From 0908342a7beade32bf0095d00ea7d295beb8d6e8 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Wed, 24 Mar 2010 00:33:22 +0000 Subject: [PATCH 001/134] Add back acpi svn path=/branches/ros-amd64-bringup/; revision=46382 --- reactos/drivers/bus/acpi/acpi.rbuild | 34 + reactos/drivers/bus/acpi/acpi.rc | 7 + reactos/drivers/bus/acpi/acpica/acpica.rbuild | 140 ++ .../bus/acpi/acpica/dispatcher/dsfield.c | 776 +++++++ .../bus/acpi/acpica/dispatcher/dsinit.c | 310 +++ .../bus/acpi/acpica/dispatcher/dsmethod.c | 762 +++++++ .../bus/acpi/acpica/dispatcher/dsmthdat.c | 846 ++++++++ .../bus/acpi/acpica/dispatcher/dsobject.c | 925 ++++++++ .../bus/acpi/acpica/dispatcher/dsopcode.c | 1619 ++++++++++++++ .../bus/acpi/acpica/dispatcher/dsutils.c | 1009 +++++++++ .../bus/acpi/acpica/dispatcher/dswexec.c | 853 ++++++++ .../bus/acpi/acpica/dispatcher/dswload.c | 1316 ++++++++++++ .../bus/acpi/acpica/dispatcher/dswscope.c | 311 +++ .../bus/acpi/acpica/dispatcher/dswstate.c | 918 ++++++++ .../drivers/bus/acpi/acpica/events/evevent.c | 430 ++++ .../drivers/bus/acpi/acpica/events/evgpe.c | 897 ++++++++ .../drivers/bus/acpi/acpica/events/evgpeblk.c | 1402 +++++++++++++ .../drivers/bus/acpi/acpica/events/evmisc.c | 740 +++++++ .../drivers/bus/acpi/acpica/events/evregion.c | 1284 ++++++++++++ .../drivers/bus/acpi/acpica/events/evrgnini.c | 799 +++++++ .../drivers/bus/acpi/acpica/events/evsci.c | 280 +++ .../drivers/bus/acpi/acpica/events/evxface.c | 967 +++++++++ .../drivers/bus/acpi/acpica/events/evxfevnt.c | 1112 ++++++++++ .../drivers/bus/acpi/acpica/events/evxfregn.c | 346 +++ .../bus/acpi/acpica/executer/exconfig.c | 751 +++++++ .../bus/acpi/acpica/executer/exconvrt.c | 826 ++++++++ .../bus/acpi/acpica/executer/excreate.c | 636 ++++++ .../drivers/bus/acpi/acpica/executer/exdump.c | 1194 +++++++++++ .../bus/acpi/acpica/executer/exfield.c | 466 +++++ .../bus/acpi/acpica/executer/exfldio.c | 1081 ++++++++++ .../drivers/bus/acpi/acpica/executer/exmisc.c | 873 ++++++++ .../bus/acpi/acpica/executer/exmutex.c | 621 ++++++ .../bus/acpi/acpica/executer/exnames.c | 560 +++++ .../bus/acpi/acpica/executer/exoparg1.c | 1183 +++++++++++ .../bus/acpi/acpica/executer/exoparg2.c | 741 +++++++ .../bus/acpi/acpica/executer/exoparg3.c | 377 ++++ .../bus/acpi/acpica/executer/exoparg6.c | 438 ++++ .../drivers/bus/acpi/acpica/executer/exprep.c | 686 ++++++ .../bus/acpi/acpica/executer/exregion.c | 630 ++++++ .../bus/acpi/acpica/executer/exresnte.c | 374 ++++ .../bus/acpi/acpica/executer/exresolv.c | 652 ++++++ .../bus/acpi/acpica/executer/exresop.c | 810 +++++++ .../bus/acpi/acpica/executer/exstore.c | 822 ++++++++ .../bus/acpi/acpica/executer/exstoren.c | 386 ++++ .../bus/acpi/acpica/executer/exstorob.c | 316 +++ .../bus/acpi/acpica/executer/exsystem.c | 418 ++++ .../bus/acpi/acpica/executer/exutils.c | 574 +++++ .../drivers/bus/acpi/acpica/hardware/hwacpi.c | 278 +++ .../drivers/bus/acpi/acpica/hardware/hwgpe.c | 597 ++++++ .../drivers/bus/acpi/acpica/hardware/hwregs.c | 805 +++++++ .../bus/acpi/acpica/hardware/hwsleep.c | 711 +++++++ .../bus/acpi/acpica/hardware/hwtimer.c | 288 +++ .../bus/acpi/acpica/hardware/hwvalid.c | 424 ++++ .../bus/acpi/acpica/hardware/hwxface.c | 710 +++++++ .../drivers/bus/acpi/acpica/include/acapps.h | 252 +++ .../bus/acpi/acpica/include/accommon.h | 136 ++ .../bus/acpi/acpica/include/acconfig.h | 279 +++ .../drivers/bus/acpi/acpica/include/acdebug.h | 449 ++++ .../bus/acpi/acpica/include/acdisasm.h | 757 +++++++ .../bus/acpi/acpica/include/acdispat.h | 527 +++++ .../bus/acpi/acpica/include/acevents.h | 375 ++++ .../drivers/bus/acpi/acpica/include/acexcep.h | 382 ++++ .../bus/acpi/acpica/include/acglobal.h | 494 +++++ .../drivers/bus/acpi/acpica/include/achware.h | 269 +++ .../bus/acpi/acpica/include/acinterp.h | 784 +++++++ .../drivers/bus/acpi/acpica/include/aclocal.h | 1332 ++++++++++++ .../bus/acpi/acpica/include/acmacros.h | 605 ++++++ .../drivers/bus/acpi/acpica/include/acnames.h | 157 ++ .../bus/acpi/acpica/include/acnamesp.h | 566 +++++ .../bus/acpi/acpica/include/acobject.h | 648 ++++++ .../bus/acpi/acpica/include/acopcode.h | 397 ++++ .../bus/acpi/acpica/include/acoutput.h | 351 ++++ .../bus/acpi/acpica/include/acparser.h | 403 ++++ .../drivers/bus/acpi/acpica/include/acpi.h | 144 ++ .../bus/acpi/acpica/include/acpiosxf.h | 495 +++++ .../drivers/bus/acpi/acpica/include/acpixf.h | 687 ++++++ .../bus/acpi/acpica/include/acpredef.h | 598 ++++++ .../drivers/bus/acpi/acpica/include/acresrc.h | 465 +++++ .../bus/acpi/acpica/include/acrestyp.h | 544 +++++ .../bus/acpi/acpica/include/acstruct.h | 326 +++ .../bus/acpi/acpica/include/actables.h | 243 +++ .../drivers/bus/acpi/acpica/include/actbl.h | 451 ++++ .../drivers/bus/acpi/acpica/include/actbl1.h | 1145 ++++++++++ .../drivers/bus/acpi/acpica/include/actbl2.h | 1124 ++++++++++ .../drivers/bus/acpi/acpica/include/actbl71.h | 144 ++ .../drivers/bus/acpi/acpica/include/actypes.h | 1248 +++++++++++ .../drivers/bus/acpi/acpica/include/acutils.h | 963 +++++++++ .../drivers/bus/acpi/acpica/include/amlcode.h | 595 ++++++ .../bus/acpi/acpica/include/amlresrc.h | 485 +++++ .../acpi/acpica/include/platform/accygwin.h | 163 ++ .../acpi/acpica/include/platform/acdos16.h | 164 ++ .../bus/acpi/acpica/include/platform/acefi.h | 147 ++ .../bus/acpi/acpica/include/platform/acenv.h | 432 ++++ .../acpi/acpica/include/platform/acfreebsd.h | 180 ++ .../bus/acpi/acpica/include/platform/acgcc.h | 179 ++ .../acpi/acpica/include/platform/acintel.h | 168 ++ .../acpi/acpica/include/platform/aclinux.h | 233 +++ .../bus/acpi/acpica/include/platform/acmsvc.h | 249 +++ .../acpi/acpica/include/platform/acnetbsd.h | 188 ++ .../bus/acpi/acpica/include/platform/acos2.h | 172 ++ .../bus/acpi/acpica/include/platform/acwin.h | 157 ++ .../acpi/acpica/include/platform/acwin64.h | 155 ++ .../bus/acpi/acpica/namespace/nsaccess.c | 772 +++++++ .../bus/acpi/acpica/namespace/nsalloc.c | 666 ++++++ .../bus/acpi/acpica/namespace/nsdump.c | 826 ++++++++ .../bus/acpi/acpica/namespace/nsdumpdv.c | 234 +++ .../bus/acpi/acpica/namespace/nseval.c | 558 +++++ .../bus/acpi/acpica/namespace/nsinit.c | 727 +++++++ .../bus/acpi/acpica/namespace/nsload.c | 428 ++++ .../bus/acpi/acpica/namespace/nsnames.c | 375 ++++ .../bus/acpi/acpica/namespace/nsobject.c | 577 +++++ .../bus/acpi/acpica/namespace/nsparse.c | 297 +++ .../bus/acpi/acpica/namespace/nspredef.c | 1263 +++++++++++ .../bus/acpi/acpica/namespace/nsrepair.c | 686 ++++++ .../bus/acpi/acpica/namespace/nsrepair2.c | 796 +++++++ .../bus/acpi/acpica/namespace/nssearch.c | 507 +++++ .../bus/acpi/acpica/namespace/nsutils.c | 1184 +++++++++++ .../bus/acpi/acpica/namespace/nswalk.c | 468 +++++ .../bus/acpi/acpica/namespace/nsxfeval.c | 1020 +++++++++ .../bus/acpi/acpica/namespace/nsxfname.c | 776 +++++++ .../bus/acpi/acpica/namespace/nsxfobj.c | 357 ++++ .../drivers/bus/acpi/acpica/parser/psargs.c | 893 ++++++++ .../drivers/bus/acpi/acpica/parser/psloop.c | 1341 ++++++++++++ .../drivers/bus/acpi/acpica/parser/psopcode.c | 589 ++++++ .../drivers/bus/acpi/acpica/parser/psparse.c | 791 +++++++ .../drivers/bus/acpi/acpica/parser/psscope.c | 374 ++++ .../drivers/bus/acpi/acpica/parser/pstree.c | 427 ++++ .../drivers/bus/acpi/acpica/parser/psutils.c | 362 ++++ .../drivers/bus/acpi/acpica/parser/pswalk.c | 193 ++ .../drivers/bus/acpi/acpica/parser/psxface.c | 510 +++++ .../bus/acpi/acpica/resources/rsaddr.c | 479 +++++ .../bus/acpi/acpica/resources/rscalc.c | 745 +++++++ .../bus/acpi/acpica/resources/rscreate.c | 533 +++++ .../bus/acpi/acpica/resources/rsdump.c | 872 ++++++++ .../bus/acpi/acpica/resources/rsinfo.c | 290 +++ .../drivers/bus/acpi/acpica/resources/rsio.c | 376 ++++ .../drivers/bus/acpi/acpica/resources/rsirq.c | 348 +++ .../bus/acpi/acpica/resources/rslist.c | 286 +++ .../bus/acpi/acpica/resources/rsmemory.c | 323 +++ .../bus/acpi/acpica/resources/rsmisc.c | 683 ++++++ .../bus/acpi/acpica/resources/rsutils.c | 874 ++++++++ .../bus/acpi/acpica/resources/rsxface.c | 713 +++++++ .../drivers/bus/acpi/acpica/tables/tbconvrt.c | 547 +++++ .../drivers/bus/acpi/acpica/tables/tbfadt.c | 752 +++++++ .../drivers/bus/acpi/acpica/tables/tbfind.c | 215 ++ .../drivers/bus/acpi/acpica/tables/tbget.c | 608 ++++++ .../drivers/bus/acpi/acpica/tables/tbinstal.c | 785 +++++++ .../drivers/bus/acpi/acpica/tables/tbutils.c | 741 +++++++ .../drivers/bus/acpi/acpica/tables/tbxface.c | 750 +++++++ .../drivers/bus/acpi/acpica/tables/tbxfroot.c | 371 ++++ .../bus/acpi/acpica/utilities/utalloc.c | 488 +++++ .../bus/acpi/acpica/utilities/utcache.c | 433 ++++ .../bus/acpi/acpica/utilities/utclib.c | 961 +++++++++ .../bus/acpi/acpica/utilities/utcopy.c | 1142 ++++++++++ .../bus/acpi/acpica/utilities/utdebug.c | 814 ++++++++ .../bus/acpi/acpica/utilities/utdelete.c | 828 ++++++++ .../bus/acpi/acpica/utilities/uteval.c | 575 +++++ .../bus/acpi/acpica/utilities/utglobal.c | 975 +++++++++ .../drivers/bus/acpi/acpica/utilities/utids.c | 497 +++++ .../bus/acpi/acpica/utilities/utinit.c | 228 ++ .../bus/acpi/acpica/utilities/utlock.c | 277 +++ .../bus/acpi/acpica/utilities/utmath.c | 431 ++++ .../bus/acpi/acpica/utilities/utmisc.c | 1485 +++++++++++++ .../bus/acpi/acpica/utilities/utmutex.c | 477 +++++ .../bus/acpi/acpica/utilities/utobject.c | 859 ++++++++ .../bus/acpi/acpica/utilities/utresrc.c | 772 +++++++ .../bus/acpi/acpica/utilities/utstate.c | 470 +++++ .../bus/acpi/acpica/utilities/uttrack.c | 726 +++++++ .../bus/acpi/acpica/utilities/utxface.c | 734 +++++++ reactos/drivers/bus/acpi/acpienum.c | 155 ++ reactos/drivers/bus/acpi/busmgr/bus.c | 1858 +++++++++++++++++ reactos/drivers/bus/acpi/busmgr/button.c | 328 +++ reactos/drivers/bus/acpi/busmgr/power.c | 679 ++++++ reactos/drivers/bus/acpi/busmgr/system.c | 427 ++++ reactos/drivers/bus/acpi/busmgr/utils.c | 376 ++++ reactos/drivers/bus/acpi/buspdo.c | 1670 +++++++++++++++ reactos/drivers/bus/acpi/cmbatt/cmbatt.c | 1328 ++++++++++++ reactos/drivers/bus/acpi/cmbatt/cmbatt.h | 282 +++ reactos/drivers/bus/acpi/cmbatt/cmbatt.rbuild | 14 + reactos/drivers/bus/acpi/cmbatt/cmbatt.rc | 5 + reactos/drivers/bus/acpi/cmbatt/cmbpnp.c | 875 ++++++++ reactos/drivers/bus/acpi/cmbatt/cmbwmi.c | 221 ++ reactos/drivers/bus/acpi/cmbatt/cmexec.c | 205 ++ reactos/drivers/bus/acpi/include/acpi_bus.h | 389 ++++ .../drivers/bus/acpi/include/acpi_drivers.h | 340 +++ reactos/drivers/bus/acpi/include/acpisys.h | 292 +++ reactos/drivers/bus/acpi/include/glue.h | 32 + reactos/drivers/bus/acpi/include/list.h | 251 +++ reactos/drivers/bus/acpi/interface.c | 138 ++ reactos/drivers/bus/acpi/main.c | 218 ++ reactos/drivers/bus/acpi/osl.c | 756 +++++++ reactos/drivers/bus/acpi/pnp.c | 586 ++++++ reactos/drivers/bus/acpi/power.c | 302 +++ 193 files changed, 112905 insertions(+) create mode 100644 reactos/drivers/bus/acpi/acpi.rbuild create mode 100644 reactos/drivers/bus/acpi/acpi.rc create mode 100644 reactos/drivers/bus/acpi/acpica/acpica.rbuild create mode 100644 reactos/drivers/bus/acpi/acpica/dispatcher/dsfield.c create mode 100644 reactos/drivers/bus/acpi/acpica/dispatcher/dsinit.c create mode 100644 reactos/drivers/bus/acpi/acpica/dispatcher/dsmethod.c create mode 100644 reactos/drivers/bus/acpi/acpica/dispatcher/dsmthdat.c create mode 100644 reactos/drivers/bus/acpi/acpica/dispatcher/dsobject.c create mode 100644 reactos/drivers/bus/acpi/acpica/dispatcher/dsopcode.c create mode 100644 reactos/drivers/bus/acpi/acpica/dispatcher/dsutils.c create mode 100644 reactos/drivers/bus/acpi/acpica/dispatcher/dswexec.c create mode 100644 reactos/drivers/bus/acpi/acpica/dispatcher/dswload.c create mode 100644 reactos/drivers/bus/acpi/acpica/dispatcher/dswscope.c create mode 100644 reactos/drivers/bus/acpi/acpica/dispatcher/dswstate.c create mode 100644 reactos/drivers/bus/acpi/acpica/events/evevent.c create mode 100644 reactos/drivers/bus/acpi/acpica/events/evgpe.c create mode 100644 reactos/drivers/bus/acpi/acpica/events/evgpeblk.c create mode 100644 reactos/drivers/bus/acpi/acpica/events/evmisc.c create mode 100644 reactos/drivers/bus/acpi/acpica/events/evregion.c create mode 100644 reactos/drivers/bus/acpi/acpica/events/evrgnini.c create mode 100644 reactos/drivers/bus/acpi/acpica/events/evsci.c create mode 100644 reactos/drivers/bus/acpi/acpica/events/evxface.c create mode 100644 reactos/drivers/bus/acpi/acpica/events/evxfevnt.c create mode 100644 reactos/drivers/bus/acpi/acpica/events/evxfregn.c create mode 100644 reactos/drivers/bus/acpi/acpica/executer/exconfig.c create mode 100644 reactos/drivers/bus/acpi/acpica/executer/exconvrt.c create mode 100644 reactos/drivers/bus/acpi/acpica/executer/excreate.c create mode 100644 reactos/drivers/bus/acpi/acpica/executer/exdump.c create mode 100644 reactos/drivers/bus/acpi/acpica/executer/exfield.c create mode 100644 reactos/drivers/bus/acpi/acpica/executer/exfldio.c create mode 100644 reactos/drivers/bus/acpi/acpica/executer/exmisc.c create mode 100644 reactos/drivers/bus/acpi/acpica/executer/exmutex.c create mode 100644 reactos/drivers/bus/acpi/acpica/executer/exnames.c create mode 100644 reactos/drivers/bus/acpi/acpica/executer/exoparg1.c create mode 100644 reactos/drivers/bus/acpi/acpica/executer/exoparg2.c create mode 100644 reactos/drivers/bus/acpi/acpica/executer/exoparg3.c create mode 100644 reactos/drivers/bus/acpi/acpica/executer/exoparg6.c create mode 100644 reactos/drivers/bus/acpi/acpica/executer/exprep.c create mode 100644 reactos/drivers/bus/acpi/acpica/executer/exregion.c create mode 100644 reactos/drivers/bus/acpi/acpica/executer/exresnte.c create mode 100644 reactos/drivers/bus/acpi/acpica/executer/exresolv.c create mode 100644 reactos/drivers/bus/acpi/acpica/executer/exresop.c create mode 100644 reactos/drivers/bus/acpi/acpica/executer/exstore.c create mode 100644 reactos/drivers/bus/acpi/acpica/executer/exstoren.c create mode 100644 reactos/drivers/bus/acpi/acpica/executer/exstorob.c create mode 100644 reactos/drivers/bus/acpi/acpica/executer/exsystem.c create mode 100644 reactos/drivers/bus/acpi/acpica/executer/exutils.c create mode 100644 reactos/drivers/bus/acpi/acpica/hardware/hwacpi.c create mode 100644 reactos/drivers/bus/acpi/acpica/hardware/hwgpe.c create mode 100644 reactos/drivers/bus/acpi/acpica/hardware/hwregs.c create mode 100644 reactos/drivers/bus/acpi/acpica/hardware/hwsleep.c create mode 100644 reactos/drivers/bus/acpi/acpica/hardware/hwtimer.c create mode 100644 reactos/drivers/bus/acpi/acpica/hardware/hwvalid.c create mode 100644 reactos/drivers/bus/acpi/acpica/hardware/hwxface.c create mode 100644 reactos/drivers/bus/acpi/acpica/include/acapps.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/accommon.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/acconfig.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/acdebug.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/acdisasm.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/acdispat.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/acevents.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/acexcep.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/acglobal.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/achware.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/acinterp.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/aclocal.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/acmacros.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/acnames.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/acnamesp.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/acobject.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/acopcode.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/acoutput.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/acparser.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/acpi.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/acpiosxf.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/acpixf.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/acpredef.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/acresrc.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/acrestyp.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/acstruct.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/actables.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/actbl.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/actbl1.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/actbl2.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/actbl71.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/actypes.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/acutils.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/amlcode.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/amlresrc.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/platform/accygwin.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/platform/acdos16.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/platform/acefi.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/platform/acenv.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/platform/acfreebsd.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/platform/acgcc.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/platform/acintel.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/platform/aclinux.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/platform/acmsvc.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/platform/acnetbsd.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/platform/acos2.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/platform/acwin.h create mode 100644 reactos/drivers/bus/acpi/acpica/include/platform/acwin64.h create mode 100644 reactos/drivers/bus/acpi/acpica/namespace/nsaccess.c create mode 100644 reactos/drivers/bus/acpi/acpica/namespace/nsalloc.c create mode 100644 reactos/drivers/bus/acpi/acpica/namespace/nsdump.c create mode 100644 reactos/drivers/bus/acpi/acpica/namespace/nsdumpdv.c create mode 100644 reactos/drivers/bus/acpi/acpica/namespace/nseval.c create mode 100644 reactos/drivers/bus/acpi/acpica/namespace/nsinit.c create mode 100644 reactos/drivers/bus/acpi/acpica/namespace/nsload.c create mode 100644 reactos/drivers/bus/acpi/acpica/namespace/nsnames.c create mode 100644 reactos/drivers/bus/acpi/acpica/namespace/nsobject.c create mode 100644 reactos/drivers/bus/acpi/acpica/namespace/nsparse.c create mode 100644 reactos/drivers/bus/acpi/acpica/namespace/nspredef.c create mode 100644 reactos/drivers/bus/acpi/acpica/namespace/nsrepair.c create mode 100644 reactos/drivers/bus/acpi/acpica/namespace/nsrepair2.c create mode 100644 reactos/drivers/bus/acpi/acpica/namespace/nssearch.c create mode 100644 reactos/drivers/bus/acpi/acpica/namespace/nsutils.c create mode 100644 reactos/drivers/bus/acpi/acpica/namespace/nswalk.c create mode 100644 reactos/drivers/bus/acpi/acpica/namespace/nsxfeval.c create mode 100644 reactos/drivers/bus/acpi/acpica/namespace/nsxfname.c create mode 100644 reactos/drivers/bus/acpi/acpica/namespace/nsxfobj.c create mode 100644 reactos/drivers/bus/acpi/acpica/parser/psargs.c create mode 100644 reactos/drivers/bus/acpi/acpica/parser/psloop.c create mode 100644 reactos/drivers/bus/acpi/acpica/parser/psopcode.c create mode 100644 reactos/drivers/bus/acpi/acpica/parser/psparse.c create mode 100644 reactos/drivers/bus/acpi/acpica/parser/psscope.c create mode 100644 reactos/drivers/bus/acpi/acpica/parser/pstree.c create mode 100644 reactos/drivers/bus/acpi/acpica/parser/psutils.c create mode 100644 reactos/drivers/bus/acpi/acpica/parser/pswalk.c create mode 100644 reactos/drivers/bus/acpi/acpica/parser/psxface.c create mode 100644 reactos/drivers/bus/acpi/acpica/resources/rsaddr.c create mode 100644 reactos/drivers/bus/acpi/acpica/resources/rscalc.c create mode 100644 reactos/drivers/bus/acpi/acpica/resources/rscreate.c create mode 100644 reactos/drivers/bus/acpi/acpica/resources/rsdump.c create mode 100644 reactos/drivers/bus/acpi/acpica/resources/rsinfo.c create mode 100644 reactos/drivers/bus/acpi/acpica/resources/rsio.c create mode 100644 reactos/drivers/bus/acpi/acpica/resources/rsirq.c create mode 100644 reactos/drivers/bus/acpi/acpica/resources/rslist.c create mode 100644 reactos/drivers/bus/acpi/acpica/resources/rsmemory.c create mode 100644 reactos/drivers/bus/acpi/acpica/resources/rsmisc.c create mode 100644 reactos/drivers/bus/acpi/acpica/resources/rsutils.c create mode 100644 reactos/drivers/bus/acpi/acpica/resources/rsxface.c create mode 100644 reactos/drivers/bus/acpi/acpica/tables/tbconvrt.c create mode 100644 reactos/drivers/bus/acpi/acpica/tables/tbfadt.c create mode 100644 reactos/drivers/bus/acpi/acpica/tables/tbfind.c create mode 100644 reactos/drivers/bus/acpi/acpica/tables/tbget.c create mode 100644 reactos/drivers/bus/acpi/acpica/tables/tbinstal.c create mode 100644 reactos/drivers/bus/acpi/acpica/tables/tbutils.c create mode 100644 reactos/drivers/bus/acpi/acpica/tables/tbxface.c create mode 100644 reactos/drivers/bus/acpi/acpica/tables/tbxfroot.c create mode 100644 reactos/drivers/bus/acpi/acpica/utilities/utalloc.c create mode 100644 reactos/drivers/bus/acpi/acpica/utilities/utcache.c create mode 100644 reactos/drivers/bus/acpi/acpica/utilities/utclib.c create mode 100644 reactos/drivers/bus/acpi/acpica/utilities/utcopy.c create mode 100644 reactos/drivers/bus/acpi/acpica/utilities/utdebug.c create mode 100644 reactos/drivers/bus/acpi/acpica/utilities/utdelete.c create mode 100644 reactos/drivers/bus/acpi/acpica/utilities/uteval.c create mode 100644 reactos/drivers/bus/acpi/acpica/utilities/utglobal.c create mode 100644 reactos/drivers/bus/acpi/acpica/utilities/utids.c create mode 100644 reactos/drivers/bus/acpi/acpica/utilities/utinit.c create mode 100644 reactos/drivers/bus/acpi/acpica/utilities/utlock.c create mode 100644 reactos/drivers/bus/acpi/acpica/utilities/utmath.c create mode 100644 reactos/drivers/bus/acpi/acpica/utilities/utmisc.c create mode 100644 reactos/drivers/bus/acpi/acpica/utilities/utmutex.c create mode 100644 reactos/drivers/bus/acpi/acpica/utilities/utobject.c create mode 100644 reactos/drivers/bus/acpi/acpica/utilities/utresrc.c create mode 100644 reactos/drivers/bus/acpi/acpica/utilities/utstate.c create mode 100644 reactos/drivers/bus/acpi/acpica/utilities/uttrack.c create mode 100644 reactos/drivers/bus/acpi/acpica/utilities/utxface.c create mode 100644 reactos/drivers/bus/acpi/acpienum.c create mode 100644 reactos/drivers/bus/acpi/busmgr/bus.c create mode 100644 reactos/drivers/bus/acpi/busmgr/button.c create mode 100644 reactos/drivers/bus/acpi/busmgr/power.c create mode 100644 reactos/drivers/bus/acpi/busmgr/system.c create mode 100644 reactos/drivers/bus/acpi/busmgr/utils.c create mode 100644 reactos/drivers/bus/acpi/buspdo.c create mode 100644 reactos/drivers/bus/acpi/cmbatt/cmbatt.c create mode 100644 reactos/drivers/bus/acpi/cmbatt/cmbatt.h create mode 100644 reactos/drivers/bus/acpi/cmbatt/cmbatt.rbuild create mode 100644 reactos/drivers/bus/acpi/cmbatt/cmbatt.rc create mode 100644 reactos/drivers/bus/acpi/cmbatt/cmbpnp.c create mode 100644 reactos/drivers/bus/acpi/cmbatt/cmbwmi.c create mode 100644 reactos/drivers/bus/acpi/cmbatt/cmexec.c create mode 100644 reactos/drivers/bus/acpi/include/acpi_bus.h create mode 100644 reactos/drivers/bus/acpi/include/acpi_drivers.h create mode 100644 reactos/drivers/bus/acpi/include/acpisys.h create mode 100644 reactos/drivers/bus/acpi/include/glue.h create mode 100644 reactos/drivers/bus/acpi/include/list.h create mode 100644 reactos/drivers/bus/acpi/interface.c create mode 100644 reactos/drivers/bus/acpi/main.c create mode 100644 reactos/drivers/bus/acpi/osl.c create mode 100644 reactos/drivers/bus/acpi/pnp.c create mode 100644 reactos/drivers/bus/acpi/power.c diff --git a/reactos/drivers/bus/acpi/acpi.rbuild b/reactos/drivers/bus/acpi/acpi.rbuild new file mode 100644 index 00000000000..4b9ec8674a5 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpi.rbuild @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + include + include + ntoskrnl + hal + wdmguid + acpica + + bus.c + button.c + power.c + utils.c + system.c + + osl.c + acpienum.c + interface.c + pnp.c + power.c + buspdo.c + main.c + diff --git a/reactos/drivers/bus/acpi/acpi.rc b/reactos/drivers/bus/acpi/acpi.rc new file mode 100644 index 00000000000..7a466943475 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpi.rc @@ -0,0 +1,7 @@ +/* $Id: acpi.rc 21698 2006-04-22 05:55:17Z tretiakov $ */ + +#define REACTOS_VERSION_DLL +#define REACTOS_STR_FILE_DESCRIPTION "ReactOS ACPI Driver\0" +#define REACTOS_STR_INTERNAL_NAME "acpi\0" +#define REACTOS_STR_ORIGINAL_FILENAME "acpi.sys\0" +#include diff --git a/reactos/drivers/bus/acpi/acpica/acpica.rbuild b/reactos/drivers/bus/acpi/acpica/acpica.rbuild new file mode 100644 index 00000000000..ce6fee8791f --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/acpica.rbuild @@ -0,0 +1,140 @@ + + + + + include + + dsfield.c + dsinit.c + dsmethod.c + dsmthdat.c + dsobject.c + dsopcode.c + dsutils.c + dswexec.c + dswload.c + dswscope.c + dswstate.c + + + evevent.c + evgpe.c + evgpeblk.c + evmisc.c + evregion.c + evrgnini.c + evsci.c + evxface.c + evxfevnt.c + evxfregn.c + + + exconfig.c + exconvrt.c + excreate.c + exdump.c + exfield.c + exfldio.c + exmisc.c + exmutex.c + exoparg1.c + exoparg2.c + exoparg3.c + exoparg6.c + exnames.c + exprep.c + exregion.c + exresnte.c + exresolv.c + exresop.c + exstore.c + exstoren.c + exstorob.c + exsystem.c + exutils.c + + + hwacpi.c + hwgpe.c + hwregs.c + hwsleep.c + hwtimer.c + hwvalid.c + hwxface.c + + + nsaccess.c + nsalloc.c + nsdump.c + nsdumpdv.c + nseval.c + nsinit.c + nsload.c + nsnames.c + nsobject.c + nsparse.c + nspredef.c + nsrepair.c + nsrepair2.c + nssearch.c + nsutils.c + nswalk.c + nsxfeval.c + nsxfname.c + nsxfobj.c + + + psargs.c + psloop.c + psopcode.c + psparse.c + psscope.c + pstree.c + psutils.c + pswalk.c + psxface.c + + + rsaddr.c + rscalc.c + rscreate.c + rsdump.c + rsinfo.c + rsio.c + rsirq.c + rslist.c + rsmemory.c + rsmisc.c + rsutils.c + rsxface.c + + + tbfadt.c + tbfind.c + tbinstal.c + tbutils.c + tbxface.c + tbxfroot.c + + + utalloc.c + utcache.c + utclib.c + utcopy.c + utdebug.c + utdelete.c + uteval.c + utglobal.c + utids.c + utinit.c + utlock.c + utmath.c + utmisc.c + utmutex.c + utobject.c + utresrc.c + utstate.c + uttrack.c + utxface.c + + diff --git a/reactos/drivers/bus/acpi/acpica/dispatcher/dsfield.c b/reactos/drivers/bus/acpi/acpica/dispatcher/dsfield.c new file mode 100644 index 00000000000..12d55f40c43 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/dispatcher/dsfield.c @@ -0,0 +1,776 @@ +/****************************************************************************** + * + * Module Name: dsfield - Dispatcher field routines + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __DSFIELD_C__ + +#include "acpi.h" +#include "accommon.h" +#include "amlcode.h" +#include "acdispat.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "acparser.h" + + +#define _COMPONENT ACPI_DISPATCHER + ACPI_MODULE_NAME ("dsfield") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiDsGetFieldNames ( + ACPI_CREATE_FIELD_INFO *Info, + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Arg); + + +/******************************************************************************* + * + * FUNCTION: AcpiDsCreateBufferField + * + * PARAMETERS: Op - Current parse op (CreateXXField) + * WalkState - Current state + * + * RETURN: Status + * + * DESCRIPTION: Execute the CreateField operators: + * CreateBitFieldOp, + * CreateByteFieldOp, + * CreateWordFieldOp, + * CreateDWordFieldOp, + * CreateQWordFieldOp, + * CreateFieldOp (all of which define a field in a buffer) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsCreateBufferField ( + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState) +{ + ACPI_PARSE_OBJECT *Arg; + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *SecondDesc = NULL; + UINT32 Flags; + + + ACPI_FUNCTION_TRACE (DsCreateBufferField); + + + /* + * Get the NameString argument (name of the new BufferField) + */ + if (Op->Common.AmlOpcode == AML_CREATE_FIELD_OP) + { + /* For CreateField, name is the 4th argument */ + + Arg = AcpiPsGetArg (Op, 3); + } + else + { + /* For all other CreateXXXField operators, name is the 3rd argument */ + + Arg = AcpiPsGetArg (Op, 2); + } + + if (!Arg) + { + return_ACPI_STATUS (AE_AML_NO_OPERAND); + } + + if (WalkState->DeferredNode) + { + Node = WalkState->DeferredNode; + Status = AE_OK; + } + else + { + /* Execute flag should always be set when this function is entered */ + + if (!(WalkState->ParseFlags & ACPI_PARSE_EXECUTE)) + { + return_ACPI_STATUS (AE_AML_INTERNAL); + } + + /* Creating new namespace node, should not already exist */ + + Flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | + ACPI_NS_ERROR_IF_FOUND; + + /* + * Mark node temporary if we are executing a normal control + * method. (Don't mark if this is a module-level code method) + */ + if (WalkState->MethodNode && + !(WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL)) + { + Flags |= ACPI_NS_TEMPORARY; + } + + /* Enter the NameString into the namespace */ + + Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String, + ACPI_TYPE_ANY, ACPI_IMODE_LOAD_PASS1, + Flags, WalkState, &Node); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR_NAMESPACE (Arg->Common.Value.String, Status); + return_ACPI_STATUS (Status); + } + } + + /* + * We could put the returned object (Node) on the object stack for later, + * but for now, we will put it in the "op" object that the parser uses, + * so we can get it again at the end of this scope. + */ + Op->Common.Node = Node; + + /* + * If there is no object attached to the node, this node was just created + * and we need to create the field object. Otherwise, this was a lookup + * of an existing node and we don't want to create the field object again. + */ + ObjDesc = AcpiNsGetAttachedObject (Node); + if (ObjDesc) + { + return_ACPI_STATUS (AE_OK); + } + + /* + * The Field definition is not fully parsed at this time. + * (We must save the address of the AML for the buffer and index operands) + */ + + /* Create the buffer field object */ + + ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER_FIELD); + if (!ObjDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* + * Remember location in AML stream of the field unit opcode and operands -- + * since the buffer and index operands must be evaluated. + */ + SecondDesc = ObjDesc->Common.NextObject; + SecondDesc->Extra.AmlStart = Op->Named.Data; + SecondDesc->Extra.AmlLength = Op->Named.Length; + ObjDesc->BufferField.Node = Node; + + /* Attach constructed field descriptors to parent node */ + + Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_BUFFER_FIELD); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + +Cleanup: + + /* Remove local reference to the object */ + + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsGetFieldNames + * + * PARAMETERS: Info - CreateField info structure + * ` WalkState - Current method state + * Arg - First parser arg for the field name list + * + * RETURN: Status + * + * DESCRIPTION: Process all named fields in a field declaration. Names are + * entered into the namespace. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDsGetFieldNames ( + ACPI_CREATE_FIELD_INFO *Info, + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Arg) +{ + ACPI_STATUS Status; + ACPI_INTEGER Position; + + + ACPI_FUNCTION_TRACE_PTR (DsGetFieldNames, Info); + + + /* First field starts at bit zero */ + + Info->FieldBitPosition = 0; + + /* Process all elements in the field list (of parse nodes) */ + + while (Arg) + { + /* + * Three types of field elements are handled: + * 1) Offset - specifies a bit offset + * 2) AccessAs - changes the access mode + * 3) Name - Enters a new named field into the namespace + */ + switch (Arg->Common.AmlOpcode) + { + case AML_INT_RESERVEDFIELD_OP: + + Position = (ACPI_INTEGER) Info->FieldBitPosition + + (ACPI_INTEGER) Arg->Common.Value.Size; + + if (Position > ACPI_UINT32_MAX) + { + ACPI_ERROR ((AE_INFO, + "Bit offset within field too large (> 0xFFFFFFFF)")); + return_ACPI_STATUS (AE_SUPPORT); + } + + Info->FieldBitPosition = (UINT32) Position; + break; + + + case AML_INT_ACCESSFIELD_OP: + + /* + * Get a new AccessType and AccessAttribute -- to be used for all + * field units that follow, until field end or another AccessAs + * keyword. + * + * In FieldFlags, preserve the flag bits other than the + * ACCESS_TYPE bits + */ + Info->FieldFlags = (UINT8) + ((Info->FieldFlags & ~(AML_FIELD_ACCESS_TYPE_MASK)) | + ((UINT8) ((UINT32) Arg->Common.Value.Integer >> 8))); + + Info->Attribute = (UINT8) (Arg->Common.Value.Integer); + break; + + + case AML_INT_NAMEDFIELD_OP: + + /* Lookup the name, it should already exist */ + + Status = AcpiNsLookup (WalkState->ScopeInfo, + (char *) &Arg->Named.Name, Info->FieldType, + ACPI_IMODE_EXECUTE, ACPI_NS_DONT_OPEN_SCOPE, + WalkState, &Info->FieldNode); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR_NAMESPACE ((char *) &Arg->Named.Name, Status); + return_ACPI_STATUS (Status); + } + else + { + Arg->Common.Node = Info->FieldNode; + Info->FieldBitLength = Arg->Common.Value.Size; + + /* + * If there is no object attached to the node, this node was + * just created and we need to create the field object. + * Otherwise, this was a lookup of an existing node and we + * don't want to create the field object again. + */ + if (!AcpiNsGetAttachedObject (Info->FieldNode)) + { + Status = AcpiExPrepFieldValue (Info); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + } + + /* Keep track of bit position for the next field */ + + Position = (ACPI_INTEGER) Info->FieldBitPosition + + (ACPI_INTEGER) Arg->Common.Value.Size; + + if (Position > ACPI_UINT32_MAX) + { + ACPI_ERROR ((AE_INFO, + "Field [%4.4s] bit offset too large (> 0xFFFFFFFF)", + ACPI_CAST_PTR (char, &Info->FieldNode->Name))); + return_ACPI_STATUS (AE_SUPPORT); + } + + Info->FieldBitPosition += Info->FieldBitLength; + break; + + + default: + + ACPI_ERROR ((AE_INFO, + "Invalid opcode in field list: %X", Arg->Common.AmlOpcode)); + return_ACPI_STATUS (AE_AML_BAD_OPCODE); + } + + Arg = Arg->Common.Next; + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsCreateField + * + * PARAMETERS: Op - Op containing the Field definition and args + * RegionNode - Object for the containing Operation Region + * ` WalkState - Current method state + * + * RETURN: Status + * + * DESCRIPTION: Create a new field in the specified operation region + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsCreateField ( + ACPI_PARSE_OBJECT *Op, + ACPI_NAMESPACE_NODE *RegionNode, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_PARSE_OBJECT *Arg; + ACPI_CREATE_FIELD_INFO Info; + + + ACPI_FUNCTION_TRACE_PTR (DsCreateField, Op); + + + /* First arg is the name of the parent OpRegion (must already exist) */ + + Arg = Op->Common.Value.Arg; + if (!RegionNode) + { + Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.Name, + ACPI_TYPE_REGION, ACPI_IMODE_EXECUTE, + ACPI_NS_SEARCH_PARENT, WalkState, &RegionNode); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR_NAMESPACE (Arg->Common.Value.Name, Status); + return_ACPI_STATUS (Status); + } + } + + /* Second arg is the field flags */ + + Arg = Arg->Common.Next; + Info.FieldFlags = (UINT8) Arg->Common.Value.Integer; + Info.Attribute = 0; + + /* Each remaining arg is a Named Field */ + + Info.FieldType = ACPI_TYPE_LOCAL_REGION_FIELD; + Info.RegionNode = RegionNode; + + Status = AcpiDsGetFieldNames (&Info, WalkState, Arg->Common.Next); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsInitFieldObjects + * + * PARAMETERS: Op - Op containing the Field definition and args + * ` WalkState - Current method state + * + * RETURN: Status + * + * DESCRIPTION: For each "Field Unit" name in the argument list that is + * part of the field declaration, enter the name into the + * namespace. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsInitFieldObjects ( + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_PARSE_OBJECT *Arg = NULL; + ACPI_NAMESPACE_NODE *Node; + UINT8 Type = 0; + UINT32 Flags; + + + ACPI_FUNCTION_TRACE_PTR (DsInitFieldObjects, Op); + + + /* Execute flag should always be set when this function is entered */ + + if (!(WalkState->ParseFlags & ACPI_PARSE_EXECUTE)) + { + if (WalkState->ParseFlags & ACPI_PARSE_DEFERRED_OP) + { + /* BankField Op is deferred, just return OK */ + + return_ACPI_STATUS (AE_OK); + } + + return_ACPI_STATUS (AE_AML_INTERNAL); + } + + /* + * Get the FieldList argument for this opcode. This is the start of the + * list of field elements. + */ + switch (WalkState->Opcode) + { + case AML_FIELD_OP: + Arg = AcpiPsGetArg (Op, 2); + Type = ACPI_TYPE_LOCAL_REGION_FIELD; + break; + + case AML_BANK_FIELD_OP: + Arg = AcpiPsGetArg (Op, 4); + Type = ACPI_TYPE_LOCAL_BANK_FIELD; + break; + + case AML_INDEX_FIELD_OP: + Arg = AcpiPsGetArg (Op, 3); + Type = ACPI_TYPE_LOCAL_INDEX_FIELD; + break; + + default: + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Creating new namespace node(s), should not already exist */ + + Flags = ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE | + ACPI_NS_ERROR_IF_FOUND; + + /* + * Mark node(s) temporary if we are executing a normal control + * method. (Don't mark if this is a module-level code method) + */ + if (WalkState->MethodNode && + !(WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL)) + { + Flags |= ACPI_NS_TEMPORARY; + } + + /* + * Walk the list of entries in the FieldList + * Note: FieldList can be of zero length. In this case, Arg will be NULL. + */ + while (Arg) + { + /* + * Ignore OFFSET and ACCESSAS terms here; we are only interested in the + * field names in order to enter them into the namespace. + */ + if (Arg->Common.AmlOpcode == AML_INT_NAMEDFIELD_OP) + { + Status = AcpiNsLookup (WalkState->ScopeInfo, + (char *) &Arg->Named.Name, Type, ACPI_IMODE_LOAD_PASS1, + Flags, WalkState, &Node); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR_NAMESPACE ((char *) &Arg->Named.Name, Status); + if (Status != AE_ALREADY_EXISTS) + { + return_ACPI_STATUS (Status); + } + + /* Name already exists, just ignore this error */ + + Status = AE_OK; + } + + Arg->Common.Node = Node; + } + + /* Get the next field element in the list */ + + Arg = Arg->Common.Next; + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsCreateBankField + * + * PARAMETERS: Op - Op containing the Field definition and args + * RegionNode - Object for the containing Operation Region + * WalkState - Current method state + * + * RETURN: Status + * + * DESCRIPTION: Create a new bank field in the specified operation region + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsCreateBankField ( + ACPI_PARSE_OBJECT *Op, + ACPI_NAMESPACE_NODE *RegionNode, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_PARSE_OBJECT *Arg; + ACPI_CREATE_FIELD_INFO Info; + + + ACPI_FUNCTION_TRACE_PTR (DsCreateBankField, Op); + + + /* First arg is the name of the parent OpRegion (must already exist) */ + + Arg = Op->Common.Value.Arg; + if (!RegionNode) + { + Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.Name, + ACPI_TYPE_REGION, ACPI_IMODE_EXECUTE, + ACPI_NS_SEARCH_PARENT, WalkState, &RegionNode); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR_NAMESPACE (Arg->Common.Value.Name, Status); + return_ACPI_STATUS (Status); + } + } + + /* Second arg is the Bank Register (Field) (must already exist) */ + + Arg = Arg->Common.Next; + Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String, + ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, + ACPI_NS_SEARCH_PARENT, WalkState, &Info.RegisterNode); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR_NAMESPACE (Arg->Common.Value.String, Status); + return_ACPI_STATUS (Status); + } + + /* + * Third arg is the BankValue + * This arg is a TermArg, not a constant + * It will be evaluated later, by AcpiDsEvalBankFieldOperands + */ + Arg = Arg->Common.Next; + + /* Fourth arg is the field flags */ + + Arg = Arg->Common.Next; + Info.FieldFlags = (UINT8) Arg->Common.Value.Integer; + + /* Each remaining arg is a Named Field */ + + Info.FieldType = ACPI_TYPE_LOCAL_BANK_FIELD; + Info.RegionNode = RegionNode; + + /* + * Use Info.DataRegisterNode to store BankField Op + * It's safe because DataRegisterNode will never be used when create bank field + * We store AmlStart and AmlLength in the BankField Op for late evaluation + * Used in AcpiExPrepFieldValue(Info) + * + * TBD: Or, should we add a field in ACPI_CREATE_FIELD_INFO, like "void *ParentOp"? + */ + Info.DataRegisterNode = (ACPI_NAMESPACE_NODE*) Op; + + Status = AcpiDsGetFieldNames (&Info, WalkState, Arg->Common.Next); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsCreateIndexField + * + * PARAMETERS: Op - Op containing the Field definition and args + * RegionNode - Object for the containing Operation Region + * ` WalkState - Current method state + * + * RETURN: Status + * + * DESCRIPTION: Create a new index field in the specified operation region + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsCreateIndexField ( + ACPI_PARSE_OBJECT *Op, + ACPI_NAMESPACE_NODE *RegionNode, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_PARSE_OBJECT *Arg; + ACPI_CREATE_FIELD_INFO Info; + + + ACPI_FUNCTION_TRACE_PTR (DsCreateIndexField, Op); + + + /* First arg is the name of the Index register (must already exist) */ + + Arg = Op->Common.Value.Arg; + Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String, + ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, + ACPI_NS_SEARCH_PARENT, WalkState, &Info.RegisterNode); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR_NAMESPACE (Arg->Common.Value.String, Status); + return_ACPI_STATUS (Status); + } + + /* Second arg is the data register (must already exist) */ + + Arg = Arg->Common.Next; + Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String, + ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, + ACPI_NS_SEARCH_PARENT, WalkState, &Info.DataRegisterNode); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR_NAMESPACE (Arg->Common.Value.String, Status); + return_ACPI_STATUS (Status); + } + + /* Next arg is the field flags */ + + Arg = Arg->Common.Next; + Info.FieldFlags = (UINT8) Arg->Common.Value.Integer; + + /* Each remaining arg is a Named Field */ + + Info.FieldType = ACPI_TYPE_LOCAL_INDEX_FIELD; + Info.RegionNode = RegionNode; + + Status = AcpiDsGetFieldNames (&Info, WalkState, Arg->Common.Next); + + return_ACPI_STATUS (Status); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/dispatcher/dsinit.c b/reactos/drivers/bus/acpi/acpica/dispatcher/dsinit.c new file mode 100644 index 00000000000..efea20e83d3 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/dispatcher/dsinit.c @@ -0,0 +1,310 @@ +/****************************************************************************** + * + * Module Name: dsinit - Object initialization namespace walk + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __DSINIT_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acdispat.h" +#include "acnamesp.h" +#include "actables.h" + +#define _COMPONENT ACPI_DISPATCHER + ACPI_MODULE_NAME ("dsinit") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiDsInitOneObject ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue); + + +/******************************************************************************* + * + * FUNCTION: AcpiDsInitOneObject + * + * PARAMETERS: ObjHandle - Node for the object + * Level - Current nesting level + * Context - Points to a init info struct + * ReturnValue - Not used + * + * RETURN: Status + * + * DESCRIPTION: Callback from AcpiWalkNamespace. Invoked for every object + * within the namespace. + * + * Currently, the only objects that require initialization are: + * 1) Methods + * 2) Operation Regions + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDsInitOneObject ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue) +{ + ACPI_INIT_WALK_INFO *Info = (ACPI_INIT_WALK_INFO *) Context; + ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; + ACPI_OBJECT_TYPE Type; + ACPI_STATUS Status; + + + ACPI_FUNCTION_ENTRY (); + + + /* + * We are only interested in NS nodes owned by the table that + * was just loaded + */ + if (Node->OwnerId != Info->OwnerId) + { + return (AE_OK); + } + + Info->ObjectCount++; + + /* And even then, we are only interested in a few object types */ + + Type = AcpiNsGetType (ObjHandle); + + switch (Type) + { + case ACPI_TYPE_REGION: + + Status = AcpiDsInitializeRegion (ObjHandle); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "During Region initialization %p [%4.4s]", + ObjHandle, AcpiUtGetNodeName (ObjHandle))); + } + + Info->OpRegionCount++; + break; + + + case ACPI_TYPE_METHOD: + + Info->MethodCount++; + break; + + + case ACPI_TYPE_DEVICE: + + Info->DeviceCount++; + break; + + + default: + break; + } + + /* + * We ignore errors from above, and always return OK, since + * we don't want to abort the walk on a single error. + */ + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsInitializeObjects + * + * PARAMETERS: TableDesc - Descriptor for parent ACPI table + * StartNode - Root of subtree to be initialized. + * + * RETURN: Status + * + * DESCRIPTION: Walk the namespace starting at "StartNode" and perform any + * necessary initialization on the objects found therein + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsInitializeObjects ( + UINT32 TableIndex, + ACPI_NAMESPACE_NODE *StartNode) +{ + ACPI_STATUS Status; + ACPI_INIT_WALK_INFO Info; + ACPI_TABLE_HEADER *Table; + ACPI_OWNER_ID OwnerId; + + + ACPI_FUNCTION_TRACE (DsInitializeObjects); + + + Status = AcpiTbGetOwnerId (TableIndex, &OwnerId); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "**** Starting initialization of namespace objects ****\n")); + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, "Parsing all Control Methods:")); + + Info.MethodCount = 0; + Info.OpRegionCount = 0; + Info.ObjectCount = 0; + Info.DeviceCount = 0; + Info.TableIndex = TableIndex; + Info.OwnerId = OwnerId; + + /* Walk entire namespace from the supplied root */ + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * We don't use AcpiWalkNamespace since we do not want to acquire + * the namespace reader lock. + */ + Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, StartNode, ACPI_UINT32_MAX, + ACPI_NS_WALK_UNLOCK, AcpiDsInitOneObject, NULL, &Info, NULL); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, "During WalkNamespace")); + } + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + + Status = AcpiGetTableByIndex (TableIndex, &Table); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, + "\nTable [%4.4s](id %4.4X) - %hd Objects with %hd Devices %hd Methods %hd 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)); + + return_ACPI_STATUS (AE_OK); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/dispatcher/dsmethod.c b/reactos/drivers/bus/acpi/acpica/dispatcher/dsmethod.c new file mode 100644 index 00000000000..48172e962e2 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/dispatcher/dsmethod.c @@ -0,0 +1,762 @@ +/****************************************************************************** + * + * Module Name: dsmethod - Parser/Interpreter interface - control method parsing + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __DSMETHOD_C__ + +#include "acpi.h" +#include "accommon.h" +#include "amlcode.h" +#include "acdispat.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "acdisasm.h" + + +#define _COMPONENT ACPI_DISPATCHER + ACPI_MODULE_NAME ("dsmethod") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiDsCreateMethodMutex ( + ACPI_OPERAND_OBJECT *MethodDesc); + + +/******************************************************************************* + * + * FUNCTION: AcpiDsMethodError + * + * PARAMETERS: Status - Execution status + * WalkState - Current state + * + * RETURN: Status + * + * DESCRIPTION: Called on method error. Invoke the global exception handler if + * present, dump the method data if the disassembler is configured + * + * Note: Allows the exception handler to change the status code + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsMethodError ( + ACPI_STATUS Status, + ACPI_WALK_STATE *WalkState) +{ + ACPI_FUNCTION_ENTRY (); + + + /* Ignore AE_OK and control exception codes */ + + if (ACPI_SUCCESS (Status) || + (Status & AE_CODE_CONTROL)) + { + return (Status); + } + + /* Invoke the global exception handler */ + + if (AcpiGbl_ExceptionHandler) + { + /* Exit the interpreter, allow handler to execute methods */ + + AcpiExExitInterpreter (); + + /* + * Handler can map the exception code to anything it wants, including + * AE_OK, in which case the executing method will not be aborted. + */ + Status = AcpiGbl_ExceptionHandler (Status, + WalkState->MethodNode ? + WalkState->MethodNode->Name.Integer : 0, + WalkState->Opcode, WalkState->AmlOffset, NULL); + AcpiExEnterInterpreter (); + } + + AcpiDsClearImplicitReturn (WalkState); + +#ifdef ACPI_DISASSEMBLER + if (ACPI_FAILURE (Status)) + { + /* Display method locals/args if disassembler is present */ + + AcpiDmDumpMethodInfo (Status, WalkState, WalkState->Op); + } +#endif + + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsCreateMethodMutex + * + * PARAMETERS: ObjDesc - The method object + * + * RETURN: Status + * + * DESCRIPTION: Create a mutex object for a serialized control method + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDsCreateMethodMutex ( + ACPI_OPERAND_OBJECT *MethodDesc) +{ + ACPI_OPERAND_OBJECT *MutexDesc; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (DsCreateMethodMutex); + + + /* Create the new mutex object */ + + MutexDesc = AcpiUtCreateInternalObject (ACPI_TYPE_MUTEX); + if (!MutexDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Create the actual OS Mutex */ + + Status = AcpiOsCreateMutex (&MutexDesc->Mutex.OsMutex); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + MutexDesc->Mutex.SyncLevel = MethodDesc->Method.SyncLevel; + MethodDesc->Method.Mutex = MutexDesc; + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsBeginMethodExecution + * + * PARAMETERS: MethodNode - Node of the method + * ObjDesc - The method object + * WalkState - current state, NULL if not yet executing + * a method. + * + * RETURN: Status + * + * DESCRIPTION: Prepare a method for execution. Parses the method if necessary, + * increments the thread count, and waits at the method semaphore + * for clearance to execute. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsBeginMethodExecution ( + ACPI_NAMESPACE_NODE *MethodNode, + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE_PTR (DsBeginMethodExecution, MethodNode); + + + if (!MethodNode) + { + return_ACPI_STATUS (AE_NULL_ENTRY); + } + + /* Prevent wraparound of thread count */ + + if (ObjDesc->Method.ThreadCount == ACPI_UINT8_MAX) + { + ACPI_ERROR ((AE_INFO, + "Method reached maximum reentrancy limit (255)")); + return_ACPI_STATUS (AE_AML_METHOD_LIMIT); + } + + /* + * If this method is serialized, we need to acquire the method mutex. + */ + if (ObjDesc->Method.MethodFlags & AML_METHOD_SERIALIZED) + { + /* + * Create a mutex for the method if it is defined to be Serialized + * and a mutex has not already been created. We defer the mutex creation + * until a method is actually executed, to minimize the object count + */ + if (!ObjDesc->Method.Mutex) + { + Status = AcpiDsCreateMethodMutex (ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* + * The CurrentSyncLevel (per-thread) must be less than or equal to + * the sync level of the method. This mechanism provides some + * deadlock prevention + * + * Top-level method invocation has no walk state at this point + */ + if (WalkState && + (WalkState->Thread->CurrentSyncLevel > ObjDesc->Method.Mutex->Mutex.SyncLevel)) + { + ACPI_ERROR ((AE_INFO, + "Cannot acquire Mutex for method [%4.4s], current SyncLevel is too large (%d)", + AcpiUtGetNodeName (MethodNode), + WalkState->Thread->CurrentSyncLevel)); + + return_ACPI_STATUS (AE_AML_MUTEX_ORDER); + } + + /* + * Obtain the method mutex if necessary. Do not acquire mutex for a + * recursive call. + */ + if (!WalkState || + !ObjDesc->Method.Mutex->Mutex.ThreadId || + (WalkState->Thread->ThreadId != ObjDesc->Method.Mutex->Mutex.ThreadId)) + { + /* + * Acquire the method mutex. This releases the interpreter if we + * block (and reacquires it before it returns) + */ + Status = AcpiExSystemWaitMutex (ObjDesc->Method.Mutex->Mutex.OsMutex, + ACPI_WAIT_FOREVER); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Update the mutex and walk info and save the original SyncLevel */ + + if (WalkState) + { + ObjDesc->Method.Mutex->Mutex.OriginalSyncLevel = + WalkState->Thread->CurrentSyncLevel; + + ObjDesc->Method.Mutex->Mutex.ThreadId = WalkState->Thread->ThreadId; + WalkState->Thread->CurrentSyncLevel = ObjDesc->Method.SyncLevel; + } + else + { + ObjDesc->Method.Mutex->Mutex.OriginalSyncLevel = + ObjDesc->Method.Mutex->Mutex.SyncLevel; + } + } + + /* Always increase acquisition depth */ + + ObjDesc->Method.Mutex->Mutex.AcquisitionDepth++; + } + + /* + * Allocate an Owner ID for this method, only if this is the first thread + * to begin concurrent execution. We only need one OwnerId, even if the + * method is invoked recursively. + */ + if (!ObjDesc->Method.OwnerId) + { + Status = AcpiUtAllocateOwnerId (&ObjDesc->Method.OwnerId); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + } + + /* + * Increment the method parse tree thread count since it has been + * reentered one more time (even if it is the same thread) + */ + ObjDesc->Method.ThreadCount++; + AcpiMethodCount++; + return_ACPI_STATUS (Status); + + +Cleanup: + /* On error, must release the method mutex (if present) */ + + if (ObjDesc->Method.Mutex) + { + AcpiOsReleaseMutex (ObjDesc->Method.Mutex->Mutex.OsMutex); + } + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsCallControlMethod + * + * PARAMETERS: Thread - Info for this thread + * ThisWalkState - Current walk state + * Op - Current Op to be walked + * + * RETURN: Status + * + * DESCRIPTION: Transfer execution to a called control method + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsCallControlMethod ( + ACPI_THREAD_STATE *Thread, + ACPI_WALK_STATE *ThisWalkState, + ACPI_PARSE_OBJECT *Op) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *MethodNode; + ACPI_WALK_STATE *NextWalkState = NULL; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_EVALUATE_INFO *Info; + UINT32 i; + + + ACPI_FUNCTION_TRACE_PTR (DsCallControlMethod, ThisWalkState); + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Calling method %p, currentstate=%p\n", + ThisWalkState->PrevOp, ThisWalkState)); + + /* + * Get the namespace entry for the control method we are about to call + */ + MethodNode = ThisWalkState->MethodCallNode; + if (!MethodNode) + { + return_ACPI_STATUS (AE_NULL_ENTRY); + } + + ObjDesc = AcpiNsGetAttachedObject (MethodNode); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NULL_OBJECT); + } + + /* Init for new method, possibly wait on method mutex */ + + Status = AcpiDsBeginMethodExecution (MethodNode, ObjDesc, + ThisWalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Begin method parse/execution. Create a new walk state */ + + NextWalkState = AcpiDsCreateWalkState (ObjDesc->Method.OwnerId, + NULL, ObjDesc, Thread); + if (!NextWalkState) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* + * The resolved arguments were put on the previous walk state's operand + * stack. Operands on the previous walk state stack always + * start at index 0. Also, null terminate the list of arguments + */ + ThisWalkState->Operands [ThisWalkState->NumOperands] = NULL; + + /* + * Allocate and initialize the evaluation information block + * TBD: this is somewhat inefficient, should change interface to + * DsInitAmlWalk. For now, keeps this struct off the CPU stack + */ + Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO)); + if (!Info) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Info->Parameters = &ThisWalkState->Operands[0]; + + Status = AcpiDsInitAmlWalk (NextWalkState, NULL, MethodNode, + ObjDesc->Method.AmlStart, ObjDesc->Method.AmlLength, + Info, ACPI_IMODE_EXECUTE); + + ACPI_FREE (Info); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* + * Delete the operands on the previous walkstate operand stack + * (they were copied to new objects) + */ + for (i = 0; i < ObjDesc->Method.ParamCount; i++) + { + AcpiUtRemoveReference (ThisWalkState->Operands [i]); + ThisWalkState->Operands [i] = NULL; + } + + /* Clear the operand stack */ + + ThisWalkState->NumOperands = 0; + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "**** Begin nested execution of [%4.4s] **** WalkState=%p\n", + MethodNode->Name.Ascii, NextWalkState)); + + /* Invoke an internal method if necessary */ + + if (ObjDesc->Method.MethodFlags & AML_METHOD_INTERNAL_ONLY) + { + Status = ObjDesc->Method.Extra.Implementation (NextWalkState); + if (Status == AE_OK) + { + Status = AE_CTRL_TERMINATE; + } + } + + return_ACPI_STATUS (Status); + + +Cleanup: + + /* On error, we must terminate the method properly */ + + AcpiDsTerminateControlMethod (ObjDesc, NextWalkState); + if (NextWalkState) + { + AcpiDsDeleteWalkState (NextWalkState); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsRestartControlMethod + * + * PARAMETERS: WalkState - State for preempted method (caller) + * ReturnDesc - Return value from the called method + * + * RETURN: Status + * + * DESCRIPTION: Restart a method that was preempted by another (nested) method + * invocation. Handle the return value (if any) from the callee. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsRestartControlMethod ( + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT *ReturnDesc) +{ + ACPI_STATUS Status; + int SameAsImplicitReturn; + + + ACPI_FUNCTION_TRACE_PTR (DsRestartControlMethod, WalkState); + + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "****Restart [%4.4s] Op %p ReturnValueFromCallee %p\n", + AcpiUtGetNodeName (WalkState->MethodNode), + WalkState->MethodCallOp, ReturnDesc)); + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + " ReturnFromThisMethodUsed?=%X ResStack %p Walk %p\n", + WalkState->ReturnUsed, + WalkState->Results, WalkState)); + + /* Did the called method return a value? */ + + if (ReturnDesc) + { + /* Is the implicit return object the same as the return desc? */ + + SameAsImplicitReturn = (WalkState->ImplicitReturnObj == ReturnDesc); + + /* Are we actually going to use the return value? */ + + if (WalkState->ReturnUsed) + { + /* Save the return value from the previous method */ + + Status = AcpiDsResultPush (ReturnDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + AcpiUtRemoveReference (ReturnDesc); + return_ACPI_STATUS (Status); + } + + /* + * Save as THIS method's return value in case it is returned + * immediately to yet another method + */ + WalkState->ReturnDesc = ReturnDesc; + } + + /* + * The following code is the optional support for the so-called + * "implicit return". Some AML code assumes that the last value of the + * method is "implicitly" returned to the caller, in the absence of an + * explicit return value. + * + * Just save the last result of the method as the return value. + * + * NOTE: this is optional because the ASL language does not actually + * support this behavior. + */ + else if (!AcpiDsDoImplicitReturn (ReturnDesc, WalkState, FALSE) || + SameAsImplicitReturn) + { + /* + * Delete the return value if it will not be used by the + * calling method or remove one reference if the explicit return + * is the same as the implicit return value. + */ + AcpiUtRemoveReference (ReturnDesc); + } + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsTerminateControlMethod + * + * PARAMETERS: MethodDesc - Method object + * WalkState - State associated with the method + * + * RETURN: None + * + * DESCRIPTION: Terminate a control method. Delete everything that the method + * created, delete all locals and arguments, and delete the parse + * tree if requested. + * + * MUTEX: Interpreter is locked + * + ******************************************************************************/ + +void +AcpiDsTerminateControlMethod ( + ACPI_OPERAND_OBJECT *MethodDesc, + ACPI_WALK_STATE *WalkState) +{ + + ACPI_FUNCTION_TRACE_PTR (DsTerminateControlMethod, WalkState); + + + /* MethodDesc is required, WalkState is optional */ + + if (!MethodDesc) + { + return_VOID; + } + + if (WalkState) + { + /* Delete all arguments and locals */ + + AcpiDsMethodDataDeleteAll (WalkState); + + /* + * If method is serialized, release the mutex and restore the + * current sync level for this thread + */ + if (MethodDesc->Method.Mutex) + { + /* Acquisition Depth handles recursive calls */ + + MethodDesc->Method.Mutex->Mutex.AcquisitionDepth--; + if (!MethodDesc->Method.Mutex->Mutex.AcquisitionDepth) + { + WalkState->Thread->CurrentSyncLevel = + MethodDesc->Method.Mutex->Mutex.OriginalSyncLevel; + + AcpiOsReleaseMutex (MethodDesc->Method.Mutex->Mutex.OsMutex); + MethodDesc->Method.Mutex->Mutex.ThreadId = 0; + } + } + + /* + * Delete any namespace objects created anywhere within the + * namespace by the execution of this method. Unless this method + * is a module-level executable code method, in which case we + * want make the objects permanent. + */ + if (!(MethodDesc->Method.Flags & AOPOBJ_MODULE_LEVEL)) + { + AcpiNsDeleteNamespaceByOwner (MethodDesc->Method.OwnerId); + } + } + + /* Decrement the thread count on the method */ + + if (MethodDesc->Method.ThreadCount) + { + MethodDesc->Method.ThreadCount--; + } + else + { + ACPI_ERROR ((AE_INFO, + "Invalid zero thread count in method")); + } + + /* Are there any other threads currently executing this method? */ + + if (MethodDesc->Method.ThreadCount) + { + /* + * Additional threads. Do not release the OwnerId in this case, + * we immediately reuse it for the next thread executing this method + */ + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "*** Completed execution of one thread, %d threads remaining\n", + MethodDesc->Method.ThreadCount)); + } + else + { + /* This is the only executing thread for this method */ + + /* + * Support to dynamically change a method from NotSerialized to + * Serialized if it appears that the method is incorrectly written and + * does not support multiple thread execution. The best example of this + * is if such a method creates namespace objects and blocks. A second + * thread will fail with an AE_ALREADY_EXISTS exception + * + * This code is here because we must wait until the last thread exits + * before creating the synchronization semaphore. + */ + if ((MethodDesc->Method.MethodFlags & AML_METHOD_SERIALIZED) && + (!MethodDesc->Method.Mutex)) + { + (void) AcpiDsCreateMethodMutex (MethodDesc); + } + + /* No more threads, we can free the OwnerId */ + + if (!(MethodDesc->Method.Flags & AOPOBJ_MODULE_LEVEL)) + { + AcpiUtReleaseOwnerId (&MethodDesc->Method.OwnerId); + } + } + + return_VOID; +} + + diff --git a/reactos/drivers/bus/acpi/acpica/dispatcher/dsmthdat.c b/reactos/drivers/bus/acpi/acpica/dispatcher/dsmthdat.c new file mode 100644 index 00000000000..551e8480a98 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/dispatcher/dsmthdat.c @@ -0,0 +1,846 @@ +/******************************************************************************* + * + * Module Name: dsmthdat - control method arguments and local variables + * + ******************************************************************************/ + +/****************************************************************************** + * + * 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 __DSMTHDAT_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acdispat.h" +#include "acnamesp.h" +#include "acinterp.h" + + +#define _COMPONENT ACPI_DISPATCHER + ACPI_MODULE_NAME ("dsmthdat") + +/* Local prototypes */ + +static void +AcpiDsMethodDataDeleteValue ( + UINT8 Type, + UINT32 Index, + ACPI_WALK_STATE *WalkState); + +static ACPI_STATUS +AcpiDsMethodDataSetValue ( + UINT8 Type, + UINT32 Index, + ACPI_OPERAND_OBJECT *Object, + ACPI_WALK_STATE *WalkState); + +#ifdef ACPI_OBSOLETE_FUNCTIONS +ACPI_OBJECT_TYPE +AcpiDsMethodDataGetType ( + UINT16 Opcode, + UINT32 Index, + ACPI_WALK_STATE *WalkState); +#endif + + +/******************************************************************************* + * + * FUNCTION: AcpiDsMethodDataInit + * + * PARAMETERS: WalkState - Current walk state object + * + * RETURN: Status + * + * DESCRIPTION: Initialize the data structures that hold the method's arguments + * and locals. The data struct is an array of namespace nodes for + * each - this allows RefOf and DeRefOf to work properly for these + * special data types. + * + * NOTES: WalkState fields are initialized to zero by the + * ACPI_ALLOCATE_ZEROED(). + * + * A pseudo-Namespace Node is assigned to each argument and local + * so that RefOf() can return a pointer to the Node. + * + ******************************************************************************/ + +void +AcpiDsMethodDataInit ( + ACPI_WALK_STATE *WalkState) +{ + UINT32 i; + + + ACPI_FUNCTION_TRACE (DsMethodDataInit); + + + /* Init the method arguments */ + + for (i = 0; i < ACPI_METHOD_NUM_ARGS; i++) + { + ACPI_MOVE_32_TO_32 (&WalkState->Arguments[i].Name, NAMEOF_ARG_NTE); + WalkState->Arguments[i].Name.Integer |= (i << 24); + WalkState->Arguments[i].DescriptorType = ACPI_DESC_TYPE_NAMED; + WalkState->Arguments[i].Type = ACPI_TYPE_ANY; + WalkState->Arguments[i].Flags = + ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_ARG; + } + + /* Init the method locals */ + + for (i = 0; i < ACPI_METHOD_NUM_LOCALS; i++) + { + ACPI_MOVE_32_TO_32 (&WalkState->LocalVariables[i].Name, NAMEOF_LOCAL_NTE); + + WalkState->LocalVariables[i].Name.Integer |= (i << 24); + WalkState->LocalVariables[i].DescriptorType = ACPI_DESC_TYPE_NAMED; + WalkState->LocalVariables[i].Type = ACPI_TYPE_ANY; + WalkState->LocalVariables[i].Flags = + ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_LOCAL; + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsMethodDataDeleteAll + * + * PARAMETERS: WalkState - Current walk state object + * + * RETURN: None + * + * DESCRIPTION: Delete method locals and arguments. Arguments are only + * deleted if this method was called from another method. + * + ******************************************************************************/ + +void +AcpiDsMethodDataDeleteAll ( + ACPI_WALK_STATE *WalkState) +{ + UINT32 Index; + + + ACPI_FUNCTION_TRACE (DsMethodDataDeleteAll); + + + /* Detach the locals */ + + for (Index = 0; Index < ACPI_METHOD_NUM_LOCALS; Index++) + { + if (WalkState->LocalVariables[Index].Object) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Local%d=%p\n", + Index, WalkState->LocalVariables[Index].Object)); + + /* Detach object (if present) and remove a reference */ + + AcpiNsDetachObject (&WalkState->LocalVariables[Index]); + } + } + + /* Detach the arguments */ + + for (Index = 0; Index < ACPI_METHOD_NUM_ARGS; Index++) + { + if (WalkState->Arguments[Index].Object) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Arg%d=%p\n", + Index, WalkState->Arguments[Index].Object)); + + /* Detach object (if present) and remove a reference */ + + AcpiNsDetachObject (&WalkState->Arguments[Index]); + } + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsMethodDataInitArgs + * + * PARAMETERS: *Params - Pointer to a parameter list for the method + * MaxParamCount - The arg count for this method + * WalkState - Current walk state object + * + * RETURN: Status + * + * DESCRIPTION: Initialize arguments for a method. The parameter list is a list + * of ACPI operand objects, either null terminated or whose length + * is defined by MaxParamCount. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsMethodDataInitArgs ( + ACPI_OPERAND_OBJECT **Params, + UINT32 MaxParamCount, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + UINT32 Index = 0; + + + ACPI_FUNCTION_TRACE_PTR (DsMethodDataInitArgs, Params); + + + if (!Params) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "No param list passed to method\n")); + return_ACPI_STATUS (AE_OK); + } + + /* Copy passed parameters into the new method stack frame */ + + while ((Index < ACPI_METHOD_NUM_ARGS) && + (Index < MaxParamCount) && + Params[Index]) + { + /* + * A valid parameter. + * Store the argument in the method/walk descriptor. + * Do not copy the arg in order to implement call by reference + */ + Status = AcpiDsMethodDataSetValue (ACPI_REFCLASS_ARG, Index, + Params[Index], WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Index++; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%d args passed to method\n", Index)); + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsMethodDataGetNode + * + * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or + * ACPI_REFCLASS_ARG + * Index - Which Local or Arg whose type to get + * WalkState - Current walk state object + * Node - Where the node is returned. + * + * RETURN: Status and node + * + * DESCRIPTION: Get the Node associated with a local or arg. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsMethodDataGetNode ( + UINT8 Type, + UINT32 Index, + ACPI_WALK_STATE *WalkState, + ACPI_NAMESPACE_NODE **Node) +{ + ACPI_FUNCTION_TRACE (DsMethodDataGetNode); + + + /* + * Method Locals and Arguments are supported + */ + switch (Type) + { + case ACPI_REFCLASS_LOCAL: + + if (Index > ACPI_METHOD_MAX_LOCAL) + { + ACPI_ERROR ((AE_INFO, + "Local index %d is invalid (max %d)", + Index, ACPI_METHOD_MAX_LOCAL)); + return_ACPI_STATUS (AE_AML_INVALID_INDEX); + } + + /* Return a pointer to the pseudo-node */ + + *Node = &WalkState->LocalVariables[Index]; + break; + + case ACPI_REFCLASS_ARG: + + if (Index > ACPI_METHOD_MAX_ARG) + { + ACPI_ERROR ((AE_INFO, + "Arg index %d is invalid (max %d)", + Index, ACPI_METHOD_MAX_ARG)); + return_ACPI_STATUS (AE_AML_INVALID_INDEX); + } + + /* Return a pointer to the pseudo-node */ + + *Node = &WalkState->Arguments[Index]; + break; + + default: + ACPI_ERROR ((AE_INFO, "Type %d is invalid", Type)); + return_ACPI_STATUS (AE_TYPE); + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsMethodDataSetValue + * + * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or + * ACPI_REFCLASS_ARG + * Index - Which Local or Arg to get + * Object - Object to be inserted into the stack entry + * WalkState - Current walk state object + * + * RETURN: Status + * + * DESCRIPTION: Insert an object onto the method stack at entry Opcode:Index. + * Note: There is no "implicit conversion" for locals. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDsMethodDataSetValue ( + UINT8 Type, + UINT32 Index, + ACPI_OPERAND_OBJECT *Object, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + + + ACPI_FUNCTION_TRACE (DsMethodDataSetValue); + + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "NewObj %p Type %2.2X, Refs=%d [%s]\n", Object, + Type, Object->Common.ReferenceCount, + AcpiUtGetTypeName (Object->Common.Type))); + + /* Get the namespace node for the arg/local */ + + Status = AcpiDsMethodDataGetNode (Type, Index, WalkState, &Node); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Increment ref count so object can't be deleted while installed. + * NOTE: We do not copy the object in order to preserve the call by + * reference semantics of ACPI Control Method invocation. + * (See ACPI Specification 2.0C) + */ + AcpiUtAddReference (Object); + + /* Install the object */ + + Node->Object = Object; + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsMethodDataGetValue + * + * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or + * ACPI_REFCLASS_ARG + * Index - Which localVar or argument to get + * WalkState - Current walk state object + * DestDesc - Where Arg or Local value is returned + * + * RETURN: Status + * + * DESCRIPTION: Retrieve value of selected Arg or Local for this method + * Used only in AcpiExResolveToValue(). + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsMethodDataGetValue ( + UINT8 Type, + UINT32 Index, + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT **DestDesc) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + ACPI_OPERAND_OBJECT *Object; + + + ACPI_FUNCTION_TRACE (DsMethodDataGetValue); + + + /* Validate the object descriptor */ + + if (!DestDesc) + { + ACPI_ERROR ((AE_INFO, "Null object descriptor pointer")); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Get the namespace node for the arg/local */ + + Status = AcpiDsMethodDataGetNode (Type, Index, WalkState, &Node); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Get the object from the node */ + + Object = Node->Object; + + /* Examine the returned object, it must be valid. */ + + if (!Object) + { + /* + * Index points to uninitialized object. + * This means that either 1) The expected argument was + * not passed to the method, or 2) A local variable + * was referenced by the method (via the ASL) + * before it was initialized. Either case is an error. + */ + + /* If slack enabled, init the LocalX/ArgX to an Integer of value zero */ + + if (AcpiGbl_EnableInterpreterSlack) + { + Object = AcpiUtCreateIntegerObject ((UINT64) 0); + if (!Object) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Node->Object = Object; + } + + /* Otherwise, return the error */ + + else switch (Type) + { + case ACPI_REFCLASS_ARG: + + ACPI_ERROR ((AE_INFO, + "Uninitialized Arg[%d] at node %p", + Index, Node)); + + return_ACPI_STATUS (AE_AML_UNINITIALIZED_ARG); + + case ACPI_REFCLASS_LOCAL: + + /* + * No error message for this case, will be trapped again later to + * detect and ignore cases of Store(LocalX,LocalX) + */ + return_ACPI_STATUS (AE_AML_UNINITIALIZED_LOCAL); + + default: + + ACPI_ERROR ((AE_INFO, "Not a Arg/Local opcode: %X", Type)); + return_ACPI_STATUS (AE_AML_INTERNAL); + } + } + + /* + * The Index points to an initialized and valid object. + * Return an additional reference to the object + */ + *DestDesc = Object; + AcpiUtAddReference (Object); + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsMethodDataDeleteValue + * + * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or + * ACPI_REFCLASS_ARG + * Index - Which localVar or argument to delete + * WalkState - Current walk state object + * + * RETURN: None + * + * DESCRIPTION: Delete the entry at Opcode:Index. Inserts + * a null into the stack slot after the object is deleted. + * + ******************************************************************************/ + +static void +AcpiDsMethodDataDeleteValue ( + UINT8 Type, + UINT32 Index, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + ACPI_OPERAND_OBJECT *Object; + + + ACPI_FUNCTION_TRACE (DsMethodDataDeleteValue); + + + /* Get the namespace node for the arg/local */ + + Status = AcpiDsMethodDataGetNode (Type, Index, WalkState, &Node); + if (ACPI_FAILURE (Status)) + { + return_VOID; + } + + /* Get the associated object */ + + Object = AcpiNsGetAttachedObject (Node); + + /* + * Undefine the Arg or Local by setting its descriptor + * pointer to NULL. Locals/Args can contain both + * ACPI_OPERAND_OBJECTS and ACPI_NAMESPACE_NODEs + */ + Node->Object = NULL; + + if ((Object) && + (ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_OPERAND)) + { + /* + * There is a valid object. + * Decrement the reference count by one to balance the + * increment when the object was stored. + */ + AcpiUtRemoveReference (Object); + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsStoreObjectToLocal + * + * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or + * ACPI_REFCLASS_ARG + * Index - Which Local or Arg to set + * ObjDesc - Value to be stored + * WalkState - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: Store a value in an Arg or Local. The ObjDesc is installed + * as the new value for the Arg or Local and the reference count + * for ObjDesc is incremented. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsStoreObjectToLocal ( + UINT8 Type, + UINT32 Index, + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + ACPI_OPERAND_OBJECT *CurrentObjDesc; + ACPI_OPERAND_OBJECT *NewObjDesc; + + + ACPI_FUNCTION_TRACE (DsStoreObjectToLocal); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Type=%2.2X Index=%d Obj=%p\n", + Type, Index, ObjDesc)); + + /* Parameter validation */ + + if (!ObjDesc) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Get the namespace node for the arg/local */ + + Status = AcpiDsMethodDataGetNode (Type, Index, WalkState, &Node); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + CurrentObjDesc = AcpiNsGetAttachedObject (Node); + if (CurrentObjDesc == ObjDesc) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p already installed!\n", + ObjDesc)); + return_ACPI_STATUS (Status); + } + + /* + * If the reference count on the object is more than one, we must + * take a copy of the object before we store. A reference count + * of exactly 1 means that the object was just created during the + * evaluation of an expression, and we can safely use it since it + * is not used anywhere else. + */ + NewObjDesc = ObjDesc; + if (ObjDesc->Common.ReferenceCount > 1) + { + Status = AcpiUtCopyIobjectToIobject (ObjDesc, &NewObjDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* + * If there is an object already in this slot, we either + * have to delete it, or if this is an argument and there + * is an object reference stored there, we have to do + * an indirect store! + */ + if (CurrentObjDesc) + { + /* + * Check for an indirect store if an argument + * contains an object reference (stored as an Node). + * We don't allow this automatic dereferencing for + * locals, since a store to a local should overwrite + * anything there, including an object reference. + * + * If both Arg0 and Local0 contain RefOf (Local4): + * + * Store (1, Arg0) - Causes indirect store to local4 + * Store (1, Local0) - Stores 1 in local0, overwriting + * the reference to local4 + * Store (1, DeRefof (Local0)) - Causes indirect store to local4 + * + * Weird, but true. + */ + if (Type == ACPI_REFCLASS_ARG) + { + /* + * If we have a valid reference object that came from RefOf(), + * do the indirect store + */ + if ((ACPI_GET_DESCRIPTOR_TYPE (CurrentObjDesc) == ACPI_DESC_TYPE_OPERAND) && + (CurrentObjDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) && + (CurrentObjDesc->Reference.Class == ACPI_REFCLASS_REFOF)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Arg (%p) is an ObjRef(Node), storing in node %p\n", + NewObjDesc, CurrentObjDesc)); + + /* + * Store this object to the Node (perform the indirect store) + * NOTE: No implicit conversion is performed, as per the ACPI + * specification rules on storing to Locals/Args. + */ + Status = AcpiExStoreObjectToNode (NewObjDesc, + CurrentObjDesc->Reference.Object, WalkState, + ACPI_NO_IMPLICIT_CONVERSION); + + /* Remove local reference if we copied the object above */ + + if (NewObjDesc != ObjDesc) + { + AcpiUtRemoveReference (NewObjDesc); + } + return_ACPI_STATUS (Status); + } + } + + /* Delete the existing object before storing the new one */ + + AcpiDsMethodDataDeleteValue (Type, Index, WalkState); + } + + /* + * Install the Obj descriptor (*NewObjDesc) into + * the descriptor for the Arg or Local. + * (increments the object reference count by one) + */ + Status = AcpiDsMethodDataSetValue (Type, Index, NewObjDesc, WalkState); + + /* Remove local reference if we copied the object above */ + + if (NewObjDesc != ObjDesc) + { + AcpiUtRemoveReference (NewObjDesc); + } + + return_ACPI_STATUS (Status); +} + + +#ifdef ACPI_OBSOLETE_FUNCTIONS +/******************************************************************************* + * + * FUNCTION: AcpiDsMethodDataGetType + * + * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP + * Index - Which Local or Arg whose type to get + * WalkState - Current walk state object + * + * RETURN: Data type of current value of the selected Arg or Local + * + * DESCRIPTION: Get the type of the object stored in the Local or Arg + * + ******************************************************************************/ + +ACPI_OBJECT_TYPE +AcpiDsMethodDataGetType ( + UINT16 Opcode, + UINT32 Index, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + ACPI_OPERAND_OBJECT *Object; + + + ACPI_FUNCTION_TRACE (DsMethodDataGetType); + + + /* Get the namespace node for the arg/local */ + + Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node); + if (ACPI_FAILURE (Status)) + { + return_VALUE ((ACPI_TYPE_NOT_FOUND)); + } + + /* Get the object */ + + Object = AcpiNsGetAttachedObject (Node); + if (!Object) + { + /* Uninitialized local/arg, return TYPE_ANY */ + + return_VALUE (ACPI_TYPE_ANY); + } + + /* Get the object type */ + + return_VALUE (Object->Type); +} +#endif + + diff --git a/reactos/drivers/bus/acpi/acpica/dispatcher/dsobject.c b/reactos/drivers/bus/acpi/acpica/dispatcher/dsobject.c new file mode 100644 index 00000000000..cf444a1df2b --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/dispatcher/dsobject.c @@ -0,0 +1,925 @@ +/****************************************************************************** + * + * Module Name: dsobject - Dispatcher object management routines + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __DSOBJECT_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acparser.h" +#include "amlcode.h" +#include "acdispat.h" +#include "acnamesp.h" +#include "acinterp.h" + +#define _COMPONENT ACPI_DISPATCHER + ACPI_MODULE_NAME ("dsobject") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiDsBuildInternalObject ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + ACPI_OPERAND_OBJECT **ObjDescPtr); + + +#ifndef ACPI_NO_METHOD_EXECUTION +/******************************************************************************* + * + * FUNCTION: AcpiDsBuildInternalObject + * + * PARAMETERS: WalkState - Current walk state + * Op - Parser object to be translated + * ObjDescPtr - Where the ACPI internal object is returned + * + * RETURN: Status + * + * DESCRIPTION: Translate a parser Op object to the equivalent namespace object + * Simple objects are any objects other than a package object! + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDsBuildInternalObject ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + ACPI_OPERAND_OBJECT **ObjDescPtr) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (DsBuildInternalObject); + + + *ObjDescPtr = NULL; + if (Op->Common.AmlOpcode == AML_INT_NAMEPATH_OP) + { + /* + * This is a named object reference. If this name was + * previously looked up in the namespace, it was stored in this op. + * Otherwise, go ahead and look it up now + */ + if (!Op->Common.Node) + { + Status = AcpiNsLookup (WalkState->ScopeInfo, + Op->Common.Value.String, + ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, + ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, NULL, + ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, &(Op->Common.Node))); + if (ACPI_FAILURE (Status)) + { + /* Check if we are resolving a named reference within a package */ + + if ((Status == AE_NOT_FOUND) && (AcpiGbl_EnableInterpreterSlack) && + + ((Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP))) + { + /* + * We didn't find the target and we are populating elements + * of a package - ignore if slack enabled. Some ASL code + * contains dangling invalid references in packages and + * expects that no exception will be issued. Leave the + * element as a null element. It cannot be used, but it + * can be overwritten by subsequent ASL code - this is + * typically the case. + */ + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Ignoring unresolved reference in package [%4.4s]\n", + WalkState->ScopeInfo->Scope.Node->Name.Ascii)); + + return_ACPI_STATUS (AE_OK); + } + else + { + ACPI_ERROR_NAMESPACE (Op->Common.Value.String, Status); + } + + return_ACPI_STATUS (Status); + } + } + + /* Special object resolution for elements of a package */ + + if ((Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP)) + { + /* + * Attempt to resolve the node to a value before we insert it into + * the package. If this is a reference to a common data type, + * resolve it immediately. According to the ACPI spec, package + * elements can only be "data objects" or method references. + * Attempt to resolve to an Integer, Buffer, String or Package. + * If cannot, return the named reference (for things like Devices, + * Methods, etc.) Buffer Fields and Fields will resolve to simple + * objects (int/buf/str/pkg). + * + * NOTE: References to things like Devices, Methods, Mutexes, etc. + * will remain as named references. This behavior is not described + * in the ACPI spec, but it appears to be an oversight. + */ + ObjDesc = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Op->Common.Node); + + Status = AcpiExResolveNodeToValue ( + ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, &ObjDesc), + WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + switch (Op->Common.Node->Type) + { + /* + * For these types, we need the actual node, not the subobject. + * However, the subobject did not get an extra reference count above. + * + * TBD: should ExResolveNodeToValue be changed to fix this? + */ + case ACPI_TYPE_DEVICE: + case ACPI_TYPE_THERMAL: + + AcpiUtAddReference (Op->Common.Node->Object); + + /*lint -fallthrough */ + /* + * For these types, we need the actual node, not the subobject. + * The subobject got an extra reference count in ExResolveNodeToValue. + */ + case ACPI_TYPE_MUTEX: + case ACPI_TYPE_METHOD: + case ACPI_TYPE_POWER: + case ACPI_TYPE_PROCESSOR: + case ACPI_TYPE_EVENT: + case ACPI_TYPE_REGION: + + /* We will create a reference object for these types below */ + break; + + default: + /* + * All other types - the node was resolved to an actual + * object, we are done. + */ + goto Exit; + } + } + } + + /* Create and init a new internal ACPI object */ + + ObjDesc = AcpiUtCreateInternalObject ( + (AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode))->ObjectType); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Status = AcpiDsInitObjectFromOp (WalkState, Op, Op->Common.AmlOpcode, + &ObjDesc); + if (ACPI_FAILURE (Status)) + { + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); + } + +Exit: + *ObjDescPtr = ObjDesc; + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsBuildInternalBufferObj + * + * PARAMETERS: WalkState - Current walk state + * Op - Parser object to be translated + * BufferLength - Length of the buffer + * ObjDescPtr - Where the ACPI internal object is returned + * + * RETURN: Status + * + * DESCRIPTION: Translate a parser Op package object to the equivalent + * namespace object + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsBuildInternalBufferObj ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + UINT32 BufferLength, + ACPI_OPERAND_OBJECT **ObjDescPtr) +{ + ACPI_PARSE_OBJECT *Arg; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_PARSE_OBJECT *ByteList; + UINT32 ByteListLength = 0; + + + ACPI_FUNCTION_TRACE (DsBuildInternalBufferObj); + + + /* + * If we are evaluating a Named buffer object "Name (xxxx, Buffer)". + * The buffer object already exists (from the NS node), otherwise it must + * be created. + */ + ObjDesc = *ObjDescPtr; + if (!ObjDesc) + { + /* Create a new buffer object */ + + ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER); + *ObjDescPtr = ObjDesc; + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + } + + /* + * Second arg is the buffer data (optional) ByteList can be either + * individual bytes or a string initializer. In either case, a + * ByteList appears in the AML. + */ + Arg = Op->Common.Value.Arg; /* skip first arg */ + + ByteList = Arg->Named.Next; + if (ByteList) + { + if (ByteList->Common.AmlOpcode != AML_INT_BYTELIST_OP) + { + ACPI_ERROR ((AE_INFO, + "Expecting bytelist, got AML opcode %X in op %p", + ByteList->Common.AmlOpcode, ByteList)); + + AcpiUtRemoveReference (ObjDesc); + return (AE_TYPE); + } + + ByteListLength = (UINT32) ByteList->Common.Value.Integer; + } + + /* + * The buffer length (number of bytes) will be the larger of: + * 1) The specified buffer length and + * 2) The length of the initializer byte list + */ + ObjDesc->Buffer.Length = BufferLength; + if (ByteListLength > BufferLength) + { + ObjDesc->Buffer.Length = ByteListLength; + } + + /* Allocate the buffer */ + + if (ObjDesc->Buffer.Length == 0) + { + ObjDesc->Buffer.Pointer = NULL; + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Buffer defined with zero length in AML, creating\n")); + } + else + { + ObjDesc->Buffer.Pointer = ACPI_ALLOCATE_ZEROED ( + ObjDesc->Buffer.Length); + if (!ObjDesc->Buffer.Pointer) + { + AcpiUtDeleteObjectDesc (ObjDesc); + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Initialize buffer from the ByteList (if present) */ + + if (ByteList) + { + ACPI_MEMCPY (ObjDesc->Buffer.Pointer, ByteList->Named.Data, + ByteListLength); + } + } + + ObjDesc->Buffer.Flags |= AOPOBJ_DATA_VALID; + Op->Common.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjDesc); + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsBuildInternalPackageObj + * + * PARAMETERS: WalkState - Current walk state + * Op - Parser object to be translated + * ElementCount - Number of elements in the package - this is + * the NumElements argument to Package() + * ObjDescPtr - Where the ACPI internal object is returned + * + * RETURN: Status + * + * DESCRIPTION: Translate a parser Op package object to the equivalent + * namespace object + * + * NOTE: The number of elements in the package will be always be the NumElements + * count, regardless of the number of elements in the package list. If + * NumElements is smaller, only that many package list elements are used. + * if NumElements is larger, the Package object is padded out with + * objects of type Uninitialized (as per ACPI spec.) + * + * Even though the ASL compilers do not allow NumElements to be smaller + * than the Package list length (for the fixed length package opcode), some + * BIOS code modifies the AML on the fly to adjust the NumElements, and + * this code compensates for that. This also provides compatibility with + * other AML interpreters. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsBuildInternalPackageObj ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + UINT32 ElementCount, + ACPI_OPERAND_OBJECT **ObjDescPtr) +{ + ACPI_PARSE_OBJECT *Arg; + ACPI_PARSE_OBJECT *Parent; + ACPI_OPERAND_OBJECT *ObjDesc = NULL; + ACPI_STATUS Status = AE_OK; + UINT32 i; + UINT16 Index; + UINT16 ReferenceCount; + + + ACPI_FUNCTION_TRACE (DsBuildInternalPackageObj); + + + /* Find the parent of a possibly nested package */ + + Parent = Op->Common.Parent; + while ((Parent->Common.AmlOpcode == AML_PACKAGE_OP) || + (Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP)) + { + Parent = Parent->Common.Parent; + } + + /* + * If we are evaluating a Named package object "Name (xxxx, Package)", + * the package object already exists, otherwise it must be created. + */ + ObjDesc = *ObjDescPtr; + if (!ObjDesc) + { + ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_PACKAGE); + *ObjDescPtr = ObjDesc; + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + ObjDesc->Package.Node = Parent->Common.Node; + } + + /* + * Allocate the element array (array of pointers to the individual + * objects) based on the NumElements parameter. Add an extra pointer slot + * so that the list is always null terminated. + */ + ObjDesc->Package.Elements = ACPI_ALLOCATE_ZEROED ( + ((ACPI_SIZE) ElementCount + 1) * sizeof (void *)); + + if (!ObjDesc->Package.Elements) + { + AcpiUtDeleteObjectDesc (ObjDesc); + return_ACPI_STATUS (AE_NO_MEMORY); + } + + ObjDesc->Package.Count = ElementCount; + + /* + * Initialize the elements of the package, up to the NumElements count. + * Package is automatically padded with uninitialized (NULL) elements + * if NumElements is greater than the package list length. Likewise, + * Package is truncated if NumElements is less than the list length. + */ + Arg = Op->Common.Value.Arg; + Arg = Arg->Common.Next; + for (i = 0; Arg && (i < ElementCount); i++) + { + if (Arg->Common.AmlOpcode == AML_INT_RETURN_VALUE_OP) + { + if (Arg->Common.Node->Type == ACPI_TYPE_METHOD) + { + /* + * A method reference "looks" to the parser to be a method + * invocation, so we special case it here + */ + Arg->Common.AmlOpcode = AML_INT_NAMEPATH_OP; + Status = AcpiDsBuildInternalObject (WalkState, Arg, + &ObjDesc->Package.Elements[i]); + } + else + { + /* This package element is already built, just get it */ + + ObjDesc->Package.Elements[i] = + ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Arg->Common.Node); + } + } + else + { + Status = AcpiDsBuildInternalObject (WalkState, Arg, + &ObjDesc->Package.Elements[i]); + } + + if (*ObjDescPtr) + { + /* Existing package, get existing reference count */ + + ReferenceCount = (*ObjDescPtr)->Common.ReferenceCount; + if (ReferenceCount > 1) + { + /* Make new element ref count match original ref count */ + + for (Index = 0; Index < (ReferenceCount - 1); Index++) + { + AcpiUtAddReference ((ObjDesc->Package.Elements[i])); + } + } + } + + Arg = Arg->Common.Next; + } + + /* Check for match between NumElements and actual length of PackageList */ + + if (Arg) + { + /* + * NumElements was exhausted, but there are remaining elements in the + * PackageList. Truncate the package to NumElements. + * + * Note: technically, this is an error, from ACPI spec: "It is an error + * for NumElements to be less than the number of elements in the + * PackageList". However, we just print a message and + * no exception is returned. This provides Windows compatibility. Some + * BIOSs will alter the NumElements on the fly, creating this type + * of ill-formed package object. + */ + while (Arg) + { + /* + * We must delete any package elements that were created earlier + * and are not going to be used because of the package truncation. + */ + if (Arg->Common.Node) + { + AcpiUtRemoveReference ( + ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Arg->Common.Node)); + Arg->Common.Node = NULL; + } + + /* Find out how many elements there really are */ + + i++; + Arg = Arg->Common.Next; + } + + ACPI_INFO ((AE_INFO, + "Actual Package length (0x%X) is larger than NumElements field (0x%X), truncated\n", + i, ElementCount)); + } + else if (i < ElementCount) + { + /* + * Arg list (elements) was exhausted, but we did not reach NumElements count. + * Note: this is not an error, the package is padded out with NULLs. + */ + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Package List length (0x%X) smaller than NumElements count (0x%X), padded with null elements\n", + i, ElementCount)); + } + + ObjDesc->Package.Flags |= AOPOBJ_DATA_VALID; + Op->Common.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjDesc); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsCreateNode + * + * PARAMETERS: WalkState - Current walk state + * Node - NS Node to be initialized + * Op - Parser object to be translated + * + * RETURN: Status + * + * DESCRIPTION: Create the object to be associated with a namespace node + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsCreateNode ( + ACPI_WALK_STATE *WalkState, + ACPI_NAMESPACE_NODE *Node, + ACPI_PARSE_OBJECT *Op) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ObjDesc; + + + ACPI_FUNCTION_TRACE_PTR (DsCreateNode, Op); + + + /* + * Because of the execution pass through the non-control-method + * parts of the table, we can arrive here twice. Only init + * the named object node the first time through + */ + if (AcpiNsGetAttachedObject (Node)) + { + return_ACPI_STATUS (AE_OK); + } + + if (!Op->Common.Value.Arg) + { + /* No arguments, there is nothing to do */ + + return_ACPI_STATUS (AE_OK); + } + + /* Build an internal object for the argument(s) */ + + Status = AcpiDsBuildInternalObject (WalkState, Op->Common.Value.Arg, + &ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Re-type the object according to its argument */ + + Node->Type = ObjDesc->Common.Type; + + /* Attach obj to node */ + + Status = AcpiNsAttachObject (Node, ObjDesc, Node->Type); + + /* Remove local reference to the object */ + + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); +} + +#endif /* ACPI_NO_METHOD_EXECUTION */ + + +/******************************************************************************* + * + * FUNCTION: AcpiDsInitObjectFromOp + * + * PARAMETERS: WalkState - Current walk state + * Op - Parser op used to init the internal object + * Opcode - AML opcode associated with the object + * RetObjDesc - Namespace object to be initialized + * + * RETURN: Status + * + * DESCRIPTION: Initialize a namespace object from a parser Op and its + * associated arguments. The namespace object is a more compact + * representation of the Op and its arguments. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsInitObjectFromOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + UINT16 Opcode, + ACPI_OPERAND_OBJECT **RetObjDesc) +{ + const ACPI_OPCODE_INFO *OpInfo; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (DsInitObjectFromOp); + + + ObjDesc = *RetObjDesc; + OpInfo = AcpiPsGetOpcodeInfo (Opcode); + if (OpInfo->Class == AML_CLASS_UNKNOWN) + { + /* Unknown opcode */ + + return_ACPI_STATUS (AE_TYPE); + } + + /* Perform per-object initialization */ + + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_BUFFER: + + /* + * Defer evaluation of Buffer TermArg operand + */ + ObjDesc->Buffer.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, + WalkState->Operands[0]); + ObjDesc->Buffer.AmlStart = Op->Named.Data; + ObjDesc->Buffer.AmlLength = Op->Named.Length; + break; + + + case ACPI_TYPE_PACKAGE: + + /* + * Defer evaluation of Package TermArg operand + */ + ObjDesc->Package.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, + WalkState->Operands[0]); + ObjDesc->Package.AmlStart = Op->Named.Data; + ObjDesc->Package.AmlLength = Op->Named.Length; + break; + + + case ACPI_TYPE_INTEGER: + + switch (OpInfo->Type) + { + case AML_TYPE_CONSTANT: + /* + * Resolve AML Constants here - AND ONLY HERE! + * All constants are integers. + * We mark the integer with a flag that indicates that it started + * life as a constant -- so that stores to constants will perform + * as expected (noop). ZeroOp is used as a placeholder for optional + * target operands. + */ + ObjDesc->Common.Flags = AOPOBJ_AML_CONSTANT; + + switch (Opcode) + { + case AML_ZERO_OP: + + ObjDesc->Integer.Value = 0; + break; + + case AML_ONE_OP: + + ObjDesc->Integer.Value = 1; + break; + + case AML_ONES_OP: + + ObjDesc->Integer.Value = ACPI_INTEGER_MAX; + + /* Truncate value if we are executing from a 32-bit ACPI table */ + +#ifndef ACPI_NO_METHOD_EXECUTION + AcpiExTruncateFor32bitTable (ObjDesc); +#endif + break; + + case AML_REVISION_OP: + + ObjDesc->Integer.Value = ACPI_CA_VERSION; + break; + + default: + + ACPI_ERROR ((AE_INFO, + "Unknown constant opcode %X", Opcode)); + Status = AE_AML_OPERAND_TYPE; + break; + } + break; + + + case AML_TYPE_LITERAL: + + ObjDesc->Integer.Value = Op->Common.Value.Integer; +#ifndef ACPI_NO_METHOD_EXECUTION + AcpiExTruncateFor32bitTable (ObjDesc); +#endif + break; + + + default: + ACPI_ERROR ((AE_INFO, "Unknown Integer type %X", + OpInfo->Type)); + Status = AE_AML_OPERAND_TYPE; + break; + } + break; + + + case ACPI_TYPE_STRING: + + ObjDesc->String.Pointer = Op->Common.Value.String; + ObjDesc->String.Length = (UINT32) ACPI_STRLEN (Op->Common.Value.String); + + /* + * The string is contained in the ACPI table, don't ever try + * to delete it + */ + ObjDesc->Common.Flags |= AOPOBJ_STATIC_POINTER; + break; + + + case ACPI_TYPE_METHOD: + break; + + + case ACPI_TYPE_LOCAL_REFERENCE: + + switch (OpInfo->Type) + { + case AML_TYPE_LOCAL_VARIABLE: + + /* Local ID (0-7) is (AML opcode - base AML_LOCAL_OP) */ + + ObjDesc->Reference.Value = ((UINT32) Opcode) - AML_LOCAL_OP; + ObjDesc->Reference.Class = ACPI_REFCLASS_LOCAL; + +#ifndef ACPI_NO_METHOD_EXECUTION + Status = AcpiDsMethodDataGetNode (ACPI_REFCLASS_LOCAL, + ObjDesc->Reference.Value, WalkState, + ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, + &ObjDesc->Reference.Object)); +#endif + break; + + + case AML_TYPE_METHOD_ARGUMENT: + + /* Arg ID (0-6) is (AML opcode - base AML_ARG_OP) */ + + ObjDesc->Reference.Value = ((UINT32) Opcode) - AML_ARG_OP; + ObjDesc->Reference.Class = ACPI_REFCLASS_ARG; + +#ifndef ACPI_NO_METHOD_EXECUTION + Status = AcpiDsMethodDataGetNode (ACPI_REFCLASS_ARG, + ObjDesc->Reference.Value, WalkState, + ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, + &ObjDesc->Reference.Object)); +#endif + break; + + default: /* Object name or Debug object */ + + switch (Op->Common.AmlOpcode) + { + case AML_INT_NAMEPATH_OP: + + /* Node was saved in Op */ + + ObjDesc->Reference.Node = Op->Common.Node; + ObjDesc->Reference.Object = Op->Common.Node->Object; + ObjDesc->Reference.Class = ACPI_REFCLASS_NAME; + break; + + case AML_DEBUG_OP: + + ObjDesc->Reference.Class = ACPI_REFCLASS_DEBUG; + break; + + default: + + ACPI_ERROR ((AE_INFO, + "Unimplemented reference type for AML opcode: %4.4X", Opcode)); + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + break; + } + break; + + + default: + + ACPI_ERROR ((AE_INFO, "Unimplemented data type: %X", + ObjDesc->Common.Type)); + + Status = AE_AML_OPERAND_TYPE; + break; + } + + return_ACPI_STATUS (Status); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/dispatcher/dsopcode.c b/reactos/drivers/bus/acpi/acpica/dispatcher/dsopcode.c new file mode 100644 index 00000000000..3edbacc1d95 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/dispatcher/dsopcode.c @@ -0,0 +1,1619 @@ +/****************************************************************************** + * + * Module Name: dsopcode - Dispatcher Op Region support and handling of + * "control" opcodes + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __DSOPCODE_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acparser.h" +#include "amlcode.h" +#include "acdispat.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "acevents.h" +#include "actables.h" + +#define _COMPONENT ACPI_DISPATCHER + ACPI_MODULE_NAME ("dsopcode") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiDsExecuteArguments ( + ACPI_NAMESPACE_NODE *Node, + ACPI_NAMESPACE_NODE *ScopeNode, + UINT32 AmlLength, + UINT8 *AmlStart); + +static ACPI_STATUS +AcpiDsInitBufferField ( + UINT16 AmlOpcode, + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT *BufferDesc, + ACPI_OPERAND_OBJECT *OffsetDesc, + ACPI_OPERAND_OBJECT *LengthDesc, + ACPI_OPERAND_OBJECT *ResultDesc); + + +/******************************************************************************* + * + * FUNCTION: 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 + * + * PARAMETERS: ObjHandle - Region namespace node + * + * RETURN: Status + * + * DESCRIPTION: Front end to EvInitializeRegion + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsInitializeRegion ( + ACPI_HANDLE ObjHandle) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + + + ObjDesc = AcpiNsGetAttachedObject (ObjHandle); + + /* Namespace is NOT locked */ + + Status = AcpiEvInitializeRegion (ObjDesc, FALSE); + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsInitBufferField + * + * PARAMETERS: AmlOpcode - CreateXxxField + * ObjDesc - BufferField object + * BufferDesc - Host Buffer + * OffsetDesc - Offset into buffer + * LengthDesc - Length of field (CREATE_FIELD_OP only) + * ResultDesc - Where to store the result + * + * RETURN: Status + * + * DESCRIPTION: Perform actual initialization of a buffer field + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDsInitBufferField ( + UINT16 AmlOpcode, + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT *BufferDesc, + ACPI_OPERAND_OBJECT *OffsetDesc, + ACPI_OPERAND_OBJECT *LengthDesc, + ACPI_OPERAND_OBJECT *ResultDesc) +{ + UINT32 Offset; + UINT32 BitOffset; + UINT32 BitCount; + UINT8 FieldFlags; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE_PTR (DsInitBufferField, ObjDesc); + + + /* Host object must be a Buffer */ + + if (BufferDesc->Common.Type != ACPI_TYPE_BUFFER) + { + ACPI_ERROR ((AE_INFO, + "Target of Create Field is not a Buffer object - %s", + AcpiUtGetObjectTypeName (BufferDesc))); + + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + + /* + * The last parameter to all of these opcodes (ResultDesc) started + * out as a NameString, and should therefore now be a NS node + * after resolution in AcpiExResolveOperands(). + */ + if (ACPI_GET_DESCRIPTOR_TYPE (ResultDesc) != ACPI_DESC_TYPE_NAMED) + { + ACPI_ERROR ((AE_INFO, + "(%s) destination not a NS Node [%s]", + AcpiPsGetOpcodeName (AmlOpcode), + AcpiUtGetDescriptorName (ResultDesc))); + + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + + Offset = (UINT32) OffsetDesc->Integer.Value; + + /* + * Setup the Bit offsets and counts, according to the opcode + */ + switch (AmlOpcode) + { + case AML_CREATE_FIELD_OP: + + /* Offset is in bits, count is in bits */ + + FieldFlags = AML_FIELD_ACCESS_BYTE; + BitOffset = Offset; + BitCount = (UINT32) LengthDesc->Integer.Value; + + /* Must have a valid (>0) bit count */ + + if (BitCount == 0) + { + ACPI_ERROR ((AE_INFO, + "Attempt to CreateField of length zero")); + Status = AE_AML_OPERAND_VALUE; + goto Cleanup; + } + break; + + case AML_CREATE_BIT_FIELD_OP: + + /* Offset is in bits, Field is one bit */ + + BitOffset = Offset; + BitCount = 1; + FieldFlags = AML_FIELD_ACCESS_BYTE; + break; + + case AML_CREATE_BYTE_FIELD_OP: + + /* Offset is in bytes, field is one byte */ + + BitOffset = 8 * Offset; + BitCount = 8; + FieldFlags = AML_FIELD_ACCESS_BYTE; + break; + + case AML_CREATE_WORD_FIELD_OP: + + /* Offset is in bytes, field is one word */ + + BitOffset = 8 * Offset; + BitCount = 16; + FieldFlags = AML_FIELD_ACCESS_WORD; + break; + + case AML_CREATE_DWORD_FIELD_OP: + + /* Offset is in bytes, field is one dword */ + + BitOffset = 8 * Offset; + BitCount = 32; + FieldFlags = AML_FIELD_ACCESS_DWORD; + break; + + case AML_CREATE_QWORD_FIELD_OP: + + /* Offset is in bytes, field is one qword */ + + BitOffset = 8 * Offset; + BitCount = 64; + FieldFlags = AML_FIELD_ACCESS_QWORD; + break; + + default: + + ACPI_ERROR ((AE_INFO, + "Unknown field creation opcode %02x", + AmlOpcode)); + Status = AE_AML_BAD_OPCODE; + goto Cleanup; + } + + /* Entire field must fit within the current length of the buffer */ + + if ((BitOffset + BitCount) > + (8 * (UINT32) BufferDesc->Buffer.Length)) + { + ACPI_ERROR ((AE_INFO, + "Field [%4.4s] at %d exceeds Buffer [%4.4s] size %d (bits)", + AcpiUtGetNodeName (ResultDesc), + BitOffset + BitCount, + AcpiUtGetNodeName (BufferDesc->Buffer.Node), + 8 * (UINT32) BufferDesc->Buffer.Length)); + Status = AE_AML_BUFFER_LIMIT; + goto Cleanup; + } + + /* + * Initialize areas of the field object that are common to all fields + * For FieldFlags, use LOCK_RULE = 0 (NO_LOCK), + * UPDATE_RULE = 0 (UPDATE_PRESERVE) + */ + Status = AcpiExPrepCommonFieldObject (ObjDesc, FieldFlags, 0, + BitOffset, BitCount); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + ObjDesc->BufferField.BufferObj = BufferDesc; + + /* Reference count for BufferDesc inherits ObjDesc count */ + + BufferDesc->Common.ReferenceCount = (UINT16) + (BufferDesc->Common.ReferenceCount + ObjDesc->Common.ReferenceCount); + + +Cleanup: + + /* Always delete the operands */ + + AcpiUtRemoveReference (OffsetDesc); + AcpiUtRemoveReference (BufferDesc); + + if (AmlOpcode == AML_CREATE_FIELD_OP) + { + AcpiUtRemoveReference (LengthDesc); + } + + /* On failure, delete the result descriptor */ + + if (ACPI_FAILURE (Status)) + { + AcpiUtRemoveReference (ResultDesc); /* Result descriptor */ + } + else + { + /* Now the address and length are valid for this BufferField */ + + ObjDesc->BufferField.Flags |= AOPOBJ_DATA_VALID; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsEvalBufferFieldOperands + * + * PARAMETERS: WalkState - Current walk + * Op - A valid BufferField Op object + * + * RETURN: Status + * + * DESCRIPTION: Get BufferField Buffer and Index + * Called from AcpiDsExecEndOp during BufferField parse tree walk + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsEvalBufferFieldOperands ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_NAMESPACE_NODE *Node; + ACPI_PARSE_OBJECT *NextOp; + + + ACPI_FUNCTION_TRACE_PTR (DsEvalBufferFieldOperands, Op); + + + /* + * This is where we evaluate the address and length fields of the + * CreateXxxField declaration + */ + Node = Op->Common.Node; + + /* NextOp points to the op that holds the Buffer */ + + NextOp = Op->Common.Value.Arg; + + /* Evaluate/create the address and length operands */ + + Status = AcpiDsCreateOperands (WalkState, NextOp); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + ObjDesc = AcpiNsGetAttachedObject (Node); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + /* Resolve the operands */ + + Status = AcpiExResolveOperands (Op->Common.AmlOpcode, + ACPI_WALK_OPERANDS, WalkState); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR ((AE_INFO, "(%s) bad operand(s) (%X)", + AcpiPsGetOpcodeName (Op->Common.AmlOpcode), Status)); + + return_ACPI_STATUS (Status); + } + + /* Initialize the Buffer Field */ + + if (Op->Common.AmlOpcode == AML_CREATE_FIELD_OP) + { + /* NOTE: Slightly different operands for this opcode */ + + Status = AcpiDsInitBufferField (Op->Common.AmlOpcode, ObjDesc, + WalkState->Operands[0], WalkState->Operands[1], + WalkState->Operands[2], WalkState->Operands[3]); + } + else + { + /* All other, CreateXxxField opcodes */ + + Status = AcpiDsInitBufferField (Op->Common.AmlOpcode, ObjDesc, + WalkState->Operands[0], WalkState->Operands[1], + NULL, WalkState->Operands[2]); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsEvalRegionOperands + * + * PARAMETERS: WalkState - Current walk + * Op - A valid region Op object + * + * RETURN: Status + * + * DESCRIPTION: Get region address and length + * Called from AcpiDsExecEndOp during OpRegion parse tree walk + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsEvalRegionOperands ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *OperandDesc; + ACPI_NAMESPACE_NODE *Node; + ACPI_PARSE_OBJECT *NextOp; + + + ACPI_FUNCTION_TRACE_PTR (DsEvalRegionOperands, Op); + + + /* + * This is where we evaluate the address and length fields of the + * OpRegion declaration + */ + Node = Op->Common.Node; + + /* NextOp points to the op that holds the SpaceID */ + + NextOp = Op->Common.Value.Arg; + + /* NextOp points to address op */ + + NextOp = NextOp->Common.Next; + + /* Evaluate/create the address and length operands */ + + Status = AcpiDsCreateOperands (WalkState, NextOp); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Resolve the length and address operands to numbers */ + + Status = AcpiExResolveOperands (Op->Common.AmlOpcode, + ACPI_WALK_OPERANDS, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + ObjDesc = AcpiNsGetAttachedObject (Node); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + /* + * Get the length operand and save it + * (at Top of stack) + */ + OperandDesc = WalkState->Operands[WalkState->NumOperands - 1]; + + ObjDesc->Region.Length = (UINT32) OperandDesc->Integer.Value; + AcpiUtRemoveReference (OperandDesc); + + /* + * Get the address and save it + * (at top of stack - 1) + */ + OperandDesc = WalkState->Operands[WalkState->NumOperands - 2]; + + ObjDesc->Region.Address = (ACPI_PHYSICAL_ADDRESS) + OperandDesc->Integer.Value; + AcpiUtRemoveReference (OperandDesc); + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "RgnObj %p Addr %8.8X%8.8X Len %X\n", + ObjDesc, + ACPI_FORMAT_NATIVE_UINT (ObjDesc->Region.Address), + ObjDesc->Region.Length)); + + /* Now the address and length are valid for this opregion */ + + ObjDesc->Region.Flags |= AOPOBJ_DATA_VALID; + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsEvalTableRegionOperands + * + * PARAMETERS: WalkState - Current walk + * Op - A valid region Op object + * + * RETURN: Status + * + * DESCRIPTION: Get region address and length + * Called from AcpiDsExecEndOp during DataTableRegion parse tree walk + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsEvalTableRegionOperands ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT **Operand; + ACPI_NAMESPACE_NODE *Node; + ACPI_PARSE_OBJECT *NextOp; + UINT32 TableIndex; + ACPI_TABLE_HEADER *Table; + + + ACPI_FUNCTION_TRACE_PTR (DsEvalTableRegionOperands, Op); + + + /* + * This is where we evaluate the SignatureString and OemIDString + * and OemTableIDString of the DataTableRegion declaration + */ + Node = Op->Common.Node; + + /* NextOp points to SignatureString op */ + + NextOp = Op->Common.Value.Arg; + + /* + * Evaluate/create the SignatureString and OemIDString + * and OemTableIDString operands + */ + Status = AcpiDsCreateOperands (WalkState, NextOp); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Resolve the SignatureString and OemIDString + * and OemTableIDString operands + */ + Status = AcpiExResolveOperands (Op->Common.AmlOpcode, + ACPI_WALK_OPERANDS, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Operand = &WalkState->Operands[0]; + + /* Find the ACPI table */ + + Status = AcpiTbFindTable (Operand[0]->String.Pointer, + Operand[1]->String.Pointer, Operand[2]->String.Pointer, + &TableIndex); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + AcpiUtRemoveReference (Operand[0]); + AcpiUtRemoveReference (Operand[1]); + AcpiUtRemoveReference (Operand[2]); + + Status = AcpiGetTableByIndex (TableIndex, &Table); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + ObjDesc = AcpiNsGetAttachedObject (Node); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + ObjDesc->Region.Address = (ACPI_PHYSICAL_ADDRESS) ACPI_TO_INTEGER (Table); + ObjDesc->Region.Length = Table->Length; + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "RgnObj %p Addr %8.8X%8.8X Len %X\n", + ObjDesc, + ACPI_FORMAT_NATIVE_UINT (ObjDesc->Region.Address), + ObjDesc->Region.Length)); + + /* Now the address and length are valid for this opregion */ + + ObjDesc->Region.Flags |= AOPOBJ_DATA_VALID; + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsEvalDataObjectOperands + * + * PARAMETERS: WalkState - Current walk + * Op - A valid DataObject Op object + * ObjDesc - DataObject + * + * RETURN: Status + * + * DESCRIPTION: Get the operands and complete the following data object types: + * Buffer, Package. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsEvalDataObjectOperands ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ArgDesc; + UINT32 Length; + + + ACPI_FUNCTION_TRACE (DsEvalDataObjectOperands); + + + /* The first operand (for all of these data objects) is the length */ + + /* + * Set proper index into operand stack for AcpiDsObjStackPush + * invoked inside AcpiDsCreateOperand. + */ + WalkState->OperandIndex = WalkState->NumOperands; + + Status = AcpiDsCreateOperand (WalkState, Op->Common.Value.Arg, 1); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiExResolveOperands (WalkState->Opcode, + &(WalkState->Operands [WalkState->NumOperands -1]), + WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Extract length operand */ + + ArgDesc = WalkState->Operands [WalkState->NumOperands - 1]; + Length = (UINT32) ArgDesc->Integer.Value; + + /* Cleanup for length operand */ + + Status = AcpiDsObjStackPop (1, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + AcpiUtRemoveReference (ArgDesc); + + /* + * Create the actual data object + */ + switch (Op->Common.AmlOpcode) + { + case AML_BUFFER_OP: + + Status = AcpiDsBuildInternalBufferObj (WalkState, Op, Length, &ObjDesc); + break; + + case AML_PACKAGE_OP: + case AML_VAR_PACKAGE_OP: + + Status = AcpiDsBuildInternalPackageObj (WalkState, Op, Length, &ObjDesc); + break; + + default: + return_ACPI_STATUS (AE_AML_BAD_OPCODE); + } + + if (ACPI_SUCCESS (Status)) + { + /* + * Return the object in the WalkState, unless the parent is a package - + * in this case, the return object will be stored in the parse tree + * for the package. + */ + if ((!Op->Common.Parent) || + ((Op->Common.Parent->Common.AmlOpcode != AML_PACKAGE_OP) && + (Op->Common.Parent->Common.AmlOpcode != AML_VAR_PACKAGE_OP) && + (Op->Common.Parent->Common.AmlOpcode != AML_NAME_OP))) + { + WalkState->ResultObj = ObjDesc; + } + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsEvalBankFieldOperands + * + * PARAMETERS: WalkState - Current walk + * Op - A valid BankField Op object + * + * RETURN: Status + * + * DESCRIPTION: Get BankField BankValue + * Called from AcpiDsExecEndOp during BankField parse tree walk + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsEvalBankFieldOperands ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *OperandDesc; + ACPI_NAMESPACE_NODE *Node; + ACPI_PARSE_OBJECT *NextOp; + ACPI_PARSE_OBJECT *Arg; + + + ACPI_FUNCTION_TRACE_PTR (DsEvalBankFieldOperands, Op); + + + /* + * This is where we evaluate the BankValue field of the + * BankField declaration + */ + + /* NextOp points to the op that holds the Region */ + + NextOp = Op->Common.Value.Arg; + + /* NextOp points to the op that holds the Bank Register */ + + NextOp = NextOp->Common.Next; + + /* NextOp points to the op that holds the Bank Value */ + + NextOp = NextOp->Common.Next; + + /* + * Set proper index into operand stack for AcpiDsObjStackPush + * invoked inside AcpiDsCreateOperand. + * + * We use WalkState->Operands[0] to store the evaluated BankValue + */ + WalkState->OperandIndex = 0; + + Status = AcpiDsCreateOperand (WalkState, NextOp, 0); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiExResolveToValue (&WalkState->Operands[0], WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + ACPI_DUMP_OPERANDS (ACPI_WALK_OPERANDS, + AcpiPsGetOpcodeName (Op->Common.AmlOpcode), 1); + /* + * Get the BankValue operand and save it + * (at Top of stack) + */ + OperandDesc = WalkState->Operands[0]; + + /* Arg points to the start Bank Field */ + + Arg = AcpiPsGetArg (Op, 4); + while (Arg) + { + /* Ignore OFFSET and ACCESSAS terms here */ + + if (Arg->Common.AmlOpcode == AML_INT_NAMEDFIELD_OP) + { + Node = Arg->Common.Node; + + ObjDesc = AcpiNsGetAttachedObject (Node); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + ObjDesc->BankField.Value = (UINT32) OperandDesc->Integer.Value; + } + + /* Move to next field in the list */ + + Arg = Arg->Common.Next; + } + + AcpiUtRemoveReference (OperandDesc); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * 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/reactos/drivers/bus/acpi/acpica/dispatcher/dsutils.c b/reactos/drivers/bus/acpi/acpica/dispatcher/dsutils.c new file mode 100644 index 00000000000..6c211ace8c6 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/dispatcher/dsutils.c @@ -0,0 +1,1009 @@ +/******************************************************************************* + * + * Module Name: dsutils - Dispatcher utilities + * + ******************************************************************************/ + +/****************************************************************************** + * + * 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 __DSUTILS_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acparser.h" +#include "amlcode.h" +#include "acdispat.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "acdebug.h" + +#define _COMPONENT ACPI_DISPATCHER + ACPI_MODULE_NAME ("dsutils") + + +/******************************************************************************* + * + * FUNCTION: AcpiDsClearImplicitReturn + * + * PARAMETERS: WalkState - Current State + * + * RETURN: None. + * + * DESCRIPTION: Clear and remove a reference on an implicit return value. Used + * to delete "stale" return values (if enabled, the return value + * from every operator is saved at least momentarily, in case the + * parent method exits.) + * + ******************************************************************************/ + +void +AcpiDsClearImplicitReturn ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_FUNCTION_NAME (DsClearImplicitReturn); + + + /* + * Slack must be enabled for this feature + */ + if (!AcpiGbl_EnableInterpreterSlack) + { + return; + } + + if (WalkState->ImplicitReturnObj) + { + /* + * Delete any "stale" implicit return. However, in + * complex statements, the implicit return value can be + * bubbled up several levels. + */ + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "Removing reference on stale implicit return obj %p\n", + WalkState->ImplicitReturnObj)); + + AcpiUtRemoveReference (WalkState->ImplicitReturnObj); + WalkState->ImplicitReturnObj = NULL; + } +} + + +#ifndef ACPI_NO_METHOD_EXECUTION +/******************************************************************************* + * + * FUNCTION: AcpiDsDoImplicitReturn + * + * PARAMETERS: ReturnDesc - The return value + * WalkState - Current State + * AddReference - True if a reference should be added to the + * return object + * + * RETURN: TRUE if implicit return enabled, FALSE otherwise + * + * DESCRIPTION: Implements the optional "implicit return". We save the result + * of every ASL operator and control method invocation in case the + * parent method exit. Before storing a new return value, we + * delete the previous return value. + * + ******************************************************************************/ + +BOOLEAN +AcpiDsDoImplicitReturn ( + ACPI_OPERAND_OBJECT *ReturnDesc, + ACPI_WALK_STATE *WalkState, + BOOLEAN AddReference) +{ + ACPI_FUNCTION_NAME (DsDoImplicitReturn); + + + /* + * Slack must be enabled for this feature, and we must + * have a valid return object + */ + if ((!AcpiGbl_EnableInterpreterSlack) || + (!ReturnDesc)) + { + return (FALSE); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "Result %p will be implicitly returned; Prev=%p\n", + ReturnDesc, + WalkState->ImplicitReturnObj)); + + /* + * Delete any "stale" implicit return value first. However, in + * complex statements, the implicit return value can be + * bubbled up several levels, so we don't clear the value if it + * is the same as the ReturnDesc. + */ + if (WalkState->ImplicitReturnObj) + { + if (WalkState->ImplicitReturnObj == ReturnDesc) + { + return (TRUE); + } + AcpiDsClearImplicitReturn (WalkState); + } + + /* Save the implicit return value, add a reference if requested */ + + WalkState->ImplicitReturnObj = ReturnDesc; + if (AddReference) + { + AcpiUtAddReference (ReturnDesc); + } + + return (TRUE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsIsResultUsed + * + * PARAMETERS: Op - Current Op + * WalkState - Current State + * + * RETURN: TRUE if result is used, FALSE otherwise + * + * DESCRIPTION: Check if a result object will be used by the parent + * + ******************************************************************************/ + +BOOLEAN +AcpiDsIsResultUsed ( + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState) +{ + const ACPI_OPCODE_INFO *ParentInfo; + + ACPI_FUNCTION_TRACE_PTR (DsIsResultUsed, Op); + + + /* Must have both an Op and a Result Object */ + + if (!Op) + { + ACPI_ERROR ((AE_INFO, "Null Op")); + return_UINT8 (TRUE); + } + + /* + * We know that this operator is not a + * Return() operator (would not come here.) The following code is the + * optional support for a so-called "implicit return". Some AML code + * assumes that the last value of the method is "implicitly" returned + * to the caller. Just save the last result as the return value. + * NOTE: this is optional because the ASL language does not actually + * support this behavior. + */ + (void) AcpiDsDoImplicitReturn (WalkState->ResultObj, WalkState, TRUE); + + /* + * Now determine if the parent will use the result + * + * If there is no parent, or the parent is a ScopeOp, we are executing + * at the method level. An executing method typically has no parent, + * since each method is parsed separately. A method invoked externally + * via ExecuteControlMethod has a ScopeOp as the parent. + */ + if ((!Op->Common.Parent) || + (Op->Common.Parent->Common.AmlOpcode == AML_SCOPE_OP)) + { + /* No parent, the return value cannot possibly be used */ + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "At Method level, result of [%s] not used\n", + AcpiPsGetOpcodeName (Op->Common.AmlOpcode))); + return_UINT8 (FALSE); + } + + /* Get info on the parent. The RootOp is AML_SCOPE */ + + ParentInfo = AcpiPsGetOpcodeInfo (Op->Common.Parent->Common.AmlOpcode); + if (ParentInfo->Class == AML_CLASS_UNKNOWN) + { + ACPI_ERROR ((AE_INFO, + "Unknown parent opcode Op=%p", Op)); + return_UINT8 (FALSE); + } + + /* + * Decide what to do with the result based on the parent. If + * the parent opcode will not use the result, delete the object. + * Otherwise leave it as is, it will be deleted when it is used + * as an operand later. + */ + switch (ParentInfo->Class) + { + case AML_CLASS_CONTROL: + + switch (Op->Common.Parent->Common.AmlOpcode) + { + case AML_RETURN_OP: + + /* Never delete the return value associated with a return opcode */ + + goto ResultUsed; + + case AML_IF_OP: + case AML_WHILE_OP: + + /* + * If we are executing the predicate AND this is the predicate op, + * we will use the return value + */ + if ((WalkState->ControlState->Common.State == ACPI_CONTROL_PREDICATE_EXECUTING) && + (WalkState->ControlState->Control.PredicateOp == Op)) + { + goto ResultUsed; + } + break; + + default: + /* Ignore other control opcodes */ + break; + } + + /* The general control opcode returns no result */ + + goto ResultNotUsed; + + + case AML_CLASS_CREATE: + + /* + * These opcodes allow TermArg(s) as operands and therefore + * the operands can be method calls. The result is used. + */ + goto ResultUsed; + + + case AML_CLASS_NAMED_OBJECT: + + if ((Op->Common.Parent->Common.AmlOpcode == AML_REGION_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_DATA_REGION_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_BUFFER_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_INT_EVAL_SUBTREE_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_BANK_FIELD_OP)) + { + /* + * These opcodes allow TermArg(s) as operands and therefore + * the operands can be method calls. The result is used. + */ + goto ResultUsed; + } + + goto ResultNotUsed; + + + default: + + /* + * In all other cases. the parent will actually use the return + * object, so keep it. + */ + goto ResultUsed; + } + + +ResultUsed: + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "Result of [%s] used by Parent [%s] Op=%p\n", + AcpiPsGetOpcodeName (Op->Common.AmlOpcode), + AcpiPsGetOpcodeName (Op->Common.Parent->Common.AmlOpcode), Op)); + + return_UINT8 (TRUE); + + +ResultNotUsed: + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "Result of [%s] not used by Parent [%s] Op=%p\n", + AcpiPsGetOpcodeName (Op->Common.AmlOpcode), + AcpiPsGetOpcodeName (Op->Common.Parent->Common.AmlOpcode), Op)); + + return_UINT8 (FALSE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsDeleteResultIfNotUsed + * + * PARAMETERS: Op - Current parse Op + * ResultObj - Result of the operation + * WalkState - Current state + * + * RETURN: Status + * + * DESCRIPTION: Used after interpretation of an opcode. If there is an internal + * result descriptor, check if the parent opcode will actually use + * this result. If not, delete the result now so that it will + * not become orphaned. + * + ******************************************************************************/ + +void +AcpiDsDeleteResultIfNotUsed ( + ACPI_PARSE_OBJECT *Op, + ACPI_OPERAND_OBJECT *ResultObj, + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE_PTR (DsDeleteResultIfNotUsed, ResultObj); + + + if (!Op) + { + ACPI_ERROR ((AE_INFO, "Null Op")); + return_VOID; + } + + if (!ResultObj) + { + return_VOID; + } + + if (!AcpiDsIsResultUsed (Op, WalkState)) + { + /* Must pop the result stack (ObjDesc should be equal to ResultObj) */ + + Status = AcpiDsResultPop (&ObjDesc, WalkState); + if (ACPI_SUCCESS (Status)) + { + AcpiUtRemoveReference (ResultObj); + } + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsResolveOperands + * + * PARAMETERS: WalkState - Current walk state with operands on stack + * + * RETURN: Status + * + * DESCRIPTION: Resolve all operands to their values. Used to prepare + * arguments to a control method invocation (a call from one + * method to another.) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsResolveOperands ( + ACPI_WALK_STATE *WalkState) +{ + UINT32 i; + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE_PTR (DsResolveOperands, WalkState); + + + /* + * Attempt to resolve each of the valid operands + * Method arguments are passed by reference, not by value. This means + * that the actual objects are passed, not copies of the objects. + */ + for (i = 0; i < WalkState->NumOperands; i++) + { + Status = AcpiExResolveToValue (&WalkState->Operands[i], WalkState); + if (ACPI_FAILURE (Status)) + { + break; + } + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsClearOperands + * + * PARAMETERS: WalkState - Current walk state with operands on stack + * + * RETURN: None + * + * DESCRIPTION: Clear all operands on the current walk state operand stack. + * + ******************************************************************************/ + +void +AcpiDsClearOperands ( + ACPI_WALK_STATE *WalkState) +{ + UINT32 i; + + + ACPI_FUNCTION_TRACE_PTR (DsClearOperands, WalkState); + + + /* Remove a reference on each operand on the stack */ + + for (i = 0; i < WalkState->NumOperands; i++) + { + /* + * Remove a reference to all operands, including both + * "Arguments" and "Targets". + */ + AcpiUtRemoveReference (WalkState->Operands[i]); + WalkState->Operands[i] = NULL; + } + + WalkState->NumOperands = 0; + return_VOID; +} +#endif + + +/******************************************************************************* + * + * FUNCTION: AcpiDsCreateOperand + * + * PARAMETERS: WalkState - Current walk state + * Arg - Parse object for the argument + * ArgIndex - Which argument (zero based) + * + * RETURN: Status + * + * DESCRIPTION: Translate a parse tree object that is an argument to an AML + * opcode to the equivalent interpreter object. This may include + * looking up a name or entering a new name into the internal + * namespace. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsCreateOperand ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Arg, + UINT32 ArgIndex) +{ + ACPI_STATUS Status = AE_OK; + char *NameString; + UINT32 NameLength; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_PARSE_OBJECT *ParentOp; + UINT16 Opcode; + ACPI_INTERPRETER_MODE InterpreterMode; + const ACPI_OPCODE_INFO *OpInfo; + + + ACPI_FUNCTION_TRACE_PTR (DsCreateOperand, Arg); + + + /* A valid name must be looked up in the namespace */ + + if ((Arg->Common.AmlOpcode == AML_INT_NAMEPATH_OP) && + (Arg->Common.Value.String) && + !(Arg->Common.Flags & ACPI_PARSEOP_IN_STACK)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Getting a name: Arg=%p\n", Arg)); + + /* Get the entire name string from the AML stream */ + + Status = AcpiExGetNameString (ACPI_TYPE_ANY, Arg->Common.Value.Buffer, + &NameString, &NameLength); + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* All prefixes have been handled, and the name is in NameString */ + + /* + * Special handling for BufferField declarations. This is a deferred + * opcode that unfortunately defines the field name as the last + * parameter instead of the first. We get here when we are performing + * the deferred execution, so the actual name of the field is already + * in the namespace. We don't want to attempt to look it up again + * because we may be executing in a different scope than where the + * actual opcode exists. + */ + if ((WalkState->DeferredNode) && + (WalkState->DeferredNode->Type == ACPI_TYPE_BUFFER_FIELD) && + (ArgIndex == (UINT32) ((WalkState->Opcode == AML_CREATE_FIELD_OP) ? 3 : 2))) + { + ObjDesc = ACPI_CAST_PTR ( + ACPI_OPERAND_OBJECT, WalkState->DeferredNode); + Status = AE_OK; + } + else /* All other opcodes */ + { + /* + * Differentiate between a namespace "create" operation + * versus a "lookup" operation (IMODE_LOAD_PASS2 vs. + * IMODE_EXECUTE) in order to support the creation of + * namespace objects during the execution of control methods. + */ + ParentOp = Arg->Common.Parent; + OpInfo = AcpiPsGetOpcodeInfo (ParentOp->Common.AmlOpcode); + if ((OpInfo->Flags & AML_NSNODE) && + (ParentOp->Common.AmlOpcode != AML_INT_METHODCALL_OP) && + (ParentOp->Common.AmlOpcode != AML_REGION_OP) && + (ParentOp->Common.AmlOpcode != AML_INT_NAMEPATH_OP)) + { + /* Enter name into namespace if not found */ + + InterpreterMode = ACPI_IMODE_LOAD_PASS2; + } + else + { + /* Return a failure if name not found */ + + InterpreterMode = ACPI_IMODE_EXECUTE; + } + + Status = AcpiNsLookup (WalkState->ScopeInfo, NameString, + ACPI_TYPE_ANY, InterpreterMode, + ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, + WalkState, + ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, &ObjDesc)); + /* + * The only case where we pass through (ignore) a NOT_FOUND + * error is for the CondRefOf opcode. + */ + if (Status == AE_NOT_FOUND) + { + if (ParentOp->Common.AmlOpcode == AML_COND_REF_OF_OP) + { + /* + * For the Conditional Reference op, it's OK if + * the name is not found; We just need a way to + * indicate this to the interpreter, set the + * object to the root + */ + ObjDesc = ACPI_CAST_PTR ( + ACPI_OPERAND_OBJECT, AcpiGbl_RootNode); + Status = AE_OK; + } + else + { + /* + * We just plain didn't find it -- which is a + * very serious error at this point + */ + Status = AE_AML_NAME_NOT_FOUND; + } + } + + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR_NAMESPACE (NameString, Status); + } + } + + /* Free the namestring created above */ + + ACPI_FREE (NameString); + + /* Check status from the lookup */ + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Put the resulting object onto the current object stack */ + + Status = AcpiDsObjStackPush (ObjDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + ACPI_DEBUGGER_EXEC (AcpiDbDisplayArgumentObject (ObjDesc, WalkState)); + } + else + { + /* Check for null name case */ + + if ((Arg->Common.AmlOpcode == AML_INT_NAMEPATH_OP) && + !(Arg->Common.Flags & ACPI_PARSEOP_IN_STACK)) + { + /* + * If the name is null, this means that this is an + * optional result parameter that was not specified + * in the original ASL. Create a Zero Constant for a + * placeholder. (Store to a constant is a Noop.) + */ + Opcode = AML_ZERO_OP; /* Has no arguments! */ + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "Null namepath: Arg=%p\n", Arg)); + } + else + { + Opcode = Arg->Common.AmlOpcode; + } + + /* Get the object type of the argument */ + + OpInfo = AcpiPsGetOpcodeInfo (Opcode); + if (OpInfo->ObjectType == ACPI_TYPE_INVALID) + { + return_ACPI_STATUS (AE_NOT_IMPLEMENTED); + } + + if ((OpInfo->Flags & AML_HAS_RETVAL) || (Arg->Common.Flags & ACPI_PARSEOP_IN_STACK)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "Argument previously created, already stacked\n")); + + ACPI_DEBUGGER_EXEC (AcpiDbDisplayArgumentObject ( + WalkState->Operands [WalkState->NumOperands - 1], WalkState)); + + /* + * Use value that was already previously returned + * by the evaluation of this argument + */ + Status = AcpiDsResultPop (&ObjDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + /* + * Only error is underflow, and this indicates + * a missing or null operand! + */ + ACPI_EXCEPTION ((AE_INFO, Status, + "Missing or null operand")); + return_ACPI_STATUS (Status); + } + } + else + { + /* Create an ACPI_INTERNAL_OBJECT for the argument */ + + ObjDesc = AcpiUtCreateInternalObject (OpInfo->ObjectType); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Initialize the new object */ + + Status = AcpiDsInitObjectFromOp ( + WalkState, Arg, Opcode, &ObjDesc); + if (ACPI_FAILURE (Status)) + { + AcpiUtDeleteObjectDesc (ObjDesc); + return_ACPI_STATUS (Status); + } + } + + /* Put the operand object on the object stack */ + + Status = AcpiDsObjStackPush (ObjDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + ACPI_DEBUGGER_EXEC (AcpiDbDisplayArgumentObject (ObjDesc, WalkState)); + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsCreateOperands + * + * PARAMETERS: WalkState - Current state + * FirstArg - First argument of a parser argument tree + * + * RETURN: Status + * + * DESCRIPTION: Convert an operator's arguments from a parse tree format to + * namespace objects and place those argument object on the object + * stack in preparation for evaluation by the interpreter. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsCreateOperands ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *FirstArg) +{ + ACPI_STATUS Status = AE_OK; + ACPI_PARSE_OBJECT *Arg; + ACPI_PARSE_OBJECT *Arguments[ACPI_OBJ_NUM_OPERANDS]; + UINT32 ArgCount = 0; + UINT32 Index = WalkState->NumOperands; + UINT32 i; + + + ACPI_FUNCTION_TRACE_PTR (DsCreateOperands, FirstArg); + + + /* Get all arguments in the list */ + + Arg = FirstArg; + while (Arg) + { + if (Index >= ACPI_OBJ_NUM_OPERANDS) + { + return_ACPI_STATUS (AE_BAD_DATA); + } + + Arguments[Index] = Arg; + WalkState->Operands [Index] = NULL; + + /* Move on to next argument, if any */ + + Arg = Arg->Common.Next; + ArgCount++; + Index++; + } + + Index--; + + /* It is the appropriate order to get objects from the Result stack */ + + for (i = 0; i < ArgCount; i++) + { + Arg = Arguments[Index]; + + /* Force the filling of the operand stack in inverse order */ + + WalkState->OperandIndex = (UINT8) Index; + + Status = AcpiDsCreateOperand (WalkState, Arg, Index); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + Index--; + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Arg #%d (%p) done, Arg1=%p\n", + Index, Arg, FirstArg)); + } + + return_ACPI_STATUS (Status); + + +Cleanup: + /* + * We must undo everything done above; meaning that we must + * pop everything off of the operand stack and delete those + * objects + */ + AcpiDsObjStackPopAndDelete (ArgCount, WalkState); + + ACPI_EXCEPTION ((AE_INFO, Status, "While creating Arg %d", Index)); + return_ACPI_STATUS (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiDsEvaluateNamePath + * + * PARAMETERS: WalkState - Current state of the parse tree walk, + * the opcode of current operation should be + * AML_INT_NAMEPATH_OP + * + * RETURN: Status + * + * DESCRIPTION: Translate the -NamePath- parse tree object to the equivalent + * interpreter object, convert it to value, if needed, duplicate + * it, if needed, and push it onto the current result stack. + * + ****************************************************************************/ + +ACPI_STATUS +AcpiDsEvaluateNamePath ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + ACPI_PARSE_OBJECT *Op = WalkState->Op; + ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; + ACPI_OPERAND_OBJECT *NewObjDesc; + UINT8 Type; + + + ACPI_FUNCTION_TRACE_PTR (DsEvaluateNamePath, WalkState); + + + if (!Op->Common.Parent) + { + /* This happens after certain exception processing */ + + goto Exit; + } + + if ((Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_REF_OF_OP)) + { + /* TBD: Should we specify this feature as a bit of OpInfo->Flags of these opcodes? */ + + goto Exit; + } + + Status = AcpiDsCreateOperand (WalkState, Op, 0); + if (ACPI_FAILURE (Status)) + { + goto Exit; + } + + if (Op->Common.Flags & ACPI_PARSEOP_TARGET) + { + NewObjDesc = *Operand; + goto PushResult; + } + + Type = (*Operand)->Common.Type; + + Status = AcpiExResolveToValue (Operand, WalkState); + if (ACPI_FAILURE (Status)) + { + goto Exit; + } + + if (Type == ACPI_TYPE_INTEGER) + { + /* It was incremented by AcpiExResolveToValue */ + + AcpiUtRemoveReference (*Operand); + + Status = AcpiUtCopyIobjectToIobject (*Operand, &NewObjDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + goto Exit; + } + } + else + { + /* + * The object either was anew created or is + * a Namespace node - don't decrement it. + */ + NewObjDesc = *Operand; + } + + /* Cleanup for name-path operand */ + + Status = AcpiDsObjStackPop (1, WalkState); + if (ACPI_FAILURE (Status)) + { + WalkState->ResultObj = NewObjDesc; + goto Exit; + } + +PushResult: + + WalkState->ResultObj = NewObjDesc; + + Status = AcpiDsResultPush (WalkState->ResultObj, WalkState); + if (ACPI_SUCCESS (Status)) + { + /* Force to take it from stack */ + + Op->Common.Flags |= ACPI_PARSEOP_IN_STACK; + } + +Exit: + + return_ACPI_STATUS (Status); +} diff --git a/reactos/drivers/bus/acpi/acpica/dispatcher/dswexec.c b/reactos/drivers/bus/acpi/acpica/dispatcher/dswexec.c new file mode 100644 index 00000000000..9485c62bb1c --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/dispatcher/dswexec.c @@ -0,0 +1,853 @@ +/****************************************************************************** + * + * Module Name: dswexec - Dispatcher method execution callbacks; + * dispatch to interpreter. + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __DSWEXEC_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acparser.h" +#include "amlcode.h" +#include "acdispat.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "acdebug.h" + + +#define _COMPONENT ACPI_DISPATCHER + ACPI_MODULE_NAME ("dswexec") + +/* + * Dispatch table for opcode classes + */ +static ACPI_EXECUTE_OP AcpiGbl_OpTypeDispatch [] = +{ + AcpiExOpcode_0A_0T_1R, + AcpiExOpcode_1A_0T_0R, + AcpiExOpcode_1A_0T_1R, + AcpiExOpcode_1A_1T_0R, + AcpiExOpcode_1A_1T_1R, + AcpiExOpcode_2A_0T_0R, + AcpiExOpcode_2A_0T_1R, + AcpiExOpcode_2A_1T_1R, + AcpiExOpcode_2A_2T_1R, + AcpiExOpcode_3A_0T_0R, + AcpiExOpcode_3A_1T_1R, + AcpiExOpcode_6A_0T_1R +}; + + +/***************************************************************************** + * + * FUNCTION: AcpiDsGetPredicateValue + * + * PARAMETERS: WalkState - Current state of the parse tree walk + * ResultObj - if non-zero, pop result from result stack + * + * RETURN: Status + * + * DESCRIPTION: Get the result of a predicate evaluation + * + ****************************************************************************/ + +ACPI_STATUS +AcpiDsGetPredicateValue ( + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT *ResultObj) +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *LocalObjDesc = NULL; + + + ACPI_FUNCTION_TRACE_PTR (DsGetPredicateValue, WalkState); + + + WalkState->ControlState->Common.State = 0; + + if (ResultObj) + { + Status = AcpiDsResultPop (&ObjDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Could not get result from predicate evaluation")); + + return_ACPI_STATUS (Status); + } + } + else + { + Status = AcpiDsCreateOperand (WalkState, WalkState->Op, 0); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiExResolveToValue (&WalkState->Operands [0], WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + ObjDesc = WalkState->Operands [0]; + } + + if (!ObjDesc) + { + ACPI_ERROR ((AE_INFO, + "No predicate ObjDesc=%p State=%p", + ObjDesc, WalkState)); + + return_ACPI_STATUS (AE_AML_NO_OPERAND); + } + + /* + * Result of predicate evaluation must be an Integer + * object. Implicitly convert the argument if necessary. + */ + Status = AcpiExConvertToInteger (ObjDesc, &LocalObjDesc, 16); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + if (LocalObjDesc->Common.Type != ACPI_TYPE_INTEGER) + { + ACPI_ERROR ((AE_INFO, + "Bad predicate (not an integer) ObjDesc=%p State=%p Type=%X", + ObjDesc, WalkState, ObjDesc->Common.Type)); + + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + + /* Truncate the predicate to 32-bits if necessary */ + + AcpiExTruncateFor32bitTable (LocalObjDesc); + + /* + * Save the result of the predicate evaluation on + * the control stack + */ + if (LocalObjDesc->Integer.Value) + { + WalkState->ControlState->Common.Value = TRUE; + } + else + { + /* + * Predicate is FALSE, we will just toss the + * rest of the package + */ + WalkState->ControlState->Common.Value = FALSE; + Status = AE_CTRL_FALSE; + } + + /* Predicate can be used for an implicit return value */ + + (void) AcpiDsDoImplicitReturn (LocalObjDesc, WalkState, TRUE); + + +Cleanup: + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Completed a predicate eval=%X Op=%p\n", + WalkState->ControlState->Common.Value, WalkState->Op)); + + /* Break to debugger to display result */ + + ACPI_DEBUGGER_EXEC (AcpiDbDisplayResultObject (LocalObjDesc, WalkState)); + + /* + * Delete the predicate result object (we know that + * we don't need it anymore) + */ + if (LocalObjDesc != ObjDesc) + { + AcpiUtRemoveReference (LocalObjDesc); + } + AcpiUtRemoveReference (ObjDesc); + + WalkState->ControlState->Common.State = ACPI_CONTROL_NORMAL; + return_ACPI_STATUS (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiDsExecBeginOp + * + * PARAMETERS: WalkState - Current state of the parse tree walk + * OutOp - Where to return op if a new one is created + * + * RETURN: Status + * + * DESCRIPTION: Descending callback used during the execution of control + * methods. This is where most operators and operands are + * dispatched to the interpreter. + * + ****************************************************************************/ + +ACPI_STATUS +AcpiDsExecBeginOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT **OutOp) +{ + ACPI_PARSE_OBJECT *Op; + ACPI_STATUS Status = AE_OK; + UINT32 OpcodeClass; + + + ACPI_FUNCTION_TRACE_PTR (DsExecBeginOp, WalkState); + + + Op = WalkState->Op; + if (!Op) + { + Status = AcpiDsLoad2BeginOp (WalkState, OutOp); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + + Op = *OutOp; + WalkState->Op = Op; + WalkState->Opcode = Op->Common.AmlOpcode; + WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); + + if (AcpiNsOpensScope (WalkState->OpInfo->ObjectType)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "(%s) Popping scope for Op %p\n", + AcpiUtGetTypeName (WalkState->OpInfo->ObjectType), Op)); + + Status = AcpiDsScopeStackPop (WalkState); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + } + } + + if (Op == WalkState->Origin) + { + if (OutOp) + { + *OutOp = Op; + } + + return_ACPI_STATUS (AE_OK); + } + + /* + * If the previous opcode was a conditional, this opcode + * must be the beginning of the associated predicate. + * Save this knowledge in the current scope descriptor + */ + if ((WalkState->ControlState) && + (WalkState->ControlState->Common.State == + ACPI_CONTROL_CONDITIONAL_EXECUTING)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Exec predicate Op=%p State=%p\n", + Op, WalkState)); + + WalkState->ControlState->Common.State = ACPI_CONTROL_PREDICATE_EXECUTING; + + /* Save start of predicate */ + + WalkState->ControlState->Control.PredicateOp = Op; + } + + + OpcodeClass = WalkState->OpInfo->Class; + + /* We want to send namepaths to the load code */ + + if (Op->Common.AmlOpcode == AML_INT_NAMEPATH_OP) + { + OpcodeClass = AML_CLASS_NAMED_OBJECT; + } + + /* + * Handle the opcode based upon the opcode type + */ + switch (OpcodeClass) + { + case AML_CLASS_CONTROL: + + Status = AcpiDsExecBeginControlOp (WalkState, Op); + break; + + + case AML_CLASS_NAMED_OBJECT: + + if (WalkState->WalkType & ACPI_WALK_METHOD) + { + /* + * Found a named object declaration during method execution; + * we must enter this object into the namespace. The created + * object is temporary and will be deleted upon completion of + * the execution of this method. + */ + Status = AcpiDsLoad2BeginOp (WalkState, NULL); + } + + break; + + + case AML_CLASS_EXECUTE: + case AML_CLASS_CREATE: + + break; + + + default: + break; + } + + /* Nothing to do here during method execution */ + + return_ACPI_STATUS (Status); + + +ErrorExit: + Status = AcpiDsMethodError (Status, WalkState); + return_ACPI_STATUS (Status); +} + + +/***************************************************************************** + * + * FUNCTION: AcpiDsExecEndOp + * + * PARAMETERS: WalkState - Current state of the parse tree walk + * + * RETURN: Status + * + * DESCRIPTION: Ascending callback used during the execution of control + * methods. The only thing we really need to do here is to + * notice the beginning of IF, ELSE, and WHILE blocks. + * + ****************************************************************************/ + +ACPI_STATUS +AcpiDsExecEndOp ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_PARSE_OBJECT *Op; + ACPI_STATUS Status = AE_OK; + UINT32 OpType; + UINT32 OpClass; + ACPI_PARSE_OBJECT *NextOp; + ACPI_PARSE_OBJECT *FirstArg; + + + ACPI_FUNCTION_TRACE_PTR (DsExecEndOp, WalkState); + + + Op = WalkState->Op; + OpType = WalkState->OpInfo->Type; + OpClass = WalkState->OpInfo->Class; + + if (OpClass == AML_CLASS_UNKNOWN) + { + ACPI_ERROR ((AE_INFO, "Unknown opcode %X", Op->Common.AmlOpcode)); + return_ACPI_STATUS (AE_NOT_IMPLEMENTED); + } + + FirstArg = Op->Common.Value.Arg; + + /* Init the walk state */ + + WalkState->NumOperands = 0; + WalkState->OperandIndex = 0; + WalkState->ReturnDesc = NULL; + WalkState->ResultObj = NULL; + + /* Call debugger for single step support (DEBUG build only) */ + + ACPI_DEBUGGER_EXEC (Status = AcpiDbSingleStep (WalkState, Op, OpClass)); + ACPI_DEBUGGER_EXEC (if (ACPI_FAILURE (Status)) {return_ACPI_STATUS (Status);}); + + /* Decode the Opcode Class */ + + switch (OpClass) + { + case AML_CLASS_ARGUMENT: /* Constants, literals, etc. */ + + if (WalkState->Opcode == AML_INT_NAMEPATH_OP) + { + Status = AcpiDsEvaluateNamePath (WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + } + break; + + + case AML_CLASS_EXECUTE: /* Most operators with arguments */ + + /* Build resolved operand stack */ + + Status = AcpiDsCreateOperands (WalkState, FirstArg); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* + * All opcodes require operand resolution, with the only exceptions + * being the ObjectType and SizeOf operators. + */ + if (!(WalkState->OpInfo->Flags & AML_NO_OPERAND_RESOLVE)) + { + /* Resolve all operands */ + + Status = AcpiExResolveOperands (WalkState->Opcode, + &(WalkState->Operands [WalkState->NumOperands -1]), + WalkState); + } + + if (ACPI_SUCCESS (Status)) + { + /* + * Dispatch the request to the appropriate interpreter handler + * routine. There is one routine per opcode "type" based upon the + * number of opcode arguments and return type. + */ + Status = AcpiGbl_OpTypeDispatch[OpType] (WalkState); + } + else + { + /* + * Treat constructs of the form "Store(LocalX,LocalX)" as noops when the + * Local is uninitialized. + */ + if ((Status == AE_AML_UNINITIALIZED_LOCAL) && + (WalkState->Opcode == AML_STORE_OP) && + (WalkState->Operands[0]->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) && + (WalkState->Operands[1]->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) && + (WalkState->Operands[0]->Reference.Class == + WalkState->Operands[1]->Reference.Class) && + (WalkState->Operands[0]->Reference.Value == + WalkState->Operands[1]->Reference.Value)) + { + Status = AE_OK; + } + else + { + ACPI_EXCEPTION ((AE_INFO, Status, + "While resolving operands for [%s]", + AcpiPsGetOpcodeName (WalkState->Opcode))); + } + } + + /* Always delete the argument objects and clear the operand stack */ + + AcpiDsClearOperands (WalkState); + + /* + * If a result object was returned from above, push it on the + * current result stack + */ + if (ACPI_SUCCESS (Status) && + WalkState->ResultObj) + { + Status = AcpiDsResultPush (WalkState->ResultObj, WalkState); + } + break; + + + default: + + switch (OpType) + { + case AML_TYPE_CONTROL: /* Type 1 opcode, IF/ELSE/WHILE/NOOP */ + + /* 1 Operand, 0 ExternalResult, 0 InternalResult */ + + Status = AcpiDsExecEndControlOp (WalkState, Op); + + break; + + + case AML_TYPE_METHOD_CALL: + + /* + * If the method is referenced from within a package + * declaration, it is not a invocation of the method, just + * a reference to it. + */ + if ((Op->Asl.Parent) && + ((Op->Asl.Parent->Asl.AmlOpcode == AML_PACKAGE_OP) || + (Op->Asl.Parent->Asl.AmlOpcode == AML_VAR_PACKAGE_OP))) + { + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "Method Reference in a Package, Op=%p\n", Op)); + + Op->Common.Node = (ACPI_NAMESPACE_NODE *) Op->Asl.Value.Arg->Asl.Node; + AcpiUtAddReference (Op->Asl.Value.Arg->Asl.Node->Object); + return_ACPI_STATUS (AE_OK); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Method invocation, Op=%p\n", Op)); + + /* + * (AML_METHODCALL) Op->Asl.Value.Arg->Asl.Node contains + * the method Node pointer + */ + /* NextOp points to the op that holds the method name */ + + NextOp = FirstArg; + + /* NextOp points to first argument op */ + + NextOp = NextOp->Common.Next; + + /* + * Get the method's arguments and put them on the operand stack + */ + Status = AcpiDsCreateOperands (WalkState, NextOp); + if (ACPI_FAILURE (Status)) + { + break; + } + + /* + * Since the operands will be passed to another control method, + * we must resolve all local references here (Local variables, + * arguments to *this* method, etc.) + */ + Status = AcpiDsResolveOperands (WalkState); + if (ACPI_FAILURE (Status)) + { + /* On error, clear all resolved operands */ + + AcpiDsClearOperands (WalkState); + break; + } + + /* + * Tell the walk loop to preempt this running method and + * execute the new method + */ + Status = AE_CTRL_TRANSFER; + + /* + * Return now; we don't want to disturb anything, + * especially the operand count! + */ + return_ACPI_STATUS (Status); + + + case AML_TYPE_CREATE_FIELD: + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Executing CreateField Buffer/Index Op=%p\n", Op)); + + Status = AcpiDsLoad2EndOp (WalkState); + if (ACPI_FAILURE (Status)) + { + break; + } + + Status = AcpiDsEvalBufferFieldOperands (WalkState, Op); + break; + + + case AML_TYPE_CREATE_OBJECT: + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Executing CreateObject (Buffer/Package) Op=%p\n", Op)); + + switch (Op->Common.Parent->Common.AmlOpcode) + { + case AML_NAME_OP: + + /* + * Put the Node on the object stack (Contains the ACPI Name + * of this object) + */ + WalkState->Operands[0] = (void *) Op->Common.Parent->Common.Node; + WalkState->NumOperands = 1; + + Status = AcpiDsCreateNode (WalkState, + Op->Common.Parent->Common.Node, + Op->Common.Parent); + if (ACPI_FAILURE (Status)) + { + break; + } + + /* Fall through */ + /*lint -fallthrough */ + + case AML_INT_EVAL_SUBTREE_OP: + + Status = AcpiDsEvalDataObjectOperands (WalkState, Op, + AcpiNsGetAttachedObject (Op->Common.Parent->Common.Node)); + break; + + default: + + Status = AcpiDsEvalDataObjectOperands (WalkState, Op, NULL); + break; + } + + /* + * If a result object was returned from above, push it on the + * current result stack + */ + if (WalkState->ResultObj) + { + Status = AcpiDsResultPush (WalkState->ResultObj, WalkState); + } + break; + + + case AML_TYPE_NAMED_FIELD: + case AML_TYPE_NAMED_COMPLEX: + case AML_TYPE_NAMED_SIMPLE: + case AML_TYPE_NAMED_NO_OBJ: + + Status = AcpiDsLoad2EndOp (WalkState); + if (ACPI_FAILURE (Status)) + { + break; + } + + if (Op->Common.AmlOpcode == AML_REGION_OP) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Executing OpRegion Address/Length Op=%p\n", Op)); + + Status = AcpiDsEvalRegionOperands (WalkState, Op); + if (ACPI_FAILURE (Status)) + { + break; + } + } + else if (Op->Common.AmlOpcode == AML_DATA_REGION_OP) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Executing DataTableRegion Strings Op=%p\n", Op)); + + Status = AcpiDsEvalTableRegionOperands (WalkState, Op); + if (ACPI_FAILURE (Status)) + { + break; + } + } + else if (Op->Common.AmlOpcode == AML_BANK_FIELD_OP) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Executing BankField Op=%p\n", Op)); + + Status = AcpiDsEvalBankFieldOperands (WalkState, Op); + if (ACPI_FAILURE (Status)) + { + break; + } + } + break; + + + case AML_TYPE_UNDEFINED: + + ACPI_ERROR ((AE_INFO, + "Undefined opcode type Op=%p", Op)); + return_ACPI_STATUS (AE_NOT_IMPLEMENTED); + + + case AML_TYPE_BOGUS: + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "Internal opcode=%X type Op=%p\n", + WalkState->Opcode, Op)); + break; + + + default: + + ACPI_ERROR ((AE_INFO, + "Unimplemented opcode, class=%X type=%X Opcode=%X Op=%p", + OpClass, OpType, Op->Common.AmlOpcode, Op)); + + Status = AE_NOT_IMPLEMENTED; + break; + } + } + + /* + * ACPI 2.0 support for 64-bit integers: Truncate numeric + * result value if we are executing from a 32-bit ACPI table + */ + AcpiExTruncateFor32bitTable (WalkState->ResultObj); + + /* + * Check if we just completed the evaluation of a + * conditional predicate + */ + if ((ACPI_SUCCESS (Status)) && + (WalkState->ControlState) && + (WalkState->ControlState->Common.State == + ACPI_CONTROL_PREDICATE_EXECUTING) && + (WalkState->ControlState->Control.PredicateOp == Op)) + { + Status = AcpiDsGetPredicateValue (WalkState, WalkState->ResultObj); + WalkState->ResultObj = NULL; + } + + +Cleanup: + + if (WalkState->ResultObj) + { + /* Break to debugger to display result */ + + ACPI_DEBUGGER_EXEC (AcpiDbDisplayResultObject (WalkState->ResultObj, + WalkState)); + + /* + * Delete the result op if and only if: + * Parent will not use the result -- such as any + * non-nested type2 op in a method (parent will be method) + */ + AcpiDsDeleteResultIfNotUsed (Op, WalkState->ResultObj, WalkState); + } + +#ifdef _UNDER_DEVELOPMENT + + if (WalkState->ParserState.Aml == WalkState->ParserState.AmlEnd) + { + AcpiDbMethodEnd (WalkState); + } +#endif + + /* Invoke exception handler on error */ + + if (ACPI_FAILURE (Status)) + { + Status = AcpiDsMethodError (Status, WalkState); + } + + /* Always clear the object stack */ + + WalkState->NumOperands = 0; + return_ACPI_STATUS (Status); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/dispatcher/dswload.c b/reactos/drivers/bus/acpi/acpica/dispatcher/dswload.c new file mode 100644 index 00000000000..48c4ae6f163 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/dispatcher/dswload.c @@ -0,0 +1,1316 @@ +/****************************************************************************** + * + * Module Name: dswload - Dispatcher namespace load callbacks + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __DSWLOAD_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acparser.h" +#include "amlcode.h" +#include "acdispat.h" +#include "acinterp.h" +#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 (Op, Path, ACPI_TYPE_DEVICE, 0); + Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, + ACPI_IMODE_LOAD_PASS1, ACPI_NS_SEARCH_PARENT, + WalkState, &Node); + } +#endif + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR_NAMESPACE (Path, Status); + return_ACPI_STATUS (Status); + } + + /* + * Check to make sure that the target is + * one of the opcodes that actually opens a scope + */ + switch (Node->Type) + { + case ACPI_TYPE_ANY: + case ACPI_TYPE_LOCAL_SCOPE: /* Scope */ + case ACPI_TYPE_DEVICE: + case ACPI_TYPE_POWER: + case ACPI_TYPE_PROCESSOR: + case ACPI_TYPE_THERMAL: + + /* These are acceptable types */ + break; + + case ACPI_TYPE_INTEGER: + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + + /* + * These types we will allow, but we will change the type. + * This enables some existing code of the form: + * + * Name (DEB, 0) + * Scope (DEB) { ... } + * + * Note: silently change the type here. On the second pass, + * we will report a warning + */ + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Type override - [%4.4s] had invalid type (%s) " + "for Scope operator, changed to type ANY\n", + AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type))); + + Node->Type = ACPI_TYPE_ANY; + WalkState->ScopeInfo->Common.Value = ACPI_TYPE_ANY; + break; + + default: + + /* All other types are an error */ + + ACPI_ERROR ((AE_INFO, + "Invalid type (%s) for target of " + "Scope operator [%4.4s] (Cannot override)", + AcpiUtGetTypeName (Node->Type), AcpiUtGetNodeName (Node))); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + break; + + + default: + /* + * For all other named opcodes, we will enter the name into + * the namespace. + * + * Setup the search flags. + * Since we are entering a name into the namespace, we do not want to + * enable the search-to-root upsearch. + * + * There are only two conditions where it is acceptable that the name + * already exists: + * 1) the Scope() operator can reopen a scoping object that was + * previously defined (Scope, Method, Device, etc.) + * 2) Whenever we are parsing a deferred opcode (OpRegion, Buffer, + * BufferField, or Package), the name of the object is already + * in the namespace. + */ + if (WalkState->DeferredNode) + { + /* This name is already in the namespace, get the node */ + + Node = WalkState->DeferredNode; + Status = AE_OK; + break; + } + + /* + * If we are executing a method, do not create any namespace objects + * during the load phase, only during execution. + */ + if (WalkState->MethodNode) + { + Node = NULL; + Status = AE_OK; + break; + } + + Flags = ACPI_NS_NO_UPSEARCH; + if ((WalkState->Opcode != AML_SCOPE_OP) && + (!(WalkState->ParseFlags & ACPI_PARSE_DEFERRED_OP))) + { + Flags |= ACPI_NS_ERROR_IF_FOUND; + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[%s] Cannot already exist\n", + AcpiUtGetTypeName (ObjectType))); + } + else + { + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "[%s] Both Find or Create allowed\n", + AcpiUtGetTypeName (ObjectType))); + } + + /* + * Enter the named type into the internal namespace. We enter the name + * as we go downward in the parse tree. Any necessary subobjects that + * involve arguments to the opcode must be created as we go back up the + * parse tree later. + */ + Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType, + ACPI_IMODE_LOAD_PASS1, Flags, WalkState, &Node); + if (ACPI_FAILURE (Status)) + { + if (Status == AE_ALREADY_EXISTS) + { + /* The name already exists in this scope */ + + if (Node->Flags & ANOBJ_IS_EXTERNAL) + { + /* + * Allow one create on an object or segment that was + * previously declared External + */ + Node->Flags &= ~ANOBJ_IS_EXTERNAL; + Node->Type = (UINT8) ObjectType; + + /* Just retyped a node, probably will need to open a scope */ + + if (AcpiNsOpensScope (ObjectType)) + { + Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + Status = AE_OK; + } + } + + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR_NAMESPACE (Path, Status); + return_ACPI_STATUS (Status); + } + } + break; + } + + /* Common exit */ + + if (!Op) + { + /* Create a new op */ + + Op = AcpiPsAllocOp (WalkState->Opcode); + if (!Op) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + } + + /* Initialize the op */ + +#if (defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY)) + Op->Named.Path = ACPI_CAST_PTR (UINT8, Path); +#endif + + if (Node) + { + /* + * Put the Node in the "op" object that the parser uses, so we + * can get it again quickly when this scope is closed + */ + Op->Common.Node = Node; + Op->Named.Name = Node->Name.Integer; + } + + AcpiPsAppendArg (AcpiPsGetParentScope (&WalkState->ParserState), Op); + *OutOp = Op; + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsLoad1EndOp + * + * PARAMETERS: WalkState - Current state of the parse tree walk + * + * RETURN: Status + * + * DESCRIPTION: Ascending callback used during the loading of the namespace, + * both control methods and everything else. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsLoad1EndOp ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_PARSE_OBJECT *Op; + ACPI_OBJECT_TYPE ObjectType; + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (DsLoad1EndOp); + + + Op = WalkState->Op; + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState)); + + /* We are only interested in opcodes that have an associated name */ + + if (!(WalkState->OpInfo->Flags & (AML_NAMED | AML_FIELD))) + { + return_ACPI_STATUS (AE_OK); + } + + /* Get the object type to determine if we should pop the scope */ + + ObjectType = WalkState->OpInfo->ObjectType; + +#ifndef ACPI_NO_METHOD_EXECUTION + if (WalkState->OpInfo->Flags & AML_FIELD) + { + /* + * If we are executing a method, do not create any namespace objects + * during the load phase, only during execution. + */ + if (!WalkState->MethodNode) + { + if (WalkState->Opcode == AML_FIELD_OP || + WalkState->Opcode == AML_BANK_FIELD_OP || + WalkState->Opcode == AML_INDEX_FIELD_OP) + { + Status = AcpiDsInitFieldObjects (Op, WalkState); + } + } + return_ACPI_STATUS (Status); + } + + /* + * If we are executing a method, do not create any namespace objects + * during the load phase, only during execution. + */ + if (!WalkState->MethodNode) + { + if (Op->Common.AmlOpcode == AML_REGION_OP) + { + Status = AcpiExCreateRegion (Op->Named.Data, Op->Named.Length, + (ACPI_ADR_SPACE_TYPE) ((Op->Common.Value.Arg)->Common.Value.Integer), + WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + else if (Op->Common.AmlOpcode == AML_DATA_REGION_OP) + { + Status = AcpiExCreateRegion (Op->Named.Data, Op->Named.Length, + 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); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsLoad2BeginOp + * + * PARAMETERS: WalkState - Current state of the parse tree walk + * OutOp - Wher to return op if a new one is created + * + * RETURN: Status + * + * DESCRIPTION: Descending callback used during the loading of ACPI tables. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsLoad2BeginOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT **OutOp) +{ + ACPI_PARSE_OBJECT *Op; + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + ACPI_OBJECT_TYPE ObjectType; + char *BufferPtr; + UINT32 Flags; + + + ACPI_FUNCTION_TRACE (DsLoad2BeginOp); + + + Op = WalkState->Op; + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p State=%p\n", Op, WalkState)); + + if (Op) + { + if ((WalkState->ControlState) && + (WalkState->ControlState->Common.State == + ACPI_CONTROL_CONDITIONAL_EXECUTING)) + { + /* We are executing a while loop outside of a method */ + + Status = AcpiDsExecBeginOp (WalkState, OutOp); + return_ACPI_STATUS (Status); + } + + /* We only care about Namespace opcodes here */ + + if ((!(WalkState->OpInfo->Flags & AML_NSOPCODE) && + (WalkState->Opcode != AML_INT_NAMEPATH_OP)) || + (!(WalkState->OpInfo->Flags & AML_NAMED))) + { + return_ACPI_STATUS (AE_OK); + } + + /* Get the name we are going to enter or lookup in the namespace */ + + if (WalkState->Opcode == AML_INT_NAMEPATH_OP) + { + /* For Namepath op, get the path string */ + + BufferPtr = Op->Common.Value.String; + if (!BufferPtr) + { + /* No name, just exit */ + + return_ACPI_STATUS (AE_OK); + } + } + else + { + /* Get name from the op */ + + BufferPtr = ACPI_CAST_PTR (char, &Op->Named.Name); + } + } + else + { + /* Get the namestring from the raw AML */ + + BufferPtr = AcpiPsGetNextNamestring (&WalkState->ParserState); + } + + /* Map the opcode into an internal object type */ + + ObjectType = WalkState->OpInfo->ObjectType; + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "State=%p Op=%p Type=%X\n", WalkState, Op, ObjectType)); + + switch (WalkState->Opcode) + { + case AML_FIELD_OP: + case AML_BANK_FIELD_OP: + case AML_INDEX_FIELD_OP: + + Node = NULL; + Status = AE_OK; + break; + + case AML_INT_NAMEPATH_OP: + /* + * The NamePath is an object reference to an existing object. + * Don't enter the name into the namespace, but look it up + * for use later. + */ + Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType, + ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, + WalkState, &(Node)); + break; + + case AML_SCOPE_OP: + + /* Special case for Scope(\) -> refers to the Root node */ + + if (Op && (Op->Named.Node == AcpiGbl_RootNode)) + { + Node = Op->Named.Node; + + Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + else + { + /* + * The Path is an object reference to an existing object. + * Don't enter the name into the namespace, but look it up + * for use later. + */ + Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType, + ACPI_IMODE_EXECUTE, ACPI_NS_SEARCH_PARENT, + WalkState, &(Node)); + if (ACPI_FAILURE (Status)) + { +#ifdef ACPI_ASL_COMPILER + if (Status == AE_NOT_FOUND) + { + Status = AE_OK; + } + else + { + ACPI_ERROR_NAMESPACE (BufferPtr, Status); + } +#else + ACPI_ERROR_NAMESPACE (BufferPtr, Status); +#endif + return_ACPI_STATUS (Status); + } + } + + /* + * We must check to make sure that the target is + * one of the opcodes that actually opens a scope + */ + switch (Node->Type) + { + case ACPI_TYPE_ANY: + case ACPI_TYPE_LOCAL_SCOPE: /* Scope */ + case ACPI_TYPE_DEVICE: + case ACPI_TYPE_POWER: + case ACPI_TYPE_PROCESSOR: + case ACPI_TYPE_THERMAL: + + /* These are acceptable types */ + break; + + case ACPI_TYPE_INTEGER: + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + + /* + * These types we will allow, but we will change the type. + * This enables some existing code of the form: + * + * Name (DEB, 0) + * Scope (DEB) { ... } + */ + ACPI_WARNING ((AE_INFO, + "Type override - [%4.4s] had invalid type (%s) " + "for Scope operator, changed to type ANY\n", + AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type))); + + Node->Type = ACPI_TYPE_ANY; + WalkState->ScopeInfo->Common.Value = ACPI_TYPE_ANY; + break; + + default: + + /* All other types are an error */ + + ACPI_ERROR ((AE_INFO, + "Invalid type (%s) for target of " + "Scope operator [%4.4s] (Cannot override)", + AcpiUtGetTypeName (Node->Type), AcpiUtGetNodeName (Node))); + + return (AE_AML_OPERAND_TYPE); + } + break; + + default: + + /* All other opcodes */ + + if (Op && Op->Common.Node) + { + /* This op/node was previously entered into the namespace */ + + Node = Op->Common.Node; + + if (AcpiNsOpensScope (ObjectType)) + { + Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + return_ACPI_STATUS (AE_OK); + } + + /* + * Enter the named type into the internal namespace. We enter the name + * as we go downward in the parse tree. Any necessary subobjects that + * involve arguments to the opcode must be created as we go back up the + * parse tree later. + * + * Note: Name may already exist if we are executing a deferred opcode. + */ + if (WalkState->DeferredNode) + { + /* This name is already in the namespace, get the node */ + + Node = WalkState->DeferredNode; + Status = AE_OK; + break; + } + + Flags = ACPI_NS_NO_UPSEARCH; + if (WalkState->PassNumber == ACPI_IMODE_EXECUTE) + { + /* Execution mode, node cannot already exist, node is temporary */ + + Flags |= ACPI_NS_ERROR_IF_FOUND; + + if (!(WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL)) + { + Flags |= ACPI_NS_TEMPORARY; + } + } + + /* Add new entry or lookup existing entry */ + + Status = AcpiNsLookup (WalkState->ScopeInfo, BufferPtr, ObjectType, + ACPI_IMODE_LOAD_PASS2, Flags, WalkState, &Node); + + if (ACPI_SUCCESS (Status) && (Flags & ACPI_NS_TEMPORARY)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "***New Node [%4.4s] %p is temporary\n", + AcpiUtGetNodeName (Node), Node)); + } + break; + } + + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR_NAMESPACE (BufferPtr, Status); + return_ACPI_STATUS (Status); + } + + if (!Op) + { + /* Create a new op */ + + Op = AcpiPsAllocOp (WalkState->Opcode); + if (!Op) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Initialize the new op */ + + if (Node) + { + Op->Named.Name = Node->Name.Integer; + } + *OutOp = Op; + } + + /* + * Put the Node in the "op" object that the parser uses, so we + * can get it again quickly when this scope is closed + */ + Op->Common.Node = Node; + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsLoad2EndOp + * + * PARAMETERS: WalkState - Current state of the parse tree walk + * + * RETURN: Status + * + * DESCRIPTION: Ascending callback used during the loading of the namespace, + * both control methods and everything else. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsLoad2EndOp ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_PARSE_OBJECT *Op; + ACPI_STATUS Status = AE_OK; + ACPI_OBJECT_TYPE ObjectType; + ACPI_NAMESPACE_NODE *Node; + ACPI_PARSE_OBJECT *Arg; + ACPI_NAMESPACE_NODE *NewNode; +#ifndef ACPI_NO_METHOD_EXECUTION + UINT32 i; + UINT8 RegionSpace; +#endif + + + ACPI_FUNCTION_TRACE (DsLoad2EndOp); + + Op = WalkState->Op; + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Opcode [%s] Op %p State %p\n", + WalkState->OpInfo->Name, Op, WalkState)); + + /* Check if opcode had an associated namespace object */ + + if (!(WalkState->OpInfo->Flags & AML_NSOBJECT)) + { + return_ACPI_STATUS (AE_OK); + } + + if (Op->Common.AmlOpcode == AML_SCOPE_OP) + { + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "Ending scope Op=%p State=%p\n", Op, WalkState)); + } + + ObjectType = WalkState->OpInfo->ObjectType; + + /* + * Get the Node/name from the earlier lookup + * (It was saved in the *op structure) + */ + Node = Op->Common.Node; + + /* + * Put the Node on the object stack (Contains the ACPI Name of + * this object) + */ + WalkState->Operands[0] = (void *) Node; + WalkState->NumOperands = 1; + + /* Pop the scope stack */ + + if (AcpiNsOpensScope (ObjectType) && + (Op->Common.AmlOpcode != AML_INT_METHODCALL_OP)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "(%s) Popping scope for Op %p\n", + AcpiUtGetTypeName (ObjectType), Op)); + + Status = AcpiDsScopeStackPop (WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + } + + /* + * Named operations are as follows: + * + * AML_ALIAS + * AML_BANKFIELD + * AML_CREATEBITFIELD + * AML_CREATEBYTEFIELD + * AML_CREATEDWORDFIELD + * AML_CREATEFIELD + * AML_CREATEQWORDFIELD + * AML_CREATEWORDFIELD + * AML_DATA_REGION + * AML_DEVICE + * AML_EVENT + * AML_FIELD + * AML_INDEXFIELD + * AML_METHOD + * AML_METHODCALL + * AML_MUTEX + * AML_NAME + * AML_NAMEDFIELD + * AML_OPREGION + * AML_POWERRES + * AML_PROCESSOR + * AML_SCOPE + * AML_THERMALZONE + */ + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "Create-Load [%s] State=%p Op=%p NamedObj=%p\n", + AcpiPsGetOpcodeName (Op->Common.AmlOpcode), WalkState, Op, Node)); + + /* Decode the opcode */ + + Arg = Op->Common.Value.Arg; + + switch (WalkState->OpInfo->Type) + { +#ifndef ACPI_NO_METHOD_EXECUTION + + case AML_TYPE_CREATE_FIELD: + /* + * Create the field object, but the field buffer and index must + * be evaluated later during the execution phase + */ + Status = AcpiDsCreateBufferField (Op, WalkState); + break; + + + case AML_TYPE_NAMED_FIELD: + /* + * If we are executing a method, initialize the field + */ + if (WalkState->MethodNode) + { + Status = AcpiDsInitFieldObjects (Op, WalkState); + } + + switch (Op->Common.AmlOpcode) + { + case AML_INDEX_FIELD_OP: + + Status = AcpiDsCreateIndexField (Op, (ACPI_HANDLE) Arg->Common.Node, + WalkState); + break; + + case AML_BANK_FIELD_OP: + + Status = AcpiDsCreateBankField (Op, Arg->Common.Node, WalkState); + break; + + case AML_FIELD_OP: + + Status = AcpiDsCreateField (Op, Arg->Common.Node, WalkState); + break; + + default: + /* All NAMED_FIELD opcodes must be handled above */ + break; + } + break; + + + case AML_TYPE_NAMED_SIMPLE: + + Status = AcpiDsCreateOperands (WalkState, Arg); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + switch (Op->Common.AmlOpcode) + { + case AML_PROCESSOR_OP: + + Status = AcpiExCreateProcessor (WalkState); + break; + + case AML_POWER_RES_OP: + + Status = AcpiExCreatePowerResource (WalkState); + break; + + case AML_MUTEX_OP: + + Status = AcpiExCreateMutex (WalkState); + break; + + case AML_EVENT_OP: + + Status = AcpiExCreateEvent (WalkState); + break; + + + case AML_ALIAS_OP: + + Status = AcpiExCreateAlias (WalkState); + break; + + default: + /* Unknown opcode */ + + Status = AE_OK; + goto Cleanup; + } + + /* Delete operands */ + + for (i = 1; i < WalkState->NumOperands; i++) + { + AcpiUtRemoveReference (WalkState->Operands[i]); + WalkState->Operands[i] = NULL; + } + + break; +#endif /* ACPI_NO_METHOD_EXECUTION */ + + case AML_TYPE_NAMED_COMPLEX: + + switch (Op->Common.AmlOpcode) + { +#ifndef ACPI_NO_METHOD_EXECUTION + case AML_REGION_OP: + case AML_DATA_REGION_OP: + + if (Op->Common.AmlOpcode == AML_REGION_OP) + { + RegionSpace = (ACPI_ADR_SPACE_TYPE) + ((Op->Common.Value.Arg)->Common.Value.Integer); + } + else + { + RegionSpace = REGION_DATA_TABLE; + } + + /* + * The OpRegion is not fully parsed at this time. The only valid + * argument is the SpaceId. (We must save the address of the + * AML of the address and length operands) + * + * If we have a valid region, initialize it. The namespace is + * unlocked at this point. + * + * Need to unlock interpreter if it is locked (if we are running + * a control method), in order to allow _REG methods to be run + * during AcpiEvInitializeRegion. + */ + if (WalkState->MethodNode) + { + /* + * Executing a method: initialize the region and unlock + * the interpreter + */ + Status = AcpiExCreateRegion (Op->Named.Data, Op->Named.Length, + RegionSpace, WalkState); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + AcpiExExitInterpreter (); + } + + Status = AcpiEvInitializeRegion (AcpiNsGetAttachedObject (Node), + FALSE); + if (WalkState->MethodNode) + { + AcpiExEnterInterpreter (); + } + + if (ACPI_FAILURE (Status)) + { + /* + * If AE_NOT_EXIST is returned, it is not fatal + * because many regions get created before a handler + * is installed for said region. + */ + if (AE_NOT_EXIST == Status) + { + Status = AE_OK; + } + } + break; + + + case AML_NAME_OP: + + Status = AcpiDsCreateNode (WalkState, Node, Op); + break; + + + case AML_METHOD_OP: + /* + * MethodOp PkgLength NameString MethodFlags TermList + * + * Note: We must create the method node/object pair as soon as we + * see the method declaration. This allows later pass1 parsing + * of invocations of the method (need to know the number of + * arguments.) + */ + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "LOADING-Method: State=%p Op=%p NamedObj=%p\n", + WalkState, Op, Op->Named.Node)); + + if (!AcpiNsGetAttachedObject (Op->Named.Node)) + { + WalkState->Operands[0] = ACPI_CAST_PTR (void, Op->Named.Node); + WalkState->NumOperands = 1; + + Status = AcpiDsCreateOperands (WalkState, Op->Common.Value.Arg); + if (ACPI_SUCCESS (Status)) + { + Status = AcpiExCreateMethod (Op->Named.Data, + Op->Named.Length, WalkState); + } + WalkState->Operands[0] = NULL; + WalkState->NumOperands = 0; + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + break; + +#endif /* ACPI_NO_METHOD_EXECUTION */ + + default: + /* All NAMED_COMPLEX opcodes must be handled above */ + break; + } + break; + + + case AML_CLASS_INTERNAL: + + /* case AML_INT_NAMEPATH_OP: */ + break; + + + case AML_CLASS_METHOD_CALL: + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "RESOLVING-MethodCall: State=%p Op=%p NamedObj=%p\n", + WalkState, Op, Node)); + + /* + * Lookup the method name and save the Node + */ + Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String, + ACPI_TYPE_ANY, ACPI_IMODE_LOAD_PASS2, + ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, + WalkState, &(NewNode)); + if (ACPI_SUCCESS (Status)) + { + /* + * Make sure that what we found is indeed a method + * We didn't search for a method on purpose, to see if the name + * would resolve + */ + if (NewNode->Type != ACPI_TYPE_METHOD) + { + Status = AE_AML_OPERAND_TYPE; + } + + /* We could put the returned object (Node) on the object stack for + * later, but for now, we will put it in the "op" object that the + * parser uses, so we can get it again at the end of this scope + */ + Op->Common.Node = NewNode; + } + else + { + ACPI_ERROR_NAMESPACE (Arg->Common.Value.String, Status); + } + break; + + + default: + break; + } + +Cleanup: + + /* Remove the Node pushed at the very beginning */ + + WalkState->Operands[0] = NULL; + WalkState->NumOperands = 0; + return_ACPI_STATUS (Status); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/dispatcher/dswscope.c b/reactos/drivers/bus/acpi/acpica/dispatcher/dswscope.c new file mode 100644 index 00000000000..023f9ef6662 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/dispatcher/dswscope.c @@ -0,0 +1,311 @@ +/****************************************************************************** + * + * Module Name: dswscope - Scope stack manipulation + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __DSWSCOPE_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acdispat.h" + + +#define _COMPONENT ACPI_DISPATCHER + ACPI_MODULE_NAME ("dswscope") + + +/**************************************************************************** + * + * FUNCTION: AcpiDsScopeStackClear + * + * PARAMETERS: WalkState - Current state + * + * RETURN: None + * + * DESCRIPTION: Pop (and free) everything on the scope stack except the + * root scope object (which remains at the stack top.) + * + ***************************************************************************/ + +void +AcpiDsScopeStackClear ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_GENERIC_STATE *ScopeInfo; + + ACPI_FUNCTION_NAME (DsScopeStackClear); + + + while (WalkState->ScopeInfo) + { + /* Pop a scope off the stack */ + + ScopeInfo = WalkState->ScopeInfo; + WalkState->ScopeInfo = ScopeInfo->Scope.Next; + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Popped object type (%s)\n", + AcpiUtGetTypeName (ScopeInfo->Common.Value))); + AcpiUtDeleteGenericState (ScopeInfo); + } +} + + +/**************************************************************************** + * + * FUNCTION: AcpiDsScopeStackPush + * + * PARAMETERS: Node - Name to be made current + * Type - Type of frame being pushed + * WalkState - Current state + * + * RETURN: Status + * + * DESCRIPTION: Push the current scope on the scope stack, and make the + * passed Node current. + * + ***************************************************************************/ + +ACPI_STATUS +AcpiDsScopeStackPush ( + ACPI_NAMESPACE_NODE *Node, + ACPI_OBJECT_TYPE Type, + ACPI_WALK_STATE *WalkState) +{ + ACPI_GENERIC_STATE *ScopeInfo; + ACPI_GENERIC_STATE *OldScopeInfo; + + + ACPI_FUNCTION_TRACE (DsScopeStackPush); + + + if (!Node) + { + /* Invalid scope */ + + ACPI_ERROR ((AE_INFO, "Null scope parameter")); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Make sure object type is valid */ + + if (!AcpiUtValidObjectType (Type)) + { + ACPI_WARNING ((AE_INFO, + "Invalid object type: 0x%X", Type)); + } + + /* Allocate a new scope object */ + + ScopeInfo = AcpiUtCreateGenericState (); + if (!ScopeInfo) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Init new scope object */ + + ScopeInfo->Common.DescriptorType = ACPI_DESC_TYPE_STATE_WSCOPE; + ScopeInfo->Scope.Node = Node; + ScopeInfo->Common.Value = (UINT16) Type; + + WalkState->ScopeDepth++; + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "[%.2d] Pushed scope ", (UINT32) WalkState->ScopeDepth)); + + OldScopeInfo = WalkState->ScopeInfo; + if (OldScopeInfo) + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, + "[%4.4s] (%s)", + AcpiUtGetNodeName (OldScopeInfo->Scope.Node), + AcpiUtGetTypeName (OldScopeInfo->Common.Value))); + } + else + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, + "[\\___] (%s)", "ROOT")); + } + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, + ", New scope -> [%4.4s] (%s)\n", + AcpiUtGetNodeName (ScopeInfo->Scope.Node), + AcpiUtGetTypeName (ScopeInfo->Common.Value))); + + /* Push new scope object onto stack */ + + AcpiUtPushGenericState (&WalkState->ScopeInfo, ScopeInfo); + return_ACPI_STATUS (AE_OK); +} + + +/**************************************************************************** + * + * FUNCTION: AcpiDsScopeStackPop + * + * PARAMETERS: WalkState - Current state + * + * RETURN: Status + * + * DESCRIPTION: Pop the scope stack once. + * + ***************************************************************************/ + +ACPI_STATUS +AcpiDsScopeStackPop ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_GENERIC_STATE *ScopeInfo; + ACPI_GENERIC_STATE *NewScopeInfo; + + + ACPI_FUNCTION_TRACE (DsScopeStackPop); + + + /* + * Pop scope info object off the stack. + */ + ScopeInfo = AcpiUtPopGenericState (&WalkState->ScopeInfo); + if (!ScopeInfo) + { + return_ACPI_STATUS (AE_STACK_UNDERFLOW); + } + + WalkState->ScopeDepth--; + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "[%.2d] Popped scope [%4.4s] (%s), New scope -> ", + (UINT32) WalkState->ScopeDepth, + AcpiUtGetNodeName (ScopeInfo->Scope.Node), + AcpiUtGetTypeName (ScopeInfo->Common.Value))); + + NewScopeInfo = WalkState->ScopeInfo; + if (NewScopeInfo) + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, + "[%4.4s] (%s)\n", + AcpiUtGetNodeName (NewScopeInfo->Scope.Node), + AcpiUtGetTypeName (NewScopeInfo->Common.Value))); + } + else + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, + "[\\___] (ROOT)\n")); + } + + AcpiUtDeleteGenericState (ScopeInfo); + return_ACPI_STATUS (AE_OK); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/dispatcher/dswstate.c b/reactos/drivers/bus/acpi/acpica/dispatcher/dswstate.c new file mode 100644 index 00000000000..f0962bf53f1 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/dispatcher/dswstate.c @@ -0,0 +1,918 @@ +/****************************************************************************** + * + * Module Name: dswstate - Dispatcher parse tree walk management routines + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __DSWSTATE_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acparser.h" +#include "acdispat.h" +#include "acnamesp.h" + +#define _COMPONENT ACPI_DISPATCHER + ACPI_MODULE_NAME ("dswstate") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiDsResultStackPush ( + ACPI_WALK_STATE *WalkState); + +static ACPI_STATUS +AcpiDsResultStackPop ( + ACPI_WALK_STATE *WalkState); + + +/******************************************************************************* + * + * FUNCTION: AcpiDsResultPop + * + * PARAMETERS: Object - Where to return the popped object + * WalkState - Current Walk state + * + * RETURN: Status + * + * DESCRIPTION: Pop an object off the top of this walk's result stack + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsResultPop ( + ACPI_OPERAND_OBJECT **Object, + ACPI_WALK_STATE *WalkState) +{ + UINT32 Index; + ACPI_GENERIC_STATE *State; + ACPI_STATUS Status; + + + ACPI_FUNCTION_NAME (DsResultPop); + + + State = WalkState->Results; + + /* Incorrect state of result stack */ + + if (State && !WalkState->ResultCount) + { + ACPI_ERROR ((AE_INFO, "No results on result stack")); + return (AE_AML_INTERNAL); + } + + if (!State && WalkState->ResultCount) + { + ACPI_ERROR ((AE_INFO, "No result state for result stack")); + return (AE_AML_INTERNAL); + } + + /* Empty result stack */ + + if (!State) + { + ACPI_ERROR ((AE_INFO, "Result stack is empty! State=%p", WalkState)); + return (AE_AML_NO_RETURN_VALUE); + } + + /* Return object of the top element and clean that top element result stack */ + + WalkState->ResultCount--; + Index = (UINT32) WalkState->ResultCount % ACPI_RESULTS_FRAME_OBJ_NUM; + + *Object = State->Results.ObjDesc [Index]; + if (!*Object) + { + ACPI_ERROR ((AE_INFO, "No result objects on result stack, State=%p", + WalkState)); + return (AE_AML_NO_RETURN_VALUE); + } + + State->Results.ObjDesc [Index] = NULL; + if (Index == 0) + { + Status = AcpiDsResultStackPop (WalkState); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Obj=%p [%s] Index=%X State=%p Num=%X\n", *Object, + AcpiUtGetObjectTypeName (*Object), + Index, WalkState, WalkState->ResultCount)); + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsResultPush + * + * PARAMETERS: Object - Where to return the popped object + * WalkState - Current Walk state + * + * RETURN: Status + * + * DESCRIPTION: Push an object onto the current result stack + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsResultPush ( + ACPI_OPERAND_OBJECT *Object, + ACPI_WALK_STATE *WalkState) +{ + ACPI_GENERIC_STATE *State; + ACPI_STATUS Status; + UINT32 Index; + + + ACPI_FUNCTION_NAME (DsResultPush); + + + if (WalkState->ResultCount > WalkState->ResultSize) + { + ACPI_ERROR ((AE_INFO, "Result stack is full")); + return (AE_AML_INTERNAL); + } + else if (WalkState->ResultCount == WalkState->ResultSize) + { + /* Extend the result stack */ + + Status = AcpiDsResultStackPush (WalkState); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR ((AE_INFO, "Failed to extend the result stack")); + return (Status); + } + } + + if (!(WalkState->ResultCount < WalkState->ResultSize)) + { + ACPI_ERROR ((AE_INFO, "No free elements in result stack")); + return (AE_AML_INTERNAL); + } + + State = WalkState->Results; + if (!State) + { + ACPI_ERROR ((AE_INFO, "No result stack frame during push")); + return (AE_AML_INTERNAL); + } + + if (!Object) + { + ACPI_ERROR ((AE_INFO, + "Null Object! Obj=%p State=%p Num=%X", + Object, WalkState, WalkState->ResultCount)); + return (AE_BAD_PARAMETER); + } + + /* Assign the address of object to the top free element of result stack */ + + Index = (UINT32) WalkState->ResultCount % ACPI_RESULTS_FRAME_OBJ_NUM; + State->Results.ObjDesc [Index] = Object; + WalkState->ResultCount++; + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p Num=%X Cur=%X\n", + Object, AcpiUtGetObjectTypeName ((ACPI_OPERAND_OBJECT *) Object), + WalkState, WalkState->ResultCount, WalkState->CurrentResult)); + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsResultStackPush + * + * PARAMETERS: WalkState - Current Walk state + * + * RETURN: Status + * + * DESCRIPTION: Push an object onto the WalkState result stack + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDsResultStackPush ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_GENERIC_STATE *State; + + + ACPI_FUNCTION_NAME (DsResultStackPush); + + + /* Check for stack overflow */ + + if (((UINT32) WalkState->ResultSize + ACPI_RESULTS_FRAME_OBJ_NUM) > + ACPI_RESULTS_OBJ_NUM_MAX) + { + ACPI_ERROR ((AE_INFO, "Result stack overflow: State=%p Num=%X", + WalkState, WalkState->ResultSize)); + return (AE_STACK_OVERFLOW); + } + + State = AcpiUtCreateGenericState (); + if (!State) + { + return (AE_NO_MEMORY); + } + + State->Common.DescriptorType = ACPI_DESC_TYPE_STATE_RESULT; + AcpiUtPushGenericState (&WalkState->Results, State); + + /* Increase the length of the result stack by the length of frame */ + + WalkState->ResultSize += ACPI_RESULTS_FRAME_OBJ_NUM; + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Results=%p State=%p\n", + State, WalkState)); + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsResultStackPop + * + * PARAMETERS: WalkState - Current Walk state + * + * RETURN: Status + * + * DESCRIPTION: Pop an object off of the WalkState result stack + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiDsResultStackPop ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_GENERIC_STATE *State; + + + ACPI_FUNCTION_NAME (DsResultStackPop); + + + /* Check for stack underflow */ + + if (WalkState->Results == NULL) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Result stack underflow - State=%p\n", + WalkState)); + return (AE_AML_NO_OPERAND); + } + + if (WalkState->ResultSize < ACPI_RESULTS_FRAME_OBJ_NUM) + { + ACPI_ERROR ((AE_INFO, "Insufficient result stack size")); + return (AE_AML_INTERNAL); + } + + State = AcpiUtPopGenericState (&WalkState->Results); + AcpiUtDeleteGenericState (State); + + /* Decrease the length of result stack by the length of frame */ + + WalkState->ResultSize -= ACPI_RESULTS_FRAME_OBJ_NUM; + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Result=%p RemainingResults=%X State=%p\n", + State, WalkState->ResultCount, WalkState)); + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsObjStackPush + * + * PARAMETERS: Object - Object to push + * WalkState - Current Walk state + * + * RETURN: Status + * + * DESCRIPTION: Push an object onto this walk's object/operand stack + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsObjStackPush ( + void *Object, + ACPI_WALK_STATE *WalkState) +{ + ACPI_FUNCTION_NAME (DsObjStackPush); + + + /* Check for stack overflow */ + + if (WalkState->NumOperands >= ACPI_OBJ_NUM_OPERANDS) + { + ACPI_ERROR ((AE_INFO, + "Object stack overflow! Obj=%p State=%p #Ops=%X", + Object, WalkState, WalkState->NumOperands)); + return (AE_STACK_OVERFLOW); + } + + /* Put the object onto the stack */ + + WalkState->Operands [WalkState->OperandIndex] = Object; + WalkState->NumOperands++; + + /* For the usual order of filling the operand stack */ + + WalkState->OperandIndex++; + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p [%s] State=%p #Ops=%X\n", + Object, AcpiUtGetObjectTypeName ((ACPI_OPERAND_OBJECT *) Object), + WalkState, WalkState->NumOperands)); + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsObjStackPop + * + * PARAMETERS: PopCount - Number of objects/entries to pop + * WalkState - Current Walk state + * + * RETURN: Status + * + * DESCRIPTION: Pop this walk's object stack. Objects on the stack are NOT + * deleted by this routine. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsObjStackPop ( + UINT32 PopCount, + ACPI_WALK_STATE *WalkState) +{ + UINT32 i; + + + ACPI_FUNCTION_NAME (DsObjStackPop); + + + for (i = 0; i < PopCount; i++) + { + /* Check for stack underflow */ + + if (WalkState->NumOperands == 0) + { + ACPI_ERROR ((AE_INFO, + "Object stack underflow! Count=%X State=%p #Ops=%X", + PopCount, WalkState, WalkState->NumOperands)); + return (AE_STACK_UNDERFLOW); + } + + /* Just set the stack entry to null */ + + WalkState->NumOperands--; + WalkState->Operands [WalkState->NumOperands] = NULL; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Count=%X State=%p #Ops=%X\n", + PopCount, WalkState, WalkState->NumOperands)); + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsObjStackPopAndDelete + * + * PARAMETERS: PopCount - Number of objects/entries to pop + * WalkState - Current Walk state + * + * RETURN: Status + * + * DESCRIPTION: Pop this walk's object stack and delete each object that is + * popped off. + * + ******************************************************************************/ + +void +AcpiDsObjStackPopAndDelete ( + UINT32 PopCount, + ACPI_WALK_STATE *WalkState) +{ + INT32 i; + ACPI_OPERAND_OBJECT *ObjDesc; + + + ACPI_FUNCTION_NAME (DsObjStackPopAndDelete); + + + if (PopCount == 0) + { + return; + } + + for (i = (INT32) PopCount - 1; i >= 0; i--) + { + if (WalkState->NumOperands == 0) + { + return; + } + + /* Pop the stack and delete an object if present in this stack entry */ + + WalkState->NumOperands--; + ObjDesc = WalkState->Operands [i]; + if (ObjDesc) + { + AcpiUtRemoveReference (WalkState->Operands [i]); + WalkState->Operands [i] = NULL; + } + } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Count=%X State=%p #Ops=%X\n", + PopCount, WalkState, WalkState->NumOperands)); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsGetCurrentWalkState + * + * PARAMETERS: Thread - Get current active state for this Thread + * + * RETURN: Pointer to the current walk state + * + * DESCRIPTION: Get the walk state that is at the head of the list (the "current" + * walk state.) + * + ******************************************************************************/ + +ACPI_WALK_STATE * +AcpiDsGetCurrentWalkState ( + ACPI_THREAD_STATE *Thread) +{ + ACPI_FUNCTION_NAME (DsGetCurrentWalkState); + + + if (!Thread) + { + return (NULL); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Current WalkState %p\n", + Thread->WalkStateList)); + + return (Thread->WalkStateList); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsPushWalkState + * + * PARAMETERS: WalkState - State to push + * Thread - Thread state object + * + * RETURN: None + * + * DESCRIPTION: Place the Thread state at the head of the state list + * + ******************************************************************************/ + +void +AcpiDsPushWalkState ( + ACPI_WALK_STATE *WalkState, + ACPI_THREAD_STATE *Thread) +{ + ACPI_FUNCTION_TRACE (DsPushWalkState); + + + WalkState->Next = Thread->WalkStateList; + Thread->WalkStateList = WalkState; + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsPopWalkState + * + * PARAMETERS: Thread - Current thread state + * + * RETURN: A WalkState object popped from the thread's stack + * + * DESCRIPTION: Remove and return the walkstate object that is at the head of + * the walk stack for the given walk list. NULL indicates that + * the list is empty. + * + ******************************************************************************/ + +ACPI_WALK_STATE * +AcpiDsPopWalkState ( + ACPI_THREAD_STATE *Thread) +{ + ACPI_WALK_STATE *WalkState; + + + ACPI_FUNCTION_TRACE (DsPopWalkState); + + + WalkState = Thread->WalkStateList; + + if (WalkState) + { + /* Next walk state becomes the current walk state */ + + Thread->WalkStateList = WalkState->Next; + + /* + * Don't clear the NEXT field, this serves as an indicator + * that there is a parent WALK STATE + * Do Not: WalkState->Next = NULL; + */ + } + + return_PTR (WalkState); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsCreateWalkState + * + * PARAMETERS: OwnerId - ID for object creation + * Origin - Starting point for this walk + * MethodDesc - Method object + * Thread - Current thread state + * + * RETURN: Pointer to the new walk state. + * + * DESCRIPTION: Allocate and initialize a new walk state. The current walk + * state is set to this new state. + * + ******************************************************************************/ + +ACPI_WALK_STATE * +AcpiDsCreateWalkState ( + ACPI_OWNER_ID OwnerId, + ACPI_PARSE_OBJECT *Origin, + ACPI_OPERAND_OBJECT *MethodDesc, + ACPI_THREAD_STATE *Thread) +{ + ACPI_WALK_STATE *WalkState; + + + ACPI_FUNCTION_TRACE (DsCreateWalkState); + + + WalkState = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_WALK_STATE)); + if (!WalkState) + { + return_PTR (NULL); + } + + WalkState->DescriptorType = ACPI_DESC_TYPE_WALK; + WalkState->MethodDesc = MethodDesc; + WalkState->OwnerId = OwnerId; + WalkState->Origin = Origin; + WalkState->Thread = Thread; + + WalkState->ParserState.StartOp = Origin; + + /* Init the method args/local */ + +#if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY)) + AcpiDsMethodDataInit (WalkState); +#endif + + /* Put the new state at the head of the walk list */ + + if (Thread) + { + AcpiDsPushWalkState (WalkState, Thread); + } + + return_PTR (WalkState); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsInitAmlWalk + * + * PARAMETERS: WalkState - New state to be initialized + * Op - Current parse op + * MethodNode - Control method NS node, if any + * AmlStart - Start of AML + * AmlLength - Length of AML + * Info - Method info block (params, etc.) + * PassNumber - 1, 2, or 3 + * + * RETURN: Status + * + * DESCRIPTION: Initialize a walk state for a pass 1 or 2 parse tree walk + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDsInitAmlWalk ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + ACPI_NAMESPACE_NODE *MethodNode, + UINT8 *AmlStart, + UINT32 AmlLength, + ACPI_EVALUATE_INFO *Info, + UINT8 PassNumber) +{ + ACPI_STATUS Status; + ACPI_PARSE_STATE *ParserState = &WalkState->ParserState; + ACPI_PARSE_OBJECT *ExtraOp; + + + ACPI_FUNCTION_TRACE (DsInitAmlWalk); + + + WalkState->ParserState.Aml = + WalkState->ParserState.AmlStart = AmlStart; + WalkState->ParserState.AmlEnd = + WalkState->ParserState.PkgEnd = AmlStart + AmlLength; + + /* The NextOp of the NextWalk will be the beginning of the method */ + + WalkState->NextOp = NULL; + WalkState->PassNumber = PassNumber; + + if (Info) + { + WalkState->Params = Info->Parameters; + WalkState->CallerReturnDesc = &Info->ReturnObject; + } + + Status = AcpiPsInitScope (&WalkState->ParserState, Op); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (MethodNode) + { + WalkState->ParserState.StartNode = MethodNode; + WalkState->WalkType = ACPI_WALK_METHOD; + WalkState->MethodNode = MethodNode; + WalkState->MethodDesc = AcpiNsGetAttachedObject (MethodNode); + + /* Push start scope on scope stack and make it current */ + + Status = AcpiDsScopeStackPush (MethodNode, ACPI_TYPE_METHOD, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Init the method arguments */ + + Status = AcpiDsMethodDataInitArgs (WalkState->Params, + ACPI_METHOD_NUM_ARGS, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + else + { + /* + * Setup the current scope. + * Find a Named Op that has a namespace node associated with it. + * search upwards from this Op. Current scope is the first + * Op with a namespace node. + */ + ExtraOp = ParserState->StartOp; + while (ExtraOp && !ExtraOp->Common.Node) + { + ExtraOp = ExtraOp->Common.Parent; + } + + if (!ExtraOp) + { + ParserState->StartNode = NULL; + } + else + { + ParserState->StartNode = ExtraOp->Common.Node; + } + + if (ParserState->StartNode) + { + /* Push start scope on scope stack and make it current */ + + Status = AcpiDsScopeStackPush (ParserState->StartNode, + ParserState->StartNode->Type, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + } + + Status = AcpiDsInitCallbacks (WalkState, PassNumber); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDsDeleteWalkState + * + * PARAMETERS: WalkState - State to delete + * + * RETURN: Status + * + * DESCRIPTION: Delete a walk state including all internal data structures + * + ******************************************************************************/ + +void +AcpiDsDeleteWalkState ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_GENERIC_STATE *State; + + + ACPI_FUNCTION_TRACE_PTR (DsDeleteWalkState, WalkState); + + + if (!WalkState) + { + return; + } + + if (WalkState->DescriptorType != ACPI_DESC_TYPE_WALK) + { + ACPI_ERROR ((AE_INFO, "%p is not a valid walk state", + WalkState)); + return; + } + + /* There should not be any open scopes */ + + if (WalkState->ParserState.Scope) + { + ACPI_ERROR ((AE_INFO, "%p walk still has a scope list", + WalkState)); + AcpiPsCleanupScope (&WalkState->ParserState); + } + + /* Always must free any linked control states */ + + while (WalkState->ControlState) + { + State = WalkState->ControlState; + WalkState->ControlState = State->Common.Next; + + AcpiUtDeleteGenericState (State); + } + + /* Always must free any linked parse states */ + + while (WalkState->ScopeInfo) + { + State = WalkState->ScopeInfo; + WalkState->ScopeInfo = State->Common.Next; + + AcpiUtDeleteGenericState (State); + } + + /* Always must free any stacked result states */ + + while (WalkState->Results) + { + State = WalkState->Results; + WalkState->Results = State->Common.Next; + + AcpiUtDeleteGenericState (State); + } + + ACPI_FREE (WalkState); + return_VOID; +} + + diff --git a/reactos/drivers/bus/acpi/acpica/events/evevent.c b/reactos/drivers/bus/acpi/acpica/events/evevent.c new file mode 100644 index 00000000000..16f40271fcf --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/events/evevent.c @@ -0,0 +1,430 @@ +/****************************************************************************** + * + * Module Name: evevent - Fixed Event handling and dispatch + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 "acpi.h" +#include "accommon.h" +#include "acevents.h" + +#define _COMPONENT ACPI_EVENTS + ACPI_MODULE_NAME ("evevent") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiEvFixedEventInitialize ( + void); + +static UINT32 +AcpiEvFixedEventDispatch ( + UINT32 Event); + + +/******************************************************************************* + * + * FUNCTION: AcpiEvInitializeEvents + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Initialize global data structures for ACPI events (Fixed, GPE) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvInitializeEvents ( + void) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (EvInitializeEvents); + + + /* + * Initialize the Fixed and General Purpose Events. This is done prior to + * enabling SCIs to prevent interrupts from occurring before the handlers + * are installed. + */ + Status = AcpiEvFixedEventInitialize (); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Unable to initialize fixed events")); + return_ACPI_STATUS (Status); + } + + Status = AcpiEvGpeInitialize (); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Unable to initialize general purpose events")); + return_ACPI_STATUS (Status); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: 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 + * + * 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 */ + + Status = AcpiEvInstallSciHandler (); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Unable to install System Control Interrupt handler")); + return_ACPI_STATUS (Status); + } + + /* Install the handler for the Global Lock */ + + Status = AcpiEvInitGlobalLockHandler (); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Unable to initialize Global Lock handler")); + return_ACPI_STATUS (Status); + } + + AcpiGbl_EventsInitialized = TRUE; + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvFixedEventInitialize + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Install the fixed event handlers and disable all fixed events. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiEvFixedEventInitialize ( + void) +{ + UINT32 i; + ACPI_STATUS Status; + + + /* + * Initialize the structure that keeps track of fixed event handlers and + * enable the fixed events. + */ + for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) + { + AcpiGbl_FixedEventHandlers[i].Handler = NULL; + AcpiGbl_FixedEventHandlers[i].Context = NULL; + + /* Disable the fixed event */ + + if (AcpiGbl_FixedEventInfo[i].EnableRegisterId != 0xFF) + { + Status = AcpiWriteBitRegister ( + AcpiGbl_FixedEventInfo[i].EnableRegisterId, + ACPI_DISABLE_EVENT); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvFixedEventDetect + * + * PARAMETERS: None + * + * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED + * + * DESCRIPTION: Checks the PM status register for active fixed events + * + ******************************************************************************/ + +UINT32 +AcpiEvFixedEventDetect ( + void) +{ + UINT32 IntStatus = ACPI_INTERRUPT_NOT_HANDLED; + UINT32 FixedStatus; + UINT32 FixedEnable; + UINT32 i; + + + ACPI_FUNCTION_NAME (EvFixedEventDetect); + + + /* + * Read the fixed feature status and enable registers, as all the cases + * depend on their values. Ignore errors here. + */ + (void) AcpiHwRegisterRead (ACPI_REGISTER_PM1_STATUS, &FixedStatus); + (void) AcpiHwRegisterRead (ACPI_REGISTER_PM1_ENABLE, &FixedEnable); + + ACPI_DEBUG_PRINT ((ACPI_DB_INTERRUPTS, + "Fixed Event Block: Enable %08X Status %08X\n", + FixedEnable, FixedStatus)); + + /* + * Check for all possible Fixed Events and dispatch those that are active + */ + for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) + { + /* Both the status and enable bits must be on for this event */ + + if ((FixedStatus & AcpiGbl_FixedEventInfo[i].StatusBitMask) && + (FixedEnable & AcpiGbl_FixedEventInfo[i].EnableBitMask)) + { + /* Found an active (signalled) event */ + + AcpiFixedEventCount[i]++; + IntStatus |= AcpiEvFixedEventDispatch (i); + } + } + + return (IntStatus); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvFixedEventDispatch + * + * PARAMETERS: Event - Event type + * + * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED + * + * DESCRIPTION: Clears the status bit for the requested event, calls the + * handler that previously registered for the event. + * + ******************************************************************************/ + +static UINT32 +AcpiEvFixedEventDispatch ( + UINT32 Event) +{ + + ACPI_FUNCTION_ENTRY (); + + + /* Clear the status bit */ + + (void) AcpiWriteBitRegister ( + AcpiGbl_FixedEventInfo[Event].StatusRegisterId, + ACPI_CLEAR_STATUS); + + /* + * Make sure we've got a handler. If not, report an error. The event is + * disabled to prevent further interrupts. + */ + if (NULL == AcpiGbl_FixedEventHandlers[Event].Handler) + { + (void) AcpiWriteBitRegister ( + AcpiGbl_FixedEventInfo[Event].EnableRegisterId, + ACPI_DISABLE_EVENT); + + ACPI_ERROR ((AE_INFO, + "No installed handler for fixed event [%08X]", + Event)); + + return (ACPI_INTERRUPT_NOT_HANDLED); + } + + /* Invoke the Fixed Event handler */ + + return ((AcpiGbl_FixedEventHandlers[Event].Handler)( + AcpiGbl_FixedEventHandlers[Event].Context)); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/events/evgpe.c b/reactos/drivers/bus/acpi/acpica/events/evgpe.c new file mode 100644 index 00000000000..00d72e54722 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/events/evgpe.c @@ -0,0 +1,897 @@ +/****************************************************************************** + * + * Module Name: evgpe - General Purpose Event handling and dispatch + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 "acpi.h" +#include "accommon.h" +#include "acevents.h" +#include "acnamesp.h" + +#define _COMPONENT ACPI_EVENTS + ACPI_MODULE_NAME ("evgpe") + +/* Local prototypes */ + +static void ACPI_SYSTEM_XFACE +AcpiEvAsynchExecuteGpeMethod ( + void *Context); + +static void ACPI_SYSTEM_XFACE +AcpiEvAsynchEnableGpe ( + void *Context); + + +/******************************************************************************* + * + * FUNCTION: AcpiEvSetGpeType + * + * PARAMETERS: GpeEventInfo - GPE to set + * Type - New type + * + * RETURN: Status + * + * DESCRIPTION: Sets the new type for the GPE (wake, run, or wake/run) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvSetGpeType ( + ACPI_GPE_EVENT_INFO *GpeEventInfo, + UINT8 Type) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (EvSetGpeType); + + + /* Validate type and update register enable masks */ + + switch (Type) + { + case ACPI_GPE_TYPE_WAKE: + case ACPI_GPE_TYPE_RUNTIME: + case ACPI_GPE_TYPE_WAKE_RUN: + break; + + default: + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Disable the GPE if currently enabled */ + + Status = AcpiEvDisableGpe (GpeEventInfo); + + /* Clear the type bits and insert the new Type */ + + GpeEventInfo->Flags &= ~ACPI_GPE_TYPE_MASK; + GpeEventInfo->Flags |= Type; + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvUpdateGpeEnableMasks + * + * PARAMETERS: GpeEventInfo - GPE to update + * Type - What to do: ACPI_GPE_DISABLE or + * ACPI_GPE_ENABLE + * + * RETURN: Status + * + * DESCRIPTION: Updates GPE register enable masks based on the GPE type + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvUpdateGpeEnableMasks ( + ACPI_GPE_EVENT_INFO *GpeEventInfo, + UINT8 Type) +{ + ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; + UINT8 RegisterBit; + + + ACPI_FUNCTION_TRACE (EvUpdateGpeEnableMasks); + + + GpeRegisterInfo = GpeEventInfo->RegisterInfo; + if (!GpeRegisterInfo) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + RegisterBit = (UINT8) + (1 << (GpeEventInfo->GpeNumber - GpeRegisterInfo->BaseGpeNumber)); + + /* 1) Disable case. Simply clear all enable bits */ + + if (Type == ACPI_GPE_DISABLE) + { + ACPI_CLEAR_BIT (GpeRegisterInfo->EnableForWake, RegisterBit); + ACPI_CLEAR_BIT (GpeRegisterInfo->EnableForRun, RegisterBit); + return_ACPI_STATUS (AE_OK); + } + + /* 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; + + default: + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvEnableGpe + * + * PARAMETERS: GpeEventInfo - GPE to enable + * WriteToHardware - Enable now, or just mark data structs + * (WAKE GPEs should be deferred) + * + * RETURN: Status + * + * DESCRIPTION: Enable a GPE based on the GPE type + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvEnableGpe ( + ACPI_GPE_EVENT_INFO *GpeEventInfo, + BOOLEAN WriteToHardware) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (EvEnableGpe); + + + /* Make sure HW enable masks are updated */ + + Status = AcpiEvUpdateGpeEnableMasks (GpeEventInfo, ACPI_GPE_ENABLE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Mark wake-enabled or HW enable, or both */ + + switch (GpeEventInfo->Flags & ACPI_GPE_TYPE_MASK) + { + 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); + + if (WriteToHardware) + { + /* 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); + } + break; + + default: + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvDisableGpe + * + * PARAMETERS: GpeEventInfo - GPE to disable + * + * RETURN: Status + * + * DESCRIPTION: Disable a GPE based on the GPE type + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvDisableGpe ( + ACPI_GPE_EVENT_INFO *GpeEventInfo) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (EvDisableGpe); + + + /* + * 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)) + { + return_ACPI_STATUS (Status); + } + + /* Clear the appropriate enabled flags for this GPE */ + + switch (GpeEventInfo->Flags & ACPI_GPE_TYPE_MASK) + { + case ACPI_GPE_TYPE_WAKE: + + ACPI_CLEAR_BIT (GpeEventInfo->Flags, ACPI_GPE_WAKE_ENABLED); + break; + + case ACPI_GPE_TYPE_WAKE_RUN: + + ACPI_CLEAR_BIT (GpeEventInfo->Flags, ACPI_GPE_WAKE_ENABLED); + + /*lint -fallthrough */ + + case ACPI_GPE_TYPE_RUNTIME: + + /* Disable the requested runtime GPE */ + + ACPI_CLEAR_BIT (GpeEventInfo->Flags, ACPI_GPE_RUN_ENABLED); + break; + + 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. + */ + Status = AcpiHwLowDisableGpe (GpeEventInfo); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvGetGpeEventInfo + * + * PARAMETERS: GpeDevice - Device node. NULL for GPE0/GPE1 + * GpeNumber - Raw GPE number + * + * RETURN: A GPE EventInfo struct. NULL if not a valid GPE + * + * DESCRIPTION: Returns the EventInfo struct associated with this GPE. + * Validates the GpeBlock and the GpeNumber + * + * Should be called only when the GPE lists are semaphore locked + * and not subject to change. + * + ******************************************************************************/ + +ACPI_GPE_EVENT_INFO * +AcpiEvGetGpeEventInfo ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_GPE_BLOCK_INFO *GpeBlock; + UINT32 i; + + + ACPI_FUNCTION_ENTRY (); + + + /* A NULL GpeBlock means use the FADT-defined GPE block(s) */ + + if (!GpeDevice) + { + /* Examine GPE Block 0 and 1 (These blocks are permanent) */ + + for (i = 0; i < ACPI_MAX_GPE_BLOCKS; i++) + { + GpeBlock = AcpiGbl_GpeFadtBlocks[i]; + if (GpeBlock) + { + if ((GpeNumber >= GpeBlock->BlockBaseNumber) && + (GpeNumber < GpeBlock->BlockBaseNumber + + (GpeBlock->RegisterCount * 8))) + { + return (&GpeBlock->EventInfo[GpeNumber - + GpeBlock->BlockBaseNumber]); + } + } + } + + /* The GpeNumber was not in the range of either FADT GPE block */ + + return (NULL); + } + + /* A Non-NULL GpeDevice means this is a GPE Block Device */ + + ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) GpeDevice); + if (!ObjDesc || + !ObjDesc->Device.GpeBlock) + { + return (NULL); + } + + GpeBlock = ObjDesc->Device.GpeBlock; + + if ((GpeNumber >= GpeBlock->BlockBaseNumber) && + (GpeNumber < GpeBlock->BlockBaseNumber + (GpeBlock->RegisterCount * 8))) + { + return (&GpeBlock->EventInfo[GpeNumber - GpeBlock->BlockBaseNumber]); + } + + return (NULL); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvGpeDetect + * + * PARAMETERS: GpeXruptList - Interrupt block for this interrupt. + * Can have multiple GPE blocks attached. + * + * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED + * + * DESCRIPTION: Detect if any GP events have occurred. This function is + * executed at interrupt level. + * + ******************************************************************************/ + +UINT32 +AcpiEvGpeDetect ( + ACPI_GPE_XRUPT_INFO *GpeXruptList) +{ + ACPI_STATUS Status; + ACPI_GPE_BLOCK_INFO *GpeBlock; + ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; + UINT32 IntStatus = ACPI_INTERRUPT_NOT_HANDLED; + UINT8 EnabledStatusByte; + UINT32 StatusReg; + UINT32 EnableReg; + //ACPI_CPU_FLAGS Flags; + UINT32 i; + UINT32 j; + + + ACPI_FUNCTION_NAME (EvGpeDetect); + + /* Check for the case where there are no GPEs */ + + if (!GpeXruptList) + { + return (IntStatus); + } + + /* + * We need to obtain the GPE lock for both the data structs and registers + * Note: Not necessary to obtain the hardware lock, since the GPE + * registers are owned by the GpeLock. + */ + //Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); + + /* Examine all GPE blocks attached to this interrupt level */ + + GpeBlock = GpeXruptList->GpeBlockListHead; + while (GpeBlock) + { + /* + * Read all of the 8-bit GPE status and enable registers in this GPE + * block, saving all of them. Find all currently active GP events. + */ + for (i = 0; i < GpeBlock->RegisterCount; i++) + { + /* Get the next status/enable pair */ + + GpeRegisterInfo = &GpeBlock->RegisterInfo[i]; + + /* Read the Status Register */ + + Status = AcpiHwRead (&StatusReg, &GpeRegisterInfo->StatusAddress); + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + + /* Read the Enable Register */ + + Status = AcpiHwRead (&EnableReg, &GpeRegisterInfo->EnableAddress); + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_INTERRUPTS, + "Read GPE Register at GPE%X: Status=%02X, Enable=%02X\n", + GpeRegisterInfo->BaseGpeNumber, StatusReg, EnableReg)); + + /* Check if there is anything active at all in this register */ + + EnabledStatusByte = (UINT8) (StatusReg & EnableReg); + if (!EnabledStatusByte) + { + /* No active GPEs in this register, move on */ + + continue; + } + + /* Now look at the individual GPEs in this byte register */ + + for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) + { + /* Examine one GPE bit */ + + if (EnabledStatusByte & (1 << j)) + { + /* + * Found an active GPE. Dispatch the event to a handler + * or method. + */ + IntStatus |= AcpiEvGpeDispatch ( + &GpeBlock->EventInfo[((ACPI_SIZE) i * + ACPI_GPE_REGISTER_WIDTH) + j], + j + GpeRegisterInfo->BaseGpeNumber); + } + } + } + + GpeBlock = GpeBlock->Next; + } + +UnlockAndExit: + + //AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); + return (IntStatus); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvAsynchExecuteGpeMethod + * + * PARAMETERS: Context (GpeEventInfo) - Info for this GPE + * + * RETURN: None + * + * DESCRIPTION: Perform the actual execution of a GPE control method. This + * function is called from an invocation of AcpiOsExecute and + * therefore does NOT execute at interrupt level - so that + * the control method itself is not executed in the context of + * an interrupt handler. + * + ******************************************************************************/ + +static void ACPI_SYSTEM_XFACE +AcpiEvAsynchExecuteGpeMethod ( + void *Context) +{ + ACPI_GPE_EVENT_INFO *GpeEventInfo = Context; + ACPI_STATUS Status; + ACPI_GPE_EVENT_INFO *LocalGpeEventInfo; + ACPI_EVALUATE_INFO *Info; + + + ACPI_FUNCTION_TRACE (EvAsynchExecuteGpeMethod); + + + /* Allocate a local GPE block */ + + LocalGpeEventInfo = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_GPE_EVENT_INFO)); + if (!LocalGpeEventInfo) + { + ACPI_EXCEPTION ((AE_INFO, AE_NO_MEMORY, + "while handling a GPE")); + return_VOID; + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) + { + return_VOID; + } + + /* Must revalidate the GpeNumber/GpeBlock */ + + if (!AcpiEvValidGpeEvent (GpeEventInfo)) + { + Status = AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + return_VOID; + } + + /* 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. + */ + ACPI_MEMCPY (LocalGpeEventInfo, GpeEventInfo, + sizeof (ACPI_GPE_EVENT_INFO)); + + Status = AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) + { + 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) + { + /* Allocate the evaluation information block */ + + Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO)); + if (!Info) + { + Status = AE_NO_MEMORY; + } + else + { + /* + * Invoke the GPE Method (_Lxx, _Exx) i.e., evaluate the _Lxx/_Exx + * control method that corresponds to this GPE + */ + Info->PrefixNode = LocalGpeEventInfo->Dispatch.MethodNode; + Info->Flags = ACPI_IGNORE_RETURN_VALUE; + + Status = AcpiNsEvaluate (Info); + ACPI_FREE (Info); + } + + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "while evaluating GPE method [%4.4s]", + AcpiUtGetNodeName (LocalGpeEventInfo->Dispatch.MethodNode))); + } + } + + /* Defer enabling of GPE until all notify handlers are done */ + + Status = AcpiOsExecute (OSL_NOTIFY_HANDLER, + AcpiEvAsynchEnableGpe, LocalGpeEventInfo); + if (ACPI_FAILURE (Status)) + { + ACPI_FREE (LocalGpeEventInfo); + } + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvAsynchEnableGpe + * + * PARAMETERS: Context (GpeEventInfo) - Info for this GPE + * + * RETURN: None + * + * DESCRIPTION: Asynchronous clear/enable for GPE. This allows the GPE to + * complete (i.e., finish execution of Notify) + * + ******************************************************************************/ + +static void ACPI_SYSTEM_XFACE +AcpiEvAsynchEnableGpe ( + void *Context) +{ + ACPI_GPE_EVENT_INFO *GpeEventInfo = Context; + ACPI_STATUS Status; + + + if ((GpeEventInfo->Flags & ACPI_GPE_XRUPT_TYPE_MASK) == + ACPI_GPE_LEVEL_TRIGGERED) + { + /* + * GPE is level-triggered, we clear the GPE status bit after handling + * the event. + */ + Status = AcpiHwClearGpe (GpeEventInfo); + if (ACPI_FAILURE (Status)) + { + goto Exit; + } + } + + /* Enable this GPE */ + + (void) AcpiHwWriteGpeEnableReg (GpeEventInfo); + +Exit: + ACPI_FREE (GpeEventInfo); + return; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvGpeDispatch + * + * PARAMETERS: GpeEventInfo - Info for this GPE + * GpeNumber - Number relative to the parent GPE block + * + * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED + * + * DESCRIPTION: Dispatch a General Purpose Event to either a function (e.g. EC) + * or method (e.g. _Lxx/_Exx) handler. + * + * This function executes at interrupt level. + * + ******************************************************************************/ + +UINT32 +AcpiEvGpeDispatch ( + ACPI_GPE_EVENT_INFO *GpeEventInfo, + UINT32 GpeNumber) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (EvGpeDispatch); + + + AcpiGpeCount++; + + /* + * If edge-triggered, clear the GPE status bit now. Note that + * level-triggered events are cleared after the GPE is serviced. + */ + if ((GpeEventInfo->Flags & ACPI_GPE_XRUPT_TYPE_MASK) == + ACPI_GPE_EDGE_TRIGGERED) + { + Status = AcpiHwClearGpe (GpeEventInfo); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Unable to clear GPE[%2X]", 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. + */ + 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); + + /* It is now safe to clear level-triggered events. */ + + if ((GpeEventInfo->Flags & ACPI_GPE_XRUPT_TYPE_MASK) == + ACPI_GPE_LEVEL_TRIGGERED) + { + Status = AcpiHwClearGpe (GpeEventInfo); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Unable to clear GPE[%2X]", GpeNumber)); + return_UINT32 (ACPI_INTERRUPT_NOT_HANDLED); + } + } + 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); + } + + /* + * Execute the method associated with the GPE + * NOTE: Level-triggered GPEs are cleared after the method completes. + */ + Status = AcpiOsExecute (OSL_GPE_HANDLER, + AcpiEvAsynchExecuteGpeMethod, GpeEventInfo); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Unable to queue handler for GPE[%2X] - 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. + */ + Status = AcpiEvDisableGpe (GpeEventInfo); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Unable to disable GPE[%2X]", GpeNumber)); + return_UINT32 (ACPI_INTERRUPT_NOT_HANDLED); + } + break; + } + + return_UINT32 (ACPI_INTERRUPT_HANDLED); +} + diff --git a/reactos/drivers/bus/acpi/acpica/events/evgpeblk.c b/reactos/drivers/bus/acpi/acpica/events/evgpeblk.c new file mode 100644 index 00000000000..c86f80aa7f5 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/events/evgpeblk.c @@ -0,0 +1,1402 @@ +/****************************************************************************** + * + * Module Name: evgpeblk - GPE block creation and initialization. + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 "acpi.h" +#include "accommon.h" +#include "acevents.h" +#include "acnamesp.h" + +#define _COMPONENT ACPI_EVENTS + ACPI_MODULE_NAME ("evgpeblk") + +/* 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, + UINT32 InterruptNumber); + +static ACPI_STATUS +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 + * + * PARAMETERS: GpeBlock - New GPE block + * InterruptNumber - Xrupt to be associated with this + * GPE block + * + * RETURN: Status + * + * DESCRIPTION: Install new GPE block with mutex support + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiEvInstallGpeBlock ( + ACPI_GPE_BLOCK_INFO *GpeBlock, + UINT32 InterruptNumber) +{ + ACPI_GPE_BLOCK_INFO *NextGpeBlock; + ACPI_GPE_XRUPT_INFO *GpeXruptBlock; + ACPI_STATUS Status; + ACPI_CPU_FLAGS Flags; + + + ACPI_FUNCTION_TRACE (EvInstallGpeBlock); + + + Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + GpeXruptBlock = AcpiEvGetGpeXruptBlock (InterruptNumber); + if (!GpeXruptBlock) + { + Status = AE_NO_MEMORY; + goto UnlockAndExit; + } + + /* Install the new block at the end of the list with lock */ + + Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); + if (GpeXruptBlock->GpeBlockListHead) + { + NextGpeBlock = GpeXruptBlock->GpeBlockListHead; + while (NextGpeBlock->Next) + { + NextGpeBlock = NextGpeBlock->Next; + } + + NextGpeBlock->Next = GpeBlock; + GpeBlock->Previous = NextGpeBlock; + } + else + { + GpeXruptBlock->GpeBlockListHead = GpeBlock; + } + + GpeBlock->XruptBlock = GpeXruptBlock; + AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); + + +UnlockAndExit: + Status = AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvDeleteGpeBlock + * + * PARAMETERS: GpeBlock - Existing GPE block + * + * RETURN: Status + * + * DESCRIPTION: Remove a GPE block + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvDeleteGpeBlock ( + ACPI_GPE_BLOCK_INFO *GpeBlock) +{ + ACPI_STATUS Status; + ACPI_CPU_FLAGS Flags; + + + ACPI_FUNCTION_TRACE (EvInstallGpeBlock); + + + Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Disable all GPEs in this block */ + + Status = AcpiHwDisableGpeBlock (GpeBlock->XruptBlock, GpeBlock, NULL); + + if (!GpeBlock->Previous && !GpeBlock->Next) + { + /* This is the last GpeBlock on this interrupt */ + + Status = AcpiEvDeleteGpeXrupt (GpeBlock->XruptBlock); + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + } + else + { + /* Remove the block on this interrupt with lock */ + + Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); + if (GpeBlock->Previous) + { + GpeBlock->Previous->Next = GpeBlock->Next; + } + else + { + GpeBlock->XruptBlock->GpeBlockListHead = GpeBlock->Next; + } + + if (GpeBlock->Next) + { + GpeBlock->Next->Previous = GpeBlock->Previous; + } + AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); + } + + AcpiCurrentGpeCount -= GpeBlock->RegisterCount * ACPI_GPE_REGISTER_WIDTH; + + /* Free the GpeBlock */ + + ACPI_FREE (GpeBlock->RegisterInfo); + ACPI_FREE (GpeBlock->EventInfo); + ACPI_FREE (GpeBlock); + +UnlockAndExit: + Status = AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvCreateGpeInfoBlocks + * + * PARAMETERS: GpeBlock - New GPE block + * + * RETURN: Status + * + * DESCRIPTION: Create the RegisterInfo and EventInfo blocks for this GPE block + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiEvCreateGpeInfoBlocks ( + ACPI_GPE_BLOCK_INFO *GpeBlock) +{ + ACPI_GPE_REGISTER_INFO *GpeRegisterInfo = NULL; + ACPI_GPE_EVENT_INFO *GpeEventInfo = NULL; + ACPI_GPE_EVENT_INFO *ThisEvent; + ACPI_GPE_REGISTER_INFO *ThisRegister; + UINT32 i; + UINT32 j; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (EvCreateGpeInfoBlocks); + + + /* Allocate the GPE register information block */ + + GpeRegisterInfo = ACPI_ALLOCATE_ZEROED ( + (ACPI_SIZE) GpeBlock->RegisterCount * + sizeof (ACPI_GPE_REGISTER_INFO)); + if (!GpeRegisterInfo) + { + ACPI_ERROR ((AE_INFO, + "Could not allocate the GpeRegisterInfo table")); + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* + * Allocate the GPE EventInfo block. There are eight distinct GPEs + * per register. Initialization to zeros is sufficient. + */ + GpeEventInfo = ACPI_ALLOCATE_ZEROED ( + ((ACPI_SIZE) GpeBlock->RegisterCount * + ACPI_GPE_REGISTER_WIDTH) * + sizeof (ACPI_GPE_EVENT_INFO)); + if (!GpeEventInfo) + { + ACPI_ERROR ((AE_INFO, + "Could not allocate the GpeEventInfo table")); + Status = AE_NO_MEMORY; + goto ErrorExit; + } + + /* Save the new Info arrays in the GPE block */ + + GpeBlock->RegisterInfo = GpeRegisterInfo; + GpeBlock->EventInfo = GpeEventInfo; + + /* + * Initialize the GPE Register and Event structures. A goal of these + * tables is to hide the fact that there are two separate GPE register + * sets in a given GPE hardware block, the status registers occupy the + * first half, and the enable registers occupy the second half. + */ + ThisRegister = GpeRegisterInfo; + ThisEvent = GpeEventInfo; + + for (i = 0; i < GpeBlock->RegisterCount; i++) + { + /* Init the RegisterInfo for this GPE register (8 GPEs) */ + + ThisRegister->BaseGpeNumber = (UINT8) (GpeBlock->BlockBaseNumber + + (i * ACPI_GPE_REGISTER_WIDTH)); + + ThisRegister->StatusAddress.Address = + GpeBlock->BlockAddress.Address + i; + + ThisRegister->EnableAddress.Address = + GpeBlock->BlockAddress.Address + i + GpeBlock->RegisterCount; + + ThisRegister->StatusAddress.SpaceId = GpeBlock->BlockAddress.SpaceId; + ThisRegister->EnableAddress.SpaceId = GpeBlock->BlockAddress.SpaceId; + ThisRegister->StatusAddress.BitWidth = ACPI_GPE_REGISTER_WIDTH; + ThisRegister->EnableAddress.BitWidth = ACPI_GPE_REGISTER_WIDTH; + ThisRegister->StatusAddress.BitOffset = 0; + ThisRegister->EnableAddress.BitOffset = 0; + + /* Init the EventInfo for each GPE within this register */ + + for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) + { + ThisEvent->GpeNumber = (UINT8) (ThisRegister->BaseGpeNumber + j); + ThisEvent->RegisterInfo = ThisRegister; + ThisEvent++; + } + + /* Disable all GPEs within this register */ + + Status = AcpiHwWrite (0x00, &ThisRegister->EnableAddress); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + + /* Clear any pending GPE events within this register */ + + Status = AcpiHwWrite (0xFF, &ThisRegister->StatusAddress); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + + ThisRegister++; + } + + return_ACPI_STATUS (AE_OK); + + +ErrorExit: + if (GpeRegisterInfo) + { + ACPI_FREE (GpeRegisterInfo); + } + if (GpeEventInfo) + { + ACPI_FREE (GpeEventInfo); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvCreateGpeBlock + * + * PARAMETERS: GpeDevice - Handle to the parent GPE block + * GpeBlockAddress - Address and SpaceID + * RegisterCount - Number of GPE register pairs in the block + * GpeBlockBaseNumber - Starting GPE number for the block + * InterruptNumber - H/W interrupt for the block + * ReturnGpeBlock - Where the new block descriptor is returned + * + * RETURN: Status + * + * DESCRIPTION: Create and Install a block of GPE registers. All GPEs within + * the block are disabled at exit. + * Note: Assumes namespace is locked. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvCreateGpeBlock ( + ACPI_NAMESPACE_NODE *GpeDevice, + ACPI_GENERIC_ADDRESS *GpeBlockAddress, + UINT32 RegisterCount, + UINT8 GpeBlockBaseNumber, + UINT32 InterruptNumber, + ACPI_GPE_BLOCK_INFO **ReturnGpeBlock) +{ + ACPI_STATUS Status; + ACPI_GPE_BLOCK_INFO *GpeBlock; + + + ACPI_FUNCTION_TRACE (EvCreateGpeBlock); + + + if (!RegisterCount) + { + return_ACPI_STATUS (AE_OK); + } + + /* Allocate a new GPE block */ + + GpeBlock = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_GPE_BLOCK_INFO)); + if (!GpeBlock) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Initialize the new GPE block */ + + GpeBlock->Node = GpeDevice; + GpeBlock->RegisterCount = RegisterCount; + GpeBlock->BlockBaseNumber = GpeBlockBaseNumber; + + ACPI_MEMCPY (&GpeBlock->BlockAddress, GpeBlockAddress, + sizeof (ACPI_GENERIC_ADDRESS)); + + /* + * Create the RegisterInfo and EventInfo sub-structures + * Note: disables and clears all GPEs in the block + */ + Status = AcpiEvCreateGpeInfoBlocks (GpeBlock); + if (ACPI_FAILURE (Status)) + { + ACPI_FREE (GpeBlock); + return_ACPI_STATUS (Status); + } + + /* Install the new block in the global lists */ + + Status = AcpiEvInstallGpeBlock (GpeBlock, InterruptNumber); + if (ACPI_FAILURE (Status)) + { + ACPI_FREE (GpeBlock); + return_ACPI_STATUS (Status); + } + + /* Find all GPE methods (_Lxx, _Exx) for this block */ + + Status = AcpiNsWalkNamespace (ACPI_TYPE_METHOD, GpeDevice, + ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK, + AcpiEvSaveMethodInfo, NULL, GpeBlock, NULL); + + /* Return the new block */ + + if (ReturnGpeBlock) + { + (*ReturnGpeBlock) = GpeBlock; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_INIT, + "GPE %02X to %02X [%4.4s] %u regs on int 0x%X\n", + (UINT32) GpeBlock->BlockBaseNumber, + (UINT32) (GpeBlock->BlockBaseNumber + + ((GpeBlock->RegisterCount * ACPI_GPE_REGISTER_WIDTH) -1)), + GpeDevice->Name.Ascii, + GpeBlock->RegisterCount, + InterruptNumber)); + + /* Update global count of currently available GPEs */ + + AcpiCurrentGpeCount += RegisterCount * ACPI_GPE_REGISTER_WIDTH; + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvInitializeGpeBlock + * + * PARAMETERS: GpeDevice - Handle to the parent GPE block + * GpeBlock - Gpe Block info + * + * 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. + * Note: Assumes namespace is locked. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvInitializeGpeBlock ( + ACPI_NAMESPACE_NODE *GpeDevice, + ACPI_GPE_BLOCK_INFO *GpeBlock) +{ + ACPI_STATUS Status; + ACPI_GPE_EVENT_INFO *GpeEventInfo; + ACPI_GPE_WALK_INFO GpeInfo; + UINT32 WakeGpeCount; + UINT32 GpeEnabledCount; + UINT32 i; + UINT32 j; + + + 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. + */ + if (AcpiGbl_LeaveWakeGpesDisabled) + { + /* + * 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, NULL, &GpeInfo, NULL); + } + + /* + * 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. + */ + WakeGpeCount = 0; + GpeEnabledCount = 0; + + for (i = 0; i < GpeBlock->RegisterCount; i++) + { + for (j = 0; j < 8; 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++; + } + + if (GpeEventInfo->Flags & ACPI_GPE_TYPE_WAKE) + { + WakeGpeCount++; + } + } + } + + 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]); + + 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); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/events/evmisc.c b/reactos/drivers/bus/acpi/acpica/events/evmisc.c new file mode 100644 index 00000000000..1e7f9e1cb56 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/events/evmisc.c @@ -0,0 +1,740 @@ +/****************************************************************************** + * + * Module Name: evmisc - Miscellaneous event manager support functions + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 "acpi.h" +#include "accommon.h" +#include "acevents.h" +#include "acnamesp.h" +#include "acinterp.h" + +#define _COMPONENT ACPI_EVENTS + ACPI_MODULE_NAME ("evmisc") + + +/* Local prototypes */ + +static void ACPI_SYSTEM_XFACE +AcpiEvNotifyDispatch ( + void *Context); + +static UINT32 +AcpiEvGlobalLockHandler ( + void *Context); + +static ACPI_STATUS +AcpiEvRemoveGlobalLockHandler ( + void); + + +/******************************************************************************* + * + * FUNCTION: AcpiEvIsNotifyObject + * + * PARAMETERS: Node - Node to check + * + * RETURN: TRUE if notifies allowed on this object + * + * DESCRIPTION: Check type of node for a object that supports notifies. + * + * TBD: This could be replaced by a flag bit in the node. + * + ******************************************************************************/ + +BOOLEAN +AcpiEvIsNotifyObject ( + ACPI_NAMESPACE_NODE *Node) +{ + switch (Node->Type) + { + case ACPI_TYPE_DEVICE: + case ACPI_TYPE_PROCESSOR: + case ACPI_TYPE_THERMAL: + /* + * These are the ONLY objects that can receive ACPI notifications + */ + return (TRUE); + + default: + return (FALSE); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvQueueNotifyRequest + * + * PARAMETERS: Node - NS node for the notified object + * NotifyValue - Value from the Notify() request + * + * RETURN: Status + * + * DESCRIPTION: Dispatch a device notification event to a previously + * installed handler. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvQueueNotifyRequest ( + ACPI_NAMESPACE_NODE *Node, + UINT32 NotifyValue) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *HandlerObj = NULL; + ACPI_GENERIC_STATE *NotifyInfo; + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_NAME (EvQueueNotifyRequest); + + + /* + * For value 3 (Ejection Request), some device method may need to be run. + * For value 2 (Device Wake) if _PRW exists, the _PS0 method may need + * to be run. + * For value 0x80 (Status Change) on the power button or sleep button, + * initiate soft-off or sleep operation? + */ + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Dispatching Notify on [%4.4s] Node %p Value 0x%2.2X (%s)\n", + AcpiUtGetNodeName (Node), Node, NotifyValue, + AcpiUtGetNotifyName (NotifyValue))); + + /* Get the notify object attached to the NS Node */ + + ObjDesc = AcpiNsGetAttachedObject (Node); + if (ObjDesc) + { + /* We have the notify object, Get the right handler */ + + switch (Node->Type) + { + /* Notify allowed only on these types */ + + case ACPI_TYPE_DEVICE: + case ACPI_TYPE_THERMAL: + case ACPI_TYPE_PROCESSOR: + + if (NotifyValue <= ACPI_MAX_SYS_NOTIFY) + { + HandlerObj = ObjDesc->CommonNotify.SystemNotify; + } + else + { + HandlerObj = ObjDesc->CommonNotify.DeviceNotify; + } + break; + + default: + + /* All other types are not supported */ + + return (AE_TYPE); + } + } + + /* + * If there is any handler to run, schedule the dispatcher. + * Check for: + * 1) Global system notify handler + * 2) Global device notify handler + * 3) Per-device notify handler + */ + if ((AcpiGbl_SystemNotify.Handler && + (NotifyValue <= ACPI_MAX_SYS_NOTIFY)) || + (AcpiGbl_DeviceNotify.Handler && + (NotifyValue > ACPI_MAX_SYS_NOTIFY)) || + HandlerObj) + { + NotifyInfo = AcpiUtCreateGenericState (); + if (!NotifyInfo) + { + return (AE_NO_MEMORY); + } + + if (!HandlerObj) + { + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Executing system notify handler for Notify (%4.4s, %X) " + "node %p\n", + AcpiUtGetNodeName (Node), NotifyValue, Node)); + } + + NotifyInfo->Common.DescriptorType = ACPI_DESC_TYPE_STATE_NOTIFY; + NotifyInfo->Notify.Node = Node; + NotifyInfo->Notify.Value = (UINT16) NotifyValue; + NotifyInfo->Notify.HandlerObj = HandlerObj; + + Status = AcpiOsExecute ( + OSL_NOTIFY_HANDLER, AcpiEvNotifyDispatch, NotifyInfo); + if (ACPI_FAILURE (Status)) + { + AcpiUtDeleteGenericState (NotifyInfo); + } + } + else + { + /* There is no notify handler (per-device or system) for this device */ + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "No notify handler for Notify (%4.4s, %X) node %p\n", + AcpiUtGetNodeName (Node), NotifyValue, Node)); + } + + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvNotifyDispatch + * + * PARAMETERS: Context - To be passed to the notify handler + * + * RETURN: None. + * + * DESCRIPTION: Dispatch a device notification event to a previously + * installed handler. + * + ******************************************************************************/ + +static void ACPI_SYSTEM_XFACE +AcpiEvNotifyDispatch ( + void *Context) +{ + ACPI_GENERIC_STATE *NotifyInfo = (ACPI_GENERIC_STATE *) Context; + ACPI_NOTIFY_HANDLER GlobalHandler = NULL; + void *GlobalContext = NULL; + ACPI_OPERAND_OBJECT *HandlerObj; + + + ACPI_FUNCTION_ENTRY (); + + + /* + * We will invoke a global notify handler if installed. This is done + * _before_ we invoke the per-device handler attached to the device. + */ + if (NotifyInfo->Notify.Value <= ACPI_MAX_SYS_NOTIFY) + { + /* Global system notification handler */ + + if (AcpiGbl_SystemNotify.Handler) + { + GlobalHandler = AcpiGbl_SystemNotify.Handler; + GlobalContext = AcpiGbl_SystemNotify.Context; + } + } + else + { + /* Global driver notification handler */ + + if (AcpiGbl_DeviceNotify.Handler) + { + GlobalHandler = AcpiGbl_DeviceNotify.Handler; + GlobalContext = AcpiGbl_DeviceNotify.Context; + } + } + + /* Invoke the system handler first, if present */ + + if (GlobalHandler) + { + GlobalHandler (NotifyInfo->Notify.Node, NotifyInfo->Notify.Value, + GlobalContext); + } + + /* Now invoke the per-device handler, if present */ + + HandlerObj = NotifyInfo->Notify.HandlerObj; + if (HandlerObj) + { + HandlerObj->Notify.Handler (NotifyInfo->Notify.Node, + NotifyInfo->Notify.Value, + HandlerObj->Notify.Context); + } + + /* All done with the info object */ + + AcpiUtDeleteGenericState (NotifyInfo); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvGlobalLockHandler + * + * PARAMETERS: Context - From thread interface, not used + * + * RETURN: ACPI_INTERRUPT_HANDLED + * + * DESCRIPTION: Invoked directly from the SCI handler when a global lock + * release interrupt occurs. Attempt to acquire the global lock, + * if successful, signal the thread waiting for the lock. + * + * NOTE: Assumes that the semaphore can be signaled from interrupt level. If + * this is not possible for some reason, a separate thread will have to be + * scheduled to do this. + * + ******************************************************************************/ + +static UINT32 +AcpiEvGlobalLockHandler ( + void *Context) +{ + BOOLEAN Acquired = FALSE; + ACPI_STATUS Status; + + + /* + * Attempt to get the lock. + * + * If we don't get it now, it will be marked pending and we will + * take another interrupt when it becomes free. + */ + ACPI_ACQUIRE_GLOBAL_LOCK (AcpiGbl_FACS, Acquired); + if (Acquired) + { + /* Got the lock, now wake the thread waiting for it */ + + AcpiGbl_GlobalLockAcquired = TRUE; + + /* Send a unit to the semaphore */ + + Status = AcpiOsSignalSemaphore (AcpiGbl_GlobalLockSemaphore, 1); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR ((AE_INFO, "Could not signal Global Lock semaphore")); + } + } + + return (ACPI_INTERRUPT_HANDLED); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvInitGlobalLockHandler + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Install a handler for the global lock release event + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvInitGlobalLockHandler ( + void) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (EvInitGlobalLockHandler); + + + /* Attempt installation of the global lock handler */ + + Status = AcpiInstallFixedEventHandler (ACPI_EVENT_GLOBAL, + AcpiEvGlobalLockHandler, NULL); + + /* + * If the global lock does not exist on this platform, the attempt to + * enable GBL_STATUS will fail (the GBL_ENABLE bit will not stick). + * Map to AE_OK, but mark global lock as not present. Any attempt to + * actually use the global lock will be flagged with an error. + */ + if (Status == AE_NO_HARDWARE_RESPONSE) + { + ACPI_ERROR ((AE_INFO, + "No response from Global Lock hardware, disabling lock")); + + AcpiGbl_GlobalLockPresent = FALSE; + return_ACPI_STATUS (AE_OK); + } + + AcpiGbl_GlobalLockPresent = TRUE; + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvRemoveGlobalLockHandler + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Remove the handler for the Global Lock + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiEvRemoveGlobalLockHandler ( + void) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (EvRemoveGlobalLockHandler); + + AcpiGbl_GlobalLockPresent = FALSE; + Status = AcpiRemoveFixedEventHandler (ACPI_EVENT_GLOBAL, + AcpiEvGlobalLockHandler); + + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiEvAcquireGlobalLock + * + * PARAMETERS: Timeout - Max time to wait for the lock, in millisec. + * + * RETURN: Status + * + * DESCRIPTION: Attempt to gain ownership of the Global Lock. + * + * MUTEX: Interpreter must be locked + * + * Note: The original implementation allowed multiple threads to "acquire" the + * Global Lock, and the OS would hold the lock until the last thread had + * released it. However, this could potentially starve the BIOS out of the + * lock, especially in the case where there is a tight handshake between the + * Embedded Controller driver and the BIOS. Therefore, this implementation + * allows only one thread to acquire the HW Global Lock at a time, and makes + * the global lock appear as a standard mutex on the OS side. + * + *****************************************************************************/ + +ACPI_STATUS +AcpiEvAcquireGlobalLock ( + UINT16 Timeout) +{ + ACPI_STATUS Status = AE_OK; + BOOLEAN Acquired = FALSE; + + + ACPI_FUNCTION_TRACE (EvAcquireGlobalLock); + + + /* + * Only one thread can acquire the GL at a time, the GlobalLockMutex + * enforces this. This interface releases the interpreter if we must wait. + */ + Status = AcpiExSystemWaitMutex (AcpiGbl_GlobalLockMutex->Mutex.OsMutex, + Timeout); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Update the global lock handle and check for wraparound. The handle is + * only used for the external global lock interfaces, but it is updated + * here to properly handle the case where a single thread may acquire the + * lock via both the AML and the AcpiAcquireGlobalLock interfaces. The + * handle is therefore updated on the first acquire from a given thread + * regardless of where the acquisition request originated. + */ + AcpiGbl_GlobalLockHandle++; + if (AcpiGbl_GlobalLockHandle == 0) + { + AcpiGbl_GlobalLockHandle = 1; + } + + /* + * Make sure that a global lock actually exists. If not, just treat the + * lock as a standard mutex. + */ + if (!AcpiGbl_GlobalLockPresent) + { + AcpiGbl_GlobalLockAcquired = TRUE; + return_ACPI_STATUS (AE_OK); + } + + /* Attempt to acquire the actual hardware lock */ + + ACPI_ACQUIRE_GLOBAL_LOCK (AcpiGbl_FACS, Acquired); + if (Acquired) + { + /* We got the lock */ + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Acquired hardware Global Lock\n")); + + AcpiGbl_GlobalLockAcquired = TRUE; + return_ACPI_STATUS (AE_OK); + } + + /* + * Did not get the lock. The pending bit was set above, and we must now + * wait until we get the global lock released interrupt. + */ + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Waiting for hardware Global Lock\n")); + + /* + * Wait for handshake with the global lock interrupt handler. + * This interface releases the interpreter if we must wait. + */ + Status = AcpiExSystemWaitSemaphore (AcpiGbl_GlobalLockSemaphore, + ACPI_WAIT_FOREVER); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvReleaseGlobalLock + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Releases ownership of the Global Lock. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvReleaseGlobalLock ( + void) +{ + BOOLEAN Pending = FALSE; + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (EvReleaseGlobalLock); + + + /* Lock must be already acquired */ + + if (!AcpiGbl_GlobalLockAcquired) + { + ACPI_WARNING ((AE_INFO, + "Cannot release the ACPI Global Lock, it has not been acquired")); + return_ACPI_STATUS (AE_NOT_ACQUIRED); + } + + if (AcpiGbl_GlobalLockPresent) + { + /* Allow any thread to release the lock */ + + ACPI_RELEASE_GLOBAL_LOCK (AcpiGbl_FACS, Pending); + + /* + * If the pending bit was set, we must write GBL_RLS to the control + * register + */ + if (Pending) + { + Status = AcpiWriteBitRegister ( + ACPI_BITREG_GLOBAL_LOCK_RELEASE, ACPI_ENABLE_EVENT); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Released hardware Global Lock\n")); + } + + AcpiGbl_GlobalLockAcquired = FALSE; + + /* Release the local GL mutex */ + + AcpiOsReleaseMutex (AcpiGbl_GlobalLockMutex->Mutex.OsMutex); + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiEvTerminate + * + * PARAMETERS: none + * + * RETURN: none + * + * DESCRIPTION: Disable events and free memory allocated for table storage. + * + ******************************************************************************/ + +void +AcpiEvTerminate ( + void) +{ + UINT32 i; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (EvTerminate); + + + if (AcpiGbl_EventsInitialized) + { + /* + * Disable all event-related functionality. In all cases, on error, + * print a message but obviously we don't abort. + */ + + /* Disable all fixed events */ + + for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) + { + Status = AcpiDisableEvent (i, 0); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR ((AE_INFO, + "Could not disable fixed event %d", (UINT32) i)); + } + } + + /* Disable all GPEs in all GPE blocks */ + + Status = AcpiEvWalkGpeList (AcpiHwDisableGpeBlock, NULL); + + /* Remove SCI handler */ + + Status = AcpiEvRemoveSciHandler (); + if (ACPI_FAILURE(Status)) + { + ACPI_ERROR ((AE_INFO, + "Could not remove SCI handler")); + } + + Status = AcpiEvRemoveGlobalLockHandler (); + if (ACPI_FAILURE(Status)) + { + ACPI_ERROR ((AE_INFO, + "Could not remove Global Lock handler")); + } + } + + /* Deallocate all handler objects installed within GPE info structs */ + + Status = AcpiEvWalkGpeList (AcpiEvDeleteGpeHandlers, NULL); + + /* Return to original mode if necessary */ + + if (AcpiGbl_OriginalMode == ACPI_SYS_MODE_LEGACY) + { + Status = AcpiDisable (); + if (ACPI_FAILURE (Status)) + { + ACPI_WARNING ((AE_INFO, "AcpiDisable failed")); + } + } + return_VOID; +} + diff --git a/reactos/drivers/bus/acpi/acpica/events/evregion.c b/reactos/drivers/bus/acpi/acpica/events/evregion.c new file mode 100644 index 00000000000..2bdfb872fe0 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/events/evregion.c @@ -0,0 +1,1284 @@ +/****************************************************************************** + * + * Module Name: evregion - ACPI AddressSpace (OpRegion) handler dispatch + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __EVREGION_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acevents.h" +#include "acnamesp.h" +#include "acinterp.h" + +#define _COMPONENT ACPI_EVENTS + ACPI_MODULE_NAME ("evregion") + + +/* Local prototypes */ + +static BOOLEAN +AcpiEvHasDefaultHandler ( + ACPI_NAMESPACE_NODE *Node, + ACPI_ADR_SPACE_TYPE SpaceId); + +static ACPI_STATUS +AcpiEvRegRun ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue); + +static ACPI_STATUS +AcpiEvInstallHandler ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue); + +/* These are the address spaces that will get default handlers */ + +#define ACPI_NUM_DEFAULT_SPACES 4 + +static UINT8 AcpiGbl_DefaultAddressSpaces[ACPI_NUM_DEFAULT_SPACES] = +{ + ACPI_ADR_SPACE_SYSTEM_MEMORY, + ACPI_ADR_SPACE_SYSTEM_IO, + ACPI_ADR_SPACE_PCI_CONFIG, + ACPI_ADR_SPACE_DATA_TABLE +}; + + +/******************************************************************************* + * + * FUNCTION: AcpiEvInstallRegionHandlers + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Installs the core subsystem default address space handlers. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvInstallRegionHandlers ( + void) +{ + ACPI_STATUS Status; + UINT32 i; + + + ACPI_FUNCTION_TRACE (EvInstallRegionHandlers); + + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * All address spaces (PCI Config, EC, SMBus) are scope dependent and + * registration must occur for a specific device. + * + * In the case of the system memory and IO address spaces there is + * currently no device associated with the address space. For these we + * use the root. + * + * We install the default PCI config space handler at the root so that + * this space is immediately available even though the we have not + * enumerated all the PCI Root Buses yet. This is to conform to the ACPI + * specification which states that the PCI config space must be always + * available -- even though we are nowhere near ready to find the PCI root + * buses at this point. + * + * NOTE: We ignore AE_ALREADY_EXISTS because this means that a handler + * has already been installed (via AcpiInstallAddressSpaceHandler). + * Similar for AE_SAME_HANDLER. + */ + for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++) + { + Status = AcpiEvInstallSpaceHandler (AcpiGbl_RootNode, + AcpiGbl_DefaultAddressSpaces[i], + ACPI_DEFAULT_HANDLER, NULL, NULL); + switch (Status) + { + case AE_OK: + case AE_SAME_HANDLER: + case AE_ALREADY_EXISTS: + + /* These exceptions are all OK */ + + Status = AE_OK; + break; + + default: + + goto UnlockAndExit; + } + } + +UnlockAndExit: + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvHasDefaultHandler + * + * PARAMETERS: Node - Namespace node for the device + * SpaceId - The address space ID + * + * RETURN: TRUE if default handler is installed, FALSE otherwise + * + * DESCRIPTION: Check if the default handler is installed for the requested + * space ID. + * + ******************************************************************************/ + +static BOOLEAN +AcpiEvHasDefaultHandler ( + ACPI_NAMESPACE_NODE *Node, + ACPI_ADR_SPACE_TYPE SpaceId) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *HandlerObj; + + + /* Must have an existing internal object */ + + ObjDesc = AcpiNsGetAttachedObject (Node); + if (ObjDesc) + { + HandlerObj = ObjDesc->Device.Handler; + + /* Walk the linked list of handlers for this object */ + + while (HandlerObj) + { + if (HandlerObj->AddressSpace.SpaceId == SpaceId) + { + if (HandlerObj->AddressSpace.HandlerFlags & + ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) + { + return (TRUE); + } + } + + HandlerObj = HandlerObj->AddressSpace.Next; + } + } + + return (FALSE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvInitializeOpRegions + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Execute _REG methods for all Operation Regions that have + * an installed default region handler. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvInitializeOpRegions ( + void) +{ + ACPI_STATUS Status; + UINT32 i; + + + ACPI_FUNCTION_TRACE (EvInitializeOpRegions); + + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Run the _REG methods for OpRegions in each default address space */ + + for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++) + { + /* + * Make sure the installed handler is the DEFAULT handler. If not the + * default, the _REG methods will have already been run (when the + * handler was installed) + */ + if (AcpiEvHasDefaultHandler (AcpiGbl_RootNode, + AcpiGbl_DefaultAddressSpaces[i])) + { + Status = AcpiEvExecuteRegMethods (AcpiGbl_RootNode, + AcpiGbl_DefaultAddressSpaces[i]); + } + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvExecuteRegMethod + * + * PARAMETERS: RegionObj - Region object + * Function - Passed to _REG: On (1) or Off (0) + * + * RETURN: Status + * + * DESCRIPTION: Execute _REG method for a region + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvExecuteRegMethod ( + ACPI_OPERAND_OBJECT *RegionObj, + UINT32 Function) +{ + ACPI_EVALUATE_INFO *Info; + ACPI_OPERAND_OBJECT *Args[3]; + ACPI_OPERAND_OBJECT *RegionObj2; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (EvExecuteRegMethod); + + + RegionObj2 = AcpiNsGetSecondaryObject (RegionObj); + if (!RegionObj2) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + if (RegionObj2->Extra.Method_REG == NULL) + { + return_ACPI_STATUS (AE_OK); + } + + /* Allocate and initialize the evaluation information block */ + + Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO)); + if (!Info) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Info->PrefixNode = RegionObj2->Extra.Method_REG; + Info->Pathname = NULL; + Info->Parameters = Args; + Info->Flags = ACPI_IGNORE_RETURN_VALUE; + + /* + * The _REG method has two arguments: + * + * Arg0 - Integer: + * Operation region space ID Same value as RegionObj->Region.SpaceId + * + * Arg1 - Integer: + * connection status 1 for connecting the handler, 0 for disconnecting + * the handler (Passed as a parameter) + */ + Args[0] = AcpiUtCreateIntegerObject ((UINT64) RegionObj->Region.SpaceId); + if (!Args[0]) + { + Status = AE_NO_MEMORY; + goto Cleanup1; + } + + Args[1] = AcpiUtCreateIntegerObject ((UINT64) Function); + if (!Args[1]) + { + Status = AE_NO_MEMORY; + goto Cleanup2; + } + + Args[2] = NULL; /* Terminate list */ + + /* Execute the method, no return value */ + + ACPI_DEBUG_EXEC ( + AcpiUtDisplayInitPathname (ACPI_TYPE_METHOD, Info->PrefixNode, NULL)); + + Status = AcpiNsEvaluate (Info); + AcpiUtRemoveReference (Args[1]); + +Cleanup2: + AcpiUtRemoveReference (Args[0]); + +Cleanup1: + ACPI_FREE (Info); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvAddressSpaceDispatch + * + * PARAMETERS: RegionObj - Internal region object + * Function - Read or Write operation + * RegionOffset - Where in the region to read or write + * BitWidth - Field width in bits (8, 16, 32, or 64) + * Value - Pointer to in or out value, must be + * full 64-bit ACPI_INTEGER + * + * RETURN: Status + * + * DESCRIPTION: Dispatch an address space or operation region access to + * a previously installed handler. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvAddressSpaceDispatch ( + ACPI_OPERAND_OBJECT *RegionObj, + UINT32 Function, + UINT32 RegionOffset, + UINT32 BitWidth, + ACPI_INTEGER *Value) +{ + ACPI_STATUS Status; + ACPI_ADR_SPACE_HANDLER Handler; + ACPI_ADR_SPACE_SETUP RegionSetup; + ACPI_OPERAND_OBJECT *HandlerDesc; + ACPI_OPERAND_OBJECT *RegionObj2; + void *RegionContext = NULL; + + + ACPI_FUNCTION_TRACE (EvAddressSpaceDispatch); + + + RegionObj2 = AcpiNsGetSecondaryObject (RegionObj); + if (!RegionObj2) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + /* Ensure that there is a handler associated with this region */ + + HandlerDesc = RegionObj->Region.Handler; + if (!HandlerDesc) + { + ACPI_ERROR ((AE_INFO, + "No handler for Region [%4.4s] (%p) [%s]", + AcpiUtGetNodeName (RegionObj->Region.Node), + RegionObj, AcpiUtGetRegionName (RegionObj->Region.SpaceId))); + + return_ACPI_STATUS (AE_NOT_EXIST); + } + + /* + * It may be the case that the region has never been initialized. + * Some types of regions require special init code + */ + if (!(RegionObj->Region.Flags & AOPOBJ_SETUP_COMPLETE)) + { + /* This region has not been initialized yet, do it */ + + RegionSetup = HandlerDesc->AddressSpace.Setup; + if (!RegionSetup) + { + /* No initialization routine, exit with error */ + + ACPI_ERROR ((AE_INFO, + "No init routine for region(%p) [%s]", + RegionObj, AcpiUtGetRegionName (RegionObj->Region.SpaceId))); + return_ACPI_STATUS (AE_NOT_EXIST); + } + + /* + * We must exit the interpreter because the region setup will + * potentially execute control methods (for example, the _REG method + * for this region) + */ + AcpiExExitInterpreter (); + + Status = RegionSetup (RegionObj, ACPI_REGION_ACTIVATE, + HandlerDesc->AddressSpace.Context, &RegionContext); + + /* Re-enter the interpreter */ + + AcpiExEnterInterpreter (); + + /* Check for failure of the Region Setup */ + + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "During region initialization: [%s]", + AcpiUtGetRegionName (RegionObj->Region.SpaceId))); + return_ACPI_STATUS (Status); + } + + /* Region initialization may have been completed by RegionSetup */ + + if (!(RegionObj->Region.Flags & AOPOBJ_SETUP_COMPLETE)) + { + RegionObj->Region.Flags |= AOPOBJ_SETUP_COMPLETE; + + if (RegionObj2->Extra.RegionContext) + { + /* The handler for this region was already installed */ + + ACPI_FREE (RegionContext); + } + else + { + /* + * Save the returned context for use in all accesses to + * this particular region + */ + RegionObj2->Extra.RegionContext = RegionContext; + } + } + } + + /* We have everything we need, we can invoke the address space handler */ + + Handler = HandlerDesc->AddressSpace.Handler; + + ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, + "Handler %p (@%p) Address %8.8X%8.8X [%s]\n", + &RegionObj->Region.Handler->AddressSpace, Handler, + ACPI_FORMAT_NATIVE_UINT (RegionObj->Region.Address + RegionOffset), + AcpiUtGetRegionName (RegionObj->Region.SpaceId))); + + if (!(HandlerDesc->AddressSpace.HandlerFlags & + ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) + { + /* + * For handlers other than the default (supplied) handlers, we must + * exit the interpreter because the handler *might* block -- we don't + * know what it will do, so we can't hold the lock on the intepreter. + */ + AcpiExExitInterpreter(); + } + + /* Call the handler */ + + Status = Handler (Function, + (RegionObj->Region.Address + RegionOffset), BitWidth, Value, + HandlerDesc->AddressSpace.Context, RegionObj2->Extra.RegionContext); + + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, "Returned by Handler for [%s]", + AcpiUtGetRegionName (RegionObj->Region.SpaceId))); + } + + if (!(HandlerDesc->AddressSpace.HandlerFlags & + ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) + { + /* + * We just returned from a non-default handler, we must re-enter the + * interpreter + */ + AcpiExEnterInterpreter (); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvDetachRegion + * + * PARAMETERS: RegionObj - Region Object + * AcpiNsIsLocked - Namespace Region Already Locked? + * + * RETURN: None + * + * DESCRIPTION: Break the association between the handler and the region + * this is a two way association. + * + ******************************************************************************/ + +void +AcpiEvDetachRegion( + ACPI_OPERAND_OBJECT *RegionObj, + BOOLEAN AcpiNsIsLocked) +{ + ACPI_OPERAND_OBJECT *HandlerObj; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT **LastObjPtr; + ACPI_ADR_SPACE_SETUP RegionSetup; + void **RegionContext; + ACPI_OPERAND_OBJECT *RegionObj2; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (EvDetachRegion); + + + RegionObj2 = AcpiNsGetSecondaryObject (RegionObj); + if (!RegionObj2) + { + return_VOID; + } + RegionContext = &RegionObj2->Extra.RegionContext; + + /* Get the address handler from the region object */ + + HandlerObj = RegionObj->Region.Handler; + if (!HandlerObj) + { + /* This region has no handler, all done */ + + return_VOID; + } + + /* Find this region in the handler's list */ + + ObjDesc = HandlerObj->AddressSpace.RegionList; + LastObjPtr = &HandlerObj->AddressSpace.RegionList; + + while (ObjDesc) + { + /* Is this the correct Region? */ + + if (ObjDesc == RegionObj) + { + ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, + "Removing Region %p from address handler %p\n", + RegionObj, HandlerObj)); + + /* This is it, remove it from the handler's list */ + + *LastObjPtr = ObjDesc->Region.Next; + ObjDesc->Region.Next = NULL; /* Must clear field */ + + if (AcpiNsIsLocked) + { + Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_VOID; + } + } + + /* Now stop region accesses by executing the _REG method */ + + Status = AcpiEvExecuteRegMethod (RegionObj, 0); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, "from region _REG, [%s]", + AcpiUtGetRegionName (RegionObj->Region.SpaceId))); + } + + if (AcpiNsIsLocked) + { + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_VOID; + } + } + + /* + * If the region has been activated, call the setup handler with + * the deactivate notification + */ + if (RegionObj->Region.Flags & AOPOBJ_SETUP_COMPLETE) + { + RegionSetup = HandlerObj->AddressSpace.Setup; + Status = RegionSetup (RegionObj, ACPI_REGION_DEACTIVATE, + HandlerObj->AddressSpace.Context, RegionContext); + + /* Init routine may fail, Just ignore errors */ + + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "from region handler - deactivate, [%s]", + AcpiUtGetRegionName (RegionObj->Region.SpaceId))); + } + + RegionObj->Region.Flags &= ~(AOPOBJ_SETUP_COMPLETE); + } + + /* + * Remove handler reference in the region + * + * NOTE: this doesn't mean that the region goes away, the region + * is just inaccessible as indicated to the _REG method + * + * If the region is on the handler's list, this must be the + * region's handler + */ + RegionObj->Region.Handler = NULL; + AcpiUtRemoveReference (HandlerObj); + + return_VOID; + } + + /* Walk the linked list of handlers */ + + LastObjPtr = &ObjDesc->Region.Next; + ObjDesc = ObjDesc->Region.Next; + } + + /* If we get here, the region was not in the handler's region list */ + + ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, + "Cannot remove region %p from address handler %p\n", + RegionObj, HandlerObj)); + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvAttachRegion + * + * PARAMETERS: HandlerObj - Handler Object + * RegionObj - Region Object + * AcpiNsIsLocked - Namespace Region Already Locked? + * + * RETURN: None + * + * DESCRIPTION: Create the association between the handler and the region + * this is a two way association. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvAttachRegion ( + ACPI_OPERAND_OBJECT *HandlerObj, + ACPI_OPERAND_OBJECT *RegionObj, + BOOLEAN AcpiNsIsLocked) +{ + + ACPI_FUNCTION_TRACE (EvAttachRegion); + + + ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, + "Adding Region [%4.4s] %p to address handler %p [%s]\n", + AcpiUtGetNodeName (RegionObj->Region.Node), + RegionObj, HandlerObj, + AcpiUtGetRegionName (RegionObj->Region.SpaceId))); + + /* Link this region to the front of the handler's list */ + + RegionObj->Region.Next = HandlerObj->AddressSpace.RegionList; + HandlerObj->AddressSpace.RegionList = RegionObj; + + /* Install the region's handler */ + + if (RegionObj->Region.Handler) + { + return_ACPI_STATUS (AE_ALREADY_EXISTS); + } + + RegionObj->Region.Handler = HandlerObj; + AcpiUtAddReference (HandlerObj); + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvInstallHandler + * + * PARAMETERS: WalkNamespace callback + * + * DESCRIPTION: This routine installs an address handler into objects that are + * of type Region or Device. + * + * If the Object is a Device, and the device has a handler of + * the same type then the search is terminated in that branch. + * + * This is because the existing handler is closer in proximity + * to any more regions than the one we are trying to install. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiEvInstallHandler ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue) +{ + ACPI_OPERAND_OBJECT *HandlerObj; + ACPI_OPERAND_OBJECT *NextHandlerObj; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + + + ACPI_FUNCTION_NAME (EvInstallHandler); + + + HandlerObj = (ACPI_OPERAND_OBJECT *) Context; + + /* Parameter validation */ + + if (!HandlerObj) + { + return (AE_OK); + } + + /* Convert and validate the device handle */ + + Node = AcpiNsValidateHandle (ObjHandle); + if (!Node) + { + return (AE_BAD_PARAMETER); + } + + /* + * We only care about regions and objects that are allowed to have + * address space handlers + */ + if ((Node->Type != ACPI_TYPE_DEVICE) && + (Node->Type != ACPI_TYPE_REGION) && + (Node != AcpiGbl_RootNode)) + { + return (AE_OK); + } + + /* Check for an existing internal object */ + + ObjDesc = AcpiNsGetAttachedObject (Node); + if (!ObjDesc) + { + /* No object, just exit */ + + return (AE_OK); + } + + /* Devices are handled different than regions */ + + if (ObjDesc->Common.Type == ACPI_TYPE_DEVICE) + { + /* Check if this Device already has a handler for this address space */ + + NextHandlerObj = ObjDesc->Device.Handler; + while (NextHandlerObj) + { + /* Found a handler, is it for the same address space? */ + + if (NextHandlerObj->AddressSpace.SpaceId == + HandlerObj->AddressSpace.SpaceId) + { + ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, + "Found handler for region [%s] in device %p(%p) " + "handler %p\n", + AcpiUtGetRegionName (HandlerObj->AddressSpace.SpaceId), + ObjDesc, NextHandlerObj, HandlerObj)); + + /* + * Since the object we found it on was a device, then it + * means that someone has already installed a handler for + * the branch of the namespace from this device on. Just + * bail out telling the walk routine to not traverse this + * branch. This preserves the scoping rule for handlers. + */ + return (AE_CTRL_DEPTH); + } + + /* Walk the linked list of handlers attached to this device */ + + NextHandlerObj = NextHandlerObj->AddressSpace.Next; + } + + /* + * As long as the device didn't have a handler for this space we + * don't care about it. We just ignore it and proceed. + */ + return (AE_OK); + } + + /* Object is a Region */ + + if (ObjDesc->Region.SpaceId != HandlerObj->AddressSpace.SpaceId) + { + /* This region is for a different address space, just ignore it */ + + return (AE_OK); + } + + /* + * Now we have a region and it is for the handler's address space type. + * + * First disconnect region for any previous handler (if any) + */ + AcpiEvDetachRegion (ObjDesc, FALSE); + + /* Connect the region to the new handler */ + + Status = AcpiEvAttachRegion (HandlerObj, ObjDesc, FALSE); + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvInstallSpaceHandler + * + * PARAMETERS: Node - Namespace node for the device + * SpaceId - The address space ID + * Handler - Address of the handler + * Setup - Address of the setup function + * Context - Value passed to the handler on each access + * + * RETURN: Status + * + * DESCRIPTION: Install a handler for all OpRegions of a given SpaceId. + * Assumes namespace is locked + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvInstallSpaceHandler ( + ACPI_NAMESPACE_NODE *Node, + ACPI_ADR_SPACE_TYPE SpaceId, + ACPI_ADR_SPACE_HANDLER Handler, + ACPI_ADR_SPACE_SETUP Setup, + void *Context) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *HandlerObj; + ACPI_STATUS Status; + ACPI_OBJECT_TYPE Type; + UINT8 Flags = 0; + + + ACPI_FUNCTION_TRACE (EvInstallSpaceHandler); + + + /* + * This registration is valid for only the types below and the root. This + * is where the default handlers get placed. + */ + if ((Node->Type != ACPI_TYPE_DEVICE) && + (Node->Type != ACPI_TYPE_PROCESSOR) && + (Node->Type != ACPI_TYPE_THERMAL) && + (Node != AcpiGbl_RootNode)) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + if (Handler == ACPI_DEFAULT_HANDLER) + { + Flags = ACPI_ADDR_HANDLER_DEFAULT_INSTALLED; + + switch (SpaceId) + { + case ACPI_ADR_SPACE_SYSTEM_MEMORY: + Handler = AcpiExSystemMemorySpaceHandler; + Setup = AcpiEvSystemMemoryRegionSetup; + break; + + case ACPI_ADR_SPACE_SYSTEM_IO: + Handler = AcpiExSystemIoSpaceHandler; + Setup = AcpiEvIoSpaceRegionSetup; + break; + + case ACPI_ADR_SPACE_PCI_CONFIG: + Handler = AcpiExPciConfigSpaceHandler; + Setup = AcpiEvPciConfigRegionSetup; + break; + + case ACPI_ADR_SPACE_CMOS: + Handler = AcpiExCmosSpaceHandler; + Setup = AcpiEvCmosRegionSetup; + break; + + case ACPI_ADR_SPACE_PCI_BAR_TARGET: + Handler = AcpiExPciBarSpaceHandler; + Setup = AcpiEvPciBarRegionSetup; + break; + + case ACPI_ADR_SPACE_DATA_TABLE: + Handler = AcpiExDataTableSpaceHandler; + Setup = NULL; + break; + + default: + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + } + + /* If the caller hasn't specified a setup routine, use the default */ + + if (!Setup) + { + Setup = AcpiEvDefaultRegionSetup; + } + + /* Check for an existing internal object */ + + ObjDesc = AcpiNsGetAttachedObject (Node); + if (ObjDesc) + { + /* + * The attached device object already exists. Make sure the handler + * is not already installed. + */ + HandlerObj = ObjDesc->Device.Handler; + + /* Walk the handler list for this device */ + + while (HandlerObj) + { + /* Same SpaceId indicates a handler already installed */ + + if (HandlerObj->AddressSpace.SpaceId == SpaceId) + { + if (HandlerObj->AddressSpace.Handler == Handler) + { + /* + * It is (relatively) OK to attempt to install the SAME + * handler twice. This can easily happen with the + * PCI_Config space. + */ + Status = AE_SAME_HANDLER; + goto UnlockAndExit; + } + else + { + /* A handler is already installed */ + + Status = AE_ALREADY_EXISTS; + } + goto UnlockAndExit; + } + + /* Walk the linked list of handlers */ + + HandlerObj = HandlerObj->AddressSpace.Next; + } + } + else + { + ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, + "Creating object on Device %p while installing handler\n", Node)); + + /* ObjDesc does not exist, create one */ + + if (Node->Type == ACPI_TYPE_ANY) + { + Type = ACPI_TYPE_DEVICE; + } + else + { + Type = Node->Type; + } + + ObjDesc = AcpiUtCreateInternalObject (Type); + if (!ObjDesc) + { + Status = AE_NO_MEMORY; + goto UnlockAndExit; + } + + /* Init new descriptor */ + + ObjDesc->Common.Type = (UINT8) Type; + + /* Attach the new object to the Node */ + + Status = AcpiNsAttachObject (Node, ObjDesc, Type); + + /* Remove local reference to the object */ + + AcpiUtRemoveReference (ObjDesc); + + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + } + + ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, + "Installing address handler for region %s(%X) on Device %4.4s %p(%p)\n", + AcpiUtGetRegionName (SpaceId), SpaceId, + AcpiUtGetNodeName (Node), Node, ObjDesc)); + + /* + * Install the handler + * + * At this point there is no existing handler. Just allocate the object + * for the handler and link it into the list. + */ + HandlerObj = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_ADDRESS_HANDLER); + if (!HandlerObj) + { + Status = AE_NO_MEMORY; + goto UnlockAndExit; + } + + /* Init handler obj */ + + HandlerObj->AddressSpace.SpaceId = (UINT8) SpaceId; + HandlerObj->AddressSpace.HandlerFlags = Flags; + HandlerObj->AddressSpace.RegionList = NULL; + HandlerObj->AddressSpace.Node = Node; + HandlerObj->AddressSpace.Handler = Handler; + HandlerObj->AddressSpace.Context = Context; + HandlerObj->AddressSpace.Setup = Setup; + + /* Install at head of Device.AddressSpace list */ + + HandlerObj->AddressSpace.Next = ObjDesc->Device.Handler; + + /* + * The Device object is the first reference on the HandlerObj. + * Each region that uses the handler adds a reference. + */ + ObjDesc->Device.Handler = HandlerObj; + + /* + * Walk the namespace finding all of the regions this + * handler will manage. + * + * Start at the device and search the branch toward + * the leaf nodes until either the leaf is encountered or + * a device is detected that has an address handler of the + * same type. + * + * In either case, back up and search down the remainder + * of the branch + */ + Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, Node, ACPI_UINT32_MAX, + ACPI_NS_WALK_UNLOCK, AcpiEvInstallHandler, NULL, + HandlerObj, NULL); + +UnlockAndExit: + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvExecuteRegMethods + * + * PARAMETERS: Node - Namespace node for the device + * SpaceId - The address space ID + * + * RETURN: Status + * + * DESCRIPTION: Run all _REG methods for the input Space ID; + * Note: assumes namespace is locked, or system init time. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvExecuteRegMethods ( + ACPI_NAMESPACE_NODE *Node, + ACPI_ADR_SPACE_TYPE SpaceId) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (EvExecuteRegMethods); + + + /* + * Run all _REG methods for all Operation Regions for this space ID. This + * is a separate walk in order to handle any interdependencies between + * regions and _REG methods. (i.e. handlers must be installed for all + * regions of this Space ID before we can run any _REG methods) + */ + Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, Node, ACPI_UINT32_MAX, + ACPI_NS_WALK_UNLOCK, AcpiEvRegRun, NULL, + &SpaceId, NULL); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvRegRun + * + * PARAMETERS: WalkNamespace callback + * + * DESCRIPTION: Run _REG method for region objects of the requested spaceID + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiEvRegRun ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_NAMESPACE_NODE *Node; + ACPI_ADR_SPACE_TYPE SpaceId; + ACPI_STATUS Status; + + + SpaceId = *ACPI_CAST_PTR (ACPI_ADR_SPACE_TYPE, Context); + + /* Convert and validate the device handle */ + + Node = AcpiNsValidateHandle (ObjHandle); + if (!Node) + { + return (AE_BAD_PARAMETER); + } + + /* + * We only care about regions.and objects that are allowed to have address + * space handlers + */ + if ((Node->Type != ACPI_TYPE_REGION) && + (Node != AcpiGbl_RootNode)) + { + return (AE_OK); + } + + /* Check for an existing internal object */ + + ObjDesc = AcpiNsGetAttachedObject (Node); + if (!ObjDesc) + { + /* No object, just exit */ + + return (AE_OK); + } + + /* Object is a Region */ + + if (ObjDesc->Region.SpaceId != SpaceId) + { + /* This region is for a different address space, just ignore it */ + + return (AE_OK); + } + + Status = AcpiEvExecuteRegMethod (ObjDesc, 1); + return (Status); +} + diff --git a/reactos/drivers/bus/acpi/acpica/events/evrgnini.c b/reactos/drivers/bus/acpi/acpica/events/evrgnini.c new file mode 100644 index 00000000000..67f6cddf66d --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/events/evrgnini.c @@ -0,0 +1,799 @@ +/****************************************************************************** + * + * Module Name: evrgnini- ACPI AddressSpace (OpRegion) init + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __EVRGNINI_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acevents.h" +#include "acnamesp.h" + +#define _COMPONENT ACPI_EVENTS + ACPI_MODULE_NAME ("evrgnini") + +/* Local prototypes */ + +static BOOLEAN +AcpiEvIsPciRootBridge ( + ACPI_NAMESPACE_NODE *Node); + + +/******************************************************************************* + * + * FUNCTION: AcpiEvSystemMemoryRegionSetup + * + * PARAMETERS: Handle - Region we are interested in + * Function - Start or stop + * HandlerContext - Address space handler context + * RegionContext - Region specific context + * + * RETURN: Status + * + * DESCRIPTION: Setup a SystemMemory operation region + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvSystemMemoryRegionSetup ( + ACPI_HANDLE Handle, + UINT32 Function, + void *HandlerContext, + void **RegionContext) +{ + ACPI_OPERAND_OBJECT *RegionDesc = (ACPI_OPERAND_OBJECT *) Handle; + ACPI_MEM_SPACE_CONTEXT *LocalRegionContext; + + + ACPI_FUNCTION_TRACE (EvSystemMemoryRegionSetup); + + + if (Function == ACPI_REGION_DEACTIVATE) + { + if (*RegionContext) + { + LocalRegionContext = (ACPI_MEM_SPACE_CONTEXT *) *RegionContext; + + /* Delete a cached mapping if present */ + + if (LocalRegionContext->MappedLength) + { + AcpiOsUnmapMemory (LocalRegionContext->MappedLogicalAddress, + LocalRegionContext->MappedLength); + } + ACPI_FREE (LocalRegionContext); + *RegionContext = NULL; + } + return_ACPI_STATUS (AE_OK); + } + + /* Create a new context */ + + LocalRegionContext = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_MEM_SPACE_CONTEXT)); + if (!(LocalRegionContext)) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Save the region length and address for use in the handler */ + + LocalRegionContext->Length = RegionDesc->Region.Length; + LocalRegionContext->Address = RegionDesc->Region.Address; + + *RegionContext = LocalRegionContext; + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvIoSpaceRegionSetup + * + * PARAMETERS: Handle - Region we are interested in + * Function - Start or stop + * HandlerContext - Address space handler context + * RegionContext - Region specific context + * + * RETURN: Status + * + * DESCRIPTION: Setup a IO operation region + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvIoSpaceRegionSetup ( + ACPI_HANDLE Handle, + UINT32 Function, + void *HandlerContext, + void **RegionContext) +{ + ACPI_FUNCTION_TRACE (EvIoSpaceRegionSetup); + + + if (Function == ACPI_REGION_DEACTIVATE) + { + *RegionContext = NULL; + } + else + { + *RegionContext = HandlerContext; + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvPciConfigRegionSetup + * + * PARAMETERS: Handle - Region we are interested in + * Function - Start or stop + * HandlerContext - Address space handler context + * RegionContext - Region specific context + * + * RETURN: Status + * + * DESCRIPTION: Setup a PCI_Config operation region + * + * MUTEX: Assumes namespace is not locked + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvPciConfigRegionSetup ( + ACPI_HANDLE Handle, + UINT32 Function, + void *HandlerContext, + void **RegionContext) +{ + ACPI_STATUS Status = AE_OK; + ACPI_INTEGER PciValue; + ACPI_PCI_ID *PciId = *RegionContext; + ACPI_OPERAND_OBJECT *HandlerObj; + ACPI_NAMESPACE_NODE *ParentNode; + ACPI_NAMESPACE_NODE *PciRootNode; + ACPI_NAMESPACE_NODE *PciDeviceNode; + ACPI_OPERAND_OBJECT *RegionObj = (ACPI_OPERAND_OBJECT *) Handle; + + + ACPI_FUNCTION_TRACE (EvPciConfigRegionSetup); + + + HandlerObj = RegionObj->Region.Handler; + if (!HandlerObj) + { + /* + * No installed handler. This shouldn't happen because the dispatch + * routine checks before we get here, but we check again just in case. + */ + ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, + "Attempting to init a region %p, with no handler\n", RegionObj)); + return_ACPI_STATUS (AE_NOT_EXIST); + } + + *RegionContext = NULL; + if (Function == ACPI_REGION_DEACTIVATE) + { + if (PciId) + { + ACPI_FREE (PciId); + } + return_ACPI_STATUS (Status); + } + + ParentNode = AcpiNsGetParentNode (RegionObj->Region.Node); + + /* + * Get the _SEG and _BBN values from the device upon which the handler + * is installed. + * + * We need to get the _SEG and _BBN objects relative to the PCI BUS device. + * This is the device the handler has been registered to handle. + */ + + /* + * If the AddressSpace.Node is still pointing to the root, we need + * to scan upward for a PCI Root bridge and re-associate the OpRegion + * handlers with that device. + */ + if (HandlerObj->AddressSpace.Node == AcpiGbl_RootNode) + { + /* Start search from the parent object */ + + PciRootNode = ParentNode; + while (PciRootNode != AcpiGbl_RootNode) + { + /* Get the _HID/_CID in order to detect a RootBridge */ + + if (AcpiEvIsPciRootBridge (PciRootNode)) + { + /* Install a handler for this PCI root bridge */ + + Status = AcpiInstallAddressSpaceHandler ( + (ACPI_HANDLE) PciRootNode, + ACPI_ADR_SPACE_PCI_CONFIG, + ACPI_DEFAULT_HANDLER, NULL, NULL); + if (ACPI_FAILURE (Status)) + { + if (Status == AE_SAME_HANDLER) + { + /* + * It is OK if the handler is already installed on the + * root bridge. Still need to return a context object + * for the new PCI_Config operation region, however. + */ + Status = AE_OK; + } + else + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Could not install PciConfig handler " + "for Root Bridge %4.4s", + AcpiUtGetNodeName (PciRootNode))); + } + } + break; + } + + PciRootNode = AcpiNsGetParentNode (PciRootNode); + } + + /* PCI root bridge not found, use namespace root node */ + } + else + { + PciRootNode = HandlerObj->AddressSpace.Node; + } + + /* + * If this region is now initialized, we are done. + * (InstallAddressSpaceHandler could have initialized it) + */ + if (RegionObj->Region.Flags & AOPOBJ_SETUP_COMPLETE) + { + return_ACPI_STATUS (AE_OK); + } + + /* Region is still not initialized. Create a new context */ + + PciId = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_PCI_ID)); + if (!PciId) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* + * For PCI_Config space access, we need the segment, bus, device and + * function numbers. Acquire them here. + * + * Find the parent device object. (This allows the operation region to be + * within a subscope under the device, such as a control method.) + */ + PciDeviceNode = RegionObj->Region.Node; + while (PciDeviceNode && (PciDeviceNode->Type != ACPI_TYPE_DEVICE)) + { + PciDeviceNode = AcpiNsGetParentNode (PciDeviceNode); + } + + if (!PciDeviceNode) + { + ACPI_FREE (PciId); + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* + * Get the PCI device and function numbers from the _ADR object contained + * in the parent's scope. + */ + Status = AcpiUtEvaluateNumericObject (METHOD_NAME__ADR, + PciDeviceNode, &PciValue); + + /* + * The default is zero, and since the allocation above zeroed the data, + * just do nothing on failure. + */ + if (ACPI_SUCCESS (Status)) + { + PciId->Device = ACPI_HIWORD (ACPI_LODWORD (PciValue)); + PciId->Function = ACPI_LOWORD (ACPI_LODWORD (PciValue)); + } + + /* The PCI segment number comes from the _SEG method */ + + Status = AcpiUtEvaluateNumericObject (METHOD_NAME__SEG, + PciRootNode, &PciValue); + if (ACPI_SUCCESS (Status)) + { + PciId->Segment = ACPI_LOWORD (PciValue); + } + + /* The PCI bus number comes from the _BBN method */ + + Status = AcpiUtEvaluateNumericObject (METHOD_NAME__BBN, + PciRootNode, &PciValue); + if (ACPI_SUCCESS (Status)) + { + PciId->Bus = ACPI_LOWORD (PciValue); + } + + /* Complete this device's PciId */ + + AcpiOsDerivePciId (PciRootNode, RegionObj->Region.Node, &PciId); + + *RegionContext = PciId; + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvIsPciRootBridge + * + * PARAMETERS: Node - Device node being examined + * + * RETURN: TRUE if device is a PCI/PCI-Express Root Bridge + * + * DESCRIPTION: Determine if the input device represents a PCI Root Bridge by + * examining the _HID and _CID for the device. + * + ******************************************************************************/ + +static BOOLEAN +AcpiEvIsPciRootBridge ( + ACPI_NAMESPACE_NODE *Node) +{ + ACPI_STATUS Status; + ACPI_DEVICE_ID *Hid; + ACPI_DEVICE_ID_LIST *Cid; + UINT32 i; + BOOLEAN Match; + + + /* Get the _HID and check for a PCI Root Bridge */ + + Status = AcpiUtExecute_HID (Node, &Hid); + if (ACPI_FAILURE (Status)) + { + return (FALSE); + } + + Match = AcpiUtIsPciRootBridge (Hid->String); + ACPI_FREE (Hid); + + if (Match) + { + return (TRUE); + } + + /* The _HID did not match. Get the _CID and check for a PCI Root Bridge */ + + Status = AcpiUtExecute_CID (Node, &Cid); + if (ACPI_FAILURE (Status)) + { + return (FALSE); + } + + /* Check all _CIDs in the returned list */ + + for (i = 0; i < Cid->Count; i++) + { + if (AcpiUtIsPciRootBridge (Cid->Ids[i].String)) + { + ACPI_FREE (Cid); + return (TRUE); + } + } + + ACPI_FREE (Cid); + return (FALSE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvPciBarRegionSetup + * + * PARAMETERS: Handle - Region we are interested in + * Function - Start or stop + * HandlerContext - Address space handler context + * RegionContext - Region specific context + * + * RETURN: Status + * + * DESCRIPTION: Setup a PciBAR operation region + * + * MUTEX: Assumes namespace is not locked + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvPciBarRegionSetup ( + ACPI_HANDLE Handle, + UINT32 Function, + void *HandlerContext, + void **RegionContext) +{ + ACPI_FUNCTION_TRACE (EvPciBarRegionSetup); + + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvCmosRegionSetup + * + * PARAMETERS: Handle - Region we are interested in + * Function - Start or stop + * HandlerContext - Address space handler context + * RegionContext - Region specific context + * + * RETURN: Status + * + * DESCRIPTION: Setup a CMOS operation region + * + * MUTEX: Assumes namespace is not locked + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvCmosRegionSetup ( + ACPI_HANDLE Handle, + UINT32 Function, + void *HandlerContext, + void **RegionContext) +{ + ACPI_FUNCTION_TRACE (EvCmosRegionSetup); + + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvDefaultRegionSetup + * + * PARAMETERS: Handle - Region we are interested in + * Function - Start or stop + * HandlerContext - Address space handler context + * RegionContext - Region specific context + * + * RETURN: Status + * + * DESCRIPTION: Default region initialization + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvDefaultRegionSetup ( + ACPI_HANDLE Handle, + UINT32 Function, + void *HandlerContext, + void **RegionContext) +{ + ACPI_FUNCTION_TRACE (EvDefaultRegionSetup); + + + if (Function == ACPI_REGION_DEACTIVATE) + { + *RegionContext = NULL; + } + else + { + *RegionContext = HandlerContext; + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvInitializeRegion + * + * PARAMETERS: RegionObj - Region we are initializing + * AcpiNsLocked - Is namespace locked? + * + * RETURN: Status + * + * DESCRIPTION: Initializes the region, finds any _REG methods and saves them + * for execution at a later time + * + * Get the appropriate address space handler for a newly + * created region. + * + * This also performs address space specific initialization. For + * example, PCI regions must have an _ADR object that contains + * a PCI address in the scope of the definition. This address is + * required to perform an access to PCI config space. + * + * MUTEX: Interpreter should be unlocked, because we may run the _REG + * method for this region. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvInitializeRegion ( + ACPI_OPERAND_OBJECT *RegionObj, + BOOLEAN AcpiNsLocked) +{ + ACPI_OPERAND_OBJECT *HandlerObj; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_ADR_SPACE_TYPE SpaceId; + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *MethodNode; + ACPI_NAME *RegNamePtr = (ACPI_NAME *) METHOD_NAME__REG; + ACPI_OPERAND_OBJECT *RegionObj2; + + + ACPI_FUNCTION_TRACE_U32 (EvInitializeRegion, AcpiNsLocked); + + + if (!RegionObj) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + if (RegionObj->Common.Flags & AOPOBJ_OBJECT_INITIALIZED) + { + return_ACPI_STATUS (AE_OK); + } + + RegionObj2 = AcpiNsGetSecondaryObject (RegionObj); + if (!RegionObj2) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + Node = AcpiNsGetParentNode (RegionObj->Region.Node); + SpaceId = RegionObj->Region.SpaceId; + + /* Setup defaults */ + + RegionObj->Region.Handler = NULL; + RegionObj2->Extra.Method_REG = NULL; + RegionObj->Common.Flags &= ~(AOPOBJ_SETUP_COMPLETE); + RegionObj->Common.Flags |= AOPOBJ_OBJECT_INITIALIZED; + + /* Find any "_REG" method associated with this region definition */ + + Status = AcpiNsSearchOneScope ( + *RegNamePtr, Node, ACPI_TYPE_METHOD, &MethodNode); + if (ACPI_SUCCESS (Status)) + { + /* + * The _REG method is optional and there can be only one per region + * definition. This will be executed when the handler is attached + * or removed + */ + RegionObj2->Extra.Method_REG = MethodNode; + } + + /* + * The following loop depends upon the root Node having no parent + * ie: AcpiGbl_RootNode->ParentEntry being set to NULL + */ + while (Node) + { + /* Check to see if a handler exists */ + + HandlerObj = NULL; + ObjDesc = AcpiNsGetAttachedObject (Node); + if (ObjDesc) + { + /* Can only be a handler if the object exists */ + + switch (Node->Type) + { + case ACPI_TYPE_DEVICE: + + HandlerObj = ObjDesc->Device.Handler; + break; + + case ACPI_TYPE_PROCESSOR: + + HandlerObj = ObjDesc->Processor.Handler; + break; + + case ACPI_TYPE_THERMAL: + + HandlerObj = ObjDesc->ThermalZone.Handler; + break; + + case ACPI_TYPE_METHOD: + /* + * If we are executing module level code, the original + * Node's object was replaced by this Method object and we + * saved the handler in the method object. + * + * See AcpiNsExecModuleCode + */ + if (ObjDesc->Method.Flags & AOPOBJ_MODULE_LEVEL) + { + HandlerObj = ObjDesc->Method.Extra.Handler; + } + break; + + default: + /* Ignore other objects */ + break; + } + + while (HandlerObj) + { + /* Is this handler of the correct type? */ + + if (HandlerObj->AddressSpace.SpaceId == SpaceId) + { + /* Found correct handler */ + + ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, + "Found handler %p for region %p in obj %p\n", + HandlerObj, RegionObj, ObjDesc)); + + Status = AcpiEvAttachRegion (HandlerObj, RegionObj, + AcpiNsLocked); + + /* + * Tell all users that this region is usable by + * running the _REG method + */ + if (AcpiNsLocked) + { + Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + Status = AcpiEvExecuteRegMethod (RegionObj, 1); + + if (AcpiNsLocked) + { + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + return_ACPI_STATUS (AE_OK); + } + + /* Try next handler in the list */ + + HandlerObj = HandlerObj->AddressSpace.Next; + } + } + + /* This node does not have the handler we need; Pop up one level */ + + Node = AcpiNsGetParentNode (Node); + } + + /* If we get here, there is no handler for this region */ + + ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, + "No handler for RegionType %s(%X) (RegionObj %p)\n", + AcpiUtGetRegionName (SpaceId), SpaceId, RegionObj)); + + return_ACPI_STATUS (AE_NOT_EXIST); +} + diff --git a/reactos/drivers/bus/acpi/acpica/events/evsci.c b/reactos/drivers/bus/acpi/acpica/events/evsci.c new file mode 100644 index 00000000000..cde433ce3ee --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/events/evsci.c @@ -0,0 +1,280 @@ +/******************************************************************************* + * + * Module Name: evsci - System Control Interrupt configuration and + * legacy to ACPI mode state transition functions + * + ******************************************************************************/ + +/****************************************************************************** + * + * 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 "acpi.h" +#include "accommon.h" +#include "acevents.h" + + +#define _COMPONENT ACPI_EVENTS + ACPI_MODULE_NAME ("evsci") + +/* Local prototypes */ + +static UINT32 ACPI_SYSTEM_XFACE +AcpiEvSciXruptHandler ( + void *Context); + + +/******************************************************************************* + * + * FUNCTION: AcpiEvSciXruptHandler + * + * PARAMETERS: Context - Calling Context + * + * RETURN: Status code indicates whether interrupt was handled. + * + * DESCRIPTION: Interrupt handler that will figure out what function or + * control method to call to deal with a SCI. + * + ******************************************************************************/ + +static UINT32 ACPI_SYSTEM_XFACE +AcpiEvSciXruptHandler ( + void *Context) +{ + ACPI_GPE_XRUPT_INFO *GpeXruptList = Context; + UINT32 InterruptHandled = ACPI_INTERRUPT_NOT_HANDLED; + + + ACPI_FUNCTION_TRACE (EvSciXruptHandler); + + + /* + * We are guaranteed by the ACPI CA initialization/shutdown code that + * if this interrupt handler is installed, ACPI is enabled. + */ + + /* + * Fixed Events: + * Check for and dispatch any Fixed Events that have occurred + */ + InterruptHandled |= AcpiEvFixedEventDetect (); + + /* + * General Purpose Events: + * Check for and dispatch any GPEs that have occurred + */ + InterruptHandled |= AcpiEvGpeDetect (GpeXruptList); + + AcpiSciCount++; + return_UINT32 (InterruptHandled); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiEvGpeXruptHandler + * + * PARAMETERS: Context - Calling Context + * + * RETURN: Status code indicates whether interrupt was handled. + * + * DESCRIPTION: Handler for GPE Block Device interrupts + * + ******************************************************************************/ + +UINT32 ACPI_SYSTEM_XFACE +AcpiEvGpeXruptHandler ( + void *Context) +{ + ACPI_GPE_XRUPT_INFO *GpeXruptList = Context; + UINT32 InterruptHandled = ACPI_INTERRUPT_NOT_HANDLED; + + + ACPI_FUNCTION_TRACE (EvGpeXruptHandler); + + + /* + * We are guaranteed by the ACPI CA initialization/shutdown code that + * if this interrupt handler is installed, ACPI is enabled. + */ + + /* GPEs: Check for and dispatch any GPEs that have occurred */ + + InterruptHandled |= AcpiEvGpeDetect (GpeXruptList); + + return_UINT32 (InterruptHandled); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiEvInstallSciHandler + * + * PARAMETERS: none + * + * RETURN: Status + * + * DESCRIPTION: Installs SCI handler. + * + ******************************************************************************/ + +UINT32 +AcpiEvInstallSciHandler ( + void) +{ + UINT32 Status = AE_OK; + + + ACPI_FUNCTION_TRACE (EvInstallSciHandler); + + + Status = AcpiOsInstallInterruptHandler ((UINT32) AcpiGbl_FADT.SciInterrupt, + AcpiEvSciXruptHandler, AcpiGbl_GpeXruptListHead); + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiEvRemoveSciHandler + * + * PARAMETERS: none + * + * RETURN: E_OK if handler uninstalled OK, E_ERROR if handler was not + * installed to begin with + * + * DESCRIPTION: Remove the SCI interrupt handler. No further SCIs will be + * taken. + * + * Note: It doesn't seem important to disable all events or set the event + * enable registers to their original values. The OS should disable + * the SCI interrupt level when the handler is removed, so no more + * events will come in. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvRemoveSciHandler ( + void) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (EvRemoveSciHandler); + + + /* Just let the OS remove the handler and disable the level */ + + Status = AcpiOsRemoveInterruptHandler ((UINT32) AcpiGbl_FADT.SciInterrupt, + AcpiEvSciXruptHandler); + + return_ACPI_STATUS (Status); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/events/evxface.c b/reactos/drivers/bus/acpi/acpica/events/evxface.c new file mode 100644 index 00000000000..6eb5a14af06 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/events/evxface.c @@ -0,0 +1,967 @@ +/****************************************************************************** + * + * Module Name: evxface - External interfaces for ACPI events + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __EVXFACE_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" +#include "acevents.h" +#include "acinterp.h" + +#define _COMPONENT ACPI_EVENTS + ACPI_MODULE_NAME ("evxface") + + +/******************************************************************************* + * + * FUNCTION: AcpiInstallExceptionHandler + * + * PARAMETERS: Handler - Pointer to the handler function for the + * event + * + * RETURN: Status + * + * DESCRIPTION: Saves the pointer to the handler function + * + ******************************************************************************/ + +ACPI_STATUS +AcpiInstallExceptionHandler ( + ACPI_EXCEPTION_HANDLER Handler) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiInstallExceptionHandler); + + + Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Don't allow two handlers. */ + + if (AcpiGbl_ExceptionHandler) + { + Status = AE_ALREADY_EXISTS; + goto Cleanup; + } + + /* Install the handler */ + + AcpiGbl_ExceptionHandler = Handler; + +Cleanup: + (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiInstallExceptionHandler) + + +/******************************************************************************* + * + * FUNCTION: AcpiInstallFixedEventHandler + * + * PARAMETERS: Event - Event type to enable. + * Handler - Pointer to the handler function for the + * event + * Context - Value passed to the handler on each GPE + * + * RETURN: Status + * + * DESCRIPTION: Saves the pointer to the handler function and then enables the + * event. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiInstallFixedEventHandler ( + UINT32 Event, + ACPI_EVENT_HANDLER Handler, + void *Context) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiInstallFixedEventHandler); + + + /* Parameter validation */ + + if (Event > ACPI_EVENT_MAX) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Don't allow two handlers. */ + + if (NULL != AcpiGbl_FixedEventHandlers[Event].Handler) + { + Status = AE_ALREADY_EXISTS; + goto Cleanup; + } + + /* Install the handler before enabling the event */ + + AcpiGbl_FixedEventHandlers[Event].Handler = Handler; + AcpiGbl_FixedEventHandlers[Event].Context = Context; + + Status = AcpiEnableEvent (Event, 0); + if (ACPI_FAILURE (Status)) + { + ACPI_WARNING ((AE_INFO, "Could not enable fixed event %X", Event)); + + /* Remove the handler */ + + AcpiGbl_FixedEventHandlers[Event].Handler = NULL; + AcpiGbl_FixedEventHandlers[Event].Context = NULL; + } + else + { + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Enabled fixed event %X, Handler=%p\n", Event, Handler)); + } + + +Cleanup: + (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiInstallFixedEventHandler) + + +/******************************************************************************* + * + * FUNCTION: AcpiRemoveFixedEventHandler + * + * PARAMETERS: Event - Event type to disable. + * Handler - Address of the handler + * + * RETURN: Status + * + * DESCRIPTION: Disables the event and unregisters the event handler. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRemoveFixedEventHandler ( + UINT32 Event, + ACPI_EVENT_HANDLER Handler) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (AcpiRemoveFixedEventHandler); + + + /* Parameter validation */ + + if (Event > ACPI_EVENT_MAX) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Disable the event before removing the handler */ + + Status = AcpiDisableEvent (Event, 0); + + /* Always Remove the handler */ + + AcpiGbl_FixedEventHandlers[Event].Handler = NULL; + AcpiGbl_FixedEventHandlers[Event].Context = NULL; + + if (ACPI_FAILURE (Status)) + { + ACPI_WARNING ((AE_INFO, + "Could not write to fixed event enable register %X", Event)); + } + else + { + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Disabled fixed event %X\n", Event)); + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiRemoveFixedEventHandler) + + +/******************************************************************************* + * + * FUNCTION: AcpiInstallNotifyHandler + * + * PARAMETERS: Device - The device for which notifies will be handled + * HandlerType - The type of handler: + * ACPI_SYSTEM_NOTIFY: SystemHandler (00-7f) + * ACPI_DEVICE_NOTIFY: DriverHandler (80-ff) + * ACPI_ALL_NOTIFY: both system and device + * Handler - Address of the handler + * Context - Value passed to the handler on each GPE + * + * RETURN: Status + * + * DESCRIPTION: Install a handler for notifies on an ACPI device + * + ******************************************************************************/ + +ACPI_STATUS +AcpiInstallNotifyHandler ( + ACPI_HANDLE Device, + UINT32 HandlerType, + ACPI_NOTIFY_HANDLER Handler, + void *Context) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *NotifyObj; + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiInstallNotifyHandler); + + + /* Parameter validation */ + + if ((!Device) || + (!Handler) || + (HandlerType > ACPI_MAX_NOTIFY_HANDLER_TYPE)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Convert and validate the device handle */ + + Node = AcpiNsValidateHandle (Device); + if (!Node) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* + * Root Object: + * Registering a notify handler on the root object indicates that the + * caller wishes to receive notifications for all objects. Note that + * only one global handler can be regsitered (per notify type). + */ + if (Device == ACPI_ROOT_OBJECT) + { + /* Make sure the handler is not already installed */ + + if (((HandlerType & ACPI_SYSTEM_NOTIFY) && + AcpiGbl_SystemNotify.Handler) || + ((HandlerType & ACPI_DEVICE_NOTIFY) && + AcpiGbl_DeviceNotify.Handler)) + { + Status = AE_ALREADY_EXISTS; + goto UnlockAndExit; + } + + if (HandlerType & ACPI_SYSTEM_NOTIFY) + { + AcpiGbl_SystemNotify.Node = Node; + AcpiGbl_SystemNotify.Handler = Handler; + AcpiGbl_SystemNotify.Context = Context; + } + + if (HandlerType & ACPI_DEVICE_NOTIFY) + { + AcpiGbl_DeviceNotify.Node = Node; + AcpiGbl_DeviceNotify.Handler = Handler; + AcpiGbl_DeviceNotify.Context = Context; + } + + /* Global notify handler installed */ + } + + /* + * All Other Objects: + * Caller will only receive notifications specific to the target object. + * Note that only certain object types can receive notifications. + */ + else + { + /* Notifies allowed on this object? */ + + if (!AcpiEvIsNotifyObject (Node)) + { + Status = AE_TYPE; + goto UnlockAndExit; + } + + /* Check for an existing internal object */ + + ObjDesc = AcpiNsGetAttachedObject (Node); + if (ObjDesc) + { + /* Object exists - make sure there's no handler */ + + if (((HandlerType & ACPI_SYSTEM_NOTIFY) && + ObjDesc->CommonNotify.SystemNotify) || + ((HandlerType & ACPI_DEVICE_NOTIFY) && + ObjDesc->CommonNotify.DeviceNotify)) + { + Status = AE_ALREADY_EXISTS; + goto UnlockAndExit; + } + } + else + { + /* Create a new object */ + + ObjDesc = AcpiUtCreateInternalObject (Node->Type); + if (!ObjDesc) + { + Status = AE_NO_MEMORY; + goto UnlockAndExit; + } + + /* Attach new object to the Node */ + + Status = AcpiNsAttachObject (Device, ObjDesc, Node->Type); + + /* Remove local reference to the object */ + + AcpiUtRemoveReference (ObjDesc); + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + } + + /* Install the handler */ + + NotifyObj = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_NOTIFY); + if (!NotifyObj) + { + Status = AE_NO_MEMORY; + goto UnlockAndExit; + } + + NotifyObj->Notify.Node = Node; + NotifyObj->Notify.Handler = Handler; + NotifyObj->Notify.Context = Context; + + if (HandlerType & ACPI_SYSTEM_NOTIFY) + { + ObjDesc->CommonNotify.SystemNotify = NotifyObj; + } + + if (HandlerType & ACPI_DEVICE_NOTIFY) + { + ObjDesc->CommonNotify.DeviceNotify = NotifyObj; + } + + if (HandlerType == ACPI_ALL_NOTIFY) + { + /* Extra ref if installed in both */ + + AcpiUtAddReference (NotifyObj); + } + } + + +UnlockAndExit: + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiInstallNotifyHandler) + + +/******************************************************************************* + * + * FUNCTION: AcpiRemoveNotifyHandler + * + * PARAMETERS: Device - The device for which notifies will be handled + * HandlerType - The type of handler: + * ACPI_SYSTEM_NOTIFY: SystemHandler (00-7f) + * ACPI_DEVICE_NOTIFY: DriverHandler (80-ff) + * ACPI_ALL_NOTIFY: both system and device + * Handler - Address of the handler + * + * RETURN: Status + * + * DESCRIPTION: Remove a handler for notifies on an ACPI device + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRemoveNotifyHandler ( + ACPI_HANDLE Device, + UINT32 HandlerType, + ACPI_NOTIFY_HANDLER Handler) +{ + ACPI_OPERAND_OBJECT *NotifyObj; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiRemoveNotifyHandler); + + + /* Parameter validation */ + + if ((!Device) || + (!Handler) || + (HandlerType > ACPI_MAX_NOTIFY_HANDLER_TYPE)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Convert and validate the device handle */ + + Node = AcpiNsValidateHandle (Device); + if (!Node) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* Root Object */ + + if (Device == ACPI_ROOT_OBJECT) + { + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Removing notify handler for namespace root object\n")); + + if (((HandlerType & ACPI_SYSTEM_NOTIFY) && + !AcpiGbl_SystemNotify.Handler) || + ((HandlerType & ACPI_DEVICE_NOTIFY) && + !AcpiGbl_DeviceNotify.Handler)) + { + Status = AE_NOT_EXIST; + goto UnlockAndExit; + } + + if (HandlerType & ACPI_SYSTEM_NOTIFY) + { + AcpiGbl_SystemNotify.Node = NULL; + AcpiGbl_SystemNotify.Handler = NULL; + AcpiGbl_SystemNotify.Context = NULL; + } + + if (HandlerType & ACPI_DEVICE_NOTIFY) + { + AcpiGbl_DeviceNotify.Node = NULL; + AcpiGbl_DeviceNotify.Handler = NULL; + AcpiGbl_DeviceNotify.Context = NULL; + } + } + + /* All Other Objects */ + + else + { + /* Notifies allowed on this object? */ + + if (!AcpiEvIsNotifyObject (Node)) + { + Status = AE_TYPE; + goto UnlockAndExit; + } + + /* Check for an existing internal object */ + + ObjDesc = AcpiNsGetAttachedObject (Node); + if (!ObjDesc) + { + Status = AE_NOT_EXIST; + goto UnlockAndExit; + } + + /* Object exists - make sure there's an existing handler */ + + if (HandlerType & ACPI_SYSTEM_NOTIFY) + { + NotifyObj = ObjDesc->CommonNotify.SystemNotify; + if (!NotifyObj) + { + Status = AE_NOT_EXIST; + goto UnlockAndExit; + } + + if (NotifyObj->Notify.Handler != Handler) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* Remove the handler */ + + ObjDesc->CommonNotify.SystemNotify = NULL; + AcpiUtRemoveReference (NotifyObj); + } + + if (HandlerType & ACPI_DEVICE_NOTIFY) + { + NotifyObj = ObjDesc->CommonNotify.DeviceNotify; + if (!NotifyObj) + { + Status = AE_NOT_EXIST; + goto UnlockAndExit; + } + + if (NotifyObj->Notify.Handler != Handler) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* Remove the handler */ + + ObjDesc->CommonNotify.DeviceNotify = NULL; + AcpiUtRemoveReference (NotifyObj); + } + } + + +UnlockAndExit: + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiRemoveNotifyHandler) + + +/******************************************************************************* + * + * FUNCTION: AcpiInstallGpeHandler + * + * PARAMETERS: GpeDevice - Namespace node for the GPE (NULL for FADT + * defined GPEs) + * GpeNumber - The GPE number within the GPE block + * Type - Whether this GPE should be treated as an + * edge- or level-triggered interrupt. + * Address - Address of the handler + * Context - Value passed to the handler on each GPE + * + * RETURN: Status + * + * DESCRIPTION: Install a handler for a General Purpose Event. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiInstallGpeHandler ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber, + UINT32 Type, + ACPI_EVENT_HANDLER Address, + void *Context) +{ + ACPI_GPE_EVENT_INFO *GpeEventInfo; + ACPI_HANDLER_INFO *Handler; + ACPI_STATUS Status; + ACPI_CPU_FLAGS Flags; + + + ACPI_FUNCTION_TRACE (AcpiInstallGpeHandler); + + + /* Parameter validation */ + + if ((!Address) || (Type > ACPI_GPE_XRUPT_TYPE_MASK)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Ensure that we have a valid GPE number */ + + GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber); + if (!GpeEventInfo) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* Make sure that there isn't a handler there already */ + + if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) == + ACPI_GPE_DISPATCH_HANDLER) + { + Status = AE_ALREADY_EXISTS; + goto UnlockAndExit; + } + + /* Allocate and init handler object */ + + Handler = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_HANDLER_INFO)); + if (!Handler) + { + Status = AE_NO_MEMORY; + goto UnlockAndExit; + } + + Handler->Address = Address; + Handler->Context = Context; + Handler->MethodNode = GpeEventInfo->Dispatch.MethodNode; + + /* Disable the GPE before installing the handler */ + + Status = AcpiEvDisableGpe (GpeEventInfo); + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + + /* Install the handler */ + + Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock); + GpeEventInfo->Dispatch.Handler = Handler; + + /* Setup up dispatch flags to indicate handler (vs. method) */ + + GpeEventInfo->Flags &= ~(ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK); + GpeEventInfo->Flags |= (UINT8) (Type | ACPI_GPE_DISPATCH_HANDLER); + + AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); + + +UnlockAndExit: + (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiInstallGpeHandler) + + +/******************************************************************************* + * + * FUNCTION: AcpiRemoveGpeHandler + * + * PARAMETERS: GpeDevice - Namespace node for the GPE (NULL for FADT + * defined GPEs) + * GpeNumber - The event to remove a handler + * Address - Address of the handler + * + * RETURN: Status + * + * DESCRIPTION: Remove a handler for a General Purpose AcpiEvent. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRemoveGpeHandler ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber, + ACPI_EVENT_HANDLER Address) +{ + ACPI_GPE_EVENT_INFO *GpeEventInfo; + ACPI_HANDLER_INFO *Handler; + ACPI_STATUS Status; + ACPI_CPU_FLAGS Flags; + + + ACPI_FUNCTION_TRACE (AcpiRemoveGpeHandler); + + + /* Parameter validation */ + + if (!Address) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Ensure that we have a valid GPE number */ + + GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber); + if (!GpeEventInfo) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* Make sure that a handler is indeed installed */ + + if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) != + ACPI_GPE_DISPATCH_HANDLER) + { + Status = AE_NOT_EXIST; + goto UnlockAndExit; + } + + /* Make sure that the installed handler is the same */ + + if (GpeEventInfo->Dispatch.Handler->Address != Address) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* 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_DISPATCH_METHOD; + } + AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags); + + /* Now we can free the handler object */ + + ACPI_FREE (Handler); + + +UnlockAndExit: + (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiRemoveGpeHandler) + + +/******************************************************************************* + * + * FUNCTION: AcpiAcquireGlobalLock + * + * PARAMETERS: Timeout - How long the caller is willing to wait + * Handle - Where the handle to the lock is returned + * (if acquired) + * + * RETURN: Status + * + * DESCRIPTION: Acquire the ACPI Global Lock + * + * Note: Allows callers with the same thread ID to acquire the global lock + * multiple times. In other words, externally, the behavior of the global lock + * is identical to an AML mutex. On the first acquire, a new handle is + * returned. On any subsequent calls to acquire by the same thread, the same + * handle is returned. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAcquireGlobalLock ( + UINT16 Timeout, + UINT32 *Handle) +{ + ACPI_STATUS Status; + + + if (!Handle) + { + return (AE_BAD_PARAMETER); + } + + /* Must lock interpreter to prevent race conditions */ + + AcpiExEnterInterpreter (); + + Status = AcpiExAcquireMutexObject (Timeout, + AcpiGbl_GlobalLockMutex, AcpiOsGetThreadId ()); + + if (ACPI_SUCCESS (Status)) + { + /* Return the global lock handle (updated in AcpiEvAcquireGlobalLock) */ + + *Handle = AcpiGbl_GlobalLockHandle; + } + + AcpiExExitInterpreter (); + return (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiAcquireGlobalLock) + + +/******************************************************************************* + * + * FUNCTION: AcpiReleaseGlobalLock + * + * PARAMETERS: Handle - Returned from AcpiAcquireGlobalLock + * + * RETURN: Status + * + * DESCRIPTION: Release the ACPI Global Lock. The handle must be valid. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiReleaseGlobalLock ( + UINT32 Handle) +{ + ACPI_STATUS Status; + + + if (!Handle || (Handle != AcpiGbl_GlobalLockHandle)) + { + return (AE_NOT_ACQUIRED); + } + + Status = AcpiExReleaseMutexObject (AcpiGbl_GlobalLockMutex); + return (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiReleaseGlobalLock) + diff --git a/reactos/drivers/bus/acpi/acpica/events/evxfevnt.c b/reactos/drivers/bus/acpi/acpica/events/evxfevnt.c new file mode 100644 index 00000000000..27066a39946 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/events/evxfevnt.c @@ -0,0 +1,1112 @@ +/****************************************************************************** + * + * Module Name: evxfevnt - External Interfaces, ACPI event disable/enable + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __EVXFEVNT_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); + + +/******************************************************************************* + * + * FUNCTION: AcpiEnable + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Transfers the system into ACPI mode. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEnable ( + void) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (AcpiEnable); + + + /* ACPI tables must be present */ + + if (!AcpiTbTablesLoaded ()) + { + return_ACPI_STATUS (AE_NO_ACPI_TABLES); + } + + /* Check current mode */ + + if (AcpiHwGetMode() == ACPI_SYS_MODE_ACPI) + { + ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "System is already in ACPI mode\n")); + } + else + { + /* Transition to ACPI mode */ + + Status = AcpiHwSetMode (ACPI_SYS_MODE_ACPI); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR ((AE_INFO, "Could not transition to ACPI mode")); + return_ACPI_STATUS (Status); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_INIT, + "Transition to ACPI mode successful\n")); + } + + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiEnable) + + +/******************************************************************************* + * + * FUNCTION: AcpiDisable + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Transfers the system into LEGACY (non-ACPI) mode. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDisable ( + void) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (AcpiDisable); + + + if (AcpiHwGetMode() == ACPI_SYS_MODE_LEGACY) + { + ACPI_DEBUG_PRINT ((ACPI_DB_INIT, + "System is already in legacy (non-ACPI) mode\n")); + } + else + { + /* Transition to LEGACY mode */ + + Status = AcpiHwSetMode (ACPI_SYS_MODE_LEGACY); + + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR ((AE_INFO, + "Could not exit ACPI mode to legacy mode")); + return_ACPI_STATUS (Status); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "ACPI mode disabled\n")); + } + + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiDisable) + + +/******************************************************************************* + * + * FUNCTION: AcpiEnableEvent + * + * PARAMETERS: Event - The fixed eventto be enabled + * Flags - Reserved + * + * RETURN: Status + * + * DESCRIPTION: Enable an ACPI event (fixed) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEnableEvent ( + UINT32 Event, + UINT32 Flags) +{ + ACPI_STATUS Status = AE_OK; + UINT32 Value; + + + ACPI_FUNCTION_TRACE (AcpiEnableEvent); + + + /* Decode the Fixed Event */ + + if (Event > ACPI_EVENT_MAX) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* + * Enable the requested fixed event (by writing a one to the enable + * register bit) + */ + Status = AcpiWriteBitRegister ( + AcpiGbl_FixedEventInfo[Event].EnableRegisterId, + ACPI_ENABLE_EVENT); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Make sure that the hardware responded */ + + Status = AcpiReadBitRegister ( + AcpiGbl_FixedEventInfo[Event].EnableRegisterId, &Value); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (Value != 1) + { + ACPI_ERROR ((AE_INFO, + "Could not enable %s event", AcpiUtGetEventName (Event))); + return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE); + } + + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiEnableEvent) + + +/******************************************************************************* + * + * FUNCTION: 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 + * Flags - Reserved + * + * RETURN: Status + * + * DESCRIPTION: Disable an ACPI event (fixed) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDisableEvent ( + UINT32 Event, + UINT32 Flags) +{ + ACPI_STATUS Status = AE_OK; + UINT32 Value; + + + ACPI_FUNCTION_TRACE (AcpiDisableEvent); + + + /* Decode the Fixed Event */ + + if (Event > ACPI_EVENT_MAX) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* + * Disable the requested fixed event (by writing a zero to the enable + * register bit) + */ + Status = AcpiWriteBitRegister ( + AcpiGbl_FixedEventInfo[Event].EnableRegisterId, + ACPI_DISABLE_EVENT); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiReadBitRegister ( + AcpiGbl_FixedEventInfo[Event].EnableRegisterId, &Value); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (Value != 0) + { + ACPI_ERROR ((AE_INFO, + "Could not disable %s events", AcpiUtGetEventName (Event))); + return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE); + } + + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiDisableEvent) + + +/******************************************************************************* + * + * FUNCTION: AcpiClearEvent + * + * PARAMETERS: Event - The fixed event to be cleared + * + * RETURN: Status + * + * DESCRIPTION: Clear an ACPI event (fixed) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiClearEvent ( + UINT32 Event) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (AcpiClearEvent); + + + /* Decode the Fixed Event */ + + if (Event > ACPI_EVENT_MAX) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* + * Clear the requested fixed event (By writing a one to the status + * register bit) + */ + Status = AcpiWriteBitRegister ( + AcpiGbl_FixedEventInfo[Event].StatusRegisterId, + ACPI_CLEAR_STATUS); + + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiClearEvent) + + +/******************************************************************************* + * + * FUNCTION: 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 + * + * PARAMETERS: Event - The fixed event + * EventStatus - Where the current status of the event will + * be returned + * + * RETURN: Status + * + * DESCRIPTION: Obtains and returns the current status of the event + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetEventStatus ( + UINT32 Event, + ACPI_EVENT_STATUS *EventStatus) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (AcpiGetEventStatus); + + + if (!EventStatus) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Decode the Fixed Event */ + + if (Event > ACPI_EVENT_MAX) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Get the status of the requested fixed event */ + + Status = AcpiReadBitRegister ( + AcpiGbl_FixedEventInfo[Event].StatusRegisterId, EventStatus); + + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiGetEventStatus) + + +/******************************************************************************* + * + * 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 = AcpiNsValidateHandle (GpeDevice); + if (!Node) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* + * For user-installed GPE Block Devices, the GpeBlockBaseNumber + * is always zero + */ + Status = AcpiEvCreateGpeBlock (Node, GpeBlockAddress, RegisterCount, + 0, InterruptNumber, &GpeBlock); + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + + /* 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 = AcpiNsValidateHandle (GpeDevice); + if (!Node) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* Get the DeviceObject attached to the node */ + + ObjDesc = AcpiNsGetAttachedObject (Node); + if (!ObjDesc || + !ObjDesc->Device.GpeBlock) + { + return_ACPI_STATUS (AE_NULL_OBJECT); + } + + /* Delete the GPE block (but not the DeviceObject) */ + + Status = AcpiEvDeleteGpeBlock (ObjDesc->Device.GpeBlock); + if (ACPI_SUCCESS (Status)) + { + ObjDesc->Device.GpeBlock = NULL; + } + +UnlockAndExit: + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiRemoveGpeBlock) + + +/******************************************************************************* + * + * FUNCTION: AcpiGetGpeDevice + * + * PARAMETERS: Index - System GPE index (0-CurrentGpeCount) + * GpeDevice - Where the parent GPE Device is returned + * + * RETURN: Status + * + * DESCRIPTION: Obtain the GPE device associated with the input index. A NULL + * gpe device indicates that the gpe number is contained in one of + * the FADT-defined gpe blocks. Otherwise, the GPE block device. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetGpeDevice ( + UINT32 Index, + ACPI_HANDLE *GpeDevice) +{ + ACPI_GPE_DEVICE_INFO Info; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiGetGpeDevice); + + + if (!GpeDevice) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + if (Index >= AcpiCurrentGpeCount) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + /* Setup and walk the GPE list */ + + Info.Index = Index; + Info.Status = AE_NOT_EXIST; + Info.GpeDevice = NULL; + Info.NextBlockBaseIndex = 0; + + Status = AcpiEvWalkGpeList (AcpiEvGetGpeDevice, &Info); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + *GpeDevice = ACPI_CAST_PTR (ACPI_HANDLE, Info.GpeDevice); + return_ACPI_STATUS (Info.Status); +} + +ACPI_EXPORT_SYMBOL (AcpiGetGpeDevice) + + +/******************************************************************************* + * + * 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/reactos/drivers/bus/acpi/acpica/events/evxfregn.c b/reactos/drivers/bus/acpi/acpica/events/evxfregn.c new file mode 100644 index 00000000000..3b60589b71a --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/events/evxfregn.c @@ -0,0 +1,346 @@ +/****************************************************************************** + * + * Module Name: evxfregn - External Interfaces, ACPI Operation Regions and + * Address Spaces. + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __EVXFREGN_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" +#include "acevents.h" + +#define _COMPONENT ACPI_EVENTS + ACPI_MODULE_NAME ("evxfregn") + + +/******************************************************************************* + * + * FUNCTION: AcpiInstallAddressSpaceHandler + * + * PARAMETERS: Device - Handle for the device + * SpaceId - The address space ID + * Handler - Address of the handler + * Setup - Address of the setup function + * Context - Value passed to the handler on each access + * + * RETURN: Status + * + * DESCRIPTION: Install a handler for all OpRegions of a given SpaceId. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiInstallAddressSpaceHandler ( + ACPI_HANDLE Device, + ACPI_ADR_SPACE_TYPE SpaceId, + ACPI_ADR_SPACE_HANDLER Handler, + ACPI_ADR_SPACE_SETUP Setup, + void *Context) +{ + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiInstallAddressSpaceHandler); + + + /* Parameter validation */ + + if (!Device) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Convert and validate the device handle */ + + Node = AcpiNsValidateHandle (Device); + if (!Node) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* Install the handler for all Regions for this Space ID */ + + Status = AcpiEvInstallSpaceHandler (Node, SpaceId, Handler, Setup, Context); + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + + /* Run all _REG methods for this address space */ + + Status = AcpiEvExecuteRegMethods (Node, SpaceId); + +UnlockAndExit: + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiInstallAddressSpaceHandler) + + +/******************************************************************************* + * + * FUNCTION: AcpiRemoveAddressSpaceHandler + * + * PARAMETERS: Device - Handle for the device + * SpaceId - The address space ID + * Handler - Address of the handler + * + * RETURN: Status + * + * DESCRIPTION: Remove a previously installed handler. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRemoveAddressSpaceHandler ( + ACPI_HANDLE Device, + ACPI_ADR_SPACE_TYPE SpaceId, + ACPI_ADR_SPACE_HANDLER Handler) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *HandlerObj; + ACPI_OPERAND_OBJECT *RegionObj; + ACPI_OPERAND_OBJECT **LastObjPtr; + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiRemoveAddressSpaceHandler); + + + /* Parameter validation */ + + if (!Device) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Convert and validate the device handle */ + + Node = AcpiNsValidateHandle (Device); + if (!Node || + ((Node->Type != ACPI_TYPE_DEVICE) && + (Node->Type != ACPI_TYPE_PROCESSOR) && + (Node->Type != ACPI_TYPE_THERMAL) && + (Node != AcpiGbl_RootNode))) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* Make sure the internal object exists */ + + ObjDesc = AcpiNsGetAttachedObject (Node); + if (!ObjDesc) + { + Status = AE_NOT_EXIST; + goto UnlockAndExit; + } + + /* Find the address handler the user requested */ + + HandlerObj = ObjDesc->Device.Handler; + LastObjPtr = &ObjDesc->Device.Handler; + while (HandlerObj) + { + /* We have a handler, see if user requested this one */ + + if (HandlerObj->AddressSpace.SpaceId == SpaceId) + { + /* Handler must be the same as the installed handler */ + + if (HandlerObj->AddressSpace.Handler != Handler) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* Matched SpaceId, first dereference this in the Regions */ + + ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, + "Removing address handler %p(%p) for region %s " + "on Device %p(%p)\n", + HandlerObj, Handler, AcpiUtGetRegionName (SpaceId), + Node, ObjDesc)); + + RegionObj = HandlerObj->AddressSpace.RegionList; + + /* Walk the handler's region list */ + + while (RegionObj) + { + /* + * First disassociate the handler from the region. + * + * NOTE: this doesn't mean that the region goes away + * The region is just inaccessible as indicated to + * the _REG method + */ + AcpiEvDetachRegion (RegionObj, TRUE); + + /* + * Walk the list: Just grab the head because the + * DetachRegion removed the previous head. + */ + RegionObj = HandlerObj->AddressSpace.RegionList; + + } + + /* Remove this Handler object from the list */ + + *LastObjPtr = HandlerObj->AddressSpace.Next; + + /* Now we can delete the handler object */ + + AcpiUtRemoveReference (HandlerObj); + goto UnlockAndExit; + } + + /* Walk the linked list of handlers */ + + LastObjPtr = &HandlerObj->AddressSpace.Next; + HandlerObj = HandlerObj->AddressSpace.Next; + } + + /* The handler does not exist */ + + ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, + "Unable to remove address handler %p for %s(%X), DevNode %p, obj %p\n", + Handler, AcpiUtGetRegionName (SpaceId), SpaceId, Node, ObjDesc)); + + Status = AE_NOT_EXIST; + +UnlockAndExit: + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiRemoveAddressSpaceHandler) + diff --git a/reactos/drivers/bus/acpi/acpica/executer/exconfig.c b/reactos/drivers/bus/acpi/acpica/executer/exconfig.c new file mode 100644 index 00000000000..d0acdd5f803 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/executer/exconfig.c @@ -0,0 +1,751 @@ +/****************************************************************************** + * + * Module Name: exconfig - Namespace reconfiguration (Load/Unload opcodes) + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __EXCONFIG_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "actables.h" +#include "acdispat.h" +#include "acevents.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exconfig") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiExAddTable ( + UINT32 TableIndex, + ACPI_NAMESPACE_NODE *ParentNode, + ACPI_OPERAND_OBJECT **DdbHandle); + +static ACPI_STATUS +AcpiExRegionRead ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 Length, + UINT8 *Buffer); + + +/******************************************************************************* + * + * FUNCTION: AcpiExAddTable + * + * PARAMETERS: Table - Pointer to raw table + * ParentNode - Where to load the table (scope) + * DdbHandle - Where to return the table handle. + * + * RETURN: Status + * + * DESCRIPTION: Common function to Install and Load an ACPI table with a + * returned table handle. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiExAddTable ( + UINT32 TableIndex, + ACPI_NAMESPACE_NODE *ParentNode, + ACPI_OPERAND_OBJECT **DdbHandle) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ObjDesc; + + + ACPI_FUNCTION_TRACE (ExAddTable); + + + /* Create an object to be the table handle */ + + ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_REFERENCE); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Init the table handle */ + + ObjDesc->Common.Flags |= AOPOBJ_DATA_VALID; + ObjDesc->Reference.Class = ACPI_REFCLASS_TABLE; + *DdbHandle = ObjDesc; + + /* Install the new table into the local data structures */ + + ObjDesc->Reference.Value = TableIndex; + + /* Add the table to the namespace */ + + Status = AcpiNsLoadTable (TableIndex, ParentNode); + if (ACPI_FAILURE (Status)) + { + AcpiUtRemoveReference (ObjDesc); + *DdbHandle = NULL; + return_ACPI_STATUS (Status); + } + + /* Execute any module-level code that was found in the table */ + + AcpiExExitInterpreter (); + AcpiNsExecModuleCodeList (); + AcpiExEnterInterpreter (); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExLoadTableOp + * + * PARAMETERS: WalkState - Current state with operands + * ReturnDesc - Where to store the return object + * + * RETURN: Status + * + * DESCRIPTION: Load an ACPI table from the RSDT/XSDT + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExLoadTableOp ( + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT **ReturnDesc) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; + ACPI_NAMESPACE_NODE *ParentNode; + ACPI_NAMESPACE_NODE *StartNode; + ACPI_NAMESPACE_NODE *ParameterNode = NULL; + ACPI_OPERAND_OBJECT *DdbHandle; + ACPI_TABLE_HEADER *Table; + UINT32 TableIndex; + + + ACPI_FUNCTION_TRACE (ExLoadTableOp); + + + /* Validate lengths for the SignatureString, OEMIDString, OEMTableID */ + + if ((Operand[0]->String.Length > ACPI_NAME_SIZE) || + (Operand[1]->String.Length > ACPI_OEM_ID_SIZE) || + (Operand[2]->String.Length > ACPI_OEM_TABLE_ID_SIZE)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Find the ACPI table in the RSDT/XSDT */ + + Status = AcpiTbFindTable (Operand[0]->String.Pointer, + Operand[1]->String.Pointer, + Operand[2]->String.Pointer, &TableIndex); + if (ACPI_FAILURE (Status)) + { + if (Status != AE_NOT_FOUND) + { + return_ACPI_STATUS (Status); + } + + /* Table not found, return an Integer=0 and AE_OK */ + + DdbHandle = AcpiUtCreateIntegerObject ((UINT64) 0); + if (!DdbHandle) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + *ReturnDesc = DdbHandle; + return_ACPI_STATUS (AE_OK); + } + + /* Default nodes */ + + StartNode = WalkState->ScopeInfo->Scope.Node; + ParentNode = AcpiGbl_RootNode; + + /* RootPath (optional parameter) */ + + if (Operand[3]->String.Length > 0) + { + /* + * Find the node referenced by the RootPathString. This is the + * location within the namespace where the table will be loaded. + */ + Status = AcpiNsGetNode (StartNode, Operand[3]->String.Pointer, + ACPI_NS_SEARCH_PARENT, &ParentNode); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* ParameterPath (optional parameter) */ + + if (Operand[4]->String.Length > 0) + { + if ((Operand[4]->String.Pointer[0] != '\\') && + (Operand[4]->String.Pointer[0] != '^')) + { + /* + * Path is not absolute, so it will be relative to the node + * referenced by the RootPathString (or the NS root if omitted) + */ + StartNode = ParentNode; + } + + /* Find the node referenced by the ParameterPathString */ + + Status = AcpiNsGetNode (StartNode, Operand[4]->String.Pointer, + ACPI_NS_SEARCH_PARENT, &ParameterNode); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* Load the table into the namespace */ + + Status = AcpiExAddTable (TableIndex, ParentNode, &DdbHandle); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Parameter Data (optional) */ + + if (ParameterNode) + { + /* Store the parameter data into the optional parameter object */ + + Status = AcpiExStore (Operand[5], + ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, ParameterNode), + WalkState); + if (ACPI_FAILURE (Status)) + { + (void) AcpiExUnloadTable (DdbHandle); + + AcpiUtRemoveReference (DdbHandle); + return_ACPI_STATUS (Status); + } + } + + Status = AcpiGetTableByIndex (TableIndex, &Table); + if (ACPI_SUCCESS (Status)) + { + ACPI_INFO ((AE_INFO, + "Dynamic OEM Table Load - [%.4s] OemId [%.6s] OemTableId [%.8s]", + Table->Signature, Table->OemId, Table->OemTableId)); + } + + /* Invoke table handler if present */ + + if (AcpiGbl_TableHandler) + { + (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_LOAD, Table, + AcpiGbl_TableHandlerContext); + } + + *ReturnDesc = DdbHandle; + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExRegionRead + * + * PARAMETERS: ObjDesc - Region descriptor + * Length - Number of bytes to read + * Buffer - Pointer to where to put the data + * + * RETURN: Status + * + * DESCRIPTION: Read data from an operation region. The read starts from the + * beginning of the region. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiExRegionRead ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 Length, + UINT8 *Buffer) +{ + ACPI_STATUS Status; + ACPI_INTEGER Value; + UINT32 RegionOffset = 0; + UINT32 i; + + + /* Bytewise reads */ + + for (i = 0; i < Length; i++) + { + Status = AcpiEvAddressSpaceDispatch (ObjDesc, ACPI_READ, + RegionOffset, 8, &Value); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + *Buffer = (UINT8) Value; + Buffer++; + RegionOffset++; + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExLoadOp + * + * PARAMETERS: ObjDesc - Region or Buffer/Field where the table will be + * obtained + * Target - Where a handle to the table will be stored + * WalkState - Current state + * + * RETURN: Status + * + * DESCRIPTION: Load an ACPI table from a field or operation region + * + * NOTE: Region Fields (Field, BankField, IndexFields) are resolved to buffer + * objects before this code is reached. + * + * If source is an operation region, it must refer to SystemMemory, as + * per the ACPI specification. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExLoadOp ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT *Target, + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT *DdbHandle; + ACPI_TABLE_HEADER *Table; + ACPI_TABLE_DESC TableDesc; + UINT32 TableIndex; + ACPI_STATUS Status; + UINT32 Length; + + + ACPI_FUNCTION_TRACE (ExLoadOp); + + + ACPI_MEMSET (&TableDesc, 0, sizeof (ACPI_TABLE_DESC)); + + /* Source Object can be either an OpRegion or a Buffer/Field */ + + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_REGION: + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Load table from Region %p\n", ObjDesc)); + + /* Region must be SystemMemory (from ACPI spec) */ + + if (ObjDesc->Region.SpaceId != ACPI_ADR_SPACE_SYSTEM_MEMORY) + { + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* + * If the Region Address and Length have not been previously evaluated, + * evaluate them now and save the results. + */ + if (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)) + { + Status = AcpiDsGetRegionArguments (ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* Get the table header first so we can get the table length */ + + Table = ACPI_ALLOCATE (sizeof (ACPI_TABLE_HEADER)); + if (!Table) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Status = AcpiExRegionRead (ObjDesc, sizeof (ACPI_TABLE_HEADER), + ACPI_CAST_PTR (UINT8, Table)); + Length = Table->Length; + ACPI_FREE (Table); + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Must have at least an ACPI table header */ + + if (Length < sizeof (ACPI_TABLE_HEADER)) + { + return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH); + } + + /* + * The original implementation simply mapped the table, with no copy. + * However, the memory region is not guaranteed to remain stable and + * we must copy the table to a local buffer. For example, the memory + * region is corrupted after suspend on some machines. Dynamically + * loaded tables are usually small, so this overhead is minimal. + * + * The latest implementation (5/2009) does not use a mapping at all. + * We use the low-level operation region interface to read the table + * instead of the obvious optimization of using a direct mapping. + * This maintains a consistent use of operation regions across the + * entire subsystem. This is important if additional processing must + * be performed in the (possibly user-installed) operation region + * handler. For example, AcpiExec and ASLTS depend on this. + */ + + /* Allocate a buffer for the table */ + + TableDesc.Pointer = ACPI_ALLOCATE (Length); + if (!TableDesc.Pointer) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Read the entire table */ + + Status = AcpiExRegionRead (ObjDesc, Length, + ACPI_CAST_PTR (UINT8, TableDesc.Pointer)); + if (ACPI_FAILURE (Status)) + { + ACPI_FREE (TableDesc.Pointer); + return_ACPI_STATUS (Status); + } + + TableDesc.Address = ObjDesc->Region.Address; + break; + + + case ACPI_TYPE_BUFFER: /* Buffer or resolved RegionField */ + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Load table from Buffer or Field %p\n", ObjDesc)); + + /* Must have at least an ACPI table header */ + + if (ObjDesc->Buffer.Length < sizeof (ACPI_TABLE_HEADER)) + { + return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH); + } + + /* Get the actual table length from the table header */ + + Table = ACPI_CAST_PTR (ACPI_TABLE_HEADER, ObjDesc->Buffer.Pointer); + Length = Table->Length; + + /* Table cannot extend beyond the buffer */ + + if (Length > ObjDesc->Buffer.Length) + { + return_ACPI_STATUS (AE_AML_BUFFER_LIMIT); + } + if (Length < sizeof (ACPI_TABLE_HEADER)) + { + return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH); + } + + /* + * Copy the table from the buffer because the buffer could be modified + * or even deleted in the future + */ + TableDesc.Pointer = ACPI_ALLOCATE (Length); + if (!TableDesc.Pointer) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + ACPI_MEMCPY (TableDesc.Pointer, Table, Length); + TableDesc.Address = ACPI_TO_INTEGER (TableDesc.Pointer); + break; + + + default: + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* Validate table checksum (will not get validated in TbAddTable) */ + + Status = AcpiTbVerifyChecksum (TableDesc.Pointer, Length); + if (ACPI_FAILURE (Status)) + { + ACPI_FREE (TableDesc.Pointer); + return_ACPI_STATUS (Status); + } + + /* Complete the table descriptor */ + + TableDesc.Length = Length; + TableDesc.Flags = ACPI_TABLE_ORIGIN_ALLOCATED; + + /* Install the new table into the local data structures */ + + Status = AcpiTbAddTable (&TableDesc, &TableIndex); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* + * Add the table to the namespace. + * + * Note: Load the table objects relative to the root of the namespace. + * This appears to go against the ACPI specification, but we do it for + * compatibility with other ACPI implementations. + */ + Status = AcpiExAddTable (TableIndex, AcpiGbl_RootNode, &DdbHandle); + if (ACPI_FAILURE (Status)) + { + /* On error, TablePtr was deallocated above */ + + return_ACPI_STATUS (Status); + } + + /* Store the DdbHandle into the Target operand */ + + Status = AcpiExStore (DdbHandle, Target, WalkState); + if (ACPI_FAILURE (Status)) + { + (void) AcpiExUnloadTable (DdbHandle); + + /* TablePtr was deallocated above */ + + AcpiUtRemoveReference (DdbHandle); + return_ACPI_STATUS (Status); + } + + /* Remove the reference by added by AcpiExStore above */ + + AcpiUtRemoveReference (DdbHandle); + + /* Invoke table handler if present */ + + if (AcpiGbl_TableHandler) + { + (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_LOAD, TableDesc.Pointer, + AcpiGbl_TableHandlerContext); + } + +Cleanup: + if (ACPI_FAILURE (Status)) + { + /* Delete allocated table buffer */ + + AcpiTbDeleteTable (&TableDesc); + } + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExUnloadTable + * + * PARAMETERS: DdbHandle - Handle to a previously loaded table + * + * RETURN: Status + * + * DESCRIPTION: Unload an ACPI table + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExUnloadTable ( + ACPI_OPERAND_OBJECT *DdbHandle) +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT *TableDesc = DdbHandle; + UINT32 TableIndex; + ACPI_TABLE_HEADER *Table; + + + ACPI_FUNCTION_TRACE (ExUnloadTable); + + + /* + * Validate the handle + * Although the handle is partially validated in AcpiExReconfiguration() + * when it calls AcpiExResolveOperands(), the handle is more completely + * validated here. + * + * Handle must be a valid operand object of type reference. Also, the + * DdbHandle must still be marked valid (table has not been previously + * unloaded) + */ + if ((!DdbHandle) || + (ACPI_GET_DESCRIPTOR_TYPE (DdbHandle) != ACPI_DESC_TYPE_OPERAND) || + (DdbHandle->Common.Type != ACPI_TYPE_LOCAL_REFERENCE) || + (!(DdbHandle->Common.Flags & AOPOBJ_DATA_VALID))) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Get the table index from the DdbHandle */ + + TableIndex = TableDesc->Reference.Value; + + /* Ensure the table is still loaded */ + + if (!AcpiTbIsTableLoaded (TableIndex)) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + /* Invoke table handler if present */ + + if (AcpiGbl_TableHandler) + { + Status = AcpiGetTableByIndex (TableIndex, &Table); + if (ACPI_SUCCESS (Status)) + { + (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_UNLOAD, Table, + AcpiGbl_TableHandlerContext); + } + } + + /* Delete the portion of the namespace owned by this table */ + + Status = AcpiTbDeleteNamespaceByOwner (TableIndex); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + (void) AcpiTbReleaseOwnerId (TableIndex); + AcpiTbSetTableLoadedFlag (TableIndex, FALSE); + + /* + * Invalidate the handle. We do this because the handle may be stored + * in a named object and may not be actually deleted until much later. + */ + DdbHandle->Common.Flags &= ~AOPOBJ_DATA_VALID; + return_ACPI_STATUS (AE_OK); +} + diff --git a/reactos/drivers/bus/acpi/acpica/executer/exconvrt.c b/reactos/drivers/bus/acpi/acpica/executer/exconvrt.c new file mode 100644 index 00000000000..fd8fec1c711 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/executer/exconvrt.c @@ -0,0 +1,826 @@ +/****************************************************************************** + * + * Module Name: exconvrt - Object conversion routines + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __EXCONVRT_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" +#include "amlcode.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exconvrt") + +/* Local prototypes */ + +static UINT32 +AcpiExConvertToAscii ( + ACPI_INTEGER Integer, + UINT16 Base, + UINT8 *String, + UINT8 MaxLength); + + +/******************************************************************************* + * + * FUNCTION: AcpiExConvertToInteger + * + * PARAMETERS: ObjDesc - Object to be converted. Must be an + * Integer, Buffer, or String + * ResultDesc - Where the new Integer object is returned + * Flags - Used for string conversion + * + * RETURN: Status + * + * DESCRIPTION: Convert an ACPI Object to an integer. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExConvertToInteger ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT **ResultDesc, + UINT32 Flags) +{ + ACPI_OPERAND_OBJECT *ReturnDesc; + UINT8 *Pointer; + ACPI_INTEGER Result; + UINT32 i; + UINT32 Count; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE_PTR (ExConvertToInteger, ObjDesc); + + + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_INTEGER: + + /* No conversion necessary */ + + *ResultDesc = ObjDesc; + return_ACPI_STATUS (AE_OK); + + case ACPI_TYPE_BUFFER: + case ACPI_TYPE_STRING: + + /* Note: Takes advantage of common buffer/string fields */ + + Pointer = ObjDesc->Buffer.Pointer; + Count = ObjDesc->Buffer.Length; + break; + + default: + return_ACPI_STATUS (AE_TYPE); + } + + /* + * Convert the buffer/string to an integer. Note that both buffers and + * strings are treated as raw data - we don't convert ascii to hex for + * strings. + * + * There are two terminating conditions for the loop: + * 1) The size of an integer has been reached, or + * 2) The end of the buffer or string has been reached + */ + Result = 0; + + /* String conversion is different than Buffer conversion */ + + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_STRING: + + /* + * Convert string to an integer - for most cases, the string must be + * hexadecimal as per the ACPI specification. The only exception (as + * of ACPI 3.0) is that the ToInteger() operator allows both decimal + * and hexadecimal strings (hex prefixed with "0x"). + */ + Status = AcpiUtStrtoul64 ((char *) Pointer, Flags, &Result); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + break; + + + case ACPI_TYPE_BUFFER: + + /* Check for zero-length buffer */ + + if (!Count) + { + return_ACPI_STATUS (AE_AML_BUFFER_LIMIT); + } + + /* Transfer no more than an integer's worth of data */ + + if (Count > AcpiGbl_IntegerByteWidth) + { + Count = AcpiGbl_IntegerByteWidth; + } + + /* + * Convert buffer to an integer - we simply grab enough raw data + * from the buffer to fill an integer + */ + for (i = 0; i < Count; i++) + { + /* + * Get next byte and shift it into the Result. + * Little endian is used, meaning that the first byte of the buffer + * is the LSB of the integer + */ + Result |= (((ACPI_INTEGER) Pointer[i]) << (i * 8)); + } + break; + + + default: + + /* No other types can get here */ + break; + } + + /* Create a new integer */ + + ReturnDesc = AcpiUtCreateIntegerObject (Result); + if (!ReturnDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Converted value: %8.8X%8.8X\n", + ACPI_FORMAT_UINT64 (Result))); + + /* Save the Result */ + + AcpiExTruncateFor32bitTable (ReturnDesc); + *ResultDesc = ReturnDesc; + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExConvertToBuffer + * + * PARAMETERS: ObjDesc - Object to be converted. Must be an + * Integer, Buffer, or String + * ResultDesc - Where the new buffer object is returned + * + * RETURN: Status + * + * DESCRIPTION: Convert an ACPI Object to a Buffer + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExConvertToBuffer ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT **ResultDesc) +{ + ACPI_OPERAND_OBJECT *ReturnDesc; + UINT8 *NewBuf; + + + ACPI_FUNCTION_TRACE_PTR (ExConvertToBuffer, ObjDesc); + + + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_BUFFER: + + /* No conversion necessary */ + + *ResultDesc = ObjDesc; + return_ACPI_STATUS (AE_OK); + + + case ACPI_TYPE_INTEGER: + + /* + * Create a new Buffer object. + * Need enough space for one integer + */ + ReturnDesc = AcpiUtCreateBufferObject (AcpiGbl_IntegerByteWidth); + if (!ReturnDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Copy the integer to the buffer, LSB first */ + + NewBuf = ReturnDesc->Buffer.Pointer; + ACPI_MEMCPY (NewBuf, + &ObjDesc->Integer.Value, + AcpiGbl_IntegerByteWidth); + break; + + + case ACPI_TYPE_STRING: + + /* + * Create a new Buffer object + * Size will be the string length + * + * NOTE: Add one to the string length to include the null terminator. + * The ACPI spec is unclear on this subject, but there is existing + * ASL/AML code that depends on the null being transferred to the new + * buffer. + */ + ReturnDesc = AcpiUtCreateBufferObject ( + (ACPI_SIZE) ObjDesc->String.Length + 1); + if (!ReturnDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Copy the string to the buffer */ + + NewBuf = ReturnDesc->Buffer.Pointer; + ACPI_STRNCPY ((char *) NewBuf, (char *) ObjDesc->String.Pointer, + ObjDesc->String.Length); + break; + + + default: + return_ACPI_STATUS (AE_TYPE); + } + + /* Mark buffer initialized */ + + ReturnDesc->Common.Flags |= AOPOBJ_DATA_VALID; + *ResultDesc = ReturnDesc; + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExConvertToAscii + * + * PARAMETERS: Integer - Value to be converted + * Base - ACPI_STRING_DECIMAL or ACPI_STRING_HEX + * String - Where the string is returned + * DataWidth - Size of data item to be converted, in bytes + * + * RETURN: Actual string length + * + * DESCRIPTION: Convert an ACPI Integer to a hex or decimal string + * + ******************************************************************************/ + +static UINT32 +AcpiExConvertToAscii ( + ACPI_INTEGER Integer, + UINT16 Base, + UINT8 *String, + UINT8 DataWidth) +{ + ACPI_INTEGER Digit; + UINT32 i; + UINT32 j; + UINT32 k = 0; + UINT32 HexLength; + UINT32 DecimalLength; + UINT32 Remainder; + BOOLEAN SupressZeros; + + + ACPI_FUNCTION_ENTRY (); + + + switch (Base) + { + case 10: + + /* Setup max length for the decimal number */ + + switch (DataWidth) + { + case 1: + DecimalLength = ACPI_MAX8_DECIMAL_DIGITS; + break; + + case 4: + DecimalLength = ACPI_MAX32_DECIMAL_DIGITS; + break; + + case 8: + default: + DecimalLength = ACPI_MAX64_DECIMAL_DIGITS; + break; + } + + SupressZeros = TRUE; /* No leading zeros */ + Remainder = 0; + + for (i = DecimalLength; i > 0; i--) + { + /* Divide by nth factor of 10 */ + + Digit = Integer; + for (j = 0; j < i; j++) + { + (void) AcpiUtShortDivide (Digit, 10, &Digit, &Remainder); + } + + /* Handle leading zeros */ + + if (Remainder != 0) + { + SupressZeros = FALSE; + } + + if (!SupressZeros) + { + String[k] = (UINT8) (ACPI_ASCII_ZERO + Remainder); + k++; + } + } + break; + + case 16: + + /* HexLength: 2 ascii hex chars per data byte */ + + HexLength = ACPI_MUL_2 (DataWidth); + for (i = 0, j = (HexLength-1); i < HexLength; i++, j--) + { + /* Get one hex digit, most significant digits first */ + + String[k] = (UINT8) AcpiUtHexToAsciiChar (Integer, ACPI_MUL_4 (j)); + k++; + } + break; + + default: + return (0); + } + + /* + * Since leading zeros are suppressed, we must check for the case where + * the integer equals 0 + * + * Finally, null terminate the string and return the length + */ + if (!k) + { + String [0] = ACPI_ASCII_ZERO; + k = 1; + } + + String [k] = 0; + return ((UINT32) k); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExConvertToString + * + * PARAMETERS: ObjDesc - Object to be converted. Must be an + * Integer, Buffer, or String + * ResultDesc - Where the string object is returned + * Type - String flags (base and conversion type) + * + * RETURN: Status + * + * DESCRIPTION: Convert an ACPI Object to a string + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExConvertToString ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT **ResultDesc, + UINT32 Type) +{ + ACPI_OPERAND_OBJECT *ReturnDesc; + UINT8 *NewBuf; + UINT32 i; + UINT32 StringLength = 0; + UINT16 Base = 16; + UINT8 Separator = ','; + + + ACPI_FUNCTION_TRACE_PTR (ExConvertToString, ObjDesc); + + + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_STRING: + + /* No conversion necessary */ + + *ResultDesc = ObjDesc; + return_ACPI_STATUS (AE_OK); + + + case ACPI_TYPE_INTEGER: + + switch (Type) + { + case ACPI_EXPLICIT_CONVERT_DECIMAL: + + /* Make room for maximum decimal number */ + + StringLength = ACPI_MAX_DECIMAL_DIGITS; + Base = 10; + break; + + default: + + /* Two hex string characters for each integer byte */ + + StringLength = ACPI_MUL_2 (AcpiGbl_IntegerByteWidth); + break; + } + + /* + * Create a new String + * Need enough space for one ASCII integer (plus null terminator) + */ + ReturnDesc = AcpiUtCreateStringObject ((ACPI_SIZE) StringLength); + if (!ReturnDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + NewBuf = ReturnDesc->Buffer.Pointer; + + /* Convert integer to string */ + + StringLength = AcpiExConvertToAscii (ObjDesc->Integer.Value, Base, + NewBuf, AcpiGbl_IntegerByteWidth); + + /* Null terminate at the correct place */ + + ReturnDesc->String.Length = StringLength; + NewBuf [StringLength] = 0; + break; + + + case ACPI_TYPE_BUFFER: + + /* Setup string length, base, and separator */ + + switch (Type) + { + case ACPI_EXPLICIT_CONVERT_DECIMAL: /* Used by ToDecimalString */ + /* + * From ACPI: "If Data is a buffer, it is converted to a string of + * decimal values separated by commas." + */ + Base = 10; + + /* + * Calculate the final string length. Individual string values + * are variable length (include separator for each) + */ + for (i = 0; i < ObjDesc->Buffer.Length; i++) + { + if (ObjDesc->Buffer.Pointer[i] >= 100) + { + StringLength += 4; + } + else if (ObjDesc->Buffer.Pointer[i] >= 10) + { + StringLength += 3; + } + else + { + StringLength += 2; + } + } + break; + + case ACPI_IMPLICIT_CONVERT_HEX: + /* + * From the ACPI spec: + *"The entire contents of the buffer are converted to a string of + * two-character hexadecimal numbers, each separated by a space." + */ + Separator = ' '; + StringLength = (ObjDesc->Buffer.Length * 3); + break; + + case ACPI_EXPLICIT_CONVERT_HEX: /* Used by ToHexString */ + /* + * From ACPI: "If Data is a buffer, it is converted to a string of + * hexadecimal values separated by commas." + */ + StringLength = (ObjDesc->Buffer.Length * 3); + break; + + default: + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* + * Create a new string object and string buffer + * (-1 because of extra separator included in StringLength from above) + * Allow creation of zero-length strings from zero-length buffers. + */ + if (StringLength) + { + StringLength--; + } + + ReturnDesc = AcpiUtCreateStringObject ((ACPI_SIZE) StringLength); + if (!ReturnDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + NewBuf = ReturnDesc->Buffer.Pointer; + + /* + * Convert buffer bytes to hex or decimal values + * (separated by commas or spaces) + */ + for (i = 0; i < ObjDesc->Buffer.Length; i++) + { + NewBuf += AcpiExConvertToAscii ( + (ACPI_INTEGER) ObjDesc->Buffer.Pointer[i], Base, + NewBuf, 1); + *NewBuf++ = Separator; /* each separated by a comma or space */ + } + + /* + * Null terminate the string + * (overwrites final comma/space from above) + */ + if (ObjDesc->Buffer.Length) + { + NewBuf--; + } + *NewBuf = 0; + break; + + default: + return_ACPI_STATUS (AE_TYPE); + } + + *ResultDesc = ReturnDesc; + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExConvertToTargetType + * + * PARAMETERS: DestinationType - Current type of the destination + * SourceDesc - Source object to be converted. + * ResultDesc - Where the converted object is returned + * WalkState - Current method state + * + * RETURN: Status + * + * DESCRIPTION: Implements "implicit conversion" rules for storing an object. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExConvertToTargetType ( + ACPI_OBJECT_TYPE DestinationType, + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT **ResultDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (ExConvertToTargetType); + + + /* Default behavior */ + + *ResultDesc = SourceDesc; + + /* + * If required by the target, + * perform implicit conversion on the source before we store it. + */ + switch (GET_CURRENT_ARG_TYPE (WalkState->OpInfo->RuntimeArgs)) + { + case ARGI_SIMPLE_TARGET: + case ARGI_FIXED_TARGET: + case ARGI_INTEGER_REF: /* Handles Increment, Decrement cases */ + + switch (DestinationType) + { + case ACPI_TYPE_LOCAL_REGION_FIELD: + /* + * Named field can always handle conversions + */ + break; + + default: + /* No conversion allowed for these types */ + + if (DestinationType != SourceDesc->Common.Type) + { + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Explicit operator, will store (%s) over existing type (%s)\n", + AcpiUtGetObjectTypeName (SourceDesc), + AcpiUtGetTypeName (DestinationType))); + Status = AE_TYPE; + } + } + break; + + + case ARGI_TARGETREF: + + switch (DestinationType) + { + case ACPI_TYPE_INTEGER: + case ACPI_TYPE_BUFFER_FIELD: + case ACPI_TYPE_LOCAL_BANK_FIELD: + case ACPI_TYPE_LOCAL_INDEX_FIELD: + /* + * These types require an Integer operand. We can convert + * a Buffer or a String to an Integer if necessary. + */ + Status = AcpiExConvertToInteger (SourceDesc, ResultDesc, + 16); + break; + + + case ACPI_TYPE_STRING: + /* + * The operand must be a String. We can convert an + * Integer or Buffer if necessary + */ + Status = AcpiExConvertToString (SourceDesc, ResultDesc, + ACPI_IMPLICIT_CONVERT_HEX); + break; + + + case ACPI_TYPE_BUFFER: + /* + * The operand must be a Buffer. We can convert an + * Integer or String if necessary + */ + Status = AcpiExConvertToBuffer (SourceDesc, ResultDesc); + break; + + + default: + ACPI_ERROR ((AE_INFO, "Bad destination type during conversion: %X", + DestinationType)); + Status = AE_AML_INTERNAL; + break; + } + break; + + + case ARGI_REFERENCE: + /* + * CreateXxxxField cases - we are storing the field object into the name + */ + break; + + + default: + ACPI_ERROR ((AE_INFO, + "Unknown Target type ID 0x%X AmlOpcode %X DestType %s", + GET_CURRENT_ARG_TYPE (WalkState->OpInfo->RuntimeArgs), + WalkState->Opcode, AcpiUtGetTypeName (DestinationType))); + Status = AE_AML_INTERNAL; + } + + /* + * Source-to-Target conversion semantics: + * + * If conversion to the target type cannot be performed, then simply + * overwrite the target with the new object and type. + */ + if (Status == AE_TYPE) + { + Status = AE_OK; + } + + return_ACPI_STATUS (Status); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/executer/excreate.c b/reactos/drivers/bus/acpi/acpica/executer/excreate.c new file mode 100644 index 00000000000..e5463187a86 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/executer/excreate.c @@ -0,0 +1,636 @@ +/****************************************************************************** + * + * Module Name: excreate - Named object creation + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __EXCREATE_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("excreate") + + +#ifndef ACPI_NO_METHOD_EXECUTION +/******************************************************************************* + * + * FUNCTION: AcpiExCreateAlias + * + * PARAMETERS: WalkState - Current state, contains operands + * + * RETURN: Status + * + * DESCRIPTION: Create a new named alias + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExCreateAlias ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_NAMESPACE_NODE *TargetNode; + ACPI_NAMESPACE_NODE *AliasNode; + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (ExCreateAlias); + + + /* Get the source/alias operands (both namespace nodes) */ + + AliasNode = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0]; + TargetNode = (ACPI_NAMESPACE_NODE *) WalkState->Operands[1]; + + if ((TargetNode->Type == ACPI_TYPE_LOCAL_ALIAS) || + (TargetNode->Type == ACPI_TYPE_LOCAL_METHOD_ALIAS)) + { + /* + * Dereference an existing alias so that we don't create a chain + * of aliases. With this code, we guarantee that an alias is + * always exactly one level of indirection away from the + * actual aliased name. + */ + TargetNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, TargetNode->Object); + } + + /* + * For objects that can never change (i.e., the NS node will + * permanently point to the same object), we can simply attach + * the object to the new NS node. For other objects (such as + * Integers, buffers, etc.), we have to point the Alias node + * to the original Node. + */ + switch (TargetNode->Type) + { + + /* For these types, the sub-object can change dynamically via a Store */ + + case ACPI_TYPE_INTEGER: + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + case ACPI_TYPE_PACKAGE: + case ACPI_TYPE_BUFFER_FIELD: + + /* + * These types open a new scope, so we need the NS node in order to access + * any children. + */ + case ACPI_TYPE_DEVICE: + case ACPI_TYPE_POWER: + case ACPI_TYPE_PROCESSOR: + case ACPI_TYPE_THERMAL: + case ACPI_TYPE_LOCAL_SCOPE: + + /* + * The new alias has the type ALIAS and points to the original + * NS node, not the object itself. + */ + AliasNode->Type = ACPI_TYPE_LOCAL_ALIAS; + AliasNode->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode); + break; + + case ACPI_TYPE_METHOD: + + /* + * Control method aliases need to be differentiated + */ + AliasNode->Type = ACPI_TYPE_LOCAL_METHOD_ALIAS; + AliasNode->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode); + break; + + default: + + /* Attach the original source object to the new Alias Node */ + + /* + * The new alias assumes the type of the target, and it points + * to the same object. The reference count of the object has an + * additional reference to prevent deletion out from under either the + * target node or the alias Node + */ + Status = AcpiNsAttachObject (AliasNode, + AcpiNsGetAttachedObject (TargetNode), TargetNode->Type); + break; + } + + /* Since both operands are Nodes, we don't need to delete them */ + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExCreateEvent + * + * PARAMETERS: WalkState - Current state + * + * RETURN: Status + * + * DESCRIPTION: Create a new event object + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExCreateEvent ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ObjDesc; + + + ACPI_FUNCTION_TRACE (ExCreateEvent); + + + ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_EVENT); + if (!ObjDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* + * Create the actual OS semaphore, with zero initial units -- meaning + * that the event is created in an unsignalled state + */ + Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 0, + &ObjDesc->Event.OsSemaphore); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* Attach object to the Node */ + + Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) WalkState->Operands[0], + ObjDesc, ACPI_TYPE_EVENT); + +Cleanup: + /* + * Remove local reference to the object (on error, will cause deletion + * of both object and semaphore if present.) + */ + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExCreateMutex + * + * PARAMETERS: WalkState - Current state + * + * RETURN: Status + * + * DESCRIPTION: Create a new mutex object + * + * Mutex (Name[0], SyncLevel[1]) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExCreateMutex ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT *ObjDesc; + + + ACPI_FUNCTION_TRACE_PTR (ExCreateMutex, ACPI_WALK_OPERANDS); + + + /* Create the new mutex object */ + + ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_MUTEX); + if (!ObjDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Create the actual OS Mutex */ + + Status = AcpiOsCreateMutex (&ObjDesc->Mutex.OsMutex); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* Init object and attach to NS node */ + + ObjDesc->Mutex.SyncLevel = (UINT8) WalkState->Operands[1]->Integer.Value; + ObjDesc->Mutex.Node = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0]; + + Status = AcpiNsAttachObject (ObjDesc->Mutex.Node, ObjDesc, ACPI_TYPE_MUTEX); + + +Cleanup: + /* + * Remove local reference to the object (on error, will cause deletion + * of both object and semaphore if present.) + */ + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExCreateRegion + * + * PARAMETERS: AmlStart - Pointer to the region declaration AML + * AmlLength - Max length of the declaration AML + * RegionSpace - SpaceID for the region + * WalkState - Current state + * + * RETURN: Status + * + * DESCRIPTION: Create a new operation region object + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExCreateRegion ( + UINT8 *AmlStart, + UINT32 AmlLength, + UINT8 RegionSpace, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_NAMESPACE_NODE *Node; + ACPI_OPERAND_OBJECT *RegionObj2; + + + ACPI_FUNCTION_TRACE (ExCreateRegion); + + + /* Get the Namespace Node */ + + Node = WalkState->Op->Common.Node; + + /* + * If the region object is already attached to this node, + * just return + */ + if (AcpiNsGetAttachedObject (Node)) + { + return_ACPI_STATUS (AE_OK); + } + + /* + * Space ID must be one of the predefined IDs, or in the user-defined + * range + */ + if ((RegionSpace >= ACPI_NUM_PREDEFINED_REGIONS) && + (RegionSpace < ACPI_USER_REGION_BEGIN)) + { + ACPI_ERROR ((AE_INFO, "Invalid AddressSpace type %X", RegionSpace)); + return_ACPI_STATUS (AE_AML_INVALID_SPACE_ID); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Region Type - %s (%X)\n", + AcpiUtGetRegionName (RegionSpace), RegionSpace)); + + /* Create the region descriptor */ + + ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_REGION); + if (!ObjDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* + * Remember location in AML stream of address & length + * operands since they need to be evaluated at run time. + */ + RegionObj2 = ObjDesc->Common.NextObject; + RegionObj2->Extra.AmlStart = AmlStart; + RegionObj2->Extra.AmlLength = AmlLength; + + /* Init the region from the operands */ + + ObjDesc->Region.SpaceId = RegionSpace; + ObjDesc->Region.Address = 0; + ObjDesc->Region.Length = 0; + ObjDesc->Region.Node = Node; + + /* Install the new region object in the parent Node */ + + Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_REGION); + + +Cleanup: + + /* Remove local reference to the object */ + + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExCreateProcessor + * + * PARAMETERS: WalkState - Current state + * + * RETURN: Status + * + * DESCRIPTION: Create a new processor object and populate the fields + * + * Processor (Name[0], CpuID[1], PblockAddr[2], PblockLength[3]) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExCreateProcessor ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE_PTR (ExCreateProcessor, WalkState); + + + /* Create the processor object */ + + ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_PROCESSOR); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Initialize the processor object from the operands */ + + ObjDesc->Processor.ProcId = (UINT8) Operand[1]->Integer.Value; + ObjDesc->Processor.Length = (UINT8) Operand[3]->Integer.Value; + ObjDesc->Processor.Address = (ACPI_IO_ADDRESS) Operand[2]->Integer.Value; + + /* Install the processor object in the parent Node */ + + Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0], + ObjDesc, ACPI_TYPE_PROCESSOR); + + /* Remove local reference to the object */ + + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExCreatePowerResource + * + * PARAMETERS: WalkState - Current state + * + * RETURN: Status + * + * DESCRIPTION: Create a new PowerResource object and populate the fields + * + * PowerResource (Name[0], SystemLevel[1], ResourceOrder[2]) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExCreatePowerResource ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ObjDesc; + + + ACPI_FUNCTION_TRACE_PTR (ExCreatePowerResource, WalkState); + + + /* Create the power resource object */ + + ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_POWER); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Initialize the power object from the operands */ + + ObjDesc->PowerResource.SystemLevel = (UINT8) Operand[1]->Integer.Value; + ObjDesc->PowerResource.ResourceOrder = (UINT16) Operand[2]->Integer.Value; + + /* Install the power resource object in the parent Node */ + + Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0], + ObjDesc, ACPI_TYPE_POWER); + + /* Remove local reference to the object */ + + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); +} +#endif + + +/******************************************************************************* + * + * FUNCTION: AcpiExCreateMethod + * + * PARAMETERS: AmlStart - First byte of the method's AML + * AmlLength - AML byte count for this method + * WalkState - Current state + * + * RETURN: Status + * + * DESCRIPTION: Create a new method object + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExCreateMethod ( + UINT8 *AmlStart, + UINT32 AmlLength, + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + UINT8 MethodFlags; + + + ACPI_FUNCTION_TRACE_PTR (ExCreateMethod, WalkState); + + + /* Create a new method object */ + + ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_METHOD); + if (!ObjDesc) + { + Status = AE_NO_MEMORY; + goto Exit; + } + + /* Save the method's AML pointer and length */ + + ObjDesc->Method.AmlStart = AmlStart; + ObjDesc->Method.AmlLength = AmlLength; + + /* + * Disassemble the method flags. Split off the Arg Count + * 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); + + /* + * Get the SyncLevel. If method is serialized, a mutex will be + * created for this method when it is parsed. + */ + if (MethodFlags & AML_METHOD_SERIALIZED) + { + /* + * ACPI 1.0: SyncLevel = 0 + * ACPI 2.0: SyncLevel = SyncLevel in method declaration + */ + ObjDesc->Method.SyncLevel = (UINT8) + ((MethodFlags & AML_METHOD_SYNC_LEVEL) >> 4); + } + + /* Attach the new object to the method Node */ + + Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0], + ObjDesc, ACPI_TYPE_METHOD); + + /* Remove local reference to the object */ + + AcpiUtRemoveReference (ObjDesc); + +Exit: + /* Remove a reference to the operand */ + + AcpiUtRemoveReference (Operand[1]); + return_ACPI_STATUS (Status); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/executer/exdump.c b/reactos/drivers/bus/acpi/acpica/executer/exdump.c new file mode 100644 index 00000000000..5de5a6f6e40 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/executer/exdump.c @@ -0,0 +1,1194 @@ +/****************************************************************************** + * + * Module Name: exdump - Interpreter debug output routines + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __EXDUMP_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exdump") + +/* + * The following routines are used for debug output only + */ +#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) + +/* Local prototypes */ + +static void +AcpiExOutString ( + char *Title, + char *Value); + +static void +AcpiExOutPointer ( + char *Title, + void *Value); + +static void +AcpiExDumpObject ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_EXDUMP_INFO *Info); + +static void +AcpiExDumpReferenceObj ( + ACPI_OPERAND_OBJECT *ObjDesc); + +static void +AcpiExDumpPackageObj ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 Level, + UINT32 Index); + + +/******************************************************************************* + * + * Object Descriptor info tables + * + * Note: The first table entry must be an INIT opcode and must contain + * the table length (number of table entries) + * + ******************************************************************************/ + +static ACPI_EXDUMP_INFO AcpiExDumpInteger[2] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpInteger), NULL}, + {ACPI_EXD_UINT64, ACPI_EXD_OFFSET (Integer.Value), "Value"} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpString[4] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpString), NULL}, + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (String.Length), "Length"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (String.Pointer), "Pointer"}, + {ACPI_EXD_STRING, 0, NULL} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpBuffer[5] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpBuffer), NULL}, + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (Buffer.Length), "Length"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Buffer.Pointer), "Pointer"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Buffer.Node), "Parent Node"}, + {ACPI_EXD_BUFFER, 0, NULL} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpPackage[5] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpPackage), NULL}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Package.Flags), "Flags"}, + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (Package.Count), "Elements"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Package.Elements), "Element List"}, + {ACPI_EXD_PACKAGE, 0, NULL} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpDevice[4] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpDevice), NULL}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Device.Handler), "Handler"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Device.SystemNotify), "System Notify"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Device.DeviceNotify), "Device Notify"} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpEvent[2] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpEvent), NULL}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Event.OsSemaphore), "OsSemaphore"} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpMethod[9] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpMethod), NULL}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Method.MethodFlags), "Method Flags"}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Method.ParamCount), "Parameter Count"}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Method.SyncLevel), "Sync Level"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Method.Mutex), "Mutex"}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Method.OwnerId), "Owner Id"}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Method.ThreadCount), "Thread Count"}, + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (Method.AmlLength), "Aml Length"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Method.AmlStart), "Aml Start"} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpMutex[5] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpMutex), NULL}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Mutex.SyncLevel), "Sync Level"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Mutex.OwnerThread), "Owner Thread"}, + {ACPI_EXD_UINT16, ACPI_EXD_OFFSET (Mutex.AcquisitionDepth), "Acquire Depth"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Mutex.OsMutex), "OsMutex"} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpRegion[7] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpRegion), NULL}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Region.SpaceId), "Space Id"}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Region.Flags), "Flags"}, + {ACPI_EXD_ADDRESS, ACPI_EXD_OFFSET (Region.Address), "Address"}, + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (Region.Length), "Length"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Region.Handler), "Handler"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Region.Next), "Next"} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpPower[5] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpPower), NULL}, + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (PowerResource.SystemLevel), "System Level"}, + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (PowerResource.ResourceOrder), "Resource Order"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (PowerResource.SystemNotify), "System Notify"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (PowerResource.DeviceNotify), "Device Notify"} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpProcessor[7] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpProcessor), NULL}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Processor.ProcId), "Processor ID"}, + {ACPI_EXD_UINT8 , ACPI_EXD_OFFSET (Processor.Length), "Length"}, + {ACPI_EXD_ADDRESS, ACPI_EXD_OFFSET (Processor.Address), "Address"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Processor.SystemNotify), "System Notify"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Processor.DeviceNotify), "Device Notify"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Processor.Handler), "Handler"} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpThermal[4] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpThermal), NULL}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (ThermalZone.SystemNotify), "System Notify"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (ThermalZone.DeviceNotify), "Device Notify"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (ThermalZone.Handler), "Handler"} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpBufferField[3] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpBufferField), NULL}, + {ACPI_EXD_FIELD, 0, NULL}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (BufferField.BufferObj), "Buffer Object"} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpRegionField[3] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpRegionField), NULL}, + {ACPI_EXD_FIELD, 0, NULL}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Field.RegionObj), "Region Object"} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpBankField[5] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpBankField), NULL}, + {ACPI_EXD_FIELD, 0, NULL}, + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (BankField.Value), "Value"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (BankField.RegionObj), "Region Object"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (BankField.BankObj), "Bank Object"} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpIndexField[5] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpBankField), NULL}, + {ACPI_EXD_FIELD, 0, NULL}, + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (IndexField.Value), "Value"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (IndexField.IndexObj), "Index Object"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (IndexField.DataObj), "Data Object"} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpReference[8] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpReference), NULL}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Reference.Class), "Class"}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Reference.TargetType), "Target Type"}, + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (Reference.Value), "Value"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Reference.Object), "Object Desc"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Reference.Node), "Node"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Reference.Where), "Where"}, + {ACPI_EXD_REFERENCE,0, NULL} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpAddressHandler[6] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpAddressHandler), NULL}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (AddressSpace.SpaceId), "Space Id"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (AddressSpace.Next), "Next"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (AddressSpace.RegionList), "Region List"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (AddressSpace.Node), "Node"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (AddressSpace.Context), "Context"} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpNotify[3] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpNotify), NULL}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Notify.Node), "Node"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (Notify.Context), "Context"} +}; + + +/* Miscellaneous tables */ + +static ACPI_EXDUMP_INFO AcpiExDumpCommon[4] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpCommon), NULL}, + {ACPI_EXD_TYPE , 0, NULL}, + {ACPI_EXD_UINT16, ACPI_EXD_OFFSET (Common.ReferenceCount), "Reference Count"}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (Common.Flags), "Flags"} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpFieldCommon[7] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpFieldCommon), NULL}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (CommonField.FieldFlags), "Field Flags"}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (CommonField.AccessByteWidth), "Access Byte Width"}, + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (CommonField.BitLength), "Bit Length"}, + {ACPI_EXD_UINT8, ACPI_EXD_OFFSET (CommonField.StartFieldBitOffset),"Field Bit Offset"}, + {ACPI_EXD_UINT32, ACPI_EXD_OFFSET (CommonField.BaseByteOffset), "Base Byte Offset"}, + {ACPI_EXD_POINTER, ACPI_EXD_OFFSET (CommonField.Node), "Parent Node"} +}; + +static ACPI_EXDUMP_INFO AcpiExDumpNode[5] = +{ + {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE (AcpiExDumpNode), NULL}, + {ACPI_EXD_UINT8, ACPI_EXD_NSOFFSET (Flags), "Flags"}, + {ACPI_EXD_UINT8, ACPI_EXD_NSOFFSET (OwnerId), "Owner Id"}, + {ACPI_EXD_POINTER, ACPI_EXD_NSOFFSET (Child), "Child List"}, + {ACPI_EXD_POINTER, ACPI_EXD_NSOFFSET (Peer), "Next Peer"} +}; + + +/* Dispatch table, indexed by object type */ + +static ACPI_EXDUMP_INFO *AcpiExDumpInfo[] = +{ + NULL, + AcpiExDumpInteger, + AcpiExDumpString, + AcpiExDumpBuffer, + AcpiExDumpPackage, + NULL, + AcpiExDumpDevice, + AcpiExDumpEvent, + AcpiExDumpMethod, + AcpiExDumpMutex, + AcpiExDumpRegion, + AcpiExDumpPower, + AcpiExDumpProcessor, + AcpiExDumpThermal, + AcpiExDumpBufferField, + NULL, + NULL, + AcpiExDumpRegionField, + AcpiExDumpBankField, + AcpiExDumpIndexField, + AcpiExDumpReference, + NULL, + NULL, + AcpiExDumpNotify, + AcpiExDumpAddressHandler, + NULL, + NULL, + NULL +}; + + +/******************************************************************************* + * + * FUNCTION: AcpiExDumpObject + * + * PARAMETERS: ObjDesc - Descriptor to dump + * Info - Info table corresponding to this object + * type + * + * RETURN: None + * + * DESCRIPTION: Walk the info table for this object + * + ******************************************************************************/ + +static void +AcpiExDumpObject ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_EXDUMP_INFO *Info) +{ + UINT8 *Target; + char *Name; + UINT8 Count; + + + if (!Info) + { + AcpiOsPrintf ( + "ExDumpObject: Display not implemented for object type %s\n", + AcpiUtGetObjectTypeName (ObjDesc)); + return; + } + + /* First table entry must contain the table length (# of table entries) */ + + Count = Info->Offset; + + while (Count) + { + Target = ACPI_ADD_PTR (UINT8, ObjDesc, Info->Offset); + Name = Info->Name; + + switch (Info->Opcode) + { + case ACPI_EXD_INIT: + break; + + case ACPI_EXD_TYPE: + + AcpiExOutString ("Type", AcpiUtGetObjectTypeName (ObjDesc)); + break; + + case ACPI_EXD_UINT8: + + AcpiOsPrintf ("%20s : %2.2X\n", Name, *Target); + break; + + case ACPI_EXD_UINT16: + + AcpiOsPrintf ("%20s : %4.4X\n", Name, ACPI_GET16 (Target)); + break; + + case ACPI_EXD_UINT32: + + AcpiOsPrintf ("%20s : %8.8X\n", Name, ACPI_GET32 (Target)); + break; + + case ACPI_EXD_UINT64: + + AcpiOsPrintf ("%20s : %8.8X%8.8X\n", "Value", + ACPI_FORMAT_UINT64 (ACPI_GET64 (Target))); + break; + + case ACPI_EXD_POINTER: + case ACPI_EXD_ADDRESS: + + AcpiExOutPointer (Name, *ACPI_CAST_PTR (void *, Target)); + break; + + case ACPI_EXD_STRING: + + AcpiUtPrintString (ObjDesc->String.Pointer, ACPI_UINT8_MAX); + AcpiOsPrintf ("\n"); + break; + + case ACPI_EXD_BUFFER: + + ACPI_DUMP_BUFFER (ObjDesc->Buffer.Pointer, ObjDesc->Buffer.Length); + break; + + case ACPI_EXD_PACKAGE: + + /* Dump the package contents */ + + AcpiOsPrintf ("\nPackage Contents:\n"); + AcpiExDumpPackageObj (ObjDesc, 0, 0); + break; + + case ACPI_EXD_FIELD: + + AcpiExDumpObject (ObjDesc, AcpiExDumpFieldCommon); + break; + + case ACPI_EXD_REFERENCE: + + AcpiExOutString ("Class Name", + ACPI_CAST_PTR (char, AcpiUtGetReferenceName (ObjDesc))); + AcpiExDumpReferenceObj (ObjDesc); + break; + + default: + + AcpiOsPrintf ("**** Invalid table opcode [%X] ****\n", + Info->Opcode); + return; + } + + Info++; + Count--; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExDumpOperand + * + * PARAMETERS: *ObjDesc - Pointer to entry to be dumped + * Depth - Current nesting depth + * + * RETURN: None + * + * DESCRIPTION: Dump an operand object + * + ******************************************************************************/ + +void +AcpiExDumpOperand ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 Depth) +{ + UINT32 Length; + UINT32 Index; + + + ACPI_FUNCTION_NAME (ExDumpOperand) + + + if (!((ACPI_LV_EXEC & AcpiDbgLevel) && (_COMPONENT & AcpiDbgLayer))) + { + return; + } + + if (!ObjDesc) + { + /* This could be a null element of a package */ + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Null Object Descriptor\n")); + return; + } + + if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_NAMED) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p Namespace Node: ", ObjDesc)); + ACPI_DUMP_ENTRY (ObjDesc, ACPI_LV_EXEC); + return; + } + + if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "%p is not a node or operand object: [%s]\n", + ObjDesc, AcpiUtGetDescriptorName (ObjDesc))); + ACPI_DUMP_BUFFER (ObjDesc, sizeof (ACPI_OPERAND_OBJECT)); + return; + } + + /* ObjDesc is a valid object */ + + if (Depth > 0) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%*s[%u] %p ", + Depth, " ", Depth, ObjDesc)); + } + else + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%p ", ObjDesc)); + } + + /* Decode object type */ + + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_LOCAL_REFERENCE: + + AcpiOsPrintf ("Reference: [%s] ", AcpiUtGetReferenceName (ObjDesc)); + + switch (ObjDesc->Reference.Class) + { + case ACPI_REFCLASS_DEBUG: + + AcpiOsPrintf ("\n"); + break; + + + case ACPI_REFCLASS_INDEX: + + AcpiOsPrintf ("%p\n", ObjDesc->Reference.Object); + break; + + + case ACPI_REFCLASS_TABLE: + + AcpiOsPrintf ("Table Index %X\n", ObjDesc->Reference.Value); + break; + + + case ACPI_REFCLASS_REFOF: + + AcpiOsPrintf ("%p [%s]\n", ObjDesc->Reference.Object, + AcpiUtGetTypeName (((ACPI_OPERAND_OBJECT *) + ObjDesc->Reference.Object)->Common.Type)); + break; + + + case ACPI_REFCLASS_NAME: + + AcpiOsPrintf ("- [%4.4s]\n", ObjDesc->Reference.Node->Name.Ascii); + break; + + + case ACPI_REFCLASS_ARG: + case ACPI_REFCLASS_LOCAL: + + AcpiOsPrintf ("%X\n", ObjDesc->Reference.Value); + break; + + + default: /* Unknown reference class */ + + AcpiOsPrintf ("%2.2X\n", ObjDesc->Reference.Class); + break; + } + break; + + + case ACPI_TYPE_BUFFER: + + AcpiOsPrintf ("Buffer length %.2X @ %p\n", + ObjDesc->Buffer.Length, ObjDesc->Buffer.Pointer); + + /* Debug only -- dump the buffer contents */ + + if (ObjDesc->Buffer.Pointer) + { + Length = ObjDesc->Buffer.Length; + if (Length > 128) + { + Length = 128; + } + + AcpiOsPrintf ("Buffer Contents: (displaying length 0x%.2X)\n", + Length); + ACPI_DUMP_BUFFER (ObjDesc->Buffer.Pointer, Length); + } + break; + + + case ACPI_TYPE_INTEGER: + + AcpiOsPrintf ("Integer %8.8X%8.8X\n", + ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value)); + break; + + + case ACPI_TYPE_PACKAGE: + + AcpiOsPrintf ("Package [Len %X] ElementArray %p\n", + ObjDesc->Package.Count, ObjDesc->Package.Elements); + + /* + * If elements exist, package element pointer is valid, + * and debug_level exceeds 1, dump package's elements. + */ + if (ObjDesc->Package.Count && + ObjDesc->Package.Elements && + AcpiDbgLevel > 1) + { + for (Index = 0; Index < ObjDesc->Package.Count; Index++) + { + AcpiExDumpOperand (ObjDesc->Package.Elements[Index], Depth+1); + } + } + break; + + + case ACPI_TYPE_REGION: + + AcpiOsPrintf ("Region %s (%X)", + AcpiUtGetRegionName (ObjDesc->Region.SpaceId), + ObjDesc->Region.SpaceId); + + /* + * If the address and length have not been evaluated, + * don't print them. + */ + if (!(ObjDesc->Region.Flags & AOPOBJ_DATA_VALID)) + { + AcpiOsPrintf ("\n"); + } + else + { + AcpiOsPrintf (" base %8.8X%8.8X Length %X\n", + ACPI_FORMAT_NATIVE_UINT (ObjDesc->Region.Address), + ObjDesc->Region.Length); + } + break; + + + case ACPI_TYPE_STRING: + + AcpiOsPrintf ("String length %X @ %p ", + ObjDesc->String.Length, + ObjDesc->String.Pointer); + + AcpiUtPrintString (ObjDesc->String.Pointer, ACPI_UINT8_MAX); + AcpiOsPrintf ("\n"); + break; + + + case ACPI_TYPE_LOCAL_BANK_FIELD: + + AcpiOsPrintf ("BankField\n"); + break; + + + case ACPI_TYPE_LOCAL_REGION_FIELD: + + AcpiOsPrintf ("RegionField: Bits=%X AccWidth=%X Lock=%X Update=%X at " + "byte=%X bit=%X of below:\n", + ObjDesc->Field.BitLength, + ObjDesc->Field.AccessByteWidth, + ObjDesc->Field.FieldFlags & AML_FIELD_LOCK_RULE_MASK, + ObjDesc->Field.FieldFlags & AML_FIELD_UPDATE_RULE_MASK, + ObjDesc->Field.BaseByteOffset, + ObjDesc->Field.StartFieldBitOffset); + + AcpiExDumpOperand (ObjDesc->Field.RegionObj, Depth+1); + break; + + + case ACPI_TYPE_LOCAL_INDEX_FIELD: + + AcpiOsPrintf ("IndexField\n"); + break; + + + case ACPI_TYPE_BUFFER_FIELD: + + AcpiOsPrintf ("BufferField: %X bits at byte %X bit %X of\n", + ObjDesc->BufferField.BitLength, + ObjDesc->BufferField.BaseByteOffset, + ObjDesc->BufferField.StartFieldBitOffset); + + if (!ObjDesc->BufferField.BufferObj) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "*NULL*\n")); + } + else if ((ObjDesc->BufferField.BufferObj)->Common.Type != + ACPI_TYPE_BUFFER) + { + AcpiOsPrintf ("*not a Buffer*\n"); + } + else + { + AcpiExDumpOperand (ObjDesc->BufferField.BufferObj, Depth+1); + } + break; + + + case ACPI_TYPE_EVENT: + + AcpiOsPrintf ("Event\n"); + break; + + + case ACPI_TYPE_METHOD: + + AcpiOsPrintf ("Method(%X) @ %p:%X\n", + ObjDesc->Method.ParamCount, + ObjDesc->Method.AmlStart, + ObjDesc->Method.AmlLength); + break; + + + case ACPI_TYPE_MUTEX: + + AcpiOsPrintf ("Mutex\n"); + break; + + + case ACPI_TYPE_DEVICE: + + AcpiOsPrintf ("Device\n"); + break; + + + case ACPI_TYPE_POWER: + + AcpiOsPrintf ("Power\n"); + break; + + + case ACPI_TYPE_PROCESSOR: + + AcpiOsPrintf ("Processor\n"); + break; + + + case ACPI_TYPE_THERMAL: + + AcpiOsPrintf ("Thermal\n"); + break; + + + default: + /* Unknown Type */ + + AcpiOsPrintf ("Unknown Type %X\n", ObjDesc->Common.Type); + break; + } + + return; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExDumpOperands + * + * PARAMETERS: Operands - A list of Operand objects + * OpcodeName - AML opcode name + * NumOperands - Operand count for this opcode + * + * DESCRIPTION: Dump the operands associated with the opcode + * + ******************************************************************************/ + +void +AcpiExDumpOperands ( + ACPI_OPERAND_OBJECT **Operands, + const char *OpcodeName, + UINT32 NumOperands) +{ + ACPI_FUNCTION_NAME (ExDumpOperands); + + + if (!OpcodeName) + { + OpcodeName = "UNKNOWN"; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "**** Start operand dump for opcode [%s], %d operands\n", + OpcodeName, NumOperands)); + + if (NumOperands == 0) + { + NumOperands = 1; + } + + /* Dump the individual operands */ + + while (NumOperands) + { + AcpiExDumpOperand (*Operands, 0); + Operands++; + NumOperands--; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "**** End operand dump for [%s]\n", OpcodeName)); + return; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExOut* functions + * + * PARAMETERS: Title - Descriptive text + * Value - Value to be displayed + * + * DESCRIPTION: Object dump output formatting functions. These functions + * reduce the number of format strings required and keeps them + * all in one place for easy modification. + * + ******************************************************************************/ + +static void +AcpiExOutString ( + char *Title, + char *Value) +{ + AcpiOsPrintf ("%20s : %s\n", Title, Value); +} + +static void +AcpiExOutPointer ( + char *Title, + void *Value) +{ + AcpiOsPrintf ("%20s : %p\n", Title, Value); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExDumpNamespaceNode + * + * PARAMETERS: Node - Descriptor to dump + * Flags - Force display if TRUE + * + * DESCRIPTION: Dumps the members of the given.Node + * + ******************************************************************************/ + +void +AcpiExDumpNamespaceNode ( + ACPI_NAMESPACE_NODE *Node, + UINT32 Flags) +{ + + ACPI_FUNCTION_ENTRY (); + + + if (!Flags) + { + if (!((ACPI_LV_OBJECTS & AcpiDbgLevel) && (_COMPONENT & AcpiDbgLayer))) + { + return; + } + } + + AcpiOsPrintf ("%20s : %4.4s\n", "Name", AcpiUtGetNodeName (Node)); + AcpiExOutString ("Type", AcpiUtGetTypeName (Node->Type)); + AcpiExOutPointer ("Attached Object", AcpiNsGetAttachedObject (Node)); + AcpiExOutPointer ("Parent", AcpiNsGetParentNode (Node)); + + AcpiExDumpObject (ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Node), + AcpiExDumpNode); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExDumpReferenceObj + * + * PARAMETERS: Object - Descriptor to dump + * + * DESCRIPTION: Dumps a reference object + * + ******************************************************************************/ + +static void +AcpiExDumpReferenceObj ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_BUFFER RetBuf; + ACPI_STATUS Status; + + + RetBuf.Length = ACPI_ALLOCATE_LOCAL_BUFFER; + + if (ObjDesc->Reference.Class == ACPI_REFCLASS_NAME) + { + AcpiOsPrintf (" %p ", ObjDesc->Reference.Node); + + Status = AcpiNsHandleToPathname (ObjDesc->Reference.Node, &RetBuf); + if (ACPI_FAILURE (Status)) + { + AcpiOsPrintf (" Could not convert name to pathname\n"); + } + else + { + AcpiOsPrintf ("%s\n", (char *) RetBuf.Pointer); + ACPI_FREE (RetBuf.Pointer); + } + } + else if (ObjDesc->Reference.Object) + { + if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_OPERAND) + { + AcpiOsPrintf (" Target: %p", ObjDesc->Reference.Object); + if (ObjDesc->Reference.Class == ACPI_REFCLASS_TABLE) + { + AcpiOsPrintf (" Table Index: %X\n", ObjDesc->Reference.Value); + } + else + { + AcpiOsPrintf (" Target: %p [%s]\n", ObjDesc->Reference.Object, + AcpiUtGetTypeName (((ACPI_OPERAND_OBJECT *) + ObjDesc->Reference.Object)->Common.Type)); + } + } + else + { + AcpiOsPrintf (" Target: %p\n", ObjDesc->Reference.Object); + } + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExDumpPackageObj + * + * PARAMETERS: ObjDesc - Descriptor to dump + * Level - Indentation Level + * Index - Package index for this object + * + * DESCRIPTION: Dumps the elements of the package + * + ******************************************************************************/ + +static void +AcpiExDumpPackageObj ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 Level, + UINT32 Index) +{ + UINT32 i; + + + /* Indentation and index output */ + + if (Level > 0) + { + for (i = 0; i < Level; i++) + { + AcpiOsPrintf (" "); + } + + AcpiOsPrintf ("[%.2d] ", Index); + } + + AcpiOsPrintf ("%p ", ObjDesc); + + /* Null package elements are allowed */ + + if (!ObjDesc) + { + AcpiOsPrintf ("[Null Object]\n"); + return; + } + + /* Packages may only contain a few object types */ + + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_INTEGER: + + AcpiOsPrintf ("[Integer] = %8.8X%8.8X\n", + ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value)); + break; + + + case ACPI_TYPE_STRING: + + AcpiOsPrintf ("[String] Value: "); + for (i = 0; i < ObjDesc->String.Length; i++) + { + AcpiOsPrintf ("%c", ObjDesc->String.Pointer[i]); + } + AcpiOsPrintf ("\n"); + break; + + + case ACPI_TYPE_BUFFER: + + AcpiOsPrintf ("[Buffer] Length %.2X = ", ObjDesc->Buffer.Length); + if (ObjDesc->Buffer.Length) + { + AcpiUtDumpBuffer (ACPI_CAST_PTR (UINT8, ObjDesc->Buffer.Pointer), + ObjDesc->Buffer.Length, DB_DWORD_DISPLAY, _COMPONENT); + } + else + { + AcpiOsPrintf ("\n"); + } + break; + + + case ACPI_TYPE_PACKAGE: + + AcpiOsPrintf ("[Package] Contains %d Elements:\n", + ObjDesc->Package.Count); + + for (i = 0; i < ObjDesc->Package.Count; i++) + { + AcpiExDumpPackageObj (ObjDesc->Package.Elements[i], Level+1, i); + } + break; + + + case ACPI_TYPE_LOCAL_REFERENCE: + + AcpiOsPrintf ("[Object Reference] Type [%s] %2.2X", + AcpiUtGetReferenceName (ObjDesc), + ObjDesc->Reference.Class); + AcpiExDumpReferenceObj (ObjDesc); + break; + + + default: + + AcpiOsPrintf ("[Unknown Type] %X\n", ObjDesc->Common.Type); + break; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExDumpObjectDescriptor + * + * PARAMETERS: ObjDesc - Descriptor to dump + * Flags - Force display if TRUE + * + * DESCRIPTION: Dumps the members of the object descriptor given. + * + ******************************************************************************/ + +void +AcpiExDumpObjectDescriptor ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 Flags) +{ + ACPI_FUNCTION_TRACE (ExDumpObjectDescriptor); + + + if (!ObjDesc) + { + return_VOID; + } + + if (!Flags) + { + if (!((ACPI_LV_OBJECTS & AcpiDbgLevel) && (_COMPONENT & AcpiDbgLayer))) + { + return_VOID; + } + } + + if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_NAMED) + { + AcpiExDumpNamespaceNode ((ACPI_NAMESPACE_NODE *) ObjDesc, Flags); + + AcpiOsPrintf ("\nAttached Object (%p):\n", + ((ACPI_NAMESPACE_NODE *) ObjDesc)->Object); + + AcpiExDumpObjectDescriptor ( + ((ACPI_NAMESPACE_NODE *) ObjDesc)->Object, Flags); + return_VOID; + } + + if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND) + { + AcpiOsPrintf ( + "ExDumpObjectDescriptor: %p is not an ACPI operand object: [%s]\n", + ObjDesc, AcpiUtGetDescriptorName (ObjDesc)); + return_VOID; + } + + if (ObjDesc->Common.Type > ACPI_TYPE_NS_NODE_MAX) + { + return_VOID; + } + + /* Common Fields */ + + AcpiExDumpObject (ObjDesc, AcpiExDumpCommon); + + /* Object-specific fields */ + + AcpiExDumpObject (ObjDesc, AcpiExDumpInfo[ObjDesc->Common.Type]); + return_VOID; +} + +#endif + diff --git a/reactos/drivers/bus/acpi/acpica/executer/exfield.c b/reactos/drivers/bus/acpi/acpica/executer/exfield.c new file mode 100644 index 00000000000..503e8e6b370 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/executer/exfield.c @@ -0,0 +1,466 @@ +/****************************************************************************** + * + * Module Name: exfield - ACPI AML (p-code) execution - field manipulation + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __EXFIELD_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acdispat.h" +#include "acinterp.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exfield") + + +/******************************************************************************* + * + * FUNCTION: AcpiExReadDataFromField + * + * PARAMETERS: WalkState - Current execution state + * ObjDesc - The named field + * RetBufferDesc - Where the return data object is stored + * + * RETURN: Status + * + * DESCRIPTION: Read from a named field. Returns either an Integer or a + * Buffer, depending on the size of the field. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExReadDataFromField ( + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT **RetBufferDesc) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *BufferDesc; + ACPI_SIZE Length; + void *Buffer; + UINT32 Function; + + + ACPI_FUNCTION_TRACE_PTR (ExReadDataFromField, ObjDesc); + + + /* Parameter validation */ + + if (!ObjDesc) + { + return_ACPI_STATUS (AE_AML_NO_OPERAND); + } + if (!RetBufferDesc) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + if (ObjDesc->Common.Type == ACPI_TYPE_BUFFER_FIELD) + { + /* + * If the BufferField arguments have not been previously evaluated, + * evaluate them now and save the results. + */ + if (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)) + { + Status = AcpiDsGetBufferFieldArguments (ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + } + else if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REGION_FIELD) && + (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_SMBUS || + ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_IPMI)) + { + /* + * 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 + */ + 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); + } + + /* Lock entire transaction if requested */ + + AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags); + + /* Call the region handler for the read */ + + Status = AcpiExAccessRegion (ObjDesc, 0, + ACPI_CAST_PTR (ACPI_INTEGER, BufferDesc->Buffer.Pointer), + Function); + AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags); + goto Exit; + } + + /* + * Allocate a buffer for the contents of the field. + * + * If the field is larger than the size of an ACPI_INTEGER, create + * a BUFFER to hold it. Otherwise, use an INTEGER. This allows + * the use of arithmetic operators on the returned value if the + * field size is equal or smaller than an Integer. + * + * Note: Field.length is in bits. + */ + Length = (ACPI_SIZE) ACPI_ROUND_BITS_UP_TO_BYTES (ObjDesc->Field.BitLength); + if (Length > AcpiGbl_IntegerByteWidth) + { + /* Field is too large for an Integer, create a Buffer instead */ + + BufferDesc = AcpiUtCreateBufferObject (Length); + if (!BufferDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + Buffer = BufferDesc->Buffer.Pointer; + } + else + { + /* Field will fit within an Integer (normal case) */ + + BufferDesc = AcpiUtCreateIntegerObject ((UINT64) 0); + if (!BufferDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Length = AcpiGbl_IntegerByteWidth; + Buffer = &BufferDesc->Integer.Value; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "FieldRead [TO]: Obj %p, Type %X, Buf %p, ByteLen %X\n", + ObjDesc, ObjDesc->Common.Type, Buffer, (UINT32) Length)); + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "FieldRead [FROM]: BitLen %X, BitOff %X, ByteOff %X\n", + ObjDesc->CommonField.BitLength, + ObjDesc->CommonField.StartFieldBitOffset, + ObjDesc->CommonField.BaseByteOffset)); + + /* Lock entire transaction if requested */ + + AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags); + + /* Read from the field */ + + Status = AcpiExExtractFromField (ObjDesc, Buffer, (UINT32) Length); + AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags); + + +Exit: + if (ACPI_FAILURE (Status)) + { + AcpiUtRemoveReference (BufferDesc); + } + else + { + *RetBufferDesc = BufferDesc; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExWriteDataToField + * + * PARAMETERS: SourceDesc - Contains data to write + * ObjDesc - The named field + * ResultDesc - Where the return value is returned, if any + * + * RETURN: Status + * + * DESCRIPTION: Write to a named field + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExWriteDataToField ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT **ResultDesc) +{ + ACPI_STATUS Status; + UINT32 Length; + void *Buffer; + ACPI_OPERAND_OBJECT *BufferDesc; + UINT32 Function; + + + ACPI_FUNCTION_TRACE_PTR (ExWriteDataToField, ObjDesc); + + + /* Parameter validation */ + + if (!SourceDesc || !ObjDesc) + { + return_ACPI_STATUS (AE_AML_NO_OPERAND); + } + + if (ObjDesc->Common.Type == ACPI_TYPE_BUFFER_FIELD) + { + /* + * If the BufferField arguments have not been previously evaluated, + * evaluate them now and save the results. + */ + if (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)) + { + Status = AcpiDsGetBufferFieldArguments (ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + } + else if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REGION_FIELD) && + (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_SMBUS || + ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_IPMI)) + { + /* + * 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. + * + * Note: SMBus protocol type is passed in upper 16-bits of Function + */ + if (SourceDesc->Common.Type != ACPI_TYPE_BUFFER) + { + ACPI_ERROR ((AE_INFO, + "SMBus or IPMI write requires Buffer, found type %s", + AcpiUtGetObjectTypeName (SourceDesc))); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + if (ObjDesc->Field.RegionObj->Region.SpaceId == ACPI_ADR_SPACE_SMBUS) + { + Length = ACPI_SMBUS_BUFFER_SIZE; + Function = ACPI_WRITE | (ObjDesc->Field.Attribute << 16); + } + else /* IPMI */ + { + Length = ACPI_IPMI_BUFFER_SIZE; + Function = ACPI_WRITE; + } + + if (SourceDesc->Buffer.Length < Length) + { + ACPI_ERROR ((AE_INFO, + "SMBus or IPMI write requires Buffer of length %X, found length %X", + Length, SourceDesc->Buffer.Length)); + + return_ACPI_STATUS (AE_AML_BUFFER_LIMIT); + } + + /* Create the bi-directional buffer */ + + BufferDesc = AcpiUtCreateBufferObject (Length); + if (!BufferDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Buffer = BufferDesc->Buffer.Pointer; + ACPI_MEMCPY (Buffer, SourceDesc->Buffer.Pointer, Length); + + /* Lock entire transaction if requested */ + + AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags); + + /* + * Perform the write (returns status and perhaps data in the + * same buffer) + */ + Status = AcpiExAccessRegion (ObjDesc, 0, + (ACPI_INTEGER *) Buffer, Function); + AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags); + + *ResultDesc = BufferDesc; + return_ACPI_STATUS (Status); + } + + /* Get a pointer to the data to be written */ + + switch (SourceDesc->Common.Type) + { + case ACPI_TYPE_INTEGER: + Buffer = &SourceDesc->Integer.Value; + Length = sizeof (SourceDesc->Integer.Value); + break; + + case ACPI_TYPE_BUFFER: + Buffer = SourceDesc->Buffer.Pointer; + Length = SourceDesc->Buffer.Length; + break; + + case ACPI_TYPE_STRING: + Buffer = SourceDesc->String.Pointer; + Length = SourceDesc->String.Length; + break; + + default: + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "FieldWrite [FROM]: Obj %p (%s:%X), Buf %p, ByteLen %X\n", + SourceDesc, AcpiUtGetTypeName (SourceDesc->Common.Type), + SourceDesc->Common.Type, Buffer, Length)); + + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "FieldWrite [TO]: Obj %p (%s:%X), BitLen %X, BitOff %X, ByteOff %X\n", + ObjDesc, AcpiUtGetTypeName (ObjDesc->Common.Type), + ObjDesc->Common.Type, + ObjDesc->CommonField.BitLength, + ObjDesc->CommonField.StartFieldBitOffset, + ObjDesc->CommonField.BaseByteOffset)); + + /* Lock entire transaction if requested */ + + AcpiExAcquireGlobalLock (ObjDesc->CommonField.FieldFlags); + + /* Write to the field */ + + Status = AcpiExInsertIntoField (ObjDesc, Buffer, Length); + AcpiExReleaseGlobalLock (ObjDesc->CommonField.FieldFlags); + + return_ACPI_STATUS (Status); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/executer/exfldio.c b/reactos/drivers/bus/acpi/acpica/executer/exfldio.c new file mode 100644 index 00000000000..37a67865517 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/executer/exfldio.c @@ -0,0 +1,1081 @@ +/****************************************************************************** + * + * Module Name: exfldio - Aml Field I/O + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __EXFLDIO_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acevents.h" +#include "acdispat.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exfldio") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiExFieldDatumIo ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 FieldDatumByteOffset, + ACPI_INTEGER *Value, + UINT32 ReadWrite); + +static BOOLEAN +AcpiExRegisterOverflow ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_INTEGER Value); + +static ACPI_STATUS +AcpiExSetupRegion ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 FieldDatumByteOffset); + + +/******************************************************************************* + * + * FUNCTION: AcpiExSetupRegion + * + * PARAMETERS: ObjDesc - Field to be read or written + * FieldDatumByteOffset - Byte offset of this datum within the + * parent field + * + * RETURN: Status + * + * DESCRIPTION: Common processing for AcpiExExtractFromField and + * AcpiExInsertIntoField. Initialize the Region if necessary and + * validate the request. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiExSetupRegion ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 FieldDatumByteOffset) +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT *RgnDesc; + + + ACPI_FUNCTION_TRACE_U32 (ExSetupRegion, FieldDatumByteOffset); + + + RgnDesc = ObjDesc->CommonField.RegionObj; + + /* We must have a valid region */ + + if (RgnDesc->Common.Type != ACPI_TYPE_REGION) + { + ACPI_ERROR ((AE_INFO, "Needed Region, found type %X (%s)", + RgnDesc->Common.Type, + AcpiUtGetObjectTypeName (RgnDesc))); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* + * If the Region Address and Length have not been previously evaluated, + * evaluate them now and save the results. + */ + if (!(RgnDesc->Common.Flags & AOPOBJ_DATA_VALID)) + { + Status = AcpiDsGetRegionArguments (RgnDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* + * 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 || + RgnDesc->Region.SpaceId == ACPI_ADR_SPACE_IPMI) + { + /* SMBus or IPMI has a non-linear address space */ + + return_ACPI_STATUS (AE_OK); + } + +#ifdef ACPI_UNDER_DEVELOPMENT + /* + * If the Field access is AnyAcc, we can now compute the optimal + * access (because we know know the length of the parent region) + */ + if (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)) + { + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } +#endif + + /* + * Validate the request. The entire request from the byte offset for a + * length of one field datum (access width) must fit within the region. + * (Region length is specified in bytes) + */ + if (RgnDesc->Region.Length < + (ObjDesc->CommonField.BaseByteOffset + + FieldDatumByteOffset + + ObjDesc->CommonField.AccessByteWidth)) + { + if (AcpiGbl_EnableInterpreterSlack) + { + /* + * Slack mode only: We will go ahead and allow access to this + * field if it is within the region length rounded up to the next + * access width boundary. ACPI_SIZE cast for 64-bit compile. + */ + if (ACPI_ROUND_UP (RgnDesc->Region.Length, + ObjDesc->CommonField.AccessByteWidth) >= + ((ACPI_SIZE) ObjDesc->CommonField.BaseByteOffset + + ObjDesc->CommonField.AccessByteWidth + + FieldDatumByteOffset)) + { + return_ACPI_STATUS (AE_OK); + } + } + + if (RgnDesc->Region.Length < ObjDesc->CommonField.AccessByteWidth) + { + /* + * This is the case where the AccessType (AccWord, etc.) is wider + * than the region itself. For example, a region of length one + * byte, and a field with Dword access specified. + */ + ACPI_ERROR ((AE_INFO, + "Field [%4.4s] access width (%d bytes) too large for region [%4.4s] (length %X)", + AcpiUtGetNodeName (ObjDesc->CommonField.Node), + ObjDesc->CommonField.AccessByteWidth, + AcpiUtGetNodeName (RgnDesc->Region.Node), + RgnDesc->Region.Length)); + } + + /* + * Offset rounded up to next multiple of field width + * exceeds region length, indicate an error + */ + ACPI_ERROR ((AE_INFO, + "Field [%4.4s] Base+Offset+Width %X+%X+%X is beyond end of region [%4.4s] (length %X)", + AcpiUtGetNodeName (ObjDesc->CommonField.Node), + ObjDesc->CommonField.BaseByteOffset, + FieldDatumByteOffset, ObjDesc->CommonField.AccessByteWidth, + AcpiUtGetNodeName (RgnDesc->Region.Node), + RgnDesc->Region.Length)); + + return_ACPI_STATUS (AE_AML_REGION_LIMIT); + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExAccessRegion + * + * PARAMETERS: ObjDesc - Field to be read + * FieldDatumByteOffset - Byte offset of this datum within the + * parent field + * Value - Where to store value (must at least + * the size of ACPI_INTEGER) + * Function - Read or Write flag plus other region- + * dependent flags + * + * RETURN: Status + * + * DESCRIPTION: Read or Write a single field datum to an Operation Region. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExAccessRegion ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 FieldDatumByteOffset, + ACPI_INTEGER *Value, + UINT32 Function) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *RgnDesc; + UINT32 RegionOffset; + + + ACPI_FUNCTION_TRACE (ExAccessRegion); + + + /* + * Ensure that the region operands are fully evaluated and verify + * the validity of the request + */ + Status = AcpiExSetupRegion (ObjDesc, FieldDatumByteOffset); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * The physical address of this field datum is: + * + * 1) The base of the region, plus + * 2) The base offset of the field, plus + * 3) The current offset into the field + */ + RgnDesc = ObjDesc->CommonField.RegionObj; + RegionOffset = + ObjDesc->CommonField.BaseByteOffset + + FieldDatumByteOffset; + + if ((Function & ACPI_IO_MASK) == ACPI_READ) + { + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "[READ]")); + } + else + { + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "[WRITE]")); + } + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_BFIELD, + " Region [%s:%X], Width %X, ByteBase %X, Offset %X at %p\n", + AcpiUtGetRegionName (RgnDesc->Region.SpaceId), + RgnDesc->Region.SpaceId, + ObjDesc->CommonField.AccessByteWidth, + ObjDesc->CommonField.BaseByteOffset, + FieldDatumByteOffset, + ACPI_CAST_PTR (void, (RgnDesc->Region.Address + RegionOffset)))); + + /* Invoke the appropriate AddressSpace/OpRegion handler */ + + Status = AcpiEvAddressSpaceDispatch (RgnDesc, Function, RegionOffset, + ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth), Value); + + if (ACPI_FAILURE (Status)) + { + if (Status == AE_NOT_IMPLEMENTED) + { + ACPI_ERROR ((AE_INFO, + "Region %s(%X) 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", + AcpiUtGetRegionName (RgnDesc->Region.SpaceId), + RgnDesc->Region.SpaceId)); + } + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExRegisterOverflow + * + * PARAMETERS: ObjDesc - Register(Field) to be written + * Value - Value to be stored + * + * RETURN: TRUE if value overflows the field, FALSE otherwise + * + * DESCRIPTION: Check if a value is out of range of the field being written. + * Used to check if the values written to Index and Bank registers + * are out of range. Normally, the value is simply truncated + * to fit the field, but this case is most likely a serious + * coding error in the ASL. + * + ******************************************************************************/ + +static BOOLEAN +AcpiExRegisterOverflow ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_INTEGER Value) +{ + + if (ObjDesc->CommonField.BitLength >= ACPI_INTEGER_BIT_SIZE) + { + /* + * The field is large enough to hold the maximum integer, so we can + * never overflow it. + */ + return (FALSE); + } + + if (Value >= ((ACPI_INTEGER) 1 << ObjDesc->CommonField.BitLength)) + { + /* + * The Value is larger than the maximum value that can fit into + * the register. + */ + return (TRUE); + } + + /* The Value will fit into the field with no truncation */ + + return (FALSE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExFieldDatumIo + * + * PARAMETERS: ObjDesc - Field to be read + * FieldDatumByteOffset - Byte offset of this datum within the + * parent field + * Value - Where to store value (must be 64 bits) + * ReadWrite - Read or Write flag + * + * RETURN: Status + * + * DESCRIPTION: Read or Write a single datum of a field. The FieldType is + * demultiplexed here to handle the different types of fields + * (BufferField, RegionField, IndexField, BankField) + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiExFieldDatumIo ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 FieldDatumByteOffset, + ACPI_INTEGER *Value, + UINT32 ReadWrite) +{ + ACPI_STATUS Status; + ACPI_INTEGER LocalValue; + + + ACPI_FUNCTION_TRACE_U32 (ExFieldDatumIo, FieldDatumByteOffset); + + + if (ReadWrite == ACPI_READ) + { + if (!Value) + { + LocalValue = 0; + + /* To support reads without saving return value */ + Value = &LocalValue; + } + + /* Clear the entire return buffer first, [Very Important!] */ + + *Value = 0; + } + + /* + * The four types of fields are: + * + * BufferField - Read/write from/to a Buffer + * RegionField - Read/write from/to a Operation Region. + * BankField - Write to a Bank Register, then read/write from/to an + * OperationRegion + * IndexField - Write to an Index Register, then read/write from/to a + * Data Register + */ + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_BUFFER_FIELD: + /* + * If the BufferField arguments have not been previously evaluated, + * evaluate them now and save the results. + */ + if (!(ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)) + { + Status = AcpiDsGetBufferFieldArguments (ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + if (ReadWrite == ACPI_READ) + { + /* + * Copy the data from the source buffer. + * Length is the field width in bytes. + */ + ACPI_MEMCPY (Value, + (ObjDesc->BufferField.BufferObj)->Buffer.Pointer + + ObjDesc->BufferField.BaseByteOffset + + FieldDatumByteOffset, + ObjDesc->CommonField.AccessByteWidth); + } + else + { + /* + * Copy the data to the target buffer. + * Length is the field width in bytes. + */ + ACPI_MEMCPY ((ObjDesc->BufferField.BufferObj)->Buffer.Pointer + + ObjDesc->BufferField.BaseByteOffset + + FieldDatumByteOffset, + Value, ObjDesc->CommonField.AccessByteWidth); + } + + Status = AE_OK; + break; + + + case ACPI_TYPE_LOCAL_BANK_FIELD: + + /* + * Ensure that the BankValue is not beyond the capacity of + * the register + */ + if (AcpiExRegisterOverflow (ObjDesc->BankField.BankObj, + (ACPI_INTEGER) ObjDesc->BankField.Value)) + { + return_ACPI_STATUS (AE_AML_REGISTER_LIMIT); + } + + /* + * For BankFields, we must write the BankValue to the BankRegister + * (itself a RegionField) before we can access the data. + */ + Status = AcpiExInsertIntoField (ObjDesc->BankField.BankObj, + &ObjDesc->BankField.Value, + sizeof (ObjDesc->BankField.Value)); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Now that the Bank has been selected, fall through to the + * RegionField case and write the datum to the Operation Region + */ + + /*lint -fallthrough */ + + + case ACPI_TYPE_LOCAL_REGION_FIELD: + /* + * For simple RegionFields, we just directly access the owning + * Operation Region. + */ + Status = AcpiExAccessRegion (ObjDesc, FieldDatumByteOffset, Value, + ReadWrite); + break; + + + case ACPI_TYPE_LOCAL_INDEX_FIELD: + + + /* + * Ensure that the IndexValue is not beyond the capacity of + * the register + */ + if (AcpiExRegisterOverflow (ObjDesc->IndexField.IndexObj, + (ACPI_INTEGER) ObjDesc->IndexField.Value)) + { + return_ACPI_STATUS (AE_AML_REGISTER_LIMIT); + } + + /* Write the index value to the IndexRegister (itself a RegionField) */ + + FieldDatumByteOffset += ObjDesc->IndexField.Value; + + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "Write to Index Register: Value %8.8X\n", + FieldDatumByteOffset)); + + Status = AcpiExInsertIntoField (ObjDesc->IndexField.IndexObj, + &FieldDatumByteOffset, + sizeof (FieldDatumByteOffset)); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (ReadWrite == ACPI_READ) + { + /* Read the datum from the DataRegister */ + + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "Read from Data Register\n")); + + Status = AcpiExExtractFromField (ObjDesc->IndexField.DataObj, + Value, sizeof (ACPI_INTEGER)); + } + else + { + /* Write the datum to the DataRegister */ + + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "Write to Data Register: Value %8.8X%8.8X\n", + ACPI_FORMAT_UINT64 (*Value))); + + Status = AcpiExInsertIntoField (ObjDesc->IndexField.DataObj, + Value, sizeof (ACPI_INTEGER)); + } + break; + + + default: + + ACPI_ERROR ((AE_INFO, "Wrong object type in field I/O %X", + ObjDesc->Common.Type)); + Status = AE_AML_INTERNAL; + break; + } + + if (ACPI_SUCCESS (Status)) + { + if (ReadWrite == ACPI_READ) + { + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "Value Read %8.8X%8.8X, Width %d\n", + ACPI_FORMAT_UINT64 (*Value), + ObjDesc->CommonField.AccessByteWidth)); + } + else + { + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "Value Written %8.8X%8.8X, Width %d\n", + ACPI_FORMAT_UINT64 (*Value), + ObjDesc->CommonField.AccessByteWidth)); + } + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExWriteWithUpdateRule + * + * PARAMETERS: ObjDesc - Field to be written + * Mask - bitmask within field datum + * FieldValue - Value to write + * FieldDatumByteOffset - Offset of datum within field + * + * RETURN: Status + * + * DESCRIPTION: Apply the field update rule to a field write + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExWriteWithUpdateRule ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_INTEGER Mask, + ACPI_INTEGER FieldValue, + UINT32 FieldDatumByteOffset) +{ + ACPI_STATUS Status = AE_OK; + ACPI_INTEGER MergedValue; + ACPI_INTEGER CurrentValue; + + + ACPI_FUNCTION_TRACE_U32 (ExWriteWithUpdateRule, Mask); + + + /* Start with the new bits */ + + MergedValue = FieldValue; + + /* If the mask is all ones, we don't need to worry about the update rule */ + + if (Mask != ACPI_INTEGER_MAX) + { + /* Decode the update rule */ + + switch (ObjDesc->CommonField.FieldFlags & AML_FIELD_UPDATE_RULE_MASK) + { + case AML_FIELD_UPDATE_PRESERVE: + /* + * Check if update rule needs to be applied (not if mask is all + * ones) The left shift drops the bits we want to ignore. + */ + if ((~Mask << (ACPI_MUL_8 (sizeof (Mask)) - + ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth))) != 0) + { + /* + * Read the current contents of the byte/word/dword containing + * the field, and merge with the new field value. + */ + Status = AcpiExFieldDatumIo (ObjDesc, FieldDatumByteOffset, + &CurrentValue, ACPI_READ); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + MergedValue |= (CurrentValue & ~Mask); + } + break; + + case AML_FIELD_UPDATE_WRITE_AS_ONES: + + /* Set positions outside the field to all ones */ + + MergedValue |= ~Mask; + break; + + case AML_FIELD_UPDATE_WRITE_AS_ZEROS: + + /* Set positions outside the field to all zeros */ + + MergedValue &= Mask; + break; + + default: + + ACPI_ERROR ((AE_INFO, + "Unknown UpdateRule value: %X", + (ObjDesc->CommonField.FieldFlags & AML_FIELD_UPDATE_RULE_MASK))); + return_ACPI_STATUS (AE_AML_OPERAND_VALUE); + } + } + + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "Mask %8.8X%8.8X, DatumOffset %X, Width %X, Value %8.8X%8.8X, MergedValue %8.8X%8.8X\n", + ACPI_FORMAT_UINT64 (Mask), + FieldDatumByteOffset, + ObjDesc->CommonField.AccessByteWidth, + ACPI_FORMAT_UINT64 (FieldValue), + ACPI_FORMAT_UINT64 (MergedValue))); + + /* Write the merged value */ + + Status = AcpiExFieldDatumIo (ObjDesc, FieldDatumByteOffset, + &MergedValue, ACPI_WRITE); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExExtractFromField + * + * PARAMETERS: ObjDesc - Field to be read + * Buffer - Where to store the field data + * BufferLength - Length of Buffer + * + * RETURN: Status + * + * DESCRIPTION: Retrieve the current value of the given field + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExExtractFromField ( + ACPI_OPERAND_OBJECT *ObjDesc, + void *Buffer, + UINT32 BufferLength) +{ + ACPI_STATUS Status; + ACPI_INTEGER RawDatum; + ACPI_INTEGER MergedDatum; + UINT32 FieldOffset = 0; + UINT32 BufferOffset = 0; + UINT32 BufferTailBits; + UINT32 DatumCount; + UINT32 FieldDatumCount; + UINT32 i; + + + ACPI_FUNCTION_TRACE (ExExtractFromField); + + + /* Validate target buffer and clear it */ + + if (BufferLength < + ACPI_ROUND_BITS_UP_TO_BYTES (ObjDesc->CommonField.BitLength)) + { + ACPI_ERROR ((AE_INFO, + "Field size %X (bits) is too large for buffer (%X)", + ObjDesc->CommonField.BitLength, BufferLength)); + + return_ACPI_STATUS (AE_BUFFER_OVERFLOW); + } + ACPI_MEMSET (Buffer, 0, BufferLength); + + /* Compute the number of datums (access width data items) */ + + DatumCount = ACPI_ROUND_UP_TO ( + ObjDesc->CommonField.BitLength, + ObjDesc->CommonField.AccessBitWidth); + FieldDatumCount = ACPI_ROUND_UP_TO ( + ObjDesc->CommonField.BitLength + + ObjDesc->CommonField.StartFieldBitOffset, + ObjDesc->CommonField.AccessBitWidth); + + /* Priming read from the field */ + + Status = AcpiExFieldDatumIo (ObjDesc, FieldOffset, &RawDatum, ACPI_READ); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + MergedDatum = RawDatum >> ObjDesc->CommonField.StartFieldBitOffset; + + /* Read the rest of the field */ + + for (i = 1; i < FieldDatumCount; i++) + { + /* Get next input datum from the field */ + + FieldOffset += ObjDesc->CommonField.AccessByteWidth; + Status = AcpiExFieldDatumIo (ObjDesc, FieldOffset, + &RawDatum, ACPI_READ); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Merge with previous datum if necessary. + * + * Note: Before the shift, check if the shift value will be larger than + * the integer size. If so, there is no need to perform the operation. + * This avoids the differences in behavior between different compilers + * concerning shift values larger than the target data width. + */ + if ((ObjDesc->CommonField.AccessBitWidth - + ObjDesc->CommonField.StartFieldBitOffset) < ACPI_INTEGER_BIT_SIZE) + { + MergedDatum |= RawDatum << + (ObjDesc->CommonField.AccessBitWidth - + ObjDesc->CommonField.StartFieldBitOffset); + } + + if (i == DatumCount) + { + break; + } + + /* Write merged datum to target buffer */ + + ACPI_MEMCPY (((char *) Buffer) + BufferOffset, &MergedDatum, + ACPI_MIN(ObjDesc->CommonField.AccessByteWidth, + BufferLength - BufferOffset)); + + BufferOffset += ObjDesc->CommonField.AccessByteWidth; + MergedDatum = RawDatum >> ObjDesc->CommonField.StartFieldBitOffset; + } + + /* Mask off any extra bits in the last datum */ + + BufferTailBits = ObjDesc->CommonField.BitLength % + ObjDesc->CommonField.AccessBitWidth; + if (BufferTailBits) + { + MergedDatum &= ACPI_MASK_BITS_ABOVE (BufferTailBits); + } + + /* Write the last datum to the buffer */ + + ACPI_MEMCPY (((char *) Buffer) + BufferOffset, &MergedDatum, + ACPI_MIN(ObjDesc->CommonField.AccessByteWidth, + BufferLength - BufferOffset)); + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExInsertIntoField + * + * PARAMETERS: ObjDesc - Field to be written + * Buffer - Data to be written + * BufferLength - Length of Buffer + * + * RETURN: Status + * + * DESCRIPTION: Store the Buffer contents into the given field + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExInsertIntoField ( + ACPI_OPERAND_OBJECT *ObjDesc, + void *Buffer, + UINT32 BufferLength) +{ + ACPI_STATUS Status; + ACPI_INTEGER Mask; + ACPI_INTEGER WidthMask; + ACPI_INTEGER MergedDatum; + ACPI_INTEGER RawDatum = 0; + UINT32 FieldOffset = 0; + UINT32 BufferOffset = 0; + UINT32 BufferTailBits; + UINT32 DatumCount; + UINT32 FieldDatumCount; + UINT32 i; + UINT32 RequiredLength; + void *NewBuffer; + + + ACPI_FUNCTION_TRACE (ExInsertIntoField); + + + /* Validate input buffer */ + + NewBuffer = NULL; + RequiredLength = ACPI_ROUND_BITS_UP_TO_BYTES ( + ObjDesc->CommonField.BitLength); + /* + * We must have a buffer that is at least as long as the field + * we are writing to. This is because individual fields are + * indivisible and partial writes are not supported -- as per + * the ACPI specification. + */ + if (BufferLength < RequiredLength) + { + /* We need to create a new buffer */ + + NewBuffer = ACPI_ALLOCATE_ZEROED (RequiredLength); + if (!NewBuffer) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* + * Copy the original data to the new buffer, starting + * at Byte zero. All unused (upper) bytes of the + * buffer will be 0. + */ + ACPI_MEMCPY ((char *) NewBuffer, (char *) Buffer, BufferLength); + Buffer = NewBuffer; + BufferLength = RequiredLength; + } + + /* + * 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) + { + WidthMask = ACPI_INTEGER_MAX; + } + else + { + WidthMask = ACPI_MASK_BITS_ABOVE (ObjDesc->CommonField.AccessBitWidth); + } + + Mask = WidthMask & + ACPI_MASK_BITS_BELOW (ObjDesc->CommonField.StartFieldBitOffset); + + /* Compute the number of datums (access width data items) */ + + DatumCount = ACPI_ROUND_UP_TO (ObjDesc->CommonField.BitLength, + ObjDesc->CommonField.AccessBitWidth); + + FieldDatumCount = ACPI_ROUND_UP_TO (ObjDesc->CommonField.BitLength + + ObjDesc->CommonField.StartFieldBitOffset, + ObjDesc->CommonField.AccessBitWidth); + + /* Get initial Datum from the input buffer */ + + ACPI_MEMCPY (&RawDatum, Buffer, + ACPI_MIN(ObjDesc->CommonField.AccessByteWidth, + BufferLength - BufferOffset)); + + MergedDatum = RawDatum << ObjDesc->CommonField.StartFieldBitOffset; + + /* Write the entire field */ + + for (i = 1; i < FieldDatumCount; i++) + { + /* Write merged datum to the target field */ + + MergedDatum &= Mask; + Status = AcpiExWriteWithUpdateRule (ObjDesc, Mask, + MergedDatum, FieldOffset); + if (ACPI_FAILURE (Status)) + { + goto Exit; + } + + FieldOffset += ObjDesc->CommonField.AccessByteWidth; + + /* + * Start new output datum by merging with previous input datum + * if necessary. + * + * Note: Before the shift, check if the shift value will be larger than + * the integer size. If so, there is no need to perform the operation. + * This avoids the differences in behavior between different compilers + * concerning shift values larger than the target data width. + */ + if ((ObjDesc->CommonField.AccessBitWidth - + ObjDesc->CommonField.StartFieldBitOffset) < ACPI_INTEGER_BIT_SIZE) + { + MergedDatum = RawDatum >> + (ObjDesc->CommonField.AccessBitWidth - + ObjDesc->CommonField.StartFieldBitOffset); + } + else + { + MergedDatum = 0; + } + + Mask = WidthMask; + + if (i == DatumCount) + { + break; + } + + /* Get the next input datum from the buffer */ + + BufferOffset += ObjDesc->CommonField.AccessByteWidth; + ACPI_MEMCPY (&RawDatum, ((char *) Buffer) + BufferOffset, + ACPI_MIN(ObjDesc->CommonField.AccessByteWidth, + BufferLength - BufferOffset)); + MergedDatum |= RawDatum << ObjDesc->CommonField.StartFieldBitOffset; + } + + /* Mask off any extra bits in the last datum */ + + BufferTailBits = (ObjDesc->CommonField.BitLength + + ObjDesc->CommonField.StartFieldBitOffset) % + ObjDesc->CommonField.AccessBitWidth; + if (BufferTailBits) + { + Mask &= ACPI_MASK_BITS_ABOVE (BufferTailBits); + } + + /* Write the last datum to the field */ + + MergedDatum &= Mask; + Status = AcpiExWriteWithUpdateRule (ObjDesc, + Mask, MergedDatum, FieldOffset); + +Exit: + /* Free temporary buffer if we used one */ + + if (NewBuffer) + { + ACPI_FREE (NewBuffer); + } + return_ACPI_STATUS (Status); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/executer/exmisc.c b/reactos/drivers/bus/acpi/acpica/executer/exmisc.c new file mode 100644 index 00000000000..41e4a9752ec --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/executer/exmisc.c @@ -0,0 +1,873 @@ + +/****************************************************************************** + * + * Module Name: exmisc - ACPI AML (p-code) execution - specific opcodes + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __EXMISC_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" +#include "amlcode.h" +#include "amlresrc.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exmisc") + + +/******************************************************************************* + * + * FUNCTION: AcpiExGetObjectReference + * + * PARAMETERS: ObjDesc - Create a reference to this object + * ReturnDesc - Where to store the reference + * WalkState - Current state + * + * RETURN: Status + * + * DESCRIPTION: Obtain and return a "reference" to the target object + * Common code for the RefOfOp and the CondRefOfOp. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExGetObjectReference ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT **ReturnDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT *ReferenceObj; + ACPI_OPERAND_OBJECT *ReferencedObj; + + + ACPI_FUNCTION_TRACE_PTR (ExGetObjectReference, ObjDesc); + + + *ReturnDesc = NULL; + + switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc)) + { + case ACPI_DESC_TYPE_OPERAND: + + if (ObjDesc->Common.Type != ACPI_TYPE_LOCAL_REFERENCE) + { + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* + * Must be a reference to a Local or Arg + */ + switch (ObjDesc->Reference.Class) + { + case ACPI_REFCLASS_LOCAL: + case ACPI_REFCLASS_ARG: + case ACPI_REFCLASS_DEBUG: + + /* The referenced object is the pseudo-node for the local/arg */ + + ReferencedObj = ObjDesc->Reference.Object; + break; + + default: + + ACPI_ERROR ((AE_INFO, "Unknown Reference Class %2.2X", + ObjDesc->Reference.Class)); + return_ACPI_STATUS (AE_AML_INTERNAL); + } + break; + + + case ACPI_DESC_TYPE_NAMED: + + /* + * A named reference that has already been resolved to a Node + */ + ReferencedObj = ObjDesc; + break; + + + default: + + ACPI_ERROR ((AE_INFO, "Invalid descriptor type %X", + ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))); + return_ACPI_STATUS (AE_TYPE); + } + + + /* Create a new reference object */ + + ReferenceObj = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_REFERENCE); + if (!ReferenceObj) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + ReferenceObj->Reference.Class = ACPI_REFCLASS_REFOF; + ReferenceObj->Reference.Object = ReferencedObj; + *ReturnDesc = ReferenceObj; + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Object %p Type [%s], returning Reference %p\n", + ObjDesc, AcpiUtGetObjectTypeName (ObjDesc), *ReturnDesc)); + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExConcatTemplate + * + * PARAMETERS: Operand0 - First source object + * Operand1 - Second source object + * ActualReturnDesc - Where to place the return object + * WalkState - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: Concatenate two resource templates + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExConcatTemplate ( + ACPI_OPERAND_OBJECT *Operand0, + ACPI_OPERAND_OBJECT *Operand1, + ACPI_OPERAND_OBJECT **ActualReturnDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_OPERAND_OBJECT *ReturnDesc; + UINT8 *NewBuf; + UINT8 *EndTag; + ACPI_SIZE Length0; + ACPI_SIZE Length1; + ACPI_SIZE NewLength; + + + ACPI_FUNCTION_TRACE (ExConcatTemplate); + + + /* + * Find the EndTag descriptor in each resource template. + * Note1: returned pointers point TO the EndTag, not past it. + * Note2: zero-length buffers are allowed; treated like one EndTag + */ + + /* Get the length of the first resource template */ + + Status = AcpiUtGetResourceEndTag (Operand0, &EndTag); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Length0 = ACPI_PTR_DIFF (EndTag, Operand0->Buffer.Pointer); + + /* Get the length of the second resource template */ + + Status = AcpiUtGetResourceEndTag (Operand1, &EndTag); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Length1 = ACPI_PTR_DIFF (EndTag, Operand1->Buffer.Pointer); + + /* Combine both lengths, minimum size will be 2 for EndTag */ + + NewLength = Length0 + Length1 + sizeof (AML_RESOURCE_END_TAG); + + /* Create a new buffer object for the result (with one EndTag) */ + + ReturnDesc = AcpiUtCreateBufferObject (NewLength); + if (!ReturnDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* + * Copy the templates to the new buffer, 0 first, then 1 follows. One + * EndTag descriptor is copied from Operand1. + */ + NewBuf = ReturnDesc->Buffer.Pointer; + ACPI_MEMCPY (NewBuf, Operand0->Buffer.Pointer, Length0); + ACPI_MEMCPY (NewBuf + Length0, Operand1->Buffer.Pointer, Length1); + + /* Insert EndTag and set the checksum to zero, means "ignore checksum" */ + + NewBuf[NewLength - 1] = 0; + NewBuf[NewLength - 2] = ACPI_RESOURCE_NAME_END_TAG | 1; + + /* Return the completed resource template */ + + *ActualReturnDesc = ReturnDesc; + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExDoConcatenate + * + * PARAMETERS: Operand0 - First source object + * Operand1 - Second source object + * ActualReturnDesc - Where to place the return object + * WalkState - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: Concatenate two objects OF THE SAME TYPE. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExDoConcatenate ( + ACPI_OPERAND_OBJECT *Operand0, + ACPI_OPERAND_OBJECT *Operand1, + ACPI_OPERAND_OBJECT **ActualReturnDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT *LocalOperand1 = Operand1; + ACPI_OPERAND_OBJECT *ReturnDesc; + char *NewBuf; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (ExDoConcatenate); + + + /* + * Convert the second operand if necessary. The first operand + * determines the type of the second operand, (See the Data Types + * section of the ACPI specification.) Both object types are + * guaranteed to be either Integer/String/Buffer by the operand + * resolution mechanism. + */ + switch (Operand0->Common.Type) + { + case ACPI_TYPE_INTEGER: + Status = AcpiExConvertToInteger (Operand1, &LocalOperand1, 16); + break; + + case ACPI_TYPE_STRING: + Status = AcpiExConvertToString (Operand1, &LocalOperand1, + ACPI_IMPLICIT_CONVERT_HEX); + break; + + case ACPI_TYPE_BUFFER: + Status = AcpiExConvertToBuffer (Operand1, &LocalOperand1); + break; + + default: + ACPI_ERROR ((AE_INFO, "Invalid object type: %X", + Operand0->Common.Type)); + Status = AE_AML_INTERNAL; + } + + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* + * Both operands are now known to be the same object type + * (Both are Integer, String, or Buffer), and we can now perform the + * concatenation. + */ + + /* + * There are three cases to handle: + * + * 1) Two Integers concatenated to produce a new Buffer + * 2) Two Strings concatenated to produce a new String + * 3) Two Buffers concatenated to produce a new Buffer + */ + switch (Operand0->Common.Type) + { + case ACPI_TYPE_INTEGER: + + /* Result of two Integers is a Buffer */ + /* Need enough buffer space for two integers */ + + ReturnDesc = AcpiUtCreateBufferObject ((ACPI_SIZE) + ACPI_MUL_2 (AcpiGbl_IntegerByteWidth)); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + NewBuf = (char *) ReturnDesc->Buffer.Pointer; + + /* Copy the first integer, LSB first */ + + ACPI_MEMCPY (NewBuf, &Operand0->Integer.Value, + AcpiGbl_IntegerByteWidth); + + /* Copy the second integer (LSB first) after the first */ + + ACPI_MEMCPY (NewBuf + AcpiGbl_IntegerByteWidth, + &LocalOperand1->Integer.Value, + AcpiGbl_IntegerByteWidth); + break; + + case ACPI_TYPE_STRING: + + /* Result of two Strings is a String */ + + ReturnDesc = AcpiUtCreateStringObject ( + ((ACPI_SIZE) Operand0->String.Length + + LocalOperand1->String.Length)); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + NewBuf = ReturnDesc->String.Pointer; + + /* Concatenate the strings */ + + ACPI_STRCPY (NewBuf, Operand0->String.Pointer); + ACPI_STRCPY (NewBuf + Operand0->String.Length, + LocalOperand1->String.Pointer); + break; + + case ACPI_TYPE_BUFFER: + + /* Result of two Buffers is a Buffer */ + + ReturnDesc = AcpiUtCreateBufferObject ( + ((ACPI_SIZE) Operand0->Buffer.Length + + LocalOperand1->Buffer.Length)); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + NewBuf = (char *) ReturnDesc->Buffer.Pointer; + + /* Concatenate the buffers */ + + ACPI_MEMCPY (NewBuf, Operand0->Buffer.Pointer, + Operand0->Buffer.Length); + ACPI_MEMCPY (NewBuf + Operand0->Buffer.Length, + LocalOperand1->Buffer.Pointer, + LocalOperand1->Buffer.Length); + break; + + default: + + /* Invalid object type, should not happen here */ + + ACPI_ERROR ((AE_INFO, "Invalid object type: %X", + Operand0->Common.Type)); + Status =AE_AML_INTERNAL; + goto Cleanup; + } + + *ActualReturnDesc = ReturnDesc; + +Cleanup: + if (LocalOperand1 != Operand1) + { + AcpiUtRemoveReference (LocalOperand1); + } + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExDoMathOp + * + * PARAMETERS: Opcode - AML opcode + * Integer0 - Integer operand #0 + * Integer1 - Integer operand #1 + * + * RETURN: Integer result of the operation + * + * DESCRIPTION: Execute a math AML opcode. The purpose of having all of the + * math functions here is to prevent a lot of pointer dereferencing + * to obtain the operands. + * + ******************************************************************************/ + +ACPI_INTEGER +AcpiExDoMathOp ( + UINT16 Opcode, + ACPI_INTEGER Integer0, + ACPI_INTEGER Integer1) +{ + + ACPI_FUNCTION_ENTRY (); + + + switch (Opcode) + { + case AML_ADD_OP: /* Add (Integer0, Integer1, Result) */ + + return (Integer0 + Integer1); + + + case AML_BIT_AND_OP: /* And (Integer0, Integer1, Result) */ + + return (Integer0 & Integer1); + + + case AML_BIT_NAND_OP: /* NAnd (Integer0, Integer1, Result) */ + + return (~(Integer0 & Integer1)); + + + case AML_BIT_OR_OP: /* Or (Integer0, Integer1, Result) */ + + return (Integer0 | Integer1); + + + case AML_BIT_NOR_OP: /* NOr (Integer0, Integer1, Result) */ + + return (~(Integer0 | Integer1)); + + + case AML_BIT_XOR_OP: /* XOr (Integer0, Integer1, Result) */ + + return (Integer0 ^ Integer1); + + + case AML_MULTIPLY_OP: /* Multiply (Integer0, Integer1, Result) */ + + return (Integer0 * Integer1); + + + case AML_SHIFT_LEFT_OP: /* ShiftLeft (Operand, ShiftCount, Result)*/ + + /* + * We need to check if the shiftcount is larger than the integer bit + * width since the behavior of this is not well-defined in the C language. + */ + if (Integer1 >= AcpiGbl_IntegerBitWidth) + { + return (0); + } + return (Integer0 << Integer1); + + + case AML_SHIFT_RIGHT_OP: /* ShiftRight (Operand, ShiftCount, Result) */ + + /* + * We need to check if the shiftcount is larger than the integer bit + * width since the behavior of this is not well-defined in the C language. + */ + if (Integer1 >= AcpiGbl_IntegerBitWidth) + { + return (0); + } + return (Integer0 >> Integer1); + + + case AML_SUBTRACT_OP: /* Subtract (Integer0, Integer1, Result) */ + + return (Integer0 - Integer1); + + default: + + return (0); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExDoLogicalNumericOp + * + * PARAMETERS: Opcode - AML opcode + * Integer0 - Integer operand #0 + * Integer1 - Integer operand #1 + * LogicalResult - TRUE/FALSE result of the operation + * + * RETURN: Status + * + * DESCRIPTION: Execute a logical "Numeric" AML opcode. For these Numeric + * operators (LAnd and LOr), both operands must be integers. + * + * Note: cleanest machine code seems to be produced by the code + * below, rather than using statements of the form: + * Result = (Integer0 && Integer1); + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExDoLogicalNumericOp ( + UINT16 Opcode, + ACPI_INTEGER Integer0, + ACPI_INTEGER Integer1, + BOOLEAN *LogicalResult) +{ + ACPI_STATUS Status = AE_OK; + BOOLEAN LocalResult = FALSE; + + + ACPI_FUNCTION_TRACE (ExDoLogicalNumericOp); + + + switch (Opcode) + { + case AML_LAND_OP: /* LAnd (Integer0, Integer1) */ + + if (Integer0 && Integer1) + { + LocalResult = TRUE; + } + break; + + case AML_LOR_OP: /* LOr (Integer0, Integer1) */ + + if (Integer0 || Integer1) + { + LocalResult = TRUE; + } + break; + + default: + Status = AE_AML_INTERNAL; + break; + } + + /* Return the logical result and status */ + + *LogicalResult = LocalResult; + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExDoLogicalOp + * + * PARAMETERS: Opcode - AML opcode + * Operand0 - operand #0 + * Operand1 - operand #1 + * LogicalResult - TRUE/FALSE result of the operation + * + * RETURN: Status + * + * DESCRIPTION: Execute a logical AML opcode. The purpose of having all of the + * functions here is to prevent a lot of pointer dereferencing + * to obtain the operands and to simplify the generation of the + * logical value. For the Numeric operators (LAnd and LOr), both + * operands must be integers. For the other logical operators, + * operands can be any combination of Integer/String/Buffer. The + * first operand determines the type to which the second operand + * will be converted. + * + * Note: cleanest machine code seems to be produced by the code + * below, rather than using statements of the form: + * Result = (Operand0 == Operand1); + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExDoLogicalOp ( + UINT16 Opcode, + ACPI_OPERAND_OBJECT *Operand0, + ACPI_OPERAND_OBJECT *Operand1, + BOOLEAN *LogicalResult) +{ + ACPI_OPERAND_OBJECT *LocalOperand1 = Operand1; + ACPI_INTEGER Integer0; + ACPI_INTEGER Integer1; + UINT32 Length0; + UINT32 Length1; + ACPI_STATUS Status = AE_OK; + BOOLEAN LocalResult = FALSE; + int Compare; + + + ACPI_FUNCTION_TRACE (ExDoLogicalOp); + + + /* + * Convert the second operand if necessary. The first operand + * determines the type of the second operand, (See the Data Types + * section of the ACPI 3.0+ specification.) Both object types are + * guaranteed to be either Integer/String/Buffer by the operand + * resolution mechanism. + */ + switch (Operand0->Common.Type) + { + case ACPI_TYPE_INTEGER: + Status = AcpiExConvertToInteger (Operand1, &LocalOperand1, 16); + break; + + case ACPI_TYPE_STRING: + Status = AcpiExConvertToString (Operand1, &LocalOperand1, + ACPI_IMPLICIT_CONVERT_HEX); + break; + + case ACPI_TYPE_BUFFER: + Status = AcpiExConvertToBuffer (Operand1, &LocalOperand1); + break; + + default: + Status = AE_AML_INTERNAL; + break; + } + + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* + * Two cases: 1) Both Integers, 2) Both Strings or Buffers + */ + if (Operand0->Common.Type == ACPI_TYPE_INTEGER) + { + /* + * 1) Both operands are of type integer + * Note: LocalOperand1 may have changed above + */ + Integer0 = Operand0->Integer.Value; + Integer1 = LocalOperand1->Integer.Value; + + switch (Opcode) + { + case AML_LEQUAL_OP: /* LEqual (Operand0, Operand1) */ + + if (Integer0 == Integer1) + { + LocalResult = TRUE; + } + break; + + case AML_LGREATER_OP: /* LGreater (Operand0, Operand1) */ + + if (Integer0 > Integer1) + { + LocalResult = TRUE; + } + break; + + case AML_LLESS_OP: /* LLess (Operand0, Operand1) */ + + if (Integer0 < Integer1) + { + LocalResult = TRUE; + } + break; + + default: + Status = AE_AML_INTERNAL; + break; + } + } + else + { + /* + * 2) Both operands are Strings or both are Buffers + * Note: Code below takes advantage of common Buffer/String + * object fields. LocalOperand1 may have changed above. Use + * memcmp to handle nulls in buffers. + */ + Length0 = Operand0->Buffer.Length; + Length1 = LocalOperand1->Buffer.Length; + + /* Lexicographic compare: compare the data bytes */ + + Compare = ACPI_MEMCMP (Operand0->Buffer.Pointer, + LocalOperand1->Buffer.Pointer, + (Length0 > Length1) ? Length1 : Length0); + + switch (Opcode) + { + case AML_LEQUAL_OP: /* LEqual (Operand0, Operand1) */ + + /* Length and all bytes must be equal */ + + if ((Length0 == Length1) && + (Compare == 0)) + { + /* Length and all bytes match ==> TRUE */ + + LocalResult = TRUE; + } + break; + + case AML_LGREATER_OP: /* LGreater (Operand0, Operand1) */ + + if (Compare > 0) + { + LocalResult = TRUE; + goto Cleanup; /* TRUE */ + } + if (Compare < 0) + { + goto Cleanup; /* FALSE */ + } + + /* Bytes match (to shortest length), compare lengths */ + + if (Length0 > Length1) + { + LocalResult = TRUE; + } + break; + + case AML_LLESS_OP: /* LLess (Operand0, Operand1) */ + + if (Compare > 0) + { + goto Cleanup; /* FALSE */ + } + if (Compare < 0) + { + LocalResult = TRUE; + goto Cleanup; /* TRUE */ + } + + /* Bytes match (to shortest length), compare lengths */ + + if (Length0 < Length1) + { + LocalResult = TRUE; + } + break; + + default: + Status = AE_AML_INTERNAL; + break; + } + } + +Cleanup: + + /* New object was created if implicit conversion performed - delete */ + + if (LocalOperand1 != Operand1) + { + AcpiUtRemoveReference (LocalOperand1); + } + + /* Return the logical result and status */ + + *LogicalResult = LocalResult; + return_ACPI_STATUS (Status); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/executer/exmutex.c b/reactos/drivers/bus/acpi/acpica/executer/exmutex.c new file mode 100644 index 00000000000..8b1bebf1e91 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/executer/exmutex.c @@ -0,0 +1,621 @@ + +/****************************************************************************** + * + * Module Name: exmutex - ASL Mutex Acquire/Release functions + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __EXMUTEX_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" +#include "acevents.h" + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exmutex") + +/* Local prototypes */ + +static void +AcpiExLinkMutex ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_THREAD_STATE *Thread); + + +/******************************************************************************* + * + * FUNCTION: AcpiExUnlinkMutex + * + * PARAMETERS: ObjDesc - The mutex to be unlinked + * + * RETURN: None + * + * DESCRIPTION: Remove a mutex from the "AcquiredMutex" list + * + ******************************************************************************/ + +void +AcpiExUnlinkMutex ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_THREAD_STATE *Thread = ObjDesc->Mutex.OwnerThread; + + + if (!Thread) + { + return; + } + + /* Doubly linked list */ + + if (ObjDesc->Mutex.Next) + { + (ObjDesc->Mutex.Next)->Mutex.Prev = ObjDesc->Mutex.Prev; + } + + if (ObjDesc->Mutex.Prev) + { + (ObjDesc->Mutex.Prev)->Mutex.Next = ObjDesc->Mutex.Next; + + /* + * Migrate the previous sync level associated with this mutex to the + * previous mutex on the list so that it may be preserved. This handles + * the case where several mutexes have been acquired at the same level, + * but are not released in opposite order. + */ + (ObjDesc->Mutex.Prev)->Mutex.OriginalSyncLevel = + ObjDesc->Mutex.OriginalSyncLevel; + } + else + { + Thread->AcquiredMutexList = ObjDesc->Mutex.Next; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExLinkMutex + * + * PARAMETERS: ObjDesc - The mutex to be linked + * Thread - Current executing thread object + * + * RETURN: None + * + * DESCRIPTION: Add a mutex to the "AcquiredMutex" list for this walk + * + ******************************************************************************/ + +static void +AcpiExLinkMutex ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_THREAD_STATE *Thread) +{ + ACPI_OPERAND_OBJECT *ListHead; + + + ListHead = Thread->AcquiredMutexList; + + /* This object will be the first object in the list */ + + ObjDesc->Mutex.Prev = NULL; + ObjDesc->Mutex.Next = ListHead; + + /* Update old first object to point back to this object */ + + if (ListHead) + { + ListHead->Mutex.Prev = ObjDesc; + } + + /* Update list head */ + + Thread->AcquiredMutexList = ObjDesc; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExAcquireMutexObject + * + * PARAMETERS: TimeDesc - Timeout in milliseconds + * ObjDesc - Mutex object + * Thread - Current thread state + * + * RETURN: Status + * + * DESCRIPTION: Acquire an AML mutex, low-level interface. Provides a common + * path that supports multiple acquires by the same thread. + * + * MUTEX: Interpreter must be locked + * + * NOTE: This interface is called from three places: + * 1) From AcpiExAcquireMutex, via an AML Acquire() operator + * 2) From AcpiExAcquireGlobalLock when an AML Field access requires the + * global lock + * 3) From the external interface, AcpiAcquireGlobalLock + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExAcquireMutexObject ( + UINT16 Timeout, + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_THREAD_ID ThreadId) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE_PTR (ExAcquireMutexObject, ObjDesc); + + + if (!ObjDesc) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Support for multiple acquires by the owning thread */ + + if (ObjDesc->Mutex.ThreadId == ThreadId) + { + /* + * The mutex is already owned by this thread, just increment the + * acquisition depth + */ + ObjDesc->Mutex.AcquisitionDepth++; + return_ACPI_STATUS (AE_OK); + } + + /* Acquire the mutex, wait if necessary. Special case for Global Lock */ + + if (ObjDesc == AcpiGbl_GlobalLockMutex) + { + Status = AcpiEvAcquireGlobalLock (Timeout); + } + else + { + Status = AcpiExSystemWaitMutex (ObjDesc->Mutex.OsMutex, + Timeout); + } + + if (ACPI_FAILURE (Status)) + { + /* Includes failure from a timeout on TimeDesc */ + + return_ACPI_STATUS (Status); + } + + /* Acquired the mutex: update mutex object */ + + ObjDesc->Mutex.ThreadId = ThreadId; + ObjDesc->Mutex.AcquisitionDepth = 1; + ObjDesc->Mutex.OriginalSyncLevel = 0; + ObjDesc->Mutex.OwnerThread = NULL; /* Used only for AML Acquire() */ + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExAcquireMutex + * + * PARAMETERS: TimeDesc - Timeout integer + * ObjDesc - Mutex object + * WalkState - Current method execution state + * + * RETURN: Status + * + * DESCRIPTION: Acquire an AML mutex + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExAcquireMutex ( + ACPI_OPERAND_OBJECT *TimeDesc, + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE_PTR (ExAcquireMutex, ObjDesc); + + + if (!ObjDesc) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Must have a valid thread ID */ + + if (!WalkState->Thread) + { + ACPI_ERROR ((AE_INFO, "Cannot acquire Mutex [%4.4s], null thread info", + AcpiUtGetNodeName (ObjDesc->Mutex.Node))); + return_ACPI_STATUS (AE_AML_INTERNAL); + } + + /* + * Current sync level must be less than or equal to the sync level of the + * mutex. This mechanism provides some deadlock prevention + */ + if (WalkState->Thread->CurrentSyncLevel > ObjDesc->Mutex.SyncLevel) + { + ACPI_ERROR ((AE_INFO, + "Cannot acquire Mutex [%4.4s], current SyncLevel is too large (%d)", + AcpiUtGetNodeName (ObjDesc->Mutex.Node), + WalkState->Thread->CurrentSyncLevel)); + return_ACPI_STATUS (AE_AML_MUTEX_ORDER); + } + + Status = AcpiExAcquireMutexObject ((UINT16) TimeDesc->Integer.Value, + ObjDesc, WalkState->Thread->ThreadId); + if (ACPI_SUCCESS (Status) && ObjDesc->Mutex.AcquisitionDepth == 1) + { + /* Save Thread object, original/current sync levels */ + + ObjDesc->Mutex.OwnerThread = WalkState->Thread; + ObjDesc->Mutex.OriginalSyncLevel = WalkState->Thread->CurrentSyncLevel; + WalkState->Thread->CurrentSyncLevel = ObjDesc->Mutex.SyncLevel; + + /* Link the mutex to the current thread for force-unlock at method exit */ + + AcpiExLinkMutex (ObjDesc, WalkState->Thread); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExReleaseMutexObject + * + * PARAMETERS: ObjDesc - The object descriptor for this op + * + * RETURN: Status + * + * DESCRIPTION: Release a previously acquired Mutex, low level interface. + * Provides a common path that supports multiple releases (after + * previous multiple acquires) by the same thread. + * + * MUTEX: Interpreter must be locked + * + * NOTE: This interface is called from three places: + * 1) From AcpiExReleaseMutex, via an AML Acquire() operator + * 2) From AcpiExReleaseGlobalLock when an AML Field access requires the + * global lock + * 3) From the external interface, AcpiReleaseGlobalLock + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExReleaseMutexObject ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (ExReleaseMutexObject); + + + if (ObjDesc->Mutex.AcquisitionDepth == 0) + { + return (AE_NOT_ACQUIRED); + } + + /* Match multiple Acquires with multiple Releases */ + + ObjDesc->Mutex.AcquisitionDepth--; + if (ObjDesc->Mutex.AcquisitionDepth != 0) + { + /* Just decrement the depth and return */ + + return_ACPI_STATUS (AE_OK); + } + + if (ObjDesc->Mutex.OwnerThread) + { + /* Unlink the mutex from the owner's list */ + + AcpiExUnlinkMutex (ObjDesc); + ObjDesc->Mutex.OwnerThread = NULL; + } + + /* Release the mutex, special case for Global Lock */ + + if (ObjDesc == AcpiGbl_GlobalLockMutex) + { + Status = AcpiEvReleaseGlobalLock (); + } + else + { + AcpiOsReleaseMutex (ObjDesc->Mutex.OsMutex); + } + + /* Clear mutex info */ + + ObjDesc->Mutex.ThreadId = 0; + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExReleaseMutex + * + * PARAMETERS: ObjDesc - The object descriptor for this op + * WalkState - Current method execution state + * + * RETURN: Status + * + * DESCRIPTION: Release a previously acquired Mutex. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExReleaseMutex ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + UINT8 PreviousSyncLevel; + + + ACPI_FUNCTION_TRACE (ExReleaseMutex); + + + if (!ObjDesc) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* The mutex must have been previously acquired in order to release it */ + + if (!ObjDesc->Mutex.OwnerThread) + { + ACPI_ERROR ((AE_INFO, "Cannot release Mutex [%4.4s], not acquired", + AcpiUtGetNodeName (ObjDesc->Mutex.Node))); + return_ACPI_STATUS (AE_AML_MUTEX_NOT_ACQUIRED); + } + + /* Must have a valid thread ID */ + + if (!WalkState->Thread) + { + ACPI_ERROR ((AE_INFO, "Cannot release Mutex [%4.4s], null thread info", + AcpiUtGetNodeName (ObjDesc->Mutex.Node))); + return_ACPI_STATUS (AE_AML_INTERNAL); + } + + /* + * The Mutex is owned, but this thread must be the owner. + * Special case for Global Lock, any thread can release + */ + if ((ObjDesc->Mutex.OwnerThread->ThreadId != WalkState->Thread->ThreadId) && + (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), + AcpiUtGetNodeName (ObjDesc->Mutex.Node), + ACPI_CAST_PTR (void, ObjDesc->Mutex.OwnerThread->ThreadId))); + return_ACPI_STATUS (AE_AML_NOT_OWNER); + } + + /* + * The sync level of the mutex must be equal to the current sync level. In + * other words, the current level means that at least one mutex at that + * level is currently being held. Attempting to release a mutex of a + * different level can only mean that the mutex ordering rule is being + * violated. This behavior is clarified in ACPI 4.0 specification. + */ + if (ObjDesc->Mutex.SyncLevel != WalkState->Thread->CurrentSyncLevel) + { + ACPI_ERROR ((AE_INFO, + "Cannot release Mutex [%4.4s], SyncLevel mismatch: mutex %d current %d", + AcpiUtGetNodeName (ObjDesc->Mutex.Node), + ObjDesc->Mutex.SyncLevel, WalkState->Thread->CurrentSyncLevel)); + return_ACPI_STATUS (AE_AML_MUTEX_ORDER); + } + + /* + * Get the previous SyncLevel from the head of the acquired mutex list. + * This handles the case where several mutexes at the same level have been + * acquired, but are not released in reverse order. + */ + PreviousSyncLevel = + WalkState->Thread->AcquiredMutexList->Mutex.OriginalSyncLevel; + + Status = AcpiExReleaseMutexObject (ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (ObjDesc->Mutex.AcquisitionDepth == 0) + { + /* Restore the previous SyncLevel */ + + WalkState->Thread->CurrentSyncLevel = PreviousSyncLevel; + } + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExReleaseAllMutexes + * + * PARAMETERS: Thread - Current executing thread object + * + * RETURN: Status + * + * DESCRIPTION: Release all mutexes held by this thread + * + * NOTE: This function is called as the thread is exiting the interpreter. + * Mutexes are not released when an individual control method is exited, but + * only when the parent thread actually exits the interpreter. This allows one + * method to acquire a mutex, and a different method to release it, as long as + * this is performed underneath a single parent control method. + * + ******************************************************************************/ + +void +AcpiExReleaseAllMutexes ( + ACPI_THREAD_STATE *Thread) +{ + ACPI_OPERAND_OBJECT *Next = Thread->AcquiredMutexList; + ACPI_OPERAND_OBJECT *ObjDesc; + + + ACPI_FUNCTION_ENTRY (); + + + /* Traverse the list of owned mutexes, releasing each one */ + + while (Next) + { + ObjDesc = Next; + Next = ObjDesc->Mutex.Next; + + ObjDesc->Mutex.Prev = NULL; + ObjDesc->Mutex.Next = NULL; + ObjDesc->Mutex.AcquisitionDepth = 0; + + /* Release the mutex, special case for Global Lock */ + + if (ObjDesc == AcpiGbl_GlobalLockMutex) + { + /* Ignore errors */ + + (void) AcpiEvReleaseGlobalLock (); + } + else + { + AcpiOsReleaseMutex (ObjDesc->Mutex.OsMutex); + } + + /* Mark mutex unowned */ + + ObjDesc->Mutex.OwnerThread = NULL; + ObjDesc->Mutex.ThreadId = 0; + + /* Update Thread SyncLevel (Last mutex is the important one) */ + + Thread->CurrentSyncLevel = ObjDesc->Mutex.OriginalSyncLevel; + } +} + + diff --git a/reactos/drivers/bus/acpi/acpica/executer/exnames.c b/reactos/drivers/bus/acpi/acpica/executer/exnames.c new file mode 100644 index 00000000000..89fa2d4874d --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/executer/exnames.c @@ -0,0 +1,560 @@ + +/****************************************************************************** + * + * Module Name: exnames - interpreter/scanner name load/execute + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __EXNAMES_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" +#include "amlcode.h" + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exnames") + +/* Local prototypes */ + +static char * +AcpiExAllocateNameString ( + UINT32 PrefixCount, + UINT32 NumNameSegs); + +static ACPI_STATUS +AcpiExNameSegment ( + UINT8 **InAmlAddress, + char *NameString); + + +/******************************************************************************* + * + * FUNCTION: AcpiExAllocateNameString + * + * PARAMETERS: PrefixCount - Count of parent levels. Special cases: + * (-1)==root, 0==none + * NumNameSegs - count of 4-character name segments + * + * RETURN: A pointer to the allocated string segment. This segment must + * be deleted by the caller. + * + * DESCRIPTION: Allocate a buffer for a name string. Ensure allocated name + * string is long enough, and set up prefix if any. + * + ******************************************************************************/ + +static char * +AcpiExAllocateNameString ( + UINT32 PrefixCount, + UINT32 NumNameSegs) +{ + char *TempPtr; + char *NameString; + UINT32 SizeNeeded; + + ACPI_FUNCTION_TRACE (ExAllocateNameString); + + + /* + * Allow room for all \ and ^ prefixes, all segments and a MultiNamePrefix. + * Also, one byte for the null terminator. + * This may actually be somewhat longer than needed. + */ + if (PrefixCount == ACPI_UINT32_MAX) + { + /* Special case for root */ + + SizeNeeded = 1 + (ACPI_NAME_SIZE * NumNameSegs) + 2 + 1; + } + else + { + SizeNeeded = PrefixCount + (ACPI_NAME_SIZE * NumNameSegs) + 2 + 1; + } + + /* + * Allocate a buffer for the name. + * This buffer must be deleted by the caller! + */ + NameString = ACPI_ALLOCATE (SizeNeeded); + if (!NameString) + { + ACPI_ERROR ((AE_INFO, + "Could not allocate size %d", SizeNeeded)); + return_PTR (NULL); + } + + TempPtr = NameString; + + /* Set up Root or Parent prefixes if needed */ + + if (PrefixCount == ACPI_UINT32_MAX) + { + *TempPtr++ = AML_ROOT_PREFIX; + } + else + { + while (PrefixCount--) + { + *TempPtr++ = AML_PARENT_PREFIX; + } + } + + + /* Set up Dual or Multi prefixes if needed */ + + if (NumNameSegs > 2) + { + /* Set up multi prefixes */ + + *TempPtr++ = AML_MULTI_NAME_PREFIX_OP; + *TempPtr++ = (char) NumNameSegs; + } + else if (2 == NumNameSegs) + { + /* Set up dual prefixes */ + + *TempPtr++ = AML_DUAL_NAME_PREFIX; + } + + /* + * Terminate string following prefixes. AcpiExNameSegment() will + * append the segment(s) + */ + *TempPtr = 0; + + return_PTR (NameString); +} + +/******************************************************************************* + * + * FUNCTION: AcpiExNameSegment + * + * PARAMETERS: InAmlAddress - Pointer to the name in the AML code + * NameString - Where to return the name. The name is appended + * to any existing string to form a namepath + * + * RETURN: Status + * + * DESCRIPTION: Extract an ACPI name (4 bytes) from the AML byte stream + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiExNameSegment ( + UINT8 **InAmlAddress, + char *NameString) +{ + char *AmlAddress = (void *) *InAmlAddress; + ACPI_STATUS Status = AE_OK; + UINT32 Index; + char CharBuf[5]; + + + ACPI_FUNCTION_TRACE (ExNameSegment); + + + /* + * If first character is a digit, then we know that we aren't looking at a + * valid name segment + */ + CharBuf[0] = *AmlAddress; + + if ('0' <= CharBuf[0] && CharBuf[0] <= '9') + { + ACPI_ERROR ((AE_INFO, "Invalid leading digit: %c", CharBuf[0])); + return_ACPI_STATUS (AE_CTRL_PENDING); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Bytes from stream:\n")); + + for (Index = 0; + (Index < ACPI_NAME_SIZE) && (AcpiUtValidAcpiChar (*AmlAddress, 0)); + Index++) + { + CharBuf[Index] = *AmlAddress++; + ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "%c\n", CharBuf[Index])); + } + + + /* Valid name segment */ + + if (Index == 4) + { + /* Found 4 valid characters */ + + CharBuf[4] = '\0'; + + if (NameString) + { + ACPI_STRCAT (NameString, CharBuf); + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "Appended to - %s\n", NameString)); + } + else + { + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "No Name string - %s\n", CharBuf)); + } + } + else if (Index == 0) + { + /* + * First character was not a valid name character, + * so we are looking at something other than a name. + */ + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Leading character is not alpha: %02Xh (not a name)\n", + CharBuf[0])); + Status = AE_CTRL_PENDING; + } + else + { + /* + * Segment started with one or more valid characters, but fewer than + * the required 4 + */ + Status = AE_AML_BAD_NAME; + ACPI_ERROR ((AE_INFO, + "Bad character %02x in name, at %p", + *AmlAddress, AmlAddress)); + } + + *InAmlAddress = ACPI_CAST_PTR (UINT8, AmlAddress); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExGetNameString + * + * PARAMETERS: DataType - Object type to be associated with this + * name + * InAmlAddress - Pointer to the namestring in the AML code + * OutNameString - Where the namestring is returned + * OutNameLength - Length of the returned string + * + * RETURN: Status, namestring and length + * + * DESCRIPTION: Extract a full namepath from the AML byte stream, + * including any prefixes. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExGetNameString ( + ACPI_OBJECT_TYPE DataType, + UINT8 *InAmlAddress, + char **OutNameString, + UINT32 *OutNameLength) +{ + ACPI_STATUS Status = AE_OK; + UINT8 *AmlAddress = InAmlAddress; + char *NameString = NULL; + UINT32 NumSegments; + UINT32 PrefixCount = 0; + BOOLEAN HasPrefix = FALSE; + + + ACPI_FUNCTION_TRACE_PTR (ExGetNameString, AmlAddress); + + + if (ACPI_TYPE_LOCAL_REGION_FIELD == DataType || + ACPI_TYPE_LOCAL_BANK_FIELD == DataType || + ACPI_TYPE_LOCAL_INDEX_FIELD == DataType) + { + /* Disallow prefixes for types associated with FieldUnit names */ + + NameString = AcpiExAllocateNameString (0, 1); + if (!NameString) + { + Status = AE_NO_MEMORY; + } + else + { + Status = AcpiExNameSegment (&AmlAddress, NameString); + } + } + else + { + /* + * DataType is not a field name. + * Examine first character of name for root or parent prefix operators + */ + switch (*AmlAddress) + { + case AML_ROOT_PREFIX: + + ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "RootPrefix(\\) at %p\n", + AmlAddress)); + + /* + * Remember that we have a RootPrefix -- + * see comment in AcpiExAllocateNameString() + */ + AmlAddress++; + PrefixCount = ACPI_UINT32_MAX; + HasPrefix = TRUE; + break; + + + case AML_PARENT_PREFIX: + + /* Increment past possibly multiple parent prefixes */ + + do + { + ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "ParentPrefix (^) at %p\n", + AmlAddress)); + + AmlAddress++; + PrefixCount++; + + } while (*AmlAddress == AML_PARENT_PREFIX); + + HasPrefix = TRUE; + break; + + + default: + + /* Not a prefix character */ + + break; + } + + /* Examine first character of name for name segment prefix operator */ + + switch (*AmlAddress) + { + case AML_DUAL_NAME_PREFIX: + + ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "DualNamePrefix at %p\n", + AmlAddress)); + + AmlAddress++; + NameString = AcpiExAllocateNameString (PrefixCount, 2); + if (!NameString) + { + Status = AE_NO_MEMORY; + break; + } + + /* Indicate that we processed a prefix */ + + HasPrefix = TRUE; + + Status = AcpiExNameSegment (&AmlAddress, NameString); + if (ACPI_SUCCESS (Status)) + { + Status = AcpiExNameSegment (&AmlAddress, NameString); + } + break; + + + case AML_MULTI_NAME_PREFIX_OP: + + ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "MultiNamePrefix at %p\n", + AmlAddress)); + + /* Fetch count of segments remaining in name path */ + + AmlAddress++; + NumSegments = *AmlAddress; + + NameString = AcpiExAllocateNameString (PrefixCount, NumSegments); + if (!NameString) + { + Status = AE_NO_MEMORY; + break; + } + + /* Indicate that we processed a prefix */ + + AmlAddress++; + HasPrefix = TRUE; + + while (NumSegments && + (Status = AcpiExNameSegment (&AmlAddress, NameString)) == + AE_OK) + { + NumSegments--; + } + + break; + + + case 0: + + /* NullName valid as of 8-12-98 ASL/AML Grammar Update */ + + if (PrefixCount == ACPI_UINT32_MAX) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "NameSeg is \"\\\" followed by NULL\n")); + } + + /* Consume the NULL byte */ + + AmlAddress++; + NameString = AcpiExAllocateNameString (PrefixCount, 0); + if (!NameString) + { + Status = AE_NO_MEMORY; + break; + } + + break; + + + default: + + /* Name segment string */ + + NameString = AcpiExAllocateNameString (PrefixCount, 1); + if (!NameString) + { + Status = AE_NO_MEMORY; + break; + } + + Status = AcpiExNameSegment (&AmlAddress, NameString); + break; + } + } + + if (AE_CTRL_PENDING == Status && HasPrefix) + { + /* Ran out of segments after processing a prefix */ + + ACPI_ERROR ((AE_INFO, + "Malformed Name at %p", NameString)); + Status = AE_AML_BAD_NAME; + } + + if (ACPI_FAILURE (Status)) + { + if (NameString) + { + ACPI_FREE (NameString); + } + return_ACPI_STATUS (Status); + } + + *OutNameString = NameString; + *OutNameLength = (UINT32) (AmlAddress - InAmlAddress); + + return_ACPI_STATUS (Status); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/executer/exoparg1.c b/reactos/drivers/bus/acpi/acpica/executer/exoparg1.c new file mode 100644 index 00000000000..4a90b9c9506 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/executer/exoparg1.c @@ -0,0 +1,1183 @@ + +/****************************************************************************** + * + * Module Name: exoparg1 - AML execution - opcodes with 1 argument + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __EXOPARG1_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acparser.h" +#include "acdispat.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exoparg1") + + +/*! + * Naming convention for AML interpreter execution routines. + * + * The routines that begin execution of AML opcodes are named with a common + * convention based upon the number of arguments, the number of target operands, + * and whether or not a value is returned: + * + * AcpiExOpcode_xA_yT_zR + * + * Where: + * + * xA - ARGUMENTS: The number of arguments (input operands) that are + * required for this opcode type (0 through 6 args). + * yT - TARGETS: The number of targets (output operands) that are required + * for this opcode type (0, 1, or 2 targets). + * zR - RETURN VALUE: Indicates whether this opcode type returns a value + * as the function return (0 or 1). + * + * The AcpiExOpcode* functions are called via the Dispatcher component with + * fully resolved operands. +!*/ + +/******************************************************************************* + * + * FUNCTION: AcpiExOpcode_0A_0T_1R + * + * PARAMETERS: WalkState - Current state (contains AML opcode) + * + * RETURN: Status + * + * DESCRIPTION: Execute operator with no operands, one return value + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExOpcode_0A_0T_1R ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT *ReturnDesc = NULL; + + + ACPI_FUNCTION_TRACE_STR (ExOpcode_0A_0T_1R, + AcpiPsGetOpcodeName (WalkState->Opcode)); + + + /* Examine the AML opcode */ + + switch (WalkState->Opcode) + { + case AML_TIMER_OP: /* Timer () */ + + /* Create a return object of type Integer */ + + ReturnDesc = AcpiUtCreateIntegerObject (AcpiOsGetTimer ()); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + break; + + default: /* Unknown opcode */ + + ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", + WalkState->Opcode)); + Status = AE_AML_BAD_OPCODE; + break; + } + +Cleanup: + + /* Delete return object on error */ + + if ((ACPI_FAILURE (Status)) || WalkState->ResultObj) + { + AcpiUtRemoveReference (ReturnDesc); + WalkState->ResultObj = NULL; + } + else + { + /* Save the return value */ + + WalkState->ResultObj = ReturnDesc; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExOpcode_1A_0T_0R + * + * PARAMETERS: WalkState - Current state (contains AML opcode) + * + * RETURN: Status + * + * DESCRIPTION: Execute Type 1 monadic operator with numeric operand on + * object stack + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExOpcode_1A_0T_0R ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_0T_0R, + AcpiPsGetOpcodeName (WalkState->Opcode)); + + + /* Examine the AML opcode */ + + switch (WalkState->Opcode) + { + case AML_RELEASE_OP: /* Release (MutexObject) */ + + Status = AcpiExReleaseMutex (Operand[0], WalkState); + break; + + + case AML_RESET_OP: /* Reset (EventObject) */ + + Status = AcpiExSystemResetEvent (Operand[0]); + break; + + + case AML_SIGNAL_OP: /* Signal (EventObject) */ + + Status = AcpiExSystemSignalEvent (Operand[0]); + break; + + + case AML_SLEEP_OP: /* Sleep (MsecTime) */ + + Status = AcpiExSystemDoSuspend (Operand[0]->Integer.Value); + break; + + + case AML_STALL_OP: /* Stall (UsecTime) */ + + Status = AcpiExSystemDoStall ((UINT32) Operand[0]->Integer.Value); + break; + + + case AML_UNLOAD_OP: /* Unload (Handle) */ + + Status = AcpiExUnloadTable (Operand[0]); + break; + + + default: /* Unknown opcode */ + + ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", + WalkState->Opcode)); + Status = AE_AML_BAD_OPCODE; + break; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExOpcode_1A_1T_0R + * + * PARAMETERS: WalkState - Current state (contains AML opcode) + * + * RETURN: Status + * + * DESCRIPTION: Execute opcode with one argument, one target, and no + * return value. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExOpcode_1A_1T_0R ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; + + + ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_1T_0R, + AcpiPsGetOpcodeName (WalkState->Opcode)); + + + /* Examine the AML opcode */ + + switch (WalkState->Opcode) + { + case AML_LOAD_OP: + + Status = AcpiExLoadOp (Operand[0], Operand[1], WalkState); + break; + + default: /* Unknown opcode */ + + ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", + WalkState->Opcode)); + Status = AE_AML_BAD_OPCODE; + goto Cleanup; + } + + +Cleanup: + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExOpcode_1A_1T_1R + * + * PARAMETERS: WalkState - Current state (contains AML opcode) + * + * RETURN: Status + * + * DESCRIPTION: Execute opcode with one argument, one target, and a + * return value. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExOpcode_1A_1T_1R ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; + ACPI_OPERAND_OBJECT *ReturnDesc = NULL; + ACPI_OPERAND_OBJECT *ReturnDesc2 = NULL; + UINT32 Temp32; + UINT32 i; + ACPI_INTEGER PowerOfTen; + ACPI_INTEGER Digit; + + + ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_1T_1R, + AcpiPsGetOpcodeName (WalkState->Opcode)); + + + /* Examine the AML opcode */ + + switch (WalkState->Opcode) + { + case AML_BIT_NOT_OP: + case AML_FIND_SET_LEFT_BIT_OP: + case AML_FIND_SET_RIGHT_BIT_OP: + case AML_FROM_BCD_OP: + case AML_TO_BCD_OP: + case AML_COND_REF_OF_OP: + + /* Create a return object of type Integer for these opcodes */ + + ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + switch (WalkState->Opcode) + { + case AML_BIT_NOT_OP: /* Not (Operand, Result) */ + + ReturnDesc->Integer.Value = ~Operand[0]->Integer.Value; + break; + + + case AML_FIND_SET_LEFT_BIT_OP: /* FindSetLeftBit (Operand, Result) */ + + ReturnDesc->Integer.Value = Operand[0]->Integer.Value; + + /* + * Acpi specification describes Integer type as a little + * endian unsigned value, so this boundary condition is valid. + */ + for (Temp32 = 0; ReturnDesc->Integer.Value && + Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32) + { + ReturnDesc->Integer.Value >>= 1; + } + + ReturnDesc->Integer.Value = Temp32; + break; + + + case AML_FIND_SET_RIGHT_BIT_OP: /* FindSetRightBit (Operand, Result) */ + + ReturnDesc->Integer.Value = Operand[0]->Integer.Value; + + /* + * The Acpi specification describes Integer type as a little + * endian unsigned value, so this boundary condition is valid. + */ + for (Temp32 = 0; ReturnDesc->Integer.Value && + Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32) + { + ReturnDesc->Integer.Value <<= 1; + } + + /* Since the bit position is one-based, subtract from 33 (65) */ + + ReturnDesc->Integer.Value = + Temp32 == 0 ? 0 : (ACPI_INTEGER_BIT_SIZE + 1) - Temp32; + break; + + + case AML_FROM_BCD_OP: /* FromBcd (BCDValue, Result) */ + + /* + * The 64-bit ACPI integer can hold 16 4-bit BCD characters + * (if table is 32-bit, integer can hold 8 BCD characters) + * Convert each 4-bit BCD value + */ + PowerOfTen = 1; + ReturnDesc->Integer.Value = 0; + Digit = Operand[0]->Integer.Value; + + /* Convert each BCD digit (each is one nybble wide) */ + + for (i = 0; (i < AcpiGbl_IntegerNybbleWidth) && (Digit > 0); i++) + { + /* Get the least significant 4-bit BCD digit */ + + Temp32 = ((UINT32) Digit) & 0xF; + + /* Check the range of the digit */ + + if (Temp32 > 9) + { + ACPI_ERROR ((AE_INFO, + "BCD digit too large (not decimal): 0x%X", + Temp32)); + + Status = AE_AML_NUMERIC_OVERFLOW; + goto Cleanup; + } + + /* Sum the digit into the result with the current power of 10 */ + + ReturnDesc->Integer.Value += + (((ACPI_INTEGER) Temp32) * PowerOfTen); + + /* Shift to next BCD digit */ + + Digit >>= 4; + + /* Next power of 10 */ + + PowerOfTen *= 10; + } + break; + + + case AML_TO_BCD_OP: /* ToBcd (Operand, Result) */ + + ReturnDesc->Integer.Value = 0; + Digit = Operand[0]->Integer.Value; + + /* Each BCD digit is one nybble wide */ + + for (i = 0; (i < AcpiGbl_IntegerNybbleWidth) && (Digit > 0); i++) + { + (void) AcpiUtShortDivide (Digit, 10, &Digit, &Temp32); + + /* + * Insert the BCD digit that resides in the + * remainder from above + */ + ReturnDesc->Integer.Value |= + (((ACPI_INTEGER) Temp32) << ACPI_MUL_4 (i)); + } + + /* Overflow if there is any data left in Digit */ + + if (Digit > 0) + { + ACPI_ERROR ((AE_INFO, + "Integer too large to convert to BCD: %8.8X%8.8X", + ACPI_FORMAT_UINT64 (Operand[0]->Integer.Value))); + Status = AE_AML_NUMERIC_OVERFLOW; + goto Cleanup; + } + break; + + + case AML_COND_REF_OF_OP: /* CondRefOf (SourceObject, Result) */ + + /* + * This op is a little strange because the internal return value is + * different than the return value stored in the result descriptor + * (There are really two return values) + */ + if ((ACPI_NAMESPACE_NODE *) Operand[0] == AcpiGbl_RootNode) + { + /* + * This means that the object does not exist in the namespace, + * return FALSE + */ + ReturnDesc->Integer.Value = 0; + goto Cleanup; + } + + /* Get the object reference, store it, and remove our reference */ + + Status = AcpiExGetObjectReference (Operand[0], + &ReturnDesc2, WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + Status = AcpiExStore (ReturnDesc2, Operand[1], WalkState); + AcpiUtRemoveReference (ReturnDesc2); + + /* The object exists in the namespace, return TRUE */ + + ReturnDesc->Integer.Value = ACPI_INTEGER_MAX; + goto Cleanup; + + + default: + /* No other opcodes get here */ + break; + } + break; + + + case AML_STORE_OP: /* Store (Source, Target) */ + + /* + * A store operand is typically a number, string, buffer or lvalue + * Be careful about deleting the source object, + * since the object itself may have been stored. + */ + Status = AcpiExStore (Operand[0], Operand[1], WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* It is possible that the Store already produced a return object */ + + if (!WalkState->ResultObj) + { + /* + * Normally, we would remove a reference on the Operand[0] + * parameter; But since it is being used as the internal return + * object (meaning we would normally increment it), the two + * cancel out, and we simply don't do anything. + */ + WalkState->ResultObj = Operand[0]; + WalkState->Operands[0] = NULL; /* Prevent deletion */ + } + return_ACPI_STATUS (Status); + + + /* + * ACPI 2.0 Opcodes + */ + case AML_COPY_OP: /* Copy (Source, Target) */ + + Status = AcpiUtCopyIobjectToIobject (Operand[0], &ReturnDesc, + WalkState); + break; + + + case AML_TO_DECSTRING_OP: /* ToDecimalString (Data, Result) */ + + Status = AcpiExConvertToString (Operand[0], &ReturnDesc, + ACPI_EXPLICIT_CONVERT_DECIMAL); + if (ReturnDesc == Operand[0]) + { + /* No conversion performed, add ref to handle return value */ + AcpiUtAddReference (ReturnDesc); + } + break; + + + case AML_TO_HEXSTRING_OP: /* ToHexString (Data, Result) */ + + Status = AcpiExConvertToString (Operand[0], &ReturnDesc, + ACPI_EXPLICIT_CONVERT_HEX); + if (ReturnDesc == Operand[0]) + { + /* No conversion performed, add ref to handle return value */ + AcpiUtAddReference (ReturnDesc); + } + break; + + + case AML_TO_BUFFER_OP: /* ToBuffer (Data, Result) */ + + Status = AcpiExConvertToBuffer (Operand[0], &ReturnDesc); + if (ReturnDesc == Operand[0]) + { + /* No conversion performed, add ref to handle return value */ + AcpiUtAddReference (ReturnDesc); + } + break; + + + case AML_TO_INTEGER_OP: /* ToInteger (Data, Result) */ + + Status = AcpiExConvertToInteger (Operand[0], &ReturnDesc, + ACPI_ANY_BASE); + if (ReturnDesc == Operand[0]) + { + /* No conversion performed, add ref to handle return value */ + AcpiUtAddReference (ReturnDesc); + } + break; + + + case AML_SHIFT_LEFT_BIT_OP: /* ShiftLeftBit (Source, BitNum) */ + case AML_SHIFT_RIGHT_BIT_OP: /* ShiftRightBit (Source, BitNum) */ + + /* These are two obsolete opcodes */ + + ACPI_ERROR ((AE_INFO, + "%s is obsolete and not implemented", + AcpiPsGetOpcodeName (WalkState->Opcode))); + Status = AE_SUPPORT; + goto Cleanup; + + + default: /* Unknown opcode */ + + ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", + WalkState->Opcode)); + Status = AE_AML_BAD_OPCODE; + goto Cleanup; + } + + if (ACPI_SUCCESS (Status)) + { + /* Store the return value computed above into the target object */ + + Status = AcpiExStore (ReturnDesc, Operand[1], WalkState); + } + + +Cleanup: + + /* Delete return object on error */ + + if (ACPI_FAILURE (Status)) + { + AcpiUtRemoveReference (ReturnDesc); + } + + /* Save return object on success */ + + else if (!WalkState->ResultObj) + { + WalkState->ResultObj = ReturnDesc; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExOpcode_1A_0T_1R + * + * PARAMETERS: WalkState - Current state (contains AML opcode) + * + * RETURN: Status + * + * DESCRIPTION: Execute opcode with one argument, no target, and a return value + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExOpcode_1A_0T_1R ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; + ACPI_OPERAND_OBJECT *TempDesc; + ACPI_OPERAND_OBJECT *ReturnDesc = NULL; + ACPI_STATUS Status = AE_OK; + UINT32 Type; + ACPI_INTEGER Value; + + + ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_0T_1R, + AcpiPsGetOpcodeName (WalkState->Opcode)); + + + /* Examine the AML opcode */ + + switch (WalkState->Opcode) + { + case AML_LNOT_OP: /* LNot (Operand) */ + + ReturnDesc = AcpiUtCreateIntegerObject ((UINT64) 0); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* + * Set result to ONES (TRUE) if Value == 0. Note: + * ReturnDesc->Integer.Value is initially == 0 (FALSE) from above. + */ + if (!Operand[0]->Integer.Value) + { + ReturnDesc->Integer.Value = ACPI_INTEGER_MAX; + } + break; + + + case AML_DECREMENT_OP: /* Decrement (Operand) */ + case AML_INCREMENT_OP: /* Increment (Operand) */ + + /* + * Create a new integer. Can't just get the base integer and + * increment it because it may be an Arg or Field. + */ + ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* + * Since we are expecting a Reference operand, it can be either a + * NS Node or an internal object. + */ + TempDesc = Operand[0]; + if (ACPI_GET_DESCRIPTOR_TYPE (TempDesc) == ACPI_DESC_TYPE_OPERAND) + { + /* Internal reference object - prevent deletion */ + + AcpiUtAddReference (TempDesc); + } + + /* + * Convert the Reference operand to an Integer (This removes a + * reference on the Operand[0] object) + * + * NOTE: We use LNOT_OP here in order to force resolution of the + * reference operand to an actual integer. + */ + Status = AcpiExResolveOperands (AML_LNOT_OP, &TempDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "While resolving operands for [%s]", + AcpiPsGetOpcodeName (WalkState->Opcode))); + + goto Cleanup; + } + + /* + * TempDesc is now guaranteed to be an Integer object -- + * Perform the actual increment or decrement + */ + if (WalkState->Opcode == AML_INCREMENT_OP) + { + ReturnDesc->Integer.Value = TempDesc->Integer.Value +1; + } + else + { + ReturnDesc->Integer.Value = TempDesc->Integer.Value -1; + } + + /* Finished with this Integer object */ + + AcpiUtRemoveReference (TempDesc); + + /* + * Store the result back (indirectly) through the original + * Reference object + */ + Status = AcpiExStore (ReturnDesc, Operand[0], WalkState); + break; + + + case AML_TYPE_OP: /* ObjectType (SourceObject) */ + + /* + * Note: The operand is not resolved at this point because we want to + * get the associated object, not its value. For example, we don't + * want to resolve a FieldUnit to its value, we want the actual + * FieldUnit object. + */ + + /* Get the type of the base object */ + + Status = AcpiExResolveMultiple (WalkState, Operand[0], &Type, NULL); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* Allocate a descriptor to hold the type. */ + + ReturnDesc = AcpiUtCreateIntegerObject ((UINT64) Type); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + break; + + + case AML_SIZE_OF_OP: /* SizeOf (SourceObject) */ + + /* + * Note: The operand is not resolved at this point because we want to + * get the associated object, not its value. + */ + + /* Get the base object */ + + Status = AcpiExResolveMultiple (WalkState, + Operand[0], &Type, &TempDesc); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* + * The type of the base object must be integer, buffer, string, or + * package. All others are not supported. + * + * NOTE: Integer is not specifically supported by the ACPI spec, + * but is supported implicitly via implicit operand conversion. + * rather than bother with conversion, we just use the byte width + * global (4 or 8 bytes). + */ + switch (Type) + { + case ACPI_TYPE_INTEGER: + Value = AcpiGbl_IntegerByteWidth; + break; + + case ACPI_TYPE_STRING: + Value = TempDesc->String.Length; + break; + + case ACPI_TYPE_BUFFER: + + /* Buffer arguments may not be evaluated at this point */ + + Status = AcpiDsGetBufferArguments (TempDesc); + Value = TempDesc->Buffer.Length; + break; + + case ACPI_TYPE_PACKAGE: + + /* Package arguments may not be evaluated at this point */ + + Status = AcpiDsGetPackageArguments (TempDesc); + Value = TempDesc->Package.Count; + break; + + default: + ACPI_ERROR ((AE_INFO, + "Operand must be Buffer/Integer/String/Package - found type %s", + AcpiUtGetTypeName (Type))); + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* + * Now that we have the size of the object, create a result + * object to hold the value + */ + ReturnDesc = AcpiUtCreateIntegerObject (Value); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + break; + + + case AML_REF_OF_OP: /* RefOf (SourceObject) */ + + Status = AcpiExGetObjectReference (Operand[0], &ReturnDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + break; + + + case AML_DEREF_OF_OP: /* DerefOf (ObjReference | String) */ + + /* Check for a method local or argument, or standalone String */ + + if (ACPI_GET_DESCRIPTOR_TYPE (Operand[0]) == ACPI_DESC_TYPE_NAMED) + { + TempDesc = AcpiNsGetAttachedObject ( + (ACPI_NAMESPACE_NODE *) Operand[0]); + if (TempDesc && + ((TempDesc->Common.Type == ACPI_TYPE_STRING) || + (TempDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE))) + { + Operand[0] = TempDesc; + AcpiUtAddReference (TempDesc); + } + else + { + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + } + else + { + switch ((Operand[0])->Common.Type) + { + case ACPI_TYPE_LOCAL_REFERENCE: + /* + * This is a DerefOf (LocalX | ArgX) + * + * Must resolve/dereference the local/arg reference first + */ + switch (Operand[0]->Reference.Class) + { + case ACPI_REFCLASS_LOCAL: + case ACPI_REFCLASS_ARG: + + /* Set Operand[0] to the value of the local/arg */ + + Status = AcpiDsMethodDataGetValue ( + Operand[0]->Reference.Class, + Operand[0]->Reference.Value, + WalkState, &TempDesc); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* + * Delete our reference to the input object and + * point to the object just retrieved + */ + AcpiUtRemoveReference (Operand[0]); + Operand[0] = TempDesc; + break; + + case ACPI_REFCLASS_REFOF: + + /* Get the object to which the reference refers */ + + TempDesc = Operand[0]->Reference.Object; + AcpiUtRemoveReference (Operand[0]); + Operand[0] = TempDesc; + break; + + default: + + /* Must be an Index op - handled below */ + break; + } + break; + + case ACPI_TYPE_STRING: + break; + + default: + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + } + + if (ACPI_GET_DESCRIPTOR_TYPE (Operand[0]) != ACPI_DESC_TYPE_NAMED) + { + if ((Operand[0])->Common.Type == ACPI_TYPE_STRING) + { + /* + * This is a DerefOf (String). The string is a reference + * to a named ACPI object. + * + * 1) Find the owning Node + * 2) Dereference the node to an actual object. Could be a + * Field, so we need to resolve the node to a value. + */ + Status = AcpiNsGetNode (WalkState->ScopeInfo->Scope.Node, + Operand[0]->String.Pointer, + ACPI_NS_SEARCH_PARENT, + ACPI_CAST_INDIRECT_PTR ( + ACPI_NAMESPACE_NODE, &ReturnDesc)); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + Status = AcpiExResolveNodeToValue ( + ACPI_CAST_INDIRECT_PTR ( + ACPI_NAMESPACE_NODE, &ReturnDesc), + WalkState); + goto Cleanup; + } + } + + /* Operand[0] may have changed from the code above */ + + if (ACPI_GET_DESCRIPTOR_TYPE (Operand[0]) == ACPI_DESC_TYPE_NAMED) + { + /* + * This is a DerefOf (ObjectReference) + * Get the actual object from the Node (This is the dereference). + * This case may only happen when a LocalX or ArgX is + * dereferenced above. + */ + ReturnDesc = AcpiNsGetAttachedObject ( + (ACPI_NAMESPACE_NODE *) Operand[0]); + AcpiUtAddReference (ReturnDesc); + } + else + { + /* + * This must be a reference object produced by either the + * Index() or RefOf() operator + */ + switch (Operand[0]->Reference.Class) + { + case ACPI_REFCLASS_INDEX: + + /* + * The target type for the Index operator must be + * either a Buffer or a Package + */ + switch (Operand[0]->Reference.TargetType) + { + case ACPI_TYPE_BUFFER_FIELD: + + TempDesc = Operand[0]->Reference.Object; + + /* + * Create a new object that contains one element of the + * buffer -- the element pointed to by the index. + * + * NOTE: index into a buffer is NOT a pointer to a + * sub-buffer of the main buffer, it is only a pointer to a + * single element (byte) of the buffer! + * + * Since we are returning the value of the buffer at the + * indexed location, we don't need to add an additional + * reference to the buffer itself. + */ + ReturnDesc = AcpiUtCreateIntegerObject ((UINT64) + TempDesc->Buffer.Pointer[Operand[0]->Reference.Value]); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + break; + + + case ACPI_TYPE_PACKAGE: + + /* + * Return the referenced element of the package. We must + * add another reference to the referenced object, however. + */ + ReturnDesc = *(Operand[0]->Reference.Where); + if (ReturnDesc) + { + AcpiUtAddReference (ReturnDesc); + } + break; + + + default: + + ACPI_ERROR ((AE_INFO, + "Unknown Index TargetType %X in reference object %p", + Operand[0]->Reference.TargetType, Operand[0])); + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + break; + + + case ACPI_REFCLASS_REFOF: + + ReturnDesc = Operand[0]->Reference.Object; + + if (ACPI_GET_DESCRIPTOR_TYPE (ReturnDesc) == + ACPI_DESC_TYPE_NAMED) + { + ReturnDesc = AcpiNsGetAttachedObject ( + (ACPI_NAMESPACE_NODE *) ReturnDesc); + } + + /* Add another reference to the object! */ + + AcpiUtAddReference (ReturnDesc); + break; + + + default: + ACPI_ERROR ((AE_INFO, + "Unknown class in reference(%p) - %2.2X", + Operand[0], Operand[0]->Reference.Class)); + + Status = AE_TYPE; + goto Cleanup; + } + } + break; + + + default: + + ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", + WalkState->Opcode)); + Status = AE_AML_BAD_OPCODE; + goto Cleanup; + } + + +Cleanup: + + /* Delete return object on error */ + + if (ACPI_FAILURE (Status)) + { + AcpiUtRemoveReference (ReturnDesc); + } + + /* Save return object on success */ + + else + { + WalkState->ResultObj = ReturnDesc; + } + + return_ACPI_STATUS (Status); +} + diff --git a/reactos/drivers/bus/acpi/acpica/executer/exoparg2.c b/reactos/drivers/bus/acpi/acpica/executer/exoparg2.c new file mode 100644 index 00000000000..7c42652cc4c --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/executer/exoparg2.c @@ -0,0 +1,741 @@ +/****************************************************************************** + * + * Module Name: exoparg2 - AML execution - opcodes with 2 arguments + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __EXOPARG2_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acparser.h" +#include "acinterp.h" +#include "acevents.h" +#include "amlcode.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exoparg2") + + +/*! + * Naming convention for AML interpreter execution routines. + * + * The routines that begin execution of AML opcodes are named with a common + * convention based upon the number of arguments, the number of target operands, + * and whether or not a value is returned: + * + * AcpiExOpcode_xA_yT_zR + * + * Where: + * + * xA - ARGUMENTS: The number of arguments (input operands) that are + * required for this opcode type (1 through 6 args). + * yT - TARGETS: The number of targets (output operands) that are required + * for this opcode type (0, 1, or 2 targets). + * zR - RETURN VALUE: Indicates whether this opcode type returns a value + * as the function return (0 or 1). + * + * The AcpiExOpcode* functions are called via the Dispatcher component with + * fully resolved operands. +!*/ + + +/******************************************************************************* + * + * FUNCTION: AcpiExOpcode_2A_0T_0R + * + * PARAMETERS: WalkState - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: Execute opcode with two arguments, no target, and no return + * value. + * + * ALLOCATION: Deletes both operands + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExOpcode_2A_0T_0R ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; + ACPI_NAMESPACE_NODE *Node; + UINT32 Value; + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_0T_0R, + AcpiPsGetOpcodeName (WalkState->Opcode)); + + + /* Examine the opcode */ + + switch (WalkState->Opcode) + { + case AML_NOTIFY_OP: /* Notify (NotifyObject, NotifyValue) */ + + /* The first operand is a namespace node */ + + Node = (ACPI_NAMESPACE_NODE *) Operand[0]; + + /* Second value is the notify value */ + + Value = (UINT32) Operand[1]->Integer.Value; + + /* Are notifies allowed on this object? */ + + if (!AcpiEvIsNotifyObject (Node)) + { + ACPI_ERROR ((AE_INFO, + "Unexpected notify object type [%s]", + AcpiUtGetTypeName (Node->Type))); + + Status = AE_AML_OPERAND_TYPE; + break; + } + +#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 + * completes. The notify handlers are NOT invoked synchronously + * from this thread -- because handlers may in turn run other + * control methods. + */ + Status = AcpiEvQueueNotifyRequest (Node, Value); + break; + + + default: + + ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", + WalkState->Opcode)); + Status = AE_AML_BAD_OPCODE; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExOpcode_2A_2T_1R + * + * PARAMETERS: WalkState - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: Execute a dyadic operator (2 operands) with 2 output targets + * and one implicit return value. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExOpcode_2A_2T_1R ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; + ACPI_OPERAND_OBJECT *ReturnDesc1 = NULL; + ACPI_OPERAND_OBJECT *ReturnDesc2 = NULL; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_2T_1R, + AcpiPsGetOpcodeName (WalkState->Opcode)); + + + /* Execute the opcode */ + + switch (WalkState->Opcode) + { + case AML_DIVIDE_OP: + + /* Divide (Dividend, Divisor, RemainderResult QuotientResult) */ + + ReturnDesc1 = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + if (!ReturnDesc1) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + ReturnDesc2 = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + if (!ReturnDesc2) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Quotient to ReturnDesc1, remainder to ReturnDesc2 */ + + Status = AcpiUtDivide (Operand[0]->Integer.Value, + Operand[1]->Integer.Value, + &ReturnDesc1->Integer.Value, + &ReturnDesc2->Integer.Value); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + break; + + + default: + + ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", + WalkState->Opcode)); + Status = AE_AML_BAD_OPCODE; + goto Cleanup; + } + + /* Store the results to the target reference operands */ + + Status = AcpiExStore (ReturnDesc2, Operand[2], WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + Status = AcpiExStore (ReturnDesc1, Operand[3], WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + +Cleanup: + /* + * Since the remainder is not returned indirectly, remove a reference to + * it. Only the quotient is returned indirectly. + */ + AcpiUtRemoveReference (ReturnDesc2); + + if (ACPI_FAILURE (Status)) + { + /* Delete the return object */ + + AcpiUtRemoveReference (ReturnDesc1); + } + + /* Save return object (the remainder) on success */ + + else + { + WalkState->ResultObj = ReturnDesc1; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExOpcode_2A_1T_1R + * + * PARAMETERS: WalkState - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: Execute opcode with two arguments, one target, and a return + * value. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExOpcode_2A_1T_1R ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; + ACPI_OPERAND_OBJECT *ReturnDesc = NULL; + ACPI_INTEGER Index; + ACPI_STATUS Status = AE_OK; + ACPI_SIZE Length; + + + ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_1T_1R, + AcpiPsGetOpcodeName (WalkState->Opcode)); + + + /* Execute the opcode */ + + if (WalkState->OpInfo->Flags & AML_MATH) + { + /* All simple math opcodes (add, etc.) */ + + ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + ReturnDesc->Integer.Value = AcpiExDoMathOp (WalkState->Opcode, + Operand[0]->Integer.Value, + Operand[1]->Integer.Value); + goto StoreResultToTarget; + } + + switch (WalkState->Opcode) + { + case AML_MOD_OP: /* Mod (Dividend, Divisor, RemainderResult (ACPI 2.0) */ + + ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* ReturnDesc will contain the remainder */ + + Status = AcpiUtDivide (Operand[0]->Integer.Value, + Operand[1]->Integer.Value, + NULL, + &ReturnDesc->Integer.Value); + break; + + + case AML_CONCAT_OP: /* Concatenate (Data1, Data2, Result) */ + + Status = AcpiExDoConcatenate (Operand[0], Operand[1], + &ReturnDesc, WalkState); + break; + + + case AML_TO_STRING_OP: /* ToString (Buffer, Length, Result) (ACPI 2.0) */ + + /* + * Input object is guaranteed to be a buffer at this point (it may have + * been converted.) Copy the raw buffer data to a new object of + * type String. + */ + + /* + * Get the length of the new string. It is the smallest of: + * 1) Length of the input buffer + * 2) Max length as specified in the ToString operator + * 3) Length of input buffer up to a zero byte (null terminator) + * + * NOTE: A length of zero is ok, and will create a zero-length, null + * terminated string. + */ + Length = 0; + while ((Length < Operand[0]->Buffer.Length) && + (Length < Operand[1]->Integer.Value) && + (Operand[0]->Buffer.Pointer[Length])) + { + Length++; + } + + /* Allocate a new string object */ + + ReturnDesc = AcpiUtCreateStringObject (Length); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* + * Copy the raw buffer data with no transform. + * (NULL terminated already) + */ + ACPI_MEMCPY (ReturnDesc->String.Pointer, + Operand[0]->Buffer.Pointer, Length); + break; + + + case AML_CONCAT_RES_OP: + + /* ConcatenateResTemplate (Buffer, Buffer, Result) (ACPI 2.0) */ + + Status = AcpiExConcatTemplate (Operand[0], Operand[1], + &ReturnDesc, WalkState); + break; + + + case AML_INDEX_OP: /* Index (Source Index Result) */ + + /* Create the internal return object */ + + ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_REFERENCE); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Initialize the Index reference object */ + + Index = Operand[1]->Integer.Value; + ReturnDesc->Reference.Value = (UINT32) Index; + ReturnDesc->Reference.Class = ACPI_REFCLASS_INDEX; + + /* + * At this point, the Source operand is a String, Buffer, or Package. + * Verify that the index is within range. + */ + switch ((Operand[0])->Common.Type) + { + case ACPI_TYPE_STRING: + + if (Index >= Operand[0]->String.Length) + { + Status = AE_AML_STRING_LIMIT; + } + + ReturnDesc->Reference.TargetType = ACPI_TYPE_BUFFER_FIELD; + break; + + case ACPI_TYPE_BUFFER: + + if (Index >= Operand[0]->Buffer.Length) + { + Status = AE_AML_BUFFER_LIMIT; + } + + ReturnDesc->Reference.TargetType = ACPI_TYPE_BUFFER_FIELD; + break; + + case ACPI_TYPE_PACKAGE: + + if (Index >= Operand[0]->Package.Count) + { + Status = AE_AML_PACKAGE_LIMIT; + } + + ReturnDesc->Reference.TargetType = ACPI_TYPE_PACKAGE; + ReturnDesc->Reference.Where = &Operand[0]->Package.Elements [Index]; + break; + + default: + + Status = AE_AML_INTERNAL; + goto Cleanup; + } + + /* Failure means that the Index was beyond the end of the object */ + + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Index (%X%8.8X) is beyond end of object", + ACPI_FORMAT_UINT64 (Index))); + goto Cleanup; + } + + /* + * Save the target object and add a reference to it for the life + * of the index + */ + ReturnDesc->Reference.Object = Operand[0]; + AcpiUtAddReference (Operand[0]); + + /* Store the reference to the Target */ + + Status = AcpiExStore (ReturnDesc, Operand[2], WalkState); + + /* Return the reference */ + + WalkState->ResultObj = ReturnDesc; + goto Cleanup; + + + default: + + ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", + WalkState->Opcode)); + Status = AE_AML_BAD_OPCODE; + break; + } + + +StoreResultToTarget: + + if (ACPI_SUCCESS (Status)) + { + /* + * Store the result of the operation (which is now in ReturnDesc) into + * the Target descriptor. + */ + Status = AcpiExStore (ReturnDesc, Operand[2], WalkState); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + if (!WalkState->ResultObj) + { + WalkState->ResultObj = ReturnDesc; + } + } + + +Cleanup: + + /* Delete return object on error */ + + if (ACPI_FAILURE (Status)) + { + AcpiUtRemoveReference (ReturnDesc); + WalkState->ResultObj = NULL; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExOpcode_2A_0T_1R + * + * PARAMETERS: WalkState - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: Execute opcode with 2 arguments, no target, and a return value + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExOpcode_2A_0T_1R ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; + ACPI_OPERAND_OBJECT *ReturnDesc = NULL; + ACPI_STATUS Status = AE_OK; + BOOLEAN LogicalResult = FALSE; + + + ACPI_FUNCTION_TRACE_STR (ExOpcode_2A_0T_1R, + AcpiPsGetOpcodeName (WalkState->Opcode)); + + + /* Create the internal return object */ + + ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Execute the Opcode */ + + if (WalkState->OpInfo->Flags & AML_LOGICAL_NUMERIC) + { + /* LogicalOp (Operand0, Operand1) */ + + Status = AcpiExDoLogicalNumericOp (WalkState->Opcode, + Operand[0]->Integer.Value, Operand[1]->Integer.Value, + &LogicalResult); + goto StoreLogicalResult; + } + else if (WalkState->OpInfo->Flags & AML_LOGICAL) + { + /* LogicalOp (Operand0, Operand1) */ + + Status = AcpiExDoLogicalOp (WalkState->Opcode, Operand[0], + Operand[1], &LogicalResult); + goto StoreLogicalResult; + } + + switch (WalkState->Opcode) + { + case AML_ACQUIRE_OP: /* Acquire (MutexObject, Timeout) */ + + Status = AcpiExAcquireMutex (Operand[1], Operand[0], WalkState); + if (Status == AE_TIME) + { + LogicalResult = TRUE; /* TRUE = Acquire timed out */ + Status = AE_OK; + } + break; + + + case AML_WAIT_OP: /* Wait (EventObject, Timeout) */ + + Status = AcpiExSystemWaitEvent (Operand[1], Operand[0]); + if (Status == AE_TIME) + { + LogicalResult = TRUE; /* TRUE, Wait timed out */ + Status = AE_OK; + } + break; + + + default: + + ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", + WalkState->Opcode)); + Status = AE_AML_BAD_OPCODE; + goto Cleanup; + } + + +StoreLogicalResult: + /* + * Set return value to according to LogicalResult. logical TRUE (all ones) + * Default is FALSE (zero) + */ + if (LogicalResult) + { + ReturnDesc->Integer.Value = ACPI_INTEGER_MAX; + } + +Cleanup: + + /* Delete return object on error */ + + if (ACPI_FAILURE (Status)) + { + AcpiUtRemoveReference (ReturnDesc); + } + + /* Save return object on success */ + + else + { + WalkState->ResultObj = ReturnDesc; + } + + return_ACPI_STATUS (Status); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/executer/exoparg3.c b/reactos/drivers/bus/acpi/acpica/executer/exoparg3.c new file mode 100644 index 00000000000..591d6aceb12 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/executer/exoparg3.c @@ -0,0 +1,377 @@ + +/****************************************************************************** + * + * Module Name: exoparg3 - AML execution - opcodes with 3 arguments + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __EXOPARG3_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" +#include "acparser.h" +#include "amlcode.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exoparg3") + + +/*! + * Naming convention for AML interpreter execution routines. + * + * The routines that begin execution of AML opcodes are named with a common + * convention based upon the number of arguments, the number of target operands, + * and whether or not a value is returned: + * + * AcpiExOpcode_xA_yT_zR + * + * Where: + * + * xA - ARGUMENTS: The number of arguments (input operands) that are + * required for this opcode type (1 through 6 args). + * yT - TARGETS: The number of targets (output operands) that are required + * for this opcode type (0, 1, or 2 targets). + * zR - RETURN VALUE: Indicates whether this opcode type returns a value + * as the function return (0 or 1). + * + * The AcpiExOpcode* functions are called via the Dispatcher component with + * fully resolved operands. +!*/ + + +/******************************************************************************* + * + * FUNCTION: AcpiExOpcode_3A_0T_0R + * + * PARAMETERS: WalkState - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: Execute Triadic operator (3 operands) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExOpcode_3A_0T_0R ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; + ACPI_SIGNAL_FATAL_INFO *Fatal; + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE_STR (ExOpcode_3A_0T_0R, + AcpiPsGetOpcodeName (WalkState->Opcode)); + + + switch (WalkState->Opcode) + { + case AML_FATAL_OP: /* Fatal (FatalType FatalCode FatalArg) */ + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "FatalOp: Type %X Code %X Arg %X <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n", + (UINT32) Operand[0]->Integer.Value, + (UINT32) Operand[1]->Integer.Value, + (UINT32) Operand[2]->Integer.Value)); + + Fatal = ACPI_ALLOCATE (sizeof (ACPI_SIGNAL_FATAL_INFO)); + if (Fatal) + { + Fatal->Type = (UINT32) Operand[0]->Integer.Value; + Fatal->Code = (UINT32) Operand[1]->Integer.Value; + Fatal->Argument = (UINT32) Operand[2]->Integer.Value; + } + + /* Always signal the OS! */ + + Status = AcpiOsSignal (ACPI_SIGNAL_FATAL, Fatal); + + /* Might return while OS is shutting down, just continue */ + + ACPI_FREE (Fatal); + break; + + + default: + + ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", + WalkState->Opcode)); + Status = AE_AML_BAD_OPCODE; + goto Cleanup; + } + + +Cleanup: + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExOpcode_3A_1T_1R + * + * PARAMETERS: WalkState - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: Execute Triadic operator (3 operands) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExOpcode_3A_1T_1R ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; + ACPI_OPERAND_OBJECT *ReturnDesc = NULL; + char *Buffer = NULL; + ACPI_STATUS Status = AE_OK; + ACPI_INTEGER Index; + ACPI_SIZE Length; + + + ACPI_FUNCTION_TRACE_STR (ExOpcode_3A_1T_1R, + AcpiPsGetOpcodeName (WalkState->Opcode)); + + + switch (WalkState->Opcode) + { + case AML_MID_OP: /* Mid (Source[0], Index[1], Length[2], Result[3]) */ + + /* + * Create the return object. The Source operand is guaranteed to be + * either a String or a Buffer, so just use its type. + */ + ReturnDesc = AcpiUtCreateInternalObject ( + (Operand[0])->Common.Type); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Get the Integer values from the objects */ + + Index = Operand[1]->Integer.Value; + Length = (ACPI_SIZE) Operand[2]->Integer.Value; + + /* + * If the index is beyond the length of the String/Buffer, or if the + * requested length is zero, return a zero-length String/Buffer + */ + if (Index >= Operand[0]->String.Length) + { + Length = 0; + } + + /* Truncate request if larger than the actual String/Buffer */ + + else if ((Index + Length) > Operand[0]->String.Length) + { + Length = (ACPI_SIZE) Operand[0]->String.Length - + (ACPI_SIZE) Index; + } + + /* Strings always have a sub-pointer, not so for buffers */ + + switch ((Operand[0])->Common.Type) + { + case ACPI_TYPE_STRING: + + /* Always allocate a new buffer for the String */ + + Buffer = ACPI_ALLOCATE_ZEROED ((ACPI_SIZE) Length + 1); + if (!Buffer) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + break; + + case ACPI_TYPE_BUFFER: + + /* If the requested length is zero, don't allocate a buffer */ + + if (Length > 0) + { + /* Allocate a new buffer for the Buffer */ + + Buffer = ACPI_ALLOCATE_ZEROED (Length); + if (!Buffer) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + } + break; + + default: /* Should not happen */ + + Status = AE_AML_OPERAND_TYPE; + goto Cleanup; + } + + if (Buffer) + { + /* We have a buffer, copy the portion requested */ + + ACPI_MEMCPY (Buffer, Operand[0]->String.Pointer + Index, + Length); + } + + /* Set the length of the new String/Buffer */ + + ReturnDesc->String.Pointer = Buffer; + ReturnDesc->String.Length = (UINT32) Length; + + /* Mark buffer initialized */ + + ReturnDesc->Buffer.Flags |= AOPOBJ_DATA_VALID; + break; + + + default: + + ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", + WalkState->Opcode)); + Status = AE_AML_BAD_OPCODE; + goto Cleanup; + } + + /* Store the result in the target */ + + Status = AcpiExStore (ReturnDesc, Operand[3], WalkState); + +Cleanup: + + /* Delete return object on error */ + + if (ACPI_FAILURE (Status) || WalkState->ResultObj) + { + AcpiUtRemoveReference (ReturnDesc); + WalkState->ResultObj = NULL; + } + + /* Set the return object and exit */ + + else + { + WalkState->ResultObj = ReturnDesc; + } + return_ACPI_STATUS (Status); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/executer/exoparg6.c b/reactos/drivers/bus/acpi/acpica/executer/exoparg6.c new file mode 100644 index 00000000000..c2609471dd7 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/executer/exoparg6.c @@ -0,0 +1,438 @@ + +/****************************************************************************** + * + * Module Name: exoparg6 - AML execution - opcodes with 6 arguments + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __EXOPARG6_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" +#include "acparser.h" +#include "amlcode.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exoparg6") + + +/*! + * Naming convention for AML interpreter execution routines. + * + * The routines that begin execution of AML opcodes are named with a common + * convention based upon the number of arguments, the number of target operands, + * and whether or not a value is returned: + * + * AcpiExOpcode_xA_yT_zR + * + * Where: + * + * xA - ARGUMENTS: The number of arguments (input operands) that are + * required for this opcode type (1 through 6 args). + * yT - TARGETS: The number of targets (output operands) that are required + * for this opcode type (0, 1, or 2 targets). + * zR - RETURN VALUE: Indicates whether this opcode type returns a value + * as the function return (0 or 1). + * + * The AcpiExOpcode* functions are called via the Dispatcher component with + * fully resolved operands. +!*/ + +/* Local prototypes */ + +static BOOLEAN +AcpiExDoMatch ( + UINT32 MatchOp, + ACPI_OPERAND_OBJECT *PackageObj, + ACPI_OPERAND_OBJECT *MatchObj); + + +/******************************************************************************* + * + * FUNCTION: AcpiExDoMatch + * + * PARAMETERS: MatchOp - The AML match operand + * PackageObj - Object from the target package + * MatchObj - Object to be matched + * + * RETURN: TRUE if the match is successful, FALSE otherwise + * + * DESCRIPTION: Implements the low-level match for the ASL Match operator. + * Package elements will be implicitly converted to the type of + * the match object (Integer/Buffer/String). + * + ******************************************************************************/ + +static BOOLEAN +AcpiExDoMatch ( + UINT32 MatchOp, + ACPI_OPERAND_OBJECT *PackageObj, + ACPI_OPERAND_OBJECT *MatchObj) +{ + BOOLEAN LogicalResult = TRUE; + ACPI_STATUS Status; + + + /* + * Note: Since the PackageObj/MatchObj ordering is opposite to that of + * the standard logical operators, we have to reverse them when we call + * DoLogicalOp in order to make the implicit conversion rules work + * correctly. However, this means we have to flip the entire equation + * also. A bit ugly perhaps, but overall, better than fussing the + * parameters around at runtime, over and over again. + * + * Below, P[i] refers to the package element, M refers to the Match object. + */ + switch (MatchOp) + { + case MATCH_MTR: + + /* Always true */ + + break; + + case MATCH_MEQ: + + /* + * True if equal: (P[i] == M) + * Change to: (M == P[i]) + */ + Status = AcpiExDoLogicalOp (AML_LEQUAL_OP, MatchObj, PackageObj, + &LogicalResult); + if (ACPI_FAILURE (Status)) + { + return (FALSE); + } + break; + + case MATCH_MLE: + + /* + * True if less than or equal: (P[i] <= M) (P[i] NotGreater than M) + * Change to: (M >= P[i]) (M NotLess than P[i]) + */ + Status = AcpiExDoLogicalOp (AML_LLESS_OP, MatchObj, PackageObj, + &LogicalResult); + if (ACPI_FAILURE (Status)) + { + return (FALSE); + } + LogicalResult = (BOOLEAN) !LogicalResult; + break; + + case MATCH_MLT: + + /* + * True if less than: (P[i] < M) + * Change to: (M > P[i]) + */ + Status = AcpiExDoLogicalOp (AML_LGREATER_OP, MatchObj, PackageObj, + &LogicalResult); + if (ACPI_FAILURE (Status)) + { + return (FALSE); + } + break; + + case MATCH_MGE: + + /* + * True if greater than or equal: (P[i] >= M) (P[i] NotLess than M) + * Change to: (M <= P[i]) (M NotGreater than P[i]) + */ + Status = AcpiExDoLogicalOp (AML_LGREATER_OP, MatchObj, PackageObj, + &LogicalResult); + if (ACPI_FAILURE (Status)) + { + return (FALSE); + } + LogicalResult = (BOOLEAN)!LogicalResult; + break; + + case MATCH_MGT: + + /* + * True if greater than: (P[i] > M) + * Change to: (M < P[i]) + */ + Status = AcpiExDoLogicalOp (AML_LLESS_OP, MatchObj, PackageObj, + &LogicalResult); + if (ACPI_FAILURE (Status)) + { + return (FALSE); + } + break; + + default: + + /* Undefined */ + + return (FALSE); + } + + return LogicalResult; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExOpcode_6A_0T_1R + * + * PARAMETERS: WalkState - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: Execute opcode with 6 arguments, no target, and a return value + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExOpcode_6A_0T_1R ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0]; + ACPI_OPERAND_OBJECT *ReturnDesc = NULL; + ACPI_STATUS Status = AE_OK; + ACPI_INTEGER Index; + ACPI_OPERAND_OBJECT *ThisElement; + + + ACPI_FUNCTION_TRACE_STR (ExOpcode_6A_0T_1R, + AcpiPsGetOpcodeName (WalkState->Opcode)); + + + switch (WalkState->Opcode) + { + case AML_MATCH_OP: + /* + * Match (SearchPkg[0], MatchOp1[1], MatchObj1[2], + * MatchOp2[3], MatchObj2[4], StartIndex[5]) + */ + + /* Validate both Match Term Operators (MTR, MEQ, etc.) */ + + if ((Operand[1]->Integer.Value > MAX_MATCH_OPERATOR) || + (Operand[3]->Integer.Value > MAX_MATCH_OPERATOR)) + { + ACPI_ERROR ((AE_INFO, "Match operator out of range")); + Status = AE_AML_OPERAND_VALUE; + goto Cleanup; + } + + /* Get the package StartIndex, validate against the package length */ + + Index = Operand[5]->Integer.Value; + if (Index >= Operand[0]->Package.Count) + { + ACPI_ERROR ((AE_INFO, + "Index (%X%8.8X) beyond package end (%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_INTEGER_MAX if no match found */ + + ReturnDesc = AcpiUtCreateIntegerObject (ACPI_INTEGER_MAX); + if (!ReturnDesc) + { + Status = AE_NO_MEMORY; + goto Cleanup; + + } + + /* + * Examine each element until a match is found. Both match conditions + * must be satisfied for a match to occur. Within the loop, + * "continue" signifies that the current element does not match + * and the next should be examined. + * + * Upon finding a match, the loop will terminate via "break" at + * the bottom. If it terminates "normally", MatchValue will be + * ACPI_INTEGER_MAX (Ones) (its initial value) indicating that no + * match was found. + */ + for ( ; Index < Operand[0]->Package.Count; Index++) + { + /* Get the current package element */ + + ThisElement = Operand[0]->Package.Elements[Index]; + + /* Treat any uninitialized (NULL) elements as non-matching */ + + if (!ThisElement) + { + continue; + } + + /* + * Both match conditions must be satisfied. Execution of a continue + * (proceed to next iteration of enclosing for loop) signifies a + * non-match. + */ + if (!AcpiExDoMatch ((UINT32) Operand[1]->Integer.Value, + ThisElement, Operand[2])) + { + continue; + } + + if (!AcpiExDoMatch ((UINT32) Operand[3]->Integer.Value, + ThisElement, Operand[4])) + { + continue; + } + + /* Match found: Index is the return value */ + + ReturnDesc->Integer.Value = Index; + break; + } + break; + + + case AML_LOAD_TABLE_OP: + + Status = AcpiExLoadTableOp (WalkState, &ReturnDesc); + break; + + + default: + + ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", + WalkState->Opcode)); + Status = AE_AML_BAD_OPCODE; + goto Cleanup; + } + + +Cleanup: + + /* Delete return object on error */ + + if (ACPI_FAILURE (Status)) + { + AcpiUtRemoveReference (ReturnDesc); + } + + /* Save return object on success */ + + else + { + WalkState->ResultObj = ReturnDesc; + } + + return_ACPI_STATUS (Status); +} diff --git a/reactos/drivers/bus/acpi/acpica/executer/exprep.c b/reactos/drivers/bus/acpi/acpica/executer/exprep.c new file mode 100644 index 00000000000..c915361e810 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/executer/exprep.c @@ -0,0 +1,686 @@ + +/****************************************************************************** + * + * Module Name: exprep - ACPI AML (p-code) execution - field prep utilities + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __EXPREP_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exprep") + +/* Local prototypes */ + +static UINT32 +AcpiExDecodeFieldAccess ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT8 FieldFlags, + UINT32 *ReturnByteAlignment); + + +#ifdef ACPI_UNDER_DEVELOPMENT + +static UINT32 +AcpiExGenerateAccess ( + UINT32 FieldBitOffset, + UINT32 FieldBitLength, + UINT32 RegionLength); + +/******************************************************************************* + * + * FUNCTION: AcpiExGenerateAccess + * + * PARAMETERS: FieldBitOffset - Start of field within parent region/buffer + * FieldBitLength - Length of field in bits + * RegionLength - Length of parent in bytes + * + * RETURN: Field granularity (8, 16, 32 or 64) and + * ByteAlignment (1, 2, 3, or 4) + * + * DESCRIPTION: Generate an optimal access width for fields defined with the + * AnyAcc keyword. + * + * NOTE: Need to have the RegionLength in order to check for boundary + * conditions (end-of-region). However, the RegionLength is a deferred + * operation. Therefore, to complete this implementation, the generation + * of this access width must be deferred until the region length has + * been evaluated. + * + ******************************************************************************/ + +static UINT32 +AcpiExGenerateAccess ( + UINT32 FieldBitOffset, + UINT32 FieldBitLength, + UINT32 RegionLength) +{ + UINT32 FieldByteLength; + UINT32 FieldByteOffset; + UINT32 FieldByteEndOffset; + UINT32 AccessByteWidth; + UINT32 FieldStartOffset; + UINT32 FieldEndOffset; + UINT32 MinimumAccessWidth = 0xFFFFFFFF; + UINT32 MinimumAccesses = 0xFFFFFFFF; + UINT32 Accesses; + + + ACPI_FUNCTION_TRACE (ExGenerateAccess); + + + /* Round Field start offset and length to "minimal" byte boundaries */ + + FieldByteOffset = ACPI_DIV_8 (ACPI_ROUND_DOWN (FieldBitOffset, 8)); + FieldByteEndOffset = ACPI_DIV_8 (ACPI_ROUND_UP (FieldBitLength + + FieldBitOffset, 8)); + FieldByteLength = FieldByteEndOffset - FieldByteOffset; + + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "Bit length %d, Bit offset %d\n", + FieldBitLength, FieldBitOffset)); + + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "Byte Length %d, Byte Offset %d, End Offset %d\n", + FieldByteLength, FieldByteOffset, FieldByteEndOffset)); + + /* + * Iterative search for the maximum access width that is both aligned + * and does not go beyond the end of the region + * + * Start at ByteAcc and work upwards to QwordAcc max. (1,2,4,8 bytes) + */ + for (AccessByteWidth = 1; AccessByteWidth <= 8; AccessByteWidth <<= 1) + { + /* + * 1) Round end offset up to next access boundary and make sure that + * this does not go beyond the end of the parent region. + * 2) When the Access width is greater than the FieldByteLength, we + * are done. (This does not optimize for the perfectly aligned + * case yet). + */ + if (ACPI_ROUND_UP (FieldByteEndOffset, AccessByteWidth) <= RegionLength) + { + FieldStartOffset = + ACPI_ROUND_DOWN (FieldByteOffset, AccessByteWidth) / + AccessByteWidth; + + FieldEndOffset = + ACPI_ROUND_UP ((FieldByteLength + FieldByteOffset), + AccessByteWidth) / AccessByteWidth; + + Accesses = FieldEndOffset - FieldStartOffset; + + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "AccessWidth %d 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)); + + /* 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", + AccessByteWidth)); + return_VALUE (AccessByteWidth); + } + + /* + * Fits in the region, but requires more than one read/write. + * try the next wider access on next iteration + */ + if (Accesses < MinimumAccesses) + { + MinimumAccesses = Accesses; + MinimumAccessWidth = AccessByteWidth; + } + } + else + { + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "AccessWidth %d end is NOT within region\n", AccessByteWidth)); + if (AccessByteWidth == 1) + { + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "Field goes beyond end-of-region!\n")); + + /* Field does not fit in the region at all */ + + return_VALUE (0); + } + + /* + * This width goes beyond the end-of-region, back off to + * previous access + */ + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "Backing off to previous optimal access width of %d\n", + MinimumAccessWidth)); + return_VALUE (MinimumAccessWidth); + } + } + + /* + * Could not read/write field with one operation, + * just use max access width + */ + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "Cannot access field in one operation, using width 8\n")); + return_VALUE (8); +} +#endif /* ACPI_UNDER_DEVELOPMENT */ + + +/******************************************************************************* + * + * FUNCTION: AcpiExDecodeFieldAccess + * + * PARAMETERS: ObjDesc - Field object + * FieldFlags - Encoded fieldflags (contains access bits) + * ReturnByteAlignment - Where the byte alignment is returned + * + * RETURN: Field granularity (8, 16, 32 or 64) and + * ByteAlignment (1, 2, 3, or 4) + * + * DESCRIPTION: Decode the AccessType bits of a field definition. + * + ******************************************************************************/ + +static UINT32 +AcpiExDecodeFieldAccess ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT8 FieldFlags, + UINT32 *ReturnByteAlignment) +{ + UINT32 Access; + UINT32 ByteAlignment; + UINT32 BitLength; + + + ACPI_FUNCTION_TRACE (ExDecodeFieldAccess); + + + Access = (FieldFlags & AML_FIELD_ACCESS_TYPE_MASK); + + switch (Access) + { + case AML_FIELD_ACCESS_ANY: + +#ifdef ACPI_UNDER_DEVELOPMENT + ByteAlignment = + AcpiExGenerateAccess (ObjDesc->CommonField.StartFieldBitOffset, + ObjDesc->CommonField.BitLength, + 0xFFFFFFFF /* Temp until we pass RegionLength as parameter */); + BitLength = ByteAlignment * 8; +#endif + + ByteAlignment = 1; + BitLength = 8; + break; + + case AML_FIELD_ACCESS_BYTE: + case AML_FIELD_ACCESS_BUFFER: /* ACPI 2.0 (SMBus Buffer) */ + ByteAlignment = 1; + BitLength = 8; + break; + + case AML_FIELD_ACCESS_WORD: + ByteAlignment = 2; + BitLength = 16; + break; + + case AML_FIELD_ACCESS_DWORD: + ByteAlignment = 4; + BitLength = 32; + break; + + case AML_FIELD_ACCESS_QWORD: /* ACPI 2.0 */ + ByteAlignment = 8; + BitLength = 64; + break; + + default: + /* Invalid field access type */ + + ACPI_ERROR ((AE_INFO, + "Unknown field access type %X", + Access)); + return_UINT32 (0); + } + + if (ObjDesc->Common.Type == ACPI_TYPE_BUFFER_FIELD) + { + /* + * BufferField access can be on any byte boundary, so the + * ByteAlignment is always 1 byte -- regardless of any ByteAlignment + * implied by the field access type. + */ + ByteAlignment = 1; + } + + *ReturnByteAlignment = ByteAlignment; + return_UINT32 (BitLength); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExPrepCommonFieldObject + * + * PARAMETERS: ObjDesc - The field object + * FieldFlags - Access, LockRule, and UpdateRule. + * The format of a FieldFlag is described + * in the ACPI specification + * FieldAttribute - Special attributes (not used) + * FieldBitPosition - Field start position + * FieldBitLength - Field length in number of bits + * + * RETURN: Status + * + * DESCRIPTION: Initialize the areas of the field object that are common + * to the various types of fields. Note: This is very "sensitive" + * code because we are solving the general case for field + * alignment. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExPrepCommonFieldObject ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT8 FieldFlags, + UINT8 FieldAttribute, + UINT32 FieldBitPosition, + UINT32 FieldBitLength) +{ + UINT32 AccessBitWidth; + UINT32 ByteAlignment; + UINT32 NearestByteAddress; + + + ACPI_FUNCTION_TRACE (ExPrepCommonFieldObject); + + + /* + * Note: the structure being initialized is the + * ACPI_COMMON_FIELD_INFO; No structure fields outside of the common + * area are initialized by this procedure. + */ + ObjDesc->CommonField.FieldFlags = FieldFlags; + ObjDesc->CommonField.Attribute = FieldAttribute; + ObjDesc->CommonField.BitLength = FieldBitLength; + + /* + * Decode the access type so we can compute offsets. The access type gives + * two pieces of information - the width of each field access and the + * necessary ByteAlignment (address granularity) of the access. + * + * For AnyAcc, the AccessBitWidth is the largest width that is both + * necessary and possible in an attempt to access the whole field in one + * I/O operation. However, for AnyAcc, the ByteAlignment is always one + * byte. + * + * For all Buffer Fields, the ByteAlignment is always one byte. + * + * For all other access types (Byte, Word, Dword, Qword), the Bitwidth is + * the same (equivalent) as the ByteAlignment. + */ + AccessBitWidth = AcpiExDecodeFieldAccess (ObjDesc, FieldFlags, + &ByteAlignment); + if (!AccessBitWidth) + { + return_ACPI_STATUS (AE_AML_OPERAND_VALUE); + } + + /* Setup width (access granularity) fields */ + + ObjDesc->CommonField.AccessByteWidth = (UINT8) + ACPI_DIV_8 (AccessBitWidth); /* 1, 2, 4, 8 */ + + ObjDesc->CommonField.AccessBitWidth = (UINT8) AccessBitWidth; + + /* + * BaseByteOffset is the address of the start of the field within the + * region. It is the byte address of the first *datum* (field-width data + * unit) of the field. (i.e., the first datum that contains at least the + * first *bit* of the field.) + * + * Note: ByteAlignment is always either equal to the AccessBitWidth or 8 + * (Byte access), and it defines the addressing granularity of the parent + * region or buffer. + */ + NearestByteAddress = + ACPI_ROUND_BITS_DOWN_TO_BYTES (FieldBitPosition); + ObjDesc->CommonField.BaseByteOffset = (UINT32) + ACPI_ROUND_DOWN (NearestByteAddress, ByteAlignment); + + /* + * StartFieldBitOffset is the offset of the first bit of the field within + * a field datum. + */ + ObjDesc->CommonField.StartFieldBitOffset = (UINT8) + (FieldBitPosition - ACPI_MUL_8 (ObjDesc->CommonField.BaseByteOffset)); + + /* + * Does the entire field fit within a single field access element? (datum) + * (i.e., without crossing a datum boundary) + */ + if ((ObjDesc->CommonField.StartFieldBitOffset + FieldBitLength) <= + (UINT16) AccessBitWidth) + { + ObjDesc->Common.Flags |= AOPOBJ_SINGLE_DATUM; + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExPrepFieldValue + * + * PARAMETERS: Info - Contains all field creation info + * + * RETURN: Status + * + * DESCRIPTION: Construct an ACPI_OPERAND_OBJECT of type DefField and + * connect it to the parent Node. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExPrepFieldValue ( + ACPI_CREATE_FIELD_INFO *Info) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *SecondDesc = NULL; + UINT32 Type; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (ExPrepFieldValue); + + + /* Parameter validation */ + + if (Info->FieldType != ACPI_TYPE_LOCAL_INDEX_FIELD) + { + if (!Info->RegionNode) + { + ACPI_ERROR ((AE_INFO, "Null RegionNode")); + return_ACPI_STATUS (AE_AML_NO_OPERAND); + } + + Type = AcpiNsGetType (Info->RegionNode); + if (Type != ACPI_TYPE_REGION) + { + ACPI_ERROR ((AE_INFO, + "Needed Region, found type %X (%s)", + Type, AcpiUtGetTypeName (Type))); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + } + + /* Allocate a new field object */ + + ObjDesc = AcpiUtCreateInternalObject (Info->FieldType); + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Initialize areas of the object that are common to all fields */ + + ObjDesc->CommonField.Node = Info->FieldNode; + Status = AcpiExPrepCommonFieldObject (ObjDesc, Info->FieldFlags, + Info->Attribute, Info->FieldBitPosition, Info->FieldBitLength); + if (ACPI_FAILURE (Status)) + { + AcpiUtDeleteObjectDesc (ObjDesc); + return_ACPI_STATUS (Status); + } + + /* Initialize areas of the object that are specific to the field type */ + + switch (Info->FieldType) + { + case ACPI_TYPE_LOCAL_REGION_FIELD: + + ObjDesc->Field.RegionObj = AcpiNsGetAttachedObject (Info->RegionNode); + + /* An additional reference for the container */ + + AcpiUtAddReference (ObjDesc->Field.RegionObj); + + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "RegionField: BitOff %X, Off %X, Gran %X, Region %p\n", + ObjDesc->Field.StartFieldBitOffset, ObjDesc->Field.BaseByteOffset, + ObjDesc->Field.AccessByteWidth, ObjDesc->Field.RegionObj)); + break; + + + case ACPI_TYPE_LOCAL_BANK_FIELD: + + ObjDesc->BankField.Value = Info->BankValue; + ObjDesc->BankField.RegionObj = AcpiNsGetAttachedObject ( + Info->RegionNode); + ObjDesc->BankField.BankObj = AcpiNsGetAttachedObject ( + Info->RegisterNode); + + /* An additional reference for the attached objects */ + + AcpiUtAddReference (ObjDesc->BankField.RegionObj); + AcpiUtAddReference (ObjDesc->BankField.BankObj); + + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "Bank Field: BitOff %X, Off %X, Gran %X, Region %p, BankReg %p\n", + ObjDesc->BankField.StartFieldBitOffset, + ObjDesc->BankField.BaseByteOffset, + ObjDesc->Field.AccessByteWidth, + ObjDesc->BankField.RegionObj, + ObjDesc->BankField.BankObj)); + + /* + * Remember location in AML stream of the field unit + * opcode and operands -- since the BankValue + * operands must be evaluated. + */ + SecondDesc = ObjDesc->Common.NextObject; + SecondDesc->Extra.AmlStart = ACPI_CAST_PTR (ACPI_PARSE_OBJECT, Info->DataRegisterNode)->Named.Data; + SecondDesc->Extra.AmlLength = ACPI_CAST_PTR (ACPI_PARSE_OBJECT, Info->DataRegisterNode)->Named.Length; + + break; + + + case ACPI_TYPE_LOCAL_INDEX_FIELD: + + /* Get the Index and Data registers */ + + ObjDesc->IndexField.IndexObj = AcpiNsGetAttachedObject ( + Info->RegisterNode); + ObjDesc->IndexField.DataObj = AcpiNsGetAttachedObject ( + Info->DataRegisterNode); + + if (!ObjDesc->IndexField.DataObj || !ObjDesc->IndexField.IndexObj) + { + ACPI_ERROR ((AE_INFO, "Null Index Object during field prep")); + AcpiUtDeleteObjectDesc (ObjDesc); + return_ACPI_STATUS (AE_AML_INTERNAL); + } + + /* An additional reference for the attached objects */ + + AcpiUtAddReference (ObjDesc->IndexField.DataObj); + AcpiUtAddReference (ObjDesc->IndexField.IndexObj); + + /* + * April 2006: Changed to match MS behavior + * + * The value written to the Index register is the byte offset of the + * target field in units of the granularity of the IndexField + * + * Previously, the value was calculated as an index in terms of the + * width of the Data register, as below: + * + * ObjDesc->IndexField.Value = (UINT32) + * (Info->FieldBitPosition / ACPI_MUL_8 ( + * ObjDesc->Field.AccessByteWidth)); + * + * February 2006: Tried value as a byte offset: + * ObjDesc->IndexField.Value = (UINT32) + * ACPI_DIV_8 (Info->FieldBitPosition); + */ + ObjDesc->IndexField.Value = (UINT32) ACPI_ROUND_DOWN ( + ACPI_DIV_8 (Info->FieldBitPosition), + ObjDesc->IndexField.AccessByteWidth); + + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, + "IndexField: BitOff %X, Off %X, Value %X, Gran %X, Index %p, Data %p\n", + ObjDesc->IndexField.StartFieldBitOffset, + ObjDesc->IndexField.BaseByteOffset, + ObjDesc->IndexField.Value, + ObjDesc->Field.AccessByteWidth, + ObjDesc->IndexField.IndexObj, + ObjDesc->IndexField.DataObj)); + break; + + default: + /* No other types should get here */ + break; + } + + /* + * Store the constructed descriptor (ObjDesc) into the parent Node, + * preserving the current type of that NamedObj. + */ + Status = AcpiNsAttachObject (Info->FieldNode, ObjDesc, + AcpiNsGetType (Info->FieldNode)); + + ACPI_DEBUG_PRINT ((ACPI_DB_BFIELD, "Set NamedObj %p [%4.4s], ObjDesc %p\n", + Info->FieldNode, AcpiUtGetNodeName (Info->FieldNode), ObjDesc)); + + /* Remove local reference to the object */ + + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); +} + diff --git a/reactos/drivers/bus/acpi/acpica/executer/exregion.c b/reactos/drivers/bus/acpi/acpica/executer/exregion.c new file mode 100644 index 00000000000..5a37be25950 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/executer/exregion.c @@ -0,0 +1,630 @@ + +/****************************************************************************** + * + * Module Name: exregion - ACPI default OpRegion (address space) handlers + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __EXREGION_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exregion") + + +/******************************************************************************* + * + * FUNCTION: AcpiExSystemMemorySpaceHandler + * + * PARAMETERS: Function - Read or Write operation + * Address - Where in the space to read or write + * BitWidth - Field width in bits (8, 16, or 32) + * Value - Pointer to in or out value + * HandlerContext - Pointer to Handler's context + * RegionContext - Pointer to context specific to the + * accessed region + * + * RETURN: Status + * + * DESCRIPTION: Handler for the System Memory address space (Op Region) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExSystemMemorySpaceHandler ( + UINT32 Function, + ACPI_PHYSICAL_ADDRESS Address, + UINT32 BitWidth, + ACPI_INTEGER *Value, + void *HandlerContext, + void *RegionContext) +{ + ACPI_STATUS Status = AE_OK; + void *LogicalAddrPtr = NULL; + ACPI_MEM_SPACE_CONTEXT *MemInfo = RegionContext; + UINT32 Length; + ACPI_SIZE MapLength; + ACPI_SIZE PageBoundaryMapLength; +#ifdef ACPI_MISALIGNMENT_NOT_SUPPORTED + UINT32 Remainder; +#endif + + + ACPI_FUNCTION_TRACE (ExSystemMemorySpaceHandler); + + + /* Validate and translate the bit width */ + + switch (BitWidth) + { + case 8: + Length = 1; + break; + + case 16: + Length = 2; + break; + + case 32: + Length = 4; + break; + + case 64: + Length = 8; + break; + + default: + ACPI_ERROR ((AE_INFO, "Invalid SystemMemory width %d", + BitWidth)); + return_ACPI_STATUS (AE_AML_OPERAND_VALUE); + } + +#ifdef ACPI_MISALIGNMENT_NOT_SUPPORTED + /* + * Hardware does not support non-aligned data transfers, we must verify + * the request. + */ + (void) AcpiUtShortDivide ((ACPI_INTEGER) Address, Length, NULL, &Remainder); + if (Remainder != 0) + { + return_ACPI_STATUS (AE_AML_ALIGNMENT); + } +#endif + + /* + * Does the request fit into the cached memory mapping? + * Is 1) Address below the current mapping? OR + * 2) Address beyond the current mapping? + */ + if ((Address < MemInfo->MappedPhysicalAddress) || + (((ACPI_INTEGER) Address + Length) > + ((ACPI_INTEGER) + MemInfo->MappedPhysicalAddress + MemInfo->MappedLength))) + { + /* + * The request cannot be resolved by the current memory mapping; + * Delete the existing mapping and create a new one. + */ + if (MemInfo->MappedLength) + { + /* Valid mapping, delete it */ + + AcpiOsUnmapMemory (MemInfo->MappedLogicalAddress, + MemInfo->MappedLength); + } + + /* + * October 2009: Attempt to map from the requested address to the + * end of the region. However, we will never map more than one + * page, nor will we cross a page boundary. + */ + MapLength = (ACPI_SIZE) + ((MemInfo->Address + MemInfo->Length) - Address); + + /* + * If mapping the entire remaining portion of the region will cross + * a page boundary, just map up to the page boundary, do not cross. + * On some systems, crossing a page boundary while mapping regions + * can cause warnings if the pages have different attributes + * due to resource management. + * + * This has the added benefit of constraining a single mapping to + * one page, which is similar to the original code that used a 4k + * maximum window. + */ + PageBoundaryMapLength = + ACPI_ROUND_UP (Address, ACPI_DEFAULT_PAGE_SIZE) - Address; + if (PageBoundaryMapLength == 0) + { + PageBoundaryMapLength = ACPI_DEFAULT_PAGE_SIZE; + } + + if (MapLength > PageBoundaryMapLength) + { + MapLength = PageBoundaryMapLength; + } + + /* Create a new mapping starting at the address given */ + + MemInfo->MappedLogicalAddress = AcpiOsMapMemory ( + (ACPI_PHYSICAL_ADDRESS) Address, MapLength); + if (!MemInfo->MappedLogicalAddress) + { + ACPI_ERROR ((AE_INFO, + "Could not map memory at %8.8X%8.8X, size %X", + ACPI_FORMAT_NATIVE_UINT (Address), (UINT32) MapLength)); + MemInfo->MappedLength = 0; + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Save the physical address and mapping size */ + + MemInfo->MappedPhysicalAddress = Address; + MemInfo->MappedLength = MapLength; + } + + /* + * Generate a logical pointer corresponding to the address we want to + * access + */ + LogicalAddrPtr = MemInfo->MappedLogicalAddress + + ((ACPI_INTEGER) Address - (ACPI_INTEGER) MemInfo->MappedPhysicalAddress); + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "System-Memory (width %d) R/W %d Address=%8.8X%8.8X\n", + BitWidth, Function, ACPI_FORMAT_NATIVE_UINT (Address))); + + /* + * Perform the memory read or write + * + * Note: For machines that do not support non-aligned transfers, the target + * address was checked for alignment above. We do not attempt to break the + * transfer up into smaller (byte-size) chunks because the AML specifically + * asked for a transfer width that the hardware may require. + */ + switch (Function) + { + case ACPI_READ: + + *Value = 0; + switch (BitWidth) + { + case 8: + *Value = (ACPI_INTEGER) ACPI_GET8 (LogicalAddrPtr); + break; + + case 16: + *Value = (ACPI_INTEGER) ACPI_GET16 (LogicalAddrPtr); + break; + + case 32: + *Value = (ACPI_INTEGER) ACPI_GET32 (LogicalAddrPtr); + break; + + case 64: + *Value = (ACPI_INTEGER) ACPI_GET64 (LogicalAddrPtr); + break; + + default: + /* BitWidth was already validated */ + break; + } + break; + + case ACPI_WRITE: + + switch (BitWidth) + { + case 8: + ACPI_SET8 (LogicalAddrPtr) = (UINT8) *Value; + break; + + case 16: + ACPI_SET16 (LogicalAddrPtr) = (UINT16) *Value; + break; + + case 32: + ACPI_SET32 ( LogicalAddrPtr) = (UINT32) *Value; + break; + + case 64: + ACPI_SET64 (LogicalAddrPtr) = (UINT64) *Value; + break; + + default: + /* BitWidth was already validated */ + break; + } + break; + + default: + Status = AE_BAD_PARAMETER; + break; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExSystemIoSpaceHandler + * + * PARAMETERS: Function - Read or Write operation + * Address - Where in the space to read or write + * BitWidth - Field width in bits (8, 16, or 32) + * Value - Pointer to in or out value + * HandlerContext - Pointer to Handler's context + * RegionContext - Pointer to context specific to the + * accessed region + * + * RETURN: Status + * + * DESCRIPTION: Handler for the System IO address space (Op Region) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExSystemIoSpaceHandler ( + UINT32 Function, + ACPI_PHYSICAL_ADDRESS Address, + UINT32 BitWidth, + ACPI_INTEGER *Value, + void *HandlerContext, + void *RegionContext) +{ + ACPI_STATUS Status = AE_OK; + UINT32 Value32; + + + ACPI_FUNCTION_TRACE (ExSystemIoSpaceHandler); + + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "System-IO (width %d) R/W %d Address=%8.8X%8.8X\n", + BitWidth, Function, ACPI_FORMAT_NATIVE_UINT (Address))); + + /* Decode the function parameter */ + + switch (Function) + { + case ACPI_READ: + + Status = AcpiHwReadPort ((ACPI_IO_ADDRESS) Address, + &Value32, BitWidth); + *Value = Value32; + break; + + case ACPI_WRITE: + + Status = AcpiHwWritePort ((ACPI_IO_ADDRESS) Address, + (UINT32) *Value, BitWidth); + break; + + default: + Status = AE_BAD_PARAMETER; + break; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExPciConfigSpaceHandler + * + * PARAMETERS: Function - Read or Write operation + * Address - Where in the space to read or write + * BitWidth - Field width in bits (8, 16, or 32) + * Value - Pointer to in or out value + * HandlerContext - Pointer to Handler's context + * RegionContext - Pointer to context specific to the + * accessed region + * + * RETURN: Status + * + * DESCRIPTION: Handler for the PCI Config address space (Op Region) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExPciConfigSpaceHandler ( + UINT32 Function, + ACPI_PHYSICAL_ADDRESS Address, + UINT32 BitWidth, + ACPI_INTEGER *Value, + void *HandlerContext, + void *RegionContext) +{ + ACPI_STATUS Status = AE_OK; + ACPI_PCI_ID *PciId; + UINT16 PciRegister; + + + ACPI_FUNCTION_TRACE (ExPciConfigSpaceHandler); + + + /* + * The arguments to AcpiOs(Read|Write)PciConfiguration are: + * + * PciSegment is the PCI bus segment range 0-31 + * PciBus is the PCI bus number range 0-255 + * PciDevice is the PCI device number range 0-31 + * PciFunction is the PCI device function number + * PciRegister is the Config space register range 0-255 bytes + * + * Value - input value for write, output address for read + * + */ + PciId = (ACPI_PCI_ID *) RegionContext; + PciRegister = (UINT16) (UINT32) Address; + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Pci-Config %d (%d) Seg(%04x) Bus(%04x) Dev(%04x) Func(%04x) Reg(%04x)\n", + Function, BitWidth, PciId->Segment, PciId->Bus, PciId->Device, + PciId->Function, PciRegister)); + + switch (Function) + { + case ACPI_READ: + + *Value = 0; + Status = AcpiOsReadPciConfiguration (PciId, PciRegister, + Value, BitWidth); + break; + + case ACPI_WRITE: + + Status = AcpiOsWritePciConfiguration (PciId, PciRegister, + *Value, BitWidth); + break; + + default: + + Status = AE_BAD_PARAMETER; + break; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExCmosSpaceHandler + * + * PARAMETERS: Function - Read or Write operation + * Address - Where in the space to read or write + * BitWidth - Field width in bits (8, 16, or 32) + * Value - Pointer to in or out value + * HandlerContext - Pointer to Handler's context + * RegionContext - Pointer to context specific to the + * accessed region + * + * RETURN: Status + * + * DESCRIPTION: Handler for the CMOS address space (Op Region) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExCmosSpaceHandler ( + UINT32 Function, + ACPI_PHYSICAL_ADDRESS Address, + UINT32 BitWidth, + ACPI_INTEGER *Value, + void *HandlerContext, + void *RegionContext) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (ExCmosSpaceHandler); + + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExPciBarSpaceHandler + * + * PARAMETERS: Function - Read or Write operation + * Address - Where in the space to read or write + * BitWidth - Field width in bits (8, 16, or 32) + * Value - Pointer to in or out value + * HandlerContext - Pointer to Handler's context + * RegionContext - Pointer to context specific to the + * accessed region + * + * RETURN: Status + * + * DESCRIPTION: Handler for the PCI BarTarget address space (Op Region) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExPciBarSpaceHandler ( + UINT32 Function, + ACPI_PHYSICAL_ADDRESS Address, + UINT32 BitWidth, + ACPI_INTEGER *Value, + void *HandlerContext, + void *RegionContext) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (ExPciBarSpaceHandler); + + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExDataTableSpaceHandler + * + * PARAMETERS: Function - Read or Write operation + * Address - Where in the space to read or write + * BitWidth - Field width in bits (8, 16, or 32) + * Value - Pointer to in or out value + * HandlerContext - Pointer to Handler's context + * RegionContext - Pointer to context specific to the + * accessed region + * + * RETURN: Status + * + * DESCRIPTION: Handler for the Data Table address space (Op Region) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExDataTableSpaceHandler ( + UINT32 Function, + ACPI_PHYSICAL_ADDRESS Address, + UINT32 BitWidth, + ACPI_INTEGER *Value, + void *HandlerContext, + void *RegionContext) +{ + ACPI_FUNCTION_TRACE (ExDataTableSpaceHandler); + + + /* Perform the memory read or write */ + + switch (Function) + { + case ACPI_READ: + + ACPI_MEMCPY (ACPI_CAST_PTR (char, Value), ACPI_PHYSADDR_TO_PTR (Address), + ACPI_DIV_8 (BitWidth)); + break; + + case ACPI_WRITE: + default: + + return_ACPI_STATUS (AE_SUPPORT); + } + + return_ACPI_STATUS (AE_OK); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/executer/exresnte.c b/reactos/drivers/bus/acpi/acpica/executer/exresnte.c new file mode 100644 index 00000000000..5481bc899a8 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/executer/exresnte.c @@ -0,0 +1,374 @@ + +/****************************************************************************** + * + * Module Name: exresnte - AML Interpreter object resolution + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __EXRESNTE_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acdispat.h" +#include "acinterp.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exresnte") + + +/******************************************************************************* + * + * FUNCTION: AcpiExResolveNodeToValue + * + * PARAMETERS: ObjectPtr - Pointer to a location that contains + * a pointer to a NS node, and will receive a + * pointer to the resolved object. + * WalkState - Current state. Valid only if executing AML + * code. NULL if simply resolving an object + * + * RETURN: Status + * + * DESCRIPTION: Resolve a Namespace node to a valued object + * + * Note: for some of the data types, the pointer attached to the Node + * can be either a pointer to an actual internal object or a pointer into the + * AML stream itself. These types are currently: + * + * ACPI_TYPE_INTEGER + * ACPI_TYPE_STRING + * ACPI_TYPE_BUFFER + * ACPI_TYPE_MUTEX + * ACPI_TYPE_PACKAGE + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExResolveNodeToValue ( + ACPI_NAMESPACE_NODE **ObjectPtr, + ACPI_WALK_STATE *WalkState) + +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT *SourceDesc; + ACPI_OPERAND_OBJECT *ObjDesc = NULL; + ACPI_NAMESPACE_NODE *Node; + ACPI_OBJECT_TYPE EntryType; + + + ACPI_FUNCTION_TRACE (ExResolveNodeToValue); + + + /* + * The stack pointer points to a ACPI_NAMESPACE_NODE (Node). Get the + * object that is attached to the Node. + */ + Node = *ObjectPtr; + SourceDesc = AcpiNsGetAttachedObject (Node); + EntryType = AcpiNsGetType ((ACPI_HANDLE) Node); + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Entry=%p SourceDesc=%p [%s]\n", + Node, SourceDesc, AcpiUtGetTypeName (EntryType))); + + if ((EntryType == ACPI_TYPE_LOCAL_ALIAS) || + (EntryType == ACPI_TYPE_LOCAL_METHOD_ALIAS)) + { + /* There is always exactly one level of indirection */ + + Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Node->Object); + SourceDesc = AcpiNsGetAttachedObject (Node); + EntryType = AcpiNsGetType ((ACPI_HANDLE) Node); + *ObjectPtr = Node; + } + + /* + * Several object types require no further processing: + * 1) Device/Thermal objects don't have a "real" subobject, return the Node + * 2) Method locals and arguments have a pseudo-Node + * 3) 10/2007: Added method type to assist with Package construction. + */ + if ((EntryType == ACPI_TYPE_DEVICE) || + (EntryType == ACPI_TYPE_THERMAL) || + (EntryType == ACPI_TYPE_METHOD) || + (Node->Flags & (ANOBJ_METHOD_ARG | ANOBJ_METHOD_LOCAL))) + { + return_ACPI_STATUS (AE_OK); + } + + if (!SourceDesc) + { + ACPI_ERROR ((AE_INFO, "No object attached to node %p", + Node)); + return_ACPI_STATUS (AE_AML_NO_OPERAND); + } + + /* + * Action is based on the type of the Node, which indicates the type + * of the attached object or pointer + */ + switch (EntryType) + { + case ACPI_TYPE_PACKAGE: + + if (SourceDesc->Common.Type != ACPI_TYPE_PACKAGE) + { + ACPI_ERROR ((AE_INFO, "Object not a Package, type %s", + AcpiUtGetObjectTypeName (SourceDesc))); + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + Status = AcpiDsGetPackageArguments (SourceDesc); + if (ACPI_SUCCESS (Status)) + { + /* Return an additional reference to the object */ + + ObjDesc = SourceDesc; + AcpiUtAddReference (ObjDesc); + } + break; + + + case ACPI_TYPE_BUFFER: + + if (SourceDesc->Common.Type != ACPI_TYPE_BUFFER) + { + ACPI_ERROR ((AE_INFO, "Object not a Buffer, type %s", + AcpiUtGetObjectTypeName (SourceDesc))); + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + Status = AcpiDsGetBufferArguments (SourceDesc); + if (ACPI_SUCCESS (Status)) + { + /* Return an additional reference to the object */ + + ObjDesc = SourceDesc; + AcpiUtAddReference (ObjDesc); + } + break; + + + case ACPI_TYPE_STRING: + + if (SourceDesc->Common.Type != ACPI_TYPE_STRING) + { + ACPI_ERROR ((AE_INFO, "Object not a String, type %s", + AcpiUtGetObjectTypeName (SourceDesc))); + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* Return an additional reference to the object */ + + ObjDesc = SourceDesc; + AcpiUtAddReference (ObjDesc); + break; + + + case ACPI_TYPE_INTEGER: + + if (SourceDesc->Common.Type != ACPI_TYPE_INTEGER) + { + ACPI_ERROR ((AE_INFO, "Object not a Integer, type %s", + AcpiUtGetObjectTypeName (SourceDesc))); + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* Return an additional reference to the object */ + + ObjDesc = SourceDesc; + AcpiUtAddReference (ObjDesc); + break; + + + case ACPI_TYPE_BUFFER_FIELD: + case ACPI_TYPE_LOCAL_REGION_FIELD: + case ACPI_TYPE_LOCAL_BANK_FIELD: + case ACPI_TYPE_LOCAL_INDEX_FIELD: + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "FieldRead Node=%p SourceDesc=%p Type=%X\n", + Node, SourceDesc, EntryType)); + + Status = AcpiExReadDataFromField (WalkState, SourceDesc, &ObjDesc); + break; + + /* For these objects, just return the object attached to the Node */ + + case ACPI_TYPE_MUTEX: + case ACPI_TYPE_POWER: + case ACPI_TYPE_PROCESSOR: + case ACPI_TYPE_EVENT: + case ACPI_TYPE_REGION: + + /* Return an additional reference to the object */ + + ObjDesc = SourceDesc; + AcpiUtAddReference (ObjDesc); + break; + + /* TYPE_ANY is untyped, and thus there is no object associated with it */ + + case ACPI_TYPE_ANY: + + ACPI_ERROR ((AE_INFO, + "Untyped entry %p, no attached object!", Node)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); /* Cannot be AE_TYPE */ + + + case ACPI_TYPE_LOCAL_REFERENCE: + + switch (SourceDesc->Reference.Class) + { + case ACPI_REFCLASS_TABLE: /* This is a DdbHandle */ + case ACPI_REFCLASS_REFOF: + case ACPI_REFCLASS_INDEX: + + /* Return an additional reference to the object */ + + ObjDesc = SourceDesc; + AcpiUtAddReference (ObjDesc); + break; + + default: + /* No named references are allowed here */ + + ACPI_ERROR ((AE_INFO, + "Unsupported Reference type %X", + SourceDesc->Reference.Class)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + break; + + + default: + + /* Default case is for unknown types */ + + ACPI_ERROR ((AE_INFO, + "Node %p - Unknown object type %X", + Node, EntryType)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + + } /* switch (EntryType) */ + + + /* Return the object descriptor */ + + *ObjectPtr = (void *) ObjDesc; + return_ACPI_STATUS (Status); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/executer/exresolv.c b/reactos/drivers/bus/acpi/acpica/executer/exresolv.c new file mode 100644 index 00000000000..a3c8ab9b5ce --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/executer/exresolv.c @@ -0,0 +1,652 @@ + +/****************************************************************************** + * + * Module Name: exresolv - AML Interpreter object resolution + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __EXRESOLV_C__ + +#include "acpi.h" +#include "accommon.h" +#include "amlcode.h" +#include "acdispat.h" +#include "acinterp.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exresolv") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiExResolveObjectToValue ( + ACPI_OPERAND_OBJECT **StackPtr, + ACPI_WALK_STATE *WalkState); + + +/******************************************************************************* + * + * FUNCTION: AcpiExResolveToValue + * + * PARAMETERS: **StackPtr - Points to entry on ObjStack, which can + * be either an (ACPI_OPERAND_OBJECT *) + * or an ACPI_HANDLE. + * WalkState - Current method state + * + * RETURN: Status + * + * DESCRIPTION: Convert Reference objects to values + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExResolveToValue ( + ACPI_OPERAND_OBJECT **StackPtr, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE_PTR (ExResolveToValue, StackPtr); + + + if (!StackPtr || !*StackPtr) + { + ACPI_ERROR ((AE_INFO, "Internal - null pointer")); + return_ACPI_STATUS (AE_AML_NO_OPERAND); + } + + /* + * The entity pointed to by the StackPtr can be either + * 1) A valid ACPI_OPERAND_OBJECT, or + * 2) A ACPI_NAMESPACE_NODE (NamedObj) + */ + if (ACPI_GET_DESCRIPTOR_TYPE (*StackPtr) == ACPI_DESC_TYPE_OPERAND) + { + Status = AcpiExResolveObjectToValue (StackPtr, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (!*StackPtr) + { + ACPI_ERROR ((AE_INFO, "Internal - null pointer")); + return_ACPI_STATUS (AE_AML_NO_OPERAND); + } + } + + /* + * Object on the stack may have changed if AcpiExResolveObjectToValue() + * was called (i.e., we can't use an _else_ here.) + */ + if (ACPI_GET_DESCRIPTOR_TYPE (*StackPtr) == ACPI_DESC_TYPE_NAMED) + { + Status = AcpiExResolveNodeToValue ( + ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, StackPtr), + WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Resolved object %p\n", *StackPtr)); + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExResolveObjectToValue + * + * PARAMETERS: StackPtr - Pointer to an internal object + * WalkState - Current method state + * + * RETURN: Status + * + * DESCRIPTION: Retrieve the value from an internal object. The Reference type + * uses the associated AML opcode to determine the value. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiExResolveObjectToValue ( + ACPI_OPERAND_OBJECT **StackPtr, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT *StackDesc; + ACPI_OPERAND_OBJECT *ObjDesc = NULL; + UINT8 RefType; + + + ACPI_FUNCTION_TRACE (ExResolveObjectToValue); + + + StackDesc = *StackPtr; + + /* This is an ACPI_OPERAND_OBJECT */ + + switch (StackDesc->Common.Type) + { + case ACPI_TYPE_LOCAL_REFERENCE: + + RefType = StackDesc->Reference.Class; + + switch (RefType) + { + case ACPI_REFCLASS_LOCAL: + case ACPI_REFCLASS_ARG: + + /* + * Get the local from the method's state info + * Note: this increments the local's object reference count + */ + Status = AcpiDsMethodDataGetValue (RefType, + StackDesc->Reference.Value, WalkState, &ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Arg/Local %X] ValueObj is %p\n", + StackDesc->Reference.Value, ObjDesc)); + + /* + * Now we can delete the original Reference Object and + * replace it with the resolved value + */ + AcpiUtRemoveReference (StackDesc); + *StackPtr = ObjDesc; + break; + + + case ACPI_REFCLASS_INDEX: + + switch (StackDesc->Reference.TargetType) + { + case ACPI_TYPE_BUFFER_FIELD: + + /* Just return - do not dereference */ + break; + + + case ACPI_TYPE_PACKAGE: + + /* If method call or CopyObject - do not dereference */ + + if ((WalkState->Opcode == AML_INT_METHODCALL_OP) || + (WalkState->Opcode == AML_COPY_OP)) + { + break; + } + + /* Otherwise, dereference the PackageIndex to a package element */ + + ObjDesc = *StackDesc->Reference.Where; + if (ObjDesc) + { + /* + * Valid object descriptor, copy pointer to return value + * (i.e., dereference the package index) + * Delete the ref object, increment the returned object + */ + AcpiUtRemoveReference (StackDesc); + AcpiUtAddReference (ObjDesc); + *StackPtr = ObjDesc; + } + else + { + /* + * A NULL object descriptor means an uninitialized element of + * the package, can't dereference it + */ + ACPI_ERROR ((AE_INFO, + "Attempt to dereference an Index to NULL package element Idx=%p", + StackDesc)); + Status = AE_AML_UNINITIALIZED_ELEMENT; + } + break; + + + default: + + /* Invalid reference object */ + + ACPI_ERROR ((AE_INFO, + "Unknown TargetType %X in Index/Reference object %p", + StackDesc->Reference.TargetType, StackDesc)); + Status = AE_AML_INTERNAL; + break; + } + break; + + + case ACPI_REFCLASS_REFOF: + case ACPI_REFCLASS_DEBUG: + case ACPI_REFCLASS_TABLE: + + /* Just leave the object as-is, do not dereference */ + + break; + + case ACPI_REFCLASS_NAME: /* Reference to a named object */ + + /* Dereference the name */ + + if ((StackDesc->Reference.Node->Type == ACPI_TYPE_DEVICE) || + (StackDesc->Reference.Node->Type == ACPI_TYPE_THERMAL)) + { + /* These node types do not have 'real' subobjects */ + + *StackPtr = (void *) StackDesc->Reference.Node; + } + else + { + /* Get the object pointed to by the namespace node */ + + *StackPtr = (StackDesc->Reference.Node)->Object; + AcpiUtAddReference (*StackPtr); + } + + AcpiUtRemoveReference (StackDesc); + break; + + default: + + ACPI_ERROR ((AE_INFO, + "Unknown Reference type %X in %p", RefType, StackDesc)); + Status = AE_AML_INTERNAL; + break; + } + break; + + + case ACPI_TYPE_BUFFER: + + Status = AcpiDsGetBufferArguments (StackDesc); + break; + + + case ACPI_TYPE_PACKAGE: + + Status = AcpiDsGetPackageArguments (StackDesc); + break; + + + case ACPI_TYPE_BUFFER_FIELD: + case ACPI_TYPE_LOCAL_REGION_FIELD: + case ACPI_TYPE_LOCAL_BANK_FIELD: + case ACPI_TYPE_LOCAL_INDEX_FIELD: + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "FieldRead SourceDesc=%p Type=%X\n", + StackDesc, StackDesc->Common.Type)); + + Status = AcpiExReadDataFromField (WalkState, StackDesc, &ObjDesc); + + /* Remove a reference to the original operand, then override */ + + AcpiUtRemoveReference (*StackPtr); + *StackPtr = (void *) ObjDesc; + break; + + default: + break; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExResolveMultiple + * + * PARAMETERS: WalkState - Current state (contains AML opcode) + * Operand - Starting point for resolution + * ReturnType - Where the object type is returned + * ReturnDesc - Where the resolved object is returned + * + * RETURN: Status + * + * DESCRIPTION: Return the base object and type. Traverse a reference list if + * necessary to get to the base object. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExResolveMultiple ( + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT *Operand, + ACPI_OBJECT_TYPE *ReturnType, + ACPI_OPERAND_OBJECT **ReturnDesc) +{ + ACPI_OPERAND_OBJECT *ObjDesc = (void *) Operand; + ACPI_NAMESPACE_NODE *Node; + ACPI_OBJECT_TYPE Type; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiExResolveMultiple); + + + /* Operand can be either a namespace node or an operand descriptor */ + + switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc)) + { + case ACPI_DESC_TYPE_OPERAND: + Type = ObjDesc->Common.Type; + break; + + case ACPI_DESC_TYPE_NAMED: + Type = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type; + ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ObjDesc); + + /* If we had an Alias node, use the attached object for type info */ + + if (Type == ACPI_TYPE_LOCAL_ALIAS) + { + Type = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type; + ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ObjDesc); + } + break; + + default: + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* If type is anything other than a reference, we are done */ + + if (Type != ACPI_TYPE_LOCAL_REFERENCE) + { + goto Exit; + } + + /* + * For reference objects created via the RefOf, Index, or Load/LoadTable + * operators, we need to get to the base object (as per the ACPI + * specification of the ObjectType and SizeOf operators). This means + * traversing the list of possibly many nested references. + */ + while (ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) + { + switch (ObjDesc->Reference.Class) + { + case ACPI_REFCLASS_REFOF: + case ACPI_REFCLASS_NAME: + + /* Dereference the reference pointer */ + + if (ObjDesc->Reference.Class == ACPI_REFCLASS_REFOF) + { + Node = ObjDesc->Reference.Object; + } + else /* AML_INT_NAMEPATH_OP */ + { + Node = ObjDesc->Reference.Node; + } + + /* All "References" point to a NS node */ + + if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED) + { + ACPI_ERROR ((AE_INFO, + "Not a NS node %p [%s]", + Node, AcpiUtGetDescriptorName (Node))); + return_ACPI_STATUS (AE_AML_INTERNAL); + } + + /* Get the attached object */ + + ObjDesc = AcpiNsGetAttachedObject (Node); + if (!ObjDesc) + { + /* No object, use the NS node type */ + + Type = AcpiNsGetType (Node); + goto Exit; + } + + /* Check for circular references */ + + if (ObjDesc == Operand) + { + return_ACPI_STATUS (AE_AML_CIRCULAR_REFERENCE); + } + break; + + + case ACPI_REFCLASS_INDEX: + + /* Get the type of this reference (index into another object) */ + + Type = ObjDesc->Reference.TargetType; + if (Type != ACPI_TYPE_PACKAGE) + { + goto Exit; + } + + /* + * The main object is a package, we want to get the type + * of the individual package element that is referenced by + * the index. + * + * This could of course in turn be another reference object. + */ + ObjDesc = *(ObjDesc->Reference.Where); + if (!ObjDesc) + { + /* NULL package elements are allowed */ + + Type = 0; /* Uninitialized */ + goto Exit; + } + break; + + + case ACPI_REFCLASS_TABLE: + + Type = ACPI_TYPE_DDB_HANDLE; + goto Exit; + + + case ACPI_REFCLASS_LOCAL: + case ACPI_REFCLASS_ARG: + + if (ReturnDesc) + { + Status = AcpiDsMethodDataGetValue (ObjDesc->Reference.Class, + ObjDesc->Reference.Value, WalkState, &ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + AcpiUtRemoveReference (ObjDesc); + } + else + { + Status = AcpiDsMethodDataGetNode (ObjDesc->Reference.Class, + ObjDesc->Reference.Value, WalkState, &Node); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + ObjDesc = AcpiNsGetAttachedObject (Node); + if (!ObjDesc) + { + Type = ACPI_TYPE_ANY; + goto Exit; + } + } + break; + + + case ACPI_REFCLASS_DEBUG: + + /* The Debug Object is of type "DebugObject" */ + + Type = ACPI_TYPE_DEBUG_OBJECT; + goto Exit; + + + default: + + ACPI_ERROR ((AE_INFO, + "Unknown Reference Class %2.2X", ObjDesc->Reference.Class)); + return_ACPI_STATUS (AE_AML_INTERNAL); + } + } + + /* + * Now we are guaranteed to have an object that has not been created + * via the RefOf or Index operators. + */ + Type = ObjDesc->Common.Type; + + +Exit: + /* Convert internal types to external types */ + + switch (Type) + { + case ACPI_TYPE_LOCAL_REGION_FIELD: + case ACPI_TYPE_LOCAL_BANK_FIELD: + case ACPI_TYPE_LOCAL_INDEX_FIELD: + + Type = ACPI_TYPE_FIELD_UNIT; + break; + + case ACPI_TYPE_LOCAL_SCOPE: + + /* Per ACPI Specification, Scope is untyped */ + + Type = ACPI_TYPE_ANY; + break; + + default: + /* No change to Type required */ + break; + } + + *ReturnType = Type; + if (ReturnDesc) + { + *ReturnDesc = ObjDesc; + } + return_ACPI_STATUS (AE_OK); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/executer/exresop.c b/reactos/drivers/bus/acpi/acpica/executer/exresop.c new file mode 100644 index 00000000000..ecc63f61357 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/executer/exresop.c @@ -0,0 +1,810 @@ + +/****************************************************************************** + * + * Module Name: exresop - AML Interpreter operand/object resolution + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __EXRESOP_C__ + +#include "acpi.h" +#include "accommon.h" +#include "amlcode.h" +#include "acparser.h" +#include "acinterp.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exresop") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiExCheckObjectType ( + ACPI_OBJECT_TYPE TypeNeeded, + ACPI_OBJECT_TYPE ThisType, + void *Object); + + +/******************************************************************************* + * + * FUNCTION: AcpiExCheckObjectType + * + * PARAMETERS: TypeNeeded Object type needed + * ThisType Actual object type + * Object Object pointer + * + * RETURN: Status + * + * DESCRIPTION: Check required type against actual type + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiExCheckObjectType ( + ACPI_OBJECT_TYPE TypeNeeded, + ACPI_OBJECT_TYPE ThisType, + void *Object) +{ + ACPI_FUNCTION_ENTRY (); + + + if (TypeNeeded == ACPI_TYPE_ANY) + { + /* All types OK, so we don't perform any typechecks */ + + return (AE_OK); + } + + if (TypeNeeded == ACPI_TYPE_LOCAL_REFERENCE) + { + /* + * Allow the AML "Constant" opcodes (Zero, One, etc.) to be reference + * objects and thus allow them to be targets. (As per the ACPI + * specification, a store to a constant is a noop.) + */ + if ((ThisType == ACPI_TYPE_INTEGER) && + (((ACPI_OPERAND_OBJECT *) Object)->Common.Flags & AOPOBJ_AML_CONSTANT)) + { + return (AE_OK); + } + } + + if (TypeNeeded != ThisType) + { + ACPI_ERROR ((AE_INFO, + "Needed type [%s], found [%s] %p", + AcpiUtGetTypeName (TypeNeeded), + AcpiUtGetTypeName (ThisType), Object)); + + return (AE_AML_OPERAND_TYPE); + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExResolveOperands + * + * PARAMETERS: Opcode - Opcode being interpreted + * StackPtr - Pointer to the operand stack to be + * resolved + * WalkState - Current state + * + * RETURN: Status + * + * DESCRIPTION: Convert multiple input operands to the types required by the + * target operator. + * + * Each 5-bit group in ArgTypes represents one required + * operand and indicates the required Type. The corresponding operand + * will be converted to the required type if possible, otherwise we + * abort with an exception. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExResolveOperands ( + UINT16 Opcode, + ACPI_OPERAND_OBJECT **StackPtr, + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status = AE_OK; + UINT8 ObjectType; + UINT32 ArgTypes; + const ACPI_OPCODE_INFO *OpInfo; + UINT32 ThisArgType; + ACPI_OBJECT_TYPE TypeNeeded; + UINT16 TargetOp = 0; + + + ACPI_FUNCTION_TRACE_U32 (ExResolveOperands, Opcode); + + + OpInfo = AcpiPsGetOpcodeInfo (Opcode); + if (OpInfo->Class == AML_CLASS_UNKNOWN) + { + return_ACPI_STATUS (AE_AML_BAD_OPCODE); + } + + ArgTypes = OpInfo->RuntimeArgs; + if (ArgTypes == ARGI_INVALID_OPCODE) + { + ACPI_ERROR ((AE_INFO, "Unknown AML opcode %X", + Opcode)); + + return_ACPI_STATUS (AE_AML_INTERNAL); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Opcode %X [%s] RequiredOperandTypes=%8.8X\n", + Opcode, OpInfo->Name, ArgTypes)); + + /* + * Normal exit is with (ArgTypes == 0) at end of argument list. + * Function will return an exception from within the loop upon + * finding an entry which is not (or cannot be converted + * to) the required type; if stack underflows; or upon + * finding a NULL stack entry (which should not happen). + */ + while (GET_CURRENT_ARG_TYPE (ArgTypes)) + { + if (!StackPtr || !*StackPtr) + { + ACPI_ERROR ((AE_INFO, "Null stack entry at %p", + StackPtr)); + + return_ACPI_STATUS (AE_AML_INTERNAL); + } + + /* Extract useful items */ + + ObjDesc = *StackPtr; + + /* Decode the descriptor type */ + + switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc)) + { + case ACPI_DESC_TYPE_NAMED: + + /* Namespace Node */ + + ObjectType = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type; + + /* + * Resolve an alias object. The construction of these objects + * guarantees that there is only one level of alias indirection; + * thus, the attached object is always the aliased namespace node + */ + if (ObjectType == ACPI_TYPE_LOCAL_ALIAS) + { + ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ObjDesc); + *StackPtr = ObjDesc; + ObjectType = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type; + } + break; + + + case ACPI_DESC_TYPE_OPERAND: + + /* ACPI internal object */ + + ObjectType = ObjDesc->Common.Type; + + /* Check for bad ACPI_OBJECT_TYPE */ + + if (!AcpiUtValidObjectType (ObjectType)) + { + ACPI_ERROR ((AE_INFO, + "Bad operand object type [%X]", ObjectType)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + if (ObjectType == (UINT8) ACPI_TYPE_LOCAL_REFERENCE) + { + /* Validate the Reference */ + + switch (ObjDesc->Reference.Class) + { + case ACPI_REFCLASS_DEBUG: + + TargetOp = AML_DEBUG_OP; + + /*lint -fallthrough */ + + case ACPI_REFCLASS_ARG: + case ACPI_REFCLASS_LOCAL: + case ACPI_REFCLASS_INDEX: + case ACPI_REFCLASS_REFOF: + case ACPI_REFCLASS_TABLE: /* DdbHandle from LOAD_OP or LOAD_TABLE_OP */ + case ACPI_REFCLASS_NAME: /* Reference to a named object */ + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Operand is a Reference, Class [%s] %2.2X\n", + AcpiUtGetReferenceName (ObjDesc), + ObjDesc->Reference.Class)); + break; + + default: + + ACPI_ERROR ((AE_INFO, + "Unknown Reference Class %2.2X in %p", + ObjDesc->Reference.Class, ObjDesc)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + } + break; + + + default: + + /* Invalid descriptor */ + + ACPI_ERROR ((AE_INFO, "Invalid descriptor %p [%s]", + ObjDesc, AcpiUtGetDescriptorName (ObjDesc))); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* Get one argument type, point to the next */ + + ThisArgType = GET_CURRENT_ARG_TYPE (ArgTypes); + INCREMENT_ARG_LIST (ArgTypes); + + /* + * Handle cases where the object does not need to be + * resolved to a value + */ + switch (ThisArgType) + { + case ARGI_REF_OR_STRING: /* Can be a String or Reference */ + + if ((ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_OPERAND) && + (ObjDesc->Common.Type == ACPI_TYPE_STRING)) + { + /* + * String found - the string references a named object and + * must be resolved to a node + */ + goto NextOperand; + } + + /* + * Else not a string - fall through to the normal Reference + * case below + */ + /*lint -fallthrough */ + + case ARGI_REFERENCE: /* References: */ + case ARGI_INTEGER_REF: + case ARGI_OBJECT_REF: + case ARGI_DEVICE_REF: + case ARGI_TARGETREF: /* Allows implicit conversion rules before store */ + case ARGI_FIXED_TARGET: /* No implicit conversion before store to target */ + case ARGI_SIMPLE_TARGET: /* Name, Local, or Arg - no implicit conversion */ + + /* + * Need an operand of type ACPI_TYPE_LOCAL_REFERENCE + * A Namespace Node is OK as-is + */ + if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_NAMED) + { + goto NextOperand; + } + + Status = AcpiExCheckObjectType (ACPI_TYPE_LOCAL_REFERENCE, + ObjectType, ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + goto NextOperand; + + + case ARGI_DATAREFOBJ: /* Store operator only */ + + /* + * We don't want to resolve IndexOp reference objects during + * a store because this would be an implicit DeRefOf operation. + * Instead, we just want to store the reference object. + * -- All others must be resolved below. + */ + if ((Opcode == AML_STORE_OP) && + ((*StackPtr)->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) && + ((*StackPtr)->Reference.Class == ACPI_REFCLASS_INDEX)) + { + goto NextOperand; + } + break; + + default: + /* All cases covered above */ + break; + } + + /* + * Resolve this object to a value + */ + Status = AcpiExResolveToValue (StackPtr, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Get the resolved object */ + + ObjDesc = *StackPtr; + + /* + * Check the resulting object (value) type + */ + switch (ThisArgType) + { + /* + * For the simple cases, only one type of resolved object + * is allowed + */ + case ARGI_MUTEX: + + /* Need an operand of type ACPI_TYPE_MUTEX */ + + TypeNeeded = ACPI_TYPE_MUTEX; + break; + + case ARGI_EVENT: + + /* Need an operand of type ACPI_TYPE_EVENT */ + + TypeNeeded = ACPI_TYPE_EVENT; + break; + + case ARGI_PACKAGE: /* Package */ + + /* Need an operand of type ACPI_TYPE_PACKAGE */ + + TypeNeeded = ACPI_TYPE_PACKAGE; + break; + + case ARGI_ANYTYPE: + + /* Any operand type will do */ + + TypeNeeded = ACPI_TYPE_ANY; + break; + + case ARGI_DDBHANDLE: + + /* Need an operand of type ACPI_TYPE_DDB_HANDLE */ + + TypeNeeded = ACPI_TYPE_LOCAL_REFERENCE; + break; + + + /* + * The more complex cases allow multiple resolved object types + */ + case ARGI_INTEGER: + + /* + * Need an operand of type ACPI_TYPE_INTEGER, + * But we can implicitly convert from a STRING or BUFFER + * Aka - "Implicit Source Operand Conversion" + */ + Status = AcpiExConvertToInteger (ObjDesc, StackPtr, 16); + if (ACPI_FAILURE (Status)) + { + if (Status == AE_TYPE) + { + ACPI_ERROR ((AE_INFO, + "Needed [Integer/String/Buffer], found [%s] %p", + AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + return_ACPI_STATUS (Status); + } + + if (ObjDesc != *StackPtr) + { + AcpiUtRemoveReference (ObjDesc); + } + goto NextOperand; + + + case ARGI_BUFFER: + + /* + * Need an operand of type ACPI_TYPE_BUFFER, + * But we can implicitly convert from a STRING or INTEGER + * Aka - "Implicit Source Operand Conversion" + */ + Status = AcpiExConvertToBuffer (ObjDesc, StackPtr); + if (ACPI_FAILURE (Status)) + { + if (Status == AE_TYPE) + { + ACPI_ERROR ((AE_INFO, + "Needed [Integer/String/Buffer], found [%s] %p", + AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + return_ACPI_STATUS (Status); + } + + if (ObjDesc != *StackPtr) + { + AcpiUtRemoveReference (ObjDesc); + } + goto NextOperand; + + + case ARGI_STRING: + + /* + * Need an operand of type ACPI_TYPE_STRING, + * But we can implicitly convert from a BUFFER or INTEGER + * Aka - "Implicit Source Operand Conversion" + */ + Status = AcpiExConvertToString (ObjDesc, StackPtr, + ACPI_IMPLICIT_CONVERT_HEX); + if (ACPI_FAILURE (Status)) + { + if (Status == AE_TYPE) + { + ACPI_ERROR ((AE_INFO, + "Needed [Integer/String/Buffer], found [%s] %p", + AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + return_ACPI_STATUS (Status); + } + + if (ObjDesc != *StackPtr) + { + AcpiUtRemoveReference (ObjDesc); + } + goto NextOperand; + + + case ARGI_COMPUTEDATA: + + /* Need an operand of type INTEGER, STRING or BUFFER */ + + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_INTEGER: + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + + /* Valid operand */ + break; + + default: + ACPI_ERROR ((AE_INFO, + "Needed [Integer/String/Buffer], found [%s] %p", + AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + goto NextOperand; + + + case ARGI_BUFFER_OR_STRING: + + /* Need an operand of type STRING or BUFFER */ + + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + + /* Valid operand */ + break; + + case ACPI_TYPE_INTEGER: + + /* Highest priority conversion is to type Buffer */ + + Status = AcpiExConvertToBuffer (ObjDesc, StackPtr); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (ObjDesc != *StackPtr) + { + AcpiUtRemoveReference (ObjDesc); + } + break; + + default: + ACPI_ERROR ((AE_INFO, + "Needed [Integer/String/Buffer], found [%s] %p", + AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + goto NextOperand; + + + case ARGI_DATAOBJECT: + /* + * ARGI_DATAOBJECT is only used by the SizeOf operator. + * Need a buffer, string, package, or RefOf reference. + * + * The only reference allowed here is a direct reference to + * a namespace node. + */ + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_PACKAGE: + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + case ACPI_TYPE_LOCAL_REFERENCE: + + /* Valid operand */ + break; + + default: + ACPI_ERROR ((AE_INFO, + "Needed [Buffer/String/Package/Reference], found [%s] %p", + AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + goto NextOperand; + + + case ARGI_COMPLEXOBJ: + + /* Need a buffer or package or (ACPI 2.0) String */ + + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_PACKAGE: + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + + /* Valid operand */ + break; + + default: + ACPI_ERROR ((AE_INFO, + "Needed [Buffer/String/Package], found [%s] %p", + AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + goto NextOperand; + + + case ARGI_REGION_OR_BUFFER: /* Used by Load() only */ + + /* Need an operand of type REGION or a BUFFER (which could be a resolved region field) */ + + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_BUFFER: + case ACPI_TYPE_REGION: + + /* Valid operand */ + break; + + default: + ACPI_ERROR ((AE_INFO, + "Needed [Region/Buffer], found [%s] %p", + AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + goto NextOperand; + + + case ARGI_DATAREFOBJ: + + /* Used by the Store() operator only */ + + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_INTEGER: + case ACPI_TYPE_PACKAGE: + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + case ACPI_TYPE_BUFFER_FIELD: + case ACPI_TYPE_LOCAL_REFERENCE: + case ACPI_TYPE_LOCAL_REGION_FIELD: + case ACPI_TYPE_LOCAL_BANK_FIELD: + case ACPI_TYPE_LOCAL_INDEX_FIELD: + case ACPI_TYPE_DDB_HANDLE: + + /* Valid operand */ + break; + + default: + + if (AcpiGbl_EnableInterpreterSlack) + { + /* + * Enable original behavior of Store(), allowing any and all + * objects as the source operand. The ACPI spec does not + * allow this, however. + */ + break; + } + + if (TargetOp == AML_DEBUG_OP) + { + /* Allow store of any object to the Debug object */ + + break; + } + + ACPI_ERROR ((AE_INFO, + "Needed Integer/Buffer/String/Package/Ref/Ddb], found [%s] %p", + AcpiUtGetObjectTypeName (ObjDesc), ObjDesc)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + goto NextOperand; + + + default: + + /* Unknown type */ + + ACPI_ERROR ((AE_INFO, + "Internal - Unknown ARGI (required operand) type %X", + ThisArgType)); + + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* + * Make sure that the original object was resolved to the + * required object type (Simple cases only). + */ + Status = AcpiExCheckObjectType (TypeNeeded, + (*StackPtr)->Common.Type, *StackPtr); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + +NextOperand: + /* + * If more operands needed, decrement StackPtr to point + * to next operand on stack + */ + if (GET_CURRENT_ARG_TYPE (ArgTypes)) + { + StackPtr--; + } + } + + ACPI_DUMP_OPERANDS (WalkState->Operands, + AcpiPsGetOpcodeName (Opcode), WalkState->NumOperands); + + return_ACPI_STATUS (Status); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/executer/exstore.c b/reactos/drivers/bus/acpi/acpica/executer/exstore.c new file mode 100644 index 00000000000..8ec8a23cffd --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/executer/exstore.c @@ -0,0 +1,822 @@ + +/****************************************************************************** + * + * Module Name: exstore - AML Interpreter object store 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 __EXSTORE_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acdispat.h" +#include "acinterp.h" +#include "amlcode.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exstore") + +/* Local prototypes */ + +static void +AcpiExDoDebugObject ( + ACPI_OPERAND_OBJECT *SourceDesc, + UINT32 Level, + UINT32 Index); + +static ACPI_STATUS +AcpiExStoreObjectToIndex ( + ACPI_OPERAND_OBJECT *ValDesc, + ACPI_OPERAND_OBJECT *DestDesc, + 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 + * + * PARAMETERS: *SourceDesc - Value to be stored + * *DestDesc - Where to store it. Must be an NS node + * or an ACPI_OPERAND_OBJECT of type + * Reference; + * WalkState - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: Store the value described by SourceDesc into the location + * described by DestDesc. Called by various interpreter + * functions to store the result of an operation into + * the destination operand -- not just simply the actual "Store" + * ASL operator. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExStore ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT *DestDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT *RefDesc = DestDesc; + + + ACPI_FUNCTION_TRACE_PTR (ExStore, DestDesc); + + + /* Validate parameters */ + + if (!SourceDesc || !DestDesc) + { + ACPI_ERROR ((AE_INFO, "Null parameter")); + return_ACPI_STATUS (AE_AML_NO_OPERAND); + } + + /* DestDesc can be either a namespace node or an ACPI object */ + + if (ACPI_GET_DESCRIPTOR_TYPE (DestDesc) == ACPI_DESC_TYPE_NAMED) + { + /* + * Dest is a namespace node, + * Storing an object into a Named node. + */ + Status = AcpiExStoreObjectToNode (SourceDesc, + (ACPI_NAMESPACE_NODE *) DestDesc, WalkState, + ACPI_IMPLICIT_CONVERSION); + + return_ACPI_STATUS (Status); + } + + /* Destination object must be a Reference or a Constant object */ + + switch (DestDesc->Common.Type) + { + case ACPI_TYPE_LOCAL_REFERENCE: + break; + + case ACPI_TYPE_INTEGER: + + /* Allow stores to Constants -- a Noop as per ACPI spec */ + + if (DestDesc->Common.Flags & AOPOBJ_AML_CONSTANT) + { + return_ACPI_STATUS (AE_OK); + } + + /*lint -fallthrough */ + + default: + + /* Destination is not a Reference object */ + + ACPI_ERROR ((AE_INFO, + "Target is not a Reference or Constant object - %s [%p]", + AcpiUtGetObjectTypeName (DestDesc), DestDesc)); + + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* + * Examine the Reference class. These cases are handled: + * + * 1) Store to Name (Change the object associated with a name) + * 2) Store to an indexed area of a Buffer or Package + * 3) Store to a Method Local or Arg + * 4) Store to the debug object + */ + switch (RefDesc->Reference.Class) + { + case ACPI_REFCLASS_REFOF: + + /* Storing an object into a Name "container" */ + + Status = AcpiExStoreObjectToNode (SourceDesc, + RefDesc->Reference.Object, + WalkState, ACPI_IMPLICIT_CONVERSION); + break; + + + case ACPI_REFCLASS_INDEX: + + /* Storing to an Index (pointer into a packager or buffer) */ + + Status = AcpiExStoreObjectToIndex (SourceDesc, RefDesc, WalkState); + break; + + + case ACPI_REFCLASS_LOCAL: + case ACPI_REFCLASS_ARG: + + /* Store to a method local/arg */ + + Status = AcpiDsStoreObjectToLocal (RefDesc->Reference.Class, + RefDesc->Reference.Value, SourceDesc, WalkState); + break; + + + case ACPI_REFCLASS_DEBUG: + + /* + * Storing to the Debug object causes the value stored to be + * displayed and otherwise has no effect -- see ACPI Specification + */ + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "**** Write to Debug Object: Object %p %s ****:\n\n", + SourceDesc, AcpiUtGetObjectTypeName (SourceDesc))); + + AcpiExDoDebugObject (SourceDesc, 0, 0); + break; + + + default: + + ACPI_ERROR ((AE_INFO, "Unknown Reference Class %2.2X", + RefDesc->Reference.Class)); + ACPI_DUMP_ENTRY (RefDesc, ACPI_LV_INFO); + + Status = AE_AML_INTERNAL; + break; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExStoreObjectToIndex + * + * PARAMETERS: *SourceDesc - Value to be stored + * *DestDesc - Named object to receive the value + * WalkState - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: Store the object to indexed Buffer or Package element + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiExStoreObjectToIndex ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT *IndexDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *NewDesc; + UINT8 Value = 0; + UINT32 i; + + + ACPI_FUNCTION_TRACE (ExStoreObjectToIndex); + + + /* + * Destination must be a reference pointer, and + * must point to either a buffer or a package + */ + switch (IndexDesc->Reference.TargetType) + { + case ACPI_TYPE_PACKAGE: + /* + * Storing to a package element. Copy the object and replace + * any existing object with the new object. No implicit + * conversion is performed. + * + * The object at *(IndexDesc->Reference.Where) is the + * element within the package that is to be modified. + * The parent package object is at IndexDesc->Reference.Object + */ + ObjDesc = *(IndexDesc->Reference.Where); + + if (SourceDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE && + SourceDesc->Reference.Class == ACPI_REFCLASS_TABLE) + { + /* This is a DDBHandle, just add a reference to it */ + + AcpiUtAddReference (SourceDesc); + NewDesc = SourceDesc; + } + else + { + /* Normal object, copy it */ + + Status = AcpiUtCopyIobjectToIobject (SourceDesc, &NewDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + if (ObjDesc) + { + /* Decrement reference count by the ref count of the parent package */ + + for (i = 0; + i < ((ACPI_OPERAND_OBJECT *) + IndexDesc->Reference.Object)->Common.ReferenceCount; + i++) + { + AcpiUtRemoveReference (ObjDesc); + } + } + + *(IndexDesc->Reference.Where) = NewDesc; + + /* Increment ref count by the ref count of the parent package-1 */ + + for (i = 1; + i < ((ACPI_OPERAND_OBJECT *) + IndexDesc->Reference.Object)->Common.ReferenceCount; + i++) + { + AcpiUtAddReference (NewDesc); + } + + break; + + + case ACPI_TYPE_BUFFER_FIELD: + + /* + * Store into a Buffer or String (not actually a real BufferField) + * at a location defined by an Index. + * + * The first 8-bit element of the source object is written to the + * 8-bit Buffer location defined by the Index destination object, + * according to the ACPI 2.0 specification. + */ + + /* + * Make sure the target is a Buffer or String. An error should + * not happen here, since the ReferenceObject was constructed + * by the INDEX_OP code. + */ + ObjDesc = IndexDesc->Reference.Object; + if ((ObjDesc->Common.Type != ACPI_TYPE_BUFFER) && + (ObjDesc->Common.Type != ACPI_TYPE_STRING)) + { + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* + * The assignment of the individual elements will be slightly + * different for each source type. + */ + switch (SourceDesc->Common.Type) + { + case ACPI_TYPE_INTEGER: + + /* Use the least-significant byte of the integer */ + + Value = (UINT8) (SourceDesc->Integer.Value); + break; + + case ACPI_TYPE_BUFFER: + case ACPI_TYPE_STRING: + + /* Note: Takes advantage of common string/buffer fields */ + + Value = SourceDesc->Buffer.Pointer[0]; + break; + + default: + + /* All other types are invalid */ + + ACPI_ERROR ((AE_INFO, + "Source must be Integer/Buffer/String type, not %s", + AcpiUtGetObjectTypeName (SourceDesc))); + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* Store the source value into the target buffer byte */ + + ObjDesc->Buffer.Pointer[IndexDesc->Reference.Value] = Value; + break; + + + default: + ACPI_ERROR ((AE_INFO, + "Target is not a Package or BufferField")); + Status = AE_AML_OPERAND_TYPE; + break; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExStoreObjectToNode + * + * PARAMETERS: SourceDesc - Value to be stored + * Node - Named object to receive the value + * WalkState - Current walk state + * ImplicitConversion - Perform implicit conversion (yes/no) + * + * RETURN: Status + * + * DESCRIPTION: Store the object to the named object. + * + * The Assignment of an object to a named object is handled here + * The value passed in will replace the current value (if any) + * with the input value. + * + * When storing into an object the data is converted to the + * target object type then stored in the object. This means + * that the target object type (for an initialized target) will + * not be changed by a store operation. + * + * Assumes parameters are already validated. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExStoreObjectToNode ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_NAMESPACE_NODE *Node, + ACPI_WALK_STATE *WalkState, + UINT8 ImplicitConversion) +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT *TargetDesc; + ACPI_OPERAND_OBJECT *NewDesc; + ACPI_OBJECT_TYPE TargetType; + + + ACPI_FUNCTION_TRACE_PTR (ExStoreObjectToNode, SourceDesc); + + + /* Get current type of the node, and object attached to Node */ + + TargetType = AcpiNsGetType (Node); + TargetDesc = AcpiNsGetAttachedObject (Node); + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Storing %p(%s) into node %p(%s)\n", + SourceDesc, AcpiUtGetObjectTypeName (SourceDesc), + Node, AcpiUtGetTypeName (TargetType))); + + /* + * Resolve the source object to an actual value + * (If it is a reference object) + */ + Status = AcpiExResolveObject (&SourceDesc, TargetType, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* If no implicit conversion, drop into the default case below */ + + if ((!ImplicitConversion) || + ((WalkState->Opcode == AML_COPY_OP) && + (TargetType != ACPI_TYPE_LOCAL_REGION_FIELD) && + (TargetType != ACPI_TYPE_LOCAL_BANK_FIELD) && + (TargetType != ACPI_TYPE_LOCAL_INDEX_FIELD))) + { + /* + * Force execution of default (no implicit conversion). Note: + * CopyObject does not perform an implicit conversion, as per the ACPI + * spec -- except in case of region/bank/index fields -- because these + * objects must retain their original type permanently. + */ + TargetType = ACPI_TYPE_ANY; + } + + /* Do the actual store operation */ + + switch (TargetType) + { + case ACPI_TYPE_BUFFER_FIELD: + case ACPI_TYPE_LOCAL_REGION_FIELD: + case ACPI_TYPE_LOCAL_BANK_FIELD: + case ACPI_TYPE_LOCAL_INDEX_FIELD: + + /* For fields, copy the source data to the target field. */ + + Status = AcpiExWriteDataToField (SourceDesc, TargetDesc, + &WalkState->ResultObj); + break; + + + case ACPI_TYPE_INTEGER: + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + + /* + * These target types are all of type Integer/String/Buffer, and + * therefore support implicit conversion before the store. + * + * Copy and/or convert the source object to a new target object + */ + Status = AcpiExStoreObjectToObject (SourceDesc, TargetDesc, + &NewDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (NewDesc != TargetDesc) + { + /* + * Store the new NewDesc as the new value of the Name, and set + * the Name's type to that of the value being stored in it. + * SourceDesc reference count is incremented by AttachObject. + * + * Note: This may change the type of the node if an explicit store + * has been performed such that the node/object type has been + * changed. + */ + Status = AcpiNsAttachObject (Node, NewDesc, NewDesc->Common.Type); + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Store %s into %s via Convert/Attach\n", + AcpiUtGetObjectTypeName (SourceDesc), + AcpiUtGetObjectTypeName (NewDesc))); + } + break; + + + default: + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Storing %s (%p) directly into node (%p) with no implicit conversion\n", + AcpiUtGetObjectTypeName (SourceDesc), SourceDesc, Node)); + + /* No conversions for all other types. Just attach the source object */ + + Status = AcpiNsAttachObject (Node, SourceDesc, + SourceDesc->Common.Type); + break; + } + + return_ACPI_STATUS (Status); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/executer/exstoren.c b/reactos/drivers/bus/acpi/acpica/executer/exstoren.c new file mode 100644 index 00000000000..0810560d39c --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/executer/exstoren.c @@ -0,0 +1,386 @@ + +/****************************************************************************** + * + * Module Name: exstoren - AML Interpreter object store support, + * Store to Node (namespace object) + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __EXSTOREN_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" +#include "amlcode.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exstoren") + + +/******************************************************************************* + * + * FUNCTION: AcpiExResolveObject + * + * PARAMETERS: SourceDescPtr - Pointer to the source object + * TargetType - Current type of the target + * WalkState - Current walk state + * + * RETURN: Status, resolved object in SourceDescPtr. + * + * DESCRIPTION: Resolve an object. If the object is a reference, dereference + * it and return the actual object in the SourceDescPtr. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExResolveObject ( + ACPI_OPERAND_OBJECT **SourceDescPtr, + ACPI_OBJECT_TYPE TargetType, + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT *SourceDesc = *SourceDescPtr; + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (ExResolveObject); + + + /* Ensure we have a Target that can be stored to */ + + switch (TargetType) + { + case ACPI_TYPE_BUFFER_FIELD: + case ACPI_TYPE_LOCAL_REGION_FIELD: + case ACPI_TYPE_LOCAL_BANK_FIELD: + case ACPI_TYPE_LOCAL_INDEX_FIELD: + /* + * These cases all require only Integers or values that + * can be converted to Integers (Strings or Buffers) + */ + + case ACPI_TYPE_INTEGER: + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + + /* + * Stores into a Field/Region or into a Integer/Buffer/String + * are all essentially the same. This case handles the + * "interchangeable" types Integer, String, and Buffer. + */ + if (SourceDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) + { + /* Resolve a reference object first */ + + Status = AcpiExResolveToValue (SourceDescPtr, WalkState); + if (ACPI_FAILURE (Status)) + { + break; + } + } + + /* For CopyObject, no further validation necessary */ + + if (WalkState->Opcode == AML_COPY_OP) + { + break; + } + + /* Must have a Integer, Buffer, or String */ + + if ((SourceDesc->Common.Type != ACPI_TYPE_INTEGER) && + (SourceDesc->Common.Type != ACPI_TYPE_BUFFER) && + (SourceDesc->Common.Type != ACPI_TYPE_STRING) && + !((SourceDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) && + (SourceDesc->Reference.Class== ACPI_REFCLASS_TABLE))) + { + /* Conversion successful but still not a valid type */ + + ACPI_ERROR ((AE_INFO, + "Cannot assign type %s to %s (must be type Int/Str/Buf)", + AcpiUtGetObjectTypeName (SourceDesc), + AcpiUtGetTypeName (TargetType))); + Status = AE_AML_OPERAND_TYPE; + } + break; + + + case ACPI_TYPE_LOCAL_ALIAS: + case ACPI_TYPE_LOCAL_METHOD_ALIAS: + + /* + * All aliases should have been resolved earlier, during the + * operand resolution phase. + */ + ACPI_ERROR ((AE_INFO, "Store into an unresolved Alias object")); + Status = AE_AML_INTERNAL; + break; + + + case ACPI_TYPE_PACKAGE: + default: + + /* + * All other types than Alias and the various Fields come here, + * including the untyped case - ACPI_TYPE_ANY. + */ + break; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExStoreObjectToObject + * + * PARAMETERS: SourceDesc - Object to store + * DestDesc - Object to receive a copy of the source + * NewDesc - New object if DestDesc is obsoleted + * WalkState - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: "Store" an object to another object. This may include + * converting the source type to the target type (implicit + * conversion), and a copy of the value of the source to + * the target. + * + * The Assignment of an object to another (not named) object + * is handled here. + * The Source passed in will replace the current value (if any) + * with the input value. + * + * When storing into an object the data is converted to the + * target object type then stored in the object. This means + * that the target object type (for an initialized target) will + * not be changed by a store operation. + * + * This module allows destination types of Number, String, + * Buffer, and Package. + * + * Assumes parameters are already validated. NOTE: SourceDesc + * resolution (from a reference object) must be performed by + * the caller if necessary. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExStoreObjectToObject ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT *DestDesc, + ACPI_OPERAND_OBJECT **NewDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_OPERAND_OBJECT *ActualSrcDesc; + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE_PTR (ExStoreObjectToObject, SourceDesc); + + + ActualSrcDesc = SourceDesc; + if (!DestDesc) + { + /* + * There is no destination object (An uninitialized node or + * package element), so we can simply copy the source object + * creating a new destination object + */ + Status = AcpiUtCopyIobjectToIobject (ActualSrcDesc, NewDesc, WalkState); + return_ACPI_STATUS (Status); + } + + if (SourceDesc->Common.Type != DestDesc->Common.Type) + { + /* + * The source type does not match the type of the destination. + * Perform the "implicit conversion" of the source to the current type + * of the target as per the ACPI specification. + * + * If no conversion performed, ActualSrcDesc = SourceDesc. + * Otherwise, ActualSrcDesc is a temporary object to hold the + * converted object. + */ + Status = AcpiExConvertToTargetType (DestDesc->Common.Type, + SourceDesc, &ActualSrcDesc, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (SourceDesc == ActualSrcDesc) + { + /* + * No conversion was performed. Return the SourceDesc as the + * new object. + */ + *NewDesc = SourceDesc; + return_ACPI_STATUS (AE_OK); + } + } + + /* + * We now have two objects of identical types, and we can perform a + * copy of the *value* of the source object. + */ + switch (DestDesc->Common.Type) + { + case ACPI_TYPE_INTEGER: + + DestDesc->Integer.Value = ActualSrcDesc->Integer.Value; + + /* Truncate value if we are executing from a 32-bit ACPI table */ + + AcpiExTruncateFor32bitTable (DestDesc); + break; + + case ACPI_TYPE_STRING: + + Status = AcpiExStoreStringToString (ActualSrcDesc, DestDesc); + break; + + case ACPI_TYPE_BUFFER: + + Status = AcpiExStoreBufferToBuffer (ActualSrcDesc, DestDesc); + break; + + case ACPI_TYPE_PACKAGE: + + Status = AcpiUtCopyIobjectToIobject (ActualSrcDesc, &DestDesc, + WalkState); + break; + + default: + /* + * All other types come here. + */ + ACPI_WARNING ((AE_INFO, "Store into type %s not implemented", + AcpiUtGetObjectTypeName (DestDesc))); + + Status = AE_NOT_IMPLEMENTED; + break; + } + + if (ActualSrcDesc != SourceDesc) + { + /* Delete the intermediate (temporary) source object */ + + AcpiUtRemoveReference (ActualSrcDesc); + } + + *NewDesc = DestDesc; + return_ACPI_STATUS (Status); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/executer/exstorob.c b/reactos/drivers/bus/acpi/acpica/executer/exstorob.c new file mode 100644 index 00000000000..b2f125d01fb --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/executer/exstorob.c @@ -0,0 +1,316 @@ + +/****************************************************************************** + * + * Module Name: exstorob - AML Interpreter object store support, store to object + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __EXSTOROB_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" + + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exstorob") + + +/******************************************************************************* + * + * FUNCTION: AcpiExStoreBufferToBuffer + * + * PARAMETERS: SourceDesc - Source object to copy + * TargetDesc - Destination object of the copy + * + * RETURN: Status + * + * DESCRIPTION: Copy a buffer object to another buffer object. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExStoreBufferToBuffer ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT *TargetDesc) +{ + UINT32 Length; + UINT8 *Buffer; + + + ACPI_FUNCTION_TRACE_PTR (ExStoreBufferToBuffer, SourceDesc); + + + /* If Source and Target are the same, just return */ + + if (SourceDesc == TargetDesc) + { + return_ACPI_STATUS (AE_OK); + } + + /* We know that SourceDesc is a buffer by now */ + + Buffer = ACPI_CAST_PTR (UINT8, SourceDesc->Buffer.Pointer); + Length = SourceDesc->Buffer.Length; + + /* + * If target is a buffer of length zero or is a static buffer, + * allocate a new buffer of the proper length + */ + if ((TargetDesc->Buffer.Length == 0) || + (TargetDesc->Common.Flags & AOPOBJ_STATIC_POINTER)) + { + TargetDesc->Buffer.Pointer = ACPI_ALLOCATE (Length); + if (!TargetDesc->Buffer.Pointer) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + TargetDesc->Buffer.Length = Length; + } + + /* Copy source buffer to target buffer */ + + if (Length <= TargetDesc->Buffer.Length) + { + /* Clear existing buffer and copy in the new one */ + + ACPI_MEMSET (TargetDesc->Buffer.Pointer, 0, TargetDesc->Buffer.Length); + ACPI_MEMCPY (TargetDesc->Buffer.Pointer, Buffer, Length); + +#ifdef ACPI_OBSOLETE_BEHAVIOR + /* + * NOTE: ACPI versions up to 3.0 specified that the buffer must be + * truncated if the string is smaller than the buffer. However, "other" + * implementations of ACPI never did this and thus became the defacto + * standard. ACPI 3.0A changes this behavior such that the buffer + * is no longer truncated. + */ + + /* + * OBSOLETE BEHAVIOR: + * If the original source was a string, we must truncate the buffer, + * according to the ACPI spec. Integer-to-Buffer and Buffer-to-Buffer + * copy must not truncate the original buffer. + */ + if (OriginalSrcType == ACPI_TYPE_STRING) + { + /* Set the new length of the target */ + + TargetDesc->Buffer.Length = Length; + } +#endif + } + else + { + /* Truncate the source, copy only what will fit */ + + ACPI_MEMCPY (TargetDesc->Buffer.Pointer, Buffer, + TargetDesc->Buffer.Length); + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Truncating source buffer from %X to %X\n", + Length, TargetDesc->Buffer.Length)); + } + + /* Copy flags */ + + TargetDesc->Buffer.Flags = SourceDesc->Buffer.Flags; + TargetDesc->Common.Flags &= ~AOPOBJ_STATIC_POINTER; + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExStoreStringToString + * + * PARAMETERS: SourceDesc - Source object to copy + * TargetDesc - Destination object of the copy + * + * RETURN: Status + * + * DESCRIPTION: Copy a String object to another String object + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExStoreStringToString ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT *TargetDesc) +{ + UINT32 Length; + UINT8 *Buffer; + + + ACPI_FUNCTION_TRACE_PTR (ExStoreStringToString, SourceDesc); + + + /* If Source and Target are the same, just return */ + + if (SourceDesc == TargetDesc) + { + return_ACPI_STATUS (AE_OK); + } + + /* We know that SourceDesc is a string by now */ + + Buffer = ACPI_CAST_PTR (UINT8, SourceDesc->String.Pointer); + Length = SourceDesc->String.Length; + + /* + * Replace existing string value if it will fit and the string + * pointer is not a static pointer (part of an ACPI table) + */ + if ((Length < TargetDesc->String.Length) && + (!(TargetDesc->Common.Flags & AOPOBJ_STATIC_POINTER))) + { + /* + * String will fit in existing non-static buffer. + * Clear old string and copy in the new one + */ + ACPI_MEMSET (TargetDesc->String.Pointer, 0, + (ACPI_SIZE) TargetDesc->String.Length + 1); + ACPI_MEMCPY (TargetDesc->String.Pointer, Buffer, Length); + } + else + { + /* + * Free the current buffer, then allocate a new buffer + * large enough to hold the value + */ + if (TargetDesc->String.Pointer && + (!(TargetDesc->Common.Flags & AOPOBJ_STATIC_POINTER))) + { + /* Only free if not a pointer into the DSDT */ + + ACPI_FREE (TargetDesc->String.Pointer); + } + + TargetDesc->String.Pointer = ACPI_ALLOCATE_ZEROED ( + (ACPI_SIZE) Length + 1); + if (!TargetDesc->String.Pointer) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + TargetDesc->Common.Flags &= ~AOPOBJ_STATIC_POINTER; + ACPI_MEMCPY (TargetDesc->String.Pointer, Buffer, Length); + } + + /* Set the new target length */ + + TargetDesc->String.Length = Length; + return_ACPI_STATUS (AE_OK); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/executer/exsystem.c b/reactos/drivers/bus/acpi/acpica/executer/exsystem.c new file mode 100644 index 00000000000..19674606a60 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/executer/exsystem.c @@ -0,0 +1,418 @@ + +/****************************************************************************** + * + * Module Name: exsystem - Interface to OS services + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __EXSYSTEM_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exsystem") + + +/******************************************************************************* + * + * FUNCTION: AcpiExSystemWaitSemaphore + * + * PARAMETERS: Semaphore - Semaphore to wait on + * Timeout - Max time to wait + * + * RETURN: Status + * + * DESCRIPTION: Implements a semaphore wait with a check to see if the + * semaphore is available immediately. If it is not, the + * interpreter is released before waiting. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExSystemWaitSemaphore ( + ACPI_SEMAPHORE Semaphore, + UINT16 Timeout) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (ExSystemWaitSemaphore); + + + Status = AcpiOsWaitSemaphore (Semaphore, 1, ACPI_DO_NOT_WAIT); + if (ACPI_SUCCESS (Status)) + { + return_ACPI_STATUS (Status); + } + + if (Status == AE_TIME) + { + /* We must wait, so unlock the interpreter */ + + AcpiExRelinquishInterpreter (); + + Status = AcpiOsWaitSemaphore (Semaphore, 1, Timeout); + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "*** Thread awake after blocking, %s\n", + AcpiFormatException (Status))); + + /* Reacquire the interpreter */ + + AcpiExReacquireInterpreter (); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExSystemWaitMutex + * + * PARAMETERS: Mutex - Mutex to wait on + * Timeout - Max time to wait + * + * RETURN: Status + * + * DESCRIPTION: Implements a mutex wait with a check to see if the + * mutex is available immediately. If it is not, the + * interpreter is released before waiting. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExSystemWaitMutex ( + ACPI_MUTEX Mutex, + UINT16 Timeout) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (ExSystemWaitMutex); + + + Status = AcpiOsAcquireMutex (Mutex, ACPI_DO_NOT_WAIT); + if (ACPI_SUCCESS (Status)) + { + return_ACPI_STATUS (Status); + } + + if (Status == AE_TIME) + { + /* We must wait, so unlock the interpreter */ + + AcpiExRelinquishInterpreter (); + + Status = AcpiOsAcquireMutex (Mutex, Timeout); + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "*** Thread awake after blocking, %s\n", + AcpiFormatException (Status))); + + /* Reacquire the interpreter */ + + AcpiExReacquireInterpreter (); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExSystemDoStall + * + * PARAMETERS: HowLong - The amount of time to stall, + * in microseconds + * + * RETURN: Status + * + * DESCRIPTION: Suspend running thread for specified amount of time. + * Note: ACPI specification requires that Stall() does not + * relinquish the processor, and delays longer than 100 usec + * should use Sleep() instead. We allow stalls up to 255 usec + * for compatibility with other interpreters and existing BIOSs. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExSystemDoStall ( + UINT32 HowLong) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_ENTRY (); + + + if (HowLong > 255) /* 255 microseconds */ + { + /* + * Longer than 255 usec, this is an error + * + * (ACPI specifies 100 usec as max, but this gives some slack in + * order to support existing BIOSs) + */ + ACPI_ERROR ((AE_INFO, "Time parameter is too large (%d)", + HowLong)); + Status = AE_AML_OPERAND_VALUE; + } + else + { + AcpiOsStall (HowLong); + } + + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExSystemDoSuspend + * + * PARAMETERS: HowLong - The amount of time to suspend, + * in milliseconds + * + * RETURN: None + * + * DESCRIPTION: Suspend running thread for specified amount of time. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExSystemDoSuspend ( + ACPI_INTEGER HowLong) +{ + ACPI_FUNCTION_ENTRY (); + + + /* Since this thread will sleep, we must release the interpreter */ + + AcpiExRelinquishInterpreter (); + + AcpiOsSleep (HowLong); + + /* And now we must get the interpreter again */ + + AcpiExReacquireInterpreter (); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExSystemSignalEvent + * + * PARAMETERS: ObjDesc - The object descriptor for this op + * + * RETURN: Status + * + * DESCRIPTION: Provides an access point to perform synchronization operations + * within the AML. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExSystemSignalEvent ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (ExSystemSignalEvent); + + + if (ObjDesc) + { + Status = AcpiOsSignalSemaphore (ObjDesc->Event.OsSemaphore, 1); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExSystemWaitEvent + * + * PARAMETERS: TimeDesc - The 'time to delay' object descriptor + * ObjDesc - The object descriptor for this op + * + * RETURN: Status + * + * DESCRIPTION: Provides an access point to perform synchronization operations + * within the AML. This operation is a request to wait for an + * event. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExSystemWaitEvent ( + ACPI_OPERAND_OBJECT *TimeDesc, + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (ExSystemWaitEvent); + + + if (ObjDesc) + { + Status = AcpiExSystemWaitSemaphore (ObjDesc->Event.OsSemaphore, + (UINT16) TimeDesc->Integer.Value); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExSystemResetEvent + * + * PARAMETERS: ObjDesc - The object descriptor for this op + * + * RETURN: Status + * + * DESCRIPTION: Reset an event to a known state. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiExSystemResetEvent ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_STATUS Status = AE_OK; + ACPI_SEMAPHORE TempSemaphore; + + + ACPI_FUNCTION_ENTRY (); + + + /* + * We are going to simply delete the existing semaphore and + * create a new one! + */ + Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 0, &TempSemaphore); + if (ACPI_SUCCESS (Status)) + { + (void) AcpiOsDeleteSemaphore (ObjDesc->Event.OsSemaphore); + ObjDesc->Event.OsSemaphore = TempSemaphore; + } + + return (Status); +} + diff --git a/reactos/drivers/bus/acpi/acpica/executer/exutils.c b/reactos/drivers/bus/acpi/acpica/executer/exutils.c new file mode 100644 index 00000000000..1f5e861b68c --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/executer/exutils.c @@ -0,0 +1,574 @@ + +/****************************************************************************** + * + * Module Name: exutils - interpreter/scanner utilities + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __EXUTILS_C__ + +/* + * DEFINE_AML_GLOBALS is tested in amlcode.h + * to determine whether certain global names should be "defined" or only + * "declared" in the current compilation. This enhances maintainability + * by enabling a single header file to embody all knowledge of the names + * in question. + * + * Exactly one module of any executable should #define DEFINE_GLOBALS + * before #including the header files which use this convention. The + * names in question will be defined and initialized in that module, + * and declared as extern in all other modules which #include those + * header files. + */ + +#define DEFINE_AML_GLOBALS + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" +#include "amlcode.h" + +#define _COMPONENT ACPI_EXECUTER + ACPI_MODULE_NAME ("exutils") + +/* Local prototypes */ + +static UINT32 +AcpiExDigitsNeeded ( + ACPI_INTEGER Value, + UINT32 Base); + + +#ifndef ACPI_NO_METHOD_EXECUTION +/******************************************************************************* + * + * FUNCTION: AcpiExEnterInterpreter + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Enter the interpreter execution region. Failure to enter + * the interpreter region is a fatal system error. Used in + * conjunction with ExitInterpreter. + * + ******************************************************************************/ + +void +AcpiExEnterInterpreter ( + void) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (ExEnterInterpreter); + + + Status = AcpiUtAcquireMutex (ACPI_MTX_INTERPRETER); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR ((AE_INFO, "Could not acquire AML Interpreter mutex")); + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExReacquireInterpreter + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Reacquire the interpreter execution region from within the + * interpreter code. Failure to enter the interpreter region is a + * fatal system error. Used in conjuction with + * RelinquishInterpreter + * + ******************************************************************************/ + +void +AcpiExReacquireInterpreter ( + void) +{ + ACPI_FUNCTION_TRACE (ExReacquireInterpreter); + + + /* + * If the global serialized flag is set, do not release the interpreter, + * since it was not actually released by AcpiExRelinquishInterpreter. + * This forces the interpreter to be single threaded. + */ + if (!AcpiGbl_AllMethodsSerialized) + { + AcpiExEnterInterpreter (); + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExExitInterpreter + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Exit the interpreter execution region. This is the top level + * routine used to exit the interpreter when all processing has + * been completed. + * + ******************************************************************************/ + +void +AcpiExExitInterpreter ( + void) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (ExExitInterpreter); + + + Status = AcpiUtReleaseMutex (ACPI_MTX_INTERPRETER); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR ((AE_INFO, "Could not release AML Interpreter mutex")); + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExRelinquishInterpreter + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Exit the interpreter execution region, from within the + * interpreter - before attempting an operation that will possibly + * block the running thread. + * + * Cases where the interpreter is unlocked internally + * 1) Method to be blocked on a Sleep() AML opcode + * 2) Method to be blocked on an Acquire() AML opcode + * 3) Method to be blocked on a Wait() AML opcode + * 4) Method to be blocked to acquire the global lock + * 5) Method to be blocked waiting to execute a serialized control method + * that is currently executing + * 6) About to invoke a user-installed opregion handler + * + ******************************************************************************/ + +void +AcpiExRelinquishInterpreter ( + void) +{ + ACPI_FUNCTION_TRACE (ExRelinquishInterpreter); + + + /* + * If the global serialized flag is set, do not release the interpreter. + * This forces the interpreter to be single threaded. + */ + if (!AcpiGbl_AllMethodsSerialized) + { + AcpiExExitInterpreter (); + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExTruncateFor32bitTable + * + * PARAMETERS: ObjDesc - Object to be truncated + * + * RETURN: none + * + * DESCRIPTION: Truncate an ACPI Integer to 32 bits if the execution mode is + * 32-bit, as determined by the revision of the DSDT. + * + ******************************************************************************/ + +void +AcpiExTruncateFor32bitTable ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + + ACPI_FUNCTION_ENTRY (); + + + /* + * Object must be a valid number and we must be executing + * a control method. NS node could be there for AML_INT_NAMEPATH_OP. + */ + if ((!ObjDesc) || + (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND) || + (ObjDesc->Common.Type != ACPI_TYPE_INTEGER)) + { + return; + } + + if (AcpiGbl_IntegerByteWidth == 4) + { + /* + * We are running a method that exists in a 32-bit ACPI table. + * Truncate the value to 32 bits by zeroing out the upper 32-bit field + */ + ObjDesc->Integer.Value &= (ACPI_INTEGER) ACPI_UINT32_MAX; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExAcquireGlobalLock + * + * PARAMETERS: FieldFlags - Flags with Lock rule: + * AlwaysLock or NeverLock + * + * RETURN: None + * + * DESCRIPTION: Obtain the ACPI hardware Global Lock, only if the field + * flags specifiy that it is to be obtained before field access. + * + ******************************************************************************/ + +void +AcpiExAcquireGlobalLock ( + UINT32 FieldFlags) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (ExAcquireGlobalLock); + + + /* Only use the lock if the AlwaysLock bit is set */ + + if (!(FieldFlags & AML_FIELD_LOCK_RULE_MASK)) + { + return_VOID; + } + + /* Attempt to get the global lock, wait forever */ + + Status = AcpiExAcquireMutexObject (ACPI_WAIT_FOREVER, + AcpiGbl_GlobalLockMutex, AcpiOsGetThreadId ()); + + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Could not acquire Global Lock")); + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExReleaseGlobalLock + * + * PARAMETERS: FieldFlags - Flags with Lock rule: + * AlwaysLock or NeverLock + * + * RETURN: None + * + * DESCRIPTION: Release the ACPI hardware Global Lock + * + ******************************************************************************/ + +void +AcpiExReleaseGlobalLock ( + UINT32 FieldFlags) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (ExReleaseGlobalLock); + + + /* Only use the lock if the AlwaysLock bit is set */ + + if (!(FieldFlags & AML_FIELD_LOCK_RULE_MASK)) + { + return_VOID; + } + + /* Release the global lock */ + + Status = AcpiExReleaseMutexObject (AcpiGbl_GlobalLockMutex); + if (ACPI_FAILURE (Status)) + { + /* Report the error, but there isn't much else we can do */ + + ACPI_EXCEPTION ((AE_INFO, Status, + "Could not release Global Lock")); + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExDigitsNeeded + * + * PARAMETERS: Value - Value to be represented + * Base - Base of representation + * + * RETURN: The number of digits. + * + * DESCRIPTION: Calculate the number of digits needed to represent the Value + * in the given Base (Radix) + * + ******************************************************************************/ + +static UINT32 +AcpiExDigitsNeeded ( + ACPI_INTEGER Value, + UINT32 Base) +{ + UINT32 NumDigits; + ACPI_INTEGER CurrentValue; + + + ACPI_FUNCTION_TRACE (ExDigitsNeeded); + + + /* ACPI_INTEGER is unsigned, so we don't worry about a '-' prefix */ + + if (Value == 0) + { + return_UINT32 (1); + } + + CurrentValue = Value; + NumDigits = 0; + + /* Count the digits in the requested base */ + + while (CurrentValue) + { + (void) AcpiUtShortDivide (CurrentValue, Base, &CurrentValue, NULL); + NumDigits++; + } + + return_UINT32 (NumDigits); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExEisaIdToString + * + * PARAMETERS: CompressedId - EISAID to be converted + * OutString - Where to put the converted string (8 bytes) + * + * RETURN: None + * + * DESCRIPTION: Convert a numeric EISAID to string representation. Return + * buffer must be large enough to hold the string. The string + * returned is always exactly of length ACPI_EISAID_STRING_SIZE + * (includes null terminator). The EISAID is always 32 bits. + * + ******************************************************************************/ + +void +AcpiExEisaIdToString ( + char *OutString, + ACPI_INTEGER CompressedId) +{ + UINT32 SwappedId; + + + ACPI_FUNCTION_ENTRY (); + + + /* The EISAID should be a 32-bit integer */ + + if (CompressedId > ACPI_UINT32_MAX) + { + ACPI_WARNING ((AE_INFO, + "Expected EISAID is larger than 32 bits: 0x%8.8X%8.8X, truncating", + ACPI_FORMAT_UINT64 (CompressedId))); + } + + /* Swap ID to big-endian to get contiguous bits */ + + SwappedId = AcpiUtDwordByteSwap ((UINT32) CompressedId); + + /* First 3 bytes are uppercase letters. Next 4 bytes are hexadecimal */ + + OutString[0] = (char) (0x40 + (((unsigned long) SwappedId >> 26) & 0x1F)); + OutString[1] = (char) (0x40 + ((SwappedId >> 21) & 0x1F)); + OutString[2] = (char) (0x40 + ((SwappedId >> 16) & 0x1F)); + OutString[3] = AcpiUtHexToAsciiChar ((ACPI_INTEGER) SwappedId, 12); + OutString[4] = AcpiUtHexToAsciiChar ((ACPI_INTEGER) SwappedId, 8); + OutString[5] = AcpiUtHexToAsciiChar ((ACPI_INTEGER) SwappedId, 4); + OutString[6] = AcpiUtHexToAsciiChar ((ACPI_INTEGER) SwappedId, 0); + OutString[7] = 0; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiExIntegerToString + * + * PARAMETERS: OutString - Where to put the converted string. At least + * 21 bytes are needed to hold the largest + * possible 64-bit integer. + * Value - Value to be converted + * + * RETURN: None, string + * + * DESCRIPTION: Convert a 64-bit integer to decimal string representation. + * Assumes string buffer is large enough to hold the string. The + * largest string is (ACPI_MAX64_DECIMAL_DIGITS + 1). + * + ******************************************************************************/ + +void +AcpiExIntegerToString ( + char *OutString, + ACPI_INTEGER Value) +{ + UINT32 Count; + UINT32 DigitsNeeded; + UINT32 Remainder; + + + ACPI_FUNCTION_ENTRY (); + + + DigitsNeeded = AcpiExDigitsNeeded (Value, 10); + OutString[DigitsNeeded] = 0; + + for (Count = DigitsNeeded; Count > 0; Count--) + { + (void) AcpiUtShortDivide (Value, 10, &Value, &Remainder); + OutString[Count-1] = (char) ('0' + Remainder);\ + } +} + +#endif diff --git a/reactos/drivers/bus/acpi/acpica/hardware/hwacpi.c b/reactos/drivers/bus/acpi/acpica/hardware/hwacpi.c new file mode 100644 index 00000000000..6b6d90ee02e --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/hardware/hwacpi.c @@ -0,0 +1,278 @@ + +/****************************************************************************** + * + * Module Name: hwacpi - ACPI Hardware Initialization/Mode Interface + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __HWACPI_C__ + +#include "acpi.h" +#include "accommon.h" + + +#define _COMPONENT ACPI_HARDWARE + ACPI_MODULE_NAME ("hwacpi") + + +/****************************************************************************** + * + * FUNCTION: AcpiHwSetMode + * + * PARAMETERS: Mode - SYS_MODE_ACPI or SYS_MODE_LEGACY + * + * RETURN: Status + * + * DESCRIPTION: Transitions the system into the requested mode. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwSetMode ( + UINT32 Mode) +{ + + ACPI_STATUS Status; + UINT32 Retry; + + + ACPI_FUNCTION_TRACE (HwSetMode); + + /* + * ACPI 2.0 clarified that if SMI_CMD in FADT is zero, + * system does not support mode transition. + */ + if (!AcpiGbl_FADT.SmiCommand) + { + ACPI_ERROR ((AE_INFO, "No SMI_CMD in FADT, mode transition failed")); + return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE); + } + + /* + * ACPI 2.0 clarified the meaning of ACPI_ENABLE and ACPI_DISABLE + * in FADT: If it is zero, enabling or disabling is not supported. + * As old systems may have used zero for mode transition, + * we make sure both the numbers are zero to determine these + * transitions are not supported. + */ + if (!AcpiGbl_FADT.AcpiEnable && !AcpiGbl_FADT.AcpiDisable) + { + ACPI_ERROR ((AE_INFO, + "No ACPI mode transition supported in this system " + "(enable/disable both zero)")); + return_ACPI_STATUS (AE_OK); + } + + switch (Mode) + { + case ACPI_SYS_MODE_ACPI: + + /* BIOS should have disabled ALL fixed and GP events */ + + Status = AcpiHwWritePort (AcpiGbl_FADT.SmiCommand, + (UINT32) AcpiGbl_FADT.AcpiEnable, 8); + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Attempting to enable ACPI mode\n")); + break; + + case ACPI_SYS_MODE_LEGACY: + + /* + * BIOS should clear all fixed status bits and restore fixed event + * enable bits to default + */ + Status = AcpiHwWritePort (AcpiGbl_FADT.SmiCommand, + (UINT32) AcpiGbl_FADT.AcpiDisable, 8); + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Attempting to enable Legacy (non-ACPI) mode\n")); + break; + + default: + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Could not write ACPI mode change")); + return_ACPI_STATUS (Status); + } + + /* + * Some hardware takes a LONG time to switch modes. Give them 3 sec to + * do so, but allow faster systems to proceed more quickly. + */ + Retry = 3000; + while (Retry) + { + if (AcpiHwGetMode() == Mode) + { + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Mode %X successfully enabled\n", + Mode)); + return_ACPI_STATUS (AE_OK); + } + AcpiOsStall(1000); + Retry--; + } + + ACPI_ERROR ((AE_INFO, "Hardware did not change modes")); + return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiHwGetMode + * + * PARAMETERS: none + * + * RETURN: SYS_MODE_ACPI or SYS_MODE_LEGACY + * + * DESCRIPTION: Return current operating state of system. Determined by + * querying the SCI_EN bit. + * + ******************************************************************************/ + +UINT32 +AcpiHwGetMode ( + void) +{ + ACPI_STATUS Status; + UINT32 Value; + + + ACPI_FUNCTION_TRACE (HwGetMode); + + + /* + * ACPI 2.0 clarified that if SMI_CMD in FADT is zero, + * system does not support mode transition. + */ + if (!AcpiGbl_FADT.SmiCommand) + { + return_UINT32 (ACPI_SYS_MODE_ACPI); + } + + Status = AcpiReadBitRegister (ACPI_BITREG_SCI_ENABLE, &Value); + if (ACPI_FAILURE (Status)) + { + return_UINT32 (ACPI_SYS_MODE_LEGACY); + } + + if (Value) + { + return_UINT32 (ACPI_SYS_MODE_ACPI); + } + else + { + return_UINT32 (ACPI_SYS_MODE_LEGACY); + } +} diff --git a/reactos/drivers/bus/acpi/acpica/hardware/hwgpe.c b/reactos/drivers/bus/acpi/acpica/hardware/hwgpe.c new file mode 100644 index 00000000000..a45603d9d5f --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/hardware/hwgpe.c @@ -0,0 +1,597 @@ + +/****************************************************************************** + * + * Module Name: hwgpe - Low level GPE enable/disable/clear functions + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 "acpi.h" +#include "accommon.h" +#include "acevents.h" + +#define _COMPONENT ACPI_HARDWARE + ACPI_MODULE_NAME ("hwgpe") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiHwEnableWakeupGpeBlock ( + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *Context); + + +/****************************************************************************** + * + * FUNCTION: AcpiHwLowDisableGpe + * + * PARAMETERS: GpeEventInfo - Info block for the GPE to be disabled + * + * RETURN: Status + * + * DESCRIPTION: Disable a single GPE in the enable register. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwLowDisableGpe ( + ACPI_GPE_EVENT_INFO *GpeEventInfo) +{ + ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; + ACPI_STATUS Status; + UINT32 EnableMask; + + + /* Get the info block for the entire GPE register */ + + GpeRegisterInfo = GpeEventInfo->RegisterInfo; + if (!GpeRegisterInfo) + { + return (AE_NOT_EXIST); + } + + /* Get current value of the enable register that contains this GPE */ + + Status = AcpiHwRead (&EnableMask, &GpeRegisterInfo->EnableAddress); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* 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 = AcpiHwWrite (EnableMask, &GpeRegisterInfo->EnableAddress); + return (Status); +} + + +/****************************************************************************** + * + * 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; + + + ACPI_FUNCTION_ENTRY (); + + + /* Get the info block for the entire GPE register */ + + GpeRegisterInfo = GpeEventInfo->RegisterInfo; + if (!GpeRegisterInfo) + { + return (AE_NOT_EXIST); + } + + /* Write the entire GPE (runtime) enable register */ + + Status = AcpiHwWrite (GpeRegisterInfo->EnableForRun, + &GpeRegisterInfo->EnableAddress); + + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwClearGpe + * + * PARAMETERS: GpeEventInfo - Info block for the GPE to be cleared + * + * RETURN: Status + * + * DESCRIPTION: Clear the status bit for a single GPE. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwClearGpe ( + ACPI_GPE_EVENT_INFO *GpeEventInfo) +{ + ACPI_STATUS Status; + UINT8 RegisterBit; + + + ACPI_FUNCTION_ENTRY (); + + + RegisterBit = (UINT8) (1 << + (GpeEventInfo->GpeNumber - GpeEventInfo->RegisterInfo->BaseGpeNumber)); + + /* + * Write a one to the appropriate bit in the status register to + * clear this GPE. + */ + Status = AcpiHwWrite (RegisterBit, + &GpeEventInfo->RegisterInfo->StatusAddress); + + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwGetGpeStatus + * + * PARAMETERS: GpeEventInfo - Info block for the GPE to queried + * EventStatus - Where the GPE status is returned + * + * RETURN: Status + * + * DESCRIPTION: Return the status of a single GPE. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwGetGpeStatus ( + ACPI_GPE_EVENT_INFO *GpeEventInfo, + ACPI_EVENT_STATUS *EventStatus) +{ + UINT32 InByte; + UINT8 RegisterBit; + ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; + ACPI_STATUS Status; + ACPI_EVENT_STATUS LocalEventStatus = 0; + + + ACPI_FUNCTION_ENTRY (); + + + if (!EventStatus) + { + return (AE_BAD_PARAMETER); + } + + /* Get the info block for the entire GPE register */ + + GpeRegisterInfo = GpeEventInfo->RegisterInfo; + + /* Get the register bitmask for this GPE */ + + RegisterBit = (UINT8) (1 << + (GpeEventInfo->GpeNumber - GpeEventInfo->RegisterInfo->BaseGpeNumber)); + + /* GPE currently enabled? (enabled for runtime?) */ + + if (RegisterBit & GpeRegisterInfo->EnableForRun) + { + LocalEventStatus |= ACPI_EVENT_FLAG_ENABLED; + } + + /* GPE enabled for wake? */ + + if (RegisterBit & GpeRegisterInfo->EnableForWake) + { + LocalEventStatus |= ACPI_EVENT_FLAG_WAKE_ENABLED; + } + + /* GPE currently active (status bit == 1)? */ + + Status = AcpiHwRead (&InByte, &GpeRegisterInfo->StatusAddress); + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + + if (RegisterBit & InByte) + { + LocalEventStatus |= ACPI_EVENT_FLAG_SET; + } + + /* Set return value */ + + (*EventStatus) = LocalEventStatus; + + +UnlockAndExit: + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwDisableGpeBlock + * + * PARAMETERS: GpeXruptInfo - GPE Interrupt info + * GpeBlock - Gpe Block info + * + * RETURN: Status + * + * DESCRIPTION: Disable all GPEs within a single GPE block + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwDisableGpeBlock ( + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *Context) +{ + UINT32 i; + ACPI_STATUS Status; + + + /* Examine each GPE Register within the block */ + + for (i = 0; i < GpeBlock->RegisterCount; i++) + { + /* Disable all GPEs in this register */ + + Status = AcpiHwWrite (0x00, &GpeBlock->RegisterInfo[i].EnableAddress); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwClearGpeBlock + * + * PARAMETERS: GpeXruptInfo - GPE Interrupt info + * GpeBlock - Gpe Block info + * + * RETURN: Status + * + * DESCRIPTION: Clear status bits for all GPEs within a single GPE block + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwClearGpeBlock ( + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *Context) +{ + UINT32 i; + ACPI_STATUS Status; + + + /* Examine each GPE Register within the block */ + + for (i = 0; i < GpeBlock->RegisterCount; i++) + { + /* Clear status on all GPEs in this register */ + + Status = AcpiHwWrite (0xFF, &GpeBlock->RegisterInfo[i].StatusAddress); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwEnableRuntimeGpeBlock + * + * PARAMETERS: GpeXruptInfo - GPE Interrupt info + * GpeBlock - Gpe Block info + * + * RETURN: Status + * + * DESCRIPTION: Enable all "runtime" GPEs within a single GPE block. Includes + * combination wake/run GPEs. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwEnableRuntimeGpeBlock ( + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *Context) +{ + UINT32 i; + ACPI_STATUS Status; + + + /* NOTE: assumes that all GPEs are currently disabled */ + + /* Examine each GPE Register within the block */ + + for (i = 0; i < GpeBlock->RegisterCount; i++) + { + if (!GpeBlock->RegisterInfo[i].EnableForRun) + { + continue; + } + + /* Enable all "runtime" GPEs in this register */ + + Status = AcpiHwWrite (GpeBlock->RegisterInfo[i].EnableForRun, + &GpeBlock->RegisterInfo[i].EnableAddress); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwEnableWakeupGpeBlock + * + * PARAMETERS: GpeXruptInfo - GPE Interrupt info + * GpeBlock - Gpe Block info + * + * RETURN: Status + * + * DESCRIPTION: Enable all "wake" GPEs within a single GPE block. Includes + * combination wake/run GPEs. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiHwEnableWakeupGpeBlock ( + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *Context) +{ + UINT32 i; + ACPI_STATUS Status; + + + /* Examine each GPE Register within the block */ + + for (i = 0; i < GpeBlock->RegisterCount; i++) + { + if (!GpeBlock->RegisterInfo[i].EnableForWake) + { + continue; + } + + /* Enable all "wake" GPEs in this register */ + + Status = AcpiHwWrite (GpeBlock->RegisterInfo[i].EnableForWake, + &GpeBlock->RegisterInfo[i].EnableAddress); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwDisableAllGpes + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Disable and clear all GPEs in all GPE blocks + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwDisableAllGpes ( + void) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (HwDisableAllGpes); + + + Status = AcpiEvWalkGpeList (AcpiHwDisableGpeBlock, NULL); + Status = AcpiEvWalkGpeList (AcpiHwClearGpeBlock, NULL); + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwEnableAllRuntimeGpes + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwEnableAllRuntimeGpes ( + void) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (HwEnableAllRuntimeGpes); + + + Status = AcpiEvWalkGpeList (AcpiHwEnableRuntimeGpeBlock, NULL); + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwEnableAllWakeupGpes + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Enable all "wakeup" GPEs, in all GPE blocks + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwEnableAllWakeupGpes ( + void) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (HwEnableAllWakeupGpes); + + + Status = AcpiEvWalkGpeList (AcpiHwEnableWakeupGpeBlock, NULL); + return_ACPI_STATUS (Status); +} + diff --git a/reactos/drivers/bus/acpi/acpica/hardware/hwregs.c b/reactos/drivers/bus/acpi/acpica/hardware/hwregs.c new file mode 100644 index 00000000000..163840d7f4a --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/hardware/hwregs.c @@ -0,0 +1,805 @@ + +/******************************************************************************* + * + * Module Name: hwregs - Read/write access functions for the various ACPI + * control and status registers. + * + ******************************************************************************/ + +/****************************************************************************** + * + * 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 __HWREGS_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acevents.h" + +#define _COMPONENT ACPI_HARDWARE + ACPI_MODULE_NAME ("hwregs") + + +/* Local Prototypes */ + +static ACPI_STATUS +AcpiHwReadMultiple ( + UINT32 *Value, + ACPI_GENERIC_ADDRESS *RegisterA, + ACPI_GENERIC_ADDRESS *RegisterB); + +static ACPI_STATUS +AcpiHwWriteMultiple ( + UINT32 Value, + ACPI_GENERIC_ADDRESS *RegisterA, + ACPI_GENERIC_ADDRESS *RegisterB); + + +/****************************************************************************** + * + * FUNCTION: AcpiHwValidateRegister + * + * PARAMETERS: Reg - GAS register structure + * MaxBitWidth - Max BitWidth supported (32 or 64) + * Address - Pointer to where the gas->address + * is returned + * + * RETURN: Status + * + * DESCRIPTION: Validate the contents of a GAS register. Checks the GAS + * pointer, Address, SpaceId, BitWidth, and BitOffset. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwValidateRegister ( + ACPI_GENERIC_ADDRESS *Reg, + UINT8 MaxBitWidth, + UINT64 *Address) +{ + + /* Must have a valid pointer to a GAS structure */ + + if (!Reg) + { + return (AE_BAD_PARAMETER); + } + + /* + * Copy the target address. This handles possible alignment issues. + * Address must not be null. A null address also indicates an optional + * ACPI register that is not supported, so no error message. + */ + ACPI_MOVE_64_TO_64 (Address, &Reg->Address); + if (!(*Address)) + { + return (AE_BAD_ADDRESS); + } + + /* Validate the SpaceID */ + + if ((Reg->SpaceId != ACPI_ADR_SPACE_SYSTEM_MEMORY) && + (Reg->SpaceId != ACPI_ADR_SPACE_SYSTEM_IO)) + { + ACPI_ERROR ((AE_INFO, + "Unsupported address space: 0x%X", Reg->SpaceId)); + return (AE_SUPPORT); + } + + /* Validate the BitWidth */ + + if ((Reg->BitWidth != 8) && + (Reg->BitWidth != 16) && + (Reg->BitWidth != 32) && + (Reg->BitWidth != MaxBitWidth)) + { + ACPI_ERROR ((AE_INFO, + "Unsupported register bit width: 0x%X", Reg->BitWidth)); + return (AE_SUPPORT); + } + + /* Validate the BitOffset. Just a warning for now. */ + + if (Reg->BitOffset != 0) + { + ACPI_WARNING ((AE_INFO, + "Unsupported register bit offset: 0x%X", Reg->BitOffset)); + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwRead + * + * PARAMETERS: Value - Where the value is returned + * Reg - GAS register structure + * + * RETURN: Status + * + * DESCRIPTION: Read from either memory or IO space. This is a 32-bit max + * version of AcpiRead, used internally since the overhead of + * 64-bit values is not needed. + * + * LIMITATIONS: + * BitWidth must be exactly 8, 16, or 32. + * SpaceID must be SystemMemory or SystemIO. + * BitOffset and AccessWidth are currently ignored, as there has + * not been a need to implement these. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwRead ( + UINT32 *Value, + ACPI_GENERIC_ADDRESS *Reg) +{ + UINT64 Address; + ACPI_STATUS Status; + + + ACPI_FUNCTION_NAME (HwRead); + + + /* Validate contents of the GAS register */ + + Status = AcpiHwValidateRegister (Reg, 32, &Address); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Initialize entire 32-bit return value to zero */ + + *Value = 0; + + /* + * Two address spaces supported: Memory or IO. PCI_Config is + * not supported here because the GAS structure is insufficient + */ + if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY) + { + Status = AcpiOsReadMemory ((ACPI_PHYSICAL_ADDRESS) + Address, Value, Reg->BitWidth); + } + else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ + { + Status = AcpiHwReadPort ((ACPI_IO_ADDRESS) + Address, Value, Reg->BitWidth); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_IO, + "Read: %8.8X width %2d from %8.8X%8.8X (%s)\n", + *Value, Reg->BitWidth, ACPI_FORMAT_UINT64 (Address), + AcpiUtGetRegionName (Reg->SpaceId))); + + return (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwWrite + * + * PARAMETERS: Value - Value to be written + * Reg - GAS register structure + * + * RETURN: Status + * + * DESCRIPTION: Write to either memory or IO space. This is a 32-bit max + * version of AcpiWrite, used internally since the overhead of + * 64-bit values is not needed. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwWrite ( + UINT32 Value, + ACPI_GENERIC_ADDRESS *Reg) +{ + UINT64 Address; + ACPI_STATUS Status; + + + ACPI_FUNCTION_NAME (HwWrite); + + + /* Validate contents of the GAS register */ + + Status = AcpiHwValidateRegister (Reg, 32, &Address); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* + * Two address spaces supported: Memory or IO. PCI_Config is + * not supported here because the GAS structure is insufficient + */ + if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY) + { + Status = AcpiOsWriteMemory ((ACPI_PHYSICAL_ADDRESS) + Address, Value, Reg->BitWidth); + } + else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ + { + Status = AcpiHwWritePort ((ACPI_IO_ADDRESS) + Address, Value, Reg->BitWidth); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_IO, + "Wrote: %8.8X width %2d to %8.8X%8.8X (%s)\n", + Value, Reg->BitWidth, ACPI_FORMAT_UINT64 (Address), + AcpiUtGetRegionName (Reg->SpaceId))); + + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiHwClearAcpiStatus + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Clears all fixed and general purpose status bits + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwClearAcpiStatus ( + void) +{ + ACPI_STATUS Status; + ACPI_CPU_FLAGS LockFlags = 0; + + + ACPI_FUNCTION_TRACE (HwClearAcpiStatus); + + + ACPI_DEBUG_PRINT ((ACPI_DB_IO, "About to write %04X to %8.8X%8.8X\n", + ACPI_BITMASK_ALL_FIXED_STATUS, + ACPI_FORMAT_UINT64 (AcpiGbl_XPm1aStatus.Address))); + + LockFlags = AcpiOsAcquireLock (AcpiGbl_HardwareLock); + + /* Clear the fixed events in PM1 A/B */ + + Status = AcpiHwRegisterWrite (ACPI_REGISTER_PM1_STATUS, + ACPI_BITMASK_ALL_FIXED_STATUS); + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + + /* Clear the GPE Bits in all GPE registers in all GPE blocks */ + + Status = AcpiEvWalkGpeList (AcpiHwClearGpeBlock, NULL); + +UnlockAndExit: + AcpiOsReleaseLock (AcpiGbl_HardwareLock, LockFlags); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiHwGetRegisterBitMask + * + * PARAMETERS: RegisterId - Index of ACPI Register to access + * + * RETURN: The bitmask to be used when accessing the register + * + * DESCRIPTION: Map RegisterId into a register bitmask. + * + ******************************************************************************/ + +ACPI_BIT_REGISTER_INFO * +AcpiHwGetBitRegisterInfo ( + UINT32 RegisterId) +{ + ACPI_FUNCTION_ENTRY (); + + + if (RegisterId > ACPI_BITREG_MAX) + { + ACPI_ERROR ((AE_INFO, "Invalid BitRegister ID: %X", RegisterId)); + return (NULL); + } + + return (&AcpiGbl_BitRegisterInfo[RegisterId]); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwWritePm1Control + * + * PARAMETERS: Pm1aControl - Value to be written to PM1A control + * Pm1bControl - Value to be written to PM1B control + * + * RETURN: Status + * + * DESCRIPTION: Write the PM1 A/B control registers. These registers are + * different than than the PM1 A/B status and enable registers + * in that different values can be written to the A/B registers. + * Most notably, the SLP_TYP bits can be different, as per the + * values returned from the _Sx predefined methods. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwWritePm1Control ( + UINT32 Pm1aControl, + UINT32 Pm1bControl) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (HwWritePm1Control); + + + Status = AcpiHwWrite (Pm1aControl, &AcpiGbl_FADT.XPm1aControlBlock); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (AcpiGbl_FADT.XPm1bControlBlock.Address) + { + Status = AcpiHwWrite (Pm1bControl, &AcpiGbl_FADT.XPm1bControlBlock); + } + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwRegisterRead + * + * PARAMETERS: RegisterId - ACPI Register ID + * ReturnValue - Where the register value is returned + * + * RETURN: Status and the value read. + * + * DESCRIPTION: Read from the specified ACPI register + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwRegisterRead ( + UINT32 RegisterId, + UINT32 *ReturnValue) +{ + UINT32 Value = 0; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (HwRegisterRead); + + + switch (RegisterId) + { + case ACPI_REGISTER_PM1_STATUS: /* PM1 A/B: 16-bit access each */ + + Status = AcpiHwReadMultiple (&Value, + &AcpiGbl_XPm1aStatus, + &AcpiGbl_XPm1bStatus); + break; + + + case ACPI_REGISTER_PM1_ENABLE: /* PM1 A/B: 16-bit access each */ + + Status = AcpiHwReadMultiple (&Value, + &AcpiGbl_XPm1aEnable, + &AcpiGbl_XPm1bEnable); + break; + + + case ACPI_REGISTER_PM1_CONTROL: /* PM1 A/B: 16-bit access each */ + + Status = AcpiHwReadMultiple (&Value, + &AcpiGbl_FADT.XPm1aControlBlock, + &AcpiGbl_FADT.XPm1bControlBlock); + + /* + * Zero the write-only bits. From the ACPI specification, "Hardware + * Write-Only Bits": "Upon reads to registers with write-only bits, + * software masks out all write-only bits." + */ + Value &= ~ACPI_PM1_CONTROL_WRITEONLY_BITS; + break; + + + case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */ + + Status = AcpiHwRead (&Value, &AcpiGbl_FADT.XPm2ControlBlock); + break; + + + case ACPI_REGISTER_PM_TIMER: /* 32-bit access */ + + Status = AcpiHwRead (&Value, &AcpiGbl_FADT.XPmTimerBlock); + break; + + + case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */ + + Status = AcpiHwReadPort (AcpiGbl_FADT.SmiCommand, &Value, 8); + break; + + + default: + ACPI_ERROR ((AE_INFO, "Unknown Register ID: %X", + RegisterId)); + Status = AE_BAD_PARAMETER; + break; + } + + if (ACPI_SUCCESS (Status)) + { + *ReturnValue = Value; + } + + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwRegisterWrite + * + * PARAMETERS: RegisterId - ACPI Register ID + * Value - The value to write + * + * RETURN: Status + * + * DESCRIPTION: Write to the specified ACPI register + * + * NOTE: In accordance with the ACPI specification, this function automatically + * preserves the value of the following bits, meaning that these bits cannot be + * changed via this interface: + * + * PM1_CONTROL[0] = SCI_EN + * PM1_CONTROL[9] + * PM1_STATUS[11] + * + * ACPI References: + * 1) Hardware Ignored Bits: When software writes to a register with ignored + * bit fields, it preserves the ignored bit fields + * 2) SCI_EN: OSPM always preserves this bit position + * + ******************************************************************************/ + +ACPI_STATUS +AcpiHwRegisterWrite ( + UINT32 RegisterId, + UINT32 Value) +{ + ACPI_STATUS Status; + UINT32 ReadValue; + + + ACPI_FUNCTION_TRACE (HwRegisterWrite); + + + switch (RegisterId) + { + case ACPI_REGISTER_PM1_STATUS: /* PM1 A/B: 16-bit access each */ + /* + * Handle the "ignored" bit in PM1 Status. According to the ACPI + * specification, ignored bits are to be preserved when writing. + * Normally, this would mean a read/modify/write sequence. However, + * preserving a bit in the status register is different. Writing a + * one clears the status, and writing a zero preserves the status. + * Therefore, we must always write zero to the ignored bit. + * + * This behavior is clarified in the ACPI 4.0 specification. + */ + Value &= ~ACPI_PM1_STATUS_PRESERVED_BITS; + + Status = AcpiHwWriteMultiple (Value, + &AcpiGbl_XPm1aStatus, + &AcpiGbl_XPm1bStatus); + break; + + + case ACPI_REGISTER_PM1_ENABLE: /* PM1 A/B: 16-bit access each */ + + Status = AcpiHwWriteMultiple (Value, + &AcpiGbl_XPm1aEnable, + &AcpiGbl_XPm1bEnable); + break; + + + case ACPI_REGISTER_PM1_CONTROL: /* PM1 A/B: 16-bit access each */ + + /* + * Perform a read first to preserve certain bits (per ACPI spec) + * Note: This includes SCI_EN, we never want to change this bit + */ + Status = AcpiHwReadMultiple (&ReadValue, + &AcpiGbl_FADT.XPm1aControlBlock, + &AcpiGbl_FADT.XPm1bControlBlock); + if (ACPI_FAILURE (Status)) + { + goto Exit; + } + + /* Insert the bits to be preserved */ + + ACPI_INSERT_BITS (Value, ACPI_PM1_CONTROL_PRESERVED_BITS, ReadValue); + + /* Now we can write the data */ + + Status = AcpiHwWriteMultiple (Value, + &AcpiGbl_FADT.XPm1aControlBlock, + &AcpiGbl_FADT.XPm1bControlBlock); + break; + + + case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */ + + /* + * For control registers, all reserved bits must be preserved, + * as per the ACPI spec. + */ + Status = AcpiHwRead (&ReadValue, &AcpiGbl_FADT.XPm2ControlBlock); + if (ACPI_FAILURE (Status)) + { + goto Exit; + } + + /* Insert the bits to be preserved */ + + ACPI_INSERT_BITS (Value, ACPI_PM2_CONTROL_PRESERVED_BITS, ReadValue); + + Status = AcpiHwWrite (Value, &AcpiGbl_FADT.XPm2ControlBlock); + break; + + + case ACPI_REGISTER_PM_TIMER: /* 32-bit access */ + + Status = AcpiHwWrite (Value, &AcpiGbl_FADT.XPmTimerBlock); + break; + + + case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */ + + /* SMI_CMD is currently always in IO space */ + + Status = AcpiHwWritePort (AcpiGbl_FADT.SmiCommand, Value, 8); + break; + + + default: + ACPI_ERROR ((AE_INFO, "Unknown Register ID: %X", + RegisterId)); + Status = AE_BAD_PARAMETER; + break; + } + +Exit: + return_ACPI_STATUS (Status); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwReadMultiple + * + * PARAMETERS: Value - Where the register value is returned + * RegisterA - First ACPI register (required) + * RegisterB - Second ACPI register (optional) + * + * RETURN: Status + * + * DESCRIPTION: Read from the specified two-part ACPI register (such as PM1 A/B) + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiHwReadMultiple ( + UINT32 *Value, + ACPI_GENERIC_ADDRESS *RegisterA, + ACPI_GENERIC_ADDRESS *RegisterB) +{ + UINT32 ValueA = 0; + UINT32 ValueB = 0; + ACPI_STATUS Status; + + + /* The first register is always required */ + + Status = AcpiHwRead (&ValueA, RegisterA); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Second register is optional */ + + if (RegisterB->Address) + { + Status = AcpiHwRead (&ValueB, RegisterB); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + + /* + * OR the two return values together. No shifting or masking is necessary, + * because of how the PM1 registers are defined in the ACPI specification: + * + * "Although the bits can be split between the two register blocks (each + * register block has a unique pointer within the FADT), the bit positions + * are maintained. The register block with unimplemented bits (that is, + * those implemented in the other register block) always returns zeros, + * and writes have no side effects" + */ + *Value = (ValueA | ValueB); + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwWriteMultiple + * + * PARAMETERS: Value - The value to write + * RegisterA - First ACPI register (required) + * RegisterB - Second ACPI register (optional) + * + * RETURN: Status + * + * DESCRIPTION: Write to the specified two-part ACPI register (such as PM1 A/B) + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiHwWriteMultiple ( + UINT32 Value, + ACPI_GENERIC_ADDRESS *RegisterA, + ACPI_GENERIC_ADDRESS *RegisterB) +{ + ACPI_STATUS Status; + + + /* The first register is always required */ + + Status = AcpiHwWrite (Value, RegisterA); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* + * Second register is optional + * + * No bit shifting or clearing is necessary, because of how the PM1 + * registers are defined in the ACPI specification: + * + * "Although the bits can be split between the two register blocks (each + * register block has a unique pointer within the FADT), the bit positions + * are maintained. The register block with unimplemented bits (that is, + * those implemented in the other register block) always returns zeros, + * and writes have no side effects" + */ + if (RegisterB->Address) + { + Status = AcpiHwWrite (Value, RegisterB); + } + + return (Status); +} + diff --git a/reactos/drivers/bus/acpi/acpica/hardware/hwsleep.c b/reactos/drivers/bus/acpi/acpica/hardware/hwsleep.c new file mode 100644 index 00000000000..fed4f1ddbf7 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/hardware/hwsleep.c @@ -0,0 +1,711 @@ + +/****************************************************************************** + * + * Name: hwsleep.c - ACPI Hardware Sleep/Wake Interface + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 "acpi.h" +#include "accommon.h" + +#define _COMPONENT ACPI_HARDWARE + ACPI_MODULE_NAME ("hwsleep") + + +/******************************************************************************* + * + * FUNCTION: AcpiSetFirmwareWakingVector + * + * PARAMETERS: PhysicalAddress - 32-bit physical address of ACPI real mode + * entry point. + * + * RETURN: Status + * + * DESCRIPTION: Sets the 32-bit FirmwareWakingVector field of the FACS + * + ******************************************************************************/ + +ACPI_STATUS +AcpiSetFirmwareWakingVector ( + UINT32 PhysicalAddress) +{ + ACPI_FUNCTION_TRACE (AcpiSetFirmwareWakingVector); + + + /* Set the 32-bit vector */ + + AcpiGbl_FACS->FirmwareWakingVector = PhysicalAddress; + + /* Clear the 64-bit vector if it exists */ + + if ((AcpiGbl_FACS->Length > 32) && (AcpiGbl_FACS->Version >= 1)) + { + AcpiGbl_FACS->XFirmwareWakingVector = 0; + } + + return_ACPI_STATUS (AE_OK); +} + +ACPI_EXPORT_SYMBOL (AcpiSetFirmwareWakingVector) + + +#if ACPI_MACHINE_WIDTH == 64 +/******************************************************************************* + * + * FUNCTION: AcpiSetFirmwareWakingVector64 + * + * PARAMETERS: PhysicalAddress - 64-bit physical address of ACPI protected + * mode entry point. + * + * RETURN: Status + * + * DESCRIPTION: Sets the 64-bit X_FirmwareWakingVector field of the FACS, if + * it exists in the table. This function is intended for use with + * 64-bit host operating systems. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiSetFirmwareWakingVector64 ( + UINT64 PhysicalAddress) +{ + ACPI_FUNCTION_TRACE (AcpiSetFirmwareWakingVector64); + + + /* Determine if the 64-bit vector actually exists */ + + if ((AcpiGbl_FACS->Length <= 32) || (AcpiGbl_FACS->Version < 1)) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + /* Clear 32-bit vector, set the 64-bit X_ vector */ + + AcpiGbl_FACS->FirmwareWakingVector = 0; + AcpiGbl_FACS->XFirmwareWakingVector = PhysicalAddress; + return_ACPI_STATUS (AE_OK); +} + +ACPI_EXPORT_SYMBOL (AcpiSetFirmwareWakingVector64) +#endif + +/******************************************************************************* + * + * FUNCTION: AcpiEnterSleepStatePrep + * + * PARAMETERS: SleepState - Which sleep state to enter + * + * RETURN: Status + * + * DESCRIPTION: Prepare to enter a system sleep state (see ACPI 2.0 spec p 231) + * This function must execute with interrupts enabled. + * We break sleeping into 2 stages so that OSPM can handle + * various OS-specific tasks between the two steps. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEnterSleepStatePrep ( + UINT8 SleepState) +{ + ACPI_STATUS Status; + ACPI_OBJECT_LIST ArgList; + ACPI_OBJECT Arg; + + + ACPI_FUNCTION_TRACE (AcpiEnterSleepStatePrep); + + + /* _PSW methods could be run here to enable wake-on keyboard, LAN, etc. */ + + Status = AcpiGetSleepTypeData (SleepState, + &AcpiGbl_SleepTypeA, &AcpiGbl_SleepTypeB); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Execute the _PTS method (Prepare To Sleep) */ + + ArgList.Count = 1; + ArgList.Pointer = &Arg; + Arg.Type = ACPI_TYPE_INTEGER; + Arg.Integer.Value = SleepState; + + Status = AcpiEvaluateObject (NULL, METHOD_NAME__PTS, &ArgList, NULL); + if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) + { + return_ACPI_STATUS (Status); + } + + /* Setup the argument to the _SST method (System STatus) */ + + switch (SleepState) + { + case ACPI_STATE_S0: + Arg.Integer.Value = ACPI_SST_WORKING; + break; + + case ACPI_STATE_S1: + case ACPI_STATE_S2: + case ACPI_STATE_S3: + Arg.Integer.Value = ACPI_SST_SLEEPING; + break; + + case ACPI_STATE_S4: + Arg.Integer.Value = ACPI_SST_SLEEP_CONTEXT; + break; + + default: + Arg.Integer.Value = ACPI_SST_INDICATOR_OFF; /* Default is off */ + break; + } + + /* + * Set the system indicators to show the desired sleep state. + * _SST is an optional method (return no error if not found) + */ + Status = AcpiEvaluateObject (NULL, METHOD_NAME__SST, &ArgList, NULL); + if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) + { + ACPI_EXCEPTION ((AE_INFO, Status, "While executing method _SST")); + } + + return_ACPI_STATUS (AE_OK); +} + +ACPI_EXPORT_SYMBOL (AcpiEnterSleepStatePrep) + + +/******************************************************************************* + * + * FUNCTION: AcpiEnterSleepState + * + * PARAMETERS: SleepState - Which sleep state to enter + * + * RETURN: Status + * + * DESCRIPTION: Enter a system sleep state + * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEnterSleepState ( + UINT8 SleepState) +{ + UINT32 Pm1aControl; + UINT32 Pm1bControl; + ACPI_BIT_REGISTER_INFO *SleepTypeRegInfo; + ACPI_BIT_REGISTER_INFO *SleepEnableRegInfo; + UINT32 InValue; + ACPI_OBJECT_LIST ArgList; + ACPI_OBJECT Arg; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiEnterSleepState); + + + if ((AcpiGbl_SleepTypeA > ACPI_SLEEP_TYPE_MAX) || + (AcpiGbl_SleepTypeB > ACPI_SLEEP_TYPE_MAX)) + { + ACPI_ERROR ((AE_INFO, "Sleep values out of range: A=%X B=%X", + AcpiGbl_SleepTypeA, AcpiGbl_SleepTypeB)); + return_ACPI_STATUS (AE_AML_OPERAND_VALUE); + } + + SleepTypeRegInfo = AcpiHwGetBitRegisterInfo (ACPI_BITREG_SLEEP_TYPE); + SleepEnableRegInfo = AcpiHwGetBitRegisterInfo (ACPI_BITREG_SLEEP_ENABLE); + + /* Clear wake status */ + + Status = AcpiWriteBitRegister (ACPI_BITREG_WAKE_STATUS, ACPI_CLEAR_STATUS); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Clear all fixed and general purpose status bits */ + + Status = AcpiHwClearAcpiStatus (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (SleepState != ACPI_STATE_S5) + { + /* + * Disable BM arbitration. This feature is contained within an + * optional register (PM2 Control), so ignore a BAD_ADDRESS + * exception. + */ + Status = AcpiWriteBitRegister (ACPI_BITREG_ARB_DISABLE, 1); + if (ACPI_FAILURE (Status) && (Status != AE_BAD_ADDRESS)) + { + return_ACPI_STATUS (Status); + } + } + + /* + * 1) Disable/Clear all GPEs + * 2) Enable all wakeup GPEs + */ + Status = AcpiHwDisableAllGpes (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + AcpiGbl_SystemAwakeAndRunning = FALSE; + + Status = AcpiHwEnableAllWakeupGpes (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Execute the _GTS method (Going To Sleep) */ + + ArgList.Count = 1; + ArgList.Pointer = &Arg; + Arg.Type = ACPI_TYPE_INTEGER; + Arg.Integer.Value = SleepState; + + Status = AcpiEvaluateObject (NULL, METHOD_NAME__GTS, &ArgList, NULL); + if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) + { + return_ACPI_STATUS (Status); + } + + /* Get current value of PM1A control */ + + Status = AcpiHwRegisterRead (ACPI_REGISTER_PM1_CONTROL, + &Pm1aControl); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + ACPI_DEBUG_PRINT ((ACPI_DB_INIT, + "Entering sleep state [S%d]\n", SleepState)); + + /* Clear the SLP_EN and SLP_TYP fields */ + + Pm1aControl &= ~(SleepTypeRegInfo->AccessBitMask | + SleepEnableRegInfo->AccessBitMask); + Pm1bControl = Pm1aControl; + + /* Insert the SLP_TYP bits */ + + Pm1aControl |= (AcpiGbl_SleepTypeA << SleepTypeRegInfo->BitPosition); + Pm1bControl |= (AcpiGbl_SleepTypeB << SleepTypeRegInfo->BitPosition); + + /* + * We split the writes of SLP_TYP and SLP_EN to workaround + * poorly implemented hardware. + */ + + /* Write #1: write the SLP_TYP data to the PM1 Control registers */ + + Status = AcpiHwWritePm1Control (Pm1aControl, Pm1bControl); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Insert the sleep enable (SLP_EN) bit */ + + Pm1aControl |= SleepEnableRegInfo->AccessBitMask; + Pm1bControl |= SleepEnableRegInfo->AccessBitMask; + + /* Flush caches, as per ACPI specification */ + + ACPI_FLUSH_CPU_CACHE (); + + /* Write #2: Write both SLP_TYP + SLP_EN */ + + Status = AcpiHwWritePm1Control (Pm1aControl, Pm1bControl); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (SleepState > ACPI_STATE_S3) + { + /* + * We wanted to sleep > S3, but it didn't happen (by virtue of the + * fact that we are still executing!) + * + * Wait ten seconds, then try again. This is to get S4/S5 to work on + * all machines. + * + * We wait so long to allow chipsets that poll this reg very slowly + * to still read the right value. Ideally, this block would go + * away entirely. + */ + AcpiOsStall (10000000); + + Status = AcpiHwRegisterWrite (ACPI_REGISTER_PM1_CONTROL, + SleepEnableRegInfo->AccessBitMask); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* Wait until we enter sleep state */ + + do + { + Status = AcpiReadBitRegister (ACPI_BITREG_WAKE_STATUS, &InValue); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Spin until we wake */ + + } while (!InValue); + + return_ACPI_STATUS (AE_OK); +} + +ACPI_EXPORT_SYMBOL (AcpiEnterSleepState) + + +/******************************************************************************* + * + * FUNCTION: AcpiEnterSleepStateS4bios + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Perform a S4 bios request. + * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEnterSleepStateS4bios ( + void) +{ + UINT32 InValue; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiEnterSleepStateS4bios); + + + /* Clear the wake status bit (PM1) */ + + Status = AcpiWriteBitRegister (ACPI_BITREG_WAKE_STATUS, ACPI_CLEAR_STATUS); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiHwClearAcpiStatus (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * 1) Disable/Clear all GPEs + * 2) Enable all wakeup GPEs + */ + Status = AcpiHwDisableAllGpes (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + AcpiGbl_SystemAwakeAndRunning = FALSE; + + Status = AcpiHwEnableAllWakeupGpes (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + ACPI_FLUSH_CPU_CACHE (); + + Status = AcpiHwWritePort (AcpiGbl_FADT.SmiCommand, + (UINT32) AcpiGbl_FADT.S4BiosRequest, 8); + + do { + AcpiOsStall(1000); + Status = AcpiReadBitRegister (ACPI_BITREG_WAKE_STATUS, &InValue); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } while (!InValue); + + return_ACPI_STATUS (AE_OK); +} + +ACPI_EXPORT_SYMBOL (AcpiEnterSleepStateS4bios) + + +/******************************************************************************* + * + * FUNCTION: AcpiLeaveSleepState + * + * PARAMETERS: SleepState - Which sleep state we just exited + * + * RETURN: Status + * + * DESCRIPTION: Perform OS-independent ACPI cleanup after a sleep + * Called with interrupts ENABLED. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiLeaveSleepState ( + UINT8 SleepState) +{ + ACPI_OBJECT_LIST ArgList; + ACPI_OBJECT Arg; + ACPI_STATUS Status; + ACPI_BIT_REGISTER_INFO *SleepTypeRegInfo; + ACPI_BIT_REGISTER_INFO *SleepEnableRegInfo; + UINT32 Pm1aControl; + UINT32 Pm1bControl; + + + ACPI_FUNCTION_TRACE (AcpiLeaveSleepState); + + + /* + * Set SLP_TYPE and SLP_EN to state S0. + * This is unclear from the ACPI Spec, but it is required + * by some machines. + */ + Status = AcpiGetSleepTypeData (ACPI_STATE_S0, + &AcpiGbl_SleepTypeA, &AcpiGbl_SleepTypeB); + if (ACPI_SUCCESS (Status)) + { + SleepTypeRegInfo = + AcpiHwGetBitRegisterInfo (ACPI_BITREG_SLEEP_TYPE); + SleepEnableRegInfo = + AcpiHwGetBitRegisterInfo (ACPI_BITREG_SLEEP_ENABLE); + + /* Get current value of PM1A control */ + + Status = AcpiHwRegisterRead (ACPI_REGISTER_PM1_CONTROL, + &Pm1aControl); + if (ACPI_SUCCESS (Status)) + { + /* Clear the SLP_EN and SLP_TYP fields */ + + Pm1aControl &= ~(SleepTypeRegInfo->AccessBitMask | + SleepEnableRegInfo->AccessBitMask); + Pm1bControl = Pm1aControl; + + /* Insert the SLP_TYP bits */ + + Pm1aControl |= (AcpiGbl_SleepTypeA << + SleepTypeRegInfo->BitPosition); + Pm1bControl |= (AcpiGbl_SleepTypeB << + SleepTypeRegInfo->BitPosition); + + /* Write the control registers and ignore any errors */ + + (void) AcpiHwWritePm1Control (Pm1aControl, Pm1bControl); + } + } + + /* Ensure EnterSleepStatePrep -> EnterSleepState ordering */ + + AcpiGbl_SleepTypeA = ACPI_SLEEP_TYPE_INVALID; + + /* Setup parameter object */ + + ArgList.Count = 1; + ArgList.Pointer = &Arg; + Arg.Type = ACPI_TYPE_INTEGER; + + /* Ignore any errors from these methods */ + + Arg.Integer.Value = ACPI_SST_WAKING; + Status = AcpiEvaluateObject (NULL, METHOD_NAME__SST, &ArgList, NULL); + if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) + { + ACPI_EXCEPTION ((AE_INFO, Status, "During Method _SST")); + } + + Arg.Integer.Value = SleepState; + Status = AcpiEvaluateObject (NULL, METHOD_NAME__BFS, &ArgList, NULL); + if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) + { + ACPI_EXCEPTION ((AE_INFO, Status, "During Method _BFS")); + } + + Status = AcpiEvaluateObject (NULL, METHOD_NAME__WAK, &ArgList, NULL); + if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) + { + ACPI_EXCEPTION ((AE_INFO, Status, "During Method _WAK")); + } + /* TBD: _WAK "sometimes" returns stuff - do we want to look at it? */ + + /* + * Restore the GPEs: + * 1) Disable/Clear all GPEs + * 2) Enable all runtime GPEs + */ + Status = AcpiHwDisableAllGpes (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + AcpiGbl_SystemAwakeAndRunning = TRUE; + + Status = AcpiHwEnableAllRuntimeGpes (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Enable power button */ + + (void) AcpiWriteBitRegister( + AcpiGbl_FixedEventInfo[ACPI_EVENT_POWER_BUTTON].EnableRegisterId, + ACPI_ENABLE_EVENT); + + (void) AcpiWriteBitRegister( + AcpiGbl_FixedEventInfo[ACPI_EVENT_POWER_BUTTON].StatusRegisterId, + ACPI_CLEAR_STATUS); + + /* + * Enable BM arbitration. This feature is contained within an + * optional register (PM2 Control), so ignore a BAD_ADDRESS + * exception. + */ + Status = AcpiWriteBitRegister (ACPI_BITREG_ARB_DISABLE, 0); + if (ACPI_FAILURE (Status) && (Status != AE_BAD_ADDRESS)) + { + return_ACPI_STATUS (Status); + } + + Arg.Integer.Value = ACPI_SST_WORKING; + Status = AcpiEvaluateObject (NULL, METHOD_NAME__SST, &ArgList, NULL); + if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) + { + ACPI_EXCEPTION ((AE_INFO, Status, "During Method _SST")); + } + + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiLeaveSleepState) + diff --git a/reactos/drivers/bus/acpi/acpica/hardware/hwtimer.c b/reactos/drivers/bus/acpi/acpica/hardware/hwtimer.c new file mode 100644 index 00000000000..f86fb7f865e --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/hardware/hwtimer.c @@ -0,0 +1,288 @@ + +/****************************************************************************** + * + * Name: hwtimer.c - ACPI Power Management Timer Interface + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 "acpi.h" +#include "accommon.h" + +#define _COMPONENT ACPI_HARDWARE + ACPI_MODULE_NAME ("hwtimer") + + +/****************************************************************************** + * + * FUNCTION: AcpiGetTimerResolution + * + * PARAMETERS: Resolution - Where the resolution is returned + * + * RETURN: Status and timer resolution + * + * DESCRIPTION: Obtains resolution of the ACPI PM Timer (24 or 32 bits). + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetTimerResolution ( + UINT32 *Resolution) +{ + ACPI_FUNCTION_TRACE (AcpiGetTimerResolution); + + + if (!Resolution) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + if ((AcpiGbl_FADT.Flags & ACPI_FADT_32BIT_TIMER) == 0) + { + *Resolution = 24; + } + else + { + *Resolution = 32; + } + + return_ACPI_STATUS (AE_OK); +} + +ACPI_EXPORT_SYMBOL (AcpiGetTimerResolution) + + +/****************************************************************************** + * + * FUNCTION: AcpiGetTimer + * + * PARAMETERS: Ticks - Where the timer value is returned + * + * RETURN: Status and current timer value (ticks) + * + * DESCRIPTION: Obtains current value of ACPI PM Timer (in ticks). + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetTimer ( + UINT32 *Ticks) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiGetTimer); + + + if (!Ticks) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Status = AcpiHwRead (Ticks, &AcpiGbl_FADT.XPmTimerBlock); + + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiGetTimer) + + +/****************************************************************************** + * + * FUNCTION: AcpiGetTimerDuration + * + * PARAMETERS: StartTicks - Starting timestamp + * EndTicks - End timestamp + * TimeElapsed - Where the elapsed time is returned + * + * RETURN: Status and TimeElapsed + * + * DESCRIPTION: Computes the time elapsed (in microseconds) between two + * PM Timer time stamps, taking into account the possibility of + * rollovers, the timer resolution, and timer frequency. + * + * The PM Timer's clock ticks at roughly 3.6 times per + * _microsecond_, and its clock continues through Cx state + * transitions (unlike many CPU timestamp counters) -- making it + * a versatile and accurate timer. + * + * Note that this function accommodates only a single timer + * rollover. Thus for 24-bit timers, this function should only + * be used for calculating durations less than ~4.6 seconds + * (~20 minutes for 32-bit timers) -- calculations below: + * + * 2**24 Ticks / 3,600,000 Ticks/Sec = 4.66 sec + * 2**32 Ticks / 3,600,000 Ticks/Sec = 1193 sec or 19.88 minutes + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetTimerDuration ( + UINT32 StartTicks, + UINT32 EndTicks, + UINT32 *TimeElapsed) +{ + ACPI_STATUS Status; + UINT32 DeltaTicks; + ACPI_INTEGER Quotient; + + + ACPI_FUNCTION_TRACE (AcpiGetTimerDuration); + + + if (!TimeElapsed) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* + * Compute Tick Delta: + * Handle (max one) timer rollovers on 24-bit versus 32-bit timers. + */ + if (StartTicks < EndTicks) + { + DeltaTicks = EndTicks - StartTicks; + } + else if (StartTicks > EndTicks) + { + if ((AcpiGbl_FADT.Flags & ACPI_FADT_32BIT_TIMER) == 0) + { + /* 24-bit Timer */ + + DeltaTicks = (((0x00FFFFFF - StartTicks) + EndTicks) & 0x00FFFFFF); + } + else + { + /* 32-bit Timer */ + + DeltaTicks = (0xFFFFFFFF - StartTicks) + EndTicks; + } + } + else /* StartTicks == EndTicks */ + { + *TimeElapsed = 0; + return_ACPI_STATUS (AE_OK); + } + + /* + * Compute Duration (Requires a 64-bit multiply and divide): + * + * TimeElapsed = (DeltaTicks * 1000000) / PM_TIMER_FREQUENCY; + */ + Status = AcpiUtShortDivide (((UINT64) DeltaTicks) * 1000000, + PM_TIMER_FREQUENCY, &Quotient, NULL); + + *TimeElapsed = (UINT32) Quotient; + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiGetTimerDuration) + diff --git a/reactos/drivers/bus/acpi/acpica/hardware/hwvalid.c b/reactos/drivers/bus/acpi/acpica/hardware/hwvalid.c new file mode 100644 index 00000000000..650b695b2cc --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/hardware/hwvalid.c @@ -0,0 +1,424 @@ + +/****************************************************************************** + * + * Module Name: hwvalid - I/O request validation + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __HWVALID_C__ + +#include "acpi.h" +#include "accommon.h" + +#define _COMPONENT ACPI_HARDWARE + ACPI_MODULE_NAME ("hwvalid") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiHwValidateIoRequest ( + ACPI_IO_ADDRESS Address, + UINT32 BitWidth); + + +/* + * Protected I/O ports. Some ports are always illegal, and some are + * conditionally illegal. This table must remain ordered by port address. + * + * The table is used to implement the Microsoft port access rules that + * first appeared in Windows XP. Some ports are always illegal, and some + * ports are only illegal if the BIOS calls _OSI with a WinXP string or + * later (meaning that the BIOS itelf is post-XP.) + * + * This provides ACPICA with the desired port protections and + * Microsoft compatibility. + * + * Description of port entries: + * DMA: DMA controller + * PIC0: Programmable Interrupt Controller (8259A) + * PIT1: System Timer 1 + * PIT2: System Timer 2 failsafe + * RTC: Real-time clock + * CMOS: Extended CMOS + * DMA1: DMA 1 page registers + * DMA1L: DMA 1 Ch 0 low page + * DMA2: DMA 2 page registers + * DMA2L: DMA 2 low page refresh + * ARBC: Arbitration control + * SETUP: Reserved system board setup + * POS: POS channel select + * PIC1: Cascaded PIC + * IDMA: ISA DMA + * ELCR: PIC edge/level registers + * PCI: PCI configuration space + */ +static const ACPI_PORT_INFO AcpiProtectedPorts[] = +{ + {"DMA", 0x0000, 0x000F, ACPI_OSI_WIN_XP}, + {"PIC0", 0x0020, 0x0021, ACPI_ALWAYS_ILLEGAL}, + {"PIT1", 0x0040, 0x0043, ACPI_OSI_WIN_XP}, + {"PIT2", 0x0048, 0x004B, ACPI_OSI_WIN_XP}, + {"RTC", 0x0070, 0x0071, ACPI_OSI_WIN_XP}, + {"CMOS", 0x0074, 0x0076, ACPI_OSI_WIN_XP}, + {"DMA1", 0x0081, 0x0083, ACPI_OSI_WIN_XP}, + {"DMA1L", 0x0087, 0x0087, ACPI_OSI_WIN_XP}, + {"DMA2", 0x0089, 0x008B, ACPI_OSI_WIN_XP}, + {"DMA2L", 0x008F, 0x008F, ACPI_OSI_WIN_XP}, + {"ARBC", 0x0090, 0x0091, ACPI_OSI_WIN_XP}, + {"SETUP", 0x0093, 0x0094, ACPI_OSI_WIN_XP}, + {"POS", 0x0096, 0x0097, ACPI_OSI_WIN_XP}, + {"PIC1", 0x00A0, 0x00A1, ACPI_ALWAYS_ILLEGAL}, + {"IDMA", 0x00C0, 0x00DF, ACPI_OSI_WIN_XP}, + {"ELCR", 0x04D0, 0x04D1, ACPI_ALWAYS_ILLEGAL}, + {"PCI", 0x0CF8, 0x0CFF, ACPI_OSI_WIN_XP} +}; + +#define ACPI_PORT_INFO_ENTRIES ACPI_ARRAY_LENGTH (AcpiProtectedPorts) + + +/****************************************************************************** + * + * FUNCTION: AcpiHwValidateIoRequest + * + * PARAMETERS: Address Address of I/O port/register + * BitWidth Number of bits (8,16,32) + * + * RETURN: Status + * + * DESCRIPTION: Validates an I/O request (address/length). Certain ports are + * always illegal and some ports are only illegal depending on + * the requests the BIOS AML code makes to the predefined + * _OSI method. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiHwValidateIoRequest ( + ACPI_IO_ADDRESS Address, + UINT32 BitWidth) +{ + UINT32 i; + UINT32 ByteWidth; + ACPI_IO_ADDRESS LastAddress; + const ACPI_PORT_INFO *PortInfo; + + + ACPI_FUNCTION_TRACE (HwValidateIoRequest); + + + /* Supported widths are 8/16/32 */ + + if ((BitWidth != 8) && + (BitWidth != 16) && + (BitWidth != 32)) + { + return (AE_BAD_PARAMETER); + } + + PortInfo = AcpiProtectedPorts; + ByteWidth = ACPI_DIV_8 (BitWidth); + LastAddress = Address + ByteWidth - 1; + + ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Address %p LastAddress %p Length %X", + ACPI_CAST_PTR (void, Address), ACPI_CAST_PTR (void, LastAddress), + ByteWidth)); + + /* Maximum 16-bit address in I/O space */ + + if (LastAddress > ACPI_UINT16_MAX) + { + ACPI_ERROR ((AE_INFO, + "Illegal I/O port address/length above 64K: 0x%p/%X", + ACPI_CAST_PTR (void, Address), ByteWidth)); + return_ACPI_STATUS (AE_LIMIT); + } + + /* Exit if requested address is not within the protected port table */ + + if (Address > AcpiProtectedPorts[ACPI_PORT_INFO_ENTRIES - 1].End) + { + return_ACPI_STATUS (AE_OK); + } + + /* Check request against the list of protected I/O ports */ + + for (i = 0; i < ACPI_PORT_INFO_ENTRIES; i++, PortInfo++) + { + /* + * Check if the requested address range will write to a reserved + * port. Four cases to consider: + * + * 1) Address range is contained completely in the port address range + * 2) Address range overlaps port range at the port range start + * 3) Address range overlaps port range at the port range end + * 4) Address range completely encompasses the port range + */ + if ((Address <= PortInfo->End) && (LastAddress >= PortInfo->Start)) + { + /* Port illegality may depend on the _OSI calls made by the BIOS */ + + if (AcpiGbl_OsiData >= PortInfo->OsiDependency) + { + ACPI_DEBUG_PRINT ((ACPI_DB_IO, + "Denied AML access to port 0x%p/%X (%s 0x%.4X-0x%.4X)", + ACPI_CAST_PTR (void, Address), ByteWidth, PortInfo->Name, + PortInfo->Start, PortInfo->End)); + + return_ACPI_STATUS (AE_AML_ILLEGAL_ADDRESS); + } + } + + /* Finished if address range ends before the end of this port */ + + if (LastAddress <= PortInfo->End) + { + break; + } + } + + return_ACPI_STATUS (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwReadPort + * + * PARAMETERS: Address Address of I/O port/register to read + * Value Where value is placed + * Width Number of bits + * + * RETURN: Status and value read from port + * + * DESCRIPTION: Read data from an I/O port or register. This is a front-end + * to AcpiOsReadPort that performs validation on both the port + * address and the length. + * + *****************************************************************************/ + +ACPI_STATUS +AcpiHwReadPort ( + ACPI_IO_ADDRESS Address, + UINT32 *Value, + UINT32 Width) +{ + ACPI_STATUS Status; + UINT32 OneByte; + UINT32 i; + + + /* Validate the entire request and perform the I/O */ + + Status = AcpiHwValidateIoRequest (Address, Width); + if (ACPI_SUCCESS (Status)) + { + Status = AcpiOsReadPort (Address, Value, Width); + return (Status); + } + + if (Status != AE_AML_ILLEGAL_ADDRESS) + { + return (Status); + } + + /* + * There has been a protection violation within the request. Fall + * back to byte granularity port I/O and ignore the failing bytes. + * This provides Windows compatibility. + */ + for (i = 0, *Value = 0; i < Width; i += 8) + { + /* Validate and read one byte */ + + if (AcpiHwValidateIoRequest (Address, 8) == AE_OK) + { + Status = AcpiOsReadPort (Address, &OneByte, 8); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + *Value |= (OneByte << i); + } + + Address++; + } + + return (AE_OK); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiHwWritePort + * + * PARAMETERS: Address Address of I/O port/register to write + * Value Value to write + * Width Number of bits + * + * RETURN: Status + * + * DESCRIPTION: Write data to an I/O port or register. This is a front-end + * to AcpiOsWritePort that performs validation on both the port + * address and the length. + * + *****************************************************************************/ + +ACPI_STATUS +AcpiHwWritePort ( + ACPI_IO_ADDRESS Address, + UINT32 Value, + UINT32 Width) +{ + ACPI_STATUS Status; + UINT32 i; + + + /* Validate the entire request and perform the I/O */ + + Status = AcpiHwValidateIoRequest (Address, Width); + if (ACPI_SUCCESS (Status)) + { + Status = AcpiOsWritePort (Address, Value, Width); + return (Status); + } + + if (Status != AE_AML_ILLEGAL_ADDRESS) + { + return (Status); + } + + /* + * There has been a protection violation within the request. Fall + * back to byte granularity port I/O and ignore the failing bytes. + * This provides Windows compatibility. + */ + for (i = 0; i < Width; i += 8) + { + /* Validate and write one byte */ + + if (AcpiHwValidateIoRequest (Address, 8) == AE_OK) + { + Status = AcpiOsWritePort (Address, (Value >> i) & 0xFF, 8); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + + Address++; + } + + return (AE_OK); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/hardware/hwxface.c b/reactos/drivers/bus/acpi/acpica/hardware/hwxface.c new file mode 100644 index 00000000000..6c345a593e1 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/hardware/hwxface.c @@ -0,0 +1,710 @@ + +/****************************************************************************** + * + * Module Name: hwxface - Public ACPICA hardware interfaces + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 "acpi.h" +#include "accommon.h" +#include "acnamesp.h" + +#define _COMPONENT ACPI_HARDWARE + ACPI_MODULE_NAME ("hwxface") + + +/****************************************************************************** + * + * FUNCTION: AcpiReset + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Set reset register in memory or IO space. Note: Does not + * support reset register in PCI config space, this must be + * handled separately. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiReset ( + void) +{ + ACPI_GENERIC_ADDRESS *ResetReg; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiReset); + + + ResetReg = &AcpiGbl_FADT.ResetRegister; + + /* Check if the reset register is supported */ + + if (!(AcpiGbl_FADT.Flags & ACPI_FADT_RESET_REGISTER) || + !ResetReg->Address) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + if (ResetReg->SpaceId == ACPI_ADR_SPACE_SYSTEM_IO) + { + /* + * For I/O space, write directly to the OSL. This bypasses the port + * validation mechanism, which may block a valid write to the reset + * register. + */ + Status = AcpiOsWritePort ((ACPI_IO_ADDRESS) ResetReg->Address, + AcpiGbl_FADT.ResetValue, ResetReg->BitWidth); + } + else + { + /* Write the reset value to the reset register */ + + Status = AcpiHwWrite (AcpiGbl_FADT.ResetValue, ResetReg); + } + + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiReset) + + +/****************************************************************************** + * + * FUNCTION: AcpiRead + * + * PARAMETERS: Value - Where the value is returned + * Reg - GAS register structure + * + * RETURN: Status + * + * DESCRIPTION: Read from either memory or IO space. + * + * LIMITATIONS: + * BitWidth must be exactly 8, 16, 32, or 64. + * SpaceID must be SystemMemory or SystemIO. + * BitOffset and AccessWidth are currently ignored, as there has + * not been a need to implement these. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRead ( + UINT64 *ReturnValue, + ACPI_GENERIC_ADDRESS *Reg) +{ + UINT32 Value; + UINT32 Width; + UINT64 Address; + ACPI_STATUS Status; + + + ACPI_FUNCTION_NAME (AcpiRead); + + + if (!ReturnValue) + { + return (AE_BAD_PARAMETER); + } + + /* Validate contents of the GAS register. Allow 64-bit transfers */ + + Status = AcpiHwValidateRegister (Reg, 64, &Address); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Width = Reg->BitWidth; + if (Width == 64) + { + Width = 32; /* Break into two 32-bit transfers */ + } + + /* Initialize entire 64-bit return value to zero */ + + *ReturnValue = 0; + Value = 0; + + /* + * Two address spaces supported: Memory or IO. PCI_Config is + * not supported here because the GAS structure is insufficient + */ + if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY) + { + Status = AcpiOsReadMemory ((ACPI_PHYSICAL_ADDRESS) + Address, &Value, Width); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + *ReturnValue = Value; + + if (Reg->BitWidth == 64) + { + /* Read the top 32 bits */ + + Status = AcpiOsReadMemory ((ACPI_PHYSICAL_ADDRESS) + (Address + 4), &Value, 32); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + *ReturnValue |= ((UINT64) Value << 32); + } + } + else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ + { + Status = AcpiHwReadPort ((ACPI_IO_ADDRESS) + Address, &Value, Width); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + *ReturnValue = Value; + + if (Reg->BitWidth == 64) + { + /* Read the top 32 bits */ + + Status = AcpiHwReadPort ((ACPI_IO_ADDRESS) + (Address + 4), &Value, 32); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + *ReturnValue |= ((UINT64) Value << 32); + } + } + + ACPI_DEBUG_PRINT ((ACPI_DB_IO, + "Read: %8.8X%8.8X width %2d from %8.8X%8.8X (%s)\n", + ACPI_FORMAT_UINT64 (*ReturnValue), Reg->BitWidth, + ACPI_FORMAT_UINT64 (Address), + AcpiUtGetRegionName (Reg->SpaceId))); + + return (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiRead) + + +/****************************************************************************** + * + * FUNCTION: AcpiWrite + * + * PARAMETERS: Value - Value to be written + * Reg - GAS register structure + * + * RETURN: Status + * + * DESCRIPTION: Write to either memory or IO space. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiWrite ( + UINT64 Value, + ACPI_GENERIC_ADDRESS *Reg) +{ + UINT32 Width; + UINT64 Address; + ACPI_STATUS Status; + + + ACPI_FUNCTION_NAME (AcpiWrite); + + + /* Validate contents of the GAS register. Allow 64-bit transfers */ + + Status = AcpiHwValidateRegister (Reg, 64, &Address); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Width = Reg->BitWidth; + if (Width == 64) + { + Width = 32; /* Break into two 32-bit transfers */ + } + + /* + * Two address spaces supported: Memory or IO. PCI_Config is + * not supported here because the GAS structure is insufficient + */ + if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY) + { + Status = AcpiOsWriteMemory ((ACPI_PHYSICAL_ADDRESS) + Address, ACPI_LODWORD (Value), Width); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + if (Reg->BitWidth == 64) + { + Status = AcpiOsWriteMemory ((ACPI_PHYSICAL_ADDRESS) + (Address + 4), ACPI_HIDWORD (Value), 32); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + } + else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */ + { + Status = AcpiHwWritePort ((ACPI_IO_ADDRESS) + Address, ACPI_LODWORD (Value), Width); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + if (Reg->BitWidth == 64) + { + Status = AcpiHwWritePort ((ACPI_IO_ADDRESS) + (Address + 4), ACPI_HIDWORD (Value), 32); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + } + + ACPI_DEBUG_PRINT ((ACPI_DB_IO, + "Wrote: %8.8X%8.8X width %2d to %8.8X%8.8X (%s)\n", + ACPI_FORMAT_UINT64 (Value), Reg->BitWidth, + ACPI_FORMAT_UINT64 (Address), + AcpiUtGetRegionName (Reg->SpaceId))); + + return (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiWrite) + + +/******************************************************************************* + * + * FUNCTION: AcpiReadBitRegister + * + * PARAMETERS: RegisterId - ID of ACPI Bit Register to access + * ReturnValue - Value that was read from the register, + * normalized to bit position zero. + * + * RETURN: Status and the value read from the specified Register. Value + * returned is normalized to bit0 (is shifted all the way right) + * + * DESCRIPTION: ACPI BitRegister read function. Does not acquire the HW lock. + * + * SUPPORTS: Bit fields in PM1 Status, PM1 Enable, PM1 Control, and + * PM2 Control. + * + * Note: The hardware lock is not required when reading the ACPI bit registers + * since almost all of them are single bit and it does not matter that + * the parent hardware register can be split across two physical + * registers. The only multi-bit field is SLP_TYP in the PM1 control + * register, but this field does not cross an 8-bit boundary (nor does + * it make much sense to actually read this field.) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiReadBitRegister ( + UINT32 RegisterId, + UINT32 *ReturnValue) +{ + ACPI_BIT_REGISTER_INFO *BitRegInfo; + UINT32 RegisterValue; + UINT32 Value; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE_U32 (AcpiReadBitRegister, RegisterId); + + + /* Get the info structure corresponding to the requested ACPI Register */ + + BitRegInfo = AcpiHwGetBitRegisterInfo (RegisterId); + if (!BitRegInfo) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Read the entire parent register */ + + Status = AcpiHwRegisterRead (BitRegInfo->ParentRegister, + &RegisterValue); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Normalize the value that was read, mask off other bits */ + + Value = ((RegisterValue & BitRegInfo->AccessBitMask) + >> BitRegInfo->BitPosition); + + ACPI_DEBUG_PRINT ((ACPI_DB_IO, + "BitReg %X, ParentReg %X, Actual %8.8X, ReturnValue %8.8X\n", + RegisterId, BitRegInfo->ParentRegister, RegisterValue, Value)); + + *ReturnValue = Value; + return_ACPI_STATUS (AE_OK); +} + +ACPI_EXPORT_SYMBOL (AcpiReadBitRegister) + + +/******************************************************************************* + * + * FUNCTION: AcpiWriteBitRegister + * + * PARAMETERS: RegisterId - ID of ACPI Bit Register to access + * Value - Value to write to the register, in bit + * position zero. The bit is automaticallly + * shifted to the correct position. + * + * RETURN: Status + * + * DESCRIPTION: ACPI Bit Register write function. Acquires the hardware lock + * since most operations require a read/modify/write sequence. + * + * SUPPORTS: Bit fields in PM1 Status, PM1 Enable, PM1 Control, and + * PM2 Control. + * + * Note that at this level, the fact that there may be actually two + * hardware registers (A and B - and B may not exist) is abstracted. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiWriteBitRegister ( + UINT32 RegisterId, + UINT32 Value) +{ + ACPI_BIT_REGISTER_INFO *BitRegInfo; + ACPI_CPU_FLAGS LockFlags; + UINT32 RegisterValue; + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE_U32 (AcpiWriteBitRegister, RegisterId); + + + /* Get the info structure corresponding to the requested ACPI Register */ + + BitRegInfo = AcpiHwGetBitRegisterInfo (RegisterId); + if (!BitRegInfo) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + LockFlags = AcpiOsAcquireLock (AcpiGbl_HardwareLock); + + /* + * At this point, we know that the parent register is one of the + * following: PM1 Status, PM1 Enable, PM1 Control, or PM2 Control + */ + if (BitRegInfo->ParentRegister != ACPI_REGISTER_PM1_STATUS) + { + /* + * 1) Case for PM1 Enable, PM1 Control, and PM2 Control + * + * Perform a register read to preserve the bits that we are not + * interested in + */ + Status = AcpiHwRegisterRead (BitRegInfo->ParentRegister, + &RegisterValue); + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + + /* + * Insert the input bit into the value that was just read + * and write the register + */ + ACPI_REGISTER_INSERT_VALUE (RegisterValue, BitRegInfo->BitPosition, + BitRegInfo->AccessBitMask, Value); + + Status = AcpiHwRegisterWrite (BitRegInfo->ParentRegister, + RegisterValue); + } + else + { + /* + * 2) Case for PM1 Status + * + * The Status register is different from the rest. Clear an event + * by writing 1, writing 0 has no effect. So, the only relevant + * information is the single bit we're interested in, all others + * should be written as 0 so they will be left unchanged. + */ + RegisterValue = ACPI_REGISTER_PREPARE_BITS (Value, + BitRegInfo->BitPosition, BitRegInfo->AccessBitMask); + + /* No need to write the register if value is all zeros */ + + if (RegisterValue) + { + Status = AcpiHwRegisterWrite (ACPI_REGISTER_PM1_STATUS, + RegisterValue); + } + } + + ACPI_DEBUG_PRINT ((ACPI_DB_IO, + "BitReg %X, ParentReg %X, Value %8.8X, Actual %8.8X\n", + RegisterId, BitRegInfo->ParentRegister, Value, RegisterValue)); + + +UnlockAndExit: + + AcpiOsReleaseLock (AcpiGbl_HardwareLock, LockFlags); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiWriteBitRegister) + + +/******************************************************************************* + * + * FUNCTION: AcpiGetSleepTypeData + * + * PARAMETERS: SleepState - Numeric sleep state + * *SleepTypeA - Where SLP_TYPa is returned + * *SleepTypeB - Where SLP_TYPb is returned + * + * RETURN: Status - ACPI status + * + * DESCRIPTION: Obtain the SLP_TYPa and SLP_TYPb values for the requested sleep + * state. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetSleepTypeData ( + UINT8 SleepState, + UINT8 *SleepTypeA, + UINT8 *SleepTypeB) +{ + ACPI_STATUS Status = AE_OK; + ACPI_EVALUATE_INFO *Info; + + + ACPI_FUNCTION_TRACE (AcpiGetSleepTypeData); + + + /* Validate parameters */ + + if ((SleepState > ACPI_S_STATES_MAX) || + !SleepTypeA || + !SleepTypeB) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Allocate the evaluation information block */ + + Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO)); + if (!Info) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Info->Pathname = ACPI_CAST_PTR (char, AcpiGbl_SleepStateNames[SleepState]); + + /* Evaluate the namespace object containing the values for this state */ + + Status = AcpiNsEvaluate (Info); + if (ACPI_FAILURE (Status)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "%s while evaluating SleepState [%s]\n", + AcpiFormatException (Status), Info->Pathname)); + + goto Cleanup; + } + + /* Must have a return object */ + + if (!Info->ReturnObject) + { + ACPI_ERROR ((AE_INFO, "No Sleep State object returned from [%s]", + Info->Pathname)); + Status = AE_NOT_EXIST; + } + + /* It must be of type Package */ + + else if (Info->ReturnObject->Common.Type != ACPI_TYPE_PACKAGE) + { + ACPI_ERROR ((AE_INFO, "Sleep State return object is not a Package")); + Status = AE_AML_OPERAND_TYPE; + } + + /* + * The package must have at least two elements. NOTE (March 2005): This + * goes against the current ACPI spec which defines this object as a + * package with one encoded DWORD element. However, existing practice + * by BIOS vendors seems to be to have 2 or more elements, at least + * one per sleep type (A/B). + */ + else if (Info->ReturnObject->Package.Count < 2) + { + ACPI_ERROR ((AE_INFO, + "Sleep State return package does not have at least two elements")); + Status = AE_AML_NO_OPERAND; + } + + /* The first two elements must both be of type Integer */ + + else if (((Info->ReturnObject->Package.Elements[0])->Common.Type + != ACPI_TYPE_INTEGER) || + ((Info->ReturnObject->Package.Elements[1])->Common.Type + != ACPI_TYPE_INTEGER)) + { + ACPI_ERROR ((AE_INFO, + "Sleep State return package elements are not both Integers " + "(%s, %s)", + AcpiUtGetObjectTypeName (Info->ReturnObject->Package.Elements[0]), + AcpiUtGetObjectTypeName (Info->ReturnObject->Package.Elements[1]))); + Status = AE_AML_OPERAND_TYPE; + } + else + { + /* Valid _Sx_ package size, type, and value */ + + *SleepTypeA = (UINT8) + (Info->ReturnObject->Package.Elements[0])->Integer.Value; + *SleepTypeB = (UINT8) + (Info->ReturnObject->Package.Elements[1])->Integer.Value; + } + + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "While evaluating SleepState [%s], bad Sleep object %p type %s", + Info->Pathname, Info->ReturnObject, + AcpiUtGetObjectTypeName (Info->ReturnObject))); + } + + AcpiUtRemoveReference (Info->ReturnObject); + +Cleanup: + ACPI_FREE (Info); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiGetSleepTypeData) diff --git a/reactos/drivers/bus/acpi/acpica/include/acapps.h b/reactos/drivers/bus/acpi/acpica/include/acapps.h new file mode 100644 index 00000000000..c5ebef1d4af --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/acapps.h @@ -0,0 +1,252 @@ +/****************************************************************************** + * + * Module Name: acapps - common include for ACPI applications/tools + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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. + * + *****************************************************************************/ + +#ifndef _ACAPPS +#define _ACAPPS + + +#ifdef _MSC_VER /* disable some level-4 warnings */ +#pragma warning(disable:4100) /* warning C4100: unreferenced formal parameter */ +#endif + +#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 char *AcpiGbl_Optarg; + + +/* + * adisasm + */ +ACPI_STATUS +AdAmlDisassemble ( + BOOLEAN OutToFile, + char *Filename, + char *Prefix, + char **OutFilename, + BOOLEAN GetAllTables); + +void +AdPrintStatistics ( + void); + +ACPI_STATUS +AdFindDsdt( + UINT8 **DsdtPtr, + UINT32 *DsdtLength); + +void +AdDumpTables ( + void); + +ACPI_STATUS +AdGetLocalTables ( + char *Filename, + BOOLEAN GetAllTables); + +ACPI_STATUS +AdParseTable ( + ACPI_TABLE_HEADER *Table, + ACPI_OWNER_ID *OwnerId, + BOOLEAN LoadTable, + BOOLEAN External); + +ACPI_STATUS +AdDisplayTables ( + char *Filename, + ACPI_TABLE_HEADER *Table); + +ACPI_STATUS +AdDisplayStatistics ( + void); + + +/* + * adwalk + */ +void +AcpiDmCrossReferenceNamespace ( + ACPI_PARSE_OBJECT *ParseTreeRoot, + ACPI_NAMESPACE_NODE *NamespaceRoot, + ACPI_OWNER_ID OwnerId); + +void +AcpiDmDumpTree ( + ACPI_PARSE_OBJECT *Origin); + +void +AcpiDmFindOrphanMethods ( + ACPI_PARSE_OBJECT *Origin); + +void +AcpiDmFinishNamespaceLoad ( + ACPI_PARSE_OBJECT *ParseTreeRoot, + ACPI_NAMESPACE_NODE *NamespaceRoot, + ACPI_OWNER_ID OwnerId); + +void +AcpiDmConvertResourceIndexes ( + ACPI_PARSE_OBJECT *ParseTreeRoot, + ACPI_NAMESPACE_NODE *NamespaceRoot); + + +/* + * adfile + */ +ACPI_STATUS +AdInitialize ( + void); + +char * +FlGenerateFilename ( + char *InputFilename, + char *Suffix); + +ACPI_STATUS +FlSplitInputPathname ( + char *InputPath, + char **OutDirectoryPath, + char **OutFilename); + +char * +FlGenerateFilename ( + char *InputFilename, + char *Suffix); + +char * +AdGenerateFilename ( + char *Prefix, + char *TableId); + +void +AdWriteTable ( + ACPI_TABLE_HEADER *Table, + UINT32 Length, + char *TableName, + char *OemTableId); + +#endif /* _ACAPPS */ + diff --git a/reactos/drivers/bus/acpi/acpica/include/accommon.h b/reactos/drivers/bus/acpi/acpica/include/accommon.h new file mode 100644 index 00000000000..690d3cdba95 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/accommon.h @@ -0,0 +1,136 @@ +/****************************************************************************** + * + * Name: accommon.h - Common include files for generation of ACPICA source + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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. + * + *****************************************************************************/ + +#ifndef __ACCOMMON_H__ +#define __ACCOMMON_H__ + +/* + * Common set of includes for all ACPICA source files. + * We put them here because we don't want to duplicate them + * in the the source code again and again. + * + * Note: The order of these include files is important. + */ +#include "acconfig.h" /* Global configuration constants */ +#include "acmacros.h" /* C macros */ +#include "aclocal.h" /* Internal data types */ +#include "acobject.h" /* ACPI internal object */ +#include "acstruct.h" /* Common structures */ +#include "acglobal.h" /* All global variables */ +#include "achware.h" /* Hardware defines and interfaces */ +#include "acutils.h" /* Utility interfaces */ + + +#endif /* __ACCOMMON_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/acconfig.h b/reactos/drivers/bus/acpi/acpica/include/acconfig.h new file mode 100644 index 00000000000..8fbe0e371b2 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/acconfig.h @@ -0,0 +1,279 @@ +/****************************************************************************** + * + * Name: acconfig.h - Global configuration constants + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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. + * + *****************************************************************************/ + +#ifndef _ACCONFIG_H +#define _ACCONFIG_H + + +/****************************************************************************** + * + * Configuration options + * + *****************************************************************************/ + +/* + * ACPI_DEBUG_OUTPUT - This switch enables all the debug facilities of the + * ACPI subsystem. This includes the DEBUG_PRINT output + * statements. When disabled, all DEBUG_PRINT + * statements are compiled out. + * + * ACPI_APPLICATION - Use this switch if the subsystem is going to be run + * at the application level. + * + */ + +/* + * OS name, used for the _OS object. The _OS object is essentially obsolete, + * but there is a large base of ASL/AML code in existing machines that check + * for the string below. The use of this string usually guarantees that + * the ASL will execute down the most tested code path. Also, there is some + * code that will not execute the _OSI method unless _OS matches the string + * below. Therefore, change this string at your own risk. + */ +#define ACPI_OS_NAME "Microsoft Windows NT" + +/* Maximum objects in the various object caches */ + +#define ACPI_MAX_STATE_CACHE_DEPTH 96 /* State objects */ +#define ACPI_MAX_PARSE_CACHE_DEPTH 96 /* Parse tree objects */ +#define ACPI_MAX_EXTPARSE_CACHE_DEPTH 96 /* Parse tree objects */ +#define ACPI_MAX_OBJECT_CACHE_DEPTH 96 /* Interpreter operand objects */ +#define ACPI_MAX_NAMESPACE_CACHE_DEPTH 96 /* Namespace objects */ + +/* + * Should the subsystem abort the loading of an ACPI table if the + * table checksum is incorrect? + */ +#define ACPI_CHECKSUM_ABORT FALSE + + +/****************************************************************************** + * + * Subsystem Constants + * + *****************************************************************************/ + +/* Version of ACPI supported */ + +#define ACPI_CA_SUPPORT_LEVEL 3 + +/* Maximum count for a semaphore object */ + +#define ACPI_MAX_SEMAPHORE_COUNT 256 + +/* Maximum object reference count (detects object deletion issues) */ + +#define ACPI_MAX_REFERENCE_COUNT 0x800 + +/* Default page size for use in mapping memory for operation regions */ + +#define ACPI_DEFAULT_PAGE_SIZE 4096 /* Must be power of 2 */ + +/* OwnerId tracking. 8 entries allows for 255 OwnerIds */ + +#define ACPI_NUM_OWNERID_MASKS 8 + +/* Size of the root table array is increased by this increment */ + +#define ACPI_ROOT_TABLE_SIZE_INCREMENT 4 + +/* Maximum number of While() loop iterations before forced abort */ + +#define ACPI_MAX_LOOP_ITERATIONS 0xFFFF + + +/****************************************************************************** + * + * ACPI Specification constants (Do not change unless the specification changes) + * + *****************************************************************************/ + +/* Method info (in WALK_STATE), containing local variables and argumetns */ + +#define ACPI_METHOD_NUM_LOCALS 8 +#define ACPI_METHOD_MAX_LOCAL 7 + +#define ACPI_METHOD_NUM_ARGS 7 +#define ACPI_METHOD_MAX_ARG 6 + +/* + * Operand Stack (in WALK_STATE), Must be large enough to contain METHOD_MAX_ARG + */ +#define ACPI_OBJ_NUM_OPERANDS 8 +#define ACPI_OBJ_MAX_OPERAND 7 + +/* Number of elements in the Result Stack frame, can be an arbitrary value */ + +#define ACPI_RESULTS_FRAME_OBJ_NUM 8 + +/* + * Maximal number of elements the Result Stack can contain, + * it may be an arbitray value not exceeding the types of + * ResultSize and ResultCount (now UINT8). + */ +#define ACPI_RESULTS_OBJ_NUM_MAX 255 + +/* Constants used in searching for the RSDP in low memory */ + +#define ACPI_EBDA_PTR_LOCATION 0x0000040E /* Physical Address */ +#define ACPI_EBDA_PTR_LENGTH 2 +#define ACPI_EBDA_WINDOW_SIZE 1024 +#define ACPI_HI_RSDP_WINDOW_BASE 0x000E0000 /* Physical Address */ +#define ACPI_HI_RSDP_WINDOW_SIZE 0x00020000 +#define ACPI_RSDP_SCAN_STEP 16 + +/* Operation regions */ + +#define ACPI_NUM_PREDEFINED_REGIONS 9 +#define ACPI_USER_REGION_BEGIN 0x80 + +/* Maximum SpaceIds for Operation Regions */ + +#define ACPI_MAX_ADDRESS_SPACE 255 + +/* Array sizes. Used for range checking also */ + +#define ACPI_MAX_MATCH_OPCODE 5 + +/* RSDP checksums */ + +#define ACPI_RSDP_CHECKSUM_LENGTH 20 +#define ACPI_RSDP_XCHECKSUM_LENGTH 36 + +/* 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 + + +/****************************************************************************** + * + * ACPI AML Debugger + * + *****************************************************************************/ + +#define ACPI_DEBUGGER_MAX_ARGS 8 /* Must be max method args + 1 */ + +#define ACPI_DEBUGGER_COMMAND_PROMPT '-' +#define ACPI_DEBUGGER_EXECUTE_PROMPT '%' + + +#endif /* _ACCONFIG_H */ + diff --git a/reactos/drivers/bus/acpi/acpica/include/acdebug.h b/reactos/drivers/bus/acpi/acpica/include/acdebug.h new file mode 100644 index 00000000000..82f2b6d49c1 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/acdebug.h @@ -0,0 +1,449 @@ +/****************************************************************************** + * + * Name: acdebug.h - ACPI/AML debugger + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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. + * + *****************************************************************************/ + +#ifndef __ACDEBUG_H__ +#define __ACDEBUG_H__ + + +#define ACPI_DEBUG_BUFFER_SIZE 4196 + +typedef struct CommandInfo +{ + char *Name; /* Command Name */ + UINT8 MinArgs; /* Minimum arguments required */ + +} COMMAND_INFO; + +typedef struct ArgumentInfo +{ + char *Name; /* Argument Name */ + +} ARGUMENT_INFO; + +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) +#define VERBOSE_PRINT(fp) DBTEST_OUTPUT_LEVEL(lvl) {\ + AcpiOsPrintf PARAM_LIST(fp);} + +#define EX_NO_SINGLE_STEP 1 +#define EX_SINGLE_STEP 2 + + +/* + * dbxface - external debugger interfaces + */ +ACPI_STATUS +AcpiDbInitialize ( + void); + +void +AcpiDbTerminate ( + void); + +ACPI_STATUS +AcpiDbSingleStep ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + UINT32 OpType); + + +/* + * dbcmds - debug commands and output routines + */ +ACPI_STATUS +AcpiDbDisassembleMethod ( + char *Name); + +void +AcpiDbDisplayTableInfo ( + char *TableArg); + +void +AcpiDbUnloadAcpiTable ( + char *TableArg, + char *InstanceArg); + +void +AcpiDbSetMethodBreakpoint ( + char *Location, + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + +void +AcpiDbSetMethodCallBreakpoint ( + ACPI_PARSE_OBJECT *Op); + +void +AcpiDbGetBusInfo ( + void); + +void +AcpiDbDisassembleAml ( + char *Statements, + ACPI_PARSE_OBJECT *Op); + +void +AcpiDbDumpNamespace ( + char *StartArg, + char *DepthArg); + +void +AcpiDbDumpNamespaceByOwner ( + char *OwnerArg, + char *DepthArg); + +void +AcpiDbSendNotify ( + char *Name, + UINT32 Value); + +void +AcpiDbSetMethodData ( + char *TypeArg, + char *IndexArg, + char *ValueArg); + +ACPI_STATUS +AcpiDbDisplayObjects ( + char *ObjTypeArg, + char *DisplayCountArg); + +ACPI_STATUS +AcpiDbFindNameInNamespace ( + char *NameArg); + +void +AcpiDbSetScope ( + char *Name); + +ACPI_STATUS +AcpiDbSleep ( + char *ObjectArg); + +void +AcpiDbFindReferences ( + char *ObjectArg); + +void +AcpiDbDisplayLocks ( + void); + +void +AcpiDbDisplayResources ( + char *ObjectArg); + +void +AcpiDbDisplayGpes ( + void); + +void +AcpiDbCheckIntegrity ( + void); + +void +AcpiDbGenerateGpe ( + char *GpeArg, + char *BlockArg); + +void +AcpiDbCheckPredefinedNames ( + void); + +void +AcpiDbBatchExecute ( + char *CountArg); + +/* + * dbdisply - debug display commands + */ +void +AcpiDbDisplayMethodInfo ( + ACPI_PARSE_OBJECT *Op); + +void +AcpiDbDecodeAndDisplayObject ( + char *Target, + char *OutputType); + +void +AcpiDbDisplayResultObject ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDbDisplayAllMethods ( + char *DisplayCountArg); + +void +AcpiDbDisplayArguments ( + void); + +void +AcpiDbDisplayLocals ( + void); + +void +AcpiDbDisplayResults ( + void); + +void +AcpiDbDisplayCallingTree ( + void); + +void +AcpiDbDisplayObjectType ( + char *ObjectArg); + +void +AcpiDbDisplayArgumentObject ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_WALK_STATE *WalkState); + + +/* + * dbexec - debugger control method execution + */ +void +AcpiDbExecute ( + char *Name, + char **Args, + UINT32 Flags); + +void +AcpiDbCreateExecutionThreads ( + char *NumThreadsArg, + char *NumLoopsArg, + char *MethodNameArg); + +#ifdef ACPI_DBG_TRACK_ALLOCATIONS +UINT32 +AcpiDbGetCacheInfo ( + ACPI_MEMORY_LIST *Cache); +#endif + + +/* + * dbfileio - Debugger file I/O commands + */ +ACPI_OBJECT_TYPE +AcpiDbMatchArgument ( + char *UserArgument, + ARGUMENT_INFO *Arguments); + +void +AcpiDbCloseDebugFile ( + void); + +void +AcpiDbOpenDebugFile ( + char *Name); + +ACPI_STATUS +AcpiDbLoadAcpiTable ( + char *Filename); + +ACPI_STATUS +AcpiDbGetTableFromFile ( + char *Filename, + ACPI_TABLE_HEADER **Table); + +ACPI_STATUS +AcpiDbReadTableFromFile ( + char *Filename, + ACPI_TABLE_HEADER **Table); + + +/* + * dbhistry - debugger HISTORY command + */ +void +AcpiDbAddToHistory ( + char *CommandLine); + +void +AcpiDbDisplayHistory ( + void); + +char * +AcpiDbGetFromHistory ( + char *CommandNumArg); + + +/* + * dbinput - user front-end to the AML debugger + */ +ACPI_STATUS +AcpiDbCommandDispatch ( + char *InputBuffer, + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + +void ACPI_SYSTEM_XFACE +AcpiDbExecuteThread ( + void *Context); + +ACPI_STATUS +AcpiDbUserCommands ( + char Prompt, + ACPI_PARSE_OBJECT *Op); + + +/* + * dbstats - Generation and display of ACPI table statistics + */ +void +AcpiDbGenerateStatistics ( + ACPI_PARSE_OBJECT *Root, + BOOLEAN IsMethod); + +ACPI_STATUS +AcpiDbDisplayStatistics ( + char *TypeArg); + + +/* + * dbutils - AML debugger utilities + */ +void +AcpiDbSetOutputDestination ( + UINT32 Where); + +void +AcpiDbDumpExternalObject ( + ACPI_OBJECT *ObjDesc, + UINT32 Level); + +void +AcpiDbPrepNamestring ( + char *Name); + +ACPI_NAMESPACE_NODE * +AcpiDbLocalNsLookup ( + char *Name); + +void +AcpiDbUInt32ToHexString ( + UINT32 Value, + char *Buffer); + +#endif /* __ACDEBUG_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/acdisasm.h b/reactos/drivers/bus/acpi/acpica/include/acdisasm.h new file mode 100644 index 00000000000..de198ff5742 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/acdisasm.h @@ -0,0 +1,757 @@ +/****************************************************************************** + * + * Name: acdisasm.h - AML disassembler + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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. + * + *****************************************************************************/ + +#ifndef __ACDISASM_H__ +#define __ACDISASM_H__ + +#include "amlresrc.h" + + +#define BLOCK_NONE 0 +#define BLOCK_PAREN 1 +#define BLOCK_BRACE 2 +#define BLOCK_COMMA_LIST 4 +#define ACPI_DEFAULT_RESNAME *(UINT32 *) "__RD" + + +typedef const struct acpi_dmtable_info +{ + UINT8 Opcode; + UINT8 Offset; + char *Name; + +} ACPI_DMTABLE_INFO; + +/* + * Values for Opcode above. + * Note: 0-7 must not change, used as a flag shift value + */ +#define ACPI_DMT_FLAG0 0 +#define ACPI_DMT_FLAG1 1 +#define ACPI_DMT_FLAG2 2 +#define ACPI_DMT_FLAG3 3 +#define ACPI_DMT_FLAG4 4 +#define ACPI_DMT_FLAG5 5 +#define ACPI_DMT_FLAG6 6 +#define ACPI_DMT_FLAG7 7 +#define ACPI_DMT_FLAGS0 8 +#define ACPI_DMT_FLAGS2 9 +#define ACPI_DMT_UINT8 10 +#define ACPI_DMT_UINT16 11 +#define ACPI_DMT_UINT24 12 +#define ACPI_DMT_UINT32 13 +#define ACPI_DMT_UINT56 14 +#define ACPI_DMT_UINT64 15 +#define ACPI_DMT_STRING 16 +#define ACPI_DMT_NAME4 17 +#define ACPI_DMT_NAME6 18 +#define ACPI_DMT_NAME8 19 +#define ACPI_DMT_CHKSUM 20 +#define ACPI_DMT_SPACEID 21 +#define ACPI_DMT_GAS 22 +#define ACPI_DMT_ASF 23 +#define ACPI_DMT_DMAR 24 +#define ACPI_DMT_HEST 25 +#define ACPI_DMT_HESTNTFY 26 +#define ACPI_DMT_HESTNTYP 27 +#define ACPI_DMT_MADT 28 +#define ACPI_DMT_SRAT 29 +#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 + + +typedef +void (*ACPI_DMTABLE_HANDLER) ( + ACPI_TABLE_HEADER *Table); + +typedef struct acpi_dmtable_data +{ + char *Signature; + ACPI_DMTABLE_INFO *TableInfo; + ACPI_DMTABLE_HANDLER TableHandler; + char *Name; + +} ACPI_DMTABLE_DATA; + + +typedef struct acpi_op_walk_info +{ + UINT32 Level; + UINT32 LastLevel; + UINT32 Count; + UINT32 BitOffset; + UINT32 Flags; + ACPI_WALK_STATE *WalkState; + +} ACPI_OP_WALK_INFO; + +typedef +ACPI_STATUS (*ASL_WALK_CALLBACK) ( + ACPI_PARSE_OBJECT *Op, + UINT32 Level, + void *Context); + +typedef struct acpi_resource_tag +{ + UINT32 BitIndex; + char *Tag; + +} ACPI_RESOURCE_TAG; + +/* Strings used for decoding flags to ASL keywords */ + +extern const char *AcpiGbl_WordDecode[]; +extern const char *AcpiGbl_IrqDecode[]; +extern const char *AcpiGbl_LockRule[]; +extern const char *AcpiGbl_AccessTypes[]; +extern const char *AcpiGbl_UpdateRules[]; +extern const char *AcpiGbl_MatchOps[]; + +extern ACPI_DMTABLE_INFO AcpiDmTableInfoAsf0[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoAsf1[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoAsf1a[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoAsf2[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoAsf2a[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoAsf3[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoAsf4[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoAsfHdr[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoBoot[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoBert[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoCpep[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoCpep0[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoDbgp[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoDmar[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoDmarHdr[]; +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 AcpiDmTableInfoFacs[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoFadt1[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoFadt2[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoFadt3[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoGas[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoHeader[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoHest[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoHest0[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoHest1[]; +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[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt2[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt3[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt4[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt5[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt6[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt7[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt8[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt9[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt10[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadtHdr[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMcfg[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoMcfg0[]; +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[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoSlic[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoSlit[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoSpcr[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoSpmi[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoSrat[]; +extern ACPI_DMTABLE_INFO AcpiDmTableInfoSratHdr[]; +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 AcpiDmTableInfoWdrt[]; + + +/* + * dmtable + */ +void +AcpiDmDumpDataTable ( + ACPI_TABLE_HEADER *Table); + +ACPI_STATUS +AcpiDmDumpTable ( + UINT32 TableLength, + UINT32 TableOffset, + void *Table, + UINT32 SubTableLength, + ACPI_DMTABLE_INFO *Info); + +void +AcpiDmLineHeader ( + UINT32 Offset, + UINT32 ByteLength, + char *Name); + +void +AcpiDmLineHeader2 ( + UINT32 Offset, + UINT32 ByteLength, + char *Name, + UINT32 Value); + + +/* + * dmtbdump + */ +void +AcpiDmDumpAsf ( + ACPI_TABLE_HEADER *Table); + +void +AcpiDmDumpCpep ( + ACPI_TABLE_HEADER *Table); + +void +AcpiDmDumpDmar ( + ACPI_TABLE_HEADER *Table); + +void +AcpiDmDumpEinj ( + ACPI_TABLE_HEADER *Table); + +void +AcpiDmDumpErst ( + ACPI_TABLE_HEADER *Table); + +void +AcpiDmDumpFadt ( + ACPI_TABLE_HEADER *Table); + +void +AcpiDmDumpHest ( + ACPI_TABLE_HEADER *Table); + +void +AcpiDmDumpIvrs ( + ACPI_TABLE_HEADER *Table); + +void +AcpiDmDumpMcfg ( + ACPI_TABLE_HEADER *Table); + +void +AcpiDmDumpMadt ( + ACPI_TABLE_HEADER *Table); + +void +AcpiDmDumpMsct ( + ACPI_TABLE_HEADER *Table); + +UINT32 +AcpiDmDumpRsdp ( + ACPI_TABLE_HEADER *Table); + +void +AcpiDmDumpRsdt ( + ACPI_TABLE_HEADER *Table); + +void +AcpiDmDumpSlit ( + ACPI_TABLE_HEADER *Table); + +void +AcpiDmDumpSrat ( + ACPI_TABLE_HEADER *Table); + +void +AcpiDmDumpWdat ( + ACPI_TABLE_HEADER *Table); + +void +AcpiDmDumpXsdt ( + ACPI_TABLE_HEADER *Table); + + +/* + * dmwalk + */ +void +AcpiDmDisassemble ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Origin, + UINT32 NumOpcodes); + +void +AcpiDmWalkParseTree ( + ACPI_PARSE_OBJECT *Op, + ASL_WALK_CALLBACK DescendingCallback, + ASL_WALK_CALLBACK AscendingCallback, + void *Context); + + +/* + * dmopcode + */ +void +AcpiDmDisassembleOneOp ( + ACPI_WALK_STATE *WalkState, + ACPI_OP_WALK_INFO *Info, + ACPI_PARSE_OBJECT *Op); + +void +AcpiDmDecodeInternalObject ( + ACPI_OPERAND_OBJECT *ObjDesc); + +UINT32 +AcpiDmListType ( + ACPI_PARSE_OBJECT *Op); + +void +AcpiDmMethodFlags ( + ACPI_PARSE_OBJECT *Op); + +void +AcpiDmFieldFlags ( + ACPI_PARSE_OBJECT *Op); + +void +AcpiDmAddressSpace ( + UINT8 SpaceId); + +void +AcpiDmRegionFlags ( + ACPI_PARSE_OBJECT *Op); + +void +AcpiDmMatchOp ( + ACPI_PARSE_OBJECT *Op); + + +/* + * dmnames + */ +UINT32 +AcpiDmDumpName ( + UINT32 Name); + +ACPI_STATUS +AcpiPsDisplayObjectPathname ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + +void +AcpiDmNamestring ( + char *Name); + + +/* + * dmobject + */ +void +AcpiDmDisplayInternalObject ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_WALK_STATE *WalkState); + +void +AcpiDmDisplayArguments ( + ACPI_WALK_STATE *WalkState); + +void +AcpiDmDisplayLocals ( + ACPI_WALK_STATE *WalkState); + +void +AcpiDmDumpMethodInfo ( + ACPI_STATUS Status, + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + + +/* + * dmbuffer + */ +void +AcpiDmDisasmByteList ( + UINT32 Level, + UINT8 *ByteData, + UINT32 ByteCount); + +void +AcpiDmByteList ( + ACPI_OP_WALK_INFO *Info, + ACPI_PARSE_OBJECT *Op); + +void +AcpiDmIsEisaId ( + ACPI_PARSE_OBJECT *Op); + +void +AcpiDmEisaId ( + UINT32 EncodedId); + +BOOLEAN +AcpiDmIsUnicodeBuffer ( + ACPI_PARSE_OBJECT *Op); + +BOOLEAN +AcpiDmIsStringBuffer ( + ACPI_PARSE_OBJECT *Op); + + +/* + * dmextern + */ +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 + */ +void +AcpiDmDumpInteger8 ( + UINT8 Value, + char *Name); + +void +AcpiDmDumpInteger16 ( + UINT16 Value, + char *Name); + +void +AcpiDmDumpInteger32 ( + UINT32 Value, + char *Name); + +void +AcpiDmDumpInteger64 ( + UINT64 Value, + char *Name); + +void +AcpiDmResourceTemplate ( + ACPI_OP_WALK_INFO *Info, + ACPI_PARSE_OBJECT *Op, + UINT8 *ByteData, + UINT32 ByteCount); + +ACPI_STATUS +AcpiDmIsResourceTemplate ( + ACPI_PARSE_OBJECT *Op); + +void +AcpiDmBitList ( + UINT16 Mask); + +void +AcpiDmDescriptorName ( + void); + + +/* + * dmresrcl + */ +void +AcpiDmWordDescriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + +void +AcpiDmDwordDescriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + +void +AcpiDmExtendedDescriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + +void +AcpiDmQwordDescriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + +void +AcpiDmMemory24Descriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + +void +AcpiDmMemory32Descriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + +void +AcpiDmFixedMemory32Descriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + +void +AcpiDmGenericRegisterDescriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + +void +AcpiDmInterruptDescriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + +void +AcpiDmVendorLargeDescriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + +void +AcpiDmVendorCommon ( + char *Name, + UINT8 *ByteData, + UINT32 Length, + UINT32 Level); + + +/* + * dmresrcs + */ +void +AcpiDmIrqDescriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + +void +AcpiDmDmaDescriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + +void +AcpiDmIoDescriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + +void +AcpiDmFixedIoDescriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + +void +AcpiDmStartDependentDescriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + +void +AcpiDmEndDependentDescriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + +void +AcpiDmVendorSmallDescriptor ( + AML_RESOURCE *Resource, + UINT32 Length, + UINT32 Level); + + +/* + * dmutils + */ +void +AcpiDmDecodeAttribute ( + UINT8 Attribute); + +void +AcpiDmIndent ( + UINT32 Level); + +BOOLEAN +AcpiDmCommaIfListMember ( + ACPI_PARSE_OBJECT *Op); + +void +AcpiDmCommaIfFieldMember ( + ACPI_PARSE_OBJECT *Op); + + +/* + * dmrestag + */ +void +AcpiDmFindResources ( + ACPI_PARSE_OBJECT *Root); + +void +AcpiDmCheckResourceReference ( + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState); + +#endif /* __ACDISASM_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/acdispat.h b/reactos/drivers/bus/acpi/acpica/include/acdispat.h new file mode 100644 index 00000000000..2aa86232b2f --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/acdispat.h @@ -0,0 +1,527 @@ +/****************************************************************************** + * + * Name: acdispat.h - dispatcher (parser to interpreter interface) + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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. + * + *****************************************************************************/ + + +#ifndef _ACDISPAT_H_ +#define _ACDISPAT_H_ + + +#define NAMEOF_LOCAL_NTE "__L0" +#define NAMEOF_ARG_NTE "__A0" + + +/* + * dsopcode - support for late evaluation + */ +ACPI_STATUS +AcpiDsGetBufferFieldArguments ( + ACPI_OPERAND_OBJECT *ObjDesc); + +ACPI_STATUS +AcpiDsGetBankFieldArguments ( + ACPI_OPERAND_OBJECT *ObjDesc); + +ACPI_STATUS +AcpiDsGetRegionArguments ( + ACPI_OPERAND_OBJECT *RgnDesc); + +ACPI_STATUS +AcpiDsGetBufferArguments ( + ACPI_OPERAND_OBJECT *ObjDesc); + +ACPI_STATUS +AcpiDsGetPackageArguments ( + ACPI_OPERAND_OBJECT *ObjDesc); + +ACPI_STATUS +AcpiDsEvalBufferFieldOperands ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + +ACPI_STATUS +AcpiDsEvalRegionOperands ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + +ACPI_STATUS +AcpiDsEvalTableRegionOperands ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + +ACPI_STATUS +AcpiDsEvalDataObjectOperands ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + ACPI_OPERAND_OBJECT *ObjDesc); + +ACPI_STATUS +AcpiDsEvalBankFieldOperands ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + +ACPI_STATUS +AcpiDsInitializeRegion ( + ACPI_HANDLE ObjHandle); + + +/* + * dsctrl - Parser/Interpreter interface, control stack routines + */ +ACPI_STATUS +AcpiDsExecBeginControlOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + +ACPI_STATUS +AcpiDsExecEndControlOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + + +/* + * dsexec - Parser/Interpreter interface, method execution callbacks + */ +ACPI_STATUS +AcpiDsGetPredicateValue ( + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT *ResultObj); + +ACPI_STATUS +AcpiDsExecBeginOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT **OutOp); + +ACPI_STATUS +AcpiDsExecEndOp ( + ACPI_WALK_STATE *State); + + +/* + * dsfield - Parser/Interpreter interface for AML fields + */ +ACPI_STATUS +AcpiDsCreateField ( + ACPI_PARSE_OBJECT *Op, + ACPI_NAMESPACE_NODE *RegionNode, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsCreateBankField ( + ACPI_PARSE_OBJECT *Op, + ACPI_NAMESPACE_NODE *RegionNode, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsCreateIndexField ( + ACPI_PARSE_OBJECT *Op, + ACPI_NAMESPACE_NODE *RegionNode, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsCreateBufferField ( + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsInitFieldObjects ( + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState); + + +/* + * dsload - Parser/Interpreter interface, namespace load callbacks + */ +ACPI_STATUS +AcpiDsLoad1BeginOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT **OutOp); + +ACPI_STATUS +AcpiDsLoad1EndOp ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsLoad2BeginOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT **OutOp); + +ACPI_STATUS +AcpiDsLoad2EndOp ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsInitCallbacks ( + ACPI_WALK_STATE *WalkState, + UINT32 PassNumber); + + +/* + * dsmthdat - method data (locals/args) + */ +ACPI_STATUS +AcpiDsStoreObjectToLocal ( + UINT8 Type, + UINT32 Index, + ACPI_OPERAND_OBJECT *SrcDesc, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsMethodDataGetEntry ( + UINT16 Opcode, + UINT32 Index, + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT ***Node); + +void +AcpiDsMethodDataDeleteAll ( + ACPI_WALK_STATE *WalkState); + +BOOLEAN +AcpiDsIsMethodValue ( + ACPI_OPERAND_OBJECT *ObjDesc); + +ACPI_STATUS +AcpiDsMethodDataGetValue ( + UINT8 Type, + UINT32 Index, + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT **DestDesc); + +ACPI_STATUS +AcpiDsMethodDataInitArgs ( + ACPI_OPERAND_OBJECT **Params, + UINT32 MaxParamCount, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsMethodDataGetNode ( + UINT8 Type, + UINT32 Index, + ACPI_WALK_STATE *WalkState, + ACPI_NAMESPACE_NODE **Node); + +void +AcpiDsMethodDataInit ( + ACPI_WALK_STATE *WalkState); + + +/* + * dsmethod - Parser/Interpreter interface - control method parsing + */ +ACPI_STATUS +AcpiDsParseMethod ( + ACPI_NAMESPACE_NODE *Node); + +ACPI_STATUS +AcpiDsCallControlMethod ( + ACPI_THREAD_STATE *Thread, + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + +ACPI_STATUS +AcpiDsRestartControlMethod ( + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT *ReturnDesc); + +void +AcpiDsTerminateControlMethod ( + ACPI_OPERAND_OBJECT *MethodDesc, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsBeginMethodExecution ( + ACPI_NAMESPACE_NODE *MethodNode, + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsMethodError ( + ACPI_STATUS Status, + ACPI_WALK_STATE *WalkState); + +/* + * dsinit + */ +ACPI_STATUS +AcpiDsInitializeObjects ( + UINT32 TableIndex, + ACPI_NAMESPACE_NODE *StartNode); + + +/* + * dsobject - Parser/Interpreter interface - object initialization and conversion + */ +ACPI_STATUS +AcpiDsBuildInternalBufferObj ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + UINT32 BufferLength, + ACPI_OPERAND_OBJECT **ObjDescPtr); + +ACPI_STATUS +AcpiDsBuildInternalPackageObj ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *op, + UINT32 PackageLength, + ACPI_OPERAND_OBJECT **ObjDesc); + +ACPI_STATUS +AcpiDsInitObjectFromOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + UINT16 Opcode, + ACPI_OPERAND_OBJECT **ObjDesc); + +ACPI_STATUS +AcpiDsCreateNode ( + ACPI_WALK_STATE *WalkState, + ACPI_NAMESPACE_NODE *Node, + ACPI_PARSE_OBJECT *Op); + + +/* + * dsutils - Parser/Interpreter interface utility routines + */ +void +AcpiDsClearImplicitReturn ( + ACPI_WALK_STATE *WalkState); + +BOOLEAN +AcpiDsDoImplicitReturn ( + ACPI_OPERAND_OBJECT *ReturnDesc, + ACPI_WALK_STATE *WalkState, + BOOLEAN AddReference); + +BOOLEAN +AcpiDsIsResultUsed ( + ACPI_PARSE_OBJECT *Op, + ACPI_WALK_STATE *WalkState); + +void +AcpiDsDeleteResultIfNotUsed ( + ACPI_PARSE_OBJECT *Op, + ACPI_OPERAND_OBJECT *ResultObj, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsCreateOperand ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Arg, + UINT32 ArgsRemaining); + +ACPI_STATUS +AcpiDsCreateOperands ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *FirstArg); + +ACPI_STATUS +AcpiDsResolveOperands ( + ACPI_WALK_STATE *WalkState); + +void +AcpiDsClearOperands ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsEvaluateNamePath ( + ACPI_WALK_STATE *WalkState); + + +/* + * dswscope - Scope Stack manipulation + */ +ACPI_STATUS +AcpiDsScopeStackPush ( + ACPI_NAMESPACE_NODE *Node, + ACPI_OBJECT_TYPE Type, + ACPI_WALK_STATE *WalkState); + + +ACPI_STATUS +AcpiDsScopeStackPop ( + ACPI_WALK_STATE *WalkState); + +void +AcpiDsScopeStackClear ( + ACPI_WALK_STATE *WalkState); + + +/* + * dswstate - parser WALK_STATE management routines + */ +ACPI_STATUS +AcpiDsObjStackPush ( + void *Object, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsObjStackPop ( + UINT32 PopCount, + ACPI_WALK_STATE *WalkState); + +ACPI_WALK_STATE * +AcpiDsCreateWalkState ( + ACPI_OWNER_ID OwnerId, + ACPI_PARSE_OBJECT *Origin, + ACPI_OPERAND_OBJECT *MthDesc, + ACPI_THREAD_STATE *Thread); + +ACPI_STATUS +AcpiDsInitAmlWalk ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + ACPI_NAMESPACE_NODE *MethodNode, + UINT8 *AmlStart, + UINT32 AmlLength, + ACPI_EVALUATE_INFO *Info, + UINT8 PassNumber); + +void +AcpiDsObjStackPopAndDelete ( + UINT32 PopCount, + ACPI_WALK_STATE *WalkState); + +void +AcpiDsDeleteWalkState ( + ACPI_WALK_STATE *WalkState); + +ACPI_WALK_STATE * +AcpiDsPopWalkState ( + ACPI_THREAD_STATE *Thread); + +void +AcpiDsPushWalkState ( + ACPI_WALK_STATE *WalkState, + ACPI_THREAD_STATE *Thread); + +ACPI_STATUS +AcpiDsResultStackClear ( + ACPI_WALK_STATE *WalkState); + +ACPI_WALK_STATE * +AcpiDsGetCurrentWalkState ( + ACPI_THREAD_STATE *Thread); + +ACPI_STATUS +AcpiDsResultPop ( + ACPI_OPERAND_OBJECT **Object, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiDsResultPush ( + ACPI_OPERAND_OBJECT *Object, + ACPI_WALK_STATE *WalkState); + +#endif /* _ACDISPAT_H_ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/acevents.h b/reactos/drivers/bus/acpi/acpica/include/acevents.h new file mode 100644 index 00000000000..0cd5e2e2869 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/acevents.h @@ -0,0 +1,375 @@ +/****************************************************************************** + * + * Name: acevents.h - Event subcomponent prototypes and defines + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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. + * + *****************************************************************************/ + +#ifndef __ACEVENTS_H__ +#define __ACEVENTS_H__ + + +/* + * evevent + */ +ACPI_STATUS +AcpiEvInitializeEvents ( + void); + +ACPI_STATUS +AcpiEvInstallXruptHandlers ( + void); + +ACPI_STATUS +AcpiEvInstallFadtGpes ( + void); + +UINT32 +AcpiEvFixedEventDetect ( + void); + + +/* + * evmisc + */ +BOOLEAN +AcpiEvIsNotifyObject ( + ACPI_NAMESPACE_NODE *Node); + +ACPI_STATUS +AcpiEvAcquireGlobalLock( + UINT16 Timeout); + +ACPI_STATUS +AcpiEvReleaseGlobalLock( + void); + +ACPI_STATUS +AcpiEvInitGlobalLockHandler ( + void); + +UINT32 +AcpiEvGetGpeNumberIndex ( + UINT32 GpeNumber); + +ACPI_STATUS +AcpiEvQueueNotifyRequest ( + ACPI_NAMESPACE_NODE *Node, + UINT32 NotifyValue); + + +/* + * evgpe - GPE handling and dispatch + */ +ACPI_STATUS +AcpiEvUpdateGpeEnableMasks ( + ACPI_GPE_EVENT_INFO *GpeEventInfo, + UINT8 Type); + +ACPI_STATUS +AcpiEvEnableGpe ( + ACPI_GPE_EVENT_INFO *GpeEventInfo, + BOOLEAN WriteToHardware); + +ACPI_STATUS +AcpiEvDisableGpe ( + ACPI_GPE_EVENT_INFO *GpeEventInfo); + +ACPI_GPE_EVENT_INFO * +AcpiEvGetGpeEventInfo ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber); + + +/* + * evgpeblk + */ +BOOLEAN +AcpiEvValidGpeEvent ( + ACPI_GPE_EVENT_INFO *GpeEventInfo); + +ACPI_STATUS +AcpiEvWalkGpeList ( + ACPI_GPE_CALLBACK GpeWalkCallback, + void *Context); + +ACPI_STATUS +AcpiEvDeleteGpeHandlers ( + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *Context); + +ACPI_STATUS +AcpiEvCreateGpeBlock ( + ACPI_NAMESPACE_NODE *GpeDevice, + ACPI_GENERIC_ADDRESS *GpeBlockAddress, + UINT32 RegisterCount, + UINT8 GpeBlockBaseNumber, + UINT32 InterruptNumber, + ACPI_GPE_BLOCK_INFO **ReturnGpeBlock); + +ACPI_STATUS +AcpiEvInitializeGpeBlock ( + ACPI_NAMESPACE_NODE *GpeDevice, + ACPI_GPE_BLOCK_INFO *GpeBlock); + +ACPI_STATUS +AcpiEvDeleteGpeBlock ( + ACPI_GPE_BLOCK_INFO *GpeBlock); + +UINT32 +AcpiEvGpeDispatch ( + ACPI_GPE_EVENT_INFO *GpeEventInfo, + UINT32 GpeNumber); + +UINT32 +AcpiEvGpeDetect ( + ACPI_GPE_XRUPT_INFO *GpeXruptList); + +ACPI_STATUS +AcpiEvSetGpeType ( + ACPI_GPE_EVENT_INFO *GpeEventInfo, + UINT8 Type); + +ACPI_STATUS +AcpiEvCheckForWakeOnlyGpe ( + ACPI_GPE_EVENT_INFO *GpeEventInfo); + +ACPI_STATUS +AcpiEvGpeInitialize ( + void); + + +/* + * evregion - Address Space handling + */ +ACPI_STATUS +AcpiEvInstallRegionHandlers ( + void); + +ACPI_STATUS +AcpiEvInitializeOpRegions ( + void); + +ACPI_STATUS +AcpiEvAddressSpaceDispatch ( + ACPI_OPERAND_OBJECT *RegionObj, + UINT32 Function, + UINT32 RegionOffset, + UINT32 BitWidth, + ACPI_INTEGER *Value); + +ACPI_STATUS +AcpiEvAttachRegion ( + ACPI_OPERAND_OBJECT *HandlerObj, + ACPI_OPERAND_OBJECT *RegionObj, + BOOLEAN AcpiNsIsLocked); + +void +AcpiEvDetachRegion ( + ACPI_OPERAND_OBJECT *RegionObj, + BOOLEAN AcpiNsIsLocked); + +ACPI_STATUS +AcpiEvInstallSpaceHandler ( + ACPI_NAMESPACE_NODE *Node, + ACPI_ADR_SPACE_TYPE SpaceId, + ACPI_ADR_SPACE_HANDLER Handler, + ACPI_ADR_SPACE_SETUP Setup, + void *Context); + +ACPI_STATUS +AcpiEvExecuteRegMethods ( + ACPI_NAMESPACE_NODE *Node, + ACPI_ADR_SPACE_TYPE SpaceId); + +ACPI_STATUS +AcpiEvExecuteRegMethod ( + ACPI_OPERAND_OBJECT *RegionObj, + UINT32 Function); + + +/* + * evregini - Region initialization and setup + */ +ACPI_STATUS +AcpiEvSystemMemoryRegionSetup ( + ACPI_HANDLE Handle, + UINT32 Function, + void *HandlerContext, + void **RegionContext); + +ACPI_STATUS +AcpiEvIoSpaceRegionSetup ( + ACPI_HANDLE Handle, + UINT32 Function, + void *HandlerContext, + void **RegionContext); + +ACPI_STATUS +AcpiEvPciConfigRegionSetup ( + ACPI_HANDLE Handle, + UINT32 Function, + void *HandlerContext, + void **RegionContext); + +ACPI_STATUS +AcpiEvCmosRegionSetup ( + ACPI_HANDLE Handle, + UINT32 Function, + void *HandlerContext, + void **RegionContext); + +ACPI_STATUS +AcpiEvPciBarRegionSetup ( + ACPI_HANDLE Handle, + UINT32 Function, + void *HandlerContext, + void **RegionContext); + +ACPI_STATUS +AcpiEvDefaultRegionSetup ( + ACPI_HANDLE Handle, + UINT32 Function, + void *HandlerContext, + void **RegionContext); + +ACPI_STATUS +AcpiEvInitializeRegion ( + ACPI_OPERAND_OBJECT *RegionObj, + BOOLEAN AcpiNsLocked); + + +/* + * evsci - SCI (System Control Interrupt) handling/dispatch + */ +UINT32 ACPI_SYSTEM_XFACE +AcpiEvGpeXruptHandler ( + void *Context); + +UINT32 +AcpiEvInstallSciHandler ( + void); + +ACPI_STATUS +AcpiEvRemoveSciHandler ( + void); + +UINT32 +AcpiEvInitializeSCI ( + UINT32 ProgramSCI); + +void +AcpiEvTerminate ( + void); + + +#endif /* __ACEVENTS_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/acexcep.h b/reactos/drivers/bus/acpi/acpica/include/acexcep.h new file mode 100644 index 00000000000..dfe2e2ee734 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/acexcep.h @@ -0,0 +1,382 @@ +/****************************************************************************** + * + * Name: acexcep.h - Exception codes returned by the ACPI subsystem + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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. + * + *****************************************************************************/ + +#ifndef __ACEXCEP_H__ +#define __ACEXCEP_H__ + + +/* + * Exceptions returned by external ACPI interfaces + */ +#define AE_CODE_ENVIRONMENTAL 0x0000 +#define AE_CODE_PROGRAMMER 0x1000 +#define AE_CODE_ACPI_TABLES 0x2000 +#define AE_CODE_AML 0x3000 +#define AE_CODE_CONTROL 0x4000 +#define AE_CODE_MASK 0xF000 + + +#define ACPI_SUCCESS(a) (!(a)) +#define ACPI_FAILURE(a) (a) + + +#define AE_OK (ACPI_STATUS) 0x0000 + +/* + * Environmental exceptions + */ +#define AE_ERROR (ACPI_STATUS) (0x0001 | AE_CODE_ENVIRONMENTAL) +#define AE_NO_ACPI_TABLES (ACPI_STATUS) (0x0002 | AE_CODE_ENVIRONMENTAL) +#define AE_NO_NAMESPACE (ACPI_STATUS) (0x0003 | AE_CODE_ENVIRONMENTAL) +#define AE_NO_MEMORY (ACPI_STATUS) (0x0004 | AE_CODE_ENVIRONMENTAL) +#define AE_NOT_FOUND (ACPI_STATUS) (0x0005 | AE_CODE_ENVIRONMENTAL) +#define AE_NOT_EXIST (ACPI_STATUS) (0x0006 | AE_CODE_ENVIRONMENTAL) +#define AE_ALREADY_EXISTS (ACPI_STATUS) (0x0007 | AE_CODE_ENVIRONMENTAL) +#define AE_TYPE (ACPI_STATUS) (0x0008 | AE_CODE_ENVIRONMENTAL) +#define AE_NULL_OBJECT (ACPI_STATUS) (0x0009 | AE_CODE_ENVIRONMENTAL) +#define AE_NULL_ENTRY (ACPI_STATUS) (0x000A | AE_CODE_ENVIRONMENTAL) +#define AE_BUFFER_OVERFLOW (ACPI_STATUS) (0x000B | AE_CODE_ENVIRONMENTAL) +#define AE_STACK_OVERFLOW (ACPI_STATUS) (0x000C | AE_CODE_ENVIRONMENTAL) +#define AE_STACK_UNDERFLOW (ACPI_STATUS) (0x000D | AE_CODE_ENVIRONMENTAL) +#define AE_NOT_IMPLEMENTED (ACPI_STATUS) (0x000E | AE_CODE_ENVIRONMENTAL) +#define AE_SUPPORT (ACPI_STATUS) (0x000F | AE_CODE_ENVIRONMENTAL) +#define AE_LIMIT (ACPI_STATUS) (0x0010 | AE_CODE_ENVIRONMENTAL) +#define AE_TIME (ACPI_STATUS) (0x0011 | AE_CODE_ENVIRONMENTAL) +#define AE_ACQUIRE_DEADLOCK (ACPI_STATUS) (0x0012 | AE_CODE_ENVIRONMENTAL) +#define AE_RELEASE_DEADLOCK (ACPI_STATUS) (0x0013 | AE_CODE_ENVIRONMENTAL) +#define AE_NOT_ACQUIRED (ACPI_STATUS) (0x0014 | AE_CODE_ENVIRONMENTAL) +#define AE_ALREADY_ACQUIRED (ACPI_STATUS) (0x0015 | AE_CODE_ENVIRONMENTAL) +#define AE_NO_HARDWARE_RESPONSE (ACPI_STATUS) (0x0016 | AE_CODE_ENVIRONMENTAL) +#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_OWNER_ID_LIMIT (ACPI_STATUS) (0x001B | AE_CODE_ENVIRONMENTAL) + +#define AE_CODE_ENV_MAX 0x001B + + +/* + * Programmer exceptions + */ +#define AE_BAD_PARAMETER (ACPI_STATUS) (0x0001 | AE_CODE_PROGRAMMER) +#define AE_BAD_CHARACTER (ACPI_STATUS) (0x0002 | AE_CODE_PROGRAMMER) +#define AE_BAD_PATHNAME (ACPI_STATUS) (0x0003 | AE_CODE_PROGRAMMER) +#define AE_BAD_DATA (ACPI_STATUS) (0x0004 | AE_CODE_PROGRAMMER) +#define AE_BAD_HEX_CONSTANT (ACPI_STATUS) (0x0005 | AE_CODE_PROGRAMMER) +#define AE_BAD_OCTAL_CONSTANT (ACPI_STATUS) (0x0006 | AE_CODE_PROGRAMMER) +#define AE_BAD_DECIMAL_CONSTANT (ACPI_STATUS) (0x0007 | AE_CODE_PROGRAMMER) +#define AE_MISSING_ARGUMENTS (ACPI_STATUS) (0x0008 | AE_CODE_PROGRAMMER) +#define AE_BAD_ADDRESS (ACPI_STATUS) (0x0009 | AE_CODE_PROGRAMMER) + +#define AE_CODE_PGM_MAX 0x0009 + + +/* + * Acpi table exceptions + */ +#define AE_BAD_SIGNATURE (ACPI_STATUS) (0x0001 | AE_CODE_ACPI_TABLES) +#define AE_BAD_HEADER (ACPI_STATUS) (0x0002 | AE_CODE_ACPI_TABLES) +#define AE_BAD_CHECKSUM (ACPI_STATUS) (0x0003 | AE_CODE_ACPI_TABLES) +#define AE_BAD_VALUE (ACPI_STATUS) (0x0004 | AE_CODE_ACPI_TABLES) +#define AE_INVALID_TABLE_LENGTH (ACPI_STATUS) (0x0005 | AE_CODE_ACPI_TABLES) + +#define AE_CODE_TBL_MAX 0x0005 + + +/* + * AML exceptions. These are caused by problems with + * the actual AML byte stream + */ +#define AE_AML_BAD_OPCODE (ACPI_STATUS) (0x0001 | AE_CODE_AML) +#define AE_AML_NO_OPERAND (ACPI_STATUS) (0x0002 | AE_CODE_AML) +#define AE_AML_OPERAND_TYPE (ACPI_STATUS) (0x0003 | AE_CODE_AML) +#define AE_AML_OPERAND_VALUE (ACPI_STATUS) (0x0004 | AE_CODE_AML) +#define AE_AML_UNINITIALIZED_LOCAL (ACPI_STATUS) (0x0005 | AE_CODE_AML) +#define AE_AML_UNINITIALIZED_ARG (ACPI_STATUS) (0x0006 | AE_CODE_AML) +#define AE_AML_UNINITIALIZED_ELEMENT (ACPI_STATUS) (0x0007 | AE_CODE_AML) +#define AE_AML_NUMERIC_OVERFLOW (ACPI_STATUS) (0x0008 | AE_CODE_AML) +#define AE_AML_REGION_LIMIT (ACPI_STATUS) (0x0009 | AE_CODE_AML) +#define AE_AML_BUFFER_LIMIT (ACPI_STATUS) (0x000A | AE_CODE_AML) +#define AE_AML_PACKAGE_LIMIT (ACPI_STATUS) (0x000B | AE_CODE_AML) +#define AE_AML_DIVIDE_BY_ZERO (ACPI_STATUS) (0x000C | AE_CODE_AML) +#define AE_AML_BAD_NAME (ACPI_STATUS) (0x000D | AE_CODE_AML) +#define AE_AML_NAME_NOT_FOUND (ACPI_STATUS) (0x000E | AE_CODE_AML) +#define AE_AML_INTERNAL (ACPI_STATUS) (0x000F | AE_CODE_AML) +#define AE_AML_INVALID_SPACE_ID (ACPI_STATUS) (0x0010 | AE_CODE_AML) +#define AE_AML_STRING_LIMIT (ACPI_STATUS) (0x0011 | AE_CODE_AML) +#define AE_AML_NO_RETURN_VALUE (ACPI_STATUS) (0x0012 | AE_CODE_AML) +#define AE_AML_METHOD_LIMIT (ACPI_STATUS) (0x0013 | AE_CODE_AML) +#define AE_AML_NOT_OWNER (ACPI_STATUS) (0x0014 | AE_CODE_AML) +#define AE_AML_MUTEX_ORDER (ACPI_STATUS) (0x0015 | AE_CODE_AML) +#define AE_AML_MUTEX_NOT_ACQUIRED (ACPI_STATUS) (0x0016 | AE_CODE_AML) +#define AE_AML_INVALID_RESOURCE_TYPE (ACPI_STATUS) (0x0017 | AE_CODE_AML) +#define AE_AML_INVALID_INDEX (ACPI_STATUS) (0x0018 | AE_CODE_AML) +#define AE_AML_REGISTER_LIMIT (ACPI_STATUS) (0x0019 | AE_CODE_AML) +#define AE_AML_NO_WHILE (ACPI_STATUS) (0x001A | AE_CODE_AML) +#define AE_AML_ALIGNMENT (ACPI_STATUS) (0x001B | AE_CODE_AML) +#define AE_AML_NO_RESOURCE_END_TAG (ACPI_STATUS) (0x001C | AE_CODE_AML) +#define AE_AML_BAD_RESOURCE_VALUE (ACPI_STATUS) (0x001D | AE_CODE_AML) +#define AE_AML_CIRCULAR_REFERENCE (ACPI_STATUS) (0x001E | AE_CODE_AML) +#define AE_AML_BAD_RESOURCE_LENGTH (ACPI_STATUS) (0x001F | AE_CODE_AML) +#define AE_AML_ILLEGAL_ADDRESS (ACPI_STATUS) (0x0020 | AE_CODE_AML) +#define AE_AML_INFINITE_LOOP (ACPI_STATUS) (0x0021 | AE_CODE_AML) + +#define AE_CODE_AML_MAX 0x0021 + + +/* + * Internal exceptions used for control + */ +#define AE_CTRL_RETURN_VALUE (ACPI_STATUS) (0x0001 | AE_CODE_CONTROL) +#define AE_CTRL_PENDING (ACPI_STATUS) (0x0002 | AE_CODE_CONTROL) +#define AE_CTRL_TERMINATE (ACPI_STATUS) (0x0003 | AE_CODE_CONTROL) +#define AE_CTRL_TRUE (ACPI_STATUS) (0x0004 | AE_CODE_CONTROL) +#define AE_CTRL_FALSE (ACPI_STATUS) (0x0005 | AE_CODE_CONTROL) +#define AE_CTRL_DEPTH (ACPI_STATUS) (0x0006 | AE_CODE_CONTROL) +#define AE_CTRL_END (ACPI_STATUS) (0x0007 | AE_CODE_CONTROL) +#define AE_CTRL_TRANSFER (ACPI_STATUS) (0x0008 | AE_CODE_CONTROL) +#define AE_CTRL_BREAK (ACPI_STATUS) (0x0009 | AE_CODE_CONTROL) +#define AE_CTRL_CONTINUE (ACPI_STATUS) (0x000A | AE_CODE_CONTROL) +#define AE_CTRL_SKIP (ACPI_STATUS) (0x000B | AE_CODE_CONTROL) +#define AE_CTRL_PARSE_CONTINUE (ACPI_STATUS) (0x000C | AE_CODE_CONTROL) +#define AE_CTRL_PARSE_PENDING (ACPI_STATUS) (0x000D | AE_CODE_CONTROL) + +#define AE_CODE_CTRL_MAX 0x000D + + +/* Exception strings for AcpiFormatException */ + +#ifdef DEFINE_ACPI_GLOBALS + +/* + * String versions of the exception codes above + * These strings must match the corresponding defines exactly + */ +char const *AcpiGbl_ExceptionNames_Env[] = +{ + "AE_OK", + "AE_ERROR", + "AE_NO_ACPI_TABLES", + "AE_NO_NAMESPACE", + "AE_NO_MEMORY", + "AE_NOT_FOUND", + "AE_NOT_EXIST", + "AE_ALREADY_EXISTS", + "AE_TYPE", + "AE_NULL_OBJECT", + "AE_NULL_ENTRY", + "AE_BUFFER_OVERFLOW", + "AE_STACK_OVERFLOW", + "AE_STACK_UNDERFLOW", + "AE_NOT_IMPLEMENTED", + "AE_SUPPORT", + "AE_LIMIT", + "AE_TIME", + "AE_ACQUIRE_DEADLOCK", + "AE_RELEASE_DEADLOCK", + "AE_NOT_ACQUIRED", + "AE_ALREADY_ACQUIRED", + "AE_NO_HARDWARE_RESPONSE", + "AE_NO_GLOBAL_LOCK", + "AE_ABORT_METHOD", + "AE_SAME_HANDLER", + "AE_WAKE_ONLY_GPE", + "AE_OWNER_ID_LIMIT" +}; + +char const *AcpiGbl_ExceptionNames_Pgm[] = +{ + NULL, + "AE_BAD_PARAMETER", + "AE_BAD_CHARACTER", + "AE_BAD_PATHNAME", + "AE_BAD_DATA", + "AE_BAD_HEX_CONSTANT", + "AE_BAD_OCTAL_CONSTANT", + "AE_BAD_DECIMAL_CONSTANT", + "AE_MISSING_ARGUMENTS", + "AE_BAD_ADDRESS" +}; + +char const *AcpiGbl_ExceptionNames_Tbl[] = +{ + NULL, + "AE_BAD_SIGNATURE", + "AE_BAD_HEADER", + "AE_BAD_CHECKSUM", + "AE_BAD_VALUE", + "AE_INVALID_TABLE_LENGTH" +}; + +char const *AcpiGbl_ExceptionNames_Aml[] = +{ + NULL, + "AE_AML_BAD_OPCODE", + "AE_AML_NO_OPERAND", + "AE_AML_OPERAND_TYPE", + "AE_AML_OPERAND_VALUE", + "AE_AML_UNINITIALIZED_LOCAL", + "AE_AML_UNINITIALIZED_ARG", + "AE_AML_UNINITIALIZED_ELEMENT", + "AE_AML_NUMERIC_OVERFLOW", + "AE_AML_REGION_LIMIT", + "AE_AML_BUFFER_LIMIT", + "AE_AML_PACKAGE_LIMIT", + "AE_AML_DIVIDE_BY_ZERO", + "AE_AML_BAD_NAME", + "AE_AML_NAME_NOT_FOUND", + "AE_AML_INTERNAL", + "AE_AML_INVALID_SPACE_ID", + "AE_AML_STRING_LIMIT", + "AE_AML_NO_RETURN_VALUE", + "AE_AML_METHOD_LIMIT", + "AE_AML_NOT_OWNER", + "AE_AML_MUTEX_ORDER", + "AE_AML_MUTEX_NOT_ACQUIRED", + "AE_AML_INVALID_RESOURCE_TYPE", + "AE_AML_INVALID_INDEX", + "AE_AML_REGISTER_LIMIT", + "AE_AML_NO_WHILE", + "AE_AML_ALIGNMENT", + "AE_AML_NO_RESOURCE_END_TAG", + "AE_AML_BAD_RESOURCE_VALUE", + "AE_AML_CIRCULAR_REFERENCE", + "AE_AML_BAD_RESOURCE_LENGTH", + "AE_AML_ILLEGAL_ADDRESS", + "AE_AML_INFINITE_LOOP" +}; + +char const *AcpiGbl_ExceptionNames_Ctrl[] = +{ + NULL, + "AE_CTRL_RETURN_VALUE", + "AE_CTRL_PENDING", + "AE_CTRL_TERMINATE", + "AE_CTRL_TRUE", + "AE_CTRL_FALSE", + "AE_CTRL_DEPTH", + "AE_CTRL_END", + "AE_CTRL_TRANSFER", + "AE_CTRL_BREAK", + "AE_CTRL_CONTINUE", + "AE_CTRL_SKIP", + "AE_CTRL_PARSE_CONTINUE", + "AE_CTRL_PARSE_PENDING" +}; + +#endif /* ACPI GLOBALS */ + +#endif /* __ACEXCEP_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/acglobal.h b/reactos/drivers/bus/acpi/acpica/include/acglobal.h new file mode 100644 index 00000000000..82fe445169d --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/acglobal.h @@ -0,0 +1,494 @@ +/****************************************************************************** + * + * Name: acglobal.h - Declarations for global variables + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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. + * + *****************************************************************************/ + +#ifndef __ACGLOBAL_H__ +#define __ACGLOBAL_H__ + + +/* + * Ensure that the globals are actually defined and initialized only once. + * + * The use of these macros allows a single list of globals (here) in order + * to simplify maintenance of the code. + */ +#ifdef DEFINE_ACPI_GLOBALS +#define ACPI_EXTERN +#define ACPI_INIT_GLOBAL(a,b) a=b +#else +#define ACPI_EXTERN extern +#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) + * + ****************************************************************************/ + +/* + * Enable "slack" in the AML interpreter? Default is FALSE, and the + * interpreter strictly follows the ACPI specification. Setting to TRUE + * allows the interpreter to ignore certain errors and/or bad AML constructs. + * + * Currently, these features are enabled by this flag: + * + * 1) Allow "implicit return" of last value in a control method + * 2) Allow access beyond the end of an operation region + * 3) Allow access to uninitialized locals/args (auto-init to integer 0) + * 4) Allow ANY object type to be a source operand for the Store() operator + * 5) Allow unresolved references (invalid target name) in package objects + * 6) Enable warning messages for behavior that is not ACPI spec compliant + */ +UINT8 ACPI_INIT_GLOBAL (AcpiGbl_EnableInterpreterSlack, FALSE); + +/* + * Automatically serialize ALL control methods? Default is FALSE, meaning + * to use the Serialized/NotSerialized method flags on a per method basis. + * Only change this if the ASL code is poorly written and cannot handle + * reentrancy even though methods are marked "NotSerialized". + */ +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. + */ +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. + */ +UINT8 ACPI_INIT_GLOBAL (AcpiGbl_LeaveWakeGpesDisabled, TRUE); + +/* + * Optionally use default values for the ACPI register widths. Set this to + * TRUE to use the defaults, if an FADT contains incorrect widths/lengths. + */ +UINT8 ACPI_INIT_GLOBAL (AcpiGbl_UseDefaultRegisterWidths, TRUE); + + +/* 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; + +#endif + +/***************************************************************************** + * + * ACPI Table globals + * + ****************************************************************************/ + +/* + * AcpiGbl_RootTableList is the master list of ACPI tables found in the + * RSDT/XSDT. + * + */ +ACPI_EXTERN ACPI_INTERNAL_RSDT AcpiGbl_RootTableList; +ACPI_EXTERN ACPI_TABLE_FACS *AcpiGbl_FACS; + +/* These addresses are calculated from the FADT Event Block addresses */ + +ACPI_EXTERN ACPI_GENERIC_ADDRESS AcpiGbl_XPm1aStatus; +ACPI_EXTERN ACPI_GENERIC_ADDRESS AcpiGbl_XPm1aEnable; + +ACPI_EXTERN ACPI_GENERIC_ADDRESS AcpiGbl_XPm1bStatus; +ACPI_EXTERN ACPI_GENERIC_ADDRESS AcpiGbl_XPm1bEnable; + +/* + * 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 + * 2, use only the lower 32 bits of the internal 64-bit Integer. + */ +ACPI_EXTERN UINT8 AcpiGbl_IntegerBitWidth; +ACPI_EXTERN UINT8 AcpiGbl_IntegerByteWidth; +ACPI_EXTERN UINT8 AcpiGbl_IntegerNybbleWidth; + + +/***************************************************************************** + * + * Mutual exlusion within ACPICA subsystem + * + ****************************************************************************/ + +/* + * Predefined mutex objects. This array contains the + * actual OS mutex handles, indexed by the local ACPI_MUTEX_HANDLEs. + * (The table maps local handles to the real OS handles) + */ +ACPI_EXTERN ACPI_MUTEX_INFO AcpiGbl_MutexInfo[ACPI_NUM_MUTEX]; + +/* + * Global lock mutex is an actual AML mutex object + * Global lock semaphore works in conjunction with the HW global lock + */ +ACPI_EXTERN ACPI_OPERAND_OBJECT *AcpiGbl_GlobalLockMutex; +ACPI_EXTERN ACPI_SEMAPHORE AcpiGbl_GlobalLockSemaphore; +ACPI_EXTERN UINT16 AcpiGbl_GlobalLockHandle; +ACPI_EXTERN BOOLEAN AcpiGbl_GlobalLockAcquired; +ACPI_EXTERN BOOLEAN AcpiGbl_GlobalLockPresent; + +/* + * Spinlocks are used for interfaces that can be possibly called at + * interrupt level + */ +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 */ + +/* Reader/Writer lock is used for namespace walk and dynamic table unload */ + +ACPI_EXTERN ACPI_RW_LOCK AcpiGbl_NamespaceRwLock; + + +/***************************************************************************** + * + * Miscellaneous globals + * + ****************************************************************************/ + +/* Object caches */ + +ACPI_EXTERN ACPI_CACHE_T *AcpiGbl_NamespaceCache; +ACPI_EXTERN ACPI_CACHE_T *AcpiGbl_StateCache; +ACPI_EXTERN ACPI_CACHE_T *AcpiGbl_PsNodeCache; +ACPI_EXTERN ACPI_CACHE_T *AcpiGbl_PsNodeExtCache; +ACPI_EXTERN ACPI_CACHE_T *AcpiGbl_OperandCache; + +/* Global handlers */ + +ACPI_EXTERN ACPI_OBJECT_NOTIFY_HANDLER AcpiGbl_DeviceNotify; +ACPI_EXTERN ACPI_OBJECT_NOTIFY_HANDLER AcpiGbl_SystemNotify; +ACPI_EXTERN ACPI_EXCEPTION_HANDLER AcpiGbl_ExceptionHandler; +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; + + +/* Owner ID support */ + +ACPI_EXTERN UINT32 AcpiGbl_OwnerIdMask[ACPI_NUM_OWNERID_MASKS]; +ACPI_EXTERN UINT8 AcpiGbl_LastOwnerIdIndex; +ACPI_EXTERN UINT8 AcpiGbl_NextOwnerIdOffset; + +/* Misc */ + +ACPI_EXTERN UINT32 AcpiGbl_OriginalMode; +ACPI_EXTERN UINT32 AcpiGbl_RsdpOriginalLocation; +ACPI_EXTERN UINT32 AcpiGbl_NsLookupCount; +ACPI_EXTERN UINT32 AcpiGbl_PsFindCount; +ACPI_EXTERN UINT16 AcpiGbl_Pm1EnableRegisterSave; +ACPI_EXTERN 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; + + +#ifndef DEFINE_ACPI_GLOBALS + +/* Exception codes */ + +extern char const *AcpiGbl_ExceptionNames_Env[]; +extern char const *AcpiGbl_ExceptionNames_Pgm[]; +extern char const *AcpiGbl_ExceptionNames_Tbl[]; +extern char const *AcpiGbl_ExceptionNames_Aml[]; +extern char const *AcpiGbl_ExceptionNames_Ctrl[]; + +/* Other miscellaneous */ + +extern BOOLEAN AcpiGbl_Shutdown; +extern UINT32 AcpiGbl_StartupFlags; +extern const char *AcpiGbl_SleepStateNames[ACPI_S_STATE_COUNT]; +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 + + +#ifdef ACPI_DBG_TRACK_ALLOCATIONS + +/* Lists for tracking memory allocations */ + +ACPI_EXTERN ACPI_MEMORY_LIST *AcpiGbl_GlobalList; +ACPI_EXTERN ACPI_MEMORY_LIST *AcpiGbl_NsNodeList; +ACPI_EXTERN BOOLEAN AcpiGbl_DisplayFinalMemStats; +#endif + + +/***************************************************************************** + * + * Namespace globals + * + ****************************************************************************/ + +#if !defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY) +#define NUM_PREDEFINED_NAMES 10 +#else +#define NUM_PREDEFINED_NAMES 9 +#endif + +ACPI_EXTERN ACPI_NAMESPACE_NODE AcpiGbl_RootNodeStruct; +ACPI_EXTERN ACPI_NAMESPACE_NODE *AcpiGbl_RootNode; +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]; + +#ifdef ACPI_DEBUG_OUTPUT +ACPI_EXTERN UINT32 AcpiGbl_CurrentNodeCount; +ACPI_EXTERN UINT32 AcpiGbl_CurrentNodeSize; +ACPI_EXTERN UINT32 AcpiGbl_MaxConcurrentNodeCount; +ACPI_EXTERN ACPI_SIZE *AcpiGbl_EntryStackPointer; +ACPI_EXTERN ACPI_SIZE *AcpiGbl_LowestStackPointer; +ACPI_EXTERN UINT32 AcpiGbl_DeepestNesting; +#endif + + +/***************************************************************************** + * + * Interpreter globals + * + ****************************************************************************/ + + +ACPI_EXTERN ACPI_THREAD_STATE *AcpiGbl_CurrentWalkList; + +/* Control method single step flag */ + +ACPI_EXTERN UINT8 AcpiGbl_CmSingleStep; + + +/***************************************************************************** + * + * Hardware globals + * + ****************************************************************************/ + +extern ACPI_BIT_REGISTER_INFO AcpiGbl_BitRegisterInfo[ACPI_NUM_BITREG]; +ACPI_EXTERN UINT8 AcpiGbl_SleepTypeA; +ACPI_EXTERN UINT8 AcpiGbl_SleepTypeB; + + +/***************************************************************************** + * + * Event and GPE globals + * + ****************************************************************************/ + +extern ACPI_FIXED_EVENT_INFO AcpiGbl_FixedEventInfo[ACPI_NUM_FIXED_EVENTS]; +ACPI_EXTERN ACPI_FIXED_EVENT_HANDLER AcpiGbl_FixedEventHandlers[ACPI_NUM_FIXED_EVENTS]; +ACPI_EXTERN ACPI_GPE_XRUPT_INFO *AcpiGbl_GpeXruptListHead; +ACPI_EXTERN ACPI_GPE_BLOCK_INFO *AcpiGbl_GpeFadtBlocks[ACPI_MAX_GPE_BLOCKS]; + + +/***************************************************************************** + * + * Debug support + * + ****************************************************************************/ + +/* Procedure nesting level for debug output */ + +extern UINT32 AcpiGbl_NestingLevel; + +/* Event counters */ + +ACPI_EXTERN UINT32 AcpiMethodCount; +ACPI_EXTERN UINT32 AcpiGpeCount; +ACPI_EXTERN UINT32 AcpiSciCount; +ACPI_EXTERN UINT32 AcpiFixedEventCount[ACPI_NUM_FIXED_EVENTS]; + +/* Support for dynamic control method tracing mechanism */ + +ACPI_EXTERN UINT32 AcpiGbl_OriginalDbgLevel; +ACPI_EXTERN UINT32 AcpiGbl_OriginalDbgLayer; +ACPI_EXTERN UINT32 AcpiGbl_TraceDbgLevel; +ACPI_EXTERN UINT32 AcpiGbl_TraceDbgLayer; + + +/***************************************************************************** + * + * Debugger globals + * + ****************************************************************************/ + +ACPI_EXTERN UINT8 AcpiGbl_DbOutputFlags; + +#ifdef ACPI_DISASSEMBLER + +ACPI_EXTERN BOOLEAN AcpiGbl_DbOpt_disasm; +ACPI_EXTERN BOOLEAN AcpiGbl_DbOpt_verbose; +ACPI_EXTERN ACPI_EXTERNAL_LIST *AcpiGbl_ExternalList; +#endif + + +#ifdef ACPI_DEBUGGER + +extern BOOLEAN AcpiGbl_MethodExecuting; +extern BOOLEAN AcpiGbl_AbortMethod; +extern BOOLEAN AcpiGbl_DbTerminateThreads; + +ACPI_EXTERN BOOLEAN AcpiGbl_DbOpt_tables; +ACPI_EXTERN BOOLEAN AcpiGbl_DbOpt_stats; +ACPI_EXTERN BOOLEAN AcpiGbl_DbOpt_ini_methods; +ACPI_EXTERN BOOLEAN AcpiGbl_DbOpt_NoRegionSupport; + +ACPI_EXTERN char *AcpiGbl_DbArgs[ACPI_DEBUGGER_MAX_ARGS]; +ACPI_EXTERN char AcpiGbl_DbLineBuf[80]; +ACPI_EXTERN char AcpiGbl_DbParsedBuf[80]; +ACPI_EXTERN char AcpiGbl_DbScopeBuf[40]; +ACPI_EXTERN char AcpiGbl_DbDebugFilename[40]; +ACPI_EXTERN BOOLEAN AcpiGbl_DbOutputToFile; +ACPI_EXTERN char *AcpiGbl_DbBuffer; +ACPI_EXTERN char *AcpiGbl_DbFilename; +ACPI_EXTERN UINT32 AcpiGbl_DbDebugLevel; +ACPI_EXTERN UINT32 AcpiGbl_DbConsoleDebugLevel; +ACPI_EXTERN ACPI_NAMESPACE_NODE *AcpiGbl_DbScopeNode; + +/* + * Statistic globals + */ +ACPI_EXTERN UINT16 AcpiGbl_ObjTypeCount[ACPI_TYPE_NS_NODE_MAX+1]; +ACPI_EXTERN UINT16 AcpiGbl_NodeTypeCount[ACPI_TYPE_NS_NODE_MAX+1]; +ACPI_EXTERN UINT16 AcpiGbl_ObjTypeCountMisc; +ACPI_EXTERN UINT16 AcpiGbl_NodeTypeCountMisc; +ACPI_EXTERN UINT32 AcpiGbl_NumNodes; +ACPI_EXTERN UINT32 AcpiGbl_NumObjects; + + +ACPI_EXTERN UINT32 AcpiGbl_SizeOfParseTree; +ACPI_EXTERN UINT32 AcpiGbl_SizeOfMethodTrees; +ACPI_EXTERN UINT32 AcpiGbl_SizeOfNodeEntries; +ACPI_EXTERN UINT32 AcpiGbl_SizeOfAcpiObjects; + +#endif /* ACPI_DEBUGGER */ + +#endif /* __ACGLOBAL_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/achware.h b/reactos/drivers/bus/acpi/acpica/include/achware.h new file mode 100644 index 00000000000..c171a5fc1df --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/achware.h @@ -0,0 +1,269 @@ +/****************************************************************************** + * + * Name: achware.h -- hardware specific interfaces + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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. + * + *****************************************************************************/ + +#ifndef __ACHWARE_H__ +#define __ACHWARE_H__ + + +/* Values for the _SST predefined method */ + +#define ACPI_SST_INDICATOR_OFF 0 +#define ACPI_SST_WORKING 1 +#define ACPI_SST_WAKING 2 +#define ACPI_SST_SLEEPING 3 +#define ACPI_SST_SLEEP_CONTEXT 4 + + +/* + * hwacpi - high level functions + */ +ACPI_STATUS +AcpiHwSetMode ( + UINT32 Mode); + +UINT32 +AcpiHwGetMode ( + void); + + +/* + * 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); + +ACPI_STATUS +AcpiHwWritePm1Control ( + UINT32 Pm1aControl, + UINT32 Pm1bControl); + +ACPI_STATUS +AcpiHwRegisterRead ( + UINT32 RegisterId, + UINT32 *ReturnValue); + +ACPI_STATUS +AcpiHwRegisterWrite ( + UINT32 RegisterId, + UINT32 Value); + +ACPI_STATUS +AcpiHwClearAcpiStatus ( + void); + + +/* + * hwvalid - Port I/O with validation + */ +ACPI_STATUS +AcpiHwReadPort ( + ACPI_IO_ADDRESS Address, + UINT32 *Value, + UINT32 Width); + +ACPI_STATUS +AcpiHwWritePort ( + ACPI_IO_ADDRESS Address, + UINT32 Value, + UINT32 Width); + + +/* + * hwgpe - GPE support + */ +ACPI_STATUS +AcpiHwLowDisableGpe ( + ACPI_GPE_EVENT_INFO *GpeEventInfo); + +ACPI_STATUS +AcpiHwWriteGpeEnableReg ( + ACPI_GPE_EVENT_INFO *GpeEventInfo); + +ACPI_STATUS +AcpiHwDisableGpeBlock ( + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *Context); + +ACPI_STATUS +AcpiHwClearGpe ( + ACPI_GPE_EVENT_INFO *GpeEventInfo); + +ACPI_STATUS +AcpiHwClearGpeBlock ( + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *Context); + +ACPI_STATUS +AcpiHwGetGpeStatus ( + ACPI_GPE_EVENT_INFO *GpeEventInfo, + ACPI_EVENT_STATUS *EventStatus); + +ACPI_STATUS +AcpiHwDisableAllGpes ( + void); + +ACPI_STATUS +AcpiHwEnableAllRuntimeGpes ( + void); + +ACPI_STATUS +AcpiHwEnableAllWakeupGpes ( + void); + +ACPI_STATUS +AcpiHwEnableRuntimeGpeBlock ( + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *Context); + + +/* + * hwtimer - ACPI Timer prototypes + */ +ACPI_STATUS +AcpiGetTimerResolution ( + UINT32 *Resolution); + +ACPI_STATUS +AcpiGetTimer ( + UINT32 *Ticks); + +ACPI_STATUS +AcpiGetTimerDuration ( + UINT32 StartTicks, + UINT32 EndTicks, + UINT32 *TimeElapsed); + + +#endif /* __ACHWARE_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/acinterp.h b/reactos/drivers/bus/acpi/acpica/include/acinterp.h new file mode 100644 index 00000000000..74c5f0b4eba --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/acinterp.h @@ -0,0 +1,784 @@ +/****************************************************************************** + * + * Name: acinterp.h - Interpreter subcomponent prototypes and defines + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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. + * + *****************************************************************************/ + +#ifndef __ACINTERP_H__ +#define __ACINTERP_H__ + + +#define ACPI_WALK_OPERANDS (&(WalkState->Operands [WalkState->NumOperands -1])) + +/* Macros for tables used for debug output */ + +#define ACPI_EXD_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_OPERAND_OBJECT,f) +#define ACPI_EXD_NSOFFSET(f) (UINT8) ACPI_OFFSET (ACPI_NAMESPACE_NODE,f) +#define ACPI_EXD_TABLE_SIZE(name) (sizeof(name) / sizeof (ACPI_EXDUMP_INFO)) + +/* + * If possible, pack the following structures to byte alignment, since we + * don't care about performance for debug output. Two cases where we cannot + * pack the structures: + * + * 1) Hardware does not support misaligned memory transfers + * 2) Compiler does not support pointers within packed structures + */ +#if (!defined(ACPI_MISALIGNMENT_NOT_SUPPORTED) && !defined(ACPI_PACKED_POINTERS_NOT_SUPPORTED)) +#pragma pack(1) +#endif + +typedef const struct acpi_exdump_info +{ + UINT8 Opcode; + UINT8 Offset; + char *Name; + +} ACPI_EXDUMP_INFO; + +/* Values for the Opcode field above */ + +#define ACPI_EXD_INIT 0 +#define ACPI_EXD_TYPE 1 +#define ACPI_EXD_UINT8 2 +#define ACPI_EXD_UINT16 3 +#define ACPI_EXD_UINT32 4 +#define ACPI_EXD_UINT64 5 +#define ACPI_EXD_LITERAL 6 +#define ACPI_EXD_POINTER 7 +#define ACPI_EXD_ADDRESS 8 +#define ACPI_EXD_STRING 9 +#define ACPI_EXD_BUFFER 10 +#define ACPI_EXD_PACKAGE 11 +#define ACPI_EXD_FIELD 12 +#define ACPI_EXD_REFERENCE 13 + +/* restore default alignment */ + +#pragma pack() + + +/* + * exconvrt - object conversion + */ +ACPI_STATUS +AcpiExConvertToInteger ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT **ResultDesc, + UINT32 Flags); + +ACPI_STATUS +AcpiExConvertToBuffer ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT **ResultDesc); + +ACPI_STATUS +AcpiExConvertToString ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT **ResultDesc, + UINT32 Type); + +/* Types for ->String conversion */ + +#define ACPI_EXPLICIT_BYTE_COPY 0x00000000 +#define ACPI_EXPLICIT_CONVERT_HEX 0x00000001 +#define ACPI_IMPLICIT_CONVERT_HEX 0x00000002 +#define ACPI_EXPLICIT_CONVERT_DECIMAL 0x00000003 + +ACPI_STATUS +AcpiExConvertToTargetType ( + ACPI_OBJECT_TYPE DestinationType, + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT **ResultDesc, + ACPI_WALK_STATE *WalkState); + + +/* + * exfield - ACPI AML (p-code) execution - field manipulation + */ +ACPI_STATUS +AcpiExCommonBufferSetup ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 BufferLength, + UINT32 *DatumCount); + +ACPI_STATUS +AcpiExWriteWithUpdateRule ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_INTEGER Mask, + ACPI_INTEGER FieldValue, + UINT32 FieldDatumByteOffset); + +void +AcpiExGetBufferDatum( + ACPI_INTEGER *Datum, + void *Buffer, + UINT32 BufferLength, + UINT32 ByteGranularity, + UINT32 BufferOffset); + +void +AcpiExSetBufferDatum ( + ACPI_INTEGER MergedDatum, + void *Buffer, + UINT32 BufferLength, + UINT32 ByteGranularity, + UINT32 BufferOffset); + +ACPI_STATUS +AcpiExReadDataFromField ( + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT **RetBufferDesc); + +ACPI_STATUS +AcpiExWriteDataToField ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT **ResultDesc); + + +/* + * exfldio - low level field I/O + */ +ACPI_STATUS +AcpiExExtractFromField ( + ACPI_OPERAND_OBJECT *ObjDesc, + void *Buffer, + UINT32 BufferLength); + +ACPI_STATUS +AcpiExInsertIntoField ( + ACPI_OPERAND_OBJECT *ObjDesc, + void *Buffer, + UINT32 BufferLength); + +ACPI_STATUS +AcpiExAccessRegion ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 FieldDatumByteOffset, + ACPI_INTEGER *Value, + UINT32 ReadWrite); + + +/* + * exmisc - misc support routines + */ +ACPI_STATUS +AcpiExGetObjectReference ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT **ReturnDesc, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExConcatTemplate ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT *ObjDesc2, + ACPI_OPERAND_OBJECT **ActualReturnDesc, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExDoConcatenate ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT *ObjDesc2, + ACPI_OPERAND_OBJECT **ActualReturnDesc, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExDoLogicalNumericOp ( + UINT16 Opcode, + ACPI_INTEGER Integer0, + ACPI_INTEGER Integer1, + BOOLEAN *LogicalResult); + +ACPI_STATUS +AcpiExDoLogicalOp ( + UINT16 Opcode, + ACPI_OPERAND_OBJECT *Operand0, + ACPI_OPERAND_OBJECT *Operand1, + BOOLEAN *LogicalResult); + +ACPI_INTEGER +AcpiExDoMathOp ( + UINT16 Opcode, + ACPI_INTEGER Operand0, + ACPI_INTEGER Operand1); + +ACPI_STATUS +AcpiExCreateMutex ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExCreateProcessor ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExCreatePowerResource ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExCreateRegion ( + UINT8 *AmlStart, + UINT32 AmlLength, + UINT8 RegionSpace, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExCreateEvent ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExCreateAlias ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExCreateMethod ( + UINT8 *AmlStart, + UINT32 AmlLength, + ACPI_WALK_STATE *WalkState); + + +/* + * exconfig - dynamic table load/unload + */ +ACPI_STATUS +AcpiExLoadOp ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_OPERAND_OBJECT *Target, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExLoadTableOp ( + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT **ReturnDesc); + +ACPI_STATUS +AcpiExUnloadTable ( + ACPI_OPERAND_OBJECT *DdbHandle); + + +/* + * exmutex - mutex support + */ +ACPI_STATUS +AcpiExAcquireMutex ( + ACPI_OPERAND_OBJECT *TimeDesc, + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExAcquireMutexObject ( + UINT16 Timeout, + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_THREAD_ID ThreadId); + +ACPI_STATUS +AcpiExReleaseMutex ( + ACPI_OPERAND_OBJECT *ObjDesc, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExReleaseMutexObject ( + ACPI_OPERAND_OBJECT *ObjDesc); + +void +AcpiExReleaseAllMutexes ( + ACPI_THREAD_STATE *Thread); + +void +AcpiExUnlinkMutex ( + ACPI_OPERAND_OBJECT *ObjDesc); + + +/* + * exprep - ACPI AML execution - prep utilities + */ +ACPI_STATUS +AcpiExPrepCommonFieldObject ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT8 FieldFlags, + UINT8 FieldAttribute, + UINT32 FieldBitPosition, + UINT32 FieldBitLength); + +ACPI_STATUS +AcpiExPrepFieldValue ( + ACPI_CREATE_FIELD_INFO *Info); + + +/* + * exsystem - Interface to OS services + */ +ACPI_STATUS +AcpiExSystemDoNotifyOp ( + ACPI_OPERAND_OBJECT *Value, + ACPI_OPERAND_OBJECT *ObjDesc); + +ACPI_STATUS +AcpiExSystemDoSuspend( + ACPI_INTEGER Time); + +ACPI_STATUS +AcpiExSystemDoStall ( + UINT32 Time); + +ACPI_STATUS +AcpiExSystemSignalEvent( + ACPI_OPERAND_OBJECT *ObjDesc); + +ACPI_STATUS +AcpiExSystemWaitEvent( + ACPI_OPERAND_OBJECT *Time, + ACPI_OPERAND_OBJECT *ObjDesc); + +ACPI_STATUS +AcpiExSystemResetEvent( + ACPI_OPERAND_OBJECT *ObjDesc); + +ACPI_STATUS +AcpiExSystemWaitSemaphore ( + ACPI_SEMAPHORE Semaphore, + UINT16 Timeout); + +ACPI_STATUS +AcpiExSystemWaitMutex ( + ACPI_MUTEX Mutex, + UINT16 Timeout); + +/* + * exoparg1 - ACPI AML execution, 1 operand + */ +ACPI_STATUS +AcpiExOpcode_0A_0T_1R ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExOpcode_1A_0T_0R ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExOpcode_1A_0T_1R ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExOpcode_1A_1T_1R ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExOpcode_1A_1T_0R ( + ACPI_WALK_STATE *WalkState); + +/* + * exoparg2 - ACPI AML execution, 2 operands + */ +ACPI_STATUS +AcpiExOpcode_2A_0T_0R ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExOpcode_2A_0T_1R ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExOpcode_2A_1T_1R ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExOpcode_2A_2T_1R ( + ACPI_WALK_STATE *WalkState); + + +/* + * exoparg3 - ACPI AML execution, 3 operands + */ +ACPI_STATUS +AcpiExOpcode_3A_0T_0R ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExOpcode_3A_1T_1R ( + ACPI_WALK_STATE *WalkState); + + +/* + * exoparg6 - ACPI AML execution, 6 operands + */ +ACPI_STATUS +AcpiExOpcode_6A_0T_1R ( + ACPI_WALK_STATE *WalkState); + + +/* + * exresolv - Object resolution and get value functions + */ +ACPI_STATUS +AcpiExResolveToValue ( + ACPI_OPERAND_OBJECT **StackPtr, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExResolveMultiple ( + ACPI_WALK_STATE *WalkState, + ACPI_OPERAND_OBJECT *Operand, + ACPI_OBJECT_TYPE *ReturnType, + ACPI_OPERAND_OBJECT **ReturnDesc); + + +/* + * exresnte - resolve namespace node + */ +ACPI_STATUS +AcpiExResolveNodeToValue ( + ACPI_NAMESPACE_NODE **StackPtr, + ACPI_WALK_STATE *WalkState); + + +/* + * exresop - resolve operand to value + */ +ACPI_STATUS +AcpiExResolveOperands ( + UINT16 Opcode, + ACPI_OPERAND_OBJECT **StackPtr, + ACPI_WALK_STATE *WalkState); + + +/* + * exdump - Interpreter debug output routines + */ +void +AcpiExDumpOperand ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT32 Depth); + +void +AcpiExDumpOperands ( + ACPI_OPERAND_OBJECT **Operands, + const char *OpcodeName, + UINT32 NumOpcodes); + +void +AcpiExDumpObjectDescriptor ( + ACPI_OPERAND_OBJECT *Object, + UINT32 Flags); + +void +AcpiExDumpNamespaceNode ( + ACPI_NAMESPACE_NODE *Node, + UINT32 Flags); + + +/* + * exnames - AML namestring support + */ +ACPI_STATUS +AcpiExGetNameString ( + ACPI_OBJECT_TYPE DataType, + UINT8 *InAmlAddress, + char **OutNameString, + UINT32 *OutNameLength); + + +/* + * exstore - Object store support + */ +ACPI_STATUS +AcpiExStore ( + ACPI_OPERAND_OBJECT *ValDesc, + ACPI_OPERAND_OBJECT *DestDesc, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExStoreObjectToNode ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_NAMESPACE_NODE *Node, + ACPI_WALK_STATE *WalkState, + UINT8 ImplicitConversion); + +#define ACPI_IMPLICIT_CONVERSION TRUE +#define ACPI_NO_IMPLICIT_CONVERSION FALSE + + +/* + * exstoren - resolve/store object + */ +ACPI_STATUS +AcpiExResolveObject ( + ACPI_OPERAND_OBJECT **SourceDescPtr, + ACPI_OBJECT_TYPE TargetType, + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiExStoreObjectToObject ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT *DestDesc, + ACPI_OPERAND_OBJECT **NewDesc, + ACPI_WALK_STATE *WalkState); + + +/* + * exstorob - store object - buffer/string + */ +ACPI_STATUS +AcpiExStoreBufferToBuffer ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT *TargetDesc); + +ACPI_STATUS +AcpiExStoreStringToString ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT *TargetDesc); + + +/* + * excopy - object copy + */ +ACPI_STATUS +AcpiExCopyIntegerToIndexField ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT *TargetDesc); + +ACPI_STATUS +AcpiExCopyIntegerToBankField ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT *TargetDesc); + +ACPI_STATUS +AcpiExCopyDataToNamedField ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_NAMESPACE_NODE *Node); + +ACPI_STATUS +AcpiExCopyIntegerToBufferField ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT *TargetDesc); + + +/* + * exutils - interpreter/scanner utilities + */ +void +AcpiExEnterInterpreter ( + void); + +void +AcpiExExitInterpreter ( + void); + +void +AcpiExReacquireInterpreter ( + void); + +void +AcpiExRelinquishInterpreter ( + void); + +void +AcpiExTruncateFor32bitTable ( + ACPI_OPERAND_OBJECT *ObjDesc); + +void +AcpiExAcquireGlobalLock ( + UINT32 Rule); + +void +AcpiExReleaseGlobalLock ( + UINT32 Rule); + +void +AcpiExEisaIdToString ( + char *Dest, + ACPI_INTEGER CompressedId); + +void +AcpiExIntegerToString ( + char *Dest, + ACPI_INTEGER Value); + + +/* + * exregion - default OpRegion handlers + */ +ACPI_STATUS +AcpiExSystemMemorySpaceHandler ( + UINT32 Function, + ACPI_PHYSICAL_ADDRESS Address, + UINT32 BitWidth, + ACPI_INTEGER *Value, + void *HandlerContext, + void *RegionContext); + +ACPI_STATUS +AcpiExSystemIoSpaceHandler ( + UINT32 Function, + ACPI_PHYSICAL_ADDRESS Address, + UINT32 BitWidth, + ACPI_INTEGER *Value, + void *HandlerContext, + void *RegionContext); + +ACPI_STATUS +AcpiExPciConfigSpaceHandler ( + UINT32 Function, + ACPI_PHYSICAL_ADDRESS Address, + UINT32 BitWidth, + ACPI_INTEGER *Value, + void *HandlerContext, + void *RegionContext); + +ACPI_STATUS +AcpiExCmosSpaceHandler ( + UINT32 Function, + ACPI_PHYSICAL_ADDRESS Address, + UINT32 BitWidth, + ACPI_INTEGER *Value, + void *HandlerContext, + void *RegionContext); + +ACPI_STATUS +AcpiExPciBarSpaceHandler ( + UINT32 Function, + ACPI_PHYSICAL_ADDRESS Address, + UINT32 BitWidth, + ACPI_INTEGER *Value, + void *HandlerContext, + void *RegionContext); + +ACPI_STATUS +AcpiExEmbeddedControllerSpaceHandler ( + UINT32 Function, + ACPI_PHYSICAL_ADDRESS Address, + UINT32 BitWidth, + ACPI_INTEGER *Value, + void *HandlerContext, + void *RegionContext); + +ACPI_STATUS +AcpiExSmBusSpaceHandler ( + UINT32 Function, + ACPI_PHYSICAL_ADDRESS Address, + UINT32 BitWidth, + ACPI_INTEGER *Value, + void *HandlerContext, + void *RegionContext); + + +ACPI_STATUS +AcpiExDataTableSpaceHandler ( + UINT32 Function, + ACPI_PHYSICAL_ADDRESS Address, + UINT32 BitWidth, + ACPI_INTEGER *Value, + void *HandlerContext, + void *RegionContext); + +#endif /* __INTERP_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/aclocal.h b/reactos/drivers/bus/acpi/acpica/include/aclocal.h new file mode 100644 index 00000000000..52dbec3a6dc --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/aclocal.h @@ -0,0 +1,1332 @@ +/****************************************************************************** + * + * Name: aclocal.h - Internal data types used across the ACPI subsystem + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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. + * + *****************************************************************************/ + +#ifndef __ACLOCAL_H__ +#define __ACLOCAL_H__ + + +/* acpisrc:StructDefs -- for acpisrc conversion */ + +#define ACPI_SERIALIZED 0xFF + +typedef UINT32 ACPI_MUTEX_HANDLE; +#define ACPI_GLOBAL_LOCK (ACPI_SEMAPHORE) (-1) + +/* Total number of aml opcodes defined */ + +#define AML_NUM_OPCODES 0x7F + + +/* Forward declarations */ + +struct acpi_walk_state; +struct acpi_obj_mutex; +union acpi_parse_object; + + +/***************************************************************************** + * + * Mutex typedefs and structs + * + ****************************************************************************/ + + +/* + * Predefined handles for the mutex objects used within the subsystem + * All mutex objects are automatically created by AcpiUtMutexInitialize. + * + * The acquire/release ordering protocol is implied via this list. Mutexes + * with a lower value must be acquired before mutexes with a higher value. + * + * NOTE: any changes here must be reflected in the AcpiGbl_MutexNames + * table below also! + */ +#define ACPI_MTX_INTERPRETER 0 /* AML Interpreter, main lock */ +#define ACPI_MTX_NAMESPACE 1 /* ACPI Namespace */ +#define ACPI_MTX_TABLES 2 /* Data for ACPI tables */ +#define ACPI_MTX_EVENTS 3 /* Data for ACPI events */ +#define ACPI_MTX_CACHES 4 /* Internal caches, general purposes */ +#define ACPI_MTX_MEMORY 5 /* Debug memory tracking lists */ +#define ACPI_MTX_DEBUG_CMD_COMPLETE 6 /* AML debugger */ +#define ACPI_MTX_DEBUG_CMD_READY 7 /* AML debugger */ + +#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 */ + +typedef struct acpi_rw_lock +{ + ACPI_MUTEX WriterMutex; + ACPI_MUTEX ReaderMutex; + UINT32 NumReaders; + +} ACPI_RW_LOCK; + + +/* + * Predefined handles for spinlocks used within the subsystem. + * These spinlocks are created by AcpiUtMutexInitialize + */ +#define ACPI_LOCK_GPES 0 +#define ACPI_LOCK_HARDWARE 1 + +#define ACPI_MAX_LOCK 1 +#define ACPI_NUM_LOCK ACPI_MAX_LOCK+1 + + +/* This Thread ID means that the mutex is not in use (unlocked) */ + +#define ACPI_MUTEX_NOT_ACQUIRED (ACPI_THREAD_ID) -1 + +/* Table for the global mutexes */ + +typedef struct acpi_mutex_info +{ + ACPI_MUTEX Mutex; + UINT32 UseCount; + ACPI_THREAD_ID ThreadId; + +} ACPI_MUTEX_INFO; + + +/* Lock flag parameter for various interfaces */ + +#define ACPI_MTX_DO_NOT_LOCK 0 +#define ACPI_MTX_LOCK 1 + + +/* Field access granularities */ + +#define ACPI_FIELD_BYTE_GRANULARITY 1 +#define ACPI_FIELD_WORD_GRANULARITY 2 +#define ACPI_FIELD_DWORD_GRANULARITY 4 +#define ACPI_FIELD_QWORD_GRANULARITY 8 + + +#define ACPI_ENTRY_NOT_FOUND NULL + + +/***************************************************************************** + * + * Namespace typedefs and structs + * + ****************************************************************************/ + +/* Operational modes of the AML interpreter/scanner */ + +typedef enum +{ + ACPI_IMODE_LOAD_PASS1 = 0x01, + ACPI_IMODE_LOAD_PASS2 = 0x02, + ACPI_IMODE_EXECUTE = 0x03 + +} ACPI_INTERPRETER_MODE; + + +/* + * The Namespace Node describes a named object that appears in the AML. + * DescriptorType is used to differentiate between internal descriptors. + * + * The node is optimized for both 32-bit and 64-bit platforms: + * 20 bytes for the 32-bit case, 32 bytes for the 64-bit case. + * + * Note: The DescriptorType and Type fields must appear in the identical + * position in both the ACPI_NAMESPACE_NODE and ACPI_OPERAND_OBJECT + * structures. + */ +typedef struct acpi_namespace_node +{ + union acpi_operand_object *Object; /* Interpreter object */ + UINT8 DescriptorType; /* Differentiate object descriptor types */ + UINT8 Type; /* ACPI Type associated with this name */ + 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 *Child; /* First child */ + struct acpi_namespace_node *Peer; /* Peer. Parent if ANOBJ_END_OF_PEER_LIST set */ + + /* + * The following fields are used by the ASL compiler and disassembler only + */ +#ifdef ACPI_LARGE_NAMESPACE_NODE + union acpi_parse_object *Op; + UINT32 Value; + UINT32 Length; +#endif + +} ACPI_NAMESPACE_NODE; + + +/* Namespace Node flags */ + +#define ANOBJ_END_OF_PEER_LIST 0x01 /* End-of-list, Peer field points to parent */ +#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 */ +#define ANOBJ_SUBTREE_HAS_INI 0x10 /* Used to optimize device initialization */ +#define ANOBJ_EVALUATED 0x20 /* Set on first evaluation of node */ +#define ANOBJ_ALLOCATED_BUFFER 0x40 /* Method AML buffer is dynamic (InstallMethod) */ + +#define ANOBJ_IS_EXTERNAL 0x08 /* iASL only: This object created via External() */ +#define ANOBJ_METHOD_NO_RETVAL 0x10 /* iASL only: Method has no return value */ +#define ANOBJ_METHOD_SOME_NO_RETVAL 0x20 /* iASL only: Method has at least one return value */ +#define ANOBJ_IS_BIT_OFFSET 0x40 /* iASL only: Reference is a bit offset */ +#define ANOBJ_IS_REFERENCED 0x80 /* iASL only: Object was referenced */ + + +/* One internal RSDT for table management */ + +typedef struct acpi_internal_rsdt +{ + ACPI_TABLE_DESC *Tables; + UINT32 Count; + UINT32 Size; + UINT8 Flags; + +} ACPI_INTERNAL_RSDT; + +/* Flags for above */ + +#define ACPI_ROOT_ORIGIN_UNKNOWN (0) /* ~ORIGIN_ALLOCATED */ +#define ACPI_ROOT_ORIGIN_ALLOCATED (1) +#define ACPI_ROOT_ALLOW_RESIZE (2) + + +/* Predefined (fixed) table indexes */ + +#define ACPI_TABLE_INDEX_DSDT (0) +#define ACPI_TABLE_INDEX_FACS (1) + + +typedef struct acpi_find_context +{ + char *SearchFor; + ACPI_HANDLE *List; + UINT32 *Count; + +} ACPI_FIND_CONTEXT; + + +typedef struct acpi_ns_search_data +{ + ACPI_NAMESPACE_NODE *Node; + +} ACPI_NS_SEARCH_DATA; + + +/* Object types used during package copies */ + +#define ACPI_COPY_TYPE_SIMPLE 0 +#define ACPI_COPY_TYPE_PACKAGE 1 + + +/* Info structure used to convert external<->internal namestrings */ + +typedef struct acpi_namestring_info +{ + const char *ExternalName; + const char *NextExternalChar; + char *InternalName; + UINT32 Length; + UINT32 NumSegments; + UINT32 NumCarats; + BOOLEAN FullyQualified; + +} ACPI_NAMESTRING_INFO; + + +/* Field creation info */ + +typedef struct acpi_create_field_info +{ + ACPI_NAMESPACE_NODE *RegionNode; + ACPI_NAMESPACE_NODE *FieldNode; + ACPI_NAMESPACE_NODE *RegisterNode; + ACPI_NAMESPACE_NODE *DataRegisterNode; + UINT32 BankValue; + UINT32 FieldBitPosition; + UINT32 FieldBitLength; + UINT8 FieldFlags; + UINT8 Attribute; + UINT8 FieldType; + +} ACPI_CREATE_FIELD_INFO; + + +typedef +ACPI_STATUS (*ACPI_INTERNAL_METHOD) ( + struct acpi_walk_state *WalkState); + + +/* + * Bitmapped ACPI types. Used internally only + */ +#define ACPI_BTYPE_ANY 0x00000000 +#define ACPI_BTYPE_INTEGER 0x00000001 +#define ACPI_BTYPE_STRING 0x00000002 +#define ACPI_BTYPE_BUFFER 0x00000004 +#define ACPI_BTYPE_PACKAGE 0x00000008 +#define ACPI_BTYPE_FIELD_UNIT 0x00000010 +#define ACPI_BTYPE_DEVICE 0x00000020 +#define ACPI_BTYPE_EVENT 0x00000040 +#define ACPI_BTYPE_METHOD 0x00000080 +#define ACPI_BTYPE_MUTEX 0x00000100 +#define ACPI_BTYPE_REGION 0x00000200 +#define ACPI_BTYPE_POWER 0x00000400 +#define ACPI_BTYPE_PROCESSOR 0x00000800 +#define ACPI_BTYPE_THERMAL 0x00001000 +#define ACPI_BTYPE_BUFFER_FIELD 0x00002000 +#define ACPI_BTYPE_DDB_HANDLE 0x00004000 +#define ACPI_BTYPE_DEBUG_OBJECT 0x00008000 +#define ACPI_BTYPE_REFERENCE 0x00010000 +#define ACPI_BTYPE_RESOURCE 0x00020000 + +#define ACPI_BTYPE_COMPUTE_DATA (ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER) + +#define ACPI_BTYPE_DATA (ACPI_BTYPE_COMPUTE_DATA | ACPI_BTYPE_PACKAGE) +#define ACPI_BTYPE_DATA_REFERENCE (ACPI_BTYPE_DATA | ACPI_BTYPE_REFERENCE | ACPI_BTYPE_DDB_HANDLE) +#define ACPI_BTYPE_DEVICE_OBJECTS (ACPI_BTYPE_DEVICE | ACPI_BTYPE_THERMAL | ACPI_BTYPE_PROCESSOR) +#define ACPI_BTYPE_OBJECTS_AND_REFS 0x0001FFFF /* ARG or LOCAL */ +#define ACPI_BTYPE_ALL_OBJECTS 0x0000FFFF + + +/* + * Information structure for ACPI predefined names. + * Each entry in the table contains the following items: + * + * Name - The ACPI reserved name + * ParamCount - Number of arguments to the method + * ExpectedReturnBtypes - Allowed type(s) for the return value + */ +typedef struct acpi_name_info +{ + char Name[ACPI_NAME_SIZE]; + UINT8 ParamCount; + UINT8 ExpectedBtypes; + +} ACPI_NAME_INFO; + +/* + * Secondary information structures for ACPI predefined objects that return + * package objects. This structure appears as the next entry in the table + * after the NAME_INFO structure above. + * + * The reason for this is to minimize the size of the predefined name table. + */ + +/* + * Used for ACPI_PTYPE1_FIXED, ACPI_PTYPE1_VAR, ACPI_PTYPE2, + * ACPI_PTYPE2_MIN, ACPI_PTYPE2_PKG_COUNT, ACPI_PTYPE2_COUNT + */ +typedef struct acpi_package_info +{ + UINT8 Type; + UINT8 ObjectType1; + UINT8 Count1; + UINT8 ObjectType2; + UINT8 Count2; + UINT8 Reserved; + +} ACPI_PACKAGE_INFO; + +/* Used for ACPI_PTYPE2_FIXED */ + +typedef struct acpi_package_info2 +{ + UINT8 Type; + UINT8 Count; + UINT8 ObjectType[4]; + +} ACPI_PACKAGE_INFO2; + +/* Used for ACPI_PTYPE1_OPTION */ + +typedef struct acpi_package_info3 +{ + UINT8 Type; + UINT8 Count; + UINT8 ObjectType[2]; + UINT8 TailObjectType; + UINT8 Reserved; + +} ACPI_PACKAGE_INFO3; + +typedef union acpi_predefined_info +{ + ACPI_NAME_INFO Info; + ACPI_PACKAGE_INFO RetInfo; + ACPI_PACKAGE_INFO2 RetInfo2; + ACPI_PACKAGE_INFO3 RetInfo3; + +} ACPI_PREDEFINED_INFO; + + +/* Data block used during object validation */ + +typedef struct acpi_predefined_data +{ + char *Pathname; + const ACPI_PREDEFINED_INFO *Predefined; + 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 + * depends on this. + */ +#define ACPI_RTYPE_ANY 0x00 +#define ACPI_RTYPE_NONE 0x01 +#define ACPI_RTYPE_INTEGER 0x02 +#define ACPI_RTYPE_STRING 0x04 +#define ACPI_RTYPE_BUFFER 0x08 +#define ACPI_RTYPE_PACKAGE 0x10 +#define ACPI_RTYPE_REFERENCE 0x20 +#define ACPI_RTYPE_ALL 0x3F + +#define ACPI_NUM_RTYPES 5 /* Number of actual object types */ + + +/***************************************************************************** + * + * Event typedefs and structs + * + ****************************************************************************/ + +/* Dispatch info for each GPE -- either a method or handler, cannot be both */ + +typedef struct acpi_handler_info +{ + ACPI_EVENT_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) */ + +} ACPI_HANDLER_INFO; + +typedef union acpi_gpe_dispatch_info +{ + ACPI_NAMESPACE_NODE *MethodNode; /* Method node for this GPE level */ + struct acpi_handler_info *Handler; + +} ACPI_GPE_DISPATCH_INFO; + +/* + * Information about a GPE, one per each GPE in an array. + * NOTE: Important to keep this struct as small as possible. + */ +typedef struct acpi_gpe_event_info +{ + union acpi_gpe_dispatch_info Dispatch; /* Either Method or Handler */ + struct acpi_gpe_register_info *RegisterInfo; /* Backpointer to register info */ + UINT8 Flags; /* Misc info about this GPE */ + UINT8 GpeNumber; /* This GPE */ + +} ACPI_GPE_EVENT_INFO; + +/* Information about a GPE register pair, one per each status/enable pair in an array */ + +typedef struct acpi_gpe_register_info +{ + ACPI_GENERIC_ADDRESS StatusAddress; /* Address of status reg */ + ACPI_GENERIC_ADDRESS EnableAddress; /* Address of enable reg */ + UINT8 EnableForWake; /* GPEs to keep enabled when sleeping */ + UINT8 EnableForRun; /* GPEs to keep enabled when running */ + UINT8 BaseGpeNumber; /* Base GPE number for this register */ + +} ACPI_GPE_REGISTER_INFO; + +/* + * Information about a GPE register block, one per each installed block -- + * GPE0, GPE1, and one per each installed GPE Block Device. + */ +typedef struct acpi_gpe_block_info +{ + ACPI_NAMESPACE_NODE *Node; + struct acpi_gpe_block_info *Previous; + struct acpi_gpe_block_info *Next; + struct acpi_gpe_xrupt_info *XruptBlock; /* Backpointer to interrupt block */ + ACPI_GPE_REGISTER_INFO *RegisterInfo; /* One per GPE register pair */ + 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 */ + UINT8 BlockBaseNumber;/* Base GPE number for this block */ + +} ACPI_GPE_BLOCK_INFO; + +/* Information about GPE interrupt handlers, one per each interrupt level used for GPEs */ + +typedef struct acpi_gpe_xrupt_info +{ + struct acpi_gpe_xrupt_info *Previous; + struct acpi_gpe_xrupt_info *Next; + ACPI_GPE_BLOCK_INFO *GpeBlockListHead; /* List of GPE blocks for this xrupt */ + UINT32 InterruptNumber; /* System interrupt number */ + +} ACPI_GPE_XRUPT_INFO; + +typedef struct acpi_gpe_walk_info +{ + ACPI_NAMESPACE_NODE *GpeDevice; + ACPI_GPE_BLOCK_INFO *GpeBlock; + +} ACPI_GPE_WALK_INFO; + +typedef struct acpi_gpe_device_info +{ + UINT32 Index; + UINT32 NextBlockBaseIndex; + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *GpeDevice; + +} ACPI_GPE_DEVICE_INFO; + +typedef ACPI_STATUS (*ACPI_GPE_CALLBACK) ( + ACPI_GPE_XRUPT_INFO *GpeXruptInfo, + ACPI_GPE_BLOCK_INFO *GpeBlock, + void *Context); + + +/* Information about each particular fixed event */ + +typedef struct acpi_fixed_event_handler +{ + ACPI_EVENT_HANDLER Handler; /* Address of handler. */ + void *Context; /* Context to be passed to handler */ + +} ACPI_FIXED_EVENT_HANDLER; + +typedef struct acpi_fixed_event_info +{ + UINT8 StatusRegisterId; + UINT8 EnableRegisterId; + UINT16 StatusBitMask; + UINT16 EnableBitMask; + +} ACPI_FIXED_EVENT_INFO; + +/* Information used during field processing */ + +typedef struct acpi_field_info +{ + UINT8 SkipField; + UINT8 FieldFlag; + UINT32 PkgLength; + +} ACPI_FIELD_INFO; + + +/***************************************************************************** + * + * Generic "state" object for stacks + * + ****************************************************************************/ + +#define ACPI_CONTROL_NORMAL 0xC0 +#define ACPI_CONTROL_CONDITIONAL_EXECUTING 0xC1 +#define ACPI_CONTROL_PREDICATE_EXECUTING 0xC2 +#define ACPI_CONTROL_PREDICATE_FALSE 0xC3 +#define ACPI_CONTROL_PREDICATE_TRUE 0xC4 + + +#define ACPI_STATE_COMMON \ + void *Next; \ + UINT8 DescriptorType; /* To differentiate various internal objs */\ + UINT8 Flags; \ + UINT16 Value; \ + UINT16 State; + + /* There are 2 bytes available here until the next natural alignment boundary */ + +typedef struct acpi_common_state +{ + ACPI_STATE_COMMON +} ACPI_COMMON_STATE; + + +/* + * Update state - used to traverse complex objects such as packages + */ +typedef struct acpi_update_state +{ + ACPI_STATE_COMMON + union acpi_operand_object *Object; + +} ACPI_UPDATE_STATE; + + +/* + * Pkg state - used to traverse nested package structures + */ +typedef struct acpi_pkg_state +{ + ACPI_STATE_COMMON + UINT16 Index; + union acpi_operand_object *SourceObject; + union acpi_operand_object *DestObject; + struct acpi_walk_state *WalkState; + void *ThisTargetObj; + UINT32 NumPackages; + +} ACPI_PKG_STATE; + + +/* + * Control state - one per if/else and while constructs. + * Allows nesting of these constructs + */ +typedef struct acpi_control_state +{ + ACPI_STATE_COMMON + UINT16 Opcode; + union acpi_parse_object *PredicateOp; + UINT8 *AmlPredicateStart; /* Start of if/while predicate */ + UINT8 *PackageEnd; /* End of if/while block */ + UINT32 LoopCount; /* While() loop counter */ + +} ACPI_CONTROL_STATE; + + +/* + * Scope state - current scope during namespace lookups + */ +typedef struct acpi_scope_state +{ + ACPI_STATE_COMMON + ACPI_NAMESPACE_NODE *Node; + +} ACPI_SCOPE_STATE; + + +typedef struct acpi_pscope_state +{ + ACPI_STATE_COMMON + UINT32 ArgCount; /* Number of fixed arguments */ + union acpi_parse_object *Op; /* Current op being parsed */ + UINT8 *ArgEnd; /* Current argument end */ + UINT8 *PkgEnd; /* Current package end */ + UINT32 ArgList; /* Next argument to parse */ + +} ACPI_PSCOPE_STATE; + + +/* + * Thread state - one per thread across multiple walk states. Multiple walk + * states are created when there are nested control methods executing. + */ +typedef struct acpi_thread_state +{ + ACPI_STATE_COMMON + UINT8 CurrentSyncLevel; /* Mutex Sync (nested acquire) level */ + struct acpi_walk_state *WalkStateList; /* Head of list of WalkStates for this thread */ + union acpi_operand_object *AcquiredMutexList; /* List of all currently acquired mutexes */ + ACPI_THREAD_ID ThreadId; /* Running thread ID */ + +} ACPI_THREAD_STATE; + + +/* + * Result values - used to accumulate the results of nested + * AML arguments + */ +typedef struct acpi_result_values +{ + ACPI_STATE_COMMON + union acpi_operand_object *ObjDesc [ACPI_RESULTS_FRAME_OBJ_NUM]; + +} ACPI_RESULT_VALUES; + + +typedef +ACPI_STATUS (*ACPI_PARSE_DOWNWARDS) ( + struct acpi_walk_state *WalkState, + union acpi_parse_object **OutOp); + +typedef +ACPI_STATUS (*ACPI_PARSE_UPWARDS) ( + struct acpi_walk_state *WalkState); + + +/* + * Notify info - used to pass info to the deferred notify + * handler/dispatcher. + */ +typedef struct acpi_notify_info +{ + ACPI_STATE_COMMON + ACPI_NAMESPACE_NODE *Node; + union acpi_operand_object *HandlerObj; + +} ACPI_NOTIFY_INFO; + + +/* Generic state is union of structs above */ + +typedef union acpi_generic_state +{ + ACPI_COMMON_STATE Common; + ACPI_CONTROL_STATE Control; + ACPI_UPDATE_STATE Update; + ACPI_SCOPE_STATE Scope; + ACPI_PSCOPE_STATE ParseScope; + ACPI_PKG_STATE Pkg; + ACPI_THREAD_STATE Thread; + ACPI_RESULT_VALUES Results; + ACPI_NOTIFY_INFO Notify; + +} ACPI_GENERIC_STATE; + + +/***************************************************************************** + * + * Interpreter typedefs and structs + * + ****************************************************************************/ + +typedef +ACPI_STATUS (*ACPI_EXECUTE_OP) ( + struct acpi_walk_state *WalkState); + + +/***************************************************************************** + * + * Parser typedefs and structs + * + ****************************************************************************/ + +/* + * AML opcode, name, and argument layout + */ +typedef struct acpi_opcode_info +{ +#if defined(ACPI_DISASSEMBLER) || defined(ACPI_DEBUG_OUTPUT) + char *Name; /* Opcode name (disassembler/debug only) */ +#endif + UINT32 ParseArgs; /* Grammar/Parse time arguments */ + UINT32 RuntimeArgs; /* Interpret time arguments */ + UINT16 Flags; /* Misc flags */ + UINT8 ObjectType; /* Corresponding internal object type */ + UINT8 Class; /* Opcode class */ + UINT8 Type; /* Opcode type */ + +} ACPI_OPCODE_INFO; + +typedef union acpi_parse_value +{ + ACPI_INTEGER Integer; /* Integer constant (Up to 64 bits) */ + UINT64_STRUCT Integer64; /* Structure overlay for 2 32-bit Dwords */ + UINT32 Size; /* bytelist or field size */ + char *String; /* NULL terminated string */ + UINT8 *Buffer; /* buffer or string */ + char *Name; /* NULL terminated string */ + union acpi_parse_object *Arg; /* arguments and contained ops */ + +} ACPI_PARSE_VALUE; + + +#ifdef ACPI_DISASSEMBLER +#define ACPI_DISASM_ONLY_MEMBERS(a) a; +#else +#define ACPI_DISASM_ONLY_MEMBERS(a) +#endif + +#define ACPI_PARSE_COMMON \ + union acpi_parse_object *Parent; /* Parent op */\ + UINT8 DescriptorType; /* To differentiate various internal objs */\ + UINT8 Flags; /* Type of Op */\ + UINT16 AmlOpcode; /* AML opcode */\ + UINT32 AmlOffset; /* Offset of declaration in AML */\ + union acpi_parse_object *Next; /* Next op */\ + ACPI_NAMESPACE_NODE *Node; /* For use by interpreter */\ + ACPI_PARSE_VALUE Value; /* Value or args associated with the opcode */\ + UINT8 ArgListLength; /* Number of elements in the arg list */\ + ACPI_DISASM_ONLY_MEMBERS (\ + UINT8 DisasmFlags; /* Used during AML disassembly */\ + UINT8 DisasmOpcode; /* Subtype used for disassembly */\ + char AmlOpName[16]) /* Op name (debug only) */ + + +#define ACPI_DASM_BUFFER 0x00 +#define ACPI_DASM_RESOURCE 0x01 +#define ACPI_DASM_STRING 0x02 +#define ACPI_DASM_UNICODE 0x03 +#define ACPI_DASM_EISAID 0x04 +#define ACPI_DASM_MATCHOP 0x05 +#define ACPI_DASM_LNOT_PREFIX 0x06 +#define ACPI_DASM_LNOT_SUFFIX 0x07 +#define ACPI_DASM_IGNORE 0x08 + +/* + * Generic operation (for example: If, While, Store) + */ +typedef struct acpi_parse_obj_common +{ + ACPI_PARSE_COMMON +} ACPI_PARSE_OBJ_COMMON; + + +/* + * Extended Op for named ops (Scope, Method, etc.), deferred ops (Methods and OpRegions), + * and bytelists. + */ +typedef struct acpi_parse_obj_named +{ + ACPI_PARSE_COMMON + UINT8 *Path; + UINT8 *Data; /* AML body or bytelist data */ + UINT32 Length; /* AML length */ + UINT32 Name; /* 4-byte name or zero if no name */ + +} ACPI_PARSE_OBJ_NAMED; + + +/* This version is used by the iASL compiler only */ + +#define ACPI_MAX_PARSEOP_NAME 20 + +typedef struct acpi_parse_obj_asl +{ + ACPI_PARSE_COMMON + union acpi_parse_object *Child; + union acpi_parse_object *ParentMethod; + char *Filename; + char *ExternalName; + char *Namepath; + char NameSeg[4]; + UINT32 ExtraValue; + UINT32 Column; + UINT32 LineNumber; + UINT32 LogicalLineNumber; + UINT32 LogicalByteOffset; + UINT32 EndLine; + UINT32 EndLogicalLine; + UINT32 AcpiBtype; + UINT32 AmlLength; + UINT32 AmlSubtreeLength; + UINT32 FinalAmlLength; + UINT32 FinalAmlOffset; + UINT32 CompileFlags; + UINT16 ParseOpcode; + UINT8 AmlOpcodeLength; + UINT8 AmlPkgLenBytes; + UINT8 Extra; + char ParseOpName[ACPI_MAX_PARSEOP_NAME]; + +} ACPI_PARSE_OBJ_ASL; + +typedef union acpi_parse_object +{ + ACPI_PARSE_OBJ_COMMON Common; + ACPI_PARSE_OBJ_NAMED Named; + ACPI_PARSE_OBJ_ASL Asl; + +} ACPI_PARSE_OBJECT; + + +/* + * Parse state - one state per parser invocation and each control + * method. + */ +typedef struct acpi_parse_state +{ + UINT8 *AmlStart; /* First AML byte */ + UINT8 *Aml; /* Next AML byte */ + UINT8 *AmlEnd; /* (last + 1) AML byte */ + UINT8 *PkgStart; /* Current package begin */ + UINT8 *PkgEnd; /* Current package end */ + union acpi_parse_object *StartOp; /* Root of parse tree */ + struct acpi_namespace_node *StartNode; + union acpi_generic_state *Scope; /* Current scope */ + union acpi_parse_object *StartScope; + UINT32 AmlSize; + +} ACPI_PARSE_STATE; + + +/* Parse object flags */ + +#define ACPI_PARSEOP_GENERIC 0x01 +#define ACPI_PARSEOP_NAMED 0x02 +#define ACPI_PARSEOP_DEFERRED 0x04 +#define ACPI_PARSEOP_BYTELIST 0x08 +#define ACPI_PARSEOP_IN_STACK 0x10 +#define ACPI_PARSEOP_TARGET 0x20 +#define ACPI_PARSEOP_IN_CACHE 0x80 + +/* Parse object DisasmFlags */ + +#define ACPI_PARSEOP_IGNORE 0x01 +#define ACPI_PARSEOP_PARAMLIST 0x02 +#define ACPI_PARSEOP_EMPTY_TERMLIST 0x04 +#define ACPI_PARSEOP_SPECIAL 0x10 + + +/***************************************************************************** + * + * Hardware (ACPI registers) and PNP + * + ****************************************************************************/ + +typedef struct acpi_bit_register_info +{ + UINT8 ParentRegister; + UINT8 BitPosition; + UINT16 AccessBitMask; + +} ACPI_BIT_REGISTER_INFO; + + +/* + * Some ACPI registers have bits that must be ignored -- meaning that they + * must be preserved. + */ +#define ACPI_PM1_STATUS_PRESERVED_BITS 0x0800 /* Bit 11 */ + +/* Write-only bits must be zeroed by software */ + +#define ACPI_PM1_CONTROL_WRITEONLY_BITS 0x2004 /* Bits 13, 2 */ + +/* For control registers, both ignored and reserved bits must be preserved */ + +/* + * For PM1 control, 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, on some machines the OS must + * write a one to this bit after resume for the machine to work properly. + * To enable this, we no longer attempt to preserve this bit. No machines + * are known to fail if the bit is not preserved. (May 2009) + */ +#define ACPI_PM1_CONTROL_IGNORED_BITS 0x0200 /* Bit 9 */ +#define ACPI_PM1_CONTROL_RESERVED_BITS 0xC1F8 /* Bits 14-15, 3-8 */ +#define ACPI_PM1_CONTROL_PRESERVED_BITS \ + (ACPI_PM1_CONTROL_IGNORED_BITS | ACPI_PM1_CONTROL_RESERVED_BITS) + +#define ACPI_PM2_CONTROL_PRESERVED_BITS 0xFFFFFFFE /* All except bit 0 */ + +/* + * Register IDs + * These are the full ACPI registers + */ +#define ACPI_REGISTER_PM1_STATUS 0x01 +#define ACPI_REGISTER_PM1_ENABLE 0x02 +#define ACPI_REGISTER_PM1_CONTROL 0x03 +#define ACPI_REGISTER_PM2_CONTROL 0x04 +#define ACPI_REGISTER_PM_TIMER 0x05 +#define ACPI_REGISTER_PROCESSOR_BLOCK 0x06 +#define ACPI_REGISTER_SMI_COMMAND_BLOCK 0x07 + + +/* Masks used to access the BitRegisters */ + +#define ACPI_BITMASK_TIMER_STATUS 0x0001 +#define ACPI_BITMASK_BUS_MASTER_STATUS 0x0010 +#define ACPI_BITMASK_GLOBAL_LOCK_STATUS 0x0020 +#define ACPI_BITMASK_POWER_BUTTON_STATUS 0x0100 +#define ACPI_BITMASK_SLEEP_BUTTON_STATUS 0x0200 +#define ACPI_BITMASK_RT_CLOCK_STATUS 0x0400 +#define ACPI_BITMASK_PCIEXP_WAKE_STATUS 0x4000 /* ACPI 3.0 */ +#define ACPI_BITMASK_WAKE_STATUS 0x8000 + +#define ACPI_BITMASK_ALL_FIXED_STATUS (\ + ACPI_BITMASK_TIMER_STATUS | \ + ACPI_BITMASK_BUS_MASTER_STATUS | \ + ACPI_BITMASK_GLOBAL_LOCK_STATUS | \ + ACPI_BITMASK_POWER_BUTTON_STATUS | \ + ACPI_BITMASK_SLEEP_BUTTON_STATUS | \ + ACPI_BITMASK_RT_CLOCK_STATUS | \ + ACPI_BITMASK_WAKE_STATUS) + +#define ACPI_BITMASK_TIMER_ENABLE 0x0001 +#define ACPI_BITMASK_GLOBAL_LOCK_ENABLE 0x0020 +#define ACPI_BITMASK_POWER_BUTTON_ENABLE 0x0100 +#define ACPI_BITMASK_SLEEP_BUTTON_ENABLE 0x0200 +#define ACPI_BITMASK_RT_CLOCK_ENABLE 0x0400 +#define ACPI_BITMASK_PCIEXP_WAKE_DISABLE 0x4000 /* ACPI 3.0 */ + +#define ACPI_BITMASK_SCI_ENABLE 0x0001 +#define ACPI_BITMASK_BUS_MASTER_RLD 0x0002 +#define ACPI_BITMASK_GLOBAL_LOCK_RELEASE 0x0004 +#define ACPI_BITMASK_SLEEP_TYPE 0x1C00 +#define ACPI_BITMASK_SLEEP_ENABLE 0x2000 + +#define ACPI_BITMASK_ARB_DISABLE 0x0001 + + +/* Raw bit position of each BitRegister */ + +#define ACPI_BITPOSITION_TIMER_STATUS 0x00 +#define ACPI_BITPOSITION_BUS_MASTER_STATUS 0x04 +#define ACPI_BITPOSITION_GLOBAL_LOCK_STATUS 0x05 +#define ACPI_BITPOSITION_POWER_BUTTON_STATUS 0x08 +#define ACPI_BITPOSITION_SLEEP_BUTTON_STATUS 0x09 +#define ACPI_BITPOSITION_RT_CLOCK_STATUS 0x0A +#define ACPI_BITPOSITION_PCIEXP_WAKE_STATUS 0x0E /* ACPI 3.0 */ +#define ACPI_BITPOSITION_WAKE_STATUS 0x0F + +#define ACPI_BITPOSITION_TIMER_ENABLE 0x00 +#define ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE 0x05 +#define ACPI_BITPOSITION_POWER_BUTTON_ENABLE 0x08 +#define ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE 0x09 +#define ACPI_BITPOSITION_RT_CLOCK_ENABLE 0x0A +#define ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE 0x0E /* ACPI 3.0 */ + +#define ACPI_BITPOSITION_SCI_ENABLE 0x00 +#define ACPI_BITPOSITION_BUS_MASTER_RLD 0x01 +#define ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE 0x02 +#define ACPI_BITPOSITION_SLEEP_TYPE 0x0A +#define ACPI_BITPOSITION_SLEEP_ENABLE 0x0D + +#define ACPI_BITPOSITION_ARB_DISABLE 0x00 + + +/* Structs and definitions for _OSI support and I/O port validation */ + +#define ACPI_OSI_WIN_2000 0x01 +#define ACPI_OSI_WIN_XP 0x02 +#define ACPI_OSI_WIN_XP_SP1 0x03 +#define ACPI_OSI_WINSRV_2003 0x04 +#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_7 0x0A + +#define ACPI_ALWAYS_ILLEGAL 0x00 + +typedef struct acpi_interface_info +{ + char *Name; + UINT8 Value; + +} ACPI_INTERFACE_INFO; + +typedef struct acpi_port_info +{ + char *Name; + UINT16 Start; + UINT16 End; + UINT8 OsiDependency; + +} ACPI_PORT_INFO; + + +/***************************************************************************** + * + * Resource descriptors + * + ****************************************************************************/ + +/* ResourceType values */ + +#define ACPI_ADDRESS_TYPE_MEMORY_RANGE 0 +#define ACPI_ADDRESS_TYPE_IO_RANGE 1 +#define ACPI_ADDRESS_TYPE_BUS_NUMBER_RANGE 2 + +/* Resource descriptor types and masks */ + +#define ACPI_RESOURCE_NAME_LARGE 0x80 +#define ACPI_RESOURCE_NAME_SMALL 0x00 + +#define ACPI_RESOURCE_NAME_SMALL_MASK 0x78 /* Bits 6:3 contain the type */ +#define ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK 0x07 /* Bits 2:0 contain the length */ +#define ACPI_RESOURCE_NAME_LARGE_MASK 0x7F /* Bits 6:0 contain the type */ + + +/* + * Small resource descriptor "names" as defined by the ACPI specification. + * Note: Bits 2:0 are used for the descriptor length + */ +#define ACPI_RESOURCE_NAME_IRQ 0x20 +#define ACPI_RESOURCE_NAME_DMA 0x28 +#define ACPI_RESOURCE_NAME_START_DEPENDENT 0x30 +#define ACPI_RESOURCE_NAME_END_DEPENDENT 0x38 +#define ACPI_RESOURCE_NAME_IO 0x40 +#define ACPI_RESOURCE_NAME_FIXED_IO 0x48 +#define ACPI_RESOURCE_NAME_RESERVED_S1 0x50 +#define ACPI_RESOURCE_NAME_RESERVED_S2 0x58 +#define ACPI_RESOURCE_NAME_RESERVED_S3 0x60 +#define ACPI_RESOURCE_NAME_RESERVED_S4 0x68 +#define ACPI_RESOURCE_NAME_VENDOR_SMALL 0x70 +#define ACPI_RESOURCE_NAME_END_TAG 0x78 + +/* + * Large resource descriptor "names" as defined by the ACPI specification. + * Note: includes the Large Descriptor bit in bit[7] + */ +#define ACPI_RESOURCE_NAME_MEMORY24 0x81 +#define ACPI_RESOURCE_NAME_GENERIC_REGISTER 0x82 +#define ACPI_RESOURCE_NAME_RESERVED_L1 0x83 +#define ACPI_RESOURCE_NAME_VENDOR_LARGE 0x84 +#define ACPI_RESOURCE_NAME_MEMORY32 0x85 +#define ACPI_RESOURCE_NAME_FIXED_MEMORY32 0x86 +#define ACPI_RESOURCE_NAME_ADDRESS32 0x87 +#define ACPI_RESOURCE_NAME_ADDRESS16 0x88 +#define ACPI_RESOURCE_NAME_EXTENDED_IRQ 0x89 +#define ACPI_RESOURCE_NAME_ADDRESS64 0x8A +#define ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64 0x8B +#define ACPI_RESOURCE_NAME_LARGE_MAX 0x8B + + +/***************************************************************************** + * + * Miscellaneous + * + ****************************************************************************/ + +#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 + + +/***************************************************************************** + * + * Debugger + * + ****************************************************************************/ + +typedef struct acpi_db_method_info +{ + ACPI_HANDLE MainThreadGate; + ACPI_HANDLE ThreadCompleteGate; + ACPI_HANDLE InfoGate; + UINT32 *Threads; + UINT32 NumThreads; + UINT32 NumCreated; + UINT32 NumCompleted; + + char *Name; + UINT32 Flags; + UINT32 NumLoops; + char Pathname[128]; + char **Args; + + /* + * Arguments to be passed to method for the command + * Threads - + * the Number of threads, ID of current thread and + * Index of current thread inside all them created. + */ + char InitArgs; + char *Arguments[4]; + char NumThreadsStr[11]; + char IdOfThreadStr[11]; + char IndexOfThreadStr[11]; + +} ACPI_DB_METHOD_INFO; + +typedef struct acpi_integrity_info +{ + UINT32 Nodes; + UINT32 Objects; + +} ACPI_INTEGRITY_INFO; + + +#define ACPI_DB_REDIRECTABLE_OUTPUT 0x01 +#define ACPI_DB_CONSOLE_OUTPUT 0x02 +#define ACPI_DB_DUPLICATE_OUTPUT 0x03 + + +/***************************************************************************** + * + * Debug + * + ****************************************************************************/ + +/* Entry for a memory allocation (debug only) */ + +#define ACPI_MEM_MALLOC 0 +#define ACPI_MEM_CALLOC 1 +#define ACPI_MAX_MODULE_NAME 16 + +#define ACPI_COMMON_DEBUG_MEM_HEADER \ + struct acpi_debug_mem_block *Previous; \ + struct acpi_debug_mem_block *Next; \ + UINT32 Size; \ + UINT32 Component; \ + UINT32 Line; \ + char Module[ACPI_MAX_MODULE_NAME]; \ + UINT8 AllocType; + +typedef struct acpi_debug_mem_header +{ + ACPI_COMMON_DEBUG_MEM_HEADER + +} ACPI_DEBUG_MEM_HEADER; + +typedef struct acpi_debug_mem_block +{ + ACPI_COMMON_DEBUG_MEM_HEADER + UINT64 UserSpace; + +} ACPI_DEBUG_MEM_BLOCK; + + +#define ACPI_MEM_LIST_GLOBAL 0 +#define ACPI_MEM_LIST_NSNODE 1 +#define ACPI_MEM_LIST_MAX 1 +#define ACPI_NUM_MEM_LISTS 2 + + +#endif /* __ACLOCAL_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/acmacros.h b/reactos/drivers/bus/acpi/acpica/include/acmacros.h new file mode 100644 index 00000000000..3d351f9fc85 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/acmacros.h @@ -0,0 +1,605 @@ +/****************************************************************************** + * + * Name: acmacros.h - C macros for the entire subsystem. + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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. + * + *****************************************************************************/ + +#ifndef __ACMACROS_H__ +#define __ACMACROS_H__ + + +/* + * Extract data using a pointer. Any more than a byte and we + * get into potential aligment issues -- see the STORE macros below. + * Use with care. + */ +#define ACPI_GET8(ptr) *ACPI_CAST_PTR (UINT8, ptr) +#define ACPI_GET16(ptr) *ACPI_CAST_PTR (UINT16, ptr) +#define ACPI_GET32(ptr) *ACPI_CAST_PTR (UINT32, ptr) +#define ACPI_GET64(ptr) *ACPI_CAST_PTR (UINT64, ptr) +#define ACPI_SET8(ptr) *ACPI_CAST_PTR (UINT8, ptr) +#define ACPI_SET16(ptr) *ACPI_CAST_PTR (UINT16, ptr) +#define ACPI_SET32(ptr) *ACPI_CAST_PTR (UINT32, ptr) +#define ACPI_SET64(ptr) *ACPI_CAST_PTR (UINT64, ptr) + +/* + * printf() format helpers + */ + +/* Split 64-bit integer into two 32-bit values. Use with %8.8X%8.8X */ + +#define ACPI_FORMAT_UINT64(i) ACPI_HIDWORD(i), ACPI_LODWORD(i) + +#if ACPI_MACHINE_WIDTH == 64 +#define ACPI_FORMAT_NATIVE_UINT(i) ACPI_FORMAT_UINT64(i) +#else +#define ACPI_FORMAT_NATIVE_UINT(i) 0, (i) +#endif + + +/* + * Macros for moving data around to/from buffers that are possibly unaligned. + * If the hardware supports the transfer of unaligned data, just do the store. + * Otherwise, we have to move one byte at a time. + */ +#ifdef ACPI_BIG_ENDIAN +/* + * Macros for big-endian machines + */ + +/* These macros reverse the bytes during the move, converting little-endian to big endian */ + + /* Big Endian <== Little Endian */ + /* Hi...Lo Lo...Hi */ +/* 16-bit source, 16/32/64 destination */ + +#define ACPI_MOVE_16_TO_16(d, s) {(( UINT8 *)(void *)(d))[0] = ((UINT8 *)(void *)(s))[1];\ + (( UINT8 *)(void *)(d))[1] = ((UINT8 *)(void *)(s))[0];} + +#define ACPI_MOVE_16_TO_32(d, s) {(*(UINT32 *)(void *)(d))=0;\ + ((UINT8 *)(void *)(d))[2] = ((UINT8 *)(void *)(s))[1];\ + ((UINT8 *)(void *)(d))[3] = ((UINT8 *)(void *)(s))[0];} + +#define ACPI_MOVE_16_TO_64(d, s) {(*(UINT64 *)(void *)(d))=0;\ + ((UINT8 *)(void *)(d))[6] = ((UINT8 *)(void *)(s))[1];\ + ((UINT8 *)(void *)(d))[7] = ((UINT8 *)(void *)(s))[0];} + +/* 32-bit source, 16/32/64 destination */ + +#define ACPI_MOVE_32_TO_16(d, s) ACPI_MOVE_16_TO_16(d, s) /* Truncate to 16 */ + +#define ACPI_MOVE_32_TO_32(d, s) {(( UINT8 *)(void *)(d))[0] = ((UINT8 *)(void *)(s))[3];\ + (( UINT8 *)(void *)(d))[1] = ((UINT8 *)(void *)(s))[2];\ + (( UINT8 *)(void *)(d))[2] = ((UINT8 *)(void *)(s))[1];\ + (( UINT8 *)(void *)(d))[3] = ((UINT8 *)(void *)(s))[0];} + +#define ACPI_MOVE_32_TO_64(d, s) {(*(UINT64 *)(void *)(d))=0;\ + ((UINT8 *)(void *)(d))[4] = ((UINT8 *)(void *)(s))[3];\ + ((UINT8 *)(void *)(d))[5] = ((UINT8 *)(void *)(s))[2];\ + ((UINT8 *)(void *)(d))[6] = ((UINT8 *)(void *)(s))[1];\ + ((UINT8 *)(void *)(d))[7] = ((UINT8 *)(void *)(s))[0];} + +/* 64-bit source, 16/32/64 destination */ + +#define ACPI_MOVE_64_TO_16(d, s) ACPI_MOVE_16_TO_16(d, s) /* Truncate to 16 */ + +#define ACPI_MOVE_64_TO_32(d, s) ACPI_MOVE_32_TO_32(d, s) /* Truncate to 32 */ + +#define ACPI_MOVE_64_TO_64(d, s) {(( UINT8 *)(void *)(d))[0] = ((UINT8 *)(void *)(s))[7];\ + (( UINT8 *)(void *)(d))[1] = ((UINT8 *)(void *)(s))[6];\ + (( UINT8 *)(void *)(d))[2] = ((UINT8 *)(void *)(s))[5];\ + (( UINT8 *)(void *)(d))[3] = ((UINT8 *)(void *)(s))[4];\ + (( UINT8 *)(void *)(d))[4] = ((UINT8 *)(void *)(s))[3];\ + (( UINT8 *)(void *)(d))[5] = ((UINT8 *)(void *)(s))[2];\ + (( UINT8 *)(void *)(d))[6] = ((UINT8 *)(void *)(s))[1];\ + (( UINT8 *)(void *)(d))[7] = ((UINT8 *)(void *)(s))[0];} +#else +/* + * Macros for little-endian machines + */ + +#ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED + +/* The hardware supports unaligned transfers, just do the little-endian move */ + +/* 16-bit source, 16/32/64 destination */ + +#define ACPI_MOVE_16_TO_16(d, s) *(UINT16 *)(void *)(d) = *(UINT16 *)(void *)(s) +#define ACPI_MOVE_16_TO_32(d, s) *(UINT32 *)(void *)(d) = *(UINT16 *)(void *)(s) +#define ACPI_MOVE_16_TO_64(d, s) *(UINT64 *)(void *)(d) = *(UINT16 *)(void *)(s) + +/* 32-bit source, 16/32/64 destination */ + +#define ACPI_MOVE_32_TO_16(d, s) ACPI_MOVE_16_TO_16(d, s) /* Truncate to 16 */ +#define ACPI_MOVE_32_TO_32(d, s) *(UINT32 *)(void *)(d) = *(UINT32 *)(void *)(s) +#define ACPI_MOVE_32_TO_64(d, s) *(UINT64 *)(void *)(d) = *(UINT32 *)(void *)(s) + +/* 64-bit source, 16/32/64 destination */ + +#define ACPI_MOVE_64_TO_16(d, s) ACPI_MOVE_16_TO_16(d, s) /* Truncate to 16 */ +#define ACPI_MOVE_64_TO_32(d, s) ACPI_MOVE_32_TO_32(d, s) /* Truncate to 32 */ +#define ACPI_MOVE_64_TO_64(d, s) *(UINT64 *)(void *)(d) = *(UINT64 *)(void *)(s) + +#else +/* + * The hardware does not support unaligned transfers. We must move the + * data one byte at a time. These macros work whether the source or + * the destination (or both) is/are unaligned. (Little-endian move) + */ + +/* 16-bit source, 16/32/64 destination */ + +#define ACPI_MOVE_16_TO_16(d, s) {(( UINT8 *)(void *)(d))[0] = ((UINT8 *)(void *)(s))[0];\ + (( UINT8 *)(void *)(d))[1] = ((UINT8 *)(void *)(s))[1];} + +#define ACPI_MOVE_16_TO_32(d, s) {(*(UINT32 *)(void *)(d)) = 0; ACPI_MOVE_16_TO_16(d, s);} +#define ACPI_MOVE_16_TO_64(d, s) {(*(UINT64 *)(void *)(d)) = 0; ACPI_MOVE_16_TO_16(d, s);} + +/* 32-bit source, 16/32/64 destination */ + +#define ACPI_MOVE_32_TO_16(d, s) ACPI_MOVE_16_TO_16(d, s) /* Truncate to 16 */ + +#define ACPI_MOVE_32_TO_32(d, s) {(( UINT8 *)(void *)(d))[0] = ((UINT8 *)(void *)(s))[0];\ + (( UINT8 *)(void *)(d))[1] = ((UINT8 *)(void *)(s))[1];\ + (( UINT8 *)(void *)(d))[2] = ((UINT8 *)(void *)(s))[2];\ + (( UINT8 *)(void *)(d))[3] = ((UINT8 *)(void *)(s))[3];} + +#define ACPI_MOVE_32_TO_64(d, s) {(*(UINT64 *)(void *)(d)) = 0; ACPI_MOVE_32_TO_32(d, s);} + +/* 64-bit source, 16/32/64 destination */ + +#define ACPI_MOVE_64_TO_16(d, s) ACPI_MOVE_16_TO_16(d, s) /* Truncate to 16 */ +#define ACPI_MOVE_64_TO_32(d, s) ACPI_MOVE_32_TO_32(d, s) /* Truncate to 32 */ +#define ACPI_MOVE_64_TO_64(d, s) {(( UINT8 *)(void *)(d))[0] = ((UINT8 *)(void *)(s))[0];\ + (( UINT8 *)(void *)(d))[1] = ((UINT8 *)(void *)(s))[1];\ + (( UINT8 *)(void *)(d))[2] = ((UINT8 *)(void *)(s))[2];\ + (( UINT8 *)(void *)(d))[3] = ((UINT8 *)(void *)(s))[3];\ + (( UINT8 *)(void *)(d))[4] = ((UINT8 *)(void *)(s))[4];\ + (( UINT8 *)(void *)(d))[5] = ((UINT8 *)(void *)(s))[5];\ + (( UINT8 *)(void *)(d))[6] = ((UINT8 *)(void *)(s))[6];\ + (( UINT8 *)(void *)(d))[7] = ((UINT8 *)(void *)(s))[7];} +#endif +#endif + + +/* + * Fast power-of-two math macros for non-optimized compilers + */ +#define _ACPI_DIV(value, PowerOf2) ((UINT32) ((value) >> (PowerOf2))) +#define _ACPI_MUL(value, PowerOf2) ((UINT32) ((value) << (PowerOf2))) +#define _ACPI_MOD(value, Divisor) ((UINT32) ((value) & ((Divisor) -1))) + +#define ACPI_DIV_2(a) _ACPI_DIV(a, 1) +#define ACPI_MUL_2(a) _ACPI_MUL(a, 1) +#define ACPI_MOD_2(a) _ACPI_MOD(a, 2) + +#define ACPI_DIV_4(a) _ACPI_DIV(a, 2) +#define ACPI_MUL_4(a) _ACPI_MUL(a, 2) +#define ACPI_MOD_4(a) _ACPI_MOD(a, 4) + +#define ACPI_DIV_8(a) _ACPI_DIV(a, 3) +#define ACPI_MUL_8(a) _ACPI_MUL(a, 3) +#define ACPI_MOD_8(a) _ACPI_MOD(a, 8) + +#define ACPI_DIV_16(a) _ACPI_DIV(a, 4) +#define ACPI_MUL_16(a) _ACPI_MUL(a, 4) +#define ACPI_MOD_16(a) _ACPI_MOD(a, 16) + +#define ACPI_DIV_32(a) _ACPI_DIV(a, 5) +#define ACPI_MUL_32(a) _ACPI_MUL(a, 5) +#define ACPI_MOD_32(a) _ACPI_MOD(a, 32) + +/* + * Rounding macros (Power of two boundaries only) + */ +#define ACPI_ROUND_DOWN(value, boundary) (((ACPI_SIZE)(value)) & \ + (~(((ACPI_SIZE) boundary)-1))) + +#define ACPI_ROUND_UP(value, boundary) ((((ACPI_SIZE)(value)) + \ + (((ACPI_SIZE) boundary)-1)) & \ + (~(((ACPI_SIZE) boundary)-1))) + +/* Note: sizeof(ACPI_SIZE) evaluates to either 4 or 8 (32- vs 64-bit mode) */ + +#define ACPI_ROUND_DOWN_TO_32BIT(a) ACPI_ROUND_DOWN(a, 4) +#define ACPI_ROUND_DOWN_TO_64BIT(a) ACPI_ROUND_DOWN(a, 8) +#define ACPI_ROUND_DOWN_TO_NATIVE_WORD(a) ACPI_ROUND_DOWN(a, sizeof(ACPI_SIZE)) + +#define ACPI_ROUND_UP_TO_32BIT(a) ACPI_ROUND_UP(a, 4) +#define ACPI_ROUND_UP_TO_64BIT(a) ACPI_ROUND_UP(a, 8) +#define ACPI_ROUND_UP_TO_NATIVE_WORD(a) ACPI_ROUND_UP(a, sizeof(ACPI_SIZE)) + +#define ACPI_ROUND_BITS_UP_TO_BYTES(a) ACPI_DIV_8((a) + 7) +#define ACPI_ROUND_BITS_DOWN_TO_BYTES(a) ACPI_DIV_8((a)) + +#define ACPI_ROUND_UP_TO_1K(a) (((a) + 1023) >> 10) + +/* Generic (non-power-of-two) rounding */ + +#define ACPI_ROUND_UP_TO(value, boundary) (((value) + ((boundary)-1)) / (boundary)) + +#define ACPI_IS_MISALIGNED(value) (((ACPI_SIZE) value) & (sizeof(ACPI_SIZE)-1)) + +/* + * Bitmask creation + * Bit positions start at zero. + * MASK_BITS_ABOVE creates a mask starting AT the position and above + * MASK_BITS_BELOW creates a mask starting one bit BELOW the position + */ +#define ACPI_MASK_BITS_ABOVE(position) (~((ACPI_INTEGER_MAX) << ((UINT32) (position)))) +#define ACPI_MASK_BITS_BELOW(position) ((ACPI_INTEGER_MAX) << ((UINT32) (position))) + +/* Bitfields within ACPI registers */ + +#define ACPI_REGISTER_PREPARE_BITS(Val, Pos, Mask) ((Val << Pos) & Mask) +#define ACPI_REGISTER_INSERT_VALUE(Reg, Pos, Mask, Val) Reg = (Reg & (~(Mask))) | ACPI_REGISTER_PREPARE_BITS(Val, Pos, Mask) + +#define ACPI_INSERT_BITS(Target, Mask, Source) Target = ((Target & (~(Mask))) | (Source & Mask)) + +/* + * An ACPI_NAMESPACE_NODE can appear in some contexts + * where a pointer to an ACPI_OPERAND_OBJECT can also + * appear. This macro is used to distinguish them. + * + * The "Descriptor" field is the first field in both structures. + */ +#define ACPI_GET_DESCRIPTOR_TYPE(d) (((ACPI_DESCRIPTOR *)(void *)(d))->Common.DescriptorType) +#define ACPI_SET_DESCRIPTOR_TYPE(d, t) (((ACPI_DESCRIPTOR *)(void *)(d))->Common.DescriptorType = t) + +/* + * Macros for the master AML opcode table + */ +#if defined (ACPI_DISASSEMBLER) || defined (ACPI_DEBUG_OUTPUT) +#define ACPI_OP(Name, PArgs, IArgs, ObjType, Class, Type, Flags) \ + {Name, (UINT32)(PArgs), (UINT32)(IArgs), (UINT32)(Flags), ObjType, Class, Type} +#else +#define ACPI_OP(Name, PArgs, IArgs, ObjType, Class, Type, Flags) \ + {(UINT32)(PArgs), (UINT32)(IArgs), (UINT32)(Flags), ObjType, Class, Type} +#endif + +#define ARG_TYPE_WIDTH 5 +#define ARG_1(x) ((UINT32)(x)) +#define ARG_2(x) ((UINT32)(x) << (1 * ARG_TYPE_WIDTH)) +#define ARG_3(x) ((UINT32)(x) << (2 * ARG_TYPE_WIDTH)) +#define ARG_4(x) ((UINT32)(x) << (3 * ARG_TYPE_WIDTH)) +#define ARG_5(x) ((UINT32)(x) << (4 * ARG_TYPE_WIDTH)) +#define ARG_6(x) ((UINT32)(x) << (5 * ARG_TYPE_WIDTH)) + +#define ARGI_LIST1(a) (ARG_1(a)) +#define ARGI_LIST2(a, b) (ARG_1(b)|ARG_2(a)) +#define ARGI_LIST3(a, b, c) (ARG_1(c)|ARG_2(b)|ARG_3(a)) +#define ARGI_LIST4(a, b, c, d) (ARG_1(d)|ARG_2(c)|ARG_3(b)|ARG_4(a)) +#define ARGI_LIST5(a, b, c, d, e) (ARG_1(e)|ARG_2(d)|ARG_3(c)|ARG_4(b)|ARG_5(a)) +#define ARGI_LIST6(a, b, c, d, e, f) (ARG_1(f)|ARG_2(e)|ARG_3(d)|ARG_4(c)|ARG_5(b)|ARG_6(a)) + +#define ARGP_LIST1(a) (ARG_1(a)) +#define ARGP_LIST2(a, b) (ARG_1(a)|ARG_2(b)) +#define ARGP_LIST3(a, b, c) (ARG_1(a)|ARG_2(b)|ARG_3(c)) +#define ARGP_LIST4(a, b, c, d) (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d)) +#define ARGP_LIST5(a, b, c, d, e) (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d)|ARG_5(e)) +#define ARGP_LIST6(a, b, c, d, e, f) (ARG_1(a)|ARG_2(b)|ARG_3(c)|ARG_4(d)|ARG_5(e)|ARG_6(f)) + +#define GET_CURRENT_ARG_TYPE(List) (List & ((UINT32) 0x1F)) +#define INCREMENT_ARG_LIST(List) (List >>= ((UINT32) ARG_TYPE_WIDTH)) + +/* + * Ascii error messages can be configured out + */ +#ifndef ACPI_NO_ERROR_MESSAGES +/* + * Error reporting. Callers module and line number are inserted by AE_INFO, + * 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_WARN_PREDEFINED(plist) AcpiUtPredefinedWarning plist +#define ACPI_INFO_PREDEFINED(plist) AcpiUtPredefinedInfo plist + +#else + +/* No error messages */ + +#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 */ + +/* + * Debug macros that are conditionally compiled + */ +#ifdef ACPI_DEBUG_OUTPUT +/* + * Function entry tracing + */ +#define ACPI_FUNCTION_TRACE(a) ACPI_FUNCTION_NAME(a) \ + AcpiUtTrace(ACPI_DEBUG_PARAMETERS) +#define ACPI_FUNCTION_TRACE_PTR(a, b) ACPI_FUNCTION_NAME(a) \ + AcpiUtTracePtr(ACPI_DEBUG_PARAMETERS, (void *)b) +#define ACPI_FUNCTION_TRACE_U32(a, b) ACPI_FUNCTION_NAME(a) \ + AcpiUtTraceU32(ACPI_DEBUG_PARAMETERS, (UINT32)b) +#define ACPI_FUNCTION_TRACE_STR(a, b) ACPI_FUNCTION_NAME(a) \ + AcpiUtTraceStr(ACPI_DEBUG_PARAMETERS, (char *)b) + +#define ACPI_FUNCTION_ENTRY() AcpiUtTrackStackPtr() + +/* + * Function exit tracing. + * WARNING: These macros include a return statement. This is usually considered + * bad form, but having a separate exit macro is very ugly and difficult to maintain. + * One of the FUNCTION_TRACE macros above must be used in conjunction with these macros + * so that "_AcpiFunctionName" is defined. + * + * Note: the DO_WHILE0 macro is used to prevent some compilers from complaining + * about these constructs. + */ +#ifdef ACPI_USE_DO_WHILE_0 +#define ACPI_DO_WHILE0(a) do a while(0) +#else +#define ACPI_DO_WHILE0(a) a +#endif + +#define return_VOID ACPI_DO_WHILE0 ({ \ + AcpiUtExit (ACPI_DEBUG_PARAMETERS); \ + return;}) +/* + * There are two versions of most of the return macros. The default version is + * safer, since it avoids side-effects by guaranteeing that the argument will + * not be evaluated twice. + * + * A less-safe version of the macros is provided for optional use if the + * compiler uses excessive CPU stack (for example, this may happen in the + * debug case if code optimzation is disabled.) + */ +#ifndef ACPI_SIMPLE_RETURN_MACROS + +#define return_ACPI_STATUS(s) ACPI_DO_WHILE0 ({ \ + register ACPI_STATUS _s = (s); \ + AcpiUtStatusExit (ACPI_DEBUG_PARAMETERS, _s); \ + return (_s); }) +#define return_PTR(s) ACPI_DO_WHILE0 ({ \ + register void *_s = (void *) (s); \ + AcpiUtPtrExit (ACPI_DEBUG_PARAMETERS, (UINT8 *) _s); \ + return (_s); }) +#define return_VALUE(s) ACPI_DO_WHILE0 ({ \ + register ACPI_INTEGER _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); \ + return (_s); }) +#define return_UINT32(s) ACPI_DO_WHILE0 ({ \ + register UINT32 _s = (UINT32) (s); \ + AcpiUtValueExit (ACPI_DEBUG_PARAMETERS, (ACPI_INTEGER) _s); \ + return (_s); }) +#else /* Use original less-safe macros */ + +#define return_ACPI_STATUS(s) ACPI_DO_WHILE0 ({ \ + AcpiUtStatusExit (ACPI_DEBUG_PARAMETERS, (s)); \ + return((s)); }) +#define return_PTR(s) ACPI_DO_WHILE0 ({ \ + AcpiUtPtrExit (ACPI_DEBUG_PARAMETERS, (UINT8 *) (s)); \ + return((s)); }) +#define return_VALUE(s) ACPI_DO_WHILE0 ({ \ + AcpiUtValueExit (ACPI_DEBUG_PARAMETERS, (ACPI_INTEGER) (s)); \ + return((s)); }) +#define return_UINT8(s) return_VALUE(s) +#define return_UINT32(s) return_VALUE(s) + +#endif /* ACPI_SIMPLE_RETURN_MACROS */ + + +/* Conditional execution */ + +#define ACPI_DEBUG_EXEC(a) a +#define ACPI_DEBUG_ONLY_MEMBERS(a) a; +#define _VERBOSE_STRUCTURES + + +/* Various object display routines for debug */ + +#define ACPI_DUMP_STACK_ENTRY(a) AcpiExDumpOperand((a), 0) +#define ACPI_DUMP_OPERANDS(a, b ,c) AcpiExDumpOperands(a, b, c) +#define ACPI_DUMP_ENTRY(a, b) AcpiNsDumpEntry (a, b) +#define ACPI_DUMP_PATHNAME(a, b, c, d) AcpiNsDumpPathname(a, b, c, d) +#define ACPI_DUMP_BUFFER(a, b) AcpiUtDumpBuffer((UINT8 *) a, b, DB_BYTE_DISPLAY, _COMPONENT) + +#else +/* + * This is the non-debug case -- make everything go away, + * leaving no executable debug code! + */ +#define ACPI_DEBUG_EXEC(a) +#define ACPI_DEBUG_ONLY_MEMBERS(a) +#define ACPI_FUNCTION_TRACE(a) +#define ACPI_FUNCTION_TRACE_PTR(a, b) +#define ACPI_FUNCTION_TRACE_U32(a, b) +#define ACPI_FUNCTION_TRACE_STR(a, b) +#define ACPI_FUNCTION_EXIT +#define ACPI_FUNCTION_STATUS_EXIT(s) +#define ACPI_FUNCTION_VALUE_EXIT(s) +#define ACPI_FUNCTION_ENTRY() +#define ACPI_DUMP_STACK_ENTRY(a) +#define ACPI_DUMP_OPERANDS(a, b, c) +#define ACPI_DUMP_ENTRY(a, b) +#define ACPI_DUMP_TABLES(a, b) +#define ACPI_DUMP_PATHNAME(a, b, c, d) +#define ACPI_DUMP_BUFFER(a, b) +#define ACPI_DEBUG_PRINT(pl) +#define ACPI_DEBUG_PRINT_RAW(pl) + +#define return_VOID return +#define return_ACPI_STATUS(s) return(s) +#define return_VALUE(s) return(s) +#define return_UINT8(s) return(s) +#define return_UINT32(s) return(s) +#define return_PTR(s) return(s) + +#endif /* ACPI_DEBUG_OUTPUT */ + +/* + * Some code only gets executed when the debugger is built in. + * Note that this is entirely independent of whether the + * DEBUG_PRINT stuff (set by ACPI_DEBUG_OUTPUT) is on, or not. + */ +#ifdef ACPI_DEBUGGER +#define ACPI_DEBUGGER_EXEC(a) a +#else +#define ACPI_DEBUGGER_EXEC(a) +#endif + + +/* + * Memory allocation tracking (DEBUG ONLY) + */ +#define ACPI_MEM_PARAMETERS _COMPONENT, _AcpiModuleName, __LINE__ + +#ifndef ACPI_DBG_TRACK_ALLOCATIONS + +/* Memory allocation */ + +#define ACPI_ALLOCATE(a) AcpiUtAllocate((ACPI_SIZE) (a), ACPI_MEM_PARAMETERS) +#define ACPI_ALLOCATE_ZEROED(a) AcpiUtAllocateZeroed((ACPI_SIZE) (a), ACPI_MEM_PARAMETERS) +#define ACPI_FREE(a) AcpiOsFree(a) +#define ACPI_MEM_TRACKING(a) + +#else + +/* Memory allocation */ + +#define ACPI_ALLOCATE(a) AcpiUtAllocateAndTrack((ACPI_SIZE) (a), ACPI_MEM_PARAMETERS) +#define ACPI_ALLOCATE_ZEROED(a) AcpiUtAllocateZeroedAndTrack((ACPI_SIZE) (a), ACPI_MEM_PARAMETERS) +#define ACPI_FREE(a) AcpiUtFreeAndTrack(a, ACPI_MEM_PARAMETERS) +#define ACPI_MEM_TRACKING(a) a + +#endif /* ACPI_DBG_TRACK_ALLOCATIONS */ + + +/* + * Macros used for ACPICA utilities only + */ + +/* Generate a UUID */ + +#define ACPI_INIT_UUID(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) \ + (a) & 0xFF, ((a) >> 8) & 0xFF, ((a) >> 16) & 0xFF, ((a) >> 24) & 0xFF, \ + (b) & 0xFF, ((b) >> 8) & 0xFF, \ + (c) & 0xFF, ((c) >> 8) & 0xFF, \ + (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) + +#define ACPI_IS_OCTAL_DIGIT(d) (((char)(d) >= '0') && ((char)(d) <= '7')) + + +#endif /* ACMACROS_H */ diff --git a/reactos/drivers/bus/acpi/acpica/include/acnames.h b/reactos/drivers/bus/acpi/acpica/include/acnames.h new file mode 100644 index 00000000000..eb9944aa16e --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/acnames.h @@ -0,0 +1,157 @@ +/****************************************************************************** + * + * Name: acnames.h - Global names and strings + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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. + * + *****************************************************************************/ + +#ifndef __ACNAMES_H__ +#define __ACNAMES_H__ + +/* Method names - these methods can appear anywhere in the namespace */ + +#define METHOD_NAME__HID "_HID" +#define METHOD_NAME__CID "_CID" +#define METHOD_NAME__UID "_UID" +#define METHOD_NAME__ADR "_ADR" +#define METHOD_NAME__INI "_INI" +#define METHOD_NAME__STA "_STA" +#define METHOD_NAME__REG "_REG" +#define METHOD_NAME__SEG "_SEG" +#define METHOD_NAME__BBN "_BBN" +#define METHOD_NAME__PRT "_PRT" +#define METHOD_NAME__CRS "_CRS" +#define METHOD_NAME__PRS "_PRS" +#define METHOD_NAME__PRW "_PRW" +#define METHOD_NAME__SRS "_SRS" + +/* Method names - these methods must appear at the namespace root */ + +#define METHOD_NAME__BFS "\\_BFS" +#define METHOD_NAME__GTS "\\_GTS" +#define METHOD_NAME__PTS "\\_PTS" +#define METHOD_NAME__SST "\\_SI._SST" +#define METHOD_NAME__WAK "\\_WAK" + +/* Definitions of the predefined namespace names */ + +#define ACPI_UNKNOWN_NAME (UINT32) 0x3F3F3F3F /* Unknown name is "????" */ +#define ACPI_ROOT_NAME (UINT32) 0x5F5F5F5C /* Root name is "\___" */ + +#define ACPI_PREFIX_MIXED (UINT32) 0x69706341 /* "Acpi" */ +#define ACPI_PREFIX_LOWER (UINT32) 0x69706361 /* "acpi" */ + +#define ACPI_NS_ROOT_PATH "\\" +#define ACPI_NS_SYSTEM_BUS "_SB_" + +#endif /* __ACNAMES_H__ */ + + diff --git a/reactos/drivers/bus/acpi/acpica/include/acnamesp.h b/reactos/drivers/bus/acpi/acpica/include/acnamesp.h new file mode 100644 index 00000000000..65798662d59 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/acnamesp.h @@ -0,0 +1,566 @@ +/****************************************************************************** + * + * Name: acnamesp.h - Namespace subcomponent prototypes and defines + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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. + * + *****************************************************************************/ + +#ifndef __ACNAMESP_H__ +#define __ACNAMESP_H__ + + +/* To search the entire name space, pass this as SearchBase */ + +#define ACPI_NS_ALL ((ACPI_HANDLE)0) + +/* + * Elements of AcpiNsProperties are bit significant + * and should be one-to-one with values of ACPI_OBJECT_TYPE + */ +#define ACPI_NS_NORMAL 0 +#define ACPI_NS_NEWSCOPE 1 /* a definition of this type opens a name scope */ +#define ACPI_NS_LOCAL 2 /* suppress search of enclosing scopes */ + +/* Flags for AcpiNsLookup, AcpiNsSearchAndEnter */ + +#define ACPI_NS_NO_UPSEARCH 0 +#define ACPI_NS_SEARCH_PARENT 0x01 +#define ACPI_NS_DONT_OPEN_SCOPE 0x02 +#define ACPI_NS_NO_PEER_SEARCH 0x04 +#define ACPI_NS_ERROR_IF_FOUND 0x08 +#define ACPI_NS_PREFIX_IS_SCOPE 0x10 +#define ACPI_NS_EXTERNAL 0x20 +#define ACPI_NS_TEMPORARY 0x40 + +/* Flags for AcpiNsWalkNamespace */ + +#define ACPI_NS_WALK_NO_UNLOCK 0 +#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 + */ +ACPI_STATUS +AcpiNsInitializeObjects ( + void); + +ACPI_STATUS +AcpiNsInitializeDevices ( + void); + + +/* + * nsload - Namespace loading + */ +ACPI_STATUS +AcpiNsLoadNamespace ( + void); + +ACPI_STATUS +AcpiNsLoadTable ( + UINT32 TableIndex, + ACPI_NAMESPACE_NODE *Node); + + +/* + * nswalk - walk the namespace + */ +ACPI_STATUS +AcpiNsWalkNamespace ( + ACPI_OBJECT_TYPE Type, + ACPI_HANDLE StartObject, + UINT32 MaxDepth, + UINT32 Flags, + ACPI_WALK_CALLBACK PreOrderVisit, + ACPI_WALK_CALLBACK PostOrderVisit, + void *Context, + void **ReturnValue); + +ACPI_NAMESPACE_NODE * +AcpiNsGetNextNode ( + ACPI_NAMESPACE_NODE *Parent, + ACPI_NAMESPACE_NODE *Child); + +ACPI_NAMESPACE_NODE * +AcpiNsGetNextNodeTyped ( + ACPI_OBJECT_TYPE Type, + ACPI_NAMESPACE_NODE *Parent, + ACPI_NAMESPACE_NODE *Child); + +/* + * nsparse - table parsing + */ +ACPI_STATUS +AcpiNsParseTable ( + UINT32 TableIndex, + ACPI_NAMESPACE_NODE *StartNode); + +ACPI_STATUS +AcpiNsOneCompleteParse ( + UINT32 PassNumber, + UINT32 TableIndex, + ACPI_NAMESPACE_NODE *StartNode); + + +/* + * nsaccess - Top-level namespace access + */ +ACPI_STATUS +AcpiNsRootInitialize ( + void); + +ACPI_STATUS +AcpiNsLookup ( + ACPI_GENERIC_STATE *ScopeInfo, + char *Name, + ACPI_OBJECT_TYPE Type, + ACPI_INTERPRETER_MODE InterpreterMode, + UINT32 Flags, + ACPI_WALK_STATE *WalkState, + ACPI_NAMESPACE_NODE **RetNode); + + +/* + * nsalloc - Named object allocation/deallocation + */ +ACPI_NAMESPACE_NODE * +AcpiNsCreateNode ( + UINT32 Name); + +void +AcpiNsDeleteNode ( + ACPI_NAMESPACE_NODE *Node); + +void +AcpiNsRemoveNode ( + ACPI_NAMESPACE_NODE *Node); + +void +AcpiNsDeleteNamespaceSubtree ( + ACPI_NAMESPACE_NODE *ParentHandle); + +void +AcpiNsDeleteNamespaceByOwner ( + ACPI_OWNER_ID OwnerId); + +void +AcpiNsDetachObject ( + ACPI_NAMESPACE_NODE *Node); + +void +AcpiNsDeleteChildren ( + ACPI_NAMESPACE_NODE *Parent); + +int +AcpiNsCompareNames ( + char *Name1, + char *Name2); + + +/* + * nsdump - Namespace dump/print utilities + */ +void +AcpiNsDumpTables ( + ACPI_HANDLE SearchBase, + UINT32 MaxDepth); + +void +AcpiNsDumpEntry ( + ACPI_HANDLE Handle, + UINT32 DebugLevel); + +void +AcpiNsDumpPathname ( + ACPI_HANDLE Handle, + char *Msg, + UINT32 Level, + UINT32 Component); + +void +AcpiNsPrintPathname ( + UINT32 NumSegments, + char *Pathname); + +ACPI_STATUS +AcpiNsDumpOneObject ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue); + +void +AcpiNsDumpObjects ( + ACPI_OBJECT_TYPE Type, + UINT8 DisplayType, + UINT32 MaxDepth, + ACPI_OWNER_ID OwnerId, + ACPI_HANDLE StartHandle); + + +/* + * nseval - Namespace evaluation functions + */ +ACPI_STATUS +AcpiNsEvaluate ( + ACPI_EVALUATE_INFO *Info); + +void +AcpiNsExecModuleCodeList ( + void); + + +/* + * nspredef - Support for predefined/reserved names + */ +ACPI_STATUS +AcpiNsCheckPredefinedNames ( + ACPI_NAMESPACE_NODE *Node, + UINT32 UserParamCount, + ACPI_STATUS ReturnStatus, + ACPI_OPERAND_OBJECT **ReturnObject); + +const ACPI_PREDEFINED_INFO * +AcpiNsCheckForPredefinedName ( + ACPI_NAMESPACE_NODE *Node); + +void +AcpiNsCheckParameterCount ( + char *Pathname, + ACPI_NAMESPACE_NODE *Node, + UINT32 UserParamCount, + const ACPI_PREDEFINED_INFO *Info); + + +/* + * nsnames - Name and Scope manipulation + */ +UINT32 +AcpiNsOpensScope ( + ACPI_OBJECT_TYPE Type); + +ACPI_STATUS +AcpiNsBuildExternalPath ( + ACPI_NAMESPACE_NODE *Node, + ACPI_SIZE Size, + char *NameBuffer); + +char * +AcpiNsGetExternalPathname ( + ACPI_NAMESPACE_NODE *Node); + +char * +AcpiNsNameOfCurrentScope ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiNsHandleToPathname ( + ACPI_HANDLE TargetHandle, + ACPI_BUFFER *Buffer); + +BOOLEAN +AcpiNsPatternMatch ( + ACPI_NAMESPACE_NODE *ObjNode, + char *SearchFor); + +ACPI_STATUS +AcpiNsGetNode ( + ACPI_NAMESPACE_NODE *PrefixNode, + const char *ExternalPathname, + UINT32 Flags, + ACPI_NAMESPACE_NODE **OutNode); + +ACPI_SIZE +AcpiNsGetPathnameLength ( + ACPI_NAMESPACE_NODE *Node); + + +/* + * nsobject - Object management for namespace nodes + */ +ACPI_STATUS +AcpiNsAttachObject ( + ACPI_NAMESPACE_NODE *Node, + ACPI_OPERAND_OBJECT *Object, + ACPI_OBJECT_TYPE Type); + +ACPI_OPERAND_OBJECT * +AcpiNsGetAttachedObject ( + ACPI_NAMESPACE_NODE *Node); + +ACPI_OPERAND_OBJECT * +AcpiNsGetSecondaryObject ( + ACPI_OPERAND_OBJECT *ObjDesc); + +ACPI_STATUS +AcpiNsAttachData ( + ACPI_NAMESPACE_NODE *Node, + ACPI_OBJECT_HANDLER Handler, + void *Data); + +ACPI_STATUS +AcpiNsDetachData ( + ACPI_NAMESPACE_NODE *Node, + ACPI_OBJECT_HANDLER Handler); + +ACPI_STATUS +AcpiNsGetAttachedData ( + ACPI_NAMESPACE_NODE *Node, + ACPI_OBJECT_HANDLER Handler, + void **Data); + + +/* + * 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); + + +/* + * 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); + +void +AcpiNsRemoveNullElements ( + ACPI_PREDEFINED_DATA *Data, + UINT8 PackageType, + ACPI_OPERAND_OBJECT *ObjDesc); + +/* + * nssearch - Namespace searching and entry + */ +ACPI_STATUS +AcpiNsSearchAndEnter ( + UINT32 EntryName, + ACPI_WALK_STATE *WalkState, + ACPI_NAMESPACE_NODE *Node, + ACPI_INTERPRETER_MODE InterpreterMode, + ACPI_OBJECT_TYPE Type, + UINT32 Flags, + ACPI_NAMESPACE_NODE **RetNode); + +ACPI_STATUS +AcpiNsSearchOneScope ( + UINT32 EntryName, + ACPI_NAMESPACE_NODE *Node, + ACPI_OBJECT_TYPE Type, + ACPI_NAMESPACE_NODE **RetNode); + +void +AcpiNsInstallNode ( + ACPI_WALK_STATE *WalkState, + ACPI_NAMESPACE_NODE *ParentNode, + ACPI_NAMESPACE_NODE *Node, + ACPI_OBJECT_TYPE Type); + + +/* + * nsutils - Utility functions + */ +BOOLEAN +AcpiNsValidRootPrefix ( + char Prefix); + +ACPI_OBJECT_TYPE +AcpiNsGetType ( + ACPI_NAMESPACE_NODE *Node); + +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, + const char *Msg); + +ACPI_STATUS +AcpiNsBuildInternalName ( + ACPI_NAMESTRING_INFO *Info); + +void +AcpiNsGetInternalNameLength ( + ACPI_NAMESTRING_INFO *Info); + +ACPI_STATUS +AcpiNsInternalizeName ( + const char *DottedName, + char **ConvertedName); + +ACPI_STATUS +AcpiNsExternalizeName ( + UINT32 InternalNameLength, + const char *InternalName, + UINT32 *ConvertedNameLength, + char **ConvertedName); + +ACPI_NAMESPACE_NODE * +AcpiNsValidateHandle ( + ACPI_HANDLE Handle); + +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/reactos/drivers/bus/acpi/acpica/include/acobject.h b/reactos/drivers/bus/acpi/acpica/include/acobject.h new file mode 100644 index 00000000000..76f623c83db --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/acobject.h @@ -0,0 +1,648 @@ + +/****************************************************************************** + * + * Name: acobject.h - Definition of ACPI_OPERAND_OBJECT (Internal object only) + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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. + * + *****************************************************************************/ + +#ifndef _ACOBJECT_H +#define _ACOBJECT_H + +/* acpisrc:StructDefs -- for acpisrc conversion */ + + +/* + * The ACPI_OPERAND_OBJECT is used to pass AML operands from the dispatcher + * to the interpreter, and to keep track of the various handlers such as + * address space handlers and notify handlers. The object is a constant + * size in order to allow it to be cached and reused. + * + * Note: The object is optimized to be aligned and will not work if it is + * byte-packed. + */ +#if ACPI_MACHINE_WIDTH == 64 +#pragma pack(8) +#else +#pragma pack(4) +#endif + +/******************************************************************************* + * + * Common Descriptors + * + ******************************************************************************/ + +/* + * Common area for all objects. + * + * DescriptorType is used to differentiate between internal descriptors, and + * must be in the same place across all descriptors + * + * Note: The DescriptorType and Type fields must appear in the identical + * position in both the ACPI_NAMESPACE_NODE and ACPI_OPERAND_OBJECT + * structures. + */ +#define ACPI_OBJECT_COMMON_HEADER \ + union acpi_operand_object *NextObject; /* Objects linked to parent NS node */\ + UINT8 DescriptorType; /* To differentiate various internal objs */\ + UINT8 Type; /* ACPI_OBJECT_TYPE */\ + UINT16 ReferenceCount; /* For object deletion management */\ + UINT8 Flags; + /* + * Note: There are 3 bytes available here before the + * next natural alignment boundary (for both 32/64 cases) + */ + +/* 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_MODULE_LEVEL 0x40 + + +/****************************************************************************** + * + * Basic data types + * + *****************************************************************************/ + +typedef struct acpi_object_common +{ + ACPI_OBJECT_COMMON_HEADER + +} ACPI_OBJECT_COMMON; + + +typedef struct acpi_object_integer +{ + ACPI_OBJECT_COMMON_HEADER + UINT8 Fill[3]; /* Prevent warning on some compilers */ + ACPI_INTEGER Value; + +} ACPI_OBJECT_INTEGER; + + +/* + * Note: The String and Buffer object must be identical through the Pointer + * and length elements. There is code that depends on this. + * + * Fields common to both Strings and Buffers + */ +#define ACPI_COMMON_BUFFER_INFO(_Type) \ + _Type *Pointer; \ + UINT32 Length; + + +typedef struct acpi_object_string /* Null terminated, ASCII characters only */ +{ + ACPI_OBJECT_COMMON_HEADER + ACPI_COMMON_BUFFER_INFO (char) /* String in AML stream or allocated string */ + +} ACPI_OBJECT_STRING; + + +typedef struct acpi_object_buffer +{ + ACPI_OBJECT_COMMON_HEADER + ACPI_COMMON_BUFFER_INFO (UINT8) /* Buffer in AML stream or allocated buffer */ + UINT32 AmlLength; + UINT8 *AmlStart; + ACPI_NAMESPACE_NODE *Node; /* Link back to parent node */ + +} ACPI_OBJECT_BUFFER; + + +typedef struct acpi_object_package +{ + ACPI_OBJECT_COMMON_HEADER + ACPI_NAMESPACE_NODE *Node; /* Link back to parent node */ + union acpi_operand_object **Elements; /* Array of pointers to AcpiObjects */ + UINT8 *AmlStart; + UINT32 AmlLength; + UINT32 Count; /* # of elements in package */ + +} ACPI_OBJECT_PACKAGE; + + +/****************************************************************************** + * + * Complex data types + * + *****************************************************************************/ + +typedef struct acpi_object_event +{ + ACPI_OBJECT_COMMON_HEADER + ACPI_SEMAPHORE OsSemaphore; /* Actual OS synchronization object */ + +} ACPI_OBJECT_EVENT; + + +typedef struct acpi_object_mutex +{ + ACPI_OBJECT_COMMON_HEADER + UINT8 SyncLevel; /* 0-15, specified in Mutex() call */ + UINT16 AcquisitionDepth; /* Allow multiple Acquires, same thread */ + ACPI_MUTEX OsMutex; /* Actual OS synchronization object */ + ACPI_THREAD_ID ThreadId; /* Current owner of the mutex */ + struct acpi_thread_state *OwnerThread; /* Current owner of the mutex */ + union acpi_operand_object *Prev; /* Link for list of acquired mutexes */ + union acpi_operand_object *Next; /* Link for list of acquired mutexes */ + ACPI_NAMESPACE_NODE *Node; /* Containing namespace node */ + UINT8 OriginalSyncLevel; /* Owner's original sync level (0-15) */ + +} ACPI_OBJECT_MUTEX; + + +typedef struct acpi_object_region +{ + ACPI_OBJECT_COMMON_HEADER + UINT8 SpaceId; + ACPI_NAMESPACE_NODE *Node; /* Containing namespace node */ + union acpi_operand_object *Handler; /* Handler for region access */ + union acpi_operand_object *Next; + ACPI_PHYSICAL_ADDRESS Address; + UINT32 Length; + +} ACPI_OBJECT_REGION; + + +typedef struct acpi_object_method +{ + ACPI_OBJECT_COMMON_HEADER + UINT8 MethodFlags; + UINT8 ParamCount; + UINT8 SyncLevel; + union acpi_operand_object *Mutex; + UINT8 *AmlStart; + union + { + ACPI_INTERNAL_METHOD Implementation; + union acpi_operand_object *Handler; + } Extra; + + UINT32 AmlLength; + UINT8 ThreadCount; + ACPI_OWNER_ID OwnerId; + +} ACPI_OBJECT_METHOD; + + +/****************************************************************************** + * + * Objects that can be notified. All share a common NotifyInfo area. + * + *****************************************************************************/ + +/* + * Common fields for objects that support ASL notifications + */ +#define ACPI_COMMON_NOTIFY_INFO \ + union acpi_operand_object *SystemNotify; /* Handler for system notifies */\ + union acpi_operand_object *DeviceNotify; /* Handler for driver notifies */\ + union acpi_operand_object *Handler; /* Handler for Address space */ + + +typedef struct acpi_object_notify_common /* COMMON NOTIFY for POWER, PROCESSOR, DEVICE, and THERMAL */ +{ + ACPI_OBJECT_COMMON_HEADER + ACPI_COMMON_NOTIFY_INFO + +} ACPI_OBJECT_NOTIFY_COMMON; + + +typedef struct acpi_object_device +{ + ACPI_OBJECT_COMMON_HEADER + ACPI_COMMON_NOTIFY_INFO + ACPI_GPE_BLOCK_INFO *GpeBlock; + +} ACPI_OBJECT_DEVICE; + + +typedef struct acpi_object_power_resource +{ + ACPI_OBJECT_COMMON_HEADER + ACPI_COMMON_NOTIFY_INFO + UINT32 SystemLevel; + UINT32 ResourceOrder; + +} ACPI_OBJECT_POWER_RESOURCE; + + +typedef struct acpi_object_processor +{ + ACPI_OBJECT_COMMON_HEADER + + /* The next two fields take advantage of the 3-byte space before NOTIFY_INFO */ + + UINT8 ProcId; + UINT8 Length; + ACPI_COMMON_NOTIFY_INFO + ACPI_IO_ADDRESS Address; + +} ACPI_OBJECT_PROCESSOR; + + +typedef struct acpi_object_thermal_zone +{ + ACPI_OBJECT_COMMON_HEADER + ACPI_COMMON_NOTIFY_INFO + +} ACPI_OBJECT_THERMAL_ZONE; + + +/****************************************************************************** + * + * Fields. All share a common header/info field. + * + *****************************************************************************/ + +/* + * Common bitfield for the field objects + * "Field Datum" -- a datum from the actual field object + * "Buffer Datum" -- a datum from a user buffer, read from or to be written to the field + */ +#define ACPI_COMMON_FIELD_INFO \ + UINT8 FieldFlags; /* Access, update, and lock bits */\ + UINT8 Attribute; /* From AccessAs keyword */\ + UINT8 AccessByteWidth; /* Read/Write size in bytes */\ + ACPI_NAMESPACE_NODE *Node; /* Link back to parent node */\ + UINT32 BitLength; /* Length of field in bits */\ + 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) */ +{ + ACPI_OBJECT_COMMON_HEADER + ACPI_COMMON_FIELD_INFO + union acpi_operand_object *RegionObj; /* Parent Operation Region object (REGION/BANK fields only) */ + +} ACPI_OBJECT_FIELD_COMMON; + + +typedef struct acpi_object_region_field +{ + ACPI_OBJECT_COMMON_HEADER + ACPI_COMMON_FIELD_INFO + union acpi_operand_object *RegionObj; /* Containing OpRegion object */ + +} ACPI_OBJECT_REGION_FIELD; + + +typedef struct acpi_object_bank_field +{ + ACPI_OBJECT_COMMON_HEADER + ACPI_COMMON_FIELD_INFO + union acpi_operand_object *RegionObj; /* Containing OpRegion object */ + union acpi_operand_object *BankObj; /* BankSelect Register object */ + +} ACPI_OBJECT_BANK_FIELD; + + +typedef struct acpi_object_index_field +{ + ACPI_OBJECT_COMMON_HEADER + ACPI_COMMON_FIELD_INFO + + /* + * No "RegionObj" pointer needed since the Index and Data registers + * are each field definitions unto themselves. + */ + union acpi_operand_object *IndexObj; /* Index register */ + union acpi_operand_object *DataObj; /* Data register */ + +} ACPI_OBJECT_INDEX_FIELD; + + +/* The BufferField is different in that it is part of a Buffer, not an OpRegion */ + +typedef struct acpi_object_buffer_field +{ + ACPI_OBJECT_COMMON_HEADER + ACPI_COMMON_FIELD_INFO + union acpi_operand_object *BufferObj; /* Containing Buffer object */ + +} ACPI_OBJECT_BUFFER_FIELD; + + +/****************************************************************************** + * + * Objects for handlers + * + *****************************************************************************/ + +typedef struct acpi_object_notify_handler +{ + ACPI_OBJECT_COMMON_HEADER + ACPI_NAMESPACE_NODE *Node; /* Parent device */ + ACPI_NOTIFY_HANDLER Handler; + void *Context; + +} ACPI_OBJECT_NOTIFY_HANDLER; + + +typedef struct acpi_object_addr_handler +{ + ACPI_OBJECT_COMMON_HEADER + UINT8 SpaceId; + UINT8 HandlerFlags; + ACPI_ADR_SPACE_HANDLER Handler; + ACPI_NAMESPACE_NODE *Node; /* Parent device */ + void *Context; + ACPI_ADR_SPACE_SETUP Setup; + union acpi_operand_object *RegionList; /* regions using this handler */ + union acpi_operand_object *Next; + +} ACPI_OBJECT_ADDR_HANDLER; + +/* Flags for address handler (HandlerFlags) */ + +#define ACPI_ADDR_HANDLER_DEFAULT_INSTALLED 0x01 + + +/****************************************************************************** + * + * Special internal objects + * + *****************************************************************************/ + +/* + * The Reference object is used for these opcodes: + * Arg[0-6], Local[0-7], IndexOp, NameOp, RefOfOp, LoadOp, LoadTableOp, DebugOp + * The Reference.Class differentiates these types. + */ +typedef struct acpi_object_reference +{ + ACPI_OBJECT_COMMON_HEADER + UINT8 Class; /* Reference Class */ + UINT8 TargetType; /* Used for Index Op */ + UINT8 Reserved; + void *Object; /* NameOp=>HANDLE to obj, IndexOp=>ACPI_OPERAND_OBJECT */ + ACPI_NAMESPACE_NODE *Node; /* RefOf or Namepath */ + union acpi_operand_object **Where; /* Target of Index */ + UINT32 Value; /* Used for Local/Arg/Index/DdbHandle */ + +} ACPI_OBJECT_REFERENCE; + +/* Values for Reference.Class above */ + +typedef enum +{ + ACPI_REFCLASS_LOCAL = 0, /* Method local */ + ACPI_REFCLASS_ARG = 1, /* Method argument */ + ACPI_REFCLASS_REFOF = 2, /* Result of RefOf() TBD: Split to Ref/Node and Ref/OperandObj? */ + ACPI_REFCLASS_INDEX = 3, /* Result of Index() */ + ACPI_REFCLASS_TABLE = 4, /* DdbHandle - Load(), LoadTable() */ + ACPI_REFCLASS_NAME = 5, /* Reference to a named object */ + ACPI_REFCLASS_DEBUG = 6, /* Debug object */ + + ACPI_REFCLASS_MAX = 6 + +} ACPI_REFERENCE_CLASSES; + + +/* + * Extra object is used as additional storage for types that + * have AML code in their declarations (TermArgs) that must be + * evaluated at run time. + * + * Currently: Region and FieldUnit types + */ +typedef struct acpi_object_extra +{ + ACPI_OBJECT_COMMON_HEADER + ACPI_NAMESPACE_NODE *Method_REG; /* _REG method for this region (if any) */ + void *RegionContext; /* Region-specific data */ + UINT8 *AmlStart; + UINT32 AmlLength; + +} ACPI_OBJECT_EXTRA; + + +/* Additional data that can be attached to namespace nodes */ + +typedef struct acpi_object_data +{ + ACPI_OBJECT_COMMON_HEADER + ACPI_OBJECT_HANDLER Handler; + void *Pointer; + +} ACPI_OBJECT_DATA; + + +/* Structure used when objects are cached for reuse */ + +typedef struct acpi_object_cache_list +{ + ACPI_OBJECT_COMMON_HEADER + union acpi_operand_object *Next; /* Link for object cache and internal lists*/ + +} ACPI_OBJECT_CACHE_LIST; + + +/****************************************************************************** + * + * ACPI_OPERAND_OBJECT Descriptor - a giant union of all of the above + * + *****************************************************************************/ + +typedef union acpi_operand_object +{ + ACPI_OBJECT_COMMON Common; + ACPI_OBJECT_INTEGER Integer; + ACPI_OBJECT_STRING String; + ACPI_OBJECT_BUFFER Buffer; + ACPI_OBJECT_PACKAGE Package; + ACPI_OBJECT_EVENT Event; + ACPI_OBJECT_METHOD Method; + ACPI_OBJECT_MUTEX Mutex; + ACPI_OBJECT_REGION Region; + ACPI_OBJECT_NOTIFY_COMMON CommonNotify; + ACPI_OBJECT_DEVICE Device; + ACPI_OBJECT_POWER_RESOURCE PowerResource; + ACPI_OBJECT_PROCESSOR Processor; + ACPI_OBJECT_THERMAL_ZONE ThermalZone; + ACPI_OBJECT_FIELD_COMMON CommonField; + ACPI_OBJECT_REGION_FIELD Field; + ACPI_OBJECT_BUFFER_FIELD BufferField; + ACPI_OBJECT_BANK_FIELD BankField; + ACPI_OBJECT_INDEX_FIELD IndexField; + ACPI_OBJECT_NOTIFY_HANDLER Notify; + ACPI_OBJECT_ADDR_HANDLER AddressSpace; + ACPI_OBJECT_REFERENCE Reference; + ACPI_OBJECT_EXTRA Extra; + ACPI_OBJECT_DATA Data; + ACPI_OBJECT_CACHE_LIST Cache; + + /* + * Add namespace node to union in order to simplify code that accepts both + * ACPI_OPERAND_OBJECTs and ACPI_NAMESPACE_NODEs. The structures share + * a common DescriptorType field in order to differentiate them. + */ + ACPI_NAMESPACE_NODE Node; + +} ACPI_OPERAND_OBJECT; + + +/****************************************************************************** + * + * ACPI_DESCRIPTOR - objects that share a common descriptor identifier + * + *****************************************************************************/ + +/* Object descriptor types */ + +#define ACPI_DESC_TYPE_CACHED 0x01 /* Used only when object is cached */ +#define ACPI_DESC_TYPE_STATE 0x02 +#define ACPI_DESC_TYPE_STATE_UPDATE 0x03 +#define ACPI_DESC_TYPE_STATE_PACKAGE 0x04 +#define ACPI_DESC_TYPE_STATE_CONTROL 0x05 +#define ACPI_DESC_TYPE_STATE_RPSCOPE 0x06 +#define ACPI_DESC_TYPE_STATE_PSCOPE 0x07 +#define ACPI_DESC_TYPE_STATE_WSCOPE 0x08 +#define ACPI_DESC_TYPE_STATE_RESULT 0x09 +#define ACPI_DESC_TYPE_STATE_NOTIFY 0x0A +#define ACPI_DESC_TYPE_STATE_THREAD 0x0B +#define ACPI_DESC_TYPE_WALK 0x0C +#define ACPI_DESC_TYPE_PARSER 0x0D +#define ACPI_DESC_TYPE_OPERAND 0x0E +#define ACPI_DESC_TYPE_NAMED 0x0F +#define ACPI_DESC_TYPE_MAX 0x0F + + +typedef struct acpi_common_descriptor +{ + void *CommonPointer; + UINT8 DescriptorType; /* To differentiate various internal objs */ + +} ACPI_COMMON_DESCRIPTOR; + +typedef union acpi_descriptor +{ + ACPI_COMMON_DESCRIPTOR Common; + ACPI_OPERAND_OBJECT Object; + ACPI_NAMESPACE_NODE Node; + ACPI_PARSE_OBJECT Op; + +} ACPI_DESCRIPTOR; + +#pragma pack() + +#endif /* _ACOBJECT_H */ diff --git a/reactos/drivers/bus/acpi/acpica/include/acopcode.h b/reactos/drivers/bus/acpi/acpica/include/acopcode.h new file mode 100644 index 00000000000..bb309c78d3f --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/acopcode.h @@ -0,0 +1,397 @@ +/****************************************************************************** + * + * Name: acopcode.h - AML opcode information for the AML parser and interpreter + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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. + * + *****************************************************************************/ + +#ifndef __ACOPCODE_H__ +#define __ACOPCODE_H__ + +#define MAX_EXTENDED_OPCODE 0x88 +#define NUM_EXTENDED_OPCODE (MAX_EXTENDED_OPCODE + 1) +#define MAX_INTERNAL_OPCODE +#define NUM_INTERNAL_OPCODE (MAX_INTERNAL_OPCODE + 1) + +/* Used for non-assigned opcodes */ + +#define _UNK 0x6B + +/* + * Reserved ASCII characters. Do not use any of these for + * internal opcodes, since they are used to differentiate + * name strings from AML opcodes + */ +#define _ASC 0x6C +#define _NAM 0x6C +#define _PFX 0x6D + + +/* + * All AML opcodes and the parse-time arguments for each. Used by the AML + * parser Each list is compressed into a 32-bit number and stored in the + * master opcode table (in psopcode.c). + */ +#define ARGP_ACCESSFIELD_OP ARGP_LIST1 (ARGP_NAMESTRING) +#define ARGP_ACQUIRE_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_WORDDATA) +#define ARGP_ADD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_ALIAS_OP ARGP_LIST2 (ARGP_NAMESTRING, ARGP_NAME) +#define ARGP_ARG0 ARG_NONE +#define ARGP_ARG1 ARG_NONE +#define ARGP_ARG2 ARG_NONE +#define ARGP_ARG3 ARG_NONE +#define ARGP_ARG4 ARG_NONE +#define ARGP_ARG5 ARG_NONE +#define ARGP_ARG6 ARG_NONE +#define ARGP_BANK_FIELD_OP ARGP_LIST6 (ARGP_PKGLENGTH, ARGP_NAMESTRING, ARGP_NAMESTRING,ARGP_TERMARG, ARGP_BYTEDATA, ARGP_FIELDLIST) +#define ARGP_BIT_AND_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_BIT_NAND_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_BIT_NOR_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_BIT_NOT_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) +#define ARGP_BIT_OR_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_BIT_XOR_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_BREAK_OP ARG_NONE +#define ARGP_BREAK_POINT_OP ARG_NONE +#define ARGP_BUFFER_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_BYTELIST) +#define ARGP_BYTE_OP ARGP_LIST1 (ARGP_BYTEDATA) +#define ARGP_BYTELIST_OP ARGP_LIST1 (ARGP_NAMESTRING) +#define ARGP_CONCAT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_CONCAT_RES_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_COND_REF_OF_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_SUPERNAME) +#define ARGP_CONTINUE_OP ARG_NONE +#define ARGP_COPY_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_SIMPLENAME) +#define ARGP_CREATE_BIT_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) +#define ARGP_CREATE_BYTE_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) +#define ARGP_CREATE_DWORD_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) +#define ARGP_CREATE_FIELD_OP ARGP_LIST4 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) +#define ARGP_CREATE_QWORD_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) +#define ARGP_CREATE_WORD_FIELD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_NAME) +#define ARGP_DATA_REGION_OP ARGP_LIST4 (ARGP_NAME, ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_DEBUG_OP ARG_NONE +#define ARGP_DECREMENT_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_DEREF_OF_OP ARGP_LIST1 (ARGP_TERMARG) +#define ARGP_DEVICE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_OBJLIST) +#define ARGP_DIVIDE_OP ARGP_LIST4 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET, ARGP_TARGET) +#define ARGP_DWORD_OP ARGP_LIST1 (ARGP_DWORDDATA) +#define ARGP_ELSE_OP ARGP_LIST2 (ARGP_PKGLENGTH, ARGP_TERMLIST) +#define ARGP_EVENT_OP ARGP_LIST1 (ARGP_NAME) +#define ARGP_FATAL_OP ARGP_LIST3 (ARGP_BYTEDATA, ARGP_DWORDDATA, ARGP_TERMARG) +#define ARGP_FIELD_OP ARGP_LIST4 (ARGP_PKGLENGTH, ARGP_NAMESTRING, ARGP_BYTEDATA, ARGP_FIELDLIST) +#define ARGP_FIND_SET_LEFT_BIT_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) +#define ARGP_FIND_SET_RIGHT_BIT_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) +#define ARGP_FROM_BCD_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) +#define ARGP_IF_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_TERMLIST) +#define ARGP_INCREMENT_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_INDEX_FIELD_OP ARGP_LIST5 (ARGP_PKGLENGTH, ARGP_NAMESTRING, ARGP_NAMESTRING,ARGP_BYTEDATA, ARGP_FIELDLIST) +#define ARGP_INDEX_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_LAND_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_LEQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_LGREATER_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_LGREATEREQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_LLESS_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_LLESSEQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_LNOT_OP ARGP_LIST1 (ARGP_TERMARG) +#define ARGP_LNOTEQUAL_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_LOAD_OP ARGP_LIST2 (ARGP_NAMESTRING, ARGP_SUPERNAME) +#define ARGP_LOAD_TABLE_OP ARGP_LIST6 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_LOCAL0 ARG_NONE +#define ARGP_LOCAL1 ARG_NONE +#define ARGP_LOCAL2 ARG_NONE +#define ARGP_LOCAL3 ARG_NONE +#define ARGP_LOCAL4 ARG_NONE +#define ARGP_LOCAL5 ARG_NONE +#define ARGP_LOCAL6 ARG_NONE +#define ARGP_LOCAL7 ARG_NONE +#define ARGP_LOR_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_MATCH_OP ARGP_LIST6 (ARGP_TERMARG, ARGP_BYTEDATA, ARGP_TERMARG, ARGP_BYTEDATA, ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_METHOD_OP ARGP_LIST4 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_BYTEDATA, ARGP_TERMLIST) +#define ARGP_METHODCALL_OP ARGP_LIST1 (ARGP_NAMESTRING) +#define ARGP_MID_OP ARGP_LIST4 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_MOD_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_MULTIPLY_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_MUTEX_OP ARGP_LIST2 (ARGP_NAME, ARGP_BYTEDATA) +#define ARGP_NAME_OP ARGP_LIST2 (ARGP_NAME, ARGP_DATAOBJ) +#define ARGP_NAMEDFIELD_OP ARGP_LIST1 (ARGP_NAMESTRING) +#define ARGP_NAMEPATH_OP ARGP_LIST1 (ARGP_NAMESTRING) +#define ARGP_NOOP_OP ARG_NONE +#define ARGP_NOTIFY_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_TERMARG) +#define ARGP_ONE_OP ARG_NONE +#define ARGP_ONES_OP ARG_NONE +#define ARGP_PACKAGE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_BYTEDATA, ARGP_DATAOBJLIST) +#define ARGP_POWER_RES_OP ARGP_LIST5 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_BYTEDATA, ARGP_WORDDATA, ARGP_OBJLIST) +#define ARGP_PROCESSOR_OP ARGP_LIST6 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_BYTEDATA, ARGP_DWORDDATA, ARGP_BYTEDATA, ARGP_OBJLIST) +#define ARGP_QWORD_OP ARGP_LIST1 (ARGP_QWORDDATA) +#define ARGP_REF_OF_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_REGION_OP ARGP_LIST4 (ARGP_NAME, ARGP_BYTEDATA, ARGP_TERMARG, ARGP_TERMARG) +#define ARGP_RELEASE_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_RESERVEDFIELD_OP ARGP_LIST1 (ARGP_NAMESTRING) +#define ARGP_RESET_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_RETURN_OP ARGP_LIST1 (ARGP_TERMARG) +#define ARGP_REVISION_OP ARG_NONE +#define ARGP_SCOPE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_TERMLIST) +#define ARGP_SHIFT_LEFT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_SHIFT_RIGHT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_SIGNAL_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_SIZE_OF_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_SLEEP_OP ARGP_LIST1 (ARGP_TERMARG) +#define ARGP_STALL_OP ARGP_LIST1 (ARGP_TERMARG) +#define ARGP_STATICSTRING_OP ARGP_LIST1 (ARGP_NAMESTRING) +#define ARGP_STORE_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_SUPERNAME) +#define ARGP_STRING_OP ARGP_LIST1 (ARGP_CHARLIST) +#define ARGP_SUBTRACT_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_THERMAL_ZONE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_NAME, ARGP_OBJLIST) +#define ARGP_TIMER_OP ARG_NONE +#define ARGP_TO_BCD_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) +#define ARGP_TO_BUFFER_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) +#define ARGP_TO_DEC_STR_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) +#define ARGP_TO_HEX_STR_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) +#define ARGP_TO_INTEGER_OP ARGP_LIST2 (ARGP_TERMARG, ARGP_TARGET) +#define ARGP_TO_STRING_OP ARGP_LIST3 (ARGP_TERMARG, ARGP_TERMARG, ARGP_TARGET) +#define ARGP_TYPE_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_UNLOAD_OP ARGP_LIST1 (ARGP_SUPERNAME) +#define ARGP_VAR_PACKAGE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_DATAOBJLIST) +#define ARGP_WAIT_OP ARGP_LIST2 (ARGP_SUPERNAME, ARGP_TERMARG) +#define ARGP_WHILE_OP ARGP_LIST3 (ARGP_PKGLENGTH, ARGP_TERMARG, ARGP_TERMLIST) +#define ARGP_WORD_OP ARGP_LIST1 (ARGP_WORDDATA) +#define ARGP_ZERO_OP ARG_NONE + + +/* + * All AML opcodes and the runtime arguments for each. Used by the AML + * interpreter Each list is compressed into a 32-bit number and stored + * in the master opcode table (in psopcode.c). + * + * (Used by PrepOperands procedure and the ASL Compiler) + */ +#define ARGI_ACCESSFIELD_OP ARGI_INVALID_OPCODE +#define ARGI_ACQUIRE_OP ARGI_LIST2 (ARGI_MUTEX, ARGI_INTEGER) +#define ARGI_ADD_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_ALIAS_OP ARGI_INVALID_OPCODE +#define ARGI_ARG0 ARG_NONE +#define ARGI_ARG1 ARG_NONE +#define ARGI_ARG2 ARG_NONE +#define ARGI_ARG3 ARG_NONE +#define ARGI_ARG4 ARG_NONE +#define ARGI_ARG5 ARG_NONE +#define ARGI_ARG6 ARG_NONE +#define ARGI_BANK_FIELD_OP ARGI_INVALID_OPCODE +#define ARGI_BIT_AND_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_BIT_NAND_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_BIT_NOR_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_BIT_NOT_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_BIT_OR_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_BIT_XOR_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_BREAK_OP ARG_NONE +#define ARGI_BREAK_POINT_OP ARG_NONE +#define ARGI_BUFFER_OP ARGI_LIST1 (ARGI_INTEGER) +#define ARGI_BYTE_OP ARGI_INVALID_OPCODE +#define ARGI_BYTELIST_OP ARGI_INVALID_OPCODE +#define ARGI_CONCAT_OP ARGI_LIST3 (ARGI_COMPUTEDATA,ARGI_COMPUTEDATA, ARGI_TARGETREF) +#define ARGI_CONCAT_RES_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_BUFFER, ARGI_TARGETREF) +#define ARGI_COND_REF_OF_OP ARGI_LIST2 (ARGI_OBJECT_REF, ARGI_TARGETREF) +#define ARGI_CONTINUE_OP ARGI_INVALID_OPCODE +#define ARGI_COPY_OP ARGI_LIST2 (ARGI_ANYTYPE, ARGI_SIMPLE_TARGET) +#define ARGI_CREATE_BIT_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE) +#define ARGI_CREATE_BYTE_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE) +#define ARGI_CREATE_DWORD_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE) +#define ARGI_CREATE_FIELD_OP ARGI_LIST4 (ARGI_BUFFER, ARGI_INTEGER, ARGI_INTEGER, ARGI_REFERENCE) +#define ARGI_CREATE_QWORD_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE) +#define ARGI_CREATE_WORD_FIELD_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_REFERENCE) +#define ARGI_DATA_REGION_OP ARGI_LIST3 (ARGI_STRING, ARGI_STRING, ARGI_STRING) +#define ARGI_DEBUG_OP ARG_NONE +#define ARGI_DECREMENT_OP ARGI_LIST1 (ARGI_TARGETREF) +#define ARGI_DEREF_OF_OP ARGI_LIST1 (ARGI_REF_OR_STRING) +#define ARGI_DEVICE_OP ARGI_INVALID_OPCODE +#define ARGI_DIVIDE_OP ARGI_LIST4 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF, ARGI_TARGETREF) +#define ARGI_DWORD_OP ARGI_INVALID_OPCODE +#define ARGI_ELSE_OP ARGI_INVALID_OPCODE +#define ARGI_EVENT_OP ARGI_INVALID_OPCODE +#define ARGI_FATAL_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_INTEGER) +#define ARGI_FIELD_OP ARGI_INVALID_OPCODE +#define ARGI_FIND_SET_LEFT_BIT_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_FIND_SET_RIGHT_BIT_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_FROM_BCD_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_FIXED_TARGET) +#define ARGI_IF_OP ARGI_INVALID_OPCODE +#define ARGI_INCREMENT_OP ARGI_LIST1 (ARGI_TARGETREF) +#define ARGI_INDEX_FIELD_OP ARGI_INVALID_OPCODE +#define ARGI_INDEX_OP ARGI_LIST3 (ARGI_COMPLEXOBJ, ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_LAND_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_INTEGER) +#define ARGI_LEQUAL_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_COMPUTEDATA) +#define ARGI_LGREATER_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_COMPUTEDATA) +#define ARGI_LGREATEREQUAL_OP ARGI_INVALID_OPCODE +#define ARGI_LLESS_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_COMPUTEDATA) +#define ARGI_LLESSEQUAL_OP ARGI_INVALID_OPCODE +#define ARGI_LNOT_OP ARGI_LIST1 (ARGI_INTEGER) +#define ARGI_LNOTEQUAL_OP ARGI_INVALID_OPCODE +#define ARGI_LOAD_OP ARGI_LIST2 (ARGI_REGION_OR_BUFFER,ARGI_TARGETREF) +#define ARGI_LOAD_TABLE_OP ARGI_LIST6 (ARGI_STRING, ARGI_STRING, ARGI_STRING, ARGI_STRING, ARGI_STRING, ARGI_ANYTYPE) +#define ARGI_LOCAL0 ARG_NONE +#define ARGI_LOCAL1 ARG_NONE +#define ARGI_LOCAL2 ARG_NONE +#define ARGI_LOCAL3 ARG_NONE +#define ARGI_LOCAL4 ARG_NONE +#define ARGI_LOCAL5 ARG_NONE +#define ARGI_LOCAL6 ARG_NONE +#define ARGI_LOCAL7 ARG_NONE +#define ARGI_LOR_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_INTEGER) +#define ARGI_MATCH_OP ARGI_LIST6 (ARGI_PACKAGE, ARGI_INTEGER, ARGI_COMPUTEDATA, ARGI_INTEGER,ARGI_COMPUTEDATA,ARGI_INTEGER) +#define ARGI_METHOD_OP ARGI_INVALID_OPCODE +#define ARGI_METHODCALL_OP ARGI_INVALID_OPCODE +#define ARGI_MID_OP ARGI_LIST4 (ARGI_BUFFER_OR_STRING,ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_MOD_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_MULTIPLY_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_MUTEX_OP ARGI_INVALID_OPCODE +#define ARGI_NAME_OP ARGI_INVALID_OPCODE +#define ARGI_NAMEDFIELD_OP ARGI_INVALID_OPCODE +#define ARGI_NAMEPATH_OP ARGI_INVALID_OPCODE +#define ARGI_NOOP_OP ARG_NONE +#define ARGI_NOTIFY_OP ARGI_LIST2 (ARGI_DEVICE_REF, ARGI_INTEGER) +#define ARGI_ONE_OP ARG_NONE +#define ARGI_ONES_OP ARG_NONE +#define ARGI_PACKAGE_OP ARGI_LIST1 (ARGI_INTEGER) +#define ARGI_POWER_RES_OP ARGI_INVALID_OPCODE +#define ARGI_PROCESSOR_OP ARGI_INVALID_OPCODE +#define ARGI_QWORD_OP ARGI_INVALID_OPCODE +#define ARGI_REF_OF_OP ARGI_LIST1 (ARGI_OBJECT_REF) +#define ARGI_REGION_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_INTEGER) +#define ARGI_RELEASE_OP ARGI_LIST1 (ARGI_MUTEX) +#define ARGI_RESERVEDFIELD_OP ARGI_INVALID_OPCODE +#define ARGI_RESET_OP ARGI_LIST1 (ARGI_EVENT) +#define ARGI_RETURN_OP ARGI_INVALID_OPCODE +#define ARGI_REVISION_OP ARG_NONE +#define ARGI_SCOPE_OP ARGI_INVALID_OPCODE +#define ARGI_SHIFT_LEFT_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_SHIFT_RIGHT_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_SIGNAL_OP ARGI_LIST1 (ARGI_EVENT) +#define ARGI_SIZE_OF_OP ARGI_LIST1 (ARGI_DATAOBJECT) +#define ARGI_SLEEP_OP ARGI_LIST1 (ARGI_INTEGER) +#define ARGI_STALL_OP ARGI_LIST1 (ARGI_INTEGER) +#define ARGI_STATICSTRING_OP ARGI_INVALID_OPCODE +#define ARGI_STORE_OP ARGI_LIST2 (ARGI_DATAREFOBJ, ARGI_TARGETREF) +#define ARGI_STRING_OP ARGI_INVALID_OPCODE +#define ARGI_SUBTRACT_OP ARGI_LIST3 (ARGI_INTEGER, ARGI_INTEGER, ARGI_TARGETREF) +#define ARGI_THERMAL_ZONE_OP ARGI_INVALID_OPCODE +#define ARGI_TIMER_OP ARG_NONE +#define ARGI_TO_BCD_OP ARGI_LIST2 (ARGI_INTEGER, ARGI_FIXED_TARGET) +#define ARGI_TO_BUFFER_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET) +#define ARGI_TO_DEC_STR_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET) +#define ARGI_TO_HEX_STR_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET) +#define ARGI_TO_INTEGER_OP ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET) +#define ARGI_TO_STRING_OP ARGI_LIST3 (ARGI_BUFFER, ARGI_INTEGER, ARGI_FIXED_TARGET) +#define ARGI_TYPE_OP ARGI_LIST1 (ARGI_ANYTYPE) +#define ARGI_UNLOAD_OP ARGI_LIST1 (ARGI_DDBHANDLE) +#define ARGI_VAR_PACKAGE_OP ARGI_LIST1 (ARGI_INTEGER) +#define ARGI_WAIT_OP ARGI_LIST2 (ARGI_EVENT, ARGI_INTEGER) +#define ARGI_WHILE_OP ARGI_INVALID_OPCODE +#define ARGI_WORD_OP ARGI_INVALID_OPCODE +#define ARGI_ZERO_OP ARG_NONE + +#endif /* __ACOPCODE_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/acoutput.h b/reactos/drivers/bus/acpi/acpica/include/acoutput.h new file mode 100644 index 00000000000..4f4b1d9c69d --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/acoutput.h @@ -0,0 +1,351 @@ +/****************************************************************************** + * + * Name: acoutput.h -- debug output + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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. + * + *****************************************************************************/ + +#ifndef __ACOUTPUT_H__ +#define __ACOUTPUT_H__ + +/* + * Debug levels and component IDs. These are used to control the + * granularity of the output of the ACPI_DEBUG_PRINT macro -- on a + * per-component basis and a per-exception-type basis. + */ + +/* Component IDs are used in the global "DebugLayer" */ + +#define ACPI_UTILITIES 0x00000001 +#define ACPI_HARDWARE 0x00000002 +#define ACPI_EVENTS 0x00000004 +#define ACPI_TABLES 0x00000008 +#define ACPI_NAMESPACE 0x00000010 +#define ACPI_PARSER 0x00000020 +#define ACPI_DISPATCHER 0x00000040 +#define ACPI_EXECUTER 0x00000080 +#define ACPI_RESOURCES 0x00000100 +#define ACPI_CA_DEBUGGER 0x00000200 +#define ACPI_OS_SERVICES 0x00000400 +#define ACPI_CA_DISASSEMBLER 0x00000800 + +/* Component IDs for ACPI tools and utilities */ + +#define ACPI_COMPILER 0x00001000 +#define ACPI_TOOLS 0x00002000 +#define ACPI_EXAMPLE 0x00004000 +#define ACPI_DRIVER 0x00008000 + +#define ACPI_ALL_COMPONENTS 0x0000FFFF +#define ACPI_COMPONENT_DEFAULT (ACPI_ALL_COMPONENTS) + +/* Component IDs reserved for ACPI drivers */ + +#define ACPI_ALL_DRIVERS 0xFFFF0000 + + +/* + * Raw debug output levels, do not use these in the ACPI_DEBUG_PRINT macros + */ +#define ACPI_LV_INIT 0x00000001 +#define ACPI_LV_DEBUG_OBJECT 0x00000002 +#define ACPI_LV_INFO 0x00000004 +#define ACPI_LV_REPAIR 0x00000008 +#define ACPI_LV_ALL_EXCEPTIONS 0x0000000F + +/* Trace verbosity level 1 [Standard Trace Level] */ + +#define ACPI_LV_INIT_NAMES 0x00000020 +#define ACPI_LV_PARSE 0x00000040 +#define ACPI_LV_LOAD 0x00000080 +#define ACPI_LV_DISPATCH 0x00000100 +#define ACPI_LV_EXEC 0x00000200 +#define ACPI_LV_NAMES 0x00000400 +#define ACPI_LV_OPREGION 0x00000800 +#define ACPI_LV_BFIELD 0x00001000 +#define ACPI_LV_TABLES 0x00002000 +#define ACPI_LV_VALUES 0x00004000 +#define ACPI_LV_OBJECTS 0x00008000 +#define ACPI_LV_RESOURCES 0x00010000 +#define ACPI_LV_USER_REQUESTS 0x00020000 +#define ACPI_LV_PACKAGE 0x00040000 +#define ACPI_LV_VERBOSITY1 0x0007FF40 | ACPI_LV_ALL_EXCEPTIONS + +/* Trace verbosity level 2 [Function tracing and memory allocation] */ + +#define ACPI_LV_ALLOCATIONS 0x00100000 +#define ACPI_LV_FUNCTIONS 0x00200000 +#define ACPI_LV_OPTIMIZATIONS 0x00400000 +#define ACPI_LV_VERBOSITY2 0x00700000 | ACPI_LV_VERBOSITY1 +#define ACPI_LV_ALL ACPI_LV_VERBOSITY2 + +/* Trace verbosity level 3 [Threading, I/O, and Interrupts] */ + +#define ACPI_LV_MUTEX 0x01000000 +#define ACPI_LV_THREADS 0x02000000 +#define ACPI_LV_IO 0x04000000 +#define ACPI_LV_INTERRUPTS 0x08000000 +#define ACPI_LV_VERBOSITY3 0x0F000000 | ACPI_LV_VERBOSITY2 + +/* Exceptionally verbose output -- also used in the global "DebugLevel" */ + +#define ACPI_LV_AML_DISASSEMBLE 0x10000000 +#define ACPI_LV_VERBOSE_INFO 0x20000000 +#define ACPI_LV_FULL_TABLES 0x40000000 +#define ACPI_LV_EVENTS 0x80000000 +#define ACPI_LV_VERBOSE 0xF0000000 + + +/* + * Debug level macros that are used in the DEBUG_PRINT macros + */ +#define ACPI_DEBUG_LEVEL(dl) (UINT32) dl,ACPI_DEBUG_PARAMETERS + +/* + * Exception level -- used in the global "DebugLevel" + * + * Note: For errors, use the ACPI_ERROR or ACPI_EXCEPTION interfaces. + * For warnings, use ACPI_WARNING. + */ +#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" */ + +#define ACPI_DB_INIT_NAMES ACPI_DEBUG_LEVEL (ACPI_LV_INIT_NAMES) +#define ACPI_DB_THREADS ACPI_DEBUG_LEVEL (ACPI_LV_THREADS) +#define ACPI_DB_PARSE ACPI_DEBUG_LEVEL (ACPI_LV_PARSE) +#define ACPI_DB_DISPATCH ACPI_DEBUG_LEVEL (ACPI_LV_DISPATCH) +#define ACPI_DB_LOAD ACPI_DEBUG_LEVEL (ACPI_LV_LOAD) +#define ACPI_DB_EXEC ACPI_DEBUG_LEVEL (ACPI_LV_EXEC) +#define ACPI_DB_NAMES ACPI_DEBUG_LEVEL (ACPI_LV_NAMES) +#define ACPI_DB_OPREGION ACPI_DEBUG_LEVEL (ACPI_LV_OPREGION) +#define ACPI_DB_BFIELD ACPI_DEBUG_LEVEL (ACPI_LV_BFIELD) +#define ACPI_DB_TABLES ACPI_DEBUG_LEVEL (ACPI_LV_TABLES) +#define ACPI_DB_FUNCTIONS ACPI_DEBUG_LEVEL (ACPI_LV_FUNCTIONS) +#define ACPI_DB_OPTIMIZATIONS ACPI_DEBUG_LEVEL (ACPI_LV_OPTIMIZATIONS) +#define ACPI_DB_VALUES ACPI_DEBUG_LEVEL (ACPI_LV_VALUES) +#define ACPI_DB_OBJECTS ACPI_DEBUG_LEVEL (ACPI_LV_OBJECTS) +#define ACPI_DB_ALLOCATIONS ACPI_DEBUG_LEVEL (ACPI_LV_ALLOCATIONS) +#define ACPI_DB_RESOURCES ACPI_DEBUG_LEVEL (ACPI_LV_RESOURCES) +#define ACPI_DB_IO ACPI_DEBUG_LEVEL (ACPI_LV_IO) +#define ACPI_DB_INTERRUPTS ACPI_DEBUG_LEVEL (ACPI_LV_INTERRUPTS) +#define ACPI_DB_USER_REQUESTS ACPI_DEBUG_LEVEL (ACPI_LV_USER_REQUESTS) +#define ACPI_DB_PACKAGE ACPI_DEBUG_LEVEL (ACPI_LV_PACKAGE) +#define ACPI_DB_MUTEX ACPI_DEBUG_LEVEL (ACPI_LV_MUTEX) +#define ACPI_DB_EVENTS ACPI_DEBUG_LEVEL (ACPI_LV_EVENTS) + +#define ACPI_DB_ALL ACPI_DEBUG_LEVEL (ACPI_LV_ALL) + +/* Defaults for DebugLevel, debug and normal */ + +#define ACPI_DEBUG_DEFAULT (ACPI_LV_INIT | ACPI_LV_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 + */ +#define ACPI_MODULE_NAME(Name) static const char ACPI_UNUSED_VAR _AcpiModuleName[] = Name; +#else +#define ACPI_MODULE_NAME(Name) +#endif + +/* + * Ascii error messages can be configured out + */ +#ifndef ACPI_NO_ERROR_MESSAGES +#define AE_INFO _AcpiModuleName, __LINE__ + +/* + * Error reporting. Callers module and line number are inserted by AE_INFO, + * 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_INFO(plist) AcpiInfo plist +#define ACPI_WARNING(plist) AcpiWarning plist +#define ACPI_EXCEPTION(plist) AcpiException plist +#define ACPI_ERROR(plist) AcpiError plist + +#else + +/* No error messages */ + +#define ACPI_INFO(plist) +#define ACPI_WARNING(plist) +#define ACPI_EXCEPTION(plist) +#define ACPI_ERROR(plist) + +#endif /* ACPI_NO_ERROR_MESSAGES */ + + +/* + * Debug macros that are conditionally compiled + */ +#ifdef ACPI_DEBUG_OUTPUT + +/* + * If ACPI_GET_FUNCTION_NAME was not defined in the compiler-dependent header, + * define it now. This is the case where there the compiler does not support + * a __FUNCTION__ macro or equivalent. + */ +#ifndef ACPI_GET_FUNCTION_NAME +#define ACPI_GET_FUNCTION_NAME _AcpiFunctionName + +/* + * The Name parameter should be the procedure name as a quoted string. + * The function name is also used by the function exit macros below. + * Note: (const char) is used to be compatible with the debug interfaces + * and macros such as __FUNCTION__. + */ +#define ACPI_FUNCTION_NAME(Name) static const char _AcpiFunctionName[] = #Name; + +#else +/* Compiler supports __FUNCTION__ (or equivalent) -- Ignore this macro */ + +#define ACPI_FUNCTION_NAME(Name) +#endif /* ACPI_GET_FUNCTION_NAME */ + +/* + * Common parameters used for debug output functions: + * line number, function name, module(file) name, component ID + */ +#define ACPI_DEBUG_PARAMETERS __LINE__, ACPI_GET_FUNCTION_NAME, _AcpiModuleName, _COMPONENT + +/* + * Master debug print macros + * Print message if and only if: + * 1) Debug print for the current component is enabled + * 2) Debug error level or trace level for the print statement is enabled + */ +#define ACPI_DEBUG_PRINT(plist) AcpiDebugPrint plist +#define ACPI_DEBUG_PRINT_RAW(plist) AcpiDebugPrintRaw plist + +#else +/* + * This is the non-debug case -- make everything go away, + * leaving no executable debug code! + */ +#define ACPI_FUNCTION_NAME(a) +#define ACPI_DEBUG_PRINT(pl) +#define ACPI_DEBUG_PRINT_RAW(pl) + +#endif /* ACPI_DEBUG_OUTPUT */ + + +#endif /* __ACOUTPUT_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/acparser.h b/reactos/drivers/bus/acpi/acpica/include/acparser.h new file mode 100644 index 00000000000..086688e3224 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/acparser.h @@ -0,0 +1,403 @@ +/****************************************************************************** + * + * Module Name: acparser.h - AML Parser subcomponent prototypes and defines + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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. + * + *****************************************************************************/ + + +#ifndef __ACPARSER_H__ +#define __ACPARSER_H__ + + +#define OP_HAS_RETURN_VALUE 1 + +/* Variable number of arguments. This field must be 32 bits */ + +#define ACPI_VAR_ARGS ACPI_UINT32_MAX + + +#define ACPI_PARSE_DELETE_TREE 0x0001 +#define ACPI_PARSE_NO_TREE_DELETE 0x0000 +#define ACPI_PARSE_TREE_MASK 0x0001 + +#define ACPI_PARSE_LOAD_PASS1 0x0010 +#define ACPI_PARSE_LOAD_PASS2 0x0020 +#define ACPI_PARSE_EXECUTE 0x0030 +#define ACPI_PARSE_MODE_MASK 0x0030 + +#define ACPI_PARSE_DEFERRED_OP 0x0100 +#define ACPI_PARSE_DISASSEMBLE 0x0200 + +#define ACPI_PARSE_MODULE_LEVEL 0x0400 + +/****************************************************************************** + * + * Parser interfaces + * + *****************************************************************************/ + + +/* + * psxface - Parser external interfaces + */ +ACPI_STATUS +AcpiPsExecuteMethod ( + ACPI_EVALUATE_INFO *Info); + + +/* + * psargs - Parse AML opcode arguments + */ +UINT8 * +AcpiPsGetNextPackageEnd ( + ACPI_PARSE_STATE *ParserState); + +char * +AcpiPsGetNextNamestring ( + ACPI_PARSE_STATE *ParserState); + +void +AcpiPsGetNextSimpleArg ( + ACPI_PARSE_STATE *ParserState, + UINT32 ArgType, + ACPI_PARSE_OBJECT *Arg); + +ACPI_STATUS +AcpiPsGetNextNamepath ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_STATE *ParserState, + ACPI_PARSE_OBJECT *Arg, + BOOLEAN MethodCall); + +ACPI_STATUS +AcpiPsGetNextArg ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_STATE *ParserState, + UINT32 ArgType, + ACPI_PARSE_OBJECT **ReturnArg); + + +/* + * psfind + */ +ACPI_PARSE_OBJECT * +AcpiPsFindName ( + ACPI_PARSE_OBJECT *Scope, + UINT32 Name, + UINT32 Opcode); + +ACPI_PARSE_OBJECT* +AcpiPsGetParent ( + ACPI_PARSE_OBJECT *Op); + + +/* + * psopcode - AML Opcode information + */ +const ACPI_OPCODE_INFO * +AcpiPsGetOpcodeInfo ( + UINT16 Opcode); + +char * +AcpiPsGetOpcodeName ( + UINT16 Opcode); + +UINT8 +AcpiPsGetArgumentCount ( + UINT32 OpType); + + +/* + * psparse - top level parsing routines + */ +ACPI_STATUS +AcpiPsParseAml ( + ACPI_WALK_STATE *WalkState); + +UINT32 +AcpiPsGetOpcodeSize ( + UINT32 Opcode); + +UINT16 +AcpiPsPeekOpcode ( + ACPI_PARSE_STATE *state); + +ACPI_STATUS +AcpiPsCompleteThisOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op); + +ACPI_STATUS +AcpiPsNextParseState ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + ACPI_STATUS CallbackStatus); + + +/* + * psloop - main parse loop + */ +ACPI_STATUS +AcpiPsParseLoop ( + ACPI_WALK_STATE *WalkState); + + +/* + * psscope - Scope stack management routines + */ +ACPI_STATUS +AcpiPsInitScope ( + ACPI_PARSE_STATE *ParserState, + ACPI_PARSE_OBJECT *Root); + +ACPI_PARSE_OBJECT * +AcpiPsGetParentScope ( + ACPI_PARSE_STATE *state); + +BOOLEAN +AcpiPsHasCompletedScope ( + ACPI_PARSE_STATE *ParserState); + +void +AcpiPsPopScope ( + ACPI_PARSE_STATE *ParserState, + ACPI_PARSE_OBJECT **Op, + UINT32 *ArgList, + UINT32 *ArgCount); + +ACPI_STATUS +AcpiPsPushScope ( + ACPI_PARSE_STATE *ParserState, + ACPI_PARSE_OBJECT *Op, + UINT32 RemainingArgs, + UINT32 ArgCount); + +void +AcpiPsCleanupScope ( + ACPI_PARSE_STATE *state); + + +/* + * pstree - parse tree manipulation routines + */ +void +AcpiPsAppendArg( + ACPI_PARSE_OBJECT *op, + ACPI_PARSE_OBJECT *arg); + +ACPI_PARSE_OBJECT* +AcpiPsFind ( + ACPI_PARSE_OBJECT *Scope, + char *Path, + UINT16 Opcode, + UINT32 Create); + +ACPI_PARSE_OBJECT * +AcpiPsGetArg( + ACPI_PARSE_OBJECT *op, + UINT32 argn); + +ACPI_PARSE_OBJECT * +AcpiPsGetDepthNext ( + ACPI_PARSE_OBJECT *Origin, + ACPI_PARSE_OBJECT *Op); + + +/* + * pswalk - parse tree walk routines + */ +ACPI_STATUS +AcpiPsWalkParsedAml ( + ACPI_PARSE_OBJECT *StartOp, + ACPI_PARSE_OBJECT *EndOp, + ACPI_OPERAND_OBJECT *MthDesc, + ACPI_NAMESPACE_NODE *StartNode, + ACPI_OPERAND_OBJECT **Params, + ACPI_OPERAND_OBJECT **CallerReturnDesc, + ACPI_OWNER_ID OwnerId, + ACPI_PARSE_DOWNWARDS DescendingCallback, + ACPI_PARSE_UPWARDS AscendingCallback); + +ACPI_STATUS +AcpiPsGetNextWalkOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + ACPI_PARSE_UPWARDS AscendingCallback); + +ACPI_STATUS +AcpiPsDeleteCompletedOp ( + ACPI_WALK_STATE *WalkState); + +void +AcpiPsDeleteParseTree ( + ACPI_PARSE_OBJECT *root); + + +/* + * psutils - parser utilities + */ +ACPI_PARSE_OBJECT * +AcpiPsCreateScopeOp ( + void); + +void +AcpiPsInitOp ( + ACPI_PARSE_OBJECT *op, + UINT16 opcode); + +ACPI_PARSE_OBJECT * +AcpiPsAllocOp ( + UINT16 opcode); + +void +AcpiPsFreeOp ( + ACPI_PARSE_OBJECT *Op); + +BOOLEAN +AcpiPsIsLeadingChar ( + UINT32 c); + +BOOLEAN +AcpiPsIsPrefixChar ( + UINT32 c); + +UINT32 +AcpiPsGetName( + ACPI_PARSE_OBJECT *op); + +void +AcpiPsSetName( + ACPI_PARSE_OBJECT *op, + UINT32 name); + + +/* + * psdump - display parser tree + */ +UINT32 +AcpiPsSprintPath ( + char *BufferStart, + UINT32 BufferSize, + ACPI_PARSE_OBJECT *Op); + +UINT32 +AcpiPsSprintOp ( + char *BufferStart, + UINT32 BufferSize, + ACPI_PARSE_OBJECT *Op); + +void +AcpiPsShow ( + ACPI_PARSE_OBJECT *op); + + +#endif /* __ACPARSER_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/acpi.h b/reactos/drivers/bus/acpi/acpica/include/acpi.h new file mode 100644 index 00000000000..db552836627 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/acpi.h @@ -0,0 +1,144 @@ +/****************************************************************************** + * + * Name: acpi.h - Master public include file used to interface to ACPICA + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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. + * + *****************************************************************************/ + +#ifndef __ACPI_H__ +#define __ACPI_H__ + +/* + * Public include files for use by code that will interface to ACPICA. + * + * Information includes the ACPICA data types, names, exceptions, and + * external interface prototypes. Also included are the definitions for + * all ACPI tables (FADT, MADT, etc.) + * + * Note: The order of these include files is important. + */ +#include +#include + +#include "platform/acenv.h" /* Environment-specific items */ +#include "acnames.h" /* Common ACPI names and strings */ +#include "actypes.h" /* ACPICA data types and structures */ +#include "acexcep.h" /* ACPICA exceptions */ +#include "actbl.h" /* ACPI table definitions */ +#include "acoutput.h" /* Error output and Debug macros */ +#include "acrestyp.h" /* Resource Descriptor structs */ +#include "acpiosxf.h" /* OSL interfaces (ACPICA-to-OS) */ +#include "acpixf.h" /* ACPI core subsystem external interfaces */ + +#include "acconfig.h" +#include "acmacros.h" + +#endif /* __ACPI_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/acpiosxf.h b/reactos/drivers/bus/acpi/acpica/include/acpiosxf.h new file mode 100644 index 00000000000..730057d1efa --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/acpiosxf.h @@ -0,0 +1,495 @@ + +/****************************************************************************** + * + * Name: acpiosxf.h - All interfaces to the OS Services Layer (OSL). These + * interfaces must be implemented by OSL to interface the + * ACPI components to the host operating system. + * + *****************************************************************************/ + + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 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 exer + se the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACPIOSXF_H__ +#define __ACPIOSXF_H__ + +#include "platform/acenv.h" +#include "actypes.h" + + +/* Types for AcpiOsExecute */ + +typedef enum +{ + OSL_GLOBAL_LOCK_HANDLER, + OSL_NOTIFY_HANDLER, + OSL_GPE_HANDLER, + OSL_DEBUGGER_THREAD, + OSL_EC_POLL_HANDLER, + OSL_EC_BURST_HANDLER + +} ACPI_EXECUTE_TYPE; + +#define ACPI_NO_UNIT_LIMIT ((UINT32) -1) +#define ACPI_MUTEX_SEM 1 + + +/* Functions for AcpiOsSignal */ + +#define ACPI_SIGNAL_FATAL 0 +#define ACPI_SIGNAL_BREAKPOINT 1 + +typedef struct acpi_signal_fatal_info +{ + UINT32 Type; + UINT32 Code; + UINT32 Argument; + +} ACPI_SIGNAL_FATAL_INFO; + + +/* + * OSL Initialization and shutdown primitives + */ +ACPI_STATUS +AcpiOsInitialize ( + void); + +ACPI_STATUS +AcpiOsTerminate ( + void); + + +/* + * ACPI Table interfaces + */ +ACPI_PHYSICAL_ADDRESS +AcpiOsGetRootPointer ( + void); + +ACPI_STATUS +AcpiOsPredefinedOverride ( + const ACPI_PREDEFINED_NAMES *InitVal, + ACPI_STRING *NewVal); + +ACPI_STATUS +AcpiOsTableOverride ( + ACPI_TABLE_HEADER *ExistingTable, + ACPI_TABLE_HEADER **NewTable); + + +/* + * Spinlock primitives + */ +ACPI_STATUS +AcpiOsCreateLock ( + ACPI_SPINLOCK *OutHandle); + +void +AcpiOsDeleteLock ( + ACPI_SPINLOCK Handle); + +ACPI_CPU_FLAGS +AcpiOsAcquireLock ( + ACPI_SPINLOCK Handle); + +void +AcpiOsReleaseLock ( + ACPI_SPINLOCK Handle, + ACPI_CPU_FLAGS Flags); + + +/* + * Semaphore primitives + */ +ACPI_STATUS +AcpiOsCreateSemaphore ( + UINT32 MaxUnits, + UINT32 InitialUnits, + ACPI_SEMAPHORE *OutHandle); + +ACPI_STATUS +AcpiOsDeleteSemaphore ( + ACPI_SEMAPHORE Handle); + +ACPI_STATUS +AcpiOsWaitSemaphore ( + ACPI_SEMAPHORE Handle, + UINT32 Units, + UINT16 Timeout); + +ACPI_STATUS +AcpiOsSignalSemaphore ( + ACPI_SEMAPHORE Handle, + UINT32 Units); + + +/* + * Mutex primitives. May be configured to use semaphores instead via + * ACPI_MUTEX_TYPE (see platform/acenv.h) + */ +#if (ACPI_MUTEX_TYPE != ACPI_BINARY_SEMAPHORE) + +ACPI_STATUS +AcpiOsCreateMutex ( + ACPI_MUTEX *OutHandle); + +void +AcpiOsDeleteMutex ( + ACPI_MUTEX Handle); + +ACPI_STATUS +AcpiOsAcquireMutex ( + ACPI_MUTEX Handle, + UINT16 Timeout); + +void +AcpiOsReleaseMutex ( + ACPI_MUTEX Handle); +#endif + + +/* + * Memory allocation and mapping + */ +void * +AcpiOsAllocate ( + ACPI_SIZE Size); + +void +AcpiOsFree ( + void * Memory); + +void * +AcpiOsMapMemory ( + ACPI_PHYSICAL_ADDRESS Where, + ACPI_SIZE Length); + +void +AcpiOsUnmapMemory ( + void *LogicalAddress, + ACPI_SIZE Size); + +ACPI_STATUS +AcpiOsGetPhysicalAddress ( + void *LogicalAddress, + ACPI_PHYSICAL_ADDRESS *PhysicalAddress); + + +/* + * Memory/Object Cache + */ +ACPI_STATUS +AcpiOsCreateCache ( + char *CacheName, + UINT16 ObjectSize, + UINT16 MaxDepth, + ACPI_CACHE_T **ReturnCache); + +ACPI_STATUS +AcpiOsDeleteCache ( + ACPI_CACHE_T *Cache); + +ACPI_STATUS +AcpiOsPurgeCache ( + ACPI_CACHE_T *Cache); + +void * +AcpiOsAcquireObject ( + ACPI_CACHE_T *Cache); + +ACPI_STATUS +AcpiOsReleaseObject ( + ACPI_CACHE_T *Cache, + void *Object); + + +/* + * Interrupt handlers + */ +ACPI_STATUS +AcpiOsInstallInterruptHandler ( + UINT32 InterruptNumber, + ACPI_OSD_HANDLER ServiceRoutine, + void *Context); + +ACPI_STATUS +AcpiOsRemoveInterruptHandler ( + UINT32 InterruptNumber, + ACPI_OSD_HANDLER ServiceRoutine); + + +/* + * Threads and Scheduling + */ +ACPI_THREAD_ID +AcpiOsGetThreadId ( + void); + +ACPI_STATUS +AcpiOsExecute ( + ACPI_EXECUTE_TYPE Type, + ACPI_OSD_EXEC_CALLBACK Function, + void *Context); + +void +AcpiOsWaitEventsComplete ( + void *Context); + +void +AcpiOsSleep ( + ACPI_INTEGER Milliseconds); + +void +AcpiOsStall ( + UINT32 Microseconds); + + +/* + * Platform and hardware-independent I/O interfaces + */ +ACPI_STATUS +AcpiOsReadPort ( + ACPI_IO_ADDRESS Address, + UINT32 *Value, + UINT32 Width); + +ACPI_STATUS +AcpiOsWritePort ( + ACPI_IO_ADDRESS Address, + UINT32 Value, + UINT32 Width); + + +/* + * Platform and hardware-independent physical memory interfaces + */ +ACPI_STATUS +AcpiOsReadMemory ( + ACPI_PHYSICAL_ADDRESS Address, + UINT32 *Value, + UINT32 Width); + +ACPI_STATUS +AcpiOsWriteMemory ( + ACPI_PHYSICAL_ADDRESS Address, + UINT32 Value, + UINT32 Width); + + +/* + * Platform and hardware-independent PCI configuration space access + * Note: Can't use "Register" as a parameter, changed to "Reg" -- + * certain compilers complain. + */ +ACPI_STATUS +AcpiOsReadPciConfiguration ( + ACPI_PCI_ID *PciId, + UINT32 Reg, + void *Value, + UINT32 Width); + +ACPI_STATUS +AcpiOsWritePciConfiguration ( + ACPI_PCI_ID *PciId, + UINT32 Reg, + ACPI_INTEGER Value, + UINT32 Width); + + +/* + * Interim function needed for PCI IRQ routing + */ +void +AcpiOsDerivePciId( + ACPI_HANDLE Rhandle, + ACPI_HANDLE Chandle, + ACPI_PCI_ID **PciId); + + +/* + * Miscellaneous + */ +ACPI_STATUS +AcpiOsValidateInterface ( + char *Interface); + +BOOLEAN +AcpiOsReadable ( + void *Pointer, + ACPI_SIZE Length); + +BOOLEAN +AcpiOsWritable ( + void *Pointer, + ACPI_SIZE Length); + +UINT64 +AcpiOsGetTimer ( + void); + +ACPI_STATUS +AcpiOsSignal ( + UINT32 Function, + void *Info); + + +/* + * Debug print routines + */ +void ACPI_INTERNAL_VAR_XFACE +AcpiOsPrintf ( + const char *Format, + ...); + +void +AcpiOsVprintf ( + const char *Format, + va_list Args); + +void +AcpiOsRedirectOutput ( + void *Destination); + + +/* + * Debug input + */ +UINT32 +AcpiOsGetLine ( + char *Buffer); + + +/* + * Directory manipulation + */ +void * +AcpiOsOpenDirectory ( + char *Pathname, + char *WildcardSpec, + char RequestedFileType); + +/* RequesteFileType values */ + +#define REQUEST_FILE_ONLY 0 +#define REQUEST_DIR_ONLY 1 + + +char * +AcpiOsGetNextFilename ( + void *DirHandle); + +void +AcpiOsCloseDirectory ( + void *DirHandle); + + +#endif /* __ACPIOSXF_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/acpixf.h b/reactos/drivers/bus/acpi/acpica/include/acpixf.h new file mode 100644 index 00000000000..a961009465a --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/acpixf.h @@ -0,0 +1,687 @@ + +/****************************************************************************** + * + * Name: acpixf.h - External interfaces to the ACPI subsystem + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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. + * + *****************************************************************************/ + + +#ifndef __ACXFACE_H__ +#define __ACXFACE_H__ + +/* Current ACPICA subsystem version in YYYYMMDD format */ + +#define ACPI_CA_VERSION 0x20091214 + +#include "actypes.h" +#include "actbl.h" + +/* + * Globals that are publically available + */ +extern UINT32 AcpiCurrentGpeCount; +extern ACPI_TABLE_FADT AcpiGbl_FADT; + +/* 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; + + +/* + * Global interfaces + */ +ACPI_STATUS +AcpiInitializeTables ( + ACPI_TABLE_DESC *InitialStorage, + UINT32 InitialTableCount, + BOOLEAN AllowResize); + +ACPI_STATUS +AcpiInitializeSubsystem ( + void); + +ACPI_STATUS +AcpiEnableSubsystem ( + UINT32 Flags); + +ACPI_STATUS +AcpiInitializeObjects ( + UINT32 Flags); + +ACPI_STATUS +AcpiTerminate ( + void); + +ACPI_STATUS +AcpiSubsystemStatus ( + void); + +ACPI_STATUS +AcpiEnable ( + void); + +ACPI_STATUS +AcpiDisable ( + void); + +ACPI_STATUS +AcpiGetSystemInfo ( + ACPI_BUFFER *RetBuffer); + +ACPI_STATUS +AcpiGetStatistics ( + ACPI_STATISTICS *Stats); + +const char * +AcpiFormatException ( + ACPI_STATUS Exception); + +ACPI_STATUS +AcpiPurgeCachedObjects ( + void); + + +/* + * ACPI Memory managment + */ +void * +AcpiAllocate ( + UINT32 Size); + +void * +AcpiCallocate ( + UINT32 Size); + +void +AcpiFree ( + void *Address); + + +/* + * ACPI table manipulation interfaces + */ +ACPI_STATUS +AcpiReallocateRootTable ( + void); + +ACPI_STATUS +AcpiFindRootPointer ( + ACPI_SIZE *RsdpAddress); + +ACPI_STATUS +AcpiLoadTables ( + void); + +ACPI_STATUS +AcpiGetTableHeader ( + ACPI_STRING Signature, + UINT32 Instance, + ACPI_TABLE_HEADER *OutTableHeader); + +ACPI_STATUS +AcpiGetTable ( + ACPI_STRING Signature, + UINT32 Instance, + ACPI_TABLE_HEADER **OutTable); + +ACPI_STATUS +AcpiGetTableByIndex ( + UINT32 TableIndex, + ACPI_TABLE_HEADER **OutTable); + +ACPI_STATUS +AcpiInstallTableHandler ( + ACPI_TABLE_HANDLER Handler, + void *Context); + +ACPI_STATUS +AcpiRemoveTableHandler ( + ACPI_TABLE_HANDLER Handler); + + +/* + * Namespace and name interfaces + */ +ACPI_STATUS +AcpiWalkNamespace ( + ACPI_OBJECT_TYPE Type, + ACPI_HANDLE StartObject, + UINT32 MaxDepth, + ACPI_WALK_CALLBACK PreOrderVisit, + ACPI_WALK_CALLBACK PostOrderVisit, + void *Context, + void **ReturnValue); + +ACPI_STATUS +AcpiGetDevices ( + char *HID, + ACPI_WALK_CALLBACK UserFunction, + void *Context, + void **ReturnValue); + +ACPI_STATUS +AcpiGetName ( + ACPI_HANDLE Handle, + UINT32 NameType, + ACPI_BUFFER *RetPathPtr); + +ACPI_STATUS +AcpiGetHandle ( + ACPI_HANDLE Parent, + ACPI_STRING Pathname, + ACPI_HANDLE *RetHandle); + +ACPI_STATUS +AcpiAttachData ( + ACPI_HANDLE ObjHandle, + ACPI_OBJECT_HANDLER Handler, + void *Data); + +ACPI_STATUS +AcpiDetachData ( + ACPI_HANDLE ObjHandle, + ACPI_OBJECT_HANDLER Handler); + +ACPI_STATUS +AcpiGetData ( + ACPI_HANDLE ObjHandle, + ACPI_OBJECT_HANDLER Handler, + void **Data); + +ACPI_STATUS +AcpiDebugTrace ( + char *Name, + UINT32 DebugLevel, + UINT32 DebugLayer, + UINT32 Flags); + + +/* + * Object manipulation and enumeration + */ +ACPI_STATUS +AcpiEvaluateObject ( + ACPI_HANDLE Object, + ACPI_STRING Pathname, + ACPI_OBJECT_LIST *ParameterObjects, + ACPI_BUFFER *ReturnObjectBuffer); + +ACPI_STATUS +AcpiEvaluateObjectTyped ( + ACPI_HANDLE Object, + ACPI_STRING Pathname, + ACPI_OBJECT_LIST *ExternalParams, + ACPI_BUFFER *ReturnBuffer, + ACPI_OBJECT_TYPE ReturnType); + +ACPI_STATUS +AcpiGetObjectInfo ( + ACPI_HANDLE Handle, + ACPI_DEVICE_INFO **ReturnBuffer); + +ACPI_STATUS +AcpiInstallMethod ( + UINT8 *Buffer); + +ACPI_STATUS +AcpiGetNextObject ( + ACPI_OBJECT_TYPE Type, + ACPI_HANDLE Parent, + ACPI_HANDLE Child, + ACPI_HANDLE *OutHandle); + +ACPI_STATUS +AcpiGetType ( + ACPI_HANDLE Object, + ACPI_OBJECT_TYPE *OutType); + +ACPI_STATUS +AcpiGetParent ( + ACPI_HANDLE Object, + ACPI_HANDLE *OutHandle); + + +/* + * Handler interfaces + */ +ACPI_STATUS +AcpiInstallInitializationHandler ( + ACPI_INIT_HANDLER Handler, + UINT32 Function); + +ACPI_STATUS +AcpiInstallFixedEventHandler ( + UINT32 AcpiEvent, + ACPI_EVENT_HANDLER Handler, + void *Context); + +ACPI_STATUS +AcpiRemoveFixedEventHandler ( + UINT32 AcpiEvent, + ACPI_EVENT_HANDLER Handler); + +ACPI_STATUS +AcpiInstallNotifyHandler ( + ACPI_HANDLE Device, + UINT32 HandlerType, + ACPI_NOTIFY_HANDLER Handler, + void *Context); + +ACPI_STATUS +AcpiRemoveNotifyHandler ( + ACPI_HANDLE Device, + UINT32 HandlerType, + ACPI_NOTIFY_HANDLER Handler); + +ACPI_STATUS +AcpiInstallAddressSpaceHandler ( + ACPI_HANDLE Device, + ACPI_ADR_SPACE_TYPE SpaceId, + ACPI_ADR_SPACE_HANDLER Handler, + ACPI_ADR_SPACE_SETUP Setup, + void *Context); + +ACPI_STATUS +AcpiRemoveAddressSpaceHandler ( + ACPI_HANDLE Device, + ACPI_ADR_SPACE_TYPE SpaceId, + ACPI_ADR_SPACE_HANDLER Handler); + +ACPI_STATUS +AcpiInstallGpeHandler ( + 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); + + +/* + * Event interfaces + */ +ACPI_STATUS +AcpiAcquireGlobalLock ( + UINT16 Timeout, + UINT32 *Handle); + +ACPI_STATUS +AcpiReleaseGlobalLock ( + UINT32 Handle); + +ACPI_STATUS +AcpiEnableEvent ( + UINT32 Event, + UINT32 Flags); + +ACPI_STATUS +AcpiDisableEvent ( + UINT32 Event, + UINT32 Flags); + +ACPI_STATUS +AcpiClearEvent ( + UINT32 Event); + +ACPI_STATUS +AcpiGetEventStatus ( + UINT32 Event, + ACPI_EVENT_STATUS *EventStatus); + + +/* + * GPE Interfaces + */ +ACPI_STATUS +AcpiSetGpeType ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber, + UINT8 Type); + +ACPI_STATUS +AcpiEnableGpe ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber, + UINT32 Flags); + +ACPI_STATUS +AcpiDisableGpe ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber, + UINT32 Flags); + +ACPI_STATUS +AcpiClearGpe ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber, + UINT32 Flags); + +ACPI_STATUS +AcpiGetGpeStatus ( + ACPI_HANDLE GpeDevice, + UINT32 GpeNumber, + UINT32 Flags, + ACPI_EVENT_STATUS *EventStatus); + +ACPI_STATUS +AcpiDisableAllGpes ( + void); + +ACPI_STATUS +AcpiEnableAllRuntimeGpes ( + void); + +ACPI_STATUS +AcpiGetGpeDevice ( + UINT32 GpeIndex, + ACPI_HANDLE *GpeDevice); + +ACPI_STATUS +AcpiInstallGpeBlock ( + ACPI_HANDLE GpeDevice, + ACPI_GENERIC_ADDRESS *GpeBlockAddress, + UINT32 RegisterCount, + UINT32 InterruptNumber); + +ACPI_STATUS +AcpiRemoveGpeBlock ( + ACPI_HANDLE GpeDevice); + + +/* + * Resource interfaces + */ +typedef +ACPI_STATUS (*ACPI_WALK_RESOURCE_CALLBACK) ( + ACPI_RESOURCE *Resource, + void *Context); + +ACPI_STATUS +AcpiGetVendorResource ( + ACPI_HANDLE DeviceHandle, + char *Name, + ACPI_VENDOR_UUID *Uuid, + ACPI_BUFFER *RetBuffer); + +ACPI_STATUS +AcpiGetCurrentResources( + ACPI_HANDLE DeviceHandle, + ACPI_BUFFER *RetBuffer); + +ACPI_STATUS +AcpiGetPossibleResources( + ACPI_HANDLE DeviceHandle, + ACPI_BUFFER *RetBuffer); + +ACPI_STATUS +AcpiWalkResources ( + ACPI_HANDLE DeviceHandle, + char *Name, + ACPI_WALK_RESOURCE_CALLBACK UserFunction, + void *Context); + +ACPI_STATUS +AcpiSetCurrentResources ( + ACPI_HANDLE DeviceHandle, + ACPI_BUFFER *InBuffer); + +ACPI_STATUS +AcpiGetIrqRoutingTable ( + ACPI_HANDLE BusDeviceHandle, + ACPI_BUFFER *RetBuffer); + +ACPI_STATUS +AcpiResourceToAddress64 ( + ACPI_RESOURCE *Resource, + ACPI_RESOURCE_ADDRESS64 *Out); + + +/* + * Hardware (ACPI device) interfaces + */ +ACPI_STATUS +AcpiReset ( + void); + +ACPI_STATUS +AcpiRead ( + UINT64 *Value, + ACPI_GENERIC_ADDRESS *Reg); + +ACPI_STATUS +AcpiWrite ( + UINT64 Value, + ACPI_GENERIC_ADDRESS *Reg); + +ACPI_STATUS +AcpiReadBitRegister ( + UINT32 RegisterId, + UINT32 *ReturnValue); + +ACPI_STATUS +AcpiWriteBitRegister ( + UINT32 RegisterId, + UINT32 Value); + +ACPI_STATUS +AcpiGetSleepTypeData ( + UINT8 SleepState, + UINT8 *Slp_TypA, + UINT8 *Slp_TypB); + +ACPI_STATUS +AcpiEnterSleepStatePrep ( + UINT8 SleepState); + +ACPI_STATUS +AcpiEnterSleepState ( + UINT8 SleepState); + +ACPI_STATUS +AcpiEnterSleepStateS4bios ( + void); + +ACPI_STATUS +AcpiLeaveSleepState ( + UINT8 SleepState) + ; +ACPI_STATUS +AcpiSetFirmwareWakingVector ( + UINT32 PhysicalAddress); + +#if ACPI_MACHINE_WIDTH == 64 +ACPI_STATUS +AcpiSetFirmwareWakingVector64 ( + UINT64 PhysicalAddress); +#endif + + +/* + * Error/Warning output + */ +void ACPI_INTERNAL_VAR_XFACE +AcpiError ( + const char *ModuleName, + UINT32 LineNumber, + const char *Format, + ...) ACPI_PRINTF_LIKE(3); + +void ACPI_INTERNAL_VAR_XFACE +AcpiException ( + const char *ModuleName, + UINT32 LineNumber, + ACPI_STATUS Status, + const char *Format, + ...) ACPI_PRINTF_LIKE(4); + +void ACPI_INTERNAL_VAR_XFACE +AcpiWarning ( + const char *ModuleName, + UINT32 LineNumber, + const char *Format, + ...) ACPI_PRINTF_LIKE(3); + +void ACPI_INTERNAL_VAR_XFACE +AcpiInfo ( + const char *ModuleName, + UINT32 LineNumber, + const char *Format, + ...) ACPI_PRINTF_LIKE(3); + + +/* + * Debug output + */ +#ifdef ACPI_DEBUG_OUTPUT + +void ACPI_INTERNAL_VAR_XFACE +AcpiDebugPrint ( + UINT32 RequestedDebugLevel, + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId, + const char *Format, + ...) ACPI_PRINTF_LIKE(6); + +void ACPI_INTERNAL_VAR_XFACE +AcpiDebugPrintRaw ( + UINT32 RequestedDebugLevel, + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId, + const char *Format, + ...) ACPI_PRINTF_LIKE(6); +#endif + +#endif /* __ACXFACE_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/acpredef.h b/reactos/drivers/bus/acpi/acpica/include/acpredef.h new file mode 100644 index 00000000000..2be401520b3 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/acpredef.h @@ -0,0 +1,598 @@ +/****************************************************************************** + * + * Name: acpredef - Information table for ACPI predefined methods and objects + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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. + * + *****************************************************************************/ + +#ifndef __ACPREDEF_H__ +#define __ACPREDEF_H__ + + +/****************************************************************************** + * + * Return Package types + * + * 1) PTYPE1 packages do not contain sub-packages. + * + * ACPI_PTYPE1_FIXED: Fixed-length length, 1 or 2 object types: + * object type + * count + * object type + * count + * + * ACPI_PTYPE1_VAR: Variable-length length: + * object type (Int/Buf/Ref) + * + * ACPI_PTYPE1_OPTION: Package has some required and some optional elements + * (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. + * + * ACPI_PTYPE2: Each subpackage contains 1 or 2 object types: + * object type + * count + * object type + * count + * (Used for _ALR,_MLS,_PSS,_TRT,_TSS) + * + * ACPI_PTYPE2_COUNT: Each subpackage has a count as first element: + * object type + * (Used for _CSD,_PSD,_TSD) + * + * ACPI_PTYPE2_PKG_COUNT: Count of subpackages at start, 1 or 2 object types: + * object type + * count + * object type + * count + * (Used for _CST) + * + * 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 +{ + ACPI_PTYPE1_FIXED = 1, + ACPI_PTYPE1_VAR = 2, + ACPI_PTYPE1_OPTION = 3, + ACPI_PTYPE2 = 4, + ACPI_PTYPE2_COUNT = 5, + ACPI_PTYPE2_PKG_COUNT = 6, + ACPI_PTYPE2_FIXED = 7, + ACPI_PTYPE2_MIN = 8, + ACPI_PTYPE2_REV_FIXED = 9 +}; + + +#ifdef ACPI_CREATE_PREDEFINED_TABLE +/* + * Predefined method/object information table. + * + * These are the names that can actually be evaluated via AcpiEvaluateObject. + * Not present in this table are the following: + * + * 1) Predefined/Reserved names that are never evaluated via + * AcpiEvaluateObject: + * _Lxx and _Exx GPE methods + * _Qxx EC methods + * _T_x compiler temporary variables + * + * 2) Predefined names that never actually exist within the AML code: + * Predefined resource descriptor field names + * + * 3) Predefined names that are implemented within ACPICA: + * _OSI + * + * 4) Some predefined names that are not documented within the ACPI spec. + * _WDG, _WED + * + * The main entries in the table each contain the following items: + * + * Name - The ACPI reserved name + * ParamCount - Number of arguments to the method + * ExpectedBtypes - Allowed type(s) for the return value. + * 0 means that no return value is expected. + * + * For methods that return packages, the next entry in the table contains + * information about the expected structure of the package. This information + * is saved here (rather than in a separate table) in order to minimize the + * overall size of the stored data. + * + * Note: The additional braces are intended to promote portability. + */ +static const ACPI_PREDEFINED_INFO PredefinedNames[] = +{ + {{"_AC0", 0, ACPI_RTYPE_INTEGER}}, + {{"_AC1", 0, ACPI_RTYPE_INTEGER}}, + {{"_AC2", 0, ACPI_RTYPE_INTEGER}}, + {{"_AC3", 0, ACPI_RTYPE_INTEGER}}, + {{"_AC4", 0, ACPI_RTYPE_INTEGER}}, + {{"_AC5", 0, ACPI_RTYPE_INTEGER}}, + {{"_AC6", 0, ACPI_RTYPE_INTEGER}}, + {{"_AC7", 0, ACPI_RTYPE_INTEGER}}, + {{"_AC8", 0, ACPI_RTYPE_INTEGER}}, + {{"_AC9", 0, ACPI_RTYPE_INTEGER}}, + {{"_ADR", 0, ACPI_RTYPE_INTEGER}}, + {{"_AL0", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_AL1", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_AL2", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_AL3", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_AL4", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_AL5", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_AL6", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_AL7", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_AL8", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_AL9", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_ALC", 0, ACPI_RTYPE_INTEGER}}, + {{"_ALI", 0, ACPI_RTYPE_INTEGER}}, + {{"_ALP", 0, ACPI_RTYPE_INTEGER}}, + {{"_ALR", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each 2 (Ints) */ + {{{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}}, + + {{"_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}}, + + {{"_CRS", 0, ACPI_RTYPE_BUFFER}}, + {{"_CRT", 0, ACPI_RTYPE_INTEGER}}, + {{"_CSD", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (1 Int(n), n-1 Int) */ + {{{ACPI_PTYPE2_COUNT, ACPI_RTYPE_INTEGER, 0,0}, 0,0}}, + + {{"_CST", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (1 Int(n), n Pkg (1 Buf/3 Int) */ + {{{ACPI_PTYPE2_PKG_COUNT,ACPI_RTYPE_BUFFER, 1, ACPI_RTYPE_INTEGER}, 3,0}}, + + {{"_DCK", 1, ACPI_RTYPE_INTEGER}}, + {{"_DCS", 0, ACPI_RTYPE_INTEGER}}, + {{"_DDC", 1, ACPI_RTYPE_INTEGER | ACPI_RTYPE_BUFFER}}, + {{"_DDN", 0, ACPI_RTYPE_STRING}}, + {{"_DGS", 0, ACPI_RTYPE_INTEGER}}, + {{"_DIS", 0, 0}}, + {{"_DMA", 0, ACPI_RTYPE_BUFFER}}, + {{"_DOD", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Ints) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 0,0}, 0,0}}, + + {{"_DOS", 1, 0}}, + {{"_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}}, + + {{"_EJ0", 1, 0}}, + {{"_EJ1", 1, 0}}, + {{"_EJ2", 1, 0}}, + {{"_EJ3", 1, 0}}, + {{"_EJ4", 1, 0}}, + {{"_EJD", 0, ACPI_RTYPE_STRING}}, + {{"_FDE", 0, ACPI_RTYPE_BUFFER}}, + {{"_FDI", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (16 Int) */ + {{{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 */ + {{"_GSB", 0, ACPI_RTYPE_INTEGER}}, + {{"_GTF", 0, ACPI_RTYPE_BUFFER}}, + {{"_GTM", 0, ACPI_RTYPE_BUFFER}}, + {{"_GTS", 1, 0}}, + {{"_HID", 0, ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING}}, + {{"_HOT", 0, ACPI_RTYPE_INTEGER}}, + {{"_HPP", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (4 Int) */ + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 4,0}, 0,0}}, + + /* + * For _HPX, a single package is returned, containing a Variable-length number + * of sub-packages. Each sub-package contains a PCI record setting. + * There are several different type of record settings, of different + * lengths, but all elements of all settings are Integers. + */ + {{"_HPX", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each (var Ints) */ + {{{ACPI_PTYPE2_MIN, ACPI_RTYPE_INTEGER, 5,0}, 0,0}}, + + {{"_IFT", 0, ACPI_RTYPE_INTEGER}}, /* See IPMI spec */ + {{"_INI", 0, 0}}, + {{"_IRC", 0, 0}}, + {{"_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}}, + + {{"_PCT", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (2 Buf) */ + {{{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) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_PR1", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_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 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}}, + + {{"_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, + ACPI_RTYPE_INTEGER}, ACPI_RTYPE_REFERENCE,0}}, + + {{"_PS0", 0, 0}}, + {{"_PS1", 0, 0}}, + {{"_PS2", 0, 0}}, + {{"_PS3", 0, 0}}, + {{"_PSC", 0, ACPI_RTYPE_INTEGER}}, + {{"_PSD", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each (5 Int) with count */ + {{{ACPI_PTYPE2_COUNT, ACPI_RTYPE_INTEGER,0,0}, 0,0}}, + + {{"_PSL", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_PSR", 0, ACPI_RTYPE_INTEGER}}, + {{"_PSS", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each (6 Int) */ + {{{ACPI_PTYPE2, ACPI_RTYPE_INTEGER, 6,0}, 0,0}}, + + {{"_PSV", 0, ACPI_RTYPE_INTEGER}}, + {{"_PSW", 1, 0}}, + {{"_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}}, + {{"_RMV", 0, ACPI_RTYPE_INTEGER}}, + {{"_ROM", 2, ACPI_RTYPE_BUFFER}}, + {{"_RTV", 0, ACPI_RTYPE_INTEGER}}, + + /* + * For _S0_ through _S5_, the ACPI spec defines a return Package + * containing 1 Integer, but most DSDTs have it wrong - 2,3, or 4 integers. + * Allow this by making the objects "Variable-length length", but all elements + * must be Integers. + */ + {{"_S0_", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (1 Int) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1,0}, 0,0}}, + + {{"_S1_", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (1 Int) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1,0}, 0,0}}, + + {{"_S2_", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (1 Int) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1,0}, 0,0}}, + + {{"_S3_", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (1 Int) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1,0}, 0,0}}, + + {{"_S4_", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (1 Int) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1,0}, 0,0}}, + + {{"_S5_", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (1 Int) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER, 1,0}, 0,0}}, + + {{"_S1D", 0, ACPI_RTYPE_INTEGER}}, + {{"_S2D", 0, ACPI_RTYPE_INTEGER}}, + {{"_S3D", 0, ACPI_RTYPE_INTEGER}}, + {{"_S4D", 0, ACPI_RTYPE_INTEGER}}, + {{"_S0W", 0, ACPI_RTYPE_INTEGER}}, + {{"_S1W", 0, ACPI_RTYPE_INTEGER}}, + {{"_S2W", 0, ACPI_RTYPE_INTEGER}}, + {{"_S3W", 0, ACPI_RTYPE_INTEGER}}, + {{"_S4W", 0, ACPI_RTYPE_INTEGER}}, + {{"_SBS", 0, ACPI_RTYPE_INTEGER}}, + {{"_SCP", 0x13, 0}}, /* Acpi 1.0 allowed 1 arg. Acpi 3.0 expanded to 3 args. Allow both. */ + /* 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}}, + {{"_SRV", 0, ACPI_RTYPE_INTEGER}}, /* See IPMI spec */ + {{"_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}}, + {{"_TRT", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each 2Ref/6Int */ + {{{ACPI_PTYPE2, ACPI_RTYPE_REFERENCE, 2, ACPI_RTYPE_INTEGER}, 6, 0}}, + + {{"_TSD", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each 5Int with count */ + {{{ACPI_PTYPE2_COUNT,ACPI_RTYPE_INTEGER, 5,0}, 0,0}}, + + {{"_TSP", 0, ACPI_RTYPE_INTEGER}}, + {{"_TSS", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Pkgs) each 5Int */ + {{{ACPI_PTYPE2, ACPI_RTYPE_INTEGER, 5,0}, 0,0}}, + + {{"_TST", 0, ACPI_RTYPE_INTEGER}}, + {{"_TTS", 1, 0}}, + {{"_TZD", 0, ACPI_RTYPE_PACKAGE}}, /* Variable-length (Refs) */ + {{{ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0}, 0,0}}, + + {{"_TZM", 0, ACPI_RTYPE_REFERENCE}}, + {{"_TZP", 0, ACPI_RTYPE_INTEGER}}, + {{"_UID", 0, ACPI_RTYPE_INTEGER | ACPI_RTYPE_STRING}}, + {{"_UPC", 0, ACPI_RTYPE_PACKAGE}}, /* Fixed-length (4 Int) */ + {{{ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 4,0}, 0,0}}, + + {{"_UPD", 0, ACPI_RTYPE_INTEGER}}, + {{"_UPP", 0, ACPI_RTYPE_INTEGER}}, + {{"_VPO", 0, ACPI_RTYPE_INTEGER}}, + + /* Acpi 1.0 defined _WAK with no return value. Later, it was changed to return a package */ + + {{"_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 */ + + {{{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}}, + + /* TBD: */ + + _PRT - currently ignore reversed entries. Attempt to fix here? + Think about possibly fixing package elements like _BIF, etc. +#endif +#endif +#endif diff --git a/reactos/drivers/bus/acpi/acpica/include/acresrc.h b/reactos/drivers/bus/acpi/acpica/include/acresrc.h new file mode 100644 index 00000000000..c70aa5e23d4 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/acresrc.h @@ -0,0 +1,465 @@ +/****************************************************************************** + * + * Name: acresrc.h - Resource Manager function prototypes + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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. + * + *****************************************************************************/ + +#ifndef __ACRESRC_H__ +#define __ACRESRC_H__ + +/* Need the AML resource descriptor structs */ + +#include "amlresrc.h" + + +/* + * If possible, pack the following structures to byte alignment, since we + * don't care about performance for debug output. Two cases where we cannot + * pack the structures: + * + * 1) Hardware does not support misaligned memory transfers + * 2) Compiler does not support pointers within packed structures + */ +#if (!defined(ACPI_MISALIGNMENT_NOT_SUPPORTED) && !defined(ACPI_PACKED_POINTERS_NOT_SUPPORTED)) +#pragma pack(1) +#endif + +/* + * Individual entry for the resource conversion tables + */ +typedef const struct acpi_rsconvert_info +{ + UINT8 Opcode; + UINT8 ResourceOffset; + UINT8 AmlOffset; + UINT8 Value; + +} ACPI_RSCONVERT_INFO; + +/* Resource conversion opcodes */ + +#define ACPI_RSC_INITGET 0 +#define ACPI_RSC_INITSET 1 +#define ACPI_RSC_FLAGINIT 2 +#define ACPI_RSC_1BITFLAG 3 +#define ACPI_RSC_2BITFLAG 4 +#define ACPI_RSC_COUNT 5 +#define ACPI_RSC_COUNT16 6 +#define ACPI_RSC_LENGTH 7 +#define ACPI_RSC_MOVE8 8 +#define ACPI_RSC_MOVE16 9 +#define ACPI_RSC_MOVE32 10 +#define ACPI_RSC_MOVE64 11 +#define ACPI_RSC_SET8 12 +#define ACPI_RSC_DATA8 13 +#define ACPI_RSC_ADDRESS 14 +#define ACPI_RSC_SOURCE 15 +#define ACPI_RSC_SOURCEX 16 +#define ACPI_RSC_BITMASK 17 +#define ACPI_RSC_BITMASK16 18 +#define ACPI_RSC_EXIT_NE 19 +#define ACPI_RSC_EXIT_LE 20 +#define ACPI_RSC_EXIT_EQ 21 + +/* Resource Conversion sub-opcodes */ + +#define ACPI_RSC_COMPARE_AML_LENGTH 0 +#define ACPI_RSC_COMPARE_VALUE 1 + +#define ACPI_RSC_TABLE_SIZE(d) (sizeof (d) / sizeof (ACPI_RSCONVERT_INFO)) + +#define ACPI_RS_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_RESOURCE,f) +#define AML_OFFSET(f) (UINT8) ACPI_OFFSET (AML_RESOURCE,f) + + +typedef const struct acpi_rsdump_info +{ + UINT8 Opcode; + UINT8 Offset; + char *Name; + const char **Pointer; + +} ACPI_RSDUMP_INFO; + +/* Values for the Opcode field above */ + +#define ACPI_RSD_TITLE 0 +#define ACPI_RSD_LITERAL 1 +#define ACPI_RSD_STRING 2 +#define ACPI_RSD_UINT8 3 +#define ACPI_RSD_UINT16 4 +#define ACPI_RSD_UINT32 5 +#define ACPI_RSD_UINT64 6 +#define ACPI_RSD_1BITFLAG 7 +#define ACPI_RSD_2BITFLAG 8 +#define ACPI_RSD_SHORTLIST 9 +#define ACPI_RSD_LONGLIST 10 +#define ACPI_RSD_DWORDLIST 11 +#define ACPI_RSD_ADDRESS 12 +#define ACPI_RSD_SOURCE 13 + +/* restore default alignment */ + +#pragma pack() + + +/* Resource tables indexed by internal resource type */ + +extern const UINT8 AcpiGbl_AmlResourceSizes[]; +extern ACPI_RSCONVERT_INFO *AcpiGbl_SetResourceDispatch[]; + +/* Resource tables indexed by raw AML resource descriptor type */ + +extern const UINT8 AcpiGbl_ResourceStructSizes[]; +extern ACPI_RSCONVERT_INFO *AcpiGbl_GetResourceDispatch[]; + + +typedef struct acpi_vendor_walk_info +{ + ACPI_VENDOR_UUID *Uuid; + ACPI_BUFFER *Buffer; + ACPI_STATUS Status; + +} ACPI_VENDOR_WALK_INFO; + + +/* + * rscreate + */ +ACPI_STATUS +AcpiRsCreateResourceList ( + ACPI_OPERAND_OBJECT *AmlBuffer, + ACPI_BUFFER *OutputBuffer); + +ACPI_STATUS +AcpiRsCreateAmlResources ( + ACPI_RESOURCE *LinkedListBuffer, + ACPI_BUFFER *OutputBuffer); + +ACPI_STATUS +AcpiRsCreatePciRoutingTable ( + ACPI_OPERAND_OBJECT *PackageObject, + ACPI_BUFFER *OutputBuffer); + + +/* + * rsutils + */ +ACPI_STATUS +AcpiRsGetPrtMethodData ( + ACPI_NAMESPACE_NODE *Node, + ACPI_BUFFER *RetBuffer); + +ACPI_STATUS +AcpiRsGetCrsMethodData ( + ACPI_NAMESPACE_NODE *Node, + ACPI_BUFFER *RetBuffer); + +ACPI_STATUS +AcpiRsGetPrsMethodData ( + ACPI_NAMESPACE_NODE *Node, + ACPI_BUFFER *RetBuffer); + +ACPI_STATUS +AcpiRsGetMethodData ( + ACPI_HANDLE Handle, + char *Path, + ACPI_BUFFER *RetBuffer); + +ACPI_STATUS +AcpiRsSetSrsMethodData ( + ACPI_NAMESPACE_NODE *Node, + ACPI_BUFFER *RetBuffer); + + +/* + * rscalc + */ +ACPI_STATUS +AcpiRsGetListLength ( + UINT8 *AmlBuffer, + UINT32 AmlBufferLength, + ACPI_SIZE *SizeNeeded); + +ACPI_STATUS +AcpiRsGetAmlLength ( + ACPI_RESOURCE *LinkedListBuffer, + ACPI_SIZE *SizeNeeded); + +ACPI_STATUS +AcpiRsGetPciRoutingTableLength ( + ACPI_OPERAND_OBJECT *PackageObject, + ACPI_SIZE *BufferSizeNeeded); + +ACPI_STATUS +AcpiRsConvertAmlToResources ( + UINT8 *Aml, + UINT32 Length, + UINT32 Offset, + UINT8 ResourceIndex, + void *Context); + +ACPI_STATUS +AcpiRsConvertResourcesToAml ( + ACPI_RESOURCE *Resource, + ACPI_SIZE AmlSizeNeeded, + UINT8 *OutputBuffer); + + +/* + * rsaddr + */ +void +AcpiRsSetAddressCommon ( + AML_RESOURCE *Aml, + ACPI_RESOURCE *Resource); + +BOOLEAN +AcpiRsGetAddressCommon ( + ACPI_RESOURCE *Resource, + AML_RESOURCE *Aml); + + +/* + * rsmisc + */ +ACPI_STATUS +AcpiRsConvertAmlToResource ( + ACPI_RESOURCE *Resource, + AML_RESOURCE *Aml, + ACPI_RSCONVERT_INFO *Info); + +ACPI_STATUS +AcpiRsConvertResourceToAml ( + ACPI_RESOURCE *Resource, + AML_RESOURCE *Aml, + ACPI_RSCONVERT_INFO *Info); + + +/* + * rsutils + */ +void +AcpiRsMoveData ( + void *Destination, + void *Source, + UINT16 ItemCount, + UINT8 MoveType); + +UINT8 +AcpiRsDecodeBitmask ( + UINT16 Mask, + UINT8 *List); + +UINT16 +AcpiRsEncodeBitmask ( + UINT8 *List, + UINT8 Count); + +ACPI_RS_LENGTH +AcpiRsGetResourceSource ( + ACPI_RS_LENGTH ResourceLength, + ACPI_RS_LENGTH MinimumLength, + ACPI_RESOURCE_SOURCE *ResourceSource, + AML_RESOURCE *Aml, + char *StringPtr); + +ACPI_RSDESC_SIZE +AcpiRsSetResourceSource ( + AML_RESOURCE *Aml, + ACPI_RS_LENGTH MinimumLength, + ACPI_RESOURCE_SOURCE *ResourceSource); + +void +AcpiRsSetResourceHeader ( + UINT8 DescriptorType, + ACPI_RSDESC_SIZE TotalLength, + AML_RESOURCE *Aml); + +void +AcpiRsSetResourceLength ( + ACPI_RSDESC_SIZE TotalLength, + AML_RESOURCE *Aml); + + +/* + * rsdump + */ +void +AcpiRsDumpResourceList ( + ACPI_RESOURCE *Resource); + +void +AcpiRsDumpIrqList ( + UINT8 *RouteTable); + + +/* + * Resource conversion tables + */ +extern ACPI_RSCONVERT_INFO AcpiRsConvertDma[]; +extern ACPI_RSCONVERT_INFO AcpiRsConvertEndDpf[]; +extern ACPI_RSCONVERT_INFO AcpiRsConvertIo[]; +extern ACPI_RSCONVERT_INFO AcpiRsConvertFixedIo[]; +extern ACPI_RSCONVERT_INFO AcpiRsConvertEndTag[]; +extern ACPI_RSCONVERT_INFO AcpiRsConvertMemory24[]; +extern ACPI_RSCONVERT_INFO AcpiRsConvertGenericReg[]; +extern ACPI_RSCONVERT_INFO AcpiRsConvertMemory32[]; +extern ACPI_RSCONVERT_INFO AcpiRsConvertFixedMemory32[]; +extern ACPI_RSCONVERT_INFO AcpiRsConvertAddress32[]; +extern ACPI_RSCONVERT_INFO AcpiRsConvertAddress16[]; +extern ACPI_RSCONVERT_INFO AcpiRsConvertExtIrq[]; +extern ACPI_RSCONVERT_INFO AcpiRsConvertAddress64[]; +extern ACPI_RSCONVERT_INFO AcpiRsConvertExtAddress64[]; + +/* These resources require separate get/set tables */ + +extern ACPI_RSCONVERT_INFO AcpiRsGetIrq[]; +extern ACPI_RSCONVERT_INFO AcpiRsGetStartDpf[]; +extern ACPI_RSCONVERT_INFO AcpiRsGetVendorSmall[]; +extern ACPI_RSCONVERT_INFO AcpiRsGetVendorLarge[]; + +extern ACPI_RSCONVERT_INFO AcpiRsSetIrq[]; +extern ACPI_RSCONVERT_INFO AcpiRsSetStartDpf[]; +extern ACPI_RSCONVERT_INFO AcpiRsSetVendor[]; + + +#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) +/* + * rsinfo + */ +extern ACPI_RSDUMP_INFO *AcpiGbl_DumpResourceDispatch[]; + +/* + * rsdump + */ +extern ACPI_RSDUMP_INFO AcpiRsDumpIrq[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpDma[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpStartDpf[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpEndDpf[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpIo[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpFixedIo[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpVendor[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpEndTag[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpMemory24[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpMemory32[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpFixedMemory32[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpAddress16[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpAddress32[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpAddress64[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpExtAddress64[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpExtIrq[]; +extern ACPI_RSDUMP_INFO AcpiRsDumpGenericReg[]; +#endif + +#endif /* __ACRESRC_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/acrestyp.h b/reactos/drivers/bus/acpi/acpica/include/acrestyp.h new file mode 100644 index 00000000000..7eb7600d982 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/acrestyp.h @@ -0,0 +1,544 @@ +/****************************************************************************** + * + * Name: acrestyp.h - Defines, types, and structures for resource descriptors + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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. + * + *****************************************************************************/ + +#ifndef __ACRESTYP_H__ +#define __ACRESTYP_H__ + + +/* + * Definitions for Resource Attributes + */ +typedef UINT16 ACPI_RS_LENGTH; /* Resource Length field is fixed at 16 bits */ +typedef UINT32 ACPI_RSDESC_SIZE; /* Max Resource Descriptor size is (Length+3) = (64K-1)+3 */ + +/* + * Memory Attributes + */ +#define ACPI_READ_ONLY_MEMORY (UINT8) 0x00 +#define ACPI_READ_WRITE_MEMORY (UINT8) 0x01 + +#define ACPI_NON_CACHEABLE_MEMORY (UINT8) 0x00 +#define ACPI_CACHABLE_MEMORY (UINT8) 0x01 +#define ACPI_WRITE_COMBINING_MEMORY (UINT8) 0x02 +#define ACPI_PREFETCHABLE_MEMORY (UINT8) 0x03 + +/* + * IO Attributes + * The ISA IO ranges are: n000-n0FFh, n400-n4FFh, n800-n8FFh, nC00-nCFFh. + * The non-ISA IO ranges are: n100-n3FFh, n500-n7FFh, n900-nBFFh, nCD0-nFFFh. + */ +#define ACPI_NON_ISA_ONLY_RANGES (UINT8) 0x01 +#define ACPI_ISA_ONLY_RANGES (UINT8) 0x02 +#define ACPI_ENTIRE_RANGE (ACPI_NON_ISA_ONLY_RANGES | ACPI_ISA_ONLY_RANGES) + +/* Type of translation - 1=Sparse, 0=Dense */ + +#define ACPI_SPARSE_TRANSLATION (UINT8) 0x01 + +/* + * IO Port Descriptor Decode + */ +#define ACPI_DECODE_10 (UINT8) 0x00 /* 10-bit IO address decode */ +#define ACPI_DECODE_16 (UINT8) 0x01 /* 16-bit IO address decode */ + +/* + * IRQ Attributes + */ +#define ACPI_LEVEL_SENSITIVE (UINT8) 0x00 +#define ACPI_EDGE_SENSITIVE (UINT8) 0x01 + +#define ACPI_ACTIVE_HIGH (UINT8) 0x00 +#define ACPI_ACTIVE_LOW (UINT8) 0x01 + +#define ACPI_EXCLUSIVE (UINT8) 0x00 +#define ACPI_SHARED (UINT8) 0x01 + +/* + * DMA Attributes + */ +#define ACPI_COMPATIBILITY (UINT8) 0x00 +#define ACPI_TYPE_A (UINT8) 0x01 +#define ACPI_TYPE_B (UINT8) 0x02 +#define ACPI_TYPE_F (UINT8) 0x03 + +#define ACPI_NOT_BUS_MASTER (UINT8) 0x00 +#define ACPI_BUS_MASTER (UINT8) 0x01 + +#define ACPI_TRANSFER_8 (UINT8) 0x00 +#define ACPI_TRANSFER_8_16 (UINT8) 0x01 +#define ACPI_TRANSFER_16 (UINT8) 0x02 + +/* + * Start Dependent Functions Priority definitions + */ +#define ACPI_GOOD_CONFIGURATION (UINT8) 0x00 +#define ACPI_ACCEPTABLE_CONFIGURATION (UINT8) 0x01 +#define ACPI_SUB_OPTIMAL_CONFIGURATION (UINT8) 0x02 + +/* + * 16, 32 and 64-bit Address Descriptor resource types + */ +#define ACPI_MEMORY_RANGE (UINT8) 0x00 +#define ACPI_IO_RANGE (UINT8) 0x01 +#define ACPI_BUS_NUMBER_RANGE (UINT8) 0x02 + +#define ACPI_ADDRESS_NOT_FIXED (UINT8) 0x00 +#define ACPI_ADDRESS_FIXED (UINT8) 0x01 + +#define ACPI_POS_DECODE (UINT8) 0x00 +#define ACPI_SUB_DECODE (UINT8) 0x01 + +#define ACPI_PRODUCER (UINT8) 0x00 +#define ACPI_CONSUMER (UINT8) 0x01 + + +/* + * If possible, pack the following structures to byte alignment + */ +#ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED +#pragma pack(1) +#endif + +/* UUID data structures for use in vendor-defined resource descriptors */ + +typedef struct acpi_uuid +{ + UINT8 Data[ACPI_UUID_LENGTH]; +} ACPI_UUID; + +typedef struct acpi_vendor_uuid +{ + UINT8 Subtype; + UINT8 Data[ACPI_UUID_LENGTH]; + +} ACPI_VENDOR_UUID; + +/* + * Structures used to describe device resources + */ +typedef struct acpi_resource_irq +{ + UINT8 DescriptorLength; + UINT8 Triggering; + UINT8 Polarity; + UINT8 Sharable; + UINT8 InterruptCount; + UINT8 Interrupts[1]; + +} ACPI_RESOURCE_IRQ; + +typedef struct ACPI_RESOURCE_DMA +{ + UINT8 Type; + UINT8 BusMaster; + UINT8 Transfer; + UINT8 ChannelCount; + UINT8 Channels[1]; + +} ACPI_RESOURCE_DMA; + +typedef struct acpi_resource_start_dependent +{ + UINT8 DescriptorLength; + UINT8 CompatibilityPriority; + UINT8 PerformanceRobustness; + +} ACPI_RESOURCE_START_DEPENDENT; + + +/* + * The END_DEPENDENT_FUNCTIONS_RESOURCE struct is not + * needed because it has no fields + */ + + +typedef struct acpi_resource_io +{ + UINT8 IoDecode; + UINT8 Alignment; + UINT8 AddressLength; + UINT16 Minimum; + UINT16 Maximum; + +} ACPI_RESOURCE_IO; + +typedef struct acpi_resource_fixed_io +{ + UINT16 Address; + UINT8 AddressLength; + +} ACPI_RESOURCE_FIXED_IO; + +typedef struct acpi_resource_vendor +{ + UINT16 ByteLength; + UINT8 ByteData[1]; + +} ACPI_RESOURCE_VENDOR; + +/* Vendor resource with UUID info (introduced in ACPI 3.0) */ + +typedef struct acpi_resource_vendor_typed +{ + UINT16 ByteLength; + UINT8 UuidSubtype; + UINT8 Uuid[ACPI_UUID_LENGTH]; + UINT8 ByteData[1]; + +} ACPI_RESOURCE_VENDOR_TYPED; + +typedef struct acpi_resource_end_tag +{ + UINT8 Checksum; + +} ACPI_RESOURCE_END_TAG; + +typedef struct acpi_resource_memory24 +{ + UINT8 WriteProtect; + UINT16 Minimum; + UINT16 Maximum; + UINT16 Alignment; + UINT16 AddressLength; + +} ACPI_RESOURCE_MEMORY24; + +typedef struct acpi_resource_memory32 +{ + UINT8 WriteProtect; + UINT32 Minimum; + UINT32 Maximum; + UINT32 Alignment; + UINT32 AddressLength; + +} ACPI_RESOURCE_MEMORY32; + +typedef struct acpi_resource_fixed_memory32 +{ + UINT8 WriteProtect; + UINT32 Address; + UINT32 AddressLength; + +} ACPI_RESOURCE_FIXED_MEMORY32; + +typedef struct acpi_memory_attribute +{ + UINT8 WriteProtect; + UINT8 Caching; + UINT8 RangeType; + UINT8 Translation; + +} ACPI_MEMORY_ATTRIBUTE; + +typedef struct acpi_io_attribute +{ + UINT8 RangeType; + UINT8 Translation; + UINT8 TranslationType; + UINT8 Reserved1; + +} ACPI_IO_ATTRIBUTE; + +typedef union acpi_resource_attribute +{ + ACPI_MEMORY_ATTRIBUTE Mem; + ACPI_IO_ATTRIBUTE Io; + + /* Used for the *WordSpace macros */ + + UINT8 TypeSpecific; + +} ACPI_RESOURCE_ATTRIBUTE; + +typedef struct acpi_resource_source +{ + UINT8 Index; + UINT16 StringLength; + char *StringPtr; + +} ACPI_RESOURCE_SOURCE; + +/* Fields common to all address descriptors, 16/32/64 bit */ + +#define ACPI_RESOURCE_ADDRESS_COMMON \ + UINT8 ResourceType; \ + UINT8 ProducerConsumer; \ + UINT8 Decode; \ + UINT8 MinAddressFixed; \ + UINT8 MaxAddressFixed; \ + ACPI_RESOURCE_ATTRIBUTE Info; + +typedef struct acpi_resource_address +{ + ACPI_RESOURCE_ADDRESS_COMMON + +} ACPI_RESOURCE_ADDRESS; + +typedef struct acpi_resource_address16 +{ + ACPI_RESOURCE_ADDRESS_COMMON + UINT16 Granularity; + UINT16 Minimum; + UINT16 Maximum; + UINT16 TranslationOffset; + UINT16 AddressLength; + ACPI_RESOURCE_SOURCE ResourceSource; + +} ACPI_RESOURCE_ADDRESS16; + +typedef struct acpi_resource_address32 +{ + ACPI_RESOURCE_ADDRESS_COMMON + UINT32 Granularity; + UINT32 Minimum; + UINT32 Maximum; + UINT32 TranslationOffset; + UINT32 AddressLength; + ACPI_RESOURCE_SOURCE ResourceSource; + +} ACPI_RESOURCE_ADDRESS32; + +typedef struct acpi_resource_address64 +{ + ACPI_RESOURCE_ADDRESS_COMMON + UINT64 Granularity; + UINT64 Minimum; + UINT64 Maximum; + UINT64 TranslationOffset; + UINT64 AddressLength; + ACPI_RESOURCE_SOURCE ResourceSource; + +} ACPI_RESOURCE_ADDRESS64; + +typedef struct acpi_resource_extended_address64 +{ + ACPI_RESOURCE_ADDRESS_COMMON + UINT8 RevisionID; + UINT64 Granularity; + UINT64 Minimum; + UINT64 Maximum; + UINT64 TranslationOffset; + UINT64 AddressLength; + UINT64 TypeSpecific; + +} ACPI_RESOURCE_EXTENDED_ADDRESS64; + +typedef struct acpi_resource_extended_irq +{ + UINT8 ProducerConsumer; + UINT8 Triggering; + UINT8 Polarity; + UINT8 Sharable; + UINT8 InterruptCount; + ACPI_RESOURCE_SOURCE ResourceSource; + UINT32 Interrupts[1]; + +} ACPI_RESOURCE_EXTENDED_IRQ; + +typedef struct acpi_resource_generic_register +{ + UINT8 SpaceId; + UINT8 BitWidth; + UINT8 BitOffset; + UINT8 AccessSize; + UINT64 Address; + +} ACPI_RESOURCE_GENERIC_REGISTER; + + +/* ACPI_RESOURCE_TYPEs */ + +#define ACPI_RESOURCE_TYPE_IRQ 0 +#define ACPI_RESOURCE_TYPE_DMA 1 +#define ACPI_RESOURCE_TYPE_START_DEPENDENT 2 +#define ACPI_RESOURCE_TYPE_END_DEPENDENT 3 +#define ACPI_RESOURCE_TYPE_IO 4 +#define ACPI_RESOURCE_TYPE_FIXED_IO 5 +#define ACPI_RESOURCE_TYPE_VENDOR 6 +#define ACPI_RESOURCE_TYPE_END_TAG 7 +#define ACPI_RESOURCE_TYPE_MEMORY24 8 +#define ACPI_RESOURCE_TYPE_MEMORY32 9 +#define ACPI_RESOURCE_TYPE_FIXED_MEMORY32 10 +#define ACPI_RESOURCE_TYPE_ADDRESS16 11 +#define ACPI_RESOURCE_TYPE_ADDRESS32 12 +#define ACPI_RESOURCE_TYPE_ADDRESS64 13 +#define ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 14 /* ACPI 3.0 */ +#define ACPI_RESOURCE_TYPE_EXTENDED_IRQ 15 +#define ACPI_RESOURCE_TYPE_GENERIC_REGISTER 16 +#define ACPI_RESOURCE_TYPE_MAX 16 + +/* Master union for resource descriptors */ + +typedef union acpi_resource_data +{ + ACPI_RESOURCE_IRQ Irq; + ACPI_RESOURCE_DMA Dma; + ACPI_RESOURCE_START_DEPENDENT StartDpf; + ACPI_RESOURCE_IO Io; + ACPI_RESOURCE_FIXED_IO FixedIo; + ACPI_RESOURCE_VENDOR Vendor; + ACPI_RESOURCE_VENDOR_TYPED VendorTyped; + ACPI_RESOURCE_END_TAG EndTag; + ACPI_RESOURCE_MEMORY24 Memory24; + ACPI_RESOURCE_MEMORY32 Memory32; + ACPI_RESOURCE_FIXED_MEMORY32 FixedMemory32; + ACPI_RESOURCE_ADDRESS16 Address16; + ACPI_RESOURCE_ADDRESS32 Address32; + ACPI_RESOURCE_ADDRESS64 Address64; + ACPI_RESOURCE_EXTENDED_ADDRESS64 ExtAddress64; + ACPI_RESOURCE_EXTENDED_IRQ ExtendedIrq; + ACPI_RESOURCE_GENERIC_REGISTER GenericReg; + + /* Common fields */ + + ACPI_RESOURCE_ADDRESS Address; /* Common 16/32/64 address fields */ + +} ACPI_RESOURCE_DATA; + + +/* Common resource header */ + +typedef struct acpi_resource +{ + UINT32 Type; + UINT32 Length; + ACPI_RESOURCE_DATA Data; + +} ACPI_RESOURCE; + +/* restore default alignment */ + +#pragma pack() + + +#define ACPI_RS_SIZE_NO_DATA 8 /* Id + Length fields */ +#define ACPI_RS_SIZE_MIN (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (12) +#define ACPI_RS_SIZE(Type) (UINT32) (ACPI_RS_SIZE_NO_DATA + sizeof (Type)) + +#define ACPI_NEXT_RESOURCE(Res) (ACPI_RESOURCE *)((UINT8 *) Res + Res->Length) + + +typedef struct acpi_pci_routing_table +{ + UINT32 Length; + UINT32 Pin; + ACPI_INTEGER Address; /* here for 64-bit alignment */ + UINT32 SourceIndex; + char Source[4]; /* pad to 64 bits so sizeof() works in all cases */ + +} ACPI_PCI_ROUTING_TABLE; + +#endif /* __ACRESTYP_H__ */ + diff --git a/reactos/drivers/bus/acpi/acpica/include/acstruct.h b/reactos/drivers/bus/acpi/acpica/include/acstruct.h new file mode 100644 index 00000000000..45c85fe0b2f --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/acstruct.h @@ -0,0 +1,326 @@ +/****************************************************************************** + * + * Name: acstruct.h - Internal structs + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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. + * + *****************************************************************************/ + +#ifndef __ACSTRUCT_H__ +#define __ACSTRUCT_H__ + +/* acpisrc:StructDefs -- for acpisrc conversion */ + +/***************************************************************************** + * + * Tree walking typedefs and structs + * + ****************************************************************************/ + + +/* + * Walk state - current state of a parse tree walk. Used for both a leisurely + * stroll through the tree (for whatever reason), and for control method + * execution. + */ +#define ACPI_NEXT_OP_DOWNWARD 1 +#define ACPI_NEXT_OP_UPWARD 2 + +/* + * Groups of definitions for WalkType used for different implementations of + * walkers (never simultaneously) - flags for interpreter: + */ +#define ACPI_WALK_NON_METHOD 0 +#define ACPI_WALK_METHOD 0x01 +#define ACPI_WALK_METHOD_RESTART 0x02 + +/* Flags for iASL compiler only */ + +#define ACPI_WALK_CONST_REQUIRED 0x10 +#define ACPI_WALK_CONST_OPTIONAL 0x20 + + +typedef struct acpi_walk_state +{ + struct acpi_walk_state *Next; /* Next WalkState in list */ + UINT8 DescriptorType; /* To differentiate various internal objs */ + UINT8 WalkType; + UINT16 Opcode; /* Current AML opcode */ + UINT8 NextOpInfo; /* Info about NextOp */ + UINT8 NumOperands; /* Stack pointer for Operands[] array */ + UINT8 OperandIndex; /* Index into operand stack, to be used by AcpiDsObjStackPush */ + ACPI_OWNER_ID OwnerId; /* Owner of objects created during the walk */ + BOOLEAN LastPredicate; /* Result of last predicate */ + UINT8 CurrentResult; + UINT8 ReturnUsed; + UINT8 ScopeDepth; + UINT8 PassNumber; /* Parse pass during table load */ + UINT8 ResultSize; /* Total elements for the result stack */ + UINT8 ResultCount; /* Current number of occupied elements of result stack */ + UINT32 AmlOffset; + UINT32 ArgTypes; + UINT32 MethodBreakpoint; /* For single stepping */ + UINT32 UserBreakpoint; /* User AML breakpoint */ + UINT32 ParseFlags; + + ACPI_PARSE_STATE ParserState; /* Current state of parser */ + UINT32 PrevArgTypes; + UINT32 ArgCount; /* push for fixed or var args */ + + struct acpi_namespace_node Arguments[ACPI_METHOD_NUM_ARGS]; /* Control method arguments */ + struct acpi_namespace_node LocalVariables[ACPI_METHOD_NUM_LOCALS]; /* Control method locals */ + union acpi_operand_object *Operands[ACPI_OBJ_NUM_OPERANDS + 1]; /* Operands passed to the interpreter (+1 for NULL terminator) */ + union acpi_operand_object **Params; + + UINT8 *AmlLastWhile; + union acpi_operand_object **CallerReturnDesc; + ACPI_GENERIC_STATE *ControlState; /* List of control states (nested IFs) */ + struct acpi_namespace_node *DeferredNode; /* Used when executing deferred opcodes */ + union acpi_operand_object *ImplicitReturnObj; + struct acpi_namespace_node *MethodCallNode; /* Called method Node*/ + ACPI_PARSE_OBJECT *MethodCallOp; /* MethodCall Op if running a method */ + union acpi_operand_object *MethodDesc; /* Method descriptor if running a method */ + struct acpi_namespace_node *MethodNode; /* Method node if running a method. */ + ACPI_PARSE_OBJECT *Op; /* Current parser op */ + const ACPI_OPCODE_INFO *OpInfo; /* Info on current opcode */ + ACPI_PARSE_OBJECT *Origin; /* Start of walk [Obsolete] */ + union acpi_operand_object *ResultObj; + ACPI_GENERIC_STATE *Results; /* Stack of accumulated results */ + union acpi_operand_object *ReturnDesc; /* Return object, if any */ + ACPI_GENERIC_STATE *ScopeInfo; /* Stack of nested scopes */ + ACPI_PARSE_OBJECT *PrevOp; /* Last op that was processed */ + ACPI_PARSE_OBJECT *NextOp; /* next op to be processed */ + ACPI_THREAD_STATE *Thread; + ACPI_PARSE_DOWNWARDS DescendingCallback; + ACPI_PARSE_UPWARDS AscendingCallback; + +} ACPI_WALK_STATE; + + +/* Info used by AcpiPsInitObjects */ + +typedef struct acpi_init_walk_info +{ + UINT16 MethodCount; + UINT16 DeviceCount; + UINT16 OpRegionCount; + UINT16 FieldCount; + UINT16 BufferCount; + UINT16 PackageCount; + UINT16 OpRegionInit; + UINT16 FieldInit; + UINT16 BufferInit; + UINT16 PackageInit; + UINT16 ObjectCount; + ACPI_OWNER_ID OwnerId; + UINT32 TableIndex; + +} ACPI_INIT_WALK_INFO; + + +typedef struct acpi_get_devices_info +{ + ACPI_WALK_CALLBACK UserFunction; + void *Context; + char *Hid; + +} ACPI_GET_DEVICES_INFO; + + +typedef union acpi_aml_operands +{ + ACPI_OPERAND_OBJECT *Operands[7]; + + struct + { + ACPI_OBJECT_INTEGER *Type; + ACPI_OBJECT_INTEGER *Code; + ACPI_OBJECT_INTEGER *Argument; + + } Fatal; + + struct + { + ACPI_OPERAND_OBJECT *Source; + ACPI_OBJECT_INTEGER *Index; + ACPI_OPERAND_OBJECT *Target; + + } Index; + + struct + { + ACPI_OPERAND_OBJECT *Source; + ACPI_OBJECT_INTEGER *Index; + ACPI_OBJECT_INTEGER *Length; + ACPI_OPERAND_OBJECT *Target; + + } Mid; + +} ACPI_AML_OPERANDS; + + +/* + * Structure used to pass object evaluation parameters. + * Purpose is to reduce CPU stack use. + */ +typedef struct acpi_evaluate_info +{ + ACPI_NAMESPACE_NODE *PrefixNode; + char *Pathname; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT **Parameters; + ACPI_NAMESPACE_NODE *ResolvedNode; + ACPI_OPERAND_OBJECT *ReturnObject; + UINT8 ParamCount; + UINT8 PassNumber; + UINT8 ReturnObjectType; + UINT8 Flags; + +} ACPI_EVALUATE_INFO; + +/* Values for Flags above */ + +#define ACPI_IGNORE_RETURN_VALUE 1 + + +/* Info used by AcpiNsInitializeDevices */ + +typedef struct acpi_device_walk_info +{ + UINT16 DeviceCount; + UINT16 Num_STA; + UINT16 Num_INI; + ACPI_TABLE_DESC *TableDesc; + ACPI_EVALUATE_INFO *EvaluateInfo; + +} ACPI_DEVICE_WALK_INFO; + + +/* TBD: [Restructure] Merge with struct above */ + +typedef struct acpi_walk_info +{ + UINT32 DebugLevel; + UINT32 Count; + ACPI_OWNER_ID OwnerId; + UINT8 DisplayType; + +} ACPI_WALK_INFO; + +/* Display Types */ + +#define ACPI_DISPLAY_SUMMARY (UINT8) 0 +#define ACPI_DISPLAY_OBJECTS (UINT8) 1 +#define ACPI_DISPLAY_MASK (UINT8) 1 + +#define ACPI_DISPLAY_SHORT (UINT8) 2 + + +#endif diff --git a/reactos/drivers/bus/acpi/acpica/include/actables.h b/reactos/drivers/bus/acpi/acpica/include/actables.h new file mode 100644 index 00000000000..e4428e64155 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/actables.h @@ -0,0 +1,243 @@ +/****************************************************************************** + * + * Name: actables.h - ACPI table management + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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. + * + *****************************************************************************/ + +#ifndef __ACTABLES_H__ +#define __ACTABLES_H__ + + +ACPI_STATUS +AcpiAllocateRootTable ( + UINT32 InitialTableCount); + +/* + * tbfadt - FADT parse/convert/validate + */ +void +AcpiTbParseFadt ( + UINT32 TableIndex); + +void +AcpiTbCreateLocalFadt ( + ACPI_TABLE_HEADER *Table, + UINT32 Length); + + +/* + * tbfind - find ACPI table + */ +ACPI_STATUS +AcpiTbFindTable ( + char *Signature, + char *OemId, + char *OemTableId, + UINT32 *TableIndex); + + +/* + * tbinstal - Table removal and deletion + */ +ACPI_STATUS +AcpiTbResizeRootTableList ( + void); + +ACPI_STATUS +AcpiTbVerifyTable ( + ACPI_TABLE_DESC *TableDesc); + +ACPI_STATUS +AcpiTbAddTable ( + ACPI_TABLE_DESC *TableDesc, + UINT32 *TableIndex); + +ACPI_STATUS +AcpiTbStoreTable ( + ACPI_PHYSICAL_ADDRESS Address, + ACPI_TABLE_HEADER *Table, + UINT32 Length, + UINT8 Flags, + UINT32 *TableIndex); + +void +AcpiTbDeleteTable ( + ACPI_TABLE_DESC *TableDesc); + +void +AcpiTbTerminate ( + void); + +ACPI_STATUS +AcpiTbDeleteNamespaceByOwner ( + UINT32 TableIndex); + +ACPI_STATUS +AcpiTbAllocateOwnerId ( + UINT32 TableIndex); + +ACPI_STATUS +AcpiTbReleaseOwnerId ( + UINT32 TableIndex); + +ACPI_STATUS +AcpiTbGetOwnerId ( + UINT32 TableIndex, + ACPI_OWNER_ID *OwnerId); + +BOOLEAN +AcpiTbIsTableLoaded ( + UINT32 TableIndex); + +void +AcpiTbSetTableLoadedFlag ( + UINT32 TableIndex, + BOOLEAN IsLoaded); + + +/* + * tbutils - table manager utilities + */ +ACPI_STATUS +AcpiTbInitializeFacs ( + void); + +BOOLEAN +AcpiTbTablesLoaded ( + void); + +void +AcpiTbPrintTableHeader( + ACPI_PHYSICAL_ADDRESS Address, + ACPI_TABLE_HEADER *Header); + +UINT8 +AcpiTbChecksum ( + UINT8 *Buffer, + UINT32 Length); + +ACPI_STATUS +AcpiTbVerifyChecksum ( + ACPI_TABLE_HEADER *Table, + UINT32 Length); + +void +AcpiTbInstallTable ( + ACPI_PHYSICAL_ADDRESS Address, + char *Signature, + UINT32 TableIndex); + +ACPI_STATUS +AcpiTbParseRootTable ( + ACPI_PHYSICAL_ADDRESS RsdpAddress); + +#endif /* __ACTABLES_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/actbl.h b/reactos/drivers/bus/acpi/acpica/include/actbl.h new file mode 100644 index 00000000000..caa3bdbe3b5 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/actbl.h @@ -0,0 +1,451 @@ +/****************************************************************************** + * + * Name: actbl.h - Basic ACPI Table Definitions + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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. + * + *****************************************************************************/ + +#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 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 */ +#define ACPI_SIG_FACS "FACS" /* Firmware ACPI Control Structure */ +#define ACPI_SIG_PSDT "PSDT" /* Persistent System Description Table */ +#define ACPI_SIG_RSDP "RSD PTR " /* Root System Description Pointer */ +#define ACPI_SIG_RSDT "RSDT" /* Root System Description Table */ +#define ACPI_SIG_XSDT "XSDT" /* Extended System Description Table */ +#define ACPI_SIG_SSDT "SSDT" /* Secondary System Description Table */ +#define ACPI_RSDP_NAME "RSDP" /* Short name for RSDP, not signature */ + + +/* + * All tables and structures 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. + */ + + +/******************************************************************************* + * + * Master ACPI Table Header. This common header is used by all ACPI tables + * except the RSDP and FACS. + * + ******************************************************************************/ + +typedef struct acpi_table_header +{ + char Signature[ACPI_NAME_SIZE]; /* ASCII table signature */ + UINT32 Length; /* Length of table in bytes, including this header */ + UINT8 Revision; /* ACPI Specification minor version # */ + UINT8 Checksum; /* To make sum of entire table == 0 */ + char OemId[ACPI_OEM_ID_SIZE]; /* ASCII OEM identification */ + char OemTableId[ACPI_OEM_TABLE_ID_SIZE]; /* ASCII OEM table identification */ + UINT32 OemRevision; /* OEM revision number */ + char AslCompilerId[ACPI_NAME_SIZE]; /* ASCII ASL compiler vendor ID */ + UINT32 AslCompilerRevision; /* ASL compiler version */ + +} 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 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 */ + UINT8 BitWidth; /* Size in bits of given register */ + UINT8 BitOffset; /* Bit offset within the register */ + UINT8 AccessWidth; /* Minimum Access size (ACPI 3.0) */ + UINT64 Address; /* 64-bit address of struct or register */ + +} ACPI_GENERIC_ADDRESS; + + +/******************************************************************************* + * + * RSDP - Root System Description Pointer (Signature is "RSD PTR ") + * Version 2 + * + ******************************************************************************/ + +typedef struct acpi_table_rsdp +{ + char Signature[8]; /* ACPI signature, contains "RSD PTR " */ + UINT8 Checksum; /* ACPI 1.0 checksum */ + char OemId[ACPI_OEM_ID_SIZE]; /* OEM identification */ + UINT8 Revision; /* Must be (0) for ACPI 1.0 or (2) for ACPI 2.0+ */ + UINT32 RsdtPhysicalAddress; /* 32-bit physical address of the RSDT */ + UINT32 Length; /* Table length in bytes, including header (ACPI 2.0+) */ + UINT64 XsdtPhysicalAddress; /* 64-bit physical address of the XSDT (ACPI 2.0+) */ + UINT8 ExtendedChecksum; /* Checksum of entire table (ACPI 2.0+) */ + UINT8 Reserved[3]; /* Reserved, must be zero */ + +} ACPI_TABLE_RSDP; + +#define ACPI_RSDP_REV0_SIZE 20 /* Size of original ACPI 1.0 RSDP */ + + +/******************************************************************************* + * + * RSDT/XSDT - Root System Description Tables + * Version 1 (both) + * + ******************************************************************************/ + +typedef struct acpi_table_rsdt +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 TableOffsetEntry[1]; /* Array of pointers to ACPI tables */ + +} ACPI_TABLE_RSDT; + +typedef struct acpi_table_xsdt +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT64 TableOffsetEntry[1]; /* Array of pointers to ACPI tables */ + +} ACPI_TABLE_XSDT; + + +/******************************************************************************* + * + * FACS - Firmware ACPI Control Structure (FACS) + * + ******************************************************************************/ + +typedef struct acpi_table_facs +{ + char Signature[4]; /* ASCII table signature */ + UINT32 Length; /* Length of structure, in bytes */ + UINT32 HardwareSignature; /* Hardware configuration signature */ + UINT32 FirmwareWakingVector; /* 32-bit physical address of the Firmware Waking Vector */ + UINT32 GlobalLock; /* Global Lock for shared hardware resources */ + 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[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; + +/* 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 */ + +/* Masks for Flags field above */ + +#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) */ + +/* 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 + * + ******************************************************************************/ + +/* Fields common to all versions of the FADT */ + +typedef struct acpi_table_fadt +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 Facs; /* 32-bit physical address of FACS */ + UINT32 Dsdt; /* 32-bit physical address of DSDT */ + UINT8 Model; /* System Interrupt Model (ACPI 1.0) - not used in ACPI 2.0+ */ + UINT8 PreferredProfile; /* Conveys preferred power management profile to OSPM. */ + UINT16 SciInterrupt; /* System vector of SCI interrupt */ + UINT32 SmiCommand; /* 32-bit Port address of SMI command port */ + UINT8 AcpiEnable; /* Value to write to smi_cmd to enable ACPI */ + UINT8 AcpiDisable; /* Value to write to smi_cmd to disable ACPI */ + UINT8 S4BiosRequest; /* Value to write to SMI CMD to enter S4BIOS state */ + UINT8 PstateControl; /* Processor performance state control*/ + UINT32 Pm1aEventBlock; /* 32-bit Port address of Power Mgt 1a Event Reg Blk */ + UINT32 Pm1bEventBlock; /* 32-bit Port address of Power Mgt 1b Event Reg Blk */ + UINT32 Pm1aControlBlock; /* 32-bit Port address of Power Mgt 1a Control Reg Blk */ + UINT32 Pm1bControlBlock; /* 32-bit Port address of Power Mgt 1b Control Reg Blk */ + UINT32 Pm2ControlBlock; /* 32-bit Port address of Power Mgt 2 Control Reg Blk */ + UINT32 PmTimerBlock; /* 32-bit Port address of Power Mgt Timer Ctrl Reg Blk */ + UINT32 Gpe0Block; /* 32-bit Port address of General Purpose Event 0 Reg Blk */ + UINT32 Gpe1Block; /* 32-bit Port address of General Purpose Event 1 Reg Blk */ + UINT8 Pm1EventLength; /* Byte Length of ports at Pm1xEventBlock */ + UINT8 Pm1ControlLength; /* Byte Length of ports at Pm1xControlBlock */ + UINT8 Pm2ControlLength; /* Byte Length of ports at Pm2ControlBlock */ + UINT8 PmTimerLength; /* Byte Length of ports at PmTimerBlock */ + UINT8 Gpe0BlockLength; /* Byte Length of ports at Gpe0Block */ + UINT8 Gpe1BlockLength; /* Byte Length of ports at Gpe1Block */ + UINT8 Gpe1Base; /* Offset in GPE number space where GPE1 events start */ + UINT8 CstControl; /* Support for the _CST object and C States change notification */ + UINT16 C2Latency; /* Worst case HW latency to enter/exit C2 state */ + UINT16 C3Latency; /* Worst case HW latency to enter/exit C3 state */ + UINT16 FlushSize; /* Processor's memory cache line width, in bytes */ + UINT16 FlushStride; /* Number of flush strides that need to be read */ + UINT8 DutyOffset; /* Processor duty cycle index in processor's P_CNT reg */ + UINT8 DutyWidth; /* Processor duty cycle value bit width in P_CNT register */ + UINT8 DayAlarm; /* Index to day-of-month alarm in RTC CMOS RAM */ + UINT8 MonthAlarm; /* Index to month-of-year alarm in RTC CMOS RAM */ + UINT8 Century; /* Index to century in RTC CMOS RAM */ + UINT16 BootFlags; /* IA-PC Boot Architecture Flags (see below for individual flags) */ + UINT8 Reserved; /* Reserved, must be zero */ + UINT32 Flags; /* Miscellaneous flag bits (see below for individual flags) */ + ACPI_GENERIC_ADDRESS ResetRegister; /* 64-bit address of the Reset register */ + UINT8 ResetValue; /* Value to write to the ResetRegister port to reset the system */ + UINT8 Reserved4[3]; /* Reserved, must be zero */ + UINT64 XFacs; /* 64-bit physical address of FACS */ + UINT64 XDsdt; /* 64-bit physical address of DSDT */ + ACPI_GENERIC_ADDRESS XPm1aEventBlock; /* 64-bit Extended Power Mgt 1a Event Reg Blk address */ + ACPI_GENERIC_ADDRESS XPm1bEventBlock; /* 64-bit Extended Power Mgt 1b Event Reg Blk address */ + ACPI_GENERIC_ADDRESS XPm1aControlBlock; /* 64-bit Extended Power Mgt 1a Control Reg Blk address */ + ACPI_GENERIC_ADDRESS XPm1bControlBlock; /* 64-bit Extended Power Mgt 1b Control Reg Blk address */ + ACPI_GENERIC_ADDRESS XPm2ControlBlock; /* 64-bit Extended Power Mgt 2 Control Reg Blk address */ + ACPI_GENERIC_ADDRESS XPmTimerBlock; /* 64-bit Extended Power Mgt Timer Ctrl Reg Blk address */ + ACPI_GENERIC_ADDRESS XGpe0Block; /* 64-bit Extended General Purpose Event 0 Reg Blk address */ + ACPI_GENERIC_ADDRESS XGpe1Block; /* 64-bit Extended General Purpose Event 1 Reg Blk address */ + +} ACPI_TABLE_FADT; + + +/* 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 */ +#define ACPI_FADT_NO_VGA (1<<2) /* 02: [V4] It is not safe to probe for VGA hardware */ +#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 */ + +/* 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 */ +#define ACPI_FADT_C1_SUPPORTED (1<<2) /* 02: [V1] All processors support C1 state */ +#define ACPI_FADT_C2_MP_SUPPORTED (1<<3) /* 03: [V1] C2 state works on MP system */ +#define ACPI_FADT_POWER_BUTTON (1<<4) /* 04: [V1] Power button is handled as a control method device */ +#define ACPI_FADT_SLEEP_BUTTON (1<<5) /* 05: [V1] Sleep button is handled as a control method device */ +#define ACPI_FADT_FIXED_RTC (1<<6) /* 06: [V1] RTC wakeup status not in fixed register space */ +#define ACPI_FADT_S4_RTC_WAKE (1<<7) /* 07: [V1] RTC alarm can wake system from S4 */ +#define ACPI_FADT_32BIT_TIMER (1<<8) /* 08: [V1] ACPI timer width is 32-bit (0=24-bit) */ +#define ACPI_FADT_DOCKING_SUPPORTED (1<<9) /* 09: [V1] Docking supported */ +#define ACPI_FADT_RESET_REGISTER (1<<10) /* 10: [V2] System reset via the FADT RESET_REG supported */ +#define ACPI_FADT_SEALED_CASE (1<<11) /* 11: [V3] No internal expansion capabilities and case is sealed */ +#define ACPI_FADT_HEADLESS (1<<12) /* 12: [V3] No local video capabilities or local input devices */ +#define ACPI_FADT_SLEEP_TYPE (1<<13) /* 13: [V3] Must execute native instruction after writing SLP_TYPx register */ +#define ACPI_FADT_PCI_EXPRESS_WAKE (1<<14) /* 14: [V4] System supports PCIEXP_WAKE (STS/EN) bits (ACPI 3.0) */ +#define ACPI_FADT_PLATFORM_CLOCK (1<<15) /* 15: [V4] OSPM should use platform-provided timer (ACPI 3.0) */ +#define ACPI_FADT_S4_RTC_VALID (1<<16) /* 16: [V4] Contents of RTC_STS valid after S4 wake (ACPI 3.0) */ +#define ACPI_FADT_REMOTE_POWER_ON (1<<17) /* 17: [V4] System is compatible with remote power on (ACPI 3.0) */ +#define ACPI_FADT_APIC_CLUSTER (1<<18) /* 18: [V4] All local APICs must use cluster model (ACPI 3.0) */ +#define ACPI_FADT_APIC_PHYSICAL (1<<19) /* 19: [V4] All local xAPICs must use physical dest mode (ACPI 3.0) */ + + +/* Values for PreferredProfile (Prefered Power Management Profiles) */ + +enum AcpiPreferedPmProfiles +{ + PM_UNSPECIFIED = 0, + PM_DESKTOP = 1, + PM_MOBILE = 2, + PM_WORKSTATION = 3, + PM_ENTERPRISE_SERVER = 4, + PM_SOHO_SERVER = 5, + PM_APPLIANCE_PC = 6 +}; + + +/* Reset to default packing */ + +#pragma pack() + + +/* + * Internal table-related structures + */ +typedef union acpi_name_union +{ + UINT32 Integer; + char Ascii[4]; + +} ACPI_NAME_UNION; + + +/* Internal ACPI Table Descriptor. One per ACPI table. */ + +typedef struct acpi_table_desc +{ + ACPI_PHYSICAL_ADDRESS Address; + ACPI_TABLE_HEADER *Pointer; + UINT32 Length; /* Length fixed at 32 bits */ + ACPI_NAME_UNION Signature; + ACPI_OWNER_ID OwnerId; + UINT8 Flags; + +} ACPI_TABLE_DESC; + +/* Masks for Flags field above */ + +#define ACPI_TABLE_ORIGIN_UNKNOWN (0) +#define ACPI_TABLE_ORIGIN_MAPPED (1) +#define ACPI_TABLE_ORIGIN_ALLOCATED (2) +#define ACPI_TABLE_ORIGIN_OVERRIDE (4) +#define ACPI_TABLE_ORIGIN_MASK (7) +#define ACPI_TABLE_IS_LOADED (8) + + +/* + * 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) + +#endif /* __ACTBL_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/actbl1.h b/reactos/drivers/bus/acpi/acpica/include/actbl1.h new file mode 100644 index 00000000000..8af7a183808 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/actbl1.h @@ -0,0 +1,1145 @@ +/****************************************************************************** + * + * Name: actbl1.h - Additional ACPI table definitions + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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. + * + *****************************************************************************/ + +#ifndef __ACTBL1_H__ +#define __ACTBL1_H__ + + +/******************************************************************************* + * + * 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 for tables defined in this + * file. Useful because they make it more difficult to inadvertently type in + * the wrong signature. + */ +#define ACPI_SIG_BERT "BERT" /* Boot Error Record Table */ +#define ACPI_SIG_CPEP "CPEP" /* Corrected Platform Error Polling 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_MADT "APIC" /* Multiple APIC Description Table */ +#define ACPI_SIG_MSCT "MSCT" /* Maximum System Characteristics Table */ +#define ACPI_SIG_SBST "SBST" /* Smart Battery Specification Table */ +#define ACPI_SIG_SLIT "SLIT" /* System Locality Distance Information Table */ +#define ACPI_SIG_SRAT "SRAT" /* System Resource Affinity Table */ + + +/* + * 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. + */ + + +/******************************************************************************* + * + * Common subtable headers + * + ******************************************************************************/ + +/* Generic subtable header (used in MADT, SRAT, etc.) */ + +typedef struct acpi_subtable_header +{ + UINT8 Type; + UINT8 Length; + +} ACPI_SUBTABLE_HEADER; + + +/* Subtable header for WHEA tables (EINJ, ERST, WDAT) */ + +typedef struct acpi_whea_header +{ + UINT8 Action; + UINT8 Instruction; + UINT8 Flags; + UINT8 Reserved; + ACPI_GENERIC_ADDRESS RegisterRegion; + UINT64 Value; /* Value used with Read/Write register */ + UINT64 Mask; /* Bitmask required for this register instruction */ + +} ACPI_WHEA_HEADER; + + +/******************************************************************************* + * + * BERT - Boot Error Record Table (ACPI 4.0) + * Version 1 + * + ******************************************************************************/ + +typedef struct acpi_table_bert +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 RegionLength; /* Length of the boot error region */ + UINT64 Address; /* Physical addresss of the error region */ + +} ACPI_TABLE_BERT; + + +/* Boot Error Region (not a subtable, pointed to by Address field above) */ + +typedef struct acpi_bert_region +{ + 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; + +/* Values for BlockStatus flags above */ + +#define ACPI_BERT_UNCORRECTABLE (1) +#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 */ + +/* Values for ErrorSeverity above */ + +enum AcpiBertErrorSeverity +{ + 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 */ +}; + +/* + * 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 (ACPI 4.0) + * Version 1 + * + ******************************************************************************/ + +typedef struct acpi_table_cpep +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT64 Reserved; + +} ACPI_TABLE_CPEP; + + +/* Subtable */ + +typedef struct acpi_cpep_polling +{ + ACPI_SUBTABLE_HEADER Header; + UINT8 Id; /* Processor ID */ + UINT8 Eid; /* Processor EID */ + UINT32 Interval; /* Polling interval (msec) */ + +} ACPI_CPEP_POLLING; + + +/******************************************************************************* + * + * ECDT - Embedded Controller Boot Resources Table + * Version 1 + * + ******************************************************************************/ + +typedef struct acpi_table_ecdt +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + ACPI_GENERIC_ADDRESS Control; /* Address of EC command/status register */ + ACPI_GENERIC_ADDRESS Data; /* Address of EC data register */ + UINT32 Uid; /* Unique ID - must be same as the EC _UID method */ + UINT8 Gpe; /* The GPE for the EC */ + UINT8 Id[1]; /* Full namepath of the EC in the ACPI namespace */ + +} ACPI_TABLE_ECDT; + + +/******************************************************************************* + * + * EINJ - Error Injection Table (ACPI 4.0) + * Version 1 + * + ******************************************************************************/ + +typedef struct acpi_table_einj +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 HeaderLength; + UINT8 Flags; + UINT8 Reserved[3]; + UINT32 Entries; + +} ACPI_TABLE_EINJ; + + +/* EINJ Injection Instruction Entries (actions) */ + +typedef struct acpi_einj_entry +{ + ACPI_WHEA_HEADER WheaHeader; /* Common header for WHEA tables */ + +} ACPI_EINJ_ENTRY; + +/* Masks for Flags field above */ + +#define ACPI_EINJ_PRESERVE (1) + +/* Values for Action field above */ + +enum AcpiEinjActions +{ + ACPI_EINJ_BEGIN_OPERATION = 0, + ACPI_EINJ_GET_TRIGGER_TABLE = 1, + ACPI_EINJ_SET_ERROR_TYPE = 2, + ACPI_EINJ_GET_ERROR_TYPE = 3, + ACPI_EINJ_END_OPERATION = 4, + ACPI_EINJ_EXECUTE_OPERATION = 5, + ACPI_EINJ_CHECK_BUSY_STATUS = 6, + ACPI_EINJ_GET_COMMAND_STATUS = 7, + ACPI_EINJ_ACTION_RESERVED = 8, /* 8 and greater are reserved */ + ACPI_EINJ_TRIGGER_ERROR = 0xFF /* Except for this value */ +}; + +/* Values for Instruction field above */ + +enum AcpiEinjInstructions +{ + ACPI_EINJ_READ_REGISTER = 0, + ACPI_EINJ_READ_REGISTER_VALUE = 1, + ACPI_EINJ_WRITE_REGISTER = 2, + ACPI_EINJ_WRITE_REGISTER_VALUE = 3, + ACPI_EINJ_NOOP = 4, + ACPI_EINJ_INSTRUCTION_RESERVED = 5 /* 5 and greater are reserved */ +}; + + +/* EINJ Trigger Error Action Table */ + +typedef struct acpi_einj_trigger +{ + UINT32 HeaderSize; + UINT32 Revision; + UINT32 TableSize; + UINT32 EntryCount; + +} 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 (ACPI 4.0) + * Version 1 + * + ******************************************************************************/ + +typedef struct acpi_table_erst +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 HeaderLength; + UINT32 Reserved; + UINT32 Entries; + +} ACPI_TABLE_ERST; + + +/* ERST Serialization Entries (actions) */ + +typedef struct acpi_erst_entry +{ + ACPI_WHEA_HEADER WheaHeader; /* Common header for WHEA tables */ + +} ACPI_ERST_ENTRY; + +/* Masks for Flags field above */ + +#define ACPI_ERST_PRESERVE (1) + +/* Values for Action field above */ + +enum AcpiErstActions +{ + 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_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, + ACPI_ERST_GET_ERROR_RANGE = 13, + ACPI_ERST_GET_ERROR_LENGTH = 14, + ACPI_ERST_GET_ERROR_ATTRIBUTES = 15, + ACPI_ERST_ACTION_RESERVED = 16 /* 16 and greater are reserved */ +}; + +/* Values for Instruction field above */ + +enum AcpiErstInstructions +{ + ACPI_ERST_READ_REGISTER = 0, + ACPI_ERST_READ_REGISTER_VALUE = 1, + ACPI_ERST_WRITE_REGISTER = 2, + ACPI_ERST_WRITE_REGISTER_VALUE = 3, + ACPI_ERST_NOOP = 4, + ACPI_ERST_LOAD_VAR1 = 5, + ACPI_ERST_LOAD_VAR2 = 6, + ACPI_ERST_STORE_VAR1 = 7, + ACPI_ERST_ADD = 8, + ACPI_ERST_SUBTRACT = 9, + ACPI_ERST_ADD_VALUE = 10, + ACPI_ERST_SUBTRACT_VALUE = 11, + ACPI_ERST_STALL = 12, + ACPI_ERST_STALL_WHILE_TRUE = 13, + ACPI_ERST_SKIP_NEXT_IF_TRUE = 14, + ACPI_ERST_GOTO = 15, + ACPI_ERST_SET_SRC_ADDRESS_BASE = 16, + ACPI_ERST_SET_DST_ADDRESS_BASE = 17, + ACPI_ERST_MOVE_DATA = 18, + 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 (ACPI 4.0) + * Version 1 + * + ******************************************************************************/ + +typedef struct acpi_table_hest +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 ErrorSourceCount; + +} ACPI_TABLE_HEST; + + +/* HEST subtable header */ + +typedef struct acpi_hest_header +{ + UINT16 Type; + UINT16 SourceId; + +} ACPI_HEST_HEADER; + + +/* Values for Type field above for subtables */ + +enum AcpiHestTypes +{ + 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 substructures contained in subtables + */ + +/* + * 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 Reserved; + UINT32 ControlRegister; + UINT64 ControlData; + UINT32 StatusRegister; + UINT32 AddressRegister; + UINT32 MiscRegister; + +} ACPI_HEST_IA_ERROR_BANK; + + +/* Common HEST sub-structure for PCI/AER structures below (6,7,8) */ + +typedef struct acpi_hest_aer_common +{ + UINT16 Reserved1; + UINT8 Flags; + UINT8 Enabled; + UINT32 RecordsToPreallocate; + UINT32 MaxSectionsPerRecord; + UINT32 Bus; + UINT16 Device; + UINT16 Function; + UINT16 DeviceControl; + 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 */ + +typedef struct acpi_hest_notify +{ + UINT8 Type; + UINT8 Length; + UINT16 ConfigWriteEnable; + UINT32 PollInterval; + UINT32 Vector; + UINT32 PollingThresholdValue; + UINT32 PollingThresholdWindow; + UINT32 ErrorThresholdValue; + UINT32 ErrorThresholdWindow; + +} ACPI_HEST_NOTIFY; + +/* Values for Notify Type field above */ + +enum AcpiHestNotifyTypes +{ + ACPI_HEST_NOTIFY_POLLED = 0, + ACPI_HEST_NOTIFY_EXTERNAL = 1, + ACPI_HEST_NOTIFY_LOCAL = 2, + ACPI_HEST_NOTIFY_SCI = 3, + ACPI_HEST_NOTIFY_NMI = 4, + 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 + */ + +/* 0: IA32 Machine Check Exception */ + +typedef struct acpi_hest_ia_machine_check +{ + ACPI_HEST_HEADER Header; + UINT16 Reserved1; + UINT8 Flags; + UINT8 Enabled; + UINT32 RecordsToPreallocate; + UINT32 MaxSectionsPerRecord; + UINT64 GlobalCapabilityData; + UINT64 GlobalControlData; + UINT8 NumHardwareBanks; + UINT8 Reserved3[7]; + +} ACPI_HEST_IA_MACHINE_CHECK; + + +/* 1: IA32 Corrected Machine Check */ + +typedef struct acpi_hest_ia_corrected +{ + ACPI_HEST_HEADER Header; + UINT16 Reserved1; + UINT8 Flags; + UINT8 Enabled; + UINT32 RecordsToPreallocate; + UINT32 MaxSectionsPerRecord; + ACPI_HEST_NOTIFY Notify; + UINT8 NumHardwareBanks; + UINT8 Reserved2[3]; + +} ACPI_HEST_IA_CORRECTED; + + +/* 2: IA32 Non-Maskable Interrupt */ + +typedef struct acpi_hest_ia_nmi +{ + ACPI_HEST_HEADER Header; + UINT32 Reserved; + UINT32 RecordsToPreallocate; + UINT32 MaxSectionsPerRecord; + UINT32 MaxRawDataLength; + +} ACPI_HEST_IA_NMI; + + +/* 3,4,5: Not used */ + +/* 6: PCI Express Root Port AER */ + +typedef struct acpi_hest_aer_root +{ + ACPI_HEST_HEADER Header; + ACPI_HEST_AER_COMMON Aer; + UINT32 RootErrorCommand; + +} ACPI_HEST_AER_ROOT; + + +/* 7: PCI Express AER (AER Endpoint) */ + +typedef struct acpi_hest_aer +{ + ACPI_HEST_HEADER Header; + ACPI_HEST_AER_COMMON Aer; + +} ACPI_HEST_AER; + + +/* 8: PCI Express/PCI-X Bridge AER */ + +typedef struct acpi_hest_aer_bridge +{ + ACPI_HEST_HEADER Header; + ACPI_HEST_AER_COMMON Aer; + UINT32 UncorrectableMask2; + UINT32 UncorrectableSeverity2; + UINT32 AdvancedCapabilities2; + +} ACPI_HEST_AER_BRIDGE; + + +/* 9: Generic Hardware Error Source */ + +typedef struct acpi_hest_generic +{ + ACPI_HEST_HEADER Header; + UINT16 RelatedSourceId; + UINT8 Reserved; + UINT8 Enabled; + UINT32 RecordsToPreallocate; + UINT32 MaxSectionsPerRecord; + UINT32 MaxRawDataLength; + ACPI_GENERIC_ADDRESS ErrorStatusAddress; + ACPI_HEST_NOTIFY Notify; + UINT32 ErrorBlockLength; + +} ACPI_HEST_GENERIC; + + +/* Generic Error Status block */ + +typedef struct acpi_hest_generic_status +{ + UINT32 BlockStatus; + UINT32 RawDataOffset; + UINT32 RawDataLength; + UINT32 DataLength; + UINT32 ErrorSeverity; + +} ACPI_HEST_GENERIC_STATUS; + +/* Values for BlockStatus flags above */ + +#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 */ + + +/* Generic Error Data entry */ + +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; + + +/******************************************************************************* + * + * MADT - Multiple APIC Description Table + * Version 3 + * + ******************************************************************************/ + +typedef struct acpi_table_madt +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 Address; /* Physical address of local APIC */ + UINT32 Flags; + +} ACPI_TABLE_MADT; + +/* Masks for Flags field above */ + +#define ACPI_MADT_PCAT_COMPAT (1) /* 00: System also has dual 8259s */ + +/* Values for PCATCompat flag */ + +#define ACPI_MADT_DUAL_PIC 0 +#define ACPI_MADT_MULTIPLE_APIC 1 + + +/* Values for MADT subtable type in ACPI_SUBTABLE_HEADER */ + +enum AcpiMadtType +{ + ACPI_MADT_TYPE_LOCAL_APIC = 0, + ACPI_MADT_TYPE_IO_APIC = 1, + ACPI_MADT_TYPE_INTERRUPT_OVERRIDE = 2, + ACPI_MADT_TYPE_NMI_SOURCE = 3, + ACPI_MADT_TYPE_LOCAL_APIC_NMI = 4, + ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE = 5, + ACPI_MADT_TYPE_IO_SAPIC = 6, + ACPI_MADT_TYPE_LOCAL_SAPIC = 7, + ACPI_MADT_TYPE_INTERRUPT_SOURCE = 8, + ACPI_MADT_TYPE_LOCAL_X2APIC = 9, + ACPI_MADT_TYPE_LOCAL_X2APIC_NMI = 10, + ACPI_MADT_TYPE_RESERVED = 11 /* 11 and greater are reserved */ +}; + + +/* + * MADT Sub-tables, correspond to Type in ACPI_SUBTABLE_HEADER + */ + +/* 0: Processor Local APIC */ + +typedef struct acpi_madt_local_apic +{ + ACPI_SUBTABLE_HEADER Header; + UINT8 ProcessorId; /* ACPI processor id */ + UINT8 Id; /* Processor's local APIC id */ + UINT32 LapicFlags; + +} ACPI_MADT_LOCAL_APIC; + + +/* 1: IO APIC */ + +typedef struct acpi_madt_io_apic +{ + ACPI_SUBTABLE_HEADER Header; + UINT8 Id; /* I/O APIC ID */ + UINT8 Reserved; /* Reserved - must be zero */ + UINT32 Address; /* APIC physical address */ + UINT32 GlobalIrqBase; /* Global system interrupt where INTI lines start */ + +} ACPI_MADT_IO_APIC; + + +/* 2: Interrupt Override */ + +typedef struct acpi_madt_interrupt_override +{ + ACPI_SUBTABLE_HEADER Header; + UINT8 Bus; /* 0 - ISA */ + UINT8 SourceIrq; /* Interrupt source (IRQ) */ + UINT32 GlobalIrq; /* Global system interrupt */ + UINT16 IntiFlags; + +} ACPI_MADT_INTERRUPT_OVERRIDE; + + +/* 3: NMI Source */ + +typedef struct acpi_madt_nmi_source +{ + ACPI_SUBTABLE_HEADER Header; + UINT16 IntiFlags; + UINT32 GlobalIrq; /* Global system interrupt */ + +} ACPI_MADT_NMI_SOURCE; + + +/* 4: Local APIC NMI */ + +typedef struct acpi_madt_local_apic_nmi +{ + ACPI_SUBTABLE_HEADER Header; + UINT8 ProcessorId; /* ACPI processor id */ + UINT16 IntiFlags; + UINT8 Lint; /* LINTn to which NMI is connected */ + +} ACPI_MADT_LOCAL_APIC_NMI; + + +/* 5: Address Override */ + +typedef struct acpi_madt_local_apic_override +{ + ACPI_SUBTABLE_HEADER Header; + UINT16 Reserved; /* Reserved, must be zero */ + UINT64 Address; /* APIC physical address */ + +} ACPI_MADT_LOCAL_APIC_OVERRIDE; + + +/* 6: I/O Sapic */ + +typedef struct acpi_madt_io_sapic +{ + ACPI_SUBTABLE_HEADER Header; + UINT8 Id; /* I/O SAPIC ID */ + UINT8 Reserved; /* Reserved, must be zero */ + UINT32 GlobalIrqBase; /* Global interrupt for SAPIC start */ + UINT64 Address; /* SAPIC physical address */ + +} ACPI_MADT_IO_SAPIC; + + +/* 7: Local Sapic */ + +typedef struct acpi_madt_local_sapic +{ + ACPI_SUBTABLE_HEADER Header; + UINT8 ProcessorId; /* ACPI processor id */ + UINT8 Id; /* SAPIC ID */ + UINT8 Eid; /* SAPIC EID */ + UINT8 Reserved[3]; /* Reserved, must be zero */ + UINT32 LapicFlags; + UINT32 Uid; /* Numeric UID - ACPI 3.0 */ + char UidString[1]; /* String UID - ACPI 3.0 */ + +} ACPI_MADT_LOCAL_SAPIC; + + +/* 8: Platform Interrupt Source */ + +typedef struct acpi_madt_interrupt_source +{ + ACPI_SUBTABLE_HEADER Header; + UINT16 IntiFlags; + UINT8 Type; /* 1=PMI, 2=INIT, 3=corrected */ + UINT8 Id; /* Processor ID */ + UINT8 Eid; /* Processor EID */ + UINT8 IoSapicVector; /* Vector value for PMI interrupts */ + UINT32 GlobalIrq; /* Global system interrupt */ + UINT32 Flags; /* Interrupt Source Flags */ + +} ACPI_MADT_INTERRUPT_SOURCE; + +/* Masks for Flags field above */ + +#define ACPI_MADT_CPEI_OVERRIDE (1) + + +/* 9: Processor Local X2APIC (ACPI 4.0) */ + +typedef struct acpi_madt_local_x2apic +{ + ACPI_SUBTABLE_HEADER Header; + UINT16 Reserved; /* Reserved - must be zero */ + UINT32 LocalApicId; /* Processor x2APIC ID */ + UINT32 LapicFlags; + UINT32 Uid; /* ACPI processor UID */ + +} ACPI_MADT_LOCAL_X2APIC; + + +/* 10: Local X2APIC NMI (ACPI 4.0) */ + +typedef struct acpi_madt_local_x2apic_nmi +{ + ACPI_SUBTABLE_HEADER Header; + UINT16 IntiFlags; + UINT32 Uid; /* ACPI processor UID */ + UINT8 Lint; /* LINTn to which NMI is connected */ + UINT8 Reserved[3]; /* Reserved - must be zero */ + +} ACPI_MADT_LOCAL_X2APIC_NMI; + + +/* + * Common flags fields for MADT subtables + */ + +/* MADT Local APIC flags (LapicFlags) */ + +#define ACPI_MADT_ENABLED (1) /* 00: Processor is usable if set */ + +/* MADT MPS INTI flags (IntiFlags) */ + +#define ACPI_MADT_POLARITY_MASK (3) /* 00-01: Polarity of APIC I/O input signals */ +#define ACPI_MADT_TRIGGER_MASK (3<<2) /* 02-03: Trigger mode of APIC input signals */ + +/* Values for MPS INTI flags */ + +#define ACPI_MADT_POLARITY_CONFORMS 0 +#define ACPI_MADT_POLARITY_ACTIVE_HIGH 1 +#define ACPI_MADT_POLARITY_RESERVED 2 +#define ACPI_MADT_POLARITY_ACTIVE_LOW 3 + +#define ACPI_MADT_TRIGGER_CONFORMS (0) +#define ACPI_MADT_TRIGGER_EDGE (1<<2) +#define ACPI_MADT_TRIGGER_RESERVED (2<<2) +#define ACPI_MADT_TRIGGER_LEVEL (3<<2) + + +/******************************************************************************* + * + * MSCT - Maximum System Characteristics Table (ACPI 4.0) + * Version 1 + * + ******************************************************************************/ + +typedef struct acpi_table_msct +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + 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_MSCT; + + +/* Subtable - Maximum Proximity Domain Information. Version 1 */ + +typedef struct acpi_msct_proximity +{ + UINT8 Revision; + UINT8 Length; + UINT32 RangeStart; /* Start of domain range */ + UINT32 RangeEnd; /* End of domain range */ + UINT32 ProcessorCapacity; + UINT64 MemoryCapacity; /* In bytes */ + +} ACPI_MSCT_PROXIMITY; + + +/******************************************************************************* + * + * SBST - Smart Battery Specification Table + * Version 1 + * + ******************************************************************************/ + +typedef struct acpi_table_sbst +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 WarningLevel; + UINT32 LowLevel; + UINT32 CriticalLevel; + +} ACPI_TABLE_SBST; + + +/******************************************************************************* + * + * SLIT - System Locality Distance Information Table + * Version 1 + * + ******************************************************************************/ + +typedef struct acpi_table_slit +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT64 LocalityCount; + UINT8 Entry[1]; /* Real size = localities^2 */ + +} ACPI_TABLE_SLIT; + + +/******************************************************************************* + * + * SRAT - System Resource Affinity Table + * Version 3 + * + ******************************************************************************/ + +typedef struct acpi_table_srat +{ + ACPI_TABLE_HEADER Header; /* Common ACPI table header */ + UINT32 TableRevision; /* Must be value '1' */ + UINT64 Reserved; /* Reserved, must be zero */ + +} ACPI_TABLE_SRAT; + +/* Values for subtable type in ACPI_SUBTABLE_HEADER */ + +enum AcpiSratType +{ + ACPI_SRAT_TYPE_CPU_AFFINITY = 0, + ACPI_SRAT_TYPE_MEMORY_AFFINITY = 1, + ACPI_SRAT_TYPE_X2APIC_CPU_AFFINITY = 2, + ACPI_SRAT_TYPE_RESERVED = 3 /* 3 and greater are reserved */ +}; + +/* + * SRAT Sub-tables, correspond to Type in ACPI_SUBTABLE_HEADER + */ + +/* 0: Processor Local APIC/SAPIC Affinity */ + +typedef struct acpi_srat_cpu_affinity +{ + ACPI_SUBTABLE_HEADER Header; + UINT8 ProximityDomainLo; + UINT8 ApicId; + UINT32 Flags; + UINT8 LocalSapicEid; + UINT8 ProximityDomainHi[3]; + UINT32 Reserved; /* Reserved, must be zero */ + +} 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 +{ + ACPI_SUBTABLE_HEADER Header; + UINT32 ProximityDomain; + UINT16 Reserved; /* Reserved, must be zero */ + UINT64 BaseAddress; + UINT64 Length; + UINT32 Reserved1; + UINT32 Flags; + UINT64 Reserved2; /* Reserved, must be zero */ + +} ACPI_SRAT_MEM_AFFINITY; + +/* Flags */ + +#define ACPI_SRAT_MEM_ENABLED (1) /* 00: Use affinity structure */ +#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 (ACPI 4.0) */ + +typedef struct acpi_srat_x2apic_cpu_affinity +{ + ACPI_SUBTABLE_HEADER Header; + UINT16 Reserved; /* Reserved, must be zero */ + UINT32 ProximityDomain; + UINT32 ApicId; + UINT32 Flags; + UINT32 ClockDomain; + UINT32 Reserved2; + +} ACPI_SRAT_X2APIC_CPU_AFFINITY; + +/* Flags for ACPI_SRAT_CPU_AFFINITY and ACPI_SRAT_X2APIC_CPU_AFFINITY */ + +#define ACPI_SRAT_CPU_ENABLED (1) /* 00: Use affinity structure */ + + +/* Reset to default packing */ + +#pragma pack() + +#endif /* __ACTBL1_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/actbl2.h b/reactos/drivers/bus/acpi/acpica/include/actbl2.h new file mode 100644 index 00000000000..e57c02356cc --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/actbl2.h @@ -0,0 +1,1124 @@ +/****************************************************************************** + * + * Name: actbl2.h - ACPI Specification Revision 2.0 Tables + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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. + * + *****************************************************************************/ + +#ifndef __ACTBL2_H__ +#define __ACTBL2_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_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_WDRT "WDRT" /* Watchdog Resource Table */ + + +/* + * 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; + + +/******************************************************************************* + * + * 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 */ +}; + + +/******************************************************************************* + * + * 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/reactos/drivers/bus/acpi/acpica/include/actbl71.h b/reactos/drivers/bus/acpi/acpica/include/actbl71.h new file mode 100644 index 00000000000..0390d6f8de6 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/actbl71.h @@ -0,0 +1,144 @@ +/****************************************************************************** + * + * Name: actbl71.h - IA-64 Extensions to the ACPI Spec Rev. 0.71 + * This file includes tables specific to this + * specification revision. + * $Revision: 1.1 $ + * + *****************************************************************************/ + +/* + * Copyright (C) 2000, 2001 R. Byron Moore + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __ACTBL71_H__ +#define __ACTBL71_H__ + +/* 0.71 FADT Address_space data item bitmasks defines */ +/* If the associated bit is zero then it is in memory space else in io space */ +#define SMI_CMD_ADDRESS_SPACE 0x01 +#define PM1_BLK_ADDRESS_SPACE 0x02 +#define PM2_CNT_BLK_ADDRESS_SPACE 0x04 +#define PM_TMR_BLK_ADDRESS_SPACE 0x08 +#define GPE0_BLK_ADDRESS_SPACE 0x10 +#define GPE1_BLK_ADDRESS_SPACE 0x20 + +/* Only for clarity in declarations */ +typedef UINT64 IO_ADDRESS; + +#pragma pack(1) + +typedef struct /* Root System Descriptor Pointer */ +{ + NATIVE_CHAR signature [8]; /* contains "RSD PTR " */ + u8 checksum; /* to make sum of struct == 0 */ + NATIVE_CHAR oem_id [6]; /* OEM identification */ + u8 reserved; /* Must be 0 for 1.0, 2 for 2.0 */ + UINT64 rsdt_physical_address; /* 64-bit physical address of RSDT */ +} RSDP_DESCRIPTOR_REV071; + + +/*****************************************/ +/* IA64 Extensions to ACPI Spec Rev 0.71 */ +/* for the Root System Description Table */ +/*****************************************/ +typedef struct +{ + ACPI_TABLE_HEADER header; /* Table header */ + u32 reserved_pad; /* IA64 alignment, must be 0 */ + UINT64 table_offset_entry [1]; /* Array of pointers to other */ + /* tables' headers */ +} RSDT_DESCRIPTOR_REV071; + + +/*******************************************/ +/* IA64 Extensions to ACPI Spec Rev 0.71 */ +/* for the Firmware ACPI Control Structure */ +/*******************************************/ +typedef struct +{ + NATIVE_CHAR signature[4]; /* signature "FACS" */ + u32 length; /* length of structure, in bytes */ + u32 hardware_signature; /* hardware configuration signature */ + u32 reserved4; /* must be 0 */ + UINT64 firmware_waking_vector; /* ACPI OS waking vector */ + UINT64 global_lock; /* Global Lock */ + u32 S4_bios_f : 1; /* Indicates if S4_bIOS support is present */ + u32 reserved1 : 31; /* must be 0 */ + u8 reserved3 [28]; /* reserved - must be zero */ + +} FACS_DESCRIPTOR_REV071; + + +/******************************************/ +/* IA64 Extensions to ACPI Spec Rev 0.71 */ +/* for the Fixed ACPI Description Table */ +/******************************************/ +typedef struct +{ + ACPI_TABLE_HEADER header; /* table header */ + u32 reserved_pad; /* IA64 alignment, must be 0 */ + UINT64 firmware_ctrl; /* 64-bit Physical address of FACS */ + UINT64 dsdt; /* 64-bit Physical address of DSDT */ + u8 model; /* System Interrupt Model */ + u8 address_space; /* Address Space Bitmask */ + u16 sci_int; /* System vector of SCI interrupt */ + u8 acpi_enable; /* value to write to smi_cmd to enable ACPI */ + u8 acpi_disable; /* value to write to smi_cmd to disable ACPI */ + u8 S4_bios_req; /* Value to write to SMI CMD to enter S4_bIOS state */ + u8 reserved2; /* reserved - must be zero */ + UINT64 smi_cmd; /* Port address of SMI command port */ + UINT64 pm1a_evt_blk; /* Port address of Power Mgt 1a Acpi_event Reg Blk */ + UINT64 pm1b_evt_blk; /* Port address of Power Mgt 1b Acpi_event Reg Blk */ + UINT64 pm1a_cnt_blk; /* Port address of Power Mgt 1a Control Reg Blk */ + UINT64 pm1b_cnt_blk; /* Port address of Power Mgt 1b Control Reg Blk */ + UINT64 pm2_cnt_blk; /* Port address of Power Mgt 2 Control Reg Blk */ + UINT64 pm_tmr_blk; /* Port address of Power Mgt Timer Ctrl Reg Blk */ + UINT64 gpe0blk; /* Port addr of General Purpose Acpi_event 0 Reg Blk */ + UINT64 gpe1_blk; /* Port addr of General Purpose Acpi_event 1 Reg Blk */ + u8 pm1_evt_len; /* Byte Length of ports at pm1_x_evt_blk */ + u8 pm1_cnt_len; /* Byte Length of ports at pm1_x_cnt_blk */ + u8 pm2_cnt_len; /* Byte Length of ports at pm2_cnt_blk */ + u8 pm_tm_len; /* Byte Length of ports at pm_tm_blk */ + u8 gpe0blk_len; /* Byte Length of ports at gpe0_blk */ + u8 gpe1_blk_len; /* Byte Length of ports at gpe1_blk */ + u8 gpe1_base; /* offset in gpe model where gpe1 events start */ + u8 reserved3; /* reserved */ + u16 plvl2_lat; /* worst case HW latency to enter/exit C2 state */ + u16 plvl3_lat; /* worst case HW latency to enter/exit C3 state */ + u8 day_alrm; /* index to day-of-month alarm in RTC CMOS RAM */ + u8 mon_alrm; /* index to month-of-year alarm in RTC CMOS RAM */ + u8 century; /* index to century in RTC CMOS RAM */ + u8 reserved4; /* reserved */ + u32 flush_cash : 1; /* PAL_FLUSH_CACHE is correctly supported */ + u32 reserved5 : 1; /* reserved - must be zero */ + u32 proc_c1 : 1; /* all processors support C1 state */ + u32 plvl2_up : 1; /* C2 state works on MP system */ + u32 pwr_button : 1; /* Power button is handled as a generic feature */ + u32 sleep_button : 1; /* Sleep button is handled as a generic feature, or not present */ + u32 fixed_rTC : 1; /* RTC wakeup stat not in fixed register space */ + u32 rtcs4 : 1; /* RTC wakeup stat not possible from S4 */ + u32 tmr_val_ext : 1; /* tmr_val is 32 bits */ + u32 dock_cap : 1; /* Supports Docking */ + u32 reserved6 : 22; /* reserved - must be zero */ + +} FADT_DESCRIPTOR_REV071; + +#pragma pack() + +#endif /* __ACTBL71_H__ */ + diff --git a/reactos/drivers/bus/acpi/acpica/include/actypes.h b/reactos/drivers/bus/acpi/acpica/include/actypes.h new file mode 100644 index 00000000000..ef8d48bd29d --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/actypes.h @@ -0,0 +1,1248 @@ +/****************************************************************************** + * + * Name: actypes.h - Common data types for the entire ACPI subsystem + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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. + * + *****************************************************************************/ + +#ifndef __ACTYPES_H__ +#define __ACTYPES_H__ + +/* acpisrc:StructDefs -- for acpisrc conversion */ + +/* + * ACPI_MACHINE_WIDTH must be specified in an OS- or compiler-dependent header + * and must be either 32 or 64. 16-bit ACPICA is no longer supported, as of + * 12/2006. + */ +#ifndef ACPI_MACHINE_WIDTH +#error ACPI_MACHINE_WIDTH not defined +#endif + +/*! [Begin] no source code translation */ + +/* + * Data type ranges + * Note: These macros are designed to be compiler independent as well as + * working around problems that some 32-bit compilers have with 64-bit + * constants. + */ +#define ACPI_UINT8_MAX (UINT8) (~((UINT8) 0)) /* 0xFF */ +#define ACPI_UINT16_MAX (UINT16)(~((UINT16) 0)) /* 0xFFFF */ +#define ACPI_UINT32_MAX (UINT32)(~((UINT32) 0)) /* 0xFFFFFFFF */ +#define ACPI_UINT64_MAX (UINT64)(~((UINT64) 0)) /* 0xFFFFFFFFFFFFFFFF */ +#define ACPI_ASCII_MAX 0x7F + + +/* + * Architecture-specific ACPICA Subsystem Data Types + * + * The goal of these types is to provide source code portability across + * 16-bit, 32-bit, and 64-bit targets. + * + * 1) The following types are of fixed size for all targets (16/32/64): + * + * BOOLEAN Logical boolean + * + * UINT8 8-bit (1 byte) unsigned value + * UINT16 16-bit (2 byte) unsigned value + * UINT32 32-bit (4 byte) unsigned value + * UINT64 64-bit (8 byte) unsigned value + * + * INT16 16-bit (2 byte) signed value + * INT32 32-bit (4 byte) signed value + * INT64 64-bit (8 byte) signed value + * + * COMPILER_DEPENDENT_UINT64/INT64 - These types are defined in the + * compiler-dependent header(s) and were introduced because there is no common + * 64-bit integer type across the various compilation models, as shown in + * the table below. + * + * Datatype LP64 ILP64 LLP64 ILP32 LP32 16bit + * char 8 8 8 8 8 8 + * short 16 16 16 16 16 16 + * _int32 32 + * int 32 64 32 32 16 16 + * long 64 64 32 32 32 32 + * long long 64 64 + * pointer 64 64 64 32 32 32 + * + * Note: ILP64 and LP32 are currently not supported. + * + * + * 2) These types represent the native word size of the target mode of the + * processor, and may be 16-bit, 32-bit, or 64-bit as required. They are + * usually used for memory allocation, efficient loop counters, and array + * indexes. The types are similar to the size_t type in the C library and are + * required because there is no C type that consistently represents the native + * data width. ACPI_SIZE is needed because there is no guarantee that a + * kernel-level C library is present. + * + * ACPI_SIZE 16/32/64-bit unsigned value + * ACPI_NATIVE_INT 16/32/64-bit signed value + * + */ + +/******************************************************************************* + * + * Common types for all compilers, all targets + * + ******************************************************************************/ + +//typedef unsigned char BOOLEAN; +//typedef unsigned char UINT8; +//typedef unsigned short UINT16; +//typedef COMPILER_DEPENDENT_UINT64 UINT64; +//typedef COMPILER_DEPENDENT_INT64 INT64; + +/*! [End] no source code translation !*/ + + +/******************************************************************************* + * + * Types specific to 64-bit targets + * + ******************************************************************************/ + +#if ACPI_MACHINE_WIDTH == 64 + +/*! [Begin] no source code translation (keep the typedefs as-is) */ + +typedef unsigned int UINT32; +typedef int INT32; + +/*! [End] no source code translation !*/ + + +typedef INT64 ACPI_NATIVE_INT; +typedef UINT64 ACPI_SIZE; +typedef UINT64 ACPI_IO_ADDRESS; +typedef UINT64 ACPI_PHYSICAL_ADDRESS; + +#define ACPI_MAX_PTR ACPI_UINT64_MAX +#define ACPI_SIZE_MAX ACPI_UINT64_MAX +#define ACPI_USE_NATIVE_DIVIDE /* Has native 64-bit integer support */ + +/* + * In the case of the Itanium Processor Family (IPF), the hardware does not + * support misaligned memory transfers. Set the MISALIGNMENT_NOT_SUPPORTED flag + * to indicate that special precautions must be taken to avoid alignment faults. + * (IA64 or ia64 is currently used by existing compilers to indicate IPF.) + * + * Note: EM64T and other X86-64 processors support misaligned transfers, + * so there is no need to define this flag. + */ +#if defined (__IA64__) || defined (__ia64__) +#define ACPI_MISALIGNMENT_NOT_SUPPORTED +#endif + + +/******************************************************************************* + * + * Types specific to 32-bit targets + * + ******************************************************************************/ + +#elif ACPI_MACHINE_WIDTH == 32 + +/*! [Begin] no source code translation (keep the typedefs as-is) */ + +//typedef unsigned int UINT32; +//typedef int INT32; + +/*! [End] no source code translation !*/ + + +typedef INT32 ACPI_NATIVE_INT; +typedef UINT32 ACPI_SIZE; +typedef UINT32 ACPI_IO_ADDRESS; +typedef UINT32 ACPI_PHYSICAL_ADDRESS; + +#define ACPI_MAX_PTR ACPI_UINT32_MAX +#define ACPI_SIZE_MAX ACPI_UINT32_MAX + +#else + +/* ACPI_MACHINE_WIDTH must be either 64 or 32 */ + +#error unknown ACPI_MACHINE_WIDTH +#endif + + +/******************************************************************************* + * + * OS-dependent types + * + * If the defaults below are not appropriate for the host system, they can + * be defined in the OS-specific header, and this will take precedence. + * + ******************************************************************************/ + +/* Value returned by AcpiOsGetThreadId */ + +#ifndef ACPI_THREAD_ID +#define ACPI_THREAD_ID ACPI_SIZE +#endif + +/* Flags for AcpiOsAcquireLock/AcpiOsReleaseLock */ + +#ifndef ACPI_CPU_FLAGS +#define ACPI_CPU_FLAGS ACPI_SIZE +#endif + +/* Object returned from AcpiOsCreateCache */ + +#ifndef ACPI_CACHE_T +#ifdef ACPI_USE_LOCAL_CACHE +#define ACPI_CACHE_T ACPI_MEMORY_LIST +#else +#define ACPI_CACHE_T void * +#endif +#endif + +/* + * Synchronization objects - Mutexes, Semaphores, and SpinLocks + */ +#if (ACPI_MUTEX_TYPE == ACPI_BINARY_SEMAPHORE) +/* + * These macros are used if the host OS does not support a mutex object. + * Map the OSL Mutex interfaces to binary semaphores. + */ +#define ACPI_MUTEX ACPI_SEMAPHORE +#define AcpiOsCreateMutex(OutHandle) AcpiOsCreateSemaphore (1, 1, OutHandle) +#define AcpiOsDeleteMutex(Handle) (void) AcpiOsDeleteSemaphore (Handle) +#define AcpiOsAcquireMutex(Handle,Time) AcpiOsWaitSemaphore (Handle, 1, Time) +#define AcpiOsReleaseMutex(Handle) (void) AcpiOsSignalSemaphore (Handle, 1) +#endif + +/* Configurable types for synchronization objects */ + +#ifndef ACPI_SPINLOCK +#define ACPI_SPINLOCK void * +#endif + +#ifndef ACPI_SEMAPHORE +#define ACPI_SEMAPHORE void * +#endif + +#ifndef ACPI_MUTEX +#define ACPI_MUTEX void * +#endif + + +/******************************************************************************* + * + * Compiler-dependent types + * + * If the defaults below are not appropriate for the host compiler, they can + * be defined in the compiler-specific header, and this will take precedence. + * + ******************************************************************************/ + +/* Use C99 uintptr_t for pointer casting if available, "void *" otherwise */ + +#ifndef ACPI_UINTPTR_T +#define ACPI_UINTPTR_T void * +#endif + +/* + * ACPI_PRINTF_LIKE is used to tag functions as "printf-like" because + * some compilers can catch printf format string problems + */ +#ifndef ACPI_PRINTF_LIKE +#define ACPI_PRINTF_LIKE(c) +#endif + +/* + * Some compilers complain about unused variables. Sometimes we don't want to + * use all the variables (for example, _AcpiModuleName). This allows us + * to to tell the compiler in a per-variable manner that a variable + * is unused + */ +#ifndef ACPI_UNUSED_VAR +#define ACPI_UNUSED_VAR +#endif + +/* + * All ACPICA functions that are available to the rest of the kernel are + * tagged with this macro which can be defined as appropriate for the host. + */ +#ifndef ACPI_EXPORT_SYMBOL +#define ACPI_EXPORT_SYMBOL(Symbol) +#endif + + +/****************************************************************************** + * + * ACPI Specification constants (Do not change unless the specification changes) + * + *****************************************************************************/ + +/* Number of distinct FADT-based GPE register blocks (GPE0 and GPE1) */ + +#define ACPI_MAX_GPE_BLOCKS 2 + +/* Default ACPI register widths */ + +#define ACPI_GPE_REGISTER_WIDTH 8 +#define ACPI_PM1_REGISTER_WIDTH 16 +#define ACPI_PM2_REGISTER_WIDTH 8 +#define ACPI_PM_TIMER_WIDTH 32 + +/* Names within the namespace are 4 bytes long */ + +#define ACPI_NAME_SIZE 4 +#define ACPI_PATH_SEGMENT_LENGTH 5 /* 4 chars for name + 1 char for separator */ +#define ACPI_PATH_SEPARATOR '.' + +/* Sizes for ACPI table headers */ + +#define ACPI_OEM_ID_SIZE 6 +#define ACPI_OEM_TABLE_ID_SIZE 8 + +/* ACPI/PNP hardware IDs */ + +#define PCI_ROOT_HID_STRING "PNP0A03" +#define PCI_EXPRESS_ROOT_HID_STRING "PNP0A08" + +/* PM Timer ticks per second (HZ) */ + +#define PM_TIMER_FREQUENCY 3579545 + + +/******************************************************************************* + * + * Independent types + * + ******************************************************************************/ + +/* Logical defines and NULL */ + +#ifdef FALSE +#undef FALSE +#endif +#define FALSE (1 == 0) + +#ifdef TRUE +#undef TRUE +#endif +#define TRUE (1 == 1) + +#ifndef NULL +#define NULL (void *) 0 +#endif + + +/* + * Miscellaneous types + */ +typedef UINT32 ACPI_STATUS; /* All ACPI Exceptions */ +typedef UINT32 ACPI_NAME; /* 4-byte ACPI name */ +typedef char * ACPI_STRING; /* Null terminated ASCII string */ +typedef void * ACPI_HANDLE; /* Actually a ptr to a NS Node */ + + +/* Owner IDs are used to track namespace nodes for selective deletion */ + +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 +#define ACPI_MAX32_DECIMAL_DIGITS 10 +#define ACPI_MAX16_DECIMAL_DIGITS 5 +#define ACPI_MAX8_DECIMAL_DIGITS 3 + +/* + * Constants with special meanings + */ +#define ACPI_ROOT_OBJECT ACPI_ADD_PTR (ACPI_HANDLE, NULL, ACPI_MAX_PTR) +#define ACPI_WAIT_FOREVER 0xFFFF /* UINT16, as per ACPI spec */ +#define ACPI_DO_NOT_WAIT 0 + + +/******************************************************************************* + * + * Commonly used macros + * + ******************************************************************************/ + +/* Data manipulation */ + +#define ACPI_LOBYTE(Integer) ((UINT8) (UINT16)(Integer)) +#define ACPI_HIBYTE(Integer) ((UINT8) (((UINT16)(Integer)) >> 8)) +#define ACPI_LOWORD(Integer) ((UINT16) (UINT32)(Integer)) +#define ACPI_HIWORD(Integer) ((UINT16)(((UINT32)(Integer)) >> 16)) +#define ACPI_LODWORD(Integer64) ((UINT32) (UINT64)(Integer64)) +#define ACPI_HIDWORD(Integer64) ((UINT32)(((UINT64)(Integer64)) >> 32)) + +#define ACPI_SET_BIT(target,bit) ((target) |= (bit)) +#define ACPI_CLEAR_BIT(target,bit) ((target) &= ~(bit)) +#define ACPI_MIN(a,b) (((a)<(b))?(a):(b)) +#define ACPI_MAX(a,b) (((a)>(b))?(a):(b)) + +/* Size calculation */ + +#define ACPI_ARRAY_LENGTH(x) (sizeof(x) / sizeof((x)[0])) + +/* Pointer manipulation */ + +#define ACPI_CAST_PTR(t, p) ((t *) (ACPI_UINTPTR_T) (p)) +#define ACPI_CAST_INDIRECT_PTR(t, p) ((t **) (ACPI_UINTPTR_T) (p)) +#define ACPI_ADD_PTR(t, a, b) ACPI_CAST_PTR (t, (ACPI_CAST_PTR (UINT8, (a)) + (ACPI_SIZE)(b))) +#define ACPI_PTR_DIFF(a, b) (ACPI_SIZE) (ACPI_CAST_PTR (UINT8, (a)) - ACPI_CAST_PTR (UINT8, (b))) + +/* Pointer/Integer type conversions */ + +#define ACPI_TO_POINTER(i) ACPI_ADD_PTR (void, (void *) NULL,(ACPI_SIZE) i) +#define ACPI_TO_INTEGER(p) ACPI_PTR_DIFF (p, (void *) NULL) +#define ACPI_OFFSET(d, f) (ACPI_SIZE) ACPI_PTR_DIFF (&(((d *)0)->f), (void *) NULL) +#define ACPI_PHYSADDR_TO_PTR(i) ACPI_TO_POINTER(i) +#define ACPI_PTR_TO_PHYSADDR(i) ACPI_TO_INTEGER(i) + +#ifndef ACPI_MISALIGNMENT_NOT_SUPPORTED +#define ACPI_COMPARE_NAME(a,b) (*ACPI_CAST_PTR (UINT32, (a)) == *ACPI_CAST_PTR (UINT32, (b))) +#else +#define ACPI_COMPARE_NAME(a,b) (!ACPI_STRNCMP (ACPI_CAST_PTR (char, (a)), ACPI_CAST_PTR (char, (b)), ACPI_NAME_SIZE)) +#endif + + +/******************************************************************************* + * + * Miscellaneous constants + * + ******************************************************************************/ + +/* + * Initialization sequence + */ +#define ACPI_FULL_INITIALIZATION 0x00 +#define ACPI_NO_ADDRESS_SPACE_INIT 0x01 +#define ACPI_NO_HARDWARE_INIT 0x02 +#define ACPI_NO_EVENT_INIT 0x04 +#define ACPI_NO_HANDLER_INIT 0x08 +#define ACPI_NO_ACPI_ENABLE 0x10 +#define ACPI_NO_DEVICE_INIT 0x20 +#define ACPI_NO_OBJECT_INIT 0x40 + +/* + * Initialization state + */ +#define ACPI_SUBSYSTEM_INITIALIZE 0x01 +#define ACPI_INITIALIZED_OK 0x02 + +/* + * Power state values + */ +#define ACPI_STATE_UNKNOWN (UINT8) 0xFF + +#define ACPI_STATE_S0 (UINT8) 0 +#define ACPI_STATE_S1 (UINT8) 1 +#define ACPI_STATE_S2 (UINT8) 2 +#define ACPI_STATE_S3 (UINT8) 3 +#define ACPI_STATE_S4 (UINT8) 4 +#define ACPI_STATE_S5 (UINT8) 5 +#define ACPI_S_STATES_MAX ACPI_STATE_S5 +#define ACPI_S_STATE_COUNT 6 + +#define ACPI_STATE_D0 (UINT8) 0 +#define ACPI_STATE_D1 (UINT8) 1 +#define ACPI_STATE_D2 (UINT8) 2 +#define ACPI_STATE_D3 (UINT8) 3 +#define ACPI_D_STATES_MAX ACPI_STATE_D3 +#define ACPI_D_STATE_COUNT 4 + +#define ACPI_STATE_C0 (UINT8) 0 +#define ACPI_STATE_C1 (UINT8) 1 +#define ACPI_STATE_C2 (UINT8) 2 +#define ACPI_STATE_C3 (UINT8) 3 +#define ACPI_C_STATES_MAX ACPI_STATE_C3 +#define ACPI_C_STATE_COUNT 4 + +/* + * Sleep type invalid value + */ +#define ACPI_SLEEP_TYPE_MAX 0x7 +#define ACPI_SLEEP_TYPE_INVALID 0xFF + +/* + * Standard notify values + */ +#define ACPI_NOTIFY_BUS_CHECK (UINT8) 0x00 +#define ACPI_NOTIFY_DEVICE_CHECK (UINT8) 0x01 +#define ACPI_NOTIFY_DEVICE_WAKE (UINT8) 0x02 +#define ACPI_NOTIFY_EJECT_REQUEST (UINT8) 0x03 +#define ACPI_NOTIFY_DEVICE_CHECK_LIGHT (UINT8) 0x04 +#define ACPI_NOTIFY_FREQUENCY_MISMATCH (UINT8) 0x05 +#define ACPI_NOTIFY_BUS_MODE_MISMATCH (UINT8) 0x06 +#define ACPI_NOTIFY_POWER_FAULT (UINT8) 0x07 +#define ACPI_NOTIFY_CAPABILITIES_CHECK (UINT8) 0x08 +#define ACPI_NOTIFY_DEVICE_PLD_CHECK (UINT8) 0x09 +#define ACPI_NOTIFY_RESERVED (UINT8) 0x0A +#define ACPI_NOTIFY_LOCALITY_UPDATE (UINT8) 0x0B + +#define ACPI_NOTIFY_MAX 0x0B + +/* + * Types associated with ACPI names and objects. The first group of + * values (up to ACPI_TYPE_EXTERNAL_MAX) correspond to the definition + * of the ACPI ObjectType() operator (See the ACPI Spec). Therefore, + * only add to the first group if the spec changes. + * + * NOTE: Types must be kept in sync with the global AcpiNsProperties + * and AcpiNsTypeNames arrays. + */ +typedef UINT32 ACPI_OBJECT_TYPE; + +#define ACPI_TYPE_ANY 0x00 +#define ACPI_TYPE_INTEGER 0x01 /* Byte/Word/Dword/Zero/One/Ones */ +#define ACPI_TYPE_STRING 0x02 +#define ACPI_TYPE_BUFFER 0x03 +#define ACPI_TYPE_PACKAGE 0x04 /* ByteConst, multiple DataTerm/Constant/SuperName */ +#define ACPI_TYPE_FIELD_UNIT 0x05 +#define ACPI_TYPE_DEVICE 0x06 /* Name, multiple Node */ +#define ACPI_TYPE_EVENT 0x07 +#define ACPI_TYPE_METHOD 0x08 /* Name, ByteConst, multiple Code */ +#define ACPI_TYPE_MUTEX 0x09 +#define ACPI_TYPE_REGION 0x0A +#define ACPI_TYPE_POWER 0x0B /* Name,ByteConst,WordConst,multi Node */ +#define ACPI_TYPE_PROCESSOR 0x0C /* Name,ByteConst,DWordConst,ByteConst,multi NmO */ +#define ACPI_TYPE_THERMAL 0x0D /* Name, multiple Node */ +#define ACPI_TYPE_BUFFER_FIELD 0x0E +#define ACPI_TYPE_DDB_HANDLE 0x0F +#define ACPI_TYPE_DEBUG_OBJECT 0x10 + +#define ACPI_TYPE_EXTERNAL_MAX 0x10 + +/* + * These are object types that do not map directly to the ACPI + * ObjectType() operator. They are used for various internal purposes only. + * If new predefined ACPI_TYPEs are added (via the ACPI specification), these + * internal types must move upwards. (There is code that depends on these + * values being contiguous with the external types above.) + */ +#define ACPI_TYPE_LOCAL_REGION_FIELD 0x11 +#define ACPI_TYPE_LOCAL_BANK_FIELD 0x12 +#define ACPI_TYPE_LOCAL_INDEX_FIELD 0x13 +#define ACPI_TYPE_LOCAL_REFERENCE 0x14 /* Arg#, Local#, Name, Debug, RefOf, Index */ +#define ACPI_TYPE_LOCAL_ALIAS 0x15 +#define ACPI_TYPE_LOCAL_METHOD_ALIAS 0x16 +#define ACPI_TYPE_LOCAL_NOTIFY 0x17 +#define ACPI_TYPE_LOCAL_ADDRESS_HANDLER 0x18 +#define ACPI_TYPE_LOCAL_RESOURCE 0x19 +#define ACPI_TYPE_LOCAL_RESOURCE_FIELD 0x1A +#define ACPI_TYPE_LOCAL_SCOPE 0x1B /* 1 Name, multiple ObjectList Nodes */ + +#define ACPI_TYPE_NS_NODE_MAX 0x1B /* Last typecode used within a NS Node */ + +/* + * These are special object types that never appear in + * a Namespace node, only in an ACPI_OPERAND_OBJECT + */ +#define ACPI_TYPE_LOCAL_EXTRA 0x1C +#define ACPI_TYPE_LOCAL_DATA 0x1D + +#define ACPI_TYPE_LOCAL_MAX 0x1D + +/* All types above here are invalid */ + +#define ACPI_TYPE_INVALID 0x1E +#define ACPI_TYPE_NOT_FOUND 0xFF + +#define ACPI_NUM_NS_TYPES (ACPI_TYPE_INVALID + 1) + + +/* + * All I/O + */ +#define ACPI_READ 0 +#define ACPI_WRITE 1 +#define ACPI_IO_MASK 1 + +/* + * Event Types: Fixed & General Purpose + */ +typedef UINT32 ACPI_EVENT_TYPE; + +/* + * Fixed events + */ +#define ACPI_EVENT_PMTIMER 0 +#define ACPI_EVENT_GLOBAL 1 +#define ACPI_EVENT_POWER_BUTTON 2 +#define ACPI_EVENT_SLEEP_BUTTON 3 +#define ACPI_EVENT_RTC 4 +#define ACPI_EVENT_MAX 4 +#define ACPI_NUM_FIXED_EVENTS ACPI_EVENT_MAX + 1 + +/* + * Event Status - Per event + * ------------- + * The encoding of ACPI_EVENT_STATUS is illustrated below. + * Note that a set bit (1) indicates the property is TRUE + * (e.g. if bit 0 is set then the event is enabled). + * +-------------+-+-+-+ + * | Bits 31:3 |2|1|0| + * +-------------+-+-+-+ + * | | | | + * | | | +- Enabled? + * | | +--- Enabled for wake? + * | +----- Set? + * +----------- + */ +typedef UINT32 ACPI_EVENT_STATUS; + +#define ACPI_EVENT_FLAG_DISABLED (ACPI_EVENT_STATUS) 0x00 +#define ACPI_EVENT_FLAG_ENABLED (ACPI_EVENT_STATUS) 0x01 +#define ACPI_EVENT_FLAG_WAKE_ENABLED (ACPI_EVENT_STATUS) 0x02 +#define ACPI_EVENT_FLAG_SET (ACPI_EVENT_STATUS) 0x04 + +/* + * General Purpose Events (GPE) + */ +#define ACPI_GPE_INVALID 0xFF +#define ACPI_GPE_MAX 0xFF +#define ACPI_NUM_GPE 256 + +#define ACPI_GPE_ENABLE 0 +#define ACPI_GPE_DISABLE 1 + + +/* + * 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 + */ +#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_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_ENABLE_MASK (UINT8) 0x60 /* Both run/wake */ + +/* + * 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 + + +/* Notify types */ + +#define ACPI_SYSTEM_NOTIFY 0x1 +#define ACPI_DEVICE_NOTIFY 0x2 +#define ACPI_ALL_NOTIFY (ACPI_SYSTEM_NOTIFY | ACPI_DEVICE_NOTIFY) +#define ACPI_MAX_NOTIFY_HANDLER_TYPE 0x3 + +#define ACPI_MAX_SYS_NOTIFY 0x7f + + +/* Address Space (Operation Region) Types */ + +typedef UINT8 ACPI_ADR_SPACE_TYPE; + +#define ACPI_ADR_SPACE_SYSTEM_MEMORY (ACPI_ADR_SPACE_TYPE) 0 +#define ACPI_ADR_SPACE_SYSTEM_IO (ACPI_ADR_SPACE_TYPE) 1 +#define ACPI_ADR_SPACE_PCI_CONFIG (ACPI_ADR_SPACE_TYPE) 2 +#define ACPI_ADR_SPACE_EC (ACPI_ADR_SPACE_TYPE) 3 +#define ACPI_ADR_SPACE_SMBUS (ACPI_ADR_SPACE_TYPE) 4 +#define ACPI_ADR_SPACE_CMOS (ACPI_ADR_SPACE_TYPE) 5 +#define ACPI_ADR_SPACE_PCI_BAR_TARGET (ACPI_ADR_SPACE_TYPE) 6 +#define ACPI_ADR_SPACE_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 + + +/* + * BitRegister IDs + * + * These values are intended to be used by the hardware interfaces + * and are mapped to individual bitfields defined within the ACPI + * registers. See the AcpiGbl_BitRegisterInfo global table in utglobal.c + * for this mapping. + */ + +/* PM1 Status register */ + +#define ACPI_BITREG_TIMER_STATUS 0x00 +#define ACPI_BITREG_BUS_MASTER_STATUS 0x01 +#define ACPI_BITREG_GLOBAL_LOCK_STATUS 0x02 +#define ACPI_BITREG_POWER_BUTTON_STATUS 0x03 +#define ACPI_BITREG_SLEEP_BUTTON_STATUS 0x04 +#define ACPI_BITREG_RT_CLOCK_STATUS 0x05 +#define ACPI_BITREG_WAKE_STATUS 0x06 +#define ACPI_BITREG_PCIEXP_WAKE_STATUS 0x07 + +/* PM1 Enable register */ + +#define ACPI_BITREG_TIMER_ENABLE 0x08 +#define ACPI_BITREG_GLOBAL_LOCK_ENABLE 0x09 +#define ACPI_BITREG_POWER_BUTTON_ENABLE 0x0A +#define ACPI_BITREG_SLEEP_BUTTON_ENABLE 0x0B +#define ACPI_BITREG_RT_CLOCK_ENABLE 0x0C +#define ACPI_BITREG_PCIEXP_WAKE_DISABLE 0x0D + +/* PM1 Control register */ + +#define ACPI_BITREG_SCI_ENABLE 0x0E +#define ACPI_BITREG_BUS_MASTER_RLD 0x0F +#define ACPI_BITREG_GLOBAL_LOCK_RELEASE 0x10 +#define ACPI_BITREG_SLEEP_TYPE 0x11 +#define ACPI_BITREG_SLEEP_ENABLE 0x12 + +/* PM2 Control register */ + +#define ACPI_BITREG_ARB_DISABLE 0x13 + +#define ACPI_BITREG_MAX 0x13 +#define ACPI_NUM_BITREG ACPI_BITREG_MAX + 1 + + +/* Status register values. A 1 clears a status bit. 0 = no effect */ + +#define ACPI_CLEAR_STATUS 1 + +/* Enable and Control register values */ + +#define ACPI_ENABLE_EVENT 1 +#define ACPI_DISABLE_EVENT 0 + + +/* + * External ACPI object definition + */ + +/* + * Note: Type == ACPI_TYPE_ANY (0) is used to indicate a NULL package element + * or an unresolved named reference. + */ +typedef union acpi_object +{ + ACPI_OBJECT_TYPE Type; /* See definition of AcpiNsType for values */ + struct + { + ACPI_OBJECT_TYPE Type; /* ACPI_TYPE_INTEGER */ + ACPI_INTEGER Value; /* The actual number */ + } Integer; + + struct + { + ACPI_OBJECT_TYPE Type; /* ACPI_TYPE_STRING */ + UINT32 Length; /* # of bytes in string, excluding trailing null */ + char *Pointer; /* points to the string value */ + } String; + + struct + { + ACPI_OBJECT_TYPE Type; /* ACPI_TYPE_BUFFER */ + UINT32 Length; /* # of bytes in buffer */ + UINT8 *Pointer; /* points to the buffer */ + } Buffer; + + struct + { + ACPI_OBJECT_TYPE Type; /* ACPI_TYPE_PACKAGE */ + UINT32 Count; /* # of elements in package */ + union acpi_object *Elements; /* Pointer to an array of ACPI_OBJECTs */ + } Package; + + struct + { + ACPI_OBJECT_TYPE Type; /* ACPI_TYPE_LOCAL_REFERENCE */ + ACPI_OBJECT_TYPE ActualType; /* Type associated with the Handle */ + ACPI_HANDLE Handle; /* object reference */ + } Reference; + + struct + { + ACPI_OBJECT_TYPE Type; /* ACPI_TYPE_PROCESSOR */ + UINT32 ProcId; + ACPI_IO_ADDRESS PblkAddress; + UINT32 PblkLength; + } Processor; + + struct + { + ACPI_OBJECT_TYPE Type; /* ACPI_TYPE_POWER */ + UINT32 SystemLevel; + UINT32 ResourceOrder; + } PowerResource; + +} ACPI_OBJECT; + + +/* + * List of objects, used as a parameter list for control method evaluation + */ +typedef struct acpi_object_list +{ + UINT32 Count; + ACPI_OBJECT *Pointer; + +} ACPI_OBJECT_LIST; + + +/* + * Miscellaneous common Data Structures used by the interfaces + */ +#define ACPI_NO_BUFFER 0 +#define ACPI_ALLOCATE_BUFFER (ACPI_SIZE) (-1) +#define ACPI_ALLOCATE_LOCAL_BUFFER (ACPI_SIZE) (-2) + +typedef struct acpi_buffer +{ + ACPI_SIZE Length; /* Length in bytes of the buffer */ + void *Pointer; /* pointer to buffer */ + +} ACPI_BUFFER; + + +/* + * NameType for AcpiGetName + */ +#define ACPI_FULL_PATHNAME 0 +#define ACPI_SINGLE_NAME 1 +#define ACPI_NAME_TYPE_MAX 1 + + +/* + * Predefined Namespace items + */ +typedef struct acpi_predefined_names +{ + char *Name; + UINT8 Type; + char *Val; + +} ACPI_PREDEFINED_NAMES; + + +/* + * Structure and flags for AcpiGetSystemInfo + */ +#define ACPI_SYS_MODE_UNKNOWN 0x0000 +#define ACPI_SYS_MODE_ACPI 0x0001 +#define ACPI_SYS_MODE_LEGACY 0x0002 +#define ACPI_SYS_MODES_MASK 0x0003 + + +/* + * System info returned by AcpiGetSystemInfo() + */ +typedef struct acpi_system_info +{ + UINT32 AcpiCaVersion; + UINT32 Flags; + UINT32 TimerResolution; + UINT32 Reserved1; + UINT32 Reserved2; + UINT32 DebugLevel; + UINT32 DebugLayer; + +} ACPI_SYSTEM_INFO; + + +/* + * System statistics returned by AcpiGetStatistics() + */ +typedef struct acpi_statistics +{ + UINT32 SciCount; + UINT32 GpeCount; + UINT32 FixedEventCount[ACPI_NUM_FIXED_EVENTS]; + UINT32 MethodCount; + +} ACPI_STATISTICS; + + +/* Table Event Types */ + +#define ACPI_TABLE_EVENT_LOAD 0x0 +#define ACPI_TABLE_EVENT_UNLOAD 0x1 +#define ACPI_NUM_TABLE_EVENTS 2 + + +/* + * Types specific to the OS service interfaces + */ +typedef UINT32 +(ACPI_SYSTEM_XFACE *ACPI_OSD_HANDLER) ( + void *Context); + +typedef void +(ACPI_SYSTEM_XFACE *ACPI_OSD_EXEC_CALLBACK) ( + void *Context); + +/* + * Various handlers and callback procedures + */ +typedef +UINT32 (*ACPI_EVENT_HANDLER) ( + void *Context); + +typedef +void (*ACPI_NOTIFY_HANDLER) ( + ACPI_HANDLE Device, + UINT32 Value, + void *Context); + +typedef +void (*ACPI_OBJECT_HANDLER) ( + ACPI_HANDLE Object, + void *Data); + +typedef +ACPI_STATUS (*ACPI_INIT_HANDLER) ( + ACPI_HANDLE Object, + UINT32 Function); + +#define ACPI_INIT_DEVICE_INI 1 + +typedef +ACPI_STATUS (*ACPI_EXCEPTION_HANDLER) ( + ACPI_STATUS AmlStatus, + ACPI_NAME Name, + UINT16 Opcode, + UINT32 AmlOffset, + void *Context); + +/* Table Event handler (Load, LoadTable, etc.) and types */ + +typedef +ACPI_STATUS (*ACPI_TABLE_HANDLER) ( + UINT32 Event, + void *Table, + void *Context); + +#define ACPI_TABLE_LOAD 0x0 +#define ACPI_TABLE_UNLOAD 0x1 +#define ACPI_NUM_TABLE_EVENTS 2 + + +/* Address Spaces (For Operation Regions) */ + +typedef +ACPI_STATUS (*ACPI_ADR_SPACE_HANDLER) ( + UINT32 Function, + ACPI_PHYSICAL_ADDRESS Address, + UINT32 BitWidth, + ACPI_INTEGER *Value, + void *HandlerContext, + void *RegionContext); + +#define ACPI_DEFAULT_HANDLER NULL + +typedef +ACPI_STATUS (*ACPI_ADR_SPACE_SETUP) ( + ACPI_HANDLE RegionHandle, + UINT32 Function, + void *HandlerContext, + void **RegionContext); + +#define ACPI_REGION_ACTIVATE 0 +#define ACPI_REGION_DEACTIVATE 1 + +typedef +ACPI_STATUS (*ACPI_WALK_CALLBACK) ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue); + + +/* Interrupt handler return values */ + +#define ACPI_INTERRUPT_NOT_HANDLED 0x00 +#define ACPI_INTERRUPT_HANDLED 0x01 + +/* 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_UUID_LENGTH 16 + + +/* Structures used for device/processor HID, UID, CID */ + +typedef struct acpi_device_id +{ + UINT32 Length; /* Length of string + null */ + char *String; + +} ACPI_DEVICE_ID; + +typedef struct acpi_device_id_list +{ + UINT32 Count; /* Number of IDs in Ids array */ + UINT32 ListSize; /* Size of list, including ID strings */ + ACPI_DEVICE_ID Ids[1]; /* ID array */ + +} ACPI_DEVICE_ID_LIST; + +/* + * Structure returned from AcpiGetObjectInfo. + * Optimized for both 32- and 64-bit builds + */ +typedef struct acpi_device_info +{ + 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 */ + ACPI_INTEGER Address; /* _ADR value */ + ACPI_DEVICE_ID HardwareId; /* _HID value */ + ACPI_DEVICE_ID UniqueId; /* _UID value */ + ACPI_DEVICE_ID_LIST CompatibleIdList; /* _CID list */ + +} ACPI_DEVICE_INFO; + +/* Values for Flags field above (AcpiGetObjectInfo) */ + +#define ACPI_PCI_ROOT_BRIDGE 0x01 + +/* Flags for Valid field above (AcpiGetObjectInfo) */ + +#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 */ + +#define ACPI_STA_DEVICE_PRESENT 0x01 +#define ACPI_STA_DEVICE_ENABLED 0x02 +#define ACPI_STA_DEVICE_UI 0x04 +#define ACPI_STA_DEVICE_FUNCTIONING 0x08 +#define ACPI_STA_DEVICE_OK 0x08 /* Synonym */ +#define ACPI_STA_BATTERY_PRESENT 0x10 + + +/* Context structs for address space handlers */ + +typedef struct acpi_pci_id +{ + UINT16 Segment; + UINT16 Bus; + UINT16 Device; + UINT16 Function; + +} ACPI_PCI_ID; + +typedef struct acpi_mem_space_context +{ + UINT32 Length; + ACPI_PHYSICAL_ADDRESS Address; + ACPI_PHYSICAL_ADDRESS MappedPhysicalAddress; + UINT8 *MappedLogicalAddress; + ACPI_SIZE MappedLength; + +} ACPI_MEM_SPACE_CONTEXT; + + +/* + * ACPI_MEMORY_LIST is used only if the ACPICA local cache is enabled + */ +typedef struct acpi_memory_list +{ + char *ListName; + void *ListHead; + UINT16 ObjectSize; + UINT16 MaxDepth; + UINT16 CurrentDepth; + UINT16 LinkOffset; + +#ifdef ACPI_DBG_TRACK_ALLOCATIONS + + /* Statistics for debug memory tracking only */ + + UINT32 TotalAllocated; + UINT32 TotalFreed; + UINT32 MaxOccupied; + UINT32 TotalSize; + UINT32 CurrentTotalSize; + UINT32 Requests; + UINT32 Hits; +#endif + +} ACPI_MEMORY_LIST; + + +#endif /* __ACTYPES_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/acutils.h b/reactos/drivers/bus/acpi/acpica/include/acutils.h new file mode 100644 index 00000000000..3e12b7ca361 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/acutils.h @@ -0,0 +1,963 @@ +/****************************************************************************** + * + * Name: acutils.h -- prototypes for the common (subsystem-wide) procedures + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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. + * + *****************************************************************************/ + +#ifndef _ACUTILS_H +#define _ACUTILS_H + + +extern const UINT8 AcpiGbl_ResourceAmlSizes[]; + +/* Strings used by the disassembler and debugger resource dump routines */ + +#if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUGGER) + +extern const char *AcpiGbl_BmDecode[]; +extern const char *AcpiGbl_ConfigDecode[]; +extern const char *AcpiGbl_ConsumeDecode[]; +extern const char *AcpiGbl_DecDecode[]; +extern const char *AcpiGbl_HeDecode[]; +extern const char *AcpiGbl_IoDecode[]; +extern const char *AcpiGbl_LlDecode[]; +extern const char *AcpiGbl_MaxDecode[]; +extern const char *AcpiGbl_MemDecode[]; +extern const char *AcpiGbl_MinDecode[]; +extern const char *AcpiGbl_MtpDecode[]; +extern const char *AcpiGbl_RngDecode[]; +extern const char *AcpiGbl_RwDecode[]; +extern const char *AcpiGbl_ShrDecode[]; +extern const char *AcpiGbl_SizDecode[]; +extern const char *AcpiGbl_TrsDecode[]; +extern const char *AcpiGbl_TtpDecode[]; +extern const char *AcpiGbl_TypDecode[]; +#endif + +/* Types for Resource descriptor entries */ + +#define ACPI_INVALID_RESOURCE 0 +#define ACPI_FIXED_LENGTH 1 +#define ACPI_VARIABLE_LENGTH 2 +#define ACPI_SMALL_VARIABLE_LENGTH 3 + +typedef +ACPI_STATUS (*ACPI_WALK_AML_CALLBACK) ( + UINT8 *Aml, + UINT32 Length, + UINT32 Offset, + UINT8 ResourceIndex, + void *Context); + +typedef +ACPI_STATUS (*ACPI_PKG_CALLBACK) ( + UINT8 ObjectType, + ACPI_OPERAND_OBJECT *SourceObject, + ACPI_GENERIC_STATE *State, + void *Context); + +typedef struct acpi_pkg_info +{ + UINT8 *FreeSpace; + ACPI_SIZE Length; + UINT32 ObjectSpace; + UINT32 NumPackages; + +} ACPI_PKG_INFO; + +#define REF_INCREMENT (UINT16) 0 +#define REF_DECREMENT (UINT16) 1 +#define REF_FORCE_DELETE (UINT16) 2 + +/* AcpiUtDumpBuffer */ + +#define DB_BYTE_DISPLAY 1 +#define DB_WORD_DISPLAY 2 +#define DB_DWORD_DISPLAY 4 +#define DB_QWORD_DISPLAY 8 + + +/* + * utglobal - Global data structures and procedures + */ +ACPI_STATUS +AcpiUtInitGlobals ( + void); + +#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) + +char * +AcpiUtGetMutexName ( + UINT32 MutexId); + +const char * +AcpiUtGetNotifyName ( + UINT32 NotifyValue); + +#endif + +char * +AcpiUtGetTypeName ( + ACPI_OBJECT_TYPE Type); + +char * +AcpiUtGetNodeName ( + void *Object); + +char * +AcpiUtGetDescriptorName ( + void *Object); + +const char * +AcpiUtGetReferenceName ( + ACPI_OPERAND_OBJECT *Object); + +char * +AcpiUtGetObjectTypeName ( + ACPI_OPERAND_OBJECT *ObjDesc); + +char * +AcpiUtGetRegionName ( + UINT8 SpaceId); + +char * +AcpiUtGetEventName ( + UINT32 EventId); + +char +AcpiUtHexToAsciiChar ( + ACPI_INTEGER Integer, + UINT32 Position); + +BOOLEAN +AcpiUtValidObjectType ( + ACPI_OBJECT_TYPE Type); + + +/* + * utinit - miscellaneous initialization and shutdown + */ +ACPI_STATUS +AcpiUtHardwareInitialize ( + void); + +void +AcpiUtSubsystemShutdown ( + void); + + +/* + * utclib - Local implementations of C library functions + */ +#ifndef ACPI_USE_SYSTEM_CLIBRARY + +ACPI_SIZE +AcpiUtStrlen ( + const char *String); + +char * +AcpiUtStrcpy ( + char *DstString, + const char *SrcString); + +char * +AcpiUtStrncpy ( + char *DstString, + const char *SrcString, + ACPI_SIZE Count); + +int +AcpiUtMemcmp ( + const char *Buffer1, + const char *Buffer2, + ACPI_SIZE Count); + +int +AcpiUtStrncmp ( + const char *String1, + const char *String2, + ACPI_SIZE Count); + +int +AcpiUtStrcmp ( + const char *String1, + const char *String2); + +char * +AcpiUtStrcat ( + char *DstString, + const char *SrcString); + +char * +AcpiUtStrncat ( + char *DstString, + const char *SrcString, + ACPI_SIZE Count); + +UINT32 +AcpiUtStrtoul ( + const char *String, + char **Terminator, + UINT32 Base); + +char * +AcpiUtStrstr ( + char *String1, + char *String2); + +void * +AcpiUtMemcpy ( + void *Dest, + const void *Src, + ACPI_SIZE Count); + +void * +AcpiUtMemset ( + void *Dest, + UINT8 Value, + ACPI_SIZE Count); + +int +AcpiUtToUpper ( + int c); + +int +AcpiUtToLower ( + int c); + +extern const UINT8 _acpi_ctype[]; + +#define _ACPI_XA 0x00 /* extra alphabetic - not supported */ +#define _ACPI_XS 0x40 /* extra space */ +#define _ACPI_BB 0x00 /* BEL, BS, etc. - not supported */ +#define _ACPI_CN 0x20 /* CR, FF, HT, NL, VT */ +#define _ACPI_DI 0x04 /* '0'-'9' */ +#define _ACPI_LO 0x02 /* 'a'-'z' */ +#define _ACPI_PU 0x10 /* punctuation */ +#define _ACPI_SP 0x08 /* space */ +#define _ACPI_UP 0x01 /* 'A'-'Z' */ +#define _ACPI_XD 0x80 /* '0'-'9', 'A'-'F', 'a'-'f' */ + +#define ACPI_IS_DIGIT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_DI)) +#define ACPI_IS_SPACE(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_SP)) +#define ACPI_IS_XDIGIT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_XD)) +#define ACPI_IS_UPPER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_UP)) +#define ACPI_IS_LOWER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO)) +#define ACPI_IS_PRINT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP | _ACPI_DI | _ACPI_SP | _ACPI_PU)) +#define ACPI_IS_ALPHA(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP)) + +#endif /* !ACPI_USE_SYSTEM_CLIBRARY */ + +#define ACPI_IS_ASCII(c) ((c) < 0x80) + + +/* + * utcopy - Object construction and conversion interfaces + */ +ACPI_STATUS +AcpiUtBuildSimpleObject( + ACPI_OPERAND_OBJECT *Obj, + ACPI_OBJECT *UserObj, + UINT8 *DataSpace, + UINT32 *BufferSpaceUsed); + +ACPI_STATUS +AcpiUtBuildPackageObject ( + ACPI_OPERAND_OBJECT *Obj, + UINT8 *Buffer, + UINT32 *SpaceUsed); + +ACPI_STATUS +AcpiUtCopyIobjectToEobject ( + ACPI_OPERAND_OBJECT *Obj, + ACPI_BUFFER *RetBuffer); + +ACPI_STATUS +AcpiUtCopyEobjectToIobject ( + ACPI_OBJECT *Obj, + ACPI_OPERAND_OBJECT **InternalObj); + +ACPI_STATUS +AcpiUtCopyISimpleToIsimple ( + ACPI_OPERAND_OBJECT *SourceObj, + ACPI_OPERAND_OBJECT *DestObj); + +ACPI_STATUS +AcpiUtCopyIobjectToIobject ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT **DestDesc, + ACPI_WALK_STATE *WalkState); + + +/* + * utcreate - Object creation + */ +ACPI_STATUS +AcpiUtUpdateObjectReference ( + ACPI_OPERAND_OBJECT *Object, + UINT16 Action); + + +/* + * utdebug - Debug interfaces + */ +void +AcpiUtInitStackPtrTrace ( + void); + +void +AcpiUtTrackStackPtr ( + void); + +void +AcpiUtTrace ( + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId); + +void +AcpiUtTracePtr ( + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId, + void *Pointer); + +void +AcpiUtTraceU32 ( + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId, + UINT32 Integer); + +void +AcpiUtTraceStr ( + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId, + char *String); + +void +AcpiUtExit ( + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId); + +void +AcpiUtStatusExit ( + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId, + ACPI_STATUS Status); + +void +AcpiUtValueExit ( + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId, + ACPI_INTEGER Value); + +void +AcpiUtPtrExit ( + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId, + UINT8 *Ptr); + +void +AcpiUtDumpBuffer ( + UINT8 *Buffer, + UINT32 Count, + UINT32 Display, + UINT32 componentId); + +void +AcpiUtDumpBuffer2 ( + UINT8 *Buffer, + UINT32 Count, + UINT32 Display); + +void +AcpiUtReportError ( + char *ModuleName, + UINT32 LineNumber); + +void +AcpiUtReportInfo ( + char *ModuleName, + UINT32 LineNumber); + +void +AcpiUtReportWarning ( + char *ModuleName, + UINT32 LineNumber); + +/* + * utdelete - Object deletion and reference counts + */ +void +AcpiUtAddReference ( + ACPI_OPERAND_OBJECT *Object); + +void +AcpiUtRemoveReference ( + ACPI_OPERAND_OBJECT *Object); + +void +AcpiUtDeleteInternalPackageObject ( + ACPI_OPERAND_OBJECT *Object); + +void +AcpiUtDeleteInternalSimpleObject ( + ACPI_OPERAND_OBJECT *Object); + +void +AcpiUtDeleteInternalObjectList ( + ACPI_OPERAND_OBJECT **ObjList); + + +/* + * uteval - object evaluation + */ +ACPI_STATUS +AcpiUtOsiImplementation ( + ACPI_WALK_STATE *WalkState); + +ACPI_STATUS +AcpiUtEvaluateObject ( + ACPI_NAMESPACE_NODE *PrefixNode, + char *Path, + UINT32 ExpectedReturnBtypes, + ACPI_OPERAND_OBJECT **ReturnDesc); + +ACPI_STATUS +AcpiUtEvaluateNumericObject ( + char *ObjectName, + ACPI_NAMESPACE_NODE *DeviceNode, + ACPI_INTEGER *Value); + +ACPI_STATUS +AcpiUtExecute_STA ( + ACPI_NAMESPACE_NODE *DeviceNode, + UINT32 *StatusFlags); + +ACPI_STATUS +AcpiUtExecutePowerMethods ( + ACPI_NAMESPACE_NODE *DeviceNode, + const char **MethodNames, + UINT8 MethodCount, + UINT8 *OutValues); + + +/* + * utids - device ID support + */ +ACPI_STATUS +AcpiUtExecute_HID ( + ACPI_NAMESPACE_NODE *DeviceNode, + ACPI_DEVICE_ID **ReturnId); + +ACPI_STATUS +AcpiUtExecute_UID ( + ACPI_NAMESPACE_NODE *DeviceNode, + ACPI_DEVICE_ID **ReturnId); + +ACPI_STATUS +AcpiUtExecute_CID ( + ACPI_NAMESPACE_NODE *DeviceNode, + ACPI_DEVICE_ID_LIST **ReturnCidList); + + +/* + * utlock - reader/writer locks + */ +ACPI_STATUS +AcpiUtCreateRwLock ( + ACPI_RW_LOCK *Lock); + +void +AcpiUtDeleteRwLock ( + ACPI_RW_LOCK *Lock); + +ACPI_STATUS +AcpiUtAcquireReadLock ( + ACPI_RW_LOCK *Lock); + +ACPI_STATUS +AcpiUtReleaseReadLock ( + ACPI_RW_LOCK *Lock); + +ACPI_STATUS +AcpiUtAcquireWriteLock ( + ACPI_RW_LOCK *Lock); + +void +AcpiUtReleaseWriteLock ( + ACPI_RW_LOCK *Lock); + + +/* + * utobject - internal object create/delete/cache routines + */ +ACPI_OPERAND_OBJECT * +AcpiUtCreateInternalObjectDbg ( + const char *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId, + ACPI_OBJECT_TYPE Type); + +void * +AcpiUtAllocateObjectDescDbg ( + const char *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId); + +#define AcpiUtCreateInternalObject(t) AcpiUtCreateInternalObjectDbg (_AcpiModuleName,__LINE__,_COMPONENT,t) +#define AcpiUtAllocateObjectDesc() AcpiUtAllocateObjectDescDbg (_AcpiModuleName,__LINE__,_COMPONENT) + +void +AcpiUtDeleteObjectDesc ( + ACPI_OPERAND_OBJECT *Object); + +BOOLEAN +AcpiUtValidInternalObject ( + void *Object); + +ACPI_OPERAND_OBJECT * +AcpiUtCreatePackageObject ( + UINT32 Count); + +ACPI_OPERAND_OBJECT * +AcpiUtCreateIntegerObject ( + UINT64 Value); + +ACPI_OPERAND_OBJECT * +AcpiUtCreateBufferObject ( + ACPI_SIZE BufferSize); + +ACPI_OPERAND_OBJECT * +AcpiUtCreateStringObject ( + ACPI_SIZE StringSize); + +ACPI_STATUS +AcpiUtGetObjectSize( + ACPI_OPERAND_OBJECT *Obj, + ACPI_SIZE *ObjLength); + + +/* + * utstate - Generic state creation/cache routines + */ +void +AcpiUtPushGenericState ( + ACPI_GENERIC_STATE **ListHead, + ACPI_GENERIC_STATE *State); + +ACPI_GENERIC_STATE * +AcpiUtPopGenericState ( + ACPI_GENERIC_STATE **ListHead); + + +ACPI_GENERIC_STATE * +AcpiUtCreateGenericState ( + void); + +ACPI_THREAD_STATE * +AcpiUtCreateThreadState ( + void); + +ACPI_GENERIC_STATE * +AcpiUtCreateUpdateState ( + ACPI_OPERAND_OBJECT *Object, + UINT16 Action); + +ACPI_GENERIC_STATE * +AcpiUtCreatePkgState ( + void *InternalObject, + void *ExternalObject, + UINT16 Index); + +ACPI_STATUS +AcpiUtCreateUpdateStateAndPush ( + ACPI_OPERAND_OBJECT *Object, + UINT16 Action, + ACPI_GENERIC_STATE **StateList); + +ACPI_STATUS +AcpiUtCreatePkgStateAndPush ( + void *InternalObject, + void *ExternalObject, + UINT16 Index, + ACPI_GENERIC_STATE **StateList); + +ACPI_GENERIC_STATE * +AcpiUtCreateControlState ( + void); + +void +AcpiUtDeleteGenericState ( + ACPI_GENERIC_STATE *State); + + +/* + * utmath + */ +ACPI_STATUS +AcpiUtDivide ( + ACPI_INTEGER InDividend, + ACPI_INTEGER InDivisor, + ACPI_INTEGER *OutQuotient, + ACPI_INTEGER *OutRemainder); + +ACPI_STATUS +AcpiUtShortDivide ( + ACPI_INTEGER InDividend, + UINT32 Divisor, + ACPI_INTEGER *OutQuotient, + UINT32 *OutRemainder); + +/* + * utmisc + */ +const char * +AcpiUtValidateException ( + ACPI_STATUS Status); + +BOOLEAN +AcpiUtIsPciRootBridge ( + char *Id); + +BOOLEAN +AcpiUtIsAmlTable ( + ACPI_TABLE_HEADER *Table); + +ACPI_STATUS +AcpiUtAllocateOwnerId ( + ACPI_OWNER_ID *OwnerId); + +void +AcpiUtReleaseOwnerId ( + ACPI_OWNER_ID *OwnerId); + +ACPI_STATUS +AcpiUtWalkPackageTree ( + ACPI_OPERAND_OBJECT *SourceObject, + void *TargetObject, + ACPI_PKG_CALLBACK WalkCallback, + void *Context); + +void +AcpiUtStrupr ( + char *SrcString); + +void +AcpiUtPrintString ( + char *String, + UINT8 MaxLength); + +BOOLEAN +AcpiUtValidAcpiName ( + UINT32 Name); + +void +AcpiUtRepairName ( + char *Name); + +BOOLEAN +AcpiUtValidAcpiChar ( + char Character, + UINT32 Position); + +ACPI_STATUS +AcpiUtStrtoul64 ( + char *String, + UINT32 Base, + ACPI_INTEGER *RetInteger); + +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, + ...); + +/* Values for Base above (16=Hex, 10=Decimal) */ + +#define ACPI_ANY_BASE 0 + +UINT32 +AcpiUtDwordByteSwap ( + UINT32 Value); + +void +AcpiUtSetIntegerWidth ( + UINT8 Revision); + +#ifdef ACPI_DEBUG_OUTPUT +void +AcpiUtDisplayInitPathname ( + UINT8 Type, + ACPI_NAMESPACE_NODE *ObjHandle, + char *Path); +#endif + + +/* + * utresrc + */ +ACPI_STATUS +AcpiUtWalkAmlResources ( + UINT8 *Aml, + ACPI_SIZE AmlLength, + ACPI_WALK_AML_CALLBACK UserFunction, + void *Context); + +ACPI_STATUS +AcpiUtValidateResource ( + void *Aml, + UINT8 *ReturnIndex); + +UINT32 +AcpiUtGetDescriptorLength ( + void *Aml); + +UINT16 +AcpiUtGetResourceLength ( + void *Aml); + +UINT8 +AcpiUtGetResourceHeaderLength ( + void *Aml); + +UINT8 +AcpiUtGetResourceType ( + void *Aml); + +ACPI_STATUS +AcpiUtGetResourceEndTag ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT8 **EndTag); + + +/* + * utmutex - mutex support + */ +ACPI_STATUS +AcpiUtMutexInitialize ( + void); + +void +AcpiUtMutexTerminate ( + void); + +ACPI_STATUS +AcpiUtAcquireMutex ( + ACPI_MUTEX_HANDLE MutexId); + +ACPI_STATUS +AcpiUtReleaseMutex ( + ACPI_MUTEX_HANDLE MutexId); + + +/* + * utalloc - memory allocation and object caching + */ +ACPI_STATUS +AcpiUtCreateCaches ( + void); + +ACPI_STATUS +AcpiUtDeleteCaches ( + void); + +ACPI_STATUS +AcpiUtValidateBuffer ( + ACPI_BUFFER *Buffer); + +ACPI_STATUS +AcpiUtInitializeBuffer ( + ACPI_BUFFER *Buffer, + ACPI_SIZE RequiredLength); + +void * +AcpiUtAllocate ( + ACPI_SIZE Size, + UINT32 Component, + const char *Module, + UINT32 Line); + +void * +AcpiUtAllocateZeroed ( + ACPI_SIZE Size, + UINT32 Component, + const char *Module, + UINT32 Line); + +#ifdef ACPI_DBG_TRACK_ALLOCATIONS +void * +AcpiUtAllocateAndTrack ( + ACPI_SIZE Size, + UINT32 Component, + const char *Module, + UINT32 Line); + +void * +AcpiUtAllocateZeroedAndTrack ( + ACPI_SIZE Size, + UINT32 Component, + const char *Module, + UINT32 Line); + +void +AcpiUtFreeAndTrack ( + void *Address, + UINT32 Component, + const char *Module, + UINT32 Line); + +void +AcpiUtDumpAllocationInfo ( + void); + +void +AcpiUtDumpAllocations ( + UINT32 Component, + const char *Module); + +ACPI_STATUS +AcpiUtCreateList ( + char *ListName, + UINT16 ObjectSize, + ACPI_MEMORY_LIST **ReturnCache); + + +#endif + +#endif /* _ACUTILS_H */ diff --git a/reactos/drivers/bus/acpi/acpica/include/amlcode.h b/reactos/drivers/bus/acpi/acpica/include/amlcode.h new file mode 100644 index 00000000000..19740d9083c --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/amlcode.h @@ -0,0 +1,595 @@ +/****************************************************************************** + * + * Name: amlcode.h - Definitions for AML, as included in "definition blocks" + * Declarations and definitions contained herein are derived + * directly from the ACPI specification. + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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. + * + *****************************************************************************/ + +#ifndef __AMLCODE_H__ +#define __AMLCODE_H__ + +/* primary opcodes */ + +#define AML_NULL_CHAR (UINT16) 0x00 + +#define AML_ZERO_OP (UINT16) 0x00 +#define AML_ONE_OP (UINT16) 0x01 +#define AML_UNASSIGNED (UINT16) 0x02 +#define AML_ALIAS_OP (UINT16) 0x06 +#define AML_NAME_OP (UINT16) 0x08 +#define AML_BYTE_OP (UINT16) 0x0a +#define AML_WORD_OP (UINT16) 0x0b +#define AML_DWORD_OP (UINT16) 0x0c +#define AML_STRING_OP (UINT16) 0x0d +#define AML_QWORD_OP (UINT16) 0x0e /* ACPI 2.0 */ +#define AML_SCOPE_OP (UINT16) 0x10 +#define AML_BUFFER_OP (UINT16) 0x11 +#define AML_PACKAGE_OP (UINT16) 0x12 +#define AML_VAR_PACKAGE_OP (UINT16) 0x13 /* ACPI 2.0 */ +#define AML_METHOD_OP (UINT16) 0x14 +#define AML_DUAL_NAME_PREFIX (UINT16) 0x2e +#define AML_MULTI_NAME_PREFIX_OP (UINT16) 0x2f +#define AML_NAME_CHAR_SUBSEQ (UINT16) 0x30 +#define AML_NAME_CHAR_FIRST (UINT16) 0x41 +#define AML_EXTENDED_OP_PREFIX (UINT16) 0x5b +#define AML_ROOT_PREFIX (UINT16) 0x5c +#define AML_PARENT_PREFIX (UINT16) 0x5e +#define AML_LOCAL_OP (UINT16) 0x60 +#define AML_LOCAL0 (UINT16) 0x60 +#define AML_LOCAL1 (UINT16) 0x61 +#define AML_LOCAL2 (UINT16) 0x62 +#define AML_LOCAL3 (UINT16) 0x63 +#define AML_LOCAL4 (UINT16) 0x64 +#define AML_LOCAL5 (UINT16) 0x65 +#define AML_LOCAL6 (UINT16) 0x66 +#define AML_LOCAL7 (UINT16) 0x67 +#define AML_ARG_OP (UINT16) 0x68 +#define AML_ARG0 (UINT16) 0x68 +#define AML_ARG1 (UINT16) 0x69 +#define AML_ARG2 (UINT16) 0x6a +#define AML_ARG3 (UINT16) 0x6b +#define AML_ARG4 (UINT16) 0x6c +#define AML_ARG5 (UINT16) 0x6d +#define AML_ARG6 (UINT16) 0x6e +#define AML_STORE_OP (UINT16) 0x70 +#define AML_REF_OF_OP (UINT16) 0x71 +#define AML_ADD_OP (UINT16) 0x72 +#define AML_CONCAT_OP (UINT16) 0x73 +#define AML_SUBTRACT_OP (UINT16) 0x74 +#define AML_INCREMENT_OP (UINT16) 0x75 +#define AML_DECREMENT_OP (UINT16) 0x76 +#define AML_MULTIPLY_OP (UINT16) 0x77 +#define AML_DIVIDE_OP (UINT16) 0x78 +#define AML_SHIFT_LEFT_OP (UINT16) 0x79 +#define AML_SHIFT_RIGHT_OP (UINT16) 0x7a +#define AML_BIT_AND_OP (UINT16) 0x7b +#define AML_BIT_NAND_OP (UINT16) 0x7c +#define AML_BIT_OR_OP (UINT16) 0x7d +#define AML_BIT_NOR_OP (UINT16) 0x7e +#define AML_BIT_XOR_OP (UINT16) 0x7f +#define AML_BIT_NOT_OP (UINT16) 0x80 +#define AML_FIND_SET_LEFT_BIT_OP (UINT16) 0x81 +#define AML_FIND_SET_RIGHT_BIT_OP (UINT16) 0x82 +#define AML_DEREF_OF_OP (UINT16) 0x83 +#define AML_CONCAT_RES_OP (UINT16) 0x84 /* ACPI 2.0 */ +#define AML_MOD_OP (UINT16) 0x85 /* ACPI 2.0 */ +#define AML_NOTIFY_OP (UINT16) 0x86 +#define AML_SIZE_OF_OP (UINT16) 0x87 +#define AML_INDEX_OP (UINT16) 0x88 +#define AML_MATCH_OP (UINT16) 0x89 +#define AML_CREATE_DWORD_FIELD_OP (UINT16) 0x8a +#define AML_CREATE_WORD_FIELD_OP (UINT16) 0x8b +#define AML_CREATE_BYTE_FIELD_OP (UINT16) 0x8c +#define AML_CREATE_BIT_FIELD_OP (UINT16) 0x8d +#define AML_TYPE_OP (UINT16) 0x8e +#define AML_CREATE_QWORD_FIELD_OP (UINT16) 0x8f /* ACPI 2.0 */ +#define AML_LAND_OP (UINT16) 0x90 +#define AML_LOR_OP (UINT16) 0x91 +#define AML_LNOT_OP (UINT16) 0x92 +#define AML_LEQUAL_OP (UINT16) 0x93 +#define AML_LGREATER_OP (UINT16) 0x94 +#define AML_LLESS_OP (UINT16) 0x95 +#define AML_TO_BUFFER_OP (UINT16) 0x96 /* ACPI 2.0 */ +#define AML_TO_DECSTRING_OP (UINT16) 0x97 /* ACPI 2.0 */ +#define AML_TO_HEXSTRING_OP (UINT16) 0x98 /* ACPI 2.0 */ +#define AML_TO_INTEGER_OP (UINT16) 0x99 /* ACPI 2.0 */ +#define AML_TO_STRING_OP (UINT16) 0x9c /* ACPI 2.0 */ +#define AML_COPY_OP (UINT16) 0x9d /* ACPI 2.0 */ +#define AML_MID_OP (UINT16) 0x9e /* ACPI 2.0 */ +#define AML_CONTINUE_OP (UINT16) 0x9f /* ACPI 2.0 */ +#define AML_IF_OP (UINT16) 0xa0 +#define AML_ELSE_OP (UINT16) 0xa1 +#define AML_WHILE_OP (UINT16) 0xa2 +#define AML_NOOP_OP (UINT16) 0xa3 +#define AML_RETURN_OP (UINT16) 0xa4 +#define AML_BREAK_OP (UINT16) 0xa5 +#define AML_BREAK_POINT_OP (UINT16) 0xcc +#define AML_ONES_OP (UINT16) 0xff + +/* prefixed opcodes */ + +#define AML_EXTENDED_OPCODE (UINT16) 0x5b00 /* prefix for 2-byte opcodes */ + +#define AML_MUTEX_OP (UINT16) 0x5b01 +#define AML_EVENT_OP (UINT16) 0x5b02 +#define AML_SHIFT_RIGHT_BIT_OP (UINT16) 0x5b10 +#define AML_SHIFT_LEFT_BIT_OP (UINT16) 0x5b11 +#define AML_COND_REF_OF_OP (UINT16) 0x5b12 +#define AML_CREATE_FIELD_OP (UINT16) 0x5b13 +#define AML_LOAD_TABLE_OP (UINT16) 0x5b1f /* ACPI 2.0 */ +#define AML_LOAD_OP (UINT16) 0x5b20 +#define AML_STALL_OP (UINT16) 0x5b21 +#define AML_SLEEP_OP (UINT16) 0x5b22 +#define AML_ACQUIRE_OP (UINT16) 0x5b23 +#define AML_SIGNAL_OP (UINT16) 0x5b24 +#define AML_WAIT_OP (UINT16) 0x5b25 +#define AML_RESET_OP (UINT16) 0x5b26 +#define AML_RELEASE_OP (UINT16) 0x5b27 +#define AML_FROM_BCD_OP (UINT16) 0x5b28 +#define AML_TO_BCD_OP (UINT16) 0x5b29 +#define AML_UNLOAD_OP (UINT16) 0x5b2a +#define AML_REVISION_OP (UINT16) 0x5b30 +#define AML_DEBUG_OP (UINT16) 0x5b31 +#define AML_FATAL_OP (UINT16) 0x5b32 +#define AML_TIMER_OP (UINT16) 0x5b33 /* ACPI 3.0 */ +#define AML_REGION_OP (UINT16) 0x5b80 +#define AML_FIELD_OP (UINT16) 0x5b81 +#define AML_DEVICE_OP (UINT16) 0x5b82 +#define AML_PROCESSOR_OP (UINT16) 0x5b83 +#define AML_POWER_RES_OP (UINT16) 0x5b84 +#define AML_THERMAL_ZONE_OP (UINT16) 0x5b85 +#define AML_INDEX_FIELD_OP (UINT16) 0x5b86 +#define AML_BANK_FIELD_OP (UINT16) 0x5b87 +#define AML_DATA_REGION_OP (UINT16) 0x5b88 /* ACPI 2.0 */ + + +/* + * Combination opcodes (actually two one-byte opcodes) + * Used by the disassembler and iASL compiler + */ +#define AML_LGREATEREQUAL_OP (UINT16) 0x9295 +#define AML_LLESSEQUAL_OP (UINT16) 0x9294 +#define AML_LNOTEQUAL_OP (UINT16) 0x9293 + + +/* + * Internal opcodes + * Use only "Unknown" AML opcodes, don't attempt to use + * any valid ACPI ASCII values (A-Z, 0-9, '-') + */ +#define AML_INT_NAMEPATH_OP (UINT16) 0x002d +#define AML_INT_NAMEDFIELD_OP (UINT16) 0x0030 +#define AML_INT_RESERVEDFIELD_OP (UINT16) 0x0031 +#define AML_INT_ACCESSFIELD_OP (UINT16) 0x0032 +#define AML_INT_BYTELIST_OP (UINT16) 0x0033 +#define AML_INT_STATICSTRING_OP (UINT16) 0x0034 +#define AML_INT_METHODCALL_OP (UINT16) 0x0035 +#define AML_INT_RETURN_VALUE_OP (UINT16) 0x0036 +#define AML_INT_EVAL_SUBTREE_OP (UINT16) 0x0037 + + +#define ARG_NONE 0x0 + +/* + * Argument types for the AML Parser + * Each field in the ArgTypes UINT32 is 5 bits, allowing for a maximum of 6 arguments. + * There can be up to 31 unique argument types + * Zero is reserved as end-of-list indicator + */ +#define ARGP_BYTEDATA 0x01 +#define ARGP_BYTELIST 0x02 +#define ARGP_CHARLIST 0x03 +#define ARGP_DATAOBJ 0x04 +#define ARGP_DATAOBJLIST 0x05 +#define ARGP_DWORDDATA 0x06 +#define ARGP_FIELDLIST 0x07 +#define ARGP_NAME 0x08 +#define ARGP_NAMESTRING 0x09 +#define ARGP_OBJLIST 0x0A +#define ARGP_PKGLENGTH 0x0B +#define ARGP_SUPERNAME 0x0C +#define ARGP_TARGET 0x0D +#define ARGP_TERMARG 0x0E +#define ARGP_TERMLIST 0x0F +#define ARGP_WORDDATA 0x10 +#define ARGP_QWORDDATA 0x11 +#define ARGP_SIMPLENAME 0x12 + +/* + * Resolved argument types for the AML Interpreter + * Each field in the ArgTypes UINT32 is 5 bits, allowing for a maximum of 6 arguments. + * There can be up to 31 unique argument types (0 is end-of-arg-list indicator) + * + * Note1: These values are completely independent from the ACPI_TYPEs + * i.e., ARGI_INTEGER != ACPI_TYPE_INTEGER + * + * Note2: If and when 5 bits becomes insufficient, it would probably be best + * to convert to a 6-byte array of argument types, allowing 8 bits per argument. + */ + +/* Single, simple types */ + +#define ARGI_ANYTYPE 0x01 /* Don't care */ +#define ARGI_PACKAGE 0x02 +#define ARGI_EVENT 0x03 +#define ARGI_MUTEX 0x04 +#define ARGI_DDBHANDLE 0x05 + +/* Interchangeable types (via implicit conversion) */ + +#define ARGI_INTEGER 0x06 +#define ARGI_STRING 0x07 +#define ARGI_BUFFER 0x08 +#define ARGI_BUFFER_OR_STRING 0x09 /* Used by MID op only */ +#define ARGI_COMPUTEDATA 0x0A /* Buffer, String, or Integer */ + +/* Reference objects */ + +#define ARGI_INTEGER_REF 0x0B +#define ARGI_OBJECT_REF 0x0C +#define ARGI_DEVICE_REF 0x0D +#define ARGI_REFERENCE 0x0E +#define ARGI_TARGETREF 0x0F /* Target, subject to implicit conversion */ +#define ARGI_FIXED_TARGET 0x10 /* Target, no implicit conversion */ +#define ARGI_SIMPLE_TARGET 0x11 /* Name, Local, Arg -- no implicit conversion */ + +/* Multiple/complex types */ + +#define ARGI_DATAOBJECT 0x12 /* Buffer, String, package or reference to a Node - Used only by SizeOf operator*/ +#define ARGI_COMPLEXOBJ 0x13 /* Buffer, String, or package (Used by INDEX op only) */ +#define ARGI_REF_OR_STRING 0x14 /* Reference or String (Used by DEREFOF op only) */ +#define ARGI_REGION_OR_BUFFER 0x15 /* Used by LOAD op only */ +#define ARGI_DATAREFOBJ 0x16 + +/* Note: types above can expand to 0x1F maximum */ + +#define ARGI_INVALID_OPCODE 0xFFFFFFFF + + +/* + * hash offsets + */ +#define AML_EXTOP_HASH_OFFSET 22 +#define AML_LNOT_HASH_OFFSET 19 + + +/* + * opcode groups and types + */ +#define OPGRP_NAMED 0x01 +#define OPGRP_FIELD 0x02 +#define OPGRP_BYTELIST 0x04 + + +/* + * Opcode information + */ + +/* Opcode flags */ + +#define AML_LOGICAL 0x0001 +#define AML_LOGICAL_NUMERIC 0x0002 +#define AML_MATH 0x0004 +#define AML_CREATE 0x0008 +#define AML_FIELD 0x0010 +#define AML_DEFER 0x0020 +#define AML_NAMED 0x0040 +#define AML_NSNODE 0x0080 +#define AML_NSOPCODE 0x0100 +#define AML_NSOBJECT 0x0200 +#define AML_HAS_RETVAL 0x0400 +#define AML_HAS_TARGET 0x0800 +#define AML_HAS_ARGS 0x1000 +#define AML_CONSTANT 0x2000 +#define AML_NO_OPERAND_RESOLVE 0x4000 + +/* Convenient flag groupings */ + +#define AML_FLAGS_EXEC_0A_0T_1R AML_HAS_RETVAL +#define AML_FLAGS_EXEC_1A_0T_0R AML_HAS_ARGS /* Monadic1 */ +#define AML_FLAGS_EXEC_1A_0T_1R AML_HAS_ARGS | AML_HAS_RETVAL /* Monadic2 */ +#define AML_FLAGS_EXEC_1A_1T_0R AML_HAS_ARGS | AML_HAS_TARGET +#define AML_FLAGS_EXEC_1A_1T_1R AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL /* Monadic2R */ +#define AML_FLAGS_EXEC_2A_0T_0R AML_HAS_ARGS /* Dyadic1 */ +#define AML_FLAGS_EXEC_2A_0T_1R AML_HAS_ARGS | AML_HAS_RETVAL /* Dyadic2 */ +#define AML_FLAGS_EXEC_2A_1T_1R AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL /* Dyadic2R */ +#define AML_FLAGS_EXEC_2A_2T_1R AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL +#define AML_FLAGS_EXEC_3A_0T_0R AML_HAS_ARGS +#define AML_FLAGS_EXEC_3A_1T_1R AML_HAS_ARGS | AML_HAS_TARGET | AML_HAS_RETVAL +#define AML_FLAGS_EXEC_6A_0T_1R AML_HAS_ARGS | AML_HAS_RETVAL + + +/* + * The opcode Type is used in a dispatch table, do not change + * without updating the table. + */ +#define AML_TYPE_EXEC_0A_0T_1R 0x00 +#define AML_TYPE_EXEC_1A_0T_0R 0x01 /* Monadic1 */ +#define AML_TYPE_EXEC_1A_0T_1R 0x02 /* Monadic2 */ +#define AML_TYPE_EXEC_1A_1T_0R 0x03 +#define AML_TYPE_EXEC_1A_1T_1R 0x04 /* Monadic2R */ +#define AML_TYPE_EXEC_2A_0T_0R 0x05 /* Dyadic1 */ +#define AML_TYPE_EXEC_2A_0T_1R 0x06 /* Dyadic2 */ +#define AML_TYPE_EXEC_2A_1T_1R 0x07 /* Dyadic2R */ +#define AML_TYPE_EXEC_2A_2T_1R 0x08 +#define AML_TYPE_EXEC_3A_0T_0R 0x09 +#define AML_TYPE_EXEC_3A_1T_1R 0x0A +#define AML_TYPE_EXEC_6A_0T_1R 0x0B +/* End of types used in dispatch table */ + +#define AML_TYPE_LITERAL 0x0B +#define AML_TYPE_CONSTANT 0x0C +#define AML_TYPE_METHOD_ARGUMENT 0x0D +#define AML_TYPE_LOCAL_VARIABLE 0x0E +#define AML_TYPE_DATA_TERM 0x0F + +/* Generic for an op that returns a value */ + +#define AML_TYPE_METHOD_CALL 0x10 + +/* Misc */ + +#define AML_TYPE_CREATE_FIELD 0x11 +#define AML_TYPE_CREATE_OBJECT 0x12 +#define AML_TYPE_CONTROL 0x13 +#define AML_TYPE_NAMED_NO_OBJ 0x14 +#define AML_TYPE_NAMED_FIELD 0x15 +#define AML_TYPE_NAMED_SIMPLE 0x16 +#define AML_TYPE_NAMED_COMPLEX 0x17 +#define AML_TYPE_RETURN 0x18 + +#define AML_TYPE_UNDEFINED 0x19 +#define AML_TYPE_BOGUS 0x1A + +/* AML Package Length encodings */ + +#define ACPI_AML_PACKAGE_TYPE1 0x40 +#define ACPI_AML_PACKAGE_TYPE2 0x4000 +#define ACPI_AML_PACKAGE_TYPE3 0x400000 +#define ACPI_AML_PACKAGE_TYPE4 0x40000000 + +/* + * Opcode classes + */ +#define AML_CLASS_EXECUTE 0x00 +#define AML_CLASS_CREATE 0x01 +#define AML_CLASS_ARGUMENT 0x02 +#define AML_CLASS_NAMED_OBJECT 0x03 +#define AML_CLASS_CONTROL 0x04 +#define AML_CLASS_ASCII 0x05 +#define AML_CLASS_PREFIX 0x06 +#define AML_CLASS_INTERNAL 0x07 +#define AML_CLASS_RETURN_VALUE 0x08 +#define AML_CLASS_METHOD_CALL 0x09 +#define AML_CLASS_UNKNOWN 0x0A + + +/* Predefined Operation Region SpaceIDs */ + +typedef enum +{ + REGION_MEMORY = 0, + REGION_IO, + REGION_PCI_CONFIG, + REGION_EC, + REGION_SMBUS, + REGION_CMOS, + REGION_PCI_BAR, + REGION_IPMI, + REGION_DATA_TABLE, /* Internal use only */ + REGION_FIXED_HW = 0x7F + +} AML_REGION_TYPES; + + +/* Comparison operation codes for MatchOp operator */ + +typedef enum +{ + MATCH_MTR = 0, + MATCH_MEQ = 1, + MATCH_MLE = 2, + MATCH_MLT = 3, + MATCH_MGE = 4, + MATCH_MGT = 5 + +} AML_MATCH_OPERATOR; + +#define MAX_MATCH_OPERATOR 5 + + +/* + * FieldFlags + * + * This byte is extracted from the AML and includes three separate + * pieces of information about the field: + * 1) The field access type + * 2) The field update rule + * 3) The lock rule for the field + * + * Bits 00 - 03 : AccessType (AnyAcc, ByteAcc, etc.) + * 04 : LockRule (1 == Lock) + * 05 - 06 : UpdateRule + */ +#define AML_FIELD_ACCESS_TYPE_MASK 0x0F +#define AML_FIELD_LOCK_RULE_MASK 0x10 +#define AML_FIELD_UPDATE_RULE_MASK 0x60 + + +/* 1) Field Access Types */ + +typedef enum +{ + AML_FIELD_ACCESS_ANY = 0x00, + AML_FIELD_ACCESS_BYTE = 0x01, + AML_FIELD_ACCESS_WORD = 0x02, + AML_FIELD_ACCESS_DWORD = 0x03, + AML_FIELD_ACCESS_QWORD = 0x04, /* ACPI 2.0 */ + AML_FIELD_ACCESS_BUFFER = 0x05 /* ACPI 2.0 */ + +} AML_ACCESS_TYPE; + + +/* 2) Field Lock Rules */ + +typedef enum +{ + AML_FIELD_LOCK_NEVER = 0x00, + AML_FIELD_LOCK_ALWAYS = 0x10 + +} AML_LOCK_RULE; + + +/* 3) Field Update Rules */ + +typedef enum +{ + AML_FIELD_UPDATE_PRESERVE = 0x00, + AML_FIELD_UPDATE_WRITE_AS_ONES = 0x20, + AML_FIELD_UPDATE_WRITE_AS_ZEROS = 0x40 + +} AML_UPDATE_RULE; + + +/* + * Field Access Attributes. + * This byte is extracted from the AML via the + * AccessAs keyword + */ +typedef enum +{ + AML_FIELD_ATTRIB_SMB_QUICK = 0x02, + AML_FIELD_ATTRIB_SMB_SEND_RCV = 0x04, + AML_FIELD_ATTRIB_SMB_BYTE = 0x06, + AML_FIELD_ATTRIB_SMB_WORD = 0x08, + AML_FIELD_ATTRIB_SMB_BLOCK = 0x0A, + AML_FIELD_ATTRIB_SMB_WORD_CALL = 0x0C, + AML_FIELD_ATTRIB_SMB_BLOCK_CALL = 0x0D + +} AML_ACCESS_ATTRIBUTE; + + +/* Bit fields in MethodFlags byte */ + +#define 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/reactos/drivers/bus/acpi/acpica/include/amlresrc.h b/reactos/drivers/bus/acpi/acpica/include/amlresrc.h new file mode 100644 index 00000000000..689564c6289 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/amlresrc.h @@ -0,0 +1,485 @@ + +/****************************************************************************** + * + * Module Name: amlresrc.h - AML resource descriptors + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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. + * + *****************************************************************************/ + +/* acpisrc:StructDefs -- for acpisrc conversion */ + +#ifndef __AMLRESRC_H +#define __AMLRESRC_H + + +/* + * Resource descriptor tags, as defined in the ACPI specification. + * Used to symbolically reference fields within a descriptor. + */ +#define ACPI_RESTAG_ADDRESS "_ADR" +#define ACPI_RESTAG_ALIGNMENT "_ALN" +#define ACPI_RESTAG_ADDRESSSPACE "_ASI" +#define ACPI_RESTAG_ACCESSSIZE "_ASZ" +#define ACPI_RESTAG_TYPESPECIFICATTRIBUTES "_ATT" +#define ACPI_RESTAG_BASEADDRESS "_BAS" +#define ACPI_RESTAG_BUSMASTER "_BM_" /* Master(1), Slave(0) */ +#define ACPI_RESTAG_DECODE "_DEC" +#define ACPI_RESTAG_DMA "_DMA" +#define ACPI_RESTAG_DMATYPE "_TYP" /* Compatible(0), A(1), B(2), F(3) */ +#define ACPI_RESTAG_GRANULARITY "_GRA" +#define ACPI_RESTAG_INTERRUPT "_INT" +#define ACPI_RESTAG_INTERRUPTLEVEL "_LL_" /* ActiveLo(1), ActiveHi(0) */ +#define ACPI_RESTAG_INTERRUPTSHARE "_SHR" /* Shareable(1), NoShare(0) */ +#define ACPI_RESTAG_INTERRUPTTYPE "_HE_" /* Edge(1), Level(0) */ +#define ACPI_RESTAG_LENGTH "_LEN" +#define ACPI_RESTAG_MEMATTRIBUTES "_MTP" /* Memory(0), Reserved(1), ACPI(2), NVS(3) */ +#define ACPI_RESTAG_MEMTYPE "_MEM" /* NonCache(0), Cacheable(1) Cache+combine(2), Cache+prefetch(3) */ +#define ACPI_RESTAG_MAXADDR "_MAX" +#define ACPI_RESTAG_MINADDR "_MIN" +#define ACPI_RESTAG_MAXTYPE "_MAF" +#define ACPI_RESTAG_MINTYPE "_MIF" +#define ACPI_RESTAG_REGISTERBITOFFSET "_RBO" +#define ACPI_RESTAG_REGISTERBITWIDTH "_RBW" +#define ACPI_RESTAG_RANGETYPE "_RNG" +#define ACPI_RESTAG_READWRITETYPE "_RW_" /* ReadOnly(0), Writeable (1) */ +#define ACPI_RESTAG_TRANSLATION "_TRA" +#define ACPI_RESTAG_TRANSTYPE "_TRS" /* Sparse(1), Dense(0) */ +#define ACPI_RESTAG_TYPE "_TTP" /* Translation(1), Static (0) */ +#define ACPI_RESTAG_XFERTYPE "_SIZ" /* 8(0), 8And16(1), 16(2) */ + + +/* Default sizes for "small" resource descriptors */ + +#define ASL_RDESC_IRQ_SIZE 0x02 +#define ASL_RDESC_DMA_SIZE 0x02 +#define ASL_RDESC_ST_DEPEND_SIZE 0x00 +#define ASL_RDESC_END_DEPEND_SIZE 0x00 +#define ASL_RDESC_IO_SIZE 0x07 +#define ASL_RDESC_FIXED_IO_SIZE 0x03 +#define ASL_RDESC_END_TAG_SIZE 0x01 + + +typedef struct asl_resource_node +{ + UINT32 BufferLength; + void *Buffer; + struct asl_resource_node *Next; + +} ASL_RESOURCE_NODE; + + +/* Macros used to generate AML resource length fields */ + +#define ACPI_AML_SIZE_LARGE(r) (sizeof (r) - sizeof (AML_RESOURCE_LARGE_HEADER)) +#define ACPI_AML_SIZE_SMALL(r) (sizeof (r) - sizeof (AML_RESOURCE_SMALL_HEADER)) + +/* + * Resource descriptors defined in the ACPI specification. + * + * Packing/alignment must be BYTE because these descriptors + * are used to overlay the raw AML byte stream. + */ +#pragma pack(1) + +/* + * SMALL descriptors + */ +#define AML_RESOURCE_SMALL_HEADER_COMMON \ + UINT8 DescriptorType; + +typedef struct aml_resource_small_header +{ + AML_RESOURCE_SMALL_HEADER_COMMON + +} AML_RESOURCE_SMALL_HEADER; + + +typedef struct aml_resource_irq +{ + AML_RESOURCE_SMALL_HEADER_COMMON + UINT16 IrqMask; + UINT8 Flags; + +} AML_RESOURCE_IRQ; + + +typedef struct aml_resource_irq_noflags +{ + AML_RESOURCE_SMALL_HEADER_COMMON + UINT16 IrqMask; + +} AML_RESOURCE_IRQ_NOFLAGS; + + +typedef struct aml_resource_dma +{ + AML_RESOURCE_SMALL_HEADER_COMMON + UINT8 DmaChannelMask; + UINT8 Flags; + +} AML_RESOURCE_DMA; + + +typedef struct aml_resource_start_dependent +{ + AML_RESOURCE_SMALL_HEADER_COMMON + UINT8 Flags; + +} AML_RESOURCE_START_DEPENDENT; + + +typedef struct aml_resource_start_dependent_noprio +{ + AML_RESOURCE_SMALL_HEADER_COMMON + +} AML_RESOURCE_START_DEPENDENT_NOPRIO; + + +typedef struct aml_resource_end_dependent +{ + AML_RESOURCE_SMALL_HEADER_COMMON + +} AML_RESOURCE_END_DEPENDENT; + + +typedef struct aml_resource_io +{ + AML_RESOURCE_SMALL_HEADER_COMMON + UINT8 Flags; + UINT16 Minimum; + UINT16 Maximum; + UINT8 Alignment; + UINT8 AddressLength; + +} AML_RESOURCE_IO; + + +typedef struct aml_resource_fixed_io +{ + AML_RESOURCE_SMALL_HEADER_COMMON + UINT16 Address; + UINT8 AddressLength; + +} AML_RESOURCE_FIXED_IO; + + +typedef struct aml_resource_vendor_small +{ + AML_RESOURCE_SMALL_HEADER_COMMON + +} AML_RESOURCE_VENDOR_SMALL; + + +typedef struct aml_resource_end_tag +{ + AML_RESOURCE_SMALL_HEADER_COMMON + UINT8 Checksum; + +} AML_RESOURCE_END_TAG; + + +/* + * LARGE descriptors + */ +#define AML_RESOURCE_LARGE_HEADER_COMMON \ + UINT8 DescriptorType;\ + UINT16 ResourceLength; + +typedef struct aml_resource_large_header +{ + AML_RESOURCE_LARGE_HEADER_COMMON + +} AML_RESOURCE_LARGE_HEADER; + + +typedef struct aml_resource_memory24 +{ + AML_RESOURCE_LARGE_HEADER_COMMON + UINT8 Flags; + UINT16 Minimum; + UINT16 Maximum; + UINT16 Alignment; + UINT16 AddressLength; + +} AML_RESOURCE_MEMORY24; + + +typedef struct aml_resource_vendor_large +{ + AML_RESOURCE_LARGE_HEADER_COMMON + +} AML_RESOURCE_VENDOR_LARGE; + + +typedef struct aml_resource_memory32 +{ + AML_RESOURCE_LARGE_HEADER_COMMON + UINT8 Flags; + UINT32 Minimum; + UINT32 Maximum; + UINT32 Alignment; + UINT32 AddressLength; + +} AML_RESOURCE_MEMORY32; + + +typedef struct aml_resource_fixed_memory32 +{ + AML_RESOURCE_LARGE_HEADER_COMMON + UINT8 Flags; + UINT32 Address; + UINT32 AddressLength; + +} AML_RESOURCE_FIXED_MEMORY32; + + +#define AML_RESOURCE_ADDRESS_COMMON \ + UINT8 ResourceType; \ + UINT8 Flags; \ + UINT8 SpecificFlags; + + +typedef struct aml_resource_address +{ + AML_RESOURCE_LARGE_HEADER_COMMON + AML_RESOURCE_ADDRESS_COMMON + +} AML_RESOURCE_ADDRESS; + + +typedef struct aml_resource_extended_address64 +{ + AML_RESOURCE_LARGE_HEADER_COMMON + AML_RESOURCE_ADDRESS_COMMON + UINT8 RevisionID; + UINT8 Reserved; + UINT64 Granularity; + UINT64 Minimum; + UINT64 Maximum; + UINT64 TranslationOffset; + UINT64 AddressLength; + UINT64 TypeSpecific; + +} AML_RESOURCE_EXTENDED_ADDRESS64; + +#define AML_RESOURCE_EXTENDED_ADDRESS_REVISION 1 /* ACPI 3.0 */ + + +typedef struct aml_resource_address64 +{ + AML_RESOURCE_LARGE_HEADER_COMMON + AML_RESOURCE_ADDRESS_COMMON + UINT64 Granularity; + UINT64 Minimum; + UINT64 Maximum; + UINT64 TranslationOffset; + UINT64 AddressLength; + +} AML_RESOURCE_ADDRESS64; + + +typedef struct aml_resource_address32 +{ + AML_RESOURCE_LARGE_HEADER_COMMON + AML_RESOURCE_ADDRESS_COMMON + UINT32 Granularity; + UINT32 Minimum; + UINT32 Maximum; + UINT32 TranslationOffset; + UINT32 AddressLength; + +} AML_RESOURCE_ADDRESS32; + + +typedef struct aml_resource_address16 +{ + AML_RESOURCE_LARGE_HEADER_COMMON + AML_RESOURCE_ADDRESS_COMMON + UINT16 Granularity; + UINT16 Minimum; + UINT16 Maximum; + UINT16 TranslationOffset; + UINT16 AddressLength; + +} AML_RESOURCE_ADDRESS16; + + +typedef struct aml_resource_extended_irq +{ + AML_RESOURCE_LARGE_HEADER_COMMON + UINT8 Flags; + UINT8 InterruptCount; + UINT32 Interrupts[1]; + /* ResSourceIndex, ResSource optional fields follow */ + +} AML_RESOURCE_EXTENDED_IRQ; + + +typedef struct aml_resource_generic_register +{ + AML_RESOURCE_LARGE_HEADER_COMMON + UINT8 AddressSpaceId; + UINT8 BitWidth; + UINT8 BitOffset; + UINT8 AccessSize; /* ACPI 3.0, was previously Reserved */ + UINT64 Address; + +} AML_RESOURCE_GENERIC_REGISTER; + +/* restore default alignment */ + +#pragma pack() + +/* Union of all resource descriptors, so we can allocate the worst case */ + +typedef union aml_resource +{ + /* Descriptor headers */ + + UINT8 DescriptorType; + AML_RESOURCE_SMALL_HEADER SmallHeader; + AML_RESOURCE_LARGE_HEADER LargeHeader; + + /* Small resource descriptors */ + + AML_RESOURCE_IRQ Irq; + AML_RESOURCE_DMA Dma; + AML_RESOURCE_START_DEPENDENT StartDpf; + AML_RESOURCE_END_DEPENDENT EndDpf; + AML_RESOURCE_IO Io; + AML_RESOURCE_FIXED_IO FixedIo; + AML_RESOURCE_VENDOR_SMALL VendorSmall; + AML_RESOURCE_END_TAG EndTag; + + /* Large resource descriptors */ + + AML_RESOURCE_MEMORY24 Memory24; + AML_RESOURCE_GENERIC_REGISTER GenericReg; + AML_RESOURCE_VENDOR_LARGE VendorLarge; + AML_RESOURCE_MEMORY32 Memory32; + AML_RESOURCE_FIXED_MEMORY32 FixedMemory32; + AML_RESOURCE_ADDRESS16 Address16; + AML_RESOURCE_ADDRESS32 Address32; + AML_RESOURCE_ADDRESS64 Address64; + AML_RESOURCE_EXTENDED_ADDRESS64 ExtAddress64; + AML_RESOURCE_EXTENDED_IRQ ExtendedIrq; + + /* Utility overlays */ + + AML_RESOURCE_ADDRESS Address; + UINT32 DwordItem; + UINT16 WordItem; + UINT8 ByteItem; + +} AML_RESOURCE; + +#endif + diff --git a/reactos/drivers/bus/acpi/acpica/include/platform/accygwin.h b/reactos/drivers/bus/acpi/acpica/include/platform/accygwin.h new file mode 100644 index 00000000000..e9585b44b10 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/platform/accygwin.h @@ -0,0 +1,163 @@ +/****************************************************************************** + * + * Name: accygwin.h - OS specific defines, etc. for cygwin environment + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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. + * + *****************************************************************************/ + +#ifndef __ACCYGWIN_H__ +#define __ACCYGWIN_H__ + +/* + * ACPICA configuration + */ +#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 + * on cygwin (always hangs forever). + */ +#define ACPI_USE_ALTERNATE_TIMEOUT + + +#include +#include +#include +#include +#include + +#if defined(__ia64__) || defined(__x86_64__) +#define ACPI_MACHINE_WIDTH 64 +#define COMPILER_DEPENDENT_INT64 long +#define COMPILER_DEPENDENT_UINT64 unsigned long +#else +#define ACPI_MACHINE_WIDTH 32 +#define COMPILER_DEPENDENT_INT64 long long +#define COMPILER_DEPENDENT_UINT64 unsigned long long +#define ACPI_USE_NATIVE_DIVIDE +#endif + +#ifndef __cdecl +#define __cdecl +#endif + +#ifdef _ANSI +#define inline +#endif + + +/* Cygwin uses GCC */ + +#include "acgcc.h" + +#endif /* __ACCYGWIN_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/platform/acdos16.h b/reactos/drivers/bus/acpi/acpica/include/platform/acdos16.h new file mode 100644 index 00000000000..f3aead6084b --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/platform/acdos16.h @@ -0,0 +1,164 @@ +/****************************************************************************** + * + * Name: acdos16.h - DOS specific defines, etc. + * $Revision: 1.18 $ + * + *****************************************************************************/ + +/****************************************************************************** + * + * 1. Copyright Notice + * + * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp. + * All rights reserved. + * + * 2. License + * + * 2.1. This is your license from Intel Corp. under its intellectual property + * rights. You may have additional license terms from the party that provided + * you this software, covering your right to use that party's intellectual + * property rights. + * + * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a + * copy of the source code appearing in this file ("Covered Code") an + * irrevocable, perpetual, worldwide license under Intel's copyrights in the + * base code distributed originally by Intel ("Original Intel Code") to copy, + * make derivatives, distribute, use and display any portion of the Covered + * Code in any form, with the right to sublicense such rights; and + * + * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent + * license (with the right to sublicense), under only those claims of Intel + * patents that are infringed by the Original Intel Code, to make, use, sell, + * offer to sell, and import the Covered Code and derivative works thereof + * solely to the minimum extent necessary to exercise the above copyright + * license, and in no event shall the patent license extend to any additions + * to or modifications of the Original Intel Code. No other license or right + * is granted directly or by implication, estoppel or otherwise; + * + * The above copyright and patent license is granted only if the following + * conditions are met: + * + * 3. Conditions + * + * 3.1. Redistribution of Source with Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification with rights to further distribute source must include + * the above Copyright Notice, the above License, this list of Conditions, + * and the following Disclaimer and Export Compliance provision. In addition, + * Licensee must cause all Covered Code to which Licensee contributes to + * contain a file documenting the changes Licensee made to create that Covered + * Code and the date of any change. Licensee must include in that file the + * documentation of any changes made by any predecessor Licensee. Licensee + * must include a prominent statement that the modification is derived, + * directly or indirectly, from Original Intel Code. + * + * 3.2. Redistribution of Source with no Rights to Further Distribute Source. + * Redistribution of source code of any substantial portion of the Covered + * Code or modification without rights to further distribute source must + * include the following Disclaimer and Export Compliance provision in the + * documentation and/or other materials provided with distribution. In + * addition, Licensee may not authorize further sublicense of source of any + * portion of the Covered Code, and must include terms to the effect that the + * license from Licensee to its licensee is limited to the intellectual + * property embodied in the software Licensee provides to its licensee, and + * not to intellectual property embodied in modifications its licensee may + * make. + * + * 3.3. Redistribution of Executable. Redistribution in executable form of any + * substantial portion of the Covered Code or modification must reproduce the + * above Copyright Notice, and the following Disclaimer and Export Compliance + * provision in the documentation and/or other materials provided with the + * distribution. + * + * 3.4. Intel retains all right, title, and interest in and to the Original + * Intel Code. + * + * 3.5. Neither the name Intel nor any other trademark owned or controlled by + * Intel shall be used in advertising or otherwise to promote the sale, use or + * other dealings in products derived from or relating to the Covered Code + * without prior written authorization from Intel. + * + * 4. Disclaimer and Export Compliance + * + * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED + * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE + * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, + * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY + * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY + * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A + * PARTICULAR PURPOSE. + * + * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES + * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR + * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, + * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY + * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL + * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS + * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY + * LIMITED REMEDY. + * + * 4.3. Licensee shall not export, either directly or indirectly, any of this + * software or system incorporating such software without first obtaining any + * required license or other approval from the U. S. Department of Commerce or + * any other agency or department of the United States Government. In the + * event Licensee exports any such software from the United States or + * re-exports any such software from a foreign destination, Licensee shall + * ensure that the distribution and export/re-export of the software is in + * compliance with all laws, regulations, orders, or other restrictions of the + * U.S. Export Administration Regulations. Licensee agrees that neither it nor + * any of its subsidiaries will export/re-export any technical data, process, + * software, or service, directly or indirectly, to any country for which the + * United States government or any agency thereof requires an export license, + * other governmental approval, or letter of assurance, without first obtaining + * such license, approval or letter. + * + *****************************************************************************/ + +#ifndef __ACDOS16_H__ +#define __ACDOS16_H__ + + +/* NOTE: 16-bit ACPICA is no longer supported, December 2006 */ + +#define ACPI_USE_STANDARD_HEADERS +#define ACPI_MACHINE_WIDTH 16 + +/* Use a struct for 64-bit integers */ + +typedef struct +{ + unsigned long Lo; + unsigned long Hi; + +} COMPILER_DEPENDENT_UINT64; + +typedef struct +{ + long Lo; + long Hi; + +} COMPILER_DEPENDENT_INT64; + +/* + * Calling conventions: + * + * ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads) + * ACPI_EXTERNAL_XFACE - External ACPI interfaces + * ACPI_INTERNAL_XFACE - Internal ACPI interfaces + * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces + */ +#define ACPI_SYSTEM_XFACE __cdecl +#define ACPI_EXTERNAL_XFACE +#define ACPI_INTERNAL_XFACE +#define ACPI_INTERNAL_VAR_XFACE __cdecl + +#define ACPI_ASM_MACROS +#define BREAKPOINT3 +#define ACPI_DISABLE_IRQS() +#define ACPI_ENABLE_IRQS() +#define halt() +#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) +#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Acq) + + +#endif /* __ACDOS16_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/platform/acefi.h b/reactos/drivers/bus/acpi/acpica/include/platform/acefi.h new file mode 100644 index 00000000000..40afaa401cf --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/platform/acefi.h @@ -0,0 +1,147 @@ +/****************************************************************************** + * + * Name: acefi.h - OS specific defines, etc. + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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. + * + *****************************************************************************/ + +#ifndef __ACEFI_H__ +#define __ACEFI_H__ + +#include +#include +#include + + +/* _int64 works for both IA32 and IA64 */ + +#define COMPILER_DEPENDENT_INT64 __int64 +#define COMPILER_DEPENDENT_UINT64 unsigned __int64 + +/* + * Calling conventions: + * + * ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads) + * ACPI_EXTERNAL_XFACE - External ACPI interfaces + * ACPI_INTERNAL_XFACE - Internal ACPI interfaces + * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces + */ +#define ACPI_SYSTEM_XFACE +#define ACPI_EXTERNAL_XFACE +#define ACPI_INTERNAL_XFACE +#define ACPI_INTERNAL_VAR_XFACE + +/* warn C4142: redefinition of type */ + +#pragma warning(disable:4142) + + +#endif /* __ACEFI_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/platform/acenv.h b/reactos/drivers/bus/acpi/acpica/include/platform/acenv.h new file mode 100644 index 00000000000..58cb03bfc1a --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/platform/acenv.h @@ -0,0 +1,432 @@ +/****************************************************************************** + * + * Name: acenv.h - Host and compiler configuration + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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. + * + *****************************************************************************/ + +#ifndef __ACENV_H__ +#define __ACENV_H__ + +/* + * Environment configuration. The purpose of this file is to interface ACPICA + * to the local environment. This includes compiler-specific, OS-specific, + * and machine-specific configuration. + */ + +/* Types for ACPI_MUTEX_TYPE */ + +#define ACPI_BINARY_SEMAPHORE 0 +#define ACPI_OSL_MUTEX 1 + +/* Types for DEBUGGER_THREADING */ + +#define DEBUGGER_SINGLE_THREADED 0 +#define DEBUGGER_MULTI_THREADED 1 + + +/****************************************************************************** + * + * Configuration for ACPI tools and utilities + * + *****************************************************************************/ + +/* iASL configuration */ + +#ifdef ACPI_ASL_COMPILER +#define ACPI_APPLICATION +#define ACPI_DISASSEMBLER +#define ACPI_DEBUG_OUTPUT +#define ACPI_CONSTANT_EVAL_ONLY +#define ACPI_LARGE_NAMESPACE_NODE +#define ACPI_DATA_TABLE_DISASSEMBLY +#endif + +/* AcpiExec configuration */ + +#ifdef ACPI_EXEC_APP +#define ACPI_APPLICATION +#define ACPI_FULL_DEBUG +#define ACPI_MUTEX_DEBUG +#define ACPI_DBG_TRACK_ALLOCATIONS +#endif + +/* Linkable ACPICA library */ + +#ifdef ACPI_LIBRARY +#define ACPI_USE_LOCAL_CACHE +#endif + +/* Common for all ACPICA applications */ + +#ifdef ACPI_APPLICATION +#define ACPI_USE_SYSTEM_CLIBRARY +#define ACPI_USE_LOCAL_CACHE +#endif + +/* Common debug support */ + +#ifdef ACPI_FULL_DEBUG +#define ACPI_DEBUGGER +#define ACPI_DEBUG_OUTPUT +#define ACPI_DISASSEMBLER +#endif + + +/*! [Begin] no source code translation */ + +/****************************************************************************** + * + * Host configuration files. The compiler configuration files are included + * by the host files. + * + *****************************************************************************/ + +#if defined(_LINUX) || defined(__linux__) +#include "aclinux.h" + +#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +#include "acfreebsd.h" + +#elif defined(__NetBSD__) +#include "acnetbsd.h" + +#elif defined(__sun) +#include "acsolaris.h" + +#elif defined(MODESTO) +#include "acmodesto.h" + +#elif defined(NETWARE) +#include "acnetware.h" + +#elif defined(_CYGWIN) +#include "accygwin.h" + +#elif defined(WIN32) +#include "acwin.h" + +#elif defined(WIN64) +#include "acwin64.h" + +#elif defined(_WRS_LIB_BUILD) +#include "acvxworks.h" + +#elif defined(__OS2__) +#include "acos2.h" + +#elif defined(_AED_EFI) +#include "acefi.h" + +#else + +/* Unknown environment */ + +#error Unknown target environment +#endif + +/*! [End] no source code translation !*/ + + +/****************************************************************************** + * + * Setup defaults for the required symbols that were not defined in one of + * the host/compiler files above. + * + *****************************************************************************/ + +/* 64-bit data types */ + +#ifndef COMPILER_DEPENDENT_INT64 +#define COMPILER_DEPENDENT_INT64 long long +#endif + +#ifndef COMPILER_DEPENDENT_UINT64 +#define COMPILER_DEPENDENT_UINT64 unsigned long long +#endif + +/* Type of mutex supported by host. Default is binary semaphores. */ + +#ifndef ACPI_MUTEX_TYPE +#define ACPI_MUTEX_TYPE ACPI_BINARY_SEMAPHORE +#endif + +/* Global Lock acquire/release */ + +#ifndef ACPI_ACQUIRE_GLOBAL_LOCK +#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) Acq = 1 +#endif + +#ifndef ACPI_RELEASE_GLOBAL_LOCK +#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Acq) Acq = 0 +#endif + +/* Flush CPU cache - used when going to sleep. Wbinvd or similar. */ + +#ifndef ACPI_FLUSH_CPU_CACHE +#define ACPI_FLUSH_CPU_CACHE() +#endif + +/* + * Configurable calling conventions: + * + * ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads) + * ACPI_EXTERNAL_XFACE - External ACPI interfaces + * ACPI_INTERNAL_XFACE - Internal ACPI interfaces + * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces + */ +#ifndef ACPI_SYSTEM_XFACE +#define ACPI_SYSTEM_XFACE +#endif + +#ifndef ACPI_EXTERNAL_XFACE +#define ACPI_EXTERNAL_XFACE +#endif + +#ifndef ACPI_INTERNAL_XFACE +#define ACPI_INTERNAL_XFACE +#endif + +#ifndef ACPI_INTERNAL_VAR_XFACE +#define ACPI_INTERNAL_VAR_XFACE +#endif + +/* + * Debugger threading model + * Use single threaded if the entire subsystem is contained in an application + * Use multiple threaded when the subsystem is running in the kernel. + * + * By default the model is single threaded if ACPI_APPLICATION is set, + * multi-threaded if ACPI_APPLICATION is not set. + */ +#ifndef DEBUGGER_THREADING +#ifdef ACPI_APPLICATION +#define DEBUGGER_THREADING DEBUGGER_SINGLE_THREADED + +#else +#define DEBUGGER_THREADING DEBUGGER_MULTI_THREADED +#endif +#endif /* !DEBUGGER_THREADING */ + + +/****************************************************************************** + * + * C library configuration + * + *****************************************************************************/ + +/* + * ACPI_USE_SYSTEM_CLIBRARY - Define this if linking to an actual C library. + * Otherwise, local versions of string/memory functions will be used. + * ACPI_USE_STANDARD_HEADERS - Define this if linking to a C library and + * the standard header files may be used. + * + * The ACPICA subsystem only uses low level C library functions that do not call + * operating system services and may therefore be inlined in the code. + * + * It may be necessary to tailor these include files to the target + * generation environment. + */ +#ifdef ACPI_USE_SYSTEM_CLIBRARY + +/* Use the standard C library headers. We want to keep these to a minimum */ + +#ifdef ACPI_USE_STANDARD_HEADERS + +/* Use the standard headers from the standard locations */ + +#include +#include +#include +#include + +#endif /* ACPI_USE_STANDARD_HEADERS */ + +/* We will be linking to the standard Clib functions */ + +#define ACPI_STRSTR(s1,s2) strstr((s1), (s2)) +#define ACPI_STRCHR(s1,c) strchr((s1), (c)) +#define ACPI_STRLEN(s) (ACPI_SIZE) strlen((s)) +#define ACPI_STRCPY(d,s) (void) strcpy((d), (s)) +#define ACPI_STRNCPY(d,s,n) (void) strncpy((d), (s), (ACPI_SIZE)(n)) +#define ACPI_STRNCMP(d,s,n) strncmp((d), (s), (ACPI_SIZE)(n)) +#define ACPI_STRCMP(d,s) strcmp((d), (s)) +#define ACPI_STRCAT(d,s) (void) strcat((d), (s)) +#define ACPI_STRNCAT(d,s,n) strncat((d), (s), (ACPI_SIZE)(n)) +#define ACPI_STRTOUL(d,s,n) strtoul((d), (s), (ACPI_SIZE)(n)) +#define ACPI_MEMCMP(s1,s2,n) memcmp((const char *)(s1), (const char *)(s2), (ACPI_SIZE)(n)) +#define ACPI_MEMCPY(d,s,n) (void) memcpy((d), (s), (ACPI_SIZE)(n)) +#define ACPI_MEMSET(d,s,n) (void) memset((d), (s), (ACPI_SIZE)(n)) +#define ACPI_TOUPPER(i) toupper((int) (i)) +#define ACPI_TOLOWER(i) tolower((int) (i)) +#define ACPI_IS_XDIGIT(i) isxdigit((int) (i)) +#define ACPI_IS_DIGIT(i) isdigit((int) (i)) +#define ACPI_IS_SPACE(i) isspace((int) (i)) +#define ACPI_IS_UPPER(i) isupper((int) (i)) +#define ACPI_IS_PRINT(i) isprint((int) (i)) +#define ACPI_IS_ALPHA(i) isalpha((int) (i)) + +#else + +/****************************************************************************** + * + * Not using native C library, use local implementations + * + *****************************************************************************/ + +/* + * Use local definitions of C library macros and functions. These function + * implementations may not be as efficient as an inline or assembly code + * implementation provided by a native C library, but they are functionally + * equivalent. + */ +#ifndef va_arg + +#ifndef _VALIST +#define _VALIST +typedef char *va_list; +#endif /* _VALIST */ + +/* Storage alignment properties */ + +#define _AUPBND (sizeof (ACPI_NATIVE_INT) - 1) +#define _ADNBND (sizeof (ACPI_NATIVE_INT) - 1) + +/* Variable argument list macro definitions */ + +#define _Bnd(X, bnd) (((sizeof (X)) + (bnd)) & (~(bnd))) +#define va_arg(ap, T) (*(T *)(((ap) += (_Bnd (T, _AUPBND))) - (_Bnd (T,_ADNBND)))) +#define va_end(ap) (void) 0 +#define va_start(ap, A) (void) ((ap) = (((char *) &(A)) + (_Bnd (A,_AUPBND)))) + +#endif /* va_arg */ + +/* Use the local (ACPICA) definitions of the clib functions */ + +#define ACPI_STRSTR(s1,s2) AcpiUtStrstr ((s1), (s2)) +#define ACPI_STRCHR(s1,c) AcpiUtStrchr ((s1), (c)) +#define ACPI_STRLEN(s) (ACPI_SIZE) AcpiUtStrlen ((s)) +#define ACPI_STRCPY(d,s) (void) AcpiUtStrcpy ((d), (s)) +#define ACPI_STRNCPY(d,s,n) (void) AcpiUtStrncpy ((d), (s), (ACPI_SIZE)(n)) +#define ACPI_STRNCMP(d,s,n) AcpiUtStrncmp ((d), (s), (ACPI_SIZE)(n)) +#define ACPI_STRCMP(d,s) AcpiUtStrcmp ((d), (s)) +#define ACPI_STRCAT(d,s) (void) AcpiUtStrcat ((d), (s)) +#define ACPI_STRNCAT(d,s,n) AcpiUtStrncat ((d), (s), (ACPI_SIZE)(n)) +#define ACPI_STRTOUL(d,s,n) AcpiUtStrtoul ((d), (s), (ACPI_SIZE)(n)) +#define ACPI_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 + +#endif /* ACPI_USE_SYSTEM_CLIBRARY */ + +#endif /* __ACENV_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/platform/acfreebsd.h b/reactos/drivers/bus/acpi/acpica/include/platform/acfreebsd.h new file mode 100644 index 00000000000..20c5687c20b --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/platform/acfreebsd.h @@ -0,0 +1,180 @@ +/****************************************************************************** + * + * Name: acfreebsd.h - OS specific defines, etc. + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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. + * + *****************************************************************************/ + +#ifndef __ACFREEBSD_H__ +#define __ACFREEBSD_H__ + + +/* FreeBSD uses GCC */ + +#include "acgcc.h" +#include +#include + +#define ACPI_UINTPTR_T uintptr_t + +#define ACPI_USE_LOCAL_CACHE +#define ACPI_USE_SYSTEM_CLIBRARY + +#define __cdecl + +#ifdef _KERNEL + +#include +#include +#include +#include +#include + +#include "opt_acpi.h" + +#define ACPI_THREAD_ID lwpid_t + +#ifdef ACPI_DEBUG +#define ACPI_DEBUG_OUTPUT /* for backward compatibility */ +#define ACPI_DISASSEMBLER +#endif + +#ifdef ACPI_DEBUG_OUTPUT +#include "opt_ddb.h" +#ifdef DDB +#define ACPI_DEBUGGER +#endif /* DDB */ +#endif /* ACPI_DEBUG_OUTPUT */ + +#ifdef DEBUGGER_THREADING +#undef DEBUGGER_THREADING +#endif /* DEBUGGER_THREADING */ + +#define DEBUGGER_THREADING 0 /* integrated with DDB */ + +#else /* _KERNEL */ + +#if __STDC_HOSTED__ +#include +#endif + +#define ACPI_THREAD_ID pthread_t + +/* Not building kernel code, so use libc */ +#define ACPI_USE_STANDARD_HEADERS +#define ACPI_FLUSH_CPU_CACHE() + +#define __cli() +#define __sti() + +#endif /* _KERNEL */ + +#endif /* __ACFREEBSD_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/platform/acgcc.h b/reactos/drivers/bus/acpi/acpica/include/platform/acgcc.h new file mode 100644 index 00000000000..e517a23ae22 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/platform/acgcc.h @@ -0,0 +1,179 @@ +/****************************************************************************** + * + * Name: acgcc.h - GCC specific defines, etc. + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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. + * + *****************************************************************************/ + +#ifndef __ACGCC_H__ +#define __ACGCC_H__ + +/* Function name is used for debug output. Non-ANSI, compiler-dependent */ + +#define ACPI_GET_FUNCTION_NAME __FUNCTION__ + +/* + * This macro is used to tag functions as "printf-like" because + * some compilers (like GCC) can catch printf format string problems. + */ +#define ACPI_PRINTF_LIKE(c) __attribute__ ((__format__ (__printf__, c, c+1))) + +/* + * Some compilers complain about unused variables. Sometimes we don't want to + * use all the variables (for example, _AcpiModuleName). This allows us + * to to tell the compiler warning in a per-variable manner that a variable + * is unused. + */ +#define ACPI_UNUSED_VAR __attribute__ ((unused)) + +#define COMPILER_DEPENDENT_INT64 long long int +#define COMPILER_DEPENDENT_UINT64 unsigned long long int + +#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) \ + do { \ + int dummy; \ + asm("1: movl (%1),%%eax;" \ + "movl %%eax,%%edx;" \ + "andl %2,%%edx;" \ + "btsl $0x1,%%edx;" \ + "adcl $0x0,%%edx;" \ + "lock; cmpxchgl %%edx,(%1);" \ + "jnz 1b;" \ + "cmpb $0x3,%%dl;" \ + "sbbl %%eax,%%eax" \ + :"=a"(Acq),"=c"(dummy):"c"(GLptr),"i"(~1L):"dx"); \ + } while(0) + +#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Acq) \ + do { \ + int dummy; \ + asm("1: movl (%1),%%eax;" \ + "movl %%eax,%%edx;" \ + "andl %2,%%edx;" \ + "lock; cmpxchgl %%edx,(%1);" \ + "jnz 1b;" \ + "andl $0x1,%%eax" \ + :"=a"(Acq),"=c"(dummy):"c"(GLptr),"i"(~3L):"dx"); \ + } while(0) + +#define ACPI_DIV_64_BY_32(n_hi, n_lo, d32, q32, r32) \ +{ \ + q32 = n_hi / d32; \ + r32 = n_lo / d32; \ +} + +#define ACPI_SHIFT_RIGHT_64(n_hi, n_lo) \ +{ \ + n_hi >>= 1; \ + n_lo >>= 1; \ +} + +#endif /* __ACGCC_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/platform/acintel.h b/reactos/drivers/bus/acpi/acpica/include/platform/acintel.h new file mode 100644 index 00000000000..44197a09946 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/platform/acintel.h @@ -0,0 +1,168 @@ +/****************************************************************************** + * + * Name: acintel.h - VC specific defines, etc. + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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. + * + *****************************************************************************/ + +#ifndef __ACINTEL_H__ +#define __ACINTEL_H__ + + +#define COMPILER_DEPENDENT_INT64 __int64 +#define COMPILER_DEPENDENT_UINT64 unsigned __int64 + +#define inline __inline + +/* + * Calling conventions: + * + * ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads) + * ACPI_EXTERNAL_XFACE - External ACPI interfaces + * ACPI_INTERNAL_XFACE - Internal ACPI interfaces + * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces + */ +#define ACPI_SYSTEM_XFACE +#define ACPI_EXTERNAL_XFACE +#define ACPI_INTERNAL_XFACE +#define ACPI_INTERNAL_VAR_XFACE + +/* + * 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) + +/* warn C4100: unreferenced formal parameter */ +#pragma warning(disable:4100) + +/* warn C4127: conditional expression is constant */ +#pragma warning(disable:4127) + +/* warn C4706: assignment within conditional expression */ +#pragma warning(disable:4706) + +/* warn C4214: bit field types other than int */ +#pragma warning(disable:4214) + + +#endif /* __ACINTEL_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/platform/aclinux.h b/reactos/drivers/bus/acpi/acpica/include/platform/aclinux.h new file mode 100644 index 00000000000..c6f868cdbf9 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/platform/aclinux.h @@ -0,0 +1,233 @@ +/****************************************************************************** + * + * Name: aclinux.h - OS specific defines, etc. for Linux + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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. + * + *****************************************************************************/ + +#ifndef __ACLINUX_H__ +#define __ACLINUX_H__ + +/* Common (in-kernel/user-space) ACPICA configuration */ + +#define ACPI_USE_SYSTEM_CLIBRARY +#define ACPI_USE_DO_WHILE_0 +#define ACPI_MUTEX_TYPE ACPI_BINARY_SEMAPHORE + + +#ifdef __KERNEL__ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* Host-dependent types and defines for in-kernel ACPICA */ + +#define ACPI_MACHINE_WIDTH BITS_PER_LONG +#define ACPI_EXPORT_SYMBOL(symbol) EXPORT_SYMBOL(symbol); +#define strtoul simple_strtoul + +#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__ */ + +#include +#include +#include +#include +#include + +/* Host-dependent types and defines for user-space ACPICA */ + +#define ACPI_FLUSH_CPU_CACHE() +#define ACPI_THREAD_ID pthread_t + +#if defined(__ia64__) || defined(__x86_64__) +#define ACPI_MACHINE_WIDTH 64 +#define COMPILER_DEPENDENT_INT64 long +#define COMPILER_DEPENDENT_UINT64 unsigned long +#else +#define ACPI_MACHINE_WIDTH 32 +#define COMPILER_DEPENDENT_INT64 long long +#define COMPILER_DEPENDENT_UINT64 unsigned long long +#define ACPI_USE_NATIVE_DIVIDE +#endif + +#ifndef __cdecl +#define __cdecl +#endif + +#endif /* __KERNEL__ */ + +/* Linux uses GCC */ + +#include "acgcc.h" + + +#ifdef __KERNEL__ +/* + * Overrides for in-kernel ACPICA + */ +static inline acpi_thread_id acpi_os_get_thread_id(void) +{ + return current; +} + +/* + * The irqs_disabled() check is for resume from RAM. + * Interrupts are off during resume, just like they are for boot. + * However, boot has (system_state != SYSTEM_RUNNING) + * to quiet __might_sleep() in kmalloc() and resume does not. + */ +#include +static inline void *acpi_os_allocate(acpi_size size) +{ + return kmalloc(size, irqs_disabled() ? GFP_ATOMIC : GFP_KERNEL); +} + +static inline void *acpi_os_allocate_zeroed(acpi_size size) +{ + return kzalloc(size, irqs_disabled() ? GFP_ATOMIC : GFP_KERNEL); +} + +static inline void *acpi_os_acquire_object(acpi_cache_t * cache) +{ + return kmem_cache_zalloc(cache, + irqs_disabled() ? GFP_ATOMIC : GFP_KERNEL); +} + +#define ACPI_ALLOCATE(a) acpi_os_allocate(a) +#define ACPI_ALLOCATE_ZEROED(a) acpi_os_allocate_zeroed(a) +#define ACPI_FREE(a) kfree(a) + +/* Used within ACPICA to show where it is safe to preempt execution */ + +#define ACPI_PREEMPTION_POINT() \ + do { \ + if (!irqs_disabled()) \ + cond_resched(); \ + } while (0) + +#endif /* __KERNEL__ */ + +#endif /* __ACLINUX_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/platform/acmsvc.h b/reactos/drivers/bus/acpi/acpica/include/platform/acmsvc.h new file mode 100644 index 00000000000..ab9e75a88a8 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/platform/acmsvc.h @@ -0,0 +1,249 @@ +/****************************************************************************** + * + * Name: acmsvc.h - VC specific defines, etc. + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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. + * + *****************************************************************************/ + +#ifndef __ACMSVC_H__ +#define __ACMSVC_H__ + +#define COMPILER_DEPENDENT_INT64 __int64 +#define COMPILER_DEPENDENT_UINT64 unsigned __int64 + +/* + * Calling conventions: + * + * ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads) + * ACPI_EXTERNAL_XFACE - External ACPI interfaces + * ACPI_INTERNAL_XFACE - Internal ACPI interfaces + * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces + */ +#define ACPI_SYSTEM_XFACE __cdecl +#define ACPI_EXTERNAL_XFACE +#define ACPI_INTERNAL_XFACE +#define ACPI_INTERNAL_VAR_XFACE __cdecl + +#ifndef _LINT +/* + * Math helper functions + */ +#define ACPI_DIV_64_BY_32(n_hi, n_lo, d32, q32, r32) \ +{ \ + __asm mov edx, n_hi \ + __asm mov eax, n_lo \ + __asm div d32 \ + __asm mov q32, eax \ + __asm mov r32, edx \ +} + +#define ACPI_SHIFT_RIGHT_64(n_hi, n_lo) \ +{ \ + __asm shr n_hi, 1 \ + __asm rcr n_lo, 1 \ +} +#else + +/* Fake versions to make lint happy */ + +#define ACPI_DIV_64_BY_32(n_hi, n_lo, d32, q32, r32) \ +{ \ + q32 = n_hi / d32; \ + r32 = n_lo / d32; \ +} + +#define ACPI_SHIFT_RIGHT_64(n_hi, n_lo) \ +{ \ + n_hi >>= 1; \ + n_lo >>= 1; \ +} +#endif + +/*! [Begin] no source code translation */ + +#ifdef ACPI_APPLICATION +#define ACPI_FLUSH_CPU_CACHE() +#else +#define ACPI_FLUSH_CPU_CACHE() __asm {WBINVD} +#endif + +#ifdef _DEBUG +#define ACPI_SIMPLE_RETURN_MACROS +#endif + +/*! [End] no source code translation !*/ + +/* + * Global Lock acquire/release code + * + * Note: Handles case where the FACS pointer is null + */ +#define ACPI_ACQUIRE_GLOBAL_LOCK(FacsPtr, Acq) __asm \ +{ \ + __asm mov eax, 0xFF \ + __asm mov ecx, FacsPtr \ + __asm or ecx, ecx \ + __asm jz exit_acq \ + __asm lea ecx, [ecx].GlobalLock \ + \ + __asm acq10: \ + __asm mov eax, [ecx] \ + __asm mov edx, eax \ + __asm and edx, 0xFFFFFFFE \ + __asm bts edx, 1 \ + __asm adc edx, 0 \ + __asm lock cmpxchg dword ptr [ecx], edx \ + __asm jnz acq10 \ + \ + __asm cmp dl, 3 \ + __asm sbb eax, eax \ + \ + __asm exit_acq: \ + __asm mov Acq, al \ +} + +#define ACPI_RELEASE_GLOBAL_LOCK(FacsPtr, Pnd) __asm \ +{ \ + __asm xor eax, eax \ + __asm mov ecx, FacsPtr \ + __asm or ecx, ecx \ + __asm jz exit_rel \ + __asm lea ecx, [ecx].GlobalLock \ + \ + __asm Rel10: \ + __asm mov eax, [ecx] \ + __asm mov edx, eax \ + __asm and edx, 0xFFFFFFFC \ + __asm lock cmpxchg dword ptr [ecx], edx \ + __asm jnz Rel10 \ + \ + __asm cmp dl, 3 \ + __asm and eax, 1 \ + \ + __asm exit_rel: \ + __asm mov Pnd, al \ +} + + +/* warn C4100: unreferenced formal parameter */ +#pragma warning(disable:4100) + +/* warn C4127: conditional expression is constant */ +#pragma warning(disable:4127) + +/* warn C4706: assignment within conditional expression */ +#pragma warning(disable:4706) + +/* warn C4131: uses old-style declarator (iASL compiler only) */ +#pragma warning(disable:4131) + + +#endif /* __ACMSVC_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/platform/acnetbsd.h b/reactos/drivers/bus/acpi/acpica/include/platform/acnetbsd.h new file mode 100644 index 00000000000..c04851b926a --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/platform/acnetbsd.h @@ -0,0 +1,188 @@ +/****************************************************************************** + * + * Name: acnetbsd.h - OS specific defines, etc. + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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. + * + *****************************************************************************/ + +#ifndef __ACNETBSD_H__ +#define __ACNETBSD_H__ + +/* NetBSD uses GCC */ + +#include "acgcc.h" + +#ifdef _LP64 +#define ACPI_MACHINE_WIDTH 64 +#else +#define ACPI_MACHINE_WIDTH 32 +#endif + +#define COMPILER_DEPENDENT_INT64 int64_t +#define COMPILER_DEPENDENT_UINT64 uint64_t + +#ifdef _KERNEL +#include "opt_acpi.h" /* collect build-time options here */ + +#include +#include +#include +#include + +#define asm __asm + +#define ACPI_USE_NATIVE_DIVIDE + +#define ACPI_SYSTEM_XFACE +#define ACPI_EXTERNAL_XFACE +#define ACPI_INTERNAL_XFACE +#define ACPI_INTERNAL_VAR_XFACE + +#ifdef ACPI_DEBUG +#define ACPI_DEBUG_OUTPUT +#define ACPI_DBG_TRACK_ALLOCATIONS +#ifdef DEBUGGER_THREADING +#undef DEBUGGER_THREADING +#endif /* DEBUGGER_THREADING */ +#define DEBUGGER_THREADING 0 /* integrated with DDB */ +#include "opt_ddb.h" +#ifdef DDB +#define ACPI_DISASSEMBLER +#define ACPI_DEBUGGER +#endif /* DDB */ +#endif /* ACPI_DEBUG */ + +static __inline int +isprint(int ch) +{ + return(isspace(ch) || isascii(ch)); +} + +#else /* _KERNEL */ + +#include + +/* Not building kernel code, so use libc */ +#define ACPI_USE_STANDARD_HEADERS + +#define __cli() +#define __sti() + +/* XXX */ +#define __inline inline + +#endif /* _KERNEL */ + +/* Always use NetBSD code over our local versions */ +#define ACPI_USE_SYSTEM_CLIBRARY +#define ACPI_USE_NATIVE_DIVIDE + +#endif /* __ACNETBSD_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/platform/acos2.h b/reactos/drivers/bus/acpi/acpica/include/platform/acos2.h new file mode 100644 index 00000000000..21e3373c24d --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/platform/acos2.h @@ -0,0 +1,172 @@ +/****************************************************************************** + * + * Name: acos2.h - OS/2 specific defines, etc. + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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. + * + *****************************************************************************/ + +#ifndef __ACOS2_H__ +#define __ACOS2_H__ +#define INCL_LONGLONG +#include + + +#define ACPI_MACHINE_WIDTH 32 + +#define COMPILER_DEPENDENT_INT64 long long +#define COMPILER_DEPENDENT_UINT64 unsigned long long +#define ACPI_USE_NATIVE_DIVIDE + +#define ACPI_SYSTEM_XFACE APIENTRY +#define ACPI_EXTERNAL_XFACE APIENTRY +#define ACPI_INTERNAL_XFACE APIENTRY +#define ACPI_INTERNAL_VAR_XFACE APIENTRY + +/* + * Some compilers complain about unused variables. Sometimes we don't want to + * use all the variables (most specifically for _THIS_MODULE). This allow us + * to to tell the compiler warning in a per-variable manner that a variable + * is unused. + */ +#define ACPI_UNUSED_VAR + +#define ACPI_USE_STANDARD_HEADERS +#include + +#define ACPI_FLUSH_CPU_CACHE() Wbinvd() +void Wbinvd(void); + +#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) Acq = OSPMAcquireGlobalLock(GLptr) +#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Pnd) Pnd = OSPMReleaseGlobalLock(GLptr) +unsigned short OSPMAcquireGlobalLock (void *); +unsigned short OSPMReleaseGlobalLock (void *); + +#define ACPI_SHIFT_RIGHT_64(n_hi, n_lo) \ +{ \ + unsigned long long val = 0LL; \ + val = n_lo | ( ((unsigned long long)h_hi) << 32 ); \ + __llrotr (val,1); \ + n_hi = (unsigned long)((val >> 32 ) & 0xffffffff ); \ + 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 +#endif + +#endif /* __ACOS2_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/platform/acwin.h b/reactos/drivers/bus/acpi/acpica/include/platform/acwin.h new file mode 100644 index 00000000000..a1f6e856e6d --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/platform/acwin.h @@ -0,0 +1,157 @@ +/****************************************************************************** + * + * Name: acwin.h - OS specific defines, etc. + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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. + * + *****************************************************************************/ + +#ifndef __ACWIN_H__ +#define __ACWIN_H__ + +/*! [Begin] no source code translation (Keep the include) */ + +/* Windows uses VC */ +#ifdef _MSC_VER +#include "acmsvc.h" +#elif __GNUC__ +#include "acgcc.h" +#endif + +/*! [End] no source code translation !*/ + +#define ACPI_MACHINE_WIDTH 32 + +#define inline __inline + +#define ACPI_USE_STANDARD_HEADERS + +#ifdef ACPI_DEFINE_ALTERNATE_TYPES +/* + * Types used only in (Linux) translated source, defined here to enable + * cross-platform compilation (i.e., generate the Linux code on Windows, + * for test purposes only) + */ +typedef int s32; +typedef unsigned char u8; +typedef unsigned short u16; +typedef unsigned int u32; +typedef COMPILER_DEPENDENT_UINT64 u64; +#endif + +/* + * Handle platform- and compiler-specific assembly language differences. + * + * Notes: + * 1) Interrupt 3 is used to break into a debugger + * 2) Interrupts are turned off during ACPI register setup + */ + +#endif /* __ACWIN_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/include/platform/acwin64.h b/reactos/drivers/bus/acpi/acpica/include/platform/acwin64.h new file mode 100644 index 00000000000..faec855e22d --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/include/platform/acwin64.h @@ -0,0 +1,155 @@ +/****************************************************************************** + * + * Name: acwin.h - OS specific defines, etc. + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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. + * + *****************************************************************************/ + +#ifndef __ACWIN64_H__ +#define __ACWIN64_H__ + +/*! [Begin] no source code translation (Keep the include) */ + +#include "acintel.h" +/*! [End] no source code translation !*/ + +#define ACPI_MACHINE_WIDTH 64 + +#define ACPI_USE_STANDARD_HEADERS + +/* + * Handle platform- and compiler-specific assembly language differences. + * + * Notes: + * 1) Interrupt 3 is used to break into a debugger + * 2) Interrupts are turned off during ACPI register setup + */ + +/*! [Begin] no source code translation */ + +#define ACPI_FLUSH_CPU_CACHE() + +/* + * For Acpi applications, we don't want to try to access the global lock + */ +#ifdef ACPI_APPLICATION +#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) if (AcpiGbl_GlobalLockPresent) {Acq = 0xFF;} else {Acq = 0;} +#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Pnd) if (AcpiGbl_GlobalLockPresent) {Pnd = 0xFF;} else {Pnd = 0;} +#else + +#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) + +#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Pnd) + +#endif + + +#endif /* __ACWIN_H__ */ diff --git a/reactos/drivers/bus/acpi/acpica/namespace/nsaccess.c b/reactos/drivers/bus/acpi/acpica/namespace/nsaccess.c new file mode 100644 index 00000000000..2bc7d8d7118 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/namespace/nsaccess.c @@ -0,0 +1,772 @@ +/******************************************************************************* + * + * Module Name: nsaccess - Top-level functions for accessing ACPI namespace + * + ******************************************************************************/ + +/****************************************************************************** + * + * 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 __NSACCESS_C__ + +#include "acpi.h" +#include "accommon.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "acdispat.h" + + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nsaccess") + + +/******************************************************************************* + * + * FUNCTION: AcpiNsRootInitialize + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Allocate and initialize the default root named objects + * + * MUTEX: Locks namespace for entire execution + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsRootInitialize ( + void) +{ + ACPI_STATUS Status; + const ACPI_PREDEFINED_NAMES *InitVal = NULL; + ACPI_NAMESPACE_NODE *NewNode; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STRING Val = NULL; + + + ACPI_FUNCTION_TRACE (NsRootInitialize); + + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * The global root ptr is initially NULL, so a non-NULL value indicates + * that AcpiNsRootInitialize() has already been called; just return. + */ + if (AcpiGbl_RootNode) + { + Status = AE_OK; + goto UnlockAndExit; + } + + /* + * Tell the rest of the subsystem that the root is initialized + * (This is OK because the namespace is locked) + */ + AcpiGbl_RootNode = &AcpiGbl_RootNodeStruct; + + /* Enter the pre-defined names in the name table */ + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Entering predefined entries into namespace\n")); + + for (InitVal = AcpiGbl_PreDefinedNames; InitVal->Name; InitVal++) + { + /* _OSI is optional for now, will be permanent later */ + + if (!ACPI_STRCMP (InitVal->Name, "_OSI") && !AcpiGbl_CreateOsiMethod) + { + continue; + } + + Status = AcpiNsLookup (NULL, InitVal->Name, InitVal->Type, + ACPI_IMODE_LOAD_PASS2, ACPI_NS_NO_UPSEARCH, + NULL, &NewNode); + + if (ACPI_FAILURE (Status) || (!NewNode)) /* Must be on same line for code converter */ + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Could not create predefined name %s", + InitVal->Name)); + } + + /* + * Name entered successfully. If entry in PreDefinedNames[] specifies + * an initial value, create the initial value. + */ + if (InitVal->Val) + { + Status = AcpiOsPredefinedOverride (InitVal, &Val); + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR ((AE_INFO, + "Could not override predefined %s", + InitVal->Name)); + } + + if (!Val) + { + Val = InitVal->Val; + } + + /* + * Entry requests an initial value, allocate a + * descriptor for it. + */ + ObjDesc = AcpiUtCreateInternalObject (InitVal->Type); + if (!ObjDesc) + { + Status = AE_NO_MEMORY; + goto UnlockAndExit; + } + + /* + * Convert value string from table entry to + * internal representation. Only types actually + * used for initial values are implemented here. + */ + switch (InitVal->Type) + { + case ACPI_TYPE_METHOD: + ObjDesc->Method.ParamCount = (UINT8) ACPI_TO_INTEGER (Val); + ObjDesc->Common.Flags |= AOPOBJ_DATA_VALID; + +#if defined (ACPI_ASL_COMPILER) + + /* Save the parameter count for the iASL compiler */ + + NewNode->Value = ObjDesc->Method.ParamCount; +#else + /* Mark this as a very SPECIAL method */ + + ObjDesc->Method.MethodFlags = AML_METHOD_INTERNAL_ONLY; + ObjDesc->Method.Extra.Implementation = AcpiUtOsiImplementation; +#endif + break; + + case ACPI_TYPE_INTEGER: + + ObjDesc->Integer.Value = ACPI_TO_INTEGER (Val); + break; + + + case ACPI_TYPE_STRING: + + /* Build an object around the static string */ + + ObjDesc->String.Length = (UINT32) ACPI_STRLEN (Val); + ObjDesc->String.Pointer = Val; + ObjDesc->Common.Flags |= AOPOBJ_STATIC_POINTER; + break; + + + case ACPI_TYPE_MUTEX: + + ObjDesc->Mutex.Node = NewNode; + ObjDesc->Mutex.SyncLevel = (UINT8) (ACPI_TO_INTEGER (Val) - 1); + + /* Create a mutex */ + + Status = AcpiOsCreateMutex (&ObjDesc->Mutex.OsMutex); + if (ACPI_FAILURE (Status)) + { + AcpiUtRemoveReference (ObjDesc); + goto UnlockAndExit; + } + + /* Special case for ACPI Global Lock */ + + if (ACPI_STRCMP (InitVal->Name, "_GL_") == 0) + { + AcpiGbl_GlobalLockMutex = ObjDesc; + + /* Create additional counting semaphore for global lock */ + + Status = AcpiOsCreateSemaphore ( + 1, 0, &AcpiGbl_GlobalLockSemaphore); + if (ACPI_FAILURE (Status)) + { + AcpiUtRemoveReference (ObjDesc); + goto UnlockAndExit; + } + } + break; + + + default: + + ACPI_ERROR ((AE_INFO, "Unsupported initial type value %X", + InitVal->Type)); + AcpiUtRemoveReference (ObjDesc); + ObjDesc = NULL; + continue; + } + + /* Store pointer to value descriptor in the Node */ + + Status = AcpiNsAttachObject (NewNode, ObjDesc, + ObjDesc->Common.Type); + + /* Remove local reference to the object */ + + AcpiUtRemoveReference (ObjDesc); + } + } + + +UnlockAndExit: + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + + /* Save a handle to "_GPE", it is always present */ + + if (ACPI_SUCCESS (Status)) + { + Status = AcpiNsGetNode (NULL, "\\_GPE", ACPI_NS_NO_UPSEARCH, + &AcpiGbl_FadtGpeDevice); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsLookup + * + * PARAMETERS: ScopeInfo - Current scope info block + * Pathname - Search pathname, in internal format + * (as represented in the AML stream) + * Type - Type associated with name + * InterpreterMode - IMODE_LOAD_PASS2 => add name if not found + * Flags - Flags describing the search restrictions + * WalkState - Current state of the walk + * ReturnNode - Where the Node is placed (if found + * or created successfully) + * + * RETURN: Status + * + * DESCRIPTION: Find or enter the passed name in the name space. + * Log an error if name not found in Exec mode. + * + * MUTEX: Assumes namespace is locked. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsLookup ( + ACPI_GENERIC_STATE *ScopeInfo, + char *Pathname, + ACPI_OBJECT_TYPE Type, + ACPI_INTERPRETER_MODE InterpreterMode, + UINT32 Flags, + ACPI_WALK_STATE *WalkState, + ACPI_NAMESPACE_NODE **ReturnNode) +{ + ACPI_STATUS Status; + char *Path = Pathname; + ACPI_NAMESPACE_NODE *PrefixNode; + ACPI_NAMESPACE_NODE *CurrentNode = NULL; + ACPI_NAMESPACE_NODE *ThisNode = NULL; + UINT32 NumSegments; + UINT32 NumCarats; + ACPI_NAME SimpleName; + ACPI_OBJECT_TYPE TypeToCheckFor; + ACPI_OBJECT_TYPE ThisSearchType; + UINT32 SearchParentFlag = ACPI_NS_SEARCH_PARENT; + UINT32 LocalFlags; + + + ACPI_FUNCTION_TRACE (NsLookup); + + + if (!ReturnNode) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + LocalFlags = Flags & ~(ACPI_NS_ERROR_IF_FOUND | ACPI_NS_SEARCH_PARENT); + *ReturnNode = ACPI_ENTRY_NOT_FOUND; + AcpiGbl_NsLookupCount++; + + if (!AcpiGbl_RootNode) + { + return_ACPI_STATUS (AE_NO_NAMESPACE); + } + + /* Get the prefix scope. A null scope means use the root scope */ + + if ((!ScopeInfo) || + (!ScopeInfo->Scope.Node)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "Null scope prefix, using root node (%p)\n", + AcpiGbl_RootNode)); + + PrefixNode = AcpiGbl_RootNode; + } + else + { + PrefixNode = ScopeInfo->Scope.Node; + if (ACPI_GET_DESCRIPTOR_TYPE (PrefixNode) != ACPI_DESC_TYPE_NAMED) + { + ACPI_ERROR ((AE_INFO, "%p is not a namespace node [%s]", + PrefixNode, AcpiUtGetDescriptorName (PrefixNode))); + return_ACPI_STATUS (AE_AML_INTERNAL); + } + + if (!(Flags & ACPI_NS_PREFIX_IS_SCOPE)) + { + /* + * This node might not be a actual "scope" node (such as a + * Device/Method, etc.) It could be a Package or other object + * node. Backup up the tree to find the containing scope node. + */ + while (!AcpiNsOpensScope (PrefixNode->Type) && + PrefixNode->Type != ACPI_TYPE_ANY) + { + PrefixNode = AcpiNsGetParentNode (PrefixNode); + } + } + } + + /* Save type. TBD: may be no longer necessary */ + + TypeToCheckFor = Type; + + /* + * Begin examination of the actual pathname + */ + if (!Pathname) + { + /* A Null NamePath is allowed and refers to the root */ + + NumSegments = 0; + ThisNode = AcpiGbl_RootNode; + Path = ""; + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "Null Pathname (Zero segments), Flags=%X\n", Flags)); + } + else + { + /* + * Name pointer is valid (and must be in internal name format) + * + * Check for scope prefixes: + * + * As represented in the AML stream, a namepath consists of an + * optional scope prefix followed by a name segment part. + * + * If present, the scope prefix is either a Root Prefix (in + * which case the name is fully qualified), or one or more + * Parent Prefixes (in which case the name's scope is relative + * to the current scope). + */ + if (*Path == (UINT8) AML_ROOT_PREFIX) + { + /* Pathname is fully qualified, start from the root */ + + ThisNode = AcpiGbl_RootNode; + SearchParentFlag = ACPI_NS_NO_UPSEARCH; + + /* Point to name segment part */ + + Path++; + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "Path is absolute from root [%p]\n", ThisNode)); + } + else + { + /* Pathname is relative to current scope, start there */ + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "Searching relative to prefix scope [%4.4s] (%p)\n", + AcpiUtGetNodeName (PrefixNode), PrefixNode)); + + /* + * Handle multiple Parent Prefixes (carat) by just getting + * the parent node for each prefix instance. + */ + ThisNode = PrefixNode; + NumCarats = 0; + while (*Path == (UINT8) AML_PARENT_PREFIX) + { + /* Name is fully qualified, no search rules apply */ + + SearchParentFlag = ACPI_NS_NO_UPSEARCH; + + /* + * Point past this prefix to the name segment + * part or the next Parent Prefix + */ + Path++; + + /* Backup to the parent node */ + + NumCarats++; + ThisNode = AcpiNsGetParentNode (ThisNode); + if (!ThisNode) + { + /* Current scope has no parent scope */ + + ACPI_ERROR ((AE_INFO, + "ACPI path has too many parent prefixes (^) " + "- reached beyond root node")); + return_ACPI_STATUS (AE_NOT_FOUND); + } + } + + if (SearchParentFlag == ACPI_NS_NO_UPSEARCH) + { + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "Search scope is [%4.4s], path has %d carat(s)\n", + AcpiUtGetNodeName (ThisNode), NumCarats)); + } + } + + /* + * Determine the number of ACPI name segments in this pathname. + * + * The segment part consists of either: + * - A Null name segment (0) + * - A DualNamePrefix followed by two 4-byte name segments + * - A MultiNamePrefix followed by a byte indicating the + * number of segments and the segments themselves. + * - A single 4-byte name segment + * + * Examine the name prefix opcode, if any, to determine the number of + * segments. + */ + switch (*Path) + { + case 0: + /* + * Null name after a root or parent prefixes. We already + * have the correct target node and there are no name segments. + */ + NumSegments = 0; + Type = ThisNode->Type; + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "Prefix-only Pathname (Zero name segments), Flags=%X\n", + Flags)); + break; + + case AML_DUAL_NAME_PREFIX: + + /* More than one NameSeg, search rules do not apply */ + + SearchParentFlag = ACPI_NS_NO_UPSEARCH; + + /* Two segments, point to first name segment */ + + NumSegments = 2; + Path++; + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "Dual Pathname (2 segments, Flags=%X)\n", Flags)); + break; + + case AML_MULTI_NAME_PREFIX_OP: + + /* More than one NameSeg, search rules do not apply */ + + SearchParentFlag = ACPI_NS_NO_UPSEARCH; + + /* Extract segment count, point to first name segment */ + + Path++; + NumSegments = (UINT32) (UINT8) *Path; + Path++; + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "Multi Pathname (%d Segments, Flags=%X)\n", + NumSegments, Flags)); + break; + + default: + /* + * Not a Null name, no Dual or Multi prefix, hence there is + * only one name segment and Pathname is already pointing to it. + */ + NumSegments = 1; + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "Simple Pathname (1 segment, Flags=%X)\n", Flags)); + break; + } + + ACPI_DEBUG_EXEC (AcpiNsPrintPathname (NumSegments, Path)); + } + + + /* + * Search namespace for each segment of the name. Loop through and + * verify (or add to the namespace) each name segment. + * + * The object type is significant only at the last name + * segment. (We don't care about the types along the path, only + * the type of the final target object.) + */ + ThisSearchType = ACPI_TYPE_ANY; + CurrentNode = ThisNode; + while (NumSegments && CurrentNode) + { + NumSegments--; + if (!NumSegments) + { + /* This is the last segment, enable typechecking */ + + ThisSearchType = Type; + + /* + * Only allow automatic parent search (search rules) if the caller + * requested it AND we have a single, non-fully-qualified NameSeg + */ + if ((SearchParentFlag != ACPI_NS_NO_UPSEARCH) && + (Flags & ACPI_NS_SEARCH_PARENT)) + { + LocalFlags |= ACPI_NS_SEARCH_PARENT; + } + + /* Set error flag according to caller */ + + if (Flags & ACPI_NS_ERROR_IF_FOUND) + { + LocalFlags |= ACPI_NS_ERROR_IF_FOUND; + } + } + + /* Extract one ACPI name from the front of the pathname */ + + ACPI_MOVE_32_TO_32 (&SimpleName, Path); + + /* Try to find the single (4 character) ACPI name */ + + Status = AcpiNsSearchAndEnter (SimpleName, WalkState, CurrentNode, + InterpreterMode, ThisSearchType, LocalFlags, &ThisNode); + if (ACPI_FAILURE (Status)) + { + if (Status == AE_NOT_FOUND) + { + /* Name not found in ACPI namespace */ + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "Name [%4.4s] not found in scope [%4.4s] %p\n", + (char *) &SimpleName, (char *) &CurrentNode->Name, + CurrentNode)); + } + + *ReturnNode = ThisNode; + return_ACPI_STATUS (Status); + } + + /* More segments to follow? */ + + if (NumSegments > 0) + { + /* + * If we have an alias to an object that opens a scope (such as a + * device or processor), we need to dereference the alias here so + * that we can access any children of the original node (via the + * remaining segments). + */ + if (ThisNode->Type == ACPI_TYPE_LOCAL_ALIAS) + { + if (!ThisNode->Object) + { + return_ACPI_STATUS (AE_NOT_EXIST); + } + + if (AcpiNsOpensScope (((ACPI_NAMESPACE_NODE *) + ThisNode->Object)->Type)) + { + ThisNode = (ACPI_NAMESPACE_NODE *) ThisNode->Object; + } + } + } + + /* Special handling for the last segment (NumSegments == 0) */ + + else + { + /* + * Sanity typecheck of the target object: + * + * If 1) This is the last segment (NumSegments == 0) + * 2) And we are looking for a specific type + * (Not checking for TYPE_ANY) + * 3) Which is not an alias + * 4) Which is not a local type (TYPE_SCOPE) + * 5) And the type of target object is known (not TYPE_ANY) + * 6) And target object does not match what we are looking for + * + * Then we have a type mismatch. Just warn and ignore it. + */ + if ((TypeToCheckFor != ACPI_TYPE_ANY) && + (TypeToCheckFor != ACPI_TYPE_LOCAL_ALIAS) && + (TypeToCheckFor != ACPI_TYPE_LOCAL_METHOD_ALIAS) && + (TypeToCheckFor != ACPI_TYPE_LOCAL_SCOPE) && + (ThisNode->Type != ACPI_TYPE_ANY) && + (ThisNode->Type != TypeToCheckFor)) + { + /* Complain about a type mismatch */ + + ACPI_WARNING ((AE_INFO, + "NsLookup: Type mismatch on %4.4s (%s), searching for (%s)", + ACPI_CAST_PTR (char, &SimpleName), + AcpiUtGetTypeName (ThisNode->Type), + AcpiUtGetTypeName (TypeToCheckFor))); + } + + /* + * If this is the last name segment and we are not looking for a + * specific type, but the type of found object is known, use that + * type to (later) see if it opens a scope. + */ + if (Type == ACPI_TYPE_ANY) + { + Type = ThisNode->Type; + } + } + + /* Point to next name segment and make this node current */ + + Path += ACPI_NAME_SIZE; + CurrentNode = ThisNode; + } + + /* Always check if we need to open a new scope */ + + if (!(Flags & ACPI_NS_DONT_OPEN_SCOPE) && (WalkState)) + { + /* + * If entry is a type which opens a scope, push the new scope on the + * scope stack. + */ + if (AcpiNsOpensScope (Type)) + { + Status = AcpiDsScopeStackPush (ThisNode, Type, WalkState); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + } + + *ReturnNode = ThisNode; + return_ACPI_STATUS (AE_OK); +} + diff --git a/reactos/drivers/bus/acpi/acpica/namespace/nsalloc.c b/reactos/drivers/bus/acpi/acpica/namespace/nsalloc.c new file mode 100644 index 00000000000..9693cb7835a --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/namespace/nsalloc.c @@ -0,0 +1,666 @@ +/******************************************************************************* + * + * Module Name: nsalloc - Namespace allocation and deletion utilities + * + ******************************************************************************/ + +/****************************************************************************** + * + * 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 __NSALLOC_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nsalloc") + + +/******************************************************************************* + * + * FUNCTION: AcpiNsCreateNode + * + * PARAMETERS: Name - Name of the new node (4 char ACPI name) + * + * RETURN: New namespace node (Null on failure) + * + * DESCRIPTION: Create a namespace node + * + ******************************************************************************/ + +ACPI_NAMESPACE_NODE * +AcpiNsCreateNode ( + UINT32 Name) +{ + ACPI_NAMESPACE_NODE *Node; +#ifdef ACPI_DBG_TRACK_ALLOCATIONS + UINT32 Temp; +#endif + + + ACPI_FUNCTION_TRACE (NsCreateNode); + + + Node = AcpiOsAcquireObject (AcpiGbl_NamespaceCache); + if (!Node) + { + return_PTR (NULL); + } + + ACPI_MEM_TRACKING (AcpiGbl_NsNodeList->TotalAllocated++); + +#ifdef ACPI_DBG_TRACK_ALLOCATIONS + Temp = AcpiGbl_NsNodeList->TotalAllocated - + AcpiGbl_NsNodeList->TotalFreed; + if (Temp > AcpiGbl_NsNodeList->MaxOccupied) + { + AcpiGbl_NsNodeList->MaxOccupied = Temp; + } +#endif + + Node->Name.Integer = Name; + ACPI_SET_DESCRIPTOR_TYPE (Node, ACPI_DESC_TYPE_NAMED); + return_PTR (Node); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsDeleteNode + * + * PARAMETERS: Node - Node to be deleted + * + * RETURN: None + * + * DESCRIPTION: Delete a namespace node. All node deletions must come through + * here. Detaches any attached objects, including any attached + * data. If a handler is associated with attached data, it is + * invoked before the node is deleted. + * + ******************************************************************************/ + +void +AcpiNsDeleteNode ( + ACPI_NAMESPACE_NODE *Node) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + + + ACPI_FUNCTION_NAME (NsDeleteNode); + + + /* Detach an object if there is one */ + + AcpiNsDetachObject (Node); + + /* + * Delete an attached data object if present (an object that was created + * and attached via AcpiAttachData). Note: After any normal object is + * detached above, the only possible remaining object is a data object. + */ + ObjDesc = Node->Object; + if (ObjDesc && + (ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA)) + { + /* Invoke the attached data deletion handler if present */ + + if (ObjDesc->Data.Handler) + { + ObjDesc->Data.Handler (Node, ObjDesc->Data.Pointer); + } + + AcpiUtRemoveReference (ObjDesc); + } + + /* Now we can delete the node */ + + (void) AcpiOsReleaseObject (AcpiGbl_NamespaceCache, Node); + + ACPI_MEM_TRACKING (AcpiGbl_NsNodeList->TotalFreed++); + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Node %p, Remaining %X\n", + Node, AcpiGbl_CurrentNodeCount)); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsRemoveNode + * + * PARAMETERS: Node - Node to be removed/deleted + * + * RETURN: None + * + * DESCRIPTION: Remove (unlink) and delete a namespace node + * + ******************************************************************************/ + +void +AcpiNsRemoveNode ( + ACPI_NAMESPACE_NODE *Node) +{ + ACPI_NAMESPACE_NODE *ParentNode; + ACPI_NAMESPACE_NODE *PrevNode; + ACPI_NAMESPACE_NODE *NextNode; + + + ACPI_FUNCTION_TRACE_PTR (NsRemoveNode, Node); + + + ParentNode = AcpiNsGetParentNode (Node); + + PrevNode = NULL; + NextNode = ParentNode->Child; + + /* Find the node that is the previous peer in the parent's child list */ + + while (NextNode != Node) + { + PrevNode = NextNode; + NextNode = PrevNode->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; + } + } + 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; + } + } + + /* Delete the node and any attached objects */ + + AcpiNsDeleteNode (Node); + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsInstallNode + * + * PARAMETERS: WalkState - Current state of the walk + * ParentNode - The parent of the new Node + * Node - The new Node to install + * Type - ACPI object type of the new Node + * + * RETURN: None + * + * DESCRIPTION: Initialize a new namespace node and install it amongst + * its peers. + * + * Note: Current namespace lookup is linear search. This appears + * to be sufficient as namespace searches consume only a small + * fraction of the execution time of the ACPI subsystem. + * + ******************************************************************************/ + +void +AcpiNsInstallNode ( + ACPI_WALK_STATE *WalkState, + ACPI_NAMESPACE_NODE *ParentNode, /* Parent */ + ACPI_NAMESPACE_NODE *Node, /* New Child*/ + ACPI_OBJECT_TYPE Type) +{ + ACPI_OWNER_ID OwnerId = 0; + ACPI_NAMESPACE_NODE *ChildNode; + + + ACPI_FUNCTION_TRACE (NsInstallNode); + + + /* + * Get the owner ID from the Walk state. The owner ID is used to track + * table deletion and deletion of objects created by methods. + */ + if (WalkState) + { + OwnerId = WalkState->OwnerId; + } + + /* Link the new entry into the parent and existing children */ + + ChildNode = ParentNode->Child; + if (!ChildNode) + { + ParentNode->Child = Node; + Node->Flags |= ANOBJ_END_OF_PEER_LIST; + Node->Peer = ParentNode; + } + else + { + while (!(ChildNode->Flags & ANOBJ_END_OF_PEER_LIST)) + { + ChildNode = ChildNode->Peer; + } + + ChildNode->Peer = Node; + + /* Clear end-of-list flag */ + + ChildNode->Flags &= ~ANOBJ_END_OF_PEER_LIST; + Node->Flags |= ANOBJ_END_OF_PEER_LIST; + Node->Peer = ParentNode; + } + + /* Init the new entry */ + + Node->OwnerId = OwnerId; + Node->Type = (UINT8) Type; + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "%4.4s (%s) [Node %p Owner %X] added to %4.4s (%s) [Node %p]\n", + AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type), Node, OwnerId, + AcpiUtGetNodeName (ParentNode), AcpiUtGetTypeName (ParentNode->Type), + ParentNode)); + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsDeleteChildren + * + * PARAMETERS: ParentNode - Delete this objects children + * + * RETURN: None. + * + * DESCRIPTION: Delete all children of the parent object. In other words, + * deletes a "scope". + * + ******************************************************************************/ + +void +AcpiNsDeleteChildren ( + ACPI_NAMESPACE_NODE *ParentNode) +{ + ACPI_NAMESPACE_NODE *ChildNode; + ACPI_NAMESPACE_NODE *NextNode; + UINT8 Flags; + + + ACPI_FUNCTION_TRACE_PTR (NsDeleteChildren, ParentNode); + + + if (!ParentNode) + { + return_VOID; + } + + /* If no children, all done! */ + + ChildNode = ParentNode->Child; + if (!ChildNode) + { + return_VOID; + } + + /* Deallocate all children at this level */ + + do + { + /* Get the things we need */ + + NextNode = ChildNode->Peer; + Flags = ChildNode->Flags; + + /* Grandchildren should have all been deleted already */ + + if (ChildNode->Child) + { + ACPI_ERROR ((AE_INFO, "Found a grandchild! P=%p C=%p", + ParentNode, ChildNode)); + } + + /* + * 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. + */ + AcpiNsDeleteNode (ChildNode); + ChildNode = NextNode; + + } while (!(Flags & ANOBJ_END_OF_PEER_LIST)); + + /* Clear the parent's child pointer */ + + ParentNode->Child = NULL; + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsDeleteNamespaceSubtree + * + * PARAMETERS: ParentNode - Root of the subtree to be deleted + * + * RETURN: None. + * + * DESCRIPTION: Delete a subtree of the namespace. This includes all objects + * stored within the subtree. + * + ******************************************************************************/ + +void +AcpiNsDeleteNamespaceSubtree ( + ACPI_NAMESPACE_NODE *ParentNode) +{ + ACPI_NAMESPACE_NODE *ChildNode = NULL; + UINT32 Level = 1; + + + ACPI_FUNCTION_TRACE (NsDeleteNamespaceSubtree); + + + if (!ParentNode) + { + return_VOID; + } + + /* + * Traverse the tree of objects until we bubble back up + * to where we started. + */ + while (Level > 0) + { + /* Get the next node in this scope (NULL if none) */ + + ChildNode = AcpiNsGetNextNode (ParentNode, ChildNode); + if (ChildNode) + { + /* Found a child node - detach any attached object */ + + AcpiNsDetachObject (ChildNode); + + /* Check if this node has any children */ + + if (ChildNode->Child) + { + /* + * There is at least one child of this node, + * visit the node + */ + Level++; + ParentNode = ChildNode; + ChildNode = NULL; + } + } + else + { + /* + * No more children of this parent node. + * Move up to the grandparent. + */ + Level--; + + /* + * Now delete all of the children of this parent + * all at the same time. + */ + AcpiNsDeleteChildren (ParentNode); + + /* New "last child" is this parent node */ + + ChildNode = ParentNode; + + /* Move up the tree to the grandparent */ + + ParentNode = AcpiNsGetParentNode (ParentNode); + } + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsDeleteNamespaceByOwner + * + * PARAMETERS: OwnerId - All nodes with this owner will be deleted + * + * RETURN: Status + * + * DESCRIPTION: Delete entries within the namespace that are owned by a + * specific ID. Used to delete entire ACPI tables. All + * reference counts are updated. + * + * MUTEX: Locks namespace during deletion walk. + * + ******************************************************************************/ + +void +AcpiNsDeleteNamespaceByOwner ( + ACPI_OWNER_ID OwnerId) +{ + ACPI_NAMESPACE_NODE *ChildNode; + ACPI_NAMESPACE_NODE *DeletionNode; + ACPI_NAMESPACE_NODE *ParentNode; + UINT32 Level; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE_U32 (NsDeleteNamespaceByOwner, OwnerId); + + + if (OwnerId == 0) + { + return_VOID; + } + + /* Lock namespace for possible update */ + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_VOID; + } + + DeletionNode = NULL; + ParentNode = AcpiGbl_RootNode; + ChildNode = NULL; + Level = 1; + + /* + * Traverse the tree of nodes until we bubble back up + * to where we started. + */ + while (Level > 0) + { + /* + * Get the next child of this parent node. When ChildNode is NULL, + * the first child of the parent is returned + */ + ChildNode = AcpiNsGetNextNode (ParentNode, ChildNode); + + if (DeletionNode) + { + AcpiNsDeleteChildren (DeletionNode); + AcpiNsRemoveNode (DeletionNode); + DeletionNode = NULL; + } + + if (ChildNode) + { + if (ChildNode->OwnerId == OwnerId) + { + /* Found a matching child node - detach any attached object */ + + AcpiNsDetachObject (ChildNode); + } + + /* Check if this node has any children */ + + if (ChildNode->Child) + { + /* + * There is at least one child of this node, + * visit the node + */ + Level++; + ParentNode = ChildNode; + ChildNode = NULL; + } + else if (ChildNode->OwnerId == OwnerId) + { + DeletionNode = ChildNode; + } + } + else + { + /* + * No more children of this parent node. + * Move up to the grandparent. + */ + Level--; + if (Level != 0) + { + if (ParentNode->OwnerId == OwnerId) + { + DeletionNode = ParentNode; + } + } + + /* New "last child" is this parent node */ + + ChildNode = ParentNode; + + /* Move up the tree to the grandparent */ + + ParentNode = AcpiNsGetParentNode (ParentNode); + } + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return_VOID; +} + + diff --git a/reactos/drivers/bus/acpi/acpica/namespace/nsdump.c b/reactos/drivers/bus/acpi/acpica/namespace/nsdump.c new file mode 100644 index 00000000000..d799f7c64ce --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/namespace/nsdump.c @@ -0,0 +1,826 @@ +/****************************************************************************** + * + * Module Name: nsdump - table dumping routines for debug + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __NSDUMP_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nsdump") + +/* Local prototypes */ + +#ifdef ACPI_OBSOLETE_FUNCTIONS +void +AcpiNsDumpRootDevices ( + void); + +static ACPI_STATUS +AcpiNsDumpOneDevice ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue); +#endif + + +#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) +/******************************************************************************* + * + * FUNCTION: AcpiNsPrintPathname + * + * PARAMETERS: NumSegments - Number of ACPI name segments + * Pathname - The compressed (internal) path + * + * RETURN: None + * + * DESCRIPTION: Print an object's full namespace pathname + * + ******************************************************************************/ + +void +AcpiNsPrintPathname ( + UINT32 NumSegments, + char *Pathname) +{ + UINT32 i; + + + ACPI_FUNCTION_NAME (NsPrintPathname); + + + if (!(AcpiDbgLevel & ACPI_LV_NAMES) || !(AcpiDbgLayer & ACPI_NAMESPACE)) + { + return; + } + + /* Print the entire name */ + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "[")); + + while (NumSegments) + { + for (i = 0; i < 4; i++) + { + ACPI_IS_PRINT (Pathname[i]) ? + AcpiOsPrintf ("%c", Pathname[i]) : + AcpiOsPrintf ("?"); + } + + Pathname += ACPI_NAME_SIZE; + NumSegments--; + if (NumSegments) + { + AcpiOsPrintf ("."); + } + } + + AcpiOsPrintf ("]\n"); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsDumpPathname + * + * PARAMETERS: Handle - Object + * Msg - Prefix message + * Level - Desired debug level + * Component - Caller's component ID + * + * RETURN: None + * + * DESCRIPTION: Print an object's full namespace pathname + * Manages allocation/freeing of a pathname buffer + * + ******************************************************************************/ + +void +AcpiNsDumpPathname ( + ACPI_HANDLE Handle, + char *Msg, + UINT32 Level, + UINT32 Component) +{ + + ACPI_FUNCTION_TRACE (NsDumpPathname); + + + /* Do this only if the requested debug level and component are enabled */ + + if (!(AcpiDbgLevel & Level) || !(AcpiDbgLayer & Component)) + { + return_VOID; + } + + /* Convert handle to a full pathname and print it (with supplied message) */ + + AcpiNsPrintNodePathname (Handle, Msg); + AcpiOsPrintf ("\n"); + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsDumpOneObject + * + * PARAMETERS: ObjHandle - Node to be dumped + * Level - Nesting level of the handle + * Context - Passed into WalkNamespace + * ReturnValue - Not used + * + * RETURN: Status + * + * DESCRIPTION: Dump a single Node + * This procedure is a UserFunction called by AcpiNsWalkNamespace. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsDumpOneObject ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue) +{ + ACPI_WALK_INFO *Info = (ACPI_WALK_INFO *) Context; + ACPI_NAMESPACE_NODE *ThisNode; + ACPI_OPERAND_OBJECT *ObjDesc = NULL; + ACPI_OBJECT_TYPE ObjType; + ACPI_OBJECT_TYPE Type; + UINT32 BytesToDump; + UINT32 DbgLevel; + UINT32 i; + + + ACPI_FUNCTION_NAME (NsDumpOneObject); + + + /* Is output enabled? */ + + if (!(AcpiDbgLevel & Info->DebugLevel)) + { + return (AE_OK); + } + + if (!ObjHandle) + { + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Null object handle\n")); + return (AE_OK); + } + + ThisNode = AcpiNsValidateHandle (ObjHandle); + if (!ThisNode) + { + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Invalid object handle %p\n", + ObjHandle)); + return (AE_OK); + } + + Type = ThisNode->Type; + + /* Check if the owner matches */ + + if ((Info->OwnerId != ACPI_OWNER_ID_MAX) && + (Info->OwnerId != ThisNode->OwnerId)) + { + return (AE_OK); + } + + if (!(Info->DisplayType & ACPI_DISPLAY_SHORT)) + { + /* Indent the object according to the level */ + + AcpiOsPrintf ("%2d%*s", (UINT32) Level - 1, (int) Level * 2, " "); + + /* Check the node type and name */ + + if (Type > ACPI_TYPE_LOCAL_MAX) + { + ACPI_WARNING ((AE_INFO, "Invalid ACPI Object Type %08X", Type)); + } + + AcpiOsPrintf ("%4.4s", AcpiUtGetNodeName (ThisNode)); + } + + /* Now we can print out the pertinent information */ + + AcpiOsPrintf (" %-12s %p %2.2X ", + AcpiUtGetTypeName (Type), ThisNode, ThisNode->OwnerId); + + DbgLevel = AcpiDbgLevel; + AcpiDbgLevel = 0; + ObjDesc = AcpiNsGetAttachedObject (ThisNode); + AcpiDbgLevel = DbgLevel; + + /* Temp nodes are those nodes created by a control method */ + + if (ThisNode->Flags & ANOBJ_TEMPORARY) + { + AcpiOsPrintf ("(T) "); + } + + switch (Info->DisplayType & ACPI_DISPLAY_MASK) + { + case ACPI_DISPLAY_SUMMARY: + + if (!ObjDesc) + { + /* No attached object, we are done */ + + AcpiOsPrintf ("\n"); + return (AE_OK); + } + + switch (Type) + { + case ACPI_TYPE_PROCESSOR: + + AcpiOsPrintf ("ID %X Len %.4X Addr %p\n", + ObjDesc->Processor.ProcId, ObjDesc->Processor.Length, + ACPI_CAST_PTR (void, ObjDesc->Processor.Address)); + break; + + + case ACPI_TYPE_DEVICE: + + AcpiOsPrintf ("Notify Object: %p\n", ObjDesc); + break; + + + case ACPI_TYPE_METHOD: + + AcpiOsPrintf ("Args %X Len %.4X Aml %p\n", + (UINT32) ObjDesc->Method.ParamCount, + ObjDesc->Method.AmlLength, ObjDesc->Method.AmlStart); + break; + + + case ACPI_TYPE_INTEGER: + + AcpiOsPrintf ("= %8.8X%8.8X\n", + ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value)); + break; + + + case ACPI_TYPE_PACKAGE: + + if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) + { + AcpiOsPrintf ("Elements %.2X\n", + ObjDesc->Package.Count); + } + else + { + AcpiOsPrintf ("[Length not yet evaluated]\n"); + } + break; + + + case ACPI_TYPE_BUFFER: + + if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) + { + AcpiOsPrintf ("Len %.2X", + ObjDesc->Buffer.Length); + + /* Dump some of the buffer */ + + if (ObjDesc->Buffer.Length > 0) + { + AcpiOsPrintf (" ="); + for (i = 0; (i < ObjDesc->Buffer.Length && i < 12); i++) + { + AcpiOsPrintf (" %.2hX", ObjDesc->Buffer.Pointer[i]); + } + } + AcpiOsPrintf ("\n"); + } + else + { + AcpiOsPrintf ("[Length not yet evaluated]\n"); + } + break; + + + case ACPI_TYPE_STRING: + + AcpiOsPrintf ("Len %.2X ", ObjDesc->String.Length); + AcpiUtPrintString (ObjDesc->String.Pointer, 32); + AcpiOsPrintf ("\n"); + break; + + + case ACPI_TYPE_REGION: + + AcpiOsPrintf ("[%s]", + AcpiUtGetRegionName (ObjDesc->Region.SpaceId)); + if (ObjDesc->Region.Flags & AOPOBJ_DATA_VALID) + { + AcpiOsPrintf (" Addr %8.8X%8.8X Len %.4X\n", + ACPI_FORMAT_NATIVE_UINT (ObjDesc->Region.Address), + ObjDesc->Region.Length); + } + else + { + AcpiOsPrintf (" [Address/Length not yet evaluated]\n"); + } + break; + + + case ACPI_TYPE_LOCAL_REFERENCE: + + AcpiOsPrintf ("[%s]\n", AcpiUtGetReferenceName (ObjDesc)); + break; + + + case ACPI_TYPE_BUFFER_FIELD: + + if (ObjDesc->BufferField.BufferObj && + ObjDesc->BufferField.BufferObj->Buffer.Node) + { + AcpiOsPrintf ("Buf [%4.4s]", + AcpiUtGetNodeName ( + ObjDesc->BufferField.BufferObj->Buffer.Node)); + } + break; + + + case ACPI_TYPE_LOCAL_REGION_FIELD: + + AcpiOsPrintf ("Rgn [%4.4s]", + AcpiUtGetNodeName ( + ObjDesc->CommonField.RegionObj->Region.Node)); + break; + + + case ACPI_TYPE_LOCAL_BANK_FIELD: + + AcpiOsPrintf ("Rgn [%4.4s] Bnk [%4.4s]", + AcpiUtGetNodeName ( + ObjDesc->CommonField.RegionObj->Region.Node), + AcpiUtGetNodeName ( + ObjDesc->BankField.BankObj->CommonField.Node)); + break; + + + case ACPI_TYPE_LOCAL_INDEX_FIELD: + + AcpiOsPrintf ("Idx [%4.4s] Dat [%4.4s]", + AcpiUtGetNodeName ( + ObjDesc->IndexField.IndexObj->CommonField.Node), + AcpiUtGetNodeName ( + ObjDesc->IndexField.DataObj->CommonField.Node)); + break; + + + case ACPI_TYPE_LOCAL_ALIAS: + case ACPI_TYPE_LOCAL_METHOD_ALIAS: + + AcpiOsPrintf ("Target %4.4s (%p)\n", + AcpiUtGetNodeName (ObjDesc), ObjDesc); + break; + + default: + + AcpiOsPrintf ("Object %p\n", ObjDesc); + break; + } + + /* Common field handling */ + + switch (Type) + { + case ACPI_TYPE_BUFFER_FIELD: + case ACPI_TYPE_LOCAL_REGION_FIELD: + case ACPI_TYPE_LOCAL_BANK_FIELD: + case ACPI_TYPE_LOCAL_INDEX_FIELD: + + AcpiOsPrintf (" Off %.3X Len %.2X Acc %.2hd\n", + (ObjDesc->CommonField.BaseByteOffset * 8) + + ObjDesc->CommonField.StartFieldBitOffset, + ObjDesc->CommonField.BitLength, + ObjDesc->CommonField.AccessByteWidth); + break; + + default: + break; + } + break; + + + case ACPI_DISPLAY_OBJECTS: + + AcpiOsPrintf ("O:%p", ObjDesc); + if (!ObjDesc) + { + /* No attached object, we are done */ + + AcpiOsPrintf ("\n"); + return (AE_OK); + } + + AcpiOsPrintf ("(R%d)", ObjDesc->Common.ReferenceCount); + + switch (Type) + { + case ACPI_TYPE_METHOD: + + /* Name is a Method and its AML offset/length are set */ + + AcpiOsPrintf (" M:%p-%X\n", ObjDesc->Method.AmlStart, + ObjDesc->Method.AmlLength); + break; + + case ACPI_TYPE_INTEGER: + + AcpiOsPrintf (" I:%8.8X8.8%X\n", + ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value)); + break; + + case ACPI_TYPE_STRING: + + AcpiOsPrintf (" S:%p-%X\n", ObjDesc->String.Pointer, + ObjDesc->String.Length); + break; + + case ACPI_TYPE_BUFFER: + + AcpiOsPrintf (" B:%p-%X\n", ObjDesc->Buffer.Pointer, + ObjDesc->Buffer.Length); + break; + + default: + + AcpiOsPrintf ("\n"); + break; + } + break; + + + default: + AcpiOsPrintf ("\n"); + break; + } + + /* If debug turned off, done */ + + if (!(AcpiDbgLevel & ACPI_LV_VALUES)) + { + return (AE_OK); + } + + /* If there is an attached object, display it */ + + DbgLevel = AcpiDbgLevel; + AcpiDbgLevel = 0; + ObjDesc = AcpiNsGetAttachedObject (ThisNode); + AcpiDbgLevel = DbgLevel; + + /* Dump attached objects */ + + while (ObjDesc) + { + ObjType = ACPI_TYPE_INVALID; + AcpiOsPrintf ("Attached Object %p: ", ObjDesc); + + /* Decode the type of attached object and dump the contents */ + + switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc)) + { + case ACPI_DESC_TYPE_NAMED: + + AcpiOsPrintf ("(Ptr to Node)\n"); + BytesToDump = sizeof (ACPI_NAMESPACE_NODE); + ACPI_DUMP_BUFFER (ObjDesc, BytesToDump); + break; + + case ACPI_DESC_TYPE_OPERAND: + + ObjType = ObjDesc->Common.Type; + + if (ObjType > ACPI_TYPE_LOCAL_MAX) + { + AcpiOsPrintf ("(Pointer to ACPI Object type %.2X [UNKNOWN])\n", + ObjType); + BytesToDump = 32; + } + else + { + AcpiOsPrintf ("(Pointer to ACPI Object type %.2X [%s])\n", + ObjType, AcpiUtGetTypeName (ObjType)); + BytesToDump = sizeof (ACPI_OPERAND_OBJECT); + } + + ACPI_DUMP_BUFFER (ObjDesc, BytesToDump); + break; + + default: + + break; + } + + /* If value is NOT an internal object, we are done */ + + if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND) + { + goto Cleanup; + } + + /* Valid object, get the pointer to next level, if any */ + + switch (ObjType) + { + case ACPI_TYPE_BUFFER: + case ACPI_TYPE_STRING: + /* + * NOTE: takes advantage of common fields between string/buffer + */ + BytesToDump = ObjDesc->String.Length; + ObjDesc = (void *) ObjDesc->String.Pointer; + AcpiOsPrintf ( "(Buffer/String pointer %p length %X)\n", + ObjDesc, BytesToDump); + ACPI_DUMP_BUFFER (ObjDesc, BytesToDump); + goto Cleanup; + + case ACPI_TYPE_BUFFER_FIELD: + ObjDesc = (ACPI_OPERAND_OBJECT *) ObjDesc->BufferField.BufferObj; + break; + + case ACPI_TYPE_PACKAGE: + ObjDesc = (void *) ObjDesc->Package.Elements; + break; + + case ACPI_TYPE_METHOD: + ObjDesc = (void *) ObjDesc->Method.AmlStart; + break; + + case ACPI_TYPE_LOCAL_REGION_FIELD: + ObjDesc = (void *) ObjDesc->Field.RegionObj; + break; + + case ACPI_TYPE_LOCAL_BANK_FIELD: + ObjDesc = (void *) ObjDesc->BankField.RegionObj; + break; + + case ACPI_TYPE_LOCAL_INDEX_FIELD: + ObjDesc = (void *) ObjDesc->IndexField.IndexObj; + break; + + default: + goto Cleanup; + } + + ObjType = ACPI_TYPE_INVALID; /* Terminate loop after next pass */ + } + +Cleanup: + AcpiOsPrintf ("\n"); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsDumpObjects + * + * PARAMETERS: Type - Object type to be dumped + * DisplayType - 0 or ACPI_DISPLAY_SUMMARY + * MaxDepth - Maximum depth of dump. Use ACPI_UINT32_MAX + * for an effectively unlimited depth. + * OwnerId - Dump only objects owned by this ID. Use + * ACPI_UINT32_MAX to match all owners. + * StartHandle - Where in namespace to start/end search + * + * RETURN: None + * + * DESCRIPTION: Dump typed objects within the loaded namespace. Uses + * AcpiNsWalkNamespace in conjunction with AcpiNsDumpOneObject. + * + ******************************************************************************/ + +void +AcpiNsDumpObjects ( + ACPI_OBJECT_TYPE Type, + UINT8 DisplayType, + UINT32 MaxDepth, + ACPI_OWNER_ID OwnerId, + ACPI_HANDLE StartHandle) +{ + ACPI_WALK_INFO Info; + + + ACPI_FUNCTION_ENTRY (); + + + Info.DebugLevel = ACPI_LV_TABLES; + Info.OwnerId = OwnerId; + Info.DisplayType = DisplayType; + + (void) AcpiNsWalkNamespace (Type, StartHandle, MaxDepth, + ACPI_NS_WALK_NO_UNLOCK | ACPI_NS_WALK_TEMP_NODES, + AcpiNsDumpOneObject, NULL, (void *) &Info, NULL); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsDumpEntry + * + * PARAMETERS: Handle - Node to be dumped + * DebugLevel - Output level + * + * RETURN: None + * + * DESCRIPTION: Dump a single Node + * + ******************************************************************************/ + +void +AcpiNsDumpEntry ( + ACPI_HANDLE Handle, + UINT32 DebugLevel) +{ + ACPI_WALK_INFO Info; + + + ACPI_FUNCTION_ENTRY (); + + + Info.DebugLevel = DebugLevel; + Info.OwnerId = ACPI_OWNER_ID_MAX; + Info.DisplayType = ACPI_DISPLAY_SUMMARY; + + (void) AcpiNsDumpOneObject (Handle, 1, &Info, NULL); +} + + +#ifdef ACPI_ASL_COMPILER +/******************************************************************************* + * + * FUNCTION: AcpiNsDumpTables + * + * PARAMETERS: SearchBase - Root of subtree to be dumped, or + * NS_ALL to dump the entire namespace + * MaxDepth - Maximum depth of dump. Use INT_MAX + * for an effectively unlimited depth. + * + * RETURN: None + * + * DESCRIPTION: Dump the name space, or a portion of it. + * + ******************************************************************************/ + +void +AcpiNsDumpTables ( + ACPI_HANDLE SearchBase, + UINT32 MaxDepth) +{ + ACPI_HANDLE SearchHandle = SearchBase; + + + ACPI_FUNCTION_TRACE (NsDumpTables); + + + if (!AcpiGbl_RootNode) + { + /* + * If the name space has not been initialized, + * there is nothing to dump. + */ + ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "namespace not initialized!\n")); + return_VOID; + } + + if (ACPI_NS_ALL == SearchBase) + { + /* Entire namespace */ + + SearchHandle = AcpiGbl_RootNode; + ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "\\\n")); + } + + AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_OBJECTS, MaxDepth, + ACPI_OWNER_ID_MAX, SearchHandle); + return_VOID; +} +#endif +#endif + diff --git a/reactos/drivers/bus/acpi/acpica/namespace/nsdumpdv.c b/reactos/drivers/bus/acpi/acpica/namespace/nsdumpdv.c new file mode 100644 index 00000000000..fbb66a61675 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/namespace/nsdumpdv.c @@ -0,0 +1,234 @@ +/****************************************************************************** + * + * Module Name: nsdump - table dumping routines for debug + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __NSDUMPDV_C__ + +#include "acpi.h" + + +/* TBD: This entire module is apparently obsolete and should be removed */ + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nsdumpdv") + +#ifdef ACPI_OBSOLETE_FUNCTIONS +#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) + +#include "acnamesp.h" + +/******************************************************************************* + * + * FUNCTION: AcpiNsDumpOneDevice + * + * PARAMETERS: Handle - Node to be dumped + * Level - Nesting level of the handle + * Context - Passed into WalkNamespace + * ReturnValue - Not used + * + * RETURN: Status + * + * DESCRIPTION: Dump a single Node that represents a device + * This procedure is a UserFunction called by AcpiNsWalkNamespace. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsDumpOneDevice ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue) +{ + ACPI_BUFFER Buffer; + ACPI_DEVICE_INFO *Info; + ACPI_STATUS Status; + UINT32 i; + + + ACPI_FUNCTION_NAME (NsDumpOneDevice); + + + Status = AcpiNsDumpOneObject (ObjHandle, Level, Context, ReturnValue); + + Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; + Status = AcpiGetObjectInfo (ObjHandle, &Buffer); + if (ACPI_SUCCESS (Status)) + { + Info = Buffer.Pointer; + for (i = 0; i < Level; i++) + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " ")); + } + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, + " HID: %s, ADR: %8.8X%8.8X, Status: %X\n", + Info->HardwareId.Value, ACPI_FORMAT_UINT64 (Info->Address), + Info->CurrentStatus)); + ACPI_FREE (Info); + } + + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsDumpRootDevices + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Dump all objects of type "device" + * + ******************************************************************************/ + +void +AcpiNsDumpRootDevices ( + void) +{ + ACPI_HANDLE SysBusHandle; + ACPI_STATUS Status; + + + ACPI_FUNCTION_NAME (NsDumpRootDevices); + + + /* Only dump the table if tracing is enabled */ + + if (!(ACPI_LV_TABLES & AcpiDbgLevel)) + { + return; + } + + Status = AcpiGetHandle (NULL, ACPI_NS_SYSTEM_BUS, &SysBusHandle); + if (ACPI_FAILURE (Status)) + { + return; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, + "Display of all devices in the namespace:\n")); + + Status = AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, SysBusHandle, + ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK, + AcpiNsDumpOneDevice, NULL, NULL, NULL); +} + +#endif +#endif + + diff --git a/reactos/drivers/bus/acpi/acpica/namespace/nseval.c b/reactos/drivers/bus/acpi/acpica/namespace/nseval.c new file mode 100644 index 00000000000..07af96ed93d --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/namespace/nseval.c @@ -0,0 +1,558 @@ +/******************************************************************************* + * + * Module Name: nseval - Object evaluation, includes control method execution + * + ******************************************************************************/ + +/****************************************************************************** + * + * 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 __NSEVAL_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acparser.h" +#include "acinterp.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nseval") + +/* Local prototypes */ + +static void +AcpiNsExecModuleCode ( + ACPI_OPERAND_OBJECT *MethodObj, + ACPI_EVALUATE_INFO *Info); + + +/******************************************************************************* + * + * FUNCTION: AcpiNsEvaluate + * + * PARAMETERS: Info - Evaluation info block, contains: + * PrefixNode - Prefix or Method/Object Node to execute + * Pathname - Name of method to execute, If NULL, the + * Node is the object to execute + * Parameters - List of parameters to pass to the method, + * terminated by NULL. Params itself may be + * NULL if no parameters are being passed. + * ReturnObject - Where to put method's return value (if + * any). If NULL, no value is returned. + * ParameterType - Type of Parameter list + * ReturnObject - Where to put method's return value (if + * any). If NULL, no value is returned. + * Flags - ACPI_IGNORE_RETURN_VALUE to delete return + * + * RETURN: Status + * + * DESCRIPTION: Execute a control method or return the current value of an + * ACPI namespace object. + * + * MUTEX: Locks interpreter + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsEvaluate ( + ACPI_EVALUATE_INFO *Info) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + + + ACPI_FUNCTION_TRACE (NsEvaluate); + + + if (!Info) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Initialize the return value to an invalid object */ + + Info->ReturnObject = NULL; + Info->ParamCount = 0; + + /* + * Get the actual namespace node for the target object. Handles these cases: + * + * 1) Null node, Pathname (absolute path) + * 2) Node, Pathname (path relative to Node) + * 3) Node, Null Pathname + */ + Status = AcpiNsGetNode (Info->PrefixNode, Info->Pathname, + ACPI_NS_NO_UPSEARCH, &Info->ResolvedNode); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * For a method alias, we must grab the actual method node so that proper + * scoping context will be established before execution. + */ + if (AcpiNsGetType (Info->ResolvedNode) == ACPI_TYPE_LOCAL_METHOD_ALIAS) + { + Info->ResolvedNode = + ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Info->ResolvedNode->Object); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "%s [%p] Value %p\n", Info->Pathname, + Info->ResolvedNode, AcpiNsGetAttachedObject (Info->ResolvedNode))); + + Node = Info->ResolvedNode; + + /* + * Two major cases here: + * + * 1) The object is a control method -- execute it + * 2) The object is not a method -- just return it's current value + */ + if (AcpiNsGetType (Info->ResolvedNode) == ACPI_TYPE_METHOD) + { + /* + * 1) Object is a control method - execute it + */ + + /* Verify that there is a method object associated with this node */ + + Info->ObjDesc = AcpiNsGetAttachedObject (Info->ResolvedNode); + if (!Info->ObjDesc) + { + ACPI_ERROR ((AE_INFO, "Control method has no attached sub-object")); + return_ACPI_STATUS (AE_NULL_OBJECT); + } + + /* Count the number of arguments being passed to the method */ + + if (Info->Parameters) + { + while (Info->Parameters[Info->ParamCount]) + { + if (Info->ParamCount > ACPI_METHOD_MAX_ARG) + { + return_ACPI_STATUS (AE_LIMIT); + } + Info->ParamCount++; + } + } + + ACPI_DUMP_PATHNAME (Info->ResolvedNode, "ACPI: Execute Method", + ACPI_LV_INFO, _COMPONENT); + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Method at AML address %p Length %X\n", + Info->ObjDesc->Method.AmlStart + 1, + Info->ObjDesc->Method.AmlLength - 1)); + + /* + * Any namespace deletion must acquire both the namespace and + * interpreter locks to ensure that no thread is using the portion of + * the namespace that is being deleted. + * + * Execute the method via the interpreter. The interpreter is locked + * here before calling into the AML parser + */ + AcpiExEnterInterpreter (); + Status = AcpiPsExecuteMethod (Info); + AcpiExExitInterpreter (); + } + else + { + /* + * 2) Object is not a method, return its current value + * + * Disallow certain object types. For these, "evaluation" is undefined. + */ + switch (Info->ResolvedNode->Type) + { + case ACPI_TYPE_DEVICE: + case ACPI_TYPE_EVENT: + case ACPI_TYPE_MUTEX: + case ACPI_TYPE_REGION: + case ACPI_TYPE_THERMAL: + case ACPI_TYPE_LOCAL_SCOPE: + + ACPI_ERROR ((AE_INFO, + "[%4.4s] Evaluation of object type [%s] is not supported", + Info->ResolvedNode->Name.Ascii, + AcpiUtGetTypeName (Info->ResolvedNode->Type))); + + return_ACPI_STATUS (AE_TYPE); + + default: + break; + } + + /* + * Objects require additional resolution steps (e.g., the Node may be + * a field that must be read, etc.) -- we can't just grab the object + * out of the node. + * + * Use ResolveNodeToValue() to get the associated value. + * + * NOTE: we can get away with passing in NULL for a walk state because + * ResolvedNode is guaranteed to not be a reference to either a method + * local or a method argument (because this interface is never called + * from a running method.) + * + * Even though we do not directly invoke the interpreter for object + * resolution, we must lock it because we could access an opregion. + * The opregion access code assumes that the interpreter is locked. + */ + AcpiExEnterInterpreter (); + + /* Function has a strange interface */ + + Status = AcpiExResolveNodeToValue (&Info->ResolvedNode, NULL); + AcpiExExitInterpreter (); + + /* + * If AcpiExResolveNodeToValue() succeeded, the return value was placed + * in ResolvedNode. + */ + if (ACPI_SUCCESS (Status)) + { + Status = AE_CTRL_RETURN_VALUE; + Info->ReturnObject = + ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Info->ResolvedNode); + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Returning object %p [%s]\n", + Info->ReturnObject, + AcpiUtGetObjectTypeName (Info->ReturnObject))); + } + } + + /* + * Check input argument count against the ASL-defined count for a method. + * Also check predefined names: argument count and return value against + * the ACPI specification. Some incorrect return value types are repaired. + */ + (void) AcpiNsCheckPredefinedNames (Node, Info->ParamCount, + Status, &Info->ReturnObject); + + /* Check if there is a return value that must be dealt with */ + + if (Status == AE_CTRL_RETURN_VALUE) + { + /* If caller does not want the return value, delete it */ + + if (Info->Flags & ACPI_IGNORE_RETURN_VALUE) + { + AcpiUtRemoveReference (Info->ReturnObject); + Info->ReturnObject = NULL; + } + + /* Map AE_CTRL_RETURN_VALUE to AE_OK, we are done with it */ + + Status = AE_OK; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "*** Completed evaluation of object %s ***\n", Info->Pathname)); + + /* + * Namespace was unlocked by the handling AcpiNs* function, so we + * just return + */ + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsExecModuleCodeList + * + * PARAMETERS: None + * + * RETURN: None. Exceptions during method execution are ignored, since + * we cannot abort a table load. + * + * DESCRIPTION: Execute all elements of the global module-level code list. + * Each element is executed as a single control method. + * + ******************************************************************************/ + +void +AcpiNsExecModuleCodeList ( + void) +{ + ACPI_OPERAND_OBJECT *Prev; + ACPI_OPERAND_OBJECT *Next; + ACPI_EVALUATE_INFO *Info; + UINT32 MethodCount = 0; + + + ACPI_FUNCTION_TRACE (NsExecModuleCodeList); + + + /* Exit now if the list is empty */ + + Next = AcpiGbl_ModuleCodeList; + if (!Next) + { + return_VOID; + } + + /* Allocate the evaluation information block */ + + Info = ACPI_ALLOCATE (sizeof (ACPI_EVALUATE_INFO)); + if (!Info) + { + return_VOID; + } + + /* Walk the list, executing each "method" */ + + while (Next) + { + Prev = Next; + Next = Next->Method.Mutex; + + /* Clear the link field and execute the method */ + + Prev->Method.Mutex = NULL; + AcpiNsExecModuleCode (Prev, Info); + MethodCount++; + + /* Delete the (temporary) method object */ + + AcpiUtRemoveReference (Prev); + } + + ACPI_INFO ((AE_INFO, + "Executed %u blocks of module-level executable AML code", + MethodCount)); + + ACPI_FREE (Info); + AcpiGbl_ModuleCodeList = NULL; + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsExecModuleCode + * + * PARAMETERS: MethodObj - Object container for the module-level code + * Info - Info block for method evaluation + * + * RETURN: None. Exceptions during method execution are ignored, since + * we cannot abort a table load. + * + * DESCRIPTION: Execute a control method containing a block of module-level + * executable AML code. The control method is temporarily + * installed to the root node, then evaluated. + * + ******************************************************************************/ + +static void +AcpiNsExecModuleCode ( + ACPI_OPERAND_OBJECT *MethodObj, + ACPI_EVALUATE_INFO *Info) +{ + ACPI_OPERAND_OBJECT *ParentObj; + ACPI_NAMESPACE_NODE *ParentNode; + ACPI_OBJECT_TYPE Type; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (NsExecModuleCode); + + + /* + * Get the parent node. We cheat by using the NextObject field + * of the method object descriptor. + */ + ParentNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, + MethodObj->Method.NextObject); + Type = AcpiNsGetType (ParentNode); + + /* + * Get the region handler and save it in the method object. We may need + * this if an operation region declaration causes a _REG method to be run. + * + * We can't do this in AcpiPsLinkModuleCode because + * AcpiGbl_RootNode->Object is NULL at PASS1. + */ + if ((Type == ACPI_TYPE_DEVICE) && ParentNode->Object) + { + MethodObj->Method.Extra.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/reactos/drivers/bus/acpi/acpica/namespace/nsinit.c b/reactos/drivers/bus/acpi/acpica/namespace/nsinit.c new file mode 100644 index 00000000000..b36fa6c7ea9 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/namespace/nsinit.c @@ -0,0 +1,727 @@ +/****************************************************************************** + * + * Module Name: nsinit - namespace initialization + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __NSXFINIT_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" +#include "acdispat.h" +#include "acinterp.h" + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nsinit") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiNsInitOneObject ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue); + +static ACPI_STATUS +AcpiNsInitOneDevice ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue); + +static ACPI_STATUS +AcpiNsFindIniMethods ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue); + + +/******************************************************************************* + * + * FUNCTION: AcpiNsInitializeObjects + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Walk the entire namespace and perform any necessary + * initialization on the objects found therein + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsInitializeObjects ( + void) +{ + ACPI_STATUS Status; + ACPI_INIT_WALK_INFO Info; + + + ACPI_FUNCTION_TRACE (NsInitializeObjects); + + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "**** Starting initialization of namespace objects ****\n")); + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, + "Completing Region/Field/Buffer/Package initialization:")); + + /* Set all init info to zero */ + + ACPI_MEMSET (&Info, 0, sizeof (ACPI_INIT_WALK_INFO)); + + /* Walk entire namespace from the supplied root */ + + Status = AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, AcpiNsInitOneObject, NULL, + &Info, NULL); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, "During WalkNamespace")); + } + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, + "\nInitialized %hd/%hd Regions %hd/%hd Fields %hd/%hd " + "Buffers %hd/%hd Packages (%hd nodes)\n", + Info.OpRegionInit, Info.OpRegionCount, + Info.FieldInit, Info.FieldCount, + Info.BufferInit, Info.BufferCount, + Info.PackageInit, Info.PackageCount, Info.ObjectCount)); + + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "%hd Control Methods found\n", Info.MethodCount)); + ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, + "%hd Op Regions found\n", Info.OpRegionCount)); + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsInitializeDevices + * + * PARAMETERS: None + * + * RETURN: ACPI_STATUS + * + * DESCRIPTION: Walk the entire namespace and initialize all ACPI devices. + * This means running _INI on all present devices. + * + * Note: We install PCI config space handler on region access, + * not here. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsInitializeDevices ( + void) +{ + ACPI_STATUS Status; + ACPI_DEVICE_WALK_INFO Info; + + + ACPI_FUNCTION_TRACE (NsInitializeDevices); + + + /* Init counters */ + + Info.DeviceCount = 0; + Info.Num_STA = 0; + Info.Num_INI = 0; + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, + "Initializing Device/Processor/Thermal objects " + "by executing _INI methods:")); + + /* Tree analysis: find all subtrees that contain _INI methods */ + + Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, FALSE, AcpiNsFindIniMethods, NULL, &Info, NULL); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + + /* Allocate the evaluation information block */ + + Info.EvaluateInfo = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO)); + if (!Info.EvaluateInfo) + { + Status = AE_NO_MEMORY; + goto ErrorExit; + } + + /* + * Execute the "global" _INI method that may appear at the root. This + * support is provided for Windows compatibility (Vista+) and is not + * part of the ACPI specification. + */ + Info.EvaluateInfo->PrefixNode = AcpiGbl_RootNode; + Info.EvaluateInfo->Pathname = METHOD_NAME__INI; + Info.EvaluateInfo->Parameters = NULL; + Info.EvaluateInfo->Flags = ACPI_IGNORE_RETURN_VALUE; + + Status = AcpiNsEvaluate (Info.EvaluateInfo); + if (ACPI_SUCCESS (Status)) + { + Info.Num_INI++; + } + + /* Walk namespace to execute all _INIs on present devices */ + + Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, FALSE, AcpiNsInitOneDevice, NULL, &Info, NULL); + + ACPI_FREE (Info.EvaluateInfo); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, + "\nExecuted %hd _INI methods requiring %hd _STA executions " + "(examined %hd objects)\n", + Info.Num_INI, Info.Num_STA, Info.DeviceCount)); + + return_ACPI_STATUS (Status); + + +ErrorExit: + ACPI_EXCEPTION ((AE_INFO, Status, "During device initialization")); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsInitOneObject + * + * PARAMETERS: ObjHandle - Node + * Level - Current nesting level + * Context - Points to a init info struct + * ReturnValue - Not used + * + * RETURN: Status + * + * DESCRIPTION: Callback from AcpiWalkNamespace. Invoked for every object + * within the namespace. + * + * Currently, the only objects that require initialization are: + * 1) Methods + * 2) Op Regions + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsInitOneObject ( + ACPI_HANDLE ObjHandle, + UINT32 Level, + void *Context, + void **ReturnValue) +{ + ACPI_OBJECT_TYPE Type; + ACPI_STATUS Status = AE_OK; + ACPI_INIT_WALK_INFO *Info = (ACPI_INIT_WALK_INFO *) Context; + ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; + ACPI_OPERAND_OBJECT *ObjDesc; + + + ACPI_FUNCTION_NAME (NsInitOneObject); + + + Info->ObjectCount++; + + /* And even then, we are only interested in a few object types */ + + Type = AcpiNsGetType (ObjHandle); + ObjDesc = AcpiNsGetAttachedObject (Node); + if (!ObjDesc) + { + return (AE_OK); + } + + /* Increment counters for object types we are looking for */ + + switch (Type) + { + case ACPI_TYPE_REGION: + Info->OpRegionCount++; + break; + + case ACPI_TYPE_BUFFER_FIELD: + Info->FieldCount++; + break; + + case ACPI_TYPE_LOCAL_BANK_FIELD: + Info->FieldCount++; + break; + + case ACPI_TYPE_BUFFER: + Info->BufferCount++; + break; + + case ACPI_TYPE_PACKAGE: + Info->PackageCount++; + break; + + default: + + /* No init required, just exit now */ + return (AE_OK); + } + + /* If the object is already initialized, nothing else to do */ + + if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID) + { + return (AE_OK); + } + + /* Must lock the interpreter before executing AML code */ + + AcpiExEnterInterpreter (); + + /* + * Each of these types can contain executable AML code within the + * declaration. + */ + switch (Type) + { + case ACPI_TYPE_REGION: + + Info->OpRegionInit++; + Status = AcpiDsGetRegionArguments (ObjDesc); + break; + + case ACPI_TYPE_BUFFER_FIELD: + + Info->FieldInit++; + Status = AcpiDsGetBufferFieldArguments (ObjDesc); + break; + + case ACPI_TYPE_LOCAL_BANK_FIELD: + + Info->FieldInit++; + Status = AcpiDsGetBankFieldArguments (ObjDesc); + break; + + case ACPI_TYPE_BUFFER: + + Info->BufferInit++; + Status = AcpiDsGetBufferArguments (ObjDesc); + break; + + case ACPI_TYPE_PACKAGE: + + Info->PackageInit++; + Status = AcpiDsGetPackageArguments (ObjDesc); + break; + + default: + /* No other types can get here */ + break; + } + + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Could not execute arguments for [%4.4s] (%s)", + AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Type))); + } + + /* + * Print a dot for each object unless we are going to print the entire + * pathname + */ + if (!(AcpiDbgLevel & ACPI_LV_INIT_NAMES)) + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, ".")); + } + + /* + * We ignore errors from above, and always return OK, since we don't want + * to abort the walk on any single error. + */ + AcpiExExitInterpreter (); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsFindIniMethods + * + * PARAMETERS: ACPI_WALK_CALLBACK + * + * RETURN: ACPI_STATUS + * + * DESCRIPTION: Called during namespace walk. Finds objects named _INI under + * device/processor/thermal objects, and marks the entire subtree + * with a SUBTREE_HAS_INI flag. This flag is used during the + * subsequent device initialization walk to avoid entire subtrees + * that do not contain an _INI. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsFindIniMethods ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue) +{ + ACPI_DEVICE_WALK_INFO *Info = ACPI_CAST_PTR (ACPI_DEVICE_WALK_INFO, Context); + ACPI_NAMESPACE_NODE *Node; + ACPI_NAMESPACE_NODE *ParentNode; + + + /* Keep count of device/processor/thermal objects */ + + Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle); + if ((Node->Type == ACPI_TYPE_DEVICE) || + (Node->Type == ACPI_TYPE_PROCESSOR) || + (Node->Type == ACPI_TYPE_THERMAL)) + { + Info->DeviceCount++; + return (AE_OK); + } + + /* We are only looking for methods named _INI */ + + if (!ACPI_COMPARE_NAME (Node->Name.Ascii, METHOD_NAME__INI)) + { + return (AE_OK); + } + + /* + * The only _INI methods that we care about are those that are + * present under Device, Processor, and Thermal objects. + */ + ParentNode = AcpiNsGetParentNode (Node); + switch (ParentNode->Type) + { + case ACPI_TYPE_DEVICE: + case ACPI_TYPE_PROCESSOR: + case ACPI_TYPE_THERMAL: + + /* Mark parent and bubble up the INI present flag to the root */ + + while (ParentNode) + { + ParentNode->Flags |= ANOBJ_SUBTREE_HAS_INI; + ParentNode = AcpiNsGetParentNode (ParentNode); + } + break; + + default: + break; + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsInitOneDevice + * + * PARAMETERS: ACPI_WALK_CALLBACK + * + * RETURN: ACPI_STATUS + * + * DESCRIPTION: This is called once per device soon after ACPI is enabled + * to initialize each device. It determines if the device is + * present, and if so, calls _INI. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsInitOneDevice ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue) +{ + ACPI_DEVICE_WALK_INFO *WalkInfo = ACPI_CAST_PTR (ACPI_DEVICE_WALK_INFO, Context); + ACPI_EVALUATE_INFO *Info = WalkInfo->EvaluateInfo; + UINT32 Flags; + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *DeviceNode; + + + ACPI_FUNCTION_TRACE (NsInitOneDevice); + + + /* We are interested in Devices, Processors and ThermalZones only */ + + DeviceNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle); + if ((DeviceNode->Type != ACPI_TYPE_DEVICE) && + (DeviceNode->Type != ACPI_TYPE_PROCESSOR) && + (DeviceNode->Type != ACPI_TYPE_THERMAL)) + { + return_ACPI_STATUS (AE_OK); + } + + /* + * Because of an earlier namespace analysis, all subtrees that contain an + * _INI method are tagged. + * + * If this device subtree does not contain any _INI methods, we + * can exit now and stop traversing this entire subtree. + */ + if (!(DeviceNode->Flags & ANOBJ_SUBTREE_HAS_INI)) + { + return_ACPI_STATUS (AE_CTRL_DEPTH); + } + + /* + * Run _STA to determine if this device is present and functioning. We + * must know this information for two important reasons (from ACPI spec): + * + * 1) We can only run _INI if the device is present. + * 2) We must abort the device tree walk on this subtree if the device is + * not present and is not functional (we will not examine the children) + * + * The _STA method is not required to be present under the device, we + * assume the device is present if _STA does not exist. + */ + ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname ( + ACPI_TYPE_METHOD, DeviceNode, METHOD_NAME__STA)); + + Status = AcpiUtExecute_STA (DeviceNode, &Flags); + if (ACPI_FAILURE (Status)) + { + /* Ignore error and move on to next device */ + + return_ACPI_STATUS (AE_OK); + } + + /* + * Flags == -1 means that _STA was not found. In this case, we assume that + * the device is both present and functional. + * + * From the ACPI spec, description of _STA: + * + * "If a device object (including the processor object) does not have an + * _STA object, then OSPM assumes that all of the above bits are set (in + * other words, the device is present, ..., and functioning)" + */ + if (Flags != ACPI_UINT32_MAX) + { + WalkInfo->Num_STA++; + } + + /* + * Examine the PRESENT and FUNCTIONING status bits + * + * Note: ACPI spec does not seem to specify behavior for the present but + * not functioning case, so we assume functioning if present. + */ + if (!(Flags & ACPI_STA_DEVICE_PRESENT)) + { + /* Device is not present, we must examine the Functioning bit */ + + if (Flags & ACPI_STA_DEVICE_FUNCTIONING) + { + /* + * Device is not present but is "functioning". In this case, + * we will not run _INI, but we continue to examine the children + * of this device. + * + * From the ACPI spec, description of _STA: (Note - no mention + * of whether to run _INI or not on the device in question) + * + * "_STA may return bit 0 clear (not present) with bit 3 set + * (device is functional). This case is used to indicate a valid + * device for which no device driver should be loaded (for example, + * a bridge device.) Children of this device may be present and + * valid. OSPM should continue enumeration below a device whose + * _STA returns this bit combination" + */ + return_ACPI_STATUS (AE_OK); + } + else + { + /* + * Device is not present and is not functioning. We must abort the + * walk of this subtree immediately -- don't look at the children + * of such a device. + * + * From the ACPI spec, description of _INI: + * + * "If the _STA method indicates that the device is not present, + * OSPM will not run the _INI and will not examine the children + * of the device for _INI methods" + */ + return_ACPI_STATUS (AE_CTRL_DEPTH); + } + } + + /* + * The device is present or is assumed present if no _STA exists. + * Run the _INI if it exists (not required to exist) + * + * Note: We know there is an _INI within this subtree, but it may not be + * under this particular device, it may be lower in the branch. + */ + ACPI_DEBUG_EXEC (AcpiUtDisplayInitPathname ( + ACPI_TYPE_METHOD, DeviceNode, METHOD_NAME__INI)); + + Info->PrefixNode = DeviceNode; + Info->Pathname = METHOD_NAME__INI; + Info->Parameters = NULL; + Info->Flags = ACPI_IGNORE_RETURN_VALUE; + + Status = AcpiNsEvaluate (Info); + if (ACPI_SUCCESS (Status)) + { + WalkInfo->Num_INI++; + + if ((AcpiDbgLevel <= ACPI_LV_ALL_EXCEPTIONS) && + (!(AcpiDbgLevel & ACPI_LV_INFO))) + { + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, ".")); + } + } + +#ifdef ACPI_DEBUG_OUTPUT + else if (Status != AE_NOT_FOUND) + { + /* Ignore error and move on to next device */ + + char *ScopeName = AcpiNsGetExternalPathname (Info->ResolvedNode); + + ACPI_EXCEPTION ((AE_INFO, Status, "during %s._INI execution", + ScopeName)); + ACPI_FREE (ScopeName); + } +#endif + + /* Ignore errors from above */ + + Status = AE_OK; + + /* + * The _INI method has been run if present; call the Global Initialization + * Handler for this device. + */ + if (AcpiGbl_InitHandler) + { + Status = AcpiGbl_InitHandler (DeviceNode, ACPI_INIT_DEVICE_INI); + } + + return_ACPI_STATUS (Status); +} diff --git a/reactos/drivers/bus/acpi/acpica/namespace/nsload.c b/reactos/drivers/bus/acpi/acpica/namespace/nsload.c new file mode 100644 index 00000000000..a9f3824718b --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/namespace/nsload.c @@ -0,0 +1,428 @@ +/****************************************************************************** + * + * Module Name: nsload - namespace loading/expanding/contracting procedures + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __NSLOAD_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" +#include "acdispat.h" +#include "actables.h" + + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nsload") + +/* Local prototypes */ + +#ifdef ACPI_FUTURE_IMPLEMENTATION +ACPI_STATUS +AcpiNsUnloadNamespace ( + ACPI_HANDLE Handle); + +static ACPI_STATUS +AcpiNsDeleteSubtree ( + ACPI_HANDLE StartHandle); +#endif + + +#ifndef ACPI_NO_METHOD_EXECUTION +/******************************************************************************* + * + * FUNCTION: AcpiNsLoadTable + * + * PARAMETERS: TableIndex - Index for table to be loaded + * Node - Owning NS node + * + * RETURN: Status + * + * DESCRIPTION: Load one ACPI table into the namespace + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsLoadTable ( + UINT32 TableIndex, + ACPI_NAMESPACE_NODE *Node) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (NsLoadTable); + + + /* + * Parse the table and load the namespace with all named + * objects found within. Control methods are NOT parsed + * at this time. In fact, the control methods cannot be + * parsed until the entire namespace is loaded, because + * if a control method makes a forward reference (call) + * to another control method, we can't continue parsing + * because we don't know how many arguments to parse next! + */ + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* If table already loaded into namespace, just return */ + + if (AcpiTbIsTableLoaded (TableIndex)) + { + Status = AE_ALREADY_EXISTS; + goto Unlock; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "**** Loading table into namespace ****\n")); + + Status = AcpiTbAllocateOwnerId (TableIndex); + if (ACPI_FAILURE (Status)) + { + goto Unlock; + } + + Status = AcpiNsParseTable (TableIndex, Node); + if (ACPI_SUCCESS (Status)) + { + AcpiTbSetTableLoadedFlag (TableIndex, TRUE); + } + else + { + (void) AcpiTbReleaseOwnerId (TableIndex); + } + +Unlock: + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Now we can parse the control methods. We always parse + * them here for a sanity check, and if configured for + * just-in-time parsing, we delete the control method + * parse trees. + */ + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "**** Begin Table Method Parsing and Object Initialization\n")); + + Status = AcpiDsInitializeObjects (TableIndex, Node); + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "**** Completed Table Method Parsing and Object Initialization\n")); + + return_ACPI_STATUS (Status); +} + + +#ifdef ACPI_OBSOLETE_FUNCTIONS +/******************************************************************************* + * + * FUNCTION: AcpiLoadNamespace + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Load the name space from what ever is pointed to by DSDT. + * (DSDT points to either the BIOS or a buffer.) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsLoadNamespace ( + void) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiLoadNameSpace); + + + /* There must be at least a DSDT installed */ + + if (AcpiGbl_DSDT == NULL) + { + ACPI_ERROR ((AE_INFO, "DSDT is not in memory")); + return_ACPI_STATUS (AE_NO_ACPI_TABLES); + } + + /* + * Load the namespace. The DSDT is required, + * but the SSDT and PSDT tables are optional. + */ + Status = AcpiNsLoadTableByType (ACPI_TABLE_ID_DSDT); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Ignore exceptions from these */ + + (void) AcpiNsLoadTableByType (ACPI_TABLE_ID_SSDT); + (void) AcpiNsLoadTableByType (ACPI_TABLE_ID_PSDT); + + ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, + "ACPI Namespace successfully loaded at root %p\n", + AcpiGbl_RootNode)); + + return_ACPI_STATUS (Status); +} +#endif + +#ifdef ACPI_FUTURE_IMPLEMENTATION +/******************************************************************************* + * + * FUNCTION: AcpiNsDeleteSubtree + * + * PARAMETERS: StartHandle - Handle in namespace where search begins + * + * RETURNS Status + * + * DESCRIPTION: Walks the namespace starting at the given handle and deletes + * all objects, entries, and scopes in the entire subtree. + * + * Namespace/Interpreter should be locked or the subsystem should + * be in shutdown before this routine is called. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsDeleteSubtree ( + ACPI_HANDLE StartHandle) +{ + ACPI_STATUS Status; + ACPI_HANDLE ChildHandle; + ACPI_HANDLE ParentHandle; + ACPI_HANDLE NextChildHandle; + ACPI_HANDLE Dummy; + UINT32 Level; + + + ACPI_FUNCTION_TRACE (NsDeleteSubtree); + + + ParentHandle = StartHandle; + ChildHandle = NULL; + Level = 1; + + /* + * Traverse the tree of objects until we bubble back up + * to where we started. + */ + while (Level > 0) + { + /* Attempt to get the next object in this scope */ + + Status = AcpiGetNextObject (ACPI_TYPE_ANY, ParentHandle, + ChildHandle, &NextChildHandle); + + ChildHandle = NextChildHandle; + + /* Did we get a new object? */ + + if (ACPI_SUCCESS (Status)) + { + /* Check if this object has any children */ + + if (ACPI_SUCCESS (AcpiGetNextObject (ACPI_TYPE_ANY, ChildHandle, + NULL, &Dummy))) + { + /* + * There is at least one child of this object, + * visit the object + */ + Level++; + ParentHandle = ChildHandle; + ChildHandle = NULL; + } + } + else + { + /* + * No more children in this object, go back up to + * the object's parent + */ + Level--; + + /* Delete all children now */ + + AcpiNsDeleteChildren (ChildHandle); + + ChildHandle = ParentHandle; + Status = AcpiGetParent (ParentHandle, &ParentHandle); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + } + + /* Now delete the starting object, and we are done */ + + AcpiNsRemoveNode (ChildHandle); + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsUnloadNameSpace + * + * PARAMETERS: Handle - Root of namespace subtree to be deleted + * + * RETURN: Status + * + * DESCRIPTION: Shrinks the namespace, typically in response to an undocking + * event. Deletes an entire subtree starting from (and + * including) the given handle. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsUnloadNamespace ( + ACPI_HANDLE Handle) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (NsUnloadNameSpace); + + + /* Parameter validation */ + + if (!AcpiGbl_RootNode) + { + return_ACPI_STATUS (AE_NO_NAMESPACE); + } + + if (!Handle) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* This function does the real work */ + + Status = AcpiNsDeleteSubtree (Handle); + + return_ACPI_STATUS (Status); +} +#endif +#endif + diff --git a/reactos/drivers/bus/acpi/acpica/namespace/nsnames.c b/reactos/drivers/bus/acpi/acpica/namespace/nsnames.c new file mode 100644 index 00000000000..c00a4457b2a --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/namespace/nsnames.c @@ -0,0 +1,375 @@ +/******************************************************************************* + * + * Module Name: nsnames - Name manipulation and search + * + ******************************************************************************/ + +/****************************************************************************** + * + * 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 __NSNAMES_C__ + +#include "acpi.h" +#include "accommon.h" +#include "amlcode.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nsnames") + + +/******************************************************************************* + * + * FUNCTION: AcpiNsBuildExternalPath + * + * PARAMETERS: Node - NS node whose pathname is needed + * Size - Size of the pathname + * *NameBuffer - Where to return the pathname + * + * RETURN: Status + * Places the pathname into the NameBuffer, in external format + * (name segments separated by path separators) + * + * DESCRIPTION: Generate a full pathaname + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsBuildExternalPath ( + ACPI_NAMESPACE_NODE *Node, + ACPI_SIZE Size, + char *NameBuffer) +{ + ACPI_SIZE Index; + ACPI_NAMESPACE_NODE *ParentNode; + + + ACPI_FUNCTION_ENTRY (); + + + /* Special case for root */ + + Index = Size - 1; + if (Index < ACPI_NAME_SIZE) + { + NameBuffer[0] = AML_ROOT_PREFIX; + NameBuffer[1] = 0; + return (AE_OK); + } + + /* Store terminator byte, then build name backwards */ + + ParentNode = Node; + NameBuffer[Index] = 0; + + while ((Index > ACPI_NAME_SIZE) && (ParentNode != AcpiGbl_RootNode)) + { + Index -= ACPI_NAME_SIZE; + + /* Put the name into the buffer */ + + ACPI_MOVE_32_TO_32 ((NameBuffer + Index), &ParentNode->Name); + ParentNode = AcpiNsGetParentNode (ParentNode); + + /* Prefix name with the path separator */ + + Index--; + NameBuffer[Index] = ACPI_PATH_SEPARATOR; + } + + /* Overwrite final separator with the root prefix character */ + + NameBuffer[Index] = AML_ROOT_PREFIX; + + if (Index != 0) + { + ACPI_ERROR ((AE_INFO, + "Could not construct external pathname; index=%X, size=%X, Path=%s", + (UINT32) Index, (UINT32) Size, &NameBuffer[Size])); + + return (AE_BAD_PARAMETER); + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsGetExternalPathname + * + * PARAMETERS: Node - Namespace node whose pathname is needed + * + * RETURN: Pointer to storage containing the fully qualified name of + * the node, In external format (name segments separated by path + * separators.) + * + * DESCRIPTION: Used to obtain the full pathname to a namespace node, usually + * for error and debug statements. + * + ******************************************************************************/ + +char * +AcpiNsGetExternalPathname ( + ACPI_NAMESPACE_NODE *Node) +{ + ACPI_STATUS Status; + char *NameBuffer; + ACPI_SIZE Size; + + + ACPI_FUNCTION_TRACE_PTR (NsGetExternalPathname, Node); + + + /* Calculate required buffer size based on depth below root */ + + Size = AcpiNsGetPathnameLength (Node); + if (!Size) + { + return_PTR (NULL); + } + + /* Allocate a buffer to be returned to caller */ + + NameBuffer = ACPI_ALLOCATE_ZEROED (Size); + if (!NameBuffer) + { + ACPI_ERROR ((AE_INFO, "Could not allocate %u bytes", (UINT32) Size)); + return_PTR (NULL); + } + + /* Build the path in the allocated buffer */ + + Status = AcpiNsBuildExternalPath (Node, Size, NameBuffer); + if (ACPI_FAILURE (Status)) + { + ACPI_FREE (NameBuffer); + return_PTR (NULL); + } + + return_PTR (NameBuffer); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsGetPathnameLength + * + * PARAMETERS: Node - Namespace node + * + * RETURN: Length of path, including prefix + * + * DESCRIPTION: Get the length of the pathname string for this node + * + ******************************************************************************/ + +ACPI_SIZE +AcpiNsGetPathnameLength ( + ACPI_NAMESPACE_NODE *Node) +{ + ACPI_SIZE Size; + ACPI_NAMESPACE_NODE *NextNode; + + + ACPI_FUNCTION_ENTRY (); + + + /* + * Compute length of pathname as 5 * number of name segments. + * Go back up the parent tree to the root + */ + Size = 0; + NextNode = Node; + + while (NextNode && (NextNode != AcpiGbl_RootNode)) + { + if (ACPI_GET_DESCRIPTOR_TYPE (NextNode) != ACPI_DESC_TYPE_NAMED) + { + ACPI_ERROR ((AE_INFO, + "Invalid Namespace Node (%p) while traversing namespace", + NextNode)); + return 0; + } + Size += ACPI_PATH_SEGMENT_LENGTH; + NextNode = AcpiNsGetParentNode (NextNode); + } + + if (!Size) + { + Size = 1; /* Root node case */ + } + + return (Size + 1); /* +1 for null string terminator */ +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsHandleToPathname + * + * PARAMETERS: TargetHandle - Handle of named object whose name is + * to be found + * Buffer - Where the pathname is returned + * + * RETURN: Status, Buffer is filled with pathname if status is AE_OK + * + * DESCRIPTION: Build and return a full namespace pathname + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsHandleToPathname ( + ACPI_HANDLE TargetHandle, + ACPI_BUFFER *Buffer) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + ACPI_SIZE RequiredSize; + + + ACPI_FUNCTION_TRACE_PTR (NsHandleToPathname, TargetHandle); + + + Node = AcpiNsValidateHandle (TargetHandle); + if (!Node) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Determine size required for the caller buffer */ + + RequiredSize = AcpiNsGetPathnameLength (Node); + if (!RequiredSize) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Validate/Allocate/Clear caller buffer */ + + Status = AcpiUtInitializeBuffer (Buffer, RequiredSize); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Build the path in the caller buffer */ + + Status = AcpiNsBuildExternalPath (Node, RequiredSize, Buffer->Pointer); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%s [%X]\n", + (char *) Buffer->Pointer, (UINT32) RequiredSize)); + return_ACPI_STATUS (AE_OK); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/namespace/nsobject.c b/reactos/drivers/bus/acpi/acpica/namespace/nsobject.c new file mode 100644 index 00000000000..c0163f4ea24 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/namespace/nsobject.c @@ -0,0 +1,577 @@ +/******************************************************************************* + * + * Module Name: nsobject - Utilities for objects attached to namespace + * table entries + * + ******************************************************************************/ + +/****************************************************************************** + * + * 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 __NSOBJECT_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nsobject") + + +/******************************************************************************* + * + * FUNCTION: AcpiNsAttachObject + * + * PARAMETERS: Node - Parent Node + * Object - Object to be attached + * Type - Type of object, or ACPI_TYPE_ANY if not + * known + * + * RETURN: Status + * + * DESCRIPTION: Record the given object as the value associated with the + * name whose ACPI_HANDLE is passed. If Object is NULL + * and Type is ACPI_TYPE_ANY, set the name as having no value. + * Note: Future may require that the Node->Flags field be passed + * as a parameter. + * + * MUTEX: Assumes namespace is locked + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsAttachObject ( + ACPI_NAMESPACE_NODE *Node, + ACPI_OPERAND_OBJECT *Object, + ACPI_OBJECT_TYPE Type) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *LastObjDesc; + ACPI_OBJECT_TYPE ObjectType = ACPI_TYPE_ANY; + + + ACPI_FUNCTION_TRACE (NsAttachObject); + + + /* + * Parameter validation + */ + if (!Node) + { + /* Invalid handle */ + + ACPI_ERROR ((AE_INFO, "Null NamedObj handle")); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + if (!Object && (ACPI_TYPE_ANY != Type)) + { + /* Null object */ + + ACPI_ERROR ((AE_INFO, + "Null object, but type not ACPI_TYPE_ANY")); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED) + { + /* Not a name handle */ + + ACPI_ERROR ((AE_INFO, "Invalid handle %p [%s]", + Node, AcpiUtGetDescriptorName (Node))); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Check if this object is already attached */ + + if (Node->Object == Object) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Obj %p already installed in NameObj %p\n", + Object, Node)); + + return_ACPI_STATUS (AE_OK); + } + + /* If null object, we will just install it */ + + if (!Object) + { + ObjDesc = NULL; + ObjectType = ACPI_TYPE_ANY; + } + + /* + * If the source object is a namespace Node with an attached object, + * we will use that (attached) object + */ + else if ((ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_NAMED) && + ((ACPI_NAMESPACE_NODE *) Object)->Object) + { + /* + * Value passed is a name handle and that name has a + * non-null value. Use that name's value and type. + */ + ObjDesc = ((ACPI_NAMESPACE_NODE *) Object)->Object; + ObjectType = ((ACPI_NAMESPACE_NODE *) Object)->Type; + } + + /* + * Otherwise, we will use the parameter object, but we must type + * it first + */ + else + { + ObjDesc = (ACPI_OPERAND_OBJECT *) Object; + + /* Use the given type */ + + ObjectType = Type; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Installing %p into Node %p [%4.4s]\n", + ObjDesc, Node, AcpiUtGetNodeName (Node))); + + /* Detach an existing attached object if present */ + + if (Node->Object) + { + AcpiNsDetachObject (Node); + } + + if (ObjDesc) + { + /* + * Must increment the new value's reference count + * (if it is an internal object) + */ + AcpiUtAddReference (ObjDesc); + + /* + * Handle objects with multiple descriptors - walk + * to the end of the descriptor list + */ + LastObjDesc = ObjDesc; + while (LastObjDesc->Common.NextObject) + { + LastObjDesc = LastObjDesc->Common.NextObject; + } + + /* Install the object at the front of the object list */ + + LastObjDesc->Common.NextObject = Node->Object; + } + + Node->Type = (UINT8) ObjectType; + Node->Object = ObjDesc; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsDetachObject + * + * PARAMETERS: Node - A Namespace node whose object will be detached + * + * RETURN: None. + * + * DESCRIPTION: Detach/delete an object associated with a namespace node. + * if the object is an allocated object, it is freed. + * Otherwise, the field is simply cleared. + * + ******************************************************************************/ + +void +AcpiNsDetachObject ( + ACPI_NAMESPACE_NODE *Node) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + + + ACPI_FUNCTION_TRACE (NsDetachObject); + + + ObjDesc = Node->Object; + + if (!ObjDesc || + (ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA)) + { + return_VOID; + } + + if (Node->Flags & ANOBJ_ALLOCATED_BUFFER) + { + /* Free the dynamic aml buffer */ + + if (ObjDesc->Common.Type == ACPI_TYPE_METHOD) + { + ACPI_FREE (ObjDesc->Method.AmlStart); + } + } + + /* Clear the entry in all cases */ + + Node->Object = NULL; + if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_OPERAND) + { + Node->Object = ObjDesc->Common.NextObject; + if (Node->Object && + ((Node->Object)->Common.Type != ACPI_TYPE_LOCAL_DATA)) + { + Node->Object = Node->Object->Common.NextObject; + } + } + + /* Reset the node type to untyped */ + + Node->Type = ACPI_TYPE_ANY; + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "Node %p [%4.4s] Object %p\n", + Node, AcpiUtGetNodeName (Node), ObjDesc)); + + /* Remove one reference on the object (and all subobjects) */ + + AcpiUtRemoveReference (ObjDesc); + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsGetAttachedObject + * + * PARAMETERS: Node - Namespace node + * + * RETURN: Current value of the object field from the Node whose + * handle is passed + * + * DESCRIPTION: Obtain the object attached to a namespace node. + * + ******************************************************************************/ + +ACPI_OPERAND_OBJECT * +AcpiNsGetAttachedObject ( + ACPI_NAMESPACE_NODE *Node) +{ + ACPI_FUNCTION_TRACE_PTR (NsGetAttachedObject, Node); + + + if (!Node) + { + ACPI_WARNING ((AE_INFO, "Null Node ptr")); + return_PTR (NULL); + } + + if (!Node->Object || + ((ACPI_GET_DESCRIPTOR_TYPE (Node->Object) != ACPI_DESC_TYPE_OPERAND) && + (ACPI_GET_DESCRIPTOR_TYPE (Node->Object) != ACPI_DESC_TYPE_NAMED)) || + ((Node->Object)->Common.Type == ACPI_TYPE_LOCAL_DATA)) + { + return_PTR (NULL); + } + + return_PTR (Node->Object); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsGetSecondaryObject + * + * PARAMETERS: Node - Namespace node + * + * RETURN: Current value of the object field from the Node whose + * handle is passed. + * + * DESCRIPTION: Obtain a secondary object associated with a namespace node. + * + ******************************************************************************/ + +ACPI_OPERAND_OBJECT * +AcpiNsGetSecondaryObject ( + ACPI_OPERAND_OBJECT *ObjDesc) +{ + ACPI_FUNCTION_TRACE_PTR (NsGetSecondaryObject, ObjDesc); + + + if ((!ObjDesc) || + (ObjDesc->Common.Type== ACPI_TYPE_LOCAL_DATA) || + (!ObjDesc->Common.NextObject) || + ((ObjDesc->Common.NextObject)->Common.Type == ACPI_TYPE_LOCAL_DATA)) + { + return_PTR (NULL); + } + + return_PTR (ObjDesc->Common.NextObject); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsAttachData + * + * PARAMETERS: Node - Namespace node + * Handler - Handler to be associated with the data + * Data - Data to be attached + * + * RETURN: Status + * + * DESCRIPTION: Low-level attach data. Create and attach a Data object. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsAttachData ( + ACPI_NAMESPACE_NODE *Node, + ACPI_OBJECT_HANDLER Handler, + void *Data) +{ + ACPI_OPERAND_OBJECT *PrevObjDesc; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *DataDesc; + + + /* We only allow one attachment per handler */ + + PrevObjDesc = NULL; + ObjDesc = Node->Object; + while (ObjDesc) + { + if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA) && + (ObjDesc->Data.Handler == Handler)) + { + return (AE_ALREADY_EXISTS); + } + + PrevObjDesc = ObjDesc; + ObjDesc = ObjDesc->Common.NextObject; + } + + /* Create an internal object for the data */ + + DataDesc = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_DATA); + if (!DataDesc) + { + return (AE_NO_MEMORY); + } + + DataDesc->Data.Handler = Handler; + DataDesc->Data.Pointer = Data; + + /* Install the data object */ + + if (PrevObjDesc) + { + PrevObjDesc->Common.NextObject = DataDesc; + } + else + { + Node->Object = DataDesc; + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsDetachData + * + * PARAMETERS: Node - Namespace node + * Handler - Handler associated with the data + * + * RETURN: Status + * + * DESCRIPTION: Low-level detach data. Delete the data node, but the caller + * is responsible for the actual data. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsDetachData ( + ACPI_NAMESPACE_NODE *Node, + ACPI_OBJECT_HANDLER Handler) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_OPERAND_OBJECT *PrevObjDesc; + + + PrevObjDesc = NULL; + ObjDesc = Node->Object; + while (ObjDesc) + { + if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA) && + (ObjDesc->Data.Handler == Handler)) + { + if (PrevObjDesc) + { + PrevObjDesc->Common.NextObject = ObjDesc->Common.NextObject; + } + else + { + Node->Object = ObjDesc->Common.NextObject; + } + + AcpiUtRemoveReference (ObjDesc); + return (AE_OK); + } + + PrevObjDesc = ObjDesc; + ObjDesc = ObjDesc->Common.NextObject; + } + + return (AE_NOT_FOUND); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsGetAttachedData + * + * PARAMETERS: Node - Namespace node + * Handler - Handler associated with the data + * Data - Where the data is returned + * + * RETURN: Status + * + * DESCRIPTION: Low level interface to obtain data previously associated with + * a namespace node. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsGetAttachedData ( + ACPI_NAMESPACE_NODE *Node, + ACPI_OBJECT_HANDLER Handler, + void **Data) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + + + ObjDesc = Node->Object; + while (ObjDesc) + { + if ((ObjDesc->Common.Type == ACPI_TYPE_LOCAL_DATA) && + (ObjDesc->Data.Handler == Handler)) + { + *Data = ObjDesc->Data.Pointer; + return (AE_OK); + } + + ObjDesc = ObjDesc->Common.NextObject; + } + + return (AE_NOT_FOUND); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/namespace/nsparse.c b/reactos/drivers/bus/acpi/acpica/namespace/nsparse.c new file mode 100644 index 00000000000..58301560ae0 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/namespace/nsparse.c @@ -0,0 +1,297 @@ +/****************************************************************************** + * + * Module Name: nsparse - namespace interface to AML parser + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __NSPARSE_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" +#include "acparser.h" +#include "acdispat.h" +#include "actables.h" + + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nsparse") + + +/******************************************************************************* + * + * FUNCTION: NsOneCompleteParse + * + * PARAMETERS: PassNumber - 1 or 2 + * TableDesc - The table to be parsed. + * + * RETURN: Status + * + * DESCRIPTION: Perform one complete parse of an ACPI/AML table. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsOneCompleteParse ( + UINT32 PassNumber, + UINT32 TableIndex, + ACPI_NAMESPACE_NODE *StartNode) +{ + ACPI_PARSE_OBJECT *ParseRoot; + ACPI_STATUS Status; + UINT32 AmlLength; + UINT8 *AmlStart; + ACPI_WALK_STATE *WalkState; + ACPI_TABLE_HEADER *Table; + ACPI_OWNER_ID OwnerId; + + + ACPI_FUNCTION_TRACE (NsOneCompleteParse); + + + Status = AcpiTbGetOwnerId (TableIndex, &OwnerId); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Create and init a Root Node */ + + ParseRoot = AcpiPsCreateScopeOp (); + if (!ParseRoot) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Create and initialize a new walk state */ + + WalkState = AcpiDsCreateWalkState (OwnerId, NULL, NULL, NULL); + if (!WalkState) + { + AcpiPsFreeOp (ParseRoot); + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Status = AcpiGetTableByIndex (TableIndex, &Table); + if (ACPI_FAILURE (Status)) + { + AcpiDsDeleteWalkState (WalkState); + AcpiPsFreeOp (ParseRoot); + return_ACPI_STATUS (Status); + } + + /* Table must consist of at least a complete header */ + + if (Table->Length < sizeof (ACPI_TABLE_HEADER)) + { + Status = AE_BAD_HEADER; + } + else + { + AmlStart = (UINT8 *) Table + sizeof (ACPI_TABLE_HEADER); + AmlLength = Table->Length - sizeof (ACPI_TABLE_HEADER); + Status = AcpiDsInitAmlWalk (WalkState, ParseRoot, NULL, + AmlStart, AmlLength, NULL, (UINT8) PassNumber); + } + + if (ACPI_FAILURE (Status)) + { + AcpiDsDeleteWalkState (WalkState); + goto Cleanup; + } + + /* StartNode is the default location to load the table */ + + if (StartNode && StartNode != AcpiGbl_RootNode) + { + Status = AcpiDsScopeStackPush (StartNode, ACPI_TYPE_METHOD, WalkState); + if (ACPI_FAILURE (Status)) + { + AcpiDsDeleteWalkState (WalkState); + goto Cleanup; + } + } + + /* Parse the AML */ + + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "*PARSE* pass %d parse\n", PassNumber)); + Status = AcpiPsParseAml (WalkState); + +Cleanup: + AcpiPsDeleteParseTree (ParseRoot); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsParseTable + * + * PARAMETERS: TableDesc - An ACPI table descriptor for table to parse + * StartNode - Where to enter the table into the namespace + * + * RETURN: Status + * + * DESCRIPTION: Parse AML within an ACPI table and return a tree of ops + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsParseTable ( + UINT32 TableIndex, + ACPI_NAMESPACE_NODE *StartNode) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (NsParseTable); + + + /* + * AML Parse, pass 1 + * + * In this pass, we load most of the namespace. Control methods + * are not parsed until later. A parse tree is not created. Instead, + * each Parser Op subtree is deleted when it is finished. This saves + * a great deal of memory, and allows a small cache of parse objects + * to service the entire parse. The second pass of the parse then + * performs another complete parse of the AML. + */ + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** Start pass 1\n")); + Status = AcpiNsOneCompleteParse (ACPI_IMODE_LOAD_PASS1, + TableIndex, StartNode); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * AML Parse, pass 2 + * + * In this pass, we resolve forward references and other things + * that could not be completed during the first pass. + * Another complete parse of the AML is performed, but the + * overhead of this is compensated for by the fact that the + * parse objects are all cached. + */ + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "**** Start pass 2\n")); + Status = AcpiNsOneCompleteParse (ACPI_IMODE_LOAD_PASS2, + TableIndex, StartNode); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + return_ACPI_STATUS (Status); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/namespace/nspredef.c b/reactos/drivers/bus/acpi/acpica/namespace/nspredef.c new file mode 100644 index 00000000000..d979c43e93f --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/namespace/nspredef.c @@ -0,0 +1,1263 @@ +/****************************************************************************** + * + * Module Name: nspredef - Validation of ACPI predefined methods and objects + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 ACPI_CREATE_PREDEFINED_TABLE + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" +#include "acpredef.h" + + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nspredef") + + +/******************************************************************************* + * + * This module validates predefined ACPI objects that appear in the namespace, + * at the time they are evaluated (via AcpiEvaluateObject). The purpose of this + * validation is to detect problems with BIOS-exposed predefined ACPI objects + * before the results are returned to the ACPI-related drivers. + * + * There are several areas that are validated: + * + * 1) The number of input arguments as defined by the method/object in the + * ASL is validated against the ACPI specification. + * 2) The type of the return object (if any) is validated against the ACPI + * specification. + * 3) For returned package objects, the count of package elements is + * validated, as well as the type of each package element. Nested + * packages are supported. + * + * For any problems found, a warning message is issued. + * + ******************************************************************************/ + + +/* Local prototypes */ + +static ACPI_STATUS +AcpiNsCheckPackage ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ReturnObjectPtr); + +static ACPI_STATUS +AcpiNsCheckPackageList ( + ACPI_PREDEFINED_DATA *Data, + const ACPI_PREDEFINED_INFO *Package, + ACPI_OPERAND_OBJECT **Elements, + UINT32 Count); + +static ACPI_STATUS +AcpiNsCheckPackageElements ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **Elements, + UINT8 Type1, + UINT32 Count1, + UINT8 Type2, + UINT32 Count2, + UINT32 StartIndex); + +static ACPI_STATUS +AcpiNsCheckObjectType ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ReturnObjectPtr, + UINT32 ExpectedBtypes, + UINT32 PackageIndex); + +static ACPI_STATUS +AcpiNsCheckReference ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT *ReturnObject); + +static void +AcpiNsGetExpectedTypes ( + char *Buffer, + UINT32 ExpectedBtypes); + +/* + * Names for the types that can be returned by the predefined objects. + * Used for warning messages. Must be in the same order as the ACPI_RTYPEs + */ +static const char *AcpiRtypeNames[] = +{ + "/Integer", + "/String", + "/Buffer", + "/Package", + "/Reference", +}; + + +/******************************************************************************* + * + * FUNCTION: AcpiNsCheckPredefinedNames + * + * PARAMETERS: Node - Namespace node for the method/object + * UserParamCount - Number of parameters actually passed + * ReturnStatus - Status from the object evaluation + * ReturnObjectPtr - Pointer to the object returned from the + * evaluation of a method or object + * + * RETURN: Status + * + * DESCRIPTION: Check an ACPI name for a match in the predefined name list. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsCheckPredefinedNames ( + ACPI_NAMESPACE_NODE *Node, + UINT32 UserParamCount, + ACPI_STATUS ReturnStatus, + ACPI_OPERAND_OBJECT **ReturnObjectPtr) +{ + ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr; + ACPI_STATUS Status = AE_OK; + const ACPI_PREDEFINED_INFO *Predefined; + char *Pathname; + ACPI_PREDEFINED_DATA *Data; + + + /* Match the name for this method/object against the predefined list */ + + Predefined = AcpiNsCheckForPredefinedName (Node); + + /* Get the full pathname to the object, for use in warning messages */ + + Pathname = AcpiNsGetExternalPathname (Node); + if (!Pathname) + { + return (AE_OK); /* Could not get pathname, ignore */ + } + + /* + * Check that the parameter count for this method matches the ASL + * definition. For predefined names, ensure that both the caller and + * the method itself are in accordance with the ACPI specification. + */ + AcpiNsCheckParameterCount (Pathname, Node, UserParamCount, Predefined); + + /* If not a predefined name, we cannot validate the return object */ + + if (!Predefined) + { + goto Cleanup; + } + + /* + * If the method failed or did not actually return an object, we cannot + * validate the return object + */ + if ((ReturnStatus != AE_OK) && (ReturnStatus != AE_CTRL_RETURN_VALUE)) + { + goto Cleanup; + } + + /* + * If there is no return value, check if we require a return value for + * this predefined name. Either one return value is expected, or none, + * for both methods and other objects. + * + * Exit now if there is no return object. Warning if one was expected. + */ + if (!ReturnObject) + { + if ((Predefined->Info.ExpectedBtypes) && + (!(Predefined->Info.ExpectedBtypes & ACPI_RTYPE_NONE))) + { + ACPI_WARN_PREDEFINED ((AE_INFO, Pathname, ACPI_WARN_ALWAYS, + "Missing expected return value")); + + Status = AE_AML_NO_RETURN_VALUE; + } + goto Cleanup; + } + + /* + * 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. + * + * 2) If the return value can be of any type, then we cannot perform any + * validation, exit. + */ + if ((!Predefined->Info.ExpectedBtypes) || + (Predefined->Info.ExpectedBtypes == ACPI_RTYPE_ALL)) + { + goto Cleanup; + } + + /* Create the parameter data block for object validation */ + + Data = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_PREDEFINED_DATA)); + if (!Data) + { + goto Cleanup; + } + Data->Predefined = Predefined; + Data->NodeFlags = Node->Flags; + Data->Pathname = Pathname; + + /* + * Check that the type of the main return object is what is expected + * for this predefined name + */ + Status = AcpiNsCheckObjectType (Data, ReturnObjectPtr, + Predefined->Info.ExpectedBtypes, ACPI_NOT_PACKAGE_ELEMENT); + if (ACPI_FAILURE (Status)) + { + goto Exit; + } + + /* + * For returned Package objects, check the type of all sub-objects. + * Note: Package may have been newly created by call above. + */ + if ((*ReturnObjectPtr)->Common.Type == ACPI_TYPE_PACKAGE) + { + Status = AcpiNsCheckPackage (Data, ReturnObjectPtr); + if (ACPI_FAILURE (Status)) + { + goto Exit; + } + } + + /* + * The return object was OK, or it was successfully repaired above. + * Now make some additional checks such as verifying that package + * objects are sorted correctly (if required) or buffer objects have + * the correct data width (bytes vs. dwords). These repairs are + * performed on a per-name basis, i.e., the code is specific to + * particular predefined names. + */ + Status = AcpiNsComplexRepairs (Data, Node, Status, ReturnObjectPtr); + +Exit: + /* + * If the object validation failed or if we successfully repaired one + * or more objects, mark the parent node to suppress further warning + * messages during the next evaluation of the same method/object. + */ + if (ACPI_FAILURE (Status) || (Data->Flags & ACPI_OBJECT_REPAIRED)) + { + Node->Flags |= ANOBJ_EVALUATED; + } + ACPI_FREE (Data); + +Cleanup: + ACPI_FREE (Pathname); + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsCheckParameterCount + * + * PARAMETERS: Pathname - Full pathname to the node (for error msgs) + * Node - Namespace node for the method/object + * UserParamCount - Number of args passed in by the caller + * Predefined - Pointer to entry in predefined name table + * + * RETURN: None + * + * DESCRIPTION: Check that the declared (in ASL/AML) parameter count for a + * predefined name is what is expected (i.e., what is defined in + * the ACPI specification for this predefined name.) + * + ******************************************************************************/ + +void +AcpiNsCheckParameterCount ( + char *Pathname, + ACPI_NAMESPACE_NODE *Node, + UINT32 UserParamCount, + const ACPI_PREDEFINED_INFO *Predefined) +{ + UINT32 ParamCount; + UINT32 RequiredParamsCurrent; + UINT32 RequiredParamsOld; + + + /* Methods have 0-7 parameters. All other types have zero. */ + + ParamCount = 0; + if (Node->Type == ACPI_TYPE_METHOD) + { + ParamCount = Node->Object->Method.ParamCount; + } + + if (!Predefined) + { + /* + * Check the parameter count for non-predefined methods/objects. + * + * Warning if too few or too many arguments have been passed by the + * caller. An incorrect number of arguments may not cause the method + * to fail. However, the method will fail if there are too few + * arguments and the method attempts to use one of the missing ones. + */ + if (UserParamCount < ParamCount) + { + ACPI_WARN_PREDEFINED ((AE_INFO, Pathname, ACPI_WARN_ALWAYS, + "Insufficient arguments - needs %u, found %u", + ParamCount, UserParamCount)); + } + else if (UserParamCount > ParamCount) + { + ACPI_WARN_PREDEFINED ((AE_INFO, Pathname, ACPI_WARN_ALWAYS, + "Excess arguments - needs %u, found %u", + ParamCount, UserParamCount)); + } + return; + } + + /* + * Validate the user-supplied parameter count. + * Allow two different legal argument counts (_SCP, etc.) + */ + RequiredParamsCurrent = Predefined->Info.ParamCount & 0x0F; + RequiredParamsOld = Predefined->Info.ParamCount >> 4; + + if (UserParamCount != ACPI_UINT32_MAX) + { + if ((UserParamCount != RequiredParamsCurrent) && + (UserParamCount != RequiredParamsOld)) + { + ACPI_WARN_PREDEFINED ((AE_INFO, Pathname, ACPI_WARN_ALWAYS, + "Parameter count mismatch - " + "caller passed %u, ACPI requires %u", + UserParamCount, RequiredParamsCurrent)); + } + } + + /* + * Check that the ASL-defined parameter count is what is expected for + * this predefined name (parameter count as defined by the ACPI + * specification) + */ + if ((ParamCount != RequiredParamsCurrent) && + (ParamCount != RequiredParamsOld)) + { + ACPI_WARN_PREDEFINED ((AE_INFO, Pathname, Node->Flags, + "Parameter count mismatch - ASL declared %u, ACPI requires %u", + ParamCount, RequiredParamsCurrent)); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsCheckForPredefinedName + * + * PARAMETERS: Node - Namespace node for the method/object + * + * RETURN: Pointer to entry in predefined table. NULL indicates not found. + * + * DESCRIPTION: Check an object name against the predefined object list. + * + ******************************************************************************/ + +const ACPI_PREDEFINED_INFO * +AcpiNsCheckForPredefinedName ( + ACPI_NAMESPACE_NODE *Node) +{ + const ACPI_PREDEFINED_INFO *ThisName; + + + /* Quick check for a predefined name, first character must be underscore */ + + if (Node->Name.Ascii[0] != '_') + { + return (NULL); + } + + /* Search info table for a predefined method/object name */ + + ThisName = PredefinedNames; + while (ThisName->Info.Name[0]) + { + if (ACPI_COMPARE_NAME (Node->Name.Ascii, ThisName->Info.Name)) + { + return (ThisName); + } + + /* + * Skip next entry in the table if this name returns a Package + * (next entry contains the package info) + */ + if (ThisName->Info.ExpectedBtypes & ACPI_RTYPE_PACKAGE) + { + ThisName++; + } + + ThisName++; + } + + return (NULL); /* Not found */ +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsCheckPackage + * + * PARAMETERS: Data - Pointer to validation data structure + * ReturnObjectPtr - Pointer to the object returned from the + * evaluation of a method or object + * + * RETURN: Status + * + * DESCRIPTION: Check a returned package object for the correct count and + * correct type of all sub-objects. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsCheckPackage ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ReturnObjectPtr) +{ + ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr; + const ACPI_PREDEFINED_INFO *Package; + ACPI_OPERAND_OBJECT **Elements; + ACPI_STATUS Status = AE_OK; + UINT32 ExpectedCount; + UINT32 Count; + UINT32 i; + + + ACPI_FUNCTION_NAME (NsCheckPackage); + + + /* The package info for this name is in the next table entry */ + + Package = Data->Predefined + 1; + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "%s Validating return Package of Type %X, Count %X\n", + Data->Pathname, Package->RetInfo.Type, ReturnObject->Package.Count)); + + /* + * For variable-length Packages, we can safely remove all embedded + * and trailing NULL package elements + */ + AcpiNsRemoveNullElements (Data, Package->RetInfo.Type, ReturnObject); + + /* Extract package count and elements array */ + + Elements = ReturnObject->Package.Elements; + Count = ReturnObject->Package.Count; + + /* The package must have at least one element, else invalid */ + + if (!Count) + { + ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, + "Return Package has no elements (empty)")); + + return (AE_AML_OPERAND_VALUE); + } + + /* + * Decode the type of the expected package contents + * + * PTYPE1 packages contain no subpackages + * PTYPE2 packages contain sub-packages + */ + switch (Package->RetInfo.Type) + { + case ACPI_PTYPE1_FIXED: + + /* + * The package count is fixed and there are no sub-packages + * + * If package is too small, exit. + * If package is larger than expected, issue warning but continue + */ + ExpectedCount = Package->RetInfo.Count1 + Package->RetInfo.Count2; + if (Count < ExpectedCount) + { + goto PackageTooSmall; + } + else if (Count > ExpectedCount) + { + ACPI_DEBUG_PRINT ((ACPI_DB_REPAIR, + "%s: Return Package is larger than needed - " + "found %u, expected %u\n", + Data->Pathname, Count, ExpectedCount)); + } + + /* Validate all elements of the returned package */ + + Status = AcpiNsCheckPackageElements (Data, Elements, + Package->RetInfo.ObjectType1, Package->RetInfo.Count1, + Package->RetInfo.ObjectType2, Package->RetInfo.Count2, 0); + break; + + + case ACPI_PTYPE1_VAR: + + /* + * The package count is variable, there are no sub-packages, and all + * elements must be of the same type + */ + for (i = 0; i < Count; i++) + { + Status = AcpiNsCheckObjectType (Data, Elements, + Package->RetInfo.ObjectType1, i); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + Elements++; + } + break; + + + case ACPI_PTYPE1_OPTION: + + /* + * The package count is variable, there are no sub-packages. There are + * a fixed number of required elements, and a variable number of + * optional elements. + * + * Check if package is at least as large as the minimum required + */ + ExpectedCount = Package->RetInfo3.Count; + if (Count < ExpectedCount) + { + goto PackageTooSmall; + } + + /* Variable number of sub-objects */ + + for (i = 0; i < Count; i++) + { + if (i < Package->RetInfo3.Count) + { + /* These are the required package elements (0, 1, or 2) */ + + Status = AcpiNsCheckObjectType (Data, Elements, + Package->RetInfo3.ObjectType[i], i); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + else + { + /* These are the optional package elements */ + + Status = AcpiNsCheckObjectType (Data, Elements, + Package->RetInfo3.TailObjectType, i); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + Elements++; + } + break; + + + case ACPI_PTYPE2_REV_FIXED: + + /* First element is the (Integer) revision */ + + Status = AcpiNsCheckObjectType (Data, Elements, + ACPI_RTYPE_INTEGER, 0); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Elements++; + Count--; + + /* Examine the sub-packages */ + + Status = AcpiNsCheckPackageList (Data, Package, Elements, Count); + break; + + + case ACPI_PTYPE2_PKG_COUNT: + + /* First element is the (Integer) count of sub-packages to follow */ + + Status = AcpiNsCheckObjectType (Data, Elements, + ACPI_RTYPE_INTEGER, 0); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* + * Count cannot be larger than the parent package length, but allow it + * to be smaller. The >= accounts for the Integer above. + */ + ExpectedCount = (UINT32) (*Elements)->Integer.Value; + if (ExpectedCount >= Count) + { + goto PackageTooSmall; + } + + Count = ExpectedCount; + Elements++; + + /* Examine the sub-packages */ + + Status = AcpiNsCheckPackageList (Data, Package, Elements, Count); + break; + + + case ACPI_PTYPE2: + case ACPI_PTYPE2_FIXED: + case ACPI_PTYPE2_MIN: + case ACPI_PTYPE2_COUNT: + + /* + * These types all return a single Package that consists of a + * variable number of sub-Packages. + * + * First, ensure that the first element is a sub-Package. If not, + * the BIOS may have incorrectly returned the object as a single + * package instead of a Package of Packages (a common error if + * there is only one entry). We may be able to repair this by + * wrapping the returned Package with a new outer Package. + */ + if (*Elements && ((*Elements)->Common.Type != ACPI_TYPE_PACKAGE)) + { + /* Create the new outer package and populate it */ + + Status = AcpiNsRepairPackageList (Data, ReturnObjectPtr); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Update locals to point to the new package (of 1 element) */ + + ReturnObject = *ReturnObjectPtr; + Elements = ReturnObject->Package.Elements; + Count = 1; + } + + /* Examine the sub-packages */ + + Status = AcpiNsCheckPackageList (Data, Package, Elements, Count); + break; + + + default: + + /* Should not get here if predefined info table is correct */ + + ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, + "Invalid internal return type in table entry: %X", + Package->RetInfo.Type)); + + return (AE_AML_INTERNAL); + } + + return (Status); + + +PackageTooSmall: + + /* Error exit for the case with an incorrect package count */ + + ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, + "Return Package is too small - found %u elements, expected %u", + Count, ExpectedCount)); + + return (AE_AML_OPERAND_VALUE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsCheckPackageList + * + * PARAMETERS: Data - Pointer to validation data structure + * Package - Pointer to package-specific info for method + * Elements - Element list of parent package. All elements + * of this list should be of type Package. + * Count - Count of subpackages + * + * RETURN: Status + * + * DESCRIPTION: Examine a list of subpackages + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsCheckPackageList ( + ACPI_PREDEFINED_DATA *Data, + const ACPI_PREDEFINED_INFO *Package, + ACPI_OPERAND_OBJECT **Elements, + UINT32 Count) +{ + ACPI_OPERAND_OBJECT *SubPackage; + ACPI_OPERAND_OBJECT **SubElements; + ACPI_STATUS Status; + UINT32 ExpectedCount; + UINT32 i; + UINT32 j; + + + /* + * Validate each sub-Package in the parent Package + * + * NOTE: assumes list of sub-packages contains no NULL elements. + * Any NULL elements should have been removed by earlier call + * to AcpiNsRemoveNullElements. + */ + for (i = 0; i < Count; i++) + { + SubPackage = *Elements; + SubElements = SubPackage->Package.Elements; + + /* Each sub-object must be of type Package */ + + Status = AcpiNsCheckObjectType (Data, &SubPackage, + ACPI_RTYPE_PACKAGE, i); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Examine the different types of expected sub-packages */ + + 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; + + + case ACPI_PTYPE2_MIN: + + /* Each sub-package has a variable but minimum length */ + + ExpectedCount = Package->RetInfo.Count1; + if (SubPackage->Package.Count < ExpectedCount) + { + goto PackageTooSmall; + } + + /* Check the type of each sub-package element */ + + Status = AcpiNsCheckPackageElements (Data, SubElements, + Package->RetInfo.ObjectType1, + SubPackage->Package.Count, 0, 0, 0); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + break; + + + case ACPI_PTYPE2_COUNT: + + /* + * First element is the (Integer) count of elements, including + * the count field. + */ + Status = AcpiNsCheckObjectType (Data, SubElements, + ACPI_RTYPE_INTEGER, 0); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* + * Make sure package is large enough for the Count and is + * is as large as the minimum size + */ + ExpectedCount = (UINT32) (*SubElements)->Integer.Value; + if (SubPackage->Package.Count < ExpectedCount) + { + goto PackageTooSmall; + } + if (SubPackage->Package.Count < Package->RetInfo.Count1) + { + ExpectedCount = Package->RetInfo.Count1; + goto PackageTooSmall; + } + + /* Check the type of each sub-package element */ + + Status = AcpiNsCheckPackageElements (Data, (SubElements + 1), + Package->RetInfo.ObjectType1, + (ExpectedCount - 1), 0, 0, 1); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + break; + + + default: /* Should not get here, type was validated by caller */ + + return (AE_AML_INTERNAL); + } + + Elements++; + } + + return (AE_OK); + + +PackageTooSmall: + + /* The sub-package count was smaller than required */ + + ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, + "Return Sub-Package[%u] is too small - found %u elements, expected %u", + i, SubPackage->Package.Count, ExpectedCount)); + + return (AE_AML_OPERAND_VALUE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsCheckPackageElements + * + * PARAMETERS: Data - Pointer to validation data structure + * Elements - Pointer to the package elements array + * Type1 - Object type for first group + * Count1 - Count for first group + * Type2 - Object type for second group + * Count2 - Count for second group + * StartIndex - Start of the first group of elements + * + * RETURN: Status + * + * DESCRIPTION: Check that all elements of a package are of the correct object + * type. Supports up to two groups of different object types. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsCheckPackageElements ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **Elements, + UINT8 Type1, + UINT32 Count1, + UINT8 Type2, + UINT32 Count2, + UINT32 StartIndex) +{ + ACPI_OPERAND_OBJECT **ThisElement = Elements; + ACPI_STATUS Status; + UINT32 i; + + + /* + * Up to two groups of package elements are supported by the data + * structure. All elements in each group must be of the same type. + * The second group can have a count of zero. + */ + for (i = 0; i < Count1; i++) + { + Status = AcpiNsCheckObjectType (Data, ThisElement, + Type1, i + StartIndex); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + ThisElement++; + } + + for (i = 0; i < Count2; i++) + { + Status = AcpiNsCheckObjectType (Data, ThisElement, + Type2, (i + Count1 + StartIndex)); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + ThisElement++; + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsCheckObjectType + * + * PARAMETERS: Data - Pointer to validation data structure + * ReturnObjectPtr - Pointer to the object returned from the + * evaluation of a method or object + * ExpectedBtypes - Bitmap of expected return type(s) + * PackageIndex - Index of object within parent package (if + * applicable - ACPI_NOT_PACKAGE_ELEMENT + * otherwise) + * + * RETURN: Status + * + * DESCRIPTION: Check the type of the return object against the expected object + * type(s). Use of Btype allows multiple expected object types. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsCheckObjectType ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT **ReturnObjectPtr, + UINT32 ExpectedBtypes, + UINT32 PackageIndex) +{ + ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr; + ACPI_STATUS Status = AE_OK; + UINT32 ReturnBtype; + char TypeBuffer[48]; /* Room for 5 types */ + + + /* + * If we get a NULL ReturnObject here, it is a NULL package element, + * and this is always an error. + */ + if (!ReturnObject) + { + goto TypeErrorExit; + } + + /* A Namespace node should not get here, but make sure */ + + if (ACPI_GET_DESCRIPTOR_TYPE (ReturnObject) == ACPI_DESC_TYPE_NAMED) + { + ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, + "Invalid return type - Found a Namespace node [%4.4s] type %s", + ReturnObject->Node.Name.Ascii, + AcpiUtGetTypeName (ReturnObject->Node.Type))); + return (AE_AML_OPERAND_TYPE); + } + + /* + * Convert the object type (ACPI_TYPE_xxx) to a bitmapped object type. + * The bitmapped type allows multiple possible return types. + * + * Note, the cases below must handle all of the possible types returned + * from all of the predefined names (including elements of returned + * packages) + */ + switch (ReturnObject->Common.Type) + { + case ACPI_TYPE_INTEGER: + ReturnBtype = ACPI_RTYPE_INTEGER; + break; + + case ACPI_TYPE_BUFFER: + ReturnBtype = ACPI_RTYPE_BUFFER; + break; + + case ACPI_TYPE_STRING: + ReturnBtype = ACPI_RTYPE_STRING; + break; + + case ACPI_TYPE_PACKAGE: + ReturnBtype = ACPI_RTYPE_PACKAGE; + break; + + case ACPI_TYPE_LOCAL_REFERENCE: + ReturnBtype = ACPI_RTYPE_REFERENCE; + break; + + default: + /* Not one of the supported objects, must be incorrect */ + + goto TypeErrorExit; + } + + /* Is the object one of the expected types? */ + + if (!(ReturnBtype & ExpectedBtypes)) + { + /* Type mismatch -- attempt repair of the returned object */ + + Status = AcpiNsRepairObject (Data, ExpectedBtypes, + PackageIndex, ReturnObjectPtr); + if (ACPI_SUCCESS (Status)) + { + return (AE_OK); /* Repair was successful */ + } + goto TypeErrorExit; + } + + /* For reference objects, check that the reference type is correct */ + + if (ReturnObject->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) + { + Status = AcpiNsCheckReference (Data, ReturnObject); + } + + return (Status); + + +TypeErrorExit: + + /* Create a string with all expected types for this predefined object */ + + AcpiNsGetExpectedTypes (TypeBuffer, ExpectedBtypes); + + if (PackageIndex == ACPI_NOT_PACKAGE_ELEMENT) + { + ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, + "Return type mismatch - found %s, expected %s", + AcpiUtGetObjectTypeName (ReturnObject), TypeBuffer)); + } + else + { + ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, + "Return Package type mismatch at index %u - " + "found %s, expected %s", PackageIndex, + AcpiUtGetObjectTypeName (ReturnObject), TypeBuffer)); + } + + return (AE_AML_OPERAND_TYPE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsCheckReference + * + * PARAMETERS: Data - Pointer to validation data structure + * ReturnObject - Object returned from the evaluation of a + * method or object + * + * RETURN: Status + * + * DESCRIPTION: Check a returned reference object for the correct reference + * type. The only reference type that can be returned from a + * predefined method is a named reference. All others are invalid. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsCheckReference ( + ACPI_PREDEFINED_DATA *Data, + ACPI_OPERAND_OBJECT *ReturnObject) +{ + + /* + * Check the reference object for the correct reference type (opcode). + * The only type of reference that can be converted to an ACPI_OBJECT is + * a reference to a named object (reference class: NAME) + */ + if (ReturnObject->Reference.Class == ACPI_REFCLASS_NAME) + { + return (AE_OK); + } + + ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags, + "Return type mismatch - unexpected reference object type [%s] %2.2X", + AcpiUtGetReferenceName (ReturnObject), + ReturnObject->Reference.Class)); + + return (AE_AML_OPERAND_TYPE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsGetExpectedTypes + * + * PARAMETERS: Buffer - Pointer to where the string is returned + * ExpectedBtypes - Bitmap of expected return type(s) + * + * RETURN: Buffer is populated with type names. + * + * DESCRIPTION: Translate the expected types bitmap into a string of ascii + * names of expected types, for use in warning messages. + * + ******************************************************************************/ + +static void +AcpiNsGetExpectedTypes ( + char *Buffer, + UINT32 ExpectedBtypes) +{ + UINT32 ThisRtype; + UINT32 i; + UINT32 j; + + + j = 1; + Buffer[0] = 0; + ThisRtype = ACPI_RTYPE_INTEGER; + + for (i = 0; i < ACPI_NUM_RTYPES; i++) + { + /* If one of the expected types, concatenate the name of this type */ + + if (ExpectedBtypes & ThisRtype) + { + ACPI_STRCAT (Buffer, &AcpiRtypeNames[i][j]); + j = 0; /* Use name separator from now on */ + } + ThisRtype <<= 1; /* Next Rtype */ + } +} diff --git a/reactos/drivers/bus/acpi/acpica/namespace/nsrepair.c b/reactos/drivers/bus/acpi/acpica/namespace/nsrepair.c new file mode 100644 index 00000000000..5c402df36b5 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/namespace/nsrepair.c @@ -0,0 +1,686 @@ +/****************************************************************************** + * + * Module Name: nsrepair - Repair for objects returned by predefined methods + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __NSREPAIR_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" +#include "acinterp.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 + * + ******************************************************************************/ + + +/* 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: 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/reactos/drivers/bus/acpi/acpica/namespace/nsrepair2.c b/reactos/drivers/bus/acpi/acpica/namespace/nsrepair2.c new file mode 100644 index 00000000000..c08028452b4 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/namespace/nsrepair2.c @@ -0,0 +1,796 @@ +/****************************************************************************** + * + * Module Name: nsrepair2 - Repair for objects returned by specific + * predefined methods + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __NSREPAIR2_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" +#include "acpredef.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_FDE ( + 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 ACPI_STATUS +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 + * _FDE: Convert Buffer of BYTEs to a Buffer of DWORDs + * _GTM: Convert Buffer of BYTEs to a Buffer of DWORDs + * _PSS: Sort the list descending by Power + * _TSS: Sort the list descending by Power + */ +static const ACPI_REPAIR_INFO AcpiNsRepairableNames[] = +{ + {"_ALR", AcpiNsRepair_ALR}, + {"_FDE", AcpiNsRepair_FDE}, + {"_GTM", AcpiNsRepair_FDE}, /* _GTM has same repair as _FDE */ + {"_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_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_STATUS Status; + + + 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, issue a warning and sort the entire list + */ + if (((SortDirection == ACPI_SORT_ASCENDING) && + (ObjDesc->Integer.Value < PreviousValue)) || + ((SortDirection == ACPI_SORT_DESCENDING) && + (ObjDesc->Integer.Value > PreviousValue))) + { + Status = AcpiNsSortList (ReturnObject->Package.Elements, + OuterElementCount, SortIndex, SortDirection); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + 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: 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. + * + *****************************************************************************/ + +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: AcpiNsSortList + * + * PARAMETERS: Elements - Package object element list + * Count - Element count for above + * Index - Sort by which package element + * SortDirection - Ascending or Descending sort + * + * RETURN: Status + * + * DESCRIPTION: Sort the objects that are in a package element list. + * + * NOTE: Assumes that all NULL elements have been removed from the package. + * + *****************************************************************************/ + +static ACPI_STATUS +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; + } + } + } + + return (AE_OK); +} diff --git a/reactos/drivers/bus/acpi/acpica/namespace/nssearch.c b/reactos/drivers/bus/acpi/acpica/namespace/nssearch.c new file mode 100644 index 00000000000..fce7c5ad4de --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/namespace/nssearch.c @@ -0,0 +1,507 @@ +/******************************************************************************* + * + * Module Name: nssearch - Namespace search + * + ******************************************************************************/ + +/****************************************************************************** + * + * 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 __NSSEARCH_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" + +#ifdef ACPI_ASL_COMPILER +#include "amlcode.h" +#endif + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nssearch") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiNsSearchParentTree ( + UINT32 TargetName, + ACPI_NAMESPACE_NODE *Node, + ACPI_OBJECT_TYPE Type, + ACPI_NAMESPACE_NODE **ReturnNode); + + +/******************************************************************************* + * + * FUNCTION: AcpiNsSearchOneScope + * + * PARAMETERS: TargetName - Ascii ACPI name to search for + * ParentNode - Starting node where search will begin + * Type - Object type to match + * ReturnNode - Where the matched Named obj is returned + * + * RETURN: Status + * + * DESCRIPTION: Search a single level of the namespace. Performs a + * simple search of the specified level, and does not add + * entries or search parents. + * + * + * Named object lists are built (and subsequently dumped) in the + * order in which the names are encountered during the namespace load; + * + * All namespace searching is linear in this implementation, but + * could be easily modified to support any improved search + * algorithm. However, the linear search was chosen for simplicity + * and because the trees are small and the other interpreter + * execution overhead is relatively high. + * + * Note: CPU execution analysis has shown that the AML interpreter spends + * a very small percentage of its time searching the namespace. Therefore, + * the linear search seems to be sufficient, as there would seem to be + * little value in improving the search. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsSearchOneScope ( + UINT32 TargetName, + ACPI_NAMESPACE_NODE *ParentNode, + ACPI_OBJECT_TYPE Type, + ACPI_NAMESPACE_NODE **ReturnNode) +{ + ACPI_NAMESPACE_NODE *Node; + + + ACPI_FUNCTION_TRACE (NsSearchOneScope); + + +#ifdef ACPI_DEBUG_OUTPUT + if (ACPI_LV_NAMES & AcpiDbgLevel) + { + char *ScopeName; + + ScopeName = AcpiNsGetExternalPathname (ParentNode); + if (ScopeName) + { + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "Searching %s (%p) For [%4.4s] (%s)\n", + ScopeName, ParentNode, ACPI_CAST_PTR (char, &TargetName), + AcpiUtGetTypeName (Type))); + + ACPI_FREE (ScopeName); + } + } +#endif + + /* + * Search for name at this namespace level, which is to say that we + * must search for the name among the children of this object + */ + Node = ParentNode->Child; + while (Node) + { + /* Check for match against the name */ + + if (Node->Name.Integer == TargetName) + { + /* Resolve a control method alias if any */ + + if (AcpiNsGetType (Node) == ACPI_TYPE_LOCAL_METHOD_ALIAS) + { + Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Node->Object); + } + + /* Found matching entry */ + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "Name [%4.4s] (%s) %p found in scope [%4.4s] %p\n", + ACPI_CAST_PTR (char, &TargetName), + AcpiUtGetTypeName (Node->Type), + Node, AcpiUtGetNodeName (ParentNode), ParentNode)); + + *ReturnNode = Node; + return_ACPI_STATUS (AE_OK); + } + + /* + * 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; + } + + /* Searched entire namespace level, not found */ + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "Name [%4.4s] (%s) not found in search in scope [%4.4s] " + "%p first child %p\n", + ACPI_CAST_PTR (char, &TargetName), AcpiUtGetTypeName (Type), + AcpiUtGetNodeName (ParentNode), ParentNode, ParentNode->Child)); + + return_ACPI_STATUS (AE_NOT_FOUND); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsSearchParentTree + * + * PARAMETERS: TargetName - Ascii ACPI name to search for + * Node - Starting node where search will begin + * Type - Object type to match + * ReturnNode - Where the matched Node is returned + * + * RETURN: Status + * + * DESCRIPTION: Called when a name has not been found in the current namespace + * level. Before adding it or giving up, ACPI scope rules require + * searching enclosing scopes in cases identified by AcpiNsLocal(). + * + * "A name is located by finding the matching name in the current + * name space, and then in the parent name space. If the parent + * name space does not contain the name, the search continues + * recursively until either the name is found or the name space + * does not have a parent (the root of the name space). This + * indicates that the name is not found" (From ACPI Specification, + * section 5.3) + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsSearchParentTree ( + UINT32 TargetName, + ACPI_NAMESPACE_NODE *Node, + ACPI_OBJECT_TYPE Type, + ACPI_NAMESPACE_NODE **ReturnNode) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *ParentNode; + + + ACPI_FUNCTION_TRACE (NsSearchParentTree); + + + ParentNode = AcpiNsGetParentNode (Node); + + /* + * If there is no parent (i.e., we are at the root) or type is "local", + * we won't be searching the parent tree. + */ + if (!ParentNode) + { + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "[%4.4s] has no parent\n", + ACPI_CAST_PTR (char, &TargetName))); + return_ACPI_STATUS (AE_NOT_FOUND); + } + + if (AcpiNsLocal (Type)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "[%4.4s] type [%s] must be local to this scope (no parent search)\n", + ACPI_CAST_PTR (char, &TargetName), AcpiUtGetTypeName (Type))); + return_ACPI_STATUS (AE_NOT_FOUND); + } + + /* Search the parent tree */ + + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "Searching parent [%4.4s] for [%4.4s]\n", + AcpiUtGetNodeName (ParentNode), ACPI_CAST_PTR (char, &TargetName))); + + /* Search parents until target is found or we have backed up to the root */ + + while (ParentNode) + { + /* + * Search parent scope. Use TYPE_ANY because we don't care about the + * object type at this point, we only care about the existence of + * the actual name we are searching for. Typechecking comes later. + */ + Status = AcpiNsSearchOneScope ( + TargetName, ParentNode, ACPI_TYPE_ANY, ReturnNode); + if (ACPI_SUCCESS (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Not found here, go up another level (until we reach the root) */ + + ParentNode = AcpiNsGetParentNode (ParentNode); + } + + /* Not found in parent tree */ + + return_ACPI_STATUS (AE_NOT_FOUND); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsSearchAndEnter + * + * PARAMETERS: TargetName - Ascii ACPI name to search for (4 chars) + * WalkState - Current state of the walk + * Node - Starting node where search will begin + * InterpreterMode - Add names only in ACPI_MODE_LOAD_PASS_x. + * Otherwise,search only. + * Type - Object type to match + * Flags - Flags describing the search restrictions + * ReturnNode - Where the Node is returned + * + * RETURN: Status + * + * DESCRIPTION: Search for a name segment in a single namespace level, + * optionally adding it if it is not found. If the passed + * Type is not Any and the type previously stored in the + * entry was Any (i.e. unknown), update the stored type. + * + * In ACPI_IMODE_EXECUTE, search only. + * In other modes, search and add if not found. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsSearchAndEnter ( + UINT32 TargetName, + ACPI_WALK_STATE *WalkState, + ACPI_NAMESPACE_NODE *Node, + ACPI_INTERPRETER_MODE InterpreterMode, + ACPI_OBJECT_TYPE Type, + UINT32 Flags, + ACPI_NAMESPACE_NODE **ReturnNode) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *NewNode; + + + ACPI_FUNCTION_TRACE (NsSearchAndEnter); + + + /* Parameter validation */ + + if (!Node || !TargetName || !ReturnNode) + { + ACPI_ERROR ((AE_INFO, + "Null parameter: Node %p Name %X ReturnNode %p", + Node, TargetName, ReturnNode)); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* + * Name must consist of valid ACPI characters. We will repair the name if + * necessary because we don't want to abort because of this, but we want + * all namespace names to be printable. A warning message is appropriate. + * + * This issue came up because there are in fact machines that exhibit + * this problem, and we want to be able to enable ACPI support for them, + * even though there are a few bad names. + */ + AcpiUtRepairName (ACPI_CAST_PTR (char, &TargetName)); + + /* Try to find the name in the namespace level specified by the caller */ + + *ReturnNode = ACPI_ENTRY_NOT_FOUND; + Status = AcpiNsSearchOneScope (TargetName, Node, Type, ReturnNode); + if (Status != AE_NOT_FOUND) + { + /* + * If we found it AND the request specifies that a find is an error, + * return the error + */ + if ((Status == AE_OK) && + (Flags & ACPI_NS_ERROR_IF_FOUND)) + { + Status = AE_ALREADY_EXISTS; + } + +#ifdef ACPI_ASL_COMPILER + if (*ReturnNode && (*ReturnNode)->Type == ACPI_TYPE_ANY) + { + (*ReturnNode)->Flags |= ANOBJ_IS_EXTERNAL; + } +#endif + + /* Either found it or there was an error: finished either way */ + + return_ACPI_STATUS (Status); + } + + /* + * The name was not found. If we are NOT performing the first pass + * (name entry) of loading the namespace, search the parent tree (all the + * way to the root if necessary.) We don't want to perform the parent + * search when the namespace is actually being loaded. We want to perform + * the search when namespace references are being resolved (load pass 2) + * and during the execution phase. + */ + if ((InterpreterMode != ACPI_IMODE_LOAD_PASS1) && + (Flags & ACPI_NS_SEARCH_PARENT)) + { + /* + * Not found at this level - search parent tree according to the + * ACPI specification + */ + Status = AcpiNsSearchParentTree (TargetName, Node, Type, ReturnNode); + if (ACPI_SUCCESS (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* In execute mode, just search, never add names. Exit now */ + + if (InterpreterMode == ACPI_IMODE_EXECUTE) + { + ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, + "%4.4s Not found in %p [Not adding]\n", + ACPI_CAST_PTR (char, &TargetName), Node)); + + return_ACPI_STATUS (AE_NOT_FOUND); + } + + /* Create the new named object */ + + NewNode = AcpiNsCreateNode (TargetName); + if (!NewNode) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + +#ifdef ACPI_ASL_COMPILER + + /* Node is an object defined by an External() statement */ + + if (Flags & ACPI_NS_EXTERNAL || + (WalkState && WalkState->Opcode == AML_SCOPE_OP)) + { + NewNode->Flags |= ANOBJ_IS_EXTERNAL; + } +#endif + + if (Flags & ACPI_NS_TEMPORARY) + { + NewNode->Flags |= ANOBJ_TEMPORARY; + } + + /* Install the new object into the parent's list of children */ + + AcpiNsInstallNode (WalkState, Node, NewNode, Type); + *ReturnNode = NewNode; + return_ACPI_STATUS (AE_OK); +} + diff --git a/reactos/drivers/bus/acpi/acpica/namespace/nsutils.c b/reactos/drivers/bus/acpi/acpica/namespace/nsutils.c new file mode 100644 index 00000000000..ed0c3f7ec81 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/namespace/nsutils.c @@ -0,0 +1,1184 @@ +/****************************************************************************** + * + * Module Name: nsutils - Utilities for accessing ACPI namespace, accessing + * parents and siblings and Scope manipulation + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __NSUTILS_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" +#include "amlcode.h" + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nsutils") + +/* Local prototypes */ + +static BOOLEAN +AcpiNsValidPathSeparator ( + char Sep); + +#ifdef ACPI_OBSOLETE_FUNCTIONS +ACPI_NAME +AcpiNsFindParentName ( + ACPI_NAMESPACE_NODE *NodeToSearch); +#endif + + +/******************************************************************************* + * + * FUNCTION: 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 + * + * PARAMETERS: Node - Object + * Message - Prefix message + * + * DESCRIPTION: Print an object's full namespace pathname + * Manages allocation/freeing of a pathname buffer + * + ******************************************************************************/ + +void +AcpiNsPrintNodePathname ( + ACPI_NAMESPACE_NODE *Node, + const char *Message) +{ + ACPI_BUFFER Buffer; + ACPI_STATUS Status; + + + if (!Node) + { + AcpiOsPrintf ("[NULL NAME]"); + return; + } + + /* Convert handle to full pathname and print it (with supplied message) */ + + Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; + + Status = AcpiNsHandleToPathname (Node, &Buffer); + if (ACPI_SUCCESS (Status)) + { + if (Message) + { + AcpiOsPrintf ("%s ", Message); + } + + AcpiOsPrintf ("[%s] (Node %p)", (char *) Buffer.Pointer, Node); + ACPI_FREE (Buffer.Pointer); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsValidRootPrefix + * + * PARAMETERS: Prefix - Character to be checked + * + * RETURN: TRUE if a valid prefix + * + * DESCRIPTION: Check if a character is a valid ACPI Root prefix + * + ******************************************************************************/ + +BOOLEAN +AcpiNsValidRootPrefix ( + char Prefix) +{ + + return ((BOOLEAN) (Prefix == '\\')); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsValidPathSeparator + * + * PARAMETERS: Sep - Character to be checked + * + * RETURN: TRUE if a valid path separator + * + * DESCRIPTION: Check if a character is a valid ACPI path separator + * + ******************************************************************************/ + +static BOOLEAN +AcpiNsValidPathSeparator ( + char Sep) +{ + + return ((BOOLEAN) (Sep == '.')); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsGetType + * + * PARAMETERS: Node - Parent Node to be examined + * + * RETURN: Type field from Node whose handle is passed + * + * DESCRIPTION: Return the type of a Namespace node + * + ******************************************************************************/ + +ACPI_OBJECT_TYPE +AcpiNsGetType ( + ACPI_NAMESPACE_NODE *Node) +{ + ACPI_FUNCTION_TRACE (NsGetType); + + + if (!Node) + { + ACPI_WARNING ((AE_INFO, "Null Node parameter")); + return_UINT32 (ACPI_TYPE_ANY); + } + + return_UINT32 ((ACPI_OBJECT_TYPE) Node->Type); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsLocal + * + * PARAMETERS: Type - A namespace object type + * + * RETURN: LOCAL if names must be found locally in objects of the + * passed type, 0 if enclosing scopes should be searched + * + * DESCRIPTION: Returns scope rule for the given object type. + * + ******************************************************************************/ + +UINT32 +AcpiNsLocal ( + ACPI_OBJECT_TYPE Type) +{ + ACPI_FUNCTION_TRACE (NsLocal); + + + if (!AcpiUtValidObjectType (Type)) + { + /* Type code out of range */ + + ACPI_WARNING ((AE_INFO, "Invalid Object Type %X", Type)); + return_UINT32 (ACPI_NS_NORMAL); + } + + return_UINT32 ((UINT32) AcpiGbl_NsProperties[Type] & ACPI_NS_LOCAL); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsGetInternalNameLength + * + * PARAMETERS: Info - Info struct initialized with the + * external name pointer. + * + * RETURN: None + * + * DESCRIPTION: Calculate the length of the internal (AML) namestring + * corresponding to the external (ASL) namestring. + * + ******************************************************************************/ + +void +AcpiNsGetInternalNameLength ( + ACPI_NAMESTRING_INFO *Info) +{ + const char *NextExternalChar; + UINT32 i; + + + ACPI_FUNCTION_ENTRY (); + + + NextExternalChar = Info->ExternalName; + Info->NumCarats = 0; + Info->NumSegments = 0; + Info->FullyQualified = FALSE; + + /* + * For the internal name, the required length is 4 bytes per segment, plus + * 1 each for RootPrefix, MultiNamePrefixOp, segment count, trailing null + * (which is not really needed, but no there's harm in putting it there) + * + * strlen() + 1 covers the first NameSeg, which has no path separator + */ + if (AcpiNsValidRootPrefix (*NextExternalChar)) + { + Info->FullyQualified = TRUE; + NextExternalChar++; + + /* Skip redundant RootPrefix, like \\_SB.PCI0.SBRG.EC0 */ + + while (AcpiNsValidRootPrefix (*NextExternalChar)) + { + NextExternalChar++; + } + } + else + { + /* Handle Carat prefixes */ + + while (*NextExternalChar == '^') + { + Info->NumCarats++; + NextExternalChar++; + } + } + + /* + * Determine the number of ACPI name "segments" by counting the number of + * path separators within the string. Start with one segment since the + * segment count is [(# separators) + 1], and zero separators is ok. + */ + if (*NextExternalChar) + { + Info->NumSegments = 1; + for (i = 0; NextExternalChar[i]; i++) + { + if (AcpiNsValidPathSeparator (NextExternalChar[i])) + { + Info->NumSegments++; + } + } + } + + Info->Length = (ACPI_NAME_SIZE * Info->NumSegments) + + 4 + Info->NumCarats; + + Info->NextExternalChar = NextExternalChar; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsBuildInternalName + * + * PARAMETERS: Info - Info struct fully initialized + * + * RETURN: Status + * + * DESCRIPTION: Construct the internal (AML) namestring + * corresponding to the external (ASL) namestring. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsBuildInternalName ( + ACPI_NAMESTRING_INFO *Info) +{ + UINT32 NumSegments = Info->NumSegments; + char *InternalName = Info->InternalName; + const char *ExternalName = Info->NextExternalChar; + char *Result = NULL; + UINT32 i; + + + ACPI_FUNCTION_TRACE (NsBuildInternalName); + + + /* Setup the correct prefixes, counts, and pointers */ + + if (Info->FullyQualified) + { + InternalName[0] = '\\'; + + if (NumSegments <= 1) + { + Result = &InternalName[1]; + } + else if (NumSegments == 2) + { + InternalName[1] = AML_DUAL_NAME_PREFIX; + Result = &InternalName[2]; + } + else + { + InternalName[1] = AML_MULTI_NAME_PREFIX_OP; + InternalName[2] = (char) NumSegments; + Result = &InternalName[3]; + } + } + else + { + /* + * Not fully qualified. + * Handle Carats first, then append the name segments + */ + i = 0; + if (Info->NumCarats) + { + for (i = 0; i < Info->NumCarats; i++) + { + InternalName[i] = '^'; + } + } + + if (NumSegments <= 1) + { + Result = &InternalName[i]; + } + else if (NumSegments == 2) + { + InternalName[i] = AML_DUAL_NAME_PREFIX; + Result = &InternalName[(ACPI_SIZE) i+1]; + } + else + { + InternalName[i] = AML_MULTI_NAME_PREFIX_OP; + InternalName[(ACPI_SIZE) i+1] = (char) NumSegments; + Result = &InternalName[(ACPI_SIZE) i+2]; + } + } + + /* Build the name (minus path separators) */ + + for (; NumSegments; NumSegments--) + { + for (i = 0; i < ACPI_NAME_SIZE; i++) + { + if (AcpiNsValidPathSeparator (*ExternalName) || + (*ExternalName == 0)) + { + /* Pad the segment with underscore(s) if segment is short */ + + Result[i] = '_'; + } + else + { + /* Convert the character to uppercase and save it */ + + Result[i] = (char) ACPI_TOUPPER ((int) *ExternalName); + ExternalName++; + } + } + + /* Now we must have a path separator, or the pathname is bad */ + + if (!AcpiNsValidPathSeparator (*ExternalName) && + (*ExternalName != 0)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Move on the next segment */ + + ExternalName++; + Result += ACPI_NAME_SIZE; + } + + /* Terminate the string */ + + *Result = 0; + + if (Info->FullyQualified) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Returning [%p] (abs) \"\\%s\"\n", + InternalName, InternalName)); + } + else + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Returning [%p] (rel) \"%s\"\n", + InternalName, InternalName)); + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsInternalizeName + * + * PARAMETERS: *ExternalName - External representation of name + * **Converted Name - Where to return the resulting + * internal represention of the name + * + * RETURN: Status + * + * DESCRIPTION: Convert an external representation (e.g. "\_PR_.CPU0") + * to internal form (e.g. 5c 2f 02 5f 50 52 5f 43 50 55 30) + * + *******************************************************************************/ + +ACPI_STATUS +AcpiNsInternalizeName ( + const char *ExternalName, + char **ConvertedName) +{ + char *InternalName; + ACPI_NAMESTRING_INFO Info; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (NsInternalizeName); + + + if ((!ExternalName) || + (*ExternalName == 0) || + (!ConvertedName)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Get the length of the new internal name */ + + Info.ExternalName = ExternalName; + AcpiNsGetInternalNameLength (&Info); + + /* We need a segment to store the internal name */ + + InternalName = ACPI_ALLOCATE_ZEROED (Info.Length); + if (!InternalName) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Build the name */ + + Info.InternalName = InternalName; + Status = AcpiNsBuildInternalName (&Info); + if (ACPI_FAILURE (Status)) + { + ACPI_FREE (InternalName); + return_ACPI_STATUS (Status); + } + + *ConvertedName = InternalName; + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsExternalizeName + * + * PARAMETERS: InternalNameLength - Lenth of the internal name below + * InternalName - Internal representation of name + * ConvertedNameLength - Where the length is returned + * ConvertedName - Where the resulting external name + * is returned + * + * RETURN: Status + * + * DESCRIPTION: Convert internal name (e.g. 5c 2f 02 5f 50 52 5f 43 50 55 30) + * to its external (printable) form (e.g. "\_PR_.CPU0") + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsExternalizeName ( + UINT32 InternalNameLength, + const char *InternalName, + UINT32 *ConvertedNameLength, + char **ConvertedName) +{ + UINT32 NamesIndex = 0; + UINT32 NumSegments = 0; + UINT32 RequiredLength; + UINT32 PrefixLength = 0; + UINT32 i = 0; + UINT32 j = 0; + + + ACPI_FUNCTION_TRACE (NsExternalizeName); + + + if (!InternalNameLength || + !InternalName || + !ConvertedName) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Check for a prefix (one '\' | one or more '^') */ + + switch (InternalName[0]) + { + case '\\': + PrefixLength = 1; + break; + + case '^': + for (i = 0; i < InternalNameLength; i++) + { + if (InternalName[i] == '^') + { + PrefixLength = i + 1; + } + else + { + break; + } + } + + if (i == InternalNameLength) + { + PrefixLength = i; + } + + break; + + default: + break; + } + + /* + * Check for object names. Note that there could be 0-255 of these + * 4-byte elements. + */ + if (PrefixLength < InternalNameLength) + { + switch (InternalName[PrefixLength]) + { + case AML_MULTI_NAME_PREFIX_OP: + + /* 4-byte names */ + + NamesIndex = PrefixLength + 2; + NumSegments = (UINT8) + InternalName[(ACPI_SIZE) PrefixLength + 1]; + break; + + case AML_DUAL_NAME_PREFIX: + + /* Two 4-byte names */ + + NamesIndex = PrefixLength + 1; + NumSegments = 2; + break; + + case 0: + + /* NullName */ + + NamesIndex = 0; + NumSegments = 0; + break; + + default: + + /* one 4-byte name */ + + NamesIndex = PrefixLength; + NumSegments = 1; + break; + } + } + + /* + * Calculate the length of ConvertedName, which equals the length + * of the prefix, length of all object names, length of any required + * punctuation ('.') between object names, plus the NULL terminator. + */ + RequiredLength = PrefixLength + (4 * NumSegments) + + ((NumSegments > 0) ? (NumSegments - 1) : 0) + 1; + + /* + * Check to see if we're still in bounds. If not, there's a problem + * with InternalName (invalid format). + */ + if (RequiredLength > InternalNameLength) + { + ACPI_ERROR ((AE_INFO, "Invalid internal name")); + return_ACPI_STATUS (AE_BAD_PATHNAME); + } + + /* Build the ConvertedName */ + + *ConvertedName = ACPI_ALLOCATE_ZEROED (RequiredLength); + if (!(*ConvertedName)) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + j = 0; + + for (i = 0; i < PrefixLength; i++) + { + (*ConvertedName)[j++] = InternalName[i]; + } + + if (NumSegments > 0) + { + for (i = 0; i < NumSegments; i++) + { + if (i > 0) + { + (*ConvertedName)[j++] = '.'; + } + + (*ConvertedName)[j++] = InternalName[NamesIndex++]; + (*ConvertedName)[j++] = InternalName[NamesIndex++]; + (*ConvertedName)[j++] = InternalName[NamesIndex++]; + (*ConvertedName)[j++] = InternalName[NamesIndex++]; + } + } + + if (ConvertedNameLength) + { + *ConvertedNameLength = (UINT32) RequiredLength; + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsValidateHandle + * + * PARAMETERS: Handle - Handle to be validated and typecast to a + * namespace node. + * + * RETURN: A pointer to a namespace node + * + * DESCRIPTION: Convert a namespace handle to a namespace node. Handles special + * cases for the root node. + * + * NOTE: Real integer handles would allow for more verification + * and keep all pointers within this subsystem - however this introduces + * more overhead and has not been necessary to this point. Drivers + * holding handles are typically notified before a node becomes invalid + * due to a table unload. + * + ******************************************************************************/ + +ACPI_NAMESPACE_NODE * +AcpiNsValidateHandle ( + ACPI_HANDLE Handle) +{ + + ACPI_FUNCTION_ENTRY (); + + + /* Parameter validation */ + + if ((!Handle) || (Handle == ACPI_ROOT_OBJECT)) + { + return (AcpiGbl_RootNode); + } + + /* We can at least attempt to verify the handle */ + + if (ACPI_GET_DESCRIPTOR_TYPE (Handle) != ACPI_DESC_TYPE_NAMED) + { + return (NULL); + } + + return (ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Handle)); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsTerminate + * + * PARAMETERS: none + * + * RETURN: none + * + * DESCRIPTION: free memory allocated for namespace and ACPI table storage. + * + ******************************************************************************/ + +void +AcpiNsTerminate ( + void) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + + + ACPI_FUNCTION_TRACE (NsTerminate); + + + /* + * 1) Free the entire namespace -- all nodes and objects + * + * Delete all object descriptors attached to namepsace nodes + */ + AcpiNsDeleteNamespaceSubtree (AcpiGbl_RootNode); + + /* Detach any objects attached to the root */ + + ObjDesc = AcpiNsGetAttachedObject (AcpiGbl_RootNode); + if (ObjDesc) + { + AcpiNsDetachObject (AcpiGbl_RootNode); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Namespace freed\n")); + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsOpensScope + * + * PARAMETERS: Type - A valid namespace type + * + * RETURN: NEWSCOPE if the passed type "opens a name scope" according + * to the ACPI specification, else 0 + * + ******************************************************************************/ + +UINT32 +AcpiNsOpensScope ( + ACPI_OBJECT_TYPE Type) +{ + ACPI_FUNCTION_TRACE_STR (NsOpensScope, AcpiUtGetTypeName (Type)); + + + if (!AcpiUtValidObjectType (Type)) + { + /* type code out of range */ + + ACPI_WARNING ((AE_INFO, "Invalid Object Type %X", Type)); + return_UINT32 (ACPI_NS_NORMAL); + } + + return_UINT32 (((UINT32) AcpiGbl_NsProperties[Type]) & ACPI_NS_NEWSCOPE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsGetNode + * + * PARAMETERS: *Pathname - Name to be found, in external (ASL) format. The + * \ (backslash) and ^ (carat) prefixes, and the + * . (period) to separate segments are supported. + * PrefixNode - Root of subtree to be searched, or NS_ALL for the + * root of the name space. If Name is fully + * qualified (first INT8 is '\'), the passed value + * of Scope will not be accessed. + * Flags - Used to indicate whether to perform upsearch or + * not. + * ReturnNode - Where the Node is returned + * + * DESCRIPTION: Look up a name relative to a given scope and return the + * corresponding Node. NOTE: Scope can be null. + * + * MUTEX: Locks namespace + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsGetNode ( + ACPI_NAMESPACE_NODE *PrefixNode, + const char *Pathname, + UINT32 Flags, + ACPI_NAMESPACE_NODE **ReturnNode) +{ + ACPI_GENERIC_STATE ScopeInfo; + ACPI_STATUS Status; + char *InternalPath; + + + ACPI_FUNCTION_TRACE_PTR (NsGetNode, ACPI_CAST_PTR (char, Pathname)); + + + if (!Pathname) + { + *ReturnNode = PrefixNode; + if (!PrefixNode) + { + *ReturnNode = AcpiGbl_RootNode; + } + return_ACPI_STATUS (AE_OK); + } + + /* Convert path to internal representation */ + + Status = AcpiNsInternalizeName (Pathname, &InternalPath); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Must lock namespace during lookup */ + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* Setup lookup scope (search starting point) */ + + ScopeInfo.Scope.Node = PrefixNode; + + /* Lookup the name in the namespace */ + + Status = AcpiNsLookup (&ScopeInfo, InternalPath, ACPI_TYPE_ANY, + ACPI_IMODE_EXECUTE, (Flags | ACPI_NS_DONT_OPEN_SCOPE), + NULL, ReturnNode); + if (ACPI_FAILURE (Status)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%s, %s\n", + Pathname, AcpiFormatException (Status))); + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + +Cleanup: + ACPI_FREE (InternalPath); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * 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/reactos/drivers/bus/acpi/acpica/namespace/nswalk.c b/reactos/drivers/bus/acpi/acpica/namespace/nswalk.c new file mode 100644 index 00000000000..7711e9a3768 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/namespace/nswalk.c @@ -0,0 +1,468 @@ +/****************************************************************************** + * + * Module Name: nswalk - Functions for walking the ACPI namespace + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __NSWALK_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nswalk") + + +/******************************************************************************* + * + * FUNCTION: AcpiNsGetNextNode + * + * PARAMETERS: ParentNode - Parent node whose children we are + * getting + * ChildNode - Previous child that was found. + * The NEXT child will be returned + * + * RETURN: ACPI_NAMESPACE_NODE - Pointer to the NEXT child or NULL if + * none is found. + * + * DESCRIPTION: Return the next peer node within the namespace. If Handle + * is valid, Scope is ignored. Otherwise, the first node + * within Scope is returned. + * + ******************************************************************************/ + +ACPI_NAMESPACE_NODE * +AcpiNsGetNextNode ( + ACPI_NAMESPACE_NODE *ParentNode, + ACPI_NAMESPACE_NODE *ChildNode) +{ + ACPI_FUNCTION_ENTRY (); + + + if (!ChildNode) + { + /* It's really the parent's _scope_ that we want */ + + return (ParentNode->Child); + } + + /* + * 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); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsGetNextNodeTyped + * + * PARAMETERS: Type - Type of node to be searched for + * ParentNode - Parent node whose children we are + * getting + * ChildNode - Previous child that was found. + * The NEXT child will be returned + * + * RETURN: ACPI_NAMESPACE_NODE - Pointer to the NEXT child or NULL if + * none is found. + * + * DESCRIPTION: Return the next peer node within the namespace. If Handle + * is valid, Scope is ignored. Otherwise, the first node + * within Scope is returned. + * + ******************************************************************************/ + +ACPI_NAMESPACE_NODE * +AcpiNsGetNextNodeTyped ( + ACPI_OBJECT_TYPE Type, + ACPI_NAMESPACE_NODE *ParentNode, + ACPI_NAMESPACE_NODE *ChildNode) +{ + ACPI_NAMESPACE_NODE *NextNode = NULL; + + + ACPI_FUNCTION_ENTRY (); + + + NextNode = AcpiNsGetNextNode (ParentNode, ChildNode); + + /* If any type is OK, we are done */ + + if (Type == ACPI_TYPE_ANY) + { + /* NextNode is NULL if we are at the end-of-list */ + + return (NextNode); + } + + /* Must search for the node -- but within this scope only */ + + while (NextNode) + { + /* If type matches, we are done */ + + if (NextNode->Type == Type) + { + return (NextNode); + } + + /* Otherwise, move on to the next node */ + + NextNode = AcpiNsGetNextValidNode (NextNode); + } + + /* Not found */ + + return (NULL); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiNsWalkNamespace + * + * PARAMETERS: Type - ACPI_OBJECT_TYPE to search for + * StartNode - Handle in namespace where search begins + * MaxDepth - Depth to which search is to reach + * Flags - Whether to unlock the NS before invoking + * the callback routine + * PreOrderVisit - Called during tree pre-order visit + * when an object of "Type" is found + * PostOrderVisit - Called during tree post-order visit + * when an object of "Type" is found + * Context - Passed to user function(s) above + * ReturnValue - from the UserFunction if terminated + * early. Otherwise, returns NULL. + * RETURNS: Status + * + * DESCRIPTION: Performs a modified depth-first walk of the namespace tree, + * starting (and ending) at the node specified by StartHandle. + * The callback function is called whenever a node that matches + * the type parameter is found. If the callback function returns + * a non-zero value, the search is terminated immediately and + * this value is returned to the caller. + * + * The point of this procedure is to provide a generic namespace + * walk routine that can be called from multiple places to + * provide multiple services; the callback function(s) can be + * tailored to each task, whether it is a print function, + * a compare function, etc. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsWalkNamespace ( + ACPI_OBJECT_TYPE Type, + ACPI_HANDLE StartNode, + UINT32 MaxDepth, + UINT32 Flags, + ACPI_WALK_CALLBACK PreOrderVisit, + ACPI_WALK_CALLBACK PostOrderVisit, + void *Context, + void **ReturnValue) +{ + ACPI_STATUS Status; + ACPI_STATUS MutexStatus; + ACPI_NAMESPACE_NODE *ChildNode; + ACPI_NAMESPACE_NODE *ParentNode; + ACPI_OBJECT_TYPE ChildType; + UINT32 Level; + BOOLEAN NodePreviouslyVisited = FALSE; + + + ACPI_FUNCTION_TRACE (NsWalkNamespace); + + + /* Special case for the namespace Root Node */ + + if (StartNode == ACPI_ROOT_OBJECT) + { + StartNode = AcpiGbl_RootNode; + } + + /* Null child means "get first node" */ + + ParentNode = StartNode; + ChildNode = AcpiNsGetNextNode (ParentNode, NULL); + ChildType = ACPI_TYPE_ANY; + Level = 1; + + /* + * Traverse the tree of nodes until we bubble back up to where we + * started. When Level is zero, the loop is done because we have + * bubbled up to (and passed) the original parent handle (StartEntry) + */ + while (Level > 0 && ChildNode) + { + Status = AE_OK; + + /* Found next child, get the type if we are not searching for ANY */ + + if (Type != ACPI_TYPE_ANY) + { + ChildType = ChildNode->Type; + } + + /* + * Ignore all temporary namespace nodes (created during control + * method execution) unless told otherwise. These temporary nodes + * can cause a race condition because they can be deleted during + * the execution of the user function (if the namespace is + * unlocked before invocation of the user function.) Only the + * debugger namespace dump will examine the temporary nodes. + */ + if ((ChildNode->Flags & ANOBJ_TEMPORARY) && + !(Flags & ACPI_NS_WALK_TEMP_NODES)) + { + Status = AE_CTRL_DEPTH; + } + + /* Type must match requested type */ + + else if (ChildType == Type) + { + /* + * Found a matching node, invoke the user callback function. + * Unlock the namespace if flag is set. + */ + if (Flags & ACPI_NS_WALK_UNLOCK) + { + MutexStatus = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (MutexStatus)) + { + return_ACPI_STATUS (MutexStatus); + } + } + + /* + * Invoke the user function, either pre-order or post-order + * or both. + */ + if (!NodePreviouslyVisited) + { + if (PreOrderVisit) + { + Status = PreOrderVisit (ChildNode, Level, + Context, ReturnValue); + } + } + else + { + if (PostOrderVisit) + { + Status = PostOrderVisit (ChildNode, Level, + Context, ReturnValue); + } + } + + if (Flags & ACPI_NS_WALK_UNLOCK) + { + MutexStatus = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (MutexStatus)) + { + return_ACPI_STATUS (MutexStatus); + } + } + + switch (Status) + { + case AE_OK: + case AE_CTRL_DEPTH: + + /* Just keep going */ + break; + + case AE_CTRL_TERMINATE: + + /* Exit now, with OK status */ + + return_ACPI_STATUS (AE_OK); + + default: + + /* All others are valid exceptions */ + + return_ACPI_STATUS (Status); + } + } + + /* + * Depth first search: Attempt to go down another level in the + * namespace if we are allowed to. Don't go any further if we have + * reached the caller specified maximum depth or if the user + * function has specified that the maximum depth has been reached. + */ + if (!NodePreviouslyVisited && + (Level < MaxDepth) && + (Status != AE_CTRL_DEPTH)) + { + if (ChildNode->Child) + { + /* There is at least one child of this node, visit it */ + + Level++; + ParentNode = ChildNode; + ChildNode = AcpiNsGetNextNode (ParentNode, NULL); + continue; + } + } + + /* No more children, re-visit this node */ + + if (!NodePreviouslyVisited) + { + NodePreviouslyVisited = TRUE; + continue; + } + + /* No more children, visit peers */ + + ChildNode = AcpiNsGetNextNode (ParentNode, ChildNode); + if (ChildNode) + { + NodePreviouslyVisited = FALSE; + } + + /* No peers, re-visit parent */ + + else + { + /* + * No more children of this node (AcpiNsGetNextNode failed), go + * back upwards in the namespace tree to the node's parent. + */ + Level--; + ChildNode = ParentNode; + ParentNode = AcpiNsGetParentNode (ParentNode); + + NodePreviouslyVisited = TRUE; + } + } + + /* Complete walk, not terminated by user function */ + + return_ACPI_STATUS (AE_OK); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/namespace/nsxfeval.c b/reactos/drivers/bus/acpi/acpica/namespace/nsxfeval.c new file mode 100644 index 00000000000..a0f96a04ee0 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/namespace/nsxfeval.c @@ -0,0 +1,1020 @@ +/******************************************************************************* + * + * Module Name: nsxfeval - Public interfaces to the ACPI subsystem + * ACPI Object evaluation interfaces + * + ******************************************************************************/ + +/****************************************************************************** + * + * 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 __NSXFEVAL_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" +#include "acinterp.h" + + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nsxfeval") + +/* Local prototypes */ + +static void +AcpiNsResolveReferences ( + ACPI_EVALUATE_INFO *Info); + + +/******************************************************************************* + * + * FUNCTION: AcpiEvaluateObjectTyped + * + * PARAMETERS: Handle - Object handle (optional) + * Pathname - Object pathname (optional) + * ExternalParams - List of parameters to pass to method, + * terminated by NULL. May be NULL + * if no parameters are being passed. + * ReturnBuffer - Where to put method's return value (if + * any). If NULL, no value is returned. + * ReturnType - Expected type of return object + * + * RETURN: Status + * + * DESCRIPTION: Find and evaluate the given object, passing the given + * parameters if necessary. One of "Handle" or "Pathname" must + * be valid (non-null) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvaluateObjectTyped ( + ACPI_HANDLE Handle, + ACPI_STRING Pathname, + ACPI_OBJECT_LIST *ExternalParams, + ACPI_BUFFER *ReturnBuffer, + ACPI_OBJECT_TYPE ReturnType) +{ + ACPI_STATUS Status; + BOOLEAN MustFree = FALSE; + + + ACPI_FUNCTION_TRACE (AcpiEvaluateObjectTyped); + + + /* Return buffer must be valid */ + + if (!ReturnBuffer) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + if (ReturnBuffer->Length == ACPI_ALLOCATE_BUFFER) + { + MustFree = TRUE; + } + + /* Evaluate the object */ + + Status = AcpiEvaluateObject (Handle, Pathname, ExternalParams, ReturnBuffer); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Type ANY means "don't care" */ + + if (ReturnType == ACPI_TYPE_ANY) + { + return_ACPI_STATUS (AE_OK); + } + + if (ReturnBuffer->Length == 0) + { + /* Error because caller specifically asked for a return value */ + + ACPI_ERROR ((AE_INFO, "No return value")); + return_ACPI_STATUS (AE_NULL_OBJECT); + } + + /* Examine the object type returned from EvaluateObject */ + + if (((ACPI_OBJECT *) ReturnBuffer->Pointer)->Type == ReturnType) + { + return_ACPI_STATUS (AE_OK); + } + + /* Return object type does not match requested type */ + + ACPI_ERROR ((AE_INFO, + "Incorrect return type [%s] requested [%s]", + AcpiUtGetTypeName (((ACPI_OBJECT *) ReturnBuffer->Pointer)->Type), + AcpiUtGetTypeName (ReturnType))); + + if (MustFree) + { + /* Caller used ACPI_ALLOCATE_BUFFER, free the return buffer */ + + AcpiOsFree (ReturnBuffer->Pointer); + ReturnBuffer->Pointer = NULL; + } + + ReturnBuffer->Length = 0; + return_ACPI_STATUS (AE_TYPE); +} + +ACPI_EXPORT_SYMBOL (AcpiEvaluateObjectTyped) + + +/******************************************************************************* + * + * FUNCTION: AcpiEvaluateObject + * + * PARAMETERS: Handle - Object handle (optional) + * Pathname - Object pathname (optional) + * ExternalParams - List of parameters to pass to method, + * terminated by NULL. May be NULL + * if no parameters are being passed. + * ReturnBuffer - Where to put method's return value (if + * any). If NULL, no value is returned. + * + * RETURN: Status + * + * DESCRIPTION: Find and evaluate the given object, passing the given + * parameters if necessary. One of "Handle" or "Pathname" must + * be valid (non-null) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEvaluateObject ( + ACPI_HANDLE Handle, + ACPI_STRING Pathname, + ACPI_OBJECT_LIST *ExternalParams, + ACPI_BUFFER *ReturnBuffer) +{ + ACPI_STATUS Status; + ACPI_EVALUATE_INFO *Info; + ACPI_SIZE BufferSpaceNeeded; + UINT32 i; + + + ACPI_FUNCTION_TRACE (AcpiEvaluateObject); + + + /* Allocate and initialize the evaluation information block */ + + Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO)); + if (!Info) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Info->Pathname = Pathname; + + /* Convert and validate the device handle */ + + Info->PrefixNode = AcpiNsValidateHandle (Handle); + if (!Info->PrefixNode) + { + Status = AE_BAD_PARAMETER; + goto Cleanup; + } + + /* + * If there are parameters to be passed to a control method, the external + * objects must all be converted to internal objects + */ + if (ExternalParams && ExternalParams->Count) + { + /* + * Allocate a new parameter block for the internal objects + * Add 1 to count to allow for null terminated internal list + */ + Info->Parameters = ACPI_ALLOCATE_ZEROED ( + ((ACPI_SIZE) ExternalParams->Count + 1) * sizeof (void *)); + if (!Info->Parameters) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Convert each external object in the list to an internal object */ + + for (i = 0; i < ExternalParams->Count; i++) + { + Status = AcpiUtCopyEobjectToIobject ( + &ExternalParams->Pointer[i], &Info->Parameters[i]); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + } + Info->Parameters[ExternalParams->Count] = NULL; + } + + /* + * Three major cases: + * 1) Fully qualified pathname + * 2) No handle, not fully qualified pathname (error) + * 3) Valid handle + */ + if ((Pathname) && + (AcpiNsValidRootPrefix (Pathname[0]))) + { + /* The path is fully qualified, just evaluate by name */ + + Info->PrefixNode = NULL; + Status = AcpiNsEvaluate (Info); + } + else if (!Handle) + { + /* + * A handle is optional iff a fully qualified pathname is specified. + * Since we've already handled fully qualified names above, this is + * an error + */ + if (!Pathname) + { + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Both Handle and Pathname are NULL")); + } + else + { + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Null Handle with relative pathname [%s]", Pathname)); + } + + Status = AE_BAD_PARAMETER; + } + else + { + /* We have a namespace a node and a possible relative path */ + + Status = AcpiNsEvaluate (Info); + } + + /* + * If we are expecting a return value, and all went well above, + * copy the return value to an external object. + */ + if (ReturnBuffer) + { + if (!Info->ReturnObject) + { + ReturnBuffer->Length = 0; + } + else + { + if (ACPI_GET_DESCRIPTOR_TYPE (Info->ReturnObject) == + ACPI_DESC_TYPE_NAMED) + { + /* + * If we received a NS Node as a return object, this means that + * the object we are evaluating has nothing interesting to + * return (such as a mutex, etc.) We return an error because + * these types are essentially unsupported by this interface. + * We don't check up front because this makes it easier to add + * support for various types at a later date if necessary. + */ + Status = AE_TYPE; + Info->ReturnObject = NULL; /* No need to delete a NS Node */ + ReturnBuffer->Length = 0; + } + + if (ACPI_SUCCESS (Status)) + { + /* Dereference Index and RefOf references */ + + AcpiNsResolveReferences (Info); + + /* Get the size of the returned object */ + + Status = AcpiUtGetObjectSize (Info->ReturnObject, + &BufferSpaceNeeded); + if (ACPI_SUCCESS (Status)) + { + /* Validate/Allocate/Clear caller buffer */ + + Status = AcpiUtInitializeBuffer (ReturnBuffer, + BufferSpaceNeeded); + if (ACPI_FAILURE (Status)) + { + /* + * Caller's buffer is too small or a new one can't + * be allocated + */ + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Needed buffer size %X, %s\n", + (UINT32) BufferSpaceNeeded, + AcpiFormatException (Status))); + } + else + { + /* We have enough space for the object, build it */ + + Status = AcpiUtCopyIobjectToEobject (Info->ReturnObject, + ReturnBuffer); + } + } + } + } + } + + if (Info->ReturnObject) + { + /* + * Delete the internal return object. NOTE: Interpreter must be + * locked to avoid race condition. + */ + AcpiExEnterInterpreter (); + + /* Remove one reference on the return object (should delete it) */ + + AcpiUtRemoveReference (Info->ReturnObject); + AcpiExExitInterpreter (); + } + + +Cleanup: + + /* Free the input parameter list (if we created one) */ + + if (Info->Parameters) + { + /* Free the allocated parameter block */ + + AcpiUtDeleteInternalObjectList (Info->Parameters); + } + + ACPI_FREE (Info); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiEvaluateObject) + + +/******************************************************************************* + * + * FUNCTION: AcpiNsResolveReferences + * + * PARAMETERS: Info - Evaluation info block + * + * RETURN: Info->ReturnObject is replaced with the dereferenced object + * + * DESCRIPTION: Dereference certain reference objects. Called before an + * internal return object is converted to an external ACPI_OBJECT. + * + * Performs an automatic dereference of Index and RefOf reference objects. + * These reference objects are not supported by the ACPI_OBJECT, so this is a + * last resort effort to return something useful. Also, provides compatibility + * with other ACPI implementations. + * + * NOTE: does not handle references within returned package objects or nested + * references, but this support could be added later if found to be necessary. + * + ******************************************************************************/ + +static void +AcpiNsResolveReferences ( + ACPI_EVALUATE_INFO *Info) +{ + ACPI_OPERAND_OBJECT *ObjDesc = NULL; + ACPI_NAMESPACE_NODE *Node; + + + /* We are interested in reference objects only */ + + if ((Info->ReturnObject)->Common.Type != ACPI_TYPE_LOCAL_REFERENCE) + { + return; + } + + /* + * Two types of references are supported - those created by Index and + * RefOf operators. A name reference (AML_NAMEPATH_OP) can be converted + * to an ACPI_OBJECT, so it is not dereferenced here. A DdbHandle + * (AML_LOAD_OP) cannot be dereferenced, nor can it be converted to + * an ACPI_OBJECT. + */ + switch (Info->ReturnObject->Reference.Class) + { + case ACPI_REFCLASS_INDEX: + + ObjDesc = *(Info->ReturnObject->Reference.Where); + break; + + case ACPI_REFCLASS_REFOF: + + Node = Info->ReturnObject->Reference.Object; + if (Node) + { + ObjDesc = Node->Object; + } + break; + + default: + return; + } + + /* Replace the existing reference object */ + + if (ObjDesc) + { + AcpiUtAddReference (ObjDesc); + AcpiUtRemoveReference (Info->ReturnObject); + Info->ReturnObject = ObjDesc; + } + + return; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiWalkNamespace + * + * PARAMETERS: Type - ACPI_OBJECT_TYPE to search for + * StartObject - Handle in namespace where search begins + * MaxDepth - Depth to which search is to reach + * PreOrderVisit - Called during tree pre-order visit + * when an object of "Type" is found + * PostOrderVisit - Called during tree post-order visit + * when an object of "Type" is found + * Context - Passed to user function(s) above + * ReturnValue - Location where return value of + * UserFunction is put if terminated early + * + * RETURNS Return value from the UserFunction if terminated early. + * Otherwise, returns NULL. + * + * DESCRIPTION: Performs a modified depth-first walk of the namespace tree, + * starting (and ending) at the object specified by StartHandle. + * The callback function is called whenever an object that matches + * the type parameter is found. If the callback function returns + * a non-zero value, the search is terminated immediately and this + * value is returned to the caller. + * + * The point of this procedure is to provide a generic namespace + * walk routine that can be called from multiple places to + * provide multiple services; the callback function(s) can be + * tailored to each task, whether it is a print function, + * a compare function, etc. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiWalkNamespace ( + ACPI_OBJECT_TYPE Type, + ACPI_HANDLE StartObject, + UINT32 MaxDepth, + ACPI_WALK_CALLBACK PreOrderVisit, + ACPI_WALK_CALLBACK PostOrderVisit, + void *Context, + void **ReturnValue) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiWalkNamespace); + + + /* Parameter validation */ + + if ((Type > ACPI_TYPE_LOCAL_MAX) || + (!MaxDepth) || + (!PreOrderVisit && !PostOrderVisit)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* + * Need to acquire the namespace reader lock to prevent interference + * with any concurrent table unloads (which causes the deletion of + * namespace objects). We cannot allow the deletion of a namespace node + * while the user function is using it. The exception to this are the + * nodes created and deleted during control method execution -- these + * nodes are marked as temporary nodes and are ignored by the namespace + * walk. Thus, control methods can be executed while holding the + * namespace deletion lock (and the user function can execute control + * methods.) + */ + Status = AcpiUtAcquireReadLock (&AcpiGbl_NamespaceRwLock); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* + * Lock the namespace around the walk. The namespace will be + * unlocked/locked around each call to the user function - since the user + * function must be allowed to make ACPICA calls itself (for example, it + * will typically execute control methods during device enumeration.) + */ + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + + Status = AcpiNsWalkNamespace (Type, StartObject, MaxDepth, + ACPI_NS_WALK_UNLOCK, PreOrderVisit, + PostOrderVisit, Context, ReturnValue); + + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + +UnlockAndExit: + (void) AcpiUtReleaseReadLock (&AcpiGbl_NamespaceRwLock); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiWalkNamespace) + + +/******************************************************************************* + * + * FUNCTION: AcpiNsGetDeviceCallback + * + * PARAMETERS: Callback from AcpiGetDevice + * + * RETURN: Status + * + * DESCRIPTION: Takes callbacks from WalkNamespace and filters out all non- + * present devices, or if they specified a HID, it filters based + * on that. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiNsGetDeviceCallback ( + ACPI_HANDLE ObjHandle, + UINT32 NestingLevel, + void *Context, + void **ReturnValue) +{ + ACPI_GET_DEVICES_INFO *Info = Context; + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + UINT32 Flags; + ACPI_DEVICE_ID *Hid; + ACPI_DEVICE_ID_LIST *Cid; + UINT32 i; + BOOLEAN Found; + int NoMatch; + + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Node = AcpiNsValidateHandle (ObjHandle); + Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + if (!Node) + { + return (AE_BAD_PARAMETER); + } + + /* 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 */ + + if (Info->Hid != NULL) + { + Status = AcpiUtExecute_HID (Node, &Hid); + if (Status == AE_NOT_FOUND) + { + return (AE_OK); + } + else if (ACPI_FAILURE (Status)) + { + return (AE_CTRL_DEPTH); + } + + NoMatch = ACPI_STRCMP (Hid->String, Info->Hid); + ACPI_FREE (Hid); + + if (NoMatch) + { + /* + * HID does not match, attempt match within the + * list of Compatible IDs (CIDs) + */ + Status = AcpiUtExecute_CID (Node, &Cid); + if (Status == AE_NOT_FOUND) + { + return (AE_OK); + } + else if (ACPI_FAILURE (Status)) + { + return (AE_CTRL_DEPTH); + } + + /* Walk the CID list */ + + Found = FALSE; + for (i = 0; i < Cid->Count; i++) + { + if (ACPI_STRCMP (Cid->Ids[i].String, Info->Hid) == 0) + { + /* Found a matching CID */ + + Found = TRUE; + break; + } + } + + ACPI_FREE (Cid); + if (!Found) + { + return (AE_OK); + } + } + } + + /* We have a valid device, invoke the user function */ + + Status = Info->UserFunction (ObjHandle, NestingLevel, Info->Context, + ReturnValue); + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiGetDevices + * + * PARAMETERS: HID - HID to search for. Can be NULL. + * UserFunction - Called when a matching object is found + * Context - Passed to user function + * ReturnValue - Location where return value of + * UserFunction is put if terminated early + * + * RETURNS Return value from the UserFunction if terminated early. + * Otherwise, returns NULL. + * + * DESCRIPTION: Performs a modified depth-first walk of the namespace tree, + * starting (and ending) at the object specified by StartHandle. + * The UserFunction is called whenever an object of type + * Device is found. If the user function returns + * a non-zero value, the search is terminated immediately and this + * value is returned to the caller. + * + * This is a wrapper for WalkNamespace, but the callback performs + * additional filtering. Please see AcpiNsGetDeviceCallback. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetDevices ( + char *HID, + ACPI_WALK_CALLBACK UserFunction, + void *Context, + void **ReturnValue) +{ + ACPI_STATUS Status; + ACPI_GET_DEVICES_INFO Info; + + + ACPI_FUNCTION_TRACE (AcpiGetDevices); + + + /* Parameter validation */ + + if (!UserFunction) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* + * We're going to call their callback from OUR callback, so we need + * to know what it is, and their context parameter. + */ + Info.Hid = HID; + Info.Context = Context; + Info.UserFunction = UserFunction; + + /* + * Lock the namespace around the walk. + * The namespace will be unlocked/locked around each call + * to the user function - since this function + * must be allowed to make Acpi calls itself. + */ + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, + ACPI_UINT32_MAX, ACPI_NS_WALK_UNLOCK, + AcpiNsGetDeviceCallback, NULL, &Info, ReturnValue); + + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiGetDevices) + + +/******************************************************************************* + * + * FUNCTION: AcpiAttachData + * + * PARAMETERS: ObjHandle - Namespace node + * Handler - Handler for this attachment + * Data - Pointer to data to be attached + * + * RETURN: Status + * + * DESCRIPTION: Attach arbitrary data and handler to a namespace node. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAttachData ( + ACPI_HANDLE ObjHandle, + ACPI_OBJECT_HANDLER Handler, + void *Data) +{ + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + + + /* Parameter validation */ + + if (!ObjHandle || + !Handler || + !Data) + { + return (AE_BAD_PARAMETER); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Convert and validate the handle */ + + Node = AcpiNsValidateHandle (ObjHandle); + if (!Node) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + Status = AcpiNsAttachData (Node, Handler, Data); + +UnlockAndExit: + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiAttachData) + + +/******************************************************************************* + * + * FUNCTION: AcpiDetachData + * + * PARAMETERS: ObjHandle - Namespace node handle + * Handler - Handler used in call to AcpiAttachData + * + * RETURN: Status + * + * DESCRIPTION: Remove data that was previously attached to a node. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDetachData ( + ACPI_HANDLE ObjHandle, + ACPI_OBJECT_HANDLER Handler) +{ + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + + + /* Parameter validation */ + + if (!ObjHandle || + !Handler) + { + return (AE_BAD_PARAMETER); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Convert and validate the handle */ + + Node = AcpiNsValidateHandle (ObjHandle); + if (!Node) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + Status = AcpiNsDetachData (Node, Handler); + +UnlockAndExit: + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiDetachData) + + +/******************************************************************************* + * + * FUNCTION: AcpiGetData + * + * PARAMETERS: ObjHandle - Namespace node + * Handler - Handler used in call to AttachData + * Data - Where the data is returned + * + * RETURN: Status + * + * DESCRIPTION: Retrieve data that was previously attached to a namespace node. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetData ( + ACPI_HANDLE ObjHandle, + ACPI_OBJECT_HANDLER Handler, + void **Data) +{ + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + + + /* Parameter validation */ + + if (!ObjHandle || + !Handler || + !Data) + { + return (AE_BAD_PARAMETER); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Convert and validate the handle */ + + Node = AcpiNsValidateHandle (ObjHandle); + if (!Node) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + Status = AcpiNsGetAttachedData (Node, Handler, Data); + +UnlockAndExit: + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiGetData) + + diff --git a/reactos/drivers/bus/acpi/acpica/namespace/nsxfname.c b/reactos/drivers/bus/acpi/acpica/namespace/nsxfname.c new file mode 100644 index 00000000000..cb7aaa6f941 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/namespace/nsxfname.c @@ -0,0 +1,776 @@ +/****************************************************************************** + * + * Module Name: nsxfname - Public interfaces to the ACPI subsystem + * ACPI Namespace oriented interfaces + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __NSXFNAME_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" +#include "acparser.h" +#include "amlcode.h" + + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nsxfname") + +/* Local prototypes */ + +static char * +AcpiNsCopyDeviceId ( + ACPI_DEVICE_ID *Dest, + ACPI_DEVICE_ID *Source, + char *StringArea); + + +/****************************************************************************** + * + * FUNCTION: AcpiGetHandle + * + * PARAMETERS: Parent - Object to search under (search scope). + * Pathname - Pointer to an asciiz string containing the + * name + * RetHandle - Where the return handle is returned + * + * RETURN: Status + * + * DESCRIPTION: This routine will search for a caller specified name in the + * name space. The caller can restrict the search region by + * specifying a non NULL parent. The parent value is itself a + * namespace handle. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetHandle ( + ACPI_HANDLE Parent, + ACPI_STRING Pathname, + ACPI_HANDLE *RetHandle) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node = NULL; + ACPI_NAMESPACE_NODE *PrefixNode = NULL; + + + ACPI_FUNCTION_ENTRY (); + + + /* Parameter Validation */ + + if (!RetHandle || !Pathname) + { + return (AE_BAD_PARAMETER); + } + + /* Convert a parent handle to a prefix node */ + + if (Parent) + { + PrefixNode = AcpiNsValidateHandle (Parent); + if (!PrefixNode) + { + return (AE_BAD_PARAMETER); + } + } + + /* + * Valid cases are: + * 1) Fully qualified pathname + * 2) Parent + Relative pathname + * + * Error for + */ + if (AcpiNsValidRootPrefix (Pathname[0])) + { + /* Pathname is fully qualified (starts with '\') */ + + /* Special case for root-only, since we can't search for it */ + + if (!ACPI_STRCMP (Pathname, ACPI_NS_ROOT_PATH)) + { + *RetHandle = ACPI_CAST_PTR (ACPI_HANDLE, AcpiGbl_RootNode); + return (AE_OK); + } + } + else if (!PrefixNode) + { + /* Relative path with null prefix is disallowed */ + + return (AE_BAD_PARAMETER); + } + + /* Find the Node and convert to a handle */ + + Status = AcpiNsGetNode (PrefixNode, Pathname, ACPI_NS_NO_UPSEARCH, &Node); + if (ACPI_SUCCESS (Status)) + { + *RetHandle = ACPI_CAST_PTR (ACPI_HANDLE, Node); + } + + return (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiGetHandle) + + +/****************************************************************************** + * + * FUNCTION: AcpiGetName + * + * PARAMETERS: Handle - Handle to be converted to a pathname + * NameType - Full pathname or single segment + * Buffer - Buffer for returned path + * + * RETURN: Pointer to a string containing the fully qualified Name. + * + * DESCRIPTION: This routine returns the fully qualified name associated with + * the Handle parameter. This and the AcpiPathnameToHandle are + * complementary functions. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetName ( + ACPI_HANDLE Handle, + UINT32 NameType, + ACPI_BUFFER *Buffer) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + + + /* Parameter validation */ + + if (NameType > ACPI_NAME_TYPE_MAX) + { + return (AE_BAD_PARAMETER); + } + + Status = AcpiUtValidateBuffer (Buffer); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + if (NameType == ACPI_FULL_PATHNAME) + { + /* Get the full pathname (From the namespace root) */ + + Status = AcpiNsHandleToPathname (Handle, Buffer); + return (Status); + } + + /* + * Wants the single segment ACPI name. + * Validate handle and convert to a namespace Node + */ + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Node = AcpiNsValidateHandle (Handle); + if (!Node) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* Validate/Allocate/Clear caller buffer */ + + Status = AcpiUtInitializeBuffer (Buffer, ACPI_PATH_SEGMENT_LENGTH); + if (ACPI_FAILURE (Status)) + { + goto UnlockAndExit; + } + + /* Just copy the ACPI name from the Node and zero terminate it */ + + ACPI_STRNCPY (Buffer->Pointer, AcpiUtGetNodeName (Node), + ACPI_NAME_SIZE); + ((char *) Buffer->Pointer) [ACPI_NAME_SIZE] = 0; + Status = AE_OK; + + +UnlockAndExit: + + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiGetName) + + +/****************************************************************************** + * + * FUNCTION: AcpiNsCopyDeviceId + * + * PARAMETERS: Dest - Pointer to the destination DEVICE_ID + * Source - Pointer to the source DEVICE_ID + * StringArea - Pointer to where to copy the dest string + * + * RETURN: Pointer to the next string area + * + * DESCRIPTION: Copy a single DEVICE_ID, including the string data. + * + ******************************************************************************/ + +static char * +AcpiNsCopyDeviceId ( + ACPI_DEVICE_ID *Dest, + ACPI_DEVICE_ID *Source, + char *StringArea) +{ + /* Create the destination DEVICE_ID */ + + Dest->String = StringArea; + Dest->Length = Source->Length; + + /* Copy actual string and return a pointer to the next string area */ + + ACPI_MEMCPY (StringArea, Source->String, Source->Length); + return (StringArea + Source->Length); +} + + +/****************************************************************************** + * + * FUNCTION: AcpiGetObjectInfo + * + * PARAMETERS: Handle - Object Handle + * ReturnBuffer - Where the info is returned + * + * RETURN: Status + * + * DESCRIPTION: Returns information about an object as gleaned from the + * namespace node and possibly by running several standard + * control methods (Such as in the case of a device.) + * + * For Device and Processor objects, run the Device _HID, _UID, _CID, _STA, + * _ADR, _SxW, and _SxD methods. + * + * Note: Allocates the return buffer, must be freed by the caller. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetObjectInfo ( + ACPI_HANDLE Handle, + ACPI_DEVICE_INFO **ReturnBuffer) +{ + ACPI_NAMESPACE_NODE *Node; + ACPI_DEVICE_INFO *Info; + ACPI_DEVICE_ID_LIST *CidList = NULL; + ACPI_DEVICE_ID *Hid = NULL; + ACPI_DEVICE_ID *Uid = NULL; + char *NextIdString; + ACPI_OBJECT_TYPE Type; + ACPI_NAME Name; + UINT8 ParamCount= 0; + UINT8 Valid = 0; + UINT32 InfoSize; + UINT32 i; + ACPI_STATUS Status; + + + /* Parameter validation */ + + if (!Handle || !ReturnBuffer) + { + return (AE_BAD_PARAMETER); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + Node = AcpiNsValidateHandle (Handle); + if (!Node) + { + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return (AE_BAD_PARAMETER); + } + + /* Get the namespace node data while the namespace is locked */ + + InfoSize = sizeof (ACPI_DEVICE_INFO); + Type = Node->Type; + Name = Node->Name.Integer; + + if (Node->Type == ACPI_TYPE_METHOD) + { + ParamCount = Node->Object->Method.ParamCount; + } + + Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + if ((Type == ACPI_TYPE_DEVICE) || + (Type == ACPI_TYPE_PROCESSOR)) + { + /* + * Get extra info for ACPI Device/Processor objects only: + * Run the Device _HID, _UID, and _CID methods. + * + * Note: none of these methods are required, so they may or may + * not be present for this device. The Info->Valid bitfield is used + * to indicate which methods were found and run successfully. + */ + + /* Execute the Device._HID method */ + + Status = AcpiUtExecute_HID (Node, &Hid); + if (ACPI_SUCCESS (Status)) + { + InfoSize += Hid->Length; + Valid |= ACPI_VALID_HID; + } + + /* Execute the Device._UID method */ + + Status = AcpiUtExecute_UID (Node, &Uid); + if (ACPI_SUCCESS (Status)) + { + InfoSize += Uid->Length; + Valid |= ACPI_VALID_UID; + } + + /* Execute the Device._CID method */ + + Status = AcpiUtExecute_CID (Node, &CidList); + if (ACPI_SUCCESS (Status)) + { + /* Add size of CID strings and CID pointer array */ + + InfoSize += (CidList->ListSize - sizeof (ACPI_DEVICE_ID_LIST)); + Valid |= ACPI_VALID_CID; + } + } + + /* + * Now that we have the variable-length data, we can allocate the + * return buffer + */ + Info = ACPI_ALLOCATE_ZEROED (InfoSize); + if (!Info) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Get the fixed-length data */ + + if ((Type == ACPI_TYPE_DEVICE) || + (Type == ACPI_TYPE_PROCESSOR)) + { + /* + * Get extra info for ACPI Device/Processor objects only: + * Run the _STA, _ADR and, SxW, and _SxD methods. + * + * Note: none of these methods are required, so they may or may + * not be present for this device. The Info->Valid bitfield is used + * to indicate which methods were found and run successfully. + */ + + /* Execute the Device._STA method */ + + Status = AcpiUtExecute_STA (Node, &Info->CurrentStatus); + if (ACPI_SUCCESS (Status)) + { + Valid |= ACPI_VALID_STA; + } + + /* Execute the Device._ADR method */ + + Status = AcpiUtEvaluateNumericObject (METHOD_NAME__ADR, Node, + &Info->Address); + if (ACPI_SUCCESS (Status)) + { + Valid |= ACPI_VALID_ADR; + } + + /* Execute the Device._SxW methods */ + + Status = AcpiUtExecutePowerMethods (Node, + AcpiGbl_LowestDstateNames, ACPI_NUM_SxW_METHODS, + Info->LowestDstates); + if (ACPI_SUCCESS (Status)) + { + Valid |= ACPI_VALID_SXWS; + } + + /* Execute the Device._SxD methods */ + + Status = AcpiUtExecutePowerMethods (Node, + AcpiGbl_HighestDstateNames, ACPI_NUM_SxD_METHODS, + Info->HighestDstates); + if (ACPI_SUCCESS (Status)) + { + Valid |= ACPI_VALID_SXDS; + } + } + + /* + * Create a pointer to the string area of the return buffer. + * Point to the end of the base ACPI_DEVICE_INFO structure. + */ + NextIdString = ACPI_CAST_PTR (char, Info->CompatibleIdList.Ids); + if (CidList) + { + /* Point past the CID DEVICE_ID array */ + + NextIdString += ((ACPI_SIZE) CidList->Count * sizeof (ACPI_DEVICE_ID)); + } + + /* + * Copy the HID, UID, and CIDs to the return buffer. The variable-length + * strings are copied to the reserved area at the end of the buffer. + * + * For HID and CID, check if the ID is a PCI Root Bridge. + */ + if (Hid) + { + NextIdString = AcpiNsCopyDeviceId (&Info->HardwareId, + Hid, NextIdString); + + if (AcpiUtIsPciRootBridge (Hid->String)) + { + Info->Flags |= ACPI_PCI_ROOT_BRIDGE; + } + } + + if (Uid) + { + NextIdString = AcpiNsCopyDeviceId (&Info->UniqueId, + Uid, NextIdString); + } + + if (CidList) + { + Info->CompatibleIdList.Count = CidList->Count; + Info->CompatibleIdList.ListSize = CidList->ListSize; + + /* Copy each CID */ + + for (i = 0; i < CidList->Count; i++) + { + NextIdString = AcpiNsCopyDeviceId (&Info->CompatibleIdList.Ids[i], + &CidList->Ids[i], NextIdString); + + if (AcpiUtIsPciRootBridge (CidList->Ids[i].String)) + { + Info->Flags |= ACPI_PCI_ROOT_BRIDGE; + } + } + } + + /* Copy the fixed-length data */ + + Info->InfoSize = InfoSize; + Info->Type = Type; + Info->Name = Name; + Info->ParamCount = ParamCount; + Info->Valid = Valid; + + *ReturnBuffer = Info; + Status = AE_OK; + + +Cleanup: + if (Hid) + { + ACPI_FREE (Hid); + } + if (Uid) + { + ACPI_FREE (Uid); + } + if (CidList) + { + ACPI_FREE (CidList); + } + return (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiGetObjectInfo) + + +/****************************************************************************** + * + * FUNCTION: AcpiInstallMethod + * + * PARAMETERS: Buffer - An ACPI table containing one control method + * + * RETURN: Status + * + * DESCRIPTION: Install a control method into the namespace. If the method + * name already exists in the namespace, it is overwritten. The + * input buffer must contain a valid DSDT or SSDT containing a + * single control method. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiInstallMethod ( + UINT8 *Buffer) +{ + ACPI_TABLE_HEADER *Table = ACPI_CAST_PTR (ACPI_TABLE_HEADER, Buffer); + UINT8 *AmlBuffer; + UINT8 *AmlStart; + char *Path; + ACPI_NAMESPACE_NODE *Node; + ACPI_OPERAND_OBJECT *MethodObj; + ACPI_PARSE_STATE ParserState; + UINT32 AmlLength; + UINT16 Opcode; + UINT8 MethodFlags; + ACPI_STATUS Status; + + + /* Parameter validation */ + + if (!Buffer) + { + return (AE_BAD_PARAMETER); + } + + /* Table must be a DSDT or SSDT */ + + if (!ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_DSDT) && + !ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_SSDT)) + { + return (AE_BAD_HEADER); + } + + /* First AML opcode in the table must be a control method */ + + ParserState.Aml = Buffer + sizeof (ACPI_TABLE_HEADER); + Opcode = AcpiPsPeekOpcode (&ParserState); + if (Opcode != AML_METHOD_OP) + { + return (AE_BAD_PARAMETER); + } + + /* Extract method information from the raw AML */ + + ParserState.Aml += AcpiPsGetOpcodeSize (Opcode); + ParserState.PkgEnd = AcpiPsGetNextPackageEnd (&ParserState); + Path = AcpiPsGetNextNamestring (&ParserState); + MethodFlags = *ParserState.Aml++; + AmlStart = ParserState.Aml; + AmlLength = ACPI_PTR_DIFF (ParserState.PkgEnd, AmlStart); + + /* + * Allocate resources up-front. We don't want to have to delete a new + * node from the namespace if we cannot allocate memory. + */ + AmlBuffer = ACPI_ALLOCATE (AmlLength); + if (!AmlBuffer) + { + return (AE_NO_MEMORY); + } + + MethodObj = AcpiUtCreateInternalObject (ACPI_TYPE_METHOD); + if (!MethodObj) + { + ACPI_FREE (AmlBuffer); + return (AE_NO_MEMORY); + } + + /* Lock namespace for AcpiNsLookup, we may be creating a new node */ + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + + /* The lookup either returns an existing node or creates a new one */ + + Status = AcpiNsLookup (NULL, Path, ACPI_TYPE_METHOD, ACPI_IMODE_LOAD_PASS1, + ACPI_NS_DONT_OPEN_SCOPE | ACPI_NS_ERROR_IF_FOUND, NULL, &Node); + + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + + if (ACPI_FAILURE (Status)) /* NsLookup */ + { + if (Status != AE_ALREADY_EXISTS) + { + goto ErrorExit; + } + + /* Node existed previously, make sure it is a method node */ + + if (Node->Type != ACPI_TYPE_METHOD) + { + Status = AE_TYPE; + goto ErrorExit; + } + } + + /* Copy the method AML to the local buffer */ + + ACPI_MEMCPY (AmlBuffer, AmlStart, AmlLength); + + /* Initialize the method object with the new method's information */ + + MethodObj->Method.AmlStart = AmlBuffer; + MethodObj->Method.AmlLength = AmlLength; + + MethodObj->Method.ParamCount = (UINT8) + (MethodFlags & AML_METHOD_ARG_COUNT); + + MethodObj->Method.MethodFlags = (UINT8) + (MethodFlags & ~AML_METHOD_ARG_COUNT); + + if (MethodFlags & AML_METHOD_SERIALIZED) + { + MethodObj->Method.SyncLevel = (UINT8) + ((MethodFlags & AML_METHOD_SYNC_LEVEL) >> 4); + } + + /* + * Now that it is complete, we can attach the new method object to + * the method Node (detaches/deletes any existing object) + */ + Status = AcpiNsAttachObject (Node, MethodObj, + ACPI_TYPE_METHOD); + + /* + * Flag indicates AML buffer is dynamic, must be deleted later. + * Must be set only after attach above. + */ + Node->Flags |= ANOBJ_ALLOCATED_BUFFER; + + /* Remove local reference to the method object */ + + AcpiUtRemoveReference (MethodObj); + return (Status); + + +ErrorExit: + + ACPI_FREE (AmlBuffer); + ACPI_FREE (MethodObj); + return (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiInstallMethod) diff --git a/reactos/drivers/bus/acpi/acpica/namespace/nsxfobj.c b/reactos/drivers/bus/acpi/acpica/namespace/nsxfobj.c new file mode 100644 index 00000000000..9c42a33f8b2 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/namespace/nsxfobj.c @@ -0,0 +1,357 @@ +/******************************************************************************* + * + * Module Name: nsxfobj - Public interfaces to the ACPI subsystem + * ACPI Object oriented interfaces + * + ******************************************************************************/ + +/****************************************************************************** + * + * 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 __NSXFOBJ_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_NAMESPACE + ACPI_MODULE_NAME ("nsxfobj") + +/******************************************************************************* + * + * FUNCTION: AcpiGetType + * + * PARAMETERS: Handle - Handle of object whose type is desired + * RetType - Where the type will be placed + * + * RETURN: Status + * + * DESCRIPTION: This routine returns the type associatd with a particular handle + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetType ( + ACPI_HANDLE Handle, + ACPI_OBJECT_TYPE *RetType) +{ + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + + + /* Parameter Validation */ + + if (!RetType) + { + return (AE_BAD_PARAMETER); + } + + /* + * Special case for the predefined Root Node + * (return type ANY) + */ + if (Handle == ACPI_ROOT_OBJECT) + { + *RetType = ACPI_TYPE_ANY; + return (AE_OK); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Convert and validate the handle */ + + Node = AcpiNsValidateHandle (Handle); + if (!Node) + { + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return (AE_BAD_PARAMETER); + } + + *RetType = Node->Type; + + + Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiGetType) + + +/******************************************************************************* + * + * FUNCTION: AcpiGetParent + * + * PARAMETERS: Handle - Handle of object whose parent is desired + * RetHandle - Where the parent handle will be placed + * + * RETURN: Status + * + * DESCRIPTION: Returns a handle to the parent of the object represented by + * Handle. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetParent ( + ACPI_HANDLE Handle, + ACPI_HANDLE *RetHandle) +{ + ACPI_NAMESPACE_NODE *Node; + ACPI_NAMESPACE_NODE *ParentNode; + ACPI_STATUS Status; + + + if (!RetHandle) + { + return (AE_BAD_PARAMETER); + } + + /* Special case for the predefined Root Node (no parent) */ + + if (Handle == ACPI_ROOT_OBJECT) + { + return (AE_NULL_ENTRY); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Convert and validate the handle */ + + Node = AcpiNsValidateHandle (Handle); + if (!Node) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + + /* Get the parent entry */ + + ParentNode = AcpiNsGetParentNode (Node); + *RetHandle = ACPI_CAST_PTR (ACPI_HANDLE, ParentNode); + + /* Return exception if parent is null */ + + if (!ParentNode) + { + Status = AE_NULL_ENTRY; + } + + +UnlockAndExit: + + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiGetParent) + + +/******************************************************************************* + * + * FUNCTION: AcpiGetNextObject + * + * PARAMETERS: Type - Type of object to be searched for + * Parent - Parent object whose children we are getting + * LastChild - Previous child that was found. + * The NEXT child will be returned + * RetHandle - Where handle to the next object is placed + * + * RETURN: Status + * + * DESCRIPTION: Return the next peer object within the namespace. If Handle is + * valid, Scope is ignored. Otherwise, the first object within + * Scope is returned. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetNextObject ( + ACPI_OBJECT_TYPE Type, + ACPI_HANDLE Parent, + ACPI_HANDLE Child, + ACPI_HANDLE *RetHandle) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + ACPI_NAMESPACE_NODE *ParentNode = NULL; + ACPI_NAMESPACE_NODE *ChildNode = NULL; + + + /* Parameter validation */ + + if (Type > ACPI_TYPE_EXTERNAL_MAX) + { + return (AE_BAD_PARAMETER); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* If null handle, use the parent */ + + if (!Child) + { + /* Start search at the beginning of the specified scope */ + + ParentNode = AcpiNsValidateHandle (Parent); + if (!ParentNode) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + } + else + { + /* Non-null handle, ignore the parent */ + /* Convert and validate the handle */ + + ChildNode = AcpiNsValidateHandle (Child); + if (!ChildNode) + { + Status = AE_BAD_PARAMETER; + goto UnlockAndExit; + } + } + + /* Internal function does the real work */ + + Node = AcpiNsGetNextNodeTyped (Type, ParentNode, ChildNode); + if (!Node) + { + Status = AE_NOT_FOUND; + goto UnlockAndExit; + } + + if (RetHandle) + { + *RetHandle = ACPI_CAST_PTR (ACPI_HANDLE, Node); + } + + +UnlockAndExit: + + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiGetNextObject) + diff --git a/reactos/drivers/bus/acpi/acpica/parser/psargs.c b/reactos/drivers/bus/acpi/acpica/parser/psargs.c new file mode 100644 index 00000000000..60d4a835b1b --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/parser/psargs.c @@ -0,0 +1,893 @@ +/****************************************************************************** + * + * Module Name: psargs - Parse AML opcode arguments + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __PSARGS_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acparser.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "acdispat.h" + +#define _COMPONENT ACPI_PARSER + ACPI_MODULE_NAME ("psargs") + +/* Local prototypes */ + +static UINT32 +AcpiPsGetNextPackageLength ( + ACPI_PARSE_STATE *ParserState); + +static ACPI_PARSE_OBJECT * +AcpiPsGetNextField ( + ACPI_PARSE_STATE *ParserState); + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetNextPackageLength + * + * PARAMETERS: ParserState - Current parser state object + * + * RETURN: Decoded package length. On completion, the AML pointer points + * past the length byte or bytes. + * + * DESCRIPTION: Decode and return a package length field. + * Note: Largest package length is 28 bits, from ACPI specification + * + ******************************************************************************/ + +static UINT32 +AcpiPsGetNextPackageLength ( + ACPI_PARSE_STATE *ParserState) +{ + UINT8 *Aml = ParserState->Aml; + UINT32 PackageLength = 0; + UINT32 ByteCount; + UINT8 ByteZeroMask = 0x3F; /* Default [0:5] */ + + + ACPI_FUNCTION_TRACE (PsGetNextPackageLength); + + + /* + * Byte 0 bits [6:7] contain the number of additional bytes + * used to encode the package length, either 0,1,2, or 3 + */ + ByteCount = (Aml[0] >> 6); + ParserState->Aml += ((ACPI_SIZE) ByteCount + 1); + + /* Get bytes 3, 2, 1 as needed */ + + while (ByteCount) + { + /* + * Final bit positions for the package length bytes: + * Byte3->[20:27] + * Byte2->[12:19] + * Byte1->[04:11] + * Byte0->[00:03] + */ + PackageLength |= (Aml[ByteCount] << ((ByteCount << 3) - 4)); + + ByteZeroMask = 0x0F; /* Use bits [0:3] of byte 0 */ + ByteCount--; + } + + /* Byte 0 is a special case, either bits [0:3] or [0:5] are used */ + + PackageLength |= (Aml[0] & ByteZeroMask); + return_UINT32 (PackageLength); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetNextPackageEnd + * + * PARAMETERS: ParserState - Current parser state object + * + * RETURN: Pointer to end-of-package +1 + * + * DESCRIPTION: Get next package length and return a pointer past the end of + * the package. Consumes the package length field + * + ******************************************************************************/ + +UINT8 * +AcpiPsGetNextPackageEnd ( + ACPI_PARSE_STATE *ParserState) +{ + UINT8 *Start = ParserState->Aml; + UINT32 PackageLength; + + + ACPI_FUNCTION_TRACE (PsGetNextPackageEnd); + + + /* Function below updates ParserState->Aml */ + + PackageLength = AcpiPsGetNextPackageLength (ParserState); + + return_PTR (Start + PackageLength); /* end of package */ +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetNextNamestring + * + * PARAMETERS: ParserState - Current parser state object + * + * RETURN: Pointer to the start of the name string (pointer points into + * the AML. + * + * DESCRIPTION: Get next raw namestring within the AML stream. Handles all name + * prefix characters. Set parser state to point past the string. + * (Name is consumed from the AML.) + * + ******************************************************************************/ + +char * +AcpiPsGetNextNamestring ( + ACPI_PARSE_STATE *ParserState) +{ + UINT8 *Start = ParserState->Aml; + UINT8 *End = ParserState->Aml; + + + ACPI_FUNCTION_TRACE (PsGetNextNamestring); + + + /* Point past any namestring prefix characters (backslash or carat) */ + + while (AcpiPsIsPrefixChar (*End)) + { + End++; + } + + /* Decode the path prefix character */ + + switch (*End) + { + case 0: + + /* NullName */ + + if (End == Start) + { + Start = NULL; + } + End++; + break; + + case AML_DUAL_NAME_PREFIX: + + /* Two name segments */ + + End += 1 + (2 * ACPI_NAME_SIZE); + break; + + case AML_MULTI_NAME_PREFIX_OP: + + /* Multiple name segments, 4 chars each, count in next byte */ + + End += 2 + (*(End + 1) * ACPI_NAME_SIZE); + break; + + default: + + /* Single name segment */ + + End += ACPI_NAME_SIZE; + break; + } + + ParserState->Aml = End; + return_PTR ((char *) Start); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetNextNamepath + * + * PARAMETERS: ParserState - Current parser state object + * Arg - Where the namepath will be stored + * ArgCount - If the namepath points to a control method + * the method's argument is returned here. + * PossibleMethodCall - Whether the namepath can possibly be the + * start of a method call + * + * RETURN: Status + * + * DESCRIPTION: Get next name (if method call, return # of required args). + * Names are looked up in the internal namespace to determine + * if the name represents a control method. If a method + * is found, the number of arguments to the method is returned. + * This information is critical for parsing to continue correctly. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiPsGetNextNamepath ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_STATE *ParserState, + ACPI_PARSE_OBJECT *Arg, + BOOLEAN PossibleMethodCall) +{ + ACPI_STATUS Status; + char *Path; + ACPI_PARSE_OBJECT *NameOp; + ACPI_OPERAND_OBJECT *MethodDesc; + ACPI_NAMESPACE_NODE *Node; + UINT8 *Start = ParserState->Aml; + + + ACPI_FUNCTION_TRACE (PsGetNextNamepath); + + + Path = AcpiPsGetNextNamestring (ParserState); + AcpiPsInitOp (Arg, AML_INT_NAMEPATH_OP); + + /* Null path case is allowed, just exit */ + + if (!Path) + { + Arg->Common.Value.Name = Path; + return_ACPI_STATUS (AE_OK); + } + + /* + * Lookup the name in the internal namespace, starting with the current + * scope. We don't want to add anything new to the namespace here, + * however, so we use MODE_EXECUTE. + * Allow searching of the parent tree, but don't open a new scope - + * we just want to lookup the object (must be mode EXECUTE to perform + * the upsearch) + */ + Status = AcpiNsLookup (WalkState->ScopeInfo, Path, + ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, + ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, NULL, &Node); + + /* + * If this name is a control method invocation, we must + * setup the method call + */ + if (ACPI_SUCCESS (Status) && + PossibleMethodCall && + (Node->Type == ACPI_TYPE_METHOD)) + { + if (WalkState->Opcode == AML_UNLOAD_OP) + { + /* + * AcpiPsGetNextNamestring has increased the AML pointer, + * so we need to restore the saved AML pointer for method call. + */ + WalkState->ParserState.Aml = Start; + WalkState->ArgCount = 1; + AcpiPsInitOp (Arg, AML_INT_METHODCALL_OP); + return_ACPI_STATUS (AE_OK); + } + + /* This name is actually a control method invocation */ + + MethodDesc = AcpiNsGetAttachedObject (Node); + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "Control Method - %p Desc %p Path=%p\n", Node, MethodDesc, Path)); + + NameOp = AcpiPsAllocOp (AML_INT_NAMEPATH_OP); + if (!NameOp) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Change Arg into a METHOD CALL and attach name to it */ + + AcpiPsInitOp (Arg, AML_INT_METHODCALL_OP); + NameOp->Common.Value.Name = Path; + + /* Point METHODCALL/NAME to the METHOD Node */ + + NameOp->Common.Node = Node; + AcpiPsAppendArg (Arg, NameOp); + + if (!MethodDesc) + { + ACPI_ERROR ((AE_INFO, + "Control Method %p has no attached object", + Node)); + return_ACPI_STATUS (AE_AML_INTERNAL); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "Control Method - %p Args %X\n", + Node, MethodDesc->Method.ParamCount)); + + /* Get the number of arguments to expect */ + + WalkState->ArgCount = MethodDesc->Method.ParamCount; + return_ACPI_STATUS (AE_OK); + } + + /* + * Special handling if the name was not found during the lookup - + * some NotFound cases are allowed + */ + if (Status == AE_NOT_FOUND) + { + /* 1) NotFound is ok during load pass 1/2 (allow forward references) */ + + if ((WalkState->ParseFlags & ACPI_PARSE_MODE_MASK) != + ACPI_PARSE_EXECUTE) + { + Status = AE_OK; + } + + /* 2) NotFound during a CondRefOf(x) is ok by definition */ + + else if (WalkState->Op->Common.AmlOpcode == AML_COND_REF_OF_OP) + { + Status = AE_OK; + } + + /* + * 3) NotFound while building a Package is ok at this point, we + * may flag as an error later if slack mode is not enabled. + * (Some ASL code depends on allowing this behavior) + */ + else if ((Arg->Common.Parent) && + ((Arg->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) || + (Arg->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP))) + { + Status = AE_OK; + } + } + + /* Final exception check (may have been changed from code above) */ + + if (ACPI_FAILURE (Status)) + { + ACPI_ERROR_NAMESPACE (Path, Status); + + if ((WalkState->ParseFlags & ACPI_PARSE_MODE_MASK) == + ACPI_PARSE_EXECUTE) + { + /* Report a control method execution error */ + + Status = AcpiDsMethodError (Status, WalkState); + } + } + + /* Save the namepath */ + + Arg->Common.Value.Name = Path; + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetNextSimpleArg + * + * PARAMETERS: ParserState - Current parser state object + * ArgType - The argument type (AML_*_ARG) + * Arg - Where the argument is returned + * + * RETURN: None + * + * DESCRIPTION: Get the next simple argument (constant, string, or namestring) + * + ******************************************************************************/ + +void +AcpiPsGetNextSimpleArg ( + ACPI_PARSE_STATE *ParserState, + UINT32 ArgType, + ACPI_PARSE_OBJECT *Arg) +{ + UINT32 Length; + UINT16 Opcode; + UINT8 *Aml = ParserState->Aml; + + + ACPI_FUNCTION_TRACE_U32 (PsGetNextSimpleArg, ArgType); + + + switch (ArgType) + { + case ARGP_BYTEDATA: + + /* Get 1 byte from the AML stream */ + + Opcode = AML_BYTE_OP; + Arg->Common.Value.Integer = (ACPI_INTEGER) *Aml; + Length = 1; + break; + + + case ARGP_WORDDATA: + + /* Get 2 bytes from the AML stream */ + + Opcode = AML_WORD_OP; + ACPI_MOVE_16_TO_64 (&Arg->Common.Value.Integer, Aml); + Length = 2; + break; + + + case ARGP_DWORDDATA: + + /* Get 4 bytes from the AML stream */ + + Opcode = AML_DWORD_OP; + ACPI_MOVE_32_TO_64 (&Arg->Common.Value.Integer, Aml); + Length = 4; + break; + + + case ARGP_QWORDDATA: + + /* Get 8 bytes from the AML stream */ + + Opcode = AML_QWORD_OP; + ACPI_MOVE_64_TO_64 (&Arg->Common.Value.Integer, Aml); + Length = 8; + break; + + + case ARGP_CHARLIST: + + /* Get a pointer to the string, point past the string */ + + Opcode = AML_STRING_OP; + Arg->Common.Value.String = ACPI_CAST_PTR (char, Aml); + + /* Find the null terminator */ + + Length = 0; + while (Aml[Length]) + { + Length++; + } + Length++; + break; + + + case ARGP_NAME: + case ARGP_NAMESTRING: + + AcpiPsInitOp (Arg, AML_INT_NAMEPATH_OP); + Arg->Common.Value.Name = AcpiPsGetNextNamestring (ParserState); + return_VOID; + + + default: + + ACPI_ERROR ((AE_INFO, "Invalid ArgType %X", ArgType)); + return_VOID; + } + + AcpiPsInitOp (Arg, Opcode); + ParserState->Aml += Length; + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetNextField + * + * PARAMETERS: ParserState - Current parser state object + * + * RETURN: A newly allocated FIELD op + * + * DESCRIPTION: Get next field (NamedField, ReservedField, or AccessField) + * + ******************************************************************************/ + +static ACPI_PARSE_OBJECT * +AcpiPsGetNextField ( + ACPI_PARSE_STATE *ParserState) +{ + UINT32 AmlOffset = (UINT32) + ACPI_PTR_DIFF (ParserState->Aml, + ParserState->AmlStart); + ACPI_PARSE_OBJECT *Field; + UINT16 Opcode; + UINT32 Name; + + + ACPI_FUNCTION_TRACE (PsGetNextField); + + + /* Determine field type */ + + switch (ACPI_GET8 (ParserState->Aml)) + { + default: + + Opcode = AML_INT_NAMEDFIELD_OP; + break; + + case 0x00: + + Opcode = AML_INT_RESERVEDFIELD_OP; + ParserState->Aml++; + break; + + case 0x01: + + Opcode = AML_INT_ACCESSFIELD_OP; + ParserState->Aml++; + break; + } + + /* Allocate a new field op */ + + Field = AcpiPsAllocOp (Opcode); + if (!Field) + { + return_PTR (NULL); + } + + Field->Common.AmlOffset = AmlOffset; + + /* Decode the field type */ + + switch (Opcode) + { + case AML_INT_NAMEDFIELD_OP: + + /* Get the 4-character name */ + + ACPI_MOVE_32_TO_32 (&Name, ParserState->Aml); + AcpiPsSetName (Field, Name); + ParserState->Aml += ACPI_NAME_SIZE; + + /* Get the length which is encoded as a package length */ + + Field->Common.Value.Size = AcpiPsGetNextPackageLength (ParserState); + break; + + + case AML_INT_RESERVEDFIELD_OP: + + /* Get the length which is encoded as a package length */ + + Field->Common.Value.Size = AcpiPsGetNextPackageLength (ParserState); + break; + + + case AML_INT_ACCESSFIELD_OP: + + /* + * Get AccessType and AccessAttrib and merge into the field Op + * AccessType is first operand, AccessAttribute is second + */ + Field->Common.Value.Integer = (((UINT32) ACPI_GET8 (ParserState->Aml) << 8)); + ParserState->Aml++; + Field->Common.Value.Integer |= ACPI_GET8 (ParserState->Aml); + ParserState->Aml++; + break; + + default: + + /* Opcode was set in previous switch */ + break; + } + + return_PTR (Field); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetNextArg + * + * PARAMETERS: WalkState - Current state + * ParserState - Current parser state object + * ArgType - The argument type (AML_*_ARG) + * ReturnArg - Where the next arg is returned + * + * RETURN: Status, and an op object containing the next argument. + * + * DESCRIPTION: Get next argument (including complex list arguments that require + * pushing the parser stack) + * + ******************************************************************************/ + +ACPI_STATUS +AcpiPsGetNextArg ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_STATE *ParserState, + UINT32 ArgType, + ACPI_PARSE_OBJECT **ReturnArg) +{ + ACPI_PARSE_OBJECT *Arg = NULL; + ACPI_PARSE_OBJECT *Prev = NULL; + ACPI_PARSE_OBJECT *Field; + UINT32 Subop; + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE_PTR (PsGetNextArg, ParserState); + + + switch (ArgType) + { + case ARGP_BYTEDATA: + case ARGP_WORDDATA: + case ARGP_DWORDDATA: + case ARGP_CHARLIST: + case ARGP_NAME: + case ARGP_NAMESTRING: + + /* Constants, strings, and namestrings are all the same size */ + + Arg = AcpiPsAllocOp (AML_BYTE_OP); + if (!Arg) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + AcpiPsGetNextSimpleArg (ParserState, ArgType, Arg); + break; + + + case ARGP_PKGLENGTH: + + /* Package length, nothing returned */ + + ParserState->PkgEnd = AcpiPsGetNextPackageEnd (ParserState); + break; + + + case ARGP_FIELDLIST: + + if (ParserState->Aml < ParserState->PkgEnd) + { + /* Non-empty list */ + + while (ParserState->Aml < ParserState->PkgEnd) + { + Field = AcpiPsGetNextField (ParserState); + if (!Field) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + if (Prev) + { + Prev->Common.Next = Field; + } + else + { + Arg = Field; + } + Prev = Field; + } + + /* Skip to End of byte data */ + + ParserState->Aml = ParserState->PkgEnd; + } + break; + + + case ARGP_BYTELIST: + + if (ParserState->Aml < ParserState->PkgEnd) + { + /* Non-empty list */ + + Arg = AcpiPsAllocOp (AML_INT_BYTELIST_OP); + if (!Arg) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Fill in bytelist data */ + + Arg->Common.Value.Size = (UINT32) + ACPI_PTR_DIFF (ParserState->PkgEnd, ParserState->Aml); + Arg->Named.Data = ParserState->Aml; + + /* Skip to End of byte data */ + + ParserState->Aml = ParserState->PkgEnd; + } + break; + + + case ARGP_TARGET: + case ARGP_SUPERNAME: + case ARGP_SIMPLENAME: + + Subop = AcpiPsPeekOpcode (ParserState); + if (Subop == 0 || + AcpiPsIsLeadingChar (Subop) || + AcpiPsIsPrefixChar (Subop)) + { + /* NullName or NameString */ + + Arg = AcpiPsAllocOp (AML_INT_NAMEPATH_OP); + if (!Arg) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* To support SuperName arg of Unload */ + + if (WalkState->Opcode == AML_UNLOAD_OP) + { + Status = AcpiPsGetNextNamepath (WalkState, ParserState, Arg, 1); + + /* + * If the SuperName arg of Unload is a method call, + * we have restored the AML pointer, just free this Arg + */ + if (Arg->Common.AmlOpcode == AML_INT_METHODCALL_OP) + { + AcpiPsFreeOp (Arg); + Arg = NULL; + } + } + else + { + Status = AcpiPsGetNextNamepath (WalkState, ParserState, Arg, 0); + } + } + else + { + /* Single complex argument, nothing returned */ + + WalkState->ArgCount = 1; + } + break; + + + case ARGP_DATAOBJ: + case ARGP_TERMARG: + + /* Single complex argument, nothing returned */ + + WalkState->ArgCount = 1; + break; + + + case ARGP_DATAOBJLIST: + case ARGP_TERMLIST: + case ARGP_OBJLIST: + + if (ParserState->Aml < ParserState->PkgEnd) + { + /* Non-empty list of variable arguments, nothing returned */ + + WalkState->ArgCount = ACPI_VAR_ARGS; + } + break; + + + default: + + ACPI_ERROR ((AE_INFO, "Invalid ArgType: %X", ArgType)); + Status = AE_AML_OPERAND_TYPE; + break; + } + + *ReturnArg = Arg; + return_ACPI_STATUS (Status); +} diff --git a/reactos/drivers/bus/acpi/acpica/parser/psloop.c b/reactos/drivers/bus/acpi/acpica/parser/psloop.c new file mode 100644 index 00000000000..4171e0dc6de --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/parser/psloop.c @@ -0,0 +1,1341 @@ +/****************************************************************************** + * + * Module Name: psloop - Main AML parse loop + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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. + * + *****************************************************************************/ + + +/* + * Parse the AML and build an operation tree as most interpreters, (such as + * Perl) do. Parsing is done by hand rather than with a YACC generated parser + * to tightly constrain stack and dynamic memory usage. Parsing is kept + * flexible and the code fairly compact by parsing based on a list of AML + * opcode templates in AmlOpInfo[]. + */ + +#include "acpi.h" +#include "accommon.h" +#include "acparser.h" +#include "acdispat.h" +#include "amlcode.h" + +#define _COMPONENT ACPI_PARSER + ACPI_MODULE_NAME ("psloop") + +static UINT32 AcpiGbl_Depth = 0; + + +/* Local prototypes */ + +static ACPI_STATUS +AcpiPsGetAmlOpcode ( + ACPI_WALK_STATE *WalkState); + +static ACPI_STATUS +AcpiPsBuildNamedOp ( + ACPI_WALK_STATE *WalkState, + UINT8 *AmlOpStart, + ACPI_PARSE_OBJECT *UnnamedOp, + ACPI_PARSE_OBJECT **Op); + +static ACPI_STATUS +AcpiPsCreateOp ( + ACPI_WALK_STATE *WalkState, + UINT8 *AmlOpStart, + ACPI_PARSE_OBJECT **NewOp); + +static ACPI_STATUS +AcpiPsGetArguments ( + ACPI_WALK_STATE *WalkState, + UINT8 *AmlOpStart, + ACPI_PARSE_OBJECT *Op); + +static ACPI_STATUS +AcpiPsCompleteOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT **Op, + ACPI_STATUS Status); + +static ACPI_STATUS +AcpiPsCompleteFinalOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + ACPI_STATUS Status); + +static void +AcpiPsLinkModuleCode ( + ACPI_PARSE_OBJECT *ParentOp, + UINT8 *AmlStart, + UINT32 AmlLength, + ACPI_OWNER_ID OwnerId); + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetAmlOpcode + * + * PARAMETERS: WalkState - Current state + * + * RETURN: Status + * + * DESCRIPTION: Extract the next AML opcode from the input stream. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiPsGetAmlOpcode ( + ACPI_WALK_STATE *WalkState) +{ + + ACPI_FUNCTION_TRACE_PTR (PsGetAmlOpcode, WalkState); + + + WalkState->AmlOffset = (UINT32) ACPI_PTR_DIFF (WalkState->ParserState.Aml, + WalkState->ParserState.AmlStart); + WalkState->Opcode = AcpiPsPeekOpcode (&(WalkState->ParserState)); + + /* + * First cut to determine what we have found: + * 1) A valid AML opcode + * 2) A name string + * 3) An unknown/invalid opcode + */ + WalkState->OpInfo = AcpiPsGetOpcodeInfo (WalkState->Opcode); + + switch (WalkState->OpInfo->Class) + { + case AML_CLASS_ASCII: + case AML_CLASS_PREFIX: + /* + * Starts with a valid prefix or ASCII char, this is a name + * string. Convert the bare name string to a namepath. + */ + WalkState->Opcode = AML_INT_NAMEPATH_OP; + WalkState->ArgTypes = ARGP_NAMESTRING; + break; + + case AML_CLASS_UNKNOWN: + + /* The opcode is unrecognized. Just skip unknown opcodes */ + + ACPI_ERROR ((AE_INFO, + "Found unknown opcode %X at AML address %p offset %X, ignoring", + WalkState->Opcode, WalkState->ParserState.Aml, WalkState->AmlOffset)); + + ACPI_DUMP_BUFFER (WalkState->ParserState.Aml, 128); + + /* Assume one-byte bad opcode */ + + WalkState->ParserState.Aml++; + return_ACPI_STATUS (AE_CTRL_PARSE_CONTINUE); + + default: + + /* Found opcode info, this is a normal opcode */ + + WalkState->ParserState.Aml += AcpiPsGetOpcodeSize (WalkState->Opcode); + WalkState->ArgTypes = WalkState->OpInfo->ParseArgs; + break; + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsBuildNamedOp + * + * PARAMETERS: WalkState - Current state + * AmlOpStart - Begin of named Op in AML + * UnnamedOp - Early Op (not a named Op) + * Op - Returned Op + * + * RETURN: Status + * + * DESCRIPTION: Parse a named Op + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiPsBuildNamedOp ( + ACPI_WALK_STATE *WalkState, + UINT8 *AmlOpStart, + ACPI_PARSE_OBJECT *UnnamedOp, + ACPI_PARSE_OBJECT **Op) +{ + ACPI_STATUS Status = AE_OK; + ACPI_PARSE_OBJECT *Arg = NULL; + + + ACPI_FUNCTION_TRACE_PTR (PsBuildNamedOp, WalkState); + + + UnnamedOp->Common.Value.Arg = NULL; + UnnamedOp->Common.ArgListLength = 0; + UnnamedOp->Common.AmlOpcode = WalkState->Opcode; + + /* + * Get and append arguments until we find the node that contains + * the name (the type ARGP_NAME). + */ + while (GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) && + (GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) != ARGP_NAME)) + { + Status = AcpiPsGetNextArg (WalkState, &(WalkState->ParserState), + GET_CURRENT_ARG_TYPE (WalkState->ArgTypes), &Arg); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + AcpiPsAppendArg (UnnamedOp, Arg); + INCREMENT_ARG_LIST (WalkState->ArgTypes); + } + + /* + * Make sure that we found a NAME and didn't run out of arguments + */ + if (!GET_CURRENT_ARG_TYPE (WalkState->ArgTypes)) + { + return_ACPI_STATUS (AE_AML_NO_OPERAND); + } + + /* We know that this arg is a name, move to next arg */ + + INCREMENT_ARG_LIST (WalkState->ArgTypes); + + /* + * Find the object. This will either insert the object into + * the namespace or simply look it up + */ + WalkState->Op = NULL; + + Status = WalkState->DescendingCallback (WalkState, Op); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, "During name lookup/catalog")); + return_ACPI_STATUS (Status); + } + + if (!*Op) + { + return_ACPI_STATUS (AE_CTRL_PARSE_CONTINUE); + } + + Status = AcpiPsNextParseState (WalkState, *Op, Status); + if (ACPI_FAILURE (Status)) + { + if (Status == AE_CTRL_PENDING) + { + return_ACPI_STATUS (AE_CTRL_PARSE_PENDING); + } + return_ACPI_STATUS (Status); + } + + AcpiPsAppendArg (*Op, UnnamedOp->Common.Value.Arg); + AcpiGbl_Depth++; + + if ((*Op)->Common.AmlOpcode == AML_REGION_OP || + (*Op)->Common.AmlOpcode == AML_DATA_REGION_OP) + { + /* + * Defer final parsing of an OperationRegion body, because we don't + * have enough info in the first pass to parse it correctly (i.e., + * there may be method calls within the TermArg elements of the body.) + * + * However, we must continue parsing because the opregion is not a + * standalone package -- we don't know where the end is at this point. + * + * (Length is unknown until parse of the body complete) + */ + (*Op)->Named.Data = AmlOpStart; + (*Op)->Named.Length = 0; + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsCreateOp + * + * PARAMETERS: WalkState - Current state + * AmlOpStart - Op start in AML + * NewOp - Returned Op + * + * RETURN: Status + * + * DESCRIPTION: Get Op from AML + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiPsCreateOp ( + ACPI_WALK_STATE *WalkState, + UINT8 *AmlOpStart, + ACPI_PARSE_OBJECT **NewOp) +{ + ACPI_STATUS Status = AE_OK; + ACPI_PARSE_OBJECT *Op; + ACPI_PARSE_OBJECT *NamedOp = NULL; + ACPI_PARSE_OBJECT *ParentScope; + UINT8 ArgumentCount; + const ACPI_OPCODE_INFO *OpInfo; + + + ACPI_FUNCTION_TRACE_PTR (PsCreateOp, WalkState); + + + Status = AcpiPsGetAmlOpcode (WalkState); + if (Status == AE_CTRL_PARSE_CONTINUE) + { + return_ACPI_STATUS (AE_CTRL_PARSE_CONTINUE); + } + + /* Create Op structure and append to parent's argument list */ + + WalkState->OpInfo = AcpiPsGetOpcodeInfo (WalkState->Opcode); + Op = AcpiPsAllocOp (WalkState->Opcode); + if (!Op) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + if (WalkState->OpInfo->Flags & AML_NAMED) + { + Status = AcpiPsBuildNamedOp (WalkState, AmlOpStart, Op, &NamedOp); + AcpiPsFreeOp (Op); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + *NewOp = NamedOp; + return_ACPI_STATUS (AE_OK); + } + + /* Not a named opcode, just allocate Op and append to parent */ + + if (WalkState->OpInfo->Flags & AML_CREATE) + { + /* + * Backup to beginning of CreateXXXfield declaration + * BodyLength is unknown until we parse the body + */ + Op->Named.Data = AmlOpStart; + Op->Named.Length = 0; + } + + if (WalkState->Opcode == AML_BANK_FIELD_OP) + { + /* + * Backup to beginning of BankField declaration + * BodyLength is unknown until we parse the body + */ + Op->Named.Data = AmlOpStart; + Op->Named.Length = 0; + } + + ParentScope = AcpiPsGetParentScope (&(WalkState->ParserState)); + AcpiPsAppendArg (ParentScope, Op); + + if (ParentScope) + { + OpInfo = AcpiPsGetOpcodeInfo (ParentScope->Common.AmlOpcode); + if (OpInfo->Flags & AML_HAS_TARGET) + { + ArgumentCount = AcpiPsGetArgumentCount (OpInfo->Type); + if (ParentScope->Common.ArgListLength > ArgumentCount) + { + Op->Common.Flags |= ACPI_PARSEOP_TARGET; + } + } + else if (ParentScope->Common.AmlOpcode == AML_INCREMENT_OP) + { + Op->Common.Flags |= ACPI_PARSEOP_TARGET; + } + } + + if (WalkState->DescendingCallback != NULL) + { + /* + * Find the object. This will either insert the object into + * the namespace or simply look it up + */ + WalkState->Op = *NewOp = Op; + + Status = WalkState->DescendingCallback (WalkState, &Op); + Status = AcpiPsNextParseState (WalkState, Op, Status); + if (Status == AE_CTRL_PENDING) + { + Status = AE_CTRL_PARSE_PENDING; + } + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetArguments + * + * PARAMETERS: WalkState - Current state + * AmlOpStart - Op start in AML + * Op - Current Op + * + * RETURN: Status + * + * DESCRIPTION: Get arguments for passed Op. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiPsGetArguments ( + ACPI_WALK_STATE *WalkState, + UINT8 *AmlOpStart, + ACPI_PARSE_OBJECT *Op) +{ + ACPI_STATUS Status = AE_OK; + ACPI_PARSE_OBJECT *Arg = NULL; + const ACPI_OPCODE_INFO *OpInfo; + + + ACPI_FUNCTION_TRACE_PTR (PsGetArguments, WalkState); + + + switch (Op->Common.AmlOpcode) + { + case AML_BYTE_OP: /* AML_BYTEDATA_ARG */ + case AML_WORD_OP: /* AML_WORDDATA_ARG */ + case AML_DWORD_OP: /* AML_DWORDATA_ARG */ + case AML_QWORD_OP: /* AML_QWORDATA_ARG */ + case AML_STRING_OP: /* AML_ASCIICHARLIST_ARG */ + + /* Fill in constant or string argument directly */ + + AcpiPsGetNextSimpleArg (&(WalkState->ParserState), + GET_CURRENT_ARG_TYPE (WalkState->ArgTypes), Op); + break; + + case AML_INT_NAMEPATH_OP: /* AML_NAMESTRING_ARG */ + + Status = AcpiPsGetNextNamepath (WalkState, &(WalkState->ParserState), Op, 1); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + WalkState->ArgTypes = 0; + break; + + default: + /* + * Op is not a constant or string, append each argument to the Op + */ + while (GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) && !WalkState->ArgCount) + { + WalkState->AmlOffset = (UINT32) ACPI_PTR_DIFF (WalkState->ParserState.Aml, + WalkState->ParserState.AmlStart); + + Status = AcpiPsGetNextArg (WalkState, &(WalkState->ParserState), + GET_CURRENT_ARG_TYPE (WalkState->ArgTypes), &Arg); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (Arg) + { + Arg->Common.AmlOffset = WalkState->AmlOffset; + AcpiPsAppendArg (Op, Arg); + } + + INCREMENT_ARG_LIST (WalkState->ArgTypes); + } + + + /* + * Handle executable code at "module-level". This refers to + * executable opcodes that appear outside of any control method. + */ + if ((WalkState->PassNumber <= ACPI_IMODE_LOAD_PASS2) && + ((WalkState->ParseFlags & ACPI_PARSE_DISASSEMBLE) == 0)) + { + /* + * We want to skip If/Else/While constructs during Pass1 because we + * want to actually conditionally execute the code during Pass2. + * + * Except for disassembly, where we always want to walk the + * If/Else/While packages + */ + switch (Op->Common.AmlOpcode) + { + case AML_IF_OP: + case AML_ELSE_OP: + case AML_WHILE_OP: + + /* + * Currently supported module-level opcodes are: + * IF/ELSE/WHILE. These appear to be the most common, + * and easiest to support since they open an AML + * package. + */ + if (WalkState->PassNumber == ACPI_IMODE_LOAD_PASS1) + { + AcpiPsLinkModuleCode (Op->Common.Parent, AmlOpStart, + (UINT32) (WalkState->ParserState.PkgEnd - AmlOpStart), + WalkState->OwnerId); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "Pass1: Skipping an If/Else/While body\n")); + + /* Skip body of if/else/while in pass 1 */ + + WalkState->ParserState.Aml = WalkState->ParserState.PkgEnd; + WalkState->ArgCount = 0; + break; + + default: + /* + * Check for an unsupported executable opcode at module + * level. We must be in PASS1, the parent must be a SCOPE, + * The opcode class must be EXECUTE, and the opcode must + * not be an argument to another opcode. + */ + if ((WalkState->PassNumber == ACPI_IMODE_LOAD_PASS1) && + (Op->Common.Parent->Common.AmlOpcode == AML_SCOPE_OP)) + { + OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); + if ((OpInfo->Class == AML_CLASS_EXECUTE) && + (!Arg)) + { + ACPI_WARNING ((AE_INFO, + "Detected an unsupported executable opcode " + "at module-level: [0x%.4X] at table offset 0x%.4X", + Op->Common.AmlOpcode, + (UINT32) (ACPI_PTR_DIFF (AmlOpStart, + WalkState->ParserState.AmlStart) + + sizeof (ACPI_TABLE_HEADER)))); + } + } + break; + } + } + + /* Special processing for certain opcodes */ + + switch (Op->Common.AmlOpcode) + { + case AML_METHOD_OP: + /* + * Skip parsing of control method because we don't have enough + * info in the first pass to parse it correctly. + * + * Save the length and address of the body + */ + Op->Named.Data = WalkState->ParserState.Aml; + Op->Named.Length = (UINT32) + (WalkState->ParserState.PkgEnd - WalkState->ParserState.Aml); + + /* Skip body of method */ + + WalkState->ParserState.Aml = WalkState->ParserState.PkgEnd; + WalkState->ArgCount = 0; + break; + + case AML_BUFFER_OP: + case AML_PACKAGE_OP: + case AML_VAR_PACKAGE_OP: + + if ((Op->Common.Parent) && + (Op->Common.Parent->Common.AmlOpcode == AML_NAME_OP) && + (WalkState->PassNumber <= ACPI_IMODE_LOAD_PASS2)) + { + /* + * Skip parsing of Buffers and Packages because we don't have + * enough info in the first pass to parse them correctly. + */ + Op->Named.Data = AmlOpStart; + Op->Named.Length = (UINT32) + (WalkState->ParserState.PkgEnd - AmlOpStart); + + /* Skip body */ + + WalkState->ParserState.Aml = WalkState->ParserState.PkgEnd; + WalkState->ArgCount = 0; + } + break; + + case AML_WHILE_OP: + + if (WalkState->ControlState) + { + WalkState->ControlState->Control.PackageEnd = + WalkState->ParserState.PkgEnd; + } + break; + + default: + + /* No action for all other opcodes */ + break; + } + + break; + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsLinkModuleCode + * + * PARAMETERS: ParentOp - Parent parser op + * AmlStart - Pointer to the AML + * AmlLength - Length of executable AML + * OwnerId - OwnerId of module level code + * + * RETURN: None. + * + * DESCRIPTION: Wrap the module-level code with a method object and link the + * object to the global list. Note, the mutex field of the method + * object is used to link multiple module-level code objects. + * + ******************************************************************************/ + +static void +AcpiPsLinkModuleCode ( + ACPI_PARSE_OBJECT *ParentOp, + UINT8 *AmlStart, + UINT32 AmlLength, + ACPI_OWNER_ID OwnerId) +{ + ACPI_OPERAND_OBJECT *Prev; + ACPI_OPERAND_OBJECT *Next; + ACPI_OPERAND_OBJECT *MethodObj; + ACPI_NAMESPACE_NODE *ParentNode; + + + /* Get the tail of the list */ + + Prev = Next = AcpiGbl_ModuleCodeList; + while (Next) + { + Prev = Next; + Next = Next->Method.Mutex; + } + + /* + * Insert the module level code into the list. Merge it if it is + * adjacent to the previous element. + */ + if (!Prev || + ((Prev->Method.AmlStart + Prev->Method.AmlLength) != AmlStart)) + { + /* Create, initialize, and link a new temporary method object */ + + MethodObj = AcpiUtCreateInternalObject (ACPI_TYPE_METHOD); + if (!MethodObj) + { + return; + } + + if (ParentOp->Common.Node) + { + ParentNode = ParentOp->Common.Node; + } + else + { + ParentNode = AcpiGbl_RootNode; + } + + MethodObj->Method.AmlStart = AmlStart; + MethodObj->Method.AmlLength = AmlLength; + MethodObj->Method.OwnerId = OwnerId; + MethodObj->Method.Flags |= AOPOBJ_MODULE_LEVEL; + + /* + * Save the parent node in NextObject. This is cheating, but we + * don't want to expand the method object. + */ + MethodObj->Method.NextObject = + ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, ParentNode); + + if (!Prev) + { + AcpiGbl_ModuleCodeList = MethodObj; + } + else + { + Prev->Method.Mutex = MethodObj; + } + } + else + { + Prev->Method.AmlLength += AmlLength; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsCompleteOp + * + * PARAMETERS: WalkState - Current state + * Op - Returned Op + * Status - Parse status before complete Op + * + * RETURN: Status + * + * DESCRIPTION: Complete Op + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiPsCompleteOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT **Op, + ACPI_STATUS Status) +{ + ACPI_STATUS Status2; + + + ACPI_FUNCTION_TRACE_PTR (PsCompleteOp, WalkState); + + + /* + * Finished one argument of the containing scope + */ + WalkState->ParserState.Scope->ParseScope.ArgCount--; + + /* Close this Op (will result in parse subtree deletion) */ + + Status2 = AcpiPsCompleteThisOp (WalkState, *Op); + if (ACPI_FAILURE (Status2)) + { + return_ACPI_STATUS (Status2); + } + + *Op = NULL; + + switch (Status) + { + case AE_OK: + break; + + + case AE_CTRL_TRANSFER: + + /* We are about to transfer to a called method */ + + WalkState->PrevOp = NULL; + WalkState->PrevArgTypes = WalkState->ArgTypes; + return_ACPI_STATUS (Status); + + + case AE_CTRL_END: + + AcpiPsPopScope (&(WalkState->ParserState), Op, + &WalkState->ArgTypes, &WalkState->ArgCount); + + if (*Op) + { + WalkState->Op = *Op; + WalkState->OpInfo = AcpiPsGetOpcodeInfo ((*Op)->Common.AmlOpcode); + WalkState->Opcode = (*Op)->Common.AmlOpcode; + + Status = WalkState->AscendingCallback (WalkState); + Status = AcpiPsNextParseState (WalkState, *Op, Status); + + Status2 = AcpiPsCompleteThisOp (WalkState, *Op); + if (ACPI_FAILURE (Status2)) + { + return_ACPI_STATUS (Status2); + } + } + + Status = AE_OK; + break; + + + case AE_CTRL_BREAK: + case AE_CTRL_CONTINUE: + + /* Pop off scopes until we find the While */ + + while (!(*Op) || ((*Op)->Common.AmlOpcode != AML_WHILE_OP)) + { + AcpiPsPopScope (&(WalkState->ParserState), Op, + &WalkState->ArgTypes, &WalkState->ArgCount); + } + + /* Close this iteration of the While loop */ + + WalkState->Op = *Op; + WalkState->OpInfo = AcpiPsGetOpcodeInfo ((*Op)->Common.AmlOpcode); + WalkState->Opcode = (*Op)->Common.AmlOpcode; + + Status = WalkState->AscendingCallback (WalkState); + Status = AcpiPsNextParseState (WalkState, *Op, Status); + + Status2 = AcpiPsCompleteThisOp (WalkState, *Op); + if (ACPI_FAILURE (Status2)) + { + return_ACPI_STATUS (Status2); + } + + Status = AE_OK; + break; + + + case AE_CTRL_TERMINATE: + + /* Clean up */ + do + { + if (*Op) + { + Status2 = AcpiPsCompleteThisOp (WalkState, *Op); + if (ACPI_FAILURE (Status2)) + { + return_ACPI_STATUS (Status2); + } + + AcpiUtDeleteGenericState ( + AcpiUtPopGenericState (&WalkState->ControlState)); + } + + AcpiPsPopScope (&(WalkState->ParserState), Op, + &WalkState->ArgTypes, &WalkState->ArgCount); + + } while (*Op); + + return_ACPI_STATUS (AE_OK); + + + default: /* All other non-AE_OK status */ + + do + { + if (*Op) + { + Status2 = AcpiPsCompleteThisOp (WalkState, *Op); + if (ACPI_FAILURE (Status2)) + { + return_ACPI_STATUS (Status2); + } + } + + AcpiPsPopScope (&(WalkState->ParserState), Op, + &WalkState->ArgTypes, &WalkState->ArgCount); + + } while (*Op); + + +#if 0 + /* + * TBD: Cleanup parse ops on error + */ + if (*Op == NULL) + { + AcpiPsPopScope (ParserState, Op, + &WalkState->ArgTypes, &WalkState->ArgCount); + } +#endif + WalkState->PrevOp = NULL; + WalkState->PrevArgTypes = WalkState->ArgTypes; + return_ACPI_STATUS (Status); + } + + /* This scope complete? */ + + if (AcpiPsHasCompletedScope (&(WalkState->ParserState))) + { + AcpiPsPopScope (&(WalkState->ParserState), Op, + &WalkState->ArgTypes, &WalkState->ArgCount); + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", *Op)); + } + else + { + *Op = NULL; + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsCompleteFinalOp + * + * PARAMETERS: WalkState - Current state + * Op - Current Op + * Status - Current parse status before complete last + * Op + * + * RETURN: Status + * + * DESCRIPTION: Complete last Op. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiPsCompleteFinalOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + ACPI_STATUS Status) +{ + ACPI_STATUS Status2; + + + ACPI_FUNCTION_TRACE_PTR (PsCompleteFinalOp, WalkState); + + + /* + * Complete the last Op (if not completed), and clear the scope stack. + * It is easily possible to end an AML "package" with an unbounded number + * of open scopes (such as when several ASL blocks are closed with + * sequential closing braces). We want to terminate each one cleanly. + */ + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "AML package complete at Op %p\n", Op)); + do + { + if (Op) + { + if (WalkState->AscendingCallback != NULL) + { + WalkState->Op = Op; + WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); + WalkState->Opcode = Op->Common.AmlOpcode; + + Status = WalkState->AscendingCallback (WalkState); + Status = AcpiPsNextParseState (WalkState, Op, Status); + if (Status == AE_CTRL_PENDING) + { + Status = AcpiPsCompleteOp (WalkState, &Op, AE_OK); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + if (Status == AE_CTRL_TERMINATE) + { + Status = AE_OK; + + /* Clean up */ + do + { + if (Op) + { + Status2 = AcpiPsCompleteThisOp (WalkState, Op); + if (ACPI_FAILURE (Status2)) + { + return_ACPI_STATUS (Status2); + } + } + + AcpiPsPopScope (&(WalkState->ParserState), &Op, + &WalkState->ArgTypes, &WalkState->ArgCount); + + } while (Op); + + return_ACPI_STATUS (Status); + } + + else if (ACPI_FAILURE (Status)) + { + /* First error is most important */ + + (void) AcpiPsCompleteThisOp (WalkState, Op); + return_ACPI_STATUS (Status); + } + } + + Status2 = AcpiPsCompleteThisOp (WalkState, Op); + if (ACPI_FAILURE (Status2)) + { + return_ACPI_STATUS (Status2); + } + } + + AcpiPsPopScope (&(WalkState->ParserState), &Op, &WalkState->ArgTypes, + &WalkState->ArgCount); + + } while (Op); + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsParseLoop + * + * PARAMETERS: WalkState - Current state + * + * RETURN: Status + * + * DESCRIPTION: Parse AML (pointed to by the current parser state) and return + * a tree of ops. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiPsParseLoop ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + ACPI_PARSE_OBJECT *Op = NULL; /* current op */ + ACPI_PARSE_STATE *ParserState; + UINT8 *AmlOpStart = NULL; + + + ACPI_FUNCTION_TRACE_PTR (PsParseLoop, WalkState); + + + if (WalkState->DescendingCallback == NULL) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + ParserState = &WalkState->ParserState; + WalkState->ArgTypes = 0; + +#if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY)) + + if (WalkState->WalkType & ACPI_WALK_METHOD_RESTART) + { + /* We are restarting a preempted control method */ + + if (AcpiPsHasCompletedScope (ParserState)) + { + /* + * We must check if a predicate to an IF or WHILE statement + * was just completed + */ + if ((ParserState->Scope->ParseScope.Op) && + ((ParserState->Scope->ParseScope.Op->Common.AmlOpcode == AML_IF_OP) || + (ParserState->Scope->ParseScope.Op->Common.AmlOpcode == AML_WHILE_OP)) && + (WalkState->ControlState) && + (WalkState->ControlState->Common.State == + ACPI_CONTROL_PREDICATE_EXECUTING)) + { + /* + * A predicate was just completed, get the value of the + * predicate and branch based on that value + */ + WalkState->Op = NULL; + Status = AcpiDsGetPredicateValue (WalkState, ACPI_TO_POINTER (TRUE)); + if (ACPI_FAILURE (Status) && + ((Status & AE_CODE_MASK) != AE_CODE_CONTROL)) + { + if (Status == AE_AML_NO_RETURN_VALUE) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Invoked method did not return a value")); + + } + + ACPI_EXCEPTION ((AE_INFO, Status, "GetPredicate Failed")); + return_ACPI_STATUS (Status); + } + + Status = AcpiPsNextParseState (WalkState, Op, Status); + } + + AcpiPsPopScope (ParserState, &Op, + &WalkState->ArgTypes, &WalkState->ArgCount); + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Popped scope, Op=%p\n", Op)); + } + else if (WalkState->PrevOp) + { + /* We were in the middle of an op */ + + Op = WalkState->PrevOp; + WalkState->ArgTypes = WalkState->PrevArgTypes; + } + } +#endif + + /* Iterative parsing loop, while there is more AML to process: */ + + while ((ParserState->Aml < ParserState->AmlEnd) || (Op)) + { + AmlOpStart = ParserState->Aml; + if (!Op) + { + Status = AcpiPsCreateOp (WalkState, AmlOpStart, &Op); + if (ACPI_FAILURE (Status)) + { + if (Status == AE_CTRL_PARSE_CONTINUE) + { + continue; + } + + if (Status == AE_CTRL_PARSE_PENDING) + { + Status = AE_OK; + } + + Status = AcpiPsCompleteOp (WalkState, &Op, Status); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + continue; + } + + Op->Common.AmlOffset = WalkState->AmlOffset; + + if (WalkState->OpInfo) + { + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "Opcode %4.4X [%s] Op %p Aml %p AmlOffset %5.5X\n", + (UINT32) Op->Common.AmlOpcode, WalkState->OpInfo->Name, + Op, ParserState->Aml, Op->Common.AmlOffset)); + } + } + + + /* + * Start ArgCount at zero because we don't know if there are + * any args yet + */ + WalkState->ArgCount = 0; + + /* Are there any arguments that must be processed? */ + + if (WalkState->ArgTypes) + { + /* Get arguments */ + + Status = AcpiPsGetArguments (WalkState, AmlOpStart, Op); + if (ACPI_FAILURE (Status)) + { + Status = AcpiPsCompleteOp (WalkState, &Op, Status); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + continue; + } + } + + /* Check for arguments that need to be processed */ + + if (WalkState->ArgCount) + { + /* + * There are arguments (complex ones), push Op and + * prepare for argument + */ + Status = AcpiPsPushScope (ParserState, Op, + WalkState->ArgTypes, WalkState->ArgCount); + if (ACPI_FAILURE (Status)) + { + Status = AcpiPsCompleteOp (WalkState, &Op, Status); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + continue; + } + + Op = NULL; + continue; + } + + /* + * All arguments have been processed -- Op is complete, + * prepare for next + */ + WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); + if (WalkState->OpInfo->Flags & AML_NAMED) + { + if (AcpiGbl_Depth) + { + AcpiGbl_Depth--; + } + + if (Op->Common.AmlOpcode == AML_REGION_OP || + Op->Common.AmlOpcode == AML_DATA_REGION_OP) + { + /* + * Skip parsing of control method or opregion body, + * because we don't have enough info in the first pass + * to parse them correctly. + * + * Completed parsing an OpRegion declaration, we now + * know the length. + */ + Op->Named.Length = (UINT32) (ParserState->Aml - Op->Named.Data); + } + } + + if (WalkState->OpInfo->Flags & AML_CREATE) + { + /* + * Backup to beginning of CreateXXXfield declaration (1 for + * Opcode) + * + * BodyLength is unknown until we parse the body + */ + Op->Named.Length = (UINT32) (ParserState->Aml - Op->Named.Data); + } + + if (Op->Common.AmlOpcode == AML_BANK_FIELD_OP) + { + /* + * Backup to beginning of BankField declaration + * + * BodyLength is unknown until we parse the body + */ + Op->Named.Length = (UINT32) (ParserState->Aml - Op->Named.Data); + } + + /* This op complete, notify the dispatcher */ + + if (WalkState->AscendingCallback != NULL) + { + WalkState->Op = Op; + WalkState->Opcode = Op->Common.AmlOpcode; + + Status = WalkState->AscendingCallback (WalkState); + Status = AcpiPsNextParseState (WalkState, Op, Status); + if (Status == AE_CTRL_PENDING) + { + Status = AE_OK; + } + } + + Status = AcpiPsCompleteOp (WalkState, &Op, Status); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + } /* while ParserState->Aml */ + + Status = AcpiPsCompleteFinalOp (WalkState, Op, Status); + return_ACPI_STATUS (Status); +} + diff --git a/reactos/drivers/bus/acpi/acpica/parser/psopcode.c b/reactos/drivers/bus/acpi/acpica/parser/psopcode.c new file mode 100644 index 00000000000..d107c523707 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/parser/psopcode.c @@ -0,0 +1,589 @@ +/****************************************************************************** + * + * Module Name: psopcode - Parser/Interpreter opcode information table + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 "acpi.h" +#include "accommon.h" +#include "acparser.h" +#include "acopcode.h" +#include "amlcode.h" + + +#define _COMPONENT ACPI_PARSER + ACPI_MODULE_NAME ("psopcode") + + +static const UINT8 AcpiGbl_ArgumentCount[] = {0,1,1,1,1,2,2,2,2,3,3,6}; + + +/******************************************************************************* + * + * NAME: AcpiGbl_AmlOpInfo + * + * DESCRIPTION: Opcode table. Each entry contains + * The name is a simple ascii string, the operand specifier is an + * ascii string with one letter per operand. The letter specifies + * the operand type. + * + ******************************************************************************/ + +/* + * Summary of opcode types/flags + * + + Opcodes that have associated namespace objects (AML_NSOBJECT flag) + + AML_SCOPE_OP + AML_DEVICE_OP + AML_THERMAL_ZONE_OP + AML_METHOD_OP + AML_POWER_RES_OP + AML_PROCESSOR_OP + AML_FIELD_OP + AML_INDEX_FIELD_OP + AML_BANK_FIELD_OP + AML_NAME_OP + AML_ALIAS_OP + AML_MUTEX_OP + AML_EVENT_OP + AML_REGION_OP + AML_CREATE_FIELD_OP + AML_CREATE_BIT_FIELD_OP + AML_CREATE_BYTE_FIELD_OP + AML_CREATE_WORD_FIELD_OP + AML_CREATE_DWORD_FIELD_OP + AML_CREATE_QWORD_FIELD_OP + AML_INT_NAMEDFIELD_OP + AML_INT_METHODCALL_OP + AML_INT_NAMEPATH_OP + + Opcodes that are "namespace" opcodes (AML_NSOPCODE flag) + + AML_SCOPE_OP + AML_DEVICE_OP + AML_THERMAL_ZONE_OP + AML_METHOD_OP + AML_POWER_RES_OP + AML_PROCESSOR_OP + AML_FIELD_OP + AML_INDEX_FIELD_OP + AML_BANK_FIELD_OP + AML_NAME_OP + AML_ALIAS_OP + AML_MUTEX_OP + AML_EVENT_OP + AML_REGION_OP + AML_INT_NAMEDFIELD_OP + + Opcodes that have an associated namespace node (AML_NSNODE flag) + + AML_SCOPE_OP + AML_DEVICE_OP + AML_THERMAL_ZONE_OP + AML_METHOD_OP + AML_POWER_RES_OP + AML_PROCESSOR_OP + AML_NAME_OP + AML_ALIAS_OP + AML_MUTEX_OP + AML_EVENT_OP + AML_REGION_OP + AML_CREATE_FIELD_OP + AML_CREATE_BIT_FIELD_OP + AML_CREATE_BYTE_FIELD_OP + AML_CREATE_WORD_FIELD_OP + AML_CREATE_DWORD_FIELD_OP + AML_CREATE_QWORD_FIELD_OP + AML_INT_NAMEDFIELD_OP + AML_INT_METHODCALL_OP + AML_INT_NAMEPATH_OP + + Opcodes that define named ACPI objects (AML_NAMED flag) + + AML_SCOPE_OP + AML_DEVICE_OP + AML_THERMAL_ZONE_OP + AML_METHOD_OP + AML_POWER_RES_OP + AML_PROCESSOR_OP + AML_NAME_OP + AML_ALIAS_OP + AML_MUTEX_OP + AML_EVENT_OP + AML_REGION_OP + AML_INT_NAMEDFIELD_OP + + Opcodes that contain executable AML as part of the definition that + must be deferred until needed + + AML_METHOD_OP + AML_VAR_PACKAGE_OP + AML_CREATE_FIELD_OP + AML_CREATE_BIT_FIELD_OP + AML_CREATE_BYTE_FIELD_OP + AML_CREATE_WORD_FIELD_OP + AML_CREATE_DWORD_FIELD_OP + AML_CREATE_QWORD_FIELD_OP + AML_REGION_OP + AML_BUFFER_OP + + Field opcodes + + AML_CREATE_FIELD_OP + AML_FIELD_OP + AML_INDEX_FIELD_OP + AML_BANK_FIELD_OP + + Field "Create" opcodes + + AML_CREATE_FIELD_OP + AML_CREATE_BIT_FIELD_OP + AML_CREATE_BYTE_FIELD_OP + AML_CREATE_WORD_FIELD_OP + AML_CREATE_DWORD_FIELD_OP + AML_CREATE_QWORD_FIELD_OP + + ******************************************************************************/ + + +/* + * Master Opcode information table. A summary of everything we know about each + * opcode, all in one place. + */ +const ACPI_OPCODE_INFO AcpiGbl_AmlOpInfo[AML_NUM_OPCODES] = +{ +/*! [Begin] no source code translation */ +/* Index Name Parser Args Interpreter Args ObjectType Class Type Flags */ + +/* 00 */ ACPI_OP ("Zero", ARGP_ZERO_OP, ARGI_ZERO_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, AML_CONSTANT), +/* 01 */ ACPI_OP ("One", ARGP_ONE_OP, ARGI_ONE_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, AML_CONSTANT), +/* 02 */ ACPI_OP ("Alias", ARGP_ALIAS_OP, ARGI_ALIAS_OP, ACPI_TYPE_LOCAL_ALIAS, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), +/* 03 */ ACPI_OP ("Name", ARGP_NAME_OP, ARGI_NAME_OP, ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_COMPLEX, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), +/* 04 */ ACPI_OP ("ByteConst", ARGP_BYTE_OP, ARGI_BYTE_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT), +/* 05 */ ACPI_OP ("WordConst", ARGP_WORD_OP, ARGI_WORD_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT), +/* 06 */ ACPI_OP ("DwordConst", ARGP_DWORD_OP, ARGI_DWORD_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT), +/* 07 */ ACPI_OP ("String", ARGP_STRING_OP, ARGI_STRING_OP, ACPI_TYPE_STRING, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT), +/* 08 */ ACPI_OP ("Scope", ARGP_SCOPE_OP, ARGI_SCOPE_OP, ACPI_TYPE_LOCAL_SCOPE, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_NO_OBJ, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), +/* 09 */ ACPI_OP ("Buffer", ARGP_BUFFER_OP, ARGI_BUFFER_OP, ACPI_TYPE_BUFFER, AML_CLASS_CREATE, AML_TYPE_CREATE_OBJECT, AML_HAS_ARGS | AML_DEFER | AML_CONSTANT), +/* 0A */ ACPI_OP ("Package", ARGP_PACKAGE_OP, ARGI_PACKAGE_OP, ACPI_TYPE_PACKAGE, AML_CLASS_CREATE, AML_TYPE_CREATE_OBJECT, AML_HAS_ARGS | AML_DEFER | AML_CONSTANT), +/* 0B */ ACPI_OP ("Method", ARGP_METHOD_OP, ARGI_METHOD_OP, ACPI_TYPE_METHOD, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_COMPLEX, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED | AML_DEFER), +/* 0C */ ACPI_OP ("Local0", ARGP_LOCAL0, ARGI_LOCAL0, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0), +/* 0D */ ACPI_OP ("Local1", ARGP_LOCAL1, ARGI_LOCAL1, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0), +/* 0E */ ACPI_OP ("Local2", ARGP_LOCAL2, ARGI_LOCAL2, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0), +/* 0F */ ACPI_OP ("Local3", ARGP_LOCAL3, ARGI_LOCAL3, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0), +/* 10 */ ACPI_OP ("Local4", ARGP_LOCAL4, ARGI_LOCAL4, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0), +/* 11 */ ACPI_OP ("Local5", ARGP_LOCAL5, ARGI_LOCAL5, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0), +/* 12 */ ACPI_OP ("Local6", ARGP_LOCAL6, ARGI_LOCAL6, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0), +/* 13 */ ACPI_OP ("Local7", ARGP_LOCAL7, ARGI_LOCAL7, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LOCAL_VARIABLE, 0), +/* 14 */ ACPI_OP ("Arg0", ARGP_ARG0, ARGI_ARG0, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0), +/* 15 */ ACPI_OP ("Arg1", ARGP_ARG1, ARGI_ARG1, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0), +/* 16 */ ACPI_OP ("Arg2", ARGP_ARG2, ARGI_ARG2, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0), +/* 17 */ ACPI_OP ("Arg3", ARGP_ARG3, ARGI_ARG3, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0), +/* 18 */ ACPI_OP ("Arg4", ARGP_ARG4, ARGI_ARG4, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0), +/* 19 */ ACPI_OP ("Arg5", ARGP_ARG5, ARGI_ARG5, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0), +/* 1A */ ACPI_OP ("Arg6", ARGP_ARG6, ARGI_ARG6, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_METHOD_ARGUMENT, 0), +/* 1B */ ACPI_OP ("Store", ARGP_STORE_OP, ARGI_STORE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R), +/* 1C */ ACPI_OP ("RefOf", ARGP_REF_OF_OP, ARGI_REF_OF_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R), +/* 1D */ ACPI_OP ("Add", ARGP_ADD_OP, ARGI_ADD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), +/* 1E */ ACPI_OP ("Concatenate", ARGP_CONCAT_OP, ARGI_CONCAT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT), +/* 1F */ ACPI_OP ("Subtract", ARGP_SUBTRACT_OP, ARGI_SUBTRACT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), +/* 20 */ ACPI_OP ("Increment", ARGP_INCREMENT_OP, ARGI_INCREMENT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT), +/* 21 */ ACPI_OP ("Decrement", ARGP_DECREMENT_OP, ARGI_DECREMENT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT), +/* 22 */ ACPI_OP ("Multiply", ARGP_MULTIPLY_OP, ARGI_MULTIPLY_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), +/* 23 */ ACPI_OP ("Divide", ARGP_DIVIDE_OP, ARGI_DIVIDE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_2T_1R, AML_FLAGS_EXEC_2A_2T_1R | AML_CONSTANT), +/* 24 */ ACPI_OP ("ShiftLeft", ARGP_SHIFT_LEFT_OP, ARGI_SHIFT_LEFT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), +/* 25 */ ACPI_OP ("ShiftRight", ARGP_SHIFT_RIGHT_OP, ARGI_SHIFT_RIGHT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), +/* 26 */ ACPI_OP ("And", ARGP_BIT_AND_OP, ARGI_BIT_AND_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), +/* 27 */ ACPI_OP ("NAnd", ARGP_BIT_NAND_OP, ARGI_BIT_NAND_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), +/* 28 */ ACPI_OP ("Or", ARGP_BIT_OR_OP, ARGI_BIT_OR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), +/* 29 */ ACPI_OP ("NOr", ARGP_BIT_NOR_OP, ARGI_BIT_NOR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), +/* 2A */ ACPI_OP ("XOr", ARGP_BIT_XOR_OP, ARGI_BIT_XOR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_MATH | AML_CONSTANT), +/* 2B */ ACPI_OP ("Not", ARGP_BIT_NOT_OP, ARGI_BIT_NOT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), +/* 2C */ ACPI_OP ("FindSetLeftBit", ARGP_FIND_SET_LEFT_BIT_OP, ARGI_FIND_SET_LEFT_BIT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), +/* 2D */ ACPI_OP ("FindSetRightBit", ARGP_FIND_SET_RIGHT_BIT_OP,ARGI_FIND_SET_RIGHT_BIT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), +/* 2E */ ACPI_OP ("DerefOf", ARGP_DEREF_OF_OP, ARGI_DEREF_OF_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R), +/* 2F */ ACPI_OP ("Notify", ARGP_NOTIFY_OP, ARGI_NOTIFY_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_0R, AML_FLAGS_EXEC_2A_0T_0R), +/* 30 */ ACPI_OP ("SizeOf", ARGP_SIZE_OF_OP, ARGI_SIZE_OF_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_NO_OPERAND_RESOLVE), +/* 31 */ ACPI_OP ("Index", ARGP_INDEX_OP, ARGI_INDEX_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R), +/* 32 */ ACPI_OP ("Match", ARGP_MATCH_OP, ARGI_MATCH_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_6A_0T_1R, AML_FLAGS_EXEC_6A_0T_1R | AML_CONSTANT), +/* 33 */ ACPI_OP ("CreateDWordField", ARGP_CREATE_DWORD_FIELD_OP,ARGI_CREATE_DWORD_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE), +/* 34 */ ACPI_OP ("CreateWordField", ARGP_CREATE_WORD_FIELD_OP, ARGI_CREATE_WORD_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE), +/* 35 */ ACPI_OP ("CreateByteField", ARGP_CREATE_BYTE_FIELD_OP, ARGI_CREATE_BYTE_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE), +/* 36 */ ACPI_OP ("CreateBitField", ARGP_CREATE_BIT_FIELD_OP, ARGI_CREATE_BIT_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE), +/* 37 */ ACPI_OP ("ObjectType", ARGP_TYPE_OP, ARGI_TYPE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_NO_OPERAND_RESOLVE), +/* 38 */ ACPI_OP ("LAnd", ARGP_LAND_OP, ARGI_LAND_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL_NUMERIC | AML_CONSTANT), +/* 39 */ ACPI_OP ("LOr", ARGP_LOR_OP, ARGI_LOR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL_NUMERIC | AML_CONSTANT), +/* 3A */ ACPI_OP ("LNot", ARGP_LNOT_OP, ARGI_LNOT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_1R, AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT), +/* 3B */ ACPI_OP ("LEqual", ARGP_LEQUAL_OP, ARGI_LEQUAL_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT), +/* 3C */ ACPI_OP ("LGreater", ARGP_LGREATER_OP, ARGI_LGREATER_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT), +/* 3D */ ACPI_OP ("LLess", ARGP_LLESS_OP, ARGI_LLESS_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL | AML_CONSTANT), +/* 3E */ ACPI_OP ("If", ARGP_IF_OP, ARGI_IF_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS), +/* 3F */ ACPI_OP ("Else", ARGP_ELSE_OP, ARGI_ELSE_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS), +/* 40 */ ACPI_OP ("While", ARGP_WHILE_OP, ARGI_WHILE_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS), +/* 41 */ ACPI_OP ("Noop", ARGP_NOOP_OP, ARGI_NOOP_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0), +/* 42 */ ACPI_OP ("Return", ARGP_RETURN_OP, ARGI_RETURN_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, AML_HAS_ARGS), +/* 43 */ ACPI_OP ("Break", ARGP_BREAK_OP, ARGI_BREAK_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0), +/* 44 */ ACPI_OP ("BreakPoint", ARGP_BREAK_POINT_OP, ARGI_BREAK_POINT_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0), +/* 45 */ ACPI_OP ("Ones", ARGP_ONES_OP, ARGI_ONES_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, AML_CONSTANT), + +/* Prefixed opcodes (Two-byte opcodes with a prefix op) */ + +/* 46 */ ACPI_OP ("Mutex", ARGP_MUTEX_OP, ARGI_MUTEX_OP, ACPI_TYPE_MUTEX, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), +/* 47 */ ACPI_OP ("Event", ARGP_EVENT_OP, ARGI_EVENT_OP, ACPI_TYPE_EVENT, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED ), +/* 48 */ ACPI_OP ("CondRefOf", ARGP_COND_REF_OF_OP, ARGI_COND_REF_OF_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R), +/* 49 */ ACPI_OP ("CreateField", ARGP_CREATE_FIELD_OP, ARGI_CREATE_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_FIELD | AML_CREATE), +/* 4A */ ACPI_OP ("Load", ARGP_LOAD_OP, ARGI_LOAD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_0R, AML_FLAGS_EXEC_1A_1T_0R), +/* 4B */ ACPI_OP ("Stall", ARGP_STALL_OP, ARGI_STALL_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R), +/* 4C */ ACPI_OP ("Sleep", ARGP_SLEEP_OP, ARGI_SLEEP_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R), +/* 4D */ ACPI_OP ("Acquire", ARGP_ACQUIRE_OP, ARGI_ACQUIRE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R), +/* 4E */ ACPI_OP ("Signal", ARGP_SIGNAL_OP, ARGI_SIGNAL_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R), +/* 4F */ ACPI_OP ("Wait", ARGP_WAIT_OP, ARGI_WAIT_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_0T_1R, AML_FLAGS_EXEC_2A_0T_1R), +/* 50 */ ACPI_OP ("Reset", ARGP_RESET_OP, ARGI_RESET_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R), +/* 51 */ ACPI_OP ("Release", ARGP_RELEASE_OP, ARGI_RELEASE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R), +/* 52 */ ACPI_OP ("FromBCD", ARGP_FROM_BCD_OP, ARGI_FROM_BCD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), +/* 53 */ ACPI_OP ("ToBCD", ARGP_TO_BCD_OP, ARGI_TO_BCD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), +/* 54 */ ACPI_OP ("Unload", ARGP_UNLOAD_OP, ARGI_UNLOAD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_0T_0R, AML_FLAGS_EXEC_1A_0T_0R), +/* 55 */ ACPI_OP ("Revision", ARGP_REVISION_OP, ARGI_REVISION_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, 0), +/* 56 */ ACPI_OP ("Debug", ARGP_DEBUG_OP, ARGI_DEBUG_OP, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_CONSTANT, 0), +/* 57 */ ACPI_OP ("Fatal", ARGP_FATAL_OP, ARGI_FATAL_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_3A_0T_0R, AML_FLAGS_EXEC_3A_0T_0R), +/* 58 */ ACPI_OP ("OperationRegion", ARGP_REGION_OP, ARGI_REGION_OP, ACPI_TYPE_REGION, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_COMPLEX, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED | AML_DEFER), +/* 59 */ ACPI_OP ("Field", ARGP_FIELD_OP, ARGI_FIELD_OP, ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD), +/* 5A */ ACPI_OP ("Device", ARGP_DEVICE_OP, ARGI_DEVICE_OP, ACPI_TYPE_DEVICE, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_NO_OBJ, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), +/* 5B */ ACPI_OP ("Processor", ARGP_PROCESSOR_OP, ARGI_PROCESSOR_OP, ACPI_TYPE_PROCESSOR, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), +/* 5C */ ACPI_OP ("PowerResource", ARGP_POWER_RES_OP, ARGI_POWER_RES_OP, ACPI_TYPE_POWER, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_SIMPLE, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), +/* 5D */ ACPI_OP ("ThermalZone", ARGP_THERMAL_ZONE_OP, ARGI_THERMAL_ZONE_OP, ACPI_TYPE_THERMAL, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_NO_OBJ, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED), +/* 5E */ ACPI_OP ("IndexField", ARGP_INDEX_FIELD_OP, ARGI_INDEX_FIELD_OP, ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD), +/* 5F */ ACPI_OP ("BankField", ARGP_BANK_FIELD_OP, ARGI_BANK_FIELD_OP, ACPI_TYPE_LOCAL_BANK_FIELD, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_FIELD | AML_DEFER), + +/* Internal opcodes that map to invalid AML opcodes */ + +/* 60 */ ACPI_OP ("LNotEqual", ARGP_LNOTEQUAL_OP, ARGI_LNOTEQUAL_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, AML_HAS_ARGS | AML_CONSTANT), +/* 61 */ ACPI_OP ("LLessEqual", ARGP_LLESSEQUAL_OP, ARGI_LLESSEQUAL_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, AML_HAS_ARGS | AML_CONSTANT), +/* 62 */ ACPI_OP ("LGreaterEqual", ARGP_LGREATEREQUAL_OP, ARGI_LGREATEREQUAL_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, AML_HAS_ARGS | AML_CONSTANT), +/* 63 */ ACPI_OP ("-NamePath-", ARGP_NAMEPATH_OP, ARGI_NAMEPATH_OP, ACPI_TYPE_LOCAL_REFERENCE, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_NSOBJECT | AML_NSNODE ), +/* 64 */ ACPI_OP ("-MethodCall-", ARGP_METHODCALL_OP, ARGI_METHODCALL_OP, ACPI_TYPE_METHOD, AML_CLASS_METHOD_CALL, AML_TYPE_METHOD_CALL, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE), +/* 65 */ ACPI_OP ("-ByteList-", ARGP_BYTELIST_OP, ARGI_BYTELIST_OP, ACPI_TYPE_ANY, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, 0), +/* 66 */ ACPI_OP ("-ReservedField-", ARGP_RESERVEDFIELD_OP, ARGI_RESERVEDFIELD_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, 0), +/* 67 */ ACPI_OP ("-NamedField-", ARGP_NAMEDFIELD_OP, ARGI_NAMEDFIELD_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED ), +/* 68 */ ACPI_OP ("-AccessField-", ARGP_ACCESSFIELD_OP, ARGI_ACCESSFIELD_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, 0), +/* 69 */ ACPI_OP ("-StaticString", ARGP_STATICSTRING_OP, ARGI_STATICSTRING_OP, ACPI_TYPE_ANY, AML_CLASS_INTERNAL, AML_TYPE_BOGUS, 0), +/* 6A */ ACPI_OP ("-Return Value-", ARG_NONE, ARG_NONE, ACPI_TYPE_ANY, AML_CLASS_RETURN_VALUE, AML_TYPE_RETURN, AML_HAS_ARGS | AML_HAS_RETVAL), +/* 6B */ ACPI_OP ("-UNKNOWN_OP-", ARG_NONE, ARG_NONE, ACPI_TYPE_INVALID, AML_CLASS_UNKNOWN, AML_TYPE_BOGUS, AML_HAS_ARGS), +/* 6C */ ACPI_OP ("-ASCII_ONLY-", ARG_NONE, ARG_NONE, ACPI_TYPE_ANY, AML_CLASS_ASCII, AML_TYPE_BOGUS, AML_HAS_ARGS), +/* 6D */ ACPI_OP ("-PREFIX_ONLY-", ARG_NONE, ARG_NONE, ACPI_TYPE_ANY, AML_CLASS_PREFIX, AML_TYPE_BOGUS, AML_HAS_ARGS), + +/* ACPI 2.0 opcodes */ + +/* 6E */ ACPI_OP ("QwordConst", ARGP_QWORD_OP, ARGI_QWORD_OP, ACPI_TYPE_INTEGER, AML_CLASS_ARGUMENT, AML_TYPE_LITERAL, AML_CONSTANT), +/* 6F */ ACPI_OP ("Package", /* Var */ ARGP_VAR_PACKAGE_OP, ARGI_VAR_PACKAGE_OP, ACPI_TYPE_PACKAGE, AML_CLASS_CREATE, AML_TYPE_CREATE_OBJECT, AML_HAS_ARGS | AML_DEFER), +/* 70 */ ACPI_OP ("ConcatenateResTemplate", ARGP_CONCAT_RES_OP, ARGI_CONCAT_RES_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT), +/* 71 */ ACPI_OP ("Mod", ARGP_MOD_OP, ARGI_MOD_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT), +/* 72 */ ACPI_OP ("CreateQWordField", ARGP_CREATE_QWORD_FIELD_OP,ARGI_CREATE_QWORD_FIELD_OP, ACPI_TYPE_BUFFER_FIELD, AML_CLASS_CREATE, AML_TYPE_CREATE_FIELD, AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE), +/* 73 */ ACPI_OP ("ToBuffer", ARGP_TO_BUFFER_OP, ARGI_TO_BUFFER_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), +/* 74 */ ACPI_OP ("ToDecimalString", ARGP_TO_DEC_STR_OP, ARGI_TO_DEC_STR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), +/* 75 */ ACPI_OP ("ToHexString", ARGP_TO_HEX_STR_OP, ARGI_TO_HEX_STR_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), +/* 76 */ ACPI_OP ("ToInteger", ARGP_TO_INTEGER_OP, ARGI_TO_INTEGER_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R | AML_CONSTANT), +/* 77 */ ACPI_OP ("ToString", ARGP_TO_STRING_OP, ARGI_TO_STRING_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_2A_1T_1R, AML_FLAGS_EXEC_2A_1T_1R | AML_CONSTANT), +/* 78 */ ACPI_OP ("CopyObject", ARGP_COPY_OP, ARGI_COPY_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_1A_1T_1R, AML_FLAGS_EXEC_1A_1T_1R), +/* 79 */ ACPI_OP ("Mid", ARGP_MID_OP, ARGI_MID_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_3A_1T_1R, AML_FLAGS_EXEC_3A_1T_1R | AML_CONSTANT), +/* 7A */ ACPI_OP ("Continue", ARGP_CONTINUE_OP, ARGI_CONTINUE_OP, ACPI_TYPE_ANY, AML_CLASS_CONTROL, AML_TYPE_CONTROL, 0), +/* 7B */ ACPI_OP ("LoadTable", ARGP_LOAD_TABLE_OP, ARGI_LOAD_TABLE_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_6A_0T_1R, AML_FLAGS_EXEC_6A_0T_1R), +/* 7C */ ACPI_OP ("DataTableRegion", ARGP_DATA_REGION_OP, ARGI_DATA_REGION_OP, ACPI_TYPE_REGION, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_COMPLEX, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE | AML_NAMED | AML_DEFER), +/* 7D */ ACPI_OP ("[EvalSubTree]", ARGP_SCOPE_OP, ARGI_SCOPE_OP, ACPI_TYPE_ANY, AML_CLASS_NAMED_OBJECT, AML_TYPE_NAMED_NO_OBJ, AML_HAS_ARGS | AML_NSOBJECT | AML_NSOPCODE | AML_NSNODE), + +/* ACPI 3.0 opcodes */ + +/* 7E */ ACPI_OP ("Timer", ARGP_TIMER_OP, ARGI_TIMER_OP, ACPI_TYPE_ANY, AML_CLASS_EXECUTE, AML_TYPE_EXEC_0A_0T_1R, AML_FLAGS_EXEC_0A_0T_1R) + +/*! [End] no source code translation !*/ +}; + +/* + * This table is directly indexed by the opcodes, and returns an + * index into the table above + */ +static const UINT8 AcpiGbl_ShortOpIndex[256] = +{ +/* 0 1 2 3 4 5 6 7 */ +/* 8 9 A B C D E F */ +/* 0x00 */ 0x00, 0x01, _UNK, _UNK, _UNK, _UNK, 0x02, _UNK, +/* 0x08 */ 0x03, _UNK, 0x04, 0x05, 0x06, 0x07, 0x6E, _UNK, +/* 0x10 */ 0x08, 0x09, 0x0a, 0x6F, 0x0b, _UNK, _UNK, _UNK, +/* 0x18 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x20 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x28 */ _UNK, _UNK, _UNK, _UNK, _UNK, 0x63, _PFX, _PFX, +/* 0x30 */ 0x67, 0x66, 0x68, 0x65, 0x69, 0x64, 0x6A, 0x7D, +/* 0x38 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x40 */ _UNK, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, +/* 0x48 */ _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, +/* 0x50 */ _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, _ASC, +/* 0x58 */ _ASC, _ASC, _ASC, _UNK, _PFX, _UNK, _PFX, _ASC, +/* 0x60 */ 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, +/* 0x68 */ 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, _UNK, +/* 0x70 */ 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, +/* 0x78 */ 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, +/* 0x80 */ 0x2b, 0x2c, 0x2d, 0x2e, 0x70, 0x71, 0x2f, 0x30, +/* 0x88 */ 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x72, +/* 0x90 */ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x73, 0x74, +/* 0x98 */ 0x75, 0x76, _UNK, _UNK, 0x77, 0x78, 0x79, 0x7A, +/* 0xA0 */ 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x60, 0x61, +/* 0xA8 */ 0x62, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0xB0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0xB8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0xC0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0xC8 */ _UNK, _UNK, _UNK, _UNK, 0x44, _UNK, _UNK, _UNK, +/* 0xD0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0xD8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0xE0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0xE8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0xF0 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0xF8 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 0x45, +}; + +/* + * This table is indexed by the second opcode of the extended opcode + * pair. It returns an index into the opcode table (AcpiGbl_AmlOpInfo) + */ +static const UINT8 AcpiGbl_LongOpIndex[NUM_EXTENDED_OPCODE] = +{ +/* 0 1 2 3 4 5 6 7 */ +/* 8 9 A B C D E F */ +/* 0x00 */ _UNK, 0x46, 0x47, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x08 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x10 */ _UNK, _UNK, 0x48, 0x49, _UNK, _UNK, _UNK, _UNK, +/* 0x18 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, 0x7B, +/* 0x20 */ 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, +/* 0x28 */ 0x52, 0x53, 0x54, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x30 */ 0x55, 0x56, 0x57, 0x7e, _UNK, _UNK, _UNK, _UNK, +/* 0x38 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x40 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x48 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x50 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x58 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x60 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x68 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x70 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x78 */ _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, +/* 0x80 */ 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, +/* 0x88 */ 0x7C, +}; + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetOpcodeInfo + * + * PARAMETERS: Opcode - The AML opcode + * + * RETURN: A pointer to the info about the opcode. + * + * DESCRIPTION: Find AML opcode description based on the opcode. + * NOTE: This procedure must ALWAYS return a valid pointer! + * + ******************************************************************************/ + +const ACPI_OPCODE_INFO * +AcpiPsGetOpcodeInfo ( + UINT16 Opcode) +{ + ACPI_FUNCTION_NAME (PsGetOpcodeInfo); + + + /* + * Detect normal 8-bit opcode or extended 16-bit opcode + */ + if (!(Opcode & 0xFF00)) + { + /* Simple (8-bit) opcode: 0-255, can't index beyond table */ + + return (&AcpiGbl_AmlOpInfo [AcpiGbl_ShortOpIndex [(UINT8) Opcode]]); + } + + if (((Opcode & 0xFF00) == AML_EXTENDED_OPCODE) && + (((UINT8) Opcode) <= MAX_EXTENDED_OPCODE)) + { + /* Valid extended (16-bit) opcode */ + + return (&AcpiGbl_AmlOpInfo [AcpiGbl_LongOpIndex [(UINT8) Opcode]]); + } + + /* Unknown AML opcode */ + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Unknown AML opcode [%4.4X]\n", Opcode)); + + return (&AcpiGbl_AmlOpInfo [_UNK]); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetOpcodeName + * + * PARAMETERS: Opcode - The AML opcode + * + * RETURN: A pointer to the name of the opcode (ASCII String) + * Note: Never returns NULL. + * + * DESCRIPTION: Translate an opcode into a human-readable string + * + ******************************************************************************/ + +char * +AcpiPsGetOpcodeName ( + UINT16 Opcode) +{ +#if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUG_OUTPUT) + + const ACPI_OPCODE_INFO *Op; + + + Op = AcpiPsGetOpcodeInfo (Opcode); + + /* Always guaranteed to return a valid pointer */ + + return (Op->Name); + +#else + return ("OpcodeName unavailable"); + +#endif +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetArgumentCount + * + * PARAMETERS: OpType - Type associated with the AML opcode + * + * RETURN: Argument count + * + * DESCRIPTION: Obtain the number of expected arguments for an AML opcode + * + ******************************************************************************/ + +UINT8 +AcpiPsGetArgumentCount ( + UINT32 OpType) +{ + + if (OpType <= AML_TYPE_EXEC_6A_0T_1R) + { + return (AcpiGbl_ArgumentCount[OpType]); + } + + return (0); +} diff --git a/reactos/drivers/bus/acpi/acpica/parser/psparse.c b/reactos/drivers/bus/acpi/acpica/parser/psparse.c new file mode 100644 index 00000000000..820f54bd0ca --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/parser/psparse.c @@ -0,0 +1,791 @@ +/****************************************************************************** + * + * Module Name: psparse - Parser top level AML parse routines + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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. + * + *****************************************************************************/ + + +/* + * Parse the AML and build an operation tree as most interpreters, + * like Perl, do. Parsing is done by hand rather than with a YACC + * generated parser to tightly constrain stack and dynamic memory + * usage. At the same time, parsing is kept flexible and the code + * fairly compact by parsing based on a list of AML opcode + * templates in AmlOpInfo[] + */ + +#include "acpi.h" +#include "accommon.h" +#include "acparser.h" +#include "acdispat.h" +#include "amlcode.h" +#include "acnamesp.h" +#include "acinterp.h" + +#define _COMPONENT ACPI_PARSER + ACPI_MODULE_NAME ("psparse") + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetOpcodeSize + * + * PARAMETERS: Opcode - An AML opcode + * + * RETURN: Size of the opcode, in bytes (1 or 2) + * + * DESCRIPTION: Get the size of the current opcode. + * + ******************************************************************************/ + +UINT32 +AcpiPsGetOpcodeSize ( + UINT32 Opcode) +{ + + /* Extended (2-byte) opcode if > 255 */ + + if (Opcode > 0x00FF) + { + return (2); + } + + /* Otherwise, just a single byte opcode */ + + return (1); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsPeekOpcode + * + * PARAMETERS: ParserState - A parser state object + * + * RETURN: Next AML opcode + * + * DESCRIPTION: Get next AML opcode (without incrementing AML pointer) + * + ******************************************************************************/ + +UINT16 +AcpiPsPeekOpcode ( + ACPI_PARSE_STATE *ParserState) +{ + UINT8 *Aml; + UINT16 Opcode; + + + Aml = ParserState->Aml; + Opcode = (UINT16) ACPI_GET8 (Aml); + + if (Opcode == AML_EXTENDED_OP_PREFIX) + { + /* Extended opcode, get the second opcode byte */ + + Aml++; + Opcode = (UINT16) ((Opcode << 8) | ACPI_GET8 (Aml)); + } + + return (Opcode); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsCompleteThisOp + * + * PARAMETERS: WalkState - Current State + * Op - Op to complete + * + * RETURN: Status + * + * DESCRIPTION: Perform any cleanup at the completion of an Op. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiPsCompleteThisOp ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PARSE_OBJECT *Prev; + ACPI_PARSE_OBJECT *Next; + const ACPI_OPCODE_INFO *ParentInfo; + ACPI_PARSE_OBJECT *ReplacementOp = NULL; + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE_PTR (PsCompleteThisOp, Op); + + + /* Check for null Op, can happen if AML code is corrupt */ + + if (!Op) + { + return_ACPI_STATUS (AE_OK); /* OK for now */ + } + + /* Delete this op and the subtree below it if asked to */ + + if (((WalkState->ParseFlags & ACPI_PARSE_TREE_MASK) != ACPI_PARSE_DELETE_TREE) || + (WalkState->OpInfo->Class == AML_CLASS_ARGUMENT)) + { + return_ACPI_STATUS (AE_OK); + } + + /* Make sure that we only delete this subtree */ + + if (Op->Common.Parent) + { + Prev = Op->Common.Parent->Common.Value.Arg; + if (!Prev) + { + /* Nothing more to do */ + + goto Cleanup; + } + + /* + * Check if we need to replace the operator and its subtree + * with a return value op (placeholder op) + */ + ParentInfo = AcpiPsGetOpcodeInfo (Op->Common.Parent->Common.AmlOpcode); + + switch (ParentInfo->Class) + { + case AML_CLASS_CONTROL: + break; + + case AML_CLASS_CREATE: + + /* + * These opcodes contain TermArg operands. The current + * op must be replaced by a placeholder return op + */ + ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP); + if (!ReplacementOp) + { + Status = AE_NO_MEMORY; + } + break; + + case AML_CLASS_NAMED_OBJECT: + + /* + * These opcodes contain TermArg operands. The current + * op must be replaced by a placeholder return op + */ + if ((Op->Common.Parent->Common.AmlOpcode == AML_REGION_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_DATA_REGION_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_BUFFER_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_BANK_FIELD_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP)) + { + ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP); + if (!ReplacementOp) + { + Status = AE_NO_MEMORY; + } + } + else if ((Op->Common.Parent->Common.AmlOpcode == AML_NAME_OP) && + (WalkState->PassNumber <= ACPI_IMODE_LOAD_PASS2)) + { + if ((Op->Common.AmlOpcode == AML_BUFFER_OP) || + (Op->Common.AmlOpcode == AML_PACKAGE_OP) || + (Op->Common.AmlOpcode == AML_VAR_PACKAGE_OP)) + { + ReplacementOp = AcpiPsAllocOp (Op->Common.AmlOpcode); + if (!ReplacementOp) + { + Status = AE_NO_MEMORY; + } + else + { + ReplacementOp->Named.Data = Op->Named.Data; + ReplacementOp->Named.Length = Op->Named.Length; + } + } + } + break; + + default: + + ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP); + if (!ReplacementOp) + { + Status = AE_NO_MEMORY; + } + } + + /* We must unlink this op from the parent tree */ + + if (Prev == Op) + { + /* This op is the first in the list */ + + if (ReplacementOp) + { + ReplacementOp->Common.Parent = Op->Common.Parent; + ReplacementOp->Common.Value.Arg = NULL; + ReplacementOp->Common.Node = Op->Common.Node; + Op->Common.Parent->Common.Value.Arg = ReplacementOp; + ReplacementOp->Common.Next = Op->Common.Next; + } + else + { + Op->Common.Parent->Common.Value.Arg = Op->Common.Next; + } + } + + /* Search the parent list */ + + else while (Prev) + { + /* Traverse all siblings in the parent's argument list */ + + Next = Prev->Common.Next; + if (Next == Op) + { + if (ReplacementOp) + { + ReplacementOp->Common.Parent = Op->Common.Parent; + ReplacementOp->Common.Value.Arg = NULL; + ReplacementOp->Common.Node = Op->Common.Node; + Prev->Common.Next = ReplacementOp; + ReplacementOp->Common.Next = Op->Common.Next; + Next = NULL; + } + else + { + Prev->Common.Next = Op->Common.Next; + Next = NULL; + } + } + Prev = Next; + } + } + + +Cleanup: + + /* Now we can actually delete the subtree rooted at Op */ + + AcpiPsDeleteParseTree (Op); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsNextParseState + * + * PARAMETERS: WalkState - Current state + * Op - Current parse op + * CallbackStatus - Status from previous operation + * + * RETURN: Status + * + * DESCRIPTION: Update the parser state based upon the return exception from + * the parser callback. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiPsNextParseState ( + ACPI_WALK_STATE *WalkState, + ACPI_PARSE_OBJECT *Op, + ACPI_STATUS CallbackStatus) +{ + ACPI_PARSE_STATE *ParserState = &WalkState->ParserState; + ACPI_STATUS Status = AE_CTRL_PENDING; + + + ACPI_FUNCTION_TRACE_PTR (PsNextParseState, Op); + + + switch (CallbackStatus) + { + case AE_CTRL_TERMINATE: + /* + * A control method was terminated via a RETURN statement. + * The walk of this method is complete. + */ + ParserState->Aml = ParserState->AmlEnd; + Status = AE_CTRL_TERMINATE; + break; + + + case AE_CTRL_BREAK: + + ParserState->Aml = WalkState->AmlLastWhile; + WalkState->ControlState->Common.Value = FALSE; + Status = AE_CTRL_BREAK; + break; + + + case AE_CTRL_CONTINUE: + + ParserState->Aml = WalkState->AmlLastWhile; + Status = AE_CTRL_CONTINUE; + break; + + + case AE_CTRL_PENDING: + + ParserState->Aml = WalkState->AmlLastWhile; + break; + +#if 0 + case AE_CTRL_SKIP: + + ParserState->Aml = ParserState->Scope->ParseScope.PkgEnd; + Status = AE_OK; + break; +#endif + + case AE_CTRL_TRUE: + /* + * Predicate of an IF was true, and we are at the matching ELSE. + * Just close out this package + */ + ParserState->Aml = AcpiPsGetNextPackageEnd (ParserState); + Status = AE_CTRL_PENDING; + break; + + + case AE_CTRL_FALSE: + /* + * Either an IF/WHILE Predicate was false or we encountered a BREAK + * opcode. In both cases, we do not execute the rest of the + * package; We simply close out the parent (finishing the walk of + * this branch of the tree) and continue execution at the parent + * level. + */ + ParserState->Aml = ParserState->Scope->ParseScope.PkgEnd; + + /* In the case of a BREAK, just force a predicate (if any) to FALSE */ + + WalkState->ControlState->Common.Value = FALSE; + Status = AE_CTRL_END; + break; + + + case AE_CTRL_TRANSFER: + + /* A method call (invocation) -- transfer control */ + + Status = AE_CTRL_TRANSFER; + WalkState->PrevOp = Op; + WalkState->MethodCallOp = Op; + WalkState->MethodCallNode = (Op->Common.Value.Arg)->Common.Node; + + /* Will return value (if any) be used by the caller? */ + + WalkState->ReturnUsed = AcpiDsIsResultUsed (Op, WalkState); + break; + + + default: + + Status = CallbackStatus; + if ((CallbackStatus & AE_CODE_MASK) == AE_CODE_CONTROL) + { + Status = AE_OK; + } + break; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsParseAml + * + * PARAMETERS: WalkState - Current state + * + * + * RETURN: Status + * + * DESCRIPTION: Parse raw AML and return a tree of ops + * + ******************************************************************************/ + +ACPI_STATUS +AcpiPsParseAml ( + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status; + ACPI_THREAD_STATE *Thread; + ACPI_THREAD_STATE *PrevWalkList = AcpiGbl_CurrentWalkList; + ACPI_WALK_STATE *PreviousWalkState; + + + ACPI_FUNCTION_TRACE (PsParseAml); + + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "Entered with WalkState=%p Aml=%p size=%X\n", + WalkState, WalkState->ParserState.Aml, + WalkState->ParserState.AmlSize)); + + if (!WalkState->ParserState.Aml) + { + return_ACPI_STATUS (AE_NULL_OBJECT); + } + + /* Create and initialize a new thread state */ + + Thread = AcpiUtCreateThreadState (); + if (!Thread) + { + if (WalkState->MethodDesc) + { + /* Executing a control method - additional cleanup */ + + AcpiDsTerminateControlMethod (WalkState->MethodDesc, WalkState); + } + + AcpiDsDeleteWalkState (WalkState); + return_ACPI_STATUS (AE_NO_MEMORY); + } + + WalkState->Thread = Thread; + + /* + * If executing a method, the starting SyncLevel is this method's + * SyncLevel + */ + if (WalkState->MethodDesc) + { + WalkState->Thread->CurrentSyncLevel = WalkState->MethodDesc->Method.SyncLevel; + } + + AcpiDsPushWalkState (WalkState, Thread); + + /* + * This global allows the AML debugger to get a handle to the currently + * executing control method. + */ + AcpiGbl_CurrentWalkList = Thread; + + /* + * Execute the walk loop as long as there is a valid Walk State. This + * handles nested control method invocations without recursion. + */ + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "State=%p\n", WalkState)); + + Status = AE_OK; + while (WalkState) + { + if (ACPI_SUCCESS (Status)) + { + /* + * The ParseLoop executes AML until the method terminates + * or calls another method. + */ + Status = AcpiPsParseLoop (WalkState); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "Completed one call to walk loop, %s State=%p\n", + AcpiFormatException (Status), WalkState)); + + if (Status == AE_CTRL_TRANSFER) + { + /* + * A method call was detected. + * Transfer control to the called control method + */ + Status = AcpiDsCallControlMethod (Thread, WalkState, NULL); + if (ACPI_FAILURE (Status)) + { + Status = AcpiDsMethodError (Status, WalkState); + } + + /* + * If the transfer to the new method method call worked, a new walk + * state was created -- get it + */ + WalkState = AcpiDsGetCurrentWalkState (Thread); + continue; + } + else if (Status == AE_CTRL_TERMINATE) + { + Status = AE_OK; + } + else if ((Status != AE_OK) && (WalkState->MethodDesc)) + { + /* Either the method parse or actual execution failed */ + + ACPI_ERROR_METHOD ("Method parse/execution failed", + WalkState->MethodNode, NULL, Status); + + /* Check for possible multi-thread reentrancy problem */ + + if ((Status == AE_ALREADY_EXISTS) && + (!WalkState->MethodDesc->Method.Mutex)) + { + 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. + */ + WalkState->MethodDesc->Method.MethodFlags |= AML_METHOD_SERIALIZED; + WalkState->MethodDesc->Method.SyncLevel = 0; + } + } + + /* We are done with this walk, move on to the parent if any */ + + WalkState = AcpiDsPopWalkState (Thread); + + /* Reset the current scope to the beginning of scope stack */ + + AcpiDsScopeStackClear (WalkState); + + /* + * If we just returned from the execution of a control method or if we + * encountered an error during the method parse phase, there's lots of + * cleanup to do + */ + if (((WalkState->ParseFlags & ACPI_PARSE_MODE_MASK) == ACPI_PARSE_EXECUTE) || + (ACPI_FAILURE (Status))) + { + AcpiDsTerminateControlMethod (WalkState->MethodDesc, WalkState); + } + + /* Delete this walk state and all linked control states */ + + AcpiPsCleanupScope (&WalkState->ParserState); + PreviousWalkState = WalkState; + + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "ReturnValue=%p, ImplicitValue=%p State=%p\n", + WalkState->ReturnDesc, WalkState->ImplicitReturnObj, WalkState)); + + /* Check if we have restarted a preempted walk */ + + WalkState = AcpiDsGetCurrentWalkState (Thread); + if (WalkState) + { + if (ACPI_SUCCESS (Status)) + { + /* + * There is another walk state, restart it. + * If the method return value is not used by the parent, + * The object is deleted + */ + if (!PreviousWalkState->ReturnDesc) + { + /* + * In slack mode execution, if there is no return value + * we should implicitly return zero (0) as a default value. + */ + if (AcpiGbl_EnableInterpreterSlack && + !PreviousWalkState->ImplicitReturnObj) + { + PreviousWalkState->ImplicitReturnObj = + AcpiUtCreateIntegerObject ((UINT64) 0); + if (!PreviousWalkState->ImplicitReturnObj) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + } + + /* Restart the calling control method */ + + Status = AcpiDsRestartControlMethod (WalkState, + PreviousWalkState->ImplicitReturnObj); + } + else + { + /* + * We have a valid return value, delete any implicit + * return value. + */ + AcpiDsClearImplicitReturn (PreviousWalkState); + + Status = AcpiDsRestartControlMethod (WalkState, + PreviousWalkState->ReturnDesc); + } + if (ACPI_SUCCESS (Status)) + { + WalkState->WalkType |= ACPI_WALK_METHOD_RESTART; + } + } + else + { + /* On error, delete any return object or implicit return */ + + AcpiUtRemoveReference (PreviousWalkState->ReturnDesc); + AcpiDsClearImplicitReturn (PreviousWalkState); + } + } + + /* + * Just completed a 1st-level method, save the final internal return + * value (if any) + */ + else if (PreviousWalkState->CallerReturnDesc) + { + if (PreviousWalkState->ImplicitReturnObj) + { + *(PreviousWalkState->CallerReturnDesc) = + PreviousWalkState->ImplicitReturnObj; + } + else + { + /* NULL if no return value */ + + *(PreviousWalkState->CallerReturnDesc) = + PreviousWalkState->ReturnDesc; + } + } + else + { + if (PreviousWalkState->ReturnDesc) + { + /* Caller doesn't want it, must delete it */ + + AcpiUtRemoveReference (PreviousWalkState->ReturnDesc); + } + if (PreviousWalkState->ImplicitReturnObj) + { + /* Caller doesn't want it, must delete it */ + + AcpiUtRemoveReference (PreviousWalkState->ImplicitReturnObj); + } + } + + AcpiDsDeleteWalkState (PreviousWalkState); + } + + /* Normal exit */ + + AcpiExReleaseAllMutexes (Thread); + AcpiUtDeleteGenericState (ACPI_CAST_PTR (ACPI_GENERIC_STATE, Thread)); + AcpiGbl_CurrentWalkList = PrevWalkList; + return_ACPI_STATUS (Status); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/parser/psscope.c b/reactos/drivers/bus/acpi/acpica/parser/psscope.c new file mode 100644 index 00000000000..979dbb15151 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/parser/psscope.c @@ -0,0 +1,374 @@ +/****************************************************************************** + * + * Module Name: psscope - Parser scope stack management routines + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 "acpi.h" +#include "accommon.h" +#include "acparser.h" + +#define _COMPONENT ACPI_PARSER + ACPI_MODULE_NAME ("psscope") + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetParentScope + * + * PARAMETERS: ParserState - Current parser state object + * + * RETURN: Pointer to an Op object + * + * DESCRIPTION: Get parent of current op being parsed + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT * +AcpiPsGetParentScope ( + ACPI_PARSE_STATE *ParserState) +{ + + return (ParserState->Scope->ParseScope.Op); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsHasCompletedScope + * + * PARAMETERS: ParserState - Current parser state object + * + * RETURN: Boolean, TRUE = scope completed. + * + * DESCRIPTION: Is parsing of current argument complete? Determined by + * 1) AML pointer is at or beyond the end of the scope + * 2) The scope argument count has reached zero. + * + ******************************************************************************/ + +BOOLEAN +AcpiPsHasCompletedScope ( + ACPI_PARSE_STATE *ParserState) +{ + + return ((BOOLEAN) + ((ParserState->Aml >= ParserState->Scope->ParseScope.ArgEnd || + !ParserState->Scope->ParseScope.ArgCount))); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsInitScope + * + * PARAMETERS: ParserState - Current parser state object + * Root - the Root Node of this new scope + * + * RETURN: Status + * + * DESCRIPTION: Allocate and init a new scope object + * + ******************************************************************************/ + +ACPI_STATUS +AcpiPsInitScope ( + ACPI_PARSE_STATE *ParserState, + ACPI_PARSE_OBJECT *RootOp) +{ + ACPI_GENERIC_STATE *Scope; + + + ACPI_FUNCTION_TRACE_PTR (PsInitScope, RootOp); + + + Scope = AcpiUtCreateGenericState (); + if (!Scope) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Scope->Common.DescriptorType = ACPI_DESC_TYPE_STATE_RPSCOPE; + Scope->ParseScope.Op = RootOp; + Scope->ParseScope.ArgCount = ACPI_VAR_ARGS; + Scope->ParseScope.ArgEnd = ParserState->AmlEnd; + Scope->ParseScope.PkgEnd = ParserState->AmlEnd; + + ParserState->Scope = Scope; + ParserState->StartOp = RootOp; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsPushScope + * + * PARAMETERS: ParserState - Current parser state object + * Op - Current op to be pushed + * RemainingArgs - List of args remaining + * ArgCount - Fixed or variable number of args + * + * RETURN: Status + * + * DESCRIPTION: Push current op to begin parsing its argument + * + ******************************************************************************/ + +ACPI_STATUS +AcpiPsPushScope ( + ACPI_PARSE_STATE *ParserState, + ACPI_PARSE_OBJECT *Op, + UINT32 RemainingArgs, + UINT32 ArgCount) +{ + ACPI_GENERIC_STATE *Scope; + + + ACPI_FUNCTION_TRACE_PTR (PsPushScope, Op); + + + Scope = AcpiUtCreateGenericState (); + if (!Scope) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Scope->Common.DescriptorType = ACPI_DESC_TYPE_STATE_PSCOPE; + Scope->ParseScope.Op = Op; + Scope->ParseScope.ArgList = RemainingArgs; + Scope->ParseScope.ArgCount = ArgCount; + Scope->ParseScope.PkgEnd = ParserState->PkgEnd; + + /* Push onto scope stack */ + + AcpiUtPushGenericState (&ParserState->Scope, Scope); + + if (ArgCount == ACPI_VAR_ARGS) + { + /* Multiple arguments */ + + Scope->ParseScope.ArgEnd = ParserState->PkgEnd; + } + else + { + /* Single argument */ + + Scope->ParseScope.ArgEnd = ACPI_TO_POINTER (ACPI_MAX_PTR); + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsPopScope + * + * PARAMETERS: ParserState - Current parser state object + * Op - Where the popped op is returned + * ArgList - Where the popped "next argument" is + * returned + * ArgCount - Count of objects in ArgList + * + * RETURN: Status + * + * DESCRIPTION: Return to parsing a previous op + * + ******************************************************************************/ + +void +AcpiPsPopScope ( + ACPI_PARSE_STATE *ParserState, + ACPI_PARSE_OBJECT **Op, + UINT32 *ArgList, + UINT32 *ArgCount) +{ + ACPI_GENERIC_STATE *Scope = ParserState->Scope; + + + ACPI_FUNCTION_TRACE (PsPopScope); + + + /* Only pop the scope if there is in fact a next scope */ + + if (Scope->Common.Next) + { + Scope = AcpiUtPopGenericState (&ParserState->Scope); + + /* Return to parsing previous op */ + + *Op = Scope->ParseScope.Op; + *ArgList = Scope->ParseScope.ArgList; + *ArgCount = Scope->ParseScope.ArgCount; + ParserState->PkgEnd = Scope->ParseScope.PkgEnd; + + /* All done with this scope state structure */ + + AcpiUtDeleteGenericState (Scope); + } + else + { + /* Empty parse stack, prepare to fetch next opcode */ + + *Op = NULL; + *ArgList = 0; + *ArgCount = 0; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "Popped Op %p Args %X\n", *Op, *ArgCount)); + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsCleanupScope + * + * PARAMETERS: ParserState - Current parser state object + * + * RETURN: None + * + * DESCRIPTION: Destroy available list, remaining stack levels, and return + * root scope + * + ******************************************************************************/ + +void +AcpiPsCleanupScope ( + ACPI_PARSE_STATE *ParserState) +{ + ACPI_GENERIC_STATE *Scope; + + + ACPI_FUNCTION_TRACE_PTR (PsCleanupScope, ParserState); + + + if (!ParserState) + { + return_VOID; + } + + /* Delete anything on the scope stack */ + + while (ParserState->Scope) + { + Scope = AcpiUtPopGenericState (&ParserState->Scope); + AcpiUtDeleteGenericState (Scope); + } + + return_VOID; +} + diff --git a/reactos/drivers/bus/acpi/acpica/parser/pstree.c b/reactos/drivers/bus/acpi/acpica/parser/pstree.c new file mode 100644 index 00000000000..20ac405cac3 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/parser/pstree.c @@ -0,0 +1,427 @@ +/****************************************************************************** + * + * Module Name: pstree - Parser op tree manipulation/traversal/search + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __PSTREE_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acparser.h" +#include "amlcode.h" + +#define _COMPONENT ACPI_PARSER + ACPI_MODULE_NAME ("pstree") + +/* Local prototypes */ + +#ifdef ACPI_OBSOLETE_FUNCTIONS +ACPI_PARSE_OBJECT * +AcpiPsGetChild ( + ACPI_PARSE_OBJECT *op); +#endif + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetArg + * + * PARAMETERS: Op - Get an argument for this op + * Argn - Nth argument to get + * + * RETURN: The argument (as an Op object). NULL if argument does not exist + * + * DESCRIPTION: Get the specified op's argument. + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT * +AcpiPsGetArg ( + ACPI_PARSE_OBJECT *Op, + UINT32 Argn) +{ + ACPI_PARSE_OBJECT *Arg = NULL; + const ACPI_OPCODE_INFO *OpInfo; + + + ACPI_FUNCTION_ENTRY (); + + + /* Get the info structure for this opcode */ + + OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); + if (OpInfo->Class == AML_CLASS_UNKNOWN) + { + /* Invalid opcode or ASCII character */ + + return (NULL); + } + + /* Check if this opcode requires argument sub-objects */ + + if (!(OpInfo->Flags & AML_HAS_ARGS)) + { + /* Has no linked argument objects */ + + return (NULL); + } + + /* Get the requested argument object */ + + Arg = Op->Common.Value.Arg; + while (Arg && Argn) + { + Argn--; + Arg = Arg->Common.Next; + } + + return (Arg); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsAppendArg + * + * PARAMETERS: Op - Append an argument to this Op. + * Arg - Argument Op to append + * + * RETURN: None. + * + * DESCRIPTION: Append an argument to an op's argument list (a NULL arg is OK) + * + ******************************************************************************/ + +void +AcpiPsAppendArg ( + ACPI_PARSE_OBJECT *Op, + ACPI_PARSE_OBJECT *Arg) +{ + ACPI_PARSE_OBJECT *PrevArg; + const ACPI_OPCODE_INFO *OpInfo; + + + ACPI_FUNCTION_ENTRY (); + + + if (!Op) + { + return; + } + + /* Get the info structure for this opcode */ + + OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); + if (OpInfo->Class == AML_CLASS_UNKNOWN) + { + /* Invalid opcode */ + + ACPI_ERROR ((AE_INFO, "Invalid AML Opcode: 0x%2.2X", + Op->Common.AmlOpcode)); + return; + } + + /* Check if this opcode requires argument sub-objects */ + + if (!(OpInfo->Flags & AML_HAS_ARGS)) + { + /* Has no linked argument objects */ + + return; + } + + /* Append the argument to the linked argument list */ + + if (Op->Common.Value.Arg) + { + /* Append to existing argument list */ + + PrevArg = Op->Common.Value.Arg; + while (PrevArg->Common.Next) + { + PrevArg = PrevArg->Common.Next; + } + PrevArg->Common.Next = Arg; + } + else + { + /* No argument list, this will be the first argument */ + + Op->Common.Value.Arg = Arg; + } + + /* Set the parent in this arg and any args linked after it */ + + while (Arg) + { + Arg->Common.Parent = Op; + Arg = Arg->Common.Next; + + Op->Common.ArgListLength++; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsGetDepthNext + * + * PARAMETERS: Origin - Root of subtree to search + * Op - Last (previous) Op that was found + * + * RETURN: Next Op found in the search. + * + * DESCRIPTION: Get next op in tree (walking the tree in depth-first order) + * Return NULL when reaching "origin" or when walking up from root + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT * +AcpiPsGetDepthNext ( + ACPI_PARSE_OBJECT *Origin, + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PARSE_OBJECT *Next = NULL; + ACPI_PARSE_OBJECT *Parent; + ACPI_PARSE_OBJECT *Arg; + + + ACPI_FUNCTION_ENTRY (); + + + if (!Op) + { + return (NULL); + } + + /* Look for an argument or child */ + + Next = AcpiPsGetArg (Op, 0); + if (Next) + { + return (Next); + } + + /* Look for a sibling */ + + Next = Op->Common.Next; + if (Next) + { + return (Next); + } + + /* Look for a sibling of parent */ + + Parent = Op->Common.Parent; + + while (Parent) + { + Arg = AcpiPsGetArg (Parent, 0); + while (Arg && (Arg != Origin) && (Arg != Op)) + { + Arg = Arg->Common.Next; + } + + if (Arg == Origin) + { + /* Reached parent of origin, end search */ + + return (NULL); + } + + if (Parent->Common.Next) + { + /* Found sibling of parent */ + + return (Parent->Common.Next); + } + + Op = Parent; + Parent = Parent->Common.Parent; + } + + return (Next); +} + + +#ifdef ACPI_OBSOLETE_FUNCTIONS +/******************************************************************************* + * + * FUNCTION: AcpiPsGetChild + * + * PARAMETERS: Op - Get the child of this Op + * + * RETURN: Child Op, Null if none is found. + * + * DESCRIPTION: Get op's children or NULL if none + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT * +AcpiPsGetChild ( + ACPI_PARSE_OBJECT *Op) +{ + ACPI_PARSE_OBJECT *Child = NULL; + + + ACPI_FUNCTION_ENTRY (); + + + switch (Op->Common.AmlOpcode) + { + case AML_SCOPE_OP: + case AML_ELSE_OP: + case AML_DEVICE_OP: + case AML_THERMAL_ZONE_OP: + case AML_INT_METHODCALL_OP: + + Child = AcpiPsGetArg (Op, 0); + break; + + + case AML_BUFFER_OP: + case AML_PACKAGE_OP: + case AML_METHOD_OP: + case AML_IF_OP: + case AML_WHILE_OP: + case AML_FIELD_OP: + + Child = AcpiPsGetArg (Op, 1); + break; + + + case AML_POWER_RES_OP: + case AML_INDEX_FIELD_OP: + + Child = AcpiPsGetArg (Op, 2); + break; + + + case AML_PROCESSOR_OP: + case AML_BANK_FIELD_OP: + + Child = AcpiPsGetArg (Op, 3); + break; + + + default: + /* All others have no children */ + break; + } + + return (Child); +} +#endif + + diff --git a/reactos/drivers/bus/acpi/acpica/parser/psutils.c b/reactos/drivers/bus/acpi/acpica/parser/psutils.c new file mode 100644 index 00000000000..42f2b015d6c --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/parser/psutils.c @@ -0,0 +1,362 @@ +/****************************************************************************** + * + * Module Name: psutils - Parser miscellaneous utilities (Parser only) + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 "acpi.h" +#include "accommon.h" +#include "acparser.h" +#include "amlcode.h" + +#define _COMPONENT ACPI_PARSER + ACPI_MODULE_NAME ("psutils") + + +/******************************************************************************* + * + * FUNCTION: AcpiPsCreateScopeOp + * + * PARAMETERS: None + * + * RETURN: A new Scope object, null on failure + * + * DESCRIPTION: Create a Scope and associated namepath op with the root name + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT * +AcpiPsCreateScopeOp ( + void) +{ + ACPI_PARSE_OBJECT *ScopeOp; + + + ScopeOp = AcpiPsAllocOp (AML_SCOPE_OP); + if (!ScopeOp) + { + return (NULL); + } + + ScopeOp->Named.Name = ACPI_ROOT_NAME; + return (ScopeOp); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsInitOp + * + * PARAMETERS: Op - A newly allocated Op object + * Opcode - Opcode to store in the Op + * + * RETURN: None + * + * DESCRIPTION: Initialize a parse (Op) object + * + ******************************************************************************/ + +void +AcpiPsInitOp ( + ACPI_PARSE_OBJECT *Op, + UINT16 Opcode) +{ + ACPI_FUNCTION_ENTRY (); + + + Op->Common.DescriptorType = ACPI_DESC_TYPE_PARSER; + Op->Common.AmlOpcode = Opcode; + + ACPI_DISASM_ONLY_MEMBERS (ACPI_STRNCPY (Op->Common.AmlOpName, + (AcpiPsGetOpcodeInfo (Opcode))->Name, + sizeof (Op->Common.AmlOpName))); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsAllocOp + * + * PARAMETERS: Opcode - Opcode that will be stored in the new Op + * + * RETURN: Pointer to the new Op, null on failure + * + * DESCRIPTION: Allocate an acpi_op, choose op type (and thus size) based on + * opcode. A cache of opcodes is available for the pure + * GENERIC_OP, since this is by far the most commonly used. + * + ******************************************************************************/ + +ACPI_PARSE_OBJECT* +AcpiPsAllocOp ( + UINT16 Opcode) +{ + ACPI_PARSE_OBJECT *Op; + const ACPI_OPCODE_INFO *OpInfo; + UINT8 Flags = ACPI_PARSEOP_GENERIC; + + + ACPI_FUNCTION_ENTRY (); + + + OpInfo = AcpiPsGetOpcodeInfo (Opcode); + + /* Determine type of ParseOp required */ + + if (OpInfo->Flags & AML_DEFER) + { + Flags = ACPI_PARSEOP_DEFERRED; + } + else if (OpInfo->Flags & AML_NAMED) + { + Flags = ACPI_PARSEOP_NAMED; + } + else if (Opcode == AML_INT_BYTELIST_OP) + { + Flags = ACPI_PARSEOP_BYTELIST; + } + + /* Allocate the minimum required size object */ + + if (Flags == ACPI_PARSEOP_GENERIC) + { + /* The generic op (default) is by far the most common (16 to 1) */ + + Op = AcpiOsAcquireObject (AcpiGbl_PsNodeCache); + } + else + { + /* Extended parseop */ + + Op = AcpiOsAcquireObject (AcpiGbl_PsNodeExtCache); + } + + /* Initialize the Op */ + + if (Op) + { + AcpiPsInitOp (Op, Opcode); + Op->Common.Flags = Flags; + } + + return (Op); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsFreeOp + * + * PARAMETERS: Op - Op to be freed + * + * RETURN: None. + * + * DESCRIPTION: Free an Op object. Either put it on the GENERIC_OP cache list + * or actually free it. + * + ******************************************************************************/ + +void +AcpiPsFreeOp ( + ACPI_PARSE_OBJECT *Op) +{ + ACPI_FUNCTION_NAME (PsFreeOp); + + + if (Op->Common.AmlOpcode == AML_INT_RETURN_VALUE_OP) + { + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Free retval op: %p\n", Op)); + } + + if (Op->Common.Flags & ACPI_PARSEOP_GENERIC) + { + (void) AcpiOsReleaseObject (AcpiGbl_PsNodeCache, Op); + } + else + { + (void) AcpiOsReleaseObject (AcpiGbl_PsNodeExtCache, Op); + } +} + + +/******************************************************************************* + * + * FUNCTION: Utility functions + * + * DESCRIPTION: Low level character and object functions + * + ******************************************************************************/ + + +/* + * Is "c" a namestring lead character? + */ +BOOLEAN +AcpiPsIsLeadingChar ( + UINT32 c) +{ + return ((BOOLEAN) (c == '_' || (c >= 'A' && c <= 'Z'))); +} + + +/* + * Is "c" a namestring prefix character? + */ +BOOLEAN +AcpiPsIsPrefixChar ( + UINT32 c) +{ + return ((BOOLEAN) (c == '\\' || c == '^')); +} + + +/* + * Get op's name (4-byte name segment) or 0 if unnamed + */ +UINT32 +AcpiPsGetName ( + ACPI_PARSE_OBJECT *Op) +{ + + /* The "generic" object has no name associated with it */ + + if (Op->Common.Flags & ACPI_PARSEOP_GENERIC) + { + return (0); + } + + /* Only the "Extended" parse objects have a name */ + + return (Op->Named.Name); +} + + +/* + * Set op's name + */ +void +AcpiPsSetName ( + ACPI_PARSE_OBJECT *Op, + UINT32 name) +{ + + /* The "generic" object has no name associated with it */ + + if (Op->Common.Flags & ACPI_PARSEOP_GENERIC) + { + return; + } + + Op->Named.Name = name; +} + diff --git a/reactos/drivers/bus/acpi/acpica/parser/pswalk.c b/reactos/drivers/bus/acpi/acpica/parser/pswalk.c new file mode 100644 index 00000000000..d8d5f5e6f21 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/parser/pswalk.c @@ -0,0 +1,193 @@ +/****************************************************************************** + * + * Module Name: pswalk - Parser routines to walk parsed op tree(s) + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 "acpi.h" +#include "accommon.h" +#include "acparser.h" + +#define _COMPONENT ACPI_PARSER + ACPI_MODULE_NAME ("pswalk") + + +/******************************************************************************* + * + * FUNCTION: AcpiPsDeleteParseTree + * + * PARAMETERS: SubtreeRoot - Root of tree (or subtree) to delete + * + * RETURN: None + * + * DESCRIPTION: Delete a portion of or an entire parse tree. + * + ******************************************************************************/ + +void +AcpiPsDeleteParseTree ( + ACPI_PARSE_OBJECT *SubtreeRoot) +{ + ACPI_PARSE_OBJECT *Op = SubtreeRoot; + ACPI_PARSE_OBJECT *Next = NULL; + ACPI_PARSE_OBJECT *Parent = NULL; + + + ACPI_FUNCTION_TRACE_PTR (PsDeleteParseTree, SubtreeRoot); + + + /* Visit all nodes in the subtree */ + + while (Op) + { + /* Check if we are not ascending */ + + if (Op != Parent) + { + /* Look for an argument or child of the current op */ + + Next = AcpiPsGetArg (Op, 0); + if (Next) + { + /* Still going downward in tree (Op is not completed yet) */ + + Op = Next; + continue; + } + } + + /* No more children, this Op is complete. */ + + Next = Op->Common.Next; + Parent = Op->Common.Parent; + + AcpiPsFreeOp (Op); + + /* If we are back to the starting point, the walk is complete. */ + + if (Op == SubtreeRoot) + { + return_VOID; + } + if (Next) + { + Op = Next; + } + else + { + Op = Parent; + } + } + + return_VOID; +} diff --git a/reactos/drivers/bus/acpi/acpica/parser/psxface.c b/reactos/drivers/bus/acpi/acpica/parser/psxface.c new file mode 100644 index 00000000000..1bf36e01c93 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/parser/psxface.c @@ -0,0 +1,510 @@ +/****************************************************************************** + * + * Module Name: psxface - Parser external interfaces + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __PSXFACE_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acparser.h" +#include "acdispat.h" +#include "acinterp.h" +#include "amlcode.h" + + +#define _COMPONENT ACPI_PARSER + ACPI_MODULE_NAME ("psxface") + +/* Local Prototypes */ + +static void +AcpiPsStartTrace ( + ACPI_EVALUATE_INFO *Info); + +static void +AcpiPsStopTrace ( + ACPI_EVALUATE_INFO *Info); + +static void +AcpiPsUpdateParameterList ( + ACPI_EVALUATE_INFO *Info, + UINT16 Action); + + +/******************************************************************************* + * + * FUNCTION: AcpiDebugTrace + * + * PARAMETERS: MethodName - Valid ACPI name string + * DebugLevel - Optional level mask. 0 to use default + * DebugLayer - Optional layer mask. 0 to use default + * Flags - bit 1: one shot(1) or persistent(0) + * + * RETURN: Status + * + * DESCRIPTION: External interface to enable debug tracing during control + * method execution + * + ******************************************************************************/ + +ACPI_STATUS +AcpiDebugTrace ( + char *Name, + UINT32 DebugLevel, + UINT32 DebugLayer, + UINT32 Flags) +{ + ACPI_STATUS Status; + + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* TBDs: Validate name, allow full path or just nameseg */ + + AcpiGbl_TraceMethodName = *ACPI_CAST_PTR (UINT32, Name); + AcpiGbl_TraceFlags = Flags; + + if (DebugLevel) + { + AcpiGbl_TraceDbgLevel = DebugLevel; + } + if (DebugLayer) + { + AcpiGbl_TraceDbgLayer = DebugLayer; + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsStartTrace + * + * PARAMETERS: Info - Method info struct + * + * RETURN: None + * + * DESCRIPTION: Start control method execution trace + * + ******************************************************************************/ + +static void +AcpiPsStartTrace ( + ACPI_EVALUATE_INFO *Info) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_ENTRY (); + + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return; + } + + if ((!AcpiGbl_TraceMethodName) || + (AcpiGbl_TraceMethodName != Info->ResolvedNode->Name.Integer)) + { + goto Exit; + } + + AcpiGbl_OriginalDbgLevel = AcpiDbgLevel; + AcpiGbl_OriginalDbgLayer = AcpiDbgLayer; + + AcpiDbgLevel = 0x00FFFFFF; + AcpiDbgLayer = ACPI_UINT32_MAX; + + if (AcpiGbl_TraceDbgLevel) + { + AcpiDbgLevel = AcpiGbl_TraceDbgLevel; + } + if (AcpiGbl_TraceDbgLayer) + { + AcpiDbgLayer = AcpiGbl_TraceDbgLayer; + } + + +Exit: + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsStopTrace + * + * PARAMETERS: Info - Method info struct + * + * RETURN: None + * + * DESCRIPTION: Stop control method execution trace + * + ******************************************************************************/ + +static void +AcpiPsStopTrace ( + ACPI_EVALUATE_INFO *Info) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_ENTRY (); + + + Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); + if (ACPI_FAILURE (Status)) + { + return; + } + + if ((!AcpiGbl_TraceMethodName) || + (AcpiGbl_TraceMethodName != Info->ResolvedNode->Name.Integer)) + { + goto Exit; + } + + /* Disable further tracing if type is one-shot */ + + if (AcpiGbl_TraceFlags & 1) + { + AcpiGbl_TraceMethodName = 0; + AcpiGbl_TraceDbgLevel = 0; + AcpiGbl_TraceDbgLayer = 0; + } + + AcpiDbgLevel = AcpiGbl_OriginalDbgLevel; + AcpiDbgLayer = AcpiGbl_OriginalDbgLayer; + +Exit: + (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsExecuteMethod + * + * PARAMETERS: Info - Method info block, contains: + * Node - Method Node to execute + * ObjDesc - Method object + * Parameters - List of parameters to pass to the method, + * terminated by NULL. Params itself may be + * NULL if no parameters are being passed. + * ReturnObject - Where to put method's return value (if + * any). If NULL, no value is returned. + * ParameterType - Type of Parameter list + * ReturnObject - Where to put method's return value (if + * any). If NULL, no value is returned. + * PassNumber - Parse or execute pass + * + * RETURN: Status + * + * DESCRIPTION: Execute a control method + * + ******************************************************************************/ + +ACPI_STATUS +AcpiPsExecuteMethod ( + ACPI_EVALUATE_INFO *Info) +{ + ACPI_STATUS Status; + ACPI_PARSE_OBJECT *Op; + ACPI_WALK_STATE *WalkState; + + + ACPI_FUNCTION_TRACE (PsExecuteMethod); + + + /* Validate the Info and method Node */ + + if (!Info || !Info->ResolvedNode) + { + return_ACPI_STATUS (AE_NULL_ENTRY); + } + + /* Init for new method, wait on concurrency semaphore */ + + Status = AcpiDsBeginMethodExecution (Info->ResolvedNode, Info->ObjDesc, NULL); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * The caller "owns" the parameters, so give each one an extra reference + */ + AcpiPsUpdateParameterList (Info, REF_INCREMENT); + + /* Begin tracing if requested */ + + AcpiPsStartTrace (Info); + + /* + * Execute the method. Performs parse simultaneously + */ + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, + "**** Begin Method Parse/Execute [%4.4s] **** Node=%p Obj=%p\n", + Info->ResolvedNode->Name.Ascii, Info->ResolvedNode, Info->ObjDesc)); + + /* Create and init a Root Node */ + + Op = AcpiPsCreateScopeOp (); + if (!Op) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + /* Create and initialize a new walk state */ + + Info->PassNumber = ACPI_IMODE_EXECUTE; + WalkState = AcpiDsCreateWalkState ( + Info->ObjDesc->Method.OwnerId, NULL, NULL, NULL); + if (!WalkState) + { + Status = AE_NO_MEMORY; + goto Cleanup; + } + + Status = AcpiDsInitAmlWalk (WalkState, Op, Info->ResolvedNode, + Info->ObjDesc->Method.AmlStart, + Info->ObjDesc->Method.AmlLength, Info, Info->PassNumber); + if (ACPI_FAILURE (Status)) + { + AcpiDsDeleteWalkState (WalkState); + goto Cleanup; + } + + if (Info->ObjDesc->Method.Flags & AOPOBJ_MODULE_LEVEL) + { + WalkState->ParseFlags |= ACPI_PARSE_MODULE_LEVEL; + } + + /* Invoke an internal method if necessary */ + + if (Info->ObjDesc->Method.MethodFlags & AML_METHOD_INTERNAL_ONLY) + { + Status = Info->ObjDesc->Method.Extra.Implementation (WalkState); + Info->ReturnObject = WalkState->ReturnDesc; + + /* Cleanup states */ + + AcpiDsScopeStackClear (WalkState); + AcpiPsCleanupScope (&WalkState->ParserState); + AcpiDsTerminateControlMethod (WalkState->MethodDesc, WalkState); + AcpiDsDeleteWalkState (WalkState); + goto Cleanup; + } + + /* + * Start method evaluation with an implicit return of zero. This is done + * for Windows compatibility. + */ + if (AcpiGbl_EnableInterpreterSlack) + { + WalkState->ImplicitReturnObj = + AcpiUtCreateIntegerObject ((UINT64) 0); + if (!WalkState->ImplicitReturnObj) + { + Status = AE_NO_MEMORY; + AcpiDsDeleteWalkState (WalkState); + goto Cleanup; + } + } + + /* Parse the AML */ + + Status = AcpiPsParseAml (WalkState); + + /* WalkState was deleted by ParseAml */ + +Cleanup: + AcpiPsDeleteParseTree (Op); + + /* End optional tracing */ + + AcpiPsStopTrace (Info); + + /* Take away the extra reference that we gave the parameters above */ + + AcpiPsUpdateParameterList (Info, REF_DECREMENT); + + /* Exit now if error above */ + + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * If the method has returned an object, signal this to the caller with + * a control exception code + */ + if (Info->ReturnObject) + { + ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Method returned ObjDesc=%p\n", + Info->ReturnObject)); + ACPI_DUMP_STACK_ENTRY (Info->ReturnObject); + + Status = AE_CTRL_RETURN_VALUE; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiPsUpdateParameterList + * + * PARAMETERS: Info - See ACPI_EVALUATE_INFO + * (Used: ParameterType and Parameters) + * Action - Add or Remove reference + * + * RETURN: Status + * + * DESCRIPTION: Update reference count on all method parameter objects + * + ******************************************************************************/ + +static void +AcpiPsUpdateParameterList ( + ACPI_EVALUATE_INFO *Info, + UINT16 Action) +{ + UINT32 i; + + + if (Info->Parameters) + { + /* Update reference count for each parameter */ + + for (i = 0; Info->Parameters[i]; i++) + { + /* Ignore errors, just do them all */ + + (void) AcpiUtUpdateObjectReference (Info->Parameters[i], Action); + } + } +} + + diff --git a/reactos/drivers/bus/acpi/acpica/resources/rsaddr.c b/reactos/drivers/bus/acpi/acpica/resources/rsaddr.c new file mode 100644 index 00000000000..f2f3c4421f6 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/resources/rsaddr.c @@ -0,0 +1,479 @@ +/******************************************************************************* + * + * Module Name: rsaddr - Address resource descriptors (16/32/64) + * + ******************************************************************************/ + +/****************************************************************************** + * + * 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 __RSADDR_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acresrc.h" + +#define _COMPONENT ACPI_RESOURCES + ACPI_MODULE_NAME ("rsaddr") + + +/******************************************************************************* + * + * AcpiRsConvertAddress16 - All WORD (16-bit) address resources + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsConvertAddress16[5] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_ADDRESS16, + ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS16), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertAddress16)}, + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_ADDRESS16, + sizeof (AML_RESOURCE_ADDRESS16), + 0}, + + /* Resource Type, General Flags, and Type-Specific Flags */ + + {ACPI_RSC_ADDRESS, 0, 0, 0}, + + /* + * These fields are contiguous in both the source and destination: + * Address Granularity + * Address Range Minimum + * Address Range Maximum + * Address Translation Offset + * Address Length + */ + {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.Address16.Granularity), + AML_OFFSET (Address16.Granularity), + 5}, + + /* Optional ResourceSource (Index and String) */ + + {ACPI_RSC_SOURCE, ACPI_RS_OFFSET (Data.Address16.ResourceSource), + 0, + sizeof (AML_RESOURCE_ADDRESS16)} +}; + + +/******************************************************************************* + * + * AcpiRsConvertAddress32 - All DWORD (32-bit) address resources + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsConvertAddress32[5] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_ADDRESS32, + ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS32), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertAddress32)}, + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_ADDRESS32, + sizeof (AML_RESOURCE_ADDRESS32), + 0}, + + /* Resource Type, General Flags, and Type-Specific Flags */ + + {ACPI_RSC_ADDRESS, 0, 0, 0}, + + /* + * These fields are contiguous in both the source and destination: + * Address Granularity + * Address Range Minimum + * Address Range Maximum + * Address Translation Offset + * Address Length + */ + {ACPI_RSC_MOVE32, ACPI_RS_OFFSET (Data.Address32.Granularity), + AML_OFFSET (Address32.Granularity), + 5}, + + /* Optional ResourceSource (Index and String) */ + + {ACPI_RSC_SOURCE, ACPI_RS_OFFSET (Data.Address32.ResourceSource), + 0, + sizeof (AML_RESOURCE_ADDRESS32)} +}; + + +/******************************************************************************* + * + * AcpiRsConvertAddress64 - All QWORD (64-bit) address resources + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsConvertAddress64[5] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_ADDRESS64, + ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS64), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertAddress64)}, + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_ADDRESS64, + sizeof (AML_RESOURCE_ADDRESS64), + 0}, + + /* Resource Type, General Flags, and Type-Specific Flags */ + + {ACPI_RSC_ADDRESS, 0, 0, 0}, + + /* + * These fields are contiguous in both the source and destination: + * Address Granularity + * Address Range Minimum + * Address Range Maximum + * Address Translation Offset + * Address Length + */ + {ACPI_RSC_MOVE64, ACPI_RS_OFFSET (Data.Address64.Granularity), + AML_OFFSET (Address64.Granularity), + 5}, + + /* Optional ResourceSource (Index and String) */ + + {ACPI_RSC_SOURCE, ACPI_RS_OFFSET (Data.Address64.ResourceSource), + 0, + sizeof (AML_RESOURCE_ADDRESS64)} +}; + + +/******************************************************************************* + * + * AcpiRsConvertExtAddress64 - All Extended (64-bit) address resources + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsConvertExtAddress64[5] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64, + ACPI_RS_SIZE (ACPI_RESOURCE_EXTENDED_ADDRESS64), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertExtAddress64)}, + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64, + sizeof (AML_RESOURCE_EXTENDED_ADDRESS64), + 0}, + + /* Resource Type, General Flags, and Type-Specific Flags */ + + {ACPI_RSC_ADDRESS, 0, 0, 0}, + + /* Revision ID */ + + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.ExtAddress64.RevisionID), + AML_OFFSET (ExtAddress64.RevisionID), + 1}, + /* + * These fields are contiguous in both the source and destination: + * Address Granularity + * Address Range Minimum + * Address Range Maximum + * Address Translation Offset + * Address Length + * Type-Specific Attribute + */ + {ACPI_RSC_MOVE64, ACPI_RS_OFFSET (Data.ExtAddress64.Granularity), + AML_OFFSET (ExtAddress64.Granularity), + 6} +}; + + +/******************************************************************************* + * + * AcpiRsConvertGeneralFlags - Flags common to all address descriptors + * + ******************************************************************************/ + +static ACPI_RSCONVERT_INFO AcpiRsConvertGeneralFlags[6] = +{ + {ACPI_RSC_FLAGINIT, 0, AML_OFFSET (Address.Flags), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertGeneralFlags)}, + + /* Resource Type (Memory, Io, BusNumber, etc.) */ + + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Address.ResourceType), + AML_OFFSET (Address.ResourceType), + 1}, + + /* General Flags - Consume, Decode, MinFixed, MaxFixed */ + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.ProducerConsumer), + AML_OFFSET (Address.Flags), + 0}, + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.Decode), + AML_OFFSET (Address.Flags), + 1}, + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.MinAddressFixed), + AML_OFFSET (Address.Flags), + 2}, + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.MaxAddressFixed), + AML_OFFSET (Address.Flags), + 3} +}; + + +/******************************************************************************* + * + * AcpiRsConvertMemFlags - Flags common to Memory address descriptors + * + ******************************************************************************/ + +static ACPI_RSCONVERT_INFO AcpiRsConvertMemFlags[5] = +{ + {ACPI_RSC_FLAGINIT, 0, AML_OFFSET (Address.SpecificFlags), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertMemFlags)}, + + /* Memory-specific flags */ + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Mem.WriteProtect), + AML_OFFSET (Address.SpecificFlags), + 0}, + + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Mem.Caching), + AML_OFFSET (Address.SpecificFlags), + 1}, + + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Mem.RangeType), + AML_OFFSET (Address.SpecificFlags), + 3}, + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Mem.Translation), + AML_OFFSET (Address.SpecificFlags), + 5} +}; + + +/******************************************************************************* + * + * AcpiRsConvertIoFlags - Flags common to I/O address descriptors + * + ******************************************************************************/ + +static ACPI_RSCONVERT_INFO AcpiRsConvertIoFlags[4] = +{ + {ACPI_RSC_FLAGINIT, 0, AML_OFFSET (Address.SpecificFlags), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertIoFlags)}, + + /* I/O-specific flags */ + + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Io.RangeType), + AML_OFFSET (Address.SpecificFlags), + 0}, + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Io.Translation), + AML_OFFSET (Address.SpecificFlags), + 4}, + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Address.Info.Io.TranslationType), + AML_OFFSET (Address.SpecificFlags), + 5} +}; + + +/******************************************************************************* + * + * FUNCTION: AcpiRsGetAddressCommon + * + * PARAMETERS: Resource - Pointer to the internal resource struct + * Aml - Pointer to the AML resource descriptor + * + * RETURN: TRUE if the ResourceType field is OK, FALSE otherwise + * + * DESCRIPTION: Convert common flag fields from a raw AML resource descriptor + * to an internal resource descriptor + * + ******************************************************************************/ + +BOOLEAN +AcpiRsGetAddressCommon ( + ACPI_RESOURCE *Resource, + AML_RESOURCE *Aml) +{ + ACPI_FUNCTION_ENTRY (); + + + /* Validate the Resource Type */ + + if ((Aml->Address.ResourceType > 2) && (Aml->Address.ResourceType < 0xC0)) + { + return (FALSE); + } + + /* Get the Resource Type and General Flags */ + + (void) AcpiRsConvertAmlToResource (Resource, Aml, AcpiRsConvertGeneralFlags); + + /* Get the Type-Specific Flags (Memory and I/O descriptors only) */ + + if (Resource->Data.Address.ResourceType == ACPI_MEMORY_RANGE) + { + (void) AcpiRsConvertAmlToResource (Resource, Aml, AcpiRsConvertMemFlags); + } + else if (Resource->Data.Address.ResourceType == ACPI_IO_RANGE) + { + (void) AcpiRsConvertAmlToResource (Resource, Aml, AcpiRsConvertIoFlags); + } + else + { + /* Generic resource type, just grab the TypeSpecific byte */ + + Resource->Data.Address.Info.TypeSpecific = Aml->Address.SpecificFlags; + } + + return (TRUE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsSetAddressCommon + * + * PARAMETERS: Aml - Pointer to the AML resource descriptor + * Resource - Pointer to the internal resource struct + * + * RETURN: None + * + * DESCRIPTION: Convert common flag fields from a resource descriptor to an + * AML descriptor + * + ******************************************************************************/ + +void +AcpiRsSetAddressCommon ( + AML_RESOURCE *Aml, + ACPI_RESOURCE *Resource) +{ + ACPI_FUNCTION_ENTRY (); + + + /* Set the Resource Type and General Flags */ + + (void) AcpiRsConvertResourceToAml (Resource, Aml, AcpiRsConvertGeneralFlags); + + /* Set the Type-Specific Flags (Memory and I/O descriptors only) */ + + if (Resource->Data.Address.ResourceType == ACPI_MEMORY_RANGE) + { + (void) AcpiRsConvertResourceToAml (Resource, Aml, AcpiRsConvertMemFlags); + } + else if (Resource->Data.Address.ResourceType == ACPI_IO_RANGE) + { + (void) AcpiRsConvertResourceToAml (Resource, Aml, AcpiRsConvertIoFlags); + } + else + { + /* Generic resource type, just copy the TypeSpecific byte */ + + Aml->Address.SpecificFlags = Resource->Data.Address.Info.TypeSpecific; + } +} + + diff --git a/reactos/drivers/bus/acpi/acpica/resources/rscalc.c b/reactos/drivers/bus/acpi/acpica/resources/rscalc.c new file mode 100644 index 00000000000..76aa44ff839 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/resources/rscalc.c @@ -0,0 +1,745 @@ +/******************************************************************************* + * + * Module Name: rscalc - Calculate stream and list lengths + * + ******************************************************************************/ + +/****************************************************************************** + * + * 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 __RSCALC_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acresrc.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_RESOURCES + ACPI_MODULE_NAME ("rscalc") + + +/* Local prototypes */ + +static UINT8 +AcpiRsCountSetBits ( + UINT16 BitField); + +static ACPI_RS_LENGTH +AcpiRsStructOptionLength ( + ACPI_RESOURCE_SOURCE *ResourceSource); + +static UINT32 +AcpiRsStreamOptionLength ( + UINT32 ResourceLength, + UINT32 MinimumTotalLength); + + +/******************************************************************************* + * + * FUNCTION: AcpiRsCountSetBits + * + * PARAMETERS: BitField - Field in which to count bits + * + * RETURN: Number of bits set within the field + * + * DESCRIPTION: Count the number of bits set in a resource field. Used for + * (Short descriptor) interrupt and DMA lists. + * + ******************************************************************************/ + +static UINT8 +AcpiRsCountSetBits ( + UINT16 BitField) +{ + UINT8 BitsSet; + + + ACPI_FUNCTION_ENTRY (); + + + for (BitsSet = 0; BitField; BitsSet++) + { + /* Zero the least significant bit that is set */ + + BitField &= (UINT16) (BitField - 1); + } + + return (BitsSet); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsStructOptionLength + * + * PARAMETERS: ResourceSource - Pointer to optional descriptor field + * + * RETURN: Status + * + * DESCRIPTION: Common code to handle optional ResourceSourceIndex and + * ResourceSource fields in some Large descriptors. Used during + * list-to-stream conversion + * + ******************************************************************************/ + +static ACPI_RS_LENGTH +AcpiRsStructOptionLength ( + ACPI_RESOURCE_SOURCE *ResourceSource) +{ + ACPI_FUNCTION_ENTRY (); + + + /* + * If the ResourceSource string is valid, return the size of the string + * (StringLength includes the NULL terminator) plus the size of the + * ResourceSourceIndex (1). + */ + if (ResourceSource->StringPtr) + { + return ((ACPI_RS_LENGTH) (ResourceSource->StringLength + 1)); + } + + return (0); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsStreamOptionLength + * + * PARAMETERS: ResourceLength - Length from the resource header + * MinimumTotalLength - Minimum length of this resource, before + * any optional fields. Includes header size + * + * RETURN: Length of optional string (0 if no string present) + * + * DESCRIPTION: Common code to handle optional ResourceSourceIndex and + * ResourceSource fields in some Large descriptors. Used during + * stream-to-list conversion + * + ******************************************************************************/ + +static UINT32 +AcpiRsStreamOptionLength ( + UINT32 ResourceLength, + UINT32 MinimumAmlResourceLength) +{ + UINT32 StringLength = 0; + + + ACPI_FUNCTION_ENTRY (); + + + /* + * The ResourceSourceIndex and ResourceSource are optional elements of some + * Large-type resource descriptors. + */ + + /* + * If the length of the actual resource descriptor is greater than the ACPI + * spec-defined minimum length, it means that a ResourceSourceIndex exists + * and is followed by a (required) null terminated string. The string length + * (including the null terminator) is the resource length minus the minimum + * length, minus one byte for the ResourceSourceIndex itself. + */ + if (ResourceLength > MinimumAmlResourceLength) + { + /* Compute the length of the optional string */ + + StringLength = ResourceLength - MinimumAmlResourceLength - 1; + } + + /* + * Round the length up to a multiple of the native word in order to + * guarantee that the entire resource descriptor is native word aligned + */ + return ((UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (StringLength)); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsGetAmlLength + * + * PARAMETERS: Resource - Pointer to the resource linked list + * SizeNeeded - Where the required size is returned + * + * RETURN: Status + * + * DESCRIPTION: Takes a linked list of internal resource descriptors and + * calculates the size buffer needed to hold the corresponding + * external resource byte stream. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsGetAmlLength ( + ACPI_RESOURCE *Resource, + ACPI_SIZE *SizeNeeded) +{ + ACPI_SIZE AmlSizeNeeded = 0; + ACPI_RS_LENGTH TotalSize; + + + ACPI_FUNCTION_TRACE (RsGetAmlLength); + + + /* Traverse entire list of internal resource descriptors */ + + while (Resource) + { + /* Validate the descriptor type */ + + if (Resource->Type > ACPI_RESOURCE_TYPE_MAX) + { + return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE); + } + + /* Get the base size of the (external stream) resource descriptor */ + + TotalSize = AcpiGbl_AmlResourceSizes [Resource->Type]; + + /* + * Augment the base size for descriptors with optional and/or + * variable-length fields + */ + switch (Resource->Type) + { + case ACPI_RESOURCE_TYPE_IRQ: + + /* Length can be 3 or 2 */ + + if (Resource->Data.Irq.DescriptorLength == 2) + { + TotalSize--; + } + break; + + + case ACPI_RESOURCE_TYPE_START_DEPENDENT: + + /* Length can be 1 or 0 */ + + if (Resource->Data.Irq.DescriptorLength == 0) + { + TotalSize--; + } + break; + + + case ACPI_RESOURCE_TYPE_VENDOR: + /* + * Vendor Defined Resource: + * For a Vendor Specific resource, if the Length is between 1 and 7 + * it will be created as a Small Resource data type, otherwise it + * is a Large Resource data type. + */ + if (Resource->Data.Vendor.ByteLength > 7) + { + /* Base size of a Large resource descriptor */ + + TotalSize = sizeof (AML_RESOURCE_LARGE_HEADER); + } + + /* Add the size of the vendor-specific data */ + + TotalSize = (ACPI_RS_LENGTH) + (TotalSize + Resource->Data.Vendor.ByteLength); + break; + + + case ACPI_RESOURCE_TYPE_END_TAG: + /* + * End Tag: + * We are done -- return the accumulated total size. + */ + *SizeNeeded = AmlSizeNeeded + TotalSize; + + /* Normal exit */ + + return_ACPI_STATUS (AE_OK); + + + case ACPI_RESOURCE_TYPE_ADDRESS16: + /* + * 16-Bit Address Resource: + * Add the size of the optional ResourceSource info + */ + TotalSize = (ACPI_RS_LENGTH) + (TotalSize + AcpiRsStructOptionLength ( + &Resource->Data.Address16.ResourceSource)); + break; + + + case ACPI_RESOURCE_TYPE_ADDRESS32: + /* + * 32-Bit Address Resource: + * Add the size of the optional ResourceSource info + */ + TotalSize = (ACPI_RS_LENGTH) + (TotalSize + AcpiRsStructOptionLength ( + &Resource->Data.Address32.ResourceSource)); + break; + + + case ACPI_RESOURCE_TYPE_ADDRESS64: + /* + * 64-Bit Address Resource: + * Add the size of the optional ResourceSource info + */ + TotalSize = (ACPI_RS_LENGTH) + (TotalSize + AcpiRsStructOptionLength ( + &Resource->Data.Address64.ResourceSource)); + break; + + + case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: + /* + * Extended IRQ Resource: + * Add the size of each additional optional interrupt beyond the + * required 1 (4 bytes for each UINT32 interrupt number) + */ + TotalSize = (ACPI_RS_LENGTH) + (TotalSize + + ((Resource->Data.ExtendedIrq.InterruptCount - 1) * 4) + + + /* Add the size of the optional ResourceSource info */ + + AcpiRsStructOptionLength ( + &Resource->Data.ExtendedIrq.ResourceSource)); + break; + + + default: + break; + } + + /* Update the total */ + + AmlSizeNeeded += TotalSize; + + /* Point to the next object */ + + Resource = ACPI_ADD_PTR (ACPI_RESOURCE, Resource, Resource->Length); + } + + /* Did not find an EndTag resource descriptor */ + + return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsGetListLength + * + * PARAMETERS: AmlBuffer - Pointer to the resource byte stream + * AmlBufferLength - Size of AmlBuffer + * SizeNeeded - Where the size needed is returned + * + * RETURN: Status + * + * DESCRIPTION: Takes an external resource byte stream and calculates the size + * buffer needed to hold the corresponding internal resource + * descriptor linked list. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsGetListLength ( + UINT8 *AmlBuffer, + UINT32 AmlBufferLength, + ACPI_SIZE *SizeNeeded) +{ + ACPI_STATUS Status; + UINT8 *EndAml; + UINT8 *Buffer; + UINT32 BufferSize; + UINT16 Temp16; + UINT16 ResourceLength; + UINT32 ExtraStructBytes; + UINT8 ResourceIndex; + UINT8 MinimumAmlResourceLength; + + + ACPI_FUNCTION_TRACE (RsGetListLength); + + + *SizeNeeded = 0; + EndAml = AmlBuffer + AmlBufferLength; + + /* Walk the list of AML resource descriptors */ + + while (AmlBuffer < EndAml) + { + /* Validate the Resource Type and Resource Length */ + + Status = AcpiUtValidateResource (AmlBuffer, &ResourceIndex); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Get the resource length and base (minimum) AML size */ + + ResourceLength = AcpiUtGetResourceLength (AmlBuffer); + MinimumAmlResourceLength = AcpiGbl_ResourceAmlSizes[ResourceIndex]; + + /* + * Augment the size for descriptors with optional + * and/or variable length fields + */ + ExtraStructBytes = 0; + Buffer = AmlBuffer + AcpiUtGetResourceHeaderLength (AmlBuffer); + + switch (AcpiUtGetResourceType (AmlBuffer)) + { + case ACPI_RESOURCE_NAME_IRQ: + /* + * IRQ Resource: + * Get the number of bits set in the 16-bit IRQ mask + */ + ACPI_MOVE_16_TO_16 (&Temp16, Buffer); + ExtraStructBytes = AcpiRsCountSetBits (Temp16); + break; + + + case ACPI_RESOURCE_NAME_DMA: + /* + * DMA Resource: + * Get the number of bits set in the 8-bit DMA mask + */ + ExtraStructBytes = AcpiRsCountSetBits (*Buffer); + break; + + + case ACPI_RESOURCE_NAME_VENDOR_SMALL: + case ACPI_RESOURCE_NAME_VENDOR_LARGE: + /* + * Vendor Resource: + * Get the number of vendor data bytes + */ + ExtraStructBytes = ResourceLength; + break; + + + case ACPI_RESOURCE_NAME_END_TAG: + /* + * End Tag: + * This is the normal exit, add size of EndTag + */ + *SizeNeeded += ACPI_RS_SIZE_MIN; + return_ACPI_STATUS (AE_OK); + + + case ACPI_RESOURCE_NAME_ADDRESS32: + case ACPI_RESOURCE_NAME_ADDRESS16: + case ACPI_RESOURCE_NAME_ADDRESS64: + /* + * Address Resource: + * Add the size of the optional ResourceSource + */ + ExtraStructBytes = AcpiRsStreamOptionLength ( + ResourceLength, MinimumAmlResourceLength); + break; + + + case ACPI_RESOURCE_NAME_EXTENDED_IRQ: + /* + * Extended IRQ Resource: + * Using the InterruptTableLength, add 4 bytes for each additional + * interrupt. Note: at least one interrupt is required and is + * included in the minimum descriptor size (reason for the -1) + */ + ExtraStructBytes = (Buffer[1] - 1) * sizeof (UINT32); + + /* Add the size of the optional ResourceSource */ + + ExtraStructBytes += AcpiRsStreamOptionLength ( + ResourceLength - ExtraStructBytes, MinimumAmlResourceLength); + break; + + + default: + break; + } + + /* + * Update the required buffer size for the internal descriptor structs + * + * Important: Round the size up for the appropriate alignment. This + * is a requirement on IA64. + */ + BufferSize = AcpiGbl_ResourceStructSizes[ResourceIndex] + + ExtraStructBytes; + BufferSize = (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (BufferSize); + + *SizeNeeded += BufferSize; + + ACPI_DEBUG_PRINT ((ACPI_DB_RESOURCES, + "Type %.2X, AmlLength %.2X InternalLength %.2X\n", + AcpiUtGetResourceType (AmlBuffer), + AcpiUtGetDescriptorLength (AmlBuffer), BufferSize)); + + /* + * Point to the next resource within the AML stream using the length + * contained in the resource descriptor header + */ + AmlBuffer += AcpiUtGetDescriptorLength (AmlBuffer); + } + + /* Did not find an EndTag resource descriptor */ + + return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsGetPciRoutingTableLength + * + * PARAMETERS: PackageObject - Pointer to the package object + * BufferSizeNeeded - UINT32 pointer of the size buffer + * needed to properly return the + * parsed data + * + * RETURN: Status + * + * DESCRIPTION: Given a package representing a PCI routing table, this + * calculates the size of the corresponding linked list of + * descriptions. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsGetPciRoutingTableLength ( + ACPI_OPERAND_OBJECT *PackageObject, + ACPI_SIZE *BufferSizeNeeded) +{ + UINT32 NumberOfElements; + ACPI_SIZE TempSizeNeeded = 0; + ACPI_OPERAND_OBJECT **TopObjectList; + UINT32 Index; + ACPI_OPERAND_OBJECT *PackageElement; + ACPI_OPERAND_OBJECT **SubObjectList; + BOOLEAN NameFound; + UINT32 TableIndex; + + + ACPI_FUNCTION_TRACE (RsGetPciRoutingTableLength); + + + NumberOfElements = PackageObject->Package.Count; + + /* + * Calculate the size of the return buffer. + * The base size is the number of elements * the sizes of the + * structures. Additional space for the strings is added below. + * The minus one is to subtract the size of the UINT8 Source[1] + * member because it is added below. + * + * But each PRT_ENTRY structure has a pointer to a string and + * the size of that string must be found. + */ + TopObjectList = PackageObject->Package.Elements; + + for (Index = 0; Index < NumberOfElements; Index++) + { + /* Dereference the sub-package */ + + PackageElement = *TopObjectList; + + /* We must have a valid Package object */ + + if (!PackageElement || + (PackageElement->Common.Type != ACPI_TYPE_PACKAGE)) + { + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* + * The SubObjectList will now point to an array of the + * four IRQ elements: Address, Pin, Source and SourceIndex + */ + SubObjectList = PackageElement->Package.Elements; + + /* Scan the IrqTableElements for the Source Name String */ + + NameFound = FALSE; + + for (TableIndex = 0; TableIndex < 4 && !NameFound; TableIndex++) + { + if (*SubObjectList && /* Null object allowed */ + + ((ACPI_TYPE_STRING == + (*SubObjectList)->Common.Type) || + + ((ACPI_TYPE_LOCAL_REFERENCE == + (*SubObjectList)->Common.Type) && + + ((*SubObjectList)->Reference.Class == + ACPI_REFCLASS_NAME)))) + { + NameFound = TRUE; + } + else + { + /* Look at the next element */ + + SubObjectList++; + } + } + + TempSizeNeeded += (sizeof (ACPI_PCI_ROUTING_TABLE) - 4); + + /* Was a String type found? */ + + if (NameFound) + { + if ((*SubObjectList)->Common.Type == ACPI_TYPE_STRING) + { + /* + * The length String.Length field does not include the + * terminating NULL, add 1 + */ + TempSizeNeeded += ((ACPI_SIZE) + (*SubObjectList)->String.Length + 1); + } + else + { + TempSizeNeeded += AcpiNsGetPathnameLength ( + (*SubObjectList)->Reference.Node); + } + } + else + { + /* + * If no name was found, then this is a NULL, which is + * translated as a UINT32 zero. + */ + TempSizeNeeded += sizeof (UINT32); + } + + /* Round up the size since each element must be aligned */ + + TempSizeNeeded = ACPI_ROUND_UP_TO_64BIT (TempSizeNeeded); + + /* Point to the next ACPI_OPERAND_OBJECT */ + + TopObjectList++; + } + + /* + * Add an extra element to the end of the list, essentially a + * NULL terminator + */ + *BufferSizeNeeded = TempSizeNeeded + sizeof (ACPI_PCI_ROUTING_TABLE); + return_ACPI_STATUS (AE_OK); +} diff --git a/reactos/drivers/bus/acpi/acpica/resources/rscreate.c b/reactos/drivers/bus/acpi/acpica/resources/rscreate.c new file mode 100644 index 00000000000..e9c840b64e5 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/resources/rscreate.c @@ -0,0 +1,533 @@ +/******************************************************************************* + * + * Module Name: rscreate - Create resource lists/tables + * + ******************************************************************************/ + +/****************************************************************************** + * + * 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 __RSCREATE_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acresrc.h" +#include "acnamesp.h" + +#define _COMPONENT ACPI_RESOURCES + ACPI_MODULE_NAME ("rscreate") + + +/******************************************************************************* + * + * FUNCTION: AcpiRsCreateResourceList + * + * PARAMETERS: AmlBuffer - Pointer to the resource byte stream + * OutputBuffer - Pointer to the user's buffer + * + * RETURN: Status: AE_OK if okay, else a valid ACPI_STATUS code + * If OutputBuffer is not large enough, OutputBufferLength + * indicates how large OutputBuffer should be, else it + * indicates how may UINT8 elements of OutputBuffer are valid. + * + * DESCRIPTION: Takes the byte stream returned from a _CRS, _PRS control method + * execution and parses the stream to create a linked list + * of device resources. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsCreateResourceList ( + ACPI_OPERAND_OBJECT *AmlBuffer, + ACPI_BUFFER *OutputBuffer) +{ + + ACPI_STATUS Status; + UINT8 *AmlStart; + ACPI_SIZE ListSizeNeeded = 0; + UINT32 AmlBufferLength; + void *Resource; + + + ACPI_FUNCTION_TRACE (RsCreateResourceList); + + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "AmlBuffer = %p\n", + AmlBuffer)); + + /* Params already validated, so we don't re-validate here */ + + AmlBufferLength = AmlBuffer->Buffer.Length; + AmlStart = AmlBuffer->Buffer.Pointer; + + /* + * Pass the AmlBuffer into a module that can calculate + * the buffer size needed for the linked list + */ + Status = AcpiRsGetListLength (AmlStart, AmlBufferLength, + &ListSizeNeeded); + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Status=%X ListSizeNeeded=%X\n", + Status, (UINT32) ListSizeNeeded)); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Validate/Allocate/Clear caller buffer */ + + Status = AcpiUtInitializeBuffer (OutputBuffer, ListSizeNeeded); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Do the conversion */ + + Resource = OutputBuffer->Pointer; + Status = AcpiUtWalkAmlResources (AmlStart, AmlBufferLength, + AcpiRsConvertAmlToResources, &Resource); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n", + OutputBuffer->Pointer, (UINT32) OutputBuffer->Length)); + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsCreatePciRoutingTable + * + * PARAMETERS: PackageObject - Pointer to an ACPI_OPERAND_OBJECT + * package + * OutputBuffer - Pointer to the user's buffer + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code. + * If the OutputBuffer is too small, the error will be + * AE_BUFFER_OVERFLOW and OutputBuffer->Length will point + * to the size buffer needed. + * + * DESCRIPTION: Takes the ACPI_OPERAND_OBJECT package and creates a + * linked list of PCI interrupt descriptions + * + * NOTE: It is the caller's responsibility to ensure that the start of the + * output buffer is aligned properly (if necessary). + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsCreatePciRoutingTable ( + ACPI_OPERAND_OBJECT *PackageObject, + ACPI_BUFFER *OutputBuffer) +{ + UINT8 *Buffer; + ACPI_OPERAND_OBJECT **TopObjectList; + ACPI_OPERAND_OBJECT **SubObjectList; + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_SIZE BufferSizeNeeded = 0; + UINT32 NumberOfElements; + UINT32 Index; + ACPI_PCI_ROUTING_TABLE *UserPrt; + ACPI_NAMESPACE_NODE *Node; + ACPI_STATUS Status; + ACPI_BUFFER PathBuffer; + + + ACPI_FUNCTION_TRACE (RsCreatePciRoutingTable); + + + /* Params already validated, so we don't re-validate here */ + + /* Get the required buffer length */ + + Status = AcpiRsGetPciRoutingTableLength (PackageObject, + &BufferSizeNeeded); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "BufferSizeNeeded = %X\n", + (UINT32) BufferSizeNeeded)); + + /* Validate/Allocate/Clear caller buffer */ + + Status = AcpiUtInitializeBuffer (OutputBuffer, BufferSizeNeeded); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Loop through the ACPI_INTERNAL_OBJECTS - Each object should be a + * package that in turn contains an ACPI_INTEGER Address, a UINT8 Pin, + * a Name, and a UINT8 SourceIndex. + */ + TopObjectList = PackageObject->Package.Elements; + NumberOfElements = PackageObject->Package.Count; + Buffer = OutputBuffer->Pointer; + UserPrt = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, Buffer); + + for (Index = 0; Index < NumberOfElements; Index++) + { + /* + * Point UserPrt past this current structure + * + * NOTE: On the first iteration, UserPrt->Length will + * be zero because we cleared the return buffer earlier + */ + Buffer += UserPrt->Length; + UserPrt = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, Buffer); + + /* + * Fill in the Length field with the information we have at this point. + * The minus four is to subtract the size of the UINT8 Source[4] member + * because it is added below. + */ + UserPrt->Length = (sizeof (ACPI_PCI_ROUTING_TABLE) - 4); + + /* Each element of the top-level package must also be a package */ + + if ((*TopObjectList)->Common.Type != ACPI_TYPE_PACKAGE) + { + ACPI_ERROR ((AE_INFO, + "(PRT[%X]) Need sub-package, found %s", + Index, AcpiUtGetObjectTypeName (*TopObjectList))); + return_ACPI_STATUS (AE_AML_OPERAND_TYPE); + } + + /* Each sub-package must be of length 4 */ + + if ((*TopObjectList)->Package.Count != 4) + { + ACPI_ERROR ((AE_INFO, + "(PRT[%X]) Need package of length 4, found length %d", + Index, (*TopObjectList)->Package.Count)); + return_ACPI_STATUS (AE_AML_PACKAGE_LIMIT); + } + + /* + * Dereference the sub-package. + * The SubObjectList will now point to an array of the four IRQ + * elements: [Address, Pin, Source, SourceIndex] + */ + SubObjectList = (*TopObjectList)->Package.Elements; + + /* 1) First subobject: Dereference the PRT.Address */ + + ObjDesc = SubObjectList[0]; + if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER) + { + ACPI_ERROR ((AE_INFO, "(PRT[%X].Address) Need Integer, found %s", + Index, AcpiUtGetObjectTypeName (ObjDesc))); + return_ACPI_STATUS (AE_BAD_DATA); + } + + UserPrt->Address = ObjDesc->Integer.Value; + + /* 2) Second subobject: Dereference the PRT.Pin */ + + ObjDesc = SubObjectList[1]; + if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER) + { + ACPI_ERROR ((AE_INFO, "(PRT[%X].Pin) Need Integer, found %s", + Index, AcpiUtGetObjectTypeName (ObjDesc))); + return_ACPI_STATUS (AE_BAD_DATA); + } + + UserPrt->Pin = (UINT32) ObjDesc->Integer.Value; + + /* + * If the BIOS has erroneously reversed the _PRT SourceName (index 2) + * and the SourceIndex (index 3), fix it. _PRT is important enough to + * workaround this BIOS error. This also provides compatibility with + * other ACPI implementations. + */ + ObjDesc = SubObjectList[3]; + if (!ObjDesc || (ObjDesc->Common.Type != ACPI_TYPE_INTEGER)) + { + SubObjectList[3] = SubObjectList[2]; + SubObjectList[2] = ObjDesc; + + ACPI_WARNING ((AE_INFO, + "(PRT[%X].Source) SourceName and SourceIndex are reversed, fixed", + Index)); + } + + /* + * 3) Third subobject: Dereference the PRT.SourceName + * The name may be unresolved (slack mode), so allow a null object + */ + ObjDesc = SubObjectList[2]; + if (ObjDesc) + { + switch (ObjDesc->Common.Type) + { + case ACPI_TYPE_LOCAL_REFERENCE: + + if (ObjDesc->Reference.Class != ACPI_REFCLASS_NAME) + { + ACPI_ERROR ((AE_INFO, + "(PRT[%X].Source) Need name, found Reference Class %X", + Index, ObjDesc->Reference.Class)); + return_ACPI_STATUS (AE_BAD_DATA); + } + + Node = ObjDesc->Reference.Node; + + /* Use *remaining* length of the buffer as max for pathname */ + + PathBuffer.Length = OutputBuffer->Length - + (UINT32) ((UINT8 *) UserPrt->Source - + (UINT8 *) OutputBuffer->Pointer); + PathBuffer.Pointer = UserPrt->Source; + + Status = AcpiNsHandleToPathname ((ACPI_HANDLE) Node, &PathBuffer); + + /* +1 to include null terminator */ + + UserPrt->Length += (UINT32) ACPI_STRLEN (UserPrt->Source) + 1; + break; + + + case ACPI_TYPE_STRING: + + ACPI_STRCPY (UserPrt->Source, ObjDesc->String.Pointer); + + /* + * Add to the Length field the length of the string + * (add 1 for terminator) + */ + UserPrt->Length += ObjDesc->String.Length + 1; + break; + + + case ACPI_TYPE_INTEGER: + /* + * If this is a number, then the Source Name is NULL, since the + * entire buffer was zeroed out, we can leave this alone. + * + * Add to the Length field the length of the UINT32 NULL + */ + UserPrt->Length += sizeof (UINT32); + break; + + + default: + + ACPI_ERROR ((AE_INFO, + "(PRT[%X].Source) Need Ref/String/Integer, found %s", + Index, AcpiUtGetObjectTypeName (ObjDesc))); + return_ACPI_STATUS (AE_BAD_DATA); + } + } + + /* Now align the current length */ + + UserPrt->Length = (UINT32) ACPI_ROUND_UP_TO_64BIT (UserPrt->Length); + + /* 4) Fourth subobject: Dereference the PRT.SourceIndex */ + + ObjDesc = SubObjectList[3]; + if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER) + { + ACPI_ERROR ((AE_INFO, + "(PRT[%X].SourceIndex) Need Integer, found %s", + Index, AcpiUtGetObjectTypeName (ObjDesc))); + return_ACPI_STATUS (AE_BAD_DATA); + } + + UserPrt->SourceIndex = (UINT32) ObjDesc->Integer.Value; + + /* Point to the next ACPI_OPERAND_OBJECT in the top level package */ + + TopObjectList++; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n", + OutputBuffer->Pointer, (UINT32) OutputBuffer->Length)); + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsCreateAmlResources + * + * PARAMETERS: LinkedListBuffer - Pointer to the resource linked list + * OutputBuffer - Pointer to the user's buffer + * + * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code. + * If the OutputBuffer is too small, the error will be + * AE_BUFFER_OVERFLOW and OutputBuffer->Length will point + * to the size buffer needed. + * + * DESCRIPTION: Takes the linked list of device resources and + * creates a bytestream to be used as input for the + * _SRS control method. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsCreateAmlResources ( + ACPI_RESOURCE *LinkedListBuffer, + ACPI_BUFFER *OutputBuffer) +{ + ACPI_STATUS Status; + ACPI_SIZE AmlSizeNeeded = 0; + + + ACPI_FUNCTION_TRACE (RsCreateAmlResources); + + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "LinkedListBuffer = %p\n", + LinkedListBuffer)); + + /* + * Params already validated, so we don't re-validate here + * + * Pass the LinkedListBuffer into a module that calculates + * the buffer size needed for the byte stream. + */ + Status = AcpiRsGetAmlLength (LinkedListBuffer, + &AmlSizeNeeded); + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "AmlSizeNeeded=%X, %s\n", + (UINT32) AmlSizeNeeded, AcpiFormatException (Status))); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Validate/Allocate/Clear caller buffer */ + + Status = AcpiUtInitializeBuffer (OutputBuffer, AmlSizeNeeded); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Do the conversion */ + + Status = AcpiRsConvertResourcesToAml (LinkedListBuffer, AmlSizeNeeded, + OutputBuffer->Pointer); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n", + OutputBuffer->Pointer, (UINT32) OutputBuffer->Length)); + return_ACPI_STATUS (AE_OK); +} + diff --git a/reactos/drivers/bus/acpi/acpica/resources/rsdump.c b/reactos/drivers/bus/acpi/acpica/resources/rsdump.c new file mode 100644 index 00000000000..62db284c6f3 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/resources/rsdump.c @@ -0,0 +1,872 @@ +/******************************************************************************* + * + * Module Name: rsdump - Functions to display the resource structures. + * + ******************************************************************************/ + +/****************************************************************************** + * + * 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 __RSDUMP_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acresrc.h" + +#define _COMPONENT ACPI_RESOURCES + ACPI_MODULE_NAME ("rsdump") + + +#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) + +/* Local prototypes */ + +static void +AcpiRsOutString ( + char *Title, + char *Value); + +static void +AcpiRsOutInteger8 ( + char *Title, + UINT8 Value); + +static void +AcpiRsOutInteger16 ( + char *Title, + UINT16 Value); + +static void +AcpiRsOutInteger32 ( + char *Title, + UINT32 Value); + +static void +AcpiRsOutInteger64 ( + char *Title, + UINT64 Value); + +static void +AcpiRsOutTitle ( + char *Title); + +static void +AcpiRsDumpByteList ( + UINT16 Length, + UINT8 *Data); + +static void +AcpiRsDumpDwordList ( + UINT8 Length, + UINT32 *Data); + +static void +AcpiRsDumpShortByteList ( + UINT8 Length, + UINT8 *Data); + +static void +AcpiRsDumpResourceSource ( + ACPI_RESOURCE_SOURCE *ResourceSource); + +static void +AcpiRsDumpAddressCommon ( + ACPI_RESOURCE_DATA *Resource); + +static void +AcpiRsDumpDescriptor ( + void *Resource, + ACPI_RSDUMP_INFO *Table); + + +#define ACPI_RSD_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_RESOURCE_DATA,f) +#define ACPI_PRT_OFFSET(f) (UINT8) ACPI_OFFSET (ACPI_PCI_ROUTING_TABLE,f) +#define ACPI_RSD_TABLE_SIZE(name) (sizeof(name) / sizeof (ACPI_RSDUMP_INFO)) + + +/******************************************************************************* + * + * Resource Descriptor info tables + * + * Note: The first table entry must be a Title or Literal and must contain + * the table length (number of table entries) + * + ******************************************************************************/ + +ACPI_RSDUMP_INFO AcpiRsDumpIrq[7] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpIrq), "IRQ", NULL}, + {ACPI_RSD_UINT8 , ACPI_RSD_OFFSET (Irq.DescriptorLength), "Descriptor Length", NULL}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Irq.Triggering), "Triggering", AcpiGbl_HeDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Irq.Polarity), "Polarity", AcpiGbl_LlDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Irq.Sharable), "Sharing", AcpiGbl_ShrDecode}, + {ACPI_RSD_UINT8 , ACPI_RSD_OFFSET (Irq.InterruptCount), "Interrupt Count", NULL}, + {ACPI_RSD_SHORTLIST,ACPI_RSD_OFFSET (Irq.Interrupts[0]), "Interrupt List", NULL} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpDma[6] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpDma), "DMA", NULL}, + {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Dma.Type), "Speed", AcpiGbl_TypDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Dma.BusMaster), "Mastering", AcpiGbl_BmDecode}, + {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Dma.Transfer), "Transfer Type", AcpiGbl_SizDecode}, + {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (Dma.ChannelCount), "Channel Count", NULL}, + {ACPI_RSD_SHORTLIST,ACPI_RSD_OFFSET (Dma.Channels[0]), "Channel List", NULL} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpStartDpf[4] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpStartDpf), "Start-Dependent-Functions",NULL}, + {ACPI_RSD_UINT8 , ACPI_RSD_OFFSET (StartDpf.DescriptorLength), "Descriptor Length", NULL}, + {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (StartDpf.CompatibilityPriority), "Compatibility Priority", AcpiGbl_ConfigDecode}, + {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (StartDpf.PerformanceRobustness), "Performance/Robustness", AcpiGbl_ConfigDecode} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpEndDpf[1] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpEndDpf), "End-Dependent-Functions", NULL} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpIo[6] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpIo), "I/O", NULL}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Io.IoDecode), "Address Decoding", AcpiGbl_IoDecode}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Io.Minimum), "Address Minimum", NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Io.Maximum), "Address Maximum", NULL}, + {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (Io.Alignment), "Alignment", NULL}, + {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (Io.AddressLength), "Address Length", NULL} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpFixedIo[3] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpFixedIo), "Fixed I/O", NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (FixedIo.Address), "Address", NULL}, + {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (FixedIo.AddressLength), "Address Length", NULL} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpVendor[3] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpVendor), "Vendor Specific", NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Vendor.ByteLength), "Length", NULL}, + {ACPI_RSD_LONGLIST, ACPI_RSD_OFFSET (Vendor.ByteData[0]), "Vendor Data", NULL} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpEndTag[1] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpEndTag), "EndTag", NULL} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpMemory24[6] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpMemory24), "24-Bit Memory Range", NULL}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Memory24.WriteProtect), "Write Protect", AcpiGbl_RwDecode}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Memory24.Minimum), "Address Minimum", NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Memory24.Maximum), "Address Maximum", NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Memory24.Alignment), "Alignment", NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Memory24.AddressLength), "Address Length", NULL} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpMemory32[6] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpMemory32), "32-Bit Memory Range", NULL}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Memory32.WriteProtect), "Write Protect", AcpiGbl_RwDecode}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Memory32.Minimum), "Address Minimum", NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Memory32.Maximum), "Address Maximum", NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Memory32.Alignment), "Alignment", NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Memory32.AddressLength), "Address Length", NULL} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpFixedMemory32[4] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpFixedMemory32), "32-Bit Fixed Memory Range",NULL}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (FixedMemory32.WriteProtect), "Write Protect", AcpiGbl_RwDecode}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (FixedMemory32.Address), "Address", NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (FixedMemory32.AddressLength), "Address Length", NULL} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpAddress16[8] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpAddress16), "16-Bit WORD Address Space",NULL}, + {ACPI_RSD_ADDRESS, 0, NULL, NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Address16.Granularity), "Granularity", NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Address16.Minimum), "Address Minimum", NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Address16.Maximum), "Address Maximum", NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Address16.TranslationOffset), "Translation Offset", NULL}, + {ACPI_RSD_UINT16, ACPI_RSD_OFFSET (Address16.AddressLength), "Address Length", NULL}, + {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET (Address16.ResourceSource), NULL, NULL} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpAddress32[8] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpAddress32), "32-Bit DWORD Address Space", NULL}, + {ACPI_RSD_ADDRESS, 0, NULL, NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Address32.Granularity), "Granularity", NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Address32.Minimum), "Address Minimum", NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Address32.Maximum), "Address Maximum", NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Address32.TranslationOffset), "Translation Offset", NULL}, + {ACPI_RSD_UINT32, ACPI_RSD_OFFSET (Address32.AddressLength), "Address Length", NULL}, + {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET (Address32.ResourceSource), NULL, NULL} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpAddress64[8] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpAddress64), "64-Bit QWORD Address Space", NULL}, + {ACPI_RSD_ADDRESS, 0, NULL, NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (Address64.Granularity), "Granularity", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (Address64.Minimum), "Address Minimum", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (Address64.Maximum), "Address Maximum", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (Address64.TranslationOffset), "Translation Offset", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (Address64.AddressLength), "Address Length", NULL}, + {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET (Address64.ResourceSource), NULL, NULL} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpExtAddress64[8] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpExtAddress64), "64-Bit Extended Address Space", NULL}, + {ACPI_RSD_ADDRESS, 0, NULL, NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (ExtAddress64.Granularity), "Granularity", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (ExtAddress64.Minimum), "Address Minimum", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (ExtAddress64.Maximum), "Address Maximum", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (ExtAddress64.TranslationOffset), "Translation Offset", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (ExtAddress64.AddressLength), "Address Length", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (ExtAddress64.TypeSpecific), "Type-Specific Attribute", NULL} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpExtIrq[8] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpExtIrq), "Extended IRQ", NULL}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (ExtendedIrq.ProducerConsumer), "Type", AcpiGbl_ConsumeDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (ExtendedIrq.Triggering), "Triggering", AcpiGbl_HeDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (ExtendedIrq.Polarity), "Polarity", AcpiGbl_LlDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (ExtendedIrq.Sharable), "Sharing", AcpiGbl_ShrDecode}, + {ACPI_RSD_SOURCE, ACPI_RSD_OFFSET (ExtendedIrq.ResourceSource), NULL, NULL}, + {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (ExtendedIrq.InterruptCount), "Interrupt Count", NULL}, + {ACPI_RSD_DWORDLIST,ACPI_RSD_OFFSET (ExtendedIrq.Interrupts[0]), "Interrupt List", NULL} +}; + +ACPI_RSDUMP_INFO AcpiRsDumpGenericReg[6] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpGenericReg), "Generic Register", NULL}, + {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (GenericReg.SpaceId), "Space ID", NULL}, + {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (GenericReg.BitWidth), "Bit Width", NULL}, + {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (GenericReg.BitOffset), "Bit Offset", NULL}, + {ACPI_RSD_UINT8, ACPI_RSD_OFFSET (GenericReg.AccessSize), "Access Size", NULL}, + {ACPI_RSD_UINT64, ACPI_RSD_OFFSET (GenericReg.Address), "Address", NULL} +}; + + +/* + * Tables used for common address descriptor flag fields + */ +static ACPI_RSDUMP_INFO AcpiRsDumpGeneralFlags[5] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpGeneralFlags), NULL, NULL}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.ProducerConsumer), "Consumer/Producer", AcpiGbl_ConsumeDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Decode), "Address Decode", AcpiGbl_DecDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.MinAddressFixed), "Min Relocatability", AcpiGbl_MinDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.MaxAddressFixed), "Max Relocatability", AcpiGbl_MaxDecode} +}; + +static ACPI_RSDUMP_INFO AcpiRsDumpMemoryFlags[5] = +{ + {ACPI_RSD_LITERAL, ACPI_RSD_TABLE_SIZE (AcpiRsDumpMemoryFlags), "Resource Type", (void *) "Memory Range"}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Info.Mem.WriteProtect), "Write Protect", AcpiGbl_RwDecode}, + {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Address.Info.Mem.Caching), "Caching", AcpiGbl_MemDecode}, + {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Address.Info.Mem.RangeType), "Range Type", AcpiGbl_MtpDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Info.Mem.Translation), "Translation", AcpiGbl_TtpDecode} +}; + +static ACPI_RSDUMP_INFO AcpiRsDumpIoFlags[4] = +{ + {ACPI_RSD_LITERAL, ACPI_RSD_TABLE_SIZE (AcpiRsDumpIoFlags), "Resource Type", (void *) "I/O Range"}, + {ACPI_RSD_2BITFLAG, ACPI_RSD_OFFSET (Address.Info.Io.RangeType), "Range Type", AcpiGbl_RngDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Info.Io.Translation), "Translation", AcpiGbl_TtpDecode}, + {ACPI_RSD_1BITFLAG, ACPI_RSD_OFFSET (Address.Info.Io.TranslationType), "Translation Type", AcpiGbl_TrsDecode} +}; + + +/* + * Table used to dump _PRT contents + */ +static ACPI_RSDUMP_INFO AcpiRsDumpPrt[5] = +{ + {ACPI_RSD_TITLE, ACPI_RSD_TABLE_SIZE (AcpiRsDumpPrt), NULL, NULL}, + {ACPI_RSD_UINT64, ACPI_PRT_OFFSET (Address), "Address", NULL}, + {ACPI_RSD_UINT32, ACPI_PRT_OFFSET (Pin), "Pin", NULL}, + {ACPI_RSD_STRING, ACPI_PRT_OFFSET (Source[0]), "Source", NULL}, + {ACPI_RSD_UINT32, ACPI_PRT_OFFSET (SourceIndex), "Source Index", NULL} +}; + + +/******************************************************************************* + * + * FUNCTION: AcpiRsDumpDescriptor + * + * PARAMETERS: Resource + * + * RETURN: None + * + * DESCRIPTION: + * + ******************************************************************************/ + +static void +AcpiRsDumpDescriptor ( + void *Resource, + ACPI_RSDUMP_INFO *Table) +{ + UINT8 *Target = NULL; + UINT8 *PreviousTarget; + char *Name; + UINT8 Count; + + + /* First table entry must contain the table length (# of table entries) */ + + Count = Table->Offset; + + while (Count) + { + PreviousTarget = Target; + Target = ACPI_ADD_PTR (UINT8, Resource, Table->Offset); + Name = Table->Name; + + switch (Table->Opcode) + { + case ACPI_RSD_TITLE: + /* + * Optional resource title + */ + if (Table->Name) + { + AcpiOsPrintf ("%s Resource\n", Name); + } + break; + + /* Strings */ + + case ACPI_RSD_LITERAL: + AcpiRsOutString (Name, ACPI_CAST_PTR (char, Table->Pointer)); + break; + + case ACPI_RSD_STRING: + AcpiRsOutString (Name, ACPI_CAST_PTR (char, Target)); + break; + + /* Data items, 8/16/32/64 bit */ + + case ACPI_RSD_UINT8: + AcpiRsOutInteger8 (Name, ACPI_GET8 (Target)); + break; + + case ACPI_RSD_UINT16: + AcpiRsOutInteger16 (Name, ACPI_GET16 (Target)); + break; + + case ACPI_RSD_UINT32: + AcpiRsOutInteger32 (Name, ACPI_GET32 (Target)); + break; + + case ACPI_RSD_UINT64: + AcpiRsOutInteger64 (Name, ACPI_GET64 (Target)); + break; + + /* Flags: 1-bit and 2-bit flags supported */ + + case ACPI_RSD_1BITFLAG: + AcpiRsOutString (Name, ACPI_CAST_PTR (char, + Table->Pointer [*Target & 0x01])); + break; + + case ACPI_RSD_2BITFLAG: + AcpiRsOutString (Name, ACPI_CAST_PTR (char, + Table->Pointer [*Target & 0x03])); + break; + + case ACPI_RSD_SHORTLIST: + /* + * Short byte list (single line output) for DMA and IRQ resources + * Note: The list length is obtained from the previous table entry + */ + if (PreviousTarget) + { + AcpiRsOutTitle (Name); + AcpiRsDumpShortByteList (*PreviousTarget, Target); + } + break; + + case ACPI_RSD_LONGLIST: + /* + * Long byte list for Vendor resource data + * Note: The list length is obtained from the previous table entry + */ + if (PreviousTarget) + { + AcpiRsDumpByteList (ACPI_GET16 (PreviousTarget), Target); + } + break; + + case ACPI_RSD_DWORDLIST: + /* + * Dword list for Extended Interrupt resources + * Note: The list length is obtained from the previous table entry + */ + if (PreviousTarget) + { + AcpiRsDumpDwordList (*PreviousTarget, + ACPI_CAST_PTR (UINT32, Target)); + } + break; + + case ACPI_RSD_ADDRESS: + /* + * Common flags for all Address resources + */ + AcpiRsDumpAddressCommon (ACPI_CAST_PTR (ACPI_RESOURCE_DATA, Target)); + break; + + case ACPI_RSD_SOURCE: + /* + * Optional ResourceSource for Address resources + */ + AcpiRsDumpResourceSource (ACPI_CAST_PTR (ACPI_RESOURCE_SOURCE, Target)); + break; + + default: + AcpiOsPrintf ("**** Invalid table opcode [%X] ****\n", + Table->Opcode); + return; + } + + Table++; + Count--; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsDumpResourceSource + * + * PARAMETERS: ResourceSource - Pointer to a Resource Source struct + * + * RETURN: None + * + * DESCRIPTION: Common routine for dumping the optional ResourceSource and the + * corresponding ResourceSourceIndex. + * + ******************************************************************************/ + +static void +AcpiRsDumpResourceSource ( + ACPI_RESOURCE_SOURCE *ResourceSource) +{ + ACPI_FUNCTION_ENTRY (); + + + if (ResourceSource->Index == 0xFF) + { + return; + } + + AcpiRsOutInteger8 ("Resource Source Index", + ResourceSource->Index); + + AcpiRsOutString ("Resource Source", + ResourceSource->StringPtr ? + ResourceSource->StringPtr : "[Not Specified]"); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsDumpAddressCommon + * + * PARAMETERS: Resource - Pointer to an internal resource descriptor + * + * RETURN: None + * + * DESCRIPTION: Dump the fields that are common to all Address resource + * descriptors + * + ******************************************************************************/ + +static void +AcpiRsDumpAddressCommon ( + ACPI_RESOURCE_DATA *Resource) +{ + ACPI_FUNCTION_ENTRY (); + + + /* Decode the type-specific flags */ + + switch (Resource->Address.ResourceType) + { + case ACPI_MEMORY_RANGE: + + AcpiRsDumpDescriptor (Resource, AcpiRsDumpMemoryFlags); + break; + + case ACPI_IO_RANGE: + + AcpiRsDumpDescriptor (Resource, AcpiRsDumpIoFlags); + break; + + case ACPI_BUS_NUMBER_RANGE: + + AcpiRsOutString ("Resource Type", "Bus Number Range"); + break; + + default: + + AcpiRsOutInteger8 ("Resource Type", + (UINT8) Resource->Address.ResourceType); + break; + } + + /* Decode the general flags */ + + AcpiRsDumpDescriptor (Resource, AcpiRsDumpGeneralFlags); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsDumpResourceList + * + * PARAMETERS: ResourceList - Pointer to a resource descriptor list + * + * RETURN: None + * + * DESCRIPTION: Dispatches the structure to the correct dump routine. + * + ******************************************************************************/ + +void +AcpiRsDumpResourceList ( + ACPI_RESOURCE *ResourceList) +{ + UINT32 Count = 0; + UINT32 Type; + + + ACPI_FUNCTION_ENTRY (); + + + if (!(AcpiDbgLevel & ACPI_LV_RESOURCES) || !( _COMPONENT & AcpiDbgLayer)) + { + return; + } + + /* Walk list and dump all resource descriptors (END_TAG terminates) */ + + do + { + AcpiOsPrintf ("\n[%02X] ", Count); + Count++; + + /* Validate Type before dispatch */ + + Type = ResourceList->Type; + if (Type > ACPI_RESOURCE_TYPE_MAX) + { + AcpiOsPrintf ( + "Invalid descriptor type (%X) in resource list\n", + ResourceList->Type); + return; + } + + /* Dump the resource descriptor */ + + AcpiRsDumpDescriptor (&ResourceList->Data, + AcpiGbl_DumpResourceDispatch[Type]); + + /* Point to the next resource structure */ + + ResourceList = ACPI_ADD_PTR (ACPI_RESOURCE, ResourceList, + ResourceList->Length); + + /* Exit when END_TAG descriptor is reached */ + + } while (Type != ACPI_RESOURCE_TYPE_END_TAG); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsDumpIrqList + * + * PARAMETERS: RouteTable - Pointer to the routing table to dump. + * + * RETURN: None + * + * DESCRIPTION: Print IRQ routing table + * + ******************************************************************************/ + +void +AcpiRsDumpIrqList ( + UINT8 *RouteTable) +{ + ACPI_PCI_ROUTING_TABLE *PrtElement; + UINT8 Count; + + + ACPI_FUNCTION_ENTRY (); + + + if (!(AcpiDbgLevel & ACPI_LV_RESOURCES) || !( _COMPONENT & AcpiDbgLayer)) + { + return; + } + + PrtElement = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, RouteTable); + + /* Dump all table elements, Exit on zero length element */ + + for (Count = 0; PrtElement->Length; Count++) + { + AcpiOsPrintf ("\n[%02X] PCI IRQ Routing Table Package\n", Count); + AcpiRsDumpDescriptor (PrtElement, AcpiRsDumpPrt); + + PrtElement = ACPI_ADD_PTR (ACPI_PCI_ROUTING_TABLE, + PrtElement, PrtElement->Length); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsOut* + * + * PARAMETERS: Title - Name of the resource field + * Value - Value of the resource field + * + * RETURN: None + * + * DESCRIPTION: Miscellaneous helper functions to consistently format the + * output of the resource dump routines + * + ******************************************************************************/ + +static void +AcpiRsOutString ( + char *Title, + char *Value) +{ + AcpiOsPrintf ("%27s : %s", Title, Value); + if (!*Value) + { + AcpiOsPrintf ("[NULL NAMESTRING]"); + } + AcpiOsPrintf ("\n"); +} + +static void +AcpiRsOutInteger8 ( + char *Title, + UINT8 Value) +{ + AcpiOsPrintf ("%27s : %2.2X\n", Title, Value); +} + +static void +AcpiRsOutInteger16 ( + char *Title, + UINT16 Value) +{ + AcpiOsPrintf ("%27s : %4.4X\n", Title, Value); +} + +static void +AcpiRsOutInteger32 ( + char *Title, + UINT32 Value) +{ + AcpiOsPrintf ("%27s : %8.8X\n", Title, Value); +} + +static void +AcpiRsOutInteger64 ( + char *Title, + UINT64 Value) +{ + AcpiOsPrintf ("%27s : %8.8X%8.8X\n", Title, + ACPI_FORMAT_UINT64 (Value)); +} + +static void +AcpiRsOutTitle ( + char *Title) +{ + AcpiOsPrintf ("%27s : ", Title); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsDump*List + * + * PARAMETERS: Length - Number of elements in the list + * Data - Start of the list + * + * RETURN: None + * + * DESCRIPTION: Miscellaneous functions to dump lists of raw data + * + ******************************************************************************/ + +static void +AcpiRsDumpByteList ( + UINT16 Length, + UINT8 *Data) +{ + UINT8 i; + + + for (i = 0; i < Length; i++) + { + AcpiOsPrintf ("%25s%2.2X : %2.2X\n", + "Byte", i, Data[i]); + } +} + +static void +AcpiRsDumpShortByteList ( + UINT8 Length, + UINT8 *Data) +{ + UINT8 i; + + + for (i = 0; i < Length; i++) + { + AcpiOsPrintf ("%X ", Data[i]); + } + AcpiOsPrintf ("\n"); +} + +static void +AcpiRsDumpDwordList ( + UINT8 Length, + UINT32 *Data) +{ + UINT8 i; + + + for (i = 0; i < Length; i++) + { + AcpiOsPrintf ("%25s%2.2X : %8.8X\n", + "Dword", i, Data[i]); + } +} + +#endif + diff --git a/reactos/drivers/bus/acpi/acpica/resources/rsinfo.c b/reactos/drivers/bus/acpi/acpica/resources/rsinfo.c new file mode 100644 index 00000000000..abf79943d97 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/resources/rsinfo.c @@ -0,0 +1,290 @@ +/******************************************************************************* + * + * Module Name: rsinfo - Dispatch and Info tables + * + ******************************************************************************/ + +/****************************************************************************** + * + * 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 __RSINFO_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acresrc.h" + +#define _COMPONENT ACPI_RESOURCES + ACPI_MODULE_NAME ("rsinfo") + +/* + * Resource dispatch and information tables. Any new resource types (either + * Large or Small) must be reflected in each of these tables, so they are here + * in one place. + * + * The tables for Large descriptors are indexed by bits 6:0 of the AML + * descriptor type byte. The tables for Small descriptors are indexed by + * bits 6:3 of the descriptor byte. The tables for internal resource + * descriptors are indexed by the ACPI_RESOURCE_TYPE field. + */ + + +/* Dispatch table for resource-to-AML (Set Resource) conversion functions */ + +ACPI_RSCONVERT_INFO *AcpiGbl_SetResourceDispatch[] = +{ + AcpiRsSetIrq, /* 0x00, ACPI_RESOURCE_TYPE_IRQ */ + AcpiRsConvertDma, /* 0x01, ACPI_RESOURCE_TYPE_DMA */ + AcpiRsSetStartDpf, /* 0x02, ACPI_RESOURCE_TYPE_START_DEPENDENT */ + AcpiRsConvertEndDpf, /* 0x03, ACPI_RESOURCE_TYPE_END_DEPENDENT */ + AcpiRsConvertIo, /* 0x04, ACPI_RESOURCE_TYPE_IO */ + AcpiRsConvertFixedIo, /* 0x05, ACPI_RESOURCE_TYPE_FIXED_IO */ + AcpiRsSetVendor, /* 0x06, ACPI_RESOURCE_TYPE_VENDOR */ + AcpiRsConvertEndTag, /* 0x07, ACPI_RESOURCE_TYPE_END_TAG */ + AcpiRsConvertMemory24, /* 0x08, ACPI_RESOURCE_TYPE_MEMORY24 */ + AcpiRsConvertMemory32, /* 0x09, ACPI_RESOURCE_TYPE_MEMORY32 */ + AcpiRsConvertFixedMemory32, /* 0x0A, ACPI_RESOURCE_TYPE_FIXED_MEMORY32 */ + AcpiRsConvertAddress16, /* 0x0B, ACPI_RESOURCE_TYPE_ADDRESS16 */ + AcpiRsConvertAddress32, /* 0x0C, ACPI_RESOURCE_TYPE_ADDRESS32 */ + AcpiRsConvertAddress64, /* 0x0D, ACPI_RESOURCE_TYPE_ADDRESS64 */ + AcpiRsConvertExtAddress64, /* 0x0E, ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */ + AcpiRsConvertExtIrq, /* 0x0F, ACPI_RESOURCE_TYPE_EXTENDED_IRQ */ + AcpiRsConvertGenericReg /* 0x10, ACPI_RESOURCE_TYPE_GENERIC_REGISTER */ +}; + +/* Dispatch tables for AML-to-resource (Get Resource) conversion functions */ + +ACPI_RSCONVERT_INFO *AcpiGbl_GetResourceDispatch[] = +{ + /* Small descriptors */ + + NULL, /* 0x00, Reserved */ + NULL, /* 0x01, Reserved */ + NULL, /* 0x02, Reserved */ + NULL, /* 0x03, Reserved */ + AcpiRsGetIrq, /* 0x04, ACPI_RESOURCE_NAME_IRQ */ + AcpiRsConvertDma, /* 0x05, ACPI_RESOURCE_NAME_DMA */ + AcpiRsGetStartDpf, /* 0x06, ACPI_RESOURCE_NAME_START_DEPENDENT */ + AcpiRsConvertEndDpf, /* 0x07, ACPI_RESOURCE_NAME_END_DEPENDENT */ + AcpiRsConvertIo, /* 0x08, ACPI_RESOURCE_NAME_IO */ + AcpiRsConvertFixedIo, /* 0x09, ACPI_RESOURCE_NAME_FIXED_IO */ + NULL, /* 0x0A, Reserved */ + NULL, /* 0x0B, Reserved */ + NULL, /* 0x0C, Reserved */ + NULL, /* 0x0D, Reserved */ + AcpiRsGetVendorSmall, /* 0x0E, ACPI_RESOURCE_NAME_VENDOR_SMALL */ + AcpiRsConvertEndTag, /* 0x0F, ACPI_RESOURCE_NAME_END_TAG */ + + /* Large descriptors */ + + NULL, /* 0x00, Reserved */ + AcpiRsConvertMemory24, /* 0x01, ACPI_RESOURCE_NAME_MEMORY24 */ + AcpiRsConvertGenericReg, /* 0x02, ACPI_RESOURCE_NAME_GENERIC_REGISTER */ + NULL, /* 0x03, Reserved */ + AcpiRsGetVendorLarge, /* 0x04, ACPI_RESOURCE_NAME_VENDOR_LARGE */ + AcpiRsConvertMemory32, /* 0x05, ACPI_RESOURCE_NAME_MEMORY32 */ + AcpiRsConvertFixedMemory32, /* 0x06, ACPI_RESOURCE_NAME_FIXED_MEMORY32 */ + AcpiRsConvertAddress32, /* 0x07, ACPI_RESOURCE_NAME_ADDRESS32 */ + AcpiRsConvertAddress16, /* 0x08, ACPI_RESOURCE_NAME_ADDRESS16 */ + AcpiRsConvertExtIrq, /* 0x09, ACPI_RESOURCE_NAME_EXTENDED_IRQ */ + AcpiRsConvertAddress64, /* 0x0A, ACPI_RESOURCE_NAME_ADDRESS64 */ + AcpiRsConvertExtAddress64 /* 0x0B, ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64 */ +}; + + +#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) + +/* Dispatch table for resource dump functions */ + +ACPI_RSDUMP_INFO *AcpiGbl_DumpResourceDispatch[] = +{ + AcpiRsDumpIrq, /* ACPI_RESOURCE_TYPE_IRQ */ + AcpiRsDumpDma, /* ACPI_RESOURCE_TYPE_DMA */ + AcpiRsDumpStartDpf, /* ACPI_RESOURCE_TYPE_START_DEPENDENT */ + AcpiRsDumpEndDpf, /* ACPI_RESOURCE_TYPE_END_DEPENDENT */ + AcpiRsDumpIo, /* ACPI_RESOURCE_TYPE_IO */ + AcpiRsDumpFixedIo, /* ACPI_RESOURCE_TYPE_FIXED_IO */ + AcpiRsDumpVendor, /* ACPI_RESOURCE_TYPE_VENDOR */ + AcpiRsDumpEndTag, /* ACPI_RESOURCE_TYPE_END_TAG */ + AcpiRsDumpMemory24, /* ACPI_RESOURCE_TYPE_MEMORY24 */ + AcpiRsDumpMemory32, /* ACPI_RESOURCE_TYPE_MEMORY32 */ + AcpiRsDumpFixedMemory32, /* ACPI_RESOURCE_TYPE_FIXED_MEMORY32 */ + AcpiRsDumpAddress16, /* ACPI_RESOURCE_TYPE_ADDRESS16 */ + AcpiRsDumpAddress32, /* ACPI_RESOURCE_TYPE_ADDRESS32 */ + AcpiRsDumpAddress64, /* ACPI_RESOURCE_TYPE_ADDRESS64 */ + AcpiRsDumpExtAddress64, /* ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */ + AcpiRsDumpExtIrq, /* ACPI_RESOURCE_TYPE_EXTENDED_IRQ */ + AcpiRsDumpGenericReg, /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */ +}; +#endif + + +/* + * Base sizes for external AML resource descriptors, indexed by internal type. + * Includes size of the descriptor header (1 byte for small descriptors, + * 3 bytes for large descriptors) + */ +const UINT8 AcpiGbl_AmlResourceSizes[] = +{ + sizeof (AML_RESOURCE_IRQ), /* ACPI_RESOURCE_TYPE_IRQ (optional Byte 3 always created) */ + sizeof (AML_RESOURCE_DMA), /* ACPI_RESOURCE_TYPE_DMA */ + sizeof (AML_RESOURCE_START_DEPENDENT), /* ACPI_RESOURCE_TYPE_START_DEPENDENT (optional Byte 1 always created) */ + sizeof (AML_RESOURCE_END_DEPENDENT), /* ACPI_RESOURCE_TYPE_END_DEPENDENT */ + sizeof (AML_RESOURCE_IO), /* ACPI_RESOURCE_TYPE_IO */ + sizeof (AML_RESOURCE_FIXED_IO), /* ACPI_RESOURCE_TYPE_FIXED_IO */ + sizeof (AML_RESOURCE_VENDOR_SMALL), /* ACPI_RESOURCE_TYPE_VENDOR */ + sizeof (AML_RESOURCE_END_TAG), /* ACPI_RESOURCE_TYPE_END_TAG */ + sizeof (AML_RESOURCE_MEMORY24), /* ACPI_RESOURCE_TYPE_MEMORY24 */ + sizeof (AML_RESOURCE_MEMORY32), /* ACPI_RESOURCE_TYPE_MEMORY32 */ + sizeof (AML_RESOURCE_FIXED_MEMORY32), /* ACPI_RESOURCE_TYPE_FIXED_MEMORY32 */ + sizeof (AML_RESOURCE_ADDRESS16), /* ACPI_RESOURCE_TYPE_ADDRESS16 */ + sizeof (AML_RESOURCE_ADDRESS32), /* ACPI_RESOURCE_TYPE_ADDRESS32 */ + sizeof (AML_RESOURCE_ADDRESS64), /* ACPI_RESOURCE_TYPE_ADDRESS64 */ + sizeof (AML_RESOURCE_EXTENDED_ADDRESS64),/*ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64 */ + sizeof (AML_RESOURCE_EXTENDED_IRQ), /* ACPI_RESOURCE_TYPE_EXTENDED_IRQ */ + sizeof (AML_RESOURCE_GENERIC_REGISTER) /* ACPI_RESOURCE_TYPE_GENERIC_REGISTER */ +}; + + +const UINT8 AcpiGbl_ResourceStructSizes[] = +{ + /* Small descriptors */ + + 0, + 0, + 0, + 0, + ACPI_RS_SIZE (ACPI_RESOURCE_IRQ), + ACPI_RS_SIZE (ACPI_RESOURCE_DMA), + ACPI_RS_SIZE (ACPI_RESOURCE_START_DEPENDENT), + ACPI_RS_SIZE_MIN, + ACPI_RS_SIZE (ACPI_RESOURCE_IO), + ACPI_RS_SIZE (ACPI_RESOURCE_FIXED_IO), + 0, + 0, + 0, + 0, + ACPI_RS_SIZE (ACPI_RESOURCE_VENDOR), + ACPI_RS_SIZE_MIN, + + /* Large descriptors */ + + 0, + ACPI_RS_SIZE (ACPI_RESOURCE_MEMORY24), + ACPI_RS_SIZE (ACPI_RESOURCE_GENERIC_REGISTER), + 0, + ACPI_RS_SIZE (ACPI_RESOURCE_VENDOR), + ACPI_RS_SIZE (ACPI_RESOURCE_MEMORY32), + ACPI_RS_SIZE (ACPI_RESOURCE_FIXED_MEMORY32), + ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS32), + ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS16), + ACPI_RS_SIZE (ACPI_RESOURCE_EXTENDED_IRQ), + ACPI_RS_SIZE (ACPI_RESOURCE_ADDRESS64), + ACPI_RS_SIZE (ACPI_RESOURCE_EXTENDED_ADDRESS64) +}; + diff --git a/reactos/drivers/bus/acpi/acpica/resources/rsio.c b/reactos/drivers/bus/acpi/acpica/resources/rsio.c new file mode 100644 index 00000000000..fb9213dd72e --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/resources/rsio.c @@ -0,0 +1,376 @@ +/******************************************************************************* + * + * Module Name: rsio - IO and DMA resource descriptors + * + ******************************************************************************/ + +/****************************************************************************** + * + * 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 __RSIO_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acresrc.h" + +#define _COMPONENT ACPI_RESOURCES + ACPI_MODULE_NAME ("rsio") + + +/******************************************************************************* + * + * AcpiRsConvertIo + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsConvertIo[5] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_IO, + ACPI_RS_SIZE (ACPI_RESOURCE_IO), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertIo)}, + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_IO, + sizeof (AML_RESOURCE_IO), + 0}, + + /* Decode flag */ + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Io.IoDecode), + AML_OFFSET (Io.Flags), + 0}, + /* + * These fields are contiguous in both the source and destination: + * Address Alignment + * Length + * Minimum Base Address + * Maximum Base Address + */ + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Io.Alignment), + AML_OFFSET (Io.Alignment), + 2}, + + {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.Io.Minimum), + AML_OFFSET (Io.Minimum), + 2} +}; + + +/******************************************************************************* + * + * AcpiRsConvertFixedIo + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsConvertFixedIo[4] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_FIXED_IO, + ACPI_RS_SIZE (ACPI_RESOURCE_FIXED_IO), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertFixedIo)}, + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_FIXED_IO, + sizeof (AML_RESOURCE_FIXED_IO), + 0}, + /* + * These fields are contiguous in both the source and destination: + * Base Address + * Length + */ + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.FixedIo.AddressLength), + AML_OFFSET (FixedIo.AddressLength), + 1}, + + {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.FixedIo.Address), + AML_OFFSET (FixedIo.Address), + 1} +}; + + +/******************************************************************************* + * + * AcpiRsConvertGenericReg + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsConvertGenericReg[4] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_GENERIC_REGISTER, + ACPI_RS_SIZE (ACPI_RESOURCE_GENERIC_REGISTER), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertGenericReg)}, + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_GENERIC_REGISTER, + sizeof (AML_RESOURCE_GENERIC_REGISTER), + 0}, + /* + * These fields are contiguous in both the source and destination: + * Address Space ID + * Register Bit Width + * Register Bit Offset + * Access Size + */ + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.GenericReg.SpaceId), + AML_OFFSET (GenericReg.AddressSpaceId), + 4}, + + /* Get the Register Address */ + + {ACPI_RSC_MOVE64, ACPI_RS_OFFSET (Data.GenericReg.Address), + AML_OFFSET (GenericReg.Address), + 1} +}; + + +/******************************************************************************* + * + * AcpiRsConvertEndDpf + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsConvertEndDpf[2] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_END_DEPENDENT, + ACPI_RS_SIZE_MIN, + ACPI_RSC_TABLE_SIZE (AcpiRsConvertEndDpf)}, + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_END_DEPENDENT, + sizeof (AML_RESOURCE_END_DEPENDENT), + 0} +}; + + +/******************************************************************************* + * + * AcpiRsConvertEndTag + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsConvertEndTag[2] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_END_TAG, + ACPI_RS_SIZE_MIN, + ACPI_RSC_TABLE_SIZE (AcpiRsConvertEndTag)}, + + /* + * Note: The checksum field is set to zero, meaning that the resource + * data is treated as if the checksum operation succeeded. + * (ACPI Spec 1.0b Section 6.4.2.8) + */ + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_END_TAG, + sizeof (AML_RESOURCE_END_TAG), + 0} +}; + + +/******************************************************************************* + * + * AcpiRsGetStartDpf + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsGetStartDpf[6] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_START_DEPENDENT, + ACPI_RS_SIZE (ACPI_RESOURCE_START_DEPENDENT), + ACPI_RSC_TABLE_SIZE (AcpiRsGetStartDpf)}, + + /* Defaults for Compatibility and Performance priorities */ + + {ACPI_RSC_SET8, ACPI_RS_OFFSET (Data.StartDpf.CompatibilityPriority), + ACPI_ACCEPTABLE_CONFIGURATION, + 2}, + + /* Get the descriptor length (0 or 1 for Start Dpf descriptor) */ + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.StartDpf.DescriptorLength), + AML_OFFSET (StartDpf.DescriptorType), + 0}, + + /* All done if there is no flag byte present in the descriptor */ + + {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_AML_LENGTH, 0, 1}, + + /* Flag byte is present, get the flags */ + + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.StartDpf.CompatibilityPriority), + AML_OFFSET (StartDpf.Flags), + 0}, + + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.StartDpf.PerformanceRobustness), + AML_OFFSET (StartDpf.Flags), + 2} +}; + + +/******************************************************************************* + * + * AcpiRsSetStartDpf + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsSetStartDpf[10] = +{ + /* Start with a default descriptor of length 1 */ + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_START_DEPENDENT, + sizeof (AML_RESOURCE_START_DEPENDENT), + ACPI_RSC_TABLE_SIZE (AcpiRsSetStartDpf)}, + + /* Set the default flag values */ + + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.StartDpf.CompatibilityPriority), + AML_OFFSET (StartDpf.Flags), + 0}, + + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.StartDpf.PerformanceRobustness), + AML_OFFSET (StartDpf.Flags), + 2}, + /* + * All done if the output descriptor length is required to be 1 + * (i.e., optimization to 0 bytes cannot be attempted) + */ + {ACPI_RSC_EXIT_EQ, ACPI_RSC_COMPARE_VALUE, + ACPI_RS_OFFSET(Data.StartDpf.DescriptorLength), + 1}, + + /* Set length to 0 bytes (no flags byte) */ + + {ACPI_RSC_LENGTH, 0, 0, sizeof (AML_RESOURCE_START_DEPENDENT_NOPRIO)}, + + /* + * All done if the output descriptor length is required to be 0. + * + * TBD: Perhaps we should check for error if input flags are not + * compatible with a 0-byte descriptor. + */ + {ACPI_RSC_EXIT_EQ, ACPI_RSC_COMPARE_VALUE, + ACPI_RS_OFFSET(Data.StartDpf.DescriptorLength), + 0}, + + /* Reset length to 1 byte (descriptor with flags byte) */ + + {ACPI_RSC_LENGTH, 0, 0, sizeof (AML_RESOURCE_START_DEPENDENT)}, + + + /* + * All done if flags byte is necessary -- if either priority value + * is not ACPI_ACCEPTABLE_CONFIGURATION + */ + {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE, + ACPI_RS_OFFSET (Data.StartDpf.CompatibilityPriority), + ACPI_ACCEPTABLE_CONFIGURATION}, + + {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE, + ACPI_RS_OFFSET (Data.StartDpf.PerformanceRobustness), + ACPI_ACCEPTABLE_CONFIGURATION}, + + /* Flag byte is not necessary */ + + {ACPI_RSC_LENGTH, 0, 0, sizeof (AML_RESOURCE_START_DEPENDENT_NOPRIO)} +}; + + diff --git a/reactos/drivers/bus/acpi/acpica/resources/rsirq.c b/reactos/drivers/bus/acpi/acpica/resources/rsirq.c new file mode 100644 index 00000000000..7eab4351399 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/resources/rsirq.c @@ -0,0 +1,348 @@ +/******************************************************************************* + * + * Module Name: rsirq - IRQ resource descriptors + * + ******************************************************************************/ + +/****************************************************************************** + * + * 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 __RSIRQ_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acresrc.h" + +#define _COMPONENT ACPI_RESOURCES + ACPI_MODULE_NAME ("rsirq") + + +/******************************************************************************* + * + * AcpiRsGetIrq + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsGetIrq[8] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_IRQ, + ACPI_RS_SIZE (ACPI_RESOURCE_IRQ), + ACPI_RSC_TABLE_SIZE (AcpiRsGetIrq)}, + + /* Get the IRQ mask (bytes 1:2) */ + + {ACPI_RSC_BITMASK16,ACPI_RS_OFFSET (Data.Irq.Interrupts[0]), + AML_OFFSET (Irq.IrqMask), + ACPI_RS_OFFSET (Data.Irq.InterruptCount)}, + + /* Set default flags (others are zero) */ + + {ACPI_RSC_SET8, ACPI_RS_OFFSET (Data.Irq.Triggering), + ACPI_EDGE_SENSITIVE, + 1}, + + /* Get the descriptor length (2 or 3 for IRQ descriptor) */ + + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Irq.DescriptorLength), + AML_OFFSET (Irq.DescriptorType), + 0}, + + /* All done if no flag byte present in descriptor */ + + {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_AML_LENGTH, 0, 3}, + + /* Get flags: Triggering[0], Polarity[3], Sharing[4] */ + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Irq.Triggering), + AML_OFFSET (Irq.Flags), + 0}, + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Irq.Polarity), + AML_OFFSET (Irq.Flags), + 3}, + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Irq.Sharable), + AML_OFFSET (Irq.Flags), + 4} +}; + + +/******************************************************************************* + * + * AcpiRsSetIrq + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsSetIrq[13] = +{ + /* Start with a default descriptor of length 3 */ + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_IRQ, + sizeof (AML_RESOURCE_IRQ), + ACPI_RSC_TABLE_SIZE (AcpiRsSetIrq)}, + + /* Convert interrupt list to 16-bit IRQ bitmask */ + + {ACPI_RSC_BITMASK16,ACPI_RS_OFFSET (Data.Irq.Interrupts[0]), + AML_OFFSET (Irq.IrqMask), + ACPI_RS_OFFSET (Data.Irq.InterruptCount)}, + + /* Set the flags byte */ + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Irq.Triggering), + AML_OFFSET (Irq.Flags), + 0}, + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Irq.Polarity), + AML_OFFSET (Irq.Flags), + 3}, + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Irq.Sharable), + AML_OFFSET (Irq.Flags), + 4}, + + /* + * All done if the output descriptor length is required to be 3 + * (i.e., optimization to 2 bytes cannot be attempted) + */ + {ACPI_RSC_EXIT_EQ, ACPI_RSC_COMPARE_VALUE, + ACPI_RS_OFFSET(Data.Irq.DescriptorLength), + 3}, + + /* Set length to 2 bytes (no flags byte) */ + + {ACPI_RSC_LENGTH, 0, 0, sizeof (AML_RESOURCE_IRQ_NOFLAGS)}, + + /* + * All done if the output descriptor length is required to be 2. + * + * TBD: Perhaps we should check for error if input flags are not + * compatible with a 2-byte descriptor. + */ + {ACPI_RSC_EXIT_EQ, ACPI_RSC_COMPARE_VALUE, + ACPI_RS_OFFSET(Data.Irq.DescriptorLength), + 2}, + + /* Reset length to 3 bytes (descriptor with flags byte) */ + + {ACPI_RSC_LENGTH, 0, 0, sizeof (AML_RESOURCE_IRQ)}, + + /* + * Check if the flags byte is necessary. Not needed if the flags are: + * ACPI_EDGE_SENSITIVE, ACPI_ACTIVE_HIGH, ACPI_EXCLUSIVE + */ + {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE, + ACPI_RS_OFFSET (Data.Irq.Triggering), + ACPI_EDGE_SENSITIVE}, + + {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE, + ACPI_RS_OFFSET (Data.Irq.Polarity), + ACPI_ACTIVE_HIGH}, + + {ACPI_RSC_EXIT_NE, ACPI_RSC_COMPARE_VALUE, + ACPI_RS_OFFSET (Data.Irq.Sharable), + ACPI_EXCLUSIVE}, + + /* We can optimize to a 2-byte IrqNoFlags() descriptor */ + + {ACPI_RSC_LENGTH, 0, 0, sizeof (AML_RESOURCE_IRQ_NOFLAGS)} +}; + + +/******************************************************************************* + * + * AcpiRsConvertExtIrq + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsConvertExtIrq[9] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_EXTENDED_IRQ, + ACPI_RS_SIZE (ACPI_RESOURCE_EXTENDED_IRQ), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertExtIrq)}, + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_EXTENDED_IRQ, + sizeof (AML_RESOURCE_EXTENDED_IRQ), + 0}, + + /* Flag bits */ + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.ExtendedIrq.ProducerConsumer), + AML_OFFSET (ExtendedIrq.Flags), + 0}, + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.ExtendedIrq.Triggering), + AML_OFFSET (ExtendedIrq.Flags), + 1}, + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.ExtendedIrq.Polarity), + AML_OFFSET (ExtendedIrq.Flags), + 2}, + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.ExtendedIrq.Sharable), + AML_OFFSET (ExtendedIrq.Flags), + 3}, + + /* IRQ Table length (Byte4) */ + + {ACPI_RSC_COUNT, ACPI_RS_OFFSET (Data.ExtendedIrq.InterruptCount), + AML_OFFSET (ExtendedIrq.InterruptCount), + sizeof (UINT32)}, + + /* Copy every IRQ in the table, each is 32 bits */ + + {ACPI_RSC_MOVE32, ACPI_RS_OFFSET (Data.ExtendedIrq.Interrupts[0]), + AML_OFFSET (ExtendedIrq.Interrupts[0]), + 0}, + + /* Optional ResourceSource (Index and String) */ + + {ACPI_RSC_SOURCEX, ACPI_RS_OFFSET (Data.ExtendedIrq.ResourceSource), + ACPI_RS_OFFSET (Data.ExtendedIrq.Interrupts[0]), + sizeof (AML_RESOURCE_EXTENDED_IRQ)} +}; + + +/******************************************************************************* + * + * AcpiRsConvertDma + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsConvertDma[6] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_DMA, + ACPI_RS_SIZE (ACPI_RESOURCE_DMA), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertDma)}, + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_DMA, + sizeof (AML_RESOURCE_DMA), + 0}, + + /* Flags: transfer preference, bus mastering, channel speed */ + + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Dma.Transfer), + AML_OFFSET (Dma.Flags), + 0}, + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Dma.BusMaster), + AML_OFFSET (Dma.Flags), + 2}, + + {ACPI_RSC_2BITFLAG, ACPI_RS_OFFSET (Data.Dma.Type), + AML_OFFSET (Dma.Flags), + 5}, + + /* DMA channel mask bits */ + + {ACPI_RSC_BITMASK, ACPI_RS_OFFSET (Data.Dma.Channels[0]), + AML_OFFSET (Dma.DmaChannelMask), + ACPI_RS_OFFSET (Data.Dma.ChannelCount)} +}; + diff --git a/reactos/drivers/bus/acpi/acpica/resources/rslist.c b/reactos/drivers/bus/acpi/acpica/resources/rslist.c new file mode 100644 index 00000000000..3adce2b3939 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/resources/rslist.c @@ -0,0 +1,286 @@ +/******************************************************************************* + * + * Module Name: rslist - Linked list utilities + * + ******************************************************************************/ + +/****************************************************************************** + * + * 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 __RSLIST_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acresrc.h" + +#define _COMPONENT ACPI_RESOURCES + ACPI_MODULE_NAME ("rslist") + + +/******************************************************************************* + * + * FUNCTION: AcpiRsConvertAmlToResources + * + * PARAMETERS: ACPI_WALK_AML_CALLBACK + * ResourcePtr - Pointer to the buffer that will + * contain the output structures + * + * RETURN: Status + * + * DESCRIPTION: Convert an AML resource to an internal representation of the + * resource that is aligned and easier to access. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsConvertAmlToResources ( + UINT8 *Aml, + UINT32 Length, + UINT32 Offset, + UINT8 ResourceIndex, + void *Context) +{ + ACPI_RESOURCE **ResourcePtr = ACPI_CAST_INDIRECT_PTR ( + ACPI_RESOURCE, Context); + ACPI_RESOURCE *Resource; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (RsConvertAmlToResources); + + + /* + * Check that the input buffer and all subsequent pointers into it + * are aligned on a native word boundary. Most important on IA64 + */ + Resource = *ResourcePtr; + if (ACPI_IS_MISALIGNED (Resource)) + { + ACPI_WARNING ((AE_INFO, + "Misaligned resource pointer %p", Resource)); + } + + /* Convert the AML byte stream resource to a local resource struct */ + + Status = AcpiRsConvertAmlToResource ( + Resource, ACPI_CAST_PTR (AML_RESOURCE, Aml), + AcpiGbl_GetResourceDispatch[ResourceIndex]); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Could not convert AML resource (Type %X)", *Aml)); + return_ACPI_STATUS (Status); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_RESOURCES, + "Type %.2X, AmlLength %.2X InternalLength %.2X\n", + AcpiUtGetResourceType (Aml), Length, + Resource->Length)); + + /* Point to the next structure in the output buffer */ + + *ResourcePtr = ACPI_ADD_PTR (void, Resource, Resource->Length); + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsConvertResourcesToAml + * + * PARAMETERS: Resource - Pointer to the resource linked list + * AmlSizeNeeded - Calculated size of the byte stream + * needed from calling AcpiRsGetAmlLength() + * The size of the OutputBuffer is + * guaranteed to be >= AmlSizeNeeded + * OutputBuffer - Pointer to the buffer that will + * contain the byte stream + * + * RETURN: Status + * + * DESCRIPTION: Takes the resource linked list and parses it, creating a + * byte stream of resources in the caller's output buffer + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsConvertResourcesToAml ( + ACPI_RESOURCE *Resource, + ACPI_SIZE AmlSizeNeeded, + UINT8 *OutputBuffer) +{ + UINT8 *Aml = OutputBuffer; + UINT8 *EndAml = OutputBuffer + AmlSizeNeeded; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (RsConvertResourcesToAml); + + + /* Walk the resource descriptor list, convert each descriptor */ + + while (Aml < EndAml) + { + /* Validate the (internal) Resource Type */ + + if (Resource->Type > ACPI_RESOURCE_TYPE_MAX) + { + ACPI_ERROR ((AE_INFO, + "Invalid descriptor type (%X) in resource list", + Resource->Type)); + return_ACPI_STATUS (AE_BAD_DATA); + } + + /* Perform the conversion */ + + Status = AcpiRsConvertResourceToAml (Resource, + ACPI_CAST_PTR (AML_RESOURCE, Aml), + AcpiGbl_SetResourceDispatch[Resource->Type]); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Could not convert resource (type %X) to AML", + Resource->Type)); + return_ACPI_STATUS (Status); + } + + /* Perform final sanity check on the new AML resource descriptor */ + + Status = AcpiUtValidateResource ( + ACPI_CAST_PTR (AML_RESOURCE, Aml), NULL); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Check for end-of-list, normal exit */ + + if (Resource->Type == ACPI_RESOURCE_TYPE_END_TAG) + { + /* An End Tag indicates the end of the input Resource Template */ + + return_ACPI_STATUS (AE_OK); + } + + /* + * Extract the total length of the new descriptor and set the + * Aml to point to the next (output) resource descriptor + */ + Aml += AcpiUtGetDescriptorLength (Aml); + + /* Point to the next input resource descriptor */ + + Resource = ACPI_ADD_PTR (ACPI_RESOURCE, Resource, Resource->Length); + } + + /* Completed buffer, but did not find an EndTag resource descriptor */ + + return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG); +} + diff --git a/reactos/drivers/bus/acpi/acpica/resources/rsmemory.c b/reactos/drivers/bus/acpi/acpica/resources/rsmemory.c new file mode 100644 index 00000000000..a3d08c01a1b --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/resources/rsmemory.c @@ -0,0 +1,323 @@ +/******************************************************************************* + * + * Module Name: rsmem24 - Memory resource descriptors + * + ******************************************************************************/ + +/****************************************************************************** + * + * 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 __RSMEMORY_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acresrc.h" + +#define _COMPONENT ACPI_RESOURCES + ACPI_MODULE_NAME ("rsmemory") + + +/******************************************************************************* + * + * AcpiRsConvertMemory24 + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsConvertMemory24[4] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_MEMORY24, + ACPI_RS_SIZE (ACPI_RESOURCE_MEMORY24), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertMemory24)}, + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_MEMORY24, + sizeof (AML_RESOURCE_MEMORY24), + 0}, + + /* Read/Write bit */ + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Memory24.WriteProtect), + AML_OFFSET (Memory24.Flags), + 0}, + /* + * These fields are contiguous in both the source and destination: + * Minimum Base Address + * Maximum Base Address + * Address Base Alignment + * Range Length + */ + {ACPI_RSC_MOVE16, ACPI_RS_OFFSET (Data.Memory24.Minimum), + AML_OFFSET (Memory24.Minimum), + 4} +}; + + +/******************************************************************************* + * + * AcpiRsConvertMemory32 + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsConvertMemory32[4] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_MEMORY32, + ACPI_RS_SIZE (ACPI_RESOURCE_MEMORY32), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertMemory32)}, + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_MEMORY32, + sizeof (AML_RESOURCE_MEMORY32), + 0}, + + /* Read/Write bit */ + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.Memory32.WriteProtect), + AML_OFFSET (Memory32.Flags), + 0}, + /* + * These fields are contiguous in both the source and destination: + * Minimum Base Address + * Maximum Base Address + * Address Base Alignment + * Range Length + */ + {ACPI_RSC_MOVE32, ACPI_RS_OFFSET (Data.Memory32.Minimum), + AML_OFFSET (Memory32.Minimum), + 4} +}; + + +/******************************************************************************* + * + * AcpiRsConvertFixedMemory32 + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsConvertFixedMemory32[4] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_FIXED_MEMORY32, + ACPI_RS_SIZE (ACPI_RESOURCE_FIXED_MEMORY32), + ACPI_RSC_TABLE_SIZE (AcpiRsConvertFixedMemory32)}, + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_FIXED_MEMORY32, + sizeof (AML_RESOURCE_FIXED_MEMORY32), + 0}, + + /* Read/Write bit */ + + {ACPI_RSC_1BITFLAG, ACPI_RS_OFFSET (Data.FixedMemory32.WriteProtect), + AML_OFFSET (FixedMemory32.Flags), + 0}, + /* + * These fields are contiguous in both the source and destination: + * Base Address + * Range Length + */ + {ACPI_RSC_MOVE32, ACPI_RS_OFFSET (Data.FixedMemory32.Address), + AML_OFFSET (FixedMemory32.Address), + 2} +}; + + +/******************************************************************************* + * + * AcpiRsGetVendorSmall + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsGetVendorSmall[3] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_VENDOR, + ACPI_RS_SIZE (ACPI_RESOURCE_VENDOR), + ACPI_RSC_TABLE_SIZE (AcpiRsGetVendorSmall)}, + + /* Length of the vendor data (byte count) */ + + {ACPI_RSC_COUNT16, ACPI_RS_OFFSET (Data.Vendor.ByteLength), + 0, + sizeof (UINT8)}, + + /* Vendor data */ + + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Vendor.ByteData[0]), + sizeof (AML_RESOURCE_SMALL_HEADER), + 0} +}; + + +/******************************************************************************* + * + * AcpiRsGetVendorLarge + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsGetVendorLarge[3] = +{ + {ACPI_RSC_INITGET, ACPI_RESOURCE_TYPE_VENDOR, + ACPI_RS_SIZE (ACPI_RESOURCE_VENDOR), + ACPI_RSC_TABLE_SIZE (AcpiRsGetVendorLarge)}, + + /* Length of the vendor data (byte count) */ + + {ACPI_RSC_COUNT16, ACPI_RS_OFFSET (Data.Vendor.ByteLength), + 0, + sizeof (UINT8)}, + + /* Vendor data */ + + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Vendor.ByteData[0]), + sizeof (AML_RESOURCE_LARGE_HEADER), + 0} +}; + + +/******************************************************************************* + * + * AcpiRsSetVendor + * + ******************************************************************************/ + +ACPI_RSCONVERT_INFO AcpiRsSetVendor[7] = +{ + /* Default is a small vendor descriptor */ + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_VENDOR_SMALL, + sizeof (AML_RESOURCE_SMALL_HEADER), + ACPI_RSC_TABLE_SIZE (AcpiRsSetVendor)}, + + /* Get the length and copy the data */ + + {ACPI_RSC_COUNT16, ACPI_RS_OFFSET (Data.Vendor.ByteLength), + 0, + 0}, + + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Vendor.ByteData[0]), + sizeof (AML_RESOURCE_SMALL_HEADER), + 0}, + + /* + * All done if the Vendor byte length is 7 or less, meaning that it will + * fit within a small descriptor + */ + {ACPI_RSC_EXIT_LE, 0, 0, 7}, + + /* Must create a large vendor descriptor */ + + {ACPI_RSC_INITSET, ACPI_RESOURCE_NAME_VENDOR_LARGE, + sizeof (AML_RESOURCE_LARGE_HEADER), + 0}, + + {ACPI_RSC_COUNT16, ACPI_RS_OFFSET (Data.Vendor.ByteLength), + 0, + 0}, + + {ACPI_RSC_MOVE8, ACPI_RS_OFFSET (Data.Vendor.ByteData[0]), + sizeof (AML_RESOURCE_LARGE_HEADER), + 0} +}; + + diff --git a/reactos/drivers/bus/acpi/acpica/resources/rsmisc.c b/reactos/drivers/bus/acpi/acpica/resources/rsmisc.c new file mode 100644 index 00000000000..3565334e732 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/resources/rsmisc.c @@ -0,0 +1,683 @@ +/******************************************************************************* + * + * Module Name: rsmisc - Miscellaneous resource descriptors + * + ******************************************************************************/ + +/****************************************************************************** + * + * 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 __RSMISC_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acresrc.h" + +#define _COMPONENT ACPI_RESOURCES + ACPI_MODULE_NAME ("rsmisc") + + +#define INIT_RESOURCE_TYPE(i) i->ResourceOffset +#define INIT_RESOURCE_LENGTH(i) i->AmlOffset +#define INIT_TABLE_LENGTH(i) i->Value + +#define COMPARE_OPCODE(i) i->ResourceOffset +#define COMPARE_TARGET(i) i->AmlOffset +#define COMPARE_VALUE(i) i->Value + + +/******************************************************************************* + * + * FUNCTION: AcpiRsConvertAmlToResource + * + * PARAMETERS: Resource - Pointer to the resource descriptor + * Aml - Where the AML descriptor is returned + * Info - Pointer to appropriate conversion table + * + * RETURN: Status + * + * DESCRIPTION: Convert an external AML resource descriptor to the corresponding + * internal resource descriptor + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsConvertAmlToResource ( + ACPI_RESOURCE *Resource, + AML_RESOURCE *Aml, + ACPI_RSCONVERT_INFO *Info) +{ + ACPI_RS_LENGTH AmlResourceLength; + void *Source; + void *Destination; + char *Target; + UINT8 Count; + UINT8 FlagsMode = FALSE; + UINT16 ItemCount = 0; + UINT16 Temp16 = 0; + + + ACPI_FUNCTION_TRACE (RsConvertAmlToResource); + + + if (((ACPI_SIZE) Resource) & 0x3) + { + /* Each internal resource struct is expected to be 32-bit aligned */ + + ACPI_WARNING ((AE_INFO, + "Misaligned resource pointer (get): %p Type %2.2X Len %X", + Resource, Resource->Type, Resource->Length)); + } + + /* Extract the resource Length field (does not include header length) */ + + AmlResourceLength = AcpiUtGetResourceLength (Aml); + + /* + * First table entry must be ACPI_RSC_INITxxx and must contain the + * table length (# of table entries) + */ + Count = INIT_TABLE_LENGTH (Info); + + while (Count) + { + /* + * Source is the external AML byte stream buffer, + * destination is the internal resource descriptor + */ + Source = ACPI_ADD_PTR (void, Aml, Info->AmlOffset); + Destination = ACPI_ADD_PTR (void, Resource, Info->ResourceOffset); + + switch (Info->Opcode) + { + case ACPI_RSC_INITGET: + /* + * Get the resource type and the initial (minimum) length + */ + ACPI_MEMSET (Resource, 0, INIT_RESOURCE_LENGTH (Info)); + Resource->Type = INIT_RESOURCE_TYPE (Info); + Resource->Length = INIT_RESOURCE_LENGTH (Info); + break; + + + case ACPI_RSC_INITSET: + break; + + + case ACPI_RSC_FLAGINIT: + + FlagsMode = TRUE; + break; + + + case ACPI_RSC_1BITFLAG: + /* + * Mask and shift the flag bit + */ + ACPI_SET8 (Destination) = (UINT8) + ((ACPI_GET8 (Source) >> Info->Value) & 0x01); + break; + + + case ACPI_RSC_2BITFLAG: + /* + * Mask and shift the flag bits + */ + ACPI_SET8 (Destination) = (UINT8) + ((ACPI_GET8 (Source) >> Info->Value) & 0x03); + break; + + + case ACPI_RSC_COUNT: + + ItemCount = ACPI_GET8 (Source); + ACPI_SET8 (Destination) = (UINT8) ItemCount; + + Resource->Length = Resource->Length + + (Info->Value * (ItemCount - 1)); + break; + + + case ACPI_RSC_COUNT16: + + ItemCount = AmlResourceLength; + ACPI_SET16 (Destination) = ItemCount; + + Resource->Length = Resource->Length + + (Info->Value * (ItemCount - 1)); + break; + + + case ACPI_RSC_LENGTH: + + Resource->Length = Resource->Length + Info->Value; + break; + + + case ACPI_RSC_MOVE8: + case ACPI_RSC_MOVE16: + case ACPI_RSC_MOVE32: + case ACPI_RSC_MOVE64: + /* + * Raw data move. Use the Info value field unless ItemCount has + * been previously initialized via a COUNT opcode + */ + if (Info->Value) + { + ItemCount = Info->Value; + } + AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode); + break; + + + case ACPI_RSC_SET8: + + ACPI_MEMSET (Destination, Info->AmlOffset, Info->Value); + break; + + + case ACPI_RSC_DATA8: + + Target = ACPI_ADD_PTR (char, Resource, Info->Value); + ACPI_MEMCPY (Destination, Source, ACPI_GET16 (Target)); + break; + + + case ACPI_RSC_ADDRESS: + /* + * Common handler for address descriptor flags + */ + if (!AcpiRsGetAddressCommon (Resource, Aml)) + { + return_ACPI_STATUS (AE_AML_INVALID_RESOURCE_TYPE); + } + break; + + + case ACPI_RSC_SOURCE: + /* + * Optional ResourceSource (Index and String) + */ + Resource->Length += + AcpiRsGetResourceSource (AmlResourceLength, Info->Value, + Destination, Aml, NULL); + break; + + + case ACPI_RSC_SOURCEX: + /* + * Optional ResourceSource (Index and String). This is the more + * complicated case used by the Interrupt() macro + */ + Target = ACPI_ADD_PTR (char, Resource, Info->AmlOffset + (ItemCount * 4)); + + Resource->Length += + AcpiRsGetResourceSource (AmlResourceLength, + (ACPI_RS_LENGTH) (((ItemCount - 1) * sizeof (UINT32)) + Info->Value), + Destination, Aml, Target); + break; + + + case ACPI_RSC_BITMASK: + /* + * 8-bit encoded bitmask (DMA macro) + */ + ItemCount = AcpiRsDecodeBitmask (ACPI_GET8 (Source), Destination); + if (ItemCount) + { + Resource->Length += (ItemCount - 1); + } + + Target = ACPI_ADD_PTR (char, Resource, Info->Value); + ACPI_SET8 (Target) = (UINT8) ItemCount; + break; + + + case ACPI_RSC_BITMASK16: + /* + * 16-bit encoded bitmask (IRQ macro) + */ + ACPI_MOVE_16_TO_16 (&Temp16, Source); + + ItemCount = AcpiRsDecodeBitmask (Temp16, Destination); + if (ItemCount) + { + Resource->Length += (ItemCount - 1); + } + + Target = ACPI_ADD_PTR (char, Resource, Info->Value); + ACPI_SET8 (Target) = (UINT8) ItemCount; + break; + + + case ACPI_RSC_EXIT_NE: + /* + * Control - Exit conversion if not equal + */ + switch (Info->ResourceOffset) + { + case ACPI_RSC_COMPARE_AML_LENGTH: + if (AmlResourceLength != Info->Value) + { + goto Exit; + } + break; + + case ACPI_RSC_COMPARE_VALUE: + if (ACPI_GET8 (Source) != Info->Value) + { + goto Exit; + } + break; + + default: + + ACPI_ERROR ((AE_INFO, "Invalid conversion sub-opcode")); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + break; + + + default: + + ACPI_ERROR ((AE_INFO, "Invalid conversion opcode")); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Count--; + Info++; + } + +Exit: + if (!FlagsMode) + { + /* Round the resource struct length up to the next boundary (32 or 64) */ + + Resource->Length = (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (Resource->Length); + } + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsConvertResourceToAml + * + * PARAMETERS: Resource - Pointer to the resource descriptor + * Aml - Where the AML descriptor is returned + * Info - Pointer to appropriate conversion table + * + * RETURN: Status + * + * DESCRIPTION: Convert an internal resource descriptor to the corresponding + * external AML resource descriptor. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsConvertResourceToAml ( + ACPI_RESOURCE *Resource, + AML_RESOURCE *Aml, + ACPI_RSCONVERT_INFO *Info) +{ + void *Source = NULL; + void *Destination; + ACPI_RSDESC_SIZE AmlLength = 0; + UINT8 Count; + UINT16 Temp16 = 0; + UINT16 ItemCount = 0; + + + ACPI_FUNCTION_TRACE (RsConvertResourceToAml); + + + /* + * First table entry must be ACPI_RSC_INITxxx and must contain the + * table length (# of table entries) + */ + Count = INIT_TABLE_LENGTH (Info); + + while (Count) + { + /* + * Source is the internal resource descriptor, + * destination is the external AML byte stream buffer + */ + Source = ACPI_ADD_PTR (void, Resource, Info->ResourceOffset); + Destination = ACPI_ADD_PTR (void, Aml, Info->AmlOffset); + + switch (Info->Opcode) + { + case ACPI_RSC_INITSET: + + ACPI_MEMSET (Aml, 0, INIT_RESOURCE_LENGTH (Info)); + AmlLength = INIT_RESOURCE_LENGTH (Info); + AcpiRsSetResourceHeader (INIT_RESOURCE_TYPE (Info), AmlLength, Aml); + break; + + + case ACPI_RSC_INITGET: + break; + + + case ACPI_RSC_FLAGINIT: + /* + * Clear the flag byte + */ + ACPI_SET8 (Destination) = 0; + break; + + + case ACPI_RSC_1BITFLAG: + /* + * Mask and shift the flag bit + */ + ACPI_SET8 (Destination) |= (UINT8) + ((ACPI_GET8 (Source) & 0x01) << Info->Value); + break; + + + case ACPI_RSC_2BITFLAG: + /* + * Mask and shift the flag bits + */ + ACPI_SET8 (Destination) |= (UINT8) + ((ACPI_GET8 (Source) & 0x03) << Info->Value); + break; + + + case ACPI_RSC_COUNT: + + ItemCount = ACPI_GET8 (Source); + ACPI_SET8 (Destination) = (UINT8) ItemCount; + + AmlLength = (UINT16) (AmlLength + (Info->Value * (ItemCount - 1))); + break; + + + case ACPI_RSC_COUNT16: + + ItemCount = ACPI_GET16 (Source); + AmlLength = (UINT16) (AmlLength + ItemCount); + AcpiRsSetResourceLength (AmlLength, Aml); + break; + + + case ACPI_RSC_LENGTH: + + AcpiRsSetResourceLength (Info->Value, Aml); + break; + + + case ACPI_RSC_MOVE8: + case ACPI_RSC_MOVE16: + case ACPI_RSC_MOVE32: + case ACPI_RSC_MOVE64: + + if (Info->Value) + { + ItemCount = Info->Value; + } + AcpiRsMoveData (Destination, Source, ItemCount, Info->Opcode); + break; + + + case ACPI_RSC_ADDRESS: + + /* Set the Resource Type, General Flags, and Type-Specific Flags */ + + AcpiRsSetAddressCommon (Aml, Resource); + break; + + + case ACPI_RSC_SOURCEX: + /* + * Optional ResourceSource (Index and String) + */ + AmlLength = AcpiRsSetResourceSource ( + Aml, (ACPI_RS_LENGTH) AmlLength, Source); + AcpiRsSetResourceLength (AmlLength, Aml); + break; + + + case ACPI_RSC_SOURCE: + /* + * Optional ResourceSource (Index and String). This is the more + * complicated case used by the Interrupt() macro + */ + AmlLength = AcpiRsSetResourceSource (Aml, Info->Value, Source); + AcpiRsSetResourceLength (AmlLength, Aml); + break; + + + case ACPI_RSC_BITMASK: + /* + * 8-bit encoded bitmask (DMA macro) + */ + ACPI_SET8 (Destination) = (UINT8) + AcpiRsEncodeBitmask (Source, + *ACPI_ADD_PTR (UINT8, Resource, Info->Value)); + break; + + + case ACPI_RSC_BITMASK16: + /* + * 16-bit encoded bitmask (IRQ macro) + */ + Temp16 = AcpiRsEncodeBitmask (Source, + *ACPI_ADD_PTR (UINT8, Resource, Info->Value)); + ACPI_MOVE_16_TO_16 (Destination, &Temp16); + break; + + + case ACPI_RSC_EXIT_LE: + /* + * Control - Exit conversion if less than or equal + */ + if (ItemCount <= Info->Value) + { + goto Exit; + } + break; + + + case ACPI_RSC_EXIT_NE: + /* + * Control - Exit conversion if not equal + */ + switch (COMPARE_OPCODE (Info)) + { + case ACPI_RSC_COMPARE_VALUE: + + if (*ACPI_ADD_PTR (UINT8, Resource, + COMPARE_TARGET (Info)) != COMPARE_VALUE (Info)) + { + goto Exit; + } + break; + + default: + + ACPI_ERROR ((AE_INFO, "Invalid conversion sub-opcode")); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + break; + + + case ACPI_RSC_EXIT_EQ: + /* + * Control - Exit conversion if equal + */ + if (*ACPI_ADD_PTR (UINT8, Resource, + COMPARE_TARGET (Info)) == COMPARE_VALUE (Info)) + { + goto Exit; + } + break; + + + default: + + ACPI_ERROR ((AE_INFO, "Invalid conversion opcode")); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Count--; + Info++; + } + +Exit: + return_ACPI_STATUS (AE_OK); +} + + +#if 0 +/* Previous resource validations */ + + if (Aml->ExtAddress64.RevisionID != AML_RESOURCE_EXTENDED_ADDRESS_REVISION) + { + return_ACPI_STATUS (AE_SUPPORT); + } + + if (Resource->Data.StartDpf.PerformanceRobustness >= 3) + { + return_ACPI_STATUS (AE_AML_BAD_RESOURCE_VALUE); + } + + if (((Aml->Irq.Flags & 0x09) == 0x00) || + ((Aml->Irq.Flags & 0x09) == 0x09)) + { + /* + * Only [ActiveHigh, EdgeSensitive] or [ActiveLow, LevelSensitive] + * polarity/trigger interrupts are allowed (ACPI spec, section + * "IRQ Format"), so 0x00 and 0x09 are illegal. + */ + ACPI_ERROR ((AE_INFO, + "Invalid interrupt polarity/trigger in resource list, %X", + Aml->Irq.Flags)); + return_ACPI_STATUS (AE_BAD_DATA); + } + + Resource->Data.ExtendedIrq.InterruptCount = Temp8; + if (Temp8 < 1) + { + /* Must have at least one IRQ */ + + return_ACPI_STATUS (AE_AML_BAD_RESOURCE_LENGTH); + } + + if (Resource->Data.Dma.Transfer == 0x03) + { + ACPI_ERROR ((AE_INFO, + "Invalid DMA.Transfer preference (3)")); + return_ACPI_STATUS (AE_BAD_DATA); + } +#endif + + diff --git a/reactos/drivers/bus/acpi/acpica/resources/rsutils.c b/reactos/drivers/bus/acpi/acpica/resources/rsutils.c new file mode 100644 index 00000000000..4e0f04ce8e5 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/resources/rsutils.c @@ -0,0 +1,874 @@ +/******************************************************************************* + * + * Module Name: rsutils - Utilities for the resource manager + * + ******************************************************************************/ + +/****************************************************************************** + * + * 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 __RSUTILS_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" +#include "acresrc.h" + + +#define _COMPONENT ACPI_RESOURCES + ACPI_MODULE_NAME ("rsutils") + + +/******************************************************************************* + * + * FUNCTION: AcpiRsDecodeBitmask + * + * PARAMETERS: Mask - Bitmask to decode + * List - Where the converted list is returned + * + * RETURN: Count of bits set (length of list) + * + * DESCRIPTION: Convert a bit mask into a list of values + * + ******************************************************************************/ + +UINT8 +AcpiRsDecodeBitmask ( + UINT16 Mask, + UINT8 *List) +{ + UINT8 i; + UINT8 BitCount; + + + ACPI_FUNCTION_ENTRY (); + + + /* Decode the mask bits */ + + for (i = 0, BitCount = 0; Mask; i++) + { + if (Mask & 0x0001) + { + List[BitCount] = i; + BitCount++; + } + + Mask >>= 1; + } + + return (BitCount); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsEncodeBitmask + * + * PARAMETERS: List - List of values to encode + * Count - Length of list + * + * RETURN: Encoded bitmask + * + * DESCRIPTION: Convert a list of values to an encoded bitmask + * + ******************************************************************************/ + +UINT16 +AcpiRsEncodeBitmask ( + UINT8 *List, + UINT8 Count) +{ + UINT32 i; + UINT16 Mask; + + + ACPI_FUNCTION_ENTRY (); + + + /* Encode the list into a single bitmask */ + + for (i = 0, Mask = 0; i < Count; i++) + { + Mask |= (0x1 << List[i]); + } + + return (Mask); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsMoveData + * + * PARAMETERS: Destination - Pointer to the destination descriptor + * Source - Pointer to the source descriptor + * ItemCount - How many items to move + * MoveType - Byte width + * + * RETURN: None + * + * DESCRIPTION: Move multiple data items from one descriptor to another. Handles + * alignment issues and endian issues if necessary, as configured + * via the ACPI_MOVE_* macros. (This is why a memcpy is not used) + * + ******************************************************************************/ + +void +AcpiRsMoveData ( + void *Destination, + void *Source, + UINT16 ItemCount, + UINT8 MoveType) +{ + UINT32 i; + + + ACPI_FUNCTION_ENTRY (); + + + /* One move per item */ + + for (i = 0; i < ItemCount; i++) + { + switch (MoveType) + { + /* + * For the 8-bit case, we can perform the move all at once + * since there are no alignment or endian issues + */ + case ACPI_RSC_MOVE8: + ACPI_MEMCPY (Destination, Source, ItemCount); + return; + + /* + * 16-, 32-, and 64-bit cases must use the move macros that perform + * endian conversion and/or accomodate hardware that cannot perform + * misaligned memory transfers + */ + case ACPI_RSC_MOVE16: + ACPI_MOVE_16_TO_16 (&ACPI_CAST_PTR (UINT16, Destination)[i], + &ACPI_CAST_PTR (UINT16, Source)[i]); + break; + + case ACPI_RSC_MOVE32: + ACPI_MOVE_32_TO_32 (&ACPI_CAST_PTR (UINT32, Destination)[i], + &ACPI_CAST_PTR (UINT32, Source)[i]); + break; + + case ACPI_RSC_MOVE64: + ACPI_MOVE_64_TO_64 (&ACPI_CAST_PTR (UINT64, Destination)[i], + &ACPI_CAST_PTR (UINT64, Source)[i]); + break; + + default: + return; + } + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsSetResourceLength + * + * PARAMETERS: TotalLength - Length of the AML descriptor, including + * the header and length fields. + * Aml - Pointer to the raw AML descriptor + * + * RETURN: None + * + * DESCRIPTION: Set the ResourceLength field of an AML + * resource descriptor, both Large and Small descriptors are + * supported automatically. Note: Descriptor Type field must + * be valid. + * + ******************************************************************************/ + +void +AcpiRsSetResourceLength ( + ACPI_RSDESC_SIZE TotalLength, + AML_RESOURCE *Aml) +{ + ACPI_RS_LENGTH ResourceLength; + + + ACPI_FUNCTION_ENTRY (); + + + /* Length is the total descriptor length minus the header length */ + + ResourceLength = (ACPI_RS_LENGTH) + (TotalLength - AcpiUtGetResourceHeaderLength (Aml)); + + /* Length is stored differently for large and small descriptors */ + + if (Aml->SmallHeader.DescriptorType & ACPI_RESOURCE_NAME_LARGE) + { + /* Large descriptor -- bytes 1-2 contain the 16-bit length */ + + ACPI_MOVE_16_TO_16 (&Aml->LargeHeader.ResourceLength, &ResourceLength); + } + else + { + /* Small descriptor -- bits 2:0 of byte 0 contain the length */ + + Aml->SmallHeader.DescriptorType = (UINT8) + + /* Clear any existing length, preserving descriptor type bits */ + + ((Aml->SmallHeader.DescriptorType & ~ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK) + + | ResourceLength); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsSetResourceHeader + * + * PARAMETERS: DescriptorType - Byte to be inserted as the type + * TotalLength - Length of the AML descriptor, including + * the header and length fields. + * Aml - Pointer to the raw AML descriptor + * + * RETURN: None + * + * DESCRIPTION: Set the DescriptorType and ResourceLength fields of an AML + * resource descriptor, both Large and Small descriptors are + * supported automatically + * + ******************************************************************************/ + +void +AcpiRsSetResourceHeader ( + UINT8 DescriptorType, + ACPI_RSDESC_SIZE TotalLength, + AML_RESOURCE *Aml) +{ + ACPI_FUNCTION_ENTRY (); + + + /* Set the Resource Type */ + + Aml->SmallHeader.DescriptorType = DescriptorType; + + /* Set the Resource Length */ + + AcpiRsSetResourceLength (TotalLength, Aml); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsStrcpy + * + * PARAMETERS: Destination - Pointer to the destination string + * Source - Pointer to the source string + * + * RETURN: String length, including NULL terminator + * + * DESCRIPTION: Local string copy that returns the string length, saving a + * strcpy followed by a strlen. + * + ******************************************************************************/ + +static UINT16 +AcpiRsStrcpy ( + char *Destination, + char *Source) +{ + UINT16 i; + + + ACPI_FUNCTION_ENTRY (); + + + for (i = 0; Source[i]; i++) + { + Destination[i] = Source[i]; + } + + Destination[i] = 0; + + /* Return string length including the NULL terminator */ + + return ((UINT16) (i + 1)); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsGetResourceSource + * + * PARAMETERS: ResourceLength - Length field of the descriptor + * MinimumLength - Minimum length of the descriptor (minus + * any optional fields) + * ResourceSource - Where the ResourceSource is returned + * Aml - Pointer to the raw AML descriptor + * StringPtr - (optional) where to store the actual + * ResourceSource string + * + * RETURN: Length of the string plus NULL terminator, rounded up to native + * word boundary + * + * DESCRIPTION: Copy the optional ResourceSource data from a raw AML descriptor + * to an internal resource descriptor + * + ******************************************************************************/ + +ACPI_RS_LENGTH +AcpiRsGetResourceSource ( + ACPI_RS_LENGTH ResourceLength, + ACPI_RS_LENGTH MinimumLength, + ACPI_RESOURCE_SOURCE *ResourceSource, + AML_RESOURCE *Aml, + char *StringPtr) +{ + ACPI_RSDESC_SIZE TotalLength; + UINT8 *AmlResourceSource; + + + ACPI_FUNCTION_ENTRY (); + + + TotalLength = ResourceLength + sizeof (AML_RESOURCE_LARGE_HEADER); + AmlResourceSource = ACPI_ADD_PTR (UINT8, Aml, MinimumLength); + + /* + * ResourceSource is present if the length of the descriptor is longer than + * the minimum length. + * + * Note: Some resource descriptors will have an additional null, so + * we add 1 to the minimum length. + */ + if (TotalLength > (ACPI_RSDESC_SIZE) (MinimumLength + 1)) + { + /* Get the ResourceSourceIndex */ + + ResourceSource->Index = AmlResourceSource[0]; + + ResourceSource->StringPtr = StringPtr; + if (!StringPtr) + { + /* + * String destination pointer is not specified; Set the String + * pointer to the end of the current ResourceSource structure. + */ + ResourceSource->StringPtr = ACPI_ADD_PTR (char, ResourceSource, + sizeof (ACPI_RESOURCE_SOURCE)); + } + + /* + * In order for the Resource length to be a multiple of the native + * word, calculate the length of the string (+1 for NULL terminator) + * and expand to the next word multiple. + * + * Zero the entire area of the buffer. + */ + TotalLength = (UINT32) ACPI_STRLEN ( + ACPI_CAST_PTR (char, &AmlResourceSource[1])) + 1; + TotalLength = (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (TotalLength); + + ACPI_MEMSET (ResourceSource->StringPtr, 0, TotalLength); + + /* Copy the ResourceSource string to the destination */ + + ResourceSource->StringLength = AcpiRsStrcpy (ResourceSource->StringPtr, + ACPI_CAST_PTR (char, &AmlResourceSource[1])); + + return ((ACPI_RS_LENGTH) TotalLength); + } + + /* ResourceSource is not present */ + + ResourceSource->Index = 0; + ResourceSource->StringLength = 0; + ResourceSource->StringPtr = NULL; + return (0); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsSetResourceSource + * + * PARAMETERS: Aml - Pointer to the raw AML descriptor + * MinimumLength - Minimum length of the descriptor (minus + * any optional fields) + * ResourceSource - Internal ResourceSource + + * + * RETURN: Total length of the AML descriptor + * + * DESCRIPTION: Convert an optional ResourceSource from internal format to a + * raw AML resource descriptor + * + ******************************************************************************/ + +ACPI_RSDESC_SIZE +AcpiRsSetResourceSource ( + AML_RESOURCE *Aml, + ACPI_RS_LENGTH MinimumLength, + ACPI_RESOURCE_SOURCE *ResourceSource) +{ + UINT8 *AmlResourceSource; + ACPI_RSDESC_SIZE DescriptorLength; + + + ACPI_FUNCTION_ENTRY (); + + + DescriptorLength = MinimumLength; + + /* Non-zero string length indicates presence of a ResourceSource */ + + if (ResourceSource->StringLength) + { + /* Point to the end of the AML descriptor */ + + AmlResourceSource = ACPI_ADD_PTR (UINT8, Aml, MinimumLength); + + /* Copy the ResourceSourceIndex */ + + AmlResourceSource[0] = (UINT8) ResourceSource->Index; + + /* Copy the ResourceSource string */ + + ACPI_STRCPY (ACPI_CAST_PTR (char, &AmlResourceSource[1]), + ResourceSource->StringPtr); + + /* + * Add the length of the string (+ 1 for null terminator) to the + * final descriptor length + */ + DescriptorLength += ((ACPI_RSDESC_SIZE) ResourceSource->StringLength + 1); + } + + /* Return the new total length of the AML descriptor */ + + return (DescriptorLength); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsGetPrtMethodData + * + * PARAMETERS: Node - Device node + * RetBuffer - Pointer to a buffer structure for the + * results + * + * RETURN: Status + * + * DESCRIPTION: This function is called to get the _PRT value of an object + * contained in an object specified by the handle passed in + * + * If the function fails an appropriate status will be returned + * and the contents of the callers buffer is undefined. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsGetPrtMethodData ( + ACPI_NAMESPACE_NODE *Node, + ACPI_BUFFER *RetBuffer) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (RsGetPrtMethodData); + + + /* Parameters guaranteed valid by caller */ + + /* Execute the method, no parameters */ + + Status = AcpiUtEvaluateObject (Node, METHOD_NAME__PRT, + ACPI_BTYPE_PACKAGE, &ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Create a resource linked list from the byte stream buffer that comes + * back from the _CRS method execution. + */ + Status = AcpiRsCreatePciRoutingTable (ObjDesc, RetBuffer); + + /* On exit, we must delete the object returned by EvaluateObject */ + + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsGetCrsMethodData + * + * PARAMETERS: Node - Device node + * RetBuffer - Pointer to a buffer structure for the + * results + * + * RETURN: Status + * + * DESCRIPTION: This function is called to get the _CRS value of an object + * contained in an object specified by the handle passed in + * + * If the function fails an appropriate status will be returned + * and the contents of the callers buffer is undefined. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsGetCrsMethodData ( + ACPI_NAMESPACE_NODE *Node, + ACPI_BUFFER *RetBuffer) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (RsGetCrsMethodData); + + + /* Parameters guaranteed valid by caller */ + + /* Execute the method, no parameters */ + + Status = AcpiUtEvaluateObject (Node, METHOD_NAME__CRS, + ACPI_BTYPE_BUFFER, &ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Make the call to create a resource linked list from the + * byte stream buffer that comes back from the _CRS method + * execution. + */ + Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer); + + /* On exit, we must delete the object returned by evaluateObject */ + + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsGetPrsMethodData + * + * PARAMETERS: Node - Device node + * RetBuffer - Pointer to a buffer structure for the + * results + * + * RETURN: Status + * + * DESCRIPTION: This function is called to get the _PRS value of an object + * contained in an object specified by the handle passed in + * + * If the function fails an appropriate status will be returned + * and the contents of the callers buffer is undefined. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsGetPrsMethodData ( + ACPI_NAMESPACE_NODE *Node, + ACPI_BUFFER *RetBuffer) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (RsGetPrsMethodData); + + + /* Parameters guaranteed valid by caller */ + + /* Execute the method, no parameters */ + + Status = AcpiUtEvaluateObject (Node, METHOD_NAME__PRS, + ACPI_BTYPE_BUFFER, &ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Make the call to create a resource linked list from the + * byte stream buffer that comes back from the _CRS method + * execution. + */ + Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer); + + /* On exit, we must delete the object returned by evaluateObject */ + + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsGetMethodData + * + * PARAMETERS: Handle - Handle to the containing object + * Path - Path to method, relative to Handle + * RetBuffer - Pointer to a buffer structure for the + * results + * + * RETURN: Status + * + * DESCRIPTION: This function is called to get the _CRS or _PRS value of an + * object contained in an object specified by the handle passed in + * + * If the function fails an appropriate status will be returned + * and the contents of the callers buffer is undefined. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsGetMethodData ( + ACPI_HANDLE Handle, + char *Path, + ACPI_BUFFER *RetBuffer) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (RsGetMethodData); + + + /* Parameters guaranteed valid by caller */ + + /* Execute the method, no parameters */ + + Status = AcpiUtEvaluateObject (Handle, Path, ACPI_BTYPE_BUFFER, &ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Make the call to create a resource linked list from the + * byte stream buffer that comes back from the method + * execution. + */ + Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer); + + /* On exit, we must delete the object returned by EvaluateObject */ + + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiRsSetSrsMethodData + * + * PARAMETERS: Node - Device node + * InBuffer - Pointer to a buffer structure of the + * parameter + * + * RETURN: Status + * + * DESCRIPTION: This function is called to set the _SRS of an object contained + * in an object specified by the handle passed in + * + * If the function fails an appropriate status will be returned + * and the contents of the callers buffer is undefined. + * + * Note: Parameters guaranteed valid by caller + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRsSetSrsMethodData ( + ACPI_NAMESPACE_NODE *Node, + ACPI_BUFFER *InBuffer) +{ + ACPI_EVALUATE_INFO *Info; + ACPI_OPERAND_OBJECT *Args[2]; + ACPI_STATUS Status; + ACPI_BUFFER Buffer; + + + ACPI_FUNCTION_TRACE (RsSetSrsMethodData); + + + /* Allocate and initialize the evaluation information block */ + + Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO)); + if (!Info) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Info->PrefixNode = Node; + Info->Pathname = METHOD_NAME__SRS; + Info->Parameters = Args; + Info->Flags = ACPI_IGNORE_RETURN_VALUE; + + /* + * The InBuffer parameter will point to a linked list of + * resource parameters. It needs to be formatted into a + * byte stream to be sent in as an input parameter to _SRS + * + * Convert the linked list into a byte stream + */ + Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; + Status = AcpiRsCreateAmlResources (InBuffer->Pointer, &Buffer); + if (ACPI_FAILURE (Status)) + { + goto Cleanup; + } + + /* Create and initialize the method parameter object */ + + Args[0] = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER); + if (!Args[0]) + { + /* + * Must free the buffer allocated above (otherwise it is freed + * later) + */ + ACPI_FREE (Buffer.Pointer); + Status = AE_NO_MEMORY; + goto Cleanup; + } + + Args[0]->Buffer.Length = (UINT32) Buffer.Length; + Args[0]->Buffer.Pointer = Buffer.Pointer; + Args[0]->Common.Flags = AOPOBJ_DATA_VALID; + Args[1] = NULL; + + /* Execute the method, no return value is expected */ + + Status = AcpiNsEvaluate (Info); + + /* Clean up and return the status from AcpiNsEvaluate */ + + AcpiUtRemoveReference (Args[0]); + +Cleanup: + ACPI_FREE (Info); + return_ACPI_STATUS (Status); +} + diff --git a/reactos/drivers/bus/acpi/acpica/resources/rsxface.c b/reactos/drivers/bus/acpi/acpica/resources/rsxface.c new file mode 100644 index 00000000000..a509c7afc7a --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/resources/rsxface.c @@ -0,0 +1,713 @@ +/******************************************************************************* + * + * Module Name: rsxface - Public interfaces to the resource manager + * + ******************************************************************************/ + +/****************************************************************************** + * + * 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 __RSXFACE_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acresrc.h" +#include "acnamesp.h" + +#define _COMPONENT ACPI_RESOURCES + ACPI_MODULE_NAME ("rsxface") + +/* Local macros for 16,32-bit to 64-bit conversion */ + +#define ACPI_COPY_FIELD(Out, In, Field) ((Out)->Field = (In)->Field) +#define ACPI_COPY_ADDRESS(Out, In) \ + ACPI_COPY_FIELD(Out, In, ResourceType); \ + ACPI_COPY_FIELD(Out, In, ProducerConsumer); \ + ACPI_COPY_FIELD(Out, In, Decode); \ + ACPI_COPY_FIELD(Out, In, MinAddressFixed); \ + ACPI_COPY_FIELD(Out, In, MaxAddressFixed); \ + ACPI_COPY_FIELD(Out, In, Info); \ + ACPI_COPY_FIELD(Out, In, Granularity); \ + ACPI_COPY_FIELD(Out, In, Minimum); \ + ACPI_COPY_FIELD(Out, In, Maximum); \ + ACPI_COPY_FIELD(Out, In, TranslationOffset); \ + ACPI_COPY_FIELD(Out, In, AddressLength); \ + ACPI_COPY_FIELD(Out, In, ResourceSource); + + +/* Local prototypes */ + +static ACPI_STATUS +AcpiRsMatchVendorResource ( + ACPI_RESOURCE *Resource, + void *Context); + +static ACPI_STATUS +AcpiRsValidateParameters ( + ACPI_HANDLE DeviceHandle, + ACPI_BUFFER *Buffer, + ACPI_NAMESPACE_NODE **ReturnNode); + + +/******************************************************************************* + * + * FUNCTION: AcpiRsValidateParameters + * + * PARAMETERS: DeviceHandle - Handle to a device + * Buffer - Pointer to a data buffer + * ReturnNode - Pointer to where the device node is returned + * + * RETURN: Status + * + * DESCRIPTION: Common parameter validation for resource interfaces + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiRsValidateParameters ( + ACPI_HANDLE DeviceHandle, + ACPI_BUFFER *Buffer, + ACPI_NAMESPACE_NODE **ReturnNode) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + + + ACPI_FUNCTION_TRACE (RsValidateParameters); + + + /* + * Must have a valid handle to an ACPI device + */ + if (!DeviceHandle) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Node = AcpiNsValidateHandle (DeviceHandle); + if (!Node) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + if (Node->Type != ACPI_TYPE_DEVICE) + { + return_ACPI_STATUS (AE_TYPE); + } + + /* + * Validate the user buffer object + * + * if there is a non-zero buffer length we also need a valid pointer in + * the buffer. If it's a zero buffer length, we'll be returning the + * needed buffer size (later), so keep going. + */ + Status = AcpiUtValidateBuffer (Buffer); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + *ReturnNode = Node; + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiGetIrqRoutingTable + * + * PARAMETERS: DeviceHandle - Handle to the Bus device we are querying + * RetBuffer - Pointer to a buffer to receive the + * current resources for the device + * + * RETURN: Status + * + * DESCRIPTION: This function is called to get the IRQ routing table for a + * specific bus. The caller must first acquire a handle for the + * desired bus. The routine table is placed in the buffer pointed + * to by the RetBuffer variable parameter. + * + * If the function fails an appropriate status will be returned + * and the value of RetBuffer is undefined. + * + * This function attempts to execute the _PRT method contained in + * the object indicated by the passed DeviceHandle. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetIrqRoutingTable ( + ACPI_HANDLE DeviceHandle, + ACPI_BUFFER *RetBuffer) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + + + ACPI_FUNCTION_TRACE (AcpiGetIrqRoutingTable); + + + /* Validate parameters then dispatch to internal routine */ + + Status = AcpiRsValidateParameters (DeviceHandle, RetBuffer, &Node); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiRsGetPrtMethodData (Node, RetBuffer); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiGetIrqRoutingTable) + + +/******************************************************************************* + * + * FUNCTION: AcpiGetCurrentResources + * + * PARAMETERS: DeviceHandle - Handle to the device object for the + * device we are querying + * RetBuffer - Pointer to a buffer to receive the + * current resources for the device + * + * RETURN: Status + * + * DESCRIPTION: This function is called to get the current resources for a + * specific device. The caller must first acquire a handle for + * the desired device. The resource data is placed in the buffer + * pointed to by the RetBuffer variable parameter. + * + * If the function fails an appropriate status will be returned + * and the value of RetBuffer is undefined. + * + * This function attempts to execute the _CRS method contained in + * the object indicated by the passed DeviceHandle. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetCurrentResources ( + ACPI_HANDLE DeviceHandle, + ACPI_BUFFER *RetBuffer) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + + + ACPI_FUNCTION_TRACE (AcpiGetCurrentResources); + + + /* Validate parameters then dispatch to internal routine */ + + Status = AcpiRsValidateParameters (DeviceHandle, RetBuffer, &Node); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiRsGetCrsMethodData (Node, RetBuffer); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiGetCurrentResources) + + +/******************************************************************************* + * + * FUNCTION: AcpiGetPossibleResources + * + * PARAMETERS: DeviceHandle - Handle to the device object for the + * device we are querying + * RetBuffer - Pointer to a buffer to receive the + * resources for the device + * + * RETURN: Status + * + * DESCRIPTION: This function is called to get a list of the possible resources + * for a specific device. The caller must first acquire a handle + * for the desired device. The resource data is placed in the + * buffer pointed to by the RetBuffer variable. + * + * If the function fails an appropriate status will be returned + * and the value of RetBuffer is undefined. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetPossibleResources ( + ACPI_HANDLE DeviceHandle, + ACPI_BUFFER *RetBuffer) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + + + ACPI_FUNCTION_TRACE (AcpiGetPossibleResources); + + + /* Validate parameters then dispatch to internal routine */ + + Status = AcpiRsValidateParameters (DeviceHandle, RetBuffer, &Node); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiRsGetPrsMethodData (Node, RetBuffer); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiGetPossibleResources) + + +/******************************************************************************* + * + * FUNCTION: AcpiSetCurrentResources + * + * PARAMETERS: DeviceHandle - Handle to the device object for the + * device we are setting resources + * InBuffer - Pointer to a buffer containing the + * resources to be set for the device + * + * RETURN: Status + * + * DESCRIPTION: This function is called to set the current resources for a + * specific device. The caller must first acquire a handle for + * the desired device. The resource data is passed to the routine + * the buffer pointed to by the InBuffer variable. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiSetCurrentResources ( + ACPI_HANDLE DeviceHandle, + ACPI_BUFFER *InBuffer) +{ + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + + + ACPI_FUNCTION_TRACE (AcpiSetCurrentResources); + + + /* Validate the buffer, don't allow zero length */ + + if ((!InBuffer) || + (!InBuffer->Pointer) || + (!InBuffer->Length)) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Validate parameters then dispatch to internal routine */ + + Status = AcpiRsValidateParameters (DeviceHandle, InBuffer, &Node); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiRsSetSrsMethodData (Node, InBuffer); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiSetCurrentResources) + + +/****************************************************************************** + * + * FUNCTION: AcpiResourceToAddress64 + * + * PARAMETERS: Resource - Pointer to a resource + * Out - Pointer to the users's return buffer + * (a struct acpi_resource_address64) + * + * RETURN: Status + * + * DESCRIPTION: If the resource is an address16, address32, or address64, + * copy it to the address64 return buffer. This saves the + * caller from having to duplicate code for different-sized + * addresses. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiResourceToAddress64 ( + ACPI_RESOURCE *Resource, + ACPI_RESOURCE_ADDRESS64 *Out) +{ + ACPI_RESOURCE_ADDRESS16 *Address16; + ACPI_RESOURCE_ADDRESS32 *Address32; + + + if (!Resource || !Out) + { + return (AE_BAD_PARAMETER); + } + + /* Convert 16 or 32 address descriptor to 64 */ + + switch (Resource->Type) + { + case ACPI_RESOURCE_TYPE_ADDRESS16: + + Address16 = ACPI_CAST_PTR (ACPI_RESOURCE_ADDRESS16, &Resource->Data); + ACPI_COPY_ADDRESS (Out, Address16); + break; + + case ACPI_RESOURCE_TYPE_ADDRESS32: + + Address32 = ACPI_CAST_PTR (ACPI_RESOURCE_ADDRESS32, &Resource->Data); + ACPI_COPY_ADDRESS (Out, Address32); + break; + + case ACPI_RESOURCE_TYPE_ADDRESS64: + + /* Simple copy for 64 bit source */ + + ACPI_MEMCPY (Out, &Resource->Data, sizeof (ACPI_RESOURCE_ADDRESS64)); + break; + + default: + return (AE_BAD_PARAMETER); + } + + return (AE_OK); +} + +ACPI_EXPORT_SYMBOL (AcpiResourceToAddress64) + + +/******************************************************************************* + * + * FUNCTION: AcpiGetVendorResource + * + * PARAMETERS: DeviceHandle - Handle for the parent device object + * Name - Method name for the parent resource + * (METHOD_NAME__CRS or METHOD_NAME__PRS) + * Uuid - Pointer to the UUID to be matched. + * includes both subtype and 16-byte UUID + * RetBuffer - Where the vendor resource is returned + * + * RETURN: Status + * + * DESCRIPTION: Walk a resource template for the specified evice to find a + * vendor-defined resource that matches the supplied UUID and + * UUID subtype. Returns a ACPI_RESOURCE of type Vendor. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetVendorResource ( + ACPI_HANDLE DeviceHandle, + char *Name, + ACPI_VENDOR_UUID *Uuid, + ACPI_BUFFER *RetBuffer) +{ + ACPI_VENDOR_WALK_INFO Info; + ACPI_STATUS Status; + + + /* Other parameters are validated by AcpiWalkResources */ + + if (!Uuid || !RetBuffer) + { + return (AE_BAD_PARAMETER); + } + + Info.Uuid = Uuid; + Info.Buffer = RetBuffer; + Info.Status = AE_NOT_EXIST; + + /* Walk the _CRS or _PRS resource list for this device */ + + Status = AcpiWalkResources (DeviceHandle, Name, AcpiRsMatchVendorResource, + &Info); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + return (Info.Status); +} + +ACPI_EXPORT_SYMBOL (AcpiGetVendorResource) + + +/******************************************************************************* + * + * FUNCTION: AcpiRsMatchVendorResource + * + * PARAMETERS: ACPI_WALK_RESOURCE_CALLBACK + * + * RETURN: Status + * + * DESCRIPTION: Match a vendor resource via the ACPI 3.0 UUID + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiRsMatchVendorResource ( + ACPI_RESOURCE *Resource, + void *Context) +{ + ACPI_VENDOR_WALK_INFO *Info = Context; + ACPI_RESOURCE_VENDOR_TYPED *Vendor; + ACPI_BUFFER *Buffer; + ACPI_STATUS Status; + + + /* Ignore all descriptors except Vendor */ + + if (Resource->Type != ACPI_RESOURCE_TYPE_VENDOR) + { + return (AE_OK); + } + + Vendor = &Resource->Data.VendorTyped; + + /* + * For a valid match, these conditions must hold: + * + * 1) Length of descriptor data must be at least as long as a UUID struct + * 2) The UUID subtypes must match + * 3) The UUID data must match + */ + if ((Vendor->ByteLength < (ACPI_UUID_LENGTH + 1)) || + (Vendor->UuidSubtype != Info->Uuid->Subtype) || + (ACPI_MEMCMP (Vendor->Uuid, Info->Uuid->Data, ACPI_UUID_LENGTH))) + { + return (AE_OK); + } + + /* Validate/Allocate/Clear caller buffer */ + + Buffer = Info->Buffer; + Status = AcpiUtInitializeBuffer (Buffer, Resource->Length); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Found the correct resource, copy and return it */ + + ACPI_MEMCPY (Buffer->Pointer, Resource, Resource->Length); + Buffer->Length = Resource->Length; + + /* Found the desired descriptor, terminate resource walk */ + + Info->Status = AE_OK; + return (AE_CTRL_TERMINATE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiWalkResources + * + * PARAMETERS: DeviceHandle - Handle to the device object for the + * device we are querying + * Name - Method name of the resources we want + * (METHOD_NAME__CRS or METHOD_NAME__PRS) + * UserFunction - Called for each resource + * Context - Passed to UserFunction + * + * RETURN: Status + * + * DESCRIPTION: Retrieves the current or possible resource list for the + * specified device. The UserFunction is called once for + * each resource in the list. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiWalkResources ( + ACPI_HANDLE DeviceHandle, + char *Name, + ACPI_WALK_RESOURCE_CALLBACK UserFunction, + void *Context) +{ + ACPI_STATUS Status; + ACPI_BUFFER Buffer; + ACPI_RESOURCE *Resource; + ACPI_RESOURCE *ResourceEnd; + + + ACPI_FUNCTION_TRACE (AcpiWalkResources); + + + /* Parameter validation */ + + if (!DeviceHandle || !UserFunction || !Name || + (!ACPI_COMPARE_NAME (Name, METHOD_NAME__CRS) && + !ACPI_COMPARE_NAME (Name, METHOD_NAME__PRS))) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Get the _CRS or _PRS resource list */ + + Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; + Status = AcpiRsGetMethodData (DeviceHandle, Name, &Buffer); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Buffer now contains the resource list */ + + Resource = ACPI_CAST_PTR (ACPI_RESOURCE, Buffer.Pointer); + ResourceEnd = ACPI_ADD_PTR (ACPI_RESOURCE, Buffer.Pointer, Buffer.Length); + + /* Walk the resource list until the EndTag is found (or buffer end) */ + + while (Resource < ResourceEnd) + { + /* Sanity check the resource */ + + if (Resource->Type > ACPI_RESOURCE_TYPE_MAX) + { + Status = AE_AML_INVALID_RESOURCE_TYPE; + break; + } + + /* Invoke the user function, abort on any error returned */ + + Status = UserFunction (Resource, Context); + if (ACPI_FAILURE (Status)) + { + if (Status == AE_CTRL_TERMINATE) + { + /* This is an OK termination by the user function */ + + Status = AE_OK; + } + break; + } + + /* EndTag indicates end-of-list */ + + if (Resource->Type == ACPI_RESOURCE_TYPE_END_TAG) + { + break; + } + + /* Get the next resource descriptor */ + + Resource = ACPI_ADD_PTR (ACPI_RESOURCE, Resource, Resource->Length); + } + + ACPI_FREE (Buffer.Pointer); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiWalkResources) diff --git a/reactos/drivers/bus/acpi/acpica/tables/tbconvrt.c b/reactos/drivers/bus/acpi/acpica/tables/tbconvrt.c new file mode 100644 index 00000000000..77ece2ae07a --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/tables/tbconvrt.c @@ -0,0 +1,547 @@ +/****************************************************************************** + * + * Module Name: tbconvrt - ACPI Table conversion utilities + * $Revision: 1.1 $ + * + *****************************************************************************/ + +/* + * Copyright (C) 2000, 2001 R. Byron Moore + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#include + +#define _COMPONENT ACPI_TABLES + MODULE_NAME ("tbconvrt") + + +/* + * Build a GAS structure from earlier ACPI table entries (V1.0 and 0.71 extensions) + * + * 1) Address space + * 2) Length in bytes -- convert to length in bits + * 3) Bit offset is zero + * 4) Reserved field is zero + * 5) Expand address to 64 bits + */ +#define ASL_BUILD_GAS_FROM_ENTRY(a,b,c,d) {a.address_space_id = (u8) d;\ + a.register_bit_width = (u8) MUL_8 (b);\ + a.register_bit_offset = 0;\ + a.reserved = 0;\ + ACPI_STORE_ADDRESS (a.address,c);} + + +/* ACPI V1.0 entries -- address space is always I/O */ + +#define ASL_BUILD_GAS_FROM_V1_ENTRY(a,b,c) ASL_BUILD_GAS_FROM_ENTRY(a,b,c,ADDRESS_SPACE_SYSTEM_IO) + + +/******************************************************************************* + * + * FUNCTION: Acpi_tb_convert_to_xsdt + * + * PARAMETERS: + * + * RETURN: + * + * DESCRIPTION: + * + ******************************************************************************/ + +ACPI_STATUS +acpi_tb_convert_to_xsdt ( + ACPI_TABLE_DESC *table_info, + u32 *number_of_tables) { + u32 table_size; + u32 pointer_size; + u32 i; + XSDT_DESCRIPTOR *new_table; + + +#ifndef _IA64 + + if (acpi_gbl_RSDP->revision < 2) { + pointer_size = sizeof (u32); + } + + else +#endif + { + pointer_size = sizeof (UINT64); + } + + /* + * Determine the number of tables pointed to by the RSDT/XSDT. + * This is defined by the ACPI Specification to be the number of + * pointers contained within the RSDT/XSDT. The size of the pointers + * is architecture-dependent. + */ + + table_size = table_info->pointer->length; + *number_of_tables = (table_size - + sizeof (ACPI_TABLE_HEADER)) / pointer_size; + + /* Compute size of the converted XSDT */ + + table_size = (*number_of_tables * sizeof (UINT64)) + sizeof (ACPI_TABLE_HEADER); + + + /* Allocate an XSDT */ + + new_table = acpi_cm_callocate (table_size); + if (!new_table) { + return (AE_NO_MEMORY); + } + + /* Copy the header and set the length */ + + MEMCPY (new_table, table_info->pointer, sizeof (ACPI_TABLE_HEADER)); + new_table->header.length = table_size; + + /* Copy the table pointers */ + + for (i = 0; i < *number_of_tables; i++) { + if (acpi_gbl_RSDP->revision < 2) { +#ifdef _IA64 + new_table->table_offset_entry[i] = + ((RSDT_DESCRIPTOR_REV071 *) table_info->pointer)->table_offset_entry[i]; +#else + ACPI_STORE_ADDRESS (new_table->table_offset_entry[i], + ((RSDT_DESCRIPTOR_REV1 *) table_info->pointer)->table_offset_entry[i]); +#endif + } + else { + new_table->table_offset_entry[i] = + ((XSDT_DESCRIPTOR *) table_info->pointer)->table_offset_entry[i]; + } + } + + + /* Delete the original table (either mapped or in a buffer) */ + + acpi_tb_delete_single_table (table_info); + + + /* Point the table descriptor to the new table */ + + table_info->pointer = (ACPI_TABLE_HEADER *) new_table; + table_info->base_pointer = (ACPI_TABLE_HEADER *) new_table; + table_info->length = table_size; + table_info->allocation = ACPI_MEM_ALLOCATED; + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: Acpi_tb_convert_table_fadt + * + * PARAMETERS: + * + * RETURN: + * + * DESCRIPTION: + * Converts BIOS supplied 1.0 and 0.71 ACPI FADT to an intermediate + * ACPI 2.0 FADT. If the BIOS supplied a 2.0 FADT then it is simply + * copied to the intermediate FADT. The ACPI CA software uses this + * intermediate FADT. Thus a significant amount of special #ifdef + * type codeing is saved. This intermediate FADT will need to be + * freed at some point. + * + ******************************************************************************/ + +ACPI_STATUS +acpi_tb_convert_table_fadt (void) +{ + +#ifdef _IA64 + FADT_DESCRIPTOR_REV071 *FADT71; + u8 pm1_address_space; + u8 pm2_address_space; + u8 pm_timer_address_space; + u8 gpe0address_space; + u8 gpe1_address_space; +#else + FADT_DESCRIPTOR_REV1 *FADT1; +#endif + + FADT_DESCRIPTOR_REV2 *FADT2; + ACPI_TABLE_DESC *table_desc; + + + /* Acpi_gbl_FADT is valid */ + /* Allocate and zero the 2.0 buffer */ + + FADT2 = acpi_cm_callocate (sizeof (FADT_DESCRIPTOR_REV2)); + if (FADT2 == NULL) { + return (AE_NO_MEMORY); + } + + + /* The ACPI FADT revision number is FADT2_REVISION_ID=3 */ + /* So, if the current table revision is less than 3 it is type 1.0 or 0.71 */ + + if (acpi_gbl_FADT->header.revision >= FADT2_REVISION_ID) { + /* We have an ACPI 2.0 FADT but we must copy it to our local buffer */ + + *FADT2 = *((FADT_DESCRIPTOR_REV2*) acpi_gbl_FADT); + + } + + else { + +#ifdef _IA64 + /* + * For the 64-bit case only, a revision ID less than V2.0 means the + * tables are the 0.71 extensions + */ + + /* The BIOS stored FADT should agree with Revision 0.71 */ + + FADT71 = (FADT_DESCRIPTOR_REV071 *) acpi_gbl_FADT; + + /* Copy the table header*/ + + FADT2->header = FADT71->header; + + /* Copy the common fields */ + + FADT2->sci_int = FADT71->sci_int; + FADT2->acpi_enable = FADT71->acpi_enable; + FADT2->acpi_disable = FADT71->acpi_disable; + FADT2->S4_bios_req = FADT71->S4_bios_req; + FADT2->plvl2_lat = FADT71->plvl2_lat; + FADT2->plvl3_lat = FADT71->plvl3_lat; + FADT2->day_alrm = FADT71->day_alrm; + FADT2->mon_alrm = FADT71->mon_alrm; + FADT2->century = FADT71->century; + FADT2->gpe1_base = FADT71->gpe1_base; + + /* + * We still use the block length registers even though + * the GAS structure should obsolete them. This is because + * these registers are byte lengths versus the GAS which + * contains a bit width + */ + FADT2->pm1_evt_len = FADT71->pm1_evt_len; + FADT2->pm1_cnt_len = FADT71->pm1_cnt_len; + FADT2->pm2_cnt_len = FADT71->pm2_cnt_len; + FADT2->pm_tm_len = FADT71->pm_tm_len; + FADT2->gpe0blk_len = FADT71->gpe0blk_len; + FADT2->gpe1_blk_len = FADT71->gpe1_blk_len; + FADT2->gpe1_base = FADT71->gpe1_base; + + /* Copy the existing 0.71 flags to 2.0. The other bits are zero.*/ + + FADT2->wb_invd = FADT71->flush_cash; + FADT2->proc_c1 = FADT71->proc_c1; + FADT2->plvl2_up = FADT71->plvl2_up; + FADT2->pwr_button = FADT71->pwr_button; + FADT2->sleep_button = FADT71->sleep_button; + FADT2->fixed_rTC = FADT71->fixed_rTC; + FADT2->rtcs4 = FADT71->rtcs4; + FADT2->tmr_val_ext = FADT71->tmr_val_ext; + FADT2->dock_cap = FADT71->dock_cap; + + + /* We should not use these next two addresses */ + /* Since our buffer is pre-zeroed nothing to do for */ + /* the next three data items in the structure */ + /* FADT2->Firmware_ctrl = 0; */ + /* FADT2->Dsdt = 0; */ + + /* System Interrupt Model isn't used in ACPI 2.0*/ + /* FADT2->Reserved1 = 0; */ + + /* This field is set by the OEM to convey the preferred */ + /* power management profile to OSPM. It doesn't have any*/ + /* 0.71 equivalence. Since we don't know what kind of */ + /* 64-bit system this is, we will pick unspecified. */ + + FADT2->prefer_PM_profile = PM_UNSPECIFIED; + + + /* Port address of SMI command port */ + /* We shouldn't use this port because IA64 doesn't */ + /* have or use SMI. It has PMI. */ + + FADT2->smi_cmd = (u32)(FADT71->smi_cmd & 0xFFFFFFFF); + + + /* processor performance state control*/ + /* The value OSPM writes to the SMI_CMD register to assume */ + /* processor performance state control responsibility. */ + /* There isn't any equivalence in 0.71 */ + /* Again this should be meaningless for IA64 */ + /* FADT2->Pstate_cnt = 0; */ + + /* The 32-bit Power management and GPE registers are */ + /* not valid in IA-64 and we are not going to use them */ + /* so leaving them pre-zeroed. */ + + /* Support for the _CST object and C States change notification.*/ + /* This data item hasn't any 0.71 equivalence so leaving it zero.*/ + /* FADT2->Cst_cnt = 0; */ + + /* number of flush strides that need to be read */ + /* No 0.71 equivalence. Leave pre-zeroed. */ + /* FADT2->Flush_size = 0; */ + + /* Processor's memory cache line width, in bytes */ + /* No 0.71 equivalence. Leave pre-zeroed. */ + /* FADT2->Flush_stride = 0; */ + + /* Processor's duty cycle index in processor's P_CNT reg*/ + /* No 0.71 equivalence. Leave pre-zeroed. */ + /* FADT2->Duty_offset = 0; */ + + /* Processor's duty cycle value bit width in P_CNT register.*/ + /* No 0.71 equivalence. Leave pre-zeroed. */ + /* FADT2->Duty_width = 0; */ + + + /* Since there isn't any equivalence in 0.71 */ + /* and since Big_sur had to support legacy */ + + FADT2->iapc_boot_arch = BAF_LEGACY_DEVICES; + + /* Copy to ACPI 2.0 64-BIT Extended Addresses */ + + FADT2->Xfirmware_ctrl = FADT71->firmware_ctrl; + FADT2->Xdsdt = FADT71->dsdt; + + + /* Extract the address space IDs */ + + pm1_address_space = (u8)((FADT71->address_space & PM1_BLK_ADDRESS_SPACE) >> 1); + pm2_address_space = (u8)((FADT71->address_space & PM2_CNT_BLK_ADDRESS_SPACE) >> 2); + pm_timer_address_space = (u8)((FADT71->address_space & PM_TMR_BLK_ADDRESS_SPACE) >> 3); + gpe0address_space = (u8)((FADT71->address_space & GPE0_BLK_ADDRESS_SPACE) >> 4); + gpe1_address_space = (u8)((FADT71->address_space & GPE1_BLK_ADDRESS_SPACE) >> 5); + + /* + * Convert the 0.71 (non-GAS style) Block addresses to V2.0 GAS structures, + * in this order: + * + * PM 1_a Events + * PM 1_b Events + * PM 1_a Control + * PM 1_b Control + * PM 2 Control + * PM Timer Control + * GPE Block 0 + * GPE Block 1 + */ + + ASL_BUILD_GAS_FROM_ENTRY (FADT2->Xpm1a_evt_blk, FADT71->pm1_evt_len, FADT71->pm1a_evt_blk, pm1_address_space); + ASL_BUILD_GAS_FROM_ENTRY (FADT2->Xpm1b_evt_blk, FADT71->pm1_evt_len, FADT71->pm1b_evt_blk, pm1_address_space); + ASL_BUILD_GAS_FROM_ENTRY (FADT2->Xpm1a_cnt_blk, FADT71->pm1_cnt_len, FADT71->pm1a_cnt_blk, pm1_address_space); + ASL_BUILD_GAS_FROM_ENTRY (FADT2->Xpm1b_cnt_blk, FADT71->pm1_cnt_len, FADT71->pm1b_cnt_blk, pm1_address_space); + ASL_BUILD_GAS_FROM_ENTRY (FADT2->Xpm2_cnt_blk, FADT71->pm2_cnt_len, FADT71->pm2_cnt_blk, pm2_address_space); + ASL_BUILD_GAS_FROM_ENTRY (FADT2->Xpm_tmr_blk, FADT71->pm_tm_len, FADT71->pm_tmr_blk, pm_timer_address_space); + ASL_BUILD_GAS_FROM_ENTRY (FADT2->Xgpe0blk, FADT71->gpe0blk_len, FADT71->gpe0blk, gpe0address_space); + ASL_BUILD_GAS_FROM_ENTRY (FADT2->Xgpe1_blk, FADT71->gpe1_blk_len, FADT71->gpe1_blk, gpe1_address_space); + +#else + + /* ACPI 1.0 FACS */ + + + /* The BIOS stored FADT should agree with Revision 1.0 */ + + FADT1 = (FADT_DESCRIPTOR_REV1*) acpi_gbl_FADT; + + /* + * Copy the table header and the common part of the tables + * The 2.0 table is an extension of the 1.0 table, so the + * entire 1.0 table can be copied first, then expand some + * fields to 64 bits. + */ + + MEMCPY (FADT2, FADT1, sizeof (FADT_DESCRIPTOR_REV1)); + + + /* Convert table pointers to 64-bit fields */ + + ACPI_STORE_ADDRESS (FADT2->Xfirmware_ctrl, FADT1->firmware_ctrl); + ACPI_STORE_ADDRESS (FADT2->Xdsdt, FADT1->dsdt); + + /* System Interrupt Model isn't used in ACPI 2.0*/ + /* FADT2->Reserved1 = 0; */ + + /* This field is set by the OEM to convey the preferred */ + /* power management profile to OSPM. It doesn't have any*/ + /* 1.0 equivalence. Since we don't know what kind of */ + /* 32-bit system this is, we will pick unspecified. */ + + FADT2->prefer_PM_profile = PM_UNSPECIFIED; + + + /* Processor Performance State Control. This is the value */ + /* OSPM writes to the SMI_CMD register to assume processor */ + /* performance state control responsibility. There isn't */ + /* any equivalence in 1.0. So leave it zeroed. */ + + FADT2->pstate_cnt = 0; + + + /* Support for the _CST object and C States change notification.*/ + /* This data item hasn't any 1.0 equivalence so leaving it zero.*/ + + FADT2->cst_cnt = 0; + + + /* Since there isn't any equivalence in 1.0 and since it */ + /* is highly likely that a 1.0 system has legacy support. */ + + FADT2->iapc_boot_arch = BAF_LEGACY_DEVICES; + + + /* + * Convert the V1.0 Block addresses to V2.0 GAS structures + * in this order: + * + * PM 1_a Events + * PM 1_b Events + * PM 1_a Control + * PM 1_b Control + * PM 2 Control + * PM Timer Control + * GPE Block 0 + * GPE Block 1 + */ + + ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xpm1a_evt_blk, FADT1->pm1_evt_len, FADT1->pm1a_evt_blk); + ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xpm1b_evt_blk, FADT1->pm1_evt_len, FADT1->pm1b_evt_blk); + ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xpm1a_cnt_blk, FADT1->pm1_cnt_len, FADT1->pm1a_cnt_blk); + ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xpm1b_cnt_blk, FADT1->pm1_cnt_len, FADT1->pm1b_cnt_blk); + ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xpm2_cnt_blk, FADT1->pm2_cnt_len, FADT1->pm2_cnt_blk); + ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xpm_tmr_blk, FADT1->pm_tm_len, FADT1->pm_tmr_blk); + ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xgpe0blk, FADT1->gpe0blk_len, FADT1->gpe0blk); + ASL_BUILD_GAS_FROM_V1_ENTRY (FADT2->Xgpe1_blk, FADT1->gpe1_blk_len, FADT1->gpe1_blk); +#endif + } + + + /* + * Global FADT pointer will point to the common V2.0 FADT + */ + acpi_gbl_FADT = FADT2; + acpi_gbl_FADT->header.length = sizeof (FADT_DESCRIPTOR); + + + /* Free the original table */ + + table_desc = &acpi_gbl_acpi_tables[ACPI_TABLE_FADT]; + acpi_tb_delete_single_table (table_desc); + + + /* Install the new table */ + + table_desc->pointer = (ACPI_TABLE_HEADER *) acpi_gbl_FADT; + table_desc->base_pointer = acpi_gbl_FADT; + table_desc->allocation = ACPI_MEM_ALLOCATED; + table_desc->length = sizeof (FADT_DESCRIPTOR_REV2); + + + /* Dump the entire FADT */ + + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: Acpi_tb_convert_table_facs + * + * PARAMETERS: + * + * RETURN: + * + * DESCRIPTION: + * + ******************************************************************************/ + +ACPI_STATUS +acpi_tb_build_common_facs ( + ACPI_TABLE_DESC *table_info) +{ + ACPI_COMMON_FACS *common_facs; + +#ifdef _IA64 + FACS_DESCRIPTOR_REV071 *FACS71; +#else + FACS_DESCRIPTOR_REV1 *FACS1; +#endif + + FACS_DESCRIPTOR_REV2 *FACS2; + + + /* Allocate a common FACS */ + + common_facs = acpi_cm_callocate (sizeof (ACPI_COMMON_FACS)); + if (!common_facs) { + return (AE_NO_MEMORY); + } + + + /* Copy fields to the new FACS */ + + if (acpi_gbl_RSDP->revision < 2) { +#ifdef _IA64 + /* 0.71 FACS */ + + FACS71 = (FACS_DESCRIPTOR_REV071 *) acpi_gbl_FACS; + + common_facs->global_lock = (u32 *) &(FACS71->global_lock); + common_facs->firmware_waking_vector = &FACS71->firmware_waking_vector; + common_facs->vector_width = 64; +#else + /* ACPI 1.0 FACS */ + + FACS1 = (FACS_DESCRIPTOR_REV1 *) acpi_gbl_FACS; + + common_facs->global_lock = &(FACS1->global_lock); + common_facs->firmware_waking_vector = (UINT64 *) &FACS1->firmware_waking_vector; + common_facs->vector_width = 32; + +#endif + } + + else { + /* ACPI 2.0 FACS */ + + FACS2 = (FACS_DESCRIPTOR_REV2 *) acpi_gbl_FACS; + + common_facs->global_lock = &(FACS2->global_lock); + common_facs->firmware_waking_vector = &FACS2->Xfirmware_waking_vector; + common_facs->vector_width = 64; + } + + + /* Set the global FACS pointer to point to the common FACS */ + + + acpi_gbl_FACS = common_facs; + + return (AE_OK); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/tables/tbfadt.c b/reactos/drivers/bus/acpi/acpica/tables/tbfadt.c new file mode 100644 index 00000000000..c657a0b75ac --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/tables/tbfadt.c @@ -0,0 +1,752 @@ +/****************************************************************************** + * + * Module Name: tbfadt - FADT table utilities + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __TBFADT_C__ + +#include "acpi.h" +#include "accommon.h" +#include "actables.h" + +#define _COMPONENT ACPI_TABLES + ACPI_MODULE_NAME ("tbfadt") + +/* Local prototypes */ + +static inline void +AcpiTbInitGenericAddress ( + ACPI_GENERIC_ADDRESS *GenericAddress, + UINT8 SpaceId, + UINT8 ByteWidth, + UINT64 Address); + +static void +AcpiTbConvertFadt ( + void); + +static void +AcpiTbValidateFadt ( + void); + +static void +AcpiTbSetupFadtRegisters ( + void); + + +/* Table for conversion of FADT to common internal format and FADT validation */ + +typedef struct acpi_fadt_info +{ + char *Name; + UINT8 Address64; + UINT8 Address32; + UINT8 Length; + UINT8 DefaultLength; + UINT8 Type; + +} ACPI_FADT_INFO; + +#define ACPI_FADT_REQUIRED 1 +#define ACPI_FADT_SEPARATE_LENGTH 2 + +static ACPI_FADT_INFO FadtInfoTable[] = +{ + {"Pm1aEventBlock", + ACPI_FADT_OFFSET (XPm1aEventBlock), + ACPI_FADT_OFFSET (Pm1aEventBlock), + ACPI_FADT_OFFSET (Pm1EventLength), + ACPI_PM1_REGISTER_WIDTH * 2, /* Enable + Status register */ + ACPI_FADT_REQUIRED}, + + {"Pm1bEventBlock", + ACPI_FADT_OFFSET (XPm1bEventBlock), + ACPI_FADT_OFFSET (Pm1bEventBlock), + ACPI_FADT_OFFSET (Pm1EventLength), + ACPI_PM1_REGISTER_WIDTH * 2, /* Enable + Status register */ + 0}, + + {"Pm1aControlBlock", + ACPI_FADT_OFFSET (XPm1aControlBlock), + ACPI_FADT_OFFSET (Pm1aControlBlock), + ACPI_FADT_OFFSET (Pm1ControlLength), + ACPI_PM1_REGISTER_WIDTH, + ACPI_FADT_REQUIRED}, + + {"Pm1bControlBlock", + ACPI_FADT_OFFSET (XPm1bControlBlock), + ACPI_FADT_OFFSET (Pm1bControlBlock), + ACPI_FADT_OFFSET (Pm1ControlLength), + ACPI_PM1_REGISTER_WIDTH, + 0}, + + {"Pm2ControlBlock", + ACPI_FADT_OFFSET (XPm2ControlBlock), + ACPI_FADT_OFFSET (Pm2ControlBlock), + ACPI_FADT_OFFSET (Pm2ControlLength), + ACPI_PM2_REGISTER_WIDTH, + ACPI_FADT_SEPARATE_LENGTH}, + + {"PmTimerBlock", + ACPI_FADT_OFFSET (XPmTimerBlock), + ACPI_FADT_OFFSET (PmTimerBlock), + ACPI_FADT_OFFSET (PmTimerLength), + ACPI_PM_TIMER_WIDTH, + ACPI_FADT_REQUIRED}, + + {"Gpe0Block", + ACPI_FADT_OFFSET (XGpe0Block), + ACPI_FADT_OFFSET (Gpe0Block), + ACPI_FADT_OFFSET (Gpe0BlockLength), + 0, + ACPI_FADT_SEPARATE_LENGTH}, + + {"Gpe1Block", + ACPI_FADT_OFFSET (XGpe1Block), + ACPI_FADT_OFFSET (Gpe1Block), + ACPI_FADT_OFFSET (Gpe1BlockLength), + 0, + ACPI_FADT_SEPARATE_LENGTH} +}; + +#define ACPI_FADT_INFO_ENTRIES \ + (sizeof (FadtInfoTable) / sizeof (ACPI_FADT_INFO)) + + +/* Table used to split Event Blocks into separate status/enable registers */ + +typedef struct acpi_fadt_pm_info +{ + ACPI_GENERIC_ADDRESS *Target; + UINT8 Source; + UINT8 RegisterNum; + +} ACPI_FADT_PM_INFO; + +static ACPI_FADT_PM_INFO FadtPmInfoTable[] = +{ + {&AcpiGbl_XPm1aStatus, + ACPI_FADT_OFFSET (XPm1aEventBlock), + 0}, + + {&AcpiGbl_XPm1aEnable, + ACPI_FADT_OFFSET (XPm1aEventBlock), + 1}, + + {&AcpiGbl_XPm1bStatus, + ACPI_FADT_OFFSET (XPm1bEventBlock), + 0}, + + {&AcpiGbl_XPm1bEnable, + ACPI_FADT_OFFSET (XPm1bEventBlock), + 1} +}; + +#define ACPI_FADT_PM_INFO_ENTRIES \ + (sizeof (FadtPmInfoTable) / sizeof (ACPI_FADT_PM_INFO)) + + +/******************************************************************************* + * + * FUNCTION: AcpiTbInitGenericAddress + * + * PARAMETERS: GenericAddress - GAS struct to be initialized + * SpaceId - ACPI Space ID for this register + * ByteWidth - Width of this register, in bytes + * Address - Address of the register + * + * RETURN: None + * + * DESCRIPTION: Initialize a Generic Address Structure (GAS) + * See the ACPI specification for a full description and + * definition of this structure. + * + ******************************************************************************/ + +static inline void +AcpiTbInitGenericAddress ( + ACPI_GENERIC_ADDRESS *GenericAddress, + UINT8 SpaceId, + UINT8 ByteWidth, + UINT64 Address) +{ + + /* + * The 64-bit Address field is non-aligned in the byte packed + * GAS struct. + */ + ACPI_MOVE_64_TO_64 (&GenericAddress->Address, &Address); + + /* All other fields are byte-wide */ + + GenericAddress->SpaceId = SpaceId; + GenericAddress->BitWidth = (UINT8) ACPI_MUL_8 (ByteWidth); + GenericAddress->BitOffset = 0; + GenericAddress->AccessWidth = 0; /* Access width ANY */ +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbParseFadt + * + * PARAMETERS: TableIndex - Index for the FADT + * + * RETURN: None + * + * DESCRIPTION: Initialize the FADT, DSDT and FACS tables + * (FADT contains the addresses of the DSDT and FACS) + * + ******************************************************************************/ + +void +AcpiTbParseFadt ( + UINT32 TableIndex) +{ + UINT32 Length; + ACPI_TABLE_HEADER *Table; + + + /* + * The FADT has multiple versions with different lengths, + * and it contains pointers to both the DSDT and FACS tables. + * + * Get a local copy of the FADT and convert it to a common format + * Map entire FADT, assumed to be smaller than one page. + */ + Length = AcpiGbl_RootTableList.Tables[TableIndex].Length; + + Table = AcpiOsMapMemory ( + AcpiGbl_RootTableList.Tables[TableIndex].Address, Length); + if (!Table) + { + return; + } + + /* + * Validate the FADT checksum before we copy the table. Ignore + * checksum error as we want to try to get the DSDT and FACS. + */ + (void) AcpiTbVerifyChecksum (Table, Length); + + /* Create a local copy of the FADT in common ACPI 2.0+ format */ + + AcpiTbCreateLocalFadt (Table, Length); + + /* All done with the real FADT, unmap it */ + + AcpiOsUnmapMemory (Table, Length); + + /* Obtain the DSDT and FACS tables via their addresses within the FADT */ + + AcpiTbInstallTable ((ACPI_PHYSICAL_ADDRESS) AcpiGbl_FADT.XDsdt, + ACPI_SIG_DSDT, ACPI_TABLE_INDEX_DSDT); + + AcpiTbInstallTable ((ACPI_PHYSICAL_ADDRESS) AcpiGbl_FADT.XFacs, + ACPI_SIG_FACS, ACPI_TABLE_INDEX_FACS); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbCreateLocalFadt + * + * PARAMETERS: Table - Pointer to BIOS FADT + * Length - Length of the table + * + * RETURN: None + * + * DESCRIPTION: Get a local copy of the FADT and convert it to a common format. + * Performs validation on some important FADT fields. + * + * NOTE: We create a local copy of the FADT regardless of the version. + * + ******************************************************************************/ + +void +AcpiTbCreateLocalFadt ( + ACPI_TABLE_HEADER *Table, + UINT32 Length) +{ + + /* + * Check if the FADT is larger than the largest table that we expect + * (the ACPI 2.0/3.0 version). If so, truncate the table, and issue + * a warning. + */ + if (Length > sizeof (ACPI_TABLE_FADT)) + { + ACPI_WARNING ((AE_INFO, + "FADT (revision %u) is longer than ACPI 2.0 version, " + "truncating length 0x%X to 0x%X", + Table->Revision, Length, (UINT32) sizeof (ACPI_TABLE_FADT))); + } + + /* Clear the entire local FADT */ + + ACPI_MEMSET (&AcpiGbl_FADT, 0, sizeof (ACPI_TABLE_FADT)); + + /* Copy the original FADT, up to sizeof (ACPI_TABLE_FADT) */ + + ACPI_MEMCPY (&AcpiGbl_FADT, Table, + ACPI_MIN (Length, sizeof (ACPI_TABLE_FADT))); + + /* Convert the local copy of the FADT to the common internal format */ + + AcpiTbConvertFadt (); + + /* Validate FADT values now, before we make any changes */ + + AcpiTbValidateFadt (); + + /* Initialize the global ACPI register structures */ + + AcpiTbSetupFadtRegisters (); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbConvertFadt + * + * PARAMETERS: None, uses AcpiGbl_FADT + * + * RETURN: None + * + * DESCRIPTION: Converts all versions of the FADT to a common internal format. + * Expand 32-bit addresses to 64-bit as necessary. + * + * NOTE: AcpiGbl_FADT must be of size (ACPI_TABLE_FADT), + * and must contain a copy of the actual FADT. + * + * Notes on 64-bit register addresses: + * + * After this FADT conversion, later ACPICA code will only use the 64-bit "X" + * fields of the FADT for all ACPI register addresses. + * + * The 64-bit "X" fields are optional extensions to the original 32-bit FADT + * V1.0 fields. Even if they are present in the FADT, they are optional and + * are unused if the BIOS sets them to zero. Therefore, we must copy/expand + * 32-bit V1.0 fields if the corresponding X field is zero. + * + * For ACPI 1.0 FADTs, all 32-bit address fields are expanded to the + * corresponding "X" fields in the internal FADT. + * + * For ACPI 2.0+ FADTs, all valid (non-zero) 32-bit address fields are expanded + * to the corresponding 64-bit X fields. For compatibility with other ACPI + * implementations, we ignore the 64-bit field if the 32-bit field is valid, + * regardless of whether the host OS is 32-bit or 64-bit. + * + ******************************************************************************/ + +static void +AcpiTbConvertFadt ( + void) +{ + ACPI_GENERIC_ADDRESS *Address64; + UINT32 Address32; + UINT32 i; + + + /* Update the local FADT table header length */ + + AcpiGbl_FADT.Header.Length = sizeof (ACPI_TABLE_FADT); + + /* + * Expand the 32-bit FACS and DSDT addresses to 64-bit as necessary. + * Later code will always use the X 64-bit field. + */ + if (!AcpiGbl_FADT.XFacs) + { + AcpiGbl_FADT.XFacs = (UINT64) AcpiGbl_FADT.Facs; + } + if (!AcpiGbl_FADT.XDsdt) + { + AcpiGbl_FADT.XDsdt = (UINT64) AcpiGbl_FADT.Dsdt; + } + + /* + * For ACPI 1.0 FADTs (revision 1 or 2), ensure that reserved fields which + * should be zero are indeed zero. This will workaround BIOSs that + * inadvertently place values in these fields. + * + * The ACPI 1.0 reserved fields that will be zeroed are the bytes located + * at offset 45, 55, 95, and the word located at offset 109, 110. + */ + if (AcpiGbl_FADT.Header.Revision < 3) + { + AcpiGbl_FADT.PreferredProfile = 0; + AcpiGbl_FADT.PstateControl = 0; + AcpiGbl_FADT.CstControl = 0; + AcpiGbl_FADT.BootFlags = 0; + } + + /* + * Expand the ACPI 1.0 32-bit addresses to the ACPI 2.0 64-bit "X" + * generic address structures as necessary. Later code will always use + * the 64-bit address structures. + * + * March 2009: + * We now always use the 32-bit address if it is valid (non-null). This + * is not in accordance with the ACPI specification which states that + * the 64-bit address supersedes the 32-bit version, but we do this for + * compatibility with other ACPI implementations. Most notably, in the + * case where both the 32 and 64 versions are non-null, we use the 32-bit + * version. This is the only address that is guaranteed to have been + * tested by the BIOS manufacturer. + */ + for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) + { + Address32 = *ACPI_ADD_PTR (UINT32, + &AcpiGbl_FADT, FadtInfoTable[i].Address32); + + Address64 = ACPI_ADD_PTR (ACPI_GENERIC_ADDRESS, + &AcpiGbl_FADT, FadtInfoTable[i].Address64); + + /* + * If both 32- and 64-bit addresses are valid (non-zero), + * they must match. + */ + if (Address64->Address && Address32 && + (Address64->Address != (UINT64) Address32)) + { + ACPI_ERROR ((AE_INFO, + "32/64X address mismatch in %s: %8.8X/%8.8X%8.8X, using 32", + FadtInfoTable[i].Name, Address32, + ACPI_FORMAT_UINT64 (Address64->Address))); + } + + /* Always use 32-bit address if it is valid (non-null) */ + + if (Address32) + { + /* + * Copy the 32-bit address to the 64-bit GAS structure. The + * Space ID is always I/O for 32-bit legacy address fields + */ + AcpiTbInitGenericAddress (Address64, ACPI_ADR_SPACE_SYSTEM_IO, + *ACPI_ADD_PTR (UINT8, &AcpiGbl_FADT, FadtInfoTable[i].Length), + (UINT64) Address32); + } + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbValidateFadt + * + * PARAMETERS: Table - Pointer to the FADT to be validated + * + * RETURN: None + * + * DESCRIPTION: Validate various important fields within the FADT. If a problem + * is found, issue a message, but no status is returned. + * Used by both the table manager and the disassembler. + * + * Possible additional checks: + * (AcpiGbl_FADT.Pm1EventLength >= 4) + * (AcpiGbl_FADT.Pm1ControlLength >= 2) + * (AcpiGbl_FADT.PmTimerLength >= 4) + * Gpe block lengths must be multiple of 2 + * + ******************************************************************************/ + +static void +AcpiTbValidateFadt ( + void) +{ + char *Name; + ACPI_GENERIC_ADDRESS *Address64; + UINT8 Length; + UINT32 i; + + + /* + * Check for FACS and DSDT address mismatches. An address mismatch between + * the 32-bit and 64-bit address fields (FIRMWARE_CTRL/X_FIRMWARE_CTRL and + * DSDT/X_DSDT) would indicate the presence of two FACS or two DSDT tables. + */ + if (AcpiGbl_FADT.Facs && + (AcpiGbl_FADT.XFacs != (UINT64) AcpiGbl_FADT.Facs)) + { + ACPI_WARNING ((AE_INFO, + "32/64X FACS address mismatch in FADT - " + "%8.8X/%8.8X%8.8X, using 32", + AcpiGbl_FADT.Facs, ACPI_FORMAT_UINT64 (AcpiGbl_FADT.XFacs))); + + AcpiGbl_FADT.XFacs = (UINT64) AcpiGbl_FADT.Facs; + } + + if (AcpiGbl_FADT.Dsdt && + (AcpiGbl_FADT.XDsdt != (UINT64) AcpiGbl_FADT.Dsdt)) + { + ACPI_WARNING ((AE_INFO, + "32/64X DSDT address mismatch in FADT - " + "%8.8X/%8.8X%8.8X, using 32", + AcpiGbl_FADT.Dsdt, ACPI_FORMAT_UINT64 (AcpiGbl_FADT.XDsdt))); + + AcpiGbl_FADT.XDsdt = (UINT64) AcpiGbl_FADT.Dsdt; + } + + /* Examine all of the 64-bit extended address fields (X fields) */ + + for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) + { + /* + * Generate pointer to the 64-bit address, get the register + * length (width) and the register name + */ + Address64 = ACPI_ADD_PTR (ACPI_GENERIC_ADDRESS, + &AcpiGbl_FADT, FadtInfoTable[i].Address64); + Length = *ACPI_ADD_PTR (UINT8, + &AcpiGbl_FADT, FadtInfoTable[i].Length); + Name = FadtInfoTable[i].Name; + + /* + * For each extended field, check for length mismatch between the + * legacy length field and the corresponding 64-bit X length field. + */ + if (Address64->Address && + (Address64->BitWidth != ACPI_MUL_8 (Length))) + { + ACPI_WARNING ((AE_INFO, + "32/64X length mismatch in %s: %d/%d", + Name, ACPI_MUL_8 (Length), Address64->BitWidth)); + } + + if (FadtInfoTable[i].Type & ACPI_FADT_REQUIRED) + { + /* + * Field is required (PM1aEvent, PM1aControl, PmTimer). + * Both the address and length must be non-zero. + */ + if (!Address64->Address || !Length) + { + ACPI_ERROR ((AE_INFO, + "Required field %s has zero address and/or length:" + " %8.8X%8.8X/%X", + Name, ACPI_FORMAT_UINT64 (Address64->Address), Length)); + } + } + else if (FadtInfoTable[i].Type & ACPI_FADT_SEPARATE_LENGTH) + { + /* + * Field is optional (PM2Control, GPE0, GPE1) AND has its own + * length field. If present, both the address and length must + * be valid. + */ + if ((Address64->Address && !Length) || + (!Address64->Address && Length)) + { + ACPI_WARNING ((AE_INFO, + "Optional field %s has zero address or length: " + "%8.8X%8.8X/%X", + Name, ACPI_FORMAT_UINT64 (Address64->Address), Length)); + } + } + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbSetupFadtRegisters + * + * PARAMETERS: None, uses AcpiGbl_FADT. + * + * RETURN: None + * + * DESCRIPTION: Initialize global ACPI PM1 register definitions. Optionally, + * force FADT register definitions to their default lengths. + * + ******************************************************************************/ + +static void +AcpiTbSetupFadtRegisters ( + void) +{ + ACPI_GENERIC_ADDRESS *Target64; + ACPI_GENERIC_ADDRESS *Source64; + UINT8 Pm1RegisterByteWidth; + UINT32 i; + + + /* + * Optionally check all register lengths against the default values and + * update them if they are incorrect. + */ + if (AcpiGbl_UseDefaultRegisterWidths) + { + for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) + { + Target64 = ACPI_ADD_PTR (ACPI_GENERIC_ADDRESS, &AcpiGbl_FADT, + FadtInfoTable[i].Address64); + + /* + * If a valid register (Address != 0) and the (DefaultLength > 0) + * (Not a GPE register), then check the width against the default. + */ + if ((Target64->Address) && + (FadtInfoTable[i].DefaultLength > 0) && + (FadtInfoTable[i].DefaultLength != Target64->BitWidth)) + { + ACPI_WARNING ((AE_INFO, + "Invalid length for %s: %d, using default %d", + FadtInfoTable[i].Name, Target64->BitWidth, + FadtInfoTable[i].DefaultLength)); + + /* Incorrect size, set width to the default */ + + Target64->BitWidth = FadtInfoTable[i].DefaultLength; + } + } + } + + /* + * Get the length of the individual PM1 registers (enable and status). + * Each register is defined to be (event block length / 2). Extra divide + * by 8 converts bits to bytes. + */ + Pm1RegisterByteWidth = (UINT8) + ACPI_DIV_16 (AcpiGbl_FADT.XPm1aEventBlock.BitWidth); + + /* + * Calculate separate GAS structs for the PM1x (A/B) Status and Enable + * registers. These addresses do not appear (directly) in the FADT, so it + * is useful to pre-calculate them from the PM1 Event Block definitions. + * + * The PM event blocks are split into two register blocks, first is the + * PM Status Register block, followed immediately by the PM Enable + * Register block. Each is of length (Pm1EventLength/2) + * + * Note: The PM1A event block is required by the ACPI specification. + * However, the PM1B event block is optional and is rarely, if ever, + * used. + */ + + for (i = 0; i < ACPI_FADT_PM_INFO_ENTRIES; i++) + { + Source64 = ACPI_ADD_PTR (ACPI_GENERIC_ADDRESS, &AcpiGbl_FADT, + FadtPmInfoTable[i].Source); + + if (Source64->Address) + { + AcpiTbInitGenericAddress (FadtPmInfoTable[i].Target, + Source64->SpaceId, Pm1RegisterByteWidth, + Source64->Address + + (FadtPmInfoTable[i].RegisterNum * Pm1RegisterByteWidth)); + } + } +} + diff --git a/reactos/drivers/bus/acpi/acpica/tables/tbfind.c b/reactos/drivers/bus/acpi/acpica/tables/tbfind.c new file mode 100644 index 00000000000..1838b5eb78a --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/tables/tbfind.c @@ -0,0 +1,215 @@ +/****************************************************************************** + * + * Module Name: tbfind - find table + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __TBFIND_C__ + +#include "acpi.h" +#include "accommon.h" +#include "actables.h" + +#define _COMPONENT ACPI_TABLES + ACPI_MODULE_NAME ("tbfind") + + +/******************************************************************************* + * + * FUNCTION: AcpiTbFindTable + * + * PARAMETERS: Signature - String with ACPI table signature + * OemId - String with the table OEM ID + * OemTableId - String with the OEM Table ID + * TableIndex - Where the table index is returned + * + * RETURN: Status and table index + * + * DESCRIPTION: Find an ACPI table (in the RSDT/XSDT) that matches the + * Signature, OEM ID and OEM Table ID. Returns an index that can + * be used to get the table header or entire table. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbFindTable ( + char *Signature, + char *OemId, + char *OemTableId, + UINT32 *TableIndex) +{ + UINT32 i; + ACPI_STATUS Status; + ACPI_TABLE_HEADER Header; + + + ACPI_FUNCTION_TRACE (TbFindTable); + + + /* Normalize the input strings */ + + ACPI_MEMSET (&Header, 0, sizeof (ACPI_TABLE_HEADER)); + ACPI_STRNCPY (Header.Signature, Signature, ACPI_NAME_SIZE); + ACPI_STRNCPY (Header.OemId, OemId, ACPI_OEM_ID_SIZE); + ACPI_STRNCPY (Header.OemTableId, OemTableId, ACPI_OEM_TABLE_ID_SIZE); + + /* Search for the table */ + + for (i = 0; i < AcpiGbl_RootTableList.Count; ++i) + { + if (ACPI_MEMCMP (&(AcpiGbl_RootTableList.Tables[i].Signature), + Header.Signature, ACPI_NAME_SIZE)) + { + /* Not the requested table */ + + continue; + } + + /* Table with matching signature has been found */ + + if (!AcpiGbl_RootTableList.Tables[i].Pointer) + { + /* Table is not currently mapped, map it */ + + Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[i]); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (!AcpiGbl_RootTableList.Tables[i].Pointer) + { + continue; + } + } + + /* Check for table match on all IDs */ + + if (!ACPI_MEMCMP (AcpiGbl_RootTableList.Tables[i].Pointer->Signature, + Header.Signature, ACPI_NAME_SIZE) && + (!OemId[0] || + !ACPI_MEMCMP (AcpiGbl_RootTableList.Tables[i].Pointer->OemId, + Header.OemId, ACPI_OEM_ID_SIZE)) && + (!OemTableId[0] || + !ACPI_MEMCMP (AcpiGbl_RootTableList.Tables[i].Pointer->OemTableId, + Header.OemTableId, ACPI_OEM_TABLE_ID_SIZE))) + { + *TableIndex = i; + + ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "Found table [%4.4s]\n", + Header.Signature)); + return_ACPI_STATUS (AE_OK); + } + } + + return_ACPI_STATUS (AE_NOT_FOUND); +} diff --git a/reactos/drivers/bus/acpi/acpica/tables/tbget.c b/reactos/drivers/bus/acpi/acpica/tables/tbget.c new file mode 100644 index 00000000000..e16db9d26b3 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/tables/tbget.c @@ -0,0 +1,608 @@ +/****************************************************************************** + * + * Module Name: tbget - ACPI Table get* routines + * $Revision: 1.1 $ + * + *****************************************************************************/ + +/* + * Copyright (C) 2000, 2001 R. Byron Moore + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#include + +#define _COMPONENT ACPI_TABLES + MODULE_NAME ("tbget") + +#define RSDP_CHECKSUM_LENGTH 20 + +/******************************************************************************* + * + * FUNCTION: Acpi_tb_get_table_ptr + * + * PARAMETERS: Table_type - one of the defined table types + * Instance - Which table of this type + * Table_ptr_loc - pointer to location to place the pointer for + * return + * + * RETURN: Status + * + * DESCRIPTION: This function is called to get the pointer to an ACPI table. + * + ******************************************************************************/ + +ACPI_STATUS +acpi_tb_get_table_ptr ( + ACPI_TABLE_TYPE table_type, + u32 instance, + ACPI_TABLE_HEADER **table_ptr_loc) +{ + ACPI_TABLE_DESC *table_desc; + u32 i; + + + if (!acpi_gbl_DSDT) { + return (AE_NO_ACPI_TABLES); + } + + if (table_type > ACPI_TABLE_MAX) { + return (AE_BAD_PARAMETER); + } + + + /* + * For all table types (Single/Multiple), the first + * instance is always in the list head. + */ + + if (instance == 1) { + /* + * Just pluck the pointer out of the global table! + * Will be null if no table is present + */ + + *table_ptr_loc = acpi_gbl_acpi_tables[table_type].pointer; + return (AE_OK); + } + + + /* + * Check for instance out of range + */ + if (instance > acpi_gbl_acpi_tables[table_type].count) { + return (AE_NOT_EXIST); + } + + /* Walk the list to get the desired table + * Since the if (Instance == 1) check above checked for the + * first table, setting Table_desc equal to the .Next member + * is actually pointing to the second table. Therefore, we + * need to walk from the 2nd table until we reach the Instance + * that the user is looking for and return its table pointer. + */ + table_desc = acpi_gbl_acpi_tables[table_type].next; + for (i = 2; i < instance; i++) { + table_desc = table_desc->next; + } + + /* We are now pointing to the requested table's descriptor */ + + *table_ptr_loc = table_desc->pointer; + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: Acpi_tb_get_table + * + * PARAMETERS: Physical_address - Physical address of table to retrieve + * *Buffer_ptr - If Buffer_ptr is valid, read data from + * buffer rather than searching memory + * *Table_info - Where the table info is returned + * + * RETURN: Status + * + * DESCRIPTION: Maps the physical address of table into a logical address + * + ******************************************************************************/ + +ACPI_STATUS +acpi_tb_get_table ( + ACPI_PHYSICAL_ADDRESS physical_address, + ACPI_TABLE_HEADER *buffer_ptr, + ACPI_TABLE_DESC *table_info) +{ + ACPI_TABLE_HEADER *table_header = NULL; + ACPI_TABLE_HEADER *full_table = NULL; + u32 size; + u8 allocation; + ACPI_STATUS status = AE_OK; + + + if (!table_info) { + return (AE_BAD_PARAMETER); + } + + + if (buffer_ptr) { + /* + * Getting data from a buffer, not BIOS tables + */ + + table_header = buffer_ptr; + status = acpi_tb_validate_table_header (table_header); + if (ACPI_FAILURE (status)) { + /* Table failed verification, map all errors to BAD_DATA */ + + return (AE_BAD_DATA); + } + + /* Allocate buffer for the entire table */ + + full_table = acpi_cm_allocate (table_header->length); + if (!full_table) { + return (AE_NO_MEMORY); + } + + /* Copy the entire table (including header) to the local buffer */ + + size = table_header->length; + MEMCPY (full_table, buffer_ptr, size); + + /* Save allocation type */ + + allocation = ACPI_MEM_ALLOCATED; + } + + + /* + * Not reading from a buffer, just map the table's physical memory + * into our address space. + */ + else { + size = SIZE_IN_HEADER; + + status = acpi_tb_map_acpi_table (physical_address, &size, + (void **) &full_table); + if (ACPI_FAILURE (status)) { + return (status); + } + + /* Save allocation type */ + + allocation = ACPI_MEM_MAPPED; + } + + + /* Return values */ + + table_info->pointer = full_table; + table_info->length = size; + table_info->allocation = allocation; + table_info->base_pointer = full_table; + + return (status); +} + + +/******************************************************************************* + * + * FUNCTION: Acpi_tb_get_all_tables + * + * PARAMETERS: Number_of_tables - Number of tables to get + * Table_ptr - Input buffer pointer, optional + * + * RETURN: Status + * + * DESCRIPTION: Load and validate all tables other than the RSDT. The RSDT must + * already be loaded and validated. + * + ******************************************************************************/ + +ACPI_STATUS +acpi_tb_get_all_tables ( + u32 number_of_tables, + ACPI_TABLE_HEADER *table_ptr) +{ + ACPI_STATUS status = AE_OK; + u32 index; + ACPI_TABLE_DESC table_info; + + + /* + * 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 < number_of_tables; index++) { + /* Clear the Table_info each time */ + + MEMSET (&table_info, 0, sizeof (ACPI_TABLE_DESC)); + + /* Get the table via the XSDT */ + + status = acpi_tb_get_table ((ACPI_PHYSICAL_ADDRESS) + ACPI_GET_ADDRESS (acpi_gbl_XSDT->table_offset_entry[index]), + table_ptr, &table_info); + + /* Ignore a table that failed verification */ + + if (status == AE_BAD_DATA) { + continue; + } + + /* However, abort on serious errors */ + + if (ACPI_FAILURE (status)) { + return (status); + } + + /* Recognize and install the table */ + + status = acpi_tb_install_table (table_ptr, &table_info); + if (ACPI_FAILURE (status)) { + /* + * Unrecognized or unsupported table, delete it and ignore the + * error. Just get as many tables as we can, later we will + * determine if there are enough tables to continue. + */ + + acpi_tb_uninstall_table (&table_info); + } + } + + + /* + * Convert the FADT to a common format. This allows earlier revisions of the + * table to coexist with newer versions, using common access code. + */ + status = acpi_tb_convert_table_fadt (); + if (ACPI_FAILURE (status)) { + return (status); + } + + + /* + * Get the minimum set of ACPI tables, namely: + * + * 1) FADT (via RSDT in loop above) + * 2) FACS + * 3) DSDT + * + */ + + + /* + * Get the FACS (must have the FADT first, from loop above) + * Acpi_tb_get_table_facs will fail if FADT pointer is not valid + */ + + status = acpi_tb_get_table_facs (table_ptr, &table_info); + if (ACPI_FAILURE (status)) { + return (status); + } + + + /* Install the FACS */ + + status = acpi_tb_install_table (table_ptr, &table_info); + if (ACPI_FAILURE (status)) { + return (status); + } + + /* + * Create the common FACS pointer table + * (Contains pointers to the original table) + */ + + status = acpi_tb_build_common_facs (&table_info); + if (ACPI_FAILURE (status)) { + return (status); + } + + + /* + * Get the DSDT (We know that the FADT is valid now) + */ + + status = acpi_tb_get_table ((ACPI_PHYSICAL_ADDRESS) ACPI_GET_ADDRESS (acpi_gbl_FADT->Xdsdt), + table_ptr, &table_info); + if (ACPI_FAILURE (status)) { + return (status); + } + + /* Install the DSDT */ + + status = acpi_tb_install_table (table_ptr, &table_info); + if (ACPI_FAILURE (status)) { + return (status); + } + + /* Dump the DSDT Header */ + + /* Dump the entire DSDT */ + + /* + * Initialize the capabilities flags. + * Assumes that platform supports ACPI_MODE since we have tables! + */ + acpi_gbl_system_flags |= acpi_hw_get_mode_capabilities (); + + + /* Always delete the RSDP mapping, we are done with it */ + + acpi_tb_delete_acpi_table (ACPI_TABLE_RSDP); + + return (status); +} + + +/******************************************************************************* + * + * FUNCTION: Acpi_tb_verify_rsdp + * + * PARAMETERS: Number_of_tables - Where the table count is placed + * + * RETURN: Status + * + * DESCRIPTION: Load and validate the RSDP (ptr) and RSDT (table) + * + ******************************************************************************/ + +ACPI_STATUS +acpi_tb_verify_rsdp ( + ACPI_PHYSICAL_ADDRESS rsdp_physical_address) +{ + ACPI_TABLE_DESC table_info; + ACPI_STATUS status; + u8 *table_ptr; + + + /* + * Obtain access to the RSDP structure + */ + status = acpi_os_map_memory (rsdp_physical_address, + sizeof (RSDP_DESCRIPTOR), + (void **) &table_ptr); + if (ACPI_FAILURE (status)) { + return (status); + } + + /* + * The signature and checksum must both be correct + */ + if (STRNCMP ((NATIVE_CHAR *) table_ptr, RSDP_SIG, sizeof (RSDP_SIG)-1) != 0) { + /* Nope, BAD Signature */ + + status = AE_BAD_SIGNATURE; + goto cleanup; + } + + if (acpi_tb_checksum (table_ptr, RSDP_CHECKSUM_LENGTH) != 0) { + /* Nope, BAD Checksum */ + + status = AE_BAD_CHECKSUM; + goto cleanup; + } + + /* TBD: Check extended checksum if table version >= 2 */ + + /* The RSDP supplied is OK */ + + table_info.pointer = (ACPI_TABLE_HEADER *) table_ptr; + table_info.length = sizeof (RSDP_DESCRIPTOR); + table_info.allocation = ACPI_MEM_MAPPED; + table_info.base_pointer = table_ptr; + + /* Save the table pointers and allocation info */ + + status = acpi_tb_init_table_descriptor (ACPI_TABLE_RSDP, &table_info); + if (ACPI_FAILURE (status)) { + goto cleanup; + } + + + /* Save the RSDP in a global for easy access */ + + acpi_gbl_RSDP = (RSDP_DESCRIPTOR *) table_info.pointer; + return (status); + + + /* Error exit */ +cleanup: + + acpi_os_unmap_memory (table_ptr, sizeof (RSDP_DESCRIPTOR)); + return (status); +} + + +/******************************************************************************* + * + * FUNCTION: Acpi_tb_get_table_rsdt + * + * PARAMETERS: Number_of_tables - Where the table count is placed + * + * RETURN: Status + * + * DESCRIPTION: Load and validate the RSDP (ptr) and RSDT (table) + * + ******************************************************************************/ + +ACPI_STATUS +acpi_tb_get_table_rsdt ( + u32 *number_of_tables) +{ + ACPI_TABLE_DESC table_info; + ACPI_STATUS status = AE_OK; + ACPI_PHYSICAL_ADDRESS physical_address; + u32 signature_length; + char *table_signature; + + + /* + * Get the RSDT from the RSDP + */ + + /* + * For RSDP revision 0 or 1, we use the RSDT. + * For RSDP revision 2 (and above), we use the XSDT + */ + if (acpi_gbl_RSDP->revision < 2) { +#ifdef _IA64 + /* 0.71 RSDP has 64bit Rsdt address field */ + physical_address = ((RSDP_DESCRIPTOR_REV071 *)acpi_gbl_RSDP)->rsdt_physical_address; +#else + physical_address = (ACPI_PHYSICAL_ADDRESS) acpi_gbl_RSDP->rsdt_physical_address; +#endif + table_signature = RSDT_SIG; + signature_length = sizeof (RSDT_SIG) -1; + } + else { + physical_address = (ACPI_PHYSICAL_ADDRESS) + ACPI_GET_ADDRESS (acpi_gbl_RSDP->xsdt_physical_address); + table_signature = XSDT_SIG; + signature_length = sizeof (XSDT_SIG) -1; + } + + + /* Get the RSDT/XSDT */ + + status = acpi_tb_get_table (physical_address, NULL, &table_info); + if (ACPI_FAILURE (status)) { + return (status); + } + + + /* Check the RSDT or XSDT signature */ + + if (STRNCMP ((char *) table_info.pointer, table_signature, + signature_length)) { + /* Invalid RSDT or XSDT signature */ + + REPORT_ERROR (("Invalid signature where RSDP indicates %s should be located\n", + table_signature)); + + return (AE_NO_ACPI_TABLES); + } + + + /* Valid RSDT signature, verify the checksum */ + + status = acpi_tb_verify_table_checksum (table_info.pointer); + + + /* Convert and/or copy to an XSDT structure */ + + status = acpi_tb_convert_to_xsdt (&table_info, number_of_tables); + if (ACPI_FAILURE (status)) { + return (status); + } + + /* Save the table pointers and allocation info */ + + status = acpi_tb_init_table_descriptor (ACPI_TABLE_XSDT, &table_info); + if (ACPI_FAILURE (status)) { + return (status); + } + + acpi_gbl_XSDT = (XSDT_DESCRIPTOR *) table_info.pointer; + + return (status); +} + + +/****************************************************************************** + * + * FUNCTION: Acpi_tb_get_table_facs + * + * PARAMETERS: *Buffer_ptr - If Buffer_ptr is valid, read data from + * buffer rather than searching memory + * *Table_info - Where the table info is returned + * + * RETURN: Status + * + * DESCRIPTION: Returns a pointer to the FACS as defined in FADT. This + * function assumes the global variable FADT has been + * correctly initialized. The value of FADT->Firmware_ctrl + * into a far pointer which is returned. + * + *****************************************************************************/ + +ACPI_STATUS +acpi_tb_get_table_facs ( + ACPI_TABLE_HEADER *buffer_ptr, + ACPI_TABLE_DESC *table_info) +{ + void *table_ptr = NULL; + u32 size; + u8 allocation; + ACPI_STATUS status = AE_OK; + + + /* Must have a valid FADT pointer */ + + if (!acpi_gbl_FADT) { + return (AE_NO_ACPI_TABLES); + } + + size = sizeof (FACS_DESCRIPTOR); + if (buffer_ptr) { + /* + * Getting table from a file -- allocate a buffer and + * read the table. + */ + table_ptr = acpi_cm_allocate (size); + if(!table_ptr) { + return (AE_NO_MEMORY); + } + + MEMCPY (table_ptr, buffer_ptr, size); + + /* Save allocation type */ + + allocation = ACPI_MEM_ALLOCATED; + } + + else { + /* Just map the physical memory to our address space */ + + status = acpi_tb_map_acpi_table ((ACPI_PHYSICAL_ADDRESS) ACPI_GET_ADDRESS (acpi_gbl_FADT->Xfirmware_ctrl), + &size, &table_ptr); + if (ACPI_FAILURE(status)) { + return (status); + } + + /* Save allocation type */ + + allocation = ACPI_MEM_MAPPED; + } + + + /* Return values */ + + table_info->pointer = table_ptr; + table_info->length = size; + table_info->allocation = allocation; + table_info->base_pointer = table_ptr; + + return (status); +} + diff --git a/reactos/drivers/bus/acpi/acpica/tables/tbinstal.c b/reactos/drivers/bus/acpi/acpica/tables/tbinstal.c new file mode 100644 index 00000000000..c911f84f68b --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/tables/tbinstal.c @@ -0,0 +1,785 @@ +/****************************************************************************** + * + * Module Name: tbinstal - ACPI table installation and removal + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __TBINSTAL_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" +#include "actables.h" + + +#define _COMPONENT ACPI_TABLES + ACPI_MODULE_NAME ("tbinstal") + + +/****************************************************************************** + * + * FUNCTION: AcpiTbVerifyTable + * + * PARAMETERS: TableDesc - table + * + * RETURN: Status + * + * DESCRIPTION: this function is called to verify and map table + * + *****************************************************************************/ + +ACPI_STATUS +AcpiTbVerifyTable ( + ACPI_TABLE_DESC *TableDesc) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (TbVerifyTable); + + + /* Map the table if necessary */ + + if (!TableDesc->Pointer) + { + if ((TableDesc->Flags & ACPI_TABLE_ORIGIN_MASK) == + ACPI_TABLE_ORIGIN_MAPPED) + { + TableDesc->Pointer = AcpiOsMapMemory ( + TableDesc->Address, TableDesc->Length); + } + + if (!TableDesc->Pointer) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + } + + /* FACS is the odd table, has no standard ACPI header and no checksum */ + + if (!ACPI_COMPARE_NAME (&TableDesc->Signature, ACPI_SIG_FACS)) + { + /* Always calculate checksum, ignore bad checksum if requested */ + + Status = AcpiTbVerifyChecksum (TableDesc->Pointer, TableDesc->Length); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbAddTable + * + * PARAMETERS: TableDesc - Table descriptor + * TableIndex - Where the table index is returned + * + * RETURN: Status + * + * DESCRIPTION: This function is called to add an ACPI table. It is used to + * dynamically load tables via the Load and LoadTable AML + * operators. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbAddTable ( + ACPI_TABLE_DESC *TableDesc, + UINT32 *TableIndex) +{ + UINT32 i; + ACPI_STATUS Status = AE_OK; + ACPI_TABLE_HEADER *OverrideTable = NULL; + + + ACPI_FUNCTION_TRACE (TbAddTable); + + + if (!TableDesc->Pointer) + { + Status = AcpiTbVerifyTable (TableDesc); + if (ACPI_FAILURE (Status) || !TableDesc->Pointer) + { + return_ACPI_STATUS (Status); + } + } + + /* + * Originally, we checked the table signature for "SSDT" or "PSDT" here. + * Next, we added support for OEMx tables, signature "OEM". + * Valid tables were encountered with a null signature, so we've just + * given up on validating the signature, since it seems to be a waste + * of code. The original code was removed (05/2008). + */ + + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + + /* Check if table is already registered */ + + for (i = 0; i < AcpiGbl_RootTableList.Count; ++i) + { + if (!AcpiGbl_RootTableList.Tables[i].Pointer) + { + Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[i]); + if (ACPI_FAILURE (Status) || + !AcpiGbl_RootTableList.Tables[i].Pointer) + { + continue; + } + } + + /* + * Check for a table match on the entire table length, + * not just the header. + */ + if (TableDesc->Length != AcpiGbl_RootTableList.Tables[i].Length) + { + continue; + } + + if (ACPI_MEMCMP (TableDesc->Pointer, + AcpiGbl_RootTableList.Tables[i].Pointer, + AcpiGbl_RootTableList.Tables[i].Length)) + { + continue; + } + + /* + * Note: the current mechanism does not unregister a table if it is + * dynamically unloaded. The related namespace entries are deleted, + * but the table remains in the root table list. + * + * The assumption here is that the number of different tables that + * will be loaded is actually small, and there is minimal overhead + * in just keeping the table in case it is needed again. + * + * If this assumption changes in the future (perhaps on large + * machines with many table load/unload operations), tables will + * need to be unregistered when they are unloaded, and slots in the + * root table list should be reused when empty. + */ + + /* + * Table is already registered. + * We can delete the table that was passed as a parameter. + */ + AcpiTbDeleteTable (TableDesc); + *TableIndex = i; + + if (AcpiGbl_RootTableList.Tables[i].Flags & ACPI_TABLE_IS_LOADED) + { + /* Table is still loaded, this is an error */ + + Status = AE_ALREADY_EXISTS; + goto Release; + } + else + { + /* Table was unloaded, allow it to be reloaded */ + + TableDesc->Pointer = AcpiGbl_RootTableList.Tables[i].Pointer; + TableDesc->Address = AcpiGbl_RootTableList.Tables[i].Address; + Status = AE_OK; + goto PrintHeader; + } + } + + /* + * ACPI Table Override: + * Allow the host to override dynamically loaded tables. + */ + Status = AcpiOsTableOverride (TableDesc->Pointer, &OverrideTable); + if (ACPI_SUCCESS (Status) && OverrideTable) + { + ACPI_INFO ((AE_INFO, + "%4.4s @ 0x%p Table override, replaced with:", + TableDesc->Pointer->Signature, + ACPI_CAST_PTR (void, TableDesc->Address))); + + /* We can delete the table that was passed as a parameter */ + + AcpiTbDeleteTable (TableDesc); + + /* Setup descriptor for the new table */ + + TableDesc->Address = ACPI_PTR_TO_PHYSADDR (OverrideTable); + TableDesc->Pointer = OverrideTable; + TableDesc->Length = OverrideTable->Length; + TableDesc->Flags = ACPI_TABLE_ORIGIN_OVERRIDE; + } + + /* Add the table to the global root table list */ + + Status = AcpiTbStoreTable (TableDesc->Address, TableDesc->Pointer, + TableDesc->Length, TableDesc->Flags, TableIndex); + if (ACPI_FAILURE (Status)) + { + goto Release; + } + +PrintHeader: + AcpiTbPrintTableHeader (TableDesc->Address, TableDesc->Pointer); + +Release: + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbResizeRootTableList + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Expand the size of global table array + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbResizeRootTableList ( + void) +{ + ACPI_TABLE_DESC *Tables; + + + ACPI_FUNCTION_TRACE (TbResizeRootTableList); + + + /* AllowResize flag is a parameter to AcpiInitializeTables */ + + if (!(AcpiGbl_RootTableList.Flags & ACPI_ROOT_ALLOW_RESIZE)) + { + ACPI_ERROR ((AE_INFO, "Resize of Root Table Array is not allowed")); + return_ACPI_STATUS (AE_SUPPORT); + } + + /* Increase the Table Array size */ + + Tables = ACPI_ALLOCATE_ZEROED ( + ((ACPI_SIZE) AcpiGbl_RootTableList.Size + + ACPI_ROOT_TABLE_SIZE_INCREMENT) * + sizeof (ACPI_TABLE_DESC)); + if (!Tables) + { + ACPI_ERROR ((AE_INFO, "Could not allocate new root table array")); + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Copy and free the previous table array */ + + if (AcpiGbl_RootTableList.Tables) + { + ACPI_MEMCPY (Tables, AcpiGbl_RootTableList.Tables, + (ACPI_SIZE) AcpiGbl_RootTableList.Size * sizeof (ACPI_TABLE_DESC)); + + if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED) + { + ACPI_FREE (AcpiGbl_RootTableList.Tables); + } + } + + AcpiGbl_RootTableList.Tables = Tables; + AcpiGbl_RootTableList.Size += ACPI_ROOT_TABLE_SIZE_INCREMENT; + AcpiGbl_RootTableList.Flags |= (UINT8) ACPI_ROOT_ORIGIN_ALLOCATED; + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbStoreTable + * + * PARAMETERS: Address - Table address + * Table - Table header + * Length - Table length + * Flags - flags + * + * RETURN: Status and table index. + * + * DESCRIPTION: Add an ACPI table to the global table list + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbStoreTable ( + ACPI_PHYSICAL_ADDRESS Address, + ACPI_TABLE_HEADER *Table, + UINT32 Length, + UINT8 Flags, + UINT32 *TableIndex) +{ + ACPI_STATUS Status = AE_OK; + + + /* Ensure that there is room for the table in the Root Table List */ + + if (AcpiGbl_RootTableList.Count >= AcpiGbl_RootTableList.Size) + { + Status = AcpiTbResizeRootTableList(); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + + /* 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; + + ACPI_MOVE_32_TO_32 ( + &(AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.Count].Signature), + Table->Signature); + + *TableIndex = AcpiGbl_RootTableList.Count; + AcpiGbl_RootTableList.Count++; + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbDeleteTable + * + * PARAMETERS: TableIndex - Table index + * + * RETURN: None + * + * DESCRIPTION: Delete one internal ACPI table + * + ******************************************************************************/ + +void +AcpiTbDeleteTable ( + ACPI_TABLE_DESC *TableDesc) +{ + + /* Table must be mapped or allocated */ + + if (!TableDesc->Pointer) + { + return; + } + + switch (TableDesc->Flags & ACPI_TABLE_ORIGIN_MASK) + { + case ACPI_TABLE_ORIGIN_MAPPED: + AcpiOsUnmapMemory (TableDesc->Pointer, TableDesc->Length); + break; + + case ACPI_TABLE_ORIGIN_ALLOCATED: + ACPI_FREE (TableDesc->Pointer); + break; + + default: + break; + } + + TableDesc->Pointer = NULL; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbTerminate + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Delete all internal ACPI tables + * + ******************************************************************************/ + +void +AcpiTbTerminate ( + void) +{ + UINT32 i; + + + ACPI_FUNCTION_TRACE (TbTerminate); + + + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + + /* Delete the individual tables */ + + for (i = 0; i < AcpiGbl_RootTableList.Count; i++) + { + AcpiTbDeleteTable (&AcpiGbl_RootTableList.Tables[i]); + } + + /* + * Delete the root table array if allocated locally. Array cannot be + * mapped, so we don't need to check for that flag. + */ + if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED) + { + ACPI_FREE (AcpiGbl_RootTableList.Tables); + } + + AcpiGbl_RootTableList.Tables = NULL; + AcpiGbl_RootTableList.Flags = 0; + AcpiGbl_RootTableList.Count = 0; + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ACPI Tables freed\n")); + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbDeleteNamespaceByOwner + * + * PARAMETERS: TableIndex - Table index + * + * RETURN: Status + * + * DESCRIPTION: Delete all namespace objects created when this table was loaded. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbDeleteNamespaceByOwner ( + UINT32 TableIndex) +{ + ACPI_OWNER_ID OwnerId; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (TbDeleteNamespaceByOwner); + + + Status = AcpiUtAcquireMutex (ACPI_MTX_TABLES); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + if (TableIndex >= AcpiGbl_RootTableList.Count) + { + /* The table index does not exist */ + + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + return_ACPI_STATUS (AE_NOT_EXIST); + } + + /* Get the owner ID for this table, used to delete namespace nodes */ + + OwnerId = AcpiGbl_RootTableList.Tables[TableIndex].OwnerId; + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + + /* + * Need to acquire the namespace writer lock to prevent interference + * with any concurrent namespace walks. The interpreter must be + * released during the deletion since the acquisition of the deletion + * lock may block, and also since the execution of a namespace walk + * must be allowed to use the interpreter. + */ + (void) AcpiUtReleaseMutex (ACPI_MTX_INTERPRETER); + Status = AcpiUtAcquireWriteLock (&AcpiGbl_NamespaceRwLock); + + AcpiNsDeleteNamespaceByOwner (OwnerId); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + AcpiUtReleaseWriteLock (&AcpiGbl_NamespaceRwLock); + + Status = AcpiUtAcquireMutex (ACPI_MTX_INTERPRETER); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbAllocateOwnerId + * + * PARAMETERS: TableIndex - Table index + * + * RETURN: Status + * + * DESCRIPTION: Allocates OwnerId in TableDesc + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbAllocateOwnerId ( + UINT32 TableIndex) +{ + ACPI_STATUS Status = AE_BAD_PARAMETER; + + + ACPI_FUNCTION_TRACE (TbAllocateOwnerId); + + + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + if (TableIndex < AcpiGbl_RootTableList.Count) + { + Status = AcpiUtAllocateOwnerId + (&(AcpiGbl_RootTableList.Tables[TableIndex].OwnerId)); + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbReleaseOwnerId + * + * PARAMETERS: TableIndex - Table index + * + * RETURN: Status + * + * DESCRIPTION: Releases OwnerId in TableDesc + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbReleaseOwnerId ( + UINT32 TableIndex) +{ + ACPI_STATUS Status = AE_BAD_PARAMETER; + + + ACPI_FUNCTION_TRACE (TbReleaseOwnerId); + + + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + if (TableIndex < AcpiGbl_RootTableList.Count) + { + AcpiUtReleaseOwnerId ( + &(AcpiGbl_RootTableList.Tables[TableIndex].OwnerId)); + Status = AE_OK; + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbGetOwnerId + * + * PARAMETERS: TableIndex - Table index + * OwnerId - Where the table OwnerId is returned + * + * RETURN: Status + * + * DESCRIPTION: returns OwnerId for the ACPI table + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbGetOwnerId ( + UINT32 TableIndex, + ACPI_OWNER_ID *OwnerId) +{ + ACPI_STATUS Status = AE_BAD_PARAMETER; + + + ACPI_FUNCTION_TRACE (TbGetOwnerId); + + + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + if (TableIndex < AcpiGbl_RootTableList.Count) + { + *OwnerId = AcpiGbl_RootTableList.Tables[TableIndex].OwnerId; + Status = AE_OK; + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbIsTableLoaded + * + * PARAMETERS: TableIndex - Table index + * + * RETURN: Table Loaded Flag + * + ******************************************************************************/ + +BOOLEAN +AcpiTbIsTableLoaded ( + UINT32 TableIndex) +{ + BOOLEAN IsLoaded = FALSE; + + + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + if (TableIndex < AcpiGbl_RootTableList.Count) + { + IsLoaded = (BOOLEAN) + (AcpiGbl_RootTableList.Tables[TableIndex].Flags & + ACPI_TABLE_IS_LOADED); + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + return (IsLoaded); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbSetTableLoadedFlag + * + * PARAMETERS: TableIndex - Table index + * IsLoaded - TRUE if table is loaded, FALSE otherwise + * + * RETURN: None + * + * DESCRIPTION: Sets the table loaded flag to either TRUE or FALSE. + * + ******************************************************************************/ + +void +AcpiTbSetTableLoadedFlag ( + UINT32 TableIndex, + BOOLEAN IsLoaded) +{ + + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + if (TableIndex < AcpiGbl_RootTableList.Count) + { + if (IsLoaded) + { + AcpiGbl_RootTableList.Tables[TableIndex].Flags |= + ACPI_TABLE_IS_LOADED; + } + else + { + AcpiGbl_RootTableList.Tables[TableIndex].Flags &= + ~ACPI_TABLE_IS_LOADED; + } + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); +} + diff --git a/reactos/drivers/bus/acpi/acpica/tables/tbutils.c b/reactos/drivers/bus/acpi/acpica/tables/tbutils.c new file mode 100644 index 00000000000..ec2a88e283d --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/tables/tbutils.c @@ -0,0 +1,741 @@ +/****************************************************************************** + * + * Module Name: tbutils - table utilities + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __TBUTILS_C__ + +#include "acpi.h" +#include "accommon.h" +#include "actables.h" + +#define _COMPONENT ACPI_TABLES + ACPI_MODULE_NAME ("tbutils") + +/* Local prototypes */ + +static void +AcpiTbFixString ( + char *String, + ACPI_SIZE Length); + +static void +AcpiTbCleanupTableHeader ( + ACPI_TABLE_HEADER *OutHeader, + ACPI_TABLE_HEADER *Header); + +static ACPI_PHYSICAL_ADDRESS +AcpiTbGetRootTableEntry ( + UINT8 *TableEntry, + UINT32 TableEntrySize); + + +/******************************************************************************* + * + * FUNCTION: AcpiTbInitializeFacs + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Create a permanent mapping for the FADT and save it in a global + * for accessing the Global Lock and Firmware Waking Vector + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbInitializeFacs ( + void) +{ + ACPI_STATUS Status; + + + Status = AcpiGetTableByIndex (ACPI_TABLE_INDEX_FACS, + ACPI_CAST_INDIRECT_PTR (ACPI_TABLE_HEADER, &AcpiGbl_FACS)); + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbTablesLoaded + * + * PARAMETERS: None + * + * RETURN: TRUE if required ACPI tables are loaded + * + * DESCRIPTION: Determine if the minimum required ACPI tables are present + * (FADT, FACS, DSDT) + * + ******************************************************************************/ + +BOOLEAN +AcpiTbTablesLoaded ( + void) +{ + + if (AcpiGbl_RootTableList.Count >= 3) + { + return (TRUE); + } + + return (FALSE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbFixString + * + * PARAMETERS: String - String to be repaired + * Length - Maximum length + * + * RETURN: None + * + * DESCRIPTION: Replace every non-printable or non-ascii byte in the string + * with a question mark '?'. + * + ******************************************************************************/ + +static void +AcpiTbFixString ( + char *String, + ACPI_SIZE Length) +{ + + while (Length && *String) + { + if (!ACPI_IS_PRINT (*String)) + { + *String = '?'; + } + String++; + Length--; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbCleanupTableHeader + * + * PARAMETERS: OutHeader - Where the cleaned header is returned + * Header - Input ACPI table header + * + * RETURN: Returns the cleaned header in OutHeader + * + * DESCRIPTION: Copy the table header and ensure that all "string" fields in + * the header consist of printable characters. + * + ******************************************************************************/ + +static void +AcpiTbCleanupTableHeader ( + ACPI_TABLE_HEADER *OutHeader, + ACPI_TABLE_HEADER *Header) +{ + + ACPI_MEMCPY (OutHeader, Header, sizeof (ACPI_TABLE_HEADER)); + + AcpiTbFixString (OutHeader->Signature, ACPI_NAME_SIZE); + AcpiTbFixString (OutHeader->OemId, ACPI_OEM_ID_SIZE); + AcpiTbFixString (OutHeader->OemTableId, ACPI_OEM_TABLE_ID_SIZE); + AcpiTbFixString (OutHeader->AslCompilerId, ACPI_NAME_SIZE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbPrintTableHeader + * + * PARAMETERS: Address - Table physical address + * Header - Table header + * + * RETURN: None + * + * DESCRIPTION: Print an ACPI table header. Special cases for FACS and RSDP. + * + ******************************************************************************/ + +void +AcpiTbPrintTableHeader ( + ACPI_PHYSICAL_ADDRESS Address, + ACPI_TABLE_HEADER *Header) +{ + ACPI_TABLE_HEADER LocalHeader; + + + /* + * The reason that the Address is cast to a void pointer is so that we + * can use %p which will work properly on both 32-bit and 64-bit hosts. + */ + if (ACPI_COMPARE_NAME (Header->Signature, ACPI_SIG_FACS)) + { + /* FACS only has signature and length fields */ + + ACPI_INFO ((AE_INFO, "%4.4s %p %05X", + Header->Signature, ACPI_CAST_PTR (void, Address), + Header->Length)); + } + else if (ACPI_COMPARE_NAME (Header->Signature, ACPI_SIG_RSDP)) + { + /* RSDP has no common fields */ + + ACPI_MEMCPY (LocalHeader.OemId, + ACPI_CAST_PTR (ACPI_TABLE_RSDP, Header)->OemId, ACPI_OEM_ID_SIZE); + AcpiTbFixString (LocalHeader.OemId, ACPI_OEM_ID_SIZE); + + ACPI_INFO ((AE_INFO, "RSDP %p %05X (v%.2d %6.6s)", + ACPI_CAST_PTR (void, Address), + (ACPI_CAST_PTR (ACPI_TABLE_RSDP, Header)->Revision > 0) ? + ACPI_CAST_PTR (ACPI_TABLE_RSDP, Header)->Length : 20, + ACPI_CAST_PTR (ACPI_TABLE_RSDP, Header)->Revision, + LocalHeader.OemId)); + } + else + { + /* Standard ACPI table with full common header */ + + AcpiTbCleanupTableHeader (&LocalHeader, Header); + + ACPI_INFO ((AE_INFO, + "%4.4s %p %05X (v%.2d %6.6s %8.8s %08X %4.4s %08X)", + LocalHeader.Signature, ACPI_CAST_PTR (void, Address), + LocalHeader.Length, LocalHeader.Revision, LocalHeader.OemId, + LocalHeader.OemTableId, LocalHeader.OemRevision, + LocalHeader.AslCompilerId, LocalHeader.AslCompilerRevision)); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbValidateChecksum + * + * PARAMETERS: Table - ACPI table to verify + * Length - Length of entire table + * + * RETURN: Status + * + * DESCRIPTION: Verifies that the table checksums to zero. Optionally returns + * exception on bad checksum. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbVerifyChecksum ( + ACPI_TABLE_HEADER *Table, + UINT32 Length) +{ + UINT8 Checksum; + + + /* Compute the checksum on the table */ + + Checksum = AcpiTbChecksum (ACPI_CAST_PTR (UINT8, Table), Length); + + /* Checksum ok? (should be zero) */ + + if (Checksum) + { + ACPI_WARNING ((AE_INFO, + "Incorrect checksum in table [%4.4s] - %2.2X, should be %2.2X", + Table->Signature, Table->Checksum, + (UINT8) (Table->Checksum - Checksum))); + +#if (ACPI_CHECKSUM_ABORT) + return (AE_BAD_CHECKSUM); +#endif + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbChecksum + * + * PARAMETERS: Buffer - Pointer to memory region to be checked + * Length - Length of this memory region + * + * RETURN: Checksum (UINT8) + * + * DESCRIPTION: Calculates circular checksum of memory region. + * + ******************************************************************************/ + +UINT8 +AcpiTbChecksum ( + UINT8 *Buffer, + UINT32 Length) +{ + UINT8 Sum = 0; + UINT8 *End = Buffer + Length; + + + while (Buffer < End) + { + Sum = (UINT8) (Sum + *(Buffer++)); + } + + return Sum; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbInstallTable + * + * PARAMETERS: Address - Physical address of DSDT or FACS + * Signature - Table signature, NULL if no need to + * match + * TableIndex - Index into root table array + * + * RETURN: None + * + * DESCRIPTION: Install an ACPI table into the global data structure. The + * table override mechanism is implemented here to allow the host + * OS to replace any table before it is installed in the root + * table array. + * + ******************************************************************************/ + +void +AcpiTbInstallTable ( + ACPI_PHYSICAL_ADDRESS Address, + char *Signature, + UINT32 TableIndex) +{ + UINT8 Flags; + ACPI_STATUS Status; + ACPI_TABLE_HEADER *TableToInstall; + ACPI_TABLE_HEADER *MappedTable; + ACPI_TABLE_HEADER *OverrideTable = NULL; + + + if (!Address) + { + ACPI_ERROR ((AE_INFO, "Null physical address for ACPI table [%s]", + Signature)); + return; + } + + /* Map just the table header */ + + MappedTable = AcpiOsMapMemory (Address, sizeof (ACPI_TABLE_HEADER)); + if (!MappedTable) + { + return; + } + + /* If a particular signature is expected (DSDT/FACS), it must match */ + + if (Signature && + !ACPI_COMPARE_NAME (MappedTable->Signature, Signature)) + { + ACPI_ERROR ((AE_INFO, + "Invalid signature 0x%X for ACPI table, expected [%s]", + *ACPI_CAST_PTR (UINT32, MappedTable->Signature), Signature)); + goto UnmapAndExit; + } + + /* + * ACPI Table Override: + * + * Before we install the table, let the host OS override it with a new + * one if desired. Any table within the RSDT/XSDT can be replaced, + * including the DSDT which is pointed to by the FADT. + */ + Status = AcpiOsTableOverride (MappedTable, &OverrideTable); + if (ACPI_SUCCESS (Status) && OverrideTable) + { + ACPI_INFO ((AE_INFO, + "%4.4s @ 0x%p Table override, replaced with:", + MappedTable->Signature, ACPI_CAST_PTR (void, Address))); + + AcpiGbl_RootTableList.Tables[TableIndex].Pointer = OverrideTable; + Address = ACPI_PTR_TO_PHYSADDR (OverrideTable); + + TableToInstall = OverrideTable; + Flags = ACPI_TABLE_ORIGIN_OVERRIDE; + } + else + { + TableToInstall = MappedTable; + Flags = ACPI_TABLE_ORIGIN_MAPPED; + } + + /* Initialize the table entry */ + + AcpiGbl_RootTableList.Tables[TableIndex].Address = Address; + AcpiGbl_RootTableList.Tables[TableIndex].Length = TableToInstall->Length; + AcpiGbl_RootTableList.Tables[TableIndex].Flags = Flags; + + ACPI_MOVE_32_TO_32 ( + &(AcpiGbl_RootTableList.Tables[TableIndex].Signature), + TableToInstall->Signature); + + AcpiTbPrintTableHeader (Address, TableToInstall); + + if (TableIndex == ACPI_TABLE_INDEX_DSDT) + { + /* Global integer width is based upon revision of the DSDT */ + + AcpiUtSetIntegerWidth (TableToInstall->Revision); + } + +UnmapAndExit: + AcpiOsUnmapMemory (MappedTable, sizeof (ACPI_TABLE_HEADER)); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbGetRootTableEntry + * + * PARAMETERS: TableEntry - Pointer to the RSDT/XSDT table entry + * TableEntrySize - sizeof 32 or 64 (RSDT or XSDT) + * + * RETURN: Physical address extracted from the root table + * + * DESCRIPTION: Get one root table entry. Handles 32-bit and 64-bit cases on + * both 32-bit and 64-bit platforms + * + * NOTE: ACPI_PHYSICAL_ADDRESS is 32-bit on 32-bit platforms, 64-bit on + * 64-bit platforms. + * + ******************************************************************************/ + +static ACPI_PHYSICAL_ADDRESS +AcpiTbGetRootTableEntry ( + UINT8 *TableEntry, + UINT32 TableEntrySize) +{ + UINT64 Address64; + + + /* + * Get the table physical address (32-bit for RSDT, 64-bit for XSDT): + * Note: Addresses are 32-bit aligned (not 64) in both RSDT and XSDT + */ + if (TableEntrySize == sizeof (UINT32)) + { + /* + * 32-bit platform, RSDT: Return 32-bit table entry + * 64-bit platform, RSDT: Expand 32-bit to 64-bit and return + */ + return ((ACPI_PHYSICAL_ADDRESS) (*ACPI_CAST_PTR (UINT32, TableEntry))); + } + else + { + /* + * 32-bit platform, XSDT: Truncate 64-bit to 32-bit and return + * 64-bit platform, XSDT: Move (unaligned) 64-bit to local, + * return 64-bit + */ + ACPI_MOVE_64_TO_64 (&Address64, TableEntry); + +#if ACPI_MACHINE_WIDTH == 32 + if (Address64 > ACPI_UINT32_MAX) + { + /* Will truncate 64-bit address to 32 bits, issue warning */ + + ACPI_WARNING ((AE_INFO, + "64-bit Physical Address in XSDT is too large (%8.8X%8.8X)," + " truncating", + ACPI_FORMAT_UINT64 (Address64))); + } +#endif + return ((ACPI_PHYSICAL_ADDRESS) (Address64)); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiTbParseRootTable + * + * PARAMETERS: Rsdp - Pointer to the RSDP + * + * RETURN: Status + * + * DESCRIPTION: This function is called to parse the Root System Description + * Table (RSDT or XSDT) + * + * NOTE: Tables are mapped (not copied) for efficiency. The FACS must + * be mapped and cannot be copied because it contains the actual + * memory location of the ACPI Global Lock. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTbParseRootTable ( + ACPI_PHYSICAL_ADDRESS RsdpAddress) +{ + ACPI_TABLE_RSDP *Rsdp; + UINT32 TableEntrySize; + UINT32 i; + UINT32 TableCount; + ACPI_TABLE_HEADER *Table; + ACPI_PHYSICAL_ADDRESS Address; + UINT32 Length; + UINT8 *TableEntry; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (TbParseRootTable); + + + /* + * Map the entire RSDP and extract the address of the RSDT or XSDT + */ + Rsdp = AcpiOsMapMemory (RsdpAddress, sizeof (ACPI_TABLE_RSDP)); + if (!Rsdp) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + AcpiTbPrintTableHeader (RsdpAddress, + ACPI_CAST_PTR (ACPI_TABLE_HEADER, Rsdp)); + + /* Differentiate between RSDT and XSDT root tables */ + + if (Rsdp->Revision > 1 && Rsdp->XsdtPhysicalAddress) + { + /* + * Root table is an XSDT (64-bit physical addresses). We must use the + * XSDT if the revision is > 1 and the XSDT pointer is present, as per + * the ACPI specification. + */ + Address = (ACPI_PHYSICAL_ADDRESS) Rsdp->XsdtPhysicalAddress; + TableEntrySize = sizeof (UINT64); + } + else + { + /* Root table is an RSDT (32-bit physical addresses) */ + + Address = (ACPI_PHYSICAL_ADDRESS) Rsdp->RsdtPhysicalAddress; + TableEntrySize = sizeof (UINT32); + } + + /* + * It is not possible to map more than one entry in some environments, + * so unmap the RSDP here before mapping other tables + */ + AcpiOsUnmapMemory (Rsdp, sizeof (ACPI_TABLE_RSDP)); + + + /* Map the RSDT/XSDT table header to get the full table length */ + + Table = AcpiOsMapMemory (Address, sizeof (ACPI_TABLE_HEADER)); + if (!Table) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + AcpiTbPrintTableHeader (Address, Table); + + /* Get the length of the full table, verify length and map entire table */ + + Length = Table->Length; + AcpiOsUnmapMemory (Table, sizeof (ACPI_TABLE_HEADER)); + + if (Length < sizeof (ACPI_TABLE_HEADER)) + { + ACPI_ERROR ((AE_INFO, "Invalid length 0x%X in RSDT/XSDT", Length)); + return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH); + } + + Table = AcpiOsMapMemory (Address, Length); + if (!Table) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Validate the root table checksum */ + + Status = AcpiTbVerifyChecksum (Table, Length); + if (ACPI_FAILURE (Status)) + { + AcpiOsUnmapMemory (Table, Length); + return_ACPI_STATUS (Status); + } + + /* Calculate the number of tables described in the root table */ + + TableCount = (UINT32) ((Table->Length - sizeof (ACPI_TABLE_HEADER)) / + TableEntrySize); + + /* + * First two entries in the table array are reserved for the DSDT + * and FACS, which are not actually present in the RSDT/XSDT - they + * come from the FADT + */ + TableEntry = ACPI_CAST_PTR (UINT8, Table) + sizeof (ACPI_TABLE_HEADER); + AcpiGbl_RootTableList.Count = 2; + + /* + * Initialize the root table array from the RSDT/XSDT + */ + for (i = 0; i < TableCount; i++) + { + if (AcpiGbl_RootTableList.Count >= AcpiGbl_RootTableList.Size) + { + /* There is no more room in the root table array, attempt resize */ + + Status = AcpiTbResizeRootTableList (); + if (ACPI_FAILURE (Status)) + { + ACPI_WARNING ((AE_INFO, "Truncating %u table entries!", + (unsigned) (TableCount - + (AcpiGbl_RootTableList.Count - 2)))); + break; + } + } + + /* Get the table physical address (32-bit for RSDT, 64-bit for XSDT) */ + + AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.Count].Address = + AcpiTbGetRootTableEntry (TableEntry, TableEntrySize); + + TableEntry += TableEntrySize; + AcpiGbl_RootTableList.Count++; + } + + /* + * It is not possible to map more than one entry in some environments, + * so unmap the root table here before mapping other tables + */ + AcpiOsUnmapMemory (Table, Length); + + /* + * Complete the initialization of the root table array by examining + * the header of each table + */ + for (i = 2; i < AcpiGbl_RootTableList.Count; i++) + { + AcpiTbInstallTable (AcpiGbl_RootTableList.Tables[i].Address, + NULL, i); + + /* Special case for FADT - get the DSDT and FACS */ + + if (ACPI_COMPARE_NAME ( + &AcpiGbl_RootTableList.Tables[i].Signature, ACPI_SIG_FADT)) + { + AcpiTbParseFadt (i); + } + } + + return_ACPI_STATUS (AE_OK); +} diff --git a/reactos/drivers/bus/acpi/acpica/tables/tbxface.c b/reactos/drivers/bus/acpi/acpica/tables/tbxface.c new file mode 100644 index 00000000000..4c12916c5ac --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/tables/tbxface.c @@ -0,0 +1,750 @@ +/****************************************************************************** + * + * Module Name: tbxface - Public interfaces to the ACPI subsystem + * ACPI table oriented interfaces + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __TBXFACE_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" +#include "actables.h" + +#define _COMPONENT ACPI_TABLES + ACPI_MODULE_NAME ("tbxface") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiTbLoadNamespace ( + void); + + +/******************************************************************************* + * + * FUNCTION: AcpiAllocateRootTable + * + * PARAMETERS: InitialTableCount - Size of InitialTableArray, in number of + * ACPI_TABLE_DESC structures + * + * RETURN: Status + * + * DESCRIPTION: Allocate a root table array. Used by iASL compiler and + * AcpiInitializeTables. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiAllocateRootTable ( + UINT32 InitialTableCount) +{ + + AcpiGbl_RootTableList.Size = InitialTableCount; + AcpiGbl_RootTableList.Flags = ACPI_ROOT_ALLOW_RESIZE; + + return (AcpiTbResizeRootTableList ()); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiInitializeTables + * + * PARAMETERS: InitialTableArray - Pointer to an array of pre-allocated + * ACPI_TABLE_DESC structures. If NULL, the + * array is dynamically allocated. + * InitialTableCount - Size of InitialTableArray, in number of + * ACPI_TABLE_DESC structures + * AllowRealloc - Flag to tell Table Manager if resize of + * pre-allocated array is allowed. Ignored + * if InitialTableArray is NULL. + * + * RETURN: Status + * + * DESCRIPTION: Initialize the table manager, get the RSDP and RSDT/XSDT. + * + * NOTE: Allows static allocation of the initial table array in order + * to avoid the use of dynamic memory in confined environments + * such as the kernel boot sequence where it may not be available. + * + * If the host OS memory managers are initialized, use NULL for + * InitialTableArray, and the table will be dynamically allocated. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiInitializeTables ( + ACPI_TABLE_DESC *InitialTableArray, + UINT32 InitialTableCount, + BOOLEAN AllowResize) +{ + ACPI_PHYSICAL_ADDRESS RsdpAddress; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiInitializeTables); + + + /* + * Set up the Root Table Array + * Allocate the table array if requested + */ + if (!InitialTableArray) + { + Status = AcpiAllocateRootTable (InitialTableCount); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + else + { + /* Root Table Array has been statically allocated by the host */ + + ACPI_MEMSET (InitialTableArray, 0, + (ACPI_SIZE) InitialTableCount * sizeof (ACPI_TABLE_DESC)); + + AcpiGbl_RootTableList.Tables = InitialTableArray; + AcpiGbl_RootTableList.Size = InitialTableCount; + AcpiGbl_RootTableList.Flags = ACPI_ROOT_ORIGIN_UNKNOWN; + if (AllowResize) + { + AcpiGbl_RootTableList.Flags |= ACPI_ROOT_ALLOW_RESIZE; + } + } + + /* Get the address of the RSDP */ + + RsdpAddress = AcpiOsGetRootPointer (); + if (!RsdpAddress) + { + return_ACPI_STATUS (AE_NOT_FOUND); + } + + /* + * Get the root table (RSDT or XSDT) and extract all entries to the local + * Root Table Array. This array contains the information of the RSDT/XSDT + * in a common, more useable format. + */ + Status = AcpiTbParseRootTable (RsdpAddress); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiInitializeTables) + + +/******************************************************************************* + * + * FUNCTION: AcpiReallocateRootTable + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Reallocate Root Table List into dynamic memory. Copies the + * root list from the previously provided scratch area. Should + * be called once dynamic memory allocation is available in the + * kernel + * + ******************************************************************************/ + +ACPI_STATUS +AcpiReallocateRootTable ( + void) +{ + ACPI_TABLE_DESC *Tables; + ACPI_SIZE NewSize; + + + ACPI_FUNCTION_TRACE (AcpiReallocateRootTable); + + + /* + * Only reallocate the root table if the host provided a static buffer + * for the table array in the call to AcpiInitializeTables. + */ + if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED) + { + return_ACPI_STATUS (AE_SUPPORT); + } + + NewSize = ((ACPI_SIZE) AcpiGbl_RootTableList.Count + + ACPI_ROOT_TABLE_SIZE_INCREMENT) * + sizeof (ACPI_TABLE_DESC); + + /* Create new array and copy the old array */ + + Tables = ACPI_ALLOCATE_ZEROED (NewSize); + if (!Tables) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + ACPI_MEMCPY (Tables, AcpiGbl_RootTableList.Tables, NewSize); + + AcpiGbl_RootTableList.Size = AcpiGbl_RootTableList.Count; + AcpiGbl_RootTableList.Tables = Tables; + AcpiGbl_RootTableList.Flags = + ACPI_ROOT_ORIGIN_ALLOCATED | ACPI_ROOT_ALLOW_RESIZE; + + return_ACPI_STATUS (AE_OK); +} + +ACPI_EXPORT_SYMBOL (AcpiReallocateRootTable) + + +/******************************************************************************* + * + * FUNCTION: AcpiGetTableHeader + * + * PARAMETERS: Signature - ACPI signature of needed table + * Instance - Which instance (for SSDTs) + * OutTableHeader - The pointer to the table header to fill + * + * RETURN: Status and pointer to mapped table header + * + * DESCRIPTION: Finds an ACPI table header. + * + * NOTE: Caller is responsible in unmapping the header with + * AcpiOsUnmapMemory + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetTableHeader ( + char *Signature, + UINT32 Instance, + ACPI_TABLE_HEADER *OutTableHeader) +{ + UINT32 i; + UINT32 j; + ACPI_TABLE_HEADER *Header; + + + /* Parameter validation */ + + if (!Signature || !OutTableHeader) + { + return (AE_BAD_PARAMETER); + } + + /* Walk the root table list */ + + for (i = 0, j = 0; i < AcpiGbl_RootTableList.Count; i++) + { + if (!ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature), + Signature)) + { + continue; + } + + if (++j < Instance) + { + continue; + } + + if (!AcpiGbl_RootTableList.Tables[i].Pointer) + { + if ((AcpiGbl_RootTableList.Tables[i].Flags & + ACPI_TABLE_ORIGIN_MASK) == + ACPI_TABLE_ORIGIN_MAPPED) + { + Header = AcpiOsMapMemory ( + AcpiGbl_RootTableList.Tables[i].Address, + sizeof (ACPI_TABLE_HEADER)); + if (!Header) + { + return AE_NO_MEMORY; + } + + ACPI_MEMCPY (OutTableHeader, Header, sizeof(ACPI_TABLE_HEADER)); + AcpiOsUnmapMemory (Header, sizeof(ACPI_TABLE_HEADER)); + } + else + { + return AE_NOT_FOUND; + } + } + else + { + ACPI_MEMCPY (OutTableHeader, + AcpiGbl_RootTableList.Tables[i].Pointer, + sizeof(ACPI_TABLE_HEADER)); + } + + return (AE_OK); + } + + return (AE_NOT_FOUND); +} + +ACPI_EXPORT_SYMBOL (AcpiGetTableHeader) + + +/******************************************************************************* + * + * FUNCTION: AcpiGetTable + * + * PARAMETERS: Signature - ACPI signature of needed table + * Instance - Which instance (for SSDTs) + * OutTable - Where the pointer to the table is returned + * + * RETURN: Status and pointer to table + * + * DESCRIPTION: Finds and verifies an ACPI table. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetTable ( + char *Signature, + UINT32 Instance, + ACPI_TABLE_HEADER **OutTable) +{ + UINT32 i; + UINT32 j; + ACPI_STATUS Status; + + + /* Parameter validation */ + + if (!Signature || !OutTable) + { + return (AE_BAD_PARAMETER); + } + + /* Walk the root table list */ + + for (i = 0, j = 0; i < AcpiGbl_RootTableList.Count; i++) + { + if (!ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature), + Signature)) + { + continue; + } + + if (++j < Instance) + { + continue; + } + + Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[i]); + if (ACPI_SUCCESS (Status)) + { + *OutTable = AcpiGbl_RootTableList.Tables[i].Pointer; + } + + return (Status); + } + + return (AE_NOT_FOUND); +} + +ACPI_EXPORT_SYMBOL (AcpiGetTable) + + +/******************************************************************************* + * + * FUNCTION: AcpiGetTableByIndex + * + * PARAMETERS: TableIndex - Table index + * Table - Where the pointer to the table is returned + * + * RETURN: Status and pointer to the table + * + * DESCRIPTION: Obtain a table by an index into the global table list. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetTableByIndex ( + UINT32 TableIndex, + ACPI_TABLE_HEADER **Table) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiGetTableByIndex); + + + /* Parameter validation */ + + if (!Table) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + + /* Validate index */ + + if (TableIndex >= AcpiGbl_RootTableList.Count) + { + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + if (!AcpiGbl_RootTableList.Tables[TableIndex].Pointer) + { + /* Table is not mapped, map it */ + + Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[TableIndex]); + if (ACPI_FAILURE (Status)) + { + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + return_ACPI_STATUS (Status); + } + } + + *Table = AcpiGbl_RootTableList.Tables[TableIndex].Pointer; + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + return_ACPI_STATUS (AE_OK); +} + +ACPI_EXPORT_SYMBOL (AcpiGetTableByIndex) + + +/******************************************************************************* + * + * FUNCTION: AcpiTbLoadNamespace + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Load the namespace from the DSDT and all SSDTs/PSDTs found in + * the RSDT/XSDT. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiTbLoadNamespace ( + void) +{ + ACPI_STATUS Status; + UINT32 i; + + + ACPI_FUNCTION_TRACE (TbLoadNamespace); + + + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + + /* + * Load the namespace. The DSDT is required, but any SSDT and PSDT tables + * are optional. + */ + if (!AcpiGbl_RootTableList.Count || + !ACPI_COMPARE_NAME ( + &(AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT].Signature), + ACPI_SIG_DSDT) || + ACPI_FAILURE (AcpiTbVerifyTable ( + &AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT]))) + { + Status = AE_NO_ACPI_TABLES; + goto UnlockAndExit; + } + + /* A valid DSDT is required */ + + Status = AcpiTbVerifyTable ( + &AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT]); + if (ACPI_FAILURE (Status)) + { + Status = AE_NO_ACPI_TABLES; + goto UnlockAndExit; + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + + /* Load and parse tables */ + + Status = AcpiNsLoadTable (ACPI_TABLE_INDEX_DSDT, AcpiGbl_RootNode); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Load any SSDT or PSDT tables. Note: Loop leaves tables locked */ + + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + for (i = 0; i < AcpiGbl_RootTableList.Count; ++i) + { + if ((!ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature), + ACPI_SIG_SSDT) && + !ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature), + ACPI_SIG_PSDT)) || + ACPI_FAILURE (AcpiTbVerifyTable ( + &AcpiGbl_RootTableList.Tables[i]))) + { + continue; + } + + /* Ignore errors while loading tables, get as many as possible */ + + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + (void) AcpiNsLoadTable (i, AcpiGbl_RootNode); + (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES); + } + + ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "ACPI Tables successfully acquired\n")); + +UnlockAndExit: + (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiLoadTables + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Load the ACPI tables from the RSDT/XSDT + * + ******************************************************************************/ + +ACPI_STATUS +AcpiLoadTables ( + void) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiLoadTables); + + + /* Load the namespace from the tables */ + + Status = AcpiTbLoadNamespace (); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, + "While loading namespace from ACPI tables")); + } + + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiLoadTables) + + +/******************************************************************************* + * + * FUNCTION: AcpiInstallTableHandler + * + * PARAMETERS: Handler - Table event handler + * Context - Value passed to the handler on each event + * + * RETURN: Status + * + * DESCRIPTION: Install table event handler + * + ******************************************************************************/ + +ACPI_STATUS +AcpiInstallTableHandler ( + ACPI_TABLE_HANDLER Handler, + void *Context) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiInstallTableHandler); + + + if (!Handler) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Don't allow more than one handler */ + + if (AcpiGbl_TableHandler) + { + Status = AE_ALREADY_EXISTS; + goto Cleanup; + } + + /* Install the handler */ + + AcpiGbl_TableHandler = Handler; + AcpiGbl_TableHandlerContext = Context; + +Cleanup: + (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiInstallTableHandler) + + +/******************************************************************************* + * + * FUNCTION: AcpiRemoveTableHandler + * + * PARAMETERS: Handler - Table event handler that was installed + * previously. + * + * RETURN: Status + * + * DESCRIPTION: Remove table event handler + * + ******************************************************************************/ + +ACPI_STATUS +AcpiRemoveTableHandler ( + ACPI_TABLE_HANDLER Handler) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiRemoveTableHandler); + + + Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Make sure that the installed handler is the same */ + + if (!Handler || + Handler != AcpiGbl_TableHandler) + { + Status = AE_BAD_PARAMETER; + goto Cleanup; + } + + /* Remove the handler */ + + AcpiGbl_TableHandler = NULL; + +Cleanup: + (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiRemoveTableHandler) + diff --git a/reactos/drivers/bus/acpi/acpica/tables/tbxfroot.c b/reactos/drivers/bus/acpi/acpica/tables/tbxfroot.c new file mode 100644 index 00000000000..e0a571f36f4 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/tables/tbxfroot.c @@ -0,0 +1,371 @@ +/****************************************************************************** + * + * Module Name: tbxfroot - Find the root ACPI table (RSDT) + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __TBXFROOT_C__ + +#include "acpi.h" +#include "accommon.h" +#include "actables.h" + + +#define _COMPONENT ACPI_TABLES + ACPI_MODULE_NAME ("tbxfroot") + +/* Local prototypes */ + +static UINT8 * +AcpiTbScanMemoryForRsdp ( + UINT8 *StartAddress, + UINT32 Length); + +static ACPI_STATUS +AcpiTbValidateRsdp ( + ACPI_TABLE_RSDP *Rsdp); + + +/******************************************************************************* + * + * FUNCTION: AcpiTbValidateRsdp + * + * PARAMETERS: Rsdp - Pointer to unvalidated RSDP + * + * RETURN: Status + * + * DESCRIPTION: Validate the RSDP (ptr) + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiTbValidateRsdp ( + ACPI_TABLE_RSDP *Rsdp) +{ + ACPI_FUNCTION_ENTRY (); + + + /* + * The signature and checksum must both be correct + * + * Note: Sometimes there exists more than one RSDP in memory; the valid + * RSDP has a valid checksum, all others have an invalid checksum. + */ + if (ACPI_STRNCMP ((char *) Rsdp, ACPI_SIG_RSDP, + sizeof (ACPI_SIG_RSDP)-1) != 0) + { + /* Nope, BAD Signature */ + + return (AE_BAD_SIGNATURE); + } + + /* Check the standard checksum */ + + if (AcpiTbChecksum ((UINT8 *) Rsdp, ACPI_RSDP_CHECKSUM_LENGTH) != 0) + { + return (AE_BAD_CHECKSUM); + } + + /* Check extended checksum if table version >= 2 */ + + if ((Rsdp->Revision >= 2) && + (AcpiTbChecksum ((UINT8 *) Rsdp, ACPI_RSDP_XCHECKSUM_LENGTH) != 0)) + { + return (AE_BAD_CHECKSUM); + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiFindRootPointer + * + * PARAMETERS: TableAddress - Where the table pointer is returned + * + * RETURN: Status, RSDP physical address + * + * DESCRIPTION: Search lower 1Mbyte of memory for the root system descriptor + * pointer structure. If it is found, set *RSDP to point to it. + * + * NOTE1: The RSDP must be either in the first 1K of the Extended + * BIOS Data Area or between E0000 and FFFFF (From ACPI Spec.) + * Only a 32-bit physical address is necessary. + * + * NOTE2: This function is always available, regardless of the + * initialization state of the rest of ACPI. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiFindRootPointer ( + ACPI_SIZE *TableAddress) +{ + UINT8 *TablePtr; + UINT8 *MemRover; + UINT32 PhysicalAddress; + + + ACPI_FUNCTION_TRACE (AcpiFindRootPointer); + + + /* 1a) Get the location of the Extended BIOS Data Area (EBDA) */ + + TablePtr = AcpiOsMapMemory ( + (ACPI_PHYSICAL_ADDRESS) ACPI_EBDA_PTR_LOCATION, + ACPI_EBDA_PTR_LENGTH); + if (!TablePtr) + { + ACPI_ERROR ((AE_INFO, + "Could not map memory at %8.8X for length %X", + ACPI_EBDA_PTR_LOCATION, ACPI_EBDA_PTR_LENGTH)); + + return_ACPI_STATUS (AE_NO_MEMORY); + } + + ACPI_MOVE_16_TO_32 (&PhysicalAddress, TablePtr); + + /* Convert segment part to physical address */ + + PhysicalAddress <<= 4; + AcpiOsUnmapMemory (TablePtr, ACPI_EBDA_PTR_LENGTH); + + /* EBDA present? */ + + if (PhysicalAddress > 0x400) + { + /* + * 1b) Search EBDA paragraphs (EBDA is required to be a + * minimum of 1K length) + */ + TablePtr = AcpiOsMapMemory ( + (ACPI_PHYSICAL_ADDRESS) PhysicalAddress, + ACPI_EBDA_WINDOW_SIZE); + if (!TablePtr) + { + ACPI_ERROR ((AE_INFO, + "Could not map memory at %8.8X for length %X", + PhysicalAddress, ACPI_EBDA_WINDOW_SIZE)); + + return_ACPI_STATUS (AE_NO_MEMORY); + } + + MemRover = AcpiTbScanMemoryForRsdp (TablePtr, ACPI_EBDA_WINDOW_SIZE); + AcpiOsUnmapMemory (TablePtr, ACPI_EBDA_WINDOW_SIZE); + + if (MemRover) + { + /* Return the physical address */ + + PhysicalAddress += (UINT32) ACPI_PTR_DIFF (MemRover, TablePtr); + + *TableAddress = PhysicalAddress; + return_ACPI_STATUS (AE_OK); + } + } + + /* + * 2) Search upper memory: 16-byte boundaries in E0000h-FFFFFh + */ + TablePtr = AcpiOsMapMemory ( + (ACPI_PHYSICAL_ADDRESS) ACPI_HI_RSDP_WINDOW_BASE, + ACPI_HI_RSDP_WINDOW_SIZE); + + if (!TablePtr) + { + ACPI_ERROR ((AE_INFO, + "Could not map memory at %8.8X for length %X", + ACPI_HI_RSDP_WINDOW_BASE, ACPI_HI_RSDP_WINDOW_SIZE)); + + return_ACPI_STATUS (AE_NO_MEMORY); + } + + MemRover = AcpiTbScanMemoryForRsdp (TablePtr, ACPI_HI_RSDP_WINDOW_SIZE); + AcpiOsUnmapMemory (TablePtr, ACPI_HI_RSDP_WINDOW_SIZE); + + if (MemRover) + { + /* Return the physical address */ + + PhysicalAddress = (UINT32) + (ACPI_HI_RSDP_WINDOW_BASE + ACPI_PTR_DIFF (MemRover, TablePtr)); + + *TableAddress = PhysicalAddress; + return_ACPI_STATUS (AE_OK); + } + + /* A valid RSDP was not found */ + + ACPI_ERROR ((AE_INFO, "A valid RSDP was not found")); + return_ACPI_STATUS (AE_NOT_FOUND); +} + +ACPI_EXPORT_SYMBOL (AcpiFindRootPointer) + + +/******************************************************************************* + * + * FUNCTION: AcpiTbScanMemoryForRsdp + * + * PARAMETERS: StartAddress - Starting pointer for search + * Length - Maximum length to search + * + * RETURN: Pointer to the RSDP if found, otherwise NULL. + * + * DESCRIPTION: Search a block of memory for the RSDP signature + * + ******************************************************************************/ + +static UINT8 * +AcpiTbScanMemoryForRsdp ( + UINT8 *StartAddress, + UINT32 Length) +{ + ACPI_STATUS Status; + UINT8 *MemRover; + UINT8 *EndAddress; + + + ACPI_FUNCTION_TRACE (TbScanMemoryForRsdp); + + + EndAddress = StartAddress + Length; + + /* Search from given start address for the requested length */ + + for (MemRover = StartAddress; MemRover < EndAddress; + MemRover += ACPI_RSDP_SCAN_STEP) + { + /* The RSDP signature and checksum must both be correct */ + + Status = AcpiTbValidateRsdp (ACPI_CAST_PTR (ACPI_TABLE_RSDP, MemRover)); + if (ACPI_SUCCESS (Status)) + { + /* Sig and checksum valid, we have found a real RSDP */ + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "RSDP located at physical address %p\n", MemRover)); + return_PTR (MemRover); + } + + /* No sig match or bad checksum, keep searching */ + } + + /* Searched entire block, no RSDP was found */ + + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Searched entire block from %p, valid RSDP was not found\n", + StartAddress)); + return_PTR (NULL); +} + diff --git a/reactos/drivers/bus/acpi/acpica/utilities/utalloc.c b/reactos/drivers/bus/acpi/acpica/utilities/utalloc.c new file mode 100644 index 00000000000..a66b94005c1 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/utilities/utalloc.c @@ -0,0 +1,488 @@ +/****************************************************************************** + * + * Module Name: utalloc - local memory allocation routines + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __UTALLOC_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acdebug.h" + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utalloc") + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreateCaches + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Create all local caches + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtCreateCaches ( + void) +{ + ACPI_STATUS Status; + + + /* Object Caches, for frequently used objects */ + + Status = AcpiOsCreateCache ("Acpi-Namespace", sizeof (ACPI_NAMESPACE_NODE), + ACPI_MAX_NAMESPACE_CACHE_DEPTH, &AcpiGbl_NamespaceCache); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Status = AcpiOsCreateCache ("Acpi-State", sizeof (ACPI_GENERIC_STATE), + ACPI_MAX_STATE_CACHE_DEPTH, &AcpiGbl_StateCache); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Status = AcpiOsCreateCache ("Acpi-Parse", sizeof (ACPI_PARSE_OBJ_COMMON), + ACPI_MAX_PARSE_CACHE_DEPTH, &AcpiGbl_PsNodeCache); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Status = AcpiOsCreateCache ("Acpi-ParseExt", sizeof (ACPI_PARSE_OBJ_NAMED), + ACPI_MAX_EXTPARSE_CACHE_DEPTH, &AcpiGbl_PsNodeExtCache); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Status = AcpiOsCreateCache ("Acpi-Operand", sizeof (ACPI_OPERAND_OBJECT), + ACPI_MAX_OBJECT_CACHE_DEPTH, &AcpiGbl_OperandCache); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + +#ifdef ACPI_DBG_TRACK_ALLOCATIONS + + /* Memory allocation lists */ + + Status = AcpiUtCreateList ("Acpi-Global", 0, + &AcpiGbl_GlobalList); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Status = AcpiUtCreateList ("Acpi-Namespace", sizeof (ACPI_NAMESPACE_NODE), + &AcpiGbl_NsNodeList); + if (ACPI_FAILURE (Status)) + { + return (Status); + } +#endif + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtDeleteCaches + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Purge and delete all local caches + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtDeleteCaches ( + void) +{ +#ifdef ACPI_DBG_TRACK_ALLOCATIONS + char Buffer[7]; + + if (AcpiGbl_DisplayFinalMemStats) + { + ACPI_STRCPY (Buffer, "MEMORY"); + (void) AcpiDbDisplayStatistics (Buffer); + } +#endif + + (void) AcpiOsDeleteCache (AcpiGbl_NamespaceCache); + AcpiGbl_NamespaceCache = NULL; + + (void) AcpiOsDeleteCache (AcpiGbl_StateCache); + AcpiGbl_StateCache = NULL; + + (void) AcpiOsDeleteCache (AcpiGbl_OperandCache); + AcpiGbl_OperandCache = NULL; + + (void) AcpiOsDeleteCache (AcpiGbl_PsNodeCache); + AcpiGbl_PsNodeCache = NULL; + + (void) AcpiOsDeleteCache (AcpiGbl_PsNodeExtCache); + AcpiGbl_PsNodeExtCache = NULL; + + +#ifdef ACPI_DBG_TRACK_ALLOCATIONS + + /* Debug only - display leftover memory allocation, if any */ + + AcpiUtDumpAllocations (ACPI_UINT32_MAX, NULL); + + /* Free memory lists */ + + AcpiOsFree (AcpiGbl_GlobalList); + AcpiGbl_GlobalList = NULL; + + AcpiOsFree (AcpiGbl_NsNodeList); + AcpiGbl_NsNodeList = NULL; +#endif + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtValidateBuffer + * + * PARAMETERS: Buffer - Buffer descriptor to be validated + * + * RETURN: Status + * + * DESCRIPTION: Perform parameter validation checks on an ACPI_BUFFER + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtValidateBuffer ( + ACPI_BUFFER *Buffer) +{ + + /* Obviously, the structure pointer must be valid */ + + if (!Buffer) + { + return (AE_BAD_PARAMETER); + } + + /* Special semantics for the length */ + + if ((Buffer->Length == ACPI_NO_BUFFER) || + (Buffer->Length == ACPI_ALLOCATE_BUFFER) || + (Buffer->Length == ACPI_ALLOCATE_LOCAL_BUFFER)) + { + return (AE_OK); + } + + /* Length is valid, the buffer pointer must be also */ + + if (!Buffer->Pointer) + { + return (AE_BAD_PARAMETER); + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtInitializeBuffer + * + * PARAMETERS: Buffer - Buffer to be validated + * RequiredLength - Length needed + * + * RETURN: Status + * + * DESCRIPTION: Validate that the buffer is of the required length or + * allocate a new buffer. Returned buffer is always zeroed. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtInitializeBuffer ( + ACPI_BUFFER *Buffer, + ACPI_SIZE RequiredLength) +{ + ACPI_SIZE InputBufferLength; + + + /* Parameter validation */ + + if (!Buffer || !RequiredLength) + { + return (AE_BAD_PARAMETER); + } + + /* + * Buffer->Length is used as both an input and output parameter. Get the + * input actual length and set the output required buffer length. + */ + InputBufferLength = Buffer->Length; + Buffer->Length = RequiredLength; + + /* + * The input buffer length contains the actual buffer length, or the type + * of buffer to be allocated by this routine. + */ + switch (InputBufferLength) + { + case ACPI_NO_BUFFER: + + /* Return the exception (and the required buffer length) */ + + return (AE_BUFFER_OVERFLOW); + + case ACPI_ALLOCATE_BUFFER: + + /* Allocate a new buffer */ + + Buffer->Pointer = AcpiOsAllocate (RequiredLength); + break; + + case ACPI_ALLOCATE_LOCAL_BUFFER: + + /* Allocate a new buffer with local interface to allow tracking */ + + Buffer->Pointer = ACPI_ALLOCATE (RequiredLength); + break; + + default: + + /* Existing buffer: Validate the size of the buffer */ + + if (InputBufferLength < RequiredLength) + { + return (AE_BUFFER_OVERFLOW); + } + break; + } + + /* Validate allocation from above or input buffer pointer */ + + if (!Buffer->Pointer) + { + return (AE_NO_MEMORY); + } + + /* Have a valid buffer, clear it */ + + ACPI_MEMSET (Buffer->Pointer, 0, RequiredLength); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtAllocate + * + * PARAMETERS: Size - Size of the allocation + * Component - Component type of caller + * Module - Source file name of caller + * Line - Line number of caller + * + * RETURN: Address of the allocated memory on success, NULL on failure. + * + * DESCRIPTION: Subsystem equivalent of malloc. + * + ******************************************************************************/ + +void * +AcpiUtAllocate ( + ACPI_SIZE Size, + UINT32 Component, + const char *Module, + UINT32 Line) +{ + void *Allocation; + + + ACPI_FUNCTION_TRACE_U32 (UtAllocate, Size); + + + /* Check for an inadvertent size of zero bytes */ + + if (!Size) + { + ACPI_WARNING ((Module, Line, + "Attempt to allocate zero bytes, allocating 1 byte")); + Size = 1; + } + + Allocation = AcpiOsAllocate (Size); + if (!Allocation) + { + /* Report allocation error */ + + ACPI_WARNING ((Module, Line, + "Could not allocate size %X", (UINT32) Size)); + + return_PTR (NULL); + } + + return_PTR (Allocation); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtAllocateZeroed + * + * PARAMETERS: Size - Size of the allocation + * Component - Component type of caller + * Module - Source file name of caller + * Line - Line number of caller + * + * RETURN: Address of the allocated memory on success, NULL on failure. + * + * DESCRIPTION: Subsystem equivalent of calloc. Allocate and zero memory. + * + ******************************************************************************/ + +void * +AcpiUtAllocateZeroed ( + ACPI_SIZE Size, + UINT32 Component, + const char *Module, + UINT32 Line) +{ + void *Allocation; + + + ACPI_FUNCTION_ENTRY (); + + + Allocation = AcpiUtAllocate (Size, Component, Module, Line); + if (Allocation) + { + /* Clear the memory block */ + + ACPI_MEMSET (Allocation, 0, Size); + } + + return (Allocation); +} + diff --git a/reactos/drivers/bus/acpi/acpica/utilities/utcache.c b/reactos/drivers/bus/acpi/acpica/utilities/utcache.c new file mode 100644 index 00000000000..aabc0a23052 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/utilities/utcache.c @@ -0,0 +1,433 @@ +/****************************************************************************** + * + * Module Name: utcache - local cache allocation routines + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __UTCACHE_C__ + +#include "acpi.h" +#include "accommon.h" + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utcache") + + +#ifdef ACPI_USE_LOCAL_CACHE +/******************************************************************************* + * + * FUNCTION: AcpiOsCreateCache + * + * PARAMETERS: CacheName - Ascii name for the cache + * ObjectSize - Size of each cached object + * MaxDepth - Maximum depth of the cache (in objects) + * ReturnCache - Where the new cache object is returned + * + * RETURN: Status + * + * DESCRIPTION: Create a cache object + * + ******************************************************************************/ + +ACPI_STATUS +AcpiOsCreateCache ( + char *CacheName, + UINT16 ObjectSize, + UINT16 MaxDepth, + ACPI_MEMORY_LIST **ReturnCache) +{ + ACPI_MEMORY_LIST *Cache; + + + ACPI_FUNCTION_ENTRY (); + + + if (!CacheName || !ReturnCache || (ObjectSize < 16)) + { + return (AE_BAD_PARAMETER); + } + + /* Create the cache object */ + + Cache = AcpiOsAllocate (sizeof (ACPI_MEMORY_LIST)); + if (!Cache) + { + return (AE_NO_MEMORY); + } + + /* Populate the cache object and return it */ + + ACPI_MEMSET (Cache, 0, sizeof (ACPI_MEMORY_LIST)); + Cache->LinkOffset = 8; + Cache->ListName = CacheName; + Cache->ObjectSize = ObjectSize; + Cache->MaxDepth = MaxDepth; + + *ReturnCache = Cache; + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiOsPurgeCache + * + * PARAMETERS: Cache - Handle to cache object + * + * RETURN: Status + * + * DESCRIPTION: Free all objects within the requested cache. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiOsPurgeCache ( + ACPI_MEMORY_LIST *Cache) +{ + char *Next; + ACPI_STATUS Status; + + + ACPI_FUNCTION_ENTRY (); + + + if (!Cache) + { + return (AE_BAD_PARAMETER); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_CACHES); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Walk the list of objects in this cache */ + + while (Cache->ListHead) + { + /* Delete and unlink one cached state object */ + + Next = *(ACPI_CAST_INDIRECT_PTR (char, + &(((char *) Cache->ListHead)[Cache->LinkOffset]))); + ACPI_FREE (Cache->ListHead); + + Cache->ListHead = Next; + Cache->CurrentDepth--; + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiOsDeleteCache + * + * PARAMETERS: Cache - Handle to cache object + * + * RETURN: Status + * + * DESCRIPTION: Free all objects within the requested cache and delete the + * cache object. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiOsDeleteCache ( + ACPI_MEMORY_LIST *Cache) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_ENTRY (); + + + /* Purge all objects in the cache */ + + Status = AcpiOsPurgeCache (Cache); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Now we can delete the cache object */ + + AcpiOsFree (Cache); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiOsReleaseObject + * + * PARAMETERS: Cache - Handle to cache object + * Object - The object to be released + * + * RETURN: None + * + * DESCRIPTION: Release an object to the specified cache. If cache is full, + * the object is deleted. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiOsReleaseObject ( + ACPI_MEMORY_LIST *Cache, + void *Object) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_ENTRY (); + + + if (!Cache || !Object) + { + return (AE_BAD_PARAMETER); + } + + /* If cache is full, just free this object */ + + if (Cache->CurrentDepth >= Cache->MaxDepth) + { + ACPI_FREE (Object); + ACPI_MEM_TRACKING (Cache->TotalFreed++); + } + + /* Otherwise put this object back into the cache */ + + else + { + Status = AcpiUtAcquireMutex (ACPI_MTX_CACHES); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Mark the object as cached */ + + ACPI_MEMSET (Object, 0xCA, Cache->ObjectSize); + ACPI_SET_DESCRIPTOR_TYPE (Object, ACPI_DESC_TYPE_CACHED); + + /* Put the object at the head of the cache list */ + + * (ACPI_CAST_INDIRECT_PTR (char, + &(((char *) Object)[Cache->LinkOffset]))) = Cache->ListHead; + Cache->ListHead = Object; + Cache->CurrentDepth++; + + (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES); + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiOsAcquireObject + * + * PARAMETERS: Cache - Handle to cache object + * + * RETURN: the acquired object. NULL on error + * + * DESCRIPTION: Get an object from the specified cache. If cache is empty, + * the object is allocated. + * + ******************************************************************************/ + +void * +AcpiOsAcquireObject ( + ACPI_MEMORY_LIST *Cache) +{ + ACPI_STATUS Status; + void *Object; + + + ACPI_FUNCTION_NAME (OsAcquireObject); + + + if (!Cache) + { + return (NULL); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_CACHES); + if (ACPI_FAILURE (Status)) + { + return (NULL); + } + + ACPI_MEM_TRACKING (Cache->Requests++); + + /* Check the cache first */ + + if (Cache->ListHead) + { + /* There is an object available, use it */ + + Object = Cache->ListHead; + Cache->ListHead = *(ACPI_CAST_INDIRECT_PTR (char, + &(((char *) Object)[Cache->LinkOffset]))); + + Cache->CurrentDepth--; + + ACPI_MEM_TRACKING (Cache->Hits++); + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "Object %p from %s cache\n", Object, Cache->ListName)); + + Status = AcpiUtReleaseMutex (ACPI_MTX_CACHES); + if (ACPI_FAILURE (Status)) + { + return (NULL); + } + + /* Clear (zero) the previously used Object */ + + ACPI_MEMSET (Object, 0, Cache->ObjectSize); + } + else + { + /* The cache is empty, create a new object */ + + ACPI_MEM_TRACKING (Cache->TotalAllocated++); + +#ifdef ACPI_DBG_TRACK_ALLOCATIONS + if ((Cache->TotalAllocated - Cache->TotalFreed) > Cache->MaxOccupied) + { + Cache->MaxOccupied = Cache->TotalAllocated - Cache->TotalFreed; + } +#endif + + /* Avoid deadlock with ACPI_ALLOCATE_ZEROED */ + + Status = AcpiUtReleaseMutex (ACPI_MTX_CACHES); + if (ACPI_FAILURE (Status)) + { + return (NULL); + } + + Object = ACPI_ALLOCATE_ZEROED (Cache->ObjectSize); + if (!Object) + { + return (NULL); + } + } + + return (Object); +} +#endif /* ACPI_USE_LOCAL_CACHE */ + + diff --git a/reactos/drivers/bus/acpi/acpica/utilities/utclib.c b/reactos/drivers/bus/acpi/acpica/utilities/utclib.c new file mode 100644 index 00000000000..a9b8122fab8 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/utilities/utclib.c @@ -0,0 +1,961 @@ +/****************************************************************************** + * + * Module Name: cmclib - Local implementation of C library functions + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __CMCLIB_C__ + +#include "acpi.h" +#include "accommon.h" + +/* + * These implementations of standard C Library routines can optionally be + * used if a C library is not available. In general, they are less efficient + * than an inline or assembly implementation + */ + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("cmclib") + + +#ifndef ACPI_USE_SYSTEM_CLIBRARY + +#define NEGATIVE 1 +#define POSITIVE 0 + + +/******************************************************************************* + * + * FUNCTION: AcpiUtMemcmp (memcmp) + * + * PARAMETERS: Buffer1 - First Buffer + * Buffer2 - Second Buffer + * Count - Maximum # of bytes to compare + * + * RETURN: Index where Buffers mismatched, or 0 if Buffers matched + * + * DESCRIPTION: Compare two Buffers, with a maximum length + * + ******************************************************************************/ + +int +AcpiUtMemcmp ( + const char *Buffer1, + const char *Buffer2, + ACPI_SIZE Count) +{ + + for ( ; Count-- && (*Buffer1 == *Buffer2); Buffer1++, Buffer2++) + { + } + + return ((Count == ACPI_SIZE_MAX) ? 0 : ((unsigned char) *Buffer1 - + (unsigned char) *Buffer2)); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtMemcpy (memcpy) + * + * PARAMETERS: Dest - Target of the copy + * Src - Source buffer to copy + * Count - Number of bytes to copy + * + * RETURN: Dest + * + * DESCRIPTION: Copy arbitrary bytes of memory + * + ******************************************************************************/ + +void * +AcpiUtMemcpy ( + void *Dest, + const void *Src, + ACPI_SIZE Count) +{ + char *New = (char *) Dest; + char *Old = (char *) Src; + + + while (Count) + { + *New = *Old; + New++; + Old++; + Count--; + } + + return (Dest); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtMemset (memset) + * + * PARAMETERS: Dest - Buffer to set + * Value - Value to set each byte of memory + * Count - Number of bytes to set + * + * RETURN: Dest + * + * DESCRIPTION: Initialize a buffer to a known value. + * + ******************************************************************************/ + +void * +AcpiUtMemset ( + void *Dest, + UINT8 Value, + ACPI_SIZE Count) +{ + char *New = (char *) Dest; + + + while (Count) + { + *New = (char) Value; + New++; + Count--; + } + + return (Dest); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtStrlen (strlen) + * + * PARAMETERS: String - Null terminated string + * + * RETURN: Length + * + * DESCRIPTION: Returns the length of the input string + * + ******************************************************************************/ + + +ACPI_SIZE +AcpiUtStrlen ( + const char *String) +{ + UINT32 Length = 0; + + + /* Count the string until a null is encountered */ + + while (*String) + { + Length++; + String++; + } + + return (Length); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtStrcpy (strcpy) + * + * PARAMETERS: DstString - Target of the copy + * SrcString - The source string to copy + * + * RETURN: DstString + * + * DESCRIPTION: Copy a null terminated string + * + ******************************************************************************/ + +char * +AcpiUtStrcpy ( + char *DstString, + const char *SrcString) +{ + char *String = DstString; + + + /* Move bytes brute force */ + + while (*SrcString) + { + *String = *SrcString; + + String++; + SrcString++; + } + + /* Null terminate */ + + *String = 0; + return (DstString); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtStrncpy (strncpy) + * + * PARAMETERS: DstString - Target of the copy + * SrcString - The source string to copy + * Count - Maximum # of bytes to copy + * + * RETURN: DstString + * + * DESCRIPTION: Copy a null terminated string, with a maximum length + * + ******************************************************************************/ + +char * +AcpiUtStrncpy ( + char *DstString, + const char *SrcString, + ACPI_SIZE Count) +{ + char *String = DstString; + + + /* Copy the string */ + + for (String = DstString; + Count && (Count--, (*String++ = *SrcString++)); ) + {;} + + /* Pad with nulls if necessary */ + + while (Count--) + { + *String = 0; + String++; + } + + /* Return original pointer */ + + return (DstString); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtStrcmp (strcmp) + * + * PARAMETERS: String1 - First string + * String2 - Second string + * + * RETURN: Index where strings mismatched, or 0 if strings matched + * + * DESCRIPTION: Compare two null terminated strings + * + ******************************************************************************/ + +int +AcpiUtStrcmp ( + const char *String1, + const char *String2) +{ + + + for ( ; (*String1 == *String2); String2++) + { + if (!*String1++) + { + return (0); + } + } + + return ((unsigned char) *String1 - (unsigned char) *String2); +} + + +#ifdef ACPI_FUTURE_IMPLEMENTATION +/* Not used at this time */ +/******************************************************************************* + * + * FUNCTION: AcpiUtStrchr (strchr) + * + * PARAMETERS: String - Search string + * ch - character to search for + * + * RETURN: Ptr to char or NULL if not found + * + * DESCRIPTION: Search a string for a character + * + ******************************************************************************/ + +char * +AcpiUtStrchr ( + const char *String, + int ch) +{ + + + for ( ; (*String); String++) + { + if ((*String) == (char) ch) + { + return ((char *) String); + } + } + + return (NULL); +} +#endif + +/******************************************************************************* + * + * FUNCTION: AcpiUtStrncmp (strncmp) + * + * PARAMETERS: String1 - First string + * String2 - Second string + * Count - Maximum # of bytes to compare + * + * RETURN: Index where strings mismatched, or 0 if strings matched + * + * DESCRIPTION: Compare two null terminated strings, with a maximum length + * + ******************************************************************************/ + +int +AcpiUtStrncmp ( + const char *String1, + const char *String2, + ACPI_SIZE Count) +{ + + + for ( ; Count-- && (*String1 == *String2); String2++) + { + if (!*String1++) + { + return (0); + } + } + + return ((Count == ACPI_SIZE_MAX) ? 0 : ((unsigned char) *String1 - + (unsigned char) *String2)); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtStrcat (Strcat) + * + * PARAMETERS: DstString - Target of the copy + * SrcString - The source string to copy + * + * RETURN: DstString + * + * DESCRIPTION: Append a null terminated string to a null terminated string + * + ******************************************************************************/ + +char * +AcpiUtStrcat ( + char *DstString, + const char *SrcString) +{ + char *String; + + + /* Find end of the destination string */ + + for (String = DstString; *String++; ) + { ; } + + /* Concatenate the string */ + + for (--String; (*String++ = *SrcString++); ) + { ; } + + return (DstString); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtStrncat (strncat) + * + * PARAMETERS: DstString - Target of the copy + * SrcString - The source string to copy + * Count - Maximum # of bytes to copy + * + * RETURN: DstString + * + * DESCRIPTION: Append a null terminated string to a null terminated string, + * with a maximum count. + * + ******************************************************************************/ + +char * +AcpiUtStrncat ( + char *DstString, + const char *SrcString, + ACPI_SIZE Count) +{ + char *String; + + + if (Count) + { + /* Find end of the destination string */ + + for (String = DstString; *String++; ) + { ; } + + /* Concatenate the string */ + + for (--String; (*String++ = *SrcString++) && --Count; ) + { ; } + + /* Null terminate if necessary */ + + if (!Count) + { + *String = 0; + } + } + + return (DstString); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtStrstr (strstr) + * + * PARAMETERS: String1 - Target string + * String2 - Substring to search for + * + * RETURN: Where substring match starts, Null if no match found + * + * DESCRIPTION: Checks if String2 occurs in String1. This is not really a + * full implementation of strstr, only sufficient for command + * matching + * + ******************************************************************************/ + +char * +AcpiUtStrstr ( + char *String1, + char *String2) +{ + char *String; + + + if (AcpiUtStrlen (String2) > AcpiUtStrlen (String1)) + { + return (NULL); + } + + /* Walk entire string, comparing the letters */ + + for (String = String1; *String2; ) + { + if (*String2 != *String) + { + return (NULL); + } + + String2++; + String++; + } + + return (String1); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtStrtoul (strtoul) + * + * PARAMETERS: String - Null terminated string + * Terminater - Where a pointer to the terminating byte is + * returned + * Base - Radix of the string + * + * RETURN: Converted value + * + * DESCRIPTION: Convert a string into a 32-bit unsigned value. + * Note: use AcpiUtStrtoul64 for 64-bit integers. + * + ******************************************************************************/ + +UINT32 +AcpiUtStrtoul ( + const char *String, + char **Terminator, + UINT32 Base) +{ + UINT32 converted = 0; + UINT32 index; + UINT32 sign; + const char *StringStart; + UINT32 ReturnValue = 0; + ACPI_STATUS Status = AE_OK; + + + /* + * Save the value of the pointer to the buffer's first + * character, save the current errno value, and then + * skip over any white space in the buffer: + */ + StringStart = String; + while (ACPI_IS_SPACE (*String) || *String == '\t') + { + ++String; + } + + /* + * The buffer may contain an optional plus or minus sign. + * If it does, then skip over it but remember what is was: + */ + if (*String == '-') + { + sign = NEGATIVE; + ++String; + } + else if (*String == '+') + { + ++String; + sign = POSITIVE; + } + else + { + sign = POSITIVE; + } + + /* + * If the input parameter Base is zero, then we need to + * determine if it is octal, decimal, or hexadecimal: + */ + if (Base == 0) + { + if (*String == '0') + { + if (AcpiUtToLower (*(++String)) == 'x') + { + Base = 16; + ++String; + } + else + { + Base = 8; + } + } + else + { + Base = 10; + } + } + else if (Base < 2 || Base > 36) + { + /* + * The specified Base parameter is not in the domain of + * this function: + */ + goto done; + } + + /* + * For octal and hexadecimal bases, skip over the leading + * 0 or 0x, if they are present. + */ + if (Base == 8 && *String == '0') + { + String++; + } + + if (Base == 16 && + *String == '0' && + AcpiUtToLower (*(++String)) == 'x') + { + String++; + } + + /* + * Main loop: convert the string to an unsigned long: + */ + while (*String) + { + if (ACPI_IS_DIGIT (*String)) + { + index = (UINT32) ((UINT8) *String - '0'); + } + else + { + index = (UINT32) AcpiUtToUpper (*String); + if (ACPI_IS_UPPER (index)) + { + index = index - 'A' + 10; + } + else + { + goto done; + } + } + + if (index >= Base) + { + goto done; + } + + /* + * Check to see if value is out of range: + */ + + if (ReturnValue > ((ACPI_UINT32_MAX - (UINT32) index) / + (UINT32) Base)) + { + Status = AE_ERROR; + ReturnValue = 0; /* reset */ + } + else + { + ReturnValue *= Base; + ReturnValue += index; + converted = 1; + } + + ++String; + } + +done: + /* + * If appropriate, update the caller's pointer to the next + * unconverted character in the buffer. + */ + if (Terminator) + { + if (converted == 0 && ReturnValue == 0 && String != NULL) + { + *Terminator = (char *) StringStart; + } + else + { + *Terminator = (char *) String; + } + } + + if (Status == AE_ERROR) + { + ReturnValue = ACPI_UINT32_MAX; + } + + /* + * If a minus sign was present, then "the conversion is negated": + */ + if (sign == NEGATIVE) + { + ReturnValue = (ACPI_UINT32_MAX - ReturnValue) + 1; + } + + return (ReturnValue); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtToUpper (TOUPPER) + * + * PARAMETERS: c - Character to convert + * + * RETURN: Converted character as an int + * + * DESCRIPTION: Convert character to uppercase + * + ******************************************************************************/ + +int +AcpiUtToUpper ( + int c) +{ + + return (ACPI_IS_LOWER(c) ? ((c)-0x20) : (c)); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtToLower (TOLOWER) + * + * PARAMETERS: c - Character to convert + * + * RETURN: Converted character as an int + * + * DESCRIPTION: Convert character to lowercase + * + ******************************************************************************/ + +int +AcpiUtToLower ( + int c) +{ + + return (ACPI_IS_UPPER(c) ? ((c)+0x20) : (c)); +} + + +/******************************************************************************* + * + * FUNCTION: is* functions + * + * DESCRIPTION: is* functions use the ctype table below + * + ******************************************************************************/ + +const UINT8 _acpi_ctype[257] = { + _ACPI_CN, /* 0x0 0. */ + _ACPI_CN, /* 0x1 1. */ + _ACPI_CN, /* 0x2 2. */ + _ACPI_CN, /* 0x3 3. */ + _ACPI_CN, /* 0x4 4. */ + _ACPI_CN, /* 0x5 5. */ + _ACPI_CN, /* 0x6 6. */ + _ACPI_CN, /* 0x7 7. */ + _ACPI_CN, /* 0x8 8. */ + _ACPI_CN|_ACPI_SP, /* 0x9 9. */ + _ACPI_CN|_ACPI_SP, /* 0xA 10. */ + _ACPI_CN|_ACPI_SP, /* 0xB 11. */ + _ACPI_CN|_ACPI_SP, /* 0xC 12. */ + _ACPI_CN|_ACPI_SP, /* 0xD 13. */ + _ACPI_CN, /* 0xE 14. */ + _ACPI_CN, /* 0xF 15. */ + _ACPI_CN, /* 0x10 16. */ + _ACPI_CN, /* 0x11 17. */ + _ACPI_CN, /* 0x12 18. */ + _ACPI_CN, /* 0x13 19. */ + _ACPI_CN, /* 0x14 20. */ + _ACPI_CN, /* 0x15 21. */ + _ACPI_CN, /* 0x16 22. */ + _ACPI_CN, /* 0x17 23. */ + _ACPI_CN, /* 0x18 24. */ + _ACPI_CN, /* 0x19 25. */ + _ACPI_CN, /* 0x1A 26. */ + _ACPI_CN, /* 0x1B 27. */ + _ACPI_CN, /* 0x1C 28. */ + _ACPI_CN, /* 0x1D 29. */ + _ACPI_CN, /* 0x1E 30. */ + _ACPI_CN, /* 0x1F 31. */ + _ACPI_XS|_ACPI_SP, /* 0x20 32. ' ' */ + _ACPI_PU, /* 0x21 33. '!' */ + _ACPI_PU, /* 0x22 34. '"' */ + _ACPI_PU, /* 0x23 35. '#' */ + _ACPI_PU, /* 0x24 36. '$' */ + _ACPI_PU, /* 0x25 37. '%' */ + _ACPI_PU, /* 0x26 38. '&' */ + _ACPI_PU, /* 0x27 39. ''' */ + _ACPI_PU, /* 0x28 40. '(' */ + _ACPI_PU, /* 0x29 41. ')' */ + _ACPI_PU, /* 0x2A 42. '*' */ + _ACPI_PU, /* 0x2B 43. '+' */ + _ACPI_PU, /* 0x2C 44. ',' */ + _ACPI_PU, /* 0x2D 45. '-' */ + _ACPI_PU, /* 0x2E 46. '.' */ + _ACPI_PU, /* 0x2F 47. '/' */ + _ACPI_XD|_ACPI_DI, /* 0x30 48. '0' */ + _ACPI_XD|_ACPI_DI, /* 0x31 49. '1' */ + _ACPI_XD|_ACPI_DI, /* 0x32 50. '2' */ + _ACPI_XD|_ACPI_DI, /* 0x33 51. '3' */ + _ACPI_XD|_ACPI_DI, /* 0x34 52. '4' */ + _ACPI_XD|_ACPI_DI, /* 0x35 53. '5' */ + _ACPI_XD|_ACPI_DI, /* 0x36 54. '6' */ + _ACPI_XD|_ACPI_DI, /* 0x37 55. '7' */ + _ACPI_XD|_ACPI_DI, /* 0x38 56. '8' */ + _ACPI_XD|_ACPI_DI, /* 0x39 57. '9' */ + _ACPI_PU, /* 0x3A 58. ':' */ + _ACPI_PU, /* 0x3B 59. ';' */ + _ACPI_PU, /* 0x3C 60. '<' */ + _ACPI_PU, /* 0x3D 61. '=' */ + _ACPI_PU, /* 0x3E 62. '>' */ + _ACPI_PU, /* 0x3F 63. '?' */ + _ACPI_PU, /* 0x40 64. '@' */ + _ACPI_XD|_ACPI_UP, /* 0x41 65. 'A' */ + _ACPI_XD|_ACPI_UP, /* 0x42 66. 'B' */ + _ACPI_XD|_ACPI_UP, /* 0x43 67. 'C' */ + _ACPI_XD|_ACPI_UP, /* 0x44 68. 'D' */ + _ACPI_XD|_ACPI_UP, /* 0x45 69. 'E' */ + _ACPI_XD|_ACPI_UP, /* 0x46 70. 'F' */ + _ACPI_UP, /* 0x47 71. 'G' */ + _ACPI_UP, /* 0x48 72. 'H' */ + _ACPI_UP, /* 0x49 73. 'I' */ + _ACPI_UP, /* 0x4A 74. 'J' */ + _ACPI_UP, /* 0x4B 75. 'K' */ + _ACPI_UP, /* 0x4C 76. 'L' */ + _ACPI_UP, /* 0x4D 77. 'M' */ + _ACPI_UP, /* 0x4E 78. 'N' */ + _ACPI_UP, /* 0x4F 79. 'O' */ + _ACPI_UP, /* 0x50 80. 'P' */ + _ACPI_UP, /* 0x51 81. 'Q' */ + _ACPI_UP, /* 0x52 82. 'R' */ + _ACPI_UP, /* 0x53 83. 'S' */ + _ACPI_UP, /* 0x54 84. 'T' */ + _ACPI_UP, /* 0x55 85. 'U' */ + _ACPI_UP, /* 0x56 86. 'V' */ + _ACPI_UP, /* 0x57 87. 'W' */ + _ACPI_UP, /* 0x58 88. 'X' */ + _ACPI_UP, /* 0x59 89. 'Y' */ + _ACPI_UP, /* 0x5A 90. 'Z' */ + _ACPI_PU, /* 0x5B 91. '[' */ + _ACPI_PU, /* 0x5C 92. '\' */ + _ACPI_PU, /* 0x5D 93. ']' */ + _ACPI_PU, /* 0x5E 94. '^' */ + _ACPI_PU, /* 0x5F 95. '_' */ + _ACPI_PU, /* 0x60 96. '`' */ + _ACPI_XD|_ACPI_LO, /* 0x61 97. 'a' */ + _ACPI_XD|_ACPI_LO, /* 0x62 98. 'b' */ + _ACPI_XD|_ACPI_LO, /* 0x63 99. 'c' */ + _ACPI_XD|_ACPI_LO, /* 0x64 100. 'd' */ + _ACPI_XD|_ACPI_LO, /* 0x65 101. 'e' */ + _ACPI_XD|_ACPI_LO, /* 0x66 102. 'f' */ + _ACPI_LO, /* 0x67 103. 'g' */ + _ACPI_LO, /* 0x68 104. 'h' */ + _ACPI_LO, /* 0x69 105. 'i' */ + _ACPI_LO, /* 0x6A 106. 'j' */ + _ACPI_LO, /* 0x6B 107. 'k' */ + _ACPI_LO, /* 0x6C 108. 'l' */ + _ACPI_LO, /* 0x6D 109. 'm' */ + _ACPI_LO, /* 0x6E 110. 'n' */ + _ACPI_LO, /* 0x6F 111. 'o' */ + _ACPI_LO, /* 0x70 112. 'p' */ + _ACPI_LO, /* 0x71 113. 'q' */ + _ACPI_LO, /* 0x72 114. 'r' */ + _ACPI_LO, /* 0x73 115. 's' */ + _ACPI_LO, /* 0x74 116. 't' */ + _ACPI_LO, /* 0x75 117. 'u' */ + _ACPI_LO, /* 0x76 118. 'v' */ + _ACPI_LO, /* 0x77 119. 'w' */ + _ACPI_LO, /* 0x78 120. 'x' */ + _ACPI_LO, /* 0x79 121. 'y' */ + _ACPI_LO, /* 0x7A 122. 'z' */ + _ACPI_PU, /* 0x7B 123. '{' */ + _ACPI_PU, /* 0x7C 124. '|' */ + _ACPI_PU, /* 0x7D 125. '}' */ + _ACPI_PU, /* 0x7E 126. '~' */ + _ACPI_CN, /* 0x7F 127. */ + + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x80 to 0x8F */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x90 to 0x9F */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xA0 to 0xAF */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xB0 to 0xBF */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xC0 to 0xCF */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xD0 to 0xDF */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0xE0 to 0xEF */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* 0xF0 to 0x100 */ +}; + + +#endif /* ACPI_USE_SYSTEM_CLIBRARY */ + diff --git a/reactos/drivers/bus/acpi/acpica/utilities/utcopy.c b/reactos/drivers/bus/acpi/acpica/utilities/utcopy.c new file mode 100644 index 00000000000..5423eff9dec --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/utilities/utcopy.c @@ -0,0 +1,1142 @@ +/****************************************************************************** + * + * Module Name: utcopy - Internal to external object translation utilities + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __UTCOPY_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utcopy") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiUtCopyIsimpleToEsimple ( + ACPI_OPERAND_OBJECT *InternalObject, + ACPI_OBJECT *ExternalObject, + UINT8 *DataSpace, + ACPI_SIZE *BufferSpaceUsed); + +static ACPI_STATUS +AcpiUtCopyIelementToIelement ( + UINT8 ObjectType, + ACPI_OPERAND_OBJECT *SourceObject, + ACPI_GENERIC_STATE *State, + void *Context); + +static ACPI_STATUS +AcpiUtCopyIpackageToEpackage ( + ACPI_OPERAND_OBJECT *InternalObject, + UINT8 *Buffer, + ACPI_SIZE *SpaceUsed); + +static ACPI_STATUS +AcpiUtCopyEsimpleToIsimple( + ACPI_OBJECT *UserObj, + ACPI_OPERAND_OBJECT **ReturnObj); + +static ACPI_STATUS +AcpiUtCopyEpackageToIpackage ( + ACPI_OBJECT *ExternalObject, + ACPI_OPERAND_OBJECT **InternalObject); + +static ACPI_STATUS +AcpiUtCopySimpleObject ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT *DestDesc); + +static ACPI_STATUS +AcpiUtCopyIelementToEelement ( + UINT8 ObjectType, + ACPI_OPERAND_OBJECT *SourceObject, + ACPI_GENERIC_STATE *State, + void *Context); + +static ACPI_STATUS +AcpiUtCopyIpackageToIpackage ( + ACPI_OPERAND_OBJECT *SourceObj, + ACPI_OPERAND_OBJECT *DestObj, + ACPI_WALK_STATE *WalkState); + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCopyIsimpleToEsimple + * + * PARAMETERS: InternalObject - Source object to be copied + * ExternalObject - Where to return the copied object + * DataSpace - Where object data is returned (such as + * buffer and string data) + * BufferSpaceUsed - Length of DataSpace that was used + * + * RETURN: Status + * + * DESCRIPTION: This function is called to copy a simple internal object to + * an external object. + * + * The DataSpace buffer is assumed to have sufficient space for + * the object. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtCopyIsimpleToEsimple ( + ACPI_OPERAND_OBJECT *InternalObject, + ACPI_OBJECT *ExternalObject, + UINT8 *DataSpace, + ACPI_SIZE *BufferSpaceUsed) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (UtCopyIsimpleToEsimple); + + + *BufferSpaceUsed = 0; + + /* + * Check for NULL object case (could be an uninitialized + * package element) + */ + if (!InternalObject) + { + return_ACPI_STATUS (AE_OK); + } + + /* Always clear the external object */ + + ACPI_MEMSET (ExternalObject, 0, sizeof (ACPI_OBJECT)); + + /* + * In general, the external object will be the same type as + * the internal object + */ + ExternalObject->Type = InternalObject->Common.Type; + + /* However, only a limited number of external types are supported */ + + switch (InternalObject->Common.Type) + { + case ACPI_TYPE_STRING: + + ExternalObject->String.Pointer = (char *) DataSpace; + ExternalObject->String.Length = InternalObject->String.Length; + *BufferSpaceUsed = ACPI_ROUND_UP_TO_NATIVE_WORD ( + (ACPI_SIZE) InternalObject->String.Length + 1); + + ACPI_MEMCPY ((void *) DataSpace, + (void *) InternalObject->String.Pointer, + (ACPI_SIZE) InternalObject->String.Length + 1); + break; + + + case ACPI_TYPE_BUFFER: + + ExternalObject->Buffer.Pointer = DataSpace; + ExternalObject->Buffer.Length = InternalObject->Buffer.Length; + *BufferSpaceUsed = ACPI_ROUND_UP_TO_NATIVE_WORD ( + InternalObject->String.Length); + + ACPI_MEMCPY ((void *) DataSpace, + (void *) InternalObject->Buffer.Pointer, + InternalObject->Buffer.Length); + break; + + + case ACPI_TYPE_INTEGER: + + ExternalObject->Integer.Value = InternalObject->Integer.Value; + break; + + + case ACPI_TYPE_LOCAL_REFERENCE: + + /* This is an object reference. */ + + switch (InternalObject->Reference.Class) + { + case ACPI_REFCLASS_NAME: + + /* + * For namepath, return the object handle ("reference") + * We are referring to the namespace node + */ + ExternalObject->Reference.Handle = + InternalObject->Reference.Node; + ExternalObject->Reference.ActualType = + AcpiNsGetType (InternalObject->Reference.Node); + break; + + default: + + /* All other reference types are unsupported */ + + return_ACPI_STATUS (AE_TYPE); + } + break; + + + case ACPI_TYPE_PROCESSOR: + + ExternalObject->Processor.ProcId = + InternalObject->Processor.ProcId; + ExternalObject->Processor.PblkAddress = + InternalObject->Processor.Address; + ExternalObject->Processor.PblkLength = + InternalObject->Processor.Length; + break; + + + case ACPI_TYPE_POWER: + + ExternalObject->PowerResource.SystemLevel = + InternalObject->PowerResource.SystemLevel; + + ExternalObject->PowerResource.ResourceOrder = + InternalObject->PowerResource.ResourceOrder; + break; + + + default: + /* + * There is no corresponding external object type + */ + ACPI_ERROR ((AE_INFO, + "Unsupported object type, cannot convert to external object: %s", + AcpiUtGetTypeName (InternalObject->Common.Type))); + + return_ACPI_STATUS (AE_SUPPORT); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCopyIelementToEelement + * + * PARAMETERS: ACPI_PKG_CALLBACK + * + * RETURN: Status + * + * DESCRIPTION: Copy one package element to another package element + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtCopyIelementToEelement ( + UINT8 ObjectType, + ACPI_OPERAND_OBJECT *SourceObject, + ACPI_GENERIC_STATE *State, + void *Context) +{ + ACPI_STATUS Status = AE_OK; + ACPI_PKG_INFO *Info = (ACPI_PKG_INFO *) Context; + ACPI_SIZE ObjectSpace; + UINT32 ThisIndex; + ACPI_OBJECT *TargetObject; + + + ACPI_FUNCTION_ENTRY (); + + + ThisIndex = State->Pkg.Index; + TargetObject = (ACPI_OBJECT *) + &((ACPI_OBJECT *)(State->Pkg.DestObject))->Package.Elements[ThisIndex]; + + switch (ObjectType) + { + case ACPI_COPY_TYPE_SIMPLE: + + /* + * This is a simple or null object + */ + Status = AcpiUtCopyIsimpleToEsimple (SourceObject, + TargetObject, Info->FreeSpace, &ObjectSpace); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + break; + + + case ACPI_COPY_TYPE_PACKAGE: + + /* + * Build the package object + */ + TargetObject->Type = ACPI_TYPE_PACKAGE; + TargetObject->Package.Count = SourceObject->Package.Count; + TargetObject->Package.Elements = + ACPI_CAST_PTR (ACPI_OBJECT, Info->FreeSpace); + + /* + * Pass the new package object back to the package walk routine + */ + State->Pkg.ThisTargetObj = TargetObject; + + /* + * Save space for the array of objects (Package elements) + * update the buffer length counter + */ + ObjectSpace = ACPI_ROUND_UP_TO_NATIVE_WORD ( + (ACPI_SIZE) TargetObject->Package.Count * + sizeof (ACPI_OBJECT)); + break; + + + default: + return (AE_BAD_PARAMETER); + } + + Info->FreeSpace += ObjectSpace; + Info->Length += ObjectSpace; + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCopyIpackageToEpackage + * + * PARAMETERS: InternalObject - Pointer to the object we are returning + * Buffer - Where the object is returned + * SpaceUsed - Where the object length is returned + * + * RETURN: Status + * + * DESCRIPTION: This function is called to place a package object in a user + * buffer. A package object by definition contains other objects. + * + * The buffer is assumed to have sufficient space for the object. + * The caller must have verified the buffer length needed using + * the AcpiUtGetObjectSize function before calling this function. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtCopyIpackageToEpackage ( + ACPI_OPERAND_OBJECT *InternalObject, + UINT8 *Buffer, + ACPI_SIZE *SpaceUsed) +{ + ACPI_OBJECT *ExternalObject; + ACPI_STATUS Status; + ACPI_PKG_INFO Info; + + + ACPI_FUNCTION_TRACE (UtCopyIpackageToEpackage); + + + /* + * First package at head of the buffer + */ + ExternalObject = ACPI_CAST_PTR (ACPI_OBJECT, Buffer); + + /* + * Free space begins right after the first package + */ + Info.Length = ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)); + Info.FreeSpace = Buffer + ACPI_ROUND_UP_TO_NATIVE_WORD ( + sizeof (ACPI_OBJECT)); + Info.ObjectSpace = 0; + Info.NumPackages = 1; + + ExternalObject->Type = InternalObject->Common.Type; + ExternalObject->Package.Count = InternalObject->Package.Count; + ExternalObject->Package.Elements = ACPI_CAST_PTR (ACPI_OBJECT, + Info.FreeSpace); + + /* + * Leave room for an array of ACPI_OBJECTS in the buffer + * and move the free space past it + */ + Info.Length += (ACPI_SIZE) ExternalObject->Package.Count * + ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)); + Info.FreeSpace += ExternalObject->Package.Count * + ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)); + + Status = AcpiUtWalkPackageTree (InternalObject, ExternalObject, + AcpiUtCopyIelementToEelement, &Info); + + *SpaceUsed = Info.Length; + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCopyIobjectToEobject + * + * PARAMETERS: InternalObject - The internal object to be converted + * RetBuffer - Where the object is returned + * + * RETURN: Status + * + * DESCRIPTION: This function is called to build an API object to be returned + * to the caller. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtCopyIobjectToEobject ( + ACPI_OPERAND_OBJECT *InternalObject, + ACPI_BUFFER *RetBuffer) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (UtCopyIobjectToEobject); + + + if (InternalObject->Common.Type == ACPI_TYPE_PACKAGE) + { + /* + * Package object: Copy all subobjects (including + * nested packages) + */ + Status = AcpiUtCopyIpackageToEpackage (InternalObject, + RetBuffer->Pointer, &RetBuffer->Length); + } + else + { + /* + * Build a simple object (no nested objects) + */ + Status = AcpiUtCopyIsimpleToEsimple (InternalObject, + ACPI_CAST_PTR (ACPI_OBJECT, RetBuffer->Pointer), + ACPI_ADD_PTR (UINT8, RetBuffer->Pointer, + ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT))), + &RetBuffer->Length); + /* + * build simple does not include the object size in the length + * so we add it in here + */ + RetBuffer->Length += sizeof (ACPI_OBJECT); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCopyEsimpleToIsimple + * + * PARAMETERS: ExternalObject - The external object to be converted + * RetInternalObject - Where the internal object is returned + * + * RETURN: Status + * + * DESCRIPTION: This function copies an external object to an internal one. + * NOTE: Pointers can be copied, we don't need to copy data. + * (The pointers have to be valid in our address space no matter + * what we do with them!) + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtCopyEsimpleToIsimple ( + ACPI_OBJECT *ExternalObject, + ACPI_OPERAND_OBJECT **RetInternalObject) +{ + ACPI_OPERAND_OBJECT *InternalObject; + + + ACPI_FUNCTION_TRACE (UtCopyEsimpleToIsimple); + + + /* + * Simple types supported are: String, Buffer, Integer + */ + switch (ExternalObject->Type) + { + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + case ACPI_TYPE_INTEGER: + case ACPI_TYPE_LOCAL_REFERENCE: + + InternalObject = AcpiUtCreateInternalObject ( + (UINT8) ExternalObject->Type); + if (!InternalObject) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + break; + + case ACPI_TYPE_ANY: /* This is the case for a NULL object */ + + *RetInternalObject = NULL; + return_ACPI_STATUS (AE_OK); + + default: + /* All other types are not supported */ + + ACPI_ERROR ((AE_INFO, + "Unsupported object type, cannot convert to internal object: %s", + AcpiUtGetTypeName (ExternalObject->Type))); + + return_ACPI_STATUS (AE_SUPPORT); + } + + + /* Must COPY string and buffer contents */ + + switch (ExternalObject->Type) + { + case ACPI_TYPE_STRING: + + InternalObject->String.Pointer = + ACPI_ALLOCATE_ZEROED ((ACPI_SIZE) + ExternalObject->String.Length + 1); + + if (!InternalObject->String.Pointer) + { + goto ErrorExit; + } + + ACPI_MEMCPY (InternalObject->String.Pointer, + ExternalObject->String.Pointer, + ExternalObject->String.Length); + + InternalObject->String.Length = ExternalObject->String.Length; + break; + + + case ACPI_TYPE_BUFFER: + + InternalObject->Buffer.Pointer = + ACPI_ALLOCATE_ZEROED (ExternalObject->Buffer.Length); + if (!InternalObject->Buffer.Pointer) + { + goto ErrorExit; + } + + ACPI_MEMCPY (InternalObject->Buffer.Pointer, + ExternalObject->Buffer.Pointer, + ExternalObject->Buffer.Length); + + InternalObject->Buffer.Length = ExternalObject->Buffer.Length; + + /* Mark buffer data valid */ + + InternalObject->Buffer.Flags |= AOPOBJ_DATA_VALID; + break; + + + case ACPI_TYPE_INTEGER: + + InternalObject->Integer.Value = ExternalObject->Integer.Value; + break; + + case ACPI_TYPE_LOCAL_REFERENCE: + + /* TBD: should validate incoming handle */ + + InternalObject->Reference.Class = ACPI_REFCLASS_NAME; + InternalObject->Reference.Node = ExternalObject->Reference.Handle; + break; + + default: + /* Other types can't get here */ + break; + } + + *RetInternalObject = InternalObject; + return_ACPI_STATUS (AE_OK); + + +ErrorExit: + AcpiUtRemoveReference (InternalObject); + return_ACPI_STATUS (AE_NO_MEMORY); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCopyEpackageToIpackage + * + * PARAMETERS: ExternalObject - The external object to be converted + * InternalObject - Where the internal object is returned + * + * RETURN: Status + * + * DESCRIPTION: Copy an external package object to an internal package. + * Handles nested packages. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtCopyEpackageToIpackage ( + ACPI_OBJECT *ExternalObject, + ACPI_OPERAND_OBJECT **InternalObject) +{ + ACPI_STATUS Status = AE_OK; + ACPI_OPERAND_OBJECT *PackageObject; + ACPI_OPERAND_OBJECT **PackageElements; + UINT32 i; + + + ACPI_FUNCTION_TRACE (UtCopyEpackageToIpackage); + + + /* Create the package object */ + + PackageObject = AcpiUtCreatePackageObject (ExternalObject->Package.Count); + if (!PackageObject) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + PackageElements = PackageObject->Package.Elements; + + /* + * Recursive implementation. Probably ok, since nested external packages + * as parameters should be very rare. + */ + for (i = 0; i < ExternalObject->Package.Count; i++) + { + Status = AcpiUtCopyEobjectToIobject ( + &ExternalObject->Package.Elements[i], + &PackageElements[i]); + if (ACPI_FAILURE (Status)) + { + /* Truncate package and delete it */ + + PackageObject->Package.Count = i; + PackageElements[i] = NULL; + AcpiUtRemoveReference (PackageObject); + return_ACPI_STATUS (Status); + } + } + + /* Mark package data valid */ + + PackageObject->Package.Flags |= AOPOBJ_DATA_VALID; + + *InternalObject = PackageObject; + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCopyEobjectToIobject + * + * PARAMETERS: ExternalObject - The external object to be converted + * InternalObject - Where the internal object is returned + * + * RETURN: Status + * + * DESCRIPTION: Converts an external object to an internal object. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtCopyEobjectToIobject ( + ACPI_OBJECT *ExternalObject, + ACPI_OPERAND_OBJECT **InternalObject) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (UtCopyEobjectToIobject); + + + if (ExternalObject->Type == ACPI_TYPE_PACKAGE) + { + Status = AcpiUtCopyEpackageToIpackage (ExternalObject, InternalObject); + } + else + { + /* + * Build a simple object (no nested objects) + */ + Status = AcpiUtCopyEsimpleToIsimple (ExternalObject, InternalObject); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCopySimpleObject + * + * PARAMETERS: SourceDesc - The internal object to be copied + * DestDesc - New target object + * + * RETURN: Status + * + * DESCRIPTION: Simple copy of one internal object to another. Reference count + * of the destination object is preserved. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtCopySimpleObject ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT *DestDesc) +{ + UINT16 ReferenceCount; + ACPI_OPERAND_OBJECT *NextObject; + ACPI_STATUS Status; + + + /* Save fields from destination that we don't want to overwrite */ + + ReferenceCount = DestDesc->Common.ReferenceCount; + NextObject = DestDesc->Common.NextObject; + + /* Copy the entire source object over the destination object*/ + + ACPI_MEMCPY ((char *) DestDesc, (char *) SourceDesc, + sizeof (ACPI_OPERAND_OBJECT)); + + /* Restore the saved fields */ + + DestDesc->Common.ReferenceCount = ReferenceCount; + DestDesc->Common.NextObject = NextObject; + + /* New object is not static, regardless of source */ + + DestDesc->Common.Flags &= ~AOPOBJ_STATIC_POINTER; + + /* Handle the objects with extra data */ + + switch (DestDesc->Common.Type) + { + case ACPI_TYPE_BUFFER: + /* + * Allocate and copy the actual buffer if and only if: + * 1) There is a valid buffer pointer + * 2) The buffer has a length > 0 + */ + if ((SourceDesc->Buffer.Pointer) && + (SourceDesc->Buffer.Length)) + { + DestDesc->Buffer.Pointer = + ACPI_ALLOCATE (SourceDesc->Buffer.Length); + if (!DestDesc->Buffer.Pointer) + { + return (AE_NO_MEMORY); + } + + /* Copy the actual buffer data */ + + ACPI_MEMCPY (DestDesc->Buffer.Pointer, + SourceDesc->Buffer.Pointer, + SourceDesc->Buffer.Length); + } + break; + + case ACPI_TYPE_STRING: + /* + * Allocate and copy the actual string if and only if: + * 1) There is a valid string pointer + * (Pointer to a NULL string is allowed) + */ + if (SourceDesc->String.Pointer) + { + DestDesc->String.Pointer = + ACPI_ALLOCATE ((ACPI_SIZE) SourceDesc->String.Length + 1); + if (!DestDesc->String.Pointer) + { + return (AE_NO_MEMORY); + } + + /* Copy the actual string data */ + + ACPI_MEMCPY (DestDesc->String.Pointer, SourceDesc->String.Pointer, + (ACPI_SIZE) SourceDesc->String.Length + 1); + } + break; + + case ACPI_TYPE_LOCAL_REFERENCE: + /* + * We copied the reference object, so we now must add a reference + * to the object pointed to by the reference + * + * DDBHandle reference (from Load/LoadTable) is a special reference, + * it does not have a Reference.Object, so does not need to + * increase the reference count + */ + if (SourceDesc->Reference.Class == ACPI_REFCLASS_TABLE) + { + break; + } + + AcpiUtAddReference (SourceDesc->Reference.Object); + break; + + case ACPI_TYPE_REGION: + /* + * We copied the Region Handler, so we now must add a reference + */ + if (DestDesc->Region.Handler) + { + AcpiUtAddReference (DestDesc->Region.Handler); + } + break; + + /* + * For Mutex and Event objects, we cannot simply copy the underlying + * OS object. We must create a new one. + */ + case ACPI_TYPE_MUTEX: + + Status = AcpiOsCreateMutex (&DestDesc->Mutex.OsMutex); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + break; + + case ACPI_TYPE_EVENT: + + Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 0, + &DestDesc->Event.OsSemaphore); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + break; + + default: + /* Nothing to do for other simple objects */ + break; + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCopyIelementToIelement + * + * PARAMETERS: ACPI_PKG_CALLBACK + * + * RETURN: Status + * + * DESCRIPTION: Copy one package element to another package element + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtCopyIelementToIelement ( + UINT8 ObjectType, + ACPI_OPERAND_OBJECT *SourceObject, + ACPI_GENERIC_STATE *State, + void *Context) +{ + ACPI_STATUS Status = AE_OK; + UINT32 ThisIndex; + ACPI_OPERAND_OBJECT **ThisTargetPtr; + ACPI_OPERAND_OBJECT *TargetObject; + + + ACPI_FUNCTION_ENTRY (); + + + ThisIndex = State->Pkg.Index; + ThisTargetPtr = (ACPI_OPERAND_OBJECT **) + &State->Pkg.DestObject->Package.Elements[ThisIndex]; + + switch (ObjectType) + { + case ACPI_COPY_TYPE_SIMPLE: + + /* A null source object indicates a (legal) null package element */ + + if (SourceObject) + { + /* + * This is a simple object, just copy it + */ + TargetObject = AcpiUtCreateInternalObject ( + SourceObject->Common.Type); + if (!TargetObject) + { + return (AE_NO_MEMORY); + } + + Status = AcpiUtCopySimpleObject (SourceObject, TargetObject); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + + *ThisTargetPtr = TargetObject; + } + else + { + /* Pass through a null element */ + + *ThisTargetPtr = NULL; + } + break; + + + case ACPI_COPY_TYPE_PACKAGE: + + /* + * This object is a package - go down another nesting level + * Create and build the package object + */ + TargetObject = AcpiUtCreatePackageObject (SourceObject->Package.Count); + if (!TargetObject) + { + return (AE_NO_MEMORY); + } + + TargetObject->Common.Flags = SourceObject->Common.Flags; + + /* Pass the new package object back to the package walk routine */ + + State->Pkg.ThisTargetObj = TargetObject; + + /* Store the object pointer in the parent package object */ + + *ThisTargetPtr = TargetObject; + break; + + + default: + return (AE_BAD_PARAMETER); + } + + return (Status); + +ErrorExit: + AcpiUtRemoveReference (TargetObject); + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCopyIpackageToIpackage + * + * PARAMETERS: SourceObj - Pointer to the source package object + * DestObj - Where the internal object is returned + * WalkState - Current Walk state descriptor + * + * RETURN: Status + * + * DESCRIPTION: This function is called to copy an internal package object + * into another internal package object. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtCopyIpackageToIpackage ( + ACPI_OPERAND_OBJECT *SourceObj, + ACPI_OPERAND_OBJECT *DestObj, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (UtCopyIpackageToIpackage); + + + DestObj->Common.Type = SourceObj->Common.Type; + DestObj->Common.Flags = SourceObj->Common.Flags; + DestObj->Package.Count = SourceObj->Package.Count; + + /* + * Create the object array and walk the source package tree + */ + DestObj->Package.Elements = ACPI_ALLOCATE_ZEROED ( + ((ACPI_SIZE) SourceObj->Package.Count + 1) * + sizeof (void *)); + if (!DestObj->Package.Elements) + { + ACPI_ERROR ((AE_INFO, "Package allocation failure")); + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* + * Copy the package element-by-element by walking the package "tree". + * This handles nested packages of arbitrary depth. + */ + Status = AcpiUtWalkPackageTree (SourceObj, DestObj, + AcpiUtCopyIelementToIelement, WalkState); + if (ACPI_FAILURE (Status)) + { + /* On failure, delete the destination package object */ + + AcpiUtRemoveReference (DestObj); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCopyIobjectToIobject + * + * PARAMETERS: SourceDesc - The internal object to be copied + * DestDesc - Where the copied object is returned + * WalkState - Current walk state + * + * RETURN: Status + * + * DESCRIPTION: Copy an internal object to a new internal object + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtCopyIobjectToIobject ( + ACPI_OPERAND_OBJECT *SourceDesc, + ACPI_OPERAND_OBJECT **DestDesc, + ACPI_WALK_STATE *WalkState) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (UtCopyIobjectToIobject); + + + /* Create the top level object */ + + *DestDesc = AcpiUtCreateInternalObject (SourceDesc->Common.Type); + if (!*DestDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Copy the object and possible subobjects */ + + if (SourceDesc->Common.Type == ACPI_TYPE_PACKAGE) + { + Status = AcpiUtCopyIpackageToIpackage (SourceDesc, *DestDesc, + WalkState); + } + else + { + Status = AcpiUtCopySimpleObject (SourceDesc, *DestDesc); + } + + return_ACPI_STATUS (Status); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/utilities/utdebug.c b/reactos/drivers/bus/acpi/acpica/utilities/utdebug.c new file mode 100644 index 00000000000..3901b07d197 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/utilities/utdebug.c @@ -0,0 +1,814 @@ +/****************************************************************************** + * + * Module Name: utdebug - Debug print routines + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __UTDEBUG_C__ + +#include "acpi.h" +#include "accommon.h" + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utdebug") + + +#ifdef ACPI_DEBUG_OUTPUT + +static ACPI_THREAD_ID AcpiGbl_PrevThreadId = (ACPI_THREAD_ID) 0xFFFFFFFF; +static char *AcpiGbl_FnEntryStr = "----Entry"; +static char *AcpiGbl_FnExitStr = "----Exit-"; + +/* Local prototypes */ + +static const char * +AcpiUtTrimFunctionName ( + const char *FunctionName); + + +/******************************************************************************* + * + * FUNCTION: AcpiUtInitStackPtrTrace + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Save the current CPU stack pointer at subsystem startup + * + ******************************************************************************/ + +void +AcpiUtInitStackPtrTrace ( + void) +{ + ACPI_SIZE CurrentSp; + + + AcpiGbl_EntryStackPointer = &CurrentSp; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtTrackStackPtr + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Save the current CPU stack pointer + * + ******************************************************************************/ + +void +AcpiUtTrackStackPtr ( + void) +{ + ACPI_SIZE CurrentSp; + + + if (&CurrentSp < AcpiGbl_LowestStackPointer) + { + AcpiGbl_LowestStackPointer = &CurrentSp; + } + + if (AcpiGbl_NestingLevel > AcpiGbl_DeepestNesting) + { + AcpiGbl_DeepestNesting = AcpiGbl_NestingLevel; + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtTrimFunctionName + * + * PARAMETERS: FunctionName - Ascii string containing a procedure name + * + * RETURN: Updated pointer to the function name + * + * DESCRIPTION: Remove the "Acpi" prefix from the function name, if present. + * This allows compiler macros such as __FUNCTION__ to be used + * with no change to the debug output. + * + ******************************************************************************/ + +static const char * +AcpiUtTrimFunctionName ( + const char *FunctionName) +{ + + /* All Function names are longer than 4 chars, check is safe */ + + if (*(ACPI_CAST_PTR (UINT32, FunctionName)) == ACPI_PREFIX_MIXED) + { + /* This is the case where the original source has not been modified */ + + return (FunctionName + 4); + } + + if (*(ACPI_CAST_PTR (UINT32, FunctionName)) == ACPI_PREFIX_LOWER) + { + /* This is the case where the source has been 'linuxized' */ + + return (FunctionName + 5); + } + + return (FunctionName); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiDebugPrint + * + * PARAMETERS: RequestedDebugLevel - Requested debug print level + * LineNumber - Caller's line number (for error output) + * FunctionName - Caller's procedure name + * ModuleName - Caller's module name + * ComponentId - Caller's component ID + * Format - Printf format field + * ... - Optional printf arguments + * + * RETURN: None + * + * DESCRIPTION: Print error message with prefix consisting of the module name, + * line number, and component ID. + * + ******************************************************************************/ + +void ACPI_INTERNAL_VAR_XFACE +AcpiDebugPrint ( + UINT32 RequestedDebugLevel, + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId, + const char *Format, + ...) +{ + ACPI_THREAD_ID ThreadId; + va_list args; + + + /* + * Stay silent if the debug level or component ID is disabled + */ + if (!(RequestedDebugLevel & AcpiDbgLevel) || + !(ComponentId & AcpiDbgLayer)) + { + return; + } + + /* + * Thread tracking and context switch notification + */ + ThreadId = AcpiOsGetThreadId (); + if (ThreadId != AcpiGbl_PrevThreadId) + { + if (ACPI_LV_THREADS & AcpiDbgLevel) + { + AcpiOsPrintf ( + "\n**** Context Switch from TID %p to TID %p ****\n\n", + ACPI_CAST_PTR (void, AcpiGbl_PrevThreadId), + ACPI_CAST_PTR (void, ThreadId)); + } + + AcpiGbl_PrevThreadId = ThreadId; + } + + /* + * Display the module name, current line number, thread ID (if requested), + * current procedure nesting level, and the current procedure name + */ + AcpiOsPrintf ("%8s-%04ld ", ModuleName, LineNumber); + + if (ACPI_LV_THREADS & AcpiDbgLevel) + { + AcpiOsPrintf ("[%p] ", ACPI_CAST_PTR (void, ThreadId)); + } + + AcpiOsPrintf ("[%02ld] %-22.22s: ", + AcpiGbl_NestingLevel, AcpiUtTrimFunctionName (FunctionName)); + + va_start (args, Format); + AcpiOsVprintf (Format, args); + va_end (args); +} + +ACPI_EXPORT_SYMBOL (AcpiDebugPrint) + + +/******************************************************************************* + * + * FUNCTION: AcpiDebugPrintRaw + * + * PARAMETERS: RequestedDebugLevel - Requested debug print level + * LineNumber - Caller's line number + * FunctionName - Caller's procedure name + * ModuleName - Caller's module name + * ComponentId - Caller's component ID + * Format - Printf format field + * ... - Optional printf arguments + * + * RETURN: None + * + * DESCRIPTION: Print message with no headers. Has same interface as + * DebugPrint so that the same macros can be used. + * + ******************************************************************************/ + +void ACPI_INTERNAL_VAR_XFACE +AcpiDebugPrintRaw ( + UINT32 RequestedDebugLevel, + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId, + const char *Format, + ...) +{ + va_list args; + + + if (!(RequestedDebugLevel & AcpiDbgLevel) || + !(ComponentId & AcpiDbgLayer)) + { + return; + } + + va_start (args, Format); + AcpiOsVprintf (Format, args); + va_end (args); +} + +ACPI_EXPORT_SYMBOL (AcpiDebugPrintRaw) + + +/******************************************************************************* + * + * FUNCTION: AcpiUtTrace + * + * PARAMETERS: LineNumber - Caller's line number + * FunctionName - Caller's procedure name + * ModuleName - Caller's module name + * ComponentId - Caller's component ID + * + * RETURN: None + * + * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is + * set in DebugLevel + * + ******************************************************************************/ + +void +AcpiUtTrace ( + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId) +{ + + AcpiGbl_NestingLevel++; + AcpiUtTrackStackPtr (); + + AcpiDebugPrint (ACPI_LV_FUNCTIONS, + LineNumber, FunctionName, ModuleName, ComponentId, + "%s\n", AcpiGbl_FnEntryStr); +} + +ACPI_EXPORT_SYMBOL (AcpiUtTrace) + + +/******************************************************************************* + * + * FUNCTION: AcpiUtTracePtr + * + * PARAMETERS: LineNumber - Caller's line number + * FunctionName - Caller's procedure name + * ModuleName - Caller's module name + * ComponentId - Caller's component ID + * Pointer - Pointer to display + * + * RETURN: None + * + * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is + * set in DebugLevel + * + ******************************************************************************/ + +void +AcpiUtTracePtr ( + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId, + void *Pointer) +{ + AcpiGbl_NestingLevel++; + AcpiUtTrackStackPtr (); + + AcpiDebugPrint (ACPI_LV_FUNCTIONS, + LineNumber, FunctionName, ModuleName, ComponentId, + "%s %p\n", AcpiGbl_FnEntryStr, Pointer); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtTraceStr + * + * PARAMETERS: LineNumber - Caller's line number + * FunctionName - Caller's procedure name + * ModuleName - Caller's module name + * ComponentId - Caller's component ID + * String - Additional string to display + * + * RETURN: None + * + * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is + * set in DebugLevel + * + ******************************************************************************/ + +void +AcpiUtTraceStr ( + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId, + char *String) +{ + + AcpiGbl_NestingLevel++; + AcpiUtTrackStackPtr (); + + AcpiDebugPrint (ACPI_LV_FUNCTIONS, + LineNumber, FunctionName, ModuleName, ComponentId, + "%s %s\n", AcpiGbl_FnEntryStr, String); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtTraceU32 + * + * PARAMETERS: LineNumber - Caller's line number + * FunctionName - Caller's procedure name + * ModuleName - Caller's module name + * ComponentId - Caller's component ID + * Integer - Integer to display + * + * RETURN: None + * + * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is + * set in DebugLevel + * + ******************************************************************************/ + +void +AcpiUtTraceU32 ( + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId, + UINT32 Integer) +{ + + AcpiGbl_NestingLevel++; + AcpiUtTrackStackPtr (); + + AcpiDebugPrint (ACPI_LV_FUNCTIONS, + LineNumber, FunctionName, ModuleName, ComponentId, + "%s %08X\n", AcpiGbl_FnEntryStr, Integer); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtExit + * + * PARAMETERS: LineNumber - Caller's line number + * FunctionName - Caller's procedure name + * ModuleName - Caller's module name + * ComponentId - Caller's component ID + * + * RETURN: None + * + * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is + * set in DebugLevel + * + ******************************************************************************/ + +void +AcpiUtExit ( + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId) +{ + + AcpiDebugPrint (ACPI_LV_FUNCTIONS, + LineNumber, FunctionName, ModuleName, ComponentId, + "%s\n", AcpiGbl_FnExitStr); + + AcpiGbl_NestingLevel--; +} + +ACPI_EXPORT_SYMBOL (AcpiUtExit) + + +/******************************************************************************* + * + * FUNCTION: AcpiUtStatusExit + * + * PARAMETERS: LineNumber - Caller's line number + * FunctionName - Caller's procedure name + * ModuleName - Caller's module name + * ComponentId - Caller's component ID + * Status - Exit status code + * + * RETURN: None + * + * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is + * set in DebugLevel. Prints exit status also. + * + ******************************************************************************/ + +void +AcpiUtStatusExit ( + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId, + ACPI_STATUS Status) +{ + + if (ACPI_SUCCESS (Status)) + { + AcpiDebugPrint (ACPI_LV_FUNCTIONS, + LineNumber, FunctionName, ModuleName, ComponentId, + "%s %s\n", AcpiGbl_FnExitStr, + AcpiFormatException (Status)); + } + else + { + AcpiDebugPrint (ACPI_LV_FUNCTIONS, + LineNumber, FunctionName, ModuleName, ComponentId, + "%s ****Exception****: %s\n", AcpiGbl_FnExitStr, + AcpiFormatException (Status)); + } + + AcpiGbl_NestingLevel--; +} + +ACPI_EXPORT_SYMBOL (AcpiUtStatusExit) + + +/******************************************************************************* + * + * FUNCTION: AcpiUtValueExit + * + * PARAMETERS: LineNumber - Caller's line number + * FunctionName - Caller's procedure name + * ModuleName - Caller's module name + * ComponentId - Caller's component ID + * Value - Value to be printed with exit msg + * + * RETURN: None + * + * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is + * set in DebugLevel. Prints exit value also. + * + ******************************************************************************/ + +void +AcpiUtValueExit ( + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId, + ACPI_INTEGER Value) +{ + + AcpiDebugPrint (ACPI_LV_FUNCTIONS, + LineNumber, FunctionName, ModuleName, ComponentId, + "%s %8.8X%8.8X\n", AcpiGbl_FnExitStr, + ACPI_FORMAT_UINT64 (Value)); + + AcpiGbl_NestingLevel--; +} + +ACPI_EXPORT_SYMBOL (AcpiUtValueExit) + + +/******************************************************************************* + * + * FUNCTION: AcpiUtPtrExit + * + * PARAMETERS: LineNumber - Caller's line number + * FunctionName - Caller's procedure name + * ModuleName - Caller's module name + * ComponentId - Caller's component ID + * Ptr - Pointer to display + * + * RETURN: None + * + * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is + * set in DebugLevel. Prints exit value also. + * + ******************************************************************************/ + +void +AcpiUtPtrExit ( + UINT32 LineNumber, + const char *FunctionName, + const char *ModuleName, + UINT32 ComponentId, + UINT8 *Ptr) +{ + + AcpiDebugPrint (ACPI_LV_FUNCTIONS, + LineNumber, FunctionName, ModuleName, ComponentId, + "%s %p\n", AcpiGbl_FnExitStr, Ptr); + + AcpiGbl_NestingLevel--; +} + +#endif + + +/******************************************************************************* + * + * FUNCTION: AcpiUtDumpBuffer + * + * PARAMETERS: Buffer - Buffer to dump + * Count - Amount to dump, in bytes + * Display - BYTE, WORD, DWORD, or QWORD display + * ComponentID - Caller's component ID + * + * RETURN: None + * + * DESCRIPTION: Generic dump buffer in both hex and ascii. + * + ******************************************************************************/ + +void +AcpiUtDumpBuffer2 ( + UINT8 *Buffer, + UINT32 Count, + UINT32 Display) +{ + UINT32 i = 0; + UINT32 j; + UINT32 Temp32; + UINT8 BufChar; + + + if (!Buffer) + { + AcpiOsPrintf ("Null Buffer Pointer in DumpBuffer!\n"); + return; + } + + if ((Count < 4) || (Count & 0x01)) + { + Display = DB_BYTE_DISPLAY; + } + + /* Nasty little dump buffer routine! */ + + while (i < Count) + { + /* Print current offset */ + + AcpiOsPrintf ("%6.4X: ", i); + + /* Print 16 hex chars */ + + for (j = 0; j < 16;) + { + if (i + j >= Count) + { + /* Dump fill spaces */ + + AcpiOsPrintf ("%*s", ((Display * 2) + 1), " "); + j += Display; + continue; + } + + switch (Display) + { + case DB_BYTE_DISPLAY: + default: /* Default is BYTE display */ + + AcpiOsPrintf ("%02X ", Buffer[(ACPI_SIZE) i + j]); + break; + + + case DB_WORD_DISPLAY: + + ACPI_MOVE_16_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j]); + AcpiOsPrintf ("%04X ", Temp32); + break; + + + case DB_DWORD_DISPLAY: + + ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j]); + AcpiOsPrintf ("%08X ", Temp32); + break; + + + case DB_QWORD_DISPLAY: + + ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j]); + AcpiOsPrintf ("%08X", Temp32); + + ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j + 4]); + AcpiOsPrintf ("%08X ", Temp32); + break; + } + + j += Display; + } + + /* + * Print the ASCII equivalent characters but watch out for the bad + * unprintable ones (printable chars are 0x20 through 0x7E) + */ + AcpiOsPrintf (" "); + for (j = 0; j < 16; j++) + { + if (i + j >= Count) + { + AcpiOsPrintf ("\n"); + return; + } + + BufChar = Buffer[(ACPI_SIZE) i + j]; + if (ACPI_IS_PRINT (BufChar)) + { + AcpiOsPrintf ("%c", BufChar); + } + else + { + AcpiOsPrintf ("."); + } + } + + /* Done with that line. */ + + AcpiOsPrintf ("\n"); + i += 16; + } + + return; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtDumpBuffer + * + * PARAMETERS: Buffer - Buffer to dump + * Count - Amount to dump, in bytes + * Display - BYTE, WORD, DWORD, or QWORD display + * ComponentID - Caller's component ID + * + * RETURN: None + * + * DESCRIPTION: Generic dump buffer in both hex and ascii. + * + ******************************************************************************/ + +void +AcpiUtDumpBuffer ( + UINT8 *Buffer, + UINT32 Count, + UINT32 Display, + UINT32 ComponentId) +{ + + /* Only dump the buffer if tracing is enabled */ + + if (!((ACPI_LV_TABLES & AcpiDbgLevel) && + (ComponentId & AcpiDbgLayer))) + { + return; + } + + AcpiUtDumpBuffer2 (Buffer, Count, Display); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/utilities/utdelete.c b/reactos/drivers/bus/acpi/acpica/utilities/utdelete.c new file mode 100644 index 00000000000..bf30aee74e0 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/utilities/utdelete.c @@ -0,0 +1,828 @@ +/******************************************************************************* + * + * Module Name: utdelete - object deletion and reference count utilities + * + ******************************************************************************/ + +/****************************************************************************** + * + * 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 __UTDELETE_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" +#include "acnamesp.h" +#include "acevents.h" + + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utdelete") + +/* Local prototypes */ + +static void +AcpiUtDeleteInternalObj ( + ACPI_OPERAND_OBJECT *Object); + +static void +AcpiUtUpdateRefCount ( + ACPI_OPERAND_OBJECT *Object, + UINT32 Action); + + +/******************************************************************************* + * + * FUNCTION: AcpiUtDeleteInternalObj + * + * PARAMETERS: Object - Object to be deleted + * + * RETURN: None + * + * DESCRIPTION: Low level object deletion, after reference counts have been + * updated (All reference counts, including sub-objects!) + * + ******************************************************************************/ + +static void +AcpiUtDeleteInternalObj ( + ACPI_OPERAND_OBJECT *Object) +{ + void *ObjPointer = NULL; + ACPI_OPERAND_OBJECT *HandlerDesc; + ACPI_OPERAND_OBJECT *SecondDesc; + ACPI_OPERAND_OBJECT *NextDesc; + ACPI_OPERAND_OBJECT **LastObjPtr; + + + ACPI_FUNCTION_TRACE_PTR (UtDeleteInternalObj, Object); + + + if (!Object) + { + return_VOID; + } + + /* + * Must delete or free any pointers within the object that are not + * actual ACPI objects (for example, a raw buffer pointer). + */ + switch (Object->Common.Type) + { + case ACPI_TYPE_STRING: + + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "**** String %p, ptr %p\n", + Object, Object->String.Pointer)); + + /* Free the actual string buffer */ + + if (!(Object->Common.Flags & AOPOBJ_STATIC_POINTER)) + { + /* But only if it is NOT a pointer into an ACPI table */ + + ObjPointer = Object->String.Pointer; + } + break; + + + case ACPI_TYPE_BUFFER: + + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "**** Buffer %p, ptr %p\n", + Object, Object->Buffer.Pointer)); + + /* Free the actual buffer */ + + if (!(Object->Common.Flags & AOPOBJ_STATIC_POINTER)) + { + /* But only if it is NOT a pointer into an ACPI table */ + + ObjPointer = Object->Buffer.Pointer; + } + break; + + + case ACPI_TYPE_PACKAGE: + + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, " **** Package of count %X\n", + Object->Package.Count)); + + /* + * Elements of the package are not handled here, they are deleted + * separately + */ + + /* Free the (variable length) element pointer array */ + + ObjPointer = Object->Package.Elements; + break; + + + /* + * These objects have a possible list of notify handlers. + * Device object also may have a GPE block. + */ + case ACPI_TYPE_DEVICE: + + if (Object->Device.GpeBlock) + { + (void) AcpiEvDeleteGpeBlock (Object->Device.GpeBlock); + } + + /*lint -fallthrough */ + + case ACPI_TYPE_PROCESSOR: + case ACPI_TYPE_THERMAL: + + /* Walk the notify handler list for this object */ + + HandlerDesc = Object->CommonNotify.Handler; + while (HandlerDesc) + { + NextDesc = HandlerDesc->AddressSpace.Next; + AcpiUtRemoveReference (HandlerDesc); + HandlerDesc = NextDesc; + } + break; + + + case ACPI_TYPE_MUTEX: + + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "***** Mutex %p, OS Mutex %p\n", + Object, Object->Mutex.OsMutex)); + + if (Object == AcpiGbl_GlobalLockMutex) + { + /* Global Lock has extra semaphore */ + + (void) AcpiOsDeleteSemaphore (AcpiGbl_GlobalLockSemaphore); + AcpiGbl_GlobalLockSemaphore = NULL; + + AcpiOsDeleteMutex (Object->Mutex.OsMutex); + AcpiGbl_GlobalLockMutex = NULL; + } + else + { + AcpiExUnlinkMutex (Object); + AcpiOsDeleteMutex (Object->Mutex.OsMutex); + } + break; + + + case ACPI_TYPE_EVENT: + + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "***** Event %p, OS Semaphore %p\n", + Object, Object->Event.OsSemaphore)); + + (void) AcpiOsDeleteSemaphore (Object->Event.OsSemaphore); + Object->Event.OsSemaphore = NULL; + break; + + + case ACPI_TYPE_METHOD: + + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "***** Method %p\n", Object)); + + /* Delete the method mutex if it exists */ + + if (Object->Method.Mutex) + { + AcpiOsDeleteMutex (Object->Method.Mutex->Mutex.OsMutex); + AcpiUtDeleteObjectDesc (Object->Method.Mutex); + Object->Method.Mutex = NULL; + } + break; + + + case ACPI_TYPE_REGION: + + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "***** Region %p\n", Object)); + + SecondDesc = AcpiNsGetSecondaryObject (Object); + if (SecondDesc) + { + /* + * Free the RegionContext if and only if the handler is one of the + * default handlers -- and therefore, we created the context object + * locally, it was not created by an external caller. + */ + HandlerDesc = Object->Region.Handler; + if (HandlerDesc) + { + NextDesc = HandlerDesc->AddressSpace.RegionList; + LastObjPtr = &HandlerDesc->AddressSpace.RegionList; + + /* Remove the region object from the handler's list */ + + while (NextDesc) + { + if (NextDesc == Object) + { + *LastObjPtr = NextDesc->Region.Next; + break; + } + + /* Walk the linked list of handler */ + + LastObjPtr = &NextDesc->Region.Next; + NextDesc = NextDesc->Region.Next; + } + + if (HandlerDesc->AddressSpace.HandlerFlags & + ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) + { + /* Deactivate region and free region context */ + + if (HandlerDesc->AddressSpace.Setup) + { + (void) HandlerDesc->AddressSpace.Setup (Object, + ACPI_REGION_DEACTIVATE, + HandlerDesc->AddressSpace.Context, + &SecondDesc->Extra.RegionContext); + } + } + + AcpiUtRemoveReference (HandlerDesc); + } + + /* Now we can free the Extra object */ + + AcpiUtDeleteObjectDesc (SecondDesc); + } + break; + + + case ACPI_TYPE_BUFFER_FIELD: + + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "***** Buffer Field %p\n", Object)); + + SecondDesc = AcpiNsGetSecondaryObject (Object); + if (SecondDesc) + { + AcpiUtDeleteObjectDesc (SecondDesc); + } + break; + + + case ACPI_TYPE_LOCAL_BANK_FIELD: + + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "***** Bank Field %p\n", Object)); + + SecondDesc = AcpiNsGetSecondaryObject (Object); + if (SecondDesc) + { + AcpiUtDeleteObjectDesc (SecondDesc); + } + break; + + + default: + break; + } + + /* Free any allocated memory (pointer within the object) found above */ + + if (ObjPointer) + { + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Deleting Object Subptr %p\n", + ObjPointer)); + ACPI_FREE (ObjPointer); + } + + /* Now the object can be safely deleted */ + + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Deleting Object %p [%s]\n", + Object, AcpiUtGetObjectTypeName (Object))); + + AcpiUtDeleteObjectDesc (Object); + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtDeleteInternalObjectList + * + * PARAMETERS: ObjList - Pointer to the list to be deleted + * + * RETURN: None + * + * DESCRIPTION: This function deletes an internal object list, including both + * simple objects and package objects + * + ******************************************************************************/ + +void +AcpiUtDeleteInternalObjectList ( + ACPI_OPERAND_OBJECT **ObjList) +{ + ACPI_OPERAND_OBJECT **InternalObj; + + + ACPI_FUNCTION_TRACE (UtDeleteInternalObjectList); + + + /* Walk the null-terminated internal list */ + + for (InternalObj = ObjList; *InternalObj; InternalObj++) + { + AcpiUtRemoveReference (*InternalObj); + } + + /* Free the combined parameter pointer list and object array */ + + ACPI_FREE (ObjList); + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtUpdateRefCount + * + * PARAMETERS: Object - Object whose ref count is to be updated + * Action - What to do + * + * RETURN: New ref count + * + * DESCRIPTION: Modify the ref count and return it. + * + ******************************************************************************/ + +static void +AcpiUtUpdateRefCount ( + ACPI_OPERAND_OBJECT *Object, + UINT32 Action) +{ + UINT16 Count; + UINT16 NewCount; + + + ACPI_FUNCTION_NAME (UtUpdateRefCount); + + + if (!Object) + { + return; + } + + Count = Object->Common.ReferenceCount; + NewCount = Count; + + /* + * Perform the reference count action (increment, decrement, force delete) + */ + switch (Action) + { + case REF_INCREMENT: + + NewCount++; + Object->Common.ReferenceCount = NewCount; + + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "Obj %p Refs=%X, [Incremented]\n", + Object, NewCount)); + break; + + case REF_DECREMENT: + + if (Count < 1) + { + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "Obj %p Refs=%X, can't decrement! (Set to 0)\n", + Object, NewCount)); + + NewCount = 0; + } + else + { + NewCount--; + + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "Obj %p Refs=%X, [Decremented]\n", + Object, NewCount)); + } + + if (Object->Common.Type == ACPI_TYPE_METHOD) + { + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "Method Obj %p Refs=%X, [Decremented]\n", Object, NewCount)); + } + + Object->Common.ReferenceCount = NewCount; + if (NewCount == 0) + { + AcpiUtDeleteInternalObj (Object); + } + break; + + case REF_FORCE_DELETE: + + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "Obj %p Refs=%X, Force delete! (Set to 0)\n", Object, Count)); + + NewCount = 0; + Object->Common.ReferenceCount = NewCount; + AcpiUtDeleteInternalObj (Object); + break; + + default: + + ACPI_ERROR ((AE_INFO, "Unknown action (%X)", Action)); + break; + } + + /* + * Sanity check the reference count, for debug purposes only. + * (A deleted object will have a huge reference count) + */ + if (Count > ACPI_MAX_REFERENCE_COUNT) + { + ACPI_WARNING ((AE_INFO, + "Large Reference Count (%X) in object %p", Count, Object)); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtUpdateObjectReference + * + * PARAMETERS: Object - Increment ref count for this object + * and all sub-objects + * Action - Either REF_INCREMENT or REF_DECREMENT or + * REF_FORCE_DELETE + * + * RETURN: Status + * + * DESCRIPTION: Increment the object reference count + * + * Object references are incremented when: + * 1) An object is attached to a Node (namespace object) + * 2) An object is copied (all subobjects must be incremented) + * + * Object references are decremented when: + * 1) An object is detached from an Node + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtUpdateObjectReference ( + ACPI_OPERAND_OBJECT *Object, + UINT16 Action) +{ + ACPI_STATUS Status = AE_OK; + ACPI_GENERIC_STATE *StateList = NULL; + ACPI_OPERAND_OBJECT *NextObject = NULL; + ACPI_GENERIC_STATE *State; + UINT32 i; + + + ACPI_FUNCTION_TRACE_PTR (UtUpdateObjectReference, Object); + + + while (Object) + { + /* Make sure that this isn't a namespace handle */ + + if (ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_NAMED) + { + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "Object %p is NS handle\n", Object)); + return_ACPI_STATUS (AE_OK); + } + + /* + * All sub-objects must have their reference count incremented also. + * Different object types have different subobjects. + */ + switch (Object->Common.Type) + { + case ACPI_TYPE_DEVICE: + case ACPI_TYPE_PROCESSOR: + case ACPI_TYPE_POWER: + case ACPI_TYPE_THERMAL: + + /* Update the notify objects for these types (if present) */ + + AcpiUtUpdateRefCount (Object->CommonNotify.SystemNotify, Action); + AcpiUtUpdateRefCount (Object->CommonNotify.DeviceNotify, Action); + break; + + case ACPI_TYPE_PACKAGE: + /* + * We must update all the sub-objects of the package, + * each of whom may have their own sub-objects. + */ + for (i = 0; i < Object->Package.Count; i++) + { + /* + * Push each element onto the stack for later processing. + * Note: There can be null elements within the package, + * these are simply ignored + */ + Status = AcpiUtCreateUpdateStateAndPush ( + Object->Package.Elements[i], Action, &StateList); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + } + break; + + case ACPI_TYPE_BUFFER_FIELD: + + NextObject = Object->BufferField.BufferObj; + break; + + case ACPI_TYPE_LOCAL_REGION_FIELD: + + NextObject = Object->Field.RegionObj; + break; + + case ACPI_TYPE_LOCAL_BANK_FIELD: + + NextObject = Object->BankField.BankObj; + Status = AcpiUtCreateUpdateStateAndPush ( + Object->BankField.RegionObj, Action, &StateList); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + break; + + case ACPI_TYPE_LOCAL_INDEX_FIELD: + + NextObject = Object->IndexField.IndexObj; + Status = AcpiUtCreateUpdateStateAndPush ( + Object->IndexField.DataObj, Action, &StateList); + if (ACPI_FAILURE (Status)) + { + goto ErrorExit; + } + break; + + case ACPI_TYPE_LOCAL_REFERENCE: + /* + * The target of an Index (a package, string, or buffer) or a named + * reference must track changes to the ref count of the index or + * target object. + */ + if ((Object->Reference.Class == ACPI_REFCLASS_INDEX) || + (Object->Reference.Class== ACPI_REFCLASS_NAME)) + { + NextObject = Object->Reference.Object; + } + break; + + case ACPI_TYPE_REGION: + default: + break; /* No subobjects for all other types */ + } + + /* + * Now we can update the count in the main object. This can only + * happen after we update the sub-objects in case this causes the + * main object to be deleted. + */ + AcpiUtUpdateRefCount (Object, Action); + Object = NULL; + + /* Move on to the next object to be updated */ + + if (NextObject) + { + Object = NextObject; + NextObject = NULL; + } + else if (StateList) + { + State = AcpiUtPopGenericState (&StateList); + Object = State->Update.Object; + AcpiUtDeleteGenericState (State); + } + } + + return_ACPI_STATUS (AE_OK); + + +ErrorExit: + + ACPI_EXCEPTION ((AE_INFO, Status, + "Could not update object reference count")); + + /* Free any stacked Update State objects */ + + while (StateList) + { + State = AcpiUtPopGenericState (&StateList); + AcpiUtDeleteGenericState (State); + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtAddReference + * + * PARAMETERS: Object - Object whose reference count is to be + * incremented + * + * RETURN: None + * + * DESCRIPTION: Add one reference to an ACPI object + * + ******************************************************************************/ + +void +AcpiUtAddReference ( + ACPI_OPERAND_OBJECT *Object) +{ + + ACPI_FUNCTION_TRACE_PTR (UtAddReference, Object); + + + /* Ensure that we have a valid object */ + + if (!AcpiUtValidInternalObject (Object)) + { + return_VOID; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "Obj %p Current Refs=%X [To Be Incremented]\n", + Object, Object->Common.ReferenceCount)); + + /* Increment the reference count */ + + (void) AcpiUtUpdateObjectReference (Object, REF_INCREMENT); + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtRemoveReference + * + * PARAMETERS: Object - Object whose ref count will be decremented + * + * RETURN: None + * + * DESCRIPTION: Decrement the reference count of an ACPI internal object + * + ******************************************************************************/ + +void +AcpiUtRemoveReference ( + ACPI_OPERAND_OBJECT *Object) +{ + + ACPI_FUNCTION_TRACE_PTR (UtRemoveReference, Object); + + + /* + * Allow a NULL pointer to be passed in, just ignore it. This saves + * each caller from having to check. Also, ignore NS nodes. + * + */ + if (!Object || + (ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_NAMED)) + + { + return_VOID; + } + + /* Ensure that we have a valid object */ + + if (!AcpiUtValidInternalObject (Object)) + { + return_VOID; + } + + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, + "Obj %p Current Refs=%X [To Be Decremented]\n", + Object, Object->Common.ReferenceCount)); + + /* + * Decrement the reference count, and only actually delete the object + * if the reference count becomes 0. (Must also decrement the ref count + * of all subobjects!) + */ + (void) AcpiUtUpdateObjectReference (Object, REF_DECREMENT); + return_VOID; +} + + diff --git a/reactos/drivers/bus/acpi/acpica/utilities/uteval.c b/reactos/drivers/bus/acpi/acpica/utilities/uteval.c new file mode 100644 index 00000000000..ecb0cf19a70 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/utilities/uteval.c @@ -0,0 +1,575 @@ +/****************************************************************************** + * + * Module Name: uteval - Object evaluation + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __UTEVAL_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("uteval") + + +/* + * 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 */ + {"Windows 2006.1", ACPI_OSI_WINSRV_2008}, /* Windows Server 2008 - Added 09/2009 */ + {"Windows 2006 SP1", ACPI_OSI_WIN_VISTA_SP1}, /* Windows Vista SP1 - Added 09/2009 */ + {"Windows 2009", ACPI_OSI_WIN_7}, /* Windows 7 and Server 2008 R2 - Added 09/2009 */ + + /* 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); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtEvaluateObject + * + * PARAMETERS: PrefixNode - Starting node + * Path - Path to object from starting node + * ExpectedReturnTypes - Bitmap of allowed return types + * ReturnDesc - Where a return value is stored + * + * RETURN: Status + * + * DESCRIPTION: Evaluates a namespace object and verifies the type of the + * return object. Common code that simplifies accessing objects + * that have required return objects of fixed types. + * + * NOTE: Internal function, no parameter validation + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtEvaluateObject ( + ACPI_NAMESPACE_NODE *PrefixNode, + char *Path, + UINT32 ExpectedReturnBtypes, + ACPI_OPERAND_OBJECT **ReturnDesc) +{ + ACPI_EVALUATE_INFO *Info; + ACPI_STATUS Status; + UINT32 ReturnBtype; + + + ACPI_FUNCTION_TRACE (UtEvaluateObject); + + + /* Allocate the evaluation information block */ + + Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO)); + if (!Info) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + Info->PrefixNode = PrefixNode; + Info->Pathname = Path; + + /* Evaluate the object/method */ + + Status = AcpiNsEvaluate (Info); + if (ACPI_FAILURE (Status)) + { + if (Status == AE_NOT_FOUND) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s.%s] was not found\n", + AcpiUtGetNodeName (PrefixNode), Path)); + } + else + { + ACPI_ERROR_METHOD ("Method execution failed", + PrefixNode, Path, Status); + } + + goto Cleanup; + } + + /* Did we get a return object? */ + + if (!Info->ReturnObject) + { + if (ExpectedReturnBtypes) + { + ACPI_ERROR_METHOD ("No object was returned from", + PrefixNode, Path, AE_NOT_EXIST); + + Status = AE_NOT_EXIST; + } + + goto Cleanup; + } + + /* Map the return object type to the bitmapped type */ + + switch ((Info->ReturnObject)->Common.Type) + { + case ACPI_TYPE_INTEGER: + ReturnBtype = ACPI_BTYPE_INTEGER; + break; + + case ACPI_TYPE_BUFFER: + ReturnBtype = ACPI_BTYPE_BUFFER; + break; + + case ACPI_TYPE_STRING: + ReturnBtype = ACPI_BTYPE_STRING; + break; + + case ACPI_TYPE_PACKAGE: + ReturnBtype = ACPI_BTYPE_PACKAGE; + break; + + default: + ReturnBtype = 0; + break; + } + + if ((AcpiGbl_EnableInterpreterSlack) && + (!ExpectedReturnBtypes)) + { + /* + * We received a return object, but one was not expected. This can + * happen frequently if the "implicit return" feature is enabled. + * Just delete the return object and return AE_OK. + */ + AcpiUtRemoveReference (Info->ReturnObject); + goto Cleanup; + } + + /* Is the return object one of the expected types? */ + + if (!(ExpectedReturnBtypes & ReturnBtype)) + { + ACPI_ERROR_METHOD ("Return object type is incorrect", + PrefixNode, Path, AE_TYPE); + + ACPI_ERROR ((AE_INFO, + "Type returned from %s was incorrect: %s, expected Btypes: %X", + Path, AcpiUtGetObjectTypeName (Info->ReturnObject), + ExpectedReturnBtypes)); + + /* On error exit, we must delete the return object */ + + AcpiUtRemoveReference (Info->ReturnObject); + Status = AE_TYPE; + goto Cleanup; + } + + /* Object type is OK, return it */ + + *ReturnDesc = Info->ReturnObject; + +Cleanup: + ACPI_FREE (Info); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtEvaluateNumericObject + * + * PARAMETERS: ObjectName - Object name to be evaluated + * DeviceNode - Node for the device + * Value - Where the value is returned + * + * RETURN: Status + * + * DESCRIPTION: Evaluates a numeric namespace object for a selected device + * and stores result in *Value. + * + * NOTE: Internal function, no parameter validation + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtEvaluateNumericObject ( + char *ObjectName, + ACPI_NAMESPACE_NODE *DeviceNode, + ACPI_INTEGER *Value) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (UtEvaluateNumericObject); + + + Status = AcpiUtEvaluateObject (DeviceNode, ObjectName, + ACPI_BTYPE_INTEGER, &ObjDesc); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Get the returned Integer */ + + *Value = ObjDesc->Integer.Value; + + /* On exit, we must delete the return object */ + + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtExecute_STA + * + * PARAMETERS: DeviceNode - Node for the device + * Flags - Where the status flags are returned + * + * RETURN: Status + * + * DESCRIPTION: Executes _STA for selected device and stores results in + * *Flags. + * + * NOTE: Internal function, no parameter validation + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtExecute_STA ( + ACPI_NAMESPACE_NODE *DeviceNode, + UINT32 *Flags) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (UtExecute_STA); + + + Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__STA, + ACPI_BTYPE_INTEGER, &ObjDesc); + if (ACPI_FAILURE (Status)) + { + if (AE_NOT_FOUND == Status) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "_STA on %4.4s was not found, assuming device is present\n", + AcpiUtGetNodeName (DeviceNode))); + + *Flags = ACPI_UINT32_MAX; + Status = AE_OK; + } + + return_ACPI_STATUS (Status); + } + + /* Extract the status flags */ + + *Flags = (UINT32) ObjDesc->Integer.Value; + + /* On exit, we must delete the return object */ + + AcpiUtRemoveReference (ObjDesc); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtExecutePowerMethods + * + * PARAMETERS: DeviceNode - Node for the device + * MethodNames - Array of power method names + * MethodCount - Number of methods to execute + * OutValues - Where the power method values are returned + * + * RETURN: Status, OutValues + * + * DESCRIPTION: Executes the specified power methods for the device and returns + * the result(s). + * + * NOTE: Internal function, no parameter validation + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtExecutePowerMethods ( + ACPI_NAMESPACE_NODE *DeviceNode, + const char **MethodNames, + UINT8 MethodCount, + UINT8 *OutValues) +{ + ACPI_OPERAND_OBJECT *ObjDesc; + ACPI_STATUS Status; + ACPI_STATUS FinalStatus = AE_NOT_FOUND; + UINT32 i; + + + ACPI_FUNCTION_TRACE (UtExecutePowerMethods); + + + for (i = 0; i < MethodCount; i++) + { + /* + * Execute the power method (_SxD or _SxW). The only allowable + * return type is an Integer. + */ + Status = AcpiUtEvaluateObject (DeviceNode, + ACPI_CAST_PTR (char, MethodNames[i]), + ACPI_BTYPE_INTEGER, &ObjDesc); + if (ACPI_SUCCESS (Status)) + { + OutValues[i] = (UINT8) ObjDesc->Integer.Value; + + /* Delete the return object */ + + AcpiUtRemoveReference (ObjDesc); + FinalStatus = AE_OK; /* At least one value is valid */ + continue; + } + + OutValues[i] = ACPI_UINT8_MAX; + if (Status == AE_NOT_FOUND) + { + continue; /* Ignore if not found */ + } + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Failed %s on Device %4.4s, %s\n", + ACPI_CAST_PTR (char, MethodNames[i]), + AcpiUtGetNodeName (DeviceNode), AcpiFormatException (Status))); + } + + return_ACPI_STATUS (FinalStatus); +} diff --git a/reactos/drivers/bus/acpi/acpica/utilities/utglobal.c b/reactos/drivers/bus/acpi/acpica/utilities/utglobal.c new file mode 100644 index 00000000000..b49ce352fbc --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/utilities/utglobal.c @@ -0,0 +1,975 @@ +/****************************************************************************** + * + * Module Name: utglobal - Global variables for the ACPI subsystem + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __UTGLOBAL_C__ +#define DEFINE_ACPI_GLOBALS + +#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_LowestDstateNames[ACPI_NUM_SxW_METHODS] = +{ + "_S0W", + "_S1W", + "_S2W", + "_S3W", + "_S4W" +}; + +const char *AcpiGbl_HighestDstateNames[ACPI_NUM_SxD_METHODS] = +{ + "_S1D", + "_S2D", + "_S3D", + "_S4D" +}; + + +/******************************************************************************* + * + * 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 + * + ******************************************************************************/ + +/* + * 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 + */ +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]); +} + + +/****************************************************************************** + * + * 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. + * + * 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", + "IPMI", + "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); +} + + +/******************************************************************************* + * + * 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_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.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; +#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/reactos/drivers/bus/acpi/acpica/utilities/utids.c b/reactos/drivers/bus/acpi/acpica/utilities/utids.c new file mode 100644 index 00000000000..76693305008 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/utilities/utids.c @@ -0,0 +1,497 @@ +/****************************************************************************** + * + * Module Name: utids - support for device IDs - HID, UID, CID + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __UTIDS_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acinterp.h" + + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utids") + +/* Local prototypes */ + +static void +AcpiUtCopyIdString ( + char *Destination, + char *Source); + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCopyIdString + * + * PARAMETERS: Destination - Where to copy the string + * Source - Source string + * + * 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) +{ + + /* + * 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_STRCPY (Destination, Source); +} + + +/******************************************************************************* + * + * 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 + { + AcpiUtCopyIdString (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 + { + AcpiUtCopyIdString (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 */ + + AcpiUtCopyIdString (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/reactos/drivers/bus/acpi/acpica/utilities/utinit.c b/reactos/drivers/bus/acpi/acpica/utilities/utinit.c new file mode 100644 index 00000000000..d59904b46a2 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/utilities/utinit.c @@ -0,0 +1,228 @@ +/****************************************************************************** + * + * Module Name: utinit - Common ACPI subsystem initialization + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __UTINIT_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" +#include "acevents.h" +#include "actables.h" + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utinit") + +/* Local prototypes */ + +static void AcpiUtTerminate ( + void); + + +/****************************************************************************** + * + * FUNCTION: AcpiUtTerminate + * + * PARAMETERS: none + * + * RETURN: none + * + * DESCRIPTION: Free global memory + * + ******************************************************************************/ + +static void +AcpiUtTerminate ( + void) +{ + ACPI_GPE_BLOCK_INFO *GpeBlock; + ACPI_GPE_BLOCK_INFO *NextGpeBlock; + ACPI_GPE_XRUPT_INFO *GpeXruptInfo; + ACPI_GPE_XRUPT_INFO *NextGpeXruptInfo; + + + ACPI_FUNCTION_TRACE (UtTerminate); + + + /* Free global GPE blocks and related info structures */ + + GpeXruptInfo = AcpiGbl_GpeXruptListHead; + while (GpeXruptInfo) + { + GpeBlock = GpeXruptInfo->GpeBlockListHead; + while (GpeBlock) + { + NextGpeBlock = GpeBlock->Next; + ACPI_FREE (GpeBlock->EventInfo); + ACPI_FREE (GpeBlock->RegisterInfo); + ACPI_FREE (GpeBlock); + + GpeBlock = NextGpeBlock; + } + NextGpeXruptInfo = GpeXruptInfo->Next; + ACPI_FREE (GpeXruptInfo); + GpeXruptInfo = NextGpeXruptInfo; + } + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtSubsystemShutdown + * + * PARAMETERS: None + * + * RETURN: None + * + * DESCRIPTION: Shutdown the various components. Do not delete the mutex + * objects here, because the AML debugger may be still running. + * + ******************************************************************************/ + +void +AcpiUtSubsystemShutdown ( + void) +{ + ACPI_FUNCTION_TRACE (UtSubsystemShutdown); + + +#ifndef ACPI_ASL_COMPILER + + /* Close the AcpiEvent Handling */ + + AcpiEvTerminate (); +#endif + + /* Close the Namespace */ + + AcpiNsTerminate (); + + /* Delete the ACPI tables */ + + AcpiTbTerminate (); + + /* Close the globals */ + + AcpiUtTerminate (); + + /* Purge the local caches */ + + (void) AcpiUtDeleteCaches (); + return_VOID; +} + + diff --git a/reactos/drivers/bus/acpi/acpica/utilities/utlock.c b/reactos/drivers/bus/acpi/acpica/utilities/utlock.c new file mode 100644 index 00000000000..dd4e100001a --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/utilities/utlock.c @@ -0,0 +1,277 @@ +/****************************************************************************** + * + * Module Name: utlock - Reader/Writer lock interfaces + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __UTLOCK_C__ + +#include "acpi.h" +#include "accommon.h" + + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utlock") + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreateRwLock + * AcpiUtDeleteRwLock + * + * PARAMETERS: Lock - Pointer to a valid RW lock + * + * RETURN: Status + * + * DESCRIPTION: Reader/writer lock creation and deletion interfaces. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtCreateRwLock ( + ACPI_RW_LOCK *Lock) +{ + ACPI_STATUS Status; + + + Lock->NumReaders = 0; + Status = AcpiOsCreateMutex (&Lock->ReaderMutex); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Status = AcpiOsCreateMutex (&Lock->WriterMutex); + return (Status); +} + + +void +AcpiUtDeleteRwLock ( + ACPI_RW_LOCK *Lock) +{ + + AcpiOsDeleteMutex (Lock->ReaderMutex); + AcpiOsDeleteMutex (Lock->WriterMutex); + + Lock->NumReaders = 0; + Lock->ReaderMutex = NULL; + Lock->WriterMutex = NULL; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtAcquireReadLock + * AcpiUtReleaseReadLock + * + * PARAMETERS: Lock - Pointer to a valid RW lock + * + * RETURN: Status + * + * DESCRIPTION: Reader interfaces for reader/writer locks. On acquisition, + * only the first reader acquires the write mutex. On release, + * only the last reader releases the write mutex. Although this + * algorithm can in theory starve writers, this should not be a + * problem with ACPICA since the subsystem is infrequently used + * in comparison to (for example) an I/O system. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtAcquireReadLock ( + ACPI_RW_LOCK *Lock) +{ + ACPI_STATUS Status; + + + Status = AcpiOsAcquireMutex (Lock->ReaderMutex, ACPI_WAIT_FOREVER); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Acquire the write lock only for the first reader */ + + Lock->NumReaders++; + if (Lock->NumReaders == 1) + { + Status = AcpiOsAcquireMutex (Lock->WriterMutex, ACPI_WAIT_FOREVER); + } + + AcpiOsReleaseMutex (Lock->ReaderMutex); + return (Status); +} + + +ACPI_STATUS +AcpiUtReleaseReadLock ( + ACPI_RW_LOCK *Lock) +{ + ACPI_STATUS Status; + + + Status = AcpiOsAcquireMutex (Lock->ReaderMutex, ACPI_WAIT_FOREVER); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + /* Release the write lock only for the very last reader */ + + Lock->NumReaders--; + if (Lock->NumReaders == 0) + { + AcpiOsReleaseMutex (Lock->WriterMutex); + } + + AcpiOsReleaseMutex (Lock->ReaderMutex); + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtAcquireWriteLock + * AcpiUtReleaseWriteLock + * + * PARAMETERS: Lock - Pointer to a valid RW lock + * + * RETURN: Status + * + * DESCRIPTION: Writer interfaces for reader/writer locks. Simply acquire or + * release the writer mutex associated with the lock. Acquisition + * of the lock is fully exclusive and will block all readers and + * writers until it is released. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtAcquireWriteLock ( + ACPI_RW_LOCK *Lock) +{ + ACPI_STATUS Status; + + + Status = AcpiOsAcquireMutex (Lock->WriterMutex, ACPI_WAIT_FOREVER); + return (Status); +} + + +void +AcpiUtReleaseWriteLock ( + ACPI_RW_LOCK *Lock) +{ + + AcpiOsReleaseMutex (Lock->WriterMutex); +} + diff --git a/reactos/drivers/bus/acpi/acpica/utilities/utmath.c b/reactos/drivers/bus/acpi/acpica/utilities/utmath.c new file mode 100644 index 00000000000..b0a40ff2bcf --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/utilities/utmath.c @@ -0,0 +1,431 @@ +/******************************************************************************* + * + * Module Name: utmath - Integer math support routines + * + ******************************************************************************/ + +/****************************************************************************** + * + * 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 __UTMATH_C__ + +#include "acpi.h" +#include "accommon.h" + + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utmath") + +/* + * Support for double-precision integer divide. This code is included here + * in order to support kernel environments where the double-precision math + * library is not available. + */ + +#ifndef ACPI_USE_NATIVE_DIVIDE +/******************************************************************************* + * + * FUNCTION: AcpiUtShortDivide + * + * PARAMETERS: Dividend - 64-bit dividend + * Divisor - 32-bit divisor + * OutQuotient - Pointer to where the quotient is returned + * OutRemainder - Pointer to where the remainder is returned + * + * RETURN: Status (Checks for divide-by-zero) + * + * DESCRIPTION: Perform a short (maximum 64 bits divided by 32 bits) + * divide and modulo. The result is a 64-bit quotient and a + * 32-bit remainder. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtShortDivide ( + ACPI_INTEGER Dividend, + UINT32 Divisor, + ACPI_INTEGER *OutQuotient, + UINT32 *OutRemainder) +{ + UINT64_OVERLAY DividendOvl; + UINT64_OVERLAY Quotient; + UINT32 Remainder32; + + + ACPI_FUNCTION_TRACE (UtShortDivide); + + + /* Always check for a zero divisor */ + + if (Divisor == 0) + { + ACPI_ERROR ((AE_INFO, "Divide by zero")); + return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO); + } + + DividendOvl.Full = Dividend; + + /* + * The quotient is 64 bits, the remainder is always 32 bits, + * and is generated by the second divide. + */ + ACPI_DIV_64_BY_32 (0, DividendOvl.Part.Hi, Divisor, + Quotient.Part.Hi, Remainder32); + ACPI_DIV_64_BY_32 (Remainder32, DividendOvl.Part.Lo, Divisor, + Quotient.Part.Lo, Remainder32); + + /* Return only what was requested */ + + if (OutQuotient) + { + *OutQuotient = Quotient.Full; + } + if (OutRemainder) + { + *OutRemainder = Remainder32; + } + + return_ACPI_STATUS (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtDivide + * + * PARAMETERS: InDividend - Dividend + * InDivisor - Divisor + * OutQuotient - Pointer to where the quotient is returned + * OutRemainder - Pointer to where the remainder is returned + * + * RETURN: Status (Checks for divide-by-zero) + * + * DESCRIPTION: Perform a divide and modulo. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtDivide ( + ACPI_INTEGER InDividend, + ACPI_INTEGER InDivisor, + ACPI_INTEGER *OutQuotient, + ACPI_INTEGER *OutRemainder) +{ + UINT64_OVERLAY Dividend; + UINT64_OVERLAY Divisor; + UINT64_OVERLAY Quotient; + UINT64_OVERLAY Remainder; + UINT64_OVERLAY NormalizedDividend; + UINT64_OVERLAY NormalizedDivisor; + UINT32 Partial1; + UINT64_OVERLAY Partial2; + UINT64_OVERLAY Partial3; + + + ACPI_FUNCTION_TRACE (UtDivide); + + + /* Always check for a zero divisor */ + + if (InDivisor == 0) + { + ACPI_ERROR ((AE_INFO, "Divide by zero")); + return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO); + } + + Divisor.Full = InDivisor; + Dividend.Full = InDividend; + if (Divisor.Part.Hi == 0) + { + /* + * 1) Simplest case is where the divisor is 32 bits, we can + * just do two divides + */ + Remainder.Part.Hi = 0; + + /* + * The quotient is 64 bits, the remainder is always 32 bits, + * and is generated by the second divide. + */ + ACPI_DIV_64_BY_32 (0, Dividend.Part.Hi, Divisor.Part.Lo, + Quotient.Part.Hi, Partial1); + ACPI_DIV_64_BY_32 (Partial1, Dividend.Part.Lo, Divisor.Part.Lo, + Quotient.Part.Lo, Remainder.Part.Lo); + } + + else + { + /* + * 2) The general case where the divisor is a full 64 bits + * is more difficult + */ + Quotient.Part.Hi = 0; + NormalizedDividend = Dividend; + NormalizedDivisor = Divisor; + + /* Normalize the operands (shift until the divisor is < 32 bits) */ + + do + { + ACPI_SHIFT_RIGHT_64 (NormalizedDivisor.Part.Hi, + NormalizedDivisor.Part.Lo); + ACPI_SHIFT_RIGHT_64 (NormalizedDividend.Part.Hi, + NormalizedDividend.Part.Lo); + + } while (NormalizedDivisor.Part.Hi != 0); + + /* Partial divide */ + + ACPI_DIV_64_BY_32 (NormalizedDividend.Part.Hi, + NormalizedDividend.Part.Lo, + NormalizedDivisor.Part.Lo, + Quotient.Part.Lo, Partial1); + + /* + * The quotient is always 32 bits, and simply requires adjustment. + * The 64-bit remainder must be generated. + */ + Partial1 = Quotient.Part.Lo * Divisor.Part.Hi; + Partial2.Full = (ACPI_INTEGER) Quotient.Part.Lo * Divisor.Part.Lo; + Partial3.Full = (ACPI_INTEGER) Partial2.Part.Hi + Partial1; + + Remainder.Part.Hi = Partial3.Part.Lo; + Remainder.Part.Lo = Partial2.Part.Lo; + + if (Partial3.Part.Hi == 0) + { + if (Partial3.Part.Lo >= Dividend.Part.Hi) + { + if (Partial3.Part.Lo == Dividend.Part.Hi) + { + if (Partial2.Part.Lo > Dividend.Part.Lo) + { + Quotient.Part.Lo--; + Remainder.Full -= Divisor.Full; + } + } + else + { + Quotient.Part.Lo--; + Remainder.Full -= Divisor.Full; + } + } + + Remainder.Full = Remainder.Full - Dividend.Full; + Remainder.Part.Hi = (UINT32) -((INT32) Remainder.Part.Hi); + Remainder.Part.Lo = (UINT32) -((INT32) Remainder.Part.Lo); + + if (Remainder.Part.Lo) + { + Remainder.Part.Hi--; + } + } + } + + /* Return only what was requested */ + + if (OutQuotient) + { + *OutQuotient = Quotient.Full; + } + if (OutRemainder) + { + *OutRemainder = Remainder.Full; + } + + return_ACPI_STATUS (AE_OK); +} + +#else + +/******************************************************************************* + * + * FUNCTION: AcpiUtShortDivide, AcpiUtDivide + * + * PARAMETERS: See function headers above + * + * DESCRIPTION: Native versions of the UtDivide functions. Use these if either + * 1) The target is a 64-bit platform and therefore 64-bit + * integer math is supported directly by the machine. + * 2) The target is a 32-bit or 16-bit platform, and the + * double-precision integer math library is available to + * perform the divide. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtShortDivide ( + ACPI_INTEGER InDividend, + UINT32 Divisor, + ACPI_INTEGER *OutQuotient, + UINT32 *OutRemainder) +{ + + ACPI_FUNCTION_TRACE (UtShortDivide); + + + /* Always check for a zero divisor */ + + if (Divisor == 0) + { + ACPI_ERROR ((AE_INFO, "Divide by zero")); + return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO); + } + + /* Return only what was requested */ + + if (OutQuotient) + { + *OutQuotient = InDividend / Divisor; + } + if (OutRemainder) + { + *OutRemainder = (UINT32) (InDividend % Divisor); + } + + return_ACPI_STATUS (AE_OK); +} + +ACPI_STATUS +AcpiUtDivide ( + ACPI_INTEGER InDividend, + ACPI_INTEGER InDivisor, + ACPI_INTEGER *OutQuotient, + ACPI_INTEGER *OutRemainder) +{ + ACPI_FUNCTION_TRACE (UtDivide); + + + /* Always check for a zero divisor */ + + if (InDivisor == 0) + { + ACPI_ERROR ((AE_INFO, "Divide by zero")); + return_ACPI_STATUS (AE_AML_DIVIDE_BY_ZERO); + } + + + /* Return only what was requested */ + + if (OutQuotient) + { + *OutQuotient = InDividend / InDivisor; + } + if (OutRemainder) + { + *OutRemainder = InDividend % InDivisor; + } + + return_ACPI_STATUS (AE_OK); +} + +#endif + + diff --git a/reactos/drivers/bus/acpi/acpica/utilities/utmisc.c b/reactos/drivers/bus/acpi/acpica/utilities/utmisc.c new file mode 100644 index 00000000000..bc27cd52938 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/utilities/utmisc.c @@ -0,0 +1,1485 @@ +/******************************************************************************* + * + * Module Name: utmisc - common utility procedures + * + ******************************************************************************/ + +/****************************************************************************** + * + * 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 __UTMISC_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utmisc") + +/* + * Common suffix for messages + */ +#define ACPI_COMMON_MSG_SUFFIX \ + AcpiOsPrintf (" (%8.8X/%s-%u)\n", ACPI_CA_VERSION, ModuleName, LineNumber) + + +/******************************************************************************* + * + * FUNCTION: AcpiUtValidateException + * + * PARAMETERS: Status - The ACPI_STATUS code to be formatted + * + * RETURN: A string containing the exception text. NULL if exception is + * not valid. + * + * DESCRIPTION: This function validates and translates an ACPI exception into + * an ASCII string. + * + ******************************************************************************/ + +const char * +AcpiUtValidateException ( + ACPI_STATUS Status) +{ + UINT32 SubStatus; + const char *Exception = NULL; + + + ACPI_FUNCTION_ENTRY (); + + + /* + * Status is composed of two parts, a "type" and an actual code + */ + SubStatus = (Status & ~AE_CODE_MASK); + + switch (Status & AE_CODE_MASK) + { + case AE_CODE_ENVIRONMENTAL: + + if (SubStatus <= AE_CODE_ENV_MAX) + { + Exception = AcpiGbl_ExceptionNames_Env [SubStatus]; + } + break; + + case AE_CODE_PROGRAMMER: + + if (SubStatus <= AE_CODE_PGM_MAX) + { + Exception = AcpiGbl_ExceptionNames_Pgm [SubStatus]; + } + break; + + case AE_CODE_ACPI_TABLES: + + if (SubStatus <= AE_CODE_TBL_MAX) + { + Exception = AcpiGbl_ExceptionNames_Tbl [SubStatus]; + } + break; + + case AE_CODE_AML: + + if (SubStatus <= AE_CODE_AML_MAX) + { + Exception = AcpiGbl_ExceptionNames_Aml [SubStatus]; + } + break; + + case AE_CODE_CONTROL: + + if (SubStatus <= AE_CODE_CTRL_MAX) + { + Exception = AcpiGbl_ExceptionNames_Ctrl [SubStatus]; + } + break; + + default: + break; + } + + return (ACPI_CAST_PTR (const char, Exception)); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtIsPciRootBridge + * + * PARAMETERS: Id - The HID/CID in string format + * + * RETURN: TRUE if the Id is a match for a PCI/PCI-Express Root Bridge + * + * DESCRIPTION: Determine if the input ID is a PCI Root Bridge ID. + * + ******************************************************************************/ + +BOOLEAN +AcpiUtIsPciRootBridge ( + char *Id) +{ + + /* + * Check if this is a PCI root bridge. + * ACPI 3.0+: check for a PCI Express root also. + */ + if (!(ACPI_STRCMP (Id, + PCI_ROOT_HID_STRING)) || + + !(ACPI_STRCMP (Id, + PCI_EXPRESS_ROOT_HID_STRING))) + { + return (TRUE); + } + + return (FALSE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtIsAmlTable + * + * PARAMETERS: Table - An ACPI table + * + * RETURN: TRUE if table contains executable AML; FALSE otherwise + * + * DESCRIPTION: Check ACPI Signature for a table that contains AML code. + * Currently, these are DSDT,SSDT,PSDT. All other table types are + * data tables that do not contain AML code. + * + ******************************************************************************/ + +BOOLEAN +AcpiUtIsAmlTable ( + ACPI_TABLE_HEADER *Table) +{ + + /* These are the only tables that contain executable AML */ + + if (ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_DSDT) || + ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_PSDT) || + ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_SSDT)) + { + return (TRUE); + } + + return (FALSE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtAllocateOwnerId + * + * PARAMETERS: OwnerId - Where the new owner ID is returned + * + * RETURN: Status + * + * DESCRIPTION: Allocate a table or method owner ID. The owner ID is used to + * track objects created by the table or method, to be deleted + * when the method exits or the table is unloaded. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtAllocateOwnerId ( + ACPI_OWNER_ID *OwnerId) +{ + UINT32 i; + UINT32 j; + UINT32 k; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (UtAllocateOwnerId); + + + /* Guard against multiple allocations of ID to the same location */ + + if (*OwnerId) + { + ACPI_ERROR ((AE_INFO, "Owner ID [%2.2X] already exists", *OwnerId)); + return_ACPI_STATUS (AE_ALREADY_EXISTS); + } + + /* Mutex for the global ID mask */ + + Status = AcpiUtAcquireMutex (ACPI_MTX_CACHES); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Find a free owner ID, cycle through all possible IDs on repeated + * allocations. (ACPI_NUM_OWNERID_MASKS + 1) because first index may have + * to be scanned twice. + */ + for (i = 0, j = AcpiGbl_LastOwnerIdIndex; + i < (ACPI_NUM_OWNERID_MASKS + 1); + i++, j++) + { + if (j >= ACPI_NUM_OWNERID_MASKS) + { + j = 0; /* Wraparound to start of mask array */ + } + + for (k = AcpiGbl_NextOwnerIdOffset; k < 32; k++) + { + if (AcpiGbl_OwnerIdMask[j] == ACPI_UINT32_MAX) + { + /* There are no free IDs in this mask */ + + break; + } + + if (!(AcpiGbl_OwnerIdMask[j] & (1 << k))) + { + /* + * Found a free ID. The actual ID is the bit index plus one, + * making zero an invalid Owner ID. Save this as the last ID + * allocated and update the global ID mask. + */ + AcpiGbl_OwnerIdMask[j] |= (1 << k); + + AcpiGbl_LastOwnerIdIndex = (UINT8) j; + AcpiGbl_NextOwnerIdOffset = (UINT8) (k + 1); + + /* + * Construct encoded ID from the index and bit position + * + * Note: Last [j].k (bit 255) is never used and is marked + * permanently allocated (prevents +1 overflow) + */ + *OwnerId = (ACPI_OWNER_ID) ((k + 1) + ACPI_MUL_32 (j)); + + ACPI_DEBUG_PRINT ((ACPI_DB_VALUES, + "Allocated OwnerId: %2.2X\n", (unsigned int) *OwnerId)); + goto Exit; + } + } + + AcpiGbl_NextOwnerIdOffset = 0; + } + + /* + * All OwnerIds have been allocated. This typically should + * not happen since the IDs are reused after deallocation. The IDs are + * allocated upon table load (one per table) and method execution, and + * they are released when a table is unloaded or a method completes + * execution. + * + * If this error happens, there may be very deep nesting of invoked control + * methods, or there may be a bug where the IDs are not released. + */ + Status = AE_OWNER_ID_LIMIT; + ACPI_ERROR ((AE_INFO, + "Could not allocate new OwnerId (255 max), AE_OWNER_ID_LIMIT")); + +Exit: + (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtReleaseOwnerId + * + * PARAMETERS: OwnerIdPtr - Pointer to a previously allocated OwnerID + * + * RETURN: None. No error is returned because we are either exiting a + * control method or unloading a table. Either way, we would + * ignore any error anyway. + * + * DESCRIPTION: Release a table or method owner ID. Valid IDs are 1 - 255 + * + ******************************************************************************/ + +void +AcpiUtReleaseOwnerId ( + ACPI_OWNER_ID *OwnerIdPtr) +{ + ACPI_OWNER_ID OwnerId = *OwnerIdPtr; + ACPI_STATUS Status; + UINT32 Index; + UINT32 Bit; + + + ACPI_FUNCTION_TRACE_U32 (UtReleaseOwnerId, OwnerId); + + + /* Always clear the input OwnerId (zero is an invalid ID) */ + + *OwnerIdPtr = 0; + + /* Zero is not a valid OwnerID */ + + if (OwnerId == 0) + { + ACPI_ERROR ((AE_INFO, "Invalid OwnerId: %2.2X", OwnerId)); + return_VOID; + } + + /* Mutex for the global ID mask */ + + Status = AcpiUtAcquireMutex (ACPI_MTX_CACHES); + if (ACPI_FAILURE (Status)) + { + return_VOID; + } + + /* Normalize the ID to zero */ + + OwnerId--; + + /* Decode ID to index/offset pair */ + + Index = ACPI_DIV_32 (OwnerId); + Bit = 1 << ACPI_MOD_32 (OwnerId); + + /* Free the owner ID only if it is valid */ + + if (AcpiGbl_OwnerIdMask[Index] & Bit) + { + AcpiGbl_OwnerIdMask[Index] ^= Bit; + } + else + { + ACPI_ERROR ((AE_INFO, + "Release of non-allocated OwnerId: %2.2X", OwnerId + 1)); + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES); + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtStrupr (strupr) + * + * PARAMETERS: SrcString - The source string to convert + * + * RETURN: None + * + * DESCRIPTION: Convert string to uppercase + * + * NOTE: This is not a POSIX function, so it appears here, not in utclib.c + * + ******************************************************************************/ + +void +AcpiUtStrupr ( + char *SrcString) +{ + char *String; + + + ACPI_FUNCTION_ENTRY (); + + + if (!SrcString) + { + return; + } + + /* Walk entire string, uppercasing the letters */ + + for (String = SrcString; *String; String++) + { + *String = (char) ACPI_TOUPPER (*String); + } + + return; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtPrintString + * + * PARAMETERS: String - Null terminated ASCII string + * MaxLength - Maximum output length + * + * RETURN: None + * + * DESCRIPTION: Dump an ASCII string with support for ACPI-defined escape + * sequences. + * + ******************************************************************************/ + +void +AcpiUtPrintString ( + char *String, + UINT8 MaxLength) +{ + UINT32 i; + + + if (!String) + { + AcpiOsPrintf ("<\"NULL STRING PTR\">"); + return; + } + + AcpiOsPrintf ("\""); + for (i = 0; String[i] && (i < MaxLength); i++) + { + /* Escape sequences */ + + switch (String[i]) + { + case 0x07: + AcpiOsPrintf ("\\a"); /* BELL */ + break; + + case 0x08: + AcpiOsPrintf ("\\b"); /* BACKSPACE */ + break; + + case 0x0C: + AcpiOsPrintf ("\\f"); /* FORMFEED */ + break; + + case 0x0A: + AcpiOsPrintf ("\\n"); /* LINEFEED */ + break; + + case 0x0D: + AcpiOsPrintf ("\\r"); /* CARRIAGE RETURN*/ + break; + + case 0x09: + AcpiOsPrintf ("\\t"); /* HORIZONTAL TAB */ + break; + + case 0x0B: + AcpiOsPrintf ("\\v"); /* VERTICAL TAB */ + break; + + case '\'': /* Single Quote */ + case '\"': /* Double Quote */ + case '\\': /* Backslash */ + AcpiOsPrintf ("\\%c", (int) String[i]); + break; + + default: + + /* Check for printable character or hex escape */ + + if (ACPI_IS_PRINT (String[i])) + { + /* This is a normal character */ + + AcpiOsPrintf ("%c", (int) String[i]); + } + else + { + /* All others will be Hex escapes */ + + AcpiOsPrintf ("\\x%2.2X", (INT32) String[i]); + } + break; + } + } + AcpiOsPrintf ("\""); + + if (i == MaxLength && String[i]) + { + AcpiOsPrintf ("..."); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtDwordByteSwap + * + * PARAMETERS: Value - Value to be converted + * + * RETURN: UINT32 integer with bytes swapped + * + * DESCRIPTION: Convert a 32-bit value to big-endian (swap the bytes) + * + ******************************************************************************/ + +UINT32 +AcpiUtDwordByteSwap ( + UINT32 Value) +{ + union + { + UINT32 Value; + UINT8 Bytes[4]; + } Out; + union + { + UINT32 Value; + UINT8 Bytes[4]; + } In; + + + ACPI_FUNCTION_ENTRY (); + + + In.Value = Value; + + Out.Bytes[0] = In.Bytes[3]; + Out.Bytes[1] = In.Bytes[2]; + Out.Bytes[2] = In.Bytes[1]; + Out.Bytes[3] = In.Bytes[0]; + + return (Out.Value); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtSetIntegerWidth + * + * PARAMETERS: Revision From DSDT header + * + * RETURN: None + * + * DESCRIPTION: Set the global integer bit width based upon the revision + * of the DSDT. For Revision 1 and 0, Integers are 32 bits. + * For Revision 2 and above, Integers are 64 bits. Yes, this + * makes a difference. + * + ******************************************************************************/ + +void +AcpiUtSetIntegerWidth ( + UINT8 Revision) +{ + + if (Revision < 2) + { + /* 32-bit case */ + + AcpiGbl_IntegerBitWidth = 32; + AcpiGbl_IntegerNybbleWidth = 8; + AcpiGbl_IntegerByteWidth = 4; + } + else + { + /* 64-bit case (ACPI 2.0+) */ + + AcpiGbl_IntegerBitWidth = 64; + AcpiGbl_IntegerNybbleWidth = 16; + AcpiGbl_IntegerByteWidth = 8; + } +} + + +#ifdef ACPI_DEBUG_OUTPUT +/******************************************************************************* + * + * FUNCTION: AcpiUtDisplayInitPathname + * + * PARAMETERS: Type - Object type of the node + * ObjHandle - Handle whose pathname will be displayed + * Path - Additional path string to be appended. + * (NULL if no extra path) + * + * RETURN: ACPI_STATUS + * + * DESCRIPTION: Display full pathname of an object, DEBUG ONLY + * + ******************************************************************************/ + +void +AcpiUtDisplayInitPathname ( + UINT8 Type, + ACPI_NAMESPACE_NODE *ObjHandle, + char *Path) +{ + ACPI_STATUS Status; + ACPI_BUFFER Buffer; + + + ACPI_FUNCTION_ENTRY (); + + + /* Only print the path if the appropriate debug level is enabled */ + + if (!(AcpiDbgLevel & ACPI_LV_INIT_NAMES)) + { + return; + } + + /* Get the full pathname to the node */ + + Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; + Status = AcpiNsHandleToPathname (ObjHandle, &Buffer); + if (ACPI_FAILURE (Status)) + { + return; + } + + /* Print what we're doing */ + + switch (Type) + { + case ACPI_TYPE_METHOD: + AcpiOsPrintf ("Executing "); + break; + + default: + AcpiOsPrintf ("Initializing "); + break; + } + + /* Print the object type and pathname */ + + AcpiOsPrintf ("%-12s %s", + AcpiUtGetTypeName (Type), (char *) Buffer.Pointer); + + /* Extra path is used to append names like _STA, _INI, etc. */ + + if (Path) + { + AcpiOsPrintf (".%s", Path); + } + AcpiOsPrintf ("\n"); + + ACPI_FREE (Buffer.Pointer); +} +#endif + + +/******************************************************************************* + * + * FUNCTION: AcpiUtValidAcpiChar + * + * PARAMETERS: Char - The character to be examined + * Position - Byte position (0-3) + * + * RETURN: TRUE if the character is valid, FALSE otherwise + * + * DESCRIPTION: Check for a valid ACPI character. Must be one of: + * 1) Upper case alpha + * 2) numeric + * 3) underscore + * + * We allow a '!' as the last character because of the ASF! table + * + ******************************************************************************/ + +BOOLEAN +AcpiUtValidAcpiChar ( + char Character, + UINT32 Position) +{ + + if (!((Character >= 'A' && Character <= 'Z') || + (Character >= '0' && Character <= '9') || + (Character == '_'))) + { + /* Allow a '!' in the last position */ + + if (Character == '!' && Position == 3) + { + return (TRUE); + } + + return (FALSE); + } + + return (TRUE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtValidAcpiName + * + * PARAMETERS: Name - The name to be examined + * + * RETURN: TRUE if the name is valid, FALSE otherwise + * + * DESCRIPTION: Check for a valid ACPI name. Each character must be one of: + * 1) Upper case alpha + * 2) numeric + * 3) underscore + * + ******************************************************************************/ + +BOOLEAN +AcpiUtValidAcpiName ( + UINT32 Name) +{ + UINT32 i; + + + ACPI_FUNCTION_ENTRY (); + + + for (i = 0; i < ACPI_NAME_SIZE; i++) + { + if (!AcpiUtValidAcpiChar ((ACPI_CAST_PTR (char, &Name))[i], i)) + { + return (FALSE); + } + } + + return (TRUE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtRepairName + * + * PARAMETERS: Name - The ACPI name to be repaired + * + * RETURN: Repaired version of the name + * + * DESCRIPTION: Repair an ACPI name: Change invalid characters to '*' and + * return the new name. NOTE: the Name parameter must reside in + * read/write memory, cannot be a const. + * + * An ACPI Name must consist of valid ACPI characters. We will repair the name + * if necessary because we don't want to abort because of this, but we want + * all namespace names to be printable. A warning message is appropriate. + * + * This issue came up because there are in fact machines that exhibit + * this problem, and we want to be able to enable ACPI support for them, + * even though there are a few bad names. + * + ******************************************************************************/ + +void +AcpiUtRepairName ( + char *Name) +{ + UINT32 i; + BOOLEAN FoundBadChar = FALSE; + + + ACPI_FUNCTION_NAME (UtRepairName); + + + /* Check each character in the name */ + + for (i = 0; i < ACPI_NAME_SIZE; i++) + { + if (AcpiUtValidAcpiChar (Name[i], i)) + { + continue; + } + + /* + * Replace a bad character with something printable, yet technically + * still invalid. This prevents any collisions with existing "good" + * names in the namespace. + */ + Name[i] = '*'; + FoundBadChar = TRUE; + } + + if (FoundBadChar) + { + /* Report warning only if in strict mode or debug mode */ + + if (!AcpiGbl_EnableInterpreterSlack) + { + ACPI_WARNING ((AE_INFO, + "Found bad character(s) in name, repaired: [%4.4s]\n", Name)); + } + else + { + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Found bad character(s) in name, repaired: [%4.4s]\n", Name)); + } + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtStrtoul64 + * + * PARAMETERS: String - Null terminated string + * Base - Radix of the string: 16 or ACPI_ANY_BASE; + * ACPI_ANY_BASE means 'in behalf of ToInteger' + * RetInteger - Where the converted integer is returned + * + * RETURN: Status and Converted value + * + * DESCRIPTION: Convert a string into an unsigned value. Performs either a + * 32-bit or 64-bit conversion, depending on the current mode + * of the interpreter. + * NOTE: Does not support Octal strings, not needed. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtStrtoul64 ( + char *String, + UINT32 Base, + ACPI_INTEGER *RetInteger) +{ + UINT32 ThisDigit = 0; + ACPI_INTEGER ReturnValue = 0; + ACPI_INTEGER Quotient; + ACPI_INTEGER Dividend; + UINT32 ToIntegerOp = (Base == ACPI_ANY_BASE); + UINT32 Mode32 = (AcpiGbl_IntegerByteWidth == 4); + UINT8 ValidDigits = 0; + UINT8 SignOf0x = 0; + UINT8 Term = 0; + + + ACPI_FUNCTION_TRACE_STR (UtStroul64, String); + + + switch (Base) + { + case ACPI_ANY_BASE: + case 16: + break; + + default: + /* Invalid Base */ + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + if (!String) + { + goto ErrorExit; + } + + /* Skip over any white space in the buffer */ + + while ((*String) && (ACPI_IS_SPACE (*String) || *String == '\t')) + { + String++; + } + + if (ToIntegerOp) + { + /* + * Base equal to ACPI_ANY_BASE means 'ToInteger operation case'. + * We need to determine if it is decimal or hexadecimal. + */ + if ((*String == '0') && (ACPI_TOLOWER (*(String + 1)) == 'x')) + { + SignOf0x = 1; + Base = 16; + + /* Skip over the leading '0x' */ + String += 2; + } + else + { + Base = 10; + } + } + + /* Any string left? Check that '0x' is not followed by white space. */ + + if (!(*String) || ACPI_IS_SPACE (*String) || *String == '\t') + { + if (ToIntegerOp) + { + goto ErrorExit; + } + else + { + goto AllDone; + } + } + + /* + * Perform a 32-bit or 64-bit conversion, depending upon the current + * execution mode of the interpreter + */ + Dividend = (Mode32) ? ACPI_UINT32_MAX : ACPI_UINT64_MAX; + + /* Main loop: convert the string to a 32- or 64-bit integer */ + + while (*String) + { + if (ACPI_IS_DIGIT (*String)) + { + /* Convert ASCII 0-9 to Decimal value */ + + ThisDigit = ((UINT8) *String) - '0'; + } + else if (Base == 10) + { + /* Digit is out of range; possible in ToInteger case only */ + + Term = 1; + } + else + { + ThisDigit = (UINT8) ACPI_TOUPPER (*String); + if (ACPI_IS_XDIGIT ((char) ThisDigit)) + { + /* Convert ASCII Hex char to value */ + + ThisDigit = ThisDigit - 'A' + 10; + } + else + { + Term = 1; + } + } + + if (Term) + { + if (ToIntegerOp) + { + goto ErrorExit; + } + else + { + break; + } + } + else if ((ValidDigits == 0) && (ThisDigit == 0) && !SignOf0x) + { + /* Skip zeros */ + String++; + continue; + } + + ValidDigits++; + + if (SignOf0x && ((ValidDigits > 16) || ((ValidDigits > 8) && Mode32))) + { + /* + * This is ToInteger operation case. + * No any restrictions for string-to-integer conversion, + * see ACPI spec. + */ + goto ErrorExit; + } + + /* Divide the digit into the correct position */ + + (void) AcpiUtShortDivide ((Dividend - (ACPI_INTEGER) ThisDigit), + Base, &Quotient, NULL); + + if (ReturnValue > Quotient) + { + if (ToIntegerOp) + { + goto ErrorExit; + } + else + { + break; + } + } + + ReturnValue *= Base; + ReturnValue += ThisDigit; + String++; + } + + /* All done, normal exit */ + +AllDone: + + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Converted value: %8.8X%8.8X\n", + ACPI_FORMAT_UINT64 (ReturnValue))); + + *RetInteger = ReturnValue; + return_ACPI_STATUS (AE_OK); + + +ErrorExit: + /* Base was set/validated above */ + + if (Base == 10) + { + return_ACPI_STATUS (AE_BAD_DECIMAL_CONSTANT); + } + else + { + return_ACPI_STATUS (AE_BAD_HEX_CONSTANT); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreateUpdateStateAndPush + * + * PARAMETERS: Object - Object to be added to the new state + * Action - Increment/Decrement + * StateList - List the state will be added to + * + * RETURN: Status + * + * DESCRIPTION: Create a new state and push it + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtCreateUpdateStateAndPush ( + ACPI_OPERAND_OBJECT *Object, + UINT16 Action, + ACPI_GENERIC_STATE **StateList) +{ + ACPI_GENERIC_STATE *State; + + + ACPI_FUNCTION_ENTRY (); + + + /* Ignore null objects; these are expected */ + + if (!Object) + { + return (AE_OK); + } + + State = AcpiUtCreateUpdateState (Object, Action); + if (!State) + { + return (AE_NO_MEMORY); + } + + AcpiUtPushGenericState (StateList, State); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtWalkPackageTree + * + * PARAMETERS: SourceObject - The package to walk + * TargetObject - Target object (if package is being copied) + * WalkCallback - Called once for each package element + * Context - Passed to the callback function + * + * RETURN: Status + * + * DESCRIPTION: Walk through a package + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtWalkPackageTree ( + ACPI_OPERAND_OBJECT *SourceObject, + void *TargetObject, + ACPI_PKG_CALLBACK WalkCallback, + void *Context) +{ + ACPI_STATUS Status = AE_OK; + ACPI_GENERIC_STATE *StateList = NULL; + ACPI_GENERIC_STATE *State; + UINT32 ThisIndex; + ACPI_OPERAND_OBJECT *ThisSourceObj; + + + ACPI_FUNCTION_TRACE (UtWalkPackageTree); + + + State = AcpiUtCreatePkgState (SourceObject, TargetObject, 0); + if (!State) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + + while (State) + { + /* Get one element of the package */ + + ThisIndex = State->Pkg.Index; + ThisSourceObj = (ACPI_OPERAND_OBJECT *) + State->Pkg.SourceObject->Package.Elements[ThisIndex]; + + /* + * Check for: + * 1) An uninitialized package element. It is completely + * legal to declare a package and leave it uninitialized + * 2) Not an internal object - can be a namespace node instead + * 3) Any type other than a package. Packages are handled in else + * case below. + */ + if ((!ThisSourceObj) || + (ACPI_GET_DESCRIPTOR_TYPE (ThisSourceObj) != ACPI_DESC_TYPE_OPERAND) || + (ThisSourceObj->Common.Type != ACPI_TYPE_PACKAGE)) + { + Status = WalkCallback (ACPI_COPY_TYPE_SIMPLE, ThisSourceObj, + State, Context); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + State->Pkg.Index++; + while (State->Pkg.Index >= State->Pkg.SourceObject->Package.Count) + { + /* + * We've handled all of the objects at this level, This means + * that we have just completed a package. That package may + * have contained one or more packages itself. + * + * Delete this state and pop the previous state (package). + */ + AcpiUtDeleteGenericState (State); + State = AcpiUtPopGenericState (&StateList); + + /* Finished when there are no more states */ + + if (!State) + { + /* + * We have handled all of the objects in the top level + * package just add the length of the package objects + * and exit + */ + return_ACPI_STATUS (AE_OK); + } + + /* + * Go back up a level and move the index past the just + * completed package object. + */ + State->Pkg.Index++; + } + } + else + { + /* This is a subobject of type package */ + + Status = WalkCallback (ACPI_COPY_TYPE_PACKAGE, ThisSourceObj, + State, Context); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Push the current state and create a new one + * The callback above returned a new target package object. + */ + AcpiUtPushGenericState (&StateList, State); + State = AcpiUtCreatePkgState (ThisSourceObj, + State->Pkg.ThisTargetObj, 0); + if (!State) + { + /* Free any stacked Update State objects */ + + while (StateList) + { + State = AcpiUtPopGenericState (&StateList); + AcpiUtDeleteGenericState (State); + } + return_ACPI_STATUS (AE_NO_MEMORY); + } + } + } + + /* We should never get here */ + + return_ACPI_STATUS (AE_AML_INTERNAL); +} + + +/******************************************************************************* + * + * 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); + ACPI_COMMON_MSG_SUFFIX; + 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); + ACPI_COMMON_MSG_SUFFIX; + 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); + ACPI_COMMON_MSG_SUFFIX; + 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) + + +/******************************************************************************* + * + * 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 args; + + + /* + * 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 Warning for %s: ", Pathname); + + va_start (args, Format); + AcpiOsVprintf (Format, args); + ACPI_COMMON_MSG_SUFFIX; + va_end (args); +} + +/******************************************************************************* + * + * 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 args; + + + /* + * 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 Info for %s: ", Pathname); + + va_start (args, Format); + AcpiOsVprintf (Format, args); + ACPI_COMMON_MSG_SUFFIX; + va_end (args); +} diff --git a/reactos/drivers/bus/acpi/acpica/utilities/utmutex.c b/reactos/drivers/bus/acpi/acpica/utilities/utmutex.c new file mode 100644 index 00000000000..f6e7cc36522 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/utilities/utmutex.c @@ -0,0 +1,477 @@ +/******************************************************************************* + * + * Module Name: utmutex - local mutex 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 __UTMUTEX_C__ + +#include "acpi.h" +#include "accommon.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); + + +/******************************************************************************* + * + * FUNCTION: AcpiUtMutexInitialize + * + * PARAMETERS: None. + * + * RETURN: Status + * + * DESCRIPTION: Create the system mutex objects. This includes mutexes, + * spin locks, and reader/writer locks. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtMutexInitialize ( + void) +{ + UINT32 i; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (UtMutexInitialize); + + + /* Create each of the predefined mutex objects */ + + for (i = 0; i < ACPI_NUM_MUTEX; i++) + { + Status = AcpiUtCreateMutex (i); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* Create the spinlocks for use at interrupt level */ + + Status = AcpiOsCreateLock (&AcpiGbl_GpeLock); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + Status = AcpiOsCreateLock (&AcpiGbl_HardwareLock); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Create the reader/writer lock for namespace access */ + + Status = AcpiUtCreateRwLock (&AcpiGbl_NamespaceRwLock); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtMutexTerminate + * + * PARAMETERS: None. + * + * RETURN: None. + * + * DESCRIPTION: Delete all of the system mutex objects. This includes mutexes, + * spin locks, and reader/writer locks. + * + ******************************************************************************/ + +void +AcpiUtMutexTerminate ( + void) +{ + UINT32 i; + + + ACPI_FUNCTION_TRACE (UtMutexTerminate); + + + /* Delete each predefined mutex object */ + + for (i = 0; i < ACPI_NUM_MUTEX; i++) + { + (void) AcpiUtDeleteMutex (i); + } + + /* Delete the spinlocks */ + + AcpiOsDeleteLock (AcpiGbl_GpeLock); + AcpiOsDeleteLock (AcpiGbl_HardwareLock); + + /* Delete the reader/writer lock */ + + AcpiUtDeleteRwLock (&AcpiGbl_NamespaceRwLock); + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreateMutex + * + * PARAMETERS: MutexID - ID of the mutex to be created + * + * RETURN: Status + * + * DESCRIPTION: Create a mutex object. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtCreateMutex ( + ACPI_MUTEX_HANDLE MutexId) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE_U32 (UtCreateMutex, MutexId); + + + if (MutexId > ACPI_MAX_MUTEX) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + if (!AcpiGbl_MutexInfo[MutexId].Mutex) + { + Status = AcpiOsCreateMutex (&AcpiGbl_MutexInfo[MutexId].Mutex); + AcpiGbl_MutexInfo[MutexId].ThreadId = ACPI_MUTEX_NOT_ACQUIRED; + AcpiGbl_MutexInfo[MutexId].UseCount = 0; + } + + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtDeleteMutex + * + * PARAMETERS: MutexID - ID of the mutex to be deleted + * + * RETURN: Status + * + * DESCRIPTION: Delete a mutex object. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtDeleteMutex ( + ACPI_MUTEX_HANDLE MutexId) +{ + + 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); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtAcquireMutex + * + * PARAMETERS: MutexID - ID of the mutex to be acquired + * + * RETURN: Status + * + * DESCRIPTION: Acquire a mutex object. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtAcquireMutex ( + ACPI_MUTEX_HANDLE MutexId) +{ + ACPI_STATUS Status; + ACPI_THREAD_ID ThisThreadId; + + + ACPI_FUNCTION_NAME (UtAcquireMutex); + + + if (MutexId > ACPI_MAX_MUTEX) + { + return (AE_BAD_PARAMETER); + } + + ThisThreadId = AcpiOsGetThreadId (); + +#ifdef ACPI_MUTEX_DEBUG + { + UINT32 i; + /* + * Mutex debug code, for internal debugging only. + * + * Deadlock prevention. Check if this thread owns any mutexes of value + * greater than or equal to this one. If so, the thread has violated + * the mutex ordering rule. This indicates a coding error somewhere in + * the ACPI subsystem code. + */ + for (i = MutexId; i < ACPI_NUM_MUTEX; i++) + { + if (AcpiGbl_MutexInfo[i].ThreadId == ThisThreadId) + { + if (i == MutexId) + { + ACPI_ERROR ((AE_INFO, + "Mutex [%s] already acquired by this thread [%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); + } + } + } +#endif + + ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, + "Thread %p attempting to acquire Mutex [%s]\n", + ACPI_CAST_PTR (void, 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))); + + AcpiGbl_MutexInfo[MutexId].UseCount++; + AcpiGbl_MutexInfo[MutexId].ThreadId = ThisThreadId; + } + else + { + ACPI_EXCEPTION ((AE_INFO, Status, + "Thread %p could not acquire Mutex [%X]", + ACPI_CAST_PTR (void, ThisThreadId), MutexId)); + } + + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtReleaseMutex + * + * PARAMETERS: MutexID - ID of the mutex to be released + * + * RETURN: Status + * + * DESCRIPTION: Release a mutex object. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtReleaseMutex ( + ACPI_MUTEX_HANDLE MutexId) +{ + ACPI_THREAD_ID ThisThreadId; + + + ACPI_FUNCTION_NAME (UtReleaseMutex); + + + ThisThreadId = AcpiOsGetThreadId (); + ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Thread %p releasing Mutex [%s]\n", + ACPI_CAST_PTR (void, ThisThreadId), AcpiUtGetMutexName (MutexId))); + + if (MutexId > ACPI_MAX_MUTEX) + { + return (AE_BAD_PARAMETER); + } + + /* + * Mutex must be acquired in order to release it! + */ + if (AcpiGbl_MutexInfo[MutexId].ThreadId == ACPI_MUTEX_NOT_ACQUIRED) + { + ACPI_ERROR ((AE_INFO, + "Mutex [%X] is not acquired, cannot release", MutexId)); + + return (AE_NOT_ACQUIRED); + } + +#ifdef ACPI_MUTEX_DEBUG + { + UINT32 i; + /* + * Mutex debug code, for internal debugging only. + * + * Deadlock prevention. Check if this thread owns any mutexes of value + * greater than this one. If so, the thread has violated the mutex + * ordering rule. This indicates a coding error somewhere in + * the ACPI subsystem code. + */ + for (i = MutexId; i < ACPI_NUM_MUTEX; i++) + { + if (AcpiGbl_MutexInfo[i].ThreadId == ThisThreadId) + { + if (i == MutexId) + { + continue; + } + + ACPI_ERROR ((AE_INFO, + "Invalid release order: owns [%s], releasing [%s]", + AcpiUtGetMutexName (i), AcpiUtGetMutexName (MutexId))); + + return (AE_RELEASE_DEADLOCK); + } + } + } +#endif + + /* Mark unlocked FIRST */ + + AcpiGbl_MutexInfo[MutexId].ThreadId = ACPI_MUTEX_NOT_ACQUIRED; + + AcpiOsReleaseMutex (AcpiGbl_MutexInfo[MutexId].Mutex); + return (AE_OK); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/utilities/utobject.c b/reactos/drivers/bus/acpi/acpica/utilities/utobject.c new file mode 100644 index 00000000000..5164744891b --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/utilities/utobject.c @@ -0,0 +1,859 @@ +/****************************************************************************** + * + * Module Name: utobject - ACPI object create/delete/size/cache routines + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __UTOBJECT_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acnamesp.h" + + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utobject") + +/* Local prototypes */ + +static ACPI_STATUS +AcpiUtGetSimpleObjectSize ( + ACPI_OPERAND_OBJECT *Obj, + ACPI_SIZE *ObjLength); + +static ACPI_STATUS +AcpiUtGetPackageObjectSize ( + ACPI_OPERAND_OBJECT *Obj, + ACPI_SIZE *ObjLength); + +static ACPI_STATUS +AcpiUtGetElementLength ( + UINT8 ObjectType, + ACPI_OPERAND_OBJECT *SourceObject, + ACPI_GENERIC_STATE *State, + void *Context); + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreateInternalObjectDbg + * + * PARAMETERS: ModuleName - Source file name of caller + * LineNumber - Line number of caller + * ComponentId - Component type of caller + * Type - ACPI Type of the new object + * + * RETURN: A new internal object, null on failure + * + * DESCRIPTION: Create and initialize a new internal object. + * + * NOTE: We always allocate the worst-case object descriptor because + * these objects are cached, and we want them to be + * one-size-satisifies-any-request. This in itself may not be + * the most memory efficient, but the efficiency of the object + * cache should more than make up for this! + * + ******************************************************************************/ + +ACPI_OPERAND_OBJECT * +AcpiUtCreateInternalObjectDbg ( + const char *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId, + ACPI_OBJECT_TYPE Type) +{ + ACPI_OPERAND_OBJECT *Object; + ACPI_OPERAND_OBJECT *SecondObject; + + + ACPI_FUNCTION_TRACE_STR (UtCreateInternalObjectDbg, + AcpiUtGetTypeName (Type)); + + + /* Allocate the raw object descriptor */ + + Object = AcpiUtAllocateObjectDescDbg (ModuleName, LineNumber, ComponentId); + if (!Object) + { + return_PTR (NULL); + } + + switch (Type) + { + case ACPI_TYPE_REGION: + case ACPI_TYPE_BUFFER_FIELD: + case ACPI_TYPE_LOCAL_BANK_FIELD: + + /* These types require a secondary object */ + + SecondObject = AcpiUtAllocateObjectDescDbg (ModuleName, + LineNumber, ComponentId); + if (!SecondObject) + { + AcpiUtDeleteObjectDesc (Object); + return_PTR (NULL); + } + + SecondObject->Common.Type = ACPI_TYPE_LOCAL_EXTRA; + SecondObject->Common.ReferenceCount = 1; + + /* Link the second object to the first */ + + Object->Common.NextObject = SecondObject; + break; + + default: + /* All others have no secondary object */ + break; + } + + /* Save the object type in the object descriptor */ + + Object->Common.Type = (UINT8) Type; + + /* Init the reference count */ + + Object->Common.ReferenceCount = 1; + + /* Any per-type initialization should go here */ + + return_PTR (Object); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreatePackageObject + * + * PARAMETERS: Count - Number of package elements + * + * RETURN: Pointer to a new Package object, null on failure + * + * DESCRIPTION: Create a fully initialized package object + * + ******************************************************************************/ + +ACPI_OPERAND_OBJECT * +AcpiUtCreatePackageObject ( + UINT32 Count) +{ + ACPI_OPERAND_OBJECT *PackageDesc; + ACPI_OPERAND_OBJECT **PackageElements; + + + ACPI_FUNCTION_TRACE_U32 (UtCreatePackageObject, Count); + + + /* Create a new Package object */ + + PackageDesc = AcpiUtCreateInternalObject (ACPI_TYPE_PACKAGE); + if (!PackageDesc) + { + return_PTR (NULL); + } + + /* + * Create the element array. Count+1 allows the array to be null + * terminated. + */ + PackageElements = ACPI_ALLOCATE_ZEROED ( + ((ACPI_SIZE) Count + 1) * sizeof (void *)); + if (!PackageElements) + { + ACPI_FREE (PackageDesc); + return_PTR (NULL); + } + + PackageDesc->Package.Count = Count; + PackageDesc->Package.Elements = PackageElements; + return_PTR (PackageDesc); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreateIntegerObject + * + * PARAMETERS: InitialValue - Initial value for the integer + * + * RETURN: Pointer to a new Integer object, null on failure + * + * DESCRIPTION: Create an initialized integer object + * + ******************************************************************************/ + +ACPI_OPERAND_OBJECT * +AcpiUtCreateIntegerObject ( + UINT64 InitialValue) +{ + ACPI_OPERAND_OBJECT *IntegerDesc; + + + ACPI_FUNCTION_TRACE (UtCreateIntegerObject); + + + /* Create and initialize a new integer object */ + + IntegerDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); + if (!IntegerDesc) + { + return_PTR (NULL); + } + + IntegerDesc->Integer.Value = InitialValue; + return_PTR (IntegerDesc); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreateBufferObject + * + * PARAMETERS: BufferSize - Size of buffer to be created + * + * RETURN: Pointer to a new Buffer object, null on failure + * + * DESCRIPTION: Create a fully initialized buffer object + * + ******************************************************************************/ + +ACPI_OPERAND_OBJECT * +AcpiUtCreateBufferObject ( + ACPI_SIZE BufferSize) +{ + ACPI_OPERAND_OBJECT *BufferDesc; + UINT8 *Buffer = NULL; + + + ACPI_FUNCTION_TRACE_U32 (UtCreateBufferObject, BufferSize); + + + /* Create a new Buffer object */ + + BufferDesc = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER); + if (!BufferDesc) + { + return_PTR (NULL); + } + + /* Create an actual buffer only if size > 0 */ + + if (BufferSize > 0) + { + /* Allocate the actual buffer */ + + Buffer = ACPI_ALLOCATE_ZEROED (BufferSize); + if (!Buffer) + { + ACPI_ERROR ((AE_INFO, "Could not allocate size %X", + (UINT32) BufferSize)); + AcpiUtRemoveReference (BufferDesc); + return_PTR (NULL); + } + } + + /* Complete buffer object initialization */ + + BufferDesc->Buffer.Flags |= AOPOBJ_DATA_VALID; + BufferDesc->Buffer.Pointer = Buffer; + BufferDesc->Buffer.Length = (UINT32) BufferSize; + + /* Return the new buffer descriptor */ + + return_PTR (BufferDesc); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreateStringObject + * + * PARAMETERS: StringSize - Size of string to be created. Does not + * include NULL terminator, this is added + * automatically. + * + * RETURN: Pointer to a new String object + * + * DESCRIPTION: Create a fully initialized string object + * + ******************************************************************************/ + +ACPI_OPERAND_OBJECT * +AcpiUtCreateStringObject ( + ACPI_SIZE StringSize) +{ + ACPI_OPERAND_OBJECT *StringDesc; + char *String; + + + ACPI_FUNCTION_TRACE_U32 (UtCreateStringObject, StringSize); + + + /* Create a new String object */ + + StringDesc = AcpiUtCreateInternalObject (ACPI_TYPE_STRING); + if (!StringDesc) + { + return_PTR (NULL); + } + + /* + * Allocate the actual string buffer -- (Size + 1) for NULL terminator. + * NOTE: Zero-length strings are NULL terminated + */ + String = ACPI_ALLOCATE_ZEROED (StringSize + 1); + if (!String) + { + ACPI_ERROR ((AE_INFO, "Could not allocate size %X", + (UINT32) StringSize)); + AcpiUtRemoveReference (StringDesc); + return_PTR (NULL); + } + + /* Complete string object initialization */ + + StringDesc->String.Pointer = String; + StringDesc->String.Length = (UINT32) StringSize; + + /* Return the new string descriptor */ + + return_PTR (StringDesc); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtValidInternalObject + * + * PARAMETERS: Object - Object to be validated + * + * RETURN: TRUE if object is valid, FALSE otherwise + * + * DESCRIPTION: Validate a pointer to be an ACPI_OPERAND_OBJECT + * + ******************************************************************************/ + +BOOLEAN +AcpiUtValidInternalObject ( + void *Object) +{ + + ACPI_FUNCTION_NAME (UtValidInternalObject); + + + /* Check for a null pointer */ + + if (!Object) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "**** Null Object Ptr\n")); + return (FALSE); + } + + /* Check the descriptor type field */ + + switch (ACPI_GET_DESCRIPTOR_TYPE (Object)) + { + case ACPI_DESC_TYPE_OPERAND: + + /* The object appears to be a valid ACPI_OPERAND_OBJECT */ + + return (TRUE); + + default: + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "%p is not not an ACPI operand obj [%s]\n", + Object, AcpiUtGetDescriptorName (Object))); + break; + } + + return (FALSE); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtAllocateObjectDescDbg + * + * PARAMETERS: ModuleName - Caller's module name (for error output) + * LineNumber - Caller's line number (for error output) + * ComponentId - Caller's component ID (for error output) + * + * RETURN: Pointer to newly allocated object descriptor. Null on error + * + * DESCRIPTION: Allocate a new object descriptor. Gracefully handle + * error conditions. + * + ******************************************************************************/ + +void * +AcpiUtAllocateObjectDescDbg ( + const char *ModuleName, + UINT32 LineNumber, + UINT32 ComponentId) +{ + ACPI_OPERAND_OBJECT *Object; + + + ACPI_FUNCTION_TRACE (UtAllocateObjectDescDbg); + + + Object = AcpiOsAcquireObject (AcpiGbl_OperandCache); + if (!Object) + { + ACPI_ERROR ((ModuleName, LineNumber, + "Could not allocate an object descriptor")); + + return_PTR (NULL); + } + + /* Mark the descriptor type */ + + ACPI_SET_DESCRIPTOR_TYPE (Object, ACPI_DESC_TYPE_OPERAND); + + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p Size %X\n", + Object, (UINT32) sizeof (ACPI_OPERAND_OBJECT))); + + return_PTR (Object); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtDeleteObjectDesc + * + * PARAMETERS: Object - An Acpi internal object to be deleted + * + * RETURN: None. + * + * DESCRIPTION: Free an ACPI object descriptor or add it to the object cache + * + ******************************************************************************/ + +void +AcpiUtDeleteObjectDesc ( + ACPI_OPERAND_OBJECT *Object) +{ + ACPI_FUNCTION_TRACE_PTR (UtDeleteObjectDesc, Object); + + + /* Object must be an ACPI_OPERAND_OBJECT */ + + if (ACPI_GET_DESCRIPTOR_TYPE (Object) != ACPI_DESC_TYPE_OPERAND) + { + ACPI_ERROR ((AE_INFO, + "%p is not an ACPI Operand object [%s]", Object, + AcpiUtGetDescriptorName (Object))); + return_VOID; + } + + (void) AcpiOsReleaseObject (AcpiGbl_OperandCache, Object); + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtGetSimpleObjectSize + * + * PARAMETERS: InternalObject - An ACPI operand object + * ObjLength - Where the length is returned + * + * RETURN: Status + * + * DESCRIPTION: This function is called to determine the space required to + * contain a simple object for return to an external user. + * + * The length includes the object structure plus any additional + * needed space. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtGetSimpleObjectSize ( + ACPI_OPERAND_OBJECT *InternalObject, + ACPI_SIZE *ObjLength) +{ + ACPI_SIZE Length; + ACPI_SIZE Size; + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE_PTR (UtGetSimpleObjectSize, InternalObject); + + + /* Start with the length of the (external) Acpi object */ + + Length = sizeof (ACPI_OBJECT); + + /* A NULL object is allowed, can be a legal uninitialized package element */ + + if (!InternalObject) + { + /* + * Object is NULL, just return the length of ACPI_OBJECT + * (A NULL ACPI_OBJECT is an object of all zeroes.) + */ + *ObjLength = ACPI_ROUND_UP_TO_NATIVE_WORD (Length); + return_ACPI_STATUS (AE_OK); + } + + /* A Namespace Node should never appear here */ + + if (ACPI_GET_DESCRIPTOR_TYPE (InternalObject) == ACPI_DESC_TYPE_NAMED) + { + /* A namespace node should never get here */ + + return_ACPI_STATUS (AE_AML_INTERNAL); + } + + /* + * The final length depends on the object type + * Strings and Buffers are packed right up against the parent object and + * must be accessed bytewise or there may be alignment problems on + * certain processors + */ + switch (InternalObject->Common.Type) + { + case ACPI_TYPE_STRING: + + Length += (ACPI_SIZE) InternalObject->String.Length + 1; + break; + + + case ACPI_TYPE_BUFFER: + + Length += (ACPI_SIZE) InternalObject->Buffer.Length; + break; + + + case ACPI_TYPE_INTEGER: + case ACPI_TYPE_PROCESSOR: + case ACPI_TYPE_POWER: + + /* No extra data for these types */ + + break; + + + case ACPI_TYPE_LOCAL_REFERENCE: + + switch (InternalObject->Reference.Class) + { + case ACPI_REFCLASS_NAME: + + /* + * Get the actual length of the full pathname to this object. + * The reference will be converted to the pathname to the object + */ + Size = AcpiNsGetPathnameLength (InternalObject->Reference.Node); + if (!Size) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + Length += ACPI_ROUND_UP_TO_NATIVE_WORD (Size); + break; + + default: + + /* + * No other reference opcodes are supported. + * Notably, Locals and Args are not supported, but this may be + * required eventually. + */ + ACPI_ERROR ((AE_INFO, "Cannot convert to external object - " + "unsupported Reference Class [%s] %X in object %p", + AcpiUtGetReferenceName (InternalObject), + InternalObject->Reference.Class, InternalObject)); + Status = AE_TYPE; + break; + } + break; + + + default: + + ACPI_ERROR ((AE_INFO, "Cannot convert to external object - " + "unsupported type [%s] %X in object %p", + AcpiUtGetObjectTypeName (InternalObject), + InternalObject->Common.Type, InternalObject)); + Status = AE_TYPE; + break; + } + + /* + * Account for the space required by the object rounded up to the next + * multiple of the machine word size. This keeps each object aligned + * on a machine word boundary. (preventing alignment faults on some + * machines.) + */ + *ObjLength = ACPI_ROUND_UP_TO_NATIVE_WORD (Length); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtGetElementLength + * + * PARAMETERS: ACPI_PKG_CALLBACK + * + * RETURN: Status + * + * DESCRIPTION: Get the length of one package element. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtGetElementLength ( + UINT8 ObjectType, + ACPI_OPERAND_OBJECT *SourceObject, + ACPI_GENERIC_STATE *State, + void *Context) +{ + ACPI_STATUS Status = AE_OK; + ACPI_PKG_INFO *Info = (ACPI_PKG_INFO *) Context; + ACPI_SIZE ObjectSpace; + + + switch (ObjectType) + { + case ACPI_COPY_TYPE_SIMPLE: + + /* + * Simple object - just get the size (Null object/entry is handled + * here also) and sum it into the running package length + */ + Status = AcpiUtGetSimpleObjectSize (SourceObject, &ObjectSpace); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + + Info->Length += ObjectSpace; + break; + + + case ACPI_COPY_TYPE_PACKAGE: + + /* Package object - nothing much to do here, let the walk handle it */ + + Info->NumPackages++; + State->Pkg.ThisTargetObj = NULL; + break; + + + default: + + /* No other types allowed */ + + return (AE_BAD_PARAMETER); + } + + return (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtGetPackageObjectSize + * + * PARAMETERS: InternalObject - An ACPI internal object + * ObjLength - Where the length is returned + * + * RETURN: Status + * + * DESCRIPTION: This function is called to determine the space required to + * contain a package object for return to an external user. + * + * This is moderately complex since a package contains other + * objects including packages. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtGetPackageObjectSize ( + ACPI_OPERAND_OBJECT *InternalObject, + ACPI_SIZE *ObjLength) +{ + ACPI_STATUS Status; + ACPI_PKG_INFO Info; + + + ACPI_FUNCTION_TRACE_PTR (UtGetPackageObjectSize, InternalObject); + + + Info.Length = 0; + Info.ObjectSpace = 0; + Info.NumPackages = 1; + + Status = AcpiUtWalkPackageTree (InternalObject, NULL, + AcpiUtGetElementLength, &Info); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * We have handled all of the objects in all levels of the package. + * just add the length of the package objects themselves. + * Round up to the next machine word. + */ + Info.Length += ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)) * + (ACPI_SIZE) Info.NumPackages; + + /* Return the total package length */ + + *ObjLength = Info.Length; + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtGetObjectSize + * + * PARAMETERS: InternalObject - An ACPI internal object + * ObjLength - Where the length will be returned + * + * RETURN: Status + * + * DESCRIPTION: This function is called to determine the space required to + * contain an object for return to an API user. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtGetObjectSize ( + ACPI_OPERAND_OBJECT *InternalObject, + ACPI_SIZE *ObjLength) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_ENTRY (); + + + if ((ACPI_GET_DESCRIPTOR_TYPE (InternalObject) == ACPI_DESC_TYPE_OPERAND) && + (InternalObject->Common.Type == ACPI_TYPE_PACKAGE)) + { + Status = AcpiUtGetPackageObjectSize (InternalObject, ObjLength); + } + else + { + Status = AcpiUtGetSimpleObjectSize (InternalObject, ObjLength); + } + + return (Status); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/utilities/utresrc.c b/reactos/drivers/bus/acpi/acpica/utilities/utresrc.c new file mode 100644 index 00000000000..2f19d639868 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/utilities/utresrc.c @@ -0,0 +1,772 @@ +/******************************************************************************* + * + * Module Name: utresrc - Resource managment utilities + * + ******************************************************************************/ + +/****************************************************************************** + * + * 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 __UTRESRC_C__ + +#include "acpi.h" +#include "accommon.h" +#include "amlresrc.h" + + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utresrc") + + +#if defined(ACPI_DISASSEMBLER) || defined (ACPI_DEBUGGER) + +/* + * Strings used to decode resource descriptors. + * Used by both the disasssembler and the debugger resource dump routines + */ +const char *AcpiGbl_BmDecode[] = +{ + "NotBusMaster", + "BusMaster" +}; + +const char *AcpiGbl_ConfigDecode[] = +{ + "0 - Good Configuration", + "1 - Acceptable Configuration", + "2 - Suboptimal Configuration", + "3 - ***Invalid Configuration***", +}; + +const char *AcpiGbl_ConsumeDecode[] = +{ + "ResourceProducer", + "ResourceConsumer" +}; + +const char *AcpiGbl_DecDecode[] = +{ + "PosDecode", + "SubDecode" +}; + +const char *AcpiGbl_HeDecode[] = +{ + "Level", + "Edge" +}; + +const char *AcpiGbl_IoDecode[] = +{ + "Decode10", + "Decode16" +}; + +const char *AcpiGbl_LlDecode[] = +{ + "ActiveHigh", + "ActiveLow" +}; + +const char *AcpiGbl_MaxDecode[] = +{ + "MaxNotFixed", + "MaxFixed" +}; + +const char *AcpiGbl_MemDecode[] = +{ + "NonCacheable", + "Cacheable", + "WriteCombining", + "Prefetchable" +}; + +const char *AcpiGbl_MinDecode[] = +{ + "MinNotFixed", + "MinFixed" +}; + +const char *AcpiGbl_MtpDecode[] = +{ + "AddressRangeMemory", + "AddressRangeReserved", + "AddressRangeACPI", + "AddressRangeNVS" +}; + +const char *AcpiGbl_RngDecode[] = +{ + "InvalidRanges", + "NonISAOnlyRanges", + "ISAOnlyRanges", + "EntireRange" +}; + +const char *AcpiGbl_RwDecode[] = +{ + "ReadOnly", + "ReadWrite" +}; + +const char *AcpiGbl_ShrDecode[] = +{ + "Exclusive", + "Shared" +}; + +const char *AcpiGbl_SizDecode[] = +{ + "Transfer8", + "Transfer8_16", + "Transfer16", + "InvalidSize" +}; + +const char *AcpiGbl_TrsDecode[] = +{ + "DenseTranslation", + "SparseTranslation" +}; + +const char *AcpiGbl_TtpDecode[] = +{ + "TypeStatic", + "TypeTranslation" +}; + +const char *AcpiGbl_TypDecode[] = +{ + "Compatibility", + "TypeA", + "TypeB", + "TypeF" +}; + +#endif + + +/* + * Base sizes of the raw AML resource descriptors, indexed by resource type. + * Zero indicates a reserved (and therefore invalid) resource type. + */ +const UINT8 AcpiGbl_ResourceAmlSizes[] = +{ + /* Small descriptors */ + + 0, + 0, + 0, + 0, + ACPI_AML_SIZE_SMALL (AML_RESOURCE_IRQ), + ACPI_AML_SIZE_SMALL (AML_RESOURCE_DMA), + ACPI_AML_SIZE_SMALL (AML_RESOURCE_START_DEPENDENT), + ACPI_AML_SIZE_SMALL (AML_RESOURCE_END_DEPENDENT), + ACPI_AML_SIZE_SMALL (AML_RESOURCE_IO), + ACPI_AML_SIZE_SMALL (AML_RESOURCE_FIXED_IO), + 0, + 0, + 0, + 0, + ACPI_AML_SIZE_SMALL (AML_RESOURCE_VENDOR_SMALL), + ACPI_AML_SIZE_SMALL (AML_RESOURCE_END_TAG), + + /* Large descriptors */ + + 0, + ACPI_AML_SIZE_LARGE (AML_RESOURCE_MEMORY24), + ACPI_AML_SIZE_LARGE (AML_RESOURCE_GENERIC_REGISTER), + 0, + ACPI_AML_SIZE_LARGE (AML_RESOURCE_VENDOR_LARGE), + ACPI_AML_SIZE_LARGE (AML_RESOURCE_MEMORY32), + ACPI_AML_SIZE_LARGE (AML_RESOURCE_FIXED_MEMORY32), + ACPI_AML_SIZE_LARGE (AML_RESOURCE_ADDRESS32), + ACPI_AML_SIZE_LARGE (AML_RESOURCE_ADDRESS16), + ACPI_AML_SIZE_LARGE (AML_RESOURCE_EXTENDED_IRQ), + ACPI_AML_SIZE_LARGE (AML_RESOURCE_ADDRESS64), + ACPI_AML_SIZE_LARGE (AML_RESOURCE_EXTENDED_ADDRESS64) +}; + + +/* + * Resource types, used to validate the resource length field. + * The length of fixed-length types must match exactly, variable + * lengths must meet the minimum required length, etc. + * Zero indicates a reserved (and therefore invalid) resource type. + */ +static const UINT8 AcpiGbl_ResourceTypes[] = +{ + /* Small descriptors */ + + 0, + 0, + 0, + 0, + ACPI_SMALL_VARIABLE_LENGTH, + ACPI_FIXED_LENGTH, + ACPI_SMALL_VARIABLE_LENGTH, + ACPI_FIXED_LENGTH, + ACPI_FIXED_LENGTH, + ACPI_FIXED_LENGTH, + 0, + 0, + 0, + 0, + ACPI_VARIABLE_LENGTH, + ACPI_FIXED_LENGTH, + + /* Large descriptors */ + + 0, + ACPI_FIXED_LENGTH, + ACPI_FIXED_LENGTH, + 0, + ACPI_VARIABLE_LENGTH, + ACPI_FIXED_LENGTH, + ACPI_FIXED_LENGTH, + ACPI_VARIABLE_LENGTH, + ACPI_VARIABLE_LENGTH, + ACPI_VARIABLE_LENGTH, + ACPI_VARIABLE_LENGTH, + ACPI_FIXED_LENGTH +}; + + +/******************************************************************************* + * + * FUNCTION: AcpiUtWalkAmlResources + * + * PARAMETERS: Aml - Pointer to the raw AML resource template + * AmlLength - Length of the entire template + * UserFunction - Called once for each descriptor found. If + * NULL, a pointer to the EndTag is returned + * Context - Passed to UserFunction + * + * RETURN: Status + * + * DESCRIPTION: Walk a raw AML resource list(buffer). User function called + * once for each resource found. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtWalkAmlResources ( + UINT8 *Aml, + ACPI_SIZE AmlLength, + ACPI_WALK_AML_CALLBACK UserFunction, + void *Context) +{ + ACPI_STATUS Status; + UINT8 *EndAml; + UINT8 ResourceIndex; + UINT32 Length; + UINT32 Offset = 0; + + + ACPI_FUNCTION_TRACE (UtWalkAmlResources); + + + /* The absolute minimum resource template is one EndTag descriptor */ + + if (AmlLength < sizeof (AML_RESOURCE_END_TAG)) + { + return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG); + } + + /* Point to the end of the resource template buffer */ + + EndAml = Aml + AmlLength; + + /* Walk the byte list, abort on any invalid descriptor type or length */ + + while (Aml < EndAml) + { + /* Validate the Resource Type and Resource Length */ + + Status = AcpiUtValidateResource (Aml, &ResourceIndex); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Get the length of this descriptor */ + + Length = AcpiUtGetDescriptorLength (Aml); + + /* Invoke the user function */ + + if (UserFunction) + { + Status = UserFunction (Aml, Length, Offset, ResourceIndex, Context); + if (ACPI_FAILURE (Status)) + { + return (Status); + } + } + + /* An EndTag descriptor terminates this resource template */ + + if (AcpiUtGetResourceType (Aml) == ACPI_RESOURCE_NAME_END_TAG) + { + /* + * There must be at least one more byte in the buffer for + * the 2nd byte of the EndTag + */ + if ((Aml + 1) >= EndAml) + { + return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG); + } + + /* Return the pointer to the EndTag if requested */ + + if (!UserFunction) + { + *(void **) Context = Aml; + } + + /* Normal exit */ + + return_ACPI_STATUS (AE_OK); + } + + Aml += Length; + Offset += Length; + } + + /* Did not find an EndTag descriptor */ + + return (AE_AML_NO_RESOURCE_END_TAG); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtValidateResource + * + * PARAMETERS: Aml - Pointer to the raw AML resource descriptor + * ReturnIndex - Where the resource index is returned. NULL + * if the index is not required. + * + * RETURN: Status, and optionally the Index into the global resource tables + * + * DESCRIPTION: Validate an AML resource descriptor by checking the Resource + * Type and Resource Length. Returns an index into the global + * resource information/dispatch tables for later use. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtValidateResource ( + void *Aml, + UINT8 *ReturnIndex) +{ + UINT8 ResourceType; + UINT8 ResourceIndex; + ACPI_RS_LENGTH ResourceLength; + ACPI_RS_LENGTH MinimumResourceLength; + + + ACPI_FUNCTION_ENTRY (); + + + /* + * 1) Validate the ResourceType field (Byte 0) + */ + ResourceType = ACPI_GET8 (Aml); + + /* + * Byte 0 contains the descriptor name (Resource Type) + * Examine the large/small bit in the resource header + */ + if (ResourceType & ACPI_RESOURCE_NAME_LARGE) + { + /* Verify the large resource type (name) against the max */ + + if (ResourceType > ACPI_RESOURCE_NAME_LARGE_MAX) + { + return (AE_AML_INVALID_RESOURCE_TYPE); + } + + /* + * Large Resource Type -- bits 6:0 contain the name + * Translate range 0x80-0x8B to index range 0x10-0x1B + */ + ResourceIndex = (UINT8) (ResourceType - 0x70); + } + else + { + /* + * Small Resource Type -- bits 6:3 contain the name + * Shift range to index range 0x00-0x0F + */ + ResourceIndex = (UINT8) + ((ResourceType & ACPI_RESOURCE_NAME_SMALL_MASK) >> 3); + } + + /* Check validity of the resource type, zero indicates name is invalid */ + + if (!AcpiGbl_ResourceTypes[ResourceIndex]) + { + return (AE_AML_INVALID_RESOURCE_TYPE); + } + + + /* + * 2) Validate the ResourceLength field. This ensures that the length + * is at least reasonable, and guarantees that it is non-zero. + */ + ResourceLength = AcpiUtGetResourceLength (Aml); + MinimumResourceLength = AcpiGbl_ResourceAmlSizes[ResourceIndex]; + + /* Validate based upon the type of resource - fixed length or variable */ + + switch (AcpiGbl_ResourceTypes[ResourceIndex]) + { + case ACPI_FIXED_LENGTH: + + /* Fixed length resource, length must match exactly */ + + if (ResourceLength != MinimumResourceLength) + { + return (AE_AML_BAD_RESOURCE_LENGTH); + } + break; + + case ACPI_VARIABLE_LENGTH: + + /* Variable length resource, length must be at least the minimum */ + + if (ResourceLength < MinimumResourceLength) + { + return (AE_AML_BAD_RESOURCE_LENGTH); + } + break; + + case ACPI_SMALL_VARIABLE_LENGTH: + + /* Small variable length resource, length can be (Min) or (Min-1) */ + + if ((ResourceLength > MinimumResourceLength) || + (ResourceLength < (MinimumResourceLength - 1))) + { + return (AE_AML_BAD_RESOURCE_LENGTH); + } + break; + + default: + + /* Shouldn't happen (because of validation earlier), but be sure */ + + return (AE_AML_INVALID_RESOURCE_TYPE); + } + + /* Optionally return the resource table index */ + + if (ReturnIndex) + { + *ReturnIndex = ResourceIndex; + } + + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtGetResourceType + * + * PARAMETERS: Aml - Pointer to the raw AML resource descriptor + * + * RETURN: The Resource Type with no extraneous bits (except the + * Large/Small descriptor bit -- this is left alone) + * + * DESCRIPTION: Extract the Resource Type/Name from the first byte of + * a resource descriptor. + * + ******************************************************************************/ + +UINT8 +AcpiUtGetResourceType ( + void *Aml) +{ + ACPI_FUNCTION_ENTRY (); + + + /* + * Byte 0 contains the descriptor name (Resource Type) + * Examine the large/small bit in the resource header + */ + if (ACPI_GET8 (Aml) & ACPI_RESOURCE_NAME_LARGE) + { + /* Large Resource Type -- bits 6:0 contain the name */ + + return (ACPI_GET8 (Aml)); + } + else + { + /* Small Resource Type -- bits 6:3 contain the name */ + + return ((UINT8) (ACPI_GET8 (Aml) & ACPI_RESOURCE_NAME_SMALL_MASK)); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtGetResourceLength + * + * PARAMETERS: Aml - Pointer to the raw AML resource descriptor + * + * RETURN: Byte Length + * + * DESCRIPTION: Get the "Resource Length" of a raw AML descriptor. By + * definition, this does not include the size of the descriptor + * header or the length field itself. + * + ******************************************************************************/ + +UINT16 +AcpiUtGetResourceLength ( + void *Aml) +{ + ACPI_RS_LENGTH ResourceLength; + + + ACPI_FUNCTION_ENTRY (); + + + /* + * Byte 0 contains the descriptor name (Resource Type) + * Examine the large/small bit in the resource header + */ + if (ACPI_GET8 (Aml) & ACPI_RESOURCE_NAME_LARGE) + { + /* Large Resource type -- bytes 1-2 contain the 16-bit length */ + + ACPI_MOVE_16_TO_16 (&ResourceLength, ACPI_ADD_PTR (UINT8, Aml, 1)); + + } + else + { + /* Small Resource type -- bits 2:0 of byte 0 contain the length */ + + ResourceLength = (UINT16) (ACPI_GET8 (Aml) & + ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK); + } + + return (ResourceLength); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtGetResourceHeaderLength + * + * PARAMETERS: Aml - Pointer to the raw AML resource descriptor + * + * RETURN: Length of the AML header (depends on large/small descriptor) + * + * DESCRIPTION: Get the length of the header for this resource. + * + ******************************************************************************/ + +UINT8 +AcpiUtGetResourceHeaderLength ( + void *Aml) +{ + ACPI_FUNCTION_ENTRY (); + + + /* Examine the large/small bit in the resource header */ + + if (ACPI_GET8 (Aml) & ACPI_RESOURCE_NAME_LARGE) + { + return (sizeof (AML_RESOURCE_LARGE_HEADER)); + } + else + { + return (sizeof (AML_RESOURCE_SMALL_HEADER)); + } +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtGetDescriptorLength + * + * PARAMETERS: Aml - Pointer to the raw AML resource descriptor + * + * RETURN: Byte length + * + * DESCRIPTION: Get the total byte length of a raw AML descriptor, including the + * length of the descriptor header and the length field itself. + * Used to walk descriptor lists. + * + ******************************************************************************/ + +UINT32 +AcpiUtGetDescriptorLength ( + void *Aml) +{ + ACPI_FUNCTION_ENTRY (); + + + /* + * Get the Resource Length (does not include header length) and add + * the header length (depends on if this is a small or large resource) + */ + return (AcpiUtGetResourceLength (Aml) + + AcpiUtGetResourceHeaderLength (Aml)); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtGetResourceEndTag + * + * PARAMETERS: ObjDesc - The resource template buffer object + * EndTag - Where the pointer to the EndTag is returned + * + * RETURN: Status, pointer to the end tag + * + * DESCRIPTION: Find the EndTag resource descriptor in an AML resource template + * Note: allows a buffer length of zero. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtGetResourceEndTag ( + ACPI_OPERAND_OBJECT *ObjDesc, + UINT8 **EndTag) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (UtGetResourceEndTag); + + + /* Allow a buffer length of zero */ + + if (!ObjDesc->Buffer.Length) + { + *EndTag = ObjDesc->Buffer.Pointer; + return_ACPI_STATUS (AE_OK); + } + + /* Validate the template and get a pointer to the EndTag */ + + Status = AcpiUtWalkAmlResources (ObjDesc->Buffer.Pointer, + ObjDesc->Buffer.Length, NULL, EndTag); + + return_ACPI_STATUS (Status); +} + + diff --git a/reactos/drivers/bus/acpi/acpica/utilities/utstate.c b/reactos/drivers/bus/acpi/acpica/utilities/utstate.c new file mode 100644 index 00000000000..245ca02bfc5 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/utilities/utstate.c @@ -0,0 +1,470 @@ +/******************************************************************************* + * + * Module Name: utstate - state object support procedures + * + ******************************************************************************/ + +/****************************************************************************** + * + * 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 __UTSTATE_C__ + +#include "acpi.h" +#include "accommon.h" + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utstate") + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreatePkgStateAndPush + * + * PARAMETERS: Object - Object to be added to the new state + * Action - Increment/Decrement + * StateList - List the state will be added to + * + * RETURN: Status + * + * DESCRIPTION: Create a new state and push it + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtCreatePkgStateAndPush ( + void *InternalObject, + void *ExternalObject, + UINT16 Index, + ACPI_GENERIC_STATE **StateList) +{ + ACPI_GENERIC_STATE *State; + + + ACPI_FUNCTION_ENTRY (); + + + State = AcpiUtCreatePkgState (InternalObject, ExternalObject, Index); + if (!State) + { + return (AE_NO_MEMORY); + } + + AcpiUtPushGenericState (StateList, State); + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtPushGenericState + * + * PARAMETERS: ListHead - Head of the state stack + * State - State object to push + * + * RETURN: None + * + * DESCRIPTION: Push a state object onto a state stack + * + ******************************************************************************/ + +void +AcpiUtPushGenericState ( + ACPI_GENERIC_STATE **ListHead, + ACPI_GENERIC_STATE *State) +{ + ACPI_FUNCTION_TRACE (UtPushGenericState); + + + /* Push the state object onto the front of the list (stack) */ + + State->Common.Next = *ListHead; + *ListHead = State; + + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtPopGenericState + * + * PARAMETERS: ListHead - Head of the state stack + * + * RETURN: The popped state object + * + * DESCRIPTION: Pop a state object from a state stack + * + ******************************************************************************/ + +ACPI_GENERIC_STATE * +AcpiUtPopGenericState ( + ACPI_GENERIC_STATE **ListHead) +{ + ACPI_GENERIC_STATE *State; + + + ACPI_FUNCTION_TRACE (UtPopGenericState); + + + /* Remove the state object at the head of the list (stack) */ + + State = *ListHead; + if (State) + { + /* Update the list head */ + + *ListHead = State->Common.Next; + } + + return_PTR (State); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreateGenericState + * + * PARAMETERS: None + * + * RETURN: The new state object. NULL on failure. + * + * DESCRIPTION: Create a generic state object. Attempt to obtain one from + * the global state cache; If none available, create a new one. + * + ******************************************************************************/ + +ACPI_GENERIC_STATE * +AcpiUtCreateGenericState ( + void) +{ + ACPI_GENERIC_STATE *State; + + + ACPI_FUNCTION_ENTRY (); + + + State = AcpiOsAcquireObject (AcpiGbl_StateCache); + if (State) + { + /* Initialize */ + State->Common.DescriptorType = ACPI_DESC_TYPE_STATE; + } + + return (State); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreateThreadState + * + * PARAMETERS: None + * + * RETURN: New Thread State. NULL on failure + * + * DESCRIPTION: Create a "Thread State" - a flavor of the generic state used + * to track per-thread info during method execution + * + ******************************************************************************/ + +ACPI_THREAD_STATE * +AcpiUtCreateThreadState ( + void) +{ + ACPI_GENERIC_STATE *State; + + + ACPI_FUNCTION_TRACE (UtCreateThreadState); + + + /* Create the generic state object */ + + State = AcpiUtCreateGenericState (); + if (!State) + { + return_PTR (NULL); + } + + /* Init fields specific to the update struct */ + + State->Common.DescriptorType = ACPI_DESC_TYPE_STATE_THREAD; + State->Thread.ThreadId = AcpiOsGetThreadId (); + + /* Check for invalid thread ID - zero is very bad, it will break things */ + + if (!State->Thread.ThreadId) + { + ACPI_ERROR ((AE_INFO, "Invalid zero ID from AcpiOsGetThreadId")); + State->Thread.ThreadId = (ACPI_THREAD_ID) 1; + } + + return_PTR ((ACPI_THREAD_STATE *) State); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreateUpdateState + * + * PARAMETERS: Object - Initial Object to be installed in the state + * Action - Update action to be performed + * + * RETURN: New state object, null on failure + * + * DESCRIPTION: Create an "Update State" - a flavor of the generic state used + * to update reference counts and delete complex objects such + * as packages. + * + ******************************************************************************/ + +ACPI_GENERIC_STATE * +AcpiUtCreateUpdateState ( + ACPI_OPERAND_OBJECT *Object, + UINT16 Action) +{ + ACPI_GENERIC_STATE *State; + + + ACPI_FUNCTION_TRACE_PTR (UtCreateUpdateState, Object); + + + /* Create the generic state object */ + + State = AcpiUtCreateGenericState (); + if (!State) + { + return_PTR (NULL); + } + + /* Init fields specific to the update struct */ + + State->Common.DescriptorType = ACPI_DESC_TYPE_STATE_UPDATE; + State->Update.Object = Object; + State->Update.Value = Action; + + return_PTR (State); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreatePkgState + * + * PARAMETERS: Object - Initial Object to be installed in the state + * Action - Update action to be performed + * + * RETURN: New state object, null on failure + * + * DESCRIPTION: Create a "Package State" + * + ******************************************************************************/ + +ACPI_GENERIC_STATE * +AcpiUtCreatePkgState ( + void *InternalObject, + void *ExternalObject, + UINT16 Index) +{ + ACPI_GENERIC_STATE *State; + + + ACPI_FUNCTION_TRACE_PTR (UtCreatePkgState, InternalObject); + + + /* Create the generic state object */ + + State = AcpiUtCreateGenericState (); + if (!State) + { + return_PTR (NULL); + } + + /* Init fields specific to the update struct */ + + State->Common.DescriptorType = ACPI_DESC_TYPE_STATE_PACKAGE; + State->Pkg.SourceObject = (ACPI_OPERAND_OBJECT *) InternalObject; + State->Pkg.DestObject = ExternalObject; + State->Pkg.Index= Index; + State->Pkg.NumPackages = 1; + + return_PTR (State); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreateControlState + * + * PARAMETERS: None + * + * RETURN: New state object, null on failure + * + * DESCRIPTION: Create a "Control State" - a flavor of the generic state used + * to support nested IF/WHILE constructs in the AML. + * + ******************************************************************************/ + +ACPI_GENERIC_STATE * +AcpiUtCreateControlState ( + void) +{ + ACPI_GENERIC_STATE *State; + + + ACPI_FUNCTION_TRACE (UtCreateControlState); + + + /* Create the generic state object */ + + State = AcpiUtCreateGenericState (); + if (!State) + { + return_PTR (NULL); + } + + /* Init fields specific to the control struct */ + + State->Common.DescriptorType = ACPI_DESC_TYPE_STATE_CONTROL; + State->Common.State = ACPI_CONTROL_CONDITIONAL_EXECUTING; + + return_PTR (State); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtDeleteGenericState + * + * PARAMETERS: State - The state object to be deleted + * + * RETURN: None + * + * DESCRIPTION: Release a state object to the state cache. NULL state objects + * are ignored. + * + ******************************************************************************/ + +void +AcpiUtDeleteGenericState ( + ACPI_GENERIC_STATE *State) +{ + ACPI_FUNCTION_TRACE (UtDeleteGenericState); + + + /* Ignore null state */ + + if (State) + { + (void) AcpiOsReleaseObject (AcpiGbl_StateCache, State); + } + return_VOID; +} + + diff --git a/reactos/drivers/bus/acpi/acpica/utilities/uttrack.c b/reactos/drivers/bus/acpi/acpica/utilities/uttrack.c new file mode 100644 index 00000000000..d712c1a3e5a --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/utilities/uttrack.c @@ -0,0 +1,726 @@ +/****************************************************************************** + * + * Module Name: uttrack - Memory allocation tracking routines (debug only) + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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. + * + *****************************************************************************/ + +/* + * These procedures are used for tracking memory leaks in the subsystem, and + * they get compiled out when the ACPI_DBG_TRACK_ALLOCATIONS is not set. + * + * Each memory allocation is tracked via a doubly linked list. Each + * element contains the caller's component, module name, function name, and + * line number. AcpiUtAllocate and AcpiUtAllocateZeroed call + * AcpiUtTrackAllocation to add an element to the list; deletion + * occurs in the body of AcpiUtFree. + */ + +#define __UTTRACK_C__ + +#include "acpi.h" +#include "accommon.h" + +#ifdef ACPI_DBG_TRACK_ALLOCATIONS + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("uttrack") + +/* Local prototypes */ + +static ACPI_DEBUG_MEM_BLOCK * +AcpiUtFindAllocation ( + void *Allocation); + +static ACPI_STATUS +AcpiUtTrackAllocation ( + ACPI_DEBUG_MEM_BLOCK *Address, + ACPI_SIZE Size, + UINT8 AllocType, + UINT32 Component, + const char *Module, + UINT32 Line); + +static ACPI_STATUS +AcpiUtRemoveAllocation ( + ACPI_DEBUG_MEM_BLOCK *Address, + UINT32 Component, + const char *Module, + UINT32 Line); + + +/******************************************************************************* + * + * FUNCTION: AcpiUtCreateList + * + * PARAMETERS: CacheName - Ascii name for the cache + * ObjectSize - Size of each cached object + * ReturnCache - Where the new cache object is returned + * + * RETURN: Status + * + * DESCRIPTION: Create a local memory list for tracking purposed + * + ******************************************************************************/ + +ACPI_STATUS +AcpiUtCreateList ( + char *ListName, + UINT16 ObjectSize, + ACPI_MEMORY_LIST **ReturnCache) +{ + ACPI_MEMORY_LIST *Cache; + + + Cache = AcpiOsAllocate (sizeof (ACPI_MEMORY_LIST)); + if (!Cache) + { + return (AE_NO_MEMORY); + } + + ACPI_MEMSET (Cache, 0, sizeof (ACPI_MEMORY_LIST)); + + Cache->ListName = ListName; + Cache->ObjectSize = ObjectSize; + + *ReturnCache = Cache; + return (AE_OK); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtAllocateAndTrack + * + * PARAMETERS: Size - Size of the allocation + * Component - Component type of caller + * Module - Source file name of caller + * Line - Line number of caller + * + * RETURN: Address of the allocated memory on success, NULL on failure. + * + * DESCRIPTION: The subsystem's equivalent of malloc. + * + ******************************************************************************/ + +void * +AcpiUtAllocateAndTrack ( + ACPI_SIZE Size, + UINT32 Component, + const char *Module, + UINT32 Line) +{ + ACPI_DEBUG_MEM_BLOCK *Allocation; + ACPI_STATUS Status; + + + Allocation = AcpiUtAllocate (Size + sizeof (ACPI_DEBUG_MEM_HEADER), + Component, Module, Line); + if (!Allocation) + { + return (NULL); + } + + Status = AcpiUtTrackAllocation (Allocation, Size, + ACPI_MEM_MALLOC, Component, Module, Line); + if (ACPI_FAILURE (Status)) + { + AcpiOsFree (Allocation); + return (NULL); + } + + AcpiGbl_GlobalList->TotalAllocated++; + AcpiGbl_GlobalList->TotalSize += (UINT32) Size; + AcpiGbl_GlobalList->CurrentTotalSize += (UINT32) Size; + if (AcpiGbl_GlobalList->CurrentTotalSize > AcpiGbl_GlobalList->MaxOccupied) + { + AcpiGbl_GlobalList->MaxOccupied = AcpiGbl_GlobalList->CurrentTotalSize; + } + + return ((void *) &Allocation->UserSpace); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtAllocateZeroedAndTrack + * + * PARAMETERS: Size - Size of the allocation + * Component - Component type of caller + * Module - Source file name of caller + * Line - Line number of caller + * + * RETURN: Address of the allocated memory on success, NULL on failure. + * + * DESCRIPTION: Subsystem equivalent of calloc. + * + ******************************************************************************/ + +void * +AcpiUtAllocateZeroedAndTrack ( + ACPI_SIZE Size, + UINT32 Component, + const char *Module, + UINT32 Line) +{ + ACPI_DEBUG_MEM_BLOCK *Allocation; + ACPI_STATUS Status; + + + Allocation = AcpiUtAllocateZeroed (Size + sizeof (ACPI_DEBUG_MEM_HEADER), + Component, Module, Line); + if (!Allocation) + { + /* Report allocation error */ + + ACPI_ERROR ((Module, Line, + "Could not allocate size %X", (UINT32) Size)); + return (NULL); + } + + Status = AcpiUtTrackAllocation (Allocation, Size, + ACPI_MEM_CALLOC, Component, Module, Line); + if (ACPI_FAILURE (Status)) + { + AcpiOsFree (Allocation); + return (NULL); + } + + AcpiGbl_GlobalList->TotalAllocated++; + AcpiGbl_GlobalList->TotalSize += (UINT32) Size; + AcpiGbl_GlobalList->CurrentTotalSize += (UINT32) Size; + if (AcpiGbl_GlobalList->CurrentTotalSize > AcpiGbl_GlobalList->MaxOccupied) + { + AcpiGbl_GlobalList->MaxOccupied = AcpiGbl_GlobalList->CurrentTotalSize; + } + + return ((void *) &Allocation->UserSpace); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtFreeAndTrack + * + * PARAMETERS: Allocation - Address of the memory to deallocate + * Component - Component type of caller + * Module - Source file name of caller + * Line - Line number of caller + * + * RETURN: None + * + * DESCRIPTION: Frees the memory at Allocation + * + ******************************************************************************/ + +void +AcpiUtFreeAndTrack ( + void *Allocation, + UINT32 Component, + const char *Module, + UINT32 Line) +{ + ACPI_DEBUG_MEM_BLOCK *DebugBlock; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE_PTR (UtFree, Allocation); + + + if (NULL == Allocation) + { + ACPI_ERROR ((Module, Line, + "Attempt to delete a NULL address")); + + return_VOID; + } + + DebugBlock = ACPI_CAST_PTR (ACPI_DEBUG_MEM_BLOCK, + (((char *) Allocation) - sizeof (ACPI_DEBUG_MEM_HEADER))); + + AcpiGbl_GlobalList->TotalFreed++; + AcpiGbl_GlobalList->CurrentTotalSize -= DebugBlock->Size; + + Status = AcpiUtRemoveAllocation (DebugBlock, + Component, Module, Line); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, "Could not free memory")); + } + + AcpiOsFree (DebugBlock); + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p freed\n", Allocation)); + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtFindAllocation + * + * PARAMETERS: Allocation - Address of allocated memory + * + * RETURN: A list element if found; NULL otherwise. + * + * DESCRIPTION: Searches for an element in the global allocation tracking list. + * + ******************************************************************************/ + +static ACPI_DEBUG_MEM_BLOCK * +AcpiUtFindAllocation ( + void *Allocation) +{ + ACPI_DEBUG_MEM_BLOCK *Element; + + + ACPI_FUNCTION_ENTRY (); + + + Element = AcpiGbl_GlobalList->ListHead; + + /* Search for the address. */ + + while (Element) + { + if (Element == Allocation) + { + return (Element); + } + + Element = Element->Next; + } + + return (NULL); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtTrackAllocation + * + * PARAMETERS: Allocation - Address of allocated memory + * Size - Size of the allocation + * AllocType - MEM_MALLOC or MEM_CALLOC + * Component - Component type of caller + * Module - Source file name of caller + * Line - Line number of caller + * + * RETURN: None. + * + * DESCRIPTION: Inserts an element into the global allocation tracking list. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtTrackAllocation ( + ACPI_DEBUG_MEM_BLOCK *Allocation, + ACPI_SIZE Size, + UINT8 AllocType, + UINT32 Component, + const char *Module, + UINT32 Line) +{ + ACPI_MEMORY_LIST *MemList; + ACPI_DEBUG_MEM_BLOCK *Element; + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE_PTR (UtTrackAllocation, Allocation); + + + MemList = AcpiGbl_GlobalList; + Status = AcpiUtAcquireMutex (ACPI_MTX_MEMORY); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Search list for this address to make sure it is not already on the list. + * This will catch several kinds of problems. + */ + Element = AcpiUtFindAllocation (Allocation); + if (Element) + { + ACPI_ERROR ((AE_INFO, + "UtTrackAllocation: Allocation already present in list! (%p)", + Allocation)); + + ACPI_ERROR ((AE_INFO, "Element %p Address %p", + Element, Allocation)); + + goto UnlockAndExit; + } + + /* Fill in the instance data. */ + + Allocation->Size = (UINT32) Size; + Allocation->AllocType = AllocType; + Allocation->Component = Component; + Allocation->Line = Line; + + ACPI_STRNCPY (Allocation->Module, Module, ACPI_MAX_MODULE_NAME); + Allocation->Module[ACPI_MAX_MODULE_NAME-1] = 0; + + /* Insert at list head */ + + if (MemList->ListHead) + { + ((ACPI_DEBUG_MEM_BLOCK *)(MemList->ListHead))->Previous = Allocation; + } + + Allocation->Next = MemList->ListHead; + Allocation->Previous = NULL; + + MemList->ListHead = Allocation; + + +UnlockAndExit: + Status = AcpiUtReleaseMutex (ACPI_MTX_MEMORY); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtRemoveAllocation + * + * PARAMETERS: Allocation - Address of allocated memory + * Component - Component type of caller + * Module - Source file name of caller + * Line - Line number of caller + * + * RETURN: + * + * DESCRIPTION: Deletes an element from the global allocation tracking list. + * + ******************************************************************************/ + +static ACPI_STATUS +AcpiUtRemoveAllocation ( + ACPI_DEBUG_MEM_BLOCK *Allocation, + UINT32 Component, + const char *Module, + UINT32 Line) +{ + ACPI_MEMORY_LIST *MemList; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (UtRemoveAllocation); + + + MemList = AcpiGbl_GlobalList; + if (NULL == MemList->ListHead) + { + /* No allocations! */ + + ACPI_ERROR ((Module, Line, + "Empty allocation list, nothing to free!")); + + return_ACPI_STATUS (AE_OK); + } + + Status = AcpiUtAcquireMutex (ACPI_MTX_MEMORY); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Unlink */ + + if (Allocation->Previous) + { + (Allocation->Previous)->Next = Allocation->Next; + } + else + { + MemList->ListHead = Allocation->Next; + } + + if (Allocation->Next) + { + (Allocation->Next)->Previous = Allocation->Previous; + } + + /* Mark the segment as deleted */ + + ACPI_MEMSET (&Allocation->UserSpace, 0xEA, Allocation->Size); + + ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Freeing size 0%X\n", + Allocation->Size)); + + Status = AcpiUtReleaseMutex (ACPI_MTX_MEMORY); + return_ACPI_STATUS (Status); +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtDumpAllocationInfo + * + * PARAMETERS: + * + * RETURN: None + * + * DESCRIPTION: Print some info about the outstanding allocations. + * + ******************************************************************************/ + +void +AcpiUtDumpAllocationInfo ( + void) +{ +/* + ACPI_MEMORY_LIST *MemList; +*/ + + ACPI_FUNCTION_TRACE (UtDumpAllocationInfo); + +/* + ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, + ("%30s: %4d (%3d Kb)\n", "Current allocations", + MemList->CurrentCount, + ROUND_UP_TO_1K (MemList->CurrentSize))); + + ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, + ("%30s: %4d (%3d Kb)\n", "Max concurrent allocations", + MemList->MaxConcurrentCount, + ROUND_UP_TO_1K (MemList->MaxConcurrentSize))); + + + ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, + ("%30s: %4d (%3d Kb)\n", "Total (all) internal objects", + RunningObjectCount, + ROUND_UP_TO_1K (RunningObjectSize))); + + ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, + ("%30s: %4d (%3d Kb)\n", "Total (all) allocations", + RunningAllocCount, + ROUND_UP_TO_1K (RunningAllocSize))); + + + ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, + ("%30s: %4d (%3d Kb)\n", "Current Nodes", + AcpiGbl_CurrentNodeCount, + ROUND_UP_TO_1K (AcpiGbl_CurrentNodeSize))); + + ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, + ("%30s: %4d (%3d Kb)\n", "Max Nodes", + AcpiGbl_MaxConcurrentNodeCount, + ROUND_UP_TO_1K ((AcpiGbl_MaxConcurrentNodeCount * + sizeof (ACPI_NAMESPACE_NODE))))); +*/ + return_VOID; +} + + +/******************************************************************************* + * + * FUNCTION: AcpiUtDumpAllocations + * + * PARAMETERS: Component - Component(s) to dump info for. + * Module - Module to dump info for. NULL means all. + * + * RETURN: None + * + * DESCRIPTION: Print a list of all outstanding allocations. + * + ******************************************************************************/ + +void +AcpiUtDumpAllocations ( + UINT32 Component, + const char *Module) +{ + ACPI_DEBUG_MEM_BLOCK *Element; + ACPI_DESCRIPTOR *Descriptor; + UINT32 NumOutstanding = 0; + + + ACPI_FUNCTION_TRACE (UtDumpAllocations); + + + /* + * Walk the allocation list. + */ + if (ACPI_FAILURE (AcpiUtAcquireMutex (ACPI_MTX_MEMORY))) + { + return; + } + + Element = AcpiGbl_GlobalList->ListHead; + while (Element) + { + if ((Element->Component & Component) && + ((Module == NULL) || (0 == ACPI_STRCMP (Module, Element->Module)))) + { + /* 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) + { + AcpiOsPrintf ("%p Len %04X %9.9s-%d [%s] ", + Descriptor, Element->Size, Element->Module, + Element->Line, AcpiUtGetDescriptorName (Descriptor)); + + /* Most of the elements will be Operand objects. */ + + switch (ACPI_GET_DESCRIPTOR_TYPE (Descriptor)) + { + 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 ( "\n"); + NumOutstanding++; + } + } + Element = Element->Next; + } + + (void) AcpiUtReleaseMutex (ACPI_MTX_MEMORY); + + /* Print summary */ + + if (!NumOutstanding) + { + ACPI_INFO ((AE_INFO, + "No outstanding allocations")); + } + else + { + ACPI_ERROR ((AE_INFO, + "%d(%X) Outstanding allocations", + NumOutstanding, NumOutstanding)); + } + + return_VOID; +} + +#endif /* ACPI_DBG_TRACK_ALLOCATIONS */ + diff --git a/reactos/drivers/bus/acpi/acpica/utilities/utxface.c b/reactos/drivers/bus/acpi/acpica/utilities/utxface.c new file mode 100644 index 00000000000..ba57f4922b7 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpica/utilities/utxface.c @@ -0,0 +1,734 @@ +/****************************************************************************** + * + * Module Name: utxface - External interfaces for "global" ACPI functions + * + *****************************************************************************/ + +/****************************************************************************** + * + * 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 __UTXFACE_C__ + +#include "acpi.h" +#include "accommon.h" +#include "acevents.h" +#include "acnamesp.h" +#include "acdebug.h" +#include "actables.h" + +#define _COMPONENT ACPI_UTILITIES + ACPI_MODULE_NAME ("utxface") + + +#ifndef ACPI_ASL_COMPILER + +/******************************************************************************* + * + * FUNCTION: AcpiInitializeSubsystem + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Initializes all global variables. This is the first function + * called, so any early initialization belongs here. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiInitializeSubsystem ( + void) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiInitializeSubsystem); + + + AcpiGbl_StartupFlags = ACPI_SUBSYSTEM_INITIALIZE; + ACPI_DEBUG_EXEC (AcpiUtInitStackPtrTrace ()); + + /* Initialize the OS-Dependent layer */ + + Status = AcpiOsInitialize (); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, "During OSL initialization")); + return_ACPI_STATUS (Status); + } + + /* Initialize all globals used by the subsystem */ + + Status = AcpiUtInitGlobals (); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, "During initialization of globals")); + return_ACPI_STATUS (Status); + } + + /* Create the default mutex objects */ + + Status = AcpiUtMutexInitialize (); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, "During Global Mutex creation")); + return_ACPI_STATUS (Status); + } + + /* + * Initialize the namespace manager and + * the root of the namespace tree + */ + Status = AcpiNsRootInitialize (); + if (ACPI_FAILURE (Status)) + { + ACPI_EXCEPTION ((AE_INFO, Status, "During Namespace initialization")); + return_ACPI_STATUS (Status); + } + + /* If configured, initialize the AML debugger */ + + ACPI_DEBUGGER_EXEC (Status = AcpiDbInitialize ()); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiInitializeSubsystem) + + +/******************************************************************************* + * + * FUNCTION: AcpiEnableSubsystem + * + * PARAMETERS: Flags - Init/enable Options + * + * RETURN: Status + * + * DESCRIPTION: Completes the subsystem initialization including hardware. + * Puts system into ACPI mode if it isn't already. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiEnableSubsystem ( + UINT32 Flags) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (AcpiEnableSubsystem); + + + /* Enable ACPI mode */ + + if (!(Flags & ACPI_NO_ACPI_ENABLE)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Going into ACPI mode\n")); + + AcpiGbl_OriginalMode = AcpiHwGetMode(); + + Status = AcpiEnable (); + if (ACPI_FAILURE (Status)) + { + ACPI_WARNING ((AE_INFO, "AcpiEnable failed")); + return_ACPI_STATUS (Status); + } + } + + /* + * Obtain a permanent mapping for the FACS. This is required for the + * Global Lock and the Firmware Waking Vector + */ + Status = AcpiTbInitializeFacs (); + if (ACPI_FAILURE (Status)) + { + ACPI_WARNING ((AE_INFO, "Could not map the FACS table")); + return_ACPI_STATUS (Status); + } + + /* + * Install the default OpRegion handlers. These are installed unless + * other handlers have already been installed via the + * InstallAddressSpaceHandler interface. + */ + if (!(Flags & ACPI_NO_ADDRESS_SPACE_INIT)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "[Init] Installing default address space handlers\n")); + + Status = AcpiEvInstallRegionHandlers (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* + * Initialize ACPI Event handling (Fixed and General Purpose) + * + * Note1: We must have the hardware and events initialized before we can + * execute any control methods safely. Any control method can require + * ACPI hardware support, so the hardware must be fully initialized before + * any method execution! + * + * Note2: Fixed events are initialized and enabled here. GPEs are + * initialized, but cannot be enabled until after the hardware is + * completely initialized (SCI and GlobalLock activated) and the various + * initialization control methods are run (_REG, _STA, _INI) on the + * entire namespace. + */ + if (!(Flags & ACPI_NO_EVENT_INIT)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "[Init] Initializing ACPI events\n")); + + Status = AcpiEvInitializeEvents (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* + * Install the SCI handler and Global Lock handler. This completes the + * hardware initialization. + */ + if (!(Flags & ACPI_NO_HANDLER_INIT)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "[Init] Installing SCI/GL handlers\n")); + + Status = AcpiEvInstallXruptHandlers (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiEnableSubsystem) + + +/******************************************************************************* + * + * FUNCTION: AcpiInitializeObjects + * + * PARAMETERS: Flags - Init/enable Options + * + * RETURN: Status + * + * DESCRIPTION: Completes namespace initialization by initializing device + * objects and executing AML code for Regions, buffers, etc. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiInitializeObjects ( + UINT32 Flags) +{ + ACPI_STATUS Status = AE_OK; + + + ACPI_FUNCTION_TRACE (AcpiInitializeObjects); + + + /* + * Run all _REG methods + * + * Note: Any objects accessed by the _REG methods will be automatically + * initialized, even if they contain executable AML (see the call to + * AcpiNsInitializeObjects below). + */ + if (!(Flags & ACPI_NO_ADDRESS_SPACE_INIT)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "[Init] Executing _REG OpRegion methods\n")); + + Status = AcpiEvInitializeOpRegions (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* + * Execute any module-level code that was detected during the table load + * phase. Although illegal since ACPI 2.0, there are many machines that + * contain this type of code. Each block of detected executable AML code + * outside of any control method is wrapped with a temporary control + * method object and placed on a global list. The methods on this list + * are executed below. + */ + AcpiNsExecModuleCodeList (); + + /* + * Initialize the objects that remain uninitialized. This runs the + * executable AML that may be part of the declaration of these objects: + * OperationRegions, BufferFields, Buffers, and Packages. + */ + if (!(Flags & ACPI_NO_OBJECT_INIT)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "[Init] Completing Initialization of ACPI Objects\n")); + + Status = AcpiNsInitializeObjects (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* + * Initialize all device objects in the namespace. This runs the device + * _STA and _INI methods. + */ + if (!(Flags & ACPI_NO_DEVICE_INIT)) + { + ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, + "[Init] Initializing ACPI Devices\n")); + + Status = AcpiNsInitializeDevices (); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + } + + /* + * 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 -- + * thus wasting non-paged memory. + */ + Status = AcpiPurgeCachedObjects (); + + AcpiGbl_StartupFlags |= ACPI_INITIALIZED_OK; + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiInitializeObjects) + + +#endif + +/******************************************************************************* + * + * FUNCTION: AcpiTerminate + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Shutdown the ACPICA subsystem and release all resources. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiTerminate ( + void) +{ + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiTerminate); + + + /* Just exit if subsystem is already shutdown */ + + if (AcpiGbl_Shutdown) + { + ACPI_ERROR ((AE_INFO, "ACPI Subsystem is already terminated")); + return_ACPI_STATUS (AE_OK); + } + + /* Subsystem appears active, go ahead and shut it down */ + + AcpiGbl_Shutdown = TRUE; + AcpiGbl_StartupFlags = 0; + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Shutting down ACPI Subsystem\n")); + + /* Terminate the AML Debugger if present */ + + ACPI_DEBUGGER_EXEC (AcpiGbl_DbTerminateThreads = TRUE); + + /* Shutdown and free all resources */ + + AcpiUtSubsystemShutdown (); + + /* Free the mutex objects */ + + AcpiUtMutexTerminate (); + + +#ifdef ACPI_DEBUGGER + + /* Shut down the debugger */ + + AcpiDbTerminate (); +#endif + + /* Now we can shutdown the OS-dependent layer */ + + Status = AcpiOsTerminate (); + return_ACPI_STATUS (Status); +} + +ACPI_EXPORT_SYMBOL (AcpiTerminate) + + +#ifndef ACPI_ASL_COMPILER +/******************************************************************************* + * + * FUNCTION: AcpiSubsystemStatus + * + * PARAMETERS: None + * + * RETURN: Status of the ACPI subsystem + * + * DESCRIPTION: Other drivers that use the ACPI subsystem should call this + * before making any other calls, to ensure the subsystem + * initialized successfully. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiSubsystemStatus ( + void) +{ + + if (AcpiGbl_StartupFlags & ACPI_INITIALIZED_OK) + { + return (AE_OK); + } + else + { + return (AE_ERROR); + } +} + +ACPI_EXPORT_SYMBOL (AcpiSubsystemStatus) + + +/******************************************************************************* + * + * FUNCTION: AcpiGetSystemInfo + * + * PARAMETERS: OutBuffer - A buffer to receive the resources for the + * device + * + * RETURN: Status - the status of the call + * + * DESCRIPTION: This function is called to get information about the current + * state of the ACPI subsystem. It will return system information + * in the OutBuffer. + * + * If the function fails an appropriate status will be returned + * and the value of OutBuffer is undefined. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetSystemInfo ( + ACPI_BUFFER *OutBuffer) +{ + ACPI_SYSTEM_INFO *InfoPtr; + ACPI_STATUS Status; + + + ACPI_FUNCTION_TRACE (AcpiGetSystemInfo); + + + /* Parameter validation */ + + Status = AcpiUtValidateBuffer (OutBuffer); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Validate/Allocate/Clear caller buffer */ + + Status = AcpiUtInitializeBuffer (OutBuffer, sizeof (ACPI_SYSTEM_INFO)); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* + * Populate the return buffer + */ + InfoPtr = (ACPI_SYSTEM_INFO *) OutBuffer->Pointer; + + InfoPtr->AcpiCaVersion = ACPI_CA_VERSION; + + /* System flags (ACPI capabilities) */ + + InfoPtr->Flags = ACPI_SYS_MODE_ACPI; + + /* Timer resolution - 24 or 32 bits */ + + if (AcpiGbl_FADT.Flags & ACPI_FADT_32BIT_TIMER) + { + InfoPtr->TimerResolution = 24; + } + else + { + InfoPtr->TimerResolution = 32; + } + + /* Clear the reserved fields */ + + InfoPtr->Reserved1 = 0; + InfoPtr->Reserved2 = 0; + + /* Current debug levels */ + + InfoPtr->DebugLayer = AcpiDbgLayer; + InfoPtr->DebugLevel = AcpiDbgLevel; + + return_ACPI_STATUS (AE_OK); +} + +ACPI_EXPORT_SYMBOL (AcpiGetSystemInfo) + + +/******************************************************************************* + * + * FUNCTION: AcpiGetStatistics + * + * PARAMETERS: Stats - Where the statistics are returned + * + * RETURN: Status - the status of the call + * + * DESCRIPTION: Get the contents of the various system counters + * + ******************************************************************************/ + +ACPI_STATUS +AcpiGetStatistics ( + ACPI_STATISTICS *Stats) +{ + ACPI_FUNCTION_TRACE (AcpiGetStatistics); + + + /* Parameter validation */ + + if (!Stats) + { + return_ACPI_STATUS (AE_BAD_PARAMETER); + } + + /* Various interrupt-based event counters */ + + Stats->SciCount = AcpiSciCount; + Stats->GpeCount = AcpiGpeCount; + + ACPI_MEMCPY (Stats->FixedEventCount, AcpiFixedEventCount, + sizeof (AcpiFixedEventCount)); + + + /* Other counters */ + + Stats->MethodCount = AcpiMethodCount; + + return_ACPI_STATUS (AE_OK); +} + +ACPI_EXPORT_SYMBOL (AcpiGetStatistics) + + +/***************************************************************************** + * + * FUNCTION: AcpiInstallInitializationHandler + * + * PARAMETERS: Handler - Callback procedure + * Function - Not (currently) used, see below + * + * RETURN: Status + * + * DESCRIPTION: Install an initialization handler + * + * TBD: When a second function is added, must save the Function also. + * + ****************************************************************************/ + +ACPI_STATUS +AcpiInstallInitializationHandler ( + ACPI_INIT_HANDLER Handler, + UINT32 Function) +{ + + if (!Handler) + { + return (AE_BAD_PARAMETER); + } + + if (AcpiGbl_InitHandler) + { + return (AE_ALREADY_EXISTS); + } + + AcpiGbl_InitHandler = Handler; + return AE_OK; +} + +ACPI_EXPORT_SYMBOL (AcpiInstallInitializationHandler) + + +/***************************************************************************** + * + * FUNCTION: AcpiPurgeCachedObjects + * + * PARAMETERS: None + * + * RETURN: Status + * + * DESCRIPTION: Empty all caches (delete the cached objects) + * + ****************************************************************************/ + +ACPI_STATUS +AcpiPurgeCachedObjects ( + void) +{ + ACPI_FUNCTION_TRACE (AcpiPurgeCachedObjects); + + (void) AcpiOsPurgeCache (AcpiGbl_StateCache); + (void) AcpiOsPurgeCache (AcpiGbl_OperandCache); + (void) AcpiOsPurgeCache (AcpiGbl_PsNodeCache); + (void) AcpiOsPurgeCache (AcpiGbl_PsNodeExtCache); + return_ACPI_STATUS (AE_OK); +} + +ACPI_EXPORT_SYMBOL (AcpiPurgeCachedObjects) + +#endif /* ACPI_ASL_COMPILER */ + diff --git a/reactos/drivers/bus/acpi/acpienum.c b/reactos/drivers/bus/acpi/acpienum.c new file mode 100644 index 00000000000..c011dbadd63 --- /dev/null +++ b/reactos/drivers/bus/acpi/acpienum.c @@ -0,0 +1,155 @@ +/* $Id: acpienum.c 21698 2006-04-22 05:55:17Z tretiakov $ + * + * PROJECT: ReactOS ACPI bus driver + * FILE: acpi/ospm/acpienum.c + * PURPOSE: ACPI namespace enumerator + * PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net) + * UPDATE HISTORY: + * 01-05-2001 CSH Created + */ +#include +#include +#include +#include +#include + +#define NDEBUG +#include + +#define HAS_CHILDREN(d) ((d)->children.next != &((d)->children)) +#define HAS_SIBLINGS(d) (((d)->parent) && ((d)->node.next != &(d)->parent->children)) +#define NODE_TO_DEVICE(n) (list_entry(n, struct acpi_device, node)) + +extern struct acpi_device *acpi_root; + +NTSTATUS +Bus_PlugInDevice ( + struct acpi_device *Device, + PFDO_DEVICE_DATA FdoData + ) +{ + PDEVICE_OBJECT pdo; + PPDO_DEVICE_DATA pdoData; + NTSTATUS status; + ULONG index; + WCHAR temp[256]; + PLIST_ENTRY entry; + + PAGED_CODE (); + + //Don't enumerate the root device + if (Device->handle == ACPI_ROOT_OBJECT) + return STATUS_SUCCESS; + + /* Check we didnt add this already */ + for (entry = FdoData->ListOfPDOs.Flink; + entry != &FdoData->ListOfPDOs; entry = entry->Flink) + { + pdoData = CONTAINING_RECORD (entry, PDO_DEVICE_DATA, Link); + //dont duplicate devices + if(pdoData->AcpiHandle == Device->handle) + return STATUS_SUCCESS; + } + + DPRINT("Exposing PDO\n" + "======AcpiHandle: %p\n" + "======HardwareId: %s\n", + Device->handle, + Device->pnp.hardware_id); + + + // + // Create the PDO + // + + DPRINT("FdoData->NextLowerDriver = 0x%p\n", FdoData->NextLowerDriver); + + status = IoCreateDevice(FdoData->Common.Self->DriverObject, + sizeof(PDO_DEVICE_DATA), + NULL, + FILE_DEVICE_CONTROLLER, + FILE_AUTOGENERATED_DEVICE_NAME, + FALSE, + &pdo); + + if (!NT_SUCCESS (status)) { + return status; + } + + pdoData = (PPDO_DEVICE_DATA) pdo->DeviceExtension; + pdoData->AcpiHandle = Device->handle; + + // + // Copy the hardware IDs + // + index = 0; + index += swprintf(&temp[index], + L"ACPI\\%hs", + Device->pnp.hardware_id); + index++; + + index += swprintf(&temp[index], + L"*%hs", + Device->pnp.hardware_id); + index++; + temp[index] = UNICODE_NULL; + + pdoData->HardwareIDs = ExAllocatePool(NonPagedPool, index*sizeof(WCHAR)); + + + if (!pdoData->HardwareIDs) { + IoDeleteDevice(pdo); + return STATUS_INSUFFICIENT_RESOURCES; + } + + RtlCopyMemory (pdoData->HardwareIDs, temp, index*sizeof(WCHAR)); + Bus_InitializePdo (pdo, FdoData); + + // + // Device Relation changes if a new pdo is created. So let + // the PNP system now about that. This forces it to send bunch of pnp + // queries and cause the function driver to be loaded. + // + + //IoInvalidateDeviceRelations (FdoData->UnderlyingPDO, BusRelations); + + return status; +} + + +/* looks alot like acpi_bus_walk doesnt it */ +NTSTATUS +ACPIEnumerateDevices(PFDO_DEVICE_DATA DeviceExtension) +{ + ULONG Count = 0; + struct acpi_device *Device = acpi_root; + + while(Device) + { + if (Device->status.present && Device->status.enabled && + Device->flags.hardware_id) + { + Bus_PlugInDevice(Device, DeviceExtension); + Count++; + } + + if (HAS_CHILDREN(Device)) { + Device = NODE_TO_DEVICE(Device->children.next); + continue; + } + if (HAS_SIBLINGS(Device)) { + Device = NODE_TO_DEVICE(Device->node.next); + continue; + } + while ((Device = Device->parent)) { + if (HAS_SIBLINGS(Device)) { + Device = NODE_TO_DEVICE(Device->node.next); + break; + } + } + } + DPRINT("acpi device count: %d\n", Count); + return STATUS_SUCCESS; +} + +/* EOF */ diff --git a/reactos/drivers/bus/acpi/busmgr/bus.c b/reactos/drivers/bus/acpi/busmgr/bus.c new file mode 100644 index 00000000000..34aa0766c04 --- /dev/null +++ b/reactos/drivers/bus/acpi/busmgr/bus.c @@ -0,0 +1,1858 @@ +/* + * acpi_bus.c - ACPI Bus Driver ($Revision: 80 $) + * + * Copyright (C) 2001, 2002 Paul Diefenbaugh + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + */ + + /* + * Modified for ReactOS and latest ACPICA + * Copyright (C)2009 Samuel Serapion + */ + +#include + +#include +#include +#include +#include + +#define NDEBUG +#include + +#define _COMPONENT ACPI_BUS_COMPONENT +ACPI_MODULE_NAME ("acpi_bus") + +#define WALK_UP 0 +#define WALK_DOWN 1 + +#define STRUCT_TO_INT(s) (*((int*)&s)) +#define HAS_CHILDREN(d) ((d)->children.next != &((d)->children)) +#define HAS_SIBLINGS(d) (((d)->parent) && ((d)->node.next != &(d)->parent->children)) +#define NODE_TO_DEVICE(n) (list_entry(n, struct acpi_device, node)) + +int event_is_open; +extern void acpi_pic_sci_set_trigger(unsigned int irq, UINT16 trigger); + +typedef int (*acpi_bus_walk_callback)(struct acpi_device*, int, void*); + +struct acpi_device *acpi_root; +KSPIN_LOCK acpi_bus_event_lock; +LIST_HEAD(acpi_bus_event_list); +//DECLARE_WAIT_QUEUE_HEAD(acpi_bus_event_queue); +KEVENT AcpiEventQueue; + + +static int +acpi_device_register ( + struct acpi_device *device, + struct acpi_device *parent) +{ + int result = 0; + + if (!device) + return_VALUE(AE_BAD_PARAMETER); + + return_VALUE(result); +} + + +static int +acpi_device_unregister ( + struct acpi_device *device) +{ + if (!device) + return_VALUE(AE_BAD_PARAMETER); + +#ifdef CONFIG_LDM + put_device(&device->dev); +#endif /*CONFIG_LDM*/ + + return_VALUE(0); +} + + +/* -------------------------------------------------------------------------- + Device Management + -------------------------------------------------------------------------- */ + +void +acpi_bus_data_handler ( + ACPI_HANDLE handle, + void *context) +{ + DPRINT1("acpi_bus_data_handler not implemented"); + + /* TBD */ + + return; +} + + +int +acpi_bus_get_device ( + ACPI_HANDLE handle, + struct acpi_device **device) +{ + ACPI_STATUS status = AE_OK; + + if (!device) + return_VALUE(AE_BAD_PARAMETER); + + /* TBD: Support fixed-feature devices */ + + status = AcpiGetData(handle, acpi_bus_data_handler, (void**)device); + if (ACPI_FAILURE(status) || !*device) { + DPRINT( "Error getting context for object [%p]\n", + handle); + return_VALUE(AE_NOT_FOUND); + } + + return 0; +} + +ACPI_STATUS acpi_bus_get_status_handle(ACPI_HANDLE handle, + unsigned long long *sta) +{ + ACPI_STATUS status; + + status = acpi_evaluate_integer(handle, "_STA", NULL, sta); + if (ACPI_SUCCESS(status)) + return AE_OK; + + if (status == AE_NOT_FOUND) { + *sta = ACPI_STA_DEVICE_PRESENT | ACPI_STA_DEVICE_ENABLED | + ACPI_STA_DEVICE_UI | ACPI_STA_DEVICE_FUNCTIONING; + return AE_OK; + } + return status; +} + +int +acpi_bus_get_status ( + struct acpi_device *device) +{ + ACPI_STATUS status; + unsigned long long sta; + + status = acpi_bus_get_status_handle(device->handle, &sta); + if (ACPI_FAILURE(status)) + return -1; + + STRUCT_TO_INT(device->status) = (int) sta; + + if (device->status.functional && !device->status.present) { + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]: " + "functional but not present;\n", + device->pnp.bus_id, + (UINT32) STRUCT_TO_INT(device->status))); + } + + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]\n", + device->pnp.bus_id, + (UINT32) STRUCT_TO_INT(device->status))); + return 0; +} + +void acpi_bus_private_data_handler(ACPI_HANDLE handle, + void *context) +{ + return; +} + +int acpi_bus_get_private_data(ACPI_HANDLE handle, void **data) +{ + ACPI_STATUS status = AE_OK; + + if (!*data) + return -1; + + status = AcpiGetData(handle, acpi_bus_private_data_handler, data); + if (ACPI_FAILURE(status) || !*data) { + DPRINT("No context for object [%p]\n", handle); + return -1; + } + + return 0; +} +/* -------------------------------------------------------------------------- + Power Management + -------------------------------------------------------------------------- */ + +int +acpi_bus_get_power ( + ACPI_HANDLE handle, + int *state) +{ + int result = 0; + ACPI_STATUS status = 0; + struct acpi_device *device = NULL; + unsigned long long psc = 0; + + result = acpi_bus_get_device(handle, &device); + if (result) + return_VALUE(result); + + *state = ACPI_STATE_UNKNOWN; + + if (!device->flags.power_manageable) { + /* TBD: Non-recursive algorithm for walking up hierarchy */ + if (device->parent) + *state = device->parent->power.state; + else + *state = ACPI_STATE_D0; + } + else { + /* + * Get the device's power state either directly (via _PSC) or + * indirectly (via power resources). + */ + if (device->power.flags.explicit_get) { + status = acpi_evaluate_integer(device->handle, "_PSC", + NULL, &psc); + if (ACPI_FAILURE(status)) + return_VALUE(AE_NOT_FOUND); + device->power.state = (int) psc; + } + else if (device->power.flags.power_resources) { + result = acpi_power_get_inferred_state(device); + if (result) + return_VALUE(result); + } + + *state = device->power.state; + } + + DPRINT("Device [%s] power state is D%d\n", + device->pnp.bus_id, device->power.state); + + return_VALUE(0); +} + + +int +acpi_bus_set_power ( + ACPI_HANDLE handle, + int state) +{ + int result = 0; + ACPI_STATUS status = AE_OK; + struct acpi_device *device = NULL; + char object_name[5] = {'_','P','S','0'+state,'\0'}; + + + result = acpi_bus_get_device(handle, &device); + if (result) + return_VALUE(result); + + if ((state < ACPI_STATE_D0) || (state > ACPI_STATE_D3)) + return_VALUE(AE_BAD_PARAMETER); + + /* Make sure this is a valid target state */ + + if (!device->flags.power_manageable) { + DPRINT1( "Device is not power manageable\n"); + return_VALUE(AE_NOT_FOUND); + } + /* + * Get device's current power state + */ + //if (!acpi_power_nocheck) { + /* + * Maybe the incorrect power state is returned on the bogus + * bios, which is different with the real power state. + * For example: the bios returns D0 state and the real power + * state is D3. OS expects to set the device to D0 state. In + * such case if OS uses the power state returned by the BIOS, + * the device can't be transisted to the correct power state. + * So if the acpi_power_nocheck is set, it is unnecessary to + * get the power state by calling acpi_bus_get_power. + */ + acpi_bus_get_power(device->handle, &device->power.state); + //} + + if ((state == device->power.state) && !device->flags.force_power_state) { + DPRINT1("Device is already at D%d\n", state); + return 0; + } + if (!device->power.states[state].flags.valid) { + DPRINT1( "Device does not support D%d\n", state); + return AE_NOT_FOUND; + } + if (device->parent && (state < device->parent->power.state)) { + DPRINT1( "Cannot set device to a higher-powered state than parent\n"); + return AE_NOT_FOUND; + } + + /* + * Transition Power + * ---------------- + * On transitions to a high-powered state we first apply power (via + * power resources) then evalute _PSx. Conversly for transitions to + * a lower-powered state. + */ + if (state < device->power.state) { + if (device->power.flags.power_resources) { + result = acpi_power_transition(device, state); + if (result) + goto end; + } + if (device->power.states[state].flags.explicit_set) { + status = AcpiEvaluateObject(device->handle, + object_name, NULL, NULL); + if (ACPI_FAILURE(status)) { + result = AE_NOT_FOUND; + goto end; + } + } + } + else { + if (device->power.states[state].flags.explicit_set) { + status = AcpiEvaluateObject(device->handle, + object_name, NULL, NULL); + if (ACPI_FAILURE(status)) { + result = AE_NOT_FOUND; + goto end; + } + } + if (device->power.flags.power_resources) { + result = acpi_power_transition(device, state); + if (result) + goto end; + } + } + +end: + if (result) + DPRINT( "Error transitioning device [%s] to D%d\n", + device->pnp.bus_id, state); + else + DPRINT("Device [%s] transitioned to D%d\n", + device->pnp.bus_id, state); + + return result; +} + +BOOLEAN acpi_bus_power_manageable(ACPI_HANDLE handle) +{ + struct acpi_device *device; + int result; + + result = acpi_bus_get_device(handle, &device); + return result ? 0 : device->flags.power_manageable; +} + +BOOLEAN acpi_bus_can_wakeup(ACPI_HANDLE handle) +{ + struct acpi_device *device; + int result; + + result = acpi_bus_get_device(handle, &device); + return result ? 0 : device->wakeup.flags.valid; +} + +static int +acpi_bus_get_power_flags ( + struct acpi_device *device) +{ + ACPI_STATUS status = 0; + ACPI_HANDLE handle = 0; + UINT32 i = 0; + + if (!device) + return AE_NOT_FOUND; + + /* + * Power Management Flags + */ + status = AcpiGetHandle(device->handle, "_PSC", &handle); + if (ACPI_SUCCESS(status)) + device->power.flags.explicit_get = 1; + status = AcpiGetHandle(device->handle, "_IRC", &handle); + if (ACPI_SUCCESS(status)) + device->power.flags.inrush_current = 1; + status = AcpiGetHandle(device->handle, "_PRW", &handle); + if (ACPI_SUCCESS(status)) + device->flags.wake_capable = 1; + + /* + * Enumerate supported power management states + */ + for (i = ACPI_STATE_D0; i <= ACPI_STATE_D3; i++) { + struct acpi_device_power_state *ps = &device->power.states[i]; + char object_name[5] = {'_','P','R','0'+i,'\0'}; + + /* Evaluate "_PRx" to se if power resources are referenced */ + acpi_evaluate_reference(device->handle, object_name, NULL, + &ps->resources); + if (ps->resources.count) { + device->power.flags.power_resources = 1; + ps->flags.valid = 1; + } + + /* Evaluate "_PSx" to see if we can do explicit sets */ + object_name[2] = 'S'; + status = AcpiGetHandle(device->handle, object_name, &handle); + if (ACPI_SUCCESS(status)) { + ps->flags.explicit_set = 1; + ps->flags.valid = 1; + } + + /* State is valid if we have some power control */ + if (ps->resources.count || ps->flags.explicit_set) + ps->flags.valid = 1; + + ps->power = -1; /* Unknown - driver assigned */ + ps->latency = -1; /* Unknown - driver assigned */ + } + + /* Set defaults for D0 and D3 states (always valid) */ + device->power.states[ACPI_STATE_D0].flags.valid = 1; + device->power.states[ACPI_STATE_D0].power = 100; + device->power.states[ACPI_STATE_D3].flags.valid = 1; + device->power.states[ACPI_STATE_D3].power = 0; + + device->power.state = ACPI_STATE_UNKNOWN; + + return 0; +} + +/* -------------------------------------------------------------------------- + Performance Management + -------------------------------------------------------------------------- */ + +static int +acpi_bus_get_perf_flags ( + struct acpi_device *device) +{ + if (!device) + return AE_NOT_FOUND; + + device->performance.state = ACPI_STATE_UNKNOWN; + + return 0; +} + + +/* -------------------------------------------------------------------------- + Event Management + -------------------------------------------------------------------------- */ + + +int +acpi_bus_generate_event ( + struct acpi_device *device, + UINT8 type, + int data) +{ + struct acpi_bus_event *event = NULL; + //unsigned long flags = 0; + KIRQL OldIrql; + + DPRINT1("acpi_bus_generate_event"); + + if (!device) + return_VALUE(AE_BAD_PARAMETER); + + /* drop event on the floor if no one's listening */ + if (!event_is_open) + return_VALUE(0); + + event = ExAllocatePool(NonPagedPool,sizeof(struct acpi_bus_event)); + if (!event) + return_VALUE(-4); + + sprintf(event->device_class, "%s", device->pnp.device_class); + sprintf(event->bus_id, "%s", device->pnp.bus_id); + event->type = type; + event->data = data; + + //spin_lock_irqsave(&acpi_bus_event_lock, flags); + KeAcquireSpinLock(&acpi_bus_event_lock, &OldIrql); + list_add_tail(&event->node, &acpi_bus_event_list); + KeReleaseSpinLock(&acpi_bus_event_lock, OldIrql); + //spin_unlock_irqrestore(&acpi_bus_event_lock, flags); + + KeSetEvent(&AcpiEventQueue, IO_NO_INCREMENT, FALSE); + //wake_up_interruptible(&acpi_bus_event_queue); + + return_VALUE(0); +} + +int +acpi_bus_receive_event ( + struct acpi_bus_event *event) +{ +// unsigned long flags = 0; + struct acpi_bus_event *entry = NULL; + KIRQL OldIrql; + + //DECLARE_WAITQUEUE(wait, current); + + DPRINT1("acpi_bus_receive_event"); + + if (!event) + return AE_BAD_PARAMETER; + + event_is_open++; + KeWaitForSingleObject(&AcpiEventQueue, + Executive, + KernelMode, + FALSE, + NULL); + event_is_open--; + KeClearEvent(&AcpiEventQueue); + + if (list_empty(&acpi_bus_event_list)) + return_VALUE(AE_NOT_FOUND); + +// spin_lock_irqsave(&acpi_bus_event_lock, flags); + KeAcquireSpinLock(&acpi_bus_event_lock, &OldIrql); + entry = list_entry(acpi_bus_event_list.next, struct acpi_bus_event, node); + if (entry) + list_del(&entry->node); + KeReleaseSpinLock(&acpi_bus_event_lock, OldIrql); +// spin_unlock_irqrestore(&acpi_bus_event_lock, flags); + + if (!entry) + return_VALUE(AE_NOT_FOUND); + + memcpy(event, entry, sizeof(struct acpi_bus_event)); + + ExFreePool(entry); + return_VALUE(0); +} + + +/* -------------------------------------------------------------------------- + Namespace Management + -------------------------------------------------------------------------- */ + + +/** + * acpi_bus_walk + * ------------- + * Used to walk the ACPI Bus's device namespace. Can walk down (depth-first) + * or up. Able to parse starting at any node in the namespace. Note that a + * callback return value of -249 will terminate the walk. + * + * @start: starting point + * callback: function to call for every device encountered while parsing + * direction: direction to parse (up or down) + * @data: context for this search operation + */ +static int +acpi_bus_walk ( + struct acpi_device *start, + acpi_bus_walk_callback callback, + int direction, + void *data) +{ + int result = 0; + int level = 0; + struct acpi_device *device = NULL; + + if (!start || !callback) + return AE_BAD_PARAMETER; + + device = start; + + /* + * Parse Namespace + * --------------- + * Parse a given subtree (specified by start) in the given direction. + * Walking 'up' simply means that we execute the callback on leaf + * devices prior to their parents (useful for things like removing + * or powering down a subtree). + */ + + while (device) { + + if (direction == WALK_DOWN) + if (-249 == callback(device, level, data)) + break; + + /* Depth First */ + + if (HAS_CHILDREN(device)) { + device = NODE_TO_DEVICE(device->children.next); + ++level; + continue; + } + + if (direction == WALK_UP) + if (-249 == callback(device, level, data)) + break; + + /* Now Breadth */ + + if (HAS_SIBLINGS(device)) { + device = NODE_TO_DEVICE(device->node.next); + continue; + } + + /* Scope Exhausted - Find Next */ + + while ((device = device->parent)) { + --level; + if (HAS_SIBLINGS(device)) { + device = NODE_TO_DEVICE(device->node.next); + break; + } + } + } + + if ((direction == WALK_UP) && (result == 0)) + callback(start, level, data); + + return result; +} + + +/* -------------------------------------------------------------------------- + Notification Handling + -------------------------------------------------------------------------- */ + +static void +acpi_bus_check_device (ACPI_HANDLE handle) +{ + struct acpi_device *device; + ACPI_STATUS status = 0; + struct acpi_device_status old_status; + + if (acpi_bus_get_device(handle, &device)) + return; + if (!device) + return; + + old_status = device->status; + + /* + * Make sure this device's parent is present before we go about + * messing with the device. + */ + if (device->parent && !device->parent->status.present) { + device->status = device->parent->status; + return; + } + + status = acpi_bus_get_status(device); + if (ACPI_FAILURE(status)) + return; + + if (STRUCT_TO_INT(old_status) == STRUCT_TO_INT(device->status)) + return; + + + /* + * Device Insertion/Removal + */ + if ((device->status.present) && !(old_status.present)) { + DPRINT("Device insertion detected\n"); + /* TBD: Handle device insertion */ + } + else if (!(device->status.present) && (old_status.present)) { + DPRINT("Device removal detected\n"); + /* TBD: Handle device removal */ + } + +} + + +static void +acpi_bus_check_scope (ACPI_HANDLE handle) +{ + /* Status Change? */ + acpi_bus_check_device(handle); + + /* + * TBD: Enumerate child devices within this device's scope and + * run acpi_bus_check_device()'s on them. + */ +} + + +/** + * acpi_bus_notify + * --------------- + * Callback for all 'system-level' device notifications (values 0x00-0x7F). + */ +static void +acpi_bus_notify ( + ACPI_HANDLE handle, + UINT32 type, + void *data) +{ + struct acpi_device *device = NULL; + struct acpi_driver *driver; + + DPRINT1("Notification %#02x to handle %p\n", type, handle); + + //blocking_notifier_call_chain(&acpi_bus_notify_list, + // type, (void *)handle); + + switch (type) { + + case ACPI_NOTIFY_BUS_CHECK: + DPRINT("Received BUS CHECK notification for device [%s]\n", + device->pnp.bus_id); + acpi_bus_check_scope(handle); + /* + * TBD: We'll need to outsource certain events to non-ACPI + * drivers via the device manager (device.c). + */ + break; + + case ACPI_NOTIFY_DEVICE_CHECK: + DPRINT("Received DEVICE CHECK notification for device [%s]\n", + device->pnp.bus_id); + acpi_bus_check_device(handle); + /* + * TBD: We'll need to outsource certain events to non-ACPI + * drivers via the device manager (device.c). + */ + break; + + case ACPI_NOTIFY_DEVICE_WAKE: + DPRINT("Received DEVICE WAKE notification for device [%s]\n", + device->pnp.bus_id); + acpi_bus_check_device(handle); + /* + * TBD: We'll need to outsource certain events to non-ACPI + * drivers via the device manager (device.c). + */ + break; + + case ACPI_NOTIFY_EJECT_REQUEST: + DPRINT1("Received EJECT REQUEST notification for device [%s]\n", + device->pnp.bus_id); + /* TBD */ + break; + + case ACPI_NOTIFY_DEVICE_CHECK_LIGHT: + DPRINT1("Received DEVICE CHECK LIGHT notification for device [%s]\n", + device->pnp.bus_id); + /* TBD: Exactly what does 'light' mean? */ + break; + + case ACPI_NOTIFY_FREQUENCY_MISMATCH: + DPRINT1("Received FREQUENCY MISMATCH notification for device [%s]\n", + device->pnp.bus_id); + /* TBD */ + break; + + case ACPI_NOTIFY_BUS_MODE_MISMATCH: + DPRINT1("Received BUS MODE MISMATCH notification for device [%s]\n", + device->pnp.bus_id); + /* TBD */ + break; + + case ACPI_NOTIFY_POWER_FAULT: + DPRINT1("Received POWER FAULT notification for device [%s]\n", + device->pnp.bus_id); + /* TBD */ + break; + + default: + DPRINT1("Received unknown/unsupported notification [%08x]\n", + type); + break; + } + + acpi_bus_get_device(handle, &device); + if (device) { + driver = device->driver; + if (driver && driver->ops.notify && + (driver->flags & ACPI_DRIVER_ALL_NOTIFY_EVENTS)) + driver->ops.notify(device, type); + } +} + + +/* -------------------------------------------------------------------------- + Driver Management + -------------------------------------------------------------------------- */ + + +static LIST_HEAD(acpi_bus_drivers); +//static DECLARE_MUTEX(acpi_bus_drivers_lock); +static FAST_MUTEX acpi_bus_drivers_lock; + + +/** + * acpi_bus_match + * -------------- + * Checks the device's hardware (_HID) or compatible (_CID) ids to see if it + * matches the specified driver's criteria. + */ +static int +acpi_bus_match ( + struct acpi_device *device, + struct acpi_driver *driver) +{ + int error = 0; + + if (device->flags.hardware_id) + if (strstr(driver->ids, device->pnp.hardware_id)) + goto Done; + + if (device->flags.compatible_ids) { + ACPI_DEVICE_ID_LIST *cid_list = device->pnp.cid_list; + int i; + + /* compare multiple _CID entries against driver ids */ + for (i = 0; i < cid_list->Count; i++) + { + if (strstr(driver->ids, cid_list->Ids[i].String)) + goto Done; + } + } + error = -2; + + Done: + + return error; +} + + +/** + * acpi_bus_driver_init + * -------------------- + * Used to initialize a device via its device driver. Called whenever a + * driver is bound to a device. Invokes the driver's add() and start() ops. + */ +static int +acpi_bus_driver_init ( + struct acpi_device *device, + struct acpi_driver *driver) +{ + int result = 0; + + if (!device || !driver) + return_VALUE(AE_BAD_PARAMETER); + + if (!driver->ops.add) + return_VALUE(-38); + + result = driver->ops.add(device); + if (result) { + device->driver = NULL; + //acpi_driver_data(device) = NULL; + return_VALUE(result); + } + + device->driver = driver; + + /* + * TBD - Configuration Management: Assign resources to device based + * upon possible configuration and currently allocated resources. + */ + + if (driver->ops.start) { + result = driver->ops.start(device); + if (result && driver->ops.remove) + driver->ops.remove(device, ACPI_BUS_REMOVAL_NORMAL); + return_VALUE(result); + } + + DPRINT("Driver successfully bound to device\n"); + + if (driver->ops.scan) { + driver->ops.scan(device); + } + + return_VALUE(0); +} + + +/** + * acpi_bus_attach + * ------------- + * Callback for acpi_bus_walk() used to find devices that match a specific + * driver's criteria and then attach the driver. + */ +static int +acpi_bus_attach ( + struct acpi_device *device, + int level, + void *data) +{ + int result = 0; + struct acpi_driver *driver = NULL; + + if (!device || !data) + return_VALUE(AE_BAD_PARAMETER); + + driver = (struct acpi_driver *) data; + + if (device->driver) + return_VALUE(-9); + + if (!device->status.present) + return_VALUE(AE_NOT_FOUND); + + result = acpi_bus_match(device, driver); + if (result) + return_VALUE(result); + + DPRINT("Found driver [%s] for device [%s]\n", + driver->name, device->pnp.bus_id); + + result = acpi_bus_driver_init(device, driver); + if (result) + return_VALUE(result); + + down(&acpi_bus_drivers_lock); + ++driver->references; + up(&acpi_bus_drivers_lock); + + return_VALUE(0); +} + + +/** + * acpi_bus_unattach + * ----------------- + * Callback for acpi_bus_walk() used to find devices that match a specific + * driver's criteria and unattach the driver. + */ +static int +acpi_bus_unattach ( + struct acpi_device *device, + int level, + void *data) +{ + int result = 0; + struct acpi_driver *driver = (struct acpi_driver *) data; + + if (!device || !driver) + return_VALUE(AE_BAD_PARAMETER); + + if (device->driver != driver) + return_VALUE(-6); + + if (!driver->ops.remove) + return_VALUE(-23); + + result = driver->ops.remove(device, ACPI_BUS_REMOVAL_NORMAL); + if (result) + return_VALUE(result); + + device->driver = NULL; + acpi_driver_data(device) = NULL; + + down(&acpi_bus_drivers_lock); + driver->references--; + up(&acpi_bus_drivers_lock); + + return_VALUE(0); +} + + +/** + * acpi_bus_find_driver + * -------------------- + * Parses the list of registered drivers looking for a driver applicable for + * the specified device. + */ +static int +acpi_bus_find_driver ( + struct acpi_device *device) +{ + int result = AE_NOT_FOUND; + struct list_head *entry = NULL; + struct acpi_driver *driver = NULL; + + if (!device || device->driver) + return_VALUE(AE_BAD_PARAMETER); + + down(&acpi_bus_drivers_lock); + + list_for_each(entry, &acpi_bus_drivers) { + + driver = list_entry(entry, struct acpi_driver, node); + + if (acpi_bus_match(device, driver)) + continue; + + result = acpi_bus_driver_init(device, driver); + if (!result) + ++driver->references; + + break; + } + + up(&acpi_bus_drivers_lock); + + return_VALUE(result); +} + + +/** + * acpi_bus_register_driver + * ------------------------ + * Registers a driver with the ACPI bus. Searches the namespace for all + * devices that match the driver's criteria and binds. + */ +int +acpi_bus_register_driver ( + struct acpi_driver *driver) +{ + if (!driver) + return_VALUE(AE_BAD_PARAMETER); + + //if (acpi_disabled) + // return_VALUE(AE_NOT_FOUND); + + down(&acpi_bus_drivers_lock); + list_add_tail(&driver->node, &acpi_bus_drivers); + up(&acpi_bus_drivers_lock); + + acpi_bus_walk(acpi_root, acpi_bus_attach, + WALK_DOWN, driver); + + return_VALUE(driver->references); +} + + +/** + * acpi_bus_unregister_driver + * -------------------------- + * Unregisters a driver with the ACPI bus. Searches the namespace for all + * devices that match the driver's criteria and unbinds. + */ +void +acpi_bus_unregister_driver ( + struct acpi_driver *driver) +{ + if (!driver) + return; + + acpi_bus_walk(acpi_root, acpi_bus_unattach, WALK_UP, driver); + + if (driver->references) + return; + + down(&acpi_bus_drivers_lock); + list_del(&driver->node); + up(&acpi_bus_drivers_lock); + + return; +} + + +/* -------------------------------------------------------------------------- + Device Enumeration + -------------------------------------------------------------------------- */ + +static int +acpi_bus_get_flags ( + struct acpi_device *device) +{ + ACPI_STATUS status = AE_OK; + ACPI_HANDLE temp = NULL; + + /* Presence of _STA indicates 'dynamic_status' */ + status = AcpiGetHandle(device->handle, "_STA", &temp); + if (ACPI_SUCCESS(status)) + device->flags.dynamic_status = 1; + + /* Presence of _CID indicates 'compatible_ids' */ + status = AcpiGetHandle(device->handle, "_CID", &temp); + if (ACPI_SUCCESS(status)) + device->flags.compatible_ids = 1; + + /* Presence of _RMV indicates 'removable' */ + status = AcpiGetHandle(device->handle, "_RMV", &temp); + if (ACPI_SUCCESS(status)) + device->flags.removable = 1; + + /* Presence of _EJD|_EJ0 indicates 'ejectable' */ + status = AcpiGetHandle(device->handle, "_EJD", &temp); + if (ACPI_SUCCESS(status)) + device->flags.ejectable = 1; + else { + status = AcpiGetHandle(device->handle, "_EJ0", &temp); + if (ACPI_SUCCESS(status)) + device->flags.ejectable = 1; + } + + /* Presence of _LCK indicates 'lockable' */ + status = AcpiGetHandle(device->handle, "_LCK", &temp); + if (ACPI_SUCCESS(status)) + device->flags.lockable = 1; + + /* Presence of _PS0|_PR0 indicates 'power manageable' */ + status = AcpiGetHandle(device->handle, "_PS0", &temp); + if (ACPI_FAILURE(status)) + status = AcpiGetHandle(device->handle, "_PR0", &temp); + if (ACPI_SUCCESS(status)) + device->flags.power_manageable = 1; + + /* TBD: Peformance management */ + + return_VALUE(0); +} + + +int +acpi_bus_add ( + struct acpi_device **child, + struct acpi_device *parent, + ACPI_HANDLE handle, + int type) +{ + int result = 0; + ACPI_STATUS status = AE_OK; + struct acpi_device *device = NULL; + char bus_id[5] = {'?',0}; + ACPI_BUFFER buffer; + ACPI_DEVICE_INFO *info; + char *hid = NULL; + char *uid = NULL; + ACPI_DEVICE_ID_LIST *cid_list = NULL; + int i = 0; + + if (!child) + return_VALUE(AE_BAD_PARAMETER); + + device = ExAllocatePool(NonPagedPool,sizeof(struct acpi_device)); + if (!device) { + DPRINT1("Memory allocation error\n"); + return_VALUE(-12); + } + memset(device, 0, sizeof(struct acpi_device)); + + device->handle = handle; + device->parent = parent; + + /* + * Bus ID + * ------ + * The device's Bus ID is simply the object name. + * TBD: Shouldn't this value be unique (within the ACPI namespace)? + */ + switch (type) { + case ACPI_BUS_TYPE_SYSTEM: + sprintf(device->pnp.bus_id, "%s", "ACPI"); + break; + case ACPI_BUS_TYPE_POWER_BUTTON: + sprintf(device->pnp.bus_id, "%s", "PWRF"); + break; + case ACPI_BUS_TYPE_SLEEP_BUTTON: + sprintf(device->pnp.bus_id, "%s", "SLPF"); + break; + default: + buffer.Length = sizeof(bus_id); + buffer.Pointer = bus_id; + AcpiGetName(handle, ACPI_SINGLE_NAME, &buffer); + + + /* Clean up trailing underscores (if any) */ + for (i = 3; i > 1; i--) { + if (bus_id[i] == '_') + bus_id[i] = '\0'; + else + break; + } + sprintf(device->pnp.bus_id, "%s", bus_id); + buffer.Pointer = NULL; + break; + } + + /* + * Flags + * ----- + * Get prior to calling acpi_bus_get_status() so we know whether + * or not _STA is present. Note that we only look for object + * handles -- cannot evaluate objects until we know the device is + * present and properly initialized. + */ + result = acpi_bus_get_flags(device); + if (result) + goto end; + + /* + * Status + * ------ + * See if the device is present. We always assume that non-Device() + * objects (e.g. thermal zones, power resources, processors, etc.) are + * present, functioning, etc. (at least when parent object is present). + * Note that _STA has a different meaning for some objects (e.g. + * power resources) so we need to be careful how we use it. + */ + switch (type) { + case ACPI_BUS_TYPE_DEVICE: + result = acpi_bus_get_status(device); + if (result) + goto end; + break; + default: + STRUCT_TO_INT(device->status) = 0x0F; + break; + } + if (!device->status.present) { + result = -2; + goto end; + } + + /* + * Initialize Device + * ----------------- + * TBD: Synch with Core's enumeration/initialization process. + */ + + /* + * Hardware ID, Unique ID, & Bus Address + * ------------------------------------- + */ + switch (type) { + case ACPI_BUS_TYPE_DEVICE: + status = AcpiGetObjectInfo(handle,&info); + if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Error reading device info\n")); + result = AE_NOT_FOUND; + goto end; + } + if (info->Valid & ACPI_VALID_HID) + hid = info->HardwareId.String; + if (info->Valid & ACPI_VALID_UID) + uid = info->UniqueId.String; + if (info->Valid & ACPI_VALID_CID) { + cid_list = &info->CompatibleIdList; + device->pnp.cid_list = ExAllocatePool(NonPagedPool,cid_list->ListSize); + if (device->pnp.cid_list) + memcpy(device->pnp.cid_list, cid_list, cid_list->ListSize); + else + DPRINT("Memory allocation error\n"); + } + if (info->Valid & ACPI_VALID_ADR) { + device->pnp.bus_address = info->Address; + device->flags.bus_address = 1; + } + break; + case ACPI_BUS_TYPE_POWER: + hid = ACPI_POWER_HID; + break; + case ACPI_BUS_TYPE_PROCESSOR: + hid = ACPI_PROCESSOR_HID; + break; + case ACPI_BUS_TYPE_SYSTEM: + hid = ACPI_SYSTEM_HID; + break; + case ACPI_BUS_TYPE_THERMAL: + hid = ACPI_THERMAL_HID; + break; + case ACPI_BUS_TYPE_POWER_BUTTON: + hid = ACPI_BUTTON_HID_POWERF; + break; + case ACPI_BUS_TYPE_SLEEP_BUTTON: + hid = ACPI_BUTTON_HID_SLEEPF; + break; + } + + /* + * \_SB + * ---- + * Fix for the system root bus device -- the only root-level device. + */ + if ((parent == ACPI_ROOT_OBJECT) && (type == ACPI_BUS_TYPE_DEVICE)) { + hid = ACPI_BUS_HID; + sprintf(device->pnp.device_name, "%s", ACPI_BUS_DEVICE_NAME); + sprintf(device->pnp.device_class, "%s", ACPI_BUS_CLASS); + } + + if (hid) { + sprintf(device->pnp.hardware_id, "%s", hid); + device->flags.hardware_id = 1; + } + if (uid) { + sprintf(device->pnp.unique_id, "%s", uid); + device->flags.unique_id = 1; + } + + /* + * If we called get_object_info, we now are finished with the buffer, + * so we can free it. + */ + //if (buffer.Pointer) + //AcpiOsFree(buffer.Pointer); + + /* + * Power Management + * ---------------- + */ + if (device->flags.power_manageable) { + result = acpi_bus_get_power_flags(device); + if (result) + goto end; + } + + /* + * Performance Management + * ---------------------- + */ + if (device->flags.performance_manageable) { + result = acpi_bus_get_perf_flags(device); + if (result) + goto end; + } + + /* + * Context + * ------- + * Attach this 'struct acpi_device' to the ACPI object. This makes + * resolutions from handle->device very efficient. Note that we need + * to be careful with fixed-feature devices as they all attach to the + * root object. + */ + switch (type) { + case ACPI_BUS_TYPE_POWER_BUTTON: + case ACPI_BUS_TYPE_SLEEP_BUTTON: + break; + default: + status = AcpiAttachData(device->handle, + acpi_bus_data_handler, device); + break; + } + if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Error attaching device data\n")); + result = AE_NOT_FOUND; + goto end; + } + + /* + * Linkage + * ------- + * Link this device to its parent and siblings. + */ + INIT_LIST_HEAD(&device->children); + if (!device->parent) + INIT_LIST_HEAD(&device->node); + else + list_add_tail(&device->node, &device->parent->children); + + /* + * Global Device Hierarchy: + * ------------------------ + * Register this device with the global device hierarchy. + */ + acpi_device_register(device, parent); + + /* + * Bind _ADR-Based Devices + * ----------------------- + * If there's a a bus address (_ADR) then we utilize the parent's + * 'bind' function (if exists) to bind the ACPI- and natively- + * enumerated device representations. + */ + if (device->flags.bus_address) { + if (device->parent && device->parent->ops.bind) + device->parent->ops.bind(device); + } + + /* + * Locate & Attach Driver + * ---------------------- + * If there's a hardware id (_HID) or compatible ids (_CID) we check + * to see if there's a driver installed for this kind of device. Note + * that drivers can install before or after a device is enumerated. + * + * TBD: Assumes LDM provides driver hot-plug capability. + */ + if (device->flags.hardware_id || device->flags.compatible_ids) + acpi_bus_find_driver(device); + +end: + if (result) { + if (device->pnp.cid_list) { + ExFreePool(device->pnp.cid_list); + } + ExFreePool(device); + return_VALUE(result); + } + *child = device; + + return_VALUE(0); +} + + +static int +acpi_bus_remove ( + struct acpi_device *device, + int type) +{ + + if (!device) + return_VALUE(AE_NOT_FOUND); + + acpi_device_unregister(device); + + if (device && device->pnp.cid_list) + ExFreePool(device->pnp.cid_list); + + if (device) + ExFreePool(device); + + return_VALUE(0); +} + + +int +acpi_bus_scan ( + struct acpi_device *start) +{ + ACPI_STATUS status = AE_OK; + struct acpi_device *parent = NULL; + struct acpi_device *child = NULL; + ACPI_HANDLE phandle = 0; + ACPI_HANDLE chandle = 0; + ACPI_OBJECT_TYPE type = 0; + UINT32 level = 1; + + if (!start) + return_VALUE(AE_BAD_PARAMETER); + + parent = start; + phandle = start->handle; + + /* + * Parse through the ACPI namespace, identify all 'devices', and + * create a new 'struct acpi_device' for each. + */ + while ((level > 0) && parent) { + + status = AcpiGetNextObject(ACPI_TYPE_ANY, phandle, + chandle, &chandle); + + /* + * If this scope is exhausted then move our way back up. + */ + if (ACPI_FAILURE(status)) { + level--; + chandle = phandle; + AcpiGetParent(phandle, &phandle); + if (parent->parent) + parent = parent->parent; + continue; + } + + status = AcpiGetType(chandle, &type); + if (ACPI_FAILURE(status)) + continue; + + /* + * If this is a scope object then parse it (depth-first). + */ + if (type == ACPI_TYPE_LOCAL_SCOPE) { + level++; + phandle = chandle; + chandle = 0; + continue; + } + + /* + * We're only interested in objects that we consider 'devices'. + */ + switch (type) { + case ACPI_TYPE_DEVICE: + type = ACPI_BUS_TYPE_DEVICE; + break; + case ACPI_TYPE_PROCESSOR: + type = ACPI_BUS_TYPE_PROCESSOR; + break; + case ACPI_TYPE_THERMAL: + type = ACPI_BUS_TYPE_THERMAL; + break; + case ACPI_TYPE_POWER: + type = ACPI_BUS_TYPE_POWER; + break; + default: + continue; + } + + status = acpi_bus_add(&child, parent, chandle, type); + if (ACPI_FAILURE(status)) + continue; + + /* + * If the device is present, enabled, and functioning then + * parse its scope (depth-first). Note that we need to + * represent absent devices to facilitate PnP notifications + * -- but only the subtree head (not all of its children, + * which will be enumerated when the parent is inserted). + * + * TBD: Need notifications and other detection mechanisms + * in place before we can fully implement this. + */ + if (child->status.present) { + status = AcpiGetNextObject(ACPI_TYPE_ANY, chandle, + 0, NULL); + if (ACPI_SUCCESS(status)) { + level++; + phandle = chandle; + chandle = 0; + parent = child; + } + } + } + + return_VALUE(0); +} + + +static int +acpi_bus_scan_fixed ( + struct acpi_device *root) +{ + int result = 0; + struct acpi_device *device = NULL; + + if (!root) + return_VALUE(AE_NOT_FOUND); + + /* + * Enumerate all fixed-feature devices. + */ + if (AcpiGbl_FADT.Flags & ACPI_FADT_POWER_BUTTON) + result = acpi_bus_add(&device, acpi_root, + NULL, ACPI_BUS_TYPE_POWER_BUTTON); + + if (AcpiGbl_FADT.Flags & ACPI_FADT_SLEEP_BUTTON) + result = acpi_bus_add(&device, acpi_root, + NULL, ACPI_BUS_TYPE_SLEEP_BUTTON); + + return_VALUE(result); +} + + +/* -------------------------------------------------------------------------- + Initialization/Cleanup + -------------------------------------------------------------------------- */ + +static int +acpi_bus_init_irq (void) +{ + ACPI_STATUS status = AE_OK; + ACPI_OBJECT arg = {ACPI_TYPE_INTEGER}; + ACPI_OBJECT_LIST arg_list = {1, &arg}; + //char *message = NULL; + + DPRINT("acpi_bus_init_irq"); + + /* + * Let the system know what interrupt model we are using by + * evaluating the \_PIC object, if exists. + */ + + //switch (acpi_irq_model) { + //case ACPI_IRQ_MODEL_PIC: + // message = "PIC"; + // break; + //case ACPI_IRQ_MODEL_IOAPIC: + // message = "IOAPIC"; + // break; + //case ACPI_IRQ_MODEL_IOSAPIC: + // message = "IOSAPIC"; + // break; + //default: + // DPRINT1("Unknown interrupt routing model\n"); + // return_VALUE(AE_NOT_FOUND); + //} + + //DPRINT("Using %s for interrupt routing\n", message); + + //arg.Integer.Value = acpi_irq_model; + + //status = AcpiEvaluateObject(NULL, "\\_PIC", &arg_list, NULL); + //if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) { + // ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PIC\n")); + // return_VALUE(AE_NOT_FOUND); + //} + + return_VALUE(0); +} + + +//void +//acpi_early_init (void) +//{ +// ACPI_STATUS status = AE_OK; +// +// DPRINT("acpi_early_init"); +// +// if (acpi_disabled) +// return_VOID; +// + /* enable workarounds, unless strict ACPI spec. compliance */ +// if (!acpi_strict) +// acpi_gbl_enable_interpreter_slack = TRUE; +// +// status = acpi_reallocate_root_table(); +// if (ACPI_FAILURE(status)) { +// printk(KERN_ERR PREFIX +// "Unable to reallocate ACPI tables\n"); +// goto error0; +// } +// +// status = acpi_initialize_subsystem(); +// if (ACPI_FAILURE(status)) { +// printk(KERN_ERR PREFIX +// "Unable to initialize the ACPI Interpreter\n"); +// goto error0; +// } +// +// status = acpi_load_tables(); +// if (ACPI_FAILURE(status)) { +// printk(KERN_ERR PREFIX +// "Unable to load the System Description Tables\n"); +// goto error0; +// } +// +//#ifdef CONFIG_X86 +// if (!acpi_ioapic) { +// /* compatible (0) means level (3) */ +// if (!(acpi_sci_flags & ACPI_MADT_TRIGGER_MASK)) { +// acpi_sci_flags &= ~ACPI_MADT_TRIGGER_MASK; +// acpi_sci_flags |= ACPI_MADT_TRIGGER_LEVEL; +// } +// /* Set PIC-mode SCI trigger type */ +// acpi_pic_sci_set_trigger(acpi_gbl_FADT.sci_interrupt, +// (acpi_sci_flags & ACPI_MADT_TRIGGER_MASK) >> 2); +// } else { +// /* +// * now that acpi_gbl_FADT is initialized, +// * update it with result from INT_SRC_OVR parsing +// */ +// acpi_gbl_FADT.sci_interrupt = acpi_sci_override_gsi; +// } +//#endif +// +// status = +// acpi_enable_subsystem(~ +// (ACPI_NO_HARDWARE_INIT | +// ACPI_NO_ACPI_ENABLE)); +// if (ACPI_FAILURE(status)) { +// printk(KERN_ERR PREFIX "Unable to enable ACPI\n"); +// goto error0; +// } +// +// return; +// +// error0: +// disable_acpi(); +// return; +//} + +int +acpi_bus_init (void) +{ + int result = 0; + ACPI_STATUS status = AE_OK; + + DPRINT("acpi_bus_init"); + + status = AcpiEnableSubsystem(ACPI_FULL_INITIALIZATION); + if (ACPI_FAILURE(status)) { + DPRINT1("Unable to start the ACPI Interpreter\n"); + goto error1; + } + + /* + * ACPI 2.0 requires the EC driver to be loaded and work before + * the EC device is found in the namespace. This is accomplished + * by looking for the ECDT table, and getting the EC parameters out + * of that. + */ + //result = acpi_ec_ecdt_probe(); + /* Ignore result. Not having an ECDT is not fatal. */ + + status = AcpiInitializeObjects(ACPI_NO_DEVICE_INIT | ACPI_NO_OBJECT_INIT); + if (ACPI_FAILURE(status)) { + DPRINT1("Unable to initialize ACPI objects\n"); + goto error1; + } + + /* + * Maybe EC region is required at bus_scan/acpi_get_devices. So it + * is necessary to enable it as early as possible. + */ + //acpi_boot_ec_enable(); + + /* Initialize sleep structures */ + //acpi_sleep_init(); + + /* + * Get the system interrupt model and evaluate \_PIC. + */ + result = acpi_bus_init_irq(); + if (result) + goto error1; + + /* + * Register the for all standard device notifications. + */ + status = AcpiInstallNotifyHandler(ACPI_ROOT_OBJECT, ACPI_SYSTEM_NOTIFY, &acpi_bus_notify, NULL); + if (ACPI_FAILURE(status)) { + DPRINT1("Unable to register for device notifications\n"); + result = AE_NOT_FOUND; + goto error1; + } + + /* + * Create the root device in the bus's device tree + */ + result = acpi_bus_add(&acpi_root, NULL, ACPI_ROOT_OBJECT, + ACPI_BUS_TYPE_SYSTEM); + if (result) + goto error2; + + /* + * Enumerate devices in the ACPI namespace. + */ + result = acpi_bus_scan_fixed(acpi_root); + if (result) + DPRINT1("acpi_bus_scan_fixed failed\n"); + result = acpi_bus_scan(acpi_root); + if (result) + DPRINT1("acpi_bus_scan failed\n"); + + //acpi_motherboard_init(); + return_VALUE(0); + + /* Mimic structured exception handling */ +error2: + AcpiRemoveNotifyHandler(ACPI_ROOT_OBJECT, + ACPI_SYSTEM_NOTIFY, &acpi_bus_notify); +error1: + AcpiTerminate(); + return_VALUE(AE_NOT_FOUND); +} + +static void +acpi_bus_exit (void) +{ + ACPI_STATUS status = AE_OK; + + DPRINT("acpi_bus_exit"); + + status = AcpiRemoveNotifyHandler(ACPI_ROOT_OBJECT, + ACPI_SYSTEM_NOTIFY, acpi_bus_notify); + if (ACPI_FAILURE(status)) + DPRINT1("Error removing notify handler\n"); + +#ifdef CONFIG_ACPI_PCI + acpi_pci_root_exit(); + acpi_pci_link_exit(); +#endif +#ifdef CONFIG_ACPI_EC + acpi_ec_exit(); +#endif + //acpi_power_exit(); + acpi_system_exit(); + + acpi_bus_remove(acpi_root, ACPI_BUS_REMOVAL_NORMAL); + + status = AcpiTerminate(); + if (ACPI_FAILURE(status)) + DPRINT1("Unable to terminate the ACPI Interpreter\n"); + else + DPRINT1("Interpreter disabled\n"); + + return_VOID; +} + + +int +acpi_init (void) +{ + int result = 0; + + DPRINT("acpi_init"); + + DPRINT("Subsystem revision %08x\n",ACPI_CA_VERSION); + + KeInitializeSpinLock(&acpi_bus_event_lock); + KeInitializeEvent(&AcpiEventQueue, NotificationEvent, FALSE); + ExInitializeFastMutex(&acpi_bus_drivers_lock); + + result = acpi_bus_init(); + + //if (!result) { + //pci_mmcfg_late_init(); + //if (!(pm_flags & PM_APM)) + // pm_flags |= PM_ACPI; + //else { + //DPRINT1("APM is already active, exiting\n"); + //disable_acpi(); + //result = -ENODEV; + //} + //} else + // disable_acpi(); + + /* + * If the laptop falls into the DMI check table, the power state check + * will be disabled in the course of device power transistion. + */ + //dmi_check_system(power_nocheck_dmi_table); + + /* + * Install drivers required for proper enumeration of the + * ACPI namespace. + */ + acpi_system_init(); /* ACPI System */ + acpi_power_init(); /* ACPI Bus Power Management */ + acpi_button_init(); + //acpi_ec_init(); /* ACPI Embedded Controller */ +#ifdef CONFIG_ACPI_PCI + if (!acpi_pci_disabled) { + acpi_pci_link_init(); /* ACPI PCI Interrupt Link */ + acpi_pci_root_init(); /* ACPI PCI Root Bridge */ + } +#endif + + //acpi_scan_init(); + //acpi_ec_init(); + //acpi_power_init(); + //acpi_system_init(); + //acpi_debug_init(); + //acpi_sleep_proc_init(); + //acpi_wakeup_device_init(); + + return result; +} + + +void +acpi_exit (void) +{ + DPRINT("acpi_exit"); + +#ifdef CONFIG_PM + pm_active = 0; +#endif + + acpi_bus_exit(); + + return_VOID; +} + diff --git a/reactos/drivers/bus/acpi/busmgr/button.c b/reactos/drivers/bus/acpi/busmgr/button.c new file mode 100644 index 00000000000..5e3eb2b5f0f --- /dev/null +++ b/reactos/drivers/bus/acpi/busmgr/button.c @@ -0,0 +1,328 @@ +/* + * acpi_button.c - ACPI Button Driver ($Revision: 29 $) + * + * Copyright (C) 2001, 2002 Andy Grover + * Copyright (C) 2001, 2002 Paul Diefenbaugh + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + */ +#include + +#include +#include +#include +#include + +#define NDEBUG +#include + + + +#define _COMPONENT ACPI_BUTTON_COMPONENT +ACPI_MODULE_NAME ("acpi_button") + + +static int acpi_button_add (struct acpi_device *device); +static int acpi_button_remove (struct acpi_device *device, int type); + +static struct acpi_driver acpi_button_driver = { + .name = ACPI_BUTTON_DRIVER_NAME, + .class = ACPI_BUTTON_CLASS, + .ids = "ACPI_FPB,ACPI_FSB,PNP0C0D,PNP0C0C,PNP0C0E", + .ops = { + .add = acpi_button_add, + .remove = acpi_button_remove, + }, +}; + +struct acpi_button { + ACPI_HANDLE handle; + struct acpi_device *device; /* Fixed button kludge */ + UINT8 type; + unsigned long pushed; +}; +/* -------------------------------------------------------------------------- + Driver Interface + -------------------------------------------------------------------------- */ + +void +acpi_button_notify ( + ACPI_HANDLE handle, + UINT32 event, + void *data) +{ + struct acpi_button *button = (struct acpi_button *) data; + + ACPI_FUNCTION_TRACE("acpi_button_notify"); + + if (!button || !button->device) + return_VOID; + + switch (event) { + case ACPI_BUTTON_NOTIFY_STATUS: + acpi_bus_generate_event(button->device, event, ++button->pushed); + break; + default: + ACPI_DEBUG_PRINT((ACPI_DB_INFO, + "Unsupported event [0x%x]\n", event)); + break; + } + + return_VOID; +} + + +ACPI_STATUS +acpi_button_notify_fixed ( + void *data) +{ + struct acpi_button *button = (struct acpi_button *) data; + + ACPI_FUNCTION_TRACE("acpi_button_notify_fixed"); + + if (!button) + return_ACPI_STATUS(AE_BAD_PARAMETER); + + acpi_button_notify(button->handle, ACPI_BUTTON_NOTIFY_STATUS, button); + + return_ACPI_STATUS(AE_OK); +} + + +static int +acpi_button_add ( + struct acpi_device *device) +{ + int result = 0; + ACPI_STATUS status = AE_OK; + struct acpi_button *button = NULL; + + static struct acpi_device *power_button; + static struct acpi_device *sleep_button; + static struct acpi_device *lid_button; + + ACPI_FUNCTION_TRACE("acpi_button_add"); + + if (!device) + return_VALUE(-1); + + button = ExAllocatePool(NonPagedPool,sizeof(struct acpi_button)); + if (!button) + return_VALUE(-4); + memset(button, 0, sizeof(struct acpi_button)); + + button->device = device; + button->handle = device->handle; + acpi_driver_data(device) = button; + + /* + * Determine the button type (via hid), as fixed-feature buttons + * need to be handled a bit differently than generic-space. + */ + if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_POWER)) { + button->type = ACPI_BUTTON_TYPE_POWER; + sprintf(acpi_device_name(device), "%s", + ACPI_BUTTON_DEVICE_NAME_POWER); + sprintf(acpi_device_class(device), "%s/%s", + ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_POWER); + } + else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_POWERF)) { + button->type = ACPI_BUTTON_TYPE_POWERF; + sprintf(acpi_device_name(device), "%s", + ACPI_BUTTON_DEVICE_NAME_POWERF); + sprintf(acpi_device_class(device), "%s/%s", + ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_POWER); + } + else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_SLEEP)) { + button->type = ACPI_BUTTON_TYPE_SLEEP; + sprintf(acpi_device_name(device), "%s", + ACPI_BUTTON_DEVICE_NAME_SLEEP); + sprintf(acpi_device_class(device), "%s/%s", + ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_SLEEP); + } + else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_SLEEPF)) { + button->type = ACPI_BUTTON_TYPE_SLEEPF; + sprintf(acpi_device_name(device), "%s", + ACPI_BUTTON_DEVICE_NAME_SLEEPF); + sprintf(acpi_device_class(device), "%s/%s", + ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_SLEEP); + } + else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_LID)) { + button->type = ACPI_BUTTON_TYPE_LID; + sprintf(acpi_device_name(device), "%s", + ACPI_BUTTON_DEVICE_NAME_LID); + sprintf(acpi_device_class(device), "%s/%s", + ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_LID); + } + else { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unsupported hid [%s]\n", + acpi_device_hid(device))); + result = -15; + goto end; + } + + /* + * Ensure only one button of each type is used. + */ + switch (button->type) { + case ACPI_BUTTON_TYPE_POWER: + case ACPI_BUTTON_TYPE_POWERF: + if (!power_button) + power_button = device; + else { + ExFreePool(button); + return_VALUE(-15); + } + break; + case ACPI_BUTTON_TYPE_SLEEP: + case ACPI_BUTTON_TYPE_SLEEPF: + if (!sleep_button) + sleep_button = device; + else { + ExFreePool(button); + return_VALUE(-15); + } + break; + case ACPI_BUTTON_TYPE_LID: + if (!lid_button) + lid_button = device; + else { + ExFreePool(button); + return_VALUE(-15); + } + break; + } + + switch (button->type) { + case ACPI_BUTTON_TYPE_POWERF: + status = AcpiInstallFixedEventHandler ( + ACPI_EVENT_POWER_BUTTON, + acpi_button_notify_fixed, + button); + break; + case ACPI_BUTTON_TYPE_SLEEPF: + status = AcpiInstallFixedEventHandler ( + ACPI_EVENT_SLEEP_BUTTON, + acpi_button_notify_fixed, + button); + break; + case ACPI_BUTTON_TYPE_LID: + status = AcpiInstallFixedEventHandler ( + ACPI_BUTTON_TYPE_LID, + acpi_button_notify_fixed, + button); + break; + default: + status = AcpiInstallNotifyHandler ( + button->handle, + ACPI_DEVICE_NOTIFY, + acpi_button_notify, + button); + break; + } + + if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Error installing notify handler\n")); + result = -15; + goto end; + } + + DPRINT("%s [%s]\n", + acpi_device_name(device), acpi_device_bid(device)); + +end: + if (result) { + ExFreePool(button); + } + + return_VALUE(result); +} + + +static int +acpi_button_remove (struct acpi_device *device, int type) +{ + ACPI_STATUS status = 0; + struct acpi_button *button = NULL; + + ACPI_FUNCTION_TRACE("acpi_button_remove"); + + if (!device || !acpi_driver_data(device)) + return_VALUE(-1); + + button = acpi_driver_data(device); + + /* Unregister for device notifications. */ + switch (button->type) { + case ACPI_BUTTON_TYPE_POWERF: + status = AcpiRemoveFixedEventHandler( + ACPI_EVENT_POWER_BUTTON, acpi_button_notify_fixed); + break; + case ACPI_BUTTON_TYPE_SLEEPF: + status = AcpiRemoveFixedEventHandler( + ACPI_EVENT_SLEEP_BUTTON, acpi_button_notify_fixed); + break; + case ACPI_BUTTON_TYPE_LID: + status = AcpiRemoveFixedEventHandler( + ACPI_BUTTON_TYPE_LID, acpi_button_notify_fixed); + break; + default: + status = AcpiRemoveNotifyHandler(button->handle, + ACPI_DEVICE_NOTIFY, acpi_button_notify); + break; + } + + if (ACPI_FAILURE(status)) + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Error removing notify handler\n")); + + ExFreePool(button); + + return_VALUE(0); +} + + +int +acpi_button_init (void) +{ + int result = 0; + + ACPI_FUNCTION_TRACE("acpi_button_init"); + + result = acpi_bus_register_driver(&acpi_button_driver); + if (result < 0) { + return_VALUE(-15); + } + + return_VALUE(0); +} + + +void +acpi_button_exit (void) +{ + ACPI_FUNCTION_TRACE("acpi_button_exit"); + + acpi_bus_unregister_driver(&acpi_button_driver); + + return_VOID; +} + + diff --git a/reactos/drivers/bus/acpi/busmgr/power.c b/reactos/drivers/bus/acpi/busmgr/power.c new file mode 100644 index 00000000000..77a37198ed7 --- /dev/null +++ b/reactos/drivers/bus/acpi/busmgr/power.c @@ -0,0 +1,679 @@ +/* + * acpi_power.c - ACPI Bus Power Management ($Revision: 39 $) + * + * Copyright (C) 2001, 2002 Andy Grover + * Copyright (C) 2001, 2002 Paul Diefenbaugh + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + */ + +/* + * ACPI power-managed devices may be controlled in two ways: + * 1. via "Device Specific (D-State) Control" + * 2. via "Power Resource Control". + * This module is used to manage devices relying on Power Resource Control. + * + * An ACPI "power resource object" describes a software controllable power + * plane, clock plane, or other resource used by a power managed device. + * A device may rely on multiple power resources, and a power resource + * may be shared by multiple devices. + */ + +/* + * Modified for ReactOS and latest ACPICA + * Copyright (C)2009 Samuel Serapion + */ + +#include +#include +#include +#include +#include + +#define NDEBUG +#include + + +#define _COMPONENT ACPI_POWER_COMPONENT +ACPI_MODULE_NAME ("acpi_power") + +#define ACPI_POWER_RESOURCE_STATE_OFF 0x00 +#define ACPI_POWER_RESOURCE_STATE_ON 0x01 +#define ACPI_POWER_RESOURCE_STATE_UNKNOWN 0xFF + +int acpi_power_nocheck; + +static int acpi_power_add (struct acpi_device *device); +static int acpi_power_remove (struct acpi_device *device, int type); +static int acpi_power_resume(struct acpi_device *device); + +static struct acpi_driver acpi_power_driver = { + .name = ACPI_POWER_DRIVER_NAME, + .class = ACPI_POWER_CLASS, + .ids = ACPI_POWER_HID, + .ops = { + .add = acpi_power_add, + .remove = acpi_power_remove, + .resume = acpi_power_resume, + }, +}; + +struct acpi_power_reference { + struct list_head node; + struct acpi_device *device; +}; + +struct acpi_power_resource +{ + struct acpi_device * device; + acpi_bus_id name; + UINT32 system_level; + UINT32 order; + //struct mutex resource_lock; + struct list_head reference; +}; + +static struct list_head acpi_power_resource_list; + + +/* -------------------------------------------------------------------------- + Power Resource Management + -------------------------------------------------------------------------- */ + +static int +acpi_power_get_context ( + ACPI_HANDLE handle, + struct acpi_power_resource **resource) +{ + int result = 0; + struct acpi_device *device = NULL; + + if (!resource) + return_VALUE(-15); + + result = acpi_bus_get_device(handle, &device); + if (result) { + ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Error getting context [%p]\n", + handle)); + return_VALUE(result); + } + + *resource = (struct acpi_power_resource *) acpi_driver_data(device); + if (!*resource) + return_VALUE(-15); + + return 0; +} + + +static int +acpi_power_get_state ( + ACPI_HANDLE handle, + int *state) +{ + ACPI_STATUS status = AE_OK; + unsigned long sta = 0; + char node_name[5]; + ACPI_BUFFER buffer = { sizeof(node_name), node_name }; + + + if (!handle || !state) + return_VALUE(-1); + + status = acpi_evaluate_integer(handle, "_STA", NULL, &sta); + if (ACPI_FAILURE(status)) + return_VALUE(-15); + + *state = (sta & 0x01)?ACPI_POWER_RESOURCE_STATE_ON: + ACPI_POWER_RESOURCE_STATE_OFF; + + AcpiGetName(handle, ACPI_SINGLE_NAME, &buffer); + + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] is %s\n", + node_name, *state?"on":"off")); + + return 0; +} + + +static int +acpi_power_get_list_state ( + struct acpi_handle_list *list, + int *state) +{ + int result = 0, state1; + UINT32 i = 0; + + if (!list || !state) + return_VALUE(-1); + + /* The state of the list is 'on' IFF all resources are 'on'. */ + + for (i=0; icount; i++) { + /* + * The state of the power resource can be obtained by + * using the ACPI handle. In such case it is unnecessary to + * get the Power resource first and then get its state again. + */ + result = acpi_power_get_state(list->handles[i], &state1); + if (result) + return result; + + *state = state1; + + if (*state != ACPI_POWER_RESOURCE_STATE_ON) + break; + } + + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource list is %s\n", + *state?"on":"off")); + + return result; +} + + +static int +acpi_power_on ( + ACPI_HANDLE handle, struct acpi_device *dev) +{ + int result = 0; + int found = 0; + ACPI_STATUS status = AE_OK; + struct acpi_power_resource *resource = NULL; + struct list_head *node, *next; + struct acpi_power_reference *ref; + + result = acpi_power_get_context(handle, &resource); + if (result) + return result; + + //mutex_lock(&resource->resource_lock); + list_for_each_safe(node, next, &resource->reference) { + ref = container_of(node, struct acpi_power_reference, node); + if (dev->handle == ref->device->handle) { + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] already referenced by resource [%s]\n", + dev->pnp.bus_id, resource->name)); + found = 1; + break; + } + } + + if (!found) { + ref = ExAllocatePool(NonPagedPool,sizeof (struct acpi_power_reference)); + if (!ref) { + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "kmalloc() failed\n")); + //mutex_unlock(&resource->resource_lock); + return -1;//-ENOMEM; + } + list_add_tail(&ref->node, &resource->reference); + ref->device = dev; + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] added to resource [%s] references\n", + dev->pnp.bus_id, resource->name)); + } + //mutex_unlock(&resource->resource_lock); + + status = AcpiEvaluateObject(resource->device->handle, "_ON", NULL, NULL); + if (ACPI_FAILURE(status)) + return_VALUE(-15); + + /* Update the power resource's _device_ power state */ + resource->device->power.state = ACPI_STATE_D0; + + return 0; +} + + +static int +acpi_power_off_device ( + ACPI_HANDLE handle, + struct acpi_device *dev) +{ + int result = 0; + ACPI_STATUS status = AE_OK; + struct acpi_power_resource *resource = NULL; + struct list_head *node, *next; + struct acpi_power_reference *ref; + + result = acpi_power_get_context(handle, &resource); + if (result) + return result; + + //mutex_lock(&resource->resource_lock); + list_for_each_safe(node, next, &resource->reference) { + ref = container_of(node, struct acpi_power_reference, node); + if (dev->handle == ref->device->handle) { + list_del(&ref->node); + ExFreePool(ref); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] removed from resource [%s] references\n", + dev->pnp.bus_id, resource->name)); + break; + } + } + + if (!list_empty(&resource->reference)) { + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Cannot turn resource [%s] off - resource is in use\n", + resource->name)); + //mutex_unlock(&resource->resource_lock); + return 0; + } + //mutex_unlock(&resource->resource_lock); + + status = AcpiEvaluateObject(resource->device->handle, "_OFF", NULL, NULL); + if (ACPI_FAILURE(status)) + return -1; + + /* Update the power resource's _device_ power state */ + resource->device->power.state = ACPI_STATE_D3; + + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Resource [%s] turned off\n", + resource->name)); + + return 0; +} + +/** + * acpi_device_sleep_wake - execute _DSW (Device Sleep Wake) or (deprecated in + * ACPI 3.0) _PSW (Power State Wake) + * @dev: Device to handle. + * @enable: 0 - disable, 1 - enable the wake capabilities of the device. + * @sleep_state: Target sleep state of the system. + * @dev_state: Target power state of the device. + * + * Execute _DSW (Device Sleep Wake) or (deprecated in ACPI 3.0) _PSW (Power + * State Wake) for the device, if present. On failure reset the device's + * wakeup.flags.valid flag. + * + * RETURN VALUE: + * 0 if either _DSW or _PSW has been successfully executed + * 0 if neither _DSW nor _PSW has been found + * -ENODEV if the execution of either _DSW or _PSW has failed + */ +int acpi_device_sleep_wake(struct acpi_device *dev, + int enable, int sleep_state, int dev_state) +{ + union acpi_object in_arg[3]; + struct acpi_object_list arg_list = { 3, in_arg }; + ACPI_STATUS status = AE_OK; + + /* + * Try to execute _DSW first. + * + * Three agruments are needed for the _DSW object: + * Argument 0: enable/disable the wake capabilities + * Argument 1: target system state + * Argument 2: target device state + * When _DSW object is called to disable the wake capabilities, maybe + * the first argument is filled. The values of the other two agruments + * are meaningless. + */ + in_arg[0].Type = ACPI_TYPE_INTEGER; + in_arg[0].Integer.Value = enable; + in_arg[1].Type = ACPI_TYPE_INTEGER; + in_arg[1].Integer.Value = sleep_state; + in_arg[2].Type = ACPI_TYPE_INTEGER; + in_arg[2].Integer.Value = dev_state; + status = AcpiEvaluateObject(dev->handle, "_DSW", &arg_list, NULL); + if (ACPI_SUCCESS(status)) { + return 0; + } else if (status != AE_NOT_FOUND) { + DPRINT1("_DSW execution failed\n"); + dev->wakeup.flags.valid = 0; + return -1; + } + + /* Execute _PSW */ + arg_list.Count = 1; + in_arg[0].Integer.Value = enable; + status = AcpiEvaluateObject(dev->handle, "_PSW", &arg_list, NULL); + if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) { + DPRINT1("_PSW execution failed\n"); + dev->wakeup.flags.valid = 0; + return -1; + } + + return 0; +} + +/* + * Prepare a wakeup device, two steps (Ref ACPI 2.0:P229): + * 1. Power on the power resources required for the wakeup device + * 2. Execute _DSW (Device Sleep Wake) or (deprecated in ACPI 3.0) _PSW (Power + * State Wake) for the device, if present + */ +int acpi_enable_wakeup_device_power(struct acpi_device *dev, int sleep_state) +{ + int i, err = 0; + + if (!dev || !dev->wakeup.flags.valid) + return -1; + + //mutex_lock(&acpi_device_lock); + + if (dev->wakeup.prepare_count++) + goto out; + + /* Open power resource */ + for (i = 0; i < dev->wakeup.resources.count; i++) { + int ret = acpi_power_on(dev->wakeup.resources.handles[i], dev); + if (ret) { + DPRINT( "Transition power state\n"); + dev->wakeup.flags.valid = 0; + err = -1; + goto err_out; + } + } + + /* + * Passing 3 as the third argument below means the device may be placed + * in arbitrary power state afterwards. + */ + err = acpi_device_sleep_wake(dev, 1, sleep_state, 3); + + err_out: + if (err) + dev->wakeup.prepare_count = 0; + + out: + //mutex_unlock(&acpi_device_lock); + return err; +} + +/* + * Shutdown a wakeup device, counterpart of above method + * 1. Execute _DSW (Device Sleep Wake) or (deprecated in ACPI 3.0) _PSW (Power + * State Wake) for the device, if present + * 2. Shutdown down the power resources + */ +int acpi_disable_wakeup_device_power(struct acpi_device *dev) +{ + int i, err = 0; + + if (!dev || !dev->wakeup.flags.valid) + return -1; + + //mutex_lock(&acpi_device_lock); + + if (--dev->wakeup.prepare_count > 0) + goto out; + + /* + * Executing the code below even if prepare_count is already zero when + * the function is called may be useful, for example for initialisation. + */ + if (dev->wakeup.prepare_count < 0) + dev->wakeup.prepare_count = 0; + + err = acpi_device_sleep_wake(dev, 0, 0, 0); + if (err) + goto out; + + /* Close power resource */ + for (i = 0; i < dev->wakeup.resources.count; i++) { + int ret = acpi_power_off_device( + dev->wakeup.resources.handles[i], dev); + if (ret) { + DPRINT("Transition power state\n"); + dev->wakeup.flags.valid = 0; + err = -1; + goto out; + } + } + + out: + //mutex_unlock(&acpi_device_lock); + return err; +} + +/* -------------------------------------------------------------------------- + Device Power Management + -------------------------------------------------------------------------- */ + +int +acpi_power_get_inferred_state ( + struct acpi_device *device) +{ + int result = 0; + struct acpi_handle_list *list = NULL; + int list_state = 0; + int i = 0; + + + if (!device) + return_VALUE(-1); + + device->power.state = ACPI_STATE_UNKNOWN; + + /* + * We know a device's inferred power state when all the resources + * required for a given D-state are 'on'. + */ + for (i=ACPI_STATE_D0; ipower.states[i].resources; + if (list->count < 1) + continue; + + result = acpi_power_get_list_state(list, &list_state); + if (result) + return_VALUE(result); + + if (list_state == ACPI_POWER_RESOURCE_STATE_ON) { + device->power.state = i; + return_VALUE(0); + } + } + + device->power.state = ACPI_STATE_D3; + + return_VALUE(0); +} + + +int +acpi_power_transition ( + struct acpi_device *device, + int state) +{ + int result = 0; + struct acpi_handle_list *cl = NULL; /* Current Resources */ + struct acpi_handle_list *tl = NULL; /* Target Resources */ + int i = 0; + + if (!device || (state < ACPI_STATE_D0) || (state > ACPI_STATE_D3)) + return_VALUE(-1); + + if ((device->power.state < ACPI_STATE_D0) || (device->power.state > ACPI_STATE_D3)) + return_VALUE(-15); + + cl = &device->power.states[device->power.state].resources; + tl = &device->power.states[state].resources; + + /* TBD: Resources must be ordered. */ + + /* + * First we reference all power resources required in the target list + * (e.g. so the device doesn't lose power while transitioning). + */ + for (i = 0; i < tl->count; i++) { + result = acpi_power_on(tl->handles[i], device); + if (result) + goto end; + } + + if (device->power.state == state) { + goto end; + } + + /* + * Then we dereference all power resources used in the current list. + */ + for (i = 0; i < cl->count; i++) { + result = acpi_power_off_device(cl->handles[i], device); + if (result) + goto end; + } + + end: + if (result) + device->power.state = ACPI_STATE_UNKNOWN; + else { + /* We shouldn't change the state till all above operations succeed */ + device->power.state = state; + } + + return result; +} + +/* -------------------------------------------------------------------------- + Driver Interface + -------------------------------------------------------------------------- */ + +int +acpi_power_add ( + struct acpi_device *device) +{ + int result = 0, state; + ACPI_STATUS status = AE_OK; + struct acpi_power_resource *resource = NULL; + union acpi_object acpi_object; + ACPI_BUFFER buffer = {sizeof(ACPI_OBJECT), &acpi_object}; + + + if (!device) + return_VALUE(-1); + + resource = ExAllocatePool(NonPagedPool,sizeof(struct acpi_power_resource)); + if (!resource) + return_VALUE(-4); + + resource->device = device; + //mutex_init(&resource->resource_lock); + INIT_LIST_HEAD(&resource->reference); + + strcpy(resource->name, device->pnp.bus_id); + strcpy(acpi_device_name(device), ACPI_POWER_DEVICE_NAME); + strcpy(acpi_device_class(device), ACPI_POWER_CLASS); + device->driver_data = resource; + + /* Evalute the object to get the system level and resource order. */ + status = AcpiEvaluateObject(device->handle, NULL, NULL, &buffer); + if (ACPI_FAILURE(status)) { + result = -15; + goto end; + } + resource->system_level = acpi_object.PowerResource.SystemLevel; + resource->order = acpi_object.PowerResource.ResourceOrder; + + result = acpi_power_get_state(device->handle, &state); + if (result) + goto end; + + switch (state) { + case ACPI_POWER_RESOURCE_STATE_ON: + device->power.state = ACPI_STATE_D0; + break; + case ACPI_POWER_RESOURCE_STATE_OFF: + device->power.state = ACPI_STATE_D3; + break; + default: + device->power.state = ACPI_STATE_UNKNOWN; + break; + } + + + DPRINT("%s [%s] (%s)\n", acpi_device_name(device), + acpi_device_bid(device), state?"on":"off"); + +end: + if (result) + ExFreePool(resource); + + return result; +} + + +int +acpi_power_remove ( + struct acpi_device *device, + int type) +{ + struct acpi_power_resource *resource = NULL; + struct list_head *node, *next; + + if (!device || !acpi_driver_data(device)) + return_VALUE(-1); + + resource = acpi_driver_data(device); + + //mutex_lock(&resource->resource_lock); + list_for_each_safe(node, next, &resource->reference) { + struct acpi_power_reference *ref = container_of(node, struct acpi_power_reference, node); + list_del(&ref->node); + ExFreePool(ref); + } + //mutex_unlock(&resource->resource_lock); + ExFreePool(resource); + + return_VALUE(0); +} + +static int acpi_power_resume(struct acpi_device *device) +{ + int result = 0, state; + struct acpi_power_resource *resource = NULL; + struct acpi_power_reference *ref; + + if (!device || !acpi_driver_data(device)) + return -1; + + resource = acpi_driver_data(device); + + result = acpi_power_get_state(device->handle, &state); + if (result) + return result; + + //mutex_lock(&resource->resource_lock); + if (state == ACPI_POWER_RESOURCE_STATE_OFF && + !list_empty(&resource->reference)) { + ref = container_of(resource->reference.next, struct acpi_power_reference, node); + //mutex_unlock(&resource->resource_lock); + result = acpi_power_on(device->handle, ref->device); + return result; + } + + //mutex_unlock(&resource->resource_lock); + return 0; +} + +int +acpi_power_init (void) +{ + int result = 0; + + DPRINT("acpi_power_init"); + + INIT_LIST_HEAD(&acpi_power_resource_list); + + + result = acpi_bus_register_driver(&acpi_power_driver); + if (result < 0) { + return_VALUE(-15); + } + + return_VALUE(0); +} diff --git a/reactos/drivers/bus/acpi/busmgr/system.c b/reactos/drivers/bus/acpi/busmgr/system.c new file mode 100644 index 00000000000..ca5a0852bf9 --- /dev/null +++ b/reactos/drivers/bus/acpi/busmgr/system.c @@ -0,0 +1,427 @@ +/* + * acpi_system.c - ACPI System Driver ($Revision: 57 $) + * + * Copyright (C) 2001, 2002 Andy Grover + * Copyright (C) 2001, 2002 Paul Diefenbaugh + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + */ + +/* Modified for ReactOS and latest ACPICA + * Copyright (C)2009 Samuel Serapion + */ +#include +#include +#include +#include +#include "list.h" + +#define NDEBUG +#include + +ACPI_STATUS acpi_system_save_state(UINT32); + +#define _COMPONENT ACPI_SYSTEM_COMPONENT +ACPI_MODULE_NAME ("acpi_system") + +#define PREFIX "ACPI: " + +static int acpi_system_add (struct acpi_device *device); +static int acpi_system_remove (struct acpi_device *device, int type); + +ACPI_STATUS acpi_suspend (UINT32 state); + +static struct acpi_driver acpi_system_driver = { + .name = ACPI_SYSTEM_DRIVER_NAME, + .class = ACPI_SYSTEM_CLASS, + .ids = ACPI_SYSTEM_HID, + .ops = { + .add = acpi_system_add, + .remove = acpi_system_remove + }, +}; + +struct acpi_system +{ + ACPI_HANDLE handle; + UINT8 states[ACPI_S_STATE_COUNT]; +}; + + +static int +acpi_system_add ( + struct acpi_device *device) +{ + int result = 0; + ACPI_STATUS status = AE_OK; + struct acpi_system *system = NULL; + UINT8 i = 0; + + ACPI_FUNCTION_TRACE("acpi_system_add"); + + if (!device) + return_VALUE(-1); + + system = ExAllocatePool(NonPagedPool,sizeof(struct acpi_system)); + if (!system) + return_VALUE(-14); + memset(system, 0, sizeof(struct acpi_system)); + + system->handle = device->handle; + sprintf(acpi_device_name(device), "%s", ACPI_SYSTEM_DEVICE_NAME); + sprintf(acpi_device_class(device), "%s", ACPI_SYSTEM_CLASS); + acpi_driver_data(device) = system; + + DPRINT("%s [%s] (supports", + acpi_device_name(device), acpi_device_bid(device)); + for (i=0; iS4bios_f &&*/ + 0 != AcpiGbl_FADT.SmiCommand) { + DPRINT(" S4bios"); + system->states[i] = 1; + } + /* no break */ + default: + if (ACPI_SUCCESS(status)) { + system->states[i] = 1; + DPRINT(" S%d", i); + } + } + } + +//#ifdef CONFIG_PM +// /* Install the soft-off (S5) handler. */ +// if (system->states[ACPI_STATE_S5]) { +// pm_power_off = acpi_power_off; +// register_sysrq_key('o', &sysrq_acpi_poweroff_op); +// } +//#endif + + if (result) + ExFreePool(system); + + return_VALUE(result); +} + +static int +acpi_system_remove ( + struct acpi_device *device, + int type) +{ + struct acpi_system *system = NULL; + + ACPI_FUNCTION_TRACE("acpi_system_remove"); + + if (!device || !acpi_driver_data(device)) + return_VALUE(-1); + + system = (struct acpi_system *) acpi_driver_data(device); + +//#ifdef CONFIG_PM +// /* Remove the soft-off (S5) handler. */ +// if (system->states[ACPI_STATE_S5]) { +// unregister_sysrq_key('o', &sysrq_acpi_poweroff_op); +// pm_power_off = NULL; +// } +//#endif +// +// + ExFreePool(system); + + return 0; +} + +/** + * acpi_system_restore_state - OS-specific restoration of state + * @state: sleep state we're exiting + * + * Note that if we're coming back from S4, the memory image should have + * already been loaded from the disk and is already in place. (Otherwise how + * else would we be here?). + */ +ACPI_STATUS +acpi_system_restore_state( + UINT32 state) +{ + /* + * We should only be here if we're coming back from STR or STD. + * And, in the case of the latter, the memory image should have already + * been loaded from disk. + */ + if (state > ACPI_STATE_S1) { + //acpi_restore_state_mem(); + + /* Do _early_ resume for irqs. Required by + * ACPI specs. + */ + /* TBD: call arch dependant reinitialization of the + * interrupts. + */ +#ifdef _X86_ + //init_8259A(0); +#endif + /* wait for power to come back */ + KeStallExecutionProcessor(100); + + } + + /* Be really sure that irqs are disabled. */ + //ACPI_DISABLE_IRQS(); + + /* Wait a little again, just in case... */ + KeStallExecutionProcessor(10); + + /* enable interrupts once again */ + //ACPI_ENABLE_IRQS(); + + /* turn all the devices back on */ + //if (state > ACPI_STATE_S1) + //pm_send_all(PM_RESUME, (void *)0); + + return AE_OK; +} + + +/** + * acpi_system_save_state - save OS specific state and power down devices + * @state: sleep state we're entering. + * + * This handles saving all context to memory, and possibly disk. + * First, we call to the device driver layer to save device state. + * Once we have that, we save whatevery processor and kernel state we + * need to memory. + * If we're entering S4, we then write the memory image to disk. + * + * Only then it is safe for us to power down devices, since we may need + * the disks and upstream buses to write to. + */ +ACPI_STATUS +acpi_system_save_state( + UINT32 state) +{ + int error = 0; + + /* Send notification to devices that they will be suspended. + * If any device or driver cannot make the transition, either up + * or down, we'll get an error back. + */ + /*if (state > ACPI_STATE_S1) { + error = pm_send_all(PM_SAVE_STATE, (void *)3); + if (error) + return AE_ERROR; + }*/ + + //if (state <= ACPI_STATE_S5) { + // /* Tell devices to stop I/O and actually save their state. + // * It is theoretically possible that something could fail, + // * so handle that gracefully.. + // */ + // if (state > ACPI_STATE_S1 && state != ACPI_STATE_S5) { + // error = pm_send_all(PM_SUSPEND, (void *)3); + // if (error) { + // /* Tell devices to restore state if they have + // * it saved and to start taking I/O requests. + // */ + // pm_send_all(PM_RESUME, (void *)0); + // return error; + // } + // } + + /* flush caches */ + ACPI_FLUSH_CPU_CACHE(); + + /* Do arch specific saving of state. */ + if (state > ACPI_STATE_S1) { + error = 0;//acpi_save_state_mem(); + + /* TBD: if no s4bios, write codes for + * acpi_save_state_disk()... + */ +#if 0 + if (!error && (state == ACPI_STATE_S4)) + error = acpi_save_state_disk(); +#endif + /*if (error) { + pm_send_all(PM_RESUME, (void *)0); + return error; + }*/ + } + //} + /* disable interrupts + * Note that acpi_suspend -- our caller -- will do this once we return. + * But, we want it done early, so we don't get any suprises during + * the device suspend sequence. + */ + //ACPI_DISABLE_IRQS(); + + /* Unconditionally turn off devices. + * Obvious if we enter a sleep state. + * If entering S5 (soft off), this should put devices in a + * quiescent state. + */ + + //if (state > ACPI_STATE_S1) { + // error = pm_send_all(PM_SUSPEND, (void *)3); + + // /* We're pretty screwed if we got an error from this. + // * We try to recover by simply calling our own restore_state + // * function; see above for definition. + // * + // * If it's S5 though, go through with it anyway.. + // */ + // if (error && state != ACPI_STATE_S5) + // acpi_system_restore_state(state); + //} + return error ? AE_ERROR : AE_OK; +} + + +/**************************************************************************** + * + * FUNCTION: acpi_system_suspend + * + * PARAMETERS: %state: Sleep state to enter. + * + * RETURN: ACPI_STATUS, whether or not we successfully entered and + * exited sleep. + * + * DESCRIPTION: Perform OS-specific action to enter sleep state. + * This is the final step in going to sleep, per spec. If we + * know we're coming back (i.e. not entering S5), we save the + * processor flags. [ We'll have to save and restore them anyway, + * so we use the arch-agnostic save_flags and restore_flags + * here.] We then set the place to return to in arch-specific + * globals using arch_set_return_point. Finally, we call the + * ACPI function to write the proper values to I/O ports. + * + ****************************************************************************/ + +ACPI_STATUS +acpi_system_suspend( + UINT32 state) +{ + ACPI_STATUS status = AE_ERROR; + //unsigned long flags = 0; + + //local_irq_save(flags); + /* kernel_fpu_begin(); */ + + switch (state) { + case ACPI_STATE_S1: + case ACPI_STATE_S5: + //barrier(); + status = AcpiEnterSleepState(state); + break; + case ACPI_STATE_S4: + //do_suspend_lowlevel_s4bios(0); + break; + } + + /* kernel_fpu_end(); */ + //local_irq_restore(flags); + + return status; +} + + + +/** + * acpi_suspend - OS-agnostic system suspend/resume support (S? states) + * @state: state we're entering + * + */ +ACPI_STATUS +acpi_suspend ( + UINT32 state) +{ + ACPI_STATUS status; + + /* only support S1 and S5 on kernel 2.4 */ + //if (state != ACPI_STATE_S1 && state != ACPI_STATE_S4 + // && state != ACPI_STATE_S5) + // return AE_ERROR; + + + //if (ACPI_STATE_S4 == state) { + // /* For s4bios, we need a wakeup address. */ + // if (1 == AcpiGbl_FACS->S4bios_f && + // 0 != AcpiGbl_FADT->smi_cmd) { + // if (!acpi_wakeup_address) + // return AE_ERROR; + // AcpiSetFirmwareWakingVector((acpi_physical_address) acpi_wakeup_address); + // } else + // /* We don't support S4 under 2.4. Give up */ + // return AE_ERROR; + //} + AcpiEnterSleepStatePrep(state); + + status = AcpiEnterSleepState(state); + if (!ACPI_SUCCESS(status) && state != ACPI_STATE_S5) + return status; + + /* disable interrupts and flush caches */ + _disable(); + ACPI_FLUSH_CPU_CACHE(); + + /* perform OS-specific sleep actions */ + status = acpi_system_suspend(state); + + /* Even if we failed to go to sleep, all of the devices are in an suspended + * mode. So, we run these unconditionaly to make sure we have a usable system + * no matter what. + */ + AcpiLeaveSleepState(state); + acpi_system_restore_state(state); + + /* make sure interrupts are enabled */ + _enable(); + + /* reset firmware waking vector */ + AcpiSetFirmwareWakingVector((ACPI_PHYSICAL_ADDRESS) 0); + + return status; +} + +int +acpi_system_init (void) +{ + int result = 0; + + ACPI_FUNCTION_TRACE("acpi_system_init"); + + result = acpi_bus_register_driver(&acpi_system_driver); + if (result < 0) + return_VALUE(AE_NOT_FOUND); + + return_VALUE(0); +} + + +void +acpi_system_exit (void) +{ + ACPI_FUNCTION_TRACE("acpi_system_exit"); + acpi_bus_unregister_driver(&acpi_system_driver); + return_VOID; +} + diff --git a/reactos/drivers/bus/acpi/busmgr/utils.c b/reactos/drivers/bus/acpi/busmgr/utils.c new file mode 100644 index 00000000000..2a82e49604c --- /dev/null +++ b/reactos/drivers/bus/acpi/busmgr/utils.c @@ -0,0 +1,376 @@ +/* + * acpi_utils.c - ACPI Utility Functions ($Revision: 10 $) + * + * Copyright (C) 2001, 2002 Andy Grover + * Copyright (C) 2001, 2002 Paul Diefenbaugh + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + */ + +#include + +#include +#include +#include +#include + +#define NDEBUG +#include + + /* Modified for ReactOS and latest ACPICA + * Copyright (C)2009 Samuel Serapion + */ + +#define _COMPONENT ACPI_BUS_COMPONENT +ACPI_MODULE_NAME ("acpi_utils") + +static void +acpi_util_eval_error(ACPI_HANDLE h, ACPI_STRING p, ACPI_STATUS s) +{ +#ifdef ACPI_DEBUG_OUTPUT + char prefix[80] = {'\0'}; + ACPI_BUFFER buffer = {sizeof(prefix), prefix}; + AcpiGetName(h, ACPI_FULL_PATHNAME, &buffer); + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluate [%s.%s]: %s\n", + (char *) prefix, p, AcpiFormatException(s))); +#else + return; +#endif +} + + +/* -------------------------------------------------------------------------- + Object Evaluation Helpers + -------------------------------------------------------------------------- */ + + +ACPI_STATUS +acpi_extract_package ( + ACPI_OBJECT *package, + ACPI_BUFFER *format, + ACPI_BUFFER *buffer) +{ + UINT32 size_required = 0; + UINT32 tail_offset = 0; + char *format_string = NULL; + UINT32 format_count = 0; + UINT32 i = 0; + UINT8 *head = NULL; + UINT8 *tail = NULL; + + if (!package || (package->Type != ACPI_TYPE_PACKAGE) || (package->Package.Count < 1)) { + ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid 'package' argument\n")); + return_ACPI_STATUS(AE_BAD_PARAMETER); + } + + if (!format || !format->Pointer || (format->Length < 1)) { + ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid 'format' argument\n")); + return_ACPI_STATUS(AE_BAD_PARAMETER); + } + + if (!buffer) { + ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid 'buffer' argument\n")); + return_ACPI_STATUS(AE_BAD_PARAMETER); + } + + format_count = (format->Length/sizeof(char)) - 1; + if (format_count > package->Package.Count) { + ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Format specifies more objects [%d] than exist in package [%d].", format_count, package->package.count)); + return_ACPI_STATUS(AE_BAD_DATA); + } + + format_string = format->Pointer; + + /* + * Calculate size_required. + */ + for (i=0; iPackage.Elements[i]); + + if (!element) { + return_ACPI_STATUS(AE_BAD_DATA); + } + + switch (element->Type) { + + case ACPI_TYPE_INTEGER: + switch (format_string[i]) { + case 'N': + size_required += sizeof(ACPI_INTEGER); + tail_offset += sizeof(ACPI_INTEGER); + break; + case 'S': + size_required += sizeof(char*) + sizeof(ACPI_INTEGER) + sizeof(char); + tail_offset += sizeof(char*); + break; + default: + ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid package element [%d]: got number, expecing [%c].\n", i, format_string[i])); + return_ACPI_STATUS(AE_BAD_DATA); + break; + } + break; + + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + switch (format_string[i]) { + case 'S': + size_required += sizeof(char*) + (element->String.Length * sizeof(char)) + sizeof(char); + tail_offset += sizeof(char*); + break; + case 'B': + size_required += sizeof(UINT8*) + (element->Buffer.Length * sizeof(UINT8)); + tail_offset += sizeof(UINT8*); + break; + default: + ACPI_DEBUG_PRINT((ACPI_DB_WARN, "Invalid package element [%d] got string/buffer, expecing [%c].\n", i, format_string[i])); + return_ACPI_STATUS(AE_BAD_DATA); + break; + } + break; + + case ACPI_TYPE_PACKAGE: + default: + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found unsupported element at index=%d\n", i)); + /* TBD: handle nested packages... */ + return_ACPI_STATUS(AE_SUPPORT); + break; + } + } + + /* + * Validate output buffer. + */ + if (buffer->Length < size_required) { + buffer->Length = size_required; + return_ACPI_STATUS(AE_BUFFER_OVERFLOW); + } + else if (buffer->Length != size_required || !buffer->Pointer) { + return_ACPI_STATUS(AE_BAD_PARAMETER); + } + + head = buffer->Pointer; + tail = buffer->Pointer + tail_offset; + + /* + * Extract package data. + */ + for (i=0; iPackage.Elements[i]); + + if (!element) { + return_ACPI_STATUS(AE_BAD_DATA); + } + + switch (element->Type) { + + case ACPI_TYPE_INTEGER: + switch (format_string[i]) { + case 'N': + *((ACPI_INTEGER*)head) = element->Integer.Value; + head += sizeof(ACPI_INTEGER); + break; + case 'S': + pointer = (UINT8**)head; + *pointer = tail; + *((ACPI_INTEGER*)tail) = element->Integer.Value; + head += sizeof(ACPI_INTEGER*); + tail += sizeof(ACPI_INTEGER); + /* NULL terminate string */ + *tail = (char)0; + tail += sizeof(char); + break; + default: + /* Should never get here */ + break; + } + break; + + case ACPI_TYPE_STRING: + case ACPI_TYPE_BUFFER: + switch (format_string[i]) { + case 'S': + pointer = (UINT8**)head; + *pointer = tail; + memcpy(tail, element->String.Pointer, element->String.Length); + head += sizeof(char*); + tail += element->String.Length * sizeof(char); + /* NULL terminate string */ + *tail = (char)0; + tail += sizeof(char); + break; + case 'B': + pointer = (UINT8**)head; + *pointer = tail; + memcpy(tail, element->Buffer.Pointer, element->Buffer.Length); + head += sizeof(UINT8*); + tail += element->Buffer.Length * sizeof(UINT8); + break; + default: + /* Should never get here */ + break; + } + break; + + case ACPI_TYPE_PACKAGE: + /* TBD: handle nested packages... */ + default: + /* Should never get here */ + break; + } + } + + return_ACPI_STATUS(AE_OK); +} + + +ACPI_STATUS +acpi_evaluate_integer ( + ACPI_HANDLE handle, + ACPI_STRING pathname, + ACPI_OBJECT_LIST *arguments, + unsigned long long *data) +{ + ACPI_STATUS status = AE_OK; + ACPI_OBJECT element; + ACPI_BUFFER buffer = {sizeof(ACPI_OBJECT), &element}; + + ACPI_FUNCTION_TRACE("acpi_evaluate_integer"); + + if (!data) + return_ACPI_STATUS(AE_BAD_PARAMETER); + + status = AcpiEvaluateObject(handle, pathname, arguments, &buffer); + if (ACPI_FAILURE(status)) { + acpi_util_eval_error(handle, pathname, status); + return_ACPI_STATUS(status); + } + + if (element.Type != ACPI_TYPE_INTEGER) { + acpi_util_eval_error(handle, pathname, AE_BAD_DATA); + return_ACPI_STATUS(AE_BAD_DATA); + } + + *data = element.Integer.Value; + + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Return value [%lu]\n", *data)); + + return_ACPI_STATUS(AE_OK); +} + + +ACPI_STATUS +acpi_evaluate_reference ( + ACPI_HANDLE handle, + ACPI_STRING pathname, + ACPI_OBJECT_LIST *arguments, + struct acpi_handle_list *list) +{ + ACPI_STATUS status = AE_OK; + ACPI_OBJECT *package = NULL; + ACPI_OBJECT *element = NULL; + ACPI_BUFFER buffer = {ACPI_ALLOCATE_BUFFER, NULL}; + UINT32 i = 0; + + ACPI_FUNCTION_TRACE("acpi_evaluate_reference"); + + if (!list) { + return_ACPI_STATUS(AE_BAD_PARAMETER); + } + + /* Evaluate object. */ + + status = AcpiEvaluateObject(handle, pathname, arguments, &buffer); + if (ACPI_FAILURE(status)) + goto end; + + package = (ACPI_OBJECT *) buffer.Pointer; + + if ((buffer.Length == 0) || !package) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "No return object (len %X ptr %p)\n", + buffer.Length, package)); + status = AE_BAD_DATA; + acpi_util_eval_error(handle, pathname, status); + goto end; + } + if (package->Type != ACPI_TYPE_PACKAGE) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Expecting a [Package], found type %X\n", + package->Type)); + status = AE_BAD_DATA; + acpi_util_eval_error(handle, pathname, status); + goto end; + } + if (!package->Package.Count) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "[Package] has zero elements (%p)\n", + package)); + status = AE_BAD_DATA; + acpi_util_eval_error(handle, pathname, status); + goto end; + } + + if (package->Package.Count > ACPI_MAX_HANDLES) { + return AE_NO_MEMORY; + } + list->count = package->Package.Count; + + /* Extract package data. */ + + for (i = 0; i < list->count; i++) { + + element = &(package->Package.Elements[i]); + + if (element->Type != ACPI_TYPE_LOCAL_REFERENCE) { + status = AE_BAD_DATA; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, + "Expecting a [Reference] package element, found type %X\n", + element->type)); + acpi_util_eval_error(handle, pathname, status); + break; + } + + if (!element->Reference.Handle) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid reference in" + " package %s\n", pathname)); + status = AE_NULL_ENTRY; + break; + } + /* Get the ACPI_HANDLE. */ + + list->handles[i] = element->Reference.Handle; + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found reference [%p]\n", + list->handles[i])); + } + +end: + if (ACPI_FAILURE(status)) { + list->count = 0; + //ExFreePool(list->handles); + } + + AcpiOsFree(buffer.Pointer); + + return_ACPI_STATUS(status); +} + + diff --git a/reactos/drivers/bus/acpi/buspdo.c b/reactos/drivers/bus/acpi/buspdo.c new file mode 100644 index 00000000000..ed6439d60a5 --- /dev/null +++ b/reactos/drivers/bus/acpi/buspdo.c @@ -0,0 +1,1670 @@ +#include + +#include +#include +#include +#include + +#include +#include + +#define NDEBUG +#include + +#ifdef ALLOC_PRAGMA +#pragma alloc_text (PAGE, Bus_PDO_PnP) +#pragma alloc_text (PAGE, Bus_PDO_QueryDeviceCaps) +#pragma alloc_text (PAGE, Bus_PDO_QueryDeviceId) +#pragma alloc_text (PAGE, Bus_PDO_QueryDeviceText) +#pragma alloc_text (PAGE, Bus_PDO_QueryResources) +#pragma alloc_text (PAGE, Bus_PDO_QueryResourceRequirements) +#pragma alloc_text (PAGE, Bus_PDO_QueryDeviceRelations) +#pragma alloc_text (PAGE, Bus_PDO_QueryBusInformation) +#pragma alloc_text (PAGE, Bus_GetDeviceCapabilities) +#endif + +NTSTATUS +Bus_PDO_PnP ( + PDEVICE_OBJECT DeviceObject, + PIRP Irp, + PIO_STACK_LOCATION IrpStack, + PPDO_DEVICE_DATA DeviceData + ) +{ + NTSTATUS status; + POWER_STATE state; + + PAGED_CODE (); + + // + // NB: Because we are a bus enumerator, we have no one to whom we could + // defer these irps. Therefore we do not pass them down but merely + // return them. + // + + switch (IrpStack->MinorFunction) { + + case IRP_MN_START_DEVICE: + + // + // Here we do what ever initialization and ``turning on'' that is + // required to allow others to access this device. + // Power up the device. + // + if (DeviceData->AcpiHandle && acpi_bus_power_manageable(DeviceData->AcpiHandle) && + !ACPI_SUCCESS(acpi_bus_set_power(DeviceData->AcpiHandle, ACPI_STATE_D0))) + { + DPRINT1("Device %x failed to start!\n", DeviceData->AcpiHandle); + status = STATUS_UNSUCCESSFUL; + break; + } + + state.DeviceState = PowerDeviceD0; + PoSetPowerState(DeviceData->Common.Self, DevicePowerState, state); + DeviceData->Common.DevicePowerState = PowerDeviceD0; + SET_NEW_PNP_STATE(DeviceData->Common, Started); + status = STATUS_SUCCESS; + break; + + case IRP_MN_STOP_DEVICE: + + // + // Here we shut down the device and give up and unmap any resources + // we acquired for the device. + // + if (DeviceData->AcpiHandle && acpi_bus_power_manageable(DeviceData->AcpiHandle) && + !ACPI_SUCCESS(acpi_bus_set_power(DeviceData->AcpiHandle, ACPI_STATE_D3))) + { + DPRINT1("Device %x failed to stop!\n", DeviceData->AcpiHandle); + status = STATUS_UNSUCCESSFUL; + break; + } + + state.DeviceState = PowerDeviceD3; + PoSetPowerState(DeviceData->Common.Self, DevicePowerState, state); + DeviceData->Common.DevicePowerState = PowerDeviceD3; + SET_NEW_PNP_STATE(DeviceData->Common, Stopped); + status = STATUS_SUCCESS; + break; + + + case IRP_MN_QUERY_STOP_DEVICE: + + // + // No reason here why we can't stop the device. + // If there were a reason we should speak now, because answering success + // here may result in a stop device irp. + // + + SET_NEW_PNP_STATE(DeviceData->Common, StopPending); + status = STATUS_SUCCESS; + break; + + case IRP_MN_CANCEL_STOP_DEVICE: + + // + // The stop was canceled. Whatever state we set, or resources we put + // on hold in anticipation of the forthcoming STOP device IRP should be + // put back to normal. Someone, in the long list of concerned parties, + // has failed the stop device query. + // + + // + // First check to see whether you have received cancel-stop + // without first receiving a query-stop. This could happen if someone + // above us fails a query-stop and passes down the subsequent + // cancel-stop. + // + + if (StopPending == DeviceData->Common.DevicePnPState) + { + // + // We did receive a query-stop, so restore. + // + RESTORE_PREVIOUS_PNP_STATE(DeviceData->Common); + } + status = STATUS_SUCCESS;// We must not fail this IRP. + break; + case IRP_MN_QUERY_CAPABILITIES: + + // + // Return the capabilities of a device, such as whether the device + // can be locked or ejected..etc + // + + status = Bus_PDO_QueryDeviceCaps(DeviceData, Irp); + + break; + + case IRP_MN_QUERY_ID: + + // Query the IDs of the device + status = Bus_PDO_QueryDeviceId(DeviceData, Irp); + + break; + + case IRP_MN_QUERY_DEVICE_RELATIONS: + + DPRINT("\tQueryDeviceRelation Type: %s\n",DbgDeviceRelationString(\ + IrpStack->Parameters.QueryDeviceRelations.Type)); + + status = Bus_PDO_QueryDeviceRelations(DeviceData, Irp); + + break; + + case IRP_MN_QUERY_DEVICE_TEXT: + + status = Bus_PDO_QueryDeviceText(DeviceData, Irp); + + break; + + case IRP_MN_QUERY_RESOURCES: + + status = Bus_PDO_QueryResources(DeviceData, Irp); + + break; + + case IRP_MN_QUERY_RESOURCE_REQUIREMENTS: + + status = Bus_PDO_QueryResourceRequirements(DeviceData, Irp); + + break; + + case IRP_MN_QUERY_BUS_INFORMATION: + + status = Bus_PDO_QueryBusInformation(DeviceData, Irp); + + break; + + case IRP_MN_QUERY_INTERFACE: + + status = Bus_PDO_QueryInterface(DeviceData, Irp); + + break; + + + case IRP_MN_FILTER_RESOURCE_REQUIREMENTS: + + // + // OPTIONAL for bus drivers. + // The PnP Manager sends this IRP to a device + // stack so filter and function drivers can adjust the + // resources required by the device, if appropriate. + // + + //break; + + //case IRP_MN_QUERY_PNP_DEVICE_STATE: + + // + // OPTIONAL for bus drivers. + // The PnP Manager sends this IRP after the drivers for + // a device return success from the IRP_MN_START_DEVICE + // request. The PnP Manager also sends this IRP when a + // driver for the device calls IoInvalidateDeviceState. + // + + // break; + + //case IRP_MN_READ_CONFIG: + //case IRP_MN_WRITE_CONFIG: + + // + // Bus drivers for buses with configuration space must handle + // this request for their child devices. Our devices don't + // have a config space. + // + + // break; + + //case IRP_MN_SET_LOCK: + + // break; + + default: + + // + // For PnP requests to the PDO that we do not understand we should + // return the IRP WITHOUT setting the status or information fields. + // These fields may have already been set by a filter (eg acpi). + status = Irp->IoStatus.Status; + + break; + } + + Irp->IoStatus.Status = status; + IoCompleteRequest (Irp, IO_NO_INCREMENT); + + return status; +} + +NTSTATUS +Bus_PDO_QueryDeviceCaps( + PPDO_DEVICE_DATA DeviceData, + PIRP Irp ) +{ + + PIO_STACK_LOCATION stack; + PDEVICE_CAPABILITIES deviceCapabilities; + struct acpi_device *device = NULL; + ULONG i; + + PAGED_CODE (); + + if (DeviceData->AcpiHandle) + acpi_bus_get_device(DeviceData->AcpiHandle, &device); + + stack = IoGetCurrentIrpStackLocation (Irp); + + // + // Get the packet. + // + deviceCapabilities=stack->Parameters.DeviceCapabilities.Capabilities; + + // + // Set the capabilities. + // + + if (deviceCapabilities->Version != 1 || + deviceCapabilities->Size < sizeof(DEVICE_CAPABILITIES)) + { + return STATUS_UNSUCCESSFUL; + } + + deviceCapabilities->D1Latency = 0; + deviceCapabilities->D2Latency = 0; + deviceCapabilities->D3Latency = 0; + + deviceCapabilities->DeviceState[PowerSystemWorking] = PowerDeviceD0; + deviceCapabilities->DeviceState[PowerSystemSleeping1] = PowerDeviceD3; + deviceCapabilities->DeviceState[PowerSystemSleeping2] = PowerDeviceD3; + deviceCapabilities->DeviceState[PowerSystemSleeping3] = PowerDeviceD3; + + for (i = 0; i < ACPI_D_STATE_COUNT && device; i++) + { + if (!device->power.states[i].flags.valid) + continue; + + switch (i) + { + case ACPI_STATE_D0: + deviceCapabilities->DeviceState[PowerSystemWorking] = PowerDeviceD0; + break; + + case ACPI_STATE_D1: + deviceCapabilities->DeviceState[PowerSystemSleeping1] = PowerDeviceD1; + deviceCapabilities->D1Latency = device->power.states[i].latency; + break; + + case ACPI_STATE_D2: + deviceCapabilities->DeviceState[PowerSystemSleeping2] = PowerDeviceD2; + deviceCapabilities->D2Latency = device->power.states[i].latency; + break; + + case ACPI_STATE_D3: + deviceCapabilities->DeviceState[PowerSystemSleeping3] = PowerDeviceD3; + deviceCapabilities->D3Latency = device->power.states[i].latency; + break; + } + } + + // We can wake the system from D1 + deviceCapabilities->DeviceWake = PowerDeviceD1; + + + deviceCapabilities->DeviceD1 = + (deviceCapabilities->DeviceState[PowerSystemSleeping1] == PowerDeviceD1) ? TRUE : FALSE; + deviceCapabilities->DeviceD2 = + (deviceCapabilities->DeviceState[PowerSystemSleeping2] == PowerDeviceD2) ? TRUE : FALSE; + + deviceCapabilities->WakeFromD0 = FALSE; + deviceCapabilities->WakeFromD1 = TRUE; //Yes we can + deviceCapabilities->WakeFromD2 = FALSE; + deviceCapabilities->WakeFromD3 = FALSE; + + if (device) + { + deviceCapabilities->EjectSupported = device->flags.ejectable; + deviceCapabilities->HardwareDisabled = !device->status.enabled; + deviceCapabilities->Removable = device->flags.removable; + deviceCapabilities->SurpriseRemovalOK = device->flags.suprise_removal_ok; + deviceCapabilities->UniqueID = device->flags.unique_id; + deviceCapabilities->NoDisplayInUI = !device->status.show_in_ui; + deviceCapabilities->Address = device->pnp.bus_address; + deviceCapabilities->RawDeviceOK = FALSE; + } + else + { + deviceCapabilities->EjectSupported = FALSE; + deviceCapabilities->HardwareDisabled = FALSE; + deviceCapabilities->Removable = FALSE; + deviceCapabilities->SurpriseRemovalOK = FALSE; + deviceCapabilities->UniqueID = FALSE; + deviceCapabilities->NoDisplayInUI = FALSE; + deviceCapabilities->Address = 0; + + /* The ACPI driver will run fixed buttons */ + deviceCapabilities->RawDeviceOK = TRUE; + } + + deviceCapabilities->SilentInstall = FALSE; + deviceCapabilities->UINumber = (ULONG)-1; + + return STATUS_SUCCESS; + +} + +NTSTATUS +Bus_PDO_QueryDeviceId( + PPDO_DEVICE_DATA DeviceData, + PIRP Irp ) +{ + PIO_STACK_LOCATION stack; + PWCHAR buffer; + WCHAR temp[256]; + ULONG length; + NTSTATUS status = STATUS_SUCCESS; + struct acpi_device *Device; + + PAGED_CODE (); + + stack = IoGetCurrentIrpStackLocation (Irp); + + switch (stack->Parameters.QueryId.IdType) { + + case BusQueryDeviceID: + if (DeviceData->AcpiHandle) + { + acpi_bus_get_device(DeviceData->AcpiHandle, &Device); + + length = swprintf(temp, + L"ACPI\\%hs", + Device->pnp.hardware_id); + } + else + { + /* We know it's a fixed feature button because + * these are direct children of the ACPI root device + * and therefore have no handle + */ + length = swprintf(temp, + L"ACPI\\FixedButton"); + } + + temp[++length] = UNICODE_NULL; + + buffer = ExAllocatePoolWithTag (PagedPool, length * sizeof(WCHAR), 'IPCA'); + + if (!buffer) { + status = STATUS_INSUFFICIENT_RESOURCES; + break; + } + + RtlCopyMemory (buffer, temp, length * sizeof(WCHAR)); + Irp->IoStatus.Information = (ULONG_PTR) buffer; + DPRINT("BusQueryDeviceID: %ls\n",buffer); + break; + + case BusQueryInstanceID: + /* See comment in BusQueryDeviceID case */ + if(DeviceData->AcpiHandle) + { + acpi_bus_get_device(DeviceData->AcpiHandle, &Device); + + if (Device->flags.unique_id) + length = swprintf(temp, + L"%hs", + Device->pnp.unique_id); + else + /* FIXME: Generate unique id! */ + length = swprintf(temp, L"%ls", L"0000"); + } + else + /* FIXME: Generate unique id! */ + length = swprintf(temp, L"%ls", L"0000"); + + temp[++length] = UNICODE_NULL; + + buffer = ExAllocatePoolWithTag (PagedPool, length * sizeof (WCHAR), 'IPCA'); + if (!buffer) { + status = STATUS_INSUFFICIENT_RESOURCES; + break; + } + + RtlCopyMemory (buffer, temp, length * sizeof (WCHAR)); + DPRINT("BusQueryInstanceID: %ls\n",buffer); + Irp->IoStatus.Information = (ULONG_PTR) buffer; + break; + + case BusQueryHardwareIDs: + length = 0; + + /* See comment in BusQueryDeviceID case */ + if (DeviceData->AcpiHandle) + { + acpi_bus_get_device(DeviceData->AcpiHandle, &Device); + + length += swprintf(&temp[length], + L"ACPI\\%hs", + Device->pnp.hardware_id); + length++; + + length += swprintf(&temp[length], + L"*%hs", + Device->pnp.hardware_id); + length++; + } + else + { + length += swprintf(&temp[length], + L"ACPI\\FixedButton"); + length++; + + length += swprintf(&temp[length], + L"*FixedButton"); + length++; + } + + temp[length] = UNICODE_NULL; + + length++; + + temp[length] = UNICODE_NULL; + + buffer = ExAllocatePoolWithTag (PagedPool, length * sizeof(WCHAR), 'IPCA'); + + if (!buffer) { + status = STATUS_INSUFFICIENT_RESOURCES; + break; + } + + RtlCopyMemory (buffer, temp, length * sizeof(WCHAR)); + Irp->IoStatus.Information = (ULONG_PTR) buffer; + DPRINT("BusQueryHardwareIDs: %ls\n",buffer); + break; + + default: + status = Irp->IoStatus.Status; + } + return status; +} + +NTSTATUS +Bus_PDO_QueryDeviceText( + PPDO_DEVICE_DATA DeviceData, + PIRP Irp ) +{ + PWCHAR Buffer; + PIO_STACK_LOCATION stack; + NTSTATUS status; + PAGED_CODE (); + + stack = IoGetCurrentIrpStackLocation (Irp); + + switch (stack->Parameters.QueryDeviceText.DeviceTextType) { + + case DeviceTextDescription: + + if (!Irp->IoStatus.Information) { + if (wcsstr (DeviceData->HardwareIDs, L"PNP000") != 0) + Buffer = L"Programmable interrupt controller"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP010") != 0) + Buffer = L"System timer"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP020") != 0) + Buffer = L"DMA controller"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP03") != 0) + Buffer = L"Keyboard"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP040") != 0) + Buffer = L"Parallel port"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP05") != 0) + Buffer = L"Serial port"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP06") != 0) + Buffer = L"Disk controller"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP07") != 0) + Buffer = L"Disk controller"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP09") != 0) + Buffer = L"Display adapter"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP0A0") != 0) + Buffer = L"Bus controller"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP0E0") != 0) + Buffer = L"PCMCIA controller"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP0F") != 0) + Buffer = L"Mouse device"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP8") != 0) + Buffer = L"Network adapter"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNPA0") != 0) + Buffer = L"SCSI controller"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNPB0") != 0) + Buffer = L"Multimedia device"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNPC00") != 0) + Buffer = L"Modem"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP0C0C") != 0) + Buffer = L"Power Button"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP0C0E") != 0) + Buffer = L"Sleep Button"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP0C0D") != 0) + Buffer = L"Lid Switch"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP0C09") != 0) + Buffer = L"ACPI Embedded Controller"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP0C0B") != 0) + Buffer = L"ACPI Fan"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP0A03") != 0) + Buffer = L"PCI Root Bridge"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP0C0A") != 0) + Buffer = L"ACPI Battery"; + else if (wcsstr(DeviceData->HardwareIDs, L"PNP0C0F") != 0) + Buffer = L"PCI Interrupt Link"; + else if (wcsstr(DeviceData->HardwareIDs, L"ACPI_PWR") != 0) + Buffer = L"ACPI Power Resource"; + else if (wcsstr(DeviceData->HardwareIDs, L"Processor") != 0) + Buffer = L"Processor"; + else if (wcsstr(DeviceData->HardwareIDs, L"ThermalZone") != 0) + Buffer = L"ACPI Thermal Zone"; + else if (wcsstr(DeviceData->HardwareIDs, L"ACPI0002") != 0) + Buffer = L"Smart Battery"; + else if (wcsstr(DeviceData->HardwareIDs, L"ACPI0003") != 0) + Buffer = L"AC Adapter"; + /* Simply checking if AcpiHandle is NULL eliminates the need to check + * for the 4 different names that ACPI knows the fixed feature button as internally + */ + else if (!DeviceData->AcpiHandle) + Buffer = L"ACPI Fixed Feature Button"; + else + Buffer = L"Other ACPI device"; + + DPRINT("\tDeviceTextDescription :%ws\n", Buffer); + + Irp->IoStatus.Information = (ULONG_PTR) Buffer; + } + status = STATUS_SUCCESS; + break; + + default: + status = Irp->IoStatus.Status; + break; + } + + return status; + +} + +NTSTATUS +Bus_PDO_QueryResources( + PPDO_DEVICE_DATA DeviceData, + PIRP Irp ) +{ + ULONG NumberOfResources = 0; + PCM_RESOURCE_LIST ResourceList; + PCM_PARTIAL_RESOURCE_DESCRIPTOR ResourceDescriptor; + ACPI_STATUS AcpiStatus; + ACPI_BUFFER Buffer; + ACPI_RESOURCE* resource; + ULONG ResourceListSize; + ULONG i; + + /* Get current resources */ + Buffer.Length = 0; + AcpiStatus = AcpiGetCurrentResources(DeviceData->AcpiHandle, &Buffer); + if ((!ACPI_SUCCESS(AcpiStatus) && AcpiStatus != AE_BUFFER_OVERFLOW) || + Buffer.Length == 0) + { + return Irp->IoStatus.Status; + } + + Buffer.Pointer = ExAllocatePool(PagedPool, Buffer.Length); + if (!Buffer.Pointer) + return STATUS_INSUFFICIENT_RESOURCES; + + AcpiStatus = AcpiGetCurrentResources(DeviceData->AcpiHandle, &Buffer); + if (!ACPI_SUCCESS(AcpiStatus)) + { + DPRINT1("AcpiGetCurrentResources #2 failed (0x%x)\n", AcpiStatus); + ASSERT(FALSE); + return STATUS_UNSUCCESSFUL; + } + + resource= Buffer.Pointer; + /* Count number of resources */ + while (resource->Type != ACPI_RESOURCE_TYPE_END_TAG) + { + switch (resource->Type) + { + case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: + { + ACPI_RESOURCE_EXTENDED_IRQ *irq_data = (ACPI_RESOURCE_EXTENDED_IRQ*) &resource->Data; + NumberOfResources += irq_data->InterruptCount; + break; + } + case ACPI_RESOURCE_TYPE_IRQ: + { + ACPI_RESOURCE_IRQ *irq_data = (ACPI_RESOURCE_IRQ*) &resource->Data; + NumberOfResources += irq_data->InterruptCount; + break; + } + case ACPI_RESOURCE_TYPE_DMA: + { + ACPI_RESOURCE_DMA *dma_data = (ACPI_RESOURCE_DMA*) &resource->Data; + NumberOfResources += dma_data->ChannelCount; + break; + } + case ACPI_RESOURCE_TYPE_ADDRESS16: + case ACPI_RESOURCE_TYPE_ADDRESS32: + case ACPI_RESOURCE_TYPE_ADDRESS64: + case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64: + case ACPI_RESOURCE_TYPE_MEMORY24: + case ACPI_RESOURCE_TYPE_MEMORY32: + case ACPI_RESOURCE_TYPE_IO: + { + NumberOfResources++; + break; + } + default: + { + DPRINT1("Unknown resource type: %d\n", resource->Type); + break; + } + } + resource = ACPI_NEXT_RESOURCE(resource); + } + + /* Allocate memory */ + ResourceListSize = sizeof(CM_RESOURCE_LIST) + sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR) * (NumberOfResources - 1); + ResourceList = (PCM_RESOURCE_LIST)ExAllocatePool(PagedPool, ResourceListSize); + + if (!ResourceList) + { + ExFreePool(Buffer.Pointer); + return STATUS_INSUFFICIENT_RESOURCES; + } + ResourceList->Count = 1; + ResourceList->List[0].InterfaceType = Internal; /* FIXME */ + ResourceList->List[0].BusNumber = 0; /* We're the only ACPI bus device in the system */ + ResourceList->List[0].PartialResourceList.Version = 1; + ResourceList->List[0].PartialResourceList.Revision = 1; + ResourceList->List[0].PartialResourceList.Count = NumberOfResources; + ResourceDescriptor = ResourceList->List[0].PartialResourceList.PartialDescriptors; + + /* Fill resources list structure */ + resource = Buffer.Pointer; + while (resource->Type != ACPI_RESOURCE_TYPE_END_TAG) + { + switch (resource->Type) + { + case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: + { + ACPI_RESOURCE_EXTENDED_IRQ *irq_data = (ACPI_RESOURCE_EXTENDED_IRQ*) &resource->Data; + for (i = 0; i < irq_data->InterruptCount; i++) + { + ResourceDescriptor->Type = CmResourceTypeInterrupt; + + ResourceDescriptor->ShareDisposition = + (irq_data->Sharable == ACPI_SHARED ? CmResourceShareShared : CmResourceShareDeviceExclusive); + ResourceDescriptor->Flags = + (irq_data->Triggering == ACPI_LEVEL_SENSITIVE ? CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE : CM_RESOURCE_INTERRUPT_LATCHED); + ResourceDescriptor->u.Interrupt.Level = irq_data->Interrupts[i]; + ResourceDescriptor->u.Interrupt.Vector = 0; + ResourceDescriptor->u.Interrupt.Affinity = (KAFFINITY)(-1); + + ResourceDescriptor++; + } + break; + } + case ACPI_RESOURCE_TYPE_IRQ: + { + ACPI_RESOURCE_IRQ *irq_data = (ACPI_RESOURCE_IRQ*) &resource->Data; + for (i = 0; i < irq_data->InterruptCount; i++) + { + ResourceDescriptor->Type = CmResourceTypeInterrupt; + + ResourceDescriptor->ShareDisposition = + (irq_data->Sharable == ACPI_SHARED ? CmResourceShareShared : CmResourceShareDeviceExclusive); + ResourceDescriptor->Flags = + (irq_data->Triggering == ACPI_LEVEL_SENSITIVE ? CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE : CM_RESOURCE_INTERRUPT_LATCHED); + ResourceDescriptor->u.Interrupt.Level = irq_data->Interrupts[i]; + ResourceDescriptor->u.Interrupt.Vector = 0; + ResourceDescriptor->u.Interrupt.Affinity = (KAFFINITY)(-1); + + ResourceDescriptor++; + } + break; + } + case ACPI_RESOURCE_TYPE_DMA: + { + ACPI_RESOURCE_DMA *dma_data = (ACPI_RESOURCE_DMA*) &resource->Data; + for (i = 0; i < dma_data->ChannelCount; i++) + { + ResourceDescriptor->Type = CmResourceTypeDma; + ResourceDescriptor->Flags = 0; + switch (dma_data->Type) + { + case ACPI_TYPE_A: ResourceDescriptor->Flags |= CM_RESOURCE_DMA_TYPE_A; break; + case ACPI_TYPE_B: ResourceDescriptor->Flags |= CM_RESOURCE_DMA_TYPE_B; break; + case ACPI_TYPE_F: ResourceDescriptor->Flags |= CM_RESOURCE_DMA_TYPE_F; break; + } + if (dma_data->BusMaster == ACPI_BUS_MASTER) + ResourceDescriptor->Flags |= CM_RESOURCE_DMA_BUS_MASTER; + switch (dma_data->Transfer) + { + case ACPI_TRANSFER_8: ResourceDescriptor->Flags |= CM_RESOURCE_DMA_8; break; + case ACPI_TRANSFER_16: ResourceDescriptor->Flags |= CM_RESOURCE_DMA_16; break; + case ACPI_TRANSFER_8_16: ResourceDescriptor->Flags |= CM_RESOURCE_DMA_8_AND_16; break; + } + ResourceDescriptor->u.Dma.Channel = dma_data->Channels[i]; + + ResourceDescriptor++; + } + break; + } + case ACPI_RESOURCE_TYPE_IO: + { + ACPI_RESOURCE_IO *io_data = (ACPI_RESOURCE_IO*) &resource->Data; + ResourceDescriptor->Type = CmResourceTypePort; + ResourceDescriptor->ShareDisposition = CmResourceShareDriverExclusive; + ResourceDescriptor->Flags = CM_RESOURCE_PORT_IO; + if (io_data->IoDecode == ACPI_DECODE_16) + ResourceDescriptor->Flags |= CM_RESOURCE_PORT_16_BIT_DECODE; + else + ResourceDescriptor->Flags |= CM_RESOURCE_PORT_10_BIT_DECODE; + ResourceDescriptor->u.Port.Start.QuadPart = io_data->Minimum; + ResourceDescriptor->u.Port.Length = io_data->AddressLength; + + ResourceDescriptor++; + break; + } + case ACPI_RESOURCE_TYPE_ADDRESS16: + { + ACPI_RESOURCE_ADDRESS16 *addr16_data = (ACPI_RESOURCE_ADDRESS16*) &resource->Data; + if (addr16_data->ResourceType == ACPI_BUS_NUMBER_RANGE) + { + ResourceDescriptor->Type = CmResourceTypeBusNumber; + ResourceDescriptor->ShareDisposition = CmResourceShareShared; + ResourceDescriptor->Flags = 0; + ResourceDescriptor->u.BusNumber.Start = addr16_data->Minimum; + ResourceDescriptor->u.BusNumber.Length = addr16_data->AddressLength; + } + else if (addr16_data->ResourceType == ACPI_IO_RANGE) + { + ResourceDescriptor->Type = CmResourceTypePort; + ResourceDescriptor->ShareDisposition = CmResourceShareDeviceExclusive; + ResourceDescriptor->Flags = CM_RESOURCE_PORT_IO; + if (addr16_data->Decode == ACPI_POS_DECODE) + ResourceDescriptor->Flags |= CM_RESOURCE_PORT_POSITIVE_DECODE; + ResourceDescriptor->u.Port.Start.QuadPart = addr16_data->Minimum; + ResourceDescriptor->u.Port.Length = addr16_data->AddressLength; + } + else + { + ResourceDescriptor->Type = CmResourceTypeMemory; + ResourceDescriptor->ShareDisposition = CmResourceShareDeviceExclusive; + ResourceDescriptor->Flags = 0; + if (addr16_data->Info.Mem.WriteProtect == ACPI_READ_ONLY_MEMORY) + ResourceDescriptor->Flags |= CM_RESOURCE_MEMORY_READ_ONLY; + else + ResourceDescriptor->Flags |= CM_RESOURCE_MEMORY_READ_WRITE; + switch (addr16_data->Info.Mem.Caching) + { + case ACPI_CACHABLE_MEMORY: ResourceDescriptor->Flags |= CM_RESOURCE_MEMORY_CACHEABLE; break; + case ACPI_WRITE_COMBINING_MEMORY: ResourceDescriptor->Flags |= CM_RESOURCE_MEMORY_COMBINEDWRITE; break; + case ACPI_PREFETCHABLE_MEMORY: ResourceDescriptor->Flags |= CM_RESOURCE_MEMORY_PREFETCHABLE; break; + } + ResourceDescriptor->u.Memory.Start.QuadPart = addr16_data->Minimum; + ResourceDescriptor->u.Memory.Length = addr16_data->AddressLength; + } + ResourceDescriptor++; + break; + } + case ACPI_RESOURCE_TYPE_ADDRESS32: + { + ACPI_RESOURCE_ADDRESS32 *addr32_data = (ACPI_RESOURCE_ADDRESS32*) &resource->Data; + if (addr32_data->ResourceType == ACPI_BUS_NUMBER_RANGE) + { + ResourceDescriptor->Type = CmResourceTypeBusNumber; + ResourceDescriptor->ShareDisposition = CmResourceShareShared; + ResourceDescriptor->Flags = 0; + ResourceDescriptor->u.BusNumber.Start = addr32_data->Minimum; + ResourceDescriptor->u.BusNumber.Length = addr32_data->AddressLength; + } + else if (addr32_data->ResourceType == ACPI_IO_RANGE) + { + ResourceDescriptor->Type = CmResourceTypePort; + ResourceDescriptor->ShareDisposition = CmResourceShareDeviceExclusive; + ResourceDescriptor->Flags = CM_RESOURCE_PORT_IO; + if (addr32_data->Decode == ACPI_POS_DECODE) + ResourceDescriptor->Flags |= CM_RESOURCE_PORT_POSITIVE_DECODE; + ResourceDescriptor->u.Port.Start.QuadPart = addr32_data->Minimum; + ResourceDescriptor->u.Port.Length = addr32_data->AddressLength; + } + else + { + ResourceDescriptor->Type = CmResourceTypeMemory; + ResourceDescriptor->ShareDisposition = CmResourceShareDeviceExclusive; + ResourceDescriptor->Flags = 0; + if (addr32_data->Info.Mem.WriteProtect == ACPI_READ_ONLY_MEMORY) + ResourceDescriptor->Flags |= CM_RESOURCE_MEMORY_READ_ONLY; + else + ResourceDescriptor->Flags |= CM_RESOURCE_MEMORY_READ_WRITE; + switch (addr32_data->Info.Mem.Caching) + { + case ACPI_CACHABLE_MEMORY: ResourceDescriptor->Flags |= CM_RESOURCE_MEMORY_CACHEABLE; break; + case ACPI_WRITE_COMBINING_MEMORY: ResourceDescriptor->Flags |= CM_RESOURCE_MEMORY_COMBINEDWRITE; break; + case ACPI_PREFETCHABLE_MEMORY: ResourceDescriptor->Flags |= CM_RESOURCE_MEMORY_PREFETCHABLE; break; + } + ResourceDescriptor->u.Memory.Start.QuadPart = addr32_data->Minimum; + ResourceDescriptor->u.Memory.Length = addr32_data->AddressLength; + } + ResourceDescriptor++; + break; + } + case ACPI_RESOURCE_TYPE_ADDRESS64: + { + ACPI_RESOURCE_ADDRESS64 *addr64_data = (ACPI_RESOURCE_ADDRESS64*) &resource->Data; + if (addr64_data->ResourceType == ACPI_BUS_NUMBER_RANGE) + { + DPRINT1("64-bit bus address is not supported!\n"); + ResourceDescriptor->Type = CmResourceTypeBusNumber; + ResourceDescriptor->ShareDisposition = CmResourceShareShared; + ResourceDescriptor->Flags = 0; + ResourceDescriptor->u.BusNumber.Start = (ULONG)addr64_data->Minimum; + ResourceDescriptor->u.BusNumber.Length = addr64_data->AddressLength; + } + else if (addr64_data->ResourceType == ACPI_IO_RANGE) + { + ResourceDescriptor->Type = CmResourceTypePort; + ResourceDescriptor->ShareDisposition = CmResourceShareDeviceExclusive; + ResourceDescriptor->Flags = CM_RESOURCE_PORT_IO; + if (addr64_data->Decode == ACPI_POS_DECODE) + ResourceDescriptor->Flags |= CM_RESOURCE_PORT_POSITIVE_DECODE; + ResourceDescriptor->u.Port.Start.QuadPart = addr64_data->Minimum; + ResourceDescriptor->u.Port.Length = addr64_data->AddressLength; + } + else + { + ResourceDescriptor->Type = CmResourceTypeMemory; + ResourceDescriptor->ShareDisposition = CmResourceShareDeviceExclusive; + ResourceDescriptor->Flags = 0; + if (addr64_data->Info.Mem.WriteProtect == ACPI_READ_ONLY_MEMORY) + ResourceDescriptor->Flags |= CM_RESOURCE_MEMORY_READ_ONLY; + else + ResourceDescriptor->Flags |= CM_RESOURCE_MEMORY_READ_WRITE; + switch (addr64_data->Info.Mem.Caching) + { + case ACPI_CACHABLE_MEMORY: ResourceDescriptor->Flags |= CM_RESOURCE_MEMORY_CACHEABLE; break; + case ACPI_WRITE_COMBINING_MEMORY: ResourceDescriptor->Flags |= CM_RESOURCE_MEMORY_COMBINEDWRITE; break; + case ACPI_PREFETCHABLE_MEMORY: ResourceDescriptor->Flags |= CM_RESOURCE_MEMORY_PREFETCHABLE; break; + } + ResourceDescriptor->u.Memory.Start.QuadPart = addr64_data->Minimum; + ResourceDescriptor->u.Memory.Length = addr64_data->AddressLength; + } + ResourceDescriptor++; + break; + } + case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64: + { + ACPI_RESOURCE_EXTENDED_ADDRESS64 *addr64_data = (ACPI_RESOURCE_EXTENDED_ADDRESS64*) &resource->Data; + if (addr64_data->ResourceType == ACPI_BUS_NUMBER_RANGE) + { + DPRINT1("64-bit bus address is not supported!\n"); + ResourceDescriptor->Type = CmResourceTypeBusNumber; + ResourceDescriptor->ShareDisposition = CmResourceShareShared; + ResourceDescriptor->Flags = 0; + ResourceDescriptor->u.BusNumber.Start = (ULONG)addr64_data->Minimum; + ResourceDescriptor->u.BusNumber.Length = addr64_data->AddressLength; + } + else if (addr64_data->ResourceType == ACPI_IO_RANGE) + { + ResourceDescriptor->Type = CmResourceTypePort; + ResourceDescriptor->ShareDisposition = CmResourceShareDeviceExclusive; + ResourceDescriptor->Flags = CM_RESOURCE_PORT_IO; + if (addr64_data->Decode == ACPI_POS_DECODE) + ResourceDescriptor->Flags |= CM_RESOURCE_PORT_POSITIVE_DECODE; + ResourceDescriptor->u.Port.Start.QuadPart = addr64_data->Minimum; + ResourceDescriptor->u.Port.Length = addr64_data->AddressLength; + } + else + { + ResourceDescriptor->Type = CmResourceTypeMemory; + ResourceDescriptor->ShareDisposition = CmResourceShareDeviceExclusive; + ResourceDescriptor->Flags = 0; + if (addr64_data->Info.Mem.WriteProtect == ACPI_READ_ONLY_MEMORY) + ResourceDescriptor->Flags |= CM_RESOURCE_MEMORY_READ_ONLY; + else + ResourceDescriptor->Flags |= CM_RESOURCE_MEMORY_READ_WRITE; + switch (addr64_data->Info.Mem.Caching) + { + case ACPI_CACHABLE_MEMORY: ResourceDescriptor->Flags |= CM_RESOURCE_MEMORY_CACHEABLE; break; + case ACPI_WRITE_COMBINING_MEMORY: ResourceDescriptor->Flags |= CM_RESOURCE_MEMORY_COMBINEDWRITE; break; + case ACPI_PREFETCHABLE_MEMORY: ResourceDescriptor->Flags |= CM_RESOURCE_MEMORY_PREFETCHABLE; break; + } + ResourceDescriptor->u.Memory.Start.QuadPart = addr64_data->Minimum; + ResourceDescriptor->u.Memory.Length = addr64_data->AddressLength; + } + ResourceDescriptor++; + break; + } + case ACPI_RESOURCE_TYPE_MEMORY24: + { + ACPI_RESOURCE_MEMORY24 *mem24_data = (ACPI_RESOURCE_MEMORY24*) &resource->Data; + ResourceDescriptor->Type = CmResourceTypeMemory; + ResourceDescriptor->ShareDisposition = CmResourceShareDeviceExclusive; + ResourceDescriptor->Flags = CM_RESOURCE_MEMORY_24; + if (mem24_data->WriteProtect == ACPI_READ_ONLY_MEMORY) + ResourceDescriptor->Flags |= CM_RESOURCE_MEMORY_READ_ONLY; + else + ResourceDescriptor->Flags |= CM_RESOURCE_MEMORY_READ_WRITE; + ResourceDescriptor->u.Memory.Start.QuadPart = mem24_data->Minimum; + ResourceDescriptor->u.Memory.Length = mem24_data->AddressLength; + + ResourceDescriptor++; + break; + } + case ACPI_RESOURCE_TYPE_MEMORY32: + { + ACPI_RESOURCE_MEMORY32 *mem32_data = (ACPI_RESOURCE_MEMORY32*) &resource->Data; + ResourceDescriptor->Type = CmResourceTypeMemory; + ResourceDescriptor->ShareDisposition = CmResourceShareDeviceExclusive; + ResourceDescriptor->Flags = 0; + if (mem32_data->WriteProtect == ACPI_READ_ONLY_MEMORY) + ResourceDescriptor->Flags |= CM_RESOURCE_MEMORY_READ_ONLY; + else + ResourceDescriptor->Flags |= CM_RESOURCE_MEMORY_READ_WRITE; + ResourceDescriptor->u.Memory.Start.QuadPart = mem32_data->Minimum; + ResourceDescriptor->u.Memory.Length = mem32_data->AddressLength; + + ResourceDescriptor++; + break; + } + default: + { + break; + } + } + resource = ACPI_NEXT_RESOURCE(resource); + } + + ExFreePool(Buffer.Pointer); + Irp->IoStatus.Information = (ULONG_PTR)ResourceList; + return STATUS_SUCCESS; +} + +NTSTATUS +Bus_PDO_QueryResourceRequirements( + PPDO_DEVICE_DATA DeviceData, + PIRP Irp ) +{ + ULONG NumberOfResources = 0; + ACPI_STATUS AcpiStatus; + ACPI_BUFFER Buffer; + ACPI_RESOURCE* resource; + ULONG i, RequirementsListSize; + PIO_RESOURCE_REQUIREMENTS_LIST RequirementsList; + PIO_RESOURCE_DESCRIPTOR RequirementDescriptor; + BOOLEAN CurrentRes = FALSE; + + PAGED_CODE (); + + + /* Get current resources */ + while (TRUE) + { + Buffer.Length = 0; + if (CurrentRes) + AcpiStatus = AcpiGetCurrentResources(DeviceData->AcpiHandle, &Buffer); + else + AcpiStatus = AcpiGetPossibleResources(DeviceData->AcpiHandle, &Buffer); + if ((!ACPI_SUCCESS(AcpiStatus) && AcpiStatus != AE_BUFFER_OVERFLOW) || + Buffer.Length == 0) + { + if (!CurrentRes) + CurrentRes = TRUE; + else + return Irp->IoStatus.Status; + } + else + break; + } + + Buffer.Pointer = ExAllocatePool(PagedPool, Buffer.Length); + if (!Buffer.Pointer) + return STATUS_INSUFFICIENT_RESOURCES; + + if (CurrentRes) + AcpiStatus = AcpiGetCurrentResources(DeviceData->AcpiHandle, &Buffer); + else + AcpiStatus = AcpiGetPossibleResources(DeviceData->AcpiHandle, &Buffer); + if (!ACPI_SUCCESS(AcpiStatus)) + { + DPRINT1("AcpiGetCurrentResources #2 failed (0x%x)\n", AcpiStatus); + ASSERT(FALSE); + return STATUS_UNSUCCESSFUL; + } + + resource= Buffer.Pointer; + /* Count number of resources */ + while (resource->Type != ACPI_RESOURCE_TYPE_END_TAG) + { + switch (resource->Type) + { + case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: + { + ACPI_RESOURCE_EXTENDED_IRQ *irq_data = (ACPI_RESOURCE_EXTENDED_IRQ*) &resource->Data; + NumberOfResources += irq_data->InterruptCount; + break; + } + case ACPI_RESOURCE_TYPE_IRQ: + { + ACPI_RESOURCE_IRQ *irq_data = (ACPI_RESOURCE_IRQ*) &resource->Data; + NumberOfResources += irq_data->InterruptCount; + break; + } + case ACPI_RESOURCE_TYPE_DMA: + { + ACPI_RESOURCE_DMA *dma_data = (ACPI_RESOURCE_DMA*) &resource->Data; + NumberOfResources += dma_data->ChannelCount; + break; + } + case ACPI_RESOURCE_TYPE_ADDRESS16: + case ACPI_RESOURCE_TYPE_ADDRESS32: + case ACPI_RESOURCE_TYPE_ADDRESS64: + case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64: + case ACPI_RESOURCE_TYPE_MEMORY24: + case ACPI_RESOURCE_TYPE_MEMORY32: + case ACPI_RESOURCE_TYPE_IO: + { + NumberOfResources++; + break; + } + default: + { + break; + } + } + resource = ACPI_NEXT_RESOURCE(resource); + } + + RequirementsListSize = sizeof(IO_RESOURCE_REQUIREMENTS_LIST) + sizeof(IO_RESOURCE_DESCRIPTOR) * (NumberOfResources - 1); + RequirementsList = (PIO_RESOURCE_REQUIREMENTS_LIST)ExAllocatePool(PagedPool, RequirementsListSize); + + if (!RequirementsList) + { + ExFreePool(Buffer.Pointer); + return STATUS_INSUFFICIENT_RESOURCES; + } + RequirementsList->ListSize = RequirementsListSize; + RequirementsList->InterfaceType = Internal; + RequirementsList->BusNumber = 0; + RequirementsList->SlotNumber = 0; /* Not used by WDM drivers */ + RequirementsList->AlternativeLists = 1; + RequirementsList->List[0].Version = 1; + RequirementsList->List[0].Revision = 1; + RequirementsList->List[0].Count = NumberOfResources; + RequirementDescriptor = RequirementsList->List[0].Descriptors; + + /* Fill resources list structure */ + resource = Buffer.Pointer; + while (resource->Type != ACPI_RESOURCE_TYPE_END_TAG) + { + switch (resource->Type) + { + case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: + { + ACPI_RESOURCE_EXTENDED_IRQ *irq_data = (ACPI_RESOURCE_EXTENDED_IRQ*) &resource->Data; + for (i = 0; i < irq_data->InterruptCount; i++) + { + RequirementDescriptor->Option = CurrentRes ? 0 : IO_RESOURCE_PREFERRED; + RequirementDescriptor->Type = CmResourceTypeInterrupt; + RequirementDescriptor->ShareDisposition = (irq_data->Sharable == ACPI_SHARED ? CmResourceShareShared : CmResourceShareDeviceExclusive); + RequirementDescriptor->Flags =(irq_data->Triggering == ACPI_LEVEL_SENSITIVE ? CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE : CM_RESOURCE_INTERRUPT_LATCHED); + RequirementDescriptor->u.Interrupt.MinimumVector = + RequirementDescriptor->u.Interrupt.MaximumVector = irq_data->Interrupts[i]; + + RequirementDescriptor++; + } + break; + } + case ACPI_RESOURCE_TYPE_IRQ: + { + ACPI_RESOURCE_IRQ *irq_data = (ACPI_RESOURCE_IRQ*) &resource->Data; + for (i = 0; i < irq_data->InterruptCount; i++) + { + RequirementDescriptor->Option = CurrentRes ? 0 : IO_RESOURCE_PREFERRED; + RequirementDescriptor->Type = CmResourceTypeInterrupt; + RequirementDescriptor->ShareDisposition = (irq_data->Sharable == ACPI_SHARED ? CmResourceShareShared : CmResourceShareDeviceExclusive); + RequirementDescriptor->Flags =(irq_data->Triggering == ACPI_LEVEL_SENSITIVE ? CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE : CM_RESOURCE_INTERRUPT_LATCHED); + RequirementDescriptor->u.Interrupt.MinimumVector = + RequirementDescriptor->u.Interrupt.MaximumVector = irq_data->Interrupts[i]; + + RequirementDescriptor++; + } + break; + } + case ACPI_RESOURCE_TYPE_DMA: + { + ACPI_RESOURCE_DMA *dma_data = (ACPI_RESOURCE_DMA*) &resource->Data; + for (i = 0; i < dma_data->ChannelCount; i++) + { + RequirementDescriptor->Type = CmResourceTypeDma; + RequirementDescriptor->Flags = 0; + switch (dma_data->Type) + { + case ACPI_TYPE_A: RequirementDescriptor->Flags |= CM_RESOURCE_DMA_TYPE_A; break; + case ACPI_TYPE_B: RequirementDescriptor->Flags |= CM_RESOURCE_DMA_TYPE_B; break; + case ACPI_TYPE_F: RequirementDescriptor->Flags |= CM_RESOURCE_DMA_TYPE_F; break; + } + if (dma_data->BusMaster == ACPI_BUS_MASTER) + RequirementDescriptor->Flags |= CM_RESOURCE_DMA_BUS_MASTER; + switch (dma_data->Transfer) + { + case ACPI_TRANSFER_8: RequirementDescriptor->Flags |= CM_RESOURCE_DMA_8; break; + case ACPI_TRANSFER_16: RequirementDescriptor->Flags |= CM_RESOURCE_DMA_16; break; + case ACPI_TRANSFER_8_16: RequirementDescriptor->Flags |= CM_RESOURCE_DMA_8_AND_16; break; + } + + RequirementDescriptor->Option = CurrentRes ? 0 : IO_RESOURCE_PREFERRED; + RequirementDescriptor->ShareDisposition = CmResourceShareDriverExclusive; + RequirementDescriptor->u.Dma.MinimumChannel = + RequirementDescriptor->u.Dma.MaximumChannel = dma_data->Channels[i]; + RequirementDescriptor++; + } + break; + } + case ACPI_RESOURCE_TYPE_IO: + { + ACPI_RESOURCE_IO *io_data = (ACPI_RESOURCE_IO*) &resource->Data; + RequirementDescriptor->Flags = CM_RESOURCE_PORT_IO; + if (io_data->IoDecode == ACPI_DECODE_16) + RequirementDescriptor->Flags |= CM_RESOURCE_PORT_16_BIT_DECODE; + else + RequirementDescriptor->Flags |= CM_RESOURCE_PORT_10_BIT_DECODE; + RequirementDescriptor->u.Port.Length = io_data->AddressLength; + RequirementDescriptor->Option = CurrentRes ? 0 : IO_RESOURCE_PREFERRED; + RequirementDescriptor->Type = CmResourceTypePort; + RequirementDescriptor->ShareDisposition = CmResourceShareDriverExclusive; + RequirementDescriptor->u.Port.Alignment = io_data->Alignment; + RequirementDescriptor->u.Port.MinimumAddress.QuadPart = io_data->Minimum; + RequirementDescriptor->u.Port.MaximumAddress.QuadPart = io_data->Maximum; + + RequirementDescriptor++; + break; + } + case ACPI_RESOURCE_TYPE_ADDRESS16: + { + ACPI_RESOURCE_ADDRESS16 *addr16_data = (ACPI_RESOURCE_ADDRESS16*) &resource->Data; + RequirementDescriptor->Option = CurrentRes ? 0 : IO_RESOURCE_PREFERRED; + if (addr16_data->ResourceType == ACPI_BUS_NUMBER_RANGE) + { + RequirementDescriptor->Type = CmResourceTypeBusNumber; + RequirementDescriptor->ShareDisposition = CmResourceShareShared; + RequirementDescriptor->Flags = 0; + RequirementDescriptor->u.BusNumber.MinBusNumber = addr16_data->Minimum; + RequirementDescriptor->u.BusNumber.MaxBusNumber = addr16_data->Maximum; + RequirementDescriptor->u.BusNumber.Length = addr16_data->AddressLength; + } + else if (addr16_data->ResourceType == ACPI_IO_RANGE) + { + RequirementDescriptor->Type = CmResourceTypePort; + RequirementDescriptor->ShareDisposition = CmResourceShareDeviceExclusive; + RequirementDescriptor->Flags = CM_RESOURCE_PORT_IO; + if (addr16_data->Decode == ACPI_POS_DECODE) + RequirementDescriptor->Flags |= CM_RESOURCE_PORT_POSITIVE_DECODE; + RequirementDescriptor->u.Port.MinimumAddress.QuadPart = addr16_data->Minimum; + RequirementDescriptor->u.Port.MaximumAddress.QuadPart = addr16_data->Maximum; + RequirementDescriptor->u.Port.Length = addr16_data->AddressLength; + } + else + { + RequirementDescriptor->Type = CmResourceTypeMemory; + RequirementDescriptor->ShareDisposition = CmResourceShareDeviceExclusive; + RequirementDescriptor->Flags = 0; + if (addr16_data->Info.Mem.WriteProtect == ACPI_READ_ONLY_MEMORY) + RequirementDescriptor->Flags |= CM_RESOURCE_MEMORY_READ_ONLY; + else + RequirementDescriptor->Flags |= CM_RESOURCE_MEMORY_READ_WRITE; + switch (addr16_data->Info.Mem.Caching) + { + case ACPI_CACHABLE_MEMORY: RequirementDescriptor->Flags |= CM_RESOURCE_MEMORY_CACHEABLE; break; + case ACPI_WRITE_COMBINING_MEMORY: RequirementDescriptor->Flags |= CM_RESOURCE_MEMORY_COMBINEDWRITE; break; + case ACPI_PREFETCHABLE_MEMORY: RequirementDescriptor->Flags |= CM_RESOURCE_MEMORY_PREFETCHABLE; break; + } + RequirementDescriptor->u.Memory.MinimumAddress.QuadPart = addr16_data->Minimum; + RequirementDescriptor->u.Memory.MaximumAddress.QuadPart = addr16_data->Maximum; + RequirementDescriptor->u.Memory.Length = addr16_data->AddressLength; + } + RequirementDescriptor++; + break; + } + case ACPI_RESOURCE_TYPE_ADDRESS32: + { + ACPI_RESOURCE_ADDRESS32 *addr32_data = (ACPI_RESOURCE_ADDRESS32*) &resource->Data; + RequirementDescriptor->Option = CurrentRes ? 0 : IO_RESOURCE_PREFERRED; + if (addr32_data->ResourceType == ACPI_BUS_NUMBER_RANGE) + { + RequirementDescriptor->Type = CmResourceTypeBusNumber; + RequirementDescriptor->ShareDisposition = CmResourceShareShared; + RequirementDescriptor->Flags = 0; + RequirementDescriptor->u.BusNumber.MinBusNumber = addr32_data->Minimum; + RequirementDescriptor->u.BusNumber.MaxBusNumber = addr32_data->Maximum; + RequirementDescriptor->u.BusNumber.Length = addr32_data->AddressLength; + } + else if (addr32_data->ResourceType == ACPI_IO_RANGE) + { + RequirementDescriptor->Type = CmResourceTypePort; + RequirementDescriptor->ShareDisposition = CmResourceShareDeviceExclusive; + RequirementDescriptor->Flags = CM_RESOURCE_PORT_IO; + if (addr32_data->Decode == ACPI_POS_DECODE) + RequirementDescriptor->Flags |= CM_RESOURCE_PORT_POSITIVE_DECODE; + RequirementDescriptor->u.Port.MinimumAddress.QuadPart = addr32_data->Minimum; + RequirementDescriptor->u.Port.MaximumAddress.QuadPart = addr32_data->Maximum; + RequirementDescriptor->u.Port.Length = addr32_data->AddressLength; + } + else + { + RequirementDescriptor->Type = CmResourceTypeMemory; + RequirementDescriptor->ShareDisposition = CmResourceShareDeviceExclusive; + RequirementDescriptor->Flags = 0; + if (addr32_data->Info.Mem.WriteProtect == ACPI_READ_ONLY_MEMORY) + RequirementDescriptor->Flags |= CM_RESOURCE_MEMORY_READ_ONLY; + else + RequirementDescriptor->Flags |= CM_RESOURCE_MEMORY_READ_WRITE; + switch (addr32_data->Info.Mem.Caching) + { + case ACPI_CACHABLE_MEMORY: RequirementDescriptor->Flags |= CM_RESOURCE_MEMORY_CACHEABLE; break; + case ACPI_WRITE_COMBINING_MEMORY: RequirementDescriptor->Flags |= CM_RESOURCE_MEMORY_COMBINEDWRITE; break; + case ACPI_PREFETCHABLE_MEMORY: RequirementDescriptor->Flags |= CM_RESOURCE_MEMORY_PREFETCHABLE; break; + } + RequirementDescriptor->u.Memory.MinimumAddress.QuadPart = addr32_data->Minimum; + RequirementDescriptor->u.Memory.MaximumAddress.QuadPart = addr32_data->Maximum; + RequirementDescriptor->u.Memory.Length = addr32_data->AddressLength; + } + RequirementDescriptor++; + break; + } + case ACPI_RESOURCE_TYPE_ADDRESS64: + { + ACPI_RESOURCE_ADDRESS64 *addr64_data = (ACPI_RESOURCE_ADDRESS64*) &resource->Data; + RequirementDescriptor->Option = CurrentRes ? 0 : IO_RESOURCE_PREFERRED; + if (addr64_data->ResourceType == ACPI_BUS_NUMBER_RANGE) + { + DPRINT1("64-bit bus address is not supported!\n"); + RequirementDescriptor->Type = CmResourceTypeBusNumber; + RequirementDescriptor->ShareDisposition = CmResourceShareShared; + RequirementDescriptor->Flags = 0; + RequirementDescriptor->u.BusNumber.MinBusNumber = (ULONG)addr64_data->Minimum; + RequirementDescriptor->u.BusNumber.MaxBusNumber = (ULONG)addr64_data->Maximum; + RequirementDescriptor->u.BusNumber.Length = addr64_data->AddressLength; + } + else if (addr64_data->ResourceType == ACPI_IO_RANGE) + { + RequirementDescriptor->Type = CmResourceTypePort; + RequirementDescriptor->ShareDisposition = CmResourceShareDeviceExclusive; + RequirementDescriptor->Flags = CM_RESOURCE_PORT_IO; + if (addr64_data->Decode == ACPI_POS_DECODE) + RequirementDescriptor->Flags |= CM_RESOURCE_PORT_POSITIVE_DECODE; + RequirementDescriptor->u.Port.MinimumAddress.QuadPart = addr64_data->Minimum; + RequirementDescriptor->u.Port.MaximumAddress.QuadPart = addr64_data->Maximum; + RequirementDescriptor->u.Port.Length = addr64_data->AddressLength; + } + else + { + RequirementDescriptor->Type = CmResourceTypeMemory; + RequirementDescriptor->ShareDisposition = CmResourceShareDeviceExclusive; + RequirementDescriptor->Flags = 0; + if (addr64_data->Info.Mem.WriteProtect == ACPI_READ_ONLY_MEMORY) + RequirementDescriptor->Flags |= CM_RESOURCE_MEMORY_READ_ONLY; + else + RequirementDescriptor->Flags |= CM_RESOURCE_MEMORY_READ_WRITE; + switch (addr64_data->Info.Mem.Caching) + { + case ACPI_CACHABLE_MEMORY: RequirementDescriptor->Flags |= CM_RESOURCE_MEMORY_CACHEABLE; break; + case ACPI_WRITE_COMBINING_MEMORY: RequirementDescriptor->Flags |= CM_RESOURCE_MEMORY_COMBINEDWRITE; break; + case ACPI_PREFETCHABLE_MEMORY: RequirementDescriptor->Flags |= CM_RESOURCE_MEMORY_PREFETCHABLE; break; + } + RequirementDescriptor->u.Memory.MinimumAddress.QuadPart = addr64_data->Minimum; + RequirementDescriptor->u.Memory.MaximumAddress.QuadPart = addr64_data->Maximum; + RequirementDescriptor->u.Memory.Length = addr64_data->AddressLength; + } + RequirementDescriptor++; + break; + } + case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64: + { + ACPI_RESOURCE_EXTENDED_ADDRESS64 *addr64_data = (ACPI_RESOURCE_EXTENDED_ADDRESS64*) &resource->Data; + RequirementDescriptor->Option = CurrentRes ? 0 : IO_RESOURCE_PREFERRED; + if (addr64_data->ResourceType == ACPI_BUS_NUMBER_RANGE) + { + DPRINT1("64-bit bus address is not supported!\n"); + RequirementDescriptor->Type = CmResourceTypeBusNumber; + RequirementDescriptor->ShareDisposition = CmResourceShareShared; + RequirementDescriptor->Flags = 0; + RequirementDescriptor->u.BusNumber.MinBusNumber = (ULONG)addr64_data->Minimum; + RequirementDescriptor->u.BusNumber.MaxBusNumber = (ULONG)addr64_data->Maximum; + RequirementDescriptor->u.BusNumber.Length = addr64_data->AddressLength; + } + else if (addr64_data->ResourceType == ACPI_IO_RANGE) + { + RequirementDescriptor->Type = CmResourceTypePort; + RequirementDescriptor->ShareDisposition = CmResourceShareDeviceExclusive; + RequirementDescriptor->Flags = CM_RESOURCE_PORT_IO; + if (addr64_data->Decode == ACPI_POS_DECODE) + RequirementDescriptor->Flags |= CM_RESOURCE_PORT_POSITIVE_DECODE; + RequirementDescriptor->u.Port.MinimumAddress.QuadPart = addr64_data->Minimum; + RequirementDescriptor->u.Port.MaximumAddress.QuadPart = addr64_data->Maximum; + RequirementDescriptor->u.Port.Length = addr64_data->AddressLength; + } + else + { + RequirementDescriptor->Type = CmResourceTypeMemory; + RequirementDescriptor->ShareDisposition = CmResourceShareDeviceExclusive; + RequirementDescriptor->Flags = 0; + if (addr64_data->Info.Mem.WriteProtect == ACPI_READ_ONLY_MEMORY) + RequirementDescriptor->Flags |= CM_RESOURCE_MEMORY_READ_ONLY; + else + RequirementDescriptor->Flags |= CM_RESOURCE_MEMORY_READ_WRITE; + switch (addr64_data->Info.Mem.Caching) + { + case ACPI_CACHABLE_MEMORY: RequirementDescriptor->Flags |= CM_RESOURCE_MEMORY_CACHEABLE; break; + case ACPI_WRITE_COMBINING_MEMORY: RequirementDescriptor->Flags |= CM_RESOURCE_MEMORY_COMBINEDWRITE; break; + case ACPI_PREFETCHABLE_MEMORY: RequirementDescriptor->Flags |= CM_RESOURCE_MEMORY_PREFETCHABLE; break; + } + RequirementDescriptor->u.Memory.MinimumAddress.QuadPart = addr64_data->Minimum; + RequirementDescriptor->u.Memory.MaximumAddress.QuadPart = addr64_data->Maximum; + RequirementDescriptor->u.Memory.Length = addr64_data->AddressLength; + } + RequirementDescriptor++; + break; + } + case ACPI_RESOURCE_TYPE_MEMORY24: + { + ACPI_RESOURCE_MEMORY24 *mem24_data = (ACPI_RESOURCE_MEMORY24*) &resource->Data; + RequirementDescriptor->Option = CurrentRes ? 0 : IO_RESOURCE_PREFERRED; + RequirementDescriptor->Type = CmResourceTypeMemory; + RequirementDescriptor->ShareDisposition = CmResourceShareDeviceExclusive; + RequirementDescriptor->Flags = CM_RESOURCE_MEMORY_24; + if (mem24_data->WriteProtect == ACPI_READ_ONLY_MEMORY) + RequirementDescriptor->Flags |= CM_RESOURCE_MEMORY_READ_ONLY; + else + RequirementDescriptor->Flags |= CM_RESOURCE_MEMORY_READ_WRITE; + RequirementDescriptor->u.Memory.MinimumAddress.QuadPart = mem24_data->Minimum; + RequirementDescriptor->u.Memory.MaximumAddress.QuadPart = mem24_data->Maximum; + RequirementDescriptor->u.Memory.Length = mem24_data->AddressLength; + + RequirementDescriptor++; + break; + } + case ACPI_RESOURCE_TYPE_MEMORY32: + { + ACPI_RESOURCE_MEMORY32 *mem32_data = (ACPI_RESOURCE_MEMORY32*) &resource->Data; + RequirementDescriptor->Option = CurrentRes ? 0 : IO_RESOURCE_PREFERRED; + RequirementDescriptor->Type = CmResourceTypeMemory; + RequirementDescriptor->ShareDisposition = CmResourceShareDeviceExclusive; + RequirementDescriptor->Flags = 0; + if (mem32_data->WriteProtect == ACPI_READ_ONLY_MEMORY) + RequirementDescriptor->Flags |= CM_RESOURCE_MEMORY_READ_ONLY; + else + RequirementDescriptor->Flags |= CM_RESOURCE_MEMORY_READ_WRITE; + RequirementDescriptor->u.Memory.MinimumAddress.QuadPart = mem32_data->Minimum; + RequirementDescriptor->u.Memory.MaximumAddress.QuadPart = mem32_data->Maximum; + RequirementDescriptor->u.Memory.Length = mem32_data->AddressLength; + + RequirementDescriptor++; + break; + } + default: + { + break; + } + } + resource = ACPI_NEXT_RESOURCE(resource); + } + ExFreePool(Buffer.Pointer); + + Irp->IoStatus.Information = (ULONG_PTR)RequirementsList; + + return STATUS_SUCCESS; +} + +NTSTATUS +Bus_PDO_QueryDeviceRelations( + PPDO_DEVICE_DATA DeviceData, + PIRP Irp ) +/*++ + +Routine Description: + + The PnP Manager sends this IRP to gather information about + devices with a relationship to the specified device. + Bus drivers must handle this request for TargetDeviceRelation + for their child devices (child PDOs). + + If a driver returns relations in response to this IRP, + it allocates a DEVICE_RELATIONS structure from paged + memory containing a count and the appropriate number of + device object pointers. The PnP Manager frees the structure + when it is no longer needed. If a driver replaces a + DEVICE_RELATIONS structure allocated by another driver, + it must free the previous structure. + + A driver must reference the PDO of any device that it + reports in this IRP (ObReferenceObject). The PnP Manager + removes the reference when appropriate. + +Arguments: + + DeviceData - Pointer to the PDO's device extension. + Irp - Pointer to the irp. + +Return Value: + + NT STATUS + +--*/ +{ + + PIO_STACK_LOCATION stack; + PDEVICE_RELATIONS deviceRelations; + NTSTATUS status; + + PAGED_CODE (); + + stack = IoGetCurrentIrpStackLocation (Irp); + + switch (stack->Parameters.QueryDeviceRelations.Type) { + + case TargetDeviceRelation: + + deviceRelations = (PDEVICE_RELATIONS) Irp->IoStatus.Information; + if (deviceRelations) { + // + // Only PDO can handle this request. Somebody above + // is not playing by rule. + // + ASSERTMSG("Someone above is handling TargetDeviceRelation", !deviceRelations); + } + + deviceRelations = (PDEVICE_RELATIONS) + ExAllocatePoolWithTag (PagedPool, + sizeof(DEVICE_RELATIONS), + 'IPCA'); + if (!deviceRelations) { + status = STATUS_INSUFFICIENT_RESOURCES; + break; + } + + // + // There is only one PDO pointer in the structure + // for this relation type. The PnP Manager removes + // the reference to the PDO when the driver or application + // un-registers for notification on the device. + // + + deviceRelations->Count = 1; + deviceRelations->Objects[0] = DeviceData->Common.Self; + ObReferenceObject(DeviceData->Common.Self); + + status = STATUS_SUCCESS; + Irp->IoStatus.Information = (ULONG_PTR) deviceRelations; + break; + + case BusRelations: // Not handled by PDO + case EjectionRelations: // optional for PDO + case RemovalRelations: // // optional for PDO + default: + status = Irp->IoStatus.Status; + } + + return status; +} + +NTSTATUS +Bus_PDO_QueryBusInformation( + PPDO_DEVICE_DATA DeviceData, + PIRP Irp ) +/*++ + +Routine Description: + + The PnP Manager uses this IRP to request the type and + instance number of a device's parent bus. Bus drivers + should handle this request for their child devices (PDOs). + +Arguments: + + DeviceData - Pointer to the PDO's device extension. + Irp - Pointer to the irp. + +Return Value: + + NT STATUS + +--*/ +{ + + PPNP_BUS_INFORMATION busInfo; + + PAGED_CODE (); + + busInfo = ExAllocatePoolWithTag (PagedPool, sizeof(PNP_BUS_INFORMATION), + 'IPCA'); + + if (busInfo == NULL) { + return STATUS_INSUFFICIENT_RESOURCES; + } + + busInfo->BusTypeGuid = GUID_ACPI_INTERFACE_STANDARD; + + busInfo->LegacyBusType = InternalPowerBus; + + busInfo->BusNumber = 0; //fixme + + Irp->IoStatus.Information = (ULONG_PTR)busInfo; + + return STATUS_SUCCESS; +} + + +NTSTATUS +Bus_GetDeviceCapabilities( + PDEVICE_OBJECT DeviceObject, + PDEVICE_CAPABILITIES DeviceCapabilities + ) +{ + IO_STATUS_BLOCK ioStatus; + KEVENT pnpEvent; + NTSTATUS status; + PDEVICE_OBJECT targetObject; + PIO_STACK_LOCATION irpStack; + PIRP pnpIrp; + + PAGED_CODE(); + + // + // Initialize the capabilities that we will send down + // + RtlZeroMemory( DeviceCapabilities, sizeof(DEVICE_CAPABILITIES) ); + DeviceCapabilities->Size = sizeof(DEVICE_CAPABILITIES); + DeviceCapabilities->Version = 1; + DeviceCapabilities->Address = -1; + DeviceCapabilities->UINumber = -1; + + // + // Initialize the event + // + KeInitializeEvent( &pnpEvent, NotificationEvent, FALSE ); + + targetObject = IoGetAttachedDeviceReference( DeviceObject ); + + // + // Build an Irp + // + pnpIrp = IoBuildSynchronousFsdRequest( + IRP_MJ_PNP, + targetObject, + NULL, + 0, + NULL, + &pnpEvent, + &ioStatus + ); + if (pnpIrp == NULL) { + + status = STATUS_INSUFFICIENT_RESOURCES; + goto GetDeviceCapabilitiesExit; + + } + + // + // Pnp Irps all begin life as STATUS_NOT_SUPPORTED; + // + pnpIrp->IoStatus.Status = STATUS_NOT_SUPPORTED; + + // + // Get the top of stack + // + irpStack = IoGetNextIrpStackLocation( pnpIrp ); + + // + // Set the top of stack + // + RtlZeroMemory( irpStack, sizeof(IO_STACK_LOCATION ) ); + irpStack->MajorFunction = IRP_MJ_PNP; + irpStack->MinorFunction = IRP_MN_QUERY_CAPABILITIES; + irpStack->Parameters.DeviceCapabilities.Capabilities = DeviceCapabilities; + + // + // Call the driver + // + status = IoCallDriver( targetObject, pnpIrp ); + if (status == STATUS_PENDING) { + + // + // Block until the irp comes back. + // Important thing to note here is when you allocate + // the memory for an event in the stack you must do a + // KernelMode wait instead of UserMode to prevent + // the stack from getting paged out. + // + + KeWaitForSingleObject( + &pnpEvent, + Executive, + KernelMode, + FALSE, + NULL + ); + status = ioStatus.Status; + + } + +GetDeviceCapabilitiesExit: + // + // Done with reference + // + ObDereferenceObject( targetObject ); + + // + // Done + // + return status; + +} + + diff --git a/reactos/drivers/bus/acpi/cmbatt/cmbatt.c b/reactos/drivers/bus/acpi/cmbatt/cmbatt.c new file mode 100644 index 00000000000..747ac9ea952 --- /dev/null +++ b/reactos/drivers/bus/acpi/cmbatt/cmbatt.c @@ -0,0 +1,1328 @@ +/* + * PROJECT: ReactOS ACPI-Compliant Control Method Battery + * LICENSE: BSD - See COPYING.ARM in the top level directory + * FILE: boot/drivers/bus/acpi/cmbatt/cmbatt.c + * PURPOSE: Main Initialization Code and IRP Handling + * PROGRAMMERS: ReactOS Portable Systems Group + */ + +/* INCLUDES *******************************************************************/ + +#include "cmbatt.h" + +/* GLOBALS ********************************************************************/ + +ULONG CmBattDebug; +PCALLBACK_OBJECT CmBattPowerCallBackObject; +PVOID CmBattPowerCallBackRegistration; +UNICODE_STRING GlobalRegistryPath; +KTIMER CmBattWakeDpcTimerObject; +KDPC CmBattWakeDpcObject; +PDEVICE_OBJECT AcAdapterPdo; +LARGE_INTEGER CmBattWakeDpcDelay; + +/* FUNCTIONS ******************************************************************/ + +VOID +NTAPI +CmBattPowerCallBack(IN PCMBATT_DEVICE_EXTENSION DeviceExtension, + IN ULONG Action, + IN ULONG Value) +{ + BOOLEAN Cancelled; + PDEVICE_OBJECT DeviceObject; + if (CmBattDebug & 0x10) + DbgPrint("CmBattPowerCallBack: action: %d, value: %d \n", Action, Value); + + /* Check if a transition is going to happen */ + if (Action == PO_CB_SYSTEM_STATE_LOCK) + { + /* We have just re-entered S0: call the wake DPC in 10 seconds */ + if (Value == 1) + { + if (CmBattDebug & 0x10) + DbgPrint("CmBattPowerCallBack: Calling CmBattWakeDpc after 10 seconds.\n"); + Cancelled = KeSetTimer(&CmBattWakeDpcTimerObject, CmBattWakeDpcDelay, &CmBattWakeDpcObject); + if (CmBattDebug & 0x10) + DbgPrint("CmBattPowerCallBack: timerCanceled = %d.\n", Cancelled); + } + else if (Value == 0) + { + /* We are exiting the S0 state: loop all devices to set the delay flag */ + if (CmBattDebug & 0x10) + DbgPrint("CmBattPowerCallBack: Delaying Notifications\n"); + for (DeviceObject = DeviceExtension->DeviceObject; + DeviceObject; + DeviceObject = DeviceObject->NextDevice) + { + /* Set the delay flag */ + DeviceExtension = DeviceObject->DeviceExtension; + DeviceExtension->DelayNotification = TRUE; + } + } + else if (CmBattDebug & 0x10) + { + /* Unknown value */ + DbgPrint("CmBattPowerCallBack: unknown argument2 = %08x\n"); + } + } +} + +VOID +NTAPI +CmBattWakeDpc(IN PKDPC Dpc, + IN PCMBATT_DEVICE_EXTENSION FdoExtension, + IN PVOID SystemArgument1, + IN PVOID SystemArgument2) +{ + PDEVICE_OBJECT CurrentObject; + BOOLEAN AcNotify = FALSE; + PCMBATT_DEVICE_EXTENSION DeviceExtension; + ULONG ArFlag; + if (CmBattDebug & 2) DbgPrint("CmBattWakeDpc: Entered.\n"); + + /* Loop all device objects */ + for (CurrentObject = FdoExtension->DeviceObject; + CurrentObject; + CurrentObject = CurrentObject->NextDevice) + { + /* Turn delay flag off, we're back in S0 */ + DeviceExtension = CurrentObject->DeviceExtension; + DeviceExtension->DelayNotification = 0; + + /* Check if this is an AC adapter */ + if (DeviceExtension->FdoType == CmBattAcAdapter) + { + /* Was there a pending notify? */ + if (DeviceExtension->ArFlag & CMBATT_AR_NOTIFY) + { + /* We'll send a notify on the next pass */ + AcNotify = TRUE; + DeviceExtension->ArFlag = 0; + if (CmBattDebug & 0x20) + DbgPrint("CmBattWakeDpc: AC adapter notified\n"); + } + } + } + + /* Loop the device objects again */ + for (CurrentObject = FdoExtension->DeviceObject; + CurrentObject; + CurrentObject = CurrentObject->NextDevice) + { + /* Check if this is a battery */ + DeviceExtension = CurrentObject->DeviceExtension; + if (DeviceExtension->FdoType == CmBattBattery) + { + /* Check what ARs are pending */ + ArFlag = DeviceExtension->ArFlag; + if (CmBattDebug & 0x20) + DbgPrint("CmBattWakeDpc: Performing delayed ARs: %01x\n", ArFlag); + + /* Insert notification, clear the lock value */ + if (ArFlag & CMBATT_AR_INSERT) InterlockedExchange(&DeviceExtension->ArLockValue, 0); + + /* Removal, clear the battery tag */ + if (ArFlag & CMBATT_AR_REMOVE) DeviceExtension->Tag = 0; + + /* Notification (or AC/DC adapter change from first pass above) */ + if ((ArFlag & CMBATT_AR_NOTIFY) || (AcNotify)) + { + /* Notify the class driver */ + BatteryClassStatusNotify(DeviceExtension->ClassData); + } + } + } +} + +VOID +NTAPI +CmBattNotifyHandler(IN PCMBATT_DEVICE_EXTENSION DeviceExtension, + IN ULONG NotifyValue) +{ + ULONG ArFlag; + PCMBATT_DEVICE_EXTENSION FdoExtension; + PDEVICE_OBJECT DeviceObject; + + if (CmBattDebug & (CMBATT_ACPI_ASSERT | CMBATT_PNP_INFO)) + DbgPrint("CmBattNotifyHandler: CmBatt 0x%08x Type %d Number %d Notify Value: %x\n", + DeviceExtension, + DeviceExtension->FdoType, + DeviceExtension->DeviceId, + NotifyValue); + + /* Check what kind of notification was received */ + switch (NotifyValue) + { + /* ACPI Specification says is sends a "Bus Check" when power source changes */ + case ACPI_BUS_CHECK: + + /* We treat it as possible physical change */ + DeviceExtension->ArFlag |= (CMBATT_AR_NOTIFY | CMBATT_AR_INSERT); + if ((DeviceExtension->Tag) && + (CmBattDebug & (CMBATT_ACPI_WARNING | CMBATT_GENERIC_WARNING))) + DbgPrint("CmBattNotifyHandler: Received battery #%x insertion, but tag was not invalid.\n", + DeviceExtension->DeviceId); + break; + + /* Status of the battery has changed */ + case ACPI_BATT_NOTIFY_STATUS: + + /* All we'll do is notify the class driver */ + DeviceExtension->ArFlag |= CMBATT_AR_NOTIFY; + break; + + /* Information on the battery has changed, such as physical presence */ + case ACPI_DEVICE_CHECK: + case ACPI_BATT_NOTIFY_INFO: + + /* Reset all state and let the class driver re-evaluate it all */ + DeviceExtension->ArFlag |= (CMBATT_AR_NOTIFY | + CMBATT_AR_INSERT | + CMBATT_AR_REMOVE); + break; + + default: + + if (CmBattDebug & CMBATT_PNP_INFO) + DbgPrint("CmBattNotifyHandler: Unknown Notify Value: %x\n", NotifyValue); + } + + /* Check if we're supposed to delay the notification till later */ + if (DeviceExtension->DelayNotification) + { + /* We'll handle this when we get a status query later on */ + if (CmBattDebug & CMBATT_PNP_INFO) + DbgPrint("CmBattNotifyHandler: Notification delayed: ARs = %01x\n", + DeviceExtension->ArFlag); + return; + } + + /* We're going to handle this now */ + if (CmBattDebug & CMBATT_PNP_INFO) + DbgPrint("CmBattNotifyHandler: Performing ARs: %01x\n", DeviceExtension->ArFlag); + + /* Check if this is a battery or AC adapter notification */ + if (DeviceExtension->FdoType == CmBattBattery) + { + /* Reset the current trip point */ + DeviceExtension->TripPointValue = BATTERY_UNKNOWN_CAPACITY; + + /* Check what ARs have to be done */ + ArFlag = DeviceExtension->ArFlag; + + /* New battery inserted, reset lock value */ + if (ArFlag & CMBATT_AR_INSERT) InterlockedExchange(&DeviceExtension->ArLockValue, 0); + + /* Check if the battery may have been removed */ + if (ArFlag & CMBATT_AR_REMOVE) DeviceExtension->Tag = 0; + + /* Check if there's been any sort of change to the battery */ + if (ArFlag & CMBATT_AR_NOTIFY) + { + /* We'll probably end up re-evaluating _BIF and _BST */ + DeviceExtension->NotifySent = TRUE; + BatteryClassStatusNotify(DeviceExtension->ClassData); + } + } + else if (DeviceExtension->ArFlag & CMBATT_AR_NOTIFY) + { + /* The only known notification is AC/DC change. Loop device objects. */ + for (DeviceObject = DeviceExtension->FdoDeviceObject->DriverObject->DeviceObject; + DeviceObject; + DeviceObject = DeviceObject->NextDevice) + { + /* Is this a battery? */ + FdoExtension = DeviceObject->DeviceExtension; + if (FdoExtension->FdoType == CmBattBattery) + { + /* Send a notification to the class driver */ + FdoExtension->NotifySent = TRUE; + BatteryClassStatusNotify(FdoExtension->ClassData); + } + } + } + + /* ARs have been processed */ + DeviceExtension->ArFlag = 0; +} + +VOID +NTAPI +CmBattUnload(IN PDRIVER_OBJECT DriverObject) +{ + if (CmBattDebug & CMBATT_GENERIC_INFO) DPRINT("CmBattUnload: \n"); + + /* Check if we have a registered power callback */ + if (CmBattPowerCallBackObject) + { + /* Get rid of it */ + ExUnregisterCallback(CmBattPowerCallBackRegistration); + ObfDereferenceObject(CmBattPowerCallBackObject); + } + + /* Free the registry buffer if it exists */ + if (GlobalRegistryPath.Buffer) ExFreePool(GlobalRegistryPath.Buffer); + + /* Make sure we don't still have references to the DO */ + if ((DriverObject->DeviceObject) && (CmBattDebug & CMBATT_GENERIC_WARNING)) + { + DbgPrint("Unload called before all devices removed.\n"); + } +} + +NTSTATUS +NTAPI +CmBattVerifyStaticInfo(PCMBATT_DEVICE_EXTENSION DeviceExtension, + ULONG BatteryTag) +{ + UNIMPLEMENTED; + return STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS +NTAPI +CmBattOpenClose(IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp) +{ + NTSTATUS Status = STATUS_SUCCESS; + PIO_STACK_LOCATION IoStackLocation; + UCHAR Major; + ULONG Count; + PCMBATT_DEVICE_EXTENSION DeviceExtension; + PAGED_CODE(); + if (CmBattDebug & CMBATT_GENERIC_INFO) DPRINT("CmBattOpenClose\n"); + + /* Grab the device extension and lock it */ + DeviceExtension = DeviceObject->DeviceExtension; + ExAcquireFastMutex(&DeviceExtension->FastMutex); + + /* Check if someone is trying to open a device that doesn't exist yet */ + Count = DeviceExtension->HandleCount; + if (Count == 0xFFFFFFFF) + { + /* Fail the request */ + Status = STATUS_NO_SUCH_DEVICE; + if (CmBattDebug & CMBATT_PNP_INFO) + { + DbgPrint("CmBattOpenClose: Failed (UID = %x)(device being removed).\n", + DeviceExtension->Tag); + } + goto Complete; + } + + /* Check if this is an open or close */ + IoStackLocation = IoGetCurrentIrpStackLocation(Irp); + Major = IoStackLocation->MajorFunction; + if (Major == IRP_MJ_CREATE) + { + /* Increment the open count */ + DeviceExtension->HandleCount = Count + 1; + if (CmBattDebug & CMBATT_PNP_INFO) + { + DbgPrint("CmBattOpenClose: Open (DeviceNumber = %x)(count = %x).\n", + DeviceExtension->DeviceId, Count + 1); + } + } + else if (Major == IRP_MJ_CLOSE) + { + /* Decrement the open count */ + DeviceExtension->HandleCount = Count - 1; + if (CmBattDebug & CMBATT_PNP_INFO) + { + DbgPrint("CmBattOpenClose: Close (DeviceNumber = %x)(count = %x).\n", + DeviceExtension->DeviceId, Count + 1); + } + } + +Complete: + /* Release lock and complete request */ + ExReleaseFastMutex(&DeviceExtension->FastMutex); + Irp->IoStatus.Status = Status; + IofCompleteRequest(Irp, IO_NO_INCREMENT); + return Status; +} + +NTSTATUS +NTAPI +CmBattIoctl(IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp) +{ + PCMBATT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension; + NTSTATUS Status; + PIO_STACK_LOCATION IoStackLocation; + ULONG IoControlCode, OutputBufferLength, InputBufferLength; + PAGED_CODE(); + if (CmBattDebug & 2) DbgPrint("CmBattIoctl\n"); + + /* Acquire the remove lock */ + Status = IoAcquireRemoveLock(&DeviceExtension->RemoveLock, 0); + if (!NT_SUCCESS(Status)) + { + /* It's too late, fail */ + Irp->IoStatus.Status = STATUS_DEVICE_REMOVED; + IofCompleteRequest(Irp, IO_NO_INCREMENT); + return STATUS_DEVICE_REMOVED; + } + + /* There's nothing to do for an AC adapter */ + if (DeviceExtension->FdoType == CmBattAcAdapter) + { + /* Pass it down, and release the remove lock */ + IoSkipCurrentIrpStackLocation(Irp); + Status = IoCallDriver(DeviceExtension->AttachedDevice, Irp); + IoReleaseRemoveLock(&DeviceExtension->RemoveLock, Irp); + return Status; + } + + /* Send to class driver */ + Status = BatteryClassIoctl(DeviceExtension->ClassData, Irp); + if (Status == STATUS_NOT_SUPPORTED) + { + /* Read IOCTL information from IRP stack */ + IoStackLocation = IoGetCurrentIrpStackLocation(Irp); + IoControlCode = IoStackLocation->Parameters.DeviceIoControl.IoControlCode; + OutputBufferLength = IoStackLocation->Parameters.DeviceIoControl.OutputBufferLength; + InputBufferLength = IoStackLocation->Parameters.DeviceIoControl.InputBufferLength; + if (CmBattDebug & 4) + DbgPrint("CmBattIoctl: Received Direct Access IOCTL %x\n", IoControlCode); + + /* Handle internal IOCTLs */ + switch (IoControlCode) + { + case IOCTL_BATTERY_QUERY_UNIQUE_ID: + + /* Data is 4 bytes long */ + if (OutputBufferLength == sizeof(ULONG)) + { + /* Query it */ + Status = CmBattGetUniqueId(DeviceExtension->PdoDeviceObject, + Irp->AssociatedIrp.SystemBuffer); + if (NT_SUCCESS(Status)) Irp->IoStatus.Information = sizeof(ULONG); + } + else + { + /* Buffer size invalid */ + Status = STATUS_INVALID_BUFFER_SIZE; + } + break; + + case IOCTL_BATTERY_QUERY_STA: + + /* Data is 4 bytes long */ + if (OutputBufferLength == sizeof(ULONG)) + { + /* Query it */ + Status = CmBattGetStaData(DeviceExtension->PdoDeviceObject, + Irp->AssociatedIrp.SystemBuffer); + if (NT_SUCCESS(Status)) Irp->IoStatus.Information = sizeof(ULONG); + } + else + { + /* Buffer size invalid */ + Status = STATUS_INVALID_BUFFER_SIZE; + } + break; + + case IOCTL_BATTERY_QUERY_PSR: + + /* Data is 4 bytes long */ + if (OutputBufferLength == sizeof(ULONG)) + { + /* Do we have an AC adapter? */ + if (AcAdapterPdo) + { + /* Query it */ + Status = CmBattGetPsrData(AcAdapterPdo, + Irp->AssociatedIrp.SystemBuffer); + if (NT_SUCCESS(Status)) Irp->IoStatus.Information = sizeof(ULONG); + } + else + { + /* No adapter, just a battery, so fail */ + Status = STATUS_NO_SUCH_DEVICE; + } + } + else + { + /* Buffer size invalid */ + Status = STATUS_INVALID_BUFFER_SIZE; + } + break; + + case IOCTL_BATTERY_SET_TRIP_POINT: + + /* Data is 4 bytes long */ + if (InputBufferLength == sizeof(ULONG)) + { + /* Query it */ + Status = CmBattSetTripPpoint(DeviceExtension, + *(PULONG)Irp->AssociatedIrp.SystemBuffer); + Irp->IoStatus.Information = 0; + } + else + { + /* Buffer size invalid */ + Status = STATUS_INVALID_BUFFER_SIZE; + } + break; + + case IOCTL_BATTERY_QUERY_BIF: + + /* Data is 1060 bytes long */ + if (OutputBufferLength == sizeof(ACPI_BIF_DATA)) + { + /* Query it */ + Status = CmBattGetBifData(DeviceExtension, + Irp->AssociatedIrp.SystemBuffer); + if (NT_SUCCESS(Status)) Irp->IoStatus.Information = sizeof(ACPI_BIF_DATA); + } + else + { + /* Buffer size invalid */ + Status = STATUS_INVALID_BUFFER_SIZE; + } + break; + + case IOCTL_BATTERY_QUERY_BST: + + /* Data is 16 bytes long */ + if (OutputBufferLength == sizeof(ACPI_BST_DATA)) + { + /* Query it */ + Status = CmBattGetBstData(DeviceExtension, + Irp->AssociatedIrp.SystemBuffer); + if (NT_SUCCESS(Status)) Irp->IoStatus.Information = sizeof(ACPI_BST_DATA); + } + else + { + /* Buffer size invalid */ + Status = STATUS_INVALID_BUFFER_SIZE; + } + break; + + default: + + /* Unknown, let us pass it on to ACPI */ + if (CmBattDebug & 0xC) + DbgPrint("CmBattIoctl: Unknown IOCTL %x\n", IoControlCode); + break; + } + + /* Did someone pick it up? */ + if (Status != STATUS_NOT_SUPPORTED) + { + /* Complete the request */ + Irp->IoStatus.Status = Status; + IofCompleteRequest(Irp, IO_NO_INCREMENT); + } + else + { + /* Still unsupported, try ACPI */ + IoSkipCurrentIrpStackLocation(Irp); + Status = IoCallDriver(DeviceExtension->AttachedDevice, Irp); + } + } + + /* Release the remove lock and return status */ + IoReleaseRemoveLock(&DeviceExtension->RemoveLock, Irp); + return Status; +} + +NTSTATUS +NTAPI +CmBattQueryTag(IN PCMBATT_DEVICE_EXTENSION DeviceExtension, + OUT PULONG Tag) +{ + PDEVICE_OBJECT PdoDevice; + ULONG StaData; + ULONG NewTag; + NTSTATUS Status; + PAGED_CODE(); + if (CmBattDebug & (CMBATT_ACPI_WARNING | CMBATT_GENERIC_INFO)) + DbgPrint("CmBattQueryTag - Tag (%d), Battery %x, Device %d\n", + *Tag, DeviceExtension, DeviceExtension->DeviceId); + + /* Get PDO and clear notification flag */ + PdoDevice = DeviceExtension->PdoDeviceObject; + DeviceExtension->NotifySent = 0; + + /* Get _STA from PDO (we need the machine status, not the battery status) */ + Status = CmBattGetStaData(PdoDevice, &StaData); + if (NT_SUCCESS(Status)) + { + /* Is a battery present? */ + if (StaData & ACPI_STA_BATTERY_PRESENT) + { + /* Do we not have a tag yet? */ + if (!DeviceExtension->Tag) + { + /* Set the new tag value, reset tags if we reached the maximum */ + NewTag = DeviceExtension->TagData; + if (DeviceExtension->TagData++ == 0xFFFFFFFF) NewTag = 1; + DeviceExtension->Tag = NewTag; + if (CmBattDebug & CMBATT_GENERIC_INFO) + DbgPrint("CmBattQueryTag - New Tag: (%d)\n", DeviceExtension->Tag); + + /* Reset trip point data */ + DeviceExtension->TripPointOld = 0; + DeviceExtension->TripPointValue = BATTERY_UNKNOWN_CAPACITY; + + /* Clear AR lock and set new interrupt time */ + InterlockedExchange(&DeviceExtension->ArLockValue, 0); + DeviceExtension->InterruptTime = KeQueryInterruptTime(); + } + } + else + { + /* No battery, so no tag */ + DeviceExtension->Tag = 0; + Status = STATUS_NO_SUCH_DEVICE; + } + } + + /* Return the tag and status result */ + *Tag = DeviceExtension->Tag; + if (CmBattDebug & CMBATT_ACPI_WARNING) + DbgPrint("CmBattQueryTag: Returning Tag: 0x%x, status 0x%x\n", *Tag, Status); + return Status; +} + +NTSTATUS +NTAPI +CmBattDisableStatusNotify(IN PCMBATT_DEVICE_EXTENSION DeviceExtension) +{ + NTSTATUS Status; + PAGED_CODE(); + if (CmBattDebug & 0xA) DbgPrint("CmBattDisableStatusNotify\n"); + + /* Do we have a trip point */ + if (DeviceExtension->TripPointSet) + { + /* Is there a current value set? */ + if (DeviceExtension->TripPointValue) + { + /* Reset it back to 0 */ + DeviceExtension->TripPointValue = 0; + Status = CmBattSetTripPpoint(DeviceExtension, 0); + if (!NT_SUCCESS(Status)) + { + /* If it failed, set unknown/invalid value */ + DeviceExtension->TripPointValue = BATTERY_UNKNOWN_CAPACITY; + if (CmBattDebug & 8) + DbgPrint("CmBattDisableStatusNotify: SetTripPoint failed - %x\n", Status); + } + } + else + { + /* No trip point set, so this is a successful no-op */ + Status = STATUS_SUCCESS; + } + } + else + { + /* Nothing we can do */ + Status = STATUS_OBJECT_NAME_NOT_FOUND; + } + + /* Return status */ + return Status; +} + +NTSTATUS +NTAPI +CmBattSetStatusNotify(IN PCMBATT_DEVICE_EXTENSION DeviceExtension, + IN ULONG BatteryTag, + IN PBATTERY_NOTIFY BatteryNotify) +{ + NTSTATUS Status; + ACPI_BST_DATA BstData; + ULONG Capacity, NewTripPoint, TripPoint, DesignVoltage; + BOOLEAN Charging; + PAGED_CODE(); + if (CmBattDebug & (CMBATT_ACPI_WARNING | CMBATT_GENERIC_INFO)) + DbgPrint("CmBattSetStatusNotify: Tag (%d) Target(0x%x)\n", + BatteryTag, BatteryNotify->LowCapacity); + + /* Update any ACPI evaluations */ + Status = CmBattVerifyStaticInfo(DeviceExtension, BatteryTag); + if (!NT_SUCCESS(Status)) return Status; + + /* Trip point not supported, fail */ + if (!DeviceExtension->TripPointSet) return STATUS_OBJECT_NAME_NOT_FOUND; + + /* Are both capacities known? */ + if ((BatteryNotify->HighCapacity == BATTERY_UNKNOWN_CAPACITY) || + (BatteryNotify->LowCapacity == BATTERY_UNKNOWN_CAPACITY)) + { + /* We can't set trip points without these */ + if (CmBattDebug & CMBATT_GENERIC_WARNING) + DbgPrint("CmBattSetStatusNotify: Failing request because of BATTERY_UNKNOWN_CAPACITY.\n"); + return STATUS_NOT_SUPPORTED; + } + + /* Is the battery charging? */ + Charging = DeviceExtension->BstData.State & ACPI_BATT_STAT_CHARGING; + if (Charging) + { + /* Then the trip point is when we hit the cap */ + Capacity = BatteryNotify->HighCapacity; + NewTripPoint = BatteryNotify->HighCapacity; + } + else + { + /* Otherwise it's when we discharge to the bottom */ + Capacity = BatteryNotify->LowCapacity; + NewTripPoint = BatteryNotify->LowCapacity; + } + + /* Do we have data in Amps or Watts? */ + if (DeviceExtension->BifData.PowerUnit == ACPI_BATT_POWER_UNIT_AMPS) + { + /* We need the voltage to do the conversion */ + DesignVoltage = DeviceExtension->BifData.DesignVoltage; + if ((DesignVoltage != BATTERY_UNKNOWN_VOLTAGE) && (DesignVoltage)) + { + /* Convert from mAh into Ah */ + TripPoint = 1000 * NewTripPoint; + if (Charging) + { + /* Scale the high trip point */ + NewTripPoint = (TripPoint + 500) / DesignVoltage + ((TripPoint + 500) % DesignVoltage != 0); + } + else + { + /* Scale the low trip point */ + NewTripPoint = (TripPoint - 500) / DesignVoltage - ((TripPoint - 500) % DesignVoltage == 0); + } + } + else + { + /* Without knowing the voltage, Amps are not enough data on consumption */ + Status = STATUS_NOT_SUPPORTED; + if (CmBattDebug & CMBATT_ACPI_WARNING) + DbgPrint("CmBattSetStatusNotify: Can't calculate BTP, DesignVoltage = 0x%08x\n", + DesignVoltage); + } + } + else if (Charging) + { + /* Make it trip just one past the charge cap */ + ++NewTripPoint; + } + else if (NewTripPoint > 0) + { + /* Make it trip just one below the drain cap */ + --NewTripPoint; + } + + /* Do we actually have a new trip point? */ + if (NewTripPoint == DeviceExtension->TripPointValue) + { + /* No, so there is no work to be done */ + if (CmBattDebug & CMBATT_GENERIC_STATUS) + DbgPrint("CmBattSetStatusNotify: Keeping original setting: %X\n", DeviceExtension->TripPointValue); + return STATUS_SUCCESS; + } + + /* Set the trip point with ACPI and check for success */ + DeviceExtension->TripPointValue = NewTripPoint; + Status = CmBattSetTripPpoint(DeviceExtension, NewTripPoint); + if (!(NewTripPoint) && (Capacity)) Status = STATUS_NOT_SUPPORTED; + if (!NT_SUCCESS(Status)) + { + /* We failed to set the trip point, or there wasn't one settable */ + DeviceExtension->TripPointValue = BATTERY_UNKNOWN_CAPACITY; + if (CmBattDebug & (CMBATT_GENERIC_WARNING | CMBATT_ACPI_WARNING)) + DbgPrint("CmBattSetStatusNotify: SetTripPoint failed - %x\n", Status); + return Status; + } + + /* Read the new BST data to see the latest state */ + Status = CmBattGetBstData(DeviceExtension, &BstData); + if (!NT_SUCCESS(Status)) + { + /* We'll return failure to the caller */ + if (CmBattDebug & (CMBATT_GENERIC_WARNING | CMBATT_ACPI_WARNING)) + DbgPrint("CmBattSetStatusNotify: GetBstData - %x\n", Status); + } + else if ((Charging) && (BstData.RemainingCapacity >= NewTripPoint)) + { + /* We are charging and our capacity is past the trip point, so trip now */ + if (CmBattDebug & CMBATT_GENERIC_WARNING) + DbgPrint("CmBattSetStatusNotify: Trip point already crossed (1): TP = %08x, remaining capacity = %08x\n", + NewTripPoint, BstData.RemainingCapacity); + CmBattNotifyHandler(DeviceExtension, ACPI_BATT_NOTIFY_STATUS); + } + else if ((BstData.RemainingCapacity) && (Capacity)) + { + /* We are discharging, and our capacity is below the trip point, trip now */ + if (CmBattDebug & CMBATT_GENERIC_WARNING) + DbgPrint("CmBattSetStatusNotify: Trip point already crossed (1): TP = %08x, remaining capacity = %08x\n", + NewTripPoint, BstData.RemainingCapacity); + CmBattNotifyHandler(DeviceExtension, ACPI_BATT_NOTIFY_STATUS); + } + + /* All should've went well if we got here, unless BST failed... return! */ + if (CmBattDebug & CMBATT_GENERIC_STATUS) + DbgPrint("CmBattSetStatusNotify: Want %X CurrentCap %X\n", + Capacity, DeviceExtension->RemainingCapacity); + if (CmBattDebug & CMBATT_ACPI_WARNING) + DbgPrint("CmBattSetStatusNotify: Set to: [%#08lx][%#08lx][%#08lx] Status %x\n", + BatteryNotify->PowerState, + BatteryNotify->LowCapacity, + BatteryNotify->HighCapacity); + return Status; +} + +NTSTATUS +NTAPI +CmBattGetBatteryStatus(IN PCMBATT_DEVICE_EXTENSION DeviceExtension, + IN ULONG Tag) +{ + ULONG PsrData = 0; + NTSTATUS Status; + ULONG BstState; + ULONG DesignVoltage, PresentRate, RemainingCapacity; + PAGED_CODE(); + if (CmBattDebug & CMBATT_GENERIC_INFO) + DbgPrint("CmBattGetBatteryStatus - CmBatt (%08x) Tag (%d)\n", DeviceExtension, Tag); + + /* Validate ACPI data */ + Status = CmBattVerifyStaticInfo(DeviceExtension, Tag); + if (!NT_SUCCESS(Status)) return Status; + + /* Check for delayed status notifications */ + if (DeviceExtension->DelayNotification) + { + /* Process them now and don't do any other work */ + CmBattNotifyHandler(DeviceExtension, ACPI_BATT_NOTIFY_STATUS); + return Status; + } + + /* Get _BST from ACPI */ + Status = CmBattGetBstData(DeviceExtension, &DeviceExtension->BstData); + if (!NT_SUCCESS(Status)) + { + /* Fail */ + InterlockedExchange(&DeviceExtension->ArLockValue, 0); + return Status; + } + + /* Clear current BST information */ + DeviceExtension->State = 0; + DeviceExtension->RemainingCapacity = 0; + DeviceExtension->PresentVoltage = 0; + DeviceExtension->Rate = 0; + + /* Get battery state */ + BstState = DeviceExtension->BstData.State; + + /* Is the battery both charging and discharging? */ + if ((BstState & ACPI_BATT_STAT_DISCHARG) && (BstState & ACPI_BATT_STAT_CHARGING) && + (CmBattDebug & (CMBATT_ACPI_WARNING | CMBATT_GENERIC_WARNING))) + DbgPrint("************************ ACPI BIOS BUG ********************\n* " + "CmBattGetBatteryStatus: Invalid state: _BST method returned 0x%08x for Battery State.\n" + "* One battery cannot be charging and discharging at the same time.\n", + BstState); + + /* Is the battery discharging? */ + if (BstState & ACPI_BATT_STAT_DISCHARG) + { + /* Set power state and check if it just started discharging now */ + DeviceExtension->State |= BATTERY_DISCHARGING; + if (!(DeviceExtension->State & ACPI_BATT_STAT_DISCHARG)) + { + /* Remember the time when the state changed */ + DeviceExtension->InterruptTime = KeQueryInterruptTime(); + } + } + else if (BstState & ACPI_BATT_STAT_CHARGING) + { + /* Battery is charging, update power state */ + DeviceExtension->State |= (BATTERY_CHARGING | BATTERY_POWER_ON_LINE); + } + + /* Is the battery in a critical state? */ + if (BstState & ACPI_BATT_STAT_CRITICAL) DeviceExtension->State |= BATTERY_CRITICAL; + + /* Read the voltage data */ + DeviceExtension->PresentVoltage = DeviceExtension->BstData.PresentVoltage; + + /* Check if we have an A/C adapter */ + if (AcAdapterPdo) + { + /* Query information on it */ + CmBattGetPsrData(AcAdapterPdo, &PsrData); + } + else + { + /* Otherwise, check if the battery is charging */ + if (BstState & ACPI_BATT_STAT_CHARGING) + { + /* Then we'll assume there's a charger */ + PsrData = 1; + } + else + { + /* Assume no charger */ + PsrData = 0; + } + } + + /* Is there a charger? */ + if (PsrData) + { + /* Set the power state flag to reflect this */ + DeviceExtension->State |= BATTERY_POWER_ON_LINE; + if (CmBattDebug & (CMBATT_GENERIC_INFO | CMBATT_GENERIC_STATUS)) + DbgPrint("CmBattGetBatteryStatus: AC adapter is connected\n"); + } + else if (CmBattDebug & (CMBATT_GENERIC_INFO | CMBATT_GENERIC_STATUS)) + { + DbgPrint("CmBattGetBatteryStatus: AC adapter is NOT connected\n"); + } + + /* Get some data we'll need */ + DesignVoltage = DeviceExtension->BifData.DesignVoltage; + PresentRate = DeviceExtension->BstData.PresentRate; + RemainingCapacity = DeviceExtension->BstData.RemainingCapacity; + + /* Check if we have battery data in Watts instead of Amps */ + if (DeviceExtension->BifData.PowerUnit == ACPI_BATT_POWER_UNIT_WATTS) + { + /* Get the data from the BST */ + DeviceExtension->RemainingCapacity = RemainingCapacity; + DeviceExtension->Rate = PresentRate; + + /* Check if the rate is invalid */ + if (PresentRate > CM_MAX_VALUE) + { + /* Set an unknown rate and don't touch the old value */ + DeviceExtension->Rate = BATTERY_UNKNOWN_RATE; + if ((PresentRate != CM_UNKNOWN_VALUE) && (CmBattDebug & CMBATT_ACPI_WARNING)) + { + DbgPrint("CmBattGetBatteryStatus - Rate is greater than CM_MAX_VALUE\n"); + DbgPrint("---------------------- PresentRate = 0x%08x\n", PresentRate); + } + } + } + else if ((DesignVoltage != CM_UNKNOWN_VALUE) && (DesignVoltage)) + { + /* We have voltage data, what about capacity? */ + if (RemainingCapacity == CM_UNKNOWN_VALUE) + { + /* Unable to calculate it */ + DeviceExtension->RemainingCapacity = BATTERY_UNKNOWN_CAPACITY; + if (CmBattDebug & CMBATT_ACPI_WARNING) + { + DbgPrint("CmBattGetBatteryStatus - Can't calculate RemainingCapacity \n"); + DbgPrint("---------------------- RemainingCapacity = CM_UNKNOWN_VALUE\n"); + } + } + else + { + /* Compute the capacity with the information we have */ + DeviceExtension->RemainingCapacity = (DesignVoltage * RemainingCapacity + 500) / 1000; + } + + /* Check if we have a rate */ + if (PresentRate != CM_UNKNOWN_VALUE) + { + /* Make sure the rate isn't too large */ + if (PresentRate > (-500 / DesignVoltage)) + { + /* It is, so set unknown state */ + DeviceExtension->Rate = BATTERY_UNKNOWN_RATE; + if (CmBattDebug & CMBATT_ACPI_WARNING) + { + DbgPrint("CmBattGetBatteryStatus - Can't calculate Rate \n"); + DbgPrint("---------------------- Overflow: PresentRate = 0x%08x\n", PresentRate); + } + } + + /* Compute the rate */ + DeviceExtension->Rate = (PresentRate * DesignVoltage + 500) / 1000; + } + else + { + /* We don't have a rate, so set unknown value */ + DeviceExtension->Rate = BATTERY_UNKNOWN_RATE; + if (CmBattDebug & CMBATT_ACPI_WARNING) + { + DbgPrint("CmBattGetBatteryStatus - Can't calculate Rate \n"); + DbgPrint("---------------------- Present Rate = CM_UNKNOWN_VALUE\n"); + } + } + } + else + { + /* We have no rate, and no capacity, set unknown values */ + DeviceExtension->Rate = BATTERY_UNKNOWN_RATE; + DeviceExtension->RemainingCapacity = BATTERY_UNKNOWN_CAPACITY; + if (CmBattDebug & CMBATT_ACPI_WARNING) + { + DbgPrint("CmBattGetBatteryStatus - Can't calculate RemainingCapacity and Rate \n"); + DbgPrint("---------------------- DesignVoltage = 0x%08x\n", DesignVoltage); + } + } + + /* Check if we have an unknown rate */ + if (DeviceExtension->Rate == BATTERY_UNKNOWN_RATE) + { + /* The battery is discharging but we don't know by how much... this is bad! */ + if ((BstState & ACPI_BATT_STAT_DISCHARG) && + (CmBattDebug & (CMBATT_ACPI_WARNING | CMBATT_GENERIC_WARNING))) + DbgPrint("CmBattGetBatteryStatus: battery rate is unkown when battery is not charging!\n"); + } + else if (DeviceExtension->State & BATTERY_DISCHARGING) + { + /* The battery is discharging, so treat the rate as a negative rate */ + DeviceExtension->Rate = -DeviceExtension->Rate; + } + else if (!(DeviceExtension->State & BATTERY_CHARGING) && (DeviceExtension->Rate)) + { + /* We are not charging, not discharging, but have a rate? Ignore it! */ + if (CmBattDebug & CMBATT_GENERIC_WARNING) + DbgPrint("CmBattGetBatteryStatus: battery is not charging or discharging, but rate = %x\n", + DeviceExtension->Rate); + DeviceExtension->Rate = 0; + } + + /* Done */ + return STATUS_SUCCESS; +} + +NTSTATUS +NTAPI +CmBattQueryInformation(IN PCMBATT_DEVICE_EXTENSION FdoExtension, + IN ULONG Tag, + IN BATTERY_QUERY_INFORMATION_LEVEL InfoLevel, + IN OPTIONAL LONG AtRate, + IN PVOID Buffer, + IN ULONG BufferLength, + OUT PULONG ReturnedLength) +{ + NTSTATUS Status; + PVOID QueryData = NULL; + ULONG QueryLength = 0; + ULONG RemainingTime = 0; + ANSI_STRING TempString; + UNICODE_STRING TempString2; + WCHAR InfoBuffer[256]; + WCHAR TempBuffer[256]; + UNICODE_STRING InfoString; + ULONG RemainingCapacity; + BATTERY_REPORTING_SCALE BatteryReportingScale[2]; + LONG Rate; + PAGED_CODE(); + if (CmBattDebug & (CMBATT_ACPI_WARNING | CMBATT_GENERIC_INFO)) + DbgPrint("CmBattQueryInformation - Tag (%d) Device %d, Informationlevel %d\n", + Tag, + FdoExtension->DeviceId, + InfoLevel); + + /* Check ACPI Data */ + Status = CmBattVerifyStaticInfo(FdoExtension, Tag); + if (!NT_SUCCESS(Status)) return Status; + + /* Check what caller wants */ + switch (InfoLevel) + { + case BatteryInformation: + /* Just return our static information */ + QueryData = &FdoExtension->BatteryInformation; + QueryLength = sizeof(BATTERY_INFORMATION); + break; + + case BatteryGranularityInformation: + + /* Return our static information, we have two scales */ + BatteryReportingScale[0].Granularity = FdoExtension->BatteryCapacityGranularity1; + BatteryReportingScale[0].Capacity = FdoExtension->BatteryInformation.DefaultAlert1; + BatteryReportingScale[1].Granularity = FdoExtension->BatteryCapacityGranularity2; + BatteryReportingScale[1].Capacity = FdoExtension->BatteryInformation.DesignedCapacity; + QueryData = BatteryReportingScale; + QueryLength = sizeof(BATTERY_REPORTING_SCALE) * 2; + break; + + case BatteryEstimatedTime: + + /* Check if it's been more than 2 1/2 minutes since the last change */ + if ((KeQueryInterruptTime() - 150000000) > (FdoExtension->InterruptTime)) + { + /* Get new battery status */ + CmBattGetBatteryStatus(FdoExtension, FdoExtension->Tag); + + /* If the caller didn't specify a rate, use our static one */ + Rate = AtRate; + if (!Rate) Rate = FdoExtension->Rate; + + /* If we don't have a valid negative rate, use unknown value */ + if (Rate >= 0) Rate = BATTERY_UNKNOWN_RATE; + + /* Grab the remaining capacity */ + RemainingCapacity = FdoExtension->RemainingCapacity; + + /* See if we don't know one or the other */ + if ((Rate == BATTERY_UNKNOWN_RATE) || + (RemainingCapacity == BATTERY_UNKNOWN_CAPACITY)) + { + /* If the battery is discharging, we can't give out a time */ + if ((FdoExtension->BstData.State & ACPI_BATT_STAT_DISCHARG) && + (CmBattDebug & CMBATT_GENERIC_WARNING)) + DbgPrint("CmBattQueryInformation: Can't calculate EstimatedTime.\n"); + + /* Check if we don't have a rate and capacity is going down */ + if ((FdoExtension->Rate == BATTERY_UNKNOWN_RATE) && + (FdoExtension->BstData.State & ACPI_BATT_STAT_DISCHARG)) + { + /* We have to fail, since we lack data */ + Status = STATUS_INVALID_DEVICE_REQUEST; + if (CmBattDebug & CMBATT_GENERIC_WARNING) + DbgPrint("---------------------- PresentRate = BATTERY_UNKNOWN_RATE\n"); + } + + /* If we don't have capacity, the rate is useless */ + if (RemainingCapacity == BATTERY_UNKNOWN_CAPACITY) + { + /* We have to fail the request */ + Status = STATUS_INVALID_DEVICE_REQUEST; + if (CmBattDebug & CMBATT_GENERIC_WARNING) + DbgPrint("---------------------- RemainingCapacity = BATTERY_UNKNOWN_CAPACITY\n"); + } + } + else + { + /* We have data, but is it valid? */ + if (RemainingCapacity > 0x123456) + { + /* The capacity seems bogus, so don't use it */ + if (CmBattDebug & CMBATT_ACPI_WARNING) + DbgPrint("CmBattQueryInformation: Data Overflow in calculating Remaining Capacity.\n"); + } + else + { + /* Compute the remaining time in seconds, based on rate */ + RemainingTime = (RemainingCapacity * 3600) / -Rate; + } + } + } + + /* Return the remaining time */ + QueryData = &RemainingTime; + QueryLength = sizeof(ULONG); + break; + + case BatteryDeviceName: + + /* Build the model number string */ + RtlInitAnsiString(&TempString, FdoExtension->ModelNumber); + + /* Convert it to Unicode */ + InfoString.Buffer = InfoBuffer; + InfoString.MaximumLength = sizeof(InfoBuffer); + Status = RtlAnsiStringToUnicodeString(&InfoString, &TempString, 0); + + /* Return the unicode buffer */ + QueryData = InfoString.Buffer; + QueryLength = InfoString.Length; + break; + + case BatteryTemperature: + case BatteryManufactureDate: + + /* We don't support these */ + Status = STATUS_INVALID_DEVICE_REQUEST; + break; + + case BatteryManufactureName: + + /* Build the OEM info string */ + RtlInitAnsiString(&TempString, FdoExtension->OemInfo); + + /* Convert it to Unicode */ + InfoString.Buffer = InfoBuffer; + InfoString.MaximumLength = sizeof(InfoBuffer); + Status = RtlAnsiStringToUnicodeString(&InfoString, &TempString, 0); + + /* Return the unicode buffer */ + QueryData = InfoString.Buffer; + QueryLength = InfoString.Length; + break; + + case BatteryUniqueID: + + /* Build the serial number string */ + RtlInitAnsiString(&TempString, FdoExtension->SerialNumber); + + /* Convert it to Unicode */ + InfoString.Buffer = InfoBuffer; + InfoString.MaximumLength = sizeof(InfoBuffer); + RtlAnsiStringToUnicodeString(&InfoString, &TempString, 0); + + /* Setup a temporary string for concatenation */ + TempString2.Buffer = TempBuffer; + TempString2.MaximumLength = sizeof(TempBuffer); + + /* Check if there's an OEM string */ + if (FdoExtension->OemInfo[0]) + { + /* Build the OEM info string */ + RtlInitAnsiString(&TempString, FdoExtension->OemInfo); + + /* Convert it to Unicode and append it */ + RtlAnsiStringToUnicodeString(&TempString2, &TempString, 0); + RtlAppendUnicodeStringToString(&InfoString, &TempString2); + } + + /* Build the model number string */ + RtlInitAnsiString(&TempString, FdoExtension->ModelNumber); + + /* Convert it to Unicode and append it */ + RtlAnsiStringToUnicodeString(&TempString2, &TempString, 0); + RtlAppendUnicodeStringToString(&InfoString, &TempString2); + + /* Return the final appended string */ + QueryData = InfoString.Buffer; + QueryLength = InfoString.Length; + break; + + default: + + /* Everything else is unknown */ + Status = STATUS_INVALID_PARAMETER; + break; + } + + /* Return the required length and check if the caller supplied enough */ + *ReturnedLength = QueryLength; + if (BufferLength < QueryLength) Status = STATUS_BUFFER_TOO_SMALL; + + /* Copy the data if there's enough space and it exists */ + if ((NT_SUCCESS(Status)) && (QueryData)) RtlCopyMemory(Buffer, QueryData, QueryLength); + + /* Return function result */ + return Status; +} + +NTSTATUS +NTAPI +CmBattQueryStatus(IN PCMBATT_DEVICE_EXTENSION DeviceExtension, + IN ULONG Tag, + IN PBATTERY_STATUS BatteryStatus) +{ + NTSTATUS Status; + PAGED_CODE(); + if (CmBattDebug & (CMBATT_ACPI_WARNING | CMBATT_GENERIC_INFO)) + DbgPrint("CmBattQueryStatus - Tag (%d) Device %x\n", Tag, DeviceExtension->DeviceId); + + /* Query ACPI information */ + Status = CmBattGetBatteryStatus(DeviceExtension, Tag); + if (NT_SUCCESS(Status)) + { + BatteryStatus->PowerState = DeviceExtension->State; + BatteryStatus->Capacity = DeviceExtension->RemainingCapacity; + BatteryStatus->Voltage = DeviceExtension->PresentVoltage; + BatteryStatus->Rate = DeviceExtension->Rate; + } + + /* Return status */ + if (CmBattDebug & (CMBATT_GENERIC_INFO)) + DbgPrint("CmBattQueryStatus: Returning [%#08lx][%#08lx][%#08lx][%#08lx]\n", + BatteryStatus->PowerState, + BatteryStatus->Capacity, + BatteryStatus->Voltage, + BatteryStatus->Rate); + return Status; +} + +NTSTATUS +NTAPI +DriverEntry(IN PDRIVER_OBJECT DriverObject, + IN PUNICODE_STRING RegistryPath) +{ + NTSTATUS Status; + PDRIVER_EXTENSION DriverExtension; + OBJECT_ATTRIBUTES ObjectAttributes; + UNICODE_STRING CallbackName; + + /* Allocate registry path */ + GlobalRegistryPath.MaximumLength = RegistryPath->Length + sizeof(UNICODE_NULL); + GlobalRegistryPath.Length = RegistryPath->Length; + GlobalRegistryPath.Buffer = ExAllocatePoolWithTag(PagedPool, + GlobalRegistryPath.MaximumLength, + 'MtaB'); + if (!GlobalRegistryPath.Buffer) + { + /* Fail if we're out of memory this early */ + if (CmBattDebug & CMBATT_GENERIC_WARNING) + DbgPrint("CmBatt: Couldn't allocate pool for registry path."); + return STATUS_INSUFFICIENT_RESOURCES; + } + + /* Buffer allocated, copy the string */ + RtlCopyUnicodeString(&GlobalRegistryPath, RegistryPath); + if (CmBattDebug & CMBATT_GENERIC_INFO) + DbgPrint("CmBatt DriverEntry - Obj (%08x) Path \"%ws\"\n", + DriverObject, + RegistryPath->Buffer); + + /* Setup the major dispatchers */ + DriverObject->MajorFunction[IRP_MJ_CREATE] = CmBattOpenClose; + DriverObject->MajorFunction[IRP_MJ_CLOSE] = CmBattOpenClose; + DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = CmBattIoctl; + DriverObject->MajorFunction[IRP_MJ_POWER] = CmBattPowerDispatch; + DriverObject->MajorFunction[IRP_MJ_PNP] = CmBattPnpDispatch; + DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = CmBattSystemControl; + + /* And the unload routine */ + DriverObject->DriverUnload = CmBattUnload; + + /* And the add device routine */ + DriverExtension = DriverObject->DriverExtension; + DriverExtension->AddDevice = CmBattAddDevice; + + /* Create a power callback */ + RtlInitUnicodeString(&CallbackName, L"\\Callback\\PowerState"); + InitializeObjectAttributes(&ObjectAttributes, + &CallbackName, + OBJ_KERNEL_HANDLE, + NULL, + NULL); + Status = ExCreateCallback(&CmBattPowerCallBackObject, &ObjectAttributes, 0, TRUE); + if (!NT_SUCCESS(Status)) + { + /* No callback, fail */ + CmBattPowerCallBackObject = 0; + if (CmBattDebug & CMBATT_GENERIC_WARNING) + DbgPrint("CmBattRegisterPowerCallBack: failed status=0x%08x\n", Status); + } + else + { + /* Register the power callback now */ + CmBattPowerCallBackRegistration = ExRegisterCallback(CmBattPowerCallBackObject, + (PVOID)CmBattPowerCallBack, + DriverObject); + if (CmBattPowerCallBackRegistration) + { + /* Last thing: setup our DPC and timer for battery wake */ + KeInitializeDpc(&CmBattWakeDpcObject, (PVOID)CmBattWakeDpc, DriverObject); + KeInitializeTimer(&CmBattWakeDpcTimerObject); + } + else + { + ObfDereferenceObject(CmBattPowerCallBackObject); + if (CmBattDebug & CMBATT_GENERIC_WARNING) + DbgPrint("CmBattRegisterPowerCallBack: ExRegisterCallback failed.\n"); + } + + /* All good */ + Status = STATUS_SUCCESS; + } + + /* Return failure or success */ + return Status; +} + +/* EOF */ diff --git a/reactos/drivers/bus/acpi/cmbatt/cmbatt.h b/reactos/drivers/bus/acpi/cmbatt/cmbatt.h new file mode 100644 index 00000000000..8f952d20200 --- /dev/null +++ b/reactos/drivers/bus/acpi/cmbatt/cmbatt.h @@ -0,0 +1,282 @@ +/* + * PROJECT: ReactOS ACPI-Compliant Control Method Battery + * LICENSE: BSD - See COPYING.ARM in the top level directory + * FILE: boot/drivers/bus/acpi/cmbatt/cmbatt.h + * PURPOSE: Main Header File + * PROGRAMMERS: ReactOS Portable Systems Group + */ + +#include +#include +#include +#include +#include +#include +#include + +#define IOCTL_BATTERY_QUERY_UNIQUE_ID \ + CTL_CODE(FILE_DEVICE_BATTERY, 0x101, METHOD_BUFFERED, FILE_READ_ACCESS) // 0x294404 + +#define IOCTL_BATTERY_QUERY_STA \ + CTL_CODE(FILE_DEVICE_BATTERY, 0x102, METHOD_BUFFERED, FILE_READ_ACCESS) // 0x294408 + +#define IOCTL_BATTERY_QUERY_PSR \ + CTL_CODE(FILE_DEVICE_BATTERY, 0x103, METHOD_BUFFERED, FILE_READ_ACCESS) // 0x29440C + +#define IOCTL_BATTERY_SET_TRIP_POINT \ + CTL_CODE(FILE_DEVICE_BATTERY, 0x104, METHOD_BUFFERED, FILE_READ_ACCESS) // 0x294410 + +#define IOCTL_BATTERY_QUERY_BIF \ + CTL_CODE(FILE_DEVICE_BATTERY, 0x105, METHOD_BUFFERED, FILE_READ_ACCESS) // 0x294414 + +#define IOCTL_BATTERY_QUERY_BST \ + CTL_CODE(FILE_DEVICE_BATTERY, 0x106, METHOD_BUFFERED, FILE_READ_ACCESS) // 0x294418 + +#define CMBATT_GENERIC_STATUS 0x01 +#define CMBATT_GENERIC_INFO 0x02 +#define CMBATT_GENERIC_WARNING 0x04 +#define CMBATT_ACPI_WARNING 0x08 +#define CMBATT_POWER_INFO 0x10 +#define CMBATT_PNP_INFO 0x20 +#define CMBATT_ACPI_ENTRY_EXIT 0x40 +#define CMBATT_PNP_ENTRY_EXIT 0x200 +#define CMBATT_ACPI_ASSERT 0x400 + +typedef enum _CMBATT_EXTENSION_TYPE +{ + CmBattAcAdapter, + CmBattBattery +} CMBATT_EXTENSION_TYPE; + +#define ACPI_BUS_CHECK 0x00 +#define ACPI_DEVICE_CHECK 0x01 + +#define ACPI_STA_PRESENT 0x01 +#define ACPI_STA_ENABLED 0x02 +#define ACPI_STA_SHOW_UI 0x04 +#define ACPI_STA_FUNCTIONAL 0x08 +#define ACPI_STA_BATTERY_PRESENT 0x10 + +#define ACPI_BATT_NOTIFY_STATUS 0x80 +#define ACPI_BATT_NOTIFY_INFO 0x81 + +#define ACPI_BATT_STAT_DISCHARG 0x0001 +#define ACPI_BATT_STAT_CHARGING 0x0002 +#define ACPI_BATT_STAT_CRITICAL 0x0004 + +#define CM_MAX_VALUE 0x7FFFFFFF +#define CM_UNKNOWN_VALUE 0xFFFFFFFF + +typedef struct _ACPI_BST_DATA +{ + ULONG State; + ULONG PresentRate; + ULONG RemainingCapacity; + ULONG PresentVoltage; +} ACPI_BST_DATA, *PACPI_BST_DATA; + +#define ACPI_BATT_POWER_UNIT_WATTS 0x0 +#define ACPI_BATT_POWER_UNIT_AMPS 0x1 + +typedef struct _ACPI_BIF_DATA +{ + ULONG PowerUnit; + ULONG DesignCapacity; + ULONG LastFullCapacity; + ULONG BatteryTechnology; + ULONG DesignVoltage; + ULONG DesignCapacityWarning; + ULONG DesignCapacityLow; + ULONG BatteryCapacityGranularity1; + ULONG BatteryCapacityGranularity2; + CHAR ModelNumber[256]; + CHAR SerialNubmer[256]; + CHAR BatteryType[256]; + CHAR OemInfo[256]; +} ACPI_BIF_DATA, *PACPI_BIF_DATA; + +#define CMBATT_AR_NOTIFY 0x01 +#define CMBATT_AR_INSERT 0x02 +#define CMBATT_AR_REMOVE 0x04 + +typedef struct _CMBATT_DEVICE_EXTENSION +{ + CMBATT_EXTENSION_TYPE FdoType; + PDEVICE_OBJECT DeviceObject; + PDEVICE_OBJECT FdoDeviceObject; + PDEVICE_OBJECT PdoDeviceObject; + PDEVICE_OBJECT AttachedDevice; + FAST_MUTEX FastMutex; + ULONG HandleCount; + PIRP PowerIrp; + POWER_STATE PowerState; + WMILIB_CONTEXT WmiLibInfo; + BOOLEAN WaitWakeEnable; + IO_REMOVE_LOCK RemoveLock; + ULONG DeviceId; + PUNICODE_STRING DeviceName; + ACPI_INTERFACE_STANDARD AcpiInterface; + BOOLEAN DelayNotification; + BOOLEAN ArFlag; + PVOID ClassData; + BOOLEAN Started; + BOOLEAN NotifySent; + LONG ArLockValue; + ULONG TagData; + ULONG Tag; + ULONG ModelNumberLength; + PCHAR ModelNumber; + ULONG SerialNumberLength; + PCHAR SerialNumber; + ULONG OemInfoLength; + PCHAR OemInfo; + ACPI_BST_DATA BstData; + ACPI_BIF_DATA BifData; + ULONG Id; + ULONG State; + ULONG RemainingCapacity; + ULONG PresentVoltage; + ULONG Rate; + BATTERY_INFORMATION BatteryInformation; + ULONG BatteryCapacityGranularity1; + ULONG BatteryCapacityGranularity2; + BOOLEAN TripPointSet; + ULONG TripPointValue; + ULONG TripPointOld; + ULONGLONG InterruptTime; +} CMBATT_DEVICE_EXTENSION, *PCMBATT_DEVICE_EXTENSION; + +NTSTATUS +NTAPI +CmBattPowerDispatch( + PDEVICE_OBJECT DeviceObject, + PIRP Irp +); + +NTSTATUS +NTAPI +CmBattPnpDispatch( + PDEVICE_OBJECT DeviceObject, + PIRP Irp +); + +NTSTATUS +NTAPI +CmBattAddDevice( + PDRIVER_OBJECT DriverObject, + PDEVICE_OBJECT DeviceObject +); + +NTSTATUS +NTAPI +CmBattSystemControl( + PDEVICE_OBJECT DeviceObject, + PIRP Irp +); + +NTSTATUS +NTAPI +CmBattGetBstData( + PCMBATT_DEVICE_EXTENSION DeviceExtension, + PACPI_BST_DATA BstData +); + +NTSTATUS +NTAPI +CmBattGetPsrData( + PDEVICE_OBJECT DeviceObject, + PULONG PsrData +); + +NTSTATUS +NTAPI +CmBattGetStaData( + PDEVICE_OBJECT DeviceObject, + PULONG StaData +); + +NTSTATUS +NTAPI +CmBattGetBifData( + PCMBATT_DEVICE_EXTENSION DeviceExtension, + PACPI_BIF_DATA BifData +); + +NTSTATUS +NTAPI +CmBattSetTripPpoint( + PCMBATT_DEVICE_EXTENSION DeviceExtension, + ULONG AlarmValue +); + +VOID +NTAPI +CmBattNotifyHandler( + IN PCMBATT_DEVICE_EXTENSION DeviceExtension, + IN ULONG NotifyValue +); + +NTSTATUS +NTAPI +CmBattWmiDeRegistration( + PCMBATT_DEVICE_EXTENSION DeviceExtension +); + +NTSTATUS +NTAPI +CmBattWmiRegistration( + PCMBATT_DEVICE_EXTENSION DeviceExtension +); + +NTSTATUS +NTAPI +CmBattGetUniqueId( + PDEVICE_OBJECT DeviceObject, + PULONG UniqueId +); + +NTSTATUS +NTAPI +CmBattQueryInformation( + IN PCMBATT_DEVICE_EXTENSION FdoExtension, + IN ULONG Tag, + IN BATTERY_QUERY_INFORMATION_LEVEL InfoLevel, + IN OPTIONAL LONG AtRate, + IN PVOID Buffer, + IN ULONG BufferLength, + OUT PULONG ReturnedLength +); + +NTSTATUS +NTAPI +CmBattQueryStatus( + IN PCMBATT_DEVICE_EXTENSION DeviceExtension, + IN ULONG Tag, + IN PBATTERY_STATUS BatteryStatus +); + +NTSTATUS +NTAPI +CmBattSetStatusNotify( + IN PCMBATT_DEVICE_EXTENSION DeviceExtension, + IN ULONG BatteryTag, + IN PBATTERY_NOTIFY BatteryNotify +); + +NTSTATUS +NTAPI +CmBattDisableStatusNotify( + IN PCMBATT_DEVICE_EXTENSION DeviceExtension +); + +NTSTATUS +NTAPI +CmBattQueryTag( + IN PCMBATT_DEVICE_EXTENSION DeviceExtension, + OUT PULONG Tag +); + +extern PDEVICE_OBJECT AcAdapterPdo; +extern ULONG CmBattDebug; + +/* EOF */ diff --git a/reactos/drivers/bus/acpi/cmbatt/cmbatt.rbuild b/reactos/drivers/bus/acpi/cmbatt/cmbatt.rbuild new file mode 100644 index 00000000000..51c46dbe2bb --- /dev/null +++ b/reactos/drivers/bus/acpi/cmbatt/cmbatt.rbuild @@ -0,0 +1,14 @@ + + + + ntoskrnl + hal + battc + wmilib + . + cmbatt.c + cmexec.c + cmbpnp.c + cmbwmi.c + cmbatt.rc + diff --git a/reactos/drivers/bus/acpi/cmbatt/cmbatt.rc b/reactos/drivers/bus/acpi/cmbatt/cmbatt.rc new file mode 100644 index 00000000000..d1542f9019e --- /dev/null +++ b/reactos/drivers/bus/acpi/cmbatt/cmbatt.rc @@ -0,0 +1,5 @@ +#define REACTOS_VERSION_DLL +#define REACTOS_STR_FILE_DESCRIPTION "Control Method Battery Miniclass Driver\0" +#define REACTOS_STR_INTERNAL_NAME "cmbatt\0" +#define REACTOS_STR_ORIGINAL_FILENAME "cmbatt.sys\0" +#include diff --git a/reactos/drivers/bus/acpi/cmbatt/cmbpnp.c b/reactos/drivers/bus/acpi/cmbatt/cmbpnp.c new file mode 100644 index 00000000000..55d3ae63d49 --- /dev/null +++ b/reactos/drivers/bus/acpi/cmbatt/cmbpnp.c @@ -0,0 +1,875 @@ +/* + * PROJECT: ReactOS ACPI-Compliant Control Method Battery + * LICENSE: BSD - See COPYING.ARM in the top level directory + * FILE: boot/drivers/bus/acpi/cmbatt/cmbpnp.c + * PURPOSE: Plug-and-Play IOCTL/IRP Handling + * PROGRAMMERS: ReactOS Portable Systems Group + */ + +/* INCLUDES *******************************************************************/ + +#include "cmbatt.h" + +/* FUNCTIONS ******************************************************************/ + +VOID +NTAPI +CmBattWaitWakeLoop(IN PDEVICE_OBJECT DeviceObject, + IN UCHAR MinorFunction, + IN POWER_STATE PowerState, + IN PVOID Context, + IN PIO_STATUS_BLOCK IoStatusBlock) +{ + NTSTATUS Status; + PCMBATT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension; + if (CmBattDebug & 0x20) DbgPrint("CmBattWaitWakeLoop: Entered.\n"); + + /* Check for success */ + if ((NT_SUCCESS(IoStatusBlock->Status)) && (DeviceExtension->WaitWakeEnable)) + { + /* Request a new power IRP */ + if (CmBattDebug & 2) DbgPrint("CmBattWaitWakeLoop: completed successfully\n"); + Status = PoRequestPowerIrp(DeviceObject, + MinorFunction, + PowerState, + CmBattWaitWakeLoop, + Context, + &DeviceExtension->PowerIrp); + if (CmBattDebug & 2) + DbgPrint("CmBattWaitWakeLoop: PoRequestPowerIrp: status = 0x%08x.\n", + Status); + } + else + { + /* Clear the power IRP, we failed */ + if (CmBattDebug & 0xC) + DbgPrint("CmBattWaitWakeLoop: failed: status = 0x%08x.\n", + IoStatusBlock->Status); + DeviceExtension->PowerIrp = NULL; + } +} + +NTSTATUS +NTAPI +CmBattIoCompletion(IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp, + IN PKEVENT Event) +{ + if (CmBattDebug & 2) DbgPrint("CmBattIoCompletion: Event (%x)\n", Event); + + /* Set the completion event */ + KeSetEvent(Event, IO_NO_INCREMENT, FALSE); + return STATUS_MORE_PROCESSING_REQUIRED; +} + +NTSTATUS +NTAPI +CmBattGetAcpiInterfaces(IN PDEVICE_OBJECT DeviceObject, + IN OUT PACPI_INTERFACE_STANDARD AcpiInterface) +{ + PIRP Irp; + NTSTATUS Status; + PIO_STACK_LOCATION IoStackLocation; + KEVENT Event; + + /* Allocate the IRP */ + Irp = IoAllocateIrp(DeviceObject->StackSize, 0); + if (!Irp) + { + /* Fail */ + if (CmBattDebug & 0xC) + DbgPrint("CmBattGetAcpiInterfaces: Failed to allocate Irp\n"); + return STATUS_INSUFFICIENT_RESOURCES; + } + + /* Set default error code */ + Irp->IoStatus.Status = STATUS_NOT_SUPPORTED; + + /* Build the query */ + IoStackLocation = IoGetNextIrpStackLocation(Irp); + IoStackLocation->MinorFunction = IRP_MN_QUERY_INTERFACE; + IoStackLocation->Parameters.QueryInterface.InterfaceType = &GUID_ACPI_INTERFACE_STANDARD; + IoStackLocation->Parameters.QueryInterface.Size = sizeof(ACPI_INTERFACE_STANDARD); + IoStackLocation->Parameters.QueryInterface.Version = 1; + IoStackLocation->Parameters.QueryInterface.Interface = (PINTERFACE)AcpiInterface; + IoStackLocation->Parameters.QueryInterface.InterfaceSpecificData = NULL; + + /* Set default ACPI interface data */ + AcpiInterface->Size = sizeof(ACPI_INTERFACE_STANDARD); + AcpiInterface->Version = 1; + + /* Initialize our wait event */ + KeInitializeEvent(&Event, SynchronizationEvent, 0); + + /* Set the completion routine */ + IoCopyCurrentIrpStackLocationToNext(Irp); + IoSetCompletionRoutine(Irp, + (PVOID)CmBattIoCompletion, + &Event, + TRUE, + TRUE, + TRUE); + + /* Now call ACPI */ + Status = IoCallDriver(DeviceObject, Irp); + if (Status == STATUS_PENDING) + { + /* Wait for completion */ + KeWaitForSingleObject(&Event, + Executive, + KernelMode, + FALSE, + NULL); + Status = Irp->IoStatus.Status; + } + + /* Free the IRP */ + IoFreeIrp(Irp); + + /* Return status */ + if (!(NT_SUCCESS(Status)) && (CmBattDebug & 0xC)) + DbgPrint("CmBattGetAcpiInterfaces: Could not get ACPI driver interfaces, status = %x\n", Status); + return Status; +} + +VOID +NTAPI +CmBattDestroyFdo(IN PDEVICE_OBJECT DeviceObject) +{ + PAGED_CODE(); + if (CmBattDebug & 0x220) DbgPrint("CmBattDestroyFdo, Battery.\n"); + + /* Delete the device */ + IoDeleteDevice(DeviceObject); + if (CmBattDebug & 0x220) DbgPrint("CmBattDestroyFdo: done.\n"); +} + +NTSTATUS +NTAPI +CmBattRemoveDevice(IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp) +{ + PCMBATT_DEVICE_EXTENSION DeviceExtension; + PVOID Context; + DeviceExtension = DeviceObject->DeviceExtension; + if (CmBattDebug & 2) + DbgPrint("CmBattRemoveDevice: CmBatt (%x), Type %d, _UID %d\n", + DeviceExtension, + DeviceExtension->FdoType, + DeviceExtension->DeviceId); + + /* Make sure it's safe to go ahead */ + IoReleaseRemoveLockAndWait(&DeviceExtension->RemoveLock, 0); + + /* Check for pending power IRP */ + if (DeviceExtension->PowerIrp) + { + /* Cancel and clear */ + IoCancelIrp(DeviceExtension->PowerIrp); + DeviceExtension->PowerIrp = NULL; + } + + /* Check what type of FDO is being removed */ + Context = DeviceExtension->AcpiInterface.Context; + if (DeviceExtension->FdoType == CmBattBattery) + { + /* Unregister battery FDO */ + DeviceExtension->AcpiInterface.UnregisterForDeviceNotifications(Context, + (PVOID)CmBattNotifyHandler); + CmBattWmiDeRegistration(DeviceExtension); + if (!NT_SUCCESS(BatteryClassUnload(DeviceExtension->ClassData))) ASSERT(FALSE); + } + else + { + /* Unregister AC adapter FDO */ + DeviceExtension->AcpiInterface.UnregisterForDeviceNotifications(Context, + (PVOID)CmBattNotifyHandler); + CmBattWmiDeRegistration(DeviceExtension); + AcAdapterPdo = NULL; + } + + /* Detach and delete */ + IoDetachDevice(DeviceExtension->AttachedDevice); + IoDeleteDevice(DeviceExtension->DeviceObject); + return STATUS_SUCCESS; +} + +NTSTATUS +NTAPI +CmBattPowerDispatch(IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp) +{ + PIO_STACK_LOCATION IoStackLocation; + PCMBATT_DEVICE_EXTENSION DeviceExtension; + NTSTATUS Status; + if (CmBattDebug & 0x210) DbgPrint("CmBattPowerDispatch\n"); + + /* Get stack location and device extension */ + IoStackLocation = IoGetCurrentIrpStackLocation(Irp); + DeviceExtension = DeviceObject->DeviceExtension; + switch (IoStackLocation->MinorFunction) + { + case IRP_MN_WAIT_WAKE: + if (CmBattDebug & 0x10) + DbgPrint("CmBattPowerDispatch: IRP_MN_WAIT_WAKE\n"); + break; + + case IRP_MN_POWER_SEQUENCE: + if (CmBattDebug & 0x10) + DbgPrint("CmBattPowerDispatch: IRP_MN_POWER_SEQUENCE\n"); + break; + + case IRP_MN_QUERY_POWER: + if (CmBattDebug & 0x10) + DbgPrint("CmBattPowerDispatch: IRP_MN_WAIT_WAKE\n"); + break; + + case IRP_MN_SET_POWER: + if (CmBattDebug & 0x10) + DbgPrint("CmBattPowerDispatch: IRP_MN_SET_POWER type: %d, State: %d \n", + IoStackLocation->Parameters.Power.Type, + IoStackLocation->Parameters.Power.State); + break; + + default: + + if (CmBattDebug & 1) + DbgPrint("CmBattPowerDispatch: minor %d\n", IoStackLocation->MinorFunction); + break; + } + + /* Start the next IRP and see if we're attached */ + PoStartNextPowerIrp(Irp); + if (DeviceExtension->AttachedDevice) + { + /* Call ACPI */ + IoSkipCurrentIrpStackLocation(Irp); + Status = PoCallDriver(DeviceExtension->AttachedDevice, Irp); + } + else + { + /* Complete the request here */ + Status = Irp->IoStatus.Status; + IofCompleteRequest(Irp, IO_NO_INCREMENT); + } + + /* Return status */ + return Status; +} + +NTSTATUS +NTAPI +CmBattPnpDispatch(IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp) +{ + PIO_STACK_LOCATION IoStackLocation; + PCMBATT_DEVICE_EXTENSION DeviceExtension; + NTSTATUS Status; + KEVENT Event; + PAGED_CODE(); + + /* Get stack location and device extension */ + IoStackLocation = IoGetCurrentIrpStackLocation(Irp); + DeviceExtension = DeviceObject->DeviceExtension; + + /* Set default error */ + Status = STATUS_NOT_SUPPORTED; + + /* Try to acquire the lock before doing anything */ + Status = IoAcquireRemoveLock(&DeviceExtension->RemoveLock, 0); + if (!NT_SUCCESS(Status)) + { + /* Complete the request */ + Irp->IoStatus.Status = STATUS_DEVICE_REMOVED; + IofCompleteRequest(Irp, IO_NO_INCREMENT); + return STATUS_DEVICE_REMOVED; + } + + /* What's the operation? */ + switch (IoStackLocation->MinorFunction) + { + case IRP_MN_QUERY_PNP_DEVICE_STATE: + + /* Initialize our wait event */ + KeInitializeEvent(&Event, SynchronizationEvent, 0); + + /* Set the completion routine */ + IoCopyCurrentIrpStackLocationToNext(Irp); + IoSetCompletionRoutine(Irp, + (PVOID)CmBattIoCompletion, + &Event, + TRUE, + TRUE, + TRUE); + + /* Now call ACPI to inherit its PnP Device State */ + Status = IoCallDriver(DeviceObject, Irp); + if (Status == STATUS_PENDING) + { + /* Wait for completion */ + KeWaitForSingleObject(&Event, + Executive, + KernelMode, + FALSE, + NULL); + Status = Irp->IoStatus.Status; + } + + /* However, a battery CAN be disabled */ + Irp->IoStatus.Information &= ~PNP_DEVICE_NOT_DISABLEABLE; + + /* Release the remove lock and complete the request */ + IoCompleteRequest(Irp, IO_NO_INCREMENT); + IoReleaseRemoveLock(&DeviceExtension->RemoveLock, Irp); + return Status; + + case IRP_MN_SURPRISE_REMOVAL: + if (CmBattDebug & 0x20) + DbgPrint("CmBattPnpDispatch: IRP_MN_SURPRISE_REMOVAL\n"); + + /* Lock the device extension and set the handle count to invalid */ + ExAcquireFastMutex(&DeviceExtension->FastMutex); + DeviceExtension->HandleCount = -1; + ExReleaseFastMutex(&DeviceExtension->FastMutex); + Status = STATUS_SUCCESS; + break; + + case IRP_MN_START_DEVICE: + if (CmBattDebug & 0x20) + DbgPrint("CmBattPnpDispatch: IRP_MN_START_DEVICE\n"); + + /* Mark the extension as started */ + if (DeviceExtension->FdoType == CmBattBattery) DeviceExtension->Started = TRUE; + Status = STATUS_SUCCESS; + break; + + case IRP_MN_STOP_DEVICE: + if (CmBattDebug & 0x20) + DbgPrint("CmBattPnpDispatch: IRP_MN_STOP_DEVICE\n"); + + /* Mark the extension as stopped */ + if (DeviceExtension->FdoType == CmBattBattery) DeviceExtension->Started = FALSE; + Status = STATUS_SUCCESS; + break; + + case IRP_MN_QUERY_REMOVE_DEVICE: + if (CmBattDebug & 0x20) + DbgPrint("CmBattPnpDispatch: IRP_MN_QUERY_REMOVE_DEVICE\n"); + + /* Lock the extension and get the current handle count */ + ExAcquireFastMutex(&DeviceExtension->FastMutex); + if (DeviceExtension->HandleCount == 0) + { + /* No handles. Mark it as invalid since it'll be removed */ + DeviceExtension->HandleCount = -1; + Status = STATUS_SUCCESS; + } + else if (DeviceExtension->HandleCount == -1) + { + /* Don't do anything, but this is strange since it's already removed */ + Status = STATUS_SUCCESS; + if (CmBattDebug & 4) + DbgPrint("CmBattPnpDispatch: Recieved two consecutive QUERY_REMOVE requests.\n"); + } + else + { + /* Fail because there's still open handles */ + Status = STATUS_UNSUCCESSFUL; + } + + /* Release the lock and return */ + ExReleaseFastMutex(&DeviceExtension->FastMutex); + break; + + case IRP_MN_REMOVE_DEVICE: + if (CmBattDebug & 0x20) + DbgPrint("CmBattPnpDispatch: IRP_MN_REMOVE_DEVICE\n"); + + /* Call the remove code */ + Status = CmBattRemoveDevice(DeviceObject, Irp); + break; + + case IRP_MN_CANCEL_REMOVE_DEVICE: + if (CmBattDebug & 0x20) + DbgPrint("CmBattPnpDispatch: IRP_MN_CANCEL_REMOVE_DEVICE\n"); + + /* Lock the extension and get the handle count */ + ExAcquireFastMutex(&DeviceExtension->FastMutex); + if (DeviceExtension->HandleCount == -1) + { + /* A remove was in progress, set the handle count back to 0 */ + DeviceExtension->HandleCount = 0; + } + else if (CmBattDebug & 2) + { + /* Nop, but warn about it */ + DbgPrint("CmBattPnpDispatch: Received CANCEL_REMOVE when OpenCount == %x\n", + DeviceExtension->HandleCount); + } + + /* Return success in all cases, and release the lock */ + Status = STATUS_SUCCESS; + ExReleaseFastMutex(&DeviceExtension->FastMutex); + break; + + case IRP_MN_QUERY_STOP_DEVICE: + if (CmBattDebug & 0x20) + DbgPrint("CmBattPnpDispatch: IRP_MN_QUERY_STOP_DEVICE\n"); + + /* There's no real support for this */ + Status = STATUS_NOT_IMPLEMENTED; + break; + + case IRP_MN_CANCEL_STOP_DEVICE: + if (CmBattDebug & 0x20) + DbgPrint("CmBattPnpDispatch: IRP_MN_CANCEL_STOP_DEVICE\n"); + + /* There's no real support for this */ + Status = STATUS_NOT_IMPLEMENTED; + break; + + case IRP_MN_QUERY_CAPABILITIES: + + /* Initialize our wait event */ + KeInitializeEvent(&Event, SynchronizationEvent, 0); + + /* Set the completion routine */ + IoCopyCurrentIrpStackLocationToNext(Irp); + IoSetCompletionRoutine(Irp, + (PVOID)CmBattIoCompletion, + &Event, + TRUE, + TRUE, + TRUE); + + /* Now call ACPI */ + Status = IoCallDriver(DeviceObject, Irp); + if (Status == STATUS_PENDING) + { + /* Wait for completion */ + KeWaitForSingleObject(&Event, + Executive, + KernelMode, + FALSE, + NULL); + Status = Irp->IoStatus.Status; + } + + /* Get the wake power state */ + DeviceExtension->PowerState.SystemState = IoStackLocation->Parameters.DeviceCapabilities.Capabilities->SystemWake; + if (CmBattDebug & 0x20) + DbgPrint("CmBattPnpDispatch: IRP_MN_QUERY_CAPABILITIES %d Capabilities->SystemWake = %x\n", + DeviceExtension->FdoType, + DeviceExtension->PowerState); + + /* Check if it's invalid */ + if (DeviceExtension->PowerState.SystemState == PowerSystemUnspecified) + { + /* Wait wake is not supported in this scenario */ + DeviceExtension->WaitWakeEnable = FALSE; + if (CmBattDebug & 0x20) + DbgPrint("CmBattPnpDispatch: IRP_MN_QUERY_CAPABILITIES Wake not supported.\n"); + } + else if (!(DeviceExtension->PowerIrp) && + (DeviceExtension->WaitWakeEnable)) + { + /* If it was requested in the registry, request the power IRP for it */ + PoRequestPowerIrp(DeviceExtension->DeviceObject, + 0, + DeviceExtension->PowerState, + CmBattWaitWakeLoop, + 0, + &DeviceExtension->PowerIrp); + if (CmBattDebug & 0x20) + DbgPrint("CmBattPnpDispatch: IRP_MN_QUERY_CAPABILITIES wait/Wake irp sent.\n"); + } + + /* Release the remove lock and complete the request */ + IofCompleteRequest(Irp, IO_NO_INCREMENT); + IoReleaseRemoveLock(&DeviceExtension->RemoveLock, Irp); + return Status; + + default: + /* Unsupported */ + if (CmBattDebug & 0x20) + DbgPrint("CmBattPnpDispatch: Unimplemented minor %0x\n", + IoStackLocation->MinorFunction); + break; + } + + /* Release the remove lock */ + IoReleaseRemoveLock(&DeviceExtension->RemoveLock, Irp); + + /* Set IRP status if we have one */ + if (Status != STATUS_NOT_SUPPORTED) Irp->IoStatus.Status = Status; + + /* Did someone pick it up? */ + if ((NT_SUCCESS(Status)) || (Status == STATUS_NOT_SUPPORTED)) + { + /* Still unsupported, try ACPI */ + IoSkipCurrentIrpStackLocation(Irp); + Status = IoCallDriver(DeviceExtension->AttachedDevice, Irp); + } + else + { + /* Complete the request */ + Status = Irp->IoStatus.Status; + IofCompleteRequest(Irp, IO_NO_INCREMENT); + } + + /* Release the remove lock and return status */ + return Status; +} + +NTSTATUS +NTAPI +CmBattCreateFdo(IN PDRIVER_OBJECT DriverObject, + IN PDEVICE_OBJECT DeviceObject, + IN ULONG DeviceExtensionSize, + IN PDEVICE_OBJECT *NewDeviceObject) +{ + PDEVICE_OBJECT FdoDeviceObject; + HANDLE KeyHandle; + PCMBATT_DEVICE_EXTENSION FdoExtension; + UCHAR Buffer[sizeof(KEY_VALUE_PARTIAL_INFORMATION) + sizeof(ULONG)]; + PKEY_VALUE_PARTIAL_INFORMATION PartialInfo = (PVOID)Buffer; + NTSTATUS Status; + UNICODE_STRING KeyString; + ULONG UniqueId; + ULONG ResultLength; + PAGED_CODE(); + if (CmBattDebug & 0x220) DbgPrint("CmBattCreateFdo: Entered\n"); + + /* Get unique ID */ + Status = CmBattGetUniqueId(DeviceObject, &UniqueId); + if (!NT_SUCCESS(Status)) + { + /* Assume 0 */ + UniqueId = 0; + if (CmBattDebug & 2) + DbgPrint("CmBattCreateFdo: Error %x from _UID, assuming unit #0\n", Status); + } + + /* Create the FDO */ + Status = IoCreateDevice(DriverObject, + DeviceExtensionSize, + 0, + FILE_DEVICE_BATTERY, + FILE_DEVICE_SECURE_OPEN, + 0, + &FdoDeviceObject); + if (!NT_SUCCESS(Status)) + { + /* Fail */ + if (CmBattDebug & 0xC) + DbgPrint("CmBattCreateFdo: error (0x%x) creating device object\n", Status); + return Status; + } + + /* Set FDO flags */ + FdoDeviceObject->Flags |= DO_BUFFERED_IO; + FdoDeviceObject->Flags |= DO_MAP_IO_BUFFER; + FdoDeviceObject->Flags &= ~DO_DEVICE_INITIALIZING; + + /* Initialize the extension */ + FdoExtension = FdoDeviceObject->DeviceExtension; + RtlZeroMemory(FdoExtension, DeviceExtensionSize); + FdoExtension->DeviceObject = FdoDeviceObject; + FdoExtension->FdoDeviceObject = FdoDeviceObject; + FdoExtension->PdoDeviceObject = DeviceObject; + + /* Attach to ACPI */ + FdoExtension->AttachedDevice = IoAttachDeviceToDeviceStack(FdoDeviceObject, + DeviceObject); + if (!FdoExtension->AttachedDevice) + { + /* Destroy and fail */ + CmBattDestroyFdo(FdoExtension->FdoDeviceObject); + if (CmBattDebug & 0xC) + DbgPrint("CmBattCreateFdo: IoAttachDeviceToDeviceStack failed.\n"); + return STATUS_UNSUCCESSFUL; + } + + /* Get ACPI interface for EVAL */ + Status = CmBattGetAcpiInterfaces(FdoExtension->AttachedDevice, + &FdoExtension->AcpiInterface); + if (!FdoExtension->AttachedDevice) + { + /* Detach, destroy, and fail */ + IoDetachDevice(FdoExtension->AttachedDevice); + CmBattDestroyFdo(FdoExtension->FdoDeviceObject); + if (CmBattDebug & 0xC) + DbgPrint("CmBattCreateFdo: Could not get ACPI interfaces: %x\n", Status); + return STATUS_UNSUCCESSFUL; + } + + /* Setup the rest of the extension */ + ExInitializeFastMutex(&FdoExtension->FastMutex); + IoInitializeRemoveLock(&FdoExtension->RemoveLock, 0, 0, 0); + FdoExtension->HandleCount = 0; + FdoExtension->WaitWakeEnable = FALSE; + FdoExtension->DeviceId = UniqueId; + FdoExtension->DeviceName = NULL; + FdoExtension->DelayNotification = FALSE; + FdoExtension->ArFlag = 0; + + /* Open the device key */ + Status = IoOpenDeviceRegistryKey(DeviceObject, + PLUGPLAY_REGKEY_DEVICE, + KEY_READ, + &KeyHandle); + if (NT_SUCCESS(Status)) + { + /* Read wait wake value */ + RtlInitUnicodeString(&KeyString, L"WaitWakeEnabled"); + Status = ZwQueryValueKey(KeyHandle, + &KeyString, + KeyValuePartialInformation, + PartialInfo, + sizeof(Buffer), + &ResultLength); + if (NT_SUCCESS(Status)) + { + /* Set value */ + FdoExtension->WaitWakeEnable = *(PULONG)PartialInfo->Data; + } + + /* Close the handle */ + ZwClose(KeyHandle); + } + + /* Return success and the new FDO */ + *NewDeviceObject = FdoDeviceObject; + if (CmBattDebug & 0x220) + DbgPrint("CmBattCreateFdo: Created FDO %x\n", FdoDeviceObject); + return STATUS_SUCCESS; +} + +NTSTATUS +NTAPI +CmBattAddBattery(IN PDRIVER_OBJECT DriverObject, + IN PDEVICE_OBJECT DeviceObject) +{ + BATTERY_MINIPORT_INFO MiniportInfo; + NTSTATUS Status; + PDEVICE_OBJECT FdoDeviceObject; + PCMBATT_DEVICE_EXTENSION FdoExtension; + PAGED_CODE(); + if (CmBattDebug & 0x220) + DbgPrint("CmBattAddBattery: pdo %x\n", DeviceObject); + + /* Create the FDO */ + Status = CmBattCreateFdo(DriverObject, + DeviceObject, + sizeof(CMBATT_DEVICE_EXTENSION), + &FdoDeviceObject); + if (!NT_SUCCESS(Status)) + { + if (CmBattDebug & 0xC) + DbgPrint("CmBattAddBattery: error (0x%x) creating Fdo\n", Status); + return Status; + } + + /* Build the FDO extensio, check if we support trip points */ + FdoExtension = FdoDeviceObject->DeviceExtension; + FdoExtension->FdoType = CmBattBattery; + FdoExtension->Started = 0; + FdoExtension->NotifySent = TRUE; + InterlockedExchange(&FdoExtension->ArLockValue, 0); + FdoExtension->TripPointValue = BATTERY_UNKNOWN_CAPACITY; + FdoExtension->Tag = 0; + FdoExtension->InterruptTime = KeQueryInterruptTime(); + FdoExtension->TripPointSet = CmBattSetTripPpoint(FdoExtension, 0) != + STATUS_OBJECT_NAME_NOT_FOUND; + + /* Setup the battery miniport information structure */ + RtlZeroMemory(&MiniportInfo, sizeof(MiniportInfo)); + MiniportInfo.Pdo = DeviceObject; + MiniportInfo.MajorVersion = BATTERY_CLASS_MAJOR_VERSION; + MiniportInfo.MinorVersion = BATTERY_CLASS_MINOR_VERSION; + MiniportInfo.Context = FdoExtension; + MiniportInfo.QueryTag = (PVOID)CmBattQueryTag; + MiniportInfo.QueryInformation = (PVOID)CmBattQueryInformation; + MiniportInfo.SetInformation = NULL; + MiniportInfo.QueryStatus = (PVOID)CmBattQueryStatus; + MiniportInfo.SetStatusNotify = (PVOID)CmBattSetStatusNotify; + MiniportInfo.DisableStatusNotify = (PVOID)CmBattDisableStatusNotify; + MiniportInfo.DeviceName = FdoExtension->DeviceName; + + /* Register with the class driver */ + Status = BatteryClassInitializeDevice(&MiniportInfo, &FdoExtension->ClassData); + if (!NT_SUCCESS(Status)) + { + IoDetachDevice(FdoExtension->AttachedDevice); + CmBattDestroyFdo(FdoExtension->FdoDeviceObject); + if (CmBattDebug & 0xC) + DbgPrint("CmBattAddBattery: error (0x%x) registering with class\n", Status); + return Status; + } + + /* Register WMI */ + Status = CmBattWmiRegistration(FdoExtension); + if (!NT_SUCCESS(Status)) + { + if (CmBattDebug & 0xC) + DbgPrint("CmBattAddBattery: Could not register as a WMI provider, status = %Lx\n", Status); + return Status; + } + + /* Register ACPI */ + Status = FdoExtension->AcpiInterface.RegisterForDeviceNotifications(FdoExtension->AcpiInterface.Context, + (PVOID)CmBattNotifyHandler, + FdoExtension); + if (!NT_SUCCESS(Status)) + { + CmBattWmiDeRegistration(FdoExtension); + BatteryClassUnload(FdoExtension->ClassData); + IoDetachDevice(FdoExtension->AttachedDevice); + CmBattDestroyFdo(FdoExtension->FdoDeviceObject); + if (CmBattDebug & 0xC) + DbgPrint("CmBattAddBattery: Could not register for battery notify, status = %Lx\n", Status); + } + + /* Return status */ + return Status; +} + +NTSTATUS +NTAPI +CmBattAddAcAdapter(IN PDRIVER_OBJECT DriverObject, + IN PDEVICE_OBJECT PdoDeviceObject) +{ + PDEVICE_OBJECT FdoDeviceObject; + NTSTATUS Status; + PCMBATT_DEVICE_EXTENSION DeviceExtension; + PAGED_CODE(); + if (CmBattDebug & 0x220) + DbgPrint("CmBattAddAcAdapter: pdo %x\n", PdoDeviceObject); + + /* Check if we already have an AC adapter */ + if (AcAdapterPdo) + { + /* Don't do anything */ + if (CmBattDebug & 0xC) + DbgPrint("CmBatt: Second AC adapter found. Current version of driver only supports 1 aadapter.\n"); + } + else + { + /* Set this as the AC adapter's PDO */ + AcAdapterPdo = PdoDeviceObject; + } + + /* Create the FDO for the adapter */ + Status = CmBattCreateFdo(DriverObject, + PdoDeviceObject, + sizeof(CMBATT_DEVICE_EXTENSION), + &FdoDeviceObject); + if (!NT_SUCCESS(Status)) + { + /* Fail */ + if (CmBattDebug & 0xC) + DbgPrint("CmBattAddAcAdapter: error (0x%x) creating Fdo\n", Status); + return Status; + } + + /* Set the type and do WMI registration */ + DeviceExtension = FdoDeviceObject->DeviceExtension; + DeviceExtension->FdoType = CmBattAcAdapter; + Status = CmBattWmiRegistration(DeviceExtension); + if (!NT_SUCCESS(Status)) + { + /* We can go on without WMI */ + if (CmBattDebug & 0xC) + DbgPrint("CmBattAddBattery: Could not register as a WMI provider, status = %Lx\n", Status); + } + + /* Register with ACPI */ + Status = DeviceExtension->AcpiInterface.RegisterForDeviceNotifications(DeviceExtension->AcpiInterface.Context, + (PVOID)CmBattNotifyHandler, + DeviceExtension); + if (!(NT_SUCCESS(Status)) && (CmBattDebug & 0xC)) + DbgPrint("CmBattAddAcAdapter: Could not register for power notify, status = %Lx\n", Status); + + /* Send the first manual notification */ + CmBattNotifyHandler(DeviceExtension, ACPI_BATT_NOTIFY_STATUS); + return STATUS_SUCCESS; +} + +NTSTATUS +NTAPI +CmBattAddDevice(IN PDRIVER_OBJECT DriverObject, + IN PDEVICE_OBJECT PdoDeviceObject) +{ + NTSTATUS Status; + HANDLE KeyHandle; + ULONG ResultLength; + UNICODE_STRING KeyString; + UCHAR Buffer[sizeof(KEY_VALUE_PARTIAL_INFORMATION) + sizeof(ULONG)]; + PKEY_VALUE_PARTIAL_INFORMATION PartialInfo = (PVOID)Buffer; + ULONG PowerSourceType; + PAGED_CODE(); + if (CmBattDebug & 0x220) + DbgPrint("CmBattAddDevice: Entered with pdo %x\n", PdoDeviceObject); + + /* Make sure we have a PDO */ + if (!PdoDeviceObject) + { + /* Should not be having as one */ + if (CmBattDebug & 0x24) DbgPrint("CmBattAddDevice: Asked to do detection\n"); + return STATUS_NO_MORE_ENTRIES; + } + + /* Open the driver key */ + Status = IoOpenDeviceRegistryKey(PdoDeviceObject, + PLUGPLAY_REGKEY_DRIVER, + KEY_READ, + &KeyHandle); + if (!NT_SUCCESS(Status)) + { + if (CmBattDebug & 0xC) + DbgPrint("CmBattAddDevice: Could not get the software branch: %x\n", Status); + return Status; + } + + /* Read the power source type */ + RtlInitUnicodeString(&KeyString, L"PowerSourceType"); + Status = ZwQueryValueKey(KeyHandle, + &KeyString, + KeyValuePartialInformation, + PartialInfo, + sizeof(Buffer), + &ResultLength); + ZwClose(KeyHandle); + if (!NT_SUCCESS(Status)) + { + /* We need the data, fail without it */ + if (CmBattDebug & 0xC) + DbgPrint("CmBattAddDevice: Could not read the power type identifier: %x\n", Status); + return Status; + } + + /* Check what kind of power source this is */ + PowerSourceType = *(PULONG)PartialInfo->Data; + if (PowerSourceType == 1) + { + /* Create an AC adapter */ + Status = CmBattAddAcAdapter(DriverObject, PdoDeviceObject); + } + else if (PowerSourceType == 0) + { + /* Create a battery */ + Status = CmBattAddBattery(DriverObject, PdoDeviceObject); + } + else + { + /* Unknown type, fail */ + if (CmBattDebug & 0xC) + DbgPrint("CmBattAddDevice: Invalid POWER_SOURCE_TYPE == %d \n", PowerSourceType); + return STATUS_UNSUCCESSFUL; + } + + /* Return whatever the FDO creation routine did */ + return Status; +} + +/* EOF */ diff --git a/reactos/drivers/bus/acpi/cmbatt/cmbwmi.c b/reactos/drivers/bus/acpi/cmbatt/cmbwmi.c new file mode 100644 index 00000000000..1274f04280b --- /dev/null +++ b/reactos/drivers/bus/acpi/cmbatt/cmbwmi.c @@ -0,0 +1,221 @@ +/* + * PROJECT: ReactOS ACPI-Compliant Control Method Battery + * LICENSE: BSD - See COPYING.ARM in the top level directory + * FILE: boot/drivers/bus/acpi/cmbatt/cmbwmi.c + * PURPOSE: WMI Interface + * PROGRAMMERS: ReactOS Portable Systems Group + */ + +/* INCLUDES *******************************************************************/ + +#include "cmbatt.h" + +/* GLOBALS ********************************************************************/ + +WMIGUIDREGINFO CmBattWmiGuidList[1] = +{ + {&GUID_POWER_DEVICE_WAKE_ENABLE, 1, 0} +}; + +/* FUNCTIONS ******************************************************************/ + +PCHAR +NTAPI +WMIMinorFunctionString(IN UCHAR MinorFunction) +{ + switch (MinorFunction) + { + case IRP_MN_CHANGE_SINGLE_INSTANCE: + return "IRP_MN_CHANGE_SINGLE_INSTANCE"; + case IRP_MN_CHANGE_SINGLE_ITEM: + return "IRP_MN_CHANGE_SINGLE_ITEM"; + case IRP_MN_DISABLE_COLLECTION: + return "IRP_MN_DISABLE_COLLECTION"; + case IRP_MN_DISABLE_EVENTS: + return "IRP_MN_DISABLE_EVENTS"; + case IRP_MN_ENABLE_COLLECTION: + return "IRP_MN_ENABLE_COLLECTION"; + case IRP_MN_ENABLE_EVENTS: + return "IRP_MN_ENABLE_EVENTS"; + case IRP_MN_EXECUTE_METHOD: + return "IRP_MN_EXECUTE_METHOD"; + case IRP_MN_QUERY_ALL_DATA: + return "IRP_MN_QUERY_ALL_DATA"; + case IRP_MN_QUERY_SINGLE_INSTANCE: + return "IRP_MN_QUERY_SINGLE_INSTANCE"; + case IRP_MN_REGINFO: + return "IRP_MN_REGINFO"; + default: + return "IRP_MN_?????"; + } +} + +NTSTATUS +NTAPI +CmBattQueryWmiRegInfo(PDEVICE_OBJECT DeviceObject, + PULONG RegFlags, + PUNICODE_STRING InstanceName, + PUNICODE_STRING *RegistryPath, + PUNICODE_STRING MofResourceName, + PDEVICE_OBJECT *Pdo) +{ + UNIMPLEMENTED; + return STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS +NTAPI +CmBattQueryWmiDataBlock(PDEVICE_OBJECT DeviceObject, + PIRP Irp, + ULONG GuidIndex, + ULONG InstanceIndex, + ULONG InstanceCount, + PULONG InstanceLengthArray, + ULONG BufferAvail, + PUCHAR Buffer) +{ + UNIMPLEMENTED; + return STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS +NTAPI +CmBattSetWmiDataBlock(PDEVICE_OBJECT DeviceObject, + PIRP Irp, + ULONG GuidIndex, + ULONG InstanceIndex, + ULONG BufferSize, + PUCHAR Buffer) +{ + UNIMPLEMENTED; + return STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS +NTAPI +CmBattSetWmiDataItem(PDEVICE_OBJECT DeviceObject, + PIRP Irp, + ULONG GuidIndex, + ULONG InstanceIndex, + ULONG DataItemId, + ULONG BufferSize, + PUCHAR Buffer) +{ + UNIMPLEMENTED; + return STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS +NTAPI +CmBattWmiDeRegistration(IN PCMBATT_DEVICE_EXTENSION DeviceExtension) +{ + PAGED_CODE(); + + /* De-register */ + return IoWMIRegistrationControl(DeviceExtension->FdoDeviceObject, + WMIREG_ACTION_DEREGISTER); +} + +NTSTATUS +NTAPI +CmBattWmiRegistration(IN PCMBATT_DEVICE_EXTENSION DeviceExtension) +{ + PAGED_CODE(); + + /* GUID information */ + DeviceExtension->WmiLibInfo.GuidCount = sizeof(CmBattWmiGuidList) / + sizeof(WMIGUIDREGINFO); + DeviceExtension->WmiLibInfo.GuidList = CmBattWmiGuidList; + + /* Callbacks */ + DeviceExtension->WmiLibInfo.QueryWmiRegInfo = CmBattQueryWmiRegInfo; + DeviceExtension->WmiLibInfo.QueryWmiDataBlock = CmBattQueryWmiDataBlock; + DeviceExtension->WmiLibInfo.SetWmiDataBlock = CmBattSetWmiDataBlock; + DeviceExtension->WmiLibInfo.SetWmiDataItem = CmBattSetWmiDataItem; + DeviceExtension->WmiLibInfo.ExecuteWmiMethod = NULL; + DeviceExtension->WmiLibInfo.WmiFunctionControl = NULL; + + /* Register */ + return IoWMIRegistrationControl(DeviceExtension->FdoDeviceObject, + WMIREG_ACTION_REGISTER); +} + +NTSTATUS +NTAPI +CmBattSystemControl(IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp) +{ + NTSTATUS Status; + PCMBATT_DEVICE_EXTENSION DeviceExtension; + PWMILIB_CONTEXT WmiLibContext; + SYSCTL_IRP_DISPOSITION Disposition = IrpForward; + PAGED_CODE(); + if (CmBattDebug & 2) + DbgPrint("CmBatt: SystemControl: %s\n", + WMIMinorFunctionString(IoGetCurrentIrpStackLocation(Irp)->MinorFunction)); + + /* Acquire the remove lock */ + DeviceExtension = DeviceObject->DeviceExtension; + Status = IoAcquireRemoveLock(&DeviceExtension->RemoveLock, 0); + if (!NT_SUCCESS(Status)) + { + /* It's too late, fail */ + Irp->IoStatus.Status = STATUS_DEVICE_REMOVED; + IofCompleteRequest(Irp, IO_NO_INCREMENT); + return STATUS_DEVICE_REMOVED; + } + + /* What kind of device is this? */ + WmiLibContext = &DeviceExtension->WmiLibInfo; + if (DeviceExtension->FdoType == CmBattBattery) + { + /* For batteries, let the class driver handle it */ + Status = BatteryClassSystemControl(DeviceExtension->ClassData, + WmiLibContext, + DeviceObject, + Irp, + &Disposition); + } + else + { + /* Otherwise, call the wmi library directly */ + Status = WmiSystemControl(WmiLibContext, + DeviceObject, + Irp, + &Disposition); + } + + /* Check what happened */ + switch (Disposition) + { + case IrpNotCompleted: + + /* Complete it here */ + if (CmBattDebug & 2) DbgPrint("CmBatt: SystemControl: Irp Not Completed.\n"); + IofCompleteRequest(Irp, IO_NO_INCREMENT); + break; + + case IrpForward: + + /* Forward it to ACPI */ + if (CmBattDebug & 2) DbgPrint("CmBatt: SystemControl: Irp Forward.\n"); + IoSkipCurrentIrpStackLocation(Irp); + Status = IoCallDriver(DeviceExtension->AttachedDevice, Irp); + break; + + case IrpProcessed: + + /* Nothing to do */ + if (CmBattDebug & 2) DbgPrint("CmBatt: SystemControl: Irp Processed.\n"); + break; + + default: + ASSERT(FALSE); + } + + /* Release the lock and return */ + IoReleaseRemoveLock(&DeviceExtension->RemoveLock, 0); + return Status; +} + +/* EOF */ diff --git a/reactos/drivers/bus/acpi/cmbatt/cmexec.c b/reactos/drivers/bus/acpi/cmbatt/cmexec.c new file mode 100644 index 00000000000..7fb4ea591bf --- /dev/null +++ b/reactos/drivers/bus/acpi/cmbatt/cmexec.c @@ -0,0 +1,205 @@ +/* + * PROJECT: ReactOS ACPI-Compliant Control Method Battery + * LICENSE: BSD - See COPYING.ARM in the top level directory + * FILE: boot/drivers/bus/acpi/cmbatt/cmexec.c + * PURPOSE: ACPI Method Execution/Evaluation Glue + * PROGRAMMERS: ReactOS Portable Systems Group + */ + +/* INCLUDES *******************************************************************/ + +#include "cmbatt.h" +#include "ntstatus.h" + +/* FUNCTIONS ******************************************************************/ + +NTSTATUS +NTAPI +GetDwordElement(IN PACPI_METHOD_ARGUMENT Argument, + OUT PULONG Value) +{ + NTSTATUS Status; + + /* Must have an integer */ + if (Argument->Type != ACPI_METHOD_ARGUMENT_INTEGER) + { + /* Not an integer, fail */ + Status = STATUS_ACPI_INVALID_DATA; + if (CmBattDebug & 0x4C) + DbgPrint("GetDwordElement: Object contained wrong data type - %d\n", + Argument->Type); + } + else + { + /* Read the integer value */ + *Value = Argument->Argument; + Status = STATUS_SUCCESS; + } + + /* Return status */ + return Status; +} + +NTSTATUS +NTAPI +GetStringElement(IN PACPI_METHOD_ARGUMENT Argument, + OUT PCHAR Value) +{ + NTSTATUS Status; + + /* Must have a string of buffer */ + if ((Argument->Type == ACPI_METHOD_ARGUMENT_STRING) || + (Argument->Type == ACPI_METHOD_ARGUMENT_BUFFER)) + { + /* String must be less than 256 characters */ + if (Argument->DataLength < 256) + { + /* Copy the buffer */ + RtlCopyMemory(Value, Argument->Data, Argument->DataLength); + Status = STATUS_SUCCESS; + } + else + { + /* The buffer is too small (the string is too large) */ + Status = STATUS_BUFFER_TOO_SMALL; + if (CmBattDebug & 0x4C) + DbgPrint("GetStringElement: return buffer not big enough - %d\n", Argument->DataLength); + } + } + else + { + /* Not valid string data */ + Status = STATUS_ACPI_INVALID_DATA; + if (CmBattDebug & 0x4C) + DbgPrint("GetStringElement: Object contained wrong data type - %d\n", Argument->Type); + } + + /* Return the status */ + return Status; +} + +NTSTATUS +NTAPI +CmBattGetPsrData(PDEVICE_OBJECT DeviceObject, + PULONG PsrData) +{ + UNIMPLEMENTED; + return STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS +NTAPI +CmBattGetBifData(PCMBATT_DEVICE_EXTENSION DeviceExtension, + PACPI_BIF_DATA BifData) +{ + UNIMPLEMENTED; + return STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS +NTAPI +CmBattGetBstData(PCMBATT_DEVICE_EXTENSION DeviceExtension, + PACPI_BST_DATA BstData) +{ + UNIMPLEMENTED; + return STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS +NTAPI +CmBattGetStaData(PDEVICE_OBJECT DeviceObject, + PULONG StaData) +{ + UNIMPLEMENTED; + return STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS +NTAPI +CmBattGetUniqueId(PDEVICE_OBJECT DeviceObject, + PULONG UniqueId) +{ + UNIMPLEMENTED; + return STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS +NTAPI +CmBattSetTripPpoint(PCMBATT_DEVICE_EXTENSION DeviceExtension, + ULONG AlarmValue) +{ + UNIMPLEMENTED; + return STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS +NTAPI +CmBattSendDownStreamIrp(IN PDEVICE_OBJECT DeviceObject, + IN ULONG IoControlCode, + IN PVOID InputBuffer, + IN ULONG InputBufferLength, + IN PACPI_EVAL_OUTPUT_BUFFER OutputBuffer, + IN ULONG OutputBufferLength) +{ + PIRP Irp; + NTSTATUS Status; + KEVENT Event; + IO_STATUS_BLOCK IoStatusBlock; + PAGED_CODE(); + + /* Initialize our wait event */ + KeInitializeEvent(&Event, SynchronizationEvent, 0); + + /* Allocate the IRP */ + Irp = IoBuildDeviceIoControlRequest(IoControlCode, + DeviceObject, + InputBuffer, + InputBufferLength, + OutputBuffer, + OutputBufferLength, + 0, + &Event, + &IoStatusBlock); + if (!Irp) + { + /* No IRP, fail */ + if (CmBattDebug & 0x4C) + DbgPrint("CmBattSendDownStreamIrp: Failed to allocate Irp\n"); + return STATUS_INSUFFICIENT_RESOURCES; + } + + /* Call ACPI */ + if (CmBattDebug & 0x40) + DbgPrint("CmBattSendDownStreamIrp: Irp %x [Tid] %x\n", Irp, KeGetCurrentThread()); + Status = IoCallDriver(DeviceObject, Irp); + if (Status == STATUS_PENDING) + { + /* Wait for completion */ + KeWaitForSingleObject(&Event, + Executive, + KernelMode, + FALSE, + NULL); + Status = Irp->IoStatus.Status; + } + + /* Check if caller wanted output */ + if (OutputBuffer) + { + /* Make sure it's valid ACPI output buffer */ + if ((OutputBuffer->Signature != ACPI_EVAL_OUTPUT_BUFFER_SIGNATURE) || + !(OutputBuffer->Count)) + { + /* It isn't, so set failure code */ + Status = STATUS_ACPI_INVALID_DATA; + } + } + + /* Return status */ + if (CmBattDebug & 0x40) + DbgPrint("CmBattSendDownStreamIrp: Irp %x completed %x! [Tid] %x\n", + Irp, Status, KeGetCurrentThread()); + return Status; +} + +/* EOF */ diff --git a/reactos/drivers/bus/acpi/include/acpi_bus.h b/reactos/drivers/bus/acpi/include/acpi_bus.h new file mode 100644 index 00000000000..d5fe9efccc6 --- /dev/null +++ b/reactos/drivers/bus/acpi/include/acpi_bus.h @@ -0,0 +1,389 @@ +/* + * acpi_bus.h - ACPI Bus Driver ($Revision: 22 $) + * + * Copyright (C) 2001, 2002 Andy Grover + * Copyright (C) 2001, 2002 Paul Diefenbaugh + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + */ + +#ifndef __ACPI_BUS_H__ +#define __ACPI_BUS_H__ + +#include + +#include "list.h" + + +/* TBD: Make dynamic */ +#define ACPI_MAX_HANDLES 10 +struct acpi_handle_list { + UINT32 count; + ACPI_HANDLE handles[ACPI_MAX_HANDLES]; +}; + + +/* acpi_utils.h */ +ACPI_STATUS +acpi_extract_package ( + ACPI_OBJECT *package, + ACPI_BUFFER *format, + ACPI_BUFFER *buffer); +ACPI_STATUS +acpi_evaluate_integer ( + ACPI_HANDLE handle, + ACPI_STRING pathname, + struct acpi_object_list *arguments, + unsigned long long *data); +ACPI_STATUS +acpi_evaluate_reference ( + ACPI_HANDLE handle, + ACPI_STRING pathname, + struct acpi_object_list *arguments, + struct acpi_handle_list *list); + +enum acpi_bus_removal_type { + ACPI_BUS_REMOVAL_NORMAL = 0, + ACPI_BUS_REMOVAL_EJECT, + ACPI_BUS_REMOVAL_SUPRISE, + ACPI_BUS_REMOVAL_TYPE_COUNT +}; + +enum acpi_bus_device_type { + ACPI_BUS_TYPE_DEVICE = 0, + ACPI_BUS_TYPE_POWER, + ACPI_BUS_TYPE_PROCESSOR, + ACPI_BUS_TYPE_THERMAL, + ACPI_BUS_TYPE_SYSTEM, + ACPI_BUS_TYPE_POWER_BUTTON, + ACPI_BUS_TYPE_SLEEP_BUTTON, + ACPI_BUS_DEVICE_TYPE_COUNT +}; + +struct acpi_driver; +struct acpi_device; + + +/* + * ACPI Driver + * ----------- + */ + +typedef int (*acpi_op_add) (struct acpi_device *device); +typedef int (*acpi_op_remove) (struct acpi_device *device, int type); +typedef int (*acpi_op_start) (struct acpi_device *device); +typedef int (*acpi_op_suspend) (struct acpi_device *device, int state); +typedef int (*acpi_op_resume) (struct acpi_device *device, int state); +typedef int (*acpi_op_scan) (struct acpi_device *device); +typedef int (*acpi_op_bind) (struct acpi_device *device); +typedef int (*acpi_op_unbind) (struct acpi_device * device); +typedef void (*acpi_op_notify) (struct acpi_device * device, UINT32 event); + +struct acpi_bus_ops { + UINT32 acpi_op_add:1; + UINT32 acpi_op_start:1; +}; + +struct acpi_device_ops { + acpi_op_add add; + acpi_op_remove remove; + acpi_op_start start; + acpi_op_suspend suspend; + acpi_op_resume resume; + acpi_op_bind bind; + acpi_op_unbind unbind; + acpi_op_notify notify; + acpi_op_scan scan; +}; + +#define ACPI_DRIVER_ALL_NOTIFY_EVENTS 0x1 /* system AND device events */ + +struct acpi_driver { + struct list_head node; + char name[80]; + char class[80]; + int references; + unsigned int flags; + char *ids; /* Supported Hardware IDs */ + struct acpi_device_ops ops; +}; + +/* + * ACPI Device + * ----------- + */ + +/* Status (_STA) */ + +struct acpi_device_status { + UINT32 present:1; + UINT32 enabled:1; + UINT32 show_in_ui:1; + UINT32 functional:1; + UINT32 battery_present:1; + UINT32 reserved:27; +}; + + +/* Flags */ + +struct acpi_device_flags { + UINT32 dynamic_status:1; + UINT32 hardware_id:1; + UINT32 compatible_ids:1; + UINT32 bus_address:1; + UINT32 unique_id:1; + UINT32 removable:1; + UINT32 ejectable:1; + UINT32 lockable:1; + UINT32 suprise_removal_ok:1; + UINT32 power_manageable:1; + UINT32 performance_manageable:1; + UINT32 wake_capable:1; + UINT32 force_power_state:1; + UINT32 reserved:20; +}; + +/* Plug and Play */ + +typedef char acpi_bus_id[8]; +typedef unsigned long acpi_bus_address; +typedef char acpi_hardware_id[9]; +typedef char acpi_unique_id[9]; +typedef char acpi_device_name[40]; +typedef char acpi_device_class[20]; + +struct acpi_device_pnp { + acpi_bus_id bus_id; /* Object name */ + acpi_bus_address bus_address; /* _ADR */ + acpi_hardware_id hardware_id; /* _HID */ + ACPI_DEVICE_ID_LIST *cid_list; /* _CIDs */ + acpi_unique_id unique_id; /* _UID */ + acpi_device_name device_name; /* Driver-determined */ + acpi_device_class device_class; /* " */ +}; + +#define acpi_device_bid(d) ((d)->pnp.bus_id) +#define acpi_device_adr(d) ((d)->pnp.bus_address) +#define acpi_device_hid(d) ((d)->pnp.hardware_id) +#define acpi_device_uid(d) ((d)->pnp.unique_id) +#define acpi_device_name(d) ((d)->pnp.device_name) +#define acpi_device_class(d) ((d)->pnp.device_class) + + +/* Power Management */ + +struct acpi_device_power_flags { + UINT32 explicit_get:1; /* _PSC present? */ + UINT32 power_resources:1; /* Power resources */ + UINT32 inrush_current:1; /* Serialize Dx->D0 */ + UINT32 power_removed:1; /* Optimize Dx->D0 */ + UINT32 reserved:28; +}; + +struct acpi_device_power_state { + struct { + UINT8 valid:1; + UINT8 explicit_set:1; /* _PSx present? */ + UINT8 reserved:6; + } flags; + int power; /* % Power (compared to D0) */ + int latency; /* Dx->D0 time (microseconds) */ + struct acpi_handle_list resources; /* Power resources referenced */ +}; + +struct acpi_device_power { + int state; /* Current state */ + struct acpi_device_power_flags flags; + struct acpi_device_power_state states[4]; /* Power states (D0-D3) */ +}; + + +/* Performance Management */ + +struct acpi_device_perf_flags { + UINT8 reserved:8; +}; + +struct acpi_device_perf_state { + struct { + UINT8 valid:1; + UINT8 reserved:7; + } flags; + UINT8 power; /* % Power (compared to P0) */ + UINT8 performance; /* % Performance ( " ) */ + int latency; /* Px->P0 time (microseconds) */ +}; + +struct acpi_device_perf { + int state; + struct acpi_device_perf_flags flags; + int state_count; + struct acpi_device_perf_state *states; +}; + +/* Wakeup Management */ +struct acpi_device_wakeup_flags { + UINT8 valid:1; /* Can successfully enable wakeup? */ + UINT8 run_wake:1; /* Run-Wake GPE devices */ +}; + +struct acpi_device_wakeup_state { + UINT8 enabled:1; +}; + +struct acpi_device_wakeup { + ACPI_HANDLE gpe_device; + ACPI_INTEGER gpe_number; + ACPI_INTEGER sleep_state; + struct acpi_handle_list resources; + struct acpi_device_wakeup_state state; + struct acpi_device_wakeup_flags flags; + int prepare_count; +}; + + +/* Device */ + +struct acpi_device { + int device_type; + ACPI_HANDLE handle; + struct acpi_device *parent; + struct list_head children; + struct list_head node; + struct list_head wakeup_list; + struct acpi_device_status status; + struct acpi_device_flags flags; + struct acpi_device_pnp pnp; + struct acpi_device_power power; + struct acpi_device_wakeup wakeup; + struct acpi_device_perf performance; + struct acpi_device_ops ops; + struct acpi_driver *driver; + void *driver_data; + struct acpi_bus_ops bus_ops; /* workaround for different code path for hotplug */ + enum acpi_bus_removal_type removal_type; /* indicate for different removal type */ + +}; + +#define acpi_driver_data(d) ((d)->driver_data) + +#define to_acpi_device(d) container_of(d, struct acpi_device, dev) +#define to_acpi_driver(d) container_of(d, struct acpi_driver, drv) + +/* acpi_device.dev.bus == &acpi_bus_type */ +extern struct bus_type acpi_bus_type; + +/* + * Events + * ------ + */ + +struct acpi_bus_event { + struct list_head node; + acpi_device_class device_class; + acpi_bus_id bus_id; + UINT32 type; + UINT32 data; +}; + + +/* + * External Functions + */ +int acpi_bus_get_private_data(ACPI_HANDLE, void **); + +void acpi_bus_data_handler(ACPI_HANDLE handle, void *context); +ACPI_STATUS acpi_bus_get_status_handle(ACPI_HANDLE handle, + unsigned long long *sta); +int acpi_bus_get_status(struct acpi_device *device); +int acpi_bus_get_power(ACPI_HANDLE handle, int *state); +int acpi_bus_set_power(ACPI_HANDLE handle, int state); +BOOLEAN acpi_bus_power_manageable(ACPI_HANDLE handle); +BOOLEAN acpi_bus_can_wakeup(ACPI_HANDLE handle); +int acpi_bus_generate_proc_event(struct acpi_device *device, UINT8 type, int data); +int acpi_bus_generate_event(struct acpi_device *device, UINT8 type, int data); +int acpi_bus_receive_event(struct acpi_bus_event *event); +int acpi_bus_register_driver(struct acpi_driver *driver); +void acpi_bus_unregister_driver(struct acpi_driver *driver); +int acpi_bus_add(struct acpi_device **child, struct acpi_device *parent, + ACPI_HANDLE handle, int type); +int acpi_bus_trim(struct acpi_device *start, int rmdevice); +int acpi_bus_start(struct acpi_device *device); +ACPI_STATUS acpi_bus_get_ejd(ACPI_HANDLE handle, ACPI_HANDLE * ejd); +int acpi_match_device_ids(struct acpi_device *device, + const struct acpi_device_id *ids); +int acpi_bus_get_device(ACPI_HANDLE handle, struct acpi_device **device); +int acpi_init(void); +ACPI_STATUS acpi_suspend (UINT32 state); + +/* + * Bind physical devices with ACPI devices + */ +//struct acpi_bus_type { +// struct list_head list; +// struct bus_type *bus; +// /* For general devices under the bus */ +// int (*find_device) (struct device *, ACPI_HANDLE *); +// /* For bridges, such as PCI root bridge, IDE controller */ +// int (*find_bridge) (struct device *, ACPI_HANDLE *); +//}; +//int register_acpi_bus_type(struct acpi_bus_type *); +//int unregister_acpi_bus_type(struct acpi_bus_type *); +//struct device *acpi_get_physical_device(ACPI_HANDLE); + +struct acpi_pci_root { + struct list_head node; + struct acpi_device * device; + struct acpi_pci_id id; + struct pci_bus *bus; + UINT16 segment; + UINT8 bus_nr; + + UINT32 osc_support_set; /* _OSC state of support bits */ + UINT32 osc_control_set; /* _OSC state of control bits */ + UINT32 osc_control_qry; /* the latest _OSC query result */ + + UINT32 osc_queried:1; /* has _OSC control been queried? */ +}; + +//static inline int acpi_pm_device_sleep_state(struct device *d, int *p) +//{ +// if (p) +// *p = ACPI_STATE_D0; +// return ACPI_STATE_D3; +//} +//static inline int acpi_pm_device_sleep_wake(struct device *dev, bool enable) +//{ +// return -1; +//} + +/* system defines: move to bigger header */ +extern enum acpi_irq_model_id acpi_irq_model; + +enum acpi_irq_model_id { + ACPI_IRQ_MODEL_PIC = 0, + ACPI_IRQ_MODEL_IOAPIC, + ACPI_IRQ_MODEL_IOSAPIC, + ACPI_IRQ_MODEL_COUNT +}; + + + +#endif /*__ACPI_BUS_H__*/ diff --git a/reactos/drivers/bus/acpi/include/acpi_drivers.h b/reactos/drivers/bus/acpi/include/acpi_drivers.h new file mode 100644 index 00000000000..6506e44882b --- /dev/null +++ b/reactos/drivers/bus/acpi/include/acpi_drivers.h @@ -0,0 +1,340 @@ +/* + * acpi_drivers.h ($Revision: 32 $) + * + * Copyright (C) 2001, 2002 Andy Grover + * Copyright (C) 2001, 2002 Paul Diefenbaugh + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + */ + +#ifndef __ACPI_DRIVERS_H__ +#define __ACPI_DRIVERS_H__ + +#define ACPI_MAX_STRING 80 + + +/* -------------------------------------------------------------------------- + ACPI Bus + -------------------------------------------------------------------------- */ + +#define ACPI_BUS_COMPONENT 0x00010000 +#define ACPI_BUS_CLASS "system_bus" +#define ACPI_BUS_HID "ACPI_BUS" +#define ACPI_BUS_DRIVER_NAME "ACPI Bus Driver" +#define ACPI_BUS_DEVICE_NAME "System Bus" + + +/* -------------------------------------------------------------------------- + AC Adapter + -------------------------------------------------------------------------- */ + +#define ACPI_AC_COMPONENT 0x00020000 +#define ACPI_AC_CLASS "ac_adapter" +#define ACPI_AC_HID "ACPI0003" +#define ACPI_AC_DRIVER_NAME "ACPI AC Adapter Driver" +#define ACPI_AC_DEVICE_NAME "AC Adapter" +#define ACPI_AC_FILE_STATE "state" +#define ACPI_AC_NOTIFY_STATUS 0x80 +#define ACPI_AC_STATUS_OFFLINE 0x00 +#define ACPI_AC_STATUS_ONLINE 0x01 +#define ACPI_AC_STATUS_UNKNOWN 0xFF + + +/* -------------------------------------------------------------------------- + Battery + -------------------------------------------------------------------------- */ + +#define ACPI_BATTERY_COMPONENT 0x00040000 +#define ACPI_BATTERY_CLASS "battery" +#define ACPI_BATTERY_HID "PNP0C0A" +#define ACPI_BATTERY_DRIVER_NAME "ACPI Battery Driver" +#define ACPI_BATTERY_DEVICE_NAME "Battery" +#define ACPI_BATTERY_FILE_INFO "info" +#define ACPI_BATTERY_FILE_STATUS "state" +#define ACPI_BATTERY_FILE_ALARM "alarm" +#define ACPI_BATTERY_NOTIFY_STATUS 0x80 +#define ACPI_BATTERY_NOTIFY_INFO 0x81 +#define ACPI_BATTERY_UNITS_WATTS "mW" +#define ACPI_BATTERY_UNITS_AMPS "mA" + + +/* -------------------------------------------------------------------------- + Button + -------------------------------------------------------------------------- */ + +#define ACPI_BUTTON_COMPONENT 0x00080000 +#define ACPI_BUTTON_DRIVER_NAME "ACPI Button Driver" +#define ACPI_BUTTON_CLASS "button" +#define ACPI_BUTTON_FILE_INFO "info" +#define ACPI_BUTTON_FILE_STATE "state" +#define ACPI_BUTTON_TYPE_UNKNOWN 0x00 +#define ACPI_BUTTON_NOTIFY_STATUS 0x80 + +#define ACPI_BUTTON_SUBCLASS_POWER "power" +#define ACPI_BUTTON_HID_POWER "PNP0C0C" +#define ACPI_BUTTON_HID_POWERF "ACPI_FPB" +#define ACPI_BUTTON_DEVICE_NAME_POWER "Power Button (CM)" +#define ACPI_BUTTON_DEVICE_NAME_POWERF "Power Button (FF)" +#define ACPI_BUTTON_TYPE_POWER 0x01 +#define ACPI_BUTTON_TYPE_POWERF 0x02 + +#define ACPI_BUTTON_SUBCLASS_SLEEP "sleep" +#define ACPI_BUTTON_HID_SLEEP "PNP0C0E" +#define ACPI_BUTTON_HID_SLEEPF "ACPI_FSB" +#define ACPI_BUTTON_DEVICE_NAME_SLEEP "Sleep Button (CM)" +#define ACPI_BUTTON_DEVICE_NAME_SLEEPF "Sleep Button (FF)" +#define ACPI_BUTTON_TYPE_SLEEP 0x03 +#define ACPI_BUTTON_TYPE_SLEEPF 0x04 + +#define ACPI_BUTTON_SUBCLASS_LID "lid" +#define ACPI_BUTTON_HID_LID "PNP0C0D" +#define ACPI_BUTTON_DEVICE_NAME_LID "Lid Switch" +#define ACPI_BUTTON_TYPE_LID 0x05 + +int acpi_button_init (void); +void acpi_button_exit (void); + +/* -------------------------------------------------------------------------- + Embedded Controller + -------------------------------------------------------------------------- */ + +#define ACPI_EC_COMPONENT 0x00100000 +#define ACPI_EC_CLASS "embedded_controller" +#define ACPI_EC_HID "PNP0C09" +#define ACPI_EC_DRIVER_NAME "ACPI Embedded Controller Driver" +#define ACPI_EC_DEVICE_NAME "Embedded Controller" +#define ACPI_EC_FILE_INFO "info" + +#ifdef CONFIG_ACPI_EC + +int acpi_ec_ecdt_probe (void); +int acpi_ec_init (void); +void acpi_ec_exit (void); + +#endif + + +/* -------------------------------------------------------------------------- + Fan + -------------------------------------------------------------------------- */ + +#define ACPI_FAN_COMPONENT 0x00200000 +#define ACPI_FAN_CLASS "fan" +#define ACPI_FAN_HID "PNP0C0B" +#define ACPI_FAN_DRIVER_NAME "ACPI Fan Driver" +#define ACPI_FAN_DEVICE_NAME "Fan" +#define ACPI_FAN_FILE_STATE "state" +#define ACPI_FAN_NOTIFY_STATUS 0x80 + + +/* -------------------------------------------------------------------------- + PCI + -------------------------------------------------------------------------- */ + +#ifdef CONFIG_ACPI_PCI + +#define ACPI_PCI_COMPONENT 0x00400000 + +/* ACPI PCI Root Bridge (pci_root.c) */ + +#define ACPI_PCI_ROOT_CLASS "pci_bridge" +#define ACPI_PCI_ROOT_HID "PNP0A03" +#define ACPI_PCI_ROOT_DRIVER_NAME "ACPI PCI Root Bridge Driver" +#define ACPI_PCI_ROOT_DEVICE_NAME "PCI Root Bridge" + +int acpi_pci_root_init (void); +void acpi_pci_root_exit (void); + +/* ACPI PCI Interrupt Link (pci_link.c) */ + +#define ACPI_PCI_LINK_CLASS "pci_irq_routing" +#define ACPI_PCI_LINK_HID "PNP0C0F" +#define ACPI_PCI_LINK_DRIVER_NAME "ACPI PCI Interrupt Link Driver" +#define ACPI_PCI_LINK_DEVICE_NAME "PCI Interrupt Link" +#define ACPI_PCI_LINK_FILE_INFO "info" +#define ACPI_PCI_LINK_FILE_STATUS "state" + +int acpi_pci_link_check (void); +int acpi_pci_link_get_irq (ACPI_HANDLE handle, int index, int* edge_level, int* active_high_low); +int acpi_pci_link_init (void); +void acpi_pci_link_exit (void); + +/* ACPI PCI Interrupt Routing (pci_irq.c) */ + +int acpi_pci_irq_add_prt (ACPI_HANDLE handle, int segment, int bus); + +/* ACPI PCI Device Binding (pci_bind.c) */ + +struct pci_bus; + +int acpi_pci_bind (struct acpi_device *device); +int acpi_pci_bind_root (struct acpi_device *device, struct acpi_pci_id *id, struct pci_bus *bus); + +#endif /*CONFIG_ACPI_PCI*/ + + +/* -------------------------------------------------------------------------- + Power Resource + -------------------------------------------------------------------------- */ + +#define ACPI_POWER_COMPONENT 0x00800000 +#define ACPI_POWER_CLASS "power_resource" +#define ACPI_POWER_HID "ACPI_PWR" +#define ACPI_POWER_DRIVER_NAME "ACPI Power Resource Driver" +#define ACPI_POWER_DEVICE_NAME "Power Resource" +#define ACPI_POWER_FILE_INFO "info" +#define ACPI_POWER_FILE_STATUS "state" +#define ACPI_POWER_RESOURCE_STATE_OFF 0x00 +#define ACPI_POWER_RESOURCE_STATE_ON 0x01 +#define ACPI_POWER_RESOURCE_STATE_UNKNOWN 0xFF + + + +int acpi_power_get_inferred_state (struct acpi_device *device); +int acpi_power_transition (struct acpi_device *device, int state); +int acpi_power_init (void); +void acpi_power_exit (void); + + +/* -------------------------------------------------------------------------- + Processor + -------------------------------------------------------------------------- */ + +#define ACPI_PROCESSOR_COMPONENT 0x01000000 +#define ACPI_PROCESSOR_CLASS "processor" +#define ACPI_PROCESSOR_HID "Processor" +#define ACPI_PROCESSOR_DRIVER_NAME "ACPI Processor Driver" +#define ACPI_PROCESSOR_DEVICE_NAME "Processor" +#define ACPI_PROCESSOR_FILE_INFO "info" +#define ACPI_PROCESSOR_FILE_POWER "power" +#define ACPI_PROCESSOR_FILE_PERFORMANCE "performance" +#define ACPI_PROCESSOR_FILE_THROTTLING "throttling" +#define ACPI_PROCESSOR_FILE_LIMIT "limit" +#define ACPI_PROCESSOR_NOTIFY_PERFORMANCE 0x80 +#define ACPI_PROCESSOR_NOTIFY_POWER 0x81 +#define ACPI_PROCESSOR_LIMIT_NONE 0x00 +#define ACPI_PROCESSOR_LIMIT_INCREMENT 0x01 +#define ACPI_PROCESSOR_LIMIT_DECREMENT 0x02 + +int acpi_processor_set_thermal_limit(ACPI_HANDLE handle, int type); + + +/* -------------------------------------------------------------------------- + System + -------------------------------------------------------------------------- */ + +#define ACPI_SYSTEM_COMPONENT 0x02000000 +#define ACPI_SYSTEM_CLASS "system" +#define ACPI_SYSTEM_HID "ACPI_SYS" +#define ACPI_SYSTEM_DRIVER_NAME "ACPI System Driver" +#define ACPI_SYSTEM_DEVICE_NAME "System" +#define ACPI_SYSTEM_FILE_INFO "info" +#define ACPI_SYSTEM_FILE_EVENT "event" +#define ACPI_SYSTEM_FILE_ALARM "alarm" +#define ACPI_SYSTEM_FILE_DSDT "dsdt" +#define ACPI_SYSTEM_FILE_FADT "fadt" +#define ACPI_SYSTEM_FILE_SLEEP "sleep" +#define ACPI_SYSTEM_FILE_DEBUG_LAYER "debug_layer" +#define ACPI_SYSTEM_FILE_DEBUG_LEVEL "debug_level" + +int acpi_system_init (void); +void acpi_system_exit (void); + + +/* -------------------------------------------------------------------------- + Thermal Zone + -------------------------------------------------------------------------- */ + +#define ACPI_THERMAL_COMPONENT 0x04000000 +#define ACPI_THERMAL_CLASS "thermal_zone" +#define ACPI_THERMAL_HID "ThermalZone" +#define ACPI_THERMAL_DRIVER_NAME "ACPI Thermal Zone Driver" +#define ACPI_THERMAL_DEVICE_NAME "Thermal Zone" +#define ACPI_THERMAL_FILE_STATE "state" +#define ACPI_THERMAL_FILE_TEMPERATURE "temperature" +#define ACPI_THERMAL_FILE_TRIP_POINTS "trip_points" +#define ACPI_THERMAL_FILE_COOLING_MODE "cooling_mode" +#define ACPI_THERMAL_FILE_POLLING_FREQ "polling_frequency" +#define ACPI_THERMAL_NOTIFY_TEMPERATURE 0x80 +#define ACPI_THERMAL_NOTIFY_THRESHOLDS 0x81 +#define ACPI_THERMAL_NOTIFY_DEVICES 0x82 +#define ACPI_THERMAL_NOTIFY_CRITICAL 0xF0 +#define ACPI_THERMAL_NOTIFY_HOT 0xF1 +#define ACPI_THERMAL_MODE_ACTIVE 0x00 +#define ACPI_THERMAL_MODE_PASSIVE 0x01 +#define ACPI_THERMAL_PATH_POWEROFF "/sbin/poweroff" + +/* Motherboard devices */ +int acpi_motherboard_init(void); +/* -------------------------------------------------------------------------- + Debug Support + -------------------------------------------------------------------------- */ + +#define ACPI_DEBUG_RESTORE 0 +#define ACPI_DEBUG_LOW 1 +#define ACPI_DEBUG_MEDIUM 2 +#define ACPI_DEBUG_HIGH 3 +#define ACPI_DEBUG_DRIVERS 4 + +extern UINT32 acpi_dbg_level; +extern UINT32 acpi_dbg_layer; + +static inline void +acpi_set_debug ( + UINT32 flag) +{ + static UINT32 layer_save; + static UINT32 level_save; + + switch (flag) { + case ACPI_DEBUG_RESTORE: + acpi_dbg_layer = layer_save; + acpi_dbg_level = level_save; + break; + case ACPI_DEBUG_LOW: + case ACPI_DEBUG_MEDIUM: + case ACPI_DEBUG_HIGH: + case ACPI_DEBUG_DRIVERS: + layer_save = acpi_dbg_layer; + level_save = acpi_dbg_level; + break; + } + + switch (flag) { + case ACPI_DEBUG_LOW: + acpi_dbg_layer = ACPI_COMPONENT_DEFAULT | ACPI_ALL_DRIVERS; + acpi_dbg_level = ACPI_DEBUG_DEFAULT; + break; + case ACPI_DEBUG_MEDIUM: + acpi_dbg_layer = ACPI_COMPONENT_DEFAULT | ACPI_ALL_DRIVERS; + acpi_dbg_level = ACPI_LV_FUNCTIONS | ACPI_LV_ALL_EXCEPTIONS; + break; + case ACPI_DEBUG_HIGH: + acpi_dbg_layer = 0xFFFFFFFF; + acpi_dbg_level = 0xFFFFFFFF; + break; + case ACPI_DEBUG_DRIVERS: + acpi_dbg_layer = ACPI_ALL_DRIVERS; + acpi_dbg_level = 0xFFFFFFFF; + break; + } +} + + +#endif /*__ACPI_DRIVERS_H__*/ diff --git a/reactos/drivers/bus/acpi/include/acpisys.h b/reactos/drivers/bus/acpi/include/acpisys.h new file mode 100644 index 00000000000..368ac97c83f --- /dev/null +++ b/reactos/drivers/bus/acpi/include/acpisys.h @@ -0,0 +1,292 @@ +/* + * PROJECT: ReactOS ACPI bus driver + * FILE: acpi/ospm/include/acpisys.h + * PURPOSE: ACPI bus driver definitions + */ +typedef enum _DEVICE_PNP_STATE { + + NotStarted = 0, // Not started yet + Started, // Device has received the START_DEVICE IRP + StopPending, // Device has received the QUERY_STOP IRP + Stopped, // Device has received the STOP_DEVICE IRP + UnKnown // Unknown state + +} DEVICE_PNP_STATE; + +// +// A common header for the device extensions of the PDOs and FDO +// + +typedef struct _COMMON_DEVICE_DATA +{ + PDEVICE_OBJECT Self; + BOOLEAN IsFDO; + DEVICE_PNP_STATE DevicePnPState; + DEVICE_PNP_STATE PreviousPnPState; + SYSTEM_POWER_STATE SystemPowerState; + DEVICE_POWER_STATE DevicePowerState; +} COMMON_DEVICE_DATA, *PCOMMON_DEVICE_DATA; + +typedef struct _PDO_DEVICE_DATA +{ + COMMON_DEVICE_DATA Common; + ACPI_HANDLE AcpiHandle; + // A back pointer to the bus + PDEVICE_OBJECT ParentFdo; + // An array of (zero terminated wide character strings). + // The array itself also null terminated + PWCHAR HardwareIDs; + // Link point to hold all the PDOs for a single bus together + LIST_ENTRY Link; + ULONG InterfaceRefCount; + +} PDO_DEVICE_DATA, *PPDO_DEVICE_DATA; + +// +// The device extension of the bus itself. From whence the PDO's are born. +// + +typedef struct _FDO_DEVICE_DATA +{ + COMMON_DEVICE_DATA Common; + PDEVICE_OBJECT UnderlyingPDO; + + // The underlying bus PDO and the actual device object to which our + // FDO is attached + PDEVICE_OBJECT NextLowerDriver; + + // List of PDOs created so far + LIST_ENTRY ListOfPDOs; + + // The PDOs currently enumerated. + ULONG NumPDOs; + + // A synchronization for access to the device extension. + FAST_MUTEX Mutex; + + // The name returned from IoRegisterDeviceInterface, + // which is used as a handle for IoSetDeviceInterfaceState. + UNICODE_STRING InterfaceName; + +} FDO_DEVICE_DATA, *PFDO_DEVICE_DATA; + +#define FDO_FROM_PDO(pdoData) \ + ((PFDO_DEVICE_DATA) (pdoData)->ParentFdo->DeviceExtension) + +#define INITIALIZE_PNP_STATE(_Data_) \ + (_Data_).DevicePnPState = NotStarted;\ + (_Data_).PreviousPnPState = NotStarted; + +#define SET_NEW_PNP_STATE(_Data_, _state_) \ + (_Data_).PreviousPnPState = (_Data_).DevicePnPState;\ + (_Data_).DevicePnPState = (_state_); + +#define RESTORE_PREVIOUS_PNP_STATE(_Data_) \ + (_Data_).DevicePnPState = (_Data_).PreviousPnPState;\ + +/* acpienum.c */ + +NTSTATUS +ACPIEnumerateDevices( + PFDO_DEVICE_DATA DeviceExtension); + +NTSTATUS +NTAPI +Bus_CreateClose ( + PDEVICE_OBJECT DeviceObject, + PIRP Irp + ); + +VOID +Bus_DriverUnload ( + PDRIVER_OBJECT DriverObject + ); + +PCHAR +PnPMinorFunctionString ( + UCHAR MinorFunction +); + +NTSTATUS +NTAPI +Bus_AddDevice( + PDRIVER_OBJECT DriverObject, + PDEVICE_OBJECT PhysicalDeviceObject + ); + +NTSTATUS +Bus_SendIrpSynchronously ( + PDEVICE_OBJECT DeviceObject, + PIRP Irp + ); + +NTSTATUS +NTAPI +Bus_PnP ( + PDEVICE_OBJECT DeviceObject, + PIRP Irp + ); + +NTSTATUS +Bus_CompletionRoutine( + PDEVICE_OBJECT DeviceObject, + PIRP Irp, + PVOID Context + ); + +VOID +Bus_InitializePdo ( + PDEVICE_OBJECT Pdo, + PFDO_DEVICE_DATA FdoData + ); + + +void +Bus_RemoveFdo ( + PFDO_DEVICE_DATA FdoData + ); + +NTSTATUS +Bus_DestroyPdo ( + PDEVICE_OBJECT Device, + PPDO_DEVICE_DATA PdoData + ); + + +NTSTATUS +Bus_FDO_PnP ( + PDEVICE_OBJECT DeviceObject, + PIRP Irp, + PIO_STACK_LOCATION IrpStack, + PFDO_DEVICE_DATA DeviceData + ); + + +NTSTATUS +Bus_StartFdo ( + PFDO_DEVICE_DATA FdoData, + PIRP Irp ); + +PCHAR +DbgDeviceIDString( + BUS_QUERY_ID_TYPE Type + ); + +PCHAR +DbgDeviceRelationString( + DEVICE_RELATION_TYPE Type + ); + +NTSTATUS +Bus_FDO_Power ( + PFDO_DEVICE_DATA FdoData, + PIRP Irp + ); + +NTSTATUS +Bus_PDO_Power ( + PPDO_DEVICE_DATA PdoData, + PIRP Irp + ); + +NTSTATUS +NTAPI +Bus_Power ( + PDEVICE_OBJECT DeviceObject, + PIRP Irp + ); + +PCHAR +PowerMinorFunctionString ( + UCHAR MinorFunction +); + +PCHAR +DbgSystemPowerString( + SYSTEM_POWER_STATE Type + ); + +PCHAR +DbgDevicePowerString( + DEVICE_POWER_STATE Type + ); + +NTSTATUS +Bus_PDO_PnP ( + PDEVICE_OBJECT DeviceObject, + PIRP Irp, + PIO_STACK_LOCATION IrpStack, + PPDO_DEVICE_DATA DeviceData + ); + +NTSTATUS +Bus_PDO_QueryDeviceCaps( + PPDO_DEVICE_DATA DeviceData, + PIRP Irp ); + +NTSTATUS +Bus_PDO_QueryDeviceId( + PPDO_DEVICE_DATA DeviceData, + PIRP Irp ); + + +NTSTATUS +Bus_PDO_QueryDeviceText( + PPDO_DEVICE_DATA DeviceData, + PIRP Irp ); + +NTSTATUS +Bus_PDO_QueryResources( + PPDO_DEVICE_DATA DeviceData, + PIRP Irp ); + +NTSTATUS +Bus_PDO_QueryResourceRequirements( + PPDO_DEVICE_DATA DeviceData, + PIRP Irp ); + +NTSTATUS +Bus_PDO_QueryDeviceRelations( + PPDO_DEVICE_DATA DeviceData, + PIRP Irp ); + +NTSTATUS +Bus_PDO_QueryBusInformation( + PPDO_DEVICE_DATA DeviceData, + PIRP Irp ); + +NTSTATUS +Bus_GetDeviceCapabilities( + PDEVICE_OBJECT DeviceObject, + PDEVICE_CAPABILITIES DeviceCapabilities + ); + +NTSTATUS +Bus_PDO_QueryInterface( + PPDO_DEVICE_DATA DeviceData, + PIRP Irp ); + +BOOLEAN +Bus_GetCrispinessLevel( + PVOID Context, + PUCHAR Level + ); +BOOLEAN +Bus_SetCrispinessLevel( + PVOID Context, + UCHAR Level + ); +BOOLEAN +Bus_IsSafetyLockEnabled( + PVOID Context + ); +VOID +Bus_InterfaceReference ( + PVOID Context + ); +VOID +Bus_InterfaceDereference ( + PVOID Context + ); + +/* EOF */ diff --git a/reactos/drivers/bus/acpi/include/glue.h b/reactos/drivers/bus/acpi/include/glue.h new file mode 100644 index 00000000000..7dd950a0691 --- /dev/null +++ b/reactos/drivers/bus/acpi/include/glue.h @@ -0,0 +1,32 @@ +#ifndef __GLUE_HEADER +#define __GLUE_HEADER + +#include + +/* header for linux macros and definitions */ + + /** + * container_of - cast a member of a structure out to the containing structure + * @ptr: the pointer to the member. + * @type: the type of the container struct this is embedded in. + * @member: the name of the member within the struct. + * + */ + #define container_of(ptr, type, member) (type *)( (char *)(ptr) - offsetof(type,member) ) + + +#define time_after(a,b) \ + ((long)(b) - (long)(a) < 0)) + +#define time_before(a,b) time_after(b,a) + +#define in_interrupt() ((__readeflags() >> 9) & 1) + +typedef int (*acpi_table_handler) (ACPI_TABLE_HEADER *table); + +typedef int (*acpi_table_entry_handler) (ACPI_SUBTABLE_HEADER *header, const unsigned long end); + +#define down(mutex) ExAcquireFastMutex(mutex) +#define up(mutex) ExReleaseFastMutex(mutex) + +#endif diff --git a/reactos/drivers/bus/acpi/include/list.h b/reactos/drivers/bus/acpi/include/list.h new file mode 100644 index 00000000000..bac8727aa73 --- /dev/null +++ b/reactos/drivers/bus/acpi/include/list.h @@ -0,0 +1,251 @@ + #ifndef _LINUX_LIST_H + #define _LINUX_LIST_H + + + /* + * Simple doubly linked list implementation. + * + * Some of the internal functions ("__xxx") are useful when + * manipulating whole lists rather than single entries, as + * sometimes we already know the next/prev entries and we can + * generate better code by using them directly rather than + * using the generic single-entry routines. + */ + + struct list_head { + struct list_head *next, *prev; + }; + + #define LIST_HEAD_INIT(name) { &(name), &(name) } + + #define LIST_HEAD(name) \ + struct list_head name = LIST_HEAD_INIT(name) + + #define INIT_LIST_HEAD(ptr) do { \ + (ptr)->next = (ptr); (ptr)->prev = (ptr); \ + } while (0) + + + /* + * Insert a new entry between two known consecutive entries. + * + * This is only for internal list manipulation where we know + * the prev/next entries already! + */ + static inline void __list_add(struct list_head *new, + struct list_head *prev, + struct list_head *next) + { + next->prev = new; + new->next = next; + new->prev = prev; + prev->next = new; + } + + /** + * list_add - add a new entry + * @new: new entry to be added + * @head: list head to add it after + * + * Insert a new entry after the specified head. + * This is good for implementing stacks. + */ + static inline void list_add(struct list_head *new, struct list_head *head) + { + __list_add(new, head, head->next); + } + + /** + * list_add_tail - add a new entry + * @new: new entry to be added + * @head: list head to add it before + * + * Insert a new entry before the specified head. + * This is useful for implementing queues. + */ + static inline void list_add_tail(struct list_head *new, struct list_head *head) + { + __list_add(new, head->prev, head); + } + + /* + * Delete a list entry by making the prev/next entries + * point to each other. + * + * This is only for internal list manipulation where we know + * the prev/next entries already! + */ + static inline void __list_del(struct list_head *prev, struct list_head *next) + { + next->prev = prev; + prev->next = next; + } + + /** + * list_del - deletes entry from list. + * @entry: the element to delete from the list. + * Note: list_empty on entry does not return true after this, the entry is in an undefined state. + */ + static inline void list_del(struct list_head *entry) + { + __list_del(entry->prev, entry->next); + entry->next = (void *) 0; + entry->prev = (void *) 0; + } + + /** + * list_del_init - deletes entry from list and reinitialize it. + * @entry: the element to delete from the list. + */ + static inline void list_del_init(struct list_head *entry) + { + __list_del(entry->prev, entry->next); + INIT_LIST_HEAD(entry); + } + + /** + * list_move - delete from one list and add as another's head + * @list: the entry to move + * @head: the head that will precede our entry + */ + static inline void list_move(struct list_head *list, struct list_head *head) + { + __list_del(list->prev, list->next); + list_add(list, head); + } + + /** + * list_move_tail - delete from one list and add as another's tail + * @list: the entry to move + * @head: the head that will follow our entry + */ + static inline void list_move_tail(struct list_head *list, + struct list_head *head) + { + __list_del(list->prev, list->next); + list_add_tail(list, head); + } + + /** + * list_empty - tests whether a list is empty + * @head: the list to test. + */ + static inline int list_empty(struct list_head *head) + { + return head->next == head; + } + + static inline void __list_splice(struct list_head *list, + struct list_head *head) + { + struct list_head *first = list->next; + struct list_head *last = list->prev; + struct list_head *at = head->next; + + first->prev = head; + head->next = first; + + last->next = at; + at->prev = last; + } + +/** + * list_splice - join two lists + * @list: the new list to add. + * @head: the place to add it in the first list. + */ + static inline void list_splice(struct list_head *list, struct list_head *head) + { + if (!list_empty(list)) + __list_splice(list, head); + } + + /** + * list_splice_init - join two lists and reinitialise the emptied list. + * @list: the new list to add. + * @head: the place to add it in the first list. + * + * The list at @list is reinitialised + */ + static inline void list_splice_init(struct list_head *list, + struct list_head *head) + { + if (!list_empty(list)) { + __list_splice(list, head); + INIT_LIST_HEAD(list); + } + } + + /** + * list_entry - get the struct for this entry + * @ptr: the &struct list_head pointer. + * @type: the type of the struct this is embedded in. + * @member: the name of the list_struct within the struct. + */ + #define list_entry(ptr, type, member) \ + ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member))) + + /** + * list_for_each - iterate over a list + * @pos: the &struct list_head to use as a loop counter. + * @head: the head for your list. + */ + #define list_for_each(pos, head) \ + for (pos = (head)->next; pos != (head); \ + pos = pos->next) + /** + * list_for_each_prev - iterate over a list backwards + * @pos: the &struct list_head to use as a loop counter. + * @head: the head for your list. + */ + #define list_for_each_prev(pos, head) \ + for (pos = (head)->prev; pos != (head); \ + pos = pos->prev) + +/** + * list_for_each_safe - iterate over a list safe against removal of list entry + * @pos: the &struct list_head to use as a loop counter. + * @n: another &struct list_head to use as temporary storage + * @head: the head for your list. + */ + #define list_for_each_safe(pos, n, head) \ + for (pos = (head)->next, n = pos->next; pos != (head); \ + pos = n, n = pos->next) + + /** + * list_for_each_entry - iterate over list of given type + * @pos: the type * to use as a loop counter. + * @head: the head for your list. + * @member: the name of the list_struct within the struct. + */ + #define list_for_each_entry(pos, head, member) \ + for (pos = list_entry((head)->next, typeof(*pos), member); \ + &pos->member != (head); \ + pos = list_entry(pos->member.next, typeof(*pos), member)) + + /** + * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry + * @pos: the type * to use as a loop counter. + * @n: another type * to use as temporary storage + * @head: the head for your list. + * @member: the name of the list_struct within the struct. + */ + #define list_for_each_entry_safe(pos, n, head, member) \ + for (pos = list_entry((head)->next, typeof(*pos), member), \ + n = list_entry(pos->member.next, typeof(*pos), member); \ + &pos->member != (head); \ + pos = n, n = list_entry(n->member.next, typeof(*n), member)) + + /** + * list_for_each_entry_continue - iterate over list of given type + * continuing after existing point + * @pos: the type * to use as a loop counter. + * @head: the head for your list. + * @member: the name of the list_struct within the struct. + */ + #define list_for_each_entry_continue(pos, head, member) \ + for (pos = list_entry(pos->member.next, typeof(*pos), member); \ + &pos->member != (head); \ + pos = list_entry(pos->member.next, typeof(*pos), member)) + + #endif diff --git a/reactos/drivers/bus/acpi/interface.c b/reactos/drivers/bus/acpi/interface.c new file mode 100644 index 00000000000..59717056484 --- /dev/null +++ b/reactos/drivers/bus/acpi/interface.c @@ -0,0 +1,138 @@ +#include + +#include + +#include +#include +#include + +#include +#define NDEBUG +#include + +VOID +NTAPI +AcpiInterfaceReference(PVOID Context) +{ + UNIMPLEMENTED +} + +VOID +NTAPI +AcpiInterfaceDereference(PVOID Context) +{ + UNIMPLEMENTED +} + +NTSTATUS +AcpiInterfaceConnectVector(PDEVICE_OBJECT Context, + ULONG GpeNumber, + KINTERRUPT_MODE Mode, + BOOLEAN Shareable, + PGPE_SERVICE_ROUTINE ServiceRoutine, + PVOID ServiceContext, + PVOID *ObjectContext) +{ + UNIMPLEMENTED + + return STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS +AcpiInterfaceDisconnectVector(PDEVICE_OBJECT Context, + PVOID ObjectContext) +{ + UNIMPLEMENTED + + return STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS +AcpiInterfaceEnableEvent(PDEVICE_OBJECT Context, + PVOID ObjectContext) +{ + UNIMPLEMENTED + + return STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS +AcpiInterfaceDisableEvent(PDEVICE_OBJECT Context, + PVOID ObjectContext) +{ + UNIMPLEMENTED + + return STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS +AcpiInterfaceClearStatus(PDEVICE_OBJECT Context, + PVOID ObjectContext) +{ + UNIMPLEMENTED + + return STATUS_NOT_IMPLEMENTED; +} + +NTSTATUS +AcpiInterfaceNotificationsRegister(PDEVICE_OBJECT Context, + PDEVICE_NOTIFY_CALLBACK NotificationHandler, + PVOID NotificationContext) +{ + UNIMPLEMENTED + + return STATUS_NOT_IMPLEMENTED; +} + +VOID +AcpiInterfaceNotificationsUnregister(PDEVICE_OBJECT Context, + PDEVICE_NOTIFY_CALLBACK NotificationHandler) +{ + UNIMPLEMENTED +} + +NTSTATUS +Bus_PDO_QueryInterface(PPDO_DEVICE_DATA DeviceData, + PIRP Irp) +{ + PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation(Irp); + PACPI_INTERFACE_STANDARD AcpiInterface; + + if (IrpSp->Parameters.QueryInterface.Version != 1) + { + DPRINT1("Invalid version number: %d\n", + IrpSp->Parameters.QueryInterface.Version); + return STATUS_INVALID_PARAMETER; + } + + if (RtlCompareMemory(IrpSp->Parameters.QueryInterface.InterfaceType, + &GUID_ACPI_INTERFACE_STANDARD, sizeof(GUID)) == sizeof(GUID)) + { + DPRINT("GUID_ACPI_INTERFACE_STANDARD\n"); + + if (IrpSp->Parameters.QueryInterface.Size < sizeof(ACPI_INTERFACE_STANDARD)) + { + DPRINT1("Buffer too small! (%d)\n", IrpSp->Parameters.QueryInterface.Size); + return STATUS_BUFFER_TOO_SMALL; + } + + AcpiInterface = (PACPI_INTERFACE_STANDARD)IrpSp->Parameters.QueryInterface.Interface; + + AcpiInterface->InterfaceReference = AcpiInterfaceReference; + AcpiInterface->InterfaceDereference = AcpiInterfaceDereference; + AcpiInterface->GpeConnectVector = AcpiInterfaceConnectVector; + AcpiInterface->GpeDisconnectVector = AcpiInterfaceDisconnectVector; + AcpiInterface->GpeEnableEvent = AcpiInterfaceEnableEvent; + AcpiInterface->GpeDisableEvent = AcpiInterfaceDisableEvent; + AcpiInterface->GpeClearStatus = AcpiInterfaceClearStatus; + AcpiInterface->RegisterForDeviceNotifications = AcpiInterfaceNotificationsRegister; + AcpiInterface->UnregisterForDeviceNotifications = AcpiInterfaceNotificationsUnregister; + + return STATUS_SUCCESS; + } + else + { + DPRINT1("Invalid GUID\n"); + return STATUS_INVALID_PARAMETER; + } +} diff --git a/reactos/drivers/bus/acpi/main.c b/reactos/drivers/bus/acpi/main.c new file mode 100644 index 00000000000..3d1170eefd6 --- /dev/null +++ b/reactos/drivers/bus/acpi/main.c @@ -0,0 +1,218 @@ +#include + +#include +#include + +#include +#include + +#define NDEBUG +#include + +#ifdef ALLOC_PRAGMA +#pragma alloc_text (INIT, DriverEntry) +#pragma alloc_text (PAGE, Bus_AddDevice) + +#endif + + + +NTSTATUS +NTAPI +Bus_AddDevice( + PDRIVER_OBJECT DriverObject, + PDEVICE_OBJECT PhysicalDeviceObject + ) + +{ + NTSTATUS status; + PDEVICE_OBJECT deviceObject = NULL; + PFDO_DEVICE_DATA deviceData = NULL; + PWCHAR deviceName = NULL; + ULONG nameLength; + + PAGED_CODE (); + + DPRINT("Add Device: 0x%p\n", PhysicalDeviceObject); + + DPRINT("#################### Bus_CreateClose Creating FDO Device ####################\n"); + status = IoCreateDevice(DriverObject, + sizeof(FDO_DEVICE_DATA), + NULL, + FILE_DEVICE_ACPI, + FILE_DEVICE_SECURE_OPEN, + TRUE, + &deviceObject); + if (!NT_SUCCESS(status)) + { + DPRINT1("IoCreateDevice() failed with status 0x%X\n", status); + goto End; + } + + deviceData = (PFDO_DEVICE_DATA) deviceObject->DeviceExtension; + RtlZeroMemory (deviceData, sizeof (FDO_DEVICE_DATA)); + + // + // Set the initial state of the FDO + // + + INITIALIZE_PNP_STATE(deviceData->Common); + + deviceData->Common.IsFDO = TRUE; + + deviceData->Common.Self = deviceObject; + + ExInitializeFastMutex (&deviceData->Mutex); + + InitializeListHead (&deviceData->ListOfPDOs); + + // Set the PDO for use with PlugPlay functions + + deviceData->UnderlyingPDO = PhysicalDeviceObject; + + // + // Set the initial powerstate of the FDO + // + + deviceData->Common.DevicePowerState = PowerDeviceUnspecified; + deviceData->Common.SystemPowerState = PowerSystemWorking; + + deviceObject->Flags |= DO_POWER_PAGABLE; + + // + // Attach our FDO to the device stack. + // The return value of IoAttachDeviceToDeviceStack is the top of the + // attachment chain. This is where all the IRPs should be routed. + // + + deviceData->NextLowerDriver = IoAttachDeviceToDeviceStack ( + deviceObject, + PhysicalDeviceObject); + + if (NULL == deviceData->NextLowerDriver) { + + status = STATUS_NO_SUCH_DEVICE; + goto End; + } + + +#ifndef NDEBUG + // + // We will demonstrate here the step to retrieve the name of the PDO + // + + status = IoGetDeviceProperty (PhysicalDeviceObject, + DevicePropertyPhysicalDeviceObjectName, + 0, + NULL, + &nameLength); + + if (status != STATUS_BUFFER_TOO_SMALL) + { + DPRINT1("AddDevice:IoGDP failed (0x%x)\n", status); + goto End; + } + + deviceName = ExAllocatePoolWithTag (NonPagedPool, + nameLength, 'IPCA'); + + if (NULL == deviceName) { + DPRINT1("AddDevice: no memory to alloc for deviceName(0x%x)\n", nameLength); + status = STATUS_INSUFFICIENT_RESOURCES; + goto End; + } + + status = IoGetDeviceProperty (PhysicalDeviceObject, + DevicePropertyPhysicalDeviceObjectName, + nameLength, + deviceName, + &nameLength); + + if (!NT_SUCCESS (status)) { + + DPRINT1("AddDevice:IoGDP(2) failed (0x%x)", status); + goto End; + } + + DPRINT("AddDevice: %p to %p->%p (%ws) \n", + deviceObject, + deviceData->NextLowerDriver, + PhysicalDeviceObject, + deviceName); + +#endif + + // + // We are done with initializing, so let's indicate that and return. + // This should be the final step in the AddDevice process. + // + deviceObject->Flags &= ~DO_DEVICE_INITIALIZING; + +End: + if (deviceName){ + ExFreePool(deviceName); + } + if (!NT_SUCCESS(status) && deviceObject){ + if (deviceData && deviceData->NextLowerDriver){ + IoDetachDevice (deviceData->NextLowerDriver); + } + IoDeleteDevice (deviceObject); + } + return status; + +} + +NTSTATUS +NTAPI +ACPIDispatchDeviceControl( + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp) +{ + PIO_STACK_LOCATION IrpSp; + NTSTATUS Status; + + DPRINT("Called. IRP is at (0x%X)\n", Irp); + + Irp->IoStatus.Information = 0; + + IrpSp = IoGetCurrentIrpStackLocation(Irp); + switch (IrpSp->Parameters.DeviceIoControl.IoControlCode) { + default: + DPRINT("Unknown IOCTL 0x%X\n", IrpSp->Parameters.DeviceIoControl.IoControlCode); + Status = STATUS_NOT_IMPLEMENTED; + break; + } + + if (Status != STATUS_PENDING) { + Irp->IoStatus.Status = Status; + + DPRINT("Completing IRP at 0x%X\n", Irp); + + IoCompleteRequest(Irp, IO_NO_INCREMENT); + } + + DPRINT("Leaving. Status 0x%X\n", Status); + + return Status; +} + +NTSTATUS +NTAPI +DriverEntry ( + PDRIVER_OBJECT DriverObject, + PUNICODE_STRING RegistryPath + ) +{ + DPRINT("Driver Entry \n"); + + // + // Set entry points into the driver + // + DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = ACPIDispatchDeviceControl; + DriverObject->MajorFunction [IRP_MJ_PNP] = Bus_PnP; + DriverObject->MajorFunction [IRP_MJ_POWER] = Bus_Power; + + DriverObject->DriverExtension->AddDevice = Bus_AddDevice; + + return STATUS_SUCCESS; +} diff --git a/reactos/drivers/bus/acpi/osl.c b/reactos/drivers/bus/acpi/osl.c new file mode 100644 index 00000000000..f2549951e7e --- /dev/null +++ b/reactos/drivers/bus/acpi/osl.c @@ -0,0 +1,756 @@ +/******************************************************************************* +* * +* ACPI Component Architecture Operating System Layer (OSL) for ReactOS * +* * +*******************************************************************************/ +#include + +#include + +#define NDEBUG +#include + +#define NUM_SEMAPHORES 128 + +static PKINTERRUPT AcpiInterrupt; +static BOOLEAN AcpiInterruptHandlerRegistered = FALSE; +static ACPI_OSD_HANDLER AcpiIrqHandler = NULL; +static PVOID AcpiIrqContext = NULL; +static ULONG AcpiIrqNumber = 0; +static KDPC AcpiDpc; +static PVOID IVTVirtualAddress = NULL; + + +typedef struct semaphore_entry +{ + UINT16 MaxUnits; + UINT16 CurrentUnits; + void *OsHandle; +} SEMAPHORE_ENTRY; + +static SEMAPHORE_ENTRY AcpiGbl_Semaphores[NUM_SEMAPHORES]; + +VOID NTAPI +OslDpcStub( + IN PKDPC Dpc, + IN PVOID DeferredContext, + IN PVOID SystemArgument1, + IN PVOID SystemArgument2) +{ + ACPI_OSD_EXEC_CALLBACK Routine = (ACPI_OSD_EXEC_CALLBACK)SystemArgument1; + + DPRINT("OslDpcStub()\n"); + DPRINT("Calling [%p]([%p])\n", Routine, SystemArgument2); + (*Routine)(SystemArgument2); +} + +BOOLEAN NTAPI +OslIsrStub( + PKINTERRUPT Interrupt, + PVOID ServiceContext) +{ + INT32 Status; + + Status = (*AcpiIrqHandler)(AcpiIrqContext); + + if (ACPI_SUCCESS(Status)) + return TRUE; + else + return FALSE; +} + +ACPI_STATUS +AcpiOsRemoveInterruptHandler ( + UINT32 InterruptNumber, + ACPI_OSD_HANDLER ServiceRoutine); + +ACPI_STATUS +AcpiOsInitialize (void) +{ + DPRINT("AcpiOsInitialize called\n"); + +#ifndef NDEBUG + /* Verboseness level of the acpica core */ + AcpiDbgLevel = 0x00FFFFFF; + AcpiDbgLayer = 0xFFFFFFFF; +#endif + + UINT32 i; + + for (i = 0; i < NUM_SEMAPHORES; i++) + { + AcpiGbl_Semaphores[i].OsHandle = NULL; + } + + KeInitializeDpc(&AcpiDpc, OslDpcStub, NULL); + + return AE_OK; +} + +ACPI_STATUS +AcpiOsTerminate(void) +{ + DPRINT("AcpiOsTerminate() called\n"); + + if (AcpiInterruptHandlerRegistered) + AcpiOsRemoveInterruptHandler(AcpiIrqNumber, AcpiIrqHandler); + + return AE_OK; +} + +void ACPI_INTERNAL_VAR_XFACE +AcpiOsPrintf ( + const char *Fmt, + ...) +{ + va_list Args; + va_start (Args, Fmt); + + AcpiOsVprintf (Fmt, Args); + + va_end (Args); + return; +} + +void +AcpiOsVprintf ( + const char *Fmt, + va_list Args) +{ +#ifndef NDEBUG + vDbgPrintEx (-1, DPFLTR_ERROR_LEVEL, Fmt, Args); +#endif + return; +} + +void * +AcpiOsAllocate (ACPI_SIZE size) +{ + DPRINT("AcpiOsAllocate size %d\n",size); + return ExAllocatePool(NonPagedPool, size); +} + +void * +AcpiOsCallocate(ACPI_SIZE size) +{ + PVOID ptr = ExAllocatePool(NonPagedPool, size); + if (ptr) + memset(ptr, 0, size); + return ptr; +} + +void +AcpiOsFree(void *ptr) +{ + if (!ptr) + DPRINT1("Attempt to free null pointer!!!\n"); + ExFreePool(ptr); +} + +#ifndef ACPI_USE_LOCAL_CACHE + +void* +AcpiOsAcquireObjectHelper ( + POOL_TYPE PoolType, + SIZE_T NumberOfBytes, + ULONG Tag) +{ + void* Alloc = ExAllocatePool(PoolType, NumberOfBytes); + + /* acpica expects memory allocated from cache to be zeroed */ + RtlZeroMemory(Alloc,NumberOfBytes); + return Alloc; +} + +ACPI_STATUS +AcpiOsCreateCache ( + char *CacheName, + UINT16 ObjectSize, + UINT16 MaxDepth, + ACPI_CACHE_T **ReturnCache) +{ + PNPAGED_LOOKASIDE_LIST Lookaside = + ExAllocatePool(NonPagedPool,sizeof(NPAGED_LOOKASIDE_LIST)); + + ExInitializeNPagedLookasideList(Lookaside, + (PALLOCATE_FUNCTION)AcpiOsAcquireObjectHelper,// custom memory allocator + NULL, + 0, + ObjectSize, + 'IPCA', + 0); + *ReturnCache = (ACPI_CACHE_T *)Lookaside; + + DPRINT("AcpiOsCreateCache %p\n", Lookaside); + return (AE_OK); +} + +ACPI_STATUS +AcpiOsDeleteCache ( + ACPI_CACHE_T *Cache) +{ + DPRINT("AcpiOsDeleteCache %p\n", Cache); + ExDeleteNPagedLookasideList( + (PNPAGED_LOOKASIDE_LIST) Cache); + ExFreePool(Cache); + return (AE_OK); +} + +ACPI_STATUS +AcpiOsPurgeCache ( + ACPI_CACHE_T *Cache) +{ + DPRINT("AcpiOsPurgeCache\n"); + /* No such functionality for LookAside lists */ + return (AE_OK); +} + +void * +AcpiOsAcquireObject ( + ACPI_CACHE_T *Cache) +{ + PNPAGED_LOOKASIDE_LIST List = (PNPAGED_LOOKASIDE_LIST)Cache; + DPRINT("AcpiOsAcquireObject from %p\n", Cache); + void* ptr = + ExAllocateFromNPagedLookasideList(List); + ASSERT(ptr); + + RtlZeroMemory(ptr,List->L.Size); + return ptr; +} + +ACPI_STATUS +AcpiOsReleaseObject ( + ACPI_CACHE_T *Cache, + void *Object) +{ + DPRINT("AcpiOsReleaseObject %p from %p\n",Object, Cache); + ExFreeToNPagedLookasideList( + (PNPAGED_LOOKASIDE_LIST)Cache, + Object); + return (AE_OK); +} + +#endif + +void * +AcpiOsMapMemory ( + ACPI_PHYSICAL_ADDRESS phys, + ACPI_SIZE length) +{ + PHYSICAL_ADDRESS Address; + + DPRINT("AcpiOsMapMemory(phys 0x%X size 0x%X)\n", (ULONG)phys, length); + if (phys == 0x0) + { + IVTVirtualAddress = ExAllocatePool(NonPagedPool, length); + return IVTVirtualAddress; + } + + Address.QuadPart = (ULONG)phys; + return MmMapIoSpace(Address, length, MmNonCached); +} + +void +AcpiOsUnmapMemory ( + void *virt, + ACPI_SIZE length) +{ + DPRINT("AcpiOsUnmapMemory()\n"); + + if (virt == 0x0) + { + ExFreePool(IVTVirtualAddress); + return; + } + MmUnmapIoSpace(virt, length); +} + +UINT32 +AcpiOsInstallInterruptHandler ( + UINT32 InterruptNumber, + ACPI_OSD_HANDLER ServiceRoutine, + void *Context) +{ + ULONG Vector; + KIRQL DIrql; + KAFFINITY Affinity; + NTSTATUS Status; + + DPRINT("AcpiOsInstallInterruptHandler()\n"); + Vector = HalGetInterruptVector( + Internal, + 0, + InterruptNumber, + 0, + &DIrql, + &Affinity); + + AcpiIrqNumber = InterruptNumber; + AcpiIrqHandler = ServiceRoutine; + AcpiIrqContext = Context; + AcpiInterruptHandlerRegistered = TRUE; + + Status = IoConnectInterrupt( + &AcpiInterrupt, + OslIsrStub, + NULL, + NULL, + Vector, + DIrql, + DIrql, + LevelSensitive, /* FIXME: LevelSensitive or Latched? */ + TRUE, + Affinity, + FALSE); + + if (!NT_SUCCESS(Status)) + { + DPRINT("Could not connect to interrupt %d\n", Vector); + return AE_ERROR; + } + return AE_OK; +} + +ACPI_STATUS +AcpiOsRemoveInterruptHandler ( + UINT32 InterruptNumber, + ACPI_OSD_HANDLER ServiceRoutine) +{ + DPRINT("AcpiOsRemoveInterruptHandler()\n"); + if (AcpiInterruptHandlerRegistered) + { + IoDisconnectInterrupt(AcpiInterrupt); + AcpiInterrupt = NULL; + AcpiInterruptHandlerRegistered = FALSE; + } + + return AE_OK; +} + +void +AcpiOsStall (UINT32 microseconds) +{ + DPRINT("AcpiOsStall %d\n",microseconds); + KeStallExecutionProcessor(microseconds); + return; +} + +void +AcpiOsSleep (ACPI_INTEGER milliseconds) +{ + DPRINT("AcpiOsSleep %d\n", milliseconds); + KeStallExecutionProcessor(milliseconds*1000); + return; +} + +ACPI_STATUS +AcpiOsReadPort ( + ACPI_IO_ADDRESS Address, + UINT32 *Value, + UINT32 Width) +{ + DPRINT("AcpiOsReadPort %p, width %d\n",Address,Width); + + switch (Width) + { + case 8: + *Value = READ_PORT_UCHAR((PUCHAR)Address); + break; + + case 16: + *Value = READ_PORT_USHORT((PUSHORT)Address); + break; + + case 32: + *Value = READ_PORT_ULONG((PULONG)Address); + break; + default: + DPRINT1("AcpiOsReadPort got bad width: %d\n",Width); + return (AE_BAD_PARAMETER); + break; + } + return (AE_OK); +} + +ACPI_STATUS +AcpiOsWritePort ( + ACPI_IO_ADDRESS Address, + UINT32 Value, + UINT32 Width) +{ + DPRINT("AcpiOsWritePort %p, width %d\n",Address,Width); + switch (Width) + { + case 8: + WRITE_PORT_UCHAR((PUCHAR)Address, Value); + break; + + case 16: + WRITE_PORT_USHORT((PUSHORT)Address, Value); + break; + + case 32: + WRITE_PORT_ULONG((PULONG)Address, Value); + break; + + default: + DPRINT1("AcpiOsWritePort got bad width: %d\n",Width); + return (AE_BAD_PARAMETER); + break; + } + return (AE_OK); +} + +ACPI_STATUS +AcpiOsReadMemory ( + ACPI_PHYSICAL_ADDRESS Address, + UINT32 *Value, + UINT32 Width) +{ + DPRINT("AcpiOsReadMemory %p\n", Address); + switch (Width) + { + case 8: + *Value = (*(PUCHAR)(ULONG)Address); + break; + case 16: + *Value = (*(PUSHORT)(ULONG)Address); + break; + case 32: + *Value = (*(PULONG)(ULONG)Address); + break; + + default: + DPRINT1("AcpiOsReadMemory got bad width: %d\n",Width); + return (AE_BAD_PARAMETER); + break; + } + return (AE_OK); +} + + +ACPI_STATUS +AcpiOsWriteMemory ( + ACPI_PHYSICAL_ADDRESS Address, + UINT32 Value, + UINT32 Width) +{ + DPRINT("AcpiOsWriteMemory %p\n", Address); + switch (Width) + { + case 8: + *(PUCHAR)(ULONG)Address = Value; + break; + case 16: + *(PUSHORT)(ULONG)Address = Value; + break; + case 32: + *(PULONG)(ULONG)Address = Value; + break; + + default: + DPRINT1("AcpiOsWriteMemory got bad width: %d\n",Width); + return (AE_BAD_PARAMETER); + break; + } + + return (AE_OK); +} + +ACPI_STATUS +AcpiOsReadPciConfiguration ( + ACPI_PCI_ID *PciId, + UINT32 Register, + void *Value, + UINT32 Width) +{ + NTSTATUS Status; + PCI_SLOT_NUMBER slot; + + if (Register == 0 || PciId->Device == 0 || + Register + Width > PCI_COMMON_HDR_LENGTH) + return AE_ERROR; + + slot.u.AsULONG = 0; + slot.u.bits.DeviceNumber = PciId->Device; + slot.u.bits.FunctionNumber = PciId->Function; + + DPRINT("AcpiOsReadPciConfiguration, slot=0x%X, func=0x%X\n", slot.u.AsULONG, Register); + Status = HalGetBusDataByOffset(PCIConfiguration, + PciId->Bus, + slot.u.AsULONG, + Value, + Register, + Width); + + if (NT_SUCCESS(Status)) + return AE_OK; + else + return AE_ERROR; +} + +ACPI_STATUS +AcpiOsWritePciConfiguration ( + ACPI_PCI_ID *PciId, + UINT32 Register, + ACPI_INTEGER Value, + UINT32 Width) +{ + NTSTATUS Status; + ULONG buf = Value; + PCI_SLOT_NUMBER slot; + + if (Register == 0 || PciId->Device == 0 || + Register + Width > PCI_COMMON_HDR_LENGTH) + return AE_ERROR; + + slot.u.AsULONG = 0; + slot.u.bits.DeviceNumber = PciId->Device; + slot.u.bits.FunctionNumber = PciId->Function; + + DPRINT("AcpiOsWritePciConfiguration, slot=0x%x\n", slot.u.AsULONG); + Status = HalSetBusDataByOffset(PCIConfiguration, + PciId->Bus, + slot.u.AsULONG, + &buf, + Register, + Width); + + if (NT_SUCCESS(Status)) + return AE_OK; + else + return AE_ERROR; +} + +ACPI_STATUS +AcpiOsCreateSemaphore ( + UINT32 MaxUnits, + UINT32 InitialUnits, + ACPI_SEMAPHORE *OutHandle) +{ + PFAST_MUTEX Mutex; + + Mutex = ExAllocatePool(NonPagedPool, sizeof(FAST_MUTEX)); + if (!Mutex) + return AE_NO_MEMORY; + + DPRINT("AcpiOsCreateSemaphore() at 0x%X\n", Mutex); + + ExInitializeFastMutex(Mutex); + + *OutHandle = Mutex; + return AE_OK; +} + +ACPI_STATUS +AcpiOsDeleteSemaphore ( + ACPI_SEMAPHORE Handle) +{ + PFAST_MUTEX Mutex = (PFAST_MUTEX)Handle; + + DPRINT("AcpiOsDeleteSemaphore(handle 0x%X)\n", Handle); + + if (!Mutex) + return AE_BAD_PARAMETER; + + ExFreePool(Mutex); + return AE_OK; +} + +ACPI_STATUS +AcpiOsWaitSemaphore( + ACPI_SEMAPHORE Handle, + UINT32 units, + UINT16 timeout) +{ + PFAST_MUTEX Mutex = (PFAST_MUTEX)Handle; + + if (!Mutex || (units < 1)) + { + DPRINT("AcpiOsWaitSemaphore(handle 0x%X, units %d) Bad parameters\n", + Mutex, units); + return AE_BAD_PARAMETER; + } + + DPRINT("Waiting for semaphore %p\n", Handle); + ASSERT(Mutex); + + ExAcquireFastMutex(Mutex); + return AE_OK; +} + +ACPI_STATUS +AcpiOsSignalSemaphore ( + ACPI_HANDLE Handle, + UINT32 Units) +{ + PFAST_MUTEX Mutex = (PFAST_MUTEX)Handle; + + DPRINT("AcpiOsSignalSemaphore %p\n",Handle); + ASSERT(Mutex); + + ExReleaseFastMutex(Mutex); + return AE_OK; +} + +ACPI_STATUS +AcpiOsCreateLock ( + ACPI_SPINLOCK *OutHandle) +{ + DPRINT("AcpiOsCreateLock\n"); + return (AcpiOsCreateSemaphore (1, 1, OutHandle)); +} + +void +AcpiOsDeleteLock ( + ACPI_SPINLOCK Handle) +{ + DPRINT("AcpiOsDeleteLock %p\n", Handle); + AcpiOsDeleteSemaphore (Handle); +} + + +ACPI_CPU_FLAGS +AcpiOsAcquireLock ( + ACPI_HANDLE Handle) +{ + DPRINT("AcpiOsAcquireLock, %p\n", Handle); + AcpiOsWaitSemaphore (Handle, 1, 0xFFFF); + return (0); +} + + +void +AcpiOsReleaseLock ( + ACPI_SPINLOCK Handle, + ACPI_CPU_FLAGS Flags) +{ + DPRINT("AcpiOsReleaseLock %p\n",Handle); + AcpiOsSignalSemaphore (Handle, 1); +} + +ACPI_STATUS +AcpiOsSignal ( + UINT32 Function, + void *Info) +{ + + switch (Function) + { + case ACPI_SIGNAL_FATAL: + if (Info) + AcpiOsPrintf ("AcpiOsBreakpoint: %s ****\n", Info); + else + AcpiOsPrintf ("AcpiOsBreakpoint ****\n"); + break; + case ACPI_SIGNAL_BREAKPOINT: + if (Info) + AcpiOsPrintf ("AcpiOsBreakpoint: %s ****\n", Info); + else + AcpiOsPrintf ("AcpiOsBreakpoint ****\n"); + break; + } + + return (AE_OK); +} + + +ACPI_THREAD_ID +AcpiOsGetThreadId (void) +{ + return (ULONG)PsGetCurrentThreadId(); +} + +ACPI_STATUS +AcpiOsExecute ( + ACPI_EXECUTE_TYPE Type, + ACPI_OSD_EXEC_CALLBACK Function, + void *Context) +{ + DPRINT("AcpiOsExecute\n"); + + KeInsertQueueDpc(&AcpiDpc, (PVOID)Function, (PVOID)Context); + +#ifdef _MULTI_THREADED + //_beginthread (Function, (unsigned) 0, Context); +#endif + + return 0; +} + +UINT64 +AcpiOsGetTimer (void) +{ + DPRINT("AcpiOsGetTimer\n"); + LARGE_INTEGER Timer; + KeQueryTickCount(&Timer); + + return Timer.QuadPart; +} + +void +AcpiOsDerivePciId( + ACPI_HANDLE rhandle, + ACPI_HANDLE chandle, + ACPI_PCI_ID **PciId) +{ + DPRINT("AcpiOsDerivePciId\n"); + return; +} + +ACPI_STATUS +AcpiOsPredefinedOverride ( + const ACPI_PREDEFINED_NAMES *InitVal, + ACPI_STRING *NewVal) +{ + if (!InitVal || !NewVal) + return AE_BAD_PARAMETER; + + *NewVal = ACPI_OS_NAME; + DPRINT("AcpiOsPredefinedOverride\n"); + return AE_OK; +} + +ACPI_PHYSICAL_ADDRESS +AcpiOsGetRootPointer ( + void); + +ACPI_STATUS +AcpiOsTableOverride ( + ACPI_TABLE_HEADER *ExistingTable, + ACPI_TABLE_HEADER **NewTable) +{ + DPRINT("AcpiOsTableOverride\n"); + *NewTable = NULL; + return (AE_OK); +} + +ACPI_STATUS +AcpiOsValidateInterface ( + char *Interface) +{ + DPRINT("AcpiOsValidateInterface\n"); + return (AE_OK); +} + +ACPI_STATUS +AcpiOsValidateAddress ( + UINT8 SpaceId, + ACPI_PHYSICAL_ADDRESS Address, + ACPI_SIZE Length) +{ + DPRINT("AcpiOsValidateAddress\n"); + return (AE_OK); +} + +ACPI_PHYSICAL_ADDRESS +AcpiOsGetRootPointer ( + void) +{ + DPRINT("AcpiOsGetRootPointer\n"); + ACPI_PHYSICAL_ADDRESS pa = 0; + + AcpiFindRootPointer(&pa); + return pa; +} diff --git a/reactos/drivers/bus/acpi/pnp.c b/reactos/drivers/bus/acpi/pnp.c new file mode 100644 index 00000000000..c82a3905023 --- /dev/null +++ b/reactos/drivers/bus/acpi/pnp.c @@ -0,0 +1,586 @@ +#include + +#include + +#include +#include +#include + +#include +#define NDEBUG +#include + +#ifdef ALLOC_PRAGMA +#pragma alloc_text (PAGE, Bus_PnP) +#pragma alloc_text (PAGE, Bus_PlugInDevice) +#pragma alloc_text (PAGE, Bus_InitializePdo) +#pragma alloc_text (PAGE, Bus_UnPlugDevice) +#pragma alloc_text (PAGE, Bus_DestroyPdo) +#pragma alloc_text (PAGE, Bus_FDO_PnP) +#pragma alloc_text (PAGE, Bus_StartFdo) +#pragma alloc_text (PAGE, Bus_SendIrpSynchronously) +#endif + + +NTSTATUS +NTAPI +Bus_PnP ( + PDEVICE_OBJECT DeviceObject, + PIRP Irp + ) +{ + PIO_STACK_LOCATION irpStack; + NTSTATUS status; + PCOMMON_DEVICE_DATA commonData; + + PAGED_CODE (); + + irpStack = IoGetCurrentIrpStackLocation (Irp); + ASSERT (IRP_MJ_PNP == irpStack->MajorFunction); + + commonData = (PCOMMON_DEVICE_DATA) DeviceObject->DeviceExtension; + + + if (commonData->IsFDO) { + DPRINT("FDO %s IRP:0x%p\n", + PnPMinorFunctionString(irpStack->MinorFunction), + Irp); + // + // Request is for the bus FDO + // + status = Bus_FDO_PnP ( + DeviceObject, + Irp, + irpStack, + (PFDO_DEVICE_DATA) commonData); + } else { + DPRINT("PDO %s IRP: 0x%p\n", + PnPMinorFunctionString(irpStack->MinorFunction), + Irp); + // + // Request is for the child PDO. + // + status = Bus_PDO_PnP ( + DeviceObject, + Irp, + irpStack, + (PPDO_DEVICE_DATA) commonData); + } + + return status; +} + +NTSTATUS +Bus_FDO_PnP ( + PDEVICE_OBJECT DeviceObject, + PIRP Irp, + PIO_STACK_LOCATION IrpStack, + PFDO_DEVICE_DATA DeviceData + ) +{ + NTSTATUS status; + ULONG length, prevcount, numPdosPresent; + PLIST_ENTRY entry; + PPDO_DEVICE_DATA pdoData; + PDEVICE_RELATIONS relations, oldRelations; + + PAGED_CODE (); + + switch (IrpStack->MinorFunction) { + + case IRP_MN_START_DEVICE: + + status = Bus_StartFdo (DeviceData, Irp); + + + // + // We must now complete the IRP, since we stopped it in the + // completion routine with MORE_PROCESSING_REQUIRED. + // + + Irp->IoStatus.Status = status; + IoCompleteRequest (Irp, IO_NO_INCREMENT); + + return status; + + case IRP_MN_QUERY_STOP_DEVICE: + + // + // The PnP manager is trying to stop the device + // for resource rebalancing. + // + SET_NEW_PNP_STATE(DeviceData->Common, StopPending); + Irp->IoStatus.Status = STATUS_SUCCESS; + break; + + case IRP_MN_CANCEL_STOP_DEVICE: + + // + // The PnP Manager sends this IRP, at some point after an + // IRP_MN_QUERY_STOP_DEVICE, to inform the drivers for a + // device that the device will not be stopped for + // resource reconfiguration. + // + // + // First check to see whether you have received cancel-stop + // without first receiving a query-stop. This could happen if + // someone above us fails a query-stop and passes down the subsequent + // cancel-stop. + // + + if (StopPending == DeviceData->Common.DevicePnPState) + { + // + // We did receive a query-stop, so restore. + // + RESTORE_PREVIOUS_PNP_STATE(DeviceData->Common); + ASSERT(DeviceData->Common.DevicePnPState == Started); + } + Irp->IoStatus.Status = STATUS_SUCCESS; // We must not fail the IRP. + break; + + case IRP_MN_QUERY_DEVICE_RELATIONS: + + DPRINT("\tQueryDeviceRelation Type: %s\n", + DbgDeviceRelationString(\ + IrpStack->Parameters.QueryDeviceRelations.Type)); + + if (BusRelations != IrpStack->Parameters.QueryDeviceRelations.Type) { + // + // We don't support any other Device Relations + // + break; + } + + + ExAcquireFastMutex (&DeviceData->Mutex); + + oldRelations = (PDEVICE_RELATIONS) Irp->IoStatus.Information; + if (oldRelations) { + prevcount = oldRelations->Count; + if (!DeviceData->NumPDOs) { + // + // There is a device relations struct already present and we have + // nothing to add to it, so just call IoSkip and IoCall + // + ExReleaseFastMutex (&DeviceData->Mutex); + break; + } + } + else { + prevcount = 0; + } + + // + // Calculate the number of PDOs actually present on the bus + // + numPdosPresent = 0; + for (entry = DeviceData->ListOfPDOs.Flink; + entry != &DeviceData->ListOfPDOs; + entry = entry->Flink) { + pdoData = CONTAINING_RECORD (entry, PDO_DEVICE_DATA, Link); + numPdosPresent++; + } + + // + // Need to allocate a new relations structure and add our + // PDOs to it. + // + + length = sizeof(DEVICE_RELATIONS) + + ((numPdosPresent + prevcount) * sizeof (PDEVICE_OBJECT)) -1; + + relations = (PDEVICE_RELATIONS) ExAllocatePoolWithTag (PagedPool, + length, 'IPCA'); + + if (NULL == relations) { + // + // Fail the IRP + // + ExReleaseFastMutex (&DeviceData->Mutex); + Irp->IoStatus.Status = status = STATUS_INSUFFICIENT_RESOURCES; + IoCompleteRequest (Irp, IO_NO_INCREMENT); + return status; + + } + + // + // Copy in the device objects so far + // + if (prevcount) { + RtlCopyMemory (relations->Objects, oldRelations->Objects, + prevcount * sizeof (PDEVICE_OBJECT)); + } + + relations->Count = prevcount + numPdosPresent; + + // + // For each PDO present on this bus add a pointer to the device relations + // buffer, being sure to take out a reference to that object. + // The Plug & Play system will dereference the object when it is done + // with it and free the device relations buffer. + // + + for (entry = DeviceData->ListOfPDOs.Flink; + entry != &DeviceData->ListOfPDOs; + entry = entry->Flink) { + + pdoData = CONTAINING_RECORD (entry, PDO_DEVICE_DATA, Link); + relations->Objects[prevcount] = pdoData->Common.Self; + ObReferenceObject (pdoData->Common.Self); + prevcount++; + } + + DPRINT("\t#PDOs present = %d\n\t#PDOs reported = %d\n", + DeviceData->NumPDOs, relations->Count); + + // + // Replace the relations structure in the IRP with the new + // one. + // + if (oldRelations) { + ExFreePool (oldRelations); + } + Irp->IoStatus.Information = (ULONG_PTR) relations; + + ExReleaseFastMutex (&DeviceData->Mutex); + + // + // Set up and pass the IRP further down the stack + // + Irp->IoStatus.Status = STATUS_SUCCESS; + break; + + default: + + // + // In the default case we merely call the next driver. + // We must not modify Irp->IoStatus.Status or complete the IRP. + // + + break; + } + + IoSkipCurrentIrpStackLocation (Irp); + status = IoCallDriver (DeviceData->NextLowerDriver, Irp); + return STATUS_SUCCESS; +} + +NTSTATUS +Bus_StartFdo ( + PFDO_DEVICE_DATA FdoData, + PIRP Irp ) +{ + NTSTATUS status = STATUS_SUCCESS; + POWER_STATE powerState; + ACPI_STATUS AcpiStatus; + + PAGED_CODE (); + + FdoData->Common.DevicePowerState = PowerDeviceD0; + powerState.DeviceState = PowerDeviceD0; + PoSetPowerState ( FdoData->Common.Self, DevicePowerState, powerState ); + + SET_NEW_PNP_STATE(FdoData->Common, Started); + + AcpiStatus = AcpiInitializeSubsystem(); + if(ACPI_FAILURE(AcpiStatus)){ + DPRINT1("Unable to AcpiInitializeSubsystem\n"); + return STATUS_UNSUCCESSFUL; + } + + + AcpiStatus = AcpiInitializeTables(NULL, 16, 0); + if (ACPI_FAILURE(status)){ + DPRINT1("Unable to AcpiInitializeSubsystem\n"); + return STATUS_UNSUCCESSFUL; + } + + AcpiStatus = AcpiLoadTables(); + if(ACPI_FAILURE(AcpiStatus)){ + DPRINT1("Unable to AcpiLoadTables\n"); + AcpiTerminate(); + return STATUS_UNSUCCESSFUL; + } + + DPRINT("Acpi subsystem init\n"); + /* Initialize ACPI bus manager */ + AcpiStatus = acpi_init(); + if (!ACPI_SUCCESS(AcpiStatus)) { + DPRINT("acpi_init() failed with status 0x%X\n", AcpiStatus); + AcpiTerminate(); + return STATUS_UNSUCCESSFUL; + } + status = ACPIEnumerateDevices(FdoData); + + return status; +} + +NTSTATUS +Bus_SendIrpSynchronously ( + PDEVICE_OBJECT DeviceObject, + PIRP Irp + ) +{ + KEVENT event; + NTSTATUS status; + + PAGED_CODE(); + + KeInitializeEvent(&event, NotificationEvent, FALSE); + + IoCopyCurrentIrpStackLocationToNext(Irp); + + IoSetCompletionRoutine(Irp, + Bus_CompletionRoutine, + &event, + TRUE, + TRUE, + TRUE + ); + + status = IoCallDriver(DeviceObject, Irp); + + // + // Wait for lower drivers to be done with the Irp. + // Important thing to note here is when you allocate + // the memory for an event in the stack you must do a + // KernelMode wait instead of UserMode to prevent + // the stack from getting paged out. + // + + if (status == STATUS_PENDING) { + KeWaitForSingleObject(&event, + Executive, + KernelMode, + FALSE, + NULL + ); + status = Irp->IoStatus.Status; + } + + return status; +} + +NTSTATUS +Bus_CompletionRoutine( + PDEVICE_OBJECT DeviceObject, + PIRP Irp, + PVOID Context + ) +{ + UNREFERENCED_PARAMETER (DeviceObject); + + // + // If the lower driver didn't return STATUS_PENDING, we don't need to + // set the event because we won't be waiting on it. + // This optimization avoids grabbing the dispatcher lock and improves perf. + // + if (Irp->PendingReturned == TRUE) { + + KeSetEvent ((PKEVENT) Context, IO_NO_INCREMENT, FALSE); + } + return STATUS_MORE_PROCESSING_REQUIRED; // Keep this IRP +} + +NTSTATUS +Bus_DestroyPdo ( + PDEVICE_OBJECT Device, + PPDO_DEVICE_DATA PdoData + ) +{ + PAGED_CODE (); + + // + // BusEnum does not queue any irps at this time so we have nothing to do. + // + + // + // Free any resources. + // + + if (PdoData->HardwareIDs) { + ExFreePool (PdoData->HardwareIDs); + PdoData->HardwareIDs = NULL; + } + + DPRINT("\tDeleting PDO: 0x%p\n", Device); + IoDeleteDevice (Device); + return STATUS_SUCCESS; +} + + +VOID +Bus_InitializePdo ( + PDEVICE_OBJECT Pdo, + PFDO_DEVICE_DATA FdoData + ) +{ + PPDO_DEVICE_DATA pdoData; + int acpistate; + DEVICE_POWER_STATE ntState; + + PAGED_CODE (); + + pdoData = (PPDO_DEVICE_DATA) Pdo->DeviceExtension; + + DPRINT("pdo 0x%p, extension 0x%p\n", Pdo, pdoData); + + if (pdoData->AcpiHandle) + acpi_bus_get_power(pdoData->AcpiHandle, &acpistate); + else + acpistate = ACPI_STATE_D0; + + switch(acpistate) + { + case ACPI_STATE_D0: + ntState = PowerDeviceD0; + break; + case ACPI_STATE_D1: + ntState = PowerDeviceD1; + break; + case ACPI_STATE_D2: + ntState = PowerDeviceD2; + break; + case ACPI_STATE_D3: + ntState = PowerDeviceD3; + break; + default: + DPRINT1("Unknown power state (%d) returned by acpi\n",acpistate); + ntState = PowerDeviceUnspecified; + break; + } + + // + // Initialize the rest + // + pdoData->Common.IsFDO = FALSE; + pdoData->Common.Self = Pdo; + + pdoData->ParentFdo = FdoData->Common.Self; + + + INITIALIZE_PNP_STATE(pdoData->Common); + + pdoData->Common.DevicePowerState = ntState; + pdoData->Common.SystemPowerState = FdoData->Common.SystemPowerState; + + Pdo->Flags |= DO_POWER_PAGABLE; + + ExAcquireFastMutex (&FdoData->Mutex); + InsertTailList(&FdoData->ListOfPDOs, &pdoData->Link); + FdoData->NumPDOs++; + ExReleaseFastMutex (&FdoData->Mutex); + + // This should be the last step in initialization. + Pdo->Flags &= ~DO_DEVICE_INITIALIZING; + +} + +#if DBG + +PCHAR +PnPMinorFunctionString ( + UCHAR MinorFunction +) +{ + switch (MinorFunction) + { + case IRP_MN_START_DEVICE: + return "IRP_MN_START_DEVICE"; + case IRP_MN_QUERY_REMOVE_DEVICE: + return "IRP_MN_QUERY_REMOVE_DEVICE"; + case IRP_MN_REMOVE_DEVICE: + return "IRP_MN_REMOVE_DEVICE"; + case IRP_MN_CANCEL_REMOVE_DEVICE: + return "IRP_MN_CANCEL_REMOVE_DEVICE"; + case IRP_MN_STOP_DEVICE: + return "IRP_MN_STOP_DEVICE"; + case IRP_MN_QUERY_STOP_DEVICE: + return "IRP_MN_QUERY_STOP_DEVICE"; + case IRP_MN_CANCEL_STOP_DEVICE: + return "IRP_MN_CANCEL_STOP_DEVICE"; + case IRP_MN_QUERY_DEVICE_RELATIONS: + return "IRP_MN_QUERY_DEVICE_RELATIONS"; + case IRP_MN_QUERY_INTERFACE: + return "IRP_MN_QUERY_INTERFACE"; + case IRP_MN_QUERY_CAPABILITIES: + return "IRP_MN_QUERY_CAPABILITIES"; + case IRP_MN_QUERY_RESOURCES: + return "IRP_MN_QUERY_RESOURCES"; + case IRP_MN_QUERY_RESOURCE_REQUIREMENTS: + return "IRP_MN_QUERY_RESOURCE_REQUIREMENTS"; + case IRP_MN_QUERY_DEVICE_TEXT: + return "IRP_MN_QUERY_DEVICE_TEXT"; + case IRP_MN_FILTER_RESOURCE_REQUIREMENTS: + return "IRP_MN_FILTER_RESOURCE_REQUIREMENTS"; + case IRP_MN_READ_CONFIG: + return "IRP_MN_READ_CONFIG"; + case IRP_MN_WRITE_CONFIG: + return "IRP_MN_WRITE_CONFIG"; + case IRP_MN_EJECT: + return "IRP_MN_EJECT"; + case IRP_MN_SET_LOCK: + return "IRP_MN_SET_LOCK"; + case IRP_MN_QUERY_ID: + return "IRP_MN_QUERY_ID"; + case IRP_MN_QUERY_PNP_DEVICE_STATE: + return "IRP_MN_QUERY_PNP_DEVICE_STATE"; + case IRP_MN_QUERY_BUS_INFORMATION: + return "IRP_MN_QUERY_BUS_INFORMATION"; + case IRP_MN_DEVICE_USAGE_NOTIFICATION: + return "IRP_MN_DEVICE_USAGE_NOTIFICATION"; + case IRP_MN_SURPRISE_REMOVAL: + return "IRP_MN_SURPRISE_REMOVAL"; + case IRP_MN_QUERY_LEGACY_BUS_INFORMATION: + return "IRP_MN_QUERY_LEGACY_BUS_INFORMATION"; + default: + return "unknown_pnp_irp"; + } +} + +PCHAR +DbgDeviceRelationString( + DEVICE_RELATION_TYPE Type + ) +{ + switch (Type) + { + case BusRelations: + return "BusRelations"; + case EjectionRelations: + return "EjectionRelations"; + case RemovalRelations: + return "RemovalRelations"; + case TargetDeviceRelation: + return "TargetDeviceRelation"; + default: + return "UnKnown Relation"; + } +} + +PCHAR +DbgDeviceIDString( + BUS_QUERY_ID_TYPE Type + ) +{ + switch (Type) + { + case BusQueryDeviceID: + return "BusQueryDeviceID"; + case BusQueryHardwareIDs: + return "BusQueryHardwareIDs"; + case BusQueryCompatibleIDs: + return "BusQueryCompatibleIDs"; + case BusQueryInstanceID: + return "BusQueryInstanceID"; + case BusQueryDeviceSerialNumber: + return "BusQueryDeviceSerialNumber"; + default: + return "UnKnown ID"; + } +} + +#endif + + diff --git a/reactos/drivers/bus/acpi/power.c b/reactos/drivers/bus/acpi/power.c new file mode 100644 index 00000000000..2f7175c74ad --- /dev/null +++ b/reactos/drivers/bus/acpi/power.c @@ -0,0 +1,302 @@ +#include + +#include +#include + +#include +#include + +#define NDEBUG +#include + +NTSTATUS +NTAPI +Bus_Power ( + PDEVICE_OBJECT DeviceObject, + PIRP Irp + ) +{ + PIO_STACK_LOCATION irpStack; + NTSTATUS status; + PCOMMON_DEVICE_DATA commonData; + + status = STATUS_SUCCESS; + irpStack = IoGetCurrentIrpStackLocation (Irp); + ASSERT (IRP_MJ_POWER == irpStack->MajorFunction); + + commonData = (PCOMMON_DEVICE_DATA) DeviceObject->DeviceExtension; + + if (commonData->IsFDO) { + + DPRINT("FDO %s IRP:0x%p %s %s\n", + PowerMinorFunctionString(irpStack->MinorFunction), Irp, + DbgSystemPowerString(commonData->SystemPowerState), + DbgDevicePowerString(commonData->DevicePowerState)); + + + status = Bus_FDO_Power ((PFDO_DEVICE_DATA)DeviceObject->DeviceExtension, + Irp); + } else { + + DPRINT("PDO %s IRP:0x%p %s %s\n", + PowerMinorFunctionString(irpStack->MinorFunction), Irp, + DbgSystemPowerString(commonData->SystemPowerState), + DbgDevicePowerString(commonData->DevicePowerState)); + + status = Bus_PDO_Power ((PPDO_DEVICE_DATA)DeviceObject->DeviceExtension, + Irp); + } + + return status; +} + + +NTSTATUS +Bus_FDO_Power ( + PFDO_DEVICE_DATA Data, + PIRP Irp + ) +{ + NTSTATUS status = STATUS_SUCCESS; + POWER_STATE powerState; + POWER_STATE_TYPE powerType; + PIO_STACK_LOCATION stack; + ULONG AcpiState; + ACPI_STATUS AcpiStatus; + SYSTEM_POWER_STATE oldPowerState; + + stack = IoGetCurrentIrpStackLocation (Irp); + powerType = stack->Parameters.Power.Type; + powerState = stack->Parameters.Power.State; + + + if (stack->MinorFunction == IRP_MN_SET_POWER) { + DPRINT("\tRequest to set %s state to %s\n", + ((powerType == SystemPowerState) ? "System" : "Device"), + ((powerType == SystemPowerState) ? \ + DbgSystemPowerString(powerState.SystemState) :\ + DbgDevicePowerString(powerState.DeviceState))); + } + + if (powerType == SystemPowerState) + { + switch (powerState.SystemState) { + case PowerSystemSleeping1: + AcpiState = ACPI_STATE_S1; + break; + case PowerSystemSleeping2: + AcpiState = ACPI_STATE_S2; + break; + case PowerSystemSleeping3: + AcpiState = ACPI_STATE_S3; + break; + case PowerSystemHibernate: + AcpiState = ACPI_STATE_S4; + break; + case PowerSystemShutdown: + AcpiState = ACPI_STATE_S5; + break; + default: + AcpiState = ACPI_STATE_UNKNOWN; + ASSERT(FALSE); + break; + } + oldPowerState = Data->Common.SystemPowerState; + Data->Common.SystemPowerState = powerState.SystemState; + AcpiStatus = acpi_suspend(AcpiState); + if (!ACPI_SUCCESS(AcpiStatus)) { + DPRINT1("Failed to enter sleep state %d (Status 0x%X)\n", + AcpiState, AcpiStatus); + Data->Common.SystemPowerState = oldPowerState; + status = STATUS_UNSUCCESSFUL; + } + } + PoStartNextPowerIrp (Irp); + IoSkipCurrentIrpStackLocation(Irp); + status = PoCallDriver (Data->NextLowerDriver, Irp); + return status; +} + + +NTSTATUS +Bus_PDO_Power ( + PPDO_DEVICE_DATA PdoData, + PIRP Irp + ) +{ + NTSTATUS status; + PIO_STACK_LOCATION stack; + POWER_STATE powerState; + POWER_STATE_TYPE powerType; + ULONG error; + + stack = IoGetCurrentIrpStackLocation (Irp); + powerType = stack->Parameters.Power.Type; + powerState = stack->Parameters.Power.State; + + switch (stack->MinorFunction) { + case IRP_MN_SET_POWER: + + DPRINT("\tSetting %s power state to %s\n", + ((powerType == SystemPowerState) ? "System" : "Device"), + ((powerType == SystemPowerState) ? \ + DbgSystemPowerString(powerState.SystemState) : \ + DbgDevicePowerString(powerState.DeviceState))); + + switch (powerType) { + case DevicePowerState: + if (!PdoData->AcpiHandle || !acpi_bus_power_manageable(PdoData->AcpiHandle)) + { + PoSetPowerState(PdoData->Common.Self, DevicePowerState, powerState); + PdoData->Common.DevicePowerState = powerState.DeviceState; + status = STATUS_SUCCESS; + break; + } + + switch (powerState.DeviceState) + { + case PowerDeviceD0: + error = acpi_bus_set_power(PdoData->AcpiHandle, ACPI_STATE_D0); + break; + + case PowerDeviceD1: + error = acpi_bus_set_power(PdoData->AcpiHandle, ACPI_STATE_D1); + break; + + case PowerDeviceD2: + error = acpi_bus_set_power(PdoData->AcpiHandle, ACPI_STATE_D2); + break; + + case PowerDeviceD3: + error = acpi_bus_set_power(PdoData->AcpiHandle, ACPI_STATE_D3); + break; + + default: + error = 0; + break; + } + + if (ACPI_SUCCESS(error)) + { + PoSetPowerState(PdoData->Common.Self, DevicePowerState, powerState); + PdoData->Common.DevicePowerState = powerState.DeviceState; + status = STATUS_SUCCESS; + } + else + status = STATUS_UNSUCCESSFUL; + break; + + case SystemPowerState: + PdoData->Common.SystemPowerState = powerState.SystemState; + status = STATUS_SUCCESS; + break; + + default: + status = STATUS_NOT_SUPPORTED; + break; + } + break; + + case IRP_MN_QUERY_POWER: + status = STATUS_SUCCESS; + break; + + case IRP_MN_WAIT_WAKE: + // + // We cannot support wait-wake because we are root-enumerated + // driver, and our parent, the PnP manager, doesn't support wait-wake. + // + case IRP_MN_POWER_SEQUENCE: + default: + status = STATUS_NOT_SUPPORTED; + break; + } + + if (status != STATUS_NOT_SUPPORTED) { + + Irp->IoStatus.Status = status; + } + + PoStartNextPowerIrp(Irp); + status = Irp->IoStatus.Status; + IoCompleteRequest (Irp, IO_NO_INCREMENT); + + return status; +} + +#ifndef NDEBUG + +PCHAR +PowerMinorFunctionString ( + UCHAR MinorFunction +) +{ + switch (MinorFunction) + { + case IRP_MN_SET_POWER: + return "IRP_MN_SET_POWER"; + case IRP_MN_QUERY_POWER: + return "IRP_MN_QUERY_POWER"; + case IRP_MN_POWER_SEQUENCE: + return "IRP_MN_POWER_SEQUENCE"; + case IRP_MN_WAIT_WAKE: + return "IRP_MN_WAIT_WAKE"; + + default: + return "unknown_power_irp"; + } +} + +PCHAR +DbgSystemPowerString( + SYSTEM_POWER_STATE Type + ) +{ + switch (Type) + { + case PowerSystemUnspecified: + return "PowerSystemUnspecified"; + case PowerSystemWorking: + return "PowerSystemWorking"; + case PowerSystemSleeping1: + return "PowerSystemSleeping1"; + case PowerSystemSleeping2: + return "PowerSystemSleeping2"; + case PowerSystemSleeping3: + return "PowerSystemSleeping3"; + case PowerSystemHibernate: + return "PowerSystemHibernate"; + case PowerSystemShutdown: + return "PowerSystemShutdown"; + case PowerSystemMaximum: + return "PowerSystemMaximum"; + default: + return "UnKnown System Power State"; + } + } + +PCHAR +DbgDevicePowerString( + DEVICE_POWER_STATE Type + ) +{ + switch (Type) + { + case PowerDeviceUnspecified: + return "PowerDeviceUnspecified"; + case PowerDeviceD0: + return "PowerDeviceD0"; + case PowerDeviceD1: + return "PowerDeviceD1"; + case PowerDeviceD2: + return "PowerDeviceD2"; + case PowerDeviceD3: + return "PowerDeviceD3"; + case PowerDeviceMaximum: + return "PowerDeviceMaximum"; + default: + return "UnKnown Device Power State"; + } +} + +#endif From 6fdf4de02b39bc626e226fd1da587692371a81d2 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Wed, 24 Mar 2010 00:59:16 +0000 Subject: [PATCH 002/134] Fix build (1/x) svn path=/branches/ros-amd64-bringup/; revision=46384 --- reactos/hal/hal.rbuild | 8 +++++++- reactos/hal/halx86/hal_generic.rbuild | 28 +++++++++++++++++++++------ reactos/hal/halx86/halamd64.rbuild | 3 +++ 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/reactos/hal/hal.rbuild b/reactos/hal/hal.rbuild index b846b042bf5..5fcdc0a4621 100644 --- a/reactos/hal/hal.rbuild +++ b/reactos/hal/hal.rbuild @@ -2,7 +2,13 @@ - + + + + + + + diff --git a/reactos/hal/halx86/hal_generic.rbuild b/reactos/hal/halx86/hal_generic.rbuild index 98cb36b95a5..971ffc83896 100644 --- a/reactos/hal/halx86/hal_generic.rbuild +++ b/reactos/hal/halx86/hal_generic.rbuild @@ -74,22 +74,38 @@ sysbus.c beep.c - bios.c cmos.c dma.c display.c drive.c - misc.c - pic.c - portio.c - processor.c profil.c reboot.c spinlock.c sysinfo.c - systimer.S timer.c usage.c + + bios.c + misc.c + pic.c + trap.S + usage.c + + portio.c + systimer.S + v86.s + + + + + halinit.c + irq.S + misc.c + apic.c + systimer.S + usage.c + + halinit_up.c diff --git a/reactos/hal/halx86/halamd64.rbuild b/reactos/hal/halx86/halamd64.rbuild index a4d9eb771df..5deb29fb68e 100644 --- a/reactos/hal/halx86/halamd64.rbuild +++ b/reactos/hal/halx86/halamd64.rbuild @@ -1,5 +1,6 @@ + @@ -31,3 +32,5 @@ + + From 36a64ffd5ce2b7b3b952e23f54cfee20d667de1d Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Wed, 24 Mar 2010 02:21:59 +0000 Subject: [PATCH 003/134] [RBUILD] - Don't use -fno-set-stack-executable on amd64 svn path=/branches/ros-amd64-bringup/; revision=46387 --- reactos/tools/rbuild/backend/mingw/compilers/gcc.mak | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/tools/rbuild/backend/mingw/compilers/gcc.mak b/reactos/tools/rbuild/backend/mingw/compilers/gcc.mak index 1f2a09f7f98..73518d38bea 100644 --- a/reactos/tools/rbuild/backend/mingw/compilers/gcc.mak +++ b/reactos/tools/rbuild/backend/mingw/compilers/gcc.mak @@ -17,7 +17,7 @@ endif BUILTIN_CXXFLAGS+= -fno-optimize-sibling-calls # Add -fno-set-stack-executable required for x86/MinGW -ifneq (,$(filter $(ARCH),amd64 i386)) +ifneq (,$(filter $(ARCH), i386)) BUILTIN_CFLAGS+= -fno-set-stack-executable BUILTIN_CXXFLAGS+= -fno-set-stack-executable endif From a9fd1700ffc9125b86991f1f991ca753d9775bae Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Wed, 24 Mar 2010 02:23:27 +0000 Subject: [PATCH 004/134] [INTRIN_X86] - Add __stosq, __movsq, _bittest64 svn path=/branches/ros-amd64-bringup/; revision=46388 --- reactos/include/crt/mingw32/intrin_x86.h | 40 +++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/reactos/include/crt/mingw32/intrin_x86.h b/reactos/include/crt/mingw32/intrin_x86.h index 8a4fa76370d..f48822bf707 100644 --- a/reactos/include/crt/mingw32/intrin_x86.h +++ b/reactos/include/crt/mingw32/intrin_x86.h @@ -569,6 +569,18 @@ __INTRIN_INLINE void __stosd(unsigned long * Dest, const unsigned long Data, siz ); } +#ifdef _M_AMD64 +__INTRIN_INLINE void __stosq(unsigned __int64 * Dest, const unsigned __int64 Data, size_t Count) +{ + __asm__ __volatile__ + ( + "rep; stosq" : + [Dest] "=D" (Dest), [Count] "=c" (Count) : + "[Dest]" (Dest), "a" (Data), "[Count]" (Count) + ); +} +#endif + __INTRIN_INLINE void __movsb(unsigned char * Destination, const unsigned char * Source, size_t Count) { __asm__ __volatile__ @@ -599,6 +611,18 @@ __INTRIN_INLINE void __movsd(unsigned long * Destination, const unsigned long * ); } +#ifdef _M_AMD64 +__INTRIN_INLINE void __movsq(unsigned long * Destination, const unsigned long * Source, size_t Count) +{ + __asm__ __volatile__ + ( + "rep; movsq" : + [Destination] "=D" (Destination), [Source] "=S" (Source), [Count] "=c" (Count) : + "[Destination]" (Destination), "[Source]" (Source), "[Count]" (Count) + ); +} +#endif + #if defined(_M_AMD64) /*** GS segment addressing ***/ @@ -791,6 +815,20 @@ __INTRIN_INLINE unsigned char _bittest(const long * const a, const long b) return retval; } +#ifdef _M_AMD64 +__INTRIN_INLINE unsigned char _bittest64(const __int64 * const a, const __int64 b) +{ + unsigned char retval; + + if(__builtin_constant_p(b)) + __asm__("bt %[b], %[a]; setb %b[retval]" : [retval] "=q" (retval) : [a] "mr" (*(a + (b / 64))), [b] "Ir" (b % 64)); + else + __asm__("bt %[b], %[a]; setb %b[retval]" : [retval] "=q" (retval) : [a] "mr" (*a), [b] "r" (b)); + + return retval; +} +#endif + __INTRIN_INLINE unsigned char _bittestandcomplement(long * const a, const long b) { unsigned char retval; @@ -1420,4 +1458,4 @@ __INTRIN_INLINE void _mm_pause(void) #endif /* KJK_INTRIN_X86_H_ */ -/* EOF */ \ No newline at end of file +/* EOF */ From eb0e6e515d595f8826ae9408d8aeda959d2deebe Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Wed, 24 Mar 2010 03:32:38 +0000 Subject: [PATCH 005/134] [DDK] Merge changes from header branch [NDK] - Prevent PPEB from being redefined svn path=/branches/ros-amd64-bringup/; revision=46390 --- reactos/include/ddk/afilter.h | 22 +- reactos/include/ddk/bdasup.h | 262 +- reactos/include/ddk/csq.h | 2 + reactos/include/ddk/hidclass.h | 4 +- reactos/include/ddk/hidpi.h | 50 +- reactos/include/ddk/mcd.h | 18 +- reactos/include/ddk/miniport.h | 2 +- reactos/include/ddk/minitape.h | 8 +- reactos/include/ddk/ndis.h | 610 +- reactos/include/ddk/ntagp.h | 12 +- reactos/include/ddk/ntdd8042.h | 14 +- reactos/include/ddk/ntddk.h | 5600 ++++++++++---- reactos/include/ddk/ntifs.h | 4754 ++++++------ reactos/include/ddk/ntimage.h | 17 +- reactos/include/ddk/ntpoapi.h | 2 +- reactos/include/ddk/parallel.h | 36 +- reactos/include/ddk/scsiwmi.h | 18 +- reactos/include/ddk/smbus.h | 20 +- reactos/include/ddk/srb.h | 108 +- reactos/include/ddk/storport.h | 84 +- reactos/include/ddk/tdikrnl.h | 112 +- reactos/include/ddk/upssvc.h | 12 +- reactos/include/ddk/video.h | 290 +- reactos/include/ddk/videoagp.h | 20 +- reactos/include/ddk/wdm.h | 12106 +++++++++++++++++++++---------- reactos/include/ddk/wmilib.h | 38 +- reactos/include/ndk/ketypes.h | 23 - reactos/include/ndk/peb_teb.h | 5 + reactos/include/ndk/rtlfuncs.h | 24 +- 29 files changed, 15659 insertions(+), 8614 deletions(-) diff --git a/reactos/include/ddk/afilter.h b/reactos/include/ddk/afilter.h index 7997a7c9e81..53900bf2b6d 100644 --- a/reactos/include/ddk/afilter.h +++ b/reactos/include/ddk/afilter.h @@ -104,33 +104,33 @@ typedef struct _ARC_FILTER } ARC_FILTER,*PARC_FILTER; BOOLEAN -DDKAPI +NTAPI ArcCreateFilter( IN struct _NDIS_MINIPORT_BLOCK *Miniport, IN UCHAR AdapterAddress, OUT PARC_FILTER *Filter); VOID -DDKAPI +NTAPI ArcDeleteFilter( IN PARC_FILTER Filter); BOOLEAN -DDKAPI +NTAPI ArcNoteFilterOpenAdapter( IN PARC_FILTER Filter, IN NDIS_HANDLE NdisBindingHandle, OUT PNDIS_HANDLE NdisFilterHandle); NDIS_STATUS -DDKAPI +NTAPI ArcDeleteFilterOpenAdapter( IN PARC_FILTER Filter, IN NDIS_HANDLE NdisFilterHandle, IN PNDIS_REQUEST NdisRequest); NDIS_STATUS -DDKAPI +NTAPI ArcFilterAdjust( IN PARC_FILTER Filter, IN NDIS_HANDLE NdisFilterHandle, @@ -139,12 +139,12 @@ ArcFilterAdjust( IN BOOLEAN Set); VOID -DDKAPI +NTAPI ArcFilterDprIndicateReceiveComplete( IN PARC_FILTER Filter); VOID -DDKAPI +NTAPI ArcFilterDprIndicateReceive( IN PARC_FILTER Filter, IN PUCHAR pRawHeader, @@ -152,7 +152,7 @@ ArcFilterDprIndicateReceive( IN UINT Length); NDIS_STATUS -DDKAPI +NTAPI ArcFilterTransferData( IN PARC_FILTER Filter, IN NDIS_HANDLE MacReceiveContext, @@ -162,18 +162,18 @@ ArcFilterTransferData( OUT PUINT BytesTransfered); VOID -DDKAPI +NTAPI ArcFreeNdisPacket( IN PARC_PACKET Packet); VOID -DDKAPI +NTAPI ArcFilterDoIndication( IN PARC_FILTER Filter, IN PARC_PACKET Packet); VOID -DDKAPI +NTAPI ArcDestroyPacket( IN PARC_FILTER Filter, IN PARC_PACKET Packet); diff --git a/reactos/include/ddk/bdasup.h b/reactos/include/ddk/bdasup.h index 0bdd590d337..373ccdbdcbf 100644 --- a/reactos/include/ddk/bdasup.h +++ b/reactos/include/ddk/bdasup.h @@ -1,8 +1,12 @@ +#pragma once + +#if (NTDDI_VERSION >= NTDDI_WINXP) + #if defined(__cplusplus) extern "C" { #endif -/* Helper macro to enable gcc's extension. */ +/* Helper macro to enable gcc's extension. */ #ifndef __GNU_EXTENSION #ifdef __GNUC__ #define __GNU_EXTENSION __extension__ @@ -12,150 +16,190 @@ extern "C" { #endif #define STDMETHODCALLTYPE __stdcall + +#ifndef _WDMDDK_ typedef GUID *PGUID; +#endif /* Types */ -typedef struct _BDA_PIN_PAIRING -{ - ULONG ulInputPin; - ULONG ulOutputPin; - ULONG ulcMaxInputsPerOutput; - ULONG ulcMinInputsPerOutput; - ULONG ulcMaxOutputsPerInput; - ULONG ulcMinOutputsPerInput; - ULONG ulcTopologyJoints; - const ULONG *pTopologyJoints; +typedef ULONG BDA_TOPOLOGY_JOINT, *PBDA_TOPOLOGY_JOINT; + +typedef struct _BDA_PIN_PAIRING { + ULONG ulInputPin; + ULONG ulOutputPin; + ULONG ulcMaxInputsPerOutput; + ULONG ulcMinInputsPerOutput; + ULONG ulcMaxOutputsPerInput; + ULONG ulcMinOutputsPerInput; + ULONG ulcTopologyJoints; + const ULONG *pTopologyJoints; } BDA_PIN_PAIRING, *PBDA_PIN_PAIRING; -typedef struct _BDA_FILTER_TEMPLATE -{ - const KSFILTER_DESCRIPTOR *pFilterDescriptor; - ULONG ulcPinPairs; - const BDA_PIN_PAIRING *pPinPairs; +typedef struct _BDA_FILTER_TEMPLATE { + const KSFILTER_DESCRIPTOR *pFilterDescriptor; + ULONG ulcPinPairs; + const BDA_PIN_PAIRING *pPinPairs; } BDA_FILTER_TEMPLATE, *PBDA_FILTER_TEMPLATE; +typedef struct _KSM_PIN_PAIR { + KSMETHOD Method; + ULONG InputPinId; + ULONG OutputPinId; + ULONG Reserved; +} KSM_PIN_PAIR, * PKSM_PIN_PAIR; -typedef struct _KSM_PIN -{ - KSMETHOD Method; - __GNU_EXTENSION union - { - ULONG PinId; - ULONG PinType; - }; - ULONG Reserved; +typedef struct _KSM_PIN { + KSMETHOD Method; + __GNU_EXTENSION union { + ULONG PinId; + ULONG PinType; + }; + ULONG Reserved; } KSM_PIN, * PKSM_PIN; /* Functions */ -STDMETHODIMP_(NTSTATUS) BdaCheckChanges(IN PIRP Irp); -STDMETHODIMP_(NTSTATUS) BdaCommitChanges(IN PIRP Irp); +STDMETHODIMP_(NTSTATUS) +BdaCheckChanges( + IN PIRP Irp); -STDMETHODIMP_(NTSTATUS) BdaCreateFilterFactory( - IN PKSDEVICE pKSDevice, - IN const KSFILTER_DESCRIPTOR *pFilterDescriptor, - IN const BDA_FILTER_TEMPLATE *pBdaFilterTemplate); +STDMETHODIMP_(NTSTATUS) +BdaCommitChanges( + IN PIRP Irp); -STDMETHODIMP_(NTSTATUS) BdaCreateFilterFactoryEx( - IN PKSDEVICE pKSDevice, - IN const KSFILTER_DESCRIPTOR *pFilterDescriptor, - IN const BDA_FILTER_TEMPLATE *pBdaFilterTemplate, - OUT PKSFILTERFACTORY *ppKSFilterFactory); +STDMETHODIMP_(NTSTATUS) +BdaCreateFilterFactory( + IN PKSDEVICE pKSDevice, + IN const KSFILTER_DESCRIPTOR *pFilterDescriptor, + IN const BDA_FILTER_TEMPLATE *pBdaFilterTemplate); -STDMETHODIMP_(NTSTATUS) BdaCreatePin( - IN PKSFILTER pKSFilter, - IN ULONG ulPinType, - OUT ULONG *pulPinId); +STDMETHODIMP_(NTSTATUS) +BdaCreateFilterFactoryEx( + IN PKSDEVICE pKSDevice, + IN const KSFILTER_DESCRIPTOR *pFilterDescriptor, + IN const BDA_FILTER_TEMPLATE *pBdaFilterTemplate, + OUT PKSFILTERFACTORY *ppKSFilterFactory); -STDMETHODIMP_(NTSTATUS) BdaCreateTopology( - IN PKSFILTER pKSFilter, - IN ULONG InputPinId, - IN ULONG OutputPinId); +STDMETHODIMP_(NTSTATUS) +BdaCreatePin( + IN PKSFILTER pKSFilter, + IN ULONG ulPinType, + OUT ULONG *pulPinId); -STDMETHODIMP_(NTSTATUS) BdaDeletePin( - IN PKSFILTER pKSFilter, - IN ULONG *pulPinId); +STDMETHODIMP_(NTSTATUS) +BdaCreateTopology( + IN PKSFILTER pKSFilter, + IN ULONG InputPinId, + IN ULONG OutputPinId); -STDMETHODIMP_(NTSTATUS) BdaFilterFactoryUpdateCacheData( - IN PKSFILTERFACTORY pFilterFactory, - IN const KSFILTER_DESCRIPTOR *pFilterDescriptor OPTIONAL); +STDMETHODIMP_(NTSTATUS) +BdaDeletePin( + IN PKSFILTER pKSFilter, + IN ULONG *pulPinId); -STDMETHODIMP_(NTSTATUS) BdaGetChangeState( - IN PIRP Irp, - OUT BDA_CHANGE_STATE *pChangeState); +STDMETHODIMP_(NTSTATUS) +BdaFilterFactoryUpdateCacheData( + IN PKSFILTERFACTORY pFilterFactory, + IN const KSFILTER_DESCRIPTOR *pFilterDescriptor OPTIONAL); -STDMETHODIMP_(NTSTATUS) BdaInitFilter( - IN PKSFILTER pKSFilter, - IN const BDA_FILTER_TEMPLATE *pBdaFilterTemplate); +STDMETHODIMP_(NTSTATUS) +BdaGetChangeState( + IN PIRP Irp, + OUT BDA_CHANGE_STATE *pChangeState); -STDMETHODIMP_(NTSTATUS) BdaMethodCreatePin( - IN PIRP Irp, - IN KSMETHOD *pKSMethod, - OUT ULONG *pulPinFactoryID); +STDMETHODIMP_(NTSTATUS) +BdaInitFilter( + IN PKSFILTER pKSFilter, + IN const BDA_FILTER_TEMPLATE *pBdaFilterTemplate); -STDMETHODIMP_(NTSTATUS) BdaMethodCreateTopology( - IN PIRP Irp, - IN KSMETHOD *pKSMethod, - OPTIONAL PVOID pvIgnored); +STDMETHODIMP_(NTSTATUS) +BdaMethodCreatePin( + IN PIRP Irp, + IN KSMETHOD *pKSMethod, + OUT ULONG *pulPinFactoryID); -STDMETHODIMP_(NTSTATUS) BdaMethodDeletePin( - IN PIRP Irp, - IN KSMETHOD *pKSMethod, - OPTIONAL PVOID pvIgnored); +STDMETHODIMP_(NTSTATUS) +BdaMethodCreateTopology( + IN PIRP Irp, + IN KSMETHOD *pKSMethod, + OPTIONAL PVOID pvIgnored); -STDMETHODIMP_(NTSTATUS) BdaPropertyGetControllingPinId( - IN PIRP Irp, - IN KSP_BDA_NODE_PIN *pProperty, - OUT ULONG *pulControllingPinId); +STDMETHODIMP_(NTSTATUS) +BdaMethodDeletePin( + IN PIRP Irp, + IN KSMETHOD *pKSMethod, + OPTIONAL PVOID pvIgnored); -STDMETHODIMP_(NTSTATUS) BdaPropertyGetPinControl( - IN PIRP Irp, - IN KSPROPERTY *pKSProperty, - OUT ULONG *pulProperty); +STDMETHODIMP_(NTSTATUS) +BdaPropertyGetControllingPinId( + IN PIRP Irp, + IN KSP_BDA_NODE_PIN *pProperty, + OUT ULONG *pulControllingPinId); -STDMETHODIMP_(NTSTATUS) BdaPropertyNodeDescriptors( - IN PIRP Irp, - IN KSPROPERTY *pKSProperty, - OUT BDANODE_DESCRIPTOR *pNodeDescriptorProperty); +STDMETHODIMP_(NTSTATUS) +BdaPropertyGetPinControl( + IN PIRP Irp, + IN KSPROPERTY *pKSProperty, + OUT ULONG *pulProperty); -STDMETHODIMP_(NTSTATUS) BdaPropertyNodeEvents( - IN PIRP Irp, - IN KSP_NODE *pKSProperty, - OUT GUID *pguidProperty); +STDMETHODIMP_(NTSTATUS) +BdaPropertyNodeDescriptors( + IN PIRP Irp, + IN KSPROPERTY *pKSProperty, + OUT BDANODE_DESCRIPTOR *pNodeDescriptorProperty); -STDMETHODIMP_(NTSTATUS) BdaPropertyNodeMethods( - IN PIRP Irp, - IN KSP_NODE *pKSProperty, - OUT GUID *pguidProperty); +STDMETHODIMP_(NTSTATUS) +BdaPropertyNodeEvents( + IN PIRP Irp, + IN KSP_NODE *pKSProperty, + OUT GUID *pguidProperty); -STDMETHODIMP_(NTSTATUS) BdaPropertyNodeProperties( - IN PIRP Irp, - IN KSP_NODE *pKSProperty, - OUT GUID *pguidProperty); +STDMETHODIMP_(NTSTATUS) +BdaPropertyNodeMethods( + IN PIRP Irp, + IN KSP_NODE *pKSProperty, + OUT GUID *pguidProperty); -STDMETHODIMP_(NTSTATUS) BdaPropertyNodeTypes( - IN PIRP Irp, - IN KSPROPERTY *pKSProperty, - OUT ULONG *pulProperty); +STDMETHODIMP_(NTSTATUS) +BdaPropertyNodeProperties( + IN PIRP Irp, + IN KSP_NODE *pKSProperty, + OUT GUID *pguidProperty); -STDMETHODIMP_(NTSTATUS) BdaPropertyPinTypes( - IN PIRP Irp, - IN KSPROPERTY *pKSProperty, - OUT ULONG *pulProperty); +STDMETHODIMP_(NTSTATUS) +BdaPropertyNodeTypes( + IN PIRP Irp, + IN KSPROPERTY *pKSProperty, + OUT ULONG *pulProperty); -STDMETHODIMP_(NTSTATUS) BdaPropertyTemplateConnections( - IN PIRP Irp, - IN KSPROPERTY *pKSProperty, - OUT KSTOPOLOGY_CONNECTION *pConnectionProperty); +STDMETHODIMP_(NTSTATUS) +BdaPropertyPinTypes( + IN PIRP Irp, + IN KSPROPERTY *pKSProperty, + OUT ULONG *pulProperty); -STDMETHODIMP_(NTSTATUS) BdaStartChanges(IN PIRP Irp); -STDMETHODIMP_(NTSTATUS) BdaUninitFilter(IN PKSFILTER pKSFilter); +STDMETHODIMP_(NTSTATUS) +BdaPropertyTemplateConnections( + IN PIRP Irp, + IN KSPROPERTY *pKSProperty, + OUT KSTOPOLOGY_CONNECTION *pConnectionProperty); -STDMETHODIMP_(NTSTATUS) BdaValidateNodeProperty( - IN PIRP Irp, - IN KSPROPERTY *pKSProperty); +STDMETHODIMP_(NTSTATUS) +BdaStartChanges( + IN PIRP Irp); + +STDMETHODIMP_(NTSTATUS) +BdaUninitFilter( + IN PKSFILTER pKSFilter); + +STDMETHODIMP_(NTSTATUS) +BdaValidateNodeProperty( + IN PIRP Irp, + IN KSPROPERTY *pKSProperty); #if defined(__cplusplus) } #endif + +#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ diff --git a/reactos/include/ddk/csq.h b/reactos/include/ddk/csq.h index 99056f610a8..cf7b2c14ce3 100644 --- a/reactos/include/ddk/csq.h +++ b/reactos/include/ddk/csq.h @@ -229,9 +229,11 @@ typedef struct _IO_CSQ_IRP_CONTEXT { } * */ +#ifndef IO_TYPE_CSQ_EX typedef NTSTATUS (NTAPI *PIO_CSQ_INSERT_IRP_EX) (struct _IO_CSQ *Csq, PIRP Irp, PVOID InsertContext); +#endif /* * CANCEL-SAFE QUEUE DDIs diff --git a/reactos/include/ddk/hidclass.h b/reactos/include/ddk/hidclass.h index f269c03f4a2..c93bfb4a525 100644 --- a/reactos/include/ddk/hidclass.h +++ b/reactos/include/ddk/hidclass.h @@ -98,11 +98,11 @@ enum DeviceObjectState { DeviceObjectRemoved }; -typedef VOID (DDKAPI *PHID_STATUS_CHANGE)( +typedef VOID (NTAPI *PHID_STATUS_CHANGE)( PVOID Context, enum DeviceObjectState State); -typedef NTSTATUS (DDKAPI *PHIDP_GETCAPS)( +typedef NTSTATUS (NTAPI *PHIDP_GETCAPS)( IN PHIDP_PREPARSED_DATA PreparsedData, OUT PHIDP_CAPS Capabilities); diff --git a/reactos/include/ddk/hidpi.h b/reactos/include/ddk/hidpi.h index 63d3cf1f936..ca6d89141f8 100644 --- a/reactos/include/ddk/hidpi.h +++ b/reactos/include/ddk/hidpi.h @@ -69,7 +69,7 @@ typedef struct _HIDP_KEYBOARD_MODIFIER_STATE { } DUMMYUNIONNAME; } HIDP_KEYBOARD_MODIFIER_STATE, *PHIDP_KEYBOARD_MODIFIER_STATE; -typedef BOOLEAN (DDKAPI *PHIDP_INSERT_SCANCODES)( +typedef BOOLEAN (NTAPI *PHIDP_INSERT_SCANCODES)( IN PVOID Context, IN PCHAR NewScanCodes, IN ULONG Length); @@ -94,7 +94,7 @@ typedef struct _HIDD_CONFIGURATION { HIDAPI NTSTATUS -DDKAPI +NTAPI HidP_TranslateUsageAndPagesToI8042ScanCodes( IN PUSAGE_AND_PAGE ChangedUsageList, IN ULONG UsageListLength, @@ -105,7 +105,7 @@ HidP_TranslateUsageAndPagesToI8042ScanCodes( HIDAPI NTSTATUS -DDKAPI +NTAPI HidP_TranslateUsagesToI8042ScanCodes( IN PUSAGE ChangedUsageList, IN ULONG UsageListLength, @@ -313,14 +313,14 @@ typedef enum _HIDP_REPORT_TYPE { HIDAPI NTSTATUS -DDKAPI +NTAPI HidP_GetCaps( IN PHIDP_PREPARSED_DATA PreparsedData, OUT PHIDP_CAPS Capabilities); HIDAPI NTSTATUS -DDKAPI +NTAPI HidP_GetData( IN HIDP_REPORT_TYPE ReportType, OUT PHIDP_DATA DataList, @@ -331,7 +331,7 @@ HidP_GetData( HIDAPI NTSTATUS -DDKAPI +NTAPI HidP_GetExtendedAttributes( IN HIDP_REPORT_TYPE ReportType, IN USHORT DataIndex, @@ -341,7 +341,7 @@ HidP_GetExtendedAttributes( HIDAPI NTSTATUS -DDKAPI +NTAPI HidP_GetLinkCollectionNodes( OUT PHIDP_LINK_COLLECTION_NODE LinkCollectionNodes, IN OUT PULONG LinkCollectionNodesLength, @@ -349,7 +349,7 @@ HidP_GetLinkCollectionNodes( HIDAPI NTSTATUS -DDKAPI +NTAPI HidP_GetScaledUsageValue( IN HIDP_REPORT_TYPE ReportType, IN USAGE UsagePage, @@ -362,7 +362,7 @@ HidP_GetScaledUsageValue( HIDAPI NTSTATUS -DDKAPI +NTAPI HidP_GetSpecificButtonCaps( IN HIDP_REPORT_TYPE ReportType, IN USAGE UsagePage, @@ -374,7 +374,7 @@ HidP_GetSpecificButtonCaps( HIDAPI NTSTATUS -DDKAPI +NTAPI HidP_GetSpecificValueCaps( IN HIDP_REPORT_TYPE ReportType, IN USAGE UsagePage, @@ -386,7 +386,7 @@ HidP_GetSpecificValueCaps( HIDAPI NTSTATUS -DDKAPI +NTAPI HidP_GetUsages( IN HIDP_REPORT_TYPE ReportType, IN USAGE UsagePage, @@ -399,7 +399,7 @@ HidP_GetUsages( HIDAPI NTSTATUS -DDKAPI +NTAPI HidP_GetUsagesEx( IN HIDP_REPORT_TYPE ReportType, IN USHORT LinkCollection, @@ -411,7 +411,7 @@ HidP_GetUsagesEx( HIDAPI NTSTATUS -DDKAPI +NTAPI HidP_GetUsageValue( IN HIDP_REPORT_TYPE ReportType, IN USAGE UsagePage, @@ -424,7 +424,7 @@ HidP_GetUsageValue( HIDAPI NTSTATUS -DDKAPI +NTAPI HidP_GetUsageValueArray( IN HIDP_REPORT_TYPE ReportType, IN USAGE UsagePage, @@ -453,7 +453,7 @@ HidP_GetUsageValueArray( HIDAPI NTSTATUS -DDKAPI +NTAPI HidP_InitializeReportForID( IN HIDP_REPORT_TYPE ReportType, IN UCHAR ReportID, @@ -475,14 +475,14 @@ HidP_InitializeReportForID( HIDAPI ULONG -DDKAPI +NTAPI HidP_MaxDataListLength( IN HIDP_REPORT_TYPE ReportType, IN PHIDP_PREPARSED_DATA PreparsedData); HIDAPI ULONG -DDKAPI +NTAPI HidP_MaxUsageListLength( IN HIDP_REPORT_TYPE ReportType, IN USAGE UsagePage OPTIONAL, @@ -509,7 +509,7 @@ HidP_MaxUsageListLength( HIDAPI NTSTATUS -DDKAPI +NTAPI HidP_SetData( IN HIDP_REPORT_TYPE ReportType, IN PHIDP_DATA DataList, @@ -520,7 +520,7 @@ HidP_SetData( HIDAPI NTSTATUS -DDKAPI +NTAPI HidP_SetScaledUsageValue( IN HIDP_REPORT_TYPE ReportType, IN USAGE UsagePage, @@ -533,7 +533,7 @@ HidP_SetScaledUsageValue( HIDAPI NTSTATUS -DDKAPI +NTAPI HidP_SetUsages( IN HIDP_REPORT_TYPE ReportType, IN USAGE UsagePage, @@ -546,7 +546,7 @@ HidP_SetUsages( HIDAPI NTSTATUS -DDKAPI +NTAPI HidP_SetUsageValue( IN HIDP_REPORT_TYPE ReportType, IN USAGE UsagePage, @@ -559,7 +559,7 @@ HidP_SetUsageValue( HIDAPI NTSTATUS -DDKAPI +NTAPI HidP_SetUsageValueArray( IN HIDP_REPORT_TYPE ReportType, IN USAGE UsagePage, @@ -592,7 +592,7 @@ HidP_SetUsageValueArray( HIDAPI NTSTATUS -DDKAPI +NTAPI HidP_UnsetUsages( IN HIDP_REPORT_TYPE ReportType, IN USAGE UsagePage, @@ -605,7 +605,7 @@ HidP_UnsetUsages( HIDAPI NTSTATUS -DDKAPI +NTAPI HidP_UsageAndPageListDifference( IN PUSAGE_AND_PAGE PreviousUsageList, IN PUSAGE_AND_PAGE CurrentUsageList, @@ -615,7 +615,7 @@ HidP_UsageAndPageListDifference( HIDAPI NTSTATUS -DDKAPI +NTAPI HidP_UsageListDifference( IN PUSAGE PreviousUsageList, IN PUSAGE CurrentUsageList, diff --git a/reactos/include/ddk/mcd.h b/reactos/include/ddk/mcd.h index cb4a1a4f032..eb3e5427bd4 100644 --- a/reactos/include/ddk/mcd.h +++ b/reactos/include/ddk/mcd.h @@ -51,7 +51,7 @@ extern "C" { CHANGERAPI PVOID -DDKAPI +NTAPI ChangerClassAllocatePool( IN POOL_TYPE PoolType, IN ULONG NumberOfBytes); @@ -64,13 +64,13 @@ ChangerClassDebugPrint( CHANGERAPI PVOID -DDKAPI +NTAPI ChangerClassFreePool( IN PVOID PoolToFree); CHANGERAPI NTSTATUS -DDKAPI +NTAPI ChangerClassSendSrbSynchronous( IN PDEVICE_OBJECT DeviceObject, IN PSCSI_REQUEST_BLOCK Srb, @@ -79,27 +79,27 @@ ChangerClassSendSrbSynchronous( IN BOOLEAN WriteToDevice); -typedef NTSTATUS DDKAPI +typedef NTSTATUS NTAPI (*CHANGER_INITIALIZE)( IN PDEVICE_OBJECT DeviceObject); -typedef ULONG DDKAPI +typedef ULONG NTAPI (*CHANGER_EXTENSION_SIZE)( VOID); -typedef VOID DDKAPI +typedef VOID NTAPI (*CHANGER_ERROR_ROUTINE)( PDEVICE_OBJECT DeviceObject, PSCSI_REQUEST_BLOCK Srb, NTSTATUS *Status, BOOLEAN *Retry); -typedef NTSTATUS DDKAPI +typedef NTSTATUS NTAPI (*CHANGER_COMMAND_ROUTINE)( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp); -typedef NTSTATUS DDKAPI +typedef NTSTATUS NTAPI (*CHANGER_PERFORM_DIAGNOSTICS)( IN PDEVICE_OBJECT DeviceObject, OUT PWMI_CHANGER_PROBLEM_DEVICE_ERROR ChangerDeviceError); @@ -125,7 +125,7 @@ typedef struct _MCD_INIT_DATA { CHANGERAPI NTSTATUS -DDKAPI +NTAPI ChangerClassInitialize( IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath, diff --git a/reactos/include/ddk/miniport.h b/reactos/include/ddk/miniport.h index 59fcc52a16e..0191e605a2b 100644 --- a/reactos/include/ddk/miniport.h +++ b/reactos/include/ddk/miniport.h @@ -59,7 +59,7 @@ typedef struct _VIDEO_ACCESS_RANGE { #endif typedef VOID -(DDKAPI *PBANKED_SECTION_ROUTINE)( +(NTAPI *PBANKED_SECTION_ROUTINE)( IN ULONG ReadBank, IN ULONG WriteBank, IN PVOID Context); diff --git a/reactos/include/ddk/minitape.h b/reactos/include/ddk/minitape.h index d8f7532f32e..43b1b030a9b 100644 --- a/reactos/include/ddk/minitape.h +++ b/reactos/include/ddk/minitape.h @@ -159,24 +159,24 @@ typedef struct _MODE_CAPABILITIES_PAGE { UCHAR Reserved11[2]; } MODE_CAPABILITIES_PAGE, *PMODE_CAPABILITIES_PAGE; -typedef BOOLEAN DDKAPI +typedef BOOLEAN NTAPI (*TAPE_VERIFY_INQUIRY_ROUTINE)( IN PINQUIRYDATA InquiryData, IN PMODE_CAPABILITIES_PAGE ModeCapabilitiesPage); -typedef VOID DDKAPI +typedef VOID NTAPI (*TAPE_EXTENSION_INIT_ROUTINE)( IN PVOID MinitapeExtension, IN PINQUIRYDATA InquiryData, IN PMODE_CAPABILITIES_PAGE ModeCapabilitiesPage); -typedef VOID DDKAPI +typedef VOID NTAPI (*TAPE_ERROR_ROUTINE)( IN PVOID MinitapeExtension, IN PSCSI_REQUEST_BLOCK Srb, IN OUT PTAPE_STATUS TapeStatus); -typedef TAPE_STATUS DDKAPI +typedef TAPE_STATUS NTAPI (*TAPE_PROCESS_COMMAND_ROUTINE)( IN OUT PVOID MinitapeExtension, IN OUT PVOID CommandExtension, diff --git a/reactos/include/ddk/ndis.h b/reactos/include/ddk/ndis.h index b08fb683b8c..da301b11042 100644 --- a/reactos/include/ddk/ndis.h +++ b/reactos/include/ddk/ndis.h @@ -268,7 +268,7 @@ typedef struct _LOCK_STATE { /* Timer */ typedef VOID -(DDKAPI *PNDIS_TIMER_FUNCTION)( +(NTAPI *PNDIS_TIMER_FUNCTION)( IN PVOID SystemSpecific1, IN PVOID FunctionContext, IN PVOID SystemSpecific2, @@ -626,16 +626,16 @@ typedef struct _NDIS_WAN_LINE_UP { typedef VOID -(DDKAPI *ADAPTER_SHUTDOWN_HANDLER)( +(NTAPI *ADAPTER_SHUTDOWN_HANDLER)( IN PVOID ShutdownContext); typedef NTSTATUS -(DDKAPI *TDI_REGISTER_CALLBACK)( +(NTAPI *TDI_REGISTER_CALLBACK)( IN PUNICODE_STRING DeviceName, OUT HANDLE* TdiHandle); typedef NTSTATUS -(DDKAPI *TDI_PNP_HANDLER)( +(NTAPI *TDI_PNP_HANDLER)( IN PUNICODE_STRING UpperComponent, IN PUNICODE_STRING LowerComponent, IN PUNICODE_STRING BindList, @@ -1057,88 +1057,88 @@ typedef struct _WAN_CO_LINKPARAMS { /* Call Manager */ typedef VOID -(DDKAPI *CM_ACTIVATE_VC_COMPLETE_HANDLER)( +(NTAPI *CM_ACTIVATE_VC_COMPLETE_HANDLER)( IN NDIS_STATUS Status, IN NDIS_HANDLE CallMgrVcContext, IN PCO_CALL_PARAMETERS CallParameters); typedef NDIS_STATUS -(DDKAPI *CM_ADD_PARTY_HANDLER)( +(NTAPI *CM_ADD_PARTY_HANDLER)( IN NDIS_HANDLE CallMgrVcContext, IN OUT PCO_CALL_PARAMETERS CallParameters, IN NDIS_HANDLE NdisPartyHandle, OUT PNDIS_HANDLE CallMgrPartyContext); typedef NDIS_STATUS -(DDKAPI *CM_CLOSE_AF_HANDLER)( +(NTAPI *CM_CLOSE_AF_HANDLER)( IN NDIS_HANDLE CallMgrAfContext); typedef NDIS_STATUS -(DDKAPI *CM_CLOSE_CALL_HANDLER)( +(NTAPI *CM_CLOSE_CALL_HANDLER)( IN NDIS_HANDLE CallMgrVcContext, IN NDIS_HANDLE CallMgrPartyContext OPTIONAL, IN PVOID CloseData OPTIONAL, IN UINT Size OPTIONAL); typedef NDIS_STATUS -(DDKAPI *CM_DEREG_SAP_HANDLER)( +(NTAPI *CM_DEREG_SAP_HANDLER)( IN NDIS_HANDLE CallMgrSapContext); typedef VOID -(DDKAPI *CM_DEACTIVATE_VC_COMPLETE_HANDLER)( +(NTAPI *CM_DEACTIVATE_VC_COMPLETE_HANDLER)( IN NDIS_STATUS Status, IN NDIS_HANDLE CallMgrVcContext); typedef NDIS_STATUS -(DDKAPI *CM_DROP_PARTY_HANDLER)( +(NTAPI *CM_DROP_PARTY_HANDLER)( IN NDIS_HANDLE CallMgrPartyContext, IN PVOID CloseData OPTIONAL, IN UINT Size OPTIONAL); typedef VOID -(DDKAPI *CM_INCOMING_CALL_COMPLETE_HANDLER)( +(NTAPI *CM_INCOMING_CALL_COMPLETE_HANDLER)( IN NDIS_STATUS Status, IN NDIS_HANDLE CallMgrVcContext, IN PCO_CALL_PARAMETERS CallParameters); typedef NDIS_STATUS -(DDKAPI *CM_MAKE_CALL_HANDLER)( +(NTAPI *CM_MAKE_CALL_HANDLER)( IN NDIS_HANDLE CallMgrVcContext, IN OUT PCO_CALL_PARAMETERS CallParameters, IN NDIS_HANDLE NdisPartyHandle OPTIONAL, OUT PNDIS_HANDLE CallMgrPartyContext OPTIONAL); typedef NDIS_STATUS -(DDKAPI *CM_MODIFY_CALL_QOS_HANDLER)( +(NTAPI *CM_MODIFY_CALL_QOS_HANDLER)( IN NDIS_HANDLE CallMgrVcContext, IN PCO_CALL_PARAMETERS CallParameters); typedef NDIS_STATUS -(DDKAPI *CM_OPEN_AF_HANDLER)( +(NTAPI *CM_OPEN_AF_HANDLER)( IN NDIS_HANDLE CallMgrBindingContext, IN PCO_ADDRESS_FAMILY AddressFamily, IN NDIS_HANDLE NdisAfHandle, OUT PNDIS_HANDLE CallMgrAfContext); typedef NDIS_STATUS -(DDKAPI *CM_REG_SAP_HANDLER)( +(NTAPI *CM_REG_SAP_HANDLER)( IN NDIS_HANDLE CallMgrAfContext, IN PCO_SAP Sap, IN NDIS_HANDLE NdisSapHandle, OUT PNDIS_HANDLE CallMgrSapContext); typedef NDIS_STATUS -(DDKAPI *CO_CREATE_VC_HANDLER)( +(NTAPI *CO_CREATE_VC_HANDLER)( IN NDIS_HANDLE ProtocolAfContext, IN NDIS_HANDLE NdisVcHandle, OUT PNDIS_HANDLE ProtocolVcContext); typedef NDIS_STATUS -(DDKAPI *CO_DELETE_VC_HANDLER)( +(NTAPI *CO_DELETE_VC_HANDLER)( IN NDIS_HANDLE ProtocolVcContext); typedef VOID -(DDKAPI *CO_REQUEST_COMPLETE_HANDLER)( +(NTAPI *CO_REQUEST_COMPLETE_HANDLER)( IN NDIS_STATUS Status, IN NDIS_HANDLE ProtocolAfContext OPTIONAL, IN NDIS_HANDLE ProtocolVcContext OPTIONAL, @@ -1146,7 +1146,7 @@ typedef VOID IN PNDIS_REQUEST NdisRequest); typedef NDIS_STATUS -(DDKAPI *CO_REQUEST_HANDLER)( +(NTAPI *CO_REQUEST_HANDLER)( IN NDIS_HANDLE ProtocolAfContext, IN NDIS_HANDLE ProtocolVcContext OPTIONAL, IN NDIS_HANDLE ProtocolPartyContext OPTIONAL, @@ -1185,80 +1185,80 @@ typedef VOID (*CL_OPEN_AF_COMPLETE_HANDLER)( IN NDIS_HANDLE NdisAfHandle); typedef VOID -(DDKAPI *CL_CLOSE_AF_COMPLETE_HANDLER)( +(NTAPI *CL_CLOSE_AF_COMPLETE_HANDLER)( IN NDIS_STATUS Status, IN NDIS_HANDLE ProtocolAfContext); typedef VOID -(DDKAPI *CL_REG_SAP_COMPLETE_HANDLER)( +(NTAPI *CL_REG_SAP_COMPLETE_HANDLER)( IN NDIS_STATUS Status, IN NDIS_HANDLE ProtocolSapContext, IN PCO_SAP Sap, IN NDIS_HANDLE NdisSapHandle); typedef VOID -(DDKAPI *CL_DEREG_SAP_COMPLETE_HANDLER)( +(NTAPI *CL_DEREG_SAP_COMPLETE_HANDLER)( IN NDIS_STATUS Status, IN NDIS_HANDLE ProtocolSapContext); typedef VOID -(DDKAPI *CL_MAKE_CALL_COMPLETE_HANDLER)( +(NTAPI *CL_MAKE_CALL_COMPLETE_HANDLER)( IN NDIS_STATUS Status, IN NDIS_HANDLE ProtocolVcContext, IN NDIS_HANDLE NdisPartyHandle OPTIONAL, IN PCO_CALL_PARAMETERS CallParameters); typedef VOID -(DDKAPI *CL_MODIFY_CALL_QOS_COMPLETE_HANDLER)( +(NTAPI *CL_MODIFY_CALL_QOS_COMPLETE_HANDLER)( IN NDIS_STATUS Status, IN NDIS_HANDLE ProtocolVcContext, IN PCO_CALL_PARAMETERS CallParameters); typedef VOID -(DDKAPI *CL_CLOSE_CALL_COMPLETE_HANDLER)( +(NTAPI *CL_CLOSE_CALL_COMPLETE_HANDLER)( IN NDIS_STATUS Status, IN NDIS_HANDLE ProtocolVcContext, IN NDIS_HANDLE ProtocolPartyContext OPTIONAL); typedef VOID -(DDKAPI *CL_ADD_PARTY_COMPLETE_HANDLER)( +(NTAPI *CL_ADD_PARTY_COMPLETE_HANDLER)( IN NDIS_STATUS Status, IN NDIS_HANDLE ProtocolPartyContext, IN NDIS_HANDLE NdisPartyHandle, IN PCO_CALL_PARAMETERS CallParameters); typedef VOID -(DDKAPI *CL_DROP_PARTY_COMPLETE_HANDLER)( +(NTAPI *CL_DROP_PARTY_COMPLETE_HANDLER)( IN NDIS_STATUS Status, IN NDIS_HANDLE ProtocolPartyContext); typedef NDIS_STATUS -(DDKAPI *CL_INCOMING_CALL_HANDLER)( +(NTAPI *CL_INCOMING_CALL_HANDLER)( IN NDIS_HANDLE ProtocolSapContext, IN NDIS_HANDLE ProtocolVcContext, IN OUT PCO_CALL_PARAMETERS CallParameters); typedef VOID -(DDKAPI *CL_INCOMING_CALL_QOS_CHANGE_HANDLER)( +(NTAPI *CL_INCOMING_CALL_QOS_CHANGE_HANDLER)( IN NDIS_HANDLE ProtocolVcContext, IN PCO_CALL_PARAMETERS CallParameters); typedef VOID -(DDKAPI *CL_INCOMING_CLOSE_CALL_HANDLER)( +(NTAPI *CL_INCOMING_CLOSE_CALL_HANDLER)( IN NDIS_STATUS CloseStatus, IN NDIS_HANDLE ProtocolVcContext, IN PVOID CloseData OPTIONAL, IN UINT Size OPTIONAL); typedef VOID -(DDKAPI *CL_INCOMING_DROP_PARTY_HANDLER)( +(NTAPI *CL_INCOMING_DROP_PARTY_HANDLER)( IN NDIS_STATUS DropStatus, IN NDIS_HANDLE ProtocolPartyContext, IN PVOID CloseData OPTIONAL, IN UINT Size OPTIONAL); typedef VOID -(DDKAPI *CL_CALL_CONNECTED_HANDLER)( +(NTAPI *CL_CALL_CONNECTED_HANDLER)( IN NDIS_HANDLE ProtocolVcContext); @@ -1293,64 +1293,64 @@ typedef struct _NDIS_CLIENT_CHARACTERISTICS { /* Prototypes for NDIS 3.0 protocol characteristics */ typedef VOID -(DDKAPI *OPEN_ADAPTER_COMPLETE_HANDLER)( +(NTAPI *OPEN_ADAPTER_COMPLETE_HANDLER)( IN NDIS_HANDLE ProtocolBindingContext, IN NDIS_STATUS Status, IN NDIS_STATUS OpenErrorStatus); typedef VOID -(DDKAPI *CLOSE_ADAPTER_COMPLETE_HANDLER)( +(NTAPI *CLOSE_ADAPTER_COMPLETE_HANDLER)( IN NDIS_HANDLE ProtocolBindingContext, IN NDIS_STATUS Status); typedef VOID -(DDKAPI *RESET_COMPLETE_HANDLER)( +(NTAPI *RESET_COMPLETE_HANDLER)( IN NDIS_HANDLE ProtocolBindingContext, IN NDIS_STATUS Status); typedef VOID -(DDKAPI *REQUEST_COMPLETE_HANDLER)( +(NTAPI *REQUEST_COMPLETE_HANDLER)( IN NDIS_HANDLE ProtocolBindingContext, IN PNDIS_REQUEST NdisRequest, IN NDIS_STATUS Status); typedef VOID -(DDKAPI *STATUS_HANDLER)( +(NTAPI *STATUS_HANDLER)( IN NDIS_HANDLE ProtocolBindingContext, IN NDIS_STATUS GeneralStatus, IN PVOID StatusBuffer, IN UINT StatusBufferSize); typedef VOID -(DDKAPI *STATUS_COMPLETE_HANDLER)( +(NTAPI *STATUS_COMPLETE_HANDLER)( IN NDIS_HANDLE ProtocolBindingContext); typedef VOID -(DDKAPI *SEND_COMPLETE_HANDLER)( +(NTAPI *SEND_COMPLETE_HANDLER)( IN NDIS_HANDLE ProtocolBindingContext, IN PNDIS_PACKET Packet, IN NDIS_STATUS Status); typedef VOID -(DDKAPI *WAN_SEND_COMPLETE_HANDLER)( +(NTAPI *WAN_SEND_COMPLETE_HANDLER)( IN NDIS_HANDLE ProtocolBindingContext, IN PNDIS_WAN_PACKET Packet, IN NDIS_STATUS Status); typedef VOID -(DDKAPI *TRANSFER_DATA_COMPLETE_HANDLER)( +(NTAPI *TRANSFER_DATA_COMPLETE_HANDLER)( IN NDIS_HANDLE ProtocolBindingContext, IN PNDIS_PACKET Packet, IN NDIS_STATUS Status, IN UINT BytesTransferred); typedef VOID -(DDKAPI *WAN_TRANSFER_DATA_COMPLETE_HANDLER)( +(NTAPI *WAN_TRANSFER_DATA_COMPLETE_HANDLER)( VOID); typedef NDIS_STATUS -(DDKAPI *RECEIVE_HANDLER)( +(NTAPI *RECEIVE_HANDLER)( IN NDIS_HANDLE ProtocolBindingContext, IN NDIS_HANDLE MacReceiveContext, IN PVOID HeaderBuffer, @@ -1360,13 +1360,13 @@ typedef NDIS_STATUS IN UINT PacketSize); typedef NDIS_STATUS -(DDKAPI *WAN_RECEIVE_HANDLER)( +(NTAPI *WAN_RECEIVE_HANDLER)( IN NDIS_HANDLE NdisLinkHandle, IN PUCHAR Packet, IN ULONG PacketSize); typedef VOID -(DDKAPI *RECEIVE_COMPLETE_HANDLER)( +(NTAPI *RECEIVE_COMPLETE_HANDLER)( IN NDIS_HANDLE ProtocolBindingContext); @@ -1409,12 +1409,12 @@ typedef struct _NDIS30_PROTOCOL_CHARACTERISTICS { /* Prototypes for NDIS 4.0 protocol characteristics */ typedef INT -(DDKAPI *RECEIVE_PACKET_HANDLER)( +(NTAPI *RECEIVE_PACKET_HANDLER)( IN NDIS_HANDLE ProtocolBindingContext, IN PNDIS_PACKET Packet); typedef VOID -(DDKAPI *BIND_HANDLER)( +(NTAPI *BIND_HANDLER)( OUT PNDIS_STATUS Status, IN NDIS_HANDLE BindContext, IN PNDIS_STRING DeviceName, @@ -1422,18 +1422,18 @@ typedef VOID IN PVOID SystemSpecific2); typedef VOID -(DDKAPI *UNBIND_HANDLER)( +(NTAPI *UNBIND_HANDLER)( OUT PNDIS_STATUS Status, IN NDIS_HANDLE ProtocolBindingContext, IN NDIS_HANDLE UnbindContext); typedef NDIS_STATUS -(DDKAPI *PNP_EVENT_HANDLER)( +(NTAPI *PNP_EVENT_HANDLER)( IN NDIS_HANDLE ProtocolBindingContext, IN PNET_PNP_EVENT NetPnPEvent); typedef VOID -(DDKAPI *UNLOAD_PROTOCOL_HANDLER)( +(NTAPI *UNLOAD_PROTOCOL_HANDLER)( VOID); @@ -1468,13 +1468,13 @@ typedef struct _NDIS40_PROTOCOL_CHARACTERISTICS { /* Prototypes for NDIS 5.0 protocol characteristics */ typedef VOID -(DDKAPI *CO_SEND_COMPLETE_HANDLER)( +(NTAPI *CO_SEND_COMPLETE_HANDLER)( IN NDIS_STATUS Status, IN NDIS_HANDLE ProtocolVcContext, IN PNDIS_PACKET Packet); typedef VOID -(DDKAPI *CO_STATUS_HANDLER)( +(NTAPI *CO_STATUS_HANDLER)( IN NDIS_HANDLE ProtocolBindingContext, IN NDIS_HANDLE ProtocolVcContext OPTIONAL, IN NDIS_STATUS GeneralStatus, @@ -1482,13 +1482,13 @@ typedef VOID IN UINT StatusBufferSize); typedef UINT -(DDKAPI *CO_RECEIVE_PACKET_HANDLER)( +(NTAPI *CO_RECEIVE_PACKET_HANDLER)( IN NDIS_HANDLE ProtocolBindingContext, IN NDIS_HANDLE ProtocolVcContext, IN PNDIS_PACKET Packet); typedef VOID -(DDKAPI *CO_AF_REGISTER_NOTIFY_HANDLER)( +(NTAPI *CO_AF_REGISTER_NOTIFY_HANDLER)( IN NDIS_HANDLE ProtocolBindingContext, IN PCO_ADDRESS_FAMILY AddressFamily); @@ -1538,7 +1538,7 @@ typedef struct _NDIS_PROTOCOL_CHARACTERISTICS { NDISAPI VOID -DDKAPI +NTAPI NdisAllocateBuffer( OUT PNDIS_STATUS Status, OUT PNDIS_BUFFER *Buffer, @@ -1549,7 +1549,7 @@ NdisAllocateBuffer( NDISAPI VOID -DDKAPI +NTAPI NdisAllocateBufferPool( OUT PNDIS_STATUS Status, OUT PNDIS_HANDLE PoolHandle, @@ -1557,7 +1557,7 @@ NdisAllocateBufferPool( NDISAPI VOID -DDKAPI +NTAPI NdisAllocatePacket( OUT PNDIS_STATUS Status, OUT PNDIS_PACKET *Packet, @@ -1565,7 +1565,7 @@ NdisAllocatePacket( NDISAPI VOID -DDKAPI +NTAPI NdisAllocatePacketPool( OUT PNDIS_STATUS Status, OUT PNDIS_HANDLE PoolHandle, @@ -1574,7 +1574,7 @@ NdisAllocatePacketPool( NDISAPI VOID -DDKAPI +NTAPI NdisCopyBuffer( OUT PNDIS_STATUS Status, OUT PNDIS_BUFFER *Buffer, @@ -1585,7 +1585,7 @@ NdisCopyBuffer( NDISAPI VOID -DDKAPI +NTAPI NdisCopyFromPacketToPacket( IN PNDIS_PACKET Destination, IN UINT DestinationOffset, @@ -1626,7 +1626,7 @@ NdisCopyFromPacketToPacket( NDISAPI VOID -DDKAPI +NTAPI NdisDprAllocatePacket( OUT PNDIS_STATUS Status, OUT PNDIS_PACKET *Packet, @@ -1634,7 +1634,7 @@ NdisDprAllocatePacket( NDISAPI VOID -DDKAPI +NTAPI NdisDprAllocatePacketNonInterlocked( OUT PNDIS_STATUS Status, OUT PNDIS_PACKET *Packet, @@ -1642,96 +1642,96 @@ NdisDprAllocatePacketNonInterlocked( NDISAPI VOID -DDKAPI +NTAPI NdisDprFreePacket( IN PNDIS_PACKET Packet); NDISAPI VOID -DDKAPI +NTAPI NdisDprFreePacketNonInterlocked( IN PNDIS_PACKET Packet); NDISAPI VOID -DDKAPI +NTAPI NdisFreeBufferPool( IN NDIS_HANDLE PoolHandle); NDISAPI VOID -DDKAPI +NTAPI NdisFreePacket( IN PNDIS_PACKET Packet); NDISAPI VOID -DDKAPI +NTAPI NdisFreePacketPool( IN NDIS_HANDLE PoolHandle); NDISAPI VOID -DDKAPI +NTAPI NdisReturnPackets( IN PNDIS_PACKET *PacketsToReturn, IN UINT NumberOfPackets); NDISAPI VOID -DDKAPI +NTAPI NdisUnchainBufferAtBack( IN OUT PNDIS_PACKET Packet, OUT PNDIS_BUFFER *Buffer); NDISAPI VOID -DDKAPI +NTAPI NdisUnchainBufferAtFront( IN OUT PNDIS_PACKET Packet, OUT PNDIS_BUFFER *Buffer); NDISAPI VOID -DDKAPI +NTAPI NdisAdjustBufferLength( IN PNDIS_BUFFER Buffer, IN UINT Length); NDISAPI ULONG -DDKAPI +NTAPI NdisBufferLength( IN PNDIS_BUFFER Buffer); NDISAPI PVOID -DDKAPI +NTAPI NdisBufferVirtualAddress( IN PNDIS_BUFFER Buffer); NDISAPI ULONG -DDKAPI +NTAPI NDIS_BUFFER_TO_SPAN_PAGES( IN PNDIS_BUFFER Buffer); NDISAPI VOID -DDKAPI +NTAPI NdisFreeBuffer( IN PNDIS_BUFFER Buffer); NDISAPI VOID -DDKAPI +NTAPI NdisGetBufferPhysicalArraySize( IN PNDIS_BUFFER Buffer, OUT PUINT ArraySize); NDISAPI VOID -DDKAPI +NTAPI NdisGetFirstBufferFromPacket( IN PNDIS_PACKET _Packet, OUT PNDIS_BUFFER *_FirstBuffer, @@ -1741,7 +1741,7 @@ NdisGetFirstBufferFromPacket( NDISAPI VOID -DDKAPI +NTAPI NdisQueryBuffer( IN PNDIS_BUFFER Buffer, OUT PVOID *VirtualAddress OPTIONAL, @@ -1749,7 +1749,7 @@ NdisQueryBuffer( NDISAPI VOID -DDKAPI +NTAPI NdisQueryBufferOffset( IN PNDIS_BUFFER Buffer, OUT PUINT Offset, @@ -2152,7 +2152,7 @@ NdisQueryPacketLength( NDISAPI VOID -DDKAPI +NTAPI NdisCreateLookaheadBufferFromSharedMemory( IN PVOID pSharedMemory, IN UINT LookaheadLength, @@ -2160,7 +2160,7 @@ NdisCreateLookaheadBufferFromSharedMemory( NDISAPI VOID -DDKAPI +NTAPI NdisDestroyLookaheadBufferFromSharedMemory( IN PVOID pLookaheadBuffer); @@ -2236,7 +2236,7 @@ NdisDestroyLookaheadBufferFromSharedMemory( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisAllocateMemory( OUT PVOID *VirtualAddress, IN UINT Length, @@ -2245,7 +2245,7 @@ NdisAllocateMemory( NDISAPI VOID -DDKAPI +NTAPI NdisFreeMemory( IN PVOID VirtualAddress, IN UINT Length, @@ -2253,7 +2253,7 @@ NdisFreeMemory( NDISAPI VOID -DDKAPI +NTAPI NdisImmediateReadSharedMemory( IN NDIS_HANDLE WrapperConfigurationContext, IN ULONG SharedMemoryAddress, @@ -2262,7 +2262,7 @@ NdisImmediateReadSharedMemory( NDISAPI VOID -DDKAPI +NTAPI NdisImmediateWriteSharedMemory( IN NDIS_HANDLE WrapperConfigurationContext, IN ULONG SharedMemoryAddress, @@ -2271,7 +2271,7 @@ NdisImmediateWriteSharedMemory( NDISAPI VOID -DDKAPI +NTAPI NdisMAllocateSharedMemory( IN NDIS_HANDLE MiniportAdapterHandle, IN ULONG Length, @@ -2281,7 +2281,7 @@ NdisMAllocateSharedMemory( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisMAllocateSharedMemoryAsync( IN NDIS_HANDLE MiniportAdapterHandle, IN ULONG Length, @@ -2299,7 +2299,7 @@ NdisMAllocateSharedMemoryAsync( NDISAPI VOID -DDKAPI +NTAPI NdisUpdateSharedMemory( IN NDIS_HANDLE NdisAdapterHandle, IN ULONG Length, @@ -2413,7 +2413,7 @@ NdisUpdateSharedMemory( RtlZeroMemory(Destination, Length) typedef VOID -(DDKAPI *NDIS_BLOCK_INITIALIZER) ( +(NTAPI *NDIS_BLOCK_INITIALIZER) ( IN PUCHAR Block, IN SIZE_T NumberOfBytes ); @@ -2422,7 +2422,7 @@ typedef VOID NDISAPI VOID -DDKAPI +NTAPI NdisOpenConfiguration( OUT PNDIS_STATUS Status, OUT PNDIS_HANDLE ConfigurationHandle, @@ -2430,7 +2430,7 @@ NdisOpenConfiguration( NDISAPI VOID -DDKAPI +NTAPI NdisReadNetworkAddress( OUT PNDIS_STATUS Status, OUT PVOID *NetworkAddress, @@ -2439,7 +2439,7 @@ NdisReadNetworkAddress( NDISAPI VOID -DDKAPI +NTAPI NdisReadEisaSlotInformation( OUT PNDIS_STATUS Status, IN NDIS_HANDLE WrapperConfigurationContext, @@ -2448,7 +2448,7 @@ NdisReadEisaSlotInformation( NDISAPI VOID -DDKAPI +NTAPI NdisReadEisaSlotInformationEx( OUT PNDIS_STATUS Status, IN NDIS_HANDLE WrapperConfigurationContext, @@ -2458,7 +2458,7 @@ NdisReadEisaSlotInformationEx( NDISAPI ULONG -DDKAPI +NTAPI NdisReadPciSlotInformation( IN NDIS_HANDLE NdisAdapterHandle, IN ULONG SlotNumber, @@ -2468,7 +2468,7 @@ NdisReadPciSlotInformation( NDISAPI ULONG -DDKAPI +NTAPI NdisWritePciSlotInformation( IN NDIS_HANDLE NdisAdapterHandle, IN ULONG SlotNumber, @@ -2482,7 +2482,7 @@ NdisWritePciSlotInformation( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisAnsiStringToUnicodeString( IN OUT PNDIS_STRING DestinationString, IN PNDIS_ANSI_STRING SourceString); @@ -2499,21 +2499,21 @@ NdisAnsiStringToUnicodeString( NDISAPI VOID -DDKAPI +NTAPI NdisInitAnsiString( IN OUT PNDIS_ANSI_STRING DestinationString, IN PCSTR SourceString); NDISAPI VOID -DDKAPI +NTAPI NdisInitUnicodeString( IN OUT PNDIS_STRING DestinationString, IN PCWSTR SourceString); NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisUnicodeStringToAnsiString( IN OUT PNDIS_ANSI_STRING DestinationString, IN PNDIS_STRING SourceString); @@ -2526,37 +2526,37 @@ NdisUnicodeStringToAnsiString( NDISAPI VOID -DDKAPI +NTAPI NdisAllocateSpinLock( IN PNDIS_SPIN_LOCK SpinLock); NDISAPI VOID -DDKAPI +NTAPI NdisFreeSpinLock( IN PNDIS_SPIN_LOCK SpinLock); NDISAPI VOID -DDKAPI +NTAPI NdisAcquireSpinLock( IN PNDIS_SPIN_LOCK SpinLock); NDISAPI VOID -DDKAPI +NTAPI NdisReleaseSpinLock( IN PNDIS_SPIN_LOCK SpinLock); NDISAPI VOID -DDKAPI +NTAPI NdisDprAcquireSpinLock( IN PNDIS_SPIN_LOCK SpinLock); NDISAPI VOID -DDKAPI +NTAPI NdisDprReleaseSpinLock( IN PNDIS_SPIN_LOCK SpinLock); @@ -2821,13 +2821,13 @@ NdisDprReleaseSpinLock( NDISAPI VOID -DDKAPI +NTAPI NdisCloseConfiguration( IN NDIS_HANDLE ConfigurationHandle); NDISAPI VOID -DDKAPI +NTAPI NdisReadConfiguration( OUT PNDIS_STATUS Status, OUT PNDIS_CONFIGURATION_PARAMETER *ParameterValue, @@ -2837,7 +2837,7 @@ NdisReadConfiguration( NDISAPI VOID -DDKAPI +NTAPI NdisWriteConfiguration( OUT PNDIS_STATUS Status, IN NDIS_HANDLE WrapperConfigurationContext, @@ -2846,7 +2846,7 @@ NdisWriteConfiguration( NDISAPI VOID -DDKCDECLAPI +__cdecl NdisWriteErrorLogEntry( IN NDIS_HANDLE NdisAdapterHandle, IN NDIS_ERROR_CODE ErrorCode, @@ -2862,18 +2862,18 @@ NdisWriteErrorLogEntry( NDISAPI VOID -DDKAPI +NTAPI NdisGetCurrentSystemTime( IN PLARGE_INTEGER pSystemTime); NDISAPI CCHAR -DDKAPI +NTAPI NdisSystemProcessorCount(VOID); NDISAPI VOID -DDKAPI +NTAPI NdisGetCurrentProcessorCpuUsage( OUT PULONG pCpuUsage); @@ -2902,7 +2902,7 @@ NdisGetCurrentProcessorCpuUsage( NDISAPI VOID -DDKAPI +NTAPI NdisMFreeSharedMemory( IN NDIS_HANDLE MiniportAdapterHandle, IN ULONG Length, @@ -2912,7 +2912,7 @@ NdisMFreeSharedMemory( NDISAPI VOID -DDKAPI +NTAPI NdisMWanIndicateReceive( OUT PNDIS_STATUS Status, IN NDIS_HANDLE MiniportAdapterHandle, @@ -2922,13 +2922,13 @@ NdisMWanIndicateReceive( NDISAPI VOID -DDKAPI +NTAPI NdisMWanIndicateReceiveComplete( IN NDIS_HANDLE MiniportAdapterHandle); NDISAPI VOID -DDKAPI +NTAPI NdisMWanSendComplete( IN NDIS_HANDLE MiniportAdapterHandle, IN PNDIS_WAN_PACKET Packet, @@ -2936,7 +2936,7 @@ NdisMWanSendComplete( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisPciAssignResources( IN NDIS_HANDLE NdisMacHandle, IN NDIS_HANDLE NdisWrapperHandle, @@ -2949,7 +2949,7 @@ NdisPciAssignResources( NDISAPI VOID -DDKAPI +NTAPI NdisAcquireReadWriteLock( IN PNDIS_RW_LOCK Lock, IN BOOLEAN fWrite, @@ -2957,7 +2957,7 @@ NdisAcquireReadWriteLock( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisAllocateMemoryWithTag( OUT PVOID *VirtualAddress, IN UINT Length, @@ -2965,7 +2965,7 @@ NdisAllocateMemoryWithTag( NDISAPI VOID -DDKAPI +NTAPI NdisAllocatePacketPoolEx( OUT PNDIS_STATUS Status, OUT PNDIS_HANDLE PoolHandle, @@ -2975,7 +2975,7 @@ NdisAllocatePacketPoolEx( NDISAPI VOID -DDKAPI +NTAPI NdisCompletePnPEvent( IN NDIS_STATUS Status, IN NDIS_HANDLE NdisBindingHandle, @@ -2983,7 +2983,7 @@ NdisCompletePnPEvent( NDISAPI VOID -DDKAPI +NTAPI NdisGetCurrentProcessorCounts( OUT PULONG pIdleCount, OUT PULONG pKernelAndUser, @@ -2991,39 +2991,39 @@ NdisGetCurrentProcessorCounts( NDISAPI VOID -DDKAPI +NTAPI NdisGetDriverHandle( IN PNDIS_HANDLE NdisBindingHandle, OUT PNDIS_HANDLE NdisDriverHandle); NDISAPI PNDIS_PACKET -DDKAPI +NTAPI NdisGetReceivedPacket( IN PNDIS_HANDLE NdisBindingHandle, IN PNDIS_HANDLE MacContext); NDISAPI VOID -DDKAPI +NTAPI NdisGetSystemUpTime( OUT PULONG pSystemUpTime); NDISAPI VOID -DDKAPI +NTAPI NdisInitializeReadWriteLock( IN PNDIS_RW_LOCK Lock); NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisMDeregisterDevice( IN NDIS_HANDLE NdisDeviceHandle); NDISAPI VOID -DDKAPI +NTAPI NdisMGetDeviceProperty( IN NDIS_HANDLE MiniportAdapterHandle, IN OUT PDEVICE_OBJECT *PhysicalDeviceObject OPTIONAL, @@ -3034,7 +3034,7 @@ NdisMGetDeviceProperty( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisMInitializeScatterGatherDma( IN NDIS_HANDLE MiniportAdapterHandle, IN BOOLEAN Dma64BitAddresses, @@ -3042,20 +3042,20 @@ NdisMInitializeScatterGatherDma( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisMPromoteMiniport( IN NDIS_HANDLE MiniportAdapterHandle); NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisMQueryAdapterInstanceName( OUT PNDIS_STRING AdapterInstanceName, IN NDIS_HANDLE MiniportAdapterHandle); NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisMRegisterDevice( IN NDIS_HANDLE NdisWrapperHandle, IN PNDIS_STRING DeviceName, @@ -3066,27 +3066,27 @@ NdisMRegisterDevice( NDISAPI VOID -DDKAPI +NTAPI NdisMRegisterUnloadHandler( IN NDIS_HANDLE NdisWrapperHandle, IN PDRIVER_UNLOAD UnloadHandler); NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisMRemoveMiniport( IN NDIS_HANDLE MiniportAdapterHandle); NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisMSetMiniportSecondary( IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_HANDLE PrimaryMiniportAdapterHandle); NDISAPI VOID -DDKAPI +NTAPI NdisOpenConfigurationKeyByIndex( OUT PNDIS_STATUS Status, IN NDIS_HANDLE ConfigurationHandle, @@ -3096,7 +3096,7 @@ NdisOpenConfigurationKeyByIndex( NDISAPI VOID -DDKAPI +NTAPI NdisOpenConfigurationKeyByName( OUT PNDIS_STATUS Status, IN NDIS_HANDLE ConfigurationHandle, @@ -3105,20 +3105,20 @@ NdisOpenConfigurationKeyByName( NDISAPI UINT -DDKAPI +NTAPI NdisPacketPoolUsage( IN NDIS_HANDLE PoolHandle); NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisQueryAdapterInstanceName( OUT PNDIS_STRING AdapterInstanceName, IN NDIS_HANDLE NdisBindingHandle); NDISAPI ULONG -DDKAPI +NTAPI NdisReadPcmciaAttributeMemory( IN NDIS_HANDLE NdisAdapterHandle, IN ULONG Offset, @@ -3127,14 +3127,14 @@ NdisReadPcmciaAttributeMemory( NDISAPI VOID -DDKAPI +NTAPI NdisReleaseReadWriteLock( IN PNDIS_RW_LOCK Lock, IN PLOCK_STATE LockState); NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisWriteEventLogEntry( IN PVOID LogHandle, IN NDIS_STATUS EventCode, @@ -3146,7 +3146,7 @@ NdisWriteEventLogEntry( NDISAPI ULONG -DDKAPI +NTAPI NdisWritePcmciaAttributeMemory( IN NDIS_HANDLE NdisAdapterHandle, IN ULONG Offset, @@ -3158,7 +3158,7 @@ NdisWritePcmciaAttributeMemory( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisClAddParty( IN NDIS_HANDLE NdisVcHandle, IN NDIS_HANDLE ProtocolPartyContext, @@ -3167,13 +3167,13 @@ NdisClAddParty( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisClCloseAddressFamily( IN NDIS_HANDLE NdisAfHandle); NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisClCloseCall( IN NDIS_HANDLE NdisVcHandle, IN NDIS_HANDLE NdisPartyHandle OPTIONAL, @@ -3182,13 +3182,13 @@ NdisClCloseCall( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisClDeregisterSap( IN NDIS_HANDLE NdisSapHandle); NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisClDropParty( IN NDIS_HANDLE NdisPartyHandle, IN PVOID Buffer OPTIONAL, @@ -3196,7 +3196,7 @@ NdisClDropParty( NDISAPI VOID -DDKAPI +NTAPI NdisClIncomingCallComplete( IN NDIS_STATUS Status, IN NDIS_HANDLE NdisVcHandle, @@ -3204,7 +3204,7 @@ NdisClIncomingCallComplete( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisClMakeCall( IN NDIS_HANDLE NdisVcHandle, IN OUT PCO_CALL_PARAMETERS CallParameters, @@ -3213,7 +3213,7 @@ NdisClMakeCall( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisClModifyCallQoS( IN NDIS_HANDLE NdisVcHandle, IN PCO_CALL_PARAMETERS CallParameters); @@ -3221,7 +3221,7 @@ NdisClModifyCallQoS( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisClOpenAddressFamily( IN NDIS_HANDLE NdisBindingHandle, IN PCO_ADDRESS_FAMILY AddressFamily, @@ -3232,7 +3232,7 @@ NdisClOpenAddressFamily( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisClRegisterSap( IN NDIS_HANDLE NdisAfHandle, IN NDIS_HANDLE ProtocolSapContext, @@ -3244,14 +3244,14 @@ NdisClRegisterSap( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisCmActivateVc( IN NDIS_HANDLE NdisVcHandle, IN OUT PCO_CALL_PARAMETERS CallParameters); NDISAPI VOID -DDKAPI +NTAPI NdisCmAddPartyComplete( IN NDIS_STATUS Status, IN NDIS_HANDLE NdisPartyHandle, @@ -3260,14 +3260,14 @@ NdisCmAddPartyComplete( NDISAPI VOID -DDKAPI +NTAPI NdisCmCloseAddressFamilyComplete( IN NDIS_STATUS Status, IN NDIS_HANDLE NdisAfHandle); NDISAPI VOID -DDKAPI +NTAPI NdisCmCloseCallComplete( IN NDIS_STATUS Status, IN NDIS_HANDLE NdisVcHandle, @@ -3275,26 +3275,26 @@ NdisCmCloseCallComplete( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisCmDeactivateVc( IN NDIS_HANDLE NdisVcHandle); NDISAPI VOID -DDKAPI +NTAPI NdisCmDeregisterSapComplete( IN NDIS_STATUS Status, IN NDIS_HANDLE NdisSapHandle); NDISAPI VOID -DDKAPI +NTAPI NdisCmDispatchCallConnected( IN NDIS_HANDLE NdisVcHandle); NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisCmDispatchIncomingCall( IN NDIS_HANDLE NdisSapHandle, IN NDIS_HANDLE NdisVcHandle, @@ -3302,14 +3302,14 @@ NdisCmDispatchIncomingCall( NDISAPI VOID -DDKAPI +NTAPI NdisCmDispatchIncomingCallQoSChange( IN NDIS_HANDLE NdisVcHandle, IN PCO_CALL_PARAMETERS CallParameters); NDISAPI VOID -DDKAPI +NTAPI NdisCmDispatchIncomingCloseCall( IN NDIS_STATUS CloseStatus, IN NDIS_HANDLE NdisVcHandle, @@ -3318,7 +3318,7 @@ NdisCmDispatchIncomingCloseCall( NDISAPI VOID -DDKAPI +NTAPI NdisCmDispatchIncomingDropParty( IN NDIS_STATUS DropStatus, IN NDIS_HANDLE NdisPartyHandle, @@ -3327,14 +3327,14 @@ NdisCmDispatchIncomingDropParty( NDISAPI VOID -DDKAPI +NTAPI NdisCmDropPartyComplete( IN NDIS_STATUS Status, IN NDIS_HANDLE NdisPartyHandle); NDISAPI VOID -DDKAPI +NTAPI NdisCmMakeCallComplete( IN NDIS_STATUS Status, IN NDIS_HANDLE NdisVcHandle, @@ -3344,7 +3344,7 @@ NdisCmMakeCallComplete( NDISAPI VOID -DDKAPI +NTAPI NdisCmModifyCallQoSComplete( IN NDIS_STATUS Status, IN NDIS_HANDLE NdisVcHandle, @@ -3352,7 +3352,7 @@ NdisCmModifyCallQoSComplete( NDISAPI VOID -DDKAPI +NTAPI NdisCmOpenAddressFamilyComplete( IN NDIS_STATUS Status, IN NDIS_HANDLE NdisAfHandle, @@ -3360,7 +3360,7 @@ NdisCmOpenAddressFamilyComplete( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisCmRegisterAddressFamily( IN NDIS_HANDLE NdisBindingHandle, IN PCO_ADDRESS_FAMILY AddressFamily, @@ -3369,7 +3369,7 @@ NdisCmRegisterAddressFamily( NDISAPI VOID -DDKAPI +NTAPI NdisCmRegisterSapComplete( IN NDIS_STATUS Status, IN NDIS_HANDLE NdisSapHandle, @@ -3378,14 +3378,14 @@ NdisCmRegisterSapComplete( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisMCmActivateVc( IN NDIS_HANDLE NdisVcHandle, IN PCO_CALL_PARAMETERS CallParameters); NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisMCmCreateVc( IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_HANDLE NdisAfHandle, @@ -3394,19 +3394,19 @@ NdisMCmCreateVc( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisMCmDeactivateVc( IN NDIS_HANDLE NdisVcHandle); NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisMCmDeleteVc( IN NDIS_HANDLE NdisVcHandle); NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisMCmRegisterAddressFamily( IN NDIS_HANDLE MiniportAdapterHandle, IN PCO_ADDRESS_FAMILY AddressFamily, @@ -3415,7 +3415,7 @@ NdisMCmRegisterAddressFamily( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisMCmRequest( IN NDIS_HANDLE NdisAfHandle, IN NDIS_HANDLE NdisVcHandle OPTIONAL, @@ -3427,7 +3427,7 @@ NdisMCmRequest( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisCoCreateVc( IN NDIS_HANDLE NdisBindingHandle, IN NDIS_HANDLE NdisAfHandle OPTIONAL, @@ -3436,13 +3436,13 @@ NdisCoCreateVc( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisCoDeleteVc( IN NDIS_HANDLE NdisVcHandle); NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisCoRequest( IN NDIS_HANDLE NdisBindingHandle, IN NDIS_HANDLE NdisAfHandle OPTIONAL, @@ -3452,7 +3452,7 @@ NdisCoRequest( NDISAPI VOID -DDKAPI +NTAPI NdisCoRequestComplete( IN NDIS_STATUS Status, IN NDIS_HANDLE NdisAfHandle, @@ -3462,7 +3462,7 @@ NdisCoRequestComplete( NDISAPI VOID -DDKAPI +NTAPI NdisCoSendPackets( IN NDIS_HANDLE NdisVcHandle, IN PPNDIS_PACKET PacketArray, @@ -3470,7 +3470,7 @@ NdisCoSendPackets( NDISAPI VOID -DDKAPI +NTAPI NdisMCoActivateVcComplete( IN NDIS_STATUS Status, IN NDIS_HANDLE NdisVcHandle, @@ -3478,14 +3478,14 @@ NdisMCoActivateVcComplete( NDISAPI VOID -DDKAPI +NTAPI NdisMCoDeactivateVcComplete( IN NDIS_STATUS Status, IN NDIS_HANDLE NdisVcHandle); NDISAPI VOID -DDKAPI +NTAPI NdisMCoIndicateReceivePacket( IN NDIS_HANDLE NdisVcHandle, IN PPNDIS_PACKET PacketArray, @@ -3493,7 +3493,7 @@ NdisMCoIndicateReceivePacket( NDISAPI VOID -DDKAPI +NTAPI NdisMCoIndicateStatus( IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_HANDLE NdisVcHandle OPTIONAL, @@ -3503,13 +3503,13 @@ NdisMCoIndicateStatus( NDISAPI VOID -DDKAPI +NTAPI NdisMCoReceiveComplete( IN NDIS_HANDLE MiniportAdapterHandle); NDISAPI VOID -DDKAPI +NTAPI NdisMCoRequestComplete( IN NDIS_STATUS Status, IN NDIS_HANDLE MiniportAdapterHandle, @@ -3517,7 +3517,7 @@ NdisMCoRequestComplete( NDISAPI VOID -DDKAPI +NTAPI NdisMCoSendComplete( IN NDIS_STATUS Status, IN NDIS_HANDLE NdisVcHandle, @@ -3528,53 +3528,53 @@ NdisMCoSendComplete( NDISAPI VOID -DDKAPI +NTAPI NdisIMAssociateMiniport( IN NDIS_HANDLE DriverHandle, IN NDIS_HANDLE ProtocolHandle); NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisIMCancelInitializeDeviceInstance( IN NDIS_HANDLE DriverHandle, IN PNDIS_STRING DeviceInstance); NDISAPI VOID -DDKAPI +NTAPI NdisIMCopySendCompletePerPacketInfo( IN PNDIS_PACKET DstPacket, IN PNDIS_PACKET SrcPacket); NDISAPI VOID -DDKAPI +NTAPI NdisIMCopySendPerPacketInfo( IN PNDIS_PACKET DstPacket, IN PNDIS_PACKET SrcPacket); NDISAPI VOID -DDKAPI +NTAPI NdisIMDeregisterLayeredMiniport( IN NDIS_HANDLE DriverHandle); NDISAPI NDIS_HANDLE -DDKAPI +NTAPI NdisIMGetBindingContext( IN NDIS_HANDLE NdisBindingHandle); NDISAPI NDIS_HANDLE -DDKAPI +NTAPI NdisIMGetDeviceContext( IN NDIS_HANDLE MiniportAdapterHandle); NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisIMInitializeDeviceInstanceEx( IN NDIS_HANDLE DriverHandle, IN PNDIS_STRING DriverInstance, @@ -3582,14 +3582,14 @@ NdisIMInitializeDeviceInstanceEx( NDISAPI PSINGLE_LIST_ENTRY -DDKAPI +NTAPI NdisInterlockedPopEntrySList( IN PSLIST_HEADER ListHead, IN PKSPIN_LOCK Lock); NDISAPI PSINGLE_LIST_ENTRY -DDKAPI +NTAPI NdisInterlockedPushEntrySList( IN PSLIST_HEADER ListHead, IN PSINGLE_LIST_ENTRY ListEntry, @@ -3597,7 +3597,7 @@ NdisInterlockedPushEntrySList( NDISAPI VOID -DDKAPI +NTAPI NdisQueryBufferSafe( IN PNDIS_BUFFER Buffer, OUT PVOID *VirtualAddress OPTIONAL, @@ -3607,27 +3607,27 @@ NdisQueryBufferSafe( /* Prototypes for NDIS_MINIPORT_CHARACTERISTICS */ typedef BOOLEAN -(DDKAPI *W_CHECK_FOR_HANG_HANDLER)( +(NTAPI *W_CHECK_FOR_HANG_HANDLER)( IN NDIS_HANDLE MiniportAdapterContext); typedef VOID -(DDKAPI *W_DISABLE_INTERRUPT_HANDLER)( +(NTAPI *W_DISABLE_INTERRUPT_HANDLER)( IN NDIS_HANDLE MiniportAdapterContext); typedef VOID -(DDKAPI *W_ENABLE_INTERRUPT_HANDLER)( +(NTAPI *W_ENABLE_INTERRUPT_HANDLER)( IN NDIS_HANDLE MiniportAdapterContext); typedef VOID -(DDKAPI *W_HALT_HANDLER)( +(NTAPI *W_HALT_HANDLER)( IN NDIS_HANDLE MiniportAdapterContext); typedef VOID -(DDKAPI *W_HANDLE_INTERRUPT_HANDLER)( +(NTAPI *W_HANDLE_INTERRUPT_HANDLER)( IN NDIS_HANDLE MiniportAdapterContext); typedef NDIS_STATUS -(DDKAPI *W_INITIALIZE_HANDLER)( +(NTAPI *W_INITIALIZE_HANDLER)( OUT PNDIS_STATUS OpenErrorStatus, OUT PUINT SelectedMediumIndex, IN PNDIS_MEDIUM MediumArray, @@ -3636,13 +3636,13 @@ typedef NDIS_STATUS IN NDIS_HANDLE WrapperConfigurationContext); typedef VOID -(DDKAPI *W_ISR_HANDLER)( +(NTAPI *W_ISR_HANDLER)( OUT PBOOLEAN InterruptRecognized, OUT PBOOLEAN QueueMiniportHandleInterrupt, IN NDIS_HANDLE MiniportAdapterContext); typedef NDIS_STATUS -(DDKAPI *W_QUERY_INFORMATION_HANDLER)( +(NTAPI *W_QUERY_INFORMATION_HANDLER)( IN NDIS_HANDLE MiniportAdapterContext, IN NDIS_OID Oid, IN PVOID InformationBuffer, @@ -3651,30 +3651,30 @@ typedef NDIS_STATUS OUT PULONG BytesNeeded); typedef NDIS_STATUS -(DDKAPI *W_RECONFIGURE_HANDLER)( +(NTAPI *W_RECONFIGURE_HANDLER)( OUT PNDIS_STATUS OpenErrorStatus, IN NDIS_HANDLE MiniportAdapterContext, IN NDIS_HANDLE WrapperConfigurationContext); typedef NDIS_STATUS -(DDKAPI *W_RESET_HANDLER)( +(NTAPI *W_RESET_HANDLER)( OUT PBOOLEAN AddressingReset, IN NDIS_HANDLE MiniportAdapterContext); typedef NDIS_STATUS -(DDKAPI *W_SEND_HANDLER)( +(NTAPI *W_SEND_HANDLER)( IN NDIS_HANDLE MiniportAdapterContext, IN PNDIS_PACKET Packet, IN UINT Flags); typedef NDIS_STATUS -(DDKAPI *WM_SEND_HANDLER)( +(NTAPI *WM_SEND_HANDLER)( IN NDIS_HANDLE MiniportAdapterContext, IN NDIS_HANDLE NdisLinkHandle, IN PNDIS_WAN_PACKET Packet); typedef NDIS_STATUS -(DDKAPI *W_SET_INFORMATION_HANDLER)( +(NTAPI *W_SET_INFORMATION_HANDLER)( IN NDIS_HANDLE MiniportAdapterContext, IN NDIS_OID Oid, IN PVOID InformationBuffer, @@ -3683,7 +3683,7 @@ typedef NDIS_STATUS OUT PULONG BytesNeeded); typedef NDIS_STATUS -(DDKAPI *W_TRANSFER_DATA_HANDLER)( +(NTAPI *W_TRANSFER_DATA_HANDLER)( OUT PNDIS_PACKET Packet, OUT PUINT BytesTransferred, IN NDIS_HANDLE MiniportAdapterContext, @@ -3692,7 +3692,7 @@ typedef NDIS_STATUS IN UINT BytesToTransfer); typedef NDIS_STATUS -(DDKAPI *WM_TRANSFER_DATA_HANDLER)( +(NTAPI *WM_TRANSFER_DATA_HANDLER)( VOID); @@ -3724,18 +3724,18 @@ typedef struct _NDIS30_MINIPORT_CHARACTERISTICS { /* Extensions for NDIS 4.0 miniports */ typedef VOID -(DDKAPI *W_SEND_PACKETS_HANDLER)( +(NTAPI *W_SEND_PACKETS_HANDLER)( IN NDIS_HANDLE MiniportAdapterContext, IN PPNDIS_PACKET PacketArray, IN UINT NumberOfPackets); typedef VOID -(DDKAPI *W_RETURN_PACKET_HANDLER)( +(NTAPI *W_RETURN_PACKET_HANDLER)( IN NDIS_HANDLE MiniportAdapterContext, IN PNDIS_PACKET Packet); typedef VOID -(DDKAPI *W_ALLOCATE_COMPLETE_HANDLER)( +(NTAPI *W_ALLOCATE_COMPLETE_HANDLER)( IN NDIS_HANDLE MiniportAdapterContext, IN PVOID VirtualAddress, IN PNDIS_PHYSICAL_ADDRESS PhysicalAddress, @@ -3768,32 +3768,32 @@ typedef struct _NDIS40_MINIPORT_CHARACTERISTICS { /* Extensions for NDIS 5.0 miniports */ typedef NDIS_STATUS -(DDKAPI *W_CO_CREATE_VC_HANDLER)( +(NTAPI *W_CO_CREATE_VC_HANDLER)( IN NDIS_HANDLE MiniportAdapterContext, IN NDIS_HANDLE NdisVcHandle, OUT PNDIS_HANDLE MiniportVcContext); typedef NDIS_STATUS -(DDKAPI *W_CO_DELETE_VC_HANDLER)( +(NTAPI *W_CO_DELETE_VC_HANDLER)( IN NDIS_HANDLE MiniportVcContext); typedef NDIS_STATUS -(DDKAPI *W_CO_ACTIVATE_VC_HANDLER)( +(NTAPI *W_CO_ACTIVATE_VC_HANDLER)( IN NDIS_HANDLE MiniportVcContext, IN OUT PCO_CALL_PARAMETERS CallParameters); typedef NDIS_STATUS -(DDKAPI *W_CO_DEACTIVATE_VC_HANDLER)( +(NTAPI *W_CO_DEACTIVATE_VC_HANDLER)( IN NDIS_HANDLE MiniportVcContext); typedef VOID -(DDKAPI *W_CO_SEND_PACKETS_HANDLER)( +(NTAPI *W_CO_SEND_PACKETS_HANDLER)( IN NDIS_HANDLE MiniportVcContext, IN PPNDIS_PACKET PacketArray, IN UINT NumberOfPackets); typedef NDIS_STATUS -(DDKAPI *W_CO_REQUEST_HANDLER)( +(NTAPI *W_CO_REQUEST_HANDLER)( IN NDIS_HANDLE MiniportAdapterContext, IN NDIS_HANDLE MiniportVcContext OPTIONAL, IN OUT PNDIS_REQUEST NdisRequest); @@ -3830,19 +3830,19 @@ typedef struct _NDIS50_MINIPORT_CHARACTERISTICS { /* Extensions for NDIS 5.1 miniports */ typedef VOID -(DDKAPI *W_CANCEL_SEND_PACKETS_HANDLER)( +(NTAPI *W_CANCEL_SEND_PACKETS_HANDLER)( IN NDIS_HANDLE MiniportAdapterContext, IN PVOID CancelId); typedef VOID -(DDKAPI *W_PNP_EVENT_NOTIFY_HANDLER)( +(NTAPI *W_PNP_EVENT_NOTIFY_HANDLER)( IN NDIS_HANDLE MiniportAdapterContext, IN NDIS_DEVICE_PNP_EVENT PnPEvent, IN PVOID InformationBuffer, IN ULONG InformationBufferLength); typedef VOID -(DDKAPI *W_MINIPORT_SHUTDOWN_HANDLER)( +(NTAPI *W_MINIPORT_SHUTDOWN_HANDLER)( IN PVOID ShutdownContext); #ifdef __cplusplus @@ -3887,12 +3887,12 @@ typedef struct _NDIS_MINIPORT_CHARACTERISTICS { typedef NDIS_STATUS -(DDKAPI *SEND_HANDLER)( +(NTAPI *SEND_HANDLER)( IN NDIS_HANDLE MacBindingHandle, IN PNDIS_PACKET Packet); typedef NDIS_STATUS -(DDKAPI *TRANSFER_DATA_HANDLER)( +(NTAPI *TRANSFER_DATA_HANDLER)( IN NDIS_HANDLE MacBindingHandle, IN NDIS_HANDLE MacReceiveContext, IN UINT ByteOffset, @@ -3901,11 +3901,11 @@ typedef NDIS_STATUS OUT PUINT BytesTransferred); typedef NDIS_STATUS -(DDKAPI *RESET_HANDLER)( +(NTAPI *RESET_HANDLER)( IN NDIS_HANDLE MacBindingHandle); typedef NDIS_STATUS -(DDKAPI *REQUEST_HANDLER)( +(NTAPI *REQUEST_HANDLER)( IN NDIS_HANDLE MacBindingHandle, IN PNDIS_REQUEST NdisRequest); @@ -3914,11 +3914,11 @@ typedef NDIS_STATUS /* Structures available only to full MAC drivers */ typedef BOOLEAN -(DDKAPI *PNDIS_INTERRUPT_SERVICE)( +(NTAPI *PNDIS_INTERRUPT_SERVICE)( IN PVOID InterruptContext); typedef VOID -(DDKAPI *PNDIS_DEFERRED_PROCESSING)( +(NTAPI *PNDIS_DEFERRED_PROCESSING)( IN PVOID SystemSpecific1, IN PVOID InterruptContext, IN PVOID SystemSpecific2, @@ -4012,11 +4012,11 @@ typedef struct _NDIS_BIND_PATHS { typedef VOID -(DDKAPI *ETH_RCV_COMPLETE_HANDLER)( +(NTAPI *ETH_RCV_COMPLETE_HANDLER)( IN PETH_FILTER Filter); typedef VOID -(DDKAPI *ETH_RCV_INDICATE_HANDLER)( +(NTAPI *ETH_RCV_INDICATE_HANDLER)( IN PETH_FILTER Filter, IN NDIS_HANDLE MacReceiveContext, IN PCHAR Address, @@ -4027,11 +4027,11 @@ typedef VOID IN UINT PacketSize); typedef VOID -(DDKAPI *FDDI_RCV_COMPLETE_HANDLER)( +(NTAPI *FDDI_RCV_COMPLETE_HANDLER)( IN PFDDI_FILTER Filter); typedef VOID -(DDKAPI *FDDI_RCV_INDICATE_HANDLER)( +(NTAPI *FDDI_RCV_INDICATE_HANDLER)( IN PFDDI_FILTER Filter, IN NDIS_HANDLE MacReceiveContext, IN PCHAR Address, @@ -4043,17 +4043,17 @@ typedef VOID IN UINT PacketSize); typedef VOID -(DDKAPI *FILTER_PACKET_INDICATION_HANDLER)( +(NTAPI *FILTER_PACKET_INDICATION_HANDLER)( IN NDIS_HANDLE Miniport, IN PPNDIS_PACKET PacketArray, IN UINT NumberOfPackets); typedef VOID -(DDKAPI *TR_RCV_COMPLETE_HANDLER)( +(NTAPI *TR_RCV_COMPLETE_HANDLER)( IN PTR_FILTER Filter); typedef VOID -(DDKAPI *TR_RCV_INDICATE_HANDLER)( +(NTAPI *TR_RCV_INDICATE_HANDLER)( IN PTR_FILTER Filter, IN NDIS_HANDLE MacReceiveContext, IN PVOID HeaderBuffer, @@ -4063,12 +4063,12 @@ typedef VOID IN UINT PacketSize); typedef VOID -(DDKAPI *WAN_RCV_COMPLETE_HANDLER)( +(NTAPI *WAN_RCV_COMPLETE_HANDLER)( IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_HANDLE NdisLinkContext); typedef VOID -(DDKAPI *WAN_RCV_HANDLER)( +(NTAPI *WAN_RCV_HANDLER)( OUT PNDIS_STATUS Status, IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_HANDLE NdisLinkContext, @@ -4094,24 +4094,24 @@ typedef NDIS_STATUS IN PVOID WorkItemContext); typedef VOID -(DDKAPI *NDIS_M_REQ_COMPLETE_HANDLER)( +(NTAPI *NDIS_M_REQ_COMPLETE_HANDLER)( IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_STATUS Status); typedef VOID -(DDKAPI *NDIS_M_RESET_COMPLETE_HANDLER)( +(NTAPI *NDIS_M_RESET_COMPLETE_HANDLER)( IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_STATUS Status, IN BOOLEAN AddressingReset); typedef VOID -(DDKAPI *NDIS_M_SEND_COMPLETE_HANDLER)( +(NTAPI *NDIS_M_SEND_COMPLETE_HANDLER)( IN NDIS_HANDLE MiniportAdapterHandle, IN PNDIS_PACKET Packet, IN NDIS_STATUS Status); typedef VOID -(DDKAPI *NDIS_M_SEND_RESOURCES_HANDLER)( +(NTAPI *NDIS_M_SEND_RESOURCES_HANDLER)( IN NDIS_HANDLE MiniportAdapterHandle); typedef BOOLEAN @@ -4119,24 +4119,24 @@ typedef BOOLEAN IN PNDIS_MINIPORT_BLOCK Miniport); typedef VOID -(DDKAPI *NDIS_M_STATUS_HANDLER)( +(NTAPI *NDIS_M_STATUS_HANDLER)( IN NDIS_HANDLE MiniportHandle, IN NDIS_STATUS GeneralStatus, IN PVOID StatusBuffer, IN UINT StatusBufferSize); typedef VOID -(DDKAPI *NDIS_M_STS_COMPLETE_HANDLER)( +(NTAPI *NDIS_M_STS_COMPLETE_HANDLER)( IN NDIS_HANDLE MiniportAdapterHandle); typedef VOID -(DDKAPI *NDIS_M_TD_COMPLETE_HANDLER)( +(NTAPI *NDIS_M_TD_COMPLETE_HANDLER)( IN NDIS_HANDLE MiniportAdapterHandle, IN PNDIS_PACKET Packet, IN NDIS_STATUS Status, IN UINT BytesTransferred); -typedef VOID (DDKAPI *NDIS_WM_SEND_COMPLETE_HANDLER)( +typedef VOID (NTAPI *NDIS_WM_SEND_COMPLETE_HANDLER)( IN NDIS_HANDLE MiniportAdapterHandle, IN PVOID Packet, IN NDIS_STATUS Status); @@ -4376,14 +4376,14 @@ struct _NDIS_MINIPORT_BLOCK { /* Handler prototypes for NDIS_OPEN_BLOCK */ -typedef NDIS_STATUS (DDKAPI *WAN_SEND_HANDLER)( +typedef NDIS_STATUS (NTAPI *WAN_SEND_HANDLER)( IN NDIS_HANDLE MacBindingHandle, IN NDIS_HANDLE LinkHandle, IN PVOID Packet); /* NDIS 4.0 extension */ -typedef VOID (DDKAPI *SEND_PACKETS_HANDLER)( +typedef VOID (NTAPI *SEND_PACKETS_HANDLER)( IN NDIS_HANDLE MiniportAdapterContext, IN PPNDIS_PACKET PacketArray, IN UINT NumberOfPackets); @@ -4466,7 +4466,7 @@ struct _NDIS_OPEN_BLOCK NDISAPI VOID -DDKAPI +NTAPI NdisInitializeWrapper( OUT PNDIS_HANDLE NdisWrapperHandle, IN PVOID SystemSpecific1, @@ -4475,7 +4475,7 @@ NdisInitializeWrapper( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisMAllocateMapRegisters( IN NDIS_HANDLE MiniportAdapterHandle, IN UINT DmaChannel, @@ -4521,13 +4521,13 @@ NdisMAllocateMapRegisters( NDISAPI VOID -DDKAPI +NTAPI NdisMCloseLog( IN NDIS_HANDLE LogHandle); NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisMCreateLog( IN NDIS_HANDLE MiniportAdapterHandle, IN UINT Size, @@ -4535,19 +4535,19 @@ NdisMCreateLog( NDISAPI VOID -DDKAPI +NTAPI NdisMDeregisterAdapterShutdownHandler( IN NDIS_HANDLE MiniportHandle); NDISAPI VOID -DDKAPI +NTAPI NdisMDeregisterInterrupt( IN PNDIS_MINIPORT_INTERRUPT Interrupt); NDISAPI VOID -DDKAPI +NTAPI NdisMDeregisterIoPortRange( IN NDIS_HANDLE MiniportAdapterHandle, IN UINT InitialPort, @@ -4643,13 +4643,13 @@ NdisMDeregisterIoPortRange( NDISAPI VOID -DDKAPI +NTAPI NdisMFlushLog( IN NDIS_HANDLE LogHandle); NDISAPI VOID -DDKAPI +NTAPI NdisMFreeMapRegisters( IN NDIS_HANDLE MiniportAdapterHandle); @@ -4708,7 +4708,7 @@ NdisMFreeMapRegisters( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisMMapIoSpace( OUT PVOID *VirtualAddress, IN NDIS_HANDLE MiniportAdapterHandle, @@ -4726,7 +4726,7 @@ NdisMMapIoSpace( NDISAPI VOID -DDKAPI +NTAPI NdisMRegisterAdapterShutdownHandler( IN NDIS_HANDLE MiniportHandle, IN PVOID ShutdownContext, @@ -4734,7 +4734,7 @@ NdisMRegisterAdapterShutdownHandler( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisMRegisterInterrupt( OUT PNDIS_MINIPORT_INTERRUPT Interrupt, IN NDIS_HANDLE MiniportAdapterHandle, @@ -4746,7 +4746,7 @@ NdisMRegisterInterrupt( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisMRegisterIoPortRange( OUT PVOID *PortOffset, IN NDIS_HANDLE MiniportAdapterHandle, @@ -4755,7 +4755,7 @@ NdisMRegisterIoPortRange( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisMRegisterMiniport( IN NDIS_HANDLE NdisWrapperHandle, IN PNDIS_MINIPORT_CHARACTERISTICS MiniportCharacteristics, @@ -4763,14 +4763,14 @@ NdisMRegisterMiniport( NDISAPI VOID -DDKAPI +NTAPI NdisMSetTimer( IN PNDIS_MINIPORT_TIMER Timer, IN UINT MillisecondsToDelay); NDISAPI VOID -DDKAPI +NTAPI NdisMInitializeTimer( IN OUT PNDIS_MINIPORT_TIMER Timer, IN NDIS_HANDLE MiniportAdapterHandle, @@ -4779,14 +4779,14 @@ NdisMInitializeTimer( NDISAPI VOID -DDKAPI +NTAPI NdisMSetPeriodicTimer( IN PNDIS_MINIPORT_TIMER Timer, IN UINT MillisecondPeriod); NDISAPI VOID -DDKAPI +NTAPI NdisMCancelTimer( IN PNDIS_MINIPORT_TIMER Timer, OUT PBOOLEAN TimerCancelled); @@ -4874,7 +4874,7 @@ NdisMCancelTimer( NDISAPI VOID -DDKAPI +NTAPI NdisMSetAttributesEx( IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_HANDLE MiniportAdapterContext, @@ -4895,13 +4895,13 @@ NdisMSetAttributesEx( NDISAPI VOID -DDKAPI +NTAPI NdisMSleep( IN ULONG MicrosecondsToSleep); NDISAPI BOOLEAN -DDKAPI +NTAPI NdisMSynchronizeWithInterrupt( IN PNDIS_MINIPORT_INTERRUPT Interrupt, IN PVOID SynchronizeFunction, @@ -4950,7 +4950,7 @@ NdisMSynchronizeWithInterrupt( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisMWriteLogData( IN NDIS_HANDLE LogHandle, IN PVOID LogBuffer, @@ -4958,7 +4958,7 @@ NdisMWriteLogData( NDISAPI VOID -DDKAPI +NTAPI NdisMQueryAdapterResources( OUT PNDIS_STATUS Status, IN NDIS_HANDLE WrapperConfigurationContext, @@ -4967,14 +4967,14 @@ NdisMQueryAdapterResources( NDISAPI VOID -DDKAPI +NTAPI NdisTerminateWrapper( IN NDIS_HANDLE NdisWrapperHandle, IN PVOID SystemSpecific); NDISAPI VOID -DDKAPI +NTAPI NdisMUnmapIoSpace( IN NDIS_HANDLE MiniportAdapterHandle, IN PVOID VirtualAddress, @@ -4986,25 +4986,25 @@ NdisMUnmapIoSpace( NDISAPI VOID -DDKAPI +NTAPI NdisInitializeEvent( IN PNDIS_EVENT Event); NDISAPI VOID -DDKAPI +NTAPI NdisSetEvent( IN PNDIS_EVENT Event); NDISAPI VOID -DDKAPI +NTAPI NdisResetEvent( IN PNDIS_EVENT Event); NDISAPI BOOLEAN -DDKAPI +NTAPI NdisWaitEvent( IN PNDIS_EVENT Event, IN UINT Timeout); @@ -5013,7 +5013,7 @@ NdisWaitEvent( /* NDIS intermediate miniport structures */ -typedef VOID (DDKAPI *W_MINIPORT_CALLBACK)( +typedef VOID (NTAPI *W_MINIPORT_CALLBACK)( IN NDIS_HANDLE MiniportAdapterContext, IN PVOID CallbackContext); @@ -5023,7 +5023,7 @@ typedef VOID (DDKAPI *W_MINIPORT_CALLBACK)( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisIMDeInitializeDeviceInstance( IN NDIS_HANDLE NdisMiniportHandle); @@ -5038,7 +5038,7 @@ NdisIMDeInitializeDeviceInstance( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisIMRegisterLayeredMiniport( IN NDIS_HANDLE NdisWrapperHandle, IN PNDIS_MINIPORT_CHARACTERISTICS MiniportCharacteristics, @@ -5050,13 +5050,13 @@ NdisIMRegisterLayeredMiniport( NDISAPI VOID -DDKAPI +NTAPI NdisFreeDmaChannel( IN PNDIS_HANDLE NdisDmaHandle); NDISAPI VOID -DDKAPI +NTAPI NdisSetupDmaTransfer( OUT PNDIS_STATUS Status, IN PNDIS_HANDLE NdisDmaHandle, @@ -5067,7 +5067,7 @@ NdisSetupDmaTransfer( NDISAPI NTSTATUS -DDKAPI +NTAPI NdisUpcaseUnicodeString( OUT PUNICODE_STRING DestinationString, IN PUNICODE_STRING SourceString); @@ -5077,7 +5077,7 @@ NdisUpcaseUnicodeString( NDISAPI VOID -DDKAPI +NTAPI NdisRequest( OUT PNDIS_STATUS Status, IN NDIS_HANDLE NdisBindingHandle, @@ -5085,14 +5085,14 @@ NdisRequest( NDISAPI VOID -DDKAPI +NTAPI NdisReset( OUT PNDIS_STATUS Status, IN NDIS_HANDLE NdisBindingHandle); NDISAPI VOID -DDKAPI +NTAPI NdisSend( OUT PNDIS_STATUS Status, IN NDIS_HANDLE NdisBindingHandle, @@ -5100,7 +5100,7 @@ NdisSend( NDISAPI VOID -DDKAPI +NTAPI NdisSendPackets( IN NDIS_HANDLE NdisBindingHandle, IN PPNDIS_PACKET PacketArray, @@ -5108,7 +5108,7 @@ NdisSendPackets( NDISAPI VOID -DDKAPI +NTAPI NdisTransferData( OUT PNDIS_STATUS Status, IN NDIS_HANDLE NdisBindingHandle, @@ -5120,14 +5120,14 @@ NdisTransferData( NDISAPI VOID -DDKAPI +NTAPI NdisCloseAdapter( OUT PNDIS_STATUS Status, IN NDIS_HANDLE NdisBindingHandle); NDISAPI VOID -DDKAPI +NTAPI NdisCompleteBindAdapter( IN NDIS_HANDLE BindAdapterContext, IN NDIS_STATUS Status, @@ -5135,21 +5135,21 @@ NdisCompleteBindAdapter( NDISAPI VOID -DDKAPI +NTAPI NdisCompleteUnbindAdapter( IN NDIS_HANDLE UnbindAdapterContext, IN NDIS_STATUS Status); NDISAPI VOID -DDKAPI +NTAPI NdisDeregisterProtocol( OUT PNDIS_STATUS Status, IN NDIS_HANDLE NdisProtocolHandle); NDISAPI VOID -DDKAPI +NTAPI NdisOpenAdapter( OUT PNDIS_STATUS Status, OUT PNDIS_STATUS OpenErrorStatus, @@ -5165,7 +5165,7 @@ NdisOpenAdapter( NDISAPI VOID -DDKAPI +NTAPI NdisOpenProtocolConfiguration( OUT PNDIS_STATUS Status, OUT PNDIS_HANDLE ConfigurationHandle, @@ -5173,7 +5173,7 @@ NdisOpenProtocolConfiguration( NDISAPI VOID -DDKAPI +NTAPI NdisRegisterProtocol( OUT PNDIS_STATUS Status, OUT PNDIS_HANDLE NdisProtocolHandle, @@ -5182,7 +5182,7 @@ NdisRegisterProtocol( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisScheduleWorkItem( IN PNDIS_WORK_ITEM WorkItem); @@ -5201,20 +5201,20 @@ typedef NDIS_STATUS (*OPEN_ADAPTER_HANDLER)( IN UINT OpenOptions, IN PSTRING AddressingInformation OPTIONAL); -typedef NDIS_STATUS (DDKAPI *CLOSE_ADAPTER_HANDLER)( +typedef NDIS_STATUS (NTAPI *CLOSE_ADAPTER_HANDLER)( IN NDIS_HANDLE MacBindingHandle); -typedef NDIS_STATUS (DDKAPI *WAN_TRANSFER_DATA_HANDLER)( +typedef NDIS_STATUS (NTAPI *WAN_TRANSFER_DATA_HANDLER)( VOID); -typedef NDIS_STATUS (DDKAPI *QUERY_GLOBAL_STATISTICS_HANDLER)( +typedef NDIS_STATUS (NTAPI *QUERY_GLOBAL_STATISTICS_HANDLER)( IN NDIS_HANDLE MacAdapterContext, IN PNDIS_REQUEST NdisRequest); -typedef VOID (DDKAPI *UNLOAD_MAC_HANDLER)( +typedef VOID (NTAPI *UNLOAD_MAC_HANDLER)( IN NDIS_HANDLE MacMacContext); -typedef NDIS_STATUS (DDKAPI *ADD_ADAPTER_HANDLER)( +typedef NDIS_STATUS (NTAPI *ADD_ADAPTER_HANDLER)( IN NDIS_HANDLE MacMacContext, IN NDIS_HANDLE WrapperConfigurationContext, IN PNDIS_STRING AdapterName); diff --git a/reactos/include/ddk/ntagp.h b/reactos/include/ddk/ntagp.h index 6776d2a1f82..6622d81c90b 100644 --- a/reactos/include/ddk/ntagp.h +++ b/reactos/include/ddk/ntagp.h @@ -36,7 +36,7 @@ extern "C" { #define AGP_CAPABILITIES_MAP_PHYSICAL 0x00000001L typedef NTSTATUS -(DDKAPI *PAGP_BUS_COMMIT_MEMORY)( +(NTAPI *PAGP_BUS_COMMIT_MEMORY)( IN PVOID AgpContext, IN PVOID MapHandle, IN ULONG NumberOfPages, @@ -45,19 +45,19 @@ typedef NTSTATUS OUT PHYSICAL_ADDRESS *MemoryBase); typedef NTSTATUS -(DDKAPI *PAGP_BUS_FREE_MEMORY)( +(NTAPI *PAGP_BUS_FREE_MEMORY)( IN PVOID AgpContext, IN PVOID MapHandle, IN ULONG NumberOfPages, IN ULONG OffsetInPages); typedef NTSTATUS -(DDKAPI *PAGP_BUS_RELEASE_MEMORY)( +(NTAPI *PAGP_BUS_RELEASE_MEMORY)( IN PVOID AgpContext, IN PVOID MapHandle); typedef NTSTATUS -(DDKAPI *PAGP_BUS_RESERVE_MEMORY)( +(NTAPI *PAGP_BUS_RESERVE_MEMORY)( IN PVOID AgpContext, IN ULONG NumberOfPages, IN MEMORY_CACHING_TYPE MemoryType, @@ -65,12 +65,12 @@ typedef NTSTATUS OUT PHYSICAL_ADDRESS *PhysicalAddress OPTIONAL); typedef NTSTATUS -(DDKAPI *PAGP_BUS_SET_RATE)( +(NTAPI *PAGP_BUS_SET_RATE)( IN PVOID AgpContext, IN ULONG AgpRate); typedef NTSTATUS -(DDKAPI *PAGP_GET_MAPPED_PAGES)( +(NTAPI *PAGP_GET_MAPPED_PAGES)( IN PVOID AgpContext, IN PVOID MapHandle, IN ULONG NumberOfPages, diff --git a/reactos/include/ddk/ntdd8042.h b/reactos/include/ddk/ntdd8042.h index 0527ef42462..4bb32529292 100644 --- a/reactos/include/ddk/ntdd8042.h +++ b/reactos/include/ddk/ntdd8042.h @@ -134,29 +134,29 @@ typedef struct _INTERNAL_I8042_START_INFORMATION { } INTERNAL_I8042_START_INFORMATION, *PINTERNAL_I8042_START_INFORMATION; typedef VOID -(DDKAPI *PI8042_ISR_WRITE_PORT)( +(NTAPI *PI8042_ISR_WRITE_PORT)( IN PVOID Context, IN UCHAR Value); typedef VOID -(DDKAPI *PI8042_QUEUE_PACKET)( +(NTAPI *PI8042_QUEUE_PACKET)( IN PVOID Context); typedef NTSTATUS -(DDKAPI *PI8042_SYNCH_READ_PORT) ( +(NTAPI *PI8042_SYNCH_READ_PORT) ( IN PVOID Context, OUT PUCHAR Value, IN BOOLEAN WaitForACK); typedef NTSTATUS -(DDKAPI *PI8042_SYNCH_WRITE_PORT)( +(NTAPI *PI8042_SYNCH_WRITE_PORT)( IN PVOID Context, IN UCHAR Value, IN BOOLEAN WaitForACK); typedef NTSTATUS -(DDKAPI *PI8042_KEYBOARD_INITIALIZATION_ROUTINE)( +(NTAPI *PI8042_KEYBOARD_INITIALIZATION_ROUTINE)( IN PVOID InitializationContext, IN PVOID SynchFuncContext, IN PI8042_SYNCH_READ_PORT ReadPort, @@ -164,7 +164,7 @@ typedef NTSTATUS OUT PBOOLEAN TurnTranslationOn); typedef BOOLEAN -(DDKAPI *PI8042_KEYBOARD_ISR)( +(NTAPI *PI8042_KEYBOARD_ISR)( PVOID IsrContext, PKEYBOARD_INPUT_DATA CurrentInput, POUTPUT_PACKET CurrentOutput, @@ -183,7 +183,7 @@ typedef struct _INTERNAL_I8042_HOOK_KEYBOARD { } INTERNAL_I8042_HOOK_KEYBOARD, *PINTERNAL_I8042_HOOK_KEYBOARD; typedef BOOLEAN -(DDKAPI *PI8042_MOUSE_ISR)( +(NTAPI *PI8042_MOUSE_ISR)( PVOID IsrContext, PMOUSE_INPUT_DATA CurrentInput, POUTPUT_PACKET CurrentOutput, diff --git a/reactos/include/ddk/ntddk.h b/reactos/include/ddk/ntddk.h index 0475b3acc85..387f538b100 100644 --- a/reactos/include/ddk/ntddk.h +++ b/reactos/include/ddk/ntddk.h @@ -1,12 +1,13 @@ /* * ntddk.h * - * Windows Device Driver Kit + * Windows NT Device Driver Kit * - * This file is part of the w32api package. + * This file is part of the ReactOS DDK package. * * Contributors: - * Created by Casper S. Hornstrup + * Amine Khaldi + * Timo Kreuzer (timo.kreuzer@reactos.org) * * THIS SOFTWARE IS NOT COPYRIGHTED * @@ -18,13 +19,10 @@ * DISCLAIMED. This includes but is not limited to warranties of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * DEFINES: - * DBG - Debugging enabled/disabled (0/1) - * POOL_TAGGING - Enable pool tagging - * _X86_ - X86 environment */ -#ifndef _NTDDK_ +#pragma once + #define _NTDDK_ #if !defined(_NTHAL_) && !defined(_NTIFS_) @@ -41,6 +39,7 @@ #include #include #include +#include /* FIXME #include @@ -55,39 +54,128 @@ extern "C" { #endif +/* GUID and UUID */ +#ifndef _NTLSA_IFS_ +#ifndef _NTLSA_AUDIT_ +#define _NTLSA_AUDIT_ + +#ifndef GUID_DEFINED +#include +#endif + +#endif /* _NTLSA_AUDIT_ */ +#endif /* _NTLSA_IFS_ */ + +typedef GUID UUID; + struct _LOADER_PARAMETER_BLOCK; struct _CREATE_DISK; struct _DRIVE_LAYOUT_INFORMATION_EX; struct _SET_PARTITION_INFORMATION_EX; -// -// GUID and UUID -// -#ifndef GUID_DEFINED -#include -#endif -typedef GUID UUID; - typedef struct _BUS_HANDLER *PBUS_HANDLER; +typedef struct _DEVICE_HANDLER_OBJECT *PDEVICE_HANDLER_OBJECT; +#if defined(_NTHAL_INCLUDED_) +typedef struct _KAFFINITY_EX *PKAFFINITY_EX; +#endif +typedef struct _PEB *PPEB; -#define EXCEPTION_READ_FAULT 0 -#define EXCEPTION_WRITE_FAULT 1 -#define EXCEPTION_EXECUTE_FAULT 8 +#ifndef _NTIMAGE_ -#if (NTDDI_VERSION >= NTDDI_VISTA) -extern NTSYSAPI volatile CCHAR KeNumberProcessors; -#elif (NTDDI_VERSION >= NTDDI_WINXP) -extern NTSYSAPI CCHAR KeNumberProcessors; +typedef struct _IMAGE_NT_HEADERS *PIMAGE_NT_HEADERS32; +typedef struct _IMAGE_NT_HEADERS64 *PIMAGE_NT_HEADERS64; + +#ifdef _WIN64 +typedef PIMAGE_NT_HEADERS64 PIMAGE_NT_HEADERS; #else -extern PCCHAR KeNumberProcessors; +typedef PIMAGE_NT_HEADERS32 PIMAGE_NT_HEADERS; #endif -#define MAX_WOW64_SHARED_ENTRIES 16 +#endif /* _NTIMAGE_ */ -#define NX_SUPPORT_POLICY_ALWAYSOFF 0 -#define NX_SUPPORT_POLICY_ALWAYSON 1 -#define NX_SUPPORT_POLICY_OPTIN 2 -#define NX_SUPPORT_POLICY_OPTOUT 3 +/****************************************************************************** + * Executive Types * + ******************************************************************************/ + +typedef struct _ZONE_SEGMENT_HEADER { + SINGLE_LIST_ENTRY SegmentList; + PVOID Reserved; +} ZONE_SEGMENT_HEADER, *PZONE_SEGMENT_HEADER; + +typedef struct _ZONE_HEADER { + SINGLE_LIST_ENTRY FreeList; + SINGLE_LIST_ENTRY SegmentList; + ULONG BlockSize; + ULONG TotalSegmentSize; +} ZONE_HEADER, *PZONE_HEADER; + +#define PROTECTED_POOL 0x80000000 + + +/****************************************************************************** + * I/O Manager Types * + ******************************************************************************/ + +/* DEVICE_OBJECT.Flags */ +#define DO_DEVICE_HAS_NAME 0x00000040 +#define DO_SYSTEM_BOOT_PARTITION 0x00000100 +#define DO_LONG_TERM_REQUESTS 0x00000200 +#define DO_NEVER_LAST_DEVICE 0x00000400 +#define DO_LOW_PRIORITY_FILESYSTEM 0x00010000 +#define DO_SUPPORTS_TRANSACTIONS 0x00040000 +#define DO_FORCE_NEITHER_IO 0x00080000 +#define DO_VOLUME_DEVICE_OBJECT 0x00100000 +#define DO_SYSTEM_SYSTEM_PARTITION 0x00200000 +#define DO_SYSTEM_CRITICAL_PARTITION 0x00400000 +#define DO_DISALLOW_EXECUTE 0x00800000 + +#ifndef _ARC_DDK_ +#define _ARC_DDK_ +typedef enum _CONFIGURATION_TYPE { + ArcSystem, + CentralProcessor, + FloatingPointProcessor, + PrimaryIcache, + PrimaryDcache, + SecondaryIcache, + SecondaryDcache, + SecondaryCache, + EisaAdapter, + TcAdapter, + ScsiAdapter, + DtiAdapter, + MultiFunctionAdapter, + DiskController, + TapeController, + CdromController, + WormController, + SerialController, + NetworkController, + DisplayController, + ParallelController, + PointerController, + KeyboardController, + AudioController, + OtherController, + DiskPeripheral, + FloppyDiskPeripheral, + TapePeripheral, + ModemPeripheral, + MonitorPeripheral, + PrinterPeripheral, + PointerPeripheral, + KeyboardPeripheral, + TerminalPeripheral, + OtherPeripheral, + LinePeripheral, + NetworkPeripheral, + SystemMemory, + DockingInformation, + RealModeIrqRoutingTable, + RealModePCIEnumeration, + MaximumType +} CONFIGURATION_TYPE, *PCONFIGURATION_TYPE; +#endif /* !_ARC_DDK_ */ /* ** IRP function codes @@ -122,102 +210,118 @@ extern PCCHAR KeNumberProcessors; #define IRP_MN_QUERY_LEGACY_BUS_INFORMATION 0x18 -typedef struct _IO_COUNTERS { - ULONGLONG ReadOperationCount; - ULONGLONG WriteOperationCount; - ULONGLONG OtherOperationCount; - ULONGLONG ReadTransferCount; - ULONGLONG WriteTransferCount; - ULONGLONG OtherTransferCount; -} IO_COUNTERS, *PIO_COUNTERS; +#define IO_CHECK_CREATE_PARAMETERS 0x0200 +#define IO_ATTACH_DEVICE 0x0400 +#define IO_IGNORE_SHARE_ACCESS_CHECK 0x0800 -typedef struct _VM_COUNTERS { - SIZE_T PeakVirtualSize; - SIZE_T VirtualSize; - ULONG PageFaultCount; - SIZE_T PeakWorkingSetSize; - SIZE_T WorkingSetSize; - SIZE_T QuotaPeakPagedPoolUsage; - SIZE_T QuotaPagedPoolUsage; - SIZE_T QuotaPeakNonPagedPoolUsage; - SIZE_T QuotaNonPagedPoolUsage; - SIZE_T PagefileUsage; - SIZE_T PeakPagefileUsage; -} VM_COUNTERS, *PVM_COUNTERS; +typedef +NTSTATUS +(NTAPI *PIO_QUERY_DEVICE_ROUTINE)( + IN PVOID Context, + IN PUNICODE_STRING PathName, + IN INTERFACE_TYPE BusType, + IN ULONG BusNumber, + IN PKEY_VALUE_FULL_INFORMATION *BusInformation, + IN CONFIGURATION_TYPE ControllerType, + IN ULONG ControllerNumber, + IN PKEY_VALUE_FULL_INFORMATION *ControllerInformation, + IN CONFIGURATION_TYPE PeripheralType, + IN ULONG PeripheralNumber, + IN PKEY_VALUE_FULL_INFORMATION *PeripheralInformation); -typedef struct _VM_COUNTERS_EX -{ - SIZE_T PeakVirtualSize; - SIZE_T VirtualSize; - ULONG PageFaultCount; - SIZE_T PeakWorkingSetSize; - SIZE_T WorkingSetSize; - SIZE_T QuotaPeakPagedPoolUsage; - SIZE_T QuotaPagedPoolUsage; - SIZE_T QuotaPeakNonPagedPoolUsage; - SIZE_T QuotaNonPagedPoolUsage; - SIZE_T PagefileUsage; - SIZE_T PeakPagefileUsage; - SIZE_T PrivateUsage; -} VM_COUNTERS_EX, *PVM_COUNTERS_EX; +typedef enum _IO_QUERY_DEVICE_DATA_FORMAT { + IoQueryDeviceIdentifier = 0, + IoQueryDeviceConfigurationData, + IoQueryDeviceComponentInformation, + IoQueryDeviceMaxData +} IO_QUERY_DEVICE_DATA_FORMAT, *PIO_QUERY_DEVICE_DATA_FORMAT; -typedef struct _POOLED_USAGE_AND_LIMITS -{ - SIZE_T PeakPagedPoolUsage; - SIZE_T PagedPoolUsage; - SIZE_T PagedPoolLimit; - SIZE_T PeakNonPagedPoolUsage; - SIZE_T NonPagedPoolUsage; - SIZE_T NonPagedPoolLimit; - SIZE_T PeakPagefileUsage; - SIZE_T PagefileUsage; - SIZE_T PagefileLimit; -} POOLED_USAGE_AND_LIMITS, *PPOOLED_USAGE_AND_LIMITS; +typedef VOID +(NTAPI *PDRIVER_REINITIALIZE)( + IN struct _DRIVER_OBJECT *DriverObject, + IN PVOID Context OPTIONAL, + IN ULONG Count); -/* DEVICE_OBJECT.Flags */ - -#define DO_VERIFY_VOLUME 0x00000002 -#define DO_BUFFERED_IO 0x00000004 -#define DO_EXCLUSIVE 0x00000008 -#define DO_DIRECT_IO 0x00000010 -#define DO_MAP_IO_BUFFER 0x00000020 -#define DO_DEVICE_HAS_NAME 0x00000040 -#define DO_DEVICE_INITIALIZING 0x00000080 -#define DO_SYSTEM_BOOT_PARTITION 0x00000100 -#define DO_LONG_TERM_REQUESTS 0x00000200 -#define DO_NEVER_LAST_DEVICE 0x00000400 -#define DO_SHUTDOWN_REGISTERED 0x00000800 -#define DO_BUS_ENUMERATED_DEVICE 0x00001000 -#define DO_POWER_PAGABLE 0x00002000 -#define DO_POWER_INRUSH 0x00004000 -#define DO_LOW_PRIORITY_FILESYSTEM 0x00010000 -#define DO_SUPPORTS_TRANSACTIONS 0x00040000 -#define DO_FORCE_NEITHER_IO 0x00080000 -#define DO_VOLUME_DEVICE_OBJECT 0x00100000 -#define DO_SYSTEM_SYSTEM_PARTITION 0x00200000 -#define DO_SYSTEM_CRITICAL_PARTITION 0x00400000 -#define DO_DISALLOW_EXECUTE 0x00800000 +typedef struct _CONTROLLER_OBJECT { + CSHORT Type; + CSHORT Size; + PVOID ControllerExtension; + KDEVICE_QUEUE DeviceWaitQueue; + ULONG Spare1; + LARGE_INTEGER Spare2; +} CONTROLLER_OBJECT, *PCONTROLLER_OBJECT; #define DRVO_REINIT_REGISTERED 0x00000008 #define DRVO_INITIALIZED 0x00000010 #define DRVO_BOOTREINIT_REGISTERED 0x00000020 #define DRVO_LEGACY_RESOURCES 0x00000040 -typedef enum _ARBITER_REQUEST_SOURCE { - ArbiterRequestUndefined = -1, - ArbiterRequestLegacyReported, - ArbiterRequestHalReported, - ArbiterRequestLegacyAssigned, - ArbiterRequestPnpDetected, - ArbiterRequestPnpEnumerated -} ARBITER_REQUEST_SOURCE; +typedef struct _CONFIGURATION_INFORMATION { + ULONG DiskCount; + ULONG FloppyCount; + ULONG CdRomCount; + ULONG TapeCount; + ULONG ScsiPortCount; + ULONG SerialCount; + ULONG ParallelCount; + BOOLEAN AtDiskPrimaryAddressClaimed; + BOOLEAN AtDiskSecondaryAddressClaimed; + ULONG Version; + ULONG MediumChangerCount; +} CONFIGURATION_INFORMATION, *PCONFIGURATION_INFORMATION; -typedef enum _ARBITER_RESULT { - ArbiterResultUndefined = -1, - ArbiterResultSuccess, - ArbiterResultExternalConflict, - ArbiterResultNullRequest -} ARBITER_RESULT; +typedef struct _DISK_SIGNATURE { + ULONG PartitionStyle; + _ANONYMOUS_UNION union { + struct { + ULONG Signature; + ULONG CheckSum; + } Mbr; + struct { + GUID DiskId; + } Gpt; + } DUMMYUNIONNAME; +} DISK_SIGNATURE, *PDISK_SIGNATURE; + +typedef struct _TXN_PARAMETER_BLOCK { + USHORT Length; + USHORT TxFsContext; + PVOID TransactionObject; +} TXN_PARAMETER_BLOCK, *PTXN_PARAMETER_BLOCK; + +#define TXF_MINIVERSION_DEFAULT_VIEW (0xFFFE) + +typedef struct _IO_DRIVER_CREATE_CONTEXT { + CSHORT Size; + struct _ECP_LIST *ExtraCreateParameter; + PVOID DeviceObjectHint; + PTXN_PARAMETER_BLOCK TxnParameters; +} IO_DRIVER_CREATE_CONTEXT, *PIO_DRIVER_CREATE_CONTEXT; + +typedef struct _AGP_TARGET_BUS_INTERFACE_STANDARD { + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; + PGET_SET_DEVICE_DATA SetBusData; + PGET_SET_DEVICE_DATA GetBusData; + UCHAR CapabilityID; +} AGP_TARGET_BUS_INTERFACE_STANDARD, *PAGP_TARGET_BUS_INTERFACE_STANDARD; + +typedef NTSTATUS +(NTAPI *PGET_LOCATION_STRING)( + IN OUT PVOID Context OPTIONAL, + OUT PWCHAR *LocationStrings); + +typedef struct _PNP_LOCATION_INTERFACE { + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; + PGET_LOCATION_STRING GetLocationString; +} PNP_LOCATION_INTERFACE, *PPNP_LOCATION_INTERFACE; typedef enum _ARBITER_ACTION { ArbiterActionTestAllocation, @@ -238,39 +342,69 @@ typedef struct _ARBITER_CONFLICT_INFO { ULONGLONG End; } ARBITER_CONFLICT_INFO, *PARBITER_CONFLICT_INFO; +typedef struct _ARBITER_TEST_ALLOCATION_PARAMETERS { + IN OUT PLIST_ENTRY ArbitrationList; + IN ULONG AllocateFromCount; + IN PCM_PARTIAL_RESOURCE_DESCRIPTOR AllocateFrom; +} ARBITER_TEST_ALLOCATION_PARAMETERS, *PARBITER_TEST_ALLOCATION_PARAMETERS; + +typedef struct _ARBITER_RETEST_ALLOCATION_PARAMETERS { + IN OUT PLIST_ENTRY ArbitrationList; + IN ULONG AllocateFromCount; + IN PCM_PARTIAL_RESOURCE_DESCRIPTOR AllocateFrom; +} ARBITER_RETEST_ALLOCATION_PARAMETERS, *PARBITER_RETEST_ALLOCATION_PARAMETERS; + +typedef struct _ARBITER_BOOT_ALLOCATION_PARAMETERS { + IN OUT PLIST_ENTRY ArbitrationList; +} ARBITER_BOOT_ALLOCATION_PARAMETERS, *PARBITER_BOOT_ALLOCATION_PARAMETERS; + +typedef struct _ARBITER_QUERY_ALLOCATED_RESOURCES_PARAMETERS { + OUT PCM_PARTIAL_RESOURCE_LIST *AllocatedResources; +} ARBITER_QUERY_ALLOCATED_RESOURCES_PARAMETERS, *PARBITER_QUERY_ALLOCATED_RESOURCES_PARAMETERS; + +typedef struct _ARBITER_QUERY_CONFLICT_PARAMETERS { + IN PDEVICE_OBJECT PhysicalDeviceObject; + IN PIO_RESOURCE_DESCRIPTOR ConflictingResource; + OUT PULONG ConflictCount; + OUT PARBITER_CONFLICT_INFO *Conflicts; +} ARBITER_QUERY_CONFLICT_PARAMETERS, *PARBITER_QUERY_CONFLICT_PARAMETERS; + +typedef struct _ARBITER_QUERY_ARBITRATE_PARAMETERS { + IN PLIST_ENTRY ArbitrationList; +} ARBITER_QUERY_ARBITRATE_PARAMETERS, *PARBITER_QUERY_ARBITRATE_PARAMETERS; + +typedef struct _ARBITER_ADD_RESERVED_PARAMETERS { + IN PDEVICE_OBJECT ReserveDevice; +} ARBITER_ADD_RESERVED_PARAMETERS, *PARBITER_ADD_RESERVED_PARAMETERS; + typedef struct _ARBITER_PARAMETERS { union { - struct { - IN OUT PLIST_ENTRY ArbitrationList; - IN ULONG AllocateFromCount; - IN PCM_PARTIAL_RESOURCE_DESCRIPTOR AllocateFrom; - } TestAllocation; - struct { - IN OUT PLIST_ENTRY ArbitrationList; - IN ULONG AllocateFromCount; - IN PCM_PARTIAL_RESOURCE_DESCRIPTOR AllocateFrom; - } RetestAllocation; - struct { - IN OUT PLIST_ENTRY ArbitrationList; - } BootAllocation; - struct { - OUT PCM_PARTIAL_RESOURCE_LIST *AllocatedResources; - } QueryAllocatedResources; - struct { - IN PDEVICE_OBJECT PhysicalDeviceObject; - IN PIO_RESOURCE_DESCRIPTOR ConflictingResource; - OUT PULONG ConflictCount; - OUT PARBITER_CONFLICT_INFO *Conflicts; - } QueryConflict; - struct { - IN PLIST_ENTRY ArbitrationList; - } QueryArbitrate; - struct { - IN PDEVICE_OBJECT ReserveDevice; - } AddReserved; + ARBITER_TEST_ALLOCATION_PARAMETERS TestAllocation; + ARBITER_RETEST_ALLOCATION_PARAMETERS RetestAllocation; + ARBITER_BOOT_ALLOCATION_PARAMETERS BootAllocation; + ARBITER_QUERY_ALLOCATED_RESOURCES_PARAMETERS QueryAllocatedResources; + ARBITER_QUERY_CONFLICT_PARAMETERS QueryConflict; + ARBITER_QUERY_ARBITRATE_PARAMETERS QueryArbitrate; + ARBITER_ADD_RESERVED_PARAMETERS AddReserved; } Parameters; } ARBITER_PARAMETERS, *PARBITER_PARAMETERS; +typedef enum _ARBITER_REQUEST_SOURCE { + ArbiterRequestUndefined = -1, + ArbiterRequestLegacyReported, + ArbiterRequestHalReported, + ArbiterRequestLegacyAssigned, + ArbiterRequestPnpDetected, + ArbiterRequestPnpEnumerated +} ARBITER_REQUEST_SOURCE; + +typedef enum _ARBITER_RESULT { + ArbiterResultUndefined = -1, + ArbiterResultSuccess, + ArbiterResultExternalConflict, + ArbiterResultNullRequest +} ARBITER_RESULT; + #define ARBITER_FLAG_BOOT_CONFIG 0x00000001 typedef struct _ARBITER_LIST_ENTRY { @@ -307,6 +441,826 @@ typedef struct _ARBITER_INTERFACE { ULONG Flags; } ARBITER_INTERFACE, *PARBITER_INTERFACE; +typedef enum _RESOURCE_TRANSLATION_DIRECTION { + TranslateChildToParent, + TranslateParentToChild +} RESOURCE_TRANSLATION_DIRECTION; + +typedef NTSTATUS +(NTAPI *PTRANSLATE_RESOURCE_HANDLER)( + IN OUT PVOID Context OPTIONAL, + IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Source, + IN RESOURCE_TRANSLATION_DIRECTION Direction, + IN ULONG AlternativesCount OPTIONAL, + IN IO_RESOURCE_DESCRIPTOR Alternatives[], + IN PDEVICE_OBJECT PhysicalDeviceObject, + OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR Target); + +typedef NTSTATUS +(NTAPI *PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER)( + IN OUT PVOID Context OPTIONAL, + IN PIO_RESOURCE_DESCRIPTOR Source, + IN PDEVICE_OBJECT PhysicalDeviceObject, + OUT PULONG TargetCount, + OUT PIO_RESOURCE_DESCRIPTOR *Target); + +typedef struct _TRANSLATOR_INTERFACE { + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; + PTRANSLATE_RESOURCE_HANDLER TranslateResources; + PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER TranslateResourceRequirements; +} TRANSLATOR_INTERFACE, *PTRANSLATOR_INTERFACE; + +typedef struct _PCI_AGP_CAPABILITY { + PCI_CAPABILITIES_HEADER Header; + USHORT Minor:4; + USHORT Major:4; + USHORT Rsvd1:8; + struct _PCI_AGP_STATUS { + ULONG Rate:3; + ULONG Agp3Mode:1; + ULONG FastWrite:1; + ULONG FourGB:1; + ULONG HostTransDisable:1; + ULONG Gart64:1; + ULONG ITA_Coherent:1; + ULONG SideBandAddressing:1; + ULONG CalibrationCycle:3; + ULONG AsyncRequestSize:3; + ULONG Rsvd1:1; + ULONG Isoch:1; + ULONG Rsvd2:6; + ULONG RequestQueueDepthMaximum:8; + } AGPStatus; + struct _PCI_AGP_COMMAND { + ULONG Rate:3; + ULONG Rsvd1:1; + ULONG FastWriteEnable:1; + ULONG FourGBEnable:1; + ULONG Rsvd2:1; + ULONG Gart64:1; + ULONG AGPEnable:1; + ULONG SBAEnable:1; + ULONG CalibrationCycle:3; + ULONG AsyncReqSize:3; + ULONG Rsvd3:8; + ULONG RequestQueueDepth:8; + } AGPCommand; +} PCI_AGP_CAPABILITY, *PPCI_AGP_CAPABILITY; + +typedef enum _EXTENDED_AGP_REGISTER { + IsochStatus, + AgpControl, + ApertureSize, + AperturePageSize, + GartLow, + GartHigh, + IsochCommand +} EXTENDED_AGP_REGISTER, *PEXTENDED_AGP_REGISTER; + +typedef struct _PCI_AGP_ISOCH_STATUS { + ULONG ErrorCode:2; + ULONG Rsvd1:1; + ULONG Isoch_L:3; + ULONG Isoch_Y:2; + ULONG Isoch_N:8; + ULONG Rsvd2:16; +} PCI_AGP_ISOCH_STATUS, *PPCI_AGP_ISOCH_STATUS; + +typedef struct _PCI_AGP_CONTROL { + ULONG Rsvd1:7; + ULONG GTLB_Enable:1; + ULONG AP_Enable:1; + ULONG CAL_Disable:1; + ULONG Rsvd2:22; +} PCI_AGP_CONTROL, *PPCI_AGP_CONTROL; + +typedef struct _PCI_AGP_APERTURE_PAGE_SIZE { + USHORT PageSizeMask:11; + USHORT Rsvd1:1; + USHORT PageSizeSelect:4; +} PCI_AGP_APERTURE_PAGE_SIZE, *PPCI_AGP_APERTURE_PAGE_SIZE; + +typedef struct _PCI_AGP_ISOCH_COMMAND { + USHORT Rsvd1:6; + USHORT Isoch_Y:2; + USHORT Isoch_N:8; +} PCI_AGP_ISOCH_COMMAND, *PPCI_AGP_ISOCH_COMMAND; + +typedef struct PCI_AGP_EXTENDED_CAPABILITY { + PCI_AGP_ISOCH_STATUS IsochStatus; + PCI_AGP_CONTROL AgpControl; + USHORT ApertureSize; + PCI_AGP_APERTURE_PAGE_SIZE AperturePageSize; + ULONG GartLow; + ULONG GartHigh; + PCI_AGP_ISOCH_COMMAND IsochCommand; +} PCI_AGP_EXTENDED_CAPABILITY, *PPCI_AGP_EXTENDED_CAPABILITY; + +#define PCI_AGP_RATE_1X 0x1 +#define PCI_AGP_RATE_2X 0x2 +#define PCI_AGP_RATE_4X 0x4 + +#define PCIX_MODE_CONVENTIONAL_PCI 0x0 +#define PCIX_MODE1_66MHZ 0x1 +#define PCIX_MODE1_100MHZ 0x2 +#define PCIX_MODE1_133MHZ 0x3 +#define PCIX_MODE2_266_66MHZ 0x9 +#define PCIX_MODE2_266_100MHZ 0xA +#define PCIX_MODE2_266_133MHZ 0xB +#define PCIX_MODE2_533_66MHZ 0xD +#define PCIX_MODE2_533_100MHZ 0xE +#define PCIX_MODE2_533_133MHZ 0xF + +#define PCIX_VERSION_MODE1_ONLY 0x0 +#define PCIX_VERSION_MODE2_ECC 0x1 +#define PCIX_VERSION_DUAL_MODE_ECC 0x2 + +typedef struct _PCIX_BRIDGE_CAPABILITY { + PCI_CAPABILITIES_HEADER Header; + union { + struct { + USHORT Bus64Bit:1; + USHORT Bus133MHzCapable:1; + USHORT SplitCompletionDiscarded:1; + USHORT UnexpectedSplitCompletion:1; + USHORT SplitCompletionOverrun:1; + USHORT SplitRequestDelayed:1; + USHORT BusModeFrequency:4; + USHORT Rsvd:2; + USHORT Version:2; + USHORT Bus266MHzCapable:1; + USHORT Bus533MHzCapable:1; + } DUMMYSTRUCTNAME; + USHORT AsUSHORT; + } SecondaryStatus; + union { + struct { + ULONG FunctionNumber:3; + ULONG DeviceNumber:5; + ULONG BusNumber:8; + ULONG Device64Bit:1; + ULONG Device133MHzCapable:1; + ULONG SplitCompletionDiscarded:1; + ULONG UnexpectedSplitCompletion:1; + ULONG SplitCompletionOverrun:1; + ULONG SplitRequestDelayed:1; + ULONG Rsvd:7; + ULONG DIMCapable:1; + ULONG Device266MHzCapable:1; + ULONG Device533MHzCapable:1; + } DUMMYSTRUCTNAME; + ULONG AsULONG; + } BridgeStatus; + USHORT UpstreamSplitTransactionCapacity; + USHORT UpstreamSplitTransactionLimit; + USHORT DownstreamSplitTransactionCapacity; + USHORT DownstreamSplitTransactionLimit; + union { + struct { + ULONG SelectSecondaryRegisters:1; + ULONG ErrorPresentInOtherBank:1; + ULONG AdditionalCorrectableError:1; + ULONG AdditionalUncorrectableError:1; + ULONG ErrorPhase:3; + ULONG ErrorCorrected:1; + ULONG Syndrome:8; + ULONG ErrorFirstCommand:4; + ULONG ErrorSecondCommand:4; + ULONG ErrorUpperAttributes:4; + ULONG ControlUpdateEnable:1; + ULONG Rsvd:1; + ULONG DisableSingleBitCorrection:1; + ULONG EccMode:1; + } DUMMYSTRUCTNAME; + ULONG AsULONG; + } EccControlStatus; + ULONG EccFirstAddress; + ULONG EccSecondAddress; + ULONG EccAttribute; +} PCIX_BRIDGE_CAPABILITY, *PPCIX_BRIDGE_CAPABILITY; + +typedef struct _PCI_SUBSYSTEM_IDS_CAPABILITY { + PCI_CAPABILITIES_HEADER Header; + USHORT Reserved; + USHORT SubVendorID; + USHORT SubSystemID; +} PCI_SUBSYSTEM_IDS_CAPABILITY, *PPCI_SUBSYSTEM_IDS_CAPABILITY; + +#define OSC_FIRMWARE_FAILURE 0x02 +#define OSC_UNRECOGNIZED_UUID 0x04 +#define OSC_UNRECOGNIZED_REVISION 0x08 +#define OSC_CAPABILITIES_MASKED 0x10 + +#define PCI_ROOT_BUS_OSC_METHOD_CAPABILITY_REVISION 0x01 + +typedef struct _PCI_ROOT_BUS_OSC_SUPPORT_FIELD { + union { + struct { + ULONG ExtendedConfigOpRegions:1; + ULONG ActiveStatePowerManagement:1; + ULONG ClockPowerManagement:1; + ULONG SegmentGroups:1; + ULONG MessageSignaledInterrupts:1; + ULONG WindowsHardwareErrorArchitecture:1; + ULONG Reserved:26; + } DUMMYSTRUCTNAME; + ULONG AsULONG; + } u; +} PCI_ROOT_BUS_OSC_SUPPORT_FIELD, *PPCI_ROOT_BUS_OSC_SUPPORT_FIELD; + +typedef struct _PCI_ROOT_BUS_OSC_CONTROL_FIELD { + union { + struct { + ULONG ExpressNativeHotPlug:1; + ULONG ShpcNativeHotPlug:1; + ULONG ExpressNativePME:1; + ULONG ExpressAdvancedErrorReporting:1; + ULONG ExpressCapabilityStructure:1; + ULONG Reserved:27; + } DUMMYSTRUCTNAME; + ULONG AsULONG; + } u; +} PCI_ROOT_BUS_OSC_CONTROL_FIELD, *PPCI_ROOT_BUS_OSC_CONTROL_FIELD; + +typedef enum _PCI_HARDWARE_INTERFACE { + PciConventional, + PciXMode1, + PciXMode2, + PciExpress +} PCI_HARDWARE_INTERFACE, *PPCI_HARDWARE_INTERFACE; + +typedef enum { + BusWidth32Bits, + BusWidth64Bits +} PCI_BUS_WIDTH; + +typedef struct _PCI_ROOT_BUS_HARDWARE_CAPABILITY { + PCI_HARDWARE_INTERFACE SecondaryInterface; + struct { + BOOLEAN BusCapabilitiesFound; + ULONG CurrentSpeedAndMode; + ULONG SupportedSpeedsAndModes; + BOOLEAN DeviceIDMessagingCapable; + PCI_BUS_WIDTH SecondaryBusWidth; + } DUMMYSTRUCTNAME; + PCI_ROOT_BUS_OSC_SUPPORT_FIELD OscFeatureSupport; + PCI_ROOT_BUS_OSC_CONTROL_FIELD OscControlRequest; + PCI_ROOT_BUS_OSC_CONTROL_FIELD OscControlGranted; +} PCI_ROOT_BUS_HARDWARE_CAPABILITY, *PPCI_ROOT_BUS_HARDWARE_CAPABILITY; + +typedef union _PCI_EXPRESS_CAPABILITIES_REGISTER { + struct { + USHORT CapabilityVersion:4; + USHORT DeviceType:4; + USHORT SlotImplemented:1; + USHORT InterruptMessageNumber:5; + USHORT Rsvd:2; + } DUMMYSTRUCTNAME; + USHORT AsUSHORT; +} PCI_EXPRESS_CAPABILITIES_REGISTER, *PPCI_EXPRESS_CAPABILITIES_REGISTER; + +typedef union _PCI_EXPRESS_DEVICE_CAPABILITIES_REGISTER { + struct { + ULONG MaxPayloadSizeSupported:3; + ULONG PhantomFunctionsSupported:2; + ULONG ExtendedTagSupported:1; + ULONG L0sAcceptableLatency:3; + ULONG L1AcceptableLatency:3; + ULONG Undefined:3; + ULONG RoleBasedErrorReporting:1; + ULONG Rsvd1:2; + ULONG CapturedSlotPowerLimit:8; + ULONG CapturedSlotPowerLimitScale:2; + ULONG Rsvd2:4; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_DEVICE_CAPABILITIES_REGISTER, *PPCI_EXPRESS_DEVICE_CAPABILITIES_REGISTER; + +#define PCI_EXPRESS_AER_DEVICE_CONTROL_MASK 0x07; + +typedef union _PCI_EXPRESS_DEVICE_CONTROL_REGISTER { + struct { + USHORT CorrectableErrorEnable:1; + USHORT NonFatalErrorEnable:1; + USHORT FatalErrorEnable:1; + USHORT UnsupportedRequestErrorEnable:1; + USHORT EnableRelaxedOrder:1; + USHORT MaxPayloadSize:3; + USHORT ExtendedTagEnable:1; + USHORT PhantomFunctionsEnable:1; + USHORT AuxPowerEnable:1; + USHORT NoSnoopEnable:1; + USHORT MaxReadRequestSize:3; + USHORT BridgeConfigRetryEnable:1; + } DUMMYSTRUCTNAME; + USHORT AsUSHORT; +} PCI_EXPRESS_DEVICE_CONTROL_REGISTER, *PPCI_EXPRESS_DEVICE_CONTROL_REGISTER; + +#define PCI_EXPRESS_AER_DEVICE_STATUS_MASK 0x0F; + +typedef union _PCI_EXPRESS_DEVICE_STATUS_REGISTER { + struct { + USHORT CorrectableErrorDetected:1; + USHORT NonFatalErrorDetected:1; + USHORT FatalErrorDetected:1; + USHORT UnsupportedRequestDetected:1; + USHORT AuxPowerDetected:1; + USHORT TransactionsPending:1; + USHORT Rsvd:10; + } DUMMYSTRUCTNAME; + USHORT AsUSHORT; +} PCI_EXPRESS_DEVICE_STATUS_REGISTER, *PPCI_EXPRESS_DEVICE_STATUS_REGISTER; + +typedef union _PCI_EXPRESS_LINK_CAPABILITIES_REGISTER { + struct { + ULONG MaximumLinkSpeed:4; + ULONG MaximumLinkWidth:6; + ULONG ActiveStatePMSupport:2; + ULONG L0sExitLatency:3; + ULONG L1ExitLatency:3; + ULONG ClockPowerManagement:1; + ULONG SurpriseDownErrorReportingCapable:1; + ULONG DataLinkLayerActiveReportingCapable:1; + ULONG Rsvd:3; + ULONG PortNumber:8; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_LINK_CAPABILITIES_REGISTER, *PPCI_EXPRESS_LINK_CAPABILITIES_REGISTER; + +typedef union _PCI_EXPRESS_LINK_CONTROL_REGISTER { + struct { + USHORT ActiveStatePMControl:2; + USHORT Rsvd1:1; + USHORT ReadCompletionBoundary:1; + USHORT LinkDisable:1; + USHORT RetrainLink:1; + USHORT CommonClockConfig:1; + USHORT ExtendedSynch:1; + USHORT EnableClockPowerManagement:1; + USHORT Rsvd2:7; + } DUMMYSTRUCTNAME; + USHORT AsUSHORT; +} PCI_EXPRESS_LINK_CONTROL_REGISTER, *PPCI_EXPRESS_LINK_CONTROL_REGISTER; + +typedef union _PCI_EXPRESS_LINK_STATUS_REGISTER { + struct { + USHORT LinkSpeed:4; + USHORT LinkWidth:6; + USHORT Undefined:1; + USHORT LinkTraining:1; + USHORT SlotClockConfig:1; + USHORT DataLinkLayerActive:1; + USHORT Rsvd:2; + } DUMMYSTRUCTNAME; + USHORT AsUSHORT; +} PCI_EXPRESS_LINK_STATUS_REGISTER, *PPCI_EXPRESS_LINK_STATUS_REGISTER; + +typedef union _PCI_EXPRESS_SLOT_CAPABILITIES_REGISTER { + struct { + ULONG AttentionButtonPresent:1; + ULONG PowerControllerPresent:1; + ULONG MRLSensorPresent:1; + ULONG AttentionIndicatorPresent:1; + ULONG PowerIndicatorPresent:1; + ULONG HotPlugSurprise:1; + ULONG HotPlugCapable:1; + ULONG SlotPowerLimit:8; + ULONG SlotPowerLimitScale:2; + ULONG ElectromechanicalLockPresent:1; + ULONG NoCommandCompletedSupport:1; + ULONG PhysicalSlotNumber:13; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_SLOT_CAPABILITIES_REGISTER, *PPCI_EXPRESS_SLOT_CAPABILITIES_REGISTER; + +typedef union _PCI_EXPRESS_SLOT_CONTROL_REGISTER { + struct { + USHORT AttentionButtonEnable:1; + USHORT PowerFaultDetectEnable:1; + USHORT MRLSensorEnable:1; + USHORT PresenceDetectEnable:1; + USHORT CommandCompletedEnable:1; + USHORT HotPlugInterruptEnable:1; + USHORT AttentionIndicatorControl:2; + USHORT PowerIndicatorControl:2; + USHORT PowerControllerControl:1; + USHORT ElectromechanicalLockControl:1; + USHORT DataLinkStateChangeEnable:1; + USHORT Rsvd:3; + } DUMMYSTRUCTNAME; + USHORT AsUSHORT; +} PCI_EXPRESS_SLOT_CONTROL_REGISTER, *PPCI_EXPRESS_SLOT_CONTROL_REGISTER; + +typedef union _PCI_EXPRESS_SLOT_STATUS_REGISTER { + struct { + USHORT AttentionButtonPressed:1; + USHORT PowerFaultDetected:1; + USHORT MRLSensorChanged:1; + USHORT PresenceDetectChanged:1; + USHORT CommandCompleted:1; + USHORT MRLSensorState:1; + USHORT PresenceDetectState:1; + USHORT ElectromechanicalLockEngaged:1; + USHORT DataLinkStateChanged:1; + USHORT Rsvd:7; + } DUMMYSTRUCTNAME; + USHORT AsUSHORT; +} PCI_EXPRESS_SLOT_STATUS_REGISTER, *PPCI_EXPRESS_SLOT_STATUS_REGISTER; + +typedef union _PCI_EXPRESS_ROOT_CONTROL_REGISTER { + struct { + USHORT CorrectableSerrEnable:1; + USHORT NonFatalSerrEnable:1; + USHORT FatalSerrEnable:1; + USHORT PMEInterruptEnable:1; + USHORT CRSSoftwareVisibilityEnable:1; + USHORT Rsvd:11; + } DUMMYSTRUCTNAME; + USHORT AsUSHORT; +} PCI_EXPRESS_ROOT_CONTROL_REGISTER, *PPCI_EXPRESS_ROOT_CONTROL_REGISTER; + +typedef union _PCI_EXPRESS_ROOT_CAPABILITIES_REGISTER { + struct { + USHORT CRSSoftwareVisibility:1; + USHORT Rsvd:15; + } DUMMYSTRUCTNAME; + USHORT AsUSHORT; +} PCI_EXPRESS_ROOT_CAPABILITIES_REGISTER, *PPCI_EXPRESS_ROOT_CAPABILITIES_REGISTER; + +typedef union _PCI_EXPRESS_ROOT_STATUS_REGISTER { + struct { + ULONG PMERequestorId:16; + ULONG PMEStatus:1; + ULONG PMEPending:1; + ULONG Rsvd:14; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_ROOT_STATUS_REGISTER, *PPCI_EXPRESS_ROOT_STATUS_REGISTER; + +typedef struct _PCI_EXPRESS_CAPABILITY { + PCI_CAPABILITIES_HEADER Header; + PCI_EXPRESS_CAPABILITIES_REGISTER ExpressCapabilities; + PCI_EXPRESS_DEVICE_CAPABILITIES_REGISTER DeviceCapabilities; + PCI_EXPRESS_DEVICE_CONTROL_REGISTER DeviceControl; + PCI_EXPRESS_DEVICE_STATUS_REGISTER DeviceStatus; + PCI_EXPRESS_LINK_CAPABILITIES_REGISTER LinkCapabilities; + PCI_EXPRESS_LINK_CONTROL_REGISTER LinkControl; + PCI_EXPRESS_LINK_STATUS_REGISTER LinkStatus; + PCI_EXPRESS_SLOT_CAPABILITIES_REGISTER SlotCapabilities; + PCI_EXPRESS_SLOT_CONTROL_REGISTER SlotControl; + PCI_EXPRESS_SLOT_STATUS_REGISTER SlotStatus; + PCI_EXPRESS_ROOT_CONTROL_REGISTER RootControl; + PCI_EXPRESS_ROOT_CAPABILITIES_REGISTER RootCapabilities; + PCI_EXPRESS_ROOT_STATUS_REGISTER RootStatus; +} PCI_EXPRESS_CAPABILITY, *PPCI_EXPRESS_CAPABILITY; + +typedef enum { + MRLClosed = 0, + MRLOpen +} PCI_EXPRESS_MRL_STATE; + +typedef enum { + SlotEmpty = 0, + CardPresent +} PCI_EXPRESS_CARD_PRESENCE; + +typedef enum { + IndicatorOn = 1, + IndicatorBlink, + IndicatorOff +} PCI_EXPRESS_INDICATOR_STATE; + +typedef enum { + PowerOn = 0, + PowerOff +} PCI_EXPRESS_POWER_STATE; + +typedef enum { + L0sEntrySupport = 1, + L0sAndL1EntrySupport = 3 +} PCI_EXPRESS_ASPM_SUPPORT; + +typedef enum { + L0sAndL1EntryDisabled, + L0sEntryEnabled, + L1EntryEnabled, + L0sAndL1EntryEnabled +} PCI_EXPRESS_ASPM_CONTROL; + +typedef enum { + L0s_Below64ns = 0, + L0s_64ns_128ns, + L0s_128ns_256ns, + L0s_256ns_512ns, + L0s_512ns_1us, + L0s_1us_2us, + L0s_2us_4us, + L0s_Above4us +} PCI_EXPRESS_L0s_EXIT_LATENCY; + +typedef enum { + L1_Below1us = 0, + L1_1us_2us, + L1_2us_4us, + L1_4us_8us, + L1_8us_16us, + L1_16us_32us, + L1_32us_64us, + L1_Above64us +} PCI_EXPRESS_L1_EXIT_LATENCY; + +typedef enum { + PciExpressEndpoint = 0, + PciExpressLegacyEndpoint, + PciExpressRootPort = 4, + PciExpressUpstreamSwitchPort, + PciExpressDownstreamSwitchPort, + PciExpressToPciXBridge, + PciXToExpressBridge, + PciExpressRootComplexIntegratedEndpoint, + PciExpressRootComplexEventCollector +} PCI_EXPRESS_DEVICE_TYPE; + +typedef enum { + MaxPayload128Bytes = 0, + MaxPayload256Bytes, + MaxPayload512Bytes, + MaxPayload1024Bytes, + MaxPayload2048Bytes, + MaxPayload4096Bytes +} PCI_EXPRESS_MAX_PAYLOAD_SIZE; + +typedef union _PCI_EXPRESS_PME_REQUESTOR_ID { + struct { + USHORT FunctionNumber:3; + USHORT DeviceNumber:5; + USHORT BusNumber:8; + } DUMMYSTRUCTNAME; + USHORT AsUSHORT; +} PCI_EXPRESS_PME_REQUESTOR_ID, *PPCI_EXPRESS_PME_REQUESTOR_ID; + +#if defined(_WIN64) + +#ifndef USE_DMA_MACROS +#define USE_DMA_MACROS +#endif + +#ifndef NO_LEGACY_DRIVERS +#define NO_LEGACY_DRIVERS +#endif + +#endif /* defined(_WIN64) */ + +typedef enum _PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR_TYPE { + ResourceTypeSingle = 0, + ResourceTypeRange, + ResourceTypeExtendedCounterConfiguration, + ResourceTypeOverflow, + ResourceTypeMax +} PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR_TYPE; + +typedef struct _PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR { + PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR_TYPE Type; + ULONG Flags; + union { + ULONG CounterIndex; + ULONG ExtendedRegisterAddress; + struct { + ULONG Begin; + ULONG End; + } Range; + } u; +} PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR, *PPHYSICAL_COUNTER_RESOURCE_DESCRIPTOR; + +typedef struct _PHYSICAL_COUNTER_RESOURCE_LIST { + ULONG Count; + PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR Descriptors[ANYSIZE_ARRAY]; +} PHYSICAL_COUNTER_RESOURCE_LIST, *PPHYSICAL_COUNTER_RESOURCE_LIST; + +typedef VOID +(NTAPI *PciPin2Line)( + IN struct _BUS_HANDLER *BusHandler, + IN struct _BUS_HANDLER *RootHandler, + IN PCI_SLOT_NUMBER SlotNumber, + IN PPCI_COMMON_CONFIG PciData); + +typedef VOID +(NTAPI *PciLine2Pin)( + IN struct _BUS_HANDLER *BusHandler, + IN struct _BUS_HANDLER *RootHandler, + IN PCI_SLOT_NUMBER SlotNumber, + IN PPCI_COMMON_CONFIG PciNewData, + IN PPCI_COMMON_CONFIG PciOldData); + +typedef VOID +(NTAPI *PciReadWriteConfig)( + IN struct _BUS_HANDLER *BusHandler, + IN PCI_SLOT_NUMBER Slot, + IN PVOID Buffer, + IN ULONG Offset, + IN ULONG Length); + +#define PCI_DATA_TAG ' ICP' +#define PCI_DATA_VERSION 1 + +typedef struct _PCIBUSDATA { + ULONG Tag; + ULONG Version; + PciReadWriteConfig ReadConfig; + PciReadWriteConfig WriteConfig; + PciPin2Line Pin2Line; + PciLine2Pin Line2Pin; + PCI_SLOT_NUMBER ParentSlot; + PVOID Reserved[4]; +} PCIBUSDATA, *PPCIBUSDATA; + +#ifndef _PCIINTRF_X_ +#define _PCIINTRF_X_ + +typedef ULONG +(NTAPI *PCI_READ_WRITE_CONFIG)( + IN PVOID Context, + IN ULONG BusOffset, + IN ULONG Slot, + IN PVOID Buffer, + IN ULONG Offset, + IN ULONG Length); + +typedef VOID +(NTAPI *PCI_PIN_TO_LINE)( + IN PVOID Context, + IN PPCI_COMMON_CONFIG PciData); + +typedef VOID +(NTAPI *PCI_LINE_TO_PIN)( + IN PVOID Context, + IN PPCI_COMMON_CONFIG PciNewData, + IN PPCI_COMMON_CONFIG PciOldData); + +typedef VOID +(NTAPI *PCI_ROOT_BUS_CAPABILITY)( + IN PVOID Context, + OUT PPCI_ROOT_BUS_HARDWARE_CAPABILITY HardwareCapability); + +typedef VOID +(NTAPI *PCI_EXPRESS_WAKE_CONTROL)( + IN PVOID Context, + IN BOOLEAN EnableWake); + +typedef struct _PCI_BUS_INTERFACE_STANDARD { + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; + PCI_READ_WRITE_CONFIG ReadConfig; + PCI_READ_WRITE_CONFIG WriteConfig; + PCI_PIN_TO_LINE PinToLine; + PCI_LINE_TO_PIN LineToPin; + PCI_ROOT_BUS_CAPABILITY RootBusCapability; + PCI_EXPRESS_WAKE_CONTROL ExpressWakeControl; +} PCI_BUS_INTERFACE_STANDARD, *PPCI_BUS_INTERFACE_STANDARD; + +#define PCI_BUS_INTERFACE_STANDARD_VERSION 1 + +#endif /* _PCIINTRF_X_ */ + +#if (NTDDI_VERSION >= NTDDI_WIN7) + +#define FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL_EX 0x00004000 +#define FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL_EX 0x00008000 +#define FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK_EX \ + (FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL_EX | \ + FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL_EX) + +#define FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL_DEPRECATED 0x00000200 +#define FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL_DEPRECATED 0x00000300 +#define FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK_DEPRECATED 0x00000300 + +#else + +#define FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL 0x00000200 +#define FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL 0x00000300 +#define FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK 0x00000300 + +#define FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL_EX FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL +#define FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL_EX FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL +#define FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK_EX FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + +#define FILE_CHARACTERISTICS_PROPAGATED ( FILE_REMOVABLE_MEDIA | \ + FILE_READ_ONLY_DEVICE | \ + FILE_FLOPPY_DISKETTE | \ + FILE_WRITE_ONCE_MEDIA | \ + FILE_DEVICE_SECURE_OPEN ) + +typedef struct _FILE_ALIGNMENT_INFORMATION { + ULONG AlignmentRequirement; +} FILE_ALIGNMENT_INFORMATION, *PFILE_ALIGNMENT_INFORMATION; + +typedef struct _FILE_NAME_INFORMATION { + ULONG FileNameLength; + WCHAR FileName[1]; +} FILE_NAME_INFORMATION, *PFILE_NAME_INFORMATION; + + +typedef struct _FILE_ATTRIBUTE_TAG_INFORMATION { + ULONG FileAttributes; + ULONG ReparseTag; +} FILE_ATTRIBUTE_TAG_INFORMATION, *PFILE_ATTRIBUTE_TAG_INFORMATION; + +typedef struct _FILE_DISPOSITION_INFORMATION { + BOOLEAN DeleteFile; +} FILE_DISPOSITION_INFORMATION, *PFILE_DISPOSITION_INFORMATION; + +typedef struct _FILE_END_OF_FILE_INFORMATION { + LARGE_INTEGER EndOfFile; +} FILE_END_OF_FILE_INFORMATION, *PFILE_END_OF_FILE_INFORMATION; + +typedef struct _FILE_VALID_DATA_LENGTH_INFORMATION { + LARGE_INTEGER ValidDataLength; +} FILE_VALID_DATA_LENGTH_INFORMATION, *PFILE_VALID_DATA_LENGTH_INFORMATION; + +typedef struct _FILE_FS_LABEL_INFORMATION { + ULONG VolumeLabelLength; + WCHAR VolumeLabel[1]; +} FILE_FS_LABEL_INFORMATION, *PFILE_FS_LABEL_INFORMATION; + +typedef struct _FILE_FS_VOLUME_INFORMATION { + LARGE_INTEGER VolumeCreationTime; + ULONG VolumeSerialNumber; + ULONG VolumeLabelLength; + BOOLEAN SupportsObjects; + WCHAR VolumeLabel[1]; +} FILE_FS_VOLUME_INFORMATION, *PFILE_FS_VOLUME_INFORMATION; + +typedef struct _FILE_FS_SIZE_INFORMATION { + LARGE_INTEGER TotalAllocationUnits; + LARGE_INTEGER AvailableAllocationUnits; + ULONG SectorsPerAllocationUnit; + ULONG BytesPerSector; +} FILE_FS_SIZE_INFORMATION, *PFILE_FS_SIZE_INFORMATION; + +typedef struct _FILE_FS_FULL_SIZE_INFORMATION { + LARGE_INTEGER TotalAllocationUnits; + LARGE_INTEGER CallerAvailableAllocationUnits; + LARGE_INTEGER ActualAvailableAllocationUnits; + ULONG SectorsPerAllocationUnit; + ULONG BytesPerSector; +} FILE_FS_FULL_SIZE_INFORMATION, *PFILE_FS_FULL_SIZE_INFORMATION; + +typedef struct _FILE_FS_OBJECTID_INFORMATION { + UCHAR ObjectId[16]; + UCHAR ExtendedInfo[48]; +} FILE_FS_OBJECTID_INFORMATION, *PFILE_FS_OBJECTID_INFORMATION; + +typedef union _FILE_SEGMENT_ELEMENT { + PVOID64 Buffer; + ULONGLONG Alignment; +}FILE_SEGMENT_ELEMENT, *PFILE_SEGMENT_ELEMENT; + +#define IOCTL_AVIO_ALLOCATE_STREAM CTL_CODE(FILE_DEVICE_AVIO, 1, METHOD_BUFFERED, FILE_SPECIAL_ACCESS) +#define IOCTL_AVIO_FREE_STREAM CTL_CODE(FILE_DEVICE_AVIO, 2, METHOD_BUFFERED, FILE_SPECIAL_ACCESS) +#define IOCTL_AVIO_MODIFY_STREAM CTL_CODE(FILE_DEVICE_AVIO, 3, METHOD_BUFFERED, FILE_SPECIAL_ACCESS) + +typedef enum _BUS_DATA_TYPE { + ConfigurationSpaceUndefined = -1, + Cmos, + EisaConfiguration, + Pos, + CbusConfiguration, + PCIConfiguration, + VMEConfiguration, + NuBusConfiguration, + PCMCIAConfiguration, + MPIConfiguration, + MPSAConfiguration, + PNPISAConfiguration, + SgiInternalConfiguration, + MaximumBusDataType +} BUS_DATA_TYPE, *PBUS_DATA_TYPE; + +/* Hardware Abstraction Layer Types */ + +typedef BOOLEAN +(NTAPI *PHAL_RESET_DISPLAY_PARAMETERS)( + IN ULONG Columns, + IN ULONG Rows); + +typedef PBUS_HANDLER +(FASTCALL *pHalHandlerForBus)( + IN INTERFACE_TYPE InterfaceType, + IN ULONG BusNumber); + +typedef VOID +(FASTCALL *pHalReferenceBusHandler)( + IN PBUS_HANDLER BusHandler); + typedef enum _HAL_QUERY_INFORMATION_CLASS { HalInstalledBusInformation, HalProfileSourceInformation, @@ -353,92 +1307,18 @@ typedef enum _HAL_SET_INFORMATION_CLASS { HalProfileDpgoSourceInterruptHandler } HAL_SET_INFORMATION_CLASS, *PHAL_SET_INFORMATION_CLASS; -typedef struct _HAL_PROFILE_SOURCE_INTERVAL { - KPROFILE_SOURCE Source; - ULONG_PTR Interval; -} HAL_PROFILE_SOURCE_INTERVAL, *PHAL_PROFILE_SOURCE_INTERVAL; - -typedef struct _HAL_PROFILE_SOURCE_INFORMATION { - KPROFILE_SOURCE Source; - BOOLEAN Supported; - ULONG Interval; -} HAL_PROFILE_SOURCE_INFORMATION, *PHAL_PROFILE_SOURCE_INFORMATION; - -typedef struct _MAP_REGISTER_ENTRY { - PVOID MapRegister; - BOOLEAN WriteToDevice; -} MAP_REGISTER_ENTRY, *PMAP_REGISTER_ENTRY; - -typedef struct _DEBUG_DEVICE_ADDRESS { - UCHAR Type; - BOOLEAN Valid; - UCHAR Reserved[2]; - PUCHAR TranslatedAddress; - ULONG Length; -} DEBUG_DEVICE_ADDRESS, *PDEBUG_DEVICE_ADDRESS; - -typedef struct _DEBUG_MEMORY_REQUIREMENTS { - PHYSICAL_ADDRESS Start; - PHYSICAL_ADDRESS MaxEnd; - PVOID VirtualAddress; - ULONG Length; - BOOLEAN Cached; - BOOLEAN Aligned; -} DEBUG_MEMORY_REQUIREMENTS, *PDEBUG_MEMORY_REQUIREMENTS; - -typedef struct _DEBUG_DEVICE_DESCRIPTOR { - ULONG Bus; - ULONG Slot; - USHORT Segment; - USHORT VendorID; - USHORT DeviceID; - UCHAR BaseClass; - UCHAR SubClass; - UCHAR ProgIf; - BOOLEAN Initialized; - BOOLEAN Configured; - DEBUG_DEVICE_ADDRESS BaseAddress[6]; - DEBUG_MEMORY_REQUIREMENTS Memory; -} DEBUG_DEVICE_DESCRIPTOR, *PDEBUG_DEVICE_DESCRIPTOR; - -typedef struct _PM_DISPATCH_TABLE { - ULONG Signature; - ULONG Version; - PVOID Function[1]; -} PM_DISPATCH_TABLE, *PPM_DISPATCH_TABLE; - -typedef enum _RESOURCE_TRANSLATION_DIRECTION { - TranslateChildToParent, - TranslateParentToChild -} RESOURCE_TRANSLATION_DIRECTION; +typedef NTSTATUS +(NTAPI *pHalQuerySystemInformation)( + IN HAL_QUERY_INFORMATION_CLASS InformationClass, + IN ULONG BufferSize, + IN OUT PVOID Buffer, + OUT PULONG ReturnedLength); typedef NTSTATUS -(NTAPI *PTRANSLATE_RESOURCE_HANDLER)( - IN OUT PVOID Context, - IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Source, - IN RESOURCE_TRANSLATION_DIRECTION Direction, - IN ULONG AlternativesCount OPTIONAL, - IN IO_RESOURCE_DESCRIPTOR Alternatives[], - IN PDEVICE_OBJECT PhysicalDeviceObject, - OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR Target); - -typedef NTSTATUS -(NTAPI *PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER)( - IN PVOID Context OPTIONAL, - IN PIO_RESOURCE_DESCRIPTOR Source, - IN PDEVICE_OBJECT PhysicalDeviceObject, - OUT PULONG TargetCount, - OUT PIO_RESOURCE_DESCRIPTOR *Target); - -typedef struct _TRANSLATOR_INTERFACE { - USHORT Size; - USHORT Version; - PVOID Context; - PINTERFACE_REFERENCE InterfaceReference; - PINTERFACE_DEREFERENCE InterfaceDereference; - PTRANSLATE_RESOURCE_HANDLER TranslateResources; - PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER TranslateResourceRequirements; -} TRANSLATOR_INTERFACE, *PTRANSLATOR_INTERFACE; +(NTAPI *pHalSetSystemInformation)( + IN HAL_SET_INFORMATION_CLASS InformationClass, + IN ULONG BufferSize, + IN PVOID Buffer); typedef VOID (FASTCALL *pHalExamineMBR)( @@ -469,28 +1349,6 @@ typedef NTSTATUS IN ULONG NumberOfHeads, IN struct _DRIVE_LAYOUT_INFORMATION *PartitionBuffer); -typedef PBUS_HANDLER -(FASTCALL *pHalHandlerForBus)( - IN INTERFACE_TYPE InterfaceType, - IN ULONG BusNumber); - -typedef VOID -(FASTCALL *pHalReferenceBusHandler)( - IN PBUS_HANDLER BusHandler); - -typedef NTSTATUS -(NTAPI *pHalQuerySystemInformation)( - IN HAL_QUERY_INFORMATION_CLASS InformationClass, - IN ULONG BufferSize, - IN OUT PVOID Buffer, - OUT PULONG ReturnedLength); - -typedef NTSTATUS -(NTAPI *pHalSetSystemInformation)( - IN HAL_SET_INFORMATION_CLASS InformationClass, - IN ULONG BufferSize, - IN PVOID Buffer); - typedef NTSTATUS (NTAPI *pHalQueryBusSlots)( IN PBUS_HANDLER BusHandler, @@ -502,6 +1360,12 @@ typedef NTSTATUS (NTAPI *pHalInitPnpDriver)( VOID); +typedef struct _PM_DISPATCH_TABLE { + ULONG Signature; + ULONG Version; + PVOID Function[1]; +} PM_DISPATCH_TABLE, *PPM_DISPATCH_TABLE; + typedef NTSTATUS (NTAPI *pHalInitPowerManagement)( IN PPM_DISPATCH_TABLE PmDriverDispatchTable, @@ -541,12 +1405,7 @@ typedef NTSTATUS IN PHYSICAL_ADDRESS PhysicalAddress, IN LARGE_INTEGER NumberOfBytes); -typedef VOID -(NTAPI *pHalEndOfBoot)( - VOID); - -typedef -BOOLEAN +typedef BOOLEAN (NTAPI *pHalTranslateBusAddress)( IN INTERFACE_TYPE InterfaceType, IN ULONG BusNumber, @@ -554,8 +1413,7 @@ BOOLEAN IN OUT PULONG AddressSpace, OUT PPHYSICAL_ADDRESS TranslatedAddress); -typedef -NTSTATUS +typedef NTSTATUS (NTAPI *pHalAssignSlotResources)( IN PUNICODE_STRING RegistryPath, IN PUNICODE_STRING DriverClassName OPTIONAL, @@ -566,23 +1424,24 @@ NTSTATUS IN ULONG SlotNumber, IN OUT PCM_RESOURCE_LIST *AllocatedResources); -typedef -VOID +typedef VOID (NTAPI *pHalHaltSystem)( VOID); -typedef -BOOLEAN +typedef BOOLEAN (NTAPI *pHalResetDisplay)( VOID); -typedef -UCHAR +typedef struct _MAP_REGISTER_ENTRY { + PVOID MapRegister; + BOOLEAN WriteToDevice; +} MAP_REGISTER_ENTRY, *PMAP_REGISTER_ENTRY; + +typedef UCHAR (NTAPI *pHalVectorToIDTEntry)( ULONG Vector); -typedef -BOOLEAN +typedef BOOLEAN (NTAPI *pHalFindBusAddressTranslation)( IN PHYSICAL_ADDRESS BusAddress, IN OUT PULONG AddressSpace, @@ -590,94 +1449,33 @@ BOOLEAN IN OUT PULONG_PTR Context, IN BOOLEAN NextBus); -typedef -NTSTATUS -(NTAPI *pKdSetupPciDeviceForDebugging)( - IN PVOID LoaderBlock OPTIONAL, - IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice); +typedef VOID +(NTAPI *pHalEndOfBoot)( + VOID); -typedef -NTSTATUS -(NTAPI *pKdReleasePciDeviceForDebugging)( - IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice); - -typedef -PVOID -(NTAPI *pKdGetAcpiTablePhase0)( - IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock, - IN ULONG Signature); - -typedef -PVOID +typedef PVOID (NTAPI *pHalGetAcpiTable)( IN ULONG Signature, IN PCSTR OemId OPTIONAL, IN PCSTR OemTableId OPTIONAL); - -typedef -VOID -(NTAPI *pKdCheckPowerButton)( - VOID); -#if (NTDDI_VERSION >= NTDDI_VISTA) -typedef -PVOID -(NTAPI *pKdMapPhysicalMemory64)( - IN PHYSICAL_ADDRESS PhysicalAddress, - IN ULONG NumberPages, - IN BOOLEAN FlushCurrentTLB); +#if defined(_IA64_) +typedef NTSTATUS +(*pHalGetErrorCapList)( + IN OUT PULONG CapsListLength, + IN OUT PUCHAR ErrorCapList); -typedef -VOID -(NTAPI *pKdUnmapVirtualAddress)( - IN PVOID VirtualAddress, - IN ULONG NumberPages, - IN BOOLEAN FlushCurrentTLB); -#else -typedef -PVOID -(NTAPI *pKdMapPhysicalMemory64)( - IN PHYSICAL_ADDRESS PhysicalAddress, - IN ULONG NumberPages); - -typedef -VOID -(NTAPI *pKdUnmapVirtualAddress)( - IN PVOID VirtualAddress, - IN ULONG NumberPages); +typedef NTSTATUS +(*pHalInjectError)( + IN ULONG BufferLength, + IN PUCHAR Buffer); #endif - -typedef -ULONG -(NTAPI *pKdGetPciDataByOffset)( - IN ULONG BusNumber, - IN ULONG SlotNumber, - OUT PVOID Buffer, - IN ULONG Offset, - IN ULONG Length); - -typedef -ULONG -(NTAPI *pKdSetPciDataByOffset)( - IN ULONG BusNumber, - IN ULONG SlotNumber, - IN PVOID Buffer, - IN ULONG Offset, - IN ULONG Length); - -typedef BOOLEAN -(NTAPI *PHAL_RESET_DISPLAY_PARAMETERS)( - IN ULONG Columns, - IN ULONG Rows); - -typedef -VOID +typedef VOID (NTAPI *PCI_ERROR_HANDLER_CALLBACK)( VOID); -typedef -VOID +typedef VOID (NTAPI *pHalSetPciErrorHandlerCallback)( IN PCI_ERROR_HANDLER_CALLBACK Callback); @@ -751,78 +1549,706 @@ extern NTKERNELAPI HAL_DISPATCH HalDispatchTable; #define HalMirrorPhysicalMemory HALDISPATCH->HalMirrorPhysicalMemory #define HalEndOfBoot HALDISPATCH->HalEndOfBoot #define HalMirrorVerify HALDISPATCH->HalMirrorVerify - -typedef struct _FILE_ALIGNMENT_INFORMATION { - ULONG AlignmentRequirement; -} FILE_ALIGNMENT_INFORMATION, *PFILE_ALIGNMENT_INFORMATION; - -typedef struct _FILE_NAME_INFORMATION { - ULONG FileNameLength; - WCHAR FileName[1]; -} FILE_NAME_INFORMATION, *PFILE_NAME_INFORMATION; - - -typedef struct _FILE_ATTRIBUTE_TAG_INFORMATION { - ULONG FileAttributes; - ULONG ReparseTag; -} FILE_ATTRIBUTE_TAG_INFORMATION, *PFILE_ATTRIBUTE_TAG_INFORMATION; - -typedef struct _FILE_DISPOSITION_INFORMATION { - BOOLEAN DeleteFile; -} FILE_DISPOSITION_INFORMATION, *PFILE_DISPOSITION_INFORMATION; - -typedef struct _FILE_END_OF_FILE_INFORMATION { - LARGE_INTEGER EndOfFile; -} FILE_END_OF_FILE_INFORMATION, *PFILE_END_OF_FILE_INFORMATION; - -typedef struct _FILE_VALID_DATA_LENGTH_INFORMATION { - LARGE_INTEGER ValidDataLength; -} FILE_VALID_DATA_LENGTH_INFORMATION, *PFILE_VALID_DATA_LENGTH_INFORMATION; - -typedef union _FILE_SEGMENT_ELEMENT { - PVOID64 Buffer; - ULONGLONG Alignment; -}FILE_SEGMENT_ELEMENT, *PFILE_SEGMENT_ELEMENT; - -#define SE_UNSOLICITED_INPUT_PRIVILEGE 6 - -#if (NTDDI_VERSION >= NTDDI_WIN2K) -NTSYSAPI -ULONGLONG -NTAPI -VerSetConditionMask( - IN ULONGLONG ConditionMask, - IN ULONG TypeMask, - IN UCHAR Condition); +#define HalGetCachedAcpiTable HALDISPATCH->HalGetCachedAcpiTable +#define HalSetPciErrorHandlerCallback HALDISPATCH->HalSetPciErrorHandlerCallback +#if defined(_IA64_) +#define HalGetErrorCapList HALDISPATCH->HalGetErrorCapList +#define HalInjectError HALDISPATCH->HalInjectError #endif -#define VER_SET_CONDITION(ConditionMask, TypeBitMask, ComparisonType) \ - ((ConditionMask) = VerSetConditionMask((ConditionMask), \ - (TypeBitMask), (ComparisonType))) +typedef struct _HAL_BUS_INFORMATION { + INTERFACE_TYPE BusType; + BUS_DATA_TYPE ConfigurationType; + ULONG BusNumber; + ULONG Reserved; +} HAL_BUS_INFORMATION, *PHAL_BUS_INFORMATION; -/* RtlVerifyVersionInfo() TypeMask */ +typedef struct _HAL_PROFILE_SOURCE_INFORMATION { + KPROFILE_SOURCE Source; + BOOLEAN Supported; + ULONG Interval; +} HAL_PROFILE_SOURCE_INFORMATION, *PHAL_PROFILE_SOURCE_INFORMATION; -#define VER_MINORVERSION 0x0000001 -#define VER_MAJORVERSION 0x0000002 -#define VER_BUILDNUMBER 0x0000004 -#define VER_PLATFORMID 0x0000008 -#define VER_SERVICEPACKMINOR 0x0000010 -#define VER_SERVICEPACKMAJOR 0x0000020 -#define VER_SUITENAME 0x0000040 -#define VER_PRODUCT_TYPE 0x0000080 +typedef struct _HAL_PROFILE_SOURCE_INFORMATION_EX { + KPROFILE_SOURCE Source; + BOOLEAN Supported; + ULONG_PTR Interval; + ULONG_PTR DefInterval; + ULONG_PTR MaxInterval; + ULONG_PTR MinInterval; +} HAL_PROFILE_SOURCE_INFORMATION_EX, *PHAL_PROFILE_SOURCE_INFORMATION_EX; -/* RtlVerifyVersionInfo() ComparisonType */ +typedef struct _HAL_PROFILE_SOURCE_INTERVAL { + KPROFILE_SOURCE Source; + ULONG_PTR Interval; +} HAL_PROFILE_SOURCE_INTERVAL, *PHAL_PROFILE_SOURCE_INTERVAL; -#define VER_EQUAL 1 -#define VER_GREATER 2 -#define VER_GREATER_EQUAL 3 -#define VER_LESS 4 -#define VER_LESS_EQUAL 5 -#define VER_AND 6 -#define VER_OR 7 +typedef struct _HAL_PROFILE_SOURCE_LIST { + KPROFILE_SOURCE Source; + PWSTR Description; +} HAL_PROFILE_SOURCE_LIST, *PHAL_PROFILE_SOURCE_LIST; -#define VER_CONDITION_MASK 7 -#define VER_NUM_BITS_PER_CONDITION_MASK 3 +typedef enum _HAL_DISPLAY_BIOS_INFORMATION { + HalDisplayInt10Bios, + HalDisplayEmulatedBios, + HalDisplayNoBios +} HAL_DISPLAY_BIOS_INFORMATION, *PHAL_DISPLAY_BIOS_INFORMATION; + +typedef struct _HAL_POWER_INFORMATION { + ULONG TBD; +} HAL_POWER_INFORMATION, *PHAL_POWER_INFORMATION; + +typedef struct _HAL_PROCESSOR_SPEED_INFO { + ULONG ProcessorSpeed; +} HAL_PROCESSOR_SPEED_INFORMATION, *PHAL_PROCESSOR_SPEED_INFORMATION; + +typedef struct _HAL_CALLBACKS { + PCALLBACK_OBJECT SetSystemInformation; + PCALLBACK_OBJECT BusCheck; +} HAL_CALLBACKS, *PHAL_CALLBACKS; + +typedef struct _HAL_PROCESSOR_FEATURE { + ULONG UsableFeatureBits; +} HAL_PROCESSOR_FEATURE; + +typedef NTSTATUS +(NTAPI *PHALIOREADWRITEHANDLER)( + IN BOOLEAN fRead, + IN ULONG dwAddr, + IN ULONG dwSize, + IN OUT PULONG pdwData); + +typedef struct _HAL_AMLI_BAD_IO_ADDRESS_LIST { + ULONG BadAddrBegin; + ULONG BadAddrSize; + ULONG OSVersionTrigger; + PHALIOREADWRITEHANDLER IOHandler; +} HAL_AMLI_BAD_IO_ADDRESS_LIST, *PHAL_AMLI_BAD_IO_ADDRESS_LIST; + +#if defined(_X86_) || defined(_IA64_) || defined(_AMD64_) + +typedef VOID +(NTAPI *PHALMCAINTERFACELOCK)( + VOID); + +typedef VOID +(NTAPI *PHALMCAINTERFACEUNLOCK)( + VOID); + +typedef NTSTATUS +(NTAPI *PHALMCAINTERFACEREADREGISTER)( + IN UCHAR BankNumber, + IN OUT PVOID Exception); + +typedef struct _HAL_MCA_INTERFACE { + PHALMCAINTERFACELOCK Lock; + PHALMCAINTERFACEUNLOCK Unlock; + PHALMCAINTERFACEREADREGISTER ReadRegister; +} HAL_MCA_INTERFACE; + +typedef enum { + ApicDestinationModePhysical = 1, + ApicDestinationModeLogicalFlat, + ApicDestinationModeLogicalClustered, + ApicDestinationModeUnknown +} HAL_APIC_DESTINATION_MODE, *PHAL_APIC_DESTINATION_MODE; + +#if defined(_AMD64_) + +struct _KTRAP_FRAME; +struct _KEXCEPTION_FRAME; + +typedef ERROR_SEVERITY +(NTAPI *PDRIVER_EXCPTN_CALLBACK)( + IN PVOID Context, + IN struct _KTRAP_FRAME *TrapFrame, + IN struct _KEXCEPTION_FRAME *ExceptionFrame, + IN PMCA_EXCEPTION Exception); + +#endif + +#if defined(_X86_) || defined(_IA64_) +typedef +#if defined(_IA64_) +ERROR_SEVERITY +#else +VOID +#endif +(NTAPI *PDRIVER_EXCPTN_CALLBACK)( + IN PVOID Context, + IN PMCA_EXCEPTION BankLog); +#endif + +typedef PDRIVER_EXCPTN_CALLBACK PDRIVER_MCA_EXCEPTION_CALLBACK; + +typedef struct _MCA_DRIVER_INFO { + PDRIVER_MCA_EXCEPTION_CALLBACK ExceptionCallback; + PKDEFERRED_ROUTINE DpcCallback; + PVOID DeviceContext; +} MCA_DRIVER_INFO, *PMCA_DRIVER_INFO; + +typedef struct _HAL_ERROR_INFO { + ULONG Version; + ULONG InitMaxSize; + ULONG McaMaxSize; + ULONG McaPreviousEventsCount; + ULONG McaCorrectedEventsCount; + ULONG McaKernelDeliveryFails; + ULONG McaDriverDpcQueueFails; + ULONG McaReserved; + ULONG CmcMaxSize; + ULONG CmcPollingInterval; + ULONG CmcInterruptsCount; + ULONG CmcKernelDeliveryFails; + ULONG CmcDriverDpcQueueFails; + ULONG CmcGetStateFails; + ULONG CmcClearStateFails; + ULONG CmcReserved; + ULONGLONG CmcLogId; + ULONG CpeMaxSize; + ULONG CpePollingInterval; + ULONG CpeInterruptsCount; + ULONG CpeKernelDeliveryFails; + ULONG CpeDriverDpcQueueFails; + ULONG CpeGetStateFails; + ULONG CpeClearStateFails; + ULONG CpeInterruptSources; + ULONGLONG CpeLogId; + ULONGLONG KernelReserved[4]; +} HAL_ERROR_INFO, *PHAL_ERROR_INFO; + +#define HAL_MCE_INTERRUPTS_BASED ((ULONG)-1) +#define HAL_MCE_DISABLED ((ULONG)0) + +#define HAL_CMC_INTERRUPTS_BASED HAL_MCE_INTERRUPTS_BASED +#define HAL_CMC_DISABLED HAL_MCE_DISABLED + +#define HAL_CPE_INTERRUPTS_BASED HAL_MCE_INTERRUPTS_BASED +#define HAL_CPE_DISABLED HAL_MCE_DISABLED + +#define HAL_MCA_INTERRUPTS_BASED HAL_MCE_INTERRUPTS_BASED +#define HAL_MCA_DISABLED HAL_MCE_DISABLED + +typedef VOID +(NTAPI *PDRIVER_CMC_EXCEPTION_CALLBACK)( + IN PVOID Context, + IN PCMC_EXCEPTION CmcLog); + +typedef VOID +(NTAPI *PDRIVER_CPE_EXCEPTION_CALLBACK)( + IN PVOID Context, + IN PCPE_EXCEPTION CmcLog); + +typedef struct _CMC_DRIVER_INFO { + PDRIVER_CMC_EXCEPTION_CALLBACK ExceptionCallback; + PKDEFERRED_ROUTINE DpcCallback; + PVOID DeviceContext; +} CMC_DRIVER_INFO, *PCMC_DRIVER_INFO; + +typedef struct _CPE_DRIVER_INFO { + PDRIVER_CPE_EXCEPTION_CALLBACK ExceptionCallback; + PKDEFERRED_ROUTINE DpcCallback; + PVOID DeviceContext; +} CPE_DRIVER_INFO, *PCPE_DRIVER_INFO; + +#endif // defined(_X86_) || defined(_IA64_) || defined(_AMD64_) + +#if defined(_IA64_) + +typedef NTSTATUS +(*HALSENDCROSSPARTITIONIPI)( + IN USHORT ProcessorID, + IN UCHAR HardwareVector); + +typedef NTSTATUS +(*HALRESERVECROSSPARTITIONINTERRUPTVECTOR)( + OUT PULONG Vector, + OUT PKIRQL Irql, + IN OUT PGROUP_AFFINITY Affinity, + OUT PUCHAR HardwareVector); + +typedef VOID +(*HALFREECROSSPARTITIONINTERRUPTVECTOR)( + IN ULONG Vector, + IN PGROUP_AFFINITY Affinity); + +typedef struct _HAL_CROSS_PARTITION_IPI_INTERFACE { + HALSENDCROSSPARTITIONIPI HalSendCrossPartitionIpi; + HALRESERVECROSSPARTITIONINTERRUPTVECTOR HalReserveCrossPartitionInterruptVector; + HALFREECROSSPARTITIONINTERRUPTVECTOR HalFreeCrossPartitionInterruptVector; +} HAL_CROSS_PARTITION_IPI_INTERFACE; + +#define HAL_CROSS_PARTITION_IPI_INTERFACE_MINIMUM_SIZE \ + FIELD_OFFSET(HAL_CROSS_PARTITION_IPI_INTERFACE, \ + HalFreeCrossPartitionInterruptVector) + +#endif /* defined(_IA64_) */ + +typedef struct _HAL_PLATFORM_INFORMATION { + ULONG PlatformFlags; +} HAL_PLATFORM_INFORMATION, *PHAL_PLATFORM_INFORMATION; + +#define HAL_PLATFORM_DISABLE_WRITE_COMBINING 0x01L +#define HAL_PLATFORM_DISABLE_PTCG 0x04L +#define HAL_PLATFORM_DISABLE_UC_MAIN_MEMORY 0x08L +#define HAL_PLATFORM_ENABLE_WRITE_COMBINING_MMIO 0x10L +#define HAL_PLATFORM_ACPI_TABLES_CACHED 0x20L + +/****************************************************************************** + * Kernel Types * + ******************************************************************************/ + +#define NX_SUPPORT_POLICY_ALWAYSOFF 0 +#define NX_SUPPORT_POLICY_ALWAYSON 1 +#define NX_SUPPORT_POLICY_OPTIN 2 +#define NX_SUPPORT_POLICY_OPTOUT 3 + +typedef VOID +(NTAPI *PEXPAND_STACK_CALLOUT)( + IN PVOID Parameter OPTIONAL); + +typedef VOID +(NTAPI *PTIMER_APC_ROUTINE)( + IN PVOID TimerContext, + IN ULONG TimerLowValue, + IN LONG TimerHighValue); + +typedef enum _TIMER_SET_INFORMATION_CLASS { + TimerSetCoalescableTimer, + MaxTimerInfoClass +} TIMER_SET_INFORMATION_CLASS; + +#if (NTDDI_VERSION >= NTDDI_WIN7) +typedef struct _TIMER_SET_COALESCABLE_TIMER_INFO { + IN LARGE_INTEGER DueTime; + IN PTIMER_APC_ROUTINE TimerApcRoutine OPTIONAL; + IN PVOID TimerContext OPTIONAL; + IN struct _COUNTED_REASON_CONTEXT *WakeContext OPTIONAL; + IN ULONG Period OPTIONAL; + IN ULONG TolerableDelay; + OUT PBOOLEAN PreviousState OPTIONAL; +} TIMER_SET_COALESCABLE_TIMER_INFO, *PTIMER_SET_COALESCABLE_TIMER_INFO; +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + +#define XSTATE_LEGACY_FLOATING_POINT 0 +#define XSTATE_LEGACY_SSE 1 +#define XSTATE_GSSE 2 + +#define XSTATE_MASK_LEGACY_FLOATING_POINT (1i64 << (XSTATE_LEGACY_FLOATING_POINT)) +#define XSTATE_MASK_LEGACY_SSE (1i64 << (XSTATE_LEGACY_SSE)) +#define XSTATE_MASK_LEGACY (XSTATE_MASK_LEGACY_FLOATING_POINT | XSTATE_MASK_LEGACY_SSE) +#define XSTATE_MASK_GSSE (1i64 << (XSTATE_GSSE)) + +#define MAXIMUM_XSTATE_FEATURES 64 + +typedef struct _XSTATE_FEATURE { + ULONG Offset; + ULONG Size; +} XSTATE_FEATURE, *PXSTATE_FEATURE; + +typedef struct _XSTATE_CONFIGURATION { + ULONG64 EnabledFeatures; + ULONG Size; + ULONG OptimizedSave:1; + XSTATE_FEATURE Features[MAXIMUM_XSTATE_FEATURES]; +} XSTATE_CONFIGURATION, *PXSTATE_CONFIGURATION; + +#define MAX_WOW64_SHARED_ENTRIES 16 + +typedef struct _KUSER_SHARED_DATA { + ULONG TickCountLowDeprecated; + ULONG TickCountMultiplier; + volatile KSYSTEM_TIME InterruptTime; + volatile KSYSTEM_TIME SystemTime; + volatile KSYSTEM_TIME TimeZoneBias; + USHORT ImageNumberLow; + USHORT ImageNumberHigh; + WCHAR NtSystemRoot[260]; + ULONG MaxStackTraceDepth; + ULONG CryptoExponent; + ULONG TimeZoneId; + ULONG LargePageMinimum; + ULONG Reserved2[7]; + NT_PRODUCT_TYPE NtProductType; + BOOLEAN ProductTypeIsValid; + ULONG NtMajorVersion; + ULONG NtMinorVersion; + BOOLEAN ProcessorFeatures[PROCESSOR_FEATURE_MAX]; + ULONG Reserved1; + ULONG Reserved3; + volatile ULONG TimeSlip; + ALTERNATIVE_ARCHITECTURE_TYPE AlternativeArchitecture; + ULONG AltArchitecturePad[1]; + LARGE_INTEGER SystemExpirationDate; + ULONG SuiteMask; + BOOLEAN KdDebuggerEnabled; +#if (NTDDI_VERSION >= NTDDI_WINXPSP2) + UCHAR NXSupportPolicy; +#endif + volatile ULONG ActiveConsoleId; + volatile ULONG DismountCount; + ULONG ComPlusPackage; + ULONG LastSystemRITEventTickCount; + ULONG NumberOfPhysicalPages; + BOOLEAN SafeBootMode; +#if (NTDDI_VERSION >= NTDDI_WIN7) + union { + UCHAR TscQpcData; + struct { + UCHAR TscQpcEnabled:1; + UCHAR TscQpcSpareFlag:1; + UCHAR TscQpcShift:6; + } DUMMYSTRUCTNAME; + } DUMMYUNIONNAME; + UCHAR TscQpcPad[2]; +#endif +#if (NTDDI_VERSION >= NTDDI_VISTA) + union { + ULONG SharedDataFlags; + struct { + ULONG DbgErrorPortPresent:1; + ULONG DbgElevationEnabled:1; + ULONG DbgVirtEnabled:1; + ULONG DbgInstallerDetectEnabled:1; + ULONG DbgSystemDllRelocated:1; + ULONG DbgDynProcessorEnabled:1; + ULONG DbgSEHValidationEnabled:1; + ULONG SpareBits:25; + } DUMMYSTRUCTNAME2; + } DUMMYUNIONNAME2; +#else + ULONG TraceLogging; +#endif + ULONG DataFlagsPad[1]; + ULONGLONG TestRetInstruction; + ULONG SystemCall; + ULONG SystemCallReturn; + ULONGLONG SystemCallPad[3]; + _ANONYMOUS_UNION union { + volatile KSYSTEM_TIME TickCount; + volatile ULONG64 TickCountQuad; + _ANONYMOUS_STRUCT struct { + ULONG ReservedTickCountOverlay[3]; + ULONG TickCountPad[1]; + } DUMMYSTRUCTNAME; + } DUMMYUNIONNAME3; + ULONG Cookie; + ULONG CookiePad[1]; +#if (NTDDI_VERSION >= NTDDI_WS03) + LONGLONG ConsoleSessionForegroundProcessId; + ULONG Wow64SharedInformation[MAX_WOW64_SHARED_ENTRIES]; +#endif +#if (NTDDI_VERSION >= NTDDI_VISTA) +#if (NTDDI_VERSION >= NTDDI_WIN7) + USHORT UserModeGlobalLogger[16]; +#else + USHORT UserModeGlobalLogger[8]; + ULONG HeapTracingPid[2]; + ULONG CritSecTracingPid[2]; +#endif + ULONG ImageFileExecutionOptions; +#if (NTDDI_VERSION >= NTDDI_VISTASP1) + ULONG LangGenerationCount; +#else + /* 4 bytes padding */ +#endif + ULONGLONG Reserved5; + volatile ULONG64 InterruptTimeBias; +#endif +#if (NTDDI_VERSION >= NTDDI_WIN7) + volatile ULONG64 TscQpcBias; + volatile ULONG ActiveProcessorCount; + volatile USHORT ActiveGroupCount; + USHORT Reserved4; + volatile ULONG AitSamplingValue; + volatile ULONG AppCompatFlag; + ULONGLONG SystemDllNativeRelocation; + ULONG SystemDllWowRelocation; + ULONG XStatePad[1]; + XSTATE_CONFIGURATION XState; +#endif +} KUSER_SHARED_DATA, *PKUSER_SHARED_DATA; + +#if (NTDDI_VERSION >= NTDDI_VISTA) +extern NTSYSAPI volatile CCHAR KeNumberProcessors; +#elif (NTDDI_VERSION >= NTDDI_WINXP) +extern NTSYSAPI CCHAR KeNumberProcessors; +#else +extern PCCHAR KeNumberProcessors; +#endif + + +/****************************************************************************** + * Kernel Debugger Types * + ******************************************************************************/ +typedef struct _DEBUG_DEVICE_ADDRESS { + UCHAR Type; + BOOLEAN Valid; + UCHAR Reserved[2]; + PUCHAR TranslatedAddress; + ULONG Length; +} DEBUG_DEVICE_ADDRESS, *PDEBUG_DEVICE_ADDRESS; + +typedef struct _DEBUG_MEMORY_REQUIREMENTS { + PHYSICAL_ADDRESS Start; + PHYSICAL_ADDRESS MaxEnd; + PVOID VirtualAddress; + ULONG Length; + BOOLEAN Cached; + BOOLEAN Aligned; +} DEBUG_MEMORY_REQUIREMENTS, *PDEBUG_MEMORY_REQUIREMENTS; + +typedef struct _DEBUG_DEVICE_DESCRIPTOR { + ULONG Bus; + ULONG Slot; + USHORT Segment; + USHORT VendorID; + USHORT DeviceID; + UCHAR BaseClass; + UCHAR SubClass; + UCHAR ProgIf; + BOOLEAN Initialized; + BOOLEAN Configured; + DEBUG_DEVICE_ADDRESS BaseAddress[6]; + DEBUG_MEMORY_REQUIREMENTS Memory; +} DEBUG_DEVICE_DESCRIPTOR, *PDEBUG_DEVICE_DESCRIPTOR; + +typedef NTSTATUS +(NTAPI *pKdSetupPciDeviceForDebugging)( + IN PVOID LoaderBlock OPTIONAL, + IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice); + +typedef NTSTATUS +(NTAPI *pKdReleasePciDeviceForDebugging)( + IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice); + +typedef PVOID +(NTAPI *pKdGetAcpiTablePhase0)( + IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock, + IN ULONG Signature); + +typedef VOID +(NTAPI *pKdCheckPowerButton)( + VOID); + +#if (NTDDI_VERSION >= NTDDI_VISTA) +typedef PVOID +(NTAPI *pKdMapPhysicalMemory64)( + IN PHYSICAL_ADDRESS PhysicalAddress, + IN ULONG NumberPages, + IN BOOLEAN FlushCurrentTLB); + +typedef VOID +(NTAPI *pKdUnmapVirtualAddress)( + IN PVOID VirtualAddress, + IN ULONG NumberPages, + IN BOOLEAN FlushCurrentTLB); +#else +typedef PVOID +(NTAPI *pKdMapPhysicalMemory64)( + IN PHYSICAL_ADDRESS PhysicalAddress, + IN ULONG NumberPages); + +typedef VOID +(NTAPI *pKdUnmapVirtualAddress)( + IN PVOID VirtualAddress, + IN ULONG NumberPages); +#endif + +typedef ULONG +(NTAPI *pKdGetPciDataByOffset)( + IN ULONG BusNumber, + IN ULONG SlotNumber, + OUT PVOID Buffer, + IN ULONG Offset, + IN ULONG Length); + +typedef ULONG +(NTAPI *pKdSetPciDataByOffset)( + IN ULONG BusNumber, + IN ULONG SlotNumber, + IN PVOID Buffer, + IN ULONG Offset, + IN ULONG Length); +/****************************************************************************** + * Memory manager Types * + ******************************************************************************/ + +typedef struct _PHYSICAL_MEMORY_RANGE { + PHYSICAL_ADDRESS BaseAddress; + LARGE_INTEGER NumberOfBytes; +} PHYSICAL_MEMORY_RANGE, *PPHYSICAL_MEMORY_RANGE; + +typedef NTSTATUS +(NTAPI *PMM_ROTATE_COPY_CALLBACK_FUNCTION)( + IN PMDL DestinationMdl, + IN PMDL SourceMdl, + IN PVOID Context); + +typedef enum _MM_ROTATE_DIRECTION { + MmToFrameBuffer, + MmToFrameBufferNoCopy, + MmToRegularMemory, + MmToRegularMemoryNoCopy, + MmMaximumRotateDirection +} MM_ROTATE_DIRECTION, *PMM_ROTATE_DIRECTION; + + +/****************************************************************************** + * Process Manager Types * + ******************************************************************************/ + +#define QUOTA_LIMITS_HARDWS_MIN_ENABLE 0x00000001 +#define QUOTA_LIMITS_HARDWS_MIN_DISABLE 0x00000002 +#define QUOTA_LIMITS_HARDWS_MAX_ENABLE 0x00000004 +#define QUOTA_LIMITS_HARDWS_MAX_DISABLE 0x00000008 +#define QUOTA_LIMITS_USE_DEFAULT_LIMITS 0x00000010 + +typedef struct _QUOTA_LIMITS { + SIZE_T PagedPoolLimit; + SIZE_T NonPagedPoolLimit; + SIZE_T MinimumWorkingSetSize; + SIZE_T MaximumWorkingSetSize; + SIZE_T PagefileLimit; + LARGE_INTEGER TimeLimit; +} QUOTA_LIMITS, *PQUOTA_LIMITS; + +typedef union _RATE_QUOTA_LIMIT { + ULONG RateData; + struct { + ULONG RatePercent:7; + ULONG Reserved0:25; + } DUMMYSTRUCTNAME; +} RATE_QUOTA_LIMIT, *PRATE_QUOTA_LIMIT; + +typedef struct _QUOTA_LIMITS_EX { + SIZE_T PagedPoolLimit; + SIZE_T NonPagedPoolLimit; + SIZE_T MinimumWorkingSetSize; + SIZE_T MaximumWorkingSetSize; + SIZE_T PagefileLimit; + LARGE_INTEGER TimeLimit; + SIZE_T WorkingSetLimit; + SIZE_T Reserved2; + SIZE_T Reserved3; + SIZE_T Reserved4; + ULONG Flags; + RATE_QUOTA_LIMIT CpuRateLimit; +} QUOTA_LIMITS_EX, *PQUOTA_LIMITS_EX; + +typedef struct _IO_COUNTERS { + ULONGLONG ReadOperationCount; + ULONGLONG WriteOperationCount; + ULONGLONG OtherOperationCount; + ULONGLONG ReadTransferCount; + ULONGLONG WriteTransferCount; + ULONGLONG OtherTransferCount; +} IO_COUNTERS, *PIO_COUNTERS; + +typedef struct _VM_COUNTERS { + SIZE_T PeakVirtualSize; + SIZE_T VirtualSize; + ULONG PageFaultCount; + SIZE_T PeakWorkingSetSize; + SIZE_T WorkingSetSize; + SIZE_T QuotaPeakPagedPoolUsage; + SIZE_T QuotaPagedPoolUsage; + SIZE_T QuotaPeakNonPagedPoolUsage; + SIZE_T QuotaNonPagedPoolUsage; + SIZE_T PagefileUsage; + SIZE_T PeakPagefileUsage; +} VM_COUNTERS, *PVM_COUNTERS; + +typedef struct _VM_COUNTERS_EX { + SIZE_T PeakVirtualSize; + SIZE_T VirtualSize; + ULONG PageFaultCount; + SIZE_T PeakWorkingSetSize; + SIZE_T WorkingSetSize; + SIZE_T QuotaPeakPagedPoolUsage; + SIZE_T QuotaPagedPoolUsage; + SIZE_T QuotaPeakNonPagedPoolUsage; + SIZE_T QuotaNonPagedPoolUsage; + SIZE_T PagefileUsage; + SIZE_T PeakPagefileUsage; + SIZE_T PrivateUsage; +} VM_COUNTERS_EX, *PVM_COUNTERS_EX; + +#define MAX_HW_COUNTERS 16 +#define THREAD_PROFILING_FLAG_DISPATCH 0x00000001 + +typedef enum _HARDWARE_COUNTER_TYPE { + PMCCounter, + MaxHardwareCounterType +} HARDWARE_COUNTER_TYPE, *PHARDWARE_COUNTER_TYPE; + +typedef struct _HARDWARE_COUNTER { + HARDWARE_COUNTER_TYPE Type; + ULONG Reserved; + ULONG64 Index; +} HARDWARE_COUNTER, *PHARDWARE_COUNTER; + +typedef struct _POOLED_USAGE_AND_LIMITS { + SIZE_T PeakPagedPoolUsage; + SIZE_T PagedPoolUsage; + SIZE_T PagedPoolLimit; + SIZE_T PeakNonPagedPoolUsage; + SIZE_T NonPagedPoolUsage; + SIZE_T NonPagedPoolLimit; + SIZE_T PeakPagefileUsage; + SIZE_T PagefileUsage; + SIZE_T PagefileLimit; +} POOLED_USAGE_AND_LIMITS, *PPOOLED_USAGE_AND_LIMITS; + +typedef struct _PROCESS_ACCESS_TOKEN { + HANDLE Token; + HANDLE Thread; +} PROCESS_ACCESS_TOKEN, *PPROCESS_ACCESS_TOKEN; + +#define PROCESS_EXCEPTION_PORT_ALL_STATE_BITS 0x00000003UL +#define PROCESS_EXCEPTION_PORT_ALL_STATE_FLAGS ((ULONG_PTR)((1UL << PROCESS_EXCEPTION_PORT_ALL_STATE_BITS) - 1)) + +typedef struct _PROCESS_EXCEPTION_PORT { + IN HANDLE ExceptionPortHandle; + IN OUT ULONG StateFlags; +} PROCESS_EXCEPTION_PORT, *PPROCESS_EXCEPTION_PORT; + +typedef VOID +(NTAPI *PCREATE_PROCESS_NOTIFY_ROUTINE)( + IN HANDLE ParentId, + IN HANDLE ProcessId, + IN BOOLEAN Create); + +typedef struct _PS_CREATE_NOTIFY_INFO { + IN SIZE_T Size; + union { + IN ULONG Flags; + struct { + IN ULONG FileOpenNameAvailable:1; + IN ULONG Reserved:31; + }; + }; + IN HANDLE ParentProcessId; + IN CLIENT_ID CreatingThreadId; + IN OUT struct _FILE_OBJECT *FileObject; + IN PCUNICODE_STRING ImageFileName; + IN PCUNICODE_STRING CommandLine OPTIONAL; + IN OUT NTSTATUS CreationStatus; +} PS_CREATE_NOTIFY_INFO, *PPS_CREATE_NOTIFY_INFO; + +typedef VOID +(NTAPI *PCREATE_PROCESS_NOTIFY_ROUTINE_EX)( + IN OUT PEPROCESS Process, + IN HANDLE ProcessId, + IN PPS_CREATE_NOTIFY_INFO CreateInfo OPTIONAL); + +typedef VOID +(NTAPI *PCREATE_THREAD_NOTIFY_ROUTINE)( + IN HANDLE ProcessId, + IN HANDLE ThreadId, + IN BOOLEAN Create); + +#define IMAGE_ADDRESSING_MODE_32BIT 3 typedef struct _IMAGE_INFO { _ANONYMOUS_UNION union { @@ -832,7 +2258,7 @@ typedef struct _IMAGE_INFO { ULONG SystemModeImage:1; ULONG ImageMappedToAllPids:1; ULONG ExtendedInfoPresent:1; - ULONG Reserved:22; + ULONG Reserved:21; } DUMMYSTRUCTNAME; } DUMMYUNIONNAME; PVOID ImageBase; @@ -841,24 +2267,24 @@ typedef struct _IMAGE_INFO { ULONG ImageSectionNumber; } IMAGE_INFO, *PIMAGE_INFO; -#define IMAGE_ADDRESSING_MODE_32BIT 3 +typedef struct _IMAGE_INFO_EX { + SIZE_T Size; + IMAGE_INFO ImageInfo; + struct _FILE_OBJECT *FileObject; +} IMAGE_INFO_EX, *PIMAGE_INFO_EX; -typedef enum _BUS_DATA_TYPE { - ConfigurationSpaceUndefined = -1, - Cmos, - EisaConfiguration, - Pos, - CbusConfiguration, - PCIConfiguration, - VMEConfiguration, - NuBusConfiguration, - PCMCIAConfiguration, - MPIConfiguration, - MPSAConfiguration, - PNPISAConfiguration, - SgiInternalConfiguration, - MaximumBusDataType -} BUS_DATA_TYPE, *PBUS_DATA_TYPE; +typedef VOID +(NTAPI *PLOAD_IMAGE_NOTIFY_ROUTINE)( + IN PUNICODE_STRING FullImageName, + IN HANDLE ProcessId, + IN PIMAGE_INFO ImageInfo); + +#define THREAD_CSWITCH_PMU_DISABLE FALSE +#define THREAD_CSWITCH_PMU_ENABLE TRUE + +#define PROCESS_LUID_DOSDEVICES_ONLY 0x00000001 + +#define PROCESS_HANDLE_TRACING_MAX_STACKS 16 typedef struct _NT_TIB { struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList; @@ -992,6 +2418,15 @@ typedef enum _THREADINFOCLASS { MaxThreadInfoClass } THREADINFOCLASS; +typedef struct _PAGE_PRIORITY_INFORMATION { + ULONG PagePriority; +} PAGE_PRIORITY_INFORMATION, *PPAGE_PRIORITY_INFORMATION; + +typedef struct _PROCESS_WS_WATCH_INFORMATION { + PVOID FaultingPc; + PVOID FaultingVa; +} PROCESS_WS_WATCH_INFORMATION, *PPROCESS_WS_WATCH_INFORMATION; + typedef struct _PROCESS_BASIC_INFORMATION { NTSTATUS ExitStatus; struct _PEB *PebBaseAddress; @@ -1001,10 +2436,20 @@ typedef struct _PROCESS_BASIC_INFORMATION { ULONG_PTR InheritedFromUniqueProcessId; } PROCESS_BASIC_INFORMATION,*PPROCESS_BASIC_INFORMATION; -typedef struct _PROCESS_WS_WATCH_INFORMATION { - PVOID FaultingPc; - PVOID FaultingVa; -} PROCESS_WS_WATCH_INFORMATION, *PPROCESS_WS_WATCH_INFORMATION; +typedef struct _PROCESS_EXTENDED_BASIC_INFORMATION { + SIZE_T Size; + PROCESS_BASIC_INFORMATION BasicInfo; + union { + ULONG Flags; + struct { + ULONG IsProtectedProcess:1; + ULONG IsWow64Process:1; + ULONG IsProcessDeleting:1; + ULONG IsCrossSessionCreate:1; + ULONG SpareBits:28; + } DUMMYSTRUCTNAME; + } DUMMYUNIONNAME; +} PROCESS_EXTENDED_BASIC_INFORMATION, *PPROCESS_EXTENDED_BASIC_INFORMATION; typedef struct _PROCESS_DEVICEMAP_INFORMATION { __GNU_EXTENSION union { @@ -1018,514 +2463,263 @@ typedef struct _PROCESS_DEVICEMAP_INFORMATION { }; } PROCESS_DEVICEMAP_INFORMATION, *PPROCESS_DEVICEMAP_INFORMATION; -typedef struct _KERNEL_USER_TIMES { - LARGE_INTEGER CreateTime; - LARGE_INTEGER ExitTime; - LARGE_INTEGER KernelTime; - LARGE_INTEGER UserTime; -} KERNEL_USER_TIMES, *PKERNEL_USER_TIMES; - -typedef struct _PROCESS_ACCESS_TOKEN { - HANDLE Token; - HANDLE Thread; -} PROCESS_ACCESS_TOKEN, *PPROCESS_ACCESS_TOKEN; +typedef struct _PROCESS_DEVICEMAP_INFORMATION_EX { + union { + struct { + HANDLE DirectoryHandle; + } Set; + struct { + ULONG DriveMap; + UCHAR DriveType[32]; + } Query; + } DUMMYUNIONNAME; + ULONG Flags; +} PROCESS_DEVICEMAP_INFORMATION_EX, *PPROCESS_DEVICEMAP_INFORMATION_EX; typedef struct _PROCESS_SESSION_INFORMATION { ULONG SessionId; } PROCESS_SESSION_INFORMATION, *PPROCESS_SESSION_INFORMATION; -typedef enum _IO_QUERY_DEVICE_DATA_FORMAT { - IoQueryDeviceIdentifier = 0, - IoQueryDeviceConfigurationData, - IoQueryDeviceComponentInformation, - IoQueryDeviceMaxData -} IO_QUERY_DEVICE_DATA_FORMAT, *PIO_QUERY_DEVICE_DATA_FORMAT; +typedef struct _PROCESS_HANDLE_TRACING_ENABLE { + ULONG Flags; +} PROCESS_HANDLE_TRACING_ENABLE, *PPROCESS_HANDLE_TRACING_ENABLE; -typedef struct _DISK_SIGNATURE { - ULONG PartitionStyle; - _ANONYMOUS_UNION union { - struct { - ULONG Signature; - ULONG CheckSum; - } Mbr; - struct { - GUID DiskId; - } Gpt; - } DUMMYUNIONNAME; -} DISK_SIGNATURE, *PDISK_SIGNATURE; +typedef struct _PROCESS_HANDLE_TRACING_ENABLE_EX { + ULONG Flags; + ULONG TotalSlots; +} PROCESS_HANDLE_TRACING_ENABLE_EX, *PPROCESS_HANDLE_TRACING_ENABLE_EX; -typedef ULONG_PTR -(NTAPI *PDRIVER_VERIFIER_THUNK_ROUTINE)( - IN PVOID Context); +typedef struct _PROCESS_HANDLE_TRACING_ENTRY { + HANDLE Handle; + CLIENT_ID ClientId; + ULONG Type; + PVOID Stacks[PROCESS_HANDLE_TRACING_MAX_STACKS]; +} PROCESS_HANDLE_TRACING_ENTRY, *PPROCESS_HANDLE_TRACING_ENTRY; -typedef struct _DRIVER_VERIFIER_THUNK_PAIRS { - PDRIVER_VERIFIER_THUNK_ROUTINE PristineRoutine; - PDRIVER_VERIFIER_THUNK_ROUTINE NewRoutine; -} DRIVER_VERIFIER_THUNK_PAIRS, *PDRIVER_VERIFIER_THUNK_PAIRS; +typedef struct _PROCESS_HANDLE_TRACING_QUERY { + HANDLE Handle; + ULONG TotalTraces; + PROCESS_HANDLE_TRACING_ENTRY HandleTrace[1]; +} PROCESS_HANDLE_TRACING_QUERY, *PPROCESS_HANDLE_TRACING_QUERY; -#define DRIVER_VERIFIER_SPECIAL_POOLING 0x0001 -#define DRIVER_VERIFIER_FORCE_IRQL_CHECKING 0x0002 -#define DRIVER_VERIFIER_INJECT_ALLOCATION_FAILURES 0x0004 -#define DRIVER_VERIFIER_TRACK_POOL_ALLOCATIONS 0x0008 -#define DRIVER_VERIFIER_IO_CHECKING 0x0010 +extern NTKERNELAPI PEPROCESS PsInitialSystemProcess; + + +/****************************************************************************** + * Runtime Library Types * + ******************************************************************************/ + + + +#ifndef _RTL_RUN_ONCE_DEF +#define _RTL_RUN_ONCE_DEF + +#define RTL_RUN_ONCE_INIT {0} + +#define RTL_RUN_ONCE_CHECK_ONLY 0x00000001UL +#define RTL_RUN_ONCE_ASYNC 0x00000002UL +#define RTL_RUN_ONCE_INIT_FAILED 0x00000004UL + +#define RTL_RUN_ONCE_CTX_RESERVED_BITS 2 + +#define RTL_HASH_ALLOCATED_HEADER 0x00000001 + +#define RTL_HASH_RESERVED_SIGNATURE 0 + +/* RtlVerifyVersionInfo() ComparisonType */ + +#define VER_EQUAL 1 +#define VER_GREATER 2 +#define VER_GREATER_EQUAL 3 +#define VER_LESS 4 +#define VER_LESS_EQUAL 5 +#define VER_AND 6 +#define VER_OR 7 + +#define VER_CONDITION_MASK 7 +#define VER_NUM_BITS_PER_CONDITION_MASK 3 + +/* RtlVerifyVersionInfo() TypeMask */ + +#define VER_MINORVERSION 0x0000001 +#define VER_MAJORVERSION 0x0000002 +#define VER_BUILDNUMBER 0x0000004 +#define VER_PLATFORMID 0x0000008 +#define VER_SERVICEPACKMINOR 0x0000010 +#define VER_SERVICEPACKMAJOR 0x0000020 +#define VER_SUITENAME 0x0000040 +#define VER_PRODUCT_TYPE 0x0000080 + +#define VER_NT_WORKSTATION 0x0000001 +#define VER_NT_DOMAIN_CONTROLLER 0x0000002 +#define VER_NT_SERVER 0x0000003 + +#define VER_PLATFORM_WIN32s 0 +#define VER_PLATFORM_WIN32_WINDOWS 1 +#define VER_PLATFORM_WIN32_NT 2 + +typedef union _RTL_RUN_ONCE { + PVOID Ptr; +} RTL_RUN_ONCE, *PRTL_RUN_ONCE; + +typedef ULONG /* LOGICAL */ +(NTAPI *PRTL_RUN_ONCE_INIT_FN) ( + IN OUT PRTL_RUN_ONCE RunOnce, + IN OUT PVOID Parameter OPTIONAL, + IN OUT PVOID *Context OPTIONAL); + +#endif /* _RTL_RUN_ONCE_DEF */ + +typedef enum _TABLE_SEARCH_RESULT { + TableEmptyTree, + TableFoundNode, + TableInsertAsLeft, + TableInsertAsRight +} TABLE_SEARCH_RESULT; + +typedef enum _RTL_GENERIC_COMPARE_RESULTS { + GenericLessThan, + GenericGreaterThan, + GenericEqual +} RTL_GENERIC_COMPARE_RESULTS; + +// Forwarder +struct _RTL_AVL_TABLE; + +typedef RTL_GENERIC_COMPARE_RESULTS +(NTAPI *PRTL_AVL_COMPARE_ROUTINE) ( + IN struct _RTL_AVL_TABLE *Table, + IN PVOID FirstStruct, + IN PVOID SecondStruct); + +typedef PVOID +(NTAPI *PRTL_AVL_ALLOCATE_ROUTINE) ( + IN struct _RTL_AVL_TABLE *Table, + IN CLONG ByteSize); typedef VOID -(NTAPI *PTIMER_APC_ROUTINE)( - IN PVOID TimerContext, - IN ULONG TimerLowValue, - IN LONG TimerHighValue); +(NTAPI *PRTL_AVL_FREE_ROUTINE) ( + IN struct _RTL_AVL_TABLE *Table, + IN PVOID Buffer); -typedef struct _KUSER_SHARED_DATA -{ - ULONG TickCountLowDeprecated; - ULONG TickCountMultiplier; - volatile KSYSTEM_TIME InterruptTime; - volatile KSYSTEM_TIME SystemTime; - volatile KSYSTEM_TIME TimeZoneBias; - USHORT ImageNumberLow; - USHORT ImageNumberHigh; - WCHAR NtSystemRoot[260]; - ULONG MaxStackTraceDepth; - ULONG CryptoExponent; - ULONG TimeZoneId; - ULONG LargePageMinimum; - ULONG Reserved2[7]; - NT_PRODUCT_TYPE NtProductType; - BOOLEAN ProductTypeIsValid; - ULONG NtMajorVersion; - ULONG NtMinorVersion; - BOOLEAN ProcessorFeatures[PROCESSOR_FEATURE_MAX]; - ULONG Reserved1; - ULONG Reserved3; - volatile ULONG TimeSlip; - ALTERNATIVE_ARCHITECTURE_TYPE AlternativeArchitecture; - ULONG AltArchitecturePad[1]; - LARGE_INTEGER SystemExpirationDate; - ULONG SuiteMask; - BOOLEAN KdDebuggerEnabled; -#if (NTDDI_VERSION >= NTDDI_WINXPSP2) - UCHAR NXSupportPolicy; -#endif - volatile ULONG ActiveConsoleId; - volatile ULONG DismountCount; - ULONG ComPlusPackage; - ULONG LastSystemRITEventTickCount; - ULONG NumberOfPhysicalPages; - BOOLEAN SafeBootMode; -#if (NTDDI_VERSION >= NTDDI_WIN7) - union { - UCHAR TscQpcData; - struct { - UCHAR TscQpcEnabled:1; - UCHAR TscQpcSpareFlag:1; - UCHAR TscQpcShift:6; - } DUMMYSTRUCTNAME; - } DUMMYUNIONNAME; - UCHAR TscQpcPad[2]; -#endif -#if (NTDDI_VERSION >= NTDDI_VISTA) - union { - ULONG SharedDataFlags; - struct { - ULONG DbgErrorPortPresent:1; - ULONG DbgElevationEnabled:1; - ULONG DbgVirtEnabled:1; - ULONG DbgInstallerDetectEnabled:1; - ULONG DbgSystemDllRelocated:1; - ULONG DbgDynProcessorEnabled:1; - ULONG DbgSEHValidationEnabled:1; - ULONG SpareBits:25; - } DUMMYSTRUCTNAME2; - } DUMMYUNIONNAME2; -#else - ULONG TraceLogging; -#endif - ULONG DataFlagsPad[1]; - ULONGLONG TestRetInstruction; - ULONG SystemCall; - ULONG SystemCallReturn; - ULONGLONG SystemCallPad[3]; - _ANONYMOUS_UNION union { - volatile KSYSTEM_TIME TickCount; - volatile ULONG64 TickCountQuad; - _ANONYMOUS_STRUCT struct { - ULONG ReservedTickCountOverlay[3]; - ULONG TickCountPad[1]; - } DUMMYSTRUCTNAME; - } DUMMYUNIONNAME3; - ULONG Cookie; - ULONG CookiePad[1]; -#if (NTDDI_VERSION >= NTDDI_WS03) - LONGLONG ConsoleSessionForegroundProcessId; - ULONG Wow64SharedInformation[MAX_WOW64_SHARED_ENTRIES]; -#endif -#if (NTDDI_VERSION >= NTDDI_VISTA) -#if (NTDDI_VERSION >= NTDDI_WIN7) - USHORT UserModeGlobalLogger[16]; -#else - USHORT UserModeGlobalLogger[8]; - ULONG HeapTracingPid[2]; - ULONG CritSecTracingPid[2]; -#endif - ULONG ImageFileExecutionOptions; -#if (NTDDI_VERSION >= NTDDI_VISTASP1) - ULONG LangGenerationCount; -#else - /* 4 bytes padding */ -#endif - ULONGLONG Reserved5; - volatile ULONG64 InterruptTimeBias; -#endif -#if (NTDDI_VERSION >= NTDDI_WIN7) - volatile ULONG64 TscQpcBias; - volatile ULONG ActiveProcessorCount; - volatile USHORT ActiveGroupCount; - USHORT Reserved4; - volatile ULONG AitSamplingValue; - volatile ULONG AppCompatFlag; - ULONGLONG SystemDllNativeRelocation; - ULONG SystemDllWowRelocation; - ULONG XStatePad[1]; - XSTATE_CONFIGURATION XState; -#endif -} KUSER_SHARED_DATA, *PKUSER_SHARED_DATA; +typedef NTSTATUS +(NTAPI *PRTL_AVL_MATCH_FUNCTION) ( + IN struct _RTL_AVL_TABLE *Table, + IN PVOID UserData, + IN PVOID MatchData); -extern NTKERNELAPI PVOID MmHighestUserAddress; -extern NTKERNELAPI PVOID MmSystemRangeStart; -extern NTKERNELAPI ULONG MmUserProbeAddress; +typedef struct _RTL_BALANCED_LINKS { + struct _RTL_BALANCED_LINKS *Parent; + struct _RTL_BALANCED_LINKS *LeftChild; + struct _RTL_BALANCED_LINKS *RightChild; + CHAR Balance; + UCHAR Reserved[3]; +} RTL_BALANCED_LINKS, *PRTL_BALANCED_LINKS; +typedef struct _RTL_AVL_TABLE { + RTL_BALANCED_LINKS BalancedRoot; + PVOID OrderedPointer; + ULONG WhichOrderedElement; + ULONG NumberGenericTableElements; + ULONG DepthOfTree; + PRTL_BALANCED_LINKS RestartKey; + ULONG DeleteCount; + PRTL_AVL_COMPARE_ROUTINE CompareRoutine; + PRTL_AVL_ALLOCATE_ROUTINE AllocateRoutine; + PRTL_AVL_FREE_ROUTINE FreeRoutine; + PVOID TableContext; +} RTL_AVL_TABLE, *PRTL_AVL_TABLE; -#ifdef _X86_ +#ifndef RTL_USE_AVL_TABLES -#define MM_HIGHEST_USER_ADDRESS MmHighestUserAddress -#define MM_SYSTEM_RANGE_START MmSystemRangeStart -#if defined(_LOCAL_COPY_USER_PROBE_ADDRESS_) -#define MM_USER_PROBE_ADDRESS _LOCAL_COPY_USER_PROBE_ADDRESS_ -extern ULONG _LOCAL_COPY_USER_PROBE_ADDRESS_; -#else -#define MM_USER_PROBE_ADDRESS MmUserProbeAddress -#endif -#define MM_LOWEST_USER_ADDRESS (PVOID)0x10000 -#define MM_KSEG0_BASE MM_SYSTEM_RANGE_START -#define MM_SYSTEM_SPACE_END 0xFFFFFFFF -#if !defined (_X86PAE_) -#define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xC0800000 -#else -#define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xC0C00000 -#endif +struct _RTL_GENERIC_TABLE; -#define KeGetPcr() PCR +typedef RTL_GENERIC_COMPARE_RESULTS +(NTAPI *PRTL_GENERIC_COMPARE_ROUTINE) ( + IN struct _RTL_GENERIC_TABLE *Table, + IN PVOID FirstStruct, + IN PVOID SecondStruct); -#define KERNEL_STACK_SIZE 12288 -#define KERNEL_LARGE_STACK_SIZE 61440 -#define KERNEL_LARGE_STACK_COMMIT 12288 +typedef PVOID +(NTAPI *PRTL_GENERIC_ALLOCATE_ROUTINE) ( + IN struct _RTL_GENERIC_TABLE *Table, + IN CLONG ByteSize); -#define SIZE_OF_80387_REGISTERS 80 +typedef VOID +(NTAPI *PRTL_GENERIC_FREE_ROUTINE) ( + IN struct _RTL_GENERIC_TABLE *Table, + IN PVOID Buffer); -#define PCR_MINOR_VERSION 1 -#define PCR_MAJOR_VERSION 1 +typedef struct _RTL_SPLAY_LINKS { + struct _RTL_SPLAY_LINKS *Parent; + struct _RTL_SPLAY_LINKS *LeftChild; + struct _RTL_SPLAY_LINKS *RightChild; +} RTL_SPLAY_LINKS, *PRTL_SPLAY_LINKS; -#if !defined(RC_INVOKED) +typedef struct _RTL_GENERIC_TABLE { + PRTL_SPLAY_LINKS TableRoot; + LIST_ENTRY InsertOrderList; + PLIST_ENTRY OrderedPointer; + ULONG WhichOrderedElement; + ULONG NumberGenericTableElements; + PRTL_GENERIC_COMPARE_ROUTINE CompareRoutine; + PRTL_GENERIC_ALLOCATE_ROUTINE AllocateRoutine; + PRTL_GENERIC_FREE_ROUTINE FreeRoutine; + PVOID TableContext; +} RTL_GENERIC_TABLE, *PRTL_GENERIC_TABLE; -#define CONTEXT_i386 0x10000 -#define CONTEXT_i486 0x10000 -#define CONTEXT_CONTROL (CONTEXT_i386|0x00000001L) -#define CONTEXT_INTEGER (CONTEXT_i386|0x00000002L) -#define CONTEXT_SEGMENTS (CONTEXT_i386|0x00000004L) -#define CONTEXT_FLOATING_POINT (CONTEXT_i386|0x00000008L) -#define CONTEXT_DEBUG_REGISTERS (CONTEXT_i386|0x00000010L) -#define CONTEXT_EXTENDED_REGISTERS (CONTEXT_i386|0x00000020L) +#endif /* !RTL_USE_AVL_TABLES */ -#define CONTEXT_FULL (CONTEXT_CONTROL|CONTEXT_INTEGER|CONTEXT_SEGMENTS) +#ifdef RTL_USE_AVL_TABLES -#endif /* !defined(RC_INVOKED) */ +#undef PRTL_GENERIC_COMPARE_ROUTINE +#undef RTL_GENERIC_COMPARE_ROUTINE +#undef PRTL_GENERIC_ALLOCATE_ROUTINE +#undef RTL_GENERIC_ALLOCATE_ROUTINE +#undef PRTL_GENERIC_FREE_ROUTINE +#undef RTL_GENERIC_FREE_ROUTINE +#undef RTL_GENERIC_TABLE +#undef PRTL_GENERIC_TABLE -typedef struct _KPCR { - union { - NT_TIB NtTib; - struct { - struct _EXCEPTION_REGISTRATION_RECORD *Used_ExceptionList; - PVOID Used_StackBase; - PVOID Spare2; - PVOID TssCopy; - ULONG ContextSwitches; - KAFFINITY SetMemberCopy; - PVOID Used_Self; - }; - }; - struct _KPCR *SelfPcr; - struct _KPRCB *Prcb; - KIRQL Irql; - ULONG IRR; - ULONG IrrActive; - ULONG IDR; - PVOID KdVersionBlock; - struct _KIDTENTRY *IDT; - struct _KGDTENTRY *GDT; - struct _KTSS *TSS; - USHORT MajorVersion; - USHORT MinorVersion; - KAFFINITY SetMember; - ULONG StallScaleFactor; - UCHAR SpareUnused; - UCHAR Number; - UCHAR Spare0; - UCHAR SecondLevelCacheAssociativity; - ULONG VdmAlert; - ULONG KernelReserved[14]; - ULONG SecondLevelCacheSize; - ULONG HalReserved[16]; -} KPCR, *PKPCR; +#define PRTL_GENERIC_COMPARE_ROUTINE PRTL_AVL_COMPARE_ROUTINE +#define RTL_GENERIC_COMPARE_ROUTINE RTL_AVL_COMPARE_ROUTINE +#define PRTL_GENERIC_ALLOCATE_ROUTINE PRTL_AVL_ALLOCATE_ROUTINE +#define RTL_GENERIC_ALLOCATE_ROUTINE RTL_AVL_ALLOCATE_ROUTINE +#define PRTL_GENERIC_FREE_ROUTINE PRTL_AVL_FREE_ROUTINE +#define RTL_GENERIC_FREE_ROUTINE RTL_AVL_FREE_ROUTINE +#define RTL_GENERIC_TABLE RTL_AVL_TABLE +#define PRTL_GENERIC_TABLE PRTL_AVL_TABLE -FORCEINLINE -ULONG -KeGetCurrentProcessorNumber(VOID) -{ - return (ULONG)__readfsbyte(FIELD_OFFSET(KPCR, Number)); -} +#endif /* RTL_USE_AVL_TABLES */ -typedef struct _FLOATING_SAVE_AREA { - ULONG ControlWord; - ULONG StatusWord; - ULONG TagWord; - ULONG ErrorOffset; - ULONG ErrorSelector; - ULONG DataOffset; - ULONG DataSelector; - UCHAR RegisterArea[SIZE_OF_80387_REGISTERS]; - ULONG Cr0NpxState; -} FLOATING_SAVE_AREA, *PFLOATING_SAVE_AREA; +typedef struct _RTL_DYNAMIC_HASH_TABLE_ENTRY { + LIST_ENTRY Linkage; + ULONG_PTR Signature; +} RTL_DYNAMIC_HASH_TABLE_ENTRY, *PRTL_DYNAMIC_HASH_TABLE_ENTRY; -#include "pshpack4.h" -typedef struct _CONTEXT { - ULONG ContextFlags; - ULONG Dr0; - ULONG Dr1; - ULONG Dr2; - ULONG Dr3; - ULONG Dr6; - ULONG Dr7; - FLOATING_SAVE_AREA FloatSave; - ULONG SegGs; - ULONG SegFs; - ULONG SegEs; - ULONG SegDs; - ULONG Edi; - ULONG Esi; - ULONG Ebx; - ULONG Edx; - ULONG Ecx; - ULONG Eax; - ULONG Ebp; - ULONG Eip; - ULONG SegCs; - ULONG EFlags; - ULONG Esp; - ULONG SegSs; - UCHAR ExtendedRegisters[MAXIMUM_SUPPORTED_EXTENSION]; -} CONTEXT; -#include "poppack.h" +typedef struct _RTL_DYNAMIC_HASH_TABLE_CONTEXT { + PLIST_ENTRY ChainHead; + PLIST_ENTRY PrevLinkage; + ULONG_PTR Signature; +} RTL_DYNAMIC_HASH_TABLE_CONTEXT, *PRTL_DYNAMIC_HASH_TABLE_CONTEXT; -#endif /* _X86_ */ +typedef struct _RTL_DYNAMIC_HASH_TABLE_ENUMERATOR { + RTL_DYNAMIC_HASH_TABLE_ENTRY HashEntry; + PLIST_ENTRY ChainHead; + ULONG BucketIndex; +} RTL_DYNAMIC_HASH_TABLE_ENUMERATOR, *PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR; -#ifdef _AMD64_ - -#define PTI_SHIFT 12L -#define PDI_SHIFT 21L -#define PPI_SHIFT 30L -#define PXI_SHIFT 39L -#define PTE_PER_PAGE 512 -#define PDE_PER_PAGE 512 -#define PPE_PER_PAGE 512 -#define PXE_PER_PAGE 512 -#define PTI_MASK_AMD64 (PTE_PER_PAGE - 1) -#define PDI_MASK_AMD64 (PDE_PER_PAGE - 1) -#define PPI_MASK (PPE_PER_PAGE - 1) -#define PXI_MASK (PXE_PER_PAGE - 1) - -#define PXE_BASE 0xFFFFF6FB7DBED000ULL -#define PXE_SELFMAP 0xFFFFF6FB7DBEDF68ULL -#define PPE_BASE 0xFFFFF6FB7DA00000ULL -#define PDE_BASE 0xFFFFF6FB40000000ULL -#define PTE_BASE 0xFFFFF68000000000ULL -#define PXE_TOP 0xFFFFF6FB7DBEDFFFULL -#define PPE_TOP 0xFFFFF6FB7DBFFFFFULL -#define PDE_TOP 0xFFFFF6FB7FFFFFFFULL -#define PTE_TOP 0xFFFFF6FFFFFFFFFFULL - -#define MM_HIGHEST_USER_ADDRESS MmHighestUserAddress -#define MM_SYSTEM_RANGE_START MmSystemRangeStart -#define MM_USER_PROBE_ADDRESS MmUserProbeAddress -#define MM_LOWEST_USER_ADDRESS (PVOID)0x10000 -#define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xFFFF080000000000ULL -#define KI_USER_SHARED_DATA 0xFFFFF78000000000ULL - -typedef struct DECLSPEC_ALIGN(16) _CONTEXT { - ULONG64 P1Home; - ULONG64 P2Home; - ULONG64 P3Home; - ULONG64 P4Home; - ULONG64 P5Home; - ULONG64 P6Home; - - /* Control flags */ - ULONG ContextFlags; - ULONG MxCsr; - - /* Segment */ - USHORT SegCs; - USHORT SegDs; - USHORT SegEs; - USHORT SegFs; - USHORT SegGs; - USHORT SegSs; - ULONG EFlags; - - /* Debug */ - ULONG64 Dr0; - ULONG64 Dr1; - ULONG64 Dr2; - ULONG64 Dr3; - ULONG64 Dr6; - ULONG64 Dr7; - - /* Integer */ - ULONG64 Rax; - ULONG64 Rcx; - ULONG64 Rdx; - ULONG64 Rbx; - ULONG64 Rsp; - ULONG64 Rbp; - ULONG64 Rsi; - ULONG64 Rdi; - ULONG64 R8; - ULONG64 R9; - ULONG64 R10; - ULONG64 R11; - ULONG64 R12; - ULONG64 R13; - ULONG64 R14; - ULONG64 R15; - - /* Counter */ - ULONG64 Rip; - - /* Floating point */ - union { - XMM_SAVE_AREA32 FltSave; - struct { - M128A Header[2]; - M128A Legacy[8]; - M128A Xmm0; - M128A Xmm1; - M128A Xmm2; - M128A Xmm3; - M128A Xmm4; - M128A Xmm5; - M128A Xmm6; - M128A Xmm7; - M128A Xmm8; - M128A Xmm9; - M128A Xmm10; - M128A Xmm11; - M128A Xmm12; - M128A Xmm13; - M128A Xmm14; - M128A Xmm15; - } DUMMYSTRUCTNAME; - } DUMMYUNIONNAME; - - /* Vector */ - M128A VectorRegister[26]; - ULONG64 VectorControl; - - /* Debug control */ - ULONG64 DebugControl; - ULONG64 LastBranchToRip; - ULONG64 LastBranchFromRip; - ULONG64 LastExceptionToRip; - ULONG64 LastExceptionFromRip; -} CONTEXT; - -typedef struct _KPCR -{ - _ANONYMOUS_UNION union - { - NT_TIB NtTib; - _ANONYMOUS_STRUCT struct - { - union _KGDTENTRY64 *GdtBase; - struct _KTSS64 *TssBase; - ULONG64 UserRsp; - struct _KPCR *Self; - struct _KPRCB *CurrentPrcb; - PKSPIN_LOCK_QUEUE LockArray; - PVOID Used_Self; - }; - }; - union _KIDTENTRY64 *IdtBase; - ULONG64 Unused[2]; - KIRQL Irql; - UCHAR SecondLevelCacheAssociativity; - UCHAR ObsoleteNumber; - UCHAR Fill0; - ULONG Unused0[3]; - USHORT MajorVersion; - USHORT MinorVersion; - ULONG StallScaleFactor; - PVOID Unused1[3]; - ULONG KernelReserved[15]; - ULONG SecondLevelCacheSize; - ULONG HalReserved[16]; - ULONG Unused2; - PVOID KdVersionBlock; - PVOID Unused3; - ULONG PcrAlign1[24]; -} KPCR, *PKPCR; - -FORCEINLINE -PKPCR -KeGetPcr(VOID) -{ - return (PKPCR)__readgsqword(FIELD_OFFSET(KPCR, Self)); -} - -FORCEINLINE -ULONG -KeGetCurrentProcessorNumber(VOID) -{ - return (ULONG)__readgsword(0x184); -} - -#if !defined(RC_INVOKED) - -#define CONTEXT_AMD64 0x100000 - -#define CONTEXT_CONTROL (CONTEXT_AMD64 | 0x1L) -#define CONTEXT_INTEGER (CONTEXT_AMD64 | 0x2L) -#define CONTEXT_SEGMENTS (CONTEXT_AMD64 | 0x4L) -#define CONTEXT_FLOATING_POINT (CONTEXT_AMD64 | 0x8L) -#define CONTEXT_DEBUG_REGISTERS (CONTEXT_AMD64 | 0x10L) - -#define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT) -#define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS) - -#define CONTEXT_XSTATE (CONTEXT_AMD64 | 0x20L) - -#define CONTEXT_EXCEPTION_ACTIVE 0x8000000 -#define CONTEXT_SERVICE_ACTIVE 0x10000000 -#define CONTEXT_EXCEPTION_REQUEST 0x40000000 -#define CONTEXT_EXCEPTION_REPORTING 0x80000000 - -#endif /* RC_INVOKED */ - -#endif /* _AMD64_ */ - -typedef enum _INTERLOCKED_RESULT { - ResultNegative = RESULT_NEGATIVE, - ResultZero = RESULT_ZERO, - ResultPositive = RESULT_POSITIVE -} INTERLOCKED_RESULT; +typedef struct _RTL_DYNAMIC_HASH_TABLE { + ULONG Flags; + ULONG Shift; + ULONG TableSize; + ULONG Pivot; + ULONG DivisorMask; + ULONG NumEntries; + ULONG NonEmptyBuckets; + ULONG NumEnumerators; + PVOID Directory; +} RTL_DYNAMIC_HASH_TABLE, *PRTL_DYNAMIC_HASH_TABLE; typedef struct _OSVERSIONINFOA { ULONG dwOSVersionInfoSize; @@ -1589,24 +2783,454 @@ typedef POSVERSIONINFOA POSVERSIONINFO; typedef LPOSVERSIONINFOA LPOSVERSIONINFO; #endif /* UNICODE */ -/* Executive Types */ +#define HASH_ENTRY_KEY(x) ((x)->Signature) -#define PROTECTED_POOL 0x80000000 +/****************************************************************************** + * Security Manager Types * + ******************************************************************************/ +#define SE_UNSOLICITED_INPUT_PRIVILEGE 6 -typedef struct _ZONE_SEGMENT_HEADER { - SINGLE_LIST_ENTRY SegmentList; - PVOID Reserved; -} ZONE_SEGMENT_HEADER, *PZONE_SEGMENT_HEADER; +typedef enum _WELL_KNOWN_SID_TYPE { + WinNullSid = 0, + WinWorldSid = 1, + WinLocalSid = 2, + WinCreatorOwnerSid = 3, + WinCreatorGroupSid = 4, + WinCreatorOwnerServerSid = 5, + WinCreatorGroupServerSid = 6, + WinNtAuthoritySid = 7, + WinDialupSid = 8, + WinNetworkSid = 9, + WinBatchSid = 10, + WinInteractiveSid = 11, + WinServiceSid = 12, + WinAnonymousSid = 13, + WinProxySid = 14, + WinEnterpriseControllersSid = 15, + WinSelfSid = 16, + WinAuthenticatedUserSid = 17, + WinRestrictedCodeSid = 18, + WinTerminalServerSid = 19, + WinRemoteLogonIdSid = 20, + WinLogonIdsSid = 21, + WinLocalSystemSid = 22, + WinLocalServiceSid = 23, + WinNetworkServiceSid = 24, + WinBuiltinDomainSid = 25, + WinBuiltinAdministratorsSid = 26, + WinBuiltinUsersSid = 27, + WinBuiltinGuestsSid = 28, + WinBuiltinPowerUsersSid = 29, + WinBuiltinAccountOperatorsSid = 30, + WinBuiltinSystemOperatorsSid = 31, + WinBuiltinPrintOperatorsSid = 32, + WinBuiltinBackupOperatorsSid = 33, + WinBuiltinReplicatorSid = 34, + WinBuiltinPreWindows2000CompatibleAccessSid = 35, + WinBuiltinRemoteDesktopUsersSid = 36, + WinBuiltinNetworkConfigurationOperatorsSid = 37, + WinAccountAdministratorSid = 38, + WinAccountGuestSid = 39, + WinAccountKrbtgtSid = 40, + WinAccountDomainAdminsSid = 41, + WinAccountDomainUsersSid = 42, + WinAccountDomainGuestsSid = 43, + WinAccountComputersSid = 44, + WinAccountControllersSid = 45, + WinAccountCertAdminsSid = 46, + WinAccountSchemaAdminsSid = 47, + WinAccountEnterpriseAdminsSid = 48, + WinAccountPolicyAdminsSid = 49, + WinAccountRasAndIasServersSid = 50, + WinNTLMAuthenticationSid = 51, + WinDigestAuthenticationSid = 52, + WinSChannelAuthenticationSid = 53, + WinThisOrganizationSid = 54, + WinOtherOrganizationSid = 55, + WinBuiltinIncomingForestTrustBuildersSid = 56, + WinBuiltinPerfMonitoringUsersSid = 57, + WinBuiltinPerfLoggingUsersSid = 58, + WinBuiltinAuthorizationAccessSid = 59, + WinBuiltinTerminalServerLicenseServersSid = 60, + WinBuiltinDCOMUsersSid = 61, + WinBuiltinIUsersSid = 62, + WinIUserSid = 63, + WinBuiltinCryptoOperatorsSid = 64, + WinUntrustedLabelSid = 65, + WinLowLabelSid = 66, + WinMediumLabelSid = 67, + WinHighLabelSid = 68, + WinSystemLabelSid = 69, + WinWriteRestrictedCodeSid = 70, + WinCreatorOwnerRightsSid = 71, + WinCacheablePrincipalsGroupSid = 72, + WinNonCacheablePrincipalsGroupSid = 73, + WinEnterpriseReadonlyControllersSid = 74, + WinAccountReadonlyControllersSid = 75, + WinBuiltinEventLogReadersGroup = 76, + WinNewEnterpriseReadonlyControllersSid = 77, + WinBuiltinCertSvcDComAccessGroup = 78, + WinMediumPlusLabelSid = 79, + WinLocalLogonSid = 80, + WinConsoleLogonSid = 81, + WinThisOrganizationCertificateSid = 82, +} WELL_KNOWN_SID_TYPE; -typedef struct _ZONE_HEADER { - SINGLE_LIST_ENTRY FreeList; - SINGLE_LIST_ENTRY SegmentList; - ULONG BlockSize; - ULONG TotalSegmentSize; -} ZONE_HEADER, *PZONE_HEADER; -/* Executive Functions */ +#if defined(_M_IX86) + +#define PAUSE_PROCESSOR YieldProcessor(); + +#define KERNEL_STACK_SIZE 12288 +#define KERNEL_LARGE_STACK_SIZE 61440 +#define KERNEL_LARGE_STACK_COMMIT 12288 + +#define SIZE_OF_80387_REGISTERS 80 + +#if !defined(RC_INVOKED) + +#define CONTEXT_i386 0x10000 +#define CONTEXT_i486 0x10000 +#define CONTEXT_CONTROL (CONTEXT_i386|0x00000001L) +#define CONTEXT_INTEGER (CONTEXT_i386|0x00000002L) +#define CONTEXT_SEGMENTS (CONTEXT_i386|0x00000004L) +#define CONTEXT_FLOATING_POINT (CONTEXT_i386|0x00000008L) +#define CONTEXT_DEBUG_REGISTERS (CONTEXT_i386|0x00000010L) +#define CONTEXT_EXTENDED_REGISTERS (CONTEXT_i386|0x00000020L) + +#define CONTEXT_FULL (CONTEXT_CONTROL|CONTEXT_INTEGER|CONTEXT_SEGMENTS) +#define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | \ + CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS | \ + CONTEXT_EXTENDED_REGISTERS) + +#define CONTEXT_XSTATE (CONTEXT_i386 | 0x00000040L) + +#endif /* !defined(RC_INVOKED) */ + +typedef struct _FLOATING_SAVE_AREA { + ULONG ControlWord; + ULONG StatusWord; + ULONG TagWord; + ULONG ErrorOffset; + ULONG ErrorSelector; + ULONG DataOffset; + ULONG DataSelector; + UCHAR RegisterArea[SIZE_OF_80387_REGISTERS]; + ULONG Cr0NpxState; +} FLOATING_SAVE_AREA, *PFLOATING_SAVE_AREA; + +#include "pshpack4.h" +typedef struct _CONTEXT { + ULONG ContextFlags; + ULONG Dr0; + ULONG Dr1; + ULONG Dr2; + ULONG Dr3; + ULONG Dr6; + ULONG Dr7; + FLOATING_SAVE_AREA FloatSave; + ULONG SegGs; + ULONG SegFs; + ULONG SegEs; + ULONG SegDs; + ULONG Edi; + ULONG Esi; + ULONG Ebx; + ULONG Edx; + ULONG Ecx; + ULONG Eax; + ULONG Ebp; + ULONG Eip; + ULONG SegCs; + ULONG EFlags; + ULONG Esp; + ULONG SegSs; + UCHAR ExtendedRegisters[MAXIMUM_SUPPORTED_EXTENSION]; +} CONTEXT; +#include "poppack.h" + +#define KeGetPcr() PCR + +#define PCR_MINOR_VERSION 1 +#define PCR_MAJOR_VERSION 1 + +typedef struct _KPCR { + union { + NT_TIB NtTib; + struct { + struct _EXCEPTION_REGISTRATION_RECORD *Used_ExceptionList; + PVOID Used_StackBase; + PVOID Spare2; + PVOID TssCopy; + ULONG ContextSwitches; + KAFFINITY SetMemberCopy; + PVOID Used_Self; + }; + }; + struct _KPCR *SelfPcr; + struct _KPRCB *Prcb; + KIRQL Irql; + ULONG IRR; + ULONG IrrActive; + ULONG IDR; + PVOID KdVersionBlock; + struct _KIDTENTRY *IDT; + struct _KGDTENTRY *GDT; + struct _KTSS *TSS; + USHORT MajorVersion; + USHORT MinorVersion; + KAFFINITY SetMember; + ULONG StallScaleFactor; + UCHAR SpareUnused; + UCHAR Number; + UCHAR Spare0; + UCHAR SecondLevelCacheAssociativity; + ULONG VdmAlert; + ULONG KernelReserved[14]; + ULONG SecondLevelCacheSize; + ULONG HalReserved[16]; +} KPCR, *PKPCR; + +FORCEINLINE +ULONG +KeGetCurrentProcessorNumber(VOID) +{ + return (ULONG)__readfsbyte(FIELD_OFFSET(KPCR, Number)); +} + + + + + + +extern NTKERNELAPI PVOID MmHighestUserAddress; +extern NTKERNELAPI PVOID MmSystemRangeStart; +extern NTKERNELAPI ULONG MmUserProbeAddress; + +#define MM_HIGHEST_USER_ADDRESS MmHighestUserAddress +#define MM_SYSTEM_RANGE_START MmSystemRangeStart +#if defined(_LOCAL_COPY_USER_PROBE_ADDRESS_) +#define MM_USER_PROBE_ADDRESS _LOCAL_COPY_USER_PROBE_ADDRESS_ +extern ULONG _LOCAL_COPY_USER_PROBE_ADDRESS_; +#else +#define MM_USER_PROBE_ADDRESS MmUserProbeAddress +#endif +#define MM_LOWEST_USER_ADDRESS (PVOID)0x10000 +#define MM_KSEG0_BASE MM_SYSTEM_RANGE_START +#define MM_SYSTEM_SPACE_END 0xFFFFFFFF +#if !defined (_X86PAE_) +#define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xC0800000 +#else +#define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xC0C00000 +#endif + +#elif defined(_M_AMD64) + +#define PAUSE_PROCESSOR YieldProcessor(); + +#define KERNEL_STACK_SIZE 0x6000 +#define KERNEL_LARGE_STACK_SIZE 0x12000 +#define KERNEL_LARGE_STACK_COMMIT KERNEL_STACK_SIZE + +#define KERNEL_MCA_EXCEPTION_STACK_SIZE 0x2000 + +#define EXCEPTION_READ_FAULT 0 +#define EXCEPTION_WRITE_FAULT 1 +#define EXCEPTION_EXECUTE_FAULT 8 + +#if !defined(RC_INVOKED) + +#define CONTEXT_AMD64 0x100000 + +#define CONTEXT_CONTROL (CONTEXT_AMD64 | 0x1L) +#define CONTEXT_INTEGER (CONTEXT_AMD64 | 0x2L) +#define CONTEXT_SEGMENTS (CONTEXT_AMD64 | 0x4L) +#define CONTEXT_FLOATING_POINT (CONTEXT_AMD64 | 0x8L) +#define CONTEXT_DEBUG_REGISTERS (CONTEXT_AMD64 | 0x10L) + +#define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT) +#define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS) + +#define CONTEXT_XSTATE (CONTEXT_AMD64 | 0x20L) + +#define CONTEXT_EXCEPTION_ACTIVE 0x8000000 +#define CONTEXT_SERVICE_ACTIVE 0x10000000 +#define CONTEXT_EXCEPTION_REQUEST 0x40000000 +#define CONTEXT_EXCEPTION_REPORTING 0x80000000 + +#endif /* !defined(RC_INVOKED) */ + +#define INITIAL_MXCSR 0x1f80 +#define INITIAL_FPCSR 0x027f + +typedef struct DECLSPEC_ALIGN(16) _CONTEXT { + ULONG64 P1Home; + ULONG64 P2Home; + ULONG64 P3Home; + ULONG64 P4Home; + ULONG64 P5Home; + ULONG64 P6Home; + ULONG ContextFlags; + ULONG MxCsr; + USHORT SegCs; + USHORT SegDs; + USHORT SegEs; + USHORT SegFs; + USHORT SegGs; + USHORT SegSs; + ULONG EFlags; + ULONG64 Dr0; + ULONG64 Dr1; + ULONG64 Dr2; + ULONG64 Dr3; + ULONG64 Dr6; + ULONG64 Dr7; + ULONG64 Rax; + ULONG64 Rcx; + ULONG64 Rdx; + ULONG64 Rbx; + ULONG64 Rsp; + ULONG64 Rbp; + ULONG64 Rsi; + ULONG64 Rdi; + ULONG64 R8; + ULONG64 R9; + ULONG64 R10; + ULONG64 R11; + ULONG64 R12; + ULONG64 R13; + ULONG64 R14; + ULONG64 R15; + ULONG64 Rip; + union { + XMM_SAVE_AREA32 FltSave; + struct { + M128A Header[2]; + M128A Legacy[8]; + M128A Xmm0; + M128A Xmm1; + M128A Xmm2; + M128A Xmm3; + M128A Xmm4; + M128A Xmm5; + M128A Xmm6; + M128A Xmm7; + M128A Xmm8; + M128A Xmm9; + M128A Xmm10; + M128A Xmm11; + M128A Xmm12; + M128A Xmm13; + M128A Xmm14; + M128A Xmm15; + } DUMMYSTRUCTNAME; + } DUMMYUNIONNAME; + M128A VectorRegister[26]; + ULONG64 VectorControl; + ULONG64 DebugControl; + ULONG64 LastBranchToRip; + ULONG64 LastBranchFromRip; + ULONG64 LastExceptionToRip; + ULONG64 LastExceptionFromRip; +} CONTEXT; + +typedef struct _KPCR +{ + _ANONYMOUS_UNION union + { + NT_TIB NtTib; + _ANONYMOUS_STRUCT struct + { + union _KGDTENTRY64 *GdtBase; + struct _KTSS64 *TssBase; + ULONG64 UserRsp; + struct _KPCR *Self; + struct _KPRCB *CurrentPrcb; + PKSPIN_LOCK_QUEUE LockArray; + PVOID Used_Self; + }; + }; + union _KIDTENTRY64 *IdtBase; + ULONG64 Unused[2]; + KIRQL Irql; + UCHAR SecondLevelCacheAssociativity; + UCHAR ObsoleteNumber; + UCHAR Fill0; + ULONG Unused0[3]; + USHORT MajorVersion; + USHORT MinorVersion; + ULONG StallScaleFactor; + PVOID Unused1[3]; + ULONG KernelReserved[15]; + ULONG SecondLevelCacheSize; + ULONG HalReserved[16]; + ULONG Unused2; + PVOID KdVersionBlock; + PVOID Unused3; + ULONG PcrAlign1[24]; +} KPCR, *PKPCR; + +FORCEINLINE +PKPCR +KeGetPcr(VOID) +{ + return (PKPCR)__readgsqword(FIELD_OFFSET(KPCR, Self)); +} + +FORCEINLINE +ULONG +KeGetCurrentProcessorNumber(VOID) +{ + return (ULONG)__readgsword(0x184); +} + + +#define PTI_SHIFT 12L +#define PDI_SHIFT 21L +#define PPI_SHIFT 30L +#define PXI_SHIFT 39L +#define PTE_PER_PAGE 512 +#define PDE_PER_PAGE 512 +#define PPE_PER_PAGE 512 +#define PXE_PER_PAGE 512 +#define PTI_MASK_AMD64 (PTE_PER_PAGE - 1) +#define PDI_MASK_AMD64 (PDE_PER_PAGE - 1) +#define PPI_MASK (PPE_PER_PAGE - 1) +#define PXI_MASK (PXE_PER_PAGE - 1) + +#define PXE_BASE 0xFFFFF6FB7DBED000ULL +#define PXE_SELFMAP 0xFFFFF6FB7DBEDF68ULL +#define PPE_BASE 0xFFFFF6FB7DA00000ULL +#define PDE_BASE 0xFFFFF6FB40000000ULL +#define PTE_BASE 0xFFFFF68000000000ULL +#define PXE_TOP 0xFFFFF6FB7DBEDFFFULL +#define PPE_TOP 0xFFFFF6FB7DBFFFFFULL +#define PDE_TOP 0xFFFFF6FB7FFFFFFFULL +#define PTE_TOP 0xFFFFF6FFFFFFFFFFULL + +#define MM_HIGHEST_USER_ADDRESS MmHighestUserAddress +#define MM_SYSTEM_RANGE_START MmSystemRangeStart +#define MM_USER_PROBE_ADDRESS MmUserProbeAddress +#define MM_LOWEST_USER_ADDRESS (PVOID)0x10000 +#define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xFFFF080000000000ULL + + +#elif defined(_M_IA64) + +#elif defined(_M_PPC) + + +#elif defined(_M_MIPS) + +#elif defined(_M_ARM) +#else +#error Unknown Architecture +#endif + +/****************************************************************************** + * Executive Functions * + ******************************************************************************/ static __inline PVOID ExAllocateFromZone( IN PZONE_HEADER Zone) @@ -1618,8 +3242,8 @@ ExAllocateFromZone( static __inline PVOID ExFreeToZone( - IN PZONE_HEADER Zone, - IN PVOID Block) + IN PZONE_HEADER Zone, + IN PVOID Block) { ((PSINGLE_LIST_ENTRY) Block)->Next = Zone->FreeList.Next; Zone->FreeList.Next = ((PSINGLE_LIST_ENTRY) Block); @@ -1672,8 +3296,36 @@ ExFreeToZone( #define ExIsResourceAcquired ExIsResourceAcquiredSharedLite #define ExReleaseResourceForThread ExReleaseResourceForThreadLite -#if (NTDDI_VERSION >= NTDDI_WIN2K) +typedef enum _INTERLOCKED_RESULT { + ResultNegative = RESULT_NEGATIVE, + ResultZero = RESULT_ZERO, + ResultPositive = RESULT_POSITIVE +} INTERLOCKED_RESULT; +#ifdef _X86_ +NTKERNELAPI +INTERLOCKED_RESULT +FASTCALL +Exfi386InterlockedIncrementLong( + IN OUT LONG volatile *Addend); + +NTKERNELAPI +INTERLOCKED_RESULT +FASTCALL +Exfi386InterlockedDecrementLong( + IN PLONG Addend); + +NTKERNELAPI +ULONG +FASTCALL +Exfi386InterlockedExchangeUlong( + IN PULONG Target, + IN ULONG Value); +#endif + + + +#if (NTDDI_VERSION >= NTDDI_WIN2K) NTKERNELAPI NTSTATUS NTAPI @@ -1710,312 +3362,24 @@ NTKERNELAPI DECLSPEC_NORETURN VOID NTAPI -ExRaiseAccessViolation( - VOID); +ExRaiseAccessViolation(VOID); NTKERNELAPI DECLSPEC_NORETURN VOID NTAPI -ExRaiseDatatypeMisalignment( - VOID); +ExRaiseDatatypeMisalignment(VOID); -#endif -#ifdef _X86_ +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ -NTKERNELAPI -INTERLOCKED_RESULT -FASTCALL -Exfi386InterlockedIncrementLong( - IN OUT LONG volatile *Addend); - -NTKERNELAPI -INTERLOCKED_RESULT -FASTCALL -Exfi386InterlockedDecrementLong( - IN PLONG Addend); - -NTKERNELAPI -ULONG -FASTCALL -Exfi386InterlockedExchangeUlong( - IN PULONG Target, - IN ULONG Value); - -#endif /* _X86_ */ - -#ifndef _ARC_DDK_ -#define _ARC_DDK_ -typedef enum _CONFIGURATION_TYPE { - ArcSystem, - CentralProcessor, - FloatingPointProcessor, - PrimaryIcache, - PrimaryDcache, - SecondaryIcache, - SecondaryDcache, - SecondaryCache, - EisaAdapter, - TcAdapter, - ScsiAdapter, - DtiAdapter, - MultiFunctionAdapter, - DiskController, - TapeController, - CdromController, - WormController, - SerialController, - NetworkController, - DisplayController, - ParallelController, - PointerController, - KeyboardController, - AudioController, - OtherController, - DiskPeripheral, - FloppyDiskPeripheral, - TapePeripheral, - ModemPeripheral, - MonitorPeripheral, - PrinterPeripheral, - PointerPeripheral, - KeyboardPeripheral, - TerminalPeripheral, - OtherPeripheral, - LinePeripheral, - NetworkPeripheral, - SystemMemory, - DockingInformation, - RealModeIrqRoutingTable, - RealModePCIEnumeration, - MaximumType -} CONFIGURATION_TYPE, *PCONFIGURATION_TYPE; -#endif /* !_ARC_DDK_ */ - -typedef struct _CONTROLLER_OBJECT { - CSHORT Type; - CSHORT Size; - PVOID ControllerExtension; - KDEVICE_QUEUE DeviceWaitQueue; - ULONG Spare1; - LARGE_INTEGER Spare2; -} CONTROLLER_OBJECT, *PCONTROLLER_OBJECT; - -typedef struct _CONFIGURATION_INFORMATION { - ULONG DiskCount; - ULONG FloppyCount; - ULONG CdRomCount; - ULONG TapeCount; - ULONG ScsiPortCount; - ULONG SerialCount; - ULONG ParallelCount; - BOOLEAN AtDiskPrimaryAddressClaimed; - BOOLEAN AtDiskSecondaryAddressClaimed; - ULONG Version; - ULONG MediumChangerCount; -} CONFIGURATION_INFORMATION, *PCONFIGURATION_INFORMATION; - -typedef -NTSTATUS -(NTAPI *PIO_QUERY_DEVICE_ROUTINE)( - IN PVOID Context, - IN PUNICODE_STRING PathName, - IN INTERFACE_TYPE BusType, - IN ULONG BusNumber, - IN PKEY_VALUE_FULL_INFORMATION *BusInformation, - IN CONFIGURATION_TYPE ControllerType, - IN ULONG ControllerNumber, - IN PKEY_VALUE_FULL_INFORMATION *ControllerInformation, - IN CONFIGURATION_TYPE PeripheralType, - IN ULONG PeripheralNumber, - IN PKEY_VALUE_FULL_INFORMATION *PeripheralInformation); - -typedef -VOID -(NTAPI DRIVER_REINITIALIZE)( - IN struct _DRIVER_OBJECT *DriverObject, - IN PVOID Context, - IN ULONG Count); - -typedef DRIVER_REINITIALIZE *PDRIVER_REINITIALIZE; - -/** Filesystem runtime library routines **/ - -#if (NTDDI_VERSION >= NTDDI_WIN2K) -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlIsTotalDeviceFailure( - IN NTSTATUS Status); -#endif - -/* Hardware Abstraction Layer Types */ - -typedef VOID -(NTAPI *PciPin2Line)( - IN struct _BUS_HANDLER *BusHandler, - IN struct _BUS_HANDLER *RootHandler, - IN PCI_SLOT_NUMBER SlotNumber, - IN PPCI_COMMON_CONFIG PciData); - -typedef VOID -(NTAPI *PciLine2Pin)( - IN struct _BUS_HANDLER *BusHandler, - IN struct _BUS_HANDLER *RootHandler, - IN PCI_SLOT_NUMBER SlotNumber, - IN PPCI_COMMON_CONFIG PciNewData, - IN PPCI_COMMON_CONFIG PciOldData); - -typedef VOID -(NTAPI *PciReadWriteConfig)( - IN struct _BUS_HANDLER *BusHandler, - IN PCI_SLOT_NUMBER Slot, - IN PVOID Buffer, - IN ULONG Offset, - IN ULONG Length); - -#define PCI_DATA_TAG ' ICP' -#define PCI_DATA_VERSION 1 - -typedef struct _PCIBUSDATA { - ULONG Tag; - ULONG Version; - PciReadWriteConfig ReadConfig; - PciReadWriteConfig WriteConfig; - PciPin2Line Pin2Line; - PciLine2Pin Line2Pin; - PCI_SLOT_NUMBER ParentSlot; - PVOID Reserved[4]; -} PCIBUSDATA, *PPCIBUSDATA; /* Hardware Abstraction Layer Functions */ -#if !defined(NO_LEGACY_DRIVERS) +#if defined(USE_DMA_MACROS) && !defined(_NTHAL_) && (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_) -#if (NTDDI_VERSION >= NTDDI_WIN2K) -NTHALAPI -NTSTATUS -NTAPI -HalAssignSlotResources( - IN PUNICODE_STRING RegistryPath, - IN PUNICODE_STRING DriverClassName, - IN PDRIVER_OBJECT DriverObject, - IN PDEVICE_OBJECT DeviceObject, - IN INTERFACE_TYPE BusType, - IN ULONG BusNumber, - IN ULONG SlotNumber, - IN OUT PCM_RESOURCE_LIST *AllocatedResources); -NTHALAPI -ULONG -NTAPI -HalGetInterruptVector( - IN INTERFACE_TYPE InterfaceType, - IN ULONG BusNumber, - IN ULONG BusInterruptLevel, - IN ULONG BusInterruptVector, - OUT PKIRQL Irql, - OUT PKAFFINITY Affinity); - -NTHALAPI -ULONG -NTAPI -HalSetBusData( - IN BUS_DATA_TYPE BusDataType, - IN ULONG BusNumber, - IN ULONG SlotNumber, - IN PVOID Buffer, - IN ULONG Length); - -#endif - -#endif /* !defined(NO_LEGACY_DRIVERS) */ - -#if (NTDDI_VERSION >= NTDDI_WIN2K) - -NTHALAPI -PADAPTER_OBJECT -NTAPI -HalGetAdapter( - IN PDEVICE_DESCRIPTION DeviceDescription, - IN OUT PULONG NumberOfMapRegisters); - -NTHALAPI -BOOLEAN -NTAPI -HalMakeBeep( - IN ULONG Frequency); - -VOID -NTAPI -HalPutDmaAdapter( - IN PADAPTER_OBJECT DmaAdapter); - -NTHALAPI -VOID -NTAPI -HalAcquireDisplayOwnership( - IN PHAL_RESET_DISPLAY_PARAMETERS ResetDisplayParameters); - -NTHALAPI -ULONG -NTAPI -HalGetBusData( - IN BUS_DATA_TYPE BusDataType, - IN ULONG BusNumber, - IN ULONG SlotNumber, - OUT PVOID Buffer, - IN ULONG Length); - -NTHALAPI -ULONG -NTAPI -HalGetBusDataByOffset( - IN BUS_DATA_TYPE BusDataType, - IN ULONG BusNumber, - IN ULONG SlotNumber, - OUT PVOID Buffer, - IN ULONG Offset, - IN ULONG Length); - -NTHALAPI -ULONG -NTAPI -HalSetBusDataByOffset( - IN BUS_DATA_TYPE BusDataType, - IN ULONG BusNumber, - IN ULONG SlotNumber, - IN PVOID Buffer, - IN ULONG Offset, - IN ULONG Length); - -NTHALAPI -BOOLEAN -NTAPI -HalTranslateBusAddress( - IN INTERFACE_TYPE InterfaceType, - IN ULONG BusNumber, - IN PHYSICAL_ADDRESS BusAddress, - IN OUT PULONG AddressSpace, - OUT PPHYSICAL_ADDRESS TranslatedAddress); - -#endif - -#if (NTDDI_VERSION >= NTDDI_WINXP) -NTKERNELAPI -VOID -FASTCALL -HalExamineMBR( - IN PDEVICE_OBJECT DeviceObject, - IN ULONG SectorSize, - IN ULONG MBRTypeIdentifier, - OUT PVOID *Buffer); -#endif - -#if defined(USE_DMA_MACROS) && !defined(_NTHAL_) && (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_) -// nothing here #else #if (NTDDI_VERSION >= NTDDI_WIN2K) @@ -2086,10 +3450,217 @@ HalAllocateAdapterChannel( #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ -#endif /* defined(USE_DMA_MACROS) && !defined(_NTHAL_) && (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_) */ -/* I/O Manager Functions */ +#endif + +#if !defined(NO_LEGACY_DRIVERS) + +#if (NTDDI_VERSION >= NTDDI_WIN2K) + +NTHALAPI +NTSTATUS +NTAPI +HalAssignSlotResources( + IN PUNICODE_STRING RegistryPath, + IN PUNICODE_STRING DriverClassName, + IN PDRIVER_OBJECT DriverObject, + IN PDEVICE_OBJECT DeviceObject, + IN INTERFACE_TYPE BusType, + IN ULONG BusNumber, + IN ULONG SlotNumber, + IN OUT PCM_RESOURCE_LIST *AllocatedResources); + +NTHALAPI +ULONG +NTAPI +HalGetInterruptVector( + IN INTERFACE_TYPE InterfaceType, + IN ULONG BusNumber, + IN ULONG BusInterruptLevel, + IN ULONG BusInterruptVector, + OUT PKIRQL Irql, + OUT PKAFFINITY Affinity); + +NTHALAPI +ULONG +NTAPI +HalSetBusData( + IN BUS_DATA_TYPE BusDataType, + IN ULONG BusNumber, + IN ULONG SlotNumber, + IN PVOID Buffer, + IN ULONG Length); + +NTHALAPI +ULONG +NTAPI +HalGetBusData( + IN BUS_DATA_TYPE BusDataType, + IN ULONG BusNumber, + IN ULONG SlotNumber, + OUT PVOID Buffer, + IN ULONG Length); + +NTHALAPI +BOOLEAN +NTAPI +HalMakeBeep( + IN ULONG Frequency); + +#endif + +#endif /* !defined(NO_LEGACY_DRIVERS) */ + +#if (NTDDI_VERSION >= NTDDI_WIN2K) + +NTHALAPI +PADAPTER_OBJECT +NTAPI +HalGetAdapter( + IN PDEVICE_DESCRIPTION DeviceDescription, + OUT PULONG NumberOfMapRegisters); + +VOID +NTAPI +HalPutDmaAdapter( + IN PADAPTER_OBJECT DmaAdapter); + +NTHALAPI +VOID +NTAPI +HalAcquireDisplayOwnership( + IN PHAL_RESET_DISPLAY_PARAMETERS ResetDisplayParameters); + +NTHALAPI +ULONG +NTAPI +HalGetBusDataByOffset( + IN BUS_DATA_TYPE BusDataType, + IN ULONG BusNumber, + IN ULONG SlotNumber, + OUT PVOID Buffer, + IN ULONG Offset, + IN ULONG Length); + +NTHALAPI +ULONG +NTAPI +HalSetBusDataByOffset( + IN BUS_DATA_TYPE BusDataType, + IN ULONG BusNumber, + IN ULONG SlotNumber, + IN PVOID Buffer, + IN ULONG Offset, + IN ULONG Length); + +NTHALAPI +BOOLEAN +NTAPI +HalTranslateBusAddress( + IN INTERFACE_TYPE InterfaceType, + IN ULONG BusNumber, + IN PHYSICAL_ADDRESS BusAddress, + IN OUT PULONG AddressSpace, + OUT PPHYSICAL_ADDRESS TranslatedAddress); + +NTHALAPI +PVOID +NTAPI +HalAllocateCrashDumpRegisters( + IN PADAPTER_OBJECT AdapterObject, + IN OUT PULONG NumberOfMapRegisters); + +NTSTATUS +NTAPI +HalGetScatterGatherList( + IN PADAPTER_OBJECT DmaAdapter, + IN PDEVICE_OBJECT DeviceObject, + IN PMDL Mdl, + IN PVOID CurrentVa, + IN ULONG Length, + IN PDRIVER_LIST_CONTROL ExecutionRoutine, + IN PVOID Context, + IN BOOLEAN WriteToDevice); + +VOID +NTAPI +HalPutScatterGatherList( + IN PADAPTER_OBJECT DmaAdapter, + IN PSCATTER_GATHER_LIST ScatterGather, + IN BOOLEAN WriteToDevice); + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ + +#if (NTDDI_VERSION >= NTDDI_WINXP) +NTKERNELAPI +VOID +FASTCALL +HalExamineMBR( + IN PDEVICE_OBJECT DeviceObject, + IN ULONG SectorSize, + IN ULONG MBRTypeIdentifier, + OUT PVOID *Buffer); +#endif + +#if (NTDDI_VERSION >= NTDDI_WIN7) + +NTSTATUS +NTAPI +HalAllocateHardwareCounters( + IN PGROUP_AFFINITY GroupAffinty, + IN ULONG GroupCount, + IN PPHYSICAL_COUNTER_RESOURCE_LIST ResourceList, + OUT PHANDLE CounterSetHandle); + +NTSTATUS +NTAPI +HalFreeHardwareCounters( + IN HANDLE CounterSetHandle); + +#endif + +#if defined(_IA64_) +#if (NTDDI_VERSION >= NTDDI_WIN2K) +NTHALAPI +ULONG +NTAPI +HalGetDmaAlignmentRequirement(VOID); +#endif +#endif /* defined(_IA64_) */ + +#if defined(_M_IX86) || defined(_M_AMD64) +#define HalGetDmaAlignmentRequirement() 1L +#endif + +#if (NTDDI_VERSION >= NTDDI_WIN7) + +typedef struct _WHEA_ERROR_SOURCE_DESCRIPTOR *PWHEA_ERROR_SOURCE_DESCRIPTOR; +typedef struct _WHEA_ERROR_RECORD *PWHEA_ERROR_RECORD; + +NTHALAPI +VOID +NTAPI +HalBugCheckSystem( + IN PWHEA_ERROR_SOURCE_DESCRIPTOR ErrorSource, + IN PWHEA_ERROR_RECORD ErrorRecord); + +#else + +typedef struct _WHEA_ERROR_RECORD *PWHEA_ERROR_RECORD; + +NTHALAPI +VOID +NTAPI +HalBugCheckSystem( + IN PWHEA_ERROR_RECORD ErrorRecord); + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + + +/****************************************************************************** + * I/O Manager Functions * + ******************************************************************************/ /* * VOID IoAssignArcName( * IN PUNICODE_STRING ArcName, @@ -2105,8 +3676,19 @@ HalAllocateAdapterChannel( */ #define IoDeassignArcName IoDeleteSymbolicLink -#if (NTDDI_VERSION >= NTDDI_WIN2K) +VOID +FORCEINLINE +NTAPI +IoInitializeDriverCreateContext( + PIO_DRIVER_CREATE_CONTEXT DriverContext) +{ + RtlZeroMemory(DriverContext, sizeof(IO_DRIVER_CREATE_CONTEXT)); + DriverContext->Size = sizeof(IO_DRIVER_CREATE_CONTEXT); +} + + +#if (NTDDI_VERSION >= NTDDI_WIN2K) #if !(defined(USE_DMA_MACROS) && (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_)) NTKERNELAPI NTSTATUS @@ -2119,6 +3701,7 @@ IoAllocateAdapterChannel( IN PVOID Context); #endif +#if !defined(DMA_MACROS_DEFINED) //DECLSPEC_DEPRECATED_DDK NTHALAPI PHYSICAL_ADDRESS @@ -2130,6 +3713,7 @@ IoMapTransfer( IN PVOID CurrentVa, IN OUT PULONG Length, IN BOOLEAN WriteToDevice); +#endif NTKERNELAPI VOID @@ -2161,8 +3745,7 @@ IoFreeController( NTKERNELAPI PCONFIGURATION_INFORMATION NTAPI -IoGetConfigurationInformation( - VOID); +IoGetConfigurationInformation(VOID); NTKERNELAPI PDEVICE_OBJECT @@ -2180,8 +3763,7 @@ IoCancelFileOpen( NTKERNELAPI PGENERIC_MAPPING NTAPI -IoGetFileObjectGenericMapping( - VOID); +IoGetFileObjectGenericMapping(VOID); NTKERNELAPI PIRP @@ -2253,7 +3835,7 @@ IoReportDetectedDevice( IN PCM_RESOURCE_LIST ResourceList OPTIONAL, IN PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirements OPTIONAL, IN BOOLEAN ResourceAssigned, - IN OUT PDEVICE_OBJECT *DeviceObject); + IN OUT PDEVICE_OBJECT *DeviceObject OPTIONAL); NTKERNELAPI NTSTATUS @@ -2299,9 +3881,59 @@ IoAssignResources( IN PIO_RESOURCE_REQUIREMENTS_LIST RequestedResources OPTIONAL, IN OUT PCM_RESOURCE_LIST *AllocatedResources); +NTKERNELAPI +BOOLEAN +NTAPI +IoSetThreadHardErrorMode( + IN BOOLEAN EnableHardErrors); + #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ +#if (NTDDI_VERSION >= NTDDI_WIN2KSP3) + +NTKERNELAPI +BOOLEAN +NTAPI +IoIsFileOriginRemote( + IN PFILE_OBJECT FileObject); + +NTKERNELAPI +NTSTATUS +NTAPI +IoSetFileOrigin( + IN PFILE_OBJECT FileObject, + IN BOOLEAN Remote); + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2KSP3) */ + #if (NTDDI_VERSION >= NTDDI_WINXP) +NTKERNELAPI +NTSTATUS +FASTCALL +IoReadPartitionTable( + IN PDEVICE_OBJECT DeviceObject, + IN ULONG SectorSize, + IN BOOLEAN ReturnRecognizedPartitions, + OUT struct _DRIVE_LAYOUT_INFORMATION **PartitionBuffer); + +NTKERNELAPI +NTSTATUS +FASTCALL +IoSetPartitionInformation( + IN PDEVICE_OBJECT DeviceObject, + IN ULONG SectorSize, + IN ULONG PartitionNumber, + IN ULONG PartitionType); + +NTKERNELAPI +NTSTATUS +FASTCALL +IoWritePartitionTable( + IN PDEVICE_OBJECT DeviceObject, + IN ULONG SectorSize, + IN ULONG SectorsPerTrack, + IN ULONG NumberOfHeads, + IN struct _DRIVE_LAYOUT_INFORMATION *PartitionBuffer); NTKERNELAPI NTSTATUS @@ -2318,30 +3950,12 @@ IoReadDiskSignature( IN ULONG BytesPerSector, OUT PDISK_SIGNATURE Signature); -NTKERNELAPI -NTSTATUS -FASTCALL -IoReadPartitionTable( - IN PDEVICE_OBJECT DeviceObject, - IN ULONG SectorSize, - IN BOOLEAN ReturnRecognizedPartitions, - OUT struct _DRIVE_LAYOUT_INFORMATION **PartitionBuffer); - NTKERNELAPI NTSTATUS NTAPI IoReadPartitionTableEx( IN PDEVICE_OBJECT DeviceObject, - IN struct _DRIVE_LAYOUT_INFORMATION_EX **PartitionBuffer); - -NTKERNELAPI -NTSTATUS -FASTCALL -IoSetPartitionInformation( - IN PDEVICE_OBJECT DeviceObject, - IN ULONG SectorSize, - IN ULONG PartitionNumber, - IN ULONG PartitionType); + OUT struct _DRIVE_LAYOUT_INFORMATION_EX **PartitionBuffer); NTKERNELAPI NTSTATUS @@ -2357,12 +3971,6 @@ NTAPI IoSetSystemPartition( IN PUNICODE_STRING VolumeNameString); -NTKERNELAPI -BOOLEAN -NTAPI -IoSetThreadHardErrorMode( - IN BOOLEAN EnableHardErrors); - NTKERNELAPI NTSTATUS NTAPI @@ -2377,16 +3985,6 @@ IoVolumeDeviceToDosName( IN PVOID VolumeDeviceObject, OUT PUNICODE_STRING DosName); -NTKERNELAPI -NTSTATUS -FASTCALL -IoWritePartitionTable( - IN PDEVICE_OBJECT DeviceObject, - IN ULONG SectorSize, - IN ULONG SectorsPerTrack, - IN ULONG NumberOfHeads, - IN struct _DRIVE_LAYOUT_INFORMATION *PartitionBuffer); - NTKERNELAPI NTSTATUS NTAPI @@ -2394,10 +3992,130 @@ IoWritePartitionTableEx( IN PDEVICE_OBJECT DeviceObject, IN struct _DRIVE_LAYOUT_INFORMATION_EX *DriveLayout); +NTKERNELAPI +NTSTATUS +NTAPI +IoCreateFileSpecifyDeviceObjectHint( + OUT PHANDLE FileHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN PLARGE_INTEGER AllocationSize OPTIONAL, + IN ULONG FileAttributes, + IN ULONG ShareAccess, + IN ULONG Disposition, + IN ULONG CreateOptions, + IN PVOID EaBuffer OPTIONAL, + IN ULONG EaLength, + IN CREATE_FILE_TYPE CreateFileType, + IN PVOID InternalParameters OPTIONAL, + IN ULONG Options, + IN PVOID DeviceObject OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +IoAttachDeviceToDeviceStackSafe( + IN PDEVICE_OBJECT SourceDevice, + IN PDEVICE_OBJECT TargetDevice, + OUT PDEVICE_OBJECT *AttachedToDeviceObject); + #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ -/** Kernel debugger routines **/ +#if (NTDDI_VERSION >= NTDDI_WS03) +NTKERNELAPI +IO_PAGING_PRIORITY +FASTCALL +IoGetPagingIoPriority( + IN PIRP Irp); + +#endif /* (NTDDI_VERSION >= NTDDI_WS03) */ + +#if (NTDDI_VERSION >= NTDDI_WS03SP1) +BOOLEAN +NTAPI +IoTranslateBusAddress( + IN INTERFACE_TYPE InterfaceType, + IN ULONG BusNumber, + IN PHYSICAL_ADDRESS BusAddress, + IN OUT PULONG AddressSpace, + OUT PPHYSICAL_ADDRESS TranslatedAddress); +#endif + +#if (NTDDI_VERSION >= NTDDI_VISTA) +NTKERNELAPI +NTSTATUS +NTAPI +IoUpdateDiskGeometry( + IN PDEVICE_OBJECT DeviceObject, + IN struct _DISK_GEOMETRY_EX* OldDiskGeometry, + IN struct _DISK_GEOMETRY_EX* NewDiskGeometry); + +PTXN_PARAMETER_BLOCK +NTAPI +IoGetTransactionParameterBlock( + IN PFILE_OBJECT FileObject); + +NTKERNELAPI +NTSTATUS +NTAPI +IoCreateFileEx( + OUT PHANDLE FileHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN PLARGE_INTEGER AllocationSize OPTIONAL, + IN ULONG FileAttributes, + IN ULONG ShareAccess, + IN ULONG Disposition, + IN ULONG CreateOptions, + IN PVOID EaBuffer OPTIONAL, + IN ULONG EaLength, + IN CREATE_FILE_TYPE CreateFileType, + IN PVOID InternalParameters OPTIONAL, + IN ULONG Options, + IN PIO_DRIVER_CREATE_CONTEXT DriverContext OPTIONAL); + +NTSTATUS +NTAPI +IoSetIrpExtraCreateParameter( + IN OUT PIRP Irp, + IN struct _ECP_LIST *ExtraCreateParameter); + +VOID +NTAPI +IoClearIrpExtraCreateParameter( + IN OUT PIRP Irp); + +NTSTATUS +NTAPI +IoGetIrpExtraCreateParameter( + IN PIRP Irp, + OUT struct _ECP_LIST **ExtraCreateParameter OPTIONAL); + +BOOLEAN +NTAPI +IoIsFileObjectIgnoringSharing( + IN PFILE_OBJECT FileObject); + + +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + + +#if (NTDDI_VERSION >= NTDDI_WIN7) +NTSTATUS +NTAPI +IoSetFileObjectIgnoreSharing( + IN PFILE_OBJECT FileObject); + + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + + +/****************************************************************************** + * Kernel Debugger Functions * + ******************************************************************************/ NTSYSAPI ULONG NTAPI @@ -2406,16 +4124,26 @@ DbgPrompt( OUT PCH Response, IN ULONG MaximumResponseLength); -/* Kernel Functions */ +/****************************************************************************** + * Kernel Functions * + ******************************************************************************/ +NTKERNELAPI +VOID +FASTCALL +KeInvalidateRangeAllCaches( + IN PVOID BaseAddress, + IN ULONG Length); + #if (NTDDI_VERSION >= NTDDI_WIN2K) + NTKERNELAPI -DECLSPEC_NORETURN VOID NTAPI -KeBugCheck( - IN ULONG BugCheckCode); +KeSetImportanceDpc( + IN OUT PRKDPC Dpc, + IN KDPC_IMPORTANCE Importance); NTKERNELAPI LONG @@ -2432,24 +4160,202 @@ KeSetBasePriorityThread( IN OUT PRKTHREAD Thread, IN LONG Increment); +NTKERNELAPI +VOID +NTAPI +KeEnterCriticalRegion(VOID); + +NTKERNELAPI +VOID +NTAPI +KeLeaveCriticalRegion(VOID); + +NTKERNELAPI +DECLSPEC_NORETURN +VOID +NTAPI +KeBugCheck( + IN ULONG BugCheckCode); + + + +#if defined(SINGLE_GROUP_LEGACY_API) + + +NTKERNELAPI +VOID +NTAPI +KeSetTargetProcessorDpc( + IN OUT PRKDPC Dpc, + IN CCHAR Number); + +NTKERNELAPI +KAFFINITY +NTAPI +KeQueryActiveProcessors(VOID); + +#endif /* defined(SINGLE_GROUP_LEGACY_API) */ + + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ + +#if (NTDDI_VERSION >= NTDDI_WINXP) +NTKERNELAPI +BOOLEAN +NTAPI +KeAreApcsDisabled(VOID); + + +#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ + + +#if (NTDDI_VERSION >= NTDDI_WS03) +NTKERNELAPI +BOOLEAN +NTAPI +KeInvalidateAllCaches(VOID); + + +#endif /* (NTDDI_VERSION >= NTDDI_WS03) */ + +#if (NTDDI_VERSION >= NTDDI_WS03SP1) +NTKERNELAPI +NTSTATUS +NTAPI +KeExpandKernelStackAndCallout( + IN PEXPAND_STACK_CALLOUT Callout, + IN PVOID Parameter OPTIONAL, + IN SIZE_T Size); + +NTKERNELAPI +VOID +NTAPI +KeEnterGuardedRegion(VOID); + +NTKERNELAPI +VOID +NTAPI +KeLeaveGuardedRegion(VOID); + + +#endif /* (NTDDI_VERSION >= NTDDI_WS03SP1) */ + +#if (NTDDI_VERSION >= NTDDI_VISTA) + +#if defined(SINGLE_GROUP_LEGACY_API) +NTKERNELAPI +ULONG +NTAPI +KeQueryActiveProcessorCount( + OUT PKAFFINITY ActiveProcessors OPTIONAL); + +NTKERNELAPI +ULONG +NTAPI +KeQueryMaximumProcessorCount(VOID); + #endif -/* Memory Manager Types */ +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ -typedef struct _PHYSICAL_MEMORY_RANGE { - PHYSICAL_ADDRESS BaseAddress; - LARGE_INTEGER NumberOfBytes; -} PHYSICAL_MEMORY_RANGE, *PPHYSICAL_MEMORY_RANGE; -/* Memory Manager Functions */ +#if (NTDDI_VERSION >= NTDDI_WIN7) + +NTKERNELAPI +ULONG +NTAPI +KeQueryActiveProcessorCountEx( + IN USHORT GroupNumber); + +NTKERNELAPI +ULONG +NTAPI +KeQueryMaximumProcessorCountEx( + IN USHORT GroupNumber); + +NTKERNELAPI +USHORT +NTAPI +KeQueryActiveGroupCount(VOID); + +NTKERNELAPI +USHORT +NTAPI +KeQueryMaximumGroupCount(VOID); + +NTKERNELAPI +KAFFINITY +NTAPI +KeQueryGroupAffinity( + IN USHORT GroupNumber); + +NTKERNELAPI +ULONG +NTAPI +KeGetCurrentProcessorNumberEx( + OUT PPROCESSOR_NUMBER ProcNumber OPTIONAL); + +NTKERNELAPI +VOID +NTAPI +KeQueryNodeActiveAffinity( + IN USHORT NodeNumber, + OUT PGROUP_AFFINITY Affinity OPTIONAL, + OUT PUSHORT Count OPTIONAL); + +NTKERNELAPI +USHORT +NTAPI +KeQueryNodeMaximumProcessorCount( + IN USHORT NodeNumber); + +NTKERNELAPI +USHORT +NTAPI +KeQueryHighestNodeNumber(VOID); + +NTKERNELAPI +USHORT +NTAPI +KeGetCurrentNodeNumber(VOID); + +NTKERNELAPI +NTSTATUS +NTAPI +KeQueryLogicalProcessorRelationship( + IN PPROCESSOR_NUMBER ProcessorNumber OPTIONAL, + IN LOGICAL_PROCESSOR_RELATIONSHIP RelationshipType, + OUT PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX Information OPTIONAL, + IN OUT PULONG Length); + +NTKERNELAPI +NTSTATUS +NTAPI +KeSetHardwareCounterConfiguration( + IN PHARDWARE_COUNTER CounterArray, + IN ULONG Count); + +NTKERNELAPI +NTSTATUS +NTAPI +KeQueryHardwareCounterConfiguration( + OUT PHARDWARE_COUNTER CounterArray, + IN ULONG MaximumCount, + OUT PULONG Count); + + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + + +/****************************************************************************** + * Memory manager Functions * + ******************************************************************************/ #if (NTDDI_VERSION >= NTDDI_WIN2K) - NTKERNELAPI PPHYSICAL_MEMORY_RANGE NTAPI -MmGetPhysicalMemoryRanges( - VOID); +MmGetPhysicalMemoryRanges(VOID); NTKERNELAPI PHYSICAL_ADDRESS @@ -2523,8 +4429,7 @@ MmIsAddressValid( NTKERNELAPI BOOLEAN NTAPI -MmIsThisAnNtAsSystem( - VOID); +MmIsThisAnNtAsSystem(VOID); NTKERNELAPI VOID @@ -2572,9 +4477,144 @@ MmUnmapVideoDisplay( IN PVOID BaseAddress, IN SIZE_T NumberOfBytes); +NTKERNELAPI +NTSTATUS +NTAPI +MmAddPhysicalMemory( + IN PPHYSICAL_ADDRESS StartAddress, + IN OUT PLARGE_INTEGER NumberOfBytes); + +NTKERNELAPI +PVOID +NTAPI +MmAllocateContiguousMemory( + IN SIZE_T NumberOfBytes, + IN PHYSICAL_ADDRESS HighestAcceptableAddress); + +NTKERNELAPI +PVOID +NTAPI +MmAllocateContiguousMemorySpecifyCache( + IN SIZE_T NumberOfBytes, + IN PHYSICAL_ADDRESS LowestAcceptableAddress, + IN PHYSICAL_ADDRESS HighestAcceptableAddress, + IN PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL, + IN MEMORY_CACHING_TYPE CacheType); + +NTKERNELAPI +PVOID +NTAPI +MmAllocateContiguousMemorySpecifyCacheNode( + IN SIZE_T NumberOfBytes, + IN PHYSICAL_ADDRESS LowestAcceptableAddress, + IN PHYSICAL_ADDRESS HighestAcceptableAddress, + IN PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL, + IN MEMORY_CACHING_TYPE CacheType, + IN NODE_REQUIREMENT PreferredNode); + +NTKERNELAPI +VOID +NTAPI +MmFreeContiguousMemory( + IN PVOID BaseAddress); + +NTKERNELAPI +VOID +NTAPI +MmFreeContiguousMemorySpecifyCache( + IN PVOID BaseAddress, + IN SIZE_T NumberOfBytes, + IN MEMORY_CACHING_TYPE CacheType); + + #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ -/* NtXxx Functions */ +#if (NTDDI_VERSION >= NTDDI_WINXP) + +NTKERNELAPI +NTSTATUS +NTAPI +MmAdvanceMdl( + IN OUT PMDL Mdl, + IN ULONG NumberOfBytes); + +NTKERNELAPI +PVOID +NTAPI +MmAllocateMappingAddress( + IN SIZE_T NumberOfBytes, + IN ULONG PoolTag); + +NTKERNELAPI +VOID +NTAPI +MmFreeMappingAddress( + IN PVOID BaseAddress, + IN ULONG PoolTag); + +NTKERNELAPI +NTSTATUS +NTAPI +MmIsVerifierEnabled( + OUT PULONG VerifierFlags); + +NTKERNELAPI +PVOID +NTAPI +MmMapLockedPagesWithReservedMapping( + IN PVOID MappingAddress, + IN ULONG PoolTag, + IN PMDL MemoryDescriptorList, + IN MEMORY_CACHING_TYPE CacheType); + +NTKERNELAPI +NTSTATUS +NTAPI +MmProtectMdlSystemAddress( + IN PMDL MemoryDescriptorList, + IN ULONG NewProtect); + +NTKERNELAPI +VOID +NTAPI +MmUnmapReservedMapping( + IN PVOID BaseAddress, + IN ULONG PoolTag, + IN PMDL MemoryDescriptorList); + +NTKERNELAPI +NTSTATUS +NTAPI +MmAddVerifierThunks( + IN PVOID ThunkBuffer, + IN ULONG ThunkBufferSize); + +#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ + +#if (NTDDI_VERSION >= NTDDI_WS03) +NTKERNELAPI +NTSTATUS +NTAPI +MmCreateMirror(VOID); +#endif + + +#if (NTDDI_VERSION >= NTDDI_VISTA) +NTSTATUS +NTAPI +MmRotatePhysicalView( + IN PVOID VirtualAddress, + IN OUT PSIZE_T NumberOfBytes, + IN PMDLX NewMdl OPTIONAL, + IN MM_ROTATE_DIRECTION Direction, + IN PMM_ROTATE_COPY_CALLBACK_FUNCTION CopyFunction, + IN PVOID Context OPTIONAL); + +#endif + +/****************************************************************************** + * Process Manager Functions * + ******************************************************************************/ NTSYSCALLAPI NTSTATUS @@ -2595,35 +4635,15 @@ NtQueryInformationProcess( IN ULONG ProcessInformationLength, OUT PULONG ReturnLength OPTIONAL); -/** Process manager types **/ - -typedef VOID -(NTAPI *PCREATE_PROCESS_NOTIFY_ROUTINE)( - IN HANDLE ParentId, - IN HANDLE ProcessId, - IN BOOLEAN Create); - -typedef VOID -(NTAPI *PCREATE_THREAD_NOTIFY_ROUTINE)( - IN HANDLE ProcessId, - IN HANDLE ThreadId, - IN BOOLEAN Create); - -typedef VOID -(NTAPI *PLOAD_IMAGE_NOTIFY_ROUTINE)( - IN PUNICODE_STRING FullImageName, - IN HANDLE ProcessId, - IN PIMAGE_INFO ImageInfo); - -/** Process manager routines **/ - #if (NTDDI_VERSION >= NTDDI_WIN2K) + NTKERNELAPI NTSTATUS NTAPI -PsSetLoadImageNotifyRoutine( - IN PLOAD_IMAGE_NOTIFY_ROUTINE NotifyRoutine); +PsSetCreateProcessNotifyRoutine( + IN PCREATE_PROCESS_NOTIFY_ROUTINE NotifyRoutine, + IN BOOLEAN Remove); NTKERNELAPI NTSTATUS @@ -2634,21 +4654,18 @@ PsSetCreateThreadNotifyRoutine( NTKERNELAPI NTSTATUS NTAPI -PsSetCreateProcessNotifyRoutine( - IN PCREATE_PROCESS_NOTIFY_ROUTINE NotifyRoutine, - IN BOOLEAN Remove); +PsSetLoadImageNotifyRoutine( + IN PLOAD_IMAGE_NOTIFY_ROUTINE NotifyRoutine); NTKERNELAPI HANDLE NTAPI -PsGetCurrentProcessId( - VOID); +PsGetCurrentProcessId(VOID); NTKERNELAPI HANDLE NTAPI -PsGetCurrentThreadId( - VOID); +PsGetCurrentThreadId(VOID); NTKERNELAPI BOOLEAN @@ -2669,6 +4686,12 @@ NTAPI PsGetProcessId( IN PEPROCESS Process); +NTKERNELAPI +HANDLE +NTAPI +PsGetThreadId( + IN PETHREAD Thread); + NTKERNELAPI NTSTATUS NTAPI @@ -2681,102 +4704,187 @@ NTAPI PsRemoveLoadImageNotifyRoutine( IN PLOAD_IMAGE_NOTIFY_ROUTINE NotifyRoutine); +NTKERNELAPI +LONGLONG +NTAPI +PsGetProcessCreateTimeQuadPart( + IN PEPROCESS Process); + #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ -extern NTKERNELAPI PEPROCESS PsInitialSystemProcess; +#if (NTDDI_VERSION >= NTDDI_WS03) +NTKERNELAPI +HANDLE +NTAPI +PsGetThreadProcessId( + IN PETHREAD Thread); +#endif /* (NTDDI_VERSION >= NTDDI_WS03) */ -/* RTL Types */ +#if (NTDDI_VERSION >= NTDDI_VISTA) -typedef struct _RTL_SPLAY_LINKS { - struct _RTL_SPLAY_LINKS *Parent; - struct _RTL_SPLAY_LINKS *LeftChild; - struct _RTL_SPLAY_LINKS *RightChild; -} RTL_SPLAY_LINKS, *PRTL_SPLAY_LINKS; +NTKERNELAPI +BOOLEAN +NTAPI +PsSetCurrentThreadPrefetching( + IN BOOLEAN Prefetching); -/* RTL Functions */ +NTKERNELAPI +BOOLEAN +NTAPI +PsIsCurrentThreadPrefetching(VOID); -#if (defined(_M_AMD64) || defined(_M_IA64)) && !defined(_REALLY_GET_CALLERS_CALLER_) +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ -#define RtlGetCallersAddress(CallersAddress, CallersCaller) \ - *CallersAddress = (PVOID)_ReturnAddress(); \ - *CallersCaller = NULL; -#else +#if (NTDDI_VERSION >= NTDDI_VISTASP1) +NTKERNELAPI +NTSTATUS +NTAPI +PsSetCreateProcessNotifyRoutineEx( + IN PCREATE_PROCESS_NOTIFY_ROUTINE_EX NotifyRoutine, + IN BOOLEAN Remove); +#endif /* (NTDDI_VERSION >= NTDDI_VISTASP1) */ +/****************************************************************************** + * Runtime Library Functions * + ******************************************************************************/ #if (NTDDI_VERSION >= NTDDI_WIN2K) + + + +#ifndef RTL_USE_AVL_TABLES + NTSYSAPI VOID NTAPI -RtlGetCallersAddress( - OUT PVOID *CallersAddress, - OUT PVOID *CallersCaller); -#endif +RtlInitializeGenericTable( + OUT PRTL_GENERIC_TABLE Table, + IN PRTL_GENERIC_COMPARE_ROUTINE CompareRoutine, + IN PRTL_GENERIC_ALLOCATE_ROUTINE AllocateRoutine, + IN PRTL_GENERIC_FREE_ROUTINE FreeRoutine, + IN PVOID TableContext OPTIONAL); -#endif - -#if !defined(MIDL_PASS) - -FORCEINLINE -LUID -NTAPI_INLINE -RtlConvertLongToLuid( - IN LONG Val) -{ - LUID Luid; - LARGE_INTEGER Temp; - - Temp.QuadPart = Val; - Luid.LowPart = Temp.u.LowPart; - Luid.HighPart = Temp.u.HighPart; - return Luid; -} - -FORCEINLINE -LUID -NTAPI_INLINE -RtlConvertUlongToLuid( - IN ULONG Val) -{ - LUID Luid; - - Luid.LowPart = Val; - Luid.HighPart = 0; - return Luid; -} - -#endif - -#if defined(_AMD64_) || defined(_IA64_) -//DECLSPEC_DEPRECATED_DDK_WINXP -__inline -LARGE_INTEGER -NTAPI_INLINE -RtlLargeIntegerDivide( - IN LARGE_INTEGER Dividend, - IN LARGE_INTEGER Divisor, - OUT PLARGE_INTEGER Remainder OPTIONAL) -{ - LARGE_INTEGER ret; - ret.QuadPart = Dividend.QuadPart / Divisor.QuadPart; - if (Remainder) - Remainder->QuadPart = Dividend.QuadPart % Divisor.QuadPart; - return ret; -} - -#else - -#if (NTDDI_VERSION >= NTDDI_WIN2K) NTSYSAPI -LARGE_INTEGER +PVOID NTAPI -RtlLargeIntegerDivide( - IN LARGE_INTEGER Dividend, - IN LARGE_INTEGER Divisor, - OUT PLARGE_INTEGER Remainder OPTIONAL); -#endif +RtlInsertElementGenericTable( + IN PRTL_GENERIC_TABLE Table, + IN PVOID Buffer, + IN CLONG BufferSize, + OUT PBOOLEAN NewElement OPTIONAL); -#endif /* defined(_AMD64_) || defined(_IA64_) */ +NTSYSAPI +PVOID +NTAPI +RtlInsertElementGenericTableFull( + IN PRTL_GENERIC_TABLE Table, + IN PVOID Buffer, + IN CLONG BufferSize, + OUT PBOOLEAN NewElement OPTIONAL, + IN PVOID NodeOrParent, + IN TABLE_SEARCH_RESULT SearchResult); -#if (NTDDI_VERSION >= NTDDI_WIN2K) +NTSYSAPI +BOOLEAN +NTAPI +RtlDeleteElementGenericTable( + IN PRTL_GENERIC_TABLE Table, + IN PVOID Buffer); + +NTSYSAPI +PVOID +NTAPI +RtlLookupElementGenericTable( + IN PRTL_GENERIC_TABLE Table, + IN PVOID Buffer); + +NTSYSAPI +PVOID +NTAPI +RtlLookupElementGenericTableFull( + IN PRTL_GENERIC_TABLE Table, + IN PVOID Buffer, + OUT PVOID *NodeOrParent, + OUT TABLE_SEARCH_RESULT *SearchResult); + +NTSYSAPI +PVOID +NTAPI +RtlEnumerateGenericTable( + IN PRTL_GENERIC_TABLE Table, + IN BOOLEAN Restart); + +NTSYSAPI +PVOID +NTAPI +RtlEnumerateGenericTableWithoutSplaying( + IN PRTL_GENERIC_TABLE Table, + IN OUT PVOID *RestartKey); + +NTSYSAPI +PVOID +NTAPI +RtlGetElementGenericTable( + IN PRTL_GENERIC_TABLE Table, + IN ULONG I); + +NTSYSAPI +ULONG +NTAPI +RtlNumberGenericTableElements( + IN PRTL_GENERIC_TABLE Table); + +NTSYSAPI +BOOLEAN +NTAPI +RtlIsGenericTableEmpty( + IN PRTL_GENERIC_TABLE Table); + +#endif /* !RTL_USE_AVL_TABLES */ + +#define RTL_STACK_WALKING_MODE_FRAMES_TO_SKIP_SHIFT 8 + +NTSYSAPI +PRTL_SPLAY_LINKS +NTAPI +RtlSplay( + IN OUT PRTL_SPLAY_LINKS Links); + +NTSYSAPI +PRTL_SPLAY_LINKS +NTAPI +RtlDelete( + IN PRTL_SPLAY_LINKS Links); + +NTSYSAPI +VOID +NTAPI +RtlDeleteNoSplay( + IN PRTL_SPLAY_LINKS Links, + IN OUT PRTL_SPLAY_LINKS *Root); + +NTSYSAPI +PRTL_SPLAY_LINKS +NTAPI +RtlSubtreeSuccessor( + IN PRTL_SPLAY_LINKS Links); + +NTSYSAPI +PRTL_SPLAY_LINKS +NTAPI +RtlSubtreePredecessor( + IN PRTL_SPLAY_LINKS Links); + +NTSYSAPI +PRTL_SPLAY_LINKS +NTAPI +RtlRealSuccessor( + IN PRTL_SPLAY_LINKS Links); + +NTSYSAPI +PRTL_SPLAY_LINKS +NTAPI +RtlRealPredecessor( + IN PRTL_SPLAY_LINKS Links); NTSYSAPI BOOLEAN @@ -2835,7 +4943,7 @@ NTAPI RtlCompareString( IN const PSTRING String1, IN const PSTRING String2, - BOOLEAN CaseInSensitive); + IN BOOLEAN CaseInSensitive); NTSYSAPI VOID @@ -2874,9 +4982,513 @@ RtlWalkFrameChain( IN ULONG Count, IN ULONG Flags); + + #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ -/* Security reference monitor routines */ + +#if (NTDDI_VERSION >= NTDDI_WINXP) + + +NTSYSAPI +VOID +NTAPI +RtlInitializeGenericTableAvl( + OUT PRTL_AVL_TABLE Table, + IN PRTL_AVL_COMPARE_ROUTINE CompareRoutine, + IN PRTL_AVL_ALLOCATE_ROUTINE AllocateRoutine, + IN PRTL_AVL_FREE_ROUTINE FreeRoutine, + IN PVOID TableContext OPTIONAL); + +NTSYSAPI +PVOID +NTAPI +RtlInsertElementGenericTableAvl( + IN PRTL_AVL_TABLE Table, + IN PVOID Buffer, + IN CLONG BufferSize, + OUT PBOOLEAN NewElement OPTIONAL); + +NTSYSAPI +PVOID +NTAPI +RtlInsertElementGenericTableFullAvl( + IN PRTL_AVL_TABLE Table, + IN PVOID Buffer, + IN CLONG BufferSize, + OUT PBOOLEAN NewElement OPTIONAL, + IN PVOID NodeOrParent, + IN TABLE_SEARCH_RESULT SearchResult); + +NTSYSAPI +BOOLEAN +NTAPI +RtlDeleteElementGenericTableAvl( + IN PRTL_AVL_TABLE Table, + IN PVOID Buffer); + +NTSYSAPI +PVOID +NTAPI +RtlLookupElementGenericTableAvl( + IN PRTL_AVL_TABLE Table, + IN PVOID Buffer); + +NTSYSAPI +PVOID +NTAPI +RtlLookupElementGenericTableFullAvl( + IN PRTL_AVL_TABLE Table, + IN PVOID Buffer, + OUT PVOID *NodeOrParent, + OUT TABLE_SEARCH_RESULT *SearchResult); + +NTSYSAPI +PVOID +NTAPI +RtlEnumerateGenericTableAvl( + IN PRTL_AVL_TABLE Table, + IN BOOLEAN Restart); + +NTSYSAPI +PVOID +NTAPI +RtlEnumerateGenericTableWithoutSplayingAvl( + IN PRTL_AVL_TABLE Table, + IN OUT PVOID *RestartKey); + +NTSYSAPI +PVOID +NTAPI +RtlLookupFirstMatchingElementGenericTableAvl( + IN PRTL_AVL_TABLE Table, + IN PVOID Buffer, + OUT PVOID *RestartKey); + +NTSYSAPI +PVOID +NTAPI +RtlEnumerateGenericTableLikeADirectory( + IN PRTL_AVL_TABLE Table, + IN PRTL_AVL_MATCH_FUNCTION MatchFunction OPTIONAL, + IN PVOID MatchData OPTIONAL, + IN ULONG NextFlag, + IN OUT PVOID *RestartKey, + IN OUT PULONG DeleteCount, + IN PVOID Buffer); + +NTSYSAPI +PVOID +NTAPI +RtlGetElementGenericTableAvl( + IN PRTL_AVL_TABLE Table, + IN ULONG I); + +NTSYSAPI +ULONG +NTAPI +RtlNumberGenericTableElementsAvl( + IN PRTL_AVL_TABLE Table); + +NTSYSAPI +BOOLEAN +NTAPI +RtlIsGenericTableEmptyAvl( + IN PRTL_AVL_TABLE Table); + + + +#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ + +#if (NTDDI_VERSION >= NTDDI_VISTA) + + +NTSYSAPI +VOID +NTAPI +RtlRunOnceInitialize( + OUT PRTL_RUN_ONCE RunOnce); + +NTSYSAPI +NTSTATUS +NTAPI +RtlRunOnceExecuteOnce( + IN OUT PRTL_RUN_ONCE RunOnce, + IN PRTL_RUN_ONCE_INIT_FN InitFn, + IN OUT PVOID Parameter OPTIONAL, + OUT PVOID *Context OPTIONAL); + +NTSYSAPI +NTSTATUS +NTAPI +RtlRunOnceBeginInitialize( + IN OUT PRTL_RUN_ONCE RunOnce, + IN ULONG Flags, + OUT PVOID *Context OPTIONAL); + +NTSYSAPI +NTSTATUS +NTAPI +RtlRunOnceComplete( + IN OUT PRTL_RUN_ONCE RunOnce, + IN ULONG Flags, + IN PVOID Context OPTIONAL); + +NTSYSAPI +BOOLEAN +NTAPI +RtlGetProductInfo( + IN ULONG OSMajorVersion, + IN ULONG OSMinorVersion, + IN ULONG SpMajorVersion, + IN ULONG SpMinorVersion, + OUT PULONG ReturnedProductType); + + + +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + +#if (NTDDI_VERSION >= NTDDI_WIN7) + + +NTSYSAPI +BOOLEAN +NTAPI +RtlCreateHashTable( + IN OUT PRTL_DYNAMIC_HASH_TABLE *HashTable OPTIONAL, + IN ULONG Shift, + IN ULONG Flags); + +NTSYSAPI +VOID +NTAPI +RtlDeleteHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable); + +NTSYSAPI +BOOLEAN +NTAPI +RtlInsertEntryHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable, + IN PRTL_DYNAMIC_HASH_TABLE_ENTRY Entry, + IN ULONG_PTR Signature, + IN OUT PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context OPTIONAL); + +NTSYSAPI +BOOLEAN +NTAPI +RtlRemoveEntryHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable, + IN PRTL_DYNAMIC_HASH_TABLE_ENTRY Entry, + IN OUT PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context OPTIONAL); + +NTSYSAPI +PRTL_DYNAMIC_HASH_TABLE_ENTRY +NTAPI +RtlLookupEntryHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable, + IN ULONG_PTR Signature, + OUT PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context OPTIONAL); + +NTSYSAPI +PRTL_DYNAMIC_HASH_TABLE_ENTRY +NTAPI +RtlGetNextEntryHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable, + IN PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context); + +NTSYSAPI +BOOLEAN +NTAPI +RtlInitEnumerationHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable, + OUT PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator); + +NTSYSAPI +PRTL_DYNAMIC_HASH_TABLE_ENTRY +NTAPI +RtlEnumerateEntryHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable, + IN OUT PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator); + +NTSYSAPI +VOID +NTAPI +RtlEndEnumerationHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable, + IN OUT PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator); + +NTSYSAPI +BOOLEAN +NTAPI +RtlInitWeakEnumerationHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable, + OUT PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator); + +NTSYSAPI +PRTL_DYNAMIC_HASH_TABLE_ENTRY +NTAPI +RtlWeaklyEnumerateEntryHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable, + IN OUT PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator); + +NTSYSAPI +VOID +NTAPI +RtlEndWeakEnumerationHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable, + IN OUT PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator); + +NTSYSAPI +BOOLEAN +NTAPI +RtlExpandHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable); + +NTSYSAPI +BOOLEAN +NTAPI +RtlContractHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable); + + + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + + +#if defined(_AMD64_) || defined(_IA64_) + + + +//DECLSPEC_DEPRECATED_DDK_WINXP +FORCEINLINE +LARGE_INTEGER +NTAPI_INLINE +RtlLargeIntegerDivide( + IN LARGE_INTEGER Dividend, + IN LARGE_INTEGER Divisor, + OUT PLARGE_INTEGER Remainder OPTIONAL) +{ + LARGE_INTEGER ret; + ret.QuadPart = Dividend.QuadPart / Divisor.QuadPart; + if (Remainder) + Remainder->QuadPart = Dividend.QuadPart % Divisor.QuadPart; + return ret; +} + +#else + +#if (NTDDI_VERSION >= NTDDI_WIN2K) +NTSYSAPI +LARGE_INTEGER +NTAPI +RtlLargeIntegerDivide( + IN LARGE_INTEGER Dividend, + IN LARGE_INTEGER Divisor, + OUT PLARGE_INTEGER Remainder OPTIONAL); +#endif + + +#endif /* defined(_AMD64_) || defined(_IA64_) */ + + + +#ifdef RTL_USE_AVL_TABLES + +#define RtlInitializeGenericTable RtlInitializeGenericTableAvl +#define RtlInsertElementGenericTable RtlInsertElementGenericTableAvl +#define RtlInsertElementGenericTableFull RtlInsertElementGenericTableFullAvl +#define RtlDeleteElementGenericTable RtlDeleteElementGenericTableAvl +#define RtlLookupElementGenericTable RtlLookupElementGenericTableAvl +#define RtlLookupElementGenericTableFull RtlLookupElementGenericTableFullAvl +#define RtlEnumerateGenericTable RtlEnumerateGenericTableAvl +#define RtlEnumerateGenericTableWithoutSplaying RtlEnumerateGenericTableWithoutSplayingAvl +#define RtlGetElementGenericTable RtlGetElementGenericTableAvl +#define RtlNumberGenericTableElements RtlNumberGenericTableElementsAvl +#define RtlIsGenericTableEmpty RtlIsGenericTableEmptyAvl + +#endif /* RTL_USE_AVL_TABLES */ + +#define RtlInitializeSplayLinks(Links) { \ + PRTL_SPLAY_LINKS _SplayLinks; \ + _SplayLinks = (PRTL_SPLAY_LINKS)(Links); \ + _SplayLinks->Parent = _SplayLinks; \ + _SplayLinks->LeftChild = NULL; \ + _SplayLinks->RightChild = NULL; \ +} + +#define RtlIsLeftChild(Links) \ + (RtlLeftChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links)) + +#define RtlIsRightChild(Links) \ + (RtlRightChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links)) + +#define RtlRightChild(Links) \ + ((PRTL_SPLAY_LINKS)(Links))->RightChild + +#define RtlIsRoot(Links) \ + (RtlParent(Links) == (PRTL_SPLAY_LINKS)(Links)) + +#define RtlLeftChild(Links) \ + ((PRTL_SPLAY_LINKS)(Links))->LeftChild + +#define RtlParent(Links) \ + ((PRTL_SPLAY_LINKS)(Links))->Parent + +#define RtlInsertAsLeftChild(ParentLinks,ChildLinks) \ + { \ + PRTL_SPLAY_LINKS _SplayParent; \ + PRTL_SPLAY_LINKS _SplayChild; \ + _SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \ + _SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks); \ + _SplayParent->LeftChild = _SplayChild; \ + _SplayChild->Parent = _SplayParent; \ + } + +#define RtlInsertAsRightChild(ParentLinks,ChildLinks) \ + { \ + PRTL_SPLAY_LINKS _SplayParent; \ + PRTL_SPLAY_LINKS _SplayChild; \ + _SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \ + _SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks); \ + _SplayParent->RightChild = _SplayChild; \ + _SplayChild->Parent = _SplayParent; \ + } + +#if !defined(MIDL_PASS) + +FORCEINLINE +LUID +NTAPI_INLINE +RtlConvertLongToLuid( + IN LONG Val) +{ + LUID Luid; + LARGE_INTEGER Temp; + + Temp.QuadPart = Val; + Luid.LowPart = Temp.u.LowPart; + Luid.HighPart = Temp.u.HighPart; + return Luid; +} + +FORCEINLINE +LUID +NTAPI_INLINE +RtlConvertUlongToLuid( + IN ULONG Val) +{ + LUID Luid; + + Luid.LowPart = Val; + Luid.HighPart = 0; + return Luid; +} + +#endif /* !defined(MIDL_PASS) */ + +#if (defined(_M_AMD64) || defined(_M_IA64)) && !defined(_REALLY_GET_CALLERS_CALLER_) +#define RtlGetCallersAddress(CallersAddress, CallersCaller) \ + *CallersAddress = (PVOID)_ReturnAddress(); \ + *CallersCaller = NULL; +#else +#if (NTDDI_VERSION >= NTDDI_WIN2K) +NTSYSAPI +VOID +NTAPI +RtlGetCallersAddress( + OUT PVOID *CallersAddress, + OUT PVOID *CallersCaller); +#endif +#endif + +#if !defined(MIDL_PASS) && !defined(SORTPP_PASS) + +#if (NTDDI_VERSION >= NTDDI_WIN7) + +FORCEINLINE +VOID +NTAPI +RtlInitHashTableContext( + IN OUT PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context) +{ + Context->ChainHead = NULL; + Context->PrevLinkage = NULL; +} + +FORCEINLINE +VOID +NTAPI +RtlInitHashTableContextFromEnumerator( + IN OUT PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context, + IN PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator) +{ + Context->ChainHead = Enumerator->ChainHead; + Context->PrevLinkage = Enumerator->HashEntry.Linkage.Blink; +} + +FORCEINLINE +VOID +NTAPI +RtlReleaseHashTableContext( + IN OUT PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context) +{ + UNREFERENCED_PARAMETER(Context); + return; +} + +FORCEINLINE +ULONG +NTAPI +RtlTotalBucketsHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable) +{ + return HashTable->TableSize; +} + +FORCEINLINE +ULONG +NTAPI +RtlNonEmptyBucketsHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable) +{ + return HashTable->NonEmptyBuckets; +} + +FORCEINLINE +ULONG +NTAPI +RtlEmptyBucketsHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable) +{ + return HashTable->TableSize - HashTable->NonEmptyBuckets; +} + +FORCEINLINE +ULONG +NTAPI +RtlTotalEntriesHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable) +{ + return HashTable->NumEntries; +} + +FORCEINLINE +ULONG +NTAPI +RtlActiveEnumeratorsHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable) +{ + return HashTable->NumEnumerators; +} + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + +#endif /* !defined(MIDL_PASS) && !defined(SORTPP_PASS) */ + +/****************************************************************************** + * Security Manager Functions * + ******************************************************************************/ #if (NTDDI_VERSION >= NTDDI_WIN2K) NTKERNELAPI @@ -2885,12 +5497,42 @@ NTAPI SeSinglePrivilegeCheck( IN LUID PrivilegeValue, IN KPROCESSOR_MODE PreviousMode); -#endif -/* ZwXxx Functions */ + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ + +/****************************************************************************** + * ZwXxx Functions * + ******************************************************************************/ + + + +NTSYSAPI +NTSTATUS +NTAPI +ZwAllocateLocallyUniqueId( + OUT PLUID Luid); + +NTSYSAPI +NTSTATUS +NTAPI +ZwTerminateProcess( + IN HANDLE ProcessHandle OPTIONAL, + IN NTSTATUS ExitStatus); + +NTSYSAPI +NTSTATUS +NTAPI +ZwOpenProcess( + OUT PHANDLE ProcessHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN PCLIENT_ID ClientId OPTIONAL); + #if (NTDDI_VERSION >= NTDDI_WIN2K) + NTSTATUS NTAPI ZwCancelTimer( @@ -2932,12 +5574,190 @@ ZwSetTimer( IN LONG Period OPTIONAL, OUT PBOOLEAN PreviousState OPTIONAL); +NTSYSAPI +NTSTATUS +NTAPI +ZwDisplayString( + IN PUNICODE_STRING String); + +NTSYSAPI +NTSTATUS +NTAPI +ZwPowerInformation( + IN POWER_INFORMATION_LEVEL PowerInformationLevel, + IN PVOID InputBuffer OPTIONAL, + IN ULONG InputBufferLength, + OUT PVOID OutputBuffer OPTIONAL, + IN ULONG OutputBufferLength); + +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryVolumeInformationFile( + IN HANDLE FileHandle, + OUT PIO_STATUS_BLOCK IoStatusBlock, + OUT PVOID FsInformation, + IN ULONG Length, + IN FS_INFORMATION_CLASS FsInformationClass); + +NTSYSAPI +NTSTATUS +NTAPI +ZwDeviceIoControlFile( + IN HANDLE FileHandle, + IN HANDLE Event OPTIONAL, + IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, + IN PVOID ApcContext OPTIONAL, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN ULONG IoControlCode, + IN PVOID InputBuffer OPTIONAL, + IN ULONG InputBufferLength, + OUT PVOID OutputBuffer OPTIONAL, + IN ULONG OutputBufferLength); + + + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ + + +#if (NTDDI_VERSION >= NTDDI_WIN7) + +NTSTATUS +NTAPI +ZwSetTimerEx( + IN HANDLE TimerHandle, + IN TIMER_SET_INFORMATION_CLASS TimerSetInformationClass, + IN OUT PVOID TimerSetInformation, + IN ULONG TimerSetInformationLength); + + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + + + +/* UNSORTED */ + +#define VER_SET_CONDITION(ConditionMask, TypeBitMask, ComparisonType) \ + ((ConditionMask) = VerSetConditionMask((ConditionMask), \ + (TypeBitMask), (ComparisonType))) + +#if (NTDDI_VERSION >= NTDDI_WIN2K) +NTSYSAPI +ULONGLONG +NTAPI +VerSetConditionMask( + IN ULONGLONG ConditionMask, + IN ULONG TypeMask, + IN UCHAR Condition); #endif +typedef struct _KERNEL_USER_TIMES { + LARGE_INTEGER CreateTime; + LARGE_INTEGER ExitTime; + LARGE_INTEGER KernelTime; + LARGE_INTEGER UserTime; +} KERNEL_USER_TIMES, *PKERNEL_USER_TIMES; + +/* NtXxx Functions */ + +typedef enum _SYSTEM_FIRMWARE_TABLE_ACTION { + SystemFirmwareTable_Enumerate, + SystemFirmwareTable_Get +} SYSTEM_FIRMWARE_TABLE_ACTION; + +typedef struct _SYSTEM_FIRMWARE_TABLE_INFORMATION { + ULONG ProviderSignature; + SYSTEM_FIRMWARE_TABLE_ACTION Action; + ULONG TableID; + ULONG TableBufferLength; + UCHAR TableBuffer[ANYSIZE_ARRAY]; +} SYSTEM_FIRMWARE_TABLE_INFORMATION, *PSYSTEM_FIRMWARE_TABLE_INFORMATION; + +typedef NTSTATUS +(__cdecl *PFNFTH)( + IN OUT PSYSTEM_FIRMWARE_TABLE_INFORMATION SystemFirmwareTableInfo); + +typedef struct _SYSTEM_FIRMWARE_TABLE_HANDLER { + ULONG ProviderSignature; + BOOLEAN Register; + PFNFTH FirmwareTableHandler; + PVOID DriverObject; +} SYSTEM_FIRMWARE_TABLE_HANDLER, *PSYSTEM_FIRMWARE_TABLE_HANDLER; + +typedef ULONG_PTR +(NTAPI *PDRIVER_VERIFIER_THUNK_ROUTINE)( + IN PVOID Context); + +typedef struct _DRIVER_VERIFIER_THUNK_PAIRS { + PDRIVER_VERIFIER_THUNK_ROUTINE PristineRoutine; + PDRIVER_VERIFIER_THUNK_ROUTINE NewRoutine; +} DRIVER_VERIFIER_THUNK_PAIRS, *PDRIVER_VERIFIER_THUNK_PAIRS; + +#define DRIVER_VERIFIER_SPECIAL_POOLING 0x0001 +#define DRIVER_VERIFIER_FORCE_IRQL_CHECKING 0x0002 +#define DRIVER_VERIFIER_INJECT_ALLOCATION_FAILURES 0x0004 +#define DRIVER_VERIFIER_TRACK_POOL_ALLOCATIONS 0x0008 +#define DRIVER_VERIFIER_IO_CHECKING 0x0010 + +#define SHARED_GLOBAL_FLAGS_ERROR_PORT_V 0x0 +#define SHARED_GLOBAL_FLAGS_ERROR_PORT (1UL << SHARED_GLOBAL_FLAGS_ERROR_PORT_V) + +#define SHARED_GLOBAL_FLAGS_ELEVATION_ENABLED_V 0x1 +#define SHARED_GLOBAL_FLAGS_ELEVATION_ENABLED (1UL << SHARED_GLOBAL_FLAGS_ELEVATION_ENABLED_V) + +#define SHARED_GLOBAL_FLAGS_VIRT_ENABLED_V 0x2 +#define SHARED_GLOBAL_FLAGS_VIRT_ENABLED (1UL << SHARED_GLOBAL_FLAGS_VIRT_ENABLED_V) + +#define SHARED_GLOBAL_FLAGS_INSTALLER_DETECT_ENABLED_V 0x3 +#define SHARED_GLOBAL_FLAGS_INSTALLER_DETECT_ENABLED \ + (1UL << SHARED_GLOBAL_FLAGS_INSTALLER_DETECT_ENABLED_V) + +#define SHARED_GLOBAL_FLAGS_SPARE_V 0x4 +#define SHARED_GLOBAL_FLAGS_SPARE \ + (1UL << SHARED_GLOBAL_FLAGS_SPARE_V) + +#define SHARED_GLOBAL_FLAGS_DYNAMIC_PROC_ENABLED_V 0x5 +#define SHARED_GLOBAL_FLAGS_DYNAMIC_PROC_ENABLED \ + (1UL << SHARED_GLOBAL_FLAGS_DYNAMIC_PROC_ENABLED_V) + +#define SHARED_GLOBAL_FLAGS_SEH_VALIDATION_ENABLED_V 0x6 +#define SHARED_GLOBAL_FLAGS_SEH_VALIDATION_ENABLED \ + (1UL << SHARED_GLOBAL_FLAGS_SEH_VALIDATION_ENABLED_V) + +#define EX_INIT_BITS(Flags, Bit) \ + *((Flags)) |= (Bit) // Safe to use before concurrently accessible + +#define EX_TEST_SET_BIT(Flags, Bit) \ + InterlockedBitTestAndSet ((PLONG)(Flags), (Bit)) + +#define EX_TEST_CLEAR_BIT(Flags, Bit) \ + InterlockedBitTestAndReset ((PLONG)(Flags), (Bit)) + +#define PCCARD_MAP_ERROR 0x01 +#define PCCARD_DEVICE_PCI 0x10 + +#define PCCARD_SCAN_DISABLED 0x01 +#define PCCARD_MAP_ZERO 0x02 +#define PCCARD_NO_TIMER 0x03 +#define PCCARD_NO_PIC 0x04 +#define PCCARD_NO_LEGACY_BASE 0x05 +#define PCCARD_DUP_LEGACY_BASE 0x06 +#define PCCARD_NO_CONTROLLERS 0x07 + +#define MAXIMUM_EXPANSION_SIZE (KERNEL_LARGE_STACK_SIZE - (PAGE_SIZE / 2)) + +/* Filesystem runtime library routines */ + +#if (NTDDI_VERSION >= NTDDI_WIN2K) +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlIsTotalDeviceFailure( + IN NTSTATUS Status); +#endif + +/* FIXME : These definitions below doesn't belong to NTDDK */ #ifdef __cplusplus } #endif - - -#endif /* _NTDDK_ */ diff --git a/reactos/include/ddk/ntifs.h b/reactos/include/ddk/ntifs.h index 5f032726d38..1122e7fcc48 100644 --- a/reactos/include/ddk/ntifs.h +++ b/reactos/include/ddk/ntifs.h @@ -25,32 +25,10 @@ #define _NTIFS_INCLUDED_ #define _GNU_NTIFS_ -/* Helper macro to enable gcc's extension. */ -#ifndef __GNU_EXTENSION -#ifdef __GNUC__ -#define __GNU_EXTENSION __extension__ -#else -#define __GNU_EXTENSION -#endif -#endif - #ifdef __cplusplus extern "C" { #endif -#if !defined(_NTHALDLL_) && !defined(_BLDR_) -#define NTHALAPI DECLSPEC_IMPORT -#else -#define NTHALAPI -#endif - -/* For ReactOS */ -#if !defined(_NTOSKRNL_) && !defined(_BLDR_) -#define NTKERNELAPI DECLSPEC_IMPORT -#else -#define NTKERNELAPI -#endif - /* Dependencies */ #include #include @@ -76,16 +54,6 @@ extern "C" { #define ClearFlag(_F,_SF) ((_F) &= ~(_SF)) #endif -#define PsGetCurrentProcess IoGetCurrentProcess - -#if (NTDDI_VERSION >= NTDDI_VISTA) -extern NTSYSAPI volatile CCHAR KeNumberProcessors; -#elif (NTDDI_VERSION >= NTDDI_WINXP) -extern NTSYSAPI CCHAR KeNumberProcessors; -#else -extern PCCHAR KeNumberProcessors; -#endif - typedef UNICODE_STRING LSA_UNICODE_STRING, *PLSA_UNICODE_STRING; typedef STRING LSA_STRING, *PLSA_STRING; typedef OBJECT_ATTRIBUTES LSA_OBJECT_ATTRIBUTES, *PLSA_OBJECT_ATTRIBUTES; @@ -751,8 +719,6 @@ typedef enum _OBJECT_INFORMATION_CLASS { MaxObjectInfoClass /* FIXME, not in WDK */ } OBJECT_INFORMATION_CLASS; -#if (NTDDI_VERSION >= NTDDI_NT4) - NTSYSCALLAPI NTSTATUS NTAPI @@ -763,8 +729,6 @@ NtQueryObject( IN ULONG ObjectInformationLength, OUT PULONG ReturnLength OPTIONAL); -#endif - #if (NTDDI_VERSION >= NTDDI_WIN2K) NTSYSCALLAPI @@ -2414,95 +2378,11 @@ extern const PRTL_REALLOCATE_STRING_ROUTINE RtlReallocateStringRoutine; #define RTL_SYSTEM_VOLUME_INFORMATION_FOLDER L"System Volume Information" -#define DEVICE_TYPE ULONG - -#define FILE_DEVICE_BEEP 0x00000001 -#define FILE_DEVICE_CD_ROM 0x00000002 -#define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003 -#define FILE_DEVICE_CONTROLLER 0x00000004 -#define FILE_DEVICE_DATALINK 0x00000005 -#define FILE_DEVICE_DFS 0x00000006 -#define FILE_DEVICE_DISK 0x00000007 -#define FILE_DEVICE_DISK_FILE_SYSTEM 0x00000008 -#define FILE_DEVICE_FILE_SYSTEM 0x00000009 -#define FILE_DEVICE_INPORT_PORT 0x0000000a -#define FILE_DEVICE_KEYBOARD 0x0000000b -#define FILE_DEVICE_MAILSLOT 0x0000000c -#define FILE_DEVICE_MIDI_IN 0x0000000d -#define FILE_DEVICE_MIDI_OUT 0x0000000e -#define FILE_DEVICE_MOUSE 0x0000000f -#define FILE_DEVICE_MULTI_UNC_PROVIDER 0x00000010 -#define FILE_DEVICE_NAMED_PIPE 0x00000011 -#define FILE_DEVICE_NETWORK 0x00000012 -#define FILE_DEVICE_NETWORK_BROWSER 0x00000013 -#define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014 -#define FILE_DEVICE_NULL 0x00000015 -#define FILE_DEVICE_PARALLEL_PORT 0x00000016 -#define FILE_DEVICE_PHYSICAL_NETCARD 0x00000017 -#define FILE_DEVICE_PRINTER 0x00000018 -#define FILE_DEVICE_SCANNER 0x00000019 -#define FILE_DEVICE_SERIAL_MOUSE_PORT 0x0000001a -#define FILE_DEVICE_SERIAL_PORT 0x0000001b -#define FILE_DEVICE_SCREEN 0x0000001c -#define FILE_DEVICE_SOUND 0x0000001d -#define FILE_DEVICE_STREAMS 0x0000001e -#define FILE_DEVICE_TAPE 0x0000001f -#define FILE_DEVICE_TAPE_FILE_SYSTEM 0x00000020 -#define FILE_DEVICE_TRANSPORT 0x00000021 -#define FILE_DEVICE_UNKNOWN 0x00000022 -#define FILE_DEVICE_VIDEO 0x00000023 -#define FILE_DEVICE_VIRTUAL_DISK 0x00000024 -#define FILE_DEVICE_WAVE_IN 0x00000025 -#define FILE_DEVICE_WAVE_OUT 0x00000026 -#define FILE_DEVICE_8042_PORT 0x00000027 -#define FILE_DEVICE_NETWORK_REDIRECTOR 0x00000028 -#define FILE_DEVICE_BATTERY 0x00000029 -#define FILE_DEVICE_BUS_EXTENDER 0x0000002a -#define FILE_DEVICE_MODEM 0x0000002b -#define FILE_DEVICE_VDM 0x0000002c -#define FILE_DEVICE_MASS_STORAGE 0x0000002d -#define FILE_DEVICE_SMB 0x0000002e -#define FILE_DEVICE_KS 0x0000002f -#define FILE_DEVICE_CHANGER 0x00000030 -#define FILE_DEVICE_SMARTCARD 0x00000031 -#define FILE_DEVICE_ACPI 0x00000032 -#define FILE_DEVICE_DVD 0x00000033 -#define FILE_DEVICE_FULLSCREEN_VIDEO 0x00000034 -#define FILE_DEVICE_DFS_FILE_SYSTEM 0x00000035 -#define FILE_DEVICE_DFS_VOLUME 0x00000036 -#define FILE_DEVICE_SERENUM 0x00000037 -#define FILE_DEVICE_TERMSRV 0x00000038 -#define FILE_DEVICE_KSEC 0x00000039 -#define FILE_DEVICE_FIPS 0x0000003A -#define FILE_DEVICE_INFINIBAND 0x0000003B -#define FILE_DEVICE_VMBUS 0x0000003E -#define FILE_DEVICE_CRYPT_PROVIDER 0x0000003F -#define FILE_DEVICE_WPD 0x00000040 -#define FILE_DEVICE_BLUETOOTH 0x00000041 -#define FILE_DEVICE_MT_COMPOSITE 0x00000042 -#define FILE_DEVICE_MT_TRANSPORT 0x00000043 -#define FILE_DEVICE_BIOMETRIC 0x00000044 -#define FILE_DEVICE_PMI 0x00000045 - -#define CTL_CODE(DeviceType, Function, Method, Access) \ - (((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method)) - -#define DEVICE_TYPE_FROM_CTL_CODE(ctl) (((ULONG) (ctl & 0xffff0000)) >> 16) - #define METHOD_FROM_CTL_CODE(ctrlCode) ((ULONG)(ctrlCode & 3)) -#define METHOD_BUFFERED 0 -#define METHOD_IN_DIRECT 1 -#define METHOD_OUT_DIRECT 2 -#define METHOD_NEITHER 3 #define METHOD_DIRECT_TO_HARDWARE METHOD_IN_DIRECT #define METHOD_DIRECT_FROM_HARDWARE METHOD_OUT_DIRECT -#define FILE_ANY_ACCESS 0x00000000 -#define FILE_SPECIAL_ACCESS FILE_ANY_ACCESS -#define FILE_READ_ACCESS 0x00000001 -#define FILE_WRITE_ACCESS 0x00000002 - typedef ULONG LSA_OPERATIONAL_MODE, *PLSA_OPERATIONAL_MODE; typedef enum _SECURITY_LOGON_TYPE { @@ -4673,6 +4553,8 @@ typedef struct _KAPC_STATE { #define KAPC_STATE_ACTUAL_LENGTH (FIELD_OFFSET(KAPC_STATE, UserApcPending) + sizeof(BOOLEAN)) +#define ASSERT_QUEUE(Q) ASSERT(((Q)->Header.Type & KOBJECT_TYPE_MASK) == QueueObject); + typedef struct _KQUEUE { DISPATCHER_HEADER Header; LIST_ENTRY EntryListHead; @@ -5022,24 +4904,6 @@ typedef NTSTATUS #if (NTDDI_VERSION >= NTDDI_WIN2K) -NTKERNELAPI -VOID -NTAPI -SeCaptureSubjectContext( - OUT PSECURITY_SUBJECT_CONTEXT SubjectContext); - -NTKERNELAPI -VOID -NTAPI -SeLockSubjectContext( - IN PSECURITY_SUBJECT_CONTEXT SubjectContext); - -NTKERNELAPI -VOID -NTAPI -SeUnlockSubjectContext( - IN PSECURITY_SUBJECT_CONTEXT SubjectContext); - NTKERNELAPI VOID NTAPI @@ -5453,18 +5317,6 @@ SeLocateProcessImageName( extern NTKERNELAPI PSE_EXPORTS SeExports; -#if !defined(_PSGETCURRENTTHREAD_) -#define _PSGETCURRENTTHREAD_ - -FORCEINLINE -PETHREAD -PsGetCurrentThread( - VOID) -{ - return (PETHREAD)KeGetCurrentThread(); -} -#endif - #if (NTDDI_VERSION >= NTDDI_WIN2K) NTKERNELAPI @@ -5534,7 +5386,20 @@ PsReturnPoolQuota( IN POOL_TYPE PoolType, IN ULONG_PTR Amount); -#endif +NTKERNELAPI +NTSTATUS +NTAPI +PsAssignImpersonationToken( + IN PETHREAD Thread, + IN HANDLE Token OPTIONAL); + +NTKERNELAPI +HANDLE +NTAPI +PsReferencePrimaryToken( + IN OUT PEPROCESS Process); + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ #if (NTDDI_VERSION >= NTDDI_WINXP) @@ -5823,18 +5688,6 @@ IoPageRead( IN PKEVENT Event, OUT PIO_STATUS_BLOCK IoStatusBlock); -NTKERNELAPI -PDEVICE_OBJECT -NTAPI -IoGetAttachedDevice( - IN PDEVICE_OBJECT DeviceObject); - -NTKERNELAPI -PDEVICE_OBJECT -NTAPI -IoGetAttachedDeviceReference( - IN PDEVICE_OBJECT DeviceObject); - NTKERNELAPI PDEVICE_OBJECT NTAPI @@ -5951,42 +5804,6 @@ NTAPI IoSetTopLevelIrp( IN PIRP Irp OPTIONAL); -NTKERNELAPI -VOID -NTAPI -IoStartNextPacket( - IN PDEVICE_OBJECT DeviceObject, - IN BOOLEAN Cancelable); - -NTKERNELAPI -VOID -NTAPI -IoStartNextPacketByKey( - IN PDEVICE_OBJECT DeviceObject, - IN BOOLEAN Cancelable, - IN ULONG Key); - -NTKERNELAPI -VOID -NTAPI -IoStartPacket( - IN PDEVICE_OBJECT DeviceObject, - IN PIRP Irp, - IN PULONG Key OPTIONAL, - IN PDRIVER_CANCEL CancelFunction OPTIONAL); - -NTKERNELAPI -VOID -NTAPI -IoStartTimer( - IN PDEVICE_OBJECT DeviceObject); - -NTKERNELAPI -VOID -NTAPI -IoStopTimer( - IN PDEVICE_OBJECT DeviceObject); - NTKERNELAPI NTSTATUS NTAPI @@ -6023,12 +5840,6 @@ IoVerifyVolume( IN PDEVICE_OBJECT DeviceObject, IN BOOLEAN AllowRawMount); -NTKERNELAPI -VOID -NTAPI -IoWriteErrorLogEntry( - IN PVOID ElEntry); - NTKERNELAPI NTSTATUS NTAPI @@ -6055,13 +5866,6 @@ IoQueryFileDosDeviceName( IN PFILE_OBJECT FileObject, OUT POBJECT_NAME_INFORMATION *ObjectNameInformation); -VOID -NTAPI -IoSetStartIoAttributes( - IN PDEVICE_OBJECT DeviceObject, - IN BOOLEAN DeferredStartIo, - IN BOOLEAN NonCancelable); - NTKERNELAPI NTSTATUS NTAPI @@ -6160,53 +5964,6 @@ typedef struct _IO_PRIORITY_INFO { #define PO_CB_LID_SWITCH_STATE 4 #define PO_CB_PROCESSOR_POWER_POLICY 5 -#if (NTDDI_VERSION >= NTDDI_WIN2K) - -NTKERNELAPI -PVOID -NTAPI -PoRegisterSystemState( - IN OUT PVOID StateHandle OPTIONAL, - IN EXECUTION_STATE Flags); - -NTKERNELAPI -VOID -NTAPI -PoUnregisterSystemState( - IN OUT PVOID StateHandle); - -NTKERNELAPI -POWER_STATE -NTAPI -PoSetPowerState( - IN PDEVICE_OBJECT DeviceObject, - IN POWER_STATE_TYPE Type, - IN POWER_STATE State); - -NTKERNELAPI -NTSTATUS -NTAPI -PoCallDriver( - IN PDEVICE_OBJECT DeviceObject, - IN OUT PIRP Irp); - -NTKERNELAPI -VOID -NTAPI -PoStartNextPowerIrp( - IN OUT PIRP Irp); - -NTKERNELAPI -PULONG -NTAPI -PoRegisterDeviceForIdleDetection( - IN PDEVICE_OBJECT DeviceObject, - IN ULONG ConservationIdleTime, - IN ULONG PerformanceIdleTime, - IN DEVICE_POWER_STATE State); - -#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ - #if (NTDDI_VERSION >= NTDDI_WINXP) NTKERNELAPI NTSTATUS @@ -6215,84 +5972,6 @@ PoQueueShutdownWorkItem( IN OUT PWORK_QUEUE_ITEM WorkItem); #endif -#if (NTDDI_VERSION >= NTDDI_VISTA) - -NTKERNELAPI -NTSTATUS -NTAPI -PoRegisterPowerSettingCallback( - IN PDEVICE_OBJECT DeviceObject OPTIONAL, - IN LPCGUID SettingGuid, - IN PPOWER_SETTING_CALLBACK Callback, - IN PVOID Context OPTIONAL, - OUT PVOID *Handle); - -NTKERNELAPI -NTSTATUS -PoUnregisterPowerSettingCallback( - IN OUT PVOID Handle); - -#endif - -#if (NTDDI_VERSION >= NTDDI_WIN6SP1) -NTKERNELAPI -VOID -NTAPI -PoSetDeviceBusyEx( - IN OUT PULONG IdlePointer); -#endif - -#if (NTDDI_VERSION >= NTDDI_WIN7) - -NTKERNELAPI -NTSTATUS -NTAPI -PoCreatePowerRequest( - OUT PVOID *PowerRequest, - IN PDEVICE_OBJECT DeviceObject, - IN PCOUNTED_REASON_CONTEXT Context); - -NTKERNELAPI -NTSTATUS -NTAPI -PoSetPowerRequest( - IN OUT PVOID PowerRequest, - IN POWER_REQUEST_TYPE Type); - -NTKERNELAPI -NTSTATUS -NTAPI -PoClearPowerRequest( - IN OUT PVOID PowerRequest, - IN POWER_REQUEST_TYPE Type); - -NTKERNELAPI -VOID -NTAPI -PoDeletePowerRequest( - IN OUT PVOID PowerRequest); - -NTKERNELAPI -VOID -NTAPI -PoStartDeviceBusy( - IN OUT PULONG IdlePointer); - -NTKERNELAPI -VOID -NTAPI -PoEndDeviceBusy( - IN OUT PULONG IdlePointer); - -NTKERNELAPI -BOOLEAN -NTAPI -PoQueryWatchdogTime( - IN PDEVICE_OBJECT Pdo, - OUT PULONG SecondsRemaining); - -#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ - #if defined(_IA64_) #if (NTDDI_VERSION >= NTDDI_WIN2K) //DECLSPEC_DEPRECATED_DDK @@ -6568,6 +6247,188 @@ typedef struct _FILE_LOCK { LONG volatile LockRequestsInProgress; } FILE_LOCK, *PFILE_LOCK; +typedef struct _TUNNEL { + FAST_MUTEX Mutex; + PRTL_SPLAY_LINKS Cache; + LIST_ENTRY TimerQueue; + USHORT NumEntries; +} TUNNEL, *PTUNNEL; + +typedef enum _FSRTL_COMPARISON_RESULT { + LessThan = -1, + EqualTo = 0, + GreaterThan = 1 +} FSRTL_COMPARISON_RESULT; + +#define FSRTL_FAT_LEGAL 0x01 +#define FSRTL_HPFS_LEGAL 0x02 +#define FSRTL_NTFS_LEGAL 0x04 +#define FSRTL_WILD_CHARACTER 0x08 +#define FSRTL_OLE_LEGAL 0x10 +#define FSRTL_NTFS_STREAM_LEGAL (FSRTL_NTFS_LEGAL | FSRTL_OLE_LEGAL) + +typedef struct _BASE_MCB { + ULONG MaximumPairCount; + ULONG PairCount; + USHORT PoolType; + USHORT Flags; + PVOID Mapping; +} BASE_MCB, *PBASE_MCB; + +typedef struct _LARGE_MCB { + PKGUARDED_MUTEX GuardedMutex; + BASE_MCB BaseMcb; +} LARGE_MCB, *PLARGE_MCB; + +#define MCB_FLAG_RAISE_ON_ALLOCATION_FAILURE 1 + +typedef struct _MCB { + LARGE_MCB DummyFieldThatSizesThisStructureCorrectly; +} MCB, *PMCB; + +typedef PVOID OPLOCK, *POPLOCK; + +typedef VOID +(NTAPI *POPLOCK_WAIT_COMPLETE_ROUTINE) ( + IN PVOID Context, + IN PIRP Irp); + +typedef VOID +(NTAPI *POPLOCK_FS_PREPOST_IRP) ( + IN PVOID Context, + IN PIRP Irp); + +#if (NTDDI_VERSION >= NTDDI_VISTASP1) +#define OPLOCK_FLAG_COMPLETE_IF_OPLOCKED 0x00000001 +#endif + +#if (NTDDI_VERSION >= NTDDI_WIN7) +#define OPLOCK_FLAG_OPLOCK_KEY_CHECK_ONLY 0x00000002 +#define OPLOCK_FLAG_BACK_OUT_ATOMIC_OPLOCK 0x00000004 +#define OPLOCK_FLAG_IGNORE_OPLOCK_KEYS 0x00000008 +#define OPLOCK_FSCTRL_FLAG_ALL_KEYS_MATCH 0x00000001 +#endif + +#if (NTDDI_VERSION >= NTDDI_WIN7) + +typedef struct _OPLOCK_KEY_ECP_CONTEXT { + GUID OplockKey; + ULONG Reserved; +} OPLOCK_KEY_ECP_CONTEXT, *POPLOCK_KEY_ECP_CONTEXT; + +DEFINE_GUID( GUID_ECP_OPLOCK_KEY, 0x48850596, 0x3050, 0x4be7, 0x98, 0x63, 0xfe, 0xc3, 0x50, 0xce, 0x8d, 0x7f ); + +#endif + +#define FSRTL_VOLUME_DISMOUNT 1 +#define FSRTL_VOLUME_DISMOUNT_FAILED 2 +#define FSRTL_VOLUME_LOCK 3 +#define FSRTL_VOLUME_LOCK_FAILED 4 +#define FSRTL_VOLUME_UNLOCK 5 +#define FSRTL_VOLUME_MOUNT 6 +#define FSRTL_VOLUME_NEEDS_CHKDSK 7 +#define FSRTL_VOLUME_WORM_NEAR_FULL 8 +#define FSRTL_VOLUME_WEARING_OUT 9 +#define FSRTL_VOLUME_FORCED_CLOSED 10 +#define FSRTL_VOLUME_INFO_MAKE_COMPAT 11 +#define FSRTL_VOLUME_PREPARING_EJECT 12 +#define FSRTL_VOLUME_CHANGE_SIZE 13 +#define FSRTL_VOLUME_BACKGROUND_FORMAT 14 + +typedef PVOID PNOTIFY_SYNC; + +typedef BOOLEAN +(NTAPI *PCHECK_FOR_TRAVERSE_ACCESS) ( + IN PVOID NotifyContext, + IN PVOID TargetContext OPTIONAL, + IN PSECURITY_SUBJECT_CONTEXT SubjectContext); + +typedef BOOLEAN +(NTAPI *PFILTER_REPORT_CHANGE) ( + IN PVOID NotifyContext, + IN PVOID FilterContext); + +typedef VOID +(NTAPI *PFSRTL_STACK_OVERFLOW_ROUTINE) ( + IN PVOID Context, + IN PKEVENT Event); + +#if (NTDDI_VERSION >= NTDDI_VISTA) + +#define FSRTL_UNC_PROVIDER_FLAGS_MAILSLOTS_SUPPORTED 0x00000001 +#define FSRTL_UNC_PROVIDER_FLAGS_CSC_ENABLED 0x00000002 +#define FSRTL_UNC_PROVIDER_FLAGS_DOMAIN_SVC_AWARE 0x00000004 + +#define FSRTL_ALLOCATE_ECPLIST_FLAG_CHARGE_QUOTA 0x00000001 + +#define FSRTL_ALLOCATE_ECP_FLAG_CHARGE_QUOTA 0x00000001 +#define FSRTL_ALLOCATE_ECP_FLAG_NONPAGED_POOL 0x00000002 + +#define FSRTL_ECP_LOOKASIDE_FLAG_NONPAGED_POOL 0x00000002 + +#define FSRTL_VIRTDISK_FULLY_ALLOCATED 0x00000001 +#define FSRTL_VIRTDISK_NO_DRIVE_LETTER 0x00000002 + +typedef struct _FSRTL_MUP_PROVIDER_INFO_LEVEL_1 { + ULONG32 ProviderId; +} FSRTL_MUP_PROVIDER_INFO_LEVEL_1, *PFSRTL_MUP_PROVIDER_INFO_LEVEL_1; + +typedef struct _FSRTL_MUP_PROVIDER_INFO_LEVEL_2 { + ULONG32 ProviderId; + UNICODE_STRING ProviderName; +} FSRTL_MUP_PROVIDER_INFO_LEVEL_2, *PFSRTL_MUP_PROVIDER_INFO_LEVEL_2; + +typedef VOID +(*PFSRTL_EXTRA_CREATE_PARAMETER_CLEANUP_CALLBACK) ( + IN OUT PVOID EcpContext, + IN LPCGUID EcpType); + +typedef struct _ECP_LIST ECP_LIST, *PECP_LIST; + +typedef ULONG FSRTL_ALLOCATE_ECPLIST_FLAGS; +typedef ULONG FSRTL_ALLOCATE_ECP_FLAGS; +typedef ULONG FSRTL_ECP_LOOKASIDE_FLAGS; + +typedef enum _FSRTL_CHANGE_BACKING_TYPE { + ChangeDataControlArea, + ChangeImageControlArea, + ChangeSharedCacheMap +} FSRTL_CHANGE_BACKING_TYPE, *PFSRTL_CHANGE_BACKING_TYPE; + +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + +typedef struct _FSRTL_PER_FILE_CONTEXT { + LIST_ENTRY Links; + PVOID OwnerId; + PVOID InstanceId; + PFREE_FUNCTION FreeCallback; +} FSRTL_PER_FILE_CONTEXT, *PFSRTL_PER_FILE_CONTEXT; + +typedef struct _FSRTL_PER_STREAM_CONTEXT { + LIST_ENTRY Links; + PVOID OwnerId; + PVOID InstanceId; + PFREE_FUNCTION FreeCallback; +} FSRTL_PER_STREAM_CONTEXT, *PFSRTL_PER_STREAM_CONTEXT; + +#if (NTDDI_VERSION >= NTDDI_WIN2K) +typedef VOID +(*PFN_FSRTLTEARDOWNPERSTREAMCONTEXTS) ( + IN PFSRTL_ADVANCED_FCB_HEADER AdvancedHeader); +#endif + +typedef struct _FSRTL_PER_FILEOBJECT_CONTEXT { + LIST_ENTRY Links; + PVOID OwnerId; + PVOID InstanceId; +} FSRTL_PER_FILEOBJECT_CONTEXT, *PFSRTL_PER_FILEOBJECT_CONTEXT; + +#define FsRtlEnterFileSystem KeEnterCriticalRegion +#define FsRtlExitFileSystem KeLeaveCriticalRegion + +#define FSRTL_CC_FLUSH_ERROR_FLAG_NO_HARD_ERROR 0x1 +#define FSRTL_CC_FLUSH_ERROR_FLAG_NO_LOG_ENTRY 0x2 + #if (NTDDI_VERSION >= NTDDI_WIN2K) NTKERNELAPI @@ -6845,15 +6706,2181 @@ FsRtlPrivateLock( IN PVOID Context, IN BOOLEAN AlreadySynchronized); +NTKERNELAPI +VOID +NTAPI +FsRtlInitializeTunnelCache( + IN PTUNNEL Cache); + +NTKERNELAPI +VOID +NTAPI +FsRtlAddToTunnelCache( + IN PTUNNEL Cache, + IN ULONGLONG DirectoryKey, + IN PUNICODE_STRING ShortName, + IN PUNICODE_STRING LongName, + IN BOOLEAN KeyByShortName, + IN ULONG DataLength, + IN PVOID Data); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlFindInTunnelCache( + IN PTUNNEL Cache, + IN ULONGLONG DirectoryKey, + IN PUNICODE_STRING Name, + OUT PUNICODE_STRING ShortName, + OUT PUNICODE_STRING LongName, + IN OUT PULONG DataLength, + OUT PVOID Data); + +NTKERNELAPI +VOID +NTAPI +FsRtlDeleteKeyFromTunnelCache( + IN PTUNNEL Cache, + IN ULONGLONG DirectoryKey); + +NTKERNELAPI +VOID +NTAPI +FsRtlDeleteTunnelCache( + IN PTUNNEL Cache); + +NTKERNELAPI +VOID +NTAPI +FsRtlDissectDbcs( + IN ANSI_STRING Name, + OUT PANSI_STRING FirstPart, + OUT PANSI_STRING RemainingPart); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlDoesDbcsContainWildCards( + IN PANSI_STRING Name); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlIsDbcsInExpression( + IN PANSI_STRING Expression, + IN PANSI_STRING Name); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlIsFatDbcsLegal( + IN ANSI_STRING DbcsName, + IN BOOLEAN WildCardsPermissible, + IN BOOLEAN PathNamePermissible, + IN BOOLEAN LeadingBackslashPermissible); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlIsHpfsDbcsLegal( + IN ANSI_STRING DbcsName, + IN BOOLEAN WildCardsPermissible, + IN BOOLEAN PathNamePermissible, + IN BOOLEAN LeadingBackslashPermissible); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlNormalizeNtstatus( + IN NTSTATUS Exception, + IN NTSTATUS GenericException); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlIsNtstatusExpected( + IN NTSTATUS Ntstatus); + +NTKERNELAPI +PERESOURCE +NTAPI +FsRtlAllocateResource( + VOID); + +NTKERNELAPI +VOID +NTAPI +FsRtlInitializeLargeMcb( + IN PLARGE_MCB Mcb, + IN POOL_TYPE PoolType); + +NTKERNELAPI +VOID +NTAPI +FsRtlUninitializeLargeMcb( + IN PLARGE_MCB Mcb); + +NTKERNELAPI +VOID +NTAPI +FsRtlResetLargeMcb( + IN PLARGE_MCB Mcb, + IN BOOLEAN SelfSynchronized); + +NTKERNELAPI +VOID +NTAPI +FsRtlTruncateLargeMcb( + IN PLARGE_MCB Mcb, + IN LONGLONG Vbn); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlAddLargeMcbEntry( + IN PLARGE_MCB Mcb, + IN LONGLONG Vbn, + IN LONGLONG Lbn, + IN LONGLONG SectorCount); + +NTKERNELAPI +VOID +NTAPI +FsRtlRemoveLargeMcbEntry( + IN PLARGE_MCB Mcb, + IN LONGLONG Vbn, + IN LONGLONG SectorCount); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlLookupLargeMcbEntry( + IN PLARGE_MCB Mcb, + IN LONGLONG Vbn, + OUT PLONGLONG Lbn OPTIONAL, + OUT PLONGLONG SectorCountFromLbn OPTIONAL, + OUT PLONGLONG StartingLbn OPTIONAL, + OUT PLONGLONG SectorCountFromStartingLbn OPTIONAL, + OUT PULONG Index OPTIONAL); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlLookupLastLargeMcbEntry( + IN PLARGE_MCB Mcb, + OUT PLONGLONG Vbn, + OUT PLONGLONG Lbn); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlLookupLastLargeMcbEntryAndIndex( + IN PLARGE_MCB OpaqueMcb, + OUT PLONGLONG LargeVbn, + OUT PLONGLONG LargeLbn, + OUT PULONG Index); + +NTKERNELAPI +ULONG +NTAPI +FsRtlNumberOfRunsInLargeMcb( + IN PLARGE_MCB Mcb); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlGetNextLargeMcbEntry( + IN PLARGE_MCB Mcb, + IN ULONG RunIndex, + OUT PLONGLONG Vbn, + OUT PLONGLONG Lbn, + OUT PLONGLONG SectorCount); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlSplitLargeMcb( + IN PLARGE_MCB Mcb, + IN LONGLONG Vbn, + IN LONGLONG Amount); + +NTKERNELAPI +VOID +NTAPI +FsRtlInitializeMcb( + IN PMCB Mcb, + IN POOL_TYPE PoolType); + +NTKERNELAPI +VOID +NTAPI +FsRtlUninitializeMcb( + IN PMCB Mcb); + +NTKERNELAPI +VOID +NTAPI +FsRtlTruncateMcb( + IN PMCB Mcb, + IN VBN Vbn); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlAddMcbEntry( + IN PMCB Mcb, + IN VBN Vbn, + IN LBN Lbn, + IN ULONG SectorCount); + +NTKERNELAPI +VOID +NTAPI +FsRtlRemoveMcbEntry( + IN PMCB Mcb, + IN VBN Vbn, + IN ULONG SectorCount); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlLookupMcbEntry( + IN PMCB Mcb, + IN VBN Vbn, + OUT PLBN Lbn, + OUT PULONG SectorCount OPTIONAL, + OUT PULONG Index); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlLookupLastMcbEntry( + IN PMCB Mcb, + OUT PVBN Vbn, + OUT PLBN Lbn); + +NTKERNELAPI +ULONG +NTAPI +FsRtlNumberOfRunsInMcb( + IN PMCB Mcb); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlGetNextMcbEntry( + IN PMCB Mcb, + IN ULONG RunIndex, + OUT PVBN Vbn, + OUT PLBN Lbn, + OUT PULONG SectorCount); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlBalanceReads( + IN PDEVICE_OBJECT TargetDevice); + +NTKERNELAPI +VOID +NTAPI +FsRtlInitializeOplock( + IN OUT POPLOCK Oplock); + +NTKERNELAPI +VOID +NTAPI +FsRtlUninitializeOplock( + IN OUT POPLOCK Oplock); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlOplockFsctrl( + IN POPLOCK Oplock, + IN PIRP Irp, + IN ULONG OpenCount); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlCheckOplock( + IN POPLOCK Oplock, + IN PIRP Irp, + IN PVOID Context, + IN POPLOCK_WAIT_COMPLETE_ROUTINE CompletionRoutine OPTIONAL, + IN POPLOCK_FS_PREPOST_IRP PostIrpRoutine OPTIONAL); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlOplockIsFastIoPossible( + IN POPLOCK Oplock); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlCurrentBatchOplock( + IN POPLOCK Oplock); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlNotifyVolumeEvent( + IN PFILE_OBJECT FileObject, + IN ULONG EventCode); + +NTKERNELAPI +VOID +NTAPI +FsRtlNotifyInitializeSync( + IN PNOTIFY_SYNC *NotifySync); + +NTKERNELAPI +VOID +NTAPI +FsRtlNotifyUninitializeSync( + IN PNOTIFY_SYNC *NotifySync); + +NTKERNELAPI +VOID +NTAPI +FsRtlNotifyFullChangeDirectory( + IN PNOTIFY_SYNC NotifySync, + IN PLIST_ENTRY NotifyList, + IN PVOID FsContext, + IN PSTRING FullDirectoryName, + IN BOOLEAN WatchTree, + IN BOOLEAN IgnoreBuffer, + IN ULONG CompletionFilter, + IN PIRP NotifyIrp OPTIONAL, + IN PCHECK_FOR_TRAVERSE_ACCESS TraverseCallback OPTIONAL, + IN PSECURITY_SUBJECT_CONTEXT SubjectContext OPTIONAL); + +NTKERNELAPI +VOID +NTAPI +FsRtlNotifyFilterReportChange( + IN PNOTIFY_SYNC NotifySync, + IN PLIST_ENTRY NotifyList, + IN PSTRING FullTargetName, + IN USHORT TargetNameOffset, + IN PSTRING StreamName OPTIONAL, + IN PSTRING NormalizedParentName OPTIONAL, + IN ULONG FilterMatch, + IN ULONG Action, + IN PVOID TargetContext OPTIONAL, + IN PVOID FilterContext OPTIONAL); + +NTKERNELAPI +VOID +NTAPI +FsRtlNotifyFullReportChange( + IN PNOTIFY_SYNC NotifySync, + IN PLIST_ENTRY NotifyList, + IN PSTRING FullTargetName, + IN USHORT TargetNameOffset, + IN PSTRING StreamName OPTIONAL, + IN PSTRING NormalizedParentName OPTIONAL, + IN ULONG FilterMatch, + IN ULONG Action, + IN PVOID TargetContext OPTIONAL); + +NTKERNELAPI +VOID +NTAPI +FsRtlNotifyCleanup( + IN PNOTIFY_SYNC NotifySync, + IN PLIST_ENTRY NotifyList, + IN PVOID FsContext); + +NTKERNELAPI +VOID +NTAPI +FsRtlDissectName( + IN UNICODE_STRING Name, + OUT PUNICODE_STRING FirstPart, + OUT PUNICODE_STRING RemainingPart); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlDoesNameContainWildCards( + IN PUNICODE_STRING Name); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlAreNamesEqual( + IN PCUNICODE_STRING Name1, + IN PCUNICODE_STRING Name2, + IN BOOLEAN IgnoreCase, + IN PCWCH UpcaseTable OPTIONAL); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlIsNameInExpression( + IN PUNICODE_STRING Expression, + IN PUNICODE_STRING Name, + IN BOOLEAN IgnoreCase, + IN PWCHAR UpcaseTable OPTIONAL); + +NTKERNELAPI +VOID +NTAPI +FsRtlPostPagingFileStackOverflow( + IN PVOID Context, + IN PKEVENT Event, + IN PFSRTL_STACK_OVERFLOW_ROUTINE StackOverflowRoutine); + +NTKERNELAPI +VOID +NTAPI +FsRtlPostStackOverflow ( + IN PVOID Context, + IN PKEVENT Event, + IN PFSRTL_STACK_OVERFLOW_ROUTINE StackOverflowRoutine); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlRegisterUncProvider( + OUT PHANDLE MupHandle, + IN PUNICODE_STRING RedirectorDeviceName, + IN BOOLEAN MailslotsSupported); + +NTKERNELAPI +VOID +NTAPI +FsRtlDeregisterUncProvider( + IN HANDLE Handle); + +NTKERNELAPI +VOID +NTAPI +FsRtlTeardownPerStreamContexts( + IN PFSRTL_ADVANCED_FCB_HEADER AdvancedHeader); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlCreateSectionForDataScan( + OUT PHANDLE SectionHandle, + OUT PVOID *SectionObject, + OUT PLARGE_INTEGER SectionFileSize OPTIONAL, + IN PFILE_OBJECT FileObject, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, + IN PLARGE_INTEGER MaximumSize OPTIONAL, + IN ULONG SectionPageProtection, + IN ULONG AllocationAttributes, + IN ULONG Flags); + #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ +#if (NTDDI_VERSION >= NTDDI_WINXP) + +NTKERNELAPI +VOID +NTAPI +FsRtlNotifyFilterChangeDirectory( + IN PNOTIFY_SYNC NotifySync, + IN PLIST_ENTRY NotifyList, + IN PVOID FsContext, + IN PSTRING FullDirectoryName, + IN BOOLEAN WatchTree, + IN BOOLEAN IgnoreBuffer, + IN ULONG CompletionFilter, + IN PIRP NotifyIrp OPTIONAL, + IN PCHECK_FOR_TRAVERSE_ACCESS TraverseCallback OPTIONAL, + IN PSECURITY_SUBJECT_CONTEXT SubjectContext OPTIONAL, + IN PFILTER_REPORT_CHANGE FilterCallback OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlInsertPerStreamContext( + IN PFSRTL_ADVANCED_FCB_HEADER PerStreamContext, + IN PFSRTL_PER_STREAM_CONTEXT Ptr); + +NTKERNELAPI +PFSRTL_PER_STREAM_CONTEXT +NTAPI +FsRtlLookupPerStreamContextInternal( + IN PFSRTL_ADVANCED_FCB_HEADER StreamContext, + IN PVOID OwnerId OPTIONAL, + IN PVOID InstanceId OPTIONAL); + +NTKERNELAPI +PFSRTL_PER_STREAM_CONTEXT +NTAPI +FsRtlRemovePerStreamContext( + IN PFSRTL_ADVANCED_FCB_HEADER StreamContext, + IN PVOID OwnerId OPTIONAL, + IN PVOID InstanceId OPTIONAL); + +NTKERNELAPI +VOID +NTAPI +FsRtlIncrementCcFastReadNotPossible( + VOID); + +NTKERNELAPI +VOID +NTAPI +FsRtlIncrementCcFastReadWait( + VOID); + +NTKERNELAPI +VOID +NTAPI +FsRtlIncrementCcFastReadNoWait( + VOID); + +NTKERNELAPI +VOID +NTAPI +FsRtlIncrementCcFastReadResourceMiss( + VOID); + +NTKERNELAPI +LOGICAL +NTAPI +FsRtlIsPagingFile( + IN PFILE_OBJECT FileObject); + +#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ + +#if (NTDDI_VERSION >= NTDDI_WS03) + +NTKERNELAPI +VOID +NTAPI +FsRtlInitializeBaseMcb( + IN PBASE_MCB Mcb, + IN POOL_TYPE PoolType); + +NTKERNELAPI +VOID +NTAPI +FsRtlUninitializeBaseMcb( + IN PBASE_MCB Mcb); + +NTKERNELAPI +VOID +NTAPI +FsRtlResetBaseMcb( + IN PBASE_MCB Mcb); + +NTKERNELAPI +VOID +NTAPI +FsRtlTruncateBaseMcb( + IN PBASE_MCB Mcb, + IN LONGLONG Vbn); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlAddBaseMcbEntry( + IN PBASE_MCB Mcb, + IN LONGLONG Vbn, + IN LONGLONG Lbn, + IN LONGLONG SectorCount); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlRemoveBaseMcbEntry( + IN PBASE_MCB Mcb, + IN LONGLONG Vbn, + IN LONGLONG SectorCount); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlLookupBaseMcbEntry( + IN PBASE_MCB Mcb, + IN LONGLONG Vbn, + OUT PLONGLONG Lbn OPTIONAL, + OUT PLONGLONG SectorCountFromLbn OPTIONAL, + OUT PLONGLONG StartingLbn OPTIONAL, + OUT PLONGLONG SectorCountFromStartingLbn OPTIONAL, + OUT PULONG Index OPTIONAL); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlLookupLastBaseMcbEntry( + IN PBASE_MCB Mcb, + OUT PLONGLONG Vbn, + OUT PLONGLONG Lbn); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlLookupLastBaseMcbEntryAndIndex( + IN PBASE_MCB OpaqueMcb, + IN OUT PLONGLONG LargeVbn, + IN OUT PLONGLONG LargeLbn, + IN OUT PULONG Index); + +NTKERNELAPI +ULONG +NTAPI +FsRtlNumberOfRunsInBaseMcb( + IN PBASE_MCB Mcb); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlGetNextBaseMcbEntry( + IN PBASE_MCB Mcb, + IN ULONG RunIndex, + OUT PLONGLONG Vbn, + OUT PLONGLONG Lbn, + OUT PLONGLONG SectorCount); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlSplitBaseMcb( + IN PBASE_MCB Mcb, + IN LONGLONG Vbn, + IN LONGLONG Amount); + +#endif /* (NTDDI_VERSION >= NTDDI_WS03) */ + +#if (NTDDI_VERSION >= NTDDI_VISTA) + +BOOLEAN +NTAPI +FsRtlInitializeBaseMcbEx( + IN PBASE_MCB Mcb, + IN POOL_TYPE PoolType, + IN USHORT Flags); + +NTSTATUS +NTAPI +FsRtlAddBaseMcbEntryEx( + IN PBASE_MCB Mcb, + IN LONGLONG Vbn, + IN LONGLONG Lbn, + IN LONGLONG SectorCount); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlCurrentOplock( + IN POPLOCK Oplock); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlOplockBreakToNone( + IN OUT POPLOCK Oplock, + IN PIO_STACK_LOCATION IrpSp OPTIONAL, + IN PIRP Irp, + IN PVOID Context OPTIONAL, + IN POPLOCK_WAIT_COMPLETE_ROUTINE CompletionRoutine OPTIONAL, + IN POPLOCK_FS_PREPOST_IRP PostIrpRoutine OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlNotifyVolumeEventEx( + IN PFILE_OBJECT FileObject, + IN ULONG EventCode, + IN PTARGET_DEVICE_CUSTOM_NOTIFICATION Event); + +NTKERNELAPI +VOID +NTAPI +FsRtlNotifyCleanupAll( + IN PNOTIFY_SYNC NotifySync, + IN PLIST_ENTRY NotifyList); + +NTSTATUS +NTAPI +FsRtlRegisterUncProviderEx( + OUT PHANDLE MupHandle, + IN PUNICODE_STRING RedirDevName, + IN PDEVICE_OBJECT DeviceObject, + IN ULONG Flags); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlCancellableWaitForSingleObject( + IN PVOID Object, + IN PLARGE_INTEGER Timeout OPTIONAL, + IN PIRP Irp OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlCancellableWaitForMultipleObjects( + IN ULONG Count, + IN PVOID ObjectArray[], + IN WAIT_TYPE WaitType, + IN PLARGE_INTEGER Timeout OPTIONAL, + IN PKWAIT_BLOCK WaitBlockArray OPTIONAL, + IN PIRP Irp OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlMupGetProviderInfoFromFileObject( + IN PFILE_OBJECT pFileObject, + IN ULONG Level, + OUT PVOID pBuffer, + IN OUT PULONG pBufferSize); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlMupGetProviderIdFromName( + IN PUNICODE_STRING pProviderName, + OUT PULONG32 pProviderId); + +NTKERNELAPI +VOID +NTAPI +FsRtlIncrementCcFastMdlReadWait( + VOID); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlValidateReparsePointBuffer( + IN ULONG BufferLength, + IN PREPARSE_DATA_BUFFER ReparseBuffer); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlRemoveDotsFromPath( + IN OUT PWSTR OriginalString, + IN USHORT PathLength, + OUT USHORT *NewLength); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlAllocateExtraCreateParameterList( + IN FSRTL_ALLOCATE_ECPLIST_FLAGS Flags, + OUT PECP_LIST *EcpList); + +NTKERNELAPI +VOID +NTAPI +FsRtlFreeExtraCreateParameterList( + IN PECP_LIST EcpList); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlAllocateExtraCreateParameter( + IN LPCGUID EcpType, + IN ULONG SizeOfContext, + IN FSRTL_ALLOCATE_ECP_FLAGS Flags, + IN PFSRTL_EXTRA_CREATE_PARAMETER_CLEANUP_CALLBACK CleanupCallback OPTIONAL, + IN ULONG PoolTag, + OUT PVOID *EcpContext); + +NTKERNELAPI +VOID +NTAPI +FsRtlFreeExtraCreateParameter( + IN PVOID EcpContext); + +NTKERNELAPI +VOID +NTAPI +FsRtlInitExtraCreateParameterLookasideList( + IN OUT PVOID Lookaside, + IN FSRTL_ECP_LOOKASIDE_FLAGS Flags, + IN SIZE_T Size, + IN ULONG Tag); + +VOID +NTAPI +FsRtlDeleteExtraCreateParameterLookasideList( + IN OUT PVOID Lookaside, + IN FSRTL_ECP_LOOKASIDE_FLAGS Flags); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlAllocateExtraCreateParameterFromLookasideList( + IN LPCGUID EcpType, + IN ULONG SizeOfContext, + IN FSRTL_ALLOCATE_ECP_FLAGS Flags, + IN PFSRTL_EXTRA_CREATE_PARAMETER_CLEANUP_CALLBACK CleanupCallback OPTIONAL, + IN OUT PVOID LookasideList, + OUT PVOID *EcpContext); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlInsertExtraCreateParameter( + IN OUT PECP_LIST EcpList, + IN OUT PVOID EcpContext); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlFindExtraCreateParameter( + IN PECP_LIST EcpList, + IN LPCGUID EcpType, + OUT PVOID *EcpContext OPTIONAL, + OUT ULONG *EcpContextSize OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlRemoveExtraCreateParameter( + IN OUT PECP_LIST EcpList, + IN LPCGUID EcpType, + OUT PVOID *EcpContext, + OUT ULONG *EcpContextSize OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlGetEcpListFromIrp( + IN PIRP Irp, + OUT PECP_LIST *EcpList OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlSetEcpListIntoIrp( + IN OUT PIRP Irp, + IN PECP_LIST EcpList); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlGetNextExtraCreateParameter( + IN PECP_LIST EcpList, + IN PVOID CurrentEcpContext OPTIONAL, + OUT LPGUID NextEcpType OPTIONAL, + OUT PVOID *NextEcpContext OPTIONAL, + OUT ULONG *NextEcpContextSize OPTIONAL); + +NTKERNELAPI +VOID +NTAPI +FsRtlAcknowledgeEcp( + IN PVOID EcpContext); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlIsEcpAcknowledged( + IN PVOID EcpContext); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlIsEcpFromUserMode( + IN PVOID EcpContext); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlChangeBackingFileObject( + IN PFILE_OBJECT CurrentFileObject OPTIONAL, + IN PFILE_OBJECT NewFileObject, + IN FSRTL_CHANGE_BACKING_TYPE ChangeBackingType, + IN ULONG Flags); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlLogCcFlushError( + IN PUNICODE_STRING FileName, + IN PDEVICE_OBJECT DeviceObject, + IN PSECTION_OBJECT_POINTERS SectionObjectPointer, + IN NTSTATUS FlushError, + IN ULONG Flags); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlAreVolumeStartupApplicationsComplete( + VOID); + +NTKERNELAPI +ULONG +NTAPI +FsRtlQueryMaximumVirtualDiskNestingLevel( + VOID); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlGetVirtualDiskNestingLevel( + IN PDEVICE_OBJECT DeviceObject, + OUT PULONG NestingLevel, + OUT PULONG NestingFlags OPTIONAL); + +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + +#if (NTDDI_VERSION >= NTDDI_VISTASP1) +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlCheckOplockEx( + IN POPLOCK Oplock, + IN PIRP Irp, + IN ULONG Flags, + IN PVOID Context OPTIONAL, + IN POPLOCK_WAIT_COMPLETE_ROUTINE CompletionRoutine OPTIONAL, + IN POPLOCK_FS_PREPOST_IRP PostIrpRoutine OPTIONAL); + +#endif + #if (NTDDI_VERSION >= NTDDI_WIN7) + NTKERNELAPI BOOLEAN NTAPI FsRtlAreThereCurrentOrInProgressFileLocks( IN PFILE_LOCK FileLock); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlOplockIsSharedRequest( + IN PIRP Irp); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlOplockBreakH( + IN POPLOCK Oplock, + IN PIRP Irp, + IN ULONG Flags, + IN PVOID Context OPTIONAL, + IN POPLOCK_WAIT_COMPLETE_ROUTINE CompletionRoutine OPTIONAL, + IN POPLOCK_FS_PREPOST_IRP PostIrpRoutine OPTIONAL); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlCurrentOplockH( + IN POPLOCK Oplock); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlOplockBreakToNoneEx( + IN OUT POPLOCK Oplock, + IN PIRP Irp, + IN ULONG Flags, + IN PVOID Context OPTIONAL, + IN POPLOCK_WAIT_COMPLETE_ROUTINE CompletionRoutine OPTIONAL, + IN POPLOCK_FS_PREPOST_IRP PostIrpRoutine OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlOplockFsctrlEx( + IN POPLOCK Oplock, + IN PIRP Irp, + IN ULONG OpenCount, + IN ULONG Flags); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlOplockKeysEqual( + IN PFILE_OBJECT Fo1 OPTIONAL, + IN PFILE_OBJECT Fo2 OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlInitializeExtraCreateParameterList( + IN OUT PECP_LIST EcpList); + +NTKERNELAPI +VOID +NTAPI +FsRtlInitializeExtraCreateParameter( + IN PECP_HEADER Ecp, + IN ULONG EcpFlags, + IN PFSRTL_EXTRA_CREATE_PARAMETER_CLEANUP_CALLBACK CleanupCallback OPTIONAL, + IN ULONG TotalSize, + IN LPCGUID EcpType, + IN PVOID ListAllocatedFrom OPTIONAL); + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlInsertPerFileContext( + IN PVOID* PerFileContextPointer, + IN PFSRTL_PER_FILE_CONTEXT Ptr); + +NTKERNELAPI +PFSRTL_PER_FILE_CONTEXT +NTAPI +FsRtlLookupPerFileContext( + IN PVOID* PerFileContextPointer, + IN PVOID OwnerId OPTIONAL, + IN PVOID InstanceId OPTIONAL); + +NTKERNELAPI +PFSRTL_PER_FILE_CONTEXT +NTAPI +FsRtlRemovePerFileContext( + IN PVOID* PerFileContextPointer, + IN PVOID OwnerId OPTIONAL, + IN PVOID InstanceId OPTIONAL); + +NTKERNELAPI +VOID +NTAPI +FsRtlTeardownPerFileContexts( + IN PVOID* PerFileContextPointer); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlInsertPerFileObjectContext( + IN PFILE_OBJECT FileObject, + IN PFSRTL_PER_FILEOBJECT_CONTEXT Ptr); + +NTKERNELAPI +PFSRTL_PER_FILEOBJECT_CONTEXT +NTAPI +FsRtlLookupPerFileObjectContext( + IN PFILE_OBJECT FileObject, + IN PVOID OwnerId OPTIONAL, + IN PVOID InstanceId OPTIONAL); + +NTKERNELAPI +PFSRTL_PER_FILEOBJECT_CONTEXT +NTAPI +FsRtlRemovePerFileObjectContext( + IN PFILE_OBJECT FileObject, + IN PVOID OwnerId OPTIONAL, + IN PVOID InstanceId OPTIONAL); + +#define FsRtlFastLock(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11) ( \ + FsRtlPrivateLock(A1, A2, A3, A4, A5, A6, A7, A8, A9, NULL, A10, A11) \ +) + +#define FsRtlAreThereCurrentFileLocks(FL) ( \ + ((FL)->FastIoIsQuestionable) \ +) + +#define FsRtlIncrementLockRequestsInProgress(FL) { \ + ASSERT( (FL)->LockRequestsInProgress >= 0 ); \ + (void) \ + (InterlockedIncrement((LONG volatile *)&((FL)->LockRequestsInProgress)));\ +} + +#define FsRtlDecrementLockRequestsInProgress(FL) { \ + ASSERT( (FL)->LockRequestsInProgress > 0 ); \ + (void) \ + (InterlockedDecrement((LONG volatile *)&((FL)->LockRequestsInProgress)));\ +} + +extern NTKERNELAPI PUSHORT NlsOemLeadByteInfo; +#define NLS_OEM_LEAD_BYTE_INFO NlsOemLeadByteInfo + +#ifdef NLS_MB_CODE_PAGE_TAG +#undef NLS_MB_CODE_PAGE_TAG #endif +#define NLS_MB_CODE_PAGE_TAG NlsMbOemCodePageTag + +/* GCC compatible definition, MS one is retarded */ +extern NTKERNELAPI const UCHAR * const FsRtlLegalAnsiCharacterArray; +#define LEGAL_ANSI_CHARACTER_ARRAY FsRtlLegalAnsiCharacterArray + +#define FsRtlIsAnsiCharacterWild(C) ( \ + FlagOn(FsRtlLegalAnsiCharacterArray[(UCHAR)(C)], FSRTL_WILD_CHARACTER ) \ +) + +#define FsRtlIsAnsiCharacterLegalFat(C, WILD) ( \ + FlagOn(FsRtlLegalAnsiCharacterArray[(UCHAR)(C)], (FSRTL_FAT_LEGAL) | \ + ((WILD) ? FSRTL_WILD_CHARACTER : 0 )) \ +) + +#define FsRtlIsAnsiCharacterLegalHpfs(C, WILD) ( \ + FlagOn(FsRtlLegalAnsiCharacterArray[(UCHAR)(C)], (FSRTL_HPFS_LEGAL) | \ + ((WILD) ? FSRTL_WILD_CHARACTER : 0 )) \ +) + +#define FsRtlIsAnsiCharacterLegalNtfs(C, WILD) ( \ + FlagOn(FsRtlLegalAnsiCharacterArray[(UCHAR)(C)], (FSRTL_NTFS_LEGAL) | \ + ((WILD) ? FSRTL_WILD_CHARACTER : 0 )) \ +) + +#define FsRtlIsAnsiCharacterLegalNtfsStream(C,WILD_OK) ( \ + FsRtlTestAnsiCharacter((C), TRUE, (WILD_OK), FSRTL_NTFS_STREAM_LEGAL) \ +) + +#define FsRtlIsAnsiCharacterLegal(C,FLAGS) ( \ + FsRtlTestAnsiCharacter((C), TRUE, FALSE, (FLAGS)) \ +) + +#define FsRtlTestAnsiCharacter(C, DEFAULT_RET, WILD_OK, FLAGS) ( \ + ((SCHAR)(C) < 0) ? DEFAULT_RET : \ + FlagOn( LEGAL_ANSI_CHARACTER_ARRAY[(C)], \ + (FLAGS) | \ + ((WILD_OK) ? FSRTL_WILD_CHARACTER : 0) ) \ +) + +#define FsRtlIsLeadDbcsCharacter(DBCS_CHAR) ( \ + (BOOLEAN)((UCHAR)(DBCS_CHAR) < 0x80 ? FALSE : \ + (NLS_MB_CODE_PAGE_TAG && \ + (NLS_OEM_LEAD_BYTE_INFO[(UCHAR)(DBCS_CHAR)] != 0))) \ +) + +#define FsRtlIsUnicodeCharacterWild(C) ( \ + (((C) >= 0x40) ? \ + FALSE : \ + FlagOn(FsRtlLegalAnsiCharacterArray[(C)], FSRTL_WILD_CHARACTER )) \ +) + +#define FsRtlInitPerFileContext( _fc, _owner, _inst, _cb) \ + ((_fc)->OwnerId = (_owner), \ + (_fc)->InstanceId = (_inst), \ + (_fc)->FreeCallback = (_cb)) + +#define FsRtlGetPerFileContextPointer(_fo) \ + (FsRtlSupportsPerFileContexts(_fo) ? \ + FsRtlGetPerStreamContextPointer(_fo)->FileContextSupportPointer : \ + NULL) + +#define FsRtlSupportsPerFileContexts(_fo) \ + ((FsRtlGetPerStreamContextPointer(_fo) != NULL) && \ + (FsRtlGetPerStreamContextPointer(_fo)->Version >= FSRTL_FCB_HEADER_V1) && \ + (FsRtlGetPerStreamContextPointer(_fo)->FileContextSupportPointer != NULL)) + +#define FsRtlSetupAdvancedHeaderEx( _advhdr, _fmutx, _fctxptr ) \ +{ \ + FsRtlSetupAdvancedHeader( _advhdr, _fmutx ); \ + if ((_fctxptr) != NULL) { \ + (_advhdr)->FileContextSupportPointer = (_fctxptr); \ + } \ +} + +#define FsRtlGetPerStreamContextPointer(FO) ( \ + (PFSRTL_ADVANCED_FCB_HEADER)(FO)->FsContext \ +) + +#define FsRtlInitPerStreamContext(PSC, O, I, FC) ( \ + (PSC)->OwnerId = (O), \ + (PSC)->InstanceId = (I), \ + (PSC)->FreeCallback = (FC) \ +) + +#define FsRtlSupportsPerStreamContexts(FO) ( \ + (BOOLEAN)((NULL != FsRtlGetPerStreamContextPointer(FO) && \ + FlagOn(FsRtlGetPerStreamContextPointer(FO)->Flags2, \ + FSRTL_FLAG2_SUPPORTS_FILTER_CONTEXTS)) \ +) + +#define FsRtlLookupPerStreamContext(_sc, _oid, _iid) \ + (((NULL != (_sc)) && \ + FlagOn((_sc)->Flags2,FSRTL_FLAG2_SUPPORTS_FILTER_CONTEXTS) && \ + !IsListEmpty(&(_sc)->FilterContexts)) ? \ + FsRtlLookupPerStreamContextInternal((_sc), (_oid), (_iid)) : \ + NULL) + +VOID +FORCEINLINE +NTAPI +FsRtlSetupAdvancedHeader( + IN PVOID AdvHdr, + IN PFAST_MUTEX FMutex ) +{ + PFSRTL_ADVANCED_FCB_HEADER localAdvHdr = (PFSRTL_ADVANCED_FCB_HEADER)AdvHdr; + + localAdvHdr->Flags |= FSRTL_FLAG_ADVANCED_HEADER; + localAdvHdr->Flags2 |= FSRTL_FLAG2_SUPPORTS_FILTER_CONTEXTS; +#if (NTDDI_VERSION >= NTDDI_VISTA) + localAdvHdr->Version = FSRTL_FCB_HEADER_V1; +#else + localAdvHdr->Version = FSRTL_FCB_HEADER_V0; +#endif + InitializeListHead( &localAdvHdr->FilterContexts ); + if (FMutex != NULL) { + localAdvHdr->FastMutex = FMutex; + } +#if (NTDDI_VERSION >= NTDDI_VISTA) + *((PULONG_PTR)(&localAdvHdr->PushLock)) = 0; + localAdvHdr->FileContextSupportPointer = NULL; +#endif +} + +#define FsRtlInitPerFileObjectContext(_fc, _owner, _inst) \ + ((_fc)->OwnerId = (_owner), (_fc)->InstanceId = (_inst)) + +#define FsRtlCompleteRequest(IRP,STATUS) { \ + (IRP)->IoStatus.Status = (STATUS); \ + IoCompleteRequest( (IRP), IO_DISK_INCREMENT ); \ +} + +#if (NTDDI_VERSION >= NTDDI_WIN7) +typedef struct _ECP_HEADER ECP_HEADER, *PECP_HEADER; +#endif + +#if (NTDDI_VERSION >= NTDDI_VISTA) + +typedef enum _NETWORK_OPEN_LOCATION_QUALIFIER { + NetworkOpenLocationAny, + NetworkOpenLocationRemote, + NetworkOpenLocationLoopback +} NETWORK_OPEN_LOCATION_QUALIFIER; + +typedef enum _NETWORK_OPEN_INTEGRITY_QUALIFIER { + NetworkOpenIntegrityAny, + NetworkOpenIntegrityNone, + NetworkOpenIntegritySigned, + NetworkOpenIntegrityEncrypted, + NetworkOpenIntegrityMaximum +} NETWORK_OPEN_INTEGRITY_QUALIFIER; + +#if (NTDDI_VERSION >= NTDDI_WIN7) + +#define NETWORK_OPEN_ECP_IN_FLAG_DISABLE_HANDLE_COLLAPSING 0x1 +#define NETWORK_OPEN_ECP_IN_FLAG_DISABLE_HANDLE_DURABILITY 0x2 +#define NETWORK_OPEN_ECP_IN_FLAG_FORCE_BUFFERED_SYNCHRONOUS_IO_HACK 0x80000000 + +typedef struct _NETWORK_OPEN_ECP_CONTEXT { + USHORT Size; + USHORT Reserved; + struct { + struct { + NETWORK_OPEN_LOCATION_QUALIFIER Location; + NETWORK_OPEN_INTEGRITY_QUALIFIER Integrity; + ULONG Flags; + } in; + struct { + NETWORK_OPEN_LOCATION_QUALIFIER Location; + NETWORK_OPEN_INTEGRITY_QUALIFIER Integrity; + ULONG Flags; + } out; + } DUMMYSTRUCTNAME; +} NETWORK_OPEN_ECP_CONTEXT, *PNETWORK_OPEN_ECP_CONTEXT; + +typedef struct _NETWORK_OPEN_ECP_CONTEXT_V0 { + USHORT Size; + USHORT Reserved; + struct { + struct { + NETWORK_OPEN_LOCATION_QUALIFIER Location; + NETWORK_OPEN_INTEGRITY_QUALIFIER Integrity; + } in; + struct { + NETWORK_OPEN_LOCATION_QUALIFIER Location; + NETWORK_OPEN_INTEGRITY_QUALIFIER Integrity; + } out; + } DUMMYSTRUCTNAME; +} NETWORK_OPEN_ECP_CONTEXT_V0, *PNETWORK_OPEN_ECP_CONTEXT_V0; + +#elif (NTDDI_VERSION >= NTDDI_VISTA) +typedef struct _NETWORK_OPEN_ECP_CONTEXT { + USHORT Size; + USHORT Reserved; + struct { + struct { + NETWORK_OPEN_LOCATION_QUALIFIER Location; + NETWORK_OPEN_INTEGRITY_QUALIFIER Integrity; + } in; + struct { + NETWORK_OPEN_LOCATION_QUALIFIER Location; + NETWORK_OPEN_INTEGRITY_QUALIFIER Integrity; + } out; + } DUMMYSTRUCTNAME; +} NETWORK_OPEN_ECP_CONTEXT, *PNETWORK_OPEN_ECP_CONTEXT; +#endif + +DEFINE_GUID(GUID_ECP_NETWORK_OPEN_CONTEXT, 0xc584edbf, 0x00df, 0x4d28, 0xb8, 0x84, 0x35, 0xba, 0xca, 0x89, 0x11, 0xe8 ); + +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + + +#if (NTDDI_VERSION >= NTDDI_VISTA) + +typedef struct _PREFETCH_OPEN_ECP_CONTEXT { + PVOID Context; +} PREFETCH_OPEN_ECP_CONTEXT, *PPREFETCH_OPEN_ECP_CONTEXT; + +DEFINE_GUID(GUID_ECP_PREFETCH_OPEN, 0xe1777b21, 0x847e, 0x4837, 0xaa, 0x45, 0x64, 0x16, 0x1d, 0x28, 0x6, 0x55 ); + +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + +#if (NTDDI_VERSION >= NTDDI_WIN7) + +DEFINE_GUID (GUID_ECP_NFS_OPEN, 0xf326d30c, 0xe5f8, 0x4fe7, 0xab, 0x74, 0xf5, 0xa3, 0x19, 0x6d, 0x92, 0xdb); +DEFINE_GUID(GUID_ECP_SRV_OPEN, 0xbebfaebc, 0xaabf, 0x489d, 0x9d, 0x2c, 0xe9, 0xe3, 0x61, 0x10, 0x28, 0x53 ); + +typedef struct sockaddr_storage *PSOCKADDR_STORAGE_NFS; + +typedef struct _NFS_OPEN_ECP_CONTEXT { + PUNICODE_STRING ExportAlias; + PSOCKADDR_STORAGE_NFS ClientSocketAddress; +} NFS_OPEN_ECP_CONTEXT, *PNFS_OPEN_ECP_CONTEXT, **PPNFS_OPEN_ECP_CONTEXT; + +typedef struct _SRV_OPEN_ECP_CONTEXT { + PUNICODE_STRING ShareName; + PSOCKADDR_STORAGE_NFS SocketAddress; + BOOLEAN OplockBlockState; + BOOLEAN OplockAppState; + BOOLEAN OplockFinalState; +} SRV_OPEN_ECP_CONTEXT, *PSRV_OPEN_ECP_CONTEXT; + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + +#define VACB_MAPPING_GRANULARITY (0x40000) +#define VACB_OFFSET_SHIFT (18) + +typedef struct _PUBLIC_BCB { + CSHORT NodeTypeCode; + CSHORT NodeByteSize; + ULONG MappedLength; + LARGE_INTEGER MappedFileOffset; +} PUBLIC_BCB, *PPUBLIC_BCB; + +typedef struct _CC_FILE_SIZES { + LARGE_INTEGER AllocationSize; + LARGE_INTEGER FileSize; + LARGE_INTEGER ValidDataLength; +} CC_FILE_SIZES, *PCC_FILE_SIZES; + +typedef BOOLEAN +(NTAPI *PACQUIRE_FOR_LAZY_WRITE) ( + IN PVOID Context, + IN BOOLEAN Wait); + +typedef VOID +(NTAPI *PRELEASE_FROM_LAZY_WRITE) ( + IN PVOID Context); + +typedef BOOLEAN +(NTAPI *PACQUIRE_FOR_READ_AHEAD) ( + IN PVOID Context, + IN BOOLEAN Wait); + +typedef VOID +(NTAPI *PRELEASE_FROM_READ_AHEAD) ( + IN PVOID Context); + +typedef struct _CACHE_MANAGER_CALLBACKS { + PACQUIRE_FOR_LAZY_WRITE AcquireForLazyWrite; + PRELEASE_FROM_LAZY_WRITE ReleaseFromLazyWrite; + PACQUIRE_FOR_READ_AHEAD AcquireForReadAhead; + PRELEASE_FROM_READ_AHEAD ReleaseFromReadAhead; +} CACHE_MANAGER_CALLBACKS, *PCACHE_MANAGER_CALLBACKS; + +typedef struct _CACHE_UNINITIALIZE_EVENT { + struct _CACHE_UNINITIALIZE_EVENT *Next; + KEVENT Event; +} CACHE_UNINITIALIZE_EVENT, *PCACHE_UNINITIALIZE_EVENT; + +typedef VOID +(NTAPI *PDIRTY_PAGE_ROUTINE) ( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN PLARGE_INTEGER OldestLsn, + IN PLARGE_INTEGER NewestLsn, + IN PVOID Context1, + IN PVOID Context2); + +typedef VOID +(NTAPI *PFLUSH_TO_LSN) ( + IN PVOID LogHandle, + IN LARGE_INTEGER Lsn); + +typedef VOID +(NTAPI *PCC_POST_DEFERRED_WRITE) ( + IN PVOID Context1, + IN PVOID Context2); + +#define CcIsFileCached(FO) ( \ + ((FO)->SectionObjectPointer != NULL) && \ + (((PSECTION_OBJECT_POINTERS)(FO)->SectionObjectPointer)->SharedCacheMap != NULL) \ +) + +extern ULONG CcFastMdlReadWait; + +#if (NTDDI_VERSION >= NTDDI_WIN2K) + +NTKERNELAPI +VOID +NTAPI +CcInitializeCacheMap( + IN PFILE_OBJECT FileObject, + IN PCC_FILE_SIZES FileSizes, + IN BOOLEAN PinAccess, + IN PCACHE_MANAGER_CALLBACKS Callbacks, + IN PVOID LazyWriteContext); + +NTKERNELAPI +BOOLEAN +NTAPI +CcUninitializeCacheMap( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER TruncateSize OPTIONAL, + IN PCACHE_UNINITIALIZE_EVENT UninitializeCompleteEvent OPTIONAL); + +NTKERNELAPI +VOID +NTAPI +CcSetFileSizes( + IN PFILE_OBJECT FileObject, + IN PCC_FILE_SIZES FileSizes); + +NTKERNELAPI +VOID +NTAPI +CcSetDirtyPageThreshold( + IN PFILE_OBJECT FileObject, + IN ULONG DirtyPageThreshold); + +NTKERNELAPI +VOID +NTAPI +CcFlushCache( + IN PSECTION_OBJECT_POINTERS SectionObjectPointer, + IN PLARGE_INTEGER FileOffset OPTIONAL, + IN ULONG Length, + OUT PIO_STATUS_BLOCK IoStatus OPTIONAL); + +NTKERNELAPI +LARGE_INTEGER +NTAPI +CcGetFlushedValidData( + IN PSECTION_OBJECT_POINTERS SectionObjectPointer, + IN BOOLEAN BcbListHeld); + +NTKERNELAPI +BOOLEAN +NTAPI +CcZeroData( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER StartOffset, + IN PLARGE_INTEGER EndOffset, + IN BOOLEAN Wait); + +NTKERNELAPI +PVOID +NTAPI +CcRemapBcb( + IN PVOID Bcb); + +NTKERNELAPI +VOID +NTAPI +CcRepinBcb( + IN PVOID Bcb); + +NTKERNELAPI +VOID +NTAPI +CcUnpinRepinnedBcb( + IN PVOID Bcb, + IN BOOLEAN WriteThrough, + OUT PIO_STATUS_BLOCK IoStatus); + +NTKERNELAPI +PFILE_OBJECT +NTAPI +CcGetFileObjectFromSectionPtrs( + IN PSECTION_OBJECT_POINTERS SectionObjectPointer); + +NTKERNELAPI +PFILE_OBJECT +NTAPI +CcGetFileObjectFromBcb( + IN PVOID Bcb); + +NTKERNELAPI +BOOLEAN +NTAPI +CcCanIWrite( + IN PFILE_OBJECT FileObject, + IN ULONG BytesToWrite, + IN BOOLEAN Wait, + IN BOOLEAN Retrying); + +NTKERNELAPI +VOID +NTAPI +CcDeferWrite( + IN PFILE_OBJECT FileObject, + IN PCC_POST_DEFERRED_WRITE PostRoutine, + IN PVOID Context1, + IN PVOID Context2, + IN ULONG BytesToWrite, + IN BOOLEAN Retrying); + +NTKERNELAPI +BOOLEAN +NTAPI +CcCopyRead( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN BOOLEAN Wait, + OUT PVOID Buffer, + OUT PIO_STATUS_BLOCK IoStatus); + +NTKERNELAPI +VOID +NTAPI +CcFastCopyRead( + IN PFILE_OBJECT FileObject, + IN ULONG FileOffset, + IN ULONG Length, + IN ULONG PageCount, + OUT PVOID Buffer, + OUT PIO_STATUS_BLOCK IoStatus); + +NTKERNELAPI +BOOLEAN +NTAPI +CcCopyWrite( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN BOOLEAN Wait, + IN PVOID Buffer); + +NTKERNELAPI +VOID +NTAPI +CcFastCopyWrite( + IN PFILE_OBJECT FileObject, + IN ULONG FileOffset, + IN ULONG Length, + IN PVOID Buffer); + +NTKERNELAPI +VOID +NTAPI +CcMdlRead( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + OUT PMDL *MdlChain, + OUT PIO_STATUS_BLOCK IoStatus); + +NTKERNELAPI +VOID +NTAPI +CcMdlReadComplete( + IN PFILE_OBJECT FileObject, + IN PMDL MdlChain); + +NTKERNELAPI +VOID +NTAPI +CcPrepareMdlWrite( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + OUT PMDL *MdlChain, + OUT PIO_STATUS_BLOCK IoStatus); + +NTKERNELAPI +VOID +NTAPI +CcMdlWriteComplete( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN PMDL MdlChain); + +NTKERNELAPI +VOID +NTAPI +CcScheduleReadAhead( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length); + +NTKERNELAPI +NTSTATUS +NTAPI +CcWaitForCurrentLazyWriterActivity( + VOID); + +NTKERNELAPI +VOID +NTAPI +CcSetReadAheadGranularity( + IN PFILE_OBJECT FileObject, + IN ULONG Granularity); + +NTKERNELAPI +BOOLEAN +NTAPI +CcPinRead( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN ULONG Flags, + OUT PVOID *Bcb, + OUT PVOID *Buffer); + +NTKERNELAPI +BOOLEAN +NTAPI +CcPinMappedData( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN ULONG Flags, + IN OUT PVOID *Bcb); + +NTKERNELAPI +BOOLEAN +NTAPI +CcPreparePinWrite( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN BOOLEAN Zero, + IN ULONG Flags, + OUT PVOID *Bcb, + OUT PVOID *Buffer); + +NTKERNELAPI +VOID +NTAPI +CcSetDirtyPinnedData( + IN PVOID BcbVoid, + IN PLARGE_INTEGER Lsn OPTIONAL); + +NTKERNELAPI +VOID +NTAPI +CcUnpinData( + IN PVOID Bcb); + +NTKERNELAPI +VOID +NTAPI +CcSetBcbOwnerPointer( + IN PVOID Bcb, + IN PVOID OwnerPointer); + +NTKERNELAPI +VOID +NTAPI +CcUnpinDataForThread( + IN PVOID Bcb, + IN ERESOURCE_THREAD ResourceThreadId); + +NTKERNELAPI +VOID +NTAPI +CcSetAdditionalCacheAttributes( + IN PFILE_OBJECT FileObject, + IN BOOLEAN DisableReadAhead, + IN BOOLEAN DisableWriteBehind); + +NTKERNELAPI +BOOLEAN +NTAPI +CcIsThereDirtyData( + IN PVPB Vpb); + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ + +#if (NTDDI_VERSION >= NTDDI_WINXP) + +NTKERNELAPI +VOID +NTAPI +CcMdlWriteAbort( + IN PFILE_OBJECT FileObject, + IN PMDL MdlChain); + +NTKERNELAPI +VOID +NTAPI +CcSetLogHandleForFile( + IN PFILE_OBJECT FileObject, + IN PVOID LogHandle, + IN PFLUSH_TO_LSN FlushToLsnRoutine); + +NTKERNELAPI +LARGE_INTEGER +NTAPI +CcGetDirtyPages( + IN PVOID LogHandle, + IN PDIRTY_PAGE_ROUTINE DirtyPageRoutine, + IN PVOID Context1, + IN PVOID Context2); + +#endif + +#if (NTDDI_VERSION >= NTDDI_WINXP) +NTKERNELAPI +BOOLEAN +NTAPI +CcMapData( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN ULONG Flags, + OUT PVOID *Bcb, + OUT PVOID *Buffer); +#elif (NTDDI_VERSION >= NTDDI_WIN2K) +NTKERNELAPI +BOOLEAN +NTAPI +CcMapData( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN BOOLEAN Wait, + OUT PVOID *Bcb, + OUT PVOID *Buffer); +#endif + +#if (NTDDI_VERSION >= NTDDI_VISTA) + +NTKERNELAPI +NTSTATUS +NTAPI +CcSetFileSizesEx( + IN PFILE_OBJECT FileObject, + IN PCC_FILE_SIZES FileSizes); + +NTKERNELAPI +PFILE_OBJECT +NTAPI +CcGetFileObjectFromSectionPtrsRef( + IN PSECTION_OBJECT_POINTERS SectionObjectPointer); + +NTKERNELAPI +VOID +NTAPI +CcSetParallelFlushFile( + IN PFILE_OBJECT FileObject, + IN BOOLEAN EnableParallelFlush); + +NTKERNELAPI +BOOLEAN +CcIsThereDirtyDataEx( + IN PVPB Vpb, + IN PULONG NumberOfDirtyPages OPTIONAL); + +#endif + +#if (NTDDI_VERSION >= NTDDI_WIN7) +NTKERNELAPI +VOID +NTAPI +CcCoherencyFlushAndPurgeCache( + IN PSECTION_OBJECT_POINTERS SectionObjectPointer, + IN PLARGE_INTEGER FileOffset OPTIONAL, + IN ULONG Length, + OUT PIO_STATUS_BLOCK IoStatus, + IN ULONG Flags OPTIONAL); +#endif + +#define CcGetFileSizePointer(FO) ( \ + ((PLARGE_INTEGER)((FO)->SectionObjectPointer->SharedCacheMap) + 1) \ +) + +#define UNINITIALIZE_CACHE_MAPS (1) +#define DO_NOT_RETRY_PURGE (2) +#define DO_NOT_PURGE_DIRTY_PAGES (0x4) + +#define CC_FLUSH_AND_PURGE_NO_PURGE (0x1) + +#if (NTDDI_VERSION >= NTDDI_VISTA) +NTKERNELAPI +BOOLEAN +NTAPI +CcPurgeCacheSection( + IN PSECTION_OBJECT_POINTERS SectionObjectPointer, + IN PLARGE_INTEGER FileOffset OPTIONAL, + IN ULONG Length, + IN ULONG Flags); +#elif (NTDDI_VERSION >= NTDDI_WIN2K) +NTKERNELAPI +BOOLEAN +NTAPI +CcPurgeCacheSection( + IN PSECTION_OBJECT_POINTERS SectionObjectPointer, + IN PLARGE_INTEGER FileOffset OPTIONAL, + IN ULONG Length, + IN BOOLEAN UninitializeCacheMaps); +#endif + +#if (NTDDI_VERSION >= NTDDI_WIN7) +NTKERNELAPI +BOOLEAN +NTAPI +CcCopyWriteWontFlush( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length); +#else +#define CcCopyWriteWontFlush(FO, FOFF, LEN) ((LEN) <= 0x10000) +#endif + +#define CcReadAhead(FO, FOFF, LEN) ( \ + if ((LEN) >= 256) { \ + CcScheduleReadAhead((FO), (FOFF), (LEN)); \ + } \ +) + +#define PIN_WAIT (1) +#define PIN_EXCLUSIVE (2) +#define PIN_NO_READ (4) +#define PIN_IF_BCB (8) +#define PIN_CALLER_TRACKS_DIRTY_DATA (32) +#define PIN_HIGH_PRIORITY (64) + +#define MAP_WAIT 1 +#define MAP_NO_READ (16) +#define MAP_HIGH_PRIORITY (64) + +#define IOCTL_REDIR_QUERY_PATH CTL_CODE(FILE_DEVICE_NETWORK_FILE_SYSTEM, 99, METHOD_NEITHER, FILE_ANY_ACCESS) +#define IOCTL_REDIR_QUERY_PATH_EX CTL_CODE(FILE_DEVICE_NETWORK_FILE_SYSTEM, 100, METHOD_NEITHER, FILE_ANY_ACCESS) + +typedef struct _QUERY_PATH_REQUEST { + ULONG PathNameLength; + PIO_SECURITY_CONTEXT SecurityContext; + WCHAR FilePathName[1]; +} QUERY_PATH_REQUEST, *PQUERY_PATH_REQUEST; + +typedef struct _QUERY_PATH_REQUEST_EX { + PIO_SECURITY_CONTEXT pSecurityContext; + ULONG EaLength; + PVOID pEaBuffer; + UNICODE_STRING PathName; + UNICODE_STRING DomainServiceName; + ULONG_PTR Reserved[ 3 ]; +} QUERY_PATH_REQUEST_EX, *PQUERY_PATH_REQUEST_EX; + +typedef struct _QUERY_PATH_RESPONSE { + ULONG LengthAccepted; +} QUERY_PATH_RESPONSE, *PQUERY_PATH_RESPONSE; + +#define VOLSNAPCONTROLTYPE 0x00000053 +#define IOCTL_VOLSNAP_FLUSH_AND_HOLD_WRITES CTL_CODE(VOLSNAPCONTROLTYPE, 0, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) + +#if (NTDDI_VERSION >= NTDDI_WIN2K) + +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryObject( + IN HANDLE Handle OPTIONAL, + IN OBJECT_INFORMATION_CLASS ObjectInformationClass, + OUT PVOID ObjectInformation OPTIONAL, + IN ULONG ObjectInformationLength, + OUT PULONG ReturnLength OPTIONAL); + +NTSYSAPI +NTSTATUS +NTAPI +ZwNotifyChangeKey( + IN HANDLE KeyHandle, + IN HANDLE EventHandle OPTIONAL, + IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, + IN PVOID ApcContext OPTIONAL, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN ULONG NotifyFilter, + IN BOOLEAN WatchSubtree, + OUT PVOID Buffer, + IN ULONG BufferLength, + IN BOOLEAN Asynchronous); + +NTSYSAPI +NTSTATUS +NTAPI +ZwCreateEvent( + OUT PHANDLE EventHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, + IN EVENT_TYPE EventType, + IN BOOLEAN InitialState); + +NTSYSAPI +NTSTATUS +NTAPI +ZwDeleteFile( + IN POBJECT_ATTRIBUTES ObjectAttributes); + +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryDirectoryFile( + IN HANDLE FileHandle, + IN HANDLE Event OPTIONAL, + IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, + IN PVOID ApcContext OPTIONAL, + OUT PIO_STATUS_BLOCK IoStatusBlock, + OUT PVOID FileInformation, + IN ULONG Length, + IN FILE_INFORMATION_CLASS FileInformationClass, + IN BOOLEAN ReturnSingleEntry, + IN PUNICODE_STRING FileName OPTIONAL, + IN BOOLEAN RestartScan); + +NTSYSAPI +NTSTATUS +NTAPI +ZwSetVolumeInformationFile( + IN HANDLE FileHandle, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN PVOID FsInformation, + IN ULONG Length, + IN FS_INFORMATION_CLASS FsInformationClass); + +NTSYSAPI +NTSTATUS +NTAPI +ZwFsControlFile( + IN HANDLE FileHandle, + IN HANDLE Event OPTIONAL, + IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, + IN PVOID ApcContext OPTIONAL, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN ULONG FsControlCode, + IN PVOID InputBuffer OPTIONAL, + IN ULONG InputBufferLength, + OUT PVOID OutputBuffer OPTIONAL, + IN ULONG OutputBufferLength); + +NTSYSAPI +NTSTATUS +NTAPI +ZwDuplicateObject( + IN HANDLE SourceProcessHandle, + IN HANDLE SourceHandle, + IN HANDLE TargetProcessHandle OPTIONAL, + OUT PHANDLE TargetHandle OPTIONAL, + IN ACCESS_MASK DesiredAccess, + IN ULONG HandleAttributes, + IN ULONG Options); + +NTSYSAPI +NTSTATUS +NTAPI +ZwOpenDirectoryObject( + OUT PHANDLE DirectoryHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes); + +NTSYSAPI +NTSTATUS +NTAPI +ZwAllocateVirtualMemory( + IN HANDLE ProcessHandle, + IN OUT PVOID *BaseAddress, + IN ULONG_PTR ZeroBits, + IN OUT PSIZE_T RegionSize, + IN ULONG AllocationType, + IN ULONG Protect); + +NTSYSAPI +NTSTATUS +NTAPI +ZwFreeVirtualMemory( + IN HANDLE ProcessHandle, + IN OUT PVOID *BaseAddress, + IN OUT PSIZE_T RegionSize, + IN ULONG FreeType); + +NTSYSAPI +NTSTATUS +NTAPI +ZwWaitForSingleObject( + IN HANDLE Handle, + IN BOOLEAN Alertable, + IN PLARGE_INTEGER Timeout OPTIONAL); + +NTSYSAPI +NTSTATUS +NTAPI +ZwSetEvent( + IN HANDLE EventHandle, + OUT PLONG PreviousState OPTIONAL); + +NTSYSAPI +NTSTATUS +NTAPI +ZwFlushVirtualMemory( + IN HANDLE ProcessHandle, + IN OUT PVOID *BaseAddress, + IN OUT PSIZE_T RegionSize, + OUT PIO_STATUS_BLOCK IoStatusBlock); + +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryInformationToken( + IN HANDLE TokenHandle, + IN TOKEN_INFORMATION_CLASS TokenInformationClass, + OUT PVOID TokenInformation, + IN ULONG Length, + OUT PULONG ResultLength); + +NTSYSAPI +NTSTATUS +NTAPI +ZwSetSecurityObject( + IN HANDLE Handle, + IN SECURITY_INFORMATION SecurityInformation, + IN PSECURITY_DESCRIPTOR SecurityDescriptor); + +NTSYSAPI +NTSTATUS +NTAPI +ZwQuerySecurityObject( + IN HANDLE FileHandle, + IN SECURITY_INFORMATION SecurityInformation, + OUT PSECURITY_DESCRIPTOR SecurityDescriptor, + IN ULONG Length, + OUT PULONG ResultLength); + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ + +#if (NTDDI_VERSION >= NTDDI_WINXP) + +NTSYSAPI +NTSTATUS +NTAPI +ZwOpenProcessTokenEx( + IN HANDLE ProcessHandle, + IN ACCESS_MASK DesiredAccess, + IN ULONG HandleAttributes, + OUT PHANDLE TokenHandle); + +NTSYSAPI +NTSTATUS +NTAPI +ZwOpenThreadTokenEx( + IN HANDLE ThreadHandle, + IN ACCESS_MASK DesiredAccess, + IN BOOLEAN OpenAsSelf, + IN ULONG HandleAttributes, + OUT PHANDLE TokenHandle); + +#endif + +#if (NTDDI_VERSION >= NTDDI_VISTA) + +NTSYSAPI +NTSTATUS +NTAPI +ZwLockFile( + IN HANDLE FileHandle, + IN HANDLE Event OPTIONAL, + IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, + IN PVOID ApcContext OPTIONAL, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN PLARGE_INTEGER ByteOffset, + IN PLARGE_INTEGER Length, + IN ULONG Key, + IN BOOLEAN FailImmediately, + IN BOOLEAN ExclusiveLock); + +NTSYSAPI +NTSTATUS +NTAPI +ZwUnlockFile( + IN HANDLE FileHandle, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN PLARGE_INTEGER ByteOffset, + IN PLARGE_INTEGER Length, + IN ULONG Key); + +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryQuotaInformationFile( + IN HANDLE FileHandle, + OUT PIO_STATUS_BLOCK IoStatusBlock, + OUT PVOID Buffer, + IN ULONG Length, + IN BOOLEAN ReturnSingleEntry, + IN PVOID SidList, + IN ULONG SidListLength, + IN PSID StartSid OPTIONAL, + IN BOOLEAN RestartScan); + +NTSYSAPI +NTSTATUS +NTAPI +ZwSetQuotaInformationFile( + IN HANDLE FileHandle, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN PVOID Buffer, + IN ULONG Length); + +NTSYSAPI +NTSTATUS +NTAPI +ZwFlushBuffersFile( + IN HANDLE FileHandle, + OUT PIO_STATUS_BLOCK IoStatusBlock); + +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + +#if (NTDDI_VERSION >= NTDDI_WIN7) +NTSYSAPI +NTSTATUS +NTAPI +ZwSetInformationToken( + IN HANDLE TokenHandle, + IN TOKEN_INFORMATION_CLASS TokenInformationClass, + IN PVOID TokenInformation, + IN ULONG TokenInformationLength); +#endif + +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryEaFile( + IN HANDLE FileHandle, + OUT PIO_STATUS_BLOCK IoStatusBlock, + OUT PVOID Buffer, + IN ULONG Length, + IN BOOLEAN ReturnSingleEntry, + IN PVOID EaList OPTIONAL, + IN ULONG EaListLength, + IN PULONG EaIndex OPTIONAL, + IN BOOLEAN RestartScan); + +NTSYSAPI +NTSTATUS +NTAPI +ZwSetEaFile( + IN HANDLE FileHandle, + OUT PIO_STATUS_BLOCK IoStatusBlock, + OUT PVOID Buffer, + IN ULONG Length); + +NTSYSAPI +NTSTATUS +NTAPI +ZwDuplicateToken( + IN HANDLE ExistingTokenHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN BOOLEAN EffectiveOnly, + IN TOKEN_TYPE TokenType, + OUT PHANDLE NewTokenHandle); #pragma pack(push,4) @@ -6863,11 +8890,6 @@ FsRtlAreThereCurrentOrInProgressFileLocks( #include "csq.h" -#ifdef _NTOSKRNL_ -extern PUCHAR FsRtlLegalAnsiCharacterArray; -#else -extern DECLSPEC_IMPORT PUCHAR FsRtlLegalAnsiCharacterArray; -#endif extern PACL SePublicDefaultDacl; extern PACL SeSystemDefaultDacl; @@ -6890,30 +8912,11 @@ extern PACL SeSystemDefaultDacl; #define FILE_VC_QUOTAS_LOG_VIOLATIONS 0x00000004 -#define FSRTL_VOLUME_DISMOUNT 1 -#define FSRTL_VOLUME_DISMOUNT_FAILED 2 -#define FSRTL_VOLUME_LOCK 3 -#define FSRTL_VOLUME_LOCK_FAILED 4 -#define FSRTL_VOLUME_UNLOCK 5 -#define FSRTL_VOLUME_MOUNT 6 - -#define FSRTL_WILD_CHARACTER 0x08 - -#define FSRTL_FAT_LEGAL 0x01 -#define FSRTL_HPFS_LEGAL 0x02 -#define FSRTL_NTFS_LEGAL 0x04 -#define FSRTL_WILD_CHARACTER 0x08 -#define FSRTL_OLE_LEGAL 0x10 -#define FSRTL_NTFS_STREAM_LEGAL 0x14 - #ifdef _X86_ #define HARDWARE_PTE HARDWARE_PTE_X86 #define PHARDWARE_PTE PHARDWARE_PTE_X86 #endif -#define IO_CHECK_CREATE_PARAMETERS 0x0200 -#define IO_ATTACH_DEVICE 0x0400 - #define IO_ATTACH_DEVICE_API 0x80000000 #define IO_TYPE_APC 18 @@ -6932,8 +8935,6 @@ extern PACL SeSystemDefaultDacl; #define MEM_DOS_LIM 0x40000000 -#define MCB_FLAG_RAISE_ON_ALLOCATION_FAILURE 1 - #define OB_TYPE_TYPE 1 #define OB_TYPE_DIRECTORY 2 #define OB_TYPE_SYMBOLIC_LINK 3 @@ -6958,23 +8959,12 @@ extern PACL SeSystemDefaultDacl; #define OB_TYPE_IO_COMPLETION 22 #define OB_TYPE_FILE 23 -#define PIN_WAIT (1) -#define PIN_EXCLUSIVE (2) -#define PIN_NO_READ (4) -#define PIN_IF_BCB (8) - #define SEC_BASED 0x00200000 -#define SECURITY_WORLD_SID_AUTHORITY {0,0,0,0,0,1} -#define SECURITY_WORLD_RID (0x00000000L) - /* end winnt.h */ #define TOKEN_HAS_ADMIN_GROUP 0x08 -#define VACB_MAPPING_GRANULARITY (0x40000) -#define VACB_OFFSET_SHIFT (18) - #if (VER_PRODUCTBUILD >= 1381) #define FSCTL_GET_HFS_INFORMATION CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 31, METHOD_BUFFERED, FILE_ANY_ACCESS) #endif /* (VER_PRODUCTBUILD >= 1381) */ @@ -7001,18 +8991,6 @@ extern PACL SeSystemDefaultDacl; #define FSCTL_NETWORK_SET_DOMAIN_NAME CTL_CODE(FILE_DEVICE_NETWORK_FILE_SYSTEM, 120, METHOD_BUFFERED, FILE_ANY_ACCESS) #define FSCTL_NETWORK_REMOTE_BOOT_INIT_SCRT CTL_CODE(FILE_DEVICE_NETWORK_FILE_SYSTEM, 250, METHOD_BUFFERED, FILE_ANY_ACCESS) -#define IOCTL_REDIR_QUERY_PATH CTL_CODE(FILE_DEVICE_NETWORK_FILE_SYSTEM, 99, METHOD_NEITHER, FILE_ANY_ACCESS) - -typedef PVOID OPLOCK, *POPLOCK; - -// -// Forwarders -// -struct _RTL_AVL_TABLE; -struct _RTL_GENERIC_TABLE; - -typedef PVOID PNOTIFY_SYNC; - typedef enum _FILE_STORAGE_TYPE { StorageTypeDefault = 1, StorageTypeDirectory, @@ -7048,17 +9026,6 @@ typedef struct _BITMAP_RANGE { PULONG Bitmap; } BITMAP_RANGE, *PBITMAP_RANGE; -typedef struct _CACHE_UNINITIALIZE_EVENT { - struct _CACHE_UNINITIALIZE_EVENT *Next; - KEVENT Event; -} CACHE_UNINITIALIZE_EVENT, *PCACHE_UNINITIALIZE_EVENT; - -typedef struct _CC_FILE_SIZES { - LARGE_INTEGER AllocationSize; - LARGE_INTEGER FileSize; - LARGE_INTEGER ValidDataLength; -} CC_FILE_SIZES, *PCC_FILE_SIZES; - typedef struct _FILE_COPY_ON_WRITE_INFORMATION { BOOLEAN ReplaceIfExists; HANDLE RootDirectory; @@ -7081,49 +9048,6 @@ typedef struct _FILE_FULL_DIRECTORY_INFORMATION { WCHAR FileName[ANYSIZE_ARRAY]; } FILE_FULL_DIRECTORY_INFORMATION, *PFILE_FULL_DIRECTORY_INFORMATION; -typedef struct _FILE_FS_FULL_SIZE_INFORMATION { - LARGE_INTEGER TotalAllocationUnits; - LARGE_INTEGER CallerAvailableAllocationUnits; - LARGE_INTEGER ActualAvailableAllocationUnits; - ULONG SectorsPerAllocationUnit; - ULONG BytesPerSector; -} FILE_FS_FULL_SIZE_INFORMATION, *PFILE_FS_FULL_SIZE_INFORMATION; - -typedef struct _FILE_FS_LABEL_INFORMATION { - ULONG VolumeLabelLength; - WCHAR VolumeLabel[1]; -} FILE_FS_LABEL_INFORMATION, *PFILE_FS_LABEL_INFORMATION; - -#if (VER_PRODUCTBUILD >= 2195) - -typedef struct _FILE_FS_OBJECT_ID_INFORMATION { - UCHAR ObjectId[16]; - UCHAR ExtendedInfo[48]; -} FILE_FS_OBJECT_ID_INFORMATION, *PFILE_FS_OBJECT_ID_INFORMATION; - -#endif /* (VER_PRODUCTBUILD >= 2195) */ - -typedef struct _FILE_FS_SIZE_INFORMATION { - LARGE_INTEGER TotalAllocationUnits; - LARGE_INTEGER AvailableAllocationUnits; - ULONG SectorsPerAllocationUnit; - ULONG BytesPerSector; -} FILE_FS_SIZE_INFORMATION, *PFILE_FS_SIZE_INFORMATION; - -typedef struct _FILE_FS_VOLUME_INFORMATION { - LARGE_INTEGER VolumeCreationTime; - ULONG VolumeSerialNumber; - ULONG VolumeLabelLength; - BOOLEAN SupportsObjects; - WCHAR VolumeLabel[1]; -} FILE_FS_VOLUME_INFORMATION, *PFILE_FS_VOLUME_INFORMATION; - -typedef struct _FILE_FS_OBJECTID_INFORMATION -{ - UCHAR ObjectId[16]; - UCHAR ExtendedInfo[48]; -} FILE_FS_OBJECTID_INFORMATION, *PFILE_FS_OBJECTID_INFORMATION; - /* raw internal file lock struct returned from FsRtlGetNextFileLock */ typedef struct _FILE_SHARED_LOCK_ENTRY { PVOID Unknown1; @@ -7208,51 +9132,6 @@ typedef struct _FILE_OLE_STATE_BITS_INFORMATION { ULONG StateBitsMask; } FILE_OLE_STATE_BITS_INFORMATION, *PFILE_OLE_STATE_BITS_INFORMATION; -typedef enum _FSRTL_COMPARISON_RESULT -{ - LessThan = -1, - EqualTo = 0, - GreaterThan = 1 -} FSRTL_COMPARISON_RESULT; - -#if (VER_PRODUCTBUILD >= 2600) - -typedef struct _FSRTL_PER_STREAM_CONTEXT { - LIST_ENTRY Links; - PVOID OwnerId; - PVOID InstanceId; - PFREE_FUNCTION FreeCallback; -} FSRTL_PER_STREAM_CONTEXT, *PFSRTL_PER_STREAM_CONTEXT; - -typedef struct _FSRTL_PER_FILEOBJECT_CONTEXT -{ - LIST_ENTRY Links; - PVOID OwnerId; - PVOID InstanceId; -} FSRTL_PER_FILEOBJECT_CONTEXT, *PFSRTL_PER_FILEOBJECT_CONTEXT; - -#endif /* (VER_PRODUCTBUILD >= 2600) */ - -typedef struct _BASE_MCB -{ - ULONG MaximumPairCount; - ULONG PairCount; - USHORT PoolType; - USHORT Flags; - PVOID Mapping; -} BASE_MCB, *PBASE_MCB; - -typedef struct _LARGE_MCB -{ - PKGUARDED_MUTEX GuardedMutex; - BASE_MCB BaseMcb; -} LARGE_MCB, *PLARGE_MCB; - -typedef struct _MCB -{ - LARGE_MCB DummyFieldThatSizesThisStructureCorrectly; -} MCB, *PMCB; - typedef struct _MAPPING_PAIR { ULONGLONG Vcn; ULONGLONG Lcn; @@ -7264,8 +9143,6 @@ typedef struct _GET_RETRIEVAL_DESCRIPTOR { MAPPING_PAIR Pair[1]; } GET_RETRIEVAL_DESCRIPTOR, *PGET_RETRIEVAL_DESCRIPTOR; -#define ASSERT_QUEUE(Q) ASSERT(((Q)->Header.Type & KOBJECT_TYPE_MASK) == QueueObject); - typedef struct _MBCB { CSHORT NodeTypeCode; CSHORT NodeIsInZone; @@ -7328,189 +9205,6 @@ typedef struct _OBJECT_ALL_TYPES_INFO { OBJECT_TYPE_INFO ObjectsTypeInfo[1]; } OBJECT_ALL_TYPES_INFO, *POBJECT_ALL_TYPES_INFO; -typedef enum _RTL_GENERIC_COMPARE_RESULTS -{ - GenericLessThan, - GenericGreaterThan, - GenericEqual -} RTL_GENERIC_COMPARE_RESULTS; - -typedef enum _TABLE_SEARCH_RESULT -{ - TableEmptyTree, - TableFoundNode, - TableInsertAsLeft, - TableInsertAsRight -} TABLE_SEARCH_RESULT; - -typedef NTSTATUS -(NTAPI *PRTL_AVL_MATCH_FUNCTION)( - struct _RTL_AVL_TABLE *Table, - PVOID UserData, - PVOID MatchData -); - -typedef RTL_GENERIC_COMPARE_RESULTS -(NTAPI *PRTL_AVL_COMPARE_ROUTINE) ( - struct _RTL_AVL_TABLE *Table, - PVOID FirstStruct, - PVOID SecondStruct -); - -typedef RTL_GENERIC_COMPARE_RESULTS -(NTAPI *PRTL_GENERIC_COMPARE_ROUTINE) ( - struct _RTL_GENERIC_TABLE *Table, - PVOID FirstStruct, - PVOID SecondStruct -); - -typedef PVOID -(NTAPI *PRTL_GENERIC_ALLOCATE_ROUTINE) ( - struct _RTL_GENERIC_TABLE *Table, - CLONG ByteSize -); - -typedef VOID -(NTAPI *PRTL_GENERIC_FREE_ROUTINE) ( - struct _RTL_GENERIC_TABLE *Table, - PVOID Buffer -); - -typedef PVOID -(NTAPI *PRTL_AVL_ALLOCATE_ROUTINE) ( - struct _RTL_AVL_TABLE *Table, - CLONG ByteSize -); - -typedef VOID -(NTAPI *PRTL_AVL_FREE_ROUTINE) ( - struct _RTL_AVL_TABLE *Table, - PVOID Buffer -); - -typedef struct _PUBLIC_BCB { - CSHORT NodeTypeCode; - CSHORT NodeByteSize; - ULONG MappedLength; - LARGE_INTEGER MappedFileOffset; -} PUBLIC_BCB, *PPUBLIC_BCB; - -typedef struct _QUERY_PATH_REQUEST { - ULONG PathNameLength; - PIO_SECURITY_CONTEXT SecurityContext; - WCHAR FilePathName[1]; -} QUERY_PATH_REQUEST, *PQUERY_PATH_REQUEST; - -typedef struct _QUERY_PATH_RESPONSE { - ULONG LengthAccepted; -} QUERY_PATH_RESPONSE, *PQUERY_PATH_RESPONSE; - -typedef struct _RTL_BALANCED_LINKS -{ - struct _RTL_BALANCED_LINKS *Parent; - struct _RTL_BALANCED_LINKS *LeftChild; - struct _RTL_BALANCED_LINKS *RightChild; - CHAR Balance; - UCHAR Reserved[3]; -} RTL_BALANCED_LINKS, *PRTL_BALANCED_LINKS; - -typedef struct _RTL_GENERIC_TABLE -{ - PRTL_SPLAY_LINKS TableRoot; - LIST_ENTRY InsertOrderList; - PLIST_ENTRY OrderedPointer; - ULONG WhichOrderedElement; - ULONG NumberGenericTableElements; - PRTL_GENERIC_COMPARE_ROUTINE CompareRoutine; - PRTL_GENERIC_ALLOCATE_ROUTINE AllocateRoutine; - PRTL_GENERIC_FREE_ROUTINE FreeRoutine; - PVOID TableContext; -} RTL_GENERIC_TABLE, *PRTL_GENERIC_TABLE; - -#undef PRTL_GENERIC_COMPARE_ROUTINE -#undef PRTL_GENERIC_ALLOCATE_ROUTINE -#undef PRTL_GENERIC_FREE_ROUTINE -#undef RTL_GENERIC_TABLE -#undef PRTL_GENERIC_TABLE - -#define PRTL_GENERIC_COMPARE_ROUTINE PRTL_AVL_COMPARE_ROUTINE -#define PRTL_GENERIC_ALLOCATE_ROUTINE PRTL_AVL_ALLOCATE_ROUTINE -#define PRTL_GENERIC_FREE_ROUTINE PRTL_AVL_FREE_ROUTINE -#define RTL_GENERIC_TABLE RTL_AVL_TABLE -#define PRTL_GENERIC_TABLE PRTL_AVL_TABLE - -#define RtlInitializeGenericTable RtlInitializeGenericTableAvl -#define RtlInsertElementGenericTable RtlInsertElementGenericTableAvl -#define RtlInsertElementGenericTableFull RtlInsertElementGenericTableFullAvl -#define RtlDeleteElementGenericTable RtlDeleteElementGenericTableAvl -#define RtlLookupElementGenericTable RtlLookupElementGenericTableAvl -#define RtlLookupElementGenericTableFull RtlLookupElementGenericTableFullAvl -#define RtlEnumerateGenericTable RtlEnumerateGenericTableAvl -#define RtlEnumerateGenericTableWithoutSplaying RtlEnumerateGenericTableWithoutSplayingAvl -#define RtlGetElementGenericTable RtlGetElementGenericTableAvl -#define RtlNumberGenericTableElements RtlNumberGenericTableElementsAvl -#define RtlIsGenericTableEmpty RtlIsGenericTableEmptyAvl - -typedef struct _RTL_AVL_TABLE -{ - RTL_BALANCED_LINKS BalancedRoot; - PVOID OrderedPointer; - ULONG WhichOrderedElement; - ULONG NumberGenericTableElements; - ULONG DepthOfTree; - PRTL_BALANCED_LINKS RestartKey; - ULONG DeleteCount; - PRTL_AVL_COMPARE_ROUTINE CompareRoutine; - PRTL_AVL_ALLOCATE_ROUTINE AllocateRoutine; - PRTL_AVL_FREE_ROUTINE FreeRoutine; - PVOID TableContext; -} RTL_AVL_TABLE, *PRTL_AVL_TABLE; - -NTSYSAPI -VOID -NTAPI -RtlInitializeGenericTableAvl( - PRTL_AVL_TABLE Table, - PRTL_AVL_COMPARE_ROUTINE CompareRoutine, - PRTL_AVL_ALLOCATE_ROUTINE AllocateRoutine, - PRTL_AVL_FREE_ROUTINE FreeRoutine, - PVOID TableContext -); - -NTSYSAPI -PVOID -NTAPI -RtlInsertElementGenericTableAvl ( - PRTL_AVL_TABLE Table, - PVOID Buffer, - CLONG BufferSize, - PBOOLEAN NewElement OPTIONAL - ); - -NTSYSAPI -BOOLEAN -NTAPI -RtlDeleteElementGenericTableAvl ( - PRTL_AVL_TABLE Table, - PVOID Buffer - ); - -NTSYSAPI -PVOID -NTAPI -RtlLookupElementGenericTableAvl ( - PRTL_AVL_TABLE Table, - PVOID Buffer - ); - -NTSYSAPI -PVOID -NTAPI -RtlEnumerateGenericTableWithoutSplayingAvl ( - PRTL_AVL_TABLE Table, - PVOID *RestartKey - ); - #if defined(USE_LPC6432) #define LPC_CLIENT_ID CLIENT_ID64 #define LPC_SIZE_T ULONGLONG @@ -7575,13 +9269,6 @@ typedef struct _REMOTE_PORT_VIEW LPC_PVOID ViewBase; } REMOTE_PORT_VIEW, *PREMOTE_PORT_VIEW; -typedef struct _TUNNEL { - FAST_MUTEX Mutex; - PRTL_SPLAY_LINKS Cache; - LIST_ENTRY TimerQueue; - USHORT NumEntries; -} TUNNEL, *PTUNNEL; - typedef struct _VAD_HEADER { PVOID StartVPN; PVOID EndVPN; @@ -7596,150 +9283,6 @@ typedef struct _VAD_HEADER { LIST_ENTRY Secured; } VAD_HEADER, *PVAD_HEADER; -#if (VER_PRODUCTBUILD >= 2600) - -typedef BOOLEAN -(NTAPI *PFILTER_REPORT_CHANGE) ( - IN PVOID NotifyContext, - IN PVOID FilterContext -); - -#endif - -NTKERNELAPI -BOOLEAN -NTAPI -CcCanIWrite ( - IN PFILE_OBJECT FileObject, - IN ULONG BytesToWrite, - IN BOOLEAN Wait, - IN BOOLEAN Retrying -); - -NTKERNELAPI -BOOLEAN -NTAPI -CcCopyRead ( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN BOOLEAN Wait, - OUT PVOID Buffer, - OUT PIO_STATUS_BLOCK IoStatus -); - -NTKERNELAPI -BOOLEAN -NTAPI -CcCopyWrite ( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN BOOLEAN Wait, - IN PVOID Buffer -); - -#define CcCopyWriteWontFlush(FO, FOFF, LEN) ((LEN) <= 0x10000) - -typedef VOID (NTAPI *PCC_POST_DEFERRED_WRITE) ( - IN PVOID Context1, - IN PVOID Context2 -); - -NTKERNELAPI -VOID -NTAPI -CcDeferWrite ( - IN PFILE_OBJECT FileObject, - IN PCC_POST_DEFERRED_WRITE PostRoutine, - IN PVOID Context1, - IN PVOID Context2, - IN ULONG BytesToWrite, - IN BOOLEAN Retrying -); - -NTKERNELAPI -VOID -NTAPI -CcFastCopyRead ( - IN PFILE_OBJECT FileObject, - IN ULONG FileOffset, - IN ULONG Length, - IN ULONG PageCount, - OUT PVOID Buffer, - OUT PIO_STATUS_BLOCK IoStatus -); - -NTKERNELAPI -VOID -NTAPI -CcFastCopyWrite ( - IN PFILE_OBJECT FileObject, - IN ULONG FileOffset, - IN ULONG Length, - IN PVOID Buffer -); - -NTKERNELAPI -VOID -NTAPI -CcFlushCache ( - IN PSECTION_OBJECT_POINTERS SectionObjectPointer, - IN PLARGE_INTEGER FileOffset OPTIONAL, - IN ULONG Length, - OUT PIO_STATUS_BLOCK IoStatus OPTIONAL -); - -typedef VOID (NTAPI *PDIRTY_PAGE_ROUTINE) ( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN PLARGE_INTEGER OldestLsn, - IN PLARGE_INTEGER NewestLsn, - IN PVOID Context1, - IN PVOID Context2 -); - -NTKERNELAPI -LARGE_INTEGER -NTAPI -CcGetDirtyPages ( - IN PVOID LogHandle, - IN PDIRTY_PAGE_ROUTINE DirtyPageRoutine, - IN PVOID Context1, - IN PVOID Context2 -); - -NTKERNELAPI -PFILE_OBJECT -NTAPI -CcGetFileObjectFromBcb ( - IN PVOID Bcb -); - -NTKERNELAPI -PFILE_OBJECT -NTAPI -CcGetFileObjectFromSectionPtrs ( - IN PSECTION_OBJECT_POINTERS SectionObjectPointer -); - -#define CcGetFileSizePointer(FO) ( \ - ((PLARGE_INTEGER)((FO)->SectionObjectPointer->SharedCacheMap) + 1) \ -) - -#if (VER_PRODUCTBUILD >= 2195) - -NTKERNELAPI -LARGE_INTEGER -NTAPI -CcGetFlushedValidData ( - IN PSECTION_OBJECT_POINTERS SectionObjectPointer, - IN BOOLEAN BcbListHeld -); - -#endif /* (VER_PRODUCTBUILD >= 2195) */ - NTKERNELAPI LARGE_INTEGER NTAPI @@ -7748,428 +9291,6 @@ CcGetLsnForFileObject ( OUT PLARGE_INTEGER OldestLsn OPTIONAL ); -typedef BOOLEAN (NTAPI *PACQUIRE_FOR_LAZY_WRITE) ( - IN PVOID Context, - IN BOOLEAN Wait -); - -typedef VOID (NTAPI *PRELEASE_FROM_LAZY_WRITE) ( - IN PVOID Context -); - -typedef BOOLEAN (NTAPI *PACQUIRE_FOR_READ_AHEAD) ( - IN PVOID Context, - IN BOOLEAN Wait -); - -typedef VOID (NTAPI *PRELEASE_FROM_READ_AHEAD) ( - IN PVOID Context -); - -typedef struct _CACHE_MANAGER_CALLBACKS { - PACQUIRE_FOR_LAZY_WRITE AcquireForLazyWrite; - PRELEASE_FROM_LAZY_WRITE ReleaseFromLazyWrite; - PACQUIRE_FOR_READ_AHEAD AcquireForReadAhead; - PRELEASE_FROM_READ_AHEAD ReleaseFromReadAhead; -} CACHE_MANAGER_CALLBACKS, *PCACHE_MANAGER_CALLBACKS; - -NTKERNELAPI -VOID -NTAPI -CcInitializeCacheMap ( - IN PFILE_OBJECT FileObject, - IN PCC_FILE_SIZES FileSizes, - IN BOOLEAN PinAccess, - IN PCACHE_MANAGER_CALLBACKS Callbacks, - IN PVOID LazyWriteContext -); - -#define CcIsFileCached(FO) ( \ - ((FO)->SectionObjectPointer != NULL) && \ - (((PSECTION_OBJECT_POINTERS)(FO)->SectionObjectPointer)->SharedCacheMap != NULL) \ -) - -extern ULONG CcFastMdlReadWait; - -NTKERNELAPI -BOOLEAN -NTAPI -CcIsThereDirtyData ( - IN PVPB Vpb -); - -NTKERNELAPI -BOOLEAN -NTAPI -CcMapData ( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN ULONG Flags, - OUT PVOID *Bcb, - OUT PVOID *Buffer -); - -NTKERNELAPI -VOID -NTAPI -CcMdlRead ( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - OUT PMDL *MdlChain, - OUT PIO_STATUS_BLOCK IoStatus -); - -NTKERNELAPI -VOID -NTAPI -CcMdlReadComplete ( - IN PFILE_OBJECT FileObject, - IN PMDL MdlChain -); - -NTKERNELAPI -VOID -NTAPI -CcMdlWriteComplete ( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN PMDL MdlChain -); - -#define MAP_WAIT 1 - -NTKERNELAPI -BOOLEAN -NTAPI -CcPinMappedData ( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN ULONG Flags, - IN OUT PVOID *Bcb -); - -NTKERNELAPI -BOOLEAN -NTAPI -CcPinRead ( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN ULONG Flags, - OUT PVOID *Bcb, - OUT PVOID *Buffer -); - -NTKERNELAPI -VOID -NTAPI -CcPrepareMdlWrite ( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - OUT PMDL *MdlChain, - OUT PIO_STATUS_BLOCK IoStatus -); - -NTKERNELAPI -BOOLEAN -NTAPI -CcPreparePinWrite ( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN BOOLEAN Zero, - IN ULONG Flags, - OUT PVOID *Bcb, - OUT PVOID *Buffer -); - -NTKERNELAPI -BOOLEAN -NTAPI -CcPurgeCacheSection ( - IN PSECTION_OBJECT_POINTERS SectionObjectPointer, - IN PLARGE_INTEGER FileOffset OPTIONAL, - IN ULONG Length, - IN BOOLEAN UninitializeCacheMaps -); - -#define CcReadAhead(FO, FOFF, LEN) ( \ - if ((LEN) >= 256) { \ - CcScheduleReadAhead((FO), (FOFF), (LEN)); \ - } \ -) - -#if (VER_PRODUCTBUILD >= 2195) - -NTKERNELAPI -PVOID -NTAPI -CcRemapBcb ( - IN PVOID Bcb -); - -#endif /* (VER_PRODUCTBUILD >= 2195) */ - -NTKERNELAPI -VOID -NTAPI -CcRepinBcb ( - IN PVOID Bcb -); - -NTKERNELAPI -VOID -NTAPI -CcScheduleReadAhead ( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length -); - -NTKERNELAPI -VOID -NTAPI -CcSetAdditionalCacheAttributes ( - IN PFILE_OBJECT FileObject, - IN BOOLEAN DisableReadAhead, - IN BOOLEAN DisableWriteBehind -); - -NTKERNELAPI -VOID -NTAPI -CcSetBcbOwnerPointer ( - IN PVOID Bcb, - IN PVOID OwnerPointer -); - -NTKERNELAPI -VOID -NTAPI -CcSetDirtyPageThreshold ( - IN PFILE_OBJECT FileObject, - IN ULONG DirtyPageThreshold -); - -NTKERNELAPI -VOID -NTAPI -CcSetDirtyPinnedData ( - IN PVOID BcbVoid, - IN PLARGE_INTEGER Lsn OPTIONAL -); - -NTKERNELAPI -VOID -NTAPI -CcSetFileSizes ( - IN PFILE_OBJECT FileObject, - IN PCC_FILE_SIZES FileSizes -); - -typedef VOID (NTAPI *PFLUSH_TO_LSN) ( - IN PVOID LogHandle, - IN LARGE_INTEGER Lsn -); - -NTKERNELAPI -VOID -NTAPI -CcSetLogHandleForFile ( - IN PFILE_OBJECT FileObject, - IN PVOID LogHandle, - IN PFLUSH_TO_LSN FlushToLsnRoutine -); - -NTKERNELAPI -VOID -NTAPI -CcSetReadAheadGranularity ( - IN PFILE_OBJECT FileObject, - IN ULONG Granularity /* default: PAGE_SIZE */ - /* allowed: 2^n * PAGE_SIZE */ -); - -NTKERNELAPI -BOOLEAN -NTAPI -CcUninitializeCacheMap ( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER TruncateSize OPTIONAL, - IN PCACHE_UNINITIALIZE_EVENT UninitializeCompleteEvent OPTIONAL -); - -NTKERNELAPI -VOID -NTAPI -CcUnpinData ( - IN PVOID Bcb -); - -NTKERNELAPI -VOID -NTAPI -CcUnpinDataForThread ( - IN PVOID Bcb, - IN ERESOURCE_THREAD ResourceThreadId -); - -NTKERNELAPI -VOID -NTAPI -CcUnpinRepinnedBcb ( - IN PVOID Bcb, - IN BOOLEAN WriteThrough, - OUT PIO_STATUS_BLOCK IoStatus -); - -#if (VER_PRODUCTBUILD >= 2195) - -NTKERNELAPI -NTSTATUS -NTAPI -CcWaitForCurrentLazyWriterActivity ( - VOID -); - -#endif /* (VER_PRODUCTBUILD >= 2195) */ - -NTKERNELAPI -BOOLEAN -NTAPI -CcZeroData ( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER StartOffset, - IN PLARGE_INTEGER EndOffset, - IN BOOLEAN Wait -); - -#if (VER_PRODUCTBUILD >= 2600) - -#ifndef __NTOSKRNL__ -NTKERNELAPI -VOID -FASTCALL -ExInitializeRundownProtection ( - IN PEX_RUNDOWN_REF RunRef -); - -NTKERNELAPI -VOID -FASTCALL -ExReInitializeRundownProtection ( - IN PEX_RUNDOWN_REF RunRef -); - -NTKERNELAPI -BOOLEAN -FASTCALL -ExAcquireRundownProtection ( - IN PEX_RUNDOWN_REF RunRef -); - -NTKERNELAPI -BOOLEAN -FASTCALL -ExAcquireRundownProtectionEx ( - IN PEX_RUNDOWN_REF RunRef, - IN ULONG Count -); - -NTKERNELAPI -VOID -FASTCALL -ExReleaseRundownProtection ( - IN PEX_RUNDOWN_REF RunRef -); - -NTKERNELAPI -VOID -FASTCALL -ExReleaseRundownProtectionEx ( - IN PEX_RUNDOWN_REF RunRef, - IN ULONG Count -); - -NTKERNELAPI -VOID -FASTCALL -ExRundownCompleted ( - IN PEX_RUNDOWN_REF RunRef -); - -NTKERNELAPI -VOID -FASTCALL -ExWaitForRundownProtectionRelease ( - IN PEX_RUNDOWN_REF RunRef -); - -#endif -#endif /* (VER_PRODUCTBUILD >= 2600) */ - - -#define FsRtlSetupAdvancedHeader( _advhdr, _fmutx ) \ -{ \ - SetFlag( (_advhdr)->Flags, FSRTL_FLAG_ADVANCED_HEADER ); \ - SetFlag( (_advhdr)->Flags2, FSRTL_FLAG2_SUPPORTS_FILTER_CONTEXTS ); \ - (_advhdr)->Version = FSRTL_FCB_HEADER_V1; \ - InitializeListHead( &(_advhdr)->FilterContexts ); \ - if ((_fmutx) != NULL) { \ - (_advhdr)->FastMutex = (_fmutx); \ - } \ - *((PULONG_PTR)(&(_advhdr)->PushLock)) = 0; \ - /*ExInitializePushLock( &(_advhdr)->PushLock ); API Not avaliable downlevel*/\ - (_advhdr)->FileContextSupportPointer = NULL; \ -} - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlAddBaseMcbEntry ( - IN PBASE_MCB Mcb, - IN LONGLONG Vbn, - IN LONGLONG Lbn, - IN LONGLONG SectorCount -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlAddLargeMcbEntry ( - IN PLARGE_MCB Mcb, - IN LONGLONG Vbn, - IN LONGLONG Lbn, - IN LONGLONG SectorCount -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlAddMcbEntry ( - IN PMCB Mcb, - IN VBN Vbn, - IN LBN Lbn, - IN ULONG SectorCount -); - -NTKERNELAPI -VOID -NTAPI -FsRtlAddToTunnelCache ( - IN PTUNNEL Cache, - IN ULONGLONG DirectoryKey, - IN PUNICODE_STRING ShortName, - IN PUNICODE_STRING LongName, - IN BOOLEAN KeyByShortName, - IN ULONG DataLength, - IN PVOID Data -); - NTKERNELAPI PVOID NTAPI @@ -8204,251 +9325,6 @@ FsRtlAllocatePoolWithTag ( IN ULONG Tag ); -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlAreNamesEqual ( - IN PCUNICODE_STRING Name1, - IN PCUNICODE_STRING Name2, - IN BOOLEAN IgnoreCase, - IN PCWCH UpcaseTable OPTIONAL -); - -#define FsRtlAreThereCurrentFileLocks(FL) ( \ - ((FL)->FastIoIsQuestionable) \ -) - -typedef -VOID -(NTAPI*POPLOCK_WAIT_COMPLETE_ROUTINE) ( - IN PVOID Context, - IN PIRP Irp -); - -typedef -VOID -(NTAPI*POPLOCK_FS_PREPOST_IRP) ( - IN PVOID Context, - IN PIRP Irp -); - -NTKERNELAPI -NTSTATUS -NTAPI -FsRtlCheckOplock ( - IN POPLOCK Oplock, - IN PIRP Irp, - IN PVOID Context, - IN POPLOCK_WAIT_COMPLETE_ROUTINE CompletionRoutine OPTIONAL, - IN POPLOCK_FS_PREPOST_IRP PostIrpRoutine OPTIONAL -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlCurrentBatchOplock ( - IN POPLOCK Oplock -); - -NTKERNELAPI -VOID -NTAPI -FsRtlDeleteKeyFromTunnelCache ( - IN PTUNNEL Cache, - IN ULONGLONG DirectoryKey -); - -NTKERNELAPI -VOID -NTAPI -FsRtlDeleteTunnelCache ( - IN PTUNNEL Cache -); - -NTKERNELAPI -VOID -NTAPI -FsRtlDeregisterUncProvider ( - IN HANDLE Handle -); - -NTKERNELAPI -VOID -NTAPI -FsRtlDissectDbcs ( - IN ANSI_STRING Name, - OUT PANSI_STRING FirstPart, - OUT PANSI_STRING RemainingPart -); - -NTKERNELAPI -VOID -NTAPI -FsRtlDissectName ( - IN UNICODE_STRING Name, - OUT PUNICODE_STRING FirstPart, - OUT PUNICODE_STRING RemainingPart -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlDoesDbcsContainWildCards ( - IN PANSI_STRING Name -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlDoesNameContainWildCards ( - IN PUNICODE_STRING Name -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlIsFatDbcsLegal ( - IN ANSI_STRING DbcsName, - IN BOOLEAN WildCardsPermissible, - IN BOOLEAN PathNamePermissible, - IN BOOLEAN LeadingBackslashPermissible - ); - - -#define FsRtlCompleteRequest(IRP,STATUS) { \ - (IRP)->IoStatus.Status = (STATUS); \ - IoCompleteRequest( (IRP), IO_DISK_INCREMENT ); \ -} - -#define FsRtlEnterFileSystem KeEnterCriticalRegion - -#define FsRtlExitFileSystem KeLeaveCriticalRegion - -#define FsRtlFastLock(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11) ( \ - FsRtlPrivateLock(A1, A2, A3, A4, A5, A6, A7, A8, A9, NULL, A10, A11) \ -) - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlFindInTunnelCache ( - IN PTUNNEL Cache, - IN ULONGLONG DirectoryKey, - IN PUNICODE_STRING Name, - OUT PUNICODE_STRING ShortName, - OUT PUNICODE_STRING LongName, - IN OUT PULONG DataLength, - OUT PVOID Data -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlGetNextBaseMcbEntry ( - IN PBASE_MCB Mcb, - IN ULONG RunIndex, - OUT PLONGLONG Vbn, - OUT PLONGLONG Lbn, - OUT PLONGLONG SectorCount -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlGetNextLargeMcbEntry ( - IN PLARGE_MCB Mcb, - IN ULONG RunIndex, - OUT PLONGLONG Vbn, - OUT PLONGLONG Lbn, - OUT PLONGLONG SectorCount -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlGetNextMcbEntry ( - IN PMCB Mcb, - IN ULONG RunIndex, - OUT PVBN Vbn, - OUT PLBN Lbn, - OUT PULONG SectorCount -); - -#define FsRtlGetPerStreamContextPointer(FO) ( \ - (PFSRTL_ADVANCED_FCB_HEADER)(FO)->FsContext \ -) - -NTKERNELAPI -VOID -NTAPI -FsRtlInitializeBaseMcb ( - IN PBASE_MCB Mcb, - IN POOL_TYPE PoolType -); - -NTKERNELAPI -VOID -NTAPI -FsRtlInitializeLargeMcb ( - IN PLARGE_MCB Mcb, - IN POOL_TYPE PoolType -); - -NTKERNELAPI -VOID -NTAPI -FsRtlInitializeMcb ( - IN PMCB Mcb, - IN POOL_TYPE PoolType -); - -NTKERNELAPI -VOID -NTAPI -FsRtlInitializeOplock ( - IN OUT POPLOCK Oplock -); - -NTKERNELAPI -VOID -NTAPI -FsRtlInitializeTunnelCache ( - IN PTUNNEL Cache -); - -#define FsRtlInitPerStreamContext(PSC, O, I, FC) ( \ - (PSC)->OwnerId = (O), \ - (PSC)->InstanceId = (I), \ - (PSC)->FreeCallback = (FC) \ -) - -NTKERNELAPI -NTSTATUS -NTAPI -FsRtlInsertPerStreamContext ( - IN PFSRTL_ADVANCED_FCB_HEADER PerStreamContext, - IN PFSRTL_PER_STREAM_CONTEXT Ptr -); - -#define FsRtlIsAnsiCharacterLegalFat(C, WILD) ( \ - FlagOn(FsRtlLegalAnsiCharacterArray[(UCHAR)(C)], (FSRTL_FAT_LEGAL) | \ - ((WILD) ? FSRTL_WILD_CHARACTER : 0 )) \ -) - -#define FsRtlIsAnsiCharacterLegalHpfs(C, WILD) ( \ - FlagOn(FsRtlLegalAnsiCharacterArray[(UCHAR)(C)], (FSRTL_HPFS_LEGAL) | \ - ((WILD) ? FSRTL_WILD_CHARACTER : 0 )) \ -) - -#define FsRtlIsAnsiCharacterLegalNtfs(C, WILD) ( \ - FlagOn(FsRtlLegalAnsiCharacterArray[(UCHAR)(C)], (FSRTL_NTFS_LEGAL) | \ - ((WILD) ? FSRTL_WILD_CHARACTER : 0 )) \ -) - -#define FsRtlIsAnsiCharacterWild(C) ( \ - FlagOn(FsRtlLegalAnsiCharacterArray[(UCHAR)(C)], FSRTL_WILD_CHARACTER ) \ -) - NTKERNELAPI BOOLEAN NTAPI @@ -8459,142 +9335,6 @@ FsRtlIsFatDbcsLegal ( IN BOOLEAN LeadingBackslashPermissible ); -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlIsHpfsDbcsLegal ( - IN ANSI_STRING DbcsName, - IN BOOLEAN WildCardsPermissible, - IN BOOLEAN PathNamePermissible, - IN BOOLEAN LeadingBackslashPermissible -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlIsNameInExpression ( - IN PUNICODE_STRING Expression, - IN PUNICODE_STRING Name, - IN BOOLEAN IgnoreCase, - IN PWCHAR UpcaseTable OPTIONAL -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlIsNtstatusExpected ( - IN NTSTATUS Ntstatus -); - -#define NLS_OEM_LEAD_BYTE_INFO NlsOemLeadByteInfo - -extern PUSHORT NlsOemLeadByteInfo; - -#define FsRtlIsLeadDbcsCharacter(DBCS_CHAR) ( \ - (BOOLEAN)((UCHAR)(DBCS_CHAR) < 0x80 ? FALSE : \ - (NLS_MB_CODE_PAGE_TAG && \ - (NLS_OEM_LEAD_BYTE_INFO[(UCHAR)(DBCS_CHAR)] != 0))) \ -) - -#define FsRtlIsUnicodeCharacterWild(C) ( \ - (((C) >= 0x40) ? \ - FALSE : \ - FlagOn(FsRtlLegalAnsiCharacterArray[(C)], FSRTL_WILD_CHARACTER )) \ -) - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlLookupBaseMcbEntry ( - IN PBASE_MCB Mcb, - IN LONGLONG Vbn, - OUT PLONGLONG Lbn OPTIONAL, - OUT PLONGLONG SectorCountFromLbn OPTIONAL, - OUT PLONGLONG StartingLbn OPTIONAL, - OUT PLONGLONG SectorCountFromStartingLbn OPTIONAL, - OUT PULONG Index OPTIONAL -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlLookupLargeMcbEntry ( - IN PLARGE_MCB Mcb, - IN LONGLONG Vbn, - OUT PLONGLONG Lbn OPTIONAL, - OUT PLONGLONG SectorCountFromLbn OPTIONAL, - OUT PLONGLONG StartingLbn OPTIONAL, - OUT PLONGLONG SectorCountFromStartingLbn OPTIONAL, - OUT PULONG Index OPTIONAL -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlLookupLastBaseMcbEntry ( - IN PBASE_MCB Mcb, - OUT PLONGLONG Vbn, - OUT PLONGLONG Lbn -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlLookupLastLargeMcbEntry ( - IN PLARGE_MCB Mcb, - OUT PLONGLONG Vbn, - OUT PLONGLONG Lbn -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlLookupLastMcbEntry ( - IN PMCB Mcb, - OUT PVBN Vbn, - OUT PLBN Lbn -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlLookupLastBaseMcbEntryAndIndex ( - IN PBASE_MCB OpaqueMcb, - IN OUT PLONGLONG LargeVbn, - IN OUT PLONGLONG LargeLbn, - IN OUT PULONG Index -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlLookupLastLargeMcbEntryAndIndex ( - IN PLARGE_MCB OpaqueMcb, - OUT PLONGLONG LargeVbn, - OUT PLONGLONG LargeLbn, - OUT PULONG Index -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlLookupMcbEntry ( - IN PMCB Mcb, - IN VBN Vbn, - OUT PLBN Lbn, - OUT PULONG SectorCount OPTIONAL, - OUT PULONG Index -); - -NTKERNELAPI -PFSRTL_PER_STREAM_CONTEXT -NTAPI -FsRtlLookupPerStreamContextInternal ( - IN PFSRTL_ADVANCED_FCB_HEADER StreamContext, - IN PVOID OwnerId OPTIONAL, - IN PVOID InstanceId OPTIONAL -); - NTKERNELAPI BOOLEAN NTAPI @@ -8612,14 +9352,6 @@ FsRtlMdlWriteComplete ( IN PMDL MdlChain ); -NTKERNELAPI -NTSTATUS -NTAPI -FsRtlNormalizeNtstatus ( - IN NTSTATUS Exception, - IN NTSTATUS GenericException -); - NTKERNELAPI VOID NTAPI @@ -8633,315 +9365,6 @@ FsRtlNotifyChangeDirectory ( IN PIRP NotifyIrp ); -NTKERNELAPI -VOID -NTAPI -FsRtlNotifyCleanup ( - IN PNOTIFY_SYNC NotifySync, - IN PLIST_ENTRY NotifyList, - IN PVOID FsContext -); - -typedef BOOLEAN (NTAPI *PCHECK_FOR_TRAVERSE_ACCESS) ( - IN PVOID NotifyContext, - IN PVOID TargetContext, - IN PSECURITY_SUBJECT_CONTEXT SubjectContext -); - -NTKERNELAPI -VOID -NTAPI -FsRtlNotifyFilterChangeDirectory ( - IN PNOTIFY_SYNC NotifySync, - IN PLIST_ENTRY NotifyList, - IN PVOID FsContext, - IN PSTRING FullDirectoryName, - IN BOOLEAN WatchTree, - IN BOOLEAN IgnoreBuffer, - IN ULONG CompletionFilter, - IN PIRP NotifyIrp, - IN PCHECK_FOR_TRAVERSE_ACCESS TraverseCallback OPTIONAL, - IN PSECURITY_SUBJECT_CONTEXT SubjectContext OPTIONAL, - IN PFILTER_REPORT_CHANGE FilterCallback OPTIONAL); - -NTKERNELAPI -VOID -NTAPI -FsRtlNotifyFilterReportChange ( - IN PNOTIFY_SYNC NotifySync, - IN PLIST_ENTRY NotifyList, - IN PSTRING FullTargetName, - IN USHORT TargetNameOffset, - IN PSTRING StreamName OPTIONAL, - IN PSTRING NormalizedParentName OPTIONAL, - IN ULONG FilterMatch, - IN ULONG Action, - IN PVOID TargetContext, - IN PVOID FilterContext); - -NTKERNELAPI -VOID -NTAPI -FsRtlNotifyFullChangeDirectory ( - IN PNOTIFY_SYNC NotifySync, - IN PLIST_ENTRY NotifyList, - IN PVOID FsContext, - IN PSTRING FullDirectoryName, - IN BOOLEAN WatchTree, - IN BOOLEAN IgnoreBuffer, - IN ULONG CompletionFilter, - IN PIRP NotifyIrp, - IN PCHECK_FOR_TRAVERSE_ACCESS TraverseCallback OPTIONAL, - IN PSECURITY_SUBJECT_CONTEXT SubjectContext OPTIONAL -); - -NTKERNELAPI -VOID -NTAPI -FsRtlNotifyFullReportChange ( - IN PNOTIFY_SYNC NotifySync, - IN PLIST_ENTRY NotifyList, - IN PSTRING FullTargetName, - IN USHORT TargetNameOffset, - IN PSTRING StreamName OPTIONAL, - IN PSTRING NormalizedParentName OPTIONAL, - IN ULONG FilterMatch, - IN ULONG Action, - IN PVOID TargetContext -); - -NTKERNELAPI -VOID -NTAPI -FsRtlNotifyInitializeSync ( - IN PNOTIFY_SYNC *NotifySync -); - -NTKERNELAPI -VOID -NTAPI -FsRtlNotifyUninitializeSync ( - IN PNOTIFY_SYNC *NotifySync -); - -#if (VER_PRODUCTBUILD >= 2195) - -NTKERNELAPI -NTSTATUS -NTAPI -FsRtlNotifyVolumeEvent ( - IN PFILE_OBJECT FileObject, - IN ULONG EventCode -); - -#endif /* (VER_PRODUCTBUILD >= 2195) */ - -NTKERNELAPI -ULONG -NTAPI -FsRtlNumberOfRunsInBaseMcb ( - IN PBASE_MCB Mcb -); - -NTKERNELAPI -ULONG -NTAPI -FsRtlNumberOfRunsInLargeMcb ( - IN PLARGE_MCB Mcb -); - -NTKERNELAPI -ULONG -NTAPI -FsRtlNumberOfRunsInMcb ( - IN PMCB Mcb -); - -NTKERNELAPI -NTSTATUS -NTAPI -FsRtlOplockFsctrl ( - IN POPLOCK Oplock, - IN PIRP Irp, - IN ULONG OpenCount -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlOplockIsFastIoPossible ( - IN POPLOCK Oplock -); - -typedef VOID -(NTAPI *PFSRTL_STACK_OVERFLOW_ROUTINE) ( - IN PVOID Context, - IN PKEVENT Event -); - -NTKERNELAPI -VOID -NTAPI -FsRtlPostPagingFileStackOverflow ( - IN PVOID Context, - IN PKEVENT Event, - IN PFSRTL_STACK_OVERFLOW_ROUTINE StackOverflowRoutine -); - -NTKERNELAPI -VOID -NTAPI -FsRtlPostStackOverflow ( - IN PVOID Context, - IN PKEVENT Event, - IN PFSRTL_STACK_OVERFLOW_ROUTINE StackOverflowRoutine -); - -NTKERNELAPI -NTSTATUS -NTAPI -FsRtlRegisterUncProvider ( - IN OUT PHANDLE MupHandle, - IN PUNICODE_STRING RedirectorDeviceName, - IN BOOLEAN MailslotsSupported -); - -NTKERNELAPI -VOID -NTAPI -FsRtlRemoveBaseMcbEntry ( - IN PBASE_MCB Mcb, - IN LONGLONG Vbn, - IN LONGLONG SectorCount -); - -NTKERNELAPI -VOID -NTAPI -FsRtlRemoveLargeMcbEntry ( - IN PLARGE_MCB Mcb, - IN LONGLONG Vbn, - IN LONGLONG SectorCount -); - -NTKERNELAPI -VOID -NTAPI -FsRtlRemoveMcbEntry ( - IN PMCB Mcb, - IN VBN Vbn, - IN ULONG SectorCount -); - -NTKERNELAPI -PFSRTL_PER_STREAM_CONTEXT -NTAPI -FsRtlRemovePerStreamContext ( - IN PFSRTL_ADVANCED_FCB_HEADER StreamContext, - IN PVOID OwnerId OPTIONAL, - IN PVOID InstanceId OPTIONAL -); - -NTKERNELAPI -VOID -NTAPI -FsRtlResetBaseMcb ( - IN PBASE_MCB Mcb -); - -NTKERNELAPI -VOID -NTAPI -FsRtlResetLargeMcb ( - IN PLARGE_MCB Mcb, - IN BOOLEAN SelfSynchronized -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlSplitBaseMcb ( - IN PBASE_MCB Mcb, - IN LONGLONG Vbn, - IN LONGLONG Amount -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlSplitLargeMcb ( - IN PLARGE_MCB Mcb, - IN LONGLONG Vbn, - IN LONGLONG Amount -); - -#define FsRtlSupportsPerStreamContexts(FO) ( \ - (BOOLEAN)((NULL != FsRtlGetPerStreamContextPointer(FO) && \ - FlagOn(FsRtlGetPerStreamContextPointer(FO)->Flags2, \ - FSRTL_FLAG2_SUPPORTS_FILTER_CONTEXTS)) \ -) - -NTKERNELAPI -VOID -NTAPI -FsRtlTruncateBaseMcb ( - IN PBASE_MCB Mcb, - IN LONGLONG Vbn -); - -NTKERNELAPI -VOID -NTAPI -FsRtlTruncateLargeMcb ( - IN PLARGE_MCB Mcb, - IN LONGLONG Vbn -); - -NTKERNELAPI -VOID -NTAPI -FsRtlTruncateMcb ( - IN PMCB Mcb, - IN VBN Vbn -); - -NTKERNELAPI -VOID -NTAPI -FsRtlUninitializeBaseMcb ( - IN PBASE_MCB Mcb -); - -NTKERNELAPI -VOID -NTAPI -FsRtlUninitializeLargeMcb ( - IN PLARGE_MCB Mcb -); - -NTKERNELAPI -VOID -NTAPI -FsRtlUninitializeMcb ( - IN PMCB Mcb -); - -NTKERNELAPI -VOID -NTAPI -FsRtlUninitializeOplock ( - IN OUT POPLOCK Oplock -); - -NTKERNELAPI -NTSTATUS -NTAPI -IoAttachDeviceToDeviceStackSafe( - IN PDEVICE_OBJECT SourceDevice, - IN PDEVICE_OBJECT TargetDevice, - OUT PDEVICE_OBJECT *AttachedToDeviceObject -); - NTKERNELAPI NTSTATUS NTAPI @@ -8978,23 +9401,6 @@ ObReferenceObjectByName ( OUT PVOID *Object ); -#if (NTDDI_VERSION >= NTDDI_WIN2K) - -NTKERNELAPI -NTSTATUS -NTAPI -PsAssignImpersonationToken( - IN PETHREAD Thread, - IN HANDLE Token OPTIONAL); - -NTKERNELAPI -HANDLE -NTAPI -PsReferencePrimaryToken( - IN OUT PEPROCESS Process); - -#endif - #define PsDereferenceImpersonationToken(T) \ {if (ARGUMENT_PRESENT(T)) { \ (ObDereferenceObject((T))); \ @@ -9012,14 +9418,6 @@ PsLookupProcessThreadByCid ( OUT PETHREAD *Thread ); -NTSYSAPI -VOID -NTAPI -RtlSecondsSince1970ToTime ( - IN ULONG SecondsSince1970, - OUT PLARGE_INTEGER Time -); - NTSYSAPI NTSTATUS NTAPI @@ -9030,105 +9428,6 @@ RtlSetSaclSecurityDescriptor ( IN BOOLEAN SaclDefaulted ); -NTSYSAPI -NTSTATUS -NTAPI -RtlUnicodeStringToCountedOemString ( - IN OUT POEM_STRING DestinationString, - IN PCUNICODE_STRING SourceString, - IN BOOLEAN AllocateDestinationString -); - -/* RTL Splay Tree Functions */ -NTSYSAPI -PRTL_SPLAY_LINKS -NTAPI -RtlSplay(PRTL_SPLAY_LINKS Links); - -NTSYSAPI -PRTL_SPLAY_LINKS -NTAPI -RtlDelete(PRTL_SPLAY_LINKS Links); - -NTSYSAPI -VOID -NTAPI -RtlDeleteNoSplay( - PRTL_SPLAY_LINKS Links, - PRTL_SPLAY_LINKS *Root -); - -NTSYSAPI -PRTL_SPLAY_LINKS -NTAPI -RtlSubtreeSuccessor(PRTL_SPLAY_LINKS Links); - -NTSYSAPI -PRTL_SPLAY_LINKS -NTAPI -RtlSubtreePredecessor(PRTL_SPLAY_LINKS Links); - -NTSYSAPI -PRTL_SPLAY_LINKS -NTAPI -RtlRealSuccessor(PRTL_SPLAY_LINKS Links); - -NTSYSAPI -PRTL_SPLAY_LINKS -NTAPI -RtlRealPredecessor(PRTL_SPLAY_LINKS Links); - -#define RtlIsLeftChild(Links) \ - (RtlLeftChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links)) - -#define RtlIsRightChild(Links) \ - (RtlRightChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links)) - -#define RtlRightChild(Links) \ - ((PRTL_SPLAY_LINKS)(Links))->RightChild - -#define RtlIsRoot(Links) \ - (RtlParent(Links) == (PRTL_SPLAY_LINKS)(Links)) - -#define RtlLeftChild(Links) \ - ((PRTL_SPLAY_LINKS)(Links))->LeftChild - -#define RtlParent(Links) \ - ((PRTL_SPLAY_LINKS)(Links))->Parent - -#define RtlInitializeSplayLinks(Links) \ - { \ - PRTL_SPLAY_LINKS _SplayLinks; \ - _SplayLinks = (PRTL_SPLAY_LINKS)(Links); \ - _SplayLinks->Parent = _SplayLinks; \ - _SplayLinks->LeftChild = NULL; \ - _SplayLinks->RightChild = NULL; \ - } - -#define RtlInsertAsLeftChild(ParentLinks,ChildLinks) \ - { \ - PRTL_SPLAY_LINKS _SplayParent; \ - PRTL_SPLAY_LINKS _SplayChild; \ - _SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \ - _SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks); \ - _SplayParent->LeftChild = _SplayChild; \ - _SplayChild->Parent = _SplayParent; \ - } - -#define RtlInsertAsRightChild(ParentLinks,ChildLinks) \ - { \ - PRTL_SPLAY_LINKS _SplayParent; \ - PRTL_SPLAY_LINKS _SplayChild; \ - _SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \ - _SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks); \ - _SplayParent->RightChild = _SplayChild; \ - _SplayChild->Parent = _SplayParent; \ - } - -// -// RTL time functions -// - #define SeEnableAccessToExports() SeExports = *(PSE_EXPORTS *)SeExports; #if (VER_PRODUCTBUILD >= 2195) @@ -9154,18 +9453,6 @@ ZwAlertThread ( IN HANDLE ThreadHandle ); -NTSYSAPI -NTSTATUS -NTAPI -ZwAllocateVirtualMemory ( - IN HANDLE ProcessHandle, - IN OUT PVOID *BaseAddress, - IN ULONG_PTR ZeroBits, - IN OUT PSIZE_T RegionSize, - IN ULONG AllocationType, - IN ULONG Protect -); - NTSYSAPI NTSTATUS NTAPI @@ -9211,19 +9498,6 @@ ZwCloseObjectAuditAlarm ( IN BOOLEAN GenerateOnClose ); -NTSYSAPI -NTSTATUS -NTAPI -ZwCreateSection ( - OUT PHANDLE SectionHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, - IN PLARGE_INTEGER MaximumSize OPTIONAL, - IN ULONG SectionPageProtection, - IN ULONG AllocationAttributes, - IN HANDLE FileHandle OPTIONAL -); - NTSYSAPI NTSTATUS NTAPI @@ -9234,71 +9508,6 @@ ZwCreateSymbolicLinkObject ( IN PUNICODE_STRING TargetName ); -NTSYSAPI -NTSTATUS -NTAPI -ZwDeleteFile ( - IN POBJECT_ATTRIBUTES ObjectAttributes -); - -NTSYSAPI -NTSTATUS -NTAPI -ZwDeleteValueKey ( - IN HANDLE Handle, - IN PUNICODE_STRING Name -); - - -#if (NTDDI_VERSION >= NTDDI_WIN2K) -NTSYSAPI -NTSTATUS -NTAPI -ZwDeviceIoControlFile ( - IN HANDLE FileHandle, - IN HANDLE Event OPTIONAL, - IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, - IN PVOID ApcContext OPTIONAL, - OUT PIO_STATUS_BLOCK IoStatusBlock, - IN ULONG IoControlCode, - IN PVOID InputBuffer OPTIONAL, - IN ULONG InputBufferLength, - OUT PVOID OutputBuffer OPTIONAL, - IN ULONG OutputBufferLength); -#endif - -NTSYSAPI -NTSTATUS -NTAPI -ZwDisplayString ( - IN PUNICODE_STRING String -); - -NTSYSAPI -NTSTATUS -NTAPI -ZwDuplicateObject ( - IN HANDLE SourceProcessHandle, - IN HANDLE SourceHandle, - IN HANDLE TargetProcessHandle OPTIONAL, - OUT PHANDLE TargetHandle OPTIONAL, - IN ACCESS_MASK DesiredAccess, - IN ULONG HandleAttributes, - IN ULONG Options -); - -NTSYSAPI -NTSTATUS -NTAPI -ZwDuplicateToken ( - IN HANDLE ExistingTokenHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes, - IN BOOLEAN EffectiveOnly, - IN TOKEN_TYPE TokenType, - OUT PHANDLE NewTokenHandle -); - NTSYSAPI NTSTATUS NTAPI @@ -9318,46 +9527,6 @@ ZwFlushBuffersFile( #if (VER_PRODUCTBUILD >= 2195) -NTSYSAPI -NTSTATUS -NTAPI -ZwFlushVirtualMemory ( - IN HANDLE ProcessHandle, - IN OUT PVOID *BaseAddress, - IN OUT PULONG FlushSize, - OUT PIO_STATUS_BLOCK IoStatusBlock -); - -#endif /* (VER_PRODUCTBUILD >= 2195) */ - -NTSYSAPI -NTSTATUS -NTAPI -ZwFreeVirtualMemory ( - IN HANDLE ProcessHandle, - IN OUT PVOID *BaseAddress, - IN OUT PSIZE_T RegionSize, - IN ULONG FreeType -); - -NTSYSAPI -NTSTATUS -NTAPI -ZwFsControlFile ( - IN HANDLE FileHandle, - IN HANDLE Event OPTIONAL, - IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, - IN PVOID ApcContext OPTIONAL, - OUT PIO_STATUS_BLOCK IoStatusBlock, - IN ULONG FsControlCode, - IN PVOID InputBuffer OPTIONAL, - IN ULONG InputBufferLength, - OUT PVOID OutputBuffer OPTIONAL, - IN ULONG OutputBufferLength -); - -#if (VER_PRODUCTBUILD >= 2195) - NTSYSAPI NTSTATUS NTAPI @@ -9370,14 +9539,6 @@ ZwInitiatePowerAction ( #endif /* (VER_PRODUCTBUILD >= 2195) */ -NTSYSAPI -NTSTATUS -NTAPI -ZwLoadDriver ( - /* "\\Registry\\Machine\\System\\CurrentControlSet\\Services\\" */ - IN PUNICODE_STRING RegistryPath -); - NTSYSAPI NTSTATUS NTAPI @@ -9386,41 +9547,6 @@ ZwLoadKey ( IN POBJECT_ATTRIBUTES FileObjectAttributes ); -NTSYSAPI -NTSTATUS -NTAPI -ZwNotifyChangeKey ( - IN HANDLE KeyHandle, - IN HANDLE EventHandle OPTIONAL, - IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, - IN PVOID ApcContext OPTIONAL, - OUT PIO_STATUS_BLOCK IoStatusBlock, - IN ULONG NotifyFilter, - IN BOOLEAN WatchSubtree, - IN PVOID Buffer, - IN ULONG BufferLength, - IN BOOLEAN Asynchronous -); - -NTSYSAPI -NTSTATUS -NTAPI -ZwOpenDirectoryObject ( - OUT PHANDLE DirectoryHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes -); - -NTSYSAPI -NTSTATUS -NTAPI -ZwOpenProcess ( - OUT PHANDLE ProcessHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes, - IN PCLIENT_ID ClientId OPTIONAL -); - NTSYSAPI NTSTATUS NTAPI @@ -9450,21 +9576,6 @@ ZwOpenThreadToken ( OUT PHANDLE TokenHandle ); -#if (VER_PRODUCTBUILD >= 2195) - -NTSYSAPI -NTSTATUS -NTAPI -ZwPowerInformation ( - IN POWER_INFORMATION_LEVEL PowerInformationLevel, - IN PVOID InputBuffer OPTIONAL, - IN ULONG InputBufferLength, - OUT PVOID OutputBuffer OPTIONAL, - IN ULONG OutputBufferLength -); - -#endif /* (VER_PRODUCTBUILD >= 2195) */ - NTSYSAPI NTSTATUS NTAPI @@ -9481,23 +9592,6 @@ ZwQueryDefaultLocale ( OUT PLCID Locale ); -NTSYSAPI -NTSTATUS -NTAPI -ZwQueryDirectoryFile ( - IN HANDLE FileHandle, - IN HANDLE Event OPTIONAL, - IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, - IN PVOID ApcContext OPTIONAL, - OUT PIO_STATUS_BLOCK IoStatusBlock, - OUT PVOID FileInformation, - IN ULONG Length, - IN FILE_INFORMATION_CLASS FileInformationClass, - IN BOOLEAN ReturnSingleEntry, - IN PUNICODE_STRING FileName OPTIONAL, - IN BOOLEAN RestartScan -); - #if (VER_PRODUCTBUILD >= 2195) NTSYSAPI @@ -9513,21 +9607,6 @@ ZwQueryDirectoryObject ( OUT PULONG ReturnLength OPTIONAL ); -NTSYSAPI -NTSTATUS -NTAPI -ZwQueryEaFile ( - IN HANDLE FileHandle, - OUT PIO_STATUS_BLOCK IoStatusBlock, - OUT PVOID Buffer, - IN ULONG Length, - IN BOOLEAN ReturnSingleEntry, - IN PVOID EaList OPTIONAL, - IN ULONG EaListLength, - IN PULONG EaIndex OPTIONAL, - IN BOOLEAN RestartScan -); - #endif /* (VER_PRODUCTBUILD >= 2195) */ NTSYSAPI @@ -9541,39 +9620,6 @@ ZwQueryInformationProcess ( OUT PULONG ReturnLength OPTIONAL ); -NTSYSAPI -NTSTATUS -NTAPI -ZwQueryInformationToken ( - IN HANDLE TokenHandle, - IN TOKEN_INFORMATION_CLASS TokenInformationClass, - OUT PVOID TokenInformation, - IN ULONG Length, - OUT PULONG ResultLength -); - -NTSYSAPI -NTSTATUS -NTAPI -ZwQuerySecurityObject ( - IN HANDLE FileHandle, - IN SECURITY_INFORMATION SecurityInformation, - OUT PSECURITY_DESCRIPTOR SecurityDescriptor, - IN ULONG Length, - OUT PULONG ResultLength -); - -NTSYSAPI -NTSTATUS -NTAPI -ZwQueryVolumeInformationFile ( - IN HANDLE FileHandle, - OUT PIO_STATUS_BLOCK IoStatusBlock, - OUT PVOID FsInformation, - IN ULONG Length, - IN FS_INFORMATION_CLASS FsInformationClass -); - NTSYSAPI NTSTATUS NTAPI @@ -9629,26 +9675,8 @@ ZwSetDefaultUILanguage ( IN LANGID LanguageId ); -NTSYSAPI -NTSTATUS -NTAPI -ZwSetEaFile ( - IN HANDLE FileHandle, - OUT PIO_STATUS_BLOCK IoStatusBlock, - OUT PVOID Buffer, - IN ULONG Length -); - #endif /* (VER_PRODUCTBUILD >= 2195) */ -NTSYSAPI -NTSTATUS -NTAPI -ZwSetEvent ( - IN HANDLE EventHandle, - OUT PLONG PreviousState OPTIONAL -); - NTSYSAPI NTSTATUS NTAPI @@ -9659,19 +9687,6 @@ ZwSetInformationProcess ( IN ULONG ProcessInformationLength ); -#if (VER_PRODUCTBUILD >= 2195) - -NTSYSAPI -NTSTATUS -NTAPI -ZwSetSecurityObject ( - IN HANDLE Handle, - IN SECURITY_INFORMATION SecurityInformation, - IN PSECURITY_DESCRIPTOR SecurityDescriptor -); - -#endif /* (VER_PRODUCTBUILD >= 2195) */ - NTSYSAPI NTSTATUS NTAPI @@ -9680,37 +9695,6 @@ ZwSetSystemTime ( OUT PLARGE_INTEGER OldTime OPTIONAL ); -#if (VER_PRODUCTBUILD >= 2195) - -NTSYSAPI -NTSTATUS -NTAPI -ZwSetVolumeInformationFile ( - IN HANDLE FileHandle, - OUT PIO_STATUS_BLOCK IoStatusBlock, - IN PVOID FsInformation, - IN ULONG Length, - IN FS_INFORMATION_CLASS FsInformationClass -); - -#endif /* (VER_PRODUCTBUILD >= 2195) */ - -NTSYSAPI -NTSTATUS -NTAPI -ZwTerminateProcess ( - IN HANDLE ProcessHandle OPTIONAL, - IN NTSTATUS ExitStatus -); - -NTSYSAPI -NTSTATUS -NTAPI -ZwUnloadDriver ( - /* "\\Registry\\Machine\\System\\CurrentControlSet\\Services\\" */ - IN PUNICODE_STRING RegistryPath -); - NTSYSAPI NTSTATUS NTAPI @@ -9718,16 +9702,6 @@ ZwUnloadKey ( IN POBJECT_ATTRIBUTES KeyObjectAttributes ); -#if (NTDDI_VERSION >= NTDDI_WIN2K) -NTSYSAPI -NTSTATUS -NTAPI -ZwWaitForSingleObject ( - IN HANDLE Handle, - IN BOOLEAN Alertable, - IN PLARGE_INTEGER Timeout OPTIONAL); -#endif - NTSYSAPI NTSTATUS NTAPI diff --git a/reactos/include/ddk/ntimage.h b/reactos/include/ddk/ntimage.h index e008a2daa94..8df984763f7 100644 --- a/reactos/include/ddk/ntimage.h +++ b/reactos/include/ddk/ntimage.h @@ -394,22 +394,33 @@ typedef struct _IMAGE_NT_HEADERS64 { ULONG Signature; IMAGE_FILE_HEADER FileHeader; IMAGE_OPTIONAL_HEADER64 OptionalHeader; -} IMAGE_NT_HEADERS64, *PIMAGE_NT_HEADERS64; +} IMAGE_NT_HEADERS64; typedef struct _IMAGE_NT_HEADERS { ULONG Signature; IMAGE_FILE_HEADER FileHeader; IMAGE_OPTIONAL_HEADER32 OptionalHeader; -} IMAGE_NT_HEADERS32, *PIMAGE_NT_HEADERS32; +} IMAGE_NT_HEADERS32; #ifdef _WIN64 typedef IMAGE_NT_HEADERS64 IMAGE_NT_HEADERS; -typedef PIMAGE_NT_HEADERS64 PIMAGE_NT_HEADERS; #else typedef IMAGE_NT_HEADERS32 IMAGE_NT_HEADERS; +#endif + +#ifndef _NTDDK_ + +typedef struct _IMAGE_NT_HEADERS *PIMAGE_NT_HEADERS32; +typedef struct _IMAGE_NT_HEADERS64 *PIMAGE_NT_HEADERS64; + +#ifdef _WIN64 +typedef PIMAGE_NT_HEADERS64 PIMAGE_NT_HEADERS; +#else typedef PIMAGE_NT_HEADERS32 PIMAGE_NT_HEADERS; #endif +#endif /* _NTDDK_ */ + // // Retreives the first image section header from the Nt Header // diff --git a/reactos/include/ddk/ntpoapi.h b/reactos/include/ddk/ntpoapi.h index 48f71072ab6..c4a4b28ec6f 100644 --- a/reactos/include/ddk/ntpoapi.h +++ b/reactos/include/ddk/ntpoapi.h @@ -220,7 +220,7 @@ typedef struct _POWER_STATE_NOTIFY_HANDLER { NTSYSCALLAPI NTSTATUS -DDKAPI +NTAPI NtPowerInformation( IN POWER_INFORMATION_LEVEL InformationLevel, IN PVOID InputBuffer OPTIONAL, diff --git a/reactos/include/ddk/parallel.h b/reactos/include/ddk/parallel.h index d567bbd2d0f..c45f09b1eef 100644 --- a/reactos/include/ddk/parallel.h +++ b/reactos/include/ddk/parallel.h @@ -80,27 +80,27 @@ typedef struct _MORE_PARALLEL_PORT_INFORMATION { } MORE_PARALLEL_PORT_INFORMATION, *PMORE_PARALLEL_PORT_INFORMATION; typedef NTSTATUS -(DDKAPI *PPARALLEL_SET_CHIP_MODE)( +(NTAPI *PPARALLEL_SET_CHIP_MODE)( IN PVOID SetChipContext, IN UCHAR ChipMode); typedef NTSTATUS -(DDKAPI *PPARALLEL_CLEAR_CHIP_MODE)( +(NTAPI *PPARALLEL_CLEAR_CHIP_MODE)( IN PVOID ClearChipContext, IN UCHAR ChipMode); typedef NTSTATUS -(DDKAPI *PPARCHIP_CLEAR_CHIP_MODE)( +(NTAPI *PPARCHIP_CLEAR_CHIP_MODE)( IN PVOID ClearChipContext, IN UCHAR ChipMode); typedef NTSTATUS -(DDKAPI *PPARALLEL_TRY_SELECT_ROUTINE)( +(NTAPI *PPARALLEL_TRY_SELECT_ROUTINE)( IN PVOID TrySelectContext, IN PVOID TrySelectCommand); typedef NTSTATUS -(DDKAPI *PPARALLEL_DESELECT_ROUTINE)( +(NTAPI *PPARALLEL_DESELECT_ROUTINE)( IN PVOID DeselectContext, IN PVOID DeselectCommand); @@ -134,15 +134,15 @@ typedef struct _PARALLEL_PNP_INFORMATION { } PARALLEL_PNP_INFORMATION, *PPARALLEL_PNP_INFORMATION; typedef BOOLEAN -(DDKAPI *PPARALLEL_TRY_ALLOCATE_ROUTINE)( +(NTAPI *PPARALLEL_TRY_ALLOCATE_ROUTINE)( IN PVOID TryAllocateContext); typedef VOID -(DDKAPI *PPARALLEL_FREE_ROUTINE)( +(NTAPI *PPARALLEL_FREE_ROUTINE)( IN PVOID FreeContext); typedef ULONG -(DDKAPI *PPARALLEL_QUERY_WAITERS_ROUTINE)( +(NTAPI *PPARALLEL_QUERY_WAITERS_ROUTINE)( IN PVOID QueryAllocsContext); typedef struct _PARALLEL_PORT_INFORMATION { @@ -165,7 +165,7 @@ typedef struct _PARALLEL_CHIP_MODE { } PARALLEL_CHIP_MODE, *PPARALLEL_CHIP_MODE; typedef VOID -(DDKAPI *PPARALLEL_DEFERRED_ROUTINE)( +(NTAPI *PPARALLEL_DEFERRED_ROUTINE)( IN PVOID DeferredContext); typedef struct _PARALLEL_INTERRUPT_SERVICE_ROUTINE { @@ -192,7 +192,7 @@ typedef struct _PARALLEL_INTERRUPT_SERVICE_ROUTINE { CTL_CODE (FILE_DEVICE_PARALLEL_PORT, 53, METHOD_BUFFERED, FILE_ANY_ACCESS) typedef USHORT -(DDKAPI *PDETERMINE_IEEE_MODES)( +(NTAPI *PDETERMINE_IEEE_MODES)( IN PVOID Context); typedef enum _PARALLEL_SAFETY { @@ -201,7 +201,7 @@ typedef enum _PARALLEL_SAFETY { } PARALLEL_SAFETY; typedef NTSTATUS -(DDKAPI *PNEGOTIATE_IEEE_MODE)( +(NTAPI *PNEGOTIATE_IEEE_MODE)( IN PVOID Context, IN USHORT ModeMaskFwd, IN USHORT ModeMaskRev, @@ -209,19 +209,19 @@ typedef NTSTATUS IN BOOLEAN IsForward); typedef NTSTATUS -(DDKAPI *PTERMINATE_IEEE_MODE)( +(NTAPI *PTERMINATE_IEEE_MODE)( IN PVOID Context); typedef NTSTATUS -(DDKAPI *PPARALLEL_IEEE_FWD_TO_REV)( +(NTAPI *PPARALLEL_IEEE_FWD_TO_REV)( IN PVOID Context); typedef NTSTATUS -(DDKAPI *PPARALLEL_IEEE_REV_TO_FWD)( +(NTAPI *PPARALLEL_IEEE_REV_TO_FWD)( IN PVOID Context); typedef NTSTATUS -(DDKAPI *PPARALLEL_READ)( +(NTAPI *PPARALLEL_READ)( IN PVOID Context, OUT PVOID Buffer, IN ULONG NumBytesToRead, @@ -229,7 +229,7 @@ typedef NTSTATUS IN UCHAR Channel); typedef NTSTATUS -(DDKAPI *PPARALLEL_WRITE)( +(NTAPI *PPARALLEL_WRITE)( IN PVOID Context, OUT PVOID Buffer, IN ULONG NumBytesToWrite, @@ -237,12 +237,12 @@ typedef NTSTATUS IN UCHAR Channel); typedef NTSTATUS -(DDKAPI *PPARALLEL_TRYSELECT_DEVICE)( +(NTAPI *PPARALLEL_TRYSELECT_DEVICE)( IN PVOID Context, IN PARALLEL_1284_COMMAND Command); typedef NTSTATUS -(DDKAPI *PPARALLEL_DESELECT_DEVICE)( +(NTAPI *PPARALLEL_DESELECT_DEVICE)( IN PVOID Context, IN PARALLEL_1284_COMMAND Command); diff --git a/reactos/include/ddk/scsiwmi.h b/reactos/include/ddk/scsiwmi.h index c599f48c01b..383d1d473a1 100644 --- a/reactos/include/ddk/scsiwmi.h +++ b/reactos/include/ddk/scsiwmi.h @@ -61,13 +61,13 @@ typedef struct _SCSIWMIGUIDREGINFO { } SCSIWMIGUIDREGINFO, *PSCSIWMIGUIDREGINFO; typedef UCHAR -(DDKAPI *PSCSIWMI_QUERY_REGINFO)( +(NTAPI *PSCSIWMI_QUERY_REGINFO)( IN PVOID DeviceContext, IN PSCSIWMI_REQUEST_CONTEXT RequestContext, OUT PWCHAR *MofResourceName); typedef BOOLEAN -(DDKAPI *PSCSIWMI_QUERY_DATABLOCK)( +(NTAPI *PSCSIWMI_QUERY_DATABLOCK)( IN PVOID Context, IN PSCSIWMI_REQUEST_CONTEXT DispatchContext, IN ULONG GuidIndex, @@ -78,7 +78,7 @@ typedef BOOLEAN OUT PUCHAR Buffer); typedef BOOLEAN -(DDKAPI *PSCSIWMI_SET_DATABLOCK)( +(NTAPI *PSCSIWMI_SET_DATABLOCK)( IN PVOID DeviceContext, IN PSCSIWMI_REQUEST_CONTEXT RequestContext, IN ULONG GuidIndex, @@ -87,7 +87,7 @@ typedef BOOLEAN IN PUCHAR Buffer); typedef BOOLEAN -(DDKAPI *PSCSIWMI_SET_DATAITEM)( +(NTAPI *PSCSIWMI_SET_DATAITEM)( IN PVOID DeviceContext, IN PSCSIWMI_REQUEST_CONTEXT RequestContext, IN ULONG GuidIndex, @@ -97,7 +97,7 @@ typedef BOOLEAN IN PUCHAR Buffer); typedef BOOLEAN -(DDKAPI *PSCSIWMI_EXECUTE_METHOD)( +(NTAPI *PSCSIWMI_EXECUTE_METHOD)( IN PVOID DeviceContext, IN PSCSIWMI_REQUEST_CONTEXT RequestContext, IN ULONG GuidIndex, @@ -113,7 +113,7 @@ typedef enum _SCSIWMI_ENABLE_DISABLE_CONTROL { } SCSIWMI_ENABLE_DISABLE_CONTROL; typedef BOOLEAN -(DDKAPI *PSCSIWMI_FUNCTION_CONTROL)( +(NTAPI *PSCSIWMI_FUNCTION_CONTROL)( IN PVOID DeviceContext, IN PSCSIWMI_REQUEST_CONTEXT RequestContext, IN ULONG GuidIndex, @@ -133,7 +133,7 @@ typedef struct _SCSIWMILIB_CONTEXT { SCSIPORTAPI BOOLEAN -DDKAPI +NTAPI ScsiPortWmiDispatchFunction( IN PSCSI_WMILIB_CONTEXT WmiLibInfo, IN UCHAR MinorFunction, @@ -176,7 +176,7 @@ ScsiPortWmiDispatchFunction( SCSIPORTAPI VOID -DDKAPI +NTAPI ScsiPortWmiPostProcess( IN PSCSIWMI_REQUEST_CONTEXT RequestContext, IN UCHAR SrbStatus, @@ -184,7 +184,7 @@ ScsiPortWmiPostProcess( SCSIPORTAPI VOID -DDKAPI +NTAPI ScsiPortWmiFireLogicalUnitEvent( IN PVOID HwDeviceExtension, IN UCHAR PathId, diff --git a/reactos/include/ddk/smbus.h b/reactos/include/ddk/smbus.h index de61c7de0e1..fd07c72556f 100644 --- a/reactos/include/ddk/smbus.h +++ b/reactos/include/ddk/smbus.h @@ -100,17 +100,17 @@ typedef struct _SMB_REGISTER_ALARM { #define SMB_CLASS_MINOR_VERSION 0x0000 typedef NTSTATUS -(DDKAPI *SMB_RESET_DEVICE)( +(NTAPI *SMB_RESET_DEVICE)( IN struct _SMB_CLASS *SmbClass, IN PVOID SmbMiniport); typedef VOID -(DDKAPI *SMB_START_IO)( +(NTAPI *SMB_START_IO)( IN struct _SMB_CLASS *SmbClass, IN PVOID SmbMiniport); typedef NTSTATUS -(DDKAPI *SMB_STOP_DEVICE)( +(NTAPI *SMB_STOP_DEVICE)( IN struct _SMB_CLASS *SmbClass, IN PVOID SmbMiniport); @@ -130,7 +130,7 @@ typedef struct _SMB_CLASS { SMBCLASSAPI VOID -DDKAPI +NTAPI SmbClassAlarm( IN PSMB_CLASS SmbClass, IN UCHAR Address, @@ -138,19 +138,19 @@ SmbClassAlarm( SMBCLASSAPI VOID -DDKAPI +NTAPI SmbClassCompleteRequest( IN PSMB_CLASS SmbClass); typedef NTSTATUS -(DDKAPI *PSMB_INITIALIZE_MINIPORT)( +(NTAPI *PSMB_INITIALIZE_MINIPORT)( IN PSMB_CLASS SmbClass, IN PVOID MiniportExtension, IN PVOID MiniportContext); SMBCLASSAPI NTSTATUS -DDKAPI +NTAPI SmbClassCreateFdo( IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT PDO, @@ -161,7 +161,7 @@ SmbClassCreateFdo( SMBCLASSAPI NTSTATUS -DDKAPI +NTAPI SmbClassInitializeDevice( IN ULONG MajorVersion, IN ULONG MinorVersion, @@ -169,13 +169,13 @@ SmbClassInitializeDevice( SMBCLASSAPI VOID -DDKAPI +NTAPI SmbClassLockDevice( IN PSMB_CLASS SmbClass); SMBCLASSAPI VOID -DDKAPI +NTAPI SmbClassUnlockDevice( IN PSMB_CLASS SmbClass); diff --git a/reactos/include/ddk/srb.h b/reactos/include/ddk/srb.h index 7d7fc516b9b..0763652749a 100644 --- a/reactos/include/ddk/srb.h +++ b/reactos/include/ddk/srb.h @@ -301,13 +301,13 @@ typedef struct _SCSI_SUPPORTED_CONTROL_TYPE_LIST { } SCSI_SUPPORTED_CONTROL_TYPE_LIST, *PSCSI_SUPPORTED_CONTROL_TYPE_LIST; typedef SCSI_ADAPTER_CONTROL_STATUS -(DDKAPI *PHW_ADAPTER_CONTROL)( +(NTAPI *PHW_ADAPTER_CONTROL)( IN PVOID DeviceExtension, IN SCSI_ADAPTER_CONTROL_TYPE ControlType, IN PVOID Parameters); typedef BOOLEAN -(DDKAPI *PHW_ADAPTER_STATE)( +(NTAPI *PHW_ADAPTER_STATE)( IN PVOID DeviceExtension, IN PVOID Context, IN BOOLEAN SaveState); @@ -318,7 +318,7 @@ typedef BOOLEAN #define SP_RETURN_BAD_CONFIG 3 typedef ULONG -(DDKAPI *PHW_FIND_ADAPTER)( +(NTAPI *PHW_FIND_ADAPTER)( IN PVOID DeviceExtension, IN PVOID HwContext, IN PVOID BusInformation, @@ -327,29 +327,29 @@ typedef ULONG OUT PBOOLEAN Again); typedef BOOLEAN -(DDKAPI *PHW_INITIALIZE)( +(NTAPI *PHW_INITIALIZE)( IN PVOID DeviceExtension); typedef BOOLEAN -(DDKAPI *PHW_INTERRUPT)( +(NTAPI *PHW_INTERRUPT)( IN PVOID DeviceExtension); typedef BOOLEAN -(DDKAPI *PHW_RESET_BUS)( +(NTAPI *PHW_RESET_BUS)( IN PVOID DeviceExtension, IN ULONG PathId); typedef VOID -(DDKAPI *PHW_DMA_STARTED)( +(NTAPI *PHW_DMA_STARTED)( IN PVOID DeviceExtension); typedef BOOLEAN -(DDKAPI *PHW_STARTIO)( +(NTAPI *PHW_STARTIO)( IN PVOID DeviceExtension, IN PSCSI_REQUEST_BLOCK Srb); typedef VOID -(DDKAPI *PHW_TIMER)( +(NTAPI *PHW_TIMER)( IN PVOID DeviceExtension); typedef struct _HW_INITIALIZATION_DATA { @@ -383,7 +383,7 @@ typedef struct _HW_INITIALIZATION_DATA { SCSIPORTAPI VOID -DDKAPI +NTAPI ScsiPortCompleteRequest( IN PVOID HwDeviceExtension, IN UCHAR PathId, @@ -400,26 +400,26 @@ ScsiPortCompleteRequest( SCSIPORTAPI SCSI_PHYSICAL_ADDRESS -DDKAPI +NTAPI ScsiPortConvertUlongToPhysicalAddress( IN ULONG UlongAddress); SCSIPORTAPI VOID -DDKAPI +NTAPI ScsiPortFlushDma( IN PVOID DeviceExtension); SCSIPORTAPI VOID -DDKAPI +NTAPI ScsiPortFreeDeviceBase( IN PVOID HwDeviceExtension, IN PVOID MappedAddress); SCSIPORTAPI ULONG -DDKAPI +NTAPI ScsiPortGetBusData( IN PVOID DeviceExtension, IN ULONG BusDataType, @@ -430,7 +430,7 @@ ScsiPortGetBusData( SCSIPORTAPI PVOID -DDKAPI +NTAPI ScsiPortGetDeviceBase( IN PVOID HwDeviceExtension, IN INTERFACE_TYPE BusType, @@ -441,7 +441,7 @@ ScsiPortGetDeviceBase( SCSIPORTAPI PVOID -DDKAPI +NTAPI ScsiPortGetLogicalUnit( IN PVOID HwDeviceExtension, IN UCHAR PathId, @@ -450,7 +450,7 @@ ScsiPortGetLogicalUnit( SCSIPORTAPI SCSI_PHYSICAL_ADDRESS -DDKAPI +NTAPI ScsiPortGetPhysicalAddress( IN PVOID HwDeviceExtension, IN PSCSI_REQUEST_BLOCK Srb OPTIONAL, @@ -459,7 +459,7 @@ ScsiPortGetPhysicalAddress( SCSIPORTAPI PSCSI_REQUEST_BLOCK -DDKAPI +NTAPI ScsiPortGetSrb( IN PVOID DeviceExtension, IN UCHAR PathId, @@ -469,7 +469,7 @@ ScsiPortGetSrb( SCSIPORTAPI PVOID -DDKAPI +NTAPI ScsiPortGetUncachedExtension( IN PVOID HwDeviceExtension, IN PPORT_CONFIGURATION_INFORMATION ConfigInfo, @@ -477,14 +477,14 @@ ScsiPortGetUncachedExtension( SCSIPORTAPI PVOID -DDKAPI +NTAPI ScsiPortGetVirtualAddress( IN PVOID HwDeviceExtension, IN SCSI_PHYSICAL_ADDRESS PhysicalAddress); SCSIPORTAPI ULONG -DDKAPI +NTAPI ScsiPortInitialize( IN PVOID Argument1, IN PVOID Argument2, @@ -493,7 +493,7 @@ ScsiPortInitialize( SCSIPORTAPI VOID -DDKAPI +NTAPI ScsiPortIoMapTransfer( IN PVOID HwDeviceExtension, IN PSCSI_REQUEST_BLOCK Srb, @@ -502,7 +502,7 @@ ScsiPortIoMapTransfer( SCSIPORTAPI VOID -DDKAPI +NTAPI ScsiPortLogError( IN PVOID HwDeviceExtension, IN PSCSI_REQUEST_BLOCK Srb OPTIONAL, @@ -514,7 +514,7 @@ ScsiPortLogError( SCSIPORTAPI VOID -DDKAPI +NTAPI ScsiPortMoveMemory( IN PVOID WriteBuffer, IN PVOID ReadBuffer, @@ -522,7 +522,7 @@ ScsiPortMoveMemory( SCSIPORTAPI VOID -DDKCDECLAPI +__cdecl ScsiPortNotification( IN SCSI_NOTIFICATION_TYPE NotificationType, IN PVOID HwDeviceExtension, @@ -530,13 +530,13 @@ ScsiPortNotification( SCSIPORTAPI VOID -DDKAPI +NTAPI ScsiPortQuerySystemTime( OUT PLARGE_INTEGER CurrentTime); SCSIPORTAPI VOID -DDKAPI +NTAPI ScsiPortReadPortBufferUchar( IN PUCHAR Port, IN PUCHAR Buffer, @@ -544,7 +544,7 @@ ScsiPortReadPortBufferUchar( SCSIPORTAPI VOID -DDKAPI +NTAPI ScsiPortReadPortBufferUlong( IN PULONG Port, IN PULONG Buffer, @@ -552,7 +552,7 @@ ScsiPortReadPortBufferUlong( SCSIPORTAPI VOID -DDKAPI +NTAPI ScsiPortReadPortBufferUshort( IN PUSHORT Port, IN PUSHORT Buffer, @@ -560,25 +560,25 @@ ScsiPortReadPortBufferUshort( SCSIPORTAPI UCHAR -DDKAPI +NTAPI ScsiPortReadPortUchar( IN PUCHAR Port); SCSIPORTAPI ULONG -DDKAPI +NTAPI ScsiPortReadPortUlong( IN PULONG Port); SCSIPORTAPI USHORT -DDKAPI +NTAPI ScsiPortReadPortUshort( IN PUSHORT Port); SCSIPORTAPI VOID -DDKAPI +NTAPI ScsiPortReadRegisterBufferUchar( IN PUCHAR Register, IN PUCHAR Buffer, @@ -586,7 +586,7 @@ ScsiPortReadRegisterBufferUchar( SCSIPORTAPI VOID -DDKAPI +NTAPI ScsiPortReadRegisterBufferUlong( IN PULONG Register, IN PULONG Buffer, @@ -594,7 +594,7 @@ ScsiPortReadRegisterBufferUlong( SCSIPORTAPI VOID -DDKAPI +NTAPI ScsiPortReadRegisterBufferUshort( IN PUSHORT Register, IN PUSHORT Buffer, @@ -602,25 +602,25 @@ ScsiPortReadRegisterBufferUshort( SCSIPORTAPI UCHAR -DDKAPI +NTAPI ScsiPortReadRegisterUchar( IN PUCHAR Register); SCSIPORTAPI ULONG -DDKAPI +NTAPI ScsiPortReadRegisterUlong( IN PULONG Register); SCSIPORTAPI USHORT -DDKAPI +NTAPI ScsiPortReadRegisterUshort( IN PUSHORT Register); SCSIPORTAPI ULONG -DDKAPI +NTAPI ScsiPortSetBusDataByOffset( IN PVOID DeviceExtension, IN ULONG BusDataType, @@ -632,13 +632,13 @@ ScsiPortSetBusDataByOffset( SCSIPORTAPI VOID -DDKAPI +NTAPI ScsiPortStallExecution( IN ULONG Delay); SCSIPORTAPI BOOLEAN -DDKAPI +NTAPI ScsiPortValidateRange( IN PVOID HwDeviceExtension, IN INTERFACE_TYPE BusType, @@ -649,7 +649,7 @@ ScsiPortValidateRange( SCSIPORTAPI VOID -DDKAPI +NTAPI ScsiPortWritePortBufferUchar( IN PUCHAR Port, IN PUCHAR Buffer, @@ -657,7 +657,7 @@ ScsiPortWritePortBufferUchar( SCSIPORTAPI VOID -DDKAPI +NTAPI ScsiPortWritePortBufferUlong( IN PULONG Port, IN PULONG Buffer, @@ -665,7 +665,7 @@ ScsiPortWritePortBufferUlong( SCSIPORTAPI VOID -DDKAPI +NTAPI ScsiPortWritePortBufferUshort( IN PUSHORT Port, IN PUSHORT Buffer, @@ -673,28 +673,28 @@ ScsiPortWritePortBufferUshort( SCSIPORTAPI VOID -DDKAPI +NTAPI ScsiPortWritePortUchar( IN PUCHAR Port, IN UCHAR Value); SCSIPORTAPI VOID -DDKAPI +NTAPI ScsiPortWritePortUlong( IN PULONG Port, IN ULONG Value); SCSIPORTAPI VOID -DDKAPI +NTAPI ScsiPortWritePortUshort( IN PUSHORT Port, IN USHORT Value); SCSIPORTAPI VOID -DDKAPI +NTAPI ScsiPortWriteRegisterBufferUchar( IN PUCHAR Register, IN PUCHAR Buffer, @@ -702,7 +702,7 @@ ScsiPortWriteRegisterBufferUchar( SCSIPORTAPI VOID -DDKAPI +NTAPI ScsiPortWriteRegisterBufferUlong( IN PULONG Register, IN PULONG Buffer, @@ -710,7 +710,7 @@ ScsiPortWriteRegisterBufferUlong( SCSIPORTAPI VOID -DDKAPI +NTAPI ScsiPortWriteRegisterBufferUshort( IN PUSHORT Register, IN PUSHORT Buffer, @@ -718,28 +718,28 @@ ScsiPortWriteRegisterBufferUshort( SCSIPORTAPI VOID -DDKAPI +NTAPI ScsiPortWriteRegisterUchar( IN PUCHAR Register, IN ULONG Value); SCSIPORTAPI VOID -DDKAPI +NTAPI ScsiPortWriteRegisterUlong( IN PULONG Register, IN ULONG Value); SCSIPORTAPI VOID -DDKAPI +NTAPI ScsiPortWriteRegisterUshort( IN PUSHORT Register, IN USHORT Value); SCSIPORTAPI VOID -DDKCDECLAPI +__cdecl ScsiDebugPrint( IN ULONG DebugPrintLevel, IN PCCHAR DebugMessage, diff --git a/reactos/include/ddk/storport.h b/reactos/include/ddk/storport.h index 7859967a32d..fd8cf9b19ae 100644 --- a/reactos/include/ddk/storport.h +++ b/reactos/include/ddk/storport.h @@ -76,7 +76,7 @@ typedef struct _SCSI_WMI_REQUEST_BLOCK { STORPORTAPI ULONG -DDKAPI +NTAPI StorPortInitialize( IN PVOID Argument1, IN PVOID Argument2, @@ -85,14 +85,14 @@ StorPortInitialize( STORPORTAPI VOID -DDKAPI +NTAPI StorPortFreeDeviceBase( IN PVOID HwDeviceExtension, IN PVOID MappedAddress); STORPORTAPI ULONG -DDKAPI +NTAPI StorPortGetBusData( IN PVOID DeviceExtension, IN ULONG BusDataType, @@ -103,7 +103,7 @@ StorPortGetBusData( STORPORTAPI ULONG -DDKAPI +NTAPI StorPortSetBusDataByOffset( IN PVOID DeviceExtension, IN ULONG BusDataType, @@ -115,7 +115,7 @@ StorPortSetBusDataByOffset( STORPORTAPI PVOID -DDKAPI +NTAPI StorPortGetDeviceBase( IN PVOID HwDeviceExtension, IN INTERFACE_TYPE BusType, @@ -126,7 +126,7 @@ StorPortGetDeviceBase( STORPORTAPI PVOID -DDKAPI +NTAPI StorPortGetLogicalUnit( IN PVOID HwDeviceExtension, IN UCHAR PathId, @@ -135,7 +135,7 @@ StorPortGetLogicalUnit( STORPORTAPI PSCSI_REQUEST_BLOCK -DDKAPI +NTAPI StorPortGetSrb( IN PVOID DeviceExtension, IN UCHAR PathId, @@ -145,7 +145,7 @@ StorPortGetSrb( STORPORTAPI STOR_PHYSICAL_ADDRESS -DDKAPI +NTAPI StorPortGetPhysicalAddress( IN PVOID HwDeviceExtension, IN PSCSI_REQUEST_BLOCK Srb, @@ -154,14 +154,14 @@ StorPortGetPhysicalAddress( STORPORTAPI PVOID -DDKAPI +NTAPI StorPortGetVirtualAddress( IN PVOID HwDeviceExtension, IN STOR_PHYSICAL_ADDRESS PhysicalAddress); STORPORTAPI PVOID -DDKAPI +NTAPI StorPortGetUncachedExtension( IN PVOID HwDeviceExtension, IN PPORT_CONFIGURATION_INFORMATION ConfigInfo, @@ -169,7 +169,7 @@ StorPortGetUncachedExtension( STORPORTAPI VOID -DDKCDECLAPI +__cdecl StorPortNotification( IN SCSI_NOTIFICATION_TYPE NotificationType, IN PVOID HwDeviceExtension, @@ -177,7 +177,7 @@ StorPortNotification( STORPORTAPI VOID -DDKAPI +NTAPI StorPortLogError( IN PVOID HwDeviceExtension, IN PSCSI_REQUEST_BLOCK Srb OPTIONAL, @@ -189,7 +189,7 @@ StorPortLogError( STORPORTAPI VOID -DDKAPI +NTAPI StorPortCompleteRequest( IN PVOID HwDeviceExtension, IN UCHAR PathId, @@ -199,7 +199,7 @@ StorPortCompleteRequest( STORPORTAPI VOID -DDKAPI +NTAPI StorPortMoveMemory( IN PVOID WriteBuffer, IN PVOID ReadBuffer, @@ -207,25 +207,25 @@ StorPortMoveMemory( STORPORTAPI VOID -DDKAPI +NTAPI StorPortStallExecution( IN ULONG Delay); STORPORTAPI STOR_PHYSICAL_ADDRESS -DDKAPI +NTAPI StorPortConvertUlong64ToPhysicalAddress( IN ULONG64 UlongAddress); STORPORTAPI ULONG64 -DDKAPI +NTAPI StorPortConvertPhysicalAddressToUlong64( IN STOR_PHYSICAL_ADDRESS Address); STORPORTAPI BOOLEAN -DDKAPI +NTAPI StorPortValidateRange( IN PVOID HwDeviceExtension, IN INTERFACE_TYPE BusType, @@ -236,7 +236,7 @@ StorPortValidateRange( STORPORTAPI VOID -DDKCDECLAPI +__cdecl StorPortDebugPrint( IN ULONG DebugPrintLevel, IN PCCHAR DebugMessage, @@ -244,85 +244,85 @@ StorPortDebugPrint( STORPORTAPI UCHAR -DDKAPI +NTAPI StorPortReadPortUchar( IN PUCHAR Port); STORPORTAPI ULONG -DDKAPI +NTAPI StorPortReadPortUlong( IN PULONG Port); STORPORTAPI USHORT -DDKAPI +NTAPI StorPortReadPortUshort( IN PUSHORT Port); STORPORTAPI UCHAR -DDKAPI +NTAPI StorPortReadRegisterUchar( IN PUCHAR Register); STORPORTAPI ULONG -DDKAPI +NTAPI StorPortReadRegisterUlong( IN PULONG Register); STORPORTAPI USHORT -DDKAPI +NTAPI StorPortReadRegisterUshort( IN PUSHORT Register); STORPORTAPI VOID -DDKAPI +NTAPI StorPortWritePortUchar( IN PUCHAR Port, IN UCHAR Value); STORPORTAPI VOID -DDKAPI +NTAPI StorPortWritePortUlong( IN PULONG Port, IN ULONG Value); STORPORTAPI VOID -DDKAPI +NTAPI StorPortWritePortUshort( IN PUSHORT Port, IN USHORT Value); STORPORTAPI VOID -DDKAPI +NTAPI StorPortWriteRegisterUchar( IN PUCHAR Port, IN UCHAR Value); STORPORTAPI VOID -DDKAPI +NTAPI StorPortWriteRegisterUlong( IN PULONG Port, IN ULONG Value); STORPORTAPI VOID -DDKAPI +NTAPI StorPortWriteRegisterUshort( IN PUSHORT Port, IN USHORT Value); STORPORTAPI BOOLEAN -DDKAPI +NTAPI StorPortPauseDevice( IN PVOID HwDeviceExtension, IN UCHAR PathId, @@ -332,7 +332,7 @@ StorPortPauseDevice( STORPORTAPI BOOLEAN -DDKAPI +NTAPI StorPortResumeDevice( IN PVOID HwDeviceExtension, IN UCHAR PathId, @@ -341,20 +341,20 @@ StorPortResumeDevice( STORPORTAPI BOOLEAN -DDKAPI +NTAPI StorPortPause( IN PVOID HwDeviceExtension, IN ULONG TimeOut); STORPORTAPI BOOLEAN -DDKAPI +NTAPI StorPortResume( IN PVOID HwDeviceExtension); STORPORTAPI BOOLEAN -DDKAPI +NTAPI StorPortDeviceBusy( IN PVOID HwDeviceExtension, IN UCHAR PathId, @@ -364,7 +364,7 @@ StorPortDeviceBusy( STORPORTAPI BOOLEAN -DDKAPI +NTAPI StorPortDeviceReady( IN PVOID HwDeviceExtension, IN UCHAR PathId, @@ -373,32 +373,32 @@ StorPortDeviceReady( STORPORTAPI BOOLEAN -DDKAPI +NTAPI StorPortBusy( IN PVOID HwDeviceExtension, IN ULONG RequestsToComplete); STORPORTAPI BOOLEAN -DDKAPI +NTAPI StorPortReady( IN PVOID HwDeviceExtension); STORPORTAPI PSTOR_SCATTER_GATHER_LIST -DDKAPI +NTAPI StorPortGetScatterGatherList( IN PVOID DeviceExtension, IN PSCSI_REQUEST_BLOCK Srb); typedef BOOLEAN -(DDKAPI *PSTOR_SYNCHRONIZED_ACCESS)( +(NTAPI *PSTOR_SYNCHRONIZED_ACCESS)( IN PVOID HwDeviceExtension, IN PVOID Context); STORPORTAPI VOID -DDKAPI +NTAPI StorPortSynchronizeAccess( IN PVOID HwDeviceExtension, IN PSTOR_SYNCHRONIZED_ACCESS SynchronizedAccessRoutine, diff --git a/reactos/include/ddk/tdikrnl.h b/reactos/include/ddk/tdikrnl.h index 7c5f90dfcd3..b6a30118b96 100644 --- a/reactos/include/ddk/tdikrnl.h +++ b/reactos/include/ddk/tdikrnl.h @@ -157,7 +157,7 @@ typedef struct _TDI_REQUEST_KERNEL_SET_INFO { #define TDI_EVENT_ERROR_EX 10 typedef NTSTATUS -(DDKAPI *PTDI_IND_CONNECT)( +(NTAPI *PTDI_IND_CONNECT)( IN PVOID TdiEventContext, IN LONG RemoteAddressLength, IN PVOID RemoteAddress, @@ -170,7 +170,7 @@ typedef NTSTATUS TDIKRNLAPI NTSTATUS -DDKAPI +NTAPI TdiDefaultConnectHandler( IN PVOID TdiEventContext, IN LONG RemoteAddressLength, @@ -183,7 +183,7 @@ TdiDefaultConnectHandler( OUT PIRP *AcceptIrp); typedef NTSTATUS -(DDKAPI *PTDI_IND_DISCONNECT)( +(NTAPI *PTDI_IND_DISCONNECT)( IN PVOID TdiEventContext, IN CONNECTION_CONTEXT ConnectionContext, IN LONG DisconnectDataLength, @@ -194,7 +194,7 @@ typedef NTSTATUS TDIKRNLAPI NTSTATUS -DDKAPI +NTAPI TdiDefaultDisconnectHandler( IN PVOID TdiEventContext, IN CONNECTION_CONTEXT ConnectionContext, @@ -205,25 +205,25 @@ TdiDefaultDisconnectHandler( IN ULONG DisconnectFlags); typedef NTSTATUS -(DDKAPI *PTDI_IND_ERROR)( +(NTAPI *PTDI_IND_ERROR)( IN PVOID TdiEventContext, IN NTSTATUS Status); typedef NTSTATUS -(DDKAPI *PTDI_IND_ERROR_EX)( +(NTAPI *PTDI_IND_ERROR_EX)( IN PVOID TdiEventContext, IN NTSTATUS Status, IN PVOID Buffer); TDIKRNLAPI NTSTATUS -DDKAPI +NTAPI TdiDefaultErrorHandler( IN PVOID TdiEventContext, IN NTSTATUS Status); typedef NTSTATUS -(DDKAPI *PTDI_IND_RECEIVE)( +(NTAPI *PTDI_IND_RECEIVE)( IN PVOID TdiEventContext, IN CONNECTION_CONTEXT ConnectionContext, IN ULONG ReceiveFlags, @@ -235,7 +235,7 @@ typedef NTSTATUS TDIKRNLAPI NTSTATUS -DDKAPI +NTAPI TdiDefaultReceiveHandler( IN PVOID TdiEventContext, IN CONNECTION_CONTEXT ConnectionContext, @@ -247,7 +247,7 @@ TdiDefaultReceiveHandler( OUT PIRP *IoRequestPacket); typedef NTSTATUS -(DDKAPI *PTDI_IND_RECEIVE_DATAGRAM)( +(NTAPI *PTDI_IND_RECEIVE_DATAGRAM)( IN PVOID TdiEventContext, IN LONG SourceAddressLength, IN PVOID SourceAddress, @@ -261,7 +261,7 @@ typedef NTSTATUS OUT PIRP *IoRequestPacket); TDIKRNLAPI -NTSTATUS DDKAPI +NTSTATUS NTAPI TdiDefaultRcvDatagramHandler( IN PVOID TdiEventContext, IN LONG SourceAddressLength, @@ -276,7 +276,7 @@ TdiDefaultRcvDatagramHandler( OUT PIRP *IoRequestPacket); typedef NTSTATUS -(DDKAPI *PTDI_IND_RECEIVE_EXPEDITED)( +(NTAPI *PTDI_IND_RECEIVE_EXPEDITED)( IN PVOID TdiEventContext, IN CONNECTION_CONTEXT ConnectionContext, IN ULONG ReceiveFlags, @@ -288,7 +288,7 @@ typedef NTSTATUS TDIKRNLAPI NTSTATUS -DDKAPI +NTAPI TdiDefaultRcvExpeditedHandler( IN PVOID TdiEventContext, IN CONNECTION_CONTEXT ConnectionContext, @@ -300,7 +300,7 @@ TdiDefaultRcvExpeditedHandler( OUT PIRP *IoRequestPacket); typedef NTSTATUS -(DDKAPI *PTDI_IND_CHAINED_RECEIVE)( +(NTAPI *PTDI_IND_CHAINED_RECEIVE)( IN PVOID TdiEventContext, IN CONNECTION_CONTEXT ConnectionContext, IN ULONG ReceiveFlags, @@ -311,7 +311,7 @@ typedef NTSTATUS TDIKRNLAPI NTSTATUS -DDKAPI +NTAPI TdiDefaultChainedReceiveHandler( IN PVOID TdiEventContext, IN CONNECTION_CONTEXT ConnectionContext, @@ -322,7 +322,7 @@ TdiDefaultChainedReceiveHandler( IN PVOID TsduDescriptor); typedef NTSTATUS -(DDKAPI *PTDI_IND_CHAINED_RECEIVE_DATAGRAM)( +(NTAPI *PTDI_IND_CHAINED_RECEIVE_DATAGRAM)( IN PVOID TdiEventContext, IN LONG SourceAddressLength, IN PVOID SourceAddress, @@ -336,7 +336,7 @@ typedef NTSTATUS TDIKRNLAPI NTSTATUS -DDKAPI +NTAPI TdiDefaultChainedRcvDatagramHandler( IN PVOID TdiEventContext, IN LONG SourceAddressLength, @@ -350,7 +350,7 @@ TdiDefaultChainedRcvDatagramHandler( IN PVOID TsduDescriptor); typedef NTSTATUS -(DDKAPI *PTDI_IND_CHAINED_RECEIVE_EXPEDITED)( +(NTAPI *PTDI_IND_CHAINED_RECEIVE_EXPEDITED)( IN PVOID TdiEventContext, IN CONNECTION_CONTEXT ConnectionContext, IN ULONG ReceiveFlags, @@ -361,7 +361,7 @@ typedef NTSTATUS TDIKRNLAPI NTSTATUS -DDKAPI +NTAPI TdiDefaultChainedRcvExpeditedHandler( IN PVOID TdiEventContext, IN CONNECTION_CONTEXT ConnectionContext, @@ -372,14 +372,14 @@ TdiDefaultChainedRcvExpeditedHandler( IN PVOID TsduDescriptor); typedef NTSTATUS -(DDKAPI *PTDI_IND_SEND_POSSIBLE)( +(NTAPI *PTDI_IND_SEND_POSSIBLE)( IN PVOID TdiEventContext, IN PVOID ConnectionContext, IN ULONG BytesAvailable); TDIKRNLAPI NTSTATUS -DDKAPI +NTAPI TdiDefaultSendPossibleHandler( IN PVOID TdiEventContext, IN PVOID ConnectionContext, @@ -611,7 +611,7 @@ TdiDefaultSendPossibleHandler( TDIKRNLAPI VOID -DDKAPI +NTAPI TdiBuildNetbiosAddress( IN PUCHAR NetbiosName, IN BOOLEAN IsGroupName, @@ -619,7 +619,7 @@ TdiBuildNetbiosAddress( TDIKRNLAPI NTSTATUS -DDKAPI +NTAPI TdiBuildNetbiosAddressEa( IN PUCHAR Buffer, IN BOOLEAN IsGroupName, @@ -869,48 +869,48 @@ typedef struct _TDI_PNP_CONTEXT { } TDI_PNP_CONTEXT, *PTDI_PNP_CONTEXT; typedef VOID -(DDKAPI *TDI_ADD_ADDRESS_HANDLER)( +(NTAPI *TDI_ADD_ADDRESS_HANDLER)( IN PTA_ADDRESS Address); typedef VOID -(DDKAPI *TDI_ADD_ADDRESS_HANDLER_V2)( +(NTAPI *TDI_ADD_ADDRESS_HANDLER_V2)( IN PTA_ADDRESS Address, IN PUNICODE_STRING DeviceName, IN PTDI_PNP_CONTEXT Context); typedef VOID -(DDKAPI *TDI_BINDING_HANDLER)( +(NTAPI *TDI_BINDING_HANDLER)( IN TDI_PNP_OPCODE PnPOpcode, IN PUNICODE_STRING DeviceName, IN PWSTR MultiSZBindList); typedef VOID -(DDKAPI *TDI_BIND_HANDLER)( +(NTAPI *TDI_BIND_HANDLER)( IN PUNICODE_STRING DeviceName); typedef VOID -(DDKAPI *TDI_DEL_ADDRESS_HANDLER)( +(NTAPI *TDI_DEL_ADDRESS_HANDLER)( IN PTA_ADDRESS Address); typedef VOID -(DDKAPI *TDI_DEL_ADDRESS_HANDLER_V2)( +(NTAPI *TDI_DEL_ADDRESS_HANDLER_V2)( IN PTA_ADDRESS Address, IN PUNICODE_STRING DeviceName, IN PTDI_PNP_CONTEXT Context); typedef NTSTATUS -(DDKAPI *TDI_PNP_POWER_HANDLER)( +(NTAPI *TDI_PNP_POWER_HANDLER)( IN PUNICODE_STRING DeviceName, IN PNET_PNP_EVENT PowerEvent, IN PTDI_PNP_CONTEXT Context1, IN PTDI_PNP_CONTEXT Context2); typedef VOID -(DDKAPI *TDI_UNBIND_HANDLER)( +(NTAPI *TDI_UNBIND_HANDLER)( IN PUNICODE_STRING DeviceName); typedef VOID -(DDKAPI *ProviderPnPPowerComplete)( +(NTAPI *ProviderPnPPowerComplete)( IN PNET_PNP_EVENT NetEvent, IN NTSTATUS ProviderStatus); @@ -964,7 +964,7 @@ typedef TDI_CLIENT_INTERFACE_INFO *PTDI_CLIENT_INTERFACE_INFO; TDIKRNLAPI NTSTATUS -DDKAPI +NTAPI TdiCopyBufferToMdl( IN PVOID SourceBuffer, IN ULONG SourceOffset, @@ -986,7 +986,7 @@ TdiCopyBufferToMdl( TDIKRNLAPI NTSTATUS -DDKAPI +NTAPI TdiCopyMdlChainToMdlChain ( IN PMDL SourceMdlChain, IN ULONG SourceOffset, @@ -996,7 +996,7 @@ TdiCopyMdlChainToMdlChain ( TDIKRNLAPI NTSTATUS -DDKAPI +NTAPI TdiCopyMdlToBuffer( IN PMDL SourceMdlChain, IN ULONG SourceOffset, @@ -1007,55 +1007,55 @@ TdiCopyMdlToBuffer( TDIKRNLAPI NTSTATUS -DDKAPI +NTAPI TdiDeregisterAddressChangeHandler( IN HANDLE BindingHandle); TDIKRNLAPI NTSTATUS -DDKAPI +NTAPI TdiDeregisterDeviceObject( IN HANDLE DevRegistrationHandle); TDIKRNLAPI NTSTATUS -DDKAPI +NTAPI TdiDeregisterNetAddress( IN HANDLE AddrRegistrationHandle); TDIKRNLAPI NTSTATUS -DDKAPI +NTAPI TdiDeregisterPnPHandlers( IN HANDLE BindingHandle); TDIKRNLAPI NTSTATUS -DDKAPI +NTAPI TdiDeregisterProvider( IN HANDLE ProviderHandle); TDIKRNLAPI NTSTATUS -DDKAPI +NTAPI TdiEnumerateAddresses( IN HANDLE BindingHandle); TDIKRNLAPI VOID -DDKAPI +NTAPI TdiInitialize( VOID); TDIKRNLAPI VOID -DDKAPI +NTAPI TdiMapBuffer( IN PMDL MdlChain); TDIKRNLAPI NTSTATUS -DDKAPI +NTAPI TdiMapUserRequest( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, @@ -1063,14 +1063,14 @@ TdiMapUserRequest( TDIKRNLAPI BOOLEAN -DDKAPI +NTAPI TdiMatchPdoWithChainedReceiveContext( IN PVOID TsduDescriptor, IN PVOID PDO); TDIKRNLAPI VOID -DDKAPI +NTAPI TdiPnPPowerComplete( IN HANDLE BindingHandle, IN PNET_PNP_EVENT PowerEvent, @@ -1078,7 +1078,7 @@ TdiPnPPowerComplete( TDIKRNLAPI NTSTATUS -DDKAPI +NTAPI TdiPnPPowerRequest( IN PUNICODE_STRING DeviceName, IN PNET_PNP_EVENT PowerEvent, @@ -1088,13 +1088,13 @@ TdiPnPPowerRequest( TDIKRNLAPI NTSTATUS -DDKAPI +NTAPI TdiProviderReady( IN HANDLE ProviderHandle); TDIKRNLAPI NTSTATUS -DDKAPI +NTAPI TdiRegisterAddressChangeHandler( IN TDI_ADD_ADDRESS_HANDLER AddHandler, IN TDI_DEL_ADDRESS_HANDLER DeleteHandler, @@ -1102,14 +1102,14 @@ TdiRegisterAddressChangeHandler( TDIKRNLAPI NTSTATUS -DDKAPI +NTAPI TdiRegisterDeviceObject( IN PUNICODE_STRING DeviceName, OUT HANDLE *DevRegistrationHandle); TDIKRNLAPI NTSTATUS -DDKAPI +NTAPI TdiRegisterNetAddress( IN PTA_ADDRESS Address, IN PUNICODE_STRING DeviceName, @@ -1118,7 +1118,7 @@ TdiRegisterNetAddress( TDIKRNLAPI NTSTATUS -DDKAPI +NTAPI TdiRegisterNotificationHandler( IN TDI_BIND_HANDLER BindHandler, IN TDI_UNBIND_HANDLER UnbindHandler, @@ -1126,7 +1126,7 @@ TdiRegisterNotificationHandler( TDIKRNLAPI NTSTATUS -DDKAPI +NTAPI TdiRegisterPnPHandlers( IN PTDI_CLIENT_INTERFACE_INFO ClientInterfaceInfo, IN ULONG InterfaceInfoSize, @@ -1134,21 +1134,21 @@ TdiRegisterPnPHandlers( TDIKRNLAPI NTSTATUS -DDKAPI +NTAPI TdiRegisterProvider( IN PUNICODE_STRING ProviderName, OUT HANDLE *ProviderHandle); TDIKRNLAPI VOID -DDKAPI +NTAPI TdiReturnChainedReceives( IN PVOID *TsduDescriptors, IN ULONG NumberOfTsdus); TDIKRNLAPI VOID -DDKAPI +NTAPI TdiUnmapBuffer( IN PMDL MdlChain); diff --git a/reactos/include/ddk/upssvc.h b/reactos/include/ddk/upssvc.h index 1d3792acfa0..8672519694b 100644 --- a/reactos/include/ddk/upssvc.h +++ b/reactos/include/ddk/upssvc.h @@ -42,12 +42,12 @@ extern "C" { UPSAPI VOID -DDKAPI +NTAPI UPSCancelWait(VOID); UPSAPI DWORD -DDKAPI +NTAPI UPSGetState(VOID); #define UPS_INITUNKNOWNERROR 0 @@ -60,23 +60,23 @@ UPSGetState(VOID); UPSAPI DWORD -DDKAPI +NTAPI UPSInit(VOID); UPSAPI VOID -DDKAPI +NTAPI UPSStop(VOID); UPSAPI VOID -DDKAPI +NTAPI UPSTurnOff( IN DWORD aTurnOffDelay); UPSAPI VOID -DDKAPI +NTAPI UPSWaitForStateChange( IN DWORD aCurrentState, IN DWORD anInterval); diff --git a/reactos/include/ddk/video.h b/reactos/include/ddk/video.h index 047a56721d9..6294b5a5a75 100644 --- a/reactos/include/ddk/video.h +++ b/reactos/include/ddk/video.h @@ -76,7 +76,7 @@ typedef enum _HW_DMA_RETURN { } HW_DMA_RETURN, *PHW_DMA_RETURN; typedef HW_DMA_RETURN -(DDKAPI *PVIDEO_HW_START_DMA)( +(NTAPI *PVIDEO_HW_START_DMA)( PVOID HwDeviceExtension, PDMA pDma); @@ -144,14 +144,14 @@ typedef struct _VP_SCATTER_GATHER_LIST { } VP_SCATTER_GATHER_LIST, *PVP_SCATTER_GATHER_LIST; typedef VOID -(DDKAPI *PEXECUTE_DMA)( +(NTAPI *PEXECUTE_DMA)( IN PVOID HwDeviceExtension, IN PVP_DMA_ADAPTER VpDmaAdapter, IN PVP_SCATTER_GATHER_LIST SGList, IN PVOID Context); typedef PVOID -(DDKAPI *PVIDEO_PORT_GET_PROC_ADDRESS)( +(NTAPI *PVIDEO_PORT_GET_PROC_ADDRESS)( IN PVOID HwDeviceExtension, IN PUCHAR FunctionName); @@ -188,7 +188,7 @@ typedef struct _VIDEO_PORT_CONFIG_INFO { } VIDEO_PORT_CONFIG_INFO, *PVIDEO_PORT_CONFIG_INFO; typedef VP_STATUS -(DDKAPI *PVIDEO_HW_FIND_ADAPTER)( +(NTAPI *PVIDEO_HW_FIND_ADAPTER)( IN PVOID HwDeviceExtension, IN PVOID HwContext, IN PWSTR ArgumentString, @@ -196,7 +196,7 @@ typedef VP_STATUS OUT PUCHAR Again); typedef VP_STATUS -(DDKAPI *PVIDEO_HW_POWER_GET)( +(NTAPI *PVIDEO_HW_POWER_GET)( IN PVOID HwDeviceExtension, IN ULONG HwId, IN OUT PVIDEO_POWER_MANAGEMENT VideoPowerControl); @@ -224,7 +224,7 @@ typedef enum _VIDEO_CHILD_TYPE { } VIDEO_CHILD_TYPE, *PVIDEO_CHILD_TYPE; typedef VP_STATUS -(DDKAPI *PVIDEO_HW_GET_CHILD_DESCRIPTOR)( +(NTAPI *PVIDEO_HW_GET_CHILD_DESCRIPTOR)( IN PVOID HwDeviceExtension, IN PVIDEO_CHILD_ENUM_INFO ChildEnumInfo, OUT PVIDEO_CHILD_TYPE VideoChildType, @@ -233,11 +233,11 @@ typedef VP_STATUS OUT PULONG pUnused); typedef BOOLEAN -(DDKAPI *PVIDEO_HW_INITIALIZE)( +(NTAPI *PVIDEO_HW_INITIALIZE)( IN PVOID HwDeviceExtension); typedef BOOLEAN -(DDKAPI *PVIDEO_HW_INTERRUPT)( +(NTAPI *PVIDEO_HW_INTERRUPT)( IN PVOID HwDeviceExtension); /* VIDEO_ACCESS_RANGE.RangePassive */ @@ -257,14 +257,14 @@ typedef struct _VIDEO_ACCESS_RANGE { #endif typedef VOID -(DDKAPI *PVIDEO_HW_LEGACYRESOURCES)( +(NTAPI *PVIDEO_HW_LEGACYRESOURCES)( IN ULONG VendorId, IN ULONG DeviceId, IN OUT PVIDEO_ACCESS_RANGE *LegacyResourceList, IN OUT PULONG LegacyResourceCount); typedef VP_STATUS -(DDKAPI *PMINIPORT_QUERY_DEVICE_ROUTINE)( +(NTAPI *PMINIPORT_QUERY_DEVICE_ROUTINE)( IN PVOID HwDeviceExtension, IN PVOID Context, IN VIDEO_DEVICE_DATA_TYPE DeviceDataType, @@ -284,12 +284,12 @@ typedef struct _QUERY_INTERFACE { } QUERY_INTERFACE, *PQUERY_INTERFACE; typedef VP_STATUS -(DDKAPI *PVIDEO_HW_QUERY_INTERFACE)( +(NTAPI *PVIDEO_HW_QUERY_INTERFACE)( IN PVOID HwDeviceExtension, IN OUT PQUERY_INTERFACE QueryInterface); typedef VP_STATUS -(DDKAPI *PMINIPORT_GET_REGISTRY_ROUTINE)( +(NTAPI *PMINIPORT_GET_REGISTRY_ROUTINE)( IN PVOID HwDeviceExtension, IN PVOID Context, IN OUT PWSTR ValueName, @@ -297,13 +297,13 @@ typedef VP_STATUS IN ULONG ValueLength); typedef BOOLEAN -(DDKAPI *PVIDEO_HW_RESET_HW)( +(NTAPI *PVIDEO_HW_RESET_HW)( IN PVOID HwDeviceExtension, IN ULONG Columns, IN ULONG Rows); typedef VP_STATUS -(DDKAPI *PVIDEO_HW_POWER_SET)( +(NTAPI *PVIDEO_HW_POWER_SET)( IN PVOID HwDeviceExtension, IN ULONG HwId, IN PVIDEO_POWER_MANAGEMENT VideoPowerControl); @@ -326,32 +326,32 @@ typedef struct _VIDEO_REQUEST_PACKET { } VIDEO_REQUEST_PACKET, *PVIDEO_REQUEST_PACKET; typedef BOOLEAN -(DDKAPI *PVIDEO_HW_START_IO)( +(NTAPI *PVIDEO_HW_START_IO)( IN PVOID HwDeviceExtension, IN PVIDEO_REQUEST_PACKET RequestPacket); typedef BOOLEAN -(DDKAPI *PMINIPORT_SYNCHRONIZE_ROUTINE)( +(NTAPI *PMINIPORT_SYNCHRONIZE_ROUTINE)( IN PVOID Context); typedef VOID -(DDKAPI *PVIDEO_HW_TIMER)( +(NTAPI *PVIDEO_HW_TIMER)( IN PVOID HwDeviceExtension); typedef VOID -(DDKAPI *PMINIPORT_DPC_ROUTINE)( +(NTAPI *PMINIPORT_DPC_ROUTINE)( IN PVOID HwDeviceExtension, IN PVOID Context); typedef VP_STATUS -(DDKAPI *PDRIVER_IO_PORT_UCHAR)( +(NTAPI *PDRIVER_IO_PORT_UCHAR)( IN ULONG_PTR Context, IN ULONG Port, IN UCHAR AccessMode, IN PUCHAR Data); typedef VP_STATUS -(DDKAPI *PDRIVER_IO_PORT_UCHAR_STRING)( +(NTAPI *PDRIVER_IO_PORT_UCHAR_STRING)( IN ULONG_PTR Context, IN ULONG Port, IN UCHAR AccessMode, @@ -359,14 +359,14 @@ typedef VP_STATUS IN ULONG DataLength); typedef VP_STATUS -(DDKAPI *PDRIVER_IO_PORT_ULONG)( +(NTAPI *PDRIVER_IO_PORT_ULONG)( IN ULONG_PTR Context, IN ULONG Port, IN UCHAR AccessMode, IN PULONG Data); typedef VP_STATUS -(DDKAPI *PDRIVER_IO_PORT_ULONG_STRING)( +(NTAPI *PDRIVER_IO_PORT_ULONG_STRING)( IN ULONG_PTR Context, IN ULONG Port, IN UCHAR AccessMode, @@ -374,14 +374,14 @@ typedef VP_STATUS IN ULONG DataLength); typedef VP_STATUS -(DDKAPI *PDRIVER_IO_PORT_USHORT)( +(NTAPI *PDRIVER_IO_PORT_USHORT)( IN ULONG_PTR Context, IN ULONG Port, IN UCHAR AccessMode, IN PUSHORT Data); typedef VP_STATUS -(DDKAPI *PDRIVER_IO_PORT_USHORT_STRING)( +(NTAPI *PDRIVER_IO_PORT_USHORT_STRING)( IN ULONG_PTR Context, IN ULONG Port, IN UCHAR AccessMode, @@ -480,21 +480,21 @@ typedef struct _VIDEO_PORT_AGP_INTERFACE_2 { #define VIDEO_PORT_I2C_INTERFACE_VERSION_1 1 typedef VOID -(DDKAPI *PVIDEO_WRITE_CLOCK_LINE)( +(NTAPI *PVIDEO_WRITE_CLOCK_LINE)( PVOID HwDeviceExtension, UCHAR Data); typedef VOID -(DDKAPI *PVIDEO_WRITE_DATA_LINE)( +(NTAPI *PVIDEO_WRITE_DATA_LINE)( PVOID HwDeviceExtension, UCHAR Data); typedef BOOLEAN -(DDKAPI *PVIDEO_READ_CLOCK_LINE)( +(NTAPI *PVIDEO_READ_CLOCK_LINE)( PVOID HwDeviceExtension); typedef BOOLEAN -(DDKAPI *PVIDEO_READ_DATA_LINE)( +(NTAPI *PVIDEO_READ_DATA_LINE)( PVOID HwDeviceExtension); typedef struct _I2C_CALLBACKS @@ -506,24 +506,24 @@ typedef struct _I2C_CALLBACKS } I2C_CALLBACKS, *PI2C_CALLBACKS; typedef BOOLEAN -(DDKAPI *PI2C_START)( +(NTAPI *PI2C_START)( IN PVOID HwDeviceExtension, IN PI2C_CALLBACKS I2CCallbacks); typedef BOOLEAN -(DDKAPI *PI2C_STOP)( +(NTAPI *PI2C_STOP)( IN PVOID HwDeviceExtension, IN PI2C_CALLBACKS I2CCallbacks); typedef BOOLEAN -(DDKAPI *PI2C_WRITE)( +(NTAPI *PI2C_WRITE)( IN PVOID HwDeviceExtension, IN PI2C_CALLBACKS I2CCallbacks, IN PUCHAR Buffer, IN ULONG Length); typedef BOOLEAN -(DDKAPI *PI2C_READ)( +(NTAPI *PI2C_READ)( IN PVOID HwDeviceExtension, IN PI2C_CALLBACKS I2CCallbacks, OUT PUCHAR Buffer, @@ -545,25 +545,25 @@ typedef struct _VIDEO_PORT_I2C_INTERFACE { #define VIDEO_PORT_INT10_INTERFACE_VERSION_1 1 typedef VP_STATUS -(DDKAPI *PINT10_ALLOCATE_BUFFER)( +(NTAPI *PINT10_ALLOCATE_BUFFER)( IN PVOID Context, OUT PUSHORT Seg, OUT PUSHORT Off, IN OUT PULONG Length); typedef VP_STATUS -(DDKAPI *PINT10_CALL_BIOS)( +(NTAPI *PINT10_CALL_BIOS)( IN PVOID Context, IN OUT PINT10_BIOS_ARGUMENTS BiosArguments); typedef VP_STATUS -(DDKAPI *PINT10_FREE_BUFFER)( +(NTAPI *PINT10_FREE_BUFFER)( IN PVOID Context, IN USHORT Seg, IN USHORT Off); typedef VP_STATUS -(DDKAPI *PINT10_READ_MEMORY)( +(NTAPI *PINT10_READ_MEMORY)( IN PVOID Context, IN USHORT Seg, IN USHORT Off, @@ -571,7 +571,7 @@ typedef VP_STATUS IN ULONG Length); typedef VP_STATUS -(DDKAPI *PINT10_WRITE_MEMORY)( +(NTAPI *PINT10_WRITE_MEMORY)( IN PVOID Context, IN USHORT Seg, IN USHORT Off, @@ -630,13 +630,13 @@ typedef struct _VPOSVERSIONINFO { VPAPI VOID -DDKAPI +NTAPI VideoPortAcquireDeviceLock( IN PVOID HwDeviceExtension); VPAPI VOID -DDKAPI +NTAPI VideoPortAcquireSpinLock( IN PVOID HwDeviceExtension, IN PSPIN_LOCK SpinLock, @@ -644,14 +644,14 @@ VideoPortAcquireSpinLock( VPAPI VOID -DDKAPI +NTAPI VideoPortAcquireSpinLockAtDpcLevel( IN PVOID HwDeviceExtension, IN PSPIN_LOCK SpinLock); VPAPI VP_STATUS -DDKAPI +NTAPI VideoPortAllocateBuffer( IN PVOID HwDeviceExtension, IN ULONG Size, @@ -659,7 +659,7 @@ VideoPortAllocateBuffer( VPAPI PVOID -DDKAPI +NTAPI VideoPortAllocateCommonBuffer( IN PVOID HwDeviceExtension, IN PVP_DMA_ADAPTER VpDmaAdapter, @@ -670,7 +670,7 @@ VideoPortAllocateCommonBuffer( VPAPI PVOID -DDKAPI +NTAPI VideoPortAllocateContiguousMemory( IN PVOID HwDeviceExtension, IN ULONG NumberOfBytes, @@ -686,7 +686,7 @@ typedef enum _VP_POOL_TYPE { VPAPI PVOID -DDKAPI +NTAPI VideoPortAllocatePool( IN PVOID HwDeviceExtension, IN VP_POOL_TYPE PoolType, @@ -695,7 +695,7 @@ VideoPortAllocatePool( VPAPI PDMA -DDKAPI +NTAPI VideoPortAssociateEventsWithDmaHandle( IN PVOID HwDeviceExtension, IN OUT PVIDEO_REQUEST_PACKET pVrp, @@ -708,7 +708,7 @@ VideoPortAssociateEventsWithDmaHandle( VPAPI BOOLEAN -DDKAPI +NTAPI VideoPortCheckForDeviceExistence( IN PVOID HwDeviceExtension, IN USHORT VendorId, @@ -720,14 +720,14 @@ VideoPortCheckForDeviceExistence( VPAPI VOID -DDKAPI +NTAPI VideoPortClearEvent( IN PVOID HwDeviceExtension, IN PEVENT pEvent); VPAPI ULONG -DDKAPI +NTAPI VideoPortCompareMemory( IN PVOID Source1, IN PVOID Source2, @@ -735,7 +735,7 @@ VideoPortCompareMemory( VPAPI VP_STATUS -DDKAPI +NTAPI VideoPortCompleteDma( IN PVOID HwDeviceExtension, IN PVP_DMA_ADAPTER VpDmaAdapter, @@ -744,7 +744,7 @@ VideoPortCompleteDma( VPAPI VP_STATUS -DDKAPI +NTAPI VideoPortCreateEvent( IN PVOID HwDeviceExtension, IN ULONG EventFlag, @@ -753,7 +753,7 @@ VideoPortCreateEvent( VPAPI VP_STATUS -DDKAPI +NTAPI VideoPortCreateSecondaryDisplay( IN PVOID HwDeviceExtension, IN OUT PVOID *SecondaryDeviceExtension, @@ -761,7 +761,7 @@ VideoPortCreateSecondaryDisplay( VPAPI VP_STATUS -DDKAPI +NTAPI VideoPortCreateSpinLock( IN PVOID HwDeviceExtension, OUT PSPIN_LOCK *SpinLock); @@ -774,7 +774,7 @@ typedef struct _DDC_CONTROL { VPAPI BOOLEAN -DDKAPI +NTAPI VideoPortDDCMonitorHelper( IN PVOID HwDeviceExtension, IN PVOID DDCControl, @@ -783,7 +783,7 @@ VideoPortDDCMonitorHelper( VPAPI VOID -DDKCDECLAPI +__cdecl VideoPortDebugPrint( IN VIDEO_DEBUG_LEVEL DebugPrintLevel, IN PCHAR DebugMessage, @@ -791,27 +791,27 @@ VideoPortDebugPrint( VPAPI VP_STATUS -DDKAPI +NTAPI VideoPortDeleteEvent( IN PVOID HwDeviceExtension, IN PEVENT pEvent); VPAPI VP_STATUS -DDKAPI +NTAPI VideoPortDeleteSpinLock( IN PVOID HwDeviceExtension, IN PSPIN_LOCK SpinLock); VPAPI VP_STATUS -DDKAPI +NTAPI VideoPortDisableInterrupt( IN PVOID HwDeviceExtension); VPAPI PDMA -DDKAPI +NTAPI VideoPortDoDma( IN PVOID HwDeviceExtension, IN PDMA pDma, @@ -819,20 +819,20 @@ VideoPortDoDma( VPAPI VP_STATUS -DDKAPI +NTAPI VideoPortEnableInterrupt( IN PVOID HwDeviceExtension); VPAPI VP_STATUS -DDKAPI +NTAPI VideoPortEnumerateChildren( IN PVOID HwDeviceExtension, IN PVOID Reserved); VPAPI VOID -DDKAPI +NTAPI VideoPortFreeCommonBuffer( IN PVOID HwDeviceExtension, IN ULONG Length, @@ -842,21 +842,21 @@ VideoPortFreeCommonBuffer( VPAPI VOID -DDKAPI +NTAPI VideoPortFreeDeviceBase( IN PVOID HwDeviceExtension, IN PVOID MappedAddress); VPAPI VOID -DDKAPI +NTAPI VideoPortFreePool( IN PVOID HwDeviceExtension, IN PVOID Ptr); VPAPI VP_STATUS -DDKAPI +NTAPI VideoPortGetAccessRanges( IN PVOID HwDeviceExtension, IN ULONG NumRequestedResources, @@ -869,19 +869,19 @@ VideoPortGetAccessRanges( VPAPI PVOID -DDKAPI +NTAPI VideoPortGetAssociatedDeviceExtension( IN PVOID DeviceObject); VPAPI ULONG -DDKAPI +NTAPI VideoPortGetAssociatedDeviceID( IN PVOID DeviceObject); VPAPI ULONG -DDKAPI +NTAPI VideoPortGetBusData( IN PVOID HwDeviceExtension, IN BUS_DATA_TYPE BusDataType, @@ -892,14 +892,14 @@ VideoPortGetBusData( VPAPI ULONG -DDKAPI +NTAPI VideoPortGetBytesUsed( IN PVOID HwDeviceExtension, IN PDMA pDma); VPAPI PVOID -DDKAPI +NTAPI VideoPortGetCommonBuffer( IN PVOID HwDeviceExtension, IN ULONG DesiredLength, @@ -910,13 +910,13 @@ VideoPortGetCommonBuffer( VPAPI UCHAR -DDKAPI +NTAPI VideoPortGetCurrentIrql( VOID); VPAPI PVOID -DDKAPI +NTAPI VideoPortGetDeviceBase( IN PVOID HwDeviceExtension, IN PHYSICAL_ADDRESS IoAddress, @@ -925,7 +925,7 @@ VideoPortGetDeviceBase( VPAPI VP_STATUS -DDKAPI +NTAPI VideoPortGetDeviceData( IN PVOID HwDeviceExtension, IN VIDEO_DEVICE_DATA_TYPE DeviceDataType, @@ -934,28 +934,28 @@ VideoPortGetDeviceData( VPAPI PVP_DMA_ADAPTER -DDKAPI +NTAPI VideoPortGetDmaAdapter( IN PVOID HwDeviceExtension, IN PVP_DEVICE_DESCRIPTION VpDeviceDescription); VPAPI PVOID -DDKAPI +NTAPI VideoPortGetDmaContext( IN PVOID HwDeviceExtension, IN PDMA pDma); VPAPI PVOID -DDKAPI +NTAPI VideoPortGetMdl( IN PVOID HwDeviceExtension, IN PDMA pDma); VPAPI VP_STATUS -DDKAPI +NTAPI VideoPortGetRegistryParameters( IN PVOID HwDeviceExtension, IN PWSTR ParameterName, @@ -965,7 +965,7 @@ VideoPortGetRegistryParameters( VPAPI PVOID -DDKAPI +NTAPI VideoPortGetRomImage( IN PVOID HwDeviceExtension, IN PVOID Unused1, @@ -974,21 +974,21 @@ VideoPortGetRomImage( VPAPI VP_STATUS -DDKAPI +NTAPI VideoPortGetVersion( IN PVOID HwDeviceExtension, IN OUT PVPOSVERSIONINFO pVpOsVersionInfo); VPAPI VP_STATUS -DDKAPI +NTAPI VideoPortGetVgaStatus( IN PVOID HwDeviceExtension, OUT PULONG VgaStatus); VPAPI ULONG -DDKAPI +NTAPI VideoPortInitialize( IN PVOID Argument1, IN PVOID Argument2, @@ -997,7 +997,7 @@ VideoPortInitialize( VPAPI VP_STATUS -DDKAPI +NTAPI VideoPortInt10( IN PVOID HwDeviceExtension, IN PVIDEO_X86_BIOS_ARGUMENTS BiosArguments); @@ -1029,7 +1029,7 @@ typedef enum _VP_LOCK_OPERATION { VPAPI PVOID -DDKAPI +NTAPI VideoPortLockBuffer( IN PVOID HwDeviceExtension, IN PVOID BaseAddress, @@ -1038,7 +1038,7 @@ VideoPortLockBuffer( VPAPI BOOLEAN -DDKAPI +NTAPI VideoPortLockPages( IN PVOID HwDeviceExtension, IN OUT PVIDEO_REQUEST_PACKET pVrp, @@ -1048,7 +1048,7 @@ VideoPortLockPages( VPAPI VOID -DDKAPI +NTAPI VideoPortLogError( IN PVOID HwDeviceExtension, IN PVIDEO_REQUEST_PACKET Vrp OPTIONAL, @@ -1057,7 +1057,7 @@ VideoPortLogError( VPAPI VP_STATUS -DDKAPI +NTAPI VideoPortMapBankedMemory( IN PVOID HwDeviceExtension, IN PHYSICAL_ADDRESS PhysicalAddress, @@ -1071,7 +1071,7 @@ VideoPortMapBankedMemory( VPAPI PDMA -DDKAPI +NTAPI VideoPortMapDmaMemory( IN PVOID HwDeviceExtension, IN PVIDEO_REQUEST_PACKET pVrp, @@ -1084,7 +1084,7 @@ VideoPortMapDmaMemory( VPAPI VP_STATUS -DDKAPI +NTAPI VideoPortMapMemory( IN PVOID HwDeviceExtension, IN PHYSICAL_ADDRESS PhysicalAddress, @@ -1094,7 +1094,7 @@ VideoPortMapMemory( VPAPI VOID -DDKAPI +NTAPI VideoPortMoveMemory( IN PVOID Destination, IN PVOID Source, @@ -1102,14 +1102,14 @@ VideoPortMoveMemory( VPAPI VOID -DDKAPI +NTAPI VideoPortPutDmaAdapter( IN PVOID HwDeviceExtension, IN PVP_DMA_ADAPTER VpDmaAdapter); VPAPI LONGLONG -DDKAPI +NTAPI VideoPortQueryPerformanceCounter( IN PVOID HwDeviceExtension, OUT PLONGLONG PerformanceFrequency OPTIONAL); @@ -1124,7 +1124,7 @@ typedef enum _VIDEO_PORT_SERVICES { VPAPI VP_STATUS -DDKAPI +NTAPI VideoPortQueryServices( IN PVOID HwDeviceExtension, IN VIDEO_PORT_SERVICES ServicesType, @@ -1132,20 +1132,20 @@ VideoPortQueryServices( VPAPI VOID -DDKAPI +NTAPI VideoPortQuerySystemTime( OUT PLARGE_INTEGER CurrentTime); VPAPI BOOLEAN -DDKAPI +NTAPI VideoPortIsNoVesa( VOID ); VPAPI BOOLEAN -DDKAPI +NTAPI VideoPortQueueDpc( IN PVOID HwDeviceExtension, IN PMINIPORT_DPC_ROUTINE CallbackRoutine, @@ -1153,7 +1153,7 @@ VideoPortQueueDpc( VPAPI VOID -DDKAPI +NTAPI VideoPortReadPortBufferUchar( IN PUCHAR Port, OUT PUCHAR Buffer, @@ -1161,7 +1161,7 @@ VideoPortReadPortBufferUchar( VPAPI VOID -DDKAPI +NTAPI VideoPortReadPortBufferUlong( IN PULONG Port, OUT PULONG Buffer, @@ -1169,7 +1169,7 @@ VideoPortReadPortBufferUlong( VPAPI VOID -DDKAPI +NTAPI VideoPortReadPortBufferUshort( IN PUSHORT Port, OUT PUSHORT Buffer, @@ -1177,25 +1177,25 @@ VideoPortReadPortBufferUshort( VPAPI UCHAR -DDKAPI +NTAPI VideoPortReadPortUchar( IN PUCHAR Port); VPAPI ULONG -DDKAPI +NTAPI VideoPortReadPortUlong( IN PULONG Port); VPAPI USHORT -DDKAPI +NTAPI VideoPortReadPortUshort( IN PUSHORT Port); VPAPI VOID -DDKAPI +NTAPI VideoPortReadRegisterBufferUchar( IN PUCHAR Register, OUT PUCHAR Buffer, @@ -1203,7 +1203,7 @@ VideoPortReadRegisterBufferUchar( VPAPI VOID -DDKAPI +NTAPI VideoPortReadRegisterBufferUlong( IN PULONG Register, OUT PULONG Buffer, @@ -1211,7 +1211,7 @@ VideoPortReadRegisterBufferUlong( VPAPI VOID -DDKAPI +NTAPI VideoPortReadRegisterBufferUshort( IN PUSHORT Register, OUT PUSHORT Buffer, @@ -1219,39 +1219,39 @@ VideoPortReadRegisterBufferUshort( VPAPI UCHAR -DDKAPI +NTAPI VideoPortReadRegisterUchar( IN PUCHAR Register); VPAPI ULONG -DDKAPI +NTAPI VideoPortReadRegisterUlong( IN PULONG Register); VPAPI USHORT -DDKAPI +NTAPI VideoPortReadRegisterUshort( IN PUSHORT Register); VPAPI LONG -DDKAPI +NTAPI VideoPortReadStateEvent( IN PVOID HwDeviceExtension, IN PEVENT pEvent); VPAPI VOID -DDKAPI +NTAPI VideoPortReleaseBuffer( IN PVOID HwDeviceExtension, IN PVOID Buffer); VPAPI VOID -DDKAPI +NTAPI VideoPortReleaseCommonBuffer( IN PVOID HwDeviceExtension, IN PVP_DMA_ADAPTER VpDmaAdapter, @@ -1262,13 +1262,13 @@ VideoPortReleaseCommonBuffer( VPAPI VOID -DDKAPI +NTAPI VideoPortReleaseDeviceLock( IN PVOID HwDeviceExtension); VPAPI VOID -DDKAPI +NTAPI VideoPortReleaseSpinLock( IN PVOID HwDeviceExtension, IN PSPIN_LOCK SpinLock, @@ -1276,14 +1276,14 @@ VideoPortReleaseSpinLock( VPAPI VOID -DDKAPI +NTAPI VideoPortReleaseSpinLockFromDpcLevel( IN PVOID HwDeviceExtension, IN PSPIN_LOCK SpinLock); VPAPI BOOLEAN -DDKAPI +NTAPI VideoPortScanRom( PVOID HwDeviceExtension, PUCHAR RomBase, @@ -1292,7 +1292,7 @@ VideoPortScanRom( VPAPI ULONG -DDKAPI +NTAPI VideoPortSetBusData( IN PVOID HwDeviceExtension, IN BUS_DATA_TYPE BusDataType, @@ -1303,7 +1303,7 @@ VideoPortSetBusData( VPAPI VOID -DDKAPI +NTAPI VideoPortSetBytesUsed( IN PVOID HwDeviceExtension, IN OUT PDMA pDma, @@ -1311,7 +1311,7 @@ VideoPortSetBytesUsed( VPAPI VOID -DDKAPI +NTAPI VideoPortSetDmaContext( IN PVOID HwDeviceExtension, OUT PDMA pDma, @@ -1319,14 +1319,14 @@ VideoPortSetDmaContext( VPAPI LONG -DDKAPI +NTAPI VideoPortSetEvent( IN PVOID HwDeviceExtension, IN PEVENT pEvent); VPAPI VP_STATUS -DDKAPI +NTAPI VideoPortSetRegistryParameters( IN PVOID HwDeviceExtension, IN PWSTR ValueName, @@ -1335,7 +1335,7 @@ VideoPortSetRegistryParameters( VPAPI VP_STATUS -DDKAPI +NTAPI VideoPortSetTrappedEmulatorPorts( IN PVOID HwDeviceExtension, IN ULONG NumAccessRanges, @@ -1343,20 +1343,20 @@ VideoPortSetTrappedEmulatorPorts( VPAPI BOOLEAN -DDKAPI +NTAPI VideoPortSignalDmaComplete( IN PVOID HwDeviceExtension, IN PDMA pDmaHandle); VPAPI VOID -DDKAPI +NTAPI VideoPortStallExecution( IN ULONG Microseconds); VPAPI VP_STATUS -DDKAPI +NTAPI VideoPortStartDma( IN PVOID HwDeviceExtension, IN PVP_DMA_ADAPTER VpDmaAdapter, @@ -1369,13 +1369,13 @@ VideoPortStartDma( VPAPI VOID -DDKAPI +NTAPI VideoPortStartTimer( IN PVOID HwDeviceExtension); VPAPI VOID -DDKAPI +NTAPI VideoPortStopTimer( IN PVOID HwDeviceExtension); @@ -1388,7 +1388,7 @@ typedef enum VIDEO_SYNCHRONIZE_PRIORITY { VPAPI BOOLEAN -DDKAPI +NTAPI VideoPortSynchronizeExecution( IN PVOID HwDeviceExtension, IN VIDEO_SYNCHRONIZE_PRIORITY Priority, @@ -1397,21 +1397,21 @@ VideoPortSynchronizeExecution( VPAPI VOID -DDKAPI +NTAPI VideoPortUnLockBuffer( IN PVOID HwDeviceExtension, IN PVOID Mdl); VPAPI BOOLEAN -DDKAPI +NTAPI VideoPortUnlockPages( IN PVOID hwDeviceExtension, IN OUT PDMA pDma); VPAPI BOOLEAN -DDKAPI +NTAPI VideoPortUnmapDmaMemory( IN PVOID HwDeviceExtension, IN PVOID VirtualAddress, @@ -1420,7 +1420,7 @@ VideoPortUnmapDmaMemory( VPAPI VP_STATUS -DDKAPI +NTAPI VideoPortUnmapMemory( IN PVOID HwDeviceExtension, IN OUT PVOID VirtualAddress, @@ -1428,7 +1428,7 @@ VideoPortUnmapMemory( VPAPI VP_STATUS -DDKAPI +NTAPI VideoPortVerifyAccessRanges( IN PVOID HwDeviceExtension, IN ULONG NumAccessRanges, @@ -1436,7 +1436,7 @@ VideoPortVerifyAccessRanges( VPAPI VP_STATUS -DDKAPI +NTAPI VideoPortWaitForSingleObject( IN PVOID HwDeviceExtension, IN PVOID Object, @@ -1444,7 +1444,7 @@ VideoPortWaitForSingleObject( VPAPI VOID -DDKAPI +NTAPI VideoPortWritePortBufferUchar( IN PUCHAR Port, IN PUCHAR Buffer, @@ -1452,7 +1452,7 @@ VideoPortWritePortBufferUchar( VPAPI VOID -DDKAPI +NTAPI VideoPortWritePortBufferUlong( IN PULONG Port, IN PULONG Buffer, @@ -1460,7 +1460,7 @@ VideoPortWritePortBufferUlong( VPAPI VOID -DDKAPI +NTAPI VideoPortWritePortBufferUshort( IN PUSHORT Port, IN PUSHORT Buffer, @@ -1468,28 +1468,28 @@ VideoPortWritePortBufferUshort( VPAPI VOID -DDKAPI +NTAPI VideoPortWritePortUchar( IN PUCHAR Port, IN UCHAR Value); VPAPI VOID -DDKAPI +NTAPI VideoPortWritePortUlong( IN PULONG Port, IN ULONG Value); VPAPI VOID -DDKAPI +NTAPI VideoPortWritePortUshort( IN PUSHORT Port, IN USHORT Value); VPAPI VOID -DDKAPI +NTAPI VideoPortWriteRegisterBufferUchar( IN PUCHAR Register, IN PUCHAR Buffer, @@ -1497,7 +1497,7 @@ VideoPortWriteRegisterBufferUchar( VPAPI VOID -DDKAPI +NTAPI VideoPortWriteRegisterBufferUlong( IN PULONG Register, IN PULONG Buffer, @@ -1505,7 +1505,7 @@ VideoPortWriteRegisterBufferUlong( VPAPI VOID -DDKAPI +NTAPI VideoPortWriteRegisterBufferUshort( IN PUSHORT Register, IN PUSHORT Buffer, @@ -1513,35 +1513,35 @@ VideoPortWriteRegisterBufferUshort( VPAPI VOID -DDKAPI +NTAPI VideoPortWriteRegisterUchar( IN PUCHAR Register, IN UCHAR Value); VPAPI VOID -DDKAPI +NTAPI VideoPortWriteRegisterUlong( IN PULONG Register, IN ULONG Value); VPAPI VOID -DDKAPI +NTAPI VideoPortWriteRegisterUshort( IN PUSHORT Register, IN USHORT Value); VPAPI VOID -DDKAPI +NTAPI VideoPortZeroDeviceMemory( IN PVOID Destination, IN ULONG Length); VPAPI VOID -DDKAPI +NTAPI VideoPortZeroMemory( IN PVOID Destination, IN ULONG Length); diff --git a/reactos/include/ddk/videoagp.h b/reactos/include/ddk/videoagp.h index 4a647ae6756..0b6d36d4126 100644 --- a/reactos/include/ddk/videoagp.h +++ b/reactos/include/ddk/videoagp.h @@ -41,59 +41,59 @@ typedef enum _VIDEO_PORT_CACHE_TYPE { } VIDEO_PORT_CACHE_TYPE; typedef BOOLEAN -(DDKAPI *PAGP_COMMIT_PHYSICAL)( +(NTAPI *PAGP_COMMIT_PHYSICAL)( IN PVOID HwDeviceExtension, IN PVOID PhysicalReserveContext, IN ULONG Pages, IN ULONG Offset); typedef PVOID -(DDKAPI *PAGP_COMMIT_VIRTUAL)( +(NTAPI *PAGP_COMMIT_VIRTUAL)( IN PVOID HwDeviceExtension, IN PVOID VirtualReserveContext, IN ULONG Pages, IN ULONG Offset); typedef VOID -(DDKAPI *PAGP_FREE_PHYSICAL)( +(NTAPI *PAGP_FREE_PHYSICAL)( IN PVOID HwDeviceExtension, IN PVOID PhysicalReserveContext, IN ULONG Pages, IN ULONG Offset); typedef VOID -(DDKAPI *PAGP_FREE_VIRTUAL)( +(NTAPI *PAGP_FREE_VIRTUAL)( IN PVOID HwDeviceExtension, IN PVOID VirtualReserveContext, IN ULONG Pages, IN ULONG Offset); typedef VOID -(DDKAPI *PAGP_RELEASE_PHYSICAL)( +(NTAPI *PAGP_RELEASE_PHYSICAL)( IN PVOID HwDeviceExtension, IN PVOID PhysicalReserveContext); typedef VOID -(DDKAPI *PAGP_RELEASE_VIRTUAL)( +(NTAPI *PAGP_RELEASE_VIRTUAL)( IN PVOID HwDeviceExtension, IN PVOID VirtualReserveContext); typedef PHYSICAL_ADDRESS -(DDKAPI *PAGP_RESERVE_PHYSICAL)( +(NTAPI *PAGP_RESERVE_PHYSICAL)( IN PVOID HwDeviceExtension, IN ULONG Pages, IN VIDEO_PORT_CACHE_TYPE Caching, OUT PVOID *PhysicalReserveContext); typedef PVOID -(DDKAPI *PAGP_RESERVE_VIRTUAL)( +(NTAPI *PAGP_RESERVE_VIRTUAL)( IN PVOID HwDeviceExtension, IN HANDLE ProcessHandle, IN PVOID PhysicalReserveContext, OUT PVOID *VirtualReserveContext); typedef BOOLEAN -(DDKAPI *PAGP_SET_RATE)( +(NTAPI *PAGP_SET_RATE)( IN PVOID HwDeviceExtension, IN ULONG AgpRate); @@ -111,7 +111,7 @@ typedef struct _VIDEO_PORT_AGP_SERVICES { VPAPI BOOLEAN -DDKAPI +NTAPI VideoPortGetAgpServices( IN PVOID HwDeviceExtension, IN PVIDEO_PORT_AGP_SERVICES AgpServices); diff --git a/reactos/include/ddk/wdm.h b/reactos/include/ddk/wdm.h index c36761d23ae..42607c295a5 100644 --- a/reactos/include/ddk/wdm.h +++ b/reactos/include/ddk/wdm.h @@ -38,10 +38,25 @@ #include #include #include +#include #ifndef GUID_DEFINED #include -#endif /* GUID_DEFINED */ +#endif + +#ifdef _MAC +#ifndef _INC_STRING +#include +#endif /* _INC_STRING */ +#else +#include +#endif /* _MAC */ + +#ifndef _KTMTYPES_ +typedef GUID UOW, *PUOW; +#endif + +typedef GUID *PGUID; #if (NTDDI_VERSION >= NTDDI_WINXP) #include @@ -91,6 +106,12 @@ extern "C" { #if defined(_MSC_VER) +/* Disable some warnings */ +#pragma warning(disable:4115) /* Named type definition in parentheses */ +#pragma warning(disable:4201) /* Nameless unions and structs */ +#pragma warning(disable:4214) /* Bit fields of other types than int */ +#pragma warning(disable:4820) /* Padding added, due to alignemnet requirement */ + /* Indicate if #pragma alloc_text() is supported */ #if defined(_M_IX86) || defined(_M_AMD64) || defined(_M_IA64) #define ALLOC_PRAGMA 1 @@ -123,17 +144,51 @@ struct _IO_RESOURCE_DESCRIPTOR; typedef struct _OBJECT_TYPE *POBJECT_TYPE; typedef struct _HAL_DISPATCH_TABLE *PHAL_DISPATCH_TABLE; typedef struct _HAL_PRIVATE_DISPATCH_TABLE *PHAL_PRIVATE_DISPATCH_TABLE; -typedef struct _DEVICE_HANDLER_OBJECT *PDEVICE_HANDLER_OBJECT; -typedef struct _ADAPTER_OBJECT *PADAPTER_OBJECT; typedef struct _CALLBACK_OBJECT *PCALLBACK_OBJECT; -typedef struct _ETHREAD *PETHREAD; typedef struct _EPROCESS *PEPROCESS; +typedef struct _ETHREAD *PETHREAD; typedef struct _IO_TIMER *PIO_TIMER; typedef struct _KINTERRUPT *PKINTERRUPT; typedef struct _KPROCESS *PKPROCESS; typedef struct _KTHREAD *PKTHREAD, *PRKTHREAD; typedef struct _CONTEXT *PCONTEXT; +#if defined(USE_DMA_MACROS) && !defined(_NTHAL_) && ( defined(_NTDDK_) || defined(_NTDRIVER_) || defined(_NTOSP_)) +typedef struct _DMA_ADAPTER *PADAPTER_OBJECT; +#elif defined(_WDM_INCLUDED_) +typedef struct _DMA_ADAPTER *PADAPTER_OBJECT; +#else +typedef struct _ADAPTER_OBJECT *PADAPTER_OBJECT; +#endif + +#ifndef DEFINE_GUIDEX +#ifdef _MSC_VER +#define DEFINE_GUIDEX(name) EXTERN_C const CDECL GUID name +#else +#define DEFINE_GUIDEX(name) EXTERN_C const GUID name +#endif +#endif /* DEFINE_GUIDEX */ + +#ifndef STATICGUIDOF +#define STATICGUIDOF(guid) STATIC_##guid +#endif + +/* GUID Comparison */ +#ifndef __IID_ALIGNED__ +#define __IID_ALIGNED__ +#ifdef __cplusplus +inline int IsEqualGUIDAligned(REFGUID guid1, REFGUID guid2) +{ + return ( (*(PLONGLONG)(&guid1) == *(PLONGLONG)(&guid2)) && + (*((PLONGLONG)(&guid1) + 1) == *((PLONGLONG)(&guid2) + 1)) ); +} +#else +#define IsEqualGUIDAligned(guid1, guid2) \ + ( (*(PLONGLONG)(guid1) == *(PLONGLONG)(guid2)) && \ + (*((PLONGLONG)(guid1) + 1) == *((PLONGLONG)(guid2) + 1)) ) +#endif /* __cplusplus */ +#endif /* !__IID_ALIGNED__ */ + /****************************************************************************** * INTERLOCKED Functions * @@ -145,42 +200,44 @@ typedef struct _CONTEXT *PCONTEXT; #if defined(__GNUC__) static __inline__ BOOLEAN -InterlockedBitTestAndSet(IN LONG volatile *Base, - IN LONG Bit) +InterlockedBitTestAndSet( + IN LONG volatile *Base, + IN LONG Bit) { #if defined(_M_IX86) - LONG OldBit; - __asm__ __volatile__("lock " - "btsl %2,%1\n\t" - "sbbl %0,%0\n\t" - :"=r" (OldBit),"+m" (*Base) - :"Ir" (Bit) - : "memory"); - return OldBit; + LONG OldBit; + __asm__ __volatile__("lock " + "btsl %2,%1\n\t" + "sbbl %0,%0\n\t" + :"=r" (OldBit),"+m" (*Base) + :"Ir" (Bit) + : "memory"); + return OldBit; #else - return (_InterlockedOr(Base, 1 << Bit) >> Bit) & 1; + return (_InterlockedOr(Base, 1 << Bit) >> Bit) & 1; #endif } static __inline__ BOOLEAN -InterlockedBitTestAndReset(IN LONG volatile *Base, - IN LONG Bit) +InterlockedBitTestAndReset( + IN LONG volatile *Base, + IN LONG Bit) { #if defined(_M_IX86) - LONG OldBit; - __asm__ __volatile__("lock " - "btrl %2,%1\n\t" - "sbbl %0,%0\n\t" - :"=r" (OldBit),"+m" (*Base) - :"Ir" (Bit) - : "memory"); - return OldBit; + LONG OldBit; + __asm__ __volatile__("lock " + "btrl %2,%1\n\t" + "sbbl %0,%0\n\t" + :"=r" (OldBit),"+m" (*Base) + :"Ir" (Bit) + : "memory"); + return OldBit; #else - return (_InterlockedAnd(Base, ~(1 << Bit)) >> Bit) & 1; + return (_InterlockedAnd(Base, ~(1 << Bit)) >> Bit) & 1; #endif } -#endif +#endif /* defined(__GNUC__) */ #define BitScanForward _BitScanForward #define BitScanReverse _BitScanReverse @@ -192,6 +249,10 @@ InterlockedBitTestAndReset(IN LONG volatile *Base, #define InterlockedBitTestAndReset _interlockedbittestandreset #ifdef _M_AMD64 +#define BitTest64 _bittest64 +#define BitTestAndComplement64 _bittestandcomplement64 +#define BitTestAndSet64 _bittestandset64 +#define BitTestAndReset64 _bittestandreset64 #define InterlockedBitTestAndSet64 _interlockedbittestandset64 #define InterlockedBitTestAndReset64 _interlockedbittestandreset64 #endif @@ -218,8 +279,8 @@ LONG FASTCALL InterlockedCompareExchange( IN OUT LONG volatile *Destination, - IN LONG Exchange, - IN LONG Comparand); + IN LONG Exchange, + IN LONG Comparand); NTKERNELAPI LONG @@ -235,7 +296,7 @@ InterlockedExchangeAdd( IN OUT LONG volatile *Addend, IN LONG Value); -#else // !defined(NO_INTERLOCKED_INTRINSICS) +#else /* !defined(NO_INTERLOCKED_INTRINSICS) */ #define InterlockedExchange _InterlockedExchange #define InterlockedIncrement _InterlockedIncrement @@ -246,9 +307,9 @@ InterlockedExchangeAdd( #define InterlockedAnd _InterlockedAnd #define InterlockedXor _InterlockedXor -#endif // !defined(NO_INTERLOCKED_INTRINSICS) +#endif /* !defined(NO_INTERLOCKED_INTRINSICS) */ -#endif // defined (_X86_) +#endif /* defined (_X86_) */ #if !defined (_WIN64) /* @@ -311,19 +372,12 @@ InterlockedExchangeAdd( FORCEINLINE LONG64 InterlockedAdd64( - IN OUT LONG64 volatile *Addend, - IN LONG64 Value) + IN OUT LONG64 volatile *Addend, + IN LONG64 Value) { - return InterlockedExchangeAdd64(Addend, Value) + Value; + return InterlockedExchangeAdd64(Addend, Value) + Value; } //#endif -#define BitScanForward _BitScanForward -#define BitScanReverse _BitScanReverse -#endif - -#ifdef _M_AMD64 -#define InterlockedBitTestAndSet64 _interlockedbittestandset64 -#define InterlockedBitTestAndReset64 _interlockedbittestandreset64 #endif #endif /* !__INTERLOCKED_DECLARED */ @@ -357,43 +411,43 @@ InterlockedAdd64( #define HASH_STRING_ALGORITHM_INVALID 0xffffffff typedef struct _RTL_BITMAP { - ULONG SizeOfBitMap; - PULONG Buffer; + ULONG SizeOfBitMap; + PULONG Buffer; } RTL_BITMAP, *PRTL_BITMAP; typedef struct _RTL_BITMAP_RUN { - ULONG StartingIndex; - ULONG NumberOfBits; + ULONG StartingIndex; + ULONG NumberOfBits; } RTL_BITMAP_RUN, *PRTL_BITMAP_RUN; typedef NTSTATUS -(DDKAPI *PRTL_QUERY_REGISTRY_ROUTINE)( - IN PWSTR ValueName, - IN ULONG ValueType, - IN PVOID ValueData, - IN ULONG ValueLength, - IN PVOID Context, - IN PVOID EntryContext); +(NTAPI *PRTL_QUERY_REGISTRY_ROUTINE)( + IN PWSTR ValueName, + IN ULONG ValueType, + IN PVOID ValueData, + IN ULONG ValueLength, + IN PVOID Context, + IN PVOID EntryContext); typedef struct _RTL_QUERY_REGISTRY_TABLE { - PRTL_QUERY_REGISTRY_ROUTINE QueryRoutine; - ULONG Flags; - PCWSTR Name; - PVOID EntryContext; - ULONG DefaultType; - PVOID DefaultData; - ULONG DefaultLength; + PRTL_QUERY_REGISTRY_ROUTINE QueryRoutine; + ULONG Flags; + PCWSTR Name; + PVOID EntryContext; + ULONG DefaultType; + PVOID DefaultData; + ULONG DefaultLength; } RTL_QUERY_REGISTRY_TABLE, *PRTL_QUERY_REGISTRY_TABLE; typedef struct _TIME_FIELDS { - CSHORT Year; - CSHORT Month; - CSHORT Day; - CSHORT Hour; - CSHORT Minute; - CSHORT Second; - CSHORT Milliseconds; - CSHORT Weekday; + CSHORT Year; + CSHORT Month; + CSHORT Day; + CSHORT Hour; + CSHORT Minute; + CSHORT Second; + CSHORT Milliseconds; + CSHORT Weekday; } TIME_FIELDS, *PTIME_FIELDS; /* Slist Header */ @@ -401,60 +455,101 @@ typedef struct _TIME_FIELDS { #define _SLIST_HEADER_ #if defined(_WIN64) -typedef struct _SLIST_ENTRY *PSLIST_ENTRY; + typedef struct DECLSPEC_ALIGN(16) _SLIST_ENTRY { - PSLIST_ENTRY Next; -} SLIST_ENTRY; + struct _SLIST_ENTRY *Next; +} SLIST_ENTRY, *PSLIST_ENTRY; + +typedef struct _SLIST_ENTRY32 { + ULONG Next; +} SLIST_ENTRY32, *PSLIST_ENTRY32; + typedef union DECLSPEC_ALIGN(16) _SLIST_HEADER { - struct { - ULONGLONG Alignment; - ULONGLONG Region; - } DUMMYSTRUCTNAME; - struct { - ULONGLONG Depth:16; - ULONGLONG Sequence:9; - ULONGLONG NextEntry:39; - ULONGLONG HeaderType:1; - ULONGLONG Init:1; - ULONGLONG Reserved:59; - ULONGLONG Region:3; - } Header8; - struct { - ULONGLONG Depth:16; - ULONGLONG Sequence:48; - ULONGLONG HeaderType:1; - ULONGLONG Init:1; - ULONGLONG Reserved:2; - ULONGLONG NextEntry:60; - } Header16; + struct { + ULONGLONG Alignment; + ULONGLONG Region; + } DUMMYSTRUCTNAME; + struct { + ULONGLONG Depth:16; + ULONGLONG Sequence:9; + ULONGLONG NextEntry:39; + ULONGLONG HeaderType:1; + ULONGLONG Init:1; + ULONGLONG Reserved:59; + ULONGLONG Region:3; + } Header8; + struct { + ULONGLONG Depth:16; + ULONGLONG Sequence:48; + ULONGLONG HeaderType:1; + ULONGLONG Init:1; + ULONGLONG Reserved:2; + ULONGLONG NextEntry:60; + } Header16; + struct { + ULONGLONG Depth:16; + ULONGLONG Sequence:48; + ULONGLONG HeaderType:1; + ULONGLONG Reserved:3; + ULONGLONG NextEntry:60; + } HeaderX64; } SLIST_HEADER, *PSLIST_HEADER; + +typedef union _SLIST_HEADER32 { + ULONGLONG Alignment; + struct { + SLIST_ENTRY32 Next; + USHORT Depth; + USHORT Sequence; + } DUMMYSTRUCTNAME; +} SLIST_HEADER32, *PSLIST_HEADER32; + #else + #define SLIST_ENTRY SINGLE_LIST_ENTRY #define _SLIST_ENTRY _SINGLE_LIST_ENTRY #define PSLIST_ENTRY PSINGLE_LIST_ENTRY + +typedef SLIST_ENTRY SLIST_ENTRY32, *PSLIST_ENTRY32; + typedef union _SLIST_HEADER { - ULONGLONG Alignment; - struct { - SLIST_ENTRY Next; - USHORT Depth; - USHORT Sequence; - } DUMMYSTRUCTNAME; + ULONGLONG Alignment; + struct { + SLIST_ENTRY Next; + USHORT Depth; + USHORT Sequence; + } DUMMYSTRUCTNAME; } SLIST_HEADER, *PSLIST_HEADER; -#endif + +typedef SLIST_HEADER SLIST_HEADER32, *PSLIST_HEADER32; + +#endif /* defined(_WIN64) */ #endif /* _SLIST_HEADER_ */ - -/* HACK HACK HACK - GCC (or perhaps LD) is messing this up */ -#if defined(_NTSYSTEM_) || defined(__GNUC__) +/* MS definition is broken! */ +extern BOOLEAN NTSYSAPI NlsMbCodePageTag; +extern BOOLEAN NTSYSAPI NlsMbOemCodePageTag; #define NLS_MB_CODE_PAGE_TAG NlsMbCodePageTag #define NLS_MB_OEM_CODE_PAGE_TAG NlsMbOemCodePageTag -#else -#define NLS_MB_CODE_PAGE_TAG (*NlsMbCodePageTag) -#define NLS_MB_OEM_CODE_PAGE_TAG (*NlsMbOemCodePageTag) -#endif /* _NT_SYSTEM */ -extern BOOLEAN NTSYSAPI NLS_MB_CODE_PAGE_TAG; -extern BOOLEAN NTSYSAPI NLS_MB_OEM_CODE_PAGE_TAG; + +#define SHORT_LEAST_SIGNIFICANT_BIT 0 +#define SHORT_MOST_SIGNIFICANT_BIT 1 + +#define LONG_LEAST_SIGNIFICANT_BIT 0 +#define LONG_3RD_MOST_SIGNIFICANT_BIT 1 +#define LONG_2ND_MOST_SIGNIFICANT_BIT 2 +#define LONG_MOST_SIGNIFICANT_BIT 3 + +#define RTLVERLIB_DDI(x) Wdmlib##x + +typedef BOOLEAN +(*PFN_RTL_IS_NTDDI_VERSION_AVAILABLE)( + IN ULONG Version); + +typedef BOOLEAN +(*PFN_RTL_IS_SERVICE_PACK_VERSION_INSTALLED)( + IN ULONG Version); /****************************************************************************** @@ -465,39 +560,139 @@ typedef UCHAR KIRQL, *PKIRQL; typedef CCHAR KPROCESSOR_MODE; typedef LONG KPRIORITY; -typedef ULONG EXECUTION_STATE; - typedef enum _MODE { KernelMode, UserMode, MaximumMode } MODE; -/* Processor features */ -#define PF_FLOATING_POINT_PRECISION_ERRATA 0 -#define PF_FLOATING_POINT_EMULATED 1 -#define PF_COMPARE_EXCHANGE_DOUBLE 2 -#define PF_MMX_INSTRUCTIONS_AVAILABLE 3 -#define PF_PPC_MOVEMEM_64BIT_OK 4 -#define PF_ALPHA_BYTE_INSTRUCTIONS 5 -#define PF_XMMI_INSTRUCTIONS_AVAILABLE 6 -#define PF_3DNOW_INSTRUCTIONS_AVAILABLE 7 -#define PF_RDTSC_INSTRUCTION_AVAILABLE 8 -#define PF_PAE_ENABLED 9 -#define PF_XMMI64_INSTRUCTIONS_AVAILABLE 10 -#define PF_SSE_DAZ_MODE_AVAILABLE 11 -#define PF_NX_ENABLED 12 -#define PF_SSE3_INSTRUCTIONS_AVAILABLE 13 -#define PF_COMPARE_EXCHANGE128 14 -#define PF_COMPARE64_EXCHANGE128 15 -#define PF_CHANNELS_ENABLED 16 -#define PF_XSAVE_ENABLED 17 +#define CACHE_FULLY_ASSOCIATIVE 0xFF +#define MAXIMUM_SUSPEND_COUNT MAXCHAR + +#define EVENT_QUERY_STATE (0x0001) +#define EVENT_MODIFY_STATE (0x0002) +#define EVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3) + +#define LTP_PC_SMT 0x1 + +#if (NTDDI_VERSION < NTDDI_WIN7) || defined(_X86_) || !defined(NT_PROCESSOR_GROUPS) +#define SINGLE_GROUP_LEGACY_API 1 +#endif + +#define SEMAPHORE_QUERY_STATE (0x0001) +#define SEMAPHORE_MODIFY_STATE (0x0002) +#define SEMAPHORE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3) + +typedef enum _LOGICAL_PROCESSOR_RELATIONSHIP { + RelationProcessorCore, + RelationNumaNode, + RelationCache, + RelationProcessorPackage, + RelationGroup, + RelationAll = 0xffff +} LOGICAL_PROCESSOR_RELATIONSHIP; + +typedef enum _PROCESSOR_CACHE_TYPE { + CacheUnified, + CacheInstruction, + CacheData, + CacheTrace +} PROCESSOR_CACHE_TYPE; + +typedef struct _CACHE_DESCRIPTOR { + UCHAR Level; + UCHAR Associativity; + USHORT LineSize; + ULONG Size; + PROCESSOR_CACHE_TYPE Type; +} CACHE_DESCRIPTOR, *PCACHE_DESCRIPTOR; + +typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION { + ULONG_PTR ProcessorMask; + LOGICAL_PROCESSOR_RELATIONSHIP Relationship; + union { + struct { + UCHAR Flags; + } ProcessorCore; + struct { + ULONG NodeNumber; + } NumaNode; + CACHE_DESCRIPTOR Cache; + ULONGLONG Reserved[2]; + } DUMMYUNIONNAME; +} SYSTEM_LOGICAL_PROCESSOR_INFORMATION, *PSYSTEM_LOGICAL_PROCESSOR_INFORMATION; + +typedef struct _PROCESSOR_RELATIONSHIP { + UCHAR Flags; + UCHAR Reserved[21]; + USHORT GroupCount; + GROUP_AFFINITY GroupMask[ANYSIZE_ARRAY]; +} PROCESSOR_RELATIONSHIP, *PPROCESSOR_RELATIONSHIP; + +typedef struct _NUMA_NODE_RELATIONSHIP { + ULONG NodeNumber; + UCHAR Reserved[20]; + GROUP_AFFINITY GroupMask; +} NUMA_NODE_RELATIONSHIP, *PNUMA_NODE_RELATIONSHIP; + +typedef struct _CACHE_RELATIONSHIP { + UCHAR Level; + UCHAR Associativity; + USHORT LineSize; + ULONG CacheSize; + PROCESSOR_CACHE_TYPE Type; + UCHAR Reserved[20]; + GROUP_AFFINITY GroupMask; +} CACHE_RELATIONSHIP, *PCACHE_RELATIONSHIP; + +typedef struct _PROCESSOR_GROUP_INFO { + UCHAR MaximumProcessorCount; + UCHAR ActiveProcessorCount; + UCHAR Reserved[38]; + KAFFINITY ActiveProcessorMask; +} PROCESSOR_GROUP_INFO, *PPROCESSOR_GROUP_INFO; + +typedef struct _GROUP_RELATIONSHIP { + USHORT MaximumGroupCount; + USHORT ActiveGroupCount; + UCHAR Reserved[20]; + PROCESSOR_GROUP_INFO GroupInfo[ANYSIZE_ARRAY]; +} GROUP_RELATIONSHIP, *PGROUP_RELATIONSHIP; + +typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX { + LOGICAL_PROCESSOR_RELATIONSHIP Relationship; + ULONG Size; + union { + PROCESSOR_RELATIONSHIP Processor; + NUMA_NODE_RELATIONSHIP NumaNode; + CACHE_RELATIONSHIP Cache; + GROUP_RELATIONSHIP Group; + } DUMMYUNIONNAME; +} SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX, *PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX;; + +/* Processor features */ +#define PF_FLOATING_POINT_PRECISION_ERRATA 0 +#define PF_FLOATING_POINT_EMULATED 1 +#define PF_COMPARE_EXCHANGE_DOUBLE 2 +#define PF_MMX_INSTRUCTIONS_AVAILABLE 3 +#define PF_PPC_MOVEMEM_64BIT_OK 4 +#define PF_ALPHA_BYTE_INSTRUCTIONS 5 +#define PF_XMMI_INSTRUCTIONS_AVAILABLE 6 +#define PF_3DNOW_INSTRUCTIONS_AVAILABLE 7 +#define PF_RDTSC_INSTRUCTION_AVAILABLE 8 +#define PF_PAE_ENABLED 9 +#define PF_XMMI64_INSTRUCTIONS_AVAILABLE 10 +#define PF_SSE_DAZ_MODE_AVAILABLE 11 +#define PF_NX_ENABLED 12 +#define PF_SSE3_INSTRUCTIONS_AVAILABLE 13 +#define PF_COMPARE_EXCHANGE128 14 +#define PF_COMPARE64_EXCHANGE128 15 +#define PF_CHANNELS_ENABLED 16 +#define PF_XSAVE_ENABLED 17 -#define MAXIMUM_SUPPORTED_EXTENSION 512 #define MAXIMUM_WAIT_OBJECTS 64 -#define ASSERT_APC(Object) \ - ASSERT((Object)->Type == ApcObject) +#define ASSERT_APC(Object) NT_ASSERT((Object)->Type == ApcObject) #define ASSERT_DPC(Object) \ ASSERT(((Object)->Type == 0) || \ @@ -505,25 +700,25 @@ typedef enum _MODE { ((Object)->Type == ThreadedDpcObject)) #define ASSERT_GATE(object) \ - ASSERT((((object)->Header.Type & KOBJECT_TYPE_MASK) == GateObject) || \ - (((object)->Header.Type & KOBJECT_TYPE_MASK) == EventSynchronizationObject)) + NT_ASSERT((((object)->Header.Type & KOBJECT_TYPE_MASK) == GateObject) || \ + (((object)->Header.Type & KOBJECT_TYPE_MASK) == EventSynchronizationObject)) #define ASSERT_DEVICE_QUEUE(Object) \ - ASSERT((Object)->Type == DeviceQueueObject) + NT_ASSERT((Object)->Type == DeviceQueueObject) #define ASSERT_TIMER(E) \ - ASSERT(((E)->Header.Type == TimerNotificationObject) || \ - ((E)->Header.Type == TimerSynchronizationObject)) + NT_ASSERT(((E)->Header.Type == TimerNotificationObject) || \ + ((E)->Header.Type == TimerSynchronizationObject)) #define ASSERT_MUTANT(E) \ - ASSERT((E)->Header.Type == MutantObject) + NT_ASSERT((E)->Header.Type == MutantObject) #define ASSERT_SEMAPHORE(E) \ - ASSERT((E)->Header.Type == SemaphoreObject) + NT_ASSERT((E)->Header.Type == SemaphoreObject) #define ASSERT_EVENT(E) \ - ASSERT(((E)->Header.Type == NotificationEvent) || \ - ((E)->Header.Type == SynchronizationEvent)) + NT_ASSERT(((E)->Header.Type == NotificationEvent) || \ + ((E)->Header.Type == SynchronizationEvent)) #define DPC_NORMAL 0 #define DPC_THREADED 1 @@ -533,6 +728,9 @@ typedef enum _MODE { #define GM_LOCK_WAITER_WOKEN 0x2 #define GM_LOCK_WAITER_INC 0x4 +#define LOCK_QUEUE_WAIT_BIT 0 +#define LOCK_QUEUE_OWNER_BIT 1 + #define LOCK_QUEUE_WAIT 1 #define LOCK_QUEUE_OWNER 2 #define LOCK_QUEUE_TIMER_LOCK_SHIFT 4 @@ -556,43 +754,59 @@ typedef enum _MODE { #define MAXIMUM_PROCESSORS MAXIMUM_PROC_PER_GROUP /* Exception Records */ -#define EXCEPTION_NONCONTINUABLE 1 +#define EXCEPTION_NONCONTINUABLE 1 #define EXCEPTION_MAXIMUM_PARAMETERS 15 +#define EXCEPTION_DIVIDED_BY_ZERO 0 +#define EXCEPTION_DEBUG 1 +#define EXCEPTION_NMI 2 +#define EXCEPTION_INT3 3 +#define EXCEPTION_BOUND_CHECK 5 +#define EXCEPTION_INVALID_OPCODE 6 +#define EXCEPTION_NPX_NOT_AVAILABLE 7 +#define EXCEPTION_DOUBLE_FAULT 8 +#define EXCEPTION_NPX_OVERRUN 9 +#define EXCEPTION_INVALID_TSS 0x0A +#define EXCEPTION_SEGMENT_NOT_PRESENT 0x0B +#define EXCEPTION_STACK_FAULT 0x0C +#define EXCEPTION_GP_FAULT 0x0D +#define EXCEPTION_RESERVED_TRAP 0x0F +#define EXCEPTION_NPX_ERROR 0x010 +#define EXCEPTION_ALIGNMENT_CHECK 0x011 + typedef struct _EXCEPTION_RECORD { - NTSTATUS ExceptionCode; - ULONG ExceptionFlags; - struct _EXCEPTION_RECORD *ExceptionRecord; - PVOID ExceptionAddress; - ULONG NumberParameters; - ULONG_PTR ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS]; + NTSTATUS ExceptionCode; + ULONG ExceptionFlags; + struct _EXCEPTION_RECORD *ExceptionRecord; + PVOID ExceptionAddress; + ULONG NumberParameters; + ULONG_PTR ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS]; } EXCEPTION_RECORD, *PEXCEPTION_RECORD; typedef struct _EXCEPTION_RECORD32 { - NTSTATUS ExceptionCode; - ULONG ExceptionFlags; - ULONG ExceptionRecord; - ULONG ExceptionAddress; - ULONG NumberParameters; - ULONG ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS]; + NTSTATUS ExceptionCode; + ULONG ExceptionFlags; + ULONG ExceptionRecord; + ULONG ExceptionAddress; + ULONG NumberParameters; + ULONG ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS]; } EXCEPTION_RECORD32, *PEXCEPTION_RECORD32; typedef struct _EXCEPTION_RECORD64 { - NTSTATUS ExceptionCode; - ULONG ExceptionFlags; - ULONG64 ExceptionRecord; - ULONG64 ExceptionAddress; - ULONG NumberParameters; - ULONG __unusedAlignment; - ULONG64 ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS]; + NTSTATUS ExceptionCode; + ULONG ExceptionFlags; + ULONG64 ExceptionRecord; + ULONG64 ExceptionAddress; + ULONG NumberParameters; + ULONG __unusedAlignment; + ULONG64 ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS]; } EXCEPTION_RECORD64, *PEXCEPTION_RECORD64; typedef struct _EXCEPTION_POINTERS { - PEXCEPTION_RECORD ExceptionRecord; - PCONTEXT ContextRecord; + PEXCEPTION_RECORD ExceptionRecord; + PCONTEXT ContextRecord; } EXCEPTION_POINTERS, *PEXCEPTION_POINTERS; - typedef enum _KBUGCHECK_CALLBACK_REASON { KbCallbackInvalid, KbCallbackReserved1, @@ -604,19 +818,56 @@ typedef enum _KBUGCHECK_CALLBACK_REASON { struct _KBUGCHECK_REASON_CALLBACK_RECORD; typedef VOID -(DDKAPI *PKBUGCHECK_REASON_CALLBACK_ROUTINE)( - IN KBUGCHECK_CALLBACK_REASON Reason, - IN struct _KBUGCHECK_REASON_CALLBACK_RECORD *Record, - IN OUT PVOID ReasonSpecificData, - IN ULONG ReasonSpecificDataLength); +(NTAPI KBUGCHECK_REASON_CALLBACK_ROUTINE)( + IN KBUGCHECK_CALLBACK_REASON Reason, + IN struct _KBUGCHECK_REASON_CALLBACK_RECORD *Record, + IN OUT PVOID ReasonSpecificData, + IN ULONG ReasonSpecificDataLength); +typedef KBUGCHECK_REASON_CALLBACK_ROUTINE *PKBUGCHECK_REASON_CALLBACK_ROUTINE; + +typedef struct _KBUGCHECK_ADD_PAGES { + IN OUT PVOID Context; + IN OUT ULONG Flags; + IN ULONG BugCheckCode; + OUT ULONG_PTR Address; + OUT ULONG_PTR Count; +} KBUGCHECK_ADD_PAGES, *PKBUGCHECK_ADD_PAGES; + +typedef struct _KBUGCHECK_SECONDARY_DUMP_DATA { + IN PVOID InBuffer; + IN ULONG InBufferLength; + IN ULONG MaximumAllowed; + OUT GUID Guid; + OUT PVOID OutBuffer; + OUT ULONG OutBufferLength; +} KBUGCHECK_SECONDARY_DUMP_DATA, *PKBUGCHECK_SECONDARY_DUMP_DATA; + +typedef enum _KBUGCHECK_DUMP_IO_TYPE { + KbDumpIoInvalid, + KbDumpIoHeader, + KbDumpIoBody, + KbDumpIoSecondaryData, + KbDumpIoComplete +} KBUGCHECK_DUMP_IO_TYPE; + +typedef struct _KBUGCHECK_DUMP_IO { + IN ULONG64 Offset; + IN PVOID Buffer; + IN ULONG BufferLength; + IN KBUGCHECK_DUMP_IO_TYPE Type; +} KBUGCHECK_DUMP_IO, *PKBUGCHECK_DUMP_IO; + +#define KB_ADD_PAGES_FLAG_VIRTUAL_ADDRESS 0x00000001UL +#define KB_ADD_PAGES_FLAG_PHYSICAL_ADDRESS 0x00000002UL +#define KB_ADD_PAGES_FLAG_ADDITIONAL_RANGES_EXIST 0x80000000UL typedef struct _KBUGCHECK_REASON_CALLBACK_RECORD { - LIST_ENTRY Entry; - PKBUGCHECK_REASON_CALLBACK_ROUTINE CallbackRoutine; - PUCHAR Component; - ULONG_PTR Checksum; - KBUGCHECK_CALLBACK_REASON Reason; - UCHAR State; + LIST_ENTRY Entry; + PKBUGCHECK_REASON_CALLBACK_ROUTINE CallbackRoutine; + PUCHAR Component; + ULONG_PTR Checksum; + KBUGCHECK_CALLBACK_REASON Reason; + UCHAR State; } KBUGCHECK_REASON_CALLBACK_RECORD, *PKBUGCHECK_REASON_CALLBACK_RECORD; typedef enum _KBUGCHECK_BUFFER_DUMP_STATE { @@ -628,39 +879,52 @@ typedef enum _KBUGCHECK_BUFFER_DUMP_STATE { } KBUGCHECK_BUFFER_DUMP_STATE; typedef VOID -(DDKAPI *PKBUGCHECK_CALLBACK_ROUTINE)( - IN PVOID Buffer, - IN ULONG Length); +(NTAPI KBUGCHECK_CALLBACK_ROUTINE)( + IN PVOID Buffer, + IN ULONG Length); +typedef KBUGCHECK_CALLBACK_ROUTINE *PKBUGCHECK_CALLBACK_ROUTINE; typedef struct _KBUGCHECK_CALLBACK_RECORD { - LIST_ENTRY Entry; - PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine; - PVOID Buffer; - ULONG Length; - PUCHAR Component; - ULONG_PTR Checksum; - UCHAR State; + LIST_ENTRY Entry; + PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine; + PVOID Buffer; + ULONG Length; + PUCHAR Component; + ULONG_PTR Checksum; + UCHAR State; } KBUGCHECK_CALLBACK_RECORD, *PKBUGCHECK_CALLBACK_RECORD; typedef BOOLEAN -(DDKAPI *PNMI_CALLBACK)( - IN PVOID Context, - IN BOOLEAN Handled); +(NTAPI NMI_CALLBACK)( + IN PVOID Context, + IN BOOLEAN Handled); +typedef NMI_CALLBACK *PNMI_CALLBACK; -typedef enum _TRACE_INFORMATION_CLASS { - TraceIdClass, - TraceHandleClass, - TraceEnableFlagsClass, - TraceEnableLevelClass, - GlobalLoggerHandleClass, - EventLoggerHandleClass, - AllLoggerHandlesClass, - TraceHandleByNameClass, - LoggerEventsLostClass, - TraceSessionSettingsClass, - LoggerEventsLoggedClass, - MaxTraceInformationClass -} TRACE_INFORMATION_CLASS; +typedef enum _KE_PROCESSOR_CHANGE_NOTIFY_STATE { + KeProcessorAddStartNotify = 0, + KeProcessorAddCompleteNotify, + KeProcessorAddFailureNotify +} KE_PROCESSOR_CHANGE_NOTIFY_STATE; + +typedef struct _KE_PROCESSOR_CHANGE_NOTIFY_CONTEXT { + KE_PROCESSOR_CHANGE_NOTIFY_STATE State; + ULONG NtNumber; + NTSTATUS Status; +#if (NTDDI_VERSION >= NTDDI_WIN7) + PROCESSOR_NUMBER ProcNumber; +#endif +} KE_PROCESSOR_CHANGE_NOTIFY_CONTEXT, *PKE_PROCESSOR_CHANGE_NOTIFY_CONTEXT; + +typedef VOID +(NTAPI PROCESSOR_CALLBACK_FUNCTION)( + IN PVOID CallbackContext, + IN PKE_PROCESSOR_CHANGE_NOTIFY_CONTEXT ChangeContext, + IN OUT PNTSTATUS OperationStatus); +typedef PROCESSOR_CALLBACK_FUNCTION *PPROCESSOR_CALLBACK_FUNCTION; + +#define KE_PROCESSOR_CHANGE_ADD_EXISTING 1 + +#define INVALID_PROCESSOR_INDEX 0xffffffff typedef enum _KINTERRUPT_POLARITY { InterruptPolarityUnknown, @@ -758,55 +1022,50 @@ typedef enum _KINTERRUPT_MODE { #define THREAD_WAIT_OBJECTS 3 typedef VOID -(DDKAPI *PKINTERRUPT_ROUTINE)( +(NTAPI KSTART_ROUTINE)( + IN PVOID StartContext); +typedef KSTART_ROUTINE *PKSTART_ROUTINE; + +typedef VOID +(NTAPI *PKINTERRUPT_ROUTINE)( VOID); +typedef BOOLEAN +(NTAPI KSERVICE_ROUTINE)( + IN struct _KINTERRUPT *Interrupt, + IN PVOID ServiceContext); +typedef KSERVICE_ROUTINE *PKSERVICE_ROUTINE; + +typedef BOOLEAN +(NTAPI KMESSAGE_SERVICE_ROUTINE)( + IN struct _KINTERRUPT *Interrupt, + IN PVOID ServiceContext, + IN ULONG MessageID); +typedef KMESSAGE_SERVICE_ROUTINE *PKMESSAGE_SERVICE_ROUTINE; + typedef enum _KD_OPTION { - KD_OPTION_SET_BLOCK_ENABLE, + KD_OPTION_SET_BLOCK_ENABLE, } KD_OPTION; -typedef enum _INTERFACE_TYPE { - InterfaceTypeUndefined = -1, - Internal, - Isa, - Eisa, - MicroChannel, - TurboChannel, - PCIBus, - VMEBus, - NuBus, - PCMCIABus, - CBus, - MPIBus, - MPSABus, - ProcessorInternal, - InternalPowerBus, - PNPISABus, - PNPBus, - Vmcs, - MaximumInterfaceType -} INTERFACE_TYPE, *PINTERFACE_TYPE; +typedef VOID +(NTAPI *PKNORMAL_ROUTINE)( + IN PVOID NormalContext OPTIONAL, + IN PVOID SystemArgument1 OPTIONAL, + IN PVOID SystemArgument2 OPTIONAL); typedef VOID -(DDKAPI *PKNORMAL_ROUTINE)( - IN PVOID NormalContext, - IN PVOID SystemArgument1, - IN PVOID SystemArgument2); +(NTAPI *PKRUNDOWN_ROUTINE)( + IN struct _KAPC *Apc); typedef VOID -(DDKAPI *PKRUNDOWN_ROUTINE)( - IN struct _KAPC *Apc); +(NTAPI *PKKERNEL_ROUTINE)( + IN struct _KAPC *Apc, + IN OUT PKNORMAL_ROUTINE *NormalRoutine OPTIONAL, + IN OUT PVOID *NormalContext OPTIONAL, + IN OUT PVOID *SystemArgument1 OPTIONAL, + IN OUT PVOID *SystemArgument2 OPTIONAL); -typedef VOID -(DDKAPI *PKKERNEL_ROUTINE)( - IN struct _KAPC *Apc, - IN OUT PKNORMAL_ROUTINE *NormalRoutine, - IN OUT PVOID *NormalContext, - IN OUT PVOID *SystemArgument1, - IN OUT PVOID *SystemArgument2); - -typedef struct _KAPC -{ +typedef struct _KAPC { UCHAR Type; UCHAR SpareByte0; UCHAR Size; @@ -825,38 +1084,62 @@ typedef struct _KAPC BOOLEAN Inserted; } KAPC, *PKAPC, *RESTRICTED_POINTER PRKAPC; +#define KAPC_OFFSET_TO_SPARE_BYTE0 FIELD_OFFSET(KAPC, SpareByte0) +#define KAPC_OFFSET_TO_SPARE_BYTE1 FIELD_OFFSET(KAPC, SpareByte1) +#define KAPC_OFFSET_TO_SPARE_LONG FIELD_OFFSET(KAPC, SpareLong0) +#define KAPC_OFFSET_TO_SYSTEMARGUMENT1 FIELD_OFFSET(KAPC, SystemArgument1) +#define KAPC_OFFSET_TO_SYSTEMARGUMENT2 FIELD_OFFSET(KAPC, SystemArgument2) +#define KAPC_OFFSET_TO_APCSTATEINDEX FIELD_OFFSET(KAPC, ApcStateIndex) +#define KAPC_ACTUAL_LENGTH (FIELD_OFFSET(KAPC, Inserted) + sizeof(BOOLEAN)) + typedef struct _KDEVICE_QUEUE_ENTRY { - LIST_ENTRY DeviceListEntry; - ULONG SortKey; - BOOLEAN Inserted; + LIST_ENTRY DeviceListEntry; + ULONG SortKey; + BOOLEAN Inserted; } KDEVICE_QUEUE_ENTRY, *PKDEVICE_QUEUE_ENTRY, *RESTRICTED_POINTER PRKDEVICE_QUEUE_ENTRY; typedef PVOID PKIPI_CONTEXT; -typedef -VOID +typedef VOID (NTAPI *PKIPI_WORKER)( - IN PKIPI_CONTEXT PacketContext, - IN PVOID Parameter1, - IN PVOID Parameter2, - IN PVOID Parameter3); + IN OUT PKIPI_CONTEXT PacketContext, + IN PVOID Parameter1 OPTIONAL, + IN PVOID Parameter2 OPTIONAL, + IN PVOID Parameter3 OPTIONAL); -typedef -ULONG_PTR -(NTAPI *PKIPI_BROADCAST_WORKER)( - IN ULONG_PTR Argument); +typedef struct _KIPI_COUNTS { + ULONG Freeze; + ULONG Packet; + ULONG DPC; + ULONG APC; + ULONG FlushSingleTb; + ULONG FlushMultipleTb; + ULONG FlushEntireTb; + ULONG GenericCall; + ULONG ChangeColor; + ULONG SweepDcache; + ULONG SweepIcache; + ULONG SweepIcacheRange; + ULONG FlushIoBuffers; + ULONG GratuitousDPC; +} KIPI_COUNTS, *PKIPI_COUNTS; + +typedef ULONG_PTR +(NTAPI KIPI_BROADCAST_WORKER)( + IN ULONG_PTR Argument); +typedef KIPI_BROADCAST_WORKER *PKIPI_BROADCAST_WORKER; typedef ULONG_PTR KSPIN_LOCK, *PKSPIN_LOCK; typedef struct _KSPIN_LOCK_QUEUE { - struct _KSPIN_LOCK_QUEUE *volatile Next; - PKSPIN_LOCK volatile Lock; + struct _KSPIN_LOCK_QUEUE *volatile Next; + PKSPIN_LOCK volatile Lock; } KSPIN_LOCK_QUEUE, *PKSPIN_LOCK_QUEUE; typedef struct _KLOCK_QUEUE_HANDLE { - KSPIN_LOCK_QUEUE LockQueue; - KIRQL OldIrql; + KSPIN_LOCK_QUEUE LockQueue; + KIRQL OldIrql; } KLOCK_QUEUE_HANDLE, *PKLOCK_QUEUE_HANDLE; #if defined(_AMD64_) @@ -907,14 +1190,14 @@ typedef enum _KSPIN_LOCK_QUEUE_NUMBER { LockQueueMaximumLock = LockQueueTimerTableLock + LOCK_QUEUE_TIMER_TABLE_LOCKS } KSPIN_LOCK_QUEUE_NUMBER, *PKSPIN_LOCK_QUEUE_NUMBER; -#endif +#endif /* defined(_AMD64_) */ typedef VOID -(DDKAPI *PKDEFERRED_ROUTINE)( - IN struct _KDPC *Dpc, - IN PVOID DeferredContext, - IN PVOID SystemArgument1, - IN PVOID SystemArgument2); +(NTAPI *PKDEFERRED_ROUTINE)( + IN struct _KDPC *Dpc, + IN PVOID DeferredContext OPTIONAL, + IN PVOID SystemArgument1 OPTIONAL, + IN PVOID SystemArgument2 OPTIONAL); typedef enum _KDPC_IMPORTANCE { LowImportance, @@ -923,17 +1206,16 @@ typedef enum _KDPC_IMPORTANCE { MediumHighImportance } KDPC_IMPORTANCE; -typedef struct _KDPC -{ - UCHAR Type; - UCHAR Importance; - volatile USHORT Number; - LIST_ENTRY DpcListEntry; - PKDEFERRED_ROUTINE DeferredRoutine; - PVOID DeferredContext; - PVOID SystemArgument1; - PVOID SystemArgument2; - volatile PVOID DpcData; +typedef struct _KDPC { + UCHAR Type; + UCHAR Importance; + volatile USHORT Number; + LIST_ENTRY DpcListEntry; + PKDEFERRED_ROUTINE DeferredRoutine; + PVOID DeferredContext; + PVOID SystemArgument1; + PVOID SystemArgument2; + volatile PVOID DpcData; } KDPC, *PKDPC, *RESTRICTED_POINTER PRKDPC; typedef struct _KDPC_WATCHDOG_INFORMATION { @@ -953,126 +1235,124 @@ typedef struct _KDEVICE_QUEUE { union { BOOLEAN Busy; struct { - LONG64 Reserved : 8; - LONG64 Hint : 56; + LONG64 Reserved:8; + LONG64 Hint:56; }; }; #else BOOLEAN Busy; #endif - } KDEVICE_QUEUE, *PKDEVICE_QUEUE, *RESTRICTED_POINTER PRKDEVICE_QUEUE; #define TIMER_EXPIRED_INDEX_BITS 6 #define TIMER_PROCESSOR_INDEX_BITS 5 + typedef struct _DISPATCHER_HEADER { - _ANONYMOUS_UNION union { - _ANONYMOUS_STRUCT struct { - UCHAR Type; - _ANONYMOUS_UNION union { - _ANONYMOUS_UNION union { - UCHAR TimerControlFlags; - _ANONYMOUS_STRUCT struct { - UCHAR Absolute:1; - UCHAR Coalescable:1; - UCHAR KeepShifting:1; - UCHAR EncodedTolerableDelay:5; - } DUMMYSTRUCTNAME; - } DUMMYUNIONNAME; - UCHAR Abandoned; + _ANONYMOUS_UNION union { + _ANONYMOUS_STRUCT struct { + UCHAR Type; + _ANONYMOUS_UNION union { + _ANONYMOUS_UNION union { + UCHAR TimerControlFlags; + _ANONYMOUS_STRUCT struct { + UCHAR Absolute:1; + UCHAR Coalescable:1; + UCHAR KeepShifting:1; + UCHAR EncodedTolerableDelay:5; + } DUMMYSTRUCTNAME; + } DUMMYUNIONNAME; + UCHAR Abandoned; #if (NTDDI_VERSION < NTDDI_WIN7) - UCHAR NpxIrql; + UCHAR NpxIrql; #endif - BOOLEAN Signalling; - } DUMMYUNIONNAME; - _ANONYMOUS_UNION union { - _ANONYMOUS_UNION union { - UCHAR ThreadControlFlags; - _ANONYMOUS_STRUCT struct { - UCHAR CpuThrottled:1; - UCHAR CycleProfiling:1; - UCHAR CounterProfiling:1; - UCHAR Reserved:5; - } DUMMYSTRUCTNAME; - } DUMMYUNIONNAME; - UCHAR Size; - UCHAR Hand; - } DUMMYUNIONNAME2; - _ANONYMOUS_UNION union { + BOOLEAN Signalling; + } DUMMYUNIONNAME; + _ANONYMOUS_UNION union { + _ANONYMOUS_UNION union { + UCHAR ThreadControlFlags; + _ANONYMOUS_STRUCT struct { + UCHAR CpuThrottled:1; + UCHAR CycleProfiling:1; + UCHAR CounterProfiling:1; + UCHAR Reserved:5; + } DUMMYSTRUCTNAME; + } DUMMYUNIONNAME; + UCHAR Size; + UCHAR Hand; + } DUMMYUNIONNAME2; + _ANONYMOUS_UNION union { #if (NTDDI_VERSION >= NTDDI_WIN7) - _ANONYMOUS_UNION union { - UCHAR TimerMiscFlags; - _ANONYMOUS_STRUCT struct { + _ANONYMOUS_UNION union { + UCHAR TimerMiscFlags; + _ANONYMOUS_STRUCT struct { #if !defined(_X86_) - UCHAR Index:TIMER_EXPIRED_INDEX_BITS; + UCHAR Index:TIMER_EXPIRED_INDEX_BITS; #else - UCHAR Index:1; - UCHAR Processor:TIMER_PROCESSOR_INDEX_BITS; + UCHAR Index:1; + UCHAR Processor:TIMER_PROCESSOR_INDEX_BITS; #endif - UCHAR Inserted:1; - volatile UCHAR Expired:1; - } DUMMYSTRUCTNAME; - } DUMMYUNIONNAME; + UCHAR Inserted:1; + volatile UCHAR Expired:1; + } DUMMYSTRUCTNAME; + } DUMMYUNIONNAME; #else - /* Pre Win7 compatibility fix to latest WDK */ - UCHAR Inserted; + /* Pre Win7 compatibility fix to latest WDK */ + UCHAR Inserted; #endif - _ANONYMOUS_UNION union { - BOOLEAN DebugActive; - _ANONYMOUS_STRUCT struct { - BOOLEAN ActiveDR7:1; - BOOLEAN Instrumented:1; - BOOLEAN Reserved2:4; - BOOLEAN UmsScheduled:1; - BOOLEAN UmsPrimary:1; - } DUMMYSTRUCTNAME; - } DUMMYUNIONNAME; /* should probably be DUMMYUNIONNAME2, but this is what WDK says */ - BOOLEAN DpcActive; - } DUMMYUNIONNAME3; - } DUMMYSTRUCTNAME; - volatile LONG Lock; - } DUMMYUNIONNAME; - LONG SignalState; - LIST_ENTRY WaitListHead; + _ANONYMOUS_UNION union { + BOOLEAN DebugActive; + _ANONYMOUS_STRUCT struct { + BOOLEAN ActiveDR7:1; + BOOLEAN Instrumented:1; + BOOLEAN Reserved2:4; + BOOLEAN UmsScheduled:1; + BOOLEAN UmsPrimary:1; + } DUMMYSTRUCTNAME; + } DUMMYUNIONNAME; /* should probably be DUMMYUNIONNAME2, but this is what WDK says */ + BOOLEAN DpcActive; + } DUMMYUNIONNAME3; + } DUMMYSTRUCTNAME; + volatile LONG Lock; + } DUMMYUNIONNAME; + LONG SignalState; + LIST_ENTRY WaitListHead; } DISPATCHER_HEADER, *PDISPATCHER_HEADER; typedef struct _KEVENT { - DISPATCHER_HEADER Header; + DISPATCHER_HEADER Header; } KEVENT, *PKEVENT, *RESTRICTED_POINTER PRKEVENT; typedef struct _KSEMAPHORE { - DISPATCHER_HEADER Header; - LONG Limit; + DISPATCHER_HEADER Header; + LONG Limit; } KSEMAPHORE, *PKSEMAPHORE, *RESTRICTED_POINTER PRKSEMAPHORE; -typedef struct _KGATE -{ - DISPATCHER_HEADER Header; +#define KSEMAPHORE_ACTUAL_LENGTH (FIELD_OFFSET(KSEMAPHORE, Limit) + sizeof(LONG)) + +typedef struct _KGATE { + DISPATCHER_HEADER Header; } KGATE, *PKGATE, *RESTRICTED_POINTER PRKGATE; -typedef struct _KGUARDED_MUTEX -{ - volatile LONG Count; - PKTHREAD Owner; - ULONG Contention; - KGATE Gate; - __GNU_EXTENSION union - { - __GNU_EXTENSION struct - { - SHORT KernelApcDisable; - SHORT SpecialApcDisable; - }; - ULONG CombinedApcDisable; +typedef struct _KGUARDED_MUTEX { + volatile LONG Count; + PKTHREAD Owner; + ULONG Contention; + KGATE Gate; + __GNU_EXTENSION union { + __GNU_EXTENSION struct { + SHORT KernelApcDisable; + SHORT SpecialApcDisable; }; + ULONG CombinedApcDisable; + }; } KGUARDED_MUTEX, *PKGUARDED_MUTEX; typedef struct _KMUTANT { - DISPATCHER_HEADER Header; - LIST_ENTRY MutantListEntry; - struct _KTHREAD *RESTRICTED_POINTER OwnerThread; - BOOLEAN Abandoned; - UCHAR ApcDisable; + DISPATCHER_HEADER Header; + LIST_ENTRY MutantListEntry; + struct _KTHREAD *RESTRICTED_POINTER OwnerThread; + BOOLEAN Abandoned; + UCHAR ApcDisable; } KMUTANT, *PKMUTANT, *RESTRICTED_POINTER PRKMUTANT, KMUTEX, *PKMUTEX, *RESTRICTED_POINTER PRKMUTEX; #define TIMER_TABLE_SIZE 512 @@ -1089,9 +1369,17 @@ typedef struct _KTIMER { ULONG Period; } KTIMER, *PKTIMER, *RESTRICTED_POINTER PRKTIMER; +typedef enum _LOCK_OPERATION { + IoReadAccess, + IoWriteAccess, + IoModifyAccess +} LOCK_OPERATION; + +#define KTIMER_ACTUAL_LENGTH (FIELD_OFFSET(KTIMER, Period) + sizeof(LONG)) + typedef BOOLEAN -(DDKAPI *PKSYNCHRONIZE_ROUTINE)( - IN PVOID SynchronizeContext); +(NTAPI *PKSYNCHRONIZE_ROUTINE)( + IN PVOID SynchronizeContext); typedef enum _POOL_TYPE { NonPagedPool, @@ -1111,29 +1399,41 @@ typedef enum _POOL_TYPE { NonPagedPoolCacheAlignedMustSSession } POOL_TYPE; -typedef enum _ALTERNATIVE_ARCHITECTURE_TYPE -{ - StandardDesign, - NEC98x86, - EndAlternatives +typedef enum _ALTERNATIVE_ARCHITECTURE_TYPE { + StandardDesign, + NEC98x86, + EndAlternatives } ALTERNATIVE_ARCHITECTURE_TYPE; -typedef struct _KSYSTEM_TIME -{ - ULONG LowPart; - LONG High1Time; - LONG High2Time; +#ifndef _X86_ + +#ifndef IsNEC_98 +#define IsNEC_98 (FALSE) +#endif + +#ifndef IsNotNEC_98 +#define IsNotNEC_98 (TRUE) +#endif + +#ifndef SetNEC_98 +#define SetNEC_98 +#endif + +#ifndef SetNotNEC_98 +#define SetNotNEC_98 +#endif + +#endif + +typedef struct _KSYSTEM_TIME { + ULONG LowPart; + LONG High1Time; + LONG High2Time; } KSYSTEM_TIME, *PKSYSTEM_TIME; -typedef struct _PNP_BUS_INFORMATION { - GUID BusTypeGuid; - INTERFACE_TYPE LegacyBusType; - ULONG BusNumber; -} PNP_BUS_INFORMATION, *PPNP_BUS_INFORMATION; - typedef struct DECLSPEC_ALIGN(16) _M128A { - ULONGLONG Low; - LONGLONG High; + ULONGLONG Low; + LONGLONG High; } M128A, *PM128A; typedef struct DECLSPEC_ALIGN(16) _XSAVE_FORMAT { @@ -1162,18 +1462,110 @@ typedef struct DECLSPEC_ALIGN(16) _XSAVE_FORMAT { #endif } XSAVE_FORMAT, *PXSAVE_FORMAT; +typedef struct DECLSPEC_ALIGN(8) _XSAVE_AREA_HEADER { + ULONG64 Mask; + ULONG64 Reserved[7]; +} XSAVE_AREA_HEADER, *PXSAVE_AREA_HEADER; + +typedef struct DECLSPEC_ALIGN(16) _XSAVE_AREA { + XSAVE_FORMAT LegacyState; + XSAVE_AREA_HEADER Header; +} XSAVE_AREA, *PXSAVE_AREA; + +typedef struct _XSTATE_CONTEXT { + ULONG64 Mask; + ULONG Length; + ULONG Reserved1; + PXSAVE_AREA Area; +#if defined(_X86_) + ULONG Reserved2; +#endif + PVOID Buffer; +#if defined(_X86_) + ULONG Reserved3; +#endif +} XSTATE_CONTEXT, *PXSTATE_CONTEXT; + +typedef struct _XSTATE_SAVE { +#if defined(_AMD64_) + struct _XSTATE_SAVE* Prev; + struct _KTHREAD* Thread; + UCHAR Level; + XSTATE_CONTEXT XStateContext; +#elif defined(_IA64_) + ULONG Dummy; +#elif defined(_X86_) + union { + struct { + LONG64 Reserved1; + ULONG Reserved2; + struct _XSTATE_SAVE* Prev; + PXSAVE_AREA Reserved3; + struct _KTHREAD* Thread; + PVOID Reserved4; + UCHAR Level; + }; + XSTATE_CONTEXT XStateContext; + }; +#endif +} XSTATE_SAVE, *PXSTATE_SAVE; + +#ifdef _X86_ + +#define MAXIMUM_SUPPORTED_EXTENSION 512 + +#if !defined(__midl) && !defined(MIDL_PASS) +C_ASSERT(sizeof(XSAVE_FORMAT) == MAXIMUM_SUPPORTED_EXTENSION); +#endif + +#endif /* _X86_ */ + +#define XSAVE_ALIGN 64 +#define MINIMAL_XSTATE_AREA_LENGTH sizeof(XSAVE_AREA) + +#if !defined(__midl) && !defined(MIDL_PASS) +C_ASSERT((sizeof(XSAVE_FORMAT) & (XSAVE_ALIGN - 1)) == 0); +C_ASSERT((FIELD_OFFSET(XSAVE_AREA, Header) & (XSAVE_ALIGN - 1)) == 0); +C_ASSERT(MINIMAL_XSTATE_AREA_LENGTH == 512 + 64); +#endif + +typedef struct _CONTEXT_CHUNK { + LONG Offset; + ULONG Length; +} CONTEXT_CHUNK, *PCONTEXT_CHUNK; + +typedef struct _CONTEXT_EX { + CONTEXT_CHUNK All; + CONTEXT_CHUNK Legacy; + CONTEXT_CHUNK XState; +} CONTEXT_EX, *PCONTEXT_EX; + +#define CONTEXT_EX_LENGTH ALIGN_UP_BY(sizeof(CONTEXT_EX), STACK_ALIGN) + +#if (NTDDI_VERSION >= NTDDI_VISTA) +extern NTSYSAPI volatile CCHAR KeNumberProcessors; +#elif (NTDDI_VERSION >= NTDDI_WINXP) +extern NTSYSAPI CCHAR KeNumberProcessors; +#else +extern PCCHAR KeNumberProcessors; +#endif /****************************************************************************** * Memory manager Types * ******************************************************************************/ -#define MM_DONT_ZERO_ALLOCATION 0x00000001 -#define MM_ALLOCATE_FROM_LOCAL_NODE_ONLY 0x00000002 -#define MM_ALLOCATE_FULLY_REQUIRED 0x00000004 -#define MM_ALLOCATE_NO_WAIT 0x00000008 -#define MM_ALLOCATE_PREFER_CONTIGUOUS 0x00000010 -#define MM_ALLOCATE_REQUIRE_CONTIGUOUS_CHUNKS 0x00000020 +#if (NTDDI_VERSION >= NTDDI_WIN2K) +typedef ULONG NODE_REQUIREMENT; +#define MM_ANY_NODE_OK 0x80000000 +#endif + +#define MM_DONT_ZERO_ALLOCATION 0x00000001 +#define MM_ALLOCATE_FROM_LOCAL_NODE_ONLY 0x00000002 +#define MM_ALLOCATE_FULLY_REQUIRED 0x00000004 +#define MM_ALLOCATE_NO_WAIT 0x00000008 +#define MM_ALLOCATE_PREFER_CONTIGUOUS 0x00000010 +#define MM_ALLOCATE_REQUIRE_CONTIGUOUS_CHUNKS 0x00000020 #define MDL_MAPPED_TO_SYSTEM_VA 0x0001 #define MDL_PAGES_LOCKED 0x0002 @@ -1256,8 +1648,8 @@ typedef struct DECLSPEC_ALIGN(16) _XSAVE_FORMAT { /* Section map options */ typedef enum _SECTION_INHERIT { - ViewShare = 1, - ViewUnmap = 2 + ViewShare = 1, + ViewUnmap = 2 } SECTION_INHERIT; typedef ULONG PFN_COUNT; @@ -1265,14 +1657,14 @@ typedef LONG_PTR SPFN_NUMBER, *PSPFN_NUMBER; typedef ULONG_PTR PFN_NUMBER, *PPFN_NUMBER; typedef struct _MDL { - struct _MDL *Next; - CSHORT Size; - CSHORT MdlFlags; - struct _EPROCESS *Process; - PVOID MappedSystemVa; - PVOID StartVa; - ULONG ByteCount; - ULONG ByteOffset; + struct _MDL *Next; + CSHORT Size; + CSHORT MdlFlags; + struct _EPROCESS *Process; + PVOID MappedSystemVa; + PVOID StartVa; + ULONG ByteCount; + ULONG ByteOffset; } MDL, *PMDL; typedef MDL *PMDLX; @@ -1296,18 +1688,15 @@ typedef enum _MM_PAGE_PRIORITY { HighPagePriority = 32 } MM_PAGE_PRIORITY; -typedef enum _LOCK_OPERATION { - IoReadAccess, - IoWriteAccess, - IoModifyAccess -} LOCK_OPERATION; - typedef enum _MM_SYSTEM_SIZE { MmSmallSystem, MmMediumSystem, MmLargeSystem } MM_SYSTEMSIZE; +extern PBOOLEAN Mm64BitPhysicalAddress; +extern PVOID MmBadPointer; + /****************************************************************************** * Executive Types * @@ -1317,12 +1706,6 @@ typedef enum _MM_SYSTEM_SIZE { #define EX_RUNDOWN_COUNT_SHIFT 0x1 #define EX_RUNDOWN_COUNT_INC (1 << EX_RUNDOWN_COUNT_SHIFT) -#ifdef _WIN64 -#define PORT_MAXIMUM_MESSAGE_LENGTH 512 -#else -#define PORT_MAXIMUM_MESSAGE_LENGTH 256 -#endif - typedef struct _FAST_MUTEX { volatile LONG Count; PKTHREAD Owner; @@ -1332,35 +1715,35 @@ typedef struct _FAST_MUTEX { } FAST_MUTEX, *PFAST_MUTEX; typedef enum _SUITE_TYPE { - SmallBusiness, - Enterprise, - BackOffice, - CommunicationServer, - TerminalServer, - SmallBusinessRestricted, - EmbeddedNT, - DataCenter, - SingleUserTS, - Personal, - Blade, - EmbeddedRestricted, - SecurityAppliance, - StorageServer, - ComputeServer, - WHServer, - MaxSuiteType + SmallBusiness, + Enterprise, + BackOffice, + CommunicationServer, + TerminalServer, + SmallBusinessRestricted, + EmbeddedNT, + DataCenter, + SingleUserTS, + Personal, + Blade, + EmbeddedRestricted, + SecurityAppliance, + StorageServer, + ComputeServer, + WHServer, + MaxSuiteType } SUITE_TYPE; typedef enum _EX_POOL_PRIORITY { - LowPoolPriority, - LowPoolPrioritySpecialPoolOverrun = 8, - LowPoolPrioritySpecialPoolUnderrun = 9, - NormalPoolPriority = 16, - NormalPoolPrioritySpecialPoolOverrun = 24, - NormalPoolPrioritySpecialPoolUnderrun = 25, - HighPoolPriority = 32, - HighPoolPrioritySpecialPoolOverrun = 40, - HighPoolPrioritySpecialPoolUnderrun = 41 + LowPoolPriority, + LowPoolPrioritySpecialPoolOverrun = 8, + LowPoolPrioritySpecialPoolUnderrun = 9, + NormalPoolPriority = 16, + NormalPoolPrioritySpecialPoolOverrun = 24, + NormalPoolPrioritySpecialPoolUnderrun = 25, + HighPoolPriority = 32, + HighPoolPrioritySpecialPoolOverrun = 40, + HighPoolPrioritySpecialPoolUnderrun = 41 } EX_POOL_PRIORITY; #if !defined(_WIN64) && (defined(_NTDDK_) || defined(_NTIFS_) || defined(_NDIS_)) @@ -1372,32 +1755,33 @@ typedef enum _EX_POOL_PRIORITY { typedef struct _LOOKASIDE_LIST_EX *PLOOKASIDE_LIST_EX; typedef PVOID -(DDKAPI *PALLOCATE_FUNCTION)( - IN POOL_TYPE PoolType, - IN SIZE_T NumberOfBytes, - IN ULONG Tag); +(NTAPI *PALLOCATE_FUNCTION)( + IN POOL_TYPE PoolType, + IN SIZE_T NumberOfBytes, + IN ULONG Tag); typedef PVOID -(DDKAPI *PALLOCATE_FUNCTION_EX)( - IN POOL_TYPE PoolType, - IN SIZE_T NumberOfBytes, - IN ULONG Tag, - IN OUT PLOOKASIDE_LIST_EX Lookaside); +(NTAPI *PALLOCATE_FUNCTION_EX)( + IN POOL_TYPE PoolType, + IN SIZE_T NumberOfBytes, + IN ULONG Tag, + IN OUT PLOOKASIDE_LIST_EX Lookaside); typedef VOID -(DDKAPI *PFREE_FUNCTION)( - IN PVOID Buffer); +(NTAPI *PFREE_FUNCTION)( + IN PVOID Buffer); typedef VOID -(DDKAPI *PFREE_FUNCTION_EX)( - IN PVOID Buffer, - IN OUT PLOOKASIDE_LIST_EX Lookaside); +(NTAPI *PFREE_FUNCTION_EX)( + IN PVOID Buffer, + IN OUT PLOOKASIDE_LIST_EX Lookaside); typedef VOID -(DDKAPI *PCALLBACK_FUNCTION)( - IN PVOID CallbackContext, - IN PVOID Argument1, - IN PVOID Argument2); +(NTAPI CALLBACK_FUNCTION)( + IN PVOID CallbackContext OPTIONAL, + IN PVOID Argument1 OPTIONAL, + IN PVOID Argument2 OPTIONAL); +typedef CALLBACK_FUNCTION *PCALLBACK_FUNCTION; #define GENERAL_LOOKASIDE_LAYOUT \ union { \ @@ -1440,50 +1824,149 @@ typedef VOID ULONG Future[2]; typedef struct LOOKASIDE_ALIGN _GENERAL_LOOKASIDE { - GENERAL_LOOKASIDE_LAYOUT + GENERAL_LOOKASIDE_LAYOUT } GENERAL_LOOKASIDE, *PGENERAL_LOOKASIDE; typedef struct _GENERAL_LOOKASIDE_POOL { - GENERAL_LOOKASIDE_LAYOUT + GENERAL_LOOKASIDE_LAYOUT } GENERAL_LOOKASIDE_POOL, *PGENERAL_LOOKASIDE_POOL; +#define LOOKASIDE_CHECK(f) \ + C_ASSERT(FIELD_OFFSET(GENERAL_LOOKASIDE,f) == FIELD_OFFSET(GENERAL_LOOKASIDE_POOL,f)) + +LOOKASIDE_CHECK(TotalFrees); +LOOKASIDE_CHECK(Tag); +LOOKASIDE_CHECK(Future); + typedef struct _PAGED_LOOKASIDE_LIST { - GENERAL_LOOKASIDE L; + GENERAL_LOOKASIDE L; #if !defined(_AMD64_) && !defined(_IA64_) - FAST_MUTEX Lock__ObsoleteButDoNotDelete; + FAST_MUTEX Lock__ObsoleteButDoNotDelete; #endif } PAGED_LOOKASIDE_LIST, *PPAGED_LOOKASIDE_LIST; typedef struct LOOKASIDE_ALIGN _NPAGED_LOOKASIDE_LIST { - GENERAL_LOOKASIDE L; + GENERAL_LOOKASIDE L; #if !defined(_AMD64_) && !defined(_IA64_) - KSPIN_LOCK Lock__ObsoleteButDoNotDelete; + KSPIN_LOCK Lock__ObsoleteButDoNotDelete; #endif } NPAGED_LOOKASIDE_LIST, *PNPAGED_LOOKASIDE_LIST; +#define LOOKASIDE_MINIMUM_BLOCK_SIZE (RTL_SIZEOF_THROUGH_FIELD (SLIST_ENTRY, Next)) + typedef struct _LOOKASIDE_LIST_EX { - GENERAL_LOOKASIDE_POOL L; + GENERAL_LOOKASIDE_POOL L; } LOOKASIDE_LIST_EX; +#if (NTDDI_VERSION >= NTDDI_VISTA) + +#define EX_LOOKASIDE_LIST_EX_FLAGS_RAISE_ON_FAIL 0x00000001UL +#define EX_LOOKASIDE_LIST_EX_FLAGS_FAIL_NO_RAISE 0x00000002UL + +#define EX_MAXIMUM_LOOKASIDE_DEPTH_BASE 256 +#define EX_MAXIMUM_LOOKASIDE_DEPTH_LIMIT 1024 + +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + typedef struct _EX_RUNDOWN_REF { - __GNU_EXTENSION union { - volatile ULONG_PTR Count; - volatile PVOID Ptr; - }; + __GNU_EXTENSION union { + volatile ULONG_PTR Count; + volatile PVOID Ptr; + }; } EX_RUNDOWN_REF, *PEX_RUNDOWN_REF; -typedef struct _EX_RUNDOWN_REF_CACHE_AWARE *PEX_RUNDOWN_REF_CACHE_AWARE; +typedef struct _EX_RUNDOWN_REF_CACHE_AWARE *PEX_RUNDOWN_REF_CACHE_AWARE; + +typedef enum _WORK_QUEUE_TYPE { + CriticalWorkQueue, + DelayedWorkQueue, + HyperCriticalWorkQueue, + MaximumWorkQueue +} WORK_QUEUE_TYPE; typedef VOID -(DDKAPI *PWORKER_THREAD_ROUTINE)( +(NTAPI WORKER_THREAD_ROUTINE)( IN PVOID Parameter); +typedef WORKER_THREAD_ROUTINE *PWORKER_THREAD_ROUTINE; typedef struct _WORK_QUEUE_ITEM { - LIST_ENTRY List; - PWORKER_THREAD_ROUTINE WorkerRoutine; - volatile PVOID Parameter; + LIST_ENTRY List; + PWORKER_THREAD_ROUTINE WorkerRoutine; + volatile PVOID Parameter; } WORK_QUEUE_ITEM, *PWORK_QUEUE_ITEM; +typedef ULONG_PTR ERESOURCE_THREAD, *PERESOURCE_THREAD; + +typedef struct _OWNER_ENTRY { + ERESOURCE_THREAD OwnerThread; + union { + struct { + ULONG IoPriorityBoosted:1; + ULONG OwnerReferenced:1; + ULONG OwnerCount:30; + }; + ULONG TableSize; + }; +} OWNER_ENTRY, *POWNER_ENTRY; + +typedef struct _ERESOURCE { + LIST_ENTRY SystemResourcesList; + POWNER_ENTRY OwnerTable; + SHORT ActiveCount; + USHORT Flag; + volatile PKSEMAPHORE SharedWaiters; + volatile PKEVENT ExclusiveWaiters; + OWNER_ENTRY OwnerEntry; + ULONG ActiveEntries; + ULONG ContentionCount; + ULONG NumberOfSharedWaiters; + ULONG NumberOfExclusiveWaiters; +#if defined(_WIN64) + PVOID Reserved2; +#endif + __GNU_EXTENSION union { + PVOID Address; + ULONG_PTR CreatorBackTraceIndex; + }; + KSPIN_LOCK SpinLock; +} ERESOURCE, *PERESOURCE; + +/* ERESOURCE.Flag */ +#define ResourceNeverExclusive 0x0010 +#define ResourceReleaseByOtherThread 0x0020 +#define ResourceOwnedExclusive 0x0080 + +#define RESOURCE_HASH_TABLE_SIZE 64 + +typedef struct _RESOURCE_HASH_ENTRY { + LIST_ENTRY ListEntry; + PVOID Address; + ULONG ContentionCount; + ULONG Number; +} RESOURCE_HASH_ENTRY, *PRESOURCE_HASH_ENTRY; + +typedef struct _RESOURCE_PERFORMANCE_DATA { + ULONG ActiveResourceCount; + ULONG TotalResourceCount; + ULONG ExclusiveAcquire; + ULONG SharedFirstLevel; + ULONG SharedSecondLevel; + ULONG StarveFirstLevel; + ULONG StarveSecondLevel; + ULONG WaitForExclusive; + ULONG OwnerTableExpands; + ULONG MaximumTableExpand; + LIST_ENTRY HashTable[RESOURCE_HASH_TABLE_SIZE]; +} RESOURCE_PERFORMANCE_DATA, *PRESOURCE_PERFORMANCE_DATA; + +/* Global debug flag */ +#if DEVL +extern ULONG NtGlobalFlag; +#define IF_NTOS_DEBUG(FlagName) if (NtGlobalFlag & (FLG_##FlagName)) +#else +#define IF_NTOS_DEBUG(FlagName) if(FALSE) +#endif + /****************************************************************************** * Security Manager Types * @@ -1515,10 +1998,10 @@ typedef PVOID PSID; #define GENERIC_ALL 0x10000000L typedef struct _GENERIC_MAPPING { - ACCESS_MASK GenericRead; - ACCESS_MASK GenericWrite; - ACCESS_MASK GenericExecute; - ACCESS_MASK GenericAll; + ACCESS_MASK GenericRead; + ACCESS_MASK GenericWrite; + ACCESS_MASK GenericExecute; + ACCESS_MASK GenericAll; } GENERIC_MAPPING, *PGENERIC_MAPPING; #define ACL_REVISION 2 @@ -1532,11 +2015,11 @@ typedef struct _GENERIC_MAPPING { #define MAX_ACL_REVISION ACL_REVISION4 typedef struct _ACL { - UCHAR AclRevision; - UCHAR Sbz1; - USHORT AclSize; - USHORT AceCount; - USHORT Sbz2; + UCHAR AclRevision; + UCHAR Sbz1; + USHORT AclSize; + USHORT AceCount; + USHORT Sbz2; } ACL, *PACL; /* Current security descriptor revision value */ @@ -1556,8 +2039,8 @@ typedef struct _ACL { #include typedef struct _LUID_AND_ATTRIBUTES { - LUID Luid; - ULONG Attributes; + LUID Luid; + ULONG Attributes; } LUID_AND_ATTRIBUTES, *PLUID_AND_ATTRIBUTES; #include @@ -1568,16 +2051,16 @@ typedef LUID_AND_ATTRIBUTES_ARRAY *PLUID_AND_ATTRIBUTES_ARRAY; #define PRIVILEGE_SET_ALL_NECESSARY (1) typedef struct _PRIVILEGE_SET { - ULONG PrivilegeCount; - ULONG Control; - LUID_AND_ATTRIBUTES Privilege[ANYSIZE_ARRAY]; + ULONG PrivilegeCount; + ULONG Control; + LUID_AND_ATTRIBUTES Privilege[ANYSIZE_ARRAY]; } PRIVILEGE_SET,*PPRIVILEGE_SET; typedef enum _SECURITY_IMPERSONATION_LEVEL { - SecurityAnonymous, - SecurityIdentification, - SecurityImpersonation, - SecurityDelegation + SecurityAnonymous, + SecurityIdentification, + SecurityImpersonation, + SecurityDelegation } SECURITY_IMPERSONATION_LEVEL, * PSECURITY_IMPERSONATION_LEVEL; #define SECURITY_MAX_IMPERSONATION_LEVEL SecurityDelegation @@ -1591,17 +2074,17 @@ typedef enum _SECURITY_IMPERSONATION_LEVEL { typedef BOOLEAN SECURITY_CONTEXT_TRACKING_MODE, *PSECURITY_CONTEXT_TRACKING_MODE; typedef struct _SECURITY_QUALITY_OF_SERVICE { - ULONG Length; - SECURITY_IMPERSONATION_LEVEL ImpersonationLevel; - SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode; - BOOLEAN EffectiveOnly; + ULONG Length; + SECURITY_IMPERSONATION_LEVEL ImpersonationLevel; + SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode; + BOOLEAN EffectiveOnly; } SECURITY_QUALITY_OF_SERVICE, *PSECURITY_QUALITY_OF_SERVICE; typedef struct _SE_IMPERSONATION_STATE { - PACCESS_TOKEN Token; - BOOLEAN CopyOnOpen; - BOOLEAN EffectiveOnly; - SECURITY_IMPERSONATION_LEVEL Level; + PACCESS_TOKEN Token; + BOOLEAN CopyOnOpen; + BOOLEAN EffectiveOnly; + SECURITY_IMPERSONATION_LEVEL Level; } SE_IMPERSONATION_STATE, *PSE_IMPERSONATION_STATE; #define OWNER_SECURITY_INFORMATION (0x00000001L) @@ -1625,9 +2108,9 @@ typedef enum _SECURITY_OPERATION_CODE { #define INITIAL_PRIVILEGE_COUNT 3 typedef struct _INITIAL_PRIVILEGE_SET { - ULONG PrivilegeCount; - ULONG Control; - LUID_AND_ATTRIBUTES Privilege[INITIAL_PRIVILEGE_COUNT]; + ULONG PrivilegeCount; + ULONG Control; + LUID_AND_ATTRIBUTES Privilege[INITIAL_PRIVILEGE_COUNT]; } INITIAL_PRIVILEGE_SET, * PINITIAL_PRIVILEGE_SET; #define SE_MIN_WELL_KNOWN_PRIVILEGE 2 @@ -1668,35 +2151,38 @@ typedef struct _INITIAL_PRIVILEGE_SET { #define SE_MAX_WELL_KNOWN_PRIVILEGE SE_CREATE_SYMBOLIC_LINK_PRIVILEGE typedef struct _SECURITY_SUBJECT_CONTEXT { - PACCESS_TOKEN ClientToken; - SECURITY_IMPERSONATION_LEVEL ImpersonationLevel; - PACCESS_TOKEN PrimaryToken; - PVOID ProcessAuditId; + PACCESS_TOKEN ClientToken; + SECURITY_IMPERSONATION_LEVEL ImpersonationLevel; + PACCESS_TOKEN PrimaryToken; + PVOID ProcessAuditId; } SECURITY_SUBJECT_CONTEXT, *PSECURITY_SUBJECT_CONTEXT; typedef struct _ACCESS_STATE { - LUID OperationID; - BOOLEAN SecurityEvaluated; - BOOLEAN GenerateAudit; - BOOLEAN GenerateOnClose; - BOOLEAN PrivilegesAllocated; - ULONG Flags; - ACCESS_MASK RemainingDesiredAccess; - ACCESS_MASK PreviouslyGrantedAccess; - ACCESS_MASK OriginalDesiredAccess; - SECURITY_SUBJECT_CONTEXT SubjectSecurityContext; - PSECURITY_DESCRIPTOR SecurityDescriptor; - PVOID AuxData; + LUID OperationID; + BOOLEAN SecurityEvaluated; + BOOLEAN GenerateAudit; + BOOLEAN GenerateOnClose; + BOOLEAN PrivilegesAllocated; + ULONG Flags; + ACCESS_MASK RemainingDesiredAccess; + ACCESS_MASK PreviouslyGrantedAccess; + ACCESS_MASK OriginalDesiredAccess; + SECURITY_SUBJECT_CONTEXT SubjectSecurityContext; + PSECURITY_DESCRIPTOR SecurityDescriptor; + PVOID AuxData; union { - INITIAL_PRIVILEGE_SET InitialPrivilegeSet; - PRIVILEGE_SET PrivilegeSet; + INITIAL_PRIVILEGE_SET InitialPrivilegeSet; + PRIVILEGE_SET PrivilegeSet; } Privileges; - - BOOLEAN AuditPrivileges; - UNICODE_STRING ObjectName; - UNICODE_STRING ObjectTypeName; + BOOLEAN AuditPrivileges; + UNICODE_STRING ObjectName; + UNICODE_STRING ObjectTypeName; } ACCESS_STATE, *PACCESS_STATE; +typedef VOID +(NTAPI *PNTFS_DEREF_EXPORTED_SECURITY_DESCRIPTOR)( + IN PVOID Vcb, + IN PSECURITY_DESCRIPTOR SecurityDescriptor); #ifndef _NTLSA_IFS_ @@ -1767,8 +2253,8 @@ typedef struct _SE_ADT_PARAMETER_ARRAY_ENTRY { typedef struct _SE_ADT_ACCESS_REASON { ACCESS_MASK AccessMask; - ULONG AccessReasons[32]; - ULONG ObjectTypeIndex; + ULONG AccessReasons[32]; + ULONG ObjectTypeIndex; ULONG AccessGranted; PSECURITY_DESCRIPTOR SecurityDescriptor; } SE_ADT_ACCESS_REASON, *PSE_ADT_ACCESS_REASON; @@ -1787,7 +2273,6 @@ typedef struct _SE_ADT_PARAMETER_ARRAY { #endif /* !_NTLSA_AUDIT_ */ #endif /* !_NTLSA_IFS_ */ - /****************************************************************************** * Power Management Support Types * ******************************************************************************/ @@ -1795,99 +2280,112 @@ typedef struct _SE_ADT_PARAMETER_ARRAY { #ifndef _PO_DDK_ #define _PO_DDK_ +#define PO_CB_SYSTEM_POWER_POLICY 0 +#define PO_CB_AC_STATUS 1 +#define PO_CB_BUTTON_COLLISION 2 +#define PO_CB_SYSTEM_STATE_LOCK 3 +#define PO_CB_LID_SWITCH_STATE 4 +#define PO_CB_PROCESSOR_POWER_POLICY 5 + /* Power States/Levels */ typedef enum _SYSTEM_POWER_STATE { - PowerSystemUnspecified, - PowerSystemWorking, - PowerSystemSleeping1, - PowerSystemSleeping2, - PowerSystemSleeping3, - PowerSystemHibernate, - PowerSystemShutdown, - PowerSystemMaximum + PowerSystemUnspecified = 0, + PowerSystemWorking, + PowerSystemSleeping1, + PowerSystemSleeping2, + PowerSystemSleeping3, + PowerSystemHibernate, + PowerSystemShutdown, + PowerSystemMaximum } SYSTEM_POWER_STATE, *PSYSTEM_POWER_STATE; #define POWER_SYSTEM_MAXIMUM PowerSystemMaximum typedef enum _POWER_INFORMATION_LEVEL { - SystemPowerPolicyAc, - SystemPowerPolicyDc, - VerifySystemPolicyAc, - VerifySystemPolicyDc, - SystemPowerCapabilities, - SystemBatteryState, - SystemPowerStateHandler, - ProcessorStateHandler, - SystemPowerPolicyCurrent, - AdministratorPowerPolicy, - SystemReserveHiberFile, - ProcessorInformation, - SystemPowerInformation, - ProcessorStateHandler2, - LastWakeTime, - LastSleepTime, - SystemExecutionState, - SystemPowerStateNotifyHandler, - ProcessorPowerPolicyAc, - ProcessorPowerPolicyDc, - VerifyProcessorPowerPolicyAc, - VerifyProcessorPowerPolicyDc, - ProcessorPowerPolicyCurrent, - SystemPowerStateLogging, - SystemPowerLoggingEntry, - SetPowerSettingValue, - NotifyUserPowerSetting, - PowerInformationLevelUnused0, - PowerInformationLevelUnused1, - SystemVideoState, - TraceApplicationPowerMessage, - TraceApplicationPowerMessageEnd, - ProcessorPerfStates, - ProcessorIdleStates, - ProcessorCap, - SystemWakeSource, - SystemHiberFileInformation, - TraceServicePowerMessage, - ProcessorLoad, - PowerShutdownNotification, - MonitorCapabilities, - SessionPowerInit, - SessionDisplayState, - PowerRequestCreate, - PowerRequestAction, - GetPowerRequestList, - ProcessorInformationEx, - NotifyUserModeLegacyPowerEvent, - GroupPark, - ProcessorIdleDomains, - WakeTimerList, - SystemHiberFileSize, - PowerInformationLevelMaximum + SystemPowerPolicyAc, + SystemPowerPolicyDc, + VerifySystemPolicyAc, + VerifySystemPolicyDc, + SystemPowerCapabilities, + SystemBatteryState, + SystemPowerStateHandler, + ProcessorStateHandler, + SystemPowerPolicyCurrent, + AdministratorPowerPolicy, + SystemReserveHiberFile, + ProcessorInformation, + SystemPowerInformation, + ProcessorStateHandler2, + LastWakeTime, + LastSleepTime, + SystemExecutionState, + SystemPowerStateNotifyHandler, + ProcessorPowerPolicyAc, + ProcessorPowerPolicyDc, + VerifyProcessorPowerPolicyAc, + VerifyProcessorPowerPolicyDc, + ProcessorPowerPolicyCurrent, + SystemPowerStateLogging, + SystemPowerLoggingEntry, + SetPowerSettingValue, + NotifyUserPowerSetting, + PowerInformationLevelUnused0, + PowerInformationLevelUnused1, + SystemVideoState, + TraceApplicationPowerMessage, + TraceApplicationPowerMessageEnd, + ProcessorPerfStates, + ProcessorIdleStates, + ProcessorCap, + SystemWakeSource, + SystemHiberFileInformation, + TraceServicePowerMessage, + ProcessorLoad, + PowerShutdownNotification, + MonitorCapabilities, + SessionPowerInit, + SessionDisplayState, + PowerRequestCreate, + PowerRequestAction, + GetPowerRequestList, + ProcessorInformationEx, + NotifyUserModeLegacyPowerEvent, + GroupPark, + ProcessorIdleDomains, + WakeTimerList, + SystemHiberFileSize, + PowerInformationLevelMaximum } POWER_INFORMATION_LEVEL; typedef enum { - PowerActionNone, - PowerActionReserved, - PowerActionSleep, - PowerActionHibernate, - PowerActionShutdown, - PowerActionShutdownReset, - PowerActionShutdownOff, - PowerActionWarmEject + PowerActionNone = 0, + PowerActionReserved, + PowerActionSleep, + PowerActionHibernate, + PowerActionShutdown, + PowerActionShutdownReset, + PowerActionShutdownOff, + PowerActionWarmEject } POWER_ACTION, *PPOWER_ACTION; typedef enum _DEVICE_POWER_STATE { - PowerDeviceUnspecified, - PowerDeviceD0, - PowerDeviceD1, - PowerDeviceD2, - PowerDeviceD3, - PowerDeviceMaximum + PowerDeviceUnspecified = 0, + PowerDeviceD0, + PowerDeviceD1, + PowerDeviceD2, + PowerDeviceD3, + PowerDeviceMaximum } DEVICE_POWER_STATE, *PDEVICE_POWER_STATE; +typedef enum _MONITOR_DISPLAY_STATE { + PowerMonitorOff = 0, + PowerMonitorOn, + PowerMonitorDim +} MONITOR_DISPLAY_STATE, *PMONITOR_DISPLAY_STATE; + typedef union _POWER_STATE { - SYSTEM_POWER_STATE SystemState; - DEVICE_POWER_STATE DeviceState; + SYSTEM_POWER_STATE SystemState; + DEVICE_POWER_STATE DeviceState; } POWER_STATE, *PPOWER_STATE; typedef enum _POWER_STATE_TYPE { @@ -1895,39 +2393,297 @@ typedef enum _POWER_STATE_TYPE { DevicePowerState } POWER_STATE_TYPE, *PPOWER_STATE_TYPE; +#if (NTDDI_VERSION >= NTDDI_VISTA) +typedef struct _SYSTEM_POWER_STATE_CONTEXT { + union { + struct { + ULONG Reserved1:8; + ULONG TargetSystemState:4; + ULONG EffectiveSystemState:4; + ULONG CurrentSystemState:4; + ULONG IgnoreHibernationPath:1; + ULONG PseudoTransition:1; + ULONG Reserved2:10; + } DUMMYSTRUCTNAME; + ULONG ContextAsUlong; + } DUMMYUNIONNAME; +} SYSTEM_POWER_STATE_CONTEXT, *PSYSTEM_POWER_STATE_CONTEXT; +#endif + +#if (NTDDI_VERSION >= NTDDI_WIN7) +typedef struct _COUNTED_REASON_CONTEXT { + ULONG Version; + ULONG Flags; + union { + struct { + UNICODE_STRING ResourceFileName; + USHORT ResourceReasonId; + ULONG StringCount; + PUNICODE_STRING ReasonStrings; + } DUMMYSTRUCTNAME; + UNICODE_STRING SimpleString; + } DUMMYUNIONNAME; +} COUNTED_REASON_CONTEXT, *PCOUNTED_REASON_CONTEXT; +#endif + +#define IOCTL_QUERY_DEVICE_POWER_STATE \ + CTL_CODE(FILE_DEVICE_BATTERY, 0x0, METHOD_BUFFERED, FILE_READ_ACCESS) + +#define IOCTL_SET_DEVICE_WAKE \ + CTL_CODE(FILE_DEVICE_BATTERY, 0x1, METHOD_BUFFERED, FILE_WRITE_ACCESS) + +#define IOCTL_CANCEL_DEVICE_WAKE \ + CTL_CODE(FILE_DEVICE_BATTERY, 0x2, METHOD_BUFFERED, FILE_WRITE_ACCESS) + +#define ES_SYSTEM_REQUIRED 0x00000001 +#define ES_DISPLAY_REQUIRED 0x00000002 +#define ES_USER_PRESENT 0x00000004 +#define ES_CONTINUOUS 0x80000000 + +typedef ULONG EXECUTION_STATE, *PEXECUTION_STATE; + +typedef enum { + LT_DONT_CARE, + LT_LOWEST_LATENCY +} LATENCY_TIME; + +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN7) +#define DIAGNOSTIC_REASON_VERSION 0 +#define DIAGNOSTIC_REASON_SIMPLE_STRING 0x00000001 +#define DIAGNOSTIC_REASON_DETAILED_STRING 0x00000002 +#define DIAGNOSTIC_REASON_NOT_SPECIFIED 0x80000000 +#define DIAGNOSTIC_REASON_INVALID_FLAGS (~0x80000003) +#endif + +#define POWER_REQUEST_CONTEXT_VERSION 0 +#define POWER_REQUEST_CONTEXT_SIMPLE_STRING 0x00000001 +#define POWER_REQUEST_CONTEXT_DETAILED_STRING 0x00000002 + +#define PowerRequestMaximum 3 + +typedef enum _POWER_REQUEST_TYPE { + PowerRequestDisplayRequired, + PowerRequestSystemRequired, + PowerRequestAwayModeRequired +} POWER_REQUEST_TYPE, *PPOWER_REQUEST_TYPE; + +#if (NTDDI_VERSION >= NTDDI_WINXP) + +#define PDCAP_D0_SUPPORTED 0x00000001 +#define PDCAP_D1_SUPPORTED 0x00000002 +#define PDCAP_D2_SUPPORTED 0x00000004 +#define PDCAP_D3_SUPPORTED 0x00000008 +#define PDCAP_WAKE_FROM_D0_SUPPORTED 0x00000010 +#define PDCAP_WAKE_FROM_D1_SUPPORTED 0x00000020 +#define PDCAP_WAKE_FROM_D2_SUPPORTED 0x00000040 +#define PDCAP_WAKE_FROM_D3_SUPPORTED 0x00000080 +#define PDCAP_WARM_EJECT_SUPPORTED 0x00000100 + +typedef struct CM_Power_Data_s { + ULONG PD_Size; + DEVICE_POWER_STATE PD_MostRecentPowerState; + ULONG PD_Capabilities; + ULONG PD_D1Latency; + ULONG PD_D2Latency; + ULONG PD_D3Latency; + DEVICE_POWER_STATE PD_PowerStateMapping[PowerSystemMaximum]; + SYSTEM_POWER_STATE PD_DeepestSystemWake; +} CM_POWER_DATA, *PCM_POWER_DATA; + +#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ + +typedef enum _SYSTEM_POWER_CONDITION { + PoAc, + PoDc, + PoHot, + PoConditionMaximum +} SYSTEM_POWER_CONDITION; + +typedef struct _SET_POWER_SETTING_VALUE { + ULONG Version; + GUID Guid; + SYSTEM_POWER_CONDITION PowerCondition; + ULONG DataLength; + UCHAR Data[ANYSIZE_ARRAY]; +} SET_POWER_SETTING_VALUE, *PSET_POWER_SETTING_VALUE; + +#define POWER_SETTING_VALUE_VERSION (0x1) + +typedef struct _NOTIFY_USER_POWER_SETTING { + GUID Guid; +} NOTIFY_USER_POWER_SETTING, *PNOTIFY_USER_POWER_SETTING; + +typedef struct _APPLICATIONLAUNCH_SETTING_VALUE { + LARGE_INTEGER ActivationTime; + ULONG Flags; + ULONG ButtonInstanceID; +} APPLICATIONLAUNCH_SETTING_VALUE, *PAPPLICATIONLAUNCH_SETTING_VALUE; + +typedef enum _POWER_PLATFORM_ROLE { + PlatformRoleUnspecified = 0, + PlatformRoleDesktop, + PlatformRoleMobile, + PlatformRoleWorkstation, + PlatformRoleEnterpriseServer, + PlatformRoleSOHOServer, + PlatformRoleAppliancePC, + PlatformRolePerformanceServer, + PlatformRoleMaximum +} POWER_PLATFORM_ROLE; + #if (NTDDI_VERSION >= NTDDI_WINXP) || !defined(_BATCLASS_) typedef struct { - ULONG Granularity; - ULONG Capacity; + ULONG Granularity; + ULONG Capacity; } BATTERY_REPORTING_SCALE, *PBATTERY_REPORTING_SCALE; #endif /* (NTDDI_VERSION >= NTDDI_WINXP) || !defined(_BATCLASS_) */ #endif /* !_PO_DDK_ */ +#define CORE_PARKING_POLICY_CHANGE_IDEAL 0 +#define CORE_PARKING_POLICY_CHANGE_SINGLE 1 +#define CORE_PARKING_POLICY_CHANGE_ROCKET 2 +#define CORE_PARKING_POLICY_CHANGE_MAX CORE_PARKING_POLICY_CHANGE_ROCKET + +DEFINE_GUID(GUID_MAX_POWER_SAVINGS, 0xA1841308, 0x3541, 0x4FAB, 0xBC, 0x81, 0xF7, 0x15, 0x56, 0xF2, 0x0B, 0x4A ); +DEFINE_GUID(GUID_MIN_POWER_SAVINGS, 0x8C5E7FDA, 0xE8BF, 0x4A96, 0x9A, 0x85, 0xA6, 0xE2, 0x3A, 0x8C, 0x63, 0x5C ); +DEFINE_GUID(GUID_TYPICAL_POWER_SAVINGS, 0x381B4222, 0xF694, 0x41F0, 0x96, 0x85, 0xFF, 0x5B, 0xB2, 0x60, 0xDF, 0x2E ); +DEFINE_GUID(NO_SUBGROUP_GUID, 0xFEA3413E, 0x7E05, 0x4911, 0x9A, 0x71, 0x70, 0x03, 0x31, 0xF1, 0xC2, 0x94 ); +DEFINE_GUID(ALL_POWERSCHEMES_GUID, 0x68A1E95E, 0x13EA, 0x41E1, 0x80, 0x11, 0x0C, 0x49, 0x6C, 0xA4, 0x90, 0xB0 ); +DEFINE_GUID(GUID_POWERSCHEME_PERSONALITY, 0x245D8541, 0x3943, 0x4422, 0xB0, 0x25, 0x13, 0xA7, 0x84, 0xF6, 0x79, 0xB7 ); +DEFINE_GUID(GUID_ACTIVE_POWERSCHEME, 0x31F9F286, 0x5084, 0x42FE, 0xB7, 0x20, 0x2B, 0x02, 0x64, 0x99, 0x37, 0x63 ); +DEFINE_GUID(GUID_VIDEO_SUBGROUP, 0x7516B95F, 0xF776, 0x4464, 0x8C, 0x53, 0x06, 0x16, 0x7F, 0x40, 0xCC, 0x99 ); +DEFINE_GUID(GUID_VIDEO_POWERDOWN_TIMEOUT, 0x3C0BC021, 0xC8A8, 0x4E07, 0xA9, 0x73, 0x6B, 0x14, 0xCB, 0xCB, 0x2B, 0x7E ); +DEFINE_GUID(GUID_VIDEO_ANNOYANCE_TIMEOUT, 0x82DBCF2D, 0xCD67, 0x40C5, 0xBF, 0xDC, 0x9F, 0x1A, 0x5C, 0xCD, 0x46, 0x63 ); +DEFINE_GUID(GUID_VIDEO_ADAPTIVE_PERCENT_INCREASE, 0xEED904DF, 0xB142, 0x4183, 0xB1, 0x0B, 0x5A, 0x11, 0x97, 0xA3, 0x78, 0x64 ); +DEFINE_GUID(GUID_VIDEO_DIM_TIMEOUT, 0x17aaa29b, 0x8b43, 0x4b94, 0xaa, 0xfe, 0x35, 0xf6, 0x4d, 0xaa, 0xf1, 0xee); +DEFINE_GUID(GUID_VIDEO_ADAPTIVE_POWERDOWN, 0x90959D22, 0xD6A1, 0x49B9, 0xAF, 0x93, 0xBC, 0xE8, 0x85, 0xAD, 0x33, 0x5B ); +DEFINE_GUID(GUID_MONITOR_POWER_ON, 0x02731015, 0x4510, 0x4526, 0x99, 0xE6, 0xE5, 0xA1, 0x7E, 0xBD, 0x1A, 0xEA ); +DEFINE_GUID(GUID_DEVICE_POWER_POLICY_VIDEO_BRIGHTNESS, 0xaded5e82L, 0xb909, 0x4619, 0x99, 0x49, 0xf5, 0xd7, 0x1d, 0xac, 0x0b, 0xcb); +DEFINE_GUID(GUID_DEVICE_POWER_POLICY_VIDEO_DIM_BRIGHTNESS, 0xf1fbfde2, 0xa960, 0x4165, 0x9f, 0x88, 0x50, 0x66, 0x79, 0x11, 0xce, 0x96); +DEFINE_GUID(GUID_VIDEO_CURRENT_MONITOR_BRIGHTNESS, 0x8ffee2c6, 0x2d01, 0x46be, 0xad, 0xb9, 0x39, 0x8a, 0xdd, 0xc5, 0xb4, 0xff); +DEFINE_GUID(GUID_VIDEO_ADAPTIVE_DISPLAY_BRIGHTNESS, 0xFBD9AA66, 0x9553, 0x4097, 0xBA, 0x44, 0xED, 0x6E, 0x9D, 0x65, 0xEA, 0xB8); +DEFINE_GUID(GUID_SESSION_DISPLAY_STATE, 0x73A5E93A, 0x5BB1, 0x4F93, 0x89, 0x5B, 0xDB, 0xD0, 0xDA, 0x85, 0x59, 0x67 ); +DEFINE_GUID(GUID_CONSOLE_DISPLAY_STATE, 0x6fe69556, 0x704a, 0x47a0, 0x8f, 0x24, 0xc2, 0x8d, 0x93, 0x6f, 0xda, 0x47); +DEFINE_GUID(GUID_ALLOW_DISPLAY_REQUIRED, 0xA9CEB8DA, 0xCD46, 0x44FB, 0xA9, 0x8B, 0x02, 0xAF, 0x69, 0xDE, 0x46, 0x23 ); +DEFINE_GUID(GUID_DISK_SUBGROUP, 0x0012EE47, 0x9041, 0x4B5D, 0x9B, 0x77, 0x53, 0x5F, 0xBA, 0x8B, 0x14, 0x42 ); +DEFINE_GUID(GUID_DISK_POWERDOWN_TIMEOUT, 0x6738E2C4, 0xE8A5, 0x4A42, 0xB1, 0x6A, 0xE0, 0x40, 0xE7, 0x69, 0x75, 0x6E ); +DEFINE_GUID(GUID_DISK_BURST_IGNORE_THRESHOLD, 0x80e3c60e, 0xbb94, 0x4ad8, 0xbb, 0xe0, 0x0d, 0x31, 0x95, 0xef, 0xc6, 0x63 ); +DEFINE_GUID(GUID_DISK_ADAPTIVE_POWERDOWN, 0x396A32E1, 0x499A, 0x40B2, 0x91, 0x24, 0xA9, 0x6A, 0xFE, 0x70, 0x76, 0x67 ); +DEFINE_GUID(GUID_SLEEP_SUBGROUP, 0x238C9FA8, 0x0AAD, 0x41ED, 0x83, 0xF4, 0x97, 0xBE, 0x24, 0x2C, 0x8F, 0x20 ); +DEFINE_GUID(GUID_SLEEP_IDLE_THRESHOLD, 0x81cd32e0, 0x7833, 0x44f3, 0x87, 0x37, 0x70, 0x81, 0xf3, 0x8d, 0x1f, 0x70 ); +DEFINE_GUID(GUID_STANDBY_TIMEOUT, 0x29F6C1DB, 0x86DA, 0x48C5, 0x9F, 0xDB, 0xF2, 0xB6, 0x7B, 0x1F, 0x44, 0xDA ); +DEFINE_GUID(GUID_UNATTEND_SLEEP_TIMEOUT, 0x7bc4a2f9, 0xd8fc, 0x4469, 0xb0, 0x7b, 0x33, 0xeb, 0x78, 0x5a, 0xac, 0xa0 ); +DEFINE_GUID(GUID_HIBERNATE_TIMEOUT, 0x9D7815A6, 0x7EE4, 0x497E, 0x88, 0x88, 0x51, 0x5A, 0x05, 0xF0, 0x23, 0x64 ); +DEFINE_GUID(GUID_HIBERNATE_FASTS4_POLICY, 0x94AC6D29, 0x73CE, 0x41A6, 0x80, 0x9F, 0x63, 0x63, 0xBA, 0x21, 0xB4, 0x7E ); +DEFINE_GUID(GUID_CRITICAL_POWER_TRANSITION, 0xB7A27025, 0xE569, 0x46c2, 0xA5, 0x04, 0x2B, 0x96, 0xCA, 0xD2, 0x25, 0xA1); +DEFINE_GUID(GUID_SYSTEM_AWAYMODE, 0x98A7F580, 0x01F7, 0x48AA, 0x9C, 0x0F, 0x44, 0x35, 0x2C, 0x29, 0xE5, 0xC0 ); +DEFINE_GUID(GUID_ALLOW_AWAYMODE, 0x25dfa149, 0x5dd1, 0x4736, 0xb5, 0xab, 0xe8, 0xa3, 0x7b, 0x5b, 0x81, 0x87 ); +DEFINE_GUID(GUID_ALLOW_STANDBY_STATES, 0xabfc2519, 0x3608, 0x4c2a, 0x94, 0xea, 0x17, 0x1b, 0x0e, 0xd5, 0x46, 0xab ); +DEFINE_GUID(GUID_ALLOW_RTC_WAKE, 0xBD3B718A, 0x0680, 0x4D9D, 0x8A, 0xB2, 0xE1, 0xD2, 0xB4, 0xAC, 0x80, 0x6D ); +DEFINE_GUID(GUID_ALLOW_SYSTEM_REQUIRED, 0xA4B195F5, 0x8225, 0x47D8, 0x80, 0x12, 0x9D, 0x41, 0x36, 0x97, 0x86, 0xE2 ); +DEFINE_GUID(GUID_SYSTEM_BUTTON_SUBGROUP, 0x4F971E89, 0xEEBD, 0x4455, 0xA8, 0xDE, 0x9E, 0x59, 0x04, 0x0E, 0x73, 0x47 ); +DEFINE_GUID(GUID_POWERBUTTON_ACTION, 0x7648EFA3, 0xDD9C, 0x4E3E, 0xB5, 0x66, 0x50, 0xF9, 0x29, 0x38, 0x62, 0x80 ); +DEFINE_GUID(GUID_POWERBUTTON_ACTION_FLAGS, 0x857E7FAC, 0x034B, 0x4704, 0xAB, 0xB1, 0xBC, 0xA5, 0x4A, 0xA3, 0x14, 0x78 ); +DEFINE_GUID(GUID_SLEEPBUTTON_ACTION, 0x96996BC0, 0xAD50, 0x47EC, 0x92, 0x3B, 0x6F, 0x41, 0x87, 0x4D, 0xD9, 0xEB ); +DEFINE_GUID(GUID_SLEEPBUTTON_ACTION_FLAGS, 0x2A160AB1, 0xB69D, 0x4743, 0xB7, 0x18, 0xBF, 0x14, 0x41, 0xD5, 0xE4, 0x93 ); +DEFINE_GUID(GUID_USERINTERFACEBUTTON_ACTION, 0xA7066653, 0x8D6C, 0x40A8, 0x91, 0x0E, 0xA1, 0xF5, 0x4B, 0x84, 0xC7, 0xE5 ); +DEFINE_GUID(GUID_LIDCLOSE_ACTION, 0x5CA83367, 0x6E45, 0x459F, 0xA2, 0x7B, 0x47, 0x6B, 0x1D, 0x01, 0xC9, 0x36 ); +DEFINE_GUID(GUID_LIDCLOSE_ACTION_FLAGS, 0x97E969AC, 0x0D6C, 0x4D08, 0x92, 0x7C, 0xD7, 0xBD, 0x7A, 0xD7, 0x85, 0x7B ); +DEFINE_GUID(GUID_LIDOPEN_POWERSTATE, 0x99FF10E7, 0x23B1, 0x4C07, 0xA9, 0xD1, 0x5C, 0x32, 0x06, 0xD7, 0x41, 0xB4 ); +DEFINE_GUID(GUID_BATTERY_SUBGROUP, 0xE73A048D, 0xBF27, 0x4F12, 0x97, 0x31, 0x8B, 0x20, 0x76, 0xE8, 0x89, 0x1F ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_ACTION_0, 0x637EA02F, 0xBBCB, 0x4015, 0x8E, 0x2C, 0xA1, 0xC7, 0xB9, 0xC0, 0xB5, 0x46 ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_LEVEL_0, 0x9A66D8D7, 0x4FF7, 0x4EF9, 0xB5, 0xA2, 0x5A, 0x32, 0x6C, 0xA2, 0xA4, 0x69 ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_FLAGS_0, 0x5dbb7c9f, 0x38e9, 0x40d2, 0x97, 0x49, 0x4f, 0x8a, 0x0e, 0x9f, 0x64, 0x0f ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_ACTION_1, 0xD8742DCB, 0x3E6A, 0x4B3C, 0xB3, 0xFE, 0x37, 0x46, 0x23, 0xCD, 0xCF, 0x06 ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_LEVEL_1, 0x8183BA9A, 0xE910, 0x48DA, 0x87, 0x69, 0x14, 0xAE, 0x6D, 0xC1, 0x17, 0x0A ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_FLAGS_1, 0xbcded951, 0x187b, 0x4d05, 0xbc, 0xcc, 0xf7, 0xe5, 0x19, 0x60, 0xc2, 0x58 ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_ACTION_2, 0x421CBA38, 0x1A8E, 0x4881, 0xAC, 0x89, 0xE3, 0x3A, 0x8B, 0x04, 0xEC, 0xE4 ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_LEVEL_2, 0x07A07CA2, 0xADAF, 0x40D7, 0xB0, 0x77, 0x53, 0x3A, 0xAD, 0xED, 0x1B, 0xFA ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_FLAGS_2, 0x7fd2f0c4, 0xfeb7, 0x4da3, 0x81, 0x17, 0xe3, 0xfb, 0xed, 0xc4, 0x65, 0x82 ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_ACTION_3, 0x80472613, 0x9780, 0x455E, 0xB3, 0x08, 0x72, 0xD3, 0x00, 0x3C, 0xF2, 0xF8 ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_LEVEL_3, 0x58AFD5A6, 0xC2DD, 0x47D2, 0x9F, 0xBF, 0xEF, 0x70, 0xCC, 0x5C, 0x59, 0x65 ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_FLAGS_3, 0x73613ccf, 0xdbfa, 0x4279, 0x83, 0x56, 0x49, 0x35, 0xf6, 0xbf, 0x62, 0xf3 ); +DEFINE_GUID(GUID_PROCESSOR_SETTINGS_SUBGROUP, 0x54533251, 0x82BE, 0x4824, 0x96, 0xC1, 0x47, 0xB6, 0x0B, 0x74, 0x0D, 0x00 ); +DEFINE_GUID(GUID_PROCESSOR_THROTTLE_POLICY, 0x57027304, 0x4AF6, 0x4104, 0x92, 0x60, 0xE3, 0xD9, 0x52, 0x48, 0xFC, 0x36 ); +DEFINE_GUID(GUID_PROCESSOR_THROTTLE_MAXIMUM, 0xBC5038F7, 0x23E0, 0x4960, 0x96, 0xDA, 0x33, 0xAB, 0xAF, 0x59, 0x35, 0xEC ); +DEFINE_GUID(GUID_PROCESSOR_THROTTLE_MINIMUM, 0x893DEE8E, 0x2BEF, 0x41E0, 0x89, 0xC6, 0xB5, 0x5D, 0x09, 0x29, 0x96, 0x4C ); +DEFINE_GUID(GUID_PROCESSOR_ALLOW_THROTTLING, 0x3b04d4fd, 0x1cc7, 0x4f23, 0xab, 0x1c, 0xd1, 0x33, 0x78, 0x19, 0xc4, 0xbb ); +DEFINE_GUID(GUID_PROCESSOR_IDLESTATE_POLICY, 0x68f262a7, 0xf621, 0x4069, 0xb9, 0xa5, 0x48, 0x74, 0x16, 0x9b, 0xe2, 0x3c); +DEFINE_GUID(GUID_PROCESSOR_PERFSTATE_POLICY, 0xBBDC3814, 0x18E9, 0x4463, 0x8A, 0x55, 0xD1, 0x97, 0x32, 0x7C, 0x45, 0xC0); +DEFINE_GUID(GUID_PROCESSOR_PERF_INCREASE_THRESHOLD, 0x06cadf0e, 0x64ed, 0x448a, 0x89, 0x27, 0xce, 0x7b, 0xf9, 0x0e, 0xb3, 0x5d ); +DEFINE_GUID(GUID_PROCESSOR_PERF_DECREASE_THRESHOLD, 0x12a0ab44, 0xfe28, 0x4fa9, 0xb3, 0xbd, 0x4b, 0x64, 0xf4, 0x49, 0x60, 0xa6 ); +DEFINE_GUID(GUID_PROCESSOR_PERF_INCREASE_POLICY, 0x465e1f50, 0xb610, 0x473a, 0xab, 0x58, 0x0, 0xd1, 0x7, 0x7d, 0xc4, 0x18); +DEFINE_GUID(GUID_PROCESSOR_PERF_DECREASE_POLICY, 0x40fbefc7, 0x2e9d, 0x4d25, 0xa1, 0x85, 0xc, 0xfd, 0x85, 0x74, 0xba, 0xc6); +DEFINE_GUID(GUID_PROCESSOR_PERF_INCREASE_TIME, 0x984cf492, 0x3bed, 0x4488, 0xa8, 0xf9, 0x42, 0x86, 0xc9, 0x7b, 0xf5, 0xaa); +DEFINE_GUID(GUID_PROCESSOR_PERF_DECREASE_TIME, 0xd8edeb9b, 0x95cf, 0x4f95, 0xa7, 0x3c, 0xb0, 0x61, 0x97, 0x36, 0x93, 0xc8); +DEFINE_GUID(GUID_PROCESSOR_PERF_TIME_CHECK, 0x4d2b0152, 0x7d5c, 0x498b, 0x88, 0xe2, 0x34, 0x34, 0x53, 0x92, 0xa2, 0xc5); +DEFINE_GUID(GUID_PROCESSOR_PERF_BOOST_POLICY, 0x45bcc044, 0xd885, 0x43e2, 0x86, 0x5, 0xee, 0xe, 0xc6, 0xe9, 0x6b, 0x59); +DEFINE_GUID(GUID_PROCESSOR_IDLE_ALLOW_SCALING, 0x6c2993b0, 0x8f48, 0x481f, 0xbc, 0xc6, 0x0, 0xdd, 0x27, 0x42, 0xaa, 0x6); +DEFINE_GUID(GUID_PROCESSOR_IDLE_DISABLE, 0x5d76a2ca, 0xe8c0, 0x402f, 0xa1, 0x33, 0x21, 0x58, 0x49, 0x2d, 0x58, 0xad); +DEFINE_GUID(GUID_PROCESSOR_IDLE_TIME_CHECK, 0xc4581c31, 0x89ab, 0x4597, 0x8e, 0x2b, 0x9c, 0x9c, 0xab, 0x44, 0xe, 0x6b); +DEFINE_GUID(GUID_PROCESSOR_IDLE_DEMOTE_THRESHOLD, 0x4b92d758, 0x5a24, 0x4851, 0xa4, 0x70, 0x81, 0x5d, 0x78, 0xae, 0xe1, 0x19); +DEFINE_GUID(GUID_PROCESSOR_IDLE_PROMOTE_THRESHOLD, 0x7b224883, 0xb3cc, 0x4d79, 0x81, 0x9f, 0x83, 0x74, 0x15, 0x2c, 0xbe, 0x7c); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_INCREASE_THRESHOLD, 0xdf142941, 0x20f3, 0x4edf, 0x9a, 0x4a, 0x9c, 0x83, 0xd3, 0xd7, 0x17, 0xd1 ); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_DECREASE_THRESHOLD, 0x68dd2f27, 0xa4ce, 0x4e11, 0x84, 0x87, 0x37, 0x94, 0xe4, 0x13, 0x5d, 0xfa); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_INCREASE_POLICY, 0xc7be0679, 0x2817, 0x4d69, 0x9d, 0x02, 0x51, 0x9a, 0x53, 0x7e, 0xd0, 0xc6); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_DECREASE_POLICY, 0x71021b41, 0xc749, 0x4d21, 0xbe, 0x74, 0xa0, 0x0f, 0x33, 0x5d, 0x58, 0x2b); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_MAX_CORES, 0xea062031, 0x0e34, 0x4ff1, 0x9b, 0x6d, 0xeb, 0x10, 0x59, 0x33, 0x40, 0x28); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_MIN_CORES, 0x0cc5b647, 0xc1df, 0x4637, 0x89, 0x1a, 0xde, 0xc3, 0x5c, 0x31, 0x85, 0x83); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_INCREASE_TIME, 0x2ddd5a84, 0x5a71, 0x437e, 0x91, 0x2a, 0xdb, 0x0b, 0x8c, 0x78, 0x87, 0x32); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_DECREASE_TIME, 0xdfd10d17, 0xd5eb, 0x45dd, 0x87, 0x7a, 0x9a, 0x34, 0xdd, 0xd1, 0x5c, 0x82); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_AFFINITY_HISTORY_DECREASE_FACTOR, 0x8f7b45e3, 0xc393, 0x480a, 0x87, 0x8c, 0xf6, 0x7a, 0xc3, 0xd0, 0x70, 0x82); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_AFFINITY_HISTORY_THRESHOLD, 0x5b33697b, 0xe89d, 0x4d38, 0xaa, 0x46, 0x9e, 0x7d, 0xfb, 0x7c, 0xd2, 0xf9); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_AFFINITY_WEIGHTING, 0xe70867f1, 0xfa2f, 0x4f4e, 0xae, 0xa1, 0x4d, 0x8a, 0x0b, 0xa2, 0x3b, 0x20); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_HISTORY_DECREASE_FACTOR, 0x1299023c, 0xbc28, 0x4f0a, 0x81, 0xec, 0xd3, 0x29, 0x5a, 0x8d, 0x81, 0x5d); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_HISTORY_THRESHOLD, 0x9ac18e92, 0xaa3c, 0x4e27, 0xb3, 0x07, 0x01, 0xae, 0x37, 0x30, 0x71, 0x29); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_WEIGHTING, 0x8809c2d8, 0xb155, 0x42d4, 0xbc, 0xda, 0x0d, 0x34, 0x56, 0x51, 0xb1, 0xdb); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_THRESHOLD, 0x943c8cb6, 0x6f93, 0x4227, 0xad, 0x87, 0xe9, 0xa3, 0xfe, 0xec, 0x08, 0xd1); +DEFINE_GUID(GUID_PROCESSOR_PARKING_CORE_OVERRIDE, 0xa55612aa, 0xf624, 0x42c6, 0xa4, 0x43, 0x73, 0x97, 0xd0, 0x64, 0xc0, 0x4f); +DEFINE_GUID(GUID_PROCESSOR_PARKING_PERF_STATE, 0x447235c7, 0x6a8d, 0x4cc0, 0x8e, 0x24, 0x9e, 0xaf, 0x70, 0xb9, 0x6e, 0x2b); +DEFINE_GUID(GUID_PROCESSOR_PERF_HISTORY, 0x7d24baa7, 0x0b84, 0x480f, 0x84, 0x0c, 0x1b, 0x07, 0x43, 0xc0, 0x0f, 0x5f); +DEFINE_GUID(GUID_SYSTEM_COOLING_POLICY, 0x94D3A615, 0xA899, 0x4AC5, 0xAE, 0x2B, 0xE4, 0xD8, 0xF6, 0x34, 0x36, 0x7F); +DEFINE_GUID(GUID_LOCK_CONSOLE_ON_WAKE, 0x0E796BDB, 0x100D, 0x47D6, 0xA2, 0xD5, 0xF7, 0xD2, 0xDA, 0xA5, 0x1F, 0x51 ); +DEFINE_GUID(GUID_DEVICE_IDLE_POLICY, 0x4faab71a, 0x92e5, 0x4726, 0xb5, 0x31, 0x22, 0x45, 0x59, 0x67, 0x2d, 0x19 ); +DEFINE_GUID(GUID_ACDC_POWER_SOURCE, 0x5D3E9A59, 0xE9D5, 0x4B00, 0xA6, 0xBD, 0xFF, 0x34, 0xFF, 0x51, 0x65, 0x48 ); +DEFINE_GUID(GUID_LIDSWITCH_STATE_CHANGE, 0xBA3E0F4D, 0xB817, 0x4094, 0xA2, 0xD1, 0xD5, 0x63, 0x79, 0xE6, 0xA0, 0xF3 ); +DEFINE_GUID(GUID_BATTERY_PERCENTAGE_REMAINING, 0xA7AD8041, 0xB45A, 0x4CAE, 0x87, 0xA3, 0xEE, 0xCB, 0xB4, 0x68, 0xA9, 0xE1 ); +DEFINE_GUID(GUID_IDLE_BACKGROUND_TASK, 0x515C31D8, 0xF734, 0x163D, 0xA0, 0xFD, 0x11, 0xA0, 0x8C, 0x91, 0xE8, 0xF1 ); +DEFINE_GUID(GUID_BACKGROUND_TASK_NOTIFICATION, 0xCF23F240, 0x2A54, 0x48D8, 0xB1, 0x14, 0xDE, 0x15, 0x18, 0xFF, 0x05, 0x2E ); +DEFINE_GUID(GUID_APPLAUNCH_BUTTON, 0x1A689231, 0x7399, 0x4E9A, 0x8F, 0x99, 0xB7, 0x1F, 0x99, 0x9D, 0xB3, 0xFA ); +DEFINE_GUID(GUID_PCIEXPRESS_SETTINGS_SUBGROUP, 0x501a4d13, 0x42af,0x4429, 0x9f, 0xd1, 0xa8, 0x21, 0x8c, 0x26, 0x8e, 0x20 ); +DEFINE_GUID(GUID_PCIEXPRESS_ASPM_POLICY, 0xee12f906, 0xd277, 0x404b, 0xb6, 0xda, 0xe5, 0xfa, 0x1a, 0x57, 0x6d, 0xf5 ); +DEFINE_GUID(GUID_ENABLE_SWITCH_FORCED_SHUTDOWN, 0x833a6b62, 0xdfa4, 0x46d1, 0x82, 0xf8, 0xe0, 0x9e, 0x34, 0xd0, 0x29, 0xd6 ); + +#define PERFSTATE_POLICY_CHANGE_IDEAL 0 +#define PERFSTATE_POLICY_CHANGE_SINGLE 1 +#define PERFSTATE_POLICY_CHANGE_ROCKET 2 +#define PERFSTATE_POLICY_CHANGE_MAX PERFSTATE_POLICY_CHANGE_ROCKET + +#define PROCESSOR_PERF_BOOST_POLICY_DISABLED 0 +#define PROCESSOR_PERF_BOOST_POLICY_MAX 100 + +#define POWER_DEVICE_IDLE_POLICY_PERFORMANCE 0 +#define POWER_DEVICE_IDLE_POLICY_CONSERVATIVE 1 + typedef VOID -(DDKAPI *PREQUEST_POWER_COMPLETE)( +(NTAPI REQUEST_POWER_COMPLETE)( IN struct _DEVICE_OBJECT *DeviceObject, IN UCHAR MinorFunction, IN POWER_STATE PowerState, IN PVOID Context, IN struct _IO_STATUS_BLOCK *IoStatus); +typedef REQUEST_POWER_COMPLETE *PREQUEST_POWER_COMPLETE; typedef NTSTATUS -(DDKAPI POWER_SETTING_CALLBACK)( +(NTAPI POWER_SETTING_CALLBACK)( IN LPCGUID SettingGuid, IN PVOID Value, IN ULONG ValueLength, IN OUT PVOID Context OPTIONAL); - typedef POWER_SETTING_CALLBACK *PPOWER_SETTING_CALLBACK; -#define PO_CB_SYSTEM_POWER_POLICY 0 -#define PO_CB_AC_STATUS 1 -#define PO_CB_BUTTON_COLLISION 2 -#define PO_CB_SYSTEM_STATE_LOCK 3 -#define PO_CB_LID_SWITCH_STATE 4 -#define PO_CB_PROCESSOR_POWER_POLICY 5 /****************************************************************************** * Configuration Manager Types * @@ -1943,11 +2699,11 @@ typedef int CM_RESOURCE_TYPE; #define CmResourceTypeDma 4 #define CmResourceTypeDeviceSpecific 5 #define CmResourceTypeBusNumber 6 -#define CmResourceTypeNonArbitrated 128 -#define CmResourceTypeConfigData 128 -#define CmResourceTypeDevicePrivate 129 -#define CmResourceTypePcCardConfig 130 -#define CmResourceTypeMfCardConfig 131 +#define CmResourceTypeNonArbitrated 128 +#define CmResourceTypeConfigData 128 +#define CmResourceTypeDevicePrivate 129 +#define CmResourceTypePcCardConfig 130 +#define CmResourceTypeMfCardConfig 131 /* KEY_VALUE_Xxx.Type */ #define REG_NONE 0 @@ -1961,9 +2717,9 @@ typedef int CM_RESOURCE_TYPE; #define REG_MULTI_SZ 7 #define REG_RESOURCE_LIST 8 #define REG_FULL_RESOURCE_DESCRIPTOR 9 -#define REG_RESOURCE_REQUIREMENTS_LIST 10 -#define REG_QWORD 11 -#define REG_QWORD_LITTLE_ENDIAN 11 +#define REG_RESOURCE_REQUIREMENTS_LIST 10 +#define REG_QWORD 11 +#define REG_QWORD_LITTLE_ENDIAN 11 /* Registry Access Rights */ #define KEY_QUERY_VALUE (0x0001) @@ -2019,6 +2775,15 @@ typedef int CM_RESOURCE_TYPE; REG_OPTION_BACKUP_RESTORE |\ REG_OPTION_OPEN_LINK) +#define REG_OPEN_LEGAL_OPTION \ + (REG_OPTION_RESERVED |\ + REG_OPTION_BACKUP_RESTORE |\ + REG_OPTION_OPEN_LINK) + +#define REG_STANDARD_FORMAT 1 +#define REG_LATEST_FORMAT 2 +#define REG_NO_COMPRESSION 4 + /* Key creation/open disposition */ #define REG_CREATED_NEW_KEY (0x00000001L) #define REG_OPENED_EXISTING_KEY (0x00000002L) @@ -2034,6 +2799,7 @@ typedef int CM_RESOURCE_TYPE; #define REG_HIVE_EXACT_FILE_GROWTH (0x00000080L) #define REG_HIVE_NO_RM (0x00000100L) #define REG_HIVE_SINGLE_LOG (0x00000200L) +#define REG_BOOT_HIVE (0x00000400L) /* Unload Flags */ #define REG_FORCE_UNLOAD 1 @@ -2050,27 +2816,6 @@ typedef int CM_RESOURCE_TYPE; REG_NOTIFY_CHANGE_LAST_SET |\ REG_NOTIFY_CHANGE_SECURITY) -typedef struct _CM_FLOPPY_DEVICE_DATA { - USHORT Version; - USHORT Revision; - CHAR Size[8]; - ULONG MaxDensity; - ULONG MountDensity; - UCHAR StepRateHeadUnloadTime; - UCHAR HeadLoadTime; - UCHAR MotorOffTime; - UCHAR SectorLengthCode; - UCHAR SectorPerTrack; - UCHAR ReadWriteGapLength; - UCHAR DataTransferLength; - UCHAR FormatGapLength; - UCHAR FormatFillCharacter; - UCHAR HeadSettleTime; - UCHAR MotorSettleTime; - UCHAR MaximumTrackValue; - UCHAR DataTransferRate; -} CM_FLOPPY_DEVICE_DATA, *PCM_FLOPPY_DEVICE_DATA; - #include typedef struct _CM_PARTIAL_RESOURCE_DESCRIPTOR { UCHAR Type; @@ -2170,15 +2915,15 @@ typedef struct _CM_PARTIAL_RESOURCE_DESCRIPTOR { #define CmResourceTypeDeviceSpecific 5 #define CmResourceTypeBusNumber 6 #define CmResourceTypeMemoryLarge 7 -#define CmResourceTypeNonArbitrated 128 -#define CmResourceTypeConfigData 128 -#define CmResourceTypeDevicePrivate 129 -#define CmResourceTypePcCardConfig 130 -#define CmResourceTypeMfCardConfig 131 +#define CmResourceTypeNonArbitrated 128 +#define CmResourceTypeConfigData 128 +#define CmResourceTypeDevicePrivate 129 +#define CmResourceTypePcCardConfig 130 +#define CmResourceTypeMfCardConfig 131 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.ShareDisposition */ typedef enum _CM_SHARE_DISPOSITION { - CmResourceShareUndetermined, + CmResourceShareUndetermined = 0, CmResourceShareDeviceExclusive, CmResourceShareDriverExclusive, CmResourceShareShared @@ -2201,6 +2946,10 @@ typedef enum _CM_SHARE_DISPOSITION { #define CM_RESOURCE_INTERRUPT_MESSAGE 0x0002 #define CM_RESOURCE_INTERRUPT_POLICY_INCLUDED 0x0004 +#define CM_RESOURCE_INTERRUPT_LEVEL_LATCHED_BITS 0x0001 + +#define CM_RESOURCE_INTERRUPT_MESSAGE_TOKEN ((ULONG)-2) + /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypeMemory */ #define CM_RESOURCE_MEMORY_READ_WRITE 0x0000 #define CM_RESOURCE_MEMORY_READ_ONLY 0x0001 @@ -2214,6 +2963,15 @@ typedef enum _CM_SHARE_DISPOSITION { #define CM_RESOURCE_MEMORY_BAR 0x0080 #define CM_RESOURCE_MEMORY_COMPAT_FOR_INACCESSIBLE_RANGE 0x0100 +#define CM_RESOURCE_MEMORY_LARGE 0x0E00 +#define CM_RESOURCE_MEMORY_LARGE_40 0x0200 +#define CM_RESOURCE_MEMORY_LARGE_48 0x0400 +#define CM_RESOURCE_MEMORY_LARGE_64 0x0800 + +#define CM_RESOURCE_MEMORY_LARGE_40_MAXLEN 0x000000FFFFFFFF00 +#define CM_RESOURCE_MEMORY_LARGE_48_MAXLEN 0x0000FFFFFFFF0000 +#define CM_RESOURCE_MEMORY_LARGE_64_MAXLEN 0xFFFFFFFF00000000 + /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypeDma */ #define CM_RESOURCE_DMA_8 0x0000 #define CM_RESOURCE_DMA_16 0x0001 @@ -2224,33 +2982,92 @@ typedef enum _CM_SHARE_DISPOSITION { #define CM_RESOURCE_DMA_TYPE_B 0x0020 #define CM_RESOURCE_DMA_TYPE_F 0x0040 +typedef struct _DEVICE_FLAGS { + ULONG Failed:1; + ULONG ReadOnly:1; + ULONG Removable:1; + ULONG ConsoleIn:1; + ULONG ConsoleOut:1; + ULONG Input:1; + ULONG Output:1; +} DEVICE_FLAGS, *PDEVICE_FLAGS; + +typedef enum _INTERFACE_TYPE { + InterfaceTypeUndefined = -1, + Internal, + Isa, + Eisa, + MicroChannel, + TurboChannel, + PCIBus, + VMEBus, + NuBus, + PCMCIABus, + CBus, + MPIBus, + MPSABus, + ProcessorInternal, + InternalPowerBus, + PNPISABus, + PNPBus, + Vmcs, + MaximumInterfaceType +} INTERFACE_TYPE, *PINTERFACE_TYPE; + +typedef struct _CM_COMPONENT_INFORMATION { + DEVICE_FLAGS Flags; + ULONG Version; + ULONG Key; + KAFFINITY AffinityMask; +} CM_COMPONENT_INFORMATION, *PCM_COMPONENT_INFORMATION; + +typedef struct _CM_ROM_BLOCK { + ULONG Address; + ULONG Size; +} CM_ROM_BLOCK, *PCM_ROM_BLOCK; + typedef struct _CM_PARTIAL_RESOURCE_LIST { - USHORT Version; - USHORT Revision; - ULONG Count; + USHORT Version; + USHORT Revision; + ULONG Count; CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1]; } CM_PARTIAL_RESOURCE_LIST, *PCM_PARTIAL_RESOURCE_LIST; typedef struct _CM_FULL_RESOURCE_DESCRIPTOR { - INTERFACE_TYPE InterfaceType; - ULONG BusNumber; - CM_PARTIAL_RESOURCE_LIST PartialResourceList; + INTERFACE_TYPE InterfaceType; + ULONG BusNumber; + CM_PARTIAL_RESOURCE_LIST PartialResourceList; } CM_FULL_RESOURCE_DESCRIPTOR, *PCM_FULL_RESOURCE_DESCRIPTOR; typedef struct _CM_RESOURCE_LIST { - ULONG Count; - CM_FULL_RESOURCE_DESCRIPTOR List[1]; + ULONG Count; + CM_FULL_RESOURCE_DESCRIPTOR List[1]; } CM_RESOURCE_LIST, *PCM_RESOURCE_LIST; +typedef struct _PNP_BUS_INFORMATION { + GUID BusTypeGuid; + INTERFACE_TYPE LegacyBusType; + ULONG BusNumber; +} PNP_BUS_INFORMATION, *PPNP_BUS_INFORMATION; + #include + typedef struct _CM_INT13_DRIVE_PARAMETER { - USHORT DriveSelect; - ULONG MaxCylinders; - USHORT SectorsPerTrack; - USHORT MaxHeads; - USHORT NumberDrives; + USHORT DriveSelect; + ULONG MaxCylinders; + USHORT SectorsPerTrack; + USHORT MaxHeads; + USHORT NumberDrives; } CM_INT13_DRIVE_PARAMETER, *PCM_INT13_DRIVE_PARAMETER; +typedef struct _CM_MCA_POS_DATA { + USHORT AdapterId; + UCHAR PosData1; + UCHAR PosData2; + UCHAR PosData3; + UCHAR PosData4; +} CM_MCA_POS_DATA, *PCM_MCA_POS_DATA; + typedef struct _CM_PNP_BIOS_DEVICE_NODE { USHORT Size; UCHAR Node; @@ -2274,154 +3091,150 @@ typedef struct _CM_PNP_BIOS_INSTALLATION_CHECK { USHORT RealModeDataBaseAddress; ULONG ProtectedModeDataBaseAddress; } CM_PNP_BIOS_INSTALLATION_CHECK, *PCM_PNP_BIOS_INSTALLATION_CHECK; + #include typedef struct _CM_DISK_GEOMETRY_DEVICE_DATA { - ULONG BytesPerSector; - ULONG NumberOfCylinders; - ULONG SectorsPerTrack; - ULONG NumberOfHeads; + ULONG BytesPerSector; + ULONG NumberOfCylinders; + ULONG SectorsPerTrack; + ULONG NumberOfHeads; } CM_DISK_GEOMETRY_DEVICE_DATA, *PCM_DISK_GEOMETRY_DEVICE_DATA; typedef struct _CM_KEYBOARD_DEVICE_DATA { - USHORT Version; - USHORT Revision; - UCHAR Type; - UCHAR Subtype; - USHORT KeyboardFlags; + USHORT Version; + USHORT Revision; + UCHAR Type; + UCHAR Subtype; + USHORT KeyboardFlags; } CM_KEYBOARD_DEVICE_DATA, *PCM_KEYBOARD_DEVICE_DATA; -typedef struct _CM_MCA_POS_DATA { - USHORT AdapterId; - UCHAR PosData1; - UCHAR PosData2; - UCHAR PosData3; - UCHAR PosData4; -} CM_MCA_POS_DATA, *PCM_MCA_POS_DATA; - -#if (NTDDI_VERSION >= NTDDI_WINXP) -typedef struct CM_Power_Data_s { - ULONG PD_Size; - DEVICE_POWER_STATE PD_MostRecentPowerState; - ULONG PD_Capabilities; - ULONG PD_D1Latency; - ULONG PD_D2Latency; - ULONG PD_D3Latency; - DEVICE_POWER_STATE PD_PowerStateMapping[PowerSystemMaximum]; - SYSTEM_POWER_STATE PD_DeepestSystemWake; -} CM_POWER_DATA, *PCM_POWER_DATA; - -#define PDCAP_D0_SUPPORTED 0x00000001 -#define PDCAP_D1_SUPPORTED 0x00000002 -#define PDCAP_D2_SUPPORTED 0x00000004 -#define PDCAP_D3_SUPPORTED 0x00000008 -#define PDCAP_WAKE_FROM_D0_SUPPORTED 0x00000010 -#define PDCAP_WAKE_FROM_D1_SUPPORTED 0x00000020 -#define PDCAP_WAKE_FROM_D2_SUPPORTED 0x00000040 -#define PDCAP_WAKE_FROM_D3_SUPPORTED 0x00000080 -#define PDCAP_WARM_EJECT_SUPPORTED 0x00000100 - -#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ - typedef struct _CM_SCSI_DEVICE_DATA { - USHORT Version; - USHORT Revision; - UCHAR HostIdentifier; + USHORT Version; + USHORT Revision; + UCHAR HostIdentifier; } CM_SCSI_DEVICE_DATA, *PCM_SCSI_DEVICE_DATA; +typedef struct _CM_VIDEO_DEVICE_DATA { + USHORT Version; + USHORT Revision; + ULONG VideoClock; +} CM_VIDEO_DEVICE_DATA, *PCM_VIDEO_DEVICE_DATA; + +typedef struct _CM_SONIC_DEVICE_DATA { + USHORT Version; + USHORT Revision; + USHORT DataConfigurationRegister; + UCHAR EthernetAddress[8]; +} CM_SONIC_DEVICE_DATA, *PCM_SONIC_DEVICE_DATA; + typedef struct _CM_SERIAL_DEVICE_DATA { - USHORT Version; - USHORT Revision; - ULONG BaudClock; + USHORT Version; + USHORT Revision; + ULONG BaudClock; } CM_SERIAL_DEVICE_DATA, *PCM_SERIAL_DEVICE_DATA; +typedef struct _CM_MONITOR_DEVICE_DATA { + USHORT Version; + USHORT Revision; + USHORT HorizontalScreenSize; + USHORT VerticalScreenSize; + USHORT HorizontalResolution; + USHORT VerticalResolution; + USHORT HorizontalDisplayTimeLow; + USHORT HorizontalDisplayTime; + USHORT HorizontalDisplayTimeHigh; + USHORT HorizontalBackPorchLow; + USHORT HorizontalBackPorch; + USHORT HorizontalBackPorchHigh; + USHORT HorizontalFrontPorchLow; + USHORT HorizontalFrontPorch; + USHORT HorizontalFrontPorchHigh; + USHORT HorizontalSyncLow; + USHORT HorizontalSync; + USHORT HorizontalSyncHigh; + USHORT VerticalBackPorchLow; + USHORT VerticalBackPorch; + USHORT VerticalBackPorchHigh; + USHORT VerticalFrontPorchLow; + USHORT VerticalFrontPorch; + USHORT VerticalFrontPorchHigh; + USHORT VerticalSyncLow; + USHORT VerticalSync; + USHORT VerticalSyncHigh; +} CM_MONITOR_DEVICE_DATA, *PCM_MONITOR_DEVICE_DATA; + +typedef struct _CM_FLOPPY_DEVICE_DATA { + USHORT Version; + USHORT Revision; + CHAR Size[8]; + ULONG MaxDensity; + ULONG MountDensity; + UCHAR StepRateHeadUnloadTime; + UCHAR HeadLoadTime; + UCHAR MotorOffTime; + UCHAR SectorLengthCode; + UCHAR SectorPerTrack; + UCHAR ReadWriteGapLength; + UCHAR DataTransferLength; + UCHAR FormatGapLength; + UCHAR FormatFillCharacter; + UCHAR HeadSettleTime; + UCHAR MotorSettleTime; + UCHAR MaximumTrackValue; + UCHAR DataTransferRate; +} CM_FLOPPY_DEVICE_DATA, *PCM_FLOPPY_DEVICE_DATA; + typedef enum _KEY_INFORMATION_CLASS { KeyBasicInformation, KeyNodeInformation, KeyFullInformation, KeyNameInformation, KeyCachedInformation, - KeyFlagsInformation + KeyFlagsInformation, + KeyVirtualizationInformation, + KeyHandleTagsInformation, + MaxKeyInfoClass } KEY_INFORMATION_CLASS; typedef struct _KEY_BASIC_INFORMATION { - LARGE_INTEGER LastWriteTime; - ULONG TitleIndex; - ULONG NameLength; - WCHAR Name[1]; + LARGE_INTEGER LastWriteTime; + ULONG TitleIndex; + ULONG NameLength; + WCHAR Name[1]; } KEY_BASIC_INFORMATION, *PKEY_BASIC_INFORMATION; +typedef struct _KEY_CONTROL_FLAGS_INFORMATION { + ULONG ControlFlags; +} KEY_CONTROL_FLAGS_INFORMATION, *PKEY_CONTROL_FLAGS_INFORMATION; + typedef struct _KEY_FULL_INFORMATION { - LARGE_INTEGER LastWriteTime; - ULONG TitleIndex; - ULONG ClassOffset; - ULONG ClassLength; - ULONG SubKeys; - ULONG MaxNameLen; - ULONG MaxClassLen; - ULONG Values; - ULONG MaxValueNameLen; - ULONG MaxValueDataLen; - WCHAR Class[1]; + LARGE_INTEGER LastWriteTime; + ULONG TitleIndex; + ULONG ClassOffset; + ULONG ClassLength; + ULONG SubKeys; + ULONG MaxNameLen; + ULONG MaxClassLen; + ULONG Values; + ULONG MaxValueNameLen; + ULONG MaxValueDataLen; + WCHAR Class[1]; } KEY_FULL_INFORMATION, *PKEY_FULL_INFORMATION; +typedef struct _KEY_HANDLE_TAGS_INFORMATION { + ULONG HandleTags; +} KEY_HANDLE_TAGS_INFORMATION, *PKEY_HANDLE_TAGS_INFORMATION; + typedef struct _KEY_NODE_INFORMATION { - LARGE_INTEGER LastWriteTime; - ULONG TitleIndex; - ULONG ClassOffset; - ULONG ClassLength; - ULONG NameLength; - WCHAR Name[1]; + LARGE_INTEGER LastWriteTime; + ULONG TitleIndex; + ULONG ClassOffset; + ULONG ClassLength; + ULONG NameLength; + WCHAR Name[1]; } KEY_NODE_INFORMATION, *PKEY_NODE_INFORMATION; -typedef struct _KEY_VALUE_BASIC_INFORMATION { - ULONG TitleIndex; - ULONG Type; - ULONG NameLength; - WCHAR Name[1]; -} KEY_VALUE_BASIC_INFORMATION, *PKEY_VALUE_BASIC_INFORMATION; - -typedef struct _KEY_VALUE_FULL_INFORMATION { - ULONG TitleIndex; - ULONG Type; - ULONG DataOffset; - ULONG DataLength; - ULONG NameLength; - WCHAR Name[1]; -} KEY_VALUE_FULL_INFORMATION, *PKEY_VALUE_FULL_INFORMATION; - -typedef struct _KEY_VALUE_PARTIAL_INFORMATION { - ULONG TitleIndex; - ULONG Type; - ULONG DataLength; - UCHAR Data[1]; -} KEY_VALUE_PARTIAL_INFORMATION, *PKEY_VALUE_PARTIAL_INFORMATION; - -typedef struct _KEY_VALUE_PARTIAL_INFORMATION_ALIGN64 { - ULONG Type; - ULONG DataLength; - UCHAR Data[1]; -} KEY_VALUE_PARTIAL_INFORMATION_ALIGN64, *PKEY_VALUE_PARTIAL_INFORMATION_ALIGN64; - -typedef struct _KEY_VALUE_ENTRY { - PUNICODE_STRING ValueName; - ULONG DataLength; - ULONG DataOffset; - ULONG Type; -} KEY_VALUE_ENTRY, *PKEY_VALUE_ENTRY; - -typedef enum _KEY_VALUE_INFORMATION_CLASS { - KeyValueBasicInformation, - KeyValueFullInformation, - KeyValuePartialInformation, - KeyValueFullInformationAlign64, - KeyValuePartialInformationAlign64 -} KEY_VALUE_INFORMATION_CLASS; - -typedef struct _KEY_WRITE_TIME_INFORMATION { - LARGE_INTEGER LastWriteTime; -} KEY_WRITE_TIME_INFORMATION, *PKEY_WRITE_TIME_INFORMATION; - typedef enum _KEY_SET_INFORMATION_CLASS { KeyWriteTimeInformation, KeyWow64FlagsInformation, @@ -2432,6 +3245,65 @@ typedef enum _KEY_SET_INFORMATION_CLASS { MaxKeySetInfoClass } KEY_SET_INFORMATION_CLASS; +typedef struct _KEY_SET_VIRTUALIZATION_INFORMATION { + ULONG VirtualTarget:1; + ULONG VirtualStore:1; + ULONG VirtualSource:1; + ULONG Reserved:29; +} KEY_SET_VIRTUALIZATION_INFORMATION, *PKEY_SET_VIRTUALIZATION_INFORMATION; + +typedef struct _KEY_VALUE_BASIC_INFORMATION { + ULONG TitleIndex; + ULONG Type; + ULONG NameLength; + WCHAR Name[1]; +} KEY_VALUE_BASIC_INFORMATION, *PKEY_VALUE_BASIC_INFORMATION; + +typedef struct _KEY_VALUE_FULL_INFORMATION { + ULONG TitleIndex; + ULONG Type; + ULONG DataOffset; + ULONG DataLength; + ULONG NameLength; + WCHAR Name[1]; +} KEY_VALUE_FULL_INFORMATION, *PKEY_VALUE_FULL_INFORMATION; + +typedef struct _KEY_VALUE_PARTIAL_INFORMATION { + ULONG TitleIndex; + ULONG Type; + ULONG DataLength; + UCHAR Data[1]; +} KEY_VALUE_PARTIAL_INFORMATION, *PKEY_VALUE_PARTIAL_INFORMATION; + +typedef struct _KEY_VALUE_PARTIAL_INFORMATION_ALIGN64 { + ULONG Type; + ULONG DataLength; + UCHAR Data[1]; +} KEY_VALUE_PARTIAL_INFORMATION_ALIGN64, *PKEY_VALUE_PARTIAL_INFORMATION_ALIGN64; + +typedef struct _KEY_VALUE_ENTRY { + PUNICODE_STRING ValueName; + ULONG DataLength; + ULONG DataOffset; + ULONG Type; +} KEY_VALUE_ENTRY, *PKEY_VALUE_ENTRY; + +typedef enum _KEY_VALUE_INFORMATION_CLASS { + KeyValueBasicInformation, + KeyValueFullInformation, + KeyValuePartialInformation, + KeyValueFullInformationAlign64, + KeyValuePartialInformationAlign64 +} KEY_VALUE_INFORMATION_CLASS; + +typedef struct _KEY_WOW64_FLAGS_INFORMATION { + ULONG UserFlags; +} KEY_WOW64_FLAGS_INFORMATION, *PKEY_WOW64_FLAGS_INFORMATION; + +typedef struct _KEY_WRITE_TIME_INFORMATION { + LARGE_INTEGER LastWriteTime; +} KEY_WRITE_TIME_INFORMATION, *PKEY_WRITE_TIME_INFORMATION; + typedef enum _REG_NOTIFY_CLASS { RegNtDeleteKey, RegNtPreDeleteKey = RegNtDeleteKey, @@ -2495,11 +3367,11 @@ typedef enum _REG_NOTIFY_CLASS { } REG_NOTIFY_CLASS, *PREG_NOTIFY_CLASS; typedef NTSTATUS -(NTAPI *PEX_CALLBACK_FUNCTION)( - IN PVOID CallbackContext, - IN PVOID Argument1, - IN PVOID Argument2 -); +(NTAPI EX_CALLBACK_FUNCTION)( + IN PVOID CallbackContext, + IN PVOID Argument1, + IN PVOID Argument2); +typedef EX_CALLBACK_FUNCTION *PEX_CALLBACK_FUNCTION; typedef struct _REG_DELETE_KEY_INFORMATION { PVOID Object; @@ -2601,6 +3473,54 @@ typedef struct _REG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION { PVOID Reserved; } REG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION, *PREG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION; +typedef struct _REG_RENAME_KEY_INFORMATION { + PVOID Object; + PUNICODE_STRING NewName; + PVOID CallContext; + PVOID ObjectContext; + PVOID Reserved; +} REG_RENAME_KEY_INFORMATION, *PREG_RENAME_KEY_INFORMATION; + +typedef struct _REG_CREATE_KEY_INFORMATION { + PUNICODE_STRING CompleteName; + PVOID RootObject; + PVOID ObjectType; + ULONG CreateOptions; + PUNICODE_STRING Class; + PVOID SecurityDescriptor; + PVOID SecurityQualityOfService; + ACCESS_MASK DesiredAccess; + ACCESS_MASK GrantedAccess; + PULONG Disposition; + PVOID *ResultObject; + PVOID CallContext; + PVOID RootObjectContext; + PVOID Transaction; + PVOID Reserved; +} REG_CREATE_KEY_INFORMATION, REG_OPEN_KEY_INFORMATION,*PREG_CREATE_KEY_INFORMATION, *PREG_OPEN_KEY_INFORMATION; + +typedef struct _REG_CREATE_KEY_INFORMATION_V1 { + PUNICODE_STRING CompleteName; + PVOID RootObject; + PVOID ObjectType; + ULONG Options; + PUNICODE_STRING Class; + PVOID SecurityDescriptor; + PVOID SecurityQualityOfService; + ACCESS_MASK DesiredAccess; + ACCESS_MASK GrantedAccess; + PULONG Disposition; + PVOID *ResultObject; + PVOID CallContext; + PVOID RootObjectContext; + PVOID Transaction; + ULONG_PTR Version; + PUNICODE_STRING RemainingName; + ULONG Wow64Flags; + ULONG Attributes; + KPROCESSOR_MODE CheckAccessMode; +} REG_CREATE_KEY_INFORMATION_V1, REG_OPEN_KEY_INFORMATION_V1,*PREG_CREATE_KEY_INFORMATION_V1, *PREG_OPEN_KEY_INFORMATION_V1; + typedef struct _REG_PRE_CREATE_KEY_INFORMATION { PUNICODE_STRING CompleteName; } REG_PRE_CREATE_KEY_INFORMATION, REG_PRE_OPEN_KEY_INFORMATION,*PREG_PRE_CREATE_KEY_INFORMATION, *PREG_PRE_OPEN_KEY_INFORMATION;; @@ -2628,151 +3548,180 @@ typedef struct _REG_KEY_HANDLE_CLOSE_INFORMATION { PVOID Reserved; } REG_KEY_HANDLE_CLOSE_INFORMATION, *PREG_KEY_HANDLE_CLOSE_INFORMATION; +#if (NTDDI_VERSION >= NTDDI_VISTA) + +typedef struct _REG_LOAD_KEY_INFORMATION { + PVOID Object; + PUNICODE_STRING KeyName; + PUNICODE_STRING SourceFile; + ULONG Flags; + PVOID TrustClassObject; + PVOID UserEvent; + ACCESS_MASK DesiredAccess; + PHANDLE RootHandle; + PVOID CallContext; + PVOID ObjectContext; + PVOID Reserved; +} REG_LOAD_KEY_INFORMATION, *PREG_LOAD_KEY_INFORMATION; + +typedef struct _REG_UNLOAD_KEY_INFORMATION { + PVOID Object; + PVOID UserEvent; + PVOID CallContext; + PVOID ObjectContext; + PVOID Reserved; +} REG_UNLOAD_KEY_INFORMATION, *PREG_UNLOAD_KEY_INFORMATION; + +typedef struct _REG_CALLBACK_CONTEXT_CLEANUP_INFORMATION { + PVOID Object; + PVOID ObjectContext; + PVOID Reserved; +} REG_CALLBACK_CONTEXT_CLEANUP_INFORMATION, *PREG_CALLBACK_CONTEXT_CLEANUP_INFORMATION; + +typedef struct _REG_QUERY_KEY_SECURITY_INFORMATION { + PVOID Object; + PSECURITY_INFORMATION SecurityInformation; + PSECURITY_DESCRIPTOR SecurityDescriptor; + PULONG Length; + PVOID CallContext; + PVOID ObjectContext; + PVOID Reserved; +} REG_QUERY_KEY_SECURITY_INFORMATION, *PREG_QUERY_KEY_SECURITY_INFORMATION; + +typedef struct _REG_SET_KEY_SECURITY_INFORMATION { + PVOID Object; + PSECURITY_INFORMATION SecurityInformation; + PSECURITY_DESCRIPTOR SecurityDescriptor; + PVOID CallContext; + PVOID ObjectContext; + PVOID Reserved; +} REG_SET_KEY_SECURITY_INFORMATION, *PREG_SET_KEY_SECURITY_INFORMATION; + +typedef struct _REG_RESTORE_KEY_INFORMATION { + PVOID Object; + HANDLE FileHandle; + ULONG Flags; + PVOID CallContext; + PVOID ObjectContext; + PVOID Reserved; +} REG_RESTORE_KEY_INFORMATION, *PREG_RESTORE_KEY_INFORMATION; + +typedef struct _REG_SAVE_KEY_INFORMATION { + PVOID Object; + HANDLE FileHandle; + ULONG Format; + PVOID CallContext; + PVOID ObjectContext; + PVOID Reserved; +} REG_SAVE_KEY_INFORMATION, *PREG_SAVE_KEY_INFORMATION; + +typedef struct _REG_REPLACE_KEY_INFORMATION { + PVOID Object; + PUNICODE_STRING OldFileName; + PUNICODE_STRING NewFileName; + PVOID CallContext; + PVOID ObjectContext; + PVOID Reserved; +} REG_REPLACE_KEY_INFORMATION, *PREG_REPLACE_KEY_INFORMATION; + +#endif /* NTDDI_VERSION >= NTDDI_VISTA */ + +#define SERVICE_KERNEL_DRIVER 0x00000001 +#define SERVICE_FILE_SYSTEM_DRIVER 0x00000002 +#define SERVICE_ADAPTER 0x00000004 +#define SERVICE_RECOGNIZER_DRIVER 0x00000008 + +#define SERVICE_DRIVER (SERVICE_KERNEL_DRIVER | \ + SERVICE_FILE_SYSTEM_DRIVER | \ + SERVICE_RECOGNIZER_DRIVER) + +#define SERVICE_WIN32_OWN_PROCESS 0x00000010 +#define SERVICE_WIN32_SHARE_PROCESS 0x00000020 +#define SERVICE_WIN32 (SERVICE_WIN32_OWN_PROCESS | \ + SERVICE_WIN32_SHARE_PROCESS) + +#define SERVICE_INTERACTIVE_PROCESS 0x00000100 + +#define SERVICE_TYPE_ALL (SERVICE_WIN32 | \ + SERVICE_ADAPTER | \ + SERVICE_DRIVER | \ + SERVICE_INTERACTIVE_PROCESS) + +/* Service Start Types */ +#define SERVICE_BOOT_START 0x00000000 +#define SERVICE_SYSTEM_START 0x00000001 +#define SERVICE_AUTO_START 0x00000002 +#define SERVICE_DEMAND_START 0x00000003 +#define SERVICE_DISABLED 0x00000004 + +#define SERVICE_ERROR_IGNORE 0x00000000 +#define SERVICE_ERROR_NORMAL 0x00000001 +#define SERVICE_ERROR_SEVERE 0x00000002 +#define SERVICE_ERROR_CRITICAL 0x00000003 + +typedef enum _CM_SERVICE_NODE_TYPE { + DriverType = SERVICE_KERNEL_DRIVER, + FileSystemType = SERVICE_FILE_SYSTEM_DRIVER, + Win32ServiceOwnProcess = SERVICE_WIN32_OWN_PROCESS, + Win32ServiceShareProcess = SERVICE_WIN32_SHARE_PROCESS, + AdapterType = SERVICE_ADAPTER, + RecognizerType = SERVICE_RECOGNIZER_DRIVER +} SERVICE_NODE_TYPE; + +typedef enum _CM_SERVICE_LOAD_TYPE { + BootLoad = SERVICE_BOOT_START, + SystemLoad = SERVICE_SYSTEM_START, + AutoLoad = SERVICE_AUTO_START, + DemandLoad = SERVICE_DEMAND_START, + DisableLoad = SERVICE_DISABLED +} SERVICE_LOAD_TYPE; + +typedef enum _CM_ERROR_CONTROL_TYPE { + IgnoreError = SERVICE_ERROR_IGNORE, + NormalError = SERVICE_ERROR_NORMAL, + SevereError = SERVICE_ERROR_SEVERE, + CriticalError = SERVICE_ERROR_CRITICAL +} SERVICE_ERROR_TYPE; + +#define CM_SERVICE_NETWORK_BOOT_LOAD 0x00000001 +#define CM_SERVICE_VIRTUAL_DISK_BOOT_LOAD 0x00000002 +#define CM_SERVICE_USB_DISK_BOOT_LOAD 0x00000004 + +#define CM_SERVICE_VALID_PROMOTION_MASK (CM_SERVICE_NETWORK_BOOT_LOAD | \ + CM_SERVICE_VIRTUAL_DISK_BOOT_LOAD | \ + CM_SERVICE_USB_DISK_BOOT_LOAD) + /****************************************************************************** * I/O Manager Types * ******************************************************************************/ - /* PCI_COMMON_CONFIG.Command */ -#define PCI_ENABLE_IO_SPACE 0x0001 -#define PCI_ENABLE_MEMORY_SPACE 0x0002 -#define PCI_ENABLE_BUS_MASTER 0x0004 -#define PCI_ENABLE_SPECIAL_CYCLES 0x0008 -#define PCI_ENABLE_WRITE_AND_INVALIDATE 0x0010 -#define PCI_ENABLE_VGA_COMPATIBLE_PALETTE 0x0020 -#define PCI_ENABLE_PARITY 0x0040 -#define PCI_ENABLE_WAIT_CYCLE 0x0080 -#define PCI_ENABLE_SERR 0x0100 -#define PCI_ENABLE_FAST_BACK_TO_BACK 0x0200 -#define PCI_DISABLE_LEVEL_INTERRUPT 0x0400 +#define WDM_MAJORVERSION 0x06 +#define WDM_MINORVERSION 0x00 -/* PCI_COMMON_CONFIG.Status */ -#define PCI_STATUS_INTERRUPT_PENDING 0x0008 -#define PCI_STATUS_CAPABILITIES_LIST 0x0010 -#define PCI_STATUS_66MHZ_CAPABLE 0x0020 -#define PCI_STATUS_UDF_SUPPORTED 0x0040 -#define PCI_STATUS_FAST_BACK_TO_BACK 0x0080 -#define PCI_STATUS_DATA_PARITY_DETECTED 0x0100 -#define PCI_STATUS_DEVSEL 0x0600 -#define PCI_STATUS_SIGNALED_TARGET_ABORT 0x0800 -#define PCI_STATUS_RECEIVED_TARGET_ABORT 0x1000 -#define PCI_STATUS_RECEIVED_MASTER_ABORT 0x2000 -#define PCI_STATUS_SIGNALED_SYSTEM_ERROR 0x4000 -#define PCI_STATUS_DETECTED_PARITY_ERROR 0x8000 +#if defined(_WIN64) -/* PCI_COMMON_CONFIG.HeaderType */ -#define PCI_MULTIFUNCTION 0x80 -#define PCI_DEVICE_TYPE 0x00 -#define PCI_BRIDGE_TYPE 0x01 -#define PCI_CARDBUS_BRIDGE_TYPE 0x02 +#ifndef USE_DMA_MACROS +#define USE_DMA_MACROS +#endif -#define PCI_CONFIGURATION_TYPE(PciData) \ - (((PPCI_COMMON_CONFIG) (PciData))->HeaderType & ~PCI_MULTIFUNCTION) +#ifndef NO_LEGACY_DRIVERS +#define NO_LEGACY_DRIVERS +#endif -#define PCI_MULTIFUNCTION_DEVICE(PciData) \ - ((((PPCI_COMMON_CONFIG) (PciData))->HeaderType & PCI_MULTIFUNCTION) != 0) +#endif /* defined(_WIN64) */ -/* PCI device classes */ -#define PCI_CLASS_PRE_20 0x00 -#define PCI_CLASS_MASS_STORAGE_CTLR 0x01 -#define PCI_CLASS_NETWORK_CTLR 0x02 -#define PCI_CLASS_DISPLAY_CTLR 0x03 -#define PCI_CLASS_MULTIMEDIA_DEV 0x04 -#define PCI_CLASS_MEMORY_CTLR 0x05 -#define PCI_CLASS_BRIDGE_DEV 0x06 -#define PCI_CLASS_SIMPLE_COMMS_CTLR 0x07 -#define PCI_CLASS_BASE_SYSTEM_DEV 0x08 -#define PCI_CLASS_INPUT_DEV 0x09 -#define PCI_CLASS_DOCKING_STATION 0x0a -#define PCI_CLASS_PROCESSOR 0x0b -#define PCI_CLASS_SERIAL_BUS_CTLR 0x0c -#define PCI_CLASS_WIRELESS_CTLR 0x0d -#define PCI_CLASS_INTELLIGENT_IO_CTLR 0x0e -#define PCI_CLASS_SATELLITE_COMMS_CTLR 0x0f -#define PCI_CLASS_ENCRYPTION_DECRYPTION 0x10 -#define PCI_CLASS_DATA_ACQ_SIGNAL_PROC 0x11 +#define STATUS_CONTINUE_COMPLETION STATUS_SUCCESS -/* PCI device subclasses for class 0 */ -#define PCI_SUBCLASS_PRE_20_NON_VGA 0x00 -#define PCI_SUBCLASS_PRE_20_VGA 0x01 - -/* PCI device subclasses for class 1 (mass storage controllers)*/ -#define PCI_SUBCLASS_MSC_SCSI_BUS_CTLR 0x00 -#define PCI_SUBCLASS_MSC_IDE_CTLR 0x01 -#define PCI_SUBCLASS_MSC_FLOPPY_CTLR 0x02 -#define PCI_SUBCLASS_MSC_IPI_CTLR 0x03 -#define PCI_SUBCLASS_MSC_RAID_CTLR 0x04 -#define PCI_SUBCLASS_MSC_OTHER 0x80 - -/* PCI device subclasses for class 2 (network controllers)*/ -#define PCI_SUBCLASS_NET_ETHERNET_CTLR 0x00 -#define PCI_SUBCLASS_NET_TOKEN_RING_CTLR 0x01 -#define PCI_SUBCLASS_NET_FDDI_CTLR 0x02 -#define PCI_SUBCLASS_NET_ATM_CTLR 0x03 -#define PCI_SUBCLASS_NET_ISDN_CTLR 0x04 -#define PCI_SUBCLASS_NET_OTHER 0x80 - -/* PCI device subclasses for class 3 (display controllers)*/ -#define PCI_SUBCLASS_VID_VGA_CTLR 0x00 -#define PCI_SUBCLASS_VID_XGA_CTLR 0x01 -#define PCI_SUBCLASS_VID_3D_CTLR 0x02 -#define PCI_SUBCLASS_VID_OTHER 0x80 - -/* PCI device subclasses for class 4 (multimedia device)*/ -#define PCI_SUBCLASS_MM_VIDEO_DEV 0x00 -#define PCI_SUBCLASS_MM_AUDIO_DEV 0x01 -#define PCI_SUBCLASS_MM_TELEPHONY_DEV 0x02 -#define PCI_SUBCLASS_MM_OTHER 0x80 - -/* PCI device subclasses for class 5 (memory controller)*/ -#define PCI_SUBCLASS_MEM_RAM 0x00 -#define PCI_SUBCLASS_MEM_FLASH 0x01 -#define PCI_SUBCLASS_MEM_OTHER 0x80 - -/* PCI device subclasses for class 6 (bridge device)*/ -#define PCI_SUBCLASS_BR_HOST 0x00 -#define PCI_SUBCLASS_BR_ISA 0x01 -#define PCI_SUBCLASS_BR_EISA 0x02 -#define PCI_SUBCLASS_BR_MCA 0x03 -#define PCI_SUBCLASS_BR_PCI_TO_PCI 0x04 -#define PCI_SUBCLASS_BR_PCMCIA 0x05 -#define PCI_SUBCLASS_BR_NUBUS 0x06 -#define PCI_SUBCLASS_BR_CARDBUS 0x07 -#define PCI_SUBCLASS_BR_RACEWAY 0x08 -#define PCI_SUBCLASS_BR_OTHER 0x80 - -/* PCI device subclasses for class C (serial bus controller)*/ -#define PCI_SUBCLASS_SB_IEEE1394 0x00 -#define PCI_SUBCLASS_SB_ACCESS 0x01 -#define PCI_SUBCLASS_SB_SSA 0x02 -#define PCI_SUBCLASS_SB_USB 0x03 -#define PCI_SUBCLASS_SB_FIBRE_CHANNEL 0x04 -#define PCI_SUBCLASS_SB_SMBUS 0x05 - -#define PCI_MAX_DEVICES 32 -#define PCI_MAX_FUNCTION 8 -#define PCI_MAX_BRIDGE_NUMBER 0xFF -#define PCI_INVALID_VENDORID 0xFFFF -#define PCI_COMMON_HDR_LENGTH (FIELD_OFFSET(PCI_COMMON_CONFIG, DeviceSpecific)) - -#define PCI_ADDRESS_IO_SPACE 0x00000001 -#define PCI_ADDRESS_MEMORY_TYPE_MASK 0x00000006 -#define PCI_ADDRESS_MEMORY_PREFETCHABLE 0x00000008 -#define PCI_ADDRESS_IO_ADDRESS_MASK 0xfffffffc -#define PCI_ADDRESS_MEMORY_ADDRESS_MASK 0xfffffff0 -#define PCI_ADDRESS_ROM_ADDRESS_MASK 0xfffff800 - -#define PCI_TYPE_32BIT 0 -#define PCI_TYPE_20BIT 2 -#define PCI_TYPE_64BIT 4 +#define CONNECT_FULLY_SPECIFIED 0x1 +#define CONNECT_LINE_BASED 0x2 +#define CONNECT_MESSAGE_BASED 0x3 +#define CONNECT_FULLY_SPECIFIED_GROUP 0x4 +#define CONNECT_CURRENT_VERSION 0x4 #define POOL_COLD_ALLOCATION 256 #define POOL_QUOTA_FAIL_INSTEAD_OF_RAISE 8 #define POOL_RAISE_IF_ALLOCATION_FAILURE 16 -#define PCI_TYPE0_ADDRESSES 6 -#define PCI_TYPE1_ADDRESSES 2 -#define PCI_TYPE2_ADDRESSES 5 - #define IO_TYPE_ADAPTER 1 #define IO_TYPE_CONTROLLER 2 #define IO_TYPE_DEVICE 3 @@ -2796,47 +3745,6 @@ typedef struct _REG_KEY_HANDLE_CLOSE_INFORMATION { #define IO_RESOURCE_DEFAULT 0x02 #define IO_RESOURCE_ALTERNATIVE 0x08 -/* DEVICE_OBJECT.Flags */ -#define DO_VERIFY_VOLUME 0x00000002 -#define DO_BUFFERED_IO 0x00000004 -#define DO_EXCLUSIVE 0x00000008 -#define DO_DIRECT_IO 0x00000010 -#define DO_MAP_IO_BUFFER 0x00000020 -#define DO_DEVICE_INITIALIZING 0x00000080 -#define DO_SHUTDOWN_REGISTERED 0x00000800 -#define DO_BUS_ENUMERATED_DEVICE 0x00001000 -#define DO_POWER_PAGABLE 0x00002000 -#define DO_POWER_INRUSH 0x00004000 - -/* DEVICE_OBJECT.Characteristics */ -#define FILE_REMOVABLE_MEDIA 0x00000001 -#define FILE_READ_ONLY_DEVICE 0x00000002 -#define FILE_FLOPPY_DISKETTE 0x00000004 -#define FILE_WRITE_ONCE_MEDIA 0x00000008 -#define FILE_REMOTE_DEVICE 0x00000010 -#define FILE_DEVICE_IS_MOUNTED 0x00000020 -#define FILE_VIRTUAL_VOLUME 0x00000040 -#define FILE_AUTOGENERATED_DEVICE_NAME 0x00000080 -#define FILE_DEVICE_SECURE_OPEN 0x00000100 -#define FILE_CHARACTERISTIC_PNP_DEVICE 0x00000800 -#define FILE_CHARACTERISTIC_TS_DEVICE 0x00001000 -#define FILE_CHARACTERISTIC_WEBDAV_DEVICE 0x00002000 - -/* DEVICE_OBJECT.AlignmentRequirement */ -#define FILE_BYTE_ALIGNMENT 0x00000000 -#define FILE_WORD_ALIGNMENT 0x00000001 -#define FILE_LONG_ALIGNMENT 0x00000003 -#define FILE_QUAD_ALIGNMENT 0x00000007 -#define FILE_OCTA_ALIGNMENT 0x0000000f -#define FILE_32_BYTE_ALIGNMENT 0x0000001f -#define FILE_64_BYTE_ALIGNMENT 0x0000003f -#define FILE_128_BYTE_ALIGNMENT 0x0000007f -#define FILE_256_BYTE_ALIGNMENT 0x000000ff -#define FILE_512_BYTE_ALIGNMENT 0x000001ff - -/* DEVICE_OBJECT.DeviceType */ -#define DEVICE_TYPE ULONG - #define FILE_DEVICE_BEEP 0x00000001 #define FILE_DEVICE_CD_ROM 0x00000002 #define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003 @@ -2905,6 +3813,44 @@ typedef struct _REG_KEY_HANDLE_CLOSE_INFORMATION { #define FILE_DEVICE_BIOMETRIC 0x00000044 #define FILE_DEVICE_PMI 0x00000045 +#if defined(NT_PROCESSOR_GROUPS) + +typedef USHORT IRQ_DEVICE_POLICY, *PIRQ_DEVICE_POLICY; + +typedef enum _IRQ_DEVICE_POLICY_USHORT { + IrqPolicyMachineDefault = 0, + IrqPolicyAllCloseProcessors = 1, + IrqPolicyOneCloseProcessor = 2, + IrqPolicyAllProcessorsInMachine = 3, + IrqPolicyAllProcessorsInGroup = 3, + IrqPolicySpecifiedProcessors = 4, + IrqPolicySpreadMessagesAcrossAllProcessors = 5}; + +#else /* defined(NT_PROCESSOR_GROUPS) */ + +typedef enum _IRQ_DEVICE_POLICY { + IrqPolicyMachineDefault = 0, + IrqPolicyAllCloseProcessors, + IrqPolicyOneCloseProcessor, + IrqPolicyAllProcessorsInMachine, + IrqPolicySpecifiedProcessors, + IrqPolicySpreadMessagesAcrossAllProcessors +} IRQ_DEVICE_POLICY, *PIRQ_DEVICE_POLICY; + +#endif + +typedef enum _IRQ_PRIORITY { + IrqPriorityUndefined = 0, + IrqPriorityLow, + IrqPriorityNormal, + IrqPriorityHigh +} IRQ_PRIORITY, *PIRQ_PRIORITY; + +typedef enum _IRQ_GROUP_POLICY { + GroupAffinityAllGroupZero = 0, + GroupAffinityDontCare +} IRQ_GROUP_POLICY, *PIRQ_GROUP_POLICY; + #define MAXIMUM_VOLUME_LABEL_LENGTH (32 * sizeof(WCHAR)) typedef struct _OBJECT_HANDLE_INFORMATION { @@ -2913,24 +3859,20 @@ typedef struct _OBJECT_HANDLE_INFORMATION { } OBJECT_HANDLE_INFORMATION, *POBJECT_HANDLE_INFORMATION; typedef struct _CLIENT_ID { - HANDLE UniqueProcess; - HANDLE UniqueThread; + HANDLE UniqueProcess; + HANDLE UniqueThread; } CLIENT_ID, *PCLIENT_ID; -typedef VOID -(DDKAPI *PKSTART_ROUTINE)( - IN PVOID StartContext); - typedef struct _VPB { - CSHORT Type; - CSHORT Size; - USHORT Flags; - USHORT VolumeLabelLength; - struct _DEVICE_OBJECT *DeviceObject; - struct _DEVICE_OBJECT *RealDevice; - ULONG SerialNumber; - ULONG ReferenceCount; - WCHAR VolumeLabel[MAXIMUM_VOLUME_LABEL_LENGTH / sizeof(WCHAR)]; + CSHORT Type; + CSHORT Size; + USHORT Flags; + USHORT VolumeLabelLength; + struct _DEVICE_OBJECT *DeviceObject; + struct _DEVICE_OBJECT *RealDevice; + ULONG SerialNumber; + ULONG ReferenceCount; + WCHAR VolumeLabel[MAXIMUM_VOLUME_LABEL_LENGTH / sizeof(WCHAR)]; } VPB, *PVPB; typedef enum _IO_ALLOCATION_ACTION { @@ -2940,190 +3882,370 @@ typedef enum _IO_ALLOCATION_ACTION { } IO_ALLOCATION_ACTION, *PIO_ALLOCATION_ACTION; typedef IO_ALLOCATION_ACTION -(DDKAPI *PDRIVER_CONTROL)( - IN struct _DEVICE_OBJECT *DeviceObject, - IN struct _IRP *Irp, - IN PVOID MapRegisterBase, - IN PVOID Context); +(NTAPI DRIVER_CONTROL)( + IN struct _DEVICE_OBJECT *DeviceObject, + IN struct _IRP *Irp, + IN PVOID MapRegisterBase, + IN PVOID Context); +typedef DRIVER_CONTROL *PDRIVER_CONTROL; typedef struct _WAIT_CONTEXT_BLOCK { - KDEVICE_QUEUE_ENTRY WaitQueueEntry; - PDRIVER_CONTROL DeviceRoutine; - PVOID DeviceContext; - ULONG NumberOfMapRegisters; - PVOID DeviceObject; - PVOID CurrentIrp; - PKDPC BufferChainingDpc; + KDEVICE_QUEUE_ENTRY WaitQueueEntry; + PDRIVER_CONTROL DeviceRoutine; + PVOID DeviceContext; + ULONG NumberOfMapRegisters; + PVOID DeviceObject; + PVOID CurrentIrp; + PKDPC BufferChainingDpc; } WAIT_CONTEXT_BLOCK, *PWAIT_CONTEXT_BLOCK; +/* DEVICE_OBJECT.Flags */ +#define DO_VERIFY_VOLUME 0x00000002 +#define DO_BUFFERED_IO 0x00000004 +#define DO_EXCLUSIVE 0x00000008 +#define DO_DIRECT_IO 0x00000010 +#define DO_MAP_IO_BUFFER 0x00000020 +#define DO_DEVICE_INITIALIZING 0x00000080 +#define DO_SHUTDOWN_REGISTERED 0x00000800 +#define DO_BUS_ENUMERATED_DEVICE 0x00001000 +#define DO_POWER_PAGABLE 0x00002000 +#define DO_POWER_INRUSH 0x00004000 + +/* DEVICE_OBJECT.Characteristics */ +#define FILE_REMOVABLE_MEDIA 0x00000001 +#define FILE_READ_ONLY_DEVICE 0x00000002 +#define FILE_FLOPPY_DISKETTE 0x00000004 +#define FILE_WRITE_ONCE_MEDIA 0x00000008 +#define FILE_REMOTE_DEVICE 0x00000010 +#define FILE_DEVICE_IS_MOUNTED 0x00000020 +#define FILE_VIRTUAL_VOLUME 0x00000040 +#define FILE_AUTOGENERATED_DEVICE_NAME 0x00000080 +#define FILE_DEVICE_SECURE_OPEN 0x00000100 +#define FILE_CHARACTERISTIC_PNP_DEVICE 0x00000800 +#define FILE_CHARACTERISTIC_TS_DEVICE 0x00001000 +#define FILE_CHARACTERISTIC_WEBDAV_DEVICE 0x00002000 + +/* DEVICE_OBJECT.AlignmentRequirement */ +#define FILE_BYTE_ALIGNMENT 0x00000000 +#define FILE_WORD_ALIGNMENT 0x00000001 +#define FILE_LONG_ALIGNMENT 0x00000003 +#define FILE_QUAD_ALIGNMENT 0x00000007 +#define FILE_OCTA_ALIGNMENT 0x0000000f +#define FILE_32_BYTE_ALIGNMENT 0x0000001f +#define FILE_64_BYTE_ALIGNMENT 0x0000003f +#define FILE_128_BYTE_ALIGNMENT 0x0000007f +#define FILE_256_BYTE_ALIGNMENT 0x000000ff +#define FILE_512_BYTE_ALIGNMENT 0x000001ff + +/* DEVICE_OBJECT.DeviceType */ +#define DEVICE_TYPE ULONG + typedef struct _DEVICE_OBJECT { - CSHORT Type; - USHORT Size; - LONG ReferenceCount; - struct _DRIVER_OBJECT *DriverObject; - struct _DEVICE_OBJECT *NextDevice; - struct _DEVICE_OBJECT *AttachedDevice; - struct _IRP *CurrentIrp; - PIO_TIMER Timer; - ULONG Flags; - ULONG Characteristics; - volatile PVPB Vpb; - PVOID DeviceExtension; - DEVICE_TYPE DeviceType; - CCHAR StackSize; + CSHORT Type; + USHORT Size; + LONG ReferenceCount; + struct _DRIVER_OBJECT *DriverObject; + struct _DEVICE_OBJECT *NextDevice; + struct _DEVICE_OBJECT *AttachedDevice; + struct _IRP *CurrentIrp; + PIO_TIMER Timer; + ULONG Flags; + ULONG Characteristics; + volatile PVPB Vpb; + PVOID DeviceExtension; + DEVICE_TYPE DeviceType; + CCHAR StackSize; union { - LIST_ENTRY ListEntry; - WAIT_CONTEXT_BLOCK Wcb; + LIST_ENTRY ListEntry; + WAIT_CONTEXT_BLOCK Wcb; } Queue; - ULONG AlignmentRequirement; - KDEVICE_QUEUE DeviceQueue; - KDPC Dpc; - ULONG ActiveThreadCount; - PSECURITY_DESCRIPTOR SecurityDescriptor; - KEVENT DeviceLock; - USHORT SectorSize; - USHORT Spare1; - struct _DEVOBJ_EXTENSION *DeviceObjectExtension; - PVOID Reserved; + ULONG AlignmentRequirement; + KDEVICE_QUEUE DeviceQueue; + KDPC Dpc; + ULONG ActiveThreadCount; + PSECURITY_DESCRIPTOR SecurityDescriptor; + KEVENT DeviceLock; + USHORT SectorSize; + USHORT Spare1; + struct _DEVOBJ_EXTENSION *DeviceObjectExtension; + PVOID Reserved; } DEVICE_OBJECT, *PDEVICE_OBJECT; +typedef enum _IO_SESSION_STATE { + IoSessionStateCreated = 1, + IoSessionStateInitialized, + IoSessionStateConnected, + IoSessionStateDisconnected, + IoSessionStateDisconnectedLoggedOn, + IoSessionStateLoggedOn, + IoSessionStateLoggedOff, + IoSessionStateTerminated, + IoSessionStateMax +} IO_SESSION_STATE, *PIO_SESSION_STATE; + +typedef enum _IO_COMPLETION_ROUTINE_RESULT { + ContinueCompletion = STATUS_CONTINUE_COMPLETION, + StopCompletion = STATUS_MORE_PROCESSING_REQUIRED +} IO_COMPLETION_ROUTINE_RESULT, *PIO_COMPLETION_ROUTINE_RESULT; + +typedef struct _IO_INTERRUPT_MESSAGE_INFO_ENTRY { + PHYSICAL_ADDRESS MessageAddress; + KAFFINITY TargetProcessorSet; + PKINTERRUPT InterruptObject; + ULONG MessageData; + ULONG Vector; + KIRQL Irql; + KINTERRUPT_MODE Mode; + KINTERRUPT_POLARITY Polarity; +} IO_INTERRUPT_MESSAGE_INFO_ENTRY, *PIO_INTERRUPT_MESSAGE_INFO_ENTRY; + +typedef struct _IO_INTERRUPT_MESSAGE_INFO { + KIRQL UnifiedIrql; + ULONG MessageCount; + IO_INTERRUPT_MESSAGE_INFO_ENTRY MessageInfo[1]; +} IO_INTERRUPT_MESSAGE_INFO, *PIO_INTERRUPT_MESSAGE_INFO; + +typedef struct _IO_CONNECT_INTERRUPT_FULLY_SPECIFIED_PARAMETERS { + IN PDEVICE_OBJECT PhysicalDeviceObject; + OUT PKINTERRUPT *InterruptObject; + IN PKSERVICE_ROUTINE ServiceRoutine; + IN PVOID ServiceContext; + IN PKSPIN_LOCK SpinLock OPTIONAL; + IN KIRQL SynchronizeIrql; + IN BOOLEAN FloatingSave; + IN BOOLEAN ShareVector; + IN ULONG Vector; + IN KIRQL Irql; + IN KINTERRUPT_MODE InterruptMode; + IN KAFFINITY ProcessorEnableMask; + IN USHORT Group; +} IO_CONNECT_INTERRUPT_FULLY_SPECIFIED_PARAMETERS, *PIO_CONNECT_INTERRUPT_FULLY_SPECIFIED_PARAMETERS; + +typedef struct _IO_CONNECT_INTERRUPT_LINE_BASED_PARAMETERS { + IN PDEVICE_OBJECT PhysicalDeviceObject; + OUT PKINTERRUPT *InterruptObject; + IN PKSERVICE_ROUTINE ServiceRoutine; + IN PVOID ServiceContext; + IN PKSPIN_LOCK SpinLock OPTIONAL; + IN KIRQL SynchronizeIrql OPTIONAL; + IN BOOLEAN FloatingSave; +} IO_CONNECT_INTERRUPT_LINE_BASED_PARAMETERS, *PIO_CONNECT_INTERRUPT_LINE_BASED_PARAMETERS; + +typedef struct _IO_CONNECT_INTERRUPT_MESSAGE_BASED_PARAMETERS { + IN PDEVICE_OBJECT PhysicalDeviceObject; + union { + OUT PVOID *Generic; + OUT PIO_INTERRUPT_MESSAGE_INFO *InterruptMessageTable; + OUT PKINTERRUPT *InterruptObject; + } ConnectionContext; + IN PKMESSAGE_SERVICE_ROUTINE MessageServiceRoutine; + IN PVOID ServiceContext; + IN PKSPIN_LOCK SpinLock OPTIONAL; + IN KIRQL SynchronizeIrql OPTIONAL; + IN BOOLEAN FloatingSave; + IN PKSERVICE_ROUTINE FallBackServiceRoutine OPTIONAL; +} IO_CONNECT_INTERRUPT_MESSAGE_BASED_PARAMETERS, *PIO_CONNECT_INTERRUPT_MESSAGE_BASED_PARAMETERS; + +typedef struct _IO_CONNECT_INTERRUPT_PARAMETERS { + IN OUT ULONG Version; + union { + IO_CONNECT_INTERRUPT_FULLY_SPECIFIED_PARAMETERS FullySpecified; + IO_CONNECT_INTERRUPT_LINE_BASED_PARAMETERS LineBased; + IO_CONNECT_INTERRUPT_MESSAGE_BASED_PARAMETERS MessageBased; + }; +} IO_CONNECT_INTERRUPT_PARAMETERS, *PIO_CONNECT_INTERRUPT_PARAMETERS; + +typedef struct _IO_DISCONNECT_INTERRUPT_PARAMETERS { + IN ULONG Version; + union { + IN PVOID Generic; + IN PKINTERRUPT InterruptObject; + IN PIO_INTERRUPT_MESSAGE_INFO InterruptMessageTable; + } ConnectionContext; +} IO_DISCONNECT_INTERRUPT_PARAMETERS, *PIO_DISCONNECT_INTERRUPT_PARAMETERS; + +typedef enum _IO_ACCESS_TYPE { + ReadAccess, + WriteAccess, + ModifyAccess +} IO_ACCESS_TYPE; + +typedef enum _IO_ACCESS_MODE { + SequentialAccess, + RandomAccess +} IO_ACCESS_MODE; + +typedef enum _IO_CONTAINER_NOTIFICATION_CLASS { + IoSessionStateNotification, + IoMaxContainerNotificationClass +} IO_CONTAINER_NOTIFICATION_CLASS; + +typedef struct _IO_SESSION_STATE_NOTIFICATION { + ULONG Size; + ULONG Flags; + PVOID IoObject; + ULONG EventMask; + PVOID Context; +} IO_SESSION_STATE_NOTIFICATION, *PIO_SESSION_STATE_NOTIFICATION; + +typedef enum _IO_CONTAINER_INFORMATION_CLASS { + IoSessionStateInformation, + IoMaxContainerInformationClass +} IO_CONTAINER_INFORMATION_CLASS; + +typedef struct _IO_SESSION_STATE_INFORMATION { + ULONG SessionId; + IO_SESSION_STATE SessionState; + BOOLEAN LocalSession; +} IO_SESSION_STATE_INFORMATION, *PIO_SESSION_STATE_INFORMATION; + +#if (NTDDI_VERSION >= NTDDI_WIN7) + +typedef NTSTATUS +(NTAPI *PIO_CONTAINER_NOTIFICATION_FUNCTION)( + VOID); + +typedef NTSTATUS +(NTAPI IO_SESSION_NOTIFICATION_FUNCTION)( + IN PVOID SessionObject, + IN PVOID IoObject, + IN ULONG Event, + IN PVOID Context, + IN PVOID NotificationPayload, + IN ULONG PayloadLength); + +typedef IO_SESSION_NOTIFICATION_FUNCTION *PIO_SESSION_NOTIFICATION_FUNCTION; + +#endif + typedef struct _IO_REMOVE_LOCK_TRACKING_BLOCK * PIO_REMOVE_LOCK_TRACKING_BLOCK; typedef struct _IO_REMOVE_LOCK_COMMON_BLOCK { - BOOLEAN Removed; - BOOLEAN Reserved[3]; - volatile LONG IoCount; - KEVENT RemoveEvent; + BOOLEAN Removed; + BOOLEAN Reserved[3]; + volatile LONG IoCount; + KEVENT RemoveEvent; } IO_REMOVE_LOCK_COMMON_BLOCK; typedef struct _IO_REMOVE_LOCK_DBG_BLOCK { - LONG Signature; - LONG HighWatermark; - LONGLONG MaxLockedTicks; - LONG AllocateTag; - LIST_ENTRY LockList; - KSPIN_LOCK Spin; - volatile LONG LowMemoryCount; - ULONG Reserved1[4]; - PVOID Reserved2; - PIO_REMOVE_LOCK_TRACKING_BLOCK Blocks; + LONG Signature; + LONG HighWatermark; + LONGLONG MaxLockedTicks; + LONG AllocateTag; + LIST_ENTRY LockList; + KSPIN_LOCK Spin; + volatile LONG LowMemoryCount; + ULONG Reserved1[4]; + PVOID Reserved2; + PIO_REMOVE_LOCK_TRACKING_BLOCK Blocks; } IO_REMOVE_LOCK_DBG_BLOCK; typedef struct _IO_REMOVE_LOCK { - IO_REMOVE_LOCK_COMMON_BLOCK Common; + IO_REMOVE_LOCK_COMMON_BLOCK Common; #if DBG - IO_REMOVE_LOCK_DBG_BLOCK Dbg; + IO_REMOVE_LOCK_DBG_BLOCK Dbg; #endif } IO_REMOVE_LOCK, *PIO_REMOVE_LOCK; typedef struct _IO_WORKITEM *PIO_WORKITEM; typedef VOID -(DDKAPI IO_WORKITEM_ROUTINE)( - IN PDEVICE_OBJECT DeviceObject, - IN PVOID Context); +(NTAPI IO_WORKITEM_ROUTINE)( + IN PDEVICE_OBJECT DeviceObject, + IN PVOID Context); typedef IO_WORKITEM_ROUTINE *PIO_WORKITEM_ROUTINE; +typedef VOID +(NTAPI IO_WORKITEM_ROUTINE_EX)( + IN PVOID IoObject, + IN PVOID Context OPTIONAL, + IN PIO_WORKITEM IoWorkItem); +typedef IO_WORKITEM_ROUTINE_EX *PIO_WORKITEM_ROUTINE_EX; + typedef struct _SHARE_ACCESS { - ULONG OpenCount; - ULONG Readers; - ULONG Writers; - ULONG Deleters; - ULONG SharedRead; - ULONG SharedWrite; - ULONG SharedDelete; + ULONG OpenCount; + ULONG Readers; + ULONG Writers; + ULONG Deleters; + ULONG SharedRead; + ULONG SharedWrite; + ULONG SharedDelete; } SHARE_ACCESS, *PSHARE_ACCESS; /* While MS WDK uses inheritance in C++, we cannot do this with gcc, as inheritance, even from a struct renders the type non-POD. So we use this hack */ #define PCI_COMMON_HEADER_LAYOUT \ - USHORT VendorID; \ - USHORT DeviceID; \ - USHORT Command; \ - USHORT Status; \ - UCHAR RevisionID; \ - UCHAR ProgIf; \ - UCHAR SubClass; \ - UCHAR BaseClass; \ - UCHAR CacheLineSize; \ - UCHAR LatencyTimer; \ - UCHAR HeaderType; \ - UCHAR BIST; \ + USHORT VendorID; \ + USHORT DeviceID; \ + USHORT Command; \ + USHORT Status; \ + UCHAR RevisionID; \ + UCHAR ProgIf; \ + UCHAR SubClass; \ + UCHAR BaseClass; \ + UCHAR CacheLineSize; \ + UCHAR LatencyTimer; \ + UCHAR HeaderType; \ + UCHAR BIST; \ union { \ struct _PCI_HEADER_TYPE_0 { \ - ULONG BaseAddresses[PCI_TYPE0_ADDRESSES]; \ - ULONG CIS; \ - USHORT SubVendorID; \ - USHORT SubSystemID; \ - ULONG ROMBaseAddress; \ - UCHAR CapabilitiesPtr; \ - UCHAR Reserved1[3]; \ - ULONG Reserved2; \ - UCHAR InterruptLine; \ - UCHAR InterruptPin; \ - UCHAR MinimumGrant; \ - UCHAR MaximumLatency; \ + ULONG BaseAddresses[PCI_TYPE0_ADDRESSES]; \ + ULONG CIS; \ + USHORT SubVendorID; \ + USHORT SubSystemID; \ + ULONG ROMBaseAddress; \ + UCHAR CapabilitiesPtr; \ + UCHAR Reserved1[3]; \ + ULONG Reserved2; \ + UCHAR InterruptLine; \ + UCHAR InterruptPin; \ + UCHAR MinimumGrant; \ + UCHAR MaximumLatency; \ } type0; \ struct _PCI_HEADER_TYPE_1 { \ - ULONG BaseAddresses[PCI_TYPE1_ADDRESSES]; \ - UCHAR PrimaryBus; \ - UCHAR SecondaryBus; \ - UCHAR SubordinateBus; \ - UCHAR SecondaryLatency; \ - UCHAR IOBase; \ - UCHAR IOLimit; \ - USHORT SecondaryStatus; \ - USHORT MemoryBase; \ - USHORT MemoryLimit; \ - USHORT PrefetchBase; \ - USHORT PrefetchLimit; \ - ULONG PrefetchBaseUpper32; \ - ULONG PrefetchLimitUpper32; \ - USHORT IOBaseUpper16; \ - USHORT IOLimitUpper16; \ - UCHAR CapabilitiesPtr; \ - UCHAR Reserved1[3]; \ - ULONG ROMBaseAddress; \ - UCHAR InterruptLine; \ - UCHAR InterruptPin; \ - USHORT BridgeControl; \ + ULONG BaseAddresses[PCI_TYPE1_ADDRESSES]; \ + UCHAR PrimaryBus; \ + UCHAR SecondaryBus; \ + UCHAR SubordinateBus; \ + UCHAR SecondaryLatency; \ + UCHAR IOBase; \ + UCHAR IOLimit; \ + USHORT SecondaryStatus; \ + USHORT MemoryBase; \ + USHORT MemoryLimit; \ + USHORT PrefetchBase; \ + USHORT PrefetchLimit; \ + ULONG PrefetchBaseUpper32; \ + ULONG PrefetchLimitUpper32; \ + USHORT IOBaseUpper16; \ + USHORT IOLimitUpper16; \ + UCHAR CapabilitiesPtr; \ + UCHAR Reserved1[3]; \ + ULONG ROMBaseAddress; \ + UCHAR InterruptLine; \ + UCHAR InterruptPin; \ + USHORT BridgeControl; \ } type1; \ struct _PCI_HEADER_TYPE_2 { \ - ULONG SocketRegistersBaseAddress; \ - UCHAR CapabilitiesPtr; \ - UCHAR Reserved; \ - USHORT SecondaryStatus; \ - UCHAR PrimaryBus; \ - UCHAR SecondaryBus; \ - UCHAR SubordinateBus; \ - UCHAR SecondaryLatency; \ - struct { \ - ULONG Base; \ - ULONG Limit; \ + ULONG SocketRegistersBaseAddress; \ + UCHAR CapabilitiesPtr; \ + UCHAR Reserved; \ + USHORT SecondaryStatus; \ + UCHAR PrimaryBus; \ + UCHAR SecondaryBus; \ + UCHAR SubordinateBus; \ + UCHAR SecondaryLatency; \ + struct { \ + ULONG Base; \ + ULONG Limit; \ } Range[PCI_TYPE2_ADDRESSES-1]; \ - UCHAR InterruptLine; \ - UCHAR InterruptPin; \ - USHORT BridgeControl; \ + UCHAR InterruptLine; \ + UCHAR InterruptPin; \ + USHORT BridgeControl; \ } type2; \ } u; -typedef struct _PCI_COMMON_HEADER { - PCI_COMMON_HEADER_LAYOUT -} PCI_COMMON_HEADER, *PPCI_COMMON_HEADER; - -#ifdef __cplusplus -typedef struct _PCI_COMMON_CONFIG { - PCI_COMMON_HEADER_LAYOUT - UCHAR DeviceSpecific[192]; -} PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG; -#else -typedef struct _PCI_COMMON_CONFIG { - PCI_COMMON_HEADER DUMMYSTRUCTNAME; - UCHAR DeviceSpecific[192]; -} PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG; -#endif - typedef enum _CREATE_FILE_TYPE { CreateFileTypeNone, CreateFileTypeNamedPipe, @@ -3138,39 +4260,54 @@ typedef enum _CREATE_FILE_TYPE { typedef struct _IO_STATUS_BLOCK { _ANONYMOUS_UNION union { - NTSTATUS Status; - PVOID Pointer; + NTSTATUS Status; + PVOID Pointer; } DUMMYUNIONNAME; - ULONG_PTR Information; + ULONG_PTR Information; } IO_STATUS_BLOCK, *PIO_STATUS_BLOCK; -typedef struct _PCI_SLOT_NUMBER { - union { - struct { - ULONG DeviceNumber : 5; - ULONG FunctionNumber : 3; - ULONG Reserved : 24; - } bits; - ULONG AsULONG; - } u; -} PCI_SLOT_NUMBER, *PPCI_SLOT_NUMBER; +#if defined(_WIN64) +typedef struct _IO_STATUS_BLOCK32 { + NTSTATUS Status; + ULONG Information; +} IO_STATUS_BLOCK32, *PIO_STATUS_BLOCK32; +#endif typedef VOID -(DDKAPI *PIO_APC_ROUTINE)( +(NTAPI *PIO_APC_ROUTINE)( IN PVOID ApcContext, IN PIO_STATUS_BLOCK IoStatusBlock, IN ULONG Reserved); -typedef VOID -(DDKAPI *WMI_NOTIFICATION_CALLBACK)( - PVOID Wnode, - PVOID Context); +#define PIO_APC_ROUTINE_DEFINED -#define WMIREG_ACTION_REGISTER 1 -#define WMIREG_ACTION_DEREGISTER 2 -#define WMIREG_ACTION_REREGISTER 3 -#define WMIREG_ACTION_UPDATE_GUIDS 4 -#define WMIREG_ACTION_BLOCK_IRPS 5 +typedef enum _IO_SESSION_EVENT { + IoSessionEventIgnore = 0, + IoSessionEventCreated, + IoSessionEventTerminated, + IoSessionEventConnected, + IoSessionEventDisconnected, + IoSessionEventLogon, + IoSessionEventLogoff, + IoSessionEventMax +} IO_SESSION_EVENT, *PIO_SESSION_EVENT; + +#define IO_SESSION_STATE_ALL_EVENTS 0xffffffff +#define IO_SESSION_STATE_CREATION_EVENT 0x00000001 +#define IO_SESSION_STATE_TERMINATION_EVENT 0x00000002 +#define IO_SESSION_STATE_CONNECT_EVENT 0x00000004 +#define IO_SESSION_STATE_DISCONNECT_EVENT 0x00000008 +#define IO_SESSION_STATE_LOGON_EVENT 0x00000010 +#define IO_SESSION_STATE_LOGOFF_EVENT 0x00000020 + +#define IO_SESSION_STATE_VALID_EVENT_MASK 0x0000003f + +#define IO_SESSION_MAX_PAYLOAD_SIZE 256L + +typedef struct _IO_SESSION_CONNECT_INFO { + ULONG SessionId; + BOOLEAN LocalSession; +} IO_SESSION_CONNECT_INFO, *PIO_SESSION_CONNECT_INFO; #define EVENT_INCREMENT 1 #define IO_NO_INCREMENT 0 @@ -3190,105 +4327,148 @@ typedef VOID #define MM_MAXIMUM_DISK_IO_SIZE (0x10000) typedef struct _BOOTDISK_INFORMATION { - LONGLONG BootPartitionOffset; - LONGLONG SystemPartitionOffset; - ULONG BootDeviceSignature; - ULONG SystemDeviceSignature; + LONGLONG BootPartitionOffset; + LONGLONG SystemPartitionOffset; + ULONG BootDeviceSignature; + ULONG SystemDeviceSignature; } BOOTDISK_INFORMATION, *PBOOTDISK_INFORMATION; typedef struct _BOOTDISK_INFORMATION_EX { - LONGLONG BootPartitionOffset; - LONGLONG SystemPartitionOffset; - ULONG BootDeviceSignature; - ULONG SystemDeviceSignature; - GUID BootDeviceGuid; - GUID SystemDeviceGuid; - BOOLEAN BootDeviceIsGpt; - BOOLEAN SystemDeviceIsGpt; + LONGLONG BootPartitionOffset; + LONGLONG SystemPartitionOffset; + ULONG BootDeviceSignature; + ULONG SystemDeviceSignature; + GUID BootDeviceGuid; + GUID SystemDeviceGuid; + BOOLEAN BootDeviceIsGpt; + BOOLEAN SystemDeviceIsGpt; } BOOTDISK_INFORMATION_EX, *PBOOTDISK_INFORMATION_EX; -typedef struct _EISA_MEMORY_TYPE { - UCHAR ReadWrite : 1; - UCHAR Cached : 1; - UCHAR Reserved0 : 1; - UCHAR Type : 2; - UCHAR Shared : 1; - UCHAR Reserved1 : 1; - UCHAR MoreEntries : 1; -} EISA_MEMORY_TYPE, *PEISA_MEMORY_TYPE; +#if (NTDDI_VERSION >= NTDDI_WIN7) + +typedef struct _LOADER_PARTITION_INFORMATION_EX { + ULONG PartitionStyle; + ULONG PartitionNumber; + union { + ULONG Signature; + GUID DeviceId; + }; + ULONG Flags; +} LOADER_PARTITION_INFORMATION_EX, *PLOADER_PARTITION_INFORMATION_EX; + +typedef struct _BOOTDISK_INFORMATION_LITE { + ULONG NumberEntries; + LOADER_PARTITION_INFORMATION_EX Entries[1]; +} BOOTDISK_INFORMATION_LITE, *PBOOTDISK_INFORMATION_LITE; + +#else + +#if (NTDDI_VERSION >= NTDDI_VISTA) +typedef struct _BOOTDISK_INFORMATION_LITE { + ULONG BootDeviceSignature; + ULONG SystemDeviceSignature; + GUID BootDeviceGuid; + GUID SystemDeviceGuid; + BOOLEAN BootDeviceIsGpt; + BOOLEAN SystemDeviceIsGpt; +} BOOTDISK_INFORMATION_LITE, *PBOOTDISK_INFORMATION_LITE; +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ #include + +typedef struct _EISA_MEMORY_TYPE { + UCHAR ReadWrite:1; + UCHAR Cached:1; + UCHAR Reserved0:1; + UCHAR Type:2; + UCHAR Shared:1; + UCHAR Reserved1:1; + UCHAR MoreEntries:1; +} EISA_MEMORY_TYPE, *PEISA_MEMORY_TYPE; + typedef struct _EISA_MEMORY_CONFIGURATION { - EISA_MEMORY_TYPE ConfigurationByte; - UCHAR DataSize; - USHORT AddressLowWord; - UCHAR AddressHighByte; - USHORT MemorySize; + EISA_MEMORY_TYPE ConfigurationByte; + UCHAR DataSize; + USHORT AddressLowWord; + UCHAR AddressHighByte; + USHORT MemorySize; } EISA_MEMORY_CONFIGURATION, *PEISA_MEMORY_CONFIGURATION; -#include typedef struct _EISA_IRQ_DESCRIPTOR { - UCHAR Interrupt : 4; - UCHAR Reserved : 1; - UCHAR LevelTriggered : 1; - UCHAR Shared : 1; - UCHAR MoreEntries : 1; + UCHAR Interrupt:4; + UCHAR Reserved:1; + UCHAR LevelTriggered:1; + UCHAR Shared:1; + UCHAR MoreEntries:1; } EISA_IRQ_DESCRIPTOR, *PEISA_IRQ_DESCRIPTOR; typedef struct _EISA_IRQ_CONFIGURATION { - EISA_IRQ_DESCRIPTOR ConfigurationByte; - UCHAR Reserved; + EISA_IRQ_DESCRIPTOR ConfigurationByte; + UCHAR Reserved; } EISA_IRQ_CONFIGURATION, *PEISA_IRQ_CONFIGURATION; typedef struct _DMA_CONFIGURATION_BYTE0 { - UCHAR Channel : 3; - UCHAR Reserved : 3; - UCHAR Shared : 1; - UCHAR MoreEntries : 1; + UCHAR Channel:3; + UCHAR Reserved:3; + UCHAR Shared:1; + UCHAR MoreEntries:1; } DMA_CONFIGURATION_BYTE0; typedef struct _DMA_CONFIGURATION_BYTE1 { - UCHAR Reserved0 : 2; - UCHAR TransferSize : 2; - UCHAR Timing : 2; - UCHAR Reserved1 : 2; + UCHAR Reserved0:2; + UCHAR TransferSize:2; + UCHAR Timing:2; + UCHAR Reserved1:2; } DMA_CONFIGURATION_BYTE1; typedef struct _EISA_DMA_CONFIGURATION { - DMA_CONFIGURATION_BYTE0 ConfigurationByte0; - DMA_CONFIGURATION_BYTE1 ConfigurationByte1; + DMA_CONFIGURATION_BYTE0 ConfigurationByte0; + DMA_CONFIGURATION_BYTE1 ConfigurationByte1; } EISA_DMA_CONFIGURATION, *PEISA_DMA_CONFIGURATION; -#include typedef struct _EISA_PORT_DESCRIPTOR { - UCHAR NumberPorts : 5; - UCHAR Reserved : 1; - UCHAR Shared : 1; - UCHAR MoreEntries : 1; + UCHAR NumberPorts:5; + UCHAR Reserved:1; + UCHAR Shared:1; + UCHAR MoreEntries:1; } EISA_PORT_DESCRIPTOR, *PEISA_PORT_DESCRIPTOR; typedef struct _EISA_PORT_CONFIGURATION { - EISA_PORT_DESCRIPTOR Configuration; - USHORT PortAddress; + EISA_PORT_DESCRIPTOR Configuration; + USHORT PortAddress; } EISA_PORT_CONFIGURATION, *PEISA_PORT_CONFIGURATION; -#include + +typedef struct _CM_EISA_SLOT_INFORMATION { + UCHAR ReturnCode; + UCHAR ReturnFlags; + UCHAR MajorRevision; + UCHAR MinorRevision; + USHORT Checksum; + UCHAR NumberFunctions; + UCHAR FunctionInformation; + ULONG CompressedId; +} CM_EISA_SLOT_INFORMATION, *PCM_EISA_SLOT_INFORMATION; typedef struct _CM_EISA_FUNCTION_INFORMATION { - ULONG CompressedId; - UCHAR IdSlotFlags1; - UCHAR IdSlotFlags2; - UCHAR MinorRevision; - UCHAR MajorRevision; - UCHAR Selections[26]; - UCHAR FunctionFlags; - UCHAR TypeString[80]; - EISA_MEMORY_CONFIGURATION EisaMemory[9]; - EISA_IRQ_CONFIGURATION EisaIrq[7]; - EISA_DMA_CONFIGURATION EisaDma[4]; - EISA_PORT_CONFIGURATION EisaPort[20]; - UCHAR InitializationData[60]; + ULONG CompressedId; + UCHAR IdSlotFlags1; + UCHAR IdSlotFlags2; + UCHAR MinorRevision; + UCHAR MajorRevision; + UCHAR Selections[26]; + UCHAR FunctionFlags; + UCHAR TypeString[80]; + EISA_MEMORY_CONFIGURATION EisaMemory[9]; + EISA_IRQ_CONFIGURATION EisaIrq[7]; + EISA_DMA_CONFIGURATION EisaDma[4]; + EISA_PORT_CONFIGURATION EisaPort[20]; + UCHAR InitializationData[60]; } CM_EISA_FUNCTION_INFORMATION, *PCM_EISA_FUNCTION_INFORMATION; +#include + /* CM_EISA_FUNCTION_INFORMATION.FunctionFlags */ #define EISA_FUNCTION_ENABLED 0x80 @@ -3303,16 +4483,9 @@ typedef struct _CM_EISA_FUNCTION_INFORMATION { (EISA_HAS_PORT_RANGE + EISA_HAS_DMA_ENTRY + EISA_HAS_IRQ_ENTRY \ + EISA_HAS_MEMORY_ENTRY + EISA_HAS_TYPE_ENTRY) -typedef struct _CM_EISA_SLOT_INFORMATION { - UCHAR ReturnCode; - UCHAR ReturnFlags; - UCHAR MajorRevision; - UCHAR MinorRevision; - USHORT Checksum; - UCHAR NumberFunctions; - UCHAR FunctionInformation; - ULONG CompressedId; -} CM_EISA_SLOT_INFORMATION, *PCM_EISA_SLOT_INFORMATION; +#define EISA_MORE_ENTRIES 0x80 +#define EISA_SYSTEM_MEMORY 0x00 +#define EISA_MEMORY_TYPE_RAM 0x01 /* CM_EISA_SLOT_INFORMATION.ReturnCode */ @@ -3327,34 +4500,76 @@ typedef struct _CM_EISA_SLOT_INFORMATION { */ typedef VOID -(DDKAPI *PINTERFACE_REFERENCE)( - PVOID Context); +(NTAPI *PINTERFACE_REFERENCE)( + PVOID Context); typedef VOID -(DDKAPI *PINTERFACE_DEREFERENCE)( +(NTAPI *PINTERFACE_DEREFERENCE)( PVOID Context); typedef BOOLEAN -(DDKAPI *PTRANSLATE_BUS_ADDRESS)( - IN PVOID Context, - IN PHYSICAL_ADDRESS BusAddress, - IN ULONG Length, - IN OUT PULONG AddressSpace, +(NTAPI TRANSLATE_BUS_ADDRESS)( + IN PVOID Context, + IN PHYSICAL_ADDRESS BusAddress, + IN ULONG Length, + IN OUT PULONG AddressSpace, OUT PPHYSICAL_ADDRESS TranslatedAddress); +typedef TRANSLATE_BUS_ADDRESS *PTRANSLATE_BUS_ADDRESS; typedef struct _DMA_ADAPTER* -(DDKAPI *PGET_DMA_ADAPTER)( - IN PVOID Context, - IN struct _DEVICE_DESCRIPTION *DeviceDescriptor, - OUT PULONG NumberOfMapRegisters); +(NTAPI GET_DMA_ADAPTER)( + IN PVOID Context, + IN struct _DEVICE_DESCRIPTION *DeviceDescriptor, + OUT PULONG NumberOfMapRegisters); +typedef GET_DMA_ADAPTER *PGET_DMA_ADAPTER; typedef ULONG -(DDKAPI *PGET_SET_DEVICE_DATA)( - IN PVOID Context, - IN ULONG DataType, - IN PVOID Buffer, - IN ULONG Offset, - IN ULONG Length); +(NTAPI GET_SET_DEVICE_DATA)( + IN PVOID Context, + IN ULONG DataType, + IN PVOID Buffer, + IN ULONG Offset, + IN ULONG Length); +typedef GET_SET_DEVICE_DATA *PGET_SET_DEVICE_DATA; + +typedef enum _DEVICE_INSTALL_STATE { + InstallStateInstalled, + InstallStateNeedsReinstall, + InstallStateFailedInstall, + InstallStateFinishInstall +} DEVICE_INSTALL_STATE, *PDEVICE_INSTALL_STATE; + +typedef struct _LEGACY_BUS_INFORMATION { + GUID BusTypeGuid; + INTERFACE_TYPE LegacyBusType; + ULONG BusNumber; +} LEGACY_BUS_INFORMATION, *PLEGACY_BUS_INFORMATION; + +typedef enum _DEVICE_REMOVAL_POLICY { + RemovalPolicyExpectNoRemoval = 1, + RemovalPolicyExpectOrderlyRemoval = 2, + RemovalPolicyExpectSurpriseRemoval = 3 +} DEVICE_REMOVAL_POLICY, *PDEVICE_REMOVAL_POLICY; + +typedef VOID +(NTAPI*PREENUMERATE_SELF)( + IN PVOID Context); + +typedef struct _REENUMERATE_SELF_INTERFACE_STANDARD { + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; + PREENUMERATE_SELF SurpriseRemoveAndReenumerateSelf; +} REENUMERATE_SELF_INTERFACE_STANDARD, *PREENUMERATE_SELF_INTERFACE_STANDARD; + +typedef VOID +(NTAPI *PIO_DEVICE_EJECT_CALLBACK)( + IN NTSTATUS Status, + IN OUT PVOID Context OPTIONAL); + +#define PCI_DEVICE_PRESENT_INTERFACE_VERSION 1 /* PCI_DEVICE_PRESENCE_PARAMETERS.Flags */ #define PCI_USE_SUBSYSTEM_IDS 0x00000001 @@ -3366,283 +4581,116 @@ typedef ULONG #define PCI_USE_LOCAL_DEVICE 0x00000040 typedef struct _PCI_DEVICE_PRESENCE_PARAMETERS { - ULONG Size; - ULONG Flags; - USHORT VendorID; - USHORT DeviceID; - UCHAR RevisionID; - USHORT SubVendorID; - USHORT SubSystemID; - UCHAR BaseClass; - UCHAR SubClass; - UCHAR ProgIf; + ULONG Size; + ULONG Flags; + USHORT VendorID; + USHORT DeviceID; + UCHAR RevisionID; + USHORT SubVendorID; + USHORT SubSystemID; + UCHAR BaseClass; + UCHAR SubClass; + UCHAR ProgIf; } PCI_DEVICE_PRESENCE_PARAMETERS, *PPCI_DEVICE_PRESENCE_PARAMETERS; typedef BOOLEAN -(DDKAPI *PPCI_IS_DEVICE_PRESENT)( - IN USHORT VendorID, - IN USHORT DeviceID, - IN UCHAR RevisionID, - IN USHORT SubVendorID, - IN USHORT SubSystemID, - IN ULONG Flags); +(NTAPI PCI_IS_DEVICE_PRESENT)( + IN USHORT VendorID, + IN USHORT DeviceID, + IN UCHAR RevisionID, + IN USHORT SubVendorID, + IN USHORT SubSystemID, + IN ULONG Flags); +typedef PCI_IS_DEVICE_PRESENT *PPCI_IS_DEVICE_PRESENT; typedef BOOLEAN -(DDKAPI *PPCI_IS_DEVICE_PRESENT_EX)( +(NTAPI PCI_IS_DEVICE_PRESENT_EX)( IN PVOID Context, IN PPCI_DEVICE_PRESENCE_PARAMETERS Parameters); +typedef PCI_IS_DEVICE_PRESENT_EX *PPCI_IS_DEVICE_PRESENT_EX; typedef struct _BUS_INTERFACE_STANDARD { - USHORT Size; - USHORT Version; - PVOID Context; - PINTERFACE_REFERENCE InterfaceReference; - PINTERFACE_DEREFERENCE InterfaceDereference; - PTRANSLATE_BUS_ADDRESS TranslateBusAddress; - PGET_DMA_ADAPTER GetDmaAdapter; - PGET_SET_DEVICE_DATA SetBusData; - PGET_SET_DEVICE_DATA GetBusData; + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; + PTRANSLATE_BUS_ADDRESS TranslateBusAddress; + PGET_DMA_ADAPTER GetDmaAdapter; + PGET_SET_DEVICE_DATA SetBusData; + PGET_SET_DEVICE_DATA GetBusData; } BUS_INTERFACE_STANDARD, *PBUS_INTERFACE_STANDARD; typedef struct _PCI_DEVICE_PRESENT_INTERFACE { - USHORT Size; - USHORT Version; - PVOID Context; - PINTERFACE_REFERENCE InterfaceReference; - PINTERFACE_DEREFERENCE InterfaceDereference; - PPCI_IS_DEVICE_PRESENT IsDevicePresent; - PPCI_IS_DEVICE_PRESENT_EX IsDevicePresentEx; + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; + PPCI_IS_DEVICE_PRESENT IsDevicePresent; + PPCI_IS_DEVICE_PRESENT_EX IsDevicePresentEx; } PCI_DEVICE_PRESENT_INTERFACE, *PPCI_DEVICE_PRESENT_INTERFACE; -typedef -BOOLEAN -(*PGPE_SERVICE_ROUTINE2)( - PVOID ObjectContext, - PVOID ServiceContext -); - -typedef -NTSTATUS -(*PGPE_CONNECT_VECTOR2)( - PVOID Context, - ULONG GpeNumber, - KINTERRUPT_MODE Mode, - BOOLEAN Shareable, - PGPE_SERVICE_ROUTINE2 ServiceRoutine, - PVOID ServiceContext, - PVOID *ObjectContext -); - -typedef -NTSTATUS -(*PGPE_DISCONNECT_VECTOR2)( - PVOID Context, - PVOID ObjectContext -); - -typedef -NTSTATUS -(*PGPE_ENABLE_EVENT2)( - PVOID Context, - PVOID ObjectContext -); - -typedef -NTSTATUS -(*PGPE_DISABLE_EVENT2)( - PVOID Context, - PVOID ObjectContext -); - -typedef -NTSTATUS -(*PGPE_CLEAR_STATUS2)( - PVOID Context, - PVOID ObjectContext -); - -typedef -VOID -(*PDEVICE_NOTIFY_CALLBACK2)( - PVOID NotificationContext, - ULONG NotifyCode -); - -typedef -NTSTATUS -(*PREGISTER_FOR_DEVICE_NOTIFICATIONS2)( - PVOID Context, - PDEVICE_NOTIFY_CALLBACK2 NotificationHandler, - PVOID NotificationContext -); - -typedef -VOID -(*PUNREGISTER_FOR_DEVICE_NOTIFICATIONS2)( - PVOID Context -); - -typedef struct -{ - USHORT Size; - USHORT Version; - PVOID Context; - PINTERFACE_REFERENCE InterfaceReference; - PINTERFACE_DEREFERENCE InterfaceDereference; - PGPE_CONNECT_VECTOR2 GpeConnectVector; - PGPE_DISCONNECT_VECTOR2 GpeDisconnectVector; - PGPE_ENABLE_EVENT2 GpeEnableEvent; - PGPE_DISABLE_EVENT2 GpeDisableEvent; - PGPE_CLEAR_STATUS2 GpeClearStatus; - PREGISTER_FOR_DEVICE_NOTIFICATIONS2 RegisterForDeviceNotifications; - PUNREGISTER_FOR_DEVICE_NOTIFICATIONS2 UnregisterForDeviceNotifications; -} ACPI_INTERFACE_STANDARD2, *PACPI_INTERFACE_STANDARD2; - -typedef -BOOLEAN -(*PGPE_SERVICE_ROUTINE)( - PDEVICE_OBJECT ObjectContext, - PVOID ServiceContext -); - -typedef -NTSTATUS -(*PGPE_CONNECT_VECTOR)( - PDEVICE_OBJECT Context, - ULONG GpeNumber, - KINTERRUPT_MODE Mode, - BOOLEAN Shareable, - PGPE_SERVICE_ROUTINE ServiceRoutine, - PVOID ServiceContext, - PVOID *ObjectContext -); - -typedef -NTSTATUS -(*PGPE_DISCONNECT_VECTOR)( - PDEVICE_OBJECT Context, - PVOID ObjectContext -); - -typedef -NTSTATUS -(*PGPE_ENABLE_EVENT)( - PDEVICE_OBJECT Context, - PVOID ObjectContext -); - -typedef -NTSTATUS -(*PGPE_DISABLE_EVENT)( - PDEVICE_OBJECT Context, - PVOID ObjectContext -); - -typedef -NTSTATUS -(*PGPE_CLEAR_STATUS)( - PDEVICE_OBJECT Context, - PVOID ObjectContext -); - -typedef -VOID -(*PDEVICE_NOTIFY_CALLBACK)( - PVOID NotificationContext, - ULONG NotifyCode -); - -typedef -NTSTATUS -(*PREGISTER_FOR_DEVICE_NOTIFICATIONS)( - PDEVICE_OBJECT Context, - PDEVICE_NOTIFY_CALLBACK NotificationHandler, - PVOID NotificationContext -); - -typedef -VOID -(*PUNREGISTER_FOR_DEVICE_NOTIFICATIONS)( - PDEVICE_OBJECT Context, - PDEVICE_NOTIFY_CALLBACK NotificationHandler -); - -typedef struct -{ - USHORT Size; - USHORT Version; - PVOID Context; - PINTERFACE_REFERENCE InterfaceReference; - PINTERFACE_DEREFERENCE InterfaceDereference; - PGPE_CONNECT_VECTOR GpeConnectVector; - PGPE_DISCONNECT_VECTOR GpeDisconnectVector; - PGPE_ENABLE_EVENT GpeEnableEvent; - PGPE_DISABLE_EVENT GpeDisableEvent; - PGPE_CLEAR_STATUS GpeClearStatus; - PREGISTER_FOR_DEVICE_NOTIFICATIONS RegisterForDeviceNotifications; - PUNREGISTER_FOR_DEVICE_NOTIFICATIONS UnregisterForDeviceNotifications; -} ACPI_INTERFACE_STANDARD, *PACPI_INTERFACE_STANDARD; - typedef struct _DEVICE_CAPABILITIES { - USHORT Size; - USHORT Version; - ULONG DeviceD1 : 1; - ULONG DeviceD2 : 1; - ULONG LockSupported : 1; - ULONG EjectSupported : 1; - ULONG Removable : 1; - ULONG DockDevice : 1; - ULONG UniqueID : 1; - ULONG SilentInstall : 1; - ULONG RawDeviceOK : 1; - ULONG SurpriseRemovalOK : 1; - ULONG WakeFromD0 : 1; - ULONG WakeFromD1 : 1; - ULONG WakeFromD2 : 1; - ULONG WakeFromD3 : 1; - ULONG HardwareDisabled : 1; - ULONG NonDynamic : 1; - ULONG WarmEjectSupported : 1; - ULONG NoDisplayInUI : 1; - ULONG Reserved : 14; - ULONG Address; - ULONG UINumber; - DEVICE_POWER_STATE DeviceState[PowerSystemMaximum]; - SYSTEM_POWER_STATE SystemWake; - DEVICE_POWER_STATE DeviceWake; - ULONG D1Latency; - ULONG D2Latency; - ULONG D3Latency; + USHORT Size; + USHORT Version; + ULONG DeviceD1:1; + ULONG DeviceD2:1; + ULONG LockSupported:1; + ULONG EjectSupported:1; + ULONG Removable:1; + ULONG DockDevice:1; + ULONG UniqueID:1; + ULONG SilentInstall:1; + ULONG RawDeviceOK:1; + ULONG SurpriseRemovalOK:1; + ULONG WakeFromD0:1; + ULONG WakeFromD1:1; + ULONG WakeFromD2:1; + ULONG WakeFromD3:1; + ULONG HardwareDisabled:1; + ULONG NonDynamic:1; + ULONG WarmEjectSupported:1; + ULONG NoDisplayInUI:1; + ULONG Reserved:14; + ULONG Address; + ULONG UINumber; + DEVICE_POWER_STATE DeviceState[PowerSystemMaximum]; + SYSTEM_POWER_STATE SystemWake; + DEVICE_POWER_STATE DeviceWake; + ULONG D1Latency; + ULONG D2Latency; + ULONG D3Latency; } DEVICE_CAPABILITIES, *PDEVICE_CAPABILITIES; typedef struct _DEVICE_INTERFACE_CHANGE_NOTIFICATION { - USHORT Version; - USHORT Size; - GUID Event; - GUID InterfaceClassGuid; - PUNICODE_STRING SymbolicLinkName; + USHORT Version; + USHORT Size; + GUID Event; + GUID InterfaceClassGuid; + PUNICODE_STRING SymbolicLinkName; } DEVICE_INTERFACE_CHANGE_NOTIFICATION, *PDEVICE_INTERFACE_CHANGE_NOTIFICATION; typedef struct _HWPROFILE_CHANGE_NOTIFICATION { - USHORT Version; - USHORT Size; - GUID Event; + USHORT Version; + USHORT Size; + GUID Event; } HWPROFILE_CHANGE_NOTIFICATION, *PHWPROFILE_CHANGE_NOTIFICATION; #undef INTERFACE typedef struct _INTERFACE { - USHORT Size; - USHORT Version; - PVOID Context; - PINTERFACE_REFERENCE InterfaceReference; - PINTERFACE_DEREFERENCE InterfaceDereference; + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; } INTERFACE, *PINTERFACE; typedef struct _PLUGPLAY_NOTIFICATION_HEADER { - USHORT Version; - USHORT Size; - GUID Event; + USHORT Version; + USHORT Size; + GUID Event; } PLUGPLAY_NOTIFICATION_HEADER, *PPLUGPLAY_NOTIFICATION_HEADER; typedef ULONG PNP_DEVICE_STATE, *PPNP_DEVICE_STATE; @@ -3657,21 +4705,154 @@ typedef ULONG PNP_DEVICE_STATE, *PPNP_DEVICE_STATE; #define PNP_DEVICE_NOT_DISABLEABLE 0x00000020 typedef struct _TARGET_DEVICE_CUSTOM_NOTIFICATION { - USHORT Version; - USHORT Size; - GUID Event; - struct _FILE_OBJECT *FileObject; - LONG NameBufferOffset; - UCHAR CustomDataBuffer[1]; + USHORT Version; + USHORT Size; + GUID Event; + struct _FILE_OBJECT *FileObject; + LONG NameBufferOffset; + UCHAR CustomDataBuffer[1]; } TARGET_DEVICE_CUSTOM_NOTIFICATION, *PTARGET_DEVICE_CUSTOM_NOTIFICATION; typedef struct _TARGET_DEVICE_REMOVAL_NOTIFICATION { - USHORT Version; - USHORT Size; - GUID Event; - struct _FILE_OBJECT *FileObject; + USHORT Version; + USHORT Size; + GUID Event; + struct _FILE_OBJECT *FileObject; } TARGET_DEVICE_REMOVAL_NOTIFICATION, *PTARGET_DEVICE_REMOVAL_NOTIFICATION; +#if (NTDDI_VERSION >= NTDDI_VISTA) +#include +#define PLUGPLAY_PROPERTY_PERSISTENT 0x00000001 +#endif + +#define PNP_REPLACE_NO_MAP MAXLONGLONG + +typedef NTSTATUS +(NTAPI *PREPLACE_MAP_MEMORY)( + IN PHYSICAL_ADDRESS TargetPhysicalAddress, + IN PHYSICAL_ADDRESS SparePhysicalAddress, + IN OUT PLARGE_INTEGER NumberOfBytes, + OUT PVOID *TargetAddress, + OUT PVOID *SpareAddress); + +typedef struct _PNP_REPLACE_MEMORY_LIST { + ULONG AllocatedCount; + ULONG Count; + ULONGLONG TotalLength; + struct { + PHYSICAL_ADDRESS Address; + ULONGLONG Length; + } Ranges[ANYSIZE_ARRAY]; +} PNP_REPLACE_MEMORY_LIST, *PPNP_REPLACE_MEMORY_LIST; + +typedef struct _PNP_REPLACE_PROCESSOR_LIST { + PKAFFINITY Affinity; + ULONG GroupCount; + ULONG AllocatedCount; + ULONG Count; + ULONG ApicIds[ANYSIZE_ARRAY]; +} PNP_REPLACE_PROCESSOR_LIST, *PPNP_REPLACE_PROCESSOR_LIST; + +typedef struct _PNP_REPLACE_PROCESSOR_LIST_V1 { + KAFFINITY AffinityMask; + ULONG AllocatedCount; + ULONG Count; + ULONG ApicIds[ANYSIZE_ARRAY]; +} PNP_REPLACE_PROCESSOR_LIST_V1, *PPNP_REPLACE_PROCESSOR_LIST_V1; + +#define PNP_REPLACE_PARAMETERS_VERSION 2 + +typedef struct _PNP_REPLACE_PARAMETERS { + ULONG Size; + ULONG Version; + ULONG64 Target; + ULONG64 Spare; + PPNP_REPLACE_PROCESSOR_LIST TargetProcessors; + PPNP_REPLACE_PROCESSOR_LIST SpareProcessors; + PPNP_REPLACE_MEMORY_LIST TargetMemory; + PPNP_REPLACE_MEMORY_LIST SpareMemory; + PREPLACE_MAP_MEMORY MapMemory; +} PNP_REPLACE_PARAMETERS, *PPNP_REPLACE_PARAMETERS; + +typedef VOID +(NTAPI *PREPLACE_UNLOAD)( + VOID); + +typedef NTSTATUS +(NTAPI *PREPLACE_BEGIN)( + IN PPNP_REPLACE_PARAMETERS Parameters, + OUT PVOID *Context); + +typedef NTSTATUS +(NTAPI *PREPLACE_END)( + IN PVOID Context); + +typedef NTSTATUS +(NTAPI *PREPLACE_MIRROR_PHYSICAL_MEMORY)( + IN PVOID Context, + IN PHYSICAL_ADDRESS PhysicalAddress, + IN LARGE_INTEGER ByteCount); + +typedef NTSTATUS +(NTAPI *PREPLACE_SET_PROCESSOR_ID)( + IN PVOID Context, + IN ULONG ApicId, + IN BOOLEAN Target); + +typedef NTSTATUS +(NTAPI *PREPLACE_SWAP)( + IN PVOID Context); + +typedef NTSTATUS +(NTAPI *PREPLACE_INITIATE_HARDWARE_MIRROR)( + IN PVOID Context); + +typedef NTSTATUS +(NTAPI *PREPLACE_MIRROR_PLATFORM_MEMORY)( + IN PVOID Context); + +typedef NTSTATUS +(NTAPI *PREPLACE_GET_MEMORY_DESTINATION)( + IN PVOID Context, + IN PHYSICAL_ADDRESS SourceAddress, + OUT PPHYSICAL_ADDRESS DestinationAddress); + +typedef NTSTATUS +(NTAPI *PREPLACE_ENABLE_DISABLE_HARDWARE_QUIESCE)( + IN PVOID Context, + IN BOOLEAN Enable); + +#define PNP_REPLACE_DRIVER_INTERFACE_VERSION 1 +#define PNP_REPLACE_DRIVER_INTERFACE_MINIMUM_SIZE \ + FIELD_OFFSET(PNP_REPLACE_DRIVER_INTERFACE, InitiateHardwareMirror) + +#define PNP_REPLACE_MEMORY_SUPPORTED 0x0001 +#define PNP_REPLACE_PROCESSOR_SUPPORTED 0x0002 +#define PNP_REPLACE_HARDWARE_MEMORY_MIRRORING 0x0004 +#define PNP_REPLACE_HARDWARE_PAGE_COPY 0x0008 +#define PNP_REPLACE_HARDWARE_QUIESCE 0x0010 + +typedef struct _PNP_REPLACE_DRIVER_INTERFACE { + ULONG Size; + ULONG Version; + ULONG Flags; + PREPLACE_UNLOAD Unload; + PREPLACE_BEGIN BeginReplace; + PREPLACE_END EndReplace; + PREPLACE_MIRROR_PHYSICAL_MEMORY MirrorPhysicalMemory; + PREPLACE_SET_PROCESSOR_ID SetProcessorId; + PREPLACE_SWAP Swap; + PREPLACE_INITIATE_HARDWARE_MIRROR InitiateHardwareMirror; + PREPLACE_MIRROR_PLATFORM_MEMORY MirrorPlatformMemory; + PREPLACE_GET_MEMORY_DESTINATION GetMemoryDestination; + PREPLACE_ENABLE_DISABLE_HARDWARE_QUIESCE EnableDisableHardwareQuiesce; +} PNP_REPLACE_DRIVER_INTERFACE, *PPNP_REPLACE_DRIVER_INTERFACE; + +typedef NTSTATUS +(NTAPI *PREPLACE_DRIVER_INIT)( + IN OUT PPNP_REPLACE_DRIVER_INTERFACE Interface, + IN PVOID Unused); + typedef enum _DEVICE_USAGE_NOTIFICATION_TYPE { DeviceUsageTypeUndefined, DeviceUsageTypePaging, @@ -3680,9 +4861,9 @@ typedef enum _DEVICE_USAGE_NOTIFICATION_TYPE { } DEVICE_USAGE_NOTIFICATION_TYPE; typedef struct _POWER_SEQUENCE { - ULONG SequenceD1; - ULONG SequenceD2; - ULONG SequenceD3; + ULONG SequenceD1; + ULONG SequenceD2; + ULONG SequenceD3; } POWER_SEQUENCE, *PPOWER_SEQUENCE; typedef enum { @@ -3718,16 +4899,27 @@ typedef enum _IO_NOTIFICATION_EVENT_CATEGORY { EventCategoryTargetDeviceChange } IO_NOTIFICATION_EVENT_CATEGORY; +typedef enum _IO_PRIORITY_HINT { + IoPriorityVeryLow = 0, + IoPriorityLow, + IoPriorityNormal, + IoPriorityHigh, + IoPriorityCritical, + MaxIoPriorityTypes +} IO_PRIORITY_HINT; + #define PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES 0x00000001 typedef NTSTATUS -(DDKAPI *PDRIVER_NOTIFICATION_CALLBACK_ROUTINE)( +(NTAPI DRIVER_NOTIFICATION_CALLBACK_ROUTINE)( IN PVOID NotificationStructure, IN PVOID Context); +typedef DRIVER_NOTIFICATION_CALLBACK_ROUTINE *PDRIVER_NOTIFICATION_CALLBACK_ROUTINE; typedef VOID -(DDKAPI *PDEVICE_CHANGE_COMPLETE_CALLBACK)( +(NTAPI DEVICE_CHANGE_COMPLETE_CALLBACK)( IN PVOID Context); +typedef DEVICE_CHANGE_COMPLETE_CALLBACK *PDEVICE_CHANGE_COMPLETE_CALLBACK; typedef enum _FILE_INFORMATION_CLASS { FileDirectoryInformation = 1, @@ -3789,35 +4981,59 @@ typedef enum _FILE_INFORMATION_CLASS { } FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS; typedef struct _FILE_POSITION_INFORMATION { - LARGE_INTEGER CurrentByteOffset; + LARGE_INTEGER CurrentByteOffset; } FILE_POSITION_INFORMATION, *PFILE_POSITION_INFORMATION; -#include typedef struct _FILE_BASIC_INFORMATION { - LARGE_INTEGER CreationTime; - LARGE_INTEGER LastAccessTime; - LARGE_INTEGER LastWriteTime; - LARGE_INTEGER ChangeTime; - ULONG FileAttributes; + LARGE_INTEGER CreationTime; + LARGE_INTEGER LastAccessTime; + LARGE_INTEGER LastWriteTime; + LARGE_INTEGER ChangeTime; + ULONG FileAttributes; } FILE_BASIC_INFORMATION, *PFILE_BASIC_INFORMATION; -#include + +typedef struct _FILE_IO_PRIORITY_HINT_INFORMATION { + IO_PRIORITY_HINT PriorityHint; +} FILE_IO_PRIORITY_HINT_INFORMATION, *PFILE_IO_PRIORITY_HINT_INFORMATION; + +typedef struct _FILE_IO_COMPLETION_NOTIFICATION_INFORMATION { + ULONG Flags; +} FILE_IO_COMPLETION_NOTIFICATION_INFORMATION, *PFILE_IO_COMPLETION_NOTIFICATION_INFORMATION; + +typedef struct _FILE_IOSTATUSBLOCK_RANGE_INFORMATION { + PUCHAR IoStatusBlockRange; + ULONG Length; +} FILE_IOSTATUSBLOCK_RANGE_INFORMATION, *PFILE_IOSTATUSBLOCK_RANGE_INFORMATION; + +typedef struct _FILE_IS_REMOTE_DEVICE_INFORMATION { + BOOLEAN IsRemote; +} FILE_IS_REMOTE_DEVICE_INFORMATION, *PFILE_IS_REMOTE_DEVICE_INFORMATION; + +typedef struct _FILE_NUMA_NODE_INFORMATION { + USHORT NodeNumber; +} FILE_NUMA_NODE_INFORMATION, *PFILE_NUMA_NODE_INFORMATION; + +typedef struct _FILE_PROCESS_IDS_USING_FILE_INFORMATION { + ULONG NumberOfProcessIdsInList; + ULONG_PTR ProcessIdList[1]; +} FILE_PROCESS_IDS_USING_FILE_INFORMATION, *PFILE_PROCESS_IDS_USING_FILE_INFORMATION; typedef struct _FILE_STANDARD_INFORMATION { - LARGE_INTEGER AllocationSize; - LARGE_INTEGER EndOfFile; - ULONG NumberOfLinks; - BOOLEAN DeletePending; - BOOLEAN Directory; + LARGE_INTEGER AllocationSize; + LARGE_INTEGER EndOfFile; + ULONG NumberOfLinks; + BOOLEAN DeletePending; + BOOLEAN Directory; } FILE_STANDARD_INFORMATION, *PFILE_STANDARD_INFORMATION; typedef struct _FILE_NETWORK_OPEN_INFORMATION { - LARGE_INTEGER CreationTime; - LARGE_INTEGER LastAccessTime; - LARGE_INTEGER LastWriteTime; - LARGE_INTEGER ChangeTime; - LARGE_INTEGER AllocationSize; - LARGE_INTEGER EndOfFile; - ULONG FileAttributes; + LARGE_INTEGER CreationTime; + LARGE_INTEGER LastAccessTime; + LARGE_INTEGER LastWriteTime; + LARGE_INTEGER ChangeTime; + LARGE_INTEGER AllocationSize; + LARGE_INTEGER EndOfFile; + ULONG FileAttributes; } FILE_NETWORK_OPEN_INFORMATION, *PFILE_NETWORK_OPEN_INFORMATION; typedef enum _FSINFOCLASS { @@ -3835,321 +5051,329 @@ typedef enum _FSINFOCLASS { } FS_INFORMATION_CLASS, *PFS_INFORMATION_CLASS; typedef struct _FILE_FS_DEVICE_INFORMATION { - DEVICE_TYPE DeviceType; - ULONG Characteristics; + DEVICE_TYPE DeviceType; + ULONG Characteristics; } FILE_FS_DEVICE_INFORMATION, *PFILE_FS_DEVICE_INFORMATION; typedef struct _FILE_FULL_EA_INFORMATION { - ULONG NextEntryOffset; - UCHAR Flags; - UCHAR EaNameLength; - USHORT EaValueLength; - CHAR EaName[1]; + ULONG NextEntryOffset; + UCHAR Flags; + UCHAR EaNameLength; + USHORT EaValueLength; + CHAR EaName[1]; } FILE_FULL_EA_INFORMATION, *PFILE_FULL_EA_INFORMATION; +typedef struct _FILE_SFIO_RESERVE_INFORMATION { + ULONG RequestsPerPeriod; + ULONG Period; + BOOLEAN RetryFailures; + BOOLEAN Discardable; + ULONG RequestSize; + ULONG NumOutstandingRequests; +} FILE_SFIO_RESERVE_INFORMATION, *PFILE_SFIO_RESERVE_INFORMATION; + +typedef struct _FILE_SFIO_VOLUME_INFORMATION { + ULONG MaximumRequestsPerPeriod; + ULONG MinimumPeriod; + ULONG MinimumTransferSize; +} FILE_SFIO_VOLUME_INFORMATION, *PFILE_SFIO_VOLUME_INFORMATION; + +#define FILE_SKIP_COMPLETION_PORT_ON_SUCCESS 0x1 +#define FILE_SKIP_SET_EVENT_ON_HANDLE 0x2 +#define FILE_SKIP_SET_USER_EVENT_ON_FAST_IO 0x4 + #define FM_LOCK_BIT (0x1) #define FM_LOCK_BIT_V (0x0) #define FM_LOCK_WAITER_WOKEN (0x2) #define FM_LOCK_WAITER_INC (0x4) -typedef ULONG_PTR ERESOURCE_THREAD, *PERESOURCE_THREAD; - -typedef struct _OWNER_ENTRY { - ERESOURCE_THREAD OwnerThread; - _ANONYMOUS_UNION union { - LONG OwnerCount; - ULONG TableSize; - } DUMMYUNIONNAME; -} OWNER_ENTRY, *POWNER_ENTRY; - -typedef struct _ERESOURCE -{ - LIST_ENTRY SystemResourcesList; - POWNER_ENTRY OwnerTable; - SHORT ActiveCount; - USHORT Flag; - volatile PKSEMAPHORE SharedWaiters; - volatile PKEVENT ExclusiveWaiters; - OWNER_ENTRY OwnerEntry; - ULONG ActiveEntries; - ULONG ContentionCount; - ULONG NumberOfSharedWaiters; - ULONG NumberOfExclusiveWaiters; - __GNU_EXTENSION union - { - PVOID Address; - ULONG_PTR CreatorBackTraceIndex; - }; - KSPIN_LOCK SpinLock; -} ERESOURCE, *PERESOURCE; - -/* ERESOURCE.Flag */ -#define ResourceNeverExclusive 0x0010 -#define ResourceReleaseByOtherThread 0x0020 -#define ResourceOwnedExclusive 0x0080 - -#define RESOURCE_HASH_TABLE_SIZE 64 +typedef BOOLEAN +(NTAPI FAST_IO_CHECK_IF_POSSIBLE)( + IN struct _FILE_OBJECT *FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN BOOLEAN Wait, + IN ULONG LockKey, + IN BOOLEAN CheckForReadOperation, + OUT PIO_STATUS_BLOCK IoStatus, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_CHECK_IF_POSSIBLE *PFAST_IO_CHECK_IF_POSSIBLE; typedef BOOLEAN -(DDKAPI *PFAST_IO_CHECK_IF_POSSIBLE)( - IN struct _FILE_OBJECT *FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN BOOLEAN Wait, - IN ULONG LockKey, - IN BOOLEAN CheckForReadOperation, - OUT PIO_STATUS_BLOCK IoStatus, - IN struct _DEVICE_OBJECT *DeviceObject); +(NTAPI FAST_IO_READ)( + IN struct _FILE_OBJECT *FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN BOOLEAN Wait, + IN ULONG LockKey, + OUT PVOID Buffer, + OUT PIO_STATUS_BLOCK IoStatus, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_READ *PFAST_IO_READ; typedef BOOLEAN -(DDKAPI *PFAST_IO_READ)( - IN struct _FILE_OBJECT *FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN BOOLEAN Wait, - IN ULONG LockKey, - OUT PVOID Buffer, - OUT PIO_STATUS_BLOCK IoStatus, - IN struct _DEVICE_OBJECT *DeviceObject); +(NTAPI FAST_IO_WRITE)( + IN struct _FILE_OBJECT *FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN BOOLEAN Wait, + IN ULONG LockKey, + IN PVOID Buffer, + OUT PIO_STATUS_BLOCK IoStatus, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_WRITE *PFAST_IO_WRITE; typedef BOOLEAN -(DDKAPI *PFAST_IO_WRITE)( - IN struct _FILE_OBJECT *FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN BOOLEAN Wait, - IN ULONG LockKey, - IN PVOID Buffer, - OUT PIO_STATUS_BLOCK IoStatus, - IN struct _DEVICE_OBJECT *DeviceObject); +(NTAPI FAST_IO_QUERY_BASIC_INFO)( + IN struct _FILE_OBJECT *FileObject, + IN BOOLEAN Wait, + OUT PFILE_BASIC_INFORMATION Buffer, + OUT PIO_STATUS_BLOCK IoStatus, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_QUERY_BASIC_INFO *PFAST_IO_QUERY_BASIC_INFO; typedef BOOLEAN -(DDKAPI *PFAST_IO_QUERY_BASIC_INFO)( - IN struct _FILE_OBJECT *FileObject, - IN BOOLEAN Wait, - OUT PFILE_BASIC_INFORMATION Buffer, - OUT PIO_STATUS_BLOCK IoStatus, - IN struct _DEVICE_OBJECT *DeviceObject); +(NTAPI FAST_IO_QUERY_STANDARD_INFO)( + IN struct _FILE_OBJECT *FileObject, + IN BOOLEAN Wait, + OUT PFILE_STANDARD_INFORMATION Buffer, + OUT PIO_STATUS_BLOCK IoStatus, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_QUERY_STANDARD_INFO *PFAST_IO_QUERY_STANDARD_INFO; typedef BOOLEAN -(DDKAPI *PFAST_IO_QUERY_STANDARD_INFO)( - IN struct _FILE_OBJECT *FileObject, - IN BOOLEAN Wait, - OUT PFILE_STANDARD_INFORMATION Buffer, - OUT PIO_STATUS_BLOCK IoStatus, - IN struct _DEVICE_OBJECT *DeviceObject); +(NTAPI FAST_IO_LOCK)( + IN struct _FILE_OBJECT *FileObject, + IN PLARGE_INTEGER FileOffset, + IN PLARGE_INTEGER Length, + PEPROCESS ProcessId, + ULONG Key, + BOOLEAN FailImmediately, + BOOLEAN ExclusiveLock, + OUT PIO_STATUS_BLOCK IoStatus, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_LOCK *PFAST_IO_LOCK; typedef BOOLEAN -(DDKAPI *PFAST_IO_LOCK)( - IN struct _FILE_OBJECT *FileObject, - IN PLARGE_INTEGER FileOffset, - IN PLARGE_INTEGER Length, - PEPROCESS ProcessId, - ULONG Key, - BOOLEAN FailImmediately, - BOOLEAN ExclusiveLock, - OUT PIO_STATUS_BLOCK IoStatus, - IN struct _DEVICE_OBJECT *DeviceObject); +(NTAPI FAST_IO_UNLOCK_SINGLE)( + IN struct _FILE_OBJECT *FileObject, + IN PLARGE_INTEGER FileOffset, + IN PLARGE_INTEGER Length, + PEPROCESS ProcessId, + ULONG Key, + OUT PIO_STATUS_BLOCK IoStatus, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_UNLOCK_SINGLE *PFAST_IO_UNLOCK_SINGLE; typedef BOOLEAN -(DDKAPI *PFAST_IO_UNLOCK_SINGLE)( - IN struct _FILE_OBJECT *FileObject, - IN PLARGE_INTEGER FileOffset, - IN PLARGE_INTEGER Length, - PEPROCESS ProcessId, - ULONG Key, - OUT PIO_STATUS_BLOCK IoStatus, - IN struct _DEVICE_OBJECT *DeviceObject); +(NTAPI FAST_IO_UNLOCK_ALL)( + IN struct _FILE_OBJECT *FileObject, + PEPROCESS ProcessId, + OUT PIO_STATUS_BLOCK IoStatus, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_UNLOCK_ALL *PFAST_IO_UNLOCK_ALL; typedef BOOLEAN -(DDKAPI *PFAST_IO_UNLOCK_ALL)( - IN struct _FILE_OBJECT *FileObject, - PEPROCESS ProcessId, - OUT PIO_STATUS_BLOCK IoStatus, - IN struct _DEVICE_OBJECT *DeviceObject); +(NTAPI FAST_IO_UNLOCK_ALL_BY_KEY)( + IN struct _FILE_OBJECT *FileObject, + PVOID ProcessId, + ULONG Key, + OUT PIO_STATUS_BLOCK IoStatus, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_UNLOCK_ALL_BY_KEY *PFAST_IO_UNLOCK_ALL_BY_KEY; typedef BOOLEAN -(DDKAPI *PFAST_IO_UNLOCK_ALL_BY_KEY)( - IN struct _FILE_OBJECT *FileObject, - PVOID ProcessId, - ULONG Key, - OUT PIO_STATUS_BLOCK IoStatus, - IN struct _DEVICE_OBJECT *DeviceObject); - -typedef BOOLEAN -(DDKAPI *PFAST_IO_DEVICE_CONTROL)( - IN struct _FILE_OBJECT *FileObject, - IN BOOLEAN Wait, - IN PVOID InputBuffer OPTIONAL, - IN ULONG InputBufferLength, - OUT PVOID OutputBuffer OPTIONAL, - IN ULONG OutputBufferLength, - IN ULONG IoControlCode, - OUT PIO_STATUS_BLOCK IoStatus, - IN struct _DEVICE_OBJECT *DeviceObject); +(NTAPI FAST_IO_DEVICE_CONTROL)( + IN struct _FILE_OBJECT *FileObject, + IN BOOLEAN Wait, + IN PVOID InputBuffer OPTIONAL, + IN ULONG InputBufferLength, + OUT PVOID OutputBuffer OPTIONAL, + IN ULONG OutputBufferLength, + IN ULONG IoControlCode, + OUT PIO_STATUS_BLOCK IoStatus, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_DEVICE_CONTROL *PFAST_IO_DEVICE_CONTROL; typedef VOID -(DDKAPI *PFAST_IO_ACQUIRE_FILE)( - IN struct _FILE_OBJECT *FileObject); +(NTAPI FAST_IO_ACQUIRE_FILE)( + IN struct _FILE_OBJECT *FileObject); +typedef FAST_IO_ACQUIRE_FILE *PFAST_IO_ACQUIRE_FILE; typedef VOID -(DDKAPI *PFAST_IO_RELEASE_FILE)( - IN struct _FILE_OBJECT *FileObject); +(NTAPI FAST_IO_RELEASE_FILE)( + IN struct _FILE_OBJECT *FileObject); +typedef FAST_IO_RELEASE_FILE *PFAST_IO_RELEASE_FILE; typedef VOID -(DDKAPI *PFAST_IO_DETACH_DEVICE)( - IN struct _DEVICE_OBJECT *SourceDevice, - IN struct _DEVICE_OBJECT *TargetDevice); +(NTAPI FAST_IO_DETACH_DEVICE)( + IN struct _DEVICE_OBJECT *SourceDevice, + IN struct _DEVICE_OBJECT *TargetDevice); +typedef FAST_IO_DETACH_DEVICE *PFAST_IO_DETACH_DEVICE; typedef BOOLEAN -(DDKAPI *PFAST_IO_QUERY_NETWORK_OPEN_INFO)( - IN struct _FILE_OBJECT *FileObject, - IN BOOLEAN Wait, - OUT struct _FILE_NETWORK_OPEN_INFORMATION *Buffer, - OUT struct _IO_STATUS_BLOCK *IoStatus, - IN struct _DEVICE_OBJECT *DeviceObject); +(NTAPI FAST_IO_QUERY_NETWORK_OPEN_INFO)( + IN struct _FILE_OBJECT *FileObject, + IN BOOLEAN Wait, + OUT struct _FILE_NETWORK_OPEN_INFORMATION *Buffer, + OUT struct _IO_STATUS_BLOCK *IoStatus, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_QUERY_NETWORK_OPEN_INFO *PFAST_IO_QUERY_NETWORK_OPEN_INFO; typedef NTSTATUS -(DDKAPI *PFAST_IO_ACQUIRE_FOR_MOD_WRITE)( - IN struct _FILE_OBJECT *FileObject, - IN PLARGE_INTEGER EndingOffset, - OUT struct _ERESOURCE **ResourceToRelease, - IN struct _DEVICE_OBJECT *DeviceObject); +(NTAPI FAST_IO_ACQUIRE_FOR_MOD_WRITE)( + IN struct _FILE_OBJECT *FileObject, + IN PLARGE_INTEGER EndingOffset, + OUT struct _ERESOURCE **ResourceToRelease, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_ACQUIRE_FOR_MOD_WRITE *PFAST_IO_ACQUIRE_FOR_MOD_WRITE; typedef BOOLEAN -(DDKAPI *PFAST_IO_MDL_READ)( - IN struct _FILE_OBJECT *FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN ULONG LockKey, - OUT PMDL *MdlChain, - OUT PIO_STATUS_BLOCK IoStatus, - IN struct _DEVICE_OBJECT *DeviceObject); +(NTAPI FAST_IO_MDL_READ)( + IN struct _FILE_OBJECT *FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN ULONG LockKey, + OUT PMDL *MdlChain, + OUT PIO_STATUS_BLOCK IoStatus, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_MDL_READ *PFAST_IO_MDL_READ; typedef BOOLEAN -(DDKAPI *PFAST_IO_MDL_READ_COMPLETE)( +(NTAPI FAST_IO_MDL_READ_COMPLETE)( IN struct _FILE_OBJECT *FileObject, IN PMDL MdlChain, IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_MDL_READ_COMPLETE *PFAST_IO_MDL_READ_COMPLETE; typedef BOOLEAN -(DDKAPI *PFAST_IO_PREPARE_MDL_WRITE)( - IN struct _FILE_OBJECT *FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN ULONG LockKey, - OUT PMDL *MdlChain, - OUT PIO_STATUS_BLOCK IoStatus, - IN struct _DEVICE_OBJECT *DeviceObject); +(NTAPI FAST_IO_PREPARE_MDL_WRITE)( + IN struct _FILE_OBJECT *FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN ULONG LockKey, + OUT PMDL *MdlChain, + OUT PIO_STATUS_BLOCK IoStatus, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_PREPARE_MDL_WRITE *PFAST_IO_PREPARE_MDL_WRITE; typedef BOOLEAN -(DDKAPI *PFAST_IO_MDL_WRITE_COMPLETE)( - IN struct _FILE_OBJECT *FileObject, - IN PLARGE_INTEGER FileOffset, - IN PMDL MdlChain, - IN struct _DEVICE_OBJECT *DeviceObject); +(NTAPI FAST_IO_MDL_WRITE_COMPLETE)( + IN struct _FILE_OBJECT *FileObject, + IN PLARGE_INTEGER FileOffset, + IN PMDL MdlChain, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_MDL_WRITE_COMPLETE *PFAST_IO_MDL_WRITE_COMPLETE; typedef BOOLEAN -(DDKAPI *PFAST_IO_READ_COMPRESSED)( - IN struct _FILE_OBJECT *FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN ULONG LockKey, - OUT PVOID Buffer, - OUT PMDL *MdlChain, - OUT PIO_STATUS_BLOCK IoStatus, - OUT struct _COMPRESSED_DATA_INFO *CompressedDataInfo, - IN ULONG CompressedDataInfoLength, - IN struct _DEVICE_OBJECT *DeviceObject); +(NTAPI FAST_IO_READ_COMPRESSED)( + IN struct _FILE_OBJECT *FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN ULONG LockKey, + OUT PVOID Buffer, + OUT PMDL *MdlChain, + OUT PIO_STATUS_BLOCK IoStatus, + OUT struct _COMPRESSED_DATA_INFO *CompressedDataInfo, + IN ULONG CompressedDataInfoLength, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_READ_COMPRESSED *PFAST_IO_READ_COMPRESSED; typedef BOOLEAN -(DDKAPI *PFAST_IO_WRITE_COMPRESSED)( - IN struct _FILE_OBJECT *FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN ULONG LockKey, - IN PVOID Buffer, - OUT PMDL *MdlChain, - OUT PIO_STATUS_BLOCK IoStatus, - IN struct _COMPRESSED_DATA_INFO *CompressedDataInfo, - IN ULONG CompressedDataInfoLength, - IN struct _DEVICE_OBJECT *DeviceObject); +(NTAPI FAST_IO_WRITE_COMPRESSED)( + IN struct _FILE_OBJECT *FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN ULONG LockKey, + IN PVOID Buffer, + OUT PMDL *MdlChain, + OUT PIO_STATUS_BLOCK IoStatus, + IN struct _COMPRESSED_DATA_INFO *CompressedDataInfo, + IN ULONG CompressedDataInfoLength, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_WRITE_COMPRESSED *PFAST_IO_WRITE_COMPRESSED; typedef BOOLEAN -(DDKAPI *PFAST_IO_MDL_READ_COMPLETE_COMPRESSED)( - IN struct _FILE_OBJECT *FileObject, - IN PMDL MdlChain, - IN struct _DEVICE_OBJECT *DeviceObject); +(NTAPI FAST_IO_MDL_READ_COMPLETE_COMPRESSED)( + IN struct _FILE_OBJECT *FileObject, + IN PMDL MdlChain, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_MDL_READ_COMPLETE_COMPRESSED *PFAST_IO_MDL_READ_COMPLETE_COMPRESSED; typedef BOOLEAN -(DDKAPI *PFAST_IO_MDL_WRITE_COMPLETE_COMPRESSED)( - IN struct _FILE_OBJECT *FileObject, - IN PLARGE_INTEGER FileOffset, - IN PMDL MdlChain, - IN struct _DEVICE_OBJECT *DeviceObject); +(NTAPI FAST_IO_MDL_WRITE_COMPLETE_COMPRESSED)( + IN struct _FILE_OBJECT *FileObject, + IN PLARGE_INTEGER FileOffset, + IN PMDL MdlChain, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_MDL_WRITE_COMPLETE_COMPRESSED *PFAST_IO_MDL_WRITE_COMPLETE_COMPRESSED; typedef BOOLEAN -(DDKAPI *PFAST_IO_QUERY_OPEN)( - IN struct _IRP *Irp, - OUT PFILE_NETWORK_OPEN_INFORMATION NetworkInformation, - IN struct _DEVICE_OBJECT *DeviceObject); +(NTAPI FAST_IO_QUERY_OPEN)( + IN struct _IRP *Irp, + OUT PFILE_NETWORK_OPEN_INFORMATION NetworkInformation, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_QUERY_OPEN *PFAST_IO_QUERY_OPEN; typedef NTSTATUS -(DDKAPI *PFAST_IO_RELEASE_FOR_MOD_WRITE)( - IN struct _FILE_OBJECT *FileObject, - IN struct _ERESOURCE *ResourceToRelease, - IN struct _DEVICE_OBJECT *DeviceObject); +(NTAPI FAST_IO_RELEASE_FOR_MOD_WRITE)( + IN struct _FILE_OBJECT *FileObject, + IN struct _ERESOURCE *ResourceToRelease, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_RELEASE_FOR_MOD_WRITE *PFAST_IO_RELEASE_FOR_MOD_WRITE; typedef NTSTATUS -(DDKAPI *PFAST_IO_ACQUIRE_FOR_CCFLUSH)( - IN struct _FILE_OBJECT *FileObject, - IN struct _DEVICE_OBJECT *DeviceObject); +(NTAPI FAST_IO_ACQUIRE_FOR_CCFLUSH)( + IN struct _FILE_OBJECT *FileObject, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_ACQUIRE_FOR_CCFLUSH *PFAST_IO_ACQUIRE_FOR_CCFLUSH; typedef NTSTATUS -(DDKAPI *PFAST_IO_RELEASE_FOR_CCFLUSH) ( - IN struct _FILE_OBJECT *FileObject, - IN struct _DEVICE_OBJECT *DeviceObject); +(NTAPI FAST_IO_RELEASE_FOR_CCFLUSH)( + IN struct _FILE_OBJECT *FileObject, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_RELEASE_FOR_CCFLUSH *PFAST_IO_RELEASE_FOR_CCFLUSH; typedef struct _FAST_IO_DISPATCH { - ULONG SizeOfFastIoDispatch; - PFAST_IO_CHECK_IF_POSSIBLE FastIoCheckIfPossible; - PFAST_IO_READ FastIoRead; - PFAST_IO_WRITE FastIoWrite; - PFAST_IO_QUERY_BASIC_INFO FastIoQueryBasicInfo; - PFAST_IO_QUERY_STANDARD_INFO FastIoQueryStandardInfo; - PFAST_IO_LOCK FastIoLock; - PFAST_IO_UNLOCK_SINGLE FastIoUnlockSingle; - PFAST_IO_UNLOCK_ALL FastIoUnlockAll; - PFAST_IO_UNLOCK_ALL_BY_KEY FastIoUnlockAllByKey; - PFAST_IO_DEVICE_CONTROL FastIoDeviceControl; - PFAST_IO_ACQUIRE_FILE AcquireFileForNtCreateSection; - PFAST_IO_RELEASE_FILE ReleaseFileForNtCreateSection; - PFAST_IO_DETACH_DEVICE FastIoDetachDevice; - PFAST_IO_QUERY_NETWORK_OPEN_INFO FastIoQueryNetworkOpenInfo; - PFAST_IO_ACQUIRE_FOR_MOD_WRITE AcquireForModWrite; - PFAST_IO_MDL_READ MdlRead; - PFAST_IO_MDL_READ_COMPLETE MdlReadComplete; - PFAST_IO_PREPARE_MDL_WRITE PrepareMdlWrite; - PFAST_IO_MDL_WRITE_COMPLETE MdlWriteComplete; - PFAST_IO_READ_COMPRESSED FastIoReadCompressed; - PFAST_IO_WRITE_COMPRESSED FastIoWriteCompressed; - PFAST_IO_MDL_READ_COMPLETE_COMPRESSED MdlReadCompleteCompressed; - PFAST_IO_MDL_WRITE_COMPLETE_COMPRESSED MdlWriteCompleteCompressed; - PFAST_IO_QUERY_OPEN FastIoQueryOpen; - PFAST_IO_RELEASE_FOR_MOD_WRITE ReleaseForModWrite; - PFAST_IO_ACQUIRE_FOR_CCFLUSH AcquireForCcFlush; - PFAST_IO_RELEASE_FOR_CCFLUSH ReleaseForCcFlush; + ULONG SizeOfFastIoDispatch; + PFAST_IO_CHECK_IF_POSSIBLE FastIoCheckIfPossible; + PFAST_IO_READ FastIoRead; + PFAST_IO_WRITE FastIoWrite; + PFAST_IO_QUERY_BASIC_INFO FastIoQueryBasicInfo; + PFAST_IO_QUERY_STANDARD_INFO FastIoQueryStandardInfo; + PFAST_IO_LOCK FastIoLock; + PFAST_IO_UNLOCK_SINGLE FastIoUnlockSingle; + PFAST_IO_UNLOCK_ALL FastIoUnlockAll; + PFAST_IO_UNLOCK_ALL_BY_KEY FastIoUnlockAllByKey; + PFAST_IO_DEVICE_CONTROL FastIoDeviceControl; + PFAST_IO_ACQUIRE_FILE AcquireFileForNtCreateSection; + PFAST_IO_RELEASE_FILE ReleaseFileForNtCreateSection; + PFAST_IO_DETACH_DEVICE FastIoDetachDevice; + PFAST_IO_QUERY_NETWORK_OPEN_INFO FastIoQueryNetworkOpenInfo; + PFAST_IO_ACQUIRE_FOR_MOD_WRITE AcquireForModWrite; + PFAST_IO_MDL_READ MdlRead; + PFAST_IO_MDL_READ_COMPLETE MdlReadComplete; + PFAST_IO_PREPARE_MDL_WRITE PrepareMdlWrite; + PFAST_IO_MDL_WRITE_COMPLETE MdlWriteComplete; + PFAST_IO_READ_COMPRESSED FastIoReadCompressed; + PFAST_IO_WRITE_COMPRESSED FastIoWriteCompressed; + PFAST_IO_MDL_READ_COMPLETE_COMPRESSED MdlReadCompleteCompressed; + PFAST_IO_MDL_WRITE_COMPLETE_COMPRESSED MdlWriteCompleteCompressed; + PFAST_IO_QUERY_OPEN FastIoQueryOpen; + PFAST_IO_RELEASE_FOR_MOD_WRITE ReleaseForModWrite; + PFAST_IO_ACQUIRE_FOR_CCFLUSH AcquireForCcFlush; + PFAST_IO_RELEASE_FOR_CCFLUSH ReleaseForCcFlush; } FAST_IO_DISPATCH, *PFAST_IO_DISPATCH; typedef struct _SECTION_OBJECT_POINTERS { - PVOID DataSectionObject; - PVOID SharedCacheMap; - PVOID ImageSectionObject; + PVOID DataSectionObject; + PVOID SharedCacheMap; + PVOID ImageSectionObject; } SECTION_OBJECT_POINTERS, *PSECTION_OBJECT_POINTERS; typedef struct _IO_COMPLETION_CONTEXT { - PVOID Port; - PVOID Key; + PVOID Port; + PVOID Key; } IO_COMPLETION_CONTEXT, *PIO_COMPLETION_CONTEXT; /* FILE_OBJECT.Flags */ @@ -4182,6 +5406,7 @@ typedef struct _IO_COMPLETION_CONTEXT { #define FO_SKIP_COMPLETION_PORT 0x02000000 #define FO_SKIP_SET_EVENT 0x04000000 #define FO_SKIP_SET_FAST_IO 0x08000000 +#define FO_FLAGS_VALID_ONLY_DURING_CREATE FO_DISALLOW_EXCLUSIVE /* VPB.Flags */ #define VPB_MOUNTED 0x0001 @@ -4196,12 +5421,18 @@ typedef struct _IO_COMPLETION_CONTEXT { #define SL_FORCE_ACCESS_CHECK 0x01 #define SL_OPEN_PAGING_FILE 0x02 #define SL_OPEN_TARGET_DIRECTORY 0x04 +#define SL_STOP_ON_SYMLINK 0x08 #define SL_CASE_SENSITIVE 0x80 #define SL_KEY_SPECIFIED 0x01 #define SL_OVERRIDE_VERIFY_VOLUME 0x02 #define SL_WRITE_THROUGH 0x04 #define SL_FT_SEQUENTIAL_WRITE 0x08 +#define SL_FORCE_DIRECT_WRITE 0x10 +#define SL_REALTIME_STREAM 0x20 + +#define SL_READ_ACCESS_GRANTED 0x01 +#define SL_WRITE_ACCESS_GRANTED 0x04 #define SL_FAIL_IMMEDIATELY 0x01 #define SL_EXCLUSIVE_LOCK 0x02 @@ -4219,6 +5450,8 @@ typedef struct _IO_COMPLETION_CONTEXT { #define DEVICE_TYPE_FROM_CTL_CODE(ctl) (((ULONG) (ctl & 0xffff0000)) >> 16) +#define METHOD_FROM_CTL_CODE(ctrlCode) ((ULONG)(ctrlCode & 3)) + #define IRP_NOCACHE 0x00000001 #define IRP_PAGING_IO 0x00000002 #define IRP_MOUNT_COMPLETION 0x00000002 @@ -4304,6 +5537,9 @@ typedef struct _IO_COMPLETION_CONTEXT { #define IRP_MN_QUERY_BUS_INFORMATION 0x15 #define IRP_MN_DEVICE_USAGE_NOTIFICATION 0x16 #define IRP_MN_SURPRISE_REMOVAL 0x17 +#if (NTDDI_VERSION >= NTDDI_WIN7) +#define IRP_MN_DEVICE_ENUMERATED 0x19 +#endif #define IRP_MN_WAIT_WAKE 0x00 #define IRP_MN_POWER_SEQUENCE 0x01 @@ -4323,63 +5559,62 @@ typedef struct _IO_COMPLETION_CONTEXT { #define IRP_MN_REGINFO_EX 0x0b -typedef struct _FILE_OBJECT -{ - CSHORT Type; - CSHORT Size; - PDEVICE_OBJECT DeviceObject; - PVPB Vpb; - PVOID FsContext; - PVOID FsContext2; - PSECTION_OBJECT_POINTERS SectionObjectPointer; - PVOID PrivateCacheMap; - NTSTATUS FinalStatus; - struct _FILE_OBJECT *RelatedFileObject; - BOOLEAN LockOperation; - BOOLEAN DeletePending; - BOOLEAN ReadAccess; - BOOLEAN WriteAccess; - BOOLEAN DeleteAccess; - BOOLEAN SharedRead; - BOOLEAN SharedWrite; - BOOLEAN SharedDelete; - ULONG Flags; - UNICODE_STRING FileName; - LARGE_INTEGER CurrentByteOffset; - volatile ULONG Waiters; - volatile ULONG Busy; - PVOID LastLock; - KEVENT Lock; - KEVENT Event; - volatile PIO_COMPLETION_CONTEXT CompletionContext; - KSPIN_LOCK IrpListLock; - LIST_ENTRY IrpList; - volatile PVOID FileObjectExtension; +typedef struct _FILE_OBJECT { + CSHORT Type; + CSHORT Size; + PDEVICE_OBJECT DeviceObject; + PVPB Vpb; + PVOID FsContext; + PVOID FsContext2; + PSECTION_OBJECT_POINTERS SectionObjectPointer; + PVOID PrivateCacheMap; + NTSTATUS FinalStatus; + struct _FILE_OBJECT *RelatedFileObject; + BOOLEAN LockOperation; + BOOLEAN DeletePending; + BOOLEAN ReadAccess; + BOOLEAN WriteAccess; + BOOLEAN DeleteAccess; + BOOLEAN SharedRead; + BOOLEAN SharedWrite; + BOOLEAN SharedDelete; + ULONG Flags; + UNICODE_STRING FileName; + LARGE_INTEGER CurrentByteOffset; + volatile ULONG Waiters; + volatile ULONG Busy; + PVOID LastLock; + KEVENT Lock; + KEVENT Event; + volatile PIO_COMPLETION_CONTEXT CompletionContext; + KSPIN_LOCK IrpListLock; + LIST_ENTRY IrpList; + volatile PVOID FileObjectExtension; } FILE_OBJECT, *PFILE_OBJECT; typedef struct _IO_ERROR_LOG_PACKET { - UCHAR MajorFunctionCode; - UCHAR RetryCount; - USHORT DumpDataSize; - USHORT NumberOfStrings; - USHORT StringOffset; - USHORT EventCategory; - NTSTATUS ErrorCode; - ULONG UniqueErrorValue; - NTSTATUS FinalStatus; - ULONG SequenceNumber; - ULONG IoControlCode; - LARGE_INTEGER DeviceOffset; - ULONG DumpData[1]; + UCHAR MajorFunctionCode; + UCHAR RetryCount; + USHORT DumpDataSize; + USHORT NumberOfStrings; + USHORT StringOffset; + USHORT EventCategory; + NTSTATUS ErrorCode; + ULONG UniqueErrorValue; + NTSTATUS FinalStatus; + ULONG SequenceNumber; + ULONG IoControlCode; + LARGE_INTEGER DeviceOffset; + ULONG DumpData[1]; } IO_ERROR_LOG_PACKET, *PIO_ERROR_LOG_PACKET; typedef struct _IO_ERROR_LOG_MESSAGE { - USHORT Type; - USHORT Size; - USHORT DriverNameLength; - LARGE_INTEGER TimeStamp; - ULONG DriverNameOffset; - IO_ERROR_LOG_PACKET EntryData; + USHORT Type; + USHORT Size; + USHORT DriverNameLength; + LARGE_INTEGER TimeStamp; + ULONG DriverNameOffset; + IO_ERROR_LOG_PACKET EntryData; } IO_ERROR_LOG_MESSAGE, *PIO_ERROR_LOG_MESSAGE; #define ERROR_LOG_LIMIT_SIZE 240 @@ -4395,6 +5630,12 @@ typedef struct _IO_ERROR_LOG_MESSAGE { #define ERROR_LOG_MAXIMUM_SIZE (IO_ERROR_LOG_MESSAGE_LENGTH - \ IO_ERROR_LOG_MESSAGE_HEADER_LENGTH) +#ifdef _WIN64 +#define PORT_MAXIMUM_MESSAGE_LENGTH 512 +#else +#define PORT_MAXIMUM_MESSAGE_LENGTH 256 +#endif + typedef enum _DMA_WIDTH { Width8Bits, Width16Bits, @@ -4418,22 +5659,22 @@ typedef enum _DMA_SPEED { #define DEVICE_DESCRIPTION_VERSION2 0x0002 typedef struct _DEVICE_DESCRIPTION { - ULONG Version; - BOOLEAN Master; - BOOLEAN ScatterGather; - BOOLEAN DemandMode; - BOOLEAN AutoInitialize; - BOOLEAN Dma32BitAddresses; - BOOLEAN IgnoreCount; - BOOLEAN Reserved1; - BOOLEAN Dma64BitAddresses; - ULONG BusNumber; - ULONG DmaChannel; - INTERFACE_TYPE InterfaceType; - DMA_WIDTH DmaWidth; - DMA_SPEED DmaSpeed; - ULONG MaximumLength; - ULONG DmaPort; + ULONG Version; + BOOLEAN Master; + BOOLEAN ScatterGather; + BOOLEAN DemandMode; + BOOLEAN AutoInitialize; + BOOLEAN Dma32BitAddresses; + BOOLEAN IgnoreCount; + BOOLEAN Reserved1; + BOOLEAN Dma64BitAddresses; + ULONG BusNumber; + ULONG DmaChannel; + INTERFACE_TYPE InterfaceType; + DMA_WIDTH DmaWidth; + DMA_SPEED DmaSpeed; + ULONG MaximumLength; + ULONG DmaPort; } DEVICE_DESCRIPTION, *PDEVICE_DESCRIPTION; typedef enum _DEVICE_RELATION_TYPE { @@ -4447,21 +5688,20 @@ typedef enum _DEVICE_RELATION_TYPE { } DEVICE_RELATION_TYPE, *PDEVICE_RELATION_TYPE; typedef struct _DEVICE_RELATIONS { - ULONG Count; + ULONG Count; PDEVICE_OBJECT Objects[1]; } DEVICE_RELATIONS, *PDEVICE_RELATIONS; -typedef struct _DEVOBJ_EXTENSION -{ - CSHORT Type; - USHORT Size; - PDEVICE_OBJECT DeviceObject; +typedef struct _DEVOBJ_EXTENSION { + CSHORT Type; + USHORT Size; + PDEVICE_OBJECT DeviceObject; } DEVOBJ_EXTENSION, *PDEVOBJ_EXTENSION; typedef struct _SCATTER_GATHER_ELEMENT { - PHYSICAL_ADDRESS Address; - ULONG Length; - ULONG_PTR Reserved; + PHYSICAL_ADDRESS Address; + ULONG Length; + ULONG_PTR Reserved; } SCATTER_GATHER_ELEMENT, *PSCATTER_GATHER_ELEMENT; #if defined(_MSC_EXTENSIONS) @@ -4471,9 +5711,9 @@ typedef struct _SCATTER_GATHER_ELEMENT { #endif #pragma warning(disable:4200) typedef struct _SCATTER_GATHER_LIST { - ULONG NumberOfElements; - ULONG_PTR Reserved; - SCATTER_GATHER_ELEMENT Elements[1]; + ULONG NumberOfElements; + ULONG_PTR Reserved; + SCATTER_GATHER_ELEMENT Elements[1]; } SCATTER_GATHER_LIST, *PSCATTER_GATHER_LIST; #if _MSC_VER >= 1200 @@ -4490,16 +5730,16 @@ typedef struct _SCATTER_GATHER_LIST SCATTER_GATHER_LIST, *PSCATTER_GATHER_LIST; #endif typedef NTSTATUS -(DDKAPI DRIVER_ADD_DEVICE)( - IN struct _DRIVER_OBJECT *DriverObject, - IN struct _DEVICE_OBJECT *PhysicalDeviceObject); +(NTAPI DRIVER_ADD_DEVICE)( + IN struct _DRIVER_OBJECT *DriverObject, + IN struct _DEVICE_OBJECT *PhysicalDeviceObject); typedef DRIVER_ADD_DEVICE *PDRIVER_ADD_DEVICE; typedef struct _DRIVER_EXTENSION { - struct _DRIVER_OBJECT *DriverObject; - PDRIVER_ADD_DEVICE AddDevice; - ULONG Count; - UNICODE_STRING ServiceKeyName; + struct _DRIVER_OBJECT *DriverObject; + PDRIVER_ADD_DEVICE AddDevice; + ULONG Count; + UNICODE_STRING ServiceKeyName; } DRIVER_EXTENSION, *PDRIVER_EXTENSION; #define DRVO_UNLOAD_INVOKED 0x00000001 @@ -4507,320 +5747,319 @@ typedef struct _DRIVER_EXTENSION { #define DRVO_BUILTIN_DRIVER 0x00000004 typedef NTSTATUS -(DDKAPI DRIVER_INITIALIZE)( - IN struct _DRIVER_OBJECT *DriverObject, - IN PUNICODE_STRING RegistryPath); +(NTAPI DRIVER_INITIALIZE)( + IN struct _DRIVER_OBJECT *DriverObject, + IN PUNICODE_STRING RegistryPath); typedef DRIVER_INITIALIZE *PDRIVER_INITIALIZE; typedef VOID -(DDKAPI DRIVER_STARTIO)( - IN struct _DEVICE_OBJECT *DeviceObject, - IN struct _IRP *Irp); +(NTAPI DRIVER_STARTIO)( + IN struct _DEVICE_OBJECT *DeviceObject, + IN struct _IRP *Irp); typedef DRIVER_STARTIO *PDRIVER_STARTIO; typedef VOID -(DDKAPI DRIVER_UNLOAD)( - IN struct _DRIVER_OBJECT *DriverObject); +(NTAPI DRIVER_UNLOAD)( + IN struct _DRIVER_OBJECT *DriverObject); typedef DRIVER_UNLOAD *PDRIVER_UNLOAD; typedef NTSTATUS -(DDKAPI DRIVER_DISPATCH)( - IN struct _DEVICE_OBJECT *DeviceObject, - IN struct _IRP *Irp); +(NTAPI DRIVER_DISPATCH)( + IN struct _DEVICE_OBJECT *DeviceObject, + IN struct _IRP *Irp); typedef DRIVER_DISPATCH *PDRIVER_DISPATCH; typedef struct _DRIVER_OBJECT { - CSHORT Type; - CSHORT Size; - PDEVICE_OBJECT DeviceObject; - ULONG Flags; - PVOID DriverStart; - ULONG DriverSize; - PVOID DriverSection; - PDRIVER_EXTENSION DriverExtension; - UNICODE_STRING DriverName; - PUNICODE_STRING HardwareDatabase; + CSHORT Type; + CSHORT Size; + PDEVICE_OBJECT DeviceObject; + ULONG Flags; + PVOID DriverStart; + ULONG DriverSize; + PVOID DriverSection; + PDRIVER_EXTENSION DriverExtension; + UNICODE_STRING DriverName; + PUNICODE_STRING HardwareDatabase; struct _FAST_IO_DISPATCH *FastIoDispatch; - PDRIVER_INITIALIZE DriverInit; - PDRIVER_STARTIO DriverStartIo; - PDRIVER_UNLOAD DriverUnload; - PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION + 1]; -} DRIVER_OBJECT; -typedef struct _DRIVER_OBJECT *PDRIVER_OBJECT; + PDRIVER_INITIALIZE DriverInit; + PDRIVER_STARTIO DriverStartIo; + PDRIVER_UNLOAD DriverUnload; + PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION + 1]; +} DRIVER_OBJECT, *PDRIVER_OBJECT; typedef struct _DMA_ADAPTER { - USHORT Version; - USHORT Size; - struct _DMA_OPERATIONS* DmaOperations; + USHORT Version; + USHORT Size; + struct _DMA_OPERATIONS* DmaOperations; } DMA_ADAPTER, *PDMA_ADAPTER; typedef VOID -(DDKAPI *PPUT_DMA_ADAPTER)( - IN PDMA_ADAPTER DmaAdapter); +(NTAPI *PPUT_DMA_ADAPTER)( + IN PDMA_ADAPTER DmaAdapter); typedef PVOID -(DDKAPI *PALLOCATE_COMMON_BUFFER)( - IN PDMA_ADAPTER DmaAdapter, - IN ULONG Length, - OUT PPHYSICAL_ADDRESS LogicalAddress, - IN BOOLEAN CacheEnabled); +(NTAPI *PALLOCATE_COMMON_BUFFER)( + IN PDMA_ADAPTER DmaAdapter, + IN ULONG Length, + OUT PPHYSICAL_ADDRESS LogicalAddress, + IN BOOLEAN CacheEnabled); typedef VOID -(DDKAPI *PFREE_COMMON_BUFFER)( - IN PDMA_ADAPTER DmaAdapter, - IN ULONG Length, - IN PHYSICAL_ADDRESS LogicalAddress, - IN PVOID VirtualAddress, - IN BOOLEAN CacheEnabled); +(NTAPI *PFREE_COMMON_BUFFER)( + IN PDMA_ADAPTER DmaAdapter, + IN ULONG Length, + IN PHYSICAL_ADDRESS LogicalAddress, + IN PVOID VirtualAddress, + IN BOOLEAN CacheEnabled); typedef NTSTATUS -(DDKAPI *PALLOCATE_ADAPTER_CHANNEL)( - IN PDMA_ADAPTER DmaAdapter, - IN PDEVICE_OBJECT DeviceObject, - IN ULONG NumberOfMapRegisters, - IN PDRIVER_CONTROL ExecutionRoutine, - IN PVOID Context); +(NTAPI *PALLOCATE_ADAPTER_CHANNEL)( + IN PDMA_ADAPTER DmaAdapter, + IN PDEVICE_OBJECT DeviceObject, + IN ULONG NumberOfMapRegisters, + IN PDRIVER_CONTROL ExecutionRoutine, + IN PVOID Context); typedef BOOLEAN -(DDKAPI *PFLUSH_ADAPTER_BUFFERS)( - IN PDMA_ADAPTER DmaAdapter, - IN PMDL Mdl, - IN PVOID MapRegisterBase, - IN PVOID CurrentVa, - IN ULONG Length, - IN BOOLEAN WriteToDevice); +(NTAPI *PFLUSH_ADAPTER_BUFFERS)( + IN PDMA_ADAPTER DmaAdapter, + IN PMDL Mdl, + IN PVOID MapRegisterBase, + IN PVOID CurrentVa, + IN ULONG Length, + IN BOOLEAN WriteToDevice); typedef VOID -(DDKAPI *PFREE_ADAPTER_CHANNEL)( - IN PDMA_ADAPTER DmaAdapter); +(NTAPI *PFREE_ADAPTER_CHANNEL)( + IN PDMA_ADAPTER DmaAdapter); typedef VOID -(DDKAPI *PFREE_MAP_REGISTERS)( - IN PDMA_ADAPTER DmaAdapter, - PVOID MapRegisterBase, - ULONG NumberOfMapRegisters); +(NTAPI *PFREE_MAP_REGISTERS)( + IN PDMA_ADAPTER DmaAdapter, + PVOID MapRegisterBase, + ULONG NumberOfMapRegisters); typedef PHYSICAL_ADDRESS -(DDKAPI *PMAP_TRANSFER)( - IN PDMA_ADAPTER DmaAdapter, - IN PMDL Mdl, - IN PVOID MapRegisterBase, - IN PVOID CurrentVa, - IN OUT PULONG Length, - IN BOOLEAN WriteToDevice); +(NTAPI *PMAP_TRANSFER)( + IN PDMA_ADAPTER DmaAdapter, + IN PMDL Mdl, + IN PVOID MapRegisterBase, + IN PVOID CurrentVa, + IN OUT PULONG Length, + IN BOOLEAN WriteToDevice); typedef ULONG -(DDKAPI *PGET_DMA_ALIGNMENT)( - IN PDMA_ADAPTER DmaAdapter); +(NTAPI *PGET_DMA_ALIGNMENT)( + IN PDMA_ADAPTER DmaAdapter); typedef ULONG -(DDKAPI *PREAD_DMA_COUNTER)( - IN PDMA_ADAPTER DmaAdapter); +(NTAPI *PREAD_DMA_COUNTER)( + IN PDMA_ADAPTER DmaAdapter); typedef VOID -(DDKAPI *PDRIVER_LIST_CONTROL)( - IN struct _DEVICE_OBJECT *DeviceObject, - IN struct _IRP *Irp, - IN struct _SCATTER_GATHER_LIST *ScatterGather, - IN PVOID Context); +(NTAPI DRIVER_LIST_CONTROL)( + IN struct _DEVICE_OBJECT *DeviceObject, + IN struct _IRP *Irp, + IN struct _SCATTER_GATHER_LIST *ScatterGather, + IN PVOID Context); +typedef DRIVER_LIST_CONTROL *PDRIVER_LIST_CONTROL; typedef NTSTATUS -(DDKAPI *PGET_SCATTER_GATHER_LIST)( - IN PDMA_ADAPTER DmaAdapter, - IN PDEVICE_OBJECT DeviceObject, - IN PMDL Mdl, - IN PVOID CurrentVa, - IN ULONG Length, - IN PDRIVER_LIST_CONTROL ExecutionRoutine, - IN PVOID Context, - IN BOOLEAN WriteToDevice); +(NTAPI *PGET_SCATTER_GATHER_LIST)( + IN PDMA_ADAPTER DmaAdapter, + IN PDEVICE_OBJECT DeviceObject, + IN PMDL Mdl, + IN PVOID CurrentVa, + IN ULONG Length, + IN PDRIVER_LIST_CONTROL ExecutionRoutine, + IN PVOID Context, + IN BOOLEAN WriteToDevice); typedef VOID -(DDKAPI *PPUT_SCATTER_GATHER_LIST)( - IN PDMA_ADAPTER DmaAdapter, - IN PSCATTER_GATHER_LIST ScatterGather, - IN BOOLEAN WriteToDevice); +(NTAPI *PPUT_SCATTER_GATHER_LIST)( + IN PDMA_ADAPTER DmaAdapter, + IN PSCATTER_GATHER_LIST ScatterGather, + IN BOOLEAN WriteToDevice); typedef NTSTATUS -(DDKAPI *PCALCULATE_SCATTER_GATHER_LIST_SIZE)( - IN PDMA_ADAPTER DmaAdapter, - IN PMDL Mdl OPTIONAL, - IN PVOID CurrentVa, - IN ULONG Length, - OUT PULONG ScatterGatherListSize, - OUT PULONG pNumberOfMapRegisters OPTIONAL); +(NTAPI *PCALCULATE_SCATTER_GATHER_LIST_SIZE)( + IN PDMA_ADAPTER DmaAdapter, + IN PMDL Mdl OPTIONAL, + IN PVOID CurrentVa, + IN ULONG Length, + OUT PULONG ScatterGatherListSize, + OUT PULONG pNumberOfMapRegisters OPTIONAL); typedef NTSTATUS -(DDKAPI *PBUILD_SCATTER_GATHER_LIST)( - IN PDMA_ADAPTER DmaAdapter, - IN PDEVICE_OBJECT DeviceObject, - IN PMDL Mdl, - IN PVOID CurrentVa, - IN ULONG Length, - IN PDRIVER_LIST_CONTROL ExecutionRoutine, - IN PVOID Context, - IN BOOLEAN WriteToDevice, - IN PVOID ScatterGatherBuffer, - IN ULONG ScatterGatherLength); +(NTAPI *PBUILD_SCATTER_GATHER_LIST)( + IN PDMA_ADAPTER DmaAdapter, + IN PDEVICE_OBJECT DeviceObject, + IN PMDL Mdl, + IN PVOID CurrentVa, + IN ULONG Length, + IN PDRIVER_LIST_CONTROL ExecutionRoutine, + IN PVOID Context, + IN BOOLEAN WriteToDevice, + IN PVOID ScatterGatherBuffer, + IN ULONG ScatterGatherLength); typedef NTSTATUS -(DDKAPI *PBUILD_MDL_FROM_SCATTER_GATHER_LIST)( - IN PDMA_ADAPTER DmaAdapter, - IN PSCATTER_GATHER_LIST ScatterGather, - IN PMDL OriginalMdl, - OUT PMDL *TargetMdl); +(NTAPI *PBUILD_MDL_FROM_SCATTER_GATHER_LIST)( + IN PDMA_ADAPTER DmaAdapter, + IN PSCATTER_GATHER_LIST ScatterGather, + IN PMDL OriginalMdl, + OUT PMDL *TargetMdl); typedef struct _DMA_OPERATIONS { - ULONG Size; - PPUT_DMA_ADAPTER PutDmaAdapter; - PALLOCATE_COMMON_BUFFER AllocateCommonBuffer; - PFREE_COMMON_BUFFER FreeCommonBuffer; - PALLOCATE_ADAPTER_CHANNEL AllocateAdapterChannel; - PFLUSH_ADAPTER_BUFFERS FlushAdapterBuffers; - PFREE_ADAPTER_CHANNEL FreeAdapterChannel; - PFREE_MAP_REGISTERS FreeMapRegisters; - PMAP_TRANSFER MapTransfer; - PGET_DMA_ALIGNMENT GetDmaAlignment; - PREAD_DMA_COUNTER ReadDmaCounter; - PGET_SCATTER_GATHER_LIST GetScatterGatherList; - PPUT_SCATTER_GATHER_LIST PutScatterGatherList; - PCALCULATE_SCATTER_GATHER_LIST_SIZE CalculateScatterGatherList; - PBUILD_SCATTER_GATHER_LIST BuildScatterGatherList; - PBUILD_MDL_FROM_SCATTER_GATHER_LIST BuildMdlFromScatterGatherList; + ULONG Size; + PPUT_DMA_ADAPTER PutDmaAdapter; + PALLOCATE_COMMON_BUFFER AllocateCommonBuffer; + PFREE_COMMON_BUFFER FreeCommonBuffer; + PALLOCATE_ADAPTER_CHANNEL AllocateAdapterChannel; + PFLUSH_ADAPTER_BUFFERS FlushAdapterBuffers; + PFREE_ADAPTER_CHANNEL FreeAdapterChannel; + PFREE_MAP_REGISTERS FreeMapRegisters; + PMAP_TRANSFER MapTransfer; + PGET_DMA_ALIGNMENT GetDmaAlignment; + PREAD_DMA_COUNTER ReadDmaCounter; + PGET_SCATTER_GATHER_LIST GetScatterGatherList; + PPUT_SCATTER_GATHER_LIST PutScatterGatherList; + PCALCULATE_SCATTER_GATHER_LIST_SIZE CalculateScatterGatherList; + PBUILD_SCATTER_GATHER_LIST BuildScatterGatherList; + PBUILD_MDL_FROM_SCATTER_GATHER_LIST BuildMdlFromScatterGatherList; } DMA_OPERATIONS, *PDMA_OPERATIONS; typedef struct _IO_RESOURCE_DESCRIPTOR { - UCHAR Option; - UCHAR Type; - UCHAR ShareDisposition; - UCHAR Spare1; - USHORT Flags; - USHORT Spare2; + UCHAR Option; + UCHAR Type; + UCHAR ShareDisposition; + UCHAR Spare1; + USHORT Flags; + USHORT Spare2; union { struct { - ULONG Length; - ULONG Alignment; - PHYSICAL_ADDRESS MinimumAddress; - PHYSICAL_ADDRESS MaximumAddress; + ULONG Length; + ULONG Alignment; + PHYSICAL_ADDRESS MinimumAddress; + PHYSICAL_ADDRESS MaximumAddress; } Port; struct { - ULONG Length; - ULONG Alignment; - PHYSICAL_ADDRESS MinimumAddress; - PHYSICAL_ADDRESS MaximumAddress; + ULONG Length; + ULONG Alignment; + PHYSICAL_ADDRESS MinimumAddress; + PHYSICAL_ADDRESS MaximumAddress; } Memory; struct { - ULONG MinimumVector; - ULONG MaximumVector; + ULONG MinimumVector; + ULONG MaximumVector; } Interrupt; struct { - ULONG MinimumChannel; - ULONG MaximumChannel; + ULONG MinimumChannel; + ULONG MaximumChannel; } Dma; struct { - ULONG Length; - ULONG Alignment; - PHYSICAL_ADDRESS MinimumAddress; - PHYSICAL_ADDRESS MaximumAddress; + ULONG Length; + ULONG Alignment; + PHYSICAL_ADDRESS MinimumAddress; + PHYSICAL_ADDRESS MaximumAddress; } Generic; struct { - ULONG Data[3]; + ULONG Data[3]; } DevicePrivate; struct { - ULONG Length; - ULONG MinBusNumber; - ULONG MaxBusNumber; - ULONG Reserved; + ULONG Length; + ULONG MinBusNumber; + ULONG MaxBusNumber; + ULONG Reserved; } BusNumber; struct { - ULONG Priority; - ULONG Reserved1; - ULONG Reserved2; + ULONG Priority; + ULONG Reserved1; + ULONG Reserved2; } ConfigData; } u; } IO_RESOURCE_DESCRIPTOR, *PIO_RESOURCE_DESCRIPTOR; typedef struct _IO_RESOURCE_LIST { - USHORT Version; - USHORT Revision; - ULONG Count; - IO_RESOURCE_DESCRIPTOR Descriptors[1]; + USHORT Version; + USHORT Revision; + ULONG Count; + IO_RESOURCE_DESCRIPTOR Descriptors[1]; } IO_RESOURCE_LIST, *PIO_RESOURCE_LIST; typedef struct _IO_RESOURCE_REQUIREMENTS_LIST { - ULONG ListSize; - INTERFACE_TYPE InterfaceType; - ULONG BusNumber; - ULONG SlotNumber; - ULONG Reserved[3]; - ULONG AlternativeLists; - IO_RESOURCE_LIST List[1]; + ULONG ListSize; + INTERFACE_TYPE InterfaceType; + ULONG BusNumber; + ULONG SlotNumber; + ULONG Reserved[3]; + ULONG AlternativeLists; + IO_RESOURCE_LIST List[1]; } IO_RESOURCE_REQUIREMENTS_LIST, *PIO_RESOURCE_REQUIREMENTS_LIST; typedef VOID -(DDKAPI DRIVER_CANCEL)( - IN struct _DEVICE_OBJECT *DeviceObject, - IN struct _IRP *Irp); +(NTAPI DRIVER_CANCEL)( + IN struct _DEVICE_OBJECT *DeviceObject, + IN struct _IRP *Irp); typedef DRIVER_CANCEL *PDRIVER_CANCEL; typedef struct _IRP { - CSHORT Type; - USHORT Size; - struct _MDL *MdlAddress; - ULONG Flags; + CSHORT Type; + USHORT Size; + struct _MDL *MdlAddress; + ULONG Flags; union { - struct _IRP *MasterIrp; - volatile LONG IrpCount; - PVOID SystemBuffer; + struct _IRP *MasterIrp; + volatile LONG IrpCount; + PVOID SystemBuffer; } AssociatedIrp; - LIST_ENTRY ThreadListEntry; - IO_STATUS_BLOCK IoStatus; - KPROCESSOR_MODE RequestorMode; - BOOLEAN PendingReturned; - CHAR StackCount; - CHAR CurrentLocation; - BOOLEAN Cancel; - KIRQL CancelIrql; - CCHAR ApcEnvironment; - UCHAR AllocationFlags; - PIO_STATUS_BLOCK UserIosb; - PKEVENT UserEvent; - union { - struct { - _ANONYMOUS_UNION union { - PIO_APC_ROUTINE UserApcRoutine; - PVOID IssuingProcess; - } DUMMYUNIONNAME; - PVOID UserApcContext; - } AsynchronousParameters; - LARGE_INTEGER AllocationSize; - } Overlay; - volatile PDRIVER_CANCEL CancelRoutine; - PVOID UserBuffer; + LIST_ENTRY ThreadListEntry; + IO_STATUS_BLOCK IoStatus; + KPROCESSOR_MODE RequestorMode; + BOOLEAN PendingReturned; + CHAR StackCount; + CHAR CurrentLocation; + BOOLEAN Cancel; + KIRQL CancelIrql; + CCHAR ApcEnvironment; + UCHAR AllocationFlags; + PIO_STATUS_BLOCK UserIosb; + PKEVENT UserEvent; union { struct { _ANONYMOUS_UNION union { - KDEVICE_QUEUE_ENTRY DeviceQueueEntry; + PIO_APC_ROUTINE UserApcRoutine; + PVOID IssuingProcess; + } DUMMYUNIONNAME; + PVOID UserApcContext; + } AsynchronousParameters; + LARGE_INTEGER AllocationSize; + } Overlay; + volatile PDRIVER_CANCEL CancelRoutine; + PVOID UserBuffer; + union { + struct { + _ANONYMOUS_UNION union { + KDEVICE_QUEUE_ENTRY DeviceQueueEntry; _ANONYMOUS_STRUCT struct { - PVOID DriverContext[4]; + PVOID DriverContext[4]; } DUMMYSTRUCTNAME; } DUMMYUNIONNAME; - PETHREAD Thread; - PCHAR AuxiliaryBuffer; + PETHREAD Thread; + PCHAR AuxiliaryBuffer; _ANONYMOUS_STRUCT struct { - LIST_ENTRY ListEntry; + LIST_ENTRY ListEntry; _ANONYMOUS_UNION union { - struct _IO_STACK_LOCATION *CurrentStackLocation; - ULONG PacketType; + struct _IO_STACK_LOCATION *CurrentStackLocation; + ULONG PacketType; } DUMMYUNIONNAME; } DUMMYSTRUCTNAME; - struct _FILE_OBJECT *OriginalFileObject; + struct _FILE_OBJECT *OriginalFileObject; } Overlay; - KAPC Apc; - PVOID CompletionKey; + KAPC Apc; + PVOID CompletionKey; } Tail; -} IRP; -typedef struct _IRP *PIRP; +} IRP, *PIRP; typedef enum _IO_PAGING_PRIORITY { IoPagingPriorityInvalid, @@ -4831,93 +6070,96 @@ typedef enum _IO_PAGING_PRIORITY { } IO_PAGING_PRIORITY; typedef NTSTATUS -(DDKAPI IO_COMPLETION_ROUTINE)( - IN struct _DEVICE_OBJECT *DeviceObject, - IN struct _IRP *Irp, - IN PVOID Context); +(NTAPI IO_COMPLETION_ROUTINE)( + IN struct _DEVICE_OBJECT *DeviceObject, + IN struct _IRP *Irp, + IN PVOID Context); typedef IO_COMPLETION_ROUTINE *PIO_COMPLETION_ROUTINE; typedef VOID -(DDKAPI *PIO_DPC_ROUTINE)( - IN struct _KDPC *Dpc, - IN struct _DEVICE_OBJECT *DeviceObject, - IN struct _IRP *Irp, - IN PVOID Context); +(NTAPI IO_DPC_ROUTINE)( + IN struct _KDPC *Dpc, + IN struct _DEVICE_OBJECT *DeviceObject, + IN struct _IRP *Irp, + IN PVOID Context); +typedef IO_DPC_ROUTINE *PIO_DPC_ROUTINE; typedef NTSTATUS -(DDKAPI *PMM_DLL_INITIALIZE)( - IN PUNICODE_STRING RegistryPath); +(NTAPI *PMM_DLL_INITIALIZE)( + IN PUNICODE_STRING RegistryPath); typedef NTSTATUS -(DDKAPI *PMM_DLL_UNLOAD)( +(NTAPI *PMM_DLL_UNLOAD)( VOID); -typedef BOOLEAN -(DDKAPI KSERVICE_ROUTINE)( - IN struct _KINTERRUPT *Interrupt, - IN PVOID ServiceContext); -typedef KSERVICE_ROUTINE *PKSERVICE_ROUTINE; - typedef VOID -(DDKAPI *PIO_TIMER_ROUTINE)( - IN struct _DEVICE_OBJECT *DeviceObject, - IN PVOID Context); +(NTAPI IO_TIMER_ROUTINE)( + IN struct _DEVICE_OBJECT *DeviceObject, + IN PVOID Context); +typedef IO_TIMER_ROUTINE *PIO_TIMER_ROUTINE; typedef struct _IO_SECURITY_CONTEXT { - PSECURITY_QUALITY_OF_SERVICE SecurityQos; - PACCESS_STATE AccessState; - ACCESS_MASK DesiredAccess; - ULONG FullCreateOptions; + PSECURITY_QUALITY_OF_SERVICE SecurityQos; + PACCESS_STATE AccessState; + ACCESS_MASK DesiredAccess; + ULONG FullCreateOptions; } IO_SECURITY_CONTEXT, *PIO_SECURITY_CONTEXT; struct _IO_CSQ; typedef struct _IO_CSQ_IRP_CONTEXT { - ULONG Type; - struct _IRP *Irp; - struct _IO_CSQ *Csq; + ULONG Type; + struct _IRP *Irp; + struct _IO_CSQ *Csq; } IO_CSQ_IRP_CONTEXT, *PIO_CSQ_IRP_CONTEXT; typedef VOID -(DDKAPI *PIO_CSQ_INSERT_IRP)( - IN struct _IO_CSQ *Csq, - IN PIRP Irp); +(NTAPI *PIO_CSQ_INSERT_IRP)( + IN struct _IO_CSQ *Csq, + IN PIRP Irp); + +typedef NTSTATUS +(NTAPI IO_CSQ_INSERT_IRP_EX)( + IN struct _IO_CSQ *Csq, + IN PIRP Irp, + IN PVOID InsertContext); +typedef IO_CSQ_INSERT_IRP_EX *PIO_CSQ_INSERT_IRP_EX; typedef VOID -(DDKAPI *PIO_CSQ_REMOVE_IRP)( - IN struct _IO_CSQ *Csq, - IN PIRP Irp); +(NTAPI *PIO_CSQ_REMOVE_IRP)( + IN struct _IO_CSQ *Csq, + IN PIRP Irp); typedef PIRP -(DDKAPI *PIO_CSQ_PEEK_NEXT_IRP)( - IN struct _IO_CSQ *Csq, - IN PIRP Irp, - IN PVOID PeekContext); +(NTAPI *PIO_CSQ_PEEK_NEXT_IRP)( + IN struct _IO_CSQ *Csq, + IN PIRP Irp, + IN PVOID PeekContext); typedef VOID -(DDKAPI *PIO_CSQ_ACQUIRE_LOCK)( - IN struct _IO_CSQ *Csq, - OUT PKIRQL Irql); +(NTAPI *PIO_CSQ_ACQUIRE_LOCK)( + IN struct _IO_CSQ *Csq, + OUT PKIRQL Irql); typedef VOID -(DDKAPI *PIO_CSQ_RELEASE_LOCK)( - IN struct _IO_CSQ *Csq, - IN KIRQL Irql); +(NTAPI *PIO_CSQ_RELEASE_LOCK)( + IN struct _IO_CSQ *Csq, + IN KIRQL Irql); typedef VOID -(DDKAPI *PIO_CSQ_COMPLETE_CANCELED_IRP)( - IN struct _IO_CSQ *Csq, - IN PIRP Irp); +(NTAPI *PIO_CSQ_COMPLETE_CANCELED_IRP)( + IN struct _IO_CSQ *Csq, + IN PIRP Irp); typedef struct _IO_CSQ { - ULONG Type; - PIO_CSQ_INSERT_IRP CsqInsertIrp; - PIO_CSQ_REMOVE_IRP CsqRemoveIrp; - PIO_CSQ_PEEK_NEXT_IRP CsqPeekNextIrp; - PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock; - PIO_CSQ_RELEASE_LOCK CsqReleaseLock; - PIO_CSQ_COMPLETE_CANCELED_IRP CsqCompleteCanceledIrp; - PVOID ReservePointer; + ULONG Type; + PIO_CSQ_INSERT_IRP CsqInsertIrp; + PIO_CSQ_REMOVE_IRP CsqRemoveIrp; + PIO_CSQ_PEEK_NEXT_IRP CsqPeekNextIrp; + PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock; + PIO_CSQ_RELEASE_LOCK CsqReleaseLock; + PIO_CSQ_COMPLETE_CANCELED_IRP CsqCompleteCanceledIrp; + PVOID ReservePointer; } IO_CSQ, *PIO_CSQ; typedef enum _BUS_QUERY_ID_TYPE { @@ -4933,198 +6175,321 @@ typedef enum _DEVICE_TEXT_TYPE { DeviceTextLocationInformation } DEVICE_TEXT_TYPE, *PDEVICE_TEXT_TYPE; -typedef enum _WORK_QUEUE_TYPE { - CriticalWorkQueue, - DelayedWorkQueue, - HyperCriticalWorkQueue, - MaximumWorkQueue -} WORK_QUEUE_TYPE; +typedef BOOLEAN +(NTAPI *PGPE_SERVICE_ROUTINE)( + PVOID, + PVOID); + +typedef NTSTATUS +(NTAPI *PGPE_CONNECT_VECTOR)( + PDEVICE_OBJECT, + ULONG, + KINTERRUPT_MODE, + BOOLEAN, + PGPE_SERVICE_ROUTINE, + PVOID, + PVOID); + +typedef NTSTATUS +(NTAPI *PGPE_DISCONNECT_VECTOR)( + PVOID); + +typedef NTSTATUS +(NTAPI *PGPE_ENABLE_EVENT)( + PDEVICE_OBJECT, + PVOID); + +typedef NTSTATUS +(NTAPI *PGPE_DISABLE_EVENT)( + PDEVICE_OBJECT, + PVOID); + +typedef NTSTATUS +(NTAPI *PGPE_CLEAR_STATUS)( + PDEVICE_OBJECT, + PVOID); + +typedef VOID +(NTAPI *PDEVICE_NOTIFY_CALLBACK)( + PVOID, + ULONG); + +typedef NTSTATUS +(NTAPI *PREGISTER_FOR_DEVICE_NOTIFICATIONS)( + PDEVICE_OBJECT, + PDEVICE_NOTIFY_CALLBACK, + PVOID); + +typedef VOID +(NTAPI *PUNREGISTER_FOR_DEVICE_NOTIFICATIONS)( + PDEVICE_OBJECT, + PDEVICE_NOTIFY_CALLBACK); + +typedef struct _ACPI_INTERFACE_STANDARD { + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; + PGPE_CONNECT_VECTOR GpeConnectVector; + PGPE_DISCONNECT_VECTOR GpeDisconnectVector; + PGPE_ENABLE_EVENT GpeEnableEvent; + PGPE_DISABLE_EVENT GpeDisableEvent; + PGPE_CLEAR_STATUS GpeClearStatus; + PREGISTER_FOR_DEVICE_NOTIFICATIONS RegisterForDeviceNotifications; + PUNREGISTER_FOR_DEVICE_NOTIFICATIONS UnregisterForDeviceNotifications; +} ACPI_INTERFACE_STANDARD, *PACPI_INTERFACE_STANDARD; + +typedef BOOLEAN +(NTAPI *PGPE_SERVICE_ROUTINE2)( + PVOID ObjectContext, + PVOID ServiceContext); + +typedef NTSTATUS +(NTAPI *PGPE_CONNECT_VECTOR2)( + PVOID Context, + ULONG GpeNumber, + KINTERRUPT_MODE Mode, + BOOLEAN Shareable, + PGPE_SERVICE_ROUTINE ServiceRoutine, + PVOID ServiceContext, + PVOID *ObjectContext); + +typedef NTSTATUS +(NTAPI *PGPE_DISCONNECT_VECTOR2)( + PVOID Context, + PVOID ObjectContext); + +typedef NTSTATUS +(NTAPI *PGPE_ENABLE_EVENT2)( + PVOID Context, + PVOID ObjectContext); + +typedef NTSTATUS +(NTAPI *PGPE_DISABLE_EVENT2)( + PVOID Context, + PVOID ObjectContext); + +typedef NTSTATUS +(NTAPI *PGPE_CLEAR_STATUS2)( + PVOID Context, + PVOID ObjectContext); + +typedef VOID +(NTAPI *PDEVICE_NOTIFY_CALLBACK2)( + PVOID NotificationContext, + ULONG NotifyCode); + +typedef NTSTATUS +(NTAPI *PREGISTER_FOR_DEVICE_NOTIFICATIONS2)( + PVOID Context, + PDEVICE_NOTIFY_CALLBACK2 NotificationHandler, + PVOID NotificationContext); + +typedef VOID +(NTAPI *PUNREGISTER_FOR_DEVICE_NOTIFICATIONS2)( + PVOID Context); + +typedef struct _ACPI_INTERFACE_STANDARD2 { + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; + PGPE_CONNECT_VECTOR2 GpeConnectVector; + PGPE_DISCONNECT_VECTOR2 GpeDisconnectVector; + PGPE_ENABLE_EVENT2 GpeEnableEvent; + PGPE_DISABLE_EVENT2 GpeDisableEvent; + PGPE_CLEAR_STATUS2 GpeClearStatus; + PREGISTER_FOR_DEVICE_NOTIFICATIONS2 RegisterForDeviceNotifications; + PUNREGISTER_FOR_DEVICE_NOTIFICATIONS2 UnregisterForDeviceNotifications; +} ACPI_INTERFACE_STANDARD2, *PACPI_INTERFACE_STANDARD2; #if !defined(_AMD64_) && !defined(_IA64_) #include #endif typedef struct _IO_STACK_LOCATION { - UCHAR MajorFunction; - UCHAR MinorFunction; - UCHAR Flags; - UCHAR Control; + UCHAR MajorFunction; + UCHAR MinorFunction; + UCHAR Flags; + UCHAR Control; union { struct { - PIO_SECURITY_CONTEXT SecurityContext; - ULONG Options; - USHORT POINTER_ALIGNMENT FileAttributes; - USHORT ShareAccess; - ULONG POINTER_ALIGNMENT EaLength; + PIO_SECURITY_CONTEXT SecurityContext; + ULONG Options; + USHORT POINTER_ALIGNMENT FileAttributes; + USHORT ShareAccess; + ULONG POINTER_ALIGNMENT EaLength; } Create; struct { - ULONG Length; - ULONG POINTER_ALIGNMENT Key; - LARGE_INTEGER ByteOffset; + ULONG Length; + ULONG POINTER_ALIGNMENT Key; + LARGE_INTEGER ByteOffset; } Read; struct { - ULONG Length; - ULONG POINTER_ALIGNMENT Key; - LARGE_INTEGER ByteOffset; + ULONG Length; + ULONG POINTER_ALIGNMENT Key; + LARGE_INTEGER ByteOffset; } Write; struct { - ULONG Length; - PUNICODE_STRING FileName; - FILE_INFORMATION_CLASS FileInformationClass; - ULONG FileIndex; + ULONG Length; + PUNICODE_STRING FileName; + FILE_INFORMATION_CLASS FileInformationClass; + ULONG FileIndex; } QueryDirectory; struct { - ULONG Length; - ULONG CompletionFilter; + ULONG Length; + ULONG CompletionFilter; } NotifyDirectory; struct { - ULONG Length; - FILE_INFORMATION_CLASS POINTER_ALIGNMENT FileInformationClass; + ULONG Length; + FILE_INFORMATION_CLASS POINTER_ALIGNMENT FileInformationClass; } QueryFile; struct { - ULONG Length; - FILE_INFORMATION_CLASS POINTER_ALIGNMENT FileInformationClass; - PFILE_OBJECT FileObject; + ULONG Length; + FILE_INFORMATION_CLASS POINTER_ALIGNMENT FileInformationClass; + PFILE_OBJECT FileObject; _ANONYMOUS_UNION union { _ANONYMOUS_STRUCT struct { - BOOLEAN ReplaceIfExists; - BOOLEAN AdvanceOnly; + BOOLEAN ReplaceIfExists; + BOOLEAN AdvanceOnly; } DUMMYSTRUCTNAME; - ULONG ClusterCount; - HANDLE DeleteHandle; + ULONG ClusterCount; + HANDLE DeleteHandle; } DUMMYUNIONNAME; } SetFile; struct { - ULONG Length; - PVOID EaList; - ULONG EaListLength; - ULONG EaIndex; + ULONG Length; + PVOID EaList; + ULONG EaListLength; + ULONG EaIndex; } QueryEa; struct { - ULONG Length; + ULONG Length; } SetEa; struct { - ULONG Length; - FS_INFORMATION_CLASS POINTER_ALIGNMENT FsInformationClass; + ULONG Length; + FS_INFORMATION_CLASS POINTER_ALIGNMENT FsInformationClass; } QueryVolume; struct { - ULONG Length; - FS_INFORMATION_CLASS FsInformationClass; + ULONG Length; + FS_INFORMATION_CLASS FsInformationClass; } SetVolume; struct { - ULONG OutputBufferLength; - ULONG InputBufferLength; - ULONG FsControlCode; - PVOID Type3InputBuffer; + ULONG OutputBufferLength; + ULONG InputBufferLength; + ULONG FsControlCode; + PVOID Type3InputBuffer; } FileSystemControl; struct { - PLARGE_INTEGER Length; - ULONG Key; - LARGE_INTEGER ByteOffset; + PLARGE_INTEGER Length; + ULONG Key; + LARGE_INTEGER ByteOffset; } LockControl; struct { - ULONG OutputBufferLength; - ULONG POINTER_ALIGNMENT InputBufferLength; - ULONG POINTER_ALIGNMENT IoControlCode; - PVOID Type3InputBuffer; + ULONG OutputBufferLength; + ULONG POINTER_ALIGNMENT InputBufferLength; + ULONG POINTER_ALIGNMENT IoControlCode; + PVOID Type3InputBuffer; } DeviceIoControl; struct { - SECURITY_INFORMATION SecurityInformation; - ULONG POINTER_ALIGNMENT Length; + SECURITY_INFORMATION SecurityInformation; + ULONG POINTER_ALIGNMENT Length; } QuerySecurity; struct { - SECURITY_INFORMATION SecurityInformation; - PSECURITY_DESCRIPTOR SecurityDescriptor; + SECURITY_INFORMATION SecurityInformation; + PSECURITY_DESCRIPTOR SecurityDescriptor; } SetSecurity; struct { - PVPB Vpb; - PDEVICE_OBJECT DeviceObject; + PVPB Vpb; + PDEVICE_OBJECT DeviceObject; } MountVolume; struct { - PVPB Vpb; - PDEVICE_OBJECT DeviceObject; + PVPB Vpb; + PDEVICE_OBJECT DeviceObject; } VerifyVolume; struct { - struct _SCSI_REQUEST_BLOCK *Srb; + struct _SCSI_REQUEST_BLOCK *Srb; } Scsi; struct { - ULONG Length; - PSID StartSid; - struct _FILE_GET_QUOTA_INFORMATION *SidList; - ULONG SidListLength; + ULONG Length; + PSID StartSid; + struct _FILE_GET_QUOTA_INFORMATION *SidList; + ULONG SidListLength; } QueryQuota; struct { - ULONG Length; + ULONG Length; } SetQuota; struct { - DEVICE_RELATION_TYPE Type; + DEVICE_RELATION_TYPE Type; } QueryDeviceRelations; struct { - CONST GUID *InterfaceType; - USHORT Size; - USHORT Version; - PINTERFACE Interface; - PVOID InterfaceSpecificData; + CONST GUID *InterfaceType; + USHORT Size; + USHORT Version; + PINTERFACE Interface; + PVOID InterfaceSpecificData; } QueryInterface; struct { - PDEVICE_CAPABILITIES Capabilities; + PDEVICE_CAPABILITIES Capabilities; } DeviceCapabilities; struct { - PIO_RESOURCE_REQUIREMENTS_LIST IoResourceRequirementList; + PIO_RESOURCE_REQUIREMENTS_LIST IoResourceRequirementList; } FilterResourceRequirements; struct { - ULONG WhichSpace; - PVOID Buffer; - ULONG Offset; - ULONG POINTER_ALIGNMENT Length; + ULONG WhichSpace; + PVOID Buffer; + ULONG Offset; + ULONG POINTER_ALIGNMENT Length; } ReadWriteConfig; struct { - BOOLEAN Lock; + BOOLEAN Lock; } SetLock; struct { - BUS_QUERY_ID_TYPE IdType; + BUS_QUERY_ID_TYPE IdType; } QueryId; struct { - DEVICE_TEXT_TYPE DeviceTextType; - LCID POINTER_ALIGNMENT LocaleId; + DEVICE_TEXT_TYPE DeviceTextType; + LCID POINTER_ALIGNMENT LocaleId; } QueryDeviceText; struct { - BOOLEAN InPath; - BOOLEAN Reserved[3]; - DEVICE_USAGE_NOTIFICATION_TYPE POINTER_ALIGNMENT Type; + BOOLEAN InPath; + BOOLEAN Reserved[3]; + DEVICE_USAGE_NOTIFICATION_TYPE POINTER_ALIGNMENT Type; } UsageNotification; struct { - SYSTEM_POWER_STATE PowerState; + SYSTEM_POWER_STATE PowerState; } WaitWake; struct { - PPOWER_SEQUENCE PowerSequence; + PPOWER_SEQUENCE PowerSequence; } PowerSequence; struct { - ULONG SystemContext; - POWER_STATE_TYPE POINTER_ALIGNMENT Type; - POWER_STATE POINTER_ALIGNMENT State; - POWER_ACTION POINTER_ALIGNMENT ShutdownType; + ULONG SystemContext; + POWER_STATE_TYPE POINTER_ALIGNMENT Type; + POWER_STATE POINTER_ALIGNMENT State; + POWER_ACTION POINTER_ALIGNMENT ShutdownType; } Power; struct { - PCM_RESOURCE_LIST AllocatedResources; - PCM_RESOURCE_LIST AllocatedResourcesTranslated; + PCM_RESOURCE_LIST AllocatedResources; + PCM_RESOURCE_LIST AllocatedResourcesTranslated; } StartDevice; struct { - ULONG_PTR ProviderId; - PVOID DataPath; - ULONG BufferSize; - PVOID Buffer; + ULONG_PTR ProviderId; + PVOID DataPath; + ULONG BufferSize; + PVOID Buffer; } WMI; struct { - PVOID Argument1; - PVOID Argument2; - PVOID Argument3; - PVOID Argument4; + PVOID Argument1; + PVOID Argument2; + PVOID Argument3; + PVOID Argument4; } Others; } Parameters; - PDEVICE_OBJECT DeviceObject; - PFILE_OBJECT FileObject; - PIO_COMPLETION_ROUTINE CompletionRoutine; - PVOID Context; + PDEVICE_OBJECT DeviceObject; + PFILE_OBJECT FileObject; + PIO_COMPLETION_ROUTINE CompletionRoutine; + PVOID Context; } IO_STACK_LOCATION, *PIO_STACK_LOCATION; #if !defined(_AMD64_) && !defined(_IA64_) #include @@ -5138,16 +6503,13 @@ typedef struct _IO_STACK_LOCATION { #define SL_INVOKE_ON_SUCCESS 0x40 #define SL_INVOKE_ON_ERROR 0x80 -/* IO_STACK_LOCATION.Parameters.ReadWriteControl.WhichSpace */ - -#define PCI_WHICHSPACE_CONFIG 0x0 -#define PCI_WHICHSPACE_ROM 0x52696350 /* 'PciR' */ - #define METHOD_BUFFERED 0 #define METHOD_IN_DIRECT 1 #define METHOD_OUT_DIRECT 2 #define METHOD_NEITHER 3 +#define METHOD_DIRECT_TO_HARDWARE METHOD_IN_DIRECT +#define METHOD_DIRECT_FROM_HARDWARE METHOD_OUT_DIRECT #define FILE_SUPERSEDED 0x00000000 #define FILE_OPENED 0x00000001 @@ -5194,6 +6556,7 @@ typedef struct _IO_STACK_LOCATION { #define FILE_ATTRIBUTE_OFFLINE 0x00001000 #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000 #define FILE_ATTRIBUTE_ENCRYPTED 0x00004000 +#define FILE_ATTRIBUTE_VIRTUAL 0x00010000 #define FILE_ATTRIBUTE_VALID_FLAGS 0x00007fb7 #define FILE_ATTRIBUTE_VALID_SET_FLAGS 0x000031a7 @@ -5227,6 +6590,10 @@ typedef struct _IO_STACK_LOCATION { #define FILE_OPEN_BY_FILE_ID 0x00002000 #define FILE_OPEN_FOR_BACKUP_INTENT 0x00004000 #define FILE_NO_COMPRESSION 0x00008000 +#if (NTDDI_VERSION >= NTDDI_WIN7) +#define FILE_OPEN_REQUIRING_OPLOCK 0x00010000 +#define FILE_DISALLOW_EXCLUSIVE 0x00020000 +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ #define FILE_RESERVE_OPFILTER 0x00100000 #define FILE_OPEN_REPARSE_POINT 0x00200000 #define FILE_OPEN_NO_RECALL 0x00400000 @@ -5265,15 +6632,926 @@ typedef struct _IO_STACK_LOCATION { /* end winnt.h */ +#define WMIREG_ACTION_REGISTER 1 +#define WMIREG_ACTION_DEREGISTER 2 +#define WMIREG_ACTION_REREGISTER 3 +#define WMIREG_ACTION_UPDATE_GUIDS 4 +#define WMIREG_ACTION_BLOCK_IRPS 5 + +#define WMIREGISTER 0 +#define WMIUPDATE 1 + +typedef VOID +(NTAPI FWMI_NOTIFICATION_CALLBACK)( + PVOID Wnode, + PVOID Context); +typedef FWMI_NOTIFICATION_CALLBACK *WMI_NOTIFICATION_CALLBACK; + +#ifndef _PCI_X_ +#define _PCI_X_ + +typedef struct _PCI_SLOT_NUMBER { + union { + struct { + ULONG DeviceNumber:5; + ULONG FunctionNumber:3; + ULONG Reserved:24; + } bits; + ULONG AsULONG; + } u; +} PCI_SLOT_NUMBER, *PPCI_SLOT_NUMBER; + +#define PCI_TYPE0_ADDRESSES 6 +#define PCI_TYPE1_ADDRESSES 2 +#define PCI_TYPE2_ADDRESSES 5 + +typedef struct _PCI_COMMON_HEADER { + PCI_COMMON_HEADER_LAYOUT +} PCI_COMMON_HEADER, *PPCI_COMMON_HEADER; + +#ifdef __cplusplus +typedef struct _PCI_COMMON_CONFIG { + PCI_COMMON_HEADER_LAYOUT + UCHAR DeviceSpecific[192]; +} PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG; +#else +typedef struct _PCI_COMMON_CONFIG { + PCI_COMMON_HEADER DUMMYSTRUCTNAME; + UCHAR DeviceSpecific[192]; +} PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG; +#endif + +#define PCI_COMMON_HDR_LENGTH (FIELD_OFFSET(PCI_COMMON_CONFIG, DeviceSpecific)) + +#define PCI_EXTENDED_CONFIG_LENGTH 0x1000 + +#define PCI_MAX_DEVICES 32 +#define PCI_MAX_FUNCTION 8 +#define PCI_MAX_BRIDGE_NUMBER 0xFF +#define PCI_INVALID_VENDORID 0xFFFF + +/* PCI_COMMON_CONFIG.HeaderType */ +#define PCI_MULTIFUNCTION 0x80 +#define PCI_DEVICE_TYPE 0x00 +#define PCI_BRIDGE_TYPE 0x01 +#define PCI_CARDBUS_BRIDGE_TYPE 0x02 + +#define PCI_CONFIGURATION_TYPE(PciData) \ + (((PPCI_COMMON_CONFIG) (PciData))->HeaderType & ~PCI_MULTIFUNCTION) + +#define PCI_MULTIFUNCTION_DEVICE(PciData) \ + ((((PPCI_COMMON_CONFIG) (PciData))->HeaderType & PCI_MULTIFUNCTION) != 0) + +/* PCI_COMMON_CONFIG.Command */ +#define PCI_ENABLE_IO_SPACE 0x0001 +#define PCI_ENABLE_MEMORY_SPACE 0x0002 +#define PCI_ENABLE_BUS_MASTER 0x0004 +#define PCI_ENABLE_SPECIAL_CYCLES 0x0008 +#define PCI_ENABLE_WRITE_AND_INVALIDATE 0x0010 +#define PCI_ENABLE_VGA_COMPATIBLE_PALETTE 0x0020 +#define PCI_ENABLE_PARITY 0x0040 +#define PCI_ENABLE_WAIT_CYCLE 0x0080 +#define PCI_ENABLE_SERR 0x0100 +#define PCI_ENABLE_FAST_BACK_TO_BACK 0x0200 +#define PCI_DISABLE_LEVEL_INTERRUPT 0x0400 + +/* PCI_COMMON_CONFIG.Status */ +#define PCI_STATUS_INTERRUPT_PENDING 0x0008 +#define PCI_STATUS_CAPABILITIES_LIST 0x0010 +#define PCI_STATUS_66MHZ_CAPABLE 0x0020 +#define PCI_STATUS_UDF_SUPPORTED 0x0040 +#define PCI_STATUS_FAST_BACK_TO_BACK 0x0080 +#define PCI_STATUS_DATA_PARITY_DETECTED 0x0100 +#define PCI_STATUS_DEVSEL 0x0600 +#define PCI_STATUS_SIGNALED_TARGET_ABORT 0x0800 +#define PCI_STATUS_RECEIVED_TARGET_ABORT 0x1000 +#define PCI_STATUS_RECEIVED_MASTER_ABORT 0x2000 +#define PCI_STATUS_SIGNALED_SYSTEM_ERROR 0x4000 +#define PCI_STATUS_DETECTED_PARITY_ERROR 0x8000 + +/* IO_STACK_LOCATION.Parameters.ReadWriteControl.WhichSpace */ + +#define PCI_WHICHSPACE_CONFIG 0x0 +#define PCI_WHICHSPACE_ROM 0x52696350 /* 'PciR' */ + +#define PCI_CAPABILITY_ID_POWER_MANAGEMENT 0x01 +#define PCI_CAPABILITY_ID_AGP 0x02 +#define PCI_CAPABILITY_ID_VPD 0x03 +#define PCI_CAPABILITY_ID_SLOT_ID 0x04 +#define PCI_CAPABILITY_ID_MSI 0x05 +#define PCI_CAPABILITY_ID_CPCI_HOTSWAP 0x06 +#define PCI_CAPABILITY_ID_PCIX 0x07 +#define PCI_CAPABILITY_ID_HYPERTRANSPORT 0x08 +#define PCI_CAPABILITY_ID_VENDOR_SPECIFIC 0x09 +#define PCI_CAPABILITY_ID_DEBUG_PORT 0x0A +#define PCI_CAPABILITY_ID_CPCI_RES_CTRL 0x0B +#define PCI_CAPABILITY_ID_SHPC 0x0C +#define PCI_CAPABILITY_ID_P2P_SSID 0x0D +#define PCI_CAPABILITY_ID_AGP_TARGET 0x0E +#define PCI_CAPABILITY_ID_SECURE 0x0F +#define PCI_CAPABILITY_ID_PCI_EXPRESS 0x10 +#define PCI_CAPABILITY_ID_MSIX 0x11 + +typedef struct _PCI_CAPABILITIES_HEADER { + UCHAR CapabilityID; + UCHAR Next; +} PCI_CAPABILITIES_HEADER, *PPCI_CAPABILITIES_HEADER; + +typedef struct _PCI_PMC { + UCHAR Version:3; + UCHAR PMEClock:1; + UCHAR Rsvd1:1; + UCHAR DeviceSpecificInitialization:1; + UCHAR Rsvd2:2; + struct _PM_SUPPORT { + UCHAR Rsvd2:1; + UCHAR D1:1; + UCHAR D2:1; + UCHAR PMED0:1; + UCHAR PMED1:1; + UCHAR PMED2:1; + UCHAR PMED3Hot:1; + UCHAR PMED3Cold:1; + } Support; +} PCI_PMC, *PPCI_PMC; + +typedef struct _PCI_PMCSR { + USHORT PowerState:2; + USHORT Rsvd1:6; + USHORT PMEEnable:1; + USHORT DataSelect:4; + USHORT DataScale:2; + USHORT PMEStatus:1; +} PCI_PMCSR, *PPCI_PMCSR; + +typedef struct _PCI_PMCSR_BSE { + UCHAR Rsvd1:6; + UCHAR D3HotSupportsStopClock:1; + UCHAR BusPowerClockControlEnabled:1; +} PCI_PMCSR_BSE, *PPCI_PMCSR_BSE; + +typedef struct _PCI_PM_CAPABILITY { + PCI_CAPABILITIES_HEADER Header; + union { + PCI_PMC Capabilities; + USHORT AsUSHORT; + } PMC; + union { + PCI_PMCSR ControlStatus; + USHORT AsUSHORT; + } PMCSR; + union { + PCI_PMCSR_BSE BridgeSupport; + UCHAR AsUCHAR; + } PMCSR_BSE; + UCHAR Data; +} PCI_PM_CAPABILITY, *PPCI_PM_CAPABILITY; + +typedef struct { + PCI_CAPABILITIES_HEADER Header; + union { + struct { + USHORT DataParityErrorRecoveryEnable:1; + USHORT EnableRelaxedOrdering:1; + USHORT MaxMemoryReadByteCount:2; + USHORT MaxOutstandingSplitTransactions:3; + USHORT Reserved:9; + } bits; + USHORT AsUSHORT; + } Command; + union { + struct { + ULONG FunctionNumber:3; + ULONG DeviceNumber:5; + ULONG BusNumber:8; + ULONG Device64Bit:1; + ULONG Capable133MHz:1; + ULONG SplitCompletionDiscarded:1; + ULONG UnexpectedSplitCompletion:1; + ULONG DeviceComplexity:1; + ULONG DesignedMaxMemoryReadByteCount:2; + ULONG DesignedMaxOutstandingSplitTransactions:3; + ULONG DesignedMaxCumulativeReadSize:3; + ULONG ReceivedSplitCompletionErrorMessage:1; + ULONG CapablePCIX266:1; + ULONG CapablePCIX533:1; + } bits; + ULONG AsULONG; + } Status; +} PCI_X_CAPABILITY, *PPCI_X_CAPABILITY; + +#define PCI_EXPRESS_ADVANCED_ERROR_REPORTING_CAP_ID 0x0001 +#define PCI_EXPRESS_VIRTUAL_CHANNEL_CAP_ID 0x0002 +#define PCI_EXPRESS_DEVICE_SERIAL_NUMBER_CAP_ID 0x0003 +#define PCI_EXPRESS_POWER_BUDGETING_CAP_ID 0x0004 +#define PCI_EXPRESS_RC_LINK_DECLARATION_CAP_ID 0x0005 +#define PCI_EXPRESS_RC_INTERNAL_LINK_CONTROL_CAP_ID 0x0006 +#define PCI_EXPRESS_RC_EVENT_COLLECTOR_ENDPOINT_ASSOCIATION_CAP_ID 0x0007 +#define PCI_EXPRESS_MFVC_CAP_ID 0x0008 +#define PCI_EXPRESS_VC_AND_MFVC_CAP_ID 0x0009 +#define PCI_EXPRESS_RCRB_HEADER_CAP_ID 0x000A +#define PCI_EXPRESS_SINGLE_ROOT_IO_VIRTUALIZATION_CAP_ID 0x0010 + +typedef struct _PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER { + USHORT CapabilityID; + USHORT Version:4; + USHORT Next:12; +} PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER, *PPCI_EXPRESS_ENHANCED_CAPABILITY_HEADER; + +typedef struct _PCI_EXPRESS_SERIAL_NUMBER_CAPABILITY { + PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Header; + ULONG LowSerialNumber; + ULONG HighSerialNumber; +} PCI_EXPRESS_SERIAL_NUMBER_CAPABILITY, *PPCI_EXPRESS_SERIAL_NUMBER_CAPABILITY; + +typedef union _PCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS { + struct { + ULONG Undefined:1; + ULONG Reserved1:3; + ULONG DataLinkProtocolError:1; + ULONG SurpriseDownError:1; + ULONG Reserved2:6; + ULONG PoisonedTLP:1; + ULONG FlowControlProtocolError:1; + ULONG CompletionTimeout:1; + ULONG CompleterAbort:1; + ULONG UnexpectedCompletion:1; + ULONG ReceiverOverflow:1; + ULONG MalformedTLP:1; + ULONG ECRCError:1; + ULONG UnsupportedRequestError:1; + ULONG Reserved3:11; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS, *PPCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS; + +typedef union _PCI_EXPRESS_UNCORRECTABLE_ERROR_MASK { + struct { + ULONG Undefined:1; + ULONG Reserved1:3; + ULONG DataLinkProtocolError:1; + ULONG SurpriseDownError:1; + ULONG Reserved2:6; + ULONG PoisonedTLP:1; + ULONG FlowControlProtocolError:1; + ULONG CompletionTimeout:1; + ULONG CompleterAbort:1; + ULONG UnexpectedCompletion:1; + ULONG ReceiverOverflow:1; + ULONG MalformedTLP:1; + ULONG ECRCError:1; + ULONG UnsupportedRequestError:1; + ULONG Reserved3:11; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_UNCORRECTABLE_ERROR_MASK, *PPCI_EXPRESS_UNCORRECTABLE_ERROR_MASK; + +typedef union _PCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY { + struct { + ULONG Undefined:1; + ULONG Reserved1:3; + ULONG DataLinkProtocolError:1; + ULONG SurpriseDownError:1; + ULONG Reserved2:6; + ULONG PoisonedTLP:1; + ULONG FlowControlProtocolError:1; + ULONG CompletionTimeout:1; + ULONG CompleterAbort:1; + ULONG UnexpectedCompletion:1; + ULONG ReceiverOverflow:1; + ULONG MalformedTLP:1; + ULONG ECRCError:1; + ULONG UnsupportedRequestError:1; + ULONG Reserved3:11; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY, *PPCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY; + +typedef union _PCI_EXPRESS_CORRECTABLE_ERROR_STATUS { + struct { + ULONG ReceiverError:1; + ULONG Reserved1:5; + ULONG BadTLP:1; + ULONG BadDLLP:1; + ULONG ReplayNumRollover:1; + ULONG Reserved2:3; + ULONG ReplayTimerTimeout:1; + ULONG AdvisoryNonFatalError:1; + ULONG Reserved3:18; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_CORRECTABLE_ERROR_STATUS, *PPCI_CORRECTABLE_ERROR_STATUS; + +typedef union _PCI_EXPRESS_CORRECTABLE_ERROR_MASK { + struct { + ULONG ReceiverError:1; + ULONG Reserved1:5; + ULONG BadTLP:1; + ULONG BadDLLP:1; + ULONG ReplayNumRollover:1; + ULONG Reserved2:3; + ULONG ReplayTimerTimeout:1; + ULONG AdvisoryNonFatalError:1; + ULONG Reserved3:18; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_CORRECTABLE_ERROR_MASK, *PPCI_CORRECTABLE_ERROR_MASK; + +typedef union _PCI_EXPRESS_AER_CAPABILITIES { + struct { + ULONG FirstErrorPointer:5; + ULONG ECRCGenerationCapable:1; + ULONG ECRCGenerationEnable:1; + ULONG ECRCCheckCapable:1; + ULONG ECRCCheckEnable:1; + ULONG Reserved:23; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_AER_CAPABILITIES, *PPCI_EXPRESS_AER_CAPABILITIES; + +typedef union _PCI_EXPRESS_ROOT_ERROR_COMMAND { + struct { + ULONG CorrectableErrorReportingEnable:1; + ULONG NonFatalErrorReportingEnable:1; + ULONG FatalErrorReportingEnable:1; + ULONG Reserved:29; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_ROOT_ERROR_COMMAND, *PPCI_EXPRESS_ROOT_ERROR_COMMAND; + +typedef union _PCI_EXPRESS_ROOT_ERROR_STATUS { + struct { + ULONG CorrectableErrorReceived:1; + ULONG MultipleCorrectableErrorsReceived:1; + ULONG UncorrectableErrorReceived:1; + ULONG MultipleUncorrectableErrorsReceived:1; + ULONG FirstUncorrectableFatal:1; + ULONG NonFatalErrorMessagesReceived:1; + ULONG FatalErrorMessagesReceived:1; + ULONG Reserved:20; + ULONG AdvancedErrorInterruptMessageNumber:5; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_ROOT_ERROR_STATUS, *PPCI_EXPRESS_ROOT_ERROR_STATUS; + +typedef union _PCI_EXPRESS_ERROR_SOURCE_ID { + struct { + USHORT CorrectableSourceIdFun:3; + USHORT CorrectableSourceIdDev:5; + USHORT CorrectableSourceIdBus:8; + USHORT UncorrectableSourceIdFun:3; + USHORT UncorrectableSourceIdDev:5; + USHORT UncorrectableSourceIdBus:8; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_ERROR_SOURCE_ID, *PPCI_EXPRESS_ERROR_SOURCE_ID; + +typedef union _PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_STATUS { + struct { + ULONG TargetAbortOnSplitCompletion:1; + ULONG MasterAbortOnSplitCompletion:1; + ULONG ReceivedTargetAbort:1; + ULONG ReceivedMasterAbort:1; + ULONG RsvdZ:1; + ULONG UnexpectedSplitCompletionError:1; + ULONG UncorrectableSplitCompletion:1; + ULONG UncorrectableDataError:1; + ULONG UncorrectableAttributeError:1; + ULONG UncorrectableAddressError:1; + ULONG DelayedTransactionDiscardTimerExpired:1; + ULONG PERRAsserted:1; + ULONG SERRAsserted:1; + ULONG InternalBridgeError:1; + ULONG Reserved:18; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_STATUS, *PPCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_STATUS; + +typedef union _PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_MASK { + struct { + ULONG TargetAbortOnSplitCompletion:1; + ULONG MasterAbortOnSplitCompletion:1; + ULONG ReceivedTargetAbort:1; + ULONG ReceivedMasterAbort:1; + ULONG RsvdZ:1; + ULONG UnexpectedSplitCompletionError:1; + ULONG UncorrectableSplitCompletion:1; + ULONG UncorrectableDataError:1; + ULONG UncorrectableAttributeError:1; + ULONG UncorrectableAddressError:1; + ULONG DelayedTransactionDiscardTimerExpired:1; + ULONG PERRAsserted:1; + ULONG SERRAsserted:1; + ULONG InternalBridgeError:1; + ULONG Reserved:18; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_MASK, *PPCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_MASK; + +typedef union _PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_SEVERITY { + struct { + ULONG TargetAbortOnSplitCompletion:1; + ULONG MasterAbortOnSplitCompletion:1; + ULONG ReceivedTargetAbort:1; + ULONG ReceivedMasterAbort:1; + ULONG RsvdZ:1; + ULONG UnexpectedSplitCompletionError:1; + ULONG UncorrectableSplitCompletion:1; + ULONG UncorrectableDataError:1; + ULONG UncorrectableAttributeError:1; + ULONG UncorrectableAddressError:1; + ULONG DelayedTransactionDiscardTimerExpired:1; + ULONG PERRAsserted:1; + ULONG SERRAsserted:1; + ULONG InternalBridgeError:1; + ULONG Reserved:18; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_SEVERITY, *PPCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_SEVERITY; + +typedef union _PCI_EXPRESS_SEC_AER_CAPABILITIES { + struct { + ULONG SecondaryUncorrectableFirstErrorPtr:5; + ULONG Reserved:27; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_SEC_AER_CAPABILITIES, *PPCI_EXPRESS_SEC_AER_CAPABILITIES; + +#define ROOT_CMD_ENABLE_CORRECTABLE_ERROR_REPORTING 0x00000001 +#define ROOT_CMD_ENABLE_NONFATAL_ERROR_REPORTING 0x00000002 +#define ROOT_CMD_ENABLE_FATAL_ERROR_REPORTING 0x00000004 + +#define ROOT_CMD_ERROR_REPORTING_ENABLE_MASK \ + (ROOT_CMD_ENABLE_FATAL_ERROR_REPORTING | \ + ROOT_CMD_ENABLE_NONFATAL_ERROR_REPORTING | \ + ROOT_CMD_ENABLE_CORRECTABLE_ERROR_REPORTING) + +typedef struct _PCI_EXPRESS_AER_CAPABILITY { + PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Header; + PCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS UncorrectableErrorStatus; + PCI_EXPRESS_UNCORRECTABLE_ERROR_MASK UncorrectableErrorMask; + PCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY UncorrectableErrorSeverity; + PCI_EXPRESS_CORRECTABLE_ERROR_STATUS CorrectableErrorStatus; + PCI_EXPRESS_CORRECTABLE_ERROR_MASK CorrectableErrorMask; + PCI_EXPRESS_AER_CAPABILITIES CapabilitiesAndControl; + ULONG HeaderLog[4]; + PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_STATUS SecUncorrectableErrorStatus; + PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_MASK SecUncorrectableErrorMask; + PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_SEVERITY SecUncorrectableErrorSeverity; + PCI_EXPRESS_SEC_AER_CAPABILITIES SecCapabilitiesAndControl; + ULONG SecHeaderLog[4]; +} PCI_EXPRESS_AER_CAPABILITY, *PPCI_EXPRESS_AER_CAPABILITY; + +typedef struct _PCI_EXPRESS_ROOTPORT_AER_CAPABILITY { + PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Header; + PCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS UncorrectableErrorStatus; + PCI_EXPRESS_UNCORRECTABLE_ERROR_MASK UncorrectableErrorMask; + PCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY UncorrectableErrorSeverity; + PCI_EXPRESS_CORRECTABLE_ERROR_STATUS CorrectableErrorStatus; + PCI_EXPRESS_CORRECTABLE_ERROR_MASK CorrectableErrorMask; + PCI_EXPRESS_AER_CAPABILITIES CapabilitiesAndControl; + ULONG HeaderLog[4]; + PCI_EXPRESS_ROOT_ERROR_COMMAND RootErrorCommand; + PCI_EXPRESS_ROOT_ERROR_STATUS RootErrorStatus; + PCI_EXPRESS_ERROR_SOURCE_ID ErrorSourceId; +} PCI_EXPRESS_ROOTPORT_AER_CAPABILITY, *PPCI_EXPRESS_ROOTPORT_AER_CAPABILITY; + +typedef struct _PCI_EXPRESS_BRIDGE_AER_CAPABILITY { + PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Header; + PCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS UncorrectableErrorStatus; + PCI_EXPRESS_UNCORRECTABLE_ERROR_MASK UncorrectableErrorMask; + PCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY UncorrectableErrorSeverity; + PCI_EXPRESS_CORRECTABLE_ERROR_STATUS CorrectableErrorStatus; + PCI_EXPRESS_CORRECTABLE_ERROR_MASK CorrectableErrorMask; + PCI_EXPRESS_AER_CAPABILITIES CapabilitiesAndControl; + ULONG HeaderLog[4]; + PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_STATUS SecUncorrectableErrorStatus; + PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_MASK SecUncorrectableErrorMask; + PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_SEVERITY SecUncorrectableErrorSeverity; + PCI_EXPRESS_SEC_AER_CAPABILITIES SecCapabilitiesAndControl; + ULONG SecHeaderLog[4]; +} PCI_EXPRESS_BRIDGE_AER_CAPABILITY, *PPCI_EXPRESS_BRIDGE_AER_CAPABILITY; + +typedef union _PCI_EXPRESS_SRIOV_CAPS { + struct { + ULONG VFMigrationCapable:1; + ULONG Reserved1:20; + ULONG VFMigrationInterruptNumber:11; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_SRIOV_CAPS, *PPCI_EXPRESS_SRIOV_CAPS; + +typedef union _PCI_EXPRESS_SRIOV_CONTROL { + struct { + USHORT VFEnable:1; + USHORT VFMigrationEnable:1; + USHORT VFMigrationInterruptEnable:1; + USHORT VFMemorySpaceEnable:1; + USHORT ARICapableHierarchy:1; + USHORT Reserved1:11; + } DUMMYSTRUCTNAME; + USHORT AsUSHORT; +} PCI_EXPRESS_SRIOV_CONTROL, *PPCI_EXPRESS_SRIOV_CONTROL; + +typedef union _PCI_EXPRESS_SRIOV_STATUS { + struct { + USHORT VFMigrationStatus:1; + USHORT Reserved1:15; + } DUMMYSTRUCTNAME; + USHORT AsUSHORT; +} PCI_EXPRESS_SRIOV_STATUS, *PPCI_EXPRESS_SRIOV_STATUS; + +typedef union _PCI_EXPRESS_SRIOV_MIGRATION_STATE_ARRAY { + struct { + ULONG VFMigrationStateBIR:3; + ULONG VFMigrationStateOffset:29; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_SRIOV_MIGRATION_STATE_ARRAY, *PPCI_EXPRESS_SRIOV_MIGRATION_STATE_ARRAY; + +typedef struct _PCI_EXPRESS_SRIOV_CAPABILITY { + PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Header; + PCI_EXPRESS_SRIOV_CAPS SRIOVCapabilities; + PCI_EXPRESS_SRIOV_CONTROL SRIOVControl; + PCI_EXPRESS_SRIOV_STATUS SRIOVStatus; + USHORT InitialVFs; + USHORT TotalVFs; + USHORT NumVFs; + UCHAR FunctionDependencyLink; + UCHAR RsvdP1; + USHORT FirstVFOffset; + USHORT VFStride; + USHORT RsvdP2; + USHORT VFDeviceId; + ULONG SupportedPageSizes; + ULONG SystemPageSize; + ULONG BaseAddresses[PCI_TYPE0_ADDRESSES]; + PCI_EXPRESS_SRIOV_MIGRATION_STATE_ARRAY VFMigrationStateArrayOffset; +} PCI_EXPRESS_SRIOV_CAPABILITY, *PPCI_EXPRESS_SRIOV_CAPABILITY; + +/* PCI device classes */ +#define PCI_CLASS_PRE_20 0x00 +#define PCI_CLASS_MASS_STORAGE_CTLR 0x01 +#define PCI_CLASS_NETWORK_CTLR 0x02 +#define PCI_CLASS_DISPLAY_CTLR 0x03 +#define PCI_CLASS_MULTIMEDIA_DEV 0x04 +#define PCI_CLASS_MEMORY_CTLR 0x05 +#define PCI_CLASS_BRIDGE_DEV 0x06 +#define PCI_CLASS_SIMPLE_COMMS_CTLR 0x07 +#define PCI_CLASS_BASE_SYSTEM_DEV 0x08 +#define PCI_CLASS_INPUT_DEV 0x09 +#define PCI_CLASS_DOCKING_STATION 0x0a +#define PCI_CLASS_PROCESSOR 0x0b +#define PCI_CLASS_SERIAL_BUS_CTLR 0x0c +#define PCI_CLASS_WIRELESS_CTLR 0x0d +#define PCI_CLASS_INTELLIGENT_IO_CTLR 0x0e +#define PCI_CLASS_SATELLITE_COMMS_CTLR 0x0f +#define PCI_CLASS_ENCRYPTION_DECRYPTION 0x10 +#define PCI_CLASS_DATA_ACQ_SIGNAL_PROC 0x11 +#define PCI_CLASS_NOT_DEFINED 0xff + +/* PCI device subclasses for class 0 */ +#define PCI_SUBCLASS_PRE_20_NON_VGA 0x00 +#define PCI_SUBCLASS_PRE_20_VGA 0x01 + +/* PCI device subclasses for class 1 (mass storage controllers)*/ +#define PCI_SUBCLASS_MSC_SCSI_BUS_CTLR 0x00 +#define PCI_SUBCLASS_MSC_IDE_CTLR 0x01 +#define PCI_SUBCLASS_MSC_FLOPPY_CTLR 0x02 +#define PCI_SUBCLASS_MSC_IPI_CTLR 0x03 +#define PCI_SUBCLASS_MSC_RAID_CTLR 0x04 +#define PCI_SUBCLASS_MSC_OTHER 0x80 + +/* PCI device subclasses for class 2 (network controllers)*/ +#define PCI_SUBCLASS_NET_ETHERNET_CTLR 0x00 +#define PCI_SUBCLASS_NET_TOKEN_RING_CTLR 0x01 +#define PCI_SUBCLASS_NET_FDDI_CTLR 0x02 +#define PCI_SUBCLASS_NET_ATM_CTLR 0x03 +#define PCI_SUBCLASS_NET_ISDN_CTLR 0x04 +#define PCI_SUBCLASS_NET_OTHER 0x80 + +/* PCI device subclasses for class 3 (display controllers)*/ +#define PCI_SUBCLASS_VID_VGA_CTLR 0x00 +#define PCI_SUBCLASS_VID_XGA_CTLR 0x01 +#define PCI_SUBCLASS_VID_3D_CTLR 0x02 +#define PCI_SUBCLASS_VID_OTHER 0x80 + +/* PCI device subclasses for class 4 (multimedia device)*/ +#define PCI_SUBCLASS_MM_VIDEO_DEV 0x00 +#define PCI_SUBCLASS_MM_AUDIO_DEV 0x01 +#define PCI_SUBCLASS_MM_TELEPHONY_DEV 0x02 +#define PCI_SUBCLASS_MM_OTHER 0x80 + +/* PCI device subclasses for class 5 (memory controller)*/ +#define PCI_SUBCLASS_MEM_RAM 0x00 +#define PCI_SUBCLASS_MEM_FLASH 0x01 +#define PCI_SUBCLASS_MEM_OTHER 0x80 + +/* PCI device subclasses for class 6 (bridge device)*/ +#define PCI_SUBCLASS_BR_HOST 0x00 +#define PCI_SUBCLASS_BR_ISA 0x01 +#define PCI_SUBCLASS_BR_EISA 0x02 +#define PCI_SUBCLASS_BR_MCA 0x03 +#define PCI_SUBCLASS_BR_PCI_TO_PCI 0x04 +#define PCI_SUBCLASS_BR_PCMCIA 0x05 +#define PCI_SUBCLASS_BR_NUBUS 0x06 +#define PCI_SUBCLASS_BR_CARDBUS 0x07 +#define PCI_SUBCLASS_BR_RACEWAY 0x08 +#define PCI_SUBCLASS_BR_OTHER 0x80 + +#define PCI_SUBCLASS_COM_SERIAL 0x00 +#define PCI_SUBCLASS_COM_PARALLEL 0x01 +#define PCI_SUBCLASS_COM_MULTIPORT 0x02 +#define PCI_SUBCLASS_COM_MODEM 0x03 +#define PCI_SUBCLASS_COM_OTHER 0x80 + +#define PCI_SUBCLASS_SYS_INTERRUPT_CTLR 0x00 +#define PCI_SUBCLASS_SYS_DMA_CTLR 0x01 +#define PCI_SUBCLASS_SYS_SYSTEM_TIMER 0x02 +#define PCI_SUBCLASS_SYS_REAL_TIME_CLOCK 0x03 +#define PCI_SUBCLASS_SYS_GEN_HOTPLUG_CTLR 0x04 +#define PCI_SUBCLASS_SYS_SDIO_CTRL 0x05 +#define PCI_SUBCLASS_SYS_OTHER 0x80 + +#define PCI_SUBCLASS_INP_KEYBOARD 0x00 +#define PCI_SUBCLASS_INP_DIGITIZER 0x01 +#define PCI_SUBCLASS_INP_MOUSE 0x02 +#define PCI_SUBCLASS_INP_SCANNER 0x03 +#define PCI_SUBCLASS_INP_GAMEPORT 0x04 +#define PCI_SUBCLASS_INP_OTHER 0x80 + +#define PCI_SUBCLASS_DOC_GENERIC 0x00 +#define PCI_SUBCLASS_DOC_OTHER 0x80 + +#define PCI_SUBCLASS_PROC_386 0x00 +#define PCI_SUBCLASS_PROC_486 0x01 +#define PCI_SUBCLASS_PROC_PENTIUM 0x02 +#define PCI_SUBCLASS_PROC_ALPHA 0x10 +#define PCI_SUBCLASS_PROC_POWERPC 0x20 +#define PCI_SUBCLASS_PROC_COPROCESSOR 0x40 + +/* PCI device subclasses for class C (serial bus controller)*/ +#define PCI_SUBCLASS_SB_IEEE1394 0x00 +#define PCI_SUBCLASS_SB_ACCESS 0x01 +#define PCI_SUBCLASS_SB_SSA 0x02 +#define PCI_SUBCLASS_SB_USB 0x03 +#define PCI_SUBCLASS_SB_FIBRE_CHANNEL 0x04 +#define PCI_SUBCLASS_SB_SMBUS 0x05 + +#define PCI_SUBCLASS_WIRELESS_IRDA 0x00 +#define PCI_SUBCLASS_WIRELESS_CON_IR 0x01 +#define PCI_SUBCLASS_WIRELESS_RF 0x10 +#define PCI_SUBCLASS_WIRELESS_OTHER 0x80 + +#define PCI_SUBCLASS_INTIO_I2O 0x00 + +#define PCI_SUBCLASS_SAT_TV 0x01 +#define PCI_SUBCLASS_SAT_AUDIO 0x02 +#define PCI_SUBCLASS_SAT_VOICE 0x03 +#define PCI_SUBCLASS_SAT_DATA 0x04 + +#define PCI_SUBCLASS_CRYPTO_NET_COMP 0x00 +#define PCI_SUBCLASS_CRYPTO_ENTERTAINMENT 0x10 +#define PCI_SUBCLASS_CRYPTO_OTHER 0x80 + +#define PCI_SUBCLASS_DASP_DPIO 0x00 +#define PCI_SUBCLASS_DASP_OTHER 0x80 + +#define PCI_ADDRESS_IO_SPACE 0x00000001 +#define PCI_ADDRESS_MEMORY_TYPE_MASK 0x00000006 +#define PCI_ADDRESS_MEMORY_PREFETCHABLE 0x00000008 +#define PCI_ADDRESS_IO_ADDRESS_MASK 0xfffffffc +#define PCI_ADDRESS_MEMORY_ADDRESS_MASK 0xfffffff0 +#define PCI_ADDRESS_ROM_ADDRESS_MASK 0xfffff800 + +#define PCI_TYPE_32BIT 0 +#define PCI_TYPE_20BIT 2 +#define PCI_TYPE_64BIT 4 + +#define PCI_ROMADDRESS_ENABLED 0x00000001 + +#endif /* _PCI_X_ */ + +#define PCI_EXPRESS_LINK_QUIESCENT_INTERFACE_VERSION 1 + +typedef NTSTATUS +(NTAPI PCI_EXPRESS_ENTER_LINK_QUIESCENT_MODE)( + IN OUT PVOID Context); +typedef PCI_EXPRESS_ENTER_LINK_QUIESCENT_MODE *PPCI_EXPRESS_ENTER_LINK_QUIESCENT_MODE; + +typedef NTSTATUS +(NTAPI PCI_EXPRESS_EXIT_LINK_QUIESCENT_MODE)( + IN OUT PVOID Context); +typedef PCI_EXPRESS_EXIT_LINK_QUIESCENT_MODE *PPCI_EXPRESS_EXIT_LINK_QUIESCENT_MODE; + +typedef struct _PCI_EXPRESS_LINK_QUIESCENT_INTERFACE { + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; + PPCI_EXPRESS_ENTER_LINK_QUIESCENT_MODE PciExpressEnterLinkQuiescentMode; + PPCI_EXPRESS_EXIT_LINK_QUIESCENT_MODE PciExpressExitLinkQuiescentMode; +} PCI_EXPRESS_LINK_QUIESCENT_INTERFACE, *PPCI_EXPRESS_LINK_QUIESCENT_INTERFACE; + +#define PCI_EXPRESS_ROOT_PORT_INTERFACE_VERSION 1 + +typedef ULONG +(NTAPI *PPCI_EXPRESS_ROOT_PORT_READ_CONFIG_SPACE)( + IN PVOID Context, + OUT PVOID Buffer, + IN ULONG Offset, + IN ULONG Length); + +typedef ULONG +(NTAPI *PPCI_EXPRESS_ROOT_PORT_WRITE_CONFIG_SPACE)( + IN PVOID Context, + IN PVOID Buffer, + IN ULONG Offset, + IN ULONG Length); + +typedef struct _PCI_EXPRESS_ROOT_PORT_INTERFACE { + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; + PPCI_EXPRESS_ROOT_PORT_READ_CONFIG_SPACE ReadConfigSpace; + PPCI_EXPRESS_ROOT_PORT_WRITE_CONFIG_SPACE WriteConfigSpace; +} PCI_EXPRESS_ROOT_PORT_INTERFACE, *PPCI_EXPRESS_ROOT_PORT_INTERFACE; + +#define PCI_MSIX_TABLE_CONFIG_INTERFACE_VERSION 1 + +typedef NTSTATUS +(NTAPI PCI_MSIX_SET_ENTRY)( + IN PVOID Context, + IN ULONG TableEntry, + IN ULONG MessageNumber); +typedef PCI_MSIX_SET_ENTRY *PPCI_MSIX_SET_ENTRY; + +typedef NTSTATUS +(NTAPI PCI_MSIX_MASKUNMASK_ENTRY)( + IN PVOID Context, + IN ULONG TableEntry); +typedef PCI_MSIX_MASKUNMASK_ENTRY *PPCI_MSIX_MASKUNMASK_ENTRY; + +typedef NTSTATUS +(NTAPI PCI_MSIX_GET_ENTRY)( + IN PVOID Context, + IN ULONG TableEntry, + OUT PULONG MessageNumber, + OUT PBOOLEAN Masked); +typedef PCI_MSIX_GET_ENTRY *PPCI_MSIX_GET_ENTRY; + +typedef NTSTATUS +(NTAPI PCI_MSIX_GET_TABLE_SIZE)( + IN PVOID Context, + OUT PULONG TableSize); +typedef PCI_MSIX_GET_TABLE_SIZE *PPCI_MSIX_GET_TABLE_SIZE; + +typedef struct _PCI_MSIX_TABLE_CONFIG_INTERFACE { + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; + PPCI_MSIX_SET_ENTRY SetTableEntry; + PPCI_MSIX_MASKUNMASK_ENTRY MaskTableEntry; + PPCI_MSIX_MASKUNMASK_ENTRY UnmaskTableEntry; + PPCI_MSIX_GET_ENTRY GetTableEntry; + PPCI_MSIX_GET_TABLE_SIZE GetTableSize; +} PCI_MSIX_TABLE_CONFIG_INTERFACE, *PPCI_MSIX_TABLE_CONFIG_INTERFACE; + +#define PCI_MSIX_TABLE_CONFIG_MINIMUM_SIZE \ + RTL_SIZEOF_THROUGH_FIELD(PCI_MSIX_TABLE_CONFIG_INTERFACE, UnmaskTableEntry) + /****************************************************************************** * Object Manager Types * ******************************************************************************/ +#define MAXIMUM_FILENAME_LENGTH 256 +#define OBJ_NAME_PATH_SEPARATOR ((WCHAR)L'\\') + +#define OBJECT_TYPE_CREATE 0x0001 +#define OBJECT_TYPE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0x1) + +#define DIRECTORY_QUERY 0x0001 +#define DIRECTORY_TRAVERSE 0x0002 +#define DIRECTORY_CREATE_OBJECT 0x0004 +#define DIRECTORY_CREATE_SUBDIRECTORY 0x0008 +#define DIRECTORY_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0xF) + +#define SYMBOLIC_LINK_QUERY 0x0001 +#define SYMBOLIC_LINK_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0x1) + +#define DUPLICATE_CLOSE_SOURCE 0x00000001 +#define DUPLICATE_SAME_ACCESS 0x00000002 +#define DUPLICATE_SAME_ATTRIBUTES 0x00000004 + +#define OB_FLT_REGISTRATION_VERSION_0100 0x0100 +#define OB_FLT_REGISTRATION_VERSION OB_FLT_REGISTRATION_VERSION_0100 + +typedef ULONG OB_OPERATION; + +#define OB_OPERATION_HANDLE_CREATE 0x00000001 +#define OB_OPERATION_HANDLE_DUPLICATE 0x00000002 + +typedef struct _OB_PRE_CREATE_HANDLE_INFORMATION { + IN OUT ACCESS_MASK DesiredAccess; + IN ACCESS_MASK OriginalDesiredAccess; +} OB_PRE_CREATE_HANDLE_INFORMATION, *POB_PRE_CREATE_HANDLE_INFORMATION; + +typedef struct _OB_PRE_DUPLICATE_HANDLE_INFORMATION { + IN OUT ACCESS_MASK DesiredAccess; + IN ACCESS_MASK OriginalDesiredAccess; + IN PVOID SourceProcess; + IN PVOID TargetProcess; +} OB_PRE_DUPLICATE_HANDLE_INFORMATION, *POB_PRE_DUPLICATE_HANDLE_INFORMATION; + +typedef union _OB_PRE_OPERATION_PARAMETERS { + IN OUT OB_PRE_CREATE_HANDLE_INFORMATION CreateHandleInformation; + IN OUT OB_PRE_DUPLICATE_HANDLE_INFORMATION DuplicateHandleInformation; +} OB_PRE_OPERATION_PARAMETERS, *POB_PRE_OPERATION_PARAMETERS; + +typedef struct _OB_PRE_OPERATION_INFORMATION { + IN OB_OPERATION Operation; + union { + IN ULONG Flags; + struct { + IN ULONG KernelHandle:1; + IN ULONG Reserved:31; + }; + }; + IN PVOID Object; + IN POBJECT_TYPE ObjectType; + OUT PVOID CallContext; + IN POB_PRE_OPERATION_PARAMETERS Parameters; +} OB_PRE_OPERATION_INFORMATION, *POB_PRE_OPERATION_INFORMATION; + +typedef struct _OB_POST_CREATE_HANDLE_INFORMATION { + IN ACCESS_MASK GrantedAccess; +} OB_POST_CREATE_HANDLE_INFORMATION, *POB_POST_CREATE_HANDLE_INFORMATION; + +typedef struct _OB_POST_DUPLICATE_HANDLE_INFORMATION { + IN ACCESS_MASK GrantedAccess; +} OB_POST_DUPLICATE_HANDLE_INFORMATION, *POB_POST_DUPLICATE_HANDLE_INFORMATION; + +typedef union _OB_POST_OPERATION_PARAMETERS { + IN OB_POST_CREATE_HANDLE_INFORMATION CreateHandleInformation; + IN OB_POST_DUPLICATE_HANDLE_INFORMATION DuplicateHandleInformation; +} OB_POST_OPERATION_PARAMETERS, *POB_POST_OPERATION_PARAMETERS; + +typedef struct _OB_POST_OPERATION_INFORMATION { + IN OB_OPERATION Operation; + union { + IN ULONG Flags; + struct { + IN ULONG KernelHandle:1; + IN ULONG Reserved:31; + }; + }; + IN PVOID Object; + IN POBJECT_TYPE ObjectType; + IN PVOID CallContext; + IN NTSTATUS ReturnStatus; + IN POB_POST_OPERATION_PARAMETERS Parameters; +} OB_POST_OPERATION_INFORMATION,*POB_POST_OPERATION_INFORMATION; + +typedef enum _OB_PREOP_CALLBACK_STATUS { + OB_PREOP_SUCCESS +} OB_PREOP_CALLBACK_STATUS, *POB_PREOP_CALLBACK_STATUS; + +typedef OB_PREOP_CALLBACK_STATUS +(NTAPI *POB_PRE_OPERATION_CALLBACK)( + IN PVOID RegistrationContext, + IN OUT POB_PRE_OPERATION_INFORMATION OperationInformation); + +typedef VOID +(NTAPI *POB_POST_OPERATION_CALLBACK)( + IN PVOID RegistrationContext, + IN POB_POST_OPERATION_INFORMATION OperationInformation); + +typedef struct _OB_OPERATION_REGISTRATION { + IN POBJECT_TYPE *ObjectType; + IN OB_OPERATION Operations; + IN POB_PRE_OPERATION_CALLBACK PreOperation; + IN POB_POST_OPERATION_CALLBACK PostOperation; +} OB_OPERATION_REGISTRATION, *POB_OPERATION_REGISTRATION; + +typedef struct _OB_CALLBACK_REGISTRATION { + IN USHORT Version; + IN USHORT OperationRegistrationCount; + IN UNICODE_STRING Altitude; + IN PVOID RegistrationContext; + IN OB_OPERATION_REGISTRATION *OperationRegistration; +} OB_CALLBACK_REGISTRATION, *POB_CALLBACK_REGISTRATION; + typedef struct _OBJECT_NAME_INFORMATION { - UNICODE_STRING Name; + UNICODE_STRING Name; } OBJECT_NAME_INFORMATION, *POBJECT_NAME_INFORMATION; /* Exported object types */ +extern POBJECT_TYPE NTSYSAPI CmKeyObjectType; extern POBJECT_TYPE NTSYSAPI ExEventObjectType; extern POBJECT_TYPE NTSYSAPI ExSemaphoreObjectType; extern POBJECT_TYPE NTSYSAPI IoFileObjectType; @@ -5292,16 +7570,6 @@ extern POBJECT_TYPE NTSYSAPI PsProcessType; #define QUOTA_LIMITS_HARDWS_MAX_DISABLE 0x00000008 #define QUOTA_LIMITS_USE_DEFAULT_LIMITS 0x00000010 -/* Process Qoutas */ -typedef struct _QUOTA_LIMITS { - SIZE_T PagedPoolLimit; - SIZE_T NonPagedPoolLimit; - SIZE_T MinimumWorkingSetSize; - SIZE_T MaximumWorkingSetSize; - SIZE_T PagefileLimit; - LARGE_INTEGER TimeLimit; -} QUOTA_LIMITS, *PQUOTA_LIMITS; - /* Thread Access Rights */ #define THREAD_TERMINATE 0x0001 #define THREAD_SUSPEND_RESUME 0x0002 @@ -5326,18 +7594,76 @@ typedef struct _QUOTA_LIMITS { #define THREAD_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3FF) #endif -#define ES_SYSTEM_REQUIRED 0x00000001 -#define ES_DISPLAY_REQUIRED 0x00000002 -#define ES_USER_PRESENT 0x00000004 -#define ES_CONTINUOUS 0x80000000 - #define LOW_PRIORITY 0 #define LOW_REALTIME_PRIORITY 16 #define HIGH_PRIORITY 31 #define MAXIMUM_PRIORITY 32 -#ifdef _X86_ +/****************************************************************************** + * WMI Library Support Types * + ******************************************************************************/ + +#ifdef RUN_WPP +#include +#include +#endif + +#ifndef _TRACEHANDLE_DEFINED +#define _TRACEHANDLE_DEFINED +typedef ULONG64 TRACEHANDLE, *PTRACEHANDLE; +#endif + +#ifndef TRACE_INFORMATION_CLASS_DEFINE + +typedef struct _ETW_TRACE_SESSION_SETTINGS { + ULONG Version; + ULONG BufferSize; + ULONG MinimumBuffers; + ULONG MaximumBuffers; + ULONG LoggerMode; + ULONG FlushTimer; + ULONG FlushThreshold; + ULONG ClockType; +} ETW_TRACE_SESSION_SETTINGS, *PETW_TRACE_SESSION_SETTINGS; + +typedef enum _TRACE_INFORMATION_CLASS { + TraceIdClass, + TraceHandleClass, + TraceEnableFlagsClass, + TraceEnableLevelClass, + GlobalLoggerHandleClass, + EventLoggerHandleClass, + AllLoggerHandlesClass, + TraceHandleByNameClass, + LoggerEventsLostClass, + TraceSessionSettingsClass, + LoggerEventsLoggedClass, + MaxTraceInformationClass +} TRACE_INFORMATION_CLASS; + +#endif /* TRACE_INFORMATION_CLASS_DEFINE */ + +#ifndef _ETW_KM_ +#define _ETW_KM_ +#endif + +#include + +typedef VOID +(NTAPI *PETWENABLECALLBACK)( + IN LPCGUID SourceId, + IN ULONG ControlCode, + IN UCHAR Level, + IN ULONGLONG MatchAnyKeyword, + IN ULONGLONG MatchAllKeyword, + IN PEVENT_FILTER_DESCRIPTOR FilterData OPTIONAL, + IN OUT PVOID CallbackContext OPTIONAL); + +#define EVENT_WRITE_FLAG_NO_FAULTING 0x00000001 + + +#if defined(_M_IX86) /** Kernel definitions for x86 **/ /* Interrupt request levels */ @@ -5352,11 +7678,11 @@ typedef struct _QUOTA_LIMITS { #define IPI_LEVEL 29 #define POWER_LEVEL 30 #define HIGH_LEVEL 31 -#define CLOCK_LEVEL (CLOCK2_LEVEL) +#define CLOCK_LEVEL CLOCK2_LEVEL -#define KIP0PCRADDRESS 0xffdff000 +#define KIP0PCRADDRESS 0xffdff000 #define KI_USER_SHARED_DATA 0xffdf0000 -#define SharedUserData ((KUSER_SHARED_DATA * CONST) KI_USER_SHARED_DATA) +#define SharedUserData ((KUSER_SHARED_DATA * CONST)KI_USER_SHARED_DATA) #define PAGE_SIZE 0x1000 #define PAGE_SHIFT 12L @@ -5372,14 +7698,14 @@ typedef struct _QUOTA_LIMITS { typedef struct _KFLOATING_SAVE { - ULONG ControlWord; - ULONG StatusWord; - ULONG ErrorOffset; - ULONG ErrorSelector; - ULONG DataOffset; - ULONG DataSelector; - ULONG Cr0NpxState; - ULONG Spare1; + ULONG ControlWord; + ULONG StatusWord; + ULONG ErrorOffset; + ULONG ErrorSelector; + ULONG DataOffset; + ULONG DataSelector; + ULONG Cr0NpxState; + ULONG Spare1; } KFLOATING_SAVE, *PKFLOATING_SAVE; extern NTKERNELAPI volatile KSYSTEM_TIME KeTickCount; @@ -5388,8 +7714,7 @@ extern NTKERNELAPI volatile KSYSTEM_TIME KeTickCount; FORCEINLINE VOID -KeMemoryBarrier( - VOID) +KeMemoryBarrier(VOID) { volatile LONG Barrier; #if defined(__GNUC__) @@ -5399,78 +7724,80 @@ KeMemoryBarrier( #endif } +NTHALAPI +KIRQL +NTAPI +KeGetCurrentIrql(VOID); + NTHALAPI VOID FASTCALL KfLowerIrql( - IN KIRQL NewIrql); + IN KIRQL NewIrql); #define KeLowerIrql(a) KfLowerIrql(a) NTHALAPI KIRQL FASTCALL KfRaiseIrql( - IN KIRQL NewIrql); + IN KIRQL NewIrql); #define KeRaiseIrql(a,b) *(b) = KfRaiseIrql(a) NTHALAPI KIRQL -DDKAPI -KeRaiseIrqlToDpcLevel( - VOID); +NTAPI +KeRaiseIrqlToDpcLevel(VOID); NTHALAPI KIRQL -DDKAPI -KeRaiseIrqlToSynchLevel( - VOID); +NTAPI +KeRaiseIrqlToSynchLevel(VOID); NTHALAPI KIRQL FASTCALL KfAcquireSpinLock( - IN PKSPIN_LOCK SpinLock); -#define KeAcquireSpinLock(a,b) *(b) = KfAcquireSpinLock(a) + IN OUT PKSPIN_LOCK SpinLock); +#define KeAcquireSpinLock(a,b) *(b) = KfAcquireSpinLock(a) NTHALAPI VOID FASTCALL KfReleaseSpinLock( - IN PKSPIN_LOCK SpinLock, + IN OUT PKSPIN_LOCK SpinLock, IN KIRQL NewIrql); -#define KeReleaseSpinLock(a,b) KfReleaseSpinLock(a,b) +#define KeReleaseSpinLock(a,b) KfReleaseSpinLock(a,b) NTKERNELAPI VOID FASTCALL KefAcquireSpinLockAtDpcLevel( - IN PKSPIN_LOCK SpinLock); + IN OUT PKSPIN_LOCK SpinLock); #define KeAcquireSpinLockAtDpcLevel(SpinLock) KefAcquireSpinLockAtDpcLevel(SpinLock) NTKERNELAPI VOID FASTCALL KefReleaseSpinLockFromDpcLevel( - IN PKSPIN_LOCK SpinLock); + IN OUT PKSPIN_LOCK SpinLock); #define KeReleaseSpinLockFromDpcLevel(SpinLock) KefReleaseSpinLockFromDpcLevel(SpinLock) NTSYSAPI PKTHREAD NTAPI -KeGetCurrentThread( - VOID); +KeGetCurrentThread(VOID); NTKERNELAPI NTSTATUS NTAPI KeSaveFloatingPointState( - OUT PKFLOATING_SAVE FloatSave); + OUT PKFLOATING_SAVE FloatSave); NTKERNELAPI NTSTATUS NTAPI KeRestoreFloatingPointState( - IN PKFLOATING_SAVE FloatSave); + IN PKFLOATING_SAVE FloatSave); /* VOID * KeFlushIoBuffers( @@ -5488,24 +7815,358 @@ VOID _KeQueryTickCount( OUT PLARGE_INTEGER CurrentCount) { - for (;;) - { - CurrentCount->HighPart = KeTickCount.High1Time; - CurrentCount->LowPart = KeTickCount.LowPart; - if (CurrentCount->HighPart == KeTickCount.High2Time) break; - YieldProcessor(); - } + for (;;) { + CurrentCount->HighPart = KeTickCount.High1Time; + CurrentCount->LowPart = KeTickCount.LowPart; + if (CurrentCount->HighPart == KeTickCount.High2Time) break; + YieldProcessor(); + } } #define KeQueryTickCount(CurrentCount) _KeQueryTickCount(CurrentCount) -#endif /* _X86_ */ + +#elif defined(_M_AMD64) +/** Kernel definitions for AMD64 **/ + +/* Interrupt request levels */ +#define PASSIVE_LEVEL 0 +#define LOW_LEVEL 0 +#define APC_LEVEL 1 +#define DISPATCH_LEVEL 2 +#define CMCI_LEVEL 5 +#define CLOCK_LEVEL 13 +#define IPI_LEVEL 14 +#define DRS_LEVEL 14 +#define POWER_LEVEL 14 +#define PROFILE_LEVEL 15 +#define HIGH_LEVEL 15 + +#define KI_USER_SHARED_DATA 0xFFFFF78000000000ULL +#define SharedUserData ((PKUSER_SHARED_DATA const)KI_USER_SHARED_DATA) +#define SharedInterruptTime (KI_USER_SHARED_DATA + 0x8) +#define SharedSystemTime (KI_USER_SHARED_DATA + 0x14) +#define SharedTickCount (KI_USER_SHARED_DATA + 0x320) + +#define PAGE_SIZE 0x1000 +#define PAGE_SHIFT 12L + +#define EFLAG_SIGN 0x8000 +#define EFLAG_ZERO 0x4000 +#define EFLAG_SELECT (EFLAG_SIGN | EFLAG_ZERO) + +#define RESULT_NEGATIVE ((EFLAG_SIGN & ~EFLAG_ZERO) & EFLAG_SELECT) +#define RESULT_ZERO ((~EFLAG_SIGN & EFLAG_ZERO) & EFLAG_SELECT) +#define RESULT_POSITIVE ((~EFLAG_SIGN & ~EFLAG_ZERO) & EFLAG_SELECT) + + +typedef struct _KFLOATING_SAVE { + ULONG Dummy; +} KFLOATING_SAVE, *PKFLOATING_SAVE; + +typedef XSAVE_FORMAT XMM_SAVE_AREA32, *PXMM_SAVE_AREA32; + +#define KeQueryInterruptTime() \ + (*(volatile ULONG64*)SharedInterruptTime) + +#define KeQuerySystemTime(CurrentCount) \ + *(ULONG64*)(CurrentCount) = *(volatile ULONG64*)SharedSystemTime + +#define KeQueryTickCount(CurrentCount) \ + *(ULONG64*)(CurrentCount) = *(volatile ULONG64*)SharedTickCount + +#define KeGetDcacheFillSize() 1L + +#define YieldProcessor _mm_pause + +FORCEINLINE +KIRQL +KeGetCurrentIrql(VOID) +{ + return (KIRQL)__readcr8(); +} + +FORCEINLINE +VOID +KeLowerIrql(IN KIRQL NewIrql) +{ + //ASSERT(KeGetCurrentIrql() >= NewIrql); + __writecr8(NewIrql); +} + +FORCEINLINE +KIRQL +KfRaiseIrql(IN KIRQL NewIrql) +{ + KIRQL OldIrql; + + OldIrql = __readcr8(); + //ASSERT(OldIrql <= NewIrql); + __writecr8(NewIrql); + return OldIrql; +} +#define KeRaiseIrql(a,b) *(b) = KfRaiseIrql(a) + +FORCEINLINE +KIRQL +KeRaiseIrqlToDpcLevel(VOID) +{ + return KfRaiseIrql(DISPATCH_LEVEL); +} + +FORCEINLINE +KIRQL +KeRaiseIrqlToSynchLevel(VOID) +{ + return KfRaiseIrql(12); // SYNCH_LEVEL = IPI_LEVEL - 2 +} + +#define KeAcquireSpinLock(SpinLock, OldIrql) \ + *(OldIrql) = KeAcquireSpinLockRaiseToDpc(SpinLock) + +FORCEINLINE +PKTHREAD +KeGetCurrentThread(VOID) +{ + return (struct _KTHREAD *)__readgsqword(0x188); +} + +/* VOID + * KeFlushIoBuffers( + * IN PMDL Mdl, + * IN BOOLEAN ReadOperation, + * IN BOOLEAN DmaOperation) + */ +#define KeFlushIoBuffers(_Mdl, _ReadOperation, _DmaOperation) + +/* x86 and x64 performs a 0x2C interrupt */ +#define DbgRaiseAssertionFailure __int2c + +#elif defined(_M_IA64) +/** Kernel definitions for IA64 **/ + +/* Interrupt request levels */ +#define PASSIVE_LEVEL 0 +#define LOW_LEVEL 0 +#define APC_LEVEL 1 +#define DISPATCH_LEVEL 2 +#define CMC_LEVEL 3 +#define DEVICE_LEVEL_BASE 4 +#define PC_LEVEL 12 +#define IPI_LEVEL 14 +#define DRS_LEVEL 14 +#define CLOCK_LEVEL 13 +#define POWER_LEVEL 15 +#define PROFILE_LEVEL 15 +#define HIGH_LEVEL 15 + +#define KI_USER_SHARED_DATA ((ULONG_PTR)(KADDRESS_BASE + 0xFFFE0000)) +extern volatile LARGE_INTEGER KeTickCount; + +#define PAUSE_PROCESSOR __yield(); + +FORCEINLINE +VOID +KeFlushWriteBuffer(VOID) +{ + __mf (); + return; +} + +NTSYSAPI +PKTHREAD +NTAPI +KeGetCurrentThread(VOID); + + +#elif defined(_M_PPC) + +/* Interrupt request levels */ +#define PASSIVE_LEVEL 0 +#define LOW_LEVEL 0 +#define APC_LEVEL 1 +#define DISPATCH_LEVEL 2 +#define PROFILE_LEVEL 27 +#define CLOCK1_LEVEL 28 +#define CLOCK2_LEVEL 28 +#define IPI_LEVEL 29 +#define POWER_LEVEL 30 +#define HIGH_LEVEL 31 + +// +// Used to contain PFNs and PFN counts +// +typedef ULONG PFN_COUNT; +typedef ULONG PFN_NUMBER, *PPFN_NUMBER; +typedef LONG SPFN_NUMBER, *PSPFN_NUMBER; + + +typedef struct _KFLOATING_SAVE { + ULONG Dummy; +} KFLOATING_SAVE, *PKFLOATING_SAVE; + +typedef struct _KPCR_TIB { + PVOID ExceptionList; /* 00 */ + PVOID StackBase; /* 04 */ + PVOID StackLimit; /* 08 */ + PVOID SubSystemTib; /* 0C */ + _ANONYMOUS_UNION union { + PVOID FiberData; /* 10 */ + ULONG Version; /* 10 */ + } DUMMYUNIONNAME; + PVOID ArbitraryUserPointer; /* 14 */ + struct _KPCR_TIB *Self; /* 18 */ +} KPCR_TIB, *PKPCR_TIB; /* 1C */ + +#define PCR_MINOR_VERSION 1 +#define PCR_MAJOR_VERSION 1 + +typedef struct _KPCR { + KPCR_TIB Tib; /* 00 */ + struct _KPCR *Self; /* 1C */ + struct _KPRCB *Prcb; /* 20 */ + KIRQL Irql; /* 24 */ + ULONG IRR; /* 28 */ + ULONG IrrActive; /* 2C */ + ULONG IDR; /* 30 */ + PVOID KdVersionBlock; /* 34 */ + PUSHORT IDT; /* 38 */ + PUSHORT GDT; /* 3C */ + struct _KTSS *TSS; /* 40 */ + USHORT MajorVersion; /* 44 */ + USHORT MinorVersion; /* 46 */ + KAFFINITY SetMember; /* 48 */ + ULONG StallScaleFactor; /* 4C */ + UCHAR SpareUnused; /* 50 */ + UCHAR Number; /* 51 */ +} KPCR, *PKPCR; /* 54 */ + +#define KeGetPcr() PCR + +#define YieldProcessor() __asm__ __volatile__("nop"); + +FORCEINLINE +ULONG +NTAPI +KeGetCurrentProcessorNumber(VOID) +{ + ULONG Number; + __asm__ __volatile__ ( + "lwz %0, %c1(12)\n" + : "=r" (Number) + : "i" (FIELD_OFFSET(KPCR, Number)) + ); + return Number; +} + +NTHALAPI +VOID +FASTCALL +KfLowerIrql( + IN KIRQL NewIrql); +#define KeLowerIrql(a) KfLowerIrql(a) + +NTHALAPI +KIRQL +FASTCALL +KfRaiseIrql( + IN KIRQL NewIrql); +#define KeRaiseIrql(a,b) *(b) = KfRaiseIrql(a) + +NTHALAPI +KIRQL +NTAPI +KeRaiseIrqlToDpcLevel(VOID); + +NTHALAPI +KIRQL +NTAPI +KeRaiseIrqlToSynchLevel(VOID); + + + +#elif defined(_M_MIPS) +#error MIPS Headers are totally incorrect + +// +// Used to contain PFNs and PFN counts +// +typedef ULONG PFN_COUNT; +typedef ULONG PFN_NUMBER, *PPFN_NUMBER; +typedef LONG SPFN_NUMBER, *PSPFN_NUMBER; + +#define PASSIVE_LEVEL 0 +#define APC_LEVEL 1 +#define DISPATCH_LEVEL 2 +#define PROFILE_LEVEL 27 +#define IPI_LEVEL 29 +#define HIGH_LEVEL 31 + +typedef struct _KPCR { + struct _KPRCB *Prcb; /* 20 */ + KIRQL Irql; /* 24 */ + ULONG IRR; /* 28 */ + ULONG IDR; /* 30 */ +} KPCR, *PKPCR; + +#define KeGetPcr() PCR + +typedef struct _KFLOATING_SAVE { +} KFLOATING_SAVE, *PKFLOATING_SAVE; + +static __inline +ULONG +NTAPI +KeGetCurrentProcessorNumber(VOID) +{ + return 0; +} + +#define YieldProcessor() __asm__ __volatile__("nop"); + +#define KeLowerIrql(a) KfLowerIrql(a) +#define KeRaiseIrql(a,b) *(b) = KfRaiseIrql(a) + +NTKERNELAPI +VOID +NTAPI +KfLowerIrql( + IN KIRQL NewIrql); + +NTKERNELAPI +KIRQL +NTAPI +KfRaiseIrql( + IN KIRQL NewIrql); + +NTKERNELAPI +KIRQL +NTAPI +KeRaiseIrqlToDpcLevel(VOID); + +NTKERNELAPI +KIRQL +NTAPI +KeRaiseIrqlToSynchLevel(VOID); + + +#elif defined(_M_ARM) +#include +#else +#error Unknown Architecture +#endif + /****************************************************************************** * Runtime Library Functions * ******************************************************************************/ + +#if !defined(MIDL_PASS) && !defined(SORTPP_PASS) + +#define RTL_STATIC_LIST_HEAD(x) LIST_ENTRY x = { &x, &x } + FORCEINLINE VOID InitializeListHead( @@ -5514,11 +8175,78 @@ InitializeListHead( ListHead->Flink = ListHead->Blink = ListHead; } +BOOLEAN +FORCEINLINE +IsListEmpty( + IN CONST LIST_ENTRY * ListHead) +{ + return (BOOLEAN)(ListHead->Flink == ListHead); +} + +FORCEINLINE +BOOLEAN +RemoveEntryList( + IN PLIST_ENTRY Entry) +{ + PLIST_ENTRY OldFlink; + PLIST_ENTRY OldBlink; + + OldFlink = Entry->Flink; + OldBlink = Entry->Blink; + OldFlink->Blink = OldBlink; + OldBlink->Flink = OldFlink; + return (BOOLEAN)(OldFlink == OldBlink); +} + +FORCEINLINE +PLIST_ENTRY +RemoveHeadList( + IN OUT PLIST_ENTRY ListHead) +{ + PLIST_ENTRY Flink; + PLIST_ENTRY Entry; + + Entry = ListHead->Flink; + Flink = Entry->Flink; + ListHead->Flink = Flink; + Flink->Blink = ListHead; + return Entry; +} + +FORCEINLINE +PLIST_ENTRY +RemoveTailList( + IN OUT PLIST_ENTRY ListHead) +{ + PLIST_ENTRY Blink; + PLIST_ENTRY Entry; + + Entry = ListHead->Blink; + Blink = Entry->Blink; + ListHead->Blink = Blink; + Blink->Flink = ListHead; + return Entry; +} + +FORCEINLINE +VOID +InsertTailList( + IN OUT PLIST_ENTRY ListHead, + IN OUT PLIST_ENTRY Entry) +{ + PLIST_ENTRY OldBlink; + OldBlink = ListHead->Blink; + Entry->Flink = ListHead; + Entry->Blink = OldBlink; + OldBlink->Flink = Entry; + ListHead->Blink = Entry; +} + FORCEINLINE VOID InsertHeadList( - IN OUT PLIST_ENTRY ListHead, - IN OUT PLIST_ENTRY Entry) + IN OUT PLIST_ENTRY ListHead, + IN OUT PLIST_ENTRY Entry) { PLIST_ENTRY OldFlink; OldFlink = ListHead->Flink; @@ -5530,24 +8258,16 @@ InsertHeadList( FORCEINLINE VOID -InsertTailList( - IN OUT PLIST_ENTRY ListHead, - IN OUT PLIST_ENTRY Entry) +AppendTailList( + IN OUT PLIST_ENTRY ListHead, + IN OUT PLIST_ENTRY ListToAppend) { - PLIST_ENTRY OldBlink; - OldBlink = ListHead->Blink; - Entry->Flink = ListHead; - Entry->Blink = OldBlink; - OldBlink->Flink = Entry; - ListHead->Blink = Entry; -} + PLIST_ENTRY ListEnd = ListHead->Blink; -BOOLEAN -FORCEINLINE -IsListEmpty( - IN CONST LIST_ENTRY * ListHead) -{ - return (BOOLEAN)(ListHead->Flink == ListHead); + ListHead->Blink->Flink = ListToAppend; + ListHead->Blink = ListToAppend->Blink; + ListToAppend->Blink->Flink = ListHead; + ListToAppend->Blink = ListEnd; } FORCEINLINE @@ -5573,59 +8293,16 @@ PushEntryList( ListHead->Next = Entry; } -FORCEINLINE -BOOLEAN -RemoveEntryList( - IN PLIST_ENTRY Entry) -{ - PLIST_ENTRY OldFlink; - PLIST_ENTRY OldBlink; - - OldFlink = Entry->Flink; - OldBlink = Entry->Blink; - OldFlink->Blink = OldBlink; - OldBlink->Flink = OldFlink; - return (BOOLEAN)(OldFlink == OldBlink); -} - -FORCEINLINE -PLIST_ENTRY -RemoveHeadList( - IN OUT PLIST_ENTRY ListHead) -{ - PLIST_ENTRY Flink; - PLIST_ENTRY Entry; - - Entry = ListHead->Flink; - Flink = Entry->Flink; - ListHead->Flink = Flink; - Flink->Blink = ListHead; - return Entry; -} - -FORCEINLINE -PLIST_ENTRY -RemoveTailList( - IN OUT PLIST_ENTRY ListHead) -{ - PLIST_ENTRY Blink; - PLIST_ENTRY Entry; - - Entry = ListHead->Blink; - Blink = Entry->Blink; - ListHead->Blink = Blink; - Blink->Flink = ListHead; - return Entry; -} +#endif /* !defined(MIDL_PASS) && !defined(SORTPP_PASS) */ NTSYSAPI VOID NTAPI RtlAssert( - IN PVOID FailedAssertion, - IN PVOID FileName, - IN ULONG LineNumber, - IN PSTR Message); + IN PVOID FailedAssertion, + IN PVOID FileName, + IN ULONG LineNumber, + IN PSTR Message); /* VOID * RtlCopyMemory( @@ -5643,9 +8320,9 @@ NTSYSAPI VOID NTAPI RtlCopyMemoryNonTemporal( - VOID UNALIGNED *Destination, - CONST VOID UNALIGNED *Source, - SIZE_T Length); + VOID UNALIGNED *Destination, + CONST VOID UNALIGNED *Source, + SIZE_T Length); #else #define RtlCopyMemoryNonTemporal RtlCopyMemory #endif @@ -5682,21 +8359,21 @@ NTSYSAPI VOID NTAPI RtlFreeUnicodeString( - IN OUT PUNICODE_STRING UnicodeString); + IN OUT PUNICODE_STRING UnicodeString); NTSYSAPI NTSTATUS NTAPI RtlGUIDFromString( - IN PUNICODE_STRING GuidString, - OUT GUID *Guid); + IN PUNICODE_STRING GuidString, + OUT GUID *Guid); NTSYSAPI VOID NTAPI RtlInitUnicodeString( - IN OUT PUNICODE_STRING DestinationString, - IN PCWSTR SourceString OPTIONAL); + IN OUT PUNICODE_STRING DestinationString, + IN PCWSTR SourceString OPTIONAL); /* VOID * RtlMoveMemory( @@ -5711,8 +8388,8 @@ NTSYSAPI NTSTATUS NTAPI RtlStringFromGUID( - IN REFGUID Guid, - OUT PUNICODE_STRING GuidString); + IN REFGUID Guid, + OUT PUNICODE_STRING GuidString); /* VOID * RtlZeroMemory( @@ -5724,37 +8401,39 @@ RtlStringFromGUID( #define RtlZeroBytes RtlZeroMemory - #if (NTDDI_VERSION >= NTDDI_WIN2K) + + + NTSYSAPI BOOLEAN NTAPI RtlAreBitsClear( - IN PRTL_BITMAP BitMapHeader, - IN ULONG StartingIndex, - IN ULONG Length); + IN PRTL_BITMAP BitMapHeader, + IN ULONG StartingIndex, + IN ULONG Length); NTSYSAPI BOOLEAN NTAPI RtlAreBitsSet( - IN PRTL_BITMAP BitMapHeader, - IN ULONG StartingIndex, - IN ULONG Length); + IN PRTL_BITMAP BitMapHeader, + IN ULONG StartingIndex, + IN ULONG Length); NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString( - IN OUT PUNICODE_STRING DestinationString, - IN PANSI_STRING SourceString, - IN BOOLEAN AllocateDestinationString); + IN OUT PUNICODE_STRING DestinationString, + IN PANSI_STRING SourceString, + IN BOOLEAN AllocateDestinationString); NTSYSAPI ULONG NTAPI RtlxAnsiStringToUnicodeSize( - IN PCANSI_STRING AnsiString); + IN PCANSI_STRING AnsiString); #define RtlAnsiStringToUnicodeSize(String) ( \ NLS_MB_CODE_PAGE_TAG ? \ @@ -5766,107 +8445,107 @@ NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString( - IN OUT PUNICODE_STRING Destination, - IN PCUNICODE_STRING Source); + IN OUT PUNICODE_STRING Destination, + IN PCUNICODE_STRING Source); NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeToString( - IN OUT PUNICODE_STRING Destination, - IN PCWSTR Source); + IN OUT PUNICODE_STRING Destination, + IN PCWSTR Source); NTSYSAPI NTSTATUS NTAPI RtlCheckRegistryKey( - IN ULONG RelativeTo, - IN PWSTR Path); + IN ULONG RelativeTo, + IN PWSTR Path); NTSYSAPI VOID NTAPI RtlClearAllBits( - IN PRTL_BITMAP BitMapHeader); + IN PRTL_BITMAP BitMapHeader); NTSYSAPI VOID NTAPI RtlClearBits( - IN PRTL_BITMAP BitMapHeader, - IN ULONG StartingIndex, - IN ULONG NumberToClear); + IN PRTL_BITMAP BitMapHeader, + IN ULONG StartingIndex, + IN ULONG NumberToClear); NTSYSAPI SIZE_T NTAPI RtlCompareMemory( - IN CONST VOID *Source1, - IN CONST VOID *Source2, - IN SIZE_T Length); + IN CONST VOID *Source1, + IN CONST VOID *Source2, + IN SIZE_T Length); NTSYSAPI LONG NTAPI RtlCompareUnicodeString( - IN PCUNICODE_STRING String1, - IN PCUNICODE_STRING String2, - IN BOOLEAN CaseInSensitive); + IN PCUNICODE_STRING String1, + IN PCUNICODE_STRING String2, + IN BOOLEAN CaseInSensitive); NTSYSAPI LONG NTAPI RtlCompareUnicodeStrings( - IN PCWCH String1, - IN SIZE_T String1Length, - IN PCWCH String2, - IN SIZE_T String2Length, - IN BOOLEAN CaseInSensitive); + IN PCWCH String1, + IN SIZE_T String1Length, + IN PCWCH String2, + IN SIZE_T String2Length, + IN BOOLEAN CaseInSensitive); NTSYSAPI VOID NTAPI RtlCopyUnicodeString( - IN OUT PUNICODE_STRING DestinationString, - IN PCUNICODE_STRING SourceString); + IN OUT PUNICODE_STRING DestinationString, + IN PCUNICODE_STRING SourceString OPTIONAL); NTSYSAPI NTSTATUS NTAPI RtlCreateRegistryKey( - IN ULONG RelativeTo, - IN PWSTR Path); + IN ULONG RelativeTo, + IN PWSTR Path); NTSYSAPI NTSTATUS NTAPI RtlCreateSecurityDescriptor( - IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor, - IN ULONG Revision); + IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor, + IN ULONG Revision); NTSYSAPI NTSTATUS NTAPI RtlDeleteRegistryValue( - IN ULONG RelativeTo, - IN PCWSTR Path, - IN PCWSTR ValueName); + IN ULONG RelativeTo, + IN PCWSTR Path, + IN PCWSTR ValueName); NTSYSAPI BOOLEAN NTAPI RtlEqualUnicodeString( - IN CONST UNICODE_STRING *String1, - IN CONST UNICODE_STRING *String2, - IN BOOLEAN CaseInSensitive); + IN CONST UNICODE_STRING *String1, + IN CONST UNICODE_STRING *String2, + IN BOOLEAN CaseInSensitive); #if !defined(_AMD64_) && !defined(_IA64_) NTSYSAPI LARGE_INTEGER NTAPI RtlExtendedIntegerMultiply( - IN LARGE_INTEGER Multiplicand, - IN LONG Multiplier); + IN LARGE_INTEGER Multiplicand, + IN LONG Multiplier); NTSYSAPI LARGE_INTEGER @@ -5874,7 +8553,7 @@ NTAPI RtlExtendedLargeIntegerDivide( IN LARGE_INTEGER Dividend, IN ULONG Divisor, - IN OUT PULONG Remainder); + OUT PULONG Remainder OPTIONAL); #endif #if defined(_X86_) || defined(_IA64_) @@ -5891,137 +8570,128 @@ NTSYSAPI VOID NTAPI RtlFreeAnsiString( - IN PANSI_STRING AnsiString); + IN PANSI_STRING AnsiString); NTSYSAPI ULONG NTAPI RtlFindClearBits( - IN PRTL_BITMAP BitMapHeader, - IN ULONG NumberToFind, - IN ULONG HintIndex); + IN PRTL_BITMAP BitMapHeader, + IN ULONG NumberToFind, + IN ULONG HintIndex); NTSYSAPI ULONG NTAPI RtlFindClearBitsAndSet( - IN PRTL_BITMAP BitMapHeader, - IN ULONG NumberToFind, - IN ULONG HintIndex); + IN PRTL_BITMAP BitMapHeader, + IN ULONG NumberToFind, + IN ULONG HintIndex); NTSYSAPI ULONG NTAPI RtlFindFirstRunClear( - IN PRTL_BITMAP BitMapHeader, - OUT PULONG StartingIndex); + IN PRTL_BITMAP BitMapHeader, + OUT PULONG StartingIndex); NTSYSAPI ULONG NTAPI RtlFindClearRuns( - IN PRTL_BITMAP BitMapHeader, - OUT PRTL_BITMAP_RUN RunArray, - IN ULONG SizeOfRunArray, - IN BOOLEAN LocateLongestRuns); + IN PRTL_BITMAP BitMapHeader, + OUT PRTL_BITMAP_RUN RunArray, + IN ULONG SizeOfRunArray, + IN BOOLEAN LocateLongestRuns); NTSYSAPI ULONG NTAPI RtlFindLastBackwardRunClear( - IN PRTL_BITMAP BitMapHeader, - IN ULONG FromIndex, - OUT PULONG StartingRunIndex); + IN PRTL_BITMAP BitMapHeader, + IN ULONG FromIndex, + OUT PULONG StartingRunIndex); NTSYSAPI CCHAR NTAPI RtlFindLeastSignificantBit( - IN ULONGLONG Set); + IN ULONGLONG Set); NTSYSAPI ULONG NTAPI RtlFindLongestRunClear( - IN PRTL_BITMAP BitMapHeader, - OUT PULONG StartingIndex); + IN PRTL_BITMAP BitMapHeader, + OUT PULONG StartingIndex); NTSYSAPI CCHAR NTAPI RtlFindMostSignificantBit( - IN ULONGLONG Set); + IN ULONGLONG Set); NTSYSAPI ULONG NTAPI RtlFindNextForwardRunClear( - IN PRTL_BITMAP BitMapHeader, - IN ULONG FromIndex, - OUT PULONG StartingRunIndex); + IN PRTL_BITMAP BitMapHeader, + IN ULONG FromIndex, + OUT PULONG StartingRunIndex); NTSYSAPI ULONG NTAPI RtlFindSetBits( - IN PRTL_BITMAP BitMapHeader, - IN ULONG NumberToFind, - IN ULONG HintIndex); + IN PRTL_BITMAP BitMapHeader, + IN ULONG NumberToFind, + IN ULONG HintIndex); NTSYSAPI ULONG NTAPI RtlFindSetBitsAndClear( - IN PRTL_BITMAP BitMapHeader, - IN ULONG NumberToFind, - IN ULONG HintIndex); - -NTSYSAPI -NTSTATUS -NTAPI -RtlHashUnicodeString( - IN CONST UNICODE_STRING *String, - IN BOOLEAN CaseInSensitive, - IN ULONG HashAlgorithm, - OUT PULONG HashValue); + IN PRTL_BITMAP BitMapHeader, + IN ULONG NumberToFind, + IN ULONG HintIndex); NTSYSAPI VOID NTAPI RtlInitAnsiString( - IN OUT PANSI_STRING DestinationString, - IN PCSZ SourceString); + IN OUT PANSI_STRING DestinationString, + IN PCSZ SourceString); NTSYSAPI VOID NTAPI RtlInitializeBitMap( - IN PRTL_BITMAP BitMapHeader, - IN PULONG BitMapBuffer, - IN ULONG SizeOfBitMap); + IN PRTL_BITMAP BitMapHeader, + IN PULONG BitMapBuffer, + IN ULONG SizeOfBitMap); NTSYSAPI VOID NTAPI RtlInitString( - IN OUT PSTRING DestinationString, - IN PCSZ SourceString); + IN OUT PSTRING DestinationString, + IN PCSZ SourceString); NTSYSAPI NTSTATUS NTAPI RtlIntegerToUnicodeString( - IN ULONG Value, - IN ULONG Base OPTIONAL, - IN OUT PUNICODE_STRING String); + IN ULONG Value, + IN ULONG Base OPTIONAL, + IN OUT PUNICODE_STRING String); NTSYSAPI NTSTATUS NTAPI RtlInt64ToUnicodeString( - IN ULONGLONG Value, - IN ULONG Base OPTIONAL, - IN OUT PUNICODE_STRING String); + IN ULONGLONG Value, + IN ULONG Base OPTIONAL, + IN OUT PUNICODE_STRING String); #ifdef _WIN64 #define RtlIntPtrToUnicodeString(Value, Base, String) \ @@ -6042,42 +8712,151 @@ NTSYSAPI ULONG NTAPI RtlLengthSecurityDescriptor( - IN PSECURITY_DESCRIPTOR SecurityDescriptor); + IN PSECURITY_DESCRIPTOR SecurityDescriptor); NTSYSAPI ULONG NTAPI RtlNumberOfClearBits( - IN PRTL_BITMAP BitMapHeader); + IN PRTL_BITMAP BitMapHeader); NTSYSAPI ULONG NTAPI RtlNumberOfSetBits( - IN PRTL_BITMAP BitMapHeader); + IN PRTL_BITMAP BitMapHeader); NTSYSAPI NTSTATUS NTAPI RtlQueryRegistryValues( - IN ULONG RelativeTo, - IN PCWSTR Path, - IN PRTL_QUERY_REGISTRY_TABLE QueryTable, - IN PVOID Context, - IN PVOID Environment OPTIONAL); + IN ULONG RelativeTo, + IN PCWSTR Path, + IN OUT PRTL_QUERY_REGISTRY_TABLE QueryTable, + IN PVOID Context OPTIONAL, + IN PVOID Environment OPTIONAL); +#define SHORT_SIZE (sizeof(USHORT)) +#define SHORT_MASK (SHORT_SIZE - 1) #define LONG_SIZE (sizeof(LONG)) +#define LONGLONG_SIZE (sizeof(LONGLONG)) #define LONG_MASK (LONG_SIZE - 1) +#define LONGLONG_MASK (LONGLONG_SIZE - 1) +#define LOWBYTE_MASK 0x00FF + +#define FIRSTBYTE(VALUE) ((VALUE) & LOWBYTE_MASK) +#define SECONDBYTE(VALUE) (((VALUE) >> 8) & LOWBYTE_MASK) +#define THIRDBYTE(VALUE) (((VALUE) >> 16) & LOWBYTE_MASK) +#define FOURTHBYTE(VALUE) (((VALUE) >> 24) & LOWBYTE_MASK) + +NTSYSAPI +VOID +NTAPI +RtlSetAllBits( + IN PRTL_BITMAP BitMapHeader); + +NTSYSAPI +VOID +NTAPI +RtlSetBits( + IN PRTL_BITMAP BitMapHeader, + IN ULONG StartingIndex, + IN ULONG NumberToSet); + +NTSYSAPI +NTSTATUS +NTAPI +RtlSetDaclSecurityDescriptor( + IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor, + IN BOOLEAN DaclPresent, + IN PACL Dacl OPTIONAL, + IN BOOLEAN DaclDefaulted OPTIONAL); + +#if defined(_AMD64_) + +/* VOID + * RtlStoreUlong( + * IN PULONG Address, + * IN ULONG Value); + */ +#define RtlStoreUlong(Address,Value) \ + *(ULONG UNALIGNED *)(Address) = (Value) + +/* VOID + * RtlStoreUlonglong( + * IN OUT PULONGLONG Address, + * ULONGLONG Value); + */ +#define RtlStoreUlonglong(Address,Value) \ + *(ULONGLONG UNALIGNED *)(Address) = (Value) + +/* VOID + * RtlStoreUshort( + * IN PUSHORT Address, + * IN USHORT Value); + */ +#define RtlStoreUshort(Address,Value) \ + *(USHORT UNALIGNED *)(Address) = (Value) + +/* VOID + * RtlRetrieveUshort( + * PUSHORT DestinationAddress, + * PUSHORT SourceAddress); + */ +#define RtlRetrieveUshort(DestAddress,SrcAddress) \ + *(USHORT UNALIGNED *)(DestAddress) = *(USHORT)(SrcAddress) /* VOID * RtlRetrieveUlong( - * PULONG DestinationAddress, - * PULONG SourceAddress); + * PULONG DestinationAddress, + * PULONG SourceAddress); */ -#if defined(_AMD64_) #define RtlRetrieveUlong(DestAddress,SrcAddress) \ *(ULONG UNALIGNED *)(DestAddress) = *(PULONG)(SrcAddress) + #else + +#define RtlStoreUlong(Address,Value) \ + if ((ULONG_PTR)(Address) & LONG_MASK) { \ + ((PUCHAR) (Address))[LONG_LEAST_SIGNIFICANT_BIT] = (UCHAR)(FIRSTBYTE(Value)); \ + ((PUCHAR) (Address))[LONG_3RD_MOST_SIGNIFICANT_BIT] = (UCHAR)(SECONDBYTE(Value)); \ + ((PUCHAR) (Address))[LONG_2ND_MOST_SIGNIFICANT_BIT] = (UCHAR)(THIRDBYTE(Value)); \ + ((PUCHAR) (Address))[LONG_MOST_SIGNIFICANT_BIT] = (UCHAR)(FOURTHBYTE(Value)); \ + } \ + else { \ + *((PULONG)(Address)) = (ULONG) (Value); \ + } + +#define RtlStoreUlonglong(Address,Value) \ + if ((ULONG_PTR)(Address) & LONGLONG_MASK) { \ + RtlStoreUlong((ULONG_PTR)(Address), \ + (ULONGLONG)(Value) & 0xFFFFFFFF); \ + RtlStoreUlong((ULONG_PTR)(Address)+sizeof(ULONG), \ + (ULONGLONG)(Value) >> 32); \ + } else { \ + *((PULONGLONG)(Address)) = (ULONGLONG)(Value); \ + } + +#define RtlStoreUshort(Address,Value) \ + if ((ULONG_PTR)(Address) & SHORT_MASK) { \ + ((PUCHAR) (Address))[SHORT_LEAST_SIGNIFICANT_BIT] = (UCHAR)(FIRSTBYTE(Value)); \ + ((PUCHAR) (Address))[SHORT_MOST_SIGNIFICANT_BIT ] = (UCHAR)(SECONDBYTE(Value)); \ + } \ + else { \ + *((PUSHORT) (Address)) = (USHORT)Value; \ + } + +#define RtlRetrieveUshort(DestAddress,SrcAddress) \ + if ((ULONG_PTR)(SrcAddress) & LONG_MASK) \ + { \ + ((PUCHAR)(DestAddress))[0]=((PUCHAR)(SrcAddress))[0]; \ + ((PUCHAR)(DestAddress))[1]=((PUCHAR)(SrcAddress))[1]; \ + } \ + else \ + { \ + *((PUSHORT)(DestAddress))=*((PUSHORT)(SrcAddress)); \ + } + #define RtlRetrieveUlong(DestAddress,SrcAddress) \ if ((ULONG_PTR)(SrcAddress) & LONG_MASK) \ { \ @@ -6090,164 +8869,60 @@ RtlQueryRegistryValues( { \ *((PULONG)(DestAddress))=*((PULONG)(SrcAddress)); \ } -#endif -/* VOID - * RtlRetrieveUshort( - * PUSHORT DestinationAddress, - * PUSHORT SourceAddress); - */ -#if defined(_AMD64_) -#define RtlRetrieveUshort(DestAddress,SrcAddress) \ - *(USHORT UNALIGNED *)(DestAddress) = *(USHORT)(SrcAddress) -#else -#define RtlRetrieveUshort(DestAddress,SrcAddress) \ - if ((ULONG_PTR)(SrcAddress) & LONG_MASK) \ - { \ - ((PUCHAR)(DestAddress))[0]=((PUCHAR)(SrcAddress))[0]; \ - ((PUCHAR)(DestAddress))[1]=((PUCHAR)(SrcAddress))[1]; \ - } \ - else \ - { \ - *((PUSHORT)(DestAddress))=*((PUSHORT)(SrcAddress)); \ - } -#endif - -NTSYSAPI -VOID -NTAPI -RtlSetAllBits( - IN PRTL_BITMAP BitMapHeader); - -NTSYSAPI -VOID -NTAPI -RtlSetBits( - IN PRTL_BITMAP BitMapHeader, - IN ULONG StartingIndex, - IN ULONG NumberToSet); - -NTSYSAPI -NTSTATUS -NTAPI -RtlSetDaclSecurityDescriptor( - IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor, - IN BOOLEAN DaclPresent, - IN PACL Dacl OPTIONAL, - IN BOOLEAN DaclDefaulted OPTIONAL); - -/* VOID - * RtlStoreUlong( - * IN PULONG Address, - * IN ULONG Value); - */ -#if defined(_AMD64_) -#define RtlStoreUlong(Address,Value) \ - *(ULONG UNALIGNED *)(Address) = (Value) -#else -#define RtlStoreUlong(Address,Value) \ - if ((ULONG_PTR)(Address) & LONG_MASK) { \ - ((PUCHAR) (Address))[LONG_LEAST_SIGNIFICANT_BIT] = (UCHAR)(FIRSTBYTE(Value)); \ - ((PUCHAR) (Address))[LONG_3RD_MOST_SIGNIFICANT_BIT] = (UCHAR)(SECONDBYTE(Value)); \ - ((PUCHAR) (Address))[LONG_2ND_MOST_SIGNIFICANT_BIT] = (UCHAR)(THIRDBYTE(Value)); \ - ((PUCHAR) (Address))[LONG_MOST_SIGNIFICANT_BIT] = (UCHAR)(FOURTHBYTE(Value)); \ - } \ - else { \ - *((PULONG)(Address)) = (ULONG) (Value); \ - } -#endif - -/* VOID - * RtlStoreUlonglong( - * IN OUT PULONGLONG Address, - * ULONGLONG Value); - */ -#if defined(_AMD64_) -#define RtlStoreUlonglong(Address,Value) \ - *(ULONGLONG UNALIGNED *)(Address) = (Value) -#else -#define RtlStoreUlonglong(Address,Value) \ - if ((ULONG_PTR)(Address) & LONGLONG_MASK) { \ - RtlStoreUlong((ULONG_PTR)(Address), \ - (ULONGLONG)(Value) & 0xFFFFFFFF); \ - RtlStoreUlong((ULONG_PTR)(Address)+sizeof(ULONG), \ - (ULONGLONG)(Value) >> 32); \ - } else { \ - *((PULONGLONG)(Address)) = (ULONGLONG)(Value); \ - } -#endif +#endif /* defined(_AMD64_) */ +#ifdef _WIN64 /* VOID * RtlStoreUlongPtr( * IN OUT PULONG_PTR Address, * IN ULONG_PTR Value); */ -#ifdef _WIN64 -#define RtlStoreUlongPtr(Address,Value) \ - RtlStoreUlonglong(Address,Value) +#define RtlStoreUlongPtr(Address,Value) RtlStoreUlonglong(Address,Value) #else -#define RtlStoreUlongPtr(Address,Value) \ - RtlStoreUlong(Address,Value) -#endif +#define RtlStoreUlongPtr(Address,Value) RtlStoreUlong(Address,Value) +#endif /* _WIN64 */ -/* VOID - * RtlStoreUshort( - * IN PUSHORT Address, - * IN USHORT Value); - */ -#if defined(_AMD64_) -#define RtlStoreUshort(Address,Value) \ - *(USHORT UNALIGNED *)(Address) = (Value) -#else -#define RtlStoreUshort(Address,Value) \ - if ((ULONG_PTR)(Address) & SHORT_MASK) { \ - ((PUCHAR) (Address))[SHORT_LEAST_SIGNIFICANT_BIT] = (UCHAR)(FIRSTBYTE(Value)); \ - ((PUCHAR) (Address))[SHORT_MOST_SIGNIFICANT_BIT ] = (UCHAR)(SECONDBYTE(Value)); \ - } \ - else { \ - *((PUSHORT) (Address)) = (USHORT)Value; \ - } -#endif NTSYSAPI BOOLEAN NTAPI RtlTimeFieldsToTime( - IN PTIME_FIELDS TimeFields, - IN PLARGE_INTEGER Time); + IN PTIME_FIELDS TimeFields, + IN PLARGE_INTEGER Time); NTSYSAPI VOID NTAPI RtlTimeToTimeFields( - IN PLARGE_INTEGER Time, - IN PTIME_FIELDS TimeFields); + IN PLARGE_INTEGER Time, + IN PTIME_FIELDS TimeFields); NTSYSAPI ULONG FASTCALL RtlUlongByteSwap( - IN ULONG Source); + IN ULONG Source); NTSYSAPI ULONGLONG FASTCALL RtlUlonglongByteSwap( - IN ULONGLONG Source); + IN ULONGLONG Source); NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToAnsiString( - IN OUT PANSI_STRING DestinationString, - IN PCUNICODE_STRING SourceString, - IN BOOLEAN AllocateDestinationString); + IN OUT PANSI_STRING DestinationString, + IN PCUNICODE_STRING SourceString, + IN BOOLEAN AllocateDestinationString); NTSYSAPI ULONG NTAPI RtlxUnicodeStringToAnsiSize( - IN PCUNICODE_STRING UnicodeString); + IN PCUNICODE_STRING UnicodeString); #define RtlUnicodeStringToAnsiSize(String) ( \ NLS_MB_CODE_PAGE_TAG ? \ @@ -6259,130 +8934,193 @@ NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToInteger( - IN PCUNICODE_STRING String, - IN ULONG Base OPTIONAL, - OUT PULONG Value); + IN PCUNICODE_STRING String, + IN ULONG Base OPTIONAL, + OUT PULONG Value); NTSYSAPI WCHAR NTAPI RtlUpcaseUnicodeChar( - IN WCHAR SourceCharacter); + IN WCHAR SourceCharacter); NTSYSAPI USHORT FASTCALL RtlUshortByteSwap( - IN USHORT Source); + IN USHORT Source); NTSYSAPI BOOLEAN NTAPI RtlValidRelativeSecurityDescriptor( - IN PSECURITY_DESCRIPTOR SecurityDescriptorInput, - IN ULONG SecurityDescriptorLength, - IN SECURITY_INFORMATION RequiredInformation); + IN PSECURITY_DESCRIPTOR SecurityDescriptorInput, + IN ULONG SecurityDescriptorLength, + IN SECURITY_INFORMATION RequiredInformation); NTSYSAPI BOOLEAN NTAPI RtlValidSecurityDescriptor( - IN PSECURITY_DESCRIPTOR SecurityDescriptor); + IN PSECURITY_DESCRIPTOR SecurityDescriptor); NTSYSAPI NTSTATUS NTAPI RtlWriteRegistryValue( - IN ULONG RelativeTo, - IN PCWSTR Path, - IN PCWSTR ValueName, - IN ULONG ValueType, - IN PVOID ValueData, - IN ULONG ValueLength); + IN ULONG RelativeTo, + IN PCWSTR Path, + IN PCWSTR ValueName, + IN ULONG ValueType, + IN PVOID ValueData, + IN ULONG ValueLength); + + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ -#endif // (NTDDI_VERSION >= NTDDI_WIN2K) #if (NTDDI_VERSION >= NTDDI_WIN2KSP3) NTSYSAPI VOID FASTCALL RtlPrefetchMemoryNonTemporal( - IN PVOID Source, - IN SIZE_T Length); + IN PVOID Source, + IN SIZE_T Length); #endif + #if (NTDDI_VERSION >= NTDDI_WINXP) + + + NTSYSAPI VOID NTAPI RtlClearBit( - PRTL_BITMAP BitMapHeader, - ULONG BitNumber); + PRTL_BITMAP BitMapHeader, + ULONG BitNumber); NTSYSAPI WCHAR NTAPI RtlDowncaseUnicodeChar( - IN WCHAR SourceCharacter); + IN WCHAR SourceCharacter); NTSYSAPI VOID NTAPI RtlSetBit( - PRTL_BITMAP BitMapHeader, - ULONG BitNumber); + PRTL_BITMAP BitMapHeader, + ULONG BitNumber); NTSYSAPI BOOLEAN NTAPI RtlTestBit( - IN PRTL_BITMAP BitMapHeader, - IN ULONG BitNumber); + IN PRTL_BITMAP BitMapHeader, + IN ULONG BitNumber); -#endif // (NTDDI_VERSION >= NTDDI_WINXP) +NTSYSAPI +NTSTATUS +NTAPI +RtlHashUnicodeString( + IN CONST UNICODE_STRING *String, + IN BOOLEAN CaseInSensitive, + IN ULONG HashAlgorithm, + OUT PULONG HashValue); + + +#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ #if (NTDDI_VERSION >= NTDDI_VISTA) + + + NTSYSAPI ULONG NTAPI RtlNumberOfSetBitsUlongPtr( - IN ULONG_PTR Target); + IN ULONG_PTR Target); NTSYSAPI ULONGLONG NTAPI -RtlIoDecodeMemIoResource ( - IN struct _IO_RESOURCE_DESCRIPTOR *Descriptor, - OUT PULONGLONG Alignment OPTIONAL, - OUT PULONGLONG MinimumAddress OPTIONAL, - OUT PULONGLONG MaximumAddress OPTIONAL); +RtlIoDecodeMemIoResource( + IN struct _IO_RESOURCE_DESCRIPTOR *Descriptor, + OUT PULONGLONG Alignment OPTIONAL, + OUT PULONGLONG MinimumAddress OPTIONAL, + OUT PULONGLONG MaximumAddress OPTIONAL); NTSYSAPI NTSTATUS NTAPI RtlIoEncodeMemIoResource( - IN struct _IO_RESOURCE_DESCRIPTOR *Descriptor, - IN UCHAR Type, - IN ULONGLONG Length, - IN ULONGLONG Alignment, - IN ULONGLONG MinimumAddress, - IN ULONGLONG MaximumAddress); + IN struct _IO_RESOURCE_DESCRIPTOR *Descriptor, + IN UCHAR Type, + IN ULONGLONG Length, + IN ULONGLONG Alignment, + IN ULONGLONG MinimumAddress, + IN ULONGLONG MaximumAddress); NTSYSAPI ULONGLONG NTAPI RtlCmDecodeMemIoResource( - IN struct _CM_PARTIAL_RESOURCE_DESCRIPTOR *Descriptor, - OUT PULONGLONG Start OPTIONAL); + IN struct _CM_PARTIAL_RESOURCE_DESCRIPTOR *Descriptor, + OUT PULONGLONG Start OPTIONAL); NTSYSAPI NTSTATUS NTAPI RtlFindClosestEncodableLength( - IN ULONGLONG SourceLength, - OUT PULONGLONG TargetLength); + IN ULONGLONG SourceLength, + OUT PULONGLONG TargetLength); + +NTSYSAPI +NTSTATUS +NTAPI +RtlCmEncodeMemIoResource( + IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor, + IN UCHAR Type, + IN ULONGLONG Length, + IN ULONGLONG Start); + + +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + +#if (NTDDI_VERSION >= NTDDI_WIN7) + + + +NTSYSAPI +NTSTATUS +NTAPI +RtlUnicodeToUTF8N( + OUT PCHAR UTF8StringDestination, + IN ULONG UTF8StringMaxByteCount, + OUT PULONG UTF8StringActualByteCount, + IN PCWCH UnicodeStringSource, + IN ULONG UnicodeStringByteCount); + +NTSYSAPI +NTSTATUS +NTAPI +RtlUTF8ToUnicodeN( + OUT PWSTR UnicodeStringDestination, + IN ULONG UnicodeStringMaxByteCount, + OUT PULONG UnicodeStringActualByteCount, + IN PCCH UTF8StringSource, + IN ULONG UTF8StringByteCount); + +NTSYSAPI +ULONG64 +NTAPI +RtlGetEnabledExtendedFeatures( + IN ULONG64 FeatureMask); + + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ -#endif #if !defined(MIDL_PASS) /* inline funftions */ @@ -6390,11 +9128,12 @@ RtlFindClosestEncodableLength( static __inline LARGE_INTEGER NTAPI_INLINE -RtlConvertLongToLargeInteger(LONG SignedInteger) +RtlConvertLongToLargeInteger( + IN LONG SignedInteger) { - LARGE_INTEGER ret; - ret.QuadPart = SignedInteger; - return ret; + LARGE_INTEGER ret; + ret.QuadPart = SignedInteger; + return ret; } //DECLSPEC_DEPRECATED_DDK_WINXP @@ -6402,11 +9141,39 @@ static __inline LARGE_INTEGER NTAPI_INLINE RtlConvertUlongToLargeInteger( - ULONG UnsignedInteger) + IN ULONG UnsignedInteger) { - LARGE_INTEGER ret; - ret.QuadPart = UnsignedInteger; - return ret; + LARGE_INTEGER ret; + ret.QuadPart = UnsignedInteger; + return ret; +} + +//DECLSPEC_DEPRECATED_DDK_WINXP +static __inline +LARGE_INTEGER +NTAPI_INLINE +RtlLargeIntegerShiftLeft( + IN LARGE_INTEGER LargeInteger, + IN CCHAR ShiftCount) +{ + LARGE_INTEGER Result; + + Result.QuadPart = LargeInteger.QuadPart << ShiftCount; + return Result; +} + +//DECLSPEC_DEPRECATED_DDK_WINXP +static __inline +LARGE_INTEGER +NTAPI_INLINE +RtlLargeIntegerShiftRight( + IN LARGE_INTEGER LargeInteger, + IN CCHAR ShiftCount) +{ + LARGE_INTEGER Result; + + Result.QuadPart = (ULONG64)LargeInteger.QuadPart >> ShiftCount; + return Result; } //DECLSPEC_DEPRECATED_DDK @@ -6414,13 +9181,40 @@ static __inline ULONG NTAPI_INLINE RtlEnlargedUnsignedDivide( - IN ULARGE_INTEGER Dividend, - IN ULONG Divisor, - IN OUT PULONG Remainder) + IN ULARGE_INTEGER Dividend, + IN ULONG Divisor, + IN OUT PULONG Remainder) { - if (Remainder) - *Remainder = (ULONG)(Dividend.QuadPart % Divisor); - return (ULONG)(Dividend.QuadPart / Divisor); + if (Remainder) + *Remainder = (ULONG)(Dividend.QuadPart % Divisor); + return (ULONG)(Dividend.QuadPart / Divisor); +} + +//DECLSPEC_DEPRECATED_DDK +static __inline +LARGE_INTEGER +NTAPI_INLINE +RtlLargeIntegerNegate( + IN LARGE_INTEGER Subtrahend) +{ + LARGE_INTEGER Difference; + + Difference.QuadPart = -Subtrahend.QuadPart; + return Difference; +} + +//DECLSPEC_DEPRECATED_DDK +static __inline +LARGE_INTEGER +NTAPI_INLINE +RtlLargeIntegerSubtract( + IN LARGE_INTEGER Minuend, + IN LARGE_INTEGER Subtrahend) +{ + LARGE_INTEGER Difference; + + Difference.QuadPart = Minuend.QuadPart - Subtrahend.QuadPart; + return Difference; } //DECLSPEC_DEPRECATED_DDK @@ -6428,12 +9222,12 @@ static __inline LARGE_INTEGER NTAPI_INLINE RtlEnlargedUnsignedMultiply( - IN ULONG Multiplicand, - IN ULONG Multiplier) + IN ULONG Multiplicand, + IN ULONG Multiplier) { - LARGE_INTEGER ret; - ret.QuadPart = (ULONGLONG)Multiplicand * (ULONGLONG)Multiplier; - return ret; + LARGE_INTEGER ret; + ret.QuadPart = (ULONGLONG)Multiplicand * (ULONGLONG)Multiplier; + return ret; } //DECLSPEC_DEPRECATED_DDK @@ -6441,65 +9235,72 @@ static __inline LARGE_INTEGER NTAPI_INLINE RtlEnlargedIntegerMultiply( - IN LONG Multiplicand, - IN LONG Multiplier) + IN LONG Multiplicand, + IN LONG Multiplier) { - LARGE_INTEGER ret; - ret.QuadPart = (LONGLONG)Multiplicand * (ULONGLONG)Multiplier; - return ret; + LARGE_INTEGER ret; + ret.QuadPart = (LONGLONG)Multiplicand * (ULONGLONG)Multiplier; + return ret; } FORCEINLINE VOID -RtlInitEmptyAnsiString(OUT PANSI_STRING AnsiString, - IN PCHAR Buffer, - IN USHORT BufferSize) +RtlInitEmptyAnsiString( + OUT PANSI_STRING AnsiString, + IN PCHAR Buffer, + IN USHORT BufferSize) { - AnsiString->Length = 0; - AnsiString->MaximumLength = BufferSize; - AnsiString->Buffer = Buffer; + AnsiString->Length = 0; + AnsiString->MaximumLength = BufferSize; + AnsiString->Buffer = Buffer; } FORCEINLINE VOID RtlInitEmptyUnicodeString( - OUT PUNICODE_STRING UnicodeString, - IN PWSTR Buffer, - IN USHORT BufferSize) + OUT PUNICODE_STRING UnicodeString, + IN PWSTR Buffer, + IN USHORT BufferSize) { - UnicodeString->Length = 0; - UnicodeString->MaximumLength = BufferSize; - UnicodeString->Buffer = Buffer; + UnicodeString->Length = 0; + UnicodeString->MaximumLength = BufferSize; + UnicodeString->Buffer = Buffer; } #if defined(_AMD64_) || defined(_IA64_) + + static __inline LARGE_INTEGER NTAPI_INLINE RtlExtendedIntegerMultiply( - LARGE_INTEGER Multiplicand, - LONG Multiplier) + IN LARGE_INTEGER Multiplicand, + IN LONG Multiplier) { - LARGE_INTEGER ret; - ret.QuadPart = Multiplicand.QuadPart * Multiplier; - return ret; + LARGE_INTEGER ret; + ret.QuadPart = Multiplicand.QuadPart * Multiplier; + return ret; } static __inline LARGE_INTEGER NTAPI_INLINE RtlExtendedLargeIntegerDivide( - LARGE_INTEGER Dividend, - ULONG Divisor, - PULONG Remainder) + IN LARGE_INTEGER Dividend, + IN ULONG Divisor, + OUT PULONG Remainder OPTIONAL) { - LARGE_INTEGER ret; - ret.QuadPart = (ULONG64)Dividend.QuadPart / Divisor; - if (Remainder) - *Remainder = (ULONG)(Dividend.QuadPart % Divisor); - return ret; + LARGE_INTEGER ret; + ret.QuadPart = (ULONG64)Dividend.QuadPart / Divisor; + if (Remainder) + *Remainder = (ULONG)(Dividend.QuadPart % Divisor); + return ret; } -#endif + + + +#endif /* defined(_AMD64_) || defined(_IA64_) */ + #if defined(_AMD64_) @@ -6511,19 +9312,19 @@ static __inline LARGE_INTEGER NTAPI_INLINE RtlExtendedMagicDivide( - IN LARGE_INTEGER Dividend, - IN LARGE_INTEGER MagicDivisor, - IN CCHAR ShiftCount) + IN LARGE_INTEGER Dividend, + IN LARGE_INTEGER MagicDivisor, + IN CCHAR ShiftCount) { - LARGE_INTEGER ret; - ULONG64 ret64; - BOOLEAN Pos; - Pos = (Dividend.QuadPart >= 0); - ret64 = UnsignedMultiplyHigh(Pos ? Dividend.QuadPart : -Dividend.QuadPart, - MagicDivisor.QuadPart); - ret64 >>= ShiftCount; - ret.QuadPart = Pos ? ret64 : -ret64; - return ret; + LARGE_INTEGER ret; + ULONG64 ret64; + BOOLEAN Pos; + Pos = (Dividend.QuadPart >= 0); + ret64 = UnsignedMultiplyHigh(Pos ? Dividend.QuadPart : -Dividend.QuadPart, + MagicDivisor.QuadPart); + ret64 >>= ShiftCount; + ret.QuadPart = Pos ? ret64 : -ret64; + return ret; } #endif @@ -6532,12 +9333,12 @@ static __inline LARGE_INTEGER NTAPI_INLINE RtlLargeIntegerAdd( - IN LARGE_INTEGER Addend1, - IN LARGE_INTEGER Addend2) + IN LARGE_INTEGER Addend1, + IN LARGE_INTEGER Addend2) { - LARGE_INTEGER ret; - ret.QuadPart = Addend1.QuadPart + Addend2.QuadPart; - return ret; + LARGE_INTEGER ret; + ret.QuadPart = Addend1.QuadPart + Addend2.QuadPart; + return ret; } /* VOID @@ -6554,12 +9355,12 @@ static __inline LARGE_INTEGER NTAPI_INLINE RtlLargeIntegerArithmeticShift( - IN LARGE_INTEGER LargeInteger, - IN CCHAR ShiftCount) + IN LARGE_INTEGER LargeInteger, + IN CCHAR ShiftCount) { - LARGE_INTEGER ret; - ret.QuadPart = LargeInteger.QuadPart >> ShiftCount; - return ret; + LARGE_INTEGER ret; + ret.QuadPart = LargeInteger.QuadPart >> ShiftCount; + return ret; } /* BOOLEAN @@ -6573,36 +9374,74 @@ RtlLargeIntegerArithmeticShift( FORCEINLINE PVOID RtlSecureZeroMemory( - OUT PVOID Pointer, - IN SIZE_T Size) + OUT PVOID Pointer, + IN SIZE_T Size) { - volatile char* vptr = (volatile char*)Pointer; + volatile char* vptr = (volatile char*)Pointer; #if defined(_M_AMD64) - __stosb((PUCHAR)vptr, 0, Size); + __stosb((PUCHAR)vptr, 0, Size); #else - char * endptr = (char *)vptr + Size; - while (vptr < endptr) - { - *vptr = 0; vptr++; - } + char * endptr = (char *)vptr + Size; + while (vptr < endptr) { + *vptr = 0; vptr++; + } #endif - return Pointer; + return Pointer; } #if defined(_M_AMD64) FORCEINLINE -ULONG +BOOLEAN RtlCheckBit( - IN PRTL_BITMAP BitMapHeader, - IN ULONG BitPosition) + IN PRTL_BITMAP BitMapHeader, + IN ULONG BitPosition) { - return BitTest((LONG CONST*)BitMapHeader->Buffer, BitPosition); + return BitTest64((LONG64 CONST*)BitMapHeader->Buffer, (LONG64)BitPosition); } #else #define RtlCheckBit(BMH,BP) (((((PLONG)(BMH)->Buffer)[(BP)/32]) >> ((BP)%32)) & 0x1) -#endif // defined(_M_AMD64) +#endif /* defined(_M_AMD64) */ -#endif // !defined(MIDL_PASS) +#define RtlLargeIntegerGreaterThan(X,Y) ( \ + (((X).HighPart == (Y).HighPart) && ((X).LowPart > (Y).LowPart)) || \ + ((X).HighPart > (Y).HighPart) \ +) + +#define RtlLargeIntegerGreaterThanOrEqualTo(X,Y) ( \ + (((X).HighPart == (Y).HighPart) && ((X).LowPart >= (Y).LowPart)) || \ + ((X).HighPart > (Y).HighPart) \ +) + +#define RtlLargeIntegerNotEqualTo(X,Y) ( \ + (((X).LowPart ^ (Y).LowPart) | ((X).HighPart ^ (Y).HighPart)) \ +) + +#define RtlLargeIntegerLessThan(X,Y) ( \ + (((X).HighPart == (Y).HighPart) && ((X).LowPart < (Y).LowPart)) || \ + ((X).HighPart < (Y).HighPart) \ +) + +#define RtlLargeIntegerLessThanOrEqualTo(X,Y) ( \ + (((X).HighPart == (Y).HighPart) && ((X).LowPart <= (Y).LowPart)) || \ + ((X).HighPart < (Y).HighPart) \ +) + +#define RtlLargeIntegerGreaterThanZero(X) ( \ + (((X).HighPart == 0) && ((X).LowPart > 0)) || \ + ((X).HighPart > 0 ) \ +) + +#define RtlLargeIntegerGreaterOrEqualToZero(X) ( (X).HighPart >= 0 ) + +#define RtlLargeIntegerEqualToZero(X) ( !((X).LowPart | (X).HighPart) ) + +#define RtlLargeIntegerNotEqualToZero(X) ( ((X).LowPart | (X).HighPart) ) + +#define RtlLargeIntegerLessThanZero(X) ( ((X).HighPart < 0) ) + +#define RtlLargeIntegerLessOrEqualToZero(X) ( ((X).HighPart < 0) || !((X).LowPart | (X).HighPart) ) + +#endif /* !defined(MIDL_PASS) */ /* Byte Swap Functions */ #if (defined(_M_IX86) && (_MSC_FULL_VER > 13009037 || defined(__GNUC__))) || \ @@ -6656,6 +9495,10 @@ RtlCheckBit( (__annotation(L"Debug", L"AssertFail", msg), \ DbgRaiseAssertionFailure(), FALSE) : TRUE) +#define NT_VERIFY NT_ASSERT +#define NT_VERIFYMSG NT_ASSERTMSG +#define NT_VERIFYMSGW NT_ASSERTMSGW + #else /* GCC doesn't support __annotation (nor PDB) */ @@ -6681,12 +9524,19 @@ RtlCheckBit( #define RTL_SOFT_VERIFY(exp) ((exp) ? TRUE : FALSE) #define RTL_SOFT_VERIFYMSG(msg, exp) ((exp) ? TRUE : FALSE) -#define NT_ASSERT(exp) ((VOID)0) -#define NT_ASSERTMSG(exp) ((VOID)0) -#define NT_ASSERTMSGW(exp) ((VOID)0) +#define NT_ASSERT(exp) ((VOID)0) +#define NT_ASSERTMSG(msg, exp) ((VOID)0) +#define NT_ASSERTMSGW(msg, exp) ((VOID)0) + +#define NT_VERIFY(_exp) ((_exp) ? TRUE : FALSE) +#define NT_VERIFYMSG(_msg, _exp ) ((_exp) ? TRUE : FALSE) +#define NT_VERIFYMSGW(_msg, _exp) ((_exp) ? TRUE : FALSE) #endif /* DBG */ +#define InitializeListHead32(ListHead) (\ + (ListHead)->Flink = (ListHead)->Blink = PtrToUlong((ListHead))) + #if !defined(_WINBASE_) #if defined(_WIN64) && (defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_) || defined(_NTOSP_)) @@ -6704,25 +9554,21 @@ InitializeSListHead( OUT PSLIST_HEADER SListHead) { #if defined(_IA64_) - ULONG64 FeatureBits; + ULONG64 FeatureBits; #endif #if defined(_WIN64) - if (((ULONG_PTR)SListHead & 0xf) != 0) - { - RtlRaiseStatus(STATUS_DATATYPE_MISALIGNMENT); - } + if (((ULONG_PTR)SListHead & 0xf) != 0) { + RtlRaiseStatus(STATUS_DATATYPE_MISALIGNMENT); + } #endif - - RtlZeroMemory(SListHead, sizeof(SLIST_HEADER)); - + RtlZeroMemory(SListHead, sizeof(SLIST_HEADER)); #if defined(_IA64_) - FeatureBits = __getReg(CV_IA64_CPUID4); - if ((FeatureBits & KF_16BYTE_INSTR) != 0) - { - SListHead->Header16.HeaderType = 1; - SListHead->Header16.Init = 1; - } + FeatureBits = __getReg(CV_IA64_CPUID4); + if ((FeatureBits & KF_16BYTE_INSTR) != 0) { + SListHead->Header16.HeaderType = 1; + SListHead->Header16.Init = 1; + } #endif } @@ -6748,14 +9594,14 @@ NTKERNELAPI PSLIST_ENTRY FASTCALL InterlockedPopEntrySList( - IN PSLIST_HEADER ListHead); + IN PSLIST_HEADER ListHead); NTKERNELAPI PSLIST_ENTRY FASTCALL InterlockedPushEntrySList( - IN PSLIST_HEADER ListHead, - IN PSLIST_ENTRY ListEntry); + IN PSLIST_HEADER ListHead, + IN PSLIST_ENTRY ListEntry); #define InterlockedFlushSList(ListHead) \ ExInterlockedFlushSList(ListHead) @@ -6767,23 +9613,68 @@ InterlockedPushEntrySList( #endif /* !defined(_WINBASE_) */ +#define RTL_CONTEXT_EX_OFFSET(ContextEx, Chunk) ((ContextEx)->Chunk.Offset) +#define RTL_CONTEXT_EX_LENGTH(ContextEx, Chunk) ((ContextEx)->Chunk.Length) +#define RTL_CONTEXT_EX_CHUNK(Base, Layout, Chunk) \ + ((PVOID)((PCHAR)(Base) + RTL_CONTEXT_EX_OFFSET(Layout, Chunk))) +#define RTL_CONTEXT_OFFSET(Context, Chunk) \ + RTL_CONTEXT_EX_OFFSET((PCONTEXT_EX)(Context + 1), Chunk) +#define RTL_CONTEXT_LENGTH(Context, Chunk) \ + RTL_CONTEXT_EX_LENGTH((PCONTEXT_EX)(Context + 1), Chunk) +#define RTL_CONTEXT_CHUNK(Context, Chunk) \ + RTL_CONTEXT_EX_CHUNK((PCONTEXT_EX)(Context + 1), \ + (PCONTEXT_EX)(Context + 1), \ + Chunk) + +BOOLEAN +RTLVERLIB_DDI(RtlIsNtDdiVersionAvailable)( + IN ULONG Version); + +BOOLEAN +RTLVERLIB_DDI(RtlIsServicePackVersionInstalled)( + IN ULONG Version); + +#ifndef RtlIsNtDdiVersionAvailable +#define RtlIsNtDdiVersionAvailable WdmlibRtlIsNtDdiVersionAvailable +#endif + +#ifndef RtlIsServicePackVersionInstalled +#define RtlIsServicePackVersionInstalled WdmlibRtlIsServicePackVersionInstalled +#endif + +#define RtlInterlockedSetBits(Flags, Flag) \ + InterlockedOr((PLONG)(Flags), Flag) + +#define RtlInterlockedAndBits(Flags, Flag) \ + InterlockedAnd((PLONG)(Flags), Flag) + +#define RtlInterlockedClearBits(Flags, Flag) \ + RtlInterlockedAndBits(Flags, ~(Flag)) + +#define RtlInterlockedXorBits(Flags, Flag) \ + InterlockedXor(Flags, Flag) + +#define RtlInterlockedSetBitsDiscardReturn(Flags, Flag) \ + (VOID) RtlInterlockedSetBits(Flags, Flag) + +#define RtlInterlockedAndBitsDiscardReturn(Flags, Flag) \ + (VOID) RtlInterlockedAndBits(Flags, Flag) + +#define RtlInterlockedClearBitsDiscardReturn(Flags, Flag) \ + RtlInterlockedAndBitsDiscardReturn(Flags, ~(Flag)) + + /****************************************************************************** * Kernel Functions * ******************************************************************************/ -NTHALAPI -KIRQL -NTAPI -KeGetCurrentIrql( - VOID); - NTKERNELAPI VOID NTAPI KeInitializeEvent( - OUT PRKEVENT Event, - IN EVENT_TYPE Type, - IN BOOLEAN State); + OUT PRKEVENT Event, + IN EVENT_TYPE Type, + IN BOOLEAN State); NTKERNELAPI VOID @@ -6793,6 +9684,9 @@ KeClearEvent( #if (NTDDI_VERSION >= NTDDI_WIN2K) + + +#if defined(_NTDDK_) || defined(_NTIFS_) NTKERNELAPI VOID NTAPI @@ -6800,6 +9694,7 @@ ProbeForRead( IN CONST VOID *Address, /* CONST is added */ IN SIZE_T Length, IN ULONG Alignment); +#endif /* defined(_NTDDK_) || defined(_NTIFS_) */ NTKERNELAPI VOID @@ -6809,7 +9704,9 @@ ProbeForWrite( IN SIZE_T Length, IN ULONG Alignment); + #if defined(SINGLE_GROUP_LEGACY_API) + NTKERNELAPI VOID NTAPI @@ -6819,7 +9716,7 @@ NTKERNELAPI VOID NTAPI KeSetSystemAffinityThread( - IN KAFFINITY Affinity); + IN KAFFINITY Affinity); NTKERNELAPI VOID @@ -6831,22 +9728,24 @@ KeSetTargetProcessorDpc( NTKERNELAPI KAFFINITY NTAPI -KeQueryActiveProcessors( - VOID); -#endif +KeQueryActiveProcessors(VOID); + + +#endif /* defined(SINGLE_GROUP_LEGACY_API) */ #if !defined(_M_AMD64) + NTKERNELAPI ULONGLONG NTAPI -KeQueryInterruptTime( - VOID); +KeQueryInterruptTime(VOID); NTKERNELAPI VOID NTAPI KeQuerySystemTime( - OUT PLARGE_INTEGER CurrentTime); + OUT PLARGE_INTEGER CurrentTime); + #endif /* !_M_AMD64 */ #if defined(_X86_) && (defined(_WDM_INCLUDED_) || defined(WIN9X_COMPAT_SPINLOCK)) @@ -6854,14 +9753,14 @@ NTKERNELAPI VOID NTAPI KeInitializeSpinLock( - IN PKSPIN_LOCK SpinLock); + IN PKSPIN_LOCK SpinLock); #else FORCEINLINE VOID KeInitializeSpinLock(IN PKSPIN_LOCK SpinLock) { - /* Clear the lock */ - *SpinLock = 0; + /* Clear the lock */ + *SpinLock = 0; } #endif @@ -6870,11 +9769,11 @@ DECLSPEC_NORETURN VOID NTAPI KeBugCheckEx( - IN ULONG BugCheckCode, - IN ULONG_PTR BugCheckParameter1, - IN ULONG_PTR BugCheckParameter2, - IN ULONG_PTR BugCheckParameter3, - IN ULONG_PTR BugCheckParameter4); + IN ULONG BugCheckCode, + IN ULONG_PTR BugCheckParameter1, + IN ULONG_PTR BugCheckParameter2, + IN ULONG_PTR BugCheckParameter3, + IN ULONG_PTR BugCheckParameter4); NTKERNELAPI BOOLEAN @@ -6905,66 +9804,66 @@ NTKERNELAPI VOID NTAPI KeInitializeDeviceQueue( - OUT PKDEVICE_QUEUE DeviceQueue); + OUT PKDEVICE_QUEUE DeviceQueue); NTKERNELAPI VOID NTAPI KeInitializeDpc( - OUT PRKDPC Dpc, - IN PKDEFERRED_ROUTINE DeferredRoutine, - IN PVOID DeferredContext OPTIONAL); + OUT PRKDPC Dpc, + IN PKDEFERRED_ROUTINE DeferredRoutine, + IN PVOID DeferredContext OPTIONAL); NTKERNELAPI VOID NTAPI KeInitializeMutex( - OUT PRKMUTEX Mutex, - IN ULONG Level); + OUT PRKMUTEX Mutex, + IN ULONG Level); NTKERNELAPI VOID NTAPI KeInitializeSemaphore( - OUT PRKSEMAPHORE Semaphore, - IN LONG Count, - IN LONG Limit); + OUT PRKSEMAPHORE Semaphore, + IN LONG Count, + IN LONG Limit); NTKERNELAPI VOID NTAPI KeInitializeTimer( - OUT PKTIMER Timer); + OUT PKTIMER Timer); NTKERNELAPI VOID NTAPI KeInitializeTimerEx( - OUT PKTIMER Timer, - IN TIMER_TYPE Type); + OUT PKTIMER Timer, + IN TIMER_TYPE Type); NTKERNELAPI BOOLEAN NTAPI KeInsertByKeyDeviceQueue( - IN OUT PKDEVICE_QUEUE DeviceQueue, - IN OUT PKDEVICE_QUEUE_ENTRY DeviceQueueEntry, - IN ULONG SortKey); + IN OUT PKDEVICE_QUEUE DeviceQueue, + IN OUT PKDEVICE_QUEUE_ENTRY DeviceQueueEntry, + IN ULONG SortKey); NTKERNELAPI BOOLEAN NTAPI KeInsertDeviceQueue( - IN OUT PKDEVICE_QUEUE DeviceQueue, - IN OUT PKDEVICE_QUEUE_ENTRY DeviceQueueEntry); + IN OUT PKDEVICE_QUEUE DeviceQueue, + IN OUT PKDEVICE_QUEUE_ENTRY DeviceQueueEntry); NTKERNELAPI BOOLEAN NTAPI KeInsertQueueDpc( - IN OUT PRKDPC Dpc, - IN PVOID SystemArgument1 OPTIONAL, - IN PVOID SystemArgument2 OPTIONAL); + IN OUT PRKDPC Dpc, + IN PVOID SystemArgument1 OPTIONAL, + IN PVOID SystemArgument2 OPTIONAL); NTKERNELAPI VOID @@ -6975,168 +9874,166 @@ NTHALAPI LARGE_INTEGER NTAPI KeQueryPerformanceCounter( - OUT PLARGE_INTEGER PerformanceFrequency OPTIONAL); + OUT PLARGE_INTEGER PerformanceFrequency OPTIONAL); NTKERNELAPI KPRIORITY NTAPI KeQueryPriorityThread( - IN PRKTHREAD Thread); + IN PRKTHREAD Thread); NTKERNELAPI ULONG NTAPI -KeQueryTimeIncrement( - VOID); +KeQueryTimeIncrement(VOID); NTKERNELAPI LONG NTAPI KeReadStateEvent( - IN PRKEVENT Event); + IN PRKEVENT Event); NTKERNELAPI LONG NTAPI KeReadStateMutex( - IN PRKMUTEX Mutex); - + IN PRKMUTEX Mutex); NTKERNELAPI LONG NTAPI KeReadStateSemaphore( - IN PRKSEMAPHORE Semaphore); + IN PRKSEMAPHORE Semaphore); NTKERNELAPI BOOLEAN NTAPI KeReadStateTimer( - IN PKTIMER Timer); + IN PKTIMER Timer); NTKERNELAPI BOOLEAN NTAPI KeRegisterBugCheckCallback( - OUT PKBUGCHECK_CALLBACK_RECORD CallbackRecord, - IN PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine, - IN PVOID Buffer, - IN ULONG Length, - IN PUCHAR Component); + OUT PKBUGCHECK_CALLBACK_RECORD CallbackRecord, + IN PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine, + IN PVOID Buffer, + IN ULONG Length, + IN PUCHAR Component); NTKERNELAPI LONG NTAPI KeReleaseMutex( - IN OUT PRKMUTEX Mutex, - IN BOOLEAN Wait); + IN OUT PRKMUTEX Mutex, + IN BOOLEAN Wait); NTKERNELAPI LONG NTAPI KeReleaseSemaphore( - IN OUT PRKSEMAPHORE Semaphore, - IN KPRIORITY Increment, - IN LONG Adjustment, - IN BOOLEAN Wait); + IN OUT PRKSEMAPHORE Semaphore, + IN KPRIORITY Increment, + IN LONG Adjustment, + IN BOOLEAN Wait); NTKERNELAPI PKDEVICE_QUEUE_ENTRY NTAPI KeRemoveByKeyDeviceQueue( - IN OUT PKDEVICE_QUEUE DeviceQueue, - IN ULONG SortKey); + IN OUT PKDEVICE_QUEUE DeviceQueue, + IN ULONG SortKey); NTKERNELAPI PKDEVICE_QUEUE_ENTRY NTAPI KeRemoveDeviceQueue( - IN OUT PKDEVICE_QUEUE DeviceQueue); + IN OUT PKDEVICE_QUEUE DeviceQueue); NTKERNELAPI BOOLEAN NTAPI KeRemoveEntryDeviceQueue( - IN OUT PKDEVICE_QUEUE DeviceQueue, - IN OUT PKDEVICE_QUEUE_ENTRY DeviceQueueEntry); + IN OUT PKDEVICE_QUEUE DeviceQueue, + IN OUT PKDEVICE_QUEUE_ENTRY DeviceQueueEntry); NTKERNELAPI BOOLEAN NTAPI KeRemoveQueueDpc( - IN OUT PRKDPC Dpc); + IN OUT PRKDPC Dpc); NTKERNELAPI LONG NTAPI KeResetEvent( - IN OUT PRKEVENT Event); + IN OUT PRKEVENT Event); NTKERNELAPI LONG NTAPI KeSetEvent( - IN OUT PRKEVENT Event, - IN KPRIORITY Increment, - IN BOOLEAN Wait); + IN OUT PRKEVENT Event, + IN KPRIORITY Increment, + IN BOOLEAN Wait); NTKERNELAPI VOID NTAPI KeSetImportanceDpc( - IN OUT PRKDPC Dpc, - IN KDPC_IMPORTANCE Importance); + IN OUT PRKDPC Dpc, + IN KDPC_IMPORTANCE Importance); NTKERNELAPI KPRIORITY NTAPI KeSetPriorityThread( - IN OUT PKTHREAD Thread, - IN KPRIORITY Priority); + IN OUT PKTHREAD Thread, + IN KPRIORITY Priority); NTKERNELAPI BOOLEAN NTAPI KeSetTimer( - IN OUT PKTIMER Timer, - IN LARGE_INTEGER DueTime, - IN PKDPC Dpc OPTIONAL); + IN OUT PKTIMER Timer, + IN LARGE_INTEGER DueTime, + IN PKDPC Dpc OPTIONAL); NTKERNELAPI BOOLEAN NTAPI KeSetTimerEx( - IN OUT PKTIMER Timer, - IN LARGE_INTEGER DueTime, - IN LONG Period OPTIONAL, - IN PKDPC Dpc OPTIONAL); + IN OUT PKTIMER Timer, + IN LARGE_INTEGER DueTime, + IN LONG Period OPTIONAL, + IN PKDPC Dpc OPTIONAL); NTHALAPI VOID NTAPI KeStallExecutionProcessor( - IN ULONG MicroSeconds); + IN ULONG MicroSeconds); NTKERNELAPI BOOLEAN NTAPI KeSynchronizeExecution( - IN OUT PKINTERRUPT Interrupt, - IN PKSYNCHRONIZE_ROUTINE SynchronizeRoutine, - IN PVOID SynchronizeContext OPTIONAL); + IN OUT PKINTERRUPT Interrupt, + IN PKSYNCHRONIZE_ROUTINE SynchronizeRoutine, + IN PVOID SynchronizeContext OPTIONAL); NTKERNELAPI NTSTATUS NTAPI KeWaitForMultipleObjects( - IN ULONG Count, - IN PVOID Object[], - IN WAIT_TYPE WaitType, - IN KWAIT_REASON WaitReason, - IN KPROCESSOR_MODE WaitMode, - IN BOOLEAN Alertable, - IN PLARGE_INTEGER Timeout OPTIONAL, - OUT PKWAIT_BLOCK WaitBlockArray OPTIONAL); + IN ULONG Count, + IN PVOID Object[], + IN WAIT_TYPE WaitType, + IN KWAIT_REASON WaitReason, + IN KPROCESSOR_MODE WaitMode, + IN BOOLEAN Alertable, + IN PLARGE_INTEGER Timeout OPTIONAL, + OUT PKWAIT_BLOCK WaitBlockArray OPTIONAL); #define KeWaitForMutexObject KeWaitForSingleObject @@ -7144,11 +10041,11 @@ NTKERNELAPI NTSTATUS NTAPI KeWaitForSingleObject( - IN PVOID Object, - IN KWAIT_REASON WaitReason, - IN KPROCESSOR_MODE WaitMode, - IN BOOLEAN Alertable, - IN PLARGE_INTEGER Timeout OPTIONAL); + IN PVOID Object, + IN KWAIT_REASON WaitReason, + IN KPROCESSOR_MODE WaitMode, + IN BOOLEAN Alertable, + IN PLARGE_INTEGER Timeout OPTIONAL); #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ @@ -7165,14 +10062,14 @@ NTKERNELAPI VOID FASTCALL KeAcquireInStackQueuedSpinLockAtDpcLevel( - IN OUT PKSPIN_LOCK SpinLock, - OUT PKLOCK_QUEUE_HANDLE LockHandle); + IN OUT PKSPIN_LOCK SpinLock, + OUT PKLOCK_QUEUE_HANDLE LockHandle); NTKERNELAPI KIRQL NTAPI KeAcquireInterruptSpinLock( - IN OUT PKINTERRUPT Interrupt); + IN OUT PKINTERRUPT Interrupt); NTKERNELAPI BOOLEAN @@ -7195,14 +10092,14 @@ NTKERNELAPI VOID FASTCALL KeReleaseInStackQueuedSpinLockFromDpcLevel( - IN PKLOCK_QUEUE_HANDLE LockHandle); + IN PKLOCK_QUEUE_HANDLE LockHandle); NTKERNELAPI VOID NTAPI KeReleaseInterruptSpinLock( - IN OUT PKINTERRUPT Interrupt, - IN KIRQL OldIrql); + IN OUT PKINTERRUPT Interrupt, + IN KIRQL OldIrql); NTKERNELAPI PKDEVICE_QUEUE_ENTRY @@ -7239,13 +10136,10 @@ KeRegisterBugCheckReasonCallback( #endif /* (NTDDI_VERSION >= NTDDI_WINXPSP1) */ #if (NTDDI_VERSION >= NTDDI_WINXPSP2) - NTKERNELAPI VOID NTAPI -KeFlushQueuedDpcs( - VOID); - +KeFlushQueuedDpcs(VOID); #endif /* (NTDDI_VERSION >= NTDDI_WINXPSP2) */ #if (NTDDI_VERSION >= NTDDI_WS03) @@ -7310,69 +10204,57 @@ KeTryToAcquireSpinLockAtDpcLevel( NTKERNELAPI BOOLEAN NTAPI -KeAreAllApcsDisabled( - VOID); +KeAreAllApcsDisabled(VOID); NTKERNELAPI VOID FASTCALL KeAcquireGuardedMutex( - IN OUT PKGUARDED_MUTEX GuardedMutex -); + IN OUT PKGUARDED_MUTEX GuardedMutex); NTKERNELAPI VOID FASTCALL KeAcquireGuardedMutexUnsafe( - IN OUT PKGUARDED_MUTEX GuardedMutex -); + IN OUT PKGUARDED_MUTEX GuardedMutex); NTKERNELAPI VOID NTAPI -KeEnterGuardedRegion( - VOID -); +KeEnterGuardedRegion(VOID); NTKERNELAPI VOID NTAPI -KeLeaveGuardedRegion( - VOID -); +KeLeaveGuardedRegion(VOID); NTKERNELAPI VOID FASTCALL KeInitializeGuardedMutex( - OUT PKGUARDED_MUTEX GuardedMutex -); + OUT PKGUARDED_MUTEX GuardedMutex); NTKERNELAPI VOID FASTCALL KeReleaseGuardedMutexUnsafe( - IN OUT PKGUARDED_MUTEX GuardedMutex -); + IN OUT PKGUARDED_MUTEX GuardedMutex); NTKERNELAPI VOID FASTCALL KeReleaseGuardedMutex( - IN OUT PKGUARDED_MUTEX GuardedMutex -); + IN OUT PKGUARDED_MUTEX GuardedMutex); NTKERNELAPI BOOLEAN FASTCALL KeTryToAcquireGuardedMutex( - IN OUT PKGUARDED_MUTEX GuardedMutex -); + IN OUT PKGUARDED_MUTEX GuardedMutex); #endif /* (NTDDI_VERSION >= NTDDI_WS03SP1) */ #if (NTDDI_VERSION >= NTDDI_VISTA) - NTKERNELAPI VOID FASTCALL @@ -7393,12 +10275,19 @@ KeQueryDpcWatchdogInformation( OUT PKDPC_WATCHDOG_INFORMATION WatchdogInformation); #if defined(SINGLE_GROUP_LEGACY_API) + NTKERNELAPI KAFFINITY NTAPI KeSetSystemAffinityThreadEx( IN KAFFINITY Affinity); +NTKERNELAPI +VOID +NTAPI +KeRevertToUserAffinityThreadEx( + IN KAFFINITY Affinity); + NTKERNELAPI ULONG NTAPI @@ -7408,11 +10297,10 @@ KeQueryActiveProcessorCount( NTKERNELAPI ULONG NTAPI -KeQueryMaximumProcessorCount( - VOID); +KeQueryMaximumProcessorCount(VOID); #endif -#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ #if (NTDDI_VERSION >= NTDDI_WS08) @@ -7430,6 +10318,7 @@ KeDeregisterProcessorChangeCallback( #if (NTDDI_VERSION >= NTDDI_WIN7) + ULONG64 NTAPI KeQueryTotalCycleTimeProcess( @@ -7475,8 +10364,7 @@ KeSetCoalescableTimer( NTKERNELAPI ULONGLONG NTAPI -KeQueryUnbiasedInterruptTime( - VOID); +KeQueryUnbiasedInterruptTime(VOID); NTKERNELAPI ULONG @@ -7493,19 +10381,17 @@ KeQueryMaximumProcessorCountEx( NTKERNELAPI USHORT NTAPI -KeQueryActiveGroupCount( - VOID); +KeQueryActiveGroupCount(VOID); NTKERNELAPI USHORT NTAPI -KeQueryMaximumGroupCount( - VOID); +KeQueryMaximumGroupCount(VOID); NTKERNELAPI KAFFINITY NTAPI -KeQueryGroupAffinity +KeQueryGroupAffinity( IN USHORT GroupNumber); NTKERNELAPI @@ -7531,14 +10417,12 @@ KeQueryNodeMaximumProcessorCount( NTKERNELAPI USHORT NTAPI -KeQueryHighestNodeNumber( - VOID); +KeQueryHighestNodeNumber(VOID); NTKERNELAPI USHORT NTAPI -KeGetCurrentNodeNumber( - VOID); +KeGetCurrentNodeNumber(VOID); NTKERNELAPI NTSTATUS @@ -7562,7 +10446,18 @@ NTAPI KeRestoreExtendedProcessorState( IN PXSTATE_SAVE XStateSave); -#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ +NTSTATUS +NTAPI +KeGetProcessorNumberFromIndex( + IN ULONG ProcIndex, + OUT PPROCESSOR_NUMBER ProcNumber); + +ULONG +NTAPI +KeGetProcessorIndexFromNumber( + IN PPROCESSOR_NUMBER ProcNumber); + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ #if !defined(_IA64_) NTHALAPI @@ -7597,17 +10492,14 @@ KeFlushWriteBuffer(VOID); #define PAGED_CODE() -#endif +#endif /* DBG */ #define PAGED_CODE_LOCKED() NOP_FUNCTION; /****************************************************************************** * Memory manager Functions * ******************************************************************************/ - -/* - * Alignment Macros - */ +/* Alignment Macros */ #define ALIGN_DOWN_BY(size, align) \ ((ULONG_PTR)(size) & ~((ULONG_PTR)(align) - 1)) @@ -7632,6 +10524,22 @@ KeFlushWriteBuffer(VOID); #define ALIGN_UP_POINTER(ptr, type) \ ALIGN_UP_POINTER_BY(ptr, sizeof(type)) +#ifndef FIELD_OFFSET +#define FIELD_OFFSET(type, field) ((ULONG)&(((type *)0)->field)) +#endif + +#ifndef FIELD_SIZE +#define FIELD_SIZE(type, field) (sizeof(((type *)0)->field)) +#endif + +#define POOL_TAGGING 1 + +#if DBG +#define IF_DEBUG if (TRUE) +#else +#define IF_DEBUG if (FALSE) +#endif /* DBG */ + /* ULONG * BYTE_OFFSET( * IN PVOID Va) @@ -7644,7 +10552,7 @@ KeFlushWriteBuffer(VOID); * IN ULONG Size) */ #define BYTES_TO_PAGES(Size) \ - (((Size) >> PAGE_SHIFT) + (((Size) & (PAGE_SIZE - 1)) != 0)) + (((Size) + PAGE_SIZE - 1) >> PAGE_SHIFT) /* PVOID * PAGE_ALIGN( @@ -7669,6 +10577,9 @@ KeFlushWriteBuffer(VOID); ((ULONG) ((((ULONG_PTR) (_Va) & (PAGE_SIZE - 1)) \ + (_Size) + (PAGE_SIZE - 1)) >> PAGE_SHIFT)) +#define COMPUTE_PAGES_SPANNED(Va, Size) \ + ADDRESS_AND_SIZE_TO_SPAN_PAGES(Va,Size) + /* * ULONG * MmGetMdlByteCount( @@ -7685,6 +10596,8 @@ KeFlushWriteBuffer(VOID); #define MmGetMdlByteOffset(_Mdl) \ ((_Mdl)->ByteOffset) +#define MmGetMdlBaseVa(Mdl) ((Mdl)->StartVa) + /* * PPFN_NUMBER * MmGetMdlPfnArray( @@ -7765,56 +10678,56 @@ NTKERNELAPI PVOID NTAPI MmAllocateContiguousMemory( - IN SIZE_T NumberOfBytes, - IN PHYSICAL_ADDRESS HighestAcceptableAddress); + IN SIZE_T NumberOfBytes, + IN PHYSICAL_ADDRESS HighestAcceptableAddress); NTKERNELAPI PVOID NTAPI MmAllocateContiguousMemorySpecifyCache( - IN SIZE_T NumberOfBytes, - IN PHYSICAL_ADDRESS LowestAcceptableAddress, - IN PHYSICAL_ADDRESS HighestAcceptableAddress, - IN PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL, - IN MEMORY_CACHING_TYPE CacheType); + IN SIZE_T NumberOfBytes, + IN PHYSICAL_ADDRESS LowestAcceptableAddress, + IN PHYSICAL_ADDRESS HighestAcceptableAddress, + IN PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL, + IN MEMORY_CACHING_TYPE CacheType); NTKERNELAPI PMDL NTAPI MmAllocatePagesForMdl( - IN PHYSICAL_ADDRESS LowAddress, - IN PHYSICAL_ADDRESS HighAddress, - IN PHYSICAL_ADDRESS SkipBytes, - IN SIZE_T TotalBytes); + IN PHYSICAL_ADDRESS LowAddress, + IN PHYSICAL_ADDRESS HighAddress, + IN PHYSICAL_ADDRESS SkipBytes, + IN SIZE_T TotalBytes); NTKERNELAPI VOID NTAPI MmBuildMdlForNonPagedPool( - IN OUT PMDLX MemoryDescriptorList); + IN OUT PMDLX MemoryDescriptorList); //DECLSPEC_DEPRECATED_DDK NTKERNELAPI PMDL NTAPI MmCreateMdl( - IN PMDL MemoryDescriptorList OPTIONAL, - IN PVOID Base, - IN SIZE_T Length); + IN PMDL MemoryDescriptorList OPTIONAL, + IN PVOID Base, + IN SIZE_T Length); NTKERNELAPI VOID NTAPI MmFreeContiguousMemory( - IN PVOID BaseAddress); + IN PVOID BaseAddress); NTKERNELAPI VOID NTAPI MmFreeContiguousMemorySpecifyCache( - IN PVOID BaseAddress, - IN SIZE_T NumberOfBytes, - IN MEMORY_CACHING_TYPE CacheType); + IN PVOID BaseAddress, + IN SIZE_T NumberOfBytes, + IN MEMORY_CACHING_TYPE CacheType); NTKERNELAPI VOID @@ -7826,7 +10739,7 @@ NTKERNELAPI PVOID NTAPI MmGetSystemRoutineAddress( - IN PUNICODE_STRING SystemRoutineName); + IN PUNICODE_STRING SystemRoutineName); NTKERNELAPI LOGICAL @@ -7838,22 +10751,22 @@ NTKERNELAPI PVOID NTAPI MmLockPagableDataSection( - IN PVOID AddressWithinSection); + IN PVOID AddressWithinSection); NTKERNELAPI PVOID NTAPI MmMapIoSpace( - IN PHYSICAL_ADDRESS PhysicalAddress, - IN SIZE_T NumberOfBytes, - IN MEMORY_CACHING_TYPE CacheEnable); + IN PHYSICAL_ADDRESS PhysicalAddress, + IN SIZE_T NumberOfBytes, + IN MEMORY_CACHING_TYPE CacheEnable); NTKERNELAPI PVOID NTAPI MmMapLockedPages( - IN PMDL MemoryDescriptorList, - IN KPROCESSOR_MODE AccessMode); + IN PMDL MemoryDescriptorList, + IN KPROCESSOR_MODE AccessMode); NTKERNELAPI PVOID @@ -7870,71 +10783,81 @@ NTKERNELAPI PVOID NTAPI MmPageEntireDriver( - IN PVOID AddressWithinSection); + IN PVOID AddressWithinSection); NTKERNELAPI VOID NTAPI MmProbeAndLockPages( - IN OUT PMDL MemoryDescriptorList, - IN KPROCESSOR_MODE AccessMode, - IN LOCK_OPERATION Operation); + IN OUT PMDL MemoryDescriptorList, + IN KPROCESSOR_MODE AccessMode, + IN LOCK_OPERATION Operation); NTKERNELAPI MM_SYSTEMSIZE NTAPI -MmQuerySystemSize( - VOID); +MmQuerySystemSize(VOID); NTKERNELAPI VOID NTAPI MmResetDriverPaging( - IN PVOID AddressWithinSection); + IN PVOID AddressWithinSection); NTKERNELAPI SIZE_T NTAPI MmSizeOfMdl( - IN PVOID Base, - IN SIZE_T Length); + IN PVOID Base, + IN SIZE_T Length); NTKERNELAPI VOID NTAPI MmUnlockPagableImageSection( - IN PVOID ImageSectionHandle); + IN PVOID ImageSectionHandle); NTKERNELAPI VOID NTAPI MmUnlockPages( - IN OUT PMDL MemoryDescriptorList); + IN OUT PMDL MemoryDescriptorList); NTKERNELAPI VOID NTAPI MmUnmapIoSpace( - IN PVOID BaseAddress, - IN SIZE_T NumberOfBytes); + IN PVOID BaseAddress, + IN SIZE_T NumberOfBytes); NTKERNELAPI VOID NTAPI MmProbeAndLockProcessPages( - IN OUT PMDL MemoryDescriptorList, - IN PEPROCESS Process, - IN KPROCESSOR_MODE AccessMode, - IN LOCK_OPERATION Operation); + IN OUT PMDL MemoryDescriptorList, + IN PEPROCESS Process, + IN KPROCESSOR_MODE AccessMode, + IN LOCK_OPERATION Operation); NTKERNELAPI VOID NTAPI MmUnmapLockedPages( - IN PVOID BaseAddress, - IN PMDL MemoryDescriptorList); + IN PVOID BaseAddress, + IN PMDL MemoryDescriptorList); -#endif +NTKERNELAPI +PVOID +NTAPI +MmAllocateContiguousMemorySpecifyCacheNode( + IN SIZE_T NumberOfBytes, + IN PHYSICAL_ADDRESS LowestAcceptableAddress, + IN PHYSICAL_ADDRESS HighestAcceptableAddress, + IN PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL, + IN MEMORY_CACHING_TYPE CacheType, + IN NODE_REQUIREMENT PreferredNode); + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ #if (NTDDI_VERSION >= NTDDI_WINXP) @@ -7942,53 +10865,69 @@ NTKERNELAPI NTSTATUS NTAPI MmAdvanceMdl( - IN OUT PMDL Mdl, - IN ULONG NumberOfBytes); + IN OUT PMDL Mdl, + IN ULONG NumberOfBytes); NTKERNELAPI PVOID NTAPI MmAllocateMappingAddress( - IN SIZE_T NumberOfBytes, - IN ULONG PoolTag); + IN SIZE_T NumberOfBytes, + IN ULONG PoolTag); NTKERNELAPI VOID NTAPI MmFreeMappingAddress( - IN PVOID BaseAddress, - IN ULONG PoolTag); + IN PVOID BaseAddress, + IN ULONG PoolTag); NTKERNELAPI NTSTATUS NTAPI MmIsVerifierEnabled( - OUT PULONG VerifierFlags); + OUT PULONG VerifierFlags); NTKERNELAPI PVOID NTAPI MmMapLockedPagesWithReservedMapping( - IN PVOID MappingAddress, - IN ULONG PoolTag, - IN PMDL MemoryDescriptorList, - IN MEMORY_CACHING_TYPE CacheType); + IN PVOID MappingAddress, + IN ULONG PoolTag, + IN PMDL MemoryDescriptorList, + IN MEMORY_CACHING_TYPE CacheType); NTKERNELAPI NTSTATUS NTAPI MmProtectMdlSystemAddress( - IN PMDL MemoryDescriptorList, - IN ULONG NewProtect); + IN PMDL MemoryDescriptorList, + IN ULONG NewProtect); NTKERNELAPI VOID NTAPI MmUnmapReservedMapping( - IN PVOID BaseAddress, - IN ULONG PoolTag, - IN PMDL MemoryDescriptorList); + IN PVOID BaseAddress, + IN ULONG PoolTag, + IN PMDL MemoryDescriptorList); +NTKERNELAPI +NTSTATUS +NTAPI +MmAddVerifierThunks( + IN PVOID ThunkBuffer, + IN ULONG ThunkBufferSize); + +#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ + +#if (NTDDI_VERSION >= NTDDI_WS03) +NTKERNELAPI +LOGICAL +NTAPI +MmIsIoSpaceActive( + IN PHYSICAL_ADDRESS StartAddress, + IN SIZE_T NumberOfBytes); #endif #if (NTDDI_VERSION >= NTDDI_WS03SP1) @@ -8004,6 +10943,15 @@ MmAllocatePagesForMdlEx( IN ULONG Flags); #endif +#if (NTDDI_VERSION >= NTDDI_VISTA) + +NTKERNELAPI +LOGICAL +NTAPI +MmIsDriverVerifyingByAddress( + IN PVOID AddressWithinSection); +#endif + /****************************************************************************** * Security Manager Functions * ******************************************************************************/ @@ -8014,42 +10962,42 @@ NTKERNELAPI BOOLEAN NTAPI SeAccessCheck( - IN PSECURITY_DESCRIPTOR SecurityDescriptor, - IN PSECURITY_SUBJECT_CONTEXT SubjectSecurityContext, - IN BOOLEAN SubjectContextLocked, - IN ACCESS_MASK DesiredAccess, - IN ACCESS_MASK PreviouslyGrantedAccess, - OUT PPRIVILEGE_SET *Privileges OPTIONAL, - IN PGENERIC_MAPPING GenericMapping, - IN KPROCESSOR_MODE AccessMode, - OUT PACCESS_MASK GrantedAccess, - OUT PNTSTATUS AccessStatus); + IN PSECURITY_DESCRIPTOR SecurityDescriptor, + IN PSECURITY_SUBJECT_CONTEXT SubjectSecurityContext, + IN BOOLEAN SubjectContextLocked, + IN ACCESS_MASK DesiredAccess, + IN ACCESS_MASK PreviouslyGrantedAccess, + OUT PPRIVILEGE_SET *Privileges OPTIONAL, + IN PGENERIC_MAPPING GenericMapping, + IN KPROCESSOR_MODE AccessMode, + OUT PACCESS_MASK GrantedAccess, + OUT PNTSTATUS AccessStatus); NTKERNELAPI NTSTATUS NTAPI SeAssignSecurity( - IN PSECURITY_DESCRIPTOR ParentDescriptor OPTIONAL, - IN PSECURITY_DESCRIPTOR ExplicitDescriptor OPTIONAL, - OUT PSECURITY_DESCRIPTOR *NewDescriptor, - IN BOOLEAN IsDirectoryObject, - IN PSECURITY_SUBJECT_CONTEXT SubjectContext, - IN PGENERIC_MAPPING GenericMapping, - IN POOL_TYPE PoolType); + IN PSECURITY_DESCRIPTOR ParentDescriptor OPTIONAL, + IN PSECURITY_DESCRIPTOR ExplicitDescriptor OPTIONAL, + OUT PSECURITY_DESCRIPTOR *NewDescriptor, + IN BOOLEAN IsDirectoryObject, + IN PSECURITY_SUBJECT_CONTEXT SubjectContext, + IN PGENERIC_MAPPING GenericMapping, + IN POOL_TYPE PoolType); NTKERNELAPI NTSTATUS NTAPI SeAssignSecurityEx( - IN PSECURITY_DESCRIPTOR ParentDescriptor OPTIONAL, - IN PSECURITY_DESCRIPTOR ExplicitDescriptor OPTIONAL, - OUT PSECURITY_DESCRIPTOR *NewDescriptor, - IN GUID *ObjectType OPTIONAL, - IN BOOLEAN IsDirectoryObject, - IN ULONG AutoInheritFlags, - IN PSECURITY_SUBJECT_CONTEXT SubjectContext, - IN PGENERIC_MAPPING GenericMapping, - IN POOL_TYPE PoolType); + IN PSECURITY_DESCRIPTOR ParentDescriptor OPTIONAL, + IN PSECURITY_DESCRIPTOR ExplicitDescriptor OPTIONAL, + OUT PSECURITY_DESCRIPTOR *NewDescriptor, + IN GUID *ObjectType OPTIONAL, + IN BOOLEAN IsDirectoryObject, + IN ULONG AutoInheritFlags, + IN PSECURITY_SUBJECT_CONTEXT SubjectContext, + IN PGENERIC_MAPPING GenericMapping, + IN POOL_TYPE PoolType); NTKERNELAPI NTSTATUS @@ -8136,7 +11084,6 @@ SeGetWorldRights( #endif /* SE_NTFS_WORLD_CACHE */ #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ - /****************************************************************************** * Configuration Manager Functions * ******************************************************************************/ @@ -8146,22 +11093,103 @@ NTKERNELAPI NTSTATUS NTAPI CmRegisterCallback( - IN PEX_CALLBACK_FUNCTION Function, - IN PVOID Context OPTIONAL, - OUT PLARGE_INTEGER Cookie); + IN PEX_CALLBACK_FUNCTION Function, + IN PVOID Context OPTIONAL, + OUT PLARGE_INTEGER Cookie); NTKERNELAPI NTSTATUS NTAPI CmUnRegisterCallback( - IN LARGE_INTEGER Cookie); + IN LARGE_INTEGER Cookie); #endif +#if (NTDDI_VERSION >= NTDDI_VISTA) + +NTKERNELAPI +NTSTATUS +NTAPI +CmRegisterCallbackEx( + PEX_CALLBACK_FUNCTION Function, + PCUNICODE_STRING Altitude, + PVOID Driver, + PVOID Context, + PLARGE_INTEGER Cookie, + PVOID Reserved); + +NTKERNELAPI +VOID +NTAPI +CmGetCallbackVersion( + OUT PULONG Major OPTIONAL, + OUT PULONG Minor OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +CmSetCallbackObjectContext( + IN OUT PVOID Object, + IN PLARGE_INTEGER Cookie, + IN PVOID NewContext, + OUT PVOID *OldContext OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +CmCallbackGetKeyObjectID( + IN PLARGE_INTEGER Cookie, + IN PVOID Object, + OUT PULONG_PTR ObjectID OPTIONAL, + OUT PCUNICODE_STRING *ObjectName OPTIONAL); + +NTKERNELAPI +PVOID +NTAPI +CmGetBoundTransaction( + IN PLARGE_INTEGER Cookie, + IN PVOID Object); + +#endif // NTDDI_VERSION >= NTDDI_VISTA + /****************************************************************************** * I/O Manager Functions * ******************************************************************************/ + +/* + * NTSTATUS + * IoAcquireRemoveLock( + * IN PIO_REMOVE_LOCK RemoveLock, + * IN OPTIONAL PVOID Tag) + */ +#if DBG +#define IoAcquireRemoveLock(RemoveLock, Tag) \ + IoAcquireRemoveLockEx(RemoveLock, Tag, __FILE__, __LINE__, sizeof (IO_REMOVE_LOCK)) +#else +#define IoAcquireRemoveLock(RemoveLock, Tag) \ + IoAcquireRemoveLockEx(RemoveLock, Tag, "", 1, sizeof (IO_REMOVE_LOCK)) +#endif + +/* + * VOID + * IoAdjustPagingPathCount( + * IN PLONG Count, + * IN BOOLEAN Increment) + */ +#define IoAdjustPagingPathCount(_Count, \ + _Increment) \ +{ \ + if (_Increment) \ + { \ + InterlockedIncrement(_Count); \ + } \ + else \ + { \ + InterlockedDecrement(_Count); \ + } \ +} + #if !defined(_M_AMD64) NTHALAPI VOID @@ -8304,9 +11332,9 @@ NTKERNELAPI VOID NTAPI WRITE_REGISTER_BUFFER_ULONG( - IN PULONG Register, - IN PULONG Buffer, - IN ULONG Count); + IN PULONG Register, + IN PULONG Buffer, + IN ULONG Count); NTKERNELAPI VOID @@ -8334,8 +11362,8 @@ NTKERNELAPI VOID NTAPI WRITE_REGISTER_USHORT( - IN PUSHORT Register, - IN USHORT Value); + IN PUSHORT Register, + IN USHORT Value); #else @@ -8346,17 +11374,17 @@ READ_PORT_BUFFER_UCHAR( IN PUCHAR Buffer, IN ULONG Count) { - __inbytestring((USHORT)(ULONG_PTR)Port, Buffer, Count); + __inbytestring((USHORT)(ULONG_PTR)Port, Buffer, Count); } FORCEINLINE VOID READ_PORT_BUFFER_ULONG( - IN PULONG Port, - IN PULONG Buffer, - IN ULONG Count) + IN PULONG Port, + IN PULONG Buffer, + IN ULONG Count) { - __indwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count); + __indwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count); } FORCEINLINE @@ -8366,7 +11394,7 @@ READ_PORT_BUFFER_USHORT( IN PUSHORT Buffer, IN ULONG Count) { - __inwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count); + __inwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count); } FORCEINLINE @@ -8374,7 +11402,7 @@ UCHAR READ_PORT_UCHAR( IN PUCHAR Port) { - return __inbyte((USHORT)(ULONG_PTR)Port); + return __inbyte((USHORT)(ULONG_PTR)Port); } FORCEINLINE @@ -8382,7 +11410,7 @@ ULONG READ_PORT_ULONG( IN PULONG Port) { - return __indword((USHORT)(ULONG_PTR)Port); + return __indword((USHORT)(ULONG_PTR)Port); } FORCEINLINE @@ -8390,7 +11418,7 @@ USHORT READ_PORT_USHORT( IN PUSHORT Port) { - return __inword((USHORT)(ULONG_PTR)Port); + return __inword((USHORT)(ULONG_PTR)Port); } FORCEINLINE @@ -8400,27 +11428,27 @@ READ_REGISTER_BUFFER_UCHAR( IN PUCHAR Buffer, IN ULONG Count) { - __movsb(Register, Buffer, Count); + __movsb(Register, Buffer, Count); } FORCEINLINE VOID READ_REGISTER_BUFFER_ULONG( - IN PULONG Register, - IN PULONG Buffer, - IN ULONG Count) + IN PULONG Register, + IN PULONG Buffer, + IN ULONG Count) { - __movsd(Register, Buffer, Count); + __movsd(Register, Buffer, Count); } FORCEINLINE VOID READ_REGISTER_BUFFER_USHORT( - IN PUSHORT Register, - IN PUSHORT Buffer, - IN ULONG Count) + IN PUSHORT Register, + IN PUSHORT Buffer, + IN ULONG Count) { - __movsw(Register, Buffer, Count); + __movsw(Register, Buffer, Count); } FORCEINLINE @@ -8428,7 +11456,7 @@ UCHAR READ_REGISTER_UCHAR( IN volatile UCHAR *Register) { - return *Register; + return *Register; } FORCEINLINE @@ -8436,7 +11464,7 @@ ULONG READ_REGISTER_ULONG( IN volatile ULONG *Register) { - return *Register; + return *Register; } FORCEINLINE @@ -8444,7 +11472,7 @@ USHORT READ_REGISTER_USHORT( IN volatile USHORT *Register) { - return *Register; + return *Register; } FORCEINLINE @@ -8454,7 +11482,7 @@ WRITE_PORT_BUFFER_UCHAR( IN PUCHAR Buffer, IN ULONG Count) { - __outbytestring((USHORT)(ULONG_PTR)Port, Buffer, Count); + __outbytestring((USHORT)(ULONG_PTR)Port, Buffer, Count); } FORCEINLINE @@ -8464,7 +11492,7 @@ WRITE_PORT_BUFFER_ULONG( IN PULONG Buffer, IN ULONG Count) { - __outdwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count); + __outdwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count); } FORCEINLINE @@ -8474,7 +11502,7 @@ WRITE_PORT_BUFFER_USHORT( IN PUSHORT Buffer, IN ULONG Count) { - __outwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count); + __outwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count); } FORCEINLINE @@ -8483,7 +11511,7 @@ WRITE_PORT_UCHAR( IN PUCHAR Port, IN UCHAR Value) { - __outbyte((USHORT)(ULONG_PTR)Port, Value); + __outbyte((USHORT)(ULONG_PTR)Port, Value); } FORCEINLINE @@ -8492,7 +11520,7 @@ WRITE_PORT_ULONG( IN PULONG Port, IN ULONG Value) { - __outdword((USHORT)(ULONG_PTR)Port, Value); + __outdword((USHORT)(ULONG_PTR)Port, Value); } FORCEINLINE @@ -8501,7 +11529,7 @@ WRITE_PORT_USHORT( IN PUSHORT Port, IN USHORT Value) { - __outword((USHORT)(ULONG_PTR)Port, Value); + __outword((USHORT)(ULONG_PTR)Port, Value); } FORCEINLINE @@ -8511,9 +11539,9 @@ WRITE_REGISTER_BUFFER_UCHAR( IN PUCHAR Buffer, IN ULONG Count) { - LONG Synch; - __movsb(Register, Buffer, Count); - InterlockedOr(&Synch, 1); + LONG Synch; + __movsb(Register, Buffer, Count); + InterlockedOr(&Synch, 1); } FORCEINLINE @@ -8523,9 +11551,9 @@ WRITE_REGISTER_BUFFER_ULONG( IN PULONG Buffer, IN ULONG Count) { - LONG Synch; - __movsd(Register, Buffer, Count); - InterlockedOr(&Synch, 1); + LONG Synch; + __movsd(Register, Buffer, Count); + InterlockedOr(&Synch, 1); } FORCEINLINE @@ -8535,9 +11563,9 @@ WRITE_REGISTER_BUFFER_USHORT( IN PUSHORT Buffer, IN ULONG Count) { - LONG Synch; - __movsw(Register, Buffer, Count); - InterlockedOr(&Synch, 1); + LONG Synch; + __movsw(Register, Buffer, Count); + InterlockedOr(&Synch, 1); } FORCEINLINE @@ -8546,9 +11574,9 @@ WRITE_REGISTER_UCHAR( IN volatile UCHAR *Register, IN UCHAR Value) { - LONG Synch; - *Register = Value; - InterlockedOr(&Synch, 1); + LONG Synch; + *Register = Value; + InterlockedOr(&Synch, 1); } FORCEINLINE @@ -8557,9 +11585,9 @@ WRITE_REGISTER_ULONG( IN volatile ULONG *Register, IN ULONG Value) { - LONG Synch; - *Register = Value; - InterlockedOr(&Synch, 1); + LONG Synch; + *Register = Value; + InterlockedOr(&Synch, 1); } FORCEINLINE @@ -8568,9 +11596,9 @@ WRITE_REGISTER_USHORT( IN volatile USHORT *Register, IN USHORT Value) { - LONG Sync; - *Register = Value; - InterlockedOr(&Sync, 1); + LONG Sync; + *Register = Value; + InterlockedOr(&Sync, 1); } #endif @@ -8582,254 +11610,218 @@ WRITE_REGISTER_USHORT( FORCEINLINE NTSTATUS IoAllocateAdapterChannel( - IN PDMA_ADAPTER DmaAdapter, - IN PDEVICE_OBJECT DeviceObject, - IN ULONG NumberOfMapRegisters, - IN PDRIVER_CONTROL ExecutionRoutine, - IN PVOID Context) + IN PDMA_ADAPTER DmaAdapter, + IN PDEVICE_OBJECT DeviceObject, + IN ULONG NumberOfMapRegisters, + IN PDRIVER_CONTROL ExecutionRoutine, + IN PVOID Context) { - PALLOCATE_ADAPTER_CHANNEL AllocateAdapterChannel; - AllocateAdapterChannel = - *(DmaAdapter)->DmaOperations->AllocateAdapterChannel; - ASSERT(AllocateAdapterChannel); - return AllocateAdapterChannel(DmaAdapter, - DeviceObject, - NumberOfMapRegisters, - ExecutionRoutine, - Context ); + PALLOCATE_ADAPTER_CHANNEL AllocateAdapterChannel; + AllocateAdapterChannel = + *(DmaAdapter)->DmaOperations->AllocateAdapterChannel; + ASSERT(AllocateAdapterChannel); + return AllocateAdapterChannel(DmaAdapter, + DeviceObject, + NumberOfMapRegisters, + ExecutionRoutine, + Context ); } FORCEINLINE BOOLEAN NTAPI IoFlushAdapterBuffers( - IN PDMA_ADAPTER DmaAdapter, - IN PMDL Mdl, - IN PVOID MapRegisterBase, - IN PVOID CurrentVa, - IN ULONG Length, - IN BOOLEAN WriteToDevice) + IN PDMA_ADAPTER DmaAdapter, + IN PMDL Mdl, + IN PVOID MapRegisterBase, + IN PVOID CurrentVa, + IN ULONG Length, + IN BOOLEAN WriteToDevice) { - PFLUSH_ADAPTER_BUFFERS FlushAdapterBuffers; - FlushAdapterBuffers = *(DmaAdapter)->DmaOperations->FlushAdapterBuffers; - ASSERT(FlushAdapterBuffers); - return FlushAdapterBuffers(DmaAdapter, - Mdl, - MapRegisterBase, - CurrentVa, - Length, - WriteToDevice ); + PFLUSH_ADAPTER_BUFFERS FlushAdapterBuffers; + FlushAdapterBuffers = *(DmaAdapter)->DmaOperations->FlushAdapterBuffers; + ASSERT(FlushAdapterBuffers); + return FlushAdapterBuffers(DmaAdapter, + Mdl, + MapRegisterBase, + CurrentVa, + Length, + WriteToDevice); } FORCEINLINE VOID NTAPI IoFreeAdapterChannel( - IN PDMA_ADAPTER DmaAdapter) + IN PDMA_ADAPTER DmaAdapter) { - PFREE_ADAPTER_CHANNEL FreeAdapterChannel; - FreeAdapterChannel = *(DmaAdapter)->DmaOperations->FreeAdapterChannel; - ASSERT(FreeAdapterChannel); - FreeAdapterChannel(DmaAdapter); + PFREE_ADAPTER_CHANNEL FreeAdapterChannel; + FreeAdapterChannel = *(DmaAdapter)->DmaOperations->FreeAdapterChannel; + ASSERT(FreeAdapterChannel); + FreeAdapterChannel(DmaAdapter); } FORCEINLINE VOID NTAPI IoFreeMapRegisters( - IN PDMA_ADAPTER DmaAdapter, - IN PVOID MapRegisterBase, - IN ULONG NumberOfMapRegisters) + IN PDMA_ADAPTER DmaAdapter, + IN PVOID MapRegisterBase, + IN ULONG NumberOfMapRegisters) { - PFREE_MAP_REGISTERS FreeMapRegisters; - FreeMapRegisters = *(DmaAdapter)->DmaOperations->FreeMapRegisters; - ASSERT(FreeMapRegisters); - FreeMapRegisters(DmaAdapter, MapRegisterBase, NumberOfMapRegisters); + PFREE_MAP_REGISTERS FreeMapRegisters; + FreeMapRegisters = *(DmaAdapter)->DmaOperations->FreeMapRegisters; + ASSERT(FreeMapRegisters); + FreeMapRegisters(DmaAdapter, MapRegisterBase, NumberOfMapRegisters); } FORCEINLINE PHYSICAL_ADDRESS NTAPI IoMapTransfer( - IN PDMA_ADAPTER DmaAdapter, - IN PMDL Mdl, - IN PVOID MapRegisterBase, - IN PVOID CurrentVa, - IN OUT PULONG Length, - IN BOOLEAN WriteToDevice) + IN PDMA_ADAPTER DmaAdapter, + IN PMDL Mdl, + IN PVOID MapRegisterBase, + IN PVOID CurrentVa, + IN OUT PULONG Length, + IN BOOLEAN WriteToDevice) { - PMAP_TRANSFER MapTransfer; + PMAP_TRANSFER MapTransfer; - MapTransfer = *(DmaAdapter)->DmaOperations->MapTransfer; - ASSERT(MapTransfer); - return MapTransfer(DmaAdapter, - Mdl, - MapRegisterBase, - CurrentVa, - Length, - WriteToDevice); + MapTransfer = *(DmaAdapter)->DmaOperations->MapTransfer; + ASSERT(MapTransfer); + return MapTransfer(DmaAdapter, + Mdl, + MapRegisterBase, + CurrentVa, + Length, + WriteToDevice); } #endif #if (NTDDI_VERSION >= NTDDI_WIN2K) + NTKERNELAPI VOID NTAPI IoAcquireCancelSpinLock( - OUT PKIRQL Irql); + OUT PKIRQL Irql); NTKERNELAPI NTSTATUS NTAPI IoAcquireRemoveLockEx( - IN PIO_REMOVE_LOCK RemoveLock, - IN PVOID Tag OPTIONAL, - IN PCSTR File, - IN ULONG Line, - IN ULONG RemlockSize); -#endif - -/* - * NTSTATUS - * IoAcquireRemoveLock( - * IN PIO_REMOVE_LOCK RemoveLock, - * IN OPTIONAL PVOID Tag) - */ -#if DBG -#define IoAcquireRemoveLock(RemoveLock, Tag) \ - IoAcquireRemoveLockEx(RemoveLock, Tag, __FILE__, __LINE__, sizeof (IO_REMOVE_LOCK)) -#else -#define IoAcquireRemoveLock(RemoveLock, Tag) \ - IoAcquireRemoveLockEx(RemoveLock, Tag, "", 1, sizeof (IO_REMOVE_LOCK)) -#endif - -/* - * VOID - * IoAdjustPagingPathCount( - * IN PLONG Count, - * IN BOOLEAN Increment) - */ -#define IoAdjustPagingPathCount(_Count, \ - _Increment) \ -{ \ - if (_Increment) \ - { \ - InterlockedIncrement(_Count); \ - } \ - else \ - { \ - InterlockedDecrement(_Count); \ - } \ -} - -#if (NTDDI_VERSION >= NTDDI_WIN2K) - + IN PIO_REMOVE_LOCK RemoveLock, + IN PVOID Tag OPTIONAL, + IN PCSTR File, + IN ULONG Line, + IN ULONG RemlockSize); NTKERNELAPI NTSTATUS NTAPI IoAllocateDriverObjectExtension( - IN PDRIVER_OBJECT DriverObject, - IN PVOID ClientIdentificationAddress, - IN ULONG DriverObjectExtensionSize, - OUT PVOID *DriverObjectExtension); + IN PDRIVER_OBJECT DriverObject, + IN PVOID ClientIdentificationAddress, + IN ULONG DriverObjectExtensionSize, + OUT PVOID *DriverObjectExtension); NTKERNELAPI PVOID NTAPI IoAllocateErrorLogEntry( - IN PVOID IoObject, - IN UCHAR EntrySize); + IN PVOID IoObject, + IN UCHAR EntrySize); NTKERNELAPI PIRP NTAPI IoAllocateIrp( - IN CCHAR StackSize, - IN BOOLEAN ChargeQuota); + IN CCHAR StackSize, + IN BOOLEAN ChargeQuota); NTKERNELAPI PMDL NTAPI IoAllocateMdl( - IN PVOID VirtualAddress OPTIONAL, - IN ULONG Length, - IN BOOLEAN SecondaryBuffer, - IN BOOLEAN ChargeQuota, - IN OUT PIRP Irp OPTIONAL); + IN PVOID VirtualAddress OPTIONAL, + IN ULONG Length, + IN BOOLEAN SecondaryBuffer, + IN BOOLEAN ChargeQuota, + IN OUT PIRP Irp OPTIONAL); NTKERNELAPI PIO_WORKITEM NTAPI IoAllocateWorkItem( - IN PDEVICE_OBJECT DeviceObject); + IN PDEVICE_OBJECT DeviceObject); NTKERNELAPI NTSTATUS NTAPI IoAttachDevice( - IN PDEVICE_OBJECT SourceDevice, - IN PUNICODE_STRING TargetDevice, - OUT PDEVICE_OBJECT *AttachedDevice); + IN PDEVICE_OBJECT SourceDevice, + IN PUNICODE_STRING TargetDevice, + OUT PDEVICE_OBJECT *AttachedDevice); NTKERNELAPI PDEVICE_OBJECT NTAPI IoAttachDeviceToDeviceStack( - IN PDEVICE_OBJECT SourceDevice, - IN PDEVICE_OBJECT TargetDevice); + IN PDEVICE_OBJECT SourceDevice, + IN PDEVICE_OBJECT TargetDevice); NTKERNELAPI PIRP NTAPI IoBuildAsynchronousFsdRequest( - IN ULONG MajorFunction, - IN PDEVICE_OBJECT DeviceObject, - IN OUT PVOID Buffer OPTIONAL, - IN ULONG Length OPTIONAL, - IN PLARGE_INTEGER StartingOffset OPTIONAL, - IN PIO_STATUS_BLOCK IoStatusBlock OPTIONAL); + IN ULONG MajorFunction, + IN PDEVICE_OBJECT DeviceObject, + IN OUT PVOID Buffer OPTIONAL, + IN ULONG Length OPTIONAL, + IN PLARGE_INTEGER StartingOffset OPTIONAL, + IN PIO_STATUS_BLOCK IoStatusBlock OPTIONAL); NTKERNELAPI PIRP NTAPI IoBuildDeviceIoControlRequest( - IN ULONG IoControlCode, - IN PDEVICE_OBJECT DeviceObject, - IN PVOID InputBuffer OPTIONAL, - IN ULONG InputBufferLength, - OUT PVOID OutputBuffer OPTIONAL, - IN ULONG OutputBufferLength, - IN BOOLEAN InternalDeviceIoControl, - IN PKEVENT Event, - OUT PIO_STATUS_BLOCK IoStatusBlock); + IN ULONG IoControlCode, + IN PDEVICE_OBJECT DeviceObject, + IN PVOID InputBuffer OPTIONAL, + IN ULONG InputBufferLength, + OUT PVOID OutputBuffer OPTIONAL, + IN ULONG OutputBufferLength, + IN BOOLEAN InternalDeviceIoControl, + IN PKEVENT Event, + OUT PIO_STATUS_BLOCK IoStatusBlock); NTKERNELAPI VOID NTAPI IoBuildPartialMdl( - IN PMDL SourceMdl, - IN OUT PMDL TargetMdl, - IN PVOID VirtualAddress, - IN ULONG Length); + IN PMDL SourceMdl, + IN OUT PMDL TargetMdl, + IN PVOID VirtualAddress, + IN ULONG Length); NTKERNELAPI PIRP NTAPI IoBuildSynchronousFsdRequest( - IN ULONG MajorFunction, - IN PDEVICE_OBJECT DeviceObject, - IN OUT PVOID Buffer OPTIONAL, - IN ULONG Length OPTIONAL, - IN PLARGE_INTEGER StartingOffset OPTIONAL, - IN PKEVENT Event, - OUT PIO_STATUS_BLOCK IoStatusBlock); + IN ULONG MajorFunction, + IN PDEVICE_OBJECT DeviceObject, + IN OUT PVOID Buffer OPTIONAL, + IN ULONG Length OPTIONAL, + IN PLARGE_INTEGER StartingOffset OPTIONAL, + IN PKEVENT Event, + OUT PIO_STATUS_BLOCK IoStatusBlock); NTKERNELAPI NTSTATUS FASTCALL IofCallDriver( - IN PDEVICE_OBJECT DeviceObject, - IN OUT PIRP Irp); + IN PDEVICE_OBJECT DeviceObject, + IN OUT PIRP Irp); #define IoCallDriver IofCallDriver NTKERNELAPI @@ -8844,52 +11836,52 @@ NTKERNELAPI BOOLEAN NTAPI IoCancelIrp( - IN PIRP Irp); + IN PIRP Irp); NTKERNELAPI NTSTATUS NTAPI IoCheckShareAccess( - IN ACCESS_MASK DesiredAccess, - IN ULONG DesiredShareAccess, - IN OUT PFILE_OBJECT FileObject, - IN OUT PSHARE_ACCESS ShareAccess, - IN BOOLEAN Update); + IN ACCESS_MASK DesiredAccess, + IN ULONG DesiredShareAccess, + IN OUT PFILE_OBJECT FileObject, + IN OUT PSHARE_ACCESS ShareAccess, + IN BOOLEAN Update); NTKERNELAPI VOID FASTCALL IofCompleteRequest( - IN PIRP Irp, - IN CCHAR PriorityBoost); + IN PIRP Irp, + IN CCHAR PriorityBoost); NTKERNELAPI NTSTATUS NTAPI IoConnectInterrupt( - OUT PKINTERRUPT *InterruptObject, - IN PKSERVICE_ROUTINE ServiceRoutine, - IN PVOID ServiceContext OPTIONAL, - IN PKSPIN_LOCK SpinLock OPTIONAL, - IN ULONG Vector, - IN KIRQL Irql, - IN KIRQL SynchronizeIrql, - IN KINTERRUPT_MODE InterruptMode, - IN BOOLEAN ShareVector, - IN KAFFINITY ProcessorEnableMask, - IN BOOLEAN FloatingSave); + OUT PKINTERRUPT *InterruptObject, + IN PKSERVICE_ROUTINE ServiceRoutine, + IN PVOID ServiceContext OPTIONAL, + IN PKSPIN_LOCK SpinLock OPTIONAL, + IN ULONG Vector, + IN KIRQL Irql, + IN KIRQL SynchronizeIrql, + IN KINTERRUPT_MODE InterruptMode, + IN BOOLEAN ShareVector, + IN KAFFINITY ProcessorEnableMask, + IN BOOLEAN FloatingSave); NTKERNELAPI NTSTATUS NTAPI IoCreateDevice( - IN PDRIVER_OBJECT DriverObject, - IN ULONG DeviceExtensionSize, - IN PUNICODE_STRING DeviceName OPTIONAL, - IN DEVICE_TYPE DeviceType, - IN ULONG DeviceCharacteristics, - IN BOOLEAN Exclusive, - OUT PDEVICE_OBJECT *DeviceObject); + IN PDRIVER_OBJECT DriverObject, + IN ULONG DeviceExtensionSize, + IN PUNICODE_STRING DeviceName OPTIONAL, + IN DEVICE_TYPE DeviceType, + IN ULONG DeviceCharacteristics, + IN BOOLEAN Exclusive, + OUT PDEVICE_OBJECT *DeviceObject); NTKERNELAPI NTSTATUS @@ -8914,53 +11906,53 @@ NTKERNELAPI PKEVENT NTAPI IoCreateNotificationEvent( - IN PUNICODE_STRING EventName, - OUT PHANDLE EventHandle); + IN PUNICODE_STRING EventName, + OUT PHANDLE EventHandle); NTKERNELAPI NTSTATUS NTAPI IoCreateSymbolicLink( - IN PUNICODE_STRING SymbolicLinkName, - IN PUNICODE_STRING DeviceName); + IN PUNICODE_STRING SymbolicLinkName, + IN PUNICODE_STRING DeviceName); NTKERNELAPI PKEVENT NTAPI IoCreateSynchronizationEvent( - IN PUNICODE_STRING EventName, - OUT PHANDLE EventHandle); + IN PUNICODE_STRING EventName, + OUT PHANDLE EventHandle); NTKERNELAPI NTSTATUS NTAPI IoCreateUnprotectedSymbolicLink( - IN PUNICODE_STRING SymbolicLinkName, - IN PUNICODE_STRING DeviceName); + IN PUNICODE_STRING SymbolicLinkName, + IN PUNICODE_STRING DeviceName); NTKERNELAPI VOID NTAPI IoDeleteDevice( - IN PDEVICE_OBJECT DeviceObject); + IN PDEVICE_OBJECT DeviceObject); NTKERNELAPI NTSTATUS NTAPI IoDeleteSymbolicLink( - IN PUNICODE_STRING SymbolicLinkName); + IN PUNICODE_STRING SymbolicLinkName); NTKERNELAPI VOID NTAPI IoDetachDevice( - IN OUT PDEVICE_OBJECT TargetDevice); + IN OUT PDEVICE_OBJECT TargetDevice); NTKERNELAPI VOID NTAPI IoDisconnectInterrupt( - IN PKINTERRUPT InterruptObject); + IN PKINTERRUPT InterruptObject); NTKERNELAPI VOID @@ -8990,359 +11982,375 @@ NTKERNELAPI PDEVICE_OBJECT NTAPI IoGetAttachedDeviceReference( - IN PDEVICE_OBJECT DeviceObject); + IN PDEVICE_OBJECT DeviceObject); NTKERNELAPI NTSTATUS NTAPI IoGetBootDiskInformation( - IN OUT PBOOTDISK_INFORMATION BootDiskInformation, - IN ULONG Size); + IN OUT PBOOTDISK_INFORMATION BootDiskInformation, + IN ULONG Size); NTKERNELAPI NTSTATUS NTAPI IoGetDeviceInterfaceAlias( - IN PUNICODE_STRING SymbolicLinkName, - IN CONST GUID *AliasInterfaceClassGuid, - OUT PUNICODE_STRING AliasSymbolicLinkName); + IN PUNICODE_STRING SymbolicLinkName, + IN CONST GUID *AliasInterfaceClassGuid, + OUT PUNICODE_STRING AliasSymbolicLinkName); NTKERNELAPI PEPROCESS NTAPI -IoGetCurrentProcess( - VOID); +IoGetCurrentProcess(VOID); NTKERNELAPI NTSTATUS NTAPI IoGetDeviceInterfaces( - IN CONST GUID *InterfaceClassGuid, - IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL, - IN ULONG Flags, - OUT PWSTR *SymbolicLinkList); + IN CONST GUID *InterfaceClassGuid, + IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL, + IN ULONG Flags, + OUT PWSTR *SymbolicLinkList); NTKERNELAPI NTSTATUS NTAPI IoGetDeviceObjectPointer( - IN PUNICODE_STRING ObjectName, - IN ACCESS_MASK DesiredAccess, - OUT PFILE_OBJECT *FileObject, - OUT PDEVICE_OBJECT *DeviceObject); + IN PUNICODE_STRING ObjectName, + IN ACCESS_MASK DesiredAccess, + OUT PFILE_OBJECT *FileObject, + OUT PDEVICE_OBJECT *DeviceObject); NTKERNELAPI NTSTATUS NTAPI IoGetDeviceProperty( - IN PDEVICE_OBJECT DeviceObject, - IN DEVICE_REGISTRY_PROPERTY DeviceProperty, - IN ULONG BufferLength, - OUT PVOID PropertyBuffer, - OUT PULONG ResultLength); + IN PDEVICE_OBJECT DeviceObject, + IN DEVICE_REGISTRY_PROPERTY DeviceProperty, + IN ULONG BufferLength, + OUT PVOID PropertyBuffer, + OUT PULONG ResultLength); NTKERNELAPI PDMA_ADAPTER NTAPI IoGetDmaAdapter( - IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL, - IN PDEVICE_DESCRIPTION DeviceDescription, - IN OUT PULONG NumberOfMapRegisters); + IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL, + IN PDEVICE_DESCRIPTION DeviceDescription, + IN OUT PULONG NumberOfMapRegisters); NTKERNELAPI PVOID NTAPI IoGetDriverObjectExtension( - IN PDRIVER_OBJECT DriverObject, - IN PVOID ClientIdentificationAddress); + IN PDRIVER_OBJECT DriverObject, + IN PVOID ClientIdentificationAddress); NTKERNELAPI PVOID NTAPI -IoGetInitialStack( - VOID); +IoGetInitialStack(VOID); NTKERNELAPI PDEVICE_OBJECT NTAPI IoGetRelatedDeviceObject( - IN PFILE_OBJECT FileObject); + IN PFILE_OBJECT FileObject); NTKERNELAPI VOID NTAPI IoQueueWorkItem( - IN PIO_WORKITEM IoWorkItem, - IN PIO_WORKITEM_ROUTINE WorkerRoutine, - IN WORK_QUEUE_TYPE QueueType, - IN PVOID Context OPTIONAL); + IN PIO_WORKITEM IoWorkItem, + IN PIO_WORKITEM_ROUTINE WorkerRoutine, + IN WORK_QUEUE_TYPE QueueType, + IN PVOID Context OPTIONAL); NTKERNELAPI VOID NTAPI IoInitializeIrp( - IN OUT PIRP Irp, - IN USHORT PacketSize, - IN CCHAR StackSize); + IN OUT PIRP Irp, + IN USHORT PacketSize, + IN CCHAR StackSize); NTKERNELAPI VOID NTAPI IoInitializeRemoveLockEx( - IN PIO_REMOVE_LOCK Lock, - IN ULONG AllocateTag, - IN ULONG MaxLockedMinutes, - IN ULONG HighWatermark, - IN ULONG RemlockSize); + IN PIO_REMOVE_LOCK Lock, + IN ULONG AllocateTag, + IN ULONG MaxLockedMinutes, + IN ULONG HighWatermark, + IN ULONG RemlockSize); NTKERNELAPI NTSTATUS NTAPI IoInitializeTimer( - IN PDEVICE_OBJECT DeviceObject, - IN PIO_TIMER_ROUTINE TimerRoutine, - IN PVOID Context OPTIONAL); + IN PDEVICE_OBJECT DeviceObject, + IN PIO_TIMER_ROUTINE TimerRoutine, + IN PVOID Context OPTIONAL); NTKERNELAPI VOID NTAPI IoInvalidateDeviceRelations( - IN PDEVICE_OBJECT DeviceObject, - IN DEVICE_RELATION_TYPE Type); + IN PDEVICE_OBJECT DeviceObject, + IN DEVICE_RELATION_TYPE Type); NTKERNELAPI VOID NTAPI IoInvalidateDeviceState( - IN PDEVICE_OBJECT PhysicalDeviceObject); + IN PDEVICE_OBJECT PhysicalDeviceObject); NTKERNELAPI BOOLEAN NTAPI IoIsWdmVersionAvailable( - IN UCHAR MajorVersion, - IN UCHAR MinorVersion); + IN UCHAR MajorVersion, + IN UCHAR MinorVersion); NTKERNELAPI NTSTATUS NTAPI IoOpenDeviceInterfaceRegistryKey( - IN PUNICODE_STRING SymbolicLinkName, - IN ACCESS_MASK DesiredAccess, - OUT PHANDLE DeviceInterfaceKey); + IN PUNICODE_STRING SymbolicLinkName, + IN ACCESS_MASK DesiredAccess, + OUT PHANDLE DeviceInterfaceKey); NTKERNELAPI NTSTATUS NTAPI IoOpenDeviceRegistryKey( - IN PDEVICE_OBJECT DeviceObject, - IN ULONG DevInstKeyType, - IN ACCESS_MASK DesiredAccess, - OUT PHANDLE DevInstRegKey); + IN PDEVICE_OBJECT DeviceObject, + IN ULONG DevInstKeyType, + IN ACCESS_MASK DesiredAccess, + OUT PHANDLE DevInstRegKey); NTKERNELAPI NTSTATUS NTAPI IoRegisterDeviceInterface( - IN PDEVICE_OBJECT PhysicalDeviceObject, - IN CONST GUID *InterfaceClassGuid, - IN PUNICODE_STRING ReferenceString OPTIONAL, - OUT PUNICODE_STRING SymbolicLinkName); + IN PDEVICE_OBJECT PhysicalDeviceObject, + IN CONST GUID *InterfaceClassGuid, + IN PUNICODE_STRING ReferenceString OPTIONAL, + OUT PUNICODE_STRING SymbolicLinkName); NTKERNELAPI NTSTATUS NTAPI IoRegisterPlugPlayNotification( - IN IO_NOTIFICATION_EVENT_CATEGORY EventCategory, - IN ULONG EventCategoryFlags, - IN PVOID EventCategoryData OPTIONAL, - IN PDRIVER_OBJECT DriverObject, - IN PDRIVER_NOTIFICATION_CALLBACK_ROUTINE CallbackRoutine, - IN OUT PVOID Context OPTIONAL, - OUT PVOID *NotificationEntry); + IN IO_NOTIFICATION_EVENT_CATEGORY EventCategory, + IN ULONG EventCategoryFlags, + IN PVOID EventCategoryData OPTIONAL, + IN PDRIVER_OBJECT DriverObject, + IN PDRIVER_NOTIFICATION_CALLBACK_ROUTINE CallbackRoutine, + IN OUT PVOID Context OPTIONAL, + OUT PVOID *NotificationEntry); NTKERNELAPI NTSTATUS NTAPI IoRegisterShutdownNotification( - IN PDEVICE_OBJECT DeviceObject); + IN PDEVICE_OBJECT DeviceObject); NTKERNELAPI VOID NTAPI IoReleaseCancelSpinLock( - IN KIRQL Irql); + IN KIRQL Irql); NTKERNELAPI VOID NTAPI IoReleaseRemoveLockAndWaitEx( - IN PIO_REMOVE_LOCK RemoveLock, - IN PVOID Tag OPTIONAL, - IN ULONG RemlockSize); + IN PIO_REMOVE_LOCK RemoveLock, + IN PVOID Tag OPTIONAL, + IN ULONG RemlockSize); NTKERNELAPI VOID NTAPI IoReleaseRemoveLockEx( - IN PIO_REMOVE_LOCK RemoveLock, - IN PVOID Tag OPTIONAL, - IN ULONG RemlockSize); + IN PIO_REMOVE_LOCK RemoveLock, + IN PVOID Tag OPTIONAL, + IN ULONG RemlockSize); NTKERNELAPI VOID NTAPI IoRemoveShareAccess( - IN PFILE_OBJECT FileObject, - IN OUT PSHARE_ACCESS ShareAccess); + IN PFILE_OBJECT FileObject, + IN OUT PSHARE_ACCESS ShareAccess); NTKERNELAPI NTSTATUS NTAPI IoReportTargetDeviceChange( - IN PDEVICE_OBJECT PhysicalDeviceObject, - IN PVOID NotificationStructure); + IN PDEVICE_OBJECT PhysicalDeviceObject, + IN PVOID NotificationStructure); NTKERNELAPI NTSTATUS NTAPI IoReportTargetDeviceChangeAsynchronous( - IN PDEVICE_OBJECT PhysicalDeviceObject, - IN PVOID NotificationStructure, - IN PDEVICE_CHANGE_COMPLETE_CALLBACK Callback OPTIONAL, - IN PVOID Context OPTIONAL); + IN PDEVICE_OBJECT PhysicalDeviceObject, + IN PVOID NotificationStructure, + IN PDEVICE_CHANGE_COMPLETE_CALLBACK Callback OPTIONAL, + IN PVOID Context OPTIONAL); NTKERNELAPI VOID NTAPI IoRequestDeviceEject( - IN PDEVICE_OBJECT PhysicalDeviceObject); + IN PDEVICE_OBJECT PhysicalDeviceObject); NTKERNELAPI VOID NTAPI IoReuseIrp( - IN OUT PIRP Irp, - IN NTSTATUS Status); + IN OUT PIRP Irp, + IN NTSTATUS Status); NTKERNELAPI NTSTATUS NTAPI IoSetDeviceInterfaceState( - IN PUNICODE_STRING SymbolicLinkName, - IN BOOLEAN Enable); + IN PUNICODE_STRING SymbolicLinkName, + IN BOOLEAN Enable); NTKERNELAPI VOID NTAPI IoSetShareAccess( - IN ACCESS_MASK DesiredAccess, - IN ULONG DesiredShareAccess, - IN OUT PFILE_OBJECT FileObject, - OUT PSHARE_ACCESS ShareAccess); + IN ACCESS_MASK DesiredAccess, + IN ULONG DesiredShareAccess, + IN OUT PFILE_OBJECT FileObject, + OUT PSHARE_ACCESS ShareAccess); NTKERNELAPI VOID NTAPI IoStartNextPacket( - IN PDEVICE_OBJECT DeviceObject, - IN BOOLEAN Cancelable); + IN PDEVICE_OBJECT DeviceObject, + IN BOOLEAN Cancelable); NTKERNELAPI VOID NTAPI IoStartNextPacketByKey( - IN PDEVICE_OBJECT DeviceObject, - IN BOOLEAN Cancelable, - IN ULONG Key); + IN PDEVICE_OBJECT DeviceObject, + IN BOOLEAN Cancelable, + IN ULONG Key); NTKERNELAPI VOID NTAPI IoStartPacket( - IN PDEVICE_OBJECT DeviceObject, - IN PIRP Irp, - IN PULONG Key OPTIONAL, - IN PDRIVER_CANCEL CancelFunction OPTIONAL); + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp, + IN PULONG Key OPTIONAL, + IN PDRIVER_CANCEL CancelFunction OPTIONAL); NTKERNELAPI VOID NTAPI IoStartTimer( - IN PDEVICE_OBJECT DeviceObject); + IN PDEVICE_OBJECT DeviceObject); NTKERNELAPI VOID NTAPI IoStopTimer( - IN PDEVICE_OBJECT DeviceObject); + IN PDEVICE_OBJECT DeviceObject); NTKERNELAPI NTSTATUS NTAPI IoUnregisterPlugPlayNotification( - IN PVOID NotificationEntry); + IN PVOID NotificationEntry); NTKERNELAPI VOID NTAPI IoUnregisterShutdownNotification( - IN PDEVICE_OBJECT DeviceObject); + IN PDEVICE_OBJECT DeviceObject); NTKERNELAPI VOID NTAPI IoUpdateShareAccess( - IN PFILE_OBJECT FileObject, - IN OUT PSHARE_ACCESS ShareAccess); + IN PFILE_OBJECT FileObject, + IN OUT PSHARE_ACCESS ShareAccess); NTKERNELAPI NTSTATUS NTAPI IoWMIAllocateInstanceIds( - IN GUID *Guid, - IN ULONG InstanceCount, - OUT ULONG *FirstInstanceId); + IN GUID *Guid, + IN ULONG InstanceCount, + OUT ULONG *FirstInstanceId); NTKERNELAPI NTSTATUS NTAPI IoWMIQuerySingleInstanceMultiple( - IN PVOID *DataBlockObjectList, - IN PUNICODE_STRING InstanceNames, - IN ULONG ObjectCount, - IN OUT ULONG *InOutBufferSize, - OUT PVOID OutBuffer); + IN PVOID *DataBlockObjectList, + IN PUNICODE_STRING InstanceNames, + IN ULONG ObjectCount, + IN OUT ULONG *InOutBufferSize, + OUT PVOID OutBuffer); NTKERNELAPI NTSTATUS NTAPI IoWMIRegistrationControl( - IN PDEVICE_OBJECT DeviceObject, - IN ULONG Action); + IN PDEVICE_OBJECT DeviceObject, + IN ULONG Action); NTKERNELAPI NTSTATUS NTAPI IoWMISuggestInstanceName( - IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL, - IN PUNICODE_STRING SymbolicLinkName OPTIONAL, - IN BOOLEAN CombineNames, - OUT PUNICODE_STRING SuggestedInstanceName); + IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL, + IN PUNICODE_STRING SymbolicLinkName OPTIONAL, + IN BOOLEAN CombineNames, + OUT PUNICODE_STRING SuggestedInstanceName); NTKERNELAPI NTSTATUS NTAPI IoWMIWriteEvent( - IN PVOID WnodeEventItem); + IN OUT PVOID WnodeEventItem); NTKERNELAPI VOID NTAPI IoWriteErrorLogEntry( - IN PVOID ElEntry); + IN PVOID ElEntry); + +NTKERNELAPI +PIRP +NTAPI +IoGetTopLevelIrp(VOID); + +NTKERNELAPI +NTSTATUS +NTAPI +IoRegisterLastChanceShutdownNotification( + IN PDEVICE_OBJECT DeviceObject); + +NTKERNELAPI +VOID +NTAPI +IoSetTopLevelIrp( + IN PIRP Irp OPTIONAL); + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ -#endif #if (NTDDI_VERSION >= NTDDI_WINXP) @@ -9377,15 +12385,15 @@ NTKERNELAPI PIRP NTAPI IoCsqRemoveNextIrp( - IN PIO_CSQ Csq, - IN PVOID PeekContext); + IN PIO_CSQ Csq, + IN PVOID PeekContext OPTIONAL); NTKERNELAPI BOOLEAN NTAPI IoForwardIrpSynchronously( - IN PDEVICE_OBJECT DeviceObject, - IN PIRP Irp); + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp); #define IoForwardAndCatchIrp IoForwardIrpSynchronously @@ -9393,119 +12401,347 @@ NTKERNELAPI VOID NTAPI IoFreeErrorLogEntry( - PVOID ElEntry); + PVOID ElEntry); NTKERNELAPI NTSTATUS NTAPI IoSetCompletionRoutineEx( - IN PDEVICE_OBJECT DeviceObject, - IN PIRP Irp, - IN PIO_COMPLETION_ROUTINE CompletionRoutine, - IN PVOID Context, - IN BOOLEAN InvokeOnSuccess, - IN BOOLEAN InvokeOnError, - IN BOOLEAN InvokeOnCancel); + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp, + IN PIO_COMPLETION_ROUTINE CompletionRoutine, + IN PVOID Context, + IN BOOLEAN InvokeOnSuccess, + IN BOOLEAN InvokeOnError, + IN BOOLEAN InvokeOnCancel); VOID NTAPI IoSetStartIoAttributes( - IN PDEVICE_OBJECT DeviceObject, - IN BOOLEAN DeferredStartIo, - IN BOOLEAN NonCancelable); + IN PDEVICE_OBJECT DeviceObject, + IN BOOLEAN DeferredStartIo, + IN BOOLEAN NonCancelable); NTKERNELAPI NTSTATUS NTAPI IoWMIDeviceObjectToInstanceName( - IN PVOID DataBlockObject, - IN PDEVICE_OBJECT DeviceObject, - OUT PUNICODE_STRING InstanceName); + IN PVOID DataBlockObject, + IN PDEVICE_OBJECT DeviceObject, + OUT PUNICODE_STRING InstanceName); NTKERNELAPI NTSTATUS NTAPI IoWMIExecuteMethod( - IN PVOID DataBlockObject, - IN PUNICODE_STRING InstanceName, - IN ULONG MethodId, - IN ULONG InBufferSize, - IN OUT PULONG OutBufferSize, - IN OUT PUCHAR InOutBuffer); + IN PVOID DataBlockObject, + IN PUNICODE_STRING InstanceName, + IN ULONG MethodId, + IN ULONG InBufferSize, + IN OUT PULONG OutBufferSize, + IN OUT PUCHAR InOutBuffer); NTKERNELAPI NTSTATUS NTAPI IoWMIHandleToInstanceName( - IN PVOID DataBlockObject, - IN HANDLE FileHandle, - OUT PUNICODE_STRING InstanceName); + IN PVOID DataBlockObject, + IN HANDLE FileHandle, + OUT PUNICODE_STRING InstanceName); NTKERNELAPI NTSTATUS NTAPI IoWMIOpenBlock( - IN GUID *DataBlockGuid, - IN ULONG DesiredAccess, - OUT PVOID *DataBlockObject); + IN GUID *DataBlockGuid, + IN ULONG DesiredAccess, + OUT PVOID *DataBlockObject); NTKERNELAPI NTSTATUS NTAPI IoWMIQueryAllData( - IN PVOID DataBlockObject, - IN OUT ULONG *InOutBufferSize, - OUT PVOID OutBuffer); + IN PVOID DataBlockObject, + IN OUT ULONG *InOutBufferSize, + OUT PVOID OutBuffer); NTKERNELAPI NTSTATUS NTAPI IoWMIQueryAllDataMultiple( - IN PVOID *DataBlockObjectList, - IN ULONG ObjectCount, - IN OUT ULONG *InOutBufferSize, - OUT PVOID OutBuffer); + IN PVOID *DataBlockObjectList, + IN ULONG ObjectCount, + IN OUT ULONG *InOutBufferSize, + OUT PVOID OutBuffer); NTKERNELAPI NTSTATUS NTAPI IoWMIQuerySingleInstance( - IN PVOID DataBlockObject, - IN PUNICODE_STRING InstanceName, - IN OUT ULONG *InOutBufferSize, + IN PVOID DataBlockObject, + IN PUNICODE_STRING InstanceName, + IN OUT ULONG *InOutBufferSize, OUT PVOID OutBuffer); NTKERNELAPI NTSTATUS NTAPI IoWMISetNotificationCallback( - IN OUT PVOID Object, - IN WMI_NOTIFICATION_CALLBACK Callback, - IN PVOID Context OPTIONAL); + IN OUT PVOID Object, + IN WMI_NOTIFICATION_CALLBACK Callback, + IN PVOID Context OPTIONAL); NTKERNELAPI NTSTATUS NTAPI IoWMISetSingleInstance( - IN PVOID DataBlockObject, - IN PUNICODE_STRING InstanceName, - IN ULONG Version, - IN ULONG ValueBufferSize, - IN PVOID ValueBuffer); + IN PVOID DataBlockObject, + IN PUNICODE_STRING InstanceName, + IN ULONG Version, + IN ULONG ValueBufferSize, + IN PVOID ValueBuffer); NTKERNELAPI NTSTATUS NTAPI IoWMISetSingleItem( - IN PVOID DataBlockObject, - IN PUNICODE_STRING InstanceName, - IN ULONG DataItemId, - IN ULONG Version, - IN ULONG ValueBufferSize, - IN PVOID ValueBuffer); + IN PVOID DataBlockObject, + IN PUNICODE_STRING InstanceName, + IN ULONG DataItemId, + IN ULONG Version, + IN ULONG ValueBufferSize, + IN PVOID ValueBuffer); +#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ +#if (NTDDI_VERSION >= NTDDI_WINXPSP1) +NTKERNELAPI +NTSTATUS +NTAPI +IoValidateDeviceIoControlAccess( + IN PIRP Irp, + IN ULONG RequiredAccess); #endif +#if (NTDDI_VERSION >= NTDDI_WS03) + +NTKERNELAPI +NTSTATUS +NTAPI +IoCsqInitializeEx( + IN PIO_CSQ Csq, + IN PIO_CSQ_INSERT_IRP_EX CsqInsertIrp, + IN PIO_CSQ_REMOVE_IRP CsqRemoveIrp, + IN PIO_CSQ_PEEK_NEXT_IRP CsqPeekNextIrp, + IN PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock, + IN PIO_CSQ_RELEASE_LOCK CsqReleaseLock, + IN PIO_CSQ_COMPLETE_CANCELED_IRP CsqCompleteCanceledIrp); + +NTKERNELAPI +NTSTATUS +NTAPI +IoCsqInsertIrpEx( + IN PIO_CSQ Csq, + IN PIRP Irp, + IN PIO_CSQ_IRP_CONTEXT Context OPTIONAL, + IN PVOID InsertContext OPTIONAL); +#endif /* (NTDDI_VERSION >= NTDDI_WS03) */ + + +#if (NTDDI_VERSION >= NTDDI_VISTA) + +NTKERNELAPI +NTSTATUS +NTAPI +IoGetBootDiskInformationLite( + OUT PBOOTDISK_INFORMATION_LITE *BootDiskInformation); + +NTKERNELAPI +NTSTATUS +NTAPI +IoCheckShareAccessEx( + IN ACCESS_MASK DesiredAccess, + IN ULONG DesiredShareAccess, + IN OUT PFILE_OBJECT FileObject, + IN OUT PSHARE_ACCESS ShareAccess, + IN BOOLEAN Update, + IN PBOOLEAN WritePermission); + +NTKERNELAPI +NTSTATUS +NTAPI +IoConnectInterruptEx( + IN OUT PIO_CONNECT_INTERRUPT_PARAMETERS Parameters); + +NTKERNELAPI +VOID +NTAPI +IoDisconnectInterruptEx( + IN PIO_DISCONNECT_INTERRUPT_PARAMETERS Parameters); + +LOGICAL +NTAPI +IoWithinStackLimits( + IN ULONG_PTR RegionStart, + IN SIZE_T RegionSize); + +NTKERNELAPI +VOID +NTAPI +IoSetShareAccessEx( + IN ACCESS_MASK DesiredAccess, + IN ULONG DesiredShareAccess, + IN OUT PFILE_OBJECT FileObject, + OUT PSHARE_ACCESS ShareAccess, + IN PBOOLEAN WritePermission); + +ULONG +NTAPI +IoSizeofWorkItem(VOID); + +VOID +NTAPI +IoInitializeWorkItem( + IN PVOID IoObject, + IN PIO_WORKITEM IoWorkItem); + +VOID +NTAPI +IoUninitializeWorkItem( + IN PIO_WORKITEM IoWorkItem); + +VOID +NTAPI +IoQueueWorkItemEx( + IN PIO_WORKITEM IoWorkItem, + IN PIO_WORKITEM_ROUTINE_EX WorkerRoutine, + IN WORK_QUEUE_TYPE QueueType, + IN PVOID Context OPTIONAL); + +IO_PRIORITY_HINT +NTAPI +IoGetIoPriorityHint( + IN PIRP Irp); + +NTSTATUS +NTAPI +IoSetIoPriorityHint( + IN PIRP Irp, + IN IO_PRIORITY_HINT PriorityHint); + +NTSTATUS +NTAPI +IoAllocateSfioStreamIdentifier( + IN PFILE_OBJECT FileObject, + IN ULONG Length, + IN PVOID Signature, + OUT PVOID *StreamIdentifier); + +PVOID +NTAPI +IoGetSfioStreamIdentifier( + IN PFILE_OBJECT FileObject, + IN PVOID Signature); + +NTSTATUS +NTAPI +IoFreeSfioStreamIdentifier( + IN PFILE_OBJECT FileObject, + IN PVOID Signature); + +NTKERNELAPI +NTSTATUS +NTAPI +IoRequestDeviceEjectEx( + IN PDEVICE_OBJECT PhysicalDeviceObject, + IN PIO_DEVICE_EJECT_CALLBACK Callback OPTIONAL, + IN PVOID Context OPTIONAL, + IN PDRIVER_OBJECT DriverObject OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +IoSetDevicePropertyData( + IN PDEVICE_OBJECT Pdo, + IN CONST DEVPROPKEY *PropertyKey, + IN LCID Lcid, + IN ULONG Flags, + IN DEVPROPTYPE Type, + IN ULONG Size, + IN PVOID Data OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +IoGetDevicePropertyData( + PDEVICE_OBJECT Pdo, + CONST DEVPROPKEY *PropertyKey, + LCID Lcid, + ULONG Flags, + ULONG Size, + PVOID Data, + PULONG RequiredSize, + PDEVPROPTYPE Type); + +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + +#define IoCallDriverStackSafeDefault(a, b) IoCallDriver(a, b) + +#if (NTDDI_VERSION >= NTDDI_WS08) +NTKERNELAPI +NTSTATUS +NTAPI +IoReplacePartitionUnit( + IN PDEVICE_OBJECT TargetPdo, + IN PDEVICE_OBJECT SparePdo, + IN ULONG Flags); +#endif + +#if (NTDDI_VERSION >= NTDDI_WIN7) + +NTKERNELAPI +NTSTATUS +NTAPI +IoGetAffinityInterrupt( + IN PKINTERRUPT InterruptObject, + OUT PGROUP_AFFINITY GroupAffinity); + +NTSTATUS +NTAPI +IoGetContainerInformation( + IN IO_CONTAINER_INFORMATION_CLASS InformationClass, + IN PVOID ContainerObject OPTIONAL, + IN OUT PVOID Buffer OPTIONAL, + IN ULONG BufferLength); + +NTSTATUS +NTAPI +IoRegisterContainerNotification( + IN IO_CONTAINER_NOTIFICATION_CLASS NotificationClass, + IN PIO_CONTAINER_NOTIFICATION_FUNCTION CallbackFunction, + IN PVOID NotificationInformation OPTIONAL, + IN ULONG NotificationInformationLength, + OUT PVOID CallbackRegistration); + +VOID +NTAPI +IoUnregisterContainerNotification( + IN PVOID CallbackRegistration); + +NTKERNELAPI +NTSTATUS +NTAPI +IoUnregisterPlugPlayNotificationEx( + IN PVOID NotificationEntry); + +NTKERNELAPI +NTSTATUS +NTAPI +IoGetDeviceNumaNode( + IN PDEVICE_OBJECT Pdo, + OUT PUSHORT NodeNumber); + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + #if defined(_WIN64) NTKERNELAPI ULONG @@ -9526,7 +12762,7 @@ IoWMIDeviceObjectToProviderId( FORCEINLINE VOID -IoSkipCurrentIrpStackLocation ( +IoSkipCurrentIrpStackLocation( IN OUT PIRP Irp) { ASSERT(Irp->CurrentLocation <= Irp->StackCount); @@ -9536,7 +12772,7 @@ IoSkipCurrentIrpStackLocation ( FORCEINLINE VOID -IoSetNextIrpStackLocation ( +IoSetNextIrpStackLocation( IN OUT PIRP Irp) { ASSERT(Irp->CurrentLocation > 0); @@ -9625,12 +12861,10 @@ IoSetCompletionRoutine( IoReleaseRemoveLockAndWaitEx(_RemoveLock, _Tag, sizeof(IO_REMOVE_LOCK)) #if defined(_WIN64) - NTKERNELAPI BOOLEAN IoIs32bitProcess( - IN PIRP Irp OPTIONAL); - + IN PIRP Irp OPTIONAL); #endif #define PLUGPLAY_REGKEY_DEVICE 1 @@ -9704,7 +12938,7 @@ IoInitializeDpcRequest( FORCEINLINE VOID IoCopyCurrentIrpStackLocationToNext( - IN PIRP Irp) + IN OUT PIRP Irp) { PIO_STACK_LOCATION irpSp; PIO_STACK_LOCATION nextIrpSp; @@ -9718,13 +12952,12 @@ NTKERNELAPI VOID NTAPI IoGetStackLimits( - OUT PULONG_PTR LowLimit, - OUT PULONG_PTR HighLimit); + OUT PULONG_PTR LowLimit, + OUT PULONG_PTR HighLimit); FORCEINLINE ULONG_PTR -IoGetRemainingStackSize( - VOID) +IoGetRemainingStackSize(VOID) { ULONG_PTR End, Begin; ULONG_PTR Result; @@ -9734,6 +12967,19 @@ IoGetRemainingStackSize( return Result; } +#if (NTDDI_VERSION >= NTDDI_WS03) +VOID +FORCEINLINE +IoInitializeThreadedDpcRequest( + IN PDEVICE_OBJECT DeviceObject, + IN PIO_DPC_ROUTINE DpcRoutine) +{ + KeInitializeThreadedDpc(&DeviceObject->Dpc, + (PKDEFERRED_ROUTINE) DpcRoutine, + DeviceObject ); +} +#endif + /****************************************************************************** * Power Management Support Functions * ******************************************************************************/ @@ -9746,17 +12992,17 @@ NTKERNELAPI NTSTATUS NTAPI PoCallDriver( - IN struct _DEVICE_OBJECT *DeviceObject, - IN OUT struct _IRP *Irp); + IN struct _DEVICE_OBJECT *DeviceObject, + IN OUT struct _IRP *Irp); NTKERNELAPI PULONG NTAPI PoRegisterDeviceForIdleDetection( - IN struct _DEVICE_OBJECT *DeviceObject, - IN ULONG ConservationIdleTime, - IN ULONG PerformanceIdleTime, - IN DEVICE_POWER_STATE State); + IN struct _DEVICE_OBJECT *DeviceObject, + IN ULONG ConservationIdleTime, + IN ULONG PerformanceIdleTime, + IN DEVICE_POWER_STATE State); NTKERNELAPI PVOID @@ -9769,26 +13015,26 @@ NTKERNELAPI NTSTATUS NTAPI PoRequestPowerIrp( - IN struct _DEVICE_OBJECT *DeviceObject, - IN UCHAR MinorFunction, - IN POWER_STATE PowerState, - IN PREQUEST_POWER_COMPLETE CompletionFunction OPTIONAL, - IN PVOID Context OPTIONAL, - OUT struct _IRP **Irp OPTIONAL); + IN struct _DEVICE_OBJECT *DeviceObject, + IN UCHAR MinorFunction, + IN POWER_STATE PowerState, + IN PREQUEST_POWER_COMPLETE CompletionFunction OPTIONAL, + IN PVOID Context OPTIONAL, + OUT struct _IRP **Irp OPTIONAL); NTKERNELAPI POWER_STATE NTAPI PoSetPowerState( - IN struct _DEVICE_OBJECT *DeviceObject, - IN POWER_STATE_TYPE Type, - IN POWER_STATE State); + IN struct _DEVICE_OBJECT *DeviceObject, + IN POWER_STATE_TYPE Type, + IN POWER_STATE State); NTKERNELAPI VOID NTAPI PoSetSystemState( - IN EXECUTION_STATE Flags); + IN EXECUTION_STATE Flags); NTKERNELAPI VOID @@ -9843,16 +13089,15 @@ PoUnregisterPowerSettingCallback( #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ #if (NTDDI_VERSION >= NTDDI_VISTASP1) - NTKERNELAPI VOID NTAPI PoSetDeviceBusyEx( IN OUT PULONG IdlePointer); - #endif /* (NTDDI_VERSION >= NTDDI_VISTASP1) */ #if (NTDDI_VERSION >= NTDDI_WIN7) + NTKERNELAPI VOID NTAPI @@ -9917,19 +13162,64 @@ PoCreatePowerRequest( #define ExInitializeSListHead InitializeSListHead -#if defined(_X86_) -#if defined(_NTHAL_) +#if defined(_NTHAL_) && defined(_X86_) + +NTKERNELAPI +VOID +FASTCALL +ExiAcquireFastMutex( + IN OUT PFAST_MUTEX FastMutex); + +NTKERNELAPI +VOID +FASTCALL +ExiReleaseFastMutex( + IN OUT PFAST_MUTEX FastMutex); + +NTKERNELAPI +BOOLEAN +FASTCALL +ExiTryToAcquireFastMutex( + IN OUT PFAST_MUTEX FastMutex); + #define ExAcquireFastMutex ExiAcquireFastMutex #define ExReleaseFastMutex ExiReleaseFastMutex #define ExTryToAcquireFastMutex ExiTryToAcquireFastMutex -#endif + +#else + +#if (NTDDI_VERSION >= NTDDI_WIN2K) + +NTKERNELAPI +VOID +FASTCALL +ExAcquireFastMutex( + IN OUT PFAST_MUTEX FastMutex); + +NTKERNELAPI +VOID +FASTCALL +ExReleaseFastMutex( + IN OUT PFAST_MUTEX FastMutex); + +NTKERNELAPI +BOOLEAN +FASTCALL +ExTryToAcquireFastMutex( + IN OUT PFAST_MUTEX FastMutex); + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ + +#endif /* defined(_NTHAL_) && defined(_X86_) */ + +#if defined(_X86_) #define ExInterlockedAddUlong ExfInterlockedAddUlong #define ExInterlockedInsertHeadList ExfInterlockedInsertHeadList #define ExInterlockedInsertTailList ExfInterlockedInsertTailList #define ExInterlockedRemoveHeadList ExfInterlockedRemoveHeadList #define ExInterlockedPopEntryList ExfInterlockedPopEntryList #define ExInterlockedPushEntryList ExfInterlockedPushEntryList -#endif +#endif /* defined(_X86_) */ #if defined(_WIN64) @@ -9943,25 +13233,25 @@ FORCEINLINE USHORT ExQueryDepthSList(IN PSLIST_HEADER ListHead) { - return (USHORT)(ListHead->Alignment & 0xffff); + return (USHORT)(ListHead->Alignment & 0xffff); } #endif NTKERNELAPI PSLIST_ENTRY ExpInterlockedFlushSList( - PSLIST_HEADER ListHead); + PSLIST_HEADER ListHead); NTKERNELAPI PSLIST_ENTRY ExpInterlockedPopEntrySList( - PSLIST_HEADER ListHead); + PSLIST_HEADER ListHead); NTKERNELAPI PSLIST_ENTRY ExpInterlockedPushEntrySList( - PSLIST_HEADER ListHead, - PSLIST_ENTRY ListEntry); + PSLIST_HEADER ListHead, + PSLIST_ENTRY ListEntry); #define ExInterlockedFlushSList(Head) \ ExpInterlockedFlushSList(Head) @@ -9970,7 +13260,7 @@ ExpInterlockedPushEntrySList( #define ExInterlockedPushEntrySList(Head, Entry, Lock) \ ExpInterlockedPushEntrySList(Head, Entry) -#else // !defined(_WIN64) +#else /* !defined(_WIN64) */ #define ExQueryDepthSList(listhead) (listhead)->Depth @@ -9978,37 +13268,87 @@ NTKERNELAPI PSINGLE_LIST_ENTRY FASTCALL ExInterlockedFlushSList( - IN PSLIST_HEADER ListHead); + IN OUT PSLIST_HEADER ListHead); #if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_) + NTKERNELAPI PSINGLE_LIST_ENTRY FASTCALL ExInterlockedPopEntrySList( - IN PSLIST_HEADER ListHead, - IN PKSPIN_LOCK Lock); + IN PSLIST_HEADER ListHead, + IN PKSPIN_LOCK Lock); NTKERNELAPI PSINGLE_LIST_ENTRY FASTCALL ExInterlockedPushEntrySList( - IN PSLIST_HEADER ListHead, - IN PSINGLE_LIST_ENTRY ListEntry, - IN PKSPIN_LOCK Lock); + IN PSLIST_HEADER ListHead, + IN PSINGLE_LIST_ENTRY ListEntry, + IN PKSPIN_LOCK Lock); + +NTKERNELAPI +PVOID +NTAPI +ExAllocateFromPagedLookasideList( + IN OUT PPAGED_LOOKASIDE_LIST Lookaside); + +NTKERNELAPI +VOID +NTAPI +ExFreeToPagedLookasideList( + IN OUT PPAGED_LOOKASIDE_LIST Lookaside, + IN PVOID Entry); + #else + #define ExInterlockedPopEntrySList(_ListHead, _Lock) \ InterlockedPopEntrySList(_ListHead) #define ExInterlockedPushEntrySList(_ListHead, _ListEntry, _Lock) \ InterlockedPushEntrySList(_ListHead, _ListEntry) -#endif // _WIN2K_COMPAT_SLIST_USAGE -#endif // !defined(_WIN64) +static __inline +PVOID +ExAllocateFromPagedLookasideList( + IN OUT PPAGED_LOOKASIDE_LIST Lookaside) +{ + PVOID Entry; + + Lookaside->L.TotalAllocates++; + Entry = InterlockedPopEntrySList(&Lookaside->L.ListHead); + if (Entry == NULL) { + Lookaside->L.AllocateMisses++; + Entry = (Lookaside->L.Allocate)(Lookaside->L.Type, + Lookaside->L.Size, + Lookaside->L.Tag); + } + return Entry; +} + +static __inline +VOID +ExFreeToPagedLookasideList( + IN OUT PPAGED_LOOKASIDE_LIST Lookaside, + IN PVOID Entry) +{ + Lookaside->L.TotalFrees++; + if (ExQueryDepthSList(&Lookaside->L.ListHead) >= Lookaside->L.Depth) { + Lookaside->L.FreeMisses++; + (Lookaside->L.Free)(Entry); + } else { + InterlockedPushEntrySList(&Lookaside->L.ListHead, (PSLIST_ENTRY)Entry); + } +} + +#endif /* _WIN2K_COMPAT_SLIST_USAGE */ + +#endif /* !defined(_WIN64) */ /* ERESOURCE_THREAD * ExGetCurrentResourceThread( * VOID); */ -#define ExGetCurrentResourceThread() ((ERESOURCE_THREAD)PsGetCurrentThread()) +#define ExGetCurrentResourceThread() ((ULONG_PTR)PsGetCurrentThread()) #define ExReleaseResource(R) (ExReleaseResourceLite(R)) @@ -10039,220 +13379,193 @@ ExInitializeFastMutex( #if (NTDDI_VERSION >= NTDDI_WIN2K) -NTKERNELAPI -VOID -FASTCALL -ExAcquireFastMutex( - IN OUT PFAST_MUTEX FastMutex); - -NTKERNELAPI -VOID -FASTCALL -ExReleaseFastMutex( - IN OUT PFAST_MUTEX FastMutex); - -NTKERNELAPI -BOOLEAN -FASTCALL -ExTryToAcquireFastMutex( - IN OUT PFAST_MUTEX FastMutex); - NTKERNELAPI VOID FASTCALL ExAcquireFastMutexUnsafe( - IN OUT PFAST_MUTEX FastMutex); + IN OUT PFAST_MUTEX FastMutex); NTKERNELAPI VOID FASTCALL ExReleaseFastMutexUnsafe( - IN OUT PFAST_MUTEX FastMutex); + IN OUT PFAST_MUTEX FastMutex); NTKERNELAPI BOOLEAN NTAPI ExAcquireResourceExclusiveLite( - IN PERESOURCE Resource, - IN BOOLEAN Wait); + IN OUT PERESOURCE Resource, + IN BOOLEAN Wait); NTKERNELAPI BOOLEAN NTAPI ExAcquireResourceSharedLite( - IN PERESOURCE Resource, - IN BOOLEAN Wait); + IN OUT PERESOURCE Resource, + IN BOOLEAN Wait); NTKERNELAPI BOOLEAN NTAPI ExAcquireSharedStarveExclusive( - IN PERESOURCE Resource, - IN BOOLEAN Wait); + IN OUT PERESOURCE Resource, + IN BOOLEAN Wait); NTKERNELAPI BOOLEAN NTAPI ExAcquireSharedWaitForExclusive( - IN PERESOURCE Resource, - IN BOOLEAN Wait); + IN OUT PERESOURCE Resource, + IN BOOLEAN Wait); NTKERNELAPI PVOID NTAPI ExAllocatePool( - IN POOL_TYPE PoolType, - IN SIZE_T NumberOfBytes); - -#ifdef POOL_TAGGING -#define ExAllocatePool(p,n) ExAllocatePoolWithTag(p,n,' kdD') -#endif /* POOL_TAGGING */ + IN POOL_TYPE PoolType, + IN SIZE_T NumberOfBytes); NTKERNELAPI PVOID NTAPI ExAllocatePoolWithQuota( - IN POOL_TYPE PoolType, - IN SIZE_T NumberOfBytes); - -#ifdef POOL_TAGGING -#define ExAllocatePoolWithQuota(p,n) ExAllocatePoolWithQuotaTag(p,n,' kdD') -#endif /* POOL_TAGGING */ + IN POOL_TYPE PoolType, + IN SIZE_T NumberOfBytes); NTKERNELAPI PVOID NTAPI ExAllocatePoolWithQuotaTag( - IN POOL_TYPE PoolType, - IN SIZE_T NumberOfBytes, - IN ULONG Tag); + IN POOL_TYPE PoolType, + IN SIZE_T NumberOfBytes, + IN ULONG Tag); #ifndef POOL_TAGGING #define ExAllocatePoolWithQuotaTag(a,b,c) ExAllocatePoolWithQuota(a,b) -#endif /* POOL_TAGGING */ +#endif NTKERNELAPI PVOID NTAPI ExAllocatePoolWithTag( - IN POOL_TYPE PoolType, - IN SIZE_T NumberOfBytes, - IN ULONG Tag); + IN POOL_TYPE PoolType, + IN SIZE_T NumberOfBytes, + IN ULONG Tag); + +#ifndef POOL_TAGGING +#define ExAllocatePoolWithTag(a,b,c) ExAllocatePool(a,b) +#endif NTKERNELAPI PVOID NTAPI ExAllocatePoolWithTagPriority( - IN POOL_TYPE PoolType, - IN SIZE_T NumberOfBytes, - IN ULONG Tag, - IN EX_POOL_PRIORITY Priority); + IN POOL_TYPE PoolType, + IN SIZE_T NumberOfBytes, + IN ULONG Tag, + IN EX_POOL_PRIORITY Priority); NTKERNELAPI VOID NTAPI ExConvertExclusiveToSharedLite( - IN PERESOURCE Resource); + IN OUT PERESOURCE Resource); NTKERNELAPI NTSTATUS NTAPI ExCreateCallback( - OUT PCALLBACK_OBJECT *CallbackObject, - IN POBJECT_ATTRIBUTES ObjectAttributes, - IN BOOLEAN Create, - IN BOOLEAN AllowMultipleCallbacks); + OUT PCALLBACK_OBJECT *CallbackObject, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN BOOLEAN Create, + IN BOOLEAN AllowMultipleCallbacks); NTKERNELAPI VOID NTAPI ExDeleteNPagedLookasideList( - IN PNPAGED_LOOKASIDE_LIST Lookaside); + IN OUT PNPAGED_LOOKASIDE_LIST Lookaside); NTKERNELAPI VOID NTAPI ExDeletePagedLookasideList( - IN PPAGED_LOOKASIDE_LIST Lookaside); + IN PPAGED_LOOKASIDE_LIST Lookaside); NTKERNELAPI NTSTATUS NTAPI ExDeleteResourceLite( - IN PERESOURCE Resource); + IN OUT PERESOURCE Resource); NTKERNELAPI VOID NTAPI ExFreePool( - IN PVOID P); - -#ifdef POOL_TAGGING -#define ExFreePool(P) ExFreePoolWithTag(P, 0) -#endif + IN PVOID P); NTKERNELAPI VOID NTAPI ExFreePoolWithTag( - IN PVOID P, - IN ULONG Tag); + IN PVOID P, + IN ULONG Tag); NTKERNELAPI ULONG NTAPI ExGetExclusiveWaiterCount( - IN PERESOURCE Resource); + IN PERESOURCE Resource); NTKERNELAPI KPROCESSOR_MODE NTAPI -ExGetPreviousMode( - VOID); +ExGetPreviousMode(VOID); NTKERNELAPI ULONG NTAPI ExGetSharedWaiterCount( - IN PERESOURCE Resource); + IN PERESOURCE Resource); NTKERNELAPI VOID NTAPI ExInitializeNPagedLookasideList( - IN PNPAGED_LOOKASIDE_LIST Lookaside, - IN PALLOCATE_FUNCTION Allocate OPTIONAL, - IN PFREE_FUNCTION Free OPTIONAL, - IN ULONG Flags, - IN SIZE_T Size, - IN ULONG Tag, - IN USHORT Depth); + IN PNPAGED_LOOKASIDE_LIST Lookaside, + IN PALLOCATE_FUNCTION Allocate OPTIONAL, + IN PFREE_FUNCTION Free OPTIONAL, + IN ULONG Flags, + IN SIZE_T Size, + IN ULONG Tag, + IN USHORT Depth); NTKERNELAPI VOID NTAPI ExInitializePagedLookasideList( - IN PPAGED_LOOKASIDE_LIST Lookaside, - IN PALLOCATE_FUNCTION Allocate OPTIONAL, - IN PFREE_FUNCTION Free OPTIONAL, - IN ULONG Flags, - IN SIZE_T Size, - IN ULONG Tag, - IN USHORT Depth); + IN PPAGED_LOOKASIDE_LIST Lookaside, + IN PALLOCATE_FUNCTION Allocate OPTIONAL, + IN PFREE_FUNCTION Free OPTIONAL, + IN ULONG Flags, + IN SIZE_T Size, + IN ULONG Tag, + IN USHORT Depth); NTKERNELAPI NTSTATUS NTAPI ExInitializeResourceLite( - IN PERESOURCE Resource); + OUT PERESOURCE Resource); NTKERNELAPI LARGE_INTEGER NTAPI ExInterlockedAddLargeInteger( - IN PLARGE_INTEGER Addend, - IN LARGE_INTEGER Increment, - IN PKSPIN_LOCK Lock); + IN PLARGE_INTEGER Addend, + IN LARGE_INTEGER Increment, + IN PKSPIN_LOCK Lock); #if defined(_WIN64) #define ExInterlockedAddLargeStatistic(Addend, Increment) \ @@ -10266,89 +13579,96 @@ NTKERNELAPI ULONG FASTCALL ExInterlockedAddUlong( - IN PULONG Addend, - IN ULONG Increment, - PKSPIN_LOCK Lock); + IN PULONG Addend, + IN ULONG Increment, + IN OUT PKSPIN_LOCK Lock); #if defined(_AMD64_) || defined(_IA64_) + #define ExInterlockedCompareExchange64(Destination, Exchange, Comperand, Lock) \ InterlockedCompareExchange64(Destination, *(Exchange), *(Comperand)) + #elif defined(_X86_) + NTKERNELAPI LONGLONG FASTCALL ExfInterlockedCompareExchange64( - IN OUT LONGLONG volatile *Destination, - IN PLONGLONG Exchange, - IN PLONGLONG Comperand); + IN OUT LONGLONG volatile *Destination, + IN PLONGLONG Exchange, + IN PLONGLONG Comperand); + #define ExInterlockedCompareExchange64(Destination, Exchange, Comperand, Lock) \ ExfInterlockedCompareExchange64(Destination, Exchange, Comperand) + #else + NTKERNELAPI LONGLONG FASTCALL ExInterlockedCompareExchange64( - IN OUT LONGLONG volatile *Destination, - IN PLONGLONG Exchange, - IN PLONGLONG Comparand, - IN PKSPIN_LOCK Lock); -#endif + IN OUT LONGLONG volatile *Destination, + IN PLONGLONG Exchange, + IN PLONGLONG Comparand, + IN PKSPIN_LOCK Lock); + +#endif /* defined(_AMD64_) || defined(_IA64_) */ NTKERNELAPI PLIST_ENTRY FASTCALL ExInterlockedInsertHeadList( - IN PLIST_ENTRY ListHead, - IN PLIST_ENTRY ListEntry, - IN PKSPIN_LOCK Lock); + IN OUT PLIST_ENTRY ListHead, + IN OUT PLIST_ENTRY ListEntry, + IN OUT PKSPIN_LOCK Lock); NTKERNELAPI PLIST_ENTRY FASTCALL ExInterlockedInsertTailList( - IN PLIST_ENTRY ListHead, - IN PLIST_ENTRY ListEntry, - IN PKSPIN_LOCK Lock); + IN OUT PLIST_ENTRY ListHead, + IN OUT PLIST_ENTRY ListEntry, + IN OUT PKSPIN_LOCK Lock); NTKERNELAPI PSINGLE_LIST_ENTRY FASTCALL ExInterlockedPopEntryList( - IN PSINGLE_LIST_ENTRY ListHead, - IN PKSPIN_LOCK Lock); + IN OUT PSINGLE_LIST_ENTRY ListHead, + IN OUT PKSPIN_LOCK Lock); NTKERNELAPI PSINGLE_LIST_ENTRY FASTCALL ExInterlockedPushEntryList( - IN PSINGLE_LIST_ENTRY ListHead, - IN PSINGLE_LIST_ENTRY ListEntry, - IN PKSPIN_LOCK Lock); + IN OUT PSINGLE_LIST_ENTRY ListHead, + IN OUT PSINGLE_LIST_ENTRY ListEntry, + IN OUT PKSPIN_LOCK Lock); NTKERNELAPI PLIST_ENTRY FASTCALL ExInterlockedRemoveHeadList( - IN PLIST_ENTRY ListHead, - IN PKSPIN_LOCK Lock); + IN OUT PLIST_ENTRY ListHead, + IN OUT PKSPIN_LOCK Lock); NTKERNELAPI BOOLEAN NTAPI ExIsProcessorFeaturePresent( - IN ULONG ProcessorFeature); + IN ULONG ProcessorFeature); NTKERNELAPI BOOLEAN NTAPI ExIsResourceAcquiredExclusiveLite( - IN PERESOURCE Resource); + IN PERESOURCE Resource); NTKERNELAPI ULONG NTAPI ExIsResourceAcquiredSharedLite( - IN PERESOURCE Resource); + IN PERESOURCE Resource); #define ExIsResourceAcquiredLite ExIsResourceAcquiredSharedLite @@ -10356,243 +13676,368 @@ NTKERNELAPI VOID NTAPI ExLocalTimeToSystemTime( - IN PLARGE_INTEGER LocalTime, - OUT PLARGE_INTEGER SystemTime); + IN PLARGE_INTEGER LocalTime, + OUT PLARGE_INTEGER SystemTime); NTKERNELAPI VOID NTAPI ExNotifyCallback( - IN PCALLBACK_OBJECT CallbackObject, - IN PVOID Argument1, - IN PVOID Argument2); + IN PCALLBACK_OBJECT CallbackObject, + IN PVOID Argument1 OPTIONAL, + IN PVOID Argument2 OPTIONAL); NTKERNELAPI VOID NTAPI ExQueueWorkItem( - IN PWORK_QUEUE_ITEM WorkItem, - IN WORK_QUEUE_TYPE QueueType); + IN OUT PWORK_QUEUE_ITEM WorkItem, + IN WORK_QUEUE_TYPE QueueType); NTKERNELAPI DECLSPEC_NORETURN VOID NTAPI ExRaiseStatus( - IN NTSTATUS Status); + IN NTSTATUS Status); NTKERNELAPI PVOID NTAPI ExRegisterCallback( - IN PCALLBACK_OBJECT CallbackObject, - IN PCALLBACK_FUNCTION CallbackFunction, - IN PVOID CallbackContext); + IN PCALLBACK_OBJECT CallbackObject, + IN PCALLBACK_FUNCTION CallbackFunction, + IN PVOID CallbackContext OPTIONAL); NTKERNELAPI NTSTATUS NTAPI ExReinitializeResourceLite( - IN PERESOURCE Resource); + IN OUT PERESOURCE Resource); NTKERNELAPI VOID NTAPI ExReleaseResourceForThreadLite( - IN PERESOURCE Resource, - IN ERESOURCE_THREAD ResourceThreadId); + IN OUT PERESOURCE Resource, + IN ERESOURCE_THREAD ResourceThreadId); NTKERNELAPI VOID FASTCALL ExReleaseResourceLite( - IN PERESOURCE Resource); + IN OUT PERESOURCE Resource); NTKERNELAPI VOID NTAPI ExSetResourceOwnerPointer( - IN PERESOURCE Resource, - IN PVOID OwnerPointer); + IN OUT PERESOURCE Resource, + IN PVOID OwnerPointer); NTKERNELAPI ULONG NTAPI ExSetTimerResolution( - IN ULONG DesiredTime, - IN BOOLEAN SetResolution); + IN ULONG DesiredTime, + IN BOOLEAN SetResolution); NTKERNELAPI VOID NTAPI ExSystemTimeToLocalTime( - IN PLARGE_INTEGER SystemTime, - OUT PLARGE_INTEGER LocalTime); + IN PLARGE_INTEGER SystemTime, + OUT PLARGE_INTEGER LocalTime); NTKERNELAPI VOID NTAPI ExUnregisterCallback( - IN PVOID CbRegistration); + IN OUT PVOID CbRegistration); - -#endif // (NTDDI_VERSION >= NTDDI_WIN2K) +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ #if (NTDDI_VERSION >= NTDDI_WINXP) + NTKERNELAPI BOOLEAN FASTCALL ExAcquireRundownProtection( - IN OUT PEX_RUNDOWN_REF RunRef); + IN OUT PEX_RUNDOWN_REF RunRef); NTKERNELAPI VOID FASTCALL ExInitializeRundownProtection( - OUT PEX_RUNDOWN_REF RunRef); + OUT PEX_RUNDOWN_REF RunRef); NTKERNELAPI VOID FASTCALL ExReInitializeRundownProtection( - OUT PEX_RUNDOWN_REF RunRef); + IN OUT PEX_RUNDOWN_REF RunRef); NTKERNELAPI VOID FASTCALL ExReleaseRundownProtection( - IN OUT PEX_RUNDOWN_REF RunRef); + IN OUT PEX_RUNDOWN_REF RunRef); NTKERNELAPI VOID FASTCALL ExRundownCompleted( - OUT PEX_RUNDOWN_REF RunRef); + OUT PEX_RUNDOWN_REF RunRef); NTKERNELAPI BOOLEAN NTAPI ExVerifySuite( - IN SUITE_TYPE SuiteType); + IN SUITE_TYPE SuiteType); NTKERNELAPI VOID FASTCALL ExWaitForRundownProtectionRelease( - IN OUT PEX_RUNDOWN_REF RunRef); + IN OUT PEX_RUNDOWN_REF RunRef); -#endif // (NTDDI_VERSION >= NTDDI_WINXP) +#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ #if (NTDDI_VERSION >= NTDDI_WINXPSP2) + NTKERNELAPI BOOLEAN FASTCALL ExAcquireRundownProtectionEx( - IN OUT PEX_RUNDOWN_REF RunRef, - IN ULONG Count); + IN OUT PEX_RUNDOWN_REF RunRef, + IN ULONG Count); NTKERNELAPI VOID FASTCALL ExReleaseRundownProtectionEx( - IN OUT PEX_RUNDOWN_REF RunRef, - IN ULONG Count); -#endif // (NTDDI_VERSION >= NTDDI_WINXPSP2) + IN OUT PEX_RUNDOWN_REF RunRef, + IN ULONG Count); + +#endif /* (NTDDI_VERSION >= NTDDI_WINXPSP2) */ #if (NTDDI_VERSION >= NTDDI_WS03SP1) + NTKERNELAPI PEX_RUNDOWN_REF_CACHE_AWARE NTAPI ExAllocateCacheAwareRundownProtection( - IN POOL_TYPE PoolType, - IN ULONG PoolTag); + IN POOL_TYPE PoolType, + IN ULONG PoolTag); NTKERNELAPI SIZE_T NTAPI ExSizeOfRundownProtectionCacheAware(VOID); -#endif // (NTDDI_VERSION >= NTDDI_WS03SP1) + +NTKERNELAPI +PVOID +NTAPI +ExEnterCriticalRegionAndAcquireResourceShared( + IN OUT PERESOURCE Resource); + +NTKERNELAPI +PVOID +NTAPI +ExEnterCriticalRegionAndAcquireResourceExclusive( + IN OUT PERESOURCE Resource); + +NTKERNELAPI +PVOID +NTAPI +ExEnterCriticalRegionAndAcquireSharedWaitForExclusive( + IN OUT PERESOURCE Resource); + +NTKERNELAPI +VOID +FASTCALL +ExReleaseResourceAndLeaveCriticalRegion( + IN OUT PERESOURCE Resource); + +NTKERNELAPI +VOID +NTAPI +ExInitializeRundownProtectionCacheAware( + OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware, + IN SIZE_T RunRefSize); + +NTKERNELAPI +VOID +NTAPI +ExFreeCacheAwareRundownProtection( + IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware); + +NTKERNELAPI +BOOLEAN +FASTCALL +ExAcquireRundownProtectionCacheAware( + IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware); + +NTKERNELAPI +VOID +FASTCALL +ExReleaseRundownProtectionCacheAware( + IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware); + +NTKERNELAPI +BOOLEAN +FASTCALL +ExAcquireRundownProtectionCacheAwareEx( + IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware, + IN ULONG Count); + +NTKERNELAPI +VOID +FASTCALL +ExReleaseRundownProtectionCacheAwareEx( + IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRef, + IN ULONG Count); + +NTKERNELAPI +VOID +FASTCALL +ExWaitForRundownProtectionReleaseCacheAware( + IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRef); + +NTKERNELAPI +VOID +FASTCALL +ExReInitializeRundownProtectionCacheAware( + IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware); + +NTKERNELAPI +VOID +FASTCALL +ExRundownCompletedCacheAware( + IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware); + +#endif /* (NTDDI_VERSION >= NTDDI_WS03SP1) */ #if (NTDDI_VERSION >= NTDDI_VISTA) + NTKERNELAPI NTSTATUS NTAPI ExInitializeLookasideListEx( - OUT PLOOKASIDE_LIST_EX Lookaside, - IN PALLOCATE_FUNCTION_EX Allocate OPTIONAL, - IN PFREE_FUNCTION_EX Free OPTIONAL, - IN POOL_TYPE PoolType, - IN ULONG Flags, - IN SIZE_T Size, - IN ULONG Tag, - IN USHORT Depth); -#endif + OUT PLOOKASIDE_LIST_EX Lookaside, + IN PALLOCATE_FUNCTION_EX Allocate OPTIONAL, + IN PFREE_FUNCTION_EX Free OPTIONAL, + IN POOL_TYPE PoolType, + IN ULONG Flags, + IN SIZE_T Size, + IN ULONG Tag, + IN USHORT Depth); -#if !defined(MIDL_PASS) +NTKERNELAPI +VOID +NTAPI +ExDeleteLookasideListEx( + IN OUT PLOOKASIDE_LIST_EX Lookaside); + +NTKERNELAPI +VOID +NTAPI +ExFlushLookasideListEx( + IN OUT PLOOKASIDE_LIST_EX Lookaside); + +FORCEINLINE +PVOID +ExAllocateFromLookasideListEx( + IN OUT PLOOKASIDE_LIST_EX Lookaside) +{ + PVOID Entry; + + Lookaside->L.TotalAllocates += 1; + Entry = InterlockedPopEntrySList(&Lookaside->L.ListHead); + if (Entry == NULL) { + Lookaside->L.AllocateMisses += 1; + Entry = (Lookaside->L.AllocateEx)(Lookaside->L.Type, + Lookaside->L.Size, + Lookaside->L.Tag, + Lookaside); + } + return Entry; +} + +FORCEINLINE +VOID +ExFreeToLookasideListEx( + IN OUT PLOOKASIDE_LIST_EX Lookaside, + IN PVOID Entry) +{ + Lookaside->L.TotalFrees += 1; + if (ExQueryDepthSList(&Lookaside->L.ListHead) >= Lookaside->L.Depth) { + Lookaside->L.FreeMisses += 1; + (Lookaside->L.FreeEx)(Entry, Lookaside); + } else { + InterlockedPushEntrySList(&Lookaside->L.ListHead, (PSLIST_ENTRY)Entry); + } + return; +} + +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + +#if (NTDDI_VERSION >= NTDDI_WIN7) + +NTKERNELAPI +VOID +NTAPI +ExSetResourceOwnerPointerEx( + IN OUT PERESOURCE Resource, + IN PVOID OwnerPointer, + IN ULONG Flags); + +#define FLAG_OWNER_POINTER_IS_THREAD 0x1 + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ static __inline PVOID ExAllocateFromNPagedLookasideList( - IN PNPAGED_LOOKASIDE_LIST Lookaside) + IN OUT PNPAGED_LOOKASIDE_LIST Lookaside) { - PVOID Entry; + PVOID Entry; - Lookaside->L.TotalAllocates++; - Entry = InterlockedPopEntrySList(&Lookaside->L.ListHead); - if (Entry == NULL) { - Lookaside->L.AllocateMisses++; - Entry = (Lookaside->L.Allocate)(Lookaside->L.Type, - Lookaside->L.Size, - Lookaside->L.Tag); - } - return Entry; -} - -static __inline PVOID -ExAllocateFromPagedLookasideList( - IN PPAGED_LOOKASIDE_LIST Lookaside) -{ - PVOID Entry; - - Lookaside->L.TotalAllocates++; - Entry = InterlockedPopEntrySList(&Lookaside->L.ListHead); - if (Entry == NULL) { - Lookaside->L.AllocateMisses++; - Entry = (Lookaside->L.Allocate)(Lookaside->L.Type, - Lookaside->L.Size, - Lookaside->L.Tag); - } - return Entry; + Lookaside->L.TotalAllocates++; +#if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_) + Entry = ExInterlockedPopEntrySList(&Lookaside->L.ListHead, + &Lookaside->Lock__ObsoleteButDoNotDelete); +#else + Entry = InterlockedPopEntrySList(&Lookaside->L.ListHead); +#endif + if (Entry == NULL) { + Lookaside->L.AllocateMisses++; + Entry = (Lookaside->L.Allocate)(Lookaside->L.Type, + Lookaside->L.Size, + Lookaside->L.Tag); + } + return Entry; } static __inline VOID ExFreeToNPagedLookasideList( - IN PNPAGED_LOOKASIDE_LIST Lookaside, - IN PVOID Entry) + IN OUT PNPAGED_LOOKASIDE_LIST Lookaside, + IN PVOID Entry) { - Lookaside->L.TotalFrees++; - if (ExQueryDepthSList(&Lookaside->L.ListHead) >= Lookaside->L.Depth) { - Lookaside->L.FreeMisses++; - (Lookaside->L.Free)(Entry); - } else { - InterlockedPushEntrySList(&Lookaside->L.ListHead, (PSLIST_ENTRY)Entry); - } + Lookaside->L.TotalFrees++; + if (ExQueryDepthSList(&Lookaside->L.ListHead) >= Lookaside->L.Depth) { + Lookaside->L.FreeMisses++; + (Lookaside->L.Free)(Entry); + } else { +#if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_) + ExInterlockedPushEntrySList(&Lookaside->L.ListHead, + (PSLIST_ENTRY)Entry, + &Lookaside->Lock__ObsoleteButDoNotDelete); +#else + InterlockedPushEntrySList(&Lookaside->L.ListHead, (PSLIST_ENTRY)Entry); +#endif + } } -static __inline VOID -ExFreeToPagedLookasideList( - IN PPAGED_LOOKASIDE_LIST Lookaside, - IN PVOID Entry) -{ - Lookaside->L.TotalFrees++; - if (ExQueryDepthSList(&Lookaside->L.ListHead) >= Lookaside->L.Depth) { - Lookaside->L.FreeMisses++; - (Lookaside->L.Free)(Entry); - } else { - InterlockedPushEntrySList(&Lookaside->L.ListHead, (PSLIST_ENTRY)Entry); - } -} - -#endif // !defined(MIDL_PASS) /****************************************************************************** * Object Manager Functions * @@ -10637,7 +14082,7 @@ NTKERNELAPI NTSTATUS NTAPI ObReferenceObjectByPointer( - IN PVOID Object, + IN PVOID Object, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType OPTIONAL, IN KPROCESSOR_MODE AccessMode); @@ -10651,10 +14096,99 @@ ObReleaseObjectSecurity( #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ +#if (NTDDI_VERSION >= NTDDI_VISTA) +NTKERNELAPI +VOID +NTAPI +ObDereferenceObjectDeferDelete( + IN PVOID Object); +#endif + +#if (NTDDI_VERSION >= NTDDI_VISTASP1) +NTKERNELAPI +NTSTATUS +NTAPI +ObRegisterCallbacks( + IN POB_CALLBACK_REGISTRATION CallbackRegistration, + OUT PVOID *RegistrationHandle); + +NTKERNELAPI +VOID +NTAPI +ObUnRegisterCallbacks( + IN PVOID RegistrationHandle); + +NTKERNELAPI +USHORT +NTAPI +ObGetFilterVersion(VOID); + +#endif /* (NTDDI_VERSION >= NTDDI_VISTASP1) */ + +#if (NTDDI_VERSION >= NTDDI_WIN7) + +NTKERNELAPI +NTSTATUS +NTAPI +ObReferenceObjectByHandleWithTag( + IN HANDLE Handle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_TYPE ObjectType OPTIONAL, + IN KPROCESSOR_MODE AccessMode, + IN ULONG Tag, + OUT PVOID *Object, + OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL); + +NTKERNELAPI +LONG_PTR +FASTCALL +ObfReferenceObjectWithTag( + IN PVOID Object, + IN ULONG Tag); + +NTKERNELAPI +NTSTATUS +NTAPI +ObReferenceObjectByPointerWithTag( + IN PVOID Object, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_TYPE ObjectType OPTIONAL, + IN KPROCESSOR_MODE AccessMode, + IN ULONG Tag); + +NTKERNELAPI +LONG_PTR +FASTCALL +ObfDereferenceObjectWithTag( + IN PVOID Object, + IN ULONG Tag); + +NTKERNELAPI +VOID +NTAPI +ObDereferenceObjectDeferDeleteWithTag( + IN PVOID Object, + IN ULONG Tag); + +#define ObDereferenceObject ObfDereferenceObject +#define ObReferenceObject ObfReferenceObject +#define ObDereferenceObjectWithTag ObfDereferenceObjectWithTag +#define ObReferenceObjectWithTag ObfReferenceObjectWithTag + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + + /****************************************************************************** * Process Manager Functions * ******************************************************************************/ +NTKERNELAPI +NTSTATUS +NTAPI +PsWrapApcWow64Thread( + IN OUT PVOID *ApcContext, + IN OUT PVOID *ApcRoutine); + /* * PEPROCESS * PsGetCurrentProcess(VOID) @@ -10662,19 +14196,16 @@ ObReleaseObjectSecurity( #define PsGetCurrentProcess IoGetCurrentProcess #if !defined(_PSGETCURRENTTHREAD_) - #define _PSGETCURRENTTHREAD_ - FORCEINLINE PETHREAD NTAPI -PsGetCurrentThread ( - VOID) +PsGetCurrentThread(VOID) { return (PETHREAD)KeGetCurrentThread(); } +#endif /* !_PSGETCURRENTTHREAD_ */ -#endif #if (NTDDI_VERSION >= NTDDI_WIN2K) @@ -10682,41 +14213,40 @@ NTKERNELAPI NTSTATUS NTAPI PsCreateSystemThread( - OUT PHANDLE ThreadHandle, - IN ULONG DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, - IN HANDLE ProcessHandle OPTIONAL, - OUT PCLIENT_ID ClientId OPTIONAL, - IN PKSTART_ROUTINE StartRoutine, - IN PVOID StartContext OPTIONAL); + OUT PHANDLE ThreadHandle, + IN ULONG DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, + IN HANDLE ProcessHandle OPTIONAL, + OUT PCLIENT_ID ClientId OPTIONAL, + IN PKSTART_ROUTINE StartRoutine, + IN PVOID StartContext OPTIONAL); NTKERNELAPI NTSTATUS NTAPI PsTerminateSystemThread( - IN NTSTATUS ExitStatus); + IN NTSTATUS ExitStatus); -#endif + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ /****************************************************************************** * WMI Library Support Functions * ******************************************************************************/ #ifdef RUN_WPP - #if (NTDDI_VERSION >= NTDDI_WINXP) NTKERNELAPI NTSTATUS -DDKCDECLAPI +__cdecl WmiTraceMessage( - IN TRACEHANDLE LoggerHandle, - IN ULONG MessageFlags, - IN LPGUID MessageGuid, - IN USHORT MessageNumber, + IN TRACEHANDLE LoggerHandle, + IN ULONG MessageFlags, + IN LPGUID MessageGuid, + IN USHORT MessageNumber, IN ...); #endif - -#endif +#endif /* RUN_WPP */ #if (NTDDI_VERSION >= NTDDI_WINXP) @@ -10724,82 +14254,167 @@ NTKERNELAPI NTSTATUS NTAPI WmiQueryTraceInformation( - IN TRACE_INFORMATION_CLASS TraceInformationClass, - OUT PVOID TraceInformation, - IN ULONG TraceInformationLength, - OUT PULONG RequiredLength OPTIONAL, - IN PVOID Buffer OPTIONAL); + IN TRACE_INFORMATION_CLASS TraceInformationClass, + OUT PVOID TraceInformation, + IN ULONG TraceInformationLength, + OUT PULONG RequiredLength OPTIONAL, + IN PVOID Buffer OPTIONAL); #if 0 /* FIXME: Get va_list from where? */ NTKERNELAPI NTSTATUS -DDKCDECLAPI +__cdecl WmiTraceMessageVa( - IN TRACEHANDLE LoggerHandle, - IN ULONG MessageFlags, - IN LPGUID MessageGuid, - IN USHORT MessageNumber, - IN va_list MessageArgList); + IN TRACEHANDLE LoggerHandle, + IN ULONG MessageFlags, + IN LPGUID MessageGuid, + IN USHORT MessageNumber, + IN va_list MessageArgList); #endif +#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ + +#ifndef TRACE_INFORMATION_CLASS_DEFINE + +#if (NTDDI_VERSION >= NTDDI_WINXP) +NTKERNELAPI +NTSTATUS +NTAPI +WmiQueryTraceInformation( + IN TRACE_INFORMATION_CLASS TraceInformationClass, + OUT PVOID TraceInformation, + IN ULONG TraceInformationLength, + OUT PULONG RequiredLength OPTIONAL, + IN PVOID Buffer OPTIONAL); #endif +#define TRACE_INFORMATION_CLASS_DEFINE + +#endif /* TRACE_INFOPRMATION_CLASS_DEFINE */ + +#if (NTDDI_VERSION >= NTDDI_VISTA) + +NTSTATUS +NTKERNELAPI +NTAPI +EtwRegister( + IN LPCGUID ProviderId, + IN PETWENABLECALLBACK EnableCallback OPTIONAL, + IN PVOID CallbackContext OPTIONAL, + OUT PREGHANDLE RegHandle); + +NTSTATUS +NTKERNELAPI +NTAPI +EtwUnregister( + IN REGHANDLE RegHandle); + +BOOLEAN +NTKERNELAPI +NTAPI +EtwEventEnabled( + IN REGHANDLE RegHandle, + IN PCEVENT_DESCRIPTOR EventDescriptor); + +BOOLEAN +NTKERNELAPI +NTAPI +EtwProviderEnabled( + IN REGHANDLE RegHandle, + IN UCHAR Level, + IN ULONGLONG Keyword); + +NTSTATUS +NTKERNELAPI +NTAPI +EtwActivityIdControl( + IN ULONG ControlCode, + IN OUT LPGUID ActivityId); + +NTSTATUS +NTKERNELAPI +NTAPI +EtwWrite( + IN REGHANDLE RegHandle, + IN PCEVENT_DESCRIPTOR EventDescriptor, + IN LPCGUID ActivityId OPTIONAL, + IN ULONG UserDataCount, + IN PEVENT_DATA_DESCRIPTOR UserData OPTIONAL); + +NTSTATUS +NTKERNELAPI +NTAPI +EtwWriteTransfer( + IN REGHANDLE RegHandle, + IN PCEVENT_DESCRIPTOR EventDescriptor, + IN LPCGUID ActivityId OPTIONAL, + IN LPCGUID RelatedActivityId OPTIONAL, + IN ULONG UserDataCount, + IN PEVENT_DATA_DESCRIPTOR UserData OPTIONAL); + +NTSTATUS +NTKERNELAPI +NTAPI +EtwWriteString( + IN REGHANDLE RegHandle, + IN UCHAR Level, + IN ULONGLONG Keyword, + IN LPCGUID ActivityId OPTIONAL, + IN PCWSTR String); + +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + +#if (NTDDI_VERSION >= NTDDI_WIN7) +NTSTATUS +NTKERNELAPI +NTAPI +EtwWriteEx( + IN REGHANDLE RegHandle, + IN PCEVENT_DESCRIPTOR EventDescriptor, + IN ULONG64 Filter, + IN ULONG Flags, + IN LPCGUID ActivityId OPTIONAL, + IN LPCGUID RelatedActivityId OPTIONAL, + IN ULONG UserDataCount, + IN PEVENT_DATA_DESCRIPTOR UserData OPTIONAL); +#endif + + + /****************************************************************************** * Kernel Debugger Functions * ******************************************************************************/ #ifndef _DBGNT_ + ULONG -DDKCDECLAPI +__cdecl DbgPrint( - IN PCSTR Format, + IN PCSTR Format, + IN ...); + +#if (NTDDI_VERSION >= NTDDI_WIN2K) +NTSYSAPI +ULONG +__cdecl +DbgPrintReturnControlC( + IN PCCH Format, IN ...); #endif -#if DBG +#if (NTDDI_VERSION >= NTDDI_WINXP) -#define KdPrint(_x_) DbgPrint _x_ -#define KdPrintEx(_x_) DbgPrintEx _x_ -#define vKdPrintExWithPrefix(_x_) vDbgPrintExWithPrefix _x_ -#define KdBreakPoint() DbgBreakPoint() -#define KdBreakPointWithStatus(s) DbgBreakPointWithStatus(s) - -#else /* !DBG */ - -#define KdPrint(_x_) -#define KdPrintEx(_x_) -#define vKdPrintExWithPrefix(_x_) -#define KdBreakPoint() -#define KdBreakPointWithStatus(s) - -#endif /* !DBG */ - -#if defined(__GNUC__) - -extern NTKERNELAPI BOOLEAN KdDebuggerNotPresent; -extern NTKERNELAPI BOOLEAN KdDebuggerEnabled; -#define KD_DEBUGGER_ENABLED KdDebuggerEnabled -#define KD_DEBUGGER_NOT_PRESENT KdDebuggerNotPresent - -#elif defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_) || defined(_WDMDDK_) || defined(_NTOSP_) - -extern NTKERNELAPI PBOOLEAN KdDebuggerNotPresent; -extern NTKERNELAPI PBOOLEAN KdDebuggerEnabled; -#define KD_DEBUGGER_ENABLED *KdDebuggerEnabled -#define KD_DEBUGGER_NOT_PRESENT *KdDebuggerNotPresent - -#else - -extern BOOLEAN KdDebuggerNotPresent; -extern BOOLEAN KdDebuggerEnabled; -#define KD_DEBUGGER_ENABLED KdDebuggerEnabled -#define KD_DEBUGGER_NOT_PRESENT KdDebuggerNotPresent - -#endif +NTSYSAPI +ULONG +__cdecl +DbgPrintEx( + IN ULONG ComponentId, + IN ULONG Level, + IN PCSTR Format, + IN ...); #ifdef _VA_LIST_DEFINED -#if (NTDDI_VERSION >= NTDDI_WINXP) NTSYSAPI ULONG @@ -10820,84 +14435,120 @@ vDbgPrintExWithPrefix( IN PCCH Format, IN va_list ap); +#endif /* _VA_LIST_DEFINED */ + +NTSYSAPI +NTSTATUS +NTAPI +DbgQueryDebugFilterState( + IN ULONG ComponentId, + IN ULONG Level); + +NTSYSAPI +NTSTATUS +NTAPI +DbgSetDebugFilterState( + IN ULONG ComponentId, + IN ULONG Level, + IN BOOLEAN State); + +#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ + +#if (NTDDI_VERSION >= NTDDI_VISTA) + +typedef VOID +(*PDEBUG_PRINT_CALLBACK)( + IN PSTRING Output, + IN ULONG ComponentId, + IN ULONG Level); + +NTSYSAPI +NTSTATUS +NTAPI +DbgSetDebugPrintCallback( + IN PDEBUG_PRINT_CALLBACK DebugPrintCallback, + IN BOOLEAN Enable); + +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + +#endif /* _DBGNT_ */ + +#if DBG + +#define KdPrint(_x_) DbgPrint _x_ +#define KdPrintEx(_x_) DbgPrintEx _x_ +#define vKdPrintEx(_x_) vDbgPrintEx _x_ +#define vKdPrintExWithPrefix(_x_) vDbgPrintExWithPrefix _x_ +#define KdBreakPoint() DbgBreakPoint() +#define KdBreakPointWithStatus(s) DbgBreakPointWithStatus(s) + +#else /* !DBG */ + +#define KdPrint(_x_) +#define KdPrintEx(_x_) +#define vKdPrintEx(_x_) +#define vKdPrintExWithPrefix(_x_) +#define KdBreakPoint() +#define KdBreakPointWithStatus(s) + +#endif /* !DBG */ + +#if defined(__GNUC__) + +extern NTKERNELAPI BOOLEAN KdDebuggerNotPresent; +extern NTKERNELAPI BOOLEAN KdDebuggerEnabled; +#define KD_DEBUGGER_ENABLED KdDebuggerEnabled +#define KD_DEBUGGER_NOT_PRESENT KdDebuggerNotPresent + +#elif defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_) || defined(_WDMDDK_) || defined(_NTOSP_) + +extern NTKERNELAPI PBOOLEAN KdDebuggerNotPresent; +extern NTKERNELAPI PBOOLEAN KdDebuggerEnabled; +#define KD_DEBUGGER_ENABLED *KdDebuggerEnabled +#define KD_DEBUGGER_NOT_PRESENT *KdDebuggerNotPresent + +#else + +extern BOOLEAN KdDebuggerNotPresent; +extern BOOLEAN KdDebuggerEnabled; +#define KD_DEBUGGER_ENABLED KdDebuggerEnabled +#define KD_DEBUGGER_NOT_PRESENT KdDebuggerNotPresent + #endif -#endif // _VA_LIST_DEFINED #if (NTDDI_VERSION >= NTDDI_WIN2K) NTKERNELAPI NTSTATUS NTAPI -KdDisableDebugger( - VOID); +KdDisableDebugger(VOID); NTKERNELAPI NTSTATUS NTAPI -KdEnableDebugger( - VOID); +KdEnableDebugger(VOID); #if (_MSC_FULL_VER >= 150030729) && !defined(IMPORT_NATIVE_DBG_BREAK) #define DbgBreakPoint __debugbreak #else VOID NTAPI -DbgBreakPoint( - VOID); +DbgBreakPoint(VOID); #endif NTSYSAPI VOID NTAPI DbgBreakPointWithStatus( - IN ULONG Status); + IN ULONG Status); -NTSYSAPI -ULONG -DDKCDECLAPI -DbgPrintReturnControlC( - IN PCCH Format, - IN ...); - -#endif - -#if (NTDDI_VERSION >= NTDDI_WINXP) - -NTSYSAPI -ULONG -DDKCDECLAPI -DbgPrintEx( - IN ULONG ComponentId, - IN ULONG Level, - IN PCSTR Format, - IN ...); - -NTSYSAPI -NTSTATUS -NTAPI -DbgQueryDebugFilterState( - IN ULONG ComponentId, - IN ULONG Level); - -NTSYSAPI -NTSTATUS -NTAPI -DbgSetDebugFilterState( - IN ULONG ComponentId, - IN ULONG Level, - IN BOOLEAN State); - -#endif +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ #if (NTDDI_VERSION >= NTDDI_WS03) - NTKERNELAPI BOOLEAN NTAPI -KdRefreshDebuggerNotPresent( - VOID -); - +KdRefreshDebuggerNotPresent(VOID); #endif #if (NTDDI_VERSION >= NTDDI_WS03SP1) @@ -10912,16 +14563,19 @@ KdChangeOption( OUT PVOID OutBuffer, OUT PULONG OutBufferNeeded OPTIONAL); #endif +/* Hardware Abstraction Layer Functions */ #if defined(USE_DMA_MACROS) && !defined(_NTHAL_) && (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_) + + FORCEINLINE PVOID NTAPI HalAllocateCommonBuffer( IN PDMA_ADAPTER DmaAdapter, - IN ULONG Length, - OUT PPHYSICAL_ADDRESS LogicalAddress, - IN BOOLEAN CacheEnabled) + IN ULONG Length, + OUT PPHYSICAL_ADDRESS LogicalAddress, + IN BOOLEAN CacheEnabled) { PALLOCATE_COMMON_BUFFER allocateCommonBuffer; PVOID commonBuffer; @@ -10937,10 +14591,10 @@ VOID NTAPI HalFreeCommonBuffer( IN PDMA_ADAPTER DmaAdapter, - IN ULONG Length, - IN PHYSICAL_ADDRESS LogicalAddress, - IN PVOID VirtualAddress, - IN BOOLEAN CacheEnabled) + IN ULONG Length, + IN PHYSICAL_ADDRESS LogicalAddress, + IN PVOID VirtualAddress, + IN BOOLEAN CacheEnabled) { PFREE_COMMON_BUFFER freeCommonBuffer; @@ -10964,14 +14618,225 @@ HalReadDmaCounter( return counter; } -#endif +FORCEINLINE +ULONG +HalGetDmaAlignment( + IN PDMA_ADAPTER DmaAdapter) +{ + PGET_DMA_ALIGNMENT getDmaAlignment; + ULONG alignment; + getDmaAlignment = *(DmaAdapter)->DmaOperations->GetDmaAlignment; + ASSERT( getDmaAlignment != NULL ); + alignment = getDmaAlignment( DmaAdapter ); + return alignment; +} + + + +#endif #ifndef _NTTMAPI_ #define _NTTMAPI_ #include +#define TRANSACTIONMANAGER_QUERY_INFORMATION (0x0001) +#define TRANSACTIONMANAGER_SET_INFORMATION (0x0002) +#define TRANSACTIONMANAGER_RECOVER (0x0004) +#define TRANSACTIONMANAGER_RENAME (0x0008) +#define TRANSACTIONMANAGER_CREATE_RM (0x0010) +#define TRANSACTIONMANAGER_BIND_TRANSACTION (0x0020) + +#define TRANSACTIONMANAGER_GENERIC_READ (STANDARD_RIGHTS_READ |\ + TRANSACTIONMANAGER_QUERY_INFORMATION) + +#define TRANSACTIONMANAGER_GENERIC_WRITE (STANDARD_RIGHTS_WRITE |\ + TRANSACTIONMANAGER_SET_INFORMATION |\ + TRANSACTIONMANAGER_RECOVER |\ + TRANSACTIONMANAGER_RENAME |\ + TRANSACTIONMANAGER_CREATE_RM) + +#define TRANSACTIONMANAGER_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE) + +#define TRANSACTIONMANAGER_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED |\ + TRANSACTIONMANAGER_GENERIC_READ |\ + TRANSACTIONMANAGER_GENERIC_WRITE |\ + TRANSACTIONMANAGER_GENERIC_EXECUTE |\ + TRANSACTIONMANAGER_BIND_TRANSACTION) + +#define TRANSACTION_QUERY_INFORMATION (0x0001) +#define TRANSACTION_SET_INFORMATION (0x0002) +#define TRANSACTION_ENLIST (0x0004) +#define TRANSACTION_COMMIT (0x0008) +#define TRANSACTION_ROLLBACK (0x0010) +#define TRANSACTION_PROPAGATE (0x0020) +#define TRANSACTION_RIGHT_RESERVED1 (0x0040) + +#define TRANSACTION_GENERIC_READ (STANDARD_RIGHTS_READ |\ + TRANSACTION_QUERY_INFORMATION |\ + SYNCHRONIZE) + +#define TRANSACTION_GENERIC_WRITE (STANDARD_RIGHTS_WRITE |\ + TRANSACTION_SET_INFORMATION |\ + TRANSACTION_COMMIT |\ + TRANSACTION_ENLIST |\ + TRANSACTION_ROLLBACK |\ + TRANSACTION_PROPAGATE |\ + SYNCHRONIZE) + +#define TRANSACTION_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE |\ + TRANSACTION_COMMIT |\ + TRANSACTION_ROLLBACK |\ + SYNCHRONIZE) + +#define TRANSACTION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED |\ + TRANSACTION_GENERIC_READ |\ + TRANSACTION_GENERIC_WRITE |\ + TRANSACTION_GENERIC_EXECUTE) + +#define TRANSACTION_RESOURCE_MANAGER_RIGHTS (TRANSACTION_GENERIC_READ |\ + STANDARD_RIGHTS_WRITE |\ + TRANSACTION_SET_INFORMATION |\ + TRANSACTION_ENLIST |\ + TRANSACTION_ROLLBACK |\ + TRANSACTION_PROPAGATE |\ + SYNCHRONIZE) + +#define RESOURCEMANAGER_QUERY_INFORMATION (0x0001) +#define RESOURCEMANAGER_SET_INFORMATION (0x0002) +#define RESOURCEMANAGER_RECOVER (0x0004) +#define RESOURCEMANAGER_ENLIST (0x0008) +#define RESOURCEMANAGER_GET_NOTIFICATION (0x0010) +#define RESOURCEMANAGER_REGISTER_PROTOCOL (0x0020) +#define RESOURCEMANAGER_COMPLETE_PROPAGATION (0x0040) + +#define RESOURCEMANAGER_GENERIC_READ (STANDARD_RIGHTS_READ |\ + RESOURCEMANAGER_QUERY_INFORMATION |\ + SYNCHRONIZE) + +#define RESOURCEMANAGER_GENERIC_WRITE (STANDARD_RIGHTS_WRITE |\ + RESOURCEMANAGER_SET_INFORMATION |\ + RESOURCEMANAGER_RECOVER |\ + RESOURCEMANAGER_ENLIST |\ + RESOURCEMANAGER_GET_NOTIFICATION |\ + RESOURCEMANAGER_REGISTER_PROTOCOL |\ + RESOURCEMANAGER_COMPLETE_PROPAGATION |\ + SYNCHRONIZE) + +#define RESOURCEMANAGER_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE |\ + RESOURCEMANAGER_RECOVER |\ + RESOURCEMANAGER_ENLIST |\ + RESOURCEMANAGER_GET_NOTIFICATION |\ + RESOURCEMANAGER_COMPLETE_PROPAGATION |\ + SYNCHRONIZE) + +#define RESOURCEMANAGER_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED |\ + RESOURCEMANAGER_GENERIC_READ |\ + RESOURCEMANAGER_GENERIC_WRITE |\ + RESOURCEMANAGER_GENERIC_EXECUTE) + +#define ENLISTMENT_QUERY_INFORMATION (0x0001) +#define ENLISTMENT_SET_INFORMATION (0x0002) +#define ENLISTMENT_RECOVER (0x0004) +#define ENLISTMENT_SUBORDINATE_RIGHTS (0x0008) +#define ENLISTMENT_SUPERIOR_RIGHTS (0x0010) + +#define ENLISTMENT_GENERIC_READ (STANDARD_RIGHTS_READ |\ + ENLISTMENT_QUERY_INFORMATION) + +#define ENLISTMENT_GENERIC_WRITE (STANDARD_RIGHTS_WRITE |\ + ENLISTMENT_SET_INFORMATION |\ + ENLISTMENT_RECOVER |\ + ENLISTMENT_SUBORDINATE_RIGHTS |\ + ENLISTMENT_SUPERIOR_RIGHTS) + +#define ENLISTMENT_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE |\ + ENLISTMENT_RECOVER |\ + ENLISTMENT_SUBORDINATE_RIGHTS |\ + ENLISTMENT_SUPERIOR_RIGHTS) + +#define ENLISTMENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED |\ + ENLISTMENT_GENERIC_READ |\ + ENLISTMENT_GENERIC_WRITE |\ + ENLISTMENT_GENERIC_EXECUTE) + +typedef enum _TRANSACTION_OUTCOME { + TransactionOutcomeUndetermined = 1, + TransactionOutcomeCommitted, + TransactionOutcomeAborted, +} TRANSACTION_OUTCOME; + + +typedef enum _TRANSACTION_STATE { + TransactionStateNormal = 1, + TransactionStateIndoubt, + TransactionStateCommittedNotify, +} TRANSACTION_STATE; + + +typedef struct _TRANSACTION_BASIC_INFORMATION { + GUID TransactionId; + ULONG State; + ULONG Outcome; +} TRANSACTION_BASIC_INFORMATION, *PTRANSACTION_BASIC_INFORMATION; + +typedef struct _TRANSACTIONMANAGER_BASIC_INFORMATION { + GUID TmIdentity; + LARGE_INTEGER VirtualClock; +} TRANSACTIONMANAGER_BASIC_INFORMATION, *PTRANSACTIONMANAGER_BASIC_INFORMATION; + +typedef struct _TRANSACTIONMANAGER_LOG_INFORMATION { + GUID LogIdentity; +} TRANSACTIONMANAGER_LOG_INFORMATION, *PTRANSACTIONMANAGER_LOG_INFORMATION; + +typedef struct _TRANSACTIONMANAGER_LOGPATH_INFORMATION { + ULONG LogPathLength; + WCHAR LogPath[1]; +} TRANSACTIONMANAGER_LOGPATH_INFORMATION, *PTRANSACTIONMANAGER_LOGPATH_INFORMATION; + +typedef struct _TRANSACTIONMANAGER_RECOVERY_INFORMATION { + ULONGLONG LastRecoveredLsn; +} TRANSACTIONMANAGER_RECOVERY_INFORMATION, *PTRANSACTIONMANAGER_RECOVERY_INFORMATION; + +typedef struct _TRANSACTION_PROPERTIES_INFORMATION { + ULONG IsolationLevel; + ULONG IsolationFlags; + LARGE_INTEGER Timeout; + ULONG Outcome; + ULONG DescriptionLength; + WCHAR Description[1]; +} TRANSACTION_PROPERTIES_INFORMATION, *PTRANSACTION_PROPERTIES_INFORMATION; + +typedef struct _TRANSACTION_BIND_INFORMATION { + HANDLE TmHandle; +} TRANSACTION_BIND_INFORMATION, *PTRANSACTION_BIND_INFORMATION; + +typedef struct _TRANSACTION_ENLISTMENT_PAIR { + GUID EnlistmentId; + GUID ResourceManagerId; +} TRANSACTION_ENLISTMENT_PAIR, *PTRANSACTION_ENLISTMENT_PAIR; + +typedef struct _TRANSACTION_ENLISTMENTS_INFORMATION { + ULONG NumberOfEnlistments; + TRANSACTION_ENLISTMENT_PAIR EnlistmentPair[1]; +} TRANSACTION_ENLISTMENTS_INFORMATION, *PTRANSACTION_ENLISTMENTS_INFORMATION; + +typedef struct _TRANSACTION_SUPERIOR_ENLISTMENT_INFORMATION { + TRANSACTION_ENLISTMENT_PAIR SuperiorEnlistmentPair; +} TRANSACTION_SUPERIOR_ENLISTMENT_INFORMATION, *PTRANSACTION_SUPERIOR_ENLISTMENT_INFORMATION; + +typedef struct _RESOURCEMANAGER_BASIC_INFORMATION { + GUID ResourceManagerId; + ULONG DescriptionLength; + WCHAR Description[1]; +} RESOURCEMANAGER_BASIC_INFORMATION, *PRESOURCEMANAGER_BASIC_INFORMATION; + +typedef struct _RESOURCEMANAGER_COMPLETION_INFORMATION { + HANDLE IoCompletionPortHandle; + ULONG_PTR CompletionKey; +} RESOURCEMANAGER_COMPLETION_INFORMATION, *PRESOURCEMANAGER_COMPLETION_INFORMATION; + typedef enum _KTMOBJECT_TYPE { KTMOBJECT_TRANSACTION, KTMOBJECT_TRANSACTION_MANAGER, @@ -11005,66 +14870,480 @@ typedef enum _RESOURCEMANAGER_INFORMATION_CLASS { ResourceManagerCompletionInformation, } RESOURCEMANAGER_INFORMATION_CLASS; +typedef struct _ENLISTMENT_BASIC_INFORMATION { + GUID EnlistmentId; + GUID TransactionId; + GUID ResourceManagerId; +} ENLISTMENT_BASIC_INFORMATION, *PENLISTMENT_BASIC_INFORMATION; + +typedef struct _ENLISTMENT_CRM_INFORMATION { + GUID CrmTransactionManagerId; + GUID CrmResourceManagerId; + GUID CrmEnlistmentId; +} ENLISTMENT_CRM_INFORMATION, *PENLISTMENT_CRM_INFORMATION; + typedef enum _ENLISTMENT_INFORMATION_CLASS { EnlistmentBasicInformation, EnlistmentRecoveryInformation, EnlistmentCrmInformation } ENLISTMENT_INFORMATION_CLASS; +typedef struct _TRANSACTION_LIST_ENTRY { +#if defined(__cplusplus) + ::UOW UOW; +#else + UOW UOW; +#endif +} TRANSACTION_LIST_ENTRY, *PTRANSACTION_LIST_ENTRY; + +typedef struct _TRANSACTION_LIST_INFORMATION { + ULONG NumberOfTransactions; + TRANSACTION_LIST_ENTRY TransactionInformation[1]; +} TRANSACTION_LIST_INFORMATION, *PTRANSACTION_LIST_INFORMATION; + +typedef NTSTATUS +(NTAPI *PFN_NT_CREATE_TRANSACTION)( + OUT PHANDLE TransactionHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, + IN LPGUID Uow OPTIONAL, + IN HANDLE TmHandle OPTIONAL, + IN ULONG CreateOptions OPTIONAL, + IN ULONG IsolationLevel OPTIONAL, + IN ULONG IsolationFlags OPTIONAL, + IN PLARGE_INTEGER Timeout OPTIONAL, + IN PUNICODE_STRING Description OPTIONAL); + +typedef NTSTATUS +(NTAPI *PFN_NT_OPEN_TRANSACTION)( + OUT PHANDLE TransactionHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN LPGUID Uow OPTIONAL, + IN HANDLE TmHandle OPTIONAL); + +typedef NTSTATUS +(NTAPI *PFN_NT_QUERY_INFORMATION_TRANSACTION)( + IN HANDLE TransactionHandle, + IN TRANSACTION_INFORMATION_CLASS TransactionInformationClass, + OUT PVOID TransactionInformation, + IN ULONG TransactionInformationLength, + OUT PULONG ReturnLength OPTIONAL); + +typedef NTSTATUS +(NTAPI *PFN_NT_SET_INFORMATION_TRANSACTION)( + IN HANDLE TransactionHandle, + IN TRANSACTION_INFORMATION_CLASS TransactionInformationClass, + IN PVOID TransactionInformation, + IN ULONG TransactionInformationLength); + +typedef NTSTATUS +(NTAPI *PFN_NT_COMMIT_TRANSACTION)( + IN HANDLE TransactionHandle, + IN BOOLEAN Wait); + +typedef NTSTATUS +(NTAPI *PFN_NT_ROLLBACK_TRANSACTION)( + IN HANDLE TransactionHandle, + IN BOOLEAN Wait); + +#if (NTDDI_VERSION >= NTDDI_VISTA) + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtCreateTransactionManager( + OUT PHANDLE TmHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, + IN PUNICODE_STRING LogFileName OPTIONAL, + IN ULONG CreateOptions OPTIONAL, + IN ULONG CommitStrength OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtOpenTransactionManager( + OUT PHANDLE TmHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, + IN PUNICODE_STRING LogFileName OPTIONAL, + IN LPGUID TmIdentity OPTIONAL, + IN ULONG OpenOptions OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtRenameTransactionManager( + IN PUNICODE_STRING LogFileName, + IN LPGUID ExistingTransactionManagerGuid); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtRollforwardTransactionManager( + IN HANDLE TransactionManagerHandle, + IN PLARGE_INTEGER TmVirtualClock OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtRecoverTransactionManager( + IN HANDLE TransactionManagerHandle); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtQueryInformationTransactionManager( + IN HANDLE TransactionManagerHandle, + IN TRANSACTIONMANAGER_INFORMATION_CLASS TransactionManagerInformationClass, + OUT PVOID TransactionManagerInformation, + IN ULONG TransactionManagerInformationLength, + OUT PULONG ReturnLength); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtSetInformationTransactionManager( + IN HANDLE TmHandle OPTIONAL, + IN TRANSACTIONMANAGER_INFORMATION_CLASS TransactionManagerInformationClass, + IN PVOID TransactionManagerInformation, + IN ULONG TransactionManagerInformationLength); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtEnumerateTransactionObject( + IN HANDLE RootObjectHandle OPTIONAL, + IN KTMOBJECT_TYPE QueryType, + IN OUT PKTMOBJECT_CURSOR ObjectCursor, + IN ULONG ObjectCursorLength, + OUT PULONG ReturnLength); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtCreateTransaction( + OUT PHANDLE TransactionHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, + IN LPGUID Uow OPTIONAL, + IN HANDLE TmHandle OPTIONAL, + IN ULONG CreateOptions OPTIONAL, + IN ULONG IsolationLevel OPTIONAL, + IN ULONG IsolationFlags OPTIONAL, + IN PLARGE_INTEGER Timeout OPTIONAL, + IN PUNICODE_STRING Description OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtOpenTransaction( + OUT PHANDLE TransactionHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN LPGUID Uow, + IN HANDLE TmHandle OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtQueryInformationTransaction( + IN HANDLE TransactionHandle, + IN TRANSACTION_INFORMATION_CLASS TransactionInformationClass, + OUT PVOID TransactionInformation, + IN ULONG TransactionInformationLength, + OUT PULONG ReturnLength OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtSetInformationTransaction( + IN HANDLE TransactionHandle, + IN TRANSACTION_INFORMATION_CLASS TransactionInformationClass, + IN PVOID TransactionInformation, + IN ULONG TransactionInformationLength); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtCommitTransaction( + IN HANDLE TransactionHandle, + IN BOOLEAN Wait); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtRollbackTransaction( + IN HANDLE TransactionHandle, + IN BOOLEAN Wait); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtCreateEnlistment( + OUT PHANDLE EnlistmentHandle, + IN ACCESS_MASK DesiredAccess, + IN HANDLE ResourceManagerHandle, + IN HANDLE TransactionHandle, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, + IN ULONG CreateOptions OPTIONAL, + IN NOTIFICATION_MASK NotificationMask, + IN PVOID EnlistmentKey OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtOpenEnlistment( + OUT PHANDLE EnlistmentHandle, + IN ACCESS_MASK DesiredAccess, + IN HANDLE ResourceManagerHandle, + IN LPGUID EnlistmentGuid, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtQueryInformationEnlistment( + IN HANDLE EnlistmentHandle, + IN ENLISTMENT_INFORMATION_CLASS EnlistmentInformationClass, + OUT PVOID EnlistmentInformation, + IN ULONG EnlistmentInformationLength, + OUT PULONG ReturnLength); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtSetInformationEnlistment( + IN HANDLE EnlistmentHandle OPTIONAL, + IN ENLISTMENT_INFORMATION_CLASS EnlistmentInformationClass, + IN PVOID EnlistmentInformation, + IN ULONG EnlistmentInformationLength); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtRecoverEnlistment( + IN HANDLE EnlistmentHandle, + IN PVOID EnlistmentKey OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtPrePrepareEnlistment( + IN HANDLE EnlistmentHandle, + IN PLARGE_INTEGER TmVirtualClock OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtPrepareEnlistment( + IN HANDLE EnlistmentHandle, + IN PLARGE_INTEGER TmVirtualClock OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtCommitEnlistment( + IN HANDLE EnlistmentHandle, + IN PLARGE_INTEGER TmVirtualClock OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtRollbackEnlistment( + IN HANDLE EnlistmentHandle, + IN PLARGE_INTEGER TmVirtualClock OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtPrePrepareComplete( + IN HANDLE EnlistmentHandle, + IN PLARGE_INTEGER TmVirtualClock OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtPrepareComplete( + IN HANDLE EnlistmentHandle, + IN PLARGE_INTEGER TmVirtualClock OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtCommitComplete( + IN HANDLE EnlistmentHandle, + IN PLARGE_INTEGER TmVirtualClock OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtReadOnlyEnlistment( + IN HANDLE EnlistmentHandle, + IN PLARGE_INTEGER TmVirtualClock OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtRollbackComplete( + IN HANDLE EnlistmentHandle, + IN PLARGE_INTEGER TmVirtualClock OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtSinglePhaseReject( + IN HANDLE EnlistmentHandle, + IN PLARGE_INTEGER TmVirtualClock OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtCreateResourceManager( + OUT PHANDLE ResourceManagerHandle, + IN ACCESS_MASK DesiredAccess, + IN HANDLE TmHandle, + IN LPGUID RmGuid, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, + IN ULONG CreateOptions OPTIONAL, + IN PUNICODE_STRING Description OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtOpenResourceManager( + OUT PHANDLE ResourceManagerHandle, + IN ACCESS_MASK DesiredAccess, + IN HANDLE TmHandle, + IN LPGUID ResourceManagerGuid OPTIONAL, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtRecoverResourceManager( + IN HANDLE ResourceManagerHandle); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtGetNotificationResourceManager( + IN HANDLE ResourceManagerHandle, + OUT PTRANSACTION_NOTIFICATION TransactionNotification, + IN ULONG NotificationLength, + IN PLARGE_INTEGER Timeout OPTIONAL, + OUT PULONG ReturnLength OPTIONAL, + IN ULONG Asynchronous, + IN ULONG_PTR AsynchronousContext OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtQueryInformationResourceManager( + IN HANDLE ResourceManagerHandle, + IN RESOURCEMANAGER_INFORMATION_CLASS ResourceManagerInformationClass, + OUT PVOID ResourceManagerInformation, + IN ULONG ResourceManagerInformationLength, + OUT PULONG ReturnLength OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtSetInformationResourceManager( + IN HANDLE ResourceManagerHandle, + IN RESOURCEMANAGER_INFORMATION_CLASS ResourceManagerInformationClass, + IN PVOID ResourceManagerInformation, + IN ULONG ResourceManagerInformationLength); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtRegisterProtocolAddressInformation( + IN HANDLE ResourceManager, + IN PCRM_PROTOCOL_ID ProtocolId, + IN ULONG ProtocolInformationSize, + IN PVOID ProtocolInformation, + IN ULONG CreateOptions OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtPropagationComplete( + IN HANDLE ResourceManagerHandle, + IN ULONG RequestCookie, + IN ULONG BufferLength, + IN PVOID Buffer); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtPropagationFailed( + IN HANDLE ResourceManagerHandle, + IN ULONG RequestCookie, + IN NTSTATUS PropStatus); + +#endif /* NTDDI_VERSION >= NTDDI_VISTA */ + #endif /* !_NTTMAPI_ */ /****************************************************************************** * ZwXxx Functions * ******************************************************************************/ + /* Constants */ #define NtCurrentProcess() ( (HANDLE)(LONG_PTR) -1 ) #define ZwCurrentProcess() NtCurrentProcess() #define NtCurrentThread() ( (HANDLE)(LONG_PTR) -2 ) #define ZwCurrentThread() NtCurrentThread() + + #if (NTDDI_VERSION >= NTDDI_WIN2K) + + NTSYSAPI NTSTATUS NTAPI ZwClose( - IN HANDLE Handle); + IN HANDLE Handle); NTSYSAPI NTSTATUS NTAPI ZwCreateDirectoryObject( - OUT PHANDLE DirectoryHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes); + OUT PHANDLE DirectoryHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes); NTSYSAPI NTSTATUS NTAPI ZwCreateFile( - OUT PHANDLE FileHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes, - OUT PIO_STATUS_BLOCK IoStatusBlock, - IN PLARGE_INTEGER AllocationSize OPTIONAL, - IN ULONG FileAttributes, - IN ULONG ShareAccess, - IN ULONG CreateDisposition, - IN ULONG CreateOptions, - IN PVOID EaBuffer OPTIONAL, - IN ULONG EaLength); + OUT PHANDLE FileHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN PLARGE_INTEGER AllocationSize OPTIONAL, + IN ULONG FileAttributes, + IN ULONG ShareAccess, + IN ULONG CreateDisposition, + IN ULONG CreateOptions, + IN PVOID EaBuffer OPTIONAL, + IN ULONG EaLength); NTSYSAPI NTSTATUS NTAPI ZwCreateKey( - OUT PHANDLE KeyHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes, - IN ULONG TitleIndex, - IN PUNICODE_STRING Class OPTIONAL, - IN ULONG CreateOptions, - OUT PULONG Disposition OPTIONAL); + OUT PHANDLE KeyHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN ULONG TitleIndex, + IN PUNICODE_STRING Class OPTIONAL, + IN ULONG CreateOptions, + OUT PULONG Disposition OPTIONAL); NTSYSAPI NTSTATUS @@ -11088,7 +15367,7 @@ NTSYSAPI NTSTATUS NTAPI ZwDeleteValueKey( - IN HANDLE KeyHandle, + IN HANDLE KeyHandle, IN PUNICODE_STRING ValueName); NTSYSAPI @@ -11117,7 +15396,7 @@ NTSYSAPI NTSTATUS NTAPI ZwFlushKey( - IN HANDLE KeyHandle); + IN HANDLE KeyHandle); NTSYSAPI NTSTATUS @@ -11129,22 +15408,22 @@ NTSYSAPI NTSTATUS NTAPI ZwMakeTemporaryObject( - IN HANDLE Handle); + IN HANDLE Handle); NTSYSAPI NTSTATUS NTAPI ZwMapViewOfSection( - IN HANDLE SectionHandle, - IN HANDLE ProcessHandle, - IN OUT PVOID *BaseAddress, - IN ULONG_PTR ZeroBits, - IN SIZE_T CommitSize, - IN OUT PLARGE_INTEGER SectionOffset OPTIONAL, - IN OUT PSIZE_T ViewSize, - IN SECTION_INHERIT InheritDisposition, - IN ULONG AllocationType, - IN ULONG Protect); + IN HANDLE SectionHandle, + IN HANDLE ProcessHandle, + IN OUT PVOID *BaseAddress, + IN ULONG_PTR ZeroBits, + IN SIZE_T CommitSize, + IN OUT PLARGE_INTEGER SectionOffset OPTIONAL, + IN OUT PSIZE_T ViewSize, + IN SECTION_INHERIT InheritDisposition, + IN ULONG AllocationType, + IN ULONG Protect); NTSYSAPI NTSTATUS @@ -11161,35 +15440,35 @@ NTSYSAPI NTSTATUS NTAPI ZwOpenKey( - OUT PHANDLE KeyHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes); + OUT PHANDLE KeyHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes); NTSYSAPI NTSTATUS NTAPI ZwOpenSection( - OUT PHANDLE SectionHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes); + OUT PHANDLE SectionHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes); NTSYSAPI NTSTATUS NTAPI ZwOpenSymbolicLinkObject( - OUT PHANDLE LinkHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes); + OUT PHANDLE LinkHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes); NTSYSAPI NTSTATUS NTAPI ZwQueryInformationFile( - IN HANDLE FileHandle, - OUT PIO_STATUS_BLOCK IoStatusBlock, - OUT PVOID FileInformation, - IN ULONG Length, - IN FILE_INFORMATION_CLASS FileInformationClass); + IN HANDLE FileHandle, + OUT PIO_STATUS_BLOCK IoStatusBlock, + OUT PVOID FileInformation, + IN ULONG Length, + IN FILE_INFORMATION_CLASS FileInformationClass); NTSYSAPI NTSTATUS @@ -11205,9 +15484,9 @@ NTSYSAPI NTSTATUS NTAPI ZwQuerySymbolicLinkObject( - IN HANDLE LinkHandle, - IN OUT PUNICODE_STRING LinkTarget, - OUT PULONG ReturnedLength OPTIONAL); + IN HANDLE LinkHandle, + IN OUT PUNICODE_STRING LinkTarget, + OUT PULONG ReturnedLength OPTIONAL); NTSYSAPI NTSTATUS @@ -11224,36 +15503,36 @@ NTSYSAPI NTSTATUS NTAPI ZwReadFile( - IN HANDLE FileHandle, - IN HANDLE Event OPTIONAL, - IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, - IN PVOID ApcContext OPTIONAL, - OUT PIO_STATUS_BLOCK IoStatusBlock, - OUT PVOID Buffer, - IN ULONG Length, - IN PLARGE_INTEGER ByteOffset OPTIONAL, - IN PULONG Key OPTIONAL); + IN HANDLE FileHandle, + IN HANDLE Event OPTIONAL, + IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, + IN PVOID ApcContext OPTIONAL, + OUT PIO_STATUS_BLOCK IoStatusBlock, + OUT PVOID Buffer, + IN ULONG Length, + IN PLARGE_INTEGER ByteOffset OPTIONAL, + IN PULONG Key OPTIONAL); NTSYSAPI NTSTATUS NTAPI ZwSetInformationFile( - IN HANDLE FileHandle, - OUT PIO_STATUS_BLOCK IoStatusBlock, - IN PVOID FileInformation, - IN ULONG Length, - IN FILE_INFORMATION_CLASS FileInformationClass); + IN HANDLE FileHandle, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN PVOID FileInformation, + IN ULONG Length, + IN FILE_INFORMATION_CLASS FileInformationClass); NTSYSAPI NTSTATUS NTAPI ZwSetValueKey( - IN HANDLE KeyHandle, - IN PUNICODE_STRING ValueName, - IN ULONG TitleIndex OPTIONAL, - IN ULONG Type, - IN PVOID Data OPTIONAL, - IN ULONG DataSize); + IN HANDLE KeyHandle, + IN PUNICODE_STRING ValueName, + IN ULONG TitleIndex OPTIONAL, + IN ULONG Type, + IN PVOID Data OPTIONAL, + IN ULONG DataSize); NTSYSAPI NTSTATUS @@ -11265,22 +15544,22 @@ NTSYSAPI NTSTATUS NTAPI ZwUnmapViewOfSection( - IN HANDLE ProcessHandle, - IN PVOID BaseAddress OPTIONAL); + IN HANDLE ProcessHandle, + IN PVOID BaseAddress OPTIONAL); NTSYSAPI NTSTATUS NTAPI ZwWriteFile( - IN HANDLE FileHandle, - IN HANDLE Event OPTIONAL, - IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, - IN PVOID ApcContext OPTIONAL, - OUT PIO_STATUS_BLOCK IoStatusBlock, - IN PVOID Buffer, - IN ULONG Length, - IN PLARGE_INTEGER ByteOffset OPTIONAL, - IN PULONG Key OPTIONAL); + IN HANDLE FileHandle, + IN HANDLE Event OPTIONAL, + IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, + IN PVOID ApcContext OPTIONAL, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN PVOID Buffer, + IN ULONG Length, + IN PLARGE_INTEGER ByteOffset OPTIONAL, + IN PULONG Key OPTIONAL); NTSYSAPI NTSTATUS @@ -11289,10 +15568,11 @@ ZwQueryFullAttributesFile( IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PFILE_NETWORK_OPEN_INFORMATION FileInformation); -#endif -#if (NTDDI_VERSION >= NTDDI_WIN2003) +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ + +#if (NTDDI_VERSION >= NTDDI_WS03) NTSYSCALLAPI NTSTATUS NTAPI @@ -11300,7 +15580,6 @@ ZwOpenEvent( OUT PHANDLE EventHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes); - #endif #if (NTDDI_VERSION >= NTDDI_VISTA) @@ -11627,10 +15906,13 @@ ZwSinglePhaseReject( IN PLARGE_INTEGER TmVirtualClock OPTIONAL); -#endif +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + #if (NTDDI_VERSION >= NTDDI_WIN7) + + NTSYSAPI NTSTATUS NTAPI @@ -11694,78 +15976,8 @@ ZwSetInformationKey( IN PVOID KeySetInformation, IN ULONG KeySetInformationLength); -#endif - -/****************************************************************************** - * Unsorted * - ******************************************************************************/ - -/* GUID Comparison */ -#ifndef __IID_ALIGNED__ -#define __IID_ALIGNED__ -#ifdef __cplusplus -inline int IsEqualGUIDAligned(REFGUID guid1, REFGUID guid2) -{ - return ( (*(PLONGLONG)(&guid1) == *(PLONGLONG)(&guid2)) && - (*((PLONGLONG)(&guid1) + 1) == *((PLONGLONG)(&guid2) + 1)) ); -} -#else -#define IsEqualGUIDAligned(guid1, guid2) \ - ( (*(PLONGLONG)(guid1) == *(PLONGLONG)(guid2)) && \ - (*((PLONGLONG)(guid1) + 1) == *((PLONGLONG)(guid2) + 1)) ) -#endif /* __cplusplus */ -#endif /* !__IID_ALIGNED__ */ - -typedef enum { - LT_DONT_CARE, - LT_LOWEST_LATENCY -} LATENCY_TIME; - -#define MAXIMUM_SUSPEND_COUNT MAXCHAR - -#define MAXIMUM_FILENAME_LENGTH 256 - -#define OBJ_NAME_PATH_SEPARATOR ((WCHAR)L'\\') - -#define OBJECT_TYPE_CREATE (0x0001) -#define OBJECT_TYPE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0x1) - -#define DIRECTORY_QUERY (0x0001) -#define DIRECTORY_TRAVERSE (0x0002) -#define DIRECTORY_CREATE_OBJECT (0x0004) -#define DIRECTORY_CREATE_SUBDIRECTORY (0x0008) -#define DIRECTORY_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0xF) - -#define EVENT_QUERY_STATE (0x0001) -#define EVENT_MODIFY_STATE (0x0002) -#define EVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3) - -#define SEMAPHORE_QUERY_STATE (0x0001) -#define SEMAPHORE_MODIFY_STATE (0x0002) -#define SEMAPHORE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3) - -#define SYMBOLIC_LINK_QUERY 0x0001 -#define SYMBOLIC_LINK_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0x1) - -#define DUPLICATE_CLOSE_SOURCE 0x00000001 -#define DUPLICATE_SAME_ACCESS 0x00000002 -#define DUPLICATE_SAME_ATTRIBUTES 0x00000004 - -/* Global debug flag */ -extern ULONG NtGlobalFlag; - -/* Service Start Types */ -#define SERVICE_BOOT_START 0x00000000 -#define SERVICE_SYSTEM_START 0x00000001 -#define SERVICE_AUTO_START 0x00000002 -#define SERVICE_DEMAND_START 0x00000003 -#define SERVICE_DISABLED 0x00000004 - -#ifndef _TRACEHANDLE_DEFINED -#define _TRACEHANDLE_DEFINED -typedef ULONG64 TRACEHANDLE, *PTRACEHANDLE; -#endif +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ #ifdef __cplusplus diff --git a/reactos/include/ddk/wmilib.h b/reactos/include/ddk/wmilib.h index 22bb087a2a7..a0a5bdc5f22 100644 --- a/reactos/include/ddk/wmilib.h +++ b/reactos/include/ddk/wmilib.h @@ -30,6 +30,14 @@ typedef NTSTATUS OUT PUNICODE_STRING *RegistryPath OPTIONAL, IN OUT PUNICODE_STRING MofResourceName, OUT PDEVICE_OBJECT *Pdo OPTIONAL); + +typedef NTSTATUS +(NTAPI *PWMI_FUNCTION_CONTROL) ( + IN OUT PDEVICE_OBJECT DeviceObject, + IN OUT PIRP Irp, + IN ULONG GuidIndex, + IN WMIENABLEDISABLECONTROL Function, + IN BOOLEAN Enable); typedef NTSTATUS (NTAPI *PWMI_QUERY_DATABLOCK) ( @@ -42,6 +50,17 @@ typedef NTSTATUS IN ULONG BufferAvail, OUT PUCHAR Buffer OPTIONAL); +typedef NTSTATUS +(NTAPI *PWMI_EXECUTE_METHOD) ( + IN OUT PDEVICE_OBJECT DeviceObject, + IN OUT PIRP Irp, + IN ULONG GuidIndex, + IN ULONG InstanceIndex, + IN ULONG MethodId, + IN ULONG InBufferSize, + IN ULONG OutBufferSize, + IN OUT PUCHAR Buffer); + typedef NTSTATUS (NTAPI *PWMI_SET_DATABLOCK) ( IN OUT PDEVICE_OBJECT DeviceObject, @@ -61,25 +80,6 @@ typedef NTSTATUS IN ULONG BufferSize, IN PUCHAR Buffer); -typedef NTSTATUS -(NTAPI *PWMI_EXECUTE_METHOD) ( - IN OUT PDEVICE_OBJECT DeviceObject, - IN OUT PIRP Irp, - IN ULONG GuidIndex, - IN ULONG InstanceIndex, - IN ULONG MethodId, - IN ULONG InBufferSize, - IN ULONG OutBufferSize, - IN OUT PUCHAR Buffer); - -typedef NTSTATUS -(NTAPI *PWMI_FUNCTION_CONTROL) ( - IN OUT PDEVICE_OBJECT DeviceObject, - IN OUT PIRP Irp, - IN ULONG GuidIndex, - IN WMIENABLEDISABLECONTROL Function, - IN BOOLEAN Enable); - typedef struct _WMILIB_CONTEXT { ULONG GuidCount; PWMIGUIDREGINFO GuidList; diff --git a/reactos/include/ndk/ketypes.h b/reactos/include/ndk/ketypes.h index a161d796509..7527c40d98d 100644 --- a/reactos/include/ndk/ketypes.h +++ b/reactos/include/ndk/ketypes.h @@ -546,17 +546,6 @@ typedef enum _KAPC_ENVIRONMENT InsertApcEnvironment } KAPC_ENVIRONMENT; -// -// CPU Cache Types -// -typedef enum _PROCESSOR_CACHE_TYPE -{ - CacheUnified, - CacheInstruction, - CacheData, - CacheTrace, -} PROCESSOR_CACHE_TYPE; - // // PRCB DPC Data // @@ -577,18 +566,6 @@ typedef struct _PP_LOOKASIDE_LIST struct _GENERAL_LOOKASIDE *L; } PP_LOOKASIDE_LIST, *PPP_LOOKASIDE_LIST; -// -// CPU Cache Descriptor -// -typedef struct _CACHE_DESCRIPTOR -{ - UCHAR Level; - UCHAR Associativity; - USHORT LineSize; - ULONG Size; - PROCESSOR_CACHE_TYPE Type; -} CACHE_DESCRIPTOR, *PCACHE_DESCRIPTOR; - // // Architectural Types // diff --git a/reactos/include/ndk/peb_teb.h b/reactos/include/ndk/peb_teb.h index 38791b31a21..3e04fabbd2b 100644 --- a/reactos/include/ndk/peb_teb.h +++ b/reactos/include/ndk/peb_teb.h @@ -19,6 +19,10 @@ #define GDI_HANDLE_BUFFER_SIZE 34 #endif +#if defined(_NTDDK_INCLUDED_) || defined(_NTIFS_) +#define PPEB PPEB_RENAMED +#endif + typedef struct STRUCT(_PEB) { BOOLEAN InheritedAddressSpace; @@ -152,6 +156,7 @@ typedef struct STRUCT(_PEB) #endif } STRUCT(PEB), *STRUCT(PPEB); +#undef PPEB #if defined(_WIN64) && !defined(EXPLICIT_32BIT) C_ASSERT(FIELD_OFFSET(STRUCT(PEB), Mutant) == 0x08); diff --git a/reactos/include/ndk/rtlfuncs.h b/reactos/include/ndk/rtlfuncs.h index 210dd2fffc5..18aa4749ad4 100644 --- a/reactos/include/ndk/rtlfuncs.h +++ b/reactos/include/ndk/rtlfuncs.h @@ -1690,6 +1690,18 @@ RtlDuplicateUnicodeString( OUT PUNICODE_STRING DestinationString ); +// +// Memory Functions +// +NTSYSAPI +VOID +NTAPI +RtlFillMemoryUlong( + IN PVOID Destination, + IN ULONG Length, + IN ULONG Fill +); + #endif NTSYSAPI @@ -1912,18 +1924,6 @@ RtlLookupAtomInAtomTable( OUT PRTL_ATOM Atom ); -// -// Memory Functions -// -NTSYSAPI -VOID -NTAPI -RtlFillMemoryUlong( - IN PVOID Destination, - IN ULONG Length, - IN ULONG Fill -); - // // Process Management Functions // From 20745aaad78187d9e2b6fb4002909ab201dfd954 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Wed, 24 Mar 2010 03:41:53 +0000 Subject: [PATCH 006/134] Add ntiologc.h svn path=/branches/ros-amd64-bringup/; revision=46391 --- reactos/include/psdk/ntiologc.h | 152 ++++++++++++++++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100644 reactos/include/psdk/ntiologc.h diff --git a/reactos/include/psdk/ntiologc.h b/reactos/include/psdk/ntiologc.h new file mode 100644 index 00000000000..b807315bf8b --- /dev/null +++ b/reactos/include/psdk/ntiologc.h @@ -0,0 +1,152 @@ +#pragma once + +#define FACILITY_RPC_RUNTIME 0x2 +#define FACILITY_RPC_STUBS 0x3 +#define FACILITY_IO_ERROR_CODE 0x4 +#define FACILITY_MCA_ERROR_CODE 0x5 + +#define IO_ERR_RETRY_SUCCEEDED ((NTSTATUS)0x00040001L) +#define IO_ERR_INSUFFICIENT_RESOURCES ((NTSTATUS)0xC0040002L) +#define IO_ERR_CONFIGURATION_ERROR ((NTSTATUS)0xC0040003L) +#define IO_ERR_DRIVER_ERROR ((NTSTATUS)0xC0040004L) +#define IO_ERR_PARITY ((NTSTATUS)0xC0040005L) +#define IO_ERR_SEEK_ERROR ((NTSTATUS)0xC0040006L) +#define IO_ERR_BAD_BLOCK ((NTSTATUS)0xC0040007L) +#define IO_ERR_OVERRUN_ERROR ((NTSTATUS)0xC0040008L) +#define IO_ERR_TIMEOUT ((NTSTATUS)0xC0040009L) +#define IO_ERR_SEQUENCE ((NTSTATUS)0xC004000AL) +#define IO_ERR_CONTROLLER_ERROR ((NTSTATUS)0xC004000BL) +#define IO_ERR_INTERNAL_ERROR ((NTSTATUS)0xC004000CL) +#define IO_ERR_INCORRECT_IRQL ((NTSTATUS)0xC004000DL) +#define IO_ERR_INVALID_IOBASE ((NTSTATUS)0xC004000EL) +#define IO_ERR_NOT_READY ((NTSTATUS)0xC004000FL) +#define IO_ERR_INVALID_REQUEST ((NTSTATUS)0xC0040010L) +#define IO_ERR_VERSION ((NTSTATUS)0xC0040011L) +#define IO_ERR_LAYERED_FAILURE ((NTSTATUS)0xC0040012L) +#define IO_ERR_RESET ((NTSTATUS)0xC0040013L) +#define IO_ERR_PROTOCOL ((NTSTATUS)0xC0040014L) +#define IO_ERR_MEMORY_CONFLICT_DETECTED ((NTSTATUS)0xC0040015L) +#define IO_ERR_PORT_CONFLICT_DETECTED ((NTSTATUS)0xC0040016L) +#define IO_ERR_DMA_CONFLICT_DETECTED ((NTSTATUS)0xC0040017L) +#define IO_ERR_IRQ_CONFLICT_DETECTED ((NTSTATUS)0xC0040018L) +#define IO_ERR_BAD_FIRMWARE ((NTSTATUS)0xC0040019L) +#define IO_WRN_BAD_FIRMWARE ((NTSTATUS)0x8004001AL) +#define IO_ERR_DMA_RESOURCE_CONFLICT ((NTSTATUS)0xC004001BL) +#define IO_ERR_INTERRUPT_RESOURCE_CONFLICT ((NTSTATUS)0xC004001CL) +#define IO_ERR_MEMORY_RESOURCE_CONFLICT ((NTSTATUS)0xC004001DL) +#define IO_ERR_PORT_RESOURCE_CONFLICT ((NTSTATUS)0xC004001EL) +#define IO_BAD_BLOCK_WITH_NAME ((NTSTATUS)0xC004001FL) +#define IO_WRITE_CACHE_ENABLED ((NTSTATUS)0x80040020L) +#define IO_RECOVERED_VIA_ECC ((NTSTATUS)0x80040021L) +#define IO_WRITE_CACHE_DISABLED ((NTSTATUS)0x80040022L) +#define IO_FILE_QUOTA_THRESHOLD ((NTSTATUS)0x40040024L) +#define IO_FILE_QUOTA_LIMIT ((NTSTATUS)0x40040025L) +#define IO_FILE_QUOTA_STARTED ((NTSTATUS)0x40040026L) +#define IO_FILE_QUOTA_SUCCEEDED ((NTSTATUS)0x40040027L) +#define IO_FILE_QUOTA_FAILED ((NTSTATUS)0x80040028L) +#define IO_FILE_SYSTEM_CORRUPT ((NTSTATUS)0xC0040029L) +#define IO_FILE_QUOTA_CORRUPT ((NTSTATUS)0xC004002AL) +#define IO_SYSTEM_SLEEP_FAILED ((NTSTATUS)0xC004002BL) +#define IO_DUMP_POINTER_FAILURE ((NTSTATUS)0xC004002CL) +#define IO_DUMP_DRIVER_LOAD_FAILURE ((NTSTATUS)0xC004002DL) +#define IO_DUMP_INITIALIZATION_FAILURE ((NTSTATUS)0xC004002EL) +#define IO_DUMP_DUMPFILE_CONFLICT ((NTSTATUS)0xC004002FL) +#define IO_DUMP_DIRECT_CONFIG_FAILED ((NTSTATUS)0xC0040030L) +#define IO_DUMP_PAGE_CONFIG_FAILED ((NTSTATUS)0xC0040031L) +#define IO_LOST_DELAYED_WRITE ((NTSTATUS)0x80040032L) +#define IO_WARNING_PAGING_FAILURE ((NTSTATUS)0x80040033L) +#define IO_WRN_FAILURE_PREDICTED ((NTSTATUS)0x80040034L) +#define IO_WARNING_INTERRUPT_STILL_PENDING ((NTSTATUS)0x80040035L) +#define IO_DRIVER_CANCEL_TIMEOUT ((NTSTATUS)0x80040036L) +#define IO_FILE_SYSTEM_CORRUPT_WITH_NAME ((NTSTATUS)0xC0040037L) +#define IO_WARNING_ALLOCATION_FAILED ((NTSTATUS)0x80040038L) +#define IO_WARNING_LOG_FLUSH_FAILED ((NTSTATUS)0x80040039L) +#define IO_WARNING_DUPLICATE_SIGNATURE ((NTSTATUS)0x8004003AL) +#define IO_WARNING_DUPLICATE_PATH ((NTSTATUS)0x8004003BL) +#define IO_ERR_THREAD_STUCK_IN_DEVICE_DRIVER ((NTSTATUS)0xC004006CL) +#define IO_ERR_PORT_TIMEOUT ((NTSTATUS)0xC0040075L) +#define IO_WARNING_BUS_RESET ((NTSTATUS)0x80040076L) +#define IO_INFO_THROTTLE_COMPLETE ((NTSTATUS)0x40040077L) +#define IO_WARNING_RESET ((NTSTATUS)0x80040081L) +#define IO_FILE_SYSTEM_REPAIR_SUCCESS ((NTSTATUS)0x80040082L) +#define IO_FILE_SYSTEM_REPAIR_FAILED ((NTSTATUS)0xC0040083L) +#define IO_WARNING_WRITE_FUA_PROBLEM ((NTSTATUS)0x80040084L) +#define IO_CDROM_EXCLUSIVE_LOCK ((NTSTATUS)0x40040085L) +#define IO_FILE_SYSTEM_TXF_RECOVERY_FAILURE ((NTSTATUS)0x80040086L) +#define IO_FILE_SYSTEM_TXF_LOG_FULL_HANDLING_FAILED ((NTSTATUS)0xC0040087L) +#define IO_FILE_SYSTEM_TXF_RESOURCE_MANAGER_RESET ((NTSTATUS)0x80040088L) +#define IO_FILE_SYSTEM_TXF_RESOURCE_MANAGER_START_FAILED ((NTSTATUS)0xC0040089L) +#define IO_FILE_SYSTEM_TXF_RESOURCE_MANAGER_SHUT_DOWN ((NTSTATUS)0xC004008AL) +#define IO_LOST_DELAYED_WRITE_NETWORK_DISCONNECTED ((NTSTATUS)0x8004008BL) +#define IO_LOST_DELAYED_WRITE_NETWORK_SERVER_ERROR ((NTSTATUS)0x8004008CL) +#define IO_LOST_DELAYED_WRITE_NETWORK_LOCAL_DISK_ERROR ((NTSTATUS)0x8004008DL) + +#define MCA_WARNING_CACHE ((NTSTATUS)0x8005003CL) +#define MCA_ERROR_CACHE ((NTSTATUS)0xC005003DL) +#define MCA_WARNING_TLB ((NTSTATUS)0x8005003EL) +#define MCA_ERROR_TLB ((NTSTATUS)0xC005003FL) +#define MCA_WARNING_CPU_BUS ((NTSTATUS)0x80050040L) +#define MCA_ERROR_CPU_BUS ((NTSTATUS)0xC0050041L) +#define MCA_WARNING_REGISTER_FILE ((NTSTATUS)0x80050042L) +#define MCA_ERROR_REGISTER_FILE ((NTSTATUS)0xC0050043L) +#define MCA_WARNING_MAS ((NTSTATUS)0x80050044L) +#define MCA_ERROR_MAS ((NTSTATUS)0xC0050045L) +#define MCA_WARNING_MEM_UNKNOWN ((NTSTATUS)0x80050046L) +#define MCA_ERROR_MEM_UNKNOWN ((NTSTATUS)0xC0050047L) +#define MCA_WARNING_MEM_1_2 ((NTSTATUS)0x80050048L) +#define MCA_ERROR_MEM_1_2 ((NTSTATUS)0xC0050049L) +#define MCA_WARNING_MEM_1_2_5 ((NTSTATUS)0x8005004AL) +#define MCA_ERROR_MEM_1_2_5 ((NTSTATUS)0xC005004BL) +#define MCA_WARNING_MEM_1_2_5_4 ((NTSTATUS)0x8005004CL) +#define MCA_ERROR_MEM_1_2_5_4 ((NTSTATUS)0xC005004DL) +#define MCA_WARNING_SYSTEM_EVENT ((NTSTATUS)0x8005004EL) +#define MCA_ERROR_SYSTEM_EVENT ((NTSTATUS)0xC005004FL) +#define MCA_WARNING_PCI_BUS_PARITY ((NTSTATUS)0x80050050L) +#define MCA_ERROR_PCI_BUS_PARITY ((NTSTATUS)0xC0050051L) +#define MCA_WARNING_PCI_BUS_PARITY_NO_INFO ((NTSTATUS)0x80050052L) +#define MCA_ERROR_PCI_BUS_PARITY_NO_INFO ((NTSTATUS)0xC0050053L) +#define MCA_WARNING_PCI_BUS_SERR ((NTSTATUS)0x80050054L) +#define MCA_ERROR_PCI_BUS_SERR ((NTSTATUS)0xC0050055L) +#define MCA_WARNING_PCI_BUS_SERR_NO_INFO ((NTSTATUS)0x80050056L) +#define MCA_ERROR_PCI_BUS_SERR_NO_INFO ((NTSTATUS)0xC0050057L) +#define MCA_WARNING_PCI_BUS_MASTER_ABORT ((NTSTATUS)0x80050058L) +#define MCA_ERROR_PCI_BUS_MASTER_ABORT ((NTSTATUS)0xC0050059L) +#define MCA_WARNING_PCI_BUS_MASTER_ABORT_NO_INFO ((NTSTATUS)0x8005005AL) +#define MCA_ERROR_PCI_BUS_MASTER_ABORT_NO_INFO ((NTSTATUS)0xC005005BL) +#define MCA_WARNING_PCI_BUS_TIMEOUT ((NTSTATUS)0x8005005CL) +#define MCA_ERROR_PCI_BUS_TIMEOUT ((NTSTATUS)0xC005005DL) +#define MCA_WARNING_PCI_BUS_TIMEOUT_NO_INFO ((NTSTATUS)0x8005005EL) +#define MCA_ERROR_PCI_BUS_TIMEOUT_NO_INFO ((NTSTATUS)0xC005005FL) +#define MCA_WARNING_PCI_BUS_UNKNOWN ((NTSTATUS)0x80050060L) +#define MCA_ERROR_PCI_BUS_UNKNOWN ((NTSTATUS)0xC0050061L) +#define MCA_WARNING_PCI_DEVICE ((NTSTATUS)0x80050062L) +#define MCA_ERROR_PCI_DEVICE ((NTSTATUS)0xC0050063L) +#define MCA_WARNING_SMBIOS ((NTSTATUS)0x80050064L) +#define MCA_ERROR_SMBIOS ((NTSTATUS)0xC0050065L) +#define MCA_WARNING_PLATFORM_SPECIFIC ((NTSTATUS)0x80050066L) +#define MCA_ERROR_PLATFORM_SPECIFIC ((NTSTATUS)0xC0050067L) +#define MCA_WARNING_UNKNOWN ((NTSTATUS)0x80050068L) +#define MCA_ERROR_UNKNOWN ((NTSTATUS)0xC0050069L) +#define MCA_WARNING_UNKNOWN_NO_CPU ((NTSTATUS)0x8005006AL) +#define MCA_ERROR_UNKNOWN_NO_CPU ((NTSTATUS)0xC005006BL) +#define MCA_WARNING_CMC_THRESHOLD_EXCEEDED ((NTSTATUS)0x8005006DL) +#define MCA_WARNING_CPE_THRESHOLD_EXCEEDED ((NTSTATUS)0x8005006EL) +#define MCA_WARNING_CPU_THERMAL_THROTTLED ((NTSTATUS)0x8005006FL) +#define MCA_INFO_CPU_THERMAL_THROTTLING_REMOVED ((NTSTATUS)0x40050070L) +#define MCA_WARNING_CPU ((NTSTATUS)0x80050071L) +#define MCA_ERROR_CPU ((NTSTATUS)0xC0050072L) +#define MCA_INFO_NO_MORE_CORRECTED_ERROR_LOGS ((NTSTATUS)0x40050073L) +#define MCA_INFO_MEMORY_PAGE_MARKED_BAD ((NTSTATUS)0x40050074L) +#define MCA_MEMORYHIERARCHY_ERROR ((NTSTATUS)0xC0050078L) +#define MCA_TLB_ERROR ((NTSTATUS)0xC0050079L) +#define MCA_BUS_ERROR ((NTSTATUS)0xC005007AL) +#define MCA_BUS_TIMEOUT_ERROR ((NTSTATUS)0xC005007BL) +#define MCA_INTERNALTIMER_ERROR ((NTSTATUS)0xC005007CL) +#define MCA_MICROCODE_ROM_PARITY_ERROR ((NTSTATUS)0xC005007EL) +#define MCA_EXTERNAL_ERROR ((NTSTATUS)0xC005007FL) +#define MCA_FRC_ERROR ((NTSTATUS)0xC0050080L) + +#define STATUS_SEVERITY_SUCCESS 0x0 +#define STATUS_SEVERITY_INFORMATIONAL 0x1 +#define STATUS_SEVERITY_WARNING 0x2 +#define STATUS_SEVERITY_ERROR 0x3 From 42bdd9f0f42c590d43af074e0a4f7de504c88715 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Wed, 24 Mar 2010 05:22:21 +0000 Subject: [PATCH 007/134] [NTOS] - Fix ExInitializeRundownProtectionCacheAware prototype - uncomment KeGetCurrentThread for amd64 - Don't redefine SINGLE_GROUP_LEGACY_API svn path=/branches/ros-amd64-bringup/; revision=46393 --- reactos/ntoskrnl/ex/rundown.c | 2 +- reactos/ntoskrnl/include/ntoskrnl.h | 1 - reactos/ntoskrnl/ke/thrdobj.c | 2 ++ 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/reactos/ntoskrnl/ex/rundown.c b/reactos/ntoskrnl/ex/rundown.c index 0466e6ed664..13dc7aab33f 100644 --- a/reactos/ntoskrnl/ex/rundown.c +++ b/reactos/ntoskrnl/ex/rundown.c @@ -491,7 +491,7 @@ ExFreeCacheAwareRundownProtection(IN PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAwar VOID NTAPI ExInitializeRundownProtectionCacheAware(IN PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware, - IN ULONG Count) + IN SIZE_T Count) { DBG_UNREFERENCED_PARAMETER(RunRefCacheAware); DBG_UNREFERENCED_PARAMETER(Count); diff --git a/reactos/ntoskrnl/include/ntoskrnl.h b/reactos/ntoskrnl/include/ntoskrnl.h index f1052ed38df..3b56d34afac 100644 --- a/reactos/ntoskrnl/include/ntoskrnl.h +++ b/reactos/ntoskrnl/include/ntoskrnl.h @@ -19,7 +19,6 @@ /* DDK/IFS/NDK Headers */ #define _REALLY_GET_CALLERS_CALLER -#define SINGLE_GROUP_LEGACY_API #include #include #include diff --git a/reactos/ntoskrnl/ke/thrdobj.c b/reactos/ntoskrnl/ke/thrdobj.c index e73f4ff9d29..16a7c8b39ae 100644 --- a/reactos/ntoskrnl/ke/thrdobj.c +++ b/reactos/ntoskrnl/ke/thrdobj.c @@ -897,6 +897,7 @@ KeCapturePersistentThreadState(IN PVOID CurrentThread, UNIMPLEMENTED; } +#ifndef _M_AMD64 /* * @implemented */ @@ -908,6 +909,7 @@ KeGetCurrentThread(VOID) /* Return the current thread on this PCR */ return _KeGetCurrentThread(); } +#endif /* * @implemented From 0e42f728535eb6b159d46efe65b97b5235942a39 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Wed, 24 Mar 2010 05:24:00 +0000 Subject: [PATCH 008/134] [ACPI] Comment out for now [FRAMEBUF_NEW] compiler flags are for x86 only svn path=/branches/ros-amd64-bringup/; revision=46394 --- reactos/drivers/bus/directory.rbuild | 4 ++-- .../video/displays/framebuf_new/framebuf_new.rbuild | 12 +++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/reactos/drivers/bus/directory.rbuild b/reactos/drivers/bus/directory.rbuild index a6904a2b137..791a34cde04 100644 --- a/reactos/drivers/bus/directory.rbuild +++ b/reactos/drivers/bus/directory.rbuild @@ -1,9 +1,9 @@ - + diff --git a/reactos/drivers/video/displays/framebuf_new/framebuf_new.rbuild b/reactos/drivers/video/displays/framebuf_new/framebuf_new.rbuild index 991954e44e2..de7c4a1d3be 100644 --- a/reactos/drivers/video/displays/framebuf_new/framebuf_new.rbuild +++ b/reactos/drivers/video/displays/framebuf_new/framebuf_new.rbuild @@ -10,10 +10,12 @@ pointer.c screen.c framebuf_new.rc - - -mrtd - -fno-builtin - -Wno-unused-variable - + + + -mrtd + -fno-builtin + -Wno-unused-variable + + driver.h From 5e7490747c8ac5e47a57126ef6f87c2e659dda5b Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Wed, 24 Mar 2010 20:22:20 +0000 Subject: [PATCH 009/134] [DDK/PSDK] - Update changes from header branch [NDK] - add KeTickCount for amd64 (HACK) svn path=/branches/ros-amd64-bringup/; revision=46402 --- reactos/include/ddk/ntddk.h | 41 ++-- reactos/include/ddk/ntifs.h | 2 +- reactos/include/ddk/wdm.h | 58 ++++-- reactos/include/ndk/amd64/ketypes.h | 3 + reactos/include/psdk/ktmtypes.h | 3 + reactos/include/psdk/ntdef.h | 291 ++++++++-------------------- 6 files changed, 153 insertions(+), 245 deletions(-) diff --git a/reactos/include/ddk/ntddk.h b/reactos/include/ddk/ntddk.h index 387f538b100..61c23d3077a 100644 --- a/reactos/include/ddk/ntddk.h +++ b/reactos/include/ddk/ntddk.h @@ -3135,6 +3135,9 @@ typedef struct DECLSPEC_ALIGN(16) _CONTEXT { ULONG64 LastExceptionFromRip; } CONTEXT; +#define PCR_MINOR_VERSION 1 +#define PCR_MAJOR_VERSION 1 + typedef struct _KPCR { _ANONYMOUS_UNION union @@ -3209,6 +3212,10 @@ KeGetCurrentProcessorNumber(VOID) #define PDE_TOP 0xFFFFF6FB7FFFFFFFULL #define PTE_TOP 0xFFFFF6FFFFFFFFFFULL +extern NTKERNELAPI PVOID MmHighestUserAddress; +extern NTKERNELAPI PVOID MmSystemRangeStart; +extern NTKERNELAPI ULONG64 MmUserProbeAddress; + #define MM_HIGHEST_USER_ADDRESS MmHighestUserAddress #define MM_SYSTEM_RANGE_START MmSystemRangeStart #define MM_USER_PROBE_ADDRESS MmUserProbeAddress @@ -3376,13 +3383,14 @@ ExRaiseDatatypeMisalignment(VOID); /* Hardware Abstraction Layer Functions */ +#if (NTDDI_VERSION >= NTDDI_WIN2K) + #if defined(USE_DMA_MACROS) && !defined(_NTHAL_) && (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_) +/* Nothing here */ +#else /* USE_DMA_MACROS ... */ -#else - -#if (NTDDI_VERSION >= NTDDI_WIN2K) //DECLSPEC_DEPRECATED_DDK NTHALAPI VOID @@ -3448,16 +3456,9 @@ HalAllocateAdapterChannel( IN ULONG NumberOfMapRegisters, IN PDRIVER_CONTROL ExecutionRoutine); -#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ - - -#endif - +#endif /* USE_DMA_MACROS ... */ #if !defined(NO_LEGACY_DRIVERS) - -#if (NTDDI_VERSION >= NTDDI_WIN2K) - NTHALAPI NTSTATUS NTAPI @@ -3507,13 +3508,8 @@ BOOLEAN NTAPI HalMakeBeep( IN ULONG Frequency); - -#endif - #endif /* !defined(NO_LEGACY_DRIVERS) */ -#if (NTDDI_VERSION >= NTDDI_WIN2K) - NTHALAPI PADAPTER_OBJECT NTAPI @@ -3601,7 +3597,7 @@ HalExamineMBR( IN ULONG SectorSize, IN ULONG MBRTypeIdentifier, OUT PVOID *Buffer); -#endif +#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ #if (NTDDI_VERSION >= NTDDI_WIN7) @@ -3618,7 +3614,7 @@ NTAPI HalFreeHardwareCounters( IN HANDLE CounterSetHandle); -#endif +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ #if defined(_IA64_) #if (NTDDI_VERSION >= NTDDI_WIN2K) @@ -4137,7 +4133,6 @@ KeInvalidateRangeAllCaches( #if (NTDDI_VERSION >= NTDDI_WIN2K) - NTKERNELAPI VOID NTAPI @@ -4178,7 +4173,6 @@ KeBugCheck( IN ULONG BugCheckCode); - #if defined(SINGLE_GROUP_LEGACY_API) @@ -4210,15 +4204,17 @@ KeAreApcsDisabled(VOID); #if (NTDDI_VERSION >= NTDDI_WS03) + + NTKERNELAPI BOOLEAN NTAPI KeInvalidateAllCaches(VOID); - #endif /* (NTDDI_VERSION >= NTDDI_WS03) */ #if (NTDDI_VERSION >= NTDDI_WS03SP1) + NTKERNELAPI NTSTATUS NTAPI @@ -4242,6 +4238,7 @@ KeLeaveGuardedRegion(VOID); #if (NTDDI_VERSION >= NTDDI_VISTA) + #if defined(SINGLE_GROUP_LEGACY_API) NTKERNELAPI ULONG @@ -4254,7 +4251,7 @@ ULONG NTAPI KeQueryMaximumProcessorCount(VOID); -#endif +#endif /* SINGLE_GROUP_LEGACY_API */ #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ diff --git a/reactos/include/ddk/ntifs.h b/reactos/include/ddk/ntifs.h index 1122e7fcc48..7e14da769e7 100644 --- a/reactos/include/ddk/ntifs.h +++ b/reactos/include/ddk/ntifs.h @@ -4689,7 +4689,7 @@ FASTCALL KeAcquireQueuedSpinLock( IN OUT KSPIN_LOCK_QUEUE_NUMBER Number); -NTHALAPI +_DECL_HAL_KE_IMPORT VOID FASTCALL KeReleaseQueuedSpinLock( diff --git a/reactos/include/ddk/wdm.h b/reactos/include/ddk/wdm.h index 42607c295a5..2742d758ed8 100644 --- a/reactos/include/ddk/wdm.h +++ b/reactos/include/ddk/wdm.h @@ -1694,7 +1694,7 @@ typedef enum _MM_SYSTEM_SIZE { MmLargeSystem } MM_SYSTEMSIZE; -extern PBOOLEAN Mm64BitPhysicalAddress; +extern NTKERNELAPI BOOLEAN Mm64BitPhysicalAddress; extern PVOID MmBadPointer; @@ -7923,9 +7923,6 @@ KeRaiseIrqlToSynchLevel(VOID) return KfRaiseIrql(12); // SYNCH_LEVEL = IPI_LEVEL - 2 } -#define KeAcquireSpinLock(SpinLock, OldIrql) \ - *(OldIrql) = KeAcquireSpinLockRaiseToDpc(SpinLock) - FORCEINLINE PKTHREAD KeGetCurrentThread(VOID) @@ -9685,7 +9682,6 @@ KeClearEvent( #if (NTDDI_VERSION >= NTDDI_WIN2K) - #if defined(_NTDDK_) || defined(_NTIFS_) NTKERNELAPI VOID @@ -9734,7 +9730,6 @@ KeQueryActiveProcessors(VOID); #endif /* defined(SINGLE_GROUP_LEGACY_API) */ #if !defined(_M_AMD64) - NTKERNELAPI ULONGLONG NTAPI @@ -9745,9 +9740,38 @@ VOID NTAPI KeQuerySystemTime( OUT PLARGE_INTEGER CurrentTime); - #endif /* !_M_AMD64 */ +#if !defined(_X86_) +NTKERNELAPI +KIRQL +NTAPI +KeAcquireSpinLockRaiseToDpc( + IN OUT PKSPIN_LOCK SpinLock); + +#define KeAcquireSpinLock(SpinLock, OldIrql) \ + *(OldIrql) = KeAcquireSpinLockRaiseToDpc(SpinLock) + +NTKERNELAPI +VOID +NTAPI +KeAcquireSpinLockAtDpcLevel( + IN OUT PKSPIN_LOCK SpinLock); + +NTKERNELAPI +VOID +NTAPI +KeReleaseSpinLock( + IN OUT PKSPIN_LOCK SpinLock, + IN KIRQL NewIrql); + +NTKERNELAPI +VOID +NTAPI +KeReleaseSpinLockFromDpcLevel( + IN OUT PKSPIN_LOCK SpinLock); +#endif /* !_X86_ */ + #if defined(_X86_) && (defined(_WDM_INCLUDED_) || defined(WIN9X_COMPAT_SPINLOCK)) NTKERNELAPI VOID @@ -10191,10 +10215,12 @@ FASTCALL KeTestSpinLock( IN PKSPIN_LOCK SpinLock); + #endif /* (NTDDI_VERSION >= NTDDI_WS03) */ #if (NTDDI_VERSION >= NTDDI_WS03SP1) + NTKERNELAPI BOOLEAN FASTCALL @@ -10255,6 +10281,7 @@ KeTryToAcquireGuardedMutex( #endif /* (NTDDI_VERSION >= NTDDI_WS03SP1) */ #if (NTDDI_VERSION >= NTDDI_VISTA) + NTKERNELAPI VOID FASTCALL @@ -10298,7 +10325,7 @@ NTKERNELAPI ULONG NTAPI KeQueryMaximumProcessorCount(VOID); -#endif +#endif /* SINGLE_GROUP_LEGACY_API */ #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ @@ -13270,6 +13297,8 @@ FASTCALL ExInterlockedFlushSList( IN OUT PSLIST_HEADER ListHead); +#endif /* !defined(_WIN64) */ + #if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_) NTKERNELAPI @@ -13300,12 +13329,14 @@ ExFreeToPagedLookasideList( IN OUT PPAGED_LOOKASIDE_LIST Lookaside, IN PVOID Entry); -#else +#else /* !_WIN2K_COMPAT_SLIST_USAGE */ +#if !defined(_WIN64) #define ExInterlockedPopEntrySList(_ListHead, _Lock) \ InterlockedPopEntrySList(_ListHead) #define ExInterlockedPushEntrySList(_ListHead, _ListEntry, _Lock) \ InterlockedPushEntrySList(_ListHead, _ListEntry) +#endif static __inline PVOID @@ -13342,7 +13373,6 @@ ExFreeToPagedLookasideList( #endif /* _WIN2K_COMPAT_SLIST_USAGE */ -#endif /* !defined(_WIN64) */ /* ERESOURCE_THREAD * ExGetCurrentResourceThread( @@ -14565,8 +14595,9 @@ KdChangeOption( #endif /* Hardware Abstraction Layer Functions */ -#if defined(USE_DMA_MACROS) && !defined(_NTHAL_) && (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_) +#if (NTDDI_VERSION >= NTDDI_WIN2K) +#if defined(USE_DMA_MACROS) && !defined(_NTHAL_) && (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_) FORCEINLINE PVOID @@ -14632,9 +14663,8 @@ HalGetDmaAlignment( return alignment; } - - -#endif +#endif /* USE_DMA_MACROS ... */ +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ #ifndef _NTTMAPI_ #define _NTTMAPI_ diff --git a/reactos/include/ndk/amd64/ketypes.h b/reactos/include/ndk/amd64/ketypes.h index f1a3edb593e..8a04f20eaf5 100644 --- a/reactos/include/ndk/amd64/ketypes.h +++ b/reactos/include/ndk/amd64/ketypes.h @@ -877,5 +877,8 @@ KeGetCurrentPrcb(VOID) return (struct _KPRCB *)__readgsqword(FIELD_OFFSET(KIPCR, CurrentPrcb)); } +// HACK +extern NTKERNELAPI volatile KSYSTEM_TIME KeTickCount; + #endif #endif diff --git a/reactos/include/psdk/ktmtypes.h b/reactos/include/psdk/ktmtypes.h index 77cf5782858..90b042f3f0b 100644 --- a/reactos/include/psdk/ktmtypes.h +++ b/reactos/include/psdk/ktmtypes.h @@ -72,7 +72,10 @@ #define MAX_TRANSACTION_DESCRIPTION_LENGTH 64 #define MAX_RESOURCEMANAGER_DESCRIPTION_LENGTH 64 +#ifndef _WDMDDK_ typedef GUID UOW, *PUOW; +#endif + typedef GUID CRM_PROTOCOL_ID, *PCRM_PROTOCOL_ID; typedef ULONG NOTIFICATION_MASK; typedef ULONG SAVEPOINT_ID, *PSAVEPOINT_ID; diff --git a/reactos/include/psdk/ntdef.h b/reactos/include/psdk/ntdef.h index a0aae3ec3a3..e4c53682c55 100644 --- a/reactos/include/psdk/ntdef.h +++ b/reactos/include/psdk/ntdef.h @@ -1,15 +1,13 @@ -#ifndef _NTDEF_H -#define _NTDEF_H +#ifndef _NTDEF_ +#define _NTDEF_ -// -// Dependencies -// +/* Dependencies */ #include #include #include #include -// FIXME: Should we include these here? +// FIXME: Shouldn't be included! #include #include @@ -24,11 +22,8 @@ typedef unsigned long POINTER_64; // FIXME! HACK!!! +/* Pseudo Modifiers for Input Parameters */ - -// -// Pseudo Modifiers for Input Parameters -// #ifndef IN #define IN #endif @@ -54,29 +49,21 @@ typedef unsigned long POINTER_64; // FIXME! HACK!!! #endif -// -// Defines the "size" of an any-size array -// +/* Defines the "size" of an any-size array */ #ifndef ANYSIZE_ARRAY #define ANYSIZE_ARRAY 1 #endif -// -// Constant modifier -// +/* Constant modifier */ #ifndef CONST #define CONST const #endif -// -// TRUE/FALSE -// +/* TRUE/FALSE */ #define FALSE 0 #define TRUE 1 -// -// NULL/NULL64 -// +/* NULL/NULL64 */ #ifndef NULL #ifdef __cplusplus #define NULL 0 @@ -85,22 +72,8 @@ typedef unsigned long POINTER_64; // FIXME! HACK!!! #define NULL ((void *)0) #define NULL64 ((void * POINTER_64)0) #endif -#endif // NULL +#endif /* NULL */ -typedef enum _EVENT_TYPE { - NotificationEvent, - SynchronizationEvent -} EVENT_TYPE; - -typedef enum _TIMER_TYPE { - NotificationTimer, - SynchronizationTimer -} TIMER_TYPE; - -typedef enum _WAIT_TYPE { - WaitAll, - WaitAny -} WAIT_TYPE; // // FIXME @@ -171,35 +144,27 @@ typedef enum _WAIT_TYPE { #define ARGUMENT_PRESENT(ArgumentPointer) \ ((CHAR*)((ULONG_PTR)(ArgumentPointer)) != (CHAR*)NULL) -// -// Returns the base address of a structure from a structure member -// +/* Returns the base address of a structure from a structure member */ #ifndef CONTAINING_RECORD #define CONTAINING_RECORD(address, type, field) \ ((type *)(((ULONG_PTR)address) - (ULONG_PTR)(&(((type *)0)->field)))) #endif -// -// Returns the byte offset of the specified structure's member -// +/* Returns the byte offset of the specified structure's member */ #ifndef __GNUC__ #define FIELD_OFFSET(Type, Field) ((LONG)(LONG_PTR)&(((Type*) 0)->Field)) #else #define FIELD_OFFSET(Type, Field) __builtin_offsetof(Type, Field) #endif -// -// Returns the type's alignment -// +/* Returns the type's alignment */ #if defined(_MSC_VER) && (_MSC_VER >= 1300) #define TYPE_ALIGNMENT(t) __alignof(t) #else #define TYPE_ALIGNMENT(t) FIELD_OFFSET( struct { char x; t test; }, test ) #endif -// -// Calling Conventions -// +/* Calling Conventions */ #if defined(_M_IX86) #define FASTCALL __fastcall #else @@ -214,15 +179,12 @@ typedef enum _WAIT_TYPE { #define DDKAPI __stdcall // Use NTAPI instead #define DDKCDECLAPI __cdecl // Just use __cdecl -// -// Import and Export Specifiers -// +/* Import and Export Specifiers */ -// Done the same way as in windef.h for now +/* Done the same way as in windef.h for now */ #define DECLSPEC_IMPORT __declspec(dllimport) #define DECLSPEC_NORETURN __declspec(noreturn) - #ifndef DECLSPEC_ADDRSAFE #if (_MSC_VER >= 1200) && (defined(_M_ALPHA) || defined(_M_AXP64)) #define DECLSPEC_ADDRSAFE __declspec(address_safe) @@ -243,9 +205,7 @@ typedef enum _WAIT_TYPE { #endif #endif -// -// Inlines -// +/* Inlines */ #ifndef FORCEINLINE #if (_MSC_VER >= 1200) #define FORCEINLINE __forceinline @@ -272,9 +232,7 @@ typedef enum _WAIT_TYPE { #define NTAPI_INLINE #endif -// -// Use to specify structure alignment -// +/* Use to specify structure alignment */ #ifndef DECLSPEC_ALIGN #if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(MIDL_PASS) #define DECLSPEC_ALIGN(x) __declspec(align(x)) @@ -285,21 +243,13 @@ typedef enum _WAIT_TYPE { #endif #endif - - -// -// Use to silence unused variable warnings when it is intentional -// +/* Use to silence unused variable warnings when it is intentional */ #define UNREFERENCED_PARAMETER(P) {(P)=(P);} #define UNREFERENCED_LOCAL_VARIABLE(L) {(L)=(L);} #define DBG_UNREFERENCED_PARAMETER(P) #define DBG_UNREFERENCED_LOCAL_VARIABLE(L) - - -// -// min/max helper macros -// +/* min/max helper macros */ #ifndef NOMINMAX #ifndef min @@ -310,25 +260,17 @@ typedef enum _WAIT_TYPE { #define max(a,b) (((a) > (b)) ? (a) : (b)) #endif -#endif // NOMINMAX +#endif /* NOMINMAX */ - - -// -// Tell windef.h that we have defined some basic types -// +/* Tell windef.h that we have defined some basic types */ #define BASETYPES -// -// Void Pointers -// +/* Void Pointers */ typedef void *PVOID; //typedef void * POINTER_64 PVOID64; typedef PVOID PVOID64; // FIXME! -// -// Handle Type -// +/* Handle Type */ #ifdef STRICT typedef void *HANDLE; #define DECLARE_HANDLE(n) typedef struct n##__{int i;}*n @@ -338,9 +280,7 @@ typedef PVOID HANDLE; #endif typedef HANDLE *PHANDLE; -// -// Upper-Case Versions of Some Standard C Types -// +/* Upper-Case Versions of Some Standard C Types */ #ifndef VOID #define VOID void typedef char CHAR; @@ -352,47 +292,25 @@ typedef int INT; #endif typedef double DOUBLE; -// -// Used to store a non-float 8 byte aligned structure -// -typedef struct _QUAD -{ - _ANONYMOUS_UNION union - { - __GNU_EXTENSION __int64 UseThisFieldToCopy; - double DoNotUseThisField; - }; -} QUAD, *PQUAD, UQUAD, *PUQUAD; - - -// -// Unsigned Types -// +/* Unsigned Types */ typedef unsigned char UCHAR, *PUCHAR; typedef unsigned short USHORT, *PUSHORT; typedef unsigned long ULONG, *PULONG; typedef CONST UCHAR *PCUCHAR; typedef CONST USHORT *PCUSHORT; typedef CONST ULONG *PCULONG; - typedef UCHAR FCHAR; typedef USHORT FSHORT; typedef ULONG FLONG; -typedef UCHAR BOOLEAN; -typedef BOOLEAN *PBOOLEAN; - +typedef UCHAR BOOLEAN, *PBOOLEAN; typedef ULONG LOGICAL; typedef ULONG *PLOGICAL; -// -// Signed Types -// +/* Signed Types */ typedef SHORT *PSHORT; typedef LONG *PLONG; - typedef LONG NTSTATUS; typedef NTSTATUS *PNTSTATUS; - typedef signed char SCHAR; typedef SCHAR *PSCHAR; @@ -401,22 +319,15 @@ typedef SCHAR *PSCHAR; typedef LONG HRESULT; #endif -// -// 64-bit types -// +/* 64-bit types */ __GNU_EXTENSION typedef __int64 LONGLONG, *PLONGLONG; __GNU_EXTENSION typedef unsigned __int64 ULONGLONG, *PULONGLONG; typedef ULONGLONG DWORDLONG, *PDWORDLONG; -// -// Update Sequence Number -// +/* Update Sequence Number */ typedef LONGLONG USN; - -// -// ANSI (Multi-byte Character) types -// +/* ANSI (Multi-byte Character) types */ typedef CHAR *PCHAR, *LPCH, *PCH; typedef CONST CHAR *LPCCH, *PCCH; typedef CHAR *NPSTR, *LPSTR, *PSTR; @@ -425,15 +336,11 @@ typedef CONST PSTR *PCZPSTR; typedef CONST CHAR *LPCSTR, *PCSTR; typedef PCSTR *PZPCSTR; -// -// Pointer to an Asciiz string -// +/* Pointer to an Asciiz string */ typedef CHAR *PSZ; typedef CONST char *PCSZ; -// -// UNICODE (Wide Character) types -// +/* UNICODE (Wide Character) types */ typedef wchar_t WCHAR; typedef WCHAR *PWCHAR, *LPWCH, *PWCH; typedef CONST WCHAR *LPCWCH, *PCWCH; @@ -445,25 +352,27 @@ typedef CONST WCHAR *LPCWSTR, *PCWSTR; typedef PCWSTR *PZPCWSTR; typedef CONST WCHAR UNALIGNED *LPCUWSTR, *PCUWSTR; -// -// Cardinal Data Types -// +/* Cardinal Data Types */ typedef char CCHAR, *PCCHAR; typedef short CSHORT, *PCSHORT; typedef ULONG CLONG, *PCLONG; -// -// NLS basics (Locale and Language Ids) -// +/* NLS basics (Locale and Language Ids) */ typedef ULONG LCID; typedef PULONG PLCID; typedef USHORT LANGID; +/* Used to store a non-float 8 byte aligned structure */ +typedef struct _QUAD +{ + _ANONYMOUS_UNION union + { + __GNU_EXTENSION __int64 UseThisFieldToCopy; + double DoNotUseThisField; + } DUMMYUNIONNAME; +} QUAD, *PQUAD, UQUAD, *PUQUAD; - -// -// Large Integer Unions -// +/* Large Integer Unions */ #if defined(MIDL_PASS) typedef struct _LARGE_INTEGER { #else @@ -478,7 +387,7 @@ typedef union _LARGE_INTEGER { ULONG LowPart; LONG HighPart; } u; -#endif //MIDL_PASS +#endif /* MIDL_PASS */ LONGLONG QuadPart; } LARGE_INTEGER, *PLARGE_INTEGER; @@ -496,40 +405,26 @@ typedef union _ULARGE_INTEGER { ULONG LowPart; ULONG HighPart; } u; -#endif //MIDL_PASS +#endif /* MIDL_PASS */ ULONGLONG QuadPart; } ULARGE_INTEGER, *PULARGE_INTEGER; -// -// Physical Addresses are always treated as 64-bit wide -// +/* Physical Addresses are always treated as 64-bit wide */ typedef LARGE_INTEGER PHYSICAL_ADDRESS, *PPHYSICAL_ADDRESS; - - -// -// Locally Unique Identifier -// +/* Locally Unique Identifier */ typedef struct _LUID { ULONG LowPart; LONG HighPart; } LUID, *PLUID; - - -// -// Native API Return Value Macros -// +/* Native API Return Value Macros */ #define NT_SUCCESS(Status) (((NTSTATUS)(Status)) >= 0) #define NT_INFORMATION(Status) ((((ULONG)(Status)) >> 30) == 1) #define NT_WARNING(Status) ((((ULONG)(Status)) >> 30) == 2) #define NT_ERROR(Status) ((((ULONG)(Status)) >> 30) == 3) - - -// -// String Types -// +/* String Types */ typedef struct _UNICODE_STRING { USHORT Length; USHORT MaximumLength; @@ -575,9 +470,7 @@ typedef struct _STRING64 { UNICODE_STRING64, *PUNICODE_STRING64, ANSI_STRING64, *PANSI_STRING64; -// -// LangID and NLS -// +/* LangID and NLS */ #define MAKELANGID(p, s) ((((USHORT)(s)) << 10) | (USHORT)(p)) #define PRIMARYLANGID(lgid) ((USHORT)(lgid) & 0x3ff) #define SUBLANGID(lgid) ((USHORT)(lgid) >> 10) @@ -594,10 +487,7 @@ typedef struct _STRING64 { #define SORTVERSIONFROMLCID(lcid) ((USHORT)((((ULONG)(lcid)) >> 20) & 0xf)) - -// -// Object Attributes -// +/* Object Attributes */ typedef struct _OBJECT_ATTRIBUTES { ULONG Length; HANDLE RootDirectory; @@ -608,9 +498,7 @@ typedef struct _OBJECT_ATTRIBUTES { } OBJECT_ATTRIBUTES, *POBJECT_ATTRIBUTES; typedef CONST OBJECT_ATTRIBUTES *PCOBJECT_ATTRIBUTES; -// -// Values for the Attributes member -// +/* Values for the Attributes member */ #define OBJ_INHERIT 0x00000002 #define OBJ_PERMANENT 0x00000010 #define OBJ_EXCLUSIVE 0x00000020 @@ -621,9 +509,7 @@ typedef CONST OBJECT_ATTRIBUTES *PCOBJECT_ATTRIBUTES; #define OBJ_FORCE_ACCESS_CHECK 0x00000400 #define OBJ_VALID_ATTRIBUTES 0x000007F2 -// -// Helper Macro -// +/* Helper Macro */ #define InitializeObjectAttributes(p,n,a,r,s) { \ (p)->Length = sizeof(OBJECT_ATTRIBUTES); \ (p)->RootDirectory = (r); \ @@ -633,22 +519,29 @@ typedef CONST OBJECT_ATTRIBUTES *PCOBJECT_ATTRIBUTES; (p)->SecurityQualityOfService = NULL; \ } - - -// -// Product Types -// +/* Product Types */ typedef enum _NT_PRODUCT_TYPE { NtProductWinNt = 1, NtProductLanManNt, NtProductServer } NT_PRODUCT_TYPE, *PNT_PRODUCT_TYPE; +typedef enum _EVENT_TYPE { + NotificationEvent, + SynchronizationEvent +} EVENT_TYPE; +typedef enum _TIMER_TYPE { + NotificationTimer, + SynchronizationTimer +} TIMER_TYPE; -// -// Doubly Linked Lists -// +typedef enum _WAIT_TYPE { + WaitAll, + WaitAny +} WAIT_TYPE; + +/* Doubly Linked Lists */ typedef struct _LIST_ENTRY { struct _LIST_ENTRY *Flink; struct _LIST_ENTRY *Blink; @@ -666,14 +559,11 @@ typedef struct LIST_ENTRY64 ULONGLONG Blink; } LIST_ENTRY64, *PLIST_ENTRY64; -// -// Singly Linked Lists -// +/* Singly Linked Lists */ typedef struct _SINGLE_LIST_ENTRY { struct _SINGLE_LIST_ENTRY *Next; } SINGLE_LIST_ENTRY, *PSINGLE_LIST_ENTRY; - typedef struct _PROCESSOR_NUMBER { USHORT Group; UCHAR Number; @@ -681,16 +571,19 @@ typedef struct _PROCESSOR_NUMBER { } PROCESSOR_NUMBER, *PPROCESSOR_NUMBER; typedef EXCEPTION_DISPOSITION -(DDKAPI *PEXCEPTION_ROUTINE)( +(NTAPI *PEXCEPTION_ROUTINE)( IN struct _EXCEPTION_RECORD *ExceptionRecord, IN PVOID EstablisherFrame, IN OUT struct _CONTEXT *ContextRecord, IN OUT PVOID DispatcherContext); +typedef struct _GROUP_AFFINITY { + KAFFINITY Mask; + USHORT Group; + USHORT Reserved[3]; +} GROUP_AFFINITY, *PGROUP_AFFINITY; -// -// Helper Macros -// +/* Helper Macros */ #define RTL_CONSTANT_STRING(s) { sizeof(s)-sizeof((s)[0]), sizeof(s), s } #define RTL_FIELD_SIZE(type, field) (sizeof(((type *)0)->field)) @@ -704,11 +597,7 @@ typedef EXCEPTION_DISPOSITION #endif #define ARRAYSIZE(A) RTL_NUMBER_OF_V2(A) - - -// -// Type Limits -// +/* Type Limits */ #define MINCHAR 0x80 #define MAXCHAR 0x7f #define MINSHORT 0x8000 @@ -720,29 +609,17 @@ typedef EXCEPTION_DISPOSITION #define MAXULONG 0xffffffff #define MAXLONGLONG (0x7fffffffffffffffLL) - - -// -// Multiplication and Shift Operations -// +/* Multiplication and Shift Operations */ #define Int32x32To64(a,b) ((LONGLONG)(a)*(LONGLONG)(b)) #define UInt32x32To64(a,b) ((DWORDLONG)(a)*(DWORDLONG)(b)) #define Int64ShllMod32(a,b) ((DWORDLONG)(a)<<(b)) #define Int64ShraMod32(a,b) ((LONGLONG)(a)>>(b)) #define Int64ShrlMod32(a,b) ((DWORDLONG)(a)>>(b)) - - -// -// C_ASSERT Definition -// +/* C_ASSERT Definition */ #define C_ASSERT(expr) extern char (*c_assert(void)) [(expr) ? 1 : -1] - - -// -// Primary language IDs. -// +/* Primary language IDs. */ #define LANG_NEUTRAL 0x00 #define LANG_INVARIANT 0x7f @@ -873,6 +750,4 @@ typedef EXCEPTION_DISPOSITION #define LANG_YORUBA 0x6a #define LANG_ZULU 0x35 - - -#endif /* _NTDEF_H */ +#endif /* _NTDEF_ */ From 84e3ee3768f6f2fdfdd00018fa3be05552dcac9e Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Wed, 24 Mar 2010 20:26:54 +0000 Subject: [PATCH 010/134] [NTOS] - fix ExInterlockedPopEntryList and ExInterlockedPushEntryList - Update amd64/mm.h and mm/amd64/init.c to reflect latest trunk changes - make freelist.c compile again svn path=/branches/ros-amd64-bringup/; revision=46403 --- reactos/ntoskrnl/ex/amd64/fastinterlck.c | 9 +- reactos/ntoskrnl/include/internal/amd64/mm.h | 94 ++++++++++++-------- reactos/ntoskrnl/mm/amd64/init.c | 64 ++++++------- reactos/ntoskrnl/mm/amd64/page.c | 5 +- reactos/ntoskrnl/mm/freelist.c | 43 +++++---- 5 files changed, 117 insertions(+), 98 deletions(-) diff --git a/reactos/ntoskrnl/ex/amd64/fastinterlck.c b/reactos/ntoskrnl/ex/amd64/fastinterlck.c index dbd9564327e..b9ca32aab1b 100644 --- a/reactos/ntoskrnl/ex/amd64/fastinterlck.c +++ b/reactos/ntoskrnl/ex/amd64/fastinterlck.c @@ -79,11 +79,11 @@ ExInterlockedPopEntryList(IN PSINGLE_LIST_ENTRY ListHead, IN PKSPIN_LOCK Lock) { KIRQL OldIrql; - PSINGLE_LIST_ENTRY OldHead = NULL; + PSINGLE_LIST_ENTRY FirstEntry; KeAcquireSpinLock(Lock, &OldIrql); - if (!ListHead->Next) OldHead = PopEntryList(ListHead); + FirstEntry = PopEntryList(ListHead); KeReleaseSpinLock(Lock, OldIrql); - return OldHead; + return FirstEntry; } PSINGLE_LIST_ENTRY @@ -94,7 +94,8 @@ ExInterlockedPushEntryList(IN PSINGLE_LIST_ENTRY ListHead, KIRQL OldIrql; PSINGLE_LIST_ENTRY OldHead = NULL; KeAcquireSpinLock(Lock, &OldIrql); - if (!ListHead->Next) OldHead = PushEntryList(ListHead, ListEntry); + OldHead = ListHead->Next; + PushEntryList(ListHead, ListEntry); KeReleaseSpinLock(Lock, OldIrql); return OldHead; } diff --git a/reactos/ntoskrnl/include/internal/amd64/mm.h b/reactos/ntoskrnl/include/internal/amd64/mm.h index eb1ef0f6ff9..a1952915416 100644 --- a/reactos/ntoskrnl/include/internal/amd64/mm.h +++ b/reactos/ntoskrnl/include/internal/amd64/mm.h @@ -2,8 +2,7 @@ * Lowlevel memory managment definitions */ -#ifndef __NTOSKRNL_INCLUDE_INTERNAL_AMD64_MM_H -#define __NTOSKRNL_INCLUDE_INTERNAL_AMD64_MM_H +#pragma once /* Helper macros */ #define PAGE_MASK(x) ((x)&(~0xfff)) @@ -22,8 +21,25 @@ #define MI_NONPAGED_POOL_END (PVOID)0xFFFFFAE000000000ULL #define MI_DEBUG_MAPPING (PVOID)0xFFFFFFFF80000000ULL // FIXME #define MI_HIGHEST_SYSTEM_ADDRESS (PVOID)0xFFFFFFFFFFFFFFFFULL +#define MI_SYSTEM_CACHE_WS_START (PVOID)0xFFFFF78000001000ULL // CHECKME - +/* Memory sizes */ +#define MI_MIN_PAGES_FOR_NONPAGED_POOL_TUNING ((255*1024*1024) >> PAGE_SHIFT) +#define MI_MIN_PAGES_FOR_SYSPTE_TUNING ((19*1024*1024) >> PAGE_SHIFT) +#define MI_MIN_PAGES_FOR_SYSPTE_BOOST ((32*1024*1024) >> PAGE_SHIFT) +#define MI_MAX_INIT_NONPAGED_POOL_SIZE (128ULL * 1024 * 1024 * 1024) +#define MI_MAX_NONPAGED_POOL_SIZE (128ULL * 1024 * 1024 * 1024) +#define MI_MAX_FREE_PAGE_LISTS 4 +#define MI_MIN_INIT_PAGED_POOLSIZE (32 * 1024 * 1024) +#define MI_SESSION_VIEW_SIZE (20 * 1024 * 1024) +#define MI_SESSION_POOL_SIZE (16 * 1024 * 1024) +#define MI_SESSION_IMAGE_SIZE (8 * 1024 * 1024) +#define MI_SESSION_WORKING_SET_SIZE (4 * 1024 * 1024) +#define MI_SESSION_SIZE (MI_SESSION_VIEW_SIZE + \ + MI_SESSION_POOL_SIZE + \ + MI_SESSION_IMAGE_SIZE + \ + MI_SESSION_WORKING_SET_SIZE) +#define MI_SYSTEM_VIEW_SIZE (16 * 1024 * 1024) #define MI_NUMBER_SYSTEM_PTES 22000 PULONG64 @@ -53,21 +69,23 @@ MiAddressToPpe(PVOID Address) PMMPTE FORCEINLINE -MiAddressToPde(PVOID Address) +_MiAddressToPde(PVOID Address) { ULONG64 Offset = (ULONG64)Address >> (PDI_SHIFT - 3); Offset &= 0x7FFFFFF << 3; return (PMMPTE)(PDE_BASE + Offset); } +#define MiAddressToPde(x) _MiAddressToPde((PVOID)(x)) PMMPTE FORCEINLINE -MiAddressToPte(PVOID Address) +_MiAddressToPte(PVOID Address) { ULONG64 Offset = (ULONG64)Address >> (PTI_SHIFT - 3); Offset &= 0xFFFFFFFFFULL << 3; return (PMMPTE)(PTE_BASE + Offset); } +#define MiAddressToPte(x) _MiAddressToPte((PVOID)(x)) /* Convert a PTE into a corresponding address */ PVOID @@ -90,9 +108,9 @@ MiIsPdeForAddressValid(PVOID Address) (MiAddressToPde(Address)->u.Hard.Valid)); } -//#define ADDR_TO_PAGE_TABLE(v) (((ULONG)(v)) / (1024 * PAGE_SIZE)) -//#define ADDR_TO_PDE_OFFSET(v) ((((ULONG)(v)) / (1024 * PAGE_SIZE))) -//#define ADDR_TO_PTE_OFFSET(v) ((((ULONG)(v)) % (1024 * PAGE_SIZE)) / PAGE_SIZE) +#define ADDR_TO_PAGE_TABLE(v) (((ULONG_PTR)(v)) / (512 * PAGE_SIZE)) +#define ADDR_TO_PDE_OFFSET(v) ((((ULONG_PTR)(v)) / (512 * PAGE_SIZE))) +#define ADDR_TO_PTE_OFFSET(v) ((((ULONG_PTR)(v)) % (512 * PAGE_SIZE)) / PAGE_SIZE) #define VAtoPXI(va) ((((ULONG64)va) >> PXI_SHIFT) & 0x1FF) #define VAtoPPI(va) ((((ULONG64)va) >> PPI_SHIFT) & 0x1FF) @@ -117,8 +135,6 @@ MmInitGlobalKernelPageDirectory(VOID) #define IS_ALIGNED(addr, align) (((ULONG64)(addr) & (align - 1)) == 0) #define IS_PAGE_ALIGNED(addr) IS_ALIGNED(addr, PAGE_SIZE) -/// MIARM.H - /* Easy accessing PFN in PTE */ #define PFN_FROM_PTE(v) ((v)->u.Hard.PageFrameNumber) @@ -128,43 +144,47 @@ MmInitGlobalKernelPageDirectory(VOID) #define MI_PAGE_DISABLE_CACHE(x) ((x)->u.Hard.CacheDisable = 1) #define MI_PAGE_WRITE_THROUGH(x) ((x)->u.Hard.WriteThrough = 1) #define MI_PAGE_WRITE_COMBINED(x) ((x)->u.Hard.WriteThrough = 0) +#if !defined(CONFIG_SMP) #define MI_IS_PAGE_WRITEABLE(x) ((x)->u.Hard.Write == 1) +#else +#define MI_IS_PAGE_WRITEABLE(x) ((x)->u.Hard.Writable == 1) +#endif #define MI_IS_PAGE_COPY_ON_WRITE(x)((x)->u.Hard.CopyOnWrite == 1) #define MI_IS_PAGE_DIRTY(x) ((x)->u.Hard.Dirty == 1) #define MI_MAKE_OWNER_PAGE(x) ((x)->u.Hard.Owner = 1) +#if !defined(CONFIG_SMP) #define MI_MAKE_WRITE_PAGE(x) ((x)->u.Hard.Write = 1) +#else +#define MI_MAKE_WRITE_PAGE(x) ((x)->u.Hard.Writable = 1) +#endif +#if 0 // FIXME +#define PAGE_TO_SECTION_PAGE_DIRECTORY_OFFSET(x) \ + ((x) / (4*1024*1024)) -#define MI_MIN_PAGES_FOR_NONPAGED_POOL_TUNING ((255*1024*1024) >> PAGE_SHIFT) -#define MI_MIN_PAGES_FOR_SYSPTE_TUNING ((19*1024*1024) >> PAGE_SHIFT) -#define MI_MIN_PAGES_FOR_SYSPTE_BOOST ((32*1024*1024) >> PAGE_SHIFT) -#define MI_MAX_INIT_NONPAGED_POOL_SIZE (128ULL * 1024 * 1024 * 1024) -#define MI_MAX_NONPAGED_POOL_SIZE (128ULL * 1024 * 1024 * 1024) -#define MI_MAX_FREE_PAGE_LISTS 4 +#define PAGE_TO_SECTION_PAGE_TABLE_OFFSET(x) \ + ((((x)) % (4*1024*1024)) / (4*1024)) +#endif -#define MI_MIN_INIT_PAGED_POOLSIZE (32 * 1024 * 1024) +#define NR_SECTION_PAGE_TABLES 1024 +#define NR_SECTION_PAGE_ENTRIES 1024 -#define MI_SESSION_VIEW_SIZE (20 * 1024 * 1024) -#define MI_SESSION_POOL_SIZE (16 * 1024 * 1024) -#define MI_SESSION_IMAGE_SIZE (8 * 1024 * 1024) -#define MI_SESSION_WORKING_SET_SIZE (4 * 1024 * 1024) -#define MI_SESSION_SIZE (MI_SESSION_VIEW_SIZE + \ - MI_SESSION_POOL_SIZE + \ - MI_SESSION_IMAGE_SIZE + \ - MI_SESSION_WORKING_SET_SIZE) +//#define TEB_BASE 0x7FFDE000 -#define MI_SYSTEM_VIEW_SIZE (16 * 1024 * 1024) +#define MI_HYPERSPACE_PTES (256 - 1) +#define MI_ZERO_PTES (32) +#define MI_MAPPING_RANGE_START (ULONG)HYPER_SPACE +#define MI_MAPPING_RANGE_END (MI_MAPPING_RANGE_START + \ + MI_HYPERSPACE_PTES * PAGE_SIZE) +#define MI_ZERO_PTE (PMMPTE)(MI_MAPPING_RANGE_END + \ + PAGE_SIZE) - -#define MM_HIGHEST_VAD_ADDRESS \ - (PVOID)((ULONG_PTR)MM_HIGHEST_USER_ADDRESS - (16 * PAGE_SIZE)) +/* On x86, these two are the same */ +#define MMPDE MMPTE +#define PMMPDE PMMPTE +/* +* FIXME - different architectures have different cache line sizes... +*/ +#define MM_CACHE_LINE_SIZE 32 -// -// FIXFIX: These should go in ex.h after the pool merge -// -#define POOL_LISTS_PER_PAGE (PAGE_SIZE / sizeof(LIST_ENTRY)) -#define BASE_POOL_TYPE_MASK 1 -#define POOL_MAX_ALLOC (PAGE_SIZE - (sizeof(POOL_HEADER) + sizeof(LIST_ENTRY))) - -#endif /* __NTOSKRNL_INCLUDE_INTERNAL_AMD64_MM_H */ diff --git a/reactos/ntoskrnl/mm/amd64/init.c b/reactos/ntoskrnl/mm/amd64/init.c index 4555478b39c..e740ef78bb4 100644 --- a/reactos/ntoskrnl/mm/amd64/init.c +++ b/reactos/ntoskrnl/mm/amd64/init.c @@ -27,21 +27,21 @@ HalInitializeBios(ULONG Unknown, PLOADER_PARAMETER_BLOCK LoaderBlock); /* GLOBALS *****************************************************************/ /* Sizes */ -ULONG64 MmBootImageSize; -ULONG64 MmMinimumNonPagedPoolSize = 256 * 1024; -ULONG64 MmSizeOfNonPagedPoolInBytes; -ULONG64 MmMaximumNonPagedPoolInBytes; -ULONG64 MmMaximumNonPagedPoolPercent; -ULONG64 MmMinAdditionNonPagedPoolPerMb = 32 * 1024; -ULONG64 MmMaxAdditionNonPagedPoolPerMb = 400 * 1024; -ULONG64 MmDefaultMaximumNonPagedPool = 1024 * 1024; -ULONG64 MmSessionSize = MI_SESSION_SIZE; -ULONG64 MmSessionViewSize = MI_SESSION_VIEW_SIZE; -ULONG64 MmSessionPoolSize = MI_SESSION_POOL_SIZE; -ULONG64 MmSessionImageSize = MI_SESSION_IMAGE_SIZE; -ULONG64 MmSystemViewSize = MI_SYSTEM_VIEW_SIZE; -ULONG64 MmSizeOfPagedPoolInBytes = MI_MIN_INIT_PAGED_POOLSIZE; -ULONG64 MiNonPagedSystemSize; +//SIZE_T MmBootImageSize; +//SIZE_T MmMinimumNonPagedPoolSize = 256 * 1024; +//SIZE_T MmSizeOfNonPagedPoolInBytes; +//SIZE_T MmMaximumNonPagedPoolInBytes; +//ULONG MmMaximumNonPagedPoolPercent; +//ULONG MmMinAdditionNonPagedPoolPerMb = 32 * 1024; +//ULONG MmMaxAdditionNonPagedPoolPerMb = 400 * 1024; +//SIZE_T MmDefaultMaximumNonPagedPool = 1024 * 1024; +//SIZE_T MmSessionSize = MI_SESSION_SIZE; +SIZE_T MmSessionViewSize = MI_SESSION_VIEW_SIZE; +SIZE_T MmSessionPoolSize = MI_SESSION_POOL_SIZE; +SIZE_T MmSessionImageSize = MI_SESSION_IMAGE_SIZE; +SIZE_T MmSystemViewSize = MI_SYSTEM_VIEW_SIZE; +//SIZE_T MmSizeOfPagedPoolInBytes = MI_MIN_INIT_PAGED_POOLSIZE; +SIZE_T MiNonPagedSystemSize; /* Address ranges */ ULONG64 MmUserProbeAddress = 0x7FFFFFF0000ULL; @@ -57,24 +57,24 @@ PVOID MiSessionImageEnd; // FFFFF98000000000 = MiSessionS PVOID MiSessionSpaceEnd = MI_SESSION_SPACE_END; // FFFFF98000000000 PVOID MmSystemCacheStart; // FFFFF98000000000 PVOID MmSystemCacheEnd; // FFFFFA8000000000 -PVOID MmPagedPoolStart = MI_PAGED_POOL_START; // FFFFFA8000000000 +/// PVOID MmPagedPoolStart = MI_PAGED_POOL_START; // FFFFFA8000000000 PVOID MmPagedPoolEnd; // FFFFFAA000000000 PVOID MiSystemViewStart; PVOID MmNonPagedSystemStart; // FFFFFAA000000000 PVOID MmNonPagedPoolStart; PVOID MmNonPagedPoolExpansionStart; -PVOID MmNonPagedPoolEnd = MI_NONPAGED_POOL_END; // 0xFFFFFAE000000000 +///PVOID MmNonPagedPoolEnd = MI_NONPAGED_POOL_END; // 0xFFFFFAE000000000 PVOID MmHyperSpaceEnd = (PVOID)HYPER_SPACE_END; -PPHYSICAL_MEMORY_DESCRIPTOR MmPhysicalMemoryBlock; -ULONG MmNumberOfPhysicalPages, MmHighestPhysicalPage, MmLowestPhysicalPage = -1; // FIXME: ULONG64 +//PPHYSICAL_MEMORY_DESCRIPTOR MmPhysicalMemoryBlock; +//ULONG MmNumberOfPhysicalPages, MmHighestPhysicalPage, MmLowestPhysicalPage = -1; // FIXME: ULONG64 -ULONG MmNumberOfSystemPtes; -PMMPTE MmSystemPagePtes; +//ULONG MmNumberOfSystemPtes; +//PMMPTE MmSystemPagePtes; MMSUPPORT MmSystemCacheWs; -RTL_BITMAP MiPfnBitMap; -ULONG64 MxPfnAllocation; +//RTL_BITMAP MiPfnBitMap; +//ULONG64 MxPfnAllocation; ULONG64 MxPfnSizeInBytes; PMEMORY_ALLOCATION_DESCRIPTOR MxFreeDescriptor; @@ -86,8 +86,8 @@ BOOLEAN MiIncludeType[LoaderMaximum]; PFN_NUMBER MxFreePageBase; ULONG64 MxFreePageCount = 0; -PFN_NUMBER MmSystemPageDirectory; -PFN_NUMBER MmSizeOfPagedPoolInPages = MI_MIN_INIT_PAGED_POOLSIZE / PAGE_SIZE; +extern PFN_NUMBER MmSystemPageDirectory; +//PFN_NUMBER MmSizeOfPagedPoolInPages = MI_MIN_INIT_PAGED_POOLSIZE / PAGE_SIZE; BOOLEAN MiPfnsInitialized = FALSE; @@ -187,7 +187,7 @@ MiEarlyAllocPage() if (MiPfnsInitialized) { - return MmAllocPage(MC_SYSTEM, 0); + return MmAllocPage(MC_SYSTEM); } /* Make sure we have enough pages */ @@ -308,7 +308,7 @@ MiPreparePfnDatabse(IN PLOADER_PARAMETER_BLOCK LoaderBlock) MxPfnAllocation = MxPfnSizeInBytes >> PAGE_SHIFT; /* Simply start at hardcoded address */ - MmPfnDatabase = MI_PFN_DATABASE; + MmPfnDatabase[1] = MI_PFN_DATABASE; /* Loop the memory descriptors */ for (ListEntry = LoaderBlock->MemoryDescriptorListHead.Flink; @@ -552,7 +552,7 @@ MiBuildNonPagedPool(VOID) } /* Initialize the ARM3 nonpaged pool */ - MiInitializeArmPool(); + MiInitializeNonPagedPool(); /* Initialize the nonpaged pool */ InitializePool(NonPagedPool, 0); @@ -693,7 +693,7 @@ MiBuildPhysicalMemoryBlock(IN PLOADER_PARAMETER_BLOCK LoaderBlock) VOID NTAPI -MiBuildPagedPool(VOID) +MiBuildPagedPool_x(VOID) { PMMPTE Pte; MMPTE TmplPte; @@ -737,7 +737,7 @@ MiBuildPagedPool(VOID) if (!Pte->u.Flush.Valid) { /* Map it! */ - TmplPte.u.Flush.PageFrameNumber = MmAllocPage(MC_SYSTEM, 0); + TmplPte.u.Flush.PageFrameNumber = MmAllocPage(MC_SYSTEM); *Pte = TmplPte; } @@ -817,7 +817,7 @@ MiBuildPagedPool(VOID) NTSTATUS NTAPI -MmArmInitSystem(IN ULONG Phase, +MmArmInitSystem_x(IN ULONG Phase, IN PLOADER_PARAMETER_BLOCK LoaderBlock) { if (Phase == 0) @@ -829,7 +829,7 @@ MmArmInitSystem(IN ULONG Phase, MiEvaluateMemoryDescriptors(LoaderBlock); /* Start PFN database at hardcoded address */ - MmPfnDatabase = MI_PFN_DATABASE; + MmPfnDatabase[1] = MI_PFN_DATABASE; /* Prepare PFN database mappings */ MiPreparePfnDatabse(LoaderBlock); diff --git a/reactos/ntoskrnl/mm/amd64/page.c b/reactos/ntoskrnl/mm/amd64/page.c index a96e519140a..bc15126eff6 100644 --- a/reactos/ntoskrnl/mm/amd64/page.c +++ b/reactos/ntoskrnl/mm/amd64/page.c @@ -15,7 +15,7 @@ #undef InterlockedExchangePte #define InterlockedExchangePte(pte1, pte2) \ - InterlockedExchange64(&pte1->u.Long, pte2.u.Long) + InterlockedExchange64((LONG64*)&pte1->u.Long, pte2.u.Long) #define PAGE_EXECUTE_ANY (PAGE_EXECUTE|PAGE_EXECUTE_READ|PAGE_EXECUTE_READWRITE|PAGE_EXECUTE_WRITECOPY) #define PAGE_WRITE_ANY (PAGE_EXECUTE_READWRITE|PAGE_READWRITE|PAGE_EXECUTE_WRITECOPY|PAGE_WRITECOPY) @@ -251,7 +251,6 @@ NTAPI MmGetPageProtect(PEPROCESS Process, PVOID Address) { MMPTE Pte; - ULONG Protect; Pte.u.Long = MiGetPteValueForProcess(Process, Address); @@ -362,7 +361,7 @@ MmDeleteVirtualMapping( if (Pte) { /* Atomically set the entry to zero and get the old value. */ - OldPte.u.Long = InterlockedExchange64(&Pte->u.Long, 0); + OldPte.u.Long = InterlockedExchange64((LONG64*)&Pte->u.Long, 0); if (OldPte.u.Hard.Valid) { diff --git a/reactos/ntoskrnl/mm/freelist.c b/reactos/ntoskrnl/mm/freelist.c index 0221fc77721..8eaecc46c6e 100644 --- a/reactos/ntoskrnl/mm/freelist.c +++ b/reactos/ntoskrnl/mm/freelist.c @@ -27,14 +27,9 @@ // // ReactOS to NT Physical Page Descriptor Entry Legacy Mapping Definitions // -// REACTOS NT -// -#define RmapListHead AweReferenceCount -#define PHYSICAL_PAGE MMPFN -#define PPHYSICAL_PAGE PMMPFN - -/* The first array contains ReactOS PFNs, the second contains ARM3 PFNs */ -PPHYSICAL_PAGE MmPfnDatabase[2]; +typedef union +{ + MMPFN;// Pfn; struct { @@ -61,18 +56,22 @@ PPHYSICAL_PAGE MmPfnDatabase[2]; C_ASSERT(sizeof(PHYSICAL_PAGE) == sizeof(MMPFN)); -#define MiGetPfnEntry(Pfn) ((PPHYSICAL_PAGE)MiGetPfnEntry(Pfn)) +//#define MiGetPfnEntry(Pfn) ((PPHYSICAL_PAGE)MiGetPfnEntry(Pfn)) #define MiGetPfnEntryIndex(x) MiGetPfnEntryIndex((struct _MMPFN*)x) #define LockCount Flags.LockCount -PMMPFN MmPfnDatabase; -#define MmPfnDatabase ((PPHYSICAL_PAGE)MmPfnDatabase) +/* The first array contains ReactOS PFNs, the second contains ARM3 PFNs */ +PMMPFN MmPfnDatabase[2]; +#define MmPfnDatabase ((PPHYSICAL_PAGE*)MmPfnDatabase) -#define MMPFN PHYSICAL_PAGE -#define PMMPFN PPHYSICAL_PAGE +//#define MMPFN PHYSICAL_PAGE +//#define PMMPFN PPHYSICAL_PAGE -ULONG MmAvailablePages; -ULONG MmResidentAvailablePages; +/* The first array contains ReactOS PFNs, the second contains ARM3 PFNs */ +//PPHYSICAL_PAGE MmPfnDatabase[2]; + +PFN_NUMBER MmAvailablePages; +PFN_NUMBER MmResidentAvailablePages; SIZE_T MmTotalCommitLimit; SIZE_T MmTotalCommittedPages; @@ -108,7 +107,7 @@ MiInitializeUserPfnBitmap(VOID) RtlClearAllBits(&MiUserPfnBitMap); } -PFN_TYPE +PFN_NUMBER NTAPI MmGetLRUFirstUserPage(VOID) { @@ -371,7 +370,7 @@ MiAllocatePagesForMdl(IN PHYSICAL_ADDRESS LowAddress, PFN_NUMBER PageCount, LowPage, HighPage, SkipPages, PagesFound = 0, Page; PPFN_NUMBER MdlPage, LastMdlPage; KIRQL OldIrql; - PPHYSICAL_PAGE Pfn1; + PMMPFN Pfn1; INT LookForZeroedPages; ASSERT (KeGetCurrentIrql() <= APC_LEVEL); @@ -608,7 +607,7 @@ NTAPI MmDumpPfnDatabase(VOID) { ULONG i; - PPHYSICAL_PAGE Pfn1; + PMMPFN Pfn1; PCHAR State = "????", Type = "Unknown"; KIRQL OldIrql; ULONG Totals[5] = {0}, FreePages = 0; @@ -646,7 +645,7 @@ MmDumpPfnDatabase(VOID) State, Type, Pfn1->u3.e2.ReferenceCount, - Pfn1->RmapListHead); + ((PPHYSICAL_PAGE)Pfn1)->RmapListHead); } DbgPrint("Nonpaged Pool: %d pages\t[%d KB]\n", Totals[MC_NPPOOL], (Totals[MC_NPPOOL] << PAGE_SHIFT) / 1024); @@ -742,7 +741,7 @@ MmSetRmapListHeadPage(PFN_NUMBER Pfn, struct _MM_RMAP_ENTRY* ListHead) KIRQL oldIrql; oldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock); - MiGetPfnEntry(Pfn)->RmapListHead = (LONG_PTR)ListHead; + ((PPHYSICAL_PAGE)MiGetPfnEntry(Pfn))->RmapListHead = (LONG_PTR)ListHead; KeReleaseQueuedSpinLock(LockQueuePfnLock, oldIrql); } @@ -754,7 +753,7 @@ MmGetRmapListHeadPage(PFN_NUMBER Pfn) struct _MM_RMAP_ENTRY* ListHead; oldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock); - ListHead = (struct _MM_RMAP_ENTRY*)MiGetPfnEntry(Pfn)->RmapListHead; + ListHead = (struct _MM_RMAP_ENTRY*)((PPHYSICAL_PAGE)MiGetPfnEntry(Pfn))->RmapListHead; KeReleaseQueuedSpinLock(LockQueuePfnLock, oldIrql); return(ListHead); @@ -833,7 +832,7 @@ MmIsPageInUse(PFN_NUMBER Pfn) VOID NTAPI -MiSetConsumer(IN PFN_TYPE Pfn, +MiSetConsumer(IN PFN_NUMBER Pfn, IN ULONG Type) { MiGetPfnEntry(Pfn)->u3.e1.PageLocation = ActiveAndValid; From 55648f149b6f1761a808b25f8bf97fdb794ef0bf Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Wed, 24 Mar 2010 20:36:12 +0000 Subject: [PATCH 011/134] [NTOS] - Multiple ULONG -> SIZE_T fixes - Use SLIST_ENTRY, not SINGLE_LIST_ENTRY in InterlockedPushEntrySList, they are not the same! - Fix InterlockedCompareExchangePointer usage - _1MB is 1024 KB, not 1000 - Rename PDE_SIZE to PD_SIZE to reflect it's purpose (size of a page directory, not a page directory entry) - Add PD_COUNT, PDE_COUNT and PTE_COUNT for amd64 (should rather use PTE_PER_PAGE etc and move them to arch specific files. - Some more PFN_TYPE -> PFN_NUMBER svn path=/branches/ros-amd64-bringup/; revision=46404 --- reactos/ntoskrnl/include/internal/mm.h | 24 +++++++++--------- reactos/ntoskrnl/io/iomgr/iocomp.c | 2 +- reactos/ntoskrnl/io/iomgr/irp.c | 2 +- reactos/ntoskrnl/ke/bug.c | 2 +- reactos/ntoskrnl/mm/ARM3/contmem.c | 2 +- reactos/ntoskrnl/mm/ARM3/iosup.c | 2 +- reactos/ntoskrnl/mm/ARM3/miarm.h | 34 ++++++++++++++------------ reactos/ntoskrnl/mm/ARM3/mminit.c | 30 +++++++++++------------ reactos/ntoskrnl/mm/ARM3/ncache.c | 2 +- reactos/ntoskrnl/mm/ARM3/procsup.c | 2 +- reactos/ntoskrnl/mm/ARM3/virtual.c | 2 +- reactos/ntoskrnl/mm/balance.c | 2 +- reactos/ntoskrnl/mm/pagefile.c | 6 ++--- reactos/ntoskrnl/mm/ppool.c | 4 +-- 14 files changed, 59 insertions(+), 57 deletions(-) diff --git a/reactos/ntoskrnl/include/internal/mm.h b/reactos/ntoskrnl/include/internal/mm.h index 3c67357ae7b..6ec931514bf 100644 --- a/reactos/ntoskrnl/include/internal/mm.h +++ b/reactos/ntoskrnl/include/internal/mm.h @@ -6,22 +6,22 @@ struct _EPROCESS; -extern ULONG MiFreeSwapPages; -extern ULONG MiUsedSwapPages; -extern ULONG MmPagedPoolSize; -extern ULONG MmTotalPagedPoolQuota; -extern ULONG MmTotalNonPagedPoolQuota; +extern PFN_NUMBER MiFreeSwapPages; +extern PFN_NUMBER MiUsedSwapPages; +extern SIZE_T MmPagedPoolSize; +extern SIZE_T MmTotalPagedPoolQuota; +extern SIZE_T MmTotalNonPagedPoolQuota; extern PHYSICAL_ADDRESS MmSharedDataPagePhysicalAddress; -extern ULONG MmNumberOfPhysicalPages; +extern PFN_NUMBER MmNumberOfPhysicalPages; extern UCHAR MmDisablePagingExecutive; -extern ULONG MmLowestPhysicalPage; -extern ULONG MmHighestPhysicalPage; -extern ULONG MmAvailablePages; -extern ULONG MmResidentAvailablePages; -extern ULONG MmNumberOfSystemPtes; +extern PFN_NUMBER MmLowestPhysicalPage; +extern PFN_NUMBER MmHighestPhysicalPage; +extern PFN_NUMBER MmAvailablePages; +extern PFN_NUMBER MmResidentAvailablePages; +extern ULONG_PTR MmNumberOfSystemPtes; extern PVOID MmPagedPoolBase; -extern ULONG MmPagedPoolSize; +extern SIZE_T MmPagedPoolSize; extern PMEMORY_ALLOCATION_DESCRIPTOR MiFreeDescriptor; extern MEMORY_ALLOCATION_DESCRIPTOR MiFreeDescriptorOrg; diff --git a/reactos/ntoskrnl/io/iomgr/iocomp.c b/reactos/ntoskrnl/io/iomgr/iocomp.c index f695ea01c55..dfb771394fa 100644 --- a/reactos/ntoskrnl/io/iomgr/iocomp.c +++ b/reactos/ntoskrnl/io/iomgr/iocomp.c @@ -92,7 +92,7 @@ IopFreeMiniPacket(PIOP_MINI_COMPLETION_PACKET Packet) } /* The free was within dhe Depth */ - InterlockedPushEntrySList(&List->L.ListHead, (PSINGLE_LIST_ENTRY)Packet); + InterlockedPushEntrySList(&List->L.ListHead, (PSLIST_ENTRY)Packet); } VOID diff --git a/reactos/ntoskrnl/io/iomgr/irp.c b/reactos/ntoskrnl/io/iomgr/irp.c index 598f53d4fe9..1d870a04668 100644 --- a/reactos/ntoskrnl/io/iomgr/irp.c +++ b/reactos/ntoskrnl/io/iomgr/irp.c @@ -1553,7 +1553,7 @@ IoFreeIrp(IN PIRP Irp) if (Irp) { InterlockedPushEntrySList(&List->L.ListHead, - (PSINGLE_LIST_ENTRY)Irp); + (PSLIST_ENTRY)Irp); } } } diff --git a/reactos/ntoskrnl/ke/bug.c b/reactos/ntoskrnl/ke/bug.c index 6aef75230bb..108fb4690b8 100644 --- a/reactos/ntoskrnl/ke/bug.c +++ b/reactos/ntoskrnl/ke/bug.c @@ -1411,7 +1411,7 @@ KeRegisterNmiCallback(IN PNMI_CALLBACK CallbackRoutine, // KiAcquireNmiListLock(&OldIrql); NmiData->Next = KiNmiCallbackListHead; - Next = InterlockedCompareExchangePointer(&KiNmiCallbackListHead, + Next = InterlockedCompareExchangePointer((PVOID*)&KiNmiCallbackListHead, NmiData, NmiData->Next); ASSERT(Next == NmiData->Next); diff --git a/reactos/ntoskrnl/mm/ARM3/contmem.c b/reactos/ntoskrnl/mm/ARM3/contmem.c index 645d973b367..a92a47c147a 100644 --- a/reactos/ntoskrnl/mm/ARM3/contmem.c +++ b/reactos/ntoskrnl/mm/ARM3/contmem.c @@ -391,7 +391,7 @@ MmAllocateContiguousMemorySpecifyCache(IN SIZE_T NumberOfBytes, */ PVOID NTAPI -MmAllocateContiguousMemory(IN ULONG NumberOfBytes, +MmAllocateContiguousMemory(IN SIZE_T NumberOfBytes, IN PHYSICAL_ADDRESS HighestAcceptableAddress) { PFN_NUMBER HighestPfn; diff --git a/reactos/ntoskrnl/mm/ARM3/iosup.c b/reactos/ntoskrnl/mm/ARM3/iosup.c index b9f7eb641d9..03cd94ec760 100644 --- a/reactos/ntoskrnl/mm/ARM3/iosup.c +++ b/reactos/ntoskrnl/mm/ARM3/iosup.c @@ -46,7 +46,7 @@ MI_PFN_CACHE_ATTRIBUTE MiPlatformCacheAttributes[2][MmMaximumCacheType] = PVOID NTAPI MmMapIoSpace(IN PHYSICAL_ADDRESS PhysicalAddress, - IN ULONG NumberOfBytes, + IN SIZE_T NumberOfBytes, IN MEMORY_CACHING_TYPE CacheType) { diff --git a/reactos/ntoskrnl/mm/ARM3/miarm.h b/reactos/ntoskrnl/mm/ARM3/miarm.h index 85137632e03..67fe723f8a1 100644 --- a/reactos/ntoskrnl/mm/ARM3/miarm.h +++ b/reactos/ntoskrnl/mm/ARM3/miarm.h @@ -33,6 +33,8 @@ #define MI_NONPAGED_POOL_END (PVOID)0xFFBE0000 #define MI_DEBUG_MAPPING (PVOID)0xFFBFF000 +#endif /* !_M_AMD64 */ + #define MI_MIN_SECONDARY_COLORS 8 #define MI_SECONDARY_COLORS 64 #define MI_MAX_SECONDARY_COLORS 1024 @@ -42,10 +44,10 @@ /* Make the code cleaner with some definitions for size multiples */ #define _1KB (1024) -#define _1MB (1000 * _1KB) +#define _1MB (1024 * _1KB) -/* Size of a PDE directory, and size of a page table */ -#define PDE_SIZE (PDE_COUNT * sizeof(MMPDE)) +/* Size of a page directory, and size of a page table */ +#define PD_SIZE (PDE_COUNT * sizeof(MMPDE)) #define PT_SIZE (PTE_COUNT * sizeof(MMPTE)) /* Architecture specific count of PDEs in a directory, and count of PTEs in a PT */ @@ -53,7 +55,11 @@ #define PD_COUNT 1 #define PDE_COUNT 1024 #define PTE_COUNT 1024 -#elif _M_ARM +#elif defined(_M_AMD64) +#define PD_COUNT (512 * 512) +#define PDE_COUNT 512 +#define PTE_COUNT 512 +#elif defined(_M_ARM) #define PD_COUNT 1 #define PDE_COUNT 4096 #define PTE_COUNT 256 @@ -73,8 +79,6 @@ #define BASE_POOL_TYPE_MASK 1 #define POOL_MAX_ALLOC (PAGE_SIZE - (sizeof(POOL_HEADER) + sizeof(LIST_ENTRY))) -#endif - typedef struct _POOL_DESCRIPTOR { POOL_TYPE PoolType; @@ -196,24 +200,24 @@ extern MMPTE HyperTemplatePte; extern MMPTE ValidKernelPde; extern MMPTE ValidKernelPte; -extern ULONG_PTR MmSizeOfNonPagedPoolInBytes; -extern ULONG_PTR MmMaximumNonPagedPoolInBytes; +extern SIZE_T MmSizeOfNonPagedPoolInBytes; +extern SIZE_T MmMaximumNonPagedPoolInBytes; extern PFN_NUMBER MmMaximumNonPagedPoolInPages; extern PFN_NUMBER MmSizeOfPagedPoolInPages; extern PVOID MmNonPagedSystemStart; extern PVOID MmNonPagedPoolStart; extern PVOID MmNonPagedPoolExpansionStart; extern PVOID MmNonPagedPoolEnd; -extern ULONG_PTR MmSizeOfPagedPoolInBytes; +extern SIZE_T MmSizeOfPagedPoolInBytes; extern PVOID MmPagedPoolStart; extern PVOID MmPagedPoolEnd; extern PVOID MmSessionBase; -extern ULONG_PTR MmSessionSize; +extern SIZE_T MmSessionSize; extern PMMPTE MmFirstReservedMappingPte, MmLastReservedMappingPte; extern PMMPTE MiFirstReservedZeroingPte; extern MI_PFN_CACHE_ATTRIBUTE MiPlatformCacheAttributes[2][MmMaximumCacheType]; extern PPHYSICAL_MEMORY_DESCRIPTOR MmPhysicalMemoryBlock; -extern ULONG_PTR MmBootImageSize; +extern SIZE_T MmBootImageSize; extern PMMPTE MmSystemPtesStart[MaximumPtePoolTypes]; extern PMMPTE MmSystemPtesEnd[MaximumPtePoolTypes]; extern PMEMORY_ALLOCATION_DESCRIPTOR MxFreeDescriptor; @@ -226,10 +230,9 @@ extern PVOID MmPagedPoolStart; extern PVOID MmPagedPoolEnd; extern PVOID MmNonPagedSystemStart; extern PVOID MiSystemViewStart; -extern ULONG_PTR MmSystemViewSize; +extern SIZE_T MmSystemViewSize; extern PVOID MmSessionBase; extern PVOID MiSessionSpaceEnd; -extern ULONG_PTR MmSizeOfPagedPoolInBytes; extern PMMPTE MmSystemPagePtes; extern PVOID MmSystemCacheStart; extern PVOID MmSystemCacheEnd; @@ -239,13 +242,12 @@ extern ULONG_PTR MmSubsectionBase; extern ULONG MmSpecialPoolTag; extern PVOID MmHyperSpaceEnd; extern PMMWSL MmSystemCacheWorkingSetList; -extern ULONG MmMinimumNonPagedPoolSize; +extern SIZE_T MmMinimumNonPagedPoolSize; extern ULONG MmMinAdditionNonPagedPoolPerMb; -extern ULONG MmDefaultMaximumNonPagedPool; +extern SIZE_T MmDefaultMaximumNonPagedPool; extern ULONG MmMaxAdditionNonPagedPoolPerMb; extern ULONG MmSecondaryColors; extern ULONG MmSecondaryColorMask; -extern ULONG MmNumberOfSystemPtes; extern ULONG MmMaximumNonPagedPoolPercent; extern ULONG MmLargeStackSize; extern PMMCOLOR_TABLES MmFreePagesByColor[FreePageList + 1]; diff --git a/reactos/ntoskrnl/mm/ARM3/mminit.c b/reactos/ntoskrnl/mm/ARM3/mminit.c index 89d082e4f95..39e3c3e898b 100644 --- a/reactos/ntoskrnl/mm/ARM3/mminit.c +++ b/reactos/ntoskrnl/mm/ARM3/mminit.c @@ -23,8 +23,8 @@ // figure out the most appropriate values. // ULONG MmMaximumNonPagedPoolPercent; -ULONG MmSizeOfNonPagedPoolInBytes; -ULONG MmMaximumNonPagedPoolInBytes; +SIZE_T MmSizeOfNonPagedPoolInBytes; +SIZE_T MmMaximumNonPagedPoolInBytes; /* Some of the same values, in pages */ PFN_NUMBER MmMaximumNonPagedPoolInPages; @@ -36,9 +36,9 @@ PFN_NUMBER MmMaximumNonPagedPoolInPages; // They are described on http://support.microsoft.com/default.aspx/kb/126402/ja // along with the algorithm that uses them, which is implemented later below. // -ULONG MmMinimumNonPagedPoolSize = 256 * 1024; +SIZE_T MmMinimumNonPagedPoolSize = 256 * 1024; ULONG MmMinAdditionNonPagedPoolPerMb = 32 * 1024; -ULONG MmDefaultMaximumNonPagedPool = 1024 * 1024; +SIZE_T MmDefaultMaximumNonPagedPool = 1024 * 1024; ULONG MmMaxAdditionNonPagedPoolPerMb = 400 * 1024; // @@ -107,7 +107,7 @@ PVOID MmPagedPoolEnd; // // And this is its default size // -ULONG MmSizeOfPagedPoolInBytes = MI_MIN_INIT_PAGED_POOLSIZE; +SIZE_T MmSizeOfPagedPoolInBytes = MI_MIN_INIT_PAGED_POOLSIZE; PFN_NUMBER MmSizeOfPagedPoolInPages = MI_MIN_INIT_PAGED_POOLSIZE / PAGE_SIZE; // @@ -131,10 +131,10 @@ PVOID MiSessionViewStart; // 0xBE000000 PVOID MiSessionPoolEnd; // 0xBE000000 PVOID MiSessionPoolStart; // 0xBD000000 PVOID MmSessionBase; // 0xBD000000 -ULONG MmSessionSize; -ULONG MmSessionViewSize; -ULONG MmSessionPoolSize; -ULONG MmSessionImageSize; +SIZE_T MmSessionSize; +SIZE_T MmSessionViewSize; +SIZE_T MmSessionPoolSize; +SIZE_T MmSessionImageSize; // // The system view space, on the other hand, is where sections that are memory @@ -143,7 +143,7 @@ ULONG MmSessionImageSize; // By default, it is a 16MB region. // PVOID MiSystemViewStart; -ULONG MmSystemViewSize; +SIZE_T MmSystemViewSize; // // A copy of the system page directory (the page directory associated with the @@ -167,13 +167,13 @@ PMMWSL MmSystemCacheWorkingSetList = MI_SYSTEM_CACHE_WS_START; // On systems with more than 32MB, this number is then doubled, and further // aligned up to a PDE boundary (4MB). // -ULONG MmNumberOfSystemPtes; +ULONG_PTR MmNumberOfSystemPtes; // // This is how many pages the PFN database will take up // In Windows, this includes the Quark Color Table, but not in ARM³ // -ULONG MxPfnAllocation; +PFN_NUMBER MxPfnAllocation; // // Unlike the old ReactOS Memory Manager, ARM³ (and Windows) does not keep track @@ -197,7 +197,7 @@ PPHYSICAL_MEMORY_DESCRIPTOR MmPhysicalMemoryBlock; // // This is where we keep track of the most basic physical layout markers // -ULONG MmNumberOfPhysicalPages, MmHighestPhysicalPage, MmLowestPhysicalPage = -1; +PFN_NUMBER MmNumberOfPhysicalPages, MmHighestPhysicalPage, MmLowestPhysicalPage = -1; // // The total number of pages mapped by the boot loader, which include the kernel @@ -207,13 +207,13 @@ ULONG MmNumberOfPhysicalPages, MmHighestPhysicalPage, MmLowestPhysicalPage = -1; // // This number is later aligned up to a PDE boundary. // -ULONG MmBootImageSize; +SIZE_T MmBootImageSize; // // These three variables keep track of the core separation of address space that // exists between kernel mode and user mode. // -ULONG MmUserProbeAddress; +ULONG_PTR MmUserProbeAddress; PVOID MmHighestUserAddress; PVOID MmSystemRangeStart; diff --git a/reactos/ntoskrnl/mm/ARM3/ncache.c b/reactos/ntoskrnl/mm/ARM3/ncache.c index f43d10afd51..6f8376fe264 100644 --- a/reactos/ntoskrnl/mm/ARM3/ncache.c +++ b/reactos/ntoskrnl/mm/ARM3/ncache.c @@ -23,7 +23,7 @@ */ PVOID NTAPI -MmAllocateNonCachedMemory(IN ULONG NumberOfBytes) +MmAllocateNonCachedMemory(IN SIZE_T NumberOfBytes) { PFN_NUMBER PageCount, MdlPageCount, PageFrameIndex; PHYSICAL_ADDRESS LowAddress, HighAddress, SkipBytes; diff --git a/reactos/ntoskrnl/mm/ARM3/procsup.c b/reactos/ntoskrnl/mm/ARM3/procsup.c index 24bd11a2586..b95098dc507 100644 --- a/reactos/ntoskrnl/mm/ARM3/procsup.c +++ b/reactos/ntoskrnl/mm/ARM3/procsup.c @@ -503,7 +503,7 @@ MmCreatePeb(IN PEPROCESS Process, ImageConfigData = RtlImageDirectoryEntryToData(Peb->ImageBaseAddress, TRUE, IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG, - &ViewSize); + (PULONG)&ViewSize); if (ImageConfigData) { // diff --git a/reactos/ntoskrnl/mm/ARM3/virtual.c b/reactos/ntoskrnl/mm/ARM3/virtual.c index 88ff54f5dcc..10c1f1bba60 100644 --- a/reactos/ntoskrnl/mm/ARM3/virtual.c +++ b/reactos/ntoskrnl/mm/ARM3/virtual.c @@ -775,7 +775,7 @@ NtWriteVirtualMemory(IN HANDLE ProcessHandle, KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); PEPROCESS Process; NTSTATUS Status = STATUS_SUCCESS; - ULONG BytesWritten = 0; + SIZE_T BytesWritten = 0; PAGED_CODE(); // diff --git a/reactos/ntoskrnl/mm/balance.c b/reactos/ntoskrnl/mm/balance.c index d786f768e3a..555c7a666db 100644 --- a/reactos/ntoskrnl/mm/balance.c +++ b/reactos/ntoskrnl/mm/balance.c @@ -228,7 +228,7 @@ MiIsBalancerThread(VOID) PsGetCurrentThread() == MiBalancerThreadId.UniqueThread; } -VOID NTAPI MiSetConsumer(IN PFN_TYPE Pfn, IN ULONG Consumer); +VOID NTAPI MiSetConsumer(IN PFN_NUMBER Pfn, IN ULONG Consumer); NTSTATUS NTAPI diff --git a/reactos/ntoskrnl/mm/pagefile.c b/reactos/ntoskrnl/mm/pagefile.c index b95d62e8329..e820c414b72 100644 --- a/reactos/ntoskrnl/mm/pagefile.c +++ b/reactos/ntoskrnl/mm/pagefile.c @@ -81,15 +81,15 @@ static ULONG MiPagingFileCount; ULONG MmNumberOfPagingFiles; /* Number of pages that are available for swapping */ -ULONG MiFreeSwapPages; +PFN_NUMBER MiFreeSwapPages; /* Number of pages that have been allocated for swapping */ -ULONG MiUsedSwapPages; +PFN_NUMBER MiUsedSwapPages; /* * Number of pages that have been reserved for swapping but not yet allocated */ -static ULONG MiReservedSwapPages; +static PFN_NUMBER MiReservedSwapPages; /* * Ratio between reserved and available swap pages, e.g. setting this to five diff --git a/reactos/ntoskrnl/mm/ppool.c b/reactos/ntoskrnl/mm/ppool.c index 973736d759a..bfeb42ba6e2 100644 --- a/reactos/ntoskrnl/mm/ppool.c +++ b/reactos/ntoskrnl/mm/ppool.c @@ -159,8 +159,8 @@ typedef struct _R_POOL R_POOL, *PR_POOL; PVOID MmPagedPoolBase; -ULONG MmPagedPoolSize; -ULONG MmTotalPagedPoolQuota = 0; // TODO FIXME commented out until we use it +SIZE_T MmPagedPoolSize; +SIZE_T MmTotalPagedPoolQuota = 0; // TODO FIXME commented out until we use it static PR_POOL MmPagedPool = NULL; /* FUNCTIONS*******************************************************************/ From b6fae9f55b8013ab56655ab605e29335ca799bc5 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Wed, 24 Mar 2010 21:56:24 +0000 Subject: [PATCH 012/134] [RTL] Fix RtlInitializeSListHead and RtlQueryDepthSList svn path=/branches/ros-amd64-bringup/; revision=46405 --- reactos/lib/rtl/slist.c | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/reactos/lib/rtl/slist.c b/reactos/lib/rtl/slist.c index 4d291abe70e..8260a38eb82 100644 --- a/reactos/lib/rtl/slist.c +++ b/reactos/lib/rtl/slist.c @@ -17,15 +17,32 @@ VOID NTAPI -RtlInitializeSListHead(IN PSLIST_HEADER ListHead) +RtlInitializeSListHead( + OUT PSLIST_HEADER SListHead) { -#ifdef _WIN64 - ListHead->Alignment = 0; - ListHead->Region = 0; - ListHead->Header8.Init = 1; - // ListHead->Header8.HeaderType = 1; // FIXME: depending on cmpxchg16b support? -#else - ListHead->Alignment = 0; +#if defined(_IA64_) + ULONG64 FeatureBits; +#endif + +#if defined(_WIN64) + /* Make sure the alignment is ok */ + if (((ULONG_PTR)SListHead & 0xf) != 0) + { + RtlRaiseStatus(STATUS_DATATYPE_MISALIGNMENT); + } +#endif + + /* Zero it */ + SListHead->Alignment = 0; + SListHead->Region = 0; + +#if defined(_IA64_) + FeatureBits = __getReg(CV_IA64_CPUID4); + if (FeatureBits & KF_16BYTE_INSTR) + { + SListHead->Header16.HeaderType = 1; + SListHead->Header16.Init = 1; + } #endif } @@ -64,7 +81,7 @@ RtlQueryDepthSList(IN PSLIST_HEADER ListHead) { #ifdef _WIN64 return ListHead->Header8.HeaderType ? - ListHead->Header16.Sequence : ListHead->Header8.Sequence; + ListHead->Header16.Depth : ListHead->Header8.Depth; #else return ListHead->Depth; #endif From 36146b651f605550f44ad2f1ab2d8f87d7c7356f Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Wed, 24 Mar 2010 22:02:26 +0000 Subject: [PATCH 013/134] [NTOS] - remove KeGetCurrentThread inline function, it's already in the wdm.h, reenable the exported function - Add InitializeSListHead export - Use RtlInitializeSListHead for InititializeSListHead - Add hacks for WDK compilation - Add ValidKernelPte/Pde - Comment out MiSyncARM3WithROS, add a stub instead svn path=/branches/ros-amd64-bringup/; revision=46406 --- reactos/ntoskrnl/include/internal/amd64/ke.h | 7 ---- reactos/ntoskrnl/include/internal/amd64/mm.h | 3 +- reactos/ntoskrnl/include/internal/rtl.h | 4 +++ reactos/ntoskrnl/include/ntoskrnl.h | 6 ++++ reactos/ntoskrnl/io/iomgr/adapter.c | 1 + reactos/ntoskrnl/io/iomgr/arcname.c | 2 ++ reactos/ntoskrnl/ke/thrdobj.c | 2 -- reactos/ntoskrnl/mm/ARM3/mminit.c | 2 ++ reactos/ntoskrnl/mm/amd64/init.c | 38 ++++++++++---------- reactos/ntoskrnl/mm/sysldr.c | 2 +- reactos/ntoskrnl/ntoskrnl.pspec | 2 ++ 11 files changed, 39 insertions(+), 30 deletions(-) diff --git a/reactos/ntoskrnl/include/internal/amd64/ke.h b/reactos/ntoskrnl/include/internal/amd64/ke.h index 001c40243ff..2e43edc248d 100644 --- a/reactos/ntoskrnl/include/internal/amd64/ke.h +++ b/reactos/ntoskrnl/include/internal/amd64/ke.h @@ -146,13 +146,6 @@ KeFlushProcessTb(VOID) __writecr3(__readcr3()); } -FORCEINLINE -PRKTHREAD -KeGetCurrentThread(VOID) -{ - return (PRKTHREAD)__readgsqword(FIELD_OFFSET(KIPCR, Prcb.CurrentThread)); -} - FORCEINLINE VOID KiRundownThread(IN PKTHREAD Thread) diff --git a/reactos/ntoskrnl/include/internal/amd64/mm.h b/reactos/ntoskrnl/include/internal/amd64/mm.h index a1952915416..6f0b2fd390c 100644 --- a/reactos/ntoskrnl/include/internal/amd64/mm.h +++ b/reactos/ntoskrnl/include/internal/amd64/mm.h @@ -158,13 +158,12 @@ MmInitGlobalKernelPageDirectory(VOID) #define MI_MAKE_WRITE_PAGE(x) ((x)->u.Hard.Writable = 1) #endif -#if 0 // FIXME +// FIXME!!! #define PAGE_TO_SECTION_PAGE_DIRECTORY_OFFSET(x) \ ((x) / (4*1024*1024)) #define PAGE_TO_SECTION_PAGE_TABLE_OFFSET(x) \ ((((x)) % (4*1024*1024)) / (4*1024)) -#endif #define NR_SECTION_PAGE_TABLES 1024 #define NR_SECTION_PAGE_ENTRIES 1024 diff --git a/reactos/ntoskrnl/include/internal/rtl.h b/reactos/ntoskrnl/include/internal/rtl.h index 18489044fc9..4a2f0b4e541 100644 --- a/reactos/ntoskrnl/include/internal/rtl.h +++ b/reactos/ntoskrnl/include/internal/rtl.h @@ -1,5 +1,9 @@ #pragma once +#ifdef _WIN64 +#define InitializeSListHead RtlInitializeSListHead +#endif + NTSTATUS NTAPI RtlQueryAtomListInAtomTable( diff --git a/reactos/ntoskrnl/include/ntoskrnl.h b/reactos/ntoskrnl/include/ntoskrnl.h index 3b56d34afac..4261d020544 100644 --- a/reactos/ntoskrnl/include/ntoskrnl.h +++ b/reactos/ntoskrnl/include/ntoskrnl.h @@ -13,6 +13,12 @@ #define DbgPrint DbgPrintEarly #endif +/* WDK hacks */ +#ifdef _M_AMD64 +#define IoAllocateAdapterChannel _IoAllocateAdapterChannel +#define KeGetCurrentThread _KeGetCurrentThread +#endif + /* Version Data */ #undef __MSVCRT__ #include diff --git a/reactos/ntoskrnl/io/iomgr/adapter.c b/reactos/ntoskrnl/io/iomgr/adapter.c index 1d402c95045..888583a28d4 100644 --- a/reactos/ntoskrnl/io/iomgr/adapter.c +++ b/reactos/ntoskrnl/io/iomgr/adapter.c @@ -21,6 +21,7 @@ ULONG IoDeviceHandlerObjectSize; /* FUNCTIONS *****************************************************************/ +#undef IoAllocateAdapterChannel /* * @implemented */ diff --git a/reactos/ntoskrnl/io/iomgr/arcname.c b/reactos/ntoskrnl/io/iomgr/arcname.c index de18d5c80c4..003c9bfc8ca 100644 --- a/reactos/ntoskrnl/io/iomgr/arcname.c +++ b/reactos/ntoskrnl/io/iomgr/arcname.c @@ -377,7 +377,9 @@ IopAssignArcNamesToCdrom(IN PLOADER_PARAMETER_BLOCK LoaderBlock, } goto checkbootcd; +#ifndef _M_AMD64 freeldrhack: +#endif /* * FIXME: In normal conditions, NTLDR/FreeLdr sends the *proper* CDROM * ARC Path name, and what happens here is a comparision of both checksums diff --git a/reactos/ntoskrnl/ke/thrdobj.c b/reactos/ntoskrnl/ke/thrdobj.c index 16a7c8b39ae..e73f4ff9d29 100644 --- a/reactos/ntoskrnl/ke/thrdobj.c +++ b/reactos/ntoskrnl/ke/thrdobj.c @@ -897,7 +897,6 @@ KeCapturePersistentThreadState(IN PVOID CurrentThread, UNIMPLEMENTED; } -#ifndef _M_AMD64 /* * @implemented */ @@ -909,7 +908,6 @@ KeGetCurrentThread(VOID) /* Return the current thread on this PCR */ return _KeGetCurrentThread(); } -#endif /* * @implemented diff --git a/reactos/ntoskrnl/mm/ARM3/mminit.c b/reactos/ntoskrnl/mm/ARM3/mminit.c index 39e3c3e898b..0a58c1e2171 100644 --- a/reactos/ntoskrnl/mm/ARM3/mminit.c +++ b/reactos/ntoskrnl/mm/ARM3/mminit.c @@ -303,6 +303,7 @@ MM_SYSTEMSIZE MmSystemSize; /* PRIVATE FUNCTIONS **********************************************************/ +#ifndef _M_AMD64 // // In Bavaria, this is probably a hate crime // @@ -325,6 +326,7 @@ MiSyncARM3WithROS(IN PVOID AddressStart, Pde++; } } +#endif PFN_NUMBER NTAPI diff --git a/reactos/ntoskrnl/mm/amd64/init.c b/reactos/ntoskrnl/mm/amd64/init.c index e740ef78bb4..4fcb0dfd9c8 100644 --- a/reactos/ntoskrnl/mm/amd64/init.c +++ b/reactos/ntoskrnl/mm/amd64/init.c @@ -26,21 +26,16 @@ HalInitializeBios(ULONG Unknown, PLOADER_PARAMETER_BLOCK LoaderBlock); /* GLOBALS *****************************************************************/ +/* Template PTE and PDE for a kernel page */ +MMPTE ValidKernelPde = {.u.Hard.Valid = 1, .u.Hard.Write = 1, .u.Hard.Dirty = 1, .u.Hard.Accessed = 1}; +MMPTE ValidKernelPte = {.u.Hard.Valid = 1, .u.Hard.Write = 1, .u.Hard.Dirty = 1, .u.Hard.Accessed = 1}; + /* Sizes */ -//SIZE_T MmBootImageSize; -//SIZE_T MmMinimumNonPagedPoolSize = 256 * 1024; -//SIZE_T MmSizeOfNonPagedPoolInBytes; -//SIZE_T MmMaximumNonPagedPoolInBytes; -//ULONG MmMaximumNonPagedPoolPercent; -//ULONG MmMinAdditionNonPagedPoolPerMb = 32 * 1024; -//ULONG MmMaxAdditionNonPagedPoolPerMb = 400 * 1024; -//SIZE_T MmDefaultMaximumNonPagedPool = 1024 * 1024; -//SIZE_T MmSessionSize = MI_SESSION_SIZE; +///SIZE_T MmSessionSize = MI_SESSION_SIZE; SIZE_T MmSessionViewSize = MI_SESSION_VIEW_SIZE; SIZE_T MmSessionPoolSize = MI_SESSION_POOL_SIZE; SIZE_T MmSessionImageSize = MI_SESSION_IMAGE_SIZE; SIZE_T MmSystemViewSize = MI_SYSTEM_VIEW_SIZE; -//SIZE_T MmSizeOfPagedPoolInBytes = MI_MIN_INIT_PAGED_POOLSIZE; SIZE_T MiNonPagedSystemSize; /* Address ranges */ @@ -66,15 +61,8 @@ PVOID MmNonPagedPoolExpansionStart; ///PVOID MmNonPagedPoolEnd = MI_NONPAGED_POOL_END; // 0xFFFFFAE000000000 PVOID MmHyperSpaceEnd = (PVOID)HYPER_SPACE_END; -//PPHYSICAL_MEMORY_DESCRIPTOR MmPhysicalMemoryBlock; -//ULONG MmNumberOfPhysicalPages, MmHighestPhysicalPage, MmLowestPhysicalPage = -1; // FIXME: ULONG64 - -//ULONG MmNumberOfSystemPtes; -//PMMPTE MmSystemPagePtes; MMSUPPORT MmSystemCacheWs; -//RTL_BITMAP MiPfnBitMap; -//ULONG64 MxPfnAllocation; ULONG64 MxPfnSizeInBytes; PMEMORY_ALLOCATION_DESCRIPTOR MxFreeDescriptor; @@ -87,7 +75,6 @@ PFN_NUMBER MxFreePageBase; ULONG64 MxFreePageCount = 0; extern PFN_NUMBER MmSystemPageDirectory; -//PFN_NUMBER MmSizeOfPagedPoolInPages = MI_MIN_INIT_PAGED_POOLSIZE / PAGE_SIZE; BOOLEAN MiPfnsInitialized = FALSE; @@ -878,3 +865,18 @@ MmArmInitSystem_x(IN ULONG Phase, return STATUS_SUCCESS; } +VOID +FASTCALL +MiSyncARM3WithROS(IN PVOID AddressStart, + IN PVOID AddressEnd) +{ + +} + +NTSTATUS +NTAPI +MiInitMachineDependent(IN PLOADER_PARAMETER_BLOCK LoaderBlock) +{ + UNIMPLEMENTED; + return STATUS_NOT_IMPLEMENTED; +} diff --git a/reactos/ntoskrnl/mm/sysldr.c b/reactos/ntoskrnl/mm/sysldr.c index 5663f1ec5a4..a822cfed5a6 100644 --- a/reactos/ntoskrnl/mm/sysldr.c +++ b/reactos/ntoskrnl/mm/sysldr.c @@ -790,7 +790,7 @@ MmUnloadSystemImage(IN PVOID ImageHandle) } /* Free the driver */ - MmFreeSection(LdrEntry->DllBase); + //MmFreeSection(LdrEntry->DllBase); /* Check if we're linked in */ if (LdrEntry->InLoadOrderLinks.Flink) diff --git a/reactos/ntoskrnl/ntoskrnl.pspec b/reactos/ntoskrnl/ntoskrnl.pspec index 7bdc16c4237..b45672a12e4 100644 --- a/reactos/ntoskrnl/ntoskrnl.pspec +++ b/reactos/ntoskrnl/ntoskrnl.pspec @@ -347,6 +347,8 @@ @ FASTCALL InterlockedIncrement(ptr) @ FASTCALL InterlockedPopEntrySList(ptr) @ FASTCALL InterlockedPushEntrySList(ptr ptr) +#else +@ stdcall InitializeSListHead(ptr) RtlInitializeSListHead #endif @ stdcall IoAcquireCancelSpinLock(ptr) @ stdcall IoAcquireRemoveLockEx(ptr ptr str long long) From 4a0270102279eb3895d9809d27aa986caff8d9e6 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Thu, 25 Mar 2010 02:04:41 +0000 Subject: [PATCH 014/134] [ACPI] Add back to build svn path=/branches/ros-amd64-bringup/; revision=46420 --- reactos/drivers/bus/directory.rbuild | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reactos/drivers/bus/directory.rbuild b/reactos/drivers/bus/directory.rbuild index 791a34cde04..a6904a2b137 100644 --- a/reactos/drivers/bus/directory.rbuild +++ b/reactos/drivers/bus/directory.rbuild @@ -1,9 +1,9 @@ - + From 0fc116b80c1872775da0f5d6924b2df4c4955ad1 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Thu, 25 Mar 2010 02:58:46 +0000 Subject: [PATCH 015/134] reduce diff to trunk svn path=/branches/ros-amd64-bringup/; revision=46421 --- .../drivers/wdm/audio/legacy/wdmaud/control.c | 2 +- .../drivers/wdm/audio/legacy/wdmaud/entry.c | 24 +++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/reactos/drivers/wdm/audio/legacy/wdmaud/control.c b/reactos/drivers/wdm/audio/legacy/wdmaud/control.c index 631b8619b55..07e9ef846d2 100644 --- a/reactos/drivers/wdm/audio/legacy/wdmaud/control.c +++ b/reactos/drivers/wdm/audio/legacy/wdmaud/control.c @@ -151,7 +151,7 @@ WdmAudIoctlClose( { ObDereferenceObject(ClientInfo->hPins[Index].NotifyEvent); ClientInfo->hPins[Index].NotifyEvent = NULL; - } + } } } diff --git a/reactos/drivers/wdm/audio/legacy/wdmaud/entry.c b/reactos/drivers/wdm/audio/legacy/wdmaud/entry.c index 572a97258c9..20421ead5e4 100644 --- a/reactos/drivers/wdm/audio/legacy/wdmaud/entry.c +++ b/reactos/drivers/wdm/audio/legacy/wdmaud/entry.c @@ -228,25 +228,25 @@ WdmAudCleanup( KeReleaseSpinLock(&DeviceExtension->Lock, OldIrql); /* check if all audio pins have been closed */ - for (Index = 0; Index < pClient->NumPins; Index++) - { - DPRINT("Index %u Pin %p Type %x\n", Index, pClient->hPins[Index].Handle, pClient->hPins[Index].Type); - if (pClient->hPins[Index].Handle && pClient->hPins[Index].Type != MIXER_DEVICE_TYPE) - { + for (Index = 0; Index < pClient->NumPins; Index++) + { + DPRINT("Index %u Pin %p Type %x\n", Index, pClient->hPins[Index].Handle, pClient->hPins[Index].Type); + if (pClient->hPins[Index].Handle && pClient->hPins[Index].Type != MIXER_DEVICE_TYPE) + { /* found an still open audio pin */ - ZwClose(pClient->hPins[Index].Handle); - } - } + ZwClose(pClient->hPins[Index].Handle); + } + } /* free pin array */ - if (pClient->hPins) - ExFreePool(pClient->hPins); + if (pClient->hPins) + ExFreePool(pClient->hPins); /* free client context struct */ - ExFreePool(pClient); + ExFreePool(pClient); /* clear old client pointer */ - IoStack->FileObject->FsContext = NULL; + IoStack->FileObject->FsContext = NULL; /* complete request */ Irp->IoStatus.Status = STATUS_SUCCESS; From 5ddd37a1ec6d3cd3d06bdcbae4d79ad47d26e9b5 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Thu, 25 Mar 2010 04:22:20 +0000 Subject: [PATCH 016/134] reduce diff to trunk svn path=/branches/ros-amd64-bringup/; revision=46426 --- reactos/drivers/wdm/audio/drivers/CMIDriver/adapter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/drivers/wdm/audio/drivers/CMIDriver/adapter.cpp b/reactos/drivers/wdm/audio/drivers/CMIDriver/adapter.cpp index 7865d6f1a09..edf88bf746e 100644 --- a/reactos/drivers/wdm/audio/drivers/CMIDriver/adapter.cpp +++ b/reactos/drivers/wdm/audio/drivers/CMIDriver/adapter.cpp @@ -535,7 +535,7 @@ DriverEntry( #pragma code_seg() int __cdecl _purecall (void) { - return 0; + return 0; } #else From 0750573b4e0945ac1aa94ada9cd0c0652a17bedd Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Thu, 25 Mar 2010 05:09:09 +0000 Subject: [PATCH 017/134] reduce diff to trunk svn path=/branches/ros-amd64-bringup/; revision=46428 --- reactos/drivers/network/tcpip/tcpip/dispatch.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/reactos/drivers/network/tcpip/tcpip/dispatch.c b/reactos/drivers/network/tcpip/tcpip/dispatch.c index 68dcb24ef2d..f216ed5f678 100644 --- a/reactos/drivers/network/tcpip/tcpip/dispatch.c +++ b/reactos/drivers/network/tcpip/tcpip/dispatch.c @@ -179,7 +179,7 @@ VOID NTAPI DispCancelRequest( } if (DequeuedIrp) - IRPFinish(Irp, STATUS_CANCELLED); + IRPFinish(Irp, STATUS_CANCELLED); TI_DbgPrint(MAX_TRACE, ("Leaving.\n")); } @@ -222,8 +222,8 @@ VOID NTAPI DispCancelListenRequest( if (TCPAbortListenForSocket(Connection->AddressFile->Listener, Connection)) { - Irp->IoStatus.Information = 0; - IRPFinish(Irp, STATUS_CANCELLED); + Irp->IoStatus.Information = 0; + IRPFinish(Irp, STATUS_CANCELLED); } TI_DbgPrint(MAX_TRACE, ("Leaving.\n")); @@ -763,7 +763,7 @@ NTSTATUS DispTdiQueryInformation( MaxDatagramInfo->MaxDatagramSize = 0xFFFF; return STATUS_SUCCESS; - } + } } return STATUS_NOT_IMPLEMENTED; @@ -1052,7 +1052,7 @@ NTSTATUS DispTdiSendDatagram( else { Status = STATUS_UNSUCCESSFUL; ASSERT(FALSE); - } + } } done: From 82569185be223a14b1dc1bbfaeef50c9ebfd8bf8 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Thu, 25 Mar 2010 05:12:42 +0000 Subject: [PATCH 018/134] revert the changes to the old kdcom svn path=/branches/ros-amd64-bringup/; revision=46430 --- reactos/drivers/base/kdcom/i386/kdbg.c | 578 +------------------------ 1 file changed, 13 insertions(+), 565 deletions(-) diff --git a/reactos/drivers/base/kdcom/i386/kdbg.c b/reactos/drivers/base/kdcom/i386/kdbg.c index 3d7ed1c0bf6..c8fad2f2afb 100644 --- a/reactos/drivers/base/kdcom/i386/kdbg.c +++ b/reactos/drivers/base/kdcom/i386/kdbg.c @@ -5,7 +5,6 @@ * PURPOSE: Serial i/o functions for the kernel debugger. * PROGRAMMER: Alex Ionescu * Hervé Poussineau - * Timo Kreuzer */ /* INCLUDES *****************************************************************/ @@ -16,7 +15,6 @@ #define NDEBUG #include #include -#include #include #include "arc/arc.h" #include "windbgkd.h" @@ -27,7 +25,7 @@ typedef struct _KD_PORT_INFORMATION { ULONG ComPort; ULONG BaudRate; - ULONG_PTR BaseAddress; + ULONG BaseAddress; } KD_PORT_INFORMATION, *PKD_PORT_INFORMATION; BOOLEAN @@ -55,12 +53,6 @@ KdPortPutByteEx( IN PKD_PORT_INFORMATION PortInformation, IN UCHAR ByteToSend); -/* serial debug connection */ -#define DEFAULT_DEBUG_PORT 2 /* COM2 */ -#define DEFAULT_DEBUG_COM1_IRQ 4 /* COM1 IRQ */ -#define DEFAULT_DEBUG_COM2_IRQ 3 /* COM2 IRQ */ -#define DEFAULT_DEBUG_BAUD_RATE 115200 /* 115200 Baud */ - #define DEFAULT_BAUD_RATE 19200 #ifdef _M_IX86 @@ -71,8 +63,6 @@ const ULONG BaseArray[2] = {0, 0x800003f8}; const ULONG BaseArray[3] = {0, 0x80006000, 0x80007000}; #elif defined(_M_ARM) const ULONG BaseArray[2] = {0, 0xF1012000}; -#elif defined(_M_AMD64) -const ULONG BaseArray[5] = {0, 0x3F8, 0x2F8, 0x3E8, 0x2E8}; #else #error Unknown architecture #endif @@ -125,8 +115,6 @@ const ULONG BaseArray[5] = {0, 0x3F8, 0x2F8, 0x3E8, 0x2E8}; /* GLOBAL VARIABLES *********************************************************/ -ULONG CurrentPacketId = INITIAL_PACKET_ID; - /* STATIC VARIABLES *********************************************************/ static KD_PORT_INFORMATION DefaultPort = { 0, 0, 0 }; @@ -134,18 +122,12 @@ static KD_PORT_INFORMATION DefaultPort = { 0, 0, 0 }; /* The com port must only be initialized once! */ static BOOLEAN PortInitialized = FALSE; -ULONG KdpPort; -ULONG KdpPortIrq; - -// HACK!!! -typedef ULONG (*DBGRNT)(const char *Format, ...); -DBGRNT FrLdrDbgPrint = 0; /* STATIC FUNCTIONS *********************************************************/ static BOOLEAN KdpDoesComPortExist( - IN ULONG_PTR BaseAddress) + IN ULONG BaseAddress) { BOOLEAN found; UCHAR mcr; @@ -205,14 +187,6 @@ KdpDoesComPortExist( /* FUNCTIONS ****************************************************************/ -NTSTATUS -DriverEntry( - IN PDRIVER_OBJECT DriverObject, - IN PUNICODE_STRING RegistryPath) -{ - return STATUS_SUCCESS; -} - /* HAL.KdPortInitialize */ BOOLEAN NTAPI @@ -272,7 +246,7 @@ KdPortInitializeEx( IN ULONG Unknown1, IN ULONG Unknown2) { - ULONG_PTR ComPortBase; + ULONG ComPortBase; CHAR buffer[80]; ULONG divisor; UCHAR lcr; @@ -493,270 +467,25 @@ KdPortEnableInterrupts(VOID) return TRUE; } -/* NEW INTERNAL FUNCTIONS ****************************************************/ - -/****************************************************************************** - * \name KdpCalculateChecksum - * \brief Calculates the checksum for the packet data. - * \param Buffer Pointer to the packet data. - * \param Length Length of data in bytes. - * \return The calculated checksum. - * \sa http://www.vista-xp.co.uk/forums/technical-reference-library/2540-basics-debugging.html - */ -ULONG -NTAPI -KdpCalculateChecksum( - IN PVOID Buffer, - IN ULONG Length) -{ - ULONG i, Checksum = 0; - - for (i = 0; i < Length; i++) - { - Checksum += ((PUCHAR)Buffer)[i]; - } - return Checksum; -} - -/****************************************************************************** - * \name KdpSendBuffer - * \brief Sends a buffer of data to the KD port. - * \param Buffer Pointer to the data. - * \param Size Size of data in bytes. - */ -VOID -NTAPI -KdpSendBuffer( - IN PVOID Buffer, - IN ULONG Size) -{ - INT i; - for (i = 0; i < Size; i++) - { - KdPortPutByteEx(&DefaultPort, ((PUCHAR)Buffer)[i]); - } -} - - -/****************************************************************************** - * \name KdpReceiveBuffer - * \brief Recieves data from the KD port and fills a buffer. - * \param Buffer Pointer to a buffer that receives the data. - * \param Size Size of data to receive in bytes. - * \return KdPacketReceived if successful. - * KdPacketTimedOut if the receice timed out (10 seconds). - * \todo Handle timeout. - */ -KDSTATUS -NTAPI -KdpReceiveBuffer( - OUT PVOID Buffer, - IN ULONG Size) -{ - ULONG i; - PUCHAR ByteBuffer = Buffer; - BOOLEAN Ret, TimeOut; - - for (i = 0; i < Size; i++) - { - do - { - Ret = KdPortGetByteEx(&DefaultPort, &ByteBuffer[i]); - TimeOut = FALSE; // FIXME timeout after 10 Sec - } - while (!Ret || TimeOut); - - if (TimeOut) - { - return KdPacketTimedOut; - } -// FrLdrDbgPrint("Received byte: %x\n", ByteBuffer[i]); - } - - return KdPacketReceived; -} - -KDSTATUS -NTAPI -KdpReceivePacketLeader( - OUT PULONG PacketLeader) -{ - UCHAR Byte, PrevByte; - ULONG i, Temp; - KDSTATUS RcvCode; - - Temp = 0; - PrevByte = 0; - for (i = 0; i < 4; i++) - { - RcvCode = KdpReceiveBuffer(&Byte, sizeof(UCHAR)); - Temp = (Temp << 8) | Byte; - if ( (RcvCode != KdPacketReceived) || - ((Byte != PACKET_LEADER_BYTE) && - (Byte != CONTROL_PACKET_LEADER_BYTE)) || - (PrevByte != 0 && Byte != PrevByte) ) - { - return KdPacketNeedsResend; - } - PrevByte = Byte; - } - - *PacketLeader = Temp; - - return KdPacketReceived; -} - - -VOID -NTAPI -KdpSendControlPacket( - IN USHORT PacketType, - IN ULONG PacketId OPTIONAL) -{ - KD_PACKET Packet; - - Packet.PacketLeader = CONTROL_PACKET_LEADER; - Packet.PacketId = PacketId; - Packet.ByteCount = 0; - Packet.Checksum = 0; - Packet.PacketType = PacketType; - - KdpSendBuffer(&Packet, sizeof(KD_PACKET)); -} - - -/* NEW PUBLIC FUNCTIONS ******************************************************/ - -/****************************************************************************** - * \name KdDebuggerInitialize0 - * \brief Phase 0 initialization. - * \param [opt] LoaderBlock Pointer to the Loader parameter block. Can be NULL. - * \return Status +/* + * @unimplemented */ NTSTATUS NTAPI KdDebuggerInitialize0( IN PLOADER_PARAMETER_BLOCK LoaderBlock OPTIONAL) { - ULONG Value; - PCHAR CommandLine, Port, BaudRate, Irq; - - /* Apply default values */ - KdpPortIrq = 0; - DefaultPort.ComPort = DEFAULT_DEBUG_PORT; - DefaultPort.BaudRate = DEFAULT_DEBUG_BAUD_RATE; - - /* Check if e have a LoaderBlock */ - if (LoaderBlock) - { - /* Get the Command Line */ - CommandLine = LoaderBlock->LoadOptions; - - /* Upcase it */ - _strupr(CommandLine); - - /* Get the port and baud rate */ - Port = strstr(CommandLine, "DEBUGPORT"); - BaudRate = strstr(CommandLine, "BAUDRATE"); - Irq = strstr(CommandLine, "IRQ"); - - /* Check if we got the /DEBUGPORT parameter */ - if (Port) - { - /* Move past the actual string, to reach the port*/ - Port += strlen("DEBUGPORT"); - - /* Now get past any spaces and skip the equal sign */ - while (*Port == ' ') Port++; - Port++; - - /* Do we have a serial port? */ - if (strncmp(Port, "COM", 3) != 0) - { - return STATUS_INVALID_PARAMETER; - } - - /* Gheck for a valid Serial Port */ - Port += 3; - Value = atol(Port); - if (Value > 4) - { - return STATUS_INVALID_PARAMETER; - } - - /* Set the port to use */ - DefaultPort.ComPort = Value; - } - - /* Check if we got a baud rate */ - if (BaudRate) - { - /* Move past the actual string, to reach the rate */ - BaudRate += strlen("BAUDRATE"); - - /* Now get past any spaces */ - while (*BaudRate == ' ') BaudRate++; - - /* And make sure we have a rate */ - if (*BaudRate) - { - /* Read and set it */ - Value = atol(BaudRate + 1); - if (Value) DefaultPort.BaudRate = Value; - } - } - - /* Check Serial Port Settings [IRQ] */ - if (Irq) - { - /* Move past the actual string, to reach the rate */ - Irq += strlen("IRQ"); - - /* Now get past any spaces */ - while (*Irq == ' ') Irq++; - - /* And make sure we have an IRQ */ - if (*Irq) - { - /* Read and set it */ - Value = atol(Irq + 1); - if (Value) KdpPortIrq = Value; - } - } - } - - // HACK use com1 for FrLdrDbg, com2 for WinDbg - DefaultPort.ComPort = 2; - - /* Get base address */ - DefaultPort.BaseAddress = BaseArray[DefaultPort.ComPort]; - - /* Check if the COM port does exist */ - if (!KdpDoesComPortExist(DefaultPort.BaseAddress)) - { - return STATUS_INVALID_PARAMETER; - } - - /* Initialize the port */ - KdPortInitializeEx(&DefaultPort, 0, 0); - PortInitialized = TRUE; - - return STATUS_SUCCESS; + return STATUS_NOT_IMPLEMENTED; } -/****************************************************************************** - * \name KdDebuggerInitialize1 - * \brief Phase 1 initialization. - * \param [opt] LoaderBlock Pointer to the Loader parameter block. Can be NULL. - * \return Status +/* + * @unimplemented */ NTSTATUS NTAPI KdDebuggerInitialize1( IN PLOADER_PARAMETER_BLOCK LoaderBlock OPTIONAL) { - // HACK: misuse this function to get a pointer to FrLdrDbgPrint - FrLdrDbgPrint = (PVOID)LoaderBlock; return STATUS_NOT_IMPLEMENTED; } @@ -795,86 +524,12 @@ KdSendPacket( IN PSTRING MessageData, IN OUT PKD_CONTEXT Context) { - KD_PACKET Packet; - KDSTATUS RcvCode; - - for (;;) - { - /* Initialize a KD_PACKET */ - Packet.PacketLeader = PACKET_LEADER; - Packet.PacketType = PacketType; - Packet.ByteCount = MessageHeader->Length; - Packet.Checksum = KdpCalculateChecksum(MessageHeader->Buffer, - MessageHeader->Length); - - /* If we have message data, add it to the packet */ - if (MessageData) - { - Packet.ByteCount += MessageData->Length; - Packet.Checksum += KdpCalculateChecksum(MessageData->Buffer, - MessageData->Length); - } - - /* Set the packet id */ - Packet.PacketId = CurrentPacketId; - - /* Send the packet header to the KD port */ - KdpSendBuffer(&Packet, sizeof(KD_PACKET)); - - /* Send the message header */ - KdpSendBuffer(MessageHeader->Buffer, MessageHeader->Length); - - /* If we have meesage data, also send it */ - if (MessageData) - { - KdpSendBuffer(MessageData->Buffer, MessageData->Length); - } - - /* Finalize with a trailing byte */ - KdPortPutByte(PACKET_TRAILING_BYTE); - - /* Wait for acknowledge */ - RcvCode = KdReceivePacket(PACKET_TYPE_KD_ACKNOWLEDGE, - NULL, - NULL, - 0, - NULL); - - /* Did we succeed? */ - if (RcvCode == KdPacketReceived) - { - CurrentPacketId &= ~SYNC_PACKET_ID; - break; - } - - /* PACKET_TYPE_KD_DEBUG_IO is allowed to instantly timeout */ - if (PacketType == PACKET_TYPE_KD_DEBUG_IO) - { - /* No response, silently fail. */ -// return; - } - - /* Packet timed out, send it again */ - } - + UNIMPLEMENTED; return; } - -/****************************************************************************** - * \name KdReceivePacket - * \brief Receive a packet from the KD port. - * \param [in] PacketType Describes the type of the packet to receive. - * This can be one of the PACKET_TYPE_ constants. - * \param [out] MessageHeader Pointer to a STRING structure for the header. - * \param [out] MessageData Pointer to a STRING structure for the data. - * \return KdPacketReceived if successful, KdPacketTimedOut if the receive - * timed out, KdPacketNeedsResend to signal that the last packet needs - * to be sent again. - * \note If PacketType is PACKET_TYPE_KD_POLL_BREAKIN, the function doesn't - * wait for any data, but returns KdPacketTimedOut instantly if no breakin - * packet byte is received. - * \sa http://www.nynaeve.net/?p=169 +/* + * @unimplemented */ KDSTATUS NTAPI @@ -885,215 +540,8 @@ KdReceivePacket( OUT PULONG DataLength, IN OUT PKD_CONTEXT Context) { - UCHAR Byte = 0; - KDSTATUS RcvCode; - KD_PACKET Packet; - ULONG Checksum; - - /* Special handling for breakin packet */ - if(PacketType == PACKET_TYPE_KD_POLL_BREAKIN) - { - if (KdPortGetByteEx(&DefaultPort, &Byte)) - { - if (Byte == BREAKIN_PACKET_BYTE) - { - return KdPacketReceived; - } - } - return KdPacketTimedOut; - } - - for (;;) - { - /* Step 1 - Read PacketLeader */ - RcvCode = KdpReceivePacketLeader(&Packet.PacketLeader); - if (RcvCode != KdPacketReceived) - { - /* Couldn't read a correct packet leader. Start over. */ - continue; - } - - /* Step 2 - Read PacketType */ - RcvCode = KdpReceiveBuffer(&Packet.PacketType, sizeof(USHORT)); - if (RcvCode != KdPacketReceived) - { - /* Didn't receive a PacketType or PacketType is bad. Start over. */ - continue; - } - - /* Step 3 - Read ByteCount */ - RcvCode = KdpReceiveBuffer(&Packet.ByteCount, sizeof(USHORT)); - if (RcvCode != KdPacketReceived || Packet.ByteCount > PACKET_MAX_SIZE) - { - /* Didn't receive ByteCount or it's too big. Start over. */ - continue; - } - - /* Step 4 - Read PacketId */ - RcvCode = KdpReceiveBuffer(&Packet.PacketId, sizeof(ULONG)); - if (RcvCode != KdPacketReceived) - { - /* Didn't receive PacketId. Start over. */ - continue; - } - -/* - if (Packet.PacketId != ExpectedPacketId) - { - // Ask for a resend! - continue; - } -*/ - - /* Step 5 - Read Checksum */ - RcvCode = KdpReceiveBuffer(&Packet.Checksum, sizeof(ULONG)); - if (RcvCode != KdPacketReceived) - { - /* Didn't receive Checksum. Start over. */ - continue; - } - - /* Step 6 - Handle control packets */ - if (Packet.PacketLeader == CONTROL_PACKET_LEADER) - { - switch (Packet.PacketType) - { - case PACKET_TYPE_KD_ACKNOWLEDGE: - if (PacketType == PACKET_TYPE_KD_ACKNOWLEDGE) - { - /* Remote acknowledges the last packet */ - CurrentPacketId ^= 1; - return KdPacketReceived; - } - /* That's not what we were waiting for, start over. */ - continue; - - case PACKET_TYPE_KD_RESET: - FrLdrDbgPrint("KdReceivePacket - got a reset packet\n"); - KdpSendControlPacket(PACKET_TYPE_KD_RESET, 0); - CurrentPacketId = INITIAL_PACKET_ID; - /* Fall through */ - - case PACKET_TYPE_KD_RESEND: - /* Remote wants us to resend the last packet */ - return KdPacketNeedsResend; - - default: - FrLdrDbgPrint("KdReceivePacket - got unknown control packet\n"); - return KdPacketNeedsResend; - } - } - - /* Did we wait for an ack packet? */ - if (PacketType == PACKET_TYPE_KD_ACKNOWLEDGE) - { - /* We received something different, start over */ - continue; - } - - /* Did we get the right packet type? */ - if (PacketType != Packet.PacketType) - { - /* We received something different, start over */ - continue; - } - - /* Get size of the message header */ - switch (Packet.PacketType) - { - case PACKET_TYPE_KD_STATE_CHANGE64: - MessageHeader->Length = sizeof(DBGKD_WAIT_STATE_CHANGE64); - break; - - case PACKET_TYPE_KD_STATE_MANIPULATE: - MessageHeader->Length = sizeof(DBGKD_MANIPULATE_STATE64); - break; - - case PACKET_TYPE_KD_DEBUG_IO: - MessageHeader->Length = sizeof(DBGKD_DEBUG_IO); - break; - - default: - FrLdrDbgPrint("KdReceivePacket - unknown PacketType\n"); - return KdPacketNeedsResend; - } - -//FrLdrDbgPrint("KdReceivePacket - got normal PacketType\n"); - - /* Packet smaller than expected? */ - if (MessageHeader->Length > Packet.ByteCount) - { - FrLdrDbgPrint("KdReceivePacket - too few data (%d) for type %d\n", - Packet.ByteCount, MessageHeader->Length); - MessageHeader->Length = Packet.ByteCount; - } - -//FrLdrDbgPrint("KdReceivePacket - got normal PacketType, Buffer = %p\n", MessageHeader->Buffer); - - /* Receive the message header data */ - RcvCode = KdpReceiveBuffer(MessageHeader->Buffer, - MessageHeader->Length); - if (RcvCode != KdPacketReceived) - { - /* Didn't receive data. Start over. */ - FrLdrDbgPrint("KdReceivePacket - Didn't receive message header data. Start over\n"); - continue; - } - -//FrLdrDbgPrint("KdReceivePacket - got normal PacketType 3\n"); - - /* Calculate checksum for the header data */ - Checksum = KdpCalculateChecksum(MessageHeader->Buffer, - MessageHeader->Length); - - /* Shall we receive messsage data? */ - if (MessageData) - { - /* Calculate the length of the message data */ - MessageData->Length = Packet.ByteCount - MessageHeader->Length; - - /* Do we have data? */ - if (MessageData->Length) - { - FrLdrDbgPrint("KdReceivePacket - got data\n"); - - /* Receive the message data */ - RcvCode = KdpReceiveBuffer(MessageData->Buffer, - MessageData->Length); - if (RcvCode != KdPacketReceived) - { - /* Didn't receive data. Start over. */ - FrLdrDbgPrint("KdReceivePacket - Didn't receive message data. Start over\n"); - continue; - } - - /* Add cheksum for message data */ - Checksum += KdpCalculateChecksum(MessageData->Buffer, - MessageData->Length); - } - } - - /* Compare checksum */ - if (Packet.Checksum != Checksum) - { - KdpSendControlPacket(PACKET_TYPE_KD_RESEND, CurrentPacketId); - FrLdrDbgPrint("KdReceivePacket - wrong cheksum, got %x, calculated %x\n", - Packet.Checksum, Checksum); - continue; - } - - /* We must receive a PACKET_TRAILING_BYTE now */ - RcvCode = KdpReceiveBuffer(&Byte, sizeof(UCHAR)); - - /* Acknowledge the received packet */ - KdpSendControlPacket(PACKET_TYPE_KD_ACKNOWLEDGE, Packet.PacketId); - -//FrLdrDbgPrint("KdReceivePacket - all ok\n"); - - return KdPacketReceived; - } - - return KdPacketReceived; + UNIMPLEMENTED; + return 0; } /* EOF */ From 6965a0af8a8730432a1b4b65fec0aa347128a80d Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Thu, 25 Mar 2010 21:29:59 +0000 Subject: [PATCH 019/134] - Reduce diff to trunk svn path=/branches/ros-amd64-bringup/; revision=46451 --- reactos/Doxyfile | 8 ++++---- reactos/ReactOS-arm.rbuild | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/reactos/Doxyfile b/reactos/Doxyfile index 47962cf501e..386ca57fdf4 100644 --- a/reactos/Doxyfile +++ b/reactos/Doxyfile @@ -590,7 +590,7 @@ WARN_LOGFILE = # directories like "/usr/src/myproject". Separate the files or directories # with spaces. -INPUT = . +INPUT = # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is @@ -723,7 +723,7 @@ INLINE_SOURCES = YES # doxygen to hide any special comment blocks from generated source code # fragments. Normal C and C++ comments will always remain visible. -STRIP_CODE_COMMENTS = NO +STRIP_CODE_COMMENTS = YES # If the REFERENCED_BY_RELATION tag is set to YES # then for each documented function all documented @@ -806,13 +806,13 @@ HTML_FILE_EXTENSION = .html # each generated HTML page. If it is left blank doxygen will generate a # standard header. -HTML_HEADER = +HTML_HEADER = Doxygen/header.html # The HTML_FOOTER tag can be used to specify a personal HTML footer for # each generated HTML page. If it is left blank doxygen will generate a # standard footer. -HTML_FOOTER = +HTML_FOOTER = Doxygen/footer.html # The HTML_STYLESHEET tag can be used to specify a user-defined cascading # style sheet that is used by each HTML page. It can be used to diff --git a/reactos/ReactOS-arm.rbuild b/reactos/ReactOS-arm.rbuild index f6b36ebc64a..777a1aa2cc3 100644 --- a/reactos/ReactOS-arm.rbuild +++ b/reactos/ReactOS-arm.rbuild @@ -8,16 +8,16 @@ - + - + - + - + include/reactos/arm @@ -33,9 +33,9 @@ -UUNICODE - + - + --strip-debug -static From 518b7b47b4d5338d1f0afa6c95c0a07fa986fa30 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Fri, 26 Mar 2010 00:25:40 +0000 Subject: [PATCH 020/134] reduce diff to trunk svn path=/branches/ros-amd64-bringup/; revision=46456 --- reactos/tools/rbuild/backend/mingw/modulehandler.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/reactos/tools/rbuild/backend/mingw/modulehandler.cpp b/reactos/tools/rbuild/backend/mingw/modulehandler.cpp index bea9ae665b4..3148e68b078 100644 --- a/reactos/tools/rbuild/backend/mingw/modulehandler.cpp +++ b/reactos/tools/rbuild/backend/mingw/modulehandler.cpp @@ -1423,13 +1423,13 @@ void MingwModuleHandler::GenerateLinkerCommand () const { string definitionFilename; - + const FileLocation *DefinitionFilename = GetDefinitionFilename (); if ( DefinitionFilename ) { definitionFilename = backend->GetFullName (*DefinitionFilename); delete DefinitionFilename; -} + } string linkerScriptArgument; if ( module.linkerScript != NULL ) { @@ -1446,7 +1446,7 @@ MingwModuleHandler::GenerateLinkerCommand () const if ( ModuleHandlerInformations[module.type].DefaultHost == HostFalse ) { if ( module.cplusplus ) { switch ( module.type ) - { + { case Win32DLL: case Win32OCX: case Win32CUI: @@ -1458,7 +1458,7 @@ MingwModuleHandler::GenerateLinkerCommand () const default: extraLibraries = "$$(PROJECT_CCLIBS)"; break; - } + } } else extraLibraries = "$$(PROJECT_CCLIBS)"; } @@ -1466,7 +1466,7 @@ MingwModuleHandler::GenerateLinkerCommand () const delete PassThruCacheDirectory ( new FileLocation ( module.output->directory, module.output->relative_path, "" ) ); delete PassThruCacheDirectory ( new FileLocation ( IntermediateDirectory, module.output->relative_path, "" ) ); - fprintf ( fMakefile, + fprintf ( fMakefile, "$(eval $(call RBUILD_LINK_RULE,%s,%s,%s,%s,%s,%s,%s))\n", module.name.c_str(), definitionFilename.c_str(), @@ -3101,4 +3101,4 @@ MingwElfExecutableModuleHandler::Process () delete target_file; fprintf ( fMakefile, "#/ELF EXECUTABLE TARGET\n" ); -} \ No newline at end of file +} From cb29f7174b56ceaa4a94ba4d926f3177347d2a47 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Fri, 26 Mar 2010 08:58:45 +0000 Subject: [PATCH 021/134] Looks like ld doesn't like specifying "-fno-leading-underscore" for anything else then shared modules (aka dlls). Therefore specify "-shared" for apps, too (Should hopefully not make a difference), making them link again. Since we have switched to non-prefixed symbols, we need to deal with 2 kinds of symbols that the compiler doesn't handle for us. 1.) __image_base__ is still defined the same way by ld, but since gcc doesn't give us an underscore anymore, we need to specify it on our own. 2.) __MINGW_IMP_SYMBOL, which is a hacky way of declaring a symbol dllimport, by prefixing it with __imp_ also needs special treatment. Fix these issues by adding appropriate macros to _mingw.h and removing the broken and duplicate definitions from multiple .c files. svn path=/branches/ros-amd64-bringup/; revision=46460 --- reactos/ReactOS-amd64.rbuild | 2 ++ reactos/include/crt/_mingw.h | 20 +++++++++++++++++++- reactos/lib/3rdparty/mingw/crt_handler.c | 8 -------- reactos/lib/3rdparty/mingw/crtexe.c | 5 ----- reactos/lib/3rdparty/mingw/pesect.c | 9 --------- reactos/lib/3rdparty/mingw/pseudo-reloc.c | 3 +-- 6 files changed, 22 insertions(+), 25 deletions(-) diff --git a/reactos/ReactOS-amd64.rbuild b/reactos/ReactOS-amd64.rbuild index 4faae306bdd..6d9f8640d08 100644 --- a/reactos/ReactOS-amd64.rbuild +++ b/reactos/ReactOS-amd64.rbuild @@ -28,6 +28,7 @@ -ftracer -momit-leaf-frame-pointer + -fms-extensions -mpreferred-stack-boundary=4 -m64 --win64 @@ -44,6 +45,7 @@ --unique=.eh_frame -static -fno-leading-underscore + -shared --exclude-all-symbols diff --git a/reactos/include/crt/_mingw.h b/reactos/include/crt/_mingw.h index d5b9d37979d..2ee41f23294 100644 --- a/reactos/include/crt/_mingw.h +++ b/reactos/include/crt/_mingw.h @@ -197,15 +197,33 @@ allow GCC to optimize away some EH unwind code, at least in DW2 case. */ #define _CRT_UNUSED(x) (void)x #endif +#if defined(__x86__) #define __MINGW_USE_UNDERSCORE_PREFIX 1 +#else +#define __MINGW_USE_UNDERSCORE_PREFIX 0 +#endif #if __MINGW_USE_UNDERSCORE_PREFIX == 0 -#define __MINGW_IMP_SYMBOL(sym) _imp_##sym +#define __MINGW_IMP_SYMBOL(sym) __imp_##sym #define __MINGW_USYMBOL(sym) sym #else #define __MINGW_IMP_SYMBOL(sym) _imp__##sym #define __MINGW_USYMBOL(sym) _##sym #endif +#if defined(__x86__) +/* Hack, for bug in ld. Will be removed soon. */ +#define __ImageBase _image_base__ +/* This symbol is defined by the linker. */ +extern char __ImageBase; +#elif defined(__x86_64__) +/* Hack, for bug in ld. Will be removed soon. */ +#define __ImageBase __image_base__ +/* This symbol is defined by the linker. */ +extern char __ImageBase; +#else +#error FIXME: Unsupported __ImageBase implementation. +#endif + #endif /* !_INC_MINGW */ diff --git a/reactos/lib/3rdparty/mingw/crt_handler.c b/reactos/lib/3rdparty/mingw/crt_handler.c index b87e14e4798..19fee7c0a42 100644 --- a/reactos/lib/3rdparty/mingw/crt_handler.c +++ b/reactos/lib/3rdparty/mingw/crt_handler.c @@ -13,14 +13,6 @@ #include #include -#if defined (_WIN64) && defined (__ia64__) -#error FIXME: Unsupported __ImageBase implementation. -#else -#define __ImageBase _image_base__ -/* This symbol is defined by the linker. */ -extern IMAGE_DOS_HEADER __ImageBase; -#endif - #pragma pack(push,1) typedef struct _UNWIND_INFO { BYTE VersionAndFlags; diff --git a/reactos/lib/3rdparty/mingw/crtexe.c b/reactos/lib/3rdparty/mingw/crtexe.c index 409b76bbdfa..9834cb29be0 100644 --- a/reactos/lib/3rdparty/mingw/crtexe.c +++ b/reactos/lib/3rdparty/mingw/crtexe.c @@ -32,11 +32,6 @@ extern char *** __MINGW_IMP_SYMBOL(__initenv); #define __initenv (* __MINGW_IMP_SYMBOL(__initenv)) #endif -/* Hack, for bug in ld. Will be removed soon. */ -#define __ImageBase _image_base__ -/* This symbol is defined by ld. */ -extern IMAGE_DOS_HEADER __ImageBase; - extern void _fpreset (void); #define SPACECHAR _T(' ') #define DQUOTECHAR _T('\"') diff --git a/reactos/lib/3rdparty/mingw/pesect.c b/reactos/lib/3rdparty/mingw/pesect.c index 2e835f252f8..c51a6d2522d 100644 --- a/reactos/lib/3rdparty/mingw/pesect.c +++ b/reactos/lib/3rdparty/mingw/pesect.c @@ -7,15 +7,6 @@ #include #include -#if defined (_WIN64) && defined (__ia64__) -#error FIXME: Unsupported __ImageBase implementation. -#else -/* Hack, for bug in ld. Will be removed soon. */ -#define __ImageBase _image_base__ -/* This symbol is defined by the linker. */ -extern IMAGE_DOS_HEADER __ImageBase; -#endif - BOOL _ValidateImageBase (PBYTE); BOOL diff --git a/reactos/lib/3rdparty/mingw/pseudo-reloc.c b/reactos/lib/3rdparty/mingw/pseudo-reloc.c index 8b5de51ff53..ea0ea8a49c3 100644 --- a/reactos/lib/3rdparty/mingw/pseudo-reloc.c +++ b/reactos/lib/3rdparty/mingw/pseudo-reloc.c @@ -16,7 +16,6 @@ extern char __RUNTIME_PSEUDO_RELOC_LIST__; extern char __RUNTIME_PSEUDO_RELOC_LIST_END__; -extern char _image_base__; typedef struct { DWORD addend; @@ -162,5 +161,5 @@ _pei386_runtime_relocator (void) if (was_init) return; ++was_init; - do_pseudo_reloc (&__RUNTIME_PSEUDO_RELOC_LIST__,&__RUNTIME_PSEUDO_RELOC_LIST_END__,&_image_base__); + do_pseudo_reloc (&__RUNTIME_PSEUDO_RELOC_LIST__,&__RUNTIME_PSEUDO_RELOC_LIST_END__,&__ImageBase); } From 67e1375139e299c3e1792d10d99738bf02fb7621 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Fri, 26 Mar 2010 16:03:03 +0000 Subject: [PATCH 022/134] [HAL] Fix rbuild files svn path=/branches/ros-amd64-bringup/; revision=46469 --- reactos/hal/halx86/hal_generic.rbuild | 14 ++++---------- reactos/hal/halx86/hal_generic_up.rbuild | 6 ------ 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/reactos/hal/halx86/hal_generic.rbuild b/reactos/hal/halx86/hal_generic.rbuild index c79ea36785b..066d6c38c65 100644 --- a/reactos/hal/halx86/hal_generic.rbuild +++ b/reactos/hal/halx86/hal_generic.rbuild @@ -27,24 +27,17 @@ sysinfo.c timer.c usage.c - - - portio.c - systimer.S bios.c - halinit.c - misc.c - pic.c - trap.S portio.c systimer.S - v86.s + trap.S + x86bios.c halinit.c irq.S misc.c @@ -81,6 +74,7 @@ sysbus.c beep.c + bios.c cmos.c dma.c display.c @@ -106,7 +100,7 @@ apic.c systimer.S usage.c - + diff --git a/reactos/hal/halx86/hal_generic_up.rbuild b/reactos/hal/halx86/hal_generic_up.rbuild index 80365f9b46f..732a374b86c 100644 --- a/reactos/hal/halx86/hal_generic_up.rbuild +++ b/reactos/hal/halx86/hal_generic_up.rbuild @@ -13,11 +13,5 @@ pic.c processor.c - - processor.c - - irq.S - - From 14d311ab865474ba4a1770606f6a85436b5c0448 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Fri, 26 Mar 2010 19:00:34 +0000 Subject: [PATCH 023/134] [ACPI] Add amd64 stubs for ACPI_ACQUIRE_GLOBAL_LOCK and ACPI_RELEASE_GLOBAL_LOCK svn path=/branches/ros-amd64-bringup/; revision=46472 --- .../bus/acpi/acpica/include/platform/acgcc.h | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/reactos/drivers/bus/acpi/acpica/include/platform/acgcc.h b/reactos/drivers/bus/acpi/acpica/include/platform/acgcc.h index e517a23ae22..354fe2e5296 100644 --- a/reactos/drivers/bus/acpi/acpica/include/platform/acgcc.h +++ b/reactos/drivers/bus/acpi/acpica/include/platform/acgcc.h @@ -134,6 +134,33 @@ */ #define ACPI_UNUSED_VAR __attribute__ ((unused)) +#if defined (_AMD64_) + +#define COMPILER_DEPENDENT_INT64 long long int +#define COMPILER_DEPENDENT_UINT64 unsigned long long int + +// FIXME: These are only sonly stubs to make it compile + +#define ACPI_ACQUIRE_GLOBAL_LOCK(GLptr, Acq) \ + do { \ + int dummy; \ + asm("1: movl (%1),%%eax;" \ + "movl %%eax,%%edx;" \ + :"=a"(Acq),"=c"(dummy):"c"(GLptr),"i"(~1L):"dx"); \ + } while(0) + +#define ACPI_RELEASE_GLOBAL_LOCK(GLptr, Acq) \ + do { \ + int dummy; \ + asm("1: movl (%1),%%eax;" \ + "movl %%eax,%%edx;" \ + :"=a"(Acq),"=c"(dummy):"c"(GLptr),"i"(~3L):"dx"); \ + } while(0) + +/*! [End] no source code translation !*/ + +#else /* DO IA32 */ + #define COMPILER_DEPENDENT_INT64 long long int #define COMPILER_DEPENDENT_UINT64 unsigned long long int @@ -164,6 +191,9 @@ :"=a"(Acq),"=c"(dummy):"c"(GLptr),"i"(~3L):"dx"); \ } while(0) +#endif /* IA 32 */ + + #define ACPI_DIV_64_BY_32(n_hi, n_lo, d32, q32, r32) \ { \ q32 = n_hi / d32; \ From faffa5519cc1329f58b3dba59eb64fe218bc9858 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Fri, 26 Mar 2010 19:01:21 +0000 Subject: [PATCH 024/134] [LIBJPG] Comment out libjpg for now. It fails badly. Maybe we need a spec file or something. svn path=/branches/ros-amd64-bringup/; revision=46473 --- reactos/dll/3rdparty/3rdparty.rbuild | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reactos/dll/3rdparty/3rdparty.rbuild b/reactos/dll/3rdparty/3rdparty.rbuild index e2d58af9496..5f0458d782a 100644 --- a/reactos/dll/3rdparty/3rdparty.rbuild +++ b/reactos/dll/3rdparty/3rdparty.rbuild @@ -4,9 +4,9 @@ - + From f8b4d53d3c62951de5fedc0d34b82ec901e65f98 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Fri, 26 Mar 2010 23:39:12 +0000 Subject: [PATCH 025/134] revert r39331 svn path=/branches/ros-amd64-bringup/; revision=46477 --- reactos/lib/sdk/crt/stdio/file.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/reactos/lib/sdk/crt/stdio/file.c b/reactos/lib/sdk/crt/stdio/file.c index 3bd1f7b668d..a3540ce28bd 100644 --- a/reactos/lib/sdk/crt/stdio/file.c +++ b/reactos/lib/sdk/crt/stdio/file.c @@ -118,11 +118,6 @@ static CRITICAL_SECTION FILE_cs; #define LOCK_FILES() do { EnterCriticalSection(&FILE_cs); } while (0) #define UNLOCK_FILES() do { LeaveCriticalSection(&FILE_cs); } while (0) -FILE *__cdecl __iob_func() -{ - return _iob; -} - static inline BOOL is_valid_fd(int fd) { return fd >= 0 && fd < fdend && (fdesc[fd].wxflag & WX_OPEN); From c57a8df416b4266843a6601f6a7378dfd6526e6f Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Fri, 26 Mar 2010 23:41:53 +0000 Subject: [PATCH 026/134] [CRT] - define _CRTBLD - rename float_t/double_t/long_double_t to float_s/double_s/long_double_s to avoid name conflicts svn path=/branches/ros-amd64-bringup/; revision=46478 --- reactos/lib/sdk/crt/crt.rbuild | 1 + reactos/lib/sdk/crt/except/xcptfil.c | 2 +- reactos/lib/sdk/crt/float/chgsign.c | 2 +- reactos/lib/sdk/crt/float/copysign.c | 4 ++-- reactos/lib/sdk/crt/float/fpclass.c | 2 +- reactos/lib/sdk/crt/float/isnan.c | 8 ++++---- reactos/lib/sdk/crt/float/scalb.c | 2 +- reactos/lib/sdk/crt/include/internal/ieee.h | 6 +++--- reactos/lib/sdk/crt/libcntpr.rbuild | 1 + reactos/lib/sdk/crt/math/frexp.c | 2 +- reactos/lib/sdk/crt/math/huge_val.c | 2 +- reactos/lib/sdk/crt/math/modf.c | 4 ++-- 12 files changed, 19 insertions(+), 17 deletions(-) diff --git a/reactos/lib/sdk/crt/crt.rbuild b/reactos/lib/sdk/crt/crt.rbuild index 799099848ea..5c06273be9d 100644 --- a/reactos/lib/sdk/crt/crt.rbuild +++ b/reactos/lib/sdk/crt/crt.rbuild @@ -25,6 +25,7 @@ + cgets.c cprintf.c diff --git a/reactos/lib/sdk/crt/except/xcptfil.c b/reactos/lib/sdk/crt/except/xcptfil.c index e617af5119e..e294e127a81 100644 --- a/reactos/lib/sdk/crt/except/xcptfil.c +++ b/reactos/lib/sdk/crt/except/xcptfil.c @@ -94,7 +94,7 @@ _XcptFilter(DWORD ExceptionCode, return ret; } -int CDECL __CppXcptFilter(NTSTATUS ex, PEXCEPTION_POINTERS ptr) +int CDECL __CppXcptFilter(unsigned long ex, PEXCEPTION_POINTERS ptr) { /* only filter c++ exceptions */ if (ex != CXX_EXCEPTION) return EXCEPTION_CONTINUE_SEARCH; diff --git a/reactos/lib/sdk/crt/float/chgsign.c b/reactos/lib/sdk/crt/float/chgsign.c index 2cc440ff9de..a9d9a1d3aed 100644 --- a/reactos/lib/sdk/crt/float/chgsign.c +++ b/reactos/lib/sdk/crt/float/chgsign.c @@ -20,7 +20,7 @@ double _chgsign( double __x ) union { double* __x; - double_t *x; + double_s *x; } u; u.__x = &__x; diff --git a/reactos/lib/sdk/crt/float/copysign.c b/reactos/lib/sdk/crt/float/copysign.c index 992f82c3cea..5ebdeb1e854 100644 --- a/reactos/lib/sdk/crt/float/copysign.c +++ b/reactos/lib/sdk/crt/float/copysign.c @@ -19,12 +19,12 @@ double _copysign (double __d, double __s) union { double* __d; - double_t* d; + double_s* d; } d; union { double* __s; - double_t* s; + double_s* s; } s; d.__d = &__d; s.__s = &__s; diff --git a/reactos/lib/sdk/crt/float/fpclass.c b/reactos/lib/sdk/crt/float/fpclass.c index 665379c21bf..82d3d4edb83 100644 --- a/reactos/lib/sdk/crt/float/fpclass.c +++ b/reactos/lib/sdk/crt/float/fpclass.c @@ -50,7 +50,7 @@ fpclass_t _fpclass(double __d) union { double* __d; - double_t* d; + double_s* d; } d; d.__d = &__d; diff --git a/reactos/lib/sdk/crt/float/isnan.c b/reactos/lib/sdk/crt/float/isnan.c index 1269df14e7e..fb328d30d97 100644 --- a/reactos/lib/sdk/crt/float/isnan.c +++ b/reactos/lib/sdk/crt/float/isnan.c @@ -28,7 +28,7 @@ int _isnan(double __x) union { double* __x; - double_t* x; + double_s* x; } x; x.__x = &__x; return ( x.x->exponent == 0x7ff && ( x.x->mantissah != 0 || x.x->mantissal != 0 )); @@ -41,7 +41,7 @@ int _isnanl(long double __x) union { long double* __x; - long_double_t* x; + long_double_s* x; } x; x.__x = &__x; @@ -59,7 +59,7 @@ int _isinf(double __x) union { double* __x; - double_t* x; + double_s* x; } x; x.__x = &__x; @@ -81,7 +81,7 @@ int _isinfl(long double __x) union { long double* __x; - long_double_t* x; + long_double_s* x; } x; x.__x = &__x; diff --git a/reactos/lib/sdk/crt/float/scalb.c b/reactos/lib/sdk/crt/float/scalb.c index ac521d0e127..f147a6e03cc 100644 --- a/reactos/lib/sdk/crt/float/scalb.c +++ b/reactos/lib/sdk/crt/float/scalb.c @@ -19,7 +19,7 @@ double _scalb( double __x, long e ) union { double* __x; - double_t* x; + double_s* x; } x; x.__x = &__x; diff --git a/reactos/lib/sdk/crt/include/internal/ieee.h b/reactos/lib/sdk/crt/include/internal/ieee.h index f397723feae..bcc693d94a6 100644 --- a/reactos/lib/sdk/crt/include/internal/ieee.h +++ b/reactos/lib/sdk/crt/include/internal/ieee.h @@ -5,14 +5,14 @@ typedef struct { unsigned int mantissa:23; unsigned int exponent:8; unsigned int sign:1; -} float_t; +} float_s; typedef struct { unsigned int mantissal:32; unsigned int mantissah:20; unsigned int exponent:11; unsigned int sign:1; -} double_t; +} double_s; typedef struct { unsigned int mantissal:32; @@ -20,6 +20,6 @@ typedef struct { unsigned int exponent:15; unsigned int sign:1; unsigned int empty:16; -} long_double_t; +} long_double_s; #endif diff --git a/reactos/lib/sdk/crt/libcntpr.rbuild b/reactos/lib/sdk/crt/libcntpr.rbuild index 156f4b9240d..bb500d681f1 100644 --- a/reactos/lib/sdk/crt/libcntpr.rbuild +++ b/reactos/lib/sdk/crt/libcntpr.rbuild @@ -7,6 +7,7 @@ + "extern __attribute__ ((dllexport))" diff --git a/reactos/lib/sdk/crt/math/frexp.c b/reactos/lib/sdk/crt/math/frexp.c index 913cc5c7271..fa8de1e01da 100644 --- a/reactos/lib/sdk/crt/math/frexp.c +++ b/reactos/lib/sdk/crt/math/frexp.c @@ -11,7 +11,7 @@ frexp(double __x, int *exptr) union { double* __x; - double_t* x; + double_s* x; } x; x.__x = &__x; diff --git a/reactos/lib/sdk/crt/math/huge_val.c b/reactos/lib/sdk/crt/math/huge_val.c index 66b5716bf80..4bab35cf60c 100644 --- a/reactos/lib/sdk/crt/math/huge_val.c +++ b/reactos/lib/sdk/crt/math/huge_val.c @@ -3,4 +3,4 @@ #include #undef _HUGE -double_t _HUGE = { 0x00000, 0x00000, 0x7ff, 0x0 }; +double_s _HUGE = { 0x00000, 0x00000, 0x7ff, 0x0 }; diff --git a/reactos/lib/sdk/crt/math/modf.c b/reactos/lib/sdk/crt/math/modf.c index 72b937c36d5..8212070e2c8 100644 --- a/reactos/lib/sdk/crt/math/modf.c +++ b/reactos/lib/sdk/crt/math/modf.c @@ -21,12 +21,12 @@ long double modfl(long double __x, long double *__i) union { long double* __x; - long_double_t* x; + long_double_s* x; } x; union { long double* __i; - long_double_t* iptr; + long_double_s* iptr; } iptr; int j0; From d134d80d0b0551260a17a919bb8caf74498ba05d Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sat, 27 Mar 2010 01:14:24 +0000 Subject: [PATCH 027/134] [CRT] - add _wctype table, it's not identical to _ctype as assumed before - point _pwctype to _wctype instead of _ctype - implement __pctype_func and __pwctype_func svn path=/branches/ros-amd64-bringup/; revision=46483 --- reactos/lib/sdk/crt/string/ctype.c | 271 ++++++++++++++++++++++++++++- 1 file changed, 270 insertions(+), 1 deletion(-) diff --git a/reactos/lib/sdk/crt/string/ctype.c b/reactos/lib/sdk/crt/string/ctype.c index a4873cebdd4..28dcda5ab66 100644 --- a/reactos/lib/sdk/crt/string/ctype.c +++ b/reactos/lib/sdk/crt/string/ctype.c @@ -289,8 +289,267 @@ const unsigned short _ctype[] = { 0 /* 0xff */ }; +const unsigned short _wctype[] = { + 0, /* , 0xFFFF */ + _CONTROL, /* CTRL+@, 0x00 */ + _CONTROL, /* CTRL+A, 0x01 */ + _CONTROL, /* CTRL+B, 0x02 */ + _CONTROL, /* CTRL+C, 0x03 */ + _CONTROL, /* CTRL+D, 0x04 */ + _CONTROL, /* CTRL+E, 0x05 */ + _CONTROL, /* CTRL+F, 0x06 */ + _CONTROL, /* CTRL+G, 0x07 */ + _CONTROL, /* CTRL+H, 0x08 */ + _BLANK | _CONTROL | _SPACE, /* CTRL+I, 0x09 */ + _CONTROL | _SPACE, /* CTRL+J, 0x0a */ + _CONTROL | _SPACE, /* CTRL+K, 0x0b */ + _CONTROL | _SPACE, /* CTRL+L, 0x0c */ + _CONTROL | _SPACE, /* CTRL+M, 0x0d */ + _CONTROL, /* CTRL+N, 0x0e */ + _CONTROL, /* CTRL+O, 0x0f */ + _CONTROL, /* CTRL+P, 0x10 */ + _CONTROL, /* CTRL+Q, 0x11 */ + _CONTROL, /* CTRL+R, 0x12 */ + _CONTROL, /* CTRL+S, 0x13 */ + _CONTROL, /* CTRL+T, 0x14 */ + _CONTROL, /* CTRL+U, 0x15 */ + _CONTROL, /* CTRL+V, 0x16 */ + _CONTROL, /* CTRL+W, 0x17 */ + _CONTROL, /* CTRL+X, 0x18 */ + _CONTROL, /* CTRL+Y, 0x19 */ + _CONTROL, /* CTRL+Z, 0x1a */ + _CONTROL, /* CTRL+[, 0x1b */ + _CONTROL, /* CTRL+\, 0x1c */ + _CONTROL, /* CTRL+], 0x1d */ + _CONTROL, /* CTRL+^, 0x1e */ + _CONTROL, /* CTRL+_, 0x1f */ + _SPACE | _BLANK, /* ` ', 0x20 */ + _PUNCT, /* `!', 0x21 */ + _PUNCT, /* 0x22 */ + _PUNCT, /* `#', 0x23 */ + _PUNCT, /* `$', 0x24 */ + _PUNCT, /* `%', 0x25 */ + _PUNCT, /* `&', 0x26 */ + _PUNCT, /* 0x27 */ + _PUNCT, /* `(', 0x28 */ + _PUNCT, /* `)', 0x29 */ + _PUNCT, /* `*', 0x2a */ + _PUNCT, /* `+', 0x2b */ + _PUNCT, /* `,', 0x2c */ + _PUNCT, /* `-', 0x2d */ + _PUNCT, /* `.', 0x2e */ + _PUNCT, /* `/', 0x2f */ + _DIGIT | _HEX, /* `0', 0x30 */ + _DIGIT | _HEX, /* `1', 0x31 */ + _DIGIT | _HEX, /* `2', 0x32 */ + _DIGIT | _HEX, /* `3', 0x33 */ + _DIGIT | _HEX, /* `4', 0x34 */ + _DIGIT | _HEX, /* `5', 0x35 */ + _DIGIT | _HEX, /* `6', 0x36 */ + _DIGIT | _HEX, /* `7', 0x37 */ + _DIGIT | _HEX, /* `8', 0x38 */ + _DIGIT | _HEX, /* `9', 0x39 */ + _PUNCT, /* `:', 0x3a */ + _PUNCT, /* `;', 0x3b */ + _PUNCT, /* `<', 0x3c */ + _PUNCT, /* `=', 0x3d */ + _PUNCT, /* `>', 0x3e */ + _PUNCT, /* `?', 0x3f */ + _PUNCT, /* `@', 0x40 */ + 0x0100 | _UPPER | _HEX, /* `A', 0x41 */ + 0x0100 | _UPPER | _HEX, /* `B', 0x42 */ + 0x0100 | _UPPER | _HEX, /* `C', 0x43 */ + 0x0100 | _UPPER | _HEX, /* `D', 0x44 */ + 0x0100 | _UPPER | _HEX, /* `E', 0x45 */ + 0x0100 | _UPPER | _HEX, /* `F', 0x46 */ + 0x0100 | _UPPER, /* `G', 0x47 */ + 0x0100 | _UPPER, /* `H', 0x48 */ + 0x0100 | _UPPER, /* `I', 0x49 */ + 0x0100 | _UPPER, /* `J', 0x4a */ + 0x0100 | _UPPER, /* `K', 0x4b */ + 0x0100 | _UPPER, /* `L', 0x4c */ + 0x0100 | _UPPER, /* `M', 0x4d */ + 0x0100 | _UPPER, /* `N', 0x4e */ + 0x0100 | _UPPER, /* `O', 0x4f */ + 0x0100 | _UPPER, /* `P', 0x50 */ + 0x0100 | _UPPER, /* `Q', 0x51 */ + 0x0100 | _UPPER, /* `R', 0x52 */ + 0x0100 | _UPPER, /* `S', 0x53 */ + 0x0100 | _UPPER, /* `T', 0x54 */ + 0x0100 | _UPPER, /* `U', 0x55 */ + 0x0100 | _UPPER, /* `V', 0x56 */ + 0x0100 | _UPPER, /* `W', 0x57 */ + 0x0100 | _UPPER, /* `X', 0x58 */ + 0x0100 | _UPPER, /* `Y', 0x59 */ + 0x0100 | _UPPER, /* `Z', 0x5a */ + _PUNCT, /* `[', 0x5b */ + _PUNCT, /* 0x5c */ + _PUNCT, /* `]', 0x5d */ + _PUNCT, /* `^', 0x5e */ + _PUNCT, /* `_', 0x5f */ + _PUNCT, /* 0x60 */ + 0x0100 | _LOWER | _HEX, /* `a', 0x61 */ + 0x0100 | _LOWER | _HEX, /* `b', 0x62 */ + 0x0100 | _LOWER | _HEX, /* `c', 0x63 */ + 0x0100 | _LOWER | _HEX, /* `d', 0x64 */ + 0x0100 | _LOWER | _HEX, /* `e', 0x65 */ + 0x0100 | _LOWER | _HEX, /* `f', 0x66 */ + 0x0100 | _LOWER, /* `g', 0x67 */ + 0x0100 | _LOWER, /* `h', 0x68 */ + 0x0100 | _LOWER, /* `i', 0x69 */ + 0x0100 | _LOWER, /* `j', 0x6a */ + 0x0100 | _LOWER, /* `k', 0x6b */ + 0x0100 | _LOWER, /* `l', 0x6c */ + 0x0100 | _LOWER, /* `m', 0x6d */ + 0x0100 | _LOWER, /* `n', 0x6e */ + 0x0100 | _LOWER, /* `o', 0x6f */ + 0x0100 | _LOWER, /* `p', 0x70 */ + 0x0100 | _LOWER, /* `q', 0x71 */ + 0x0100 | _LOWER, /* `r', 0x72 */ + 0x0100 | _LOWER, /* `s', 0x73 */ + 0x0100 | _LOWER, /* `t', 0x74 */ + 0x0100 | _LOWER, /* `u', 0x75 */ + 0x0100 | _LOWER, /* `v', 0x76 */ + 0x0100 | _LOWER, /* `w', 0x77 */ + 0x0100 | _LOWER, /* `x', 0x78 */ + 0x0100 | _LOWER, /* `y', 0x79 */ + 0x0100 | _LOWER, /* `z', 0x7a */ + _PUNCT, /* `{', 0x7b */ + _PUNCT, /* `|', 0x7c */ + _PUNCT, /* `}', 0x7d */ + _PUNCT, /* `~', 0x7e */ + _CONTROL, /* 0x7f */ + _CONTROL, /* 0x80 */ + _CONTROL, /* 0x81 */ + _CONTROL, /* 0x82 */ + _CONTROL, /* 0x83 */ + _CONTROL, /* 0x84 */ + _CONTROL, /* 0x85 */ + _CONTROL, /* 0x86 */ + _CONTROL, /* 0x87 */ + _CONTROL, /* 0x88 */ + _CONTROL, /* 0x89 */ + _CONTROL, /* 0x8a */ + _CONTROL, /* 0x8b */ + _CONTROL, /* 0x8c */ + _CONTROL, /* 0x8d */ + _CONTROL, /* 0x8e */ + _CONTROL, /* 0x8f */ + _CONTROL, /* 0x90 */ + _CONTROL, /* 0x91 */ + _CONTROL, /* 0x92 */ + _CONTROL, /* 0x93 */ + _CONTROL, /* 0x94 */ + _CONTROL, /* 0x95 */ + _CONTROL, /* 0x96 */ + _CONTROL, /* 0x97 */ + _CONTROL, /* 0x98 */ + _CONTROL, /* 0x99 */ + _CONTROL, /* 0x9a */ + _CONTROL, /* 0x9b */ + _CONTROL, /* 0x9c */ + _CONTROL, /* 0x9d */ + _CONTROL, /* 0x9e */ + _CONTROL, /* 0x9f */ + _BLANK | _SPACE, /* 0xa0 */ + _PUNCT, /* 0xa1 */ + _PUNCT, /* 0xa2 */ + _PUNCT, /* 0xa3 */ + _PUNCT, /* 0xa4 */ + _PUNCT, /* 0xa5 */ + _PUNCT, /* 0xa6 */ + _PUNCT, /* 0xa7 */ + _PUNCT, /* 0xa8 */ + _PUNCT, /* 0xa9 */ + _PUNCT, /* 0xaa */ + _PUNCT, /* 0xab */ + _PUNCT, /* 0xac */ + _PUNCT, /* 0xad */ + _PUNCT, /* 0xae */ + _PUNCT, /* 0xaf */ + _PUNCT, /* 0xb0 */ + _PUNCT, /* 0xb1 */ + _PUNCT | _DIGIT, /* 0xb2 */ + _PUNCT | _DIGIT, /* 0xb3 */ + _PUNCT, /* 0xb4 */ + _PUNCT, /* 0xb5 */ + _PUNCT, /* 0xb6 */ + _PUNCT, /* 0xb7 */ + _PUNCT, /* 0xb8 */ + _PUNCT | _DIGIT, /* 0xb9 */ + _PUNCT, /* 0xba */ + _PUNCT, /* 0xbb */ + _PUNCT, /* 0xbc */ + _PUNCT, /* 0xbd */ + _PUNCT, /* 0xbe */ + _PUNCT, /* 0xbf */ + 0x0100 | _UPPER, /* 0xc0 */ + 0x0100 | _UPPER, /* 0xc1 */ + 0x0100 | _UPPER, /* 0xc2 */ + 0x0100 | _UPPER, /* 0xc3 */ + 0x0100 | _UPPER, /* 0xc4 */ + 0x0100 | _UPPER, /* 0xc5 */ + 0x0100 | _UPPER, /* 0xc6 */ + 0x0100 | _UPPER, /* 0xc7 */ + 0x0100 | _UPPER, /* 0xc8 */ + 0x0100 | _UPPER, /* 0xc9 */ + 0x0100 | _UPPER, /* 0xca */ + 0x0100 | _UPPER, /* 0xcb */ + 0x0100 | _UPPER, /* 0xcc */ + 0x0100 | _UPPER, /* 0xcd */ + 0x0100 | _UPPER, /* 0xce */ + 0x0100 | _UPPER, /* 0xcf */ + 0x0100 | _UPPER, /* 0xd0 */ + 0x0100 | _UPPER, /* 0xd1 */ + 0x0100 | _UPPER, /* 0xd2 */ + 0x0100 | _UPPER, /* 0xd3 */ + 0x0100 | _UPPER, /* 0xd4 */ + 0x0100 | _UPPER, /* 0xd5 */ + 0x0100 | _UPPER, /* 0xd6 */ + _PUNCT, /* 0xd7 */ + 0x0100 | _UPPER, /* 0xd8 */ + 0x0100 | _UPPER, /* 0xd9 */ + 0x0100 | _UPPER, /* 0xda */ + 0x0100 | _UPPER, /* 0xdb */ + 0x0100 | _UPPER, /* 0xdc */ + 0x0100 | _UPPER, /* 0xdd */ + 0x0100 | _UPPER, /* 0xde */ + 0x0100 | _LOWER, /* 0xdf */ + 0x0100 | _LOWER, /* 0xe0 */ + 0x0100 | _LOWER, /* 0xe1 */ + 0x0100 | _LOWER, /* 0xe2 */ + 0x0100 | _LOWER, /* 0xe3 */ + 0x0100 | _LOWER, /* 0xe4 */ + 0x0100 | _LOWER, /* 0xe5 */ + 0x0100 | _LOWER, /* 0xe6 */ + 0x0100 | _LOWER, /* 0xe7 */ + 0x0100 | _LOWER, /* 0xe8 */ + 0x0100 | _LOWER, /* 0xe9 */ + 0x0100 | _LOWER, /* 0xea */ + 0x0100 | _LOWER, /* 0xeb */ + 0x0100 | _LOWER, /* 0xec */ + 0x0100 | _LOWER, /* 0xed */ + 0x0100 | _LOWER, /* 0xee */ + 0x0100 | _LOWER, /* 0xef */ + 0x0100 | _LOWER, /* 0xf0 */ + 0x0100 | _LOWER, /* 0xf1 */ + 0x0100 | _LOWER, /* 0xf2 */ + 0x0100 | _LOWER, /* 0xf3 */ + 0x0100 | _LOWER, /* 0xf4 */ + 0x0100 | _LOWER, /* 0xf5 */ + 0x0100 | _LOWER, /* 0xf6 */ + _PUNCT, /* 0xf7 */ + 0x0100 | _LOWER, /* 0xf8 */ + 0x0100 | _LOWER, /* 0xf9 */ + 0x0100 | _LOWER, /* 0xfa */ + 0x0100 | _LOWER, /* 0xfb */ + 0x0100 | _LOWER, /* 0xfc */ + 0x0100 | _LOWER, /* 0xfd */ + 0x0100 | _LOWER, /* 0xfe */ + 0x0100 | _LOWER /* 0xff */ +}; const unsigned short *_pctype = _ctype + 1; -const unsigned short *_pwctype = _ctype + 1; +const unsigned short *_pwctype = _wctype + 1; /* * @implemented @@ -300,6 +559,11 @@ const unsigned short **__p__pctype(void) return &_pctype; } +const unsigned short* __cdecl __pctype_func(void) +{ + return _pctype; +} + /* * @implemented */ @@ -308,6 +572,11 @@ const unsigned short **__p__pwctype(void) return &_pwctype; } +const unsigned short* __cdecl __pwctype_func(void) +{ + return _pwctype; +} + int _isctype (int c, int ctypeFlags) { return (_pctype[(unsigned char)(c & 0xFF)] & ctypeFlags); From 884cba10efc6dcd1cffeda06a8a2dd2c475c99b4 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sat, 27 Mar 2010 14:54:55 +0000 Subject: [PATCH 028/134] [CMPBATT] reduce diff to trunk svn path=/branches/ros-amd64-bringup/; revision=46489 --- reactos/drivers/bus/acpi/cmbatt/cmexec.c | 80 ++++-------------------- 1 file changed, 11 insertions(+), 69 deletions(-) diff --git a/reactos/drivers/bus/acpi/cmbatt/cmexec.c b/reactos/drivers/bus/acpi/cmbatt/cmexec.c index 543a8a70293..beb646ab509 100644 --- a/reactos/drivers/bus/acpi/cmbatt/cmexec.c +++ b/reactos/drivers/bus/acpi/cmbatt/cmexec.c @@ -9,7 +9,6 @@ /* INCLUDES *******************************************************************/ #include "cmbatt.h" -#include "ntstatus.h" /* FUNCTIONS ******************************************************************/ @@ -112,8 +111,8 @@ CmBattSendDownStreamIrp(IN PDEVICE_OBJECT DeviceObject, if (CmBattDebug & 0x4C) DbgPrint("CmBattSendDownStreamIrp: Failed to allocate Irp\n"); return STATUS_INSUFFICIENT_RESOURCES; -} - + } + /* Call ACPI */ if (CmBattDebug & 0x40) DbgPrint("CmBattSendDownStreamIrp: Irp %x [Tid] %x\n", @@ -183,13 +182,13 @@ CmBattGetPsrData(IN PDEVICE_OBJECT DeviceObject, Status = GetDwordElement(OutputBuffer.Argument, PsrData); if (CmBattDebug & 0x440) DbgPrint("CmBattGetPsrData: _PSR method returned %x \n", *PsrData); -} + } else if (CmBattDebug & 0x44C) { /* Failure */ DbgPrint("CmBattGetPsrData: Failed _PSR method - Status (0x%x)\n", Status); } - + /* Return status */ return Status; } @@ -228,14 +227,14 @@ CmBattGetStaData(IN PDEVICE_OBJECT DeviceObject, Status = GetDwordElement(OutputBuffer.Argument, StaData); if (CmBattDebug & 0x440) DbgPrint("CmBattGetStaData: _STA method returned %x \n", *StaData); -} + } else if (CmBattDebug & 0x44C) { /* Failure */ DbgPrint("CmBattGetStaData: Failed _STA method - Status (0x%x)\n", Status); Status = STATUS_NO_SUCH_DEVICE; } - + /* Return status */ return Status; } @@ -274,14 +273,14 @@ CmBattGetUniqueId(IN PDEVICE_OBJECT DeviceObject, Status = GetDwordElement(OutputBuffer.Argument, UniqueId); if (CmBattDebug & 0x440) DbgPrint("CmBattGetUniqueId: _UID method returned %x \n", *UniqueId); -} + } else if (CmBattDebug & 0x44C) { /* Failure */ DbgPrint("CmBattGetUniqueId: Failed _UID method - Status (0x%x)\n", Status); Status = STATUS_NO_SUCH_DEVICE; } - + /* Return status */ return Status; } @@ -332,65 +331,8 @@ NTAPI CmBattGetBstData(PCMBATT_DEVICE_EXTENSION DeviceExtension, PACPI_BST_DATA BstData) { - PIRP Irp; - NTSTATUS Status; - KEVENT Event; - IO_STATUS_BLOCK IoStatusBlock; - PAGED_CODE(); - - /* Initialize our wait event */ - KeInitializeEvent(&Event, SynchronizationEvent, 0); - - /* Allocate the IRP */ - Irp = IoBuildDeviceIoControlRequest(IoControlCode, - DeviceObject, - InputBuffer, - InputBufferLength, - OutputBuffer, - OutputBufferLength, - 0, - &Event, - &IoStatusBlock); - if (!Irp) - { - /* No IRP, fail */ - if (CmBattDebug & 0x4C) - DbgPrint("CmBattSendDownStreamIrp: Failed to allocate Irp\n"); - return STATUS_INSUFFICIENT_RESOURCES; - } - - /* Call ACPI */ - if (CmBattDebug & 0x40) - DbgPrint("CmBattSendDownStreamIrp: Irp %x [Tid] %x\n", Irp, KeGetCurrentThread()); - Status = IoCallDriver(DeviceObject, Irp); - if (Status == STATUS_PENDING) - { - /* Wait for completion */ - KeWaitForSingleObject(&Event, - Executive, - KernelMode, - FALSE, - NULL); - Status = Irp->IoStatus.Status; - } - - /* Check if caller wanted output */ - if (OutputBuffer) - { - /* Make sure it's valid ACPI output buffer */ - if ((OutputBuffer->Signature != ACPI_EVAL_OUTPUT_BUFFER_SIGNATURE) || - !(OutputBuffer->Count)) - { - /* It isn't, so set failure code */ - Status = STATUS_ACPI_INVALID_DATA; - } - } - - /* Return status */ - if (CmBattDebug & 0x40) - DbgPrint("CmBattSendDownStreamIrp: Irp %x completed %x! [Tid] %x\n", - Irp, Status, KeGetCurrentThread()); - return Status; + UNIMPLEMENTED; + return STATUS_NOT_IMPLEMENTED; } - + /* EOF */ From d188708a4dfd35edeb5e6e1ddedea59ee10273e8 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sat, 27 Mar 2010 21:26:24 +0000 Subject: [PATCH 029/134] [NTOSKRNL] - Detect floppy controllers, parallel ports, and the ISA bus - Dedicated to dreimer svn path=/trunk/; revision=46495 --- reactos/ntoskrnl/io/pnpmgr/pnpmgr.c | 44 ++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c b/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c index 9cd6347e957..f40c505918b 100644 --- a/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c +++ b/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c @@ -2180,6 +2180,15 @@ IopEnumerateDetectedDevices( const UNICODE_STRING IdentifierMouse = RTL_CONSTANT_STRING(L"PointerController"); UNICODE_STRING HardwareIdMouse = RTL_CONSTANT_STRING(L"*PNP0F13\0"); static ULONG DeviceIndexMouse = 0; + const UNICODE_STRING IdentifierParallel = RTL_CONSTANT_STRING(L"PARALLEL"); + UNICODE_STRING HardwareIdParallel = RTL_CONSTANT_STRING(L"*PNP0400\0"); + static ULONG DeviceIndexParallel = 0; + const UNICODE_STRING IdentifierFloppy = RTL_CONSTANT_STRING(L"FLOPPY"); + UNICODE_STRING HardwareIdFloppy = RTL_CONSTANT_STRING(L"*PNP0700\0"); + static ULONG DeviceIndexFloppy = 0; + const UNICODE_STRING IdentifierIsa = RTL_CONSTANT_STRING(L"ISA"); + UNICODE_STRING HardwareIdIsa = RTL_CONSTANT_STRING(L"*PNP0A00\0"); + static ULONG DeviceIndexIsa = 0; UNICODE_STRING HardwareIdKey; PUNICODE_STRING pHardwareId; ULONG DeviceIndex = 0; @@ -2428,6 +2437,11 @@ IopEnumerateDetectedDevices( pHardwareId = &HardwareIdPci; DeviceIndex = DeviceIndexPci++; } + else if (RtlCompareUnicodeString(&ValueName, &IdentifierIsa, FALSE) == 0) + { + pHardwareId = &HardwareIdIsa; + DeviceIndex = DeviceIndexIsa++; + } #ifdef ENABLE_ACPI else if (RtlCompareUnicodeString(&ValueName, &IdentifierAcpi, FALSE) == 0) { @@ -2435,11 +2449,33 @@ IopEnumerateDetectedDevices( DeviceIndex = DeviceIndexAcpi++; } #endif - else + else /* Now let's detect devices with a device number at the end */ { - /* Unknown device */ - DPRINT("Unknown device '%wZ'\n", &ValueName); - goto nextdevice; + /* First, we remove the number */ + ValueName.Length -= sizeof(WCHAR); + + /* Let's see if it is a floppy device */ + if (RtlCompareUnicodeString(&ValueName, &IdentifierFloppy, FALSE) == 0) + { + pHardwareId = &HardwareIdFloppy; + DeviceIndex = DeviceIndexFloppy++; + } + /* Nope, is it a parallel port? */ + else if (RtlCompareUnicodeString(&ValueName, &IdentifierParallel, FALSE) == 0) + { + pHardwareId = &HardwareIdParallel; + DeviceIndex = DeviceIndexParallel++; + } + /* Nope, out of ideas so let's skip this one */ + else + { + ValueName.Length += sizeof(WCHAR); + DPRINT("Unknown device '%wZ'\n", &ValueName); + goto nextdevice; + } + + /* Add the number back */ + ValueName.Length += sizeof(WCHAR); } } else From 18c595da66cdd8c39483e905cac075ed3cf42505 Mon Sep 17 00:00:00 2001 From: Sir Richard Date: Sat, 27 Mar 2010 21:33:07 +0000 Subject: [PATCH 030/134] [CMBATT]: Fix wrong DO flags. svn path=/trunk/; revision=46497 --- reactos/drivers/bus/acpi/cmbatt/cmbpnp.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/reactos/drivers/bus/acpi/cmbatt/cmbpnp.c b/reactos/drivers/bus/acpi/cmbatt/cmbpnp.c index 55d3ae63d49..bbeee7960d8 100644 --- a/reactos/drivers/bus/acpi/cmbatt/cmbpnp.c +++ b/reactos/drivers/bus/acpi/cmbatt/cmbpnp.c @@ -567,8 +567,7 @@ CmBattCreateFdo(IN PDRIVER_OBJECT DriverObject, } /* Set FDO flags */ - FdoDeviceObject->Flags |= DO_BUFFERED_IO; - FdoDeviceObject->Flags |= DO_MAP_IO_BUFFER; + FdoDeviceObject->Flags |= (DO_POWER_PAGABLE | DO_BUFFERED_IO); FdoDeviceObject->Flags &= ~DO_DEVICE_INITIALIZING; /* Initialize the extension */ From 48b9dc33d5f139a95070b84bfbae0b793de441f0 Mon Sep 17 00:00:00 2001 From: Sir Richard Date: Sat, 27 Mar 2010 21:34:06 +0000 Subject: [PATCH 031/134] [COMPBATT]: Main driver skeleton: CompBattAddDevice, DriverEntry, CompBattSystemControl, CompBattIoct, CompBattOpenClose, CompBattPowerDispatch, CompBattPnpDispatch. svn path=/trunk/; revision=46498 --- reactos/drivers/bus/acpi/compbatt/compbatt.c | 70 +++++++- reactos/drivers/bus/acpi/compbatt/compbatt.h | 64 ++++++- reactos/drivers/bus/acpi/compbatt/comppnp.c | 179 ++++++++++++++++++- 3 files changed, 298 insertions(+), 15 deletions(-) diff --git a/reactos/drivers/bus/acpi/compbatt/compbatt.c b/reactos/drivers/bus/acpi/compbatt/compbatt.c index 03d587c46ad..d8f8920cc0a 100644 --- a/reactos/drivers/bus/acpi/compbatt/compbatt.c +++ b/reactos/drivers/bus/acpi/compbatt/compbatt.c @@ -21,8 +21,17 @@ NTAPI CompBattOpenClose(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp) { - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; + PAGED_CODE(); + if (CompBattDebug & 0x100) DbgPrint("CompBatt: ENTERING OpenClose\n"); + + /* Complete the IRP with success */ + Irp->IoStatus.Status = STATUS_SUCCESS; + Irp->IoStatus.Information = 0; + IofCompleteRequest(Irp, IO_NO_INCREMENT); + + /* Return success */ + if (CompBattDebug & 0x100) DbgPrint("CompBatt: Exiting OpenClose\n"); + return STATUS_SUCCESS; } NTSTATUS @@ -30,8 +39,28 @@ NTAPI CompBattSystemControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp) { - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; + PCOMPBATT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension; + NTSTATUS Status; + PAGED_CODE(); + if (CompBattDebug & 1) DbgPrint("CompBatt: ENTERING System Control\n"); + + /* Are we attached yet? */ + if (DeviceExtension->AttachedDevice) + { + /* Send it up the stack */ + IoSkipCurrentIrpStackLocation(Irp); + Status = IoCallDriver(DeviceExtension->AttachedDevice, Irp); + } + else + { + /* We don't support WMI */ + Status = STATUS_NOT_SUPPORTED; + Irp->IoStatus.Status = STATUS_NOT_SUPPORTED; + IofCompleteRequest(Irp, IO_NO_INCREMENT); + } + + /* Return status */ + return Status; } NTSTATUS @@ -65,8 +94,23 @@ NTAPI CompBattIoctl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp) { - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; + PCOMPBATT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension; + NTSTATUS Status; + if (CompBattDebug & 1) DbgPrint("CompBatt: ENTERING Ioctl\n"); + + /* Let the class driver handle it */ + Status = BatteryClassIoctl(DeviceExtension->ClassData, Irp); + if (Status == STATUS_NOT_SUPPORTED) + { + /* It failed, try the next driver up the stack */ + Irp->IoStatus.Status = Status; + IoSkipCurrentIrpStackLocation(Irp); + Status = IoCallDriver(DeviceExtension->AttachedDevice, Irp); + } + + /* Return status */ + if (CompBattDebug & 1) DbgPrint("CompBatt: EXITING Ioctl\n"); + return Status; } NTSTATUS @@ -161,8 +205,18 @@ NTAPI DriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath) { - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; + /* Register add device routine */ + DriverObject->DriverExtension->AddDevice = CompBattAddDevice; + + /* Register other handlers */ + DriverObject->MajorFunction[0] = CompBattOpenClose; + DriverObject->MajorFunction[2] = CompBattOpenClose; + DriverObject->MajorFunction[14] = CompBattIoctl; + DriverObject->MajorFunction[22] = CompBattPowerDispatch; + DriverObject->MajorFunction[23] = CompBattSystemControl; + DriverObject->MajorFunction[27] = CompBattPnpDispatch; + + return STATUS_SUCCESS; } /* EOF */ diff --git a/reactos/drivers/bus/acpi/compbatt/compbatt.h b/reactos/drivers/bus/acpi/compbatt/compbatt.h index 701f1362641..015195bafe2 100644 --- a/reactos/drivers/bus/acpi/compbatt/compbatt.h +++ b/reactos/drivers/bus/acpi/compbatt/compbatt.h @@ -52,6 +52,68 @@ typedef struct _COMPBATT_DEVICE_EXTENSION PVOID NotificationEntry; } COMPBATT_DEVICE_EXTENSION, *PCOMPBATT_DEVICE_EXTENSION; -extern ULONG CmBattDebug; +NTSTATUS +NTAPI +CompBattAddDevice( + IN PDRIVER_OBJECT DriverObject, + IN PDEVICE_OBJECT PdoDeviceObject +); + +NTSTATUS +NTAPI +CompBattPowerDispatch( + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp +); + +NTSTATUS +NTAPI +CompBattPnpDispatch( + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp +); + +NTSTATUS +NTAPI +CompBattQueryInformation( + IN PCOMPBATT_DEVICE_EXTENSION FdoExtension, + IN ULONG Tag, + IN BATTERY_QUERY_INFORMATION_LEVEL InfoLevel, + IN OPTIONAL LONG AtRate, + IN PVOID Buffer, + IN ULONG BufferLength, + OUT PULONG ReturnedLength +); + +NTSTATUS +NTAPI +CompBattQueryStatus( + IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension, + IN ULONG Tag, + IN PBATTERY_STATUS BatteryStatus +); + +NTSTATUS +NTAPI +CompBattSetStatusNotify( + IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension, + IN ULONG BatteryTag, + IN PBATTERY_NOTIFY BatteryNotify +); + +NTSTATUS +NTAPI +CompBattDisableStatusNotify( + IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension +); + +NTSTATUS +NTAPI +CompBattQueryTag( + IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension, + OUT PULONG Tag +); + +extern ULONG CompBattDebug; /* EOF */ diff --git a/reactos/drivers/bus/acpi/compbatt/comppnp.c b/reactos/drivers/bus/acpi/compbatt/comppnp.c index a767c18ab80..156ee3fd81f 100644 --- a/reactos/drivers/bus/acpi/compbatt/comppnp.c +++ b/reactos/drivers/bus/acpi/compbatt/comppnp.c @@ -17,8 +17,15 @@ NTAPI CompBattPowerDispatch(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp) { - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; + PCOMPBATT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension; + if (CompBattDebug & 1) DbgPrint("CompBatt: PowerDispatch recieved power IRP.\n"); + + /* Start the next IRP */ + PoStartNextPowerIrp(Irp); + + /* Call the next driver in the stack */ + IoSkipCurrentIrpStackLocation(Irp); + return PoCallDriver(DeviceExtension->AttachedDevice, Irp); } PCOMPBATT_BATTERY_ENTRY @@ -79,8 +86,82 @@ NTAPI CompBattAddDevice(IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT PdoDeviceObject) { - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; + NTSTATUS Status; + UNICODE_STRING DeviceName; + PCOMPBATT_DEVICE_EXTENSION DeviceExtension; + PDEVICE_OBJECT DeviceObject; + UNICODE_STRING SymbolicLinkName; + BATTERY_MINIPORT_INFO MiniportInfo; + if (CompBattDebug & 2) DbgPrint("CompBatt: Got an AddDevice - %x\n", PdoDeviceObject); + + /* Create the device */ + RtlInitUnicodeString(&DeviceName, L"\\Device\\CompositeBattery"); + Status = IoCreateDevice(DriverObject, + sizeof(COMPBATT_DEVICE_EXTENSION), + &DeviceName, + FILE_DEVICE_BATTERY, + FILE_DEVICE_SECURE_OPEN, + FALSE, + &DeviceObject); + if (!NT_SUCCESS(Status)) return Status; + + /* Setup symbolic link for Win32 access */ + RtlInitUnicodeString(&SymbolicLinkName, L"\\DosDevices\\CompositeBattery"); + IoCreateSymbolicLink(&SymbolicLinkName, &DeviceName); + + /* Initialize the device extension */ + DeviceExtension = DeviceObject->DeviceExtension; + RtlZeroMemory(DeviceExtension, 0x1B0u); + + /* Attach to device stack and set DO pointers */ + DeviceExtension->AttachedDevice = IoAttachDeviceToDeviceStack(DeviceObject, + PdoDeviceObject); + DeviceExtension->DeviceObject = DeviceObject; + if (!DeviceExtension->AttachedDevice) + { + /* Fail */ + if (CompBattDebug & 8) + DbgPrint("CompBattAddDevice: Could not attach to LowerDevice.\n"); + IoDeleteDevice(DeviceObject); + return STATUS_UNSUCCESSFUL; + } + + /* Set device object flags */ + DeviceObject->Flags |= (DO_POWER_PAGABLE | DO_BUFFERED_IO); + DeviceObject->Flags &= ~DO_DEVICE_INITIALIZING; + + /* Setup the device extension */ + ExInitializeFastMutex(&DeviceExtension->Lock); + InitializeListHead(&DeviceExtension->BatteryList); + DeviceExtension->Flags = 0; + DeviceExtension->NextTag = 1; + + /* Setup the miniport data */ + RtlZeroMemory(&MiniportInfo, sizeof(MiniportInfo)); + MiniportInfo.MajorVersion = BATTERY_CLASS_MAJOR_VERSION; + MiniportInfo.MinorVersion = BATTERY_CLASS_MINOR_VERSION; + MiniportInfo.Context = DeviceExtension; + MiniportInfo.DeviceName = &DeviceName; + MiniportInfo.QueryTag = (BCLASS_QUERY_TAG)CompBattQueryTag; + MiniportInfo.QueryInformation = (BCLASS_QUERY_INFORMATION)CompBattQueryInformation; + MiniportInfo.SetInformation = NULL; + MiniportInfo.QueryStatus = (BCLASS_QUERY_STATUS)CompBattQueryStatus; + MiniportInfo.SetStatusNotify = (BCLASS_SET_STATUS_NOTIFY)CompBattSetStatusNotify; + MiniportInfo.DisableStatusNotify = (BCLASS_DISABLE_STATUS_NOTIFY)CompBattDisableStatusNotify; + MiniportInfo.Pdo = NULL; + + /* Register with the class driver */ + Status = BatteryClassInitializeDevice(&MiniportInfo, + &DeviceExtension->ClassData); + if (!NT_SUCCESS(Status)) + { + /* Undo everything */ + IoDetachDevice(DeviceExtension->AttachedDevice); + IoDeleteDevice(DeviceObject); + } + + /* Return status */ + return Status; } NTSTATUS @@ -88,8 +169,94 @@ NTAPI CompBattPnpDispatch(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp) { - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; + PIO_STACK_LOCATION IoStackLocation = IoGetCurrentIrpStackLocation(Irp); + NTSTATUS Status; + PCOMPBATT_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension; + if (CompBattDebug & 1) DbgPrint("CompBatt: ENTERING PnpDispatch\n"); + + /* Set default error */ + Status = STATUS_NOT_SUPPORTED; + + /* Check what kind of PnP function this is */ + switch (IoStackLocation->MinorFunction) + { + case IRP_MN_START_DEVICE: + + /* Device is starting, register for new batteries and pick up current ones */ + Status = IoRegisterPlugPlayNotification(EventCategoryDeviceInterfaceChange, + 0, + (PVOID)&GUID_DEVICE_BATTERY, + DeviceObject->DriverObject, + (PDRIVER_NOTIFICATION_CALLBACK_ROUTINE)CompBattPnpEventHandler, + DeviceExtension, + &DeviceExtension->NotificationEntry); + if (NT_SUCCESS(Status)) + { + /* Now go get the batteries */ + if (CompBattDebug & 2) + DbgPrint("CompBatt: Successfully registered for PnP notification\n"); + Status = CompBattGetBatteries(DeviceExtension); + } + else + { + /* We failed */ + if (CompBattDebug & 8) + DbgPrint("CompBatt: Couldn't register for PnP notification - %x\n", + Status); + } + + case IRP_MN_CANCEL_STOP_DEVICE: + + /* Explicitly say ok */ + Status = STATUS_SUCCESS; + break; + + case IRP_MN_CANCEL_REMOVE_DEVICE: + + /* Explicitly say ok */ + Status = STATUS_SUCCESS; + break; + + case IRP_MN_SURPRISE_REMOVAL: + + /* Explicitly say ok */ + Status = STATUS_SUCCESS; + break; + + case IRP_MN_QUERY_PNP_DEVICE_STATE: + + /* Add this in */ + Irp->IoStatus.Information |= PNP_DEVICE_NOT_DISABLEABLE; + Status = STATUS_SUCCESS; + break; + + default: + + /* Not supported */ + Status = STATUS_INVALID_DEVICE_REQUEST; + break; + } + + /* Set IRP status if we have one */ + if (Status != STATUS_NOT_SUPPORTED) Irp->IoStatus.Status = Status; + + /* Did someone pick it up? */ + if ((NT_SUCCESS(Status)) || (Status == STATUS_NOT_SUPPORTED)) + { + /* Still unsupported, try ACPI */ + IoSkipCurrentIrpStackLocation(Irp); + Status = IoCallDriver(DeviceExtension->AttachedDevice, Irp); + } + else + { + /* Complete the request */ + Status = Irp->IoStatus.Status; + IofCompleteRequest(Irp, IO_NO_INCREMENT); + } + + /* Release the remove lock and return status */ + if (CompBattDebug & 1) DbgPrint("CompBatt: EXITING PnpDispatch\n"); + return Status; } /* EOF */ From 79cb786ef5da332ea81c163f941024984e6a6179 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sat, 27 Mar 2010 21:42:52 +0000 Subject: [PATCH 032/134] [INF] - Add a device description for PNP0A00 svn path=/trunk/; revision=46499 --- reactos/media/inf/machine.inf | Bin 45554 -> 45620 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/reactos/media/inf/machine.inf b/reactos/media/inf/machine.inf index 7b7e0a9d3026fd75257188e6899e1686858204b5..ecc90375e8d1de8d54b6cc66e14fa58f09e17e72 100644 GIT binary patch delta 45 zcmV+|0Mh^R;{vqg00gZvOu-d<^ Date: Sat, 27 Mar 2010 21:45:35 +0000 Subject: [PATCH 033/134] [NTOSKRNL] - Don't always use the value name as the device description - Fixes bug 3416 svn path=/trunk/; revision=46500 --- reactos/ntoskrnl/io/pnpmgr/pnpmgr.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c b/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c index f40c505918b..cd0859b261b 100644 --- a/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c +++ b/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c @@ -2192,6 +2192,7 @@ IopEnumerateDetectedDevices( UNICODE_STRING HardwareIdKey; PUNICODE_STRING pHardwareId; ULONG DeviceIndex = 0; + BOOLEAN IsDeviceDesc; if (RelativePath) { @@ -2418,16 +2419,19 @@ IopEnumerateDetectedDevices( { pHardwareId = &HardwareIdSerial; DeviceIndex = DeviceIndexSerial++; + IsDeviceDesc = TRUE; } else if (RelativePath && RtlCompareUnicodeString(RelativePath, &IdentifierKeyboard, FALSE) == 0) { pHardwareId = &HardwareIdKeyboard; DeviceIndex = DeviceIndexKeyboard++; + IsDeviceDesc = FALSE; } else if (RelativePath && RtlCompareUnicodeString(RelativePath, &IdentifierMouse, FALSE) == 0) { pHardwareId = &HardwareIdMouse; DeviceIndex = DeviceIndexMouse++; + IsDeviceDesc = FALSE; } else if (NT_SUCCESS(Status)) { @@ -2436,17 +2440,20 @@ IopEnumerateDetectedDevices( { pHardwareId = &HardwareIdPci; DeviceIndex = DeviceIndexPci++; + IsDeviceDesc = FALSE; } else if (RtlCompareUnicodeString(&ValueName, &IdentifierIsa, FALSE) == 0) { pHardwareId = &HardwareIdIsa; DeviceIndex = DeviceIndexIsa++; + IsDeviceDesc = FALSE; } #ifdef ENABLE_ACPI else if (RtlCompareUnicodeString(&ValueName, &IdentifierAcpi, FALSE) == 0) { pHardwareId = &HardwareIdAcpi; DeviceIndex = DeviceIndexAcpi++; + IsDeviceDesc = FALSE; } #endif else /* Now let's detect devices with a device number at the end */ @@ -2459,12 +2466,14 @@ IopEnumerateDetectedDevices( { pHardwareId = &HardwareIdFloppy; DeviceIndex = DeviceIndexFloppy++; + IsDeviceDesc = FALSE; } /* Nope, is it a parallel port? */ else if (RtlCompareUnicodeString(&ValueName, &IdentifierParallel, FALSE) == 0) { pHardwareId = &HardwareIdParallel; DeviceIndex = DeviceIndexParallel++; + IsDeviceDesc = FALSE; } /* Nope, out of ideas so let's skip this one */ else @@ -2522,12 +2531,15 @@ IopEnumerateDetectedDevices( goto nextdevice; } DPRINT("Found %wZ #%lu (%wZ)\n", &ValueName, DeviceIndex, &HardwareIdKey); - Status = ZwSetValueKey(hLevel2Key, &DeviceDescU, 0, REG_SZ, ValueName.Buffer, ValueName.MaximumLength); - if (!NT_SUCCESS(Status)) + if (IsDeviceDesc) { - DPRINT("ZwSetValueKey() failed with status 0x%08lx\n", Status); - ZwDeleteKey(hLevel2Key); - goto nextdevice; + Status = ZwSetValueKey(hLevel2Key, &DeviceDescU, 0, REG_SZ, ValueName.Buffer, ValueName.MaximumLength); + if (!NT_SUCCESS(Status)) + { + DPRINT("ZwSetValueKey() failed with status 0x%08lx\n", Status); + ZwDeleteKey(hLevel2Key); + goto nextdevice; + } } Status = ZwSetValueKey(hLevel2Key, &HardwareIDU, 0, REG_MULTI_SZ, pHardwareId->Buffer, pHardwareId->MaximumLength); if (!NT_SUCCESS(Status)) From b3349e95bcfa9d4e4956759aff0480c8c23ae237 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sat, 27 Mar 2010 22:38:22 +0000 Subject: [PATCH 034/134] [MSVCRT] - enable exports for __pctype_func, __pwctype_func, _wctype svn path=/branches/ros-amd64-bringup/; revision=46502 --- reactos/dll/win32/msvcrt/msvcrt-amd64.def | 6 +++--- reactos/dll/win32/msvcrt/msvcrt-i386.def | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/reactos/dll/win32/msvcrt/msvcrt-amd64.def b/reactos/dll/win32/msvcrt/msvcrt-amd64.def index 61b42844390..b554400cc93 100644 --- a/reactos/dll/win32/msvcrt/msvcrt-amd64.def +++ b/reactos/dll/win32/msvcrt/msvcrt-amd64.def @@ -158,9 +158,9 @@ EXPORTS __p__winminor @153 __p__winver @154 __p__wpgmptr @155 -; __pctype_func @156 + __pctype_func @156 __pioinfo @157 DATA -; __pwctype_func @158 + __pwctype_func @158 __pxcptinfoptrs @159 __set_app_type @160 __setlc_active @161 DATA @@ -583,7 +583,7 @@ EXPORTS _wcsupr @576 _wctime @577 ; _wctime64 @578 -; _wctype @579 + _wctype @579 _wenviron @580 DATA _wexecl @581 _wexecle @582 diff --git a/reactos/dll/win32/msvcrt/msvcrt-i386.def b/reactos/dll/win32/msvcrt/msvcrt-i386.def index bcf3fe378c8..fde304e08e6 100644 --- a/reactos/dll/win32/msvcrt/msvcrt-i386.def +++ b/reactos/dll/win32/msvcrt/msvcrt-i386.def @@ -158,9 +158,9 @@ EXPORTS __p__winminor @153 __p__winver @154 __p__wpgmptr @155 -; __pctype_func @156 + __pctype_func @156 __pioinfo @157 DATA -; __pwctype_func @158 + __pwctype_func @158 __pxcptinfoptrs @159 __set_app_type @160 __setlc_active @161 DATA @@ -583,7 +583,7 @@ EXPORTS _wcsupr @576 _wctime @577 ; _wctime64 @578 -; _wctype @579 + _wctype @579 _wenviron @580 DATA _wexecl @581 _wexecle @582 From 8492ce3f393a48e0a526deb5b52319d316aa7340 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sat, 27 Mar 2010 22:58:37 +0000 Subject: [PATCH 035/134] Fix definition of _wctype svn path=/trunk/; revision=46503 --- reactos/include/crt/ctype.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/include/crt/ctype.h b/reactos/include/crt/ctype.h index 74f7b1eb170..294e0171111 100644 --- a/reactos/include/crt/ctype.h +++ b/reactos/include/crt/ctype.h @@ -38,7 +38,7 @@ extern "C" { #ifndef _CRT_WCTYPEDATA_DEFINED #define _CRT_WCTYPEDATA_DEFINED # ifndef _CTYPE_DISABLE_MACROS - _CRTDATA(extern unsigned short *_wctype); + _CRTDATA(extern const unsigned short _wctype[]); _CRTIMP const wctype_t * __cdecl __pwctype_func(void); # ifndef _M_CEE_PURE _CRTDATA(extern const wctype_t *_pwctype); From a26b8712a8557473c72d72b065f0b78cfd6117eb Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sat, 27 Mar 2010 23:01:05 +0000 Subject: [PATCH 036/134] Merge from amd64-branch: 46483 (tkreuzer) [CRT] - add _wctype table, it's not identical to _ctype as assumed before - point _pwctype to _wctype instead of _ctype - implement __pctype_func and __pwctype_func 46502 (tkreuzer) [MSVCRT] - enable exports for __pctype_func, __pwctype_func, _wctype svn path=/trunk/; revision=46504 --- reactos/dll/win32/msvcrt/msvcrt.def | 6 +- reactos/lib/sdk/crt/string/ctype.c | 271 +++++++++++++++++++++++++++- 2 files changed, 273 insertions(+), 4 deletions(-) diff --git a/reactos/dll/win32/msvcrt/msvcrt.def b/reactos/dll/win32/msvcrt/msvcrt.def index f7d9e100a2f..9fdd97ad02b 100644 --- a/reactos/dll/win32/msvcrt/msvcrt.def +++ b/reactos/dll/win32/msvcrt/msvcrt.def @@ -158,9 +158,9 @@ EXPORTS __p__winminor @153 __p__winver @154 __p__wpgmptr @155 -; __pctype_func @156 + __pctype_func @156 __pioinfo @157 DATA -; __pwctype_func @158 + __pwctype_func @158 __pxcptinfoptrs @159 __set_app_type @160 __setlc_active @161 DATA @@ -583,7 +583,7 @@ EXPORTS _wcsupr @576 _wctime @577 ; _wctime64 @578 -; _wctype @579 + _wctype @579 _wenviron @580 DATA _wexecl @581 _wexecle @582 diff --git a/reactos/lib/sdk/crt/string/ctype.c b/reactos/lib/sdk/crt/string/ctype.c index a4873cebdd4..28dcda5ab66 100644 --- a/reactos/lib/sdk/crt/string/ctype.c +++ b/reactos/lib/sdk/crt/string/ctype.c @@ -289,8 +289,267 @@ const unsigned short _ctype[] = { 0 /* 0xff */ }; +const unsigned short _wctype[] = { + 0, /* , 0xFFFF */ + _CONTROL, /* CTRL+@, 0x00 */ + _CONTROL, /* CTRL+A, 0x01 */ + _CONTROL, /* CTRL+B, 0x02 */ + _CONTROL, /* CTRL+C, 0x03 */ + _CONTROL, /* CTRL+D, 0x04 */ + _CONTROL, /* CTRL+E, 0x05 */ + _CONTROL, /* CTRL+F, 0x06 */ + _CONTROL, /* CTRL+G, 0x07 */ + _CONTROL, /* CTRL+H, 0x08 */ + _BLANK | _CONTROL | _SPACE, /* CTRL+I, 0x09 */ + _CONTROL | _SPACE, /* CTRL+J, 0x0a */ + _CONTROL | _SPACE, /* CTRL+K, 0x0b */ + _CONTROL | _SPACE, /* CTRL+L, 0x0c */ + _CONTROL | _SPACE, /* CTRL+M, 0x0d */ + _CONTROL, /* CTRL+N, 0x0e */ + _CONTROL, /* CTRL+O, 0x0f */ + _CONTROL, /* CTRL+P, 0x10 */ + _CONTROL, /* CTRL+Q, 0x11 */ + _CONTROL, /* CTRL+R, 0x12 */ + _CONTROL, /* CTRL+S, 0x13 */ + _CONTROL, /* CTRL+T, 0x14 */ + _CONTROL, /* CTRL+U, 0x15 */ + _CONTROL, /* CTRL+V, 0x16 */ + _CONTROL, /* CTRL+W, 0x17 */ + _CONTROL, /* CTRL+X, 0x18 */ + _CONTROL, /* CTRL+Y, 0x19 */ + _CONTROL, /* CTRL+Z, 0x1a */ + _CONTROL, /* CTRL+[, 0x1b */ + _CONTROL, /* CTRL+\, 0x1c */ + _CONTROL, /* CTRL+], 0x1d */ + _CONTROL, /* CTRL+^, 0x1e */ + _CONTROL, /* CTRL+_, 0x1f */ + _SPACE | _BLANK, /* ` ', 0x20 */ + _PUNCT, /* `!', 0x21 */ + _PUNCT, /* 0x22 */ + _PUNCT, /* `#', 0x23 */ + _PUNCT, /* `$', 0x24 */ + _PUNCT, /* `%', 0x25 */ + _PUNCT, /* `&', 0x26 */ + _PUNCT, /* 0x27 */ + _PUNCT, /* `(', 0x28 */ + _PUNCT, /* `)', 0x29 */ + _PUNCT, /* `*', 0x2a */ + _PUNCT, /* `+', 0x2b */ + _PUNCT, /* `,', 0x2c */ + _PUNCT, /* `-', 0x2d */ + _PUNCT, /* `.', 0x2e */ + _PUNCT, /* `/', 0x2f */ + _DIGIT | _HEX, /* `0', 0x30 */ + _DIGIT | _HEX, /* `1', 0x31 */ + _DIGIT | _HEX, /* `2', 0x32 */ + _DIGIT | _HEX, /* `3', 0x33 */ + _DIGIT | _HEX, /* `4', 0x34 */ + _DIGIT | _HEX, /* `5', 0x35 */ + _DIGIT | _HEX, /* `6', 0x36 */ + _DIGIT | _HEX, /* `7', 0x37 */ + _DIGIT | _HEX, /* `8', 0x38 */ + _DIGIT | _HEX, /* `9', 0x39 */ + _PUNCT, /* `:', 0x3a */ + _PUNCT, /* `;', 0x3b */ + _PUNCT, /* `<', 0x3c */ + _PUNCT, /* `=', 0x3d */ + _PUNCT, /* `>', 0x3e */ + _PUNCT, /* `?', 0x3f */ + _PUNCT, /* `@', 0x40 */ + 0x0100 | _UPPER | _HEX, /* `A', 0x41 */ + 0x0100 | _UPPER | _HEX, /* `B', 0x42 */ + 0x0100 | _UPPER | _HEX, /* `C', 0x43 */ + 0x0100 | _UPPER | _HEX, /* `D', 0x44 */ + 0x0100 | _UPPER | _HEX, /* `E', 0x45 */ + 0x0100 | _UPPER | _HEX, /* `F', 0x46 */ + 0x0100 | _UPPER, /* `G', 0x47 */ + 0x0100 | _UPPER, /* `H', 0x48 */ + 0x0100 | _UPPER, /* `I', 0x49 */ + 0x0100 | _UPPER, /* `J', 0x4a */ + 0x0100 | _UPPER, /* `K', 0x4b */ + 0x0100 | _UPPER, /* `L', 0x4c */ + 0x0100 | _UPPER, /* `M', 0x4d */ + 0x0100 | _UPPER, /* `N', 0x4e */ + 0x0100 | _UPPER, /* `O', 0x4f */ + 0x0100 | _UPPER, /* `P', 0x50 */ + 0x0100 | _UPPER, /* `Q', 0x51 */ + 0x0100 | _UPPER, /* `R', 0x52 */ + 0x0100 | _UPPER, /* `S', 0x53 */ + 0x0100 | _UPPER, /* `T', 0x54 */ + 0x0100 | _UPPER, /* `U', 0x55 */ + 0x0100 | _UPPER, /* `V', 0x56 */ + 0x0100 | _UPPER, /* `W', 0x57 */ + 0x0100 | _UPPER, /* `X', 0x58 */ + 0x0100 | _UPPER, /* `Y', 0x59 */ + 0x0100 | _UPPER, /* `Z', 0x5a */ + _PUNCT, /* `[', 0x5b */ + _PUNCT, /* 0x5c */ + _PUNCT, /* `]', 0x5d */ + _PUNCT, /* `^', 0x5e */ + _PUNCT, /* `_', 0x5f */ + _PUNCT, /* 0x60 */ + 0x0100 | _LOWER | _HEX, /* `a', 0x61 */ + 0x0100 | _LOWER | _HEX, /* `b', 0x62 */ + 0x0100 | _LOWER | _HEX, /* `c', 0x63 */ + 0x0100 | _LOWER | _HEX, /* `d', 0x64 */ + 0x0100 | _LOWER | _HEX, /* `e', 0x65 */ + 0x0100 | _LOWER | _HEX, /* `f', 0x66 */ + 0x0100 | _LOWER, /* `g', 0x67 */ + 0x0100 | _LOWER, /* `h', 0x68 */ + 0x0100 | _LOWER, /* `i', 0x69 */ + 0x0100 | _LOWER, /* `j', 0x6a */ + 0x0100 | _LOWER, /* `k', 0x6b */ + 0x0100 | _LOWER, /* `l', 0x6c */ + 0x0100 | _LOWER, /* `m', 0x6d */ + 0x0100 | _LOWER, /* `n', 0x6e */ + 0x0100 | _LOWER, /* `o', 0x6f */ + 0x0100 | _LOWER, /* `p', 0x70 */ + 0x0100 | _LOWER, /* `q', 0x71 */ + 0x0100 | _LOWER, /* `r', 0x72 */ + 0x0100 | _LOWER, /* `s', 0x73 */ + 0x0100 | _LOWER, /* `t', 0x74 */ + 0x0100 | _LOWER, /* `u', 0x75 */ + 0x0100 | _LOWER, /* `v', 0x76 */ + 0x0100 | _LOWER, /* `w', 0x77 */ + 0x0100 | _LOWER, /* `x', 0x78 */ + 0x0100 | _LOWER, /* `y', 0x79 */ + 0x0100 | _LOWER, /* `z', 0x7a */ + _PUNCT, /* `{', 0x7b */ + _PUNCT, /* `|', 0x7c */ + _PUNCT, /* `}', 0x7d */ + _PUNCT, /* `~', 0x7e */ + _CONTROL, /* 0x7f */ + _CONTROL, /* 0x80 */ + _CONTROL, /* 0x81 */ + _CONTROL, /* 0x82 */ + _CONTROL, /* 0x83 */ + _CONTROL, /* 0x84 */ + _CONTROL, /* 0x85 */ + _CONTROL, /* 0x86 */ + _CONTROL, /* 0x87 */ + _CONTROL, /* 0x88 */ + _CONTROL, /* 0x89 */ + _CONTROL, /* 0x8a */ + _CONTROL, /* 0x8b */ + _CONTROL, /* 0x8c */ + _CONTROL, /* 0x8d */ + _CONTROL, /* 0x8e */ + _CONTROL, /* 0x8f */ + _CONTROL, /* 0x90 */ + _CONTROL, /* 0x91 */ + _CONTROL, /* 0x92 */ + _CONTROL, /* 0x93 */ + _CONTROL, /* 0x94 */ + _CONTROL, /* 0x95 */ + _CONTROL, /* 0x96 */ + _CONTROL, /* 0x97 */ + _CONTROL, /* 0x98 */ + _CONTROL, /* 0x99 */ + _CONTROL, /* 0x9a */ + _CONTROL, /* 0x9b */ + _CONTROL, /* 0x9c */ + _CONTROL, /* 0x9d */ + _CONTROL, /* 0x9e */ + _CONTROL, /* 0x9f */ + _BLANK | _SPACE, /* 0xa0 */ + _PUNCT, /* 0xa1 */ + _PUNCT, /* 0xa2 */ + _PUNCT, /* 0xa3 */ + _PUNCT, /* 0xa4 */ + _PUNCT, /* 0xa5 */ + _PUNCT, /* 0xa6 */ + _PUNCT, /* 0xa7 */ + _PUNCT, /* 0xa8 */ + _PUNCT, /* 0xa9 */ + _PUNCT, /* 0xaa */ + _PUNCT, /* 0xab */ + _PUNCT, /* 0xac */ + _PUNCT, /* 0xad */ + _PUNCT, /* 0xae */ + _PUNCT, /* 0xaf */ + _PUNCT, /* 0xb0 */ + _PUNCT, /* 0xb1 */ + _PUNCT | _DIGIT, /* 0xb2 */ + _PUNCT | _DIGIT, /* 0xb3 */ + _PUNCT, /* 0xb4 */ + _PUNCT, /* 0xb5 */ + _PUNCT, /* 0xb6 */ + _PUNCT, /* 0xb7 */ + _PUNCT, /* 0xb8 */ + _PUNCT | _DIGIT, /* 0xb9 */ + _PUNCT, /* 0xba */ + _PUNCT, /* 0xbb */ + _PUNCT, /* 0xbc */ + _PUNCT, /* 0xbd */ + _PUNCT, /* 0xbe */ + _PUNCT, /* 0xbf */ + 0x0100 | _UPPER, /* 0xc0 */ + 0x0100 | _UPPER, /* 0xc1 */ + 0x0100 | _UPPER, /* 0xc2 */ + 0x0100 | _UPPER, /* 0xc3 */ + 0x0100 | _UPPER, /* 0xc4 */ + 0x0100 | _UPPER, /* 0xc5 */ + 0x0100 | _UPPER, /* 0xc6 */ + 0x0100 | _UPPER, /* 0xc7 */ + 0x0100 | _UPPER, /* 0xc8 */ + 0x0100 | _UPPER, /* 0xc9 */ + 0x0100 | _UPPER, /* 0xca */ + 0x0100 | _UPPER, /* 0xcb */ + 0x0100 | _UPPER, /* 0xcc */ + 0x0100 | _UPPER, /* 0xcd */ + 0x0100 | _UPPER, /* 0xce */ + 0x0100 | _UPPER, /* 0xcf */ + 0x0100 | _UPPER, /* 0xd0 */ + 0x0100 | _UPPER, /* 0xd1 */ + 0x0100 | _UPPER, /* 0xd2 */ + 0x0100 | _UPPER, /* 0xd3 */ + 0x0100 | _UPPER, /* 0xd4 */ + 0x0100 | _UPPER, /* 0xd5 */ + 0x0100 | _UPPER, /* 0xd6 */ + _PUNCT, /* 0xd7 */ + 0x0100 | _UPPER, /* 0xd8 */ + 0x0100 | _UPPER, /* 0xd9 */ + 0x0100 | _UPPER, /* 0xda */ + 0x0100 | _UPPER, /* 0xdb */ + 0x0100 | _UPPER, /* 0xdc */ + 0x0100 | _UPPER, /* 0xdd */ + 0x0100 | _UPPER, /* 0xde */ + 0x0100 | _LOWER, /* 0xdf */ + 0x0100 | _LOWER, /* 0xe0 */ + 0x0100 | _LOWER, /* 0xe1 */ + 0x0100 | _LOWER, /* 0xe2 */ + 0x0100 | _LOWER, /* 0xe3 */ + 0x0100 | _LOWER, /* 0xe4 */ + 0x0100 | _LOWER, /* 0xe5 */ + 0x0100 | _LOWER, /* 0xe6 */ + 0x0100 | _LOWER, /* 0xe7 */ + 0x0100 | _LOWER, /* 0xe8 */ + 0x0100 | _LOWER, /* 0xe9 */ + 0x0100 | _LOWER, /* 0xea */ + 0x0100 | _LOWER, /* 0xeb */ + 0x0100 | _LOWER, /* 0xec */ + 0x0100 | _LOWER, /* 0xed */ + 0x0100 | _LOWER, /* 0xee */ + 0x0100 | _LOWER, /* 0xef */ + 0x0100 | _LOWER, /* 0xf0 */ + 0x0100 | _LOWER, /* 0xf1 */ + 0x0100 | _LOWER, /* 0xf2 */ + 0x0100 | _LOWER, /* 0xf3 */ + 0x0100 | _LOWER, /* 0xf4 */ + 0x0100 | _LOWER, /* 0xf5 */ + 0x0100 | _LOWER, /* 0xf6 */ + _PUNCT, /* 0xf7 */ + 0x0100 | _LOWER, /* 0xf8 */ + 0x0100 | _LOWER, /* 0xf9 */ + 0x0100 | _LOWER, /* 0xfa */ + 0x0100 | _LOWER, /* 0xfb */ + 0x0100 | _LOWER, /* 0xfc */ + 0x0100 | _LOWER, /* 0xfd */ + 0x0100 | _LOWER, /* 0xfe */ + 0x0100 | _LOWER /* 0xff */ +}; const unsigned short *_pctype = _ctype + 1; -const unsigned short *_pwctype = _ctype + 1; +const unsigned short *_pwctype = _wctype + 1; /* * @implemented @@ -300,6 +559,11 @@ const unsigned short **__p__pctype(void) return &_pctype; } +const unsigned short* __cdecl __pctype_func(void) +{ + return _pctype; +} + /* * @implemented */ @@ -308,6 +572,11 @@ const unsigned short **__p__pwctype(void) return &_pwctype; } +const unsigned short* __cdecl __pwctype_func(void) +{ + return _pwctype; +} + int _isctype (int c, int ctypeFlags) { return (_pctype[(unsigned char)(c & 0xFF)] & ctypeFlags); From 772682da0e0118d1d1d4b39a5b06230fcba496cb Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sun, 28 Mar 2010 01:25:22 +0000 Subject: [PATCH 037/134] [DHCP] define NO_OLDNAMES to prevent redefinition svn path=/branches/ros-amd64-bringup/; revision=46509 --- reactos/base/services/dhcp/dhcp.rbuild | 1 + 1 file changed, 1 insertion(+) diff --git a/reactos/base/services/dhcp/dhcp.rbuild b/reactos/base/services/dhcp/dhcp.rbuild index c886e4a4918..85e5147d834 100644 --- a/reactos/base/services/dhcp/dhcp.rbuild +++ b/reactos/base/services/dhcp/dhcp.rbuild @@ -9,6 +9,7 @@ _close _read _write + 1 ntdll ws2_32 From 55e794943f85399e0d0cc667225c052ac2a014b8 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sun, 28 Mar 2010 03:06:50 +0000 Subject: [PATCH 038/134] [FREELDR] - Add a missing cast svn path=/branches/ros-amd64-bringup/; revision=46510 --- reactos/boot/freeldr/freeldr/windows/peloader.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reactos/boot/freeldr/freeldr/windows/peloader.c b/reactos/boot/freeldr/freeldr/windows/peloader.c index fae23d6b90c..778967d77d3 100644 --- a/reactos/boot/freeldr/freeldr/windows/peloader.c +++ b/reactos/boot/freeldr/freeldr/windows/peloader.c @@ -573,7 +573,7 @@ WinLdrpBindImportName(IN OUT PLOADER_PARAMETER_BLOCK WinLdrBlock, High = ExportDirectory->NumberOfNames - 1; DPRINTM(DPRINT_PELOADER, "WinLdrpBindImportName() looking up import '%s' in #0..#%d\n", - VaToPa(&((PIMAGE_IMPORT_BY_NAME)VaToPa(ThunkData->u1.AddressOfData))->Name[0]), High); + VaToPa(&((PIMAGE_IMPORT_BY_NAME)VaToPa((PVOID)ThunkData->u1.AddressOfData))->Name[0]), High); /* Perform a binary-search loop */ while (High >= Low) @@ -586,7 +586,7 @@ WinLdrpBindImportName(IN OUT PLOADER_PARAMETER_BLOCK WinLdrBlock, (PCHAR)VaToPa(RVA(DllBase, NameTable[Middle]))); DPRINTM(DPRINT_PELOADER, "Binary search: comparing Import '%s', Export #%ld:'%s' -> %d\n", - VaToPa(&((PIMAGE_IMPORT_BY_NAME)VaToPa(ThunkData->u1.AddressOfData))->Name[0]), + VaToPa(&((PIMAGE_IMPORT_BY_NAME)VaToPa((PVOID)ThunkData->u1.AddressOfData))->Name[0]), Middle, (PCHAR)VaToPa(RVA(DllBase, NameTable[Middle])), Result); /*DPRINTM(DPRINT_PELOADER, "TE->u1.AOD %p, fulladdr %p\n", From f42510da3b9b35141923248290f013eb7d4b7a7b Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sun, 28 Mar 2010 04:52:19 +0000 Subject: [PATCH 039/134] [FREELDR] snprintf -> _snprintf svn path=/branches/ros-amd64-bringup/; revision=46511 --- reactos/boot/freeldr/freeldr/windows/winldr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reactos/boot/freeldr/freeldr/windows/winldr.c b/reactos/boot/freeldr/freeldr/windows/winldr.c index dc210bd6a6d..72d5df4609e 100644 --- a/reactos/boot/freeldr/freeldr/windows/winldr.c +++ b/reactos/boot/freeldr/freeldr/windows/winldr.c @@ -232,7 +232,7 @@ WinLdrLoadDeviceDriver(PLOADER_PARAMETER_BLOCK LoaderBlock, PVOID DriverBase; // Separate the path to file name and directory path - snprintf(DriverPath, sizeof(DriverPath), "%wZ", FilePath); + _snprintf(DriverPath, sizeof(DriverPath), "%wZ", FilePath); DriverNamePos = strrchr(DriverPath, '\\'); if (DriverNamePos != NULL) { @@ -261,7 +261,7 @@ WinLdrLoadDeviceDriver(PLOADER_PARAMETER_BLOCK LoaderBlock, } // It's not loaded, we have to load it - snprintf(FullPath, sizeof(FullPath), "%s%wZ", BootPath, FilePath); + _snprintf(FullPath, sizeof(FullPath), "%s%wZ", BootPath, FilePath); Status = WinLdrLoadImage(FullPath, LoaderBootDriver, &DriverBase); if (!Status) { From 63cf51be08b1ecafc912819ffc592cc0853e8cb2 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sun, 28 Mar 2010 05:20:27 +0000 Subject: [PATCH 040/134] [FREETYPE] - Don't include setjmp/longjmp, we have our own svn path=/branches/ros-amd64-bringup/; revision=46512 --- reactos/lib/3rdparty/freetype/freetype.rbuild | 5 ----- 1 file changed, 5 deletions(-) diff --git a/reactos/lib/3rdparty/freetype/freetype.rbuild b/reactos/lib/3rdparty/freetype/freetype.rbuild index bf7709ede9d..51d3f0315d3 100644 --- a/reactos/lib/3rdparty/freetype/freetype.rbuild +++ b/reactos/lib/3rdparty/freetype/freetype.rbuild @@ -10,11 +10,6 @@ - - - setjmplongjmp.s - - ftsystem.c From 17d56ed0b9b23cce0f94c8244a9c0e3116d57068 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sun, 28 Mar 2010 07:09:13 +0000 Subject: [PATCH 041/134] [NTOS] Add KiEoiHelper export for x86 like in trunk svn path=/branches/ros-amd64-bringup/; revision=46513 --- reactos/ntoskrnl/ntoskrnl.pspec | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/reactos/ntoskrnl/ntoskrnl.pspec b/reactos/ntoskrnl/ntoskrnl.pspec index b45672a12e4..965929af7c4 100644 --- a/reactos/ntoskrnl/ntoskrnl.pspec +++ b/reactos/ntoskrnl/ntoskrnl.pspec @@ -728,7 +728,8 @@ @ stdcall KeWaitForSingleObject(ptr long long long ptr) @ FASTCALL KefAcquireSpinLockAtDpcLevel(ptr) @ FASTCALL KefReleaseSpinLockFromDpcLevel(ptr) -@ stdcall -arch=i386 Kei386EoiHelper(ptr) /* FIXME: Evaluate decision */ +@ stdcall -arch=i386 Kei386EoiHelper() +@ fastcall -arch=i386 KiEoiHelper(ptr) /* FIXME: Evaluate decision */ @ FASTCALL KiAcquireSpinLock(ptr) @ extern KiBugCheckData @ stdcall KiCheckForKernelApcDelivery() From 7c2c99f92e7d9708ba9923a0a024aa68ad9bc20d Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Sun, 28 Mar 2010 09:32:27 +0000 Subject: [PATCH 042/134] [PSDK] - Manually merge header changes from arwinss branch. svn path=/trunk/; revision=46514 --- reactos/dll/win32/user32/misc/desktop.c | 4 +- reactos/dll/win32/user32/misc/winsta.c | 8 +- reactos/dll/win32/user32/windows/defwnd.c | 4 - reactos/dll/win32/user32/windows/draw.c | 2 - reactos/include/psdk/wingdi.h | 103 ++++++++++++++++++++-- reactos/include/psdk/winuser.h | 65 +++++++++++--- 6 files changed, 157 insertions(+), 29 deletions(-) diff --git a/reactos/dll/win32/user32/misc/desktop.c b/reactos/dll/win32/user32/misc/desktop.c index 5bea3bbfefa..f6b1657c581 100644 --- a/reactos/dll/win32/user32/misc/desktop.c +++ b/reactos/dll/win32/user32/misc/desktop.c @@ -522,7 +522,7 @@ GetThreadDesktop( HDESK WINAPI OpenDesktopA( - LPSTR lpszDesktop, + LPCSTR lpszDesktop, DWORD dwFlags, BOOL fInherit, ACCESS_MASK dwDesiredAccess) @@ -558,7 +558,7 @@ OpenDesktopA( HDESK WINAPI OpenDesktopW( - LPWSTR lpszDesktop, + LPCWSTR lpszDesktop, DWORD dwFlags, BOOL fInherit, ACCESS_MASK dwDesiredAccess) diff --git a/reactos/dll/win32/user32/misc/winsta.c b/reactos/dll/win32/user32/misc/winsta.c index a0481696b34..f6f237c2a74 100644 --- a/reactos/dll/win32/user32/misc/winsta.c +++ b/reactos/dll/win32/user32/misc/winsta.c @@ -18,7 +18,7 @@ * @implemented */ HWINSTA WINAPI -CreateWindowStationA(LPSTR lpwinsta, +CreateWindowStationA(LPCSTR lpwinsta, DWORD dwReserved, ACCESS_MASK dwDesiredAccess, LPSECURITY_ATTRIBUTES lpsa) @@ -52,7 +52,7 @@ CreateWindowStationA(LPSTR lpwinsta, * @implemented */ HWINSTA WINAPI -CreateWindowStationW(LPWSTR lpwinsta, +CreateWindowStationW(LPCWSTR lpwinsta, DWORD dwReserved, ACCESS_MASK dwDesiredAccess, LPSECURITY_ATTRIBUTES lpsa) @@ -266,7 +266,7 @@ EnumWindowStationsW(WINSTAENUMPROCW EnumFunc, * @implemented */ HWINSTA WINAPI -OpenWindowStationA(LPSTR lpszWinSta, +OpenWindowStationA(LPCSTR lpszWinSta, BOOL fInherit, ACCESS_MASK dwDesiredAccess) { @@ -298,7 +298,7 @@ OpenWindowStationA(LPSTR lpszWinSta, * @implemented */ HWINSTA WINAPI -OpenWindowStationW(LPWSTR lpszWinSta, +OpenWindowStationW(LPCWSTR lpszWinSta, BOOL fInherit, ACCESS_MASK dwDesiredAccess) { diff --git a/reactos/dll/win32/user32/windows/defwnd.c b/reactos/dll/win32/user32/windows/defwnd.c index 890076b0286..628940de1d6 100644 --- a/reactos/dll/win32/user32/windows/defwnd.c +++ b/reactos/dll/win32/user32/windows/defwnd.c @@ -851,10 +851,6 @@ DefWndHandleWindowPosChanging(HWND hWnd, WINDOWPOS* Pos) return 0; } -/* Undocumented flags. */ -#define SWP_NOCLIENTMOVE 0x0800 -#define SWP_NOCLIENTSIZE 0x1000 - LRESULT DefWndHandleWindowPosChanged(HWND hWnd, WINDOWPOS* Pos) { diff --git a/reactos/dll/win32/user32/windows/draw.c b/reactos/dll/win32/user32/windows/draw.c index 2eb68d11988..c722dc7dbe8 100644 --- a/reactos/dll/win32/user32/windows/draw.c +++ b/reactos/dll/win32/user32/windows/draw.c @@ -37,8 +37,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(user32); /* GLOBALS *******************************************************************/ -#define DSS_DEFAULT 0x0040 /* Make it bold */ - static const WORD wPattern_AA55[8] = { 0xaaaa, 0x5555, 0xaaaa, 0x5555, 0xaaaa, 0x5555, 0xaaaa, 0x5555 }; diff --git a/reactos/include/psdk/wingdi.h b/reactos/include/psdk/wingdi.h index b7bd62b1aae..a7c5261cce8 100644 --- a/reactos/include/psdk/wingdi.h +++ b/reactos/include/psdk/wingdi.h @@ -69,6 +69,7 @@ extern "C" { #define DI_MASK 1 #define DI_NORMAL 3 #define DI_APPBANDING 1 +#define DI_NOMIRROR 16 #define EMR_HEADER 1 #define EMR_POLYBEZIER 2 #define EMR_POLYGON 3 @@ -184,12 +185,19 @@ extern "C" { #define EMR_SETICMPROFILEW 113 #define EMR_ALPHABLEND 114 #define EMR_ALPHADIBBLEND 115 +#define EMR_SETLAYOUT 115 #define EMR_TRANSPARENTBLT 116 #define EMR_TRANSPARENTDIB 117 +#define EMR_RESERVED_117 117 #define EMR_GRADIENTFILL 118 #define EMR_SETLINKEDUFIS 119 #define EMR_SETTEXTJUSTIFICATION 120 #define EMR_COLORMATCHTOTARGETW 121 +#define EMR_CREATECOLORSPACEW 122 + +#define EMR_MIN 1 +#define EMR_MAX 122 + #endif #define ENHMETA_SIGNATURE 1179469088 #define EPS_SIGNATURE 0x46535045 @@ -265,6 +273,16 @@ extern "C" { #define META_CREATEFONTINDIRECT 0x2FB #define META_CREATEBRUSHINDIRECT 0x2FC #define META_CREATEREGION 0x6FF +#define META_DRAWTEXT 0x062F +#define META_RESETDC 0x014C +#define META_STARTDOC 0x014D +#define META_STARTPAGE 0x004F +#define META_ENDPAGE 0x0050 +#define META_ABORTDOC 0x0052 +#define META_ENDDOC 0x005E +#define META_CREATEBRUSH 0x00F8 +#define META_CREATEBITMAPINDIRECT 0x02FD +#define META_CREATEBITMAP 0x06FE #define PT_MOVETO 6 #define PT_LINETO 2 #define PT_BEZIERTO 4 @@ -379,6 +397,17 @@ extern "C" { #define JOHAB_CHARSET 130 #define VIETNAMESE_CHARSET 163 #define MAC_CHARSET 77 +/* I don't know if the values of *_CHARSET macros are defined in Windows + * or if we can choose them as we want. -- srtxg + */ +#define VISCII_CHARSET (BYTE)240 /* viscii1.1-1 */ +#define TCVN_CHARSET (BYTE)241 /* tcvn-0 */ +#define KOI8_CHARSET (BYTE)242 /* koi8-{r,u,ru} */ +#define ISO3_CHARSET (BYTE)243 /* iso8859-3 */ +#define ISO4_CHARSET (BYTE)244 /* iso8859-4 */ +#define ISO10_CHARSET (BYTE)245 /* iso8859-10 */ +#define CELTIC_CHARSET (BYTE)246 /* iso8859-14 */ + #define OUT_DEFAULT_PRECIS 0 #define OUT_STRING_PRECIS 1 #define OUT_CHARACTER_PRECIS 2 @@ -400,6 +429,8 @@ extern "C" { #define PROOF_QUALITY 2 #define NONANTIALIASED_QUALITY 3 #define ANTIALIASED_QUALITY 4 +#define CLEARTYPE_QUALITY 5 +#define CLEARTYPE_NATURAL_QUALITY 6 #define DEFAULT_PITCH 0 #define FIXED_PITCH 1 #define VARIABLE_PITCH 2 @@ -562,6 +593,7 @@ extern "C" { #define PS_TYPE_MASK 983040 #define ALTERNATE 1 #define WINDING 2 +#define POLYFILL_LAST 2 #define DC_BINNAMES 12 #define DC_BINS 6 #define DC_COPIES 18 @@ -601,6 +633,7 @@ extern "C" { #define DCBA_FACEDOWNRIGHT 259 #define FLOODFILLBORDER 0 #define FLOODFILLSURFACE 1 +#define ETO_GRAYED 0x00001 #define ETO_OPAQUE 0x00002 #define ETO_CLIPPED 0x00004 #if (WINVER >= 0x0400) @@ -811,8 +844,16 @@ extern "C" { #define GGO_GRAY8_BITMAP 6 #define GGO_GLYPH_INDEX 128 #define GGO_UNHINTED 256 +#ifdef __WINESRC__ +#define WINE_GGO_GRAY16_BITMAP 0x10 +#define WINE_GGO_HRGB_BITMAP 0x11 +#define WINE_GGO_HBGR_BITMAP 0x12 +#define WINE_GGO_VRGB_BITMAP 0x13 +#define WINE_GGO_VBGR_BITMAP 0x14 +#endif #define GM_COMPATIBLE 1 #define GM_ADVANCED 2 +#define GM_LAST 2 #define MM_ANISOTROPIC 8 #define MM_HIENGLISH 5 #define MM_HIMETRIC 3 @@ -836,6 +877,12 @@ extern "C" { #define PT_CLOSEFIGURE 1 #define TT_AVAILABLE 1 #define TT_ENABLED 2 + +#ifdef __WINESRC__ +#define WINE_TT_SUBPIXEL_RENDERING_ENABLED 0x4000 +#define WINE_TT_HINTER_ENABLED 0x8000 +#endif + #define BLACK_BRUSH 4 #define DKGRAY_BRUSH 3 #define GRAY_BRUSH 2 @@ -891,6 +938,7 @@ extern "C" { #define MWT_MAX MWT_RIGHTMULTIPLY #define OPAQUE 2 #define TRANSPARENT 1 +#define BKMODE_LAST 2 #define BLACKONWHITE 1 #define WHITEONBLACK 2 #define COLORONCOLOR 3 @@ -1017,6 +1065,7 @@ extern "C" { #define BS_DIBPATTERNPT 6 #define BS_PATTERN8X8 7 #define BS_DIBPATTERN8X8 8 +#define BS_MONOPATTERN 9 #define LCS_CALIBRATED_RGB 0 #define LCS_DEVICE_RGB 1 #define LCS_DEVICE_CMYK 2 @@ -2162,6 +2211,26 @@ typedef struct tagEMRSTRETCHBLT { LONG cxSrc; LONG cySrc; } EMRSTRETCHBLT,*PEMRSTRETCHBLT; +typedef struct tagEMRALPHABLEND { + EMR emr; + RECTL rclBounds; + LONG xDest; + LONG yDest; + LONG cxDest; + LONG cyDest; + DWORD dwRop; + LONG xSrc; + LONG ySrc; + XFORM xformSrc; + COLORREF crBkColorSrc; + DWORD iUsageSrc; + DWORD offBmiSrc; + DWORD cbBmiSrc; + DWORD offBitsSrc; + DWORD cbBitsSrc; + LONG cxSrc; + LONG cySrc; +} EMRALPHABLEND, *PEMRALPHABLEND; typedef struct tagEMRSTRETCHDIBITS { EMR emr; RECTL rclBounds; @@ -2915,12 +2984,17 @@ int WINAPI FillRgn(HDC,HRGN,HBRUSH); BOOL WINAPI FixBrushOrgEx(HDC,int,int,LPPOINT); BOOL WINAPI FlattenPath(HDC); BOOL WINAPI FloodFill(HDC,int,int,COLORREF); +BOOL WINAPI FrameRgn(HDC,HRGN,HBRUSH,INT,INT); BOOL WINAPI GdiAlphaBlend(HDC,int,int,int,int,HDC,int,int,int,int,BLENDFUNCTION); BOOL WINAPI GdiComment(HDC,UINT,const BYTE*); -DEVMODEW* WINAPI GdiConvertToDevmodeW(const DEVMODEA *); +DEVMODEW * WINAPI GdiConvertToDevmodeW(const DEVMODEA *); BOOL WINAPI GdiFlush(void); +LONG WINAPI GdiGetCharDimensions(HDC, LPTEXTMETRICW, LONG *); +DWORD WINAPI GdiGetCodePage(HDC); DWORD WINAPI GdiGetBatchLimit(void); DWORD WINAPI GdiSetBatchLimit(DWORD); +BOOL WINAPI GdiGradientFill(HDC,PTRIVERTEX,ULONG,PVOID,ULONG,ULONG); +BOOL WINAPI GdiIsMetaFileDC(HDC); #define GetCValue(cmyk) ((BYTE)(cmyk)) #define GetMValue(cmyk) ((BYTE)((cmyk)>> 8)) #define GetYValue(cmyk) ((BYTE)((cmyk)>>16)) @@ -3017,8 +3091,8 @@ UINT WINAPI GetSystemPaletteEntries(HDC,UINT,UINT,LPPALETTEENTRY); UINT WINAPI GetSystemPaletteUse(HDC); UINT WINAPI GetTextAlign(HDC); int WINAPI GetTextCharacterExtra(HDC); -int WINAPI GetTextCharset(HDC); -int WINAPI GetTextCharsetInfo(HDC,LPFONTSIGNATURE,DWORD); +UINT WINAPI GetTextCharset(HDC); +UINT WINAPI GetTextCharsetInfo(HDC,LPFONTSIGNATURE,DWORD); COLORREF WINAPI GetTextColor(HDC); BOOL WINAPI GetTextExtentExPointA(HDC,LPCSTR,int,int,LPINT,LPINT,LPSIZE); BOOL WINAPI GetTextExtentExPointW( HDC,LPCWSTR,int,int,LPINT,LPINT,LPSIZE ); @@ -3059,11 +3133,11 @@ BOOL WINAPI PlayMetaFileRecord(HDC,LPHANDLETABLE,LPMETARECORD,UINT); BOOL WINAPI PlgBlt(HDC,const POINT*,HDC,int,int,int,int,HBITMAP,int,int); BOOL WINAPI PolyBezier(HDC,const POINT*,DWORD); BOOL WINAPI PolyBezierTo(HDC,const POINT*,DWORD); -BOOL WINAPI PolyDraw(HDC,const POINT*,const BYTE*,int); +BOOL WINAPI PolyDraw(HDC,const POINT*,const BYTE*,DWORD); BOOL WINAPI Polygon(HDC,const POINT*,int); BOOL WINAPI Polyline(HDC,const POINT*,int); BOOL WINAPI PolylineTo(HDC,const POINT*,DWORD); -BOOL WINAPI PolyPolygon(HDC,const POINT*,const INT*,int); +BOOL WINAPI PolyPolygon(HDC,const POINT*,const INT*,DWORD); BOOL WINAPI PolyPolyline(HDC,const POINT*,const DWORD*,DWORD); BOOL WINAPI PolyTextOutA(HDC,const POLYTEXTA*,int); BOOL WINAPI PolyTextOutW(HDC,const POLYTEXTW*,int); @@ -3094,7 +3168,7 @@ HGDIOBJ WINAPI SelectObject(HDC,HGDIOBJ); HPALETTE WINAPI SelectPalette(HDC,HPALETTE,BOOL); int WINAPI SetAbortProc(HDC,ABORTPROC); int WINAPI SetArcDirection(HDC,int); -LONG WINAPI SetBitmapBits(HBITMAP,DWORD,PCVOID); +LONG WINAPI SetBitmapBits(HBITMAP,LONG,PCVOID); BOOL WINAPI SetBitmapDimensionEx(HBITMAP,int,int,LPSIZE); COLORREF WINAPI SetBkColor(HDC,COLORREF); int WINAPI SetBkMode(HDC,int); @@ -3130,6 +3204,7 @@ BOOL WINAPI SetPixelFormat(HDC,int,const PIXELFORMATDESCRIPTOR*); BOOL WINAPI SetPixelV(HDC,int,int,COLORREF); int WINAPI SetPolyFillMode(HDC,int); BOOL WINAPI SetRectRgn(HRGN,int,int,int,int); +INT WINAPI SetRelAbs(HDC,INT); int WINAPI SetROP2(HDC,int); int WINAPI SetStretchBltMode(HDC,int); UINT WINAPI SetSystemPaletteUse(HDC,UINT); @@ -3349,6 +3424,22 @@ typedef DISPLAY_DEVICEA DISPLAY_DEVICE, *PDISPLAY_DEVICE, *LPDISPLAY_DEVICE; #endif #endif +#ifdef __WINESRC__ +/* the DC hook support is only exported on Win16, the 32-bit version is a Wine extension */ + +#define DCHC_INVALIDVISRGN 0x0001 +#define DCHC_DELETEDC 0x0002 +#define DCHF_INVALIDATEVISRGN 0x0001 +#define DCHF_VALIDATEVISRGN 0x0002 + +typedef BOOL (CALLBACK *DCHOOKPROC)(HDC,WORD,DWORD_PTR,LPARAM); + +WINGDIAPI DWORD_PTR WINAPI GetDCHook(HDC,DCHOOKPROC*); +WINGDIAPI BOOL WINAPI SetDCHook(HDC,DCHOOKPROC,DWORD_PTR); +WINGDIAPI WORD WINAPI SetHookFlags(HDC,WORD); +WINGDIAPI INT WINAPI SelectVisRgn(HDC,HRGN); +#endif /* __WINESRC__ */ + #ifdef _MSC_VER #pragma warning(pop) #endif diff --git a/reactos/include/psdk/winuser.h b/reactos/include/psdk/winuser.h index 57c1ac13aac..cd855588efe 100644 --- a/reactos/include/psdk/winuser.h +++ b/reactos/include/psdk/winuser.h @@ -299,6 +299,9 @@ extern "C" { #define ES_LOWERCASE 16 #define ES_MULTILINE 4 #define ES_NOHIDESEL 256 +#ifdef _WINE +#define ES_COMBO 0x200 /* Undocumented. Parent is a combobox */ +#endif #define ES_NUMBER 0x2000 #define ES_OEMCONVERT 0x400 #define ES_PASSWORD 32 @@ -386,6 +389,7 @@ extern "C" { #define WS_EX_COMPOSITED 0x2000000 /* XP */ #define WS_EX_CONTEXTHELP 0x400 #define WS_EX_CONTROLPARENT 0x10000 +#define WS_EX_DRAGDETECT 0x00000002L #define WS_EX_DLGMODALFRAME 1 #define WS_EX_LAYERED 0x80000 /* w2k */ #define WS_EX_LAYOUTRTL 0x400000 /* w98, w2k */ @@ -518,6 +522,7 @@ extern "C" { #define DSS_NORMAL 0 #define DSS_UNION 16 #define DSS_DISABLED 32 +#define DSS_DEFAULT 64 #define DSS_MONO 128 #define DSS_HIDEPREFIX 0x0200 #define DSS_PREFIXONLY 0x0400 @@ -864,6 +869,8 @@ extern "C" { #endif #define QS_SENDMESSAGE 64 #define QS_TIMER 16 +/* Extra (undocumented) queue wake bits - see "Undoc. Windows" */ +#define QS_SMRESULT 0x8000 #define USER_TIMER_MAXIMUM 2147483647 #define USER_TIMER_MINIMUM 10 @@ -1135,6 +1142,7 @@ extern "C" { #define MSGF_NEXTWINDOW 6 #define MSGF_MAINLOOP 8 #define MSGF_USER 4096 +#define MSGF_MAX 8 #define MOUSEEVENTF_MOVE 1 #define MOUSEEVENTF_LEFTDOWN 2 #define MOUSEEVENTF_LEFTUP 4 @@ -1142,6 +1150,8 @@ extern "C" { #define MOUSEEVENTF_RIGHTUP 16 #define MOUSEEVENTF_MIDDLEDOWN 32 #define MOUSEEVENTF_MIDDLEUP 64 +#define MOUSEEVENTF_XDOWN 128 +#define MOUSEEVENTF_XUP 256 #define MOUSEEVENTF_WHEEL 0x0800 #define MOUSEEVENTF_ABSOLUTE 32768 #define PM_NOREMOVE 0 @@ -1202,6 +1212,10 @@ extern "C" { #define SWP_NOSENDCHANGING 1024 #define SWP_DEFERERASE 8192 #define SWP_ASYNCWINDOWPOS 16384 +/* undocumented SWP flags - from SDK 3.1 */ +#define SWP_NOCLIENTSIZE 0x0800 +#define SWP_NOCLIENTMOVE 0x1000 +#define SWP_STATECHANGED 0x8000 #define HSHELL_WINDOWCREATED 1 #define HSHELL_WINDOWDESTROYED 2 @@ -1560,6 +1574,9 @@ extern "C" { #define WM_ACTIVATE 6 #define WM_SETFOCUS 7 #define WM_KILLFOCUS 8 +#ifdef _WINE +#define WM_SETVISIBLE 9 +#endif #define WM_ENABLE 10 #define WM_SETREDRAW 11 #define WM_SETTEXT 12 @@ -1599,6 +1616,8 @@ extern "C" { #define WM_GETFONT 49 #define WM_SETHOTKEY 50 #define WM_GETHOTKEY 51 +#define WM_ISACTIVEICON 53 +#define WM_QUERYPARKICON 54 #define WM_QUERYDRAGICON 55 #define WM_COMPAREITEM 57 #if (WINVER >= 0x0500) @@ -1653,6 +1672,7 @@ extern "C" { #define WM_NCXBUTTONDBLCLK 173 #endif /* (_WIN32_WINNT >= 0x0500) */ +#define WM_KEYF1 0x004d #define WM_KEYFIRST 256 #define WM_KEYDOWN 256 #define WM_KEYUP 257 @@ -1686,6 +1706,7 @@ extern "C" { #define WM_VSCROLL 277 #define WM_INITMENU 278 #define WM_INITMENUPOPUP 279 +#define WM_SYSTIMER 280 #define WM_MENUSELECT 287 #define WM_MENUCHAR 288 #define WM_ENTERIDLE 289 @@ -1705,6 +1726,15 @@ extern "C" { #endif /* _WIN32_WCE */ #endif /* (WINVER >= 0x0500) */ +/* D&D messages */ +#define WM_DROPOBJECT 0x022A +#define WM_QUERYDROPOBJECT 0x022B +#define WM_BEGINDRAG 0x022C +#define WM_DRAGLOOP 0x022D +#define WM_DRAGSELECT 0x022E +#define WM_DRAGMOVE 0x022F + +#define WM_CTLCOLOR 25 #define WM_CTLCOLORMSGBOX 306 #define WM_CTLCOLOREDIT 307 #define WM_CTLCOLORLISTBOX 308 @@ -1715,6 +1745,7 @@ extern "C" { #define MN_GETHMENU 481 #define WM_MOUSEFIRST 512 #define WM_MOUSEMOVE 512 +#define WM_LBTRACKPOINT 0x0131 #define WM_LBUTTONDOWN 513 #define WM_LBUTTONUP 514 #define WM_LBUTTONDBLCLK 515 @@ -1803,6 +1834,7 @@ extern "C" { #define WM_HOTKEY 786 #define WM_PRINT 791 #define WM_PRINTCLIENT 792 +#define WM_APPCOMMAND 793 #define WM_DWMCOMPOSITIONCHANGED 0x031E #define WM_DWMNCRENDERINGCHANGED 0x031F @@ -1819,6 +1851,8 @@ extern "C" { #define WM_APP 32768 #define WM_GETTITLEBARINFOEX 0x033F +#define XBUTTON1 0x0001 +#define XBUTTON2 0x0002 #if (_WIN32_WINNT >= 0x0400) #define WHEEL_DELTA 120 @@ -1882,6 +1916,7 @@ extern "C" { #define CB_SETLOCALE 345 #define CB_SETTOPINDEX 348 #define CB_SHOWDROPDOWN 335 +#define CB_MSGMAX 357 #define CBN_CLOSEUP 8 #define CBN_DBLCLK 2 #define CBN_DROPDOWN 7 @@ -1943,6 +1978,7 @@ extern "C" { #define LB_ADDFILE 406 #define LB_ADDSTRING 384 #ifdef _WINE +#define LB_CARETON 419 #define LB_CARETOFF 420 #endif #define LB_DELETESTRING 386 @@ -2190,6 +2226,7 @@ extern "C" { #define VK_F24 0x87 #define VK_NUMLOCK 0x90 #define VK_SCROLL 0x91 +#define VK_OEM_NEC_EQUAL 0x92 #define VK_LSHIFT 0xA0 #define VK_RSHIFT 0xA1 #define VK_LCONTROL 0xA2 @@ -3815,13 +3852,14 @@ HDC WINAPI BeginPaint(HWND,LPPAINTSTRUCT); BOOL WINAPI BringWindowToTop(HWND); long WINAPI BroadcastSystemMessage(DWORD,LPDWORD,UINT,WPARAM,LPARAM); #if (_WIN32_WINNT >= 0x0400) -long WINAPI BroadcastSystemMessageA(DWORD,LPDWORD,UINT,WPARAM,LPARAM); -long WINAPI BroadcastSystemMessageW(DWORD,LPDWORD,UINT,WPARAM,LPARAM); +LONG WINAPI BroadcastSystemMessageA(DWORD,LPDWORD,UINT,WPARAM,LPARAM); +LONG WINAPI BroadcastSystemMessageW(DWORD,LPDWORD,UINT,WPARAM,LPARAM); #endif /* (_WIN32_WINNT >= 0x0400) */ #if (_WIN32_WINNT >= 0x0501) -long WINAPI BroadcastSystemMessageExA(DWORD,LPDWORD,UINT,WPARAM,LPARAM,PBSMINFO); -long WINAPI BroadcastSystemMessageExW(DWORD,LPDWORD,UINT,WPARAM,LPARAM,PBSMINFO); +LONG WINAPI BroadcastSystemMessageExA(DWORD,LPDWORD,UINT,WPARAM,LPARAM,PBSMINFO); +LONG WINAPI BroadcastSystemMessageExW(DWORD,LPDWORD,UINT,WPARAM,LPARAM,PBSMINFO); #endif /* (_WIN32_WINNT >= 0x0501) */ +void WINAPI CalcChildScroll(HWND, INT); BOOL WINAPI CallMsgFilterA(LPMSG,INT); BOOL WINAPI CallMsgFilterW(LPMSG,INT); LRESULT WINAPI CallNextHookEx(HHOOK,int,WPARAM,LPARAM); @@ -3905,8 +3943,8 @@ HMENU WINAPI CreatePopupMenu(void); HWND WINAPI CreateWindowExA(DWORD,LPCSTR,LPCSTR,DWORD,int,int,int,int,HWND,HMENU,HINSTANCE,LPVOID); HWND WINAPI CreateWindowExW(DWORD,LPCWSTR,LPCWSTR,DWORD,int,int,int,int,HWND,HMENU,HINSTANCE,LPVOID); #ifndef NOWINDOWSTATION -HWINSTA WINAPI CreateWindowStationA(LPSTR,DWORD,DWORD,LPSECURITY_ATTRIBUTES); -HWINSTA WINAPI CreateWindowStationW(LPWSTR,DWORD,DWORD,LPSECURITY_ATTRIBUTES); +HWINSTA WINAPI CreateWindowStationA(LPCSTR,DWORD,ACCESS_MASK,LPSECURITY_ATTRIBUTES); +HWINSTA WINAPI CreateWindowStationW(LPCWSTR,DWORD,ACCESS_MASK,LPSECURITY_ATTRIBUTES); #endif LRESULT WINAPI DefDlgProcA(HWND,UINT,WPARAM,LPARAM); LRESULT WINAPI DefDlgProcW(HWND,UINT,WPARAM,LPARAM); @@ -4051,7 +4089,7 @@ BOOL WINAPI GetCursorPos(LPPOINT); HDC WINAPI GetDC(HWND); HDC WINAPI GetDCEx(HWND,HRGN,DWORD); HWND WINAPI GetDesktopWindow(void); -long WINAPI GetDialogBaseUnits(void); +LONG WINAPI GetDialogBaseUnits(void); int WINAPI GetDlgCtrlID(HWND); HWND WINAPI GetDlgItem(HWND,int); UINT WINAPI GetDlgItemInt(HWND,int,PBOOL,BOOL); @@ -4227,6 +4265,7 @@ BOOL WINAPI IsWinEventHookInstalled(DWORD); BOOL WINAPI IsZoomed(HWND); VOID WINAPI keybd_event(BYTE,BYTE,DWORD,ULONG_PTR); BOOL WINAPI KillTimer(HWND,UINT_PTR); +BOOL WINAPI KillSystemTimer(HWND,UINT_PTR); HACCEL WINAPI LoadAcceleratorsA(HINSTANCE,LPCSTR); HACCEL WINAPI LoadAcceleratorsW(HINSTANCE,LPCWSTR); HBITMAP WINAPI LoadBitmapA(HINSTANCE,LPCSTR); @@ -4286,12 +4325,12 @@ BOOL WINAPI OemToCharBuffW(LPCSTR,LPWSTR,DWORD); BOOL WINAPI OemToCharW(LPCSTR,LPWSTR); BOOL WINAPI OffsetRect(LPRECT,int,int); BOOL WINAPI OpenClipboard(HWND); -HDESK WINAPI OpenDesktopA(LPSTR,DWORD,BOOL,DWORD); -HDESK WINAPI OpenDesktopW(LPWSTR,DWORD,BOOL,DWORD); +HDESK WINAPI OpenDesktopA(LPCSTR,DWORD,BOOL,DWORD); +HDESK WINAPI OpenDesktopW(LPCWSTR,DWORD,BOOL,DWORD); BOOL WINAPI OpenIcon(HWND); HDESK WINAPI OpenInputDesktop(DWORD,BOOL,DWORD); -HWINSTA WINAPI OpenWindowStationA(LPSTR,BOOL,DWORD); -HWINSTA WINAPI OpenWindowStationW(LPWSTR,BOOL,DWORD); +HWINSTA WINAPI OpenWindowStationA(LPCSTR,BOOL,DWORD); +HWINSTA WINAPI OpenWindowStationW(LPCWSTR,BOOL,DWORD); BOOL WINAPI PaintDesktop(HDC); BOOL WINAPI PeekMessageA(LPMSG,HWND,UINT,UINT,UINT); BOOL WINAPI PeekMessageW(LPMSG,HWND,UINT,UINT,UINT); @@ -4337,6 +4376,7 @@ HANDLE WINAPI RemovePropA(HWND,LPCSTR); HANDLE WINAPI RemovePropW(HWND,LPCWSTR); BOOL WINAPI ReplyMessage(LRESULT); BOOL WINAPI ScreenToClient(HWND,LPPOINT); +VOID WINAPI ScrollChildren(HWND,UINT,WPARAM,LPARAM); BOOL WINAPI ScrollDC(HDC,int,int,LPCRECT,LPCRECT,HRGN,LPRECT); BOOL WINAPI ScrollWindow(HWND,int,int,LPCRECT,LPCRECT); int WINAPI ScrollWindowEx(HWND,int,int,LPCRECT,LPCRECT,HRGN,LPRECT,UINT); @@ -4372,6 +4412,7 @@ HWND WINAPI SetClipboardViewer(HWND); HCURSOR WINAPI SetCursor(HCURSOR); BOOL WINAPI SetCursorPos(int,int); VOID WINAPI SetDebugErrorLevel(DWORD); +BOOL WINAPI SetDeskWallPaper(LPCSTR); BOOL WINAPI SetDlgItemInt(HWND,int,UINT,BOOL); BOOL WINAPI SetDlgItemTextA(HWND,int,LPCSTR); BOOL WINAPI SetDlgItemTextW(HWND,int,LPCWSTR); @@ -4404,8 +4445,10 @@ BOOL WINAPI SetSysColors(int,const INT *,const COLORREF *); DWORD WINAPI SetSysColorsTemp(const COLORREF *, const HBRUSH *, DWORD); #define SetSysModalWindow(h) (NULL) BOOL WINAPI SetSystemCursor(HCURSOR,DWORD); +BOOL WINAPI SetSystemMenu(HWND,HMENU); BOOL WINAPI SetThreadDesktop(HDESK); UINT_PTR WINAPI SetTimer(HWND,UINT_PTR,UINT,TIMERPROC); +UINT_PTR WINAPI SetSystemTimer(HWND,UINT_PTR,UINT,TIMERPROC); BOOL WINAPI SetUserObjectInformationA(HANDLE,int,PVOID,DWORD); BOOL WINAPI SetUserObjectInformationW(HANDLE,int,PVOID,DWORD); BOOL WINAPI SetUserObjectSecurity(HANDLE,PSECURITY_INFORMATION,PSECURITY_DESCRIPTOR); From 9859090ba20a789adf03ad37bd69f5500c6c38f1 Mon Sep 17 00:00:00 2001 From: Sylvain Petreolle Date: Sun, 28 Mar 2010 10:54:44 +0000 Subject: [PATCH 043/134] Revert 46514, fixes build. svn path=/trunk/; revision=46515 --- reactos/dll/win32/user32/misc/desktop.c | 4 +- reactos/dll/win32/user32/misc/winsta.c | 8 +- reactos/dll/win32/user32/windows/defwnd.c | 4 + reactos/dll/win32/user32/windows/draw.c | 2 + reactos/include/psdk/wingdi.h | 103 ++-------------------- reactos/include/psdk/winuser.h | 65 +++----------- 6 files changed, 29 insertions(+), 157 deletions(-) diff --git a/reactos/dll/win32/user32/misc/desktop.c b/reactos/dll/win32/user32/misc/desktop.c index f6b1657c581..5bea3bbfefa 100644 --- a/reactos/dll/win32/user32/misc/desktop.c +++ b/reactos/dll/win32/user32/misc/desktop.c @@ -522,7 +522,7 @@ GetThreadDesktop( HDESK WINAPI OpenDesktopA( - LPCSTR lpszDesktop, + LPSTR lpszDesktop, DWORD dwFlags, BOOL fInherit, ACCESS_MASK dwDesiredAccess) @@ -558,7 +558,7 @@ OpenDesktopA( HDESK WINAPI OpenDesktopW( - LPCWSTR lpszDesktop, + LPWSTR lpszDesktop, DWORD dwFlags, BOOL fInherit, ACCESS_MASK dwDesiredAccess) diff --git a/reactos/dll/win32/user32/misc/winsta.c b/reactos/dll/win32/user32/misc/winsta.c index f6f237c2a74..a0481696b34 100644 --- a/reactos/dll/win32/user32/misc/winsta.c +++ b/reactos/dll/win32/user32/misc/winsta.c @@ -18,7 +18,7 @@ * @implemented */ HWINSTA WINAPI -CreateWindowStationA(LPCSTR lpwinsta, +CreateWindowStationA(LPSTR lpwinsta, DWORD dwReserved, ACCESS_MASK dwDesiredAccess, LPSECURITY_ATTRIBUTES lpsa) @@ -52,7 +52,7 @@ CreateWindowStationA(LPCSTR lpwinsta, * @implemented */ HWINSTA WINAPI -CreateWindowStationW(LPCWSTR lpwinsta, +CreateWindowStationW(LPWSTR lpwinsta, DWORD dwReserved, ACCESS_MASK dwDesiredAccess, LPSECURITY_ATTRIBUTES lpsa) @@ -266,7 +266,7 @@ EnumWindowStationsW(WINSTAENUMPROCW EnumFunc, * @implemented */ HWINSTA WINAPI -OpenWindowStationA(LPCSTR lpszWinSta, +OpenWindowStationA(LPSTR lpszWinSta, BOOL fInherit, ACCESS_MASK dwDesiredAccess) { @@ -298,7 +298,7 @@ OpenWindowStationA(LPCSTR lpszWinSta, * @implemented */ HWINSTA WINAPI -OpenWindowStationW(LPCWSTR lpszWinSta, +OpenWindowStationW(LPWSTR lpszWinSta, BOOL fInherit, ACCESS_MASK dwDesiredAccess) { diff --git a/reactos/dll/win32/user32/windows/defwnd.c b/reactos/dll/win32/user32/windows/defwnd.c index 628940de1d6..890076b0286 100644 --- a/reactos/dll/win32/user32/windows/defwnd.c +++ b/reactos/dll/win32/user32/windows/defwnd.c @@ -851,6 +851,10 @@ DefWndHandleWindowPosChanging(HWND hWnd, WINDOWPOS* Pos) return 0; } +/* Undocumented flags. */ +#define SWP_NOCLIENTMOVE 0x0800 +#define SWP_NOCLIENTSIZE 0x1000 + LRESULT DefWndHandleWindowPosChanged(HWND hWnd, WINDOWPOS* Pos) { diff --git a/reactos/dll/win32/user32/windows/draw.c b/reactos/dll/win32/user32/windows/draw.c index c722dc7dbe8..2eb68d11988 100644 --- a/reactos/dll/win32/user32/windows/draw.c +++ b/reactos/dll/win32/user32/windows/draw.c @@ -37,6 +37,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(user32); /* GLOBALS *******************************************************************/ +#define DSS_DEFAULT 0x0040 /* Make it bold */ + static const WORD wPattern_AA55[8] = { 0xaaaa, 0x5555, 0xaaaa, 0x5555, 0xaaaa, 0x5555, 0xaaaa, 0x5555 }; diff --git a/reactos/include/psdk/wingdi.h b/reactos/include/psdk/wingdi.h index a7c5261cce8..b7bd62b1aae 100644 --- a/reactos/include/psdk/wingdi.h +++ b/reactos/include/psdk/wingdi.h @@ -69,7 +69,6 @@ extern "C" { #define DI_MASK 1 #define DI_NORMAL 3 #define DI_APPBANDING 1 -#define DI_NOMIRROR 16 #define EMR_HEADER 1 #define EMR_POLYBEZIER 2 #define EMR_POLYGON 3 @@ -185,19 +184,12 @@ extern "C" { #define EMR_SETICMPROFILEW 113 #define EMR_ALPHABLEND 114 #define EMR_ALPHADIBBLEND 115 -#define EMR_SETLAYOUT 115 #define EMR_TRANSPARENTBLT 116 #define EMR_TRANSPARENTDIB 117 -#define EMR_RESERVED_117 117 #define EMR_GRADIENTFILL 118 #define EMR_SETLINKEDUFIS 119 #define EMR_SETTEXTJUSTIFICATION 120 #define EMR_COLORMATCHTOTARGETW 121 -#define EMR_CREATECOLORSPACEW 122 - -#define EMR_MIN 1 -#define EMR_MAX 122 - #endif #define ENHMETA_SIGNATURE 1179469088 #define EPS_SIGNATURE 0x46535045 @@ -273,16 +265,6 @@ extern "C" { #define META_CREATEFONTINDIRECT 0x2FB #define META_CREATEBRUSHINDIRECT 0x2FC #define META_CREATEREGION 0x6FF -#define META_DRAWTEXT 0x062F -#define META_RESETDC 0x014C -#define META_STARTDOC 0x014D -#define META_STARTPAGE 0x004F -#define META_ENDPAGE 0x0050 -#define META_ABORTDOC 0x0052 -#define META_ENDDOC 0x005E -#define META_CREATEBRUSH 0x00F8 -#define META_CREATEBITMAPINDIRECT 0x02FD -#define META_CREATEBITMAP 0x06FE #define PT_MOVETO 6 #define PT_LINETO 2 #define PT_BEZIERTO 4 @@ -397,17 +379,6 @@ extern "C" { #define JOHAB_CHARSET 130 #define VIETNAMESE_CHARSET 163 #define MAC_CHARSET 77 -/* I don't know if the values of *_CHARSET macros are defined in Windows - * or if we can choose them as we want. -- srtxg - */ -#define VISCII_CHARSET (BYTE)240 /* viscii1.1-1 */ -#define TCVN_CHARSET (BYTE)241 /* tcvn-0 */ -#define KOI8_CHARSET (BYTE)242 /* koi8-{r,u,ru} */ -#define ISO3_CHARSET (BYTE)243 /* iso8859-3 */ -#define ISO4_CHARSET (BYTE)244 /* iso8859-4 */ -#define ISO10_CHARSET (BYTE)245 /* iso8859-10 */ -#define CELTIC_CHARSET (BYTE)246 /* iso8859-14 */ - #define OUT_DEFAULT_PRECIS 0 #define OUT_STRING_PRECIS 1 #define OUT_CHARACTER_PRECIS 2 @@ -429,8 +400,6 @@ extern "C" { #define PROOF_QUALITY 2 #define NONANTIALIASED_QUALITY 3 #define ANTIALIASED_QUALITY 4 -#define CLEARTYPE_QUALITY 5 -#define CLEARTYPE_NATURAL_QUALITY 6 #define DEFAULT_PITCH 0 #define FIXED_PITCH 1 #define VARIABLE_PITCH 2 @@ -593,7 +562,6 @@ extern "C" { #define PS_TYPE_MASK 983040 #define ALTERNATE 1 #define WINDING 2 -#define POLYFILL_LAST 2 #define DC_BINNAMES 12 #define DC_BINS 6 #define DC_COPIES 18 @@ -633,7 +601,6 @@ extern "C" { #define DCBA_FACEDOWNRIGHT 259 #define FLOODFILLBORDER 0 #define FLOODFILLSURFACE 1 -#define ETO_GRAYED 0x00001 #define ETO_OPAQUE 0x00002 #define ETO_CLIPPED 0x00004 #if (WINVER >= 0x0400) @@ -844,16 +811,8 @@ extern "C" { #define GGO_GRAY8_BITMAP 6 #define GGO_GLYPH_INDEX 128 #define GGO_UNHINTED 256 -#ifdef __WINESRC__ -#define WINE_GGO_GRAY16_BITMAP 0x10 -#define WINE_GGO_HRGB_BITMAP 0x11 -#define WINE_GGO_HBGR_BITMAP 0x12 -#define WINE_GGO_VRGB_BITMAP 0x13 -#define WINE_GGO_VBGR_BITMAP 0x14 -#endif #define GM_COMPATIBLE 1 #define GM_ADVANCED 2 -#define GM_LAST 2 #define MM_ANISOTROPIC 8 #define MM_HIENGLISH 5 #define MM_HIMETRIC 3 @@ -877,12 +836,6 @@ extern "C" { #define PT_CLOSEFIGURE 1 #define TT_AVAILABLE 1 #define TT_ENABLED 2 - -#ifdef __WINESRC__ -#define WINE_TT_SUBPIXEL_RENDERING_ENABLED 0x4000 -#define WINE_TT_HINTER_ENABLED 0x8000 -#endif - #define BLACK_BRUSH 4 #define DKGRAY_BRUSH 3 #define GRAY_BRUSH 2 @@ -938,7 +891,6 @@ extern "C" { #define MWT_MAX MWT_RIGHTMULTIPLY #define OPAQUE 2 #define TRANSPARENT 1 -#define BKMODE_LAST 2 #define BLACKONWHITE 1 #define WHITEONBLACK 2 #define COLORONCOLOR 3 @@ -1065,7 +1017,6 @@ extern "C" { #define BS_DIBPATTERNPT 6 #define BS_PATTERN8X8 7 #define BS_DIBPATTERN8X8 8 -#define BS_MONOPATTERN 9 #define LCS_CALIBRATED_RGB 0 #define LCS_DEVICE_RGB 1 #define LCS_DEVICE_CMYK 2 @@ -2211,26 +2162,6 @@ typedef struct tagEMRSTRETCHBLT { LONG cxSrc; LONG cySrc; } EMRSTRETCHBLT,*PEMRSTRETCHBLT; -typedef struct tagEMRALPHABLEND { - EMR emr; - RECTL rclBounds; - LONG xDest; - LONG yDest; - LONG cxDest; - LONG cyDest; - DWORD dwRop; - LONG xSrc; - LONG ySrc; - XFORM xformSrc; - COLORREF crBkColorSrc; - DWORD iUsageSrc; - DWORD offBmiSrc; - DWORD cbBmiSrc; - DWORD offBitsSrc; - DWORD cbBitsSrc; - LONG cxSrc; - LONG cySrc; -} EMRALPHABLEND, *PEMRALPHABLEND; typedef struct tagEMRSTRETCHDIBITS { EMR emr; RECTL rclBounds; @@ -2984,17 +2915,12 @@ int WINAPI FillRgn(HDC,HRGN,HBRUSH); BOOL WINAPI FixBrushOrgEx(HDC,int,int,LPPOINT); BOOL WINAPI FlattenPath(HDC); BOOL WINAPI FloodFill(HDC,int,int,COLORREF); -BOOL WINAPI FrameRgn(HDC,HRGN,HBRUSH,INT,INT); BOOL WINAPI GdiAlphaBlend(HDC,int,int,int,int,HDC,int,int,int,int,BLENDFUNCTION); BOOL WINAPI GdiComment(HDC,UINT,const BYTE*); -DEVMODEW * WINAPI GdiConvertToDevmodeW(const DEVMODEA *); +DEVMODEW* WINAPI GdiConvertToDevmodeW(const DEVMODEA *); BOOL WINAPI GdiFlush(void); -LONG WINAPI GdiGetCharDimensions(HDC, LPTEXTMETRICW, LONG *); -DWORD WINAPI GdiGetCodePage(HDC); DWORD WINAPI GdiGetBatchLimit(void); DWORD WINAPI GdiSetBatchLimit(DWORD); -BOOL WINAPI GdiGradientFill(HDC,PTRIVERTEX,ULONG,PVOID,ULONG,ULONG); -BOOL WINAPI GdiIsMetaFileDC(HDC); #define GetCValue(cmyk) ((BYTE)(cmyk)) #define GetMValue(cmyk) ((BYTE)((cmyk)>> 8)) #define GetYValue(cmyk) ((BYTE)((cmyk)>>16)) @@ -3091,8 +3017,8 @@ UINT WINAPI GetSystemPaletteEntries(HDC,UINT,UINT,LPPALETTEENTRY); UINT WINAPI GetSystemPaletteUse(HDC); UINT WINAPI GetTextAlign(HDC); int WINAPI GetTextCharacterExtra(HDC); -UINT WINAPI GetTextCharset(HDC); -UINT WINAPI GetTextCharsetInfo(HDC,LPFONTSIGNATURE,DWORD); +int WINAPI GetTextCharset(HDC); +int WINAPI GetTextCharsetInfo(HDC,LPFONTSIGNATURE,DWORD); COLORREF WINAPI GetTextColor(HDC); BOOL WINAPI GetTextExtentExPointA(HDC,LPCSTR,int,int,LPINT,LPINT,LPSIZE); BOOL WINAPI GetTextExtentExPointW( HDC,LPCWSTR,int,int,LPINT,LPINT,LPSIZE ); @@ -3133,11 +3059,11 @@ BOOL WINAPI PlayMetaFileRecord(HDC,LPHANDLETABLE,LPMETARECORD,UINT); BOOL WINAPI PlgBlt(HDC,const POINT*,HDC,int,int,int,int,HBITMAP,int,int); BOOL WINAPI PolyBezier(HDC,const POINT*,DWORD); BOOL WINAPI PolyBezierTo(HDC,const POINT*,DWORD); -BOOL WINAPI PolyDraw(HDC,const POINT*,const BYTE*,DWORD); +BOOL WINAPI PolyDraw(HDC,const POINT*,const BYTE*,int); BOOL WINAPI Polygon(HDC,const POINT*,int); BOOL WINAPI Polyline(HDC,const POINT*,int); BOOL WINAPI PolylineTo(HDC,const POINT*,DWORD); -BOOL WINAPI PolyPolygon(HDC,const POINT*,const INT*,DWORD); +BOOL WINAPI PolyPolygon(HDC,const POINT*,const INT*,int); BOOL WINAPI PolyPolyline(HDC,const POINT*,const DWORD*,DWORD); BOOL WINAPI PolyTextOutA(HDC,const POLYTEXTA*,int); BOOL WINAPI PolyTextOutW(HDC,const POLYTEXTW*,int); @@ -3168,7 +3094,7 @@ HGDIOBJ WINAPI SelectObject(HDC,HGDIOBJ); HPALETTE WINAPI SelectPalette(HDC,HPALETTE,BOOL); int WINAPI SetAbortProc(HDC,ABORTPROC); int WINAPI SetArcDirection(HDC,int); -LONG WINAPI SetBitmapBits(HBITMAP,LONG,PCVOID); +LONG WINAPI SetBitmapBits(HBITMAP,DWORD,PCVOID); BOOL WINAPI SetBitmapDimensionEx(HBITMAP,int,int,LPSIZE); COLORREF WINAPI SetBkColor(HDC,COLORREF); int WINAPI SetBkMode(HDC,int); @@ -3204,7 +3130,6 @@ BOOL WINAPI SetPixelFormat(HDC,int,const PIXELFORMATDESCRIPTOR*); BOOL WINAPI SetPixelV(HDC,int,int,COLORREF); int WINAPI SetPolyFillMode(HDC,int); BOOL WINAPI SetRectRgn(HRGN,int,int,int,int); -INT WINAPI SetRelAbs(HDC,INT); int WINAPI SetROP2(HDC,int); int WINAPI SetStretchBltMode(HDC,int); UINT WINAPI SetSystemPaletteUse(HDC,UINT); @@ -3424,22 +3349,6 @@ typedef DISPLAY_DEVICEA DISPLAY_DEVICE, *PDISPLAY_DEVICE, *LPDISPLAY_DEVICE; #endif #endif -#ifdef __WINESRC__ -/* the DC hook support is only exported on Win16, the 32-bit version is a Wine extension */ - -#define DCHC_INVALIDVISRGN 0x0001 -#define DCHC_DELETEDC 0x0002 -#define DCHF_INVALIDATEVISRGN 0x0001 -#define DCHF_VALIDATEVISRGN 0x0002 - -typedef BOOL (CALLBACK *DCHOOKPROC)(HDC,WORD,DWORD_PTR,LPARAM); - -WINGDIAPI DWORD_PTR WINAPI GetDCHook(HDC,DCHOOKPROC*); -WINGDIAPI BOOL WINAPI SetDCHook(HDC,DCHOOKPROC,DWORD_PTR); -WINGDIAPI WORD WINAPI SetHookFlags(HDC,WORD); -WINGDIAPI INT WINAPI SelectVisRgn(HDC,HRGN); -#endif /* __WINESRC__ */ - #ifdef _MSC_VER #pragma warning(pop) #endif diff --git a/reactos/include/psdk/winuser.h b/reactos/include/psdk/winuser.h index cd855588efe..57c1ac13aac 100644 --- a/reactos/include/psdk/winuser.h +++ b/reactos/include/psdk/winuser.h @@ -299,9 +299,6 @@ extern "C" { #define ES_LOWERCASE 16 #define ES_MULTILINE 4 #define ES_NOHIDESEL 256 -#ifdef _WINE -#define ES_COMBO 0x200 /* Undocumented. Parent is a combobox */ -#endif #define ES_NUMBER 0x2000 #define ES_OEMCONVERT 0x400 #define ES_PASSWORD 32 @@ -389,7 +386,6 @@ extern "C" { #define WS_EX_COMPOSITED 0x2000000 /* XP */ #define WS_EX_CONTEXTHELP 0x400 #define WS_EX_CONTROLPARENT 0x10000 -#define WS_EX_DRAGDETECT 0x00000002L #define WS_EX_DLGMODALFRAME 1 #define WS_EX_LAYERED 0x80000 /* w2k */ #define WS_EX_LAYOUTRTL 0x400000 /* w98, w2k */ @@ -522,7 +518,6 @@ extern "C" { #define DSS_NORMAL 0 #define DSS_UNION 16 #define DSS_DISABLED 32 -#define DSS_DEFAULT 64 #define DSS_MONO 128 #define DSS_HIDEPREFIX 0x0200 #define DSS_PREFIXONLY 0x0400 @@ -869,8 +864,6 @@ extern "C" { #endif #define QS_SENDMESSAGE 64 #define QS_TIMER 16 -/* Extra (undocumented) queue wake bits - see "Undoc. Windows" */ -#define QS_SMRESULT 0x8000 #define USER_TIMER_MAXIMUM 2147483647 #define USER_TIMER_MINIMUM 10 @@ -1142,7 +1135,6 @@ extern "C" { #define MSGF_NEXTWINDOW 6 #define MSGF_MAINLOOP 8 #define MSGF_USER 4096 -#define MSGF_MAX 8 #define MOUSEEVENTF_MOVE 1 #define MOUSEEVENTF_LEFTDOWN 2 #define MOUSEEVENTF_LEFTUP 4 @@ -1150,8 +1142,6 @@ extern "C" { #define MOUSEEVENTF_RIGHTUP 16 #define MOUSEEVENTF_MIDDLEDOWN 32 #define MOUSEEVENTF_MIDDLEUP 64 -#define MOUSEEVENTF_XDOWN 128 -#define MOUSEEVENTF_XUP 256 #define MOUSEEVENTF_WHEEL 0x0800 #define MOUSEEVENTF_ABSOLUTE 32768 #define PM_NOREMOVE 0 @@ -1212,10 +1202,6 @@ extern "C" { #define SWP_NOSENDCHANGING 1024 #define SWP_DEFERERASE 8192 #define SWP_ASYNCWINDOWPOS 16384 -/* undocumented SWP flags - from SDK 3.1 */ -#define SWP_NOCLIENTSIZE 0x0800 -#define SWP_NOCLIENTMOVE 0x1000 -#define SWP_STATECHANGED 0x8000 #define HSHELL_WINDOWCREATED 1 #define HSHELL_WINDOWDESTROYED 2 @@ -1574,9 +1560,6 @@ extern "C" { #define WM_ACTIVATE 6 #define WM_SETFOCUS 7 #define WM_KILLFOCUS 8 -#ifdef _WINE -#define WM_SETVISIBLE 9 -#endif #define WM_ENABLE 10 #define WM_SETREDRAW 11 #define WM_SETTEXT 12 @@ -1616,8 +1599,6 @@ extern "C" { #define WM_GETFONT 49 #define WM_SETHOTKEY 50 #define WM_GETHOTKEY 51 -#define WM_ISACTIVEICON 53 -#define WM_QUERYPARKICON 54 #define WM_QUERYDRAGICON 55 #define WM_COMPAREITEM 57 #if (WINVER >= 0x0500) @@ -1672,7 +1653,6 @@ extern "C" { #define WM_NCXBUTTONDBLCLK 173 #endif /* (_WIN32_WINNT >= 0x0500) */ -#define WM_KEYF1 0x004d #define WM_KEYFIRST 256 #define WM_KEYDOWN 256 #define WM_KEYUP 257 @@ -1706,7 +1686,6 @@ extern "C" { #define WM_VSCROLL 277 #define WM_INITMENU 278 #define WM_INITMENUPOPUP 279 -#define WM_SYSTIMER 280 #define WM_MENUSELECT 287 #define WM_MENUCHAR 288 #define WM_ENTERIDLE 289 @@ -1726,15 +1705,6 @@ extern "C" { #endif /* _WIN32_WCE */ #endif /* (WINVER >= 0x0500) */ -/* D&D messages */ -#define WM_DROPOBJECT 0x022A -#define WM_QUERYDROPOBJECT 0x022B -#define WM_BEGINDRAG 0x022C -#define WM_DRAGLOOP 0x022D -#define WM_DRAGSELECT 0x022E -#define WM_DRAGMOVE 0x022F - -#define WM_CTLCOLOR 25 #define WM_CTLCOLORMSGBOX 306 #define WM_CTLCOLOREDIT 307 #define WM_CTLCOLORLISTBOX 308 @@ -1745,7 +1715,6 @@ extern "C" { #define MN_GETHMENU 481 #define WM_MOUSEFIRST 512 #define WM_MOUSEMOVE 512 -#define WM_LBTRACKPOINT 0x0131 #define WM_LBUTTONDOWN 513 #define WM_LBUTTONUP 514 #define WM_LBUTTONDBLCLK 515 @@ -1834,7 +1803,6 @@ extern "C" { #define WM_HOTKEY 786 #define WM_PRINT 791 #define WM_PRINTCLIENT 792 -#define WM_APPCOMMAND 793 #define WM_DWMCOMPOSITIONCHANGED 0x031E #define WM_DWMNCRENDERINGCHANGED 0x031F @@ -1851,8 +1819,6 @@ extern "C" { #define WM_APP 32768 #define WM_GETTITLEBARINFOEX 0x033F -#define XBUTTON1 0x0001 -#define XBUTTON2 0x0002 #if (_WIN32_WINNT >= 0x0400) #define WHEEL_DELTA 120 @@ -1916,7 +1882,6 @@ extern "C" { #define CB_SETLOCALE 345 #define CB_SETTOPINDEX 348 #define CB_SHOWDROPDOWN 335 -#define CB_MSGMAX 357 #define CBN_CLOSEUP 8 #define CBN_DBLCLK 2 #define CBN_DROPDOWN 7 @@ -1978,7 +1943,6 @@ extern "C" { #define LB_ADDFILE 406 #define LB_ADDSTRING 384 #ifdef _WINE -#define LB_CARETON 419 #define LB_CARETOFF 420 #endif #define LB_DELETESTRING 386 @@ -2226,7 +2190,6 @@ extern "C" { #define VK_F24 0x87 #define VK_NUMLOCK 0x90 #define VK_SCROLL 0x91 -#define VK_OEM_NEC_EQUAL 0x92 #define VK_LSHIFT 0xA0 #define VK_RSHIFT 0xA1 #define VK_LCONTROL 0xA2 @@ -3852,14 +3815,13 @@ HDC WINAPI BeginPaint(HWND,LPPAINTSTRUCT); BOOL WINAPI BringWindowToTop(HWND); long WINAPI BroadcastSystemMessage(DWORD,LPDWORD,UINT,WPARAM,LPARAM); #if (_WIN32_WINNT >= 0x0400) -LONG WINAPI BroadcastSystemMessageA(DWORD,LPDWORD,UINT,WPARAM,LPARAM); -LONG WINAPI BroadcastSystemMessageW(DWORD,LPDWORD,UINT,WPARAM,LPARAM); +long WINAPI BroadcastSystemMessageA(DWORD,LPDWORD,UINT,WPARAM,LPARAM); +long WINAPI BroadcastSystemMessageW(DWORD,LPDWORD,UINT,WPARAM,LPARAM); #endif /* (_WIN32_WINNT >= 0x0400) */ #if (_WIN32_WINNT >= 0x0501) -LONG WINAPI BroadcastSystemMessageExA(DWORD,LPDWORD,UINT,WPARAM,LPARAM,PBSMINFO); -LONG WINAPI BroadcastSystemMessageExW(DWORD,LPDWORD,UINT,WPARAM,LPARAM,PBSMINFO); +long WINAPI BroadcastSystemMessageExA(DWORD,LPDWORD,UINT,WPARAM,LPARAM,PBSMINFO); +long WINAPI BroadcastSystemMessageExW(DWORD,LPDWORD,UINT,WPARAM,LPARAM,PBSMINFO); #endif /* (_WIN32_WINNT >= 0x0501) */ -void WINAPI CalcChildScroll(HWND, INT); BOOL WINAPI CallMsgFilterA(LPMSG,INT); BOOL WINAPI CallMsgFilterW(LPMSG,INT); LRESULT WINAPI CallNextHookEx(HHOOK,int,WPARAM,LPARAM); @@ -3943,8 +3905,8 @@ HMENU WINAPI CreatePopupMenu(void); HWND WINAPI CreateWindowExA(DWORD,LPCSTR,LPCSTR,DWORD,int,int,int,int,HWND,HMENU,HINSTANCE,LPVOID); HWND WINAPI CreateWindowExW(DWORD,LPCWSTR,LPCWSTR,DWORD,int,int,int,int,HWND,HMENU,HINSTANCE,LPVOID); #ifndef NOWINDOWSTATION -HWINSTA WINAPI CreateWindowStationA(LPCSTR,DWORD,ACCESS_MASK,LPSECURITY_ATTRIBUTES); -HWINSTA WINAPI CreateWindowStationW(LPCWSTR,DWORD,ACCESS_MASK,LPSECURITY_ATTRIBUTES); +HWINSTA WINAPI CreateWindowStationA(LPSTR,DWORD,DWORD,LPSECURITY_ATTRIBUTES); +HWINSTA WINAPI CreateWindowStationW(LPWSTR,DWORD,DWORD,LPSECURITY_ATTRIBUTES); #endif LRESULT WINAPI DefDlgProcA(HWND,UINT,WPARAM,LPARAM); LRESULT WINAPI DefDlgProcW(HWND,UINT,WPARAM,LPARAM); @@ -4089,7 +4051,7 @@ BOOL WINAPI GetCursorPos(LPPOINT); HDC WINAPI GetDC(HWND); HDC WINAPI GetDCEx(HWND,HRGN,DWORD); HWND WINAPI GetDesktopWindow(void); -LONG WINAPI GetDialogBaseUnits(void); +long WINAPI GetDialogBaseUnits(void); int WINAPI GetDlgCtrlID(HWND); HWND WINAPI GetDlgItem(HWND,int); UINT WINAPI GetDlgItemInt(HWND,int,PBOOL,BOOL); @@ -4265,7 +4227,6 @@ BOOL WINAPI IsWinEventHookInstalled(DWORD); BOOL WINAPI IsZoomed(HWND); VOID WINAPI keybd_event(BYTE,BYTE,DWORD,ULONG_PTR); BOOL WINAPI KillTimer(HWND,UINT_PTR); -BOOL WINAPI KillSystemTimer(HWND,UINT_PTR); HACCEL WINAPI LoadAcceleratorsA(HINSTANCE,LPCSTR); HACCEL WINAPI LoadAcceleratorsW(HINSTANCE,LPCWSTR); HBITMAP WINAPI LoadBitmapA(HINSTANCE,LPCSTR); @@ -4325,12 +4286,12 @@ BOOL WINAPI OemToCharBuffW(LPCSTR,LPWSTR,DWORD); BOOL WINAPI OemToCharW(LPCSTR,LPWSTR); BOOL WINAPI OffsetRect(LPRECT,int,int); BOOL WINAPI OpenClipboard(HWND); -HDESK WINAPI OpenDesktopA(LPCSTR,DWORD,BOOL,DWORD); -HDESK WINAPI OpenDesktopW(LPCWSTR,DWORD,BOOL,DWORD); +HDESK WINAPI OpenDesktopA(LPSTR,DWORD,BOOL,DWORD); +HDESK WINAPI OpenDesktopW(LPWSTR,DWORD,BOOL,DWORD); BOOL WINAPI OpenIcon(HWND); HDESK WINAPI OpenInputDesktop(DWORD,BOOL,DWORD); -HWINSTA WINAPI OpenWindowStationA(LPCSTR,BOOL,DWORD); -HWINSTA WINAPI OpenWindowStationW(LPCWSTR,BOOL,DWORD); +HWINSTA WINAPI OpenWindowStationA(LPSTR,BOOL,DWORD); +HWINSTA WINAPI OpenWindowStationW(LPWSTR,BOOL,DWORD); BOOL WINAPI PaintDesktop(HDC); BOOL WINAPI PeekMessageA(LPMSG,HWND,UINT,UINT,UINT); BOOL WINAPI PeekMessageW(LPMSG,HWND,UINT,UINT,UINT); @@ -4376,7 +4337,6 @@ HANDLE WINAPI RemovePropA(HWND,LPCSTR); HANDLE WINAPI RemovePropW(HWND,LPCWSTR); BOOL WINAPI ReplyMessage(LRESULT); BOOL WINAPI ScreenToClient(HWND,LPPOINT); -VOID WINAPI ScrollChildren(HWND,UINT,WPARAM,LPARAM); BOOL WINAPI ScrollDC(HDC,int,int,LPCRECT,LPCRECT,HRGN,LPRECT); BOOL WINAPI ScrollWindow(HWND,int,int,LPCRECT,LPCRECT); int WINAPI ScrollWindowEx(HWND,int,int,LPCRECT,LPCRECT,HRGN,LPRECT,UINT); @@ -4412,7 +4372,6 @@ HWND WINAPI SetClipboardViewer(HWND); HCURSOR WINAPI SetCursor(HCURSOR); BOOL WINAPI SetCursorPos(int,int); VOID WINAPI SetDebugErrorLevel(DWORD); -BOOL WINAPI SetDeskWallPaper(LPCSTR); BOOL WINAPI SetDlgItemInt(HWND,int,UINT,BOOL); BOOL WINAPI SetDlgItemTextA(HWND,int,LPCSTR); BOOL WINAPI SetDlgItemTextW(HWND,int,LPCWSTR); @@ -4445,10 +4404,8 @@ BOOL WINAPI SetSysColors(int,const INT *,const COLORREF *); DWORD WINAPI SetSysColorsTemp(const COLORREF *, const HBRUSH *, DWORD); #define SetSysModalWindow(h) (NULL) BOOL WINAPI SetSystemCursor(HCURSOR,DWORD); -BOOL WINAPI SetSystemMenu(HWND,HMENU); BOOL WINAPI SetThreadDesktop(HDESK); UINT_PTR WINAPI SetTimer(HWND,UINT_PTR,UINT,TIMERPROC); -UINT_PTR WINAPI SetSystemTimer(HWND,UINT_PTR,UINT,TIMERPROC); BOOL WINAPI SetUserObjectInformationA(HANDLE,int,PVOID,DWORD); BOOL WINAPI SetUserObjectInformationW(HANDLE,int,PVOID,DWORD); BOOL WINAPI SetUserObjectSecurity(HANDLE,PSECURITY_INFORMATION,PSECURITY_DESCRIPTOR); From 7b864dca955fb2d07285915fb54cc17a3bb57147 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Sun, 28 Mar 2010 15:32:23 +0000 Subject: [PATCH 044/134] [PSDK] - Manually merge header changes from arwinss branch. Undocumented values are wrapped into #ifdef _WINE so they don't affect non-Wine code. - Undocumented flags shouldn't be defined multiple times in user32 and win32k. Put them in winuser.h for now, should be factored out into a separate file later. - Shouldn't break build this time. svn path=/trunk/; revision=46516 --- reactos/dll/win32/gdi32/objects/dc.c | 2 +- reactos/dll/win32/gdi32/objects/font.c | 2 +- reactos/dll/win32/user32/misc/desktop.c | 4 +- reactos/dll/win32/user32/misc/winsta.c | 8 +- reactos/dll/win32/user32/windows/defwnd.c | 4 - reactos/dll/win32/user32/windows/draw.c | 2 - reactos/include/psdk/wingdi.h | 97 ++++++++++++++++++- reactos/include/psdk/winuser.h | 65 ++++++++++--- .../subsystems/win32/win32k/include/timer.h | 2 +- .../subsystems/win32/win32k/include/winpos.h | 4 - .../subsystems/win32/win32k/ntuser/timer.c | 2 +- 11 files changed, 158 insertions(+), 34 deletions(-) diff --git a/reactos/dll/win32/gdi32/objects/dc.c b/reactos/dll/win32/gdi32/objects/dc.c index f6b0f90331f..2d90f60cdac 100644 --- a/reactos/dll/win32/gdi32/objects/dc.c +++ b/reactos/dll/win32/gdi32/objects/dc.c @@ -673,7 +673,7 @@ GetRelAbs( /* * @implemented */ -DWORD +INT WINAPI SetRelAbs( HDC hdc, diff --git a/reactos/dll/win32/gdi32/objects/font.c b/reactos/dll/win32/gdi32/objects/font.c index 9bdbcd63158..7ea6a32929e 100644 --- a/reactos/dll/win32/gdi32/objects/font.c +++ b/reactos/dll/win32/gdi32/objects/font.c @@ -1671,7 +1671,7 @@ RemoveFontResourceExW(LPCWSTR lpFileName, /* * @implemented */ -DWORD +LONG WINAPI GdiGetCharDimensions(HDC hdc, LPTEXTMETRICW lptm, LONG *height) { diff --git a/reactos/dll/win32/user32/misc/desktop.c b/reactos/dll/win32/user32/misc/desktop.c index 5bea3bbfefa..f6b1657c581 100644 --- a/reactos/dll/win32/user32/misc/desktop.c +++ b/reactos/dll/win32/user32/misc/desktop.c @@ -522,7 +522,7 @@ GetThreadDesktop( HDESK WINAPI OpenDesktopA( - LPSTR lpszDesktop, + LPCSTR lpszDesktop, DWORD dwFlags, BOOL fInherit, ACCESS_MASK dwDesiredAccess) @@ -558,7 +558,7 @@ OpenDesktopA( HDESK WINAPI OpenDesktopW( - LPWSTR lpszDesktop, + LPCWSTR lpszDesktop, DWORD dwFlags, BOOL fInherit, ACCESS_MASK dwDesiredAccess) diff --git a/reactos/dll/win32/user32/misc/winsta.c b/reactos/dll/win32/user32/misc/winsta.c index a0481696b34..f6f237c2a74 100644 --- a/reactos/dll/win32/user32/misc/winsta.c +++ b/reactos/dll/win32/user32/misc/winsta.c @@ -18,7 +18,7 @@ * @implemented */ HWINSTA WINAPI -CreateWindowStationA(LPSTR lpwinsta, +CreateWindowStationA(LPCSTR lpwinsta, DWORD dwReserved, ACCESS_MASK dwDesiredAccess, LPSECURITY_ATTRIBUTES lpsa) @@ -52,7 +52,7 @@ CreateWindowStationA(LPSTR lpwinsta, * @implemented */ HWINSTA WINAPI -CreateWindowStationW(LPWSTR lpwinsta, +CreateWindowStationW(LPCWSTR lpwinsta, DWORD dwReserved, ACCESS_MASK dwDesiredAccess, LPSECURITY_ATTRIBUTES lpsa) @@ -266,7 +266,7 @@ EnumWindowStationsW(WINSTAENUMPROCW EnumFunc, * @implemented */ HWINSTA WINAPI -OpenWindowStationA(LPSTR lpszWinSta, +OpenWindowStationA(LPCSTR lpszWinSta, BOOL fInherit, ACCESS_MASK dwDesiredAccess) { @@ -298,7 +298,7 @@ OpenWindowStationA(LPSTR lpszWinSta, * @implemented */ HWINSTA WINAPI -OpenWindowStationW(LPWSTR lpszWinSta, +OpenWindowStationW(LPCWSTR lpszWinSta, BOOL fInherit, ACCESS_MASK dwDesiredAccess) { diff --git a/reactos/dll/win32/user32/windows/defwnd.c b/reactos/dll/win32/user32/windows/defwnd.c index 890076b0286..628940de1d6 100644 --- a/reactos/dll/win32/user32/windows/defwnd.c +++ b/reactos/dll/win32/user32/windows/defwnd.c @@ -851,10 +851,6 @@ DefWndHandleWindowPosChanging(HWND hWnd, WINDOWPOS* Pos) return 0; } -/* Undocumented flags. */ -#define SWP_NOCLIENTMOVE 0x0800 -#define SWP_NOCLIENTSIZE 0x1000 - LRESULT DefWndHandleWindowPosChanged(HWND hWnd, WINDOWPOS* Pos) { diff --git a/reactos/dll/win32/user32/windows/draw.c b/reactos/dll/win32/user32/windows/draw.c index 2eb68d11988..c722dc7dbe8 100644 --- a/reactos/dll/win32/user32/windows/draw.c +++ b/reactos/dll/win32/user32/windows/draw.c @@ -37,8 +37,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(user32); /* GLOBALS *******************************************************************/ -#define DSS_DEFAULT 0x0040 /* Make it bold */ - static const WORD wPattern_AA55[8] = { 0xaaaa, 0x5555, 0xaaaa, 0x5555, 0xaaaa, 0x5555, 0xaaaa, 0x5555 }; diff --git a/reactos/include/psdk/wingdi.h b/reactos/include/psdk/wingdi.h index b7bd62b1aae..f67e77ec4e6 100644 --- a/reactos/include/psdk/wingdi.h +++ b/reactos/include/psdk/wingdi.h @@ -69,6 +69,7 @@ extern "C" { #define DI_MASK 1 #define DI_NORMAL 3 #define DI_APPBANDING 1 +#define DI_NOMIRROR 16 #define EMR_HEADER 1 #define EMR_POLYBEZIER 2 #define EMR_POLYGON 3 @@ -184,12 +185,19 @@ extern "C" { #define EMR_SETICMPROFILEW 113 #define EMR_ALPHABLEND 114 #define EMR_ALPHADIBBLEND 115 +#define EMR_SETLAYOUT 115 #define EMR_TRANSPARENTBLT 116 #define EMR_TRANSPARENTDIB 117 +#define EMR_RESERVED_117 117 #define EMR_GRADIENTFILL 118 #define EMR_SETLINKEDUFIS 119 #define EMR_SETTEXTJUSTIFICATION 120 #define EMR_COLORMATCHTOTARGETW 121 +#define EMR_CREATECOLORSPACEW 122 + +#define EMR_MIN 1 +#define EMR_MAX 122 + #endif #define ENHMETA_SIGNATURE 1179469088 #define EPS_SIGNATURE 0x46535045 @@ -265,6 +273,16 @@ extern "C" { #define META_CREATEFONTINDIRECT 0x2FB #define META_CREATEBRUSHINDIRECT 0x2FC #define META_CREATEREGION 0x6FF +#define META_DRAWTEXT 0x062F +#define META_RESETDC 0x014C +#define META_STARTDOC 0x014D +#define META_STARTPAGE 0x004F +#define META_ENDPAGE 0x0050 +#define META_ABORTDOC 0x0052 +#define META_ENDDOC 0x005E +#define META_CREATEBRUSH 0x00F8 +#define META_CREATEBITMAPINDIRECT 0x02FD +#define META_CREATEBITMAP 0x06FE #define PT_MOVETO 6 #define PT_LINETO 2 #define PT_BEZIERTO 4 @@ -379,6 +397,17 @@ extern "C" { #define JOHAB_CHARSET 130 #define VIETNAMESE_CHARSET 163 #define MAC_CHARSET 77 +/* I don't know if the values of *_CHARSET macros are defined in Windows + * or if we can choose them as we want. -- srtxg + */ +#define VISCII_CHARSET (BYTE)240 /* viscii1.1-1 */ +#define TCVN_CHARSET (BYTE)241 /* tcvn-0 */ +#define KOI8_CHARSET (BYTE)242 /* koi8-{r,u,ru} */ +#define ISO3_CHARSET (BYTE)243 /* iso8859-3 */ +#define ISO4_CHARSET (BYTE)244 /* iso8859-4 */ +#define ISO10_CHARSET (BYTE)245 /* iso8859-10 */ +#define CELTIC_CHARSET (BYTE)246 /* iso8859-14 */ + #define OUT_DEFAULT_PRECIS 0 #define OUT_STRING_PRECIS 1 #define OUT_CHARACTER_PRECIS 2 @@ -400,6 +429,8 @@ extern "C" { #define PROOF_QUALITY 2 #define NONANTIALIASED_QUALITY 3 #define ANTIALIASED_QUALITY 4 +#define CLEARTYPE_QUALITY 5 +#define CLEARTYPE_NATURAL_QUALITY 6 #define DEFAULT_PITCH 0 #define FIXED_PITCH 1 #define VARIABLE_PITCH 2 @@ -562,6 +593,7 @@ extern "C" { #define PS_TYPE_MASK 983040 #define ALTERNATE 1 #define WINDING 2 +#define POLYFILL_LAST 2 #define DC_BINNAMES 12 #define DC_BINS 6 #define DC_COPIES 18 @@ -601,6 +633,7 @@ extern "C" { #define DCBA_FACEDOWNRIGHT 259 #define FLOODFILLBORDER 0 #define FLOODFILLSURFACE 1 +#define ETO_GRAYED 0x00001 #define ETO_OPAQUE 0x00002 #define ETO_CLIPPED 0x00004 #if (WINVER >= 0x0400) @@ -811,8 +844,16 @@ extern "C" { #define GGO_GRAY8_BITMAP 6 #define GGO_GLYPH_INDEX 128 #define GGO_UNHINTED 256 +#ifdef __WINESRC__ +#define WINE_GGO_GRAY16_BITMAP 0x10 +#define WINE_GGO_HRGB_BITMAP 0x11 +#define WINE_GGO_HBGR_BITMAP 0x12 +#define WINE_GGO_VRGB_BITMAP 0x13 +#define WINE_GGO_VBGR_BITMAP 0x14 +#endif #define GM_COMPATIBLE 1 #define GM_ADVANCED 2 +#define GM_LAST 2 #define MM_ANISOTROPIC 8 #define MM_HIENGLISH 5 #define MM_HIMETRIC 3 @@ -836,6 +877,12 @@ extern "C" { #define PT_CLOSEFIGURE 1 #define TT_AVAILABLE 1 #define TT_ENABLED 2 + +#ifdef __WINESRC__ +#define WINE_TT_SUBPIXEL_RENDERING_ENABLED 0x4000 +#define WINE_TT_HINTER_ENABLED 0x8000 +#endif + #define BLACK_BRUSH 4 #define DKGRAY_BRUSH 3 #define GRAY_BRUSH 2 @@ -891,6 +938,7 @@ extern "C" { #define MWT_MAX MWT_RIGHTMULTIPLY #define OPAQUE 2 #define TRANSPARENT 1 +#define BKMODE_LAST 2 #define BLACKONWHITE 1 #define WHITEONBLACK 2 #define COLORONCOLOR 3 @@ -1017,6 +1065,7 @@ extern "C" { #define BS_DIBPATTERNPT 6 #define BS_PATTERN8X8 7 #define BS_DIBPATTERN8X8 8 +#define BS_MONOPATTERN 9 #define LCS_CALIBRATED_RGB 0 #define LCS_DEVICE_RGB 1 #define LCS_DEVICE_CMYK 2 @@ -2162,6 +2211,26 @@ typedef struct tagEMRSTRETCHBLT { LONG cxSrc; LONG cySrc; } EMRSTRETCHBLT,*PEMRSTRETCHBLT; +typedef struct tagEMRALPHABLEND { + EMR emr; + RECTL rclBounds; + LONG xDest; + LONG yDest; + LONG cxDest; + LONG cyDest; + DWORD dwRop; + LONG xSrc; + LONG ySrc; + XFORM xformSrc; + COLORREF crBkColorSrc; + DWORD iUsageSrc; + DWORD offBmiSrc; + DWORD cbBmiSrc; + DWORD offBitsSrc; + DWORD cbBitsSrc; + LONG cxSrc; + LONG cySrc; +} EMRALPHABLEND, *PEMRALPHABLEND; typedef struct tagEMRSTRETCHDIBITS { EMR emr; RECTL rclBounds; @@ -2915,12 +2984,17 @@ int WINAPI FillRgn(HDC,HRGN,HBRUSH); BOOL WINAPI FixBrushOrgEx(HDC,int,int,LPPOINT); BOOL WINAPI FlattenPath(HDC); BOOL WINAPI FloodFill(HDC,int,int,COLORREF); +BOOL WINAPI FrameRgn(HDC,HRGN,HBRUSH,INT,INT); BOOL WINAPI GdiAlphaBlend(HDC,int,int,int,int,HDC,int,int,int,int,BLENDFUNCTION); BOOL WINAPI GdiComment(HDC,UINT,const BYTE*); -DEVMODEW* WINAPI GdiConvertToDevmodeW(const DEVMODEA *); +DEVMODEW * WINAPI GdiConvertToDevmodeW(const DEVMODEA *); BOOL WINAPI GdiFlush(void); +LONG WINAPI GdiGetCharDimensions(HDC, LPTEXTMETRICW, LONG *); +DWORD WINAPI GdiGetCodePage(HDC); DWORD WINAPI GdiGetBatchLimit(void); DWORD WINAPI GdiSetBatchLimit(DWORD); +BOOL WINAPI GdiGradientFill(HDC,PTRIVERTEX,ULONG,PVOID,ULONG,ULONG); +BOOL WINAPI GdiIsMetaFileDC(HDC); #define GetCValue(cmyk) ((BYTE)(cmyk)) #define GetMValue(cmyk) ((BYTE)((cmyk)>> 8)) #define GetYValue(cmyk) ((BYTE)((cmyk)>>16)) @@ -3018,7 +3092,7 @@ UINT WINAPI GetSystemPaletteUse(HDC); UINT WINAPI GetTextAlign(HDC); int WINAPI GetTextCharacterExtra(HDC); int WINAPI GetTextCharset(HDC); -int WINAPI GetTextCharsetInfo(HDC,LPFONTSIGNATURE,DWORD); +UINT WINAPI GetTextCharsetInfo(HDC,LPFONTSIGNATURE,DWORD); COLORREF WINAPI GetTextColor(HDC); BOOL WINAPI GetTextExtentExPointA(HDC,LPCSTR,int,int,LPINT,LPINT,LPSIZE); BOOL WINAPI GetTextExtentExPointW( HDC,LPCWSTR,int,int,LPINT,LPINT,LPSIZE ); @@ -3094,7 +3168,7 @@ HGDIOBJ WINAPI SelectObject(HDC,HGDIOBJ); HPALETTE WINAPI SelectPalette(HDC,HPALETTE,BOOL); int WINAPI SetAbortProc(HDC,ABORTPROC); int WINAPI SetArcDirection(HDC,int); -LONG WINAPI SetBitmapBits(HBITMAP,DWORD,PCVOID); +LONG WINAPI SetBitmapBits(HBITMAP,LONG,PCVOID); BOOL WINAPI SetBitmapDimensionEx(HBITMAP,int,int,LPSIZE); COLORREF WINAPI SetBkColor(HDC,COLORREF); int WINAPI SetBkMode(HDC,int); @@ -3130,6 +3204,7 @@ BOOL WINAPI SetPixelFormat(HDC,int,const PIXELFORMATDESCRIPTOR*); BOOL WINAPI SetPixelV(HDC,int,int,COLORREF); int WINAPI SetPolyFillMode(HDC,int); BOOL WINAPI SetRectRgn(HRGN,int,int,int,int); +INT WINAPI SetRelAbs(HDC,INT); int WINAPI SetROP2(HDC,int); int WINAPI SetStretchBltMode(HDC,int); UINT WINAPI SetSystemPaletteUse(HDC,UINT); @@ -3349,6 +3424,22 @@ typedef DISPLAY_DEVICEA DISPLAY_DEVICE, *PDISPLAY_DEVICE, *LPDISPLAY_DEVICE; #endif #endif +#ifdef __WINESRC__ +/* the DC hook support is only exported on Win16, the 32-bit version is a Wine extension */ + +#define DCHC_INVALIDVISRGN 0x0001 +#define DCHC_DELETEDC 0x0002 +#define DCHF_INVALIDATEVISRGN 0x0001 +#define DCHF_VALIDATEVISRGN 0x0002 + +typedef BOOL (CALLBACK *DCHOOKPROC)(HDC,WORD,DWORD_PTR,LPARAM); + +WINGDIAPI DWORD_PTR WINAPI GetDCHook(HDC,DCHOOKPROC*); +WINGDIAPI BOOL WINAPI SetDCHook(HDC,DCHOOKPROC,DWORD_PTR); +WINGDIAPI WORD WINAPI SetHookFlags(HDC,WORD); +WINGDIAPI INT WINAPI SelectVisRgn(HDC,HRGN); +#endif /* __WINESRC__ */ + #ifdef _MSC_VER #pragma warning(pop) #endif diff --git a/reactos/include/psdk/winuser.h b/reactos/include/psdk/winuser.h index 57c1ac13aac..cd855588efe 100644 --- a/reactos/include/psdk/winuser.h +++ b/reactos/include/psdk/winuser.h @@ -299,6 +299,9 @@ extern "C" { #define ES_LOWERCASE 16 #define ES_MULTILINE 4 #define ES_NOHIDESEL 256 +#ifdef _WINE +#define ES_COMBO 0x200 /* Undocumented. Parent is a combobox */ +#endif #define ES_NUMBER 0x2000 #define ES_OEMCONVERT 0x400 #define ES_PASSWORD 32 @@ -386,6 +389,7 @@ extern "C" { #define WS_EX_COMPOSITED 0x2000000 /* XP */ #define WS_EX_CONTEXTHELP 0x400 #define WS_EX_CONTROLPARENT 0x10000 +#define WS_EX_DRAGDETECT 0x00000002L #define WS_EX_DLGMODALFRAME 1 #define WS_EX_LAYERED 0x80000 /* w2k */ #define WS_EX_LAYOUTRTL 0x400000 /* w98, w2k */ @@ -518,6 +522,7 @@ extern "C" { #define DSS_NORMAL 0 #define DSS_UNION 16 #define DSS_DISABLED 32 +#define DSS_DEFAULT 64 #define DSS_MONO 128 #define DSS_HIDEPREFIX 0x0200 #define DSS_PREFIXONLY 0x0400 @@ -864,6 +869,8 @@ extern "C" { #endif #define QS_SENDMESSAGE 64 #define QS_TIMER 16 +/* Extra (undocumented) queue wake bits - see "Undoc. Windows" */ +#define QS_SMRESULT 0x8000 #define USER_TIMER_MAXIMUM 2147483647 #define USER_TIMER_MINIMUM 10 @@ -1135,6 +1142,7 @@ extern "C" { #define MSGF_NEXTWINDOW 6 #define MSGF_MAINLOOP 8 #define MSGF_USER 4096 +#define MSGF_MAX 8 #define MOUSEEVENTF_MOVE 1 #define MOUSEEVENTF_LEFTDOWN 2 #define MOUSEEVENTF_LEFTUP 4 @@ -1142,6 +1150,8 @@ extern "C" { #define MOUSEEVENTF_RIGHTUP 16 #define MOUSEEVENTF_MIDDLEDOWN 32 #define MOUSEEVENTF_MIDDLEUP 64 +#define MOUSEEVENTF_XDOWN 128 +#define MOUSEEVENTF_XUP 256 #define MOUSEEVENTF_WHEEL 0x0800 #define MOUSEEVENTF_ABSOLUTE 32768 #define PM_NOREMOVE 0 @@ -1202,6 +1212,10 @@ extern "C" { #define SWP_NOSENDCHANGING 1024 #define SWP_DEFERERASE 8192 #define SWP_ASYNCWINDOWPOS 16384 +/* undocumented SWP flags - from SDK 3.1 */ +#define SWP_NOCLIENTSIZE 0x0800 +#define SWP_NOCLIENTMOVE 0x1000 +#define SWP_STATECHANGED 0x8000 #define HSHELL_WINDOWCREATED 1 #define HSHELL_WINDOWDESTROYED 2 @@ -1560,6 +1574,9 @@ extern "C" { #define WM_ACTIVATE 6 #define WM_SETFOCUS 7 #define WM_KILLFOCUS 8 +#ifdef _WINE +#define WM_SETVISIBLE 9 +#endif #define WM_ENABLE 10 #define WM_SETREDRAW 11 #define WM_SETTEXT 12 @@ -1599,6 +1616,8 @@ extern "C" { #define WM_GETFONT 49 #define WM_SETHOTKEY 50 #define WM_GETHOTKEY 51 +#define WM_ISACTIVEICON 53 +#define WM_QUERYPARKICON 54 #define WM_QUERYDRAGICON 55 #define WM_COMPAREITEM 57 #if (WINVER >= 0x0500) @@ -1653,6 +1672,7 @@ extern "C" { #define WM_NCXBUTTONDBLCLK 173 #endif /* (_WIN32_WINNT >= 0x0500) */ +#define WM_KEYF1 0x004d #define WM_KEYFIRST 256 #define WM_KEYDOWN 256 #define WM_KEYUP 257 @@ -1686,6 +1706,7 @@ extern "C" { #define WM_VSCROLL 277 #define WM_INITMENU 278 #define WM_INITMENUPOPUP 279 +#define WM_SYSTIMER 280 #define WM_MENUSELECT 287 #define WM_MENUCHAR 288 #define WM_ENTERIDLE 289 @@ -1705,6 +1726,15 @@ extern "C" { #endif /* _WIN32_WCE */ #endif /* (WINVER >= 0x0500) */ +/* D&D messages */ +#define WM_DROPOBJECT 0x022A +#define WM_QUERYDROPOBJECT 0x022B +#define WM_BEGINDRAG 0x022C +#define WM_DRAGLOOP 0x022D +#define WM_DRAGSELECT 0x022E +#define WM_DRAGMOVE 0x022F + +#define WM_CTLCOLOR 25 #define WM_CTLCOLORMSGBOX 306 #define WM_CTLCOLOREDIT 307 #define WM_CTLCOLORLISTBOX 308 @@ -1715,6 +1745,7 @@ extern "C" { #define MN_GETHMENU 481 #define WM_MOUSEFIRST 512 #define WM_MOUSEMOVE 512 +#define WM_LBTRACKPOINT 0x0131 #define WM_LBUTTONDOWN 513 #define WM_LBUTTONUP 514 #define WM_LBUTTONDBLCLK 515 @@ -1803,6 +1834,7 @@ extern "C" { #define WM_HOTKEY 786 #define WM_PRINT 791 #define WM_PRINTCLIENT 792 +#define WM_APPCOMMAND 793 #define WM_DWMCOMPOSITIONCHANGED 0x031E #define WM_DWMNCRENDERINGCHANGED 0x031F @@ -1819,6 +1851,8 @@ extern "C" { #define WM_APP 32768 #define WM_GETTITLEBARINFOEX 0x033F +#define XBUTTON1 0x0001 +#define XBUTTON2 0x0002 #if (_WIN32_WINNT >= 0x0400) #define WHEEL_DELTA 120 @@ -1882,6 +1916,7 @@ extern "C" { #define CB_SETLOCALE 345 #define CB_SETTOPINDEX 348 #define CB_SHOWDROPDOWN 335 +#define CB_MSGMAX 357 #define CBN_CLOSEUP 8 #define CBN_DBLCLK 2 #define CBN_DROPDOWN 7 @@ -1943,6 +1978,7 @@ extern "C" { #define LB_ADDFILE 406 #define LB_ADDSTRING 384 #ifdef _WINE +#define LB_CARETON 419 #define LB_CARETOFF 420 #endif #define LB_DELETESTRING 386 @@ -2190,6 +2226,7 @@ extern "C" { #define VK_F24 0x87 #define VK_NUMLOCK 0x90 #define VK_SCROLL 0x91 +#define VK_OEM_NEC_EQUAL 0x92 #define VK_LSHIFT 0xA0 #define VK_RSHIFT 0xA1 #define VK_LCONTROL 0xA2 @@ -3815,13 +3852,14 @@ HDC WINAPI BeginPaint(HWND,LPPAINTSTRUCT); BOOL WINAPI BringWindowToTop(HWND); long WINAPI BroadcastSystemMessage(DWORD,LPDWORD,UINT,WPARAM,LPARAM); #if (_WIN32_WINNT >= 0x0400) -long WINAPI BroadcastSystemMessageA(DWORD,LPDWORD,UINT,WPARAM,LPARAM); -long WINAPI BroadcastSystemMessageW(DWORD,LPDWORD,UINT,WPARAM,LPARAM); +LONG WINAPI BroadcastSystemMessageA(DWORD,LPDWORD,UINT,WPARAM,LPARAM); +LONG WINAPI BroadcastSystemMessageW(DWORD,LPDWORD,UINT,WPARAM,LPARAM); #endif /* (_WIN32_WINNT >= 0x0400) */ #if (_WIN32_WINNT >= 0x0501) -long WINAPI BroadcastSystemMessageExA(DWORD,LPDWORD,UINT,WPARAM,LPARAM,PBSMINFO); -long WINAPI BroadcastSystemMessageExW(DWORD,LPDWORD,UINT,WPARAM,LPARAM,PBSMINFO); +LONG WINAPI BroadcastSystemMessageExA(DWORD,LPDWORD,UINT,WPARAM,LPARAM,PBSMINFO); +LONG WINAPI BroadcastSystemMessageExW(DWORD,LPDWORD,UINT,WPARAM,LPARAM,PBSMINFO); #endif /* (_WIN32_WINNT >= 0x0501) */ +void WINAPI CalcChildScroll(HWND, INT); BOOL WINAPI CallMsgFilterA(LPMSG,INT); BOOL WINAPI CallMsgFilterW(LPMSG,INT); LRESULT WINAPI CallNextHookEx(HHOOK,int,WPARAM,LPARAM); @@ -3905,8 +3943,8 @@ HMENU WINAPI CreatePopupMenu(void); HWND WINAPI CreateWindowExA(DWORD,LPCSTR,LPCSTR,DWORD,int,int,int,int,HWND,HMENU,HINSTANCE,LPVOID); HWND WINAPI CreateWindowExW(DWORD,LPCWSTR,LPCWSTR,DWORD,int,int,int,int,HWND,HMENU,HINSTANCE,LPVOID); #ifndef NOWINDOWSTATION -HWINSTA WINAPI CreateWindowStationA(LPSTR,DWORD,DWORD,LPSECURITY_ATTRIBUTES); -HWINSTA WINAPI CreateWindowStationW(LPWSTR,DWORD,DWORD,LPSECURITY_ATTRIBUTES); +HWINSTA WINAPI CreateWindowStationA(LPCSTR,DWORD,ACCESS_MASK,LPSECURITY_ATTRIBUTES); +HWINSTA WINAPI CreateWindowStationW(LPCWSTR,DWORD,ACCESS_MASK,LPSECURITY_ATTRIBUTES); #endif LRESULT WINAPI DefDlgProcA(HWND,UINT,WPARAM,LPARAM); LRESULT WINAPI DefDlgProcW(HWND,UINT,WPARAM,LPARAM); @@ -4051,7 +4089,7 @@ BOOL WINAPI GetCursorPos(LPPOINT); HDC WINAPI GetDC(HWND); HDC WINAPI GetDCEx(HWND,HRGN,DWORD); HWND WINAPI GetDesktopWindow(void); -long WINAPI GetDialogBaseUnits(void); +LONG WINAPI GetDialogBaseUnits(void); int WINAPI GetDlgCtrlID(HWND); HWND WINAPI GetDlgItem(HWND,int); UINT WINAPI GetDlgItemInt(HWND,int,PBOOL,BOOL); @@ -4227,6 +4265,7 @@ BOOL WINAPI IsWinEventHookInstalled(DWORD); BOOL WINAPI IsZoomed(HWND); VOID WINAPI keybd_event(BYTE,BYTE,DWORD,ULONG_PTR); BOOL WINAPI KillTimer(HWND,UINT_PTR); +BOOL WINAPI KillSystemTimer(HWND,UINT_PTR); HACCEL WINAPI LoadAcceleratorsA(HINSTANCE,LPCSTR); HACCEL WINAPI LoadAcceleratorsW(HINSTANCE,LPCWSTR); HBITMAP WINAPI LoadBitmapA(HINSTANCE,LPCSTR); @@ -4286,12 +4325,12 @@ BOOL WINAPI OemToCharBuffW(LPCSTR,LPWSTR,DWORD); BOOL WINAPI OemToCharW(LPCSTR,LPWSTR); BOOL WINAPI OffsetRect(LPRECT,int,int); BOOL WINAPI OpenClipboard(HWND); -HDESK WINAPI OpenDesktopA(LPSTR,DWORD,BOOL,DWORD); -HDESK WINAPI OpenDesktopW(LPWSTR,DWORD,BOOL,DWORD); +HDESK WINAPI OpenDesktopA(LPCSTR,DWORD,BOOL,DWORD); +HDESK WINAPI OpenDesktopW(LPCWSTR,DWORD,BOOL,DWORD); BOOL WINAPI OpenIcon(HWND); HDESK WINAPI OpenInputDesktop(DWORD,BOOL,DWORD); -HWINSTA WINAPI OpenWindowStationA(LPSTR,BOOL,DWORD); -HWINSTA WINAPI OpenWindowStationW(LPWSTR,BOOL,DWORD); +HWINSTA WINAPI OpenWindowStationA(LPCSTR,BOOL,DWORD); +HWINSTA WINAPI OpenWindowStationW(LPCWSTR,BOOL,DWORD); BOOL WINAPI PaintDesktop(HDC); BOOL WINAPI PeekMessageA(LPMSG,HWND,UINT,UINT,UINT); BOOL WINAPI PeekMessageW(LPMSG,HWND,UINT,UINT,UINT); @@ -4337,6 +4376,7 @@ HANDLE WINAPI RemovePropA(HWND,LPCSTR); HANDLE WINAPI RemovePropW(HWND,LPCWSTR); BOOL WINAPI ReplyMessage(LRESULT); BOOL WINAPI ScreenToClient(HWND,LPPOINT); +VOID WINAPI ScrollChildren(HWND,UINT,WPARAM,LPARAM); BOOL WINAPI ScrollDC(HDC,int,int,LPCRECT,LPCRECT,HRGN,LPRECT); BOOL WINAPI ScrollWindow(HWND,int,int,LPCRECT,LPCRECT); int WINAPI ScrollWindowEx(HWND,int,int,LPCRECT,LPCRECT,HRGN,LPRECT,UINT); @@ -4372,6 +4412,7 @@ HWND WINAPI SetClipboardViewer(HWND); HCURSOR WINAPI SetCursor(HCURSOR); BOOL WINAPI SetCursorPos(int,int); VOID WINAPI SetDebugErrorLevel(DWORD); +BOOL WINAPI SetDeskWallPaper(LPCSTR); BOOL WINAPI SetDlgItemInt(HWND,int,UINT,BOOL); BOOL WINAPI SetDlgItemTextA(HWND,int,LPCSTR); BOOL WINAPI SetDlgItemTextW(HWND,int,LPCWSTR); @@ -4404,8 +4445,10 @@ BOOL WINAPI SetSysColors(int,const INT *,const COLORREF *); DWORD WINAPI SetSysColorsTemp(const COLORREF *, const HBRUSH *, DWORD); #define SetSysModalWindow(h) (NULL) BOOL WINAPI SetSystemCursor(HCURSOR,DWORD); +BOOL WINAPI SetSystemMenu(HWND,HMENU); BOOL WINAPI SetThreadDesktop(HDESK); UINT_PTR WINAPI SetTimer(HWND,UINT_PTR,UINT,TIMERPROC); +UINT_PTR WINAPI SetSystemTimer(HWND,UINT_PTR,UINT,TIMERPROC); BOOL WINAPI SetUserObjectInformationA(HANDLE,int,PVOID,DWORD); BOOL WINAPI SetUserObjectInformationW(HANDLE,int,PVOID,DWORD); BOOL WINAPI SetUserObjectSecurity(HANDLE,PSECURITY_INFORMATION,PSECURITY_DESCRIPTOR); diff --git a/reactos/subsystems/win32/win32k/include/timer.h b/reactos/subsystems/win32/win32k/include/timer.h index 73b2c36afae..2b65b0e55d8 100644 --- a/reactos/subsystems/win32/win32k/include/timer.h +++ b/reactos/subsystems/win32/win32k/include/timer.h @@ -32,7 +32,7 @@ UINT_PTR FASTCALL IntSetTimer(HWND Wnd, UINT_PTR IDEvent, UINT Elapse, TIMERPROC PTIMER FASTCALL FindSystemTimer(PMSG); BOOL FASTCALL ValidateTimerCallback(PTHREADINFO,PWINDOW_OBJECT,WPARAM,LPARAM); VOID CALLBACK SystemTimerProc(HWND,UINT,UINT_PTR,DWORD); -UINT_PTR FASTCALL SetSystemTimer(PWINDOW_OBJECT,UINT_PTR,UINT,TIMERPROC); +UINT_PTR FASTCALL SystemTimerSet(PWINDOW_OBJECT,UINT_PTR,UINT,TIMERPROC); BOOL FASTCALL PostTimerMessages(PWINDOW_OBJECT); VOID FASTCALL ProcessTimers(VOID); VOID FASTCALL StartTheTimers(VOID); diff --git a/reactos/subsystems/win32/win32k/include/winpos.h b/reactos/subsystems/win32/win32k/include/winpos.h index 47f6b389cec..9bb6cfffaba 100644 --- a/reactos/subsystems/win32/win32k/include/winpos.h +++ b/reactos/subsystems/win32/win32k/include/winpos.h @@ -1,9 +1,5 @@ #pragma once -/* Undocumented flags. */ -#define SWP_NOCLIENTMOVE 0x0800 -#define SWP_NOCLIENTSIZE 0x1000 - #define IntPtInWindow(WndObject,x,y) \ ((x) >= (WndObject)->Wnd->rcWindow.left && \ (x) < (WndObject)->Wnd->rcWindow.right && \ diff --git a/reactos/subsystems/win32/win32k/ntuser/timer.c b/reactos/subsystems/win32/win32k/ntuser/timer.c index b65a2ebfb61..c706805a9c8 100644 --- a/reactos/subsystems/win32/win32k/ntuser/timer.c +++ b/reactos/subsystems/win32/win32k/ntuser/timer.c @@ -253,7 +253,7 @@ StartTheTimers(VOID) UINT_PTR FASTCALL -SetSystemTimer( PWINDOW_OBJECT Window, +SystemTimerSet( PWINDOW_OBJECT Window, UINT_PTR nIDEvent, UINT uElapse, TIMERPROC lpTimerFunc) From 973ecf7e61b59e44e304403c3f475ddeec275a9b Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sun, 28 Mar 2010 19:02:07 +0000 Subject: [PATCH 045/134] [NTOSKRNL] - Add a missing OBJ_CASE_INSENSITIVE attribute so IopIsAcpiComputer doesn't always fail svn path=/trunk/; revision=46517 --- reactos/ntoskrnl/io/pnpmgr/pnpmgr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c b/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c index cd0859b261b..0871047c33a 100644 --- a/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c +++ b/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c @@ -2629,7 +2629,7 @@ IopIsAcpiComputer(VOID) NTSTATUS Status; BOOLEAN ret = FALSE; - InitializeObjectAttributes(&ObjectAttributes, &MultiKeyPathU, OBJ_KERNEL_HANDLE, NULL, NULL); + InitializeObjectAttributes(&ObjectAttributes, &MultiKeyPathU, OBJ_KERNEL_HANDLE | OBJ_CASE_INSENSITIVE, NULL, NULL); Status = ZwOpenKey(&hDevicesKey, KEY_ENUMERATE_SUB_KEYS, &ObjectAttributes); if (!NT_SUCCESS(Status)) { From 6b4dc6c7db65eaa8a0d5dd1a6a4f6adb077e950f Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Sun, 28 Mar 2010 19:06:48 +0000 Subject: [PATCH 046/134] [KSPROXY, MSDVBNP, MSVIDCTL, BDAPLGIN] - Implement DllRegisterServer, DllUnregisterServer for those components - Add msdvbnp, msvidctl to build - Add msdvbnp, bdaplgin, msvidctl to bootcd svn path=/trunk/; revision=46518 --- reactos/baseaddress.rbuild | 2 + reactos/boot/bootdata/packages/reactos.dff | 3 + reactos/dll/directx/bdaplgin/bdaplgin.cpp | 56 ++++++++++++++++++- reactos/dll/directx/directx.rbuild | 6 ++ reactos/dll/directx/ksproxy/ksproxy.cpp | 56 ++++++++++++++++++- reactos/dll/directx/msdvbnp/msdvbnp.cpp | 56 ++++++++++++++++++- reactos/dll/directx/msdvbnp/scanningtuner.cpp | 2 +- reactos/dll/directx/msvidctl/msvidctl.cpp | 56 ++++++++++++++++++- 8 files changed, 228 insertions(+), 9 deletions(-) diff --git a/reactos/baseaddress.rbuild b/reactos/baseaddress.rbuild index 80401c1db46..58a65efc7bc 100644 --- a/reactos/baseaddress.rbuild +++ b/reactos/baseaddress.rbuild @@ -24,6 +24,7 @@ + @@ -32,6 +33,7 @@ + diff --git a/reactos/boot/bootdata/packages/reactos.dff b/reactos/boot/bootdata/packages/reactos.dff index a58e5c1c6c2..f16a96ed4ce 100644 --- a/reactos/boot/bootdata/packages/reactos.dff +++ b/reactos/boot/bootdata/packages/reactos.dff @@ -151,6 +151,7 @@ dll\cpl\timedate\timedate.cpl 1 ;dll\cpl\usrmgr\usrmgr.cpl 1 dll\directx\amstream\amstream.dll 1 +dll\directx\bdaplgin\bdaplgin.ax 1 dll\directx\dinput\dinput.dll 1 dll\directx\dinput8\dinput8.dll 1 dll\directx\dmusic\dmusic.dll 1 @@ -164,6 +165,8 @@ dll\directx\devenum\devenum.dll 1 dll\directx\ksproxy\ksproxy.ax 1 dll\directx\ksuser\ksuser.dll 1 dll\directx\msdmo\msdmo.dll 1 +dll\directx\msdvbnp\msdvbnp.ax 1 +dll\directx\msvidctl\msvidctl.dll 1 dll\directx\quartz\quartz.dll 1 dll\directx\qedit\qedit.dll 1 dll\directx\wine\d3d8\d3d8.dll 1 diff --git a/reactos/dll/directx/bdaplgin/bdaplgin.cpp b/reactos/dll/directx/bdaplgin/bdaplgin.cpp index 39ddb8a2ccb..bc15f3110e9 100644 --- a/reactos/dll/directx/bdaplgin/bdaplgin.cpp +++ b/reactos/dll/directx/bdaplgin/bdaplgin.cpp @@ -52,7 +52,27 @@ HRESULT WINAPI DllUnregisterServer(void) { - return S_OK; + ULONG Index = 0; + LPOLESTR pStr; + HRESULT hr = S_OK; + HKEY hClass; + + if (RegOpenKeyExW(HKEY_CLASSES_ROOT, L"CLSID", 0, KEY_SET_VALUE, &hClass) != ERROR_SUCCESS) + return E_FAIL; + + do + { + hr = StringFromCLSID(*InterfaceTable[Index].riid, &pStr); + if (FAILED(hr)) + break; + + RegDeleteKeyW(hClass, pStr); + CoTaskMemFree(pStr); + Index++; + }while(InterfaceTable[Index].lpfnCI != 0); + + RegCloseKey(hClass); + return hr; } extern "C" @@ -61,7 +81,39 @@ HRESULT WINAPI DllRegisterServer(void) { - return S_OK; + ULONG Index = 0; + LPOLESTR pStr; + HRESULT hr = S_OK; + HKEY hClass, hKey, hSubKey; + static LPCWSTR ModuleName = L"bdaplgin.ax"; + static LPCWSTR ThreadingModel = L"Both"; + + if (RegOpenKeyExW(HKEY_CLASSES_ROOT, L"CLSID", 0, KEY_WRITE, &hClass) != ERROR_SUCCESS) + return E_FAIL; + + do + { + hr = StringFromCLSID(*InterfaceTable[Index].riid, &pStr); + if (FAILED(hr)) + break; + + if (RegCreateKeyExW(hClass, pStr, 0, 0, 0, KEY_WRITE, NULL, &hKey, 0) == ERROR_SUCCESS) + { + if (RegCreateKeyExW(hKey, L"InprocServer32", 0, 0, 0, KEY_WRITE, NULL, &hSubKey, 0) == ERROR_SUCCESS) + { + RegSetValueExW(hSubKey, 0, 0, REG_SZ, (const BYTE*)ModuleName, (wcslen(ModuleName) + 1) * sizeof(WCHAR)); + RegSetValueExW(hSubKey, L"ThreadingModel", 0, REG_SZ, (const BYTE*)ThreadingModel, (wcslen(ThreadingModel) + 1) * sizeof(WCHAR)); + RegCloseKey(hSubKey); + } + RegCloseKey(hKey); + } + + CoTaskMemFree(pStr); + Index++; + }while(InterfaceTable[Index].lpfnCI != 0); + + RegCloseKey(hClass); + return hr; } KSDDKAPI diff --git a/reactos/dll/directx/directx.rbuild b/reactos/dll/directx/directx.rbuild index 78508ecc99f..d953456790b 100644 --- a/reactos/dll/directx/directx.rbuild +++ b/reactos/dll/directx/directx.rbuild @@ -43,6 +43,12 @@ + + + + + + diff --git a/reactos/dll/directx/ksproxy/ksproxy.cpp b/reactos/dll/directx/ksproxy/ksproxy.cpp index f1e17c96922..7baa7e30496 100644 --- a/reactos/dll/directx/ksproxy/ksproxy.cpp +++ b/reactos/dll/directx/ksproxy/ksproxy.cpp @@ -343,7 +343,27 @@ HRESULT WINAPI DllUnregisterServer(void) { - return S_OK; + ULONG Index = 0; + LPOLESTR pStr; + HRESULT hr = S_OK; + HKEY hClass; + + if (RegOpenKeyExW(HKEY_CLASSES_ROOT, L"CLSID", 0, KEY_SET_VALUE, &hClass) != ERROR_SUCCESS) + return E_FAIL; + + do + { + hr = StringFromCLSID(*InterfaceTable[Index].riid, &pStr); + if (FAILED(hr)) + break; + + RegDeleteKeyW(hClass, pStr); + CoTaskMemFree(pStr); + Index++; + }while(InterfaceTable[Index].lpfnCI != 0); + + RegCloseKey(hClass); + return hr; } extern "C" @@ -352,7 +372,39 @@ HRESULT WINAPI DllRegisterServer(void) { - return S_OK; + ULONG Index = 0; + LPOLESTR pStr; + HRESULT hr = S_OK; + HKEY hClass, hKey, hSubKey; + static LPCWSTR ModuleName = L"ksproxy.ax"; + static LPCWSTR ThreadingModel = L"Both"; + + if (RegOpenKeyExW(HKEY_CLASSES_ROOT, L"CLSID", 0, KEY_WRITE, &hClass) != ERROR_SUCCESS) + return E_FAIL; + + do + { + hr = StringFromCLSID(*InterfaceTable[Index].riid, &pStr); + if (FAILED(hr)) + break; + + if (RegCreateKeyExW(hClass, pStr, 0, 0, 0, KEY_WRITE, NULL, &hKey, 0) == ERROR_SUCCESS) + { + if (RegCreateKeyExW(hKey, L"InprocServer32", 0, 0, 0, KEY_WRITE, NULL, &hSubKey, 0) == ERROR_SUCCESS) + { + RegSetValueExW(hSubKey, 0, 0, REG_SZ, (const BYTE*)ModuleName, (wcslen(ModuleName) + 1) * sizeof(WCHAR)); + RegSetValueExW(hSubKey, L"ThreadingModel", 0, REG_SZ, (const BYTE*)ThreadingModel, (wcslen(ThreadingModel) + 1) * sizeof(WCHAR)); + RegCloseKey(hSubKey); + } + RegCloseKey(hKey); + } + + CoTaskMemFree(pStr); + Index++; + }while(InterfaceTable[Index].lpfnCI != 0); + + RegCloseKey(hClass); + return hr; } KSDDKAPI diff --git a/reactos/dll/directx/msdvbnp/msdvbnp.cpp b/reactos/dll/directx/msdvbnp/msdvbnp.cpp index 2b80a7717bc..2da8108bdcf 100644 --- a/reactos/dll/directx/msdvbnp/msdvbnp.cpp +++ b/reactos/dll/directx/msdvbnp/msdvbnp.cpp @@ -48,7 +48,27 @@ HRESULT WINAPI DllUnregisterServer(void) { - return S_OK; + ULONG Index = 0; + LPOLESTR pStr; + HRESULT hr = S_OK; + HKEY hClass; + + if (RegOpenKeyExW(HKEY_CLASSES_ROOT, L"CLSID", 0, KEY_SET_VALUE, &hClass) != ERROR_SUCCESS) + return E_FAIL; + + do + { + hr = StringFromCLSID(*InterfaceTable[Index].riid, &pStr); + if (FAILED(hr)) + break; + + RegDeleteKeyW(hClass, pStr); + CoTaskMemFree(pStr); + Index++; + }while(InterfaceTable[Index].lpfnCI != 0); + + RegCloseKey(hClass); + return hr; } extern "C" @@ -57,7 +77,39 @@ HRESULT WINAPI DllRegisterServer(void) { - return S_OK; + ULONG Index = 0; + LPOLESTR pStr; + HRESULT hr = S_OK; + HKEY hClass, hKey, hSubKey; + static LPCWSTR ModuleName = L"msdvbnp.ax"; + static LPCWSTR ThreadingModel = L"Both"; + + if (RegOpenKeyExW(HKEY_CLASSES_ROOT, L"CLSID", 0, KEY_WRITE, &hClass) != ERROR_SUCCESS) + return E_FAIL; + + do + { + hr = StringFromCLSID(*InterfaceTable[Index].riid, &pStr); + if (FAILED(hr)) + break; + + if (RegCreateKeyExW(hClass, pStr, 0, 0, 0, KEY_WRITE, NULL, &hKey, 0) == ERROR_SUCCESS) + { + if (RegCreateKeyExW(hKey, L"InprocServer32", 0, 0, 0, KEY_WRITE, NULL, &hSubKey, 0) == ERROR_SUCCESS) + { + RegSetValueExW(hSubKey, 0, 0, REG_SZ, (const BYTE*)ModuleName, (wcslen(ModuleName) + 1) * sizeof(WCHAR)); + RegSetValueExW(hSubKey, L"ThreadingModel", 0, REG_SZ, (const BYTE*)ThreadingModel, (wcslen(ThreadingModel) + 1) * sizeof(WCHAR)); + RegCloseKey(hSubKey); + } + RegCloseKey(hKey); + } + + CoTaskMemFree(pStr); + Index++; + }while(InterfaceTable[Index].lpfnCI != 0); + + RegCloseKey(hClass); + return hr; } KSDDKAPI diff --git a/reactos/dll/directx/msdvbnp/scanningtuner.cpp b/reactos/dll/directx/msdvbnp/scanningtuner.cpp index 76665f66a28..8c2d90ef1c4 100644 --- a/reactos/dll/directx/msdvbnp/scanningtuner.cpp +++ b/reactos/dll/directx/msdvbnp/scanningtuner.cpp @@ -287,7 +287,7 @@ CScanningTunner::performDVBTTune( IDVBTuneRequest * pDVBTRequest, IDVBTLocator *pDVBTLocator) { - HRESULT hr; + HRESULT hr = S_OK; ULONG Index; IBDA_Topology *pTopo; IUnknown *pNode; diff --git a/reactos/dll/directx/msvidctl/msvidctl.cpp b/reactos/dll/directx/msvidctl/msvidctl.cpp index b086e59d580..57d6ada3882 100644 --- a/reactos/dll/directx/msvidctl/msvidctl.cpp +++ b/reactos/dll/directx/msvidctl/msvidctl.cpp @@ -48,7 +48,27 @@ HRESULT WINAPI DllUnregisterServer(void) { - return S_OK; + ULONG Index = 0; + LPOLESTR pStr; + HRESULT hr = S_OK; + HKEY hClass; + + if (RegOpenKeyExW(HKEY_CLASSES_ROOT, L"CLSID", 0, KEY_SET_VALUE, &hClass) != ERROR_SUCCESS) + return E_FAIL; + + do + { + hr = StringFromCLSID(*InterfaceTable[Index].riid, &pStr); + if (FAILED(hr)) + break; + + RegDeleteKeyW(hClass, pStr); + CoTaskMemFree(pStr); + Index++; + }while(InterfaceTable[Index].lpfnCI != 0); + + RegCloseKey(hClass); + return hr; } extern "C" @@ -57,7 +77,39 @@ HRESULT WINAPI DllRegisterServer(void) { - return S_OK; + ULONG Index = 0; + LPOLESTR pStr; + HRESULT hr = S_OK; + HKEY hClass, hKey, hSubKey; + static LPCWSTR ModuleName = L"msvidctl.ax"; + static LPCWSTR ThreadingModel = L"Both"; + + if (RegOpenKeyExW(HKEY_CLASSES_ROOT, L"CLSID", 0, KEY_WRITE, &hClass) != ERROR_SUCCESS) + return E_FAIL; + + do + { + hr = StringFromCLSID(*InterfaceTable[Index].riid, &pStr); + if (FAILED(hr)) + break; + + if (RegCreateKeyExW(hClass, pStr, 0, 0, 0, KEY_WRITE, NULL, &hKey, 0) == ERROR_SUCCESS) + { + if (RegCreateKeyExW(hKey, L"InprocServer32", 0, 0, 0, KEY_WRITE, NULL, &hSubKey, 0) == ERROR_SUCCESS) + { + RegSetValueExW(hSubKey, 0, 0, REG_SZ, (const BYTE*)ModuleName, (wcslen(ModuleName) + 1) * sizeof(WCHAR)); + RegSetValueExW(hSubKey, L"ThreadingModel", 0, REG_SZ, (const BYTE*)ThreadingModel, (wcslen(ThreadingModel) + 1) * sizeof(WCHAR)); + RegCloseKey(hSubKey); + } + RegCloseKey(hKey); + } + + CoTaskMemFree(pStr); + Index++; + }while(InterfaceTable[Index].lpfnCI != 0); + + RegCloseKey(hClass); + return hr; } KSDDKAPI From a81b14171e48b67ed31d306f490a315cb37df0a0 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sun, 28 Mar 2010 19:22:28 +0000 Subject: [PATCH 047/134] [NTOSKRNL] - Revert part of r46495 and replace it with much better code svn path=/trunk/; revision=46519 --- reactos/ntoskrnl/io/pnpmgr/pnpmgr.c | 47 +++++++++++------------------ 1 file changed, 17 insertions(+), 30 deletions(-) diff --git a/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c b/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c index 0871047c33a..3b9fbab482c 100644 --- a/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c +++ b/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c @@ -2180,10 +2180,10 @@ IopEnumerateDetectedDevices( const UNICODE_STRING IdentifierMouse = RTL_CONSTANT_STRING(L"PointerController"); UNICODE_STRING HardwareIdMouse = RTL_CONSTANT_STRING(L"*PNP0F13\0"); static ULONG DeviceIndexMouse = 0; - const UNICODE_STRING IdentifierParallel = RTL_CONSTANT_STRING(L"PARALLEL"); + const UNICODE_STRING IdentifierParallel = RTL_CONSTANT_STRING(L"ParallelController"); UNICODE_STRING HardwareIdParallel = RTL_CONSTANT_STRING(L"*PNP0400\0"); static ULONG DeviceIndexParallel = 0; - const UNICODE_STRING IdentifierFloppy = RTL_CONSTANT_STRING(L"FLOPPY"); + const UNICODE_STRING IdentifierFloppy = RTL_CONSTANT_STRING(L"FloppyDiskPeripheral"); UNICODE_STRING HardwareIdFloppy = RTL_CONSTANT_STRING(L"*PNP0700\0"); static ULONG DeviceIndexFloppy = 0; const UNICODE_STRING IdentifierIsa = RTL_CONSTANT_STRING(L"ISA"); @@ -2433,6 +2433,18 @@ IopEnumerateDetectedDevices( DeviceIndex = DeviceIndexMouse++; IsDeviceDesc = FALSE; } + else if (RelativePath && RtlCompareUnicodeString(RelativePath, &IdentifierParallel, FALSE) == 0) + { + pHardwareId = &HardwareIdParallel; + DeviceIndex = DeviceIndexParallel++; + IsDeviceDesc = FALSE; + } + else if (RelativePath && RtlCompareUnicodeString(RelativePath, &IdentifierFloppy, FALSE) == 0) + { + pHardwareId = &HardwareIdFloppy; + DeviceIndex = DeviceIndexFloppy++; + IsDeviceDesc = FALSE; + } else if (NT_SUCCESS(Status)) { /* Try to also match the device identifier */ @@ -2456,35 +2468,10 @@ IopEnumerateDetectedDevices( IsDeviceDesc = FALSE; } #endif - else /* Now let's detect devices with a device number at the end */ + else { - /* First, we remove the number */ - ValueName.Length -= sizeof(WCHAR); - - /* Let's see if it is a floppy device */ - if (RtlCompareUnicodeString(&ValueName, &IdentifierFloppy, FALSE) == 0) - { - pHardwareId = &HardwareIdFloppy; - DeviceIndex = DeviceIndexFloppy++; - IsDeviceDesc = FALSE; - } - /* Nope, is it a parallel port? */ - else if (RtlCompareUnicodeString(&ValueName, &IdentifierParallel, FALSE) == 0) - { - pHardwareId = &HardwareIdParallel; - DeviceIndex = DeviceIndexParallel++; - IsDeviceDesc = FALSE; - } - /* Nope, out of ideas so let's skip this one */ - else - { - ValueName.Length += sizeof(WCHAR); - DPRINT("Unknown device '%wZ'\n", &ValueName); - goto nextdevice; - } - - /* Add the number back */ - ValueName.Length += sizeof(WCHAR); + DPRINT("Unknown device '%wZ'\n", &ValueName); + goto nextdevice; } } else From ccc4a57c6f4f945dd177e2fd44e297a5353c0321 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sun, 28 Mar 2010 19:25:40 +0000 Subject: [PATCH 048/134] update asm.h from trunk svn path=/branches/ros-amd64-bringup/; revision=46520 --- reactos/include/reactos/asm.h | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/reactos/include/reactos/asm.h b/reactos/include/reactos/asm.h index 6df3821ec86..30afca482a0 100644 --- a/reactos/include/reactos/asm.h +++ b/reactos/include/reactos/asm.h @@ -6,11 +6,14 @@ * PROGRAMMERS: Timo Kreuzer (timo.kreuzer@reactos.org) */ -#ifdef _MSC_VER +#ifdef _USE_ML /* Allow ".name" identifiers */ OPTION DOTNAME +.586 +.MODEL FLAT + /* Hex numbers need to be in 01ABh format */ #define HEX(x) 0##x##h @@ -48,7 +51,11 @@ ENDM ENDM .code64 MACRO - .code + .code +ENDM + +.code32 MACRO + .code ENDM UNIMPLEMENTED MACRO name @@ -108,6 +115,13 @@ ENDM /* MASM needs an END tag */ #define END +.macro .MODEL model +.endm + +.macro .code + .text +.endm + /* Macros for x64 stack unwind OPs */ .macro .allocstack size @@ -171,5 +185,6 @@ code = 1 #define if .if #define endif .endif #define else .else +#define elseif .elseif #endif From c2fb167d36f0fd775cbfe02a7f619f7d2aaa1730 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sun, 28 Mar 2010 19:30:58 +0000 Subject: [PATCH 049/134] [SCSIPORT] DDKAPI -> NTAPI svn path=/branches/ros-amd64-bringup/; revision=46521 --- reactos/drivers/storage/scsiport/stubs.c | 54 +++++++++++------------- 1 file changed, 25 insertions(+), 29 deletions(-) diff --git a/reactos/drivers/storage/scsiport/stubs.c b/reactos/drivers/storage/scsiport/stubs.c index 9e286d186f4..478c35b4d08 100644 --- a/reactos/drivers/storage/scsiport/stubs.c +++ b/reactos/drivers/storage/scsiport/stubs.c @@ -14,12 +14,8 @@ #define NDEBUG #include -#ifdef _MSC_VER - #define DDKAPI -#endif - SCSI_PHYSICAL_ADDRESS -DDKAPI +NTAPI ScsiPortConvertUlongToPhysicalAddress( IN ULONG UlongAddress) { @@ -27,7 +23,7 @@ ScsiPortConvertUlongToPhysicalAddress( } VOID -DDKAPI +NTAPI ScsiPortReadPortBufferUchar( IN PUCHAR Port, IN PUCHAR Buffer, @@ -37,7 +33,7 @@ ScsiPortReadPortBufferUchar( } VOID -DDKAPI +NTAPI ScsiPortReadPortBufferUshort( IN PUSHORT Port, IN PUSHORT Buffer, @@ -47,7 +43,7 @@ ScsiPortReadPortBufferUshort( } VOID -DDKAPI +NTAPI ScsiPortReadPortBufferUlong( IN PULONG Port, IN PULONG Buffer, @@ -57,7 +53,7 @@ ScsiPortReadPortBufferUlong( } UCHAR -DDKAPI +NTAPI ScsiPortReadPortUchar( IN PUCHAR Port) { @@ -65,7 +61,7 @@ ScsiPortReadPortUchar( } USHORT -DDKAPI +NTAPI ScsiPortReadPortUshort( IN PUSHORT Port) { @@ -73,7 +69,7 @@ ScsiPortReadPortUshort( } ULONG -DDKAPI +NTAPI ScsiPortReadPortUlong( IN PULONG Port) { @@ -81,7 +77,7 @@ ScsiPortReadPortUlong( } VOID -DDKAPI +NTAPI ScsiPortReadRegisterBufferUchar( IN PUCHAR Register, IN PUCHAR Buffer, @@ -91,7 +87,7 @@ ScsiPortReadRegisterBufferUchar( } VOID -DDKAPI +NTAPI ScsiPortReadRegisterBufferUshort( IN PUSHORT Register, IN PUSHORT Buffer, @@ -101,7 +97,7 @@ ScsiPortReadRegisterBufferUshort( } VOID -DDKAPI +NTAPI ScsiPortReadRegisterBufferUlong( IN PULONG Register, IN PULONG Buffer, @@ -111,7 +107,7 @@ ScsiPortReadRegisterBufferUlong( } UCHAR -DDKAPI +NTAPI ScsiPortReadRegisterUchar( IN PUCHAR Register) { @@ -119,7 +115,7 @@ ScsiPortReadRegisterUchar( } USHORT -DDKAPI +NTAPI ScsiPortReadRegisterUshort( IN PUSHORT Register) { @@ -127,7 +123,7 @@ ScsiPortReadRegisterUshort( } ULONG -DDKAPI +NTAPI ScsiPortReadRegisterUlong( IN PULONG Register) { @@ -135,7 +131,7 @@ ScsiPortReadRegisterUlong( } VOID -DDKAPI +NTAPI ScsiPortWritePortBufferUchar( IN PUCHAR Port, IN PUCHAR Buffer, @@ -145,7 +141,7 @@ ScsiPortWritePortBufferUchar( } VOID -DDKAPI +NTAPI ScsiPortWritePortBufferUshort( IN PUSHORT Port, IN PUSHORT Buffer, @@ -155,7 +151,7 @@ ScsiPortWritePortBufferUshort( } VOID -DDKAPI +NTAPI ScsiPortWritePortBufferUlong( IN PULONG Port, IN PULONG Buffer, @@ -165,7 +161,7 @@ ScsiPortWritePortBufferUlong( } VOID -DDKAPI +NTAPI ScsiPortWritePortUchar( IN PUCHAR Port, IN UCHAR Value) @@ -174,7 +170,7 @@ ScsiPortWritePortUchar( } VOID -DDKAPI +NTAPI ScsiPortWritePortUshort( IN PUSHORT Port, IN USHORT Value) @@ -183,7 +179,7 @@ ScsiPortWritePortUshort( } VOID -DDKAPI +NTAPI ScsiPortWritePortUlong( IN PULONG Port, IN ULONG Value) @@ -192,7 +188,7 @@ ScsiPortWritePortUlong( } VOID -DDKAPI +NTAPI ScsiPortWriteRegisterBufferUchar( IN PUCHAR Register, IN PUCHAR Buffer, @@ -202,7 +198,7 @@ ScsiPortWriteRegisterBufferUchar( } VOID -DDKAPI +NTAPI ScsiPortWriteRegisterBufferUshort( IN PUSHORT Register, IN PUSHORT Buffer, @@ -212,7 +208,7 @@ ScsiPortWriteRegisterBufferUshort( } VOID -DDKAPI +NTAPI ScsiPortWriteRegisterBufferUlong( IN PULONG Register, IN PULONG Buffer, @@ -222,7 +218,7 @@ ScsiPortWriteRegisterBufferUlong( } VOID -DDKAPI +NTAPI ScsiPortWriteRegisterUchar( IN PUCHAR Register, IN ULONG Value) @@ -231,7 +227,7 @@ ScsiPortWriteRegisterUchar( } VOID -DDKAPI +NTAPI ScsiPortWriteRegisterUshort( IN PUSHORT Register, IN USHORT Value) @@ -240,7 +236,7 @@ ScsiPortWriteRegisterUshort( } VOID -DDKAPI +NTAPI ScsiPortWriteRegisterUlong( IN PULONG Register, IN ULONG Value) From 9b445221d82ed7635005e50b2c7d21a7a45d2adb Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sun, 28 Mar 2010 19:46:29 +0000 Subject: [PATCH 050/134] Fix 32bit RtlInitializeSListHead svn path=/branches/ros-amd64-bringup/; revision=46522 --- reactos/lib/rtl/slist.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/reactos/lib/rtl/slist.c b/reactos/lib/rtl/slist.c index 8260a38eb82..7a115bf1f9a 100644 --- a/reactos/lib/rtl/slist.c +++ b/reactos/lib/rtl/slist.c @@ -30,11 +30,12 @@ RtlInitializeSListHead( { RtlRaiseStatus(STATUS_DATATYPE_MISALIGNMENT); } + + SListHead->Region = 0; #endif /* Zero it */ SListHead->Alignment = 0; - SListHead->Region = 0; #if defined(_IA64_) FeatureBits = __getReg(CV_IA64_CPUID4); From 7558e99439ae07fa6ea5ea28a37a2fac3a203d18 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sun, 28 Mar 2010 19:56:11 +0000 Subject: [PATCH 051/134] - Fix assert macro - Add crt="MSVC" to a number of modules to resolve _assert svn path=/branches/ros-amd64-bringup/; revision=46523 --- reactos/dll/directx/qedit/qedit.rbuild | 2 +- reactos/dll/directx/quartz/quartz.rbuild | 2 +- reactos/dll/directx/wine/ddraw/ddraw.rbuild | 2 +- reactos/dll/win32/avifil32/avifil32.rbuild | 2 +- reactos/dll/win32/comctl32/comctl32.rbuild | 2 +- reactos/dll/win32/comdlg32/comdlg32.rbuild | 2 +- reactos/dll/win32/imaadp32.acm/imaadp32.acm.rbuild | 2 +- reactos/dll/win32/inetmib1/inetmib1.rbuild | 2 +- reactos/dll/win32/mciwave/mciwave.rbuild | 2 +- reactos/dll/win32/msacm32/msacm32.rbuild | 2 +- reactos/dll/win32/msadp32.acm/msadp32.acm.rbuild | 2 +- reactos/dll/win32/msg711.acm/msg711.acm.rbuild | 2 +- reactos/dll/win32/msrle32/msrle32.rbuild | 2 +- reactos/dll/win32/odbccp32/odbccp32.rbuild | 2 +- reactos/dll/win32/ole32/ole32.rbuild | 2 +- reactos/dll/win32/riched20/riched20.rbuild | 2 +- reactos/dll/win32/winemp3.acm/winemp3.acm.rbuild | 2 +- reactos/dll/win32/wintrust/wintrust.rbuild | 2 +- reactos/include/crt/assert.h | 3 +-- 19 files changed, 19 insertions(+), 20 deletions(-) diff --git a/reactos/dll/directx/qedit/qedit.rbuild b/reactos/dll/directx/qedit/qedit.rbuild index f3285f4ef48..0fd54bf8ea3 100644 --- a/reactos/dll/directx/qedit/qedit.rbuild +++ b/reactos/dll/directx/qedit/qedit.rbuild @@ -1,4 +1,4 @@ - + . diff --git a/reactos/dll/directx/quartz/quartz.rbuild b/reactos/dll/directx/quartz/quartz.rbuild index b7097f6ff1f..4a86c54b112 100644 --- a/reactos/dll/directx/quartz/quartz.rbuild +++ b/reactos/dll/directx/quartz/quartz.rbuild @@ -1,7 +1,7 @@ - + . diff --git a/reactos/dll/directx/wine/ddraw/ddraw.rbuild b/reactos/dll/directx/wine/ddraw/ddraw.rbuild index f8d9c92c279..962cd7a96ad 100644 --- a/reactos/dll/directx/wine/ddraw/ddraw.rbuild +++ b/reactos/dll/directx/wine/ddraw/ddraw.rbuild @@ -1,6 +1,6 @@ - + . diff --git a/reactos/dll/win32/avifil32/avifil32.rbuild b/reactos/dll/win32/avifil32/avifil32.rbuild index 1741f2a481d..da4f495711d 100644 --- a/reactos/dll/win32/avifil32/avifil32.rbuild +++ b/reactos/dll/win32/avifil32/avifil32.rbuild @@ -1,7 +1,7 @@ - + . diff --git a/reactos/dll/win32/comctl32/comctl32.rbuild b/reactos/dll/win32/comctl32/comctl32.rbuild index 460df46a789..3f8d1e231fd 100644 --- a/reactos/dll/win32/comctl32/comctl32.rbuild +++ b/reactos/dll/win32/comctl32/comctl32.rbuild @@ -1,7 +1,7 @@ - + . diff --git a/reactos/dll/win32/comdlg32/comdlg32.rbuild b/reactos/dll/win32/comdlg32/comdlg32.rbuild index d9ea84d9e28..70c0322000f 100644 --- a/reactos/dll/win32/comdlg32/comdlg32.rbuild +++ b/reactos/dll/win32/comdlg32/comdlg32.rbuild @@ -1,7 +1,7 @@ - + . include/reactos/wine diff --git a/reactos/dll/win32/imaadp32.acm/imaadp32.acm.rbuild b/reactos/dll/win32/imaadp32.acm/imaadp32.acm.rbuild index f2b04bb6914..073f714f979 100644 --- a/reactos/dll/win32/imaadp32.acm/imaadp32.acm.rbuild +++ b/reactos/dll/win32/imaadp32.acm/imaadp32.acm.rbuild @@ -1,4 +1,4 @@ - + . include/reactos/wine diff --git a/reactos/dll/win32/inetmib1/inetmib1.rbuild b/reactos/dll/win32/inetmib1/inetmib1.rbuild index 77c39b582a1..27079b19c05 100644 --- a/reactos/dll/win32/inetmib1/inetmib1.rbuild +++ b/reactos/dll/win32/inetmib1/inetmib1.rbuild @@ -1,7 +1,7 @@ - + . include/reactos/wine diff --git a/reactos/dll/win32/mciwave/mciwave.rbuild b/reactos/dll/win32/mciwave/mciwave.rbuild index be21c0711ed..69e3c094388 100644 --- a/reactos/dll/win32/mciwave/mciwave.rbuild +++ b/reactos/dll/win32/mciwave/mciwave.rbuild @@ -1,4 +1,4 @@ - + . include/reactos/wine diff --git a/reactos/dll/win32/msacm32/msacm32.rbuild b/reactos/dll/win32/msacm32/msacm32.rbuild index df9cb0340ef..562225819e3 100644 --- a/reactos/dll/win32/msacm32/msacm32.rbuild +++ b/reactos/dll/win32/msacm32/msacm32.rbuild @@ -1,7 +1,7 @@ - + . include/reactos/wine diff --git a/reactos/dll/win32/msadp32.acm/msadp32.acm.rbuild b/reactos/dll/win32/msadp32.acm/msadp32.acm.rbuild index 89911f484c5..3dcc1c96085 100644 --- a/reactos/dll/win32/msadp32.acm/msadp32.acm.rbuild +++ b/reactos/dll/win32/msadp32.acm/msadp32.acm.rbuild @@ -1,4 +1,4 @@ - + . include/reactos/wine diff --git a/reactos/dll/win32/msg711.acm/msg711.acm.rbuild b/reactos/dll/win32/msg711.acm/msg711.acm.rbuild index 468d9927b2f..88e87f98add 100644 --- a/reactos/dll/win32/msg711.acm/msg711.acm.rbuild +++ b/reactos/dll/win32/msg711.acm/msg711.acm.rbuild @@ -1,4 +1,4 @@ - + . include/reactos/wine diff --git a/reactos/dll/win32/msrle32/msrle32.rbuild b/reactos/dll/win32/msrle32/msrle32.rbuild index 6ef26447334..2b8a6ca4dc6 100644 --- a/reactos/dll/win32/msrle32/msrle32.rbuild +++ b/reactos/dll/win32/msrle32/msrle32.rbuild @@ -1,4 +1,4 @@ - + . include/reactos/wine diff --git a/reactos/dll/win32/odbccp32/odbccp32.rbuild b/reactos/dll/win32/odbccp32/odbccp32.rbuild index 253485a359e..15bb8d84bb4 100644 --- a/reactos/dll/win32/odbccp32/odbccp32.rbuild +++ b/reactos/dll/win32/odbccp32/odbccp32.rbuild @@ -1,7 +1,7 @@ - + . include/reactos/wine diff --git a/reactos/dll/win32/ole32/ole32.rbuild b/reactos/dll/win32/ole32/ole32.rbuild index 24f60c87a32..02d91d71a01 100644 --- a/reactos/dll/win32/ole32/ole32.rbuild +++ b/reactos/dll/win32/ole32/ole32.rbuild @@ -1,7 +1,7 @@ - + . diff --git a/reactos/dll/win32/riched20/riched20.rbuild b/reactos/dll/win32/riched20/riched20.rbuild index 0191c64390a..b176049bb8a 100644 --- a/reactos/dll/win32/riched20/riched20.rbuild +++ b/reactos/dll/win32/riched20/riched20.rbuild @@ -1,7 +1,7 @@ - + . include/reactos/wine diff --git a/reactos/dll/win32/winemp3.acm/winemp3.acm.rbuild b/reactos/dll/win32/winemp3.acm/winemp3.acm.rbuild index fec518725e0..be4a53bc8eb 100644 --- a/reactos/dll/win32/winemp3.acm/winemp3.acm.rbuild +++ b/reactos/dll/win32/winemp3.acm/winemp3.acm.rbuild @@ -1,4 +1,4 @@ - + . include/reactos/wine diff --git a/reactos/dll/win32/wintrust/wintrust.rbuild b/reactos/dll/win32/wintrust/wintrust.rbuild index 910d2278f8e..bcb1c2b8304 100644 --- a/reactos/dll/win32/wintrust/wintrust.rbuild +++ b/reactos/dll/win32/wintrust/wintrust.rbuild @@ -1,4 +1,4 @@ - + . diff --git a/reactos/include/crt/assert.h b/reactos/include/crt/assert.h index 252fd54a269..9107ee5a272 100644 --- a/reactos/include/crt/assert.h +++ b/reactos/include/crt/assert.h @@ -28,8 +28,7 @@ extern "C" { #endif #ifndef assert -//#define assert(_Expression) (void)((!!(_Expression)) || (_assert(#_Expression,__FILE__,__LINE__),0)) -#define assert(_Expression) (void)((!!(_Expression)))// || (_wassert(_CRT_WIDE(#_Expression),_CRT_WIDE(__FILE__),__LINE__),0)) +#define assert(_Expression) (void)((!!(_Expression)) || (_assert(#_Expression,__FILE__,__LINE__),0)) #endif #ifndef wassert From 0e76e9857cef06116f234cae251ea2bba459dbf7 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sun, 28 Mar 2010 20:11:55 +0000 Subject: [PATCH 052/134] [LIBOLDNAMES] - add snprintf svn path=/branches/ros-amd64-bringup/; revision=46524 --- reactos/lib/3rdparty/mingw/moldname-msvcrt.def | 1 + 1 file changed, 1 insertion(+) diff --git a/reactos/lib/3rdparty/mingw/moldname-msvcrt.def b/reactos/lib/3rdparty/mingw/moldname-msvcrt.def index 70b92ed77a2..af6661fada4 100644 --- a/reactos/lib/3rdparty/mingw/moldname-msvcrt.def +++ b/reactos/lib/3rdparty/mingw/moldname-msvcrt.def @@ -61,6 +61,7 @@ rmdir==_rmdir rmtmp==_rmtmp searchenv==_searchenv setmode==_setmode +snprintf=_snprintf sopen==_sopen spawnl==_spawnl spawnle==_spawnle From 12f66ee7b9e5ceda764187c36ed339bfb8417459 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sun, 28 Mar 2010 20:23:30 +0000 Subject: [PATCH 053/134] [NTOSKRNL] - Don't use REG_OPTION_VOLATILE because it causes ACPI to be reinstalled after every boot svn path=/trunk/; revision=46525 --- reactos/ntoskrnl/io/pnpmgr/pnpmgr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c b/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c index 3b9fbab482c..546c1d16140 100644 --- a/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c +++ b/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c @@ -2771,12 +2771,12 @@ IopUpdateRootKey(VOID) if (IopIsAcpiComputer()) { InitializeObjectAttributes(&ObjectAttributes, &HalAcpiDevice, OBJ_KERNEL_HANDLE | OBJ_CASE_INSENSITIVE, hRoot, NULL); - Status = ZwCreateKey(&hHalAcpiDevice, KEY_CREATE_SUB_KEY, &ObjectAttributes, 0, NULL, REG_OPTION_VOLATILE, NULL); + Status = ZwCreateKey(&hHalAcpiDevice, KEY_CREATE_SUB_KEY, &ObjectAttributes, 0, NULL, 0, NULL); ZwClose(hRoot); if (!NT_SUCCESS(Status)) return Status; InitializeObjectAttributes(&ObjectAttributes, &HalAcpiId, OBJ_KERNEL_HANDLE | OBJ_CASE_INSENSITIVE, hHalAcpiDevice, NULL); - Status = ZwCreateKey(&hHalAcpiId, KEY_CREATE_SUB_KEY, &ObjectAttributes, 0, NULL, REG_OPTION_VOLATILE, NULL); + Status = ZwCreateKey(&hHalAcpiId, KEY_CREATE_SUB_KEY, &ObjectAttributes, 0, NULL, 0, NULL); ZwClose(hHalAcpiDevice); if (!NT_SUCCESS(Status)) return Status; From 3479ab1925e92f8afc096838676341dd37f675cd Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sun, 28 Mar 2010 21:01:25 +0000 Subject: [PATCH 054/134] [FTP/DHCP] - remove the oldnames hack, as we now have a proper oldnames lib (included in mingw_common) - protect struct timezone from redefinition svn path=/branches/ros-amd64-bringup/; revision=46526 --- reactos/base/applications/network/ftp/fake.h | 9 ++++++--- reactos/base/applications/network/ftp/ftp.rbuild | 11 ----------- reactos/base/services/dhcp/dhcp.rbuild | 7 ------- 3 files changed, 6 insertions(+), 21 deletions(-) diff --git a/reactos/base/applications/network/ftp/fake.h b/reactos/base/applications/network/ftp/fake.h index f622c401970..a22009886bd 100644 --- a/reactos/base/applications/network/ftp/fake.h +++ b/reactos/base/applications/network/ftp/fake.h @@ -9,9 +9,12 @@ #define strcasecmp _stricmp #define strncasecmp _strnicmp +#ifndef _TIMEZONE_DEFINED /* also in sys/time.h */ +#define _TIMEZONE_DEFINED struct timezone { - int tz_minuteswest; /* minutes W of Greenwich */ - int tz_dsttime; /* type of dst correction */ + int tz_minuteswest; + int tz_dsttime; }; -int gettimeofday(struct timeval *tv, struct timezone *tz); + extern int __cdecl gettimeofday (struct timeval *p, struct timezone *z); +#endif diff --git a/reactos/base/applications/network/ftp/ftp.rbuild b/reactos/base/applications/network/ftp/ftp.rbuild index 193fa6e8ebd..d7794dc986a 100644 --- a/reactos/base/applications/network/ftp/ftp.rbuild +++ b/reactos/base/applications/network/ftp/ftp.rbuild @@ -4,17 +4,6 @@ . - - _chdir - _getcwd - _mktemp - _unlink - _close - _fileno - _read - _write - _lseek - ws2_32 iphlpapi cmds.c diff --git a/reactos/base/services/dhcp/dhcp.rbuild b/reactos/base/services/dhcp/dhcp.rbuild index 85e5147d834..93a31dcd613 100644 --- a/reactos/base/services/dhcp/dhcp.rbuild +++ b/reactos/base/services/dhcp/dhcp.rbuild @@ -4,13 +4,6 @@ . include - - _tzset - _close - _read - _write - 1 - ntdll ws2_32 iphlpapi From 7aab8a308bca5b4f0ac36df0f5da9dd825969c31 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sun, 28 Mar 2010 22:50:04 +0000 Subject: [PATCH 055/134] [HAL] Update from trunk svn path=/branches/ros-amd64-bringup/; revision=46531 --- reactos/hal/halx86/mp/halinit_mp.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/reactos/hal/halx86/mp/halinit_mp.c b/reactos/hal/halx86/mp/halinit_mp.c index ff385393f1e..e8d80e54af5 100644 --- a/reactos/hal/halx86/mp/halinit_mp.c +++ b/reactos/hal/halx86/mp/halinit_mp.c @@ -22,6 +22,11 @@ ULONG_PTR KernelBase; /***************************************************************************/ +VOID NTAPI HalpInitializePICs(IN BOOLEAN EnableInterrupts) +{ + UNIMPLEMENTED; +} + VOID HalpInitPhase0(PLOADER_PARAMETER_BLOCK LoaderBlock) From 6f805c852be7cf7e08c4e8b5d2296da159b2fd93 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sun, 28 Mar 2010 22:51:39 +0000 Subject: [PATCH 056/134] [NTOS] Some freelist.c fixes, to make it compile svn path=/branches/ros-amd64-bringup/; revision=46532 --- reactos/ntoskrnl/mm/freelist.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/reactos/ntoskrnl/mm/freelist.c b/reactos/ntoskrnl/mm/freelist.c index 8eaecc46c6e..9551e1840be 100644 --- a/reactos/ntoskrnl/mm/freelist.c +++ b/reactos/ntoskrnl/mm/freelist.c @@ -56,6 +56,7 @@ typedef union C_ASSERT(sizeof(PHYSICAL_PAGE) == sizeof(MMPFN)); +#define MiInsertInListTail(x, y) MiInsertInListTail(x, (PMMPFN)y) //#define MiGetPfnEntry(Pfn) ((PPHYSICAL_PAGE)MiGetPfnEntry(Pfn)) #define MiGetPfnEntryIndex(x) MiGetPfnEntryIndex((struct _MMPFN*)x) #define LockCount Flags.LockCount @@ -797,7 +798,7 @@ MmReferencePage(PFN_NUMBER Pfn) return; } - Page = MiGetPfnEntry(Pfn); + Page = (PVOID)MiGetPfnEntry(Pfn); ASSERT(Page); Page->u3.e2.ReferenceCount++; @@ -814,7 +815,7 @@ MmGetReferenceCountPage(PFN_NUMBER Pfn) DPRINT("MmGetReferenceCountPage(PhysicalAddress %x)\n", Pfn << PAGE_SHIFT); oldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock); - Page = MiGetPfnEntry(Pfn); + Page = (PVOID)MiGetPfnEntry(Pfn); ASSERT(Page); RCount = Page->u3.e2.ReferenceCount; @@ -846,7 +847,7 @@ MmDereferencePage(PFN_NUMBER Pfn) DPRINT("MmDereferencePage(PhysicalAddress %x)\n", Pfn << PAGE_SHIFT); - Page = MiGetPfnEntry(Pfn); + Page = (PVOID)MiGetPfnEntry(Pfn); ASSERT(Page); Page->u3.e2.ReferenceCount--; @@ -885,13 +886,13 @@ MmAllocPage(ULONG Type) DPRINT1("MmAllocPage(): Out of memory\n"); return 0; } - PageDescriptor = MiRemoveHeadList(&MmFreePageListHead); + PageDescriptor = (PVOID)MiRemoveHeadList(&MmFreePageListHead); NeedClear = TRUE; } else { - PageDescriptor = MiRemoveHeadList(&MmZeroedPageListHead); + PageDescriptor = (PVOID)MiRemoveHeadList(&MmZeroedPageListHead); } PageDescriptor->u3.e2.ReferenceCount = 1; @@ -961,7 +962,7 @@ MmZeroPageThreadMain(PVOID Ignored) oldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock); while (MmFreePageListHead.Total) { - PageDescriptor = MiRemoveHeadList(&MmFreePageListHead); + PageDescriptor = (PVOID)MiRemoveHeadList(&MmFreePageListHead); /* We set the page to used, because MmCreateVirtualMapping failed with unused pages */ KeReleaseQueuedSpinLock(LockQueuePfnLock, oldIrql); Pfn = PageDescriptor - MmPfnDatabase[0]; From 3bb7bcab0931f996f81bc85342a49e6cc18f404f Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sun, 28 Mar 2010 22:59:38 +0000 Subject: [PATCH 057/134] [NTOSKRNL] - Fix a nasty bug that discarded any response to IRP_MN_FILTER_RESOURCE_REQUIREMENTS so drivers never got the resources they needed svn path=/trunk/; revision=46533 --- reactos/ntoskrnl/io/pnpmgr/pnpmgr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c b/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c index 546c1d16140..71cfde10cab 100644 --- a/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c +++ b/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c @@ -150,7 +150,7 @@ IopStartDevice( DPRINT("IopInitiatePnpIrp(IRP_MN_FILTER_RESOURCE_REQUIREMENTS) failed\n"); return Status; } - DeviceNode->ResourceRequirements = Stack.Parameters.FilterResourceRequirements.IoResourceRequirementList; + DeviceNode->ResourceRequirements = (PIO_RESOURCE_REQUIREMENTS_LIST)IoStatusBlock.Information; Status = IopAssignDeviceResources(DeviceNode, &RequiredLength); if (NT_SUCCESS(Status)) From 173013b4d41fb524c45a4858c77f90b1ba4735cf Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sun, 28 Mar 2010 23:06:36 +0000 Subject: [PATCH 058/134] [CRT] - Set crt="static" in freeldr, rtl, bmfs, ftfd, rtl, mini_hal - define "CRTDLL" in ntdll, crtdll, msvcrt, msvcrt20, msvcrt40 svn path=/branches/ros-amd64-bringup/; revision=46534 --- reactos/boot/freeldr/freeldr/freeldr_arch.rbuild | 2 +- reactos/boot/freeldr/freeldr/freeldr_base.rbuild | 2 +- reactos/boot/freeldr/freeldr/freeldr_main.rbuild | 2 +- reactos/boot/freeldr/freeldr/setupldr_main.rbuild | 2 +- reactos/dll/ntdll/ntdll.rbuild | 1 + reactos/dll/win32/crtdll/crtdll.rbuild | 1 + reactos/dll/win32/msvcrt/msvcrt.rbuild | 1 + reactos/dll/win32/msvcrt20/msvcrt20.rbuild | 1 + reactos/dll/win32/msvcrt40/msvcrt40.rbuild | 1 + reactos/hal/halx86/hal_generic.rbuild | 4 ++-- reactos/lib/rtl/rtl.rbuild | 2 +- 11 files changed, 12 insertions(+), 7 deletions(-) diff --git a/reactos/boot/freeldr/freeldr/freeldr_arch.rbuild b/reactos/boot/freeldr/freeldr/freeldr_arch.rbuild index 05ca7b327f1..2b8a8b288ab 100644 --- a/reactos/boot/freeldr/freeldr/freeldr_arch.rbuild +++ b/reactos/boot/freeldr/freeldr/freeldr_arch.rbuild @@ -1,6 +1,6 @@ - + include cache include diff --git a/reactos/boot/freeldr/freeldr/freeldr_base.rbuild b/reactos/boot/freeldr/freeldr/freeldr_base.rbuild index 8edcd8ef4d0..c8c2ab113c1 100644 --- a/reactos/boot/freeldr/freeldr/freeldr_base.rbuild +++ b/reactos/boot/freeldr/freeldr/freeldr_base.rbuild @@ -1,6 +1,6 @@ - + include cache . diff --git a/reactos/boot/freeldr/freeldr/freeldr_main.rbuild b/reactos/boot/freeldr/freeldr/freeldr_main.rbuild index fbb410e86a4..f45ef931fdc 100644 --- a/reactos/boot/freeldr/freeldr/freeldr_main.rbuild +++ b/reactos/boot/freeldr/freeldr/freeldr_main.rbuild @@ -1,6 +1,6 @@ - + include include diff --git a/reactos/boot/freeldr/freeldr/setupldr_main.rbuild b/reactos/boot/freeldr/freeldr/setupldr_main.rbuild index c89e46ba0c5..ec99ca9c962 100644 --- a/reactos/boot/freeldr/freeldr/setupldr_main.rbuild +++ b/reactos/boot/freeldr/freeldr/setupldr_main.rbuild @@ -1,6 +1,6 @@ - + include include diff --git a/reactos/dll/ntdll/ntdll.rbuild b/reactos/dll/ntdll/ntdll.rbuild index 8f2c72609f5..0a09528d93f 100644 --- a/reactos/dll/ntdll/ntdll.rbuild +++ b/reactos/dll/ntdll/ntdll.rbuild @@ -12,6 +12,7 @@ include/reactos/subsys + rtl ntdllsys libcntpr diff --git a/reactos/dll/win32/crtdll/crtdll.rbuild b/reactos/dll/win32/crtdll/crtdll.rbuild index 047b966c2c0..9df85785956 100644 --- a/reactos/dll/win32/crtdll/crtdll.rbuild +++ b/reactos/dll/win32/crtdll/crtdll.rbuild @@ -5,6 +5,7 @@ + diff --git a/reactos/dll/win32/msvcrt/msvcrt.rbuild b/reactos/dll/win32/msvcrt/msvcrt.rbuild index 3e4a5d93f2a..b448c21676e 100644 --- a/reactos/dll/win32/msvcrt/msvcrt.rbuild +++ b/reactos/dll/win32/msvcrt/msvcrt.rbuild @@ -8,6 +8,7 @@ + -enable-stdcall-fixup + + include/reactos/mingw-w64 @@ -18,19 +22,18 @@ CRT_glob.c crt_handler.c dllentry.c - dummy_mingwthrd.c gccmain.c - getopt.c gs_support.c merr.c mingw_helpers.c - mingwthrd_nomt.c natstart.c pesect.c pseudo-reloc.c pseudo-reloc-list.c + tlsmcrt.c tlssup.c + tlsthrd.c txtmode.c wildcard.c xncommod.c diff --git a/reactos/lib/3rdparty/mingw/mingw_custom.c b/reactos/lib/3rdparty/mingw/mingw_custom.c index 280eab9b1c8..59201987ceb 100644 --- a/reactos/lib/3rdparty/mingw/mingw_custom.c +++ b/reactos/lib/3rdparty/mingw/mingw_custom.c @@ -1,7 +1,7 @@ /** * This file has no copyright assigned and is placed in the Public Domain. * This file is part of the w64 mingw-runtime package. - * No warranty is given; refer to the file DISCLAIMER within this package. + * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ #include <_mingw.h> diff --git a/reactos/lib/3rdparty/mingw/mingw_helpers.c b/reactos/lib/3rdparty/mingw/mingw_helpers.c index 72103dca437..b1bafd35653 100644 --- a/reactos/lib/3rdparty/mingw/mingw_helpers.c +++ b/reactos/lib/3rdparty/mingw/mingw_helpers.c @@ -1,7 +1,7 @@ /** * This file has no copyright assigned and is placed in the Public Domain. * This file is part of the w64 mingw-runtime package. - * No warranty is given; refer to the file DISCLAIMER within this package. + * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ #include diff --git a/reactos/lib/3rdparty/mingw/mingwthrd_nomt.c b/reactos/lib/3rdparty/mingw/mingwthrd_nomt.c deleted file mode 100644 index 7df31f67969..00000000000 --- a/reactos/lib/3rdparty/mingw/mingwthrd_nomt.c +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN -#endif -#include -#include - -/* We support TLS cleanup code in any case. If shared version of libgcc is used _CRT_MT has value 1, otherwise - we do tls cleanup in runtime and _CRT_MT has value 2. */ -int _CRT_MT = 2; - -int __mingwthr_key_dtor (DWORD key, void (*dtor)(void *)); -int __mingwthr_remove_key_dtor (DWORD key); - -extern int ___w64_mingwthr_remove_key_dtor (DWORD key); -extern int ___w64_mingwthr_add_key_dtor (DWORD key, void (*dtor)(void *)); - -int -__mingwthr_remove_key_dtor (DWORD key) -{ - return ___w64_mingwthr_remove_key_dtor (key); -} - -int -__mingwthr_key_dtor (DWORD key, void (*dtor)(void *)) -{ - if (dtor) - return ___w64_mingwthr_add_key_dtor (key, dtor); - - return 0; -} diff --git a/reactos/lib/3rdparty/mingw/natstart.c b/reactos/lib/3rdparty/mingw/natstart.c index dfea54e4a36..1122d19f3de 100644 --- a/reactos/lib/3rdparty/mingw/natstart.c +++ b/reactos/lib/3rdparty/mingw/natstart.c @@ -1,7 +1,7 @@ /** * This file has no copyright assigned and is placed in the Public Domain. * This file is part of the w64 mingw-runtime package. - * No warranty is given; refer to the file DISCLAIMER within this package. + * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ #include diff --git a/reactos/lib/3rdparty/mingw/pesect.c b/reactos/lib/3rdparty/mingw/pesect.c index c51a6d2522d..60bbbc4c0d0 100644 --- a/reactos/lib/3rdparty/mingw/pesect.c +++ b/reactos/lib/3rdparty/mingw/pesect.c @@ -1,15 +1,24 @@ /** * This file has no copyright assigned and is placed in the Public Domain. * This file is part of the w64 mingw-runtime package. - * No warranty is given; refer to the file DISCLAIMER within this package. + * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ #include #include -BOOL _ValidateImageBase (PBYTE); +#if defined (_WIN64) && defined (__ia64__) +#error FIXME: Unsupported __ImageBase implementation. +#else +/* Hack, for bug in ld. Will be removed soon. */ +#define __ImageBase __MINGW_LSYMBOL(_image_base__) +/* This symbol is defined by the linker. */ +extern IMAGE_DOS_HEADER __ImageBase; +#endif -BOOL +WINBOOL _ValidateImageBase (PBYTE); + +WINBOOL _ValidateImageBase (PBYTE pImageBase) { PIMAGE_DOS_HEADER pDOSHeader; @@ -122,9 +131,9 @@ _GetPEImageBase (void) return pImageBase; } -BOOL _IsNonwritableInCurrentImage (PBYTE); +WINBOOL _IsNonwritableInCurrentImage (PBYTE); -BOOL +WINBOOL _IsNonwritableInCurrentImage (PBYTE pTarget) { PBYTE pImageBase; diff --git a/reactos/lib/3rdparty/mingw/pseudo-reloc-list.c b/reactos/lib/3rdparty/mingw/pseudo-reloc-list.c index b723bb8cb97..4ce46bbb29b 100644 --- a/reactos/lib/3rdparty/mingw/pseudo-reloc-list.c +++ b/reactos/lib/3rdparty/mingw/pseudo-reloc-list.c @@ -1,7 +1,7 @@ /** * This file has no copyright assigned and is placed in the Public Domain. * This file is part of the w64 mingw-runtime package. - * No warranty is given; refer to the file DISCLAIMER within this package. + * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ char __RUNTIME_PSEUDO_RELOC_LIST_END__ = 0; diff --git a/reactos/lib/3rdparty/mingw/pseudo-reloc.c b/reactos/lib/3rdparty/mingw/pseudo-reloc.c index ea0ea8a49c3..77f041114d7 100644 --- a/reactos/lib/3rdparty/mingw/pseudo-reloc.c +++ b/reactos/lib/3rdparty/mingw/pseudo-reloc.c @@ -1,27 +1,71 @@ -/** - * This file has no copyright assigned and is placed in the Public Domain. - * This file is part of the w64 mingw-runtime package. - * No warranty is given; refer to the file DISCLAIMER within this package. - * - * Contributed by Egor Duda - * Modified by addition of runtime_pseudo_reloc version 2 - * by Kai Tietz - */ +/* pseudo-reloc.c + + Contributed by Egor Duda + Modified by addition of runtime_pseudo_reloc version 2 + by Kai Tietz + + THIS SOFTWARE IS NOT COPYRIGHTED + + This source code is offered for use in the public domain. You may + use, modify or distribute it freely. + + This code is distributed in the hope that it will be useful but + WITHOUT ANY WARRANTY. ALL WARRENTIES, EXPRESS OR IMPLIED ARE HEREBY + DISCLAMED. This includes but is not limited to warrenties of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +*/ #include #include #include +#include #include -#include + +#if defined(__CYGWIN__) +#include +#include +#include +/* copied from winsup.h */ +# define NO_COPY __attribute__((nocommon)) __attribute__((section(".data_cygwin_nocopy"))) +/* custom status code: */ +#define STATUS_ILLEGAL_DLL_PSEUDO_RELOCATION ((NTSTATUS) 0xe0000269) +#define SHORT_MSG_BUF_SZ 128 +#else +# define NO_COPY +#endif + +#ifdef __GNUC__ +#define ATTRIBUTE_NORETURN __attribute__ ((noreturn)) +#else +#define ATTRIBUTE_NORETURN +#endif + +#ifndef __MINGW_LSYMBOL +#define __MINGW_LSYMBOL(sym) sym +#endif extern char __RUNTIME_PSEUDO_RELOC_LIST__; extern char __RUNTIME_PSEUDO_RELOC_LIST_END__; +extern char __MINGW_LSYMBOL(_image_base__); +void _pei386_runtime_relocator (void); + +/* v1 relocation is basically: + * *(base + .target) += .addend + * where (base + .target) is always assumed to point + * to a DWORD (4 bytes). + */ typedef struct { DWORD addend; DWORD target; } runtime_pseudo_reloc_item_v1; +/* v2 relocation is more complex. In effect, it is + * *(base + .target) += *(base + .sym) - (base + .sym) + * with care taken in both reading, sign extension, and writing + * because .flags may indicate that (base + .target) may point + * to a BYTE, WORD, DWORD, or QWORD (w64). + */ typedef struct { DWORD sym; DWORD target; @@ -29,24 +73,123 @@ typedef struct { } runtime_pseudo_reloc_item_v2; typedef struct { - DWORD magic1; - DWORD magic2; - DWORD version; + DWORD magic1; + DWORD magic2; + DWORD version; } runtime_pseudo_reloc_v2; +static void ATTRIBUTE_NORETURN +__report_error (const char *msg, ...) +{ +#ifdef __CYGWIN__ + /* This function is used to print short error messages + * to stderr, which may occur during DLL initialization + * while fixing up 'pseudo' relocations. This early, we + * may not be able to use cygwin stdio functions, so we + * use the win32 WriteFile api. This should work with both + * normal win32 console IO handles, redirected ones, and + * cygwin ptys. + */ + char buf[SHORT_MSG_BUF_SZ]; + wchar_t module[MAX_PATH]; + char * posix_module = NULL; + static const char UNKNOWN_MODULE[] = ": "; + static const size_t UNKNOWN_MODULE_LEN = sizeof (UNKNOWN_MODULE) - 1; + static const char CYGWIN_FAILURE_MSG[] = "Cygwin runtime failure: "; + static const size_t CYGWIN_FAILURE_MSG_LEN = sizeof (CYGWIN_FAILURE_MSG) - 1; + DWORD len; + DWORD done; + va_list args; + HANDLE errh = GetStdHandle (STD_ERROR_HANDLE); + ssize_t modulelen = GetModuleFileNameW (NULL, module, sizeof (module)); + + if (errh == INVALID_HANDLE_VALUE) + cygwin_internal (CW_EXIT_PROCESS, + STATUS_ILLEGAL_DLL_PSEUDO_RELOCATION, + 1); + + if (modulelen > 0) + posix_module = cygwin_create_path (CCP_WIN_W_TO_POSIX, module); + + va_start (args, msg); + len = (DWORD) vsnprintf (buf, SHORT_MSG_BUF_SZ, msg, args); + va_end (args); + buf[SHORT_MSG_BUF_SZ-1] = '\0'; /* paranoia */ + + if (posix_module) + { + WriteFile (errh, (PCVOID)CYGWIN_FAILURE_MSG, + CYGWIN_FAILURE_MSG_LEN, &done, NULL); + WriteFile (errh, (PCVOID)posix_module, + strlen(posix_module), &done, NULL); + WriteFile (errh, (PCVOID)": ", 2, &done, NULL); + WriteFile (errh, (PCVOID)buf, len, &done, NULL); + free (posix_module); + } + else + { + WriteFile (errh, (PCVOID)CYGWIN_FAILURE_MSG, + CYGWIN_FAILURE_MSG_LEN, &done, NULL); + WriteFile (errh, (PCVOID)UNKNOWN_MODULE, + UNKNOWN_MODULE_LEN, &done, NULL); + WriteFile (errh, (PCVOID)buf, len, &done, NULL); + } + WriteFile (errh, (PCVOID)"\n", 1, &done, NULL); + + cygwin_internal (CW_EXIT_PROCESS, + STATUS_ILLEGAL_DLL_PSEUDO_RELOCATION, + 1); + /* not reached, but silences noreturn warning */ + abort (); +#else + va_list argp; + va_start (argp, msg); +# ifdef __MINGW64_VERSION_MAJOR + fprintf (stderr, "Mingw-w64 runtime failure:\n"); +# else + fprintf (stderr, "Mingw runtime failure:\n"); +# endif + vfprintf (stderr, msg, argp); + va_end (argp); + abort (); +#endif +} + +/* This function temporarily marks the page containing addr + * writable, before copying len bytes from *src to *addr, and + * then restores the original protection settings to the page. + * + * Using this function eliminates the requirement with older + * pseudo-reloc implementations, that sections containing + * pseudo-relocs (such as .text and .rdata) be permanently + * marked writable. This older behavior sabotaged any memory + * savings achieved by shared libraries on win32 -- and was + * slower, too. However, on cygwin as of binutils 2.20 the + * .text section is still marked writable, and the .rdata section + * is folded into the (writable) .data when --enable-auto-import. + */ static void __write_memory (void *addr, const void *src, size_t len) { MEMORY_BASIC_INFORMATION b; DWORD oldprot; + if (!len) return; - assert (VirtualQuery (addr, &b, sizeof(b))); + + if (!VirtualQuery (addr, &b, sizeof(b))) + { + __report_error (" VirtualQuery failed for %d bytes at address %p", + (int) sizeof(b), addr); + } + /* Temporarily allow write access to read-only protected memory. */ if (b.Protect != PAGE_EXECUTE_READWRITE && b.Protect != PAGE_READWRITE) VirtualProtect (b.BaseAddress, b.RegionSize, PAGE_EXECUTE_READWRITE, &oldprot); + /* write the data. */ memcpy (addr, src, len); + /* Restore original protection. */ if (b.Protect != PAGE_EXECUTE_READWRITE && b.Protect != PAGE_READWRITE) VirtualProtect (b.BaseAddress, b.RegionSize, oldprot, &oldprot); } @@ -55,66 +198,122 @@ __write_memory (void *addr, const void *src, size_t len) #define RP_VERSION_V2 1 static void -do_pseudo_reloc (void *start, void *end, void *base) +do_pseudo_reloc (void * start, void * end, void * base) { ptrdiff_t addr_imp, reldata; ptrdiff_t reloc_target = (ptrdiff_t) ((char *)end - (char*)start); runtime_pseudo_reloc_v2 *v2_hdr = (runtime_pseudo_reloc_v2 *) start; runtime_pseudo_reloc_item_v2 *r; + /* A valid relocation list will contain at least one entry, and + * one v1 data structure (the smallest one) requires two DWORDs. + * So, if the relocation list is smaller than 8 bytes, bail. + */ if (reloc_target < 8) return; - /* Check if this is old version pseudo relocation version. */ + + /* Check if this is the old pseudo relocation version. */ + /* There are two kinds of v1 relocation lists: + * 1) With a (v2-style) version header. In this case, the + * first entry in the list is a 3-DWORD structure, with + * value: + * { 0, 0, RP_VERSION_V1 } + * In this case, we skip to the next entry in the list, + * knowing that all elements after the head item can + * be cast to runtime_pseudo_reloc_item_v1. + * 2) Without a (v2-style) version header. In this case, the + * first element in the list IS an actual v1 relocation + * record, which is two DWORDs. Because there will never + * be a case where a v1 relocation record has both + * addend == 0 and target == 0, this case will not be + * confused with the prior one. + * All current binutils, when generating a v1 relocation list, + * use the second (e.g. original) form -- that is, without the + * v2-style version header. + */ if (reloc_target >= 12 && v2_hdr->magic1 == 0 && v2_hdr->magic2 == 0 && v2_hdr->version == RP_VERSION_V1) + { + /* We have a list header item indicating that the rest + * of the list contains v1 entries. Move the pointer to + * the first true v1 relocation record. By definition, + * that v1 element will not have both addend == 0 and + * target == 0 (and thus, when interpreted as a + * runtime_pseudo_reloc_v2, it will not have both + * magic1 == 0 and magic2 == 0). + */ v2_hdr++; + } + if (v2_hdr->magic1 != 0 || v2_hdr->magic2 != 0) { - runtime_pseudo_reloc_item_v1 *o; - for (o = (runtime_pseudo_reloc_item_v1 *) v2_hdr; o < (runtime_pseudo_reloc_item_v1 *)end; o++) - { - DWORD newval; + /************************* + * Handle v1 relocations * + *************************/ + runtime_pseudo_reloc_item_v1 * o; + for (o = (runtime_pseudo_reloc_item_v1 *) v2_hdr; + o < (runtime_pseudo_reloc_item_v1 *)end; + o++) + { + DWORD newval; reloc_target = (ptrdiff_t) base + o->target; newval = (*((DWORD*) reloc_target)) + o->addend; __write_memory ((void *) reloc_target, &newval, sizeof(DWORD)); - } + } return; } + + /* If we got this far, then we have relocations of version 2 or newer */ + /* Check if this is a known version. */ if (v2_hdr->version != RP_VERSION_V2) { -#ifdef DEBUG - fprintf (stderr, "pseudo_relocation protocol version %d is unknown to this runtime.\n", - (int) v2_hdr->version); -#endif + __report_error (" Unknown pseudo relocation protocol version %d.\n", + (int) v2_hdr->version); return; } - /* Walk over header. */ + + /************************* + * Handle v2 relocations * + *************************/ + + /* Walk over header. */ r = (runtime_pseudo_reloc_item_v2 *) &v2_hdr[1]; for (; r < (runtime_pseudo_reloc_item_v2 *) end; r++) { + /* location where new address will be written */ reloc_target = (ptrdiff_t) base + r->target; + + /* get sym pointer. It points either to the iat entry + * of the referenced element, or to the stub function. + */ addr_imp = (ptrdiff_t) base + r->sym; addr_imp = *((ptrdiff_t *) addr_imp); - switch ((r->flags&0xff)) + /* read existing relocation value from image, casting to the + * bitsize indicated by the 8 LSBs of flags. If the value is + * negative, manually sign-extend to ptrdiff_t width. Raise an + * error if the bitsize indicated by the 8 LSBs of flags is not + * supported. + */ + switch ((r->flags & 0xff)) { case 8: reldata = (ptrdiff_t) (*((unsigned char *)reloc_target)); - if ((reldata&0x80) != 0) + if ((reldata & 0x80) != 0) reldata |= ~((ptrdiff_t) 0xff); break; case 16: reldata = (ptrdiff_t) (*((unsigned short *)reloc_target)); - if ((reldata&0x8000) != 0) + if ((reldata & 0x8000) != 0) reldata |= ~((ptrdiff_t) 0xffff); break; case 32: reldata = (ptrdiff_t) (*((unsigned int *)reloc_target)); #ifdef _WIN64 - if ((reldata&0x80000000) != 0) + if ((reldata & 0x80000000) != 0) reldata |= ~((ptrdiff_t) 0xffffffff); #endif break; @@ -125,15 +324,18 @@ do_pseudo_reloc (void *start, void *end, void *base) #endif default: reldata=0; -#ifdef DEBUG - fprintf(stderr, "Unknown pseudo relocation bit size %d\n",(int) (r->flags & 0xff)); -#endif + __report_error (" Unknown pseudo relocation bit size %d.\n", + (int) (r->flags & 0xff)); break; } + + /* Adjust the relocation value */ reldata -= ((ptrdiff_t) base + r->sym); reldata += addr_imp; + + /* Write the new relocation value back to *reloc_target */ switch ((r->flags & 0xff)) - { + { case 8: __write_memory ((void *) reloc_target, &reldata, 1); break; @@ -148,18 +350,18 @@ do_pseudo_reloc (void *start, void *end, void *base) __write_memory ((void *) reloc_target, &reldata, 8); break; #endif - } - } + } + } } -void _pei386_runtime_relocator (void); - void _pei386_runtime_relocator (void) { - static int was_init = 0; + static NO_COPY int was_init = 0; if (was_init) return; ++was_init; - do_pseudo_reloc (&__RUNTIME_PSEUDO_RELOC_LIST__,&__RUNTIME_PSEUDO_RELOC_LIST_END__,&__ImageBase); + do_pseudo_reloc (&__RUNTIME_PSEUDO_RELOC_LIST__, + &__RUNTIME_PSEUDO_RELOC_LIST_END__, + &__MINGW_LSYMBOL(_image_base__)); } diff --git a/reactos/lib/3rdparty/mingw/strcasecmp.c b/reactos/lib/3rdparty/mingw/strcasecmp.c new file mode 100644 index 00000000000..17aba0b0b3c --- /dev/null +++ b/reactos/lib/3rdparty/mingw/strcasecmp.c @@ -0,0 +1,16 @@ +/** + * This file has no copyright assigned and is placed in the Public Domain. + * This file is part of the w64 mingw-runtime package. + * No warranty is given; refer to the file DISCLAIMER.PD within this package. + */ + +#define __CRT__NO_INLINE +#include + +#undef strcasecmp +int strcasecmp (const char *, const char *); +int +strcasecmp (const char *sz1, const char *sz2) +{ + return _stricmp (sz1,sz2); +} diff --git a/reactos/lib/3rdparty/mingw/strncasecmp.c b/reactos/lib/3rdparty/mingw/strncasecmp.c new file mode 100644 index 00000000000..b06afdac648 --- /dev/null +++ b/reactos/lib/3rdparty/mingw/strncasecmp.c @@ -0,0 +1,17 @@ +/** + * This file has no copyright assigned and is placed in the Public Domain. + * This file is part of the w64 mingw-runtime package. + * No warranty is given; refer to the file DISCLAIMER.PD within this package. + */ + +#define __CRT__NO_INLINE +#include + +#undef strncasecmp +int strncasecmp (const char *, const char *, size_t); + +int +strncasecmp (const char *sz1,const char *sz2,size_t sizeMaxCompare) +{ + return _strnicmp (sz1,sz2,sizeMaxCompare); +} diff --git a/reactos/lib/3rdparty/mingw/tlsmcrt.c b/reactos/lib/3rdparty/mingw/tlsmcrt.c new file mode 100644 index 00000000000..2450b8b9216 --- /dev/null +++ b/reactos/lib/3rdparty/mingw/tlsmcrt.c @@ -0,0 +1,13 @@ +/** + * This file has no copyright assigned and is placed in the Public Domain. + * This file is part of the w64 mingw-runtime package. + * No warranty is given; refer to the file DISCLAIMER.PD within this package. + * + * Written by Kai Tietz + */ + +/* We support TLS cleanup code in any case. If shared version of libgcc is used _CRT_MT has value 1, + otherwise + we do tls cleanup in runtime and _CRT_MT has value 2. */ +int _CRT_MT = 2; + diff --git a/reactos/lib/3rdparty/mingw/tlsmthread.c b/reactos/lib/3rdparty/mingw/tlsmthread.c new file mode 100644 index 00000000000..c018abfd21e --- /dev/null +++ b/reactos/lib/3rdparty/mingw/tlsmthread.c @@ -0,0 +1,59 @@ +/** + * This file has no copyright assigned and is placed in the Public Domain. + * This file is part of the w64 mingw-runtime package. + * No warranty is given; refer to the file DISCLAIMER.PD within this package. + * + * Written by Kai Tietz + */ +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#include +#include + +int __mingwthr_key_dtor (DWORD key, void (*dtor)(void *)); +int __mingwthr_remove_key_dtor (DWORD key); + +extern int ___w64_mingwthr_remove_key_dtor (DWORD key); +extern int ___w64_mingwthr_add_key_dtor (DWORD key, void (*dtor)(void *)); + + +#ifndef _WIN64 +#define MINGWM10_DLL "mingwm10.dll" +typedef int (*fMTRemoveKeyDtor)(DWORD key); +typedef int (*fMTKeyDtor)(DWORD key, void (*dtor)(void *)); +extern fMTRemoveKeyDtor __mingw_gMTRemoveKeyDtor; +extern fMTKeyDtor __mingw_gMTKeyDtor; +extern int __mingw_usemthread_dll; +#endif + +int +__mingwthr_remove_key_dtor (DWORD key) +{ +#ifndef _WIN64 + if (!__mingw_usemthread_dll) +#endif + return ___w64_mingwthr_remove_key_dtor (key); +#ifndef _WIN64 + if (__mingw_gMTRemoveKeyDtor) + return (*__mingw_gMTRemoveKeyDtor) (key); + return 0; +#endif +} + +int +__mingwthr_key_dtor (DWORD key, void (*dtor)(void *)) +{ + if (dtor) + { +#ifndef _WIN64 + if (!__mingw_usemthread_dll) +#endif + return ___w64_mingwthr_add_key_dtor (key, dtor); +#ifndef _WIN64 + if (__mingw_gMTKeyDtor) + return (*__mingw_gMTKeyDtor) (key, dtor); +#endif + } + return 0; +} diff --git a/reactos/lib/3rdparty/mingw/tlssup.c b/reactos/lib/3rdparty/mingw/tlssup.c index 0088beb2f1a..aec217dba5e 100644 --- a/reactos/lib/3rdparty/mingw/tlssup.c +++ b/reactos/lib/3rdparty/mingw/tlssup.c @@ -1,20 +1,32 @@ /** * This file has no copyright assigned and is placed in the Public Domain. * This file is part of the w64 mingw-runtime package. - * No warranty is given; refer to the file DISCLAIMER within this package. + * No warranty is given; refer to the file DISCLAIMER.PD within this package. + * + * Written by Kai Tietz */ #ifdef CRTDLL #undef CRTDLL #endif -#include -#include #include +#include +#include #include -#include -extern BOOL __mingw_TLScallback (HANDLE hDllHandle, DWORD reason, LPVOID reserved); +#ifndef _CRTALLOC +#define _CRTALLOC(x) __attribute__ ((section (x) )) +#endif + +#ifndef __INTERNAL_FUNC_DEFINED +#define __INTERNAL_FUNC_DEFINED + typedef void (__cdecl *_PVFV)(void); + typedef int (__cdecl *_PIFV)(void); + typedef void (__cdecl *_PVFI)(int); +#endif + +extern WINBOOL __mingw_TLScallback (HANDLE hDllHandle, DWORD reason, LPVOID reserved); #define FUNCS_PER_NODE 30 @@ -66,6 +78,16 @@ static __CRT_THREAD TlsDtorNode dtor_list_head; extern int _CRT_MT; +#ifndef _WIN64 +#define MINGWM10_DLL "mingwm10.dll" +typedef int (*fMTRemoveKeyDtor)(DWORD key); +typedef int (*fMTKeyDtor)(DWORD key, void (*dtor)(void *)); +fMTRemoveKeyDtor __mingw_gMTRemoveKeyDtor; +fMTKeyDtor __mingw_gMTKeyDtor; +int __mingw_usemthread_dll; +static HANDLE __mingw_mthread_hdll; +#endif + BOOL WINAPI __dyn_tls_init (HANDLE, DWORD, LPVOID); BOOL WINAPI @@ -73,6 +95,30 @@ __dyn_tls_init (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved) { _PVFV *pfunc; +#ifndef _WIN64 + if (_winmajor < 4) + { + __mingw_usemthread_dll = 1; + __mingw_mthread_hdll = LoadLibrary (MINGWM10_DLL); + if (__mingw_mthread_hdll != NULL) + { + __mingw_gMTRemoveKeyDtor = (fMTRemoveKeyDtor) GetProcAddress (__mingw_mthread_hdll, "__mingwthr_remove_key_dtor"); + __mingw_gMTKeyDtor = (fMTKeyDtor) GetProcAddress (__mingw_mthread_hdll, "__mingwthr_key_dtor"); + } + if (__mingw_mthread_hdll == NULL || !__mingw_gMTRemoveKeyDtor || !__mingw_gMTKeyDtor) + { + __mingw_gMTKeyDtor = NULL; + __mingw_gMTRemoveKeyDtor = NULL; + if (__mingw_mthread_hdll) + FreeLibrary (__mingw_mthread_hdll); + __mingw_mthread_hdll = NULL; + _CRT_MT = 0; + return TRUE; + } + _CRT_MT = 1; + return TRUE; + } +#endif /* We don't let us trick here. */ if (_CRT_MT != 2) _CRT_MT = 2; diff --git a/reactos/lib/3rdparty/mingw/dummy_mingwthrd.c b/reactos/lib/3rdparty/mingw/tlsthrd.c similarity index 87% rename from reactos/lib/3rdparty/mingw/dummy_mingwthrd.c rename to reactos/lib/3rdparty/mingw/tlsthrd.c index 597144fc06b..2e76727d20d 100644 --- a/reactos/lib/3rdparty/mingw/dummy_mingwthrd.c +++ b/reactos/lib/3rdparty/mingw/tlsthrd.c @@ -1,9 +1,11 @@ -/* - * mthr_stub.c +/** + * This file has no copyright assigned and is placed in the Public Domain. + * This file is part of the w64 mingw-runtime package. + * No warranty is given; refer to the file DISCLAIMER.PD within this package. * - * Implement Mingw-w64 thread-support. + * Written by Kai Tietz * - * This file is used by if gcc is built with --enable-threads=win32. + * This file is used by if gcc is built with --enable-threads=win32. * * Based on version created by Mumit Khan * @@ -15,7 +17,7 @@ #include #include -BOOL __mingw_TLScallback (HANDLE hDllHandle, DWORD reason, LPVOID reserved); +WINBOOL __mingw_TLScallback (HANDLE hDllHandle, DWORD reason, LPVOID reserved); int ___w64_mingwthr_remove_key_dtor (DWORD key); int ___w64_mingwthr_add_key_dtor (DWORD key, void (*dtor)(void *)); @@ -42,12 +44,10 @@ ___w64_mingwthr_add_key_dtor (DWORD key, void (*dtor)(void *)) if (__mingwthr_cs_init == 0) return 0; - new_key = (__mingwthr_key_t *)malloc(sizeof (__mingwthr_key_t)); - + new_key = (__mingwthr_key_t *) calloc (1, sizeof (__mingwthr_key_t)); if (new_key == NULL) return -1; - memset(new_key, 0,sizeof (__mingwthr_key_t)); new_key->key = key; new_key->dtor = dtor; @@ -116,8 +116,8 @@ __mingwthr_run_key_dtors (void) LeaveCriticalSection (&__mingwthr_cs); } - -BOOL + +WINBOOL __mingw_TLScallback (HANDLE hDllHandle __attribute__ ((__unused__)), DWORD reason, LPVOID reserved __attribute__ ((__unused__))) diff --git a/reactos/lib/3rdparty/mingw/toascii.c b/reactos/lib/3rdparty/mingw/toascii.c new file mode 100644 index 00000000000..946b321af41 --- /dev/null +++ b/reactos/lib/3rdparty/mingw/toascii.c @@ -0,0 +1,17 @@ +/** + * This file has no copyright assigned and is placed in the Public Domain. + * This file is part of the w64 mingw-runtime package. + * No warranty is given; refer to the file DISCLAIMER.PD within this package. + */ + +#include + +#undef toascii + +int toascii (int); + +int +toascii (int c) +{ + return __toascii(c); +} diff --git a/reactos/lib/3rdparty/mingw/txtmode.c b/reactos/lib/3rdparty/mingw/txtmode.c index 59a960ceecf..0c700ee1a19 100644 --- a/reactos/lib/3rdparty/mingw/txtmode.c +++ b/reactos/lib/3rdparty/mingw/txtmode.c @@ -1,7 +1,7 @@ /** * This file has no copyright assigned and is placed in the Public Domain. * This file is part of the w64 mingw-runtime package. - * No warranty is given; refer to the file DISCLAIMER within this package. + * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ #include diff --git a/reactos/lib/3rdparty/mingw/ucrtexe.c b/reactos/lib/3rdparty/mingw/ucrtexe.c new file mode 100644 index 00000000000..76e0e0cc205 --- /dev/null +++ b/reactos/lib/3rdparty/mingw/ucrtexe.c @@ -0,0 +1,14 @@ +/** + * This file has no copyright assigned and is placed in the Public Domain. + * This file is part of the w64 mingw-runtime package. + * No warranty is given; refer to the file DISCLAIMER.PD within this package. + */ + +#ifndef UNICODE +#define UNICODE +#endif + +#define WPRFLAG 1 + +#include "crtexe.c" + diff --git a/reactos/lib/3rdparty/mingw/udll_argv.c b/reactos/lib/3rdparty/mingw/udll_argv.c new file mode 100644 index 00000000000..3511925afa2 --- /dev/null +++ b/reactos/lib/3rdparty/mingw/udll_argv.c @@ -0,0 +1,14 @@ +/** + * This file has no copyright assigned and is placed in the Public Domain. + * This file is part of the w64 mingw-runtime package. + * No warranty is given; refer to the file DISCLAIMER.PD within this package. + */ + +#ifndef UNICODE +#define UNICODE +#endif + +#define WPRFLAG 1 + +#include "dll_argv.c" + diff --git a/reactos/lib/3rdparty/mingw/udllargc.c b/reactos/lib/3rdparty/mingw/udllargc.c new file mode 100644 index 00000000000..bcec7546726 --- /dev/null +++ b/reactos/lib/3rdparty/mingw/udllargc.c @@ -0,0 +1,14 @@ +/** + * This file has no copyright assigned and is placed in the Public Domain. + * This file is part of the w64 mingw-runtime package. + * No warranty is given; refer to the file DISCLAIMER.PD within this package. + */ + +#ifndef UNICODE +#define UNICODE +#endif + +#define WPRFLAG 1 + +#include "dllargv.c" + diff --git a/reactos/lib/3rdparty/mingw/wcscmpi.c b/reactos/lib/3rdparty/mingw/wcscmpi.c new file mode 100644 index 00000000000..2fce2b41706 --- /dev/null +++ b/reactos/lib/3rdparty/mingw/wcscmpi.c @@ -0,0 +1,17 @@ +/** + * This file has no copyright assigned and is placed in the Public Domain. + * This file is part of the w64 mingw-runtime package. + * No warranty is given; refer to the file DISCLAIMER.PD within this package. + */ + +#define __CRT__NO_INLINE +#include + +#undef wcscmpi +int wcscmpi (const wchar_t *, const wchar_t *); + +int +wcscmpi (const wchar_t * ws1,const wchar_t * ws2) +{ + return _wcsicmp (ws1,ws2); +} diff --git a/reactos/lib/3rdparty/mingw/wildcard.c b/reactos/lib/3rdparty/mingw/wildcard.c index 82085d31cec..f996577bf27 100644 --- a/reactos/lib/3rdparty/mingw/wildcard.c +++ b/reactos/lib/3rdparty/mingw/wildcard.c @@ -1,19 +1,33 @@ /** * This file has no copyright assigned and is placed in the Public Domain. * This file is part of the w64 mingw-runtime package. - * No warranty is given; refer to the file DISCLAIMER within this package. + * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ /* _dowildcard is an int that controls the globbing of the command line. * If _dowildcard is non-zero, the command line will be globbed: *.* * will be expanded to be all files in the startup directory. + * * In the mingw-w64 library the _dowildcard variable is defined as being * 0, therefore command line globbing is DISABLED by default. To turn it * on and to leave wildcard command line processing MS's globbing code, * include a line in one of your source modules defining _dowildcard and * setting it to -1, like so: * int _dowildcard = -1; + * + * Alternatively, the mingw-w64 library can be configured using the + * --enable-wildcard option and compiled thusly upon which the resulting + * library will have _dowildcard as -1 and command line globbing will be + * enabled by default. */ -int _dowildcard = 0; +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#ifndef __ENABLE_GLOBBING +#define __ENABLE_GLOBBING 0 /* -1 */ +#endif + +int _dowildcard = __ENABLE_GLOBBING; diff --git a/reactos/lib/3rdparty/mingw/xncommod.c b/reactos/lib/3rdparty/mingw/xncommod.c index 462c8267a68..f4efddb49ea 100644 --- a/reactos/lib/3rdparty/mingw/xncommod.c +++ b/reactos/lib/3rdparty/mingw/xncommod.c @@ -1,7 +1,7 @@ /** * This file has no copyright assigned and is placed in the Public Domain. * This file is part of the w64 mingw-runtime package. - * No warranty is given; refer to the file DISCLAIMER within this package. + * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ int _commode = 0; diff --git a/reactos/lib/3rdparty/mingw/xthdloc.c b/reactos/lib/3rdparty/mingw/xthdloc.c index 1f7e59ac31e..285bc958037 100644 --- a/reactos/lib/3rdparty/mingw/xthdloc.c +++ b/reactos/lib/3rdparty/mingw/xthdloc.c @@ -1,7 +1,7 @@ /** * This file has no copyright assigned and is placed in the Public Domain. * This file is part of the w64 mingw-runtime package. - * No warranty is given; refer to the file DISCLAIMER within this package. + * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ int __globallocalestatus = ~0x1; diff --git a/reactos/lib/3rdparty/mingw/xtxtmode.c b/reactos/lib/3rdparty/mingw/xtxtmode.c index 6f1a195a88f..6da7d6b9d63 100644 --- a/reactos/lib/3rdparty/mingw/xtxtmode.c +++ b/reactos/lib/3rdparty/mingw/xtxtmode.c @@ -1,7 +1,7 @@ /** * This file has no copyright assigned and is placed in the Public Domain. * This file is part of the w64 mingw-runtime package. - * No warranty is given; refer to the file DISCLAIMER within this package. + * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ int _fmode = 0; From bf6ce4779ee88a997afe36d82d47c45da18634ca Mon Sep 17 00:00:00 2001 From: Sir Richard Date: Mon, 29 Mar 2010 00:02:05 +0000 Subject: [PATCH 062/134] [COMPBATT]: Main battery detection/PnP notification logic: CompBattAddNewBattery, CompBattRemoveBattery, IsBatteryAlreadyOnList, RemoveBatteryFromList, CompBattGetBatteries, CompBattPnpEventHandler. svn path=/trunk/; revision=46540 --- reactos/drivers/bus/acpi/compbatt/compbatt.c | 6 +- reactos/drivers/bus/acpi/compbatt/compbatt.h | 28 +- reactos/drivers/bus/acpi/compbatt/comppnp.c | 254 ++++++++++++++++++- 3 files changed, 269 insertions(+), 19 deletions(-) diff --git a/reactos/drivers/bus/acpi/compbatt/compbatt.c b/reactos/drivers/bus/acpi/compbatt/compbatt.c index d8f8920cc0a..e0006eca97a 100644 --- a/reactos/drivers/bus/acpi/compbatt/compbatt.c +++ b/reactos/drivers/bus/acpi/compbatt/compbatt.c @@ -27,7 +27,7 @@ CompBattOpenClose(IN PDEVICE_OBJECT DeviceObject, /* Complete the IRP with success */ Irp->IoStatus.Status = STATUS_SUCCESS; Irp->IoStatus.Information = 0; - IofCompleteRequest(Irp, IO_NO_INCREMENT); + IoCompleteRequest(Irp, IO_NO_INCREMENT); /* Return success */ if (CompBattDebug & 0x100) DbgPrint("CompBatt: Exiting OpenClose\n"); @@ -56,7 +56,7 @@ CompBattSystemControl(IN PDEVICE_OBJECT DeviceObject, /* We don't support WMI */ Status = STATUS_NOT_SUPPORTED; Irp->IoStatus.Status = STATUS_NOT_SUPPORTED; - IofCompleteRequest(Irp, IO_NO_INCREMENT); + IoCompleteRequest(Irp, IO_NO_INCREMENT); } /* Return status */ @@ -75,7 +75,7 @@ CompBattMonitorIrpComplete(IN PDEVICE_OBJECT DeviceObject, NTSTATUS NTAPI -CompBattMonitorIrpCompleteWorker(IN PCOMPBATT_BATTERY_ENTRY BatteryData) +CompBattMonitorIrpCompleteWorker(IN PCOMPBATT_BATTERY_DATA BatteryData) { UNIMPLEMENTED; return STATUS_NOT_IMPLEMENTED; diff --git a/reactos/drivers/bus/acpi/compbatt/compbatt.h b/reactos/drivers/bus/acpi/compbatt/compbatt.h index 015195bafe2..996b5559690 100644 --- a/reactos/drivers/bus/acpi/compbatt/compbatt.h +++ b/reactos/drivers/bus/acpi/compbatt/compbatt.h @@ -10,8 +10,9 @@ #include #include #include +#include -typedef struct _COMPBATT_BATTERY_ENTRY +typedef struct _COMPBATT_BATTERY_DATA { LIST_ENTRY BatteryLink; IO_REMOVE_LOCK RemoveLock; @@ -31,7 +32,7 @@ typedef struct _COMPBATT_BATTERY_ENTRY BATTERY_STATUS BatteryStatus; ULONGLONG InterruptTime; UNICODE_STRING BatteryName; -} COMPBATT_BATTERY_ENTRY, *PCOMPBATT_BATTERY_ENTRY; +} COMPBATT_BATTERY_DATA, *PCOMPBATT_BATTERY_DATA; typedef struct _COMPBATT_DEVICE_EXTENSION { @@ -114,6 +115,29 @@ CompBattQueryTag( OUT PULONG Tag ); +NTSTATUS +NTAPI +CompBattMonitorIrpComplete( + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp, + IN PKEVENT Event +); + +NTSTATUS +NTAPI +CompBattMonitorIrpCompleteWorker( + IN PCOMPBATT_BATTERY_DATA BatteryData +); + +NTSTATUS +NTAPI +CompBattGetDeviceObjectPointer( + IN PCUNICODE_STRING DeviceName, + IN ACCESS_MASK DesiredAccess, + OUT PFILE_OBJECT *FileObject, + OUT PDEVICE_OBJECT *DeviceObject +); + extern ULONG CompBattDebug; /* EOF */ diff --git a/reactos/drivers/bus/acpi/compbatt/comppnp.c b/reactos/drivers/bus/acpi/compbatt/comppnp.c index 156ee3fd81f..b9dd70ccc29 100644 --- a/reactos/drivers/bus/acpi/compbatt/comppnp.c +++ b/reactos/drivers/bus/acpi/compbatt/comppnp.c @@ -28,13 +28,43 @@ CompBattPowerDispatch(IN PDEVICE_OBJECT DeviceObject, return PoCallDriver(DeviceExtension->AttachedDevice, Irp); } -PCOMPBATT_BATTERY_ENTRY +PCOMPBATT_BATTERY_DATA NTAPI RemoveBatteryFromList(IN PCUNICODE_STRING BatteryName, IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension) { - UNIMPLEMENTED; - return NULL; + PLIST_ENTRY ListHead, NextEntry; + PCOMPBATT_BATTERY_DATA BatteryData; + if (CompBattDebug & 1) + DbgPrint("CompBatt: ENTERING RemoveBatteryFromList\n"); + + /* Loop the battery list */ + ExAcquireFastMutex(&DeviceExtension->Lock); + ListHead = &DeviceExtension->BatteryList; + NextEntry = ListHead->Flink; + while (NextEntry != ListHead) + { + /* Get the battery information and compare the name */ + BatteryData = CONTAINING_RECORD(NextEntry, COMPBATT_BATTERY_DATA, BatteryLink); + if (!RtlCompareUnicodeString(BatteryName, &BatteryData->BatteryName, TRUE)) + { + /* Flush pending deletes and any lock waiters */ + IoAcquireRemoveLock(&BatteryData->RemoveLock, 0); + ExReleaseFastMutex(&DeviceExtension->Lock); + IoReleaseRemoveLockAndWait(&BatteryData->RemoveLock, 0); + + /* Remove the entry from the list */ + ExAcquireFastMutex(&DeviceExtension->Lock); + RemoveEntryList(&BatteryData->BatteryLink); + ExReleaseFastMutex(&DeviceExtension->Lock); + return BatteryData; + } + } + + /* Done */ + ExReleaseFastMutex(&DeviceExtension->Lock); + if (CompBattDebug & 1) DbgPrint("CompBatt: EXITING RemoveBatteryFromList\n"); + return STATUS_SUCCESS; } BOOLEAN @@ -42,8 +72,32 @@ NTAPI IsBatteryAlreadyOnList(IN PCUNICODE_STRING BatteryName, IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension) { - UNIMPLEMENTED; - return FALSE; + PLIST_ENTRY ListHead, NextEntry; + PCOMPBATT_BATTERY_DATA BatteryData; + BOOLEAN Found = FALSE; + if (CompBattDebug & 1) + DbgPrint("CompBatt: ENTERING IsBatteryAlreadyOnList\n"); + + /* Loop the battery list */ + ExAcquireFastMutex(&DeviceExtension->Lock); + ListHead = &DeviceExtension->BatteryList; + NextEntry = ListHead->Flink; + while (NextEntry != ListHead) + { + /* Get the battery information and compare the name */ + BatteryData = CONTAINING_RECORD(NextEntry, COMPBATT_BATTERY_DATA, BatteryLink); + if (!RtlCompareUnicodeString(BatteryName, &BatteryData->BatteryName, TRUE)) + { + /* Got it */ + Found = TRUE; + break; + } + } + + /* Release the lock and return search status */ + ExReleaseFastMutex(&DeviceExtension->Lock); + if (CompBattDebug & 1) DbgPrint("CompBatt: EXITING IsBatteryAlreadyOnList\n"); + return Found; } NTSTATUS @@ -51,8 +105,107 @@ NTAPI CompBattAddNewBattery(IN PCUNICODE_STRING BatteryName, IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension) { - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; + NTSTATUS Status = STATUS_SUCCESS; + PCOMPBATT_BATTERY_DATA BatteryData; + PIRP Irp; + PIO_STACK_LOCATION IoStackLocation; + PFILE_OBJECT FileObject; + PAGED_CODE(); + if (CompBattDebug & 1) + DbgPrint("CompBatt: ENTERING AddNewBattery \"%w\" \n", BatteryName->Buffer); + + /* Is this a new battery? */ + if (!IsBatteryAlreadyOnList(BatteryName, DeviceExtension)) + { + /* Allocate battery data */ + BatteryData = ExAllocatePoolWithTag(NonPagedPool, + sizeof(COMPBATT_BATTERY_DATA) + + BatteryName->Length, + 'CtaB'); + if (BatteryData) + { + /* Initialize the data and write the battery name */ + RtlZeroMemory(BatteryData, sizeof(COMPBATT_BATTERY_DATA)); + BatteryData->Tag = 0; + BatteryData->BatteryName.MaximumLength = BatteryName->Length; + BatteryData->BatteryName.Buffer = (PWCHAR)(BatteryData + 1); + RtlCopyUnicodeString(&BatteryData->BatteryName, BatteryName); + + /* Get the device object */ + Status = CompBattGetDeviceObjectPointer(BatteryName, + FILE_ALL_ACCESS, + &FileObject, + &BatteryData->DeviceObject); + if (NT_SUCCESS(Status)) + { + /* Reference the DO and drop the FO */ + ObfReferenceObject(BatteryData->DeviceObject); + ObfDereferenceObject(FileObject); + + /* Allocate the battery IRP */ + Irp = IoAllocateIrp(BatteryData->DeviceObject->StackSize + 1, 0); + if (Irp) + { + /* Save it */ + BatteryData->Irp = Irp; + + /* Setup the stack location */ + IoStackLocation = IoGetNextIrpStackLocation(Irp); + IoStackLocation->Parameters.Others.Argument1 = DeviceExtension; + IoStackLocation->Parameters.Others.Argument2 = BatteryData; + + /* Set IRP data */ + IoSetNextIrpStackLocation(Irp); + Irp->IoStatus.Status = STATUS_DEVICE_NOT_CONNECTED; + BatteryData->WaitFlag = 0; + + /* Insert this battery in the list */ + ExAcquireFastMutex(&DeviceExtension->Lock); + InsertTailList(&DeviceExtension->BatteryList, + &BatteryData->BatteryLink); + ExReleaseFastMutex(&DeviceExtension->Lock); + + /* Initialize the work item and delete lock */ + IoInitializeRemoveLock(&BatteryData->RemoveLock, 0, 0, 0); + ExInitializeWorkItem(&BatteryData->WorkItem, + (PVOID)CompBattMonitorIrpCompleteWorker, + BatteryData); + + /* Setup the IRP work entry */ + CompBattMonitorIrpComplete(BatteryData->DeviceObject, Irp, 0); + Status = STATUS_SUCCESS; + } + else + { + /* Fail, no memory */ + if (CompBattDebug & 8) + DbgPrint("CompBatt: Couldn't allocate new battery Irp\n"); + Status = STATUS_INSUFFICIENT_RESOURCES; + ObfDereferenceObject(BatteryData->DeviceObject); + } + } + else if (CompBattDebug & 8) + { + /* Fail */ + DbgPrint("CompBattAddNewBattery: Failed to get device Object. status = %lx\n", + Status); + } + + /* Free the battery data */ + ExFreePool(BatteryData); + } + else + { + /* Fail, no memory */ + if (CompBattDebug & 8) + DbgPrint("CompBatt: Couldn't allocate new battery node\n"); + Status = STATUS_INSUFFICIENT_RESOURCES; + } + } + + /* We're done */ + if (CompBattDebug & 1) DbgPrint("CompBatt: EXITING AddNewBattery\n"); + return Status; } NTSTATUS @@ -60,16 +213,65 @@ NTAPI CompBattRemoveBattery(IN PCUNICODE_STRING BatteryName, IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension) { - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; + PCOMPBATT_BATTERY_DATA BatteryData; + if (CompBattDebug & 1) DbgPrint("CompBatt: RemoveBattery\n"); + + /* Remove the entry */ + BatteryData = RemoveBatteryFromList(BatteryName, DeviceExtension); + if (BatteryData) + { + /* Dereference and free it */ + ObfDereferenceObject(BatteryData->DeviceObject); + ExFreePool(BatteryData); + + /* Notify class driver */ + DeviceExtension->Flags = 0; + BatteryClassStatusNotify(DeviceExtension->ClassData); + } + + /* It's done */ + return STATUS_SUCCESS; } NTSTATUS NTAPI CompBattGetBatteries(IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension) { - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; + PWCHAR p; + NTSTATUS Status; + PWCHAR LinkList; + UNICODE_STRING LinkString; + if (CompBattDebug & 1) DbgPrint("CompBatt: ENTERING GetBatteries\n"); + + /* Get all battery links */ + Status = IoGetDeviceInterfaces(&GUID_DEVICE_BATTERY, NULL, 0, &LinkList); + p = LinkList; + if (NT_SUCCESS(Status)) + { + /* Loop all strings inside */ + while (TRUE) + { + /* Create the string */ + RtlInitUnicodeString(&LinkString, p); + if (!LinkString.Length) break; + + /* Add this battery and move on */ + Status = CompBattAddNewBattery(&LinkString, DeviceExtension); + p += (LinkString.Length / sizeof(WCHAR)) + sizeof(UNICODE_NULL); + } + + /* Parsing complete, clean up buffer */ + ExFreePool(LinkList); + } + else if (CompBattDebug & 8) + { + /* Fail */ + DbgPrint("CompBatt: Couldn't get list of batteries\n"); + } + + /* Done */ + if (CompBattDebug & 1) DbgPrint("CompBatt: EXITING GetBatteries\n"); + return Status; } NTSTATUS @@ -77,8 +279,32 @@ NTAPI CompBattPnpEventHandler(IN PDEVICE_INTERFACE_CHANGE_NOTIFICATION Notification, IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension) { - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; + if (CompBattDebug & 1) DbgPrint("CompBatt: ENTERING PnpEventHandler\n"); + if (CompBattDebug & 2) DbgPrint("CompBatt: Received device interface change notification\n"); + + /* Check what happened */ + if (IsEqualGUIDAligned(&Notification->Event, &GUID_DEVICE_INTERFACE_ARRIVAL)) + { + /* Add the new battery */ + if (CompBattDebug & 2) + DbgPrint("CompBatt: Received notification of battery arrival\n"); + CompBattAddNewBattery(Notification->SymbolicLinkName, DeviceExtension); + } + else if (IsEqualGUIDAligned(&Notification->Event, &GUID_DEVICE_INTERFACE_REMOVAL)) + { + /* Don't do anything */ + if (CompBattDebug & 2) + DbgPrint("CompBatt: Received notification of battery removal\n"); + } + else + { + /* Shouldn't happen */ + if (CompBattDebug & 2) DbgPrint("CompBatt: Received unhandled PnP event\n"); + } + + /* Done, return success */ + if (CompBattDebug & 1) DbgPrint("CompBatt: EXITING PnpEventHandler\n"); + return STATUS_SUCCESS; } NTSTATUS @@ -251,7 +477,7 @@ CompBattPnpDispatch(IN PDEVICE_OBJECT DeviceObject, { /* Complete the request */ Status = Irp->IoStatus.Status; - IofCompleteRequest(Irp, IO_NO_INCREMENT); + IoCompleteRequest(Irp, IO_NO_INCREMENT); } /* Release the remove lock and return status */ From 123bf68a1a1875951b10003deb470b8bee13a529 Mon Sep 17 00:00:00 2001 From: Sir Richard Date: Mon, 29 Mar 2010 00:10:56 +0000 Subject: [PATCH 063/134] [COMPBATT]: Helper code, CompBattGetDeviceObjectPointer and BatteryIoctl. svn path=/trunk/; revision=46541 --- reactos/drivers/bus/acpi/compbatt/compbatt.h | 2 +- reactos/drivers/bus/acpi/compbatt/compmisc.c | 93 ++++++++++++++++++-- reactos/drivers/bus/acpi/compbatt/comppnp.c | 2 +- 3 files changed, 90 insertions(+), 7 deletions(-) diff --git a/reactos/drivers/bus/acpi/compbatt/compbatt.h b/reactos/drivers/bus/acpi/compbatt/compbatt.h index 996b5559690..87e3cb11cf4 100644 --- a/reactos/drivers/bus/acpi/compbatt/compbatt.h +++ b/reactos/drivers/bus/acpi/compbatt/compbatt.h @@ -132,7 +132,7 @@ CompBattMonitorIrpCompleteWorker( NTSTATUS NTAPI CompBattGetDeviceObjectPointer( - IN PCUNICODE_STRING DeviceName, + IN PUNICODE_STRING DeviceName, IN ACCESS_MASK DesiredAccess, OUT PFILE_OBJECT *FileObject, OUT PDEVICE_OBJECT *DeviceObject diff --git a/reactos/drivers/bus/acpi/compbatt/compmisc.c b/reactos/drivers/bus/acpi/compbatt/compmisc.c index 3f75d4b9abf..ced7e4195a2 100644 --- a/reactos/drivers/bus/acpi/compbatt/compmisc.c +++ b/reactos/drivers/bus/acpi/compbatt/compmisc.c @@ -22,19 +22,102 @@ BatteryIoctl(IN ULONG IoControlCode, IN ULONG OutputBufferLength, IN BOOLEAN InternalDeviceIoControl) { - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; + IO_STATUS_BLOCK IoStatusBlock; + KEVENT Event; + NTSTATUS Status; + PIRP Irp; + PAGED_CODE(); + if (CompBattDebug & 0x100) DbgPrint("CompBatt: ENTERING BatteryIoctl\n"); + + /* Initialize the event and IRP */ + KeInitializeEvent(&Event, SynchronizationEvent, 0); + Irp = IoBuildDeviceIoControlRequest(IoControlCode, + DeviceObject, + InputBuffer, + InputBufferLength, + OutputBuffer, + OutputBufferLength, + InternalDeviceIoControl, + &Event, + &IoStatusBlock); + if (Irp) + { + /* Call the class driver miniport */ + Status = IofCallDriver(DeviceObject, Irp); + if (Status == STATUS_PENDING) + { + /* Wait for result */ + KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL); + Status = IoStatusBlock.Status; + } + + /* Print failure */ + if (!(NT_SUCCESS(Status)) && (CompBattDebug & 8)) + DbgPrint("BatteryIoctl: Irp failed - %x\n", Status); + + /* Done */ + if (CompBattDebug & 0x100) DbgPrint("CompBatt: EXITING BatteryIoctl\n"); + } + else + { + /* Out of memory */ + if (CompBattDebug & 8) DbgPrint("BatteryIoctl: couldn't create Irp\n"); + Status = STATUS_INSUFFICIENT_RESOURCES; + } + + /* Return status */ + return Status; } NTSTATUS NTAPI -CompBattGetDeviceObjectPointer(IN PCUNICODE_STRING DeviceName, +CompBattGetDeviceObjectPointer(IN PUNICODE_STRING DeviceName, IN ACCESS_MASK DesiredAccess, OUT PFILE_OBJECT *FileObject, OUT PDEVICE_OBJECT *DeviceObject) { - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; + NTSTATUS Status; + OBJECT_ATTRIBUTES ObjectAttributes; + IO_STATUS_BLOCK IoStatusBlock; + PFILE_OBJECT LocalFileObject; + HANDLE DeviceHandle; + PAGED_CODE(); + + /* Open a file object handle to the device */ + InitializeObjectAttributes(&ObjectAttributes, DeviceName, 0, NULL, NULL); + Status = ZwCreateFile(&DeviceHandle, + DesiredAccess, + &ObjectAttributes, + &IoStatusBlock, + NULL, + 0, + FILE_SHARE_READ | FILE_SHARE_WRITE, + FILE_OPEN, + 0, + NULL, + 0); + if (NT_SUCCESS(Status)) + { + /* Reference the file object */ + Status = ObReferenceObjectByHandle(DeviceHandle, + 0, + IoFileObjectType, + KernelMode, + (PVOID)&LocalFileObject, + NULL); + if (NT_SUCCESS(Status)) + { + /* Return the FO and the associated DO */ + *FileObject = LocalFileObject; + *DeviceObject = IoGetRelatedDeviceObject(LocalFileObject); + } + + /* Close the handle */ + ZwClose(DeviceHandle); + } + + /* Return status */ + return Status; } /* EOF */ diff --git a/reactos/drivers/bus/acpi/compbatt/comppnp.c b/reactos/drivers/bus/acpi/compbatt/comppnp.c index b9dd70ccc29..f09ed5c25bb 100644 --- a/reactos/drivers/bus/acpi/compbatt/comppnp.c +++ b/reactos/drivers/bus/acpi/compbatt/comppnp.c @@ -102,7 +102,7 @@ IsBatteryAlreadyOnList(IN PCUNICODE_STRING BatteryName, NTSTATUS NTAPI -CompBattAddNewBattery(IN PCUNICODE_STRING BatteryName, +CompBattAddNewBattery(IN PUNICODE_STRING BatteryName, IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension) { NTSTATUS Status = STATUS_SUCCESS; From dd1c6f7b0627ce533a72b510657a48cf4f47884a Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 29 Mar 2010 01:51:11 +0000 Subject: [PATCH 064/134] Reintegrate header branch part 1/x DDKAPI -> NTAPI svn path=/trunk/; revision=46542 --- reactos/boot/freeldr/freeldr/disk/scsiport.c | 90 +-- reactos/drivers/battery/battc/battc.c | 12 +- reactos/drivers/storage/ide/uniata/atapi.h | 4 +- reactos/drivers/storage/ide/uniata/bsmaster.h | 8 +- reactos/drivers/storage/ide/uniata/config.h | 2 - reactos/drivers/storage/ide/uniata/id_ata.cpp | 30 +- reactos/drivers/storage/ide/uniata/srb.h | 108 ++-- reactos/drivers/storage/scsiport/stubs.c | 54 +- reactos/drivers/video/displays/vga/vgaddi.h | 1 - reactos/include/ddk/afilter.h | 22 +- reactos/include/ddk/hidclass.h | 4 +- reactos/include/ddk/hidpi.h | 50 +- reactos/include/ddk/mcd.h | 18 +- reactos/include/ddk/miniport.h | 2 +- reactos/include/ddk/minitape.h | 8 +- reactos/include/ddk/ndis.h | 610 +++++++++--------- reactos/include/ddk/ntagp.h | 12 +- reactos/include/ddk/ntdd8042.h | 14 +- reactos/include/ddk/ntpoapi.h | 2 +- reactos/include/ddk/parallel.h | 36 +- reactos/include/ddk/scsiwmi.h | 18 +- reactos/include/ddk/smbus.h | 20 +- reactos/include/ddk/srb.h | 108 ++-- reactos/include/ddk/storport.h | 84 +-- reactos/include/ddk/tdikrnl.h | 112 ++-- reactos/include/ddk/upssvc.h | 12 +- reactos/include/ddk/video.h | 290 ++++----- reactos/include/ddk/videoagp.h | 20 +- reactos/include/psdk/batclass.h | 24 +- 29 files changed, 884 insertions(+), 891 deletions(-) diff --git a/reactos/boot/freeldr/freeldr/disk/scsiport.c b/reactos/boot/freeldr/freeldr/disk/scsiport.c index d8d15b12d84..81ba4a4efa2 100644 --- a/reactos/boot/freeldr/freeldr/disk/scsiport.c +++ b/reactos/boot/freeldr/freeldr/disk/scsiport.c @@ -385,7 +385,7 @@ SpiCreatePortConfig( } VOID -DDKCDECLAPI +__cdecl ScsiDebugPrint( IN ULONG DebugPrintLevel, IN PCCHAR DebugMessage, @@ -421,7 +421,7 @@ ScsiDebugPrint( } VOID -DDKAPI +NTAPI ScsiPortCompleteRequest( IN PVOID HwDeviceExtension, IN UCHAR PathId, @@ -435,7 +435,7 @@ ScsiPortCompleteRequest( #undef ScsiPortConvertPhysicalAddressToUlong ULONG -DDKAPI +NTAPI ScsiPortConvertPhysicalAddressToUlong( IN SCSI_PHYSICAL_ADDRESS Address) { @@ -443,7 +443,7 @@ ScsiPortConvertPhysicalAddressToUlong( } SCSI_PHYSICAL_ADDRESS -DDKAPI +NTAPI ScsiPortConvertUlongToPhysicalAddress( IN ULONG UlongAddress) { @@ -451,7 +451,7 @@ ScsiPortConvertUlongToPhysicalAddress( } VOID -DDKAPI +NTAPI ScsiPortFlushDma( IN PVOID DeviceExtension) { @@ -460,7 +460,7 @@ ScsiPortFlushDma( } VOID -DDKAPI +NTAPI ScsiPortFreeDeviceBase( IN PVOID HwDeviceExtension, IN PVOID MappedAddress) @@ -469,7 +469,7 @@ ScsiPortFreeDeviceBase( } ULONG -DDKAPI +NTAPI ScsiPortGetBusData( IN PVOID DeviceExtension, IN ULONG BusDataType, @@ -482,7 +482,7 @@ ScsiPortGetBusData( } PVOID -DDKAPI +NTAPI ScsiPortGetDeviceBase( IN PVOID HwDeviceExtension, IN INTERFACE_TYPE BusType, @@ -514,7 +514,7 @@ ScsiPortGetDeviceBase( } PVOID -DDKAPI +NTAPI ScsiPortGetLogicalUnit( IN PVOID HwDeviceExtension, IN UCHAR PathId, @@ -527,7 +527,7 @@ ScsiPortGetLogicalUnit( } SCSI_PHYSICAL_ADDRESS -DDKAPI +NTAPI ScsiPortGetPhysicalAddress( IN PVOID HwDeviceExtension, IN PSCSI_REQUEST_BLOCK Srb OPTIONAL, @@ -564,7 +564,7 @@ ScsiPortGetPhysicalAddress( } PSCSI_REQUEST_BLOCK -DDKAPI +NTAPI ScsiPortGetSrb( IN PVOID DeviceExtension, IN UCHAR PathId, @@ -641,7 +641,7 @@ SpiAllocateCommonBuffer( } PVOID -DDKAPI +NTAPI ScsiPortGetUncachedExtension( IN PVOID HwDeviceExtension, IN PPORT_CONFIGURATION_INFORMATION ConfigInfo, @@ -726,7 +726,7 @@ ScsiPortGetUncachedExtension( } PVOID -DDKAPI +NTAPI ScsiPortGetVirtualAddress( IN PVOID HwDeviceExtension, IN SCSI_PHYSICAL_ADDRESS PhysicalAddress) @@ -1031,7 +1031,7 @@ SpiGetPciConfigData( } ULONG -DDKAPI +NTAPI ScsiPortInitialize( IN PVOID Argument1, IN PVOID Argument2, @@ -1186,7 +1186,7 @@ ScsiPortInitialize( } VOID -DDKAPI +NTAPI ScsiPortIoMapTransfer( IN PVOID HwDeviceExtension, IN PSCSI_REQUEST_BLOCK Srb, @@ -1198,7 +1198,7 @@ ScsiPortIoMapTransfer( } VOID -DDKAPI +NTAPI ScsiPortLogError( IN PVOID HwDeviceExtension, IN PSCSI_REQUEST_BLOCK Srb OPTIONAL, @@ -1213,7 +1213,7 @@ ScsiPortLogError( } VOID -DDKAPI +NTAPI ScsiPortMoveMemory( IN PVOID WriteBuffer, IN PVOID ReadBuffer, @@ -1223,7 +1223,7 @@ ScsiPortMoveMemory( } VOID -DDKCDECLAPI +__cdecl ScsiPortNotification( IN SCSI_NOTIFICATION_TYPE NotificationType, IN PVOID HwDeviceExtension, @@ -1259,7 +1259,7 @@ ScsiPortNotification( } VOID -DDKAPI +NTAPI ScsiPortReadPortBufferUchar( IN PUCHAR Port, OUT PUCHAR Buffer, @@ -1269,7 +1269,7 @@ ScsiPortReadPortBufferUchar( } VOID -DDKAPI +NTAPI ScsiPortReadPortBufferUlong( IN PULONG Port, OUT PULONG Buffer, @@ -1279,7 +1279,7 @@ ScsiPortReadPortBufferUlong( } VOID -DDKAPI +NTAPI ScsiPortReadPortBufferUshort( IN PUSHORT Port, OUT PUSHORT Buffer, @@ -1289,7 +1289,7 @@ ScsiPortReadPortBufferUshort( } UCHAR -DDKAPI +NTAPI ScsiPortReadPortUchar( IN PUCHAR Port) { @@ -1300,7 +1300,7 @@ ScsiPortReadPortUchar( } ULONG -DDKAPI +NTAPI ScsiPortReadPortUlong( IN PULONG Port) { @@ -1308,7 +1308,7 @@ ScsiPortReadPortUlong( } USHORT -DDKAPI +NTAPI ScsiPortReadPortUshort( IN PUSHORT Port) { @@ -1316,7 +1316,7 @@ ScsiPortReadPortUshort( } VOID -DDKAPI +NTAPI ScsiPortReadRegisterBufferUchar( IN PUCHAR Register, IN PUCHAR Buffer, @@ -1327,7 +1327,7 @@ ScsiPortReadRegisterBufferUchar( } VOID -DDKAPI +NTAPI ScsiPortReadRegisterBufferUlong( IN PULONG Register, IN PULONG Buffer, @@ -1338,7 +1338,7 @@ ScsiPortReadRegisterBufferUlong( } VOID -DDKAPI +NTAPI ScsiPortReadRegisterBufferUshort( IN PUSHORT Register, IN PUSHORT Buffer, @@ -1349,7 +1349,7 @@ ScsiPortReadRegisterBufferUshort( } UCHAR -DDKAPI +NTAPI ScsiPortReadRegisterUchar( IN PUCHAR Register) { @@ -1357,7 +1357,7 @@ ScsiPortReadRegisterUchar( } ULONG -DDKAPI +NTAPI ScsiPortReadRegisterUlong( IN PULONG Register) { @@ -1365,7 +1365,7 @@ ScsiPortReadRegisterUlong( } USHORT -DDKAPI +NTAPI ScsiPortReadRegisterUshort( IN PUSHORT Register) { @@ -1373,7 +1373,7 @@ ScsiPortReadRegisterUshort( } ULONG -DDKAPI +NTAPI ScsiPortSetBusDataByOffset( IN PVOID DeviceExtension, IN ULONG BusDataType, @@ -1389,7 +1389,7 @@ ScsiPortSetBusDataByOffset( } VOID -DDKAPI +NTAPI ScsiPortStallExecution( IN ULONG Delay) { @@ -1397,7 +1397,7 @@ ScsiPortStallExecution( } BOOLEAN -DDKAPI +NTAPI ScsiPortValidateRange( IN PVOID HwDeviceExtension, IN INTERFACE_TYPE BusType, @@ -1417,7 +1417,7 @@ ScsiPortValidateRange( VOID -DDKAPI +NTAPI ScsiPortWritePortBufferUchar( IN PUCHAR Port, IN PUCHAR Buffer, @@ -1427,7 +1427,7 @@ ScsiPortWritePortBufferUchar( } VOID -DDKAPI +NTAPI ScsiPortWritePortBufferUlong( IN PULONG Port, IN PULONG Buffer, @@ -1437,7 +1437,7 @@ ScsiPortWritePortBufferUlong( } VOID -DDKAPI +NTAPI ScsiPortWritePortBufferUshort( IN PUSHORT Port, IN PUSHORT Buffer, @@ -1447,7 +1447,7 @@ ScsiPortWritePortBufferUshort( } VOID -DDKAPI +NTAPI ScsiPortWritePortUchar( IN PUCHAR Port, IN UCHAR Value) @@ -1456,7 +1456,7 @@ ScsiPortWritePortUchar( } VOID -DDKAPI +NTAPI ScsiPortWritePortUlong( IN PULONG Port, IN ULONG Value) @@ -1465,7 +1465,7 @@ ScsiPortWritePortUlong( } VOID -DDKAPI +NTAPI ScsiPortWritePortUshort( IN PUSHORT Port, IN USHORT Value) @@ -1474,7 +1474,7 @@ ScsiPortWritePortUshort( } VOID -DDKAPI +NTAPI ScsiPortWriteRegisterBufferUchar( IN PUCHAR Register, IN PUCHAR Buffer, @@ -1485,7 +1485,7 @@ ScsiPortWriteRegisterBufferUchar( } VOID -DDKAPI +NTAPI ScsiPortWriteRegisterBufferUlong( IN PULONG Register, IN PULONG Buffer, @@ -1496,7 +1496,7 @@ ScsiPortWriteRegisterBufferUlong( } VOID -DDKAPI +NTAPI ScsiPortWriteRegisterBufferUshort( IN PUSHORT Register, IN PUSHORT Buffer, @@ -1507,7 +1507,7 @@ ScsiPortWriteRegisterBufferUshort( } VOID -DDKAPI +NTAPI ScsiPortWriteRegisterUchar( IN PUCHAR Register, IN ULONG Value) @@ -1516,7 +1516,7 @@ ScsiPortWriteRegisterUchar( } VOID -DDKAPI +NTAPI ScsiPortWriteRegisterUlong( IN PULONG Register, IN ULONG Value) @@ -1525,7 +1525,7 @@ ScsiPortWriteRegisterUlong( } VOID -DDKAPI +NTAPI ScsiPortWriteRegisterUshort( IN PUSHORT Register, IN USHORT Value) diff --git a/reactos/drivers/battery/battc/battc.c b/reactos/drivers/battery/battc/battc.c index 6a0b7220c1c..7e4854c9ef2 100644 --- a/reactos/drivers/battery/battc/battc.c +++ b/reactos/drivers/battery/battc/battc.c @@ -23,7 +23,7 @@ DriverEntry(PDRIVER_OBJECT DriverObject, BCLASSAPI NTSTATUS -DDKAPI +NTAPI BatteryClassUnload(PVOID ClassData) { PBATTERY_CLASS_DATA BattClass = ClassData; @@ -44,7 +44,7 @@ BatteryClassUnload(PVOID ClassData) BCLASSAPI NTSTATUS -DDKAPI +NTAPI BatteryClassSystemControl(PVOID ClassData, PVOID WmiLibContext, PDEVICE_OBJECT DeviceObject, @@ -58,7 +58,7 @@ BatteryClassSystemControl(PVOID ClassData, BCLASSAPI NTSTATUS -DDKAPI +NTAPI BatteryClassQueryWmiDataBlock(PVOID ClassData, PDEVICE_OBJECT DeviceObject, PIRP Irp, @@ -74,7 +74,7 @@ BatteryClassQueryWmiDataBlock(PVOID ClassData, BCLASSAPI NTSTATUS -DDKAPI +NTAPI BatteryClassStatusNotify(PVOID ClassData) { PBATTERY_CLASS_DATA BattClass = ClassData; @@ -129,7 +129,7 @@ BatteryClassStatusNotify(PVOID ClassData) BCLASSAPI NTSTATUS -DDKAPI +NTAPI BatteryClassInitializeDevice(PBATTERY_MINIPORT_INFO MiniportInfo, PVOID *ClassData) { @@ -172,7 +172,7 @@ BatteryClassInitializeDevice(PBATTERY_MINIPORT_INFO MiniportInfo, BCLASSAPI NTSTATUS -DDKAPI +NTAPI BatteryClassIoctl(PVOID ClassData, PIRP Irp) { diff --git a/reactos/drivers/storage/ide/uniata/atapi.h b/reactos/drivers/storage/ide/uniata/atapi.h index 9974b51406e..2648d4b0b55 100644 --- a/reactos/drivers/storage/ide/uniata/atapi.h +++ b/reactos/drivers/storage/ide/uniata/atapi.h @@ -77,7 +77,7 @@ extern "C" { SCSIPORT_API VOID -DDKCDECLAPI +__cdecl ScsiDebugPrint( ULONG DebugPrintLevel, PCCHAR DebugMessage, @@ -1066,7 +1066,7 @@ IdeMediaStatus( IN UCHAR Channel ); -ULONG DDKAPI +ULONG NTAPI AtapiFindController( IN PVOID HwDeviceExtension, IN PVOID Context, diff --git a/reactos/drivers/storage/ide/uniata/bsmaster.h b/reactos/drivers/storage/ide/uniata/bsmaster.h index cfb153991f7..6d2adabba8c 100644 --- a/reactos/drivers/storage/ide/uniata/bsmaster.h +++ b/reactos/drivers/storage/ide/uniata/bsmaster.h @@ -1015,7 +1015,7 @@ UniataEnumBusMasterController( PVOID Argument2 ); -extern ULONG DDKAPI +extern ULONG NTAPI UniataFindCompatBusMasterController1( IN PVOID HwDeviceExtension, IN PVOID Context, @@ -1025,7 +1025,7 @@ UniataFindCompatBusMasterController1( OUT PBOOLEAN Again ); -extern ULONG DDKAPI +extern ULONG NTAPI UniataFindCompatBusMasterController2( IN PVOID HwDeviceExtension, IN PVOID Context, @@ -1044,7 +1044,7 @@ UniataAllocateLunExt( ULONG NewNumberChannels ); -extern ULONG DDKAPI +extern ULONG NTAPI UniataFindBusMasterController( IN PVOID HwDeviceExtension, IN PVOID Context, @@ -1054,7 +1054,7 @@ UniataFindBusMasterController( OUT PBOOLEAN Again ); -extern ULONG DDKAPI +extern ULONG NTAPI UniataFindFakeBusMasterController( IN PVOID HwDeviceExtension, IN PVOID Context, diff --git a/reactos/drivers/storage/ide/uniata/config.h b/reactos/drivers/storage/ide/uniata/config.h index e17416f1367..c0b9f4f88ad 100644 --- a/reactos/drivers/storage/ide/uniata/config.h +++ b/reactos/drivers/storage/ide/uniata/config.h @@ -86,9 +86,7 @@ /* Compiler dependencies */ /***************************************************/ -#define DDKAPI __stdcall #define DDKFASTAPI __fastcall -#define DDKCDECLAPI __cdecl /* Are we under GNU C (mingw) ??? */ #ifdef __GNUC__ diff --git a/reactos/drivers/storage/ide/uniata/id_ata.cpp b/reactos/drivers/storage/ide/uniata/id_ata.cpp index 5bb5cf74009..1cace8bd488 100644 --- a/reactos/drivers/storage/ide/uniata/id_ata.cpp +++ b/reactos/drivers/storage/ide/uniata/id_ata.cpp @@ -94,7 +94,7 @@ BOOLEAN WinVer_WDM_Model = FALSE; UCHAR g_foo = 0; BOOLEAN -DDKAPI +NTAPI AtapiResetController__( IN PVOID HwDeviceExtension, IN ULONG PathId, @@ -115,7 +115,7 @@ AtapiHwInitialize__( #ifndef UNIATA_CORE VOID -DDKAPI +NTAPI AtapiCallBack_X( IN PVOID HwDeviceExtension ); @@ -129,13 +129,13 @@ AtapiCallBack_X( #endif RETTYPE_XXableInterrupts -DDKAPI +NTAPI AtapiInterruptDpc( IN PVOID HwDeviceExtension ); RETTYPE_XXableInterrupts -DDKAPI +NTAPI AtapiEnableInterrupts__( IN PVOID HwDeviceExtension ); @@ -150,7 +150,7 @@ AtapiQueueTimerDpc( ); SCSI_ADAPTER_CONTROL_STATUS -DDKAPI +NTAPI AtapiAdapterControl( IN PVOID HwDeviceExtension, IN SCSI_ADAPTER_CONTROL_TYPE ControlType, @@ -1005,7 +1005,7 @@ AtaUmode(PIDENTIFY_DATA2 ident) #ifndef UNIATA_CORE VOID -DDKAPI +NTAPI AtapiTimerDpc( IN PVOID HwDeviceExtension ) @@ -1856,7 +1856,7 @@ Return Value: --*/ BOOLEAN -DDKAPI +NTAPI AtapiResetController( IN PVOID HwDeviceExtension, IN ULONG PathId @@ -2598,7 +2598,7 @@ Return Value: --*/ BOOLEAN -DDKAPI +NTAPI AtapiHwInitialize( IN PVOID HwDeviceExtension ) @@ -3210,7 +3210,7 @@ Return Value: --*/ BOOLEAN -DDKAPI +NTAPI AtapiInterrupt( IN PVOID HwDeviceExtension ) @@ -3400,7 +3400,7 @@ AtapiInterrupt2( } // end AtapiInterrupt2() RETTYPE_XXableInterrupts -DDKAPI +NTAPI AtapiInterruptDpc( IN PVOID HwDeviceExtension ) @@ -3437,7 +3437,7 @@ AtapiInterruptDpc( RETTYPE_XXableInterrupts -DDKAPI +NTAPI AtapiEnableInterrupts__( IN PVOID HwDeviceExtension ) @@ -7251,7 +7251,7 @@ Return Value: --*/ BOOLEAN -DDKAPI +NTAPI AtapiStartIo( IN PVOID HwDeviceExtension, IN PSCSI_REQUEST_BLOCK Srb @@ -8343,7 +8343,7 @@ Return Value: --*/ extern "C" ULONG -DDKAPI +NTAPI DriverEntry( IN PVOID DriverObject, IN PVOID Argument2 @@ -9059,7 +9059,7 @@ AtapiRegCheckParameterValue( SCSI_ADAPTER_CONTROL_STATUS -DDKAPI +NTAPI AtapiAdapterControl( IN PVOID HwDeviceExtension, IN SCSI_ADAPTER_CONTROL_TYPE ControlType, @@ -9152,7 +9152,7 @@ AtapiAdapterControl( extern "C" NTHALAPI VOID -DDKAPI +NTAPI HalDisplayString ( PUCHAR String ); diff --git a/reactos/drivers/storage/ide/uniata/srb.h b/reactos/drivers/storage/ide/uniata/srb.h index aa4f7f1ce5f..b3795b22808 100644 --- a/reactos/drivers/storage/ide/uniata/srb.h +++ b/reactos/drivers/storage/ide/uniata/srb.h @@ -424,38 +424,38 @@ typedef struct _SCSI_WMI_REQUEST_BLOCK { typedef BOOLEAN -(DDKAPI *PHW_INITIALIZE) ( +(NTAPI *PHW_INITIALIZE) ( IN PVOID DeviceExtension ); typedef BOOLEAN -(DDKAPI *PHW_STARTIO) ( +(NTAPI *PHW_STARTIO) ( IN PVOID DeviceExtension, IN PSCSI_REQUEST_BLOCK Srb ); typedef BOOLEAN -(DDKAPI *PHW_INTERRUPT) ( +(NTAPI *PHW_INTERRUPT) ( IN PVOID DeviceExtension ); typedef VOID -(DDKAPI *PHW_TIMER) ( +(NTAPI *PHW_TIMER) ( IN PVOID DeviceExtension ); typedef VOID -(DDKAPI *PHW_DMA_STARTED) ( +(NTAPI *PHW_DMA_STARTED) ( IN PVOID DeviceExtension ); typedef ULONG -(DDKAPI *PHW_FIND_ADAPTER) ( +(NTAPI *PHW_FIND_ADAPTER) ( IN PVOID DeviceExtension, IN PVOID HwContext, IN PVOID BusInformation, @@ -466,14 +466,14 @@ ULONG typedef BOOLEAN -(DDKAPI *PHW_RESET_BUS) ( +(NTAPI *PHW_RESET_BUS) ( IN PVOID DeviceExtension, IN ULONG PathId ); typedef BOOLEAN -(DDKAPI *PHW_ADAPTER_STATE) ( +(NTAPI *PHW_ADAPTER_STATE) ( IN PVOID DeviceExtension, IN PVOID Context, IN BOOLEAN SaveState @@ -481,7 +481,7 @@ BOOLEAN typedef SCSI_ADAPTER_CONTROL_STATUS -(DDKAPI *PHW_ADAPTER_CONTROL) ( +(NTAPI *PHW_ADAPTER_CONTROL) ( IN PVOID DeviceExtension, IN SCSI_ADAPTER_CONTROL_TYPE ControlType, IN PVOID Parameters @@ -607,7 +607,7 @@ typedef struct _HW_INITIALIZATION_DATA_COMMON { // SCSIPORT_API -ULONG DDKAPI +ULONG NTAPI ScsiPortInitialize( IN PVOID Argument1, IN PVOID Argument2, @@ -616,14 +616,14 @@ ScsiPortInitialize( ); SCSIPORT_API -VOID DDKAPI +VOID NTAPI ScsiPortFreeDeviceBase( IN PVOID HwDeviceExtension, IN PVOID MappedAddress ); SCSIPORT_API -ULONG DDKAPI +ULONG NTAPI ScsiPortGetBusData( IN PVOID DeviceExtension, IN ULONG BusDataType, @@ -634,7 +634,7 @@ ScsiPortGetBusData( ); SCSIPORT_API -ULONG DDKAPI +ULONG NTAPI ScsiPortSetBusDataByOffset( IN PVOID DeviceExtension, IN ULONG BusDataType, @@ -646,7 +646,7 @@ ScsiPortSetBusDataByOffset( ); SCSIPORT_API -PVOID DDKAPI +PVOID NTAPI ScsiPortGetDeviceBase( IN PVOID HwDeviceExtension, IN INTERFACE_TYPE BusType, @@ -657,7 +657,7 @@ ScsiPortGetDeviceBase( ); SCSIPORT_API -PVOID DDKAPI +PVOID NTAPI ScsiPortGetLogicalUnit( IN PVOID HwDeviceExtension, IN UCHAR PathId, @@ -666,7 +666,7 @@ ScsiPortGetLogicalUnit( ); SCSIPORT_API -PSCSI_REQUEST_BLOCK DDKAPI +PSCSI_REQUEST_BLOCK NTAPI ScsiPortGetSrb( IN PVOID DeviceExtension, IN UCHAR PathId, @@ -676,7 +676,7 @@ ScsiPortGetSrb( ); SCSIPORT_API -SCSI_PHYSICAL_ADDRESS DDKAPI +SCSI_PHYSICAL_ADDRESS NTAPI ScsiPortGetPhysicalAddress( IN PVOID HwDeviceExtension, IN PSCSI_REQUEST_BLOCK Srb, @@ -685,14 +685,14 @@ ScsiPortGetPhysicalAddress( ); SCSIPORT_API -PVOID DDKAPI +PVOID NTAPI ScsiPortGetVirtualAddress( IN PVOID HwDeviceExtension, IN SCSI_PHYSICAL_ADDRESS PhysicalAddress ); SCSIPORT_API -PVOID DDKAPI +PVOID NTAPI ScsiPortGetUncachedExtension( IN PVOID HwDeviceExtension, IN PPORT_CONFIGURATION_INFORMATION ConfigInfo, @@ -700,13 +700,13 @@ ScsiPortGetUncachedExtension( ); SCSIPORT_API -VOID DDKAPI +VOID NTAPI ScsiPortFlushDma( IN PVOID DeviceExtension ); SCSIPORT_API -VOID DDKAPI +VOID NTAPI ScsiPortIoMapTransfer( IN PVOID HwDeviceExtension, IN PSCSI_REQUEST_BLOCK Srb, @@ -715,7 +715,7 @@ ScsiPortIoMapTransfer( ); SCSIPORT_API -VOID DDKCDECLAPI +VOID __cdecl ScsiPortNotification( IN SCSI_NOTIFICATION_TYPE NotificationType, IN PVOID HwDeviceExtension, @@ -723,7 +723,7 @@ ScsiPortNotification( ); SCSIPORT_API -VOID DDKAPI +VOID NTAPI ScsiPortLogError( IN PVOID HwDeviceExtension, IN PSCSI_REQUEST_BLOCK Srb OPTIONAL, @@ -735,7 +735,7 @@ ScsiPortLogError( ); SCSIPORT_API -VOID DDKAPI +VOID NTAPI ScsiPortCompleteRequest( IN PVOID HwDeviceExtension, IN UCHAR PathId, @@ -745,7 +745,7 @@ ScsiPortCompleteRequest( ); SCSIPORT_API -VOID DDKAPI +VOID NTAPI ScsiPortMoveMemory( IN PVOID WriteBuffer, IN PVOID ReadBuffer, @@ -753,25 +753,25 @@ ScsiPortMoveMemory( ); SCSIPORT_API -UCHAR DDKAPI +UCHAR NTAPI ScsiPortReadPortUchar( IN PUCHAR Port ); SCSIPORT_API -USHORT DDKAPI +USHORT NTAPI ScsiPortReadPortUshort( IN PUSHORT Port ); SCSIPORT_API -ULONG DDKAPI +ULONG NTAPI ScsiPortReadPortUlong( IN PULONG Port ); SCSIPORT_API -VOID DDKAPI +VOID NTAPI ScsiPortReadPortBufferUchar( IN PUCHAR Port, IN PUCHAR Buffer, @@ -779,7 +779,7 @@ ScsiPortReadPortBufferUchar( ); SCSIPORT_API -VOID DDKAPI +VOID NTAPI ScsiPortReadPortBufferUshort( IN PUSHORT Port, IN PUSHORT Buffer, @@ -787,7 +787,7 @@ ScsiPortReadPortBufferUshort( ); SCSIPORT_API -VOID DDKAPI +VOID NTAPI ScsiPortReadPortBufferUlong( IN PULONG Port, IN PULONG Buffer, @@ -795,25 +795,25 @@ ScsiPortReadPortBufferUlong( ); SCSIPORT_API -UCHAR DDKAPI +UCHAR NTAPI ScsiPortReadRegisterUchar( IN PUCHAR Register ); SCSIPORT_API -USHORT DDKAPI +USHORT NTAPI ScsiPortReadRegisterUshort( IN PUSHORT Register ); SCSIPORT_API -ULONG DDKAPI +ULONG NTAPI ScsiPortReadRegisterUlong( IN PULONG Register ); SCSIPORT_API -VOID DDKAPI +VOID NTAPI ScsiPortReadRegisterBufferUchar( IN PUCHAR Register, IN PUCHAR Buffer, @@ -821,7 +821,7 @@ ScsiPortReadRegisterBufferUchar( ); SCSIPORT_API -VOID DDKAPI +VOID NTAPI ScsiPortReadRegisterBufferUshort( IN PUSHORT Register, IN PUSHORT Buffer, @@ -829,7 +829,7 @@ ScsiPortReadRegisterBufferUshort( ); SCSIPORT_API -VOID DDKAPI +VOID NTAPI ScsiPortReadRegisterBufferUlong( IN PULONG Register, IN PULONG Buffer, @@ -837,34 +837,34 @@ ScsiPortReadRegisterBufferUlong( ); SCSIPORT_API -VOID DDKAPI +VOID NTAPI ScsiPortStallExecution( IN ULONG Delay ); SCSIPORT_API -VOID DDKAPI +VOID NTAPI ScsiPortWritePortUchar( IN PUCHAR Port, IN UCHAR Value ); SCSIPORT_API -VOID DDKAPI +VOID NTAPI ScsiPortWritePortUshort( IN PUSHORT Port, IN USHORT Value ); SCSIPORT_API -VOID DDKAPI +VOID NTAPI ScsiPortWritePortUlong( IN PULONG Port, IN ULONG Value ); SCSIPORT_API -VOID DDKAPI +VOID NTAPI ScsiPortWritePortBufferUchar( IN PUCHAR Port, IN PUCHAR Buffer, @@ -872,7 +872,7 @@ ScsiPortWritePortBufferUchar( ); SCSIPORT_API -VOID DDKAPI +VOID NTAPI ScsiPortWritePortBufferUshort( IN PUSHORT Port, IN PUSHORT Buffer, @@ -880,7 +880,7 @@ ScsiPortWritePortBufferUshort( ); SCSIPORT_API -VOID DDKAPI +VOID NTAPI ScsiPortWritePortBufferUlong( IN PULONG Port, IN PULONG Buffer, @@ -888,28 +888,28 @@ ScsiPortWritePortBufferUlong( ); SCSIPORT_API -VOID DDKAPI +VOID NTAPI ScsiPortWriteRegisterUchar( IN PUCHAR Register, IN UCHAR Value ); SCSIPORT_API -VOID DDKAPI +VOID NTAPI ScsiPortWriteRegisterUshort( IN PUSHORT Register, IN USHORT Value ); SCSIPORT_API -VOID DDKAPI +VOID NTAPI ScsiPortWriteRegisterUlong( IN PULONG Register, IN ULONG Value ); SCSIPORT_API -VOID DDKAPI +VOID NTAPI ScsiPortWriteRegisterBufferUchar( IN PUCHAR Register, IN PUCHAR Buffer, @@ -917,7 +917,7 @@ ScsiPortWriteRegisterBufferUchar( ); SCSIPORT_API -VOID DDKAPI +VOID NTAPI ScsiPortWriteRegisterBufferUshort( IN PUSHORT Register, IN PUSHORT Buffer, @@ -925,7 +925,7 @@ ScsiPortWriteRegisterBufferUshort( ); SCSIPORT_API -VOID DDKAPI +VOID NTAPI ScsiPortWriteRegisterBufferUlong( IN PULONG Register, IN PULONG Buffer, @@ -933,13 +933,13 @@ ScsiPortWriteRegisterBufferUlong( ); SCSIPORT_API -SCSI_PHYSICAL_ADDRESS DDKAPI +SCSI_PHYSICAL_ADDRESS NTAPI ScsiPortConvertUlongToPhysicalAddress( ULONG UlongAddress ); SCSIPORT_API -ULONG DDKAPI +ULONG NTAPI ScsiPortConvertPhysicalAddressToUlong( SCSI_PHYSICAL_ADDRESS Address ); @@ -947,7 +947,7 @@ ScsiPortConvertPhysicalAddressToUlong( #define ScsiPortConvertPhysicalAddressToUlong(Address) ((Address).LowPart) SCSIPORT_API -BOOLEAN DDKAPI +BOOLEAN NTAPI ScsiPortValidateRange( IN PVOID HwDeviceExtension, IN INTERFACE_TYPE BusType, @@ -960,7 +960,7 @@ ScsiPortValidateRange( // begin_ntminitape SCSIPORT_API -VOID DDKCDECLAPI +VOID __cdecl ScsiDebugPrint( ULONG DebugPrintLevel, PCCHAR DebugMessage, diff --git a/reactos/drivers/storage/scsiport/stubs.c b/reactos/drivers/storage/scsiport/stubs.c index 9e286d186f4..478c35b4d08 100644 --- a/reactos/drivers/storage/scsiport/stubs.c +++ b/reactos/drivers/storage/scsiport/stubs.c @@ -14,12 +14,8 @@ #define NDEBUG #include -#ifdef _MSC_VER - #define DDKAPI -#endif - SCSI_PHYSICAL_ADDRESS -DDKAPI +NTAPI ScsiPortConvertUlongToPhysicalAddress( IN ULONG UlongAddress) { @@ -27,7 +23,7 @@ ScsiPortConvertUlongToPhysicalAddress( } VOID -DDKAPI +NTAPI ScsiPortReadPortBufferUchar( IN PUCHAR Port, IN PUCHAR Buffer, @@ -37,7 +33,7 @@ ScsiPortReadPortBufferUchar( } VOID -DDKAPI +NTAPI ScsiPortReadPortBufferUshort( IN PUSHORT Port, IN PUSHORT Buffer, @@ -47,7 +43,7 @@ ScsiPortReadPortBufferUshort( } VOID -DDKAPI +NTAPI ScsiPortReadPortBufferUlong( IN PULONG Port, IN PULONG Buffer, @@ -57,7 +53,7 @@ ScsiPortReadPortBufferUlong( } UCHAR -DDKAPI +NTAPI ScsiPortReadPortUchar( IN PUCHAR Port) { @@ -65,7 +61,7 @@ ScsiPortReadPortUchar( } USHORT -DDKAPI +NTAPI ScsiPortReadPortUshort( IN PUSHORT Port) { @@ -73,7 +69,7 @@ ScsiPortReadPortUshort( } ULONG -DDKAPI +NTAPI ScsiPortReadPortUlong( IN PULONG Port) { @@ -81,7 +77,7 @@ ScsiPortReadPortUlong( } VOID -DDKAPI +NTAPI ScsiPortReadRegisterBufferUchar( IN PUCHAR Register, IN PUCHAR Buffer, @@ -91,7 +87,7 @@ ScsiPortReadRegisterBufferUchar( } VOID -DDKAPI +NTAPI ScsiPortReadRegisterBufferUshort( IN PUSHORT Register, IN PUSHORT Buffer, @@ -101,7 +97,7 @@ ScsiPortReadRegisterBufferUshort( } VOID -DDKAPI +NTAPI ScsiPortReadRegisterBufferUlong( IN PULONG Register, IN PULONG Buffer, @@ -111,7 +107,7 @@ ScsiPortReadRegisterBufferUlong( } UCHAR -DDKAPI +NTAPI ScsiPortReadRegisterUchar( IN PUCHAR Register) { @@ -119,7 +115,7 @@ ScsiPortReadRegisterUchar( } USHORT -DDKAPI +NTAPI ScsiPortReadRegisterUshort( IN PUSHORT Register) { @@ -127,7 +123,7 @@ ScsiPortReadRegisterUshort( } ULONG -DDKAPI +NTAPI ScsiPortReadRegisterUlong( IN PULONG Register) { @@ -135,7 +131,7 @@ ScsiPortReadRegisterUlong( } VOID -DDKAPI +NTAPI ScsiPortWritePortBufferUchar( IN PUCHAR Port, IN PUCHAR Buffer, @@ -145,7 +141,7 @@ ScsiPortWritePortBufferUchar( } VOID -DDKAPI +NTAPI ScsiPortWritePortBufferUshort( IN PUSHORT Port, IN PUSHORT Buffer, @@ -155,7 +151,7 @@ ScsiPortWritePortBufferUshort( } VOID -DDKAPI +NTAPI ScsiPortWritePortBufferUlong( IN PULONG Port, IN PULONG Buffer, @@ -165,7 +161,7 @@ ScsiPortWritePortBufferUlong( } VOID -DDKAPI +NTAPI ScsiPortWritePortUchar( IN PUCHAR Port, IN UCHAR Value) @@ -174,7 +170,7 @@ ScsiPortWritePortUchar( } VOID -DDKAPI +NTAPI ScsiPortWritePortUshort( IN PUSHORT Port, IN USHORT Value) @@ -183,7 +179,7 @@ ScsiPortWritePortUshort( } VOID -DDKAPI +NTAPI ScsiPortWritePortUlong( IN PULONG Port, IN ULONG Value) @@ -192,7 +188,7 @@ ScsiPortWritePortUlong( } VOID -DDKAPI +NTAPI ScsiPortWriteRegisterBufferUchar( IN PUCHAR Register, IN PUCHAR Buffer, @@ -202,7 +198,7 @@ ScsiPortWriteRegisterBufferUchar( } VOID -DDKAPI +NTAPI ScsiPortWriteRegisterBufferUshort( IN PUSHORT Register, IN PUSHORT Buffer, @@ -212,7 +208,7 @@ ScsiPortWriteRegisterBufferUshort( } VOID -DDKAPI +NTAPI ScsiPortWriteRegisterBufferUlong( IN PULONG Register, IN PULONG Buffer, @@ -222,7 +218,7 @@ ScsiPortWriteRegisterBufferUlong( } VOID -DDKAPI +NTAPI ScsiPortWriteRegisterUchar( IN PUCHAR Register, IN ULONG Value) @@ -231,7 +227,7 @@ ScsiPortWriteRegisterUchar( } VOID -DDKAPI +NTAPI ScsiPortWriteRegisterUshort( IN PUSHORT Register, IN USHORT Value) @@ -240,7 +236,7 @@ ScsiPortWriteRegisterUshort( } VOID -DDKAPI +NTAPI ScsiPortWriteRegisterUlong( IN PULONG Register, IN ULONG Value) diff --git a/reactos/drivers/video/displays/vga/vgaddi.h b/reactos/drivers/video/displays/vga/vgaddi.h index 97282f882dc..980965da696 100644 --- a/reactos/drivers/video/displays/vga/vgaddi.h +++ b/reactos/drivers/video/displays/vga/vgaddi.h @@ -26,7 +26,6 @@ #define DDKFASTAPI __fastcall #define FASTCALL __fastcall -#define DDKCDECLAPI __cdecl ULONG DbgPrint(PCCH Format,...); diff --git a/reactos/include/ddk/afilter.h b/reactos/include/ddk/afilter.h index 7997a7c9e81..53900bf2b6d 100644 --- a/reactos/include/ddk/afilter.h +++ b/reactos/include/ddk/afilter.h @@ -104,33 +104,33 @@ typedef struct _ARC_FILTER } ARC_FILTER,*PARC_FILTER; BOOLEAN -DDKAPI +NTAPI ArcCreateFilter( IN struct _NDIS_MINIPORT_BLOCK *Miniport, IN UCHAR AdapterAddress, OUT PARC_FILTER *Filter); VOID -DDKAPI +NTAPI ArcDeleteFilter( IN PARC_FILTER Filter); BOOLEAN -DDKAPI +NTAPI ArcNoteFilterOpenAdapter( IN PARC_FILTER Filter, IN NDIS_HANDLE NdisBindingHandle, OUT PNDIS_HANDLE NdisFilterHandle); NDIS_STATUS -DDKAPI +NTAPI ArcDeleteFilterOpenAdapter( IN PARC_FILTER Filter, IN NDIS_HANDLE NdisFilterHandle, IN PNDIS_REQUEST NdisRequest); NDIS_STATUS -DDKAPI +NTAPI ArcFilterAdjust( IN PARC_FILTER Filter, IN NDIS_HANDLE NdisFilterHandle, @@ -139,12 +139,12 @@ ArcFilterAdjust( IN BOOLEAN Set); VOID -DDKAPI +NTAPI ArcFilterDprIndicateReceiveComplete( IN PARC_FILTER Filter); VOID -DDKAPI +NTAPI ArcFilterDprIndicateReceive( IN PARC_FILTER Filter, IN PUCHAR pRawHeader, @@ -152,7 +152,7 @@ ArcFilterDprIndicateReceive( IN UINT Length); NDIS_STATUS -DDKAPI +NTAPI ArcFilterTransferData( IN PARC_FILTER Filter, IN NDIS_HANDLE MacReceiveContext, @@ -162,18 +162,18 @@ ArcFilterTransferData( OUT PUINT BytesTransfered); VOID -DDKAPI +NTAPI ArcFreeNdisPacket( IN PARC_PACKET Packet); VOID -DDKAPI +NTAPI ArcFilterDoIndication( IN PARC_FILTER Filter, IN PARC_PACKET Packet); VOID -DDKAPI +NTAPI ArcDestroyPacket( IN PARC_FILTER Filter, IN PARC_PACKET Packet); diff --git a/reactos/include/ddk/hidclass.h b/reactos/include/ddk/hidclass.h index f269c03f4a2..c93bfb4a525 100644 --- a/reactos/include/ddk/hidclass.h +++ b/reactos/include/ddk/hidclass.h @@ -98,11 +98,11 @@ enum DeviceObjectState { DeviceObjectRemoved }; -typedef VOID (DDKAPI *PHID_STATUS_CHANGE)( +typedef VOID (NTAPI *PHID_STATUS_CHANGE)( PVOID Context, enum DeviceObjectState State); -typedef NTSTATUS (DDKAPI *PHIDP_GETCAPS)( +typedef NTSTATUS (NTAPI *PHIDP_GETCAPS)( IN PHIDP_PREPARSED_DATA PreparsedData, OUT PHIDP_CAPS Capabilities); diff --git a/reactos/include/ddk/hidpi.h b/reactos/include/ddk/hidpi.h index 63d3cf1f936..ca6d89141f8 100644 --- a/reactos/include/ddk/hidpi.h +++ b/reactos/include/ddk/hidpi.h @@ -69,7 +69,7 @@ typedef struct _HIDP_KEYBOARD_MODIFIER_STATE { } DUMMYUNIONNAME; } HIDP_KEYBOARD_MODIFIER_STATE, *PHIDP_KEYBOARD_MODIFIER_STATE; -typedef BOOLEAN (DDKAPI *PHIDP_INSERT_SCANCODES)( +typedef BOOLEAN (NTAPI *PHIDP_INSERT_SCANCODES)( IN PVOID Context, IN PCHAR NewScanCodes, IN ULONG Length); @@ -94,7 +94,7 @@ typedef struct _HIDD_CONFIGURATION { HIDAPI NTSTATUS -DDKAPI +NTAPI HidP_TranslateUsageAndPagesToI8042ScanCodes( IN PUSAGE_AND_PAGE ChangedUsageList, IN ULONG UsageListLength, @@ -105,7 +105,7 @@ HidP_TranslateUsageAndPagesToI8042ScanCodes( HIDAPI NTSTATUS -DDKAPI +NTAPI HidP_TranslateUsagesToI8042ScanCodes( IN PUSAGE ChangedUsageList, IN ULONG UsageListLength, @@ -313,14 +313,14 @@ typedef enum _HIDP_REPORT_TYPE { HIDAPI NTSTATUS -DDKAPI +NTAPI HidP_GetCaps( IN PHIDP_PREPARSED_DATA PreparsedData, OUT PHIDP_CAPS Capabilities); HIDAPI NTSTATUS -DDKAPI +NTAPI HidP_GetData( IN HIDP_REPORT_TYPE ReportType, OUT PHIDP_DATA DataList, @@ -331,7 +331,7 @@ HidP_GetData( HIDAPI NTSTATUS -DDKAPI +NTAPI HidP_GetExtendedAttributes( IN HIDP_REPORT_TYPE ReportType, IN USHORT DataIndex, @@ -341,7 +341,7 @@ HidP_GetExtendedAttributes( HIDAPI NTSTATUS -DDKAPI +NTAPI HidP_GetLinkCollectionNodes( OUT PHIDP_LINK_COLLECTION_NODE LinkCollectionNodes, IN OUT PULONG LinkCollectionNodesLength, @@ -349,7 +349,7 @@ HidP_GetLinkCollectionNodes( HIDAPI NTSTATUS -DDKAPI +NTAPI HidP_GetScaledUsageValue( IN HIDP_REPORT_TYPE ReportType, IN USAGE UsagePage, @@ -362,7 +362,7 @@ HidP_GetScaledUsageValue( HIDAPI NTSTATUS -DDKAPI +NTAPI HidP_GetSpecificButtonCaps( IN HIDP_REPORT_TYPE ReportType, IN USAGE UsagePage, @@ -374,7 +374,7 @@ HidP_GetSpecificButtonCaps( HIDAPI NTSTATUS -DDKAPI +NTAPI HidP_GetSpecificValueCaps( IN HIDP_REPORT_TYPE ReportType, IN USAGE UsagePage, @@ -386,7 +386,7 @@ HidP_GetSpecificValueCaps( HIDAPI NTSTATUS -DDKAPI +NTAPI HidP_GetUsages( IN HIDP_REPORT_TYPE ReportType, IN USAGE UsagePage, @@ -399,7 +399,7 @@ HidP_GetUsages( HIDAPI NTSTATUS -DDKAPI +NTAPI HidP_GetUsagesEx( IN HIDP_REPORT_TYPE ReportType, IN USHORT LinkCollection, @@ -411,7 +411,7 @@ HidP_GetUsagesEx( HIDAPI NTSTATUS -DDKAPI +NTAPI HidP_GetUsageValue( IN HIDP_REPORT_TYPE ReportType, IN USAGE UsagePage, @@ -424,7 +424,7 @@ HidP_GetUsageValue( HIDAPI NTSTATUS -DDKAPI +NTAPI HidP_GetUsageValueArray( IN HIDP_REPORT_TYPE ReportType, IN USAGE UsagePage, @@ -453,7 +453,7 @@ HidP_GetUsageValueArray( HIDAPI NTSTATUS -DDKAPI +NTAPI HidP_InitializeReportForID( IN HIDP_REPORT_TYPE ReportType, IN UCHAR ReportID, @@ -475,14 +475,14 @@ HidP_InitializeReportForID( HIDAPI ULONG -DDKAPI +NTAPI HidP_MaxDataListLength( IN HIDP_REPORT_TYPE ReportType, IN PHIDP_PREPARSED_DATA PreparsedData); HIDAPI ULONG -DDKAPI +NTAPI HidP_MaxUsageListLength( IN HIDP_REPORT_TYPE ReportType, IN USAGE UsagePage OPTIONAL, @@ -509,7 +509,7 @@ HidP_MaxUsageListLength( HIDAPI NTSTATUS -DDKAPI +NTAPI HidP_SetData( IN HIDP_REPORT_TYPE ReportType, IN PHIDP_DATA DataList, @@ -520,7 +520,7 @@ HidP_SetData( HIDAPI NTSTATUS -DDKAPI +NTAPI HidP_SetScaledUsageValue( IN HIDP_REPORT_TYPE ReportType, IN USAGE UsagePage, @@ -533,7 +533,7 @@ HidP_SetScaledUsageValue( HIDAPI NTSTATUS -DDKAPI +NTAPI HidP_SetUsages( IN HIDP_REPORT_TYPE ReportType, IN USAGE UsagePage, @@ -546,7 +546,7 @@ HidP_SetUsages( HIDAPI NTSTATUS -DDKAPI +NTAPI HidP_SetUsageValue( IN HIDP_REPORT_TYPE ReportType, IN USAGE UsagePage, @@ -559,7 +559,7 @@ HidP_SetUsageValue( HIDAPI NTSTATUS -DDKAPI +NTAPI HidP_SetUsageValueArray( IN HIDP_REPORT_TYPE ReportType, IN USAGE UsagePage, @@ -592,7 +592,7 @@ HidP_SetUsageValueArray( HIDAPI NTSTATUS -DDKAPI +NTAPI HidP_UnsetUsages( IN HIDP_REPORT_TYPE ReportType, IN USAGE UsagePage, @@ -605,7 +605,7 @@ HidP_UnsetUsages( HIDAPI NTSTATUS -DDKAPI +NTAPI HidP_UsageAndPageListDifference( IN PUSAGE_AND_PAGE PreviousUsageList, IN PUSAGE_AND_PAGE CurrentUsageList, @@ -615,7 +615,7 @@ HidP_UsageAndPageListDifference( HIDAPI NTSTATUS -DDKAPI +NTAPI HidP_UsageListDifference( IN PUSAGE PreviousUsageList, IN PUSAGE CurrentUsageList, diff --git a/reactos/include/ddk/mcd.h b/reactos/include/ddk/mcd.h index cb4a1a4f032..eb3e5427bd4 100644 --- a/reactos/include/ddk/mcd.h +++ b/reactos/include/ddk/mcd.h @@ -51,7 +51,7 @@ extern "C" { CHANGERAPI PVOID -DDKAPI +NTAPI ChangerClassAllocatePool( IN POOL_TYPE PoolType, IN ULONG NumberOfBytes); @@ -64,13 +64,13 @@ ChangerClassDebugPrint( CHANGERAPI PVOID -DDKAPI +NTAPI ChangerClassFreePool( IN PVOID PoolToFree); CHANGERAPI NTSTATUS -DDKAPI +NTAPI ChangerClassSendSrbSynchronous( IN PDEVICE_OBJECT DeviceObject, IN PSCSI_REQUEST_BLOCK Srb, @@ -79,27 +79,27 @@ ChangerClassSendSrbSynchronous( IN BOOLEAN WriteToDevice); -typedef NTSTATUS DDKAPI +typedef NTSTATUS NTAPI (*CHANGER_INITIALIZE)( IN PDEVICE_OBJECT DeviceObject); -typedef ULONG DDKAPI +typedef ULONG NTAPI (*CHANGER_EXTENSION_SIZE)( VOID); -typedef VOID DDKAPI +typedef VOID NTAPI (*CHANGER_ERROR_ROUTINE)( PDEVICE_OBJECT DeviceObject, PSCSI_REQUEST_BLOCK Srb, NTSTATUS *Status, BOOLEAN *Retry); -typedef NTSTATUS DDKAPI +typedef NTSTATUS NTAPI (*CHANGER_COMMAND_ROUTINE)( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp); -typedef NTSTATUS DDKAPI +typedef NTSTATUS NTAPI (*CHANGER_PERFORM_DIAGNOSTICS)( IN PDEVICE_OBJECT DeviceObject, OUT PWMI_CHANGER_PROBLEM_DEVICE_ERROR ChangerDeviceError); @@ -125,7 +125,7 @@ typedef struct _MCD_INIT_DATA { CHANGERAPI NTSTATUS -DDKAPI +NTAPI ChangerClassInitialize( IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath, diff --git a/reactos/include/ddk/miniport.h b/reactos/include/ddk/miniport.h index 59fcc52a16e..0191e605a2b 100644 --- a/reactos/include/ddk/miniport.h +++ b/reactos/include/ddk/miniport.h @@ -59,7 +59,7 @@ typedef struct _VIDEO_ACCESS_RANGE { #endif typedef VOID -(DDKAPI *PBANKED_SECTION_ROUTINE)( +(NTAPI *PBANKED_SECTION_ROUTINE)( IN ULONG ReadBank, IN ULONG WriteBank, IN PVOID Context); diff --git a/reactos/include/ddk/minitape.h b/reactos/include/ddk/minitape.h index d8f7532f32e..43b1b030a9b 100644 --- a/reactos/include/ddk/minitape.h +++ b/reactos/include/ddk/minitape.h @@ -159,24 +159,24 @@ typedef struct _MODE_CAPABILITIES_PAGE { UCHAR Reserved11[2]; } MODE_CAPABILITIES_PAGE, *PMODE_CAPABILITIES_PAGE; -typedef BOOLEAN DDKAPI +typedef BOOLEAN NTAPI (*TAPE_VERIFY_INQUIRY_ROUTINE)( IN PINQUIRYDATA InquiryData, IN PMODE_CAPABILITIES_PAGE ModeCapabilitiesPage); -typedef VOID DDKAPI +typedef VOID NTAPI (*TAPE_EXTENSION_INIT_ROUTINE)( IN PVOID MinitapeExtension, IN PINQUIRYDATA InquiryData, IN PMODE_CAPABILITIES_PAGE ModeCapabilitiesPage); -typedef VOID DDKAPI +typedef VOID NTAPI (*TAPE_ERROR_ROUTINE)( IN PVOID MinitapeExtension, IN PSCSI_REQUEST_BLOCK Srb, IN OUT PTAPE_STATUS TapeStatus); -typedef TAPE_STATUS DDKAPI +typedef TAPE_STATUS NTAPI (*TAPE_PROCESS_COMMAND_ROUTINE)( IN OUT PVOID MinitapeExtension, IN OUT PVOID CommandExtension, diff --git a/reactos/include/ddk/ndis.h b/reactos/include/ddk/ndis.h index b08fb683b8c..da301b11042 100644 --- a/reactos/include/ddk/ndis.h +++ b/reactos/include/ddk/ndis.h @@ -268,7 +268,7 @@ typedef struct _LOCK_STATE { /* Timer */ typedef VOID -(DDKAPI *PNDIS_TIMER_FUNCTION)( +(NTAPI *PNDIS_TIMER_FUNCTION)( IN PVOID SystemSpecific1, IN PVOID FunctionContext, IN PVOID SystemSpecific2, @@ -626,16 +626,16 @@ typedef struct _NDIS_WAN_LINE_UP { typedef VOID -(DDKAPI *ADAPTER_SHUTDOWN_HANDLER)( +(NTAPI *ADAPTER_SHUTDOWN_HANDLER)( IN PVOID ShutdownContext); typedef NTSTATUS -(DDKAPI *TDI_REGISTER_CALLBACK)( +(NTAPI *TDI_REGISTER_CALLBACK)( IN PUNICODE_STRING DeviceName, OUT HANDLE* TdiHandle); typedef NTSTATUS -(DDKAPI *TDI_PNP_HANDLER)( +(NTAPI *TDI_PNP_HANDLER)( IN PUNICODE_STRING UpperComponent, IN PUNICODE_STRING LowerComponent, IN PUNICODE_STRING BindList, @@ -1057,88 +1057,88 @@ typedef struct _WAN_CO_LINKPARAMS { /* Call Manager */ typedef VOID -(DDKAPI *CM_ACTIVATE_VC_COMPLETE_HANDLER)( +(NTAPI *CM_ACTIVATE_VC_COMPLETE_HANDLER)( IN NDIS_STATUS Status, IN NDIS_HANDLE CallMgrVcContext, IN PCO_CALL_PARAMETERS CallParameters); typedef NDIS_STATUS -(DDKAPI *CM_ADD_PARTY_HANDLER)( +(NTAPI *CM_ADD_PARTY_HANDLER)( IN NDIS_HANDLE CallMgrVcContext, IN OUT PCO_CALL_PARAMETERS CallParameters, IN NDIS_HANDLE NdisPartyHandle, OUT PNDIS_HANDLE CallMgrPartyContext); typedef NDIS_STATUS -(DDKAPI *CM_CLOSE_AF_HANDLER)( +(NTAPI *CM_CLOSE_AF_HANDLER)( IN NDIS_HANDLE CallMgrAfContext); typedef NDIS_STATUS -(DDKAPI *CM_CLOSE_CALL_HANDLER)( +(NTAPI *CM_CLOSE_CALL_HANDLER)( IN NDIS_HANDLE CallMgrVcContext, IN NDIS_HANDLE CallMgrPartyContext OPTIONAL, IN PVOID CloseData OPTIONAL, IN UINT Size OPTIONAL); typedef NDIS_STATUS -(DDKAPI *CM_DEREG_SAP_HANDLER)( +(NTAPI *CM_DEREG_SAP_HANDLER)( IN NDIS_HANDLE CallMgrSapContext); typedef VOID -(DDKAPI *CM_DEACTIVATE_VC_COMPLETE_HANDLER)( +(NTAPI *CM_DEACTIVATE_VC_COMPLETE_HANDLER)( IN NDIS_STATUS Status, IN NDIS_HANDLE CallMgrVcContext); typedef NDIS_STATUS -(DDKAPI *CM_DROP_PARTY_HANDLER)( +(NTAPI *CM_DROP_PARTY_HANDLER)( IN NDIS_HANDLE CallMgrPartyContext, IN PVOID CloseData OPTIONAL, IN UINT Size OPTIONAL); typedef VOID -(DDKAPI *CM_INCOMING_CALL_COMPLETE_HANDLER)( +(NTAPI *CM_INCOMING_CALL_COMPLETE_HANDLER)( IN NDIS_STATUS Status, IN NDIS_HANDLE CallMgrVcContext, IN PCO_CALL_PARAMETERS CallParameters); typedef NDIS_STATUS -(DDKAPI *CM_MAKE_CALL_HANDLER)( +(NTAPI *CM_MAKE_CALL_HANDLER)( IN NDIS_HANDLE CallMgrVcContext, IN OUT PCO_CALL_PARAMETERS CallParameters, IN NDIS_HANDLE NdisPartyHandle OPTIONAL, OUT PNDIS_HANDLE CallMgrPartyContext OPTIONAL); typedef NDIS_STATUS -(DDKAPI *CM_MODIFY_CALL_QOS_HANDLER)( +(NTAPI *CM_MODIFY_CALL_QOS_HANDLER)( IN NDIS_HANDLE CallMgrVcContext, IN PCO_CALL_PARAMETERS CallParameters); typedef NDIS_STATUS -(DDKAPI *CM_OPEN_AF_HANDLER)( +(NTAPI *CM_OPEN_AF_HANDLER)( IN NDIS_HANDLE CallMgrBindingContext, IN PCO_ADDRESS_FAMILY AddressFamily, IN NDIS_HANDLE NdisAfHandle, OUT PNDIS_HANDLE CallMgrAfContext); typedef NDIS_STATUS -(DDKAPI *CM_REG_SAP_HANDLER)( +(NTAPI *CM_REG_SAP_HANDLER)( IN NDIS_HANDLE CallMgrAfContext, IN PCO_SAP Sap, IN NDIS_HANDLE NdisSapHandle, OUT PNDIS_HANDLE CallMgrSapContext); typedef NDIS_STATUS -(DDKAPI *CO_CREATE_VC_HANDLER)( +(NTAPI *CO_CREATE_VC_HANDLER)( IN NDIS_HANDLE ProtocolAfContext, IN NDIS_HANDLE NdisVcHandle, OUT PNDIS_HANDLE ProtocolVcContext); typedef NDIS_STATUS -(DDKAPI *CO_DELETE_VC_HANDLER)( +(NTAPI *CO_DELETE_VC_HANDLER)( IN NDIS_HANDLE ProtocolVcContext); typedef VOID -(DDKAPI *CO_REQUEST_COMPLETE_HANDLER)( +(NTAPI *CO_REQUEST_COMPLETE_HANDLER)( IN NDIS_STATUS Status, IN NDIS_HANDLE ProtocolAfContext OPTIONAL, IN NDIS_HANDLE ProtocolVcContext OPTIONAL, @@ -1146,7 +1146,7 @@ typedef VOID IN PNDIS_REQUEST NdisRequest); typedef NDIS_STATUS -(DDKAPI *CO_REQUEST_HANDLER)( +(NTAPI *CO_REQUEST_HANDLER)( IN NDIS_HANDLE ProtocolAfContext, IN NDIS_HANDLE ProtocolVcContext OPTIONAL, IN NDIS_HANDLE ProtocolPartyContext OPTIONAL, @@ -1185,80 +1185,80 @@ typedef VOID (*CL_OPEN_AF_COMPLETE_HANDLER)( IN NDIS_HANDLE NdisAfHandle); typedef VOID -(DDKAPI *CL_CLOSE_AF_COMPLETE_HANDLER)( +(NTAPI *CL_CLOSE_AF_COMPLETE_HANDLER)( IN NDIS_STATUS Status, IN NDIS_HANDLE ProtocolAfContext); typedef VOID -(DDKAPI *CL_REG_SAP_COMPLETE_HANDLER)( +(NTAPI *CL_REG_SAP_COMPLETE_HANDLER)( IN NDIS_STATUS Status, IN NDIS_HANDLE ProtocolSapContext, IN PCO_SAP Sap, IN NDIS_HANDLE NdisSapHandle); typedef VOID -(DDKAPI *CL_DEREG_SAP_COMPLETE_HANDLER)( +(NTAPI *CL_DEREG_SAP_COMPLETE_HANDLER)( IN NDIS_STATUS Status, IN NDIS_HANDLE ProtocolSapContext); typedef VOID -(DDKAPI *CL_MAKE_CALL_COMPLETE_HANDLER)( +(NTAPI *CL_MAKE_CALL_COMPLETE_HANDLER)( IN NDIS_STATUS Status, IN NDIS_HANDLE ProtocolVcContext, IN NDIS_HANDLE NdisPartyHandle OPTIONAL, IN PCO_CALL_PARAMETERS CallParameters); typedef VOID -(DDKAPI *CL_MODIFY_CALL_QOS_COMPLETE_HANDLER)( +(NTAPI *CL_MODIFY_CALL_QOS_COMPLETE_HANDLER)( IN NDIS_STATUS Status, IN NDIS_HANDLE ProtocolVcContext, IN PCO_CALL_PARAMETERS CallParameters); typedef VOID -(DDKAPI *CL_CLOSE_CALL_COMPLETE_HANDLER)( +(NTAPI *CL_CLOSE_CALL_COMPLETE_HANDLER)( IN NDIS_STATUS Status, IN NDIS_HANDLE ProtocolVcContext, IN NDIS_HANDLE ProtocolPartyContext OPTIONAL); typedef VOID -(DDKAPI *CL_ADD_PARTY_COMPLETE_HANDLER)( +(NTAPI *CL_ADD_PARTY_COMPLETE_HANDLER)( IN NDIS_STATUS Status, IN NDIS_HANDLE ProtocolPartyContext, IN NDIS_HANDLE NdisPartyHandle, IN PCO_CALL_PARAMETERS CallParameters); typedef VOID -(DDKAPI *CL_DROP_PARTY_COMPLETE_HANDLER)( +(NTAPI *CL_DROP_PARTY_COMPLETE_HANDLER)( IN NDIS_STATUS Status, IN NDIS_HANDLE ProtocolPartyContext); typedef NDIS_STATUS -(DDKAPI *CL_INCOMING_CALL_HANDLER)( +(NTAPI *CL_INCOMING_CALL_HANDLER)( IN NDIS_HANDLE ProtocolSapContext, IN NDIS_HANDLE ProtocolVcContext, IN OUT PCO_CALL_PARAMETERS CallParameters); typedef VOID -(DDKAPI *CL_INCOMING_CALL_QOS_CHANGE_HANDLER)( +(NTAPI *CL_INCOMING_CALL_QOS_CHANGE_HANDLER)( IN NDIS_HANDLE ProtocolVcContext, IN PCO_CALL_PARAMETERS CallParameters); typedef VOID -(DDKAPI *CL_INCOMING_CLOSE_CALL_HANDLER)( +(NTAPI *CL_INCOMING_CLOSE_CALL_HANDLER)( IN NDIS_STATUS CloseStatus, IN NDIS_HANDLE ProtocolVcContext, IN PVOID CloseData OPTIONAL, IN UINT Size OPTIONAL); typedef VOID -(DDKAPI *CL_INCOMING_DROP_PARTY_HANDLER)( +(NTAPI *CL_INCOMING_DROP_PARTY_HANDLER)( IN NDIS_STATUS DropStatus, IN NDIS_HANDLE ProtocolPartyContext, IN PVOID CloseData OPTIONAL, IN UINT Size OPTIONAL); typedef VOID -(DDKAPI *CL_CALL_CONNECTED_HANDLER)( +(NTAPI *CL_CALL_CONNECTED_HANDLER)( IN NDIS_HANDLE ProtocolVcContext); @@ -1293,64 +1293,64 @@ typedef struct _NDIS_CLIENT_CHARACTERISTICS { /* Prototypes for NDIS 3.0 protocol characteristics */ typedef VOID -(DDKAPI *OPEN_ADAPTER_COMPLETE_HANDLER)( +(NTAPI *OPEN_ADAPTER_COMPLETE_HANDLER)( IN NDIS_HANDLE ProtocolBindingContext, IN NDIS_STATUS Status, IN NDIS_STATUS OpenErrorStatus); typedef VOID -(DDKAPI *CLOSE_ADAPTER_COMPLETE_HANDLER)( +(NTAPI *CLOSE_ADAPTER_COMPLETE_HANDLER)( IN NDIS_HANDLE ProtocolBindingContext, IN NDIS_STATUS Status); typedef VOID -(DDKAPI *RESET_COMPLETE_HANDLER)( +(NTAPI *RESET_COMPLETE_HANDLER)( IN NDIS_HANDLE ProtocolBindingContext, IN NDIS_STATUS Status); typedef VOID -(DDKAPI *REQUEST_COMPLETE_HANDLER)( +(NTAPI *REQUEST_COMPLETE_HANDLER)( IN NDIS_HANDLE ProtocolBindingContext, IN PNDIS_REQUEST NdisRequest, IN NDIS_STATUS Status); typedef VOID -(DDKAPI *STATUS_HANDLER)( +(NTAPI *STATUS_HANDLER)( IN NDIS_HANDLE ProtocolBindingContext, IN NDIS_STATUS GeneralStatus, IN PVOID StatusBuffer, IN UINT StatusBufferSize); typedef VOID -(DDKAPI *STATUS_COMPLETE_HANDLER)( +(NTAPI *STATUS_COMPLETE_HANDLER)( IN NDIS_HANDLE ProtocolBindingContext); typedef VOID -(DDKAPI *SEND_COMPLETE_HANDLER)( +(NTAPI *SEND_COMPLETE_HANDLER)( IN NDIS_HANDLE ProtocolBindingContext, IN PNDIS_PACKET Packet, IN NDIS_STATUS Status); typedef VOID -(DDKAPI *WAN_SEND_COMPLETE_HANDLER)( +(NTAPI *WAN_SEND_COMPLETE_HANDLER)( IN NDIS_HANDLE ProtocolBindingContext, IN PNDIS_WAN_PACKET Packet, IN NDIS_STATUS Status); typedef VOID -(DDKAPI *TRANSFER_DATA_COMPLETE_HANDLER)( +(NTAPI *TRANSFER_DATA_COMPLETE_HANDLER)( IN NDIS_HANDLE ProtocolBindingContext, IN PNDIS_PACKET Packet, IN NDIS_STATUS Status, IN UINT BytesTransferred); typedef VOID -(DDKAPI *WAN_TRANSFER_DATA_COMPLETE_HANDLER)( +(NTAPI *WAN_TRANSFER_DATA_COMPLETE_HANDLER)( VOID); typedef NDIS_STATUS -(DDKAPI *RECEIVE_HANDLER)( +(NTAPI *RECEIVE_HANDLER)( IN NDIS_HANDLE ProtocolBindingContext, IN NDIS_HANDLE MacReceiveContext, IN PVOID HeaderBuffer, @@ -1360,13 +1360,13 @@ typedef NDIS_STATUS IN UINT PacketSize); typedef NDIS_STATUS -(DDKAPI *WAN_RECEIVE_HANDLER)( +(NTAPI *WAN_RECEIVE_HANDLER)( IN NDIS_HANDLE NdisLinkHandle, IN PUCHAR Packet, IN ULONG PacketSize); typedef VOID -(DDKAPI *RECEIVE_COMPLETE_HANDLER)( +(NTAPI *RECEIVE_COMPLETE_HANDLER)( IN NDIS_HANDLE ProtocolBindingContext); @@ -1409,12 +1409,12 @@ typedef struct _NDIS30_PROTOCOL_CHARACTERISTICS { /* Prototypes for NDIS 4.0 protocol characteristics */ typedef INT -(DDKAPI *RECEIVE_PACKET_HANDLER)( +(NTAPI *RECEIVE_PACKET_HANDLER)( IN NDIS_HANDLE ProtocolBindingContext, IN PNDIS_PACKET Packet); typedef VOID -(DDKAPI *BIND_HANDLER)( +(NTAPI *BIND_HANDLER)( OUT PNDIS_STATUS Status, IN NDIS_HANDLE BindContext, IN PNDIS_STRING DeviceName, @@ -1422,18 +1422,18 @@ typedef VOID IN PVOID SystemSpecific2); typedef VOID -(DDKAPI *UNBIND_HANDLER)( +(NTAPI *UNBIND_HANDLER)( OUT PNDIS_STATUS Status, IN NDIS_HANDLE ProtocolBindingContext, IN NDIS_HANDLE UnbindContext); typedef NDIS_STATUS -(DDKAPI *PNP_EVENT_HANDLER)( +(NTAPI *PNP_EVENT_HANDLER)( IN NDIS_HANDLE ProtocolBindingContext, IN PNET_PNP_EVENT NetPnPEvent); typedef VOID -(DDKAPI *UNLOAD_PROTOCOL_HANDLER)( +(NTAPI *UNLOAD_PROTOCOL_HANDLER)( VOID); @@ -1468,13 +1468,13 @@ typedef struct _NDIS40_PROTOCOL_CHARACTERISTICS { /* Prototypes for NDIS 5.0 protocol characteristics */ typedef VOID -(DDKAPI *CO_SEND_COMPLETE_HANDLER)( +(NTAPI *CO_SEND_COMPLETE_HANDLER)( IN NDIS_STATUS Status, IN NDIS_HANDLE ProtocolVcContext, IN PNDIS_PACKET Packet); typedef VOID -(DDKAPI *CO_STATUS_HANDLER)( +(NTAPI *CO_STATUS_HANDLER)( IN NDIS_HANDLE ProtocolBindingContext, IN NDIS_HANDLE ProtocolVcContext OPTIONAL, IN NDIS_STATUS GeneralStatus, @@ -1482,13 +1482,13 @@ typedef VOID IN UINT StatusBufferSize); typedef UINT -(DDKAPI *CO_RECEIVE_PACKET_HANDLER)( +(NTAPI *CO_RECEIVE_PACKET_HANDLER)( IN NDIS_HANDLE ProtocolBindingContext, IN NDIS_HANDLE ProtocolVcContext, IN PNDIS_PACKET Packet); typedef VOID -(DDKAPI *CO_AF_REGISTER_NOTIFY_HANDLER)( +(NTAPI *CO_AF_REGISTER_NOTIFY_HANDLER)( IN NDIS_HANDLE ProtocolBindingContext, IN PCO_ADDRESS_FAMILY AddressFamily); @@ -1538,7 +1538,7 @@ typedef struct _NDIS_PROTOCOL_CHARACTERISTICS { NDISAPI VOID -DDKAPI +NTAPI NdisAllocateBuffer( OUT PNDIS_STATUS Status, OUT PNDIS_BUFFER *Buffer, @@ -1549,7 +1549,7 @@ NdisAllocateBuffer( NDISAPI VOID -DDKAPI +NTAPI NdisAllocateBufferPool( OUT PNDIS_STATUS Status, OUT PNDIS_HANDLE PoolHandle, @@ -1557,7 +1557,7 @@ NdisAllocateBufferPool( NDISAPI VOID -DDKAPI +NTAPI NdisAllocatePacket( OUT PNDIS_STATUS Status, OUT PNDIS_PACKET *Packet, @@ -1565,7 +1565,7 @@ NdisAllocatePacket( NDISAPI VOID -DDKAPI +NTAPI NdisAllocatePacketPool( OUT PNDIS_STATUS Status, OUT PNDIS_HANDLE PoolHandle, @@ -1574,7 +1574,7 @@ NdisAllocatePacketPool( NDISAPI VOID -DDKAPI +NTAPI NdisCopyBuffer( OUT PNDIS_STATUS Status, OUT PNDIS_BUFFER *Buffer, @@ -1585,7 +1585,7 @@ NdisCopyBuffer( NDISAPI VOID -DDKAPI +NTAPI NdisCopyFromPacketToPacket( IN PNDIS_PACKET Destination, IN UINT DestinationOffset, @@ -1626,7 +1626,7 @@ NdisCopyFromPacketToPacket( NDISAPI VOID -DDKAPI +NTAPI NdisDprAllocatePacket( OUT PNDIS_STATUS Status, OUT PNDIS_PACKET *Packet, @@ -1634,7 +1634,7 @@ NdisDprAllocatePacket( NDISAPI VOID -DDKAPI +NTAPI NdisDprAllocatePacketNonInterlocked( OUT PNDIS_STATUS Status, OUT PNDIS_PACKET *Packet, @@ -1642,96 +1642,96 @@ NdisDprAllocatePacketNonInterlocked( NDISAPI VOID -DDKAPI +NTAPI NdisDprFreePacket( IN PNDIS_PACKET Packet); NDISAPI VOID -DDKAPI +NTAPI NdisDprFreePacketNonInterlocked( IN PNDIS_PACKET Packet); NDISAPI VOID -DDKAPI +NTAPI NdisFreeBufferPool( IN NDIS_HANDLE PoolHandle); NDISAPI VOID -DDKAPI +NTAPI NdisFreePacket( IN PNDIS_PACKET Packet); NDISAPI VOID -DDKAPI +NTAPI NdisFreePacketPool( IN NDIS_HANDLE PoolHandle); NDISAPI VOID -DDKAPI +NTAPI NdisReturnPackets( IN PNDIS_PACKET *PacketsToReturn, IN UINT NumberOfPackets); NDISAPI VOID -DDKAPI +NTAPI NdisUnchainBufferAtBack( IN OUT PNDIS_PACKET Packet, OUT PNDIS_BUFFER *Buffer); NDISAPI VOID -DDKAPI +NTAPI NdisUnchainBufferAtFront( IN OUT PNDIS_PACKET Packet, OUT PNDIS_BUFFER *Buffer); NDISAPI VOID -DDKAPI +NTAPI NdisAdjustBufferLength( IN PNDIS_BUFFER Buffer, IN UINT Length); NDISAPI ULONG -DDKAPI +NTAPI NdisBufferLength( IN PNDIS_BUFFER Buffer); NDISAPI PVOID -DDKAPI +NTAPI NdisBufferVirtualAddress( IN PNDIS_BUFFER Buffer); NDISAPI ULONG -DDKAPI +NTAPI NDIS_BUFFER_TO_SPAN_PAGES( IN PNDIS_BUFFER Buffer); NDISAPI VOID -DDKAPI +NTAPI NdisFreeBuffer( IN PNDIS_BUFFER Buffer); NDISAPI VOID -DDKAPI +NTAPI NdisGetBufferPhysicalArraySize( IN PNDIS_BUFFER Buffer, OUT PUINT ArraySize); NDISAPI VOID -DDKAPI +NTAPI NdisGetFirstBufferFromPacket( IN PNDIS_PACKET _Packet, OUT PNDIS_BUFFER *_FirstBuffer, @@ -1741,7 +1741,7 @@ NdisGetFirstBufferFromPacket( NDISAPI VOID -DDKAPI +NTAPI NdisQueryBuffer( IN PNDIS_BUFFER Buffer, OUT PVOID *VirtualAddress OPTIONAL, @@ -1749,7 +1749,7 @@ NdisQueryBuffer( NDISAPI VOID -DDKAPI +NTAPI NdisQueryBufferOffset( IN PNDIS_BUFFER Buffer, OUT PUINT Offset, @@ -2152,7 +2152,7 @@ NdisQueryPacketLength( NDISAPI VOID -DDKAPI +NTAPI NdisCreateLookaheadBufferFromSharedMemory( IN PVOID pSharedMemory, IN UINT LookaheadLength, @@ -2160,7 +2160,7 @@ NdisCreateLookaheadBufferFromSharedMemory( NDISAPI VOID -DDKAPI +NTAPI NdisDestroyLookaheadBufferFromSharedMemory( IN PVOID pLookaheadBuffer); @@ -2236,7 +2236,7 @@ NdisDestroyLookaheadBufferFromSharedMemory( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisAllocateMemory( OUT PVOID *VirtualAddress, IN UINT Length, @@ -2245,7 +2245,7 @@ NdisAllocateMemory( NDISAPI VOID -DDKAPI +NTAPI NdisFreeMemory( IN PVOID VirtualAddress, IN UINT Length, @@ -2253,7 +2253,7 @@ NdisFreeMemory( NDISAPI VOID -DDKAPI +NTAPI NdisImmediateReadSharedMemory( IN NDIS_HANDLE WrapperConfigurationContext, IN ULONG SharedMemoryAddress, @@ -2262,7 +2262,7 @@ NdisImmediateReadSharedMemory( NDISAPI VOID -DDKAPI +NTAPI NdisImmediateWriteSharedMemory( IN NDIS_HANDLE WrapperConfigurationContext, IN ULONG SharedMemoryAddress, @@ -2271,7 +2271,7 @@ NdisImmediateWriteSharedMemory( NDISAPI VOID -DDKAPI +NTAPI NdisMAllocateSharedMemory( IN NDIS_HANDLE MiniportAdapterHandle, IN ULONG Length, @@ -2281,7 +2281,7 @@ NdisMAllocateSharedMemory( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisMAllocateSharedMemoryAsync( IN NDIS_HANDLE MiniportAdapterHandle, IN ULONG Length, @@ -2299,7 +2299,7 @@ NdisMAllocateSharedMemoryAsync( NDISAPI VOID -DDKAPI +NTAPI NdisUpdateSharedMemory( IN NDIS_HANDLE NdisAdapterHandle, IN ULONG Length, @@ -2413,7 +2413,7 @@ NdisUpdateSharedMemory( RtlZeroMemory(Destination, Length) typedef VOID -(DDKAPI *NDIS_BLOCK_INITIALIZER) ( +(NTAPI *NDIS_BLOCK_INITIALIZER) ( IN PUCHAR Block, IN SIZE_T NumberOfBytes ); @@ -2422,7 +2422,7 @@ typedef VOID NDISAPI VOID -DDKAPI +NTAPI NdisOpenConfiguration( OUT PNDIS_STATUS Status, OUT PNDIS_HANDLE ConfigurationHandle, @@ -2430,7 +2430,7 @@ NdisOpenConfiguration( NDISAPI VOID -DDKAPI +NTAPI NdisReadNetworkAddress( OUT PNDIS_STATUS Status, OUT PVOID *NetworkAddress, @@ -2439,7 +2439,7 @@ NdisReadNetworkAddress( NDISAPI VOID -DDKAPI +NTAPI NdisReadEisaSlotInformation( OUT PNDIS_STATUS Status, IN NDIS_HANDLE WrapperConfigurationContext, @@ -2448,7 +2448,7 @@ NdisReadEisaSlotInformation( NDISAPI VOID -DDKAPI +NTAPI NdisReadEisaSlotInformationEx( OUT PNDIS_STATUS Status, IN NDIS_HANDLE WrapperConfigurationContext, @@ -2458,7 +2458,7 @@ NdisReadEisaSlotInformationEx( NDISAPI ULONG -DDKAPI +NTAPI NdisReadPciSlotInformation( IN NDIS_HANDLE NdisAdapterHandle, IN ULONG SlotNumber, @@ -2468,7 +2468,7 @@ NdisReadPciSlotInformation( NDISAPI ULONG -DDKAPI +NTAPI NdisWritePciSlotInformation( IN NDIS_HANDLE NdisAdapterHandle, IN ULONG SlotNumber, @@ -2482,7 +2482,7 @@ NdisWritePciSlotInformation( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisAnsiStringToUnicodeString( IN OUT PNDIS_STRING DestinationString, IN PNDIS_ANSI_STRING SourceString); @@ -2499,21 +2499,21 @@ NdisAnsiStringToUnicodeString( NDISAPI VOID -DDKAPI +NTAPI NdisInitAnsiString( IN OUT PNDIS_ANSI_STRING DestinationString, IN PCSTR SourceString); NDISAPI VOID -DDKAPI +NTAPI NdisInitUnicodeString( IN OUT PNDIS_STRING DestinationString, IN PCWSTR SourceString); NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisUnicodeStringToAnsiString( IN OUT PNDIS_ANSI_STRING DestinationString, IN PNDIS_STRING SourceString); @@ -2526,37 +2526,37 @@ NdisUnicodeStringToAnsiString( NDISAPI VOID -DDKAPI +NTAPI NdisAllocateSpinLock( IN PNDIS_SPIN_LOCK SpinLock); NDISAPI VOID -DDKAPI +NTAPI NdisFreeSpinLock( IN PNDIS_SPIN_LOCK SpinLock); NDISAPI VOID -DDKAPI +NTAPI NdisAcquireSpinLock( IN PNDIS_SPIN_LOCK SpinLock); NDISAPI VOID -DDKAPI +NTAPI NdisReleaseSpinLock( IN PNDIS_SPIN_LOCK SpinLock); NDISAPI VOID -DDKAPI +NTAPI NdisDprAcquireSpinLock( IN PNDIS_SPIN_LOCK SpinLock); NDISAPI VOID -DDKAPI +NTAPI NdisDprReleaseSpinLock( IN PNDIS_SPIN_LOCK SpinLock); @@ -2821,13 +2821,13 @@ NdisDprReleaseSpinLock( NDISAPI VOID -DDKAPI +NTAPI NdisCloseConfiguration( IN NDIS_HANDLE ConfigurationHandle); NDISAPI VOID -DDKAPI +NTAPI NdisReadConfiguration( OUT PNDIS_STATUS Status, OUT PNDIS_CONFIGURATION_PARAMETER *ParameterValue, @@ -2837,7 +2837,7 @@ NdisReadConfiguration( NDISAPI VOID -DDKAPI +NTAPI NdisWriteConfiguration( OUT PNDIS_STATUS Status, IN NDIS_HANDLE WrapperConfigurationContext, @@ -2846,7 +2846,7 @@ NdisWriteConfiguration( NDISAPI VOID -DDKCDECLAPI +__cdecl NdisWriteErrorLogEntry( IN NDIS_HANDLE NdisAdapterHandle, IN NDIS_ERROR_CODE ErrorCode, @@ -2862,18 +2862,18 @@ NdisWriteErrorLogEntry( NDISAPI VOID -DDKAPI +NTAPI NdisGetCurrentSystemTime( IN PLARGE_INTEGER pSystemTime); NDISAPI CCHAR -DDKAPI +NTAPI NdisSystemProcessorCount(VOID); NDISAPI VOID -DDKAPI +NTAPI NdisGetCurrentProcessorCpuUsage( OUT PULONG pCpuUsage); @@ -2902,7 +2902,7 @@ NdisGetCurrentProcessorCpuUsage( NDISAPI VOID -DDKAPI +NTAPI NdisMFreeSharedMemory( IN NDIS_HANDLE MiniportAdapterHandle, IN ULONG Length, @@ -2912,7 +2912,7 @@ NdisMFreeSharedMemory( NDISAPI VOID -DDKAPI +NTAPI NdisMWanIndicateReceive( OUT PNDIS_STATUS Status, IN NDIS_HANDLE MiniportAdapterHandle, @@ -2922,13 +2922,13 @@ NdisMWanIndicateReceive( NDISAPI VOID -DDKAPI +NTAPI NdisMWanIndicateReceiveComplete( IN NDIS_HANDLE MiniportAdapterHandle); NDISAPI VOID -DDKAPI +NTAPI NdisMWanSendComplete( IN NDIS_HANDLE MiniportAdapterHandle, IN PNDIS_WAN_PACKET Packet, @@ -2936,7 +2936,7 @@ NdisMWanSendComplete( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisPciAssignResources( IN NDIS_HANDLE NdisMacHandle, IN NDIS_HANDLE NdisWrapperHandle, @@ -2949,7 +2949,7 @@ NdisPciAssignResources( NDISAPI VOID -DDKAPI +NTAPI NdisAcquireReadWriteLock( IN PNDIS_RW_LOCK Lock, IN BOOLEAN fWrite, @@ -2957,7 +2957,7 @@ NdisAcquireReadWriteLock( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisAllocateMemoryWithTag( OUT PVOID *VirtualAddress, IN UINT Length, @@ -2965,7 +2965,7 @@ NdisAllocateMemoryWithTag( NDISAPI VOID -DDKAPI +NTAPI NdisAllocatePacketPoolEx( OUT PNDIS_STATUS Status, OUT PNDIS_HANDLE PoolHandle, @@ -2975,7 +2975,7 @@ NdisAllocatePacketPoolEx( NDISAPI VOID -DDKAPI +NTAPI NdisCompletePnPEvent( IN NDIS_STATUS Status, IN NDIS_HANDLE NdisBindingHandle, @@ -2983,7 +2983,7 @@ NdisCompletePnPEvent( NDISAPI VOID -DDKAPI +NTAPI NdisGetCurrentProcessorCounts( OUT PULONG pIdleCount, OUT PULONG pKernelAndUser, @@ -2991,39 +2991,39 @@ NdisGetCurrentProcessorCounts( NDISAPI VOID -DDKAPI +NTAPI NdisGetDriverHandle( IN PNDIS_HANDLE NdisBindingHandle, OUT PNDIS_HANDLE NdisDriverHandle); NDISAPI PNDIS_PACKET -DDKAPI +NTAPI NdisGetReceivedPacket( IN PNDIS_HANDLE NdisBindingHandle, IN PNDIS_HANDLE MacContext); NDISAPI VOID -DDKAPI +NTAPI NdisGetSystemUpTime( OUT PULONG pSystemUpTime); NDISAPI VOID -DDKAPI +NTAPI NdisInitializeReadWriteLock( IN PNDIS_RW_LOCK Lock); NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisMDeregisterDevice( IN NDIS_HANDLE NdisDeviceHandle); NDISAPI VOID -DDKAPI +NTAPI NdisMGetDeviceProperty( IN NDIS_HANDLE MiniportAdapterHandle, IN OUT PDEVICE_OBJECT *PhysicalDeviceObject OPTIONAL, @@ -3034,7 +3034,7 @@ NdisMGetDeviceProperty( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisMInitializeScatterGatherDma( IN NDIS_HANDLE MiniportAdapterHandle, IN BOOLEAN Dma64BitAddresses, @@ -3042,20 +3042,20 @@ NdisMInitializeScatterGatherDma( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisMPromoteMiniport( IN NDIS_HANDLE MiniportAdapterHandle); NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisMQueryAdapterInstanceName( OUT PNDIS_STRING AdapterInstanceName, IN NDIS_HANDLE MiniportAdapterHandle); NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisMRegisterDevice( IN NDIS_HANDLE NdisWrapperHandle, IN PNDIS_STRING DeviceName, @@ -3066,27 +3066,27 @@ NdisMRegisterDevice( NDISAPI VOID -DDKAPI +NTAPI NdisMRegisterUnloadHandler( IN NDIS_HANDLE NdisWrapperHandle, IN PDRIVER_UNLOAD UnloadHandler); NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisMRemoveMiniport( IN NDIS_HANDLE MiniportAdapterHandle); NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisMSetMiniportSecondary( IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_HANDLE PrimaryMiniportAdapterHandle); NDISAPI VOID -DDKAPI +NTAPI NdisOpenConfigurationKeyByIndex( OUT PNDIS_STATUS Status, IN NDIS_HANDLE ConfigurationHandle, @@ -3096,7 +3096,7 @@ NdisOpenConfigurationKeyByIndex( NDISAPI VOID -DDKAPI +NTAPI NdisOpenConfigurationKeyByName( OUT PNDIS_STATUS Status, IN NDIS_HANDLE ConfigurationHandle, @@ -3105,20 +3105,20 @@ NdisOpenConfigurationKeyByName( NDISAPI UINT -DDKAPI +NTAPI NdisPacketPoolUsage( IN NDIS_HANDLE PoolHandle); NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisQueryAdapterInstanceName( OUT PNDIS_STRING AdapterInstanceName, IN NDIS_HANDLE NdisBindingHandle); NDISAPI ULONG -DDKAPI +NTAPI NdisReadPcmciaAttributeMemory( IN NDIS_HANDLE NdisAdapterHandle, IN ULONG Offset, @@ -3127,14 +3127,14 @@ NdisReadPcmciaAttributeMemory( NDISAPI VOID -DDKAPI +NTAPI NdisReleaseReadWriteLock( IN PNDIS_RW_LOCK Lock, IN PLOCK_STATE LockState); NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisWriteEventLogEntry( IN PVOID LogHandle, IN NDIS_STATUS EventCode, @@ -3146,7 +3146,7 @@ NdisWriteEventLogEntry( NDISAPI ULONG -DDKAPI +NTAPI NdisWritePcmciaAttributeMemory( IN NDIS_HANDLE NdisAdapterHandle, IN ULONG Offset, @@ -3158,7 +3158,7 @@ NdisWritePcmciaAttributeMemory( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisClAddParty( IN NDIS_HANDLE NdisVcHandle, IN NDIS_HANDLE ProtocolPartyContext, @@ -3167,13 +3167,13 @@ NdisClAddParty( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisClCloseAddressFamily( IN NDIS_HANDLE NdisAfHandle); NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisClCloseCall( IN NDIS_HANDLE NdisVcHandle, IN NDIS_HANDLE NdisPartyHandle OPTIONAL, @@ -3182,13 +3182,13 @@ NdisClCloseCall( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisClDeregisterSap( IN NDIS_HANDLE NdisSapHandle); NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisClDropParty( IN NDIS_HANDLE NdisPartyHandle, IN PVOID Buffer OPTIONAL, @@ -3196,7 +3196,7 @@ NdisClDropParty( NDISAPI VOID -DDKAPI +NTAPI NdisClIncomingCallComplete( IN NDIS_STATUS Status, IN NDIS_HANDLE NdisVcHandle, @@ -3204,7 +3204,7 @@ NdisClIncomingCallComplete( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisClMakeCall( IN NDIS_HANDLE NdisVcHandle, IN OUT PCO_CALL_PARAMETERS CallParameters, @@ -3213,7 +3213,7 @@ NdisClMakeCall( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisClModifyCallQoS( IN NDIS_HANDLE NdisVcHandle, IN PCO_CALL_PARAMETERS CallParameters); @@ -3221,7 +3221,7 @@ NdisClModifyCallQoS( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisClOpenAddressFamily( IN NDIS_HANDLE NdisBindingHandle, IN PCO_ADDRESS_FAMILY AddressFamily, @@ -3232,7 +3232,7 @@ NdisClOpenAddressFamily( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisClRegisterSap( IN NDIS_HANDLE NdisAfHandle, IN NDIS_HANDLE ProtocolSapContext, @@ -3244,14 +3244,14 @@ NdisClRegisterSap( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisCmActivateVc( IN NDIS_HANDLE NdisVcHandle, IN OUT PCO_CALL_PARAMETERS CallParameters); NDISAPI VOID -DDKAPI +NTAPI NdisCmAddPartyComplete( IN NDIS_STATUS Status, IN NDIS_HANDLE NdisPartyHandle, @@ -3260,14 +3260,14 @@ NdisCmAddPartyComplete( NDISAPI VOID -DDKAPI +NTAPI NdisCmCloseAddressFamilyComplete( IN NDIS_STATUS Status, IN NDIS_HANDLE NdisAfHandle); NDISAPI VOID -DDKAPI +NTAPI NdisCmCloseCallComplete( IN NDIS_STATUS Status, IN NDIS_HANDLE NdisVcHandle, @@ -3275,26 +3275,26 @@ NdisCmCloseCallComplete( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisCmDeactivateVc( IN NDIS_HANDLE NdisVcHandle); NDISAPI VOID -DDKAPI +NTAPI NdisCmDeregisterSapComplete( IN NDIS_STATUS Status, IN NDIS_HANDLE NdisSapHandle); NDISAPI VOID -DDKAPI +NTAPI NdisCmDispatchCallConnected( IN NDIS_HANDLE NdisVcHandle); NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisCmDispatchIncomingCall( IN NDIS_HANDLE NdisSapHandle, IN NDIS_HANDLE NdisVcHandle, @@ -3302,14 +3302,14 @@ NdisCmDispatchIncomingCall( NDISAPI VOID -DDKAPI +NTAPI NdisCmDispatchIncomingCallQoSChange( IN NDIS_HANDLE NdisVcHandle, IN PCO_CALL_PARAMETERS CallParameters); NDISAPI VOID -DDKAPI +NTAPI NdisCmDispatchIncomingCloseCall( IN NDIS_STATUS CloseStatus, IN NDIS_HANDLE NdisVcHandle, @@ -3318,7 +3318,7 @@ NdisCmDispatchIncomingCloseCall( NDISAPI VOID -DDKAPI +NTAPI NdisCmDispatchIncomingDropParty( IN NDIS_STATUS DropStatus, IN NDIS_HANDLE NdisPartyHandle, @@ -3327,14 +3327,14 @@ NdisCmDispatchIncomingDropParty( NDISAPI VOID -DDKAPI +NTAPI NdisCmDropPartyComplete( IN NDIS_STATUS Status, IN NDIS_HANDLE NdisPartyHandle); NDISAPI VOID -DDKAPI +NTAPI NdisCmMakeCallComplete( IN NDIS_STATUS Status, IN NDIS_HANDLE NdisVcHandle, @@ -3344,7 +3344,7 @@ NdisCmMakeCallComplete( NDISAPI VOID -DDKAPI +NTAPI NdisCmModifyCallQoSComplete( IN NDIS_STATUS Status, IN NDIS_HANDLE NdisVcHandle, @@ -3352,7 +3352,7 @@ NdisCmModifyCallQoSComplete( NDISAPI VOID -DDKAPI +NTAPI NdisCmOpenAddressFamilyComplete( IN NDIS_STATUS Status, IN NDIS_HANDLE NdisAfHandle, @@ -3360,7 +3360,7 @@ NdisCmOpenAddressFamilyComplete( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisCmRegisterAddressFamily( IN NDIS_HANDLE NdisBindingHandle, IN PCO_ADDRESS_FAMILY AddressFamily, @@ -3369,7 +3369,7 @@ NdisCmRegisterAddressFamily( NDISAPI VOID -DDKAPI +NTAPI NdisCmRegisterSapComplete( IN NDIS_STATUS Status, IN NDIS_HANDLE NdisSapHandle, @@ -3378,14 +3378,14 @@ NdisCmRegisterSapComplete( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisMCmActivateVc( IN NDIS_HANDLE NdisVcHandle, IN PCO_CALL_PARAMETERS CallParameters); NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisMCmCreateVc( IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_HANDLE NdisAfHandle, @@ -3394,19 +3394,19 @@ NdisMCmCreateVc( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisMCmDeactivateVc( IN NDIS_HANDLE NdisVcHandle); NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisMCmDeleteVc( IN NDIS_HANDLE NdisVcHandle); NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisMCmRegisterAddressFamily( IN NDIS_HANDLE MiniportAdapterHandle, IN PCO_ADDRESS_FAMILY AddressFamily, @@ -3415,7 +3415,7 @@ NdisMCmRegisterAddressFamily( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisMCmRequest( IN NDIS_HANDLE NdisAfHandle, IN NDIS_HANDLE NdisVcHandle OPTIONAL, @@ -3427,7 +3427,7 @@ NdisMCmRequest( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisCoCreateVc( IN NDIS_HANDLE NdisBindingHandle, IN NDIS_HANDLE NdisAfHandle OPTIONAL, @@ -3436,13 +3436,13 @@ NdisCoCreateVc( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisCoDeleteVc( IN NDIS_HANDLE NdisVcHandle); NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisCoRequest( IN NDIS_HANDLE NdisBindingHandle, IN NDIS_HANDLE NdisAfHandle OPTIONAL, @@ -3452,7 +3452,7 @@ NdisCoRequest( NDISAPI VOID -DDKAPI +NTAPI NdisCoRequestComplete( IN NDIS_STATUS Status, IN NDIS_HANDLE NdisAfHandle, @@ -3462,7 +3462,7 @@ NdisCoRequestComplete( NDISAPI VOID -DDKAPI +NTAPI NdisCoSendPackets( IN NDIS_HANDLE NdisVcHandle, IN PPNDIS_PACKET PacketArray, @@ -3470,7 +3470,7 @@ NdisCoSendPackets( NDISAPI VOID -DDKAPI +NTAPI NdisMCoActivateVcComplete( IN NDIS_STATUS Status, IN NDIS_HANDLE NdisVcHandle, @@ -3478,14 +3478,14 @@ NdisMCoActivateVcComplete( NDISAPI VOID -DDKAPI +NTAPI NdisMCoDeactivateVcComplete( IN NDIS_STATUS Status, IN NDIS_HANDLE NdisVcHandle); NDISAPI VOID -DDKAPI +NTAPI NdisMCoIndicateReceivePacket( IN NDIS_HANDLE NdisVcHandle, IN PPNDIS_PACKET PacketArray, @@ -3493,7 +3493,7 @@ NdisMCoIndicateReceivePacket( NDISAPI VOID -DDKAPI +NTAPI NdisMCoIndicateStatus( IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_HANDLE NdisVcHandle OPTIONAL, @@ -3503,13 +3503,13 @@ NdisMCoIndicateStatus( NDISAPI VOID -DDKAPI +NTAPI NdisMCoReceiveComplete( IN NDIS_HANDLE MiniportAdapterHandle); NDISAPI VOID -DDKAPI +NTAPI NdisMCoRequestComplete( IN NDIS_STATUS Status, IN NDIS_HANDLE MiniportAdapterHandle, @@ -3517,7 +3517,7 @@ NdisMCoRequestComplete( NDISAPI VOID -DDKAPI +NTAPI NdisMCoSendComplete( IN NDIS_STATUS Status, IN NDIS_HANDLE NdisVcHandle, @@ -3528,53 +3528,53 @@ NdisMCoSendComplete( NDISAPI VOID -DDKAPI +NTAPI NdisIMAssociateMiniport( IN NDIS_HANDLE DriverHandle, IN NDIS_HANDLE ProtocolHandle); NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisIMCancelInitializeDeviceInstance( IN NDIS_HANDLE DriverHandle, IN PNDIS_STRING DeviceInstance); NDISAPI VOID -DDKAPI +NTAPI NdisIMCopySendCompletePerPacketInfo( IN PNDIS_PACKET DstPacket, IN PNDIS_PACKET SrcPacket); NDISAPI VOID -DDKAPI +NTAPI NdisIMCopySendPerPacketInfo( IN PNDIS_PACKET DstPacket, IN PNDIS_PACKET SrcPacket); NDISAPI VOID -DDKAPI +NTAPI NdisIMDeregisterLayeredMiniport( IN NDIS_HANDLE DriverHandle); NDISAPI NDIS_HANDLE -DDKAPI +NTAPI NdisIMGetBindingContext( IN NDIS_HANDLE NdisBindingHandle); NDISAPI NDIS_HANDLE -DDKAPI +NTAPI NdisIMGetDeviceContext( IN NDIS_HANDLE MiniportAdapterHandle); NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisIMInitializeDeviceInstanceEx( IN NDIS_HANDLE DriverHandle, IN PNDIS_STRING DriverInstance, @@ -3582,14 +3582,14 @@ NdisIMInitializeDeviceInstanceEx( NDISAPI PSINGLE_LIST_ENTRY -DDKAPI +NTAPI NdisInterlockedPopEntrySList( IN PSLIST_HEADER ListHead, IN PKSPIN_LOCK Lock); NDISAPI PSINGLE_LIST_ENTRY -DDKAPI +NTAPI NdisInterlockedPushEntrySList( IN PSLIST_HEADER ListHead, IN PSINGLE_LIST_ENTRY ListEntry, @@ -3597,7 +3597,7 @@ NdisInterlockedPushEntrySList( NDISAPI VOID -DDKAPI +NTAPI NdisQueryBufferSafe( IN PNDIS_BUFFER Buffer, OUT PVOID *VirtualAddress OPTIONAL, @@ -3607,27 +3607,27 @@ NdisQueryBufferSafe( /* Prototypes for NDIS_MINIPORT_CHARACTERISTICS */ typedef BOOLEAN -(DDKAPI *W_CHECK_FOR_HANG_HANDLER)( +(NTAPI *W_CHECK_FOR_HANG_HANDLER)( IN NDIS_HANDLE MiniportAdapterContext); typedef VOID -(DDKAPI *W_DISABLE_INTERRUPT_HANDLER)( +(NTAPI *W_DISABLE_INTERRUPT_HANDLER)( IN NDIS_HANDLE MiniportAdapterContext); typedef VOID -(DDKAPI *W_ENABLE_INTERRUPT_HANDLER)( +(NTAPI *W_ENABLE_INTERRUPT_HANDLER)( IN NDIS_HANDLE MiniportAdapterContext); typedef VOID -(DDKAPI *W_HALT_HANDLER)( +(NTAPI *W_HALT_HANDLER)( IN NDIS_HANDLE MiniportAdapterContext); typedef VOID -(DDKAPI *W_HANDLE_INTERRUPT_HANDLER)( +(NTAPI *W_HANDLE_INTERRUPT_HANDLER)( IN NDIS_HANDLE MiniportAdapterContext); typedef NDIS_STATUS -(DDKAPI *W_INITIALIZE_HANDLER)( +(NTAPI *W_INITIALIZE_HANDLER)( OUT PNDIS_STATUS OpenErrorStatus, OUT PUINT SelectedMediumIndex, IN PNDIS_MEDIUM MediumArray, @@ -3636,13 +3636,13 @@ typedef NDIS_STATUS IN NDIS_HANDLE WrapperConfigurationContext); typedef VOID -(DDKAPI *W_ISR_HANDLER)( +(NTAPI *W_ISR_HANDLER)( OUT PBOOLEAN InterruptRecognized, OUT PBOOLEAN QueueMiniportHandleInterrupt, IN NDIS_HANDLE MiniportAdapterContext); typedef NDIS_STATUS -(DDKAPI *W_QUERY_INFORMATION_HANDLER)( +(NTAPI *W_QUERY_INFORMATION_HANDLER)( IN NDIS_HANDLE MiniportAdapterContext, IN NDIS_OID Oid, IN PVOID InformationBuffer, @@ -3651,30 +3651,30 @@ typedef NDIS_STATUS OUT PULONG BytesNeeded); typedef NDIS_STATUS -(DDKAPI *W_RECONFIGURE_HANDLER)( +(NTAPI *W_RECONFIGURE_HANDLER)( OUT PNDIS_STATUS OpenErrorStatus, IN NDIS_HANDLE MiniportAdapterContext, IN NDIS_HANDLE WrapperConfigurationContext); typedef NDIS_STATUS -(DDKAPI *W_RESET_HANDLER)( +(NTAPI *W_RESET_HANDLER)( OUT PBOOLEAN AddressingReset, IN NDIS_HANDLE MiniportAdapterContext); typedef NDIS_STATUS -(DDKAPI *W_SEND_HANDLER)( +(NTAPI *W_SEND_HANDLER)( IN NDIS_HANDLE MiniportAdapterContext, IN PNDIS_PACKET Packet, IN UINT Flags); typedef NDIS_STATUS -(DDKAPI *WM_SEND_HANDLER)( +(NTAPI *WM_SEND_HANDLER)( IN NDIS_HANDLE MiniportAdapterContext, IN NDIS_HANDLE NdisLinkHandle, IN PNDIS_WAN_PACKET Packet); typedef NDIS_STATUS -(DDKAPI *W_SET_INFORMATION_HANDLER)( +(NTAPI *W_SET_INFORMATION_HANDLER)( IN NDIS_HANDLE MiniportAdapterContext, IN NDIS_OID Oid, IN PVOID InformationBuffer, @@ -3683,7 +3683,7 @@ typedef NDIS_STATUS OUT PULONG BytesNeeded); typedef NDIS_STATUS -(DDKAPI *W_TRANSFER_DATA_HANDLER)( +(NTAPI *W_TRANSFER_DATA_HANDLER)( OUT PNDIS_PACKET Packet, OUT PUINT BytesTransferred, IN NDIS_HANDLE MiniportAdapterContext, @@ -3692,7 +3692,7 @@ typedef NDIS_STATUS IN UINT BytesToTransfer); typedef NDIS_STATUS -(DDKAPI *WM_TRANSFER_DATA_HANDLER)( +(NTAPI *WM_TRANSFER_DATA_HANDLER)( VOID); @@ -3724,18 +3724,18 @@ typedef struct _NDIS30_MINIPORT_CHARACTERISTICS { /* Extensions for NDIS 4.0 miniports */ typedef VOID -(DDKAPI *W_SEND_PACKETS_HANDLER)( +(NTAPI *W_SEND_PACKETS_HANDLER)( IN NDIS_HANDLE MiniportAdapterContext, IN PPNDIS_PACKET PacketArray, IN UINT NumberOfPackets); typedef VOID -(DDKAPI *W_RETURN_PACKET_HANDLER)( +(NTAPI *W_RETURN_PACKET_HANDLER)( IN NDIS_HANDLE MiniportAdapterContext, IN PNDIS_PACKET Packet); typedef VOID -(DDKAPI *W_ALLOCATE_COMPLETE_HANDLER)( +(NTAPI *W_ALLOCATE_COMPLETE_HANDLER)( IN NDIS_HANDLE MiniportAdapterContext, IN PVOID VirtualAddress, IN PNDIS_PHYSICAL_ADDRESS PhysicalAddress, @@ -3768,32 +3768,32 @@ typedef struct _NDIS40_MINIPORT_CHARACTERISTICS { /* Extensions for NDIS 5.0 miniports */ typedef NDIS_STATUS -(DDKAPI *W_CO_CREATE_VC_HANDLER)( +(NTAPI *W_CO_CREATE_VC_HANDLER)( IN NDIS_HANDLE MiniportAdapterContext, IN NDIS_HANDLE NdisVcHandle, OUT PNDIS_HANDLE MiniportVcContext); typedef NDIS_STATUS -(DDKAPI *W_CO_DELETE_VC_HANDLER)( +(NTAPI *W_CO_DELETE_VC_HANDLER)( IN NDIS_HANDLE MiniportVcContext); typedef NDIS_STATUS -(DDKAPI *W_CO_ACTIVATE_VC_HANDLER)( +(NTAPI *W_CO_ACTIVATE_VC_HANDLER)( IN NDIS_HANDLE MiniportVcContext, IN OUT PCO_CALL_PARAMETERS CallParameters); typedef NDIS_STATUS -(DDKAPI *W_CO_DEACTIVATE_VC_HANDLER)( +(NTAPI *W_CO_DEACTIVATE_VC_HANDLER)( IN NDIS_HANDLE MiniportVcContext); typedef VOID -(DDKAPI *W_CO_SEND_PACKETS_HANDLER)( +(NTAPI *W_CO_SEND_PACKETS_HANDLER)( IN NDIS_HANDLE MiniportVcContext, IN PPNDIS_PACKET PacketArray, IN UINT NumberOfPackets); typedef NDIS_STATUS -(DDKAPI *W_CO_REQUEST_HANDLER)( +(NTAPI *W_CO_REQUEST_HANDLER)( IN NDIS_HANDLE MiniportAdapterContext, IN NDIS_HANDLE MiniportVcContext OPTIONAL, IN OUT PNDIS_REQUEST NdisRequest); @@ -3830,19 +3830,19 @@ typedef struct _NDIS50_MINIPORT_CHARACTERISTICS { /* Extensions for NDIS 5.1 miniports */ typedef VOID -(DDKAPI *W_CANCEL_SEND_PACKETS_HANDLER)( +(NTAPI *W_CANCEL_SEND_PACKETS_HANDLER)( IN NDIS_HANDLE MiniportAdapterContext, IN PVOID CancelId); typedef VOID -(DDKAPI *W_PNP_EVENT_NOTIFY_HANDLER)( +(NTAPI *W_PNP_EVENT_NOTIFY_HANDLER)( IN NDIS_HANDLE MiniportAdapterContext, IN NDIS_DEVICE_PNP_EVENT PnPEvent, IN PVOID InformationBuffer, IN ULONG InformationBufferLength); typedef VOID -(DDKAPI *W_MINIPORT_SHUTDOWN_HANDLER)( +(NTAPI *W_MINIPORT_SHUTDOWN_HANDLER)( IN PVOID ShutdownContext); #ifdef __cplusplus @@ -3887,12 +3887,12 @@ typedef struct _NDIS_MINIPORT_CHARACTERISTICS { typedef NDIS_STATUS -(DDKAPI *SEND_HANDLER)( +(NTAPI *SEND_HANDLER)( IN NDIS_HANDLE MacBindingHandle, IN PNDIS_PACKET Packet); typedef NDIS_STATUS -(DDKAPI *TRANSFER_DATA_HANDLER)( +(NTAPI *TRANSFER_DATA_HANDLER)( IN NDIS_HANDLE MacBindingHandle, IN NDIS_HANDLE MacReceiveContext, IN UINT ByteOffset, @@ -3901,11 +3901,11 @@ typedef NDIS_STATUS OUT PUINT BytesTransferred); typedef NDIS_STATUS -(DDKAPI *RESET_HANDLER)( +(NTAPI *RESET_HANDLER)( IN NDIS_HANDLE MacBindingHandle); typedef NDIS_STATUS -(DDKAPI *REQUEST_HANDLER)( +(NTAPI *REQUEST_HANDLER)( IN NDIS_HANDLE MacBindingHandle, IN PNDIS_REQUEST NdisRequest); @@ -3914,11 +3914,11 @@ typedef NDIS_STATUS /* Structures available only to full MAC drivers */ typedef BOOLEAN -(DDKAPI *PNDIS_INTERRUPT_SERVICE)( +(NTAPI *PNDIS_INTERRUPT_SERVICE)( IN PVOID InterruptContext); typedef VOID -(DDKAPI *PNDIS_DEFERRED_PROCESSING)( +(NTAPI *PNDIS_DEFERRED_PROCESSING)( IN PVOID SystemSpecific1, IN PVOID InterruptContext, IN PVOID SystemSpecific2, @@ -4012,11 +4012,11 @@ typedef struct _NDIS_BIND_PATHS { typedef VOID -(DDKAPI *ETH_RCV_COMPLETE_HANDLER)( +(NTAPI *ETH_RCV_COMPLETE_HANDLER)( IN PETH_FILTER Filter); typedef VOID -(DDKAPI *ETH_RCV_INDICATE_HANDLER)( +(NTAPI *ETH_RCV_INDICATE_HANDLER)( IN PETH_FILTER Filter, IN NDIS_HANDLE MacReceiveContext, IN PCHAR Address, @@ -4027,11 +4027,11 @@ typedef VOID IN UINT PacketSize); typedef VOID -(DDKAPI *FDDI_RCV_COMPLETE_HANDLER)( +(NTAPI *FDDI_RCV_COMPLETE_HANDLER)( IN PFDDI_FILTER Filter); typedef VOID -(DDKAPI *FDDI_RCV_INDICATE_HANDLER)( +(NTAPI *FDDI_RCV_INDICATE_HANDLER)( IN PFDDI_FILTER Filter, IN NDIS_HANDLE MacReceiveContext, IN PCHAR Address, @@ -4043,17 +4043,17 @@ typedef VOID IN UINT PacketSize); typedef VOID -(DDKAPI *FILTER_PACKET_INDICATION_HANDLER)( +(NTAPI *FILTER_PACKET_INDICATION_HANDLER)( IN NDIS_HANDLE Miniport, IN PPNDIS_PACKET PacketArray, IN UINT NumberOfPackets); typedef VOID -(DDKAPI *TR_RCV_COMPLETE_HANDLER)( +(NTAPI *TR_RCV_COMPLETE_HANDLER)( IN PTR_FILTER Filter); typedef VOID -(DDKAPI *TR_RCV_INDICATE_HANDLER)( +(NTAPI *TR_RCV_INDICATE_HANDLER)( IN PTR_FILTER Filter, IN NDIS_HANDLE MacReceiveContext, IN PVOID HeaderBuffer, @@ -4063,12 +4063,12 @@ typedef VOID IN UINT PacketSize); typedef VOID -(DDKAPI *WAN_RCV_COMPLETE_HANDLER)( +(NTAPI *WAN_RCV_COMPLETE_HANDLER)( IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_HANDLE NdisLinkContext); typedef VOID -(DDKAPI *WAN_RCV_HANDLER)( +(NTAPI *WAN_RCV_HANDLER)( OUT PNDIS_STATUS Status, IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_HANDLE NdisLinkContext, @@ -4094,24 +4094,24 @@ typedef NDIS_STATUS IN PVOID WorkItemContext); typedef VOID -(DDKAPI *NDIS_M_REQ_COMPLETE_HANDLER)( +(NTAPI *NDIS_M_REQ_COMPLETE_HANDLER)( IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_STATUS Status); typedef VOID -(DDKAPI *NDIS_M_RESET_COMPLETE_HANDLER)( +(NTAPI *NDIS_M_RESET_COMPLETE_HANDLER)( IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_STATUS Status, IN BOOLEAN AddressingReset); typedef VOID -(DDKAPI *NDIS_M_SEND_COMPLETE_HANDLER)( +(NTAPI *NDIS_M_SEND_COMPLETE_HANDLER)( IN NDIS_HANDLE MiniportAdapterHandle, IN PNDIS_PACKET Packet, IN NDIS_STATUS Status); typedef VOID -(DDKAPI *NDIS_M_SEND_RESOURCES_HANDLER)( +(NTAPI *NDIS_M_SEND_RESOURCES_HANDLER)( IN NDIS_HANDLE MiniportAdapterHandle); typedef BOOLEAN @@ -4119,24 +4119,24 @@ typedef BOOLEAN IN PNDIS_MINIPORT_BLOCK Miniport); typedef VOID -(DDKAPI *NDIS_M_STATUS_HANDLER)( +(NTAPI *NDIS_M_STATUS_HANDLER)( IN NDIS_HANDLE MiniportHandle, IN NDIS_STATUS GeneralStatus, IN PVOID StatusBuffer, IN UINT StatusBufferSize); typedef VOID -(DDKAPI *NDIS_M_STS_COMPLETE_HANDLER)( +(NTAPI *NDIS_M_STS_COMPLETE_HANDLER)( IN NDIS_HANDLE MiniportAdapterHandle); typedef VOID -(DDKAPI *NDIS_M_TD_COMPLETE_HANDLER)( +(NTAPI *NDIS_M_TD_COMPLETE_HANDLER)( IN NDIS_HANDLE MiniportAdapterHandle, IN PNDIS_PACKET Packet, IN NDIS_STATUS Status, IN UINT BytesTransferred); -typedef VOID (DDKAPI *NDIS_WM_SEND_COMPLETE_HANDLER)( +typedef VOID (NTAPI *NDIS_WM_SEND_COMPLETE_HANDLER)( IN NDIS_HANDLE MiniportAdapterHandle, IN PVOID Packet, IN NDIS_STATUS Status); @@ -4376,14 +4376,14 @@ struct _NDIS_MINIPORT_BLOCK { /* Handler prototypes for NDIS_OPEN_BLOCK */ -typedef NDIS_STATUS (DDKAPI *WAN_SEND_HANDLER)( +typedef NDIS_STATUS (NTAPI *WAN_SEND_HANDLER)( IN NDIS_HANDLE MacBindingHandle, IN NDIS_HANDLE LinkHandle, IN PVOID Packet); /* NDIS 4.0 extension */ -typedef VOID (DDKAPI *SEND_PACKETS_HANDLER)( +typedef VOID (NTAPI *SEND_PACKETS_HANDLER)( IN NDIS_HANDLE MiniportAdapterContext, IN PPNDIS_PACKET PacketArray, IN UINT NumberOfPackets); @@ -4466,7 +4466,7 @@ struct _NDIS_OPEN_BLOCK NDISAPI VOID -DDKAPI +NTAPI NdisInitializeWrapper( OUT PNDIS_HANDLE NdisWrapperHandle, IN PVOID SystemSpecific1, @@ -4475,7 +4475,7 @@ NdisInitializeWrapper( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisMAllocateMapRegisters( IN NDIS_HANDLE MiniportAdapterHandle, IN UINT DmaChannel, @@ -4521,13 +4521,13 @@ NdisMAllocateMapRegisters( NDISAPI VOID -DDKAPI +NTAPI NdisMCloseLog( IN NDIS_HANDLE LogHandle); NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisMCreateLog( IN NDIS_HANDLE MiniportAdapterHandle, IN UINT Size, @@ -4535,19 +4535,19 @@ NdisMCreateLog( NDISAPI VOID -DDKAPI +NTAPI NdisMDeregisterAdapterShutdownHandler( IN NDIS_HANDLE MiniportHandle); NDISAPI VOID -DDKAPI +NTAPI NdisMDeregisterInterrupt( IN PNDIS_MINIPORT_INTERRUPT Interrupt); NDISAPI VOID -DDKAPI +NTAPI NdisMDeregisterIoPortRange( IN NDIS_HANDLE MiniportAdapterHandle, IN UINT InitialPort, @@ -4643,13 +4643,13 @@ NdisMDeregisterIoPortRange( NDISAPI VOID -DDKAPI +NTAPI NdisMFlushLog( IN NDIS_HANDLE LogHandle); NDISAPI VOID -DDKAPI +NTAPI NdisMFreeMapRegisters( IN NDIS_HANDLE MiniportAdapterHandle); @@ -4708,7 +4708,7 @@ NdisMFreeMapRegisters( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisMMapIoSpace( OUT PVOID *VirtualAddress, IN NDIS_HANDLE MiniportAdapterHandle, @@ -4726,7 +4726,7 @@ NdisMMapIoSpace( NDISAPI VOID -DDKAPI +NTAPI NdisMRegisterAdapterShutdownHandler( IN NDIS_HANDLE MiniportHandle, IN PVOID ShutdownContext, @@ -4734,7 +4734,7 @@ NdisMRegisterAdapterShutdownHandler( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisMRegisterInterrupt( OUT PNDIS_MINIPORT_INTERRUPT Interrupt, IN NDIS_HANDLE MiniportAdapterHandle, @@ -4746,7 +4746,7 @@ NdisMRegisterInterrupt( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisMRegisterIoPortRange( OUT PVOID *PortOffset, IN NDIS_HANDLE MiniportAdapterHandle, @@ -4755,7 +4755,7 @@ NdisMRegisterIoPortRange( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisMRegisterMiniport( IN NDIS_HANDLE NdisWrapperHandle, IN PNDIS_MINIPORT_CHARACTERISTICS MiniportCharacteristics, @@ -4763,14 +4763,14 @@ NdisMRegisterMiniport( NDISAPI VOID -DDKAPI +NTAPI NdisMSetTimer( IN PNDIS_MINIPORT_TIMER Timer, IN UINT MillisecondsToDelay); NDISAPI VOID -DDKAPI +NTAPI NdisMInitializeTimer( IN OUT PNDIS_MINIPORT_TIMER Timer, IN NDIS_HANDLE MiniportAdapterHandle, @@ -4779,14 +4779,14 @@ NdisMInitializeTimer( NDISAPI VOID -DDKAPI +NTAPI NdisMSetPeriodicTimer( IN PNDIS_MINIPORT_TIMER Timer, IN UINT MillisecondPeriod); NDISAPI VOID -DDKAPI +NTAPI NdisMCancelTimer( IN PNDIS_MINIPORT_TIMER Timer, OUT PBOOLEAN TimerCancelled); @@ -4874,7 +4874,7 @@ NdisMCancelTimer( NDISAPI VOID -DDKAPI +NTAPI NdisMSetAttributesEx( IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_HANDLE MiniportAdapterContext, @@ -4895,13 +4895,13 @@ NdisMSetAttributesEx( NDISAPI VOID -DDKAPI +NTAPI NdisMSleep( IN ULONG MicrosecondsToSleep); NDISAPI BOOLEAN -DDKAPI +NTAPI NdisMSynchronizeWithInterrupt( IN PNDIS_MINIPORT_INTERRUPT Interrupt, IN PVOID SynchronizeFunction, @@ -4950,7 +4950,7 @@ NdisMSynchronizeWithInterrupt( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisMWriteLogData( IN NDIS_HANDLE LogHandle, IN PVOID LogBuffer, @@ -4958,7 +4958,7 @@ NdisMWriteLogData( NDISAPI VOID -DDKAPI +NTAPI NdisMQueryAdapterResources( OUT PNDIS_STATUS Status, IN NDIS_HANDLE WrapperConfigurationContext, @@ -4967,14 +4967,14 @@ NdisMQueryAdapterResources( NDISAPI VOID -DDKAPI +NTAPI NdisTerminateWrapper( IN NDIS_HANDLE NdisWrapperHandle, IN PVOID SystemSpecific); NDISAPI VOID -DDKAPI +NTAPI NdisMUnmapIoSpace( IN NDIS_HANDLE MiniportAdapterHandle, IN PVOID VirtualAddress, @@ -4986,25 +4986,25 @@ NdisMUnmapIoSpace( NDISAPI VOID -DDKAPI +NTAPI NdisInitializeEvent( IN PNDIS_EVENT Event); NDISAPI VOID -DDKAPI +NTAPI NdisSetEvent( IN PNDIS_EVENT Event); NDISAPI VOID -DDKAPI +NTAPI NdisResetEvent( IN PNDIS_EVENT Event); NDISAPI BOOLEAN -DDKAPI +NTAPI NdisWaitEvent( IN PNDIS_EVENT Event, IN UINT Timeout); @@ -5013,7 +5013,7 @@ NdisWaitEvent( /* NDIS intermediate miniport structures */ -typedef VOID (DDKAPI *W_MINIPORT_CALLBACK)( +typedef VOID (NTAPI *W_MINIPORT_CALLBACK)( IN NDIS_HANDLE MiniportAdapterContext, IN PVOID CallbackContext); @@ -5023,7 +5023,7 @@ typedef VOID (DDKAPI *W_MINIPORT_CALLBACK)( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisIMDeInitializeDeviceInstance( IN NDIS_HANDLE NdisMiniportHandle); @@ -5038,7 +5038,7 @@ NdisIMDeInitializeDeviceInstance( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisIMRegisterLayeredMiniport( IN NDIS_HANDLE NdisWrapperHandle, IN PNDIS_MINIPORT_CHARACTERISTICS MiniportCharacteristics, @@ -5050,13 +5050,13 @@ NdisIMRegisterLayeredMiniport( NDISAPI VOID -DDKAPI +NTAPI NdisFreeDmaChannel( IN PNDIS_HANDLE NdisDmaHandle); NDISAPI VOID -DDKAPI +NTAPI NdisSetupDmaTransfer( OUT PNDIS_STATUS Status, IN PNDIS_HANDLE NdisDmaHandle, @@ -5067,7 +5067,7 @@ NdisSetupDmaTransfer( NDISAPI NTSTATUS -DDKAPI +NTAPI NdisUpcaseUnicodeString( OUT PUNICODE_STRING DestinationString, IN PUNICODE_STRING SourceString); @@ -5077,7 +5077,7 @@ NdisUpcaseUnicodeString( NDISAPI VOID -DDKAPI +NTAPI NdisRequest( OUT PNDIS_STATUS Status, IN NDIS_HANDLE NdisBindingHandle, @@ -5085,14 +5085,14 @@ NdisRequest( NDISAPI VOID -DDKAPI +NTAPI NdisReset( OUT PNDIS_STATUS Status, IN NDIS_HANDLE NdisBindingHandle); NDISAPI VOID -DDKAPI +NTAPI NdisSend( OUT PNDIS_STATUS Status, IN NDIS_HANDLE NdisBindingHandle, @@ -5100,7 +5100,7 @@ NdisSend( NDISAPI VOID -DDKAPI +NTAPI NdisSendPackets( IN NDIS_HANDLE NdisBindingHandle, IN PPNDIS_PACKET PacketArray, @@ -5108,7 +5108,7 @@ NdisSendPackets( NDISAPI VOID -DDKAPI +NTAPI NdisTransferData( OUT PNDIS_STATUS Status, IN NDIS_HANDLE NdisBindingHandle, @@ -5120,14 +5120,14 @@ NdisTransferData( NDISAPI VOID -DDKAPI +NTAPI NdisCloseAdapter( OUT PNDIS_STATUS Status, IN NDIS_HANDLE NdisBindingHandle); NDISAPI VOID -DDKAPI +NTAPI NdisCompleteBindAdapter( IN NDIS_HANDLE BindAdapterContext, IN NDIS_STATUS Status, @@ -5135,21 +5135,21 @@ NdisCompleteBindAdapter( NDISAPI VOID -DDKAPI +NTAPI NdisCompleteUnbindAdapter( IN NDIS_HANDLE UnbindAdapterContext, IN NDIS_STATUS Status); NDISAPI VOID -DDKAPI +NTAPI NdisDeregisterProtocol( OUT PNDIS_STATUS Status, IN NDIS_HANDLE NdisProtocolHandle); NDISAPI VOID -DDKAPI +NTAPI NdisOpenAdapter( OUT PNDIS_STATUS Status, OUT PNDIS_STATUS OpenErrorStatus, @@ -5165,7 +5165,7 @@ NdisOpenAdapter( NDISAPI VOID -DDKAPI +NTAPI NdisOpenProtocolConfiguration( OUT PNDIS_STATUS Status, OUT PNDIS_HANDLE ConfigurationHandle, @@ -5173,7 +5173,7 @@ NdisOpenProtocolConfiguration( NDISAPI VOID -DDKAPI +NTAPI NdisRegisterProtocol( OUT PNDIS_STATUS Status, OUT PNDIS_HANDLE NdisProtocolHandle, @@ -5182,7 +5182,7 @@ NdisRegisterProtocol( NDISAPI NDIS_STATUS -DDKAPI +NTAPI NdisScheduleWorkItem( IN PNDIS_WORK_ITEM WorkItem); @@ -5201,20 +5201,20 @@ typedef NDIS_STATUS (*OPEN_ADAPTER_HANDLER)( IN UINT OpenOptions, IN PSTRING AddressingInformation OPTIONAL); -typedef NDIS_STATUS (DDKAPI *CLOSE_ADAPTER_HANDLER)( +typedef NDIS_STATUS (NTAPI *CLOSE_ADAPTER_HANDLER)( IN NDIS_HANDLE MacBindingHandle); -typedef NDIS_STATUS (DDKAPI *WAN_TRANSFER_DATA_HANDLER)( +typedef NDIS_STATUS (NTAPI *WAN_TRANSFER_DATA_HANDLER)( VOID); -typedef NDIS_STATUS (DDKAPI *QUERY_GLOBAL_STATISTICS_HANDLER)( +typedef NDIS_STATUS (NTAPI *QUERY_GLOBAL_STATISTICS_HANDLER)( IN NDIS_HANDLE MacAdapterContext, IN PNDIS_REQUEST NdisRequest); -typedef VOID (DDKAPI *UNLOAD_MAC_HANDLER)( +typedef VOID (NTAPI *UNLOAD_MAC_HANDLER)( IN NDIS_HANDLE MacMacContext); -typedef NDIS_STATUS (DDKAPI *ADD_ADAPTER_HANDLER)( +typedef NDIS_STATUS (NTAPI *ADD_ADAPTER_HANDLER)( IN NDIS_HANDLE MacMacContext, IN NDIS_HANDLE WrapperConfigurationContext, IN PNDIS_STRING AdapterName); diff --git a/reactos/include/ddk/ntagp.h b/reactos/include/ddk/ntagp.h index 6776d2a1f82..6622d81c90b 100644 --- a/reactos/include/ddk/ntagp.h +++ b/reactos/include/ddk/ntagp.h @@ -36,7 +36,7 @@ extern "C" { #define AGP_CAPABILITIES_MAP_PHYSICAL 0x00000001L typedef NTSTATUS -(DDKAPI *PAGP_BUS_COMMIT_MEMORY)( +(NTAPI *PAGP_BUS_COMMIT_MEMORY)( IN PVOID AgpContext, IN PVOID MapHandle, IN ULONG NumberOfPages, @@ -45,19 +45,19 @@ typedef NTSTATUS OUT PHYSICAL_ADDRESS *MemoryBase); typedef NTSTATUS -(DDKAPI *PAGP_BUS_FREE_MEMORY)( +(NTAPI *PAGP_BUS_FREE_MEMORY)( IN PVOID AgpContext, IN PVOID MapHandle, IN ULONG NumberOfPages, IN ULONG OffsetInPages); typedef NTSTATUS -(DDKAPI *PAGP_BUS_RELEASE_MEMORY)( +(NTAPI *PAGP_BUS_RELEASE_MEMORY)( IN PVOID AgpContext, IN PVOID MapHandle); typedef NTSTATUS -(DDKAPI *PAGP_BUS_RESERVE_MEMORY)( +(NTAPI *PAGP_BUS_RESERVE_MEMORY)( IN PVOID AgpContext, IN ULONG NumberOfPages, IN MEMORY_CACHING_TYPE MemoryType, @@ -65,12 +65,12 @@ typedef NTSTATUS OUT PHYSICAL_ADDRESS *PhysicalAddress OPTIONAL); typedef NTSTATUS -(DDKAPI *PAGP_BUS_SET_RATE)( +(NTAPI *PAGP_BUS_SET_RATE)( IN PVOID AgpContext, IN ULONG AgpRate); typedef NTSTATUS -(DDKAPI *PAGP_GET_MAPPED_PAGES)( +(NTAPI *PAGP_GET_MAPPED_PAGES)( IN PVOID AgpContext, IN PVOID MapHandle, IN ULONG NumberOfPages, diff --git a/reactos/include/ddk/ntdd8042.h b/reactos/include/ddk/ntdd8042.h index 0527ef42462..4bb32529292 100644 --- a/reactos/include/ddk/ntdd8042.h +++ b/reactos/include/ddk/ntdd8042.h @@ -134,29 +134,29 @@ typedef struct _INTERNAL_I8042_START_INFORMATION { } INTERNAL_I8042_START_INFORMATION, *PINTERNAL_I8042_START_INFORMATION; typedef VOID -(DDKAPI *PI8042_ISR_WRITE_PORT)( +(NTAPI *PI8042_ISR_WRITE_PORT)( IN PVOID Context, IN UCHAR Value); typedef VOID -(DDKAPI *PI8042_QUEUE_PACKET)( +(NTAPI *PI8042_QUEUE_PACKET)( IN PVOID Context); typedef NTSTATUS -(DDKAPI *PI8042_SYNCH_READ_PORT) ( +(NTAPI *PI8042_SYNCH_READ_PORT) ( IN PVOID Context, OUT PUCHAR Value, IN BOOLEAN WaitForACK); typedef NTSTATUS -(DDKAPI *PI8042_SYNCH_WRITE_PORT)( +(NTAPI *PI8042_SYNCH_WRITE_PORT)( IN PVOID Context, IN UCHAR Value, IN BOOLEAN WaitForACK); typedef NTSTATUS -(DDKAPI *PI8042_KEYBOARD_INITIALIZATION_ROUTINE)( +(NTAPI *PI8042_KEYBOARD_INITIALIZATION_ROUTINE)( IN PVOID InitializationContext, IN PVOID SynchFuncContext, IN PI8042_SYNCH_READ_PORT ReadPort, @@ -164,7 +164,7 @@ typedef NTSTATUS OUT PBOOLEAN TurnTranslationOn); typedef BOOLEAN -(DDKAPI *PI8042_KEYBOARD_ISR)( +(NTAPI *PI8042_KEYBOARD_ISR)( PVOID IsrContext, PKEYBOARD_INPUT_DATA CurrentInput, POUTPUT_PACKET CurrentOutput, @@ -183,7 +183,7 @@ typedef struct _INTERNAL_I8042_HOOK_KEYBOARD { } INTERNAL_I8042_HOOK_KEYBOARD, *PINTERNAL_I8042_HOOK_KEYBOARD; typedef BOOLEAN -(DDKAPI *PI8042_MOUSE_ISR)( +(NTAPI *PI8042_MOUSE_ISR)( PVOID IsrContext, PMOUSE_INPUT_DATA CurrentInput, POUTPUT_PACKET CurrentOutput, diff --git a/reactos/include/ddk/ntpoapi.h b/reactos/include/ddk/ntpoapi.h index 48f71072ab6..c4a4b28ec6f 100644 --- a/reactos/include/ddk/ntpoapi.h +++ b/reactos/include/ddk/ntpoapi.h @@ -220,7 +220,7 @@ typedef struct _POWER_STATE_NOTIFY_HANDLER { NTSYSCALLAPI NTSTATUS -DDKAPI +NTAPI NtPowerInformation( IN POWER_INFORMATION_LEVEL InformationLevel, IN PVOID InputBuffer OPTIONAL, diff --git a/reactos/include/ddk/parallel.h b/reactos/include/ddk/parallel.h index d567bbd2d0f..c45f09b1eef 100644 --- a/reactos/include/ddk/parallel.h +++ b/reactos/include/ddk/parallel.h @@ -80,27 +80,27 @@ typedef struct _MORE_PARALLEL_PORT_INFORMATION { } MORE_PARALLEL_PORT_INFORMATION, *PMORE_PARALLEL_PORT_INFORMATION; typedef NTSTATUS -(DDKAPI *PPARALLEL_SET_CHIP_MODE)( +(NTAPI *PPARALLEL_SET_CHIP_MODE)( IN PVOID SetChipContext, IN UCHAR ChipMode); typedef NTSTATUS -(DDKAPI *PPARALLEL_CLEAR_CHIP_MODE)( +(NTAPI *PPARALLEL_CLEAR_CHIP_MODE)( IN PVOID ClearChipContext, IN UCHAR ChipMode); typedef NTSTATUS -(DDKAPI *PPARCHIP_CLEAR_CHIP_MODE)( +(NTAPI *PPARCHIP_CLEAR_CHIP_MODE)( IN PVOID ClearChipContext, IN UCHAR ChipMode); typedef NTSTATUS -(DDKAPI *PPARALLEL_TRY_SELECT_ROUTINE)( +(NTAPI *PPARALLEL_TRY_SELECT_ROUTINE)( IN PVOID TrySelectContext, IN PVOID TrySelectCommand); typedef NTSTATUS -(DDKAPI *PPARALLEL_DESELECT_ROUTINE)( +(NTAPI *PPARALLEL_DESELECT_ROUTINE)( IN PVOID DeselectContext, IN PVOID DeselectCommand); @@ -134,15 +134,15 @@ typedef struct _PARALLEL_PNP_INFORMATION { } PARALLEL_PNP_INFORMATION, *PPARALLEL_PNP_INFORMATION; typedef BOOLEAN -(DDKAPI *PPARALLEL_TRY_ALLOCATE_ROUTINE)( +(NTAPI *PPARALLEL_TRY_ALLOCATE_ROUTINE)( IN PVOID TryAllocateContext); typedef VOID -(DDKAPI *PPARALLEL_FREE_ROUTINE)( +(NTAPI *PPARALLEL_FREE_ROUTINE)( IN PVOID FreeContext); typedef ULONG -(DDKAPI *PPARALLEL_QUERY_WAITERS_ROUTINE)( +(NTAPI *PPARALLEL_QUERY_WAITERS_ROUTINE)( IN PVOID QueryAllocsContext); typedef struct _PARALLEL_PORT_INFORMATION { @@ -165,7 +165,7 @@ typedef struct _PARALLEL_CHIP_MODE { } PARALLEL_CHIP_MODE, *PPARALLEL_CHIP_MODE; typedef VOID -(DDKAPI *PPARALLEL_DEFERRED_ROUTINE)( +(NTAPI *PPARALLEL_DEFERRED_ROUTINE)( IN PVOID DeferredContext); typedef struct _PARALLEL_INTERRUPT_SERVICE_ROUTINE { @@ -192,7 +192,7 @@ typedef struct _PARALLEL_INTERRUPT_SERVICE_ROUTINE { CTL_CODE (FILE_DEVICE_PARALLEL_PORT, 53, METHOD_BUFFERED, FILE_ANY_ACCESS) typedef USHORT -(DDKAPI *PDETERMINE_IEEE_MODES)( +(NTAPI *PDETERMINE_IEEE_MODES)( IN PVOID Context); typedef enum _PARALLEL_SAFETY { @@ -201,7 +201,7 @@ typedef enum _PARALLEL_SAFETY { } PARALLEL_SAFETY; typedef NTSTATUS -(DDKAPI *PNEGOTIATE_IEEE_MODE)( +(NTAPI *PNEGOTIATE_IEEE_MODE)( IN PVOID Context, IN USHORT ModeMaskFwd, IN USHORT ModeMaskRev, @@ -209,19 +209,19 @@ typedef NTSTATUS IN BOOLEAN IsForward); typedef NTSTATUS -(DDKAPI *PTERMINATE_IEEE_MODE)( +(NTAPI *PTERMINATE_IEEE_MODE)( IN PVOID Context); typedef NTSTATUS -(DDKAPI *PPARALLEL_IEEE_FWD_TO_REV)( +(NTAPI *PPARALLEL_IEEE_FWD_TO_REV)( IN PVOID Context); typedef NTSTATUS -(DDKAPI *PPARALLEL_IEEE_REV_TO_FWD)( +(NTAPI *PPARALLEL_IEEE_REV_TO_FWD)( IN PVOID Context); typedef NTSTATUS -(DDKAPI *PPARALLEL_READ)( +(NTAPI *PPARALLEL_READ)( IN PVOID Context, OUT PVOID Buffer, IN ULONG NumBytesToRead, @@ -229,7 +229,7 @@ typedef NTSTATUS IN UCHAR Channel); typedef NTSTATUS -(DDKAPI *PPARALLEL_WRITE)( +(NTAPI *PPARALLEL_WRITE)( IN PVOID Context, OUT PVOID Buffer, IN ULONG NumBytesToWrite, @@ -237,12 +237,12 @@ typedef NTSTATUS IN UCHAR Channel); typedef NTSTATUS -(DDKAPI *PPARALLEL_TRYSELECT_DEVICE)( +(NTAPI *PPARALLEL_TRYSELECT_DEVICE)( IN PVOID Context, IN PARALLEL_1284_COMMAND Command); typedef NTSTATUS -(DDKAPI *PPARALLEL_DESELECT_DEVICE)( +(NTAPI *PPARALLEL_DESELECT_DEVICE)( IN PVOID Context, IN PARALLEL_1284_COMMAND Command); diff --git a/reactos/include/ddk/scsiwmi.h b/reactos/include/ddk/scsiwmi.h index c599f48c01b..383d1d473a1 100644 --- a/reactos/include/ddk/scsiwmi.h +++ b/reactos/include/ddk/scsiwmi.h @@ -61,13 +61,13 @@ typedef struct _SCSIWMIGUIDREGINFO { } SCSIWMIGUIDREGINFO, *PSCSIWMIGUIDREGINFO; typedef UCHAR -(DDKAPI *PSCSIWMI_QUERY_REGINFO)( +(NTAPI *PSCSIWMI_QUERY_REGINFO)( IN PVOID DeviceContext, IN PSCSIWMI_REQUEST_CONTEXT RequestContext, OUT PWCHAR *MofResourceName); typedef BOOLEAN -(DDKAPI *PSCSIWMI_QUERY_DATABLOCK)( +(NTAPI *PSCSIWMI_QUERY_DATABLOCK)( IN PVOID Context, IN PSCSIWMI_REQUEST_CONTEXT DispatchContext, IN ULONG GuidIndex, @@ -78,7 +78,7 @@ typedef BOOLEAN OUT PUCHAR Buffer); typedef BOOLEAN -(DDKAPI *PSCSIWMI_SET_DATABLOCK)( +(NTAPI *PSCSIWMI_SET_DATABLOCK)( IN PVOID DeviceContext, IN PSCSIWMI_REQUEST_CONTEXT RequestContext, IN ULONG GuidIndex, @@ -87,7 +87,7 @@ typedef BOOLEAN IN PUCHAR Buffer); typedef BOOLEAN -(DDKAPI *PSCSIWMI_SET_DATAITEM)( +(NTAPI *PSCSIWMI_SET_DATAITEM)( IN PVOID DeviceContext, IN PSCSIWMI_REQUEST_CONTEXT RequestContext, IN ULONG GuidIndex, @@ -97,7 +97,7 @@ typedef BOOLEAN IN PUCHAR Buffer); typedef BOOLEAN -(DDKAPI *PSCSIWMI_EXECUTE_METHOD)( +(NTAPI *PSCSIWMI_EXECUTE_METHOD)( IN PVOID DeviceContext, IN PSCSIWMI_REQUEST_CONTEXT RequestContext, IN ULONG GuidIndex, @@ -113,7 +113,7 @@ typedef enum _SCSIWMI_ENABLE_DISABLE_CONTROL { } SCSIWMI_ENABLE_DISABLE_CONTROL; typedef BOOLEAN -(DDKAPI *PSCSIWMI_FUNCTION_CONTROL)( +(NTAPI *PSCSIWMI_FUNCTION_CONTROL)( IN PVOID DeviceContext, IN PSCSIWMI_REQUEST_CONTEXT RequestContext, IN ULONG GuidIndex, @@ -133,7 +133,7 @@ typedef struct _SCSIWMILIB_CONTEXT { SCSIPORTAPI BOOLEAN -DDKAPI +NTAPI ScsiPortWmiDispatchFunction( IN PSCSI_WMILIB_CONTEXT WmiLibInfo, IN UCHAR MinorFunction, @@ -176,7 +176,7 @@ ScsiPortWmiDispatchFunction( SCSIPORTAPI VOID -DDKAPI +NTAPI ScsiPortWmiPostProcess( IN PSCSIWMI_REQUEST_CONTEXT RequestContext, IN UCHAR SrbStatus, @@ -184,7 +184,7 @@ ScsiPortWmiPostProcess( SCSIPORTAPI VOID -DDKAPI +NTAPI ScsiPortWmiFireLogicalUnitEvent( IN PVOID HwDeviceExtension, IN UCHAR PathId, diff --git a/reactos/include/ddk/smbus.h b/reactos/include/ddk/smbus.h index de61c7de0e1..fd07c72556f 100644 --- a/reactos/include/ddk/smbus.h +++ b/reactos/include/ddk/smbus.h @@ -100,17 +100,17 @@ typedef struct _SMB_REGISTER_ALARM { #define SMB_CLASS_MINOR_VERSION 0x0000 typedef NTSTATUS -(DDKAPI *SMB_RESET_DEVICE)( +(NTAPI *SMB_RESET_DEVICE)( IN struct _SMB_CLASS *SmbClass, IN PVOID SmbMiniport); typedef VOID -(DDKAPI *SMB_START_IO)( +(NTAPI *SMB_START_IO)( IN struct _SMB_CLASS *SmbClass, IN PVOID SmbMiniport); typedef NTSTATUS -(DDKAPI *SMB_STOP_DEVICE)( +(NTAPI *SMB_STOP_DEVICE)( IN struct _SMB_CLASS *SmbClass, IN PVOID SmbMiniport); @@ -130,7 +130,7 @@ typedef struct _SMB_CLASS { SMBCLASSAPI VOID -DDKAPI +NTAPI SmbClassAlarm( IN PSMB_CLASS SmbClass, IN UCHAR Address, @@ -138,19 +138,19 @@ SmbClassAlarm( SMBCLASSAPI VOID -DDKAPI +NTAPI SmbClassCompleteRequest( IN PSMB_CLASS SmbClass); typedef NTSTATUS -(DDKAPI *PSMB_INITIALIZE_MINIPORT)( +(NTAPI *PSMB_INITIALIZE_MINIPORT)( IN PSMB_CLASS SmbClass, IN PVOID MiniportExtension, IN PVOID MiniportContext); SMBCLASSAPI NTSTATUS -DDKAPI +NTAPI SmbClassCreateFdo( IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT PDO, @@ -161,7 +161,7 @@ SmbClassCreateFdo( SMBCLASSAPI NTSTATUS -DDKAPI +NTAPI SmbClassInitializeDevice( IN ULONG MajorVersion, IN ULONG MinorVersion, @@ -169,13 +169,13 @@ SmbClassInitializeDevice( SMBCLASSAPI VOID -DDKAPI +NTAPI SmbClassLockDevice( IN PSMB_CLASS SmbClass); SMBCLASSAPI VOID -DDKAPI +NTAPI SmbClassUnlockDevice( IN PSMB_CLASS SmbClass); diff --git a/reactos/include/ddk/srb.h b/reactos/include/ddk/srb.h index 7d7fc516b9b..0763652749a 100644 --- a/reactos/include/ddk/srb.h +++ b/reactos/include/ddk/srb.h @@ -301,13 +301,13 @@ typedef struct _SCSI_SUPPORTED_CONTROL_TYPE_LIST { } SCSI_SUPPORTED_CONTROL_TYPE_LIST, *PSCSI_SUPPORTED_CONTROL_TYPE_LIST; typedef SCSI_ADAPTER_CONTROL_STATUS -(DDKAPI *PHW_ADAPTER_CONTROL)( +(NTAPI *PHW_ADAPTER_CONTROL)( IN PVOID DeviceExtension, IN SCSI_ADAPTER_CONTROL_TYPE ControlType, IN PVOID Parameters); typedef BOOLEAN -(DDKAPI *PHW_ADAPTER_STATE)( +(NTAPI *PHW_ADAPTER_STATE)( IN PVOID DeviceExtension, IN PVOID Context, IN BOOLEAN SaveState); @@ -318,7 +318,7 @@ typedef BOOLEAN #define SP_RETURN_BAD_CONFIG 3 typedef ULONG -(DDKAPI *PHW_FIND_ADAPTER)( +(NTAPI *PHW_FIND_ADAPTER)( IN PVOID DeviceExtension, IN PVOID HwContext, IN PVOID BusInformation, @@ -327,29 +327,29 @@ typedef ULONG OUT PBOOLEAN Again); typedef BOOLEAN -(DDKAPI *PHW_INITIALIZE)( +(NTAPI *PHW_INITIALIZE)( IN PVOID DeviceExtension); typedef BOOLEAN -(DDKAPI *PHW_INTERRUPT)( +(NTAPI *PHW_INTERRUPT)( IN PVOID DeviceExtension); typedef BOOLEAN -(DDKAPI *PHW_RESET_BUS)( +(NTAPI *PHW_RESET_BUS)( IN PVOID DeviceExtension, IN ULONG PathId); typedef VOID -(DDKAPI *PHW_DMA_STARTED)( +(NTAPI *PHW_DMA_STARTED)( IN PVOID DeviceExtension); typedef BOOLEAN -(DDKAPI *PHW_STARTIO)( +(NTAPI *PHW_STARTIO)( IN PVOID DeviceExtension, IN PSCSI_REQUEST_BLOCK Srb); typedef VOID -(DDKAPI *PHW_TIMER)( +(NTAPI *PHW_TIMER)( IN PVOID DeviceExtension); typedef struct _HW_INITIALIZATION_DATA { @@ -383,7 +383,7 @@ typedef struct _HW_INITIALIZATION_DATA { SCSIPORTAPI VOID -DDKAPI +NTAPI ScsiPortCompleteRequest( IN PVOID HwDeviceExtension, IN UCHAR PathId, @@ -400,26 +400,26 @@ ScsiPortCompleteRequest( SCSIPORTAPI SCSI_PHYSICAL_ADDRESS -DDKAPI +NTAPI ScsiPortConvertUlongToPhysicalAddress( IN ULONG UlongAddress); SCSIPORTAPI VOID -DDKAPI +NTAPI ScsiPortFlushDma( IN PVOID DeviceExtension); SCSIPORTAPI VOID -DDKAPI +NTAPI ScsiPortFreeDeviceBase( IN PVOID HwDeviceExtension, IN PVOID MappedAddress); SCSIPORTAPI ULONG -DDKAPI +NTAPI ScsiPortGetBusData( IN PVOID DeviceExtension, IN ULONG BusDataType, @@ -430,7 +430,7 @@ ScsiPortGetBusData( SCSIPORTAPI PVOID -DDKAPI +NTAPI ScsiPortGetDeviceBase( IN PVOID HwDeviceExtension, IN INTERFACE_TYPE BusType, @@ -441,7 +441,7 @@ ScsiPortGetDeviceBase( SCSIPORTAPI PVOID -DDKAPI +NTAPI ScsiPortGetLogicalUnit( IN PVOID HwDeviceExtension, IN UCHAR PathId, @@ -450,7 +450,7 @@ ScsiPortGetLogicalUnit( SCSIPORTAPI SCSI_PHYSICAL_ADDRESS -DDKAPI +NTAPI ScsiPortGetPhysicalAddress( IN PVOID HwDeviceExtension, IN PSCSI_REQUEST_BLOCK Srb OPTIONAL, @@ -459,7 +459,7 @@ ScsiPortGetPhysicalAddress( SCSIPORTAPI PSCSI_REQUEST_BLOCK -DDKAPI +NTAPI ScsiPortGetSrb( IN PVOID DeviceExtension, IN UCHAR PathId, @@ -469,7 +469,7 @@ ScsiPortGetSrb( SCSIPORTAPI PVOID -DDKAPI +NTAPI ScsiPortGetUncachedExtension( IN PVOID HwDeviceExtension, IN PPORT_CONFIGURATION_INFORMATION ConfigInfo, @@ -477,14 +477,14 @@ ScsiPortGetUncachedExtension( SCSIPORTAPI PVOID -DDKAPI +NTAPI ScsiPortGetVirtualAddress( IN PVOID HwDeviceExtension, IN SCSI_PHYSICAL_ADDRESS PhysicalAddress); SCSIPORTAPI ULONG -DDKAPI +NTAPI ScsiPortInitialize( IN PVOID Argument1, IN PVOID Argument2, @@ -493,7 +493,7 @@ ScsiPortInitialize( SCSIPORTAPI VOID -DDKAPI +NTAPI ScsiPortIoMapTransfer( IN PVOID HwDeviceExtension, IN PSCSI_REQUEST_BLOCK Srb, @@ -502,7 +502,7 @@ ScsiPortIoMapTransfer( SCSIPORTAPI VOID -DDKAPI +NTAPI ScsiPortLogError( IN PVOID HwDeviceExtension, IN PSCSI_REQUEST_BLOCK Srb OPTIONAL, @@ -514,7 +514,7 @@ ScsiPortLogError( SCSIPORTAPI VOID -DDKAPI +NTAPI ScsiPortMoveMemory( IN PVOID WriteBuffer, IN PVOID ReadBuffer, @@ -522,7 +522,7 @@ ScsiPortMoveMemory( SCSIPORTAPI VOID -DDKCDECLAPI +__cdecl ScsiPortNotification( IN SCSI_NOTIFICATION_TYPE NotificationType, IN PVOID HwDeviceExtension, @@ -530,13 +530,13 @@ ScsiPortNotification( SCSIPORTAPI VOID -DDKAPI +NTAPI ScsiPortQuerySystemTime( OUT PLARGE_INTEGER CurrentTime); SCSIPORTAPI VOID -DDKAPI +NTAPI ScsiPortReadPortBufferUchar( IN PUCHAR Port, IN PUCHAR Buffer, @@ -544,7 +544,7 @@ ScsiPortReadPortBufferUchar( SCSIPORTAPI VOID -DDKAPI +NTAPI ScsiPortReadPortBufferUlong( IN PULONG Port, IN PULONG Buffer, @@ -552,7 +552,7 @@ ScsiPortReadPortBufferUlong( SCSIPORTAPI VOID -DDKAPI +NTAPI ScsiPortReadPortBufferUshort( IN PUSHORT Port, IN PUSHORT Buffer, @@ -560,25 +560,25 @@ ScsiPortReadPortBufferUshort( SCSIPORTAPI UCHAR -DDKAPI +NTAPI ScsiPortReadPortUchar( IN PUCHAR Port); SCSIPORTAPI ULONG -DDKAPI +NTAPI ScsiPortReadPortUlong( IN PULONG Port); SCSIPORTAPI USHORT -DDKAPI +NTAPI ScsiPortReadPortUshort( IN PUSHORT Port); SCSIPORTAPI VOID -DDKAPI +NTAPI ScsiPortReadRegisterBufferUchar( IN PUCHAR Register, IN PUCHAR Buffer, @@ -586,7 +586,7 @@ ScsiPortReadRegisterBufferUchar( SCSIPORTAPI VOID -DDKAPI +NTAPI ScsiPortReadRegisterBufferUlong( IN PULONG Register, IN PULONG Buffer, @@ -594,7 +594,7 @@ ScsiPortReadRegisterBufferUlong( SCSIPORTAPI VOID -DDKAPI +NTAPI ScsiPortReadRegisterBufferUshort( IN PUSHORT Register, IN PUSHORT Buffer, @@ -602,25 +602,25 @@ ScsiPortReadRegisterBufferUshort( SCSIPORTAPI UCHAR -DDKAPI +NTAPI ScsiPortReadRegisterUchar( IN PUCHAR Register); SCSIPORTAPI ULONG -DDKAPI +NTAPI ScsiPortReadRegisterUlong( IN PULONG Register); SCSIPORTAPI USHORT -DDKAPI +NTAPI ScsiPortReadRegisterUshort( IN PUSHORT Register); SCSIPORTAPI ULONG -DDKAPI +NTAPI ScsiPortSetBusDataByOffset( IN PVOID DeviceExtension, IN ULONG BusDataType, @@ -632,13 +632,13 @@ ScsiPortSetBusDataByOffset( SCSIPORTAPI VOID -DDKAPI +NTAPI ScsiPortStallExecution( IN ULONG Delay); SCSIPORTAPI BOOLEAN -DDKAPI +NTAPI ScsiPortValidateRange( IN PVOID HwDeviceExtension, IN INTERFACE_TYPE BusType, @@ -649,7 +649,7 @@ ScsiPortValidateRange( SCSIPORTAPI VOID -DDKAPI +NTAPI ScsiPortWritePortBufferUchar( IN PUCHAR Port, IN PUCHAR Buffer, @@ -657,7 +657,7 @@ ScsiPortWritePortBufferUchar( SCSIPORTAPI VOID -DDKAPI +NTAPI ScsiPortWritePortBufferUlong( IN PULONG Port, IN PULONG Buffer, @@ -665,7 +665,7 @@ ScsiPortWritePortBufferUlong( SCSIPORTAPI VOID -DDKAPI +NTAPI ScsiPortWritePortBufferUshort( IN PUSHORT Port, IN PUSHORT Buffer, @@ -673,28 +673,28 @@ ScsiPortWritePortBufferUshort( SCSIPORTAPI VOID -DDKAPI +NTAPI ScsiPortWritePortUchar( IN PUCHAR Port, IN UCHAR Value); SCSIPORTAPI VOID -DDKAPI +NTAPI ScsiPortWritePortUlong( IN PULONG Port, IN ULONG Value); SCSIPORTAPI VOID -DDKAPI +NTAPI ScsiPortWritePortUshort( IN PUSHORT Port, IN USHORT Value); SCSIPORTAPI VOID -DDKAPI +NTAPI ScsiPortWriteRegisterBufferUchar( IN PUCHAR Register, IN PUCHAR Buffer, @@ -702,7 +702,7 @@ ScsiPortWriteRegisterBufferUchar( SCSIPORTAPI VOID -DDKAPI +NTAPI ScsiPortWriteRegisterBufferUlong( IN PULONG Register, IN PULONG Buffer, @@ -710,7 +710,7 @@ ScsiPortWriteRegisterBufferUlong( SCSIPORTAPI VOID -DDKAPI +NTAPI ScsiPortWriteRegisterBufferUshort( IN PUSHORT Register, IN PUSHORT Buffer, @@ -718,28 +718,28 @@ ScsiPortWriteRegisterBufferUshort( SCSIPORTAPI VOID -DDKAPI +NTAPI ScsiPortWriteRegisterUchar( IN PUCHAR Register, IN ULONG Value); SCSIPORTAPI VOID -DDKAPI +NTAPI ScsiPortWriteRegisterUlong( IN PULONG Register, IN ULONG Value); SCSIPORTAPI VOID -DDKAPI +NTAPI ScsiPortWriteRegisterUshort( IN PUSHORT Register, IN USHORT Value); SCSIPORTAPI VOID -DDKCDECLAPI +__cdecl ScsiDebugPrint( IN ULONG DebugPrintLevel, IN PCCHAR DebugMessage, diff --git a/reactos/include/ddk/storport.h b/reactos/include/ddk/storport.h index 7859967a32d..fd8cf9b19ae 100644 --- a/reactos/include/ddk/storport.h +++ b/reactos/include/ddk/storport.h @@ -76,7 +76,7 @@ typedef struct _SCSI_WMI_REQUEST_BLOCK { STORPORTAPI ULONG -DDKAPI +NTAPI StorPortInitialize( IN PVOID Argument1, IN PVOID Argument2, @@ -85,14 +85,14 @@ StorPortInitialize( STORPORTAPI VOID -DDKAPI +NTAPI StorPortFreeDeviceBase( IN PVOID HwDeviceExtension, IN PVOID MappedAddress); STORPORTAPI ULONG -DDKAPI +NTAPI StorPortGetBusData( IN PVOID DeviceExtension, IN ULONG BusDataType, @@ -103,7 +103,7 @@ StorPortGetBusData( STORPORTAPI ULONG -DDKAPI +NTAPI StorPortSetBusDataByOffset( IN PVOID DeviceExtension, IN ULONG BusDataType, @@ -115,7 +115,7 @@ StorPortSetBusDataByOffset( STORPORTAPI PVOID -DDKAPI +NTAPI StorPortGetDeviceBase( IN PVOID HwDeviceExtension, IN INTERFACE_TYPE BusType, @@ -126,7 +126,7 @@ StorPortGetDeviceBase( STORPORTAPI PVOID -DDKAPI +NTAPI StorPortGetLogicalUnit( IN PVOID HwDeviceExtension, IN UCHAR PathId, @@ -135,7 +135,7 @@ StorPortGetLogicalUnit( STORPORTAPI PSCSI_REQUEST_BLOCK -DDKAPI +NTAPI StorPortGetSrb( IN PVOID DeviceExtension, IN UCHAR PathId, @@ -145,7 +145,7 @@ StorPortGetSrb( STORPORTAPI STOR_PHYSICAL_ADDRESS -DDKAPI +NTAPI StorPortGetPhysicalAddress( IN PVOID HwDeviceExtension, IN PSCSI_REQUEST_BLOCK Srb, @@ -154,14 +154,14 @@ StorPortGetPhysicalAddress( STORPORTAPI PVOID -DDKAPI +NTAPI StorPortGetVirtualAddress( IN PVOID HwDeviceExtension, IN STOR_PHYSICAL_ADDRESS PhysicalAddress); STORPORTAPI PVOID -DDKAPI +NTAPI StorPortGetUncachedExtension( IN PVOID HwDeviceExtension, IN PPORT_CONFIGURATION_INFORMATION ConfigInfo, @@ -169,7 +169,7 @@ StorPortGetUncachedExtension( STORPORTAPI VOID -DDKCDECLAPI +__cdecl StorPortNotification( IN SCSI_NOTIFICATION_TYPE NotificationType, IN PVOID HwDeviceExtension, @@ -177,7 +177,7 @@ StorPortNotification( STORPORTAPI VOID -DDKAPI +NTAPI StorPortLogError( IN PVOID HwDeviceExtension, IN PSCSI_REQUEST_BLOCK Srb OPTIONAL, @@ -189,7 +189,7 @@ StorPortLogError( STORPORTAPI VOID -DDKAPI +NTAPI StorPortCompleteRequest( IN PVOID HwDeviceExtension, IN UCHAR PathId, @@ -199,7 +199,7 @@ StorPortCompleteRequest( STORPORTAPI VOID -DDKAPI +NTAPI StorPortMoveMemory( IN PVOID WriteBuffer, IN PVOID ReadBuffer, @@ -207,25 +207,25 @@ StorPortMoveMemory( STORPORTAPI VOID -DDKAPI +NTAPI StorPortStallExecution( IN ULONG Delay); STORPORTAPI STOR_PHYSICAL_ADDRESS -DDKAPI +NTAPI StorPortConvertUlong64ToPhysicalAddress( IN ULONG64 UlongAddress); STORPORTAPI ULONG64 -DDKAPI +NTAPI StorPortConvertPhysicalAddressToUlong64( IN STOR_PHYSICAL_ADDRESS Address); STORPORTAPI BOOLEAN -DDKAPI +NTAPI StorPortValidateRange( IN PVOID HwDeviceExtension, IN INTERFACE_TYPE BusType, @@ -236,7 +236,7 @@ StorPortValidateRange( STORPORTAPI VOID -DDKCDECLAPI +__cdecl StorPortDebugPrint( IN ULONG DebugPrintLevel, IN PCCHAR DebugMessage, @@ -244,85 +244,85 @@ StorPortDebugPrint( STORPORTAPI UCHAR -DDKAPI +NTAPI StorPortReadPortUchar( IN PUCHAR Port); STORPORTAPI ULONG -DDKAPI +NTAPI StorPortReadPortUlong( IN PULONG Port); STORPORTAPI USHORT -DDKAPI +NTAPI StorPortReadPortUshort( IN PUSHORT Port); STORPORTAPI UCHAR -DDKAPI +NTAPI StorPortReadRegisterUchar( IN PUCHAR Register); STORPORTAPI ULONG -DDKAPI +NTAPI StorPortReadRegisterUlong( IN PULONG Register); STORPORTAPI USHORT -DDKAPI +NTAPI StorPortReadRegisterUshort( IN PUSHORT Register); STORPORTAPI VOID -DDKAPI +NTAPI StorPortWritePortUchar( IN PUCHAR Port, IN UCHAR Value); STORPORTAPI VOID -DDKAPI +NTAPI StorPortWritePortUlong( IN PULONG Port, IN ULONG Value); STORPORTAPI VOID -DDKAPI +NTAPI StorPortWritePortUshort( IN PUSHORT Port, IN USHORT Value); STORPORTAPI VOID -DDKAPI +NTAPI StorPortWriteRegisterUchar( IN PUCHAR Port, IN UCHAR Value); STORPORTAPI VOID -DDKAPI +NTAPI StorPortWriteRegisterUlong( IN PULONG Port, IN ULONG Value); STORPORTAPI VOID -DDKAPI +NTAPI StorPortWriteRegisterUshort( IN PUSHORT Port, IN USHORT Value); STORPORTAPI BOOLEAN -DDKAPI +NTAPI StorPortPauseDevice( IN PVOID HwDeviceExtension, IN UCHAR PathId, @@ -332,7 +332,7 @@ StorPortPauseDevice( STORPORTAPI BOOLEAN -DDKAPI +NTAPI StorPortResumeDevice( IN PVOID HwDeviceExtension, IN UCHAR PathId, @@ -341,20 +341,20 @@ StorPortResumeDevice( STORPORTAPI BOOLEAN -DDKAPI +NTAPI StorPortPause( IN PVOID HwDeviceExtension, IN ULONG TimeOut); STORPORTAPI BOOLEAN -DDKAPI +NTAPI StorPortResume( IN PVOID HwDeviceExtension); STORPORTAPI BOOLEAN -DDKAPI +NTAPI StorPortDeviceBusy( IN PVOID HwDeviceExtension, IN UCHAR PathId, @@ -364,7 +364,7 @@ StorPortDeviceBusy( STORPORTAPI BOOLEAN -DDKAPI +NTAPI StorPortDeviceReady( IN PVOID HwDeviceExtension, IN UCHAR PathId, @@ -373,32 +373,32 @@ StorPortDeviceReady( STORPORTAPI BOOLEAN -DDKAPI +NTAPI StorPortBusy( IN PVOID HwDeviceExtension, IN ULONG RequestsToComplete); STORPORTAPI BOOLEAN -DDKAPI +NTAPI StorPortReady( IN PVOID HwDeviceExtension); STORPORTAPI PSTOR_SCATTER_GATHER_LIST -DDKAPI +NTAPI StorPortGetScatterGatherList( IN PVOID DeviceExtension, IN PSCSI_REQUEST_BLOCK Srb); typedef BOOLEAN -(DDKAPI *PSTOR_SYNCHRONIZED_ACCESS)( +(NTAPI *PSTOR_SYNCHRONIZED_ACCESS)( IN PVOID HwDeviceExtension, IN PVOID Context); STORPORTAPI VOID -DDKAPI +NTAPI StorPortSynchronizeAccess( IN PVOID HwDeviceExtension, IN PSTOR_SYNCHRONIZED_ACCESS SynchronizedAccessRoutine, diff --git a/reactos/include/ddk/tdikrnl.h b/reactos/include/ddk/tdikrnl.h index 7c5f90dfcd3..b6a30118b96 100644 --- a/reactos/include/ddk/tdikrnl.h +++ b/reactos/include/ddk/tdikrnl.h @@ -157,7 +157,7 @@ typedef struct _TDI_REQUEST_KERNEL_SET_INFO { #define TDI_EVENT_ERROR_EX 10 typedef NTSTATUS -(DDKAPI *PTDI_IND_CONNECT)( +(NTAPI *PTDI_IND_CONNECT)( IN PVOID TdiEventContext, IN LONG RemoteAddressLength, IN PVOID RemoteAddress, @@ -170,7 +170,7 @@ typedef NTSTATUS TDIKRNLAPI NTSTATUS -DDKAPI +NTAPI TdiDefaultConnectHandler( IN PVOID TdiEventContext, IN LONG RemoteAddressLength, @@ -183,7 +183,7 @@ TdiDefaultConnectHandler( OUT PIRP *AcceptIrp); typedef NTSTATUS -(DDKAPI *PTDI_IND_DISCONNECT)( +(NTAPI *PTDI_IND_DISCONNECT)( IN PVOID TdiEventContext, IN CONNECTION_CONTEXT ConnectionContext, IN LONG DisconnectDataLength, @@ -194,7 +194,7 @@ typedef NTSTATUS TDIKRNLAPI NTSTATUS -DDKAPI +NTAPI TdiDefaultDisconnectHandler( IN PVOID TdiEventContext, IN CONNECTION_CONTEXT ConnectionContext, @@ -205,25 +205,25 @@ TdiDefaultDisconnectHandler( IN ULONG DisconnectFlags); typedef NTSTATUS -(DDKAPI *PTDI_IND_ERROR)( +(NTAPI *PTDI_IND_ERROR)( IN PVOID TdiEventContext, IN NTSTATUS Status); typedef NTSTATUS -(DDKAPI *PTDI_IND_ERROR_EX)( +(NTAPI *PTDI_IND_ERROR_EX)( IN PVOID TdiEventContext, IN NTSTATUS Status, IN PVOID Buffer); TDIKRNLAPI NTSTATUS -DDKAPI +NTAPI TdiDefaultErrorHandler( IN PVOID TdiEventContext, IN NTSTATUS Status); typedef NTSTATUS -(DDKAPI *PTDI_IND_RECEIVE)( +(NTAPI *PTDI_IND_RECEIVE)( IN PVOID TdiEventContext, IN CONNECTION_CONTEXT ConnectionContext, IN ULONG ReceiveFlags, @@ -235,7 +235,7 @@ typedef NTSTATUS TDIKRNLAPI NTSTATUS -DDKAPI +NTAPI TdiDefaultReceiveHandler( IN PVOID TdiEventContext, IN CONNECTION_CONTEXT ConnectionContext, @@ -247,7 +247,7 @@ TdiDefaultReceiveHandler( OUT PIRP *IoRequestPacket); typedef NTSTATUS -(DDKAPI *PTDI_IND_RECEIVE_DATAGRAM)( +(NTAPI *PTDI_IND_RECEIVE_DATAGRAM)( IN PVOID TdiEventContext, IN LONG SourceAddressLength, IN PVOID SourceAddress, @@ -261,7 +261,7 @@ typedef NTSTATUS OUT PIRP *IoRequestPacket); TDIKRNLAPI -NTSTATUS DDKAPI +NTSTATUS NTAPI TdiDefaultRcvDatagramHandler( IN PVOID TdiEventContext, IN LONG SourceAddressLength, @@ -276,7 +276,7 @@ TdiDefaultRcvDatagramHandler( OUT PIRP *IoRequestPacket); typedef NTSTATUS -(DDKAPI *PTDI_IND_RECEIVE_EXPEDITED)( +(NTAPI *PTDI_IND_RECEIVE_EXPEDITED)( IN PVOID TdiEventContext, IN CONNECTION_CONTEXT ConnectionContext, IN ULONG ReceiveFlags, @@ -288,7 +288,7 @@ typedef NTSTATUS TDIKRNLAPI NTSTATUS -DDKAPI +NTAPI TdiDefaultRcvExpeditedHandler( IN PVOID TdiEventContext, IN CONNECTION_CONTEXT ConnectionContext, @@ -300,7 +300,7 @@ TdiDefaultRcvExpeditedHandler( OUT PIRP *IoRequestPacket); typedef NTSTATUS -(DDKAPI *PTDI_IND_CHAINED_RECEIVE)( +(NTAPI *PTDI_IND_CHAINED_RECEIVE)( IN PVOID TdiEventContext, IN CONNECTION_CONTEXT ConnectionContext, IN ULONG ReceiveFlags, @@ -311,7 +311,7 @@ typedef NTSTATUS TDIKRNLAPI NTSTATUS -DDKAPI +NTAPI TdiDefaultChainedReceiveHandler( IN PVOID TdiEventContext, IN CONNECTION_CONTEXT ConnectionContext, @@ -322,7 +322,7 @@ TdiDefaultChainedReceiveHandler( IN PVOID TsduDescriptor); typedef NTSTATUS -(DDKAPI *PTDI_IND_CHAINED_RECEIVE_DATAGRAM)( +(NTAPI *PTDI_IND_CHAINED_RECEIVE_DATAGRAM)( IN PVOID TdiEventContext, IN LONG SourceAddressLength, IN PVOID SourceAddress, @@ -336,7 +336,7 @@ typedef NTSTATUS TDIKRNLAPI NTSTATUS -DDKAPI +NTAPI TdiDefaultChainedRcvDatagramHandler( IN PVOID TdiEventContext, IN LONG SourceAddressLength, @@ -350,7 +350,7 @@ TdiDefaultChainedRcvDatagramHandler( IN PVOID TsduDescriptor); typedef NTSTATUS -(DDKAPI *PTDI_IND_CHAINED_RECEIVE_EXPEDITED)( +(NTAPI *PTDI_IND_CHAINED_RECEIVE_EXPEDITED)( IN PVOID TdiEventContext, IN CONNECTION_CONTEXT ConnectionContext, IN ULONG ReceiveFlags, @@ -361,7 +361,7 @@ typedef NTSTATUS TDIKRNLAPI NTSTATUS -DDKAPI +NTAPI TdiDefaultChainedRcvExpeditedHandler( IN PVOID TdiEventContext, IN CONNECTION_CONTEXT ConnectionContext, @@ -372,14 +372,14 @@ TdiDefaultChainedRcvExpeditedHandler( IN PVOID TsduDescriptor); typedef NTSTATUS -(DDKAPI *PTDI_IND_SEND_POSSIBLE)( +(NTAPI *PTDI_IND_SEND_POSSIBLE)( IN PVOID TdiEventContext, IN PVOID ConnectionContext, IN ULONG BytesAvailable); TDIKRNLAPI NTSTATUS -DDKAPI +NTAPI TdiDefaultSendPossibleHandler( IN PVOID TdiEventContext, IN PVOID ConnectionContext, @@ -611,7 +611,7 @@ TdiDefaultSendPossibleHandler( TDIKRNLAPI VOID -DDKAPI +NTAPI TdiBuildNetbiosAddress( IN PUCHAR NetbiosName, IN BOOLEAN IsGroupName, @@ -619,7 +619,7 @@ TdiBuildNetbiosAddress( TDIKRNLAPI NTSTATUS -DDKAPI +NTAPI TdiBuildNetbiosAddressEa( IN PUCHAR Buffer, IN BOOLEAN IsGroupName, @@ -869,48 +869,48 @@ typedef struct _TDI_PNP_CONTEXT { } TDI_PNP_CONTEXT, *PTDI_PNP_CONTEXT; typedef VOID -(DDKAPI *TDI_ADD_ADDRESS_HANDLER)( +(NTAPI *TDI_ADD_ADDRESS_HANDLER)( IN PTA_ADDRESS Address); typedef VOID -(DDKAPI *TDI_ADD_ADDRESS_HANDLER_V2)( +(NTAPI *TDI_ADD_ADDRESS_HANDLER_V2)( IN PTA_ADDRESS Address, IN PUNICODE_STRING DeviceName, IN PTDI_PNP_CONTEXT Context); typedef VOID -(DDKAPI *TDI_BINDING_HANDLER)( +(NTAPI *TDI_BINDING_HANDLER)( IN TDI_PNP_OPCODE PnPOpcode, IN PUNICODE_STRING DeviceName, IN PWSTR MultiSZBindList); typedef VOID -(DDKAPI *TDI_BIND_HANDLER)( +(NTAPI *TDI_BIND_HANDLER)( IN PUNICODE_STRING DeviceName); typedef VOID -(DDKAPI *TDI_DEL_ADDRESS_HANDLER)( +(NTAPI *TDI_DEL_ADDRESS_HANDLER)( IN PTA_ADDRESS Address); typedef VOID -(DDKAPI *TDI_DEL_ADDRESS_HANDLER_V2)( +(NTAPI *TDI_DEL_ADDRESS_HANDLER_V2)( IN PTA_ADDRESS Address, IN PUNICODE_STRING DeviceName, IN PTDI_PNP_CONTEXT Context); typedef NTSTATUS -(DDKAPI *TDI_PNP_POWER_HANDLER)( +(NTAPI *TDI_PNP_POWER_HANDLER)( IN PUNICODE_STRING DeviceName, IN PNET_PNP_EVENT PowerEvent, IN PTDI_PNP_CONTEXT Context1, IN PTDI_PNP_CONTEXT Context2); typedef VOID -(DDKAPI *TDI_UNBIND_HANDLER)( +(NTAPI *TDI_UNBIND_HANDLER)( IN PUNICODE_STRING DeviceName); typedef VOID -(DDKAPI *ProviderPnPPowerComplete)( +(NTAPI *ProviderPnPPowerComplete)( IN PNET_PNP_EVENT NetEvent, IN NTSTATUS ProviderStatus); @@ -964,7 +964,7 @@ typedef TDI_CLIENT_INTERFACE_INFO *PTDI_CLIENT_INTERFACE_INFO; TDIKRNLAPI NTSTATUS -DDKAPI +NTAPI TdiCopyBufferToMdl( IN PVOID SourceBuffer, IN ULONG SourceOffset, @@ -986,7 +986,7 @@ TdiCopyBufferToMdl( TDIKRNLAPI NTSTATUS -DDKAPI +NTAPI TdiCopyMdlChainToMdlChain ( IN PMDL SourceMdlChain, IN ULONG SourceOffset, @@ -996,7 +996,7 @@ TdiCopyMdlChainToMdlChain ( TDIKRNLAPI NTSTATUS -DDKAPI +NTAPI TdiCopyMdlToBuffer( IN PMDL SourceMdlChain, IN ULONG SourceOffset, @@ -1007,55 +1007,55 @@ TdiCopyMdlToBuffer( TDIKRNLAPI NTSTATUS -DDKAPI +NTAPI TdiDeregisterAddressChangeHandler( IN HANDLE BindingHandle); TDIKRNLAPI NTSTATUS -DDKAPI +NTAPI TdiDeregisterDeviceObject( IN HANDLE DevRegistrationHandle); TDIKRNLAPI NTSTATUS -DDKAPI +NTAPI TdiDeregisterNetAddress( IN HANDLE AddrRegistrationHandle); TDIKRNLAPI NTSTATUS -DDKAPI +NTAPI TdiDeregisterPnPHandlers( IN HANDLE BindingHandle); TDIKRNLAPI NTSTATUS -DDKAPI +NTAPI TdiDeregisterProvider( IN HANDLE ProviderHandle); TDIKRNLAPI NTSTATUS -DDKAPI +NTAPI TdiEnumerateAddresses( IN HANDLE BindingHandle); TDIKRNLAPI VOID -DDKAPI +NTAPI TdiInitialize( VOID); TDIKRNLAPI VOID -DDKAPI +NTAPI TdiMapBuffer( IN PMDL MdlChain); TDIKRNLAPI NTSTATUS -DDKAPI +NTAPI TdiMapUserRequest( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, @@ -1063,14 +1063,14 @@ TdiMapUserRequest( TDIKRNLAPI BOOLEAN -DDKAPI +NTAPI TdiMatchPdoWithChainedReceiveContext( IN PVOID TsduDescriptor, IN PVOID PDO); TDIKRNLAPI VOID -DDKAPI +NTAPI TdiPnPPowerComplete( IN HANDLE BindingHandle, IN PNET_PNP_EVENT PowerEvent, @@ -1078,7 +1078,7 @@ TdiPnPPowerComplete( TDIKRNLAPI NTSTATUS -DDKAPI +NTAPI TdiPnPPowerRequest( IN PUNICODE_STRING DeviceName, IN PNET_PNP_EVENT PowerEvent, @@ -1088,13 +1088,13 @@ TdiPnPPowerRequest( TDIKRNLAPI NTSTATUS -DDKAPI +NTAPI TdiProviderReady( IN HANDLE ProviderHandle); TDIKRNLAPI NTSTATUS -DDKAPI +NTAPI TdiRegisterAddressChangeHandler( IN TDI_ADD_ADDRESS_HANDLER AddHandler, IN TDI_DEL_ADDRESS_HANDLER DeleteHandler, @@ -1102,14 +1102,14 @@ TdiRegisterAddressChangeHandler( TDIKRNLAPI NTSTATUS -DDKAPI +NTAPI TdiRegisterDeviceObject( IN PUNICODE_STRING DeviceName, OUT HANDLE *DevRegistrationHandle); TDIKRNLAPI NTSTATUS -DDKAPI +NTAPI TdiRegisterNetAddress( IN PTA_ADDRESS Address, IN PUNICODE_STRING DeviceName, @@ -1118,7 +1118,7 @@ TdiRegisterNetAddress( TDIKRNLAPI NTSTATUS -DDKAPI +NTAPI TdiRegisterNotificationHandler( IN TDI_BIND_HANDLER BindHandler, IN TDI_UNBIND_HANDLER UnbindHandler, @@ -1126,7 +1126,7 @@ TdiRegisterNotificationHandler( TDIKRNLAPI NTSTATUS -DDKAPI +NTAPI TdiRegisterPnPHandlers( IN PTDI_CLIENT_INTERFACE_INFO ClientInterfaceInfo, IN ULONG InterfaceInfoSize, @@ -1134,21 +1134,21 @@ TdiRegisterPnPHandlers( TDIKRNLAPI NTSTATUS -DDKAPI +NTAPI TdiRegisterProvider( IN PUNICODE_STRING ProviderName, OUT HANDLE *ProviderHandle); TDIKRNLAPI VOID -DDKAPI +NTAPI TdiReturnChainedReceives( IN PVOID *TsduDescriptors, IN ULONG NumberOfTsdus); TDIKRNLAPI VOID -DDKAPI +NTAPI TdiUnmapBuffer( IN PMDL MdlChain); diff --git a/reactos/include/ddk/upssvc.h b/reactos/include/ddk/upssvc.h index 1d3792acfa0..8672519694b 100644 --- a/reactos/include/ddk/upssvc.h +++ b/reactos/include/ddk/upssvc.h @@ -42,12 +42,12 @@ extern "C" { UPSAPI VOID -DDKAPI +NTAPI UPSCancelWait(VOID); UPSAPI DWORD -DDKAPI +NTAPI UPSGetState(VOID); #define UPS_INITUNKNOWNERROR 0 @@ -60,23 +60,23 @@ UPSGetState(VOID); UPSAPI DWORD -DDKAPI +NTAPI UPSInit(VOID); UPSAPI VOID -DDKAPI +NTAPI UPSStop(VOID); UPSAPI VOID -DDKAPI +NTAPI UPSTurnOff( IN DWORD aTurnOffDelay); UPSAPI VOID -DDKAPI +NTAPI UPSWaitForStateChange( IN DWORD aCurrentState, IN DWORD anInterval); diff --git a/reactos/include/ddk/video.h b/reactos/include/ddk/video.h index 047a56721d9..6294b5a5a75 100644 --- a/reactos/include/ddk/video.h +++ b/reactos/include/ddk/video.h @@ -76,7 +76,7 @@ typedef enum _HW_DMA_RETURN { } HW_DMA_RETURN, *PHW_DMA_RETURN; typedef HW_DMA_RETURN -(DDKAPI *PVIDEO_HW_START_DMA)( +(NTAPI *PVIDEO_HW_START_DMA)( PVOID HwDeviceExtension, PDMA pDma); @@ -144,14 +144,14 @@ typedef struct _VP_SCATTER_GATHER_LIST { } VP_SCATTER_GATHER_LIST, *PVP_SCATTER_GATHER_LIST; typedef VOID -(DDKAPI *PEXECUTE_DMA)( +(NTAPI *PEXECUTE_DMA)( IN PVOID HwDeviceExtension, IN PVP_DMA_ADAPTER VpDmaAdapter, IN PVP_SCATTER_GATHER_LIST SGList, IN PVOID Context); typedef PVOID -(DDKAPI *PVIDEO_PORT_GET_PROC_ADDRESS)( +(NTAPI *PVIDEO_PORT_GET_PROC_ADDRESS)( IN PVOID HwDeviceExtension, IN PUCHAR FunctionName); @@ -188,7 +188,7 @@ typedef struct _VIDEO_PORT_CONFIG_INFO { } VIDEO_PORT_CONFIG_INFO, *PVIDEO_PORT_CONFIG_INFO; typedef VP_STATUS -(DDKAPI *PVIDEO_HW_FIND_ADAPTER)( +(NTAPI *PVIDEO_HW_FIND_ADAPTER)( IN PVOID HwDeviceExtension, IN PVOID HwContext, IN PWSTR ArgumentString, @@ -196,7 +196,7 @@ typedef VP_STATUS OUT PUCHAR Again); typedef VP_STATUS -(DDKAPI *PVIDEO_HW_POWER_GET)( +(NTAPI *PVIDEO_HW_POWER_GET)( IN PVOID HwDeviceExtension, IN ULONG HwId, IN OUT PVIDEO_POWER_MANAGEMENT VideoPowerControl); @@ -224,7 +224,7 @@ typedef enum _VIDEO_CHILD_TYPE { } VIDEO_CHILD_TYPE, *PVIDEO_CHILD_TYPE; typedef VP_STATUS -(DDKAPI *PVIDEO_HW_GET_CHILD_DESCRIPTOR)( +(NTAPI *PVIDEO_HW_GET_CHILD_DESCRIPTOR)( IN PVOID HwDeviceExtension, IN PVIDEO_CHILD_ENUM_INFO ChildEnumInfo, OUT PVIDEO_CHILD_TYPE VideoChildType, @@ -233,11 +233,11 @@ typedef VP_STATUS OUT PULONG pUnused); typedef BOOLEAN -(DDKAPI *PVIDEO_HW_INITIALIZE)( +(NTAPI *PVIDEO_HW_INITIALIZE)( IN PVOID HwDeviceExtension); typedef BOOLEAN -(DDKAPI *PVIDEO_HW_INTERRUPT)( +(NTAPI *PVIDEO_HW_INTERRUPT)( IN PVOID HwDeviceExtension); /* VIDEO_ACCESS_RANGE.RangePassive */ @@ -257,14 +257,14 @@ typedef struct _VIDEO_ACCESS_RANGE { #endif typedef VOID -(DDKAPI *PVIDEO_HW_LEGACYRESOURCES)( +(NTAPI *PVIDEO_HW_LEGACYRESOURCES)( IN ULONG VendorId, IN ULONG DeviceId, IN OUT PVIDEO_ACCESS_RANGE *LegacyResourceList, IN OUT PULONG LegacyResourceCount); typedef VP_STATUS -(DDKAPI *PMINIPORT_QUERY_DEVICE_ROUTINE)( +(NTAPI *PMINIPORT_QUERY_DEVICE_ROUTINE)( IN PVOID HwDeviceExtension, IN PVOID Context, IN VIDEO_DEVICE_DATA_TYPE DeviceDataType, @@ -284,12 +284,12 @@ typedef struct _QUERY_INTERFACE { } QUERY_INTERFACE, *PQUERY_INTERFACE; typedef VP_STATUS -(DDKAPI *PVIDEO_HW_QUERY_INTERFACE)( +(NTAPI *PVIDEO_HW_QUERY_INTERFACE)( IN PVOID HwDeviceExtension, IN OUT PQUERY_INTERFACE QueryInterface); typedef VP_STATUS -(DDKAPI *PMINIPORT_GET_REGISTRY_ROUTINE)( +(NTAPI *PMINIPORT_GET_REGISTRY_ROUTINE)( IN PVOID HwDeviceExtension, IN PVOID Context, IN OUT PWSTR ValueName, @@ -297,13 +297,13 @@ typedef VP_STATUS IN ULONG ValueLength); typedef BOOLEAN -(DDKAPI *PVIDEO_HW_RESET_HW)( +(NTAPI *PVIDEO_HW_RESET_HW)( IN PVOID HwDeviceExtension, IN ULONG Columns, IN ULONG Rows); typedef VP_STATUS -(DDKAPI *PVIDEO_HW_POWER_SET)( +(NTAPI *PVIDEO_HW_POWER_SET)( IN PVOID HwDeviceExtension, IN ULONG HwId, IN PVIDEO_POWER_MANAGEMENT VideoPowerControl); @@ -326,32 +326,32 @@ typedef struct _VIDEO_REQUEST_PACKET { } VIDEO_REQUEST_PACKET, *PVIDEO_REQUEST_PACKET; typedef BOOLEAN -(DDKAPI *PVIDEO_HW_START_IO)( +(NTAPI *PVIDEO_HW_START_IO)( IN PVOID HwDeviceExtension, IN PVIDEO_REQUEST_PACKET RequestPacket); typedef BOOLEAN -(DDKAPI *PMINIPORT_SYNCHRONIZE_ROUTINE)( +(NTAPI *PMINIPORT_SYNCHRONIZE_ROUTINE)( IN PVOID Context); typedef VOID -(DDKAPI *PVIDEO_HW_TIMER)( +(NTAPI *PVIDEO_HW_TIMER)( IN PVOID HwDeviceExtension); typedef VOID -(DDKAPI *PMINIPORT_DPC_ROUTINE)( +(NTAPI *PMINIPORT_DPC_ROUTINE)( IN PVOID HwDeviceExtension, IN PVOID Context); typedef VP_STATUS -(DDKAPI *PDRIVER_IO_PORT_UCHAR)( +(NTAPI *PDRIVER_IO_PORT_UCHAR)( IN ULONG_PTR Context, IN ULONG Port, IN UCHAR AccessMode, IN PUCHAR Data); typedef VP_STATUS -(DDKAPI *PDRIVER_IO_PORT_UCHAR_STRING)( +(NTAPI *PDRIVER_IO_PORT_UCHAR_STRING)( IN ULONG_PTR Context, IN ULONG Port, IN UCHAR AccessMode, @@ -359,14 +359,14 @@ typedef VP_STATUS IN ULONG DataLength); typedef VP_STATUS -(DDKAPI *PDRIVER_IO_PORT_ULONG)( +(NTAPI *PDRIVER_IO_PORT_ULONG)( IN ULONG_PTR Context, IN ULONG Port, IN UCHAR AccessMode, IN PULONG Data); typedef VP_STATUS -(DDKAPI *PDRIVER_IO_PORT_ULONG_STRING)( +(NTAPI *PDRIVER_IO_PORT_ULONG_STRING)( IN ULONG_PTR Context, IN ULONG Port, IN UCHAR AccessMode, @@ -374,14 +374,14 @@ typedef VP_STATUS IN ULONG DataLength); typedef VP_STATUS -(DDKAPI *PDRIVER_IO_PORT_USHORT)( +(NTAPI *PDRIVER_IO_PORT_USHORT)( IN ULONG_PTR Context, IN ULONG Port, IN UCHAR AccessMode, IN PUSHORT Data); typedef VP_STATUS -(DDKAPI *PDRIVER_IO_PORT_USHORT_STRING)( +(NTAPI *PDRIVER_IO_PORT_USHORT_STRING)( IN ULONG_PTR Context, IN ULONG Port, IN UCHAR AccessMode, @@ -480,21 +480,21 @@ typedef struct _VIDEO_PORT_AGP_INTERFACE_2 { #define VIDEO_PORT_I2C_INTERFACE_VERSION_1 1 typedef VOID -(DDKAPI *PVIDEO_WRITE_CLOCK_LINE)( +(NTAPI *PVIDEO_WRITE_CLOCK_LINE)( PVOID HwDeviceExtension, UCHAR Data); typedef VOID -(DDKAPI *PVIDEO_WRITE_DATA_LINE)( +(NTAPI *PVIDEO_WRITE_DATA_LINE)( PVOID HwDeviceExtension, UCHAR Data); typedef BOOLEAN -(DDKAPI *PVIDEO_READ_CLOCK_LINE)( +(NTAPI *PVIDEO_READ_CLOCK_LINE)( PVOID HwDeviceExtension); typedef BOOLEAN -(DDKAPI *PVIDEO_READ_DATA_LINE)( +(NTAPI *PVIDEO_READ_DATA_LINE)( PVOID HwDeviceExtension); typedef struct _I2C_CALLBACKS @@ -506,24 +506,24 @@ typedef struct _I2C_CALLBACKS } I2C_CALLBACKS, *PI2C_CALLBACKS; typedef BOOLEAN -(DDKAPI *PI2C_START)( +(NTAPI *PI2C_START)( IN PVOID HwDeviceExtension, IN PI2C_CALLBACKS I2CCallbacks); typedef BOOLEAN -(DDKAPI *PI2C_STOP)( +(NTAPI *PI2C_STOP)( IN PVOID HwDeviceExtension, IN PI2C_CALLBACKS I2CCallbacks); typedef BOOLEAN -(DDKAPI *PI2C_WRITE)( +(NTAPI *PI2C_WRITE)( IN PVOID HwDeviceExtension, IN PI2C_CALLBACKS I2CCallbacks, IN PUCHAR Buffer, IN ULONG Length); typedef BOOLEAN -(DDKAPI *PI2C_READ)( +(NTAPI *PI2C_READ)( IN PVOID HwDeviceExtension, IN PI2C_CALLBACKS I2CCallbacks, OUT PUCHAR Buffer, @@ -545,25 +545,25 @@ typedef struct _VIDEO_PORT_I2C_INTERFACE { #define VIDEO_PORT_INT10_INTERFACE_VERSION_1 1 typedef VP_STATUS -(DDKAPI *PINT10_ALLOCATE_BUFFER)( +(NTAPI *PINT10_ALLOCATE_BUFFER)( IN PVOID Context, OUT PUSHORT Seg, OUT PUSHORT Off, IN OUT PULONG Length); typedef VP_STATUS -(DDKAPI *PINT10_CALL_BIOS)( +(NTAPI *PINT10_CALL_BIOS)( IN PVOID Context, IN OUT PINT10_BIOS_ARGUMENTS BiosArguments); typedef VP_STATUS -(DDKAPI *PINT10_FREE_BUFFER)( +(NTAPI *PINT10_FREE_BUFFER)( IN PVOID Context, IN USHORT Seg, IN USHORT Off); typedef VP_STATUS -(DDKAPI *PINT10_READ_MEMORY)( +(NTAPI *PINT10_READ_MEMORY)( IN PVOID Context, IN USHORT Seg, IN USHORT Off, @@ -571,7 +571,7 @@ typedef VP_STATUS IN ULONG Length); typedef VP_STATUS -(DDKAPI *PINT10_WRITE_MEMORY)( +(NTAPI *PINT10_WRITE_MEMORY)( IN PVOID Context, IN USHORT Seg, IN USHORT Off, @@ -630,13 +630,13 @@ typedef struct _VPOSVERSIONINFO { VPAPI VOID -DDKAPI +NTAPI VideoPortAcquireDeviceLock( IN PVOID HwDeviceExtension); VPAPI VOID -DDKAPI +NTAPI VideoPortAcquireSpinLock( IN PVOID HwDeviceExtension, IN PSPIN_LOCK SpinLock, @@ -644,14 +644,14 @@ VideoPortAcquireSpinLock( VPAPI VOID -DDKAPI +NTAPI VideoPortAcquireSpinLockAtDpcLevel( IN PVOID HwDeviceExtension, IN PSPIN_LOCK SpinLock); VPAPI VP_STATUS -DDKAPI +NTAPI VideoPortAllocateBuffer( IN PVOID HwDeviceExtension, IN ULONG Size, @@ -659,7 +659,7 @@ VideoPortAllocateBuffer( VPAPI PVOID -DDKAPI +NTAPI VideoPortAllocateCommonBuffer( IN PVOID HwDeviceExtension, IN PVP_DMA_ADAPTER VpDmaAdapter, @@ -670,7 +670,7 @@ VideoPortAllocateCommonBuffer( VPAPI PVOID -DDKAPI +NTAPI VideoPortAllocateContiguousMemory( IN PVOID HwDeviceExtension, IN ULONG NumberOfBytes, @@ -686,7 +686,7 @@ typedef enum _VP_POOL_TYPE { VPAPI PVOID -DDKAPI +NTAPI VideoPortAllocatePool( IN PVOID HwDeviceExtension, IN VP_POOL_TYPE PoolType, @@ -695,7 +695,7 @@ VideoPortAllocatePool( VPAPI PDMA -DDKAPI +NTAPI VideoPortAssociateEventsWithDmaHandle( IN PVOID HwDeviceExtension, IN OUT PVIDEO_REQUEST_PACKET pVrp, @@ -708,7 +708,7 @@ VideoPortAssociateEventsWithDmaHandle( VPAPI BOOLEAN -DDKAPI +NTAPI VideoPortCheckForDeviceExistence( IN PVOID HwDeviceExtension, IN USHORT VendorId, @@ -720,14 +720,14 @@ VideoPortCheckForDeviceExistence( VPAPI VOID -DDKAPI +NTAPI VideoPortClearEvent( IN PVOID HwDeviceExtension, IN PEVENT pEvent); VPAPI ULONG -DDKAPI +NTAPI VideoPortCompareMemory( IN PVOID Source1, IN PVOID Source2, @@ -735,7 +735,7 @@ VideoPortCompareMemory( VPAPI VP_STATUS -DDKAPI +NTAPI VideoPortCompleteDma( IN PVOID HwDeviceExtension, IN PVP_DMA_ADAPTER VpDmaAdapter, @@ -744,7 +744,7 @@ VideoPortCompleteDma( VPAPI VP_STATUS -DDKAPI +NTAPI VideoPortCreateEvent( IN PVOID HwDeviceExtension, IN ULONG EventFlag, @@ -753,7 +753,7 @@ VideoPortCreateEvent( VPAPI VP_STATUS -DDKAPI +NTAPI VideoPortCreateSecondaryDisplay( IN PVOID HwDeviceExtension, IN OUT PVOID *SecondaryDeviceExtension, @@ -761,7 +761,7 @@ VideoPortCreateSecondaryDisplay( VPAPI VP_STATUS -DDKAPI +NTAPI VideoPortCreateSpinLock( IN PVOID HwDeviceExtension, OUT PSPIN_LOCK *SpinLock); @@ -774,7 +774,7 @@ typedef struct _DDC_CONTROL { VPAPI BOOLEAN -DDKAPI +NTAPI VideoPortDDCMonitorHelper( IN PVOID HwDeviceExtension, IN PVOID DDCControl, @@ -783,7 +783,7 @@ VideoPortDDCMonitorHelper( VPAPI VOID -DDKCDECLAPI +__cdecl VideoPortDebugPrint( IN VIDEO_DEBUG_LEVEL DebugPrintLevel, IN PCHAR DebugMessage, @@ -791,27 +791,27 @@ VideoPortDebugPrint( VPAPI VP_STATUS -DDKAPI +NTAPI VideoPortDeleteEvent( IN PVOID HwDeviceExtension, IN PEVENT pEvent); VPAPI VP_STATUS -DDKAPI +NTAPI VideoPortDeleteSpinLock( IN PVOID HwDeviceExtension, IN PSPIN_LOCK SpinLock); VPAPI VP_STATUS -DDKAPI +NTAPI VideoPortDisableInterrupt( IN PVOID HwDeviceExtension); VPAPI PDMA -DDKAPI +NTAPI VideoPortDoDma( IN PVOID HwDeviceExtension, IN PDMA pDma, @@ -819,20 +819,20 @@ VideoPortDoDma( VPAPI VP_STATUS -DDKAPI +NTAPI VideoPortEnableInterrupt( IN PVOID HwDeviceExtension); VPAPI VP_STATUS -DDKAPI +NTAPI VideoPortEnumerateChildren( IN PVOID HwDeviceExtension, IN PVOID Reserved); VPAPI VOID -DDKAPI +NTAPI VideoPortFreeCommonBuffer( IN PVOID HwDeviceExtension, IN ULONG Length, @@ -842,21 +842,21 @@ VideoPortFreeCommonBuffer( VPAPI VOID -DDKAPI +NTAPI VideoPortFreeDeviceBase( IN PVOID HwDeviceExtension, IN PVOID MappedAddress); VPAPI VOID -DDKAPI +NTAPI VideoPortFreePool( IN PVOID HwDeviceExtension, IN PVOID Ptr); VPAPI VP_STATUS -DDKAPI +NTAPI VideoPortGetAccessRanges( IN PVOID HwDeviceExtension, IN ULONG NumRequestedResources, @@ -869,19 +869,19 @@ VideoPortGetAccessRanges( VPAPI PVOID -DDKAPI +NTAPI VideoPortGetAssociatedDeviceExtension( IN PVOID DeviceObject); VPAPI ULONG -DDKAPI +NTAPI VideoPortGetAssociatedDeviceID( IN PVOID DeviceObject); VPAPI ULONG -DDKAPI +NTAPI VideoPortGetBusData( IN PVOID HwDeviceExtension, IN BUS_DATA_TYPE BusDataType, @@ -892,14 +892,14 @@ VideoPortGetBusData( VPAPI ULONG -DDKAPI +NTAPI VideoPortGetBytesUsed( IN PVOID HwDeviceExtension, IN PDMA pDma); VPAPI PVOID -DDKAPI +NTAPI VideoPortGetCommonBuffer( IN PVOID HwDeviceExtension, IN ULONG DesiredLength, @@ -910,13 +910,13 @@ VideoPortGetCommonBuffer( VPAPI UCHAR -DDKAPI +NTAPI VideoPortGetCurrentIrql( VOID); VPAPI PVOID -DDKAPI +NTAPI VideoPortGetDeviceBase( IN PVOID HwDeviceExtension, IN PHYSICAL_ADDRESS IoAddress, @@ -925,7 +925,7 @@ VideoPortGetDeviceBase( VPAPI VP_STATUS -DDKAPI +NTAPI VideoPortGetDeviceData( IN PVOID HwDeviceExtension, IN VIDEO_DEVICE_DATA_TYPE DeviceDataType, @@ -934,28 +934,28 @@ VideoPortGetDeviceData( VPAPI PVP_DMA_ADAPTER -DDKAPI +NTAPI VideoPortGetDmaAdapter( IN PVOID HwDeviceExtension, IN PVP_DEVICE_DESCRIPTION VpDeviceDescription); VPAPI PVOID -DDKAPI +NTAPI VideoPortGetDmaContext( IN PVOID HwDeviceExtension, IN PDMA pDma); VPAPI PVOID -DDKAPI +NTAPI VideoPortGetMdl( IN PVOID HwDeviceExtension, IN PDMA pDma); VPAPI VP_STATUS -DDKAPI +NTAPI VideoPortGetRegistryParameters( IN PVOID HwDeviceExtension, IN PWSTR ParameterName, @@ -965,7 +965,7 @@ VideoPortGetRegistryParameters( VPAPI PVOID -DDKAPI +NTAPI VideoPortGetRomImage( IN PVOID HwDeviceExtension, IN PVOID Unused1, @@ -974,21 +974,21 @@ VideoPortGetRomImage( VPAPI VP_STATUS -DDKAPI +NTAPI VideoPortGetVersion( IN PVOID HwDeviceExtension, IN OUT PVPOSVERSIONINFO pVpOsVersionInfo); VPAPI VP_STATUS -DDKAPI +NTAPI VideoPortGetVgaStatus( IN PVOID HwDeviceExtension, OUT PULONG VgaStatus); VPAPI ULONG -DDKAPI +NTAPI VideoPortInitialize( IN PVOID Argument1, IN PVOID Argument2, @@ -997,7 +997,7 @@ VideoPortInitialize( VPAPI VP_STATUS -DDKAPI +NTAPI VideoPortInt10( IN PVOID HwDeviceExtension, IN PVIDEO_X86_BIOS_ARGUMENTS BiosArguments); @@ -1029,7 +1029,7 @@ typedef enum _VP_LOCK_OPERATION { VPAPI PVOID -DDKAPI +NTAPI VideoPortLockBuffer( IN PVOID HwDeviceExtension, IN PVOID BaseAddress, @@ -1038,7 +1038,7 @@ VideoPortLockBuffer( VPAPI BOOLEAN -DDKAPI +NTAPI VideoPortLockPages( IN PVOID HwDeviceExtension, IN OUT PVIDEO_REQUEST_PACKET pVrp, @@ -1048,7 +1048,7 @@ VideoPortLockPages( VPAPI VOID -DDKAPI +NTAPI VideoPortLogError( IN PVOID HwDeviceExtension, IN PVIDEO_REQUEST_PACKET Vrp OPTIONAL, @@ -1057,7 +1057,7 @@ VideoPortLogError( VPAPI VP_STATUS -DDKAPI +NTAPI VideoPortMapBankedMemory( IN PVOID HwDeviceExtension, IN PHYSICAL_ADDRESS PhysicalAddress, @@ -1071,7 +1071,7 @@ VideoPortMapBankedMemory( VPAPI PDMA -DDKAPI +NTAPI VideoPortMapDmaMemory( IN PVOID HwDeviceExtension, IN PVIDEO_REQUEST_PACKET pVrp, @@ -1084,7 +1084,7 @@ VideoPortMapDmaMemory( VPAPI VP_STATUS -DDKAPI +NTAPI VideoPortMapMemory( IN PVOID HwDeviceExtension, IN PHYSICAL_ADDRESS PhysicalAddress, @@ -1094,7 +1094,7 @@ VideoPortMapMemory( VPAPI VOID -DDKAPI +NTAPI VideoPortMoveMemory( IN PVOID Destination, IN PVOID Source, @@ -1102,14 +1102,14 @@ VideoPortMoveMemory( VPAPI VOID -DDKAPI +NTAPI VideoPortPutDmaAdapter( IN PVOID HwDeviceExtension, IN PVP_DMA_ADAPTER VpDmaAdapter); VPAPI LONGLONG -DDKAPI +NTAPI VideoPortQueryPerformanceCounter( IN PVOID HwDeviceExtension, OUT PLONGLONG PerformanceFrequency OPTIONAL); @@ -1124,7 +1124,7 @@ typedef enum _VIDEO_PORT_SERVICES { VPAPI VP_STATUS -DDKAPI +NTAPI VideoPortQueryServices( IN PVOID HwDeviceExtension, IN VIDEO_PORT_SERVICES ServicesType, @@ -1132,20 +1132,20 @@ VideoPortQueryServices( VPAPI VOID -DDKAPI +NTAPI VideoPortQuerySystemTime( OUT PLARGE_INTEGER CurrentTime); VPAPI BOOLEAN -DDKAPI +NTAPI VideoPortIsNoVesa( VOID ); VPAPI BOOLEAN -DDKAPI +NTAPI VideoPortQueueDpc( IN PVOID HwDeviceExtension, IN PMINIPORT_DPC_ROUTINE CallbackRoutine, @@ -1153,7 +1153,7 @@ VideoPortQueueDpc( VPAPI VOID -DDKAPI +NTAPI VideoPortReadPortBufferUchar( IN PUCHAR Port, OUT PUCHAR Buffer, @@ -1161,7 +1161,7 @@ VideoPortReadPortBufferUchar( VPAPI VOID -DDKAPI +NTAPI VideoPortReadPortBufferUlong( IN PULONG Port, OUT PULONG Buffer, @@ -1169,7 +1169,7 @@ VideoPortReadPortBufferUlong( VPAPI VOID -DDKAPI +NTAPI VideoPortReadPortBufferUshort( IN PUSHORT Port, OUT PUSHORT Buffer, @@ -1177,25 +1177,25 @@ VideoPortReadPortBufferUshort( VPAPI UCHAR -DDKAPI +NTAPI VideoPortReadPortUchar( IN PUCHAR Port); VPAPI ULONG -DDKAPI +NTAPI VideoPortReadPortUlong( IN PULONG Port); VPAPI USHORT -DDKAPI +NTAPI VideoPortReadPortUshort( IN PUSHORT Port); VPAPI VOID -DDKAPI +NTAPI VideoPortReadRegisterBufferUchar( IN PUCHAR Register, OUT PUCHAR Buffer, @@ -1203,7 +1203,7 @@ VideoPortReadRegisterBufferUchar( VPAPI VOID -DDKAPI +NTAPI VideoPortReadRegisterBufferUlong( IN PULONG Register, OUT PULONG Buffer, @@ -1211,7 +1211,7 @@ VideoPortReadRegisterBufferUlong( VPAPI VOID -DDKAPI +NTAPI VideoPortReadRegisterBufferUshort( IN PUSHORT Register, OUT PUSHORT Buffer, @@ -1219,39 +1219,39 @@ VideoPortReadRegisterBufferUshort( VPAPI UCHAR -DDKAPI +NTAPI VideoPortReadRegisterUchar( IN PUCHAR Register); VPAPI ULONG -DDKAPI +NTAPI VideoPortReadRegisterUlong( IN PULONG Register); VPAPI USHORT -DDKAPI +NTAPI VideoPortReadRegisterUshort( IN PUSHORT Register); VPAPI LONG -DDKAPI +NTAPI VideoPortReadStateEvent( IN PVOID HwDeviceExtension, IN PEVENT pEvent); VPAPI VOID -DDKAPI +NTAPI VideoPortReleaseBuffer( IN PVOID HwDeviceExtension, IN PVOID Buffer); VPAPI VOID -DDKAPI +NTAPI VideoPortReleaseCommonBuffer( IN PVOID HwDeviceExtension, IN PVP_DMA_ADAPTER VpDmaAdapter, @@ -1262,13 +1262,13 @@ VideoPortReleaseCommonBuffer( VPAPI VOID -DDKAPI +NTAPI VideoPortReleaseDeviceLock( IN PVOID HwDeviceExtension); VPAPI VOID -DDKAPI +NTAPI VideoPortReleaseSpinLock( IN PVOID HwDeviceExtension, IN PSPIN_LOCK SpinLock, @@ -1276,14 +1276,14 @@ VideoPortReleaseSpinLock( VPAPI VOID -DDKAPI +NTAPI VideoPortReleaseSpinLockFromDpcLevel( IN PVOID HwDeviceExtension, IN PSPIN_LOCK SpinLock); VPAPI BOOLEAN -DDKAPI +NTAPI VideoPortScanRom( PVOID HwDeviceExtension, PUCHAR RomBase, @@ -1292,7 +1292,7 @@ VideoPortScanRom( VPAPI ULONG -DDKAPI +NTAPI VideoPortSetBusData( IN PVOID HwDeviceExtension, IN BUS_DATA_TYPE BusDataType, @@ -1303,7 +1303,7 @@ VideoPortSetBusData( VPAPI VOID -DDKAPI +NTAPI VideoPortSetBytesUsed( IN PVOID HwDeviceExtension, IN OUT PDMA pDma, @@ -1311,7 +1311,7 @@ VideoPortSetBytesUsed( VPAPI VOID -DDKAPI +NTAPI VideoPortSetDmaContext( IN PVOID HwDeviceExtension, OUT PDMA pDma, @@ -1319,14 +1319,14 @@ VideoPortSetDmaContext( VPAPI LONG -DDKAPI +NTAPI VideoPortSetEvent( IN PVOID HwDeviceExtension, IN PEVENT pEvent); VPAPI VP_STATUS -DDKAPI +NTAPI VideoPortSetRegistryParameters( IN PVOID HwDeviceExtension, IN PWSTR ValueName, @@ -1335,7 +1335,7 @@ VideoPortSetRegistryParameters( VPAPI VP_STATUS -DDKAPI +NTAPI VideoPortSetTrappedEmulatorPorts( IN PVOID HwDeviceExtension, IN ULONG NumAccessRanges, @@ -1343,20 +1343,20 @@ VideoPortSetTrappedEmulatorPorts( VPAPI BOOLEAN -DDKAPI +NTAPI VideoPortSignalDmaComplete( IN PVOID HwDeviceExtension, IN PDMA pDmaHandle); VPAPI VOID -DDKAPI +NTAPI VideoPortStallExecution( IN ULONG Microseconds); VPAPI VP_STATUS -DDKAPI +NTAPI VideoPortStartDma( IN PVOID HwDeviceExtension, IN PVP_DMA_ADAPTER VpDmaAdapter, @@ -1369,13 +1369,13 @@ VideoPortStartDma( VPAPI VOID -DDKAPI +NTAPI VideoPortStartTimer( IN PVOID HwDeviceExtension); VPAPI VOID -DDKAPI +NTAPI VideoPortStopTimer( IN PVOID HwDeviceExtension); @@ -1388,7 +1388,7 @@ typedef enum VIDEO_SYNCHRONIZE_PRIORITY { VPAPI BOOLEAN -DDKAPI +NTAPI VideoPortSynchronizeExecution( IN PVOID HwDeviceExtension, IN VIDEO_SYNCHRONIZE_PRIORITY Priority, @@ -1397,21 +1397,21 @@ VideoPortSynchronizeExecution( VPAPI VOID -DDKAPI +NTAPI VideoPortUnLockBuffer( IN PVOID HwDeviceExtension, IN PVOID Mdl); VPAPI BOOLEAN -DDKAPI +NTAPI VideoPortUnlockPages( IN PVOID hwDeviceExtension, IN OUT PDMA pDma); VPAPI BOOLEAN -DDKAPI +NTAPI VideoPortUnmapDmaMemory( IN PVOID HwDeviceExtension, IN PVOID VirtualAddress, @@ -1420,7 +1420,7 @@ VideoPortUnmapDmaMemory( VPAPI VP_STATUS -DDKAPI +NTAPI VideoPortUnmapMemory( IN PVOID HwDeviceExtension, IN OUT PVOID VirtualAddress, @@ -1428,7 +1428,7 @@ VideoPortUnmapMemory( VPAPI VP_STATUS -DDKAPI +NTAPI VideoPortVerifyAccessRanges( IN PVOID HwDeviceExtension, IN ULONG NumAccessRanges, @@ -1436,7 +1436,7 @@ VideoPortVerifyAccessRanges( VPAPI VP_STATUS -DDKAPI +NTAPI VideoPortWaitForSingleObject( IN PVOID HwDeviceExtension, IN PVOID Object, @@ -1444,7 +1444,7 @@ VideoPortWaitForSingleObject( VPAPI VOID -DDKAPI +NTAPI VideoPortWritePortBufferUchar( IN PUCHAR Port, IN PUCHAR Buffer, @@ -1452,7 +1452,7 @@ VideoPortWritePortBufferUchar( VPAPI VOID -DDKAPI +NTAPI VideoPortWritePortBufferUlong( IN PULONG Port, IN PULONG Buffer, @@ -1460,7 +1460,7 @@ VideoPortWritePortBufferUlong( VPAPI VOID -DDKAPI +NTAPI VideoPortWritePortBufferUshort( IN PUSHORT Port, IN PUSHORT Buffer, @@ -1468,28 +1468,28 @@ VideoPortWritePortBufferUshort( VPAPI VOID -DDKAPI +NTAPI VideoPortWritePortUchar( IN PUCHAR Port, IN UCHAR Value); VPAPI VOID -DDKAPI +NTAPI VideoPortWritePortUlong( IN PULONG Port, IN ULONG Value); VPAPI VOID -DDKAPI +NTAPI VideoPortWritePortUshort( IN PUSHORT Port, IN USHORT Value); VPAPI VOID -DDKAPI +NTAPI VideoPortWriteRegisterBufferUchar( IN PUCHAR Register, IN PUCHAR Buffer, @@ -1497,7 +1497,7 @@ VideoPortWriteRegisterBufferUchar( VPAPI VOID -DDKAPI +NTAPI VideoPortWriteRegisterBufferUlong( IN PULONG Register, IN PULONG Buffer, @@ -1505,7 +1505,7 @@ VideoPortWriteRegisterBufferUlong( VPAPI VOID -DDKAPI +NTAPI VideoPortWriteRegisterBufferUshort( IN PUSHORT Register, IN PUSHORT Buffer, @@ -1513,35 +1513,35 @@ VideoPortWriteRegisterBufferUshort( VPAPI VOID -DDKAPI +NTAPI VideoPortWriteRegisterUchar( IN PUCHAR Register, IN UCHAR Value); VPAPI VOID -DDKAPI +NTAPI VideoPortWriteRegisterUlong( IN PULONG Register, IN ULONG Value); VPAPI VOID -DDKAPI +NTAPI VideoPortWriteRegisterUshort( IN PUSHORT Register, IN USHORT Value); VPAPI VOID -DDKAPI +NTAPI VideoPortZeroDeviceMemory( IN PVOID Destination, IN ULONG Length); VPAPI VOID -DDKAPI +NTAPI VideoPortZeroMemory( IN PVOID Destination, IN ULONG Length); diff --git a/reactos/include/ddk/videoagp.h b/reactos/include/ddk/videoagp.h index 4a647ae6756..0b6d36d4126 100644 --- a/reactos/include/ddk/videoagp.h +++ b/reactos/include/ddk/videoagp.h @@ -41,59 +41,59 @@ typedef enum _VIDEO_PORT_CACHE_TYPE { } VIDEO_PORT_CACHE_TYPE; typedef BOOLEAN -(DDKAPI *PAGP_COMMIT_PHYSICAL)( +(NTAPI *PAGP_COMMIT_PHYSICAL)( IN PVOID HwDeviceExtension, IN PVOID PhysicalReserveContext, IN ULONG Pages, IN ULONG Offset); typedef PVOID -(DDKAPI *PAGP_COMMIT_VIRTUAL)( +(NTAPI *PAGP_COMMIT_VIRTUAL)( IN PVOID HwDeviceExtension, IN PVOID VirtualReserveContext, IN ULONG Pages, IN ULONG Offset); typedef VOID -(DDKAPI *PAGP_FREE_PHYSICAL)( +(NTAPI *PAGP_FREE_PHYSICAL)( IN PVOID HwDeviceExtension, IN PVOID PhysicalReserveContext, IN ULONG Pages, IN ULONG Offset); typedef VOID -(DDKAPI *PAGP_FREE_VIRTUAL)( +(NTAPI *PAGP_FREE_VIRTUAL)( IN PVOID HwDeviceExtension, IN PVOID VirtualReserveContext, IN ULONG Pages, IN ULONG Offset); typedef VOID -(DDKAPI *PAGP_RELEASE_PHYSICAL)( +(NTAPI *PAGP_RELEASE_PHYSICAL)( IN PVOID HwDeviceExtension, IN PVOID PhysicalReserveContext); typedef VOID -(DDKAPI *PAGP_RELEASE_VIRTUAL)( +(NTAPI *PAGP_RELEASE_VIRTUAL)( IN PVOID HwDeviceExtension, IN PVOID VirtualReserveContext); typedef PHYSICAL_ADDRESS -(DDKAPI *PAGP_RESERVE_PHYSICAL)( +(NTAPI *PAGP_RESERVE_PHYSICAL)( IN PVOID HwDeviceExtension, IN ULONG Pages, IN VIDEO_PORT_CACHE_TYPE Caching, OUT PVOID *PhysicalReserveContext); typedef PVOID -(DDKAPI *PAGP_RESERVE_VIRTUAL)( +(NTAPI *PAGP_RESERVE_VIRTUAL)( IN PVOID HwDeviceExtension, IN HANDLE ProcessHandle, IN PVOID PhysicalReserveContext, OUT PVOID *VirtualReserveContext); typedef BOOLEAN -(DDKAPI *PAGP_SET_RATE)( +(NTAPI *PAGP_SET_RATE)( IN PVOID HwDeviceExtension, IN ULONG AgpRate); @@ -111,7 +111,7 @@ typedef struct _VIDEO_PORT_AGP_SERVICES { VPAPI BOOLEAN -DDKAPI +NTAPI VideoPortGetAgpServices( IN PVOID HwDeviceExtension, IN PVIDEO_PORT_AGP_SERVICES AgpServices); diff --git a/reactos/include/psdk/batclass.h b/reactos/include/psdk/batclass.h index 457212519d0..24fc0892944 100644 --- a/reactos/include/psdk/batclass.h +++ b/reactos/include/psdk/batclass.h @@ -180,11 +180,11 @@ typedef struct _BATTERY_WAIT_STATUS { typedef NTSTATUS -(DDKAPI*BCLASS_DISABLE_STATUS_NOTIFY)( +(NTAPI *BCLASS_DISABLE_STATUS_NOTIFY)( IN PVOID Context); typedef NTSTATUS -(DDKAPI*BCLASS_QUERY_INFORMATION)( +(NTAPI *BCLASS_QUERY_INFORMATION)( IN PVOID Context, IN ULONG BatteryTag, IN BATTERY_QUERY_INFORMATION_LEVEL Level, @@ -194,25 +194,25 @@ typedef NTSTATUS OUT PULONG ReturnedLength); typedef NTSTATUS -(DDKAPI*BCLASS_QUERY_STATUS)( +(NTAPI *BCLASS_QUERY_STATUS)( IN PVOID Context, IN ULONG BatteryTag, OUT PBATTERY_STATUS BatteryStatus); typedef NTSTATUS -(DDKAPI*BCLASS_QUERY_TAG)( +(NTAPI *BCLASS_QUERY_TAG)( IN PVOID Context, OUT PULONG BatteryTag); typedef NTSTATUS -(DDKAPI*BCLASS_SET_INFORMATION)( +(NTAPI *BCLASS_SET_INFORMATION)( IN PVOID Context, IN ULONG BatteryTag, IN BATTERY_SET_INFORMATION_LEVEL Level, IN PVOID Buffer OPTIONAL); typedef NTSTATUS -(DDKAPI*BCLASS_SET_STATUS_NOTIFY)( +(NTAPI *BCLASS_SET_STATUS_NOTIFY)( IN PVOID Context, IN ULONG BatteryTag, IN PBATTERY_NOTIFY BatteryNotify); @@ -239,21 +239,21 @@ typedef struct _BATTERY_MINIPORT_INFO { BCLASSAPI NTSTATUS -DDKAPI +NTAPI BatteryClassInitializeDevice( IN PBATTERY_MINIPORT_INFO MiniportInfo, IN PVOID *ClassData); BCLASSAPI NTSTATUS -DDKAPI +NTAPI BatteryClassIoctl( IN PVOID ClassData, IN PIRP Irp); BCLASSAPI NTSTATUS -DDKAPI +NTAPI BatteryClassQueryWmiDataBlock( IN PVOID ClassData, IN PDEVICE_OBJECT DeviceObject, @@ -265,13 +265,13 @@ BatteryClassQueryWmiDataBlock( BCLASSAPI NTSTATUS -DDKAPI +NTAPI BatteryClassStatusNotify( IN PVOID ClassData); BCLASSAPI NTSTATUS -DDKAPI +NTAPI BatteryClassSystemControl( IN PVOID ClassData, IN PVOID WmiLibContext, /* PWMILIB_CONTEXT */ @@ -281,7 +281,7 @@ BatteryClassSystemControl( BCLASSAPI NTSTATUS -DDKAPI +NTAPI BatteryClassUnload( IN PVOID ClassData); From 9f049065102214a9f88170810c69507f8a27c103 Mon Sep 17 00:00:00 2001 From: Sir Richard Date: Mon, 29 Mar 2010 02:02:07 +0000 Subject: [PATCH 065/134] [COMPBATT]: Mini-class driver interface work: CompBattDisableStatusNotify, CompBattQueryTag, CompBattRecalculateTag, CompBattGetBatteryInformation. svn path=/trunk/; revision=46543 --- reactos/drivers/bus/acpi/compbatt/compbatt.c | 254 +++++++++++++++++-- reactos/drivers/bus/acpi/compbatt/compbatt.h | 15 ++ reactos/drivers/bus/acpi/compbatt/comppnp.c | 6 + 3 files changed, 258 insertions(+), 17 deletions(-) diff --git a/reactos/drivers/bus/acpi/compbatt/compbatt.c b/reactos/drivers/bus/acpi/compbatt/compbatt.c index e0006eca97a..b337241be4d 100644 --- a/reactos/drivers/bus/acpi/compbatt/compbatt.c +++ b/reactos/drivers/bus/acpi/compbatt/compbatt.c @@ -81,12 +81,41 @@ CompBattMonitorIrpCompleteWorker(IN PCOMPBATT_BATTERY_DATA BatteryData) return STATUS_NOT_IMPLEMENTED; } -NTSTATUS +VOID NTAPI CompBattRecalculateTag(IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension) { - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; + PCOMPBATT_BATTERY_DATA BatteryData; + ULONG Tag; + PLIST_ENTRY ListHead, NextEntry; + if (CompBattDebug & 0x100) DbgPrint("CompBatt: ENTERING CompBattRecalculateTag\n"); + + /* Loop the battery list */ + ExAcquireFastMutex(&DeviceExtension->Lock); + ListHead = &DeviceExtension->BatteryList; + NextEntry = ListHead->Flink; + while (NextEntry != ListHead) + { + /* Get the battery information and check if it has a tag */ + BatteryData = CONTAINING_RECORD(NextEntry, COMPBATT_BATTERY_DATA, BatteryLink); + if (BatteryData->Flags & COMPBATT_TAG_ASSIGNED) + { + /* Generate the next tag and exit */ + Tag = DeviceExtension->NextTag; + DeviceExtension->Flags |= COMPBATT_TAG_ASSIGNED; + DeviceExtension->Tag = Tag; + DeviceExtension->NextTag = Tag + 1; + break; + } + + /* No tag for this device extension, clear it */ + DeviceExtension->Tag = 0; + NextEntry = NextEntry->Flink; + } + + /* We're done */ + ExReleaseFastMutex(&DeviceExtension->Lock); + if (CompBattDebug & 0x100) DbgPrint("CompBatt: EXITING CompBattRecalculateTag\n"); } NTSTATUS @@ -118,16 +147,61 @@ NTAPI CompBattQueryTag(IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension, OUT PULONG Tag) { - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; + NTSTATUS Status; + PAGED_CODE(); + if (CompBattDebug & 0x100) DbgPrint("CompBatt: ENTERING QueryTag\n"); + + /* Was a tag assigned? */ + if (!(DeviceExtension->Flags & COMPBATT_TAG_ASSIGNED)) + { + /* Assign one */ + CompBattRecalculateTag(DeviceExtension); + } + + /* Do we have a tag now? */ + if ((DeviceExtension->Flags & COMPBATT_TAG_ASSIGNED) && (DeviceExtension->Tag)) + { + /* Return the tag */ + *Tag = DeviceExtension->Tag; + Status = STATUS_SUCCESS; + } + else + { + /* No tag */ + *Tag = 0; + Status = STATUS_NO_SUCH_DEVICE; + } + + /* Return status */ + if (CompBattDebug & 0x100) DbgPrint("CompBatt: EXITING QueryTag\n"); + return Status; } NTSTATUS NTAPI CompBattDisableStatusNotify(IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension) { - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; + PCOMPBATT_BATTERY_DATA BatteryData; + PLIST_ENTRY ListHead, NextEntry; + if (CompBattDebug & 0x100) DbgPrint("CompBatt: ENTERING DisableStatusNotify\n"); + + /* Loop the battery list */ + ExAcquireFastMutex(&DeviceExtension->Lock); + ListHead = &DeviceExtension->BatteryList; + NextEntry = ListHead->Flink; + while (NextEntry != ListHead) + { + /* Get the battery information and clear capacity data */ + BatteryData = CONTAINING_RECORD(NextEntry, COMPBATT_BATTERY_DATA, BatteryLink); + BatteryData->WaitStatus.LowCapacity = 0; + BatteryData->WaitStatus.HighCapacity = 0x7FFFFFFF; + NextEntry = NextEntry->Flink; + } + + /* Done */ + ExReleaseFastMutex(&DeviceExtension->Lock); + if (CompBattDebug & 0x100) DbgPrint("CompBatt: EXITING DisableStatusNotify\n"); + return STATUS_SUCCESS; } NTSTATUS @@ -161,11 +235,158 @@ CompBattQueryStatus(IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension, NTSTATUS NTAPI -CompBattGetBatteryInformation(OUT PBATTERY_INFORMATION BatteryInformation, +CompBattGetBatteryInformation(OUT PBATTERY_INFORMATION BatteryInfo, IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension) { - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; + NTSTATUS Status = STATUS_SUCCESS; + BATTERY_QUERY_INFORMATION InputBuffer; + PCOMPBATT_BATTERY_DATA BatteryData; + PLIST_ENTRY ListHead, NextEntry; + if (CompBattDebug & 1) DbgPrint("CompBatt: ENTERING GetBatteryInformation\n"); + + /* Set defaults */ + BatteryInfo->DefaultAlert1 = 0; + BatteryInfo->DefaultAlert2 = 0; + BatteryInfo->CriticalBias = 0; + + /* Loop the battery list */ + ExAcquireFastMutex(&DeviceExtension->Lock); + ListHead = &DeviceExtension->BatteryList; + NextEntry = ListHead->Flink; + while (NextEntry != ListHead) + { + /* Try to acquire the remove lock */ + BatteryData = CONTAINING_RECORD(NextEntry, COMPBATT_BATTERY_DATA, BatteryLink); + if (NT_SUCCESS(IoAcquireRemoveLock(&BatteryData->RemoveLock, 0))) + { + /* Now release the device lock since the battery can't go away */ + ExReleaseFastMutex(&DeviceExtension->Lock); + + /* Build the query */ + InputBuffer.BatteryTag = BatteryData->Tag; + InputBuffer.InformationLevel = BatteryInformation; + InputBuffer.AtRate = 0; + + /* Make sure the battery has a tag */ + if (BatteryData->Tag) + { + /* Do we already have the data? */ + if (!(BatteryData->Flags & COMPBATT_BATTERY_INFORMATION_PRESENT)) + { + /* Send the IOCTL to query the information */ + RtlZeroMemory(&BatteryData->BatteryInformation, + sizeof(BatteryData->BatteryInformation)); + Status = BatteryIoctl(IOCTL_BATTERY_QUERY_INFORMATION, + BatteryData->DeviceObject, + &InputBuffer, + sizeof(InputBuffer), + &BatteryData->BatteryInformation, + sizeof(BatteryData->BatteryInformation), + 0); + if (!NT_SUCCESS(Status)) + { + /* Fail if the query had a problem */ + if (Status == STATUS_DEVICE_REMOVED) Status = STATUS_NO_SUCH_DEVICE; + ExAcquireFastMutex(&DeviceExtension->Lock); + IoReleaseRemoveLock(&BatteryData->RemoveLock, 0); + break; + } + + /* Next time we can use the static copy */ + BatteryData->Flags |= COMPBATT_BATTERY_INFORMATION_PRESENT; + if (CompBattDebug & 2) + DbgPrint("CompBattGetBatteryInformation: Read individual BATTERY_INFORMATION\n" + "-------- Capabilities = %x\n-------- Technology = %x\n" + "-------- Chemistry[4] = %x\n-------- DesignedCapacity = %x\n" + "-------- FullChargedCapacity = %x\n-------- DefaultAlert1 = %x\n" + "-------- DefaultAlert2 = %x\n-------- CriticalBias = %x\n" + "-------- CycleCount = %x\n", + BatteryData->BatteryInformation.Capabilities, + BatteryData->BatteryInformation.Technology, + BatteryData->BatteryInformation.Chemistry, + BatteryData->BatteryInformation.DesignedCapacity, + BatteryData->BatteryInformation.FullChargedCapacity, + BatteryData->BatteryInformation.DefaultAlert1, + BatteryData->BatteryInformation.DefaultAlert2, + BatteryData->BatteryInformation.CriticalBias, + BatteryData->BatteryInformation.CycleCount); + } + + /* Combine capabilities */ + BatteryInfo->Capabilities |= BatteryData->BatteryInformation.Capabilities; + + /* Add-on capacity */ + if (BatteryData->BatteryInformation.DesignedCapacity != BATTERY_UNKNOWN_CAPACITY) + { + BatteryInfo->DesignedCapacity += BatteryData->BatteryInformation.DesignedCapacity; + } + + /* Add on fully charged capacity */ + if (BatteryData->BatteryInformation.FullChargedCapacity != BATTERY_UNKNOWN_CAPACITY) + { + BatteryInfo->FullChargedCapacity += BatteryData->BatteryInformation.FullChargedCapacity; + } + + /* Choose the highest alert */ + BatteryInfo->DefaultAlert1 = max(BatteryInfo->DefaultAlert1, + BatteryData->BatteryInformation.DefaultAlert1); + + /* Choose the highest alert */ + BatteryInfo->DefaultAlert2 = max(BatteryInfo->DefaultAlert2, + BatteryData->BatteryInformation.DefaultAlert2); + + /* Choose the highest critical bias */ + BatteryInfo->CriticalBias = max(BatteryInfo->CriticalBias, + BatteryData->BatteryInformation.CriticalBias); + } + + /* Re-acquire the device extension lock and release the remove lock */ + ExAcquireFastMutex(&DeviceExtension->Lock); + IoReleaseRemoveLock(&BatteryData->RemoveLock, 0); + } + + /* Next entry */ + NextEntry = NextEntry->Flink; + } + + /* We are done with the list, check if the information was queried okay */ + ExReleaseFastMutex(&DeviceExtension->Lock); + if (NT_SUCCESS(Status)) + { + /* If there's no fully charged capacity, use the design capacity */ + if (!BatteryInfo->FullChargedCapacity) + { + BatteryInfo->FullChargedCapacity = BatteryInfo->DesignedCapacity; + } + + /* Print out final combined data */ + if (CompBattDebug & 2) + DbgPrint("CompBattGetBatteryInformation: Returning BATTERY_INFORMATION\n" + "-------- Capabilities = %x\n-------- Technology = %x\n" + "-------- Chemistry[4] = %x\n-------- DesignedCapacity = %x\n" + "-------- FullChargedCapacity = %x\n-------- DefaultAlert1 = %x\n" + "-------- DefaultAlert2 = %x\n-------- CriticalBias = %x\n" + "-------- CycleCount = %x\n", + BatteryInfo->Capabilities, + BatteryInfo->Technology, + BatteryInfo->Chemistry, + BatteryInfo->DesignedCapacity, + BatteryInfo->FullChargedCapacity, + BatteryInfo->DefaultAlert1, + BatteryInfo->DefaultAlert2, + BatteryInfo->CriticalBias, + BatteryInfo->CycleCount); + + /* Copy the data into the device extension */ + RtlCopyMemory(&DeviceExtension->BatteryInformation, + BatteryInfo, + sizeof(DeviceExtension->BatteryInformation)); + DeviceExtension->Flags |= COMPBATT_BATTERY_INFORMATION_PRESENT; + } + + /* We are done */ + if (CompBattDebug & 1) DbgPrint("CompBatt: EXITING GetBatteryInformation\n"); + return Status; } NTSTATUS @@ -209,13 +430,12 @@ DriverEntry(IN PDRIVER_OBJECT DriverObject, DriverObject->DriverExtension->AddDevice = CompBattAddDevice; /* Register other handlers */ - DriverObject->MajorFunction[0] = CompBattOpenClose; - DriverObject->MajorFunction[2] = CompBattOpenClose; - DriverObject->MajorFunction[14] = CompBattIoctl; - DriverObject->MajorFunction[22] = CompBattPowerDispatch; - DriverObject->MajorFunction[23] = CompBattSystemControl; - DriverObject->MajorFunction[27] = CompBattPnpDispatch; - + DriverObject->MajorFunction[IRP_MJ_CREATE] = CompBattOpenClose; + DriverObject->MajorFunction[IRP_MJ_CLOSE] = CompBattOpenClose; + DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = CompBattIoctl; + DriverObject->MajorFunction[IRP_MJ_POWER] = CompBattPowerDispatch; + DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = CompBattSystemControl; + DriverObject->MajorFunction[IRP_MJ_PNP] = CompBattPnpDispatch; return STATUS_SUCCESS; } diff --git a/reactos/drivers/bus/acpi/compbatt/compbatt.h b/reactos/drivers/bus/acpi/compbatt/compbatt.h index 87e3cb11cf4..792b893573e 100644 --- a/reactos/drivers/bus/acpi/compbatt/compbatt.h +++ b/reactos/drivers/bus/acpi/compbatt/compbatt.h @@ -12,6 +12,9 @@ #include #include +#define COMPBATT_BATTERY_INFORMATION_PRESENT 0x04 +#define COMPBATT_TAG_ASSIGNED 0x80 + typedef struct _COMPBATT_BATTERY_DATA { LIST_ENTRY BatteryLink; @@ -137,6 +140,18 @@ CompBattGetDeviceObjectPointer( OUT PFILE_OBJECT *FileObject, OUT PDEVICE_OBJECT *DeviceObject ); + +NTSTATUS +NTAPI +BatteryIoctl( + IN ULONG IoControlCode, + IN PDEVICE_OBJECT DeviceObject, + IN PVOID InputBuffer, + IN ULONG InputBufferLength, + IN PVOID OutputBuffer, + IN ULONG OutputBufferLength, + IN BOOLEAN InternalDeviceIoControl +); extern ULONG CompBattDebug; diff --git a/reactos/drivers/bus/acpi/compbatt/comppnp.c b/reactos/drivers/bus/acpi/compbatt/comppnp.c index f09ed5c25bb..164ea6f6274 100644 --- a/reactos/drivers/bus/acpi/compbatt/comppnp.c +++ b/reactos/drivers/bus/acpi/compbatt/comppnp.c @@ -59,6 +59,9 @@ RemoveBatteryFromList(IN PCUNICODE_STRING BatteryName, ExReleaseFastMutex(&DeviceExtension->Lock); return BatteryData; } + + /* Next */ + NextEntry = NextEntry->Flink; } /* Done */ @@ -92,6 +95,9 @@ IsBatteryAlreadyOnList(IN PCUNICODE_STRING BatteryName, Found = TRUE; break; } + + /* Next */ + NextEntry = NextEntry->Flink; } /* Release the lock and return search status */ From 041aa4c728a1cbf512abe89989757c52a6ed63d8 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 29 Mar 2010 02:03:41 +0000 Subject: [PATCH 066/134] Reintegrate header-branch 2/x - PCVOID -> LPCVOID / CONST VOID * - move cfgmgr32.h and cfg.h to psdk - remove wine/cfgmgr32.h make setupapi use the proper header svn path=/trunk/; revision=46544 --- reactos/dll/win32/gdi32/objects/bitmap.c | 2 +- reactos/dll/win32/hid/precomp.h | 1 - reactos/dll/win32/setupapi/setupapi.rbuild | 1 + reactos/dll/win32/setupapi/setupapi_private.h | 7 +- reactos/include/ddk/cfgmgr32.h | 2244 ------------ reactos/include/{ddk => psdk}/cfg.h | 95 +- reactos/include/psdk/cfgmgr32.h | 3206 +++++++++++++++++ reactos/include/psdk/winbase.h | 26 +- reactos/include/psdk/wincon.h | 4 +- reactos/include/psdk/windef.h | 2 +- reactos/include/psdk/wingdi.h | 12 +- reactos/include/psdk/winuser.h | 2 +- reactos/include/reactos/wine/cfgmgr32.h | 373 -- 13 files changed, 3298 insertions(+), 2677 deletions(-) delete mode 100644 reactos/include/ddk/cfgmgr32.h rename reactos/include/{ddk => psdk}/cfg.h (65%) create mode 100644 reactos/include/psdk/cfgmgr32.h delete mode 100644 reactos/include/reactos/wine/cfgmgr32.h diff --git a/reactos/dll/win32/gdi32/objects/bitmap.c b/reactos/dll/win32/gdi32/objects/bitmap.c index f94c31a24f2..2c7d4cea90c 100644 --- a/reactos/dll/win32/gdi32/objects/bitmap.c +++ b/reactos/dll/win32/gdi32/objects/bitmap.c @@ -292,7 +292,7 @@ CreateBitmap(INT Width, INT Height, UINT Planes, UINT BitsPixel, - PCVOID pUnsafeBits) + CONST VOID* pUnsafeBits) { /* FIXME some part should be done in user mode */ if (Width && Height) diff --git a/reactos/dll/win32/hid/precomp.h b/reactos/dll/win32/hid/precomp.h index 29e4dd61ba0..9ae79cae666 100644 --- a/reactos/dll/win32/hid/precomp.h +++ b/reactos/dll/win32/hid/precomp.h @@ -10,7 +10,6 @@ typedef VOID typedef VOID (WINAPI *PINTERFACE_DEREFERENCE)( PVOID Context); -#define DDKAPI __stdcall // FIXME #include #include #include diff --git a/reactos/dll/win32/setupapi/setupapi.rbuild b/reactos/dll/win32/setupapi/setupapi.rbuild index bb3e0e37c56..6f2d0c2c627 100644 --- a/reactos/dll/win32/setupapi/setupapi.rbuild +++ b/reactos/dll/win32/setupapi/setupapi.rbuild @@ -10,6 +10,7 @@ _wcsnicmp + pnp_client uuid wine diff --git a/reactos/dll/win32/setupapi/setupapi_private.h b/reactos/dll/win32/setupapi/setupapi_private.h index 50c2d4250cb..a3ff489b9c3 100644 --- a/reactos/dll/win32/setupapi/setupapi_private.h +++ b/reactos/dll/win32/setupapi/setupapi_private.h @@ -45,11 +45,6 @@ #include -/* This hack definition is necessary as long as setupapi - depends on Wine "compatibility" headers */ -typedef ULONG RESOURCEID; -typedef RESOURCEID *PRESOURCEID; - #include #include "rpc_private.h" #include "resource.h" @@ -61,6 +56,8 @@ typedef RESOURCEID *PRESOURCEID; #define SETUP_DEVICE_INFO_SET_MAGIC 0xd00ff057 #define SETUP_CLASS_IMAGE_LIST_MAGIC 0xd00ff058 +#define CMP_MAGIC 0x01234567 + struct DeviceInterface /* Element of DeviceInfo.InterfaceListHead */ { LIST_ENTRY ListEntry; diff --git a/reactos/include/ddk/cfgmgr32.h b/reactos/include/ddk/cfgmgr32.h deleted file mode 100644 index 5ca47bd7448..00000000000 --- a/reactos/include/ddk/cfgmgr32.h +++ /dev/null @@ -1,2244 +0,0 @@ -/* - * cfgmgr32.h - * - * PnP configuration manager - * - * This file is part of the w32api package. - * - * Contributors: - * Created by Casper S. Hornstrup - * - * THIS SOFTWARE IS NOT COPYRIGHTED - * - * This source code is offered for use in the public domain. You may - * use, modify or distribute it freely. - * - * This code is distributed in the hope that it will be useful but - * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY - * DISCLAIMED. This includes but is not limited to warranties of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - */ - -#ifndef _CFGMGR32_H_ -#define _CFGMGR32_H_ - -#include "cfg.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#if defined(_CFGMGR32_) -#define CMAPI -#else -#define CMAPI DECLSPEC_IMPORT -#endif - -#include - -#define CR_SUCCESS 0x00000000 -#define CR_DEFAULT 0x00000001 -#define CR_OUT_OF_MEMORY 0x00000002 -#define CR_INVALID_POINTER 0x00000003 -#define CR_INVALID_FLAG 0x00000004 -#define CR_INVALID_DEVNODE 0x00000005 -#define CR_INVALID_DEVINST CR_INVALID_DEVNODE -#define CR_INVALID_RES_DES 0x00000006 -#define CR_INVALID_LOG_CONF 0x00000007 -#define CR_INVALID_ARBITRATOR 0x00000008 -#define CR_INVALID_NODELIST 0x00000009 -#define CR_DEVNODE_HAS_REQS 0x0000000A -#define CR_DEVINST_HAS_REQS CR_DEVNODE_HAS_REQS -#define CR_INVALID_RESOURCEID 0x0000000B -#define CR_DLVXD_NOT_FOUND 0x0000000C -#define CR_NO_SUCH_DEVNODE 0x0000000D -#define CR_NO_SUCH_DEVINST CR_NO_SUCH_DEVNODE -#define CR_NO_MORE_LOG_CONF 0x0000000E -#define CR_NO_MORE_RES_DES 0x0000000F -#define CR_ALREADY_SUCH_DEVNODE 0x00000010 -#define CR_ALREADY_SUCH_DEVINST CR_ALREADY_SUCH_DEVNODE -#define CR_INVALID_RANGE_LIST 0x00000011 -#define CR_INVALID_RANGE 0x00000012 -#define CR_FAILURE 0x00000013 -#define CR_NO_SUCH_LOGICAL_DEV 0x00000014 -#define CR_CREATE_BLOCKED 0x00000015 -#define CR_NOT_SYSTEM_VM 0x00000016 -#define CR_REMOVE_VETOED 0x00000017 -#define CR_APM_VETOED 0x00000018 -#define CR_INVALID_LOAD_TYPE 0x00000019 -#define CR_BUFFER_SMALL 0x0000001A -#define CR_NO_ARBITRATOR 0x0000001B -#define CR_NO_REGISTRY_HANDLE 0x0000001C -#define CR_REGISTRY_ERROR 0x0000001D -#define CR_INVALID_DEVICE_ID 0x0000001E -#define CR_INVALID_DATA 0x0000001F -#define CR_INVALID_API 0x00000020 -#define CR_DEVLOADER_NOT_READY 0x00000021 -#define CR_NEED_RESTART 0x00000022 -#define CR_NO_MORE_HW_PROFILES 0x00000023 -#define CR_DEVICE_NOT_THERE 0x00000024 -#define CR_NO_SUCH_VALUE 0x00000025 -#define CR_WRONG_TYPE 0x00000026 -#define CR_INVALID_PRIORITY 0x00000027 -#define CR_NOT_DISABLEABLE 0x00000028 -#define CR_FREE_RESOURCES 0x00000029 -#define CR_QUERY_VETOED 0x0000002A -#define CR_CANT_SHARE_IRQ 0x0000002B -#define CR_NO_DEPENDENT 0x0000002C -#define CR_SAME_RESOURCES 0x0000002D -#define CR_NO_SUCH_REGISTRY_KEY 0x0000002E -#define CR_INVALID_MACHINENAME 0x0000002F -#define CR_REMOTE_COMM_FAILURE 0x00000030 -#define CR_MACHINE_UNAVAILABLE 0x00000031 -#define CR_NO_CM_SERVICES 0x00000032 -#define CR_ACCESS_DENIED 0x00000033 -#define CR_CALL_NOT_IMPLEMENTED 0x00000034 -#define CR_INVALID_PROPERTY 0x00000035 -#define CR_DEVICE_INTERFACE_ACTIVE 0x00000036 -#define CR_NO_SUCH_DEVICE_INTERFACE 0x00000037 -#define CR_INVALID_REFERENCE_STRING 0x00000038 -#define CR_INVALID_CONFLICT_LIST 0x00000039 -#define CR_INVALID_INDEX 0x0000003A -#define CR_INVALID_STRUCTURE_SIZE 0x0000003B - -#define RegDisposition_OpenAlways 0x00000000 -#define RegDisposition_OpenExisting 0x00000001 -#define RegDisposition_Bits 0x00000001 - - -typedef DWORD RETURN_TYPE; -typedef RETURN_TYPE CONFIGRET; - -typedef HANDLE HMACHINE; -typedef HMACHINE *PHMACHINE; - -typedef DWORD_PTR RES_DES; -typedef RES_DES *PRES_DES; - -typedef DWORD_PTR RANGE_ELEMENT; -typedef RANGE_ELEMENT *PRANGE_ELEMENT; - -typedef ULONG_PTR CONFLICT_LIST; -typedef CONFLICT_LIST *PCONFLICT_LIST; - -typedef DWORD_PTR LOG_CONF; -typedef LOG_CONF *PLOG_CONF; - -typedef ULONG PRIORITY; -typedef PRIORITY *PPRIORITY; - -typedef DWORD_PTR RANGE_LIST; -typedef RANGE_LIST *PRANGE_LIST; - -typedef DWORD DEVNODE, DEVINST; -typedef DEVNODE *PDEVNODE, *PDEVINST; - -typedef CHAR *DEVNODEID_A, *DEVINSTID_A; -typedef WCHAR *DEVNODEID_W, *DEVINSTID_W; - -#ifdef UNICODE -typedef DEVNODEID_W DEVNODEID; -typedef DEVINSTID_W DEVINSTID; -#else -typedef DEVNODEID_A DEVNODEID; -typedef DEVINSTID_A DEVINSTID; -#endif - -typedef ULONG REGDISPOSITION; - -typedef ULONG RESOURCEID; -typedef RESOURCEID *PRESOURCEID; - -#define CM_RESDES_WIDTH_DEFAULT 0x00000000 -#define CM_RESDES_WIDTH_32 0x00000001 -#define CM_RESDES_WIDTH_64 0x00000002 -#define CM_RESDES_WIDTH_BITS 0x00000003 - - -#define MAX_CONFIG_VALUE 9999 -#define MAX_INSTANCE_VALUE 9999 - -#define MAX_DEVICE_ID_LEN 200 -#define MAX_DEVNODE_ID_LEN MAX_DEVICE_ID_LEN - -#define MAX_CLASS_NAME_LEN 32 -#define MAX_GUID_STRING_LEN 39 -#define MAX_PROFILE_LEN 80 - - -#define ResType_All 0x00000000 -#define ResType_None 0x00000000 -#define ResType_Mem 0x00000001 -#define ResType_IO 0x00000002 -#define ResType_DMA 0x00000003 -#define ResType_IRQ 0x00000004 -#define ResType_DoNotUse 0x00000005 -#define ResType_BusNumber 0x00000006 -#define ResType_MAX 0x00000006 -#define ResType_Ignored_Bit 0x00008000 -#define ResType_ClassSpecific 0x0000FFFF -#define ResType_Reserved 0x00008000 -#define ResType_DevicePrivate 0x00008001 -#define ResType_PcCardConfig 0x00008002 -#define ResType_MfCardConfig 0x00008003 - -#define CM_GETIDLIST_FILTER_NONE 0x00000000 -#define CM_GETIDLIST_FILTER_ENUMERATOR 0x00000001 -#define CM_GETIDLIST_FILTER_SERVICE 0x00000002 -#define CM_GETIDLIST_FILTER_EJECTRELATIONS 0x00000004 -#define CM_GETIDLIST_FILTER_REMOVALRELATIONS 0x00000008 -#define CM_GETIDLIST_FILTER_POWERRELATIONS 0x00000010 -#define CM_GETIDLIST_FILTER_BUSRELATIONS 0x00000020 -#define CM_GETIDLIST_DONOTGENERATE 0x10000040 -#define CM_GETIDLIST_FILTER_BITS 0x1000007F - -#define CM_GET_DEVICE_INTERFACE_LIST_PRESENT 0x00000000 -#define CM_GET_DEVICE_INTERFACE_LIST_ALL_DEVICES 0x00000001 -#define CM_GET_DEVICE_INTERFACE_LIST_BITS 0x00000001 - -#define CM_DRP_DEVICEDESC 0x00000001 -#define CM_DRP_HARDWAREID 0x00000002 -#define CM_DRP_COMPATIBLEIDS 0x00000003 -#define CM_DRP_UNUSED0 0x00000004 -#define CM_DRP_SERVICE 0x00000005 -#define CM_DRP_UNUSED1 0x00000006 -#define CM_DRP_UNUSED2 0x00000007 -#define CM_DRP_CLASS 0x00000008 -#define CM_DRP_CLASSGUID 0x00000009 -#define CM_DRP_DRIVER 0x0000000A -#define CM_DRP_CONFIGFLAGS 0x0000000B -#define CM_DRP_MFG 0x0000000C -#define CM_DRP_FRIENDLYNAME 0x0000000D -#define CM_DRP_LOCATION_INFORMATION 0x0000000E -#define CM_DRP_PHYSICAL_DEVICE_OBJECT_NAME 0x0000000F -#define CM_DRP_CAPABILITIES 0x00000010 -#define CM_DRP_UI_NUMBER 0x00000011 -#define CM_DRP_UPPERFILTERS 0x00000012 -#define CM_DRP_LOWERFILTERS 0x00000013 -#define CM_DRP_BUSTYPEGUID 0x00000014 -#define CM_DRP_LEGACYBUSTYPE 0x00000015 -#define CM_DRP_BUSNUMBER 0x00000016 -#define CM_DRP_ENUMERATOR_NAME 0x00000017 - -#define CM_DRP_MIN 0x00000001 -#define CM_DRP_MAX 0x00000017 - -#define CM_REGISTRY_HARDWARE 0x00000000 -#define CM_REGISTRY_SOFTWARE 0x00000001 -#define CM_REGISTRY_USER 0x00000100 -#define CM_REGISTRY_CONFIG 0x00000200 -#define CM_REGISTRY_BITS 0x00000301 - -#define CM_DEVCAP_LOCKSUPPORTED 0x00000001 -#define CM_DEVCAP_EJECTSUPPORTED 0x00000002 -#define CM_DEVCAP_REMOVABLE 0x00000004 -#define CM_DEVCAP_DOCKDEVICE 0x00000008 -#define CM_DEVCAP_UNIQUEID 0x00000010 -#define CM_DEVCAP_SILENTINSTALL 0x00000020 -#define CM_DEVCAP_RAWDEVICEOK 0x00000040 -#define CM_DEVCAP_SURPRISEREMOVALOK 0x00000080 -#define CM_DEVCAP_HARDWAREDISABLED 0x00000100 -#define CM_DEVCAP_NONDYNAMIC 0x00000200 - -typedef struct BusNumber_Des_s { - DWORD BUSD_Count; - DWORD BUSD_Type; - DWORD BUSD_Flags; - ULONG BUSD_Alloc_Base; - ULONG BUSD_Alloc_End; -} BUSNUMBER_DES, *PBUSNUMBER_DES; - -typedef struct BusNumber_Range_s { - ULONG BUSR_Min; - ULONG BUSR_Max; - ULONG BUSR_nBusNumbers; - ULONG BUSR_Flags; -} BUSNUMBER_RANGE, *PBUSNUMBER_RANGE; - -#define BusNumberType_Range sizeof(BUSNUMBER_RANGE) - -typedef struct BusNumber_Resource_s { - BUSNUMBER_DES BusNumber_Header; - BUSNUMBER_RANGE BusNumber_Data[ANYSIZE_ARRAY]; -} BUSNUMBER_RESOURCE, *PBUSNUMBER_RESOURCE; - -typedef struct CS_Des_s { - DWORD CSD_SignatureLength; - DWORD CSD_LegacyDataOffset; - DWORD CSD_LegacyDataSize; - DWORD CSD_Flags; - GUID CSD_ClassGuid; - BYTE CSD_Signature[ANYSIZE_ARRAY]; -} CS_DES, *PCS_DES; - -typedef struct CS_Resource_s { - CS_DES CS_Header; -} CS_RESOURCE, *PCS_RESOURCE; - -typedef struct DevPrivate_Des_s { - DWORD PD_Count; - DWORD PD_Type; - DWORD PD_Data1; - DWORD PD_Data2; - DWORD PD_Data3; - DWORD PD_Flags; -} DEVPRIVATE_DES, *PDEVPRIVATE_DES; - -typedef struct DevPrivate_Range_s { - DWORD PR_Data1; - DWORD PR_Data2; - DWORD PR_Data3; -} DEVPRIVATE_RANGE, *PDEVPRIVATE_RANGE; - -#define PType_Range sizeof(DEVPRIVATE_RANGE) - -typedef struct DevPrivate_Resource_s { - DEVPRIVATE_DES PRV_Header; - DEVPRIVATE_RANGE PRV_Data[ANYSIZE_ARRAY]; -} DEVPRIVATE_RESOURCE, *PDEVPRIVATE_RESOURCE; - -/* DMA_DES.DD_Flags constants and masks */ -#define mDD_Width 0x3 -#define fDD_BYTE 0x0 -#define fDD_WORD 0x1 -#define fDD_DWORD 0x2 -#define fDD_BYTE_AND_WORD 0x3 - -#define mDD_BusMaster 0x4 -#define fDD_NoBusMaster 0x0 -#define fDD_BusMaster 0x4 - -#define mDD_Type 0x18 -#define fDD_TypeStandard 0x00 -#define fDD_TypeA 0x08 -#define fDD_TypeB 0x10 -#define fDD_TypeF 0x18 - -typedef struct DMA_Des_s { - DWORD DD_Count; - DWORD DD_Type; - DWORD DD_Flags; - ULONG DD_Alloc_Chan; -} DMA_DES, *PDMA_DES; - -typedef struct DMA_Range_s { - ULONG DR_Min; - ULONG DR_Max; - ULONG DR_Flags; -} DMA_RANGE, *PDMA_RANGE; - -#define DType_Range sizeof(DMA_RANGE) - -typedef struct DMA_Resource_s { - DMA_DES DMA_Header; - DMA_RANGE DMA_Data[ANYSIZE_ARRAY]; -} DMA_RESOURCE, *PDMA_RESOURCE; - -/* IO_DES.Type constants and masks */ -#define fIOD_PortType 0x1 -#define fIOD_Memory 0x0 -#define fIOD_IO 0x1 -#define fIOD_DECODE 0x00fc -#define fIOD_10_BIT_DECODE 0x0004 -#define fIOD_12_BIT_DECODE 0x0008 -#define fIOD_16_BIT_DECODE 0x0010 -#define fIOD_POSITIVE_DECODE 0x0020 -#define fIOD_PASSIVE_DECODE 0x0040 -#define fIOD_WINDOW_DECODE 0x0080 - -typedef struct IO_Des_s { - DWORD IOD_Count; - DWORD IOD_Type; - DWORDLONG IOD_Alloc_Base; - DWORDLONG IOD_Alloc_End; - DWORD IOD_DesFlags; -} IO_DES, *PIO_DES; - -/* IO_RANGE.IOR_Alias constants */ -#define IO_ALIAS_10_BIT_DECODE 0x00000004 -#define IO_ALIAS_12_BIT_DECODE 0x00000010 -#define IO_ALIAS_16_BIT_DECODE 0x00000000 -#define IO_ALIAS_POSITIVE_DECODE 0x000000FF - -typedef struct IO_Range_s { - DWORDLONG IOR_Align; - DWORD IOR_nPorts; - DWORDLONG IOR_Min; - DWORDLONG IOR_Max; - DWORD IOR_RangeFlags; - DWORDLONG IOR_Alias; -} IO_RANGE, *PIO_RANGE; - -#define IOType_Range sizeof(IO_RANGE) - -typedef struct IO_Resource_s { - IO_DES IO_Header; - IO_RANGE IO_Data[ANYSIZE_ARRAY]; -} IO_RESOURCE, *PIO_RESOURCE; - -/* IRQ_DES.IRQD_flags constants */ -#define mIRQD_Share 0x1 -#define fIRQD_Exclusive 0x0 -#define fIRQD_Share 0x1 - -#define fIRQD_Share_Bit 0 -#define fIRQD_Level_Bit 1 - -#define mIRQD_Edge_Level 0x2 -#define fIRQD_Level 0x0 -#define fIRQD_Edge 0x2 - -typedef struct IRQ_Des_32_s { - DWORD IRQD_Count; - DWORD IRQD_Type; - DWORD IRQD_Flags; - ULONG IRQD_Alloc_Num; - ULONG32 IRQD_Affinity; -} IRQ_DES_32, *PIRQ_DES_32; - -typedef struct IRQ_Des_64_s { - DWORD IRQD_Count; - DWORD IRQD_Type; - DWORD IRQD_Flags; - ULONG IRQD_Alloc_Num; - ULONG64 IRQD_Affinity; -} IRQ_DES_64, *PIRQ_DES_64; - -#ifdef _WIN64 -typedef IRQ_DES_64 IRQ_DES; -typedef PIRQ_DES_64 PIRQ_DES; -#else -typedef IRQ_DES_32 IRQ_DES; -typedef PIRQ_DES_32 PIRQ_DES; -#endif - -typedef struct IRQ_Range_s { - ULONG IRQR_Min; - ULONG IRQR_Max; - ULONG IRQR_Flags; -} IRQ_RANGE, *PIRQ_RANGE; - -#define IRQType_Range sizeof(IRQ_RANGE) - -typedef struct IRQ_Resource_s { - IRQ_DES IRQ_Header; - IRQ_RANGE IRQ_Data[ANYSIZE_ARRAY]; -} IRQ_RESOURCE, *PIRQ_RESOURCE; - -/* MEM_DES.MD_Flags constants */ -#define mMD_MemoryType 0x1 -#define fMD_MemoryType mMD_MemoryType -#define fMD_ROM 0x0 -#define fMD_RAM 0x1 - -#define mMD_32_24 0x2 -#define fMD_32_24 mMD_32_24 -#define fMD_24 0x0 -#define fMD_32 0x2 - -#define mMD_Prefetchable 0x4 -#define fMD_Prefetchable mMD_Prefetchable -#define fMD_Pref mMD_Prefetchable -#define fMD_PrefetchDisallowed 0x0 -#define fMD_PrefetchAllowed 0x4 - -#define mMD_Readable 0x8 -#define fMD_Readable mMD_Readable -#define fMD_ReadAllowed 0x0 -#define fMD_ReadDisallowed 0x8 - -#define mMD_CombinedWrite 0x10 -#define fMD_CombinedWrite mMD_CombinedWrite -#define fMD_CombinedWriteDisallowed 0x0 -#define fMD_CombinedWriteAllowed 0x10 - -#define mMD_Cacheable 0x20 -#define fMD_NonCacheable 0x0 -#define fMD_Cacheable 0x20 - -typedef struct Mem_Des_s { - DWORD MD_Count; - DWORD MD_Type; - DWORDLONG MD_Alloc_Base; - DWORDLONG MD_Alloc_End; - DWORD MD_Flags; - DWORD MD_Reserved; -} MEM_DES, *PMEM_DES; - -typedef struct Mem_Range_s { - DWORDLONG MR_Align; - ULONG MR_nBytes; - DWORDLONG MR_Min; - DWORDLONG MR_Max; - DWORD MR_Flags; - DWORD MR_Reserved; -} MEM_RANGE, *PMEM_RANGE; - -#define MType_Range sizeof(MEM_RANGE) - -typedef struct Mem_Resource_s { - MEM_DES MEM_Header; - MEM_RANGE MEM_Data[ANYSIZE_ARRAY]; -} MEM_RESOURCE, *PMEM_RESOURCE; - -/* MFCARD_DES.PMF_Flags constants */ -#define fPMF_AUDIO_ENABLE 0x8 -#define mPMF_AUDIO_ENABLE fPMF_AUDIO_ENABLE - -typedef struct MfCard_Des_s { - DWORD PMF_Count; - DWORD PMF_Type; - DWORD PMF_Flags; - BYTE PMF_ConfigOptions; - BYTE PMF_IoResourceIndex; - BYTE PMF_Reserved[2]; - DWORD PMF_ConfigRegisterBase; -} MFCARD_DES, *PMFCARD_DES; - -typedef struct MfCard_Resource_s { - MFCARD_DES MfCard_Header; -} MFCARD_RESOURCE, *PMFCARD_RESOURCE; - -/* PCCARD_DES.PCD_Flags constants */ - -typedef struct PcCard_Des_s { - DWORD PCD_Count; - DWORD PCD_Type; - DWORD PCD_Flags; - BYTE PCD_ConfigIndex; - BYTE PCD_Reserved[3]; - DWORD PCD_MemoryCardBase1; - DWORD PCD_MemoryCardBase2; -} PCCARD_DES, *PPCCARD_DES; - -#define mPCD_IO_8_16 0x1 -#define fPCD_IO_8 0x0 -#define fPCD_IO_16 0x1 -#define mPCD_MEM_8_16 0x2 -#define fPCD_MEM_8 0x0 -#define fPCD_MEM_16 0x2 -#define mPCD_MEM_A_C 0xC -#define fPCD_MEM1_A 0x4 -#define fPCD_MEM2_A 0x8 -#define fPCD_IO_ZW_8 0x10 -#define fPCD_IO_SRC_16 0x20 -#define fPCD_IO_WS_16 0x40 -#define mPCD_MEM_WS 0x300 -#define fPCD_MEM_WS_ONE 0x100 -#define fPCD_MEM_WS_TWO 0x200 -#define fPCD_MEM_WS_THREE 0x300 - -#define fPCD_MEM_A 0x4 - -#define fPCD_ATTRIBUTES_PER_WINDOW 0x8000 - -#define fPCD_IO1_16 0x00010000 -#define fPCD_IO1_ZW_8 0x00020000 -#define fPCD_IO1_SRC_16 0x00040000 -#define fPCD_IO1_WS_16 0x00080000 - -#define fPCD_IO2_16 0x00100000 -#define fPCD_IO2_ZW_8 0x00200000 -#define fPCD_IO2_SRC_16 0x00400000 -#define fPCD_IO2_WS_16 0x00800000 - -#define mPCD_MEM1_WS 0x03000000 -#define fPCD_MEM1_WS_ONE 0x01000000 -#define fPCD_MEM1_WS_TWO 0x02000000 -#define fPCD_MEM1_WS_THREE 0x03000000 -#define fPCD_MEM1_16 0x04000000 - -#define mPCD_MEM2_WS 0x30000000 -#define fPCD_MEM2_WS_ONE 0x10000000 -#define fPCD_MEM2_WS_TWO 0x20000000 -#define fPCD_MEM2_WS_THREE 0x30000000 -#define fPCD_MEM2_16 0x40000000 - -#define PCD_MAX_MEMORY 2 -#define PCD_MAX_IO 2 - -typedef struct PcCard_Resource_s { - PCCARD_DES PcCard_Header; -} PCCARD_RESOURCE, *PPCCARD_RESOURCE; - - -/* CONFLICT_DETAILS.CD.ulMask constants */ -#define CM_CDMASK_DEVINST 0x00000001 -#define CM_CDMASK_RESDES 0x00000002 -#define CM_CDMASK_FLAGS 0x00000004 -#define CM_CDMASK_DESCRIPTION 0x00000008 -#define CM_CDMASK_VALID 0x0000000F - -/* CONFLICT_DETAILS.CD.ulFlags constants */ -#define CM_CDFLAGS_DRIVER 0x00000001 -#define CM_CDFLAGS_ROOT_OWNED 0x00000002 -#define CM_CDFLAGS_RESERVED 0x00000004 - -typedef struct _CONFLICT_DETAILS_A { - ULONG CD_ulSize; - ULONG CD_ulMask; - DEVINST CD_dnDevInst; - RES_DES CD_rdResDes; - ULONG CD_ulFlags; - CHAR CD_szDescription[MAX_PATH]; -} CONFLICT_DETAILS_A , *PCONFLICT_DETAILS_A; - -typedef struct _CONFLICT_DETAILS_W { - ULONG CD_ulSize; - ULONG CD_ulMask; - DEVINST CD_dnDevInst; - RES_DES CD_rdResDes; - ULONG CD_ulFlags; - WCHAR CD_szDescription[MAX_PATH]; -} CONFLICT_DETAILS_W , *PCONFLICT_DETAILS_W; - -#ifdef UNICODE -typedef CONFLICT_DETAILS_W CONFLICT_DETAILS; -typedef PCONFLICT_DETAILS_W PCONFLICT_DETAILS; -#else -typedef CONFLICT_DETAILS_A CONFLICT_DETAILS; -typedef PCONFLICT_DETAILS_A PCONFLICT_DETAILS; -#endif - - -#define CMP_MAGIC 0x01234567 - - -CMAPI -CONFIGRET -WINAPI -CMP_Init_Detection( - IN DWORD dwMagic); - -CMAPI -CONFIGRET -WINAPI -CMP_RegisterNotification( - IN HANDLE hRecipient, - IN LPVOID lpvNotificationFilter, - IN DWORD dwFlags, - OUT PULONG pluhDevNotify); - -CMAPI -CONFIGRET -WINAPI -CMP_Report_LogOn( - IN DWORD dwMagic, - IN DWORD dwProcessId); - -CMAPI -CONFIGRET -WINAPI -CMP_UnregisterNotification(IN ULONG luhDevNotify); - -/* FIXME: Missing CMP_WaitNoPendingInstallEvents */ -/* FIXME: Missing CMP_WaitServicesAvailable */ - -/* CM_Add_Empty_Log_Conf.ulFlags constants */ -#define BASIC_LOG_CONF 0x00000000 -#define FILTERED_LOG_CONF 0x00000001 -#define ALLOC_LOG_CONF 0x00000002 -#define BOOT_LOG_CONF 0x00000003 -#define FORCED_LOG_CONF 0x00000004 -#define OVERRIDE_LOG_CONF 0x00000005 -#define NUM_LOG_CONF 0x00000006 -#define LOG_CONF_BITS 0x00000007 - -#define PRIORITY_EQUAL_FIRST 0x00000008 -#define PRIORITY_EQUAL_LAST 0x00000000 -#define PRIORITY_BIT 0x00000008 - -CMAPI -CONFIGRET -WINAPI -CM_Add_Empty_Log_Conf( - OUT PLOG_CONF plcLogConf, - IN DEVINST dnDevInst, - IN PRIORITY Priority, - IN ULONG ulFlags); - -CMAPI -CONFIGRET -WINAPI -CM_Add_Empty_Log_Conf_Ex( - OUT PLOG_CONF plcLogConf, - IN DEVINST dnDevInst, - IN PRIORITY Priority, - IN ULONG ulFlags, - IN HMACHINE hMachine); - -/* CM_Add_ID.ulFlags constants */ -#define CM_ADD_ID_HARDWARE 0x00000000 -#define CM_ADD_ID_COMPATIBLE 0x00000001 -#define CM_ADD_ID_BITS 0x00000001 - -CMAPI -CONFIGRET -WINAPI -CM_Add_IDA( - IN DEVINST dnDevInst, - IN PSTR pszID, - IN ULONG ulFlags); - -CMAPI -CONFIGRET -WINAPI -CM_Add_ID_ExA( - IN DEVINST dnDevInst, - IN PSTR pszID, - IN ULONG ulFlags, - IN HMACHINE hMachine); - -CMAPI -CONFIGRET -WINAPI -CM_Add_ID_ExW( - IN DEVINST dnDevInst, - IN PWSTR pszID, - IN ULONG ulFlags, - IN HMACHINE hMachine); - -CMAPI -CONFIGRET -WINAPI -CM_Add_IDW( - IN DEVINST dnDevInst, - IN PWSTR pszID, - IN ULONG ulFlags); - -#ifdef UNICODE -#define CM_Add_ID CM_Add_IDW -#define CM_Add_ID_Ex CM_Add_ID_ExW -#else -#define CM_Add_ID CM_Add_IDA -#define CM_Add_ID_Ex CM_Add_ID_ExA -#endif /* UNICODE */ - -/* FIXME: Obsolete CM_Add_Range */ - -CMAPI -CONFIGRET -WINAPI -CM_Add_Res_Des( - OUT PRES_DES prdResDes, - IN LOG_CONF lcLogConf, - IN RESOURCEID ResourceID, - IN PCVOID ResourceData, - IN ULONG ResourceLen, - IN ULONG ulFlags); - -CMAPI -CONFIGRET -WINAPI -CM_Add_Res_Des_Ex( - OUT PRES_DES prdResDes, - IN LOG_CONF lcLogConf, - IN RESOURCEID ResourceID, - IN PCVOID ResourceData, - IN ULONG ResourceLen, - IN ULONG ulFlags, - IN HMACHINE hMachine); - -CMAPI -CONFIGRET -WINAPI -CM_Connect_MachineA( - IN PCSTR UNCServerName, - OUT PHMACHINE phMachine); - -CMAPI -CONFIGRET -WINAPI -CM_Connect_MachineW( - IN PCWSTR UNCServerName, - OUT PHMACHINE phMachine); - -#ifdef UNICODE -#define CM_Connect_Machine CM_Connect_MachineW -#else -#define CM_Connect_Machine CM_Connect_MachineA -#endif /* UNICODE */ - -/* Flags for CM_Create_DevNode[_Ex].ulFlags constants */ -#define CM_CREATE_DEVNODE_NORMAL 0x00000000 -#define CM_CREATE_DEVNODE_NO_WAIT_INSTALL 0x00000001 -#define CM_CREATE_DEVNODE_PHANTOM 0x00000002 -#define CM_CREATE_DEVNODE_GENERATE_ID 0x00000004 -#define CM_CREATE_DEVNODE_DO_NOT_INSTALL 0x00000008 -#define CM_CREATE_DEVNODE_BITS 0x0000000F - -#define CM_CREATE_DEVINST_NORMAL CM_CREATE_DEVNODE_NORMAL -#define CM_CREATE_DEVINST_NO_WAIT_INSTALL CM_CREATE_DEVNODE_NO_WAIT_INSTALL -#define CM_CREATE_DEVINST_PHANTOM CM_CREATE_DEVNODE_PHANTOM -#define CM_CREATE_DEVINST_GENERATE_ID CM_CREATE_DEVNODE_GENERATE_ID -#define CM_CREATE_DEVINST_DO_NOT_INSTALL CM_CREATE_DEVNODE_DO_NOT_INSTALL -#define CM_CREATE_DEVINST_BITS CM_CREATE_DEVNODE_BITS - -CMAPI -CONFIGRET -WINAPI -CM_Create_DevNodeA( - OUT PDEVINST pdnDevInst, - IN DEVINSTID_A pDeviceID, - IN DEVINST dnParent, - IN ULONG ulFlags); - -CMAPI -CONFIGRET -WINAPI -CM_Create_DevNodeW( - OUT PDEVINST pdnDevInst, - IN DEVINSTID_W pDeviceID, - IN DEVINST dnParent, - IN ULONG ulFlags); - -CMAPI -CONFIGRET -WINAPI -CM_Create_DevNode_ExA( - OUT PDEVINST pdnDevInst, - IN DEVINSTID_A pDeviceID, - IN DEVINST dnParent, - IN ULONG ulFlags, - IN HANDLE hMachine); - -CMAPI -CONFIGRET -WINAPI -CM_Create_DevNode_ExW( - OUT PDEVINST pdnDevInst, - IN DEVINSTID_W pDeviceID, - IN DEVINST dnParent, - IN ULONG ulFlags, - IN HANDLE hMachine); - -#define CM_Create_DevInstW CM_Create_DevNodeW -#define CM_Create_DevInstA CM_Create_DevNodeA -#define CM_Create_DevInst_ExW CM_Create_DevNode_ExW -#define CM_Create_DevInst_ExA CM_Create_DevNode_ExA -#ifdef UNICODE -#define CM_Create_DevNode CM_Create_DevNodeW -#define CM_Create_DevInst CM_Create_DevNodeW -#define CM_Create_DevNode_Ex CM_Create_DevNode_ExW -#define CM_Create_DevInst_Ex CM_Create_DevInst_ExW -#else -#define CM_Create_DevNode CM_Create_DevNodeA -#define CM_Create_DevInst CM_Create_DevNodeA -#define CM_Create_DevNode_Ex CM_Create_DevNode_ExA -#define CM_Create_DevInst_Ex CM_Create_DevNode_ExA -#endif /* UNICODE */ - -/* FIXME: Obsolete CM_Create_Range_List */ - -/* Flags for CM_Delete_Class_Key.ulFlags constants */ -#define CM_DELETE_CLASS_ONLY 0x00000000 -#define CM_DELETE_CLASS_SUBKEYS 0x00000001 -#define CM_DELETE_CLASS_BITS 0x00000001 - -CMAPI -CONFIGRET -WINAPI -CM_Delete_Class_Key( - IN LPGUID ClassGuid, - IN ULONG ulFlags); - -CMAPI -CONFIGRET -WINAPI -CM_Delete_Class_Key_Ex( - IN LPGUID ClassGuid, - IN ULONG ulFlags, - IN HANDLE hMachine); - -CMAPI -CONFIGRET -WINAPI -CM_Delete_DevNode_Key( - IN DEVNODE dnDevNode, - IN ULONG ulHardwareProfile, - IN ULONG ulFlags); - -CMAPI -CONFIGRET -WINAPI -CM_Delete_DevNode_Key_Ex( - IN DEVNODE dnDevNode, - IN ULONG ulHardwareProfile, - IN ULONG ulFlags, - IN HANDLE hMachine); - -#define CM_Delete_DevInst_Key CM_Delete_DevNode_Key -#define CM_Delete_DevInst_Key_Ex CM_Delete_DevNode_Key_Ex - -/* FIXME: Obsolete CM_Delete_Range */ -/* FIXME: Obsolete CM_Detected_Resource_Conflict */ -/* FIXME: Obsolete CM_Detected_Resource_Conflict_Ex */ - -CMAPI -CONFIGRET -WINAPI -CM_Disable_DevNode( - IN DEVINST dnDevInst, - IN ULONG ulFlags); - -CMAPI -CONFIGRET -WINAPI -CM_Disable_DevNode_Ex( - IN DEVINST dnDevInst, - IN ULONG ulFlags, - IN HMACHINE hMachine); - -#define CM_Disable_DevInst CM_Disable_DevNode -#define CM_Disable_DevInst_Ex CM_Disable_DevNode_Ex - -CMAPI -CONFIGRET -WINAPI -CM_Disconnect_Machine( - IN HMACHINE hMachine); - -CMAPI -CONFIGRET -WINAPI -CM_Enable_DevNode( - IN DEVINST dnDevInst, - IN ULONG ulFlags); - -CMAPI -CONFIGRET -WINAPI -CM_Enable_DevNode_Ex( - IN DEVINST dnDevInst, - IN ULONG ulFlags, - IN HMACHINE hMachine); - -#define CM_Enable_DevInst CM_Enable_DevNode -#define CM_Enable_DevInst_Ex CM_Enable_DevNode_Ex - -CMAPI -CONFIGRET -WINAPI -CM_Enumerate_Classes( - IN ULONG ulClassIndex, - OUT LPGUID ClassGuid, - IN ULONG ulFlags); - -CMAPI -CONFIGRET -WINAPI -CM_Enumerate_Classes_Ex( - IN ULONG ulClassIndex, - OUT LPGUID ClassGuid, - IN ULONG ulFlags, - IN HMACHINE hMachine); - -CMAPI -CONFIGRET -WINAPI -CM_Enumerate_EnumeratorsA( - IN ULONG ulEnumIndex, - OUT PCHAR Buffer, - IN OUT PULONG pulLength, - IN ULONG ulFlags); - -CMAPI -CONFIGRET -WINAPI -CM_Enumerate_Enumerators_ExA( - IN ULONG ulEnumIndex, - OUT PCHAR Buffer, - IN OUT PULONG pulLength, - IN ULONG ulFlags, - IN HMACHINE hMachine); - -CMAPI -CONFIGRET -WINAPI -CM_Enumerate_Enumerators_ExW( - IN ULONG ulEnumIndex, - OUT PWCHAR Buffer, - IN OUT PULONG pulLength, - IN ULONG ulFlags, - IN HMACHINE hMachine); - -CMAPI -CONFIGRET -WINAPI -CM_Enumerate_EnumeratorsW( - IN ULONG ulEnumIndex, - OUT PWCHAR Buffer, - IN OUT PULONG pulLength, - IN ULONG ulFlags); - -#ifdef UNICODE -#define CM_Enumerate_Enumerators CM_Enumerate_EnumeratorsW -#define CM_Enumerate_Enumerators_Ex CM_Enumerate_Enumerators_ExW -#else -#define CM_Enumerate_Enumerators CM_Enumerate_EnumeratorsA -#define CM_Enumerate_Enumerators_Ex CM_Enumerate_Enumerators_ExA -#endif /* UNICODE */ - -/* FIXME: Obsolete CM_Find_Range */ -/* FIXME: Obsolete CM_First_Range */ - -CMAPI -CONFIGRET -WINAPI -CM_Free_Log_Conf( - IN LOG_CONF lcLogConfToBeFreed, - IN ULONG ulFlags); - -CMAPI -CONFIGRET -WINAPI -CM_Free_Log_Conf_Ex( - IN LOG_CONF lcLogConfToBeFreed, - IN ULONG ulFlags, - IN HMACHINE hMachine); - -CMAPI -CONFIGRET -WINAPI -CM_Free_Log_Conf_Handle( - IN LOG_CONF lcLogConf); - -/* FIXME: Obsolete CM_Free_Range_List */ - -CMAPI -CONFIGRET -WINAPI -CM_Free_Res_Des( - OUT PRES_DES prdResDes, - IN RES_DES rdResDes, - IN ULONG ulFlags); - -CMAPI -CONFIGRET -WINAPI -CM_Free_Res_Des_Ex( - OUT PRES_DES prdResDes, - IN RES_DES rdResDes, - IN ULONG ulFlags, - IN HMACHINE hMachine); - -CMAPI -CONFIGRET -WINAPI -CM_Free_Res_Des_Handle( - IN RES_DES rdResDes); - -CMAPI -CONFIGRET -WINAPI -CM_Free_Resource_Conflict_Handle( - IN CONFLICT_LIST clConflictList); - -CMAPI -CONFIGRET -WINAPI -CM_Get_Child( - OUT PDEVINST pdnDevInst, - IN DEVINST dnDevInst, - IN ULONG ulFlags); - -CMAPI -CONFIGRET -WINAPI -CM_Get_Child_Ex( - OUT PDEVINST pdnDevInst, - IN DEVINST dnDevInst, - IN ULONG ulFlags, - IN HMACHINE hMachine); - -CMAPI -CONFIGRET -WINAPI -CM_Get_Class_NameA( - IN LPGUID ClassGuid, - OUT PCHAR Buffer, - IN OUT PULONG pulLength, - IN ULONG ulFlags); - -CMAPI -CONFIGRET -WINAPI -CM_Get_Class_NameW( - IN LPGUID ClassGuid, - OUT PWCHAR Buffer, - IN OUT PULONG pulLength, - IN ULONG ulFlags); - -CMAPI -CONFIGRET -WINAPI -CM_Get_Class_Name_ExA( - IN LPGUID ClassGuid, - OUT PCHAR Buffer, - IN OUT PULONG pulLength, - IN ULONG ulFlags, - IN HMACHINE hMachine); - -CMAPI -CONFIGRET -WINAPI -CM_Get_Class_Name_ExW( - IN LPGUID ClassGuid, - OUT PWCHAR Buffer, - IN OUT PULONG pulLength, - IN ULONG ulFlags, - IN HMACHINE hMachine); - -#ifdef UNICODE -#define CM_Get_Class_Name CM_Get_Class_NameW -#define CM_Get_Class_Name_Ex CM_Get_Class_Name_ExW -#else -#define CM_Get_Class_Name CM_Get_Class_NameA -#define CM_Get_Class_Name_Ex CM_Get_Class_Name_ExA -#endif /* UNICODE */ - -CMAPI -CONFIGRET -WINAPI -CM_Get_Class_Key_NameA( - IN LPGUID ClassGuid, - OUT LPSTR pszKeyName, - IN OUT PULONG pulLength, - IN ULONG ulFlags); - -CMAPI -CONFIGRET -WINAPI -CM_Get_Class_Key_NameW( - IN LPGUID ClassGuid, - OUT LPWSTR pszKeyName, - IN OUT PULONG pulLength, - IN ULONG ulFlags); - -CMAPI -CONFIGRET -WINAPI -CM_Get_Class_Key_Name_ExA( - IN LPGUID ClassGuid, - OUT LPSTR pszKeyName, - IN OUT PULONG pulLength, - IN ULONG ulFlags, - IN HMACHINE hMachine); - -CMAPI -CONFIGRET -WINAPI -CM_Get_Class_Key_Name_ExW( - IN LPGUID ClassGuid, - OUT LPWSTR pszKeyName, - IN OUT PULONG pulLength, - IN ULONG ulFlags, - IN HMACHINE hMachine); - -#ifdef UNICODE -#define CM_Get_Class_Key_Name CM_Get_Class_Key_NameW -#define CM_Get_Class_Key_Name_Ex CM_Get_Class_Key_Name_ExW -#else -#define CM_Get_Class_Key_Name CM_Get_Class_Key_NameA -#define CM_Get_Class_Key_Name_Ex CM_Get_Class_Key_Name_ExA -#endif /* UNICODE */ - -/* FIXME: Obsolete CM_Get_Class_Registry_Property */ - -CMAPI -CONFIGRET -WINAPI -CM_Get_Depth( - OUT PULONG pulDepth, - IN DEVINST dnDevInst, - IN ULONG ulFlags); - -CMAPI -CONFIGRET -WINAPI -CM_Get_Depth_Ex( - OUT PULONG pulDepth, - IN DEVINST dnDevInst, - IN ULONG ulFlags, - IN HMACHINE hMachine); - -CMAPI -CONFIGRET -WINAPI -CM_Get_Device_IDA( - IN DEVINST dnDevInst, - OUT PCHAR Buffer, - IN ULONG BufferLen, - IN ULONG ulFlags); - -CMAPI -CONFIGRET -WINAPI -CM_Get_Device_ID_ExA( - IN DEVINST dnDevInst, - OUT PCHAR Buffer, - IN ULONG BufferLen, - IN ULONG ulFlags, - IN HMACHINE hMachine); - -CMAPI -CONFIGRET -WINAPI -CM_Get_Device_ID_ExW( - IN DEVINST dnDevInst, - OUT PWCHAR Buffer, - IN ULONG BufferLen, - IN ULONG ulFlags, - IN HMACHINE hMachine); - -CMAPI -CONFIGRET -WINAPI -CM_Get_Device_IDW( - IN DEVINST dnDevInst, - OUT PWCHAR Buffer, - IN ULONG BufferLen, - IN ULONG ulFlags); - -#ifdef UNICODE -#define CM_Get_Device_ID CM_Get_Device_IDW -#define CM_Get_Device_ID_Ex CM_Get_Device_ID_ExW -#else -#define CM_Get_Device_ID CM_Get_Device_IDA -#define CM_Get_Device_ID_Ex CM_Get_Device_ID_ExA -#endif /* UNICODE */ - -CMAPI -CONFIGRET -WINAPI -CM_Get_Device_ID_ListA( - IN PCSTR pszFilter, OPTIONAL - OUT PCHAR Buffer, - IN ULONG BufferLen, - IN ULONG ulFlags); - -CMAPI -CONFIGRET -WINAPI -CM_Get_Device_ID_List_ExA( - IN PCSTR pszFilter, OPTIONAL - OUT PCHAR Buffer, - IN ULONG BufferLen, - IN ULONG ulFlags, - IN HMACHINE hMachine); - -CMAPI -CONFIGRET -WINAPI -CM_Get_Device_ID_List_ExW( - IN PCWSTR pszFilter, OPTIONAL - OUT PWCHAR Buffer, - IN ULONG BufferLen, - IN ULONG ulFlags, - IN HMACHINE hMachine); - -CMAPI -CONFIGRET -WINAPI -CM_Get_Device_ID_ListW( - IN PCWSTR pszFilter, OPTIONAL - OUT PWCHAR Buffer, - IN ULONG BufferLen, - IN ULONG ulFlags); - -#ifdef UNICODE -#define CM_Get_Device_ID_List CM_Get_Device_ID_ListW -#define CM_Get_Device_ID_List_Ex CM_Get_Device_ID_List_ExW -#else -#define CM_Get_Device_ID_List CM_Get_Device_ID_ListA -#define CM_Get_Device_ID_List_Ex CM_Get_Device_ID_List_ExA -#endif /* UNICODE */ - -CMAPI -CONFIGRET -WINAPI -CM_Get_Device_ID_List_SizeA( - OUT PULONG pulLen, - IN PCSTR pszFilter, OPTIONAL - IN ULONG ulFlags); - -CMAPI -CONFIGRET -WINAPI -CM_Get_Device_ID_List_Size_ExA( - OUT PULONG pulLen, - IN PCSTR pszFilter, OPTIONAL - IN ULONG ulFlags, - IN HMACHINE hMachine); - -CMAPI -CONFIGRET -WINAPI -CM_Get_Device_ID_List_Size_ExW( - OUT PULONG pulLen, - IN PCWSTR pszFilter, OPTIONAL - IN ULONG ulFlags, - IN HMACHINE hMachine); - -CMAPI -CONFIGRET -WINAPI -CM_Get_Device_ID_List_SizeW( - OUT PULONG pulLen, - IN PCWSTR pszFilter, OPTIONAL - IN ULONG ulFlags); - -#ifdef UNICODE -#define CM_Get_Device_ID_List_Size CM_Get_Device_ID_List_SizeW -#define CM_Get_Device_ID_List_Size_Ex CM_Get_Device_ID_List_Size_ExW -#else -#define CM_Get_Device_ID_List_Size CM_Get_Device_ID_List_SizeA -#define CM_Get_Device_ID_List_Size_Ex CM_Get_Device_ID_List_Size_ExA -#endif /* UNICODE */ - -CMAPI -CONFIGRET -WINAPI -CM_Get_Device_ID_Size( - OUT PULONG pulLen, - IN DEVINST dnDevInst, - IN ULONG ulFlags); - -CMAPI -CONFIGRET -WINAPI -CM_Get_Device_ID_Size_Ex( - OUT PULONG pulLen, - IN DEVINST dnDevInst, - IN ULONG ulFlags, - IN HMACHINE hMachine); - -/* FIXME: Obsolete CM_Get_Device_Interface_Alias */ -/* FIXME: Obsolete CM_Get_Device_Interface_Alias_Ex */ -/* FIXME: Obsolete CM_Get_Device_Interface_List */ -/* FIXME: Obsolete CM_Get_Device_Interface_List_Ex */ -/* FIXME: Obsolete CM_Get_Device_Interface_List_Size */ -/* FIXME: Obsolete CM_Get_Device_Interface_List_Size_Ex */ -/* FIXME: Obsolete CM_Get_DevNode_Custom_Property */ -/* FIXME: Obsolete CM_Get_DevNode_Custom_Property_Ex */ - -CMAPI -CONFIGRET -WINAPI -CM_Get_DevNode_Registry_PropertyA( - IN DEVINST dnDevInst, - IN ULONG ulProperty, - OUT PULONG pulRegDataType, OPTIONAL - OUT PVOID Buffer, OPTIONAL - IN OUT PULONG pulLength, - IN ULONG ulFlags); - -CMAPI -CONFIGRET -WINAPI -CM_Get_DevNode_Registry_PropertyW( - IN DEVINST dnDevInst, - IN ULONG ulProperty, - OUT PULONG pulRegDataType, OPTIONAL - OUT PVOID Buffer, OPTIONAL - IN OUT PULONG pulLength, - IN ULONG ulFlags); - -CMAPI -CONFIGRET -WINAPI -CM_Get_DevNode_Registry_Property_ExA( - IN DEVINST dnDevInst, - IN ULONG ulProperty, - OUT PULONG pulRegDataType, OPTIONAL - OUT PVOID Buffer, OPTIONAL - IN OUT PULONG pulLength, - IN ULONG ulFlags, - IN HMACHINE hMachine); - -CMAPI -CONFIGRET -WINAPI -CM_Get_DevNode_Registry_Property_ExW( - IN DEVINST dnDevInst, - IN ULONG ulProperty, - OUT PULONG pulRegDataType, OPTIONAL - OUT PVOID Buffer, OPTIONAL - IN OUT PULONG pulLength, - IN ULONG ulFlags, - IN HMACHINE hMachine); - -#define CM_Get_DevInst_Registry_PropertyW CM_Get_DevNode_Registry_PropertyW -#define CM_Get_DevInst_Registry_PropertyA CM_Get_DevNode_Registry_PropertyA -#define CM_Get_DevInst_Registry_Property_ExW CM_Get_DevNode_Registry_Property_ExW -#define CM_Get_DevInst_Registry_Property_ExA CM_Get_DevNode_Registry_Property_ExA - -#ifdef UNICODE -#define CM_Get_DevInst_Registry_Property CM_Get_DevNode_Registry_PropertyW -#define CM_Get_DevInst_Registry_Property_Ex CM_Get_DevNode_Registry_Property_ExW -#define CM_Get_DevNode_Registry_Property CM_Get_DevNode_Registry_PropertyW -#define CM_Get_DevNode_Registry_Property_Ex CM_Get_DevNode_Registry_Property_ExW -#else -#define CM_Get_DevInst_Registry_Property CM_Get_DevNode_Registry_PropertyA -#define CM_Get_DevInst_Registry_Property_Ex CM_Get_DevNode_Registry_Property_ExA -#define CM_Get_DevNode_Registry_Property CM_Get_DevNode_Registry_PropertyA -#define CM_Get_DevNode_Registry_Property_Ex CM_Get_DevNode_Registry_Property_ExA -#endif /* UNICODE */ - -CMAPI -CONFIGRET -WINAPI -CM_Get_DevNode_Status( - OUT PULONG pulStatus, - OUT PULONG pulProblemNumber, - IN DEVINST dnDevInst, - IN ULONG ulFlags); - -CMAPI -CONFIGRET -WINAPI -CM_Get_DevNode_Status_Ex( - OUT PULONG pulStatus, - OUT PULONG pulProblemNumber, - IN DEVINST dnDevInst, - IN ULONG ulFlags, - IN HMACHINE hMachine); - -#define CM_Get_DevInst_Status CM_Get_DevNode_Status -#define CM_Get_DevInst_Status_Ex CM_Get_DevNode_Status_Ex - -/* CM_Get_First_Log_Conf.ulFlags constants */ -#define BASIC_LOG_CONF 0x00000000 /* Specifies the req list. */ -#define FILTERED_LOG_CONF 0x00000001 /* Specifies the filtered req list. */ -#define ALLOC_LOG_CONF 0x00000002 /* Specifies the Alloc Element. */ -#define BOOT_LOG_CONF 0x00000003 /* Specifies the RM Alloc Element. */ -#define FORCED_LOG_CONF 0x00000004 /* Specifies the Forced Log Conf */ -#define OVERRIDE_LOG_CONF 0x00000005 /* Specifies the Override req list. */ -#define NUM_LOG_CONF 0x00000006 /* Number of Log Conf type */ -#define LOG_CONF_BITS 0x00000007 /* The bits of the log conf type. */ - -CMAPI -CONFIGRET -WINAPI -CM_Get_First_Log_Conf( - OUT PLOG_CONF plcLogConf, OPTIONAL - IN DEVINST dnDevInst, - IN ULONG ulFlags); - -CMAPI -CONFIGRET -WINAPI -CM_Get_First_Log_Conf_Ex( - OUT PLOG_CONF plcLogConf, OPTIONAL - IN DEVINST dnDevInst, - IN ULONG ulFlags, - IN HMACHINE hMachine); - -CMAPI -CONFIGRET -WINAPI -CM_Get_Global_State( - OUT PULONG pulState, - IN ULONG ulFlags); - -CMAPI -CONFIGRET -WINAPI -CM_Get_Global_State_Ex( - OUT PULONG pulState, - IN ULONG ulFlags, - IN HMACHINE hMachine); - -/* FIXME: Obsolete CM_Get_Hardware_Profile_Info */ -/* FIXME: Obsolete CM_Get_Hardware_Profile_Info_Ex */ - -CMAPI -CONFIGRET -WINAPI -CM_Get_HW_Prof_FlagsA( - IN DEVINSTID_A szDevInstName, - IN ULONG ulHardwareProfile, - OUT PULONG pulValue, - IN ULONG ulFlags); - -CMAPI -CONFIGRET -WINAPI -CM_Get_HW_Prof_FlagsW( - IN DEVINSTID_W szDevInstName, - IN ULONG ulHardwareProfile, - OUT PULONG pulValue, - IN ULONG ulFlags); - -CMAPI -CONFIGRET -WINAPI -CM_Get_HW_Prof_Flags_ExA( - IN DEVINSTID_A szDevInstName, - IN ULONG ulHardwareProfile, - OUT PULONG pulValue, - IN ULONG ulFlags, - IN HMACHINE hMachine); - -CMAPI -CONFIGRET -WINAPI -CM_Get_HW_Prof_Flags_ExW( - IN DEVINSTID_W szDevInstName, - IN ULONG ulHardwareProfile, - OUT PULONG pulValue, - IN ULONG ulFlags, - IN HMACHINE hMachine); - -#ifdef UNICODE -#define CM_Get_HW_Prof_Flags CM_Get_HW_Prof_FlagsW -#define CM_Get_HW_Prof_Flags_Ex CM_Get_HW_Prof_Flags_ExW -#else -#define CM_Get_HW_Prof_Flags CM_Get_HW_Prof_FlagsA -#define CM_Get_HW_Prof_Flags_Ex CM_Get_HW_Prof_Flags_ExA -#endif /* UNICODE */ - -CMAPI -CONFIGRET -WINAPI -CM_Get_Log_Conf_Priority( - IN LOG_CONF lcLogConf, - OUT PPRIORITY pPriority, - IN ULONG ulFlags); - -CMAPI -CONFIGRET -WINAPI -CM_Get_Log_Conf_Priority_Ex( - IN LOG_CONF lcLogConf, - OUT PPRIORITY pPriority, - IN ULONG ulFlags, - IN HMACHINE hMachine); - -CMAPI -CONFIGRET -WINAPI -CM_Get_Next_Log_Conf( - OUT PLOG_CONF plcLogConf, OPTIONAL - IN LOG_CONF lcLogConf, - IN ULONG ulFlags); - -CMAPI -CONFIGRET -WINAPI -CM_Get_Next_Log_Conf_Ex( - OUT PLOG_CONF plcLogConf, OPTIONAL - IN LOG_CONF lcLogConf, - IN ULONG ulFlags, - IN HMACHINE hMachine); - -CMAPI -CONFIGRET -WINAPI -CM_Get_Next_Res_Des( - OUT PRES_DES prdResDes, - IN RES_DES rdResDes, - IN RESOURCEID ForResource, - OUT PRESOURCEID pResourceID, - IN ULONG ulFlags); - -CMAPI -CONFIGRET -WINAPI -CM_Get_Next_Res_Des_Ex( - OUT PRES_DES prdResDes, - IN RES_DES rdResDes, - IN RESOURCEID ForResource, - OUT PRESOURCEID pResourceID, - IN ULONG ulFlags, - IN HMACHINE hMachine); - -CMAPI -CONFIGRET -WINAPI -CM_Get_Parent( - OUT PDEVINST pdnDevInst, - IN DEVINST dnDevInst, - IN ULONG ulFlags); - -CMAPI -CONFIGRET -WINAPI -CM_Get_Parent_Ex( - OUT PDEVINST pdnDevInst, - IN DEVINST dnDevInst, - IN ULONG ulFlags, - IN HMACHINE hMachine); - -CMAPI -CONFIGRET -WINAPI -CM_Get_Res_Des_Data( - IN RES_DES rdResDes, - OUT PVOID Buffer, - IN ULONG BufferLen, - IN ULONG ulFlags); - -CMAPI -CONFIGRET -WINAPI -CM_Get_Res_Des_Data_Ex( - IN RES_DES rdResDes, - OUT PVOID Buffer, - IN ULONG BufferLen, - IN ULONG ulFlags, - IN HMACHINE hMachine); - -CMAPI -CONFIGRET -WINAPI -CM_Get_Res_Des_Data_Size( - OUT PULONG pulSize, - IN RES_DES rdResDes, - IN ULONG ulFlags); - -CMAPI -CONFIGRET -WINAPI -CM_Get_Res_Des_Data_Size_Ex( - OUT PULONG pulSize, - IN RES_DES rdResDes, - IN ULONG ulFlags, - IN HMACHINE hMachine); - -CMAPI -CONFIGRET -WINAPI -CM_Get_Resource_Conflict_Count( - IN CONFLICT_LIST clConflictList, - OUT PULONG pulCount); - -CMAPI -CONFIGRET -WINAPI -CM_Get_Resource_Conflict_DetailsA( - IN CONFLICT_LIST clConflictList, - IN ULONG ulIndex, - IN OUT PCONFLICT_DETAILS_A pConflictDetails); - -CMAPI -CONFIGRET -WINAPI -CM_Get_Resource_Conflict_DetailsW( - IN CONFLICT_LIST clConflictList, - IN ULONG ulIndex, - IN OUT PCONFLICT_DETAILS_W pConflictDetails); - -#ifdef UNICODE -#define CM_Get_Resource_Conflict_Details CM_Get_Resource_Conflict_DetailsW -#else -#define CM_Get_Resource_Conflict_Details CM_Get_Resource_Conflict_DetailsA -#endif /* UNICODE */ - -CMAPI -CONFIGRET -WINAPI -CM_Get_Sibling( - OUT PDEVINST pdnDevInst, - IN DEVINST DevInst, - IN ULONG ulFlags); - -CMAPI -CONFIGRET -WINAPI -CM_Get_Sibling_Ex( - OUT PDEVINST pdnDevInst, - IN DEVINST DevInst, - IN ULONG ulFlags, - IN HMACHINE hMachine); - -CMAPI -WORD -WINAPI -CM_Get_Version( - VOID); - -CMAPI -WORD -WINAPI -CM_Get_Version_Ex( - IN HMACHINE hMachine); - -/* FIXME: Obsolete CM_Intersect_Range_List */ -/* FIXME: Obsolete CM_Invert_Range_List */ - -CMAPI -CONFIGRET -WINAPI -CM_Is_Dock_Station_Present( - OUT PBOOL pbPresent); - -CMAPI -CONFIGRET -WINAPI -CM_Is_Dock_Station_Present_Ex( - OUT PBOOL pbPresent, - IN HMACHINE hMachine); - -/* CM_Locate_DevNode.ulFlags constants */ -#define CM_LOCATE_DEVNODE_NORMAL 0x00000000 -#define CM_LOCATE_DEVNODE_PHANTOM 0x00000001 -#define CM_LOCATE_DEVNODE_CANCELREMOVE 0x00000002 -#define CM_LOCATE_DEVNODE_NOVALIDATION 0x00000004 -#define CM_LOCATE_DEVNODE_BITS 0x00000007 - -#define CM_LOCATE_DEVINST_NORMAL CM_LOCATE_DEVNODE_NORMAL -#define CM_LOCATE_DEVINST_PHANTOM CM_LOCATE_DEVNODE_PHANTOM -#define CM_LOCATE_DEVINST_CANCELREMOVE CM_LOCATE_DEVNODE_CANCELREMOVE -#define CM_LOCATE_DEVINST_NOVALIDATION CM_LOCATE_DEVNODE_NOVALIDATION -#define CM_LOCATE_DEVINST_BITS CM_LOCATE_DEVNODE_BITS - -CMAPI -CONFIGRET -WINAPI -CM_Locate_DevNodeA( - OUT PDEVINST pdnDevInst, - IN DEVINSTID_A pDeviceID, OPTIONAL - IN ULONG ulFlags); - -CMAPI -CONFIGRET -WINAPI -CM_Locate_DevNode_ExA( - OUT PDEVINST pdnDevInst, - IN DEVINSTID_A pDeviceID, OPTIONAL - IN ULONG ulFlags, - IN HMACHINE hMachine); - -CMAPI -CONFIGRET -WINAPI -CM_Locate_DevNode_ExW( - OUT PDEVINST pdnDevInst, - IN DEVINSTID_W pDeviceID, OPTIONAL - IN ULONG ulFlags, - IN HMACHINE hMachine); - -CMAPI -CONFIGRET -WINAPI -CM_Locate_DevNodeW( - OUT PDEVINST pdnDevInst, - IN DEVINSTID_W pDeviceID, OPTIONAL - IN ULONG ulFlags); - -#define CM_Locate_DevInstA CM_Locate_DevNodeA -#define CM_Locate_DevInstW CM_Locate_DevNodeW -#define CM_Locate_DevInst_ExA CM_Locate_DevNode_ExA -#define CM_Locate_DevInst_ExW CM_Locate_DevNode_ExW - -#ifdef UNICODE -#define CM_Locate_DevNode CM_Locate_DevNodeW -#define CM_Locate_DevInst CM_Locate_DevNodeW -#define CM_Locate_DevNode_Ex CM_Locate_DevNode_ExW -#define CM_Locate_DevInst_Ex CM_Locate_DevNode_ExW -#else -#define CM_Locate_DevNode CM_Locate_DevNodeA -#define CM_Locate_DevInst CM_Locate_DevNodeA -#define CM_Locate_DevNode_Ex CM_Locate_DevNode_ExA -#define CM_Locate_DevInst_Ex CM_Locate_DevNode_ExA -#endif /* UNICODE */ - -/* FIXME: Obsolete CM_Merge_Range_List */ - -CMAPI -CONFIGRET -WINAPI -CM_Modify_Res_Des( - OUT PRES_DES prdResDes, - IN RES_DES rdResDes, - IN RESOURCEID ResourceID, - IN PCVOID ResourceData, - IN ULONG ResourceLen, - IN ULONG ulFlags); - -CMAPI -CONFIGRET -WINAPI -CM_Modify_Res_Des_Ex( - OUT PRES_DES prdResDes, - IN RES_DES rdResDes, - IN RESOURCEID ResourceID, - IN PCVOID ResourceData, - IN ULONG ResourceLen, - IN ULONG ulFlags, - IN HMACHINE hMachine); - -/* FIXME: Obsolete CM_Move_DevNode */ -/* FIXME: Obsolete CM_Move_DevNode_Ex */ -/* FIXME: Obsolete CM_Next_Range */ - -CMAPI -CONFIGRET -WINAPI -CM_Open_Class_KeyA( - IN LPGUID ClassGuid, OPTIONAL - IN LPCSTR pszClassName, OPTIONAL - IN REGSAM samDesired, - IN REGDISPOSITION Disposition, - OUT PHKEY phkClass, - IN ULONG ulFlags); - -CMAPI -CONFIGRET -WINAPI -CM_Open_Class_KeyW( - IN LPGUID ClassGuid, OPTIONAL - IN LPCWSTR pszClassName, OPTIONAL - IN REGSAM samDesired, - IN REGDISPOSITION Disposition, - OUT PHKEY phkClass, - IN ULONG ulFlags); - -CMAPI -CONFIGRET -WINAPI -CM_Open_Class_Key_ExA( - IN LPGUID pszClassGuid, OPTIONAL - IN LPCSTR pszClassName, OPTIONAL - IN REGSAM samDesired, - IN REGDISPOSITION Disposition, - OUT PHKEY phkClass, - IN ULONG ulFlags, - IN HMACHINE hMachine); - -CMAPI -CONFIGRET -WINAPI -CM_Open_Class_Key_ExW( - IN LPGUID pszClassGuid, OPTIONAL - IN LPCWSTR pszClassName, OPTIONAL - IN REGSAM samDesired, - IN REGDISPOSITION Disposition, - OUT PHKEY phkClass, - IN ULONG ulFlags, - IN HMACHINE hMachine); - -#ifdef UNICODE -#define CM_Open_Class_Key CM_Open_Class_KeyW -#define CM_Open_Class_Key_Ex CM_Open_Class_Key_ExW -#else -#define CM_Open_Class_Key CM_Open_Class_KeyA -#define CM_Open_Class_Key_Ex CM_Open_Class_Key_ExA -#endif /* UNICODE */ - -CMAPI -CONFIGRET -WINAPI -CM_Open_DevNode_Key( - IN DEVINST dnDevNode, - IN REGSAM samDesired, - IN ULONG ulHardwareProfile, - IN REGDISPOSITION Disposition, - OUT PHKEY phkDevice, - IN ULONG ulFlags); - -CMAPI -CONFIGRET -WINAPI -CM_Open_DevNode_Key_Ex( - IN DEVINST dnDevNode, - IN REGSAM samDesired, - IN ULONG ulHardwareProfile, - IN REGDISPOSITION Disposition, - OUT PHKEY phkDevice, - IN ULONG ulFlags, - IN HMACHINE hMachine); - -#define CM_Open_DevInst_Key CM_Open_DevNode_Key -#define CM_Open_DevInst_Key_Ex CM_Open_DevNode_Key_Ex - -/* CM_Query_And_Remove_SubTree.ulFlags constants */ -#define CM_REMOVE_UI_OK 0x00000000 -#define CM_REMOVE_UI_NOT_OK 0x00000001 -#define CM_REMOVE_NO_RESTART 0x00000002 -#define CM_REMOVE_BITS 0x00000003 - -CMAPI -CONFIGRET -WINAPI -CM_Query_And_Remove_SubTreeA( - IN DEVINST dnAncestor, - OUT PPNP_VETO_TYPE pVetoType, - OUT LPSTR pszVetoName, - IN ULONG ulNameLength, - IN ULONG ulFlags); - -CMAPI -CONFIGRET -WINAPI -CM_Query_And_Remove_SubTreeW( - IN DEVINST dnAncestor, - OUT PPNP_VETO_TYPE pVetoType, - OUT LPWSTR pszVetoName, - IN ULONG ulNameLength, - IN ULONG ulFlags); - -CMAPI -CONFIGRET -WINAPI -CM_Query_And_Remove_SubTree_ExA( - IN DEVINST dnAncestor, - OUT PPNP_VETO_TYPE pVetoType, - OUT LPSTR pszVetoName, - IN ULONG ulNameLength, - IN ULONG ulFlags, - IN HMACHINE hMachine); - -CMAPI -CONFIGRET -WINAPI -CM_Query_And_Remove_SubTree_ExW( - IN DEVINST dnAncestor, - OUT PPNP_VETO_TYPE pVetoType, - OUT LPWSTR pszVetoName, - IN ULONG ulNameLength, - IN ULONG ulFlags, - IN HMACHINE hMachine); - -/* FIXME: Obsolete CM_Query_Arbitrator_Free_Data */ -/* FIXME: Obsolete CM_Query_Arbitrator_Free_Data_Ex */ -/* FIXME: Obsolete CM_Query_Arbitrator_Free_Size */ -/* FIXME: Obsolete CM_Query_Arbitrator_Free_Size_Ex */ -/* FIXME: Obsolete CM_Query_Arbitrator_Free_Size_Ex */ -/* FIXME: Obsolete CM_Query_Remove_SubTree */ -/* FIXME: Obsolete CM_Query_Remove_SubTree_Ex */ - -CMAPI -CONFIGRET -WINAPI -CM_Query_Resource_Conflict_List( - OUT PCONFLICT_LIST pclConflictList, - IN DEVINST dnDevInst, - IN RESOURCEID ResourceID, - IN PCVOID ResourceData, - IN ULONG ResourceLen, - IN ULONG ulFlags, - IN HMACHINE hMachine); - -/* CM_Reenumerate_DevNode.ulFlags constants */ -#define CM_REENUMERATE_NORMAL 0x00000000 -#define CM_REENUMERATE_SYNCHRONOUS 0x00000001 -#define CM_REENUMERATE_RETRY_INSTALLATION 0x00000002 -#define CM_REENUMERATE_ASYNCHRONOUS 0x00000004 -#define CM_REENUMERATE_BITS 0x00000007 - -CMAPI -CONFIGRET -WINAPI -CM_Reenumerate_DevNode( - IN DEVINST dnDevInst, - IN ULONG ulFlags); - -CMAPI -CONFIGRET -WINAPI -CM_Reenumerate_DevNode_Ex( - IN DEVINST dnDevInst, - IN ULONG ulFlags, - IN HMACHINE hMachine); - -#define CM_Reenumerate_DevInst CM_Reenumerate_DevNode -#define CM_Reenumerate_DevInst_Ex CM_Reenumerate_DevNode_Ex - -/* FIXME: Obsolete CM_Register_Device_Driver */ -/* FIXME: Obsolete CM_Register_Device_Driver_Ex */ -/* FIXME: Obsolete CM_Register_Device_Interface */ -/* FIXME: Obsolete CM_Register_Device_Interface_Ex */ -/* FIXME: Obsolete CM_Remove_SubTree */ -/* FIXME: Obsolete CM_Remove_SubTree_Ex */ - -CMAPI -CONFIGRET -WINAPI -CM_Request_Device_EjectA( - IN DEVINST dnDevInst, - OUT PPNP_VETO_TYPE pVetoType, - OUT LPSTR pszVetoName, - IN ULONG ulNameLength, - IN ULONG ulFlags); - -CMAPI -CONFIGRET -WINAPI -CM_Request_Device_Eject_ExW( - IN DEVINST dnDevInst, - OUT PPNP_VETO_TYPE pVetoType, - OUT LPWSTR pszVetoName, - IN ULONG ulNameLength, - IN ULONG ulFlags, - IN HMACHINE hMachine); - -CMAPI -CONFIGRET -WINAPI -CM_Request_Device_Eject_ExA( - IN DEVINST dnDevInst, - OUT PPNP_VETO_TYPE pVetoType, - OUT LPSTR pszVetoName, - IN ULONG ulNameLength, - IN ULONG ulFlags, - IN HMACHINE hMachine); - -CMAPI -CONFIGRET -WINAPI -CM_Request_Device_EjectW( - IN DEVINST dnDevInst, - OUT PPNP_VETO_TYPE pVetoType, - OUT LPWSTR pszVetoName, - IN ULONG ulNameLength, - IN ULONG ulFlags); - -#ifdef UNICODE -#define CM_Request_Device_Eject CM_Request_Device_EjectW -#define CM_Request_Device_Eject_Ex CM_Request_Device_Eject_ExW -#else -#define CM_Request_Device_Eject CM_Request_Device_EjectA -#define CM_Request_Device_Eject_Ex CM_Request_Device_Eject_ExA -#endif /* UNICODE */ - -CMAPI -CONFIGRET -WINAPI -CM_Request_Eject_PC( - VOID); - -CMAPI -CONFIGRET -WINAPI -CM_Request_Eject_PC_Ex( - IN HMACHINE hMachine); - -/* CM_Run_Detection[_Ex].ulFlags constants */ -#define CM_DETECT_NEW_PROFILE 0x00000001 -#define CM_DETECT_CRASHED 0x00000002 -#define CM_DETECT_HWPROF_FIRST_BOOT 0x00000004 -#define CM_DETECT_RUN 0x80000000 -#define CM_DETECT_BITS 0x80000007 - -CMAPI -CONFIGRET -WINAPI -CM_Run_Detection( - IN ULONG ulFlags); - -CMAPI -CONFIGRET -WINAPI -CM_Run_Detection_Ex( - IN ULONG ulFlags, - IN HMACHINE hMachine); - -/* FIXME: Obsolete CM_Set_Class_Registry_Property */ - -CMAPI -CONFIGRET -WINAPI -CM_Set_DevNode_Problem( - IN DEVINST dnDevInst, - IN ULONG ulProblem, - IN ULONG ulFlags); - -CMAPI -CONFIGRET -WINAPI -CM_Set_DevNode_Problem_Ex( - IN DEVINST dnDevInst, - IN ULONG ulProblem, - IN ULONG ulFlags, - IN HMACHINE hMachine); - -#define CM_Set_DevInst_Problem CM_Set_DevNode_Problem -#define CM_Set_DevInst_Problem_Ex CM_Set_DevNode_Problem_Ex - -CMAPI -CONFIGRET -WINAPI -CM_Set_DevNode_Registry_PropertyA( - IN DEVINST dnDevInst, - IN ULONG ulProperty, - IN PCVOID Buffer, OPTIONAL - IN ULONG ulLength, - IN ULONG ulFlags); - -CMAPI -CONFIGRET -WINAPI -CM_Set_DevNode_Registry_PropertyW( - IN DEVINST dnDevInst, - IN ULONG ulProperty, - IN PCVOID Buffer, OPTIONAL - IN ULONG ulLength, - IN ULONG ulFlags); - -CMAPI -CONFIGRET -WINAPI -CM_Set_DevNode_Registry_Property_ExA( - IN DEVINST dnDevInst, - IN ULONG ulProperty, - IN PCVOID Buffer, OPTIONAL - IN ULONG ulLength, - IN ULONG ulFlags, - IN HMACHINE hMachine); - -CMAPI -CONFIGRET -WINAPI -CM_Set_DevNode_Registry_Property_ExW( - IN DEVINST dnDevInst, - IN ULONG ulProperty, - IN PCVOID Buffer, OPTIONAL - IN ULONG ulLength, - IN ULONG ulFlags, - IN HMACHINE hMachine); - -#define CM_Set_DevInst_Registry_PropertyW CM_Set_DevNode_Registry_PropertyW -#define CM_Set_DevInst_Registry_PropertyA CM_Set_DevNode_Registry_PropertyA -#define CM_Set_DevInst_Registry_Property_ExW CM_Set_DevNode_Registry_Property_ExW -#define CM_Set_DevInst_Registry_Property_ExA CM_Set_DevNode_Registry_Property_ExA - -#ifdef UNICODE -#define CM_Set_DevInst_Registry_Property CM_Set_DevNode_Registry_PropertyW -#define CM_Set_DevInst_Registry_Property_Ex CM_Set_DevNode_Registry_Property_ExW -#define CM_Set_DevNode_Registry_Property CM_Set_DevNode_Registry_PropertyW -#define CM_Set_DevNode_Registry_Property_Ex CM_Set_DevNode_Registry_Property_ExW -#else -#define CM_Set_DevInst_Registry_Property CM_Set_DevNode_Registry_PropertyA -#define CM_Set_DevInst_Registry_Property_Ex CM_Set_DevNode_Registry_Property_ExA -#define CM_Set_DevNode_Registry_Property CM_Set_DevNode_Registry_PropertyA -#define CM_Set_DevNode_Registry_Property_Ex CM_Set_DevNode_Registry_Property_ExA -#endif /* UNICODE */ - -CMAPI -CONFIGRET -WINAPI -CM_Set_HW_Prof( - IN ULONG ulHardwareProfile, - IN ULONG ulFlags); - -CMAPI -CONFIGRET -WINAPI -CM_Set_HW_Prof_Ex( - IN ULONG ulHardwareProfile, - IN ULONG ulFlags, - IN HMACHINE hMachine); - -/* CM_Set_HW_Prof_Flags[_Ex].ulFlags constants */ -#define CM_SET_HW_PROF_FLAGS_UI_NOT_OK (0x00000001) -#define CM_SET_HW_PROF_FLAGS_BITS (0x00000001) - -CMAPI -CONFIGRET -WINAPI -CM_Set_HW_Prof_FlagsA( - IN DEVINSTID_A szDevInstName, - IN ULONG ulConfig, - IN ULONG ulValue, - IN ULONG ulFlags); - -CMAPI -CONFIGRET -WINAPI -CM_Set_HW_Prof_FlagsW( - IN DEVINSTID_W szDevInstName, - IN ULONG ulConfig, - IN ULONG ulValue, - IN ULONG ulFlags); - -CMAPI -CONFIGRET -WINAPI -CM_Set_HW_Prof_Flags_ExA( - IN DEVINSTID_A szDevInstName, - IN ULONG ulConfig, - IN ULONG ulValue, - IN ULONG ulFlags, - IN HMACHINE hMachine); - -CMAPI -CONFIGRET -WINAPI -CM_Set_HW_Prof_Flags_ExW( - IN DEVINSTID_W szDevInstName, - IN ULONG ulConfig, - IN ULONG ulValue, - IN ULONG ulFlags, - IN HMACHINE hMachine); - -#ifdef UNICODE -#define CM_Set_HW_Prof_Flags CM_Set_HW_Prof_FlagsW -#define CM_Set_HW_Prof_Flags_Ex CM_Set_HW_Prof_Flags_ExW -#else -#define CM_Set_HW_Prof_Flags CM_Set_HW_Prof_FlagsA -#define CM_Set_HW_Prof_Flags_Ex CM_Set_HW_Prof_Flags_ExA -#endif /* UNICODE */ - -/* CM_Setup_DevInst[_Ex].ulFlags constants */ -#define CM_SETUP_DEVNODE_READY (0x00000000) -#define CM_SETUP_DEVINST_READY CM_SETUP_DEVNODE_READY -#define CM_SETUP_DOWNLOAD (0x00000001) -#define CM_SETUP_WRITE_LOG_CONFS (0x00000002) -#define CM_SETUP_PROP_CHANGE (0x00000003) -#define CM_SETUP_DEVNODE_RESET (0x00000004) -#define CM_SETUP_DEVINST_RESET CM_SETUP_DEVNODE_RESET -#define CM_SETUP_BITS (0x00000007) - -CMAPI -CONFIGRET -WINAPI -CM_Setup_DevNode( - IN DEVINST dnDevInst, - IN ULONG ulFlags); - -CMAPI -CONFIGRET -WINAPI -CM_Setup_DevNode_Ex( - IN DEVINST dnDevInst, - IN ULONG ulFlags, - IN HMACHINE hMachine); - -/* FIXME: Obsolete CM_Test_Range_Available */ - -CMAPI -CONFIGRET -WINAPI -CM_Uninstall_DevNode( - IN DEVINST dnPhantom, - IN ULONG ulFlags); - -CMAPI -CONFIGRET -WINAPI -CM_Uninstall_DevNode_Ex( - IN DEVINST dnPhantom, - IN ULONG ulFlags, - IN HMACHINE hMachine); - -/* FIXME: Obsolete CM_Unregister_Device_Interface */ -/* FIXME: Obsolete CM_Unregister_Device_Interface_Ex */ - -#define CM_WaitNoPendingInstallEvents CMP_WaitNoPendingInstallEvents - -CMAPI -DWORD -WINAPI -CMP_WaitNoPendingInstallEvents( - IN DWORD dwTimeout); - -#include - -#ifdef __cplusplus -} -#endif - -#endif /* _CFGMGR32_H_ */ diff --git a/reactos/include/ddk/cfg.h b/reactos/include/psdk/cfg.h similarity index 65% rename from reactos/include/ddk/cfg.h rename to reactos/include/psdk/cfg.h index d9a4802da42..3653dec0eeb 100644 --- a/reactos/include/ddk/cfg.h +++ b/reactos/include/psdk/cfg.h @@ -20,7 +20,8 @@ * */ -#ifndef _CFG_INCLUDED_ +#pragma once + #define _CFG_INCLUDED_ #ifdef __cplusplus @@ -77,7 +78,26 @@ extern "C" { #define CM_PROB_DRIVER_BLOCKED 0x00000030 #define CM_PROB_REGISTRY_TOO_LARGE 0x00000031 #define CM_PROB_SETPROPERTIES_FAILED 0x00000032 -#define NUM_CM_PROB 0x00000033 +#define CM_PROB_WAITING_ON_DEPENDENCY 0x00000033 +#define CM_PROB_UNSIGNED_DRIVER 0x00000034 + +#define NUM_CM_PROB_V1 0x00000025 +#define NUM_CM_PROB_V2 0x00000032 +#define NUM_CM_PROB_V3 0x00000033 +#define NUM_CM_PROB_V4 0x00000034 +#define NUM_CM_PROB_V5 0x00000035 + +#if (NTDDI_VERSION >= NTDDI_WIN7) +#define NUM_CM_PROB NUM_CM_PROB_V5 +#elif (NTDDI_VERSION >= NTDDI_WS08) +#define NUM_CM_PROB NUM_CM_PROB_V4 +#elif (NTDDI_VERSION >= NTDDI_WS03) +#define NUM_CM_PROB NUM_CM_PROB_V3 +#elif (NTDDI_VERSION >= NTDDI_WINXP) +#define NUM_CM_PROB NUM_CM_PROB_V2 +#elif (NTDDI_VERSION >= WIN2K) +#define NUM_CM_PROB NUM_CM_PROB_V1 +#endif #define LCPRI_FORCECONFIG 0x00000000 #define LCPRI_BOOTCONFIG 0x00000001 @@ -95,24 +115,24 @@ extern "C" { #define LCPRI_DISABLED 0x0000FFFF #define MAX_LCPRI 0x0000FFFF -#define DN_ROOT_ENUMERATED 0x00000001 /* Was enumerated by ROOT */ -#define DN_DRIVER_LOADED 0x00000002 /* Has Register_Device_Driver */ -#define DN_ENUM_LOADED 0x00000004 /* Has Register_Enumerator */ -#define DN_STARTED 0x00000008 /* Is currently configured */ -#define DN_MANUAL 0x00000010 /* Manually installed */ -#define DN_NEED_TO_ENUM 0x00000020 /* May need reenumeration */ -#define DN_NOT_FIRST_TIME 0x00000040 /* Has received a config (Win9x only) */ -#define DN_HARDWARE_ENUM 0x00000080 /* Enum generates hardware ID */ -#define DN_LIAR 0x00000100 /* Lied about can reconfig once (Win9x only) */ -#define DN_HAS_MARK 0x00000200 /* Not CM_Create_DevNode lately (Win9x only) */ -#define DN_HAS_PROBLEM 0x00000400 /* Need device installer */ -#define DN_FILTERED 0x00000800 /* Is filtered */ -#define DN_MOVED 0x00001000 /* Has been moved (Win9x only) */ -#define DN_DISABLEABLE 0x00002000 /* Can be rebalanced */ -#define DN_REMOVABLE 0x00004000 /* Can be removed */ -#define DN_PRIVATE_PROBLEM 0x00008000 /* Has a private problem */ -#define DN_MF_PARENT 0x00010000 /* Multi function parent */ -#define DN_MF_CHILD 0x00020000 /* Multi function child */ +#define DN_ROOT_ENUMERATED 0x00000001 /* Was enumerated by ROOT */ +#define DN_DRIVER_LOADED 0x00000002 /* Has Register_Device_Driver */ +#define DN_ENUM_LOADED 0x00000004 /* Has Register_Enumerator */ +#define DN_STARTED 0x00000008 /* Is currently configured */ +#define DN_MANUAL 0x00000010 /* Manually installed */ +#define DN_NEED_TO_ENUM 0x00000020 /* May need reenumeration */ +#define DN_NOT_FIRST_TIME 0x00000040 /* Has received a config (Win9x only) */ +#define DN_HARDWARE_ENUM 0x00000080 /* Enum generates hardware ID */ +#define DN_LIAR 0x00000100 /* Lied about can reconfig once (Win9x only) */ +#define DN_HAS_MARK 0x00000200 /* Not CM_Create_DevNode lately (Win9x only) */ +#define DN_HAS_PROBLEM 0x00000400 /* Need device installer */ +#define DN_FILTERED 0x00000800 /* Is filtered */ +#define DN_MOVED 0x00001000 /* Has been moved (Win9x only) */ +#define DN_DISABLEABLE 0x00002000 /* Can be rebalanced */ +#define DN_REMOVABLE 0x00004000 /* Can be removed */ +#define DN_PRIVATE_PROBLEM 0x00008000 /* Has a private problem */ +#define DN_MF_PARENT 0x00010000 /* Multi function parent */ +#define DN_MF_CHILD 0x00020000 /* Multi function child */ #define DN_WILL_BE_REMOVED 0x00040000 #define DN_NOT_FIRST_TIMEE 0x00080000 #define DN_STOP_FREE_RES 0x00100000 @@ -128,11 +148,33 @@ extern "C" { #define DN_NO_SHOW_IN_DM 0x40000000 #define DN_BOOT_LOG_PROB 0x80000000 -#define DN_NEED_RESTART DN_LIAR -#define DN_DRIVER_BLOCKED DN_NOT_FIRST_TIME -#define DN_LEGACY_DRIVER DN_MOVED +#if (NTDDI_VERSION >= NTDDI_WINXP) + +#define DN_NEED_RESTART DN_LIAR +#define DN_DRIVER_BLOCKED DN_NOT_FIRST_TIME +#define DN_LEGACY_DRIVER DN_MOVED #define DN_CHILD_WITH_INVALID_ID DN_HAS_MARK +#elif (NTDDI_VERSION >= NTDDI_WIN2K) + +#define DN_NEED_RESTART 0x00000100 + +#endif + +#define DN_CHANGEABLE_FLAGS (DN_NOT_FIRST_TIME + \ + DN_HARDWARE_ENUM + \ + DN_HAS_MARK + \ + DN_DISABLEABLE + \ + DN_REMOVABLE + \ + DN_MF_CHILD + \ + DN_MF_PARENT + \ + DN_NOT_FIRST_TIMEE + \ + DN_STOP_FREE_RES + \ + DN_REBAL_CANDIDATE + \ + DN_NT_ENUMERATOR + \ + DN_NT_DRIVER + \ + DN_SILENT_INSTALL + \ + DN_NO_SHOW_IN_DM) typedef enum _PNP_VETO_TYPE { PNP_VetoTypeUnknown, @@ -149,14 +191,7 @@ typedef enum _PNP_VETO_TYPE { PNP_VetoLegacyDriver } PNP_VETO_TYPE, *PPNP_VETO_TYPE; -#define CM_GLOBAL_STATE_CAN_DO_UI 0x00000001 -#define CM_GLOBAL_STATE_ON_BIG_STACK 0x00000002 -#define CM_GLOBAL_STATE_SERVICES_AVAILABLE 0x00000004 -#define CM_GLOBAL_STATE_SHUTTING_DOWN 0x00000008 -#define CM_GLOBAL_STATE_DETECTION_PENDING 0x00000010 - #ifdef __cplusplus } #endif -#endif /* _CFG_INCLUDED_ */ diff --git a/reactos/include/psdk/cfgmgr32.h b/reactos/include/psdk/cfgmgr32.h new file mode 100644 index 00000000000..4623a65c11f --- /dev/null +++ b/reactos/include/psdk/cfgmgr32.h @@ -0,0 +1,3206 @@ +/* + * cfgmgr32.h + * + * PnP configuration manager + * + * This file is part of the w32api package. + * + * Contributors: + * Created by Casper S. Hornstrup + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAIMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + */ + +#pragma once + +#define _CFGMGR32_H_ + +#include + +#ifndef GUID_DEFINED +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(_CFGMGR32_) +#define CMAPI +#else +#define CMAPI DECLSPEC_IMPORT +#endif + +typedef CONST VOID *PCVOID; + +#define MAX_CONFIG_VALUE 9999 +#define MAX_INSTANCE_VALUE 9999 + +#define MAX_DEVICE_ID_LEN 200 +#define MAX_DEVNODE_ID_LEN MAX_DEVICE_ID_LEN + +#define MAX_CLASS_NAME_LEN 32 +#define MAX_GUID_STRING_LEN 39 +#define MAX_PROFILE_LEN 80 + +#define MAX_MEM_REGISTERS 9 +#define MAX_IO_PORTS 20 +#define MAX_IRQS 7 +#define MAX_DMA_CHANNELS 7 + +#define DWORD_MAX 0xffffffffUL +#define DWORDLONG_MAX 0xffffffffffffffffui64 + +#define CONFIGMG_VERSION 0x0400 + +#ifdef NT_INCLUDED + +typedef unsigned __int64 DWORDLONG; +typedef DWORDLONG *PDWORDLONG; + +#endif /* NT_INCLUDED */ + +typedef DWORD RETURN_TYPE; +typedef RETURN_TYPE CONFIGRET; + +typedef DWORD DEVNODE, DEVINST; +typedef DEVNODE *PDEVNODE, *PDEVINST; + +typedef CHAR *DEVNODEID_A, *DEVINSTID_A; +typedef WCHAR *DEVNODEID_W, *DEVINSTID_W; + +#ifdef UNICODE +typedef DEVNODEID_W DEVNODEID; +typedef DEVINSTID_W DEVINSTID; +#else +typedef DEVNODEID_A DEVNODEID; +typedef DEVINSTID_A DEVINSTID; +#endif + +typedef DWORD_PTR LOG_CONF; +typedef LOG_CONF *PLOG_CONF; + +typedef DWORD_PTR RES_DES; +typedef RES_DES *PRES_DES; + +typedef ULONG RESOURCEID; +typedef RESOURCEID *PRESOURCEID; + +typedef ULONG PRIORITY; +typedef PRIORITY *PPRIORITY; + +typedef DWORD_PTR RANGE_LIST; +typedef RANGE_LIST *PRANGE_LIST; + +typedef DWORD_PTR RANGE_ELEMENT; +typedef RANGE_ELEMENT *PRANGE_ELEMENT; + +typedef HANDLE HMACHINE; +typedef HMACHINE *PHMACHINE; + +typedef ULONG_PTR CONFLICT_LIST; +typedef CONFLICT_LIST *PCONFLICT_LIST; + +typedef struct _CONFLICT_DETAILS_A { + ULONG CD_ulSize; + ULONG CD_ulMask; + DEVINST CD_dnDevInst; + RES_DES CD_rdResDes; + ULONG CD_ulFlags; + CHAR CD_szDescription[MAX_PATH]; +} CONFLICT_DETAILS_A, *PCONFLICT_DETAILS_A; + +typedef struct _CONFLICT_DETAILS_W { + ULONG CD_ulSize; + ULONG CD_ulMask; + DEVINST CD_dnDevInst; + RES_DES CD_rdResDes; + ULONG CD_ulFlags; + WCHAR CD_szDescription[MAX_PATH]; +} CONFLICT_DETAILS_W, *PCONFLICT_DETAILS_W; + +#ifdef UNICODE +typedef CONFLICT_DETAILS_W CONFLICT_DETAILS; +typedef PCONFLICT_DETAILS_W PCONFLICT_DETAILS; +#else +typedef CONFLICT_DETAILS_A CONFLICT_DETAILS; +typedef PCONFLICT_DETAILS_A PCONFLICT_DETAILS; +#endif + +/* CONFLICT_DETAILS.CD.ulMask constants */ +#define CM_CDMASK_DEVINST 0x00000001 +#define CM_CDMASK_RESDES 0x00000002 +#define CM_CDMASK_FLAGS 0x00000004 +#define CM_CDMASK_DESCRIPTION 0x00000008 +#define CM_CDMASK_VALID 0x0000000F + +/* CONFLICT_DETAILS.CD.ulFlags constants */ +#define CM_CDFLAGS_DRIVER 0x00000001 +#define CM_CDFLAGS_ROOT_OWNED 0x00000002 +#define CM_CDFLAGS_RESERVED 0x00000004 + +typedef ULONG REGDISPOSITION; + +#include + +/* MEM_DES.MD_Flags constants */ +#define mMD_MemoryType 0x1 +#define fMD_MemoryType mMD_MemoryType +#define fMD_ROM 0x0 +#define fMD_RAM 0x1 + +#define mMD_32_24 0x2 +#define fMD_32_24 mMD_32_24 +#define fMD_24 0x0 +#define fMD_32 0x2 + +#define mMD_Prefetchable 0x4 +#define fMD_Prefetchable mMD_Prefetchable +#define fMD_Pref mMD_Prefetchable +#define fMD_PrefetchDisallowed 0x0 +#define fMD_PrefetchAllowed 0x4 + +#define mMD_Readable 0x8 +#define fMD_Readable mMD_Readable +#define fMD_ReadAllowed 0x0 +#define fMD_ReadDisallowed 0x8 + +#define mMD_CombinedWrite 0x10 +#define fMD_CombinedWrite mMD_CombinedWrite +#define fMD_CombinedWriteDisallowed 0x0 +#define fMD_CombinedWriteAllowed 0x10 + +#define mMD_Cacheable 0x20 +#define fMD_NonCacheable 0x0 +#define fMD_Cacheable 0x20 +#define fMD_WINDOW_DECODE 0x40 +#define fMD_MEMORY_BAR 0x80 + +typedef struct Mem_Range_s { + DWORDLONG MR_Align; + ULONG MR_nBytes; + DWORDLONG MR_Min; + DWORDLONG MR_Max; + DWORD MR_Flags; + DWORD MR_Reserved; +} MEM_RANGE, *PMEM_RANGE; + +typedef struct Mem_Des_s { + DWORD MD_Count; + DWORD MD_Type; + DWORDLONG MD_Alloc_Base; + DWORDLONG MD_Alloc_End; + DWORD MD_Flags; + DWORD MD_Reserved; +} MEM_DES, *PMEM_DES; + +typedef struct Mem_Resource_s { + MEM_DES MEM_Header; + MEM_RANGE MEM_Data[ANYSIZE_ARRAY]; +} MEM_RESOURCE, *PMEM_RESOURCE; + +#define MType_Range sizeof(MEM_RANGE) + +typedef struct Mem_Large_Range_s { + DWORDLONG MLR_Align; + ULONGLONG MLR_nBytes; + DWORDLONG MLR_Min; + DWORDLONG MLR_Max; + DWORD MLR_Flags; + DWORD MLR_Reserved; +} MEM_LARGE_RANGE, *PMEM_LARGE_RANGE; + +typedef struct Mem_Large_Des_s { + DWORD MLD_Count; + DWORD MLD_Type; + DWORDLONG MLD_Alloc_Base; + DWORDLONG MLD_Alloc_End; + DWORD MLD_Flags; + DWORD MLD_Reserved; +} MEM_LARGE_DES, *PMEM_LARGE_DES; + +typedef struct Mem_Large_Resource_s { + MEM_LARGE_DES MEM_LARGE_Header; + MEM_LARGE_RANGE MEM_LARGE_Data[ANYSIZE_ARRAY]; +} MEM_LARGE_RESOURCE, *PMEM_LARGE_RESOURCE; + +#define MLType_Range sizeof(struct Mem_Large_Range_s) + +/* IO_DES.Type constants and masks */ +#define fIOD_PortType 0x1 +#define fIOD_Memory 0x0 +#define fIOD_IO 0x1 +#define fIOD_DECODE 0x00fc +#define fIOD_10_BIT_DECODE 0x0004 +#define fIOD_12_BIT_DECODE 0x0008 +#define fIOD_16_BIT_DECODE 0x0010 +#define fIOD_POSITIVE_DECODE 0x0020 +#define fIOD_PASSIVE_DECODE 0x0040 +#define fIOD_WINDOW_DECODE 0x0080 +#define fIOD_PORT_BAR 0x0100 + +/* IO_RANGE.IOR_Alias constants */ +#define IO_ALIAS_10_BIT_DECODE 0x00000004 +#define IO_ALIAS_12_BIT_DECODE 0x00000010 +#define IO_ALIAS_16_BIT_DECODE 0x00000000 +#define IO_ALIAS_POSITIVE_DECODE 0x000000FF + +typedef struct IO_Range_s { + DWORDLONG IOR_Align; + DWORD IOR_nPorts; + DWORDLONG IOR_Min; + DWORDLONG IOR_Max; + DWORD IOR_RangeFlags; + DWORDLONG IOR_Alias; +} IO_RANGE, *PIO_RANGE; + +typedef struct IO_Des_s { + DWORD IOD_Count; + DWORD IOD_Type; + DWORDLONG IOD_Alloc_Base; + DWORDLONG IOD_Alloc_End; + DWORD IOD_DesFlags; +} IO_DES, *PIO_DES; + +typedef struct IO_Resource_s { + IO_DES IO_Header; + IO_RANGE IO_Data[ANYSIZE_ARRAY]; +} IO_RESOURCE, *PIO_RESOURCE; + +#define IOA_Local 0xff + +#define IOType_Range sizeof(IO_RANGE) + +/* DMA_DES.DD_Flags constants and masks */ +#define mDD_Width 0x3 +#define fDD_BYTE 0x0 +#define fDD_WORD 0x1 +#define fDD_DWORD 0x2 +#define fDD_BYTE_AND_WORD 0x3 + +#define mDD_BusMaster 0x4 +#define fDD_NoBusMaster 0x0 +#define fDD_BusMaster 0x4 + +#define mDD_Type 0x18 +#define fDD_TypeStandard 0x00 +#define fDD_TypeA 0x08 +#define fDD_TypeB 0x10 +#define fDD_TypeF 0x18 + +typedef struct DMA_Des_s { + DWORD DD_Count; + DWORD DD_Type; + DWORD DD_Flags; + ULONG DD_Alloc_Chan; +} DMA_DES, *PDMA_DES; + +typedef struct DMA_Range_s { + ULONG DR_Min; + ULONG DR_Max; + ULONG DR_Flags; +} DMA_RANGE, *PDMA_RANGE; + +#define DType_Range sizeof(DMA_RANGE) + +typedef struct DMA_Resource_s { + DMA_DES DMA_Header; + DMA_RANGE DMA_Data[ANYSIZE_ARRAY]; +} DMA_RESOURCE, *PDMA_RESOURCE; + +/* IRQ_DES.IRQD_flags constants */ +#define mIRQD_Share 0x1 +#define fIRQD_Exclusive 0x0 +#define fIRQD_Share 0x1 + +#define fIRQD_Share_Bit 0 +#define fIRQD_Level_Bit 1 + +#define mIRQD_Edge_Level 0x2 +#define fIRQD_Level 0x0 +#define fIRQD_Edge 0x2 + +typedef struct IRQ_Range_s { + ULONG IRQR_Min; + ULONG IRQR_Max; +#if defined(NT_PROCESSOR_GROUPS) + USHORT IRQR_Flags; + USHORT IRQR_Rsvdz; +#else + ULONG IRQR_Flags; +#endif +} IRQ_RANGE, *PIRQ_RANGE; + +typedef struct IRQ_Des_32_s { + DWORD IRQD_Count; + DWORD IRQD_Type; +#if defined(NT_PROCESSOR_GROUPS) + USHORT IRQD_Flags; + USHORT IRQD_Group; +#else + DWORD IRQD_Flags; +#endif + ULONG IRQD_Alloc_Num; + ULONG32 IRQD_Affinity; +} IRQ_DES_32, *PIRQ_DES_32; + +typedef struct IRQ_Des_64_s { + DWORD IRQD_Count; + DWORD IRQD_Type; +#if defined(NT_PROCESSOR_GROUPS) + USHORT IRQD_Flags; + USHORT IRQD_Group; +#else + DWORD IRQD_Flags; +#endif + ULONG IRQD_Alloc_Num; + ULONG64 IRQD_Affinity; +} IRQ_DES_64, *PIRQ_DES_64; + +#ifdef _WIN64 +typedef IRQ_DES_64 IRQ_DES; +typedef PIRQ_DES_64 PIRQ_DES; +#else +typedef IRQ_DES_32 IRQ_DES; +typedef PIRQ_DES_32 PIRQ_DES; +#endif + +typedef struct IRQ_Resource_32_s { + IRQ_DES_32 IRQ_Header; + IRQ_RANGE IRQ_Data[ANYSIZE_ARRAY]; +} IRQ_RESOURCE_32, *PIRQ_RESOURCE_32; + +typedef struct IRQ_Resource_64_s { + IRQ_DES_64 IRQ_Header; + IRQ_RANGE IRQ_Data[ANYSIZE_ARRAY]; +} IRQ_RESOURCE_64, *PIRQ_RESOURCE_64; + +#ifdef _WIN64 +typedef IRQ_RESOURCE_64 IRQ_RESOURCE; +typedef PIRQ_RESOURCE_64 PIRQ_RESOURCE; +#else +typedef IRQ_RESOURCE_32 IRQ_RESOURCE; +typedef PIRQ_RESOURCE_32 PIRQ_RESOURCE; +#endif + +#define IRQType_Range sizeof(IRQ_RANGE) + +#if (WINVER >= _WIN32_WINNT_WINXP) +#define CM_RESDES_WIDTH_DEFAULT 0x00000000 +#define CM_RESDES_WIDTH_32 0x00000001 +#define CM_RESDES_WIDTH_64 0x00000002 +#define CM_RESDES_WIDTH_BITS 0x00000003 +#endif + +typedef struct DevPrivate_Range_s { + DWORD PR_Data1; + DWORD PR_Data2; + DWORD PR_Data3; +} DEVPRIVATE_RANGE, *PDEVPRIVATE_RANGE; + +typedef struct DevPrivate_Des_s { + DWORD PD_Count; + DWORD PD_Type; + DWORD PD_Data1; + DWORD PD_Data2; + DWORD PD_Data3; + DWORD PD_Flags; +} DEVPRIVATE_DES, *PDEVPRIVATE_DES; + +#define PType_Range sizeof(DEVPRIVATE_RANGE) + +typedef struct DevPrivate_Resource_s { + DEVPRIVATE_DES PRV_Header; + DEVPRIVATE_RANGE PRV_Data[ANYSIZE_ARRAY]; +} DEVPRIVATE_RESOURCE, *PDEVPRIVATE_RESOURCE; + +typedef struct CS_Des_s { + DWORD CSD_SignatureLength; + DWORD CSD_LegacyDataOffset; + DWORD CSD_LegacyDataSize; + DWORD CSD_Flags; + GUID CSD_ClassGuid; + BYTE CSD_Signature[ANYSIZE_ARRAY]; +} CS_DES, *PCS_DES; + +typedef struct CS_Resource_s { + CS_DES CS_Header; +} CS_RESOURCE, *PCS_RESOURCE; + +#define mPCD_IO_8_16 0x1 +#define fPCD_IO_8 0x0 +#define fPCD_IO_16 0x1 +#define mPCD_MEM_8_16 0x2 +#define fPCD_MEM_8 0x0 +#define fPCD_MEM_16 0x2 +#define mPCD_MEM_A_C 0xC +#define fPCD_MEM1_A 0x4 +#define fPCD_MEM2_A 0x8 +#define fPCD_IO_ZW_8 0x10 +#define fPCD_IO_SRC_16 0x20 +#define fPCD_IO_WS_16 0x40 +#define mPCD_MEM_WS 0x300 +#define fPCD_MEM_WS_ONE 0x100 +#define fPCD_MEM_WS_TWO 0x200 +#define fPCD_MEM_WS_THREE 0x300 + +#if (WINVER >= _WIN32_WINNT_WINXP) + +#define fPCD_MEM_A 0x4 + +#define fPCD_ATTRIBUTES_PER_WINDOW 0x8000 + +#define fPCD_IO1_16 0x00010000 +#define fPCD_IO1_ZW_8 0x00020000 +#define fPCD_IO1_SRC_16 0x00040000 +#define fPCD_IO1_WS_16 0x00080000 + +#define fPCD_IO2_16 0x00100000 +#define fPCD_IO2_ZW_8 0x00200000 +#define fPCD_IO2_SRC_16 0x00400000 +#define fPCD_IO2_WS_16 0x00800000 + +#define mPCD_MEM1_WS 0x03000000 +#define fPCD_MEM1_WS_ONE 0x01000000 +#define fPCD_MEM1_WS_TWO 0x02000000 +#define fPCD_MEM1_WS_THREE 0x03000000 +#define fPCD_MEM1_16 0x04000000 + +#define mPCD_MEM2_WS 0x30000000 +#define fPCD_MEM2_WS_ONE 0x10000000 +#define fPCD_MEM2_WS_TWO 0x20000000 +#define fPCD_MEM2_WS_THREE 0x30000000 +#define fPCD_MEM2_16 0x40000000 + +#define PCD_MAX_MEMORY 2 +#define PCD_MAX_IO 2 + +#endif /* (WINVER >= _WIN32_WINNT_WINXP) */ + +typedef struct PcCard_Des_s { + DWORD PCD_Count; + DWORD PCD_Type; + DWORD PCD_Flags; + BYTE PCD_ConfigIndex; + BYTE PCD_Reserved[3]; + DWORD PCD_MemoryCardBase1; + DWORD PCD_MemoryCardBase2; +#if (WINVER >= _WIN32_WINNT_WINXP) + DWORD PCD_MemoryCardBase[PCD_MAX_MEMORY]; + WORD PCD_MemoryFlags[PCD_MAX_MEMORY]; + BYTE PCD_IoFlags[PCD_MAX_IO]; +#endif +} PCCARD_DES, *PPCCARD_DES; + +typedef struct PcCard_Resource_s { + PCCARD_DES PcCard_Header; +} PCCARD_RESOURCE, *PPCCARD_RESOURCE; + +/* MFCARD_DES.PMF_Flags constants */ +#define fPMF_AUDIO_ENABLE 0x8 +#define mPMF_AUDIO_ENABLE fPMF_AUDIO_ENABLE + +typedef struct MfCard_Des_s { + DWORD PMF_Count; + DWORD PMF_Type; + DWORD PMF_Flags; + BYTE PMF_ConfigOptions; + BYTE PMF_IoResourceIndex; + BYTE PMF_Reserved[2]; + DWORD PMF_ConfigRegisterBase; +} MFCARD_DES, *PMFCARD_DES; + +typedef struct MfCard_Resource_s { + MFCARD_DES MfCard_Header; +} MFCARD_RESOURCE, *PMFCARD_RESOURCE; + +typedef struct BusNumber_Des_s { + DWORD BUSD_Count; + DWORD BUSD_Type; + DWORD BUSD_Flags; + ULONG BUSD_Alloc_Base; + ULONG BUSD_Alloc_End; +} BUSNUMBER_DES, *PBUSNUMBER_DES; + +typedef struct BusNumber_Range_s { + ULONG BUSR_Min; + ULONG BUSR_Max; + ULONG BUSR_nBusNumbers; + ULONG BUSR_Flags; +} BUSNUMBER_RANGE, *PBUSNUMBER_RANGE; + +#define BusNumberType_Range sizeof(BUSNUMBER_RANGE) + +typedef struct BusNumber_Resource_s { + BUSNUMBER_DES BusNumber_Header; + BUSNUMBER_RANGE BusNumber_Data[ANYSIZE_ARRAY]; +} BUSNUMBER_RESOURCE, *PBUSNUMBER_RESOURCE; + +#define CM_HWPI_NOT_DOCKABLE 0x00000000 +#define CM_HWPI_UNDOCKED 0x00000001 +#define CM_HWPI_DOCKED 0x00000002 + +typedef struct HWProfileInfo_sA { + ULONG HWPI_ulHWProfile; + CHAR HWPI_szFriendlyName[MAX_PROFILE_LEN]; + DWORD HWPI_dwFlags; +} HWPROFILEINFO_A, *PHWPROFILEINFO_A; + +typedef struct HWProfileInfo_sW { + ULONG HWPI_ulHWProfile; + WCHAR HWPI_szFriendlyName[MAX_PROFILE_LEN]; + DWORD HWPI_dwFlags; +} HWPROFILEINFO_W, *PHWPROFILEINFO_W; + +#ifdef UNICODE +typedef HWPROFILEINFO_W HWPROFILEINFO; +typedef PHWPROFILEINFO_W PHWPROFILEINFO; +#else +typedef HWPROFILEINFO_A HWPROFILEINFO; +typedef PHWPROFILEINFO_A PHWPROFILEINFO; +#endif + +#include + +#define ResType_All 0x00000000 +#define ResType_None 0x00000000 +#define ResType_Mem 0x00000001 +#define ResType_IO 0x00000002 +#define ResType_DMA 0x00000003 +#define ResType_IRQ 0x00000004 +#define ResType_DoNotUse 0x00000005 +#define ResType_BusNumber 0x00000006 +#define ResType_MemLarge 0x00000007 +#define ResType_MAX 0x00000007 +#define ResType_Ignored_Bit 0x00008000 +#define ResType_ClassSpecific 0x0000FFFF +#define ResType_Reserved 0x00008000 +#define ResType_DevicePrivate 0x00008001 +#define ResType_PcCardConfig 0x00008002 +#define ResType_MfCardConfig 0x00008003 + +#define CM_ADD_RANGE_ADDIFCONFLICT 0x00000000 +#define CM_ADD_RANGE_DONOTADDIFCONFLICT 0x00000001 +#define CM_ADD_RANGE_BITS 0x00000001 + +#define BASIC_LOG_CONF 0x00000000 +#define FILTERED_LOG_CONF 0x00000001 +#define ALLOC_LOG_CONF 0x00000002 +#define BOOT_LOG_CONF 0x00000003 +#define FORCED_LOG_CONF 0x00000004 +#define OVERRIDE_LOG_CONF 0x00000005 +#define NUM_LOG_CONF 0x00000006 +#define LOG_CONF_BITS 0x00000007 + +#define PRIORITY_EQUAL_FIRST 0x00000008 +#define PRIORITY_EQUAL_LAST 0x00000000 +#define PRIORITY_BIT 0x00000008 + +#define RegDisposition_OpenAlways 0x00000000 +#define RegDisposition_OpenExisting 0x00000001 +#define RegDisposition_Bits 0x00000001 + +/* CM_Add_ID.ulFlags constants */ +#define CM_ADD_ID_HARDWARE 0x00000000 +#define CM_ADD_ID_COMPATIBLE 0x00000001 +#define CM_ADD_ID_BITS 0x00000001 + +/* Flags for CM_Create_DevNode[_Ex].ulFlags constants */ +#define CM_CREATE_DEVNODE_NORMAL 0x00000000 +#define CM_CREATE_DEVNODE_NO_WAIT_INSTALL 0x00000001 +#define CM_CREATE_DEVNODE_PHANTOM 0x00000002 +#define CM_CREATE_DEVNODE_GENERATE_ID 0x00000004 +#define CM_CREATE_DEVNODE_DO_NOT_INSTALL 0x00000008 +#define CM_CREATE_DEVNODE_BITS 0x0000000F + +#define CM_CREATE_DEVINST_NORMAL CM_CREATE_DEVNODE_NORMAL +#define CM_CREATE_DEVINST_NO_WAIT_INSTALL CM_CREATE_DEVNODE_NO_WAIT_INSTALL +#define CM_CREATE_DEVINST_PHANTOM CM_CREATE_DEVNODE_PHANTOM +#define CM_CREATE_DEVINST_GENERATE_ID CM_CREATE_DEVNODE_GENERATE_ID +#define CM_CREATE_DEVINST_DO_NOT_INSTALL CM_CREATE_DEVNODE_DO_NOT_INSTALL +#define CM_CREATE_DEVINST_BITS CM_CREATE_DEVNODE_BITS + +/* Flags for CM_Delete_Class_Key.ulFlags constants */ +#define CM_DELETE_CLASS_ONLY 0x00000000 +#define CM_DELETE_CLASS_SUBKEYS 0x00000001 +#if (WINVER >= _WIN32_WINNT_VISTA) +#define CM_DELETE_CLASS_INTERFACE 0x00000002 +#endif +#define CM_DELETE_CLASS_BITS 0x00000003 + +/* CM_Run_Detection[_Ex].ulFlags constants */ +#define CM_DETECT_NEW_PROFILE 0x00000001 +#define CM_DETECT_CRASHED 0x00000002 +#define CM_DETECT_HWPROF_FIRST_BOOT 0x00000004 +#define CM_DETECT_RUN 0x80000000 +#define CM_DETECT_BITS 0x80000007 + +#define CM_DISABLE_POLITE 0x00000000 +#define CM_DISABLE_ABSOLUTE 0x00000001 +#define CM_DISABLE_HARDWARE 0x00000002 +#define CM_DISABLE_UI_NOT_OK 0x00000004 +#define CM_DISABLE_BITS 0x00000007 + +#define CM_GETIDLIST_FILTER_NONE 0x00000000 +#define CM_GETIDLIST_FILTER_ENUMERATOR 0x00000001 +#define CM_GETIDLIST_FILTER_SERVICE 0x00000002 +#define CM_GETIDLIST_FILTER_EJECTRELATIONS 0x00000004 +#define CM_GETIDLIST_FILTER_REMOVALRELATIONS 0x00000008 +#define CM_GETIDLIST_FILTER_POWERRELATIONS 0x00000010 +#define CM_GETIDLIST_FILTER_BUSRELATIONS 0x00000020 +#define CM_GETIDLIST_DONOTGENERATE 0x10000040 +#if (WINVER <= _WIN32_WINNT_VISTA) +#define CM_GETIDLIST_FILTER_BITS 0x1000007F +#endif +#if (WINVER >= _WIN32_WINNT_WIN7) +#define CM_GETIDLIST_FILTER_TRANSPORTRELATIONS 0x00000080 +#define CM_GETIDLIST_FILTER_PRESENT 0x00000100 +#define CM_GETIDLIST_FILTER_CLASS 0x00000200 +#define CM_GETIDLIST_FILTER_BITS 0x100003FF +#endif + +#define CM_GET_DEVICE_INTERFACE_LIST_PRESENT 0x00000000 +#define CM_GET_DEVICE_INTERFACE_LIST_ALL_DEVICES 0x00000001 +#define CM_GET_DEVICE_INTERFACE_LIST_BITS 0x00000001 + +#define CM_DRP_DEVICEDESC 0x00000001 +#define CM_DRP_HARDWAREID 0x00000002 +#define CM_DRP_COMPATIBLEIDS 0x00000003 +#define CM_DRP_UNUSED0 0x00000004 +#define CM_DRP_SERVICE 0x00000005 +#define CM_DRP_UNUSED1 0x00000006 +#define CM_DRP_UNUSED2 0x00000007 +#define CM_DRP_CLASS 0x00000008 +#define CM_DRP_CLASSGUID 0x00000009 +#define CM_DRP_DRIVER 0x0000000A +#define CM_DRP_CONFIGFLAGS 0x0000000B +#define CM_DRP_MFG 0x0000000C +#define CM_DRP_FRIENDLYNAME 0x0000000D +#define CM_DRP_LOCATION_INFORMATION 0x0000000E +#define CM_DRP_PHYSICAL_DEVICE_OBJECT_NAME 0x0000000F +#define CM_DRP_CAPABILITIES 0x00000010 +#define CM_DRP_UI_NUMBER 0x00000011 +#define CM_DRP_UPPERFILTERS 0x00000012 +#if (WINVER >= _WIN32_WINNT_VISTA) +#define CM_CRP_UPPERFILTERS CM_DRP_UPPERFILTERS +#endif +#define CM_DRP_LOWERFILTERS 0x00000013 +#if (WINVER >= _WIN32_WINNT_VISTA) +#define CM_CRP_LOWERFILTERS CM_DRP_LOWERFILTERS +#endif +#define CM_DRP_BUSTYPEGUID 0x00000014 +#define CM_DRP_LEGACYBUSTYPE 0x00000015 +#define CM_DRP_BUSNUMBER 0x00000016 +#define CM_DRP_ENUMERATOR_NAME 0x00000017 +#define CM_DRP_SECURITY 0x00000018 +#define CM_CRP_SECURITY CM_DRP_SECURITY +#define CM_DRP_SECURITY_SDS 0x00000019 +#define CM_CRP_SECURITY_SDS CM_DRP_SECURITY_SDS +#define CM_DRP_DEVTYPE 0x0000001A +#define CM_CRP_DEVTYPE CM_DRP_DEVTYPE +#define CM_DRP_EXCLUSIVE 0x0000001B +#define CM_CRP_EXCLUSIVE CM_DRP_EXCLUSIVE +#define CM_DRP_CHARACTERISTICS 0x0000001C +#define CM_CRP_CHARACTERISTICS CM_DRP_CHARACTERISTICS +#define CM_DRP_ADDRESS 0x0000001D +#define CM_DRP_UI_NUMBER_DESC_FORMAT 0x0000001E +#if (WINVER >= _WIN32_WINNT_WINXP) +#define CM_DRP_DEVICE_POWER_DATA 0x0000001F +#define CM_DRP_REMOVAL_POLICY 0x00000020 +#define CM_DRP_REMOVAL_POLICY_HW_DEFAULT 0x00000021 +#define CM_DRP_REMOVAL_POLICY_OVERRIDE 0x00000022 +#define CM_DRP_INSTALL_STATE 0x00000023 +#endif +#if (WINVER >= _WIN32_WINNT_WS03) +#define CM_DRP_LOCATION_PATHS 0x00000024 +#endif +#if (WINVER >= _WIN32_WINNT_WIN7) +#define CM_DRP_BASE_CONTAINERID 0x00000025 +#endif +#define CM_DRP_MIN 0x00000001 +#define CM_CRP_MIN CM_DRP_MIN +#define CM_DRP_MAX 0x00000025 +#define CM_CRP_MAX CM_DRP_MAX + +#define CM_DEVCAP_LOCKSUPPORTED 0x00000001 +#define CM_DEVCAP_EJECTSUPPORTED 0x00000002 +#define CM_DEVCAP_REMOVABLE 0x00000004 +#define CM_DEVCAP_DOCKDEVICE 0x00000008 +#define CM_DEVCAP_UNIQUEID 0x00000010 +#define CM_DEVCAP_SILENTINSTALL 0x00000020 +#define CM_DEVCAP_RAWDEVICEOK 0x00000040 +#define CM_DEVCAP_SURPRISEREMOVALOK 0x00000080 +#define CM_DEVCAP_HARDWAREDISABLED 0x00000100 +#define CM_DEVCAP_NONDYNAMIC 0x00000200 + +#if (WINVER >= _WIN32_WINNT_WINXP) + +#define CM_REMOVAL_POLICY_EXPECT_NO_REMOVAL 1 +#define CM_REMOVAL_POLICY_EXPECT_ORDERLY_REMOVAL 2 +#define CM_REMOVAL_POLICY_EXPECT_SURPRISE_REMOVAL 3 + +#define CM_INSTALL_STATE_INSTALLED 0 +#define CM_INSTALL_STATE_NEEDS_REINSTALL 1 +#define CM_INSTALL_STATE_FAILED_INSTALL 2 +#define CM_INSTALL_STATE_FINISH_INSTALL 3 + +#endif /* (WINVER >= _WIN32_WINNT_WINXP) */ + +/* CM_Locate_DevNode.ulFlags constants */ +#define CM_LOCATE_DEVNODE_NORMAL 0x00000000 +#define CM_LOCATE_DEVNODE_PHANTOM 0x00000001 +#define CM_LOCATE_DEVNODE_CANCELREMOVE 0x00000002 +#define CM_LOCATE_DEVNODE_NOVALIDATION 0x00000004 +#define CM_LOCATE_DEVNODE_BITS 0x00000007 + +#define CM_LOCATE_DEVINST_NORMAL CM_LOCATE_DEVNODE_NORMAL +#define CM_LOCATE_DEVINST_PHANTOM CM_LOCATE_DEVNODE_PHANTOM +#define CM_LOCATE_DEVINST_CANCELREMOVE CM_LOCATE_DEVNODE_CANCELREMOVE +#define CM_LOCATE_DEVINST_NOVALIDATION CM_LOCATE_DEVNODE_NOVALIDATION +#define CM_LOCATE_DEVINST_BITS CM_LOCATE_DEVNODE_BITS + +#define CM_OPEN_CLASS_KEY_INSTALLER 0x00000000 +#define CM_OPEN_CLASS_KEY_INTERFACE 0x00000001 +#define CM_OPEN_CLASS_KEY_BITS 0x00000001 + +/* CM_Query_And_Remove_SubTree.ulFlags constants */ +#define CM_REMOVE_UI_OK 0x00000000 +#define CM_REMOVE_UI_NOT_OK 0x00000001 +#define CM_REMOVE_NO_RESTART 0x00000002 +#define CM_REMOVE_BITS 0x00000003 + +#define CM_QUERY_REMOVE_UI_OK (CM_REMOVE_UI_OK) +#define CM_QUERY_REMOVE_UI_NOT_OK (CM_REMOVE_UI_NOT_OK) +#define CM_QUERY_REMOVE_BITS (CM_QUERY_REMOVE_UI_OK|CM_QUERY_REMOVE_UI_NOT_OK) + +/* CM_Reenumerate_DevNode.ulFlags constants */ +#define CM_REENUMERATE_NORMAL 0x00000000 +#define CM_REENUMERATE_SYNCHRONOUS 0x00000001 +#if (WINVER >= _WIN32_WINNT_WINXP) +#define CM_REENUMERATE_RETRY_INSTALLATION 0x00000002 +#define CM_REENUMERATE_ASYNCHRONOUS 0x00000004 +#endif +#define CM_REENUMERATE_BITS 0x00000007 + +#define CM_REGISTER_DEVICE_DRIVER_STATIC 0x00000000 +#define CM_REGISTER_DEVICE_DRIVER_DISABLEABLE 0x00000001 +#define CM_REGISTER_DEVICE_DRIVER_REMOVABLE 0x00000002 +#define CM_REGISTER_DEVICE_DRIVER_BITS 0x00000003 + +#define CM_REGISTRY_HARDWARE 0x00000000 +#define CM_REGISTRY_SOFTWARE 0x00000001 +#define CM_REGISTRY_USER 0x00000100 +#define CM_REGISTRY_CONFIG 0x00000200 +#define CM_REGISTRY_BITS 0x00000301 + +#define CM_SET_DEVNODE_PROBLEM_NORMAL 0x00000000 +#define CM_SET_DEVNODE_PROBLEM_OVERRIDE 0x00000001 +#define CM_SET_DEVNODE_PROBLEM_BITS 0x00000001 + +#define CM_SET_DEVINST_PROBLEM_NORMAL CM_SET_DEVNODE_PROBLEM_NORMAL +#define CM_SET_DEVINST_PROBLEM_OVERRIDE CM_SET_DEVNODE_PROBLEM_OVERRIDE +#define CM_SET_DEVINST_PROBLEM_BITS CM_SET_DEVNODE_PROBLEM_BITS + +/* CM_Set_HW_Prof_Flags[_Ex].ulFlags constants */ +#define CM_SET_HW_PROF_FLAGS_UI_NOT_OK 0x00000001 +#define CM_SET_HW_PROF_FLAGS_BITS 0x00000001 + +/* CM_Setup_DevInst[_Ex].ulFlags constants */ +#define CM_SETUP_DEVNODE_READY 0x00000000 +#define CM_SETUP_DEVINST_READY CM_SETUP_DEVNODE_READY +#define CM_SETUP_DOWNLOAD 0x00000001 +#define CM_SETUP_WRITE_LOG_CONFS 0x00000002 +#define CM_SETUP_PROP_CHANGE 0x00000003 +#if (WINVER >= _WIN32_WINNT_WINXP) +#define CM_SETUP_DEVNODE_RESET 0x00000004 +#define CM_SETUP_DEVINST_RESET CM_SETUP_DEVNODE_RESET +#endif +#define CM_SETUP_BITS 0x00000007 + +#define CM_QUERY_ARBITRATOR_RAW 0x00000000 +#define CM_QUERY_ARBITRATOR_TRANSLATED 0x00000001 +#define CM_QUERY_ARBITRATOR_BITS 0x00000001 + +#if (WINVER >= _WIN32_WINNT_WINXP) +#define CM_CUSTOMDEVPROP_MERGE_MULTISZ 0x00000001 +#define CM_CUSTOMDEVPROP_BITS 0x00000001 +#endif + +#define CM_NAME_ATTRIBUTE_NAME_RETRIEVED_FROM_DEVICE 0x1 +#define CM_NAME_ATTRIBUTE_USER_ASSIGNED_NAME 0x2 + +#define CR_SUCCESS 0x00000000 +#define CR_DEFAULT 0x00000001 +#define CR_OUT_OF_MEMORY 0x00000002 +#define CR_INVALID_POINTER 0x00000003 +#define CR_INVALID_FLAG 0x00000004 +#define CR_INVALID_DEVNODE 0x00000005 +#define CR_INVALID_DEVINST CR_INVALID_DEVNODE +#define CR_INVALID_RES_DES 0x00000006 +#define CR_INVALID_LOG_CONF 0x00000007 +#define CR_INVALID_ARBITRATOR 0x00000008 +#define CR_INVALID_NODELIST 0x00000009 +#define CR_DEVNODE_HAS_REQS 0x0000000A +#define CR_DEVINST_HAS_REQS CR_DEVNODE_HAS_REQS +#define CR_INVALID_RESOURCEID 0x0000000B +#define CR_DLVXD_NOT_FOUND 0x0000000C +#define CR_NO_SUCH_DEVNODE 0x0000000D +#define CR_NO_SUCH_DEVINST CR_NO_SUCH_DEVNODE +#define CR_NO_MORE_LOG_CONF 0x0000000E +#define CR_NO_MORE_RES_DES 0x0000000F +#define CR_ALREADY_SUCH_DEVNODE 0x00000010 +#define CR_ALREADY_SUCH_DEVINST CR_ALREADY_SUCH_DEVNODE +#define CR_INVALID_RANGE_LIST 0x00000011 +#define CR_INVALID_RANGE 0x00000012 +#define CR_FAILURE 0x00000013 +#define CR_NO_SUCH_LOGICAL_DEV 0x00000014 +#define CR_CREATE_BLOCKED 0x00000015 +#define CR_NOT_SYSTEM_VM 0x00000016 +#define CR_REMOVE_VETOED 0x00000017 +#define CR_APM_VETOED 0x00000018 +#define CR_INVALID_LOAD_TYPE 0x00000019 +#define CR_BUFFER_SMALL 0x0000001A +#define CR_NO_ARBITRATOR 0x0000001B +#define CR_NO_REGISTRY_HANDLE 0x0000001C +#define CR_REGISTRY_ERROR 0x0000001D +#define CR_INVALID_DEVICE_ID 0x0000001E +#define CR_INVALID_DATA 0x0000001F +#define CR_INVALID_API 0x00000020 +#define CR_DEVLOADER_NOT_READY 0x00000021 +#define CR_NEED_RESTART 0x00000022 +#define CR_NO_MORE_HW_PROFILES 0x00000023 +#define CR_DEVICE_NOT_THERE 0x00000024 +#define CR_NO_SUCH_VALUE 0x00000025 +#define CR_WRONG_TYPE 0x00000026 +#define CR_INVALID_PRIORITY 0x00000027 +#define CR_NOT_DISABLEABLE 0x00000028 +#define CR_FREE_RESOURCES 0x00000029 +#define CR_QUERY_VETOED 0x0000002A +#define CR_CANT_SHARE_IRQ 0x0000002B +#define CR_NO_DEPENDENT 0x0000002C +#define CR_SAME_RESOURCES 0x0000002D +#define CR_NO_SUCH_REGISTRY_KEY 0x0000002E +#define CR_INVALID_MACHINENAME 0x0000002F +#define CR_REMOTE_COMM_FAILURE 0x00000030 +#define CR_MACHINE_UNAVAILABLE 0x00000031 +#define CR_NO_CM_SERVICES 0x00000032 +#define CR_ACCESS_DENIED 0x00000033 +#define CR_CALL_NOT_IMPLEMENTED 0x00000034 +#define CR_INVALID_PROPERTY 0x00000035 +#define CR_DEVICE_INTERFACE_ACTIVE 0x00000036 +#define CR_NO_SUCH_DEVICE_INTERFACE 0x00000037 +#define CR_INVALID_REFERENCE_STRING 0x00000038 +#define CR_INVALID_CONFLICT_LIST 0x00000039 +#define CR_INVALID_INDEX 0x0000003A +#define CR_INVALID_STRUCTURE_SIZE 0x0000003B +#define NUM_CR_RESULTS 0x0000003C + +#define CM_GLOBAL_STATE_CAN_DO_UI 0x00000001 +#define CM_GLOBAL_STATE_ON_BIG_STACK 0x00000002 +#define CM_GLOBAL_STATE_SERVICES_AVAILABLE 0x00000004 +#define CM_GLOBAL_STATE_SHUTTING_DOWN 0x00000008 +#define CM_GLOBAL_STATE_DETECTION_PENDING 0x00000010 +#if (WINVER >= _WIN32_WINNT_WIN7) +#define CM_GLOBAL_STATE_REBOOT_REQUIRED 0x00000020 +#endif + +/* FIXME : These definitions don't exist in the official header + +#define CMP_MAGIC 0x01234567 + +CMAPI +CONFIGRET +WINAPI +CMP_Init_Detection(IN DWORD dwMagic); + +CMAPI +CONFIGRET +WINAPI +CMP_RegisterNotification( + IN HANDLE hRecipient, + IN LPVOID lpvNotificationFilter, + IN DWORD dwFlags, + OUT PULONG pluhDevNotify); + +CMAPI +CONFIGRET +WINAPI +CMP_Report_LogOn( + IN DWORD dwMagic, + IN DWORD dwProcessId); + +CMAPI +CONFIGRET +WINAPI +CMP_UnregisterNotification(IN ULONG luhDevNotify); + +*/ + +CMAPI +CONFIGRET +WINAPI +CM_Add_Empty_Log_Conf( + OUT PLOG_CONF plcLogConf, + IN DEVINST dnDevInst, + IN PRIORITY Priority, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Add_Empty_Log_Conf_Ex( + OUT PLOG_CONF plcLogConf, + IN DEVINST dnDevInst, + IN PRIORITY Priority, + IN ULONG ulFlags, + IN HMACHINE hMachine); + +CMAPI +CONFIGRET +WINAPI +CM_Add_IDA( + IN DEVINST dnDevInst, + IN PSTR pszID, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Add_ID_ExA( + IN DEVINST dnDevInst, + IN PSTR pszID, + IN ULONG ulFlags, + IN HMACHINE hMachine); + +CMAPI +CONFIGRET +WINAPI +CM_Add_ID_ExW( + IN DEVINST dnDevInst, + IN PWSTR pszID, + IN ULONG ulFlags, + IN HMACHINE hMachine); + +CMAPI +CONFIGRET +WINAPI +CM_Add_IDW( + IN DEVINST dnDevInst, + IN PWSTR pszID, + IN ULONG ulFlags); + +#ifdef UNICODE +#define CM_Add_ID CM_Add_IDW +#define CM_Add_ID_Ex CM_Add_ID_ExW +#else +#define CM_Add_ID CM_Add_IDA +#define CM_Add_ID_Ex CM_Add_ID_ExA +#endif /* UNICODE */ + +CMAPI +CONFIGRET +WINAPI +CM_Add_Range( + IN DWORDLONG ullStartValue, + IN DWORDLONG ullEndValue, + IN RANGE_LIST rlh, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Add_Res_Des( + OUT PRES_DES prdResDes OPTIONAL, + IN LOG_CONF lcLogConf, + IN RESOURCEID ResourceID, + IN PCVOID ResourceData, + IN ULONG ResourceLen, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Add_Res_Des_Ex( + OUT PRES_DES prdResDes OPTIONAL, + IN LOG_CONF lcLogConf, + IN RESOURCEID ResourceID, + IN PCVOID ResourceData, + IN ULONG ResourceLen, + IN ULONG ulFlags, + IN HMACHINE hMachine); + +CMAPI +CONFIGRET +WINAPI +CM_Connect_MachineA( + IN PCSTR UNCServerName OPTIONAL, + OUT PHMACHINE phMachine); + +CMAPI +CONFIGRET +WINAPI +CM_Connect_MachineW( + IN PCWSTR UNCServerName OPTIONAL, + OUT PHMACHINE phMachine); + +#ifdef UNICODE +#define CM_Connect_Machine CM_Connect_MachineW +#else +#define CM_Connect_Machine CM_Connect_MachineA +#endif /* UNICODE */ + +CMAPI +CONFIGRET +WINAPI +CM_Create_DevNodeA( + OUT PDEVINST pdnDevInst, + IN DEVINSTID_A pDeviceID, + IN DEVINST dnParent, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Create_DevNodeW( + OUT PDEVINST pdnDevInst, + IN DEVINSTID_W pDeviceID, + IN DEVINST dnParent, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Create_DevNode_ExA( + OUT PDEVINST pdnDevInst, + IN DEVINSTID_A pDeviceID, + IN DEVINST dnParent, + IN ULONG ulFlags, + IN HANDLE hMachine); + +CMAPI +CONFIGRET +WINAPI +CM_Create_DevNode_ExW( + OUT PDEVINST pdnDevInst, + IN DEVINSTID_W pDeviceID, + IN DEVINST dnParent, + IN ULONG ulFlags, + IN HANDLE hMachine); + +#define CM_Create_DevInstW CM_Create_DevNodeW +#define CM_Create_DevInstA CM_Create_DevNodeA +#define CM_Create_DevInst_ExW CM_Create_DevNode_ExW +#define CM_Create_DevInst_ExA CM_Create_DevNode_ExA +#ifdef UNICODE +#define CM_Create_DevNode CM_Create_DevNodeW +#define CM_Create_DevInst CM_Create_DevNodeW +#define CM_Create_DevNode_Ex CM_Create_DevNode_ExW +#define CM_Create_DevInst_Ex CM_Create_DevInst_ExW +#else +#define CM_Create_DevNode CM_Create_DevNodeA +#define CM_Create_DevInst CM_Create_DevNodeA +#define CM_Create_DevNode_Ex CM_Create_DevNode_ExA +#define CM_Create_DevInst_Ex CM_Create_DevNode_ExA +#endif /* UNICODE */ + +CMAPI +CONFIGRET +WINAPI +CM_Create_Range_List( + OUT PRANGE_LIST prlh, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Delete_Class_Key( + IN LPGUID ClassGuid, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Delete_Class_Key_Ex( + IN LPGUID ClassGuid, + IN ULONG ulFlags, + IN HANDLE hMachine); + +CMAPI +CONFIGRET +WINAPI +CM_Delete_DevNode_Key( + IN DEVNODE dnDevNode, + IN ULONG ulHardwareProfile, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Delete_DevNode_Key_Ex( + IN DEVNODE dnDevNode, + IN ULONG ulHardwareProfile, + IN ULONG ulFlags, + IN HANDLE hMachine); + +#define CM_Delete_DevInst_Key CM_Delete_DevNode_Key +#define CM_Delete_DevInst_Key_Ex CM_Delete_DevNode_Key_Ex + +CMAPI +CONFIGRET +WINAPI +CM_Delete_Range( + IN DWORDLONG ullStartValue, + IN DWORDLONG ullEndValue, + IN RANGE_LIST rlh, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Detect_Resource_Conflict( + IN DEVINST dnDevInst, + IN RESOURCEID ResourceID, + IN PCVOID ResourceData, + IN ULONG ResourceLen, + OUT PBOOL pbConflictDetected, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Detect_Resource_Conflict_Ex( + IN DEVINST dnDevInst, + IN RESOURCEID ResourceID, + IN PCVOID ResourceData, + IN ULONG ResourceLen, + OUT PBOOL pbConflictDetected, + IN ULONG ulFlags, + IN HMACHINE hMachine OPTIONAL); + +CMAPI +CONFIGRET +WINAPI +CM_Disable_DevNode( + IN DEVINST dnDevInst, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Disable_DevNode_Ex( + IN DEVINST dnDevInst, + IN ULONG ulFlags, + IN HMACHINE hMachine OPTIONAL); + +#define CM_Disable_DevInst CM_Disable_DevNode +#define CM_Disable_DevInst_Ex CM_Disable_DevNode_Ex + +CMAPI +CONFIGRET +WINAPI +CM_Disconnect_Machine( + IN HMACHINE hMachine OPTIONAL); + +CMAPI +CONFIGRET +WINAPI +CM_Dup_Range_List( + IN RANGE_LIST rlhOld, + IN RANGE_LIST rlhNew, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Enable_DevNode( + IN DEVINST dnDevInst, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Enable_DevNode_Ex( + IN DEVINST dnDevInst, + IN ULONG ulFlags, + IN HMACHINE hMachine OPTIONAL); + +#define CM_Enable_DevInst CM_Enable_DevNode +#define CM_Enable_DevInst_Ex CM_Enable_DevNode_Ex + +CMAPI +CONFIGRET +WINAPI +CM_Enumerate_Classes( + IN ULONG ulClassIndex, + OUT LPGUID ClassGuid, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Enumerate_Classes_Ex( + IN ULONG ulClassIndex, + OUT LPGUID ClassGuid, + IN ULONG ulFlags, + IN HMACHINE hMachine OPTIONAL); + +CMAPI +CONFIGRET +WINAPI +CM_Enumerate_EnumeratorsA( + IN ULONG ulEnumIndex, + OUT PCHAR Buffer, + IN OUT PULONG pulLength, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Enumerate_Enumerators_ExA( + IN ULONG ulEnumIndex, + OUT PCHAR Buffer, + IN OUT PULONG pulLength, + IN ULONG ulFlags, + IN HMACHINE hMachine OPTIONAL); + +CMAPI +CONFIGRET +WINAPI +CM_Enumerate_Enumerators_ExW( + IN ULONG ulEnumIndex, + OUT PWCHAR Buffer, + IN OUT PULONG pulLength, + IN ULONG ulFlags, + IN HMACHINE hMachine OPTIONAL); + +CMAPI +CONFIGRET +WINAPI +CM_Enumerate_EnumeratorsW( + IN ULONG ulEnumIndex, + OUT PWCHAR Buffer, + IN OUT PULONG pulLength, + IN ULONG ulFlags); + +#ifdef UNICODE +#define CM_Enumerate_Enumerators CM_Enumerate_EnumeratorsW +#define CM_Enumerate_Enumerators_Ex CM_Enumerate_Enumerators_ExW +#else +#define CM_Enumerate_Enumerators CM_Enumerate_EnumeratorsA +#define CM_Enumerate_Enumerators_Ex CM_Enumerate_Enumerators_ExA +#endif /* UNICODE */ + +CMAPI +CONFIGRET +WINAPI +CM_Find_Range( + OUT PDWORDLONG pullStart, + IN DWORDLONG ullStart, + IN ULONG ulLength, + IN DWORDLONG ullAlignment, + IN DWORDLONG ullEnd, + IN RANGE_LIST rlh, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_First_Range( + IN RANGE_LIST rlh, + OUT PDWORDLONG pullStart, + OUT PDWORDLONG pullEnd, + OUT PRANGE_ELEMENT preElement, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Free_Log_Conf( + IN LOG_CONF lcLogConfToBeFreed, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Free_Log_Conf_Ex( + IN LOG_CONF lcLogConfToBeFreed, + IN ULONG ulFlags, + IN HMACHINE hMachine); + +CMAPI +CONFIGRET +WINAPI +CM_Free_Log_Conf_Handle( + IN LOG_CONF lcLogConf); + +CMAPI +CONFIGRET +WINAPI +CM_Free_Range_List( + IN RANGE_LIST rlh, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Free_Res_Des( + OUT PRES_DES prdResDes, + IN RES_DES rdResDes, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Free_Res_Des_Ex( + OUT PRES_DES prdResDes, + IN RES_DES rdResDes, + IN ULONG ulFlags, + IN HMACHINE hMachine); + +CMAPI +CONFIGRET +WINAPI +CM_Free_Res_Des_Handle( + IN RES_DES rdResDes); + +CMAPI +CONFIGRET +WINAPI +CM_Free_Resource_Conflict_Handle( + IN CONFLICT_LIST clConflictList); + +CMAPI +CONFIGRET +WINAPI +CM_Get_Child( + OUT PDEVINST pdnDevInst, + IN DEVINST dnDevInst, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Get_Child_Ex( + OUT PDEVINST pdnDevInst, + IN DEVINST dnDevInst, + IN ULONG ulFlags, + IN HMACHINE hMachine); + +CMAPI +CONFIGRET +WINAPI +CM_Get_Class_NameA( + IN LPGUID ClassGuid, + OUT PCHAR Buffer, + IN OUT PULONG pulLength, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Get_Class_NameW( + IN LPGUID ClassGuid, + OUT PWCHAR Buffer, + IN OUT PULONG pulLength, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Get_Class_Name_ExA( + IN LPGUID ClassGuid, + OUT PCHAR Buffer, + IN OUT PULONG pulLength, + IN ULONG ulFlags, + IN HMACHINE hMachine); + +CMAPI +CONFIGRET +WINAPI +CM_Get_Class_Name_ExW( + IN LPGUID ClassGuid, + OUT PWCHAR Buffer, + IN OUT PULONG pulLength, + IN ULONG ulFlags, + IN HMACHINE hMachine); + +#ifdef UNICODE +#define CM_Get_Class_Name CM_Get_Class_NameW +#define CM_Get_Class_Name_Ex CM_Get_Class_Name_ExW +#else +#define CM_Get_Class_Name CM_Get_Class_NameA +#define CM_Get_Class_Name_Ex CM_Get_Class_Name_ExA +#endif /* UNICODE */ + +CMAPI +CONFIGRET +WINAPI +CM_Get_Class_Key_NameA( + IN LPGUID ClassGuid, + OUT LPSTR pszKeyName, + IN OUT PULONG pulLength, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Get_Class_Key_NameW( + IN LPGUID ClassGuid, + OUT LPWSTR pszKeyName, + IN OUT PULONG pulLength, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Get_Class_Key_Name_ExA( + IN LPGUID ClassGuid, + OUT LPSTR pszKeyName, + IN OUT PULONG pulLength, + IN ULONG ulFlags, + IN HMACHINE hMachine); + +CMAPI +CONFIGRET +WINAPI +CM_Get_Class_Key_Name_ExW( + IN LPGUID ClassGuid, + OUT LPWSTR pszKeyName, + IN OUT PULONG pulLength, + IN ULONG ulFlags, + IN HMACHINE hMachine); + +#ifdef UNICODE +#define CM_Get_Class_Key_Name CM_Get_Class_Key_NameW +#define CM_Get_Class_Key_Name_Ex CM_Get_Class_Key_Name_ExW +#else +#define CM_Get_Class_Key_Name CM_Get_Class_Key_NameA +#define CM_Get_Class_Key_Name_Ex CM_Get_Class_Key_Name_ExA +#endif /* UNICODE */ + +CMAPI +CONFIGRET +WINAPI +CM_Get_Depth( + OUT PULONG pulDepth, + IN DEVINST dnDevInst, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Get_Depth_Ex( + OUT PULONG pulDepth, + IN DEVINST dnDevInst, + IN ULONG ulFlags, + IN HMACHINE hMachine); + +CMAPI +CONFIGRET +WINAPI +CM_Get_Device_IDA( + IN DEVINST dnDevInst, + OUT PCHAR Buffer, + IN ULONG BufferLen, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Get_Device_ID_ExA( + IN DEVINST dnDevInst, + OUT PCHAR Buffer, + IN ULONG BufferLen, + IN ULONG ulFlags, + IN HMACHINE hMachine); + +CMAPI +CONFIGRET +WINAPI +CM_Get_Device_ID_ExW( + IN DEVINST dnDevInst, + OUT PWCHAR Buffer, + IN ULONG BufferLen, + IN ULONG ulFlags, + IN HMACHINE hMachine); + +CMAPI +CONFIGRET +WINAPI +CM_Get_Device_IDW( + IN DEVINST dnDevInst, + OUT PWCHAR Buffer, + IN ULONG BufferLen, + IN ULONG ulFlags); + +#ifdef UNICODE +#define CM_Get_Device_ID CM_Get_Device_IDW +#define CM_Get_Device_ID_Ex CM_Get_Device_ID_ExW +#else +#define CM_Get_Device_ID CM_Get_Device_IDA +#define CM_Get_Device_ID_Ex CM_Get_Device_ID_ExA +#endif /* UNICODE */ + +CMAPI +CONFIGRET +WINAPI +CM_Get_Device_ID_ListA( + IN PCSTR pszFilter OPTIONAL, + OUT PCHAR Buffer, + IN ULONG BufferLen, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Get_Device_ID_List_ExA( + IN PCSTR pszFilter OPTIONAL, + OUT PCHAR Buffer, + IN ULONG BufferLen, + IN ULONG ulFlags, + IN HMACHINE hMachine); + +CMAPI +CONFIGRET +WINAPI +CM_Get_Device_ID_List_ExW( + IN PCWSTR pszFilter OPTIONAL, + OUT PWCHAR Buffer, + IN ULONG BufferLen, + IN ULONG ulFlags, + IN HMACHINE hMachine); + +CMAPI +CONFIGRET +WINAPI +CM_Get_Device_ID_ListW( + IN PCWSTR pszFilter OPTIONAL, + OUT PWCHAR Buffer, + IN ULONG BufferLen, + IN ULONG ulFlags); + +#ifdef UNICODE +#define CM_Get_Device_ID_List CM_Get_Device_ID_ListW +#define CM_Get_Device_ID_List_Ex CM_Get_Device_ID_List_ExW +#else +#define CM_Get_Device_ID_List CM_Get_Device_ID_ListA +#define CM_Get_Device_ID_List_Ex CM_Get_Device_ID_List_ExA +#endif /* UNICODE */ + +CMAPI +CONFIGRET +WINAPI +CM_Get_Device_ID_List_SizeA( + OUT PULONG pulLen, + IN PCSTR pszFilter OPTIONAL, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Get_Device_ID_List_Size_ExA( + OUT PULONG pulLen, + IN PCSTR pszFilter OPTIONAL, + IN ULONG ulFlags, + IN HMACHINE hMachine); + +CMAPI +CONFIGRET +WINAPI +CM_Get_Device_ID_List_Size_ExW( + OUT PULONG pulLen, + IN PCWSTR pszFilter OPTIONAL, + IN ULONG ulFlags, + IN HMACHINE hMachine); + +CMAPI +CONFIGRET +WINAPI +CM_Get_Device_ID_List_SizeW( + OUT PULONG pulLen, + IN PCWSTR pszFilter OPTIONAL, + IN ULONG ulFlags); + +#ifdef UNICODE +#define CM_Get_Device_ID_List_Size CM_Get_Device_ID_List_SizeW +#define CM_Get_Device_ID_List_Size_Ex CM_Get_Device_ID_List_Size_ExW +#else +#define CM_Get_Device_ID_List_Size CM_Get_Device_ID_List_SizeA +#define CM_Get_Device_ID_List_Size_Ex CM_Get_Device_ID_List_Size_ExA +#endif /* UNICODE */ + +CMAPI +CONFIGRET +WINAPI +CM_Get_Device_ID_Size( + OUT PULONG pulLen, + IN DEVINST dnDevInst, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Get_Device_ID_Size_Ex( + OUT PULONG pulLen, + IN DEVINST dnDevInst, + IN ULONG ulFlags, + IN HMACHINE hMachine); + +CMAPI +CONFIGRET +WINAPI +CM_Get_DevNode_Registry_PropertyA( + IN DEVINST dnDevInst, + IN ULONG ulProperty, + OUT PULONG pulRegDataType OPTIONAL, + OUT PVOID Buffer OPTIONAL, + IN OUT PULONG pulLength, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Get_DevNode_Registry_PropertyW( + IN DEVINST dnDevInst, + IN ULONG ulProperty, + OUT PULONG pulRegDataType OPTIONAL, + OUT PVOID Buffer OPTIONAL, + IN OUT PULONG pulLength, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Get_DevNode_Registry_Property_ExA( + IN DEVINST dnDevInst, + IN ULONG ulProperty, + OUT PULONG pulRegDataType OPTIONAL, + OUT PVOID Buffer OPTIONAL, + IN OUT PULONG pulLength, + IN ULONG ulFlags, + IN HMACHINE hMachine); + +CMAPI +CONFIGRET +WINAPI +CM_Get_DevNode_Registry_Property_ExW( + IN DEVINST dnDevInst, + IN ULONG ulProperty, + OUT PULONG pulRegDataType OPTIONAL, + OUT PVOID Buffer OPTIONAL, + IN OUT PULONG pulLength, + IN ULONG ulFlags, + IN HMACHINE hMachine); + +#define CM_Get_DevInst_Registry_PropertyW CM_Get_DevNode_Registry_PropertyW +#define CM_Get_DevInst_Registry_PropertyA CM_Get_DevNode_Registry_PropertyA +#define CM_Get_DevInst_Registry_Property_ExW CM_Get_DevNode_Registry_Property_ExW +#define CM_Get_DevInst_Registry_Property_ExA CM_Get_DevNode_Registry_Property_ExA + +#ifdef UNICODE +#define CM_Get_DevInst_Registry_Property CM_Get_DevNode_Registry_PropertyW +#define CM_Get_DevInst_Registry_Property_Ex CM_Get_DevNode_Registry_Property_ExW +#define CM_Get_DevNode_Registry_Property CM_Get_DevNode_Registry_PropertyW +#define CM_Get_DevNode_Registry_Property_Ex CM_Get_DevNode_Registry_Property_ExW +#else +#define CM_Get_DevInst_Registry_Property CM_Get_DevNode_Registry_PropertyA +#define CM_Get_DevInst_Registry_Property_Ex CM_Get_DevNode_Registry_Property_ExA +#define CM_Get_DevNode_Registry_Property CM_Get_DevNode_Registry_PropertyA +#define CM_Get_DevNode_Registry_Property_Ex CM_Get_DevNode_Registry_Property_ExA +#endif /* UNICODE */ + +#if (WINVER >= _WIN32_WINNT_WINXP) + +CMAPI +CONFIGRET +WINAPI +CM_Get_DevNode_Custom_PropertyA( + IN DEVINST dnDevInst, + IN PCSTR pszCustomPropertyName, + OUT PULONG pulRegDataType OPTIONAL, + OUT PVOID Buffer OPTIONAL, + IN OUT PULONG pulLength, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Get_DevNode_Custom_PropertyW( + IN DEVINST dnDevInst, + IN PCWSTR pszCustomPropertyName, + OUT PULONG pulRegDataType OPTIONAL, + OUT PVOID Buffer OPTIONAL, + IN OUT PULONG pulLength, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Get_DevNode_Custom_Property_ExA( + IN DEVINST dnDevInst, + IN PCSTR pszCustomPropertyName, + OUT PULONG pulRegDataType OPTIONAL, + OUT PVOID Buffer OPTIONAL, + IN OUT PULONG pulLength, + IN ULONG ulFlags, + IN HMACHINE hMachine OPTIONAL); + +CMAPI +CONFIGRET +WINAPI +CM_Get_DevNode_Custom_Property_ExW( + IN DEVINST dnDevInst, + IN PCWSTR pszCustomPropertyName, + OUT PULONG pulRegDataType OPTIONAL, + OUT PVOID Buffer OPTIONAL, + IN OUT PULONG pulLength, + IN ULONG ulFlags, + IN HMACHINE hMachine OPTIONAL); + +#define CM_Get_DevInst_Custom_PropertyW CM_Get_DevNode_Custom_PropertyW +#define CM_Get_DevInst_Custom_PropertyA CM_Get_DevNode_Custom_PropertyA +#define CM_Get_DevInst_Custom_Property_ExW CM_Get_DevNode_Custom_Property_ExW +#define CM_Get_DevInst_Custom_Property_ExA CM_Get_DevNode_Custom_Property_ExA +#ifdef UNICODE +#define CM_Get_DevInst_Custom_Property CM_Get_DevNode_Custom_PropertyW +#define CM_Get_DevInst_Custom_Property_Ex CM_Get_DevNode_Custom_Property_ExW +#define CM_Get_DevNode_Custom_Property CM_Get_DevNode_Custom_PropertyW +#define CM_Get_DevNode_Custom_Property_Ex CM_Get_DevNode_Custom_Property_ExW +#else +#define CM_Get_DevInst_Custom_Property CM_Get_DevNode_Custom_PropertyA +#define CM_Get_DevInst_Custom_Property_Ex CM_Get_DevNode_Custom_Property_ExA +#define CM_Get_DevNode_Custom_Property CM_Get_DevNode_Custom_PropertyA +#define CM_Get_DevNode_Custom_Property_Ex CM_Get_DevNode_Custom_Property_ExA +#endif + +#endif /* (WINVER >= _WIN32_WINNT_WINXP) */ + +CMAPI +CONFIGRET +WINAPI +CM_Get_DevNode_Status( + OUT PULONG pulStatus, + OUT PULONG pulProblemNumber, + IN DEVINST dnDevInst, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Get_DevNode_Status_Ex( + OUT PULONG pulStatus, + OUT PULONG pulProblemNumber, + IN DEVINST dnDevInst, + IN ULONG ulFlags, + IN HMACHINE hMachine); + +#define CM_Get_DevInst_Status CM_Get_DevNode_Status +#define CM_Get_DevInst_Status_Ex CM_Get_DevNode_Status_Ex + +CMAPI +CONFIGRET +WINAPI +CM_Get_First_Log_Conf( + OUT PLOG_CONF plcLogConf OPTIONAL, + IN DEVINST dnDevInst, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Get_First_Log_Conf_Ex( + OUT PLOG_CONF plcLogConf OPTIONAL, + IN DEVINST dnDevInst, + IN ULONG ulFlags, + IN HMACHINE hMachine OPTIONAL); + +CMAPI +CONFIGRET +WINAPI +CM_Get_Global_State( + OUT PULONG pulState, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Get_Global_State_Ex( + OUT PULONG pulState, + IN ULONG ulFlags, + IN HMACHINE hMachine); + +CMAPI +CONFIGRET +WINAPI +CM_Get_Hardware_Profile_InfoA( + IN ULONG ulIndex, + OUT PHWPROFILEINFO_A pHWProfileInfo, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Get_Hardware_Profile_Info_ExA( + IN ULONG ulIndex, + OUT PHWPROFILEINFO_A pHWProfileInfo, + IN ULONG ulFlags, + IN HMACHINE hMachine OPTIONAL); + +CMAPI +CONFIGRET +WINAPI +CM_Get_Hardware_Profile_InfoW( + IN ULONG ulIndex, + OUT PHWPROFILEINFO_W pHWProfileInfo, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Get_Hardware_Profile_Info_ExW( + IN ULONG ulIndex, + OUT PHWPROFILEINFO_W pHWProfileInfo, + IN ULONG ulFlags, + IN HMACHINE hMachine OPTIONAL); + +#ifdef UNICODE +#define CM_Get_Hardware_Profile_Info CM_Get_Hardware_Profile_InfoW +#define CM_Get_Hardware_Profile_Info_Ex CM_Get_Hardware_Profile_Info_ExW +#else +#define CM_Get_Hardware_Profile_Info CM_Get_Hardware_Profile_InfoA +#define CM_Get_Hardware_Profile_Info_Ex CM_Get_Hardware_Profile_Info_ExA +#endif + +CMAPI +CONFIGRET +WINAPI +CM_Get_HW_Prof_FlagsA( + IN DEVINSTID_A szDevInstName, + IN ULONG ulHardwareProfile, + OUT PULONG pulValue, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Get_HW_Prof_FlagsW( + IN DEVINSTID_W szDevInstName, + IN ULONG ulHardwareProfile, + OUT PULONG pulValue, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Get_HW_Prof_Flags_ExA( + IN DEVINSTID_A szDevInstName, + IN ULONG ulHardwareProfile, + OUT PULONG pulValue, + IN ULONG ulFlags, + IN HMACHINE hMachine); + +CMAPI +CONFIGRET +WINAPI +CM_Get_HW_Prof_Flags_ExW( + IN DEVINSTID_W szDevInstName, + IN ULONG ulHardwareProfile, + OUT PULONG pulValue, + IN ULONG ulFlags, + IN HMACHINE hMachine); + +#ifdef UNICODE +#define CM_Get_HW_Prof_Flags CM_Get_HW_Prof_FlagsW +#define CM_Get_HW_Prof_Flags_Ex CM_Get_HW_Prof_Flags_ExW +#else +#define CM_Get_HW_Prof_Flags CM_Get_HW_Prof_FlagsA +#define CM_Get_HW_Prof_Flags_Ex CM_Get_HW_Prof_Flags_ExA +#endif + +CMAPI +CONFIGRET +WINAPI +CM_Get_Device_Interface_AliasA( + IN LPCSTR pszDeviceInterface, + IN LPGUID AliasInterfaceGuid, + OUT LPSTR pszAliasDeviceInterface, + IN OUT PULONG pulLength, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Get_Device_Interface_AliasW( + IN LPCWSTR pszDeviceInterface, + IN LPGUID AliasInterfaceGuid, + OUT LPWSTR pszAliasDeviceInterface, + IN OUT PULONG pulLength, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Get_Device_Interface_Alias_ExA( + IN LPCSTR pszDeviceInterface, + IN LPGUID AliasInterfaceGuid, + OUT LPSTR pszAliasDeviceInterface, + IN OUT PULONG pulLength, + IN ULONG ulFlags, + IN HMACHINE hMachine OPTIONAL); + +CMAPI +CONFIGRET +WINAPI +CM_Get_Device_Interface_Alias_ExW( + IN LPCWSTR pszDeviceInterface, + IN LPGUID AliasInterfaceGuid, + OUT LPWSTR pszAliasDeviceInterface, + IN OUT PULONG pulLength, + IN ULONG ulFlags, + IN HMACHINE hMachine OPTIONAL); + +#ifdef UNICODE +#define CM_Get_Device_Interface_Alias CM_Get_Device_Interface_AliasW +#define CM_Get_Device_Interface_Alias_Ex CM_Get_Device_Interface_Alias_ExW +#else +#define CM_Get_Device_Interface_Alias CM_Get_Device_Interface_AliasA +#define CM_Get_Device_Interface_Alias_Ex CM_Get_Device_Interface_Alias_ExA +#endif + +CMAPI +CONFIGRET +WINAPI +CM_Get_Device_Interface_ListA( + IN LPGUID InterfaceClassGuid, + IN DEVINSTID_A pDeviceID OPTIONAL, + OUT PCHAR Buffer, + IN ULONG BufferLen, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Get_Device_Interface_ListW( + IN LPGUID InterfaceClassGuid, + IN DEVINSTID_W pDeviceID OPTIONAL, + OUT PWCHAR Buffer, + IN ULONG BufferLen, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Get_Device_Interface_List_ExA( + IN LPGUID InterfaceClassGuid, + IN DEVINSTID_A pDeviceID OPTIONAL, + OUT PCHAR Buffer, + IN ULONG BufferLen, + IN ULONG ulFlags, + IN HMACHINE hMachine OPTIONAL); + +CMAPI +CONFIGRET +WINAPI +CM_Get_Device_Interface_List_ExW( + IN LPGUID InterfaceClassGuid, + IN DEVINSTID_W pDeviceID OPTIONAL, + OUT PWCHAR Buffer, + IN ULONG BufferLen, + IN ULONG ulFlags, + IN HMACHINE hMachine OPTIONAL); + +#ifdef UNICODE +#define CM_Get_Device_Interface_List CM_Get_Device_Interface_ListW +#define CM_Get_Device_Interface_List_Ex CM_Get_Device_Interface_List_ExW +#else +#define CM_Get_Device_Interface_List CM_Get_Device_Interface_ListA +#define CM_Get_Device_Interface_List_Ex CM_Get_Device_Interface_List_ExA +#endif + +CMAPI +CONFIGRET +WINAPI +CM_Get_Device_Interface_List_SizeA( + OUT PULONG pulLen, + IN LPGUID InterfaceClassGuid, + IN DEVINSTID_A pDeviceID OPTIONAL, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Get_Device_Interface_List_SizeW( + OUT PULONG pulLen, + IN LPGUID InterfaceClassGuid, + IN DEVINSTID_W pDeviceID OPTIONAL, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Get_Device_Interface_List_Size_ExA( + OUT PULONG pulLen, + IN LPGUID InterfaceClassGuid, + IN DEVINSTID_A pDeviceID OPTIONAL, + IN ULONG ulFlags, + IN HMACHINE hMachine OPTIONAL); + +CMAPI +CONFIGRET +WINAPI +CM_Get_Device_Interface_List_Size_ExW( + OUT PULONG pulLen, + IN LPGUID InterfaceClassGuid, + IN DEVINSTID_W pDeviceID OPTIONAL, + IN ULONG ulFlags, + IN HMACHINE hMachine OPTIONAL); + +#ifdef UNICODE +#define CM_Get_Device_Interface_List_Size CM_Get_Device_Interface_List_SizeW +#define CM_Get_Device_Interface_List_Size_Ex CM_Get_Device_Interface_List_Size_ExW +#else +#define CM_Get_Device_Interface_List_Size CM_Get_Device_Interface_List_SizeA +#define CM_Get_Device_Interface_List_Size_Ex CM_Get_Device_Interface_List_Size_ExA +#endif + +CMAPI +CONFIGRET +WINAPI +CM_Get_Log_Conf_Priority( + IN LOG_CONF lcLogConf, + OUT PPRIORITY pPriority, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Get_Log_Conf_Priority_Ex( + IN LOG_CONF lcLogConf, + OUT PPRIORITY pPriority, + IN ULONG ulFlags, + IN HMACHINE hMachine); + +CMAPI +CONFIGRET +WINAPI +CM_Get_Next_Log_Conf( + OUT PLOG_CONF plcLogConf OPTIONAL, + IN LOG_CONF lcLogConf, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Get_Next_Log_Conf_Ex( + OUT PLOG_CONF plcLogConf OPTIONAL, + IN LOG_CONF lcLogConf, + IN ULONG ulFlags, + IN HMACHINE hMachine); + +CMAPI +CONFIGRET +WINAPI +CM_Get_Next_Res_Des( + OUT PRES_DES prdResDes, + IN RES_DES rdResDes, + IN RESOURCEID ForResource, + OUT PRESOURCEID pResourceID, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Get_Next_Res_Des_Ex( + OUT PRES_DES prdResDes, + IN RES_DES rdResDes, + IN RESOURCEID ForResource, + OUT PRESOURCEID pResourceID, + IN ULONG ulFlags, + IN HMACHINE hMachine); + +CMAPI +CONFIGRET +WINAPI +CM_Get_Parent( + OUT PDEVINST pdnDevInst, + IN DEVINST dnDevInst, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Get_Parent_Ex( + OUT PDEVINST pdnDevInst, + IN DEVINST dnDevInst, + IN ULONG ulFlags, + IN HMACHINE hMachine); + +CMAPI +CONFIGRET +WINAPI +CM_Get_Res_Des_Data( + IN RES_DES rdResDes, + OUT PVOID Buffer, + IN ULONG BufferLen, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Get_Res_Des_Data_Ex( + IN RES_DES rdResDes, + OUT PVOID Buffer, + IN ULONG BufferLen, + IN ULONG ulFlags, + IN HMACHINE hMachine); + +CMAPI +CONFIGRET +WINAPI +CM_Get_Res_Des_Data_Size( + OUT PULONG pulSize, + IN RES_DES rdResDes, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Get_Res_Des_Data_Size_Ex( + OUT PULONG pulSize, + IN RES_DES rdResDes, + IN ULONG ulFlags, + IN HMACHINE hMachine); + +CMAPI +CONFIGRET +WINAPI +CM_Get_Resource_Conflict_Count( + IN CONFLICT_LIST clConflictList, + OUT PULONG pulCount); + +CMAPI +CONFIGRET +WINAPI +CM_Get_Resource_Conflict_DetailsA( + IN CONFLICT_LIST clConflictList, + IN ULONG ulIndex, + IN OUT PCONFLICT_DETAILS_A pConflictDetails); + +CMAPI +CONFIGRET +WINAPI +CM_Get_Resource_Conflict_DetailsW( + IN CONFLICT_LIST clConflictList, + IN ULONG ulIndex, + IN OUT PCONFLICT_DETAILS_W pConflictDetails); + +#ifdef UNICODE +#define CM_Get_Resource_Conflict_Details CM_Get_Resource_Conflict_DetailsW +#else +#define CM_Get_Resource_Conflict_Details CM_Get_Resource_Conflict_DetailsA +#endif /* UNICODE */ + +CMAPI +CONFIGRET +WINAPI +CM_Get_Class_Registry_PropertyW( + IN LPGUID ClassGuid, + IN ULONG ulProperty, + OUT PULONG pulRegDataType OPTIONAL, + OUT PVOID Buffer OPTIONAL, + IN OUT PULONG pulLength, + IN ULONG ulFlags, + IN HMACHINE hMachine OPTIONAL); + +CMAPI +CONFIGRET +WINAPI +CM_Set_Class_Registry_PropertyW( + IN LPGUID ClassGuid, + IN ULONG ulProperty, + IN PCVOID Buffer OPTIONAL, + IN ULONG ulLength, + IN ULONG ulFlags, + IN HMACHINE hMachine OPTIONAL); + +CMAPI +CONFIGRET +WINAPI +CM_Get_Class_Registry_PropertyA( + IN LPGUID ClassGuid, + IN ULONG ulProperty, + OUT PULONG pulRegDataType OPTIONAL, + OUT PVOID Buffer OPTIONAL, + IN OUT PULONG pulLength, + IN ULONG ulFlags, + IN HMACHINE hMachine OPTIONAL); + +CMAPI +CONFIGRET +WINAPI +CM_Set_Class_Registry_PropertyA( + IN LPGUID ClassGuid, + IN ULONG ulProperty, + IN PCVOID Buffer OPTIONAL, + IN ULONG ulLength, + IN ULONG ulFlags, + IN HMACHINE hMachine OPTIONAL); + +#ifdef UNICODE +#define CM_Get_Class_Registry_Property CM_Get_Class_Registry_PropertyW +#define CM_Set_Class_Registry_Property CM_Set_Class_Registry_PropertyW +#else +#define CM_Get_Class_Registry_Property CM_Get_Class_Registry_PropertyA +#define CM_Set_Class_Registry_Property CM_Set_Class_Registry_PropertyA +#endif // UNICODE + +CMAPI +CONFIGRET +WINAPI +CM_Get_Sibling( + OUT PDEVINST pdnDevInst, + IN DEVINST DevInst, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Get_Sibling_Ex( + OUT PDEVINST pdnDevInst, + IN DEVINST DevInst, + IN ULONG ulFlags, + IN HMACHINE hMachine); + +CMAPI +WORD +WINAPI +CM_Get_Version(VOID); + +CMAPI +WORD +WINAPI +CM_Get_Version_Ex( + IN HMACHINE hMachine); + +#if (WINVER >= _WIN32_WINNT_WINXP) + +CMAPI +BOOL +WINAPI +CM_Is_Version_Available( + IN WORD wVersion); + +CMAPI +BOOL +WINAPI +CM_Is_Version_Available_Ex( + IN WORD wVersion, + IN HMACHINE hMachine OPTIONAL); + +#endif /* (WINVER >= _WIN32_WINNT_WINXP) */ + +CMAPI +CONFIGRET +WINAPI +CM_Intersect_Range_List( + IN RANGE_LIST rlhOld1, + IN RANGE_LIST rlhOld2, + IN RANGE_LIST rlhNew, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Invert_Range_List( + IN RANGE_LIST rlhOld, + IN RANGE_LIST rlhNew, + IN DWORDLONG ullMaxValue, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Is_Dock_Station_Present( + OUT PBOOL pbPresent); + +CMAPI +CONFIGRET +WINAPI +CM_Is_Dock_Station_Present_Ex( + OUT PBOOL pbPresent, + IN HMACHINE hMachine OPTIONAL); + +CMAPI +CONFIGRET +WINAPI +CM_Locate_DevNodeA( + OUT PDEVINST pdnDevInst, + IN DEVINSTID_A pDeviceID OPTIONAL, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Locate_DevNode_ExA( + OUT PDEVINST pdnDevInst, + IN DEVINSTID_A pDeviceID OPTIONAL, + IN ULONG ulFlags, + IN HMACHINE hMachine); + +CMAPI +CONFIGRET +WINAPI +CM_Locate_DevNode_ExW( + OUT PDEVINST pdnDevInst, + IN DEVINSTID_W pDeviceID OPTIONAL, + IN ULONG ulFlags, + IN HMACHINE hMachine); + +CMAPI +CONFIGRET +WINAPI +CM_Locate_DevNodeW( + OUT PDEVINST pdnDevInst, + IN DEVINSTID_W pDeviceID OPTIONAL, + IN ULONG ulFlags); + +#define CM_Locate_DevInstA CM_Locate_DevNodeA +#define CM_Locate_DevInstW CM_Locate_DevNodeW +#define CM_Locate_DevInst_ExA CM_Locate_DevNode_ExA +#define CM_Locate_DevInst_ExW CM_Locate_DevNode_ExW + +#ifdef UNICODE +#define CM_Locate_DevNode CM_Locate_DevNodeW +#define CM_Locate_DevInst CM_Locate_DevNodeW +#define CM_Locate_DevNode_Ex CM_Locate_DevNode_ExW +#define CM_Locate_DevInst_Ex CM_Locate_DevNode_ExW +#else +#define CM_Locate_DevNode CM_Locate_DevNodeA +#define CM_Locate_DevInst CM_Locate_DevNodeA +#define CM_Locate_DevNode_Ex CM_Locate_DevNode_ExA +#define CM_Locate_DevInst_Ex CM_Locate_DevNode_ExA +#endif /* UNICODE */ + +CMAPI +CONFIGRET +WINAPI +CM_Merge_Range_List( + IN RANGE_LIST rlhOld1, + IN RANGE_LIST rlhOld2, + IN RANGE_LIST rlhNew, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Modify_Res_Des( + OUT PRES_DES prdResDes, + IN RES_DES rdResDes, + IN RESOURCEID ResourceID, + IN PCVOID ResourceData, + IN ULONG ResourceLen, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Modify_Res_Des_Ex( + OUT PRES_DES prdResDes, + IN RES_DES rdResDes, + IN RESOURCEID ResourceID, + IN PCVOID ResourceData, + IN ULONG ResourceLen, + IN ULONG ulFlags, + IN HMACHINE hMachine); + +CMAPI +CONFIGRET +WINAPI +CM_Move_DevNode( + IN DEVINST dnFromDevInst, + IN DEVINST dnToDevInst, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Move_DevNode_Ex( + IN DEVINST dnFromDevInst, + IN DEVINST dnToDevInst, + IN ULONG ulFlags, + IN HMACHINE hMachine OPTIONAL); + +#define CM_Move_DevInst CM_Move_DevNode +#define CM_Move_DevInst_Ex CM_Move_DevNode_Ex + +CMAPI +CONFIGRET +WINAPI +CM_Next_Range( + IN OUT PRANGE_ELEMENT preElement, + OUT PDWORDLONG pullStart, + OUT PDWORDLONG pullEnd, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Open_Class_KeyA( + IN LPGUID ClassGuid OPTIONAL, + IN LPCSTR pszClassName OPTIONAL, + IN REGSAM samDesired, + IN REGDISPOSITION Disposition, + OUT PHKEY phkClass, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Open_Class_KeyW( + IN LPGUID ClassGuid OPTIONAL, + IN LPCWSTR pszClassName OPTIONAL, + IN REGSAM samDesired, + IN REGDISPOSITION Disposition, + OUT PHKEY phkClass, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Open_Class_Key_ExA( + IN LPGUID pszClassGuid OPTIONAL, + IN LPCSTR pszClassName OPTIONAL, + IN REGSAM samDesired, + IN REGDISPOSITION Disposition, + OUT PHKEY phkClass, + IN ULONG ulFlags, + IN HMACHINE hMachine); + +CMAPI +CONFIGRET +WINAPI +CM_Open_Class_Key_ExW( + IN LPGUID pszClassGuid OPTIONAL, + IN LPCWSTR pszClassName OPTIONAL, + IN REGSAM samDesired, + IN REGDISPOSITION Disposition, + OUT PHKEY phkClass, + IN ULONG ulFlags, + IN HMACHINE hMachine); + +#ifdef UNICODE +#define CM_Open_Class_Key CM_Open_Class_KeyW +#define CM_Open_Class_Key_Ex CM_Open_Class_Key_ExW +#else +#define CM_Open_Class_Key CM_Open_Class_KeyA +#define CM_Open_Class_Key_Ex CM_Open_Class_Key_ExA +#endif /* UNICODE */ + +CMAPI +CONFIGRET +WINAPI +CM_Open_DevNode_Key( + IN DEVINST dnDevNode, + IN REGSAM samDesired, + IN ULONG ulHardwareProfile, + IN REGDISPOSITION Disposition, + OUT PHKEY phkDevice, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Open_DevNode_Key_Ex( + IN DEVINST dnDevNode, + IN REGSAM samDesired, + IN ULONG ulHardwareProfile, + IN REGDISPOSITION Disposition, + OUT PHKEY phkDevice, + IN ULONG ulFlags, + IN HMACHINE hMachine); + +#define CM_Open_DevInst_Key CM_Open_DevNode_Key +#define CM_Open_DevInst_Key_Ex CM_Open_DevNode_Key_Ex + +#if (WINVER >= _WIN32_WINNT_VISTA) + +CMAPI +CONFIGRET +WINAPI +CM_Open_Device_Interface_KeyA( + IN LPCSTR pszDeviceInterface, + IN REGSAM samDesired, + IN REGDISPOSITION Disposition, + OUT PHKEY phkDeviceInterface, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Open_Device_Interface_KeyW( + IN LPCWSTR pszDeviceInterface, + IN REGSAM samDesired, + IN REGDISPOSITION Disposition, + OUT PHKEY phkDeviceInterface, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Open_Device_Interface_Key_ExA( + IN LPCSTR pszDeviceInterface, + IN REGSAM samDesired, + IN REGDISPOSITION Disposition, + OUT PHKEY phkDeviceInterface, + IN ULONG ulFlags, + IN HMACHINE hMachine OPTIONAL); + +CMAPI +CONFIGRET +WINAPI +CM_Open_Device_Interface_Key_ExW( + IN LPCWSTR pszDeviceInterface, + IN REGSAM samDesired, + IN REGDISPOSITION Disposition, + OUT PHKEY phkDeviceInterface, + IN ULONG ulFlags, + IN HMACHINE hMachine OPTIONAL); + +#ifdef UNICODE +#define CM_Open_Device_Interface_Key CM_Open_Device_Interface_KeyW +#define CM_Open_Device_Interface_Key_Ex CM_Open_Device_Interface_Key_ExW +#else +#define CM_Open_Device_Interface_Key CM_Open_Device_Interface_KeyA +#define CM_Open_Device_Interface_Key_Ex CM_Open_Device_Interface_Key_ExA +#endif + +CMAPI +CONFIGRET +WINAPI +CM_Delete_Device_Interface_KeyA( + IN LPCSTR pszDeviceInterface, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Delete_Device_Interface_KeyW( + IN LPCWSTR pszDeviceInterface, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Delete_Device_Interface_Key_ExA( + IN LPCSTR pszDeviceInterface, + IN ULONG ulFlags, + IN HMACHINE hMachine OPTIONAL); + +CMAPI +CONFIGRET +WINAPI +CM_Delete_Device_Interface_Key_ExW( + IN LPCWSTR pszDeviceInterface, + IN ULONG ulFlags, + IN HMACHINE hMachine OPTIONAL); + +#ifdef UNICODE +#define CM_Delete_Device_Interface_Key CM_Delete_Device_Interface_KeyW +#define CM_Delete_Device_Interface_Key_Ex CM_Delete_Device_Interface_Key_ExW +#else +#define CM_Delete_Device_Interface_Key CM_Delete_Device_Interface_KeyA +#define CM_Delete_Device_Interface_Key_Ex CM_Delete_Device_Interface_Key_ExA +#endif + +#endif /* (WINVER >= _WIN32_WINNT_VISTA) */ + +CMAPI +CONFIGRET +WINAPI +CM_Query_Arbitrator_Free_Data( + OUT PVOID pData, + IN ULONG DataLen, + IN DEVINST dnDevInst, + IN RESOURCEID ResourceID, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Query_Arbitrator_Free_Data_Ex( + OUT PVOID pData, + IN ULONG DataLen, + IN DEVINST dnDevInst, + IN RESOURCEID ResourceID, + IN ULONG ulFlags, + IN HMACHINE hMachine OPTIONAL); + +CMAPI +CONFIGRET +WINAPI +CM_Query_Arbitrator_Free_Size( + OUT PULONG pulSize, + IN DEVINST dnDevInst, + IN RESOURCEID ResourceID, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Query_Arbitrator_Free_Size_Ex( + OUT PULONG pulSize, + IN DEVINST dnDevInst, + IN RESOURCEID ResourceID, + IN ULONG ulFlags, + IN HMACHINE hMachine OPTIONAL); + +CMAPI +CONFIGRET +WINAPI +CM_Query_Remove_SubTree( + IN DEVINST dnAncestor, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Query_Remove_SubTree_Ex( + IN DEVINST dnAncestor, + IN ULONG ulFlags, + IN HMACHINE hMachine OPTIONAL); + +CMAPI +CONFIGRET +WINAPI +CM_Query_And_Remove_SubTreeA( + IN DEVINST dnAncestor, + OUT PPNP_VETO_TYPE pVetoType, + OUT LPSTR pszVetoName, + IN ULONG ulNameLength, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Query_And_Remove_SubTreeW( + IN DEVINST dnAncestor, + OUT PPNP_VETO_TYPE pVetoType, + OUT LPWSTR pszVetoName, + IN ULONG ulNameLength, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Query_And_Remove_SubTree_ExA( + IN DEVINST dnAncestor, + OUT PPNP_VETO_TYPE pVetoType, + OUT LPSTR pszVetoName, + IN ULONG ulNameLength, + IN ULONG ulFlags, + IN HMACHINE hMachine); + +CMAPI +CONFIGRET +WINAPI +CM_Query_And_Remove_SubTree_ExW( + IN DEVINST dnAncestor, + OUT PPNP_VETO_TYPE pVetoType, + OUT LPWSTR pszVetoName, + IN ULONG ulNameLength, + IN ULONG ulFlags, + IN HMACHINE hMachine); + +#ifdef UNICODE +#define CM_Query_And_Remove_SubTree CM_Query_And_Remove_SubTreeW +#define CM_Query_And_Remove_SubTree_Ex CM_Query_And_Remove_SubTree_ExW +#else +#define CM_Query_And_Remove_SubTree CM_Query_And_Remove_SubTreeA +#define CM_Query_And_Remove_SubTree_Ex CM_Query_And_Remove_SubTree_ExA +#endif + +CMAPI +CONFIGRET +WINAPI +CM_Query_Resource_Conflict_List( + OUT PCONFLICT_LIST pclConflictList, + IN DEVINST dnDevInst, + IN RESOURCEID ResourceID, + IN PCVOID ResourceData, + IN ULONG ResourceLen, + IN ULONG ulFlags, + IN HMACHINE hMachine OPTIONAL); + +CMAPI +CONFIGRET +WINAPI +CM_Reenumerate_DevNode( + IN DEVINST dnDevInst, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Reenumerate_DevNode_Ex( + IN DEVINST dnDevInst, + IN ULONG ulFlags, + IN HMACHINE hMachine); + +#define CM_Reenumerate_DevInst CM_Reenumerate_DevNode +#define CM_Reenumerate_DevInst_Ex CM_Reenumerate_DevNode_Ex + +CMAPI +CONFIGRET +WINAPI +CM_Register_Device_InterfaceA( + IN DEVINST dnDevInst, + IN LPGUID InterfaceClassGuid, + IN LPCSTR pszReference OPTIONAL, + OUT LPSTR pszDeviceInterface, + IN OUT PULONG pulLength, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Register_Device_InterfaceW( + IN DEVINST dnDevInst, + IN LPGUID InterfaceClassGuid, + IN LPCWSTR pszReference OPTIONAL, + OUT LPWSTR pszDeviceInterface, + IN OUT PULONG pulLength, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Register_Device_Interface_ExA( + IN DEVINST dnDevInst, + IN LPGUID InterfaceClassGuid, + IN LPCSTR pszReference OPTIONAL, + OUT LPSTR pszDeviceInterface, + IN OUT PULONG pulLength, + IN ULONG ulFlags, + IN HMACHINE hMachine OPTIONAL); + +CMAPI +CONFIGRET +WINAPI +CM_Register_Device_Interface_ExW( + IN DEVINST dnDevInst, + IN LPGUID InterfaceClassGuid, + IN LPCWSTR pszReference OPTIONAL, + OUT LPWSTR pszDeviceInterface, + IN OUT PULONG pulLength, + IN ULONG ulFlags, + IN HMACHINE hMachine OPTIONAL); + +#ifdef UNICODE +#define CM_Register_Device_Interface CM_Register_Device_InterfaceW +#define CM_Register_Device_Interface_Ex CM_Register_Device_Interface_ExW +#else +#define CM_Register_Device_Interface CM_Register_Device_InterfaceA +#define CM_Register_Device_Interface_Ex CM_Register_Device_Interface_ExA +#endif + +CMAPI +CONFIGRET +WINAPI +CM_Request_Device_EjectA( + IN DEVINST dnDevInst, + OUT PPNP_VETO_TYPE pVetoType, + OUT LPSTR pszVetoName, + IN ULONG ulNameLength, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Request_Device_Eject_ExW( + IN DEVINST dnDevInst, + OUT PPNP_VETO_TYPE pVetoType, + OUT LPWSTR pszVetoName, + IN ULONG ulNameLength, + IN ULONG ulFlags, + IN HMACHINE hMachine); + +CMAPI +CONFIGRET +WINAPI +CM_Request_Device_Eject_ExA( + IN DEVINST dnDevInst, + OUT PPNP_VETO_TYPE pVetoType, + OUT LPSTR pszVetoName, + IN ULONG ulNameLength, + IN ULONG ulFlags, + IN HMACHINE hMachine); + +CMAPI +CONFIGRET +WINAPI +CM_Request_Device_EjectW( + IN DEVINST dnDevInst, + OUT PPNP_VETO_TYPE pVetoType, + OUT LPWSTR pszVetoName, + IN ULONG ulNameLength, + IN ULONG ulFlags); + +#ifdef UNICODE +#define CM_Request_Device_Eject CM_Request_Device_EjectW +#define CM_Request_Device_Eject_Ex CM_Request_Device_Eject_ExW +#else +#define CM_Request_Device_Eject CM_Request_Device_EjectA +#define CM_Request_Device_Eject_Ex CM_Request_Device_Eject_ExA +#endif + +CMAPI +CONFIGRET +WINAPI +CM_Request_Eject_PC(VOID); + +CMAPI +CONFIGRET +WINAPI +CM_Request_Eject_PC_Ex( + IN HMACHINE hMachine OPTIONAL); + +CMAPI +CONFIGRET +WINAPI +CM_Run_Detection( + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Run_Detection_Ex( + IN ULONG ulFlags, + IN HMACHINE hMachine OPTIONAL); + +#if (WINVER >= _WIN32_WINNT_VISTA) + +CONFIGRET +CM_Apply_PowerScheme(VOID); + +CONFIGRET +CM_Write_UserPowerKey( + IN CONST GUID *SchemeGuid OPTIONAL, + IN CONST GUID *SubGroupOfPowerSettingsGuid OPTIONAL, + IN CONST GUID *PowerSettingGuid OPTIONAL, + IN ULONG AccessFlags, + IN ULONG Type, + IN UCHAR *Buffer, + IN DWORD BufferSize, + OUT PDWORD Error); + +CONFIGRET +CM_Set_ActiveScheme( + IN CONST GUID *SchemeGuid, + OUT PDWORD Error); + +CONFIGRET +CM_Restore_DefaultPowerScheme( + IN CONST GUID *SchemeGuid, + OUT PDWORD Error); + +CONFIGRET +CM_RestoreAll_DefaultPowerSchemes( + OUT PDWORD Error); + +CONFIGRET +CM_Duplicate_PowerScheme( + IN CONST GUID *SourceSchemeGuid, + IN GUID **DestinationSchemeGuid, + OUT PDWORD Error); + +CONFIGRET +CM_Delete_PowerScheme( + IN CONST GUID *SchemeGuid, + OUT PDWORD Error); + +CONFIGRET +CM_Import_PowerScheme( + IN LPCWSTR ImportFileNamePath, + IN OUT GUID **DestinationSchemeGuid, + OUT PDWORD Error); + +#endif /* (WINVER >= _WIN32_WINNT_VISTA) */ + +CMAPI +CONFIGRET +WINAPI +CM_Set_DevNode_Problem( + IN DEVINST dnDevInst, + IN ULONG ulProblem, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Set_DevNode_Problem_Ex( + IN DEVINST dnDevInst, + IN ULONG ulProblem, + IN ULONG ulFlags, + IN HMACHINE hMachine); + +#define CM_Set_DevInst_Problem CM_Set_DevNode_Problem +#define CM_Set_DevInst_Problem_Ex CM_Set_DevNode_Problem_Ex + +CMAPI +CONFIGRET +WINAPI +CM_Unregister_Device_InterfaceA( + IN LPCSTR pszDeviceInterface, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Unregister_Device_InterfaceW( + IN LPCWSTR pszDeviceInterface, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Unregister_Device_Interface_ExA( + IN LPCSTR pszDeviceInterface, + IN ULONG ulFlags, + IN HMACHINE hMachine OPTIONAL); + +CMAPI +CONFIGRET +WINAPI +CM_Unregister_Device_Interface_ExW( + IN LPCWSTR pszDeviceInterface, + IN ULONG ulFlags, + IN HMACHINE hMachine OPTIONAL); + +#ifdef UNICODE +#define CM_Unregister_Device_Interface CM_Unregister_Device_InterfaceW +#define CM_Unregister_Device_Interface_Ex CM_Unregister_Device_Interface_ExW +#else +#define CM_Unregister_Device_Interface CM_Unregister_Device_InterfaceA +#define CM_Unregister_Device_Interface_Ex CM_Unregister_Device_Interface_ExA +#endif + +CMAPI +CONFIGRET +WINAPI +CM_Register_Device_Driver( + IN DEVINST dnDevInst, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Register_Device_Driver_Ex( + IN DEVINST dnDevInst, + IN ULONG ulFlags, + IN HMACHINE hMachine OPTIONAL); + +CMAPI +CONFIGRET +WINAPI +CM_Remove_SubTree( + IN DEVINST dnAncestor, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Remove_SubTree_Ex( + IN DEVINST dnAncestor, + IN ULONG ulFlags, + IN HMACHINE hMachine OPTIONAL); + +CMAPI +CONFIGRET +WINAPI +CM_Set_DevNode_Registry_PropertyA( + IN DEVINST dnDevInst, + IN ULONG ulProperty, + IN PCVOID Buffer OPTIONAL, + IN ULONG ulLength, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Set_DevNode_Registry_PropertyW( + IN DEVINST dnDevInst, + IN ULONG ulProperty, + IN PCVOID Buffer OPTIONAL, + IN ULONG ulLength, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Set_DevNode_Registry_Property_ExA( + IN DEVINST dnDevInst, + IN ULONG ulProperty, + IN PCVOID Buffer OPTIONAL, + IN ULONG ulLength, + IN ULONG ulFlags, + IN HMACHINE hMachine); + +CMAPI +CONFIGRET +WINAPI +CM_Set_DevNode_Registry_Property_ExW( + IN DEVINST dnDevInst, + IN ULONG ulProperty, + IN PCVOID Buffer OPTIONAL, + IN ULONG ulLength, + IN ULONG ulFlags, + IN HMACHINE hMachine); + +#define CM_Set_DevInst_Registry_PropertyW CM_Set_DevNode_Registry_PropertyW +#define CM_Set_DevInst_Registry_PropertyA CM_Set_DevNode_Registry_PropertyA +#define CM_Set_DevInst_Registry_Property_ExW CM_Set_DevNode_Registry_Property_ExW +#define CM_Set_DevInst_Registry_Property_ExA CM_Set_DevNode_Registry_Property_ExA + +#ifdef UNICODE +#define CM_Set_DevInst_Registry_Property CM_Set_DevNode_Registry_PropertyW +#define CM_Set_DevInst_Registry_Property_Ex CM_Set_DevNode_Registry_Property_ExW +#define CM_Set_DevNode_Registry_Property CM_Set_DevNode_Registry_PropertyW +#define CM_Set_DevNode_Registry_Property_Ex CM_Set_DevNode_Registry_Property_ExW +#else +#define CM_Set_DevInst_Registry_Property CM_Set_DevNode_Registry_PropertyA +#define CM_Set_DevInst_Registry_Property_Ex CM_Set_DevNode_Registry_Property_ExA +#define CM_Set_DevNode_Registry_Property CM_Set_DevNode_Registry_PropertyA +#define CM_Set_DevNode_Registry_Property_Ex CM_Set_DevNode_Registry_Property_ExA +#endif /* UNICODE */ + +CMAPI +CONFIGRET +WINAPI +CM_Set_HW_Prof( + IN ULONG ulHardwareProfile, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Set_HW_Prof_Ex( + IN ULONG ulHardwareProfile, + IN ULONG ulFlags, + IN HMACHINE hMachine); + +CMAPI +CONFIGRET +WINAPI +CM_Set_HW_Prof_FlagsA( + IN DEVINSTID_A szDevInstName, + IN ULONG ulConfig, + IN ULONG ulValue, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Set_HW_Prof_FlagsW( + IN DEVINSTID_W szDevInstName, + IN ULONG ulConfig, + IN ULONG ulValue, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Set_HW_Prof_Flags_ExA( + IN DEVINSTID_A szDevInstName, + IN ULONG ulConfig, + IN ULONG ulValue, + IN ULONG ulFlags, + IN HMACHINE hMachine); + +CMAPI +CONFIGRET +WINAPI +CM_Set_HW_Prof_Flags_ExW( + IN DEVINSTID_W szDevInstName, + IN ULONG ulConfig, + IN ULONG ulValue, + IN ULONG ulFlags, + IN HMACHINE hMachine); + +#ifdef UNICODE +#define CM_Set_HW_Prof_Flags CM_Set_HW_Prof_FlagsW +#define CM_Set_HW_Prof_Flags_Ex CM_Set_HW_Prof_Flags_ExW +#else +#define CM_Set_HW_Prof_Flags CM_Set_HW_Prof_FlagsA +#define CM_Set_HW_Prof_Flags_Ex CM_Set_HW_Prof_Flags_ExA +#endif /* UNICODE */ + +CMAPI +CONFIGRET +WINAPI +CM_Setup_DevNode( + IN DEVINST dnDevInst, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Setup_DevNode_Ex( + IN DEVINST dnDevInst, + IN ULONG ulFlags, + IN HMACHINE hMachine OPTIONAL); + +#define CM_Setup_DevInst CM_Setup_DevNode +#define CM_Setup_DevInst_Ex CM_Setup_DevNode_Ex + +CMAPI +CONFIGRET +WINAPI +CM_Test_Range_Available( + IN DWORDLONG ullStartValue, + IN DWORDLONG ullEndValue, + IN RANGE_LIST rlh, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Uninstall_DevNode( + IN DEVINST dnPhantom, + IN ULONG ulFlags); + +CMAPI +CONFIGRET +WINAPI +CM_Uninstall_DevNode_Ex( + IN DEVINST dnPhantom, + IN ULONG ulFlags, + IN HMACHINE hMachine); + +#define CM_Uninstall_DevInst CM_Uninstall_DevNode +#define CM_Uninstall_DevInst_Ex CM_Uninstall_DevNode_Ex + + +#if (WINVER >= _WIN32_WINNT_WIN2K) + +#define CM_WaitNoPendingInstallEvents CMP_WaitNoPendingInstallEvents + +CMAPI +DWORD +WINAPI +CMP_WaitNoPendingInstallEvents( + IN DWORD dwTimeout); + +#endif /* (WINVER >= _WIN32_WINNT_WIN2K) */ + +#ifdef __cplusplus +} +#endif diff --git a/reactos/include/psdk/winbase.h b/reactos/include/psdk/winbase.h index b7a5fd2776d..6b38dacb365 100644 --- a/reactos/include/psdk/winbase.h +++ b/reactos/include/psdk/winbase.h @@ -1505,14 +1505,14 @@ DWORD WINAPI GetFirmwareEnvironmentVariableA(LPCSTR,LPCSTR,PVOID,DWORD); DWORD WINAPI GetFirmwareEnvironmentVariableW(LPCWSTR,LPCWSTR,PVOID,DWORD); #endif BOOL WINAPI FlushFileBuffers(HANDLE); -BOOL WINAPI FlushInstructionCache(HANDLE,PCVOID,DWORD); -BOOL WINAPI FlushViewOfFile(PCVOID,SIZE_T); +BOOL WINAPI FlushInstructionCache(HANDLE,LPCVOID,SIZE_T); +BOOL WINAPI FlushViewOfFile(LPCVOID,SIZE_T); DWORD WINAPI FlsAlloc(PFLS_CALLBACK_FUNCTION); PVOID WINAPI FlsGetValue(DWORD); BOOL WINAPI FlsSetValue(DWORD,PVOID); BOOL WINAPI FlsFree(DWORD); -DWORD WINAPI FormatMessageA(DWORD,PCVOID,DWORD,DWORD,LPSTR,DWORD,va_list*); -DWORD WINAPI FormatMessageW(DWORD,PCVOID,DWORD,DWORD,LPWSTR,DWORD,va_list*); +DWORD WINAPI FormatMessageA(DWORD,LPCVOID,DWORD,DWORD,LPSTR,DWORD,va_list*); +DWORD WINAPI FormatMessageW(DWORD,LPCVOID,DWORD,DWORD,LPWSTR,DWORD,va_list*); BOOL WINAPI FreeEnvironmentStringsA(LPSTR); BOOL WINAPI FreeEnvironmentStringsW(LPWSTR); BOOL WINAPI FreeLibrary(HMODULE); @@ -1763,7 +1763,7 @@ UINT WINAPI GlobalFlags(HGLOBAL); /* Obsolete: Has no effect. */ HGLOBAL WINAPI GlobalFree(HGLOBAL); UINT WINAPI GlobalGetAtomNameA(ATOM,LPSTR,int); UINT WINAPI GlobalGetAtomNameW(ATOM,LPWSTR,int); -HGLOBAL WINAPI GlobalHandle(PCVOID); +HGLOBAL WINAPI GlobalHandle(LPCVOID); LPVOID WINAPI GlobalLock(HGLOBAL); VOID WINAPI GlobalMemoryStatus(LPMEMORYSTATUS); #if (_WIN32_WINNT >= 0x0500) @@ -1789,9 +1789,9 @@ PVOID WINAPI HeapReAlloc(HANDLE,DWORD,PVOID,DWORD); #if (_WIN32_WINNT >= 0x0501) BOOL WINAPI HeapSetInformation(HANDLE,HEAP_INFORMATION_CLASS,PVOID,SIZE_T); #endif -DWORD WINAPI HeapSize(HANDLE,DWORD,PCVOID); +SIZE_T WINAPI HeapSize(HANDLE,DWORD,LPCVOID); BOOL WINAPI HeapUnlock(HANDLE); -BOOL WINAPI HeapValidate(HANDLE,DWORD,PCVOID); +BOOL WINAPI HeapValidate(HANDLE,DWORD,LPCVOID); BOOL WINAPI HeapWalk(HANDLE,LPPROCESS_HEAP_ENTRY); BOOL WINAPI ImpersonateAnonymousToken(HANDLE); BOOL WINAPI ImpersonateLoggedOnUser(HANDLE); @@ -1948,9 +1948,9 @@ InterlockedOr_Inline(IN OUT volatile LONG *Target, #endif /* __INTERLOCKED_DECLARED */ BOOL WINAPI IsBadCodePtr(FARPROC); -BOOL WINAPI IsBadHugeReadPtr(PCVOID,UINT_PTR); +BOOL WINAPI IsBadHugeReadPtr(CONST VOID*,UINT_PTR); BOOL WINAPI IsBadHugeWritePtr(PVOID,UINT_PTR); -BOOL WINAPI IsBadReadPtr(PCVOID,UINT_PTR); +BOOL WINAPI IsBadReadPtr(CONST VOID*,UINT_PTR); BOOL WINAPI IsBadStringPtrA(LPCSTR,UINT_PTR); BOOL WINAPI IsBadStringPtrW(LPCWSTR,UINT_PTR); BOOL WINAPI IsBadWritePtr(PVOID,UINT_PTR); @@ -1960,7 +1960,7 @@ BOOL WINAPI IsProcessInJob(HANDLE,HANDLE,PBOOL); #endif BOOL WINAPI IsProcessorFeaturePresent(DWORD); BOOL WINAPI IsSystemResumeAutomatic(void); -BOOL WINAPI IsTextUnicode(PCVOID,int,LPINT); +BOOL WINAPI IsTextUnicode(CONST VOID*,int,LPINT); #if (_WIN32_WINNT >= 0x0600) BOOL WINAPI IsThreadAFiber(VOID); #endif @@ -2100,7 +2100,7 @@ BOOL WINAPI ReadEventLogW(HANDLE,DWORD,DWORD,PVOID,DWORD,DWORD *,DWORD *); BOOL WINAPI ReadFile(HANDLE,PVOID,DWORD,PDWORD,LPOVERLAPPED); BOOL WINAPI ReadFileEx(HANDLE,PVOID,DWORD,LPOVERLAPPED,LPOVERLAPPED_COMPLETION_ROUTINE); BOOL WINAPI ReadFileScatter(HANDLE,FILE_SEGMENT_ELEMENT*,DWORD,LPDWORD,LPOVERLAPPED); -BOOL WINAPI ReadProcessMemory(HANDLE,PCVOID,PVOID,SIZE_T,PSIZE_T); +BOOL WINAPI ReadProcessMemory(HANDLE,LPCVOID,LPVOID,SIZE_T,PSIZE_T); #if (_WIN32_WINNT >= 0x0600) VOID WINAPI RecoveryFinished(BOOL); HRESULT WINAPI RecoveryInProgress(OUT PBOOL); @@ -2301,8 +2301,8 @@ VOID WINAPI WakeConditionVariable(PCONDITION_VARIABLE); VOID WINAPI WakeAllConditionVariable(PCONDITION_VARIABLE); #endif BOOL WINAPI WinLoadTrustProvider(GUID*); -BOOL WINAPI WriteFile(HANDLE,PCVOID,DWORD,PDWORD,LPOVERLAPPED); -BOOL WINAPI WriteFileEx(HANDLE,PCVOID,DWORD,LPOVERLAPPED,LPOVERLAPPED_COMPLETION_ROUTINE); +BOOL WINAPI WriteFile(HANDLE,LPCVOID,DWORD,LPDWORD,LPOVERLAPPED); +BOOL WINAPI WriteFileEx(HANDLE,LPCVOID,DWORD,LPOVERLAPPED,LPOVERLAPPED_COMPLETION_ROUTINE); BOOL WINAPI WriteFileGather(HANDLE,FILE_SEGMENT_ELEMENT*,DWORD,LPDWORD,LPOVERLAPPED); BOOL WINAPI WritePrivateProfileSectionA(LPCSTR,LPCSTR,LPCSTR); BOOL WINAPI WritePrivateProfileSectionW(LPCWSTR,LPCWSTR,LPCWSTR); diff --git a/reactos/include/psdk/wincon.h b/reactos/include/psdk/wincon.h index f2dd6fa6f95..a7916b46834 100644 --- a/reactos/include/psdk/wincon.h +++ b/reactos/include/psdk/wincon.h @@ -223,8 +223,8 @@ BOOL WINAPI SetConsoleTextAttribute(HANDLE,WORD); BOOL WINAPI SetConsoleTitleA(LPCSTR); BOOL WINAPI SetConsoleTitleW(LPCWSTR); BOOL WINAPI SetConsoleWindowInfo(HANDLE,BOOL,const SMALL_RECT*); -BOOL WINAPI WriteConsoleA(HANDLE,PCVOID,DWORD,PDWORD,PVOID); -BOOL WINAPI WriteConsoleW(HANDLE,PCVOID,DWORD,PDWORD,PVOID); +BOOL WINAPI WriteConsoleA(HANDLE,CONST VOID*,DWORD,LPDWORD,LPVOID); +BOOL WINAPI WriteConsoleW(HANDLE,CONST VOID*,DWORD,LPDWORD,LPVOID); BOOL WINAPI WriteConsoleInputA(HANDLE,const INPUT_RECORD*,DWORD,PDWORD); BOOL WINAPI WriteConsoleInputW(HANDLE,const INPUT_RECORD*,DWORD,PDWORD); BOOL WINAPI WriteConsoleOutputA(HANDLE,const CHAR_INFO*,COORD,COORD,PSMALL_RECT); diff --git a/reactos/include/psdk/windef.h b/reactos/include/psdk/windef.h index 97ccf73368a..bcd7c4dcd76 100644 --- a/reactos/include/psdk/windef.h +++ b/reactos/include/psdk/windef.h @@ -305,7 +305,7 @@ typedef long *LPLONG; typedef int *LPLONG; #endif typedef DWORD *PDWORD,*LPDWORD; -typedef CONST void *PCVOID,*LPCVOID; +typedef CONST void *LPCVOID; typedef unsigned int UINT,*PUINT,*LPUINT; diff --git a/reactos/include/psdk/wingdi.h b/reactos/include/psdk/wingdi.h index f67e77ec4e6..edfbae652f3 100644 --- a/reactos/include/psdk/wingdi.h +++ b/reactos/include/psdk/wingdi.h @@ -2900,7 +2900,7 @@ HENHMETAFILE WINAPI CopyEnhMetaFileA(HENHMETAFILE,LPCSTR); HENHMETAFILE WINAPI CopyEnhMetaFileW(HENHMETAFILE,LPCWSTR); HMETAFILE WINAPI CopyMetaFileA(HMETAFILE,LPCSTR); HMETAFILE WINAPI CopyMetaFileW(HMETAFILE,LPCWSTR); -HBITMAP WINAPI CreateBitmap(int,int,UINT,UINT,PCVOID); +HBITMAP WINAPI CreateBitmap(int,int,UINT,UINT,CONST VOID*); HBITMAP WINAPI CreateBitmapIndirect(const BITMAP*); HBRUSH WINAPI CreateBrushIndirect(const LOGBRUSH*); HCOLORSPACE WINAPI CreateColorSpaceA(LPLOGCOLORSPACEA); @@ -2909,9 +2909,9 @@ HBITMAP WINAPI CreateCompatibleBitmap(HDC,int,int); HDC WINAPI CreateCompatibleDC(HDC); HDC WINAPI CreateDCA(LPCSTR,LPCSTR,LPCSTR,const DEVMODEA*); HDC WINAPI CreateDCW(LPCWSTR,LPCWSTR,LPCWSTR,const DEVMODEW*); -HBITMAP WINAPI CreateDIBitmap(HDC,const BITMAPINFOHEADER*,DWORD,PCVOID,const BITMAPINFO*,UINT); +HBITMAP WINAPI CreateDIBitmap(HDC,CONST BITMAPINFOHEADER*,DWORD,CONST VOID*,CONST BITMAPINFO*,UINT); HBRUSH WINAPI CreateDIBPatternBrush(HGLOBAL,UINT); -HBRUSH WINAPI CreateDIBPatternBrushPt(PCVOID,UINT); +HBRUSH WINAPI CreateDIBPatternBrushPt(CONST VOID*,UINT); HBITMAP WINAPI CreateDIBSection(HDC,const BITMAPINFO*,UINT,PVOID*,HANDLE,DWORD); HBITMAP WINAPI CreateDiscardableBitmap(HDC,int,int); HRGN WINAPI CreateEllipticRgn(int,int,int,int); @@ -3168,7 +3168,7 @@ HGDIOBJ WINAPI SelectObject(HDC,HGDIOBJ); HPALETTE WINAPI SelectPalette(HDC,HPALETTE,BOOL); int WINAPI SetAbortProc(HDC,ABORTPROC); int WINAPI SetArcDirection(HDC,int); -LONG WINAPI SetBitmapBits(HBITMAP,LONG,PCVOID); +LONG WINAPI SetBitmapBits(HBITMAP,DWORD,CONST VOID*); BOOL WINAPI SetBitmapDimensionEx(HBITMAP,int,int,LPSIZE); COLORREF WINAPI SetBkColor(HDC,COLORREF); int WINAPI SetBkMode(HDC,int); @@ -3182,8 +3182,8 @@ COLORREF WINAPI SetDCPenColor(HDC,COLORREF); #endif BOOL WINAPI SetDeviceGammaRamp(HDC,PVOID); UINT WINAPI SetDIBColorTable(HDC,UINT,UINT,const RGBQUAD*); -int WINAPI SetDIBits(HDC,HBITMAP,UINT,UINT,PCVOID,const BITMAPINFO*,UINT); -int WINAPI SetDIBitsToDevice(HDC,int,int,DWORD,DWORD,int,int,UINT,UINT,PCVOID,const BITMAPINFO*,UINT); +int WINAPI SetDIBits(HDC,HBITMAP,UINT,UINT,CONST VOID*,CONST BITMAPINFO*,UINT); +int WINAPI SetDIBitsToDevice(HDC,int,int,DWORD,DWORD,int,int,UINT,UINT,CONST VOID*,CONST BITMAPINFO*,UINT); HENHMETAFILE WINAPI SetEnhMetaFileBits(UINT,const BYTE*); int WINAPI SetGraphicsMode(HDC,int); int WINAPI SetICMMode(HDC,int); diff --git a/reactos/include/psdk/winuser.h b/reactos/include/psdk/winuser.h index cd855588efe..bea47d14f05 100644 --- a/reactos/include/psdk/winuser.h +++ b/reactos/include/psdk/winuser.h @@ -3917,7 +3917,7 @@ int WINAPI CountClipboardFormats(void); HACCEL WINAPI CreateAcceleratorTableA(LPACCEL,int); HACCEL WINAPI CreateAcceleratorTableW(LPACCEL,int); BOOL WINAPI CreateCaret(HWND,HBITMAP,int,int); -HCURSOR WINAPI CreateCursor(HINSTANCE,int,int,int,int,PCVOID,PCVOID); +HCURSOR WINAPI CreateCursor(HINSTANCE,int,int,int,int,CONST VOID*,CONST VOID*); #if defined(_WINGDI_) && !defined(NOGDI) HDESK WINAPI CreateDesktopA(LPCSTR,LPCSTR,LPDEVMODEA,DWORD,ACCESS_MASK,LPSECURITY_ATTRIBUTES); HDESK WINAPI CreateDesktopW(LPCWSTR,LPCWSTR,LPDEVMODEW,DWORD,ACCESS_MASK,LPSECURITY_ATTRIBUTES); diff --git a/reactos/include/reactos/wine/cfgmgr32.h b/reactos/include/reactos/wine/cfgmgr32.h deleted file mode 100644 index 7837f2a485b..00000000000 --- a/reactos/include/reactos/wine/cfgmgr32.h +++ /dev/null @@ -1,373 +0,0 @@ -/* - * Copyright (C) 2005 Mike McCormack - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef _CFGMGR32_H_ -#define _CFGMGR32_H_ - -/* cfgmgr32 doesn't use the normal convention, it adds an underscore before A/W */ -#ifdef __WINESRC__ -# define DECL_WINELIB_CFGMGR32_TYPE_AW(type) /* nothing */ -#else /* __WINESRC__ */ -# define DECL_WINELIB_CFGMGR32_TYPE_AW(type) typedef WINELIB_NAME_AW(type##_) type; -#endif /* __WINESRC__ */ - -typedef DWORD CONFIGRET; -typedef HANDLE HMACHINE; -typedef HMACHINE *PHMACHINE; -typedef DWORD DEVINST; -typedef DEVINST *PDEVINST; -typedef DWORD DEVNODE; -typedef DEVNODE *PDEVNODE; -typedef ULONG REGDISPOSITION; -typedef DWORD_PTR LOG_CONF; -typedef LOG_CONF *PLOG_CONF; -typedef ULONG PRIORITY; -typedef PRIORITY *PPRIORITY; - - -typedef CHAR *DEVINSTID_A; -typedef WCHAR *DEVINSTID_W; -DECL_WINELIB_CFGMGR32_TYPE_AW(DEVINSTID) - -#define CR_SUCCESS 0x00000000 -#define CR_OUT_OF_MEMORY 0x00000002 -#define CR_INVALID_POINTER 0x00000003 -#define CR_INVALID_FLAG 0x00000004 -#define CR_INVALID_DEVNODE 0x00000005 -#define CR_INVALID_DEVINST CR_INVALID_DEVNODE -#define CR_INVALID_LOG_CONF 0x00000007 -#define CR_NO_SUCH_DEVNODE 0x0000000D -#define CR_NO_SUCH_DEVINST CR_NO_SUCH_DEVNODE -#define CR_FAILURE 0x00000013 -#define CR_BUFFER_SMALL 0x0000001A -#define CR_REGISTRY_ERROR 0x0000001D -#define CR_INVALID_DEVICE_ID 0x0000001E -#define CR_INVALID_DATA 0x0000001F -#define CR_NO_SUCH_VALUE 0x00000025 -#define CR_INVALID_PRIORITY 0x00000027 -#define CR_NO_SUCH_REGISTRY_KEY 0x0000002E -#define CR_INVALID_MACHINENAME 0x0000002F -#define CR_ACCESS_DENIED 0x00000033 -#define CR_CALL_NOT_IMPLEMENTED 0x00000034 -#define CR_INVALID_PROPERTY 0x00000035 - -#define MAX_CLASS_NAME_LEN 32 -#define MAX_GUID_STRING_LEN 39 -#define MAX_PROFILE_LEN 80 -#define MAX_DEVICE_ID_LEN 200 -#define MAX_DEVNODE_ID_LEN MAX_DEVICE_ID_LEN - -/* Disposition values for CM_Open_Class_Key[_Ex] */ -#define RegDisposition_OpenAlways 0x00000000 -#define RegDisposition_OpenExisting 0x00000001 -#define RegDisposition_Bits 0x00000001 - -/* ulFlags for CM_Add_ID[_Ex] */ -#define CM_ADD_ID_HARDWARE 0x00000000 -#define CM_ADD_ID_COMPATIBLE 0x00000001 -#define CM_ADD_ID_BITS 0x00000001 - -/* ulFlags for CM_Open_Class_Key[_Ex] */ -#define CM_OPEN_CLASS_KEY_INSTALLER 0x00000000 -#define CM_OPEN_CLASS_KEY_INTERFACE 0x00000001 -#define CM_OPEN_CLASS_KEY_BITS 0x00000001 - -/* ulFlags for CM_Locate_DevNode[_Ex] */ -#define CM_LOCATE_DEVNODE_NORMAL 0x00000000 -#define CM_LOCATE_DEVNODE_PHANTOM 0x00000001 -#define CM_LOCATE_DEVNODE_CANCELREMOVE 0x00000002 -#define CM_LOCATE_DEVNODE_NOVALIDATION 0x00000004 -#define CM_LOCATE_DEVNODE_BITS 0x00000007 - -#define CM_LOCATE_DEVINST_NORMAL CM_LOCATE_DEVNODE_NORMAL -#define CM_LOCATE_DEVINST_PHANTOM CM_LOCATE_DEVNODE_PHANTOM -#define CM_LOCATE_DEVINST_CANCELREMOVE CM_LOCATE_DEVNODE_CANCELREMOVE -#define CM_LOCATE_DEVINST_NOVALIDATION CM_LOCATE_DEVNODE_NOVALIDATION -#define CM_LOCATE_DEVINST_BITS CM_LOCATE_DEVNODE_BITS - -/* ulFlags for CM_Set_DevNode_Problem[_Ex] */ -#define CM_SET_DEVNODE_PROBLEM_NORMAL 0x00000000 -#define CM_SET_DEVNODE_PROBLEM_OVERRIDE 0x00000001 -#define CM_SET_DEVNODE_PROBLEM_BITS 0x00000001 - -#define CM_SET_DEVINST_PROBLEM_NORMAL CM_SET_DEVNODE_PROBLEM_NORMAL -#define CM_SET_DEVINST_PROBLEM_OVERRIDE CM_SET_DEVNODE_PROBLEM_OVERRIDE -#define CM_SET_DEVINST_PROBLEM_BITS CM_SET_DEVNODE_PROBLEM_BITS - -/* Properties for CM_Get/Set_DevNode_Registry_Property[_Ex]A/W */ -#define CM_DRP_DEVICEDESC 0x00000001 -#define CM_DRP_HARDWAREID 0x00000002 -#define CM_DRP_COMPATIBLEIDS 0x00000003 -#define CM_DRP_UNUSED0 0x00000004 -#define CM_DRP_SERVICE 0x00000005 -#define CM_DRP_UNUSED1 0x00000006 -#define CM_DRP_UNUSED2 0x00000007 -#define CM_DRP_CLASS 0x00000008 -#define CM_DRP_CLASSGUID 0x00000009 -#define CM_DRP_DRIVER 0x0000000A -#define CM_DRP_CONFIGFLAGS 0x0000000B -#define CM_DRP_MFG 0x0000000C -#define CM_DRP_FRIENDLYNAME 0x0000000D -#define CM_DRP_LOCATION_INFORMATION 0x0000000E -#define CM_DRP_PHYSICAL_DEVICE_OBJECT_NAME 0x0000000F -#define CM_DRP_CAPABILITIES 0x00000010 -#define CM_DRP_UI_NUMBER 0x00000011 -#define CM_DRP_UPPERFILTERS 0x00000012 -#define CM_DRP_LOWERFILTERS 0x00000013 -#define CM_DRP_BUSTYPEGUID 0x00000014 -#define CM_DRP_LEGACYBUSTYPE 0x00000015 -#define CM_DRP_BUSNUMBER 0x00000016 -#define CM_DRP_ENUMERATOR_NAME 0x00000017 - -#define CM_DRP_MIN 0x00000001 -#define CM_DRP_MAX 0x00000017 - -/* ulFlags for CM_Delete_Class_Key[_Ex] */ -#define CM_DELETE_CLASS_ONLY 0x00000000 -#define CM_DELETE_CLASS_SUBKEYS 0x00000001 -#define CM_DELETE_CLASS_BITS 0x00000001 - -/* ulFlags for CM_Get_Device_ID_List and CM_Get_Device_ID_List_Size */ -#define CM_GETIDLIST_FILTER_NONE (0x00000000) -#define CM_GETIDLIST_FILTER_ENUMERATOR (0x00000001) -#define CM_GETIDLIST_FILTER_SERVICE (0x00000002) -#define CM_GETIDLIST_FILTER_EJECTRELATIONS (0x00000004) -#define CM_GETIDLIST_FILTER_REMOVALRELATIONS (0x00000008) -#define CM_GETIDLIST_FILTER_POWERRELATIONS (0x00000010) -#define CM_GETIDLIST_FILTER_BUSRELATIONS (0x00000020) -#define CM_GETIDLIST_DONOTGENERATE (0x10000040) -#define CM_GETIDLIST_FILTER_BITS (0x1000007F) - -/* ulFlags for CM_Reenumerate_DevNode[_Ex] */ -#define CM_REENUMERATE_NORMAL 0x00000000 -#define CM_REENUMERATE_SYNCHRONOUS 0x00000001 -#define CM_REENUMERATE_RETRY_INSTALLATION 0x00000002 -#define CM_REENUMERATE_ASYNCHRONOUS 0x00000004 -#define CM_REENUMERATE_BITS 0x00000007 - -/* ulFlags for CM_Run_Detection[_Ex] */ -#define CM_DETECT_NEW_PROFILE 0x00000001 -#define CM_DETECT_CRASHED 0x00000002 -#define CM_DETECT_HWPROF_FIRST_BOOT 0x00000004 -#define CM_DETECT_RUN 0x80000000 -#define CM_DETECT_BITS 0x80000007 - -/* ulFlags for CM_Setup_DevInst[_Ex] */ -#define CM_SETUP_DEVNODE_READY 0x00000000 -#define CM_SETUP_DEVINST_READY CM_SETUP_DEVNODE_READY -#define CM_SETUP_DOWNLOAD 0x00000001 -#define CM_SETUP_WRITE_LOG_CONFS 0x00000002 -#define CM_SETUP_PROP_CHANGE 0x00000003 -#define CM_SETUP_DEVNODE_RESET 0x00000004 -#define CM_SETUP_DEVINST_RESET CM_SETUP_DEVNODE_RESET -#define CM_SETUP_BITS 0x00000007 - -/* ulFlags for CM_Create_DevNode[_Ex]A/W */ -#define CM_CREATE_DEVNODE_NORMAL 0x00000000 -#define CM_CREATE_DEVNODE_NO_WAIT_INSTALL 0x00000001 -#define CM_CREATE_DEVNODE_PHANTOM 0x00000002 -#define CM_CREATE_DEVNODE_GENERATE_ID 0x00000004 -#define CM_CREATE_DEVNODE_DO_NOT_INSTALL 0x00000008 -#define CM_CREATE_DEVNODE_BITS 0x0000000F - -#define CM_CREATE_DEVINST_NORMAL CM_CREATE_DEVNODE_NORMAL -#define CM_CREATE_DEVINST_NO_WAIT_INSTALL CM_CREATE_DEVNODE_NO_WAIT_INSTALL -#define CM_CREATE_DEVINST_PHANTOM CM_CREATE_DEVNODE_PHANTOM -#define CM_CREATE_DEVINST_GENERATE_ID CM_CREATE_DEVNODE_GENERATE_ID -#define CM_CREATE_DEVINST_DO_NOT_INSTALL CM_CREATE_DEVNODE_DO_NOT_INSTALL -#define CM_CREATE_DEVINST_BITS CM_CREATE_DEVNODE_BITS - -/* ulFlags for CM_Set_HW_Prof_Flags[_Ex]A/W */ -#define CM_SET_HW_PROF_FLAGS_UI_NOT_OK 0x00000001 -#define CM_SET_HW_PROF_FLAGS_BITS 0x00000001 - -/* ulFlags for Log_Conf functions */ -#define BASIC_LOG_CONF 0x00000000 -#define FILTERED_LOG_CONF 0x00000001 -#define ALLOC_LOG_CONF 0x00000002 -#define BOOT_LOG_CONF 0x00000003 -#define FORCED_LOG_CONF 0x00000004 -#define OVERRIDE_LOG_CONF 0x00000005 -#define NUM_LOG_CONF 0x00000006 -#define LOG_CONF_BITS 0x00000007 - -#define PRIORITY_EQUAL_FIRST 0x00000008 -#define PRIORITY_EQUAL_LAST 0x00000000 -#define PRIORITY_BIT 0x00000008 - -#define CMP_MAGIC 0x01234567 - - -CONFIGRET WINAPI CMP_Init_Detection( DWORD ); -CONFIGRET WINAPI CMP_Report_LogOn( DWORD, DWORD ); - -CONFIGRET WINAPI CM_Add_Empty_Log_Conf( PLOG_CONF, DEVINST, PRIORITY, ULONG ); -CONFIGRET WINAPI CM_Add_Empty_Log_Conf_Ex( PLOG_CONF, DEVINST, PRIORITY, ULONG, HMACHINE ); -CONFIGRET WINAPI CM_Add_IDA( DEVINST, PSTR, ULONG ); -CONFIGRET WINAPI CM_Add_IDW( DEVINST, PWSTR, ULONG ); -#define CM_Add_ID WINELIB_NAME_AW(CM_Add_ID) -CONFIGRET WINAPI CM_Add_ID_ExA( DEVINST, PSTR, ULONG, HMACHINE ); -CONFIGRET WINAPI CM_Add_ID_ExW( DEVINST, PWSTR, ULONG, HMACHINE ); -#define CM_Add_ID_Ex WINELIB_NAME_AW(CM_Add_ID_Ex) -CONFIGRET WINAPI CM_Connect_MachineA( PCSTR, PHMACHINE ); -CONFIGRET WINAPI CM_Connect_MachineW( PCWSTR, PHMACHINE ); -#define CM_Connect_Machine WINELIB_NAME_AW(CM_Connect_Machine) -CONFIGRET WINAPI CM_Create_DevNodeA( PDEVINST, DEVINSTID_A, DEVINST, ULONG ); -CONFIGRET WINAPI CM_Create_DevNodeW( PDEVINST, DEVINSTID_W, DEVINST, ULONG ); -#define CM_Create_DevNode WINELIB_NAME_AW(CM_Create_DevNode) -CONFIGRET WINAPI CM_Create_DevNode_ExA( PDEVINST, DEVINSTID_A, DEVINST, ULONG, HANDLE ); -CONFIGRET WINAPI CM_Create_DevNode_ExW( PDEVINST, DEVINSTID_W, DEVINST, ULONG, HANDLE ); -#define CM_Create_DevNode_Ex WINELIB_NAME_AW(CM_Create_DevNode_Ex) -CONFIGRET WINAPI CM_Delete_Class_Key( LPGUID, ULONG ); -CONFIGRET WINAPI CM_Delete_Class_Key_Ex( LPGUID, ULONG, HANDLE ); -CONFIGRET WINAPI CM_Delete_DevNode_Key( DEVNODE, ULONG, ULONG ); -CONFIGRET WINAPI CM_Delete_DevNode_Key_Ex( DEVNODE, ULONG, ULONG, HANDLE ); -CONFIGRET WINAPI CM_Disable_DevNode( DEVINST, ULONG ); -CONFIGRET WINAPI CM_Disable_DevNode_Ex( DEVINST, ULONG, HMACHINE ); -CONFIGRET WINAPI CM_Disconnect_Machine( HMACHINE ); -CONFIGRET WINAPI CM_Enable_DevNode( DEVINST, ULONG ); -CONFIGRET WINAPI CM_Enable_DevNode_Ex( DEVINST, ULONG, HMACHINE ); -CONFIGRET WINAPI CM_Enumerate_Classes( ULONG, LPGUID, ULONG ); -CONFIGRET WINAPI CM_Enumerate_Classes_Ex( ULONG, LPGUID, ULONG, HMACHINE ); -CONFIGRET WINAPI CM_Enumerate_EnumeratorsA( ULONG, PCHAR, PULONG, ULONG ); -CONFIGRET WINAPI CM_Enumerate_EnumeratorsW( ULONG, PWCHAR, PULONG, ULONG ); -#define CM_Enumerate_Enumerators WINELIB_NAME_AW(CM_Enumerate_Enumerators) -CONFIGRET WINAPI CM_Enumerate_Enumerators_ExA( ULONG, PCHAR, PULONG, ULONG, HMACHINE ); -CONFIGRET WINAPI CM_Enumerate_Enumerators_ExW( ULONG, PWCHAR, PULONG, ULONG, HMACHINE ); -#define CM_Enumerate_Enumerators_Ex WINELIB_NAME_AW(CM_Enumerate_Enumerators_Ex) -CONFIGRET WINAPI CM_Free_Log_Conf( LOG_CONF, ULONG ); -CONFIGRET WINAPI CM_Free_Log_Conf_Ex( LOG_CONF, ULONG, HMACHINE ); -CONFIGRET WINAPI CM_Free_Log_Conf_Handle( LOG_CONF ); -CONFIGRET WINAPI CM_Get_Child( PDEVINST, DEVINST, ULONG ); -CONFIGRET WINAPI CM_Get_Child_Ex( PDEVINST, DEVINST, ULONG, HMACHINE ); -CONFIGRET WINAPI CM_Get_Class_Key_NameA( LPGUID, LPSTR, PULONG, ULONG ); -CONFIGRET WINAPI CM_Get_Class_Key_NameW( LPGUID, LPWSTR, PULONG, ULONG ); -#define CM_Get_Class_Key_Name WINELIB_NAME_AW(CM_Get_Class_Key_Name) -CONFIGRET WINAPI CM_Get_Class_Key_Name_ExA( LPGUID, LPSTR, PULONG, ULONG, HMACHINE ); -CONFIGRET WINAPI CM_Get_Class_Key_Name_ExW( LPGUID, LPWSTR, PULONG, ULONG, HMACHINE ); -#define CM_Get_Class_Key_Name_Ex WINELIB_NAME_AW(CM_Get_Class_Key_Name_Ex) -CONFIGRET WINAPI CM_Get_Class_NameA( LPGUID, PCHAR, PULONG, ULONG ); -CONFIGRET WINAPI CM_Get_Class_NameW( LPGUID, PWCHAR, PULONG, ULONG ); -#define CM_Get_Class_Name WINELIB_NAME_AW(CM_Get_Class_Name) -CONFIGRET WINAPI CM_Get_Class_Name_ExA( LPGUID, PCHAR, PULONG, ULONG, HMACHINE ); -CONFIGRET WINAPI CM_Get_Class_Name_ExW( LPGUID, PWCHAR, PULONG, ULONG, HMACHINE ); -#define CM_Get_Class_Name_Ex WINELIB_NAME_AW(CM_Get_Class_Name_Ex) -CONFIGRET WINAPI CM_Get_Depth( PULONG, DEVINST, ULONG ); -CONFIGRET WINAPI CM_Get_Depth_Ex( PULONG, DEVINST, ULONG, HMACHINE ); -CONFIGRET WINAPI CM_Get_DevNode_Registry_PropertyA( DEVINST, ULONG, PULONG, PVOID, PULONG, ULONG ); -CONFIGRET WINAPI CM_Get_DevNode_Registry_PropertyW( DEVINST, ULONG, PULONG, PVOID, PULONG, ULONG ); -#define CM_Get_DevNode_Registry_Property WINELIB_NAME_AW(CM_Get_DevNode_Registry_Property) -CONFIGRET WINAPI CM_Get_DevNode_Registry_Property_ExA( DEVINST, ULONG, PULONG, PVOID, PULONG, ULONG, HMACHINE ); -CONFIGRET WINAPI CM_Get_DevNode_Registry_Property_ExW( DEVINST, ULONG, PULONG, PVOID, PULONG, ULONG, HMACHINE ); -#define CM_Get_DevNode_Registry_Property_Ex WINELIB_NAME_AW(CM_Get_DevNode_Registry_Property_Ex) -CONFIGRET WINAPI CM_Get_DevNode_Status( PULONG, PULONG, DEVINST, ULONG ); -CONFIGRET WINAPI CM_Get_DevNode_Status_Ex( PULONG, PULONG, DEVINST, ULONG, HMACHINE ); -CONFIGRET WINAPI CM_Get_Device_IDA( DEVINST, PCHAR, ULONG, ULONG ); -CONFIGRET WINAPI CM_Get_Device_IDW( DEVINST, PWCHAR, ULONG, ULONG ); -#define CM_Get_Device_ID WINELIB_NAME_AW(CM_Get_Device_ID) -CONFIGRET WINAPI CM_Get_Device_ID_ExW( DEVINST, PWCHAR, ULONG, ULONG, HMACHINE ); -CONFIGRET WINAPI CM_Get_Device_ID_ExA( DEVINST, PCHAR, ULONG, ULONG, HMACHINE ); -#define CM_Get_Device_ID_Ex WINELIB_NAME_AW(CM_Get_Device_ID_Ex) -CONFIGRET WINAPI CM_Get_Device_ID_ListA( PCSTR, PCHAR, ULONG, ULONG ); -CONFIGRET WINAPI CM_Get_Device_ID_ListW( PCWSTR, PWCHAR, ULONG, ULONG ); -#define CM_Get_Device_ID_List WINELIB_NAME_AW(CM_Get_Device_ID_List) -CONFIGRET WINAPI CM_Get_Device_ID_List_ExA( PCSTR, PCHAR, ULONG, ULONG, HMACHINE ); -CONFIGRET WINAPI CM_Get_Device_ID_List_ExW( PCWSTR, PWCHAR, ULONG, ULONG, HMACHINE ); -#define CM_Get_Device_ID_List_Ex WINELIB_NAME_AW(CM_Get_Device_ID_List_Ex) -CONFIGRET WINAPI CM_Get_Device_ID_List_SizeA( PULONG, PCSTR, ULONG ); -CONFIGRET WINAPI CM_Get_Device_ID_List_SizeW( PULONG, PCWSTR, ULONG ); -#define CM_Get_Device_ID_List_Size WINELIB_NAME_AW(CM_Get_Device_ID_List_Size) -CONFIGRET WINAPI CM_Get_Device_ID_List_Size_ExA( PULONG, PCSTR, ULONG, HMACHINE ); -CONFIGRET WINAPI CM_Get_Device_ID_List_Size_ExW( PULONG, PCWSTR, ULONG, HMACHINE ); -#define CM_Get_Device_ID_List_Size_Ex WINELIB_NAME_AW(CM_Get_Device_ID_List_Size_Ex) -CONFIGRET WINAPI CM_Get_Device_ID_Size( PULONG, DEVINST, ULONG ); -CONFIGRET WINAPI CM_Get_Device_ID_Size_Ex( PULONG, DEVINST, ULONG, HMACHINE ); -CONFIGRET WINAPI CM_Get_First_Log_Conf( PLOG_CONF, DEVINST, ULONG ); -CONFIGRET WINAPI CM_Get_First_Log_Conf_Ex( PLOG_CONF, DEVINST, ULONG, HMACHINE ); -CONFIGRET WINAPI CM_Get_Global_State( PULONG, ULONG ); -CONFIGRET WINAPI CM_Get_Global_State_Ex( PULONG, ULONG, HMACHINE ); -CONFIGRET WINAPI CM_Set_HW_Prof( ULONG, ULONG ); -CONFIGRET WINAPI CM_Set_HW_Prof_Ex( ULONG, ULONG, HMACHINE ); -CONFIGRET WINAPI CM_Get_HW_Prof_FlagsA( DEVINSTID_A, ULONG, PULONG, ULONG ); -CONFIGRET WINAPI CM_Get_HW_Prof_FlagsW( DEVINSTID_W, ULONG, PULONG, ULONG ); -#define CM_Get_HW_Prof_Flags WINELIB_NAME_AW(CM_Get_HW_Prof_Flags) -CONFIGRET WINAPI CM_Get_HW_Prof_Flags_ExA( DEVINSTID_A, ULONG, PULONG, ULONG, HMACHINE ); -CONFIGRET WINAPI CM_Get_HW_Prof_Flags_ExW( DEVINSTID_W, ULONG, PULONG, ULONG, HMACHINE ); -#define CM_Get_HW_Prof_Flags_Ex WINELIB_NAME_AW(CM_Get_HW_Prof_Flags_Ex) -CONFIGRET WINAPI CM_Get_Log_Conf_Priority( LOG_CONF, PPRIORITY, ULONG ); -CONFIGRET WINAPI CM_Get_Log_Conf_Priority_Ex( LOG_CONF, PPRIORITY, ULONG, HMACHINE ); -CONFIGRET WINAPI CM_Get_Next_Log_Conf( PLOG_CONF, LOG_CONF, ULONG ); -CONFIGRET WINAPI CM_Get_Next_Log_Conf_Ex( PLOG_CONF, LOG_CONF, ULONG, HMACHINE ); -CONFIGRET WINAPI CM_Get_Parent( PDEVINST, DEVINST, ULONG ); -CONFIGRET WINAPI CM_Get_Parent_Ex( PDEVINST, DEVINST, ULONG, HMACHINE ); -CONFIGRET WINAPI CM_Get_Sibling( PDEVINST, DEVINST, ULONG ); -CONFIGRET WINAPI CM_Get_Sibling_Ex( PDEVINST, DEVINST, ULONG, HMACHINE ); -WORD WINAPI CM_Get_Version( VOID ); -WORD WINAPI CM_Get_Version_Ex( HMACHINE ); - -CONFIGRET WINAPI CM_Is_Dock_Station_Present( PBOOL ); -CONFIGRET WINAPI CM_Is_Dock_Station_Present_Ex( PBOOL, HMACHINE ); -CONFIGRET WINAPI CM_Locate_DevNodeA( PDEVINST, DEVINSTID_A, ULONG ); -CONFIGRET WINAPI CM_Locate_DevNodeW( PDEVINST, DEVINSTID_W, ULONG ); -#define CM_Locate_DevNode WINELIB_NAME_AW(CM_Locate_DevNode) -CONFIGRET WINAPI CM_Locate_DevNode_ExA( PDEVINST, DEVINSTID_A, ULONG, HMACHINE ); -CONFIGRET WINAPI CM_Locate_DevNode_ExW( PDEVINST, DEVINSTID_W, ULONG, HMACHINE ); -#define CM_Locate_DevNode_Ex WINELIB_NAME_AW(CM_Locate_DevNode_Ex) - -CONFIGRET WINAPI CM_Move_DevNode( DEVINST, DEVINST, ULONG ); -CONFIGRET WINAPI CM_Move_DevNode_Ex( DEVINST, DEVINST, ULONG, HMACHINE ); - -CONFIGRET WINAPI CM_Open_Class_KeyA( LPGUID, LPCSTR, REGSAM, REGDISPOSITION, PHKEY, ULONG ); -CONFIGRET WINAPI CM_Open_Class_KeyW( LPGUID, LPCWSTR, REGSAM, REGDISPOSITION, PHKEY, ULONG ); -#define CM_Open_Class_Key WINELIB_NAME_AW(CM_Open_Class_Key) -CONFIGRET WINAPI CM_Open_Class_Key_ExA( LPGUID, LPCSTR, REGSAM, REGDISPOSITION, PHKEY, ULONG, HMACHINE ); -CONFIGRET WINAPI CM_Open_Class_Key_ExW( LPGUID, LPCWSTR, REGSAM, REGDISPOSITION, PHKEY, ULONG, HMACHINE ); -#define CM_Open_Class_Key_Ex WINELIB_NAME_AW(CM_Open_Class_Key_Ex) -CONFIGRET WINAPI CM_Open_DevNode_Key( DEVINST, REGSAM, ULONG, REGDISPOSITION, PHKEY, ULONG ); -CONFIGRET WINAPI CM_Open_DevNode_Key_Ex( DEVINST, REGSAM, ULONG, REGDISPOSITION, PHKEY, ULONG, HMACHINE ); - -CONFIGRET WINAPI CM_Reenumerate_DevNode( DEVINST, ULONG ); -CONFIGRET WINAPI CM_Reenumerate_DevNode_Ex( DEVINST, ULONG, HMACHINE ); - -CONFIGRET WINAPI CM_Request_Eject_PC( VOID ); -CONFIGRET WINAPI CM_Request_Eject_PC_Ex( HMACHINE ); - -CONFIGRET WINAPI CM_Run_Detection( ULONG ); -CONFIGRET WINAPI CM_Run_Detection_Ex( ULONG, HMACHINE ); -CONFIGRET WINAPI CM_Set_DevNode_Problem( DEVINST, ULONG, ULONG ); -CONFIGRET WINAPI CM_Set_DevNode_Problem_Ex( DEVINST, ULONG, ULONG, HMACHINE ); -CONFIGRET WINAPI CM_Set_DevNode_Registry_PropertyA( DEVINST, ULONG, PCVOID, ULONG, ULONG ); -CONFIGRET WINAPI CM_Set_DevNode_Registry_PropertyW( DEVINST, ULONG, PCVOID, ULONG, ULONG ); -#define CM_Set_DevNode_Registry_Property WINELIB_NAME_AW(CM_Set_DevNode_Registry_Property) -CONFIGRET WINAPI CM_Set_DevNode_Registry_Property_ExA( DEVINST, ULONG, PCVOID, ULONG, ULONG, HMACHINE ); -CONFIGRET WINAPI CM_Set_DevNode_Registry_Property_ExW( DEVINST, ULONG, PCVOID, ULONG, ULONG, HMACHINE ); -#define CM_Set_DevNode_Registry_Property_Ex WINELIB_NAME_AW(CM_Set_DevNode_Registry_Property_Ex) - -CONFIGRET WINAPI CM_Set_HW_Prof_FlagsA( DEVINSTID_A, ULONG, ULONG, ULONG ); -CONFIGRET WINAPI CM_Set_HW_Prof_FlagsW( DEVINSTID_W, ULONG, ULONG, ULONG ); -#define CM_Set_HW_Prof_Flags WINELIB_NAME_AW(CM_Set_HW_Prof_Flags) -CONFIGRET WINAPI CM_Set_HW_Prof_Flags_ExA( DEVINSTID_A, ULONG, ULONG, ULONG, HMACHINE ); -CONFIGRET WINAPI CM_Set_HW_Prof_Flags_ExW( DEVINSTID_W, ULONG, ULONG, ULONG, HMACHINE ); -#define CM_Set_HW_Prof_Flags_Ex WINELIB_NAME_AW(CM_Set_HW_Prof_Flags_Ex) -CONFIGRET WINAPI CM_Setup_DevNode( DEVINST, ULONG ); -CONFIGRET WINAPI CM_Setup_DevNode_Ex( DEVINST, ULONG, HMACHINE ); - -CONFIGRET WINAPI CM_Uninstall_DevNode( DEVINST, ULONG ); -CONFIGRET WINAPI CM_Uninstall_DevNode_Ex( DEVINST, ULONG, HMACHINE ); - -#endif /* _CFGMGR32_H_ */ From fa60118aec3141fe3c29d487ab03c25741307501 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 29 Mar 2010 02:15:21 +0000 Subject: [PATCH 067/134] Fix build svn path=/trunk/; revision=46545 --- reactos/include/reactos/idl/pnp.idl | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/reactos/include/reactos/idl/pnp.idl b/reactos/include/reactos/idl/pnp.idl index 44fd06a9654..ff5f5cca14c 100644 --- a/reactos/include/reactos/idl/pnp.idl +++ b/reactos/include/reactos/idl/pnp.idl @@ -16,6 +16,13 @@ const unsigned long PNP_MAX_BUFFER_SIZE = 16000000; cpp_quote("#ifndef _CFGMGR32_H_") typedef unsigned long RESOURCEID; + +typedef struct _HWPROFILEINFO { + DWORD HWPI_ulHWProfile; + WCHAR HWPI_szFriendlyName[80]; + DWORD HWPI_dwFlags; +} HWPROFILEINFO; + cpp_quote("#endif") typedef unsigned long DEVPROPTYPE; typedef [range(0, PNP_MAX_PROP_SIZE)] unsigned long PNP_PROP_SIZE; @@ -242,12 +249,6 @@ typedef struct _DEVPROPKEY { DWORD pid; } DEVPROPKEY; -typedef struct _HWPROFILEINFO { - DWORD HWPI_ulHWProfile; - WCHAR HWPI_szFriendlyName[80]; - DWORD HWPI_dwFlags; -} HWPROFILEINFO; - [ uuid (809F4e40-A03D-11CE-8F69-08003E30051B), version(1.0), From f903a6242e6419bd1b9eff4a14e84e0211afe1ae Mon Sep 17 00:00:00 2001 From: Sir Richard Date: Mon, 29 Mar 2010 02:27:41 +0000 Subject: [PATCH 068/134] [COMPBATT]: More miniclass driver interface work: CompBattQueryInformation and CompBattGetBatteryGranularity. svn path=/trunk/; revision=46546 --- reactos/drivers/bus/acpi/compbatt/compbatt.c | 188 ++++++++++++++++++- 1 file changed, 183 insertions(+), 5 deletions(-) diff --git a/reactos/drivers/bus/acpi/compbatt/compbatt.c b/reactos/drivers/bus/acpi/compbatt/compbatt.c index b337241be4d..a0b17f83e45 100644 --- a/reactos/drivers/bus/acpi/compbatt/compbatt.c +++ b/reactos/drivers/bus/acpi/compbatt/compbatt.c @@ -394,8 +394,85 @@ NTAPI CompBattGetBatteryGranularity(OUT PBATTERY_REPORTING_SCALE ReportingScale, IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension) { - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; + NTSTATUS Status = STATUS_SUCCESS; + BATTERY_QUERY_INFORMATION InputBuffer; + PCOMPBATT_BATTERY_DATA BatteryData; + BATTERY_REPORTING_SCALE BatteryScale[4]; + PLIST_ENTRY ListHead, NextEntry; + ULONG i; + if (CompBattDebug & 1) DbgPrint("CompBatt: ENTERING GetBatteryGranularity\n"); + + /* Set defaults */ + ReportingScale[0].Granularity = -1; + ReportingScale[1].Granularity = -1; + ReportingScale[2].Granularity = -1; + ReportingScale[3].Granularity = -1; + + /* Loop the battery list */ + ExAcquireFastMutex(&DeviceExtension->Lock); + ListHead = &DeviceExtension->BatteryList; + NextEntry = ListHead->Flink; + while (NextEntry != ListHead) + { + /* Try to acquire the remove lock */ + BatteryData = CONTAINING_RECORD(NextEntry, COMPBATT_BATTERY_DATA, BatteryLink); + if (NT_SUCCESS(IoAcquireRemoveLock(&BatteryData->RemoveLock, 0))) + { + /* Now release the device lock since the battery can't go away */ + ExReleaseFastMutex(&DeviceExtension->Lock); + + /* Build the query */ + InputBuffer.BatteryTag = BatteryData->Tag; + InputBuffer.InformationLevel = BatteryGranularityInformation; + + /* Make sure the battery has a tag */ + if (BatteryData->Tag) + { + /* Send the IOCTL to query the information */ + RtlZeroMemory(&BatteryData->BatteryInformation, + sizeof(BatteryData->BatteryInformation)); + Status = BatteryIoctl(IOCTL_BATTERY_QUERY_INFORMATION, + BatteryData->DeviceObject, + &InputBuffer, + sizeof(InputBuffer), + &BatteryScale, + sizeof(BatteryScale), + 0); + if (!NT_SUCCESS(Status)) + { + /* Fail if the query had a problem */ + ExAcquireFastMutex(&DeviceExtension->Lock); + IoReleaseRemoveLock(&BatteryData->RemoveLock, 0); + break; + } + + /* Loop all 4 scales */ + for (i = 0; i < 4; i++) + { + /* Check for valid granularity */ + if (BatteryScale[i].Granularity) + { + /* If it's smaller, use it instead */ + ReportingScale[i].Granularity = min(BatteryScale[i].Granularity, + ReportingScale[i].Granularity); + } + + } + } + + /* Re-acquire the device extension lock and release the remove lock */ + ExAcquireFastMutex(&DeviceExtension->Lock); + IoReleaseRemoveLock(&BatteryData->RemoveLock, 0); + } + + /* Next entry */ + NextEntry = NextEntry->Flink; + } + + /* All done */ + ExReleaseFastMutex(&DeviceExtension->Lock); + if (CompBattDebug & 1) DbgPrint("CompBatt: EXITING GetBatteryGranularity\n"); + return STATUS_SUCCESS; } NTSTATUS @@ -409,7 +486,7 @@ CompBattGetEstimatedTime(OUT PULONG Time, NTSTATUS NTAPI -CompBattQueryInformation(IN PCOMPBATT_DEVICE_EXTENSION FdoExtension, +CompBattQueryInformation(IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension, IN ULONG Tag, IN BATTERY_QUERY_INFORMATION_LEVEL InfoLevel, IN OPTIONAL LONG AtRate, @@ -417,8 +494,109 @@ CompBattQueryInformation(IN PCOMPBATT_DEVICE_EXTENSION FdoExtension, IN ULONG BufferLength, OUT PULONG ReturnedLength) { - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; + BATTERY_INFORMATION BatteryInfo; + BATTERY_REPORTING_SCALE BatteryGranularity[4]; + PWCHAR BatteryName = L"Composite Battery"; + BATTERY_MANUFACTURE_DATE Date; + ULONG Dummy, Time; + PVOID QueryData = NULL; + ULONG QueryLength = 0; + NTSTATUS Status = STATUS_SUCCESS; + PAGED_CODE(); + if (CompBattDebug & 1) DbgPrint("CompBatt: ENTERING QueryInformation\n"); + + /* Check for valid/correct tag */ + if ((Tag != DeviceExtension->Tag) || + (!(DeviceExtension->Flags & COMPBATT_TAG_ASSIGNED))) + { + /* Not right, so fail */ + return STATUS_NO_SUCH_DEVICE; + } + + /* Check what caller wants */ + switch (InfoLevel) + { + case BatteryInformation: + + /* Query combined battery information */ + RtlZeroMemory(&BatteryInfo, sizeof(BatteryInfo)); + Status = CompBattGetBatteryInformation(&BatteryInfo, DeviceExtension); + if (NT_SUCCESS(Status)) + { + /* Return the data if successful */ + QueryData = &BatteryInfo; + QueryLength = sizeof(BatteryInfo); + } + break; + + case BatteryGranularityInformation: + + /* Query combined granularity information */ + RtlZeroMemory(&BatteryGranularity, sizeof(BatteryGranularity)); + Status = CompBattGetBatteryGranularity(BatteryGranularity, DeviceExtension); + if (NT_SUCCESS(Status)) + { + /* Return the data if successful */ + QueryLength = sizeof(BatteryGranularity); + QueryData = &BatteryGranularity; + } + break; + + case BatteryEstimatedTime: + + /* Query combined time estimate information */ + RtlZeroMemory(&Time, sizeof(Time)); + Status = CompBattGetEstimatedTime(&Time, DeviceExtension); + if (NT_SUCCESS(Status)) + { + /* Return the data if successful */ + QueryLength = sizeof(Time); + QueryData = &Time; + } + break; + + case BatteryManufactureName: + case BatteryDeviceName: + + /* Return the static buffer */ + QueryData = BatteryName; + QueryLength = sizeof(L"Composite Battery"); + break; + + case BatteryManufactureDate: + + /* Static data */ + Date.Day = 26; + Date.Month = 06; + Date.Year = 1997; + break; + + case BatteryTemperature: + case BatteryUniqueID: + + /* Return zero */ + Dummy = 0; + QueryData = &Dummy; + QueryLength = sizeof(Dummy); + break; + + default: + + /* Everything else is unknown */ + Status = STATUS_INVALID_PARAMETER; + break; + } + + /* Return the required length and check if the caller supplied enough */ + *ReturnedLength = QueryLength; + if (BufferLength < QueryLength) Status = STATUS_BUFFER_TOO_SMALL; + + /* Copy the data if there's enough space and it exists */ + if ((NT_SUCCESS(Status)) && (QueryData)) RtlCopyMemory(Buffer, QueryData, QueryLength); + + /* Return function result */ + if (CompBattDebug & 1) DbgPrint("CompBatt: EXITING QueryInformation\n"); + return Status; } NTSTATUS From 6a40b4927e4c66957195d7dea008c2ffe00e1f58 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 29 Mar 2010 02:38:12 +0000 Subject: [PATCH 069/134] Reintegrate header-branch 3/x - Add XDK svn path=/trunk/; revision=46547 --- reactos/include/xdk/amd64/ke.h | 278 ++ reactos/include/xdk/amd64/mm.h | 37 + reactos/include/xdk/arm/ke.h | 3 + reactos/include/xdk/cmfuncs.h | 70 + reactos/include/xdk/cmtypes.h | 1048 ++++++ reactos/include/xdk/exfuncs.h | 1040 ++++++ reactos/include/xdk/extypes.h | 289 ++ reactos/include/xdk/generate.bat | 4 + reactos/include/xdk/halfuncs.h | 346 ++ reactos/include/xdk/haltypes.h | 551 +++ reactos/include/xdk/ia64/ke.h | 38 + reactos/include/xdk/interlocked.h | 193 + reactos/include/xdk/iofuncs.h | 2284 ++++++++++++ reactos/include/xdk/iotypes.h | 4869 ++++++++++++++++++++++++++ reactos/include/xdk/kdfuncs.h | 192 + reactos/include/xdk/kdtypes.h | 94 + reactos/include/xdk/kefuncs.h | 1075 ++++++ reactos/include/xdk/ketypes.h | 1183 +++++++ reactos/include/xdk/mips/ke.h | 66 + reactos/include/xdk/mmfuncs.h | 658 ++++ reactos/include/xdk/mmtypes.h | 171 + reactos/include/xdk/ntddk.template.h | 262 ++ reactos/include/xdk/nttmapi.h | 652 ++++ reactos/include/xdk/obfuncs.h | 141 + reactos/include/xdk/obtypes.h | 135 + reactos/include/xdk/pofuncs.h | 167 + reactos/include/xdk/potypes.h | 412 +++ reactos/include/xdk/ppc/ke.h | 107 + reactos/include/xdk/psfuncs.h | 184 + reactos/include/xdk/pstypes.h | 451 +++ reactos/include/xdk/rtlfuncs.h | 2259 ++++++++++++ reactos/include/xdk/rtltypes.h | 448 +++ reactos/include/xdk/sefuncs.h | 144 + reactos/include/xdk/setypes.h | 396 +++ reactos/include/xdk/wdm.template.h | 243 ++ reactos/include/xdk/wmifuncs.h | 152 + reactos/include/xdk/wmitypes.h | 62 + reactos/include/xdk/x86/ke.h | 288 ++ reactos/include/xdk/x86/mm.h | 24 + reactos/include/xdk/zwfuncs.h | 820 +++++ 40 files changed, 21836 insertions(+) create mode 100644 reactos/include/xdk/amd64/ke.h create mode 100644 reactos/include/xdk/amd64/mm.h create mode 100644 reactos/include/xdk/arm/ke.h create mode 100644 reactos/include/xdk/cmfuncs.h create mode 100644 reactos/include/xdk/cmtypes.h create mode 100644 reactos/include/xdk/exfuncs.h create mode 100644 reactos/include/xdk/extypes.h create mode 100644 reactos/include/xdk/generate.bat create mode 100644 reactos/include/xdk/halfuncs.h create mode 100644 reactos/include/xdk/haltypes.h create mode 100644 reactos/include/xdk/ia64/ke.h create mode 100644 reactos/include/xdk/interlocked.h create mode 100644 reactos/include/xdk/iofuncs.h create mode 100644 reactos/include/xdk/iotypes.h create mode 100644 reactos/include/xdk/kdfuncs.h create mode 100644 reactos/include/xdk/kdtypes.h create mode 100644 reactos/include/xdk/kefuncs.h create mode 100644 reactos/include/xdk/ketypes.h create mode 100644 reactos/include/xdk/mips/ke.h create mode 100644 reactos/include/xdk/mmfuncs.h create mode 100644 reactos/include/xdk/mmtypes.h create mode 100644 reactos/include/xdk/ntddk.template.h create mode 100644 reactos/include/xdk/nttmapi.h create mode 100644 reactos/include/xdk/obfuncs.h create mode 100644 reactos/include/xdk/obtypes.h create mode 100644 reactos/include/xdk/pofuncs.h create mode 100644 reactos/include/xdk/potypes.h create mode 100644 reactos/include/xdk/ppc/ke.h create mode 100644 reactos/include/xdk/psfuncs.h create mode 100644 reactos/include/xdk/pstypes.h create mode 100644 reactos/include/xdk/rtlfuncs.h create mode 100644 reactos/include/xdk/rtltypes.h create mode 100644 reactos/include/xdk/sefuncs.h create mode 100644 reactos/include/xdk/setypes.h create mode 100644 reactos/include/xdk/wdm.template.h create mode 100644 reactos/include/xdk/wmifuncs.h create mode 100644 reactos/include/xdk/wmitypes.h create mode 100644 reactos/include/xdk/x86/ke.h create mode 100644 reactos/include/xdk/x86/mm.h create mode 100644 reactos/include/xdk/zwfuncs.h diff --git a/reactos/include/xdk/amd64/ke.h b/reactos/include/xdk/amd64/ke.h new file mode 100644 index 00000000000..d744cd5eca7 --- /dev/null +++ b/reactos/include/xdk/amd64/ke.h @@ -0,0 +1,278 @@ +$if (_WDMDDK_) +/** Kernel definitions for AMD64 **/ + +/* Interrupt request levels */ +#define PASSIVE_LEVEL 0 +#define LOW_LEVEL 0 +#define APC_LEVEL 1 +#define DISPATCH_LEVEL 2 +#define CMCI_LEVEL 5 +#define CLOCK_LEVEL 13 +#define IPI_LEVEL 14 +#define DRS_LEVEL 14 +#define POWER_LEVEL 14 +#define PROFILE_LEVEL 15 +#define HIGH_LEVEL 15 + +#define KI_USER_SHARED_DATA 0xFFFFF78000000000ULL +#define SharedUserData ((PKUSER_SHARED_DATA const)KI_USER_SHARED_DATA) +#define SharedInterruptTime (KI_USER_SHARED_DATA + 0x8) +#define SharedSystemTime (KI_USER_SHARED_DATA + 0x14) +#define SharedTickCount (KI_USER_SHARED_DATA + 0x320) + +#define PAGE_SIZE 0x1000 +#define PAGE_SHIFT 12L + +#define EFLAG_SIGN 0x8000 +#define EFLAG_ZERO 0x4000 +#define EFLAG_SELECT (EFLAG_SIGN | EFLAG_ZERO) + +#define RESULT_NEGATIVE ((EFLAG_SIGN & ~EFLAG_ZERO) & EFLAG_SELECT) +#define RESULT_ZERO ((~EFLAG_SIGN & EFLAG_ZERO) & EFLAG_SELECT) +#define RESULT_POSITIVE ((~EFLAG_SIGN & ~EFLAG_ZERO) & EFLAG_SELECT) + + +typedef struct _KFLOATING_SAVE { + ULONG Dummy; +} KFLOATING_SAVE, *PKFLOATING_SAVE; + +typedef XSAVE_FORMAT XMM_SAVE_AREA32, *PXMM_SAVE_AREA32; + +#define KeQueryInterruptTime() \ + (*(volatile ULONG64*)SharedInterruptTime) + +#define KeQuerySystemTime(CurrentCount) \ + *(ULONG64*)(CurrentCount) = *(volatile ULONG64*)SharedSystemTime + +#define KeQueryTickCount(CurrentCount) \ + *(ULONG64*)(CurrentCount) = *(volatile ULONG64*)SharedTickCount + +#define KeGetDcacheFillSize() 1L + +#define YieldProcessor _mm_pause + +FORCEINLINE +KIRQL +KeGetCurrentIrql(VOID) +{ + return (KIRQL)__readcr8(); +} + +FORCEINLINE +VOID +KeLowerIrql(IN KIRQL NewIrql) +{ + //ASSERT(KeGetCurrentIrql() >= NewIrql); + __writecr8(NewIrql); +} + +FORCEINLINE +KIRQL +KfRaiseIrql(IN KIRQL NewIrql) +{ + KIRQL OldIrql; + + OldIrql = __readcr8(); + //ASSERT(OldIrql <= NewIrql); + __writecr8(NewIrql); + return OldIrql; +} +#define KeRaiseIrql(a,b) *(b) = KfRaiseIrql(a) + +FORCEINLINE +KIRQL +KeRaiseIrqlToDpcLevel(VOID) +{ + return KfRaiseIrql(DISPATCH_LEVEL); +} + +FORCEINLINE +KIRQL +KeRaiseIrqlToSynchLevel(VOID) +{ + return KfRaiseIrql(12); // SYNCH_LEVEL = IPI_LEVEL - 2 +} + +FORCEINLINE +PKTHREAD +KeGetCurrentThread(VOID) +{ + return (struct _KTHREAD *)__readgsqword(0x188); +} + +/* VOID + * KeFlushIoBuffers( + * IN PMDL Mdl, + * IN BOOLEAN ReadOperation, + * IN BOOLEAN DmaOperation) + */ +#define KeFlushIoBuffers(_Mdl, _ReadOperation, _DmaOperation) + +/* x86 and x64 performs a 0x2C interrupt */ +#define DbgRaiseAssertionFailure __int2c + +$endif /* _WDMDDK_ */ +$if (_NTDDK_) + +#define PAUSE_PROCESSOR YieldProcessor(); + +#define KERNEL_STACK_SIZE 0x6000 +#define KERNEL_LARGE_STACK_SIZE 0x12000 +#define KERNEL_LARGE_STACK_COMMIT KERNEL_STACK_SIZE + +#define KERNEL_MCA_EXCEPTION_STACK_SIZE 0x2000 + +#define EXCEPTION_READ_FAULT 0 +#define EXCEPTION_WRITE_FAULT 1 +#define EXCEPTION_EXECUTE_FAULT 8 + +#if !defined(RC_INVOKED) + +#define CONTEXT_AMD64 0x100000 + +#define CONTEXT_CONTROL (CONTEXT_AMD64 | 0x1L) +#define CONTEXT_INTEGER (CONTEXT_AMD64 | 0x2L) +#define CONTEXT_SEGMENTS (CONTEXT_AMD64 | 0x4L) +#define CONTEXT_FLOATING_POINT (CONTEXT_AMD64 | 0x8L) +#define CONTEXT_DEBUG_REGISTERS (CONTEXT_AMD64 | 0x10L) + +#define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT) +#define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS) + +#define CONTEXT_XSTATE (CONTEXT_AMD64 | 0x20L) + +#define CONTEXT_EXCEPTION_ACTIVE 0x8000000 +#define CONTEXT_SERVICE_ACTIVE 0x10000000 +#define CONTEXT_EXCEPTION_REQUEST 0x40000000 +#define CONTEXT_EXCEPTION_REPORTING 0x80000000 + +#endif /* !defined(RC_INVOKED) */ + +#define INITIAL_MXCSR 0x1f80 +#define INITIAL_FPCSR 0x027f + +typedef struct DECLSPEC_ALIGN(16) _CONTEXT { + ULONG64 P1Home; + ULONG64 P2Home; + ULONG64 P3Home; + ULONG64 P4Home; + ULONG64 P5Home; + ULONG64 P6Home; + ULONG ContextFlags; + ULONG MxCsr; + USHORT SegCs; + USHORT SegDs; + USHORT SegEs; + USHORT SegFs; + USHORT SegGs; + USHORT SegSs; + ULONG EFlags; + ULONG64 Dr0; + ULONG64 Dr1; + ULONG64 Dr2; + ULONG64 Dr3; + ULONG64 Dr6; + ULONG64 Dr7; + ULONG64 Rax; + ULONG64 Rcx; + ULONG64 Rdx; + ULONG64 Rbx; + ULONG64 Rsp; + ULONG64 Rbp; + ULONG64 Rsi; + ULONG64 Rdi; + ULONG64 R8; + ULONG64 R9; + ULONG64 R10; + ULONG64 R11; + ULONG64 R12; + ULONG64 R13; + ULONG64 R14; + ULONG64 R15; + ULONG64 Rip; + union { + XMM_SAVE_AREA32 FltSave; + struct { + M128A Header[2]; + M128A Legacy[8]; + M128A Xmm0; + M128A Xmm1; + M128A Xmm2; + M128A Xmm3; + M128A Xmm4; + M128A Xmm5; + M128A Xmm6; + M128A Xmm7; + M128A Xmm8; + M128A Xmm9; + M128A Xmm10; + M128A Xmm11; + M128A Xmm12; + M128A Xmm13; + M128A Xmm14; + M128A Xmm15; + } DUMMYSTRUCTNAME; + } DUMMYUNIONNAME; + M128A VectorRegister[26]; + ULONG64 VectorControl; + ULONG64 DebugControl; + ULONG64 LastBranchToRip; + ULONG64 LastBranchFromRip; + ULONG64 LastExceptionToRip; + ULONG64 LastExceptionFromRip; +} CONTEXT; + +#define PCR_MINOR_VERSION 1 +#define PCR_MAJOR_VERSION 1 + +typedef struct _KPCR +{ + _ANONYMOUS_UNION union + { + NT_TIB NtTib; + _ANONYMOUS_STRUCT struct + { + union _KGDTENTRY64 *GdtBase; + struct _KTSS64 *TssBase; + ULONG64 UserRsp; + struct _KPCR *Self; + struct _KPRCB *CurrentPrcb; + PKSPIN_LOCK_QUEUE LockArray; + PVOID Used_Self; + }; + }; + union _KIDTENTRY64 *IdtBase; + ULONG64 Unused[2]; + KIRQL Irql; + UCHAR SecondLevelCacheAssociativity; + UCHAR ObsoleteNumber; + UCHAR Fill0; + ULONG Unused0[3]; + USHORT MajorVersion; + USHORT MinorVersion; + ULONG StallScaleFactor; + PVOID Unused1[3]; + ULONG KernelReserved[15]; + ULONG SecondLevelCacheSize; + ULONG HalReserved[16]; + ULONG Unused2; + PVOID KdVersionBlock; + PVOID Unused3; + ULONG PcrAlign1[24]; +} KPCR, *PKPCR; + +FORCEINLINE +PKPCR +KeGetPcr(VOID) +{ + return (PKPCR)__readgsqword(FIELD_OFFSET(KPCR, Self)); +} + +FORCEINLINE +ULONG +KeGetCurrentProcessorNumber(VOID) +{ + return (ULONG)__readgsword(0x184); +} + +$endif /* _NTDDK_ */ diff --git a/reactos/include/xdk/amd64/mm.h b/reactos/include/xdk/amd64/mm.h new file mode 100644 index 00000000000..2c390a14d26 --- /dev/null +++ b/reactos/include/xdk/amd64/mm.h @@ -0,0 +1,37 @@ +$if (_NTDDK_) + +#define PTI_SHIFT 12L +#define PDI_SHIFT 21L +#define PPI_SHIFT 30L +#define PXI_SHIFT 39L +#define PTE_PER_PAGE 512 +#define PDE_PER_PAGE 512 +#define PPE_PER_PAGE 512 +#define PXE_PER_PAGE 512 +#define PTI_MASK_AMD64 (PTE_PER_PAGE - 1) +#define PDI_MASK_AMD64 (PDE_PER_PAGE - 1) +#define PPI_MASK (PPE_PER_PAGE - 1) +#define PXI_MASK (PXE_PER_PAGE - 1) + +#define PXE_BASE 0xFFFFF6FB7DBED000ULL +#define PXE_SELFMAP 0xFFFFF6FB7DBEDF68ULL +#define PPE_BASE 0xFFFFF6FB7DA00000ULL +#define PDE_BASE 0xFFFFF6FB40000000ULL +#define PTE_BASE 0xFFFFF68000000000ULL +#define PXE_TOP 0xFFFFF6FB7DBEDFFFULL +#define PPE_TOP 0xFFFFF6FB7DBFFFFFULL +#define PDE_TOP 0xFFFFF6FB7FFFFFFFULL +#define PTE_TOP 0xFFFFF6FFFFFFFFFFULL + +extern NTKERNELAPI PVOID MmHighestUserAddress; +extern NTKERNELAPI PVOID MmSystemRangeStart; +extern NTKERNELAPI ULONG64 MmUserProbeAddress; + +#define MM_HIGHEST_USER_ADDRESS MmHighestUserAddress +#define MM_SYSTEM_RANGE_START MmSystemRangeStart +#define MM_USER_PROBE_ADDRESS MmUserProbeAddress +#define MM_LOWEST_USER_ADDRESS (PVOID)0x10000 +#define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xFFFF080000000000ULL + +$endif /* _NTDDK_ */ + diff --git a/reactos/include/xdk/arm/ke.h b/reactos/include/xdk/arm/ke.h new file mode 100644 index 00000000000..372e5658328 --- /dev/null +++ b/reactos/include/xdk/arm/ke.h @@ -0,0 +1,3 @@ +$if (_WDMDDK_) +#include +$endif diff --git a/reactos/include/xdk/cmfuncs.h b/reactos/include/xdk/cmfuncs.h new file mode 100644 index 00000000000..9fb3de09a7f --- /dev/null +++ b/reactos/include/xdk/cmfuncs.h @@ -0,0 +1,70 @@ +/****************************************************************************** + * Configuration Manager Functions * + ******************************************************************************/ + +$if (_WDMDDK_) +#if (NTDDI_VERSION >= NTDDI_WINXP) +NTKERNELAPI +NTSTATUS +NTAPI +CmRegisterCallback( + IN PEX_CALLBACK_FUNCTION Function, + IN PVOID Context OPTIONAL, + OUT PLARGE_INTEGER Cookie); + +NTKERNELAPI +NTSTATUS +NTAPI +CmUnRegisterCallback( + IN LARGE_INTEGER Cookie); +#endif + +#if (NTDDI_VERSION >= NTDDI_VISTA) + +NTKERNELAPI +NTSTATUS +NTAPI +CmRegisterCallbackEx( + PEX_CALLBACK_FUNCTION Function, + PCUNICODE_STRING Altitude, + PVOID Driver, + PVOID Context, + PLARGE_INTEGER Cookie, + PVOID Reserved); + +NTKERNELAPI +VOID +NTAPI +CmGetCallbackVersion( + OUT PULONG Major OPTIONAL, + OUT PULONG Minor OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +CmSetCallbackObjectContext( + IN OUT PVOID Object, + IN PLARGE_INTEGER Cookie, + IN PVOID NewContext, + OUT PVOID *OldContext OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +CmCallbackGetKeyObjectID( + IN PLARGE_INTEGER Cookie, + IN PVOID Object, + OUT PULONG_PTR ObjectID OPTIONAL, + OUT PCUNICODE_STRING *ObjectName OPTIONAL); + +NTKERNELAPI +PVOID +NTAPI +CmGetBoundTransaction( + IN PLARGE_INTEGER Cookie, + IN PVOID Object); + +#endif // NTDDI_VERSION >= NTDDI_VISTA + +$endif + diff --git a/reactos/include/xdk/cmtypes.h b/reactos/include/xdk/cmtypes.h new file mode 100644 index 00000000000..2599a78cfc4 --- /dev/null +++ b/reactos/include/xdk/cmtypes.h @@ -0,0 +1,1048 @@ +/****************************************************************************** + * Configuration Manager Types * + ******************************************************************************/ + +$if (_WDMDDK_) +/* Resource list definitions */ +typedef int CM_RESOURCE_TYPE; + +#define CmResourceTypeNull 0 +#define CmResourceTypePort 1 +#define CmResourceTypeInterrupt 2 +#define CmResourceTypeMemory 3 +#define CmResourceTypeDma 4 +#define CmResourceTypeDeviceSpecific 5 +#define CmResourceTypeBusNumber 6 +#define CmResourceTypeNonArbitrated 128 +#define CmResourceTypeConfigData 128 +#define CmResourceTypeDevicePrivate 129 +#define CmResourceTypePcCardConfig 130 +#define CmResourceTypeMfCardConfig 131 + +/* KEY_VALUE_Xxx.Type */ +#define REG_NONE 0 +#define REG_SZ 1 +#define REG_EXPAND_SZ 2 +#define REG_BINARY 3 +#define REG_DWORD 4 +#define REG_DWORD_LITTLE_ENDIAN 4 +#define REG_DWORD_BIG_ENDIAN 5 +#define REG_LINK 6 +#define REG_MULTI_SZ 7 +#define REG_RESOURCE_LIST 8 +#define REG_FULL_RESOURCE_DESCRIPTOR 9 +#define REG_RESOURCE_REQUIREMENTS_LIST 10 +#define REG_QWORD 11 +#define REG_QWORD_LITTLE_ENDIAN 11 + +/* Registry Access Rights */ +#define KEY_QUERY_VALUE (0x0001) +#define KEY_SET_VALUE (0x0002) +#define KEY_CREATE_SUB_KEY (0x0004) +#define KEY_ENUMERATE_SUB_KEYS (0x0008) +#define KEY_NOTIFY (0x0010) +#define KEY_CREATE_LINK (0x0020) +#define KEY_WOW64_32KEY (0x0200) +#define KEY_WOW64_64KEY (0x0100) +#define KEY_WOW64_RES (0x0300) + +#define KEY_READ ((STANDARD_RIGHTS_READ |\ + KEY_QUERY_VALUE |\ + KEY_ENUMERATE_SUB_KEYS |\ + KEY_NOTIFY) \ + & \ + (~SYNCHRONIZE)) + +#define KEY_WRITE ((STANDARD_RIGHTS_WRITE |\ + KEY_SET_VALUE |\ + KEY_CREATE_SUB_KEY) \ + & \ + (~SYNCHRONIZE)) + +#define KEY_EXECUTE ((KEY_READ) \ + & \ + (~SYNCHRONIZE)) + +#define KEY_ALL_ACCESS ((STANDARD_RIGHTS_ALL |\ + KEY_QUERY_VALUE |\ + KEY_SET_VALUE |\ + KEY_CREATE_SUB_KEY |\ + KEY_ENUMERATE_SUB_KEYS |\ + KEY_NOTIFY |\ + KEY_CREATE_LINK) \ + & \ + (~SYNCHRONIZE)) + +/* Registry Open/Create Options */ +#define REG_OPTION_RESERVED (0x00000000L) +#define REG_OPTION_NON_VOLATILE (0x00000000L) +#define REG_OPTION_VOLATILE (0x00000001L) +#define REG_OPTION_CREATE_LINK (0x00000002L) +#define REG_OPTION_BACKUP_RESTORE (0x00000004L) +#define REG_OPTION_OPEN_LINK (0x00000008L) + +#define REG_LEGAL_OPTION \ + (REG_OPTION_RESERVED |\ + REG_OPTION_NON_VOLATILE |\ + REG_OPTION_VOLATILE |\ + REG_OPTION_CREATE_LINK |\ + REG_OPTION_BACKUP_RESTORE |\ + REG_OPTION_OPEN_LINK) + +#define REG_OPEN_LEGAL_OPTION \ + (REG_OPTION_RESERVED |\ + REG_OPTION_BACKUP_RESTORE |\ + REG_OPTION_OPEN_LINK) + +#define REG_STANDARD_FORMAT 1 +#define REG_LATEST_FORMAT 2 +#define REG_NO_COMPRESSION 4 + +/* Key creation/open disposition */ +#define REG_CREATED_NEW_KEY (0x00000001L) +#define REG_OPENED_EXISTING_KEY (0x00000002L) + +/* Key restore & hive load flags */ +#define REG_WHOLE_HIVE_VOLATILE (0x00000001L) +#define REG_REFRESH_HIVE (0x00000002L) +#define REG_NO_LAZY_FLUSH (0x00000004L) +#define REG_FORCE_RESTORE (0x00000008L) +#define REG_APP_HIVE (0x00000010L) +#define REG_PROCESS_PRIVATE (0x00000020L) +#define REG_START_JOURNAL (0x00000040L) +#define REG_HIVE_EXACT_FILE_GROWTH (0x00000080L) +#define REG_HIVE_NO_RM (0x00000100L) +#define REG_HIVE_SINGLE_LOG (0x00000200L) +#define REG_BOOT_HIVE (0x00000400L) + +/* Unload Flags */ +#define REG_FORCE_UNLOAD 1 + +/* Notify Filter Values */ +#define REG_NOTIFY_CHANGE_NAME (0x00000001L) +#define REG_NOTIFY_CHANGE_ATTRIBUTES (0x00000002L) +#define REG_NOTIFY_CHANGE_LAST_SET (0x00000004L) +#define REG_NOTIFY_CHANGE_SECURITY (0x00000008L) + +#define REG_LEGAL_CHANGE_FILTER \ + (REG_NOTIFY_CHANGE_NAME |\ + REG_NOTIFY_CHANGE_ATTRIBUTES |\ + REG_NOTIFY_CHANGE_LAST_SET |\ + REG_NOTIFY_CHANGE_SECURITY) + +#include +typedef struct _CM_PARTIAL_RESOURCE_DESCRIPTOR { + UCHAR Type; + UCHAR ShareDisposition; + USHORT Flags; + union { + struct { + PHYSICAL_ADDRESS Start; + ULONG Length; + } Generic; + struct { + PHYSICAL_ADDRESS Start; + ULONG Length; + } Port; + struct { +#if defined(NT_PROCESSOR_GROUPS) + USHORT Level; + USHORT Group; +#else + ULONG Level; +#endif + ULONG Vector; + KAFFINITY Affinity; + } Interrupt; +#if (NTDDI_VERSION >= NTDDI_LONGHORN) + struct { + __GNU_EXTENSION union { + struct { +#if defined(NT_PROCESSOR_GROUPS) + USHORT Group; +#else + USHORT Reserved; +#endif + USHORT MessageCount; + ULONG Vector; + KAFFINITY Affinity; + } Raw; + struct { +#if defined(NT_PROCESSOR_GROUPS) + USHORT Level; + USHORT Group; +#else + ULONG Level; +#endif + ULONG Vector; + KAFFINITY Affinity; + } Translated; + } DUMMYUNIONNAME; + } MessageInterrupt; +#endif + struct { + PHYSICAL_ADDRESS Start; + ULONG Length; + } Memory; + struct { + ULONG Channel; + ULONG Port; + ULONG Reserved1; + } Dma; + struct { + ULONG Data[3]; + } DevicePrivate; + struct { + ULONG Start; + ULONG Length; + ULONG Reserved; + } BusNumber; + struct { + ULONG DataSize; + ULONG Reserved1; + ULONG Reserved2; + } DeviceSpecificData; +#if (NTDDI_VERSION >= NTDDI_LONGHORN) + struct { + PHYSICAL_ADDRESS Start; + ULONG Length40; + } Memory40; + struct { + PHYSICAL_ADDRESS Start; + ULONG Length48; + } Memory48; + struct { + PHYSICAL_ADDRESS Start; + ULONG Length64; + } Memory64; +#endif + } u; +} CM_PARTIAL_RESOURCE_DESCRIPTOR, *PCM_PARTIAL_RESOURCE_DESCRIPTOR; +#include + +/* CM_PARTIAL_RESOURCE_DESCRIPTOR.Type */ +#define CmResourceTypeNull 0 +#define CmResourceTypePort 1 +#define CmResourceTypeInterrupt 2 +#define CmResourceTypeMemory 3 +#define CmResourceTypeDma 4 +#define CmResourceTypeDeviceSpecific 5 +#define CmResourceTypeBusNumber 6 +#define CmResourceTypeMemoryLarge 7 +#define CmResourceTypeNonArbitrated 128 +#define CmResourceTypeConfigData 128 +#define CmResourceTypeDevicePrivate 129 +#define CmResourceTypePcCardConfig 130 +#define CmResourceTypeMfCardConfig 131 + +/* CM_PARTIAL_RESOURCE_DESCRIPTOR.ShareDisposition */ +typedef enum _CM_SHARE_DISPOSITION { + CmResourceShareUndetermined = 0, + CmResourceShareDeviceExclusive, + CmResourceShareDriverExclusive, + CmResourceShareShared +} CM_SHARE_DISPOSITION; + +/* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypePort */ +#define CM_RESOURCE_PORT_MEMORY 0x0000 +#define CM_RESOURCE_PORT_IO 0x0001 +#define CM_RESOURCE_PORT_10_BIT_DECODE 0x0004 +#define CM_RESOURCE_PORT_12_BIT_DECODE 0x0008 +#define CM_RESOURCE_PORT_16_BIT_DECODE 0x0010 +#define CM_RESOURCE_PORT_POSITIVE_DECODE 0x0020 +#define CM_RESOURCE_PORT_PASSIVE_DECODE 0x0040 +#define CM_RESOURCE_PORT_WINDOW_DECODE 0x0080 +#define CM_RESOURCE_PORT_BAR 0x0100 + +/* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypeInterrupt */ +#define CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE 0x0000 +#define CM_RESOURCE_INTERRUPT_LATCHED 0x0001 +#define CM_RESOURCE_INTERRUPT_MESSAGE 0x0002 +#define CM_RESOURCE_INTERRUPT_POLICY_INCLUDED 0x0004 + +#define CM_RESOURCE_INTERRUPT_LEVEL_LATCHED_BITS 0x0001 + +#define CM_RESOURCE_INTERRUPT_MESSAGE_TOKEN ((ULONG)-2) + +/* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypeMemory */ +#define CM_RESOURCE_MEMORY_READ_WRITE 0x0000 +#define CM_RESOURCE_MEMORY_READ_ONLY 0x0001 +#define CM_RESOURCE_MEMORY_WRITE_ONLY 0x0002 +#define CM_RESOURCE_MEMORY_WRITEABILITY_MASK 0x0003 +#define CM_RESOURCE_MEMORY_PREFETCHABLE 0x0004 +#define CM_RESOURCE_MEMORY_COMBINEDWRITE 0x0008 +#define CM_RESOURCE_MEMORY_24 0x0010 +#define CM_RESOURCE_MEMORY_CACHEABLE 0x0020 +#define CM_RESOURCE_MEMORY_WINDOW_DECODE 0x0040 +#define CM_RESOURCE_MEMORY_BAR 0x0080 +#define CM_RESOURCE_MEMORY_COMPAT_FOR_INACCESSIBLE_RANGE 0x0100 + +#define CM_RESOURCE_MEMORY_LARGE 0x0E00 +#define CM_RESOURCE_MEMORY_LARGE_40 0x0200 +#define CM_RESOURCE_MEMORY_LARGE_48 0x0400 +#define CM_RESOURCE_MEMORY_LARGE_64 0x0800 + +#define CM_RESOURCE_MEMORY_LARGE_40_MAXLEN 0x000000FFFFFFFF00 +#define CM_RESOURCE_MEMORY_LARGE_48_MAXLEN 0x0000FFFFFFFF0000 +#define CM_RESOURCE_MEMORY_LARGE_64_MAXLEN 0xFFFFFFFF00000000 + +/* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypeDma */ +#define CM_RESOURCE_DMA_8 0x0000 +#define CM_RESOURCE_DMA_16 0x0001 +#define CM_RESOURCE_DMA_32 0x0002 +#define CM_RESOURCE_DMA_8_AND_16 0x0004 +#define CM_RESOURCE_DMA_BUS_MASTER 0x0008 +#define CM_RESOURCE_DMA_TYPE_A 0x0010 +#define CM_RESOURCE_DMA_TYPE_B 0x0020 +#define CM_RESOURCE_DMA_TYPE_F 0x0040 + +typedef struct _DEVICE_FLAGS { + ULONG Failed:1; + ULONG ReadOnly:1; + ULONG Removable:1; + ULONG ConsoleIn:1; + ULONG ConsoleOut:1; + ULONG Input:1; + ULONG Output:1; +} DEVICE_FLAGS, *PDEVICE_FLAGS; + +typedef enum _INTERFACE_TYPE { + InterfaceTypeUndefined = -1, + Internal, + Isa, + Eisa, + MicroChannel, + TurboChannel, + PCIBus, + VMEBus, + NuBus, + PCMCIABus, + CBus, + MPIBus, + MPSABus, + ProcessorInternal, + InternalPowerBus, + PNPISABus, + PNPBus, + Vmcs, + MaximumInterfaceType +} INTERFACE_TYPE, *PINTERFACE_TYPE; + +typedef struct _CM_COMPONENT_INFORMATION { + DEVICE_FLAGS Flags; + ULONG Version; + ULONG Key; + KAFFINITY AffinityMask; +} CM_COMPONENT_INFORMATION, *PCM_COMPONENT_INFORMATION; + +typedef struct _CM_ROM_BLOCK { + ULONG Address; + ULONG Size; +} CM_ROM_BLOCK, *PCM_ROM_BLOCK; + +typedef struct _CM_PARTIAL_RESOURCE_LIST { + USHORT Version; + USHORT Revision; + ULONG Count; + CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1]; +} CM_PARTIAL_RESOURCE_LIST, *PCM_PARTIAL_RESOURCE_LIST; + +typedef struct _CM_FULL_RESOURCE_DESCRIPTOR { + INTERFACE_TYPE InterfaceType; + ULONG BusNumber; + CM_PARTIAL_RESOURCE_LIST PartialResourceList; +} CM_FULL_RESOURCE_DESCRIPTOR, *PCM_FULL_RESOURCE_DESCRIPTOR; + +typedef struct _CM_RESOURCE_LIST { + ULONG Count; + CM_FULL_RESOURCE_DESCRIPTOR List[1]; +} CM_RESOURCE_LIST, *PCM_RESOURCE_LIST; + +typedef struct _PNP_BUS_INFORMATION { + GUID BusTypeGuid; + INTERFACE_TYPE LegacyBusType; + ULONG BusNumber; +} PNP_BUS_INFORMATION, *PPNP_BUS_INFORMATION; + +#include + +typedef struct _CM_INT13_DRIVE_PARAMETER { + USHORT DriveSelect; + ULONG MaxCylinders; + USHORT SectorsPerTrack; + USHORT MaxHeads; + USHORT NumberDrives; +} CM_INT13_DRIVE_PARAMETER, *PCM_INT13_DRIVE_PARAMETER; + +typedef struct _CM_MCA_POS_DATA { + USHORT AdapterId; + UCHAR PosData1; + UCHAR PosData2; + UCHAR PosData3; + UCHAR PosData4; +} CM_MCA_POS_DATA, *PCM_MCA_POS_DATA; + +typedef struct _CM_PNP_BIOS_DEVICE_NODE { + USHORT Size; + UCHAR Node; + ULONG ProductId; + UCHAR DeviceType[3]; + USHORT DeviceAttributes; +} CM_PNP_BIOS_DEVICE_NODE,*PCM_PNP_BIOS_DEVICE_NODE; + +typedef struct _CM_PNP_BIOS_INSTALLATION_CHECK { + UCHAR Signature[4]; + UCHAR Revision; + UCHAR Length; + USHORT ControlField; + UCHAR Checksum; + ULONG EventFlagAddress; + USHORT RealModeEntryOffset; + USHORT RealModeEntrySegment; + USHORT ProtectedModeEntryOffset; + ULONG ProtectedModeCodeBaseAddress; + ULONG OemDeviceId; + USHORT RealModeDataBaseAddress; + ULONG ProtectedModeDataBaseAddress; +} CM_PNP_BIOS_INSTALLATION_CHECK, *PCM_PNP_BIOS_INSTALLATION_CHECK; + +#include + +typedef struct _CM_DISK_GEOMETRY_DEVICE_DATA { + ULONG BytesPerSector; + ULONG NumberOfCylinders; + ULONG SectorsPerTrack; + ULONG NumberOfHeads; +} CM_DISK_GEOMETRY_DEVICE_DATA, *PCM_DISK_GEOMETRY_DEVICE_DATA; + +typedef struct _CM_KEYBOARD_DEVICE_DATA { + USHORT Version; + USHORT Revision; + UCHAR Type; + UCHAR Subtype; + USHORT KeyboardFlags; +} CM_KEYBOARD_DEVICE_DATA, *PCM_KEYBOARD_DEVICE_DATA; + +typedef struct _CM_SCSI_DEVICE_DATA { + USHORT Version; + USHORT Revision; + UCHAR HostIdentifier; +} CM_SCSI_DEVICE_DATA, *PCM_SCSI_DEVICE_DATA; + +typedef struct _CM_VIDEO_DEVICE_DATA { + USHORT Version; + USHORT Revision; + ULONG VideoClock; +} CM_VIDEO_DEVICE_DATA, *PCM_VIDEO_DEVICE_DATA; + +typedef struct _CM_SONIC_DEVICE_DATA { + USHORT Version; + USHORT Revision; + USHORT DataConfigurationRegister; + UCHAR EthernetAddress[8]; +} CM_SONIC_DEVICE_DATA, *PCM_SONIC_DEVICE_DATA; + +typedef struct _CM_SERIAL_DEVICE_DATA { + USHORT Version; + USHORT Revision; + ULONG BaudClock; +} CM_SERIAL_DEVICE_DATA, *PCM_SERIAL_DEVICE_DATA; + +typedef struct _CM_MONITOR_DEVICE_DATA { + USHORT Version; + USHORT Revision; + USHORT HorizontalScreenSize; + USHORT VerticalScreenSize; + USHORT HorizontalResolution; + USHORT VerticalResolution; + USHORT HorizontalDisplayTimeLow; + USHORT HorizontalDisplayTime; + USHORT HorizontalDisplayTimeHigh; + USHORT HorizontalBackPorchLow; + USHORT HorizontalBackPorch; + USHORT HorizontalBackPorchHigh; + USHORT HorizontalFrontPorchLow; + USHORT HorizontalFrontPorch; + USHORT HorizontalFrontPorchHigh; + USHORT HorizontalSyncLow; + USHORT HorizontalSync; + USHORT HorizontalSyncHigh; + USHORT VerticalBackPorchLow; + USHORT VerticalBackPorch; + USHORT VerticalBackPorchHigh; + USHORT VerticalFrontPorchLow; + USHORT VerticalFrontPorch; + USHORT VerticalFrontPorchHigh; + USHORT VerticalSyncLow; + USHORT VerticalSync; + USHORT VerticalSyncHigh; +} CM_MONITOR_DEVICE_DATA, *PCM_MONITOR_DEVICE_DATA; + +typedef struct _CM_FLOPPY_DEVICE_DATA { + USHORT Version; + USHORT Revision; + CHAR Size[8]; + ULONG MaxDensity; + ULONG MountDensity; + UCHAR StepRateHeadUnloadTime; + UCHAR HeadLoadTime; + UCHAR MotorOffTime; + UCHAR SectorLengthCode; + UCHAR SectorPerTrack; + UCHAR ReadWriteGapLength; + UCHAR DataTransferLength; + UCHAR FormatGapLength; + UCHAR FormatFillCharacter; + UCHAR HeadSettleTime; + UCHAR MotorSettleTime; + UCHAR MaximumTrackValue; + UCHAR DataTransferRate; +} CM_FLOPPY_DEVICE_DATA, *PCM_FLOPPY_DEVICE_DATA; + +typedef enum _KEY_INFORMATION_CLASS { + KeyBasicInformation, + KeyNodeInformation, + KeyFullInformation, + KeyNameInformation, + KeyCachedInformation, + KeyFlagsInformation, + KeyVirtualizationInformation, + KeyHandleTagsInformation, + MaxKeyInfoClass +} KEY_INFORMATION_CLASS; + +typedef struct _KEY_BASIC_INFORMATION { + LARGE_INTEGER LastWriteTime; + ULONG TitleIndex; + ULONG NameLength; + WCHAR Name[1]; +} KEY_BASIC_INFORMATION, *PKEY_BASIC_INFORMATION; + +typedef struct _KEY_CONTROL_FLAGS_INFORMATION { + ULONG ControlFlags; +} KEY_CONTROL_FLAGS_INFORMATION, *PKEY_CONTROL_FLAGS_INFORMATION; + +typedef struct _KEY_FULL_INFORMATION { + LARGE_INTEGER LastWriteTime; + ULONG TitleIndex; + ULONG ClassOffset; + ULONG ClassLength; + ULONG SubKeys; + ULONG MaxNameLen; + ULONG MaxClassLen; + ULONG Values; + ULONG MaxValueNameLen; + ULONG MaxValueDataLen; + WCHAR Class[1]; +} KEY_FULL_INFORMATION, *PKEY_FULL_INFORMATION; + +typedef struct _KEY_HANDLE_TAGS_INFORMATION { + ULONG HandleTags; +} KEY_HANDLE_TAGS_INFORMATION, *PKEY_HANDLE_TAGS_INFORMATION; + +typedef struct _KEY_NODE_INFORMATION { + LARGE_INTEGER LastWriteTime; + ULONG TitleIndex; + ULONG ClassOffset; + ULONG ClassLength; + ULONG NameLength; + WCHAR Name[1]; +} KEY_NODE_INFORMATION, *PKEY_NODE_INFORMATION; + +typedef enum _KEY_SET_INFORMATION_CLASS { + KeyWriteTimeInformation, + KeyWow64FlagsInformation, + KeyControlFlagsInformation, + KeySetVirtualizationInformation, + KeySetDebugInformation, + KeySetHandleTagsInformation, + MaxKeySetInfoClass +} KEY_SET_INFORMATION_CLASS; + +typedef struct _KEY_SET_VIRTUALIZATION_INFORMATION { + ULONG VirtualTarget:1; + ULONG VirtualStore:1; + ULONG VirtualSource:1; + ULONG Reserved:29; +} KEY_SET_VIRTUALIZATION_INFORMATION, *PKEY_SET_VIRTUALIZATION_INFORMATION; + +typedef struct _KEY_VALUE_BASIC_INFORMATION { + ULONG TitleIndex; + ULONG Type; + ULONG NameLength; + WCHAR Name[1]; +} KEY_VALUE_BASIC_INFORMATION, *PKEY_VALUE_BASIC_INFORMATION; + +typedef struct _KEY_VALUE_FULL_INFORMATION { + ULONG TitleIndex; + ULONG Type; + ULONG DataOffset; + ULONG DataLength; + ULONG NameLength; + WCHAR Name[1]; +} KEY_VALUE_FULL_INFORMATION, *PKEY_VALUE_FULL_INFORMATION; + +typedef struct _KEY_VALUE_PARTIAL_INFORMATION { + ULONG TitleIndex; + ULONG Type; + ULONG DataLength; + UCHAR Data[1]; +} KEY_VALUE_PARTIAL_INFORMATION, *PKEY_VALUE_PARTIAL_INFORMATION; + +typedef struct _KEY_VALUE_PARTIAL_INFORMATION_ALIGN64 { + ULONG Type; + ULONG DataLength; + UCHAR Data[1]; +} KEY_VALUE_PARTIAL_INFORMATION_ALIGN64, *PKEY_VALUE_PARTIAL_INFORMATION_ALIGN64; + +typedef struct _KEY_VALUE_ENTRY { + PUNICODE_STRING ValueName; + ULONG DataLength; + ULONG DataOffset; + ULONG Type; +} KEY_VALUE_ENTRY, *PKEY_VALUE_ENTRY; + +typedef enum _KEY_VALUE_INFORMATION_CLASS { + KeyValueBasicInformation, + KeyValueFullInformation, + KeyValuePartialInformation, + KeyValueFullInformationAlign64, + KeyValuePartialInformationAlign64 +} KEY_VALUE_INFORMATION_CLASS; + +typedef struct _KEY_WOW64_FLAGS_INFORMATION { + ULONG UserFlags; +} KEY_WOW64_FLAGS_INFORMATION, *PKEY_WOW64_FLAGS_INFORMATION; + +typedef struct _KEY_WRITE_TIME_INFORMATION { + LARGE_INTEGER LastWriteTime; +} KEY_WRITE_TIME_INFORMATION, *PKEY_WRITE_TIME_INFORMATION; + +typedef enum _REG_NOTIFY_CLASS { + RegNtDeleteKey, + RegNtPreDeleteKey = RegNtDeleteKey, + RegNtSetValueKey, + RegNtPreSetValueKey = RegNtSetValueKey, + RegNtDeleteValueKey, + RegNtPreDeleteValueKey = RegNtDeleteValueKey, + RegNtSetInformationKey, + RegNtPreSetInformationKey = RegNtSetInformationKey, + RegNtRenameKey, + RegNtPreRenameKey = RegNtRenameKey, + RegNtEnumerateKey, + RegNtPreEnumerateKey = RegNtEnumerateKey, + RegNtEnumerateValueKey, + RegNtPreEnumerateValueKey = RegNtEnumerateValueKey, + RegNtQueryKey, + RegNtPreQueryKey = RegNtQueryKey, + RegNtQueryValueKey, + RegNtPreQueryValueKey = RegNtQueryValueKey, + RegNtQueryMultipleValueKey, + RegNtPreQueryMultipleValueKey = RegNtQueryMultipleValueKey, + RegNtPreCreateKey, + RegNtPostCreateKey, + RegNtPreOpenKey, + RegNtPostOpenKey, + RegNtKeyHandleClose, + RegNtPreKeyHandleClose = RegNtKeyHandleClose, + RegNtPostDeleteKey, + RegNtPostSetValueKey, + RegNtPostDeleteValueKey, + RegNtPostSetInformationKey, + RegNtPostRenameKey, + RegNtPostEnumerateKey, + RegNtPostEnumerateValueKey, + RegNtPostQueryKey, + RegNtPostQueryValueKey, + RegNtPostQueryMultipleValueKey, + RegNtPostKeyHandleClose, + RegNtPreCreateKeyEx, + RegNtPostCreateKeyEx, + RegNtPreOpenKeyEx, + RegNtPostOpenKeyEx, + RegNtPreFlushKey, + RegNtPostFlushKey, + RegNtPreLoadKey, + RegNtPostLoadKey, + RegNtPreUnLoadKey, + RegNtPostUnLoadKey, + RegNtPreQueryKeySecurity, + RegNtPostQueryKeySecurity, + RegNtPreSetKeySecurity, + RegNtPostSetKeySecurity, + RegNtCallbackObjectContextCleanup, + RegNtPreRestoreKey, + RegNtPostRestoreKey, + RegNtPreSaveKey, + RegNtPostSaveKey, + RegNtPreReplaceKey, + RegNtPostReplaceKey, + MaxRegNtNotifyClass +} REG_NOTIFY_CLASS, *PREG_NOTIFY_CLASS; + +typedef NTSTATUS +(NTAPI EX_CALLBACK_FUNCTION)( + IN PVOID CallbackContext, + IN PVOID Argument1, + IN PVOID Argument2); +typedef EX_CALLBACK_FUNCTION *PEX_CALLBACK_FUNCTION; + +typedef struct _REG_DELETE_KEY_INFORMATION { + PVOID Object; + PVOID CallContext; + PVOID ObjectContext; + PVOID Reserved; +} REG_DELETE_KEY_INFORMATION, *PREG_DELETE_KEY_INFORMATION +#if (NTDDI_VERSION >= NTDDI_VISTA) +, REG_FLUSH_KEY_INFORMATION, *PREG_FLUSH_KEY_INFORMATION +#endif +; + +typedef struct _REG_SET_VALUE_KEY_INFORMATION { + PVOID Object; + PUNICODE_STRING ValueName; + ULONG TitleIndex; + ULONG Type; + PVOID Data; + ULONG DataSize; + PVOID CallContext; + PVOID ObjectContext; + PVOID Reserved; +} REG_SET_VALUE_KEY_INFORMATION, *PREG_SET_VALUE_KEY_INFORMATION; + +typedef struct _REG_DELETE_VALUE_KEY_INFORMATION { + PVOID Object; + PUNICODE_STRING ValueName; + PVOID CallContext; + PVOID ObjectContext; + PVOID Reserved; +} REG_DELETE_VALUE_KEY_INFORMATION, *PREG_DELETE_VALUE_KEY_INFORMATION; + +typedef struct _REG_SET_INFORMATION_KEY_INFORMATION { + PVOID Object; + KEY_SET_INFORMATION_CLASS KeySetInformationClass; + PVOID KeySetInformation; + ULONG KeySetInformationLength; + PVOID CallContext; + PVOID ObjectContext; + PVOID Reserved; +} REG_SET_INFORMATION_KEY_INFORMATION, *PREG_SET_INFORMATION_KEY_INFORMATION; + +typedef struct _REG_ENUMERATE_KEY_INFORMATION { + PVOID Object; + ULONG Index; + KEY_INFORMATION_CLASS KeyInformationClass; + PVOID KeyInformation; + ULONG Length; + PULONG ResultLength; + PVOID CallContext; + PVOID ObjectContext; + PVOID Reserved; +} REG_ENUMERATE_KEY_INFORMATION, *PREG_ENUMERATE_KEY_INFORMATION; + +typedef struct _REG_ENUMERATE_VALUE_KEY_INFORMATION { + PVOID Object; + ULONG Index; + KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass; + PVOID KeyValueInformation; + ULONG Length; + PULONG ResultLength; + PVOID CallContext; + PVOID ObjectContext; + PVOID Reserved; +} REG_ENUMERATE_VALUE_KEY_INFORMATION, *PREG_ENUMERATE_VALUE_KEY_INFORMATION; + +typedef struct _REG_QUERY_KEY_INFORMATION { + PVOID Object; + KEY_INFORMATION_CLASS KeyInformationClass; + PVOID KeyInformation; + ULONG Length; + PULONG ResultLength; + PVOID CallContext; + PVOID ObjectContext; + PVOID Reserved; +} REG_QUERY_KEY_INFORMATION, *PREG_QUERY_KEY_INFORMATION; + +typedef struct _REG_QUERY_VALUE_KEY_INFORMATION { + PVOID Object; + PUNICODE_STRING ValueName; + KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass; + PVOID KeyValueInformation; + ULONG Length; + PULONG ResultLength; + PVOID CallContext; + PVOID ObjectContext; + PVOID Reserved; +} REG_QUERY_VALUE_KEY_INFORMATION, *PREG_QUERY_VALUE_KEY_INFORMATION; + +typedef struct _REG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION { + PVOID Object; + PKEY_VALUE_ENTRY ValueEntries; + ULONG EntryCount; + PVOID ValueBuffer; + PULONG BufferLength; + PULONG RequiredBufferLength; + PVOID CallContext; + PVOID ObjectContext; + PVOID Reserved; +} REG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION, *PREG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION; + +typedef struct _REG_RENAME_KEY_INFORMATION { + PVOID Object; + PUNICODE_STRING NewName; + PVOID CallContext; + PVOID ObjectContext; + PVOID Reserved; +} REG_RENAME_KEY_INFORMATION, *PREG_RENAME_KEY_INFORMATION; + +typedef struct _REG_CREATE_KEY_INFORMATION { + PUNICODE_STRING CompleteName; + PVOID RootObject; + PVOID ObjectType; + ULONG CreateOptions; + PUNICODE_STRING Class; + PVOID SecurityDescriptor; + PVOID SecurityQualityOfService; + ACCESS_MASK DesiredAccess; + ACCESS_MASK GrantedAccess; + PULONG Disposition; + PVOID *ResultObject; + PVOID CallContext; + PVOID RootObjectContext; + PVOID Transaction; + PVOID Reserved; +} REG_CREATE_KEY_INFORMATION, REG_OPEN_KEY_INFORMATION,*PREG_CREATE_KEY_INFORMATION, *PREG_OPEN_KEY_INFORMATION; + +typedef struct _REG_CREATE_KEY_INFORMATION_V1 { + PUNICODE_STRING CompleteName; + PVOID RootObject; + PVOID ObjectType; + ULONG Options; + PUNICODE_STRING Class; + PVOID SecurityDescriptor; + PVOID SecurityQualityOfService; + ACCESS_MASK DesiredAccess; + ACCESS_MASK GrantedAccess; + PULONG Disposition; + PVOID *ResultObject; + PVOID CallContext; + PVOID RootObjectContext; + PVOID Transaction; + ULONG_PTR Version; + PUNICODE_STRING RemainingName; + ULONG Wow64Flags; + ULONG Attributes; + KPROCESSOR_MODE CheckAccessMode; +} REG_CREATE_KEY_INFORMATION_V1, REG_OPEN_KEY_INFORMATION_V1,*PREG_CREATE_KEY_INFORMATION_V1, *PREG_OPEN_KEY_INFORMATION_V1; + +typedef struct _REG_PRE_CREATE_KEY_INFORMATION { + PUNICODE_STRING CompleteName; +} REG_PRE_CREATE_KEY_INFORMATION, REG_PRE_OPEN_KEY_INFORMATION,*PREG_PRE_CREATE_KEY_INFORMATION, *PREG_PRE_OPEN_KEY_INFORMATION;; + +typedef struct _REG_POST_CREATE_KEY_INFORMATION { + PUNICODE_STRING CompleteName; + PVOID Object; + NTSTATUS Status; +} REG_POST_CREATE_KEY_INFORMATION,REG_POST_OPEN_KEY_INFORMATION, *PREG_POST_CREATE_KEY_INFORMATION, *PREG_POST_OPEN_KEY_INFORMATION; + +typedef struct _REG_POST_OPERATION_INFORMATION { + PVOID Object; + NTSTATUS Status; + PVOID PreInformation; + NTSTATUS ReturnStatus; + PVOID CallContext; + PVOID ObjectContext; + PVOID Reserved; +} REG_POST_OPERATION_INFORMATION,*PREG_POST_OPERATION_INFORMATION; + +typedef struct _REG_KEY_HANDLE_CLOSE_INFORMATION { + PVOID Object; + PVOID CallContext; + PVOID ObjectContext; + PVOID Reserved; +} REG_KEY_HANDLE_CLOSE_INFORMATION, *PREG_KEY_HANDLE_CLOSE_INFORMATION; + +#if (NTDDI_VERSION >= NTDDI_VISTA) + +typedef struct _REG_LOAD_KEY_INFORMATION { + PVOID Object; + PUNICODE_STRING KeyName; + PUNICODE_STRING SourceFile; + ULONG Flags; + PVOID TrustClassObject; + PVOID UserEvent; + ACCESS_MASK DesiredAccess; + PHANDLE RootHandle; + PVOID CallContext; + PVOID ObjectContext; + PVOID Reserved; +} REG_LOAD_KEY_INFORMATION, *PREG_LOAD_KEY_INFORMATION; + +typedef struct _REG_UNLOAD_KEY_INFORMATION { + PVOID Object; + PVOID UserEvent; + PVOID CallContext; + PVOID ObjectContext; + PVOID Reserved; +} REG_UNLOAD_KEY_INFORMATION, *PREG_UNLOAD_KEY_INFORMATION; + +typedef struct _REG_CALLBACK_CONTEXT_CLEANUP_INFORMATION { + PVOID Object; + PVOID ObjectContext; + PVOID Reserved; +} REG_CALLBACK_CONTEXT_CLEANUP_INFORMATION, *PREG_CALLBACK_CONTEXT_CLEANUP_INFORMATION; + +typedef struct _REG_QUERY_KEY_SECURITY_INFORMATION { + PVOID Object; + PSECURITY_INFORMATION SecurityInformation; + PSECURITY_DESCRIPTOR SecurityDescriptor; + PULONG Length; + PVOID CallContext; + PVOID ObjectContext; + PVOID Reserved; +} REG_QUERY_KEY_SECURITY_INFORMATION, *PREG_QUERY_KEY_SECURITY_INFORMATION; + +typedef struct _REG_SET_KEY_SECURITY_INFORMATION { + PVOID Object; + PSECURITY_INFORMATION SecurityInformation; + PSECURITY_DESCRIPTOR SecurityDescriptor; + PVOID CallContext; + PVOID ObjectContext; + PVOID Reserved; +} REG_SET_KEY_SECURITY_INFORMATION, *PREG_SET_KEY_SECURITY_INFORMATION; + +typedef struct _REG_RESTORE_KEY_INFORMATION { + PVOID Object; + HANDLE FileHandle; + ULONG Flags; + PVOID CallContext; + PVOID ObjectContext; + PVOID Reserved; +} REG_RESTORE_KEY_INFORMATION, *PREG_RESTORE_KEY_INFORMATION; + +typedef struct _REG_SAVE_KEY_INFORMATION { + PVOID Object; + HANDLE FileHandle; + ULONG Format; + PVOID CallContext; + PVOID ObjectContext; + PVOID Reserved; +} REG_SAVE_KEY_INFORMATION, *PREG_SAVE_KEY_INFORMATION; + +typedef struct _REG_REPLACE_KEY_INFORMATION { + PVOID Object; + PUNICODE_STRING OldFileName; + PUNICODE_STRING NewFileName; + PVOID CallContext; + PVOID ObjectContext; + PVOID Reserved; +} REG_REPLACE_KEY_INFORMATION, *PREG_REPLACE_KEY_INFORMATION; + +#endif /* NTDDI_VERSION >= NTDDI_VISTA */ + +#define SERVICE_KERNEL_DRIVER 0x00000001 +#define SERVICE_FILE_SYSTEM_DRIVER 0x00000002 +#define SERVICE_ADAPTER 0x00000004 +#define SERVICE_RECOGNIZER_DRIVER 0x00000008 + +#define SERVICE_DRIVER (SERVICE_KERNEL_DRIVER | \ + SERVICE_FILE_SYSTEM_DRIVER | \ + SERVICE_RECOGNIZER_DRIVER) + +#define SERVICE_WIN32_OWN_PROCESS 0x00000010 +#define SERVICE_WIN32_SHARE_PROCESS 0x00000020 +#define SERVICE_WIN32 (SERVICE_WIN32_OWN_PROCESS | \ + SERVICE_WIN32_SHARE_PROCESS) + +#define SERVICE_INTERACTIVE_PROCESS 0x00000100 + +#define SERVICE_TYPE_ALL (SERVICE_WIN32 | \ + SERVICE_ADAPTER | \ + SERVICE_DRIVER | \ + SERVICE_INTERACTIVE_PROCESS) + +/* Service Start Types */ +#define SERVICE_BOOT_START 0x00000000 +#define SERVICE_SYSTEM_START 0x00000001 +#define SERVICE_AUTO_START 0x00000002 +#define SERVICE_DEMAND_START 0x00000003 +#define SERVICE_DISABLED 0x00000004 + +#define SERVICE_ERROR_IGNORE 0x00000000 +#define SERVICE_ERROR_NORMAL 0x00000001 +#define SERVICE_ERROR_SEVERE 0x00000002 +#define SERVICE_ERROR_CRITICAL 0x00000003 + +typedef enum _CM_SERVICE_NODE_TYPE { + DriverType = SERVICE_KERNEL_DRIVER, + FileSystemType = SERVICE_FILE_SYSTEM_DRIVER, + Win32ServiceOwnProcess = SERVICE_WIN32_OWN_PROCESS, + Win32ServiceShareProcess = SERVICE_WIN32_SHARE_PROCESS, + AdapterType = SERVICE_ADAPTER, + RecognizerType = SERVICE_RECOGNIZER_DRIVER +} SERVICE_NODE_TYPE; + +typedef enum _CM_SERVICE_LOAD_TYPE { + BootLoad = SERVICE_BOOT_START, + SystemLoad = SERVICE_SYSTEM_START, + AutoLoad = SERVICE_AUTO_START, + DemandLoad = SERVICE_DEMAND_START, + DisableLoad = SERVICE_DISABLED +} SERVICE_LOAD_TYPE; + +typedef enum _CM_ERROR_CONTROL_TYPE { + IgnoreError = SERVICE_ERROR_IGNORE, + NormalError = SERVICE_ERROR_NORMAL, + SevereError = SERVICE_ERROR_SEVERE, + CriticalError = SERVICE_ERROR_CRITICAL +} SERVICE_ERROR_TYPE; + +#define CM_SERVICE_NETWORK_BOOT_LOAD 0x00000001 +#define CM_SERVICE_VIRTUAL_DISK_BOOT_LOAD 0x00000002 +#define CM_SERVICE_USB_DISK_BOOT_LOAD 0x00000004 + +#define CM_SERVICE_VALID_PROMOTION_MASK (CM_SERVICE_NETWORK_BOOT_LOAD | \ + CM_SERVICE_VIRTUAL_DISK_BOOT_LOAD | \ + CM_SERVICE_USB_DISK_BOOT_LOAD) + +$endif +$if (_NTDDK_) + +typedef struct _KEY_NAME_INFORMATION { + ULONG NameLength; + WCHAR Name[1]; +} KEY_NAME_INFORMATION, *PKEY_NAME_INFORMATION; + +typedef struct _KEY_CACHED_INFORMATION { + LARGE_INTEGER LastWriteTime; + ULONG TitleIndex; + ULONG SubKeys; + ULONG MaxNameLen; + ULONG Values; + ULONG MaxValueNameLen; + ULONG MaxValueDataLen; + ULONG NameLength; +} KEY_CACHED_INFORMATION, *PKEY_CACHED_INFORMATION; + +typedef struct _KEY_VIRTUALIZATION_INFORMATION { + ULONG VirtualizationCandidate:1; + ULONG VirtualizationEnabled:1; + ULONG VirtualTarget:1; + ULONG VirtualStore:1; + ULONG VirtualSource:1; + ULONG Reserved:27; +} KEY_VIRTUALIZATION_INFORMATION, *PKEY_VIRTUALIZATION_INFORMATION; + +#define CmResourceTypeMaximum 8 + +typedef struct _CM_PCCARD_DEVICE_DATA { + UCHAR Flags; + UCHAR ErrorCode; + USHORT Reserved; + ULONG BusData; + ULONG DeviceId; + ULONG LegacyBaseAddress; + UCHAR IRQMap[16]; +} CM_PCCARD_DEVICE_DATA, *PCM_PCCARD_DEVICE_DATA; + +$endif /* _NTDDK_ */ diff --git a/reactos/include/xdk/exfuncs.h b/reactos/include/xdk/exfuncs.h new file mode 100644 index 00000000000..46a5387733a --- /dev/null +++ b/reactos/include/xdk/exfuncs.h @@ -0,0 +1,1040 @@ +/****************************************************************************** + * Executive Functions * + ******************************************************************************/ +$if (_NTDDK_) +static __inline PVOID +ExAllocateFromZone( + IN PZONE_HEADER Zone) +{ + if (Zone->FreeList.Next) + Zone->FreeList.Next = Zone->FreeList.Next->Next; + return (PVOID) Zone->FreeList.Next; +} + +static __inline PVOID +ExFreeToZone( + IN PZONE_HEADER Zone, + IN PVOID Block) +{ + ((PSINGLE_LIST_ENTRY) Block)->Next = Zone->FreeList.Next; + Zone->FreeList.Next = ((PSINGLE_LIST_ENTRY) Block); + return ((PSINGLE_LIST_ENTRY) Block)->Next; +} + +/* + * PVOID + * ExInterlockedAllocateFromZone( + * IN PZONE_HEADER Zone, + * IN PKSPIN_LOCK Lock) + */ +#define ExInterlockedAllocateFromZone(Zone, Lock) \ + ((PVOID) ExInterlockedPopEntryList(&Zone->FreeList, Lock)) + +/* PVOID + * ExInterlockedFreeToZone( + * IN PZONE_HEADER Zone, + * IN PVOID Block, + * IN PKSPIN_LOCK Lock); + */ +#define ExInterlockedFreeToZone(Zone, Block, Lock) \ + ExInterlockedPushEntryList(&(Zone)->FreeList, (PSINGLE_LIST_ENTRY)(Block), Lock) + +/* + * BOOLEAN + * ExIsFullZone( + * IN PZONE_HEADER Zone) + */ +#define ExIsFullZone(Zone) \ + ((Zone)->FreeList.Next == (PSINGLE_LIST_ENTRY) NULL) + +/* BOOLEAN + * ExIsObjectInFirstZoneSegment( + * IN PZONE_HEADER Zone, + * IN PVOID Object); + */ +#define ExIsObjectInFirstZoneSegment(Zone,Object) \ + ((BOOLEAN)( ((PUCHAR)(Object) >= (PUCHAR)(Zone)->SegmentList.Next) && \ + ((PUCHAR)(Object) < (PUCHAR)(Zone)->SegmentList.Next + \ + (Zone)->TotalSegmentSize)) ) + +#define ExAcquireResourceExclusive ExAcquireResourceExclusiveLite +#define ExAcquireResourceShared ExAcquireResourceSharedLite +#define ExConvertExclusiveToShared ExConvertExclusiveToSharedLite +#define ExDeleteResource ExDeleteResourceLite +#define ExInitializeResource ExInitializeResourceLite +#define ExIsResourceAcquiredExclusive ExIsResourceAcquiredExclusiveLite +#define ExIsResourceAcquiredShared ExIsResourceAcquiredSharedLite +#define ExIsResourceAcquired ExIsResourceAcquiredSharedLite +#define ExReleaseResourceForThread ExReleaseResourceForThreadLite + +typedef enum _INTERLOCKED_RESULT { + ResultNegative = RESULT_NEGATIVE, + ResultZero = RESULT_ZERO, + ResultPositive = RESULT_POSITIVE +} INTERLOCKED_RESULT; + +#ifdef _X86_ +NTKERNELAPI +INTERLOCKED_RESULT +FASTCALL +Exfi386InterlockedIncrementLong( + IN OUT LONG volatile *Addend); + +NTKERNELAPI +INTERLOCKED_RESULT +FASTCALL +Exfi386InterlockedDecrementLong( + IN PLONG Addend); + +NTKERNELAPI +ULONG +FASTCALL +Exfi386InterlockedExchangeUlong( + IN PULONG Target, + IN ULONG Value); +#endif + +$endif + +$if (_WDMDDK_) +#define ExInterlockedIncrementLong(Addend,Lock) Exfi386InterlockedIncrementLong(Addend) +#define ExInterlockedDecrementLong(Addend,Lock) Exfi386InterlockedDecrementLong(Addend) +#define ExInterlockedExchangeUlong(Target, Value, Lock) Exfi386InterlockedExchangeUlong(Target, Value) + +#define ExAcquireSpinLock(Lock, OldIrql) KeAcquireSpinLock((Lock), (OldIrql)) +#define ExReleaseSpinLock(Lock, OldIrql) KeReleaseSpinLock((Lock), (OldIrql)) +#define ExAcquireSpinLockAtDpcLevel(Lock) KeAcquireSpinLockAtDpcLevel(Lock) +#define ExReleaseSpinLockFromDpcLevel(Lock) KeReleaseSpinLockFromDpcLevel(Lock) + +#define ExInitializeSListHead InitializeSListHead + +#if defined(_NTHAL_) && defined(_X86_) + +NTKERNELAPI +VOID +FASTCALL +ExiAcquireFastMutex( + IN OUT PFAST_MUTEX FastMutex); + +NTKERNELAPI +VOID +FASTCALL +ExiReleaseFastMutex( + IN OUT PFAST_MUTEX FastMutex); + +NTKERNELAPI +BOOLEAN +FASTCALL +ExiTryToAcquireFastMutex( + IN OUT PFAST_MUTEX FastMutex); + +#define ExAcquireFastMutex ExiAcquireFastMutex +#define ExReleaseFastMutex ExiReleaseFastMutex +#define ExTryToAcquireFastMutex ExiTryToAcquireFastMutex + +#else + +#if (NTDDI_VERSION >= NTDDI_WIN2K) + +NTKERNELAPI +VOID +FASTCALL +ExAcquireFastMutex( + IN OUT PFAST_MUTEX FastMutex); + +NTKERNELAPI +VOID +FASTCALL +ExReleaseFastMutex( + IN OUT PFAST_MUTEX FastMutex); + +NTKERNELAPI +BOOLEAN +FASTCALL +ExTryToAcquireFastMutex( + IN OUT PFAST_MUTEX FastMutex); + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ + +#endif /* defined(_NTHAL_) && defined(_X86_) */ + +#if defined(_X86_) +#define ExInterlockedAddUlong ExfInterlockedAddUlong +#define ExInterlockedInsertHeadList ExfInterlockedInsertHeadList +#define ExInterlockedInsertTailList ExfInterlockedInsertTailList +#define ExInterlockedRemoveHeadList ExfInterlockedRemoveHeadList +#define ExInterlockedPopEntryList ExfInterlockedPopEntryList +#define ExInterlockedPushEntryList ExfInterlockedPushEntryList +#endif /* defined(_X86_) */ + +#if defined(_WIN64) + +#if defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_) || \ + defined(_NTHAL_) || defined(_NTOSP_) +NTKERNELAPI +USHORT +ExQueryDepthSList(IN PSLIST_HEADER ListHead); +#else +FORCEINLINE +USHORT +ExQueryDepthSList(IN PSLIST_HEADER ListHead) +{ + return (USHORT)(ListHead->Alignment & 0xffff); +} +#endif + +NTKERNELAPI +PSLIST_ENTRY +ExpInterlockedFlushSList( + PSLIST_HEADER ListHead); + +NTKERNELAPI +PSLIST_ENTRY +ExpInterlockedPopEntrySList( + PSLIST_HEADER ListHead); + +NTKERNELAPI +PSLIST_ENTRY +ExpInterlockedPushEntrySList( + PSLIST_HEADER ListHead, + PSLIST_ENTRY ListEntry); + +#define ExInterlockedFlushSList(Head) \ + ExpInterlockedFlushSList(Head) +#define ExInterlockedPopEntrySList(Head, Lock) \ + ExpInterlockedPopEntrySList(Head) +#define ExInterlockedPushEntrySList(Head, Entry, Lock) \ + ExpInterlockedPushEntrySList(Head, Entry) + +#else /* !defined(_WIN64) */ + +#define ExQueryDepthSList(listhead) (listhead)->Depth + +NTKERNELAPI +PSINGLE_LIST_ENTRY +FASTCALL +ExInterlockedFlushSList( + IN OUT PSLIST_HEADER ListHead); + +#endif /* !defined(_WIN64) */ + +#if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_) + +NTKERNELAPI +PSINGLE_LIST_ENTRY +FASTCALL +ExInterlockedPopEntrySList( + IN PSLIST_HEADER ListHead, + IN PKSPIN_LOCK Lock); + +NTKERNELAPI +PSINGLE_LIST_ENTRY +FASTCALL +ExInterlockedPushEntrySList( + IN PSLIST_HEADER ListHead, + IN PSINGLE_LIST_ENTRY ListEntry, + IN PKSPIN_LOCK Lock); + +NTKERNELAPI +PVOID +NTAPI +ExAllocateFromPagedLookasideList( + IN OUT PPAGED_LOOKASIDE_LIST Lookaside); + +NTKERNELAPI +VOID +NTAPI +ExFreeToPagedLookasideList( + IN OUT PPAGED_LOOKASIDE_LIST Lookaside, + IN PVOID Entry); + +#else /* !_WIN2K_COMPAT_SLIST_USAGE */ + +#if !defined(_WIN64) +#define ExInterlockedPopEntrySList(_ListHead, _Lock) \ + InterlockedPopEntrySList(_ListHead) +#define ExInterlockedPushEntrySList(_ListHead, _ListEntry, _Lock) \ + InterlockedPushEntrySList(_ListHead, _ListEntry) +#endif + +static __inline +PVOID +ExAllocateFromPagedLookasideList( + IN OUT PPAGED_LOOKASIDE_LIST Lookaside) +{ + PVOID Entry; + + Lookaside->L.TotalAllocates++; + Entry = InterlockedPopEntrySList(&Lookaside->L.ListHead); + if (Entry == NULL) { + Lookaside->L.AllocateMisses++; + Entry = (Lookaside->L.Allocate)(Lookaside->L.Type, + Lookaside->L.Size, + Lookaside->L.Tag); + } + return Entry; +} + +static __inline +VOID +ExFreeToPagedLookasideList( + IN OUT PPAGED_LOOKASIDE_LIST Lookaside, + IN PVOID Entry) +{ + Lookaside->L.TotalFrees++; + if (ExQueryDepthSList(&Lookaside->L.ListHead) >= Lookaside->L.Depth) { + Lookaside->L.FreeMisses++; + (Lookaside->L.Free)(Entry); + } else { + InterlockedPushEntrySList(&Lookaside->L.ListHead, (PSLIST_ENTRY)Entry); + } +} + +#endif /* _WIN2K_COMPAT_SLIST_USAGE */ + + +/* ERESOURCE_THREAD + * ExGetCurrentResourceThread( + * VOID); + */ +#define ExGetCurrentResourceThread() ((ULONG_PTR)PsGetCurrentThread()) + +#define ExReleaseResource(R) (ExReleaseResourceLite(R)) + +/* VOID + * ExInitializeWorkItem( + * IN PWORK_QUEUE_ITEM Item, + * IN PWORKER_THREAD_ROUTINE Routine, + * IN PVOID Context) + */ +#define ExInitializeWorkItem(Item, Routine, Context) \ +{ \ + (Item)->WorkerRoutine = Routine; \ + (Item)->Parameter = Context; \ + (Item)->List.Flink = NULL; \ +} + +FORCEINLINE +VOID +ExInitializeFastMutex( + OUT PFAST_MUTEX FastMutex) +{ + FastMutex->Count = FM_LOCK_BIT; + FastMutex->Owner = NULL; + FastMutex->Contention = 0; + KeInitializeEvent(&FastMutex->Event, SynchronizationEvent, FALSE); + return; +} +$endif + +#if (NTDDI_VERSION >= NTDDI_WIN2K) +$if (_NTDDK_) +NTKERNELAPI +NTSTATUS +NTAPI +ExExtendZone( + IN OUT PZONE_HEADER Zone, + IN OUT PVOID Segment, + IN ULONG SegmentSize); + +NTKERNELAPI +NTSTATUS +NTAPI +ExInitializeZone( + OUT PZONE_HEADER Zone, + IN ULONG BlockSize, + IN OUT PVOID InitialSegment, + IN ULONG InitialSegmentSize); + +NTKERNELAPI +NTSTATUS +NTAPI +ExInterlockedExtendZone( + IN OUT PZONE_HEADER Zone, + IN OUT PVOID Segment, + IN ULONG SegmentSize, + IN OUT PKSPIN_LOCK Lock); + +NTKERNELAPI +NTSTATUS +NTAPI +ExUuidCreate( + OUT UUID *Uuid); + +NTKERNELAPI +DECLSPEC_NORETURN +VOID +NTAPI +ExRaiseAccessViolation(VOID); + +NTKERNELAPI +DECLSPEC_NORETURN +VOID +NTAPI +ExRaiseDatatypeMisalignment(VOID); +$endif + +$if (_WDMDDK_) +NTKERNELAPI +VOID +FASTCALL +ExAcquireFastMutexUnsafe( + IN OUT PFAST_MUTEX FastMutex); + +NTKERNELAPI +VOID +FASTCALL +ExReleaseFastMutexUnsafe( + IN OUT PFAST_MUTEX FastMutex); + +NTKERNELAPI +BOOLEAN +NTAPI +ExAcquireResourceExclusiveLite( + IN OUT PERESOURCE Resource, + IN BOOLEAN Wait); + +NTKERNELAPI +BOOLEAN +NTAPI +ExAcquireResourceSharedLite( + IN OUT PERESOURCE Resource, + IN BOOLEAN Wait); + +NTKERNELAPI +BOOLEAN +NTAPI +ExAcquireSharedStarveExclusive( + IN OUT PERESOURCE Resource, + IN BOOLEAN Wait); + +NTKERNELAPI +BOOLEAN +NTAPI +ExAcquireSharedWaitForExclusive( + IN OUT PERESOURCE Resource, + IN BOOLEAN Wait); + +NTKERNELAPI +PVOID +NTAPI +ExAllocatePool( + IN POOL_TYPE PoolType, + IN SIZE_T NumberOfBytes); + +NTKERNELAPI +PVOID +NTAPI +ExAllocatePoolWithQuota( + IN POOL_TYPE PoolType, + IN SIZE_T NumberOfBytes); + +NTKERNELAPI +PVOID +NTAPI +ExAllocatePoolWithQuotaTag( + IN POOL_TYPE PoolType, + IN SIZE_T NumberOfBytes, + IN ULONG Tag); + +#ifndef POOL_TAGGING +#define ExAllocatePoolWithQuotaTag(a,b,c) ExAllocatePoolWithQuota(a,b) +#endif + +NTKERNELAPI +PVOID +NTAPI +ExAllocatePoolWithTag( + IN POOL_TYPE PoolType, + IN SIZE_T NumberOfBytes, + IN ULONG Tag); + +#ifndef POOL_TAGGING +#define ExAllocatePoolWithTag(a,b,c) ExAllocatePool(a,b) +#endif + +NTKERNELAPI +PVOID +NTAPI +ExAllocatePoolWithTagPriority( + IN POOL_TYPE PoolType, + IN SIZE_T NumberOfBytes, + IN ULONG Tag, + IN EX_POOL_PRIORITY Priority); + +NTKERNELAPI +VOID +NTAPI +ExConvertExclusiveToSharedLite( + IN OUT PERESOURCE Resource); + +NTKERNELAPI +NTSTATUS +NTAPI +ExCreateCallback( + OUT PCALLBACK_OBJECT *CallbackObject, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN BOOLEAN Create, + IN BOOLEAN AllowMultipleCallbacks); + +NTKERNELAPI +VOID +NTAPI +ExDeleteNPagedLookasideList( + IN OUT PNPAGED_LOOKASIDE_LIST Lookaside); + +NTKERNELAPI +VOID +NTAPI +ExDeletePagedLookasideList( + IN PPAGED_LOOKASIDE_LIST Lookaside); + +NTKERNELAPI +NTSTATUS +NTAPI +ExDeleteResourceLite( + IN OUT PERESOURCE Resource); + +NTKERNELAPI +VOID +NTAPI +ExFreePool( + IN PVOID P); + +NTKERNELAPI +VOID +NTAPI +ExFreePoolWithTag( + IN PVOID P, + IN ULONG Tag); + +NTKERNELAPI +ULONG +NTAPI +ExGetExclusiveWaiterCount( + IN PERESOURCE Resource); + +NTKERNELAPI +KPROCESSOR_MODE +NTAPI +ExGetPreviousMode(VOID); + +NTKERNELAPI +ULONG +NTAPI +ExGetSharedWaiterCount( + IN PERESOURCE Resource); + +NTKERNELAPI +VOID +NTAPI +ExInitializeNPagedLookasideList( + IN PNPAGED_LOOKASIDE_LIST Lookaside, + IN PALLOCATE_FUNCTION Allocate OPTIONAL, + IN PFREE_FUNCTION Free OPTIONAL, + IN ULONG Flags, + IN SIZE_T Size, + IN ULONG Tag, + IN USHORT Depth); + +NTKERNELAPI +VOID +NTAPI +ExInitializePagedLookasideList( + IN PPAGED_LOOKASIDE_LIST Lookaside, + IN PALLOCATE_FUNCTION Allocate OPTIONAL, + IN PFREE_FUNCTION Free OPTIONAL, + IN ULONG Flags, + IN SIZE_T Size, + IN ULONG Tag, + IN USHORT Depth); + +NTKERNELAPI +NTSTATUS +NTAPI +ExInitializeResourceLite( + OUT PERESOURCE Resource); + +NTKERNELAPI +LARGE_INTEGER +NTAPI +ExInterlockedAddLargeInteger( + IN PLARGE_INTEGER Addend, + IN LARGE_INTEGER Increment, + IN PKSPIN_LOCK Lock); + +#if defined(_WIN64) +#define ExInterlockedAddLargeStatistic(Addend, Increment) \ + (VOID)InterlockedAdd64(&(Addend)->QuadPart, Increment) +#else +#define ExInterlockedAddLargeStatistic(Addend, Increment) \ + _InterlockedAddLargeStatistic((PLONGLONG)&(Addend)->QuadPart, Increment) +#endif + +NTKERNELAPI +ULONG +FASTCALL +ExInterlockedAddUlong( + IN PULONG Addend, + IN ULONG Increment, + IN OUT PKSPIN_LOCK Lock); + +#if defined(_AMD64_) || defined(_IA64_) + +#define ExInterlockedCompareExchange64(Destination, Exchange, Comperand, Lock) \ + InterlockedCompareExchange64(Destination, *(Exchange), *(Comperand)) + +#elif defined(_X86_) + +NTKERNELAPI +LONGLONG +FASTCALL +ExfInterlockedCompareExchange64( + IN OUT LONGLONG volatile *Destination, + IN PLONGLONG Exchange, + IN PLONGLONG Comperand); + +#define ExInterlockedCompareExchange64(Destination, Exchange, Comperand, Lock) \ + ExfInterlockedCompareExchange64(Destination, Exchange, Comperand) + +#else + +NTKERNELAPI +LONGLONG +FASTCALL +ExInterlockedCompareExchange64( + IN OUT LONGLONG volatile *Destination, + IN PLONGLONG Exchange, + IN PLONGLONG Comparand, + IN PKSPIN_LOCK Lock); + +#endif /* defined(_AMD64_) || defined(_IA64_) */ + +NTKERNELAPI +PLIST_ENTRY +FASTCALL +ExInterlockedInsertHeadList( + IN OUT PLIST_ENTRY ListHead, + IN OUT PLIST_ENTRY ListEntry, + IN OUT PKSPIN_LOCK Lock); + +NTKERNELAPI +PLIST_ENTRY +FASTCALL +ExInterlockedInsertTailList( + IN OUT PLIST_ENTRY ListHead, + IN OUT PLIST_ENTRY ListEntry, + IN OUT PKSPIN_LOCK Lock); + +NTKERNELAPI +PSINGLE_LIST_ENTRY +FASTCALL +ExInterlockedPopEntryList( + IN OUT PSINGLE_LIST_ENTRY ListHead, + IN OUT PKSPIN_LOCK Lock); + +NTKERNELAPI +PSINGLE_LIST_ENTRY +FASTCALL +ExInterlockedPushEntryList( + IN OUT PSINGLE_LIST_ENTRY ListHead, + IN OUT PSINGLE_LIST_ENTRY ListEntry, + IN OUT PKSPIN_LOCK Lock); + +NTKERNELAPI +PLIST_ENTRY +FASTCALL +ExInterlockedRemoveHeadList( + IN OUT PLIST_ENTRY ListHead, + IN OUT PKSPIN_LOCK Lock); + +NTKERNELAPI +BOOLEAN +NTAPI +ExIsProcessorFeaturePresent( + IN ULONG ProcessorFeature); + +NTKERNELAPI +BOOLEAN +NTAPI +ExIsResourceAcquiredExclusiveLite( + IN PERESOURCE Resource); + +NTKERNELAPI +ULONG +NTAPI +ExIsResourceAcquiredSharedLite( + IN PERESOURCE Resource); + +#define ExIsResourceAcquiredLite ExIsResourceAcquiredSharedLite + +NTKERNELAPI +VOID +NTAPI +ExLocalTimeToSystemTime( + IN PLARGE_INTEGER LocalTime, + OUT PLARGE_INTEGER SystemTime); + +NTKERNELAPI +VOID +NTAPI +ExNotifyCallback( + IN PCALLBACK_OBJECT CallbackObject, + IN PVOID Argument1 OPTIONAL, + IN PVOID Argument2 OPTIONAL); + +NTKERNELAPI +VOID +NTAPI +ExQueueWorkItem( + IN OUT PWORK_QUEUE_ITEM WorkItem, + IN WORK_QUEUE_TYPE QueueType); + +NTKERNELAPI +DECLSPEC_NORETURN +VOID +NTAPI +ExRaiseStatus( + IN NTSTATUS Status); + +NTKERNELAPI +PVOID +NTAPI +ExRegisterCallback( + IN PCALLBACK_OBJECT CallbackObject, + IN PCALLBACK_FUNCTION CallbackFunction, + IN PVOID CallbackContext OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +ExReinitializeResourceLite( + IN OUT PERESOURCE Resource); + +NTKERNELAPI +VOID +NTAPI +ExReleaseResourceForThreadLite( + IN OUT PERESOURCE Resource, + IN ERESOURCE_THREAD ResourceThreadId); + +NTKERNELAPI +VOID +FASTCALL +ExReleaseResourceLite( + IN OUT PERESOURCE Resource); + +NTKERNELAPI +VOID +NTAPI +ExSetResourceOwnerPointer( + IN OUT PERESOURCE Resource, + IN PVOID OwnerPointer); + +NTKERNELAPI +ULONG +NTAPI +ExSetTimerResolution( + IN ULONG DesiredTime, + IN BOOLEAN SetResolution); + +NTKERNELAPI +VOID +NTAPI +ExSystemTimeToLocalTime( + IN PLARGE_INTEGER SystemTime, + OUT PLARGE_INTEGER LocalTime); + +NTKERNELAPI +VOID +NTAPI +ExUnregisterCallback( + IN OUT PVOID CbRegistration); +$endif + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ + +$if (_WDMDDK_) +#if (NTDDI_VERSION >= NTDDI_WINXP) + +NTKERNELAPI +BOOLEAN +FASTCALL +ExAcquireRundownProtection( + IN OUT PEX_RUNDOWN_REF RunRef); + +NTKERNELAPI +VOID +FASTCALL +ExInitializeRundownProtection( + OUT PEX_RUNDOWN_REF RunRef); + +NTKERNELAPI +VOID +FASTCALL +ExReInitializeRundownProtection( + IN OUT PEX_RUNDOWN_REF RunRef); + +NTKERNELAPI +VOID +FASTCALL +ExReleaseRundownProtection( + IN OUT PEX_RUNDOWN_REF RunRef); + +NTKERNELAPI +VOID +FASTCALL +ExRundownCompleted( + OUT PEX_RUNDOWN_REF RunRef); + +NTKERNELAPI +BOOLEAN +NTAPI +ExVerifySuite( + IN SUITE_TYPE SuiteType); + +NTKERNELAPI +VOID +FASTCALL +ExWaitForRundownProtectionRelease( + IN OUT PEX_RUNDOWN_REF RunRef); + +#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ + +#if (NTDDI_VERSION >= NTDDI_WINXPSP2) + +NTKERNELAPI +BOOLEAN +FASTCALL +ExAcquireRundownProtectionEx( + IN OUT PEX_RUNDOWN_REF RunRef, + IN ULONG Count); + +NTKERNELAPI +VOID +FASTCALL +ExReleaseRundownProtectionEx( + IN OUT PEX_RUNDOWN_REF RunRef, + IN ULONG Count); + +#endif /* (NTDDI_VERSION >= NTDDI_WINXPSP2) */ + +#if (NTDDI_VERSION >= NTDDI_WS03SP1) + +NTKERNELAPI +PEX_RUNDOWN_REF_CACHE_AWARE +NTAPI +ExAllocateCacheAwareRundownProtection( + IN POOL_TYPE PoolType, + IN ULONG PoolTag); + +NTKERNELAPI +SIZE_T +NTAPI +ExSizeOfRundownProtectionCacheAware(VOID); + +NTKERNELAPI +PVOID +NTAPI +ExEnterCriticalRegionAndAcquireResourceShared( + IN OUT PERESOURCE Resource); + +NTKERNELAPI +PVOID +NTAPI +ExEnterCriticalRegionAndAcquireResourceExclusive( + IN OUT PERESOURCE Resource); + +NTKERNELAPI +PVOID +NTAPI +ExEnterCriticalRegionAndAcquireSharedWaitForExclusive( + IN OUT PERESOURCE Resource); + +NTKERNELAPI +VOID +FASTCALL +ExReleaseResourceAndLeaveCriticalRegion( + IN OUT PERESOURCE Resource); + +NTKERNELAPI +VOID +NTAPI +ExInitializeRundownProtectionCacheAware( + OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware, + IN SIZE_T RunRefSize); + +NTKERNELAPI +VOID +NTAPI +ExFreeCacheAwareRundownProtection( + IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware); + +NTKERNELAPI +BOOLEAN +FASTCALL +ExAcquireRundownProtectionCacheAware( + IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware); + +NTKERNELAPI +VOID +FASTCALL +ExReleaseRundownProtectionCacheAware( + IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware); + +NTKERNELAPI +BOOLEAN +FASTCALL +ExAcquireRundownProtectionCacheAwareEx( + IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware, + IN ULONG Count); + +NTKERNELAPI +VOID +FASTCALL +ExReleaseRundownProtectionCacheAwareEx( + IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRef, + IN ULONG Count); + +NTKERNELAPI +VOID +FASTCALL +ExWaitForRundownProtectionReleaseCacheAware( + IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRef); + +NTKERNELAPI +VOID +FASTCALL +ExReInitializeRundownProtectionCacheAware( + IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware); + +NTKERNELAPI +VOID +FASTCALL +ExRundownCompletedCacheAware( + IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware); + +#endif /* (NTDDI_VERSION >= NTDDI_WS03SP1) */ + +#if (NTDDI_VERSION >= NTDDI_VISTA) + +NTKERNELAPI +NTSTATUS +NTAPI +ExInitializeLookasideListEx( + OUT PLOOKASIDE_LIST_EX Lookaside, + IN PALLOCATE_FUNCTION_EX Allocate OPTIONAL, + IN PFREE_FUNCTION_EX Free OPTIONAL, + IN POOL_TYPE PoolType, + IN ULONG Flags, + IN SIZE_T Size, + IN ULONG Tag, + IN USHORT Depth); + +NTKERNELAPI +VOID +NTAPI +ExDeleteLookasideListEx( + IN OUT PLOOKASIDE_LIST_EX Lookaside); + +NTKERNELAPI +VOID +NTAPI +ExFlushLookasideListEx( + IN OUT PLOOKASIDE_LIST_EX Lookaside); + +FORCEINLINE +PVOID +ExAllocateFromLookasideListEx( + IN OUT PLOOKASIDE_LIST_EX Lookaside) +{ + PVOID Entry; + + Lookaside->L.TotalAllocates += 1; + Entry = InterlockedPopEntrySList(&Lookaside->L.ListHead); + if (Entry == NULL) { + Lookaside->L.AllocateMisses += 1; + Entry = (Lookaside->L.AllocateEx)(Lookaside->L.Type, + Lookaside->L.Size, + Lookaside->L.Tag, + Lookaside); + } + return Entry; +} + +FORCEINLINE +VOID +ExFreeToLookasideListEx( + IN OUT PLOOKASIDE_LIST_EX Lookaside, + IN PVOID Entry) +{ + Lookaside->L.TotalFrees += 1; + if (ExQueryDepthSList(&Lookaside->L.ListHead) >= Lookaside->L.Depth) { + Lookaside->L.FreeMisses += 1; + (Lookaside->L.FreeEx)(Entry, Lookaside); + } else { + InterlockedPushEntrySList(&Lookaside->L.ListHead, (PSLIST_ENTRY)Entry); + } + return; +} + +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + +#if (NTDDI_VERSION >= NTDDI_WIN7) + +NTKERNELAPI +VOID +NTAPI +ExSetResourceOwnerPointerEx( + IN OUT PERESOURCE Resource, + IN PVOID OwnerPointer, + IN ULONG Flags); + +#define FLAG_OWNER_POINTER_IS_THREAD 0x1 + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + +static __inline PVOID +ExAllocateFromNPagedLookasideList( + IN OUT PNPAGED_LOOKASIDE_LIST Lookaside) +{ + PVOID Entry; + + Lookaside->L.TotalAllocates++; +#if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_) + Entry = ExInterlockedPopEntrySList(&Lookaside->L.ListHead, + &Lookaside->Lock__ObsoleteButDoNotDelete); +#else + Entry = InterlockedPopEntrySList(&Lookaside->L.ListHead); +#endif + if (Entry == NULL) { + Lookaside->L.AllocateMisses++; + Entry = (Lookaside->L.Allocate)(Lookaside->L.Type, + Lookaside->L.Size, + Lookaside->L.Tag); + } + return Entry; +} + +static __inline VOID +ExFreeToNPagedLookasideList( + IN OUT PNPAGED_LOOKASIDE_LIST Lookaside, + IN PVOID Entry) +{ + Lookaside->L.TotalFrees++; + if (ExQueryDepthSList(&Lookaside->L.ListHead) >= Lookaside->L.Depth) { + Lookaside->L.FreeMisses++; + (Lookaside->L.Free)(Entry); + } else { +#if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_) + ExInterlockedPushEntrySList(&Lookaside->L.ListHead, + (PSLIST_ENTRY)Entry, + &Lookaside->Lock__ObsoleteButDoNotDelete); +#else + InterlockedPushEntrySList(&Lookaside->L.ListHead, (PSLIST_ENTRY)Entry); +#endif + } +} + +$endif + diff --git a/reactos/include/xdk/extypes.h b/reactos/include/xdk/extypes.h new file mode 100644 index 00000000000..4d18ac12f04 --- /dev/null +++ b/reactos/include/xdk/extypes.h @@ -0,0 +1,289 @@ +/****************************************************************************** + * Executive Types * + ******************************************************************************/ +$if (_WDMDDK_) + +#define EX_RUNDOWN_ACTIVE 0x1 +#define EX_RUNDOWN_COUNT_SHIFT 0x1 +#define EX_RUNDOWN_COUNT_INC (1 << EX_RUNDOWN_COUNT_SHIFT) + +typedef struct _FAST_MUTEX { + volatile LONG Count; + PKTHREAD Owner; + ULONG Contention; + KEVENT Event; + ULONG OldIrql; +} FAST_MUTEX, *PFAST_MUTEX; + +typedef enum _SUITE_TYPE { + SmallBusiness, + Enterprise, + BackOffice, + CommunicationServer, + TerminalServer, + SmallBusinessRestricted, + EmbeddedNT, + DataCenter, + SingleUserTS, + Personal, + Blade, + EmbeddedRestricted, + SecurityAppliance, + StorageServer, + ComputeServer, + WHServer, + MaxSuiteType +} SUITE_TYPE; + +typedef enum _EX_POOL_PRIORITY { + LowPoolPriority, + LowPoolPrioritySpecialPoolOverrun = 8, + LowPoolPrioritySpecialPoolUnderrun = 9, + NormalPoolPriority = 16, + NormalPoolPrioritySpecialPoolOverrun = 24, + NormalPoolPrioritySpecialPoolUnderrun = 25, + HighPoolPriority = 32, + HighPoolPrioritySpecialPoolOverrun = 40, + HighPoolPrioritySpecialPoolUnderrun = 41 +} EX_POOL_PRIORITY; + +#if !defined(_WIN64) && (defined(_NTDDK_) || defined(_NTIFS_) || defined(_NDIS_)) +#define LOOKASIDE_ALIGN +#else +#define LOOKASIDE_ALIGN /* FIXME: DECLSPEC_CACHEALIGN */ +#endif + +typedef struct _LOOKASIDE_LIST_EX *PLOOKASIDE_LIST_EX; + +typedef PVOID +(NTAPI *PALLOCATE_FUNCTION)( + IN POOL_TYPE PoolType, + IN SIZE_T NumberOfBytes, + IN ULONG Tag); + +typedef PVOID +(NTAPI *PALLOCATE_FUNCTION_EX)( + IN POOL_TYPE PoolType, + IN SIZE_T NumberOfBytes, + IN ULONG Tag, + IN OUT PLOOKASIDE_LIST_EX Lookaside); + +typedef VOID +(NTAPI *PFREE_FUNCTION)( + IN PVOID Buffer); + +typedef VOID +(NTAPI *PFREE_FUNCTION_EX)( + IN PVOID Buffer, + IN OUT PLOOKASIDE_LIST_EX Lookaside); + +typedef VOID +(NTAPI CALLBACK_FUNCTION)( + IN PVOID CallbackContext OPTIONAL, + IN PVOID Argument1 OPTIONAL, + IN PVOID Argument2 OPTIONAL); +typedef CALLBACK_FUNCTION *PCALLBACK_FUNCTION; + +#define GENERAL_LOOKASIDE_LAYOUT \ + union { \ + SLIST_HEADER ListHead; \ + SINGLE_LIST_ENTRY SingleListHead; \ + } DUMMYUNIONNAME; \ + USHORT Depth; \ + USHORT MaximumDepth; \ + ULONG TotalAllocates; \ + union { \ + ULONG AllocateMisses; \ + ULONG AllocateHits; \ + } DUMMYUNIONNAME2; \ + \ + ULONG TotalFrees; \ + union { \ + ULONG FreeMisses; \ + ULONG FreeHits; \ + } DUMMYUNIONNAME3; \ + \ + POOL_TYPE Type; \ + ULONG Tag; \ + ULONG Size; \ + union { \ + PALLOCATE_FUNCTION_EX AllocateEx; \ + PALLOCATE_FUNCTION Allocate; \ + } DUMMYUNIONNAME4; \ + \ + union { \ + PFREE_FUNCTION_EX FreeEx; \ + PFREE_FUNCTION Free; \ + } DUMMYUNIONNAME5; \ + \ + LIST_ENTRY ListEntry; \ + ULONG LastTotalAllocates; \ + union { \ + ULONG LastAllocateMisses; \ + ULONG LastAllocateHits; \ + } DUMMYUNIONNAME6; \ + ULONG Future[2]; + +typedef struct LOOKASIDE_ALIGN _GENERAL_LOOKASIDE { + GENERAL_LOOKASIDE_LAYOUT +} GENERAL_LOOKASIDE, *PGENERAL_LOOKASIDE; + +typedef struct _GENERAL_LOOKASIDE_POOL { + GENERAL_LOOKASIDE_LAYOUT +} GENERAL_LOOKASIDE_POOL, *PGENERAL_LOOKASIDE_POOL; + +#define LOOKASIDE_CHECK(f) \ + C_ASSERT(FIELD_OFFSET(GENERAL_LOOKASIDE,f) == FIELD_OFFSET(GENERAL_LOOKASIDE_POOL,f)) + +LOOKASIDE_CHECK(TotalFrees); +LOOKASIDE_CHECK(Tag); +LOOKASIDE_CHECK(Future); + +typedef struct _PAGED_LOOKASIDE_LIST { + GENERAL_LOOKASIDE L; +#if !defined(_AMD64_) && !defined(_IA64_) + FAST_MUTEX Lock__ObsoleteButDoNotDelete; +#endif +} PAGED_LOOKASIDE_LIST, *PPAGED_LOOKASIDE_LIST; + +typedef struct LOOKASIDE_ALIGN _NPAGED_LOOKASIDE_LIST { + GENERAL_LOOKASIDE L; +#if !defined(_AMD64_) && !defined(_IA64_) + KSPIN_LOCK Lock__ObsoleteButDoNotDelete; +#endif +} NPAGED_LOOKASIDE_LIST, *PNPAGED_LOOKASIDE_LIST; + +#define LOOKASIDE_MINIMUM_BLOCK_SIZE (RTL_SIZEOF_THROUGH_FIELD (SLIST_ENTRY, Next)) + +typedef struct _LOOKASIDE_LIST_EX { + GENERAL_LOOKASIDE_POOL L; +} LOOKASIDE_LIST_EX; + +#if (NTDDI_VERSION >= NTDDI_VISTA) + +#define EX_LOOKASIDE_LIST_EX_FLAGS_RAISE_ON_FAIL 0x00000001UL +#define EX_LOOKASIDE_LIST_EX_FLAGS_FAIL_NO_RAISE 0x00000002UL + +#define EX_MAXIMUM_LOOKASIDE_DEPTH_BASE 256 +#define EX_MAXIMUM_LOOKASIDE_DEPTH_LIMIT 1024 + +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + +typedef struct _EX_RUNDOWN_REF { + __GNU_EXTENSION union { + volatile ULONG_PTR Count; + volatile PVOID Ptr; + }; +} EX_RUNDOWN_REF, *PEX_RUNDOWN_REF; + +typedef struct _EX_RUNDOWN_REF_CACHE_AWARE *PEX_RUNDOWN_REF_CACHE_AWARE; + +typedef enum _WORK_QUEUE_TYPE { + CriticalWorkQueue, + DelayedWorkQueue, + HyperCriticalWorkQueue, + MaximumWorkQueue +} WORK_QUEUE_TYPE; + +typedef VOID +(NTAPI WORKER_THREAD_ROUTINE)( + IN PVOID Parameter); +typedef WORKER_THREAD_ROUTINE *PWORKER_THREAD_ROUTINE; + +typedef struct _WORK_QUEUE_ITEM { + LIST_ENTRY List; + PWORKER_THREAD_ROUTINE WorkerRoutine; + volatile PVOID Parameter; +} WORK_QUEUE_ITEM, *PWORK_QUEUE_ITEM; + +typedef ULONG_PTR ERESOURCE_THREAD, *PERESOURCE_THREAD; + +typedef struct _OWNER_ENTRY { + ERESOURCE_THREAD OwnerThread; + union { + struct { + ULONG IoPriorityBoosted:1; + ULONG OwnerReferenced:1; + ULONG OwnerCount:30; + }; + ULONG TableSize; + }; +} OWNER_ENTRY, *POWNER_ENTRY; + +typedef struct _ERESOURCE { + LIST_ENTRY SystemResourcesList; + POWNER_ENTRY OwnerTable; + SHORT ActiveCount; + USHORT Flag; + volatile PKSEMAPHORE SharedWaiters; + volatile PKEVENT ExclusiveWaiters; + OWNER_ENTRY OwnerEntry; + ULONG ActiveEntries; + ULONG ContentionCount; + ULONG NumberOfSharedWaiters; + ULONG NumberOfExclusiveWaiters; +#if defined(_WIN64) + PVOID Reserved2; +#endif + __GNU_EXTENSION union { + PVOID Address; + ULONG_PTR CreatorBackTraceIndex; + }; + KSPIN_LOCK SpinLock; +} ERESOURCE, *PERESOURCE; + +/* ERESOURCE.Flag */ +#define ResourceNeverExclusive 0x0010 +#define ResourceReleaseByOtherThread 0x0020 +#define ResourceOwnedExclusive 0x0080 + +#define RESOURCE_HASH_TABLE_SIZE 64 + +typedef struct _RESOURCE_HASH_ENTRY { + LIST_ENTRY ListEntry; + PVOID Address; + ULONG ContentionCount; + ULONG Number; +} RESOURCE_HASH_ENTRY, *PRESOURCE_HASH_ENTRY; + +typedef struct _RESOURCE_PERFORMANCE_DATA { + ULONG ActiveResourceCount; + ULONG TotalResourceCount; + ULONG ExclusiveAcquire; + ULONG SharedFirstLevel; + ULONG SharedSecondLevel; + ULONG StarveFirstLevel; + ULONG StarveSecondLevel; + ULONG WaitForExclusive; + ULONG OwnerTableExpands; + ULONG MaximumTableExpand; + LIST_ENTRY HashTable[RESOURCE_HASH_TABLE_SIZE]; +} RESOURCE_PERFORMANCE_DATA, *PRESOURCE_PERFORMANCE_DATA; + +/* Global debug flag */ +#if DEVL +extern ULONG NtGlobalFlag; +#define IF_NTOS_DEBUG(FlagName) if (NtGlobalFlag & (FLG_##FlagName)) +#else +#define IF_NTOS_DEBUG(FlagName) if(FALSE) +#endif + +$endif /* _WDMDDK_ */ +$if (_NTDDK_) + +typedef struct _ZONE_SEGMENT_HEADER { + SINGLE_LIST_ENTRY SegmentList; + PVOID Reserved; +} ZONE_SEGMENT_HEADER, *PZONE_SEGMENT_HEADER; + +typedef struct _ZONE_HEADER { + SINGLE_LIST_ENTRY FreeList; + SINGLE_LIST_ENTRY SegmentList; + ULONG BlockSize; + ULONG TotalSegmentSize; +} ZONE_HEADER, *PZONE_HEADER; + +#define PROTECTED_POOL 0x80000000 + +$endif /* _NTDDK_ */ + diff --git a/reactos/include/xdk/generate.bat b/reactos/include/xdk/generate.bat new file mode 100644 index 00000000000..e26f34aa105 --- /dev/null +++ b/reactos/include/xdk/generate.bat @@ -0,0 +1,4 @@ + + +..\..\output-i386\tools\hpp\hpp.exe wdm.template.h wdm.h +..\..\output-i386\tools\hpp\hpp.exe ntddk.template.h ntddk.h diff --git a/reactos/include/xdk/halfuncs.h b/reactos/include/xdk/halfuncs.h new file mode 100644 index 00000000000..547f4e4b7ce --- /dev/null +++ b/reactos/include/xdk/halfuncs.h @@ -0,0 +1,346 @@ +/* Hardware Abstraction Layer Functions */ + +#if (NTDDI_VERSION >= NTDDI_WIN2K) + +#if defined(USE_DMA_MACROS) && !defined(_NTHAL_) && (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_) +$if (_WDMDDK_) + +FORCEINLINE +PVOID +NTAPI +HalAllocateCommonBuffer( + IN PDMA_ADAPTER DmaAdapter, + IN ULONG Length, + OUT PPHYSICAL_ADDRESS LogicalAddress, + IN BOOLEAN CacheEnabled) +{ + PALLOCATE_COMMON_BUFFER allocateCommonBuffer; + PVOID commonBuffer; + + allocateCommonBuffer = *(DmaAdapter)->DmaOperations->AllocateCommonBuffer; + ASSERT( allocateCommonBuffer != NULL ); + commonBuffer = allocateCommonBuffer( DmaAdapter, Length, LogicalAddress, CacheEnabled ); + return commonBuffer; +} + +FORCEINLINE +VOID +NTAPI +HalFreeCommonBuffer( + IN PDMA_ADAPTER DmaAdapter, + IN ULONG Length, + IN PHYSICAL_ADDRESS LogicalAddress, + IN PVOID VirtualAddress, + IN BOOLEAN CacheEnabled) +{ + PFREE_COMMON_BUFFER freeCommonBuffer; + + freeCommonBuffer = *(DmaAdapter)->DmaOperations->FreeCommonBuffer; + ASSERT( freeCommonBuffer != NULL ); + freeCommonBuffer( DmaAdapter, Length, LogicalAddress, VirtualAddress, CacheEnabled ); +} + +FORCEINLINE +ULONG +NTAPI +HalReadDmaCounter( + IN PDMA_ADAPTER DmaAdapter) +{ + PREAD_DMA_COUNTER readDmaCounter; + ULONG counter; + + readDmaCounter = *(DmaAdapter)->DmaOperations->ReadDmaCounter; + ASSERT( readDmaCounter != NULL ); + counter = readDmaCounter( DmaAdapter ); + return counter; +} + +FORCEINLINE +ULONG +HalGetDmaAlignment( + IN PDMA_ADAPTER DmaAdapter) +{ + PGET_DMA_ALIGNMENT getDmaAlignment; + ULONG alignment; + + getDmaAlignment = *(DmaAdapter)->DmaOperations->GetDmaAlignment; + ASSERT( getDmaAlignment != NULL ); + alignment = getDmaAlignment( DmaAdapter ); + return alignment; +} + +$endif +$if (_NTDDK_) + +/* Nothing here */ + +#else /* USE_DMA_MACROS ... */ + +//DECLSPEC_DEPRECATED_DDK +NTHALAPI +VOID +NTAPI +IoFreeAdapterChannel( + IN PADAPTER_OBJECT AdapterObject); + +//DECLSPEC_DEPRECATED_DDK +NTHALAPI +BOOLEAN +NTAPI +IoFlushAdapterBuffers( + IN PADAPTER_OBJECT AdapterObject, + IN PMDL Mdl, + IN PVOID MapRegisterBase, + IN PVOID CurrentVa, + IN ULONG Length, + IN BOOLEAN WriteToDevice); + +//DECLSPEC_DEPRECATED_DDK +NTHALAPI +VOID +NTAPI +IoFreeMapRegisters( + IN PADAPTER_OBJECT AdapterObject, + IN PVOID MapRegisterBase, + IN ULONG NumberOfMapRegisters); + +//DECLSPEC_DEPRECATED_DDK +NTHALAPI +PVOID +NTAPI +HalAllocateCommonBuffer( + IN PADAPTER_OBJECT AdapterObject, + IN ULONG Length, + OUT PPHYSICAL_ADDRESS LogicalAddress, + IN BOOLEAN CacheEnabled); + +//DECLSPEC_DEPRECATED_DDK +NTHALAPI +VOID +NTAPI +HalFreeCommonBuffer( + IN PADAPTER_OBJECT AdapterObject, + IN ULONG Length, + IN PHYSICAL_ADDRESS LogicalAddress, + IN PVOID VirtualAddress, + IN BOOLEAN CacheEnabled); + +//DECLSPEC_DEPRECATED_DDK +NTHALAPI +ULONG +NTAPI +HalReadDmaCounter( + IN PADAPTER_OBJECT AdapterObject); + +NTHALAPI +NTSTATUS +NTAPI +HalAllocateAdapterChannel( + IN PADAPTER_OBJECT AdapterObject, + IN PWAIT_CONTEXT_BLOCK Wcb, + IN ULONG NumberOfMapRegisters, + IN PDRIVER_CONTROL ExecutionRoutine); + +$endif /* _NTDDK_ */ +#endif /* USE_DMA_MACROS ... */ +$if (_NTDDK_) + +#if !defined(NO_LEGACY_DRIVERS) +NTHALAPI +NTSTATUS +NTAPI +HalAssignSlotResources( + IN PUNICODE_STRING RegistryPath, + IN PUNICODE_STRING DriverClassName, + IN PDRIVER_OBJECT DriverObject, + IN PDEVICE_OBJECT DeviceObject, + IN INTERFACE_TYPE BusType, + IN ULONG BusNumber, + IN ULONG SlotNumber, + IN OUT PCM_RESOURCE_LIST *AllocatedResources); + +NTHALAPI +ULONG +NTAPI +HalGetInterruptVector( + IN INTERFACE_TYPE InterfaceType, + IN ULONG BusNumber, + IN ULONG BusInterruptLevel, + IN ULONG BusInterruptVector, + OUT PKIRQL Irql, + OUT PKAFFINITY Affinity); + +NTHALAPI +ULONG +NTAPI +HalSetBusData( + IN BUS_DATA_TYPE BusDataType, + IN ULONG BusNumber, + IN ULONG SlotNumber, + IN PVOID Buffer, + IN ULONG Length); + +NTHALAPI +ULONG +NTAPI +HalGetBusData( + IN BUS_DATA_TYPE BusDataType, + IN ULONG BusNumber, + IN ULONG SlotNumber, + OUT PVOID Buffer, + IN ULONG Length); + +NTHALAPI +BOOLEAN +NTAPI +HalMakeBeep( + IN ULONG Frequency); +#endif /* !defined(NO_LEGACY_DRIVERS) */ + +NTHALAPI +PADAPTER_OBJECT +NTAPI +HalGetAdapter( + IN PDEVICE_DESCRIPTION DeviceDescription, + OUT PULONG NumberOfMapRegisters); + +VOID +NTAPI +HalPutDmaAdapter( + IN PADAPTER_OBJECT DmaAdapter); + +NTHALAPI +VOID +NTAPI +HalAcquireDisplayOwnership( + IN PHAL_RESET_DISPLAY_PARAMETERS ResetDisplayParameters); + +NTHALAPI +ULONG +NTAPI +HalGetBusDataByOffset( + IN BUS_DATA_TYPE BusDataType, + IN ULONG BusNumber, + IN ULONG SlotNumber, + OUT PVOID Buffer, + IN ULONG Offset, + IN ULONG Length); + +NTHALAPI +ULONG +NTAPI +HalSetBusDataByOffset( + IN BUS_DATA_TYPE BusDataType, + IN ULONG BusNumber, + IN ULONG SlotNumber, + IN PVOID Buffer, + IN ULONG Offset, + IN ULONG Length); + +NTHALAPI +BOOLEAN +NTAPI +HalTranslateBusAddress( + IN INTERFACE_TYPE InterfaceType, + IN ULONG BusNumber, + IN PHYSICAL_ADDRESS BusAddress, + IN OUT PULONG AddressSpace, + OUT PPHYSICAL_ADDRESS TranslatedAddress); + +NTHALAPI +PVOID +NTAPI +HalAllocateCrashDumpRegisters( + IN PADAPTER_OBJECT AdapterObject, + IN OUT PULONG NumberOfMapRegisters); + +NTSTATUS +NTAPI +HalGetScatterGatherList( + IN PADAPTER_OBJECT DmaAdapter, + IN PDEVICE_OBJECT DeviceObject, + IN PMDL Mdl, + IN PVOID CurrentVa, + IN ULONG Length, + IN PDRIVER_LIST_CONTROL ExecutionRoutine, + IN PVOID Context, + IN BOOLEAN WriteToDevice); + +VOID +NTAPI +HalPutScatterGatherList( + IN PADAPTER_OBJECT DmaAdapter, + IN PSCATTER_GATHER_LIST ScatterGather, + IN BOOLEAN WriteToDevice); + +$endif /* _NTDDK_ */ +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ +$if (_NTDDK_) + +#if (NTDDI_VERSION >= NTDDI_WINXP) +NTKERNELAPI +VOID +FASTCALL +HalExamineMBR( + IN PDEVICE_OBJECT DeviceObject, + IN ULONG SectorSize, + IN ULONG MBRTypeIdentifier, + OUT PVOID *Buffer); +#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ + +#if (NTDDI_VERSION >= NTDDI_WIN7) + +NTSTATUS +NTAPI +HalAllocateHardwareCounters( + IN PGROUP_AFFINITY GroupAffinty, + IN ULONG GroupCount, + IN PPHYSICAL_COUNTER_RESOURCE_LIST ResourceList, + OUT PHANDLE CounterSetHandle); + +NTSTATUS +NTAPI +HalFreeHardwareCounters( + IN HANDLE CounterSetHandle); + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + +#if defined(_IA64_) +#if (NTDDI_VERSION >= NTDDI_WIN2K) +NTHALAPI +ULONG +NTAPI +HalGetDmaAlignmentRequirement(VOID); +#endif +#endif /* defined(_IA64_) */ + +#if defined(_M_IX86) || defined(_M_AMD64) +#define HalGetDmaAlignmentRequirement() 1L +#endif + +#if (NTDDI_VERSION >= NTDDI_WIN7) + +typedef struct _WHEA_ERROR_SOURCE_DESCRIPTOR *PWHEA_ERROR_SOURCE_DESCRIPTOR; +typedef struct _WHEA_ERROR_RECORD *PWHEA_ERROR_RECORD; + +NTHALAPI +VOID +NTAPI +HalBugCheckSystem( + IN PWHEA_ERROR_SOURCE_DESCRIPTOR ErrorSource, + IN PWHEA_ERROR_RECORD ErrorRecord); + +#else + +typedef struct _WHEA_ERROR_RECORD *PWHEA_ERROR_RECORD; + +NTHALAPI +VOID +NTAPI +HalBugCheckSystem( + IN PWHEA_ERROR_RECORD ErrorRecord); + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + +$endif /* _NTDDK_ */ + diff --git a/reactos/include/xdk/haltypes.h b/reactos/include/xdk/haltypes.h new file mode 100644 index 00000000000..a9a031776fd --- /dev/null +++ b/reactos/include/xdk/haltypes.h @@ -0,0 +1,551 @@ +/* Hardware Abstraction Layer Types */ + +$if (_NTDDK_) +typedef BOOLEAN +(NTAPI *PHAL_RESET_DISPLAY_PARAMETERS)( + IN ULONG Columns, + IN ULONG Rows); + +typedef PBUS_HANDLER +(FASTCALL *pHalHandlerForBus)( + IN INTERFACE_TYPE InterfaceType, + IN ULONG BusNumber); + +typedef VOID +(FASTCALL *pHalReferenceBusHandler)( + IN PBUS_HANDLER BusHandler); + +typedef enum _HAL_QUERY_INFORMATION_CLASS { + HalInstalledBusInformation, + HalProfileSourceInformation, + HalInformationClassUnused1, + HalPowerInformation, + HalProcessorSpeedInformation, + HalCallbackInformation, + HalMapRegisterInformation, + HalMcaLogInformation, + HalFrameBufferCachingInformation, + HalDisplayBiosInformation, + HalProcessorFeatureInformation, + HalNumaTopologyInterface, + HalErrorInformation, + HalCmcLogInformation, + HalCpeLogInformation, + HalQueryMcaInterface, + HalQueryAMLIIllegalIOPortAddresses, + HalQueryMaxHotPlugMemoryAddress, + HalPartitionIpiInterface, + HalPlatformInformation, + HalQueryProfileSourceList, + HalInitLogInformation, + HalFrequencyInformation, + HalProcessorBrandString, + HalHypervisorInformation, + HalPlatformTimerInformation, + HalAcpiAuditInformation +} HAL_QUERY_INFORMATION_CLASS, *PHAL_QUERY_INFORMATION_CLASS; + +typedef enum _HAL_SET_INFORMATION_CLASS { + HalProfileSourceInterval, + HalProfileSourceInterruptHandler, + HalMcaRegisterDriver, + HalKernelErrorHandler, + HalCmcRegisterDriver, + HalCpeRegisterDriver, + HalMcaLog, + HalCmcLog, + HalCpeLog, + HalGenerateCmcInterrupt, + HalProfileSourceTimerHandler, + HalEnlightenment, + HalProfileDpgoSourceInterruptHandler +} HAL_SET_INFORMATION_CLASS, *PHAL_SET_INFORMATION_CLASS; + +typedef NTSTATUS +(NTAPI *pHalQuerySystemInformation)( + IN HAL_QUERY_INFORMATION_CLASS InformationClass, + IN ULONG BufferSize, + IN OUT PVOID Buffer, + OUT PULONG ReturnedLength); + +typedef NTSTATUS +(NTAPI *pHalSetSystemInformation)( + IN HAL_SET_INFORMATION_CLASS InformationClass, + IN ULONG BufferSize, + IN PVOID Buffer); + +typedef VOID +(FASTCALL *pHalExamineMBR)( + IN PDEVICE_OBJECT DeviceObject, + IN ULONG SectorSize, + IN ULONG MBRTypeIdentifier, + OUT PVOID *Buffer); + +typedef NTSTATUS +(FASTCALL *pHalIoReadPartitionTable)( + IN PDEVICE_OBJECT DeviceObject, + IN ULONG SectorSize, + IN BOOLEAN ReturnRecognizedPartitions, + OUT struct _DRIVE_LAYOUT_INFORMATION **PartitionBuffer); + +typedef NTSTATUS +(FASTCALL *pHalIoSetPartitionInformation)( + IN PDEVICE_OBJECT DeviceObject, + IN ULONG SectorSize, + IN ULONG PartitionNumber, + IN ULONG PartitionType); + +typedef NTSTATUS +(FASTCALL *pHalIoWritePartitionTable)( + IN PDEVICE_OBJECT DeviceObject, + IN ULONG SectorSize, + IN ULONG SectorsPerTrack, + IN ULONG NumberOfHeads, + IN struct _DRIVE_LAYOUT_INFORMATION *PartitionBuffer); + +typedef NTSTATUS +(NTAPI *pHalQueryBusSlots)( + IN PBUS_HANDLER BusHandler, + IN ULONG BufferSize, + OUT PULONG SlotNumbers, + OUT PULONG ReturnedLength); + +typedef NTSTATUS +(NTAPI *pHalInitPnpDriver)( + VOID); + +typedef struct _PM_DISPATCH_TABLE { + ULONG Signature; + ULONG Version; + PVOID Function[1]; +} PM_DISPATCH_TABLE, *PPM_DISPATCH_TABLE; + +typedef NTSTATUS +(NTAPI *pHalInitPowerManagement)( + IN PPM_DISPATCH_TABLE PmDriverDispatchTable, + OUT PPM_DISPATCH_TABLE *PmHalDispatchTable); + +typedef struct _DMA_ADAPTER* +(NTAPI *pHalGetDmaAdapter)( + IN PVOID Context, + IN struct _DEVICE_DESCRIPTION *DeviceDescriptor, + OUT PULONG NumberOfMapRegisters); + +typedef NTSTATUS +(NTAPI *pHalGetInterruptTranslator)( + IN INTERFACE_TYPE ParentInterfaceType, + IN ULONG ParentBusNumber, + IN INTERFACE_TYPE BridgeInterfaceType, + IN USHORT Size, + IN USHORT Version, + OUT PTRANSLATOR_INTERFACE Translator, + OUT PULONG BridgeBusNumber); + +typedef NTSTATUS +(NTAPI *pHalStartMirroring)( + VOID); + +typedef NTSTATUS +(NTAPI *pHalEndMirroring)( + IN ULONG PassNumber); + +typedef NTSTATUS +(NTAPI *pHalMirrorPhysicalMemory)( + IN PHYSICAL_ADDRESS PhysicalAddress, + IN LARGE_INTEGER NumberOfBytes); + +typedef NTSTATUS +(NTAPI *pHalMirrorVerify)( + IN PHYSICAL_ADDRESS PhysicalAddress, + IN LARGE_INTEGER NumberOfBytes); + +typedef BOOLEAN +(NTAPI *pHalTranslateBusAddress)( + IN INTERFACE_TYPE InterfaceType, + IN ULONG BusNumber, + IN PHYSICAL_ADDRESS BusAddress, + IN OUT PULONG AddressSpace, + OUT PPHYSICAL_ADDRESS TranslatedAddress); + +typedef NTSTATUS +(NTAPI *pHalAssignSlotResources)( + IN PUNICODE_STRING RegistryPath, + IN PUNICODE_STRING DriverClassName OPTIONAL, + IN PDRIVER_OBJECT DriverObject, + IN PDEVICE_OBJECT DeviceObject, + IN INTERFACE_TYPE BusType, + IN ULONG BusNumber, + IN ULONG SlotNumber, + IN OUT PCM_RESOURCE_LIST *AllocatedResources); + +typedef VOID +(NTAPI *pHalHaltSystem)( + VOID); + +typedef BOOLEAN +(NTAPI *pHalResetDisplay)( + VOID); + +typedef struct _MAP_REGISTER_ENTRY { + PVOID MapRegister; + BOOLEAN WriteToDevice; +} MAP_REGISTER_ENTRY, *PMAP_REGISTER_ENTRY; + +typedef UCHAR +(NTAPI *pHalVectorToIDTEntry)( + ULONG Vector); + +typedef BOOLEAN +(NTAPI *pHalFindBusAddressTranslation)( + IN PHYSICAL_ADDRESS BusAddress, + IN OUT PULONG AddressSpace, + OUT PPHYSICAL_ADDRESS TranslatedAddress, + IN OUT PULONG_PTR Context, + IN BOOLEAN NextBus); + +typedef VOID +(NTAPI *pHalEndOfBoot)( + VOID); + +typedef PVOID +(NTAPI *pHalGetAcpiTable)( + IN ULONG Signature, + IN PCSTR OemId OPTIONAL, + IN PCSTR OemTableId OPTIONAL); + +#if defined(_IA64_) +typedef NTSTATUS +(*pHalGetErrorCapList)( + IN OUT PULONG CapsListLength, + IN OUT PUCHAR ErrorCapList); + +typedef NTSTATUS +(*pHalInjectError)( + IN ULONG BufferLength, + IN PUCHAR Buffer); +#endif + +typedef VOID +(NTAPI *PCI_ERROR_HANDLER_CALLBACK)( + VOID); + +typedef VOID +(NTAPI *pHalSetPciErrorHandlerCallback)( + IN PCI_ERROR_HANDLER_CALLBACK Callback); + +#if 1 /* Not present in WDK 7600 */ +typedef VOID +(FASTCALL *pHalIoAssignDriveLetters)( + IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock, + IN PSTRING NtDeviceName, + OUT PUCHAR NtSystemPath, + OUT PSTRING NtSystemPathString); +#endif + +typedef struct { + ULONG Version; + pHalQuerySystemInformation HalQuerySystemInformation; + pHalSetSystemInformation HalSetSystemInformation; + pHalQueryBusSlots HalQueryBusSlots; + ULONG Spare1; + pHalExamineMBR HalExamineMBR; +#if 1 /* Not present in WDK 7600 */ + pHalIoAssignDriveLetters HalIoAssignDriveLetters; +#endif + pHalIoReadPartitionTable HalIoReadPartitionTable; + pHalIoSetPartitionInformation HalIoSetPartitionInformation; + pHalIoWritePartitionTable HalIoWritePartitionTable; + pHalHandlerForBus HalReferenceHandlerForBus; + pHalReferenceBusHandler HalReferenceBusHandler; + pHalReferenceBusHandler HalDereferenceBusHandler; + pHalInitPnpDriver HalInitPnpDriver; + pHalInitPowerManagement HalInitPowerManagement; + pHalGetDmaAdapter HalGetDmaAdapter; + pHalGetInterruptTranslator HalGetInterruptTranslator; + pHalStartMirroring HalStartMirroring; + pHalEndMirroring HalEndMirroring; + pHalMirrorPhysicalMemory HalMirrorPhysicalMemory; + pHalEndOfBoot HalEndOfBoot; + pHalMirrorVerify HalMirrorVerify; + pHalGetAcpiTable HalGetCachedAcpiTable; + pHalSetPciErrorHandlerCallback HalSetPciErrorHandlerCallback; +#if defined(_IA64_) + pHalGetErrorCapList HalGetErrorCapList; + pHalInjectError HalInjectError; +#endif +} HAL_DISPATCH, *PHAL_DISPATCH; + +/* GCC/MSVC and WDK compatible declaration */ +extern NTKERNELAPI HAL_DISPATCH HalDispatchTable; + +#if defined(_NTOSKRNL_) || defined(_BLDR_) +#define HALDISPATCH (&HalDispatchTable) +#else +/* This is a WDK compatibility definition */ +#define HalDispatchTable (&HalDispatchTable) +#define HALDISPATCH HalDispatchTable +#endif + +#define HAL_DISPATCH_VERSION 3 /* FIXME: when to use 4? */ +#define HalDispatchTableVersion HALDISPATCH->Version +#define HalQuerySystemInformation HALDISPATCH->HalQuerySystemInformation +#define HalSetSystemInformation HALDISPATCH->HalSetSystemInformation +#define HalQueryBusSlots HALDISPATCH->HalQueryBusSlots +#define HalReferenceHandlerForBus HALDISPATCH->HalReferenceHandlerForBus +#define HalReferenceBusHandler HALDISPATCH->HalReferenceBusHandler +#define HalDereferenceBusHandler HALDISPATCH->HalDereferenceBusHandler +#define HalInitPnpDriver HALDISPATCH->HalInitPnpDriver +#define HalInitPowerManagement HALDISPATCH->HalInitPowerManagement +#define HalGetDmaAdapter HALDISPATCH->HalGetDmaAdapter +#define HalGetInterruptTranslator HALDISPATCH->HalGetInterruptTranslator +#define HalStartMirroring HALDISPATCH->HalStartMirroring +#define HalEndMirroring HALDISPATCH->HalEndMirroring +#define HalMirrorPhysicalMemory HALDISPATCH->HalMirrorPhysicalMemory +#define HalEndOfBoot HALDISPATCH->HalEndOfBoot +#define HalMirrorVerify HALDISPATCH->HalMirrorVerify +#define HalGetCachedAcpiTable HALDISPATCH->HalGetCachedAcpiTable +#define HalSetPciErrorHandlerCallback HALDISPATCH->HalSetPciErrorHandlerCallback +#if defined(_IA64_) +#define HalGetErrorCapList HALDISPATCH->HalGetErrorCapList +#define HalInjectError HALDISPATCH->HalInjectError +#endif + +typedef struct _HAL_BUS_INFORMATION { + INTERFACE_TYPE BusType; + BUS_DATA_TYPE ConfigurationType; + ULONG BusNumber; + ULONG Reserved; +} HAL_BUS_INFORMATION, *PHAL_BUS_INFORMATION; + +typedef struct _HAL_PROFILE_SOURCE_INFORMATION { + KPROFILE_SOURCE Source; + BOOLEAN Supported; + ULONG Interval; +} HAL_PROFILE_SOURCE_INFORMATION, *PHAL_PROFILE_SOURCE_INFORMATION; + +typedef struct _HAL_PROFILE_SOURCE_INFORMATION_EX { + KPROFILE_SOURCE Source; + BOOLEAN Supported; + ULONG_PTR Interval; + ULONG_PTR DefInterval; + ULONG_PTR MaxInterval; + ULONG_PTR MinInterval; +} HAL_PROFILE_SOURCE_INFORMATION_EX, *PHAL_PROFILE_SOURCE_INFORMATION_EX; + +typedef struct _HAL_PROFILE_SOURCE_INTERVAL { + KPROFILE_SOURCE Source; + ULONG_PTR Interval; +} HAL_PROFILE_SOURCE_INTERVAL, *PHAL_PROFILE_SOURCE_INTERVAL; + +typedef struct _HAL_PROFILE_SOURCE_LIST { + KPROFILE_SOURCE Source; + PWSTR Description; +} HAL_PROFILE_SOURCE_LIST, *PHAL_PROFILE_SOURCE_LIST; + +typedef enum _HAL_DISPLAY_BIOS_INFORMATION { + HalDisplayInt10Bios, + HalDisplayEmulatedBios, + HalDisplayNoBios +} HAL_DISPLAY_BIOS_INFORMATION, *PHAL_DISPLAY_BIOS_INFORMATION; + +typedef struct _HAL_POWER_INFORMATION { + ULONG TBD; +} HAL_POWER_INFORMATION, *PHAL_POWER_INFORMATION; + +typedef struct _HAL_PROCESSOR_SPEED_INFO { + ULONG ProcessorSpeed; +} HAL_PROCESSOR_SPEED_INFORMATION, *PHAL_PROCESSOR_SPEED_INFORMATION; + +typedef struct _HAL_CALLBACKS { + PCALLBACK_OBJECT SetSystemInformation; + PCALLBACK_OBJECT BusCheck; +} HAL_CALLBACKS, *PHAL_CALLBACKS; + +typedef struct _HAL_PROCESSOR_FEATURE { + ULONG UsableFeatureBits; +} HAL_PROCESSOR_FEATURE; + +typedef NTSTATUS +(NTAPI *PHALIOREADWRITEHANDLER)( + IN BOOLEAN fRead, + IN ULONG dwAddr, + IN ULONG dwSize, + IN OUT PULONG pdwData); + +typedef struct _HAL_AMLI_BAD_IO_ADDRESS_LIST { + ULONG BadAddrBegin; + ULONG BadAddrSize; + ULONG OSVersionTrigger; + PHALIOREADWRITEHANDLER IOHandler; +} HAL_AMLI_BAD_IO_ADDRESS_LIST, *PHAL_AMLI_BAD_IO_ADDRESS_LIST; + +#if defined(_X86_) || defined(_IA64_) || defined(_AMD64_) + +typedef VOID +(NTAPI *PHALMCAINTERFACELOCK)( + VOID); + +typedef VOID +(NTAPI *PHALMCAINTERFACEUNLOCK)( + VOID); + +typedef NTSTATUS +(NTAPI *PHALMCAINTERFACEREADREGISTER)( + IN UCHAR BankNumber, + IN OUT PVOID Exception); + +typedef struct _HAL_MCA_INTERFACE { + PHALMCAINTERFACELOCK Lock; + PHALMCAINTERFACEUNLOCK Unlock; + PHALMCAINTERFACEREADREGISTER ReadRegister; +} HAL_MCA_INTERFACE; + +typedef enum { + ApicDestinationModePhysical = 1, + ApicDestinationModeLogicalFlat, + ApicDestinationModeLogicalClustered, + ApicDestinationModeUnknown +} HAL_APIC_DESTINATION_MODE, *PHAL_APIC_DESTINATION_MODE; + +#if defined(_AMD64_) + +struct _KTRAP_FRAME; +struct _KEXCEPTION_FRAME; + +typedef ERROR_SEVERITY +(NTAPI *PDRIVER_EXCPTN_CALLBACK)( + IN PVOID Context, + IN struct _KTRAP_FRAME *TrapFrame, + IN struct _KEXCEPTION_FRAME *ExceptionFrame, + IN PMCA_EXCEPTION Exception); + +#endif + +#if defined(_X86_) || defined(_IA64_) +typedef +#if defined(_IA64_) +ERROR_SEVERITY +#else +VOID +#endif +(NTAPI *PDRIVER_EXCPTN_CALLBACK)( + IN PVOID Context, + IN PMCA_EXCEPTION BankLog); +#endif + +typedef PDRIVER_EXCPTN_CALLBACK PDRIVER_MCA_EXCEPTION_CALLBACK; + +typedef struct _MCA_DRIVER_INFO { + PDRIVER_MCA_EXCEPTION_CALLBACK ExceptionCallback; + PKDEFERRED_ROUTINE DpcCallback; + PVOID DeviceContext; +} MCA_DRIVER_INFO, *PMCA_DRIVER_INFO; + +typedef struct _HAL_ERROR_INFO { + ULONG Version; + ULONG InitMaxSize; + ULONG McaMaxSize; + ULONG McaPreviousEventsCount; + ULONG McaCorrectedEventsCount; + ULONG McaKernelDeliveryFails; + ULONG McaDriverDpcQueueFails; + ULONG McaReserved; + ULONG CmcMaxSize; + ULONG CmcPollingInterval; + ULONG CmcInterruptsCount; + ULONG CmcKernelDeliveryFails; + ULONG CmcDriverDpcQueueFails; + ULONG CmcGetStateFails; + ULONG CmcClearStateFails; + ULONG CmcReserved; + ULONGLONG CmcLogId; + ULONG CpeMaxSize; + ULONG CpePollingInterval; + ULONG CpeInterruptsCount; + ULONG CpeKernelDeliveryFails; + ULONG CpeDriverDpcQueueFails; + ULONG CpeGetStateFails; + ULONG CpeClearStateFails; + ULONG CpeInterruptSources; + ULONGLONG CpeLogId; + ULONGLONG KernelReserved[4]; +} HAL_ERROR_INFO, *PHAL_ERROR_INFO; + +#define HAL_MCE_INTERRUPTS_BASED ((ULONG)-1) +#define HAL_MCE_DISABLED ((ULONG)0) + +#define HAL_CMC_INTERRUPTS_BASED HAL_MCE_INTERRUPTS_BASED +#define HAL_CMC_DISABLED HAL_MCE_DISABLED + +#define HAL_CPE_INTERRUPTS_BASED HAL_MCE_INTERRUPTS_BASED +#define HAL_CPE_DISABLED HAL_MCE_DISABLED + +#define HAL_MCA_INTERRUPTS_BASED HAL_MCE_INTERRUPTS_BASED +#define HAL_MCA_DISABLED HAL_MCE_DISABLED + +typedef VOID +(NTAPI *PDRIVER_CMC_EXCEPTION_CALLBACK)( + IN PVOID Context, + IN PCMC_EXCEPTION CmcLog); + +typedef VOID +(NTAPI *PDRIVER_CPE_EXCEPTION_CALLBACK)( + IN PVOID Context, + IN PCPE_EXCEPTION CmcLog); + +typedef struct _CMC_DRIVER_INFO { + PDRIVER_CMC_EXCEPTION_CALLBACK ExceptionCallback; + PKDEFERRED_ROUTINE DpcCallback; + PVOID DeviceContext; +} CMC_DRIVER_INFO, *PCMC_DRIVER_INFO; + +typedef struct _CPE_DRIVER_INFO { + PDRIVER_CPE_EXCEPTION_CALLBACK ExceptionCallback; + PKDEFERRED_ROUTINE DpcCallback; + PVOID DeviceContext; +} CPE_DRIVER_INFO, *PCPE_DRIVER_INFO; + +#endif // defined(_X86_) || defined(_IA64_) || defined(_AMD64_) + +#if defined(_IA64_) + +typedef NTSTATUS +(*HALSENDCROSSPARTITIONIPI)( + IN USHORT ProcessorID, + IN UCHAR HardwareVector); + +typedef NTSTATUS +(*HALRESERVECROSSPARTITIONINTERRUPTVECTOR)( + OUT PULONG Vector, + OUT PKIRQL Irql, + IN OUT PGROUP_AFFINITY Affinity, + OUT PUCHAR HardwareVector); + +typedef VOID +(*HALFREECROSSPARTITIONINTERRUPTVECTOR)( + IN ULONG Vector, + IN PGROUP_AFFINITY Affinity); + +typedef struct _HAL_CROSS_PARTITION_IPI_INTERFACE { + HALSENDCROSSPARTITIONIPI HalSendCrossPartitionIpi; + HALRESERVECROSSPARTITIONINTERRUPTVECTOR HalReserveCrossPartitionInterruptVector; + HALFREECROSSPARTITIONINTERRUPTVECTOR HalFreeCrossPartitionInterruptVector; +} HAL_CROSS_PARTITION_IPI_INTERFACE; + +#define HAL_CROSS_PARTITION_IPI_INTERFACE_MINIMUM_SIZE \ + FIELD_OFFSET(HAL_CROSS_PARTITION_IPI_INTERFACE, \ + HalFreeCrossPartitionInterruptVector) + +#endif /* defined(_IA64_) */ + +typedef struct _HAL_PLATFORM_INFORMATION { + ULONG PlatformFlags; +} HAL_PLATFORM_INFORMATION, *PHAL_PLATFORM_INFORMATION; + +#define HAL_PLATFORM_DISABLE_WRITE_COMBINING 0x01L +#define HAL_PLATFORM_DISABLE_PTCG 0x04L +#define HAL_PLATFORM_DISABLE_UC_MAIN_MEMORY 0x08L +#define HAL_PLATFORM_ENABLE_WRITE_COMBINING_MMIO 0x10L +#define HAL_PLATFORM_ACPI_TABLES_CACHED 0x20L +$endif + diff --git a/reactos/include/xdk/ia64/ke.h b/reactos/include/xdk/ia64/ke.h new file mode 100644 index 00000000000..2920636bf54 --- /dev/null +++ b/reactos/include/xdk/ia64/ke.h @@ -0,0 +1,38 @@ +$if (_WDMDDK_) +/** Kernel definitions for IA64 **/ + +/* Interrupt request levels */ +#define PASSIVE_LEVEL 0 +#define LOW_LEVEL 0 +#define APC_LEVEL 1 +#define DISPATCH_LEVEL 2 +#define CMC_LEVEL 3 +#define DEVICE_LEVEL_BASE 4 +#define PC_LEVEL 12 +#define IPI_LEVEL 14 +#define DRS_LEVEL 14 +#define CLOCK_LEVEL 13 +#define POWER_LEVEL 15 +#define PROFILE_LEVEL 15 +#define HIGH_LEVEL 15 + +#define KI_USER_SHARED_DATA ((ULONG_PTR)(KADDRESS_BASE + 0xFFFE0000)) +extern volatile LARGE_INTEGER KeTickCount; + +#define PAUSE_PROCESSOR __yield(); + +FORCEINLINE +VOID +KeFlushWriteBuffer(VOID) +{ + __mf (); + return; +} + +NTSYSAPI +PKTHREAD +NTAPI +KeGetCurrentThread(VOID); + +$endif + diff --git a/reactos/include/xdk/interlocked.h b/reactos/include/xdk/interlocked.h new file mode 100644 index 00000000000..722096bf18e --- /dev/null +++ b/reactos/include/xdk/interlocked.h @@ -0,0 +1,193 @@ +/****************************************************************************** + * INTERLOCKED Functions * + ******************************************************************************/ +// +// Intrinsics (note: taken from our winnt.h) +// FIXME: 64-bit +// +#if defined(__GNUC__) + +static __inline__ BOOLEAN +InterlockedBitTestAndSet( + IN LONG volatile *Base, + IN LONG Bit) +{ +#if defined(_M_IX86) + LONG OldBit; + __asm__ __volatile__("lock " + "btsl %2,%1\n\t" + "sbbl %0,%0\n\t" + :"=r" (OldBit),"+m" (*Base) + :"Ir" (Bit) + : "memory"); + return OldBit; +#else + return (_InterlockedOr(Base, 1 << Bit) >> Bit) & 1; +#endif +} + +static __inline__ BOOLEAN +InterlockedBitTestAndReset( + IN LONG volatile *Base, + IN LONG Bit) +{ +#if defined(_M_IX86) + LONG OldBit; + __asm__ __volatile__("lock " + "btrl %2,%1\n\t" + "sbbl %0,%0\n\t" + :"=r" (OldBit),"+m" (*Base) + :"Ir" (Bit) + : "memory"); + return OldBit; +#else + return (_InterlockedAnd(Base, ~(1 << Bit)) >> Bit) & 1; +#endif +} + +#endif /* defined(__GNUC__) */ + +#define BitScanForward _BitScanForward +#define BitScanReverse _BitScanReverse +#define BitTest _bittest +#define BitTestAndComplement _bittestandcomplement +#define BitTestAndSet _bittestandset +#define BitTestAndReset _bittestandreset +#define InterlockedBitTestAndSet _interlockedbittestandset +#define InterlockedBitTestAndReset _interlockedbittestandreset + +#ifdef _M_AMD64 +#define BitTest64 _bittest64 +#define BitTestAndComplement64 _bittestandcomplement64 +#define BitTestAndSet64 _bittestandset64 +#define BitTestAndReset64 _bittestandreset64 +#define InterlockedBitTestAndSet64 _interlockedbittestandset64 +#define InterlockedBitTestAndReset64 _interlockedbittestandreset64 +#endif + +#if !defined(__INTERLOCKED_DECLARED) +#define __INTERLOCKED_DECLARED + +#if defined (_X86_) +#if defined(NO_INTERLOCKED_INTRINSICS) +NTKERNELAPI +LONG +FASTCALL +InterlockedIncrement( + IN OUT LONG volatile *Addend); + +NTKERNELAPI +LONG +FASTCALL +InterlockedDecrement( + IN OUT LONG volatile *Addend); + +NTKERNELAPI +LONG +FASTCALL +InterlockedCompareExchange( + IN OUT LONG volatile *Destination, + IN LONG Exchange, + IN LONG Comparand); + +NTKERNELAPI +LONG +FASTCALL +InterlockedExchange( + IN OUT LONG volatile *Destination, + IN LONG Value); + +NTKERNELAPI +LONG +FASTCALL +InterlockedExchangeAdd( + IN OUT LONG volatile *Addend, + IN LONG Value); + +#else /* !defined(NO_INTERLOCKED_INTRINSICS) */ + +#define InterlockedExchange _InterlockedExchange +#define InterlockedIncrement _InterlockedIncrement +#define InterlockedDecrement _InterlockedDecrement +#define InterlockedExchangeAdd _InterlockedExchangeAdd +#define InterlockedCompareExchange _InterlockedCompareExchange +#define InterlockedOr _InterlockedOr +#define InterlockedAnd _InterlockedAnd +#define InterlockedXor _InterlockedXor + +#endif /* !defined(NO_INTERLOCKED_INTRINSICS) */ + +#endif /* defined (_X86_) */ + +#if !defined (_WIN64) +/* + * PVOID + * InterlockedExchangePointer( + * IN OUT PVOID volatile *Target, + * IN PVOID Value) + */ +#define InterlockedExchangePointer(Target, Value) \ + ((PVOID) InterlockedExchange((PLONG) Target, (LONG) Value)) + +/* + * PVOID + * InterlockedCompareExchangePointer( + * IN OUT PVOID *Destination, + * IN PVOID Exchange, + * IN PVOID Comparand) + */ +#define InterlockedCompareExchangePointer(Destination, Exchange, Comparand) \ + ((PVOID) InterlockedCompareExchange((PLONG) Destination, (LONG) Exchange, (LONG) Comparand)) + +#define InterlockedExchangeAddSizeT(a, b) InterlockedExchangeAdd((LONG *)a, b) +#define InterlockedIncrementSizeT(a) InterlockedIncrement((LONG *)a) +#define InterlockedDecrementSizeT(a) InterlockedDecrement((LONG *)a) + +#endif // !defined (_WIN64) + +#if defined (_M_AMD64) + +#define InterlockedExchangeAddSizeT(a, b) InterlockedExchangeAdd64((LONGLONG *)a, (LONGLONG)b) +#define InterlockedIncrementSizeT(a) InterlockedIncrement64((LONGLONG *)a) +#define InterlockedDecrementSizeT(a) InterlockedDecrement64((LONGLONG *)a) +#define InterlockedAnd _InterlockedAnd +#define InterlockedOr _InterlockedOr +#define InterlockedXor _InterlockedXor +#define InterlockedIncrement _InterlockedIncrement +#define InterlockedDecrement _InterlockedDecrement +#define InterlockedAdd _InterlockedAdd +#define InterlockedExchange _InterlockedExchange +#define InterlockedExchangeAdd _InterlockedExchangeAdd +#define InterlockedCompareExchange _InterlockedCompareExchange +#define InterlockedAnd64 _InterlockedAnd64 +#define InterlockedOr64 _InterlockedOr64 +#define InterlockedXor64 _InterlockedXor64 +#define InterlockedIncrement64 _InterlockedIncrement64 +#define InterlockedDecrement64 _InterlockedDecrement64 +#define InterlockedAdd64 _InterlockedAdd64 +#define InterlockedExchange64 _InterlockedExchange64 +#define InterlockedExchangeAdd64 _InterlockedExchangeAdd64 +#define InterlockedCompareExchange64 _InterlockedCompareExchange64 +#define InterlockedCompareExchangePointer _InterlockedCompareExchangePointer +#define InterlockedExchangePointer _InterlockedExchangePointer +#define InterlockedBitTestAndSet64 _interlockedbittestandset64 +#define InterlockedBitTestAndReset64 _interlockedbittestandreset64 + +#endif // _M_AMD64 + +#if defined(_M_AMD64) && !defined(RC_INVOKED) && !defined(MIDL_PASS) +//#if !defined(_X86AMD64_) // FIXME: what's _X86AMD64_ used for? +FORCEINLINE +LONG64 +InterlockedAdd64( + IN OUT LONG64 volatile *Addend, + IN LONG64 Value) +{ + return InterlockedExchangeAdd64(Addend, Value) + Value; +} +//#endif +#endif + +#endif /* !__INTERLOCKED_DECLARED */ + + diff --git a/reactos/include/xdk/iofuncs.h b/reactos/include/xdk/iofuncs.h new file mode 100644 index 00000000000..a1a2fcf88ee --- /dev/null +++ b/reactos/include/xdk/iofuncs.h @@ -0,0 +1,2284 @@ +/****************************************************************************** + * I/O Manager Functions * + ******************************************************************************/ +$if (_NTDDK_) +/* + * VOID IoAssignArcName( + * IN PUNICODE_STRING ArcName, + * IN PUNICODE_STRING DeviceName); + */ +#define IoAssignArcName(_ArcName, _DeviceName) ( \ + IoCreateSymbolicLink((_ArcName), (_DeviceName))) + +/* + * VOID + * IoDeassignArcName( + * IN PUNICODE_STRING ArcName) + */ +#define IoDeassignArcName IoDeleteSymbolicLink + +VOID +FORCEINLINE +NTAPI +IoInitializeDriverCreateContext( + PIO_DRIVER_CREATE_CONTEXT DriverContext) +{ + RtlZeroMemory(DriverContext, sizeof(IO_DRIVER_CREATE_CONTEXT)); + DriverContext->Size = sizeof(IO_DRIVER_CREATE_CONTEXT); +} +$endif + + +$if (_WDMDDK_) +/* + * NTSTATUS + * IoAcquireRemoveLock( + * IN PIO_REMOVE_LOCK RemoveLock, + * IN OPTIONAL PVOID Tag) + */ +#if DBG +#define IoAcquireRemoveLock(RemoveLock, Tag) \ + IoAcquireRemoveLockEx(RemoveLock, Tag, __FILE__, __LINE__, sizeof (IO_REMOVE_LOCK)) +#else +#define IoAcquireRemoveLock(RemoveLock, Tag) \ + IoAcquireRemoveLockEx(RemoveLock, Tag, "", 1, sizeof (IO_REMOVE_LOCK)) +#endif + +/* + * VOID + * IoAdjustPagingPathCount( + * IN PLONG Count, + * IN BOOLEAN Increment) + */ +#define IoAdjustPagingPathCount(_Count, \ + _Increment) \ +{ \ + if (_Increment) \ + { \ + InterlockedIncrement(_Count); \ + } \ + else \ + { \ + InterlockedDecrement(_Count); \ + } \ +} + +#if !defined(_M_AMD64) +NTHALAPI +VOID +NTAPI +READ_PORT_BUFFER_UCHAR( + IN PUCHAR Port, + IN PUCHAR Buffer, + IN ULONG Count); + +NTHALAPI +VOID +NTAPI +READ_PORT_BUFFER_ULONG( + IN PULONG Port, + IN PULONG Buffer, + IN ULONG Count); + +NTHALAPI +VOID +NTAPI +READ_PORT_BUFFER_USHORT( + IN PUSHORT Port, + IN PUSHORT Buffer, + IN ULONG Count); + +NTHALAPI +UCHAR +NTAPI +READ_PORT_UCHAR( + IN PUCHAR Port); + +NTHALAPI +ULONG +NTAPI +READ_PORT_ULONG( + IN PULONG Port); + +NTHALAPI +USHORT +NTAPI +READ_PORT_USHORT( + IN PUSHORT Port); + +NTKERNELAPI +VOID +NTAPI +READ_REGISTER_BUFFER_UCHAR( + IN PUCHAR Register, + IN PUCHAR Buffer, + IN ULONG Count); + +NTKERNELAPI +VOID +NTAPI +READ_REGISTER_BUFFER_ULONG( + IN PULONG Register, + IN PULONG Buffer, + IN ULONG Count); + +NTKERNELAPI +VOID +NTAPI +READ_REGISTER_BUFFER_USHORT( + IN PUSHORT Register, + IN PUSHORT Buffer, + IN ULONG Count); + +NTKERNELAPI +UCHAR +NTAPI +READ_REGISTER_UCHAR( + IN PUCHAR Register); + +NTKERNELAPI +ULONG +NTAPI +READ_REGISTER_ULONG( + IN PULONG Register); + +NTKERNELAPI +USHORT +NTAPI +READ_REGISTER_USHORT( + IN PUSHORT Register); + +NTHALAPI +VOID +NTAPI +WRITE_PORT_BUFFER_UCHAR( + IN PUCHAR Port, + IN PUCHAR Buffer, + IN ULONG Count); + +NTHALAPI +VOID +NTAPI +WRITE_PORT_BUFFER_ULONG( + IN PULONG Port, + IN PULONG Buffer, + IN ULONG Count); + +NTHALAPI +VOID +NTAPI +WRITE_PORT_BUFFER_USHORT( + IN PUSHORT Port, + IN PUSHORT Buffer, + IN ULONG Count); + +NTHALAPI +VOID +NTAPI +WRITE_PORT_UCHAR( + IN PUCHAR Port, + IN UCHAR Value); + +NTHALAPI +VOID +NTAPI +WRITE_PORT_ULONG( + IN PULONG Port, + IN ULONG Value); + +NTHALAPI +VOID +NTAPI +WRITE_PORT_USHORT( + IN PUSHORT Port, + IN USHORT Value); + +NTKERNELAPI +VOID +NTAPI +WRITE_REGISTER_BUFFER_UCHAR( + IN PUCHAR Register, + IN PUCHAR Buffer, + IN ULONG Count); + +NTKERNELAPI +VOID +NTAPI +WRITE_REGISTER_BUFFER_ULONG( + IN PULONG Register, + IN PULONG Buffer, + IN ULONG Count); + +NTKERNELAPI +VOID +NTAPI +WRITE_REGISTER_BUFFER_USHORT( + IN PUSHORT Register, + IN PUSHORT Buffer, + IN ULONG Count); + +NTKERNELAPI +VOID +NTAPI +WRITE_REGISTER_UCHAR( + IN PUCHAR Register, + IN UCHAR Value); + +NTKERNELAPI +VOID +NTAPI +WRITE_REGISTER_ULONG( + IN PULONG Register, + IN ULONG Value); + +NTKERNELAPI +VOID +NTAPI +WRITE_REGISTER_USHORT( + IN PUSHORT Register, + IN USHORT Value); + +#else + +FORCEINLINE +VOID +READ_PORT_BUFFER_UCHAR( + IN PUCHAR Port, + IN PUCHAR Buffer, + IN ULONG Count) +{ + __inbytestring((USHORT)(ULONG_PTR)Port, Buffer, Count); +} + +FORCEINLINE +VOID +READ_PORT_BUFFER_ULONG( + IN PULONG Port, + IN PULONG Buffer, + IN ULONG Count) +{ + __indwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count); +} + +FORCEINLINE +VOID +READ_PORT_BUFFER_USHORT( + IN PUSHORT Port, + IN PUSHORT Buffer, + IN ULONG Count) +{ + __inwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count); +} + +FORCEINLINE +UCHAR +READ_PORT_UCHAR( + IN PUCHAR Port) +{ + return __inbyte((USHORT)(ULONG_PTR)Port); +} + +FORCEINLINE +ULONG +READ_PORT_ULONG( + IN PULONG Port) +{ + return __indword((USHORT)(ULONG_PTR)Port); +} + +FORCEINLINE +USHORT +READ_PORT_USHORT( + IN PUSHORT Port) +{ + return __inword((USHORT)(ULONG_PTR)Port); +} + +FORCEINLINE +VOID +READ_REGISTER_BUFFER_UCHAR( + IN PUCHAR Register, + IN PUCHAR Buffer, + IN ULONG Count) +{ + __movsb(Register, Buffer, Count); +} + +FORCEINLINE +VOID +READ_REGISTER_BUFFER_ULONG( + IN PULONG Register, + IN PULONG Buffer, + IN ULONG Count) +{ + __movsd(Register, Buffer, Count); +} + +FORCEINLINE +VOID +READ_REGISTER_BUFFER_USHORT( + IN PUSHORT Register, + IN PUSHORT Buffer, + IN ULONG Count) +{ + __movsw(Register, Buffer, Count); +} + +FORCEINLINE +UCHAR +READ_REGISTER_UCHAR( + IN volatile UCHAR *Register) +{ + return *Register; +} + +FORCEINLINE +ULONG +READ_REGISTER_ULONG( + IN volatile ULONG *Register) +{ + return *Register; +} + +FORCEINLINE +USHORT +READ_REGISTER_USHORT( + IN volatile USHORT *Register) +{ + return *Register; +} + +FORCEINLINE +VOID +WRITE_PORT_BUFFER_UCHAR( + IN PUCHAR Port, + IN PUCHAR Buffer, + IN ULONG Count) +{ + __outbytestring((USHORT)(ULONG_PTR)Port, Buffer, Count); +} + +FORCEINLINE +VOID +WRITE_PORT_BUFFER_ULONG( + IN PULONG Port, + IN PULONG Buffer, + IN ULONG Count) +{ + __outdwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count); +} + +FORCEINLINE +VOID +WRITE_PORT_BUFFER_USHORT( + IN PUSHORT Port, + IN PUSHORT Buffer, + IN ULONG Count) +{ + __outwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count); +} + +FORCEINLINE +VOID +WRITE_PORT_UCHAR( + IN PUCHAR Port, + IN UCHAR Value) +{ + __outbyte((USHORT)(ULONG_PTR)Port, Value); +} + +FORCEINLINE +VOID +WRITE_PORT_ULONG( + IN PULONG Port, + IN ULONG Value) +{ + __outdword((USHORT)(ULONG_PTR)Port, Value); +} + +FORCEINLINE +VOID +WRITE_PORT_USHORT( + IN PUSHORT Port, + IN USHORT Value) +{ + __outword((USHORT)(ULONG_PTR)Port, Value); +} + +FORCEINLINE +VOID +WRITE_REGISTER_BUFFER_UCHAR( + IN PUCHAR Register, + IN PUCHAR Buffer, + IN ULONG Count) +{ + LONG Synch; + __movsb(Register, Buffer, Count); + InterlockedOr(&Synch, 1); +} + +FORCEINLINE +VOID +WRITE_REGISTER_BUFFER_ULONG( + IN PULONG Register, + IN PULONG Buffer, + IN ULONG Count) +{ + LONG Synch; + __movsd(Register, Buffer, Count); + InterlockedOr(&Synch, 1); +} + +FORCEINLINE +VOID +WRITE_REGISTER_BUFFER_USHORT( + IN PUSHORT Register, + IN PUSHORT Buffer, + IN ULONG Count) +{ + LONG Synch; + __movsw(Register, Buffer, Count); + InterlockedOr(&Synch, 1); +} + +FORCEINLINE +VOID +WRITE_REGISTER_UCHAR( + IN volatile UCHAR *Register, + IN UCHAR Value) +{ + LONG Synch; + *Register = Value; + InterlockedOr(&Synch, 1); +} + +FORCEINLINE +VOID +WRITE_REGISTER_ULONG( + IN volatile ULONG *Register, + IN ULONG Value) +{ + LONG Synch; + *Register = Value; + InterlockedOr(&Synch, 1); +} + +FORCEINLINE +VOID +WRITE_REGISTER_USHORT( + IN volatile USHORT *Register, + IN USHORT Value) +{ + LONG Sync; + *Register = Value; + InterlockedOr(&Sync, 1); +} +#endif + +#if defined(USE_DMA_MACROS) && !defined(_NTHAL_) && \ + (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_) + +#define DMA_MACROS_DEFINED + +FORCEINLINE +NTSTATUS +IoAllocateAdapterChannel( + IN PDMA_ADAPTER DmaAdapter, + IN PDEVICE_OBJECT DeviceObject, + IN ULONG NumberOfMapRegisters, + IN PDRIVER_CONTROL ExecutionRoutine, + IN PVOID Context) +{ + PALLOCATE_ADAPTER_CHANNEL AllocateAdapterChannel; + AllocateAdapterChannel = + *(DmaAdapter)->DmaOperations->AllocateAdapterChannel; + ASSERT(AllocateAdapterChannel); + return AllocateAdapterChannel(DmaAdapter, + DeviceObject, + NumberOfMapRegisters, + ExecutionRoutine, + Context ); +} + +FORCEINLINE +BOOLEAN +NTAPI +IoFlushAdapterBuffers( + IN PDMA_ADAPTER DmaAdapter, + IN PMDL Mdl, + IN PVOID MapRegisterBase, + IN PVOID CurrentVa, + IN ULONG Length, + IN BOOLEAN WriteToDevice) +{ + PFLUSH_ADAPTER_BUFFERS FlushAdapterBuffers; + FlushAdapterBuffers = *(DmaAdapter)->DmaOperations->FlushAdapterBuffers; + ASSERT(FlushAdapterBuffers); + return FlushAdapterBuffers(DmaAdapter, + Mdl, + MapRegisterBase, + CurrentVa, + Length, + WriteToDevice); +} + +FORCEINLINE +VOID +NTAPI +IoFreeAdapterChannel( + IN PDMA_ADAPTER DmaAdapter) +{ + PFREE_ADAPTER_CHANNEL FreeAdapterChannel; + FreeAdapterChannel = *(DmaAdapter)->DmaOperations->FreeAdapterChannel; + ASSERT(FreeAdapterChannel); + FreeAdapterChannel(DmaAdapter); +} + +FORCEINLINE +VOID +NTAPI +IoFreeMapRegisters( + IN PDMA_ADAPTER DmaAdapter, + IN PVOID MapRegisterBase, + IN ULONG NumberOfMapRegisters) +{ + PFREE_MAP_REGISTERS FreeMapRegisters; + FreeMapRegisters = *(DmaAdapter)->DmaOperations->FreeMapRegisters; + ASSERT(FreeMapRegisters); + FreeMapRegisters(DmaAdapter, MapRegisterBase, NumberOfMapRegisters); +} + +FORCEINLINE +PHYSICAL_ADDRESS +NTAPI +IoMapTransfer( + IN PDMA_ADAPTER DmaAdapter, + IN PMDL Mdl, + IN PVOID MapRegisterBase, + IN PVOID CurrentVa, + IN OUT PULONG Length, + IN BOOLEAN WriteToDevice) +{ + PMAP_TRANSFER MapTransfer; + + MapTransfer = *(DmaAdapter)->DmaOperations->MapTransfer; + ASSERT(MapTransfer); + return MapTransfer(DmaAdapter, + Mdl, + MapRegisterBase, + CurrentVa, + Length, + WriteToDevice); +} +#endif +$endif + +#if (NTDDI_VERSION >= NTDDI_WIN2K) +$if (_NTDDK_) +#if !(defined(USE_DMA_MACROS) && (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_)) +NTKERNELAPI +NTSTATUS +NTAPI +IoAllocateAdapterChannel( + IN PADAPTER_OBJECT AdapterObject, + IN PDEVICE_OBJECT DeviceObject, + IN ULONG NumberOfMapRegisters, + IN PDRIVER_CONTROL ExecutionRoutine, + IN PVOID Context); +#endif + +#if !defined(DMA_MACROS_DEFINED) +//DECLSPEC_DEPRECATED_DDK +NTHALAPI +PHYSICAL_ADDRESS +NTAPI +IoMapTransfer( + IN PADAPTER_OBJECT AdapterObject, + IN PMDL Mdl, + IN PVOID MapRegisterBase, + IN PVOID CurrentVa, + IN OUT PULONG Length, + IN BOOLEAN WriteToDevice); +#endif + +NTKERNELAPI +VOID +NTAPI +IoAllocateController( + IN PCONTROLLER_OBJECT ControllerObject, + IN PDEVICE_OBJECT DeviceObject, + IN PDRIVER_CONTROL ExecutionRoutine, + IN PVOID Context OPTIONAL); + +NTKERNELAPI +PCONTROLLER_OBJECT +NTAPI +IoCreateController( + IN ULONG Size); + +NTKERNELAPI +VOID +NTAPI +IoDeleteController( + IN PCONTROLLER_OBJECT ControllerObject); + +NTKERNELAPI +VOID +NTAPI +IoFreeController( + IN PCONTROLLER_OBJECT ControllerObject); + +NTKERNELAPI +PCONFIGURATION_INFORMATION +NTAPI +IoGetConfigurationInformation(VOID); + +NTKERNELAPI +PDEVICE_OBJECT +NTAPI +IoGetDeviceToVerify( + IN PETHREAD Thread); + +NTKERNELAPI +VOID +NTAPI +IoCancelFileOpen( + IN PDEVICE_OBJECT DeviceObject, + IN PFILE_OBJECT FileObject); + +NTKERNELAPI +PGENERIC_MAPPING +NTAPI +IoGetFileObjectGenericMapping(VOID); + +NTKERNELAPI +PIRP +NTAPI +IoMakeAssociatedIrp( + IN PIRP Irp, + IN CCHAR StackSize); + +NTKERNELAPI +NTSTATUS +NTAPI +IoQueryDeviceDescription( + IN PINTERFACE_TYPE BusType OPTIONAL, + IN PULONG BusNumber OPTIONAL, + IN PCONFIGURATION_TYPE ControllerType OPTIONAL, + IN PULONG ControllerNumber OPTIONAL, + IN PCONFIGURATION_TYPE PeripheralType OPTIONAL, + IN PULONG PeripheralNumber OPTIONAL, + IN PIO_QUERY_DEVICE_ROUTINE CalloutRoutine, + IN OUT PVOID Context OPTIONAL); + +NTKERNELAPI +VOID +NTAPI +IoRaiseHardError( + IN PIRP Irp, + IN PVPB Vpb OPTIONAL, + IN PDEVICE_OBJECT RealDeviceObject); + +NTKERNELAPI +BOOLEAN +NTAPI +IoRaiseInformationalHardError( + IN NTSTATUS ErrorStatus, + IN PUNICODE_STRING String OPTIONAL, + IN PKTHREAD Thread OPTIONAL); + +NTKERNELAPI +VOID +NTAPI +IoRegisterBootDriverReinitialization( + IN PDRIVER_OBJECT DriverObject, + IN PDRIVER_REINITIALIZE DriverReinitializationRoutine, + IN PVOID Context OPTIONAL); + +NTKERNELAPI +VOID +NTAPI +IoRegisterDriverReinitialization( + IN PDRIVER_OBJECT DriverObject, + IN PDRIVER_REINITIALIZE DriverReinitializationRoutine, + IN PVOID Context OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +IoAttachDeviceByPointer( + IN PDEVICE_OBJECT SourceDevice, + IN PDEVICE_OBJECT TargetDevice); + +NTKERNELAPI +NTSTATUS +NTAPI +IoReportDetectedDevice( + IN PDRIVER_OBJECT DriverObject, + IN INTERFACE_TYPE LegacyBusType, + IN ULONG BusNumber, + IN ULONG SlotNumber, + IN PCM_RESOURCE_LIST ResourceList OPTIONAL, + IN PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirements OPTIONAL, + IN BOOLEAN ResourceAssigned, + IN OUT PDEVICE_OBJECT *DeviceObject OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +IoReportResourceForDetection( + IN PDRIVER_OBJECT DriverObject, + IN PCM_RESOURCE_LIST DriverList OPTIONAL, + IN ULONG DriverListSize OPTIONAL, + IN PDEVICE_OBJECT DeviceObject OPTIONAL, + IN PCM_RESOURCE_LIST DeviceList OPTIONAL, + IN ULONG DeviceListSize OPTIONAL, + OUT PBOOLEAN ConflictDetected); + +NTKERNELAPI +NTSTATUS +NTAPI +IoReportResourceUsage( + IN PUNICODE_STRING DriverClassName OPTIONAL, + IN PDRIVER_OBJECT DriverObject, + IN PCM_RESOURCE_LIST DriverList OPTIONAL, + IN ULONG DriverListSize OPTIONAL, + IN PDEVICE_OBJECT DeviceObject, + IN PCM_RESOURCE_LIST DeviceList OPTIONAL, + IN ULONG DeviceListSize OPTIONAL, + IN BOOLEAN OverrideConflict, + OUT PBOOLEAN ConflictDetected); + +NTKERNELAPI +VOID +NTAPI +IoSetHardErrorOrVerifyDevice( + IN PIRP Irp, + IN PDEVICE_OBJECT DeviceObject); + +NTKERNELAPI +NTSTATUS +NTAPI +IoAssignResources( + IN PUNICODE_STRING RegistryPath, + IN PUNICODE_STRING DriverClassName OPTIONAL, + IN PDRIVER_OBJECT DriverObject, + IN PDEVICE_OBJECT DeviceObject OPTIONAL, + IN PIO_RESOURCE_REQUIREMENTS_LIST RequestedResources OPTIONAL, + IN OUT PCM_RESOURCE_LIST *AllocatedResources); + +NTKERNELAPI +BOOLEAN +NTAPI +IoSetThreadHardErrorMode( + IN BOOLEAN EnableHardErrors); +$endif + +$if (_WDMDDK_) +NTKERNELAPI +VOID +NTAPI +IoAcquireCancelSpinLock( + OUT PKIRQL Irql); + +NTKERNELAPI +NTSTATUS +NTAPI +IoAcquireRemoveLockEx( + IN PIO_REMOVE_LOCK RemoveLock, + IN PVOID Tag OPTIONAL, + IN PCSTR File, + IN ULONG Line, + IN ULONG RemlockSize); +NTKERNELAPI +NTSTATUS +NTAPI +IoAllocateDriverObjectExtension( + IN PDRIVER_OBJECT DriverObject, + IN PVOID ClientIdentificationAddress, + IN ULONG DriverObjectExtensionSize, + OUT PVOID *DriverObjectExtension); + +NTKERNELAPI +PVOID +NTAPI +IoAllocateErrorLogEntry( + IN PVOID IoObject, + IN UCHAR EntrySize); + +NTKERNELAPI +PIRP +NTAPI +IoAllocateIrp( + IN CCHAR StackSize, + IN BOOLEAN ChargeQuota); + +NTKERNELAPI +PMDL +NTAPI +IoAllocateMdl( + IN PVOID VirtualAddress OPTIONAL, + IN ULONG Length, + IN BOOLEAN SecondaryBuffer, + IN BOOLEAN ChargeQuota, + IN OUT PIRP Irp OPTIONAL); + +NTKERNELAPI +PIO_WORKITEM +NTAPI +IoAllocateWorkItem( + IN PDEVICE_OBJECT DeviceObject); + +NTKERNELAPI +NTSTATUS +NTAPI +IoAttachDevice( + IN PDEVICE_OBJECT SourceDevice, + IN PUNICODE_STRING TargetDevice, + OUT PDEVICE_OBJECT *AttachedDevice); + +NTKERNELAPI +PDEVICE_OBJECT +NTAPI +IoAttachDeviceToDeviceStack( + IN PDEVICE_OBJECT SourceDevice, + IN PDEVICE_OBJECT TargetDevice); + +NTKERNELAPI +PIRP +NTAPI +IoBuildAsynchronousFsdRequest( + IN ULONG MajorFunction, + IN PDEVICE_OBJECT DeviceObject, + IN OUT PVOID Buffer OPTIONAL, + IN ULONG Length OPTIONAL, + IN PLARGE_INTEGER StartingOffset OPTIONAL, + IN PIO_STATUS_BLOCK IoStatusBlock OPTIONAL); + +NTKERNELAPI +PIRP +NTAPI +IoBuildDeviceIoControlRequest( + IN ULONG IoControlCode, + IN PDEVICE_OBJECT DeviceObject, + IN PVOID InputBuffer OPTIONAL, + IN ULONG InputBufferLength, + OUT PVOID OutputBuffer OPTIONAL, + IN ULONG OutputBufferLength, + IN BOOLEAN InternalDeviceIoControl, + IN PKEVENT Event, + OUT PIO_STATUS_BLOCK IoStatusBlock); + +NTKERNELAPI +VOID +NTAPI +IoBuildPartialMdl( + IN PMDL SourceMdl, + IN OUT PMDL TargetMdl, + IN PVOID VirtualAddress, + IN ULONG Length); + +NTKERNELAPI +PIRP +NTAPI +IoBuildSynchronousFsdRequest( + IN ULONG MajorFunction, + IN PDEVICE_OBJECT DeviceObject, + IN OUT PVOID Buffer OPTIONAL, + IN ULONG Length OPTIONAL, + IN PLARGE_INTEGER StartingOffset OPTIONAL, + IN PKEVENT Event, + OUT PIO_STATUS_BLOCK IoStatusBlock); + +NTKERNELAPI +NTSTATUS +FASTCALL +IofCallDriver( + IN PDEVICE_OBJECT DeviceObject, + IN OUT PIRP Irp); +#define IoCallDriver IofCallDriver + +NTKERNELAPI +VOID +FASTCALL +IofCompleteRequest( + IN PIRP Irp, + IN CCHAR PriorityBoost); +#define IoCompleteRequest IofCompleteRequest + +NTKERNELAPI +BOOLEAN +NTAPI +IoCancelIrp( + IN PIRP Irp); + +NTKERNELAPI +NTSTATUS +NTAPI +IoCheckShareAccess( + IN ACCESS_MASK DesiredAccess, + IN ULONG DesiredShareAccess, + IN OUT PFILE_OBJECT FileObject, + IN OUT PSHARE_ACCESS ShareAccess, + IN BOOLEAN Update); + +NTKERNELAPI +VOID +FASTCALL +IofCompleteRequest( + IN PIRP Irp, + IN CCHAR PriorityBoost); + +NTKERNELAPI +NTSTATUS +NTAPI +IoConnectInterrupt( + OUT PKINTERRUPT *InterruptObject, + IN PKSERVICE_ROUTINE ServiceRoutine, + IN PVOID ServiceContext OPTIONAL, + IN PKSPIN_LOCK SpinLock OPTIONAL, + IN ULONG Vector, + IN KIRQL Irql, + IN KIRQL SynchronizeIrql, + IN KINTERRUPT_MODE InterruptMode, + IN BOOLEAN ShareVector, + IN KAFFINITY ProcessorEnableMask, + IN BOOLEAN FloatingSave); + +NTKERNELAPI +NTSTATUS +NTAPI +IoCreateDevice( + IN PDRIVER_OBJECT DriverObject, + IN ULONG DeviceExtensionSize, + IN PUNICODE_STRING DeviceName OPTIONAL, + IN DEVICE_TYPE DeviceType, + IN ULONG DeviceCharacteristics, + IN BOOLEAN Exclusive, + OUT PDEVICE_OBJECT *DeviceObject); + +NTKERNELAPI +NTSTATUS +NTAPI +IoCreateFile( + OUT PHANDLE FileHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN PLARGE_INTEGER AllocationSize OPTIONAL, + IN ULONG FileAttributes, + IN ULONG ShareAccess, + IN ULONG Disposition, + IN ULONG CreateOptions, + IN PVOID EaBuffer OPTIONAL, + IN ULONG EaLength, + IN CREATE_FILE_TYPE CreateFileType, + IN PVOID InternalParameters OPTIONAL, + IN ULONG Options); + +NTKERNELAPI +PKEVENT +NTAPI +IoCreateNotificationEvent( + IN PUNICODE_STRING EventName, + OUT PHANDLE EventHandle); + +NTKERNELAPI +NTSTATUS +NTAPI +IoCreateSymbolicLink( + IN PUNICODE_STRING SymbolicLinkName, + IN PUNICODE_STRING DeviceName); + +NTKERNELAPI +PKEVENT +NTAPI +IoCreateSynchronizationEvent( + IN PUNICODE_STRING EventName, + OUT PHANDLE EventHandle); + +NTKERNELAPI +NTSTATUS +NTAPI +IoCreateUnprotectedSymbolicLink( + IN PUNICODE_STRING SymbolicLinkName, + IN PUNICODE_STRING DeviceName); + +NTKERNELAPI +VOID +NTAPI +IoDeleteDevice( + IN PDEVICE_OBJECT DeviceObject); + +NTKERNELAPI +NTSTATUS +NTAPI +IoDeleteSymbolicLink( + IN PUNICODE_STRING SymbolicLinkName); + +NTKERNELAPI +VOID +NTAPI +IoDetachDevice( + IN OUT PDEVICE_OBJECT TargetDevice); + +NTKERNELAPI +VOID +NTAPI +IoDisconnectInterrupt( + IN PKINTERRUPT InterruptObject); + +NTKERNELAPI +VOID +NTAPI +IoFreeIrp( + IN PIRP Irp); + +NTKERNELAPI +VOID +NTAPI +IoFreeMdl( + IN PMDL Mdl); + +NTKERNELAPI +VOID +NTAPI +IoFreeWorkItem( + IN PIO_WORKITEM IoWorkItem); + +NTKERNELAPI +PDEVICE_OBJECT +NTAPI +IoGetAttachedDevice( + IN PDEVICE_OBJECT DeviceObject); + +NTKERNELAPI +PDEVICE_OBJECT +NTAPI +IoGetAttachedDeviceReference( + IN PDEVICE_OBJECT DeviceObject); + +NTKERNELAPI +NTSTATUS +NTAPI +IoGetBootDiskInformation( + IN OUT PBOOTDISK_INFORMATION BootDiskInformation, + IN ULONG Size); + +NTKERNELAPI +NTSTATUS +NTAPI +IoGetDeviceInterfaceAlias( + IN PUNICODE_STRING SymbolicLinkName, + IN CONST GUID *AliasInterfaceClassGuid, + OUT PUNICODE_STRING AliasSymbolicLinkName); + +NTKERNELAPI +PEPROCESS +NTAPI +IoGetCurrentProcess(VOID); + +NTKERNELAPI +NTSTATUS +NTAPI +IoGetDeviceInterfaces( + IN CONST GUID *InterfaceClassGuid, + IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL, + IN ULONG Flags, + OUT PWSTR *SymbolicLinkList); + +NTKERNELAPI +NTSTATUS +NTAPI +IoGetDeviceObjectPointer( + IN PUNICODE_STRING ObjectName, + IN ACCESS_MASK DesiredAccess, + OUT PFILE_OBJECT *FileObject, + OUT PDEVICE_OBJECT *DeviceObject); + +NTKERNELAPI +NTSTATUS +NTAPI +IoGetDeviceProperty( + IN PDEVICE_OBJECT DeviceObject, + IN DEVICE_REGISTRY_PROPERTY DeviceProperty, + IN ULONG BufferLength, + OUT PVOID PropertyBuffer, + OUT PULONG ResultLength); + +NTKERNELAPI +PDMA_ADAPTER +NTAPI +IoGetDmaAdapter( + IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL, + IN PDEVICE_DESCRIPTION DeviceDescription, + IN OUT PULONG NumberOfMapRegisters); + +NTKERNELAPI +PVOID +NTAPI +IoGetDriverObjectExtension( + IN PDRIVER_OBJECT DriverObject, + IN PVOID ClientIdentificationAddress); + +NTKERNELAPI +PVOID +NTAPI +IoGetInitialStack(VOID); + +NTKERNELAPI +PDEVICE_OBJECT +NTAPI +IoGetRelatedDeviceObject( + IN PFILE_OBJECT FileObject); + +NTKERNELAPI +VOID +NTAPI +IoQueueWorkItem( + IN PIO_WORKITEM IoWorkItem, + IN PIO_WORKITEM_ROUTINE WorkerRoutine, + IN WORK_QUEUE_TYPE QueueType, + IN PVOID Context OPTIONAL); + +NTKERNELAPI +VOID +NTAPI +IoInitializeIrp( + IN OUT PIRP Irp, + IN USHORT PacketSize, + IN CCHAR StackSize); + +NTKERNELAPI +VOID +NTAPI +IoInitializeRemoveLockEx( + IN PIO_REMOVE_LOCK Lock, + IN ULONG AllocateTag, + IN ULONG MaxLockedMinutes, + IN ULONG HighWatermark, + IN ULONG RemlockSize); + +NTKERNELAPI +NTSTATUS +NTAPI +IoInitializeTimer( + IN PDEVICE_OBJECT DeviceObject, + IN PIO_TIMER_ROUTINE TimerRoutine, + IN PVOID Context OPTIONAL); + +NTKERNELAPI +VOID +NTAPI +IoInvalidateDeviceRelations( + IN PDEVICE_OBJECT DeviceObject, + IN DEVICE_RELATION_TYPE Type); + +NTKERNELAPI +VOID +NTAPI +IoInvalidateDeviceState( + IN PDEVICE_OBJECT PhysicalDeviceObject); + +NTKERNELAPI +BOOLEAN +NTAPI +IoIsWdmVersionAvailable( + IN UCHAR MajorVersion, + IN UCHAR MinorVersion); + +NTKERNELAPI +NTSTATUS +NTAPI +IoOpenDeviceInterfaceRegistryKey( + IN PUNICODE_STRING SymbolicLinkName, + IN ACCESS_MASK DesiredAccess, + OUT PHANDLE DeviceInterfaceKey); + +NTKERNELAPI +NTSTATUS +NTAPI +IoOpenDeviceRegistryKey( + IN PDEVICE_OBJECT DeviceObject, + IN ULONG DevInstKeyType, + IN ACCESS_MASK DesiredAccess, + OUT PHANDLE DevInstRegKey); + +NTKERNELAPI +NTSTATUS +NTAPI +IoRegisterDeviceInterface( + IN PDEVICE_OBJECT PhysicalDeviceObject, + IN CONST GUID *InterfaceClassGuid, + IN PUNICODE_STRING ReferenceString OPTIONAL, + OUT PUNICODE_STRING SymbolicLinkName); + +NTKERNELAPI +NTSTATUS +NTAPI +IoRegisterPlugPlayNotification( + IN IO_NOTIFICATION_EVENT_CATEGORY EventCategory, + IN ULONG EventCategoryFlags, + IN PVOID EventCategoryData OPTIONAL, + IN PDRIVER_OBJECT DriverObject, + IN PDRIVER_NOTIFICATION_CALLBACK_ROUTINE CallbackRoutine, + IN OUT PVOID Context OPTIONAL, + OUT PVOID *NotificationEntry); + +NTKERNELAPI +NTSTATUS +NTAPI +IoRegisterShutdownNotification( + IN PDEVICE_OBJECT DeviceObject); + +NTKERNELAPI +VOID +NTAPI +IoReleaseCancelSpinLock( + IN KIRQL Irql); + +NTKERNELAPI +VOID +NTAPI +IoReleaseRemoveLockAndWaitEx( + IN PIO_REMOVE_LOCK RemoveLock, + IN PVOID Tag OPTIONAL, + IN ULONG RemlockSize); + +NTKERNELAPI +VOID +NTAPI +IoReleaseRemoveLockEx( + IN PIO_REMOVE_LOCK RemoveLock, + IN PVOID Tag OPTIONAL, + IN ULONG RemlockSize); + +NTKERNELAPI +VOID +NTAPI +IoRemoveShareAccess( + IN PFILE_OBJECT FileObject, + IN OUT PSHARE_ACCESS ShareAccess); + +NTKERNELAPI +NTSTATUS +NTAPI +IoReportTargetDeviceChange( + IN PDEVICE_OBJECT PhysicalDeviceObject, + IN PVOID NotificationStructure); + +NTKERNELAPI +NTSTATUS +NTAPI +IoReportTargetDeviceChangeAsynchronous( + IN PDEVICE_OBJECT PhysicalDeviceObject, + IN PVOID NotificationStructure, + IN PDEVICE_CHANGE_COMPLETE_CALLBACK Callback OPTIONAL, + IN PVOID Context OPTIONAL); + +NTKERNELAPI +VOID +NTAPI +IoRequestDeviceEject( + IN PDEVICE_OBJECT PhysicalDeviceObject); + +NTKERNELAPI +VOID +NTAPI +IoReuseIrp( + IN OUT PIRP Irp, + IN NTSTATUS Status); + +NTKERNELAPI +NTSTATUS +NTAPI +IoSetDeviceInterfaceState( + IN PUNICODE_STRING SymbolicLinkName, + IN BOOLEAN Enable); + +NTKERNELAPI +VOID +NTAPI +IoSetShareAccess( + IN ACCESS_MASK DesiredAccess, + IN ULONG DesiredShareAccess, + IN OUT PFILE_OBJECT FileObject, + OUT PSHARE_ACCESS ShareAccess); + +NTKERNELAPI +VOID +NTAPI +IoStartNextPacket( + IN PDEVICE_OBJECT DeviceObject, + IN BOOLEAN Cancelable); + +NTKERNELAPI +VOID +NTAPI +IoStartNextPacketByKey( + IN PDEVICE_OBJECT DeviceObject, + IN BOOLEAN Cancelable, + IN ULONG Key); + +NTKERNELAPI +VOID +NTAPI +IoStartPacket( + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp, + IN PULONG Key OPTIONAL, + IN PDRIVER_CANCEL CancelFunction OPTIONAL); + +NTKERNELAPI +VOID +NTAPI +IoStartTimer( + IN PDEVICE_OBJECT DeviceObject); + +NTKERNELAPI +VOID +NTAPI +IoStopTimer( + IN PDEVICE_OBJECT DeviceObject); + +NTKERNELAPI +NTSTATUS +NTAPI +IoUnregisterPlugPlayNotification( + IN PVOID NotificationEntry); + +NTKERNELAPI +VOID +NTAPI +IoUnregisterShutdownNotification( + IN PDEVICE_OBJECT DeviceObject); + +NTKERNELAPI +VOID +NTAPI +IoUpdateShareAccess( + IN PFILE_OBJECT FileObject, + IN OUT PSHARE_ACCESS ShareAccess); + +NTKERNELAPI +NTSTATUS +NTAPI +IoWMIAllocateInstanceIds( + IN GUID *Guid, + IN ULONG InstanceCount, + OUT ULONG *FirstInstanceId); + +NTKERNELAPI +NTSTATUS +NTAPI +IoWMIQuerySingleInstanceMultiple( + IN PVOID *DataBlockObjectList, + IN PUNICODE_STRING InstanceNames, + IN ULONG ObjectCount, + IN OUT ULONG *InOutBufferSize, + OUT PVOID OutBuffer); + +NTKERNELAPI +NTSTATUS +NTAPI +IoWMIRegistrationControl( + IN PDEVICE_OBJECT DeviceObject, + IN ULONG Action); + +NTKERNELAPI +NTSTATUS +NTAPI +IoWMISuggestInstanceName( + IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL, + IN PUNICODE_STRING SymbolicLinkName OPTIONAL, + IN BOOLEAN CombineNames, + OUT PUNICODE_STRING SuggestedInstanceName); + +NTKERNELAPI +NTSTATUS +NTAPI +IoWMIWriteEvent( + IN OUT PVOID WnodeEventItem); + +NTKERNELAPI +VOID +NTAPI +IoWriteErrorLogEntry( + IN PVOID ElEntry); + +NTKERNELAPI +PIRP +NTAPI +IoGetTopLevelIrp(VOID); + +NTKERNELAPI +NTSTATUS +NTAPI +IoRegisterLastChanceShutdownNotification( + IN PDEVICE_OBJECT DeviceObject); + +NTKERNELAPI +VOID +NTAPI +IoSetTopLevelIrp( + IN PIRP Irp OPTIONAL); + +$endif +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ + +$if (_NTDDK_) +#if (NTDDI_VERSION >= NTDDI_WIN2KSP3) + +NTKERNELAPI +BOOLEAN +NTAPI +IoIsFileOriginRemote( + IN PFILE_OBJECT FileObject); + +NTKERNELAPI +NTSTATUS +NTAPI +IoSetFileOrigin( + IN PFILE_OBJECT FileObject, + IN BOOLEAN Remote); + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2KSP3) */ +$endif + +#if (NTDDI_VERSION >= NTDDI_WINXP) +$if (_NTDDK_) +NTKERNELAPI +NTSTATUS +FASTCALL +IoReadPartitionTable( + IN PDEVICE_OBJECT DeviceObject, + IN ULONG SectorSize, + IN BOOLEAN ReturnRecognizedPartitions, + OUT struct _DRIVE_LAYOUT_INFORMATION **PartitionBuffer); + +NTKERNELAPI +NTSTATUS +FASTCALL +IoSetPartitionInformation( + IN PDEVICE_OBJECT DeviceObject, + IN ULONG SectorSize, + IN ULONG PartitionNumber, + IN ULONG PartitionType); + +NTKERNELAPI +NTSTATUS +FASTCALL +IoWritePartitionTable( + IN PDEVICE_OBJECT DeviceObject, + IN ULONG SectorSize, + IN ULONG SectorsPerTrack, + IN ULONG NumberOfHeads, + IN struct _DRIVE_LAYOUT_INFORMATION *PartitionBuffer); + +NTKERNELAPI +NTSTATUS +NTAPI +IoCreateDisk( + IN PDEVICE_OBJECT DeviceObject, + IN struct _CREATE_DISK* Disk OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +IoReadDiskSignature( + IN PDEVICE_OBJECT DeviceObject, + IN ULONG BytesPerSector, + OUT PDISK_SIGNATURE Signature); + +NTKERNELAPI +NTSTATUS +NTAPI +IoReadPartitionTableEx( + IN PDEVICE_OBJECT DeviceObject, + OUT struct _DRIVE_LAYOUT_INFORMATION_EX **PartitionBuffer); + +NTKERNELAPI +NTSTATUS +NTAPI +IoSetPartitionInformationEx( + IN PDEVICE_OBJECT DeviceObject, + IN ULONG PartitionNumber, + IN struct _SET_PARTITION_INFORMATION_EX *PartitionInfo); + +NTKERNELAPI +NTSTATUS +NTAPI +IoSetSystemPartition( + IN PUNICODE_STRING VolumeNameString); + +NTKERNELAPI +NTSTATUS +NTAPI +IoVerifyPartitionTable( + IN PDEVICE_OBJECT DeviceObject, + IN BOOLEAN FixErrors); + +NTKERNELAPI +NTSTATUS +NTAPI +IoVolumeDeviceToDosName( + IN PVOID VolumeDeviceObject, + OUT PUNICODE_STRING DosName); + +NTKERNELAPI +NTSTATUS +NTAPI +IoWritePartitionTableEx( + IN PDEVICE_OBJECT DeviceObject, + IN struct _DRIVE_LAYOUT_INFORMATION_EX *DriveLayout); + +NTKERNELAPI +NTSTATUS +NTAPI +IoCreateFileSpecifyDeviceObjectHint( + OUT PHANDLE FileHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN PLARGE_INTEGER AllocationSize OPTIONAL, + IN ULONG FileAttributes, + IN ULONG ShareAccess, + IN ULONG Disposition, + IN ULONG CreateOptions, + IN PVOID EaBuffer OPTIONAL, + IN ULONG EaLength, + IN CREATE_FILE_TYPE CreateFileType, + IN PVOID InternalParameters OPTIONAL, + IN ULONG Options, + IN PVOID DeviceObject OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +IoAttachDeviceToDeviceStackSafe( + IN PDEVICE_OBJECT SourceDevice, + IN PDEVICE_OBJECT TargetDevice, + OUT PDEVICE_OBJECT *AttachedToDeviceObject); +$endif + +$if (_WDMDDK_) +NTKERNELAPI +NTSTATUS +NTAPI +IoCsqInitialize( + IN PIO_CSQ Csq, + IN PIO_CSQ_INSERT_IRP CsqInsertIrp, + IN PIO_CSQ_REMOVE_IRP CsqRemoveIrp, + IN PIO_CSQ_PEEK_NEXT_IRP CsqPeekNextIrp, + IN PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock, + IN PIO_CSQ_RELEASE_LOCK CsqReleaseLock, + IN PIO_CSQ_COMPLETE_CANCELED_IRP CsqCompleteCanceledIrp); + +NTKERNELAPI +VOID +NTAPI +IoCsqInsertIrp( + IN PIO_CSQ Csq, + IN PIRP Irp, + IN PIO_CSQ_IRP_CONTEXT Context OPTIONAL); + +NTKERNELAPI +PIRP +NTAPI +IoCsqRemoveIrp( + IN PIO_CSQ Csq, + IN PIO_CSQ_IRP_CONTEXT Context); + +NTKERNELAPI +PIRP +NTAPI +IoCsqRemoveNextIrp( + IN PIO_CSQ Csq, + IN PVOID PeekContext OPTIONAL); + +NTKERNELAPI +BOOLEAN +NTAPI +IoForwardIrpSynchronously( + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp); + +#define IoForwardAndCatchIrp IoForwardIrpSynchronously + +NTKERNELAPI +VOID +NTAPI +IoFreeErrorLogEntry( + PVOID ElEntry); + +NTKERNELAPI +NTSTATUS +NTAPI +IoSetCompletionRoutineEx( + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp, + IN PIO_COMPLETION_ROUTINE CompletionRoutine, + IN PVOID Context, + IN BOOLEAN InvokeOnSuccess, + IN BOOLEAN InvokeOnError, + IN BOOLEAN InvokeOnCancel); + +VOID +NTAPI +IoSetStartIoAttributes( + IN PDEVICE_OBJECT DeviceObject, + IN BOOLEAN DeferredStartIo, + IN BOOLEAN NonCancelable); + +NTKERNELAPI +NTSTATUS +NTAPI +IoWMIDeviceObjectToInstanceName( + IN PVOID DataBlockObject, + IN PDEVICE_OBJECT DeviceObject, + OUT PUNICODE_STRING InstanceName); + +NTKERNELAPI +NTSTATUS +NTAPI +IoWMIExecuteMethod( + IN PVOID DataBlockObject, + IN PUNICODE_STRING InstanceName, + IN ULONG MethodId, + IN ULONG InBufferSize, + IN OUT PULONG OutBufferSize, + IN OUT PUCHAR InOutBuffer); + +NTKERNELAPI +NTSTATUS +NTAPI +IoWMIHandleToInstanceName( + IN PVOID DataBlockObject, + IN HANDLE FileHandle, + OUT PUNICODE_STRING InstanceName); + +NTKERNELAPI +NTSTATUS +NTAPI +IoWMIOpenBlock( + IN GUID *DataBlockGuid, + IN ULONG DesiredAccess, + OUT PVOID *DataBlockObject); + +NTKERNELAPI +NTSTATUS +NTAPI +IoWMIQueryAllData( + IN PVOID DataBlockObject, + IN OUT ULONG *InOutBufferSize, + OUT PVOID OutBuffer); + +NTKERNELAPI +NTSTATUS +NTAPI +IoWMIQueryAllDataMultiple( + IN PVOID *DataBlockObjectList, + IN ULONG ObjectCount, + IN OUT ULONG *InOutBufferSize, + OUT PVOID OutBuffer); + +NTKERNELAPI +NTSTATUS +NTAPI +IoWMIQuerySingleInstance( + IN PVOID DataBlockObject, + IN PUNICODE_STRING InstanceName, + IN OUT ULONG *InOutBufferSize, + OUT PVOID OutBuffer); + +NTKERNELAPI +NTSTATUS +NTAPI +IoWMISetNotificationCallback( + IN OUT PVOID Object, + IN WMI_NOTIFICATION_CALLBACK Callback, + IN PVOID Context OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +IoWMISetSingleInstance( + IN PVOID DataBlockObject, + IN PUNICODE_STRING InstanceName, + IN ULONG Version, + IN ULONG ValueBufferSize, + IN PVOID ValueBuffer); + +NTKERNELAPI +NTSTATUS +NTAPI +IoWMISetSingleItem( + IN PVOID DataBlockObject, + IN PUNICODE_STRING InstanceName, + IN ULONG DataItemId, + IN ULONG Version, + IN ULONG ValueBufferSize, + IN PVOID ValueBuffer); +$endif +#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ + +$if (_WDMDDK_) +#if (NTDDI_VERSION >= NTDDI_WINXPSP1) +NTKERNELAPI +NTSTATUS +NTAPI +IoValidateDeviceIoControlAccess( + IN PIRP Irp, + IN ULONG RequiredAccess); +#endif +$endif + +#if (NTDDI_VERSION >= NTDDI_WS03) +$if (_NTDDK_) +NTKERNELAPI +IO_PAGING_PRIORITY +FASTCALL +IoGetPagingIoPriority( + IN PIRP Irp); +$endif + +$if (_WDMDDK_) +NTKERNELAPI +NTSTATUS +NTAPI +IoCsqInitializeEx( + IN PIO_CSQ Csq, + IN PIO_CSQ_INSERT_IRP_EX CsqInsertIrp, + IN PIO_CSQ_REMOVE_IRP CsqRemoveIrp, + IN PIO_CSQ_PEEK_NEXT_IRP CsqPeekNextIrp, + IN PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock, + IN PIO_CSQ_RELEASE_LOCK CsqReleaseLock, + IN PIO_CSQ_COMPLETE_CANCELED_IRP CsqCompleteCanceledIrp); + +NTKERNELAPI +NTSTATUS +NTAPI +IoCsqInsertIrpEx( + IN PIO_CSQ Csq, + IN PIRP Irp, + IN PIO_CSQ_IRP_CONTEXT Context OPTIONAL, + IN PVOID InsertContext OPTIONAL); +$endif +#endif /* (NTDDI_VERSION >= NTDDI_WS03) */ + +$if (_NTDDK_) +#if (NTDDI_VERSION >= NTDDI_WS03SP1) +BOOLEAN +NTAPI +IoTranslateBusAddress( + IN INTERFACE_TYPE InterfaceType, + IN ULONG BusNumber, + IN PHYSICAL_ADDRESS BusAddress, + IN OUT PULONG AddressSpace, + OUT PPHYSICAL_ADDRESS TranslatedAddress); +#endif +$endif + +#if (NTDDI_VERSION >= NTDDI_VISTA) +$if (_NTDDK_) +NTKERNELAPI +NTSTATUS +NTAPI +IoUpdateDiskGeometry( + IN PDEVICE_OBJECT DeviceObject, + IN struct _DISK_GEOMETRY_EX* OldDiskGeometry, + IN struct _DISK_GEOMETRY_EX* NewDiskGeometry); + +PTXN_PARAMETER_BLOCK +NTAPI +IoGetTransactionParameterBlock( + IN PFILE_OBJECT FileObject); + +NTKERNELAPI +NTSTATUS +NTAPI +IoCreateFileEx( + OUT PHANDLE FileHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN PLARGE_INTEGER AllocationSize OPTIONAL, + IN ULONG FileAttributes, + IN ULONG ShareAccess, + IN ULONG Disposition, + IN ULONG CreateOptions, + IN PVOID EaBuffer OPTIONAL, + IN ULONG EaLength, + IN CREATE_FILE_TYPE CreateFileType, + IN PVOID InternalParameters OPTIONAL, + IN ULONG Options, + IN PIO_DRIVER_CREATE_CONTEXT DriverContext OPTIONAL); + +NTSTATUS +NTAPI +IoSetIrpExtraCreateParameter( + IN OUT PIRP Irp, + IN struct _ECP_LIST *ExtraCreateParameter); + +VOID +NTAPI +IoClearIrpExtraCreateParameter( + IN OUT PIRP Irp); + +NTSTATUS +NTAPI +IoGetIrpExtraCreateParameter( + IN PIRP Irp, + OUT struct _ECP_LIST **ExtraCreateParameter OPTIONAL); + +BOOLEAN +NTAPI +IoIsFileObjectIgnoringSharing( + IN PFILE_OBJECT FileObject); +$endif + +$if (_WDMDDK_) +NTKERNELAPI +NTSTATUS +NTAPI +IoGetBootDiskInformationLite( + OUT PBOOTDISK_INFORMATION_LITE *BootDiskInformation); + +NTKERNELAPI +NTSTATUS +NTAPI +IoCheckShareAccessEx( + IN ACCESS_MASK DesiredAccess, + IN ULONG DesiredShareAccess, + IN OUT PFILE_OBJECT FileObject, + IN OUT PSHARE_ACCESS ShareAccess, + IN BOOLEAN Update, + IN PBOOLEAN WritePermission); + +NTKERNELAPI +NTSTATUS +NTAPI +IoConnectInterruptEx( + IN OUT PIO_CONNECT_INTERRUPT_PARAMETERS Parameters); + +NTKERNELAPI +VOID +NTAPI +IoDisconnectInterruptEx( + IN PIO_DISCONNECT_INTERRUPT_PARAMETERS Parameters); + +LOGICAL +NTAPI +IoWithinStackLimits( + IN ULONG_PTR RegionStart, + IN SIZE_T RegionSize); + +NTKERNELAPI +VOID +NTAPI +IoSetShareAccessEx( + IN ACCESS_MASK DesiredAccess, + IN ULONG DesiredShareAccess, + IN OUT PFILE_OBJECT FileObject, + OUT PSHARE_ACCESS ShareAccess, + IN PBOOLEAN WritePermission); + +ULONG +NTAPI +IoSizeofWorkItem(VOID); + +VOID +NTAPI +IoInitializeWorkItem( + IN PVOID IoObject, + IN PIO_WORKITEM IoWorkItem); + +VOID +NTAPI +IoUninitializeWorkItem( + IN PIO_WORKITEM IoWorkItem); + +VOID +NTAPI +IoQueueWorkItemEx( + IN PIO_WORKITEM IoWorkItem, + IN PIO_WORKITEM_ROUTINE_EX WorkerRoutine, + IN WORK_QUEUE_TYPE QueueType, + IN PVOID Context OPTIONAL); + +IO_PRIORITY_HINT +NTAPI +IoGetIoPriorityHint( + IN PIRP Irp); + +NTSTATUS +NTAPI +IoSetIoPriorityHint( + IN PIRP Irp, + IN IO_PRIORITY_HINT PriorityHint); + +NTSTATUS +NTAPI +IoAllocateSfioStreamIdentifier( + IN PFILE_OBJECT FileObject, + IN ULONG Length, + IN PVOID Signature, + OUT PVOID *StreamIdentifier); + +PVOID +NTAPI +IoGetSfioStreamIdentifier( + IN PFILE_OBJECT FileObject, + IN PVOID Signature); + +NTSTATUS +NTAPI +IoFreeSfioStreamIdentifier( + IN PFILE_OBJECT FileObject, + IN PVOID Signature); + +NTKERNELAPI +NTSTATUS +NTAPI +IoRequestDeviceEjectEx( + IN PDEVICE_OBJECT PhysicalDeviceObject, + IN PIO_DEVICE_EJECT_CALLBACK Callback OPTIONAL, + IN PVOID Context OPTIONAL, + IN PDRIVER_OBJECT DriverObject OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +IoSetDevicePropertyData( + IN PDEVICE_OBJECT Pdo, + IN CONST DEVPROPKEY *PropertyKey, + IN LCID Lcid, + IN ULONG Flags, + IN DEVPROPTYPE Type, + IN ULONG Size, + IN PVOID Data OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +IoGetDevicePropertyData( + PDEVICE_OBJECT Pdo, + CONST DEVPROPKEY *PropertyKey, + LCID Lcid, + ULONG Flags, + ULONG Size, + PVOID Data, + PULONG RequiredSize, + PDEVPROPTYPE Type); +$endif + +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + +$if (_WDMDDK_) +#define IoCallDriverStackSafeDefault(a, b) IoCallDriver(a, b) + +#if (NTDDI_VERSION >= NTDDI_WS08) +NTKERNELAPI +NTSTATUS +NTAPI +IoReplacePartitionUnit( + IN PDEVICE_OBJECT TargetPdo, + IN PDEVICE_OBJECT SparePdo, + IN ULONG Flags); +#endif +$endif + +#if (NTDDI_VERSION >= NTDDI_WIN7) +$if (_NTDDK_) +NTSTATUS +NTAPI +IoSetFileObjectIgnoreSharing( + IN PFILE_OBJECT FileObject); +$endif + +$if (_WDMDDK_) +NTKERNELAPI +NTSTATUS +NTAPI +IoGetAffinityInterrupt( + IN PKINTERRUPT InterruptObject, + OUT PGROUP_AFFINITY GroupAffinity); + +NTSTATUS +NTAPI +IoGetContainerInformation( + IN IO_CONTAINER_INFORMATION_CLASS InformationClass, + IN PVOID ContainerObject OPTIONAL, + IN OUT PVOID Buffer OPTIONAL, + IN ULONG BufferLength); + +NTSTATUS +NTAPI +IoRegisterContainerNotification( + IN IO_CONTAINER_NOTIFICATION_CLASS NotificationClass, + IN PIO_CONTAINER_NOTIFICATION_FUNCTION CallbackFunction, + IN PVOID NotificationInformation OPTIONAL, + IN ULONG NotificationInformationLength, + OUT PVOID CallbackRegistration); + +VOID +NTAPI +IoUnregisterContainerNotification( + IN PVOID CallbackRegistration); + +NTKERNELAPI +NTSTATUS +NTAPI +IoUnregisterPlugPlayNotificationEx( + IN PVOID NotificationEntry); + +NTKERNELAPI +NTSTATUS +NTAPI +IoGetDeviceNumaNode( + IN PDEVICE_OBJECT Pdo, + OUT PUSHORT NodeNumber); +$endif + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + +$if (_WDMDDK_) +#if defined(_WIN64) +NTKERNELAPI +ULONG +NTAPI +IoWMIDeviceObjectToProviderId( + IN PDEVICE_OBJECT DeviceObject); +#else +#define IoWMIDeviceObjectToProviderId(DeviceObject) ((ULONG)(DeviceObject)) +#endif + +/* + * USHORT + * IoSizeOfIrp( + * IN CCHAR StackSize) + */ +#define IoSizeOfIrp(_StackSize) \ + ((USHORT) (sizeof(IRP) + ((_StackSize) * (sizeof(IO_STACK_LOCATION))))) + +FORCEINLINE +VOID +IoSkipCurrentIrpStackLocation( + IN OUT PIRP Irp) +{ + ASSERT(Irp->CurrentLocation <= Irp->StackCount); + Irp->CurrentLocation++; + Irp->Tail.Overlay.CurrentStackLocation++; +} + +FORCEINLINE +VOID +IoSetNextIrpStackLocation( + IN OUT PIRP Irp) +{ + ASSERT(Irp->CurrentLocation > 0); + Irp->CurrentLocation--; + Irp->Tail.Overlay.CurrentStackLocation--; +} + +FORCEINLINE +PIO_STACK_LOCATION +IoGetNextIrpStackLocation( + IN PIRP Irp) +{ + ASSERT(Irp->CurrentLocation > 0); + return ((Irp)->Tail.Overlay.CurrentStackLocation - 1 ); +} + +FORCEINLINE +VOID +IoSetCompletionRoutine( + IN PIRP Irp, + IN PIO_COMPLETION_ROUTINE CompletionRoutine OPTIONAL, + IN PVOID Context OPTIONAL, + IN BOOLEAN InvokeOnSuccess, + IN BOOLEAN InvokeOnError, + IN BOOLEAN InvokeOnCancel) +{ + PIO_STACK_LOCATION irpSp; + ASSERT( (InvokeOnSuccess || InvokeOnError || InvokeOnCancel) ? (CompletionRoutine != NULL) : TRUE ); + irpSp = IoGetNextIrpStackLocation(Irp); + irpSp->CompletionRoutine = CompletionRoutine; + irpSp->Context = Context; + irpSp->Control = 0; + + if (InvokeOnSuccess) { + irpSp->Control = SL_INVOKE_ON_SUCCESS; + } + + if (InvokeOnError) { + irpSp->Control |= SL_INVOKE_ON_ERROR; + } + + if (InvokeOnCancel) { + irpSp->Control |= SL_INVOKE_ON_CANCEL; + } +} + +/* + * PDRIVER_CANCEL + * IoSetCancelRoutine( + * IN PIRP Irp, + * IN PDRIVER_CANCEL CancelRoutine) + */ +#define IoSetCancelRoutine(_Irp, \ + _CancelRoutine) \ + ((PDRIVER_CANCEL) (ULONG_PTR) InterlockedExchangePointer( \ + (PVOID *) &(_Irp)->CancelRoutine, (PVOID) (ULONG_PTR) (_CancelRoutine))) + +/* + * VOID + * IoRequestDpc( + * IN PDEVICE_OBJECT DeviceObject, + * IN PIRP Irp, + * IN PVOID Context); + */ +#define IoRequestDpc(DeviceObject, Irp, Context)( \ + KeInsertQueueDpc(&(DeviceObject)->Dpc, (Irp), (Context))) + +/* + * VOID + * IoReleaseRemoveLock( + * IN PIO_REMOVE_LOCK RemoveLock, + * IN PVOID Tag) + */ +#define IoReleaseRemoveLock(_RemoveLock, \ + _Tag) \ + IoReleaseRemoveLockEx(_RemoveLock, _Tag, sizeof(IO_REMOVE_LOCK)) + +/* + * VOID + * IoReleaseRemoveLockAndWait( + * IN PIO_REMOVE_LOCK RemoveLock, + * IN PVOID Tag) + */ +#define IoReleaseRemoveLockAndWait(_RemoveLock, \ + _Tag) \ + IoReleaseRemoveLockAndWaitEx(_RemoveLock, _Tag, sizeof(IO_REMOVE_LOCK)) + +#if defined(_WIN64) +NTKERNELAPI +BOOLEAN +IoIs32bitProcess( + IN PIRP Irp OPTIONAL); +#endif + +#define PLUGPLAY_REGKEY_DEVICE 1 +#define PLUGPLAY_REGKEY_DRIVER 2 +#define PLUGPLAY_REGKEY_CURRENT_HWPROFILE 4 + +FORCEINLINE +PIO_STACK_LOCATION +IoGetCurrentIrpStackLocation( + IN PIRP Irp) +{ + ASSERT(Irp->CurrentLocation <= Irp->StackCount + 1); + return Irp->Tail.Overlay.CurrentStackLocation; +} + +FORCEINLINE +VOID +IoMarkIrpPending( + IN OUT PIRP Irp) +{ + IoGetCurrentIrpStackLocation( (Irp) )->Control |= SL_PENDING_RETURNED; +} + +/* + * BOOLEAN + * IoIsErrorUserInduced( + * IN NTSTATUS Status); + */ +#define IoIsErrorUserInduced(Status) \ + ((BOOLEAN)(((Status) == STATUS_DEVICE_NOT_READY) || \ + ((Status) == STATUS_IO_TIMEOUT) || \ + ((Status) == STATUS_MEDIA_WRITE_PROTECTED) || \ + ((Status) == STATUS_NO_MEDIA_IN_DEVICE) || \ + ((Status) == STATUS_VERIFY_REQUIRED) || \ + ((Status) == STATUS_UNRECOGNIZED_MEDIA) || \ + ((Status) == STATUS_WRONG_VOLUME))) + +/* VOID + * IoInitializeRemoveLock( + * IN PIO_REMOVE_LOCK Lock, + * IN ULONG AllocateTag, + * IN ULONG MaxLockedMinutes, + * IN ULONG HighWatermark) + */ +#define IoInitializeRemoveLock( \ + Lock, AllocateTag, MaxLockedMinutes, HighWatermark) \ + IoInitializeRemoveLockEx(Lock, AllocateTag, MaxLockedMinutes, \ + HighWatermark, sizeof(IO_REMOVE_LOCK)) + +VOID +FORCEINLINE +IoInitializeDpcRequest( + IN PDEVICE_OBJECT DeviceObject, + IN PIO_DPC_ROUTINE DpcRoutine) +{ + KeInitializeDpc( &DeviceObject->Dpc, + (PKDEFERRED_ROUTINE) DpcRoutine, + DeviceObject ); +} + +#define DEVICE_INTERFACE_INCLUDE_NONACTIVE 0x00000001 + +/* + * ULONG + * IoGetFunctionCodeFromCtlCode( + * IN ULONG ControlCode) + */ +#define IoGetFunctionCodeFromCtlCode(_ControlCode) \ + (((_ControlCode) >> 2) & 0x00000FFF) + +FORCEINLINE +VOID +IoCopyCurrentIrpStackLocationToNext( + IN OUT PIRP Irp) +{ + PIO_STACK_LOCATION irpSp; + PIO_STACK_LOCATION nextIrpSp; + irpSp = IoGetCurrentIrpStackLocation(Irp); + nextIrpSp = IoGetNextIrpStackLocation(Irp); + RtlCopyMemory( nextIrpSp, irpSp, FIELD_OFFSET(IO_STACK_LOCATION, CompletionRoutine)); + nextIrpSp->Control = 0; +} + +NTKERNELAPI +VOID +NTAPI +IoGetStackLimits( + OUT PULONG_PTR LowLimit, + OUT PULONG_PTR HighLimit); + +FORCEINLINE +ULONG_PTR +IoGetRemainingStackSize(VOID) +{ + ULONG_PTR End, Begin; + ULONG_PTR Result; + + IoGetStackLimits(&Begin, &End); + Result = (ULONG_PTR)(&End) - Begin; + return Result; +} + +#if (NTDDI_VERSION >= NTDDI_WS03) +VOID +FORCEINLINE +IoInitializeThreadedDpcRequest( + IN PDEVICE_OBJECT DeviceObject, + IN PIO_DPC_ROUTINE DpcRoutine) +{ + KeInitializeThreadedDpc(&DeviceObject->Dpc, + (PKDEFERRED_ROUTINE) DpcRoutine, + DeviceObject ); +} +#endif +$endif + diff --git a/reactos/include/xdk/iotypes.h b/reactos/include/xdk/iotypes.h new file mode 100644 index 00000000000..aac22cb3668 --- /dev/null +++ b/reactos/include/xdk/iotypes.h @@ -0,0 +1,4869 @@ +/****************************************************************************** + * I/O Manager Types * + ******************************************************************************/ + +$if (_WDMDDK_) +#define WDM_MAJORVERSION 0x06 +#define WDM_MINORVERSION 0x00 + +#if defined(_WIN64) + +#ifndef USE_DMA_MACROS +#define USE_DMA_MACROS +#endif + +#ifndef NO_LEGACY_DRIVERS +#define NO_LEGACY_DRIVERS +#endif + +#endif /* defined(_WIN64) */ + +#define STATUS_CONTINUE_COMPLETION STATUS_SUCCESS + +#define CONNECT_FULLY_SPECIFIED 0x1 +#define CONNECT_LINE_BASED 0x2 +#define CONNECT_MESSAGE_BASED 0x3 +#define CONNECT_FULLY_SPECIFIED_GROUP 0x4 +#define CONNECT_CURRENT_VERSION 0x4 + +#define POOL_COLD_ALLOCATION 256 +#define POOL_QUOTA_FAIL_INSTEAD_OF_RAISE 8 +#define POOL_RAISE_IF_ALLOCATION_FAILURE 16 + +#define IO_TYPE_ADAPTER 1 +#define IO_TYPE_CONTROLLER 2 +#define IO_TYPE_DEVICE 3 +#define IO_TYPE_DRIVER 4 +#define IO_TYPE_FILE 5 +#define IO_TYPE_IRP 6 +#define IO_TYPE_MASTER_ADAPTER 7 +#define IO_TYPE_OPEN_PACKET 8 +#define IO_TYPE_TIMER 9 +#define IO_TYPE_VPB 10 +#define IO_TYPE_ERROR_LOG 11 +#define IO_TYPE_ERROR_MESSAGE 12 +#define IO_TYPE_DEVICE_OBJECT_EXTENSION 13 + +#define IO_TYPE_CSQ_IRP_CONTEXT 1 +#define IO_TYPE_CSQ 2 +#define IO_TYPE_CSQ_EX 3 + +/* IO_RESOURCE_DESCRIPTOR.Option */ +#define IO_RESOURCE_PREFERRED 0x01 +#define IO_RESOURCE_DEFAULT 0x02 +#define IO_RESOURCE_ALTERNATIVE 0x08 + +#define FILE_DEVICE_BEEP 0x00000001 +#define FILE_DEVICE_CD_ROM 0x00000002 +#define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003 +#define FILE_DEVICE_CONTROLLER 0x00000004 +#define FILE_DEVICE_DATALINK 0x00000005 +#define FILE_DEVICE_DFS 0x00000006 +#define FILE_DEVICE_DISK 0x00000007 +#define FILE_DEVICE_DISK_FILE_SYSTEM 0x00000008 +#define FILE_DEVICE_FILE_SYSTEM 0x00000009 +#define FILE_DEVICE_INPORT_PORT 0x0000000a +#define FILE_DEVICE_KEYBOARD 0x0000000b +#define FILE_DEVICE_MAILSLOT 0x0000000c +#define FILE_DEVICE_MIDI_IN 0x0000000d +#define FILE_DEVICE_MIDI_OUT 0x0000000e +#define FILE_DEVICE_MOUSE 0x0000000f +#define FILE_DEVICE_MULTI_UNC_PROVIDER 0x00000010 +#define FILE_DEVICE_NAMED_PIPE 0x00000011 +#define FILE_DEVICE_NETWORK 0x00000012 +#define FILE_DEVICE_NETWORK_BROWSER 0x00000013 +#define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014 +#define FILE_DEVICE_NULL 0x00000015 +#define FILE_DEVICE_PARALLEL_PORT 0x00000016 +#define FILE_DEVICE_PHYSICAL_NETCARD 0x00000017 +#define FILE_DEVICE_PRINTER 0x00000018 +#define FILE_DEVICE_SCANNER 0x00000019 +#define FILE_DEVICE_SERIAL_MOUSE_PORT 0x0000001a +#define FILE_DEVICE_SERIAL_PORT 0x0000001b +#define FILE_DEVICE_SCREEN 0x0000001c +#define FILE_DEVICE_SOUND 0x0000001d +#define FILE_DEVICE_STREAMS 0x0000001e +#define FILE_DEVICE_TAPE 0x0000001f +#define FILE_DEVICE_TAPE_FILE_SYSTEM 0x00000020 +#define FILE_DEVICE_TRANSPORT 0x00000021 +#define FILE_DEVICE_UNKNOWN 0x00000022 +#define FILE_DEVICE_VIDEO 0x00000023 +#define FILE_DEVICE_VIRTUAL_DISK 0x00000024 +#define FILE_DEVICE_WAVE_IN 0x00000025 +#define FILE_DEVICE_WAVE_OUT 0x00000026 +#define FILE_DEVICE_8042_PORT 0x00000027 +#define FILE_DEVICE_NETWORK_REDIRECTOR 0x00000028 +#define FILE_DEVICE_BATTERY 0x00000029 +#define FILE_DEVICE_BUS_EXTENDER 0x0000002a +#define FILE_DEVICE_MODEM 0x0000002b +#define FILE_DEVICE_VDM 0x0000002c +#define FILE_DEVICE_MASS_STORAGE 0x0000002d +#define FILE_DEVICE_SMB 0x0000002e +#define FILE_DEVICE_KS 0x0000002f +#define FILE_DEVICE_CHANGER 0x00000030 +#define FILE_DEVICE_SMARTCARD 0x00000031 +#define FILE_DEVICE_ACPI 0x00000032 +#define FILE_DEVICE_DVD 0x00000033 +#define FILE_DEVICE_FULLSCREEN_VIDEO 0x00000034 +#define FILE_DEVICE_DFS_FILE_SYSTEM 0x00000035 +#define FILE_DEVICE_DFS_VOLUME 0x00000036 +#define FILE_DEVICE_SERENUM 0x00000037 +#define FILE_DEVICE_TERMSRV 0x00000038 +#define FILE_DEVICE_KSEC 0x00000039 +#define FILE_DEVICE_FIPS 0x0000003A +#define FILE_DEVICE_INFINIBAND 0x0000003B +#define FILE_DEVICE_VMBUS 0x0000003E +#define FILE_DEVICE_CRYPT_PROVIDER 0x0000003F +#define FILE_DEVICE_WPD 0x00000040 +#define FILE_DEVICE_BLUETOOTH 0x00000041 +#define FILE_DEVICE_MT_COMPOSITE 0x00000042 +#define FILE_DEVICE_MT_TRANSPORT 0x00000043 +#define FILE_DEVICE_BIOMETRIC 0x00000044 +#define FILE_DEVICE_PMI 0x00000045 + +#if defined(NT_PROCESSOR_GROUPS) + +typedef USHORT IRQ_DEVICE_POLICY, *PIRQ_DEVICE_POLICY; + +typedef enum _IRQ_DEVICE_POLICY_USHORT { + IrqPolicyMachineDefault = 0, + IrqPolicyAllCloseProcessors = 1, + IrqPolicyOneCloseProcessor = 2, + IrqPolicyAllProcessorsInMachine = 3, + IrqPolicyAllProcessorsInGroup = 3, + IrqPolicySpecifiedProcessors = 4, + IrqPolicySpreadMessagesAcrossAllProcessors = 5}; + +#else /* defined(NT_PROCESSOR_GROUPS) */ + +typedef enum _IRQ_DEVICE_POLICY { + IrqPolicyMachineDefault = 0, + IrqPolicyAllCloseProcessors, + IrqPolicyOneCloseProcessor, + IrqPolicyAllProcessorsInMachine, + IrqPolicySpecifiedProcessors, + IrqPolicySpreadMessagesAcrossAllProcessors +} IRQ_DEVICE_POLICY, *PIRQ_DEVICE_POLICY; + +#endif + +typedef enum _IRQ_PRIORITY { + IrqPriorityUndefined = 0, + IrqPriorityLow, + IrqPriorityNormal, + IrqPriorityHigh +} IRQ_PRIORITY, *PIRQ_PRIORITY; + +typedef enum _IRQ_GROUP_POLICY { + GroupAffinityAllGroupZero = 0, + GroupAffinityDontCare +} IRQ_GROUP_POLICY, *PIRQ_GROUP_POLICY; + +#define MAXIMUM_VOLUME_LABEL_LENGTH (32 * sizeof(WCHAR)) + +typedef struct _OBJECT_HANDLE_INFORMATION { + ULONG HandleAttributes; + ACCESS_MASK GrantedAccess; +} OBJECT_HANDLE_INFORMATION, *POBJECT_HANDLE_INFORMATION; + +typedef struct _CLIENT_ID { + HANDLE UniqueProcess; + HANDLE UniqueThread; +} CLIENT_ID, *PCLIENT_ID; + +typedef struct _VPB { + CSHORT Type; + CSHORT Size; + USHORT Flags; + USHORT VolumeLabelLength; + struct _DEVICE_OBJECT *DeviceObject; + struct _DEVICE_OBJECT *RealDevice; + ULONG SerialNumber; + ULONG ReferenceCount; + WCHAR VolumeLabel[MAXIMUM_VOLUME_LABEL_LENGTH / sizeof(WCHAR)]; +} VPB, *PVPB; + +typedef enum _IO_ALLOCATION_ACTION { + KeepObject = 1, + DeallocateObject, + DeallocateObjectKeepRegisters +} IO_ALLOCATION_ACTION, *PIO_ALLOCATION_ACTION; + +typedef IO_ALLOCATION_ACTION +(NTAPI DRIVER_CONTROL)( + IN struct _DEVICE_OBJECT *DeviceObject, + IN struct _IRP *Irp, + IN PVOID MapRegisterBase, + IN PVOID Context); +typedef DRIVER_CONTROL *PDRIVER_CONTROL; + +typedef struct _WAIT_CONTEXT_BLOCK { + KDEVICE_QUEUE_ENTRY WaitQueueEntry; + PDRIVER_CONTROL DeviceRoutine; + PVOID DeviceContext; + ULONG NumberOfMapRegisters; + PVOID DeviceObject; + PVOID CurrentIrp; + PKDPC BufferChainingDpc; +} WAIT_CONTEXT_BLOCK, *PWAIT_CONTEXT_BLOCK; + +$endif +/* DEVICE_OBJECT.Flags */ +$if (_NTDDK_) +#define DO_DEVICE_HAS_NAME 0x00000040 +#define DO_SYSTEM_BOOT_PARTITION 0x00000100 +#define DO_LONG_TERM_REQUESTS 0x00000200 +#define DO_NEVER_LAST_DEVICE 0x00000400 +#define DO_LOW_PRIORITY_FILESYSTEM 0x00010000 +#define DO_SUPPORTS_TRANSACTIONS 0x00040000 +#define DO_FORCE_NEITHER_IO 0x00080000 +#define DO_VOLUME_DEVICE_OBJECT 0x00100000 +#define DO_SYSTEM_SYSTEM_PARTITION 0x00200000 +#define DO_SYSTEM_CRITICAL_PARTITION 0x00400000 +#define DO_DISALLOW_EXECUTE 0x00800000 +$endif +$if (_WDMDDK_) +#define DO_VERIFY_VOLUME 0x00000002 +#define DO_BUFFERED_IO 0x00000004 +#define DO_EXCLUSIVE 0x00000008 +#define DO_DIRECT_IO 0x00000010 +#define DO_MAP_IO_BUFFER 0x00000020 +#define DO_DEVICE_INITIALIZING 0x00000080 +#define DO_SHUTDOWN_REGISTERED 0x00000800 +#define DO_BUS_ENUMERATED_DEVICE 0x00001000 +#define DO_POWER_PAGABLE 0x00002000 +#define DO_POWER_INRUSH 0x00004000 + +/* DEVICE_OBJECT.Characteristics */ +#define FILE_REMOVABLE_MEDIA 0x00000001 +#define FILE_READ_ONLY_DEVICE 0x00000002 +#define FILE_FLOPPY_DISKETTE 0x00000004 +#define FILE_WRITE_ONCE_MEDIA 0x00000008 +#define FILE_REMOTE_DEVICE 0x00000010 +#define FILE_DEVICE_IS_MOUNTED 0x00000020 +#define FILE_VIRTUAL_VOLUME 0x00000040 +#define FILE_AUTOGENERATED_DEVICE_NAME 0x00000080 +#define FILE_DEVICE_SECURE_OPEN 0x00000100 +#define FILE_CHARACTERISTIC_PNP_DEVICE 0x00000800 +#define FILE_CHARACTERISTIC_TS_DEVICE 0x00001000 +#define FILE_CHARACTERISTIC_WEBDAV_DEVICE 0x00002000 + +/* DEVICE_OBJECT.AlignmentRequirement */ +#define FILE_BYTE_ALIGNMENT 0x00000000 +#define FILE_WORD_ALIGNMENT 0x00000001 +#define FILE_LONG_ALIGNMENT 0x00000003 +#define FILE_QUAD_ALIGNMENT 0x00000007 +#define FILE_OCTA_ALIGNMENT 0x0000000f +#define FILE_32_BYTE_ALIGNMENT 0x0000001f +#define FILE_64_BYTE_ALIGNMENT 0x0000003f +#define FILE_128_BYTE_ALIGNMENT 0x0000007f +#define FILE_256_BYTE_ALIGNMENT 0x000000ff +#define FILE_512_BYTE_ALIGNMENT 0x000001ff + +/* DEVICE_OBJECT.DeviceType */ +#define DEVICE_TYPE ULONG + +typedef struct _DEVICE_OBJECT { + CSHORT Type; + USHORT Size; + LONG ReferenceCount; + struct _DRIVER_OBJECT *DriverObject; + struct _DEVICE_OBJECT *NextDevice; + struct _DEVICE_OBJECT *AttachedDevice; + struct _IRP *CurrentIrp; + PIO_TIMER Timer; + ULONG Flags; + ULONG Characteristics; + volatile PVPB Vpb; + PVOID DeviceExtension; + DEVICE_TYPE DeviceType; + CCHAR StackSize; + union { + LIST_ENTRY ListEntry; + WAIT_CONTEXT_BLOCK Wcb; + } Queue; + ULONG AlignmentRequirement; + KDEVICE_QUEUE DeviceQueue; + KDPC Dpc; + ULONG ActiveThreadCount; + PSECURITY_DESCRIPTOR SecurityDescriptor; + KEVENT DeviceLock; + USHORT SectorSize; + USHORT Spare1; + struct _DEVOBJ_EXTENSION *DeviceObjectExtension; + PVOID Reserved; +} DEVICE_OBJECT, *PDEVICE_OBJECT; + +typedef enum _IO_SESSION_STATE { + IoSessionStateCreated = 1, + IoSessionStateInitialized, + IoSessionStateConnected, + IoSessionStateDisconnected, + IoSessionStateDisconnectedLoggedOn, + IoSessionStateLoggedOn, + IoSessionStateLoggedOff, + IoSessionStateTerminated, + IoSessionStateMax +} IO_SESSION_STATE, *PIO_SESSION_STATE; + +typedef enum _IO_COMPLETION_ROUTINE_RESULT { + ContinueCompletion = STATUS_CONTINUE_COMPLETION, + StopCompletion = STATUS_MORE_PROCESSING_REQUIRED +} IO_COMPLETION_ROUTINE_RESULT, *PIO_COMPLETION_ROUTINE_RESULT; + +typedef struct _IO_INTERRUPT_MESSAGE_INFO_ENTRY { + PHYSICAL_ADDRESS MessageAddress; + KAFFINITY TargetProcessorSet; + PKINTERRUPT InterruptObject; + ULONG MessageData; + ULONG Vector; + KIRQL Irql; + KINTERRUPT_MODE Mode; + KINTERRUPT_POLARITY Polarity; +} IO_INTERRUPT_MESSAGE_INFO_ENTRY, *PIO_INTERRUPT_MESSAGE_INFO_ENTRY; + +typedef struct _IO_INTERRUPT_MESSAGE_INFO { + KIRQL UnifiedIrql; + ULONG MessageCount; + IO_INTERRUPT_MESSAGE_INFO_ENTRY MessageInfo[1]; +} IO_INTERRUPT_MESSAGE_INFO, *PIO_INTERRUPT_MESSAGE_INFO; + +typedef struct _IO_CONNECT_INTERRUPT_FULLY_SPECIFIED_PARAMETERS { + IN PDEVICE_OBJECT PhysicalDeviceObject; + OUT PKINTERRUPT *InterruptObject; + IN PKSERVICE_ROUTINE ServiceRoutine; + IN PVOID ServiceContext; + IN PKSPIN_LOCK SpinLock OPTIONAL; + IN KIRQL SynchronizeIrql; + IN BOOLEAN FloatingSave; + IN BOOLEAN ShareVector; + IN ULONG Vector; + IN KIRQL Irql; + IN KINTERRUPT_MODE InterruptMode; + IN KAFFINITY ProcessorEnableMask; + IN USHORT Group; +} IO_CONNECT_INTERRUPT_FULLY_SPECIFIED_PARAMETERS, *PIO_CONNECT_INTERRUPT_FULLY_SPECIFIED_PARAMETERS; + +typedef struct _IO_CONNECT_INTERRUPT_LINE_BASED_PARAMETERS { + IN PDEVICE_OBJECT PhysicalDeviceObject; + OUT PKINTERRUPT *InterruptObject; + IN PKSERVICE_ROUTINE ServiceRoutine; + IN PVOID ServiceContext; + IN PKSPIN_LOCK SpinLock OPTIONAL; + IN KIRQL SynchronizeIrql OPTIONAL; + IN BOOLEAN FloatingSave; +} IO_CONNECT_INTERRUPT_LINE_BASED_PARAMETERS, *PIO_CONNECT_INTERRUPT_LINE_BASED_PARAMETERS; + +typedef struct _IO_CONNECT_INTERRUPT_MESSAGE_BASED_PARAMETERS { + IN PDEVICE_OBJECT PhysicalDeviceObject; + union { + OUT PVOID *Generic; + OUT PIO_INTERRUPT_MESSAGE_INFO *InterruptMessageTable; + OUT PKINTERRUPT *InterruptObject; + } ConnectionContext; + IN PKMESSAGE_SERVICE_ROUTINE MessageServiceRoutine; + IN PVOID ServiceContext; + IN PKSPIN_LOCK SpinLock OPTIONAL; + IN KIRQL SynchronizeIrql OPTIONAL; + IN BOOLEAN FloatingSave; + IN PKSERVICE_ROUTINE FallBackServiceRoutine OPTIONAL; +} IO_CONNECT_INTERRUPT_MESSAGE_BASED_PARAMETERS, *PIO_CONNECT_INTERRUPT_MESSAGE_BASED_PARAMETERS; + +typedef struct _IO_CONNECT_INTERRUPT_PARAMETERS { + IN OUT ULONG Version; + union { + IO_CONNECT_INTERRUPT_FULLY_SPECIFIED_PARAMETERS FullySpecified; + IO_CONNECT_INTERRUPT_LINE_BASED_PARAMETERS LineBased; + IO_CONNECT_INTERRUPT_MESSAGE_BASED_PARAMETERS MessageBased; + }; +} IO_CONNECT_INTERRUPT_PARAMETERS, *PIO_CONNECT_INTERRUPT_PARAMETERS; + +typedef struct _IO_DISCONNECT_INTERRUPT_PARAMETERS { + IN ULONG Version; + union { + IN PVOID Generic; + IN PKINTERRUPT InterruptObject; + IN PIO_INTERRUPT_MESSAGE_INFO InterruptMessageTable; + } ConnectionContext; +} IO_DISCONNECT_INTERRUPT_PARAMETERS, *PIO_DISCONNECT_INTERRUPT_PARAMETERS; + +typedef enum _IO_ACCESS_TYPE { + ReadAccess, + WriteAccess, + ModifyAccess +} IO_ACCESS_TYPE; + +typedef enum _IO_ACCESS_MODE { + SequentialAccess, + RandomAccess +} IO_ACCESS_MODE; + +typedef enum _IO_CONTAINER_NOTIFICATION_CLASS { + IoSessionStateNotification, + IoMaxContainerNotificationClass +} IO_CONTAINER_NOTIFICATION_CLASS; + +typedef struct _IO_SESSION_STATE_NOTIFICATION { + ULONG Size; + ULONG Flags; + PVOID IoObject; + ULONG EventMask; + PVOID Context; +} IO_SESSION_STATE_NOTIFICATION, *PIO_SESSION_STATE_NOTIFICATION; + +typedef enum _IO_CONTAINER_INFORMATION_CLASS { + IoSessionStateInformation, + IoMaxContainerInformationClass +} IO_CONTAINER_INFORMATION_CLASS; + +typedef struct _IO_SESSION_STATE_INFORMATION { + ULONG SessionId; + IO_SESSION_STATE SessionState; + BOOLEAN LocalSession; +} IO_SESSION_STATE_INFORMATION, *PIO_SESSION_STATE_INFORMATION; + +#if (NTDDI_VERSION >= NTDDI_WIN7) + +typedef NTSTATUS +(NTAPI *PIO_CONTAINER_NOTIFICATION_FUNCTION)( + VOID); + +typedef NTSTATUS +(NTAPI IO_SESSION_NOTIFICATION_FUNCTION)( + IN PVOID SessionObject, + IN PVOID IoObject, + IN ULONG Event, + IN PVOID Context, + IN PVOID NotificationPayload, + IN ULONG PayloadLength); + +typedef IO_SESSION_NOTIFICATION_FUNCTION *PIO_SESSION_NOTIFICATION_FUNCTION; + +#endif + +typedef struct _IO_REMOVE_LOCK_TRACKING_BLOCK * PIO_REMOVE_LOCK_TRACKING_BLOCK; + +typedef struct _IO_REMOVE_LOCK_COMMON_BLOCK { + BOOLEAN Removed; + BOOLEAN Reserved[3]; + volatile LONG IoCount; + KEVENT RemoveEvent; +} IO_REMOVE_LOCK_COMMON_BLOCK; + +typedef struct _IO_REMOVE_LOCK_DBG_BLOCK { + LONG Signature; + LONG HighWatermark; + LONGLONG MaxLockedTicks; + LONG AllocateTag; + LIST_ENTRY LockList; + KSPIN_LOCK Spin; + volatile LONG LowMemoryCount; + ULONG Reserved1[4]; + PVOID Reserved2; + PIO_REMOVE_LOCK_TRACKING_BLOCK Blocks; +} IO_REMOVE_LOCK_DBG_BLOCK; + +typedef struct _IO_REMOVE_LOCK { + IO_REMOVE_LOCK_COMMON_BLOCK Common; +#if DBG + IO_REMOVE_LOCK_DBG_BLOCK Dbg; +#endif +} IO_REMOVE_LOCK, *PIO_REMOVE_LOCK; + +typedef struct _IO_WORKITEM *PIO_WORKITEM; + +typedef VOID +(NTAPI IO_WORKITEM_ROUTINE)( + IN PDEVICE_OBJECT DeviceObject, + IN PVOID Context); +typedef IO_WORKITEM_ROUTINE *PIO_WORKITEM_ROUTINE; + +typedef VOID +(NTAPI IO_WORKITEM_ROUTINE_EX)( + IN PVOID IoObject, + IN PVOID Context OPTIONAL, + IN PIO_WORKITEM IoWorkItem); +typedef IO_WORKITEM_ROUTINE_EX *PIO_WORKITEM_ROUTINE_EX; + +typedef struct _SHARE_ACCESS { + ULONG OpenCount; + ULONG Readers; + ULONG Writers; + ULONG Deleters; + ULONG SharedRead; + ULONG SharedWrite; + ULONG SharedDelete; +} SHARE_ACCESS, *PSHARE_ACCESS; + +/* While MS WDK uses inheritance in C++, we cannot do this with gcc, as + inheritance, even from a struct renders the type non-POD. So we use + this hack */ +#define PCI_COMMON_HEADER_LAYOUT \ + USHORT VendorID; \ + USHORT DeviceID; \ + USHORT Command; \ + USHORT Status; \ + UCHAR RevisionID; \ + UCHAR ProgIf; \ + UCHAR SubClass; \ + UCHAR BaseClass; \ + UCHAR CacheLineSize; \ + UCHAR LatencyTimer; \ + UCHAR HeaderType; \ + UCHAR BIST; \ + union { \ + struct _PCI_HEADER_TYPE_0 { \ + ULONG BaseAddresses[PCI_TYPE0_ADDRESSES]; \ + ULONG CIS; \ + USHORT SubVendorID; \ + USHORT SubSystemID; \ + ULONG ROMBaseAddress; \ + UCHAR CapabilitiesPtr; \ + UCHAR Reserved1[3]; \ + ULONG Reserved2; \ + UCHAR InterruptLine; \ + UCHAR InterruptPin; \ + UCHAR MinimumGrant; \ + UCHAR MaximumLatency; \ + } type0; \ + struct _PCI_HEADER_TYPE_1 { \ + ULONG BaseAddresses[PCI_TYPE1_ADDRESSES]; \ + UCHAR PrimaryBus; \ + UCHAR SecondaryBus; \ + UCHAR SubordinateBus; \ + UCHAR SecondaryLatency; \ + UCHAR IOBase; \ + UCHAR IOLimit; \ + USHORT SecondaryStatus; \ + USHORT MemoryBase; \ + USHORT MemoryLimit; \ + USHORT PrefetchBase; \ + USHORT PrefetchLimit; \ + ULONG PrefetchBaseUpper32; \ + ULONG PrefetchLimitUpper32; \ + USHORT IOBaseUpper16; \ + USHORT IOLimitUpper16; \ + UCHAR CapabilitiesPtr; \ + UCHAR Reserved1[3]; \ + ULONG ROMBaseAddress; \ + UCHAR InterruptLine; \ + UCHAR InterruptPin; \ + USHORT BridgeControl; \ + } type1; \ + struct _PCI_HEADER_TYPE_2 { \ + ULONG SocketRegistersBaseAddress; \ + UCHAR CapabilitiesPtr; \ + UCHAR Reserved; \ + USHORT SecondaryStatus; \ + UCHAR PrimaryBus; \ + UCHAR SecondaryBus; \ + UCHAR SubordinateBus; \ + UCHAR SecondaryLatency; \ + struct { \ + ULONG Base; \ + ULONG Limit; \ + } Range[PCI_TYPE2_ADDRESSES-1]; \ + UCHAR InterruptLine; \ + UCHAR InterruptPin; \ + USHORT BridgeControl; \ + } type2; \ + } u; + +typedef enum _CREATE_FILE_TYPE { + CreateFileTypeNone, + CreateFileTypeNamedPipe, + CreateFileTypeMailslot +} CREATE_FILE_TYPE; + +#define IO_FORCE_ACCESS_CHECK 0x001 +#define IO_NO_PARAMETER_CHECKING 0x100 + +#define IO_REPARSE 0x0 +#define IO_REMOUNT 0x1 + +typedef struct _IO_STATUS_BLOCK { + _ANONYMOUS_UNION union { + NTSTATUS Status; + PVOID Pointer; + } DUMMYUNIONNAME; + ULONG_PTR Information; +} IO_STATUS_BLOCK, *PIO_STATUS_BLOCK; + +#if defined(_WIN64) +typedef struct _IO_STATUS_BLOCK32 { + NTSTATUS Status; + ULONG Information; +} IO_STATUS_BLOCK32, *PIO_STATUS_BLOCK32; +#endif + +typedef VOID +(NTAPI *PIO_APC_ROUTINE)( + IN PVOID ApcContext, + IN PIO_STATUS_BLOCK IoStatusBlock, + IN ULONG Reserved); + +#define PIO_APC_ROUTINE_DEFINED + +typedef enum _IO_SESSION_EVENT { + IoSessionEventIgnore = 0, + IoSessionEventCreated, + IoSessionEventTerminated, + IoSessionEventConnected, + IoSessionEventDisconnected, + IoSessionEventLogon, + IoSessionEventLogoff, + IoSessionEventMax +} IO_SESSION_EVENT, *PIO_SESSION_EVENT; + +#define IO_SESSION_STATE_ALL_EVENTS 0xffffffff +#define IO_SESSION_STATE_CREATION_EVENT 0x00000001 +#define IO_SESSION_STATE_TERMINATION_EVENT 0x00000002 +#define IO_SESSION_STATE_CONNECT_EVENT 0x00000004 +#define IO_SESSION_STATE_DISCONNECT_EVENT 0x00000008 +#define IO_SESSION_STATE_LOGON_EVENT 0x00000010 +#define IO_SESSION_STATE_LOGOFF_EVENT 0x00000020 + +#define IO_SESSION_STATE_VALID_EVENT_MASK 0x0000003f + +#define IO_SESSION_MAX_PAYLOAD_SIZE 256L + +typedef struct _IO_SESSION_CONNECT_INFO { + ULONG SessionId; + BOOLEAN LocalSession; +} IO_SESSION_CONNECT_INFO, *PIO_SESSION_CONNECT_INFO; + +#define EVENT_INCREMENT 1 +#define IO_NO_INCREMENT 0 +#define IO_CD_ROM_INCREMENT 1 +#define IO_DISK_INCREMENT 1 +#define IO_KEYBOARD_INCREMENT 6 +#define IO_MAILSLOT_INCREMENT 2 +#define IO_MOUSE_INCREMENT 6 +#define IO_NAMED_PIPE_INCREMENT 2 +#define IO_NETWORK_INCREMENT 2 +#define IO_PARALLEL_INCREMENT 1 +#define IO_SERIAL_INCREMENT 2 +#define IO_SOUND_INCREMENT 8 +#define IO_VIDEO_INCREMENT 1 +#define SEMAPHORE_INCREMENT 1 + +#define MM_MAXIMUM_DISK_IO_SIZE (0x10000) + +typedef struct _BOOTDISK_INFORMATION { + LONGLONG BootPartitionOffset; + LONGLONG SystemPartitionOffset; + ULONG BootDeviceSignature; + ULONG SystemDeviceSignature; +} BOOTDISK_INFORMATION, *PBOOTDISK_INFORMATION; + +typedef struct _BOOTDISK_INFORMATION_EX { + LONGLONG BootPartitionOffset; + LONGLONG SystemPartitionOffset; + ULONG BootDeviceSignature; + ULONG SystemDeviceSignature; + GUID BootDeviceGuid; + GUID SystemDeviceGuid; + BOOLEAN BootDeviceIsGpt; + BOOLEAN SystemDeviceIsGpt; +} BOOTDISK_INFORMATION_EX, *PBOOTDISK_INFORMATION_EX; + +#if (NTDDI_VERSION >= NTDDI_WIN7) + +typedef struct _LOADER_PARTITION_INFORMATION_EX { + ULONG PartitionStyle; + ULONG PartitionNumber; + union { + ULONG Signature; + GUID DeviceId; + }; + ULONG Flags; +} LOADER_PARTITION_INFORMATION_EX, *PLOADER_PARTITION_INFORMATION_EX; + +typedef struct _BOOTDISK_INFORMATION_LITE { + ULONG NumberEntries; + LOADER_PARTITION_INFORMATION_EX Entries[1]; +} BOOTDISK_INFORMATION_LITE, *PBOOTDISK_INFORMATION_LITE; + +#else + +#if (NTDDI_VERSION >= NTDDI_VISTA) +typedef struct _BOOTDISK_INFORMATION_LITE { + ULONG BootDeviceSignature; + ULONG SystemDeviceSignature; + GUID BootDeviceGuid; + GUID SystemDeviceGuid; + BOOLEAN BootDeviceIsGpt; + BOOLEAN SystemDeviceIsGpt; +} BOOTDISK_INFORMATION_LITE, *PBOOTDISK_INFORMATION_LITE; +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + +#include + +typedef struct _EISA_MEMORY_TYPE { + UCHAR ReadWrite:1; + UCHAR Cached:1; + UCHAR Reserved0:1; + UCHAR Type:2; + UCHAR Shared:1; + UCHAR Reserved1:1; + UCHAR MoreEntries:1; +} EISA_MEMORY_TYPE, *PEISA_MEMORY_TYPE; + +typedef struct _EISA_MEMORY_CONFIGURATION { + EISA_MEMORY_TYPE ConfigurationByte; + UCHAR DataSize; + USHORT AddressLowWord; + UCHAR AddressHighByte; + USHORT MemorySize; +} EISA_MEMORY_CONFIGURATION, *PEISA_MEMORY_CONFIGURATION; + +typedef struct _EISA_IRQ_DESCRIPTOR { + UCHAR Interrupt:4; + UCHAR Reserved:1; + UCHAR LevelTriggered:1; + UCHAR Shared:1; + UCHAR MoreEntries:1; +} EISA_IRQ_DESCRIPTOR, *PEISA_IRQ_DESCRIPTOR; + +typedef struct _EISA_IRQ_CONFIGURATION { + EISA_IRQ_DESCRIPTOR ConfigurationByte; + UCHAR Reserved; +} EISA_IRQ_CONFIGURATION, *PEISA_IRQ_CONFIGURATION; + +typedef struct _DMA_CONFIGURATION_BYTE0 { + UCHAR Channel:3; + UCHAR Reserved:3; + UCHAR Shared:1; + UCHAR MoreEntries:1; +} DMA_CONFIGURATION_BYTE0; + +typedef struct _DMA_CONFIGURATION_BYTE1 { + UCHAR Reserved0:2; + UCHAR TransferSize:2; + UCHAR Timing:2; + UCHAR Reserved1:2; +} DMA_CONFIGURATION_BYTE1; + +typedef struct _EISA_DMA_CONFIGURATION { + DMA_CONFIGURATION_BYTE0 ConfigurationByte0; + DMA_CONFIGURATION_BYTE1 ConfigurationByte1; +} EISA_DMA_CONFIGURATION, *PEISA_DMA_CONFIGURATION; + +typedef struct _EISA_PORT_DESCRIPTOR { + UCHAR NumberPorts:5; + UCHAR Reserved:1; + UCHAR Shared:1; + UCHAR MoreEntries:1; +} EISA_PORT_DESCRIPTOR, *PEISA_PORT_DESCRIPTOR; + +typedef struct _EISA_PORT_CONFIGURATION { + EISA_PORT_DESCRIPTOR Configuration; + USHORT PortAddress; +} EISA_PORT_CONFIGURATION, *PEISA_PORT_CONFIGURATION; + +typedef struct _CM_EISA_SLOT_INFORMATION { + UCHAR ReturnCode; + UCHAR ReturnFlags; + UCHAR MajorRevision; + UCHAR MinorRevision; + USHORT Checksum; + UCHAR NumberFunctions; + UCHAR FunctionInformation; + ULONG CompressedId; +} CM_EISA_SLOT_INFORMATION, *PCM_EISA_SLOT_INFORMATION; + +typedef struct _CM_EISA_FUNCTION_INFORMATION { + ULONG CompressedId; + UCHAR IdSlotFlags1; + UCHAR IdSlotFlags2; + UCHAR MinorRevision; + UCHAR MajorRevision; + UCHAR Selections[26]; + UCHAR FunctionFlags; + UCHAR TypeString[80]; + EISA_MEMORY_CONFIGURATION EisaMemory[9]; + EISA_IRQ_CONFIGURATION EisaIrq[7]; + EISA_DMA_CONFIGURATION EisaDma[4]; + EISA_PORT_CONFIGURATION EisaPort[20]; + UCHAR InitializationData[60]; +} CM_EISA_FUNCTION_INFORMATION, *PCM_EISA_FUNCTION_INFORMATION; + +#include + +/* CM_EISA_FUNCTION_INFORMATION.FunctionFlags */ + +#define EISA_FUNCTION_ENABLED 0x80 +#define EISA_FREE_FORM_DATA 0x40 +#define EISA_HAS_PORT_INIT_ENTRY 0x20 +#define EISA_HAS_PORT_RANGE 0x10 +#define EISA_HAS_DMA_ENTRY 0x08 +#define EISA_HAS_IRQ_ENTRY 0x04 +#define EISA_HAS_MEMORY_ENTRY 0x02 +#define EISA_HAS_TYPE_ENTRY 0x01 +#define EISA_HAS_INFORMATION \ + (EISA_HAS_PORT_RANGE + EISA_HAS_DMA_ENTRY + EISA_HAS_IRQ_ENTRY \ + + EISA_HAS_MEMORY_ENTRY + EISA_HAS_TYPE_ENTRY) + +#define EISA_MORE_ENTRIES 0x80 +#define EISA_SYSTEM_MEMORY 0x00 +#define EISA_MEMORY_TYPE_RAM 0x01 + +/* CM_EISA_SLOT_INFORMATION.ReturnCode */ + +#define EISA_INVALID_SLOT 0x80 +#define EISA_INVALID_FUNCTION 0x81 +#define EISA_INVALID_CONFIGURATION 0x82 +#define EISA_EMPTY_SLOT 0x83 +#define EISA_INVALID_BIOS_CALL 0x86 + +/* +** Plug and Play structures +*/ + +typedef VOID +(NTAPI *PINTERFACE_REFERENCE)( + PVOID Context); + +typedef VOID +(NTAPI *PINTERFACE_DEREFERENCE)( + PVOID Context); + +typedef BOOLEAN +(NTAPI TRANSLATE_BUS_ADDRESS)( + IN PVOID Context, + IN PHYSICAL_ADDRESS BusAddress, + IN ULONG Length, + IN OUT PULONG AddressSpace, + OUT PPHYSICAL_ADDRESS TranslatedAddress); +typedef TRANSLATE_BUS_ADDRESS *PTRANSLATE_BUS_ADDRESS; + +typedef struct _DMA_ADAPTER* +(NTAPI GET_DMA_ADAPTER)( + IN PVOID Context, + IN struct _DEVICE_DESCRIPTION *DeviceDescriptor, + OUT PULONG NumberOfMapRegisters); +typedef GET_DMA_ADAPTER *PGET_DMA_ADAPTER; + +typedef ULONG +(NTAPI GET_SET_DEVICE_DATA)( + IN PVOID Context, + IN ULONG DataType, + IN PVOID Buffer, + IN ULONG Offset, + IN ULONG Length); +typedef GET_SET_DEVICE_DATA *PGET_SET_DEVICE_DATA; + +typedef enum _DEVICE_INSTALL_STATE { + InstallStateInstalled, + InstallStateNeedsReinstall, + InstallStateFailedInstall, + InstallStateFinishInstall +} DEVICE_INSTALL_STATE, *PDEVICE_INSTALL_STATE; + +typedef struct _LEGACY_BUS_INFORMATION { + GUID BusTypeGuid; + INTERFACE_TYPE LegacyBusType; + ULONG BusNumber; +} LEGACY_BUS_INFORMATION, *PLEGACY_BUS_INFORMATION; + +typedef enum _DEVICE_REMOVAL_POLICY { + RemovalPolicyExpectNoRemoval = 1, + RemovalPolicyExpectOrderlyRemoval = 2, + RemovalPolicyExpectSurpriseRemoval = 3 +} DEVICE_REMOVAL_POLICY, *PDEVICE_REMOVAL_POLICY; + +typedef VOID +(NTAPI*PREENUMERATE_SELF)( + IN PVOID Context); + +typedef struct _REENUMERATE_SELF_INTERFACE_STANDARD { + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; + PREENUMERATE_SELF SurpriseRemoveAndReenumerateSelf; +} REENUMERATE_SELF_INTERFACE_STANDARD, *PREENUMERATE_SELF_INTERFACE_STANDARD; + +typedef VOID +(NTAPI *PIO_DEVICE_EJECT_CALLBACK)( + IN NTSTATUS Status, + IN OUT PVOID Context OPTIONAL); + +#define PCI_DEVICE_PRESENT_INTERFACE_VERSION 1 + +/* PCI_DEVICE_PRESENCE_PARAMETERS.Flags */ +#define PCI_USE_SUBSYSTEM_IDS 0x00000001 +#define PCI_USE_REVISION 0x00000002 +#define PCI_USE_VENDEV_IDS 0x00000004 +#define PCI_USE_CLASS_SUBCLASS 0x00000008 +#define PCI_USE_PROGIF 0x00000010 +#define PCI_USE_LOCAL_BUS 0x00000020 +#define PCI_USE_LOCAL_DEVICE 0x00000040 + +typedef struct _PCI_DEVICE_PRESENCE_PARAMETERS { + ULONG Size; + ULONG Flags; + USHORT VendorID; + USHORT DeviceID; + UCHAR RevisionID; + USHORT SubVendorID; + USHORT SubSystemID; + UCHAR BaseClass; + UCHAR SubClass; + UCHAR ProgIf; +} PCI_DEVICE_PRESENCE_PARAMETERS, *PPCI_DEVICE_PRESENCE_PARAMETERS; + +typedef BOOLEAN +(NTAPI PCI_IS_DEVICE_PRESENT)( + IN USHORT VendorID, + IN USHORT DeviceID, + IN UCHAR RevisionID, + IN USHORT SubVendorID, + IN USHORT SubSystemID, + IN ULONG Flags); +typedef PCI_IS_DEVICE_PRESENT *PPCI_IS_DEVICE_PRESENT; + +typedef BOOLEAN +(NTAPI PCI_IS_DEVICE_PRESENT_EX)( + IN PVOID Context, + IN PPCI_DEVICE_PRESENCE_PARAMETERS Parameters); +typedef PCI_IS_DEVICE_PRESENT_EX *PPCI_IS_DEVICE_PRESENT_EX; + +typedef struct _BUS_INTERFACE_STANDARD { + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; + PTRANSLATE_BUS_ADDRESS TranslateBusAddress; + PGET_DMA_ADAPTER GetDmaAdapter; + PGET_SET_DEVICE_DATA SetBusData; + PGET_SET_DEVICE_DATA GetBusData; +} BUS_INTERFACE_STANDARD, *PBUS_INTERFACE_STANDARD; + +typedef struct _PCI_DEVICE_PRESENT_INTERFACE { + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; + PPCI_IS_DEVICE_PRESENT IsDevicePresent; + PPCI_IS_DEVICE_PRESENT_EX IsDevicePresentEx; +} PCI_DEVICE_PRESENT_INTERFACE, *PPCI_DEVICE_PRESENT_INTERFACE; + +typedef struct _DEVICE_CAPABILITIES { + USHORT Size; + USHORT Version; + ULONG DeviceD1:1; + ULONG DeviceD2:1; + ULONG LockSupported:1; + ULONG EjectSupported:1; + ULONG Removable:1; + ULONG DockDevice:1; + ULONG UniqueID:1; + ULONG SilentInstall:1; + ULONG RawDeviceOK:1; + ULONG SurpriseRemovalOK:1; + ULONG WakeFromD0:1; + ULONG WakeFromD1:1; + ULONG WakeFromD2:1; + ULONG WakeFromD3:1; + ULONG HardwareDisabled:1; + ULONG NonDynamic:1; + ULONG WarmEjectSupported:1; + ULONG NoDisplayInUI:1; + ULONG Reserved:14; + ULONG Address; + ULONG UINumber; + DEVICE_POWER_STATE DeviceState[PowerSystemMaximum]; + SYSTEM_POWER_STATE SystemWake; + DEVICE_POWER_STATE DeviceWake; + ULONG D1Latency; + ULONG D2Latency; + ULONG D3Latency; +} DEVICE_CAPABILITIES, *PDEVICE_CAPABILITIES; + +typedef struct _DEVICE_INTERFACE_CHANGE_NOTIFICATION { + USHORT Version; + USHORT Size; + GUID Event; + GUID InterfaceClassGuid; + PUNICODE_STRING SymbolicLinkName; +} DEVICE_INTERFACE_CHANGE_NOTIFICATION, *PDEVICE_INTERFACE_CHANGE_NOTIFICATION; + +typedef struct _HWPROFILE_CHANGE_NOTIFICATION { + USHORT Version; + USHORT Size; + GUID Event; +} HWPROFILE_CHANGE_NOTIFICATION, *PHWPROFILE_CHANGE_NOTIFICATION; + +#undef INTERFACE + +typedef struct _INTERFACE { + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; +} INTERFACE, *PINTERFACE; + +typedef struct _PLUGPLAY_NOTIFICATION_HEADER { + USHORT Version; + USHORT Size; + GUID Event; +} PLUGPLAY_NOTIFICATION_HEADER, *PPLUGPLAY_NOTIFICATION_HEADER; + +typedef ULONG PNP_DEVICE_STATE, *PPNP_DEVICE_STATE; + +/* PNP_DEVICE_STATE */ + +#define PNP_DEVICE_DISABLED 0x00000001 +#define PNP_DEVICE_DONT_DISPLAY_IN_UI 0x00000002 +#define PNP_DEVICE_FAILED 0x00000004 +#define PNP_DEVICE_REMOVED 0x00000008 +#define PNP_DEVICE_RESOURCE_REQUIREMENTS_CHANGED 0x00000010 +#define PNP_DEVICE_NOT_DISABLEABLE 0x00000020 + +typedef struct _TARGET_DEVICE_CUSTOM_NOTIFICATION { + USHORT Version; + USHORT Size; + GUID Event; + struct _FILE_OBJECT *FileObject; + LONG NameBufferOffset; + UCHAR CustomDataBuffer[1]; +} TARGET_DEVICE_CUSTOM_NOTIFICATION, *PTARGET_DEVICE_CUSTOM_NOTIFICATION; + +typedef struct _TARGET_DEVICE_REMOVAL_NOTIFICATION { + USHORT Version; + USHORT Size; + GUID Event; + struct _FILE_OBJECT *FileObject; +} TARGET_DEVICE_REMOVAL_NOTIFICATION, *PTARGET_DEVICE_REMOVAL_NOTIFICATION; + +#if (NTDDI_VERSION >= NTDDI_VISTA) +#include +#define PLUGPLAY_PROPERTY_PERSISTENT 0x00000001 +#endif + +#define PNP_REPLACE_NO_MAP MAXLONGLONG + +typedef NTSTATUS +(NTAPI *PREPLACE_MAP_MEMORY)( + IN PHYSICAL_ADDRESS TargetPhysicalAddress, + IN PHYSICAL_ADDRESS SparePhysicalAddress, + IN OUT PLARGE_INTEGER NumberOfBytes, + OUT PVOID *TargetAddress, + OUT PVOID *SpareAddress); + +typedef struct _PNP_REPLACE_MEMORY_LIST { + ULONG AllocatedCount; + ULONG Count; + ULONGLONG TotalLength; + struct { + PHYSICAL_ADDRESS Address; + ULONGLONG Length; + } Ranges[ANYSIZE_ARRAY]; +} PNP_REPLACE_MEMORY_LIST, *PPNP_REPLACE_MEMORY_LIST; + +typedef struct _PNP_REPLACE_PROCESSOR_LIST { + PKAFFINITY Affinity; + ULONG GroupCount; + ULONG AllocatedCount; + ULONG Count; + ULONG ApicIds[ANYSIZE_ARRAY]; +} PNP_REPLACE_PROCESSOR_LIST, *PPNP_REPLACE_PROCESSOR_LIST; + +typedef struct _PNP_REPLACE_PROCESSOR_LIST_V1 { + KAFFINITY AffinityMask; + ULONG AllocatedCount; + ULONG Count; + ULONG ApicIds[ANYSIZE_ARRAY]; +} PNP_REPLACE_PROCESSOR_LIST_V1, *PPNP_REPLACE_PROCESSOR_LIST_V1; + +#define PNP_REPLACE_PARAMETERS_VERSION 2 + +typedef struct _PNP_REPLACE_PARAMETERS { + ULONG Size; + ULONG Version; + ULONG64 Target; + ULONG64 Spare; + PPNP_REPLACE_PROCESSOR_LIST TargetProcessors; + PPNP_REPLACE_PROCESSOR_LIST SpareProcessors; + PPNP_REPLACE_MEMORY_LIST TargetMemory; + PPNP_REPLACE_MEMORY_LIST SpareMemory; + PREPLACE_MAP_MEMORY MapMemory; +} PNP_REPLACE_PARAMETERS, *PPNP_REPLACE_PARAMETERS; + +typedef VOID +(NTAPI *PREPLACE_UNLOAD)( + VOID); + +typedef NTSTATUS +(NTAPI *PREPLACE_BEGIN)( + IN PPNP_REPLACE_PARAMETERS Parameters, + OUT PVOID *Context); + +typedef NTSTATUS +(NTAPI *PREPLACE_END)( + IN PVOID Context); + +typedef NTSTATUS +(NTAPI *PREPLACE_MIRROR_PHYSICAL_MEMORY)( + IN PVOID Context, + IN PHYSICAL_ADDRESS PhysicalAddress, + IN LARGE_INTEGER ByteCount); + +typedef NTSTATUS +(NTAPI *PREPLACE_SET_PROCESSOR_ID)( + IN PVOID Context, + IN ULONG ApicId, + IN BOOLEAN Target); + +typedef NTSTATUS +(NTAPI *PREPLACE_SWAP)( + IN PVOID Context); + +typedef NTSTATUS +(NTAPI *PREPLACE_INITIATE_HARDWARE_MIRROR)( + IN PVOID Context); + +typedef NTSTATUS +(NTAPI *PREPLACE_MIRROR_PLATFORM_MEMORY)( + IN PVOID Context); + +typedef NTSTATUS +(NTAPI *PREPLACE_GET_MEMORY_DESTINATION)( + IN PVOID Context, + IN PHYSICAL_ADDRESS SourceAddress, + OUT PPHYSICAL_ADDRESS DestinationAddress); + +typedef NTSTATUS +(NTAPI *PREPLACE_ENABLE_DISABLE_HARDWARE_QUIESCE)( + IN PVOID Context, + IN BOOLEAN Enable); + +#define PNP_REPLACE_DRIVER_INTERFACE_VERSION 1 +#define PNP_REPLACE_DRIVER_INTERFACE_MINIMUM_SIZE \ + FIELD_OFFSET(PNP_REPLACE_DRIVER_INTERFACE, InitiateHardwareMirror) + +#define PNP_REPLACE_MEMORY_SUPPORTED 0x0001 +#define PNP_REPLACE_PROCESSOR_SUPPORTED 0x0002 +#define PNP_REPLACE_HARDWARE_MEMORY_MIRRORING 0x0004 +#define PNP_REPLACE_HARDWARE_PAGE_COPY 0x0008 +#define PNP_REPLACE_HARDWARE_QUIESCE 0x0010 + +typedef struct _PNP_REPLACE_DRIVER_INTERFACE { + ULONG Size; + ULONG Version; + ULONG Flags; + PREPLACE_UNLOAD Unload; + PREPLACE_BEGIN BeginReplace; + PREPLACE_END EndReplace; + PREPLACE_MIRROR_PHYSICAL_MEMORY MirrorPhysicalMemory; + PREPLACE_SET_PROCESSOR_ID SetProcessorId; + PREPLACE_SWAP Swap; + PREPLACE_INITIATE_HARDWARE_MIRROR InitiateHardwareMirror; + PREPLACE_MIRROR_PLATFORM_MEMORY MirrorPlatformMemory; + PREPLACE_GET_MEMORY_DESTINATION GetMemoryDestination; + PREPLACE_ENABLE_DISABLE_HARDWARE_QUIESCE EnableDisableHardwareQuiesce; +} PNP_REPLACE_DRIVER_INTERFACE, *PPNP_REPLACE_DRIVER_INTERFACE; + +typedef NTSTATUS +(NTAPI *PREPLACE_DRIVER_INIT)( + IN OUT PPNP_REPLACE_DRIVER_INTERFACE Interface, + IN PVOID Unused); + +typedef enum _DEVICE_USAGE_NOTIFICATION_TYPE { + DeviceUsageTypeUndefined, + DeviceUsageTypePaging, + DeviceUsageTypeHibernation, + DeviceUsageTypeDumpFile +} DEVICE_USAGE_NOTIFICATION_TYPE; + +typedef struct _POWER_SEQUENCE { + ULONG SequenceD1; + ULONG SequenceD2; + ULONG SequenceD3; +} POWER_SEQUENCE, *PPOWER_SEQUENCE; + +typedef enum { + DevicePropertyDeviceDescription = 0x0, + DevicePropertyHardwareID = 0x1, + DevicePropertyCompatibleIDs = 0x2, + DevicePropertyBootConfiguration = 0x3, + DevicePropertyBootConfigurationTranslated = 0x4, + DevicePropertyClassName = 0x5, + DevicePropertyClassGuid = 0x6, + DevicePropertyDriverKeyName = 0x7, + DevicePropertyManufacturer = 0x8, + DevicePropertyFriendlyName = 0x9, + DevicePropertyLocationInformation = 0xa, + DevicePropertyPhysicalDeviceObjectName = 0xb, + DevicePropertyBusTypeGuid = 0xc, + DevicePropertyLegacyBusType = 0xd, + DevicePropertyBusNumber = 0xe, + DevicePropertyEnumeratorName = 0xf, + DevicePropertyAddress = 0x10, + DevicePropertyUINumber = 0x11, + DevicePropertyInstallState = 0x12, + DevicePropertyRemovalPolicy = 0x13, + DevicePropertyResourceRequirements = 0x14, + DevicePropertyAllocatedResources = 0x15, + DevicePropertyContainerID = 0x16 +} DEVICE_REGISTRY_PROPERTY; + +typedef enum _IO_NOTIFICATION_EVENT_CATEGORY { + EventCategoryReserved, + EventCategoryHardwareProfileChange, + EventCategoryDeviceInterfaceChange, + EventCategoryTargetDeviceChange +} IO_NOTIFICATION_EVENT_CATEGORY; + +typedef enum _IO_PRIORITY_HINT { + IoPriorityVeryLow = 0, + IoPriorityLow, + IoPriorityNormal, + IoPriorityHigh, + IoPriorityCritical, + MaxIoPriorityTypes +} IO_PRIORITY_HINT; + +#define PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES 0x00000001 + +typedef NTSTATUS +(NTAPI DRIVER_NOTIFICATION_CALLBACK_ROUTINE)( + IN PVOID NotificationStructure, + IN PVOID Context); +typedef DRIVER_NOTIFICATION_CALLBACK_ROUTINE *PDRIVER_NOTIFICATION_CALLBACK_ROUTINE; + +typedef VOID +(NTAPI DEVICE_CHANGE_COMPLETE_CALLBACK)( + IN PVOID Context); +typedef DEVICE_CHANGE_COMPLETE_CALLBACK *PDEVICE_CHANGE_COMPLETE_CALLBACK; + +typedef enum _FILE_INFORMATION_CLASS { + FileDirectoryInformation = 1, + FileFullDirectoryInformation, + FileBothDirectoryInformation, + FileBasicInformation, + FileStandardInformation, + FileInternalInformation, + FileEaInformation, + FileAccessInformation, + FileNameInformation, + FileRenameInformation, + FileLinkInformation, + FileNamesInformation, + FileDispositionInformation, + FilePositionInformation, + FileFullEaInformation, + FileModeInformation, + FileAlignmentInformation, + FileAllInformation, + FileAllocationInformation, + FileEndOfFileInformation, + FileAlternateNameInformation, + FileStreamInformation, + FilePipeInformation, + FilePipeLocalInformation, + FilePipeRemoteInformation, + FileMailslotQueryInformation, + FileMailslotSetInformation, + FileCompressionInformation, + FileObjectIdInformation, + FileCompletionInformation, + FileMoveClusterInformation, + FileQuotaInformation, + FileReparsePointInformation, + FileNetworkOpenInformation, + FileAttributeTagInformation, + FileTrackingInformation, + FileIdBothDirectoryInformation, + FileIdFullDirectoryInformation, + FileValidDataLengthInformation, + FileShortNameInformation, + FileIoCompletionNotificationInformation, + FileIoStatusBlockRangeInformation, + FileIoPriorityHintInformation, + FileSfioReserveInformation, + FileSfioVolumeInformation, + FileHardLinkInformation, + FileProcessIdsUsingFileInformation, + FileNormalizedNameInformation, + FileNetworkPhysicalNameInformation, + FileIdGlobalTxDirectoryInformation, + FileIsRemoteDeviceInformation, + FileAttributeCacheInformation, + FileNumaNodeInformation, + FileStandardLinkInformation, + FileRemoteProtocolInformation, + FileMaximumInformation +} FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS; + +typedef struct _FILE_POSITION_INFORMATION { + LARGE_INTEGER CurrentByteOffset; +} FILE_POSITION_INFORMATION, *PFILE_POSITION_INFORMATION; + +typedef struct _FILE_BASIC_INFORMATION { + LARGE_INTEGER CreationTime; + LARGE_INTEGER LastAccessTime; + LARGE_INTEGER LastWriteTime; + LARGE_INTEGER ChangeTime; + ULONG FileAttributes; +} FILE_BASIC_INFORMATION, *PFILE_BASIC_INFORMATION; + +typedef struct _FILE_IO_PRIORITY_HINT_INFORMATION { + IO_PRIORITY_HINT PriorityHint; +} FILE_IO_PRIORITY_HINT_INFORMATION, *PFILE_IO_PRIORITY_HINT_INFORMATION; + +typedef struct _FILE_IO_COMPLETION_NOTIFICATION_INFORMATION { + ULONG Flags; +} FILE_IO_COMPLETION_NOTIFICATION_INFORMATION, *PFILE_IO_COMPLETION_NOTIFICATION_INFORMATION; + +typedef struct _FILE_IOSTATUSBLOCK_RANGE_INFORMATION { + PUCHAR IoStatusBlockRange; + ULONG Length; +} FILE_IOSTATUSBLOCK_RANGE_INFORMATION, *PFILE_IOSTATUSBLOCK_RANGE_INFORMATION; + +typedef struct _FILE_IS_REMOTE_DEVICE_INFORMATION { + BOOLEAN IsRemote; +} FILE_IS_REMOTE_DEVICE_INFORMATION, *PFILE_IS_REMOTE_DEVICE_INFORMATION; + +typedef struct _FILE_NUMA_NODE_INFORMATION { + USHORT NodeNumber; +} FILE_NUMA_NODE_INFORMATION, *PFILE_NUMA_NODE_INFORMATION; + +typedef struct _FILE_PROCESS_IDS_USING_FILE_INFORMATION { + ULONG NumberOfProcessIdsInList; + ULONG_PTR ProcessIdList[1]; +} FILE_PROCESS_IDS_USING_FILE_INFORMATION, *PFILE_PROCESS_IDS_USING_FILE_INFORMATION; + +typedef struct _FILE_STANDARD_INFORMATION { + LARGE_INTEGER AllocationSize; + LARGE_INTEGER EndOfFile; + ULONG NumberOfLinks; + BOOLEAN DeletePending; + BOOLEAN Directory; +} FILE_STANDARD_INFORMATION, *PFILE_STANDARD_INFORMATION; + +typedef struct _FILE_NETWORK_OPEN_INFORMATION { + LARGE_INTEGER CreationTime; + LARGE_INTEGER LastAccessTime; + LARGE_INTEGER LastWriteTime; + LARGE_INTEGER ChangeTime; + LARGE_INTEGER AllocationSize; + LARGE_INTEGER EndOfFile; + ULONG FileAttributes; +} FILE_NETWORK_OPEN_INFORMATION, *PFILE_NETWORK_OPEN_INFORMATION; + +typedef enum _FSINFOCLASS { + FileFsVolumeInformation = 1, + FileFsLabelInformation, + FileFsSizeInformation, + FileFsDeviceInformation, + FileFsAttributeInformation, + FileFsControlInformation, + FileFsFullSizeInformation, + FileFsObjectIdInformation, + FileFsDriverPathInformation, + FileFsVolumeFlagsInformation, + FileFsMaximumInformation +} FS_INFORMATION_CLASS, *PFS_INFORMATION_CLASS; + +typedef struct _FILE_FS_DEVICE_INFORMATION { + DEVICE_TYPE DeviceType; + ULONG Characteristics; +} FILE_FS_DEVICE_INFORMATION, *PFILE_FS_DEVICE_INFORMATION; + +typedef struct _FILE_FULL_EA_INFORMATION { + ULONG NextEntryOffset; + UCHAR Flags; + UCHAR EaNameLength; + USHORT EaValueLength; + CHAR EaName[1]; +} FILE_FULL_EA_INFORMATION, *PFILE_FULL_EA_INFORMATION; + +typedef struct _FILE_SFIO_RESERVE_INFORMATION { + ULONG RequestsPerPeriod; + ULONG Period; + BOOLEAN RetryFailures; + BOOLEAN Discardable; + ULONG RequestSize; + ULONG NumOutstandingRequests; +} FILE_SFIO_RESERVE_INFORMATION, *PFILE_SFIO_RESERVE_INFORMATION; + +typedef struct _FILE_SFIO_VOLUME_INFORMATION { + ULONG MaximumRequestsPerPeriod; + ULONG MinimumPeriod; + ULONG MinimumTransferSize; +} FILE_SFIO_VOLUME_INFORMATION, *PFILE_SFIO_VOLUME_INFORMATION; + +#define FILE_SKIP_COMPLETION_PORT_ON_SUCCESS 0x1 +#define FILE_SKIP_SET_EVENT_ON_HANDLE 0x2 +#define FILE_SKIP_SET_USER_EVENT_ON_FAST_IO 0x4 + +#define FM_LOCK_BIT (0x1) +#define FM_LOCK_BIT_V (0x0) +#define FM_LOCK_WAITER_WOKEN (0x2) +#define FM_LOCK_WAITER_INC (0x4) + +typedef BOOLEAN +(NTAPI FAST_IO_CHECK_IF_POSSIBLE)( + IN struct _FILE_OBJECT *FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN BOOLEAN Wait, + IN ULONG LockKey, + IN BOOLEAN CheckForReadOperation, + OUT PIO_STATUS_BLOCK IoStatus, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_CHECK_IF_POSSIBLE *PFAST_IO_CHECK_IF_POSSIBLE; + +typedef BOOLEAN +(NTAPI FAST_IO_READ)( + IN struct _FILE_OBJECT *FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN BOOLEAN Wait, + IN ULONG LockKey, + OUT PVOID Buffer, + OUT PIO_STATUS_BLOCK IoStatus, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_READ *PFAST_IO_READ; + +typedef BOOLEAN +(NTAPI FAST_IO_WRITE)( + IN struct _FILE_OBJECT *FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN BOOLEAN Wait, + IN ULONG LockKey, + IN PVOID Buffer, + OUT PIO_STATUS_BLOCK IoStatus, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_WRITE *PFAST_IO_WRITE; + +typedef BOOLEAN +(NTAPI FAST_IO_QUERY_BASIC_INFO)( + IN struct _FILE_OBJECT *FileObject, + IN BOOLEAN Wait, + OUT PFILE_BASIC_INFORMATION Buffer, + OUT PIO_STATUS_BLOCK IoStatus, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_QUERY_BASIC_INFO *PFAST_IO_QUERY_BASIC_INFO; + +typedef BOOLEAN +(NTAPI FAST_IO_QUERY_STANDARD_INFO)( + IN struct _FILE_OBJECT *FileObject, + IN BOOLEAN Wait, + OUT PFILE_STANDARD_INFORMATION Buffer, + OUT PIO_STATUS_BLOCK IoStatus, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_QUERY_STANDARD_INFO *PFAST_IO_QUERY_STANDARD_INFO; + +typedef BOOLEAN +(NTAPI FAST_IO_LOCK)( + IN struct _FILE_OBJECT *FileObject, + IN PLARGE_INTEGER FileOffset, + IN PLARGE_INTEGER Length, + PEPROCESS ProcessId, + ULONG Key, + BOOLEAN FailImmediately, + BOOLEAN ExclusiveLock, + OUT PIO_STATUS_BLOCK IoStatus, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_LOCK *PFAST_IO_LOCK; + +typedef BOOLEAN +(NTAPI FAST_IO_UNLOCK_SINGLE)( + IN struct _FILE_OBJECT *FileObject, + IN PLARGE_INTEGER FileOffset, + IN PLARGE_INTEGER Length, + PEPROCESS ProcessId, + ULONG Key, + OUT PIO_STATUS_BLOCK IoStatus, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_UNLOCK_SINGLE *PFAST_IO_UNLOCK_SINGLE; + +typedef BOOLEAN +(NTAPI FAST_IO_UNLOCK_ALL)( + IN struct _FILE_OBJECT *FileObject, + PEPROCESS ProcessId, + OUT PIO_STATUS_BLOCK IoStatus, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_UNLOCK_ALL *PFAST_IO_UNLOCK_ALL; + +typedef BOOLEAN +(NTAPI FAST_IO_UNLOCK_ALL_BY_KEY)( + IN struct _FILE_OBJECT *FileObject, + PVOID ProcessId, + ULONG Key, + OUT PIO_STATUS_BLOCK IoStatus, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_UNLOCK_ALL_BY_KEY *PFAST_IO_UNLOCK_ALL_BY_KEY; + +typedef BOOLEAN +(NTAPI FAST_IO_DEVICE_CONTROL)( + IN struct _FILE_OBJECT *FileObject, + IN BOOLEAN Wait, + IN PVOID InputBuffer OPTIONAL, + IN ULONG InputBufferLength, + OUT PVOID OutputBuffer OPTIONAL, + IN ULONG OutputBufferLength, + IN ULONG IoControlCode, + OUT PIO_STATUS_BLOCK IoStatus, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_DEVICE_CONTROL *PFAST_IO_DEVICE_CONTROL; + +typedef VOID +(NTAPI FAST_IO_ACQUIRE_FILE)( + IN struct _FILE_OBJECT *FileObject); +typedef FAST_IO_ACQUIRE_FILE *PFAST_IO_ACQUIRE_FILE; + +typedef VOID +(NTAPI FAST_IO_RELEASE_FILE)( + IN struct _FILE_OBJECT *FileObject); +typedef FAST_IO_RELEASE_FILE *PFAST_IO_RELEASE_FILE; + +typedef VOID +(NTAPI FAST_IO_DETACH_DEVICE)( + IN struct _DEVICE_OBJECT *SourceDevice, + IN struct _DEVICE_OBJECT *TargetDevice); +typedef FAST_IO_DETACH_DEVICE *PFAST_IO_DETACH_DEVICE; + +typedef BOOLEAN +(NTAPI FAST_IO_QUERY_NETWORK_OPEN_INFO)( + IN struct _FILE_OBJECT *FileObject, + IN BOOLEAN Wait, + OUT struct _FILE_NETWORK_OPEN_INFORMATION *Buffer, + OUT struct _IO_STATUS_BLOCK *IoStatus, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_QUERY_NETWORK_OPEN_INFO *PFAST_IO_QUERY_NETWORK_OPEN_INFO; + +typedef NTSTATUS +(NTAPI FAST_IO_ACQUIRE_FOR_MOD_WRITE)( + IN struct _FILE_OBJECT *FileObject, + IN PLARGE_INTEGER EndingOffset, + OUT struct _ERESOURCE **ResourceToRelease, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_ACQUIRE_FOR_MOD_WRITE *PFAST_IO_ACQUIRE_FOR_MOD_WRITE; + +typedef BOOLEAN +(NTAPI FAST_IO_MDL_READ)( + IN struct _FILE_OBJECT *FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN ULONG LockKey, + OUT PMDL *MdlChain, + OUT PIO_STATUS_BLOCK IoStatus, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_MDL_READ *PFAST_IO_MDL_READ; + +typedef BOOLEAN +(NTAPI FAST_IO_MDL_READ_COMPLETE)( + IN struct _FILE_OBJECT *FileObject, + IN PMDL MdlChain, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_MDL_READ_COMPLETE *PFAST_IO_MDL_READ_COMPLETE; + +typedef BOOLEAN +(NTAPI FAST_IO_PREPARE_MDL_WRITE)( + IN struct _FILE_OBJECT *FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN ULONG LockKey, + OUT PMDL *MdlChain, + OUT PIO_STATUS_BLOCK IoStatus, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_PREPARE_MDL_WRITE *PFAST_IO_PREPARE_MDL_WRITE; + +typedef BOOLEAN +(NTAPI FAST_IO_MDL_WRITE_COMPLETE)( + IN struct _FILE_OBJECT *FileObject, + IN PLARGE_INTEGER FileOffset, + IN PMDL MdlChain, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_MDL_WRITE_COMPLETE *PFAST_IO_MDL_WRITE_COMPLETE; + +typedef BOOLEAN +(NTAPI FAST_IO_READ_COMPRESSED)( + IN struct _FILE_OBJECT *FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN ULONG LockKey, + OUT PVOID Buffer, + OUT PMDL *MdlChain, + OUT PIO_STATUS_BLOCK IoStatus, + OUT struct _COMPRESSED_DATA_INFO *CompressedDataInfo, + IN ULONG CompressedDataInfoLength, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_READ_COMPRESSED *PFAST_IO_READ_COMPRESSED; + +typedef BOOLEAN +(NTAPI FAST_IO_WRITE_COMPRESSED)( + IN struct _FILE_OBJECT *FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN ULONG LockKey, + IN PVOID Buffer, + OUT PMDL *MdlChain, + OUT PIO_STATUS_BLOCK IoStatus, + IN struct _COMPRESSED_DATA_INFO *CompressedDataInfo, + IN ULONG CompressedDataInfoLength, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_WRITE_COMPRESSED *PFAST_IO_WRITE_COMPRESSED; + +typedef BOOLEAN +(NTAPI FAST_IO_MDL_READ_COMPLETE_COMPRESSED)( + IN struct _FILE_OBJECT *FileObject, + IN PMDL MdlChain, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_MDL_READ_COMPLETE_COMPRESSED *PFAST_IO_MDL_READ_COMPLETE_COMPRESSED; + +typedef BOOLEAN +(NTAPI FAST_IO_MDL_WRITE_COMPLETE_COMPRESSED)( + IN struct _FILE_OBJECT *FileObject, + IN PLARGE_INTEGER FileOffset, + IN PMDL MdlChain, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_MDL_WRITE_COMPLETE_COMPRESSED *PFAST_IO_MDL_WRITE_COMPLETE_COMPRESSED; + +typedef BOOLEAN +(NTAPI FAST_IO_QUERY_OPEN)( + IN struct _IRP *Irp, + OUT PFILE_NETWORK_OPEN_INFORMATION NetworkInformation, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_QUERY_OPEN *PFAST_IO_QUERY_OPEN; + +typedef NTSTATUS +(NTAPI FAST_IO_RELEASE_FOR_MOD_WRITE)( + IN struct _FILE_OBJECT *FileObject, + IN struct _ERESOURCE *ResourceToRelease, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_RELEASE_FOR_MOD_WRITE *PFAST_IO_RELEASE_FOR_MOD_WRITE; + +typedef NTSTATUS +(NTAPI FAST_IO_ACQUIRE_FOR_CCFLUSH)( + IN struct _FILE_OBJECT *FileObject, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_ACQUIRE_FOR_CCFLUSH *PFAST_IO_ACQUIRE_FOR_CCFLUSH; + +typedef NTSTATUS +(NTAPI FAST_IO_RELEASE_FOR_CCFLUSH)( + IN struct _FILE_OBJECT *FileObject, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_RELEASE_FOR_CCFLUSH *PFAST_IO_RELEASE_FOR_CCFLUSH; + +typedef struct _FAST_IO_DISPATCH { + ULONG SizeOfFastIoDispatch; + PFAST_IO_CHECK_IF_POSSIBLE FastIoCheckIfPossible; + PFAST_IO_READ FastIoRead; + PFAST_IO_WRITE FastIoWrite; + PFAST_IO_QUERY_BASIC_INFO FastIoQueryBasicInfo; + PFAST_IO_QUERY_STANDARD_INFO FastIoQueryStandardInfo; + PFAST_IO_LOCK FastIoLock; + PFAST_IO_UNLOCK_SINGLE FastIoUnlockSingle; + PFAST_IO_UNLOCK_ALL FastIoUnlockAll; + PFAST_IO_UNLOCK_ALL_BY_KEY FastIoUnlockAllByKey; + PFAST_IO_DEVICE_CONTROL FastIoDeviceControl; + PFAST_IO_ACQUIRE_FILE AcquireFileForNtCreateSection; + PFAST_IO_RELEASE_FILE ReleaseFileForNtCreateSection; + PFAST_IO_DETACH_DEVICE FastIoDetachDevice; + PFAST_IO_QUERY_NETWORK_OPEN_INFO FastIoQueryNetworkOpenInfo; + PFAST_IO_ACQUIRE_FOR_MOD_WRITE AcquireForModWrite; + PFAST_IO_MDL_READ MdlRead; + PFAST_IO_MDL_READ_COMPLETE MdlReadComplete; + PFAST_IO_PREPARE_MDL_WRITE PrepareMdlWrite; + PFAST_IO_MDL_WRITE_COMPLETE MdlWriteComplete; + PFAST_IO_READ_COMPRESSED FastIoReadCompressed; + PFAST_IO_WRITE_COMPRESSED FastIoWriteCompressed; + PFAST_IO_MDL_READ_COMPLETE_COMPRESSED MdlReadCompleteCompressed; + PFAST_IO_MDL_WRITE_COMPLETE_COMPRESSED MdlWriteCompleteCompressed; + PFAST_IO_QUERY_OPEN FastIoQueryOpen; + PFAST_IO_RELEASE_FOR_MOD_WRITE ReleaseForModWrite; + PFAST_IO_ACQUIRE_FOR_CCFLUSH AcquireForCcFlush; + PFAST_IO_RELEASE_FOR_CCFLUSH ReleaseForCcFlush; +} FAST_IO_DISPATCH, *PFAST_IO_DISPATCH; + +typedef struct _SECTION_OBJECT_POINTERS { + PVOID DataSectionObject; + PVOID SharedCacheMap; + PVOID ImageSectionObject; +} SECTION_OBJECT_POINTERS, *PSECTION_OBJECT_POINTERS; + +typedef struct _IO_COMPLETION_CONTEXT { + PVOID Port; + PVOID Key; +} IO_COMPLETION_CONTEXT, *PIO_COMPLETION_CONTEXT; + +/* FILE_OBJECT.Flags */ +#define FO_FILE_OPEN 0x00000001 +#define FO_SYNCHRONOUS_IO 0x00000002 +#define FO_ALERTABLE_IO 0x00000004 +#define FO_NO_INTERMEDIATE_BUFFERING 0x00000008 +#define FO_WRITE_THROUGH 0x00000010 +#define FO_SEQUENTIAL_ONLY 0x00000020 +#define FO_CACHE_SUPPORTED 0x00000040 +#define FO_NAMED_PIPE 0x00000080 +#define FO_STREAM_FILE 0x00000100 +#define FO_MAILSLOT 0x00000200 +#define FO_GENERATE_AUDIT_ON_CLOSE 0x00000400 +#define FO_QUEUE_IRP_TO_THREAD 0x00000400 +#define FO_DIRECT_DEVICE_OPEN 0x00000800 +#define FO_FILE_MODIFIED 0x00001000 +#define FO_FILE_SIZE_CHANGED 0x00002000 +#define FO_CLEANUP_COMPLETE 0x00004000 +#define FO_TEMPORARY_FILE 0x00008000 +#define FO_DELETE_ON_CLOSE 0x00010000 +#define FO_OPENED_CASE_SENSITIVE 0x00020000 +#define FO_HANDLE_CREATED 0x00040000 +#define FO_FILE_FAST_IO_READ 0x00080000 +#define FO_RANDOM_ACCESS 0x00100000 +#define FO_FILE_OPEN_CANCELLED 0x00200000 +#define FO_VOLUME_OPEN 0x00400000 +#define FO_REMOTE_ORIGIN 0x01000000 +#define FO_DISALLOW_EXCLUSIVE 0x02000000 +#define FO_SKIP_COMPLETION_PORT 0x02000000 +#define FO_SKIP_SET_EVENT 0x04000000 +#define FO_SKIP_SET_FAST_IO 0x08000000 +#define FO_FLAGS_VALID_ONLY_DURING_CREATE FO_DISALLOW_EXCLUSIVE + +/* VPB.Flags */ +#define VPB_MOUNTED 0x0001 +#define VPB_LOCKED 0x0002 +#define VPB_PERSISTENT 0x0004 +#define VPB_REMOVE_PENDING 0x0008 +#define VPB_RAW_MOUNT 0x0010 +#define VPB_DIRECT_WRITES_ALLOWED 0x0020 + +/* IRP.Flags */ + +#define SL_FORCE_ACCESS_CHECK 0x01 +#define SL_OPEN_PAGING_FILE 0x02 +#define SL_OPEN_TARGET_DIRECTORY 0x04 +#define SL_STOP_ON_SYMLINK 0x08 +#define SL_CASE_SENSITIVE 0x80 + +#define SL_KEY_SPECIFIED 0x01 +#define SL_OVERRIDE_VERIFY_VOLUME 0x02 +#define SL_WRITE_THROUGH 0x04 +#define SL_FT_SEQUENTIAL_WRITE 0x08 +#define SL_FORCE_DIRECT_WRITE 0x10 +#define SL_REALTIME_STREAM 0x20 + +#define SL_READ_ACCESS_GRANTED 0x01 +#define SL_WRITE_ACCESS_GRANTED 0x04 + +#define SL_FAIL_IMMEDIATELY 0x01 +#define SL_EXCLUSIVE_LOCK 0x02 + +#define SL_RESTART_SCAN 0x01 +#define SL_RETURN_SINGLE_ENTRY 0x02 +#define SL_INDEX_SPECIFIED 0x04 + +#define SL_WATCH_TREE 0x01 + +#define SL_ALLOW_RAW_MOUNT 0x01 + +#define CTL_CODE(DeviceType, Function, Method, Access) \ + (((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method)) + +#define DEVICE_TYPE_FROM_CTL_CODE(ctl) (((ULONG) (ctl & 0xffff0000)) >> 16) + +#define METHOD_FROM_CTL_CODE(ctrlCode) ((ULONG)(ctrlCode & 3)) + +#define IRP_NOCACHE 0x00000001 +#define IRP_PAGING_IO 0x00000002 +#define IRP_MOUNT_COMPLETION 0x00000002 +#define IRP_SYNCHRONOUS_API 0x00000004 +#define IRP_ASSOCIATED_IRP 0x00000008 +#define IRP_BUFFERED_IO 0x00000010 +#define IRP_DEALLOCATE_BUFFER 0x00000020 +#define IRP_INPUT_OPERATION 0x00000040 +#define IRP_SYNCHRONOUS_PAGING_IO 0x00000040 +#define IRP_CREATE_OPERATION 0x00000080 +#define IRP_READ_OPERATION 0x00000100 +#define IRP_WRITE_OPERATION 0x00000200 +#define IRP_CLOSE_OPERATION 0x00000400 +#define IRP_DEFER_IO_COMPLETION 0x00000800 +#define IRP_OB_QUERY_NAME 0x00001000 +#define IRP_HOLD_DEVICE_QUEUE 0x00002000 + +#define IRP_QUOTA_CHARGED 0x01 +#define IRP_ALLOCATED_MUST_SUCCEED 0x02 +#define IRP_ALLOCATED_FIXED_SIZE 0x04 +#define IRP_LOOKASIDE_ALLOCATION 0x08 + +/* +** IRP function codes +*/ + +#define IRP_MJ_CREATE 0x00 +#define IRP_MJ_CREATE_NAMED_PIPE 0x01 +#define IRP_MJ_CLOSE 0x02 +#define IRP_MJ_READ 0x03 +#define IRP_MJ_WRITE 0x04 +#define IRP_MJ_QUERY_INFORMATION 0x05 +#define IRP_MJ_SET_INFORMATION 0x06 +#define IRP_MJ_QUERY_EA 0x07 +#define IRP_MJ_SET_EA 0x08 +#define IRP_MJ_FLUSH_BUFFERS 0x09 +#define IRP_MJ_QUERY_VOLUME_INFORMATION 0x0a +#define IRP_MJ_SET_VOLUME_INFORMATION 0x0b +#define IRP_MJ_DIRECTORY_CONTROL 0x0c +#define IRP_MJ_FILE_SYSTEM_CONTROL 0x0d +#define IRP_MJ_DEVICE_CONTROL 0x0e +#define IRP_MJ_INTERNAL_DEVICE_CONTROL 0x0f +#define IRP_MJ_SCSI 0x0f +#define IRP_MJ_SHUTDOWN 0x10 +#define IRP_MJ_LOCK_CONTROL 0x11 +#define IRP_MJ_CLEANUP 0x12 +#define IRP_MJ_CREATE_MAILSLOT 0x13 +#define IRP_MJ_QUERY_SECURITY 0x14 +#define IRP_MJ_SET_SECURITY 0x15 +#define IRP_MJ_POWER 0x16 +#define IRP_MJ_SYSTEM_CONTROL 0x17 +#define IRP_MJ_DEVICE_CHANGE 0x18 +#define IRP_MJ_QUERY_QUOTA 0x19 +#define IRP_MJ_SET_QUOTA 0x1a +#define IRP_MJ_PNP 0x1b +#define IRP_MJ_PNP_POWER 0x1b +#define IRP_MJ_MAXIMUM_FUNCTION 0x1b + +#define IRP_MN_SCSI_CLASS 0x01 + +#define IRP_MN_START_DEVICE 0x00 +#define IRP_MN_QUERY_REMOVE_DEVICE 0x01 +#define IRP_MN_REMOVE_DEVICE 0x02 +#define IRP_MN_CANCEL_REMOVE_DEVICE 0x03 +#define IRP_MN_STOP_DEVICE 0x04 +#define IRP_MN_QUERY_STOP_DEVICE 0x05 +#define IRP_MN_CANCEL_STOP_DEVICE 0x06 + +#define IRP_MN_QUERY_DEVICE_RELATIONS 0x07 +#define IRP_MN_QUERY_INTERFACE 0x08 +#define IRP_MN_QUERY_CAPABILITIES 0x09 +#define IRP_MN_QUERY_RESOURCES 0x0A +#define IRP_MN_QUERY_RESOURCE_REQUIREMENTS 0x0B +#define IRP_MN_QUERY_DEVICE_TEXT 0x0C +#define IRP_MN_FILTER_RESOURCE_REQUIREMENTS 0x0D + +#define IRP_MN_READ_CONFIG 0x0F +#define IRP_MN_WRITE_CONFIG 0x10 +#define IRP_MN_EJECT 0x11 +#define IRP_MN_SET_LOCK 0x12 +#define IRP_MN_QUERY_ID 0x13 +#define IRP_MN_QUERY_PNP_DEVICE_STATE 0x14 +#define IRP_MN_QUERY_BUS_INFORMATION 0x15 +#define IRP_MN_DEVICE_USAGE_NOTIFICATION 0x16 +#define IRP_MN_SURPRISE_REMOVAL 0x17 +#if (NTDDI_VERSION >= NTDDI_WIN7) +#define IRP_MN_DEVICE_ENUMERATED 0x19 +#endif + +#define IRP_MN_WAIT_WAKE 0x00 +#define IRP_MN_POWER_SEQUENCE 0x01 +#define IRP_MN_SET_POWER 0x02 +#define IRP_MN_QUERY_POWER 0x03 + +#define IRP_MN_QUERY_ALL_DATA 0x00 +#define IRP_MN_QUERY_SINGLE_INSTANCE 0x01 +#define IRP_MN_CHANGE_SINGLE_INSTANCE 0x02 +#define IRP_MN_CHANGE_SINGLE_ITEM 0x03 +#define IRP_MN_ENABLE_EVENTS 0x04 +#define IRP_MN_DISABLE_EVENTS 0x05 +#define IRP_MN_ENABLE_COLLECTION 0x06 +#define IRP_MN_DISABLE_COLLECTION 0x07 +#define IRP_MN_REGINFO 0x08 +#define IRP_MN_EXECUTE_METHOD 0x09 + +#define IRP_MN_REGINFO_EX 0x0b + +typedef struct _FILE_OBJECT { + CSHORT Type; + CSHORT Size; + PDEVICE_OBJECT DeviceObject; + PVPB Vpb; + PVOID FsContext; + PVOID FsContext2; + PSECTION_OBJECT_POINTERS SectionObjectPointer; + PVOID PrivateCacheMap; + NTSTATUS FinalStatus; + struct _FILE_OBJECT *RelatedFileObject; + BOOLEAN LockOperation; + BOOLEAN DeletePending; + BOOLEAN ReadAccess; + BOOLEAN WriteAccess; + BOOLEAN DeleteAccess; + BOOLEAN SharedRead; + BOOLEAN SharedWrite; + BOOLEAN SharedDelete; + ULONG Flags; + UNICODE_STRING FileName; + LARGE_INTEGER CurrentByteOffset; + volatile ULONG Waiters; + volatile ULONG Busy; + PVOID LastLock; + KEVENT Lock; + KEVENT Event; + volatile PIO_COMPLETION_CONTEXT CompletionContext; + KSPIN_LOCK IrpListLock; + LIST_ENTRY IrpList; + volatile PVOID FileObjectExtension; +} FILE_OBJECT, *PFILE_OBJECT; + +typedef struct _IO_ERROR_LOG_PACKET { + UCHAR MajorFunctionCode; + UCHAR RetryCount; + USHORT DumpDataSize; + USHORT NumberOfStrings; + USHORT StringOffset; + USHORT EventCategory; + NTSTATUS ErrorCode; + ULONG UniqueErrorValue; + NTSTATUS FinalStatus; + ULONG SequenceNumber; + ULONG IoControlCode; + LARGE_INTEGER DeviceOffset; + ULONG DumpData[1]; +} IO_ERROR_LOG_PACKET, *PIO_ERROR_LOG_PACKET; + +typedef struct _IO_ERROR_LOG_MESSAGE { + USHORT Type; + USHORT Size; + USHORT DriverNameLength; + LARGE_INTEGER TimeStamp; + ULONG DriverNameOffset; + IO_ERROR_LOG_PACKET EntryData; +} IO_ERROR_LOG_MESSAGE, *PIO_ERROR_LOG_MESSAGE; + +#define ERROR_LOG_LIMIT_SIZE 240 +#define IO_ERROR_LOG_MESSAGE_HEADER_LENGTH (sizeof(IO_ERROR_LOG_MESSAGE) - \ + sizeof(IO_ERROR_LOG_PACKET) + \ + (sizeof(WCHAR) * 40)) +#define ERROR_LOG_MESSAGE_LIMIT_SIZE \ + (ERROR_LOG_LIMIT_SIZE + IO_ERROR_LOG_MESSAGE_HEADER_LENGTH) +#define IO_ERROR_LOG_MESSAGE_LENGTH \ + ((PORT_MAXIMUM_MESSAGE_LENGTH > ERROR_LOG_MESSAGE_LIMIT_SIZE) ? \ + ERROR_LOG_MESSAGE_LIMIT_SIZE : \ + PORT_MAXIMUM_MESSAGE_LENGTH) +#define ERROR_LOG_MAXIMUM_SIZE (IO_ERROR_LOG_MESSAGE_LENGTH - \ + IO_ERROR_LOG_MESSAGE_HEADER_LENGTH) + +#ifdef _WIN64 +#define PORT_MAXIMUM_MESSAGE_LENGTH 512 +#else +#define PORT_MAXIMUM_MESSAGE_LENGTH 256 +#endif + +typedef enum _DMA_WIDTH { + Width8Bits, + Width16Bits, + Width32Bits, + MaximumDmaWidth +} DMA_WIDTH, *PDMA_WIDTH; + +typedef enum _DMA_SPEED { + Compatible, + TypeA, + TypeB, + TypeC, + TypeF, + MaximumDmaSpeed +} DMA_SPEED, *PDMA_SPEED; + +/* DEVICE_DESCRIPTION.Version */ + +#define DEVICE_DESCRIPTION_VERSION 0x0000 +#define DEVICE_DESCRIPTION_VERSION1 0x0001 +#define DEVICE_DESCRIPTION_VERSION2 0x0002 + +typedef struct _DEVICE_DESCRIPTION { + ULONG Version; + BOOLEAN Master; + BOOLEAN ScatterGather; + BOOLEAN DemandMode; + BOOLEAN AutoInitialize; + BOOLEAN Dma32BitAddresses; + BOOLEAN IgnoreCount; + BOOLEAN Reserved1; + BOOLEAN Dma64BitAddresses; + ULONG BusNumber; + ULONG DmaChannel; + INTERFACE_TYPE InterfaceType; + DMA_WIDTH DmaWidth; + DMA_SPEED DmaSpeed; + ULONG MaximumLength; + ULONG DmaPort; +} DEVICE_DESCRIPTION, *PDEVICE_DESCRIPTION; + +typedef enum _DEVICE_RELATION_TYPE { + BusRelations, + EjectionRelations, + PowerRelations, + RemovalRelations, + TargetDeviceRelation, + SingleBusRelations, + TransportRelations +} DEVICE_RELATION_TYPE, *PDEVICE_RELATION_TYPE; + +typedef struct _DEVICE_RELATIONS { + ULONG Count; + PDEVICE_OBJECT Objects[1]; +} DEVICE_RELATIONS, *PDEVICE_RELATIONS; + +typedef struct _DEVOBJ_EXTENSION { + CSHORT Type; + USHORT Size; + PDEVICE_OBJECT DeviceObject; +} DEVOBJ_EXTENSION, *PDEVOBJ_EXTENSION; + +typedef struct _SCATTER_GATHER_ELEMENT { + PHYSICAL_ADDRESS Address; + ULONG Length; + ULONG_PTR Reserved; +} SCATTER_GATHER_ELEMENT, *PSCATTER_GATHER_ELEMENT; + +#if defined(_MSC_EXTENSIONS) + +#if _MSC_VER >= 1200 +#pragma warning(push) +#endif +#pragma warning(disable:4200) +typedef struct _SCATTER_GATHER_LIST { + ULONG NumberOfElements; + ULONG_PTR Reserved; + SCATTER_GATHER_ELEMENT Elements[1]; +} SCATTER_GATHER_LIST, *PSCATTER_GATHER_LIST; + +#if _MSC_VER >= 1200 +#pragma warning(pop) +#else +#pragma warning(default:4200) +#endif + +#else + +struct _SCATTER_GATHER_LIST; +typedef struct _SCATTER_GATHER_LIST SCATTER_GATHER_LIST, *PSCATTER_GATHER_LIST; + +#endif + +typedef NTSTATUS +(NTAPI DRIVER_ADD_DEVICE)( + IN struct _DRIVER_OBJECT *DriverObject, + IN struct _DEVICE_OBJECT *PhysicalDeviceObject); +typedef DRIVER_ADD_DEVICE *PDRIVER_ADD_DEVICE; + +typedef struct _DRIVER_EXTENSION { + struct _DRIVER_OBJECT *DriverObject; + PDRIVER_ADD_DEVICE AddDevice; + ULONG Count; + UNICODE_STRING ServiceKeyName; +} DRIVER_EXTENSION, *PDRIVER_EXTENSION; + +#define DRVO_UNLOAD_INVOKED 0x00000001 +#define DRVO_LEGACY_DRIVER 0x00000002 +#define DRVO_BUILTIN_DRIVER 0x00000004 + +typedef NTSTATUS +(NTAPI DRIVER_INITIALIZE)( + IN struct _DRIVER_OBJECT *DriverObject, + IN PUNICODE_STRING RegistryPath); +typedef DRIVER_INITIALIZE *PDRIVER_INITIALIZE; + +typedef VOID +(NTAPI DRIVER_STARTIO)( + IN struct _DEVICE_OBJECT *DeviceObject, + IN struct _IRP *Irp); +typedef DRIVER_STARTIO *PDRIVER_STARTIO; + +typedef VOID +(NTAPI DRIVER_UNLOAD)( + IN struct _DRIVER_OBJECT *DriverObject); +typedef DRIVER_UNLOAD *PDRIVER_UNLOAD; + +typedef NTSTATUS +(NTAPI DRIVER_DISPATCH)( + IN struct _DEVICE_OBJECT *DeviceObject, + IN struct _IRP *Irp); +typedef DRIVER_DISPATCH *PDRIVER_DISPATCH; + +typedef struct _DRIVER_OBJECT { + CSHORT Type; + CSHORT Size; + PDEVICE_OBJECT DeviceObject; + ULONG Flags; + PVOID DriverStart; + ULONG DriverSize; + PVOID DriverSection; + PDRIVER_EXTENSION DriverExtension; + UNICODE_STRING DriverName; + PUNICODE_STRING HardwareDatabase; + struct _FAST_IO_DISPATCH *FastIoDispatch; + PDRIVER_INITIALIZE DriverInit; + PDRIVER_STARTIO DriverStartIo; + PDRIVER_UNLOAD DriverUnload; + PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION + 1]; +} DRIVER_OBJECT, *PDRIVER_OBJECT; + +typedef struct _DMA_ADAPTER { + USHORT Version; + USHORT Size; + struct _DMA_OPERATIONS* DmaOperations; +} DMA_ADAPTER, *PDMA_ADAPTER; + +typedef VOID +(NTAPI *PPUT_DMA_ADAPTER)( + IN PDMA_ADAPTER DmaAdapter); + +typedef PVOID +(NTAPI *PALLOCATE_COMMON_BUFFER)( + IN PDMA_ADAPTER DmaAdapter, + IN ULONG Length, + OUT PPHYSICAL_ADDRESS LogicalAddress, + IN BOOLEAN CacheEnabled); + +typedef VOID +(NTAPI *PFREE_COMMON_BUFFER)( + IN PDMA_ADAPTER DmaAdapter, + IN ULONG Length, + IN PHYSICAL_ADDRESS LogicalAddress, + IN PVOID VirtualAddress, + IN BOOLEAN CacheEnabled); + +typedef NTSTATUS +(NTAPI *PALLOCATE_ADAPTER_CHANNEL)( + IN PDMA_ADAPTER DmaAdapter, + IN PDEVICE_OBJECT DeviceObject, + IN ULONG NumberOfMapRegisters, + IN PDRIVER_CONTROL ExecutionRoutine, + IN PVOID Context); + +typedef BOOLEAN +(NTAPI *PFLUSH_ADAPTER_BUFFERS)( + IN PDMA_ADAPTER DmaAdapter, + IN PMDL Mdl, + IN PVOID MapRegisterBase, + IN PVOID CurrentVa, + IN ULONG Length, + IN BOOLEAN WriteToDevice); + +typedef VOID +(NTAPI *PFREE_ADAPTER_CHANNEL)( + IN PDMA_ADAPTER DmaAdapter); + +typedef VOID +(NTAPI *PFREE_MAP_REGISTERS)( + IN PDMA_ADAPTER DmaAdapter, + PVOID MapRegisterBase, + ULONG NumberOfMapRegisters); + +typedef PHYSICAL_ADDRESS +(NTAPI *PMAP_TRANSFER)( + IN PDMA_ADAPTER DmaAdapter, + IN PMDL Mdl, + IN PVOID MapRegisterBase, + IN PVOID CurrentVa, + IN OUT PULONG Length, + IN BOOLEAN WriteToDevice); + +typedef ULONG +(NTAPI *PGET_DMA_ALIGNMENT)( + IN PDMA_ADAPTER DmaAdapter); + +typedef ULONG +(NTAPI *PREAD_DMA_COUNTER)( + IN PDMA_ADAPTER DmaAdapter); + +typedef VOID +(NTAPI DRIVER_LIST_CONTROL)( + IN struct _DEVICE_OBJECT *DeviceObject, + IN struct _IRP *Irp, + IN struct _SCATTER_GATHER_LIST *ScatterGather, + IN PVOID Context); +typedef DRIVER_LIST_CONTROL *PDRIVER_LIST_CONTROL; + +typedef NTSTATUS +(NTAPI *PGET_SCATTER_GATHER_LIST)( + IN PDMA_ADAPTER DmaAdapter, + IN PDEVICE_OBJECT DeviceObject, + IN PMDL Mdl, + IN PVOID CurrentVa, + IN ULONG Length, + IN PDRIVER_LIST_CONTROL ExecutionRoutine, + IN PVOID Context, + IN BOOLEAN WriteToDevice); + +typedef VOID +(NTAPI *PPUT_SCATTER_GATHER_LIST)( + IN PDMA_ADAPTER DmaAdapter, + IN PSCATTER_GATHER_LIST ScatterGather, + IN BOOLEAN WriteToDevice); + +typedef NTSTATUS +(NTAPI *PCALCULATE_SCATTER_GATHER_LIST_SIZE)( + IN PDMA_ADAPTER DmaAdapter, + IN PMDL Mdl OPTIONAL, + IN PVOID CurrentVa, + IN ULONG Length, + OUT PULONG ScatterGatherListSize, + OUT PULONG pNumberOfMapRegisters OPTIONAL); + +typedef NTSTATUS +(NTAPI *PBUILD_SCATTER_GATHER_LIST)( + IN PDMA_ADAPTER DmaAdapter, + IN PDEVICE_OBJECT DeviceObject, + IN PMDL Mdl, + IN PVOID CurrentVa, + IN ULONG Length, + IN PDRIVER_LIST_CONTROL ExecutionRoutine, + IN PVOID Context, + IN BOOLEAN WriteToDevice, + IN PVOID ScatterGatherBuffer, + IN ULONG ScatterGatherLength); + +typedef NTSTATUS +(NTAPI *PBUILD_MDL_FROM_SCATTER_GATHER_LIST)( + IN PDMA_ADAPTER DmaAdapter, + IN PSCATTER_GATHER_LIST ScatterGather, + IN PMDL OriginalMdl, + OUT PMDL *TargetMdl); + +typedef struct _DMA_OPERATIONS { + ULONG Size; + PPUT_DMA_ADAPTER PutDmaAdapter; + PALLOCATE_COMMON_BUFFER AllocateCommonBuffer; + PFREE_COMMON_BUFFER FreeCommonBuffer; + PALLOCATE_ADAPTER_CHANNEL AllocateAdapterChannel; + PFLUSH_ADAPTER_BUFFERS FlushAdapterBuffers; + PFREE_ADAPTER_CHANNEL FreeAdapterChannel; + PFREE_MAP_REGISTERS FreeMapRegisters; + PMAP_TRANSFER MapTransfer; + PGET_DMA_ALIGNMENT GetDmaAlignment; + PREAD_DMA_COUNTER ReadDmaCounter; + PGET_SCATTER_GATHER_LIST GetScatterGatherList; + PPUT_SCATTER_GATHER_LIST PutScatterGatherList; + PCALCULATE_SCATTER_GATHER_LIST_SIZE CalculateScatterGatherList; + PBUILD_SCATTER_GATHER_LIST BuildScatterGatherList; + PBUILD_MDL_FROM_SCATTER_GATHER_LIST BuildMdlFromScatterGatherList; +} DMA_OPERATIONS, *PDMA_OPERATIONS; + +typedef struct _IO_RESOURCE_DESCRIPTOR { + UCHAR Option; + UCHAR Type; + UCHAR ShareDisposition; + UCHAR Spare1; + USHORT Flags; + USHORT Spare2; + union { + struct { + ULONG Length; + ULONG Alignment; + PHYSICAL_ADDRESS MinimumAddress; + PHYSICAL_ADDRESS MaximumAddress; + } Port; + struct { + ULONG Length; + ULONG Alignment; + PHYSICAL_ADDRESS MinimumAddress; + PHYSICAL_ADDRESS MaximumAddress; + } Memory; + struct { + ULONG MinimumVector; + ULONG MaximumVector; + } Interrupt; + struct { + ULONG MinimumChannel; + ULONG MaximumChannel; + } Dma; + struct { + ULONG Length; + ULONG Alignment; + PHYSICAL_ADDRESS MinimumAddress; + PHYSICAL_ADDRESS MaximumAddress; + } Generic; + struct { + ULONG Data[3]; + } DevicePrivate; + struct { + ULONG Length; + ULONG MinBusNumber; + ULONG MaxBusNumber; + ULONG Reserved; + } BusNumber; + struct { + ULONG Priority; + ULONG Reserved1; + ULONG Reserved2; + } ConfigData; + } u; +} IO_RESOURCE_DESCRIPTOR, *PIO_RESOURCE_DESCRIPTOR; + +typedef struct _IO_RESOURCE_LIST { + USHORT Version; + USHORT Revision; + ULONG Count; + IO_RESOURCE_DESCRIPTOR Descriptors[1]; +} IO_RESOURCE_LIST, *PIO_RESOURCE_LIST; + +typedef struct _IO_RESOURCE_REQUIREMENTS_LIST { + ULONG ListSize; + INTERFACE_TYPE InterfaceType; + ULONG BusNumber; + ULONG SlotNumber; + ULONG Reserved[3]; + ULONG AlternativeLists; + IO_RESOURCE_LIST List[1]; +} IO_RESOURCE_REQUIREMENTS_LIST, *PIO_RESOURCE_REQUIREMENTS_LIST; + +typedef VOID +(NTAPI DRIVER_CANCEL)( + IN struct _DEVICE_OBJECT *DeviceObject, + IN struct _IRP *Irp); +typedef DRIVER_CANCEL *PDRIVER_CANCEL; + +typedef struct _IRP { + CSHORT Type; + USHORT Size; + struct _MDL *MdlAddress; + ULONG Flags; + union { + struct _IRP *MasterIrp; + volatile LONG IrpCount; + PVOID SystemBuffer; + } AssociatedIrp; + LIST_ENTRY ThreadListEntry; + IO_STATUS_BLOCK IoStatus; + KPROCESSOR_MODE RequestorMode; + BOOLEAN PendingReturned; + CHAR StackCount; + CHAR CurrentLocation; + BOOLEAN Cancel; + KIRQL CancelIrql; + CCHAR ApcEnvironment; + UCHAR AllocationFlags; + PIO_STATUS_BLOCK UserIosb; + PKEVENT UserEvent; + union { + struct { + _ANONYMOUS_UNION union { + PIO_APC_ROUTINE UserApcRoutine; + PVOID IssuingProcess; + } DUMMYUNIONNAME; + PVOID UserApcContext; + } AsynchronousParameters; + LARGE_INTEGER AllocationSize; + } Overlay; + volatile PDRIVER_CANCEL CancelRoutine; + PVOID UserBuffer; + union { + struct { + _ANONYMOUS_UNION union { + KDEVICE_QUEUE_ENTRY DeviceQueueEntry; + _ANONYMOUS_STRUCT struct { + PVOID DriverContext[4]; + } DUMMYSTRUCTNAME; + } DUMMYUNIONNAME; + PETHREAD Thread; + PCHAR AuxiliaryBuffer; + _ANONYMOUS_STRUCT struct { + LIST_ENTRY ListEntry; + _ANONYMOUS_UNION union { + struct _IO_STACK_LOCATION *CurrentStackLocation; + ULONG PacketType; + } DUMMYUNIONNAME; + } DUMMYSTRUCTNAME; + struct _FILE_OBJECT *OriginalFileObject; + } Overlay; + KAPC Apc; + PVOID CompletionKey; + } Tail; +} IRP, *PIRP; + +typedef enum _IO_PAGING_PRIORITY { + IoPagingPriorityInvalid, + IoPagingPriorityNormal, + IoPagingPriorityHigh, + IoPagingPriorityReserved1, + IoPagingPriorityReserved2 +} IO_PAGING_PRIORITY; + +typedef NTSTATUS +(NTAPI IO_COMPLETION_ROUTINE)( + IN struct _DEVICE_OBJECT *DeviceObject, + IN struct _IRP *Irp, + IN PVOID Context); +typedef IO_COMPLETION_ROUTINE *PIO_COMPLETION_ROUTINE; + +typedef VOID +(NTAPI IO_DPC_ROUTINE)( + IN struct _KDPC *Dpc, + IN struct _DEVICE_OBJECT *DeviceObject, + IN struct _IRP *Irp, + IN PVOID Context); +typedef IO_DPC_ROUTINE *PIO_DPC_ROUTINE; + +typedef NTSTATUS +(NTAPI *PMM_DLL_INITIALIZE)( + IN PUNICODE_STRING RegistryPath); + +typedef NTSTATUS +(NTAPI *PMM_DLL_UNLOAD)( + VOID); + +typedef VOID +(NTAPI IO_TIMER_ROUTINE)( + IN struct _DEVICE_OBJECT *DeviceObject, + IN PVOID Context); +typedef IO_TIMER_ROUTINE *PIO_TIMER_ROUTINE; + +typedef struct _IO_SECURITY_CONTEXT { + PSECURITY_QUALITY_OF_SERVICE SecurityQos; + PACCESS_STATE AccessState; + ACCESS_MASK DesiredAccess; + ULONG FullCreateOptions; +} IO_SECURITY_CONTEXT, *PIO_SECURITY_CONTEXT; + +struct _IO_CSQ; + +typedef struct _IO_CSQ_IRP_CONTEXT { + ULONG Type; + struct _IRP *Irp; + struct _IO_CSQ *Csq; +} IO_CSQ_IRP_CONTEXT, *PIO_CSQ_IRP_CONTEXT; + +typedef VOID +(NTAPI *PIO_CSQ_INSERT_IRP)( + IN struct _IO_CSQ *Csq, + IN PIRP Irp); + +typedef NTSTATUS +(NTAPI IO_CSQ_INSERT_IRP_EX)( + IN struct _IO_CSQ *Csq, + IN PIRP Irp, + IN PVOID InsertContext); +typedef IO_CSQ_INSERT_IRP_EX *PIO_CSQ_INSERT_IRP_EX; + +typedef VOID +(NTAPI *PIO_CSQ_REMOVE_IRP)( + IN struct _IO_CSQ *Csq, + IN PIRP Irp); + +typedef PIRP +(NTAPI *PIO_CSQ_PEEK_NEXT_IRP)( + IN struct _IO_CSQ *Csq, + IN PIRP Irp, + IN PVOID PeekContext); + +typedef VOID +(NTAPI *PIO_CSQ_ACQUIRE_LOCK)( + IN struct _IO_CSQ *Csq, + OUT PKIRQL Irql); + +typedef VOID +(NTAPI *PIO_CSQ_RELEASE_LOCK)( + IN struct _IO_CSQ *Csq, + IN KIRQL Irql); + +typedef VOID +(NTAPI *PIO_CSQ_COMPLETE_CANCELED_IRP)( + IN struct _IO_CSQ *Csq, + IN PIRP Irp); + +typedef struct _IO_CSQ { + ULONG Type; + PIO_CSQ_INSERT_IRP CsqInsertIrp; + PIO_CSQ_REMOVE_IRP CsqRemoveIrp; + PIO_CSQ_PEEK_NEXT_IRP CsqPeekNextIrp; + PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock; + PIO_CSQ_RELEASE_LOCK CsqReleaseLock; + PIO_CSQ_COMPLETE_CANCELED_IRP CsqCompleteCanceledIrp; + PVOID ReservePointer; +} IO_CSQ, *PIO_CSQ; + +typedef enum _BUS_QUERY_ID_TYPE { + BusQueryDeviceID, + BusQueryHardwareIDs, + BusQueryCompatibleIDs, + BusQueryInstanceID, + BusQueryDeviceSerialNumber +} BUS_QUERY_ID_TYPE, *PBUS_QUERY_ID_TYPE; + +typedef enum _DEVICE_TEXT_TYPE { + DeviceTextDescription, + DeviceTextLocationInformation +} DEVICE_TEXT_TYPE, *PDEVICE_TEXT_TYPE; + +typedef BOOLEAN +(NTAPI *PGPE_SERVICE_ROUTINE)( + PVOID, + PVOID); + +typedef NTSTATUS +(NTAPI *PGPE_CONNECT_VECTOR)( + PDEVICE_OBJECT, + ULONG, + KINTERRUPT_MODE, + BOOLEAN, + PGPE_SERVICE_ROUTINE, + PVOID, + PVOID); + +typedef NTSTATUS +(NTAPI *PGPE_DISCONNECT_VECTOR)( + PVOID); + +typedef NTSTATUS +(NTAPI *PGPE_ENABLE_EVENT)( + PDEVICE_OBJECT, + PVOID); + +typedef NTSTATUS +(NTAPI *PGPE_DISABLE_EVENT)( + PDEVICE_OBJECT, + PVOID); + +typedef NTSTATUS +(NTAPI *PGPE_CLEAR_STATUS)( + PDEVICE_OBJECT, + PVOID); + +typedef VOID +(NTAPI *PDEVICE_NOTIFY_CALLBACK)( + PVOID, + ULONG); + +typedef NTSTATUS +(NTAPI *PREGISTER_FOR_DEVICE_NOTIFICATIONS)( + PDEVICE_OBJECT, + PDEVICE_NOTIFY_CALLBACK, + PVOID); + +typedef VOID +(NTAPI *PUNREGISTER_FOR_DEVICE_NOTIFICATIONS)( + PDEVICE_OBJECT, + PDEVICE_NOTIFY_CALLBACK); + +typedef struct _ACPI_INTERFACE_STANDARD { + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; + PGPE_CONNECT_VECTOR GpeConnectVector; + PGPE_DISCONNECT_VECTOR GpeDisconnectVector; + PGPE_ENABLE_EVENT GpeEnableEvent; + PGPE_DISABLE_EVENT GpeDisableEvent; + PGPE_CLEAR_STATUS GpeClearStatus; + PREGISTER_FOR_DEVICE_NOTIFICATIONS RegisterForDeviceNotifications; + PUNREGISTER_FOR_DEVICE_NOTIFICATIONS UnregisterForDeviceNotifications; +} ACPI_INTERFACE_STANDARD, *PACPI_INTERFACE_STANDARD; + +typedef BOOLEAN +(NTAPI *PGPE_SERVICE_ROUTINE2)( + PVOID ObjectContext, + PVOID ServiceContext); + +typedef NTSTATUS +(NTAPI *PGPE_CONNECT_VECTOR2)( + PVOID Context, + ULONG GpeNumber, + KINTERRUPT_MODE Mode, + BOOLEAN Shareable, + PGPE_SERVICE_ROUTINE ServiceRoutine, + PVOID ServiceContext, + PVOID *ObjectContext); + +typedef NTSTATUS +(NTAPI *PGPE_DISCONNECT_VECTOR2)( + PVOID Context, + PVOID ObjectContext); + +typedef NTSTATUS +(NTAPI *PGPE_ENABLE_EVENT2)( + PVOID Context, + PVOID ObjectContext); + +typedef NTSTATUS +(NTAPI *PGPE_DISABLE_EVENT2)( + PVOID Context, + PVOID ObjectContext); + +typedef NTSTATUS +(NTAPI *PGPE_CLEAR_STATUS2)( + PVOID Context, + PVOID ObjectContext); + +typedef VOID +(NTAPI *PDEVICE_NOTIFY_CALLBACK2)( + PVOID NotificationContext, + ULONG NotifyCode); + +typedef NTSTATUS +(NTAPI *PREGISTER_FOR_DEVICE_NOTIFICATIONS2)( + PVOID Context, + PDEVICE_NOTIFY_CALLBACK2 NotificationHandler, + PVOID NotificationContext); + +typedef VOID +(NTAPI *PUNREGISTER_FOR_DEVICE_NOTIFICATIONS2)( + PVOID Context); + +typedef struct _ACPI_INTERFACE_STANDARD2 { + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; + PGPE_CONNECT_VECTOR2 GpeConnectVector; + PGPE_DISCONNECT_VECTOR2 GpeDisconnectVector; + PGPE_ENABLE_EVENT2 GpeEnableEvent; + PGPE_DISABLE_EVENT2 GpeDisableEvent; + PGPE_CLEAR_STATUS2 GpeClearStatus; + PREGISTER_FOR_DEVICE_NOTIFICATIONS2 RegisterForDeviceNotifications; + PUNREGISTER_FOR_DEVICE_NOTIFICATIONS2 UnregisterForDeviceNotifications; +} ACPI_INTERFACE_STANDARD2, *PACPI_INTERFACE_STANDARD2; + +#if !defined(_AMD64_) && !defined(_IA64_) +#include +#endif +typedef struct _IO_STACK_LOCATION { + UCHAR MajorFunction; + UCHAR MinorFunction; + UCHAR Flags; + UCHAR Control; + union { + struct { + PIO_SECURITY_CONTEXT SecurityContext; + ULONG Options; + USHORT POINTER_ALIGNMENT FileAttributes; + USHORT ShareAccess; + ULONG POINTER_ALIGNMENT EaLength; + } Create; + struct { + ULONG Length; + ULONG POINTER_ALIGNMENT Key; + LARGE_INTEGER ByteOffset; + } Read; + struct { + ULONG Length; + ULONG POINTER_ALIGNMENT Key; + LARGE_INTEGER ByteOffset; + } Write; + struct { + ULONG Length; + PUNICODE_STRING FileName; + FILE_INFORMATION_CLASS FileInformationClass; + ULONG FileIndex; + } QueryDirectory; + struct { + ULONG Length; + ULONG CompletionFilter; + } NotifyDirectory; + struct { + ULONG Length; + FILE_INFORMATION_CLASS POINTER_ALIGNMENT FileInformationClass; + } QueryFile; + struct { + ULONG Length; + FILE_INFORMATION_CLASS POINTER_ALIGNMENT FileInformationClass; + PFILE_OBJECT FileObject; + _ANONYMOUS_UNION union { + _ANONYMOUS_STRUCT struct { + BOOLEAN ReplaceIfExists; + BOOLEAN AdvanceOnly; + } DUMMYSTRUCTNAME; + ULONG ClusterCount; + HANDLE DeleteHandle; + } DUMMYUNIONNAME; + } SetFile; + struct { + ULONG Length; + PVOID EaList; + ULONG EaListLength; + ULONG EaIndex; + } QueryEa; + struct { + ULONG Length; + } SetEa; + struct { + ULONG Length; + FS_INFORMATION_CLASS POINTER_ALIGNMENT FsInformationClass; + } QueryVolume; + struct { + ULONG Length; + FS_INFORMATION_CLASS FsInformationClass; + } SetVolume; + struct { + ULONG OutputBufferLength; + ULONG InputBufferLength; + ULONG FsControlCode; + PVOID Type3InputBuffer; + } FileSystemControl; + struct { + PLARGE_INTEGER Length; + ULONG Key; + LARGE_INTEGER ByteOffset; + } LockControl; + struct { + ULONG OutputBufferLength; + ULONG POINTER_ALIGNMENT InputBufferLength; + ULONG POINTER_ALIGNMENT IoControlCode; + PVOID Type3InputBuffer; + } DeviceIoControl; + struct { + SECURITY_INFORMATION SecurityInformation; + ULONG POINTER_ALIGNMENT Length; + } QuerySecurity; + struct { + SECURITY_INFORMATION SecurityInformation; + PSECURITY_DESCRIPTOR SecurityDescriptor; + } SetSecurity; + struct { + PVPB Vpb; + PDEVICE_OBJECT DeviceObject; + } MountVolume; + struct { + PVPB Vpb; + PDEVICE_OBJECT DeviceObject; + } VerifyVolume; + struct { + struct _SCSI_REQUEST_BLOCK *Srb; + } Scsi; + struct { + ULONG Length; + PSID StartSid; + struct _FILE_GET_QUOTA_INFORMATION *SidList; + ULONG SidListLength; + } QueryQuota; + struct { + ULONG Length; + } SetQuota; + struct { + DEVICE_RELATION_TYPE Type; + } QueryDeviceRelations; + struct { + CONST GUID *InterfaceType; + USHORT Size; + USHORT Version; + PINTERFACE Interface; + PVOID InterfaceSpecificData; + } QueryInterface; + struct { + PDEVICE_CAPABILITIES Capabilities; + } DeviceCapabilities; + struct { + PIO_RESOURCE_REQUIREMENTS_LIST IoResourceRequirementList; + } FilterResourceRequirements; + struct { + ULONG WhichSpace; + PVOID Buffer; + ULONG Offset; + ULONG POINTER_ALIGNMENT Length; + } ReadWriteConfig; + struct { + BOOLEAN Lock; + } SetLock; + struct { + BUS_QUERY_ID_TYPE IdType; + } QueryId; + struct { + DEVICE_TEXT_TYPE DeviceTextType; + LCID POINTER_ALIGNMENT LocaleId; + } QueryDeviceText; + struct { + BOOLEAN InPath; + BOOLEAN Reserved[3]; + DEVICE_USAGE_NOTIFICATION_TYPE POINTER_ALIGNMENT Type; + } UsageNotification; + struct { + SYSTEM_POWER_STATE PowerState; + } WaitWake; + struct { + PPOWER_SEQUENCE PowerSequence; + } PowerSequence; + struct { + ULONG SystemContext; + POWER_STATE_TYPE POINTER_ALIGNMENT Type; + POWER_STATE POINTER_ALIGNMENT State; + POWER_ACTION POINTER_ALIGNMENT ShutdownType; + } Power; + struct { + PCM_RESOURCE_LIST AllocatedResources; + PCM_RESOURCE_LIST AllocatedResourcesTranslated; + } StartDevice; + struct { + ULONG_PTR ProviderId; + PVOID DataPath; + ULONG BufferSize; + PVOID Buffer; + } WMI; + struct { + PVOID Argument1; + PVOID Argument2; + PVOID Argument3; + PVOID Argument4; + } Others; + } Parameters; + PDEVICE_OBJECT DeviceObject; + PFILE_OBJECT FileObject; + PIO_COMPLETION_ROUTINE CompletionRoutine; + PVOID Context; +} IO_STACK_LOCATION, *PIO_STACK_LOCATION; +#if !defined(_AMD64_) && !defined(_IA64_) +#include +#endif + +/* IO_STACK_LOCATION.Control */ + +#define SL_PENDING_RETURNED 0x01 +#define SL_ERROR_RETURNED 0x02 +#define SL_INVOKE_ON_CANCEL 0x20 +#define SL_INVOKE_ON_SUCCESS 0x40 +#define SL_INVOKE_ON_ERROR 0x80 + +#define METHOD_BUFFERED 0 +#define METHOD_IN_DIRECT 1 +#define METHOD_OUT_DIRECT 2 +#define METHOD_NEITHER 3 + +#define METHOD_DIRECT_TO_HARDWARE METHOD_IN_DIRECT +#define METHOD_DIRECT_FROM_HARDWARE METHOD_OUT_DIRECT + +#define FILE_SUPERSEDED 0x00000000 +#define FILE_OPENED 0x00000001 +#define FILE_CREATED 0x00000002 +#define FILE_OVERWRITTEN 0x00000003 +#define FILE_EXISTS 0x00000004 +#define FILE_DOES_NOT_EXIST 0x00000005 + +#define FILE_USE_FILE_POINTER_POSITION 0xfffffffe +#define FILE_WRITE_TO_END_OF_FILE 0xffffffff + +/* also in winnt.h */ +#define FILE_LIST_DIRECTORY 0x00000001 +#define FILE_READ_DATA 0x00000001 +#define FILE_ADD_FILE 0x00000002 +#define FILE_WRITE_DATA 0x00000002 +#define FILE_ADD_SUBDIRECTORY 0x00000004 +#define FILE_APPEND_DATA 0x00000004 +#define FILE_CREATE_PIPE_INSTANCE 0x00000004 +#define FILE_READ_EA 0x00000008 +#define FILE_WRITE_EA 0x00000010 +#define FILE_EXECUTE 0x00000020 +#define FILE_TRAVERSE 0x00000020 +#define FILE_DELETE_CHILD 0x00000040 +#define FILE_READ_ATTRIBUTES 0x00000080 +#define FILE_WRITE_ATTRIBUTES 0x00000100 + +#define FILE_SHARE_READ 0x00000001 +#define FILE_SHARE_WRITE 0x00000002 +#define FILE_SHARE_DELETE 0x00000004 +#define FILE_SHARE_VALID_FLAGS 0x00000007 + +#define FILE_ATTRIBUTE_READONLY 0x00000001 +#define FILE_ATTRIBUTE_HIDDEN 0x00000002 +#define FILE_ATTRIBUTE_SYSTEM 0x00000004 +#define FILE_ATTRIBUTE_DIRECTORY 0x00000010 +#define FILE_ATTRIBUTE_ARCHIVE 0x00000020 +#define FILE_ATTRIBUTE_DEVICE 0x00000040 +#define FILE_ATTRIBUTE_NORMAL 0x00000080 +#define FILE_ATTRIBUTE_TEMPORARY 0x00000100 +#define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200 +#define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400 +#define FILE_ATTRIBUTE_COMPRESSED 0x00000800 +#define FILE_ATTRIBUTE_OFFLINE 0x00001000 +#define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000 +#define FILE_ATTRIBUTE_ENCRYPTED 0x00004000 +#define FILE_ATTRIBUTE_VIRTUAL 0x00010000 + +#define FILE_ATTRIBUTE_VALID_FLAGS 0x00007fb7 +#define FILE_ATTRIBUTE_VALID_SET_FLAGS 0x000031a7 + +#define FILE_VALID_OPTION_FLAGS 0x00ffffff +#define FILE_VALID_PIPE_OPTION_FLAGS 0x00000032 +#define FILE_VALID_MAILSLOT_OPTION_FLAGS 0x00000032 +#define FILE_VALID_SET_FLAGS 0x00000036 + +#define FILE_SUPERSEDE 0x00000000 +#define FILE_OPEN 0x00000001 +#define FILE_CREATE 0x00000002 +#define FILE_OPEN_IF 0x00000003 +#define FILE_OVERWRITE 0x00000004 +#define FILE_OVERWRITE_IF 0x00000005 +#define FILE_MAXIMUM_DISPOSITION 0x00000005 + +#define FILE_DIRECTORY_FILE 0x00000001 +#define FILE_WRITE_THROUGH 0x00000002 +#define FILE_SEQUENTIAL_ONLY 0x00000004 +#define FILE_NO_INTERMEDIATE_BUFFERING 0x00000008 +#define FILE_SYNCHRONOUS_IO_ALERT 0x00000010 +#define FILE_SYNCHRONOUS_IO_NONALERT 0x00000020 +#define FILE_NON_DIRECTORY_FILE 0x00000040 +#define FILE_CREATE_TREE_CONNECTION 0x00000080 +#define FILE_COMPLETE_IF_OPLOCKED 0x00000100 +#define FILE_NO_EA_KNOWLEDGE 0x00000200 +#define FILE_OPEN_REMOTE_INSTANCE 0x00000400 +#define FILE_RANDOM_ACCESS 0x00000800 +#define FILE_DELETE_ON_CLOSE 0x00001000 +#define FILE_OPEN_BY_FILE_ID 0x00002000 +#define FILE_OPEN_FOR_BACKUP_INTENT 0x00004000 +#define FILE_NO_COMPRESSION 0x00008000 +#if (NTDDI_VERSION >= NTDDI_WIN7) +#define FILE_OPEN_REQUIRING_OPLOCK 0x00010000 +#define FILE_DISALLOW_EXCLUSIVE 0x00020000 +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ +#define FILE_RESERVE_OPFILTER 0x00100000 +#define FILE_OPEN_REPARSE_POINT 0x00200000 +#define FILE_OPEN_NO_RECALL 0x00400000 +#define FILE_OPEN_FOR_FREE_SPACE_QUERY 0x00800000 + +#define FILE_ANY_ACCESS 0x00000000 +#define FILE_SPECIAL_ACCESS FILE_ANY_ACCESS +#define FILE_READ_ACCESS 0x00000001 +#define FILE_WRITE_ACCESS 0x00000002 + +#define FILE_ALL_ACCESS \ + (STANDARD_RIGHTS_REQUIRED | \ + SYNCHRONIZE | \ + 0x1FF) + +#define FILE_GENERIC_EXECUTE \ + (STANDARD_RIGHTS_EXECUTE | \ + FILE_READ_ATTRIBUTES | \ + FILE_EXECUTE | \ + SYNCHRONIZE) + +#define FILE_GENERIC_READ \ + (STANDARD_RIGHTS_READ | \ + FILE_READ_DATA | \ + FILE_READ_ATTRIBUTES | \ + FILE_READ_EA | \ + SYNCHRONIZE) + +#define FILE_GENERIC_WRITE \ + (STANDARD_RIGHTS_WRITE | \ + FILE_WRITE_DATA | \ + FILE_WRITE_ATTRIBUTES | \ + FILE_WRITE_EA | \ + FILE_APPEND_DATA | \ + SYNCHRONIZE) + +/* end winnt.h */ + +#define WMIREG_ACTION_REGISTER 1 +#define WMIREG_ACTION_DEREGISTER 2 +#define WMIREG_ACTION_REREGISTER 3 +#define WMIREG_ACTION_UPDATE_GUIDS 4 +#define WMIREG_ACTION_BLOCK_IRPS 5 + +#define WMIREGISTER 0 +#define WMIUPDATE 1 + +typedef VOID +(NTAPI FWMI_NOTIFICATION_CALLBACK)( + PVOID Wnode, + PVOID Context); +typedef FWMI_NOTIFICATION_CALLBACK *WMI_NOTIFICATION_CALLBACK; + +#ifndef _PCI_X_ +#define _PCI_X_ + +typedef struct _PCI_SLOT_NUMBER { + union { + struct { + ULONG DeviceNumber:5; + ULONG FunctionNumber:3; + ULONG Reserved:24; + } bits; + ULONG AsULONG; + } u; +} PCI_SLOT_NUMBER, *PPCI_SLOT_NUMBER; + +#define PCI_TYPE0_ADDRESSES 6 +#define PCI_TYPE1_ADDRESSES 2 +#define PCI_TYPE2_ADDRESSES 5 + +typedef struct _PCI_COMMON_HEADER { + PCI_COMMON_HEADER_LAYOUT +} PCI_COMMON_HEADER, *PPCI_COMMON_HEADER; + +#ifdef __cplusplus +typedef struct _PCI_COMMON_CONFIG { + PCI_COMMON_HEADER_LAYOUT + UCHAR DeviceSpecific[192]; +} PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG; +#else +typedef struct _PCI_COMMON_CONFIG { + PCI_COMMON_HEADER DUMMYSTRUCTNAME; + UCHAR DeviceSpecific[192]; +} PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG; +#endif + +#define PCI_COMMON_HDR_LENGTH (FIELD_OFFSET(PCI_COMMON_CONFIG, DeviceSpecific)) + +#define PCI_EXTENDED_CONFIG_LENGTH 0x1000 + +#define PCI_MAX_DEVICES 32 +#define PCI_MAX_FUNCTION 8 +#define PCI_MAX_BRIDGE_NUMBER 0xFF +#define PCI_INVALID_VENDORID 0xFFFF + +/* PCI_COMMON_CONFIG.HeaderType */ +#define PCI_MULTIFUNCTION 0x80 +#define PCI_DEVICE_TYPE 0x00 +#define PCI_BRIDGE_TYPE 0x01 +#define PCI_CARDBUS_BRIDGE_TYPE 0x02 + +#define PCI_CONFIGURATION_TYPE(PciData) \ + (((PPCI_COMMON_CONFIG) (PciData))->HeaderType & ~PCI_MULTIFUNCTION) + +#define PCI_MULTIFUNCTION_DEVICE(PciData) \ + ((((PPCI_COMMON_CONFIG) (PciData))->HeaderType & PCI_MULTIFUNCTION) != 0) + +/* PCI_COMMON_CONFIG.Command */ +#define PCI_ENABLE_IO_SPACE 0x0001 +#define PCI_ENABLE_MEMORY_SPACE 0x0002 +#define PCI_ENABLE_BUS_MASTER 0x0004 +#define PCI_ENABLE_SPECIAL_CYCLES 0x0008 +#define PCI_ENABLE_WRITE_AND_INVALIDATE 0x0010 +#define PCI_ENABLE_VGA_COMPATIBLE_PALETTE 0x0020 +#define PCI_ENABLE_PARITY 0x0040 +#define PCI_ENABLE_WAIT_CYCLE 0x0080 +#define PCI_ENABLE_SERR 0x0100 +#define PCI_ENABLE_FAST_BACK_TO_BACK 0x0200 +#define PCI_DISABLE_LEVEL_INTERRUPT 0x0400 + +/* PCI_COMMON_CONFIG.Status */ +#define PCI_STATUS_INTERRUPT_PENDING 0x0008 +#define PCI_STATUS_CAPABILITIES_LIST 0x0010 +#define PCI_STATUS_66MHZ_CAPABLE 0x0020 +#define PCI_STATUS_UDF_SUPPORTED 0x0040 +#define PCI_STATUS_FAST_BACK_TO_BACK 0x0080 +#define PCI_STATUS_DATA_PARITY_DETECTED 0x0100 +#define PCI_STATUS_DEVSEL 0x0600 +#define PCI_STATUS_SIGNALED_TARGET_ABORT 0x0800 +#define PCI_STATUS_RECEIVED_TARGET_ABORT 0x1000 +#define PCI_STATUS_RECEIVED_MASTER_ABORT 0x2000 +#define PCI_STATUS_SIGNALED_SYSTEM_ERROR 0x4000 +#define PCI_STATUS_DETECTED_PARITY_ERROR 0x8000 + +/* IO_STACK_LOCATION.Parameters.ReadWriteControl.WhichSpace */ + +#define PCI_WHICHSPACE_CONFIG 0x0 +#define PCI_WHICHSPACE_ROM 0x52696350 /* 'PciR' */ + +#define PCI_CAPABILITY_ID_POWER_MANAGEMENT 0x01 +#define PCI_CAPABILITY_ID_AGP 0x02 +#define PCI_CAPABILITY_ID_VPD 0x03 +#define PCI_CAPABILITY_ID_SLOT_ID 0x04 +#define PCI_CAPABILITY_ID_MSI 0x05 +#define PCI_CAPABILITY_ID_CPCI_HOTSWAP 0x06 +#define PCI_CAPABILITY_ID_PCIX 0x07 +#define PCI_CAPABILITY_ID_HYPERTRANSPORT 0x08 +#define PCI_CAPABILITY_ID_VENDOR_SPECIFIC 0x09 +#define PCI_CAPABILITY_ID_DEBUG_PORT 0x0A +#define PCI_CAPABILITY_ID_CPCI_RES_CTRL 0x0B +#define PCI_CAPABILITY_ID_SHPC 0x0C +#define PCI_CAPABILITY_ID_P2P_SSID 0x0D +#define PCI_CAPABILITY_ID_AGP_TARGET 0x0E +#define PCI_CAPABILITY_ID_SECURE 0x0F +#define PCI_CAPABILITY_ID_PCI_EXPRESS 0x10 +#define PCI_CAPABILITY_ID_MSIX 0x11 + +typedef struct _PCI_CAPABILITIES_HEADER { + UCHAR CapabilityID; + UCHAR Next; +} PCI_CAPABILITIES_HEADER, *PPCI_CAPABILITIES_HEADER; + +typedef struct _PCI_PMC { + UCHAR Version:3; + UCHAR PMEClock:1; + UCHAR Rsvd1:1; + UCHAR DeviceSpecificInitialization:1; + UCHAR Rsvd2:2; + struct _PM_SUPPORT { + UCHAR Rsvd2:1; + UCHAR D1:1; + UCHAR D2:1; + UCHAR PMED0:1; + UCHAR PMED1:1; + UCHAR PMED2:1; + UCHAR PMED3Hot:1; + UCHAR PMED3Cold:1; + } Support; +} PCI_PMC, *PPCI_PMC; + +typedef struct _PCI_PMCSR { + USHORT PowerState:2; + USHORT Rsvd1:6; + USHORT PMEEnable:1; + USHORT DataSelect:4; + USHORT DataScale:2; + USHORT PMEStatus:1; +} PCI_PMCSR, *PPCI_PMCSR; + +typedef struct _PCI_PMCSR_BSE { + UCHAR Rsvd1:6; + UCHAR D3HotSupportsStopClock:1; + UCHAR BusPowerClockControlEnabled:1; +} PCI_PMCSR_BSE, *PPCI_PMCSR_BSE; + +typedef struct _PCI_PM_CAPABILITY { + PCI_CAPABILITIES_HEADER Header; + union { + PCI_PMC Capabilities; + USHORT AsUSHORT; + } PMC; + union { + PCI_PMCSR ControlStatus; + USHORT AsUSHORT; + } PMCSR; + union { + PCI_PMCSR_BSE BridgeSupport; + UCHAR AsUCHAR; + } PMCSR_BSE; + UCHAR Data; +} PCI_PM_CAPABILITY, *PPCI_PM_CAPABILITY; + +typedef struct { + PCI_CAPABILITIES_HEADER Header; + union { + struct { + USHORT DataParityErrorRecoveryEnable:1; + USHORT EnableRelaxedOrdering:1; + USHORT MaxMemoryReadByteCount:2; + USHORT MaxOutstandingSplitTransactions:3; + USHORT Reserved:9; + } bits; + USHORT AsUSHORT; + } Command; + union { + struct { + ULONG FunctionNumber:3; + ULONG DeviceNumber:5; + ULONG BusNumber:8; + ULONG Device64Bit:1; + ULONG Capable133MHz:1; + ULONG SplitCompletionDiscarded:1; + ULONG UnexpectedSplitCompletion:1; + ULONG DeviceComplexity:1; + ULONG DesignedMaxMemoryReadByteCount:2; + ULONG DesignedMaxOutstandingSplitTransactions:3; + ULONG DesignedMaxCumulativeReadSize:3; + ULONG ReceivedSplitCompletionErrorMessage:1; + ULONG CapablePCIX266:1; + ULONG CapablePCIX533:1; + } bits; + ULONG AsULONG; + } Status; +} PCI_X_CAPABILITY, *PPCI_X_CAPABILITY; + +#define PCI_EXPRESS_ADVANCED_ERROR_REPORTING_CAP_ID 0x0001 +#define PCI_EXPRESS_VIRTUAL_CHANNEL_CAP_ID 0x0002 +#define PCI_EXPRESS_DEVICE_SERIAL_NUMBER_CAP_ID 0x0003 +#define PCI_EXPRESS_POWER_BUDGETING_CAP_ID 0x0004 +#define PCI_EXPRESS_RC_LINK_DECLARATION_CAP_ID 0x0005 +#define PCI_EXPRESS_RC_INTERNAL_LINK_CONTROL_CAP_ID 0x0006 +#define PCI_EXPRESS_RC_EVENT_COLLECTOR_ENDPOINT_ASSOCIATION_CAP_ID 0x0007 +#define PCI_EXPRESS_MFVC_CAP_ID 0x0008 +#define PCI_EXPRESS_VC_AND_MFVC_CAP_ID 0x0009 +#define PCI_EXPRESS_RCRB_HEADER_CAP_ID 0x000A +#define PCI_EXPRESS_SINGLE_ROOT_IO_VIRTUALIZATION_CAP_ID 0x0010 + +typedef struct _PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER { + USHORT CapabilityID; + USHORT Version:4; + USHORT Next:12; +} PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER, *PPCI_EXPRESS_ENHANCED_CAPABILITY_HEADER; + +typedef struct _PCI_EXPRESS_SERIAL_NUMBER_CAPABILITY { + PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Header; + ULONG LowSerialNumber; + ULONG HighSerialNumber; +} PCI_EXPRESS_SERIAL_NUMBER_CAPABILITY, *PPCI_EXPRESS_SERIAL_NUMBER_CAPABILITY; + +typedef union _PCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS { + struct { + ULONG Undefined:1; + ULONG Reserved1:3; + ULONG DataLinkProtocolError:1; + ULONG SurpriseDownError:1; + ULONG Reserved2:6; + ULONG PoisonedTLP:1; + ULONG FlowControlProtocolError:1; + ULONG CompletionTimeout:1; + ULONG CompleterAbort:1; + ULONG UnexpectedCompletion:1; + ULONG ReceiverOverflow:1; + ULONG MalformedTLP:1; + ULONG ECRCError:1; + ULONG UnsupportedRequestError:1; + ULONG Reserved3:11; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS, *PPCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS; + +typedef union _PCI_EXPRESS_UNCORRECTABLE_ERROR_MASK { + struct { + ULONG Undefined:1; + ULONG Reserved1:3; + ULONG DataLinkProtocolError:1; + ULONG SurpriseDownError:1; + ULONG Reserved2:6; + ULONG PoisonedTLP:1; + ULONG FlowControlProtocolError:1; + ULONG CompletionTimeout:1; + ULONG CompleterAbort:1; + ULONG UnexpectedCompletion:1; + ULONG ReceiverOverflow:1; + ULONG MalformedTLP:1; + ULONG ECRCError:1; + ULONG UnsupportedRequestError:1; + ULONG Reserved3:11; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_UNCORRECTABLE_ERROR_MASK, *PPCI_EXPRESS_UNCORRECTABLE_ERROR_MASK; + +typedef union _PCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY { + struct { + ULONG Undefined:1; + ULONG Reserved1:3; + ULONG DataLinkProtocolError:1; + ULONG SurpriseDownError:1; + ULONG Reserved2:6; + ULONG PoisonedTLP:1; + ULONG FlowControlProtocolError:1; + ULONG CompletionTimeout:1; + ULONG CompleterAbort:1; + ULONG UnexpectedCompletion:1; + ULONG ReceiverOverflow:1; + ULONG MalformedTLP:1; + ULONG ECRCError:1; + ULONG UnsupportedRequestError:1; + ULONG Reserved3:11; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY, *PPCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY; + +typedef union _PCI_EXPRESS_CORRECTABLE_ERROR_STATUS { + struct { + ULONG ReceiverError:1; + ULONG Reserved1:5; + ULONG BadTLP:1; + ULONG BadDLLP:1; + ULONG ReplayNumRollover:1; + ULONG Reserved2:3; + ULONG ReplayTimerTimeout:1; + ULONG AdvisoryNonFatalError:1; + ULONG Reserved3:18; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_CORRECTABLE_ERROR_STATUS, *PPCI_CORRECTABLE_ERROR_STATUS; + +typedef union _PCI_EXPRESS_CORRECTABLE_ERROR_MASK { + struct { + ULONG ReceiverError:1; + ULONG Reserved1:5; + ULONG BadTLP:1; + ULONG BadDLLP:1; + ULONG ReplayNumRollover:1; + ULONG Reserved2:3; + ULONG ReplayTimerTimeout:1; + ULONG AdvisoryNonFatalError:1; + ULONG Reserved3:18; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_CORRECTABLE_ERROR_MASK, *PPCI_CORRECTABLE_ERROR_MASK; + +typedef union _PCI_EXPRESS_AER_CAPABILITIES { + struct { + ULONG FirstErrorPointer:5; + ULONG ECRCGenerationCapable:1; + ULONG ECRCGenerationEnable:1; + ULONG ECRCCheckCapable:1; + ULONG ECRCCheckEnable:1; + ULONG Reserved:23; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_AER_CAPABILITIES, *PPCI_EXPRESS_AER_CAPABILITIES; + +typedef union _PCI_EXPRESS_ROOT_ERROR_COMMAND { + struct { + ULONG CorrectableErrorReportingEnable:1; + ULONG NonFatalErrorReportingEnable:1; + ULONG FatalErrorReportingEnable:1; + ULONG Reserved:29; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_ROOT_ERROR_COMMAND, *PPCI_EXPRESS_ROOT_ERROR_COMMAND; + +typedef union _PCI_EXPRESS_ROOT_ERROR_STATUS { + struct { + ULONG CorrectableErrorReceived:1; + ULONG MultipleCorrectableErrorsReceived:1; + ULONG UncorrectableErrorReceived:1; + ULONG MultipleUncorrectableErrorsReceived:1; + ULONG FirstUncorrectableFatal:1; + ULONG NonFatalErrorMessagesReceived:1; + ULONG FatalErrorMessagesReceived:1; + ULONG Reserved:20; + ULONG AdvancedErrorInterruptMessageNumber:5; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_ROOT_ERROR_STATUS, *PPCI_EXPRESS_ROOT_ERROR_STATUS; + +typedef union _PCI_EXPRESS_ERROR_SOURCE_ID { + struct { + USHORT CorrectableSourceIdFun:3; + USHORT CorrectableSourceIdDev:5; + USHORT CorrectableSourceIdBus:8; + USHORT UncorrectableSourceIdFun:3; + USHORT UncorrectableSourceIdDev:5; + USHORT UncorrectableSourceIdBus:8; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_ERROR_SOURCE_ID, *PPCI_EXPRESS_ERROR_SOURCE_ID; + +typedef union _PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_STATUS { + struct { + ULONG TargetAbortOnSplitCompletion:1; + ULONG MasterAbortOnSplitCompletion:1; + ULONG ReceivedTargetAbort:1; + ULONG ReceivedMasterAbort:1; + ULONG RsvdZ:1; + ULONG UnexpectedSplitCompletionError:1; + ULONG UncorrectableSplitCompletion:1; + ULONG UncorrectableDataError:1; + ULONG UncorrectableAttributeError:1; + ULONG UncorrectableAddressError:1; + ULONG DelayedTransactionDiscardTimerExpired:1; + ULONG PERRAsserted:1; + ULONG SERRAsserted:1; + ULONG InternalBridgeError:1; + ULONG Reserved:18; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_STATUS, *PPCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_STATUS; + +typedef union _PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_MASK { + struct { + ULONG TargetAbortOnSplitCompletion:1; + ULONG MasterAbortOnSplitCompletion:1; + ULONG ReceivedTargetAbort:1; + ULONG ReceivedMasterAbort:1; + ULONG RsvdZ:1; + ULONG UnexpectedSplitCompletionError:1; + ULONG UncorrectableSplitCompletion:1; + ULONG UncorrectableDataError:1; + ULONG UncorrectableAttributeError:1; + ULONG UncorrectableAddressError:1; + ULONG DelayedTransactionDiscardTimerExpired:1; + ULONG PERRAsserted:1; + ULONG SERRAsserted:1; + ULONG InternalBridgeError:1; + ULONG Reserved:18; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_MASK, *PPCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_MASK; + +typedef union _PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_SEVERITY { + struct { + ULONG TargetAbortOnSplitCompletion:1; + ULONG MasterAbortOnSplitCompletion:1; + ULONG ReceivedTargetAbort:1; + ULONG ReceivedMasterAbort:1; + ULONG RsvdZ:1; + ULONG UnexpectedSplitCompletionError:1; + ULONG UncorrectableSplitCompletion:1; + ULONG UncorrectableDataError:1; + ULONG UncorrectableAttributeError:1; + ULONG UncorrectableAddressError:1; + ULONG DelayedTransactionDiscardTimerExpired:1; + ULONG PERRAsserted:1; + ULONG SERRAsserted:1; + ULONG InternalBridgeError:1; + ULONG Reserved:18; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_SEVERITY, *PPCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_SEVERITY; + +typedef union _PCI_EXPRESS_SEC_AER_CAPABILITIES { + struct { + ULONG SecondaryUncorrectableFirstErrorPtr:5; + ULONG Reserved:27; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_SEC_AER_CAPABILITIES, *PPCI_EXPRESS_SEC_AER_CAPABILITIES; + +#define ROOT_CMD_ENABLE_CORRECTABLE_ERROR_REPORTING 0x00000001 +#define ROOT_CMD_ENABLE_NONFATAL_ERROR_REPORTING 0x00000002 +#define ROOT_CMD_ENABLE_FATAL_ERROR_REPORTING 0x00000004 + +#define ROOT_CMD_ERROR_REPORTING_ENABLE_MASK \ + (ROOT_CMD_ENABLE_FATAL_ERROR_REPORTING | \ + ROOT_CMD_ENABLE_NONFATAL_ERROR_REPORTING | \ + ROOT_CMD_ENABLE_CORRECTABLE_ERROR_REPORTING) + +typedef struct _PCI_EXPRESS_AER_CAPABILITY { + PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Header; + PCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS UncorrectableErrorStatus; + PCI_EXPRESS_UNCORRECTABLE_ERROR_MASK UncorrectableErrorMask; + PCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY UncorrectableErrorSeverity; + PCI_EXPRESS_CORRECTABLE_ERROR_STATUS CorrectableErrorStatus; + PCI_EXPRESS_CORRECTABLE_ERROR_MASK CorrectableErrorMask; + PCI_EXPRESS_AER_CAPABILITIES CapabilitiesAndControl; + ULONG HeaderLog[4]; + PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_STATUS SecUncorrectableErrorStatus; + PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_MASK SecUncorrectableErrorMask; + PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_SEVERITY SecUncorrectableErrorSeverity; + PCI_EXPRESS_SEC_AER_CAPABILITIES SecCapabilitiesAndControl; + ULONG SecHeaderLog[4]; +} PCI_EXPRESS_AER_CAPABILITY, *PPCI_EXPRESS_AER_CAPABILITY; + +typedef struct _PCI_EXPRESS_ROOTPORT_AER_CAPABILITY { + PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Header; + PCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS UncorrectableErrorStatus; + PCI_EXPRESS_UNCORRECTABLE_ERROR_MASK UncorrectableErrorMask; + PCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY UncorrectableErrorSeverity; + PCI_EXPRESS_CORRECTABLE_ERROR_STATUS CorrectableErrorStatus; + PCI_EXPRESS_CORRECTABLE_ERROR_MASK CorrectableErrorMask; + PCI_EXPRESS_AER_CAPABILITIES CapabilitiesAndControl; + ULONG HeaderLog[4]; + PCI_EXPRESS_ROOT_ERROR_COMMAND RootErrorCommand; + PCI_EXPRESS_ROOT_ERROR_STATUS RootErrorStatus; + PCI_EXPRESS_ERROR_SOURCE_ID ErrorSourceId; +} PCI_EXPRESS_ROOTPORT_AER_CAPABILITY, *PPCI_EXPRESS_ROOTPORT_AER_CAPABILITY; + +typedef struct _PCI_EXPRESS_BRIDGE_AER_CAPABILITY { + PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Header; + PCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS UncorrectableErrorStatus; + PCI_EXPRESS_UNCORRECTABLE_ERROR_MASK UncorrectableErrorMask; + PCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY UncorrectableErrorSeverity; + PCI_EXPRESS_CORRECTABLE_ERROR_STATUS CorrectableErrorStatus; + PCI_EXPRESS_CORRECTABLE_ERROR_MASK CorrectableErrorMask; + PCI_EXPRESS_AER_CAPABILITIES CapabilitiesAndControl; + ULONG HeaderLog[4]; + PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_STATUS SecUncorrectableErrorStatus; + PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_MASK SecUncorrectableErrorMask; + PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_SEVERITY SecUncorrectableErrorSeverity; + PCI_EXPRESS_SEC_AER_CAPABILITIES SecCapabilitiesAndControl; + ULONG SecHeaderLog[4]; +} PCI_EXPRESS_BRIDGE_AER_CAPABILITY, *PPCI_EXPRESS_BRIDGE_AER_CAPABILITY; + +typedef union _PCI_EXPRESS_SRIOV_CAPS { + struct { + ULONG VFMigrationCapable:1; + ULONG Reserved1:20; + ULONG VFMigrationInterruptNumber:11; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_SRIOV_CAPS, *PPCI_EXPRESS_SRIOV_CAPS; + +typedef union _PCI_EXPRESS_SRIOV_CONTROL { + struct { + USHORT VFEnable:1; + USHORT VFMigrationEnable:1; + USHORT VFMigrationInterruptEnable:1; + USHORT VFMemorySpaceEnable:1; + USHORT ARICapableHierarchy:1; + USHORT Reserved1:11; + } DUMMYSTRUCTNAME; + USHORT AsUSHORT; +} PCI_EXPRESS_SRIOV_CONTROL, *PPCI_EXPRESS_SRIOV_CONTROL; + +typedef union _PCI_EXPRESS_SRIOV_STATUS { + struct { + USHORT VFMigrationStatus:1; + USHORT Reserved1:15; + } DUMMYSTRUCTNAME; + USHORT AsUSHORT; +} PCI_EXPRESS_SRIOV_STATUS, *PPCI_EXPRESS_SRIOV_STATUS; + +typedef union _PCI_EXPRESS_SRIOV_MIGRATION_STATE_ARRAY { + struct { + ULONG VFMigrationStateBIR:3; + ULONG VFMigrationStateOffset:29; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_SRIOV_MIGRATION_STATE_ARRAY, *PPCI_EXPRESS_SRIOV_MIGRATION_STATE_ARRAY; + +typedef struct _PCI_EXPRESS_SRIOV_CAPABILITY { + PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Header; + PCI_EXPRESS_SRIOV_CAPS SRIOVCapabilities; + PCI_EXPRESS_SRIOV_CONTROL SRIOVControl; + PCI_EXPRESS_SRIOV_STATUS SRIOVStatus; + USHORT InitialVFs; + USHORT TotalVFs; + USHORT NumVFs; + UCHAR FunctionDependencyLink; + UCHAR RsvdP1; + USHORT FirstVFOffset; + USHORT VFStride; + USHORT RsvdP2; + USHORT VFDeviceId; + ULONG SupportedPageSizes; + ULONG SystemPageSize; + ULONG BaseAddresses[PCI_TYPE0_ADDRESSES]; + PCI_EXPRESS_SRIOV_MIGRATION_STATE_ARRAY VFMigrationStateArrayOffset; +} PCI_EXPRESS_SRIOV_CAPABILITY, *PPCI_EXPRESS_SRIOV_CAPABILITY; + +/* PCI device classes */ +#define PCI_CLASS_PRE_20 0x00 +#define PCI_CLASS_MASS_STORAGE_CTLR 0x01 +#define PCI_CLASS_NETWORK_CTLR 0x02 +#define PCI_CLASS_DISPLAY_CTLR 0x03 +#define PCI_CLASS_MULTIMEDIA_DEV 0x04 +#define PCI_CLASS_MEMORY_CTLR 0x05 +#define PCI_CLASS_BRIDGE_DEV 0x06 +#define PCI_CLASS_SIMPLE_COMMS_CTLR 0x07 +#define PCI_CLASS_BASE_SYSTEM_DEV 0x08 +#define PCI_CLASS_INPUT_DEV 0x09 +#define PCI_CLASS_DOCKING_STATION 0x0a +#define PCI_CLASS_PROCESSOR 0x0b +#define PCI_CLASS_SERIAL_BUS_CTLR 0x0c +#define PCI_CLASS_WIRELESS_CTLR 0x0d +#define PCI_CLASS_INTELLIGENT_IO_CTLR 0x0e +#define PCI_CLASS_SATELLITE_COMMS_CTLR 0x0f +#define PCI_CLASS_ENCRYPTION_DECRYPTION 0x10 +#define PCI_CLASS_DATA_ACQ_SIGNAL_PROC 0x11 +#define PCI_CLASS_NOT_DEFINED 0xff + +/* PCI device subclasses for class 0 */ +#define PCI_SUBCLASS_PRE_20_NON_VGA 0x00 +#define PCI_SUBCLASS_PRE_20_VGA 0x01 + +/* PCI device subclasses for class 1 (mass storage controllers)*/ +#define PCI_SUBCLASS_MSC_SCSI_BUS_CTLR 0x00 +#define PCI_SUBCLASS_MSC_IDE_CTLR 0x01 +#define PCI_SUBCLASS_MSC_FLOPPY_CTLR 0x02 +#define PCI_SUBCLASS_MSC_IPI_CTLR 0x03 +#define PCI_SUBCLASS_MSC_RAID_CTLR 0x04 +#define PCI_SUBCLASS_MSC_OTHER 0x80 + +/* PCI device subclasses for class 2 (network controllers)*/ +#define PCI_SUBCLASS_NET_ETHERNET_CTLR 0x00 +#define PCI_SUBCLASS_NET_TOKEN_RING_CTLR 0x01 +#define PCI_SUBCLASS_NET_FDDI_CTLR 0x02 +#define PCI_SUBCLASS_NET_ATM_CTLR 0x03 +#define PCI_SUBCLASS_NET_ISDN_CTLR 0x04 +#define PCI_SUBCLASS_NET_OTHER 0x80 + +/* PCI device subclasses for class 3 (display controllers)*/ +#define PCI_SUBCLASS_VID_VGA_CTLR 0x00 +#define PCI_SUBCLASS_VID_XGA_CTLR 0x01 +#define PCI_SUBCLASS_VID_3D_CTLR 0x02 +#define PCI_SUBCLASS_VID_OTHER 0x80 + +/* PCI device subclasses for class 4 (multimedia device)*/ +#define PCI_SUBCLASS_MM_VIDEO_DEV 0x00 +#define PCI_SUBCLASS_MM_AUDIO_DEV 0x01 +#define PCI_SUBCLASS_MM_TELEPHONY_DEV 0x02 +#define PCI_SUBCLASS_MM_OTHER 0x80 + +/* PCI device subclasses for class 5 (memory controller)*/ +#define PCI_SUBCLASS_MEM_RAM 0x00 +#define PCI_SUBCLASS_MEM_FLASH 0x01 +#define PCI_SUBCLASS_MEM_OTHER 0x80 + +/* PCI device subclasses for class 6 (bridge device)*/ +#define PCI_SUBCLASS_BR_HOST 0x00 +#define PCI_SUBCLASS_BR_ISA 0x01 +#define PCI_SUBCLASS_BR_EISA 0x02 +#define PCI_SUBCLASS_BR_MCA 0x03 +#define PCI_SUBCLASS_BR_PCI_TO_PCI 0x04 +#define PCI_SUBCLASS_BR_PCMCIA 0x05 +#define PCI_SUBCLASS_BR_NUBUS 0x06 +#define PCI_SUBCLASS_BR_CARDBUS 0x07 +#define PCI_SUBCLASS_BR_RACEWAY 0x08 +#define PCI_SUBCLASS_BR_OTHER 0x80 + +#define PCI_SUBCLASS_COM_SERIAL 0x00 +#define PCI_SUBCLASS_COM_PARALLEL 0x01 +#define PCI_SUBCLASS_COM_MULTIPORT 0x02 +#define PCI_SUBCLASS_COM_MODEM 0x03 +#define PCI_SUBCLASS_COM_OTHER 0x80 + +#define PCI_SUBCLASS_SYS_INTERRUPT_CTLR 0x00 +#define PCI_SUBCLASS_SYS_DMA_CTLR 0x01 +#define PCI_SUBCLASS_SYS_SYSTEM_TIMER 0x02 +#define PCI_SUBCLASS_SYS_REAL_TIME_CLOCK 0x03 +#define PCI_SUBCLASS_SYS_GEN_HOTPLUG_CTLR 0x04 +#define PCI_SUBCLASS_SYS_SDIO_CTRL 0x05 +#define PCI_SUBCLASS_SYS_OTHER 0x80 + +#define PCI_SUBCLASS_INP_KEYBOARD 0x00 +#define PCI_SUBCLASS_INP_DIGITIZER 0x01 +#define PCI_SUBCLASS_INP_MOUSE 0x02 +#define PCI_SUBCLASS_INP_SCANNER 0x03 +#define PCI_SUBCLASS_INP_GAMEPORT 0x04 +#define PCI_SUBCLASS_INP_OTHER 0x80 + +#define PCI_SUBCLASS_DOC_GENERIC 0x00 +#define PCI_SUBCLASS_DOC_OTHER 0x80 + +#define PCI_SUBCLASS_PROC_386 0x00 +#define PCI_SUBCLASS_PROC_486 0x01 +#define PCI_SUBCLASS_PROC_PENTIUM 0x02 +#define PCI_SUBCLASS_PROC_ALPHA 0x10 +#define PCI_SUBCLASS_PROC_POWERPC 0x20 +#define PCI_SUBCLASS_PROC_COPROCESSOR 0x40 + +/* PCI device subclasses for class C (serial bus controller)*/ +#define PCI_SUBCLASS_SB_IEEE1394 0x00 +#define PCI_SUBCLASS_SB_ACCESS 0x01 +#define PCI_SUBCLASS_SB_SSA 0x02 +#define PCI_SUBCLASS_SB_USB 0x03 +#define PCI_SUBCLASS_SB_FIBRE_CHANNEL 0x04 +#define PCI_SUBCLASS_SB_SMBUS 0x05 + +#define PCI_SUBCLASS_WIRELESS_IRDA 0x00 +#define PCI_SUBCLASS_WIRELESS_CON_IR 0x01 +#define PCI_SUBCLASS_WIRELESS_RF 0x10 +#define PCI_SUBCLASS_WIRELESS_OTHER 0x80 + +#define PCI_SUBCLASS_INTIO_I2O 0x00 + +#define PCI_SUBCLASS_SAT_TV 0x01 +#define PCI_SUBCLASS_SAT_AUDIO 0x02 +#define PCI_SUBCLASS_SAT_VOICE 0x03 +#define PCI_SUBCLASS_SAT_DATA 0x04 + +#define PCI_SUBCLASS_CRYPTO_NET_COMP 0x00 +#define PCI_SUBCLASS_CRYPTO_ENTERTAINMENT 0x10 +#define PCI_SUBCLASS_CRYPTO_OTHER 0x80 + +#define PCI_SUBCLASS_DASP_DPIO 0x00 +#define PCI_SUBCLASS_DASP_OTHER 0x80 + +#define PCI_ADDRESS_IO_SPACE 0x00000001 +#define PCI_ADDRESS_MEMORY_TYPE_MASK 0x00000006 +#define PCI_ADDRESS_MEMORY_PREFETCHABLE 0x00000008 +#define PCI_ADDRESS_IO_ADDRESS_MASK 0xfffffffc +#define PCI_ADDRESS_MEMORY_ADDRESS_MASK 0xfffffff0 +#define PCI_ADDRESS_ROM_ADDRESS_MASK 0xfffff800 + +#define PCI_TYPE_32BIT 0 +#define PCI_TYPE_20BIT 2 +#define PCI_TYPE_64BIT 4 + +#define PCI_ROMADDRESS_ENABLED 0x00000001 + +#endif /* _PCI_X_ */ + +#define PCI_EXPRESS_LINK_QUIESCENT_INTERFACE_VERSION 1 + +typedef NTSTATUS +(NTAPI PCI_EXPRESS_ENTER_LINK_QUIESCENT_MODE)( + IN OUT PVOID Context); +typedef PCI_EXPRESS_ENTER_LINK_QUIESCENT_MODE *PPCI_EXPRESS_ENTER_LINK_QUIESCENT_MODE; + +typedef NTSTATUS +(NTAPI PCI_EXPRESS_EXIT_LINK_QUIESCENT_MODE)( + IN OUT PVOID Context); +typedef PCI_EXPRESS_EXIT_LINK_QUIESCENT_MODE *PPCI_EXPRESS_EXIT_LINK_QUIESCENT_MODE; + +typedef struct _PCI_EXPRESS_LINK_QUIESCENT_INTERFACE { + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; + PPCI_EXPRESS_ENTER_LINK_QUIESCENT_MODE PciExpressEnterLinkQuiescentMode; + PPCI_EXPRESS_EXIT_LINK_QUIESCENT_MODE PciExpressExitLinkQuiescentMode; +} PCI_EXPRESS_LINK_QUIESCENT_INTERFACE, *PPCI_EXPRESS_LINK_QUIESCENT_INTERFACE; + +#define PCI_EXPRESS_ROOT_PORT_INTERFACE_VERSION 1 + +typedef ULONG +(NTAPI *PPCI_EXPRESS_ROOT_PORT_READ_CONFIG_SPACE)( + IN PVOID Context, + OUT PVOID Buffer, + IN ULONG Offset, + IN ULONG Length); + +typedef ULONG +(NTAPI *PPCI_EXPRESS_ROOT_PORT_WRITE_CONFIG_SPACE)( + IN PVOID Context, + IN PVOID Buffer, + IN ULONG Offset, + IN ULONG Length); + +typedef struct _PCI_EXPRESS_ROOT_PORT_INTERFACE { + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; + PPCI_EXPRESS_ROOT_PORT_READ_CONFIG_SPACE ReadConfigSpace; + PPCI_EXPRESS_ROOT_PORT_WRITE_CONFIG_SPACE WriteConfigSpace; +} PCI_EXPRESS_ROOT_PORT_INTERFACE, *PPCI_EXPRESS_ROOT_PORT_INTERFACE; + +#define PCI_MSIX_TABLE_CONFIG_INTERFACE_VERSION 1 + +typedef NTSTATUS +(NTAPI PCI_MSIX_SET_ENTRY)( + IN PVOID Context, + IN ULONG TableEntry, + IN ULONG MessageNumber); +typedef PCI_MSIX_SET_ENTRY *PPCI_MSIX_SET_ENTRY; + +typedef NTSTATUS +(NTAPI PCI_MSIX_MASKUNMASK_ENTRY)( + IN PVOID Context, + IN ULONG TableEntry); +typedef PCI_MSIX_MASKUNMASK_ENTRY *PPCI_MSIX_MASKUNMASK_ENTRY; + +typedef NTSTATUS +(NTAPI PCI_MSIX_GET_ENTRY)( + IN PVOID Context, + IN ULONG TableEntry, + OUT PULONG MessageNumber, + OUT PBOOLEAN Masked); +typedef PCI_MSIX_GET_ENTRY *PPCI_MSIX_GET_ENTRY; + +typedef NTSTATUS +(NTAPI PCI_MSIX_GET_TABLE_SIZE)( + IN PVOID Context, + OUT PULONG TableSize); +typedef PCI_MSIX_GET_TABLE_SIZE *PPCI_MSIX_GET_TABLE_SIZE; + +typedef struct _PCI_MSIX_TABLE_CONFIG_INTERFACE { + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; + PPCI_MSIX_SET_ENTRY SetTableEntry; + PPCI_MSIX_MASKUNMASK_ENTRY MaskTableEntry; + PPCI_MSIX_MASKUNMASK_ENTRY UnmaskTableEntry; + PPCI_MSIX_GET_ENTRY GetTableEntry; + PPCI_MSIX_GET_TABLE_SIZE GetTableSize; +} PCI_MSIX_TABLE_CONFIG_INTERFACE, *PPCI_MSIX_TABLE_CONFIG_INTERFACE; + +#define PCI_MSIX_TABLE_CONFIG_MINIMUM_SIZE \ + RTL_SIZEOF_THROUGH_FIELD(PCI_MSIX_TABLE_CONFIG_INTERFACE, UnmaskTableEntry) +$endif +$if (_NTDDK_) + +#ifndef _ARC_DDK_ +#define _ARC_DDK_ +typedef enum _CONFIGURATION_TYPE { + ArcSystem, + CentralProcessor, + FloatingPointProcessor, + PrimaryIcache, + PrimaryDcache, + SecondaryIcache, + SecondaryDcache, + SecondaryCache, + EisaAdapter, + TcAdapter, + ScsiAdapter, + DtiAdapter, + MultiFunctionAdapter, + DiskController, + TapeController, + CdromController, + WormController, + SerialController, + NetworkController, + DisplayController, + ParallelController, + PointerController, + KeyboardController, + AudioController, + OtherController, + DiskPeripheral, + FloppyDiskPeripheral, + TapePeripheral, + ModemPeripheral, + MonitorPeripheral, + PrinterPeripheral, + PointerPeripheral, + KeyboardPeripheral, + TerminalPeripheral, + OtherPeripheral, + LinePeripheral, + NetworkPeripheral, + SystemMemory, + DockingInformation, + RealModeIrqRoutingTable, + RealModePCIEnumeration, + MaximumType +} CONFIGURATION_TYPE, *PCONFIGURATION_TYPE; +#endif /* !_ARC_DDK_ */ + +/* +** IRP function codes +*/ + +#define IRP_MN_QUERY_DIRECTORY 0x01 +#define IRP_MN_NOTIFY_CHANGE_DIRECTORY 0x02 + +#define IRP_MN_USER_FS_REQUEST 0x00 +#define IRP_MN_MOUNT_VOLUME 0x01 +#define IRP_MN_VERIFY_VOLUME 0x02 +#define IRP_MN_LOAD_FILE_SYSTEM 0x03 +#define IRP_MN_TRACK_LINK 0x04 +#define IRP_MN_KERNEL_CALL 0x04 + +#define IRP_MN_LOCK 0x01 +#define IRP_MN_UNLOCK_SINGLE 0x02 +#define IRP_MN_UNLOCK_ALL 0x03 +#define IRP_MN_UNLOCK_ALL_BY_KEY 0x04 + +#define IRP_MN_FLUSH_AND_PURGE 0x01 + +#define IRP_MN_NORMAL 0x00 +#define IRP_MN_DPC 0x01 +#define IRP_MN_MDL 0x02 +#define IRP_MN_COMPLETE 0x04 +#define IRP_MN_COMPRESSED 0x08 + +#define IRP_MN_MDL_DPC (IRP_MN_MDL | IRP_MN_DPC) +#define IRP_MN_COMPLETE_MDL (IRP_MN_COMPLETE | IRP_MN_MDL) +#define IRP_MN_COMPLETE_MDL_DPC (IRP_MN_COMPLETE_MDL | IRP_MN_DPC) + +#define IRP_MN_QUERY_LEGACY_BUS_INFORMATION 0x18 + +#define IO_CHECK_CREATE_PARAMETERS 0x0200 +#define IO_ATTACH_DEVICE 0x0400 +#define IO_IGNORE_SHARE_ACCESS_CHECK 0x0800 + +typedef +NTSTATUS +(NTAPI *PIO_QUERY_DEVICE_ROUTINE)( + IN PVOID Context, + IN PUNICODE_STRING PathName, + IN INTERFACE_TYPE BusType, + IN ULONG BusNumber, + IN PKEY_VALUE_FULL_INFORMATION *BusInformation, + IN CONFIGURATION_TYPE ControllerType, + IN ULONG ControllerNumber, + IN PKEY_VALUE_FULL_INFORMATION *ControllerInformation, + IN CONFIGURATION_TYPE PeripheralType, + IN ULONG PeripheralNumber, + IN PKEY_VALUE_FULL_INFORMATION *PeripheralInformation); + +typedef enum _IO_QUERY_DEVICE_DATA_FORMAT { + IoQueryDeviceIdentifier = 0, + IoQueryDeviceConfigurationData, + IoQueryDeviceComponentInformation, + IoQueryDeviceMaxData +} IO_QUERY_DEVICE_DATA_FORMAT, *PIO_QUERY_DEVICE_DATA_FORMAT; + +typedef VOID +(NTAPI *PDRIVER_REINITIALIZE)( + IN struct _DRIVER_OBJECT *DriverObject, + IN PVOID Context OPTIONAL, + IN ULONG Count); + +typedef struct _CONTROLLER_OBJECT { + CSHORT Type; + CSHORT Size; + PVOID ControllerExtension; + KDEVICE_QUEUE DeviceWaitQueue; + ULONG Spare1; + LARGE_INTEGER Spare2; +} CONTROLLER_OBJECT, *PCONTROLLER_OBJECT; + +#define DRVO_REINIT_REGISTERED 0x00000008 +#define DRVO_INITIALIZED 0x00000010 +#define DRVO_BOOTREINIT_REGISTERED 0x00000020 +#define DRVO_LEGACY_RESOURCES 0x00000040 + +typedef struct _CONFIGURATION_INFORMATION { + ULONG DiskCount; + ULONG FloppyCount; + ULONG CdRomCount; + ULONG TapeCount; + ULONG ScsiPortCount; + ULONG SerialCount; + ULONG ParallelCount; + BOOLEAN AtDiskPrimaryAddressClaimed; + BOOLEAN AtDiskSecondaryAddressClaimed; + ULONG Version; + ULONG MediumChangerCount; +} CONFIGURATION_INFORMATION, *PCONFIGURATION_INFORMATION; + +typedef struct _DISK_SIGNATURE { + ULONG PartitionStyle; + _ANONYMOUS_UNION union { + struct { + ULONG Signature; + ULONG CheckSum; + } Mbr; + struct { + GUID DiskId; + } Gpt; + } DUMMYUNIONNAME; +} DISK_SIGNATURE, *PDISK_SIGNATURE; + +typedef struct _TXN_PARAMETER_BLOCK { + USHORT Length; + USHORT TxFsContext; + PVOID TransactionObject; +} TXN_PARAMETER_BLOCK, *PTXN_PARAMETER_BLOCK; + +#define TXF_MINIVERSION_DEFAULT_VIEW (0xFFFE) + +typedef struct _IO_DRIVER_CREATE_CONTEXT { + CSHORT Size; + struct _ECP_LIST *ExtraCreateParameter; + PVOID DeviceObjectHint; + PTXN_PARAMETER_BLOCK TxnParameters; +} IO_DRIVER_CREATE_CONTEXT, *PIO_DRIVER_CREATE_CONTEXT; + +typedef struct _AGP_TARGET_BUS_INTERFACE_STANDARD { + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; + PGET_SET_DEVICE_DATA SetBusData; + PGET_SET_DEVICE_DATA GetBusData; + UCHAR CapabilityID; +} AGP_TARGET_BUS_INTERFACE_STANDARD, *PAGP_TARGET_BUS_INTERFACE_STANDARD; + +typedef NTSTATUS +(NTAPI *PGET_LOCATION_STRING)( + IN OUT PVOID Context OPTIONAL, + OUT PWCHAR *LocationStrings); + +typedef struct _PNP_LOCATION_INTERFACE { + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; + PGET_LOCATION_STRING GetLocationString; +} PNP_LOCATION_INTERFACE, *PPNP_LOCATION_INTERFACE; + +typedef enum _ARBITER_ACTION { + ArbiterActionTestAllocation, + ArbiterActionRetestAllocation, + ArbiterActionCommitAllocation, + ArbiterActionRollbackAllocation, + ArbiterActionQueryAllocatedResources, + ArbiterActionWriteReservedResources, + ArbiterActionQueryConflict, + ArbiterActionQueryArbitrate, + ArbiterActionAddReserved, + ArbiterActionBootAllocation +} ARBITER_ACTION, *PARBITER_ACTION; + +typedef struct _ARBITER_CONFLICT_INFO { + PDEVICE_OBJECT OwningObject; + ULONGLONG Start; + ULONGLONG End; +} ARBITER_CONFLICT_INFO, *PARBITER_CONFLICT_INFO; + +typedef struct _ARBITER_TEST_ALLOCATION_PARAMETERS { + IN OUT PLIST_ENTRY ArbitrationList; + IN ULONG AllocateFromCount; + IN PCM_PARTIAL_RESOURCE_DESCRIPTOR AllocateFrom; +} ARBITER_TEST_ALLOCATION_PARAMETERS, *PARBITER_TEST_ALLOCATION_PARAMETERS; + +typedef struct _ARBITER_RETEST_ALLOCATION_PARAMETERS { + IN OUT PLIST_ENTRY ArbitrationList; + IN ULONG AllocateFromCount; + IN PCM_PARTIAL_RESOURCE_DESCRIPTOR AllocateFrom; +} ARBITER_RETEST_ALLOCATION_PARAMETERS, *PARBITER_RETEST_ALLOCATION_PARAMETERS; + +typedef struct _ARBITER_BOOT_ALLOCATION_PARAMETERS { + IN OUT PLIST_ENTRY ArbitrationList; +} ARBITER_BOOT_ALLOCATION_PARAMETERS, *PARBITER_BOOT_ALLOCATION_PARAMETERS; + +typedef struct _ARBITER_QUERY_ALLOCATED_RESOURCES_PARAMETERS { + OUT PCM_PARTIAL_RESOURCE_LIST *AllocatedResources; +} ARBITER_QUERY_ALLOCATED_RESOURCES_PARAMETERS, *PARBITER_QUERY_ALLOCATED_RESOURCES_PARAMETERS; + +typedef struct _ARBITER_QUERY_CONFLICT_PARAMETERS { + IN PDEVICE_OBJECT PhysicalDeviceObject; + IN PIO_RESOURCE_DESCRIPTOR ConflictingResource; + OUT PULONG ConflictCount; + OUT PARBITER_CONFLICT_INFO *Conflicts; +} ARBITER_QUERY_CONFLICT_PARAMETERS, *PARBITER_QUERY_CONFLICT_PARAMETERS; + +typedef struct _ARBITER_QUERY_ARBITRATE_PARAMETERS { + IN PLIST_ENTRY ArbitrationList; +} ARBITER_QUERY_ARBITRATE_PARAMETERS, *PARBITER_QUERY_ARBITRATE_PARAMETERS; + +typedef struct _ARBITER_ADD_RESERVED_PARAMETERS { + IN PDEVICE_OBJECT ReserveDevice; +} ARBITER_ADD_RESERVED_PARAMETERS, *PARBITER_ADD_RESERVED_PARAMETERS; + +typedef struct _ARBITER_PARAMETERS { + union { + ARBITER_TEST_ALLOCATION_PARAMETERS TestAllocation; + ARBITER_RETEST_ALLOCATION_PARAMETERS RetestAllocation; + ARBITER_BOOT_ALLOCATION_PARAMETERS BootAllocation; + ARBITER_QUERY_ALLOCATED_RESOURCES_PARAMETERS QueryAllocatedResources; + ARBITER_QUERY_CONFLICT_PARAMETERS QueryConflict; + ARBITER_QUERY_ARBITRATE_PARAMETERS QueryArbitrate; + ARBITER_ADD_RESERVED_PARAMETERS AddReserved; + } Parameters; +} ARBITER_PARAMETERS, *PARBITER_PARAMETERS; + +typedef enum _ARBITER_REQUEST_SOURCE { + ArbiterRequestUndefined = -1, + ArbiterRequestLegacyReported, + ArbiterRequestHalReported, + ArbiterRequestLegacyAssigned, + ArbiterRequestPnpDetected, + ArbiterRequestPnpEnumerated +} ARBITER_REQUEST_SOURCE; + +typedef enum _ARBITER_RESULT { + ArbiterResultUndefined = -1, + ArbiterResultSuccess, + ArbiterResultExternalConflict, + ArbiterResultNullRequest +} ARBITER_RESULT; + +#define ARBITER_FLAG_BOOT_CONFIG 0x00000001 + +typedef struct _ARBITER_LIST_ENTRY { + LIST_ENTRY ListEntry; + ULONG AlternativeCount; + PIO_RESOURCE_DESCRIPTOR Alternatives; + PDEVICE_OBJECT PhysicalDeviceObject; + ARBITER_REQUEST_SOURCE RequestSource; + ULONG Flags; + LONG_PTR WorkSpace; + INTERFACE_TYPE InterfaceType; + ULONG SlotNumber; + ULONG BusNumber; + PCM_PARTIAL_RESOURCE_DESCRIPTOR Assignment; + PIO_RESOURCE_DESCRIPTOR SelectedAlternative; + ARBITER_RESULT Result; +} ARBITER_LIST_ENTRY, *PARBITER_LIST_ENTRY; + +typedef NTSTATUS +(NTAPI *PARBITER_HANDLER)( + IN OUT PVOID Context, + IN ARBITER_ACTION Action, + IN OUT PARBITER_PARAMETERS Parameters); + +#define ARBITER_PARTIAL 0x00000001 + +typedef struct _ARBITER_INTERFACE { + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; + PARBITER_HANDLER ArbiterHandler; + ULONG Flags; +} ARBITER_INTERFACE, *PARBITER_INTERFACE; + +typedef enum _RESOURCE_TRANSLATION_DIRECTION { + TranslateChildToParent, + TranslateParentToChild +} RESOURCE_TRANSLATION_DIRECTION; + +typedef NTSTATUS +(NTAPI *PTRANSLATE_RESOURCE_HANDLER)( + IN OUT PVOID Context OPTIONAL, + IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Source, + IN RESOURCE_TRANSLATION_DIRECTION Direction, + IN ULONG AlternativesCount OPTIONAL, + IN IO_RESOURCE_DESCRIPTOR Alternatives[], + IN PDEVICE_OBJECT PhysicalDeviceObject, + OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR Target); + +typedef NTSTATUS +(NTAPI *PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER)( + IN OUT PVOID Context OPTIONAL, + IN PIO_RESOURCE_DESCRIPTOR Source, + IN PDEVICE_OBJECT PhysicalDeviceObject, + OUT PULONG TargetCount, + OUT PIO_RESOURCE_DESCRIPTOR *Target); + +typedef struct _TRANSLATOR_INTERFACE { + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; + PTRANSLATE_RESOURCE_HANDLER TranslateResources; + PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER TranslateResourceRequirements; +} TRANSLATOR_INTERFACE, *PTRANSLATOR_INTERFACE; + +typedef struct _PCI_AGP_CAPABILITY { + PCI_CAPABILITIES_HEADER Header; + USHORT Minor:4; + USHORT Major:4; + USHORT Rsvd1:8; + struct _PCI_AGP_STATUS { + ULONG Rate:3; + ULONG Agp3Mode:1; + ULONG FastWrite:1; + ULONG FourGB:1; + ULONG HostTransDisable:1; + ULONG Gart64:1; + ULONG ITA_Coherent:1; + ULONG SideBandAddressing:1; + ULONG CalibrationCycle:3; + ULONG AsyncRequestSize:3; + ULONG Rsvd1:1; + ULONG Isoch:1; + ULONG Rsvd2:6; + ULONG RequestQueueDepthMaximum:8; + } AGPStatus; + struct _PCI_AGP_COMMAND { + ULONG Rate:3; + ULONG Rsvd1:1; + ULONG FastWriteEnable:1; + ULONG FourGBEnable:1; + ULONG Rsvd2:1; + ULONG Gart64:1; + ULONG AGPEnable:1; + ULONG SBAEnable:1; + ULONG CalibrationCycle:3; + ULONG AsyncReqSize:3; + ULONG Rsvd3:8; + ULONG RequestQueueDepth:8; + } AGPCommand; +} PCI_AGP_CAPABILITY, *PPCI_AGP_CAPABILITY; + +typedef enum _EXTENDED_AGP_REGISTER { + IsochStatus, + AgpControl, + ApertureSize, + AperturePageSize, + GartLow, + GartHigh, + IsochCommand +} EXTENDED_AGP_REGISTER, *PEXTENDED_AGP_REGISTER; + +typedef struct _PCI_AGP_ISOCH_STATUS { + ULONG ErrorCode:2; + ULONG Rsvd1:1; + ULONG Isoch_L:3; + ULONG Isoch_Y:2; + ULONG Isoch_N:8; + ULONG Rsvd2:16; +} PCI_AGP_ISOCH_STATUS, *PPCI_AGP_ISOCH_STATUS; + +typedef struct _PCI_AGP_CONTROL { + ULONG Rsvd1:7; + ULONG GTLB_Enable:1; + ULONG AP_Enable:1; + ULONG CAL_Disable:1; + ULONG Rsvd2:22; +} PCI_AGP_CONTROL, *PPCI_AGP_CONTROL; + +typedef struct _PCI_AGP_APERTURE_PAGE_SIZE { + USHORT PageSizeMask:11; + USHORT Rsvd1:1; + USHORT PageSizeSelect:4; +} PCI_AGP_APERTURE_PAGE_SIZE, *PPCI_AGP_APERTURE_PAGE_SIZE; + +typedef struct _PCI_AGP_ISOCH_COMMAND { + USHORT Rsvd1:6; + USHORT Isoch_Y:2; + USHORT Isoch_N:8; +} PCI_AGP_ISOCH_COMMAND, *PPCI_AGP_ISOCH_COMMAND; + +typedef struct PCI_AGP_EXTENDED_CAPABILITY { + PCI_AGP_ISOCH_STATUS IsochStatus; + PCI_AGP_CONTROL AgpControl; + USHORT ApertureSize; + PCI_AGP_APERTURE_PAGE_SIZE AperturePageSize; + ULONG GartLow; + ULONG GartHigh; + PCI_AGP_ISOCH_COMMAND IsochCommand; +} PCI_AGP_EXTENDED_CAPABILITY, *PPCI_AGP_EXTENDED_CAPABILITY; + +#define PCI_AGP_RATE_1X 0x1 +#define PCI_AGP_RATE_2X 0x2 +#define PCI_AGP_RATE_4X 0x4 + +#define PCIX_MODE_CONVENTIONAL_PCI 0x0 +#define PCIX_MODE1_66MHZ 0x1 +#define PCIX_MODE1_100MHZ 0x2 +#define PCIX_MODE1_133MHZ 0x3 +#define PCIX_MODE2_266_66MHZ 0x9 +#define PCIX_MODE2_266_100MHZ 0xA +#define PCIX_MODE2_266_133MHZ 0xB +#define PCIX_MODE2_533_66MHZ 0xD +#define PCIX_MODE2_533_100MHZ 0xE +#define PCIX_MODE2_533_133MHZ 0xF + +#define PCIX_VERSION_MODE1_ONLY 0x0 +#define PCIX_VERSION_MODE2_ECC 0x1 +#define PCIX_VERSION_DUAL_MODE_ECC 0x2 + +typedef struct _PCIX_BRIDGE_CAPABILITY { + PCI_CAPABILITIES_HEADER Header; + union { + struct { + USHORT Bus64Bit:1; + USHORT Bus133MHzCapable:1; + USHORT SplitCompletionDiscarded:1; + USHORT UnexpectedSplitCompletion:1; + USHORT SplitCompletionOverrun:1; + USHORT SplitRequestDelayed:1; + USHORT BusModeFrequency:4; + USHORT Rsvd:2; + USHORT Version:2; + USHORT Bus266MHzCapable:1; + USHORT Bus533MHzCapable:1; + } DUMMYSTRUCTNAME; + USHORT AsUSHORT; + } SecondaryStatus; + union { + struct { + ULONG FunctionNumber:3; + ULONG DeviceNumber:5; + ULONG BusNumber:8; + ULONG Device64Bit:1; + ULONG Device133MHzCapable:1; + ULONG SplitCompletionDiscarded:1; + ULONG UnexpectedSplitCompletion:1; + ULONG SplitCompletionOverrun:1; + ULONG SplitRequestDelayed:1; + ULONG Rsvd:7; + ULONG DIMCapable:1; + ULONG Device266MHzCapable:1; + ULONG Device533MHzCapable:1; + } DUMMYSTRUCTNAME; + ULONG AsULONG; + } BridgeStatus; + USHORT UpstreamSplitTransactionCapacity; + USHORT UpstreamSplitTransactionLimit; + USHORT DownstreamSplitTransactionCapacity; + USHORT DownstreamSplitTransactionLimit; + union { + struct { + ULONG SelectSecondaryRegisters:1; + ULONG ErrorPresentInOtherBank:1; + ULONG AdditionalCorrectableError:1; + ULONG AdditionalUncorrectableError:1; + ULONG ErrorPhase:3; + ULONG ErrorCorrected:1; + ULONG Syndrome:8; + ULONG ErrorFirstCommand:4; + ULONG ErrorSecondCommand:4; + ULONG ErrorUpperAttributes:4; + ULONG ControlUpdateEnable:1; + ULONG Rsvd:1; + ULONG DisableSingleBitCorrection:1; + ULONG EccMode:1; + } DUMMYSTRUCTNAME; + ULONG AsULONG; + } EccControlStatus; + ULONG EccFirstAddress; + ULONG EccSecondAddress; + ULONG EccAttribute; +} PCIX_BRIDGE_CAPABILITY, *PPCIX_BRIDGE_CAPABILITY; + +typedef struct _PCI_SUBSYSTEM_IDS_CAPABILITY { + PCI_CAPABILITIES_HEADER Header; + USHORT Reserved; + USHORT SubVendorID; + USHORT SubSystemID; +} PCI_SUBSYSTEM_IDS_CAPABILITY, *PPCI_SUBSYSTEM_IDS_CAPABILITY; + +#define OSC_FIRMWARE_FAILURE 0x02 +#define OSC_UNRECOGNIZED_UUID 0x04 +#define OSC_UNRECOGNIZED_REVISION 0x08 +#define OSC_CAPABILITIES_MASKED 0x10 + +#define PCI_ROOT_BUS_OSC_METHOD_CAPABILITY_REVISION 0x01 + +typedef struct _PCI_ROOT_BUS_OSC_SUPPORT_FIELD { + union { + struct { + ULONG ExtendedConfigOpRegions:1; + ULONG ActiveStatePowerManagement:1; + ULONG ClockPowerManagement:1; + ULONG SegmentGroups:1; + ULONG MessageSignaledInterrupts:1; + ULONG WindowsHardwareErrorArchitecture:1; + ULONG Reserved:26; + } DUMMYSTRUCTNAME; + ULONG AsULONG; + } u; +} PCI_ROOT_BUS_OSC_SUPPORT_FIELD, *PPCI_ROOT_BUS_OSC_SUPPORT_FIELD; + +typedef struct _PCI_ROOT_BUS_OSC_CONTROL_FIELD { + union { + struct { + ULONG ExpressNativeHotPlug:1; + ULONG ShpcNativeHotPlug:1; + ULONG ExpressNativePME:1; + ULONG ExpressAdvancedErrorReporting:1; + ULONG ExpressCapabilityStructure:1; + ULONG Reserved:27; + } DUMMYSTRUCTNAME; + ULONG AsULONG; + } u; +} PCI_ROOT_BUS_OSC_CONTROL_FIELD, *PPCI_ROOT_BUS_OSC_CONTROL_FIELD; + +typedef enum _PCI_HARDWARE_INTERFACE { + PciConventional, + PciXMode1, + PciXMode2, + PciExpress +} PCI_HARDWARE_INTERFACE, *PPCI_HARDWARE_INTERFACE; + +typedef enum { + BusWidth32Bits, + BusWidth64Bits +} PCI_BUS_WIDTH; + +typedef struct _PCI_ROOT_BUS_HARDWARE_CAPABILITY { + PCI_HARDWARE_INTERFACE SecondaryInterface; + struct { + BOOLEAN BusCapabilitiesFound; + ULONG CurrentSpeedAndMode; + ULONG SupportedSpeedsAndModes; + BOOLEAN DeviceIDMessagingCapable; + PCI_BUS_WIDTH SecondaryBusWidth; + } DUMMYSTRUCTNAME; + PCI_ROOT_BUS_OSC_SUPPORT_FIELD OscFeatureSupport; + PCI_ROOT_BUS_OSC_CONTROL_FIELD OscControlRequest; + PCI_ROOT_BUS_OSC_CONTROL_FIELD OscControlGranted; +} PCI_ROOT_BUS_HARDWARE_CAPABILITY, *PPCI_ROOT_BUS_HARDWARE_CAPABILITY; + +typedef union _PCI_EXPRESS_CAPABILITIES_REGISTER { + struct { + USHORT CapabilityVersion:4; + USHORT DeviceType:4; + USHORT SlotImplemented:1; + USHORT InterruptMessageNumber:5; + USHORT Rsvd:2; + } DUMMYSTRUCTNAME; + USHORT AsUSHORT; +} PCI_EXPRESS_CAPABILITIES_REGISTER, *PPCI_EXPRESS_CAPABILITIES_REGISTER; + +typedef union _PCI_EXPRESS_DEVICE_CAPABILITIES_REGISTER { + struct { + ULONG MaxPayloadSizeSupported:3; + ULONG PhantomFunctionsSupported:2; + ULONG ExtendedTagSupported:1; + ULONG L0sAcceptableLatency:3; + ULONG L1AcceptableLatency:3; + ULONG Undefined:3; + ULONG RoleBasedErrorReporting:1; + ULONG Rsvd1:2; + ULONG CapturedSlotPowerLimit:8; + ULONG CapturedSlotPowerLimitScale:2; + ULONG Rsvd2:4; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_DEVICE_CAPABILITIES_REGISTER, *PPCI_EXPRESS_DEVICE_CAPABILITIES_REGISTER; + +#define PCI_EXPRESS_AER_DEVICE_CONTROL_MASK 0x07; + +typedef union _PCI_EXPRESS_DEVICE_CONTROL_REGISTER { + struct { + USHORT CorrectableErrorEnable:1; + USHORT NonFatalErrorEnable:1; + USHORT FatalErrorEnable:1; + USHORT UnsupportedRequestErrorEnable:1; + USHORT EnableRelaxedOrder:1; + USHORT MaxPayloadSize:3; + USHORT ExtendedTagEnable:1; + USHORT PhantomFunctionsEnable:1; + USHORT AuxPowerEnable:1; + USHORT NoSnoopEnable:1; + USHORT MaxReadRequestSize:3; + USHORT BridgeConfigRetryEnable:1; + } DUMMYSTRUCTNAME; + USHORT AsUSHORT; +} PCI_EXPRESS_DEVICE_CONTROL_REGISTER, *PPCI_EXPRESS_DEVICE_CONTROL_REGISTER; + +#define PCI_EXPRESS_AER_DEVICE_STATUS_MASK 0x0F; + +typedef union _PCI_EXPRESS_DEVICE_STATUS_REGISTER { + struct { + USHORT CorrectableErrorDetected:1; + USHORT NonFatalErrorDetected:1; + USHORT FatalErrorDetected:1; + USHORT UnsupportedRequestDetected:1; + USHORT AuxPowerDetected:1; + USHORT TransactionsPending:1; + USHORT Rsvd:10; + } DUMMYSTRUCTNAME; + USHORT AsUSHORT; +} PCI_EXPRESS_DEVICE_STATUS_REGISTER, *PPCI_EXPRESS_DEVICE_STATUS_REGISTER; + +typedef union _PCI_EXPRESS_LINK_CAPABILITIES_REGISTER { + struct { + ULONG MaximumLinkSpeed:4; + ULONG MaximumLinkWidth:6; + ULONG ActiveStatePMSupport:2; + ULONG L0sExitLatency:3; + ULONG L1ExitLatency:3; + ULONG ClockPowerManagement:1; + ULONG SurpriseDownErrorReportingCapable:1; + ULONG DataLinkLayerActiveReportingCapable:1; + ULONG Rsvd:3; + ULONG PortNumber:8; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_LINK_CAPABILITIES_REGISTER, *PPCI_EXPRESS_LINK_CAPABILITIES_REGISTER; + +typedef union _PCI_EXPRESS_LINK_CONTROL_REGISTER { + struct { + USHORT ActiveStatePMControl:2; + USHORT Rsvd1:1; + USHORT ReadCompletionBoundary:1; + USHORT LinkDisable:1; + USHORT RetrainLink:1; + USHORT CommonClockConfig:1; + USHORT ExtendedSynch:1; + USHORT EnableClockPowerManagement:1; + USHORT Rsvd2:7; + } DUMMYSTRUCTNAME; + USHORT AsUSHORT; +} PCI_EXPRESS_LINK_CONTROL_REGISTER, *PPCI_EXPRESS_LINK_CONTROL_REGISTER; + +typedef union _PCI_EXPRESS_LINK_STATUS_REGISTER { + struct { + USHORT LinkSpeed:4; + USHORT LinkWidth:6; + USHORT Undefined:1; + USHORT LinkTraining:1; + USHORT SlotClockConfig:1; + USHORT DataLinkLayerActive:1; + USHORT Rsvd:2; + } DUMMYSTRUCTNAME; + USHORT AsUSHORT; +} PCI_EXPRESS_LINK_STATUS_REGISTER, *PPCI_EXPRESS_LINK_STATUS_REGISTER; + +typedef union _PCI_EXPRESS_SLOT_CAPABILITIES_REGISTER { + struct { + ULONG AttentionButtonPresent:1; + ULONG PowerControllerPresent:1; + ULONG MRLSensorPresent:1; + ULONG AttentionIndicatorPresent:1; + ULONG PowerIndicatorPresent:1; + ULONG HotPlugSurprise:1; + ULONG HotPlugCapable:1; + ULONG SlotPowerLimit:8; + ULONG SlotPowerLimitScale:2; + ULONG ElectromechanicalLockPresent:1; + ULONG NoCommandCompletedSupport:1; + ULONG PhysicalSlotNumber:13; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_SLOT_CAPABILITIES_REGISTER, *PPCI_EXPRESS_SLOT_CAPABILITIES_REGISTER; + +typedef union _PCI_EXPRESS_SLOT_CONTROL_REGISTER { + struct { + USHORT AttentionButtonEnable:1; + USHORT PowerFaultDetectEnable:1; + USHORT MRLSensorEnable:1; + USHORT PresenceDetectEnable:1; + USHORT CommandCompletedEnable:1; + USHORT HotPlugInterruptEnable:1; + USHORT AttentionIndicatorControl:2; + USHORT PowerIndicatorControl:2; + USHORT PowerControllerControl:1; + USHORT ElectromechanicalLockControl:1; + USHORT DataLinkStateChangeEnable:1; + USHORT Rsvd:3; + } DUMMYSTRUCTNAME; + USHORT AsUSHORT; +} PCI_EXPRESS_SLOT_CONTROL_REGISTER, *PPCI_EXPRESS_SLOT_CONTROL_REGISTER; + +typedef union _PCI_EXPRESS_SLOT_STATUS_REGISTER { + struct { + USHORT AttentionButtonPressed:1; + USHORT PowerFaultDetected:1; + USHORT MRLSensorChanged:1; + USHORT PresenceDetectChanged:1; + USHORT CommandCompleted:1; + USHORT MRLSensorState:1; + USHORT PresenceDetectState:1; + USHORT ElectromechanicalLockEngaged:1; + USHORT DataLinkStateChanged:1; + USHORT Rsvd:7; + } DUMMYSTRUCTNAME; + USHORT AsUSHORT; +} PCI_EXPRESS_SLOT_STATUS_REGISTER, *PPCI_EXPRESS_SLOT_STATUS_REGISTER; + +typedef union _PCI_EXPRESS_ROOT_CONTROL_REGISTER { + struct { + USHORT CorrectableSerrEnable:1; + USHORT NonFatalSerrEnable:1; + USHORT FatalSerrEnable:1; + USHORT PMEInterruptEnable:1; + USHORT CRSSoftwareVisibilityEnable:1; + USHORT Rsvd:11; + } DUMMYSTRUCTNAME; + USHORT AsUSHORT; +} PCI_EXPRESS_ROOT_CONTROL_REGISTER, *PPCI_EXPRESS_ROOT_CONTROL_REGISTER; + +typedef union _PCI_EXPRESS_ROOT_CAPABILITIES_REGISTER { + struct { + USHORT CRSSoftwareVisibility:1; + USHORT Rsvd:15; + } DUMMYSTRUCTNAME; + USHORT AsUSHORT; +} PCI_EXPRESS_ROOT_CAPABILITIES_REGISTER, *PPCI_EXPRESS_ROOT_CAPABILITIES_REGISTER; + +typedef union _PCI_EXPRESS_ROOT_STATUS_REGISTER { + struct { + ULONG PMERequestorId:16; + ULONG PMEStatus:1; + ULONG PMEPending:1; + ULONG Rsvd:14; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_ROOT_STATUS_REGISTER, *PPCI_EXPRESS_ROOT_STATUS_REGISTER; + +typedef struct _PCI_EXPRESS_CAPABILITY { + PCI_CAPABILITIES_HEADER Header; + PCI_EXPRESS_CAPABILITIES_REGISTER ExpressCapabilities; + PCI_EXPRESS_DEVICE_CAPABILITIES_REGISTER DeviceCapabilities; + PCI_EXPRESS_DEVICE_CONTROL_REGISTER DeviceControl; + PCI_EXPRESS_DEVICE_STATUS_REGISTER DeviceStatus; + PCI_EXPRESS_LINK_CAPABILITIES_REGISTER LinkCapabilities; + PCI_EXPRESS_LINK_CONTROL_REGISTER LinkControl; + PCI_EXPRESS_LINK_STATUS_REGISTER LinkStatus; + PCI_EXPRESS_SLOT_CAPABILITIES_REGISTER SlotCapabilities; + PCI_EXPRESS_SLOT_CONTROL_REGISTER SlotControl; + PCI_EXPRESS_SLOT_STATUS_REGISTER SlotStatus; + PCI_EXPRESS_ROOT_CONTROL_REGISTER RootControl; + PCI_EXPRESS_ROOT_CAPABILITIES_REGISTER RootCapabilities; + PCI_EXPRESS_ROOT_STATUS_REGISTER RootStatus; +} PCI_EXPRESS_CAPABILITY, *PPCI_EXPRESS_CAPABILITY; + +typedef enum { + MRLClosed = 0, + MRLOpen +} PCI_EXPRESS_MRL_STATE; + +typedef enum { + SlotEmpty = 0, + CardPresent +} PCI_EXPRESS_CARD_PRESENCE; + +typedef enum { + IndicatorOn = 1, + IndicatorBlink, + IndicatorOff +} PCI_EXPRESS_INDICATOR_STATE; + +typedef enum { + PowerOn = 0, + PowerOff +} PCI_EXPRESS_POWER_STATE; + +typedef enum { + L0sEntrySupport = 1, + L0sAndL1EntrySupport = 3 +} PCI_EXPRESS_ASPM_SUPPORT; + +typedef enum { + L0sAndL1EntryDisabled, + L0sEntryEnabled, + L1EntryEnabled, + L0sAndL1EntryEnabled +} PCI_EXPRESS_ASPM_CONTROL; + +typedef enum { + L0s_Below64ns = 0, + L0s_64ns_128ns, + L0s_128ns_256ns, + L0s_256ns_512ns, + L0s_512ns_1us, + L0s_1us_2us, + L0s_2us_4us, + L0s_Above4us +} PCI_EXPRESS_L0s_EXIT_LATENCY; + +typedef enum { + L1_Below1us = 0, + L1_1us_2us, + L1_2us_4us, + L1_4us_8us, + L1_8us_16us, + L1_16us_32us, + L1_32us_64us, + L1_Above64us +} PCI_EXPRESS_L1_EXIT_LATENCY; + +typedef enum { + PciExpressEndpoint = 0, + PciExpressLegacyEndpoint, + PciExpressRootPort = 4, + PciExpressUpstreamSwitchPort, + PciExpressDownstreamSwitchPort, + PciExpressToPciXBridge, + PciXToExpressBridge, + PciExpressRootComplexIntegratedEndpoint, + PciExpressRootComplexEventCollector +} PCI_EXPRESS_DEVICE_TYPE; + +typedef enum { + MaxPayload128Bytes = 0, + MaxPayload256Bytes, + MaxPayload512Bytes, + MaxPayload1024Bytes, + MaxPayload2048Bytes, + MaxPayload4096Bytes +} PCI_EXPRESS_MAX_PAYLOAD_SIZE; + +typedef union _PCI_EXPRESS_PME_REQUESTOR_ID { + struct { + USHORT FunctionNumber:3; + USHORT DeviceNumber:5; + USHORT BusNumber:8; + } DUMMYSTRUCTNAME; + USHORT AsUSHORT; +} PCI_EXPRESS_PME_REQUESTOR_ID, *PPCI_EXPRESS_PME_REQUESTOR_ID; + +#if defined(_WIN64) + +#ifndef USE_DMA_MACROS +#define USE_DMA_MACROS +#endif + +#ifndef NO_LEGACY_DRIVERS +#define NO_LEGACY_DRIVERS +#endif + +#endif /* defined(_WIN64) */ + +typedef enum _PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR_TYPE { + ResourceTypeSingle = 0, + ResourceTypeRange, + ResourceTypeExtendedCounterConfiguration, + ResourceTypeOverflow, + ResourceTypeMax +} PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR_TYPE; + +typedef struct _PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR { + PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR_TYPE Type; + ULONG Flags; + union { + ULONG CounterIndex; + ULONG ExtendedRegisterAddress; + struct { + ULONG Begin; + ULONG End; + } Range; + } u; +} PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR, *PPHYSICAL_COUNTER_RESOURCE_DESCRIPTOR; + +typedef struct _PHYSICAL_COUNTER_RESOURCE_LIST { + ULONG Count; + PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR Descriptors[ANYSIZE_ARRAY]; +} PHYSICAL_COUNTER_RESOURCE_LIST, *PPHYSICAL_COUNTER_RESOURCE_LIST; + +typedef VOID +(NTAPI *PciPin2Line)( + IN struct _BUS_HANDLER *BusHandler, + IN struct _BUS_HANDLER *RootHandler, + IN PCI_SLOT_NUMBER SlotNumber, + IN PPCI_COMMON_CONFIG PciData); + +typedef VOID +(NTAPI *PciLine2Pin)( + IN struct _BUS_HANDLER *BusHandler, + IN struct _BUS_HANDLER *RootHandler, + IN PCI_SLOT_NUMBER SlotNumber, + IN PPCI_COMMON_CONFIG PciNewData, + IN PPCI_COMMON_CONFIG PciOldData); + +typedef VOID +(NTAPI *PciReadWriteConfig)( + IN struct _BUS_HANDLER *BusHandler, + IN PCI_SLOT_NUMBER Slot, + IN PVOID Buffer, + IN ULONG Offset, + IN ULONG Length); + +#define PCI_DATA_TAG ' ICP' +#define PCI_DATA_VERSION 1 + +typedef struct _PCIBUSDATA { + ULONG Tag; + ULONG Version; + PciReadWriteConfig ReadConfig; + PciReadWriteConfig WriteConfig; + PciPin2Line Pin2Line; + PciLine2Pin Line2Pin; + PCI_SLOT_NUMBER ParentSlot; + PVOID Reserved[4]; +} PCIBUSDATA, *PPCIBUSDATA; + +#ifndef _PCIINTRF_X_ +#define _PCIINTRF_X_ + +typedef ULONG +(NTAPI *PCI_READ_WRITE_CONFIG)( + IN PVOID Context, + IN ULONG BusOffset, + IN ULONG Slot, + IN PVOID Buffer, + IN ULONG Offset, + IN ULONG Length); + +typedef VOID +(NTAPI *PCI_PIN_TO_LINE)( + IN PVOID Context, + IN PPCI_COMMON_CONFIG PciData); + +typedef VOID +(NTAPI *PCI_LINE_TO_PIN)( + IN PVOID Context, + IN PPCI_COMMON_CONFIG PciNewData, + IN PPCI_COMMON_CONFIG PciOldData); + +typedef VOID +(NTAPI *PCI_ROOT_BUS_CAPABILITY)( + IN PVOID Context, + OUT PPCI_ROOT_BUS_HARDWARE_CAPABILITY HardwareCapability); + +typedef VOID +(NTAPI *PCI_EXPRESS_WAKE_CONTROL)( + IN PVOID Context, + IN BOOLEAN EnableWake); + +typedef struct _PCI_BUS_INTERFACE_STANDARD { + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; + PCI_READ_WRITE_CONFIG ReadConfig; + PCI_READ_WRITE_CONFIG WriteConfig; + PCI_PIN_TO_LINE PinToLine; + PCI_LINE_TO_PIN LineToPin; + PCI_ROOT_BUS_CAPABILITY RootBusCapability; + PCI_EXPRESS_WAKE_CONTROL ExpressWakeControl; +} PCI_BUS_INTERFACE_STANDARD, *PPCI_BUS_INTERFACE_STANDARD; + +#define PCI_BUS_INTERFACE_STANDARD_VERSION 1 + +#endif /* _PCIINTRF_X_ */ + +#if (NTDDI_VERSION >= NTDDI_WIN7) + +#define FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL_EX 0x00004000 +#define FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL_EX 0x00008000 +#define FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK_EX \ + (FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL_EX | \ + FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL_EX) + +#define FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL_DEPRECATED 0x00000200 +#define FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL_DEPRECATED 0x00000300 +#define FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK_DEPRECATED 0x00000300 + +#else + +#define FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL 0x00000200 +#define FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL 0x00000300 +#define FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK 0x00000300 + +#define FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL_EX FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL +#define FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL_EX FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL +#define FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK_EX FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + +#define FILE_CHARACTERISTICS_PROPAGATED ( FILE_REMOVABLE_MEDIA | \ + FILE_READ_ONLY_DEVICE | \ + FILE_FLOPPY_DISKETTE | \ + FILE_WRITE_ONCE_MEDIA | \ + FILE_DEVICE_SECURE_OPEN ) + +typedef struct _FILE_ALIGNMENT_INFORMATION { + ULONG AlignmentRequirement; +} FILE_ALIGNMENT_INFORMATION, *PFILE_ALIGNMENT_INFORMATION; + +typedef struct _FILE_NAME_INFORMATION { + ULONG FileNameLength; + WCHAR FileName[1]; +} FILE_NAME_INFORMATION, *PFILE_NAME_INFORMATION; + + +typedef struct _FILE_ATTRIBUTE_TAG_INFORMATION { + ULONG FileAttributes; + ULONG ReparseTag; +} FILE_ATTRIBUTE_TAG_INFORMATION, *PFILE_ATTRIBUTE_TAG_INFORMATION; + +typedef struct _FILE_DISPOSITION_INFORMATION { + BOOLEAN DeleteFile; +} FILE_DISPOSITION_INFORMATION, *PFILE_DISPOSITION_INFORMATION; + +typedef struct _FILE_END_OF_FILE_INFORMATION { + LARGE_INTEGER EndOfFile; +} FILE_END_OF_FILE_INFORMATION, *PFILE_END_OF_FILE_INFORMATION; + +typedef struct _FILE_VALID_DATA_LENGTH_INFORMATION { + LARGE_INTEGER ValidDataLength; +} FILE_VALID_DATA_LENGTH_INFORMATION, *PFILE_VALID_DATA_LENGTH_INFORMATION; + +typedef struct _FILE_FS_LABEL_INFORMATION { + ULONG VolumeLabelLength; + WCHAR VolumeLabel[1]; +} FILE_FS_LABEL_INFORMATION, *PFILE_FS_LABEL_INFORMATION; + +typedef struct _FILE_FS_VOLUME_INFORMATION { + LARGE_INTEGER VolumeCreationTime; + ULONG VolumeSerialNumber; + ULONG VolumeLabelLength; + BOOLEAN SupportsObjects; + WCHAR VolumeLabel[1]; +} FILE_FS_VOLUME_INFORMATION, *PFILE_FS_VOLUME_INFORMATION; + +typedef struct _FILE_FS_SIZE_INFORMATION { + LARGE_INTEGER TotalAllocationUnits; + LARGE_INTEGER AvailableAllocationUnits; + ULONG SectorsPerAllocationUnit; + ULONG BytesPerSector; +} FILE_FS_SIZE_INFORMATION, *PFILE_FS_SIZE_INFORMATION; + +typedef struct _FILE_FS_FULL_SIZE_INFORMATION { + LARGE_INTEGER TotalAllocationUnits; + LARGE_INTEGER CallerAvailableAllocationUnits; + LARGE_INTEGER ActualAvailableAllocationUnits; + ULONG SectorsPerAllocationUnit; + ULONG BytesPerSector; +} FILE_FS_FULL_SIZE_INFORMATION, *PFILE_FS_FULL_SIZE_INFORMATION; + +typedef struct _FILE_FS_OBJECTID_INFORMATION { + UCHAR ObjectId[16]; + UCHAR ExtendedInfo[48]; +} FILE_FS_OBJECTID_INFORMATION, *PFILE_FS_OBJECTID_INFORMATION; + +typedef union _FILE_SEGMENT_ELEMENT { + PVOID64 Buffer; + ULONGLONG Alignment; +}FILE_SEGMENT_ELEMENT, *PFILE_SEGMENT_ELEMENT; + +#define IOCTL_AVIO_ALLOCATE_STREAM CTL_CODE(FILE_DEVICE_AVIO, 1, METHOD_BUFFERED, FILE_SPECIAL_ACCESS) +#define IOCTL_AVIO_FREE_STREAM CTL_CODE(FILE_DEVICE_AVIO, 2, METHOD_BUFFERED, FILE_SPECIAL_ACCESS) +#define IOCTL_AVIO_MODIFY_STREAM CTL_CODE(FILE_DEVICE_AVIO, 3, METHOD_BUFFERED, FILE_SPECIAL_ACCESS) + +typedef enum _BUS_DATA_TYPE { + ConfigurationSpaceUndefined = -1, + Cmos, + EisaConfiguration, + Pos, + CbusConfiguration, + PCIConfiguration, + VMEConfiguration, + NuBusConfiguration, + PCMCIAConfiguration, + MPIConfiguration, + MPSAConfiguration, + PNPISAConfiguration, + SgiInternalConfiguration, + MaximumBusDataType +} BUS_DATA_TYPE, *PBUS_DATA_TYPE; +$endif + diff --git a/reactos/include/xdk/kdfuncs.h b/reactos/include/xdk/kdfuncs.h new file mode 100644 index 00000000000..1817849b425 --- /dev/null +++ b/reactos/include/xdk/kdfuncs.h @@ -0,0 +1,192 @@ +/****************************************************************************** + * Kernel Debugger Functions * + ******************************************************************************/ +$if (_NTDDK_) +NTSYSAPI +ULONG +NTAPI +DbgPrompt( + IN PCCH Prompt, + OUT PCH Response, + IN ULONG MaximumResponseLength); +$endif + +$if (_WDMDDK_) +#ifndef _DBGNT_ + +ULONG +__cdecl +DbgPrint( + IN PCSTR Format, + IN ...); + +#if (NTDDI_VERSION >= NTDDI_WIN2K) +NTSYSAPI +ULONG +__cdecl +DbgPrintReturnControlC( + IN PCCH Format, + IN ...); +#endif + +#if (NTDDI_VERSION >= NTDDI_WINXP) + +NTSYSAPI +ULONG +__cdecl +DbgPrintEx( + IN ULONG ComponentId, + IN ULONG Level, + IN PCSTR Format, + IN ...); + +#ifdef _VA_LIST_DEFINED + +NTSYSAPI +ULONG +NTAPI +vDbgPrintEx( + IN ULONG ComponentId, + IN ULONG Level, + IN PCCH Format, + IN va_list ap); + +NTSYSAPI +ULONG +NTAPI +vDbgPrintExWithPrefix( + IN PCCH Prefix, + IN ULONG ComponentId, + IN ULONG Level, + IN PCCH Format, + IN va_list ap); + +#endif /* _VA_LIST_DEFINED */ + +NTSYSAPI +NTSTATUS +NTAPI +DbgQueryDebugFilterState( + IN ULONG ComponentId, + IN ULONG Level); + +NTSYSAPI +NTSTATUS +NTAPI +DbgSetDebugFilterState( + IN ULONG ComponentId, + IN ULONG Level, + IN BOOLEAN State); + +#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ + +#if (NTDDI_VERSION >= NTDDI_VISTA) + +typedef VOID +(*PDEBUG_PRINT_CALLBACK)( + IN PSTRING Output, + IN ULONG ComponentId, + IN ULONG Level); + +NTSYSAPI +NTSTATUS +NTAPI +DbgSetDebugPrintCallback( + IN PDEBUG_PRINT_CALLBACK DebugPrintCallback, + IN BOOLEAN Enable); + +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + +#endif /* _DBGNT_ */ + +#if DBG + +#define KdPrint(_x_) DbgPrint _x_ +#define KdPrintEx(_x_) DbgPrintEx _x_ +#define vKdPrintEx(_x_) vDbgPrintEx _x_ +#define vKdPrintExWithPrefix(_x_) vDbgPrintExWithPrefix _x_ +#define KdBreakPoint() DbgBreakPoint() +#define KdBreakPointWithStatus(s) DbgBreakPointWithStatus(s) + +#else /* !DBG */ + +#define KdPrint(_x_) +#define KdPrintEx(_x_) +#define vKdPrintEx(_x_) +#define vKdPrintExWithPrefix(_x_) +#define KdBreakPoint() +#define KdBreakPointWithStatus(s) + +#endif /* !DBG */ + +#if defined(__GNUC__) + +extern NTKERNELAPI BOOLEAN KdDebuggerNotPresent; +extern NTKERNELAPI BOOLEAN KdDebuggerEnabled; +#define KD_DEBUGGER_ENABLED KdDebuggerEnabled +#define KD_DEBUGGER_NOT_PRESENT KdDebuggerNotPresent + +#elif defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_) || defined(_WDMDDK_) || defined(_NTOSP_) + +extern NTKERNELAPI PBOOLEAN KdDebuggerNotPresent; +extern NTKERNELAPI PBOOLEAN KdDebuggerEnabled; +#define KD_DEBUGGER_ENABLED *KdDebuggerEnabled +#define KD_DEBUGGER_NOT_PRESENT *KdDebuggerNotPresent + +#else + +extern BOOLEAN KdDebuggerNotPresent; +extern BOOLEAN KdDebuggerEnabled; +#define KD_DEBUGGER_ENABLED KdDebuggerEnabled +#define KD_DEBUGGER_NOT_PRESENT KdDebuggerNotPresent + +#endif + +#if (NTDDI_VERSION >= NTDDI_WIN2K) + +NTKERNELAPI +NTSTATUS +NTAPI +KdDisableDebugger(VOID); + +NTKERNELAPI +NTSTATUS +NTAPI +KdEnableDebugger(VOID); + +#if (_MSC_FULL_VER >= 150030729) && !defined(IMPORT_NATIVE_DBG_BREAK) +#define DbgBreakPoint __debugbreak +#else +VOID +NTAPI +DbgBreakPoint(VOID); +#endif + +NTSYSAPI +VOID +NTAPI +DbgBreakPointWithStatus( + IN ULONG Status); + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ + +#if (NTDDI_VERSION >= NTDDI_WS03) +NTKERNELAPI +BOOLEAN +NTAPI +KdRefreshDebuggerNotPresent(VOID); +#endif + +#if (NTDDI_VERSION >= NTDDI_WS03SP1) +NTKERNELAPI +NTSTATUS +NTAPI +KdChangeOption( + IN KD_OPTION Option, + IN ULONG InBufferBytes OPTIONAL, + IN PVOID InBuffer, + IN ULONG OutBufferBytes OPTIONAL, + OUT PVOID OutBuffer, + OUT PULONG OutBufferNeeded OPTIONAL); +#endif +$endif diff --git a/reactos/include/xdk/kdtypes.h b/reactos/include/xdk/kdtypes.h new file mode 100644 index 00000000000..b030a2349f0 --- /dev/null +++ b/reactos/include/xdk/kdtypes.h @@ -0,0 +1,94 @@ +/****************************************************************************** + * Kernel Debugger Types * + ******************************************************************************/ +$if (_NTDDK_) +typedef struct _DEBUG_DEVICE_ADDRESS { + UCHAR Type; + BOOLEAN Valid; + UCHAR Reserved[2]; + PUCHAR TranslatedAddress; + ULONG Length; +} DEBUG_DEVICE_ADDRESS, *PDEBUG_DEVICE_ADDRESS; + +typedef struct _DEBUG_MEMORY_REQUIREMENTS { + PHYSICAL_ADDRESS Start; + PHYSICAL_ADDRESS MaxEnd; + PVOID VirtualAddress; + ULONG Length; + BOOLEAN Cached; + BOOLEAN Aligned; +} DEBUG_MEMORY_REQUIREMENTS, *PDEBUG_MEMORY_REQUIREMENTS; + +typedef struct _DEBUG_DEVICE_DESCRIPTOR { + ULONG Bus; + ULONG Slot; + USHORT Segment; + USHORT VendorID; + USHORT DeviceID; + UCHAR BaseClass; + UCHAR SubClass; + UCHAR ProgIf; + BOOLEAN Initialized; + BOOLEAN Configured; + DEBUG_DEVICE_ADDRESS BaseAddress[6]; + DEBUG_MEMORY_REQUIREMENTS Memory; +} DEBUG_DEVICE_DESCRIPTOR, *PDEBUG_DEVICE_DESCRIPTOR; + +typedef NTSTATUS +(NTAPI *pKdSetupPciDeviceForDebugging)( + IN PVOID LoaderBlock OPTIONAL, + IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice); + +typedef NTSTATUS +(NTAPI *pKdReleasePciDeviceForDebugging)( + IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice); + +typedef PVOID +(NTAPI *pKdGetAcpiTablePhase0)( + IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock, + IN ULONG Signature); + +typedef VOID +(NTAPI *pKdCheckPowerButton)( + VOID); + +#if (NTDDI_VERSION >= NTDDI_VISTA) +typedef PVOID +(NTAPI *pKdMapPhysicalMemory64)( + IN PHYSICAL_ADDRESS PhysicalAddress, + IN ULONG NumberPages, + IN BOOLEAN FlushCurrentTLB); + +typedef VOID +(NTAPI *pKdUnmapVirtualAddress)( + IN PVOID VirtualAddress, + IN ULONG NumberPages, + IN BOOLEAN FlushCurrentTLB); +#else +typedef PVOID +(NTAPI *pKdMapPhysicalMemory64)( + IN PHYSICAL_ADDRESS PhysicalAddress, + IN ULONG NumberPages); + +typedef VOID +(NTAPI *pKdUnmapVirtualAddress)( + IN PVOID VirtualAddress, + IN ULONG NumberPages); +#endif + +typedef ULONG +(NTAPI *pKdGetPciDataByOffset)( + IN ULONG BusNumber, + IN ULONG SlotNumber, + OUT PVOID Buffer, + IN ULONG Offset, + IN ULONG Length); + +typedef ULONG +(NTAPI *pKdSetPciDataByOffset)( + IN ULONG BusNumber, + IN ULONG SlotNumber, + IN PVOID Buffer, + IN ULONG Offset, + IN ULONG Length); +$endif diff --git a/reactos/include/xdk/kefuncs.h b/reactos/include/xdk/kefuncs.h new file mode 100644 index 00000000000..716ee872db8 --- /dev/null +++ b/reactos/include/xdk/kefuncs.h @@ -0,0 +1,1075 @@ +/****************************************************************************** + * Kernel Functions * + ******************************************************************************/ +$if (_NTDDK_) +NTKERNELAPI +VOID +FASTCALL +KeInvalidateRangeAllCaches( + IN PVOID BaseAddress, + IN ULONG Length); +$endif + +$if (_WDMDDK_) +NTKERNELAPI +VOID +NTAPI +KeInitializeEvent( + OUT PRKEVENT Event, + IN EVENT_TYPE Type, + IN BOOLEAN State); + +NTKERNELAPI +VOID +NTAPI +KeClearEvent( + IN OUT PRKEVENT Event); +$endif + +#if (NTDDI_VERSION >= NTDDI_WIN2K) + +$if (_NTDDK_) +NTKERNELAPI +VOID +NTAPI +KeSetImportanceDpc( + IN OUT PRKDPC Dpc, + IN KDPC_IMPORTANCE Importance); + +NTKERNELAPI +LONG +NTAPI +KePulseEvent( + IN OUT PRKEVENT Event, + IN KPRIORITY Increment, + IN BOOLEAN Wait); + +NTKERNELAPI +LONG +NTAPI +KeSetBasePriorityThread( + IN OUT PRKTHREAD Thread, + IN LONG Increment); + +NTKERNELAPI +VOID +NTAPI +KeEnterCriticalRegion(VOID); + +NTKERNELAPI +VOID +NTAPI +KeLeaveCriticalRegion(VOID); + +NTKERNELAPI +DECLSPEC_NORETURN +VOID +NTAPI +KeBugCheck( + IN ULONG BugCheckCode); +$endif /* _NTDDK_ */ + +$if (_WDMDDK_) +#if defined(_NTDDK_) || defined(_NTIFS_) +NTKERNELAPI +VOID +NTAPI +ProbeForRead( + IN CONST VOID *Address, /* CONST is added */ + IN SIZE_T Length, + IN ULONG Alignment); +#endif /* defined(_NTDDK_) || defined(_NTIFS_) */ + +NTKERNELAPI +VOID +NTAPI +ProbeForWrite( + IN PVOID Address, + IN SIZE_T Length, + IN ULONG Alignment); + +$endif /* _WDMDDK_ */ + +#if defined(SINGLE_GROUP_LEGACY_API) + +$if (_WDMDDK_) +NTKERNELAPI +VOID +NTAPI +KeRevertToUserAffinityThread(VOID); + +NTKERNELAPI +VOID +NTAPI +KeSetSystemAffinityThread( + IN KAFFINITY Affinity); + +NTKERNELAPI +VOID +NTAPI +KeSetTargetProcessorDpc( + IN OUT PRKDPC Dpc, + IN CCHAR Number); + +NTKERNELAPI +KAFFINITY +NTAPI +KeQueryActiveProcessors(VOID); +$endif + +$if (_NTDDK_) +NTKERNELAPI +VOID +NTAPI +KeSetTargetProcessorDpc( + IN OUT PRKDPC Dpc, + IN CCHAR Number); + +NTKERNELAPI +KAFFINITY +NTAPI +KeQueryActiveProcessors(VOID); +$endif + +#endif /* defined(SINGLE_GROUP_LEGACY_API) */ + +$if (_WDMDDK_) +#if !defined(_M_AMD64) +NTKERNELAPI +ULONGLONG +NTAPI +KeQueryInterruptTime(VOID); + +NTKERNELAPI +VOID +NTAPI +KeQuerySystemTime( + OUT PLARGE_INTEGER CurrentTime); +#endif /* !_M_AMD64 */ + +#if !defined(_X86_) +NTKERNELAPI +KIRQL +NTAPI +KeAcquireSpinLockRaiseToDpc( + IN OUT PKSPIN_LOCK SpinLock); + +#define KeAcquireSpinLock(SpinLock, OldIrql) \ + *(OldIrql) = KeAcquireSpinLockRaiseToDpc(SpinLock) + +NTKERNELAPI +VOID +NTAPI +KeAcquireSpinLockAtDpcLevel( + IN OUT PKSPIN_LOCK SpinLock); + +NTKERNELAPI +VOID +NTAPI +KeReleaseSpinLock( + IN OUT PKSPIN_LOCK SpinLock, + IN KIRQL NewIrql); + +NTKERNELAPI +VOID +NTAPI +KeReleaseSpinLockFromDpcLevel( + IN OUT PKSPIN_LOCK SpinLock); +#endif /* !_X86_ */ + +#if defined(_X86_) && (defined(_WDM_INCLUDED_) || defined(WIN9X_COMPAT_SPINLOCK)) +NTKERNELAPI +VOID +NTAPI +KeInitializeSpinLock( + IN PKSPIN_LOCK SpinLock); +#else +FORCEINLINE +VOID +KeInitializeSpinLock(IN PKSPIN_LOCK SpinLock) +{ + /* Clear the lock */ + *SpinLock = 0; +} +#endif + +NTKERNELAPI +DECLSPEC_NORETURN +VOID +NTAPI +KeBugCheckEx( + IN ULONG BugCheckCode, + IN ULONG_PTR BugCheckParameter1, + IN ULONG_PTR BugCheckParameter2, + IN ULONG_PTR BugCheckParameter3, + IN ULONG_PTR BugCheckParameter4); + +NTKERNELAPI +BOOLEAN +NTAPI +KeCancelTimer( + IN OUT PKTIMER); + +NTKERNELAPI +NTSTATUS +NTAPI +KeDelayExecutionThread( + IN KPROCESSOR_MODE WaitMode, + IN BOOLEAN Alertable, + IN PLARGE_INTEGER Interval); + +NTKERNELAPI +BOOLEAN +NTAPI +KeDeregisterBugCheckCallback( + IN OUT PKBUGCHECK_CALLBACK_RECORD CallbackRecord); + +NTKERNELAPI +VOID +NTAPI +KeEnterCriticalRegion(VOID); + +NTKERNELAPI +VOID +NTAPI +KeInitializeDeviceQueue( + OUT PKDEVICE_QUEUE DeviceQueue); + +NTKERNELAPI +VOID +NTAPI +KeInitializeDpc( + OUT PRKDPC Dpc, + IN PKDEFERRED_ROUTINE DeferredRoutine, + IN PVOID DeferredContext OPTIONAL); + +NTKERNELAPI +VOID +NTAPI +KeInitializeMutex( + OUT PRKMUTEX Mutex, + IN ULONG Level); + +NTKERNELAPI +VOID +NTAPI +KeInitializeSemaphore( + OUT PRKSEMAPHORE Semaphore, + IN LONG Count, + IN LONG Limit); + +NTKERNELAPI +VOID +NTAPI +KeInitializeTimer( + OUT PKTIMER Timer); + +NTKERNELAPI +VOID +NTAPI +KeInitializeTimerEx( + OUT PKTIMER Timer, + IN TIMER_TYPE Type); + +NTKERNELAPI +BOOLEAN +NTAPI +KeInsertByKeyDeviceQueue( + IN OUT PKDEVICE_QUEUE DeviceQueue, + IN OUT PKDEVICE_QUEUE_ENTRY DeviceQueueEntry, + IN ULONG SortKey); + +NTKERNELAPI +BOOLEAN +NTAPI +KeInsertDeviceQueue( + IN OUT PKDEVICE_QUEUE DeviceQueue, + IN OUT PKDEVICE_QUEUE_ENTRY DeviceQueueEntry); + +NTKERNELAPI +BOOLEAN +NTAPI +KeInsertQueueDpc( + IN OUT PRKDPC Dpc, + IN PVOID SystemArgument1 OPTIONAL, + IN PVOID SystemArgument2 OPTIONAL); + +NTKERNELAPI +VOID +NTAPI +KeLeaveCriticalRegion(VOID); + +NTHALAPI +LARGE_INTEGER +NTAPI +KeQueryPerformanceCounter( + OUT PLARGE_INTEGER PerformanceFrequency OPTIONAL); + +NTKERNELAPI +KPRIORITY +NTAPI +KeQueryPriorityThread( + IN PRKTHREAD Thread); + +NTKERNELAPI +ULONG +NTAPI +KeQueryTimeIncrement(VOID); + +NTKERNELAPI +LONG +NTAPI +KeReadStateEvent( + IN PRKEVENT Event); + +NTKERNELAPI +LONG +NTAPI +KeReadStateMutex( + IN PRKMUTEX Mutex); + +NTKERNELAPI +LONG +NTAPI +KeReadStateSemaphore( + IN PRKSEMAPHORE Semaphore); + +NTKERNELAPI +BOOLEAN +NTAPI +KeReadStateTimer( + IN PKTIMER Timer); + +NTKERNELAPI +BOOLEAN +NTAPI +KeRegisterBugCheckCallback( + OUT PKBUGCHECK_CALLBACK_RECORD CallbackRecord, + IN PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine, + IN PVOID Buffer, + IN ULONG Length, + IN PUCHAR Component); + +NTKERNELAPI +LONG +NTAPI +KeReleaseMutex( + IN OUT PRKMUTEX Mutex, + IN BOOLEAN Wait); + +NTKERNELAPI +LONG +NTAPI +KeReleaseSemaphore( + IN OUT PRKSEMAPHORE Semaphore, + IN KPRIORITY Increment, + IN LONG Adjustment, + IN BOOLEAN Wait); + +NTKERNELAPI +PKDEVICE_QUEUE_ENTRY +NTAPI +KeRemoveByKeyDeviceQueue( + IN OUT PKDEVICE_QUEUE DeviceQueue, + IN ULONG SortKey); + +NTKERNELAPI +PKDEVICE_QUEUE_ENTRY +NTAPI +KeRemoveDeviceQueue( + IN OUT PKDEVICE_QUEUE DeviceQueue); + +NTKERNELAPI +BOOLEAN +NTAPI +KeRemoveEntryDeviceQueue( + IN OUT PKDEVICE_QUEUE DeviceQueue, + IN OUT PKDEVICE_QUEUE_ENTRY DeviceQueueEntry); + +NTKERNELAPI +BOOLEAN +NTAPI +KeRemoveQueueDpc( + IN OUT PRKDPC Dpc); + +NTKERNELAPI +LONG +NTAPI +KeResetEvent( + IN OUT PRKEVENT Event); + +NTKERNELAPI +LONG +NTAPI +KeSetEvent( + IN OUT PRKEVENT Event, + IN KPRIORITY Increment, + IN BOOLEAN Wait); + +NTKERNELAPI +VOID +NTAPI +KeSetImportanceDpc( + IN OUT PRKDPC Dpc, + IN KDPC_IMPORTANCE Importance); + +NTKERNELAPI +KPRIORITY +NTAPI +KeSetPriorityThread( + IN OUT PKTHREAD Thread, + IN KPRIORITY Priority); + +NTKERNELAPI +BOOLEAN +NTAPI +KeSetTimer( + IN OUT PKTIMER Timer, + IN LARGE_INTEGER DueTime, + IN PKDPC Dpc OPTIONAL); + +NTKERNELAPI +BOOLEAN +NTAPI +KeSetTimerEx( + IN OUT PKTIMER Timer, + IN LARGE_INTEGER DueTime, + IN LONG Period OPTIONAL, + IN PKDPC Dpc OPTIONAL); + +NTHALAPI +VOID +NTAPI +KeStallExecutionProcessor( + IN ULONG MicroSeconds); + +NTKERNELAPI +BOOLEAN +NTAPI +KeSynchronizeExecution( + IN OUT PKINTERRUPT Interrupt, + IN PKSYNCHRONIZE_ROUTINE SynchronizeRoutine, + IN PVOID SynchronizeContext OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +KeWaitForMultipleObjects( + IN ULONG Count, + IN PVOID Object[], + IN WAIT_TYPE WaitType, + IN KWAIT_REASON WaitReason, + IN KPROCESSOR_MODE WaitMode, + IN BOOLEAN Alertable, + IN PLARGE_INTEGER Timeout OPTIONAL, + OUT PKWAIT_BLOCK WaitBlockArray OPTIONAL); + +#define KeWaitForMutexObject KeWaitForSingleObject + +NTKERNELAPI +NTSTATUS +NTAPI +KeWaitForSingleObject( + IN PVOID Object, + IN KWAIT_REASON WaitReason, + IN KPROCESSOR_MODE WaitMode, + IN BOOLEAN Alertable, + IN PLARGE_INTEGER Timeout OPTIONAL); +$endif + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ + +#if (NTDDI_VERSION >= NTDDI_WINXP) +$if (_NTDDK_) +NTKERNELAPI +BOOLEAN +NTAPI +KeAreApcsDisabled(VOID); +$endif + +$if (_WDMDDK_) +_DECL_HAL_KE_IMPORT +VOID +FASTCALL +KeAcquireInStackQueuedSpinLock( + IN OUT PKSPIN_LOCK SpinLock, + OUT PKLOCK_QUEUE_HANDLE LockHandle); + +NTKERNELAPI +VOID +FASTCALL +KeAcquireInStackQueuedSpinLockAtDpcLevel( + IN OUT PKSPIN_LOCK SpinLock, + OUT PKLOCK_QUEUE_HANDLE LockHandle); + +NTKERNELAPI +KIRQL +NTAPI +KeAcquireInterruptSpinLock( + IN OUT PKINTERRUPT Interrupt); + +NTKERNELAPI +BOOLEAN +NTAPI +KeAreApcsDisabled(VOID); + +NTKERNELAPI +ULONG +NTAPI +KeGetRecommendedSharedDataAlignment(VOID); + +NTKERNELAPI +ULONG +NTAPI +KeQueryRuntimeThread( + IN PKTHREAD Thread, + OUT PULONG UserTime); + +NTKERNELAPI +VOID +FASTCALL +KeReleaseInStackQueuedSpinLockFromDpcLevel( + IN PKLOCK_QUEUE_HANDLE LockHandle); + +NTKERNELAPI +VOID +NTAPI +KeReleaseInterruptSpinLock( + IN OUT PKINTERRUPT Interrupt, + IN KIRQL OldIrql); + +NTKERNELAPI +PKDEVICE_QUEUE_ENTRY +NTAPI +KeRemoveByKeyDeviceQueueIfBusy( + IN OUT PKDEVICE_QUEUE DeviceQueue, + IN ULONG SortKey); + +_DECL_HAL_KE_IMPORT +VOID +FASTCALL +KeReleaseInStackQueuedSpinLock( + IN PKLOCK_QUEUE_HANDLE LockHandle); +$endif + +#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ + +$if (_WDMDDK_) +#if (NTDDI_VERSION >= NTDDI_WINXPSP1) + +NTKERNELAPI +BOOLEAN +NTAPI +KeDeregisterBugCheckReasonCallback( + IN OUT PKBUGCHECK_REASON_CALLBACK_RECORD CallbackRecord); + +NTKERNELAPI +BOOLEAN +NTAPI +KeRegisterBugCheckReasonCallback( + OUT PKBUGCHECK_REASON_CALLBACK_RECORD CallbackRecord, + IN PKBUGCHECK_REASON_CALLBACK_ROUTINE CallbackRoutine, + IN KBUGCHECK_CALLBACK_REASON Reason, + IN PUCHAR Component); + +#endif /* (NTDDI_VERSION >= NTDDI_WINXPSP1) */ + +#if (NTDDI_VERSION >= NTDDI_WINXPSP2) +NTKERNELAPI +VOID +NTAPI +KeFlushQueuedDpcs(VOID); +#endif /* (NTDDI_VERSION >= NTDDI_WINXPSP2) */ +$endif /* _WDMDDK_ */ + +#if (NTDDI_VERSION >= NTDDI_WS03) + +$if (_WDMDDK_) +NTKERNELAPI +PVOID +NTAPI +KeRegisterNmiCallback( + IN PNMI_CALLBACK CallbackRoutine, + IN PVOID Context OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +KeDeregisterNmiCallback( + IN PVOID Handle); + +NTKERNELAPI +VOID +NTAPI +KeInitializeThreadedDpc( + OUT PRKDPC Dpc, + IN PKDEFERRED_ROUTINE DeferredRoutine, + IN PVOID DeferredContext OPTIONAL); + +NTKERNELAPI +ULONG_PTR +NTAPI +KeIpiGenericCall( + IN PKIPI_BROADCAST_WORKER BroadcastFunction, + IN ULONG_PTR Context); + +NTKERNELAPI +KIRQL +FASTCALL +KeAcquireSpinLockForDpc( + IN OUT PKSPIN_LOCK SpinLock); + +NTKERNELAPI +VOID +FASTCALL +KeReleaseSpinLockForDpc( + IN OUT PKSPIN_LOCK SpinLock, + IN KIRQL OldIrql); + +NTKERNELAPI +BOOLEAN +FASTCALL +KeTestSpinLock( + IN PKSPIN_LOCK SpinLock); +$endif /* _WDMDDK_ */ + +$if (_NTDDK_) +NTKERNELAPI +BOOLEAN +NTAPI +KeInvalidateAllCaches(VOID); +$endif /* _NTDDK_ */ + +#endif /* (NTDDI_VERSION >= NTDDI_WS03) */ + +#if (NTDDI_VERSION >= NTDDI_WS03SP1) + +$if (_NTDDK_) +NTKERNELAPI +NTSTATUS +NTAPI +KeExpandKernelStackAndCallout( + IN PEXPAND_STACK_CALLOUT Callout, + IN PVOID Parameter OPTIONAL, + IN SIZE_T Size); + +NTKERNELAPI +VOID +NTAPI +KeEnterGuardedRegion(VOID); + +NTKERNELAPI +VOID +NTAPI +KeLeaveGuardedRegion(VOID); +$endif /* _NTDDK_ */ + +$if (_WDMDDK_) +NTKERNELAPI +BOOLEAN +FASTCALL +KeTryToAcquireSpinLockAtDpcLevel( + IN OUT PKSPIN_LOCK SpinLock); + +NTKERNELAPI +BOOLEAN +NTAPI +KeAreAllApcsDisabled(VOID); + +NTKERNELAPI +VOID +FASTCALL +KeAcquireGuardedMutex( + IN OUT PKGUARDED_MUTEX GuardedMutex); + +NTKERNELAPI +VOID +FASTCALL +KeAcquireGuardedMutexUnsafe( + IN OUT PKGUARDED_MUTEX GuardedMutex); + +NTKERNELAPI +VOID +NTAPI +KeEnterGuardedRegion(VOID); + +NTKERNELAPI +VOID +NTAPI +KeLeaveGuardedRegion(VOID); + +NTKERNELAPI +VOID +FASTCALL +KeInitializeGuardedMutex( + OUT PKGUARDED_MUTEX GuardedMutex); + +NTKERNELAPI +VOID +FASTCALL +KeReleaseGuardedMutexUnsafe( + IN OUT PKGUARDED_MUTEX GuardedMutex); + +NTKERNELAPI +VOID +FASTCALL +KeReleaseGuardedMutex( + IN OUT PKGUARDED_MUTEX GuardedMutex); + +NTKERNELAPI +BOOLEAN +FASTCALL +KeTryToAcquireGuardedMutex( + IN OUT PKGUARDED_MUTEX GuardedMutex); +$endif /* _WDMDDK_ */ + +#endif /* (NTDDI_VERSION >= NTDDI_WS03SP1) */ + +#if (NTDDI_VERSION >= NTDDI_VISTA) + +$if (_WDMDDK_) +NTKERNELAPI +VOID +FASTCALL +KeAcquireInStackQueuedSpinLockForDpc( + IN OUT PKSPIN_LOCK SpinLock, + OUT PKLOCK_QUEUE_HANDLE LockHandle); + +NTKERNELAPI +VOID +FASTCALL +KeReleaseInStackQueuedSpinLockForDpc( + IN PKLOCK_QUEUE_HANDLE LockHandle); + +NTKERNELAPI +NTSTATUS +NTAPI +KeQueryDpcWatchdogInformation( + OUT PKDPC_WATCHDOG_INFORMATION WatchdogInformation); +$endif /* _WDMDDK_ */ + +#if defined(SINGLE_GROUP_LEGACY_API) +$if (_NTDDK_) +NTKERNELAPI +ULONG +NTAPI +KeQueryActiveProcessorCount( + OUT PKAFFINITY ActiveProcessors OPTIONAL); + +NTKERNELAPI +ULONG +NTAPI +KeQueryMaximumProcessorCount(VOID); +$endif /* _NTDDK_ */ + +$if (_WDMDDK_) +NTKERNELAPI +KAFFINITY +NTAPI +KeSetSystemAffinityThreadEx( + IN KAFFINITY Affinity); + +NTKERNELAPI +VOID +NTAPI +KeRevertToUserAffinityThreadEx( + IN KAFFINITY Affinity); + +NTKERNELAPI +ULONG +NTAPI +KeQueryActiveProcessorCount( + OUT PKAFFINITY ActiveProcessors OPTIONAL); + +NTKERNELAPI +ULONG +NTAPI +KeQueryMaximumProcessorCount(VOID); +$endif /* _WDMDDK_ */ +#endif /* SINGLE_GROUP_LEGACY_API */ + +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + +$if (_WDMDDK_) +#if (NTDDI_VERSION >= NTDDI_WS08) + +PVOID +KeRegisterProcessorChangeCallback( + IN PPROCESSOR_CALLBACK_FUNCTION CallbackFunction, + IN PVOID CallbackContext OPTIONAL, + IN ULONG Flags); + +VOID +KeDeregisterProcessorChangeCallback( + IN PVOID CallbackHandle); + +#endif /* (NTDDI_VERSION >= NTDDI_WS08) */ +$endif /* _WDMDDK_ */ + +#if (NTDDI_VERSION >= NTDDI_WIN7) + +$if (_NTDDK_) +NTKERNELAPI +ULONG +NTAPI +KeQueryActiveProcessorCountEx( + IN USHORT GroupNumber); + +NTKERNELAPI +ULONG +NTAPI +KeQueryMaximumProcessorCountEx( + IN USHORT GroupNumber); + +NTKERNELAPI +USHORT +NTAPI +KeQueryActiveGroupCount(VOID); + +NTKERNELAPI +USHORT +NTAPI +KeQueryMaximumGroupCount(VOID); + +NTKERNELAPI +KAFFINITY +NTAPI +KeQueryGroupAffinity( + IN USHORT GroupNumber); + +NTKERNELAPI +ULONG +NTAPI +KeGetCurrentProcessorNumberEx( + OUT PPROCESSOR_NUMBER ProcNumber OPTIONAL); + +NTKERNELAPI +VOID +NTAPI +KeQueryNodeActiveAffinity( + IN USHORT NodeNumber, + OUT PGROUP_AFFINITY Affinity OPTIONAL, + OUT PUSHORT Count OPTIONAL); + +NTKERNELAPI +USHORT +NTAPI +KeQueryNodeMaximumProcessorCount( + IN USHORT NodeNumber); + +NTKERNELAPI +USHORT +NTAPI +KeQueryHighestNodeNumber(VOID); + +NTKERNELAPI +USHORT +NTAPI +KeGetCurrentNodeNumber(VOID); + +NTKERNELAPI +NTSTATUS +NTAPI +KeQueryLogicalProcessorRelationship( + IN PPROCESSOR_NUMBER ProcessorNumber OPTIONAL, + IN LOGICAL_PROCESSOR_RELATIONSHIP RelationshipType, + OUT PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX Information OPTIONAL, + IN OUT PULONG Length); + +NTKERNELAPI +NTSTATUS +NTAPI +KeSetHardwareCounterConfiguration( + IN PHARDWARE_COUNTER CounterArray, + IN ULONG Count); + +NTKERNELAPI +NTSTATUS +NTAPI +KeQueryHardwareCounterConfiguration( + OUT PHARDWARE_COUNTER CounterArray, + IN ULONG MaximumCount, + OUT PULONG Count); +$endif /* _NTDDK_ */ + +$if (_WDMDDK_) +ULONG64 +NTAPI +KeQueryTotalCycleTimeProcess( + IN OUT PKPROCESS Process, + OUT PULONG64 CycleTimeStamp); + +ULONG64 +NTAPI +KeQueryTotalCycleTimeThread( + IN OUT PKTHREAD Thread, + OUT PULONG64 CycleTimeStamp); + +NTKERNELAPI +NTSTATUS +NTAPI +KeSetTargetProcessorDpcEx( + IN OUT PKDPC Dpc, + IN PPROCESSOR_NUMBER ProcNumber); + +NTKERNELAPI +VOID +NTAPI +KeSetSystemGroupAffinityThread( + IN PGROUP_AFFINITY Affinity, + OUT PGROUP_AFFINITY PreviousAffinity OPTIONAL); + +NTKERNELAPI +VOID +NTAPI +KeRevertToUserGroupAffinityThread( + IN PGROUP_AFFINITY PreviousAffinity); + +NTKERNELAPI +BOOLEAN +NTAPI +KeSetCoalescableTimer( + IN OUT PKTIMER Timer, + IN LARGE_INTEGER DueTime, + IN ULONG Period, + IN ULONG TolerableDelay, + IN PKDPC Dpc OPTIONAL); + +NTKERNELAPI +ULONGLONG +NTAPI +KeQueryUnbiasedInterruptTime(VOID); + +NTKERNELAPI +ULONG +NTAPI +KeQueryActiveProcessorCountEx( + IN USHORT GroupNumber); + +NTKERNELAPI +ULONG +NTAPI +KeQueryMaximumProcessorCountEx( + IN USHORT GroupNumber); + +NTKERNELAPI +USHORT +NTAPI +KeQueryActiveGroupCount(VOID); + +NTKERNELAPI +USHORT +NTAPI +KeQueryMaximumGroupCount(VOID); + +NTKERNELAPI +KAFFINITY +NTAPI +KeQueryGroupAffinity( + IN USHORT GroupNumber); + +NTKERNELAPI +ULONG +NTAPI +KeGetCurrentProcessorNumberEx( + OUT PPROCESSOR_NUMBER ProcNumber OPTIONAL); + +NTKERNELAPI +VOID +NTAPI +KeQueryNodeActiveAffinity( + IN USHORT NodeNumber, + OUT PGROUP_AFFINITY Affinity OPTIONAL, + OUT PUSHORT Count OPTIONAL); + +NTKERNELAPI +USHORT +NTAPI +KeQueryNodeMaximumProcessorCount( + IN USHORT NodeNumber); + +NTKERNELAPI +USHORT +NTAPI +KeQueryHighestNodeNumber(VOID); + +NTKERNELAPI +USHORT +NTAPI +KeGetCurrentNodeNumber(VOID); + +NTKERNELAPI +NTSTATUS +NTAPI +KeQueryLogicalProcessorRelationship( + IN PPROCESSOR_NUMBER ProcessorNumber OPTIONAL, + IN LOGICAL_PROCESSOR_RELATIONSHIP RelationshipType, + OUT PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX Information OPTIONAL, + IN OUT PULONG Length); + +NTKERNELAPI +NTSTATUS +NTAPI +KeSaveExtendedProcessorState( + IN ULONG64 Mask, + OUT PXSTATE_SAVE XStateSave); + +NTKERNELAPI +VOID +NTAPI +KeRestoreExtendedProcessorState( + IN PXSTATE_SAVE XStateSave); + +NTSTATUS +NTAPI +KeGetProcessorNumberFromIndex( + IN ULONG ProcIndex, + OUT PPROCESSOR_NUMBER ProcNumber); + +ULONG +NTAPI +KeGetProcessorIndexFromNumber( + IN PPROCESSOR_NUMBER ProcNumber); +$endif + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + +$if (_WDMDDK_) +#if !defined(_IA64_) +NTHALAPI +VOID +NTAPI +KeFlushWriteBuffer(VOID); +#endif + +/* VOID + * KeInitializeCallbackRecord( + * IN PKBUGCHECK_CALLBACK_RECORD CallbackRecord) + */ +#define KeInitializeCallbackRecord(CallbackRecord) \ + CallbackRecord->State = BufferEmpty; + +#if DBG + +#if (NTDDI_VERSION >= NTDDI_VISTA) +#define PAGED_ASSERT( exp ) NT_ASSERT( exp ) +#else +#define PAGED_ASSERT( exp ) ASSERT( exp ) +#endif + +#define PAGED_CODE() { \ + if (KeGetCurrentIrql() > APC_LEVEL) { \ + KdPrint( ("NTDDK: Pageable code called at IRQL > APC_LEVEL (%d)\n", KeGetCurrentIrql() )); \ + PAGED_ASSERT(FALSE); \ + } \ +} + +#else + +#define PAGED_CODE() + +#endif /* DBG */ + +#define PAGED_CODE_LOCKED() NOP_FUNCTION; +$endif + diff --git a/reactos/include/xdk/ketypes.h b/reactos/include/xdk/ketypes.h new file mode 100644 index 00000000000..a4bb36303a2 --- /dev/null +++ b/reactos/include/xdk/ketypes.h @@ -0,0 +1,1183 @@ +/****************************************************************************** + * Kernel Types * + ******************************************************************************/ +$if (_WDMDDK_) + +typedef UCHAR KIRQL, *PKIRQL; +typedef CCHAR KPROCESSOR_MODE; +typedef LONG KPRIORITY; + +typedef enum _MODE { + KernelMode, + UserMode, + MaximumMode +} MODE; + +#define CACHE_FULLY_ASSOCIATIVE 0xFF +#define MAXIMUM_SUSPEND_COUNT MAXCHAR + +#define EVENT_QUERY_STATE (0x0001) +#define EVENT_MODIFY_STATE (0x0002) +#define EVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3) + +#define LTP_PC_SMT 0x1 + +#if (NTDDI_VERSION < NTDDI_WIN7) || defined(_X86_) || !defined(NT_PROCESSOR_GROUPS) +#define SINGLE_GROUP_LEGACY_API 1 +#endif + +#define SEMAPHORE_QUERY_STATE (0x0001) +#define SEMAPHORE_MODIFY_STATE (0x0002) +#define SEMAPHORE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3) + +typedef enum _LOGICAL_PROCESSOR_RELATIONSHIP { + RelationProcessorCore, + RelationNumaNode, + RelationCache, + RelationProcessorPackage, + RelationGroup, + RelationAll = 0xffff +} LOGICAL_PROCESSOR_RELATIONSHIP; + +typedef enum _PROCESSOR_CACHE_TYPE { + CacheUnified, + CacheInstruction, + CacheData, + CacheTrace +} PROCESSOR_CACHE_TYPE; + +typedef struct _CACHE_DESCRIPTOR { + UCHAR Level; + UCHAR Associativity; + USHORT LineSize; + ULONG Size; + PROCESSOR_CACHE_TYPE Type; +} CACHE_DESCRIPTOR, *PCACHE_DESCRIPTOR; + +typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION { + ULONG_PTR ProcessorMask; + LOGICAL_PROCESSOR_RELATIONSHIP Relationship; + union { + struct { + UCHAR Flags; + } ProcessorCore; + struct { + ULONG NodeNumber; + } NumaNode; + CACHE_DESCRIPTOR Cache; + ULONGLONG Reserved[2]; + } DUMMYUNIONNAME; +} SYSTEM_LOGICAL_PROCESSOR_INFORMATION, *PSYSTEM_LOGICAL_PROCESSOR_INFORMATION; + +typedef struct _PROCESSOR_RELATIONSHIP { + UCHAR Flags; + UCHAR Reserved[21]; + USHORT GroupCount; + GROUP_AFFINITY GroupMask[ANYSIZE_ARRAY]; +} PROCESSOR_RELATIONSHIP, *PPROCESSOR_RELATIONSHIP; + +typedef struct _NUMA_NODE_RELATIONSHIP { + ULONG NodeNumber; + UCHAR Reserved[20]; + GROUP_AFFINITY GroupMask; +} NUMA_NODE_RELATIONSHIP, *PNUMA_NODE_RELATIONSHIP; + +typedef struct _CACHE_RELATIONSHIP { + UCHAR Level; + UCHAR Associativity; + USHORT LineSize; + ULONG CacheSize; + PROCESSOR_CACHE_TYPE Type; + UCHAR Reserved[20]; + GROUP_AFFINITY GroupMask; +} CACHE_RELATIONSHIP, *PCACHE_RELATIONSHIP; + +typedef struct _PROCESSOR_GROUP_INFO { + UCHAR MaximumProcessorCount; + UCHAR ActiveProcessorCount; + UCHAR Reserved[38]; + KAFFINITY ActiveProcessorMask; +} PROCESSOR_GROUP_INFO, *PPROCESSOR_GROUP_INFO; + +typedef struct _GROUP_RELATIONSHIP { + USHORT MaximumGroupCount; + USHORT ActiveGroupCount; + UCHAR Reserved[20]; + PROCESSOR_GROUP_INFO GroupInfo[ANYSIZE_ARRAY]; +} GROUP_RELATIONSHIP, *PGROUP_RELATIONSHIP; + +typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX { + LOGICAL_PROCESSOR_RELATIONSHIP Relationship; + ULONG Size; + union { + PROCESSOR_RELATIONSHIP Processor; + NUMA_NODE_RELATIONSHIP NumaNode; + CACHE_RELATIONSHIP Cache; + GROUP_RELATIONSHIP Group; + } DUMMYUNIONNAME; +} SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX, *PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX;; + +/* Processor features */ +#define PF_FLOATING_POINT_PRECISION_ERRATA 0 +#define PF_FLOATING_POINT_EMULATED 1 +#define PF_COMPARE_EXCHANGE_DOUBLE 2 +#define PF_MMX_INSTRUCTIONS_AVAILABLE 3 +#define PF_PPC_MOVEMEM_64BIT_OK 4 +#define PF_ALPHA_BYTE_INSTRUCTIONS 5 +#define PF_XMMI_INSTRUCTIONS_AVAILABLE 6 +#define PF_3DNOW_INSTRUCTIONS_AVAILABLE 7 +#define PF_RDTSC_INSTRUCTION_AVAILABLE 8 +#define PF_PAE_ENABLED 9 +#define PF_XMMI64_INSTRUCTIONS_AVAILABLE 10 +#define PF_SSE_DAZ_MODE_AVAILABLE 11 +#define PF_NX_ENABLED 12 +#define PF_SSE3_INSTRUCTIONS_AVAILABLE 13 +#define PF_COMPARE_EXCHANGE128 14 +#define PF_COMPARE64_EXCHANGE128 15 +#define PF_CHANNELS_ENABLED 16 +#define PF_XSAVE_ENABLED 17 + +#define MAXIMUM_WAIT_OBJECTS 64 + +#define ASSERT_APC(Object) NT_ASSERT((Object)->Type == ApcObject) + +#define ASSERT_DPC(Object) \ + ASSERT(((Object)->Type == 0) || \ + ((Object)->Type == DpcObject) || \ + ((Object)->Type == ThreadedDpcObject)) + +#define ASSERT_GATE(object) \ + NT_ASSERT((((object)->Header.Type & KOBJECT_TYPE_MASK) == GateObject) || \ + (((object)->Header.Type & KOBJECT_TYPE_MASK) == EventSynchronizationObject)) + +#define ASSERT_DEVICE_QUEUE(Object) \ + NT_ASSERT((Object)->Type == DeviceQueueObject) + +#define ASSERT_TIMER(E) \ + NT_ASSERT(((E)->Header.Type == TimerNotificationObject) || \ + ((E)->Header.Type == TimerSynchronizationObject)) + +#define ASSERT_MUTANT(E) \ + NT_ASSERT((E)->Header.Type == MutantObject) + +#define ASSERT_SEMAPHORE(E) \ + NT_ASSERT((E)->Header.Type == SemaphoreObject) + +#define ASSERT_EVENT(E) \ + NT_ASSERT(((E)->Header.Type == NotificationEvent) || \ + ((E)->Header.Type == SynchronizationEvent)) + +#define DPC_NORMAL 0 +#define DPC_THREADED 1 + +#define GM_LOCK_BIT 0x1 +#define GM_LOCK_BIT_V 0x0 +#define GM_LOCK_WAITER_WOKEN 0x2 +#define GM_LOCK_WAITER_INC 0x4 + +#define LOCK_QUEUE_WAIT_BIT 0 +#define LOCK_QUEUE_OWNER_BIT 1 + +#define LOCK_QUEUE_WAIT 1 +#define LOCK_QUEUE_OWNER 2 +#define LOCK_QUEUE_TIMER_LOCK_SHIFT 4 +#define LOCK_QUEUE_TIMER_TABLE_LOCKS (1 << (8 - LOCK_QUEUE_TIMER_LOCK_SHIFT)) + +#define PROCESSOR_FEATURE_MAX 64 + +#define DBG_STATUS_CONTROL_C 1 +#define DBG_STATUS_SYSRQ 2 +#define DBG_STATUS_BUGCHECK_FIRST 3 +#define DBG_STATUS_BUGCHECK_SECOND 4 +#define DBG_STATUS_FATAL 5 +#define DBG_STATUS_DEBUG_CONTROL 6 +#define DBG_STATUS_WORKER 7 + +#if defined(_WIN64) +#define MAXIMUM_PROC_PER_GROUP 64 +#else +#define MAXIMUM_PROC_PER_GROUP 32 +#endif +#define MAXIMUM_PROCESSORS MAXIMUM_PROC_PER_GROUP + +/* Exception Records */ +#define EXCEPTION_NONCONTINUABLE 1 +#define EXCEPTION_MAXIMUM_PARAMETERS 15 + +#define EXCEPTION_DIVIDED_BY_ZERO 0 +#define EXCEPTION_DEBUG 1 +#define EXCEPTION_NMI 2 +#define EXCEPTION_INT3 3 +#define EXCEPTION_BOUND_CHECK 5 +#define EXCEPTION_INVALID_OPCODE 6 +#define EXCEPTION_NPX_NOT_AVAILABLE 7 +#define EXCEPTION_DOUBLE_FAULT 8 +#define EXCEPTION_NPX_OVERRUN 9 +#define EXCEPTION_INVALID_TSS 0x0A +#define EXCEPTION_SEGMENT_NOT_PRESENT 0x0B +#define EXCEPTION_STACK_FAULT 0x0C +#define EXCEPTION_GP_FAULT 0x0D +#define EXCEPTION_RESERVED_TRAP 0x0F +#define EXCEPTION_NPX_ERROR 0x010 +#define EXCEPTION_ALIGNMENT_CHECK 0x011 + +typedef struct _EXCEPTION_RECORD { + NTSTATUS ExceptionCode; + ULONG ExceptionFlags; + struct _EXCEPTION_RECORD *ExceptionRecord; + PVOID ExceptionAddress; + ULONG NumberParameters; + ULONG_PTR ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS]; +} EXCEPTION_RECORD, *PEXCEPTION_RECORD; + +typedef struct _EXCEPTION_RECORD32 { + NTSTATUS ExceptionCode; + ULONG ExceptionFlags; + ULONG ExceptionRecord; + ULONG ExceptionAddress; + ULONG NumberParameters; + ULONG ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS]; +} EXCEPTION_RECORD32, *PEXCEPTION_RECORD32; + +typedef struct _EXCEPTION_RECORD64 { + NTSTATUS ExceptionCode; + ULONG ExceptionFlags; + ULONG64 ExceptionRecord; + ULONG64 ExceptionAddress; + ULONG NumberParameters; + ULONG __unusedAlignment; + ULONG64 ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS]; +} EXCEPTION_RECORD64, *PEXCEPTION_RECORD64; + +typedef struct _EXCEPTION_POINTERS { + PEXCEPTION_RECORD ExceptionRecord; + PCONTEXT ContextRecord; +} EXCEPTION_POINTERS, *PEXCEPTION_POINTERS; + +typedef enum _KBUGCHECK_CALLBACK_REASON { + KbCallbackInvalid, + KbCallbackReserved1, + KbCallbackSecondaryDumpData, + KbCallbackDumpIo, + KbCallbackAddPages +} KBUGCHECK_CALLBACK_REASON; + +struct _KBUGCHECK_REASON_CALLBACK_RECORD; + +typedef VOID +(NTAPI KBUGCHECK_REASON_CALLBACK_ROUTINE)( + IN KBUGCHECK_CALLBACK_REASON Reason, + IN struct _KBUGCHECK_REASON_CALLBACK_RECORD *Record, + IN OUT PVOID ReasonSpecificData, + IN ULONG ReasonSpecificDataLength); +typedef KBUGCHECK_REASON_CALLBACK_ROUTINE *PKBUGCHECK_REASON_CALLBACK_ROUTINE; + +typedef struct _KBUGCHECK_ADD_PAGES { + IN OUT PVOID Context; + IN OUT ULONG Flags; + IN ULONG BugCheckCode; + OUT ULONG_PTR Address; + OUT ULONG_PTR Count; +} KBUGCHECK_ADD_PAGES, *PKBUGCHECK_ADD_PAGES; + +typedef struct _KBUGCHECK_SECONDARY_DUMP_DATA { + IN PVOID InBuffer; + IN ULONG InBufferLength; + IN ULONG MaximumAllowed; + OUT GUID Guid; + OUT PVOID OutBuffer; + OUT ULONG OutBufferLength; +} KBUGCHECK_SECONDARY_DUMP_DATA, *PKBUGCHECK_SECONDARY_DUMP_DATA; + +typedef enum _KBUGCHECK_DUMP_IO_TYPE { + KbDumpIoInvalid, + KbDumpIoHeader, + KbDumpIoBody, + KbDumpIoSecondaryData, + KbDumpIoComplete +} KBUGCHECK_DUMP_IO_TYPE; + +typedef struct _KBUGCHECK_DUMP_IO { + IN ULONG64 Offset; + IN PVOID Buffer; + IN ULONG BufferLength; + IN KBUGCHECK_DUMP_IO_TYPE Type; +} KBUGCHECK_DUMP_IO, *PKBUGCHECK_DUMP_IO; + +#define KB_ADD_PAGES_FLAG_VIRTUAL_ADDRESS 0x00000001UL +#define KB_ADD_PAGES_FLAG_PHYSICAL_ADDRESS 0x00000002UL +#define KB_ADD_PAGES_FLAG_ADDITIONAL_RANGES_EXIST 0x80000000UL + +typedef struct _KBUGCHECK_REASON_CALLBACK_RECORD { + LIST_ENTRY Entry; + PKBUGCHECK_REASON_CALLBACK_ROUTINE CallbackRoutine; + PUCHAR Component; + ULONG_PTR Checksum; + KBUGCHECK_CALLBACK_REASON Reason; + UCHAR State; +} KBUGCHECK_REASON_CALLBACK_RECORD, *PKBUGCHECK_REASON_CALLBACK_RECORD; + +typedef enum _KBUGCHECK_BUFFER_DUMP_STATE { + BufferEmpty, + BufferInserted, + BufferStarted, + BufferFinished, + BufferIncomplete +} KBUGCHECK_BUFFER_DUMP_STATE; + +typedef VOID +(NTAPI KBUGCHECK_CALLBACK_ROUTINE)( + IN PVOID Buffer, + IN ULONG Length); +typedef KBUGCHECK_CALLBACK_ROUTINE *PKBUGCHECK_CALLBACK_ROUTINE; + +typedef struct _KBUGCHECK_CALLBACK_RECORD { + LIST_ENTRY Entry; + PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine; + PVOID Buffer; + ULONG Length; + PUCHAR Component; + ULONG_PTR Checksum; + UCHAR State; +} KBUGCHECK_CALLBACK_RECORD, *PKBUGCHECK_CALLBACK_RECORD; + +typedef BOOLEAN +(NTAPI NMI_CALLBACK)( + IN PVOID Context, + IN BOOLEAN Handled); +typedef NMI_CALLBACK *PNMI_CALLBACK; + +typedef enum _KE_PROCESSOR_CHANGE_NOTIFY_STATE { + KeProcessorAddStartNotify = 0, + KeProcessorAddCompleteNotify, + KeProcessorAddFailureNotify +} KE_PROCESSOR_CHANGE_NOTIFY_STATE; + +typedef struct _KE_PROCESSOR_CHANGE_NOTIFY_CONTEXT { + KE_PROCESSOR_CHANGE_NOTIFY_STATE State; + ULONG NtNumber; + NTSTATUS Status; +#if (NTDDI_VERSION >= NTDDI_WIN7) + PROCESSOR_NUMBER ProcNumber; +#endif +} KE_PROCESSOR_CHANGE_NOTIFY_CONTEXT, *PKE_PROCESSOR_CHANGE_NOTIFY_CONTEXT; + +typedef VOID +(NTAPI PROCESSOR_CALLBACK_FUNCTION)( + IN PVOID CallbackContext, + IN PKE_PROCESSOR_CHANGE_NOTIFY_CONTEXT ChangeContext, + IN OUT PNTSTATUS OperationStatus); +typedef PROCESSOR_CALLBACK_FUNCTION *PPROCESSOR_CALLBACK_FUNCTION; + +#define KE_PROCESSOR_CHANGE_ADD_EXISTING 1 + +#define INVALID_PROCESSOR_INDEX 0xffffffff + +typedef enum _KINTERRUPT_POLARITY { + InterruptPolarityUnknown, + InterruptActiveHigh, + InterruptActiveLow +} KINTERRUPT_POLARITY, *PKINTERRUPT_POLARITY; + +typedef enum _KPROFILE_SOURCE { + ProfileTime, + ProfileAlignmentFixup, + ProfileTotalIssues, + ProfilePipelineDry, + ProfileLoadInstructions, + ProfilePipelineFrozen, + ProfileBranchInstructions, + ProfileTotalNonissues, + ProfileDcacheMisses, + ProfileIcacheMisses, + ProfileCacheMisses, + ProfileBranchMispredictions, + ProfileStoreInstructions, + ProfileFpInstructions, + ProfileIntegerInstructions, + Profile2Issue, + Profile3Issue, + Profile4Issue, + ProfileSpecialInstructions, + ProfileTotalCycles, + ProfileIcacheIssues, + ProfileDcacheAccesses, + ProfileMemoryBarrierCycles, + ProfileLoadLinkedIssues, + ProfileMaximum +} KPROFILE_SOURCE; + +typedef enum _KWAIT_REASON { + Executive, + FreePage, + PageIn, + PoolAllocation, + DelayExecution, + Suspended, + UserRequest, + WrExecutive, + WrFreePage, + WrPageIn, + WrPoolAllocation, + WrDelayExecution, + WrSuspended, + WrUserRequest, + WrEventPair, + WrQueue, + WrLpcReceive, + WrLpcReply, + WrVirtualMemory, + WrPageOut, + WrRendezvous, + WrKeyedEvent, + WrTerminated, + WrProcessInSwap, + WrCpuRateControl, + WrCalloutStack, + WrKernel, + WrResource, + WrPushLock, + WrMutex, + WrQuantumEnd, + WrDispatchInt, + WrPreempted, + WrYieldExecution, + WrFastMutex, + WrGuardedMutex, + WrRundown, + MaximumWaitReason +} KWAIT_REASON; + +typedef struct _KWAIT_BLOCK { + LIST_ENTRY WaitListEntry; + struct _KTHREAD *Thread; + PVOID Object; + struct _KWAIT_BLOCK *NextWaitBlock; + USHORT WaitKey; + UCHAR WaitType; + volatile UCHAR BlockState; +#if defined(_WIN64) + LONG SpareLong; +#endif +} KWAIT_BLOCK, *PKWAIT_BLOCK, *PRKWAIT_BLOCK; + +typedef enum _KINTERRUPT_MODE { + LevelSensitive, + Latched +} KINTERRUPT_MODE; + +#define THREAD_WAIT_OBJECTS 3 + +typedef VOID +(NTAPI KSTART_ROUTINE)( + IN PVOID StartContext); +typedef KSTART_ROUTINE *PKSTART_ROUTINE; + +typedef VOID +(NTAPI *PKINTERRUPT_ROUTINE)( + VOID); + +typedef BOOLEAN +(NTAPI KSERVICE_ROUTINE)( + IN struct _KINTERRUPT *Interrupt, + IN PVOID ServiceContext); +typedef KSERVICE_ROUTINE *PKSERVICE_ROUTINE; + +typedef BOOLEAN +(NTAPI KMESSAGE_SERVICE_ROUTINE)( + IN struct _KINTERRUPT *Interrupt, + IN PVOID ServiceContext, + IN ULONG MessageID); +typedef KMESSAGE_SERVICE_ROUTINE *PKMESSAGE_SERVICE_ROUTINE; + +typedef enum _KD_OPTION { + KD_OPTION_SET_BLOCK_ENABLE, +} KD_OPTION; + +typedef VOID +(NTAPI *PKNORMAL_ROUTINE)( + IN PVOID NormalContext OPTIONAL, + IN PVOID SystemArgument1 OPTIONAL, + IN PVOID SystemArgument2 OPTIONAL); + +typedef VOID +(NTAPI *PKRUNDOWN_ROUTINE)( + IN struct _KAPC *Apc); + +typedef VOID +(NTAPI *PKKERNEL_ROUTINE)( + IN struct _KAPC *Apc, + IN OUT PKNORMAL_ROUTINE *NormalRoutine OPTIONAL, + IN OUT PVOID *NormalContext OPTIONAL, + IN OUT PVOID *SystemArgument1 OPTIONAL, + IN OUT PVOID *SystemArgument2 OPTIONAL); + +typedef struct _KAPC { + UCHAR Type; + UCHAR SpareByte0; + UCHAR Size; + UCHAR SpareByte1; + ULONG SpareLong0; + struct _KTHREAD *Thread; + LIST_ENTRY ApcListEntry; + PKKERNEL_ROUTINE KernelRoutine; + PKRUNDOWN_ROUTINE RundownRoutine; + PKNORMAL_ROUTINE NormalRoutine; + PVOID NormalContext; + PVOID SystemArgument1; + PVOID SystemArgument2; + CCHAR ApcStateIndex; + KPROCESSOR_MODE ApcMode; + BOOLEAN Inserted; +} KAPC, *PKAPC, *RESTRICTED_POINTER PRKAPC; + +#define KAPC_OFFSET_TO_SPARE_BYTE0 FIELD_OFFSET(KAPC, SpareByte0) +#define KAPC_OFFSET_TO_SPARE_BYTE1 FIELD_OFFSET(KAPC, SpareByte1) +#define KAPC_OFFSET_TO_SPARE_LONG FIELD_OFFSET(KAPC, SpareLong0) +#define KAPC_OFFSET_TO_SYSTEMARGUMENT1 FIELD_OFFSET(KAPC, SystemArgument1) +#define KAPC_OFFSET_TO_SYSTEMARGUMENT2 FIELD_OFFSET(KAPC, SystemArgument2) +#define KAPC_OFFSET_TO_APCSTATEINDEX FIELD_OFFSET(KAPC, ApcStateIndex) +#define KAPC_ACTUAL_LENGTH (FIELD_OFFSET(KAPC, Inserted) + sizeof(BOOLEAN)) + +typedef struct _KDEVICE_QUEUE_ENTRY { + LIST_ENTRY DeviceListEntry; + ULONG SortKey; + BOOLEAN Inserted; +} KDEVICE_QUEUE_ENTRY, *PKDEVICE_QUEUE_ENTRY, +*RESTRICTED_POINTER PRKDEVICE_QUEUE_ENTRY; + +typedef PVOID PKIPI_CONTEXT; + +typedef VOID +(NTAPI *PKIPI_WORKER)( + IN OUT PKIPI_CONTEXT PacketContext, + IN PVOID Parameter1 OPTIONAL, + IN PVOID Parameter2 OPTIONAL, + IN PVOID Parameter3 OPTIONAL); + +typedef struct _KIPI_COUNTS { + ULONG Freeze; + ULONG Packet; + ULONG DPC; + ULONG APC; + ULONG FlushSingleTb; + ULONG FlushMultipleTb; + ULONG FlushEntireTb; + ULONG GenericCall; + ULONG ChangeColor; + ULONG SweepDcache; + ULONG SweepIcache; + ULONG SweepIcacheRange; + ULONG FlushIoBuffers; + ULONG GratuitousDPC; +} KIPI_COUNTS, *PKIPI_COUNTS; + +typedef ULONG_PTR +(NTAPI KIPI_BROADCAST_WORKER)( + IN ULONG_PTR Argument); +typedef KIPI_BROADCAST_WORKER *PKIPI_BROADCAST_WORKER; + +typedef ULONG_PTR KSPIN_LOCK, *PKSPIN_LOCK; + +typedef struct _KSPIN_LOCK_QUEUE { + struct _KSPIN_LOCK_QUEUE *volatile Next; + PKSPIN_LOCK volatile Lock; +} KSPIN_LOCK_QUEUE, *PKSPIN_LOCK_QUEUE; + +typedef struct _KLOCK_QUEUE_HANDLE { + KSPIN_LOCK_QUEUE LockQueue; + KIRQL OldIrql; +} KLOCK_QUEUE_HANDLE, *PKLOCK_QUEUE_HANDLE; + +#if defined(_AMD64_) + +typedef ULONG64 KSPIN_LOCK_QUEUE_NUMBER; + +#define LockQueueDispatcherLock 0 +#define LockQueueExpansionLock 1 +#define LockQueuePfnLock 2 +#define LockQueueSystemSpaceLock 3 +#define LockQueueVacbLock 4 +#define LockQueueMasterLock 5 +#define LockQueueNonPagedPoolLock 6 +#define LockQueueIoCancelLock 7 +#define LockQueueWorkQueueLock 8 +#define LockQueueIoVpbLock 9 +#define LockQueueIoDatabaseLock 10 +#define LockQueueIoCompletionLock 11 +#define LockQueueNtfsStructLock 12 +#define LockQueueAfdWorkQueueLock 13 +#define LockQueueBcbLock 14 +#define LockQueueMmNonPagedPoolLock 15 +#define LockQueueUnusedSpare16 16 +#define LockQueueTimerTableLock 17 +#define LockQueueMaximumLock (LockQueueTimerTableLock + LOCK_QUEUE_TIMER_TABLE_LOCKS) + +#else + +typedef enum _KSPIN_LOCK_QUEUE_NUMBER { + LockQueueDispatcherLock, + LockQueueExpansionLock, + LockQueuePfnLock, + LockQueueSystemSpaceLock, + LockQueueVacbLock, + LockQueueMasterLock, + LockQueueNonPagedPoolLock, + LockQueueIoCancelLock, + LockQueueWorkQueueLock, + LockQueueIoVpbLock, + LockQueueIoDatabaseLock, + LockQueueIoCompletionLock, + LockQueueNtfsStructLock, + LockQueueAfdWorkQueueLock, + LockQueueBcbLock, + LockQueueMmNonPagedPoolLock, + LockQueueUnusedSpare16, + LockQueueTimerTableLock, + LockQueueMaximumLock = LockQueueTimerTableLock + LOCK_QUEUE_TIMER_TABLE_LOCKS +} KSPIN_LOCK_QUEUE_NUMBER, *PKSPIN_LOCK_QUEUE_NUMBER; + +#endif /* defined(_AMD64_) */ + +typedef VOID +(NTAPI *PKDEFERRED_ROUTINE)( + IN struct _KDPC *Dpc, + IN PVOID DeferredContext OPTIONAL, + IN PVOID SystemArgument1 OPTIONAL, + IN PVOID SystemArgument2 OPTIONAL); + +typedef enum _KDPC_IMPORTANCE { + LowImportance, + MediumImportance, + HighImportance, + MediumHighImportance +} KDPC_IMPORTANCE; + +typedef struct _KDPC { + UCHAR Type; + UCHAR Importance; + volatile USHORT Number; + LIST_ENTRY DpcListEntry; + PKDEFERRED_ROUTINE DeferredRoutine; + PVOID DeferredContext; + PVOID SystemArgument1; + PVOID SystemArgument2; + volatile PVOID DpcData; +} KDPC, *PKDPC, *RESTRICTED_POINTER PRKDPC; + +typedef struct _KDPC_WATCHDOG_INFORMATION { + ULONG DpcTimeLimit; + ULONG DpcTimeCount; + ULONG DpcWatchdogLimit; + ULONG DpcWatchdogCount; + ULONG Reserved; +} KDPC_WATCHDOG_INFORMATION, *PKDPC_WATCHDOG_INFORMATION; + +typedef struct _KDEVICE_QUEUE { + CSHORT Type; + CSHORT Size; + LIST_ENTRY DeviceListHead; + KSPIN_LOCK Lock; + #if defined(_AMD64_) + union { + BOOLEAN Busy; + struct { + LONG64 Reserved:8; + LONG64 Hint:56; + }; + }; + #else + BOOLEAN Busy; + #endif +} KDEVICE_QUEUE, *PKDEVICE_QUEUE, *RESTRICTED_POINTER PRKDEVICE_QUEUE; + +#define TIMER_EXPIRED_INDEX_BITS 6 +#define TIMER_PROCESSOR_INDEX_BITS 5 + +typedef struct _DISPATCHER_HEADER { + _ANONYMOUS_UNION union { + _ANONYMOUS_STRUCT struct { + UCHAR Type; + _ANONYMOUS_UNION union { + _ANONYMOUS_UNION union { + UCHAR TimerControlFlags; + _ANONYMOUS_STRUCT struct { + UCHAR Absolute:1; + UCHAR Coalescable:1; + UCHAR KeepShifting:1; + UCHAR EncodedTolerableDelay:5; + } DUMMYSTRUCTNAME; + } DUMMYUNIONNAME; + UCHAR Abandoned; +#if (NTDDI_VERSION < NTDDI_WIN7) + UCHAR NpxIrql; +#endif + BOOLEAN Signalling; + } DUMMYUNIONNAME; + _ANONYMOUS_UNION union { + _ANONYMOUS_UNION union { + UCHAR ThreadControlFlags; + _ANONYMOUS_STRUCT struct { + UCHAR CpuThrottled:1; + UCHAR CycleProfiling:1; + UCHAR CounterProfiling:1; + UCHAR Reserved:5; + } DUMMYSTRUCTNAME; + } DUMMYUNIONNAME; + UCHAR Size; + UCHAR Hand; + } DUMMYUNIONNAME2; + _ANONYMOUS_UNION union { +#if (NTDDI_VERSION >= NTDDI_WIN7) + _ANONYMOUS_UNION union { + UCHAR TimerMiscFlags; + _ANONYMOUS_STRUCT struct { +#if !defined(_X86_) + UCHAR Index:TIMER_EXPIRED_INDEX_BITS; +#else + UCHAR Index:1; + UCHAR Processor:TIMER_PROCESSOR_INDEX_BITS; +#endif + UCHAR Inserted:1; + volatile UCHAR Expired:1; + } DUMMYSTRUCTNAME; + } DUMMYUNIONNAME; +#else + /* Pre Win7 compatibility fix to latest WDK */ + UCHAR Inserted; +#endif + _ANONYMOUS_UNION union { + BOOLEAN DebugActive; + _ANONYMOUS_STRUCT struct { + BOOLEAN ActiveDR7:1; + BOOLEAN Instrumented:1; + BOOLEAN Reserved2:4; + BOOLEAN UmsScheduled:1; + BOOLEAN UmsPrimary:1; + } DUMMYSTRUCTNAME; + } DUMMYUNIONNAME; /* should probably be DUMMYUNIONNAME2, but this is what WDK says */ + BOOLEAN DpcActive; + } DUMMYUNIONNAME3; + } DUMMYSTRUCTNAME; + volatile LONG Lock; + } DUMMYUNIONNAME; + LONG SignalState; + LIST_ENTRY WaitListHead; +} DISPATCHER_HEADER, *PDISPATCHER_HEADER; + +typedef struct _KEVENT { + DISPATCHER_HEADER Header; +} KEVENT, *PKEVENT, *RESTRICTED_POINTER PRKEVENT; + +typedef struct _KSEMAPHORE { + DISPATCHER_HEADER Header; + LONG Limit; +} KSEMAPHORE, *PKSEMAPHORE, *RESTRICTED_POINTER PRKSEMAPHORE; + +#define KSEMAPHORE_ACTUAL_LENGTH (FIELD_OFFSET(KSEMAPHORE, Limit) + sizeof(LONG)) + +typedef struct _KGATE { + DISPATCHER_HEADER Header; +} KGATE, *PKGATE, *RESTRICTED_POINTER PRKGATE; + +typedef struct _KGUARDED_MUTEX { + volatile LONG Count; + PKTHREAD Owner; + ULONG Contention; + KGATE Gate; + __GNU_EXTENSION union { + __GNU_EXTENSION struct { + SHORT KernelApcDisable; + SHORT SpecialApcDisable; + }; + ULONG CombinedApcDisable; + }; +} KGUARDED_MUTEX, *PKGUARDED_MUTEX; + +typedef struct _KMUTANT { + DISPATCHER_HEADER Header; + LIST_ENTRY MutantListEntry; + struct _KTHREAD *RESTRICTED_POINTER OwnerThread; + BOOLEAN Abandoned; + UCHAR ApcDisable; +} KMUTANT, *PKMUTANT, *RESTRICTED_POINTER PRKMUTANT, KMUTEX, *PKMUTEX, *RESTRICTED_POINTER PRKMUTEX; + +#define TIMER_TABLE_SIZE 512 +#define TIMER_TABLE_SHIFT 9 + +typedef struct _KTIMER { + DISPATCHER_HEADER Header; + ULARGE_INTEGER DueTime; + LIST_ENTRY TimerListEntry; + struct _KDPC *Dpc; + #if !defined(_X86_) + ULONG Processor; + #endif + ULONG Period; +} KTIMER, *PKTIMER, *RESTRICTED_POINTER PRKTIMER; + +typedef enum _LOCK_OPERATION { + IoReadAccess, + IoWriteAccess, + IoModifyAccess +} LOCK_OPERATION; + +#define KTIMER_ACTUAL_LENGTH (FIELD_OFFSET(KTIMER, Period) + sizeof(LONG)) + +typedef BOOLEAN +(NTAPI *PKSYNCHRONIZE_ROUTINE)( + IN PVOID SynchronizeContext); + +typedef enum _POOL_TYPE { + NonPagedPool, + PagedPool, + NonPagedPoolMustSucceed, + DontUseThisType, + NonPagedPoolCacheAligned, + PagedPoolCacheAligned, + NonPagedPoolCacheAlignedMustS, + MaxPoolType, + NonPagedPoolSession = 32, + PagedPoolSession, + NonPagedPoolMustSucceedSession, + DontUseThisTypeSession, + NonPagedPoolCacheAlignedSession, + PagedPoolCacheAlignedSession, + NonPagedPoolCacheAlignedMustSSession +} POOL_TYPE; + +typedef enum _ALTERNATIVE_ARCHITECTURE_TYPE { + StandardDesign, + NEC98x86, + EndAlternatives +} ALTERNATIVE_ARCHITECTURE_TYPE; + +#ifndef _X86_ + +#ifndef IsNEC_98 +#define IsNEC_98 (FALSE) +#endif + +#ifndef IsNotNEC_98 +#define IsNotNEC_98 (TRUE) +#endif + +#ifndef SetNEC_98 +#define SetNEC_98 +#endif + +#ifndef SetNotNEC_98 +#define SetNotNEC_98 +#endif + +#endif + +typedef struct _KSYSTEM_TIME { + ULONG LowPart; + LONG High1Time; + LONG High2Time; +} KSYSTEM_TIME, *PKSYSTEM_TIME; + +typedef struct DECLSPEC_ALIGN(16) _M128A { + ULONGLONG Low; + LONGLONG High; +} M128A, *PM128A; + +typedef struct DECLSPEC_ALIGN(16) _XSAVE_FORMAT { + USHORT ControlWord; + USHORT StatusWord; + UCHAR TagWord; + UCHAR Reserved1; + USHORT ErrorOpcode; + ULONG ErrorOffset; + USHORT ErrorSelector; + USHORT Reserved2; + ULONG DataOffset; + USHORT DataSelector; + USHORT Reserved3; + ULONG MxCsr; + ULONG MxCsr_Mask; + M128A FloatRegisters[8]; +#if defined(_WIN64) + M128A XmmRegisters[16]; + UCHAR Reserved4[96]; +#else + M128A XmmRegisters[8]; + UCHAR Reserved4[192]; + ULONG StackControl[7]; + ULONG Cr0NpxState; +#endif +} XSAVE_FORMAT, *PXSAVE_FORMAT; + +typedef struct DECLSPEC_ALIGN(8) _XSAVE_AREA_HEADER { + ULONG64 Mask; + ULONG64 Reserved[7]; +} XSAVE_AREA_HEADER, *PXSAVE_AREA_HEADER; + +typedef struct DECLSPEC_ALIGN(16) _XSAVE_AREA { + XSAVE_FORMAT LegacyState; + XSAVE_AREA_HEADER Header; +} XSAVE_AREA, *PXSAVE_AREA; + +typedef struct _XSTATE_CONTEXT { + ULONG64 Mask; + ULONG Length; + ULONG Reserved1; + PXSAVE_AREA Area; +#if defined(_X86_) + ULONG Reserved2; +#endif + PVOID Buffer; +#if defined(_X86_) + ULONG Reserved3; +#endif +} XSTATE_CONTEXT, *PXSTATE_CONTEXT; + +typedef struct _XSTATE_SAVE { +#if defined(_AMD64_) + struct _XSTATE_SAVE* Prev; + struct _KTHREAD* Thread; + UCHAR Level; + XSTATE_CONTEXT XStateContext; +#elif defined(_IA64_) + ULONG Dummy; +#elif defined(_X86_) + union { + struct { + LONG64 Reserved1; + ULONG Reserved2; + struct _XSTATE_SAVE* Prev; + PXSAVE_AREA Reserved3; + struct _KTHREAD* Thread; + PVOID Reserved4; + UCHAR Level; + }; + XSTATE_CONTEXT XStateContext; + }; +#endif +} XSTATE_SAVE, *PXSTATE_SAVE; + +#ifdef _X86_ + +#define MAXIMUM_SUPPORTED_EXTENSION 512 + +#if !defined(__midl) && !defined(MIDL_PASS) +C_ASSERT(sizeof(XSAVE_FORMAT) == MAXIMUM_SUPPORTED_EXTENSION); +#endif + +#endif /* _X86_ */ + +#define XSAVE_ALIGN 64 +#define MINIMAL_XSTATE_AREA_LENGTH sizeof(XSAVE_AREA) + +#if !defined(__midl) && !defined(MIDL_PASS) +C_ASSERT((sizeof(XSAVE_FORMAT) & (XSAVE_ALIGN - 1)) == 0); +C_ASSERT((FIELD_OFFSET(XSAVE_AREA, Header) & (XSAVE_ALIGN - 1)) == 0); +C_ASSERT(MINIMAL_XSTATE_AREA_LENGTH == 512 + 64); +#endif + +typedef struct _CONTEXT_CHUNK { + LONG Offset; + ULONG Length; +} CONTEXT_CHUNK, *PCONTEXT_CHUNK; + +typedef struct _CONTEXT_EX { + CONTEXT_CHUNK All; + CONTEXT_CHUNK Legacy; + CONTEXT_CHUNK XState; +} CONTEXT_EX, *PCONTEXT_EX; + +#define CONTEXT_EX_LENGTH ALIGN_UP_BY(sizeof(CONTEXT_EX), STACK_ALIGN) + +#if (NTDDI_VERSION >= NTDDI_VISTA) +extern NTSYSAPI volatile CCHAR KeNumberProcessors; +#elif (NTDDI_VERSION >= NTDDI_WINXP) +extern NTSYSAPI CCHAR KeNumberProcessors; +#else +extern PCCHAR KeNumberProcessors; +#endif + +$endif /* _WDMDDK_ */ +$if (_NTDDK_) + +#define NX_SUPPORT_POLICY_ALWAYSOFF 0 +#define NX_SUPPORT_POLICY_ALWAYSON 1 +#define NX_SUPPORT_POLICY_OPTIN 2 +#define NX_SUPPORT_POLICY_OPTOUT 3 + +typedef VOID +(NTAPI *PEXPAND_STACK_CALLOUT)( + IN PVOID Parameter OPTIONAL); + +typedef VOID +(NTAPI *PTIMER_APC_ROUTINE)( + IN PVOID TimerContext, + IN ULONG TimerLowValue, + IN LONG TimerHighValue); + +typedef enum _TIMER_SET_INFORMATION_CLASS { + TimerSetCoalescableTimer, + MaxTimerInfoClass +} TIMER_SET_INFORMATION_CLASS; + +#if (NTDDI_VERSION >= NTDDI_WIN7) +typedef struct _TIMER_SET_COALESCABLE_TIMER_INFO { + IN LARGE_INTEGER DueTime; + IN PTIMER_APC_ROUTINE TimerApcRoutine OPTIONAL; + IN PVOID TimerContext OPTIONAL; + IN struct _COUNTED_REASON_CONTEXT *WakeContext OPTIONAL; + IN ULONG Period OPTIONAL; + IN ULONG TolerableDelay; + OUT PBOOLEAN PreviousState OPTIONAL; +} TIMER_SET_COALESCABLE_TIMER_INFO, *PTIMER_SET_COALESCABLE_TIMER_INFO; +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + +#define XSTATE_LEGACY_FLOATING_POINT 0 +#define XSTATE_LEGACY_SSE 1 +#define XSTATE_GSSE 2 + +#define XSTATE_MASK_LEGACY_FLOATING_POINT (1i64 << (XSTATE_LEGACY_FLOATING_POINT)) +#define XSTATE_MASK_LEGACY_SSE (1i64 << (XSTATE_LEGACY_SSE)) +#define XSTATE_MASK_LEGACY (XSTATE_MASK_LEGACY_FLOATING_POINT | XSTATE_MASK_LEGACY_SSE) +#define XSTATE_MASK_GSSE (1i64 << (XSTATE_GSSE)) + +#define MAXIMUM_XSTATE_FEATURES 64 + +typedef struct _XSTATE_FEATURE { + ULONG Offset; + ULONG Size; +} XSTATE_FEATURE, *PXSTATE_FEATURE; + +typedef struct _XSTATE_CONFIGURATION { + ULONG64 EnabledFeatures; + ULONG Size; + ULONG OptimizedSave:1; + XSTATE_FEATURE Features[MAXIMUM_XSTATE_FEATURES]; +} XSTATE_CONFIGURATION, *PXSTATE_CONFIGURATION; + +#define MAX_WOW64_SHARED_ENTRIES 16 + +typedef struct _KUSER_SHARED_DATA { + ULONG TickCountLowDeprecated; + ULONG TickCountMultiplier; + volatile KSYSTEM_TIME InterruptTime; + volatile KSYSTEM_TIME SystemTime; + volatile KSYSTEM_TIME TimeZoneBias; + USHORT ImageNumberLow; + USHORT ImageNumberHigh; + WCHAR NtSystemRoot[260]; + ULONG MaxStackTraceDepth; + ULONG CryptoExponent; + ULONG TimeZoneId; + ULONG LargePageMinimum; + ULONG Reserved2[7]; + NT_PRODUCT_TYPE NtProductType; + BOOLEAN ProductTypeIsValid; + ULONG NtMajorVersion; + ULONG NtMinorVersion; + BOOLEAN ProcessorFeatures[PROCESSOR_FEATURE_MAX]; + ULONG Reserved1; + ULONG Reserved3; + volatile ULONG TimeSlip; + ALTERNATIVE_ARCHITECTURE_TYPE AlternativeArchitecture; + ULONG AltArchitecturePad[1]; + LARGE_INTEGER SystemExpirationDate; + ULONG SuiteMask; + BOOLEAN KdDebuggerEnabled; +#if (NTDDI_VERSION >= NTDDI_WINXPSP2) + UCHAR NXSupportPolicy; +#endif + volatile ULONG ActiveConsoleId; + volatile ULONG DismountCount; + ULONG ComPlusPackage; + ULONG LastSystemRITEventTickCount; + ULONG NumberOfPhysicalPages; + BOOLEAN SafeBootMode; +#if (NTDDI_VERSION >= NTDDI_WIN7) + union { + UCHAR TscQpcData; + struct { + UCHAR TscQpcEnabled:1; + UCHAR TscQpcSpareFlag:1; + UCHAR TscQpcShift:6; + } DUMMYSTRUCTNAME; + } DUMMYUNIONNAME; + UCHAR TscQpcPad[2]; +#endif +#if (NTDDI_VERSION >= NTDDI_VISTA) + union { + ULONG SharedDataFlags; + struct { + ULONG DbgErrorPortPresent:1; + ULONG DbgElevationEnabled:1; + ULONG DbgVirtEnabled:1; + ULONG DbgInstallerDetectEnabled:1; + ULONG DbgSystemDllRelocated:1; + ULONG DbgDynProcessorEnabled:1; + ULONG DbgSEHValidationEnabled:1; + ULONG SpareBits:25; + } DUMMYSTRUCTNAME2; + } DUMMYUNIONNAME2; +#else + ULONG TraceLogging; +#endif + ULONG DataFlagsPad[1]; + ULONGLONG TestRetInstruction; + ULONG SystemCall; + ULONG SystemCallReturn; + ULONGLONG SystemCallPad[3]; + _ANONYMOUS_UNION union { + volatile KSYSTEM_TIME TickCount; + volatile ULONG64 TickCountQuad; + _ANONYMOUS_STRUCT struct { + ULONG ReservedTickCountOverlay[3]; + ULONG TickCountPad[1]; + } DUMMYSTRUCTNAME; + } DUMMYUNIONNAME3; + ULONG Cookie; + ULONG CookiePad[1]; +#if (NTDDI_VERSION >= NTDDI_WS03) + LONGLONG ConsoleSessionForegroundProcessId; + ULONG Wow64SharedInformation[MAX_WOW64_SHARED_ENTRIES]; +#endif +#if (NTDDI_VERSION >= NTDDI_VISTA) +#if (NTDDI_VERSION >= NTDDI_WIN7) + USHORT UserModeGlobalLogger[16]; +#else + USHORT UserModeGlobalLogger[8]; + ULONG HeapTracingPid[2]; + ULONG CritSecTracingPid[2]; +#endif + ULONG ImageFileExecutionOptions; +#if (NTDDI_VERSION >= NTDDI_VISTASP1) + ULONG LangGenerationCount; +#else + /* 4 bytes padding */ +#endif + ULONGLONG Reserved5; + volatile ULONG64 InterruptTimeBias; +#endif +#if (NTDDI_VERSION >= NTDDI_WIN7) + volatile ULONG64 TscQpcBias; + volatile ULONG ActiveProcessorCount; + volatile USHORT ActiveGroupCount; + USHORT Reserved4; + volatile ULONG AitSamplingValue; + volatile ULONG AppCompatFlag; + ULONGLONG SystemDllNativeRelocation; + ULONG SystemDllWowRelocation; + ULONG XStatePad[1]; + XSTATE_CONFIGURATION XState; +#endif +} KUSER_SHARED_DATA, *PKUSER_SHARED_DATA; + +#if (NTDDI_VERSION >= NTDDI_VISTA) +extern NTSYSAPI volatile CCHAR KeNumberProcessors; +#elif (NTDDI_VERSION >= NTDDI_WINXP) +extern NTSYSAPI CCHAR KeNumberProcessors; +#else +extern PCCHAR KeNumberProcessors; +#endif + +$endif /* _NTDDK_ */ + diff --git a/reactos/include/xdk/mips/ke.h b/reactos/include/xdk/mips/ke.h new file mode 100644 index 00000000000..31384ad4d27 --- /dev/null +++ b/reactos/include/xdk/mips/ke.h @@ -0,0 +1,66 @@ +$if (_WDMDDK_) +#error MIPS Headers are totally incorrect + +// +// Used to contain PFNs and PFN counts +// +typedef ULONG PFN_COUNT; +typedef ULONG PFN_NUMBER, *PPFN_NUMBER; +typedef LONG SPFN_NUMBER, *PSPFN_NUMBER; + +#define PASSIVE_LEVEL 0 +#define APC_LEVEL 1 +#define DISPATCH_LEVEL 2 +#define PROFILE_LEVEL 27 +#define IPI_LEVEL 29 +#define HIGH_LEVEL 31 + +typedef struct _KPCR { + struct _KPRCB *Prcb; /* 20 */ + KIRQL Irql; /* 24 */ + ULONG IRR; /* 28 */ + ULONG IDR; /* 30 */ +} KPCR, *PKPCR; + +#define KeGetPcr() PCR + +typedef struct _KFLOATING_SAVE { +} KFLOATING_SAVE, *PKFLOATING_SAVE; + +static __inline +ULONG +NTAPI +KeGetCurrentProcessorNumber(VOID) +{ + return 0; +} + +#define YieldProcessor() __asm__ __volatile__("nop"); + +#define KeLowerIrql(a) KfLowerIrql(a) +#define KeRaiseIrql(a,b) *(b) = KfRaiseIrql(a) + +NTKERNELAPI +VOID +NTAPI +KfLowerIrql( + IN KIRQL NewIrql); + +NTKERNELAPI +KIRQL +NTAPI +KfRaiseIrql( + IN KIRQL NewIrql); + +NTKERNELAPI +KIRQL +NTAPI +KeRaiseIrqlToDpcLevel(VOID); + +NTKERNELAPI +KIRQL +NTAPI +KeRaiseIrqlToSynchLevel(VOID); + +$endif + diff --git a/reactos/include/xdk/mmfuncs.h b/reactos/include/xdk/mmfuncs.h new file mode 100644 index 00000000000..b714f97845a --- /dev/null +++ b/reactos/include/xdk/mmfuncs.h @@ -0,0 +1,658 @@ +/****************************************************************************** + * Memory manager Functions * + ******************************************************************************/ +$if (_WDMDDK_) +/* Alignment Macros */ +#define ALIGN_DOWN_BY(size, align) \ + ((ULONG_PTR)(size) & ~((ULONG_PTR)(align) - 1)) + +#define ALIGN_UP_BY(size, align) \ + (ALIGN_DOWN_BY(((ULONG_PTR)(size) + align - 1), align)) + +#define ALIGN_DOWN_POINTER_BY(ptr, align) \ + ((PVOID)ALIGN_DOWN_BY(ptr, align)) + +#define ALIGN_UP_POINTER_BY(ptr, align) \ + ((PVOID)ALIGN_UP_BY(ptr, align)) + +#define ALIGN_DOWN(size, type) \ + ALIGN_DOWN_BY(size, sizeof(type)) + +#define ALIGN_UP(size, type) \ + ALIGN_UP_BY(size, sizeof(type)) + +#define ALIGN_DOWN_POINTER(ptr, type) \ + ALIGN_DOWN_POINTER_BY(ptr, sizeof(type)) + +#define ALIGN_UP_POINTER(ptr, type) \ + ALIGN_UP_POINTER_BY(ptr, sizeof(type)) + +#ifndef FIELD_OFFSET +#define FIELD_OFFSET(type, field) ((ULONG)&(((type *)0)->field)) +#endif + +#ifndef FIELD_SIZE +#define FIELD_SIZE(type, field) (sizeof(((type *)0)->field)) +#endif + +#define POOL_TAGGING 1 + +#if DBG +#define IF_DEBUG if (TRUE) +#else +#define IF_DEBUG if (FALSE) +#endif /* DBG */ + +/* ULONG + * BYTE_OFFSET( + * IN PVOID Va) + */ +#define BYTE_OFFSET(Va) \ + ((ULONG) ((ULONG_PTR) (Va) & (PAGE_SIZE - 1))) + +/* ULONG + * BYTES_TO_PAGES( + * IN ULONG Size) + */ +#define BYTES_TO_PAGES(Size) \ + (((Size) + PAGE_SIZE - 1) >> PAGE_SHIFT) + +/* PVOID + * PAGE_ALIGN( + * IN PVOID Va) + */ +#define PAGE_ALIGN(Va) \ + ((PVOID) ((ULONG_PTR)(Va) & ~(PAGE_SIZE - 1))) + +/* ULONG_PTR + * ROUND_TO_PAGES( + * IN ULONG_PTR Size) + */ +#define ROUND_TO_PAGES(Size) \ + (((ULONG_PTR) (Size) + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1)) + +/* ULONG + * ADDRESS_AND_SIZE_TO_SPAN_PAGES( + * IN PVOID Va, + * IN ULONG Size) + */ +#define ADDRESS_AND_SIZE_TO_SPAN_PAGES(_Va, _Size) \ + ((ULONG) ((((ULONG_PTR) (_Va) & (PAGE_SIZE - 1)) \ + + (_Size) + (PAGE_SIZE - 1)) >> PAGE_SHIFT)) + +#define COMPUTE_PAGES_SPANNED(Va, Size) \ + ADDRESS_AND_SIZE_TO_SPAN_PAGES(Va,Size) + +/* + * ULONG + * MmGetMdlByteCount( + * IN PMDL Mdl) + */ +#define MmGetMdlByteCount(_Mdl) \ + ((_Mdl)->ByteCount) + +/* + * ULONG + * MmGetMdlByteOffset( + * IN PMDL Mdl) + */ +#define MmGetMdlByteOffset(_Mdl) \ + ((_Mdl)->ByteOffset) + +#define MmGetMdlBaseVa(Mdl) ((Mdl)->StartVa) + +/* + * PPFN_NUMBER + * MmGetMdlPfnArray( + * IN PMDL Mdl) + */ +#define MmGetMdlPfnArray(_Mdl) \ + ((PPFN_NUMBER) ((_Mdl) + 1)) + +/* + * PVOID + * MmGetMdlVirtualAddress( + * IN PMDL Mdl) + */ +#define MmGetMdlVirtualAddress(_Mdl) \ + ((PVOID) ((PCHAR) ((_Mdl)->StartVa) + (_Mdl)->ByteOffset)) + +#define MmGetProcedureAddress(Address) (Address) + +/* PVOID MmGetSystemAddressForMdl( + * IN PMDL Mdl); + */ +#define MmGetSystemAddressForMdl(Mdl) \ + (((Mdl)->MdlFlags & (MDL_MAPPED_TO_SYSTEM_VA | \ + MDL_SOURCE_IS_NONPAGED_POOL)) ? \ + ((Mdl)->MappedSystemVa) : \ + (MmMapLockedPages((Mdl), KernelMode))) + +/* PVOID + * MmGetSystemAddressForMdlSafe( + * IN PMDL Mdl, + * IN MM_PAGE_PRIORITY Priority) + */ +#define MmGetSystemAddressForMdlSafe(_Mdl, _Priority) \ + (((_Mdl)->MdlFlags & (MDL_MAPPED_TO_SYSTEM_VA \ + | MDL_SOURCE_IS_NONPAGED_POOL)) ? \ + (_Mdl)->MappedSystemVa : \ + (PVOID) MmMapLockedPagesSpecifyCache((_Mdl), \ + KernelMode, MmCached, NULL, FALSE, (_Priority))) + +/* + * VOID + * MmInitializeMdl( + * IN PMDL MemoryDescriptorList, + * IN PVOID BaseVa, + * IN SIZE_T Length) + */ +#define MmInitializeMdl(_MemoryDescriptorList, \ + _BaseVa, \ + _Length) \ +{ \ + (_MemoryDescriptorList)->Next = (PMDL) NULL; \ + (_MemoryDescriptorList)->Size = (CSHORT) (sizeof(MDL) + \ + (sizeof(PFN_NUMBER) * ADDRESS_AND_SIZE_TO_SPAN_PAGES(_BaseVa, _Length))); \ + (_MemoryDescriptorList)->MdlFlags = 0; \ + (_MemoryDescriptorList)->StartVa = (PVOID) PAGE_ALIGN(_BaseVa); \ + (_MemoryDescriptorList)->ByteOffset = BYTE_OFFSET(_BaseVa); \ + (_MemoryDescriptorList)->ByteCount = (ULONG) _Length; \ +} + +/* + * VOID + * MmPrepareMdlForReuse( + * IN PMDL Mdl) + */ +#define MmPrepareMdlForReuse(_Mdl) \ +{ \ + if (((_Mdl)->MdlFlags & MDL_PARTIAL_HAS_BEEN_MAPPED) != 0) { \ + ASSERT(((_Mdl)->MdlFlags & MDL_PARTIAL) != 0); \ + MmUnmapLockedPages((_Mdl)->MappedSystemVa, (_Mdl)); \ + } else if (((_Mdl)->MdlFlags & MDL_PARTIAL) == 0) { \ + ASSERT(((_Mdl)->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA) == 0); \ + } \ +} +$endif + +#if (NTDDI_VERSION >= NTDDI_WIN2K) +$if (_NTDDK_) +NTKERNELAPI +PPHYSICAL_MEMORY_RANGE +NTAPI +MmGetPhysicalMemoryRanges(VOID); + +NTKERNELAPI +PHYSICAL_ADDRESS +NTAPI +MmGetPhysicalAddress( + IN PVOID BaseAddress); + +NTKERNELAPI +BOOLEAN +NTAPI +MmIsNonPagedSystemAddressValid( + IN PVOID VirtualAddress); + +NTKERNELAPI +PVOID +NTAPI +MmAllocateNonCachedMemory( + IN SIZE_T NumberOfBytes); + +NTKERNELAPI +VOID +NTAPI +MmFreeNonCachedMemory( + IN PVOID BaseAddress, + IN SIZE_T NumberOfBytes); + +NTKERNELAPI +PVOID +NTAPI +MmGetVirtualForPhysical( + IN PHYSICAL_ADDRESS PhysicalAddress); + +NTKERNELAPI +NTSTATUS +NTAPI +MmMapUserAddressesToPage( + IN PVOID BaseAddress, + IN SIZE_T NumberOfBytes, + IN PVOID PageAddress); + +NTKERNELAPI +PVOID +NTAPI +MmMapVideoDisplay( + IN PHYSICAL_ADDRESS PhysicalAddress, + IN SIZE_T NumberOfBytes, + IN MEMORY_CACHING_TYPE CacheType); + +NTKERNELAPI +NTSTATUS +NTAPI +MmMapViewInSessionSpace( + IN PVOID Section, + OUT PVOID *MappedBase, + IN OUT PSIZE_T ViewSize); + +NTKERNELAPI +NTSTATUS +NTAPI +MmMapViewInSystemSpace( + IN PVOID Section, + OUT PVOID *MappedBase, + IN OUT PSIZE_T ViewSize); + +NTKERNELAPI +BOOLEAN +NTAPI +MmIsAddressValid( + IN PVOID VirtualAddress); + +NTKERNELAPI +BOOLEAN +NTAPI +MmIsThisAnNtAsSystem(VOID); + +NTKERNELAPI +VOID +NTAPI +MmLockPagableSectionByHandle( + IN PVOID ImageSectionHandle); + +NTKERNELAPI +NTSTATUS +NTAPI +MmUnmapViewInSessionSpace( + IN PVOID MappedBase); + +NTKERNELAPI +NTSTATUS +NTAPI +MmUnmapViewInSystemSpace( + IN PVOID MappedBase); + +NTKERNELAPI +VOID +NTAPI +MmUnsecureVirtualMemory( + IN HANDLE SecureHandle); + +NTKERNELAPI +NTSTATUS +NTAPI +MmRemovePhysicalMemory( + IN PPHYSICAL_ADDRESS StartAddress, + IN OUT PLARGE_INTEGER NumberOfBytes); + +NTKERNELAPI +HANDLE +NTAPI +MmSecureVirtualMemory( + IN PVOID Address, + IN SIZE_T Size, + IN ULONG ProbeMode); + +NTKERNELAPI +VOID +NTAPI +MmUnmapVideoDisplay( + IN PVOID BaseAddress, + IN SIZE_T NumberOfBytes); + +NTKERNELAPI +NTSTATUS +NTAPI +MmAddPhysicalMemory( + IN PPHYSICAL_ADDRESS StartAddress, + IN OUT PLARGE_INTEGER NumberOfBytes); + +NTKERNELAPI +PVOID +NTAPI +MmAllocateContiguousMemory( + IN SIZE_T NumberOfBytes, + IN PHYSICAL_ADDRESS HighestAcceptableAddress); + +NTKERNELAPI +PVOID +NTAPI +MmAllocateContiguousMemorySpecifyCache( + IN SIZE_T NumberOfBytes, + IN PHYSICAL_ADDRESS LowestAcceptableAddress, + IN PHYSICAL_ADDRESS HighestAcceptableAddress, + IN PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL, + IN MEMORY_CACHING_TYPE CacheType); + +NTKERNELAPI +PVOID +NTAPI +MmAllocateContiguousMemorySpecifyCacheNode( + IN SIZE_T NumberOfBytes, + IN PHYSICAL_ADDRESS LowestAcceptableAddress, + IN PHYSICAL_ADDRESS HighestAcceptableAddress, + IN PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL, + IN MEMORY_CACHING_TYPE CacheType, + IN NODE_REQUIREMENT PreferredNode); + +NTKERNELAPI +VOID +NTAPI +MmFreeContiguousMemory( + IN PVOID BaseAddress); + +NTKERNELAPI +VOID +NTAPI +MmFreeContiguousMemorySpecifyCache( + IN PVOID BaseAddress, + IN SIZE_T NumberOfBytes, + IN MEMORY_CACHING_TYPE CacheType); +$endif + +$if (_WDMDDK_) +NTKERNELAPI +PVOID +NTAPI +MmAllocateContiguousMemory( + IN SIZE_T NumberOfBytes, + IN PHYSICAL_ADDRESS HighestAcceptableAddress); + +NTKERNELAPI +PVOID +NTAPI +MmAllocateContiguousMemorySpecifyCache( + IN SIZE_T NumberOfBytes, + IN PHYSICAL_ADDRESS LowestAcceptableAddress, + IN PHYSICAL_ADDRESS HighestAcceptableAddress, + IN PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL, + IN MEMORY_CACHING_TYPE CacheType); + +NTKERNELAPI +PMDL +NTAPI +MmAllocatePagesForMdl( + IN PHYSICAL_ADDRESS LowAddress, + IN PHYSICAL_ADDRESS HighAddress, + IN PHYSICAL_ADDRESS SkipBytes, + IN SIZE_T TotalBytes); + +NTKERNELAPI +VOID +NTAPI +MmBuildMdlForNonPagedPool( + IN OUT PMDLX MemoryDescriptorList); + +//DECLSPEC_DEPRECATED_DDK +NTKERNELAPI +PMDL +NTAPI +MmCreateMdl( + IN PMDL MemoryDescriptorList OPTIONAL, + IN PVOID Base, + IN SIZE_T Length); + +NTKERNELAPI +VOID +NTAPI +MmFreeContiguousMemory( + IN PVOID BaseAddress); + +NTKERNELAPI +VOID +NTAPI +MmFreeContiguousMemorySpecifyCache( + IN PVOID BaseAddress, + IN SIZE_T NumberOfBytes, + IN MEMORY_CACHING_TYPE CacheType); + +NTKERNELAPI +VOID +NTAPI +MmFreePagesFromMdl( + IN PMDLX MemoryDescriptorList); + +NTKERNELAPI +PVOID +NTAPI +MmGetSystemRoutineAddress( + IN PUNICODE_STRING SystemRoutineName); + +NTKERNELAPI +LOGICAL +NTAPI +MmIsDriverVerifying( + IN struct _DRIVER_OBJECT *DriverObject); + +NTKERNELAPI +PVOID +NTAPI +MmLockPagableDataSection( + IN PVOID AddressWithinSection); + +NTKERNELAPI +PVOID +NTAPI +MmMapIoSpace( + IN PHYSICAL_ADDRESS PhysicalAddress, + IN SIZE_T NumberOfBytes, + IN MEMORY_CACHING_TYPE CacheEnable); + +NTKERNELAPI +PVOID +NTAPI +MmMapLockedPages( + IN PMDL MemoryDescriptorList, + IN KPROCESSOR_MODE AccessMode); + +NTKERNELAPI +PVOID +NTAPI +MmMapLockedPagesSpecifyCache( + IN PMDLX MemoryDescriptorList, + IN KPROCESSOR_MODE AccessMode, + IN MEMORY_CACHING_TYPE CacheType, + IN PVOID BaseAddress OPTIONAL, + IN ULONG BugCheckOnFailure, + IN MM_PAGE_PRIORITY Priority); + +NTKERNELAPI +PVOID +NTAPI +MmPageEntireDriver( + IN PVOID AddressWithinSection); + +NTKERNELAPI +VOID +NTAPI +MmProbeAndLockPages( + IN OUT PMDL MemoryDescriptorList, + IN KPROCESSOR_MODE AccessMode, + IN LOCK_OPERATION Operation); + +NTKERNELAPI +MM_SYSTEMSIZE +NTAPI +MmQuerySystemSize(VOID); + +NTKERNELAPI +VOID +NTAPI +MmResetDriverPaging( + IN PVOID AddressWithinSection); + +NTKERNELAPI +SIZE_T +NTAPI +MmSizeOfMdl( + IN PVOID Base, + IN SIZE_T Length); + +NTKERNELAPI +VOID +NTAPI +MmUnlockPagableImageSection( + IN PVOID ImageSectionHandle); + +NTKERNELAPI +VOID +NTAPI +MmUnlockPages( + IN OUT PMDL MemoryDescriptorList); + +NTKERNELAPI +VOID +NTAPI +MmUnmapIoSpace( + IN PVOID BaseAddress, + IN SIZE_T NumberOfBytes); + +NTKERNELAPI +VOID +NTAPI +MmProbeAndLockProcessPages( + IN OUT PMDL MemoryDescriptorList, + IN PEPROCESS Process, + IN KPROCESSOR_MODE AccessMode, + IN LOCK_OPERATION Operation); + +NTKERNELAPI +VOID +NTAPI +MmUnmapLockedPages( + IN PVOID BaseAddress, + IN PMDL MemoryDescriptorList); + +NTKERNELAPI +PVOID +NTAPI +MmAllocateContiguousMemorySpecifyCacheNode( + IN SIZE_T NumberOfBytes, + IN PHYSICAL_ADDRESS LowestAcceptableAddress, + IN PHYSICAL_ADDRESS HighestAcceptableAddress, + IN PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL, + IN MEMORY_CACHING_TYPE CacheType, + IN NODE_REQUIREMENT PreferredNode); +$endif + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ + +#if (NTDDI_VERSION >= NTDDI_WINXP) + +NTKERNELAPI +NTSTATUS +NTAPI +MmAdvanceMdl( + IN OUT PMDL Mdl, + IN ULONG NumberOfBytes); + +NTKERNELAPI +PVOID +NTAPI +MmAllocateMappingAddress( + IN SIZE_T NumberOfBytes, + IN ULONG PoolTag); + +NTKERNELAPI +VOID +NTAPI +MmFreeMappingAddress( + IN PVOID BaseAddress, + IN ULONG PoolTag); + +NTKERNELAPI +NTSTATUS +NTAPI +MmIsVerifierEnabled( + OUT PULONG VerifierFlags); + +NTKERNELAPI +PVOID +NTAPI +MmMapLockedPagesWithReservedMapping( + IN PVOID MappingAddress, + IN ULONG PoolTag, + IN PMDL MemoryDescriptorList, + IN MEMORY_CACHING_TYPE CacheType); + +NTKERNELAPI +NTSTATUS +NTAPI +MmProtectMdlSystemAddress( + IN PMDL MemoryDescriptorList, + IN ULONG NewProtect); + +NTKERNELAPI +VOID +NTAPI +MmUnmapReservedMapping( + IN PVOID BaseAddress, + IN ULONG PoolTag, + IN PMDL MemoryDescriptorList); + +NTKERNELAPI +NTSTATUS +NTAPI +MmAddVerifierThunks( + IN PVOID ThunkBuffer, + IN ULONG ThunkBufferSize); + +#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ + +#if (NTDDI_VERSION >= NTDDI_WS03) +$if (_NTDDK_) +NTKERNELAPI +NTSTATUS +NTAPI +MmCreateMirror(VOID); +$endif +$if (_WDMDDK_) +NTKERNELAPI +LOGICAL +NTAPI +MmIsIoSpaceActive( + IN PHYSICAL_ADDRESS StartAddress, + IN SIZE_T NumberOfBytes); +$endif +#endif + +$if (_WDMDDK_) +#if (NTDDI_VERSION >= NTDDI_WS03SP1) +NTKERNELAPI +PMDL +NTAPI +MmAllocatePagesForMdlEx( + IN PHYSICAL_ADDRESS LowAddress, + IN PHYSICAL_ADDRESS HighAddress, + IN PHYSICAL_ADDRESS SkipBytes, + IN SIZE_T TotalBytes, + IN MEMORY_CACHING_TYPE CacheType, + IN ULONG Flags); +#endif +$endif + +#if (NTDDI_VERSION >= NTDDI_VISTA) +$if (_NTDDK_) +NTSTATUS +NTAPI +MmRotatePhysicalView( + IN PVOID VirtualAddress, + IN OUT PSIZE_T NumberOfBytes, + IN PMDLX NewMdl OPTIONAL, + IN MM_ROTATE_DIRECTION Direction, + IN PMM_ROTATE_COPY_CALLBACK_FUNCTION CopyFunction, + IN PVOID Context OPTIONAL); +$endif + +$if (_WDMDDK_) +NTKERNELAPI +LOGICAL +NTAPI +MmIsDriverVerifyingByAddress( + IN PVOID AddressWithinSection); +$endif +#endif + diff --git a/reactos/include/xdk/mmtypes.h b/reactos/include/xdk/mmtypes.h new file mode 100644 index 00000000000..e4a23f48215 --- /dev/null +++ b/reactos/include/xdk/mmtypes.h @@ -0,0 +1,171 @@ +/****************************************************************************** + * Memory manager Types * + ******************************************************************************/ +$if (_WDMDDK_) + +#if (NTDDI_VERSION >= NTDDI_WIN2K) +typedef ULONG NODE_REQUIREMENT; +#define MM_ANY_NODE_OK 0x80000000 +#endif + +#define MM_DONT_ZERO_ALLOCATION 0x00000001 +#define MM_ALLOCATE_FROM_LOCAL_NODE_ONLY 0x00000002 +#define MM_ALLOCATE_FULLY_REQUIRED 0x00000004 +#define MM_ALLOCATE_NO_WAIT 0x00000008 +#define MM_ALLOCATE_PREFER_CONTIGUOUS 0x00000010 +#define MM_ALLOCATE_REQUIRE_CONTIGUOUS_CHUNKS 0x00000020 + +#define MDL_MAPPED_TO_SYSTEM_VA 0x0001 +#define MDL_PAGES_LOCKED 0x0002 +#define MDL_SOURCE_IS_NONPAGED_POOL 0x0004 +#define MDL_ALLOCATED_FIXED_SIZE 0x0008 +#define MDL_PARTIAL 0x0010 +#define MDL_PARTIAL_HAS_BEEN_MAPPED 0x0020 +#define MDL_IO_PAGE_READ 0x0040 +#define MDL_WRITE_OPERATION 0x0080 +#define MDL_PARENT_MAPPED_SYSTEM_VA 0x0100 +#define MDL_FREE_EXTRA_PTES 0x0200 +#define MDL_DESCRIBES_AWE 0x0400 +#define MDL_IO_SPACE 0x0800 +#define MDL_NETWORK_HEADER 0x1000 +#define MDL_MAPPING_CAN_FAIL 0x2000 +#define MDL_ALLOCATED_MUST_SUCCEED 0x4000 +#define MDL_INTERNAL 0x8000 + +#define MDL_MAPPING_FLAGS ( \ + MDL_MAPPED_TO_SYSTEM_VA | \ + MDL_PAGES_LOCKED | \ + MDL_SOURCE_IS_NONPAGED_POOL | \ + MDL_PARTIAL_HAS_BEEN_MAPPED | \ + MDL_PARENT_MAPPED_SYSTEM_VA | \ + MDL_SYSTEM_VA | \ + MDL_IO_SPACE) + +#define FLUSH_MULTIPLE_MAXIMUM 32 + +/* Section access rights */ +#define SECTION_QUERY 0x0001 +#define SECTION_MAP_WRITE 0x0002 +#define SECTION_MAP_READ 0x0004 +#define SECTION_MAP_EXECUTE 0x0008 +#define SECTION_EXTEND_SIZE 0x0010 +#define SECTION_MAP_EXECUTE_EXPLICIT 0x0020 + +#define SECTION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SECTION_QUERY|\ + SECTION_MAP_WRITE | \ + SECTION_MAP_READ | \ + SECTION_MAP_EXECUTE | \ + SECTION_EXTEND_SIZE) + +#define SESSION_QUERY_ACCESS 0x0001 +#define SESSION_MODIFY_ACCESS 0x0002 + +#define SESSION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | \ + SESSION_QUERY_ACCESS | \ + SESSION_MODIFY_ACCESS) + +#define SEGMENT_ALL_ACCESS SECTION_ALL_ACCESS + +#define PAGE_NOACCESS 0x01 +#define PAGE_READONLY 0x02 +#define PAGE_READWRITE 0x04 +#define PAGE_WRITECOPY 0x08 +#define PAGE_EXECUTE 0x10 +#define PAGE_EXECUTE_READ 0x20 +#define PAGE_EXECUTE_READWRITE 0x40 +#define PAGE_EXECUTE_WRITECOPY 0x80 +#define PAGE_GUARD 0x100 +#define PAGE_NOCACHE 0x200 +#define PAGE_WRITECOMBINE 0x400 + +#define MEM_COMMIT 0x1000 +#define MEM_RESERVE 0x2000 +#define MEM_DECOMMIT 0x4000 +#define MEM_RELEASE 0x8000 +#define MEM_FREE 0x10000 +#define MEM_PRIVATE 0x20000 +#define MEM_MAPPED 0x40000 +#define MEM_RESET 0x80000 +#define MEM_TOP_DOWN 0x100000 +#define MEM_LARGE_PAGES 0x20000000 +#define MEM_4MB_PAGES 0x80000000 + +#define SEC_RESERVE 0x4000000 +#define SEC_COMMIT 0x8000000 +#define SEC_LARGE_PAGES 0x80000000 + +/* Section map options */ +typedef enum _SECTION_INHERIT { + ViewShare = 1, + ViewUnmap = 2 +} SECTION_INHERIT; + +typedef ULONG PFN_COUNT; +typedef LONG_PTR SPFN_NUMBER, *PSPFN_NUMBER; +typedef ULONG_PTR PFN_NUMBER, *PPFN_NUMBER; + +typedef struct _MDL { + struct _MDL *Next; + CSHORT Size; + CSHORT MdlFlags; + struct _EPROCESS *Process; + PVOID MappedSystemVa; + PVOID StartVa; + ULONG ByteCount; + ULONG ByteOffset; +} MDL, *PMDL; +typedef MDL *PMDLX; + +typedef enum _MEMORY_CACHING_TYPE_ORIG { + MmFrameBufferCached = 2 +} MEMORY_CACHING_TYPE_ORIG; + +typedef enum _MEMORY_CACHING_TYPE { + MmNonCached = FALSE, + MmCached = TRUE, + MmWriteCombined = MmFrameBufferCached, + MmHardwareCoherentCached, + MmNonCachedUnordered, + MmUSWCCached, + MmMaximumCacheType +} MEMORY_CACHING_TYPE; + +typedef enum _MM_PAGE_PRIORITY { + LowPagePriority, + NormalPagePriority = 16, + HighPagePriority = 32 +} MM_PAGE_PRIORITY; + +typedef enum _MM_SYSTEM_SIZE { + MmSmallSystem, + MmMediumSystem, + MmLargeSystem +} MM_SYSTEMSIZE; + +extern NTKERNELAPI BOOLEAN Mm64BitPhysicalAddress; +extern PVOID MmBadPointer; + +$endif /* _WDMDDK_ */ +$if (_NTDDK_) + +typedef struct _PHYSICAL_MEMORY_RANGE { + PHYSICAL_ADDRESS BaseAddress; + LARGE_INTEGER NumberOfBytes; +} PHYSICAL_MEMORY_RANGE, *PPHYSICAL_MEMORY_RANGE; + +typedef NTSTATUS +(NTAPI *PMM_ROTATE_COPY_CALLBACK_FUNCTION)( + IN PMDL DestinationMdl, + IN PMDL SourceMdl, + IN PVOID Context); + +typedef enum _MM_ROTATE_DIRECTION { + MmToFrameBuffer, + MmToFrameBufferNoCopy, + MmToRegularMemory, + MmToRegularMemoryNoCopy, + MmMaximumRotateDirection +} MM_ROTATE_DIRECTION, *PMM_ROTATE_DIRECTION; + +$endif /* _NTDDK_ */ + diff --git a/reactos/include/xdk/ntddk.template.h b/reactos/include/xdk/ntddk.template.h new file mode 100644 index 00000000000..003e9b7397d --- /dev/null +++ b/reactos/include/xdk/ntddk.template.h @@ -0,0 +1,262 @@ +/* + * ntddk.h + * + * Windows NT Device Driver Kit + * + * This file is part of the ReactOS DDK package. + * + * Contributors: + * Amine Khaldi + * Timo Kreuzer (timo.kreuzer@reactos.org) + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAIMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + */ + +#pragma once + +#define _NTDDK_ + +#if !defined(_NTHAL_) && !defined(_NTIFS_) +#define _NTDDK_INCLUDED_ +#define _DDK_DRIVER_ +#endif + +/* Dependencies */ + +#define NT_INCLUDED +#define _CTYPE_DISABLE_MACROS + +#include +#include +#include +#include +#include + +/* FIXME +#include +#include +*/ + +#include // FIXME +#include // FIXME + + +#ifdef __cplusplus +extern "C" { +#endif + +/* GUID and UUID */ +#ifndef _NTLSA_IFS_ +#ifndef _NTLSA_AUDIT_ +#define _NTLSA_AUDIT_ + +#ifndef GUID_DEFINED +#include +#endif + +#endif /* _NTLSA_AUDIT_ */ +#endif /* _NTLSA_IFS_ */ + +typedef GUID UUID; + +struct _LOADER_PARAMETER_BLOCK; +struct _CREATE_DISK; +struct _DRIVE_LAYOUT_INFORMATION_EX; +struct _SET_PARTITION_INFORMATION_EX; + +typedef struct _BUS_HANDLER *PBUS_HANDLER; +typedef struct _DEVICE_HANDLER_OBJECT *PDEVICE_HANDLER_OBJECT; +#if defined(_NTHAL_INCLUDED_) +typedef struct _KAFFINITY_EX *PKAFFINITY_EX; +#endif +typedef struct _PEB *PPEB; + +#ifndef _NTIMAGE_ + +typedef struct _IMAGE_NT_HEADERS *PIMAGE_NT_HEADERS32; +typedef struct _IMAGE_NT_HEADERS64 *PIMAGE_NT_HEADERS64; + +#ifdef _WIN64 +typedef PIMAGE_NT_HEADERS64 PIMAGE_NT_HEADERS; +#else +typedef PIMAGE_NT_HEADERS32 PIMAGE_NT_HEADERS; +#endif + +#endif /* _NTIMAGE_ */ + +$define (_NTDDK_) +$include (extypes.h) +$include (iotypes.h) +$include (haltypes.h) +$include (ketypes.h) +$include (kdtypes.h) +$include (mmtypes.h) +$include (pstypes.h) +$include (rtltypes.h) +$include (setypes.h) + +#if defined(_M_IX86) +$include(x86/ke.h) +$include(x86/mm.h) +#elif defined(_M_AMD64) +$include(amd64/ke.h) +$include(amd64/mm.h) +#elif defined(_M_IA64) +$include(ia64/ke.h) +#elif defined(_M_PPC) +$include(ppc/ke.h) +#elif defined(_M_MIPS) +$include(mips/ke.h) +#elif defined(_M_ARM) +$include(arm/ke.h) +#else +#error Unknown Architecture +#endif + +$include (exfuncs.h) +$include (halfuncs.h) +$include (iofuncs.h) +$include (kdfuncs.h) +$include (kefuncs.h) +$include (mmfuncs.h) +$include (psfuncs.h) +$include (rtlfuncs.h) +$include (sefuncs.h) +$include (zwfuncs.h) + + +/* UNSORTED */ + +#define VER_SET_CONDITION(ConditionMask, TypeBitMask, ComparisonType) \ + ((ConditionMask) = VerSetConditionMask((ConditionMask), \ + (TypeBitMask), (ComparisonType))) + +#if (NTDDI_VERSION >= NTDDI_WIN2K) +NTSYSAPI +ULONGLONG +NTAPI +VerSetConditionMask( + IN ULONGLONG ConditionMask, + IN ULONG TypeMask, + IN UCHAR Condition); +#endif + +typedef struct _KERNEL_USER_TIMES { + LARGE_INTEGER CreateTime; + LARGE_INTEGER ExitTime; + LARGE_INTEGER KernelTime; + LARGE_INTEGER UserTime; +} KERNEL_USER_TIMES, *PKERNEL_USER_TIMES; + +/* NtXxx Functions */ + +typedef enum _SYSTEM_FIRMWARE_TABLE_ACTION { + SystemFirmwareTable_Enumerate, + SystemFirmwareTable_Get +} SYSTEM_FIRMWARE_TABLE_ACTION; + +typedef struct _SYSTEM_FIRMWARE_TABLE_INFORMATION { + ULONG ProviderSignature; + SYSTEM_FIRMWARE_TABLE_ACTION Action; + ULONG TableID; + ULONG TableBufferLength; + UCHAR TableBuffer[ANYSIZE_ARRAY]; +} SYSTEM_FIRMWARE_TABLE_INFORMATION, *PSYSTEM_FIRMWARE_TABLE_INFORMATION; + +typedef NTSTATUS +(__cdecl *PFNFTH)( + IN OUT PSYSTEM_FIRMWARE_TABLE_INFORMATION SystemFirmwareTableInfo); + +typedef struct _SYSTEM_FIRMWARE_TABLE_HANDLER { + ULONG ProviderSignature; + BOOLEAN Register; + PFNFTH FirmwareTableHandler; + PVOID DriverObject; +} SYSTEM_FIRMWARE_TABLE_HANDLER, *PSYSTEM_FIRMWARE_TABLE_HANDLER; + +typedef ULONG_PTR +(NTAPI *PDRIVER_VERIFIER_THUNK_ROUTINE)( + IN PVOID Context); + +typedef struct _DRIVER_VERIFIER_THUNK_PAIRS { + PDRIVER_VERIFIER_THUNK_ROUTINE PristineRoutine; + PDRIVER_VERIFIER_THUNK_ROUTINE NewRoutine; +} DRIVER_VERIFIER_THUNK_PAIRS, *PDRIVER_VERIFIER_THUNK_PAIRS; + +#define DRIVER_VERIFIER_SPECIAL_POOLING 0x0001 +#define DRIVER_VERIFIER_FORCE_IRQL_CHECKING 0x0002 +#define DRIVER_VERIFIER_INJECT_ALLOCATION_FAILURES 0x0004 +#define DRIVER_VERIFIER_TRACK_POOL_ALLOCATIONS 0x0008 +#define DRIVER_VERIFIER_IO_CHECKING 0x0010 + +#define SHARED_GLOBAL_FLAGS_ERROR_PORT_V 0x0 +#define SHARED_GLOBAL_FLAGS_ERROR_PORT (1UL << SHARED_GLOBAL_FLAGS_ERROR_PORT_V) + +#define SHARED_GLOBAL_FLAGS_ELEVATION_ENABLED_V 0x1 +#define SHARED_GLOBAL_FLAGS_ELEVATION_ENABLED (1UL << SHARED_GLOBAL_FLAGS_ELEVATION_ENABLED_V) + +#define SHARED_GLOBAL_FLAGS_VIRT_ENABLED_V 0x2 +#define SHARED_GLOBAL_FLAGS_VIRT_ENABLED (1UL << SHARED_GLOBAL_FLAGS_VIRT_ENABLED_V) + +#define SHARED_GLOBAL_FLAGS_INSTALLER_DETECT_ENABLED_V 0x3 +#define SHARED_GLOBAL_FLAGS_INSTALLER_DETECT_ENABLED \ + (1UL << SHARED_GLOBAL_FLAGS_INSTALLER_DETECT_ENABLED_V) + +#define SHARED_GLOBAL_FLAGS_SPARE_V 0x4 +#define SHARED_GLOBAL_FLAGS_SPARE \ + (1UL << SHARED_GLOBAL_FLAGS_SPARE_V) + +#define SHARED_GLOBAL_FLAGS_DYNAMIC_PROC_ENABLED_V 0x5 +#define SHARED_GLOBAL_FLAGS_DYNAMIC_PROC_ENABLED \ + (1UL << SHARED_GLOBAL_FLAGS_DYNAMIC_PROC_ENABLED_V) + +#define SHARED_GLOBAL_FLAGS_SEH_VALIDATION_ENABLED_V 0x6 +#define SHARED_GLOBAL_FLAGS_SEH_VALIDATION_ENABLED \ + (1UL << SHARED_GLOBAL_FLAGS_SEH_VALIDATION_ENABLED_V) + +#define EX_INIT_BITS(Flags, Bit) \ + *((Flags)) |= (Bit) // Safe to use before concurrently accessible + +#define EX_TEST_SET_BIT(Flags, Bit) \ + InterlockedBitTestAndSet ((PLONG)(Flags), (Bit)) + +#define EX_TEST_CLEAR_BIT(Flags, Bit) \ + InterlockedBitTestAndReset ((PLONG)(Flags), (Bit)) + +#define PCCARD_MAP_ERROR 0x01 +#define PCCARD_DEVICE_PCI 0x10 + +#define PCCARD_SCAN_DISABLED 0x01 +#define PCCARD_MAP_ZERO 0x02 +#define PCCARD_NO_TIMER 0x03 +#define PCCARD_NO_PIC 0x04 +#define PCCARD_NO_LEGACY_BASE 0x05 +#define PCCARD_DUP_LEGACY_BASE 0x06 +#define PCCARD_NO_CONTROLLERS 0x07 + +#define MAXIMUM_EXPANSION_SIZE (KERNEL_LARGE_STACK_SIZE - (PAGE_SIZE / 2)) + +/* Filesystem runtime library routines */ + +#if (NTDDI_VERSION >= NTDDI_WIN2K) +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlIsTotalDeviceFailure( + IN NTSTATUS Status); +#endif + +/* FIXME : These definitions below doesn't belong to NTDDK */ + +#ifdef __cplusplus +} +#endif diff --git a/reactos/include/xdk/nttmapi.h b/reactos/include/xdk/nttmapi.h new file mode 100644 index 00000000000..721005fdd88 --- /dev/null +++ b/reactos/include/xdk/nttmapi.h @@ -0,0 +1,652 @@ +$if (_WDMDDK_) +#ifndef _NTTMAPI_ +#define _NTTMAPI_ + +#include + +#define TRANSACTIONMANAGER_QUERY_INFORMATION (0x0001) +#define TRANSACTIONMANAGER_SET_INFORMATION (0x0002) +#define TRANSACTIONMANAGER_RECOVER (0x0004) +#define TRANSACTIONMANAGER_RENAME (0x0008) +#define TRANSACTIONMANAGER_CREATE_RM (0x0010) +#define TRANSACTIONMANAGER_BIND_TRANSACTION (0x0020) + +#define TRANSACTIONMANAGER_GENERIC_READ (STANDARD_RIGHTS_READ |\ + TRANSACTIONMANAGER_QUERY_INFORMATION) + +#define TRANSACTIONMANAGER_GENERIC_WRITE (STANDARD_RIGHTS_WRITE |\ + TRANSACTIONMANAGER_SET_INFORMATION |\ + TRANSACTIONMANAGER_RECOVER |\ + TRANSACTIONMANAGER_RENAME |\ + TRANSACTIONMANAGER_CREATE_RM) + +#define TRANSACTIONMANAGER_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE) + +#define TRANSACTIONMANAGER_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED |\ + TRANSACTIONMANAGER_GENERIC_READ |\ + TRANSACTIONMANAGER_GENERIC_WRITE |\ + TRANSACTIONMANAGER_GENERIC_EXECUTE |\ + TRANSACTIONMANAGER_BIND_TRANSACTION) + +#define TRANSACTION_QUERY_INFORMATION (0x0001) +#define TRANSACTION_SET_INFORMATION (0x0002) +#define TRANSACTION_ENLIST (0x0004) +#define TRANSACTION_COMMIT (0x0008) +#define TRANSACTION_ROLLBACK (0x0010) +#define TRANSACTION_PROPAGATE (0x0020) +#define TRANSACTION_RIGHT_RESERVED1 (0x0040) + +#define TRANSACTION_GENERIC_READ (STANDARD_RIGHTS_READ |\ + TRANSACTION_QUERY_INFORMATION |\ + SYNCHRONIZE) + +#define TRANSACTION_GENERIC_WRITE (STANDARD_RIGHTS_WRITE |\ + TRANSACTION_SET_INFORMATION |\ + TRANSACTION_COMMIT |\ + TRANSACTION_ENLIST |\ + TRANSACTION_ROLLBACK |\ + TRANSACTION_PROPAGATE |\ + SYNCHRONIZE) + +#define TRANSACTION_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE |\ + TRANSACTION_COMMIT |\ + TRANSACTION_ROLLBACK |\ + SYNCHRONIZE) + +#define TRANSACTION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED |\ + TRANSACTION_GENERIC_READ |\ + TRANSACTION_GENERIC_WRITE |\ + TRANSACTION_GENERIC_EXECUTE) + +#define TRANSACTION_RESOURCE_MANAGER_RIGHTS (TRANSACTION_GENERIC_READ |\ + STANDARD_RIGHTS_WRITE |\ + TRANSACTION_SET_INFORMATION |\ + TRANSACTION_ENLIST |\ + TRANSACTION_ROLLBACK |\ + TRANSACTION_PROPAGATE |\ + SYNCHRONIZE) + +#define RESOURCEMANAGER_QUERY_INFORMATION (0x0001) +#define RESOURCEMANAGER_SET_INFORMATION (0x0002) +#define RESOURCEMANAGER_RECOVER (0x0004) +#define RESOURCEMANAGER_ENLIST (0x0008) +#define RESOURCEMANAGER_GET_NOTIFICATION (0x0010) +#define RESOURCEMANAGER_REGISTER_PROTOCOL (0x0020) +#define RESOURCEMANAGER_COMPLETE_PROPAGATION (0x0040) + +#define RESOURCEMANAGER_GENERIC_READ (STANDARD_RIGHTS_READ |\ + RESOURCEMANAGER_QUERY_INFORMATION |\ + SYNCHRONIZE) + +#define RESOURCEMANAGER_GENERIC_WRITE (STANDARD_RIGHTS_WRITE |\ + RESOURCEMANAGER_SET_INFORMATION |\ + RESOURCEMANAGER_RECOVER |\ + RESOURCEMANAGER_ENLIST |\ + RESOURCEMANAGER_GET_NOTIFICATION |\ + RESOURCEMANAGER_REGISTER_PROTOCOL |\ + RESOURCEMANAGER_COMPLETE_PROPAGATION |\ + SYNCHRONIZE) + +#define RESOURCEMANAGER_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE |\ + RESOURCEMANAGER_RECOVER |\ + RESOURCEMANAGER_ENLIST |\ + RESOURCEMANAGER_GET_NOTIFICATION |\ + RESOURCEMANAGER_COMPLETE_PROPAGATION |\ + SYNCHRONIZE) + +#define RESOURCEMANAGER_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED |\ + RESOURCEMANAGER_GENERIC_READ |\ + RESOURCEMANAGER_GENERIC_WRITE |\ + RESOURCEMANAGER_GENERIC_EXECUTE) + +#define ENLISTMENT_QUERY_INFORMATION (0x0001) +#define ENLISTMENT_SET_INFORMATION (0x0002) +#define ENLISTMENT_RECOVER (0x0004) +#define ENLISTMENT_SUBORDINATE_RIGHTS (0x0008) +#define ENLISTMENT_SUPERIOR_RIGHTS (0x0010) + +#define ENLISTMENT_GENERIC_READ (STANDARD_RIGHTS_READ |\ + ENLISTMENT_QUERY_INFORMATION) + +#define ENLISTMENT_GENERIC_WRITE (STANDARD_RIGHTS_WRITE |\ + ENLISTMENT_SET_INFORMATION |\ + ENLISTMENT_RECOVER |\ + ENLISTMENT_SUBORDINATE_RIGHTS |\ + ENLISTMENT_SUPERIOR_RIGHTS) + +#define ENLISTMENT_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE |\ + ENLISTMENT_RECOVER |\ + ENLISTMENT_SUBORDINATE_RIGHTS |\ + ENLISTMENT_SUPERIOR_RIGHTS) + +#define ENLISTMENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED |\ + ENLISTMENT_GENERIC_READ |\ + ENLISTMENT_GENERIC_WRITE |\ + ENLISTMENT_GENERIC_EXECUTE) + +typedef enum _TRANSACTION_OUTCOME { + TransactionOutcomeUndetermined = 1, + TransactionOutcomeCommitted, + TransactionOutcomeAborted, +} TRANSACTION_OUTCOME; + + +typedef enum _TRANSACTION_STATE { + TransactionStateNormal = 1, + TransactionStateIndoubt, + TransactionStateCommittedNotify, +} TRANSACTION_STATE; + + +typedef struct _TRANSACTION_BASIC_INFORMATION { + GUID TransactionId; + ULONG State; + ULONG Outcome; +} TRANSACTION_BASIC_INFORMATION, *PTRANSACTION_BASIC_INFORMATION; + +typedef struct _TRANSACTIONMANAGER_BASIC_INFORMATION { + GUID TmIdentity; + LARGE_INTEGER VirtualClock; +} TRANSACTIONMANAGER_BASIC_INFORMATION, *PTRANSACTIONMANAGER_BASIC_INFORMATION; + +typedef struct _TRANSACTIONMANAGER_LOG_INFORMATION { + GUID LogIdentity; +} TRANSACTIONMANAGER_LOG_INFORMATION, *PTRANSACTIONMANAGER_LOG_INFORMATION; + +typedef struct _TRANSACTIONMANAGER_LOGPATH_INFORMATION { + ULONG LogPathLength; + WCHAR LogPath[1]; +} TRANSACTIONMANAGER_LOGPATH_INFORMATION, *PTRANSACTIONMANAGER_LOGPATH_INFORMATION; + +typedef struct _TRANSACTIONMANAGER_RECOVERY_INFORMATION { + ULONGLONG LastRecoveredLsn; +} TRANSACTIONMANAGER_RECOVERY_INFORMATION, *PTRANSACTIONMANAGER_RECOVERY_INFORMATION; + +typedef struct _TRANSACTION_PROPERTIES_INFORMATION { + ULONG IsolationLevel; + ULONG IsolationFlags; + LARGE_INTEGER Timeout; + ULONG Outcome; + ULONG DescriptionLength; + WCHAR Description[1]; +} TRANSACTION_PROPERTIES_INFORMATION, *PTRANSACTION_PROPERTIES_INFORMATION; + +typedef struct _TRANSACTION_BIND_INFORMATION { + HANDLE TmHandle; +} TRANSACTION_BIND_INFORMATION, *PTRANSACTION_BIND_INFORMATION; + +typedef struct _TRANSACTION_ENLISTMENT_PAIR { + GUID EnlistmentId; + GUID ResourceManagerId; +} TRANSACTION_ENLISTMENT_PAIR, *PTRANSACTION_ENLISTMENT_PAIR; + +typedef struct _TRANSACTION_ENLISTMENTS_INFORMATION { + ULONG NumberOfEnlistments; + TRANSACTION_ENLISTMENT_PAIR EnlistmentPair[1]; +} TRANSACTION_ENLISTMENTS_INFORMATION, *PTRANSACTION_ENLISTMENTS_INFORMATION; + +typedef struct _TRANSACTION_SUPERIOR_ENLISTMENT_INFORMATION { + TRANSACTION_ENLISTMENT_PAIR SuperiorEnlistmentPair; +} TRANSACTION_SUPERIOR_ENLISTMENT_INFORMATION, *PTRANSACTION_SUPERIOR_ENLISTMENT_INFORMATION; + +typedef struct _RESOURCEMANAGER_BASIC_INFORMATION { + GUID ResourceManagerId; + ULONG DescriptionLength; + WCHAR Description[1]; +} RESOURCEMANAGER_BASIC_INFORMATION, *PRESOURCEMANAGER_BASIC_INFORMATION; + +typedef struct _RESOURCEMANAGER_COMPLETION_INFORMATION { + HANDLE IoCompletionPortHandle; + ULONG_PTR CompletionKey; +} RESOURCEMANAGER_COMPLETION_INFORMATION, *PRESOURCEMANAGER_COMPLETION_INFORMATION; + +typedef enum _KTMOBJECT_TYPE { + KTMOBJECT_TRANSACTION, + KTMOBJECT_TRANSACTION_MANAGER, + KTMOBJECT_RESOURCE_MANAGER, + KTMOBJECT_ENLISTMENT, + KTMOBJECT_INVALID +} KTMOBJECT_TYPE, *PKTMOBJECT_TYPE; + +typedef struct _KTMOBJECT_CURSOR { + GUID LastQuery; + ULONG ObjectIdCount; + GUID ObjectIds[1]; +} KTMOBJECT_CURSOR, *PKTMOBJECT_CURSOR; + +typedef enum _TRANSACTION_INFORMATION_CLASS { + TransactionBasicInformation, + TransactionPropertiesInformation, + TransactionEnlistmentInformation, + TransactionSuperiorEnlistmentInformation +} TRANSACTION_INFORMATION_CLASS; + +typedef enum _TRANSACTIONMANAGER_INFORMATION_CLASS { + TransactionManagerBasicInformation, + TransactionManagerLogInformation, + TransactionManagerLogPathInformation, + TransactionManagerRecoveryInformation = 4 +} TRANSACTIONMANAGER_INFORMATION_CLASS; + +typedef enum _RESOURCEMANAGER_INFORMATION_CLASS { + ResourceManagerBasicInformation, + ResourceManagerCompletionInformation, +} RESOURCEMANAGER_INFORMATION_CLASS; + +typedef struct _ENLISTMENT_BASIC_INFORMATION { + GUID EnlistmentId; + GUID TransactionId; + GUID ResourceManagerId; +} ENLISTMENT_BASIC_INFORMATION, *PENLISTMENT_BASIC_INFORMATION; + +typedef struct _ENLISTMENT_CRM_INFORMATION { + GUID CrmTransactionManagerId; + GUID CrmResourceManagerId; + GUID CrmEnlistmentId; +} ENLISTMENT_CRM_INFORMATION, *PENLISTMENT_CRM_INFORMATION; + +typedef enum _ENLISTMENT_INFORMATION_CLASS { + EnlistmentBasicInformation, + EnlistmentRecoveryInformation, + EnlistmentCrmInformation +} ENLISTMENT_INFORMATION_CLASS; + +typedef struct _TRANSACTION_LIST_ENTRY { +#if defined(__cplusplus) + ::UOW UOW; +#else + UOW UOW; +#endif +} TRANSACTION_LIST_ENTRY, *PTRANSACTION_LIST_ENTRY; + +typedef struct _TRANSACTION_LIST_INFORMATION { + ULONG NumberOfTransactions; + TRANSACTION_LIST_ENTRY TransactionInformation[1]; +} TRANSACTION_LIST_INFORMATION, *PTRANSACTION_LIST_INFORMATION; + +typedef NTSTATUS +(NTAPI *PFN_NT_CREATE_TRANSACTION)( + OUT PHANDLE TransactionHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, + IN LPGUID Uow OPTIONAL, + IN HANDLE TmHandle OPTIONAL, + IN ULONG CreateOptions OPTIONAL, + IN ULONG IsolationLevel OPTIONAL, + IN ULONG IsolationFlags OPTIONAL, + IN PLARGE_INTEGER Timeout OPTIONAL, + IN PUNICODE_STRING Description OPTIONAL); + +typedef NTSTATUS +(NTAPI *PFN_NT_OPEN_TRANSACTION)( + OUT PHANDLE TransactionHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN LPGUID Uow OPTIONAL, + IN HANDLE TmHandle OPTIONAL); + +typedef NTSTATUS +(NTAPI *PFN_NT_QUERY_INFORMATION_TRANSACTION)( + IN HANDLE TransactionHandle, + IN TRANSACTION_INFORMATION_CLASS TransactionInformationClass, + OUT PVOID TransactionInformation, + IN ULONG TransactionInformationLength, + OUT PULONG ReturnLength OPTIONAL); + +typedef NTSTATUS +(NTAPI *PFN_NT_SET_INFORMATION_TRANSACTION)( + IN HANDLE TransactionHandle, + IN TRANSACTION_INFORMATION_CLASS TransactionInformationClass, + IN PVOID TransactionInformation, + IN ULONG TransactionInformationLength); + +typedef NTSTATUS +(NTAPI *PFN_NT_COMMIT_TRANSACTION)( + IN HANDLE TransactionHandle, + IN BOOLEAN Wait); + +typedef NTSTATUS +(NTAPI *PFN_NT_ROLLBACK_TRANSACTION)( + IN HANDLE TransactionHandle, + IN BOOLEAN Wait); + +#if (NTDDI_VERSION >= NTDDI_VISTA) + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtCreateTransactionManager( + OUT PHANDLE TmHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, + IN PUNICODE_STRING LogFileName OPTIONAL, + IN ULONG CreateOptions OPTIONAL, + IN ULONG CommitStrength OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtOpenTransactionManager( + OUT PHANDLE TmHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, + IN PUNICODE_STRING LogFileName OPTIONAL, + IN LPGUID TmIdentity OPTIONAL, + IN ULONG OpenOptions OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtRenameTransactionManager( + IN PUNICODE_STRING LogFileName, + IN LPGUID ExistingTransactionManagerGuid); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtRollforwardTransactionManager( + IN HANDLE TransactionManagerHandle, + IN PLARGE_INTEGER TmVirtualClock OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtRecoverTransactionManager( + IN HANDLE TransactionManagerHandle); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtQueryInformationTransactionManager( + IN HANDLE TransactionManagerHandle, + IN TRANSACTIONMANAGER_INFORMATION_CLASS TransactionManagerInformationClass, + OUT PVOID TransactionManagerInformation, + IN ULONG TransactionManagerInformationLength, + OUT PULONG ReturnLength); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtSetInformationTransactionManager( + IN HANDLE TmHandle OPTIONAL, + IN TRANSACTIONMANAGER_INFORMATION_CLASS TransactionManagerInformationClass, + IN PVOID TransactionManagerInformation, + IN ULONG TransactionManagerInformationLength); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtEnumerateTransactionObject( + IN HANDLE RootObjectHandle OPTIONAL, + IN KTMOBJECT_TYPE QueryType, + IN OUT PKTMOBJECT_CURSOR ObjectCursor, + IN ULONG ObjectCursorLength, + OUT PULONG ReturnLength); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtCreateTransaction( + OUT PHANDLE TransactionHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, + IN LPGUID Uow OPTIONAL, + IN HANDLE TmHandle OPTIONAL, + IN ULONG CreateOptions OPTIONAL, + IN ULONG IsolationLevel OPTIONAL, + IN ULONG IsolationFlags OPTIONAL, + IN PLARGE_INTEGER Timeout OPTIONAL, + IN PUNICODE_STRING Description OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtOpenTransaction( + OUT PHANDLE TransactionHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN LPGUID Uow, + IN HANDLE TmHandle OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtQueryInformationTransaction( + IN HANDLE TransactionHandle, + IN TRANSACTION_INFORMATION_CLASS TransactionInformationClass, + OUT PVOID TransactionInformation, + IN ULONG TransactionInformationLength, + OUT PULONG ReturnLength OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtSetInformationTransaction( + IN HANDLE TransactionHandle, + IN TRANSACTION_INFORMATION_CLASS TransactionInformationClass, + IN PVOID TransactionInformation, + IN ULONG TransactionInformationLength); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtCommitTransaction( + IN HANDLE TransactionHandle, + IN BOOLEAN Wait); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtRollbackTransaction( + IN HANDLE TransactionHandle, + IN BOOLEAN Wait); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtCreateEnlistment( + OUT PHANDLE EnlistmentHandle, + IN ACCESS_MASK DesiredAccess, + IN HANDLE ResourceManagerHandle, + IN HANDLE TransactionHandle, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, + IN ULONG CreateOptions OPTIONAL, + IN NOTIFICATION_MASK NotificationMask, + IN PVOID EnlistmentKey OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtOpenEnlistment( + OUT PHANDLE EnlistmentHandle, + IN ACCESS_MASK DesiredAccess, + IN HANDLE ResourceManagerHandle, + IN LPGUID EnlistmentGuid, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtQueryInformationEnlistment( + IN HANDLE EnlistmentHandle, + IN ENLISTMENT_INFORMATION_CLASS EnlistmentInformationClass, + OUT PVOID EnlistmentInformation, + IN ULONG EnlistmentInformationLength, + OUT PULONG ReturnLength); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtSetInformationEnlistment( + IN HANDLE EnlistmentHandle OPTIONAL, + IN ENLISTMENT_INFORMATION_CLASS EnlistmentInformationClass, + IN PVOID EnlistmentInformation, + IN ULONG EnlistmentInformationLength); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtRecoverEnlistment( + IN HANDLE EnlistmentHandle, + IN PVOID EnlistmentKey OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtPrePrepareEnlistment( + IN HANDLE EnlistmentHandle, + IN PLARGE_INTEGER TmVirtualClock OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtPrepareEnlistment( + IN HANDLE EnlistmentHandle, + IN PLARGE_INTEGER TmVirtualClock OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtCommitEnlistment( + IN HANDLE EnlistmentHandle, + IN PLARGE_INTEGER TmVirtualClock OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtRollbackEnlistment( + IN HANDLE EnlistmentHandle, + IN PLARGE_INTEGER TmVirtualClock OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtPrePrepareComplete( + IN HANDLE EnlistmentHandle, + IN PLARGE_INTEGER TmVirtualClock OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtPrepareComplete( + IN HANDLE EnlistmentHandle, + IN PLARGE_INTEGER TmVirtualClock OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtCommitComplete( + IN HANDLE EnlistmentHandle, + IN PLARGE_INTEGER TmVirtualClock OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtReadOnlyEnlistment( + IN HANDLE EnlistmentHandle, + IN PLARGE_INTEGER TmVirtualClock OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtRollbackComplete( + IN HANDLE EnlistmentHandle, + IN PLARGE_INTEGER TmVirtualClock OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtSinglePhaseReject( + IN HANDLE EnlistmentHandle, + IN PLARGE_INTEGER TmVirtualClock OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtCreateResourceManager( + OUT PHANDLE ResourceManagerHandle, + IN ACCESS_MASK DesiredAccess, + IN HANDLE TmHandle, + IN LPGUID RmGuid, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, + IN ULONG CreateOptions OPTIONAL, + IN PUNICODE_STRING Description OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtOpenResourceManager( + OUT PHANDLE ResourceManagerHandle, + IN ACCESS_MASK DesiredAccess, + IN HANDLE TmHandle, + IN LPGUID ResourceManagerGuid OPTIONAL, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtRecoverResourceManager( + IN HANDLE ResourceManagerHandle); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtGetNotificationResourceManager( + IN HANDLE ResourceManagerHandle, + OUT PTRANSACTION_NOTIFICATION TransactionNotification, + IN ULONG NotificationLength, + IN PLARGE_INTEGER Timeout OPTIONAL, + OUT PULONG ReturnLength OPTIONAL, + IN ULONG Asynchronous, + IN ULONG_PTR AsynchronousContext OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtQueryInformationResourceManager( + IN HANDLE ResourceManagerHandle, + IN RESOURCEMANAGER_INFORMATION_CLASS ResourceManagerInformationClass, + OUT PVOID ResourceManagerInformation, + IN ULONG ResourceManagerInformationLength, + OUT PULONG ReturnLength OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtSetInformationResourceManager( + IN HANDLE ResourceManagerHandle, + IN RESOURCEMANAGER_INFORMATION_CLASS ResourceManagerInformationClass, + IN PVOID ResourceManagerInformation, + IN ULONG ResourceManagerInformationLength); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtRegisterProtocolAddressInformation( + IN HANDLE ResourceManager, + IN PCRM_PROTOCOL_ID ProtocolId, + IN ULONG ProtocolInformationSize, + IN PVOID ProtocolInformation, + IN ULONG CreateOptions OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtPropagationComplete( + IN HANDLE ResourceManagerHandle, + IN ULONG RequestCookie, + IN ULONG BufferLength, + IN PVOID Buffer); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtPropagationFailed( + IN HANDLE ResourceManagerHandle, + IN ULONG RequestCookie, + IN NTSTATUS PropStatus); + +#endif /* NTDDI_VERSION >= NTDDI_VISTA */ + +#endif /* !_NTTMAPI_ */ +$endif diff --git a/reactos/include/xdk/obfuncs.h b/reactos/include/xdk/obfuncs.h new file mode 100644 index 00000000000..40912fa411c --- /dev/null +++ b/reactos/include/xdk/obfuncs.h @@ -0,0 +1,141 @@ +/****************************************************************************** + * Object Manager Functions * + ******************************************************************************/ + +$if (_WDMDDK_) +#if (NTDDI_VERSION >= NTDDI_WIN2K) + +NTKERNELAPI +LONG_PTR +FASTCALL +ObfDereferenceObject( + IN PVOID Object); +#define ObDereferenceObject ObfDereferenceObject + +NTKERNELAPI +NTSTATUS +NTAPI +ObGetObjectSecurity( + IN PVOID Object, + OUT PSECURITY_DESCRIPTOR *SecurityDescriptor, + OUT PBOOLEAN MemoryAllocated); + +NTKERNELAPI +LONG_PTR +FASTCALL +ObfReferenceObject( + IN PVOID Object); +#define ObReferenceObject ObfReferenceObject + +NTKERNELAPI +NTSTATUS +NTAPI +ObReferenceObjectByHandle( + IN HANDLE Handle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_TYPE ObjectType OPTIONAL, + IN KPROCESSOR_MODE AccessMode, + OUT PVOID *Object, + OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +ObReferenceObjectByPointer( + IN PVOID Object, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_TYPE ObjectType OPTIONAL, + IN KPROCESSOR_MODE AccessMode); + +NTKERNELAPI +VOID +NTAPI +ObReleaseObjectSecurity( + IN PSECURITY_DESCRIPTOR SecurityDescriptor, + IN BOOLEAN MemoryAllocated); + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ + +#if (NTDDI_VERSION >= NTDDI_VISTA) +NTKERNELAPI +VOID +NTAPI +ObDereferenceObjectDeferDelete( + IN PVOID Object); +#endif + +#if (NTDDI_VERSION >= NTDDI_VISTASP1) +NTKERNELAPI +NTSTATUS +NTAPI +ObRegisterCallbacks( + IN POB_CALLBACK_REGISTRATION CallbackRegistration, + OUT PVOID *RegistrationHandle); + +NTKERNELAPI +VOID +NTAPI +ObUnRegisterCallbacks( + IN PVOID RegistrationHandle); + +NTKERNELAPI +USHORT +NTAPI +ObGetFilterVersion(VOID); + +#endif /* (NTDDI_VERSION >= NTDDI_VISTASP1) */ + +#if (NTDDI_VERSION >= NTDDI_WIN7) + +NTKERNELAPI +NTSTATUS +NTAPI +ObReferenceObjectByHandleWithTag( + IN HANDLE Handle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_TYPE ObjectType OPTIONAL, + IN KPROCESSOR_MODE AccessMode, + IN ULONG Tag, + OUT PVOID *Object, + OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL); + +NTKERNELAPI +LONG_PTR +FASTCALL +ObfReferenceObjectWithTag( + IN PVOID Object, + IN ULONG Tag); + +NTKERNELAPI +NTSTATUS +NTAPI +ObReferenceObjectByPointerWithTag( + IN PVOID Object, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_TYPE ObjectType OPTIONAL, + IN KPROCESSOR_MODE AccessMode, + IN ULONG Tag); + +NTKERNELAPI +LONG_PTR +FASTCALL +ObfDereferenceObjectWithTag( + IN PVOID Object, + IN ULONG Tag); + +NTKERNELAPI +VOID +NTAPI +ObDereferenceObjectDeferDeleteWithTag( + IN PVOID Object, + IN ULONG Tag); + +#define ObDereferenceObject ObfDereferenceObject +#define ObReferenceObject ObfReferenceObject +#define ObDereferenceObjectWithTag ObfDereferenceObjectWithTag +#define ObReferenceObjectWithTag ObfReferenceObjectWithTag + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + +$endif + diff --git a/reactos/include/xdk/obtypes.h b/reactos/include/xdk/obtypes.h new file mode 100644 index 00000000000..84310a968db --- /dev/null +++ b/reactos/include/xdk/obtypes.h @@ -0,0 +1,135 @@ +/****************************************************************************** + * Object Manager Types * + ******************************************************************************/ + +#define MAXIMUM_FILENAME_LENGTH 256 +#define OBJ_NAME_PATH_SEPARATOR ((WCHAR)L'\\') + +#define OBJECT_TYPE_CREATE 0x0001 +#define OBJECT_TYPE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0x1) + +#define DIRECTORY_QUERY 0x0001 +#define DIRECTORY_TRAVERSE 0x0002 +#define DIRECTORY_CREATE_OBJECT 0x0004 +#define DIRECTORY_CREATE_SUBDIRECTORY 0x0008 +#define DIRECTORY_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0xF) + +#define SYMBOLIC_LINK_QUERY 0x0001 +#define SYMBOLIC_LINK_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0x1) + +#define DUPLICATE_CLOSE_SOURCE 0x00000001 +#define DUPLICATE_SAME_ACCESS 0x00000002 +#define DUPLICATE_SAME_ATTRIBUTES 0x00000004 + +#define OB_FLT_REGISTRATION_VERSION_0100 0x0100 +#define OB_FLT_REGISTRATION_VERSION OB_FLT_REGISTRATION_VERSION_0100 + +typedef ULONG OB_OPERATION; + +#define OB_OPERATION_HANDLE_CREATE 0x00000001 +#define OB_OPERATION_HANDLE_DUPLICATE 0x00000002 + +typedef struct _OB_PRE_CREATE_HANDLE_INFORMATION { + IN OUT ACCESS_MASK DesiredAccess; + IN ACCESS_MASK OriginalDesiredAccess; +} OB_PRE_CREATE_HANDLE_INFORMATION, *POB_PRE_CREATE_HANDLE_INFORMATION; + +typedef struct _OB_PRE_DUPLICATE_HANDLE_INFORMATION { + IN OUT ACCESS_MASK DesiredAccess; + IN ACCESS_MASK OriginalDesiredAccess; + IN PVOID SourceProcess; + IN PVOID TargetProcess; +} OB_PRE_DUPLICATE_HANDLE_INFORMATION, *POB_PRE_DUPLICATE_HANDLE_INFORMATION; + +typedef union _OB_PRE_OPERATION_PARAMETERS { + IN OUT OB_PRE_CREATE_HANDLE_INFORMATION CreateHandleInformation; + IN OUT OB_PRE_DUPLICATE_HANDLE_INFORMATION DuplicateHandleInformation; +} OB_PRE_OPERATION_PARAMETERS, *POB_PRE_OPERATION_PARAMETERS; + +typedef struct _OB_PRE_OPERATION_INFORMATION { + IN OB_OPERATION Operation; + union { + IN ULONG Flags; + struct { + IN ULONG KernelHandle:1; + IN ULONG Reserved:31; + }; + }; + IN PVOID Object; + IN POBJECT_TYPE ObjectType; + OUT PVOID CallContext; + IN POB_PRE_OPERATION_PARAMETERS Parameters; +} OB_PRE_OPERATION_INFORMATION, *POB_PRE_OPERATION_INFORMATION; + +typedef struct _OB_POST_CREATE_HANDLE_INFORMATION { + IN ACCESS_MASK GrantedAccess; +} OB_POST_CREATE_HANDLE_INFORMATION, *POB_POST_CREATE_HANDLE_INFORMATION; + +typedef struct _OB_POST_DUPLICATE_HANDLE_INFORMATION { + IN ACCESS_MASK GrantedAccess; +} OB_POST_DUPLICATE_HANDLE_INFORMATION, *POB_POST_DUPLICATE_HANDLE_INFORMATION; + +typedef union _OB_POST_OPERATION_PARAMETERS { + IN OB_POST_CREATE_HANDLE_INFORMATION CreateHandleInformation; + IN OB_POST_DUPLICATE_HANDLE_INFORMATION DuplicateHandleInformation; +} OB_POST_OPERATION_PARAMETERS, *POB_POST_OPERATION_PARAMETERS; + +typedef struct _OB_POST_OPERATION_INFORMATION { + IN OB_OPERATION Operation; + union { + IN ULONG Flags; + struct { + IN ULONG KernelHandle:1; + IN ULONG Reserved:31; + }; + }; + IN PVOID Object; + IN POBJECT_TYPE ObjectType; + IN PVOID CallContext; + IN NTSTATUS ReturnStatus; + IN POB_POST_OPERATION_PARAMETERS Parameters; +} OB_POST_OPERATION_INFORMATION,*POB_POST_OPERATION_INFORMATION; + +typedef enum _OB_PREOP_CALLBACK_STATUS { + OB_PREOP_SUCCESS +} OB_PREOP_CALLBACK_STATUS, *POB_PREOP_CALLBACK_STATUS; + +typedef OB_PREOP_CALLBACK_STATUS +(NTAPI *POB_PRE_OPERATION_CALLBACK)( + IN PVOID RegistrationContext, + IN OUT POB_PRE_OPERATION_INFORMATION OperationInformation); + +typedef VOID +(NTAPI *POB_POST_OPERATION_CALLBACK)( + IN PVOID RegistrationContext, + IN POB_POST_OPERATION_INFORMATION OperationInformation); + +typedef struct _OB_OPERATION_REGISTRATION { + IN POBJECT_TYPE *ObjectType; + IN OB_OPERATION Operations; + IN POB_PRE_OPERATION_CALLBACK PreOperation; + IN POB_POST_OPERATION_CALLBACK PostOperation; +} OB_OPERATION_REGISTRATION, *POB_OPERATION_REGISTRATION; + +typedef struct _OB_CALLBACK_REGISTRATION { + IN USHORT Version; + IN USHORT OperationRegistrationCount; + IN UNICODE_STRING Altitude; + IN PVOID RegistrationContext; + IN OB_OPERATION_REGISTRATION *OperationRegistration; +} OB_CALLBACK_REGISTRATION, *POB_CALLBACK_REGISTRATION; + +typedef struct _OBJECT_NAME_INFORMATION { + UNICODE_STRING Name; +} OBJECT_NAME_INFORMATION, *POBJECT_NAME_INFORMATION; + +/* Exported object types */ +extern POBJECT_TYPE NTSYSAPI CmKeyObjectType; +extern POBJECT_TYPE NTSYSAPI ExEventObjectType; +extern POBJECT_TYPE NTSYSAPI ExSemaphoreObjectType; +extern POBJECT_TYPE NTSYSAPI IoFileObjectType; +extern POBJECT_TYPE NTSYSAPI PsThreadType; +extern POBJECT_TYPE NTSYSAPI SeTokenObjectType; +extern POBJECT_TYPE NTSYSAPI PsProcessType; + + diff --git a/reactos/include/xdk/pofuncs.h b/reactos/include/xdk/pofuncs.h new file mode 100644 index 00000000000..9fd1ec6d2b0 --- /dev/null +++ b/reactos/include/xdk/pofuncs.h @@ -0,0 +1,167 @@ +/****************************************************************************** + * Power Management Support Functions * + ******************************************************************************/ + +#define PoSetDeviceBusy(IdlePointer) ((void)(*(IdlePointer) = 0)) + +#if (NTDDI_VERSION >= NTDDI_WIN2K) + +NTKERNELAPI +NTSTATUS +NTAPI +PoCallDriver( + IN struct _DEVICE_OBJECT *DeviceObject, + IN OUT struct _IRP *Irp); + +NTKERNELAPI +PULONG +NTAPI +PoRegisterDeviceForIdleDetection( + IN struct _DEVICE_OBJECT *DeviceObject, + IN ULONG ConservationIdleTime, + IN ULONG PerformanceIdleTime, + IN DEVICE_POWER_STATE State); + +NTKERNELAPI +PVOID +NTAPI +PoRegisterSystemState( + IN OUT PVOID StateHandle OPTIONAL, + IN EXECUTION_STATE Flags); + +NTKERNELAPI +NTSTATUS +NTAPI +PoRequestPowerIrp( + IN struct _DEVICE_OBJECT *DeviceObject, + IN UCHAR MinorFunction, + IN POWER_STATE PowerState, + IN PREQUEST_POWER_COMPLETE CompletionFunction OPTIONAL, + IN PVOID Context OPTIONAL, + OUT struct _IRP **Irp OPTIONAL); + +NTKERNELAPI +POWER_STATE +NTAPI +PoSetPowerState( + IN struct _DEVICE_OBJECT *DeviceObject, + IN POWER_STATE_TYPE Type, + IN POWER_STATE State); + +NTKERNELAPI +VOID +NTAPI +PoSetSystemState( + IN EXECUTION_STATE Flags); + +NTKERNELAPI +VOID +NTAPI +PoStartNextPowerIrp( + IN OUT struct _IRP *Irp); + +NTKERNELAPI +VOID +NTAPI +PoUnregisterSystemState( + IN OUT PVOID StateHandle); + +NTKERNELAPI +NTSTATUS +NTAPI +PoRequestShutdownEvent( + OUT PVOID *Event); + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ + +#if (NTDDI_VERSION >= NTDDI_VISTA) + +NTKERNELAPI +VOID +NTAPI +PoSetSystemWake( + IN OUT struct _IRP *Irp); + +NTKERNELAPI +BOOLEAN +NTAPI +PoGetSystemWake( + IN struct _IRP *Irp); + +NTKERNELAPI +NTSTATUS +NTAPI +PoRegisterPowerSettingCallback( + IN PDEVICE_OBJECT DeviceObject OPTIONAL, + IN LPCGUID SettingGuid, + IN PPOWER_SETTING_CALLBACK Callback, + IN PVOID Context OPTIONAL, + OUT PVOID *Handle OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +PoUnregisterPowerSettingCallback( + IN OUT PVOID Handle); + +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + +#if (NTDDI_VERSION >= NTDDI_VISTASP1) +NTKERNELAPI +VOID +NTAPI +PoSetDeviceBusyEx( + IN OUT PULONG IdlePointer); +#endif /* (NTDDI_VERSION >= NTDDI_VISTASP1) */ + +#if (NTDDI_VERSION >= NTDDI_WIN7) + +NTKERNELAPI +VOID +NTAPI +PoStartDeviceBusy( + IN OUT PULONG IdlePointer); + +NTKERNELAPI +VOID +NTAPI +PoEndDeviceBusy( + IN OUT PULONG IdlePointer); + +NTKERNELAPI +BOOLEAN +NTAPI +PoQueryWatchdogTime( + IN PDEVICE_OBJECT Pdo, + OUT PULONG SecondsRemaining); + +NTKERNELAPI +VOID +NTAPI +PoDeletePowerRequest( + IN OUT PVOID PowerRequest); + +NTKERNELAPI +NTSTATUS +NTAPI +PoSetPowerRequest( + IN OUT PVOID PowerRequest, + IN POWER_REQUEST_TYPE Type); + +NTKERNELAPI +NTSTATUS +NTAPI +PoClearPowerRequest( + IN OUT PVOID PowerRequest, + IN POWER_REQUEST_TYPE Type); + +NTKERNELAPI +NTSTATUS +NTAPI +PoCreatePowerRequest( + OUT PVOID *PowerRequest, + IN PDEVICE_OBJECT DeviceObject, + IN PCOUNTED_REASON_CONTEXT Context); + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + diff --git a/reactos/include/xdk/potypes.h b/reactos/include/xdk/potypes.h new file mode 100644 index 00000000000..3caf8254d55 --- /dev/null +++ b/reactos/include/xdk/potypes.h @@ -0,0 +1,412 @@ +/****************************************************************************** + * Power Management Support Types * + ******************************************************************************/ + +#ifndef _PO_DDK_ +#define _PO_DDK_ + +#define PO_CB_SYSTEM_POWER_POLICY 0 +#define PO_CB_AC_STATUS 1 +#define PO_CB_BUTTON_COLLISION 2 +#define PO_CB_SYSTEM_STATE_LOCK 3 +#define PO_CB_LID_SWITCH_STATE 4 +#define PO_CB_PROCESSOR_POWER_POLICY 5 + +/* Power States/Levels */ +typedef enum _SYSTEM_POWER_STATE { + PowerSystemUnspecified = 0, + PowerSystemWorking, + PowerSystemSleeping1, + PowerSystemSleeping2, + PowerSystemSleeping3, + PowerSystemHibernate, + PowerSystemShutdown, + PowerSystemMaximum +} SYSTEM_POWER_STATE, *PSYSTEM_POWER_STATE; + +#define POWER_SYSTEM_MAXIMUM PowerSystemMaximum + +typedef enum _POWER_INFORMATION_LEVEL { + SystemPowerPolicyAc, + SystemPowerPolicyDc, + VerifySystemPolicyAc, + VerifySystemPolicyDc, + SystemPowerCapabilities, + SystemBatteryState, + SystemPowerStateHandler, + ProcessorStateHandler, + SystemPowerPolicyCurrent, + AdministratorPowerPolicy, + SystemReserveHiberFile, + ProcessorInformation, + SystemPowerInformation, + ProcessorStateHandler2, + LastWakeTime, + LastSleepTime, + SystemExecutionState, + SystemPowerStateNotifyHandler, + ProcessorPowerPolicyAc, + ProcessorPowerPolicyDc, + VerifyProcessorPowerPolicyAc, + VerifyProcessorPowerPolicyDc, + ProcessorPowerPolicyCurrent, + SystemPowerStateLogging, + SystemPowerLoggingEntry, + SetPowerSettingValue, + NotifyUserPowerSetting, + PowerInformationLevelUnused0, + PowerInformationLevelUnused1, + SystemVideoState, + TraceApplicationPowerMessage, + TraceApplicationPowerMessageEnd, + ProcessorPerfStates, + ProcessorIdleStates, + ProcessorCap, + SystemWakeSource, + SystemHiberFileInformation, + TraceServicePowerMessage, + ProcessorLoad, + PowerShutdownNotification, + MonitorCapabilities, + SessionPowerInit, + SessionDisplayState, + PowerRequestCreate, + PowerRequestAction, + GetPowerRequestList, + ProcessorInformationEx, + NotifyUserModeLegacyPowerEvent, + GroupPark, + ProcessorIdleDomains, + WakeTimerList, + SystemHiberFileSize, + PowerInformationLevelMaximum +} POWER_INFORMATION_LEVEL; + +typedef enum { + PowerActionNone = 0, + PowerActionReserved, + PowerActionSleep, + PowerActionHibernate, + PowerActionShutdown, + PowerActionShutdownReset, + PowerActionShutdownOff, + PowerActionWarmEject +} POWER_ACTION, *PPOWER_ACTION; + +typedef enum _DEVICE_POWER_STATE { + PowerDeviceUnspecified = 0, + PowerDeviceD0, + PowerDeviceD1, + PowerDeviceD2, + PowerDeviceD3, + PowerDeviceMaximum +} DEVICE_POWER_STATE, *PDEVICE_POWER_STATE; + +typedef enum _MONITOR_DISPLAY_STATE { + PowerMonitorOff = 0, + PowerMonitorOn, + PowerMonitorDim +} MONITOR_DISPLAY_STATE, *PMONITOR_DISPLAY_STATE; + +typedef union _POWER_STATE { + SYSTEM_POWER_STATE SystemState; + DEVICE_POWER_STATE DeviceState; +} POWER_STATE, *PPOWER_STATE; + +typedef enum _POWER_STATE_TYPE { + SystemPowerState = 0, + DevicePowerState +} POWER_STATE_TYPE, *PPOWER_STATE_TYPE; + +#if (NTDDI_VERSION >= NTDDI_VISTA) +typedef struct _SYSTEM_POWER_STATE_CONTEXT { + union { + struct { + ULONG Reserved1:8; + ULONG TargetSystemState:4; + ULONG EffectiveSystemState:4; + ULONG CurrentSystemState:4; + ULONG IgnoreHibernationPath:1; + ULONG PseudoTransition:1; + ULONG Reserved2:10; + } DUMMYSTRUCTNAME; + ULONG ContextAsUlong; + } DUMMYUNIONNAME; +} SYSTEM_POWER_STATE_CONTEXT, *PSYSTEM_POWER_STATE_CONTEXT; +#endif + +#if (NTDDI_VERSION >= NTDDI_WIN7) +typedef struct _COUNTED_REASON_CONTEXT { + ULONG Version; + ULONG Flags; + union { + struct { + UNICODE_STRING ResourceFileName; + USHORT ResourceReasonId; + ULONG StringCount; + PUNICODE_STRING ReasonStrings; + } DUMMYSTRUCTNAME; + UNICODE_STRING SimpleString; + } DUMMYUNIONNAME; +} COUNTED_REASON_CONTEXT, *PCOUNTED_REASON_CONTEXT; +#endif + +#define IOCTL_QUERY_DEVICE_POWER_STATE \ + CTL_CODE(FILE_DEVICE_BATTERY, 0x0, METHOD_BUFFERED, FILE_READ_ACCESS) + +#define IOCTL_SET_DEVICE_WAKE \ + CTL_CODE(FILE_DEVICE_BATTERY, 0x1, METHOD_BUFFERED, FILE_WRITE_ACCESS) + +#define IOCTL_CANCEL_DEVICE_WAKE \ + CTL_CODE(FILE_DEVICE_BATTERY, 0x2, METHOD_BUFFERED, FILE_WRITE_ACCESS) + +#define ES_SYSTEM_REQUIRED 0x00000001 +#define ES_DISPLAY_REQUIRED 0x00000002 +#define ES_USER_PRESENT 0x00000004 +#define ES_CONTINUOUS 0x80000000 + +typedef ULONG EXECUTION_STATE, *PEXECUTION_STATE; + +typedef enum { + LT_DONT_CARE, + LT_LOWEST_LATENCY +} LATENCY_TIME; + +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN7) +#define DIAGNOSTIC_REASON_VERSION 0 +#define DIAGNOSTIC_REASON_SIMPLE_STRING 0x00000001 +#define DIAGNOSTIC_REASON_DETAILED_STRING 0x00000002 +#define DIAGNOSTIC_REASON_NOT_SPECIFIED 0x80000000 +#define DIAGNOSTIC_REASON_INVALID_FLAGS (~0x80000003) +#endif + +#define POWER_REQUEST_CONTEXT_VERSION 0 +#define POWER_REQUEST_CONTEXT_SIMPLE_STRING 0x00000001 +#define POWER_REQUEST_CONTEXT_DETAILED_STRING 0x00000002 + +#define PowerRequestMaximum 3 + +typedef enum _POWER_REQUEST_TYPE { + PowerRequestDisplayRequired, + PowerRequestSystemRequired, + PowerRequestAwayModeRequired +} POWER_REQUEST_TYPE, *PPOWER_REQUEST_TYPE; + +#if (NTDDI_VERSION >= NTDDI_WINXP) + +#define PDCAP_D0_SUPPORTED 0x00000001 +#define PDCAP_D1_SUPPORTED 0x00000002 +#define PDCAP_D2_SUPPORTED 0x00000004 +#define PDCAP_D3_SUPPORTED 0x00000008 +#define PDCAP_WAKE_FROM_D0_SUPPORTED 0x00000010 +#define PDCAP_WAKE_FROM_D1_SUPPORTED 0x00000020 +#define PDCAP_WAKE_FROM_D2_SUPPORTED 0x00000040 +#define PDCAP_WAKE_FROM_D3_SUPPORTED 0x00000080 +#define PDCAP_WARM_EJECT_SUPPORTED 0x00000100 + +typedef struct CM_Power_Data_s { + ULONG PD_Size; + DEVICE_POWER_STATE PD_MostRecentPowerState; + ULONG PD_Capabilities; + ULONG PD_D1Latency; + ULONG PD_D2Latency; + ULONG PD_D3Latency; + DEVICE_POWER_STATE PD_PowerStateMapping[PowerSystemMaximum]; + SYSTEM_POWER_STATE PD_DeepestSystemWake; +} CM_POWER_DATA, *PCM_POWER_DATA; + +#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ + +typedef enum _SYSTEM_POWER_CONDITION { + PoAc, + PoDc, + PoHot, + PoConditionMaximum +} SYSTEM_POWER_CONDITION; + +typedef struct _SET_POWER_SETTING_VALUE { + ULONG Version; + GUID Guid; + SYSTEM_POWER_CONDITION PowerCondition; + ULONG DataLength; + UCHAR Data[ANYSIZE_ARRAY]; +} SET_POWER_SETTING_VALUE, *PSET_POWER_SETTING_VALUE; + +#define POWER_SETTING_VALUE_VERSION (0x1) + +typedef struct _NOTIFY_USER_POWER_SETTING { + GUID Guid; +} NOTIFY_USER_POWER_SETTING, *PNOTIFY_USER_POWER_SETTING; + +typedef struct _APPLICATIONLAUNCH_SETTING_VALUE { + LARGE_INTEGER ActivationTime; + ULONG Flags; + ULONG ButtonInstanceID; +} APPLICATIONLAUNCH_SETTING_VALUE, *PAPPLICATIONLAUNCH_SETTING_VALUE; + +typedef enum _POWER_PLATFORM_ROLE { + PlatformRoleUnspecified = 0, + PlatformRoleDesktop, + PlatformRoleMobile, + PlatformRoleWorkstation, + PlatformRoleEnterpriseServer, + PlatformRoleSOHOServer, + PlatformRoleAppliancePC, + PlatformRolePerformanceServer, + PlatformRoleMaximum +} POWER_PLATFORM_ROLE; + +#if (NTDDI_VERSION >= NTDDI_WINXP) || !defined(_BATCLASS_) +typedef struct { + ULONG Granularity; + ULONG Capacity; +} BATTERY_REPORTING_SCALE, *PBATTERY_REPORTING_SCALE; +#endif /* (NTDDI_VERSION >= NTDDI_WINXP) || !defined(_BATCLASS_) */ + +#endif /* !_PO_DDK_ */ + +#define CORE_PARKING_POLICY_CHANGE_IDEAL 0 +#define CORE_PARKING_POLICY_CHANGE_SINGLE 1 +#define CORE_PARKING_POLICY_CHANGE_ROCKET 2 +#define CORE_PARKING_POLICY_CHANGE_MAX CORE_PARKING_POLICY_CHANGE_ROCKET + +DEFINE_GUID(GUID_MAX_POWER_SAVINGS, 0xA1841308, 0x3541, 0x4FAB, 0xBC, 0x81, 0xF7, 0x15, 0x56, 0xF2, 0x0B, 0x4A ); +DEFINE_GUID(GUID_MIN_POWER_SAVINGS, 0x8C5E7FDA, 0xE8BF, 0x4A96, 0x9A, 0x85, 0xA6, 0xE2, 0x3A, 0x8C, 0x63, 0x5C ); +DEFINE_GUID(GUID_TYPICAL_POWER_SAVINGS, 0x381B4222, 0xF694, 0x41F0, 0x96, 0x85, 0xFF, 0x5B, 0xB2, 0x60, 0xDF, 0x2E ); +DEFINE_GUID(NO_SUBGROUP_GUID, 0xFEA3413E, 0x7E05, 0x4911, 0x9A, 0x71, 0x70, 0x03, 0x31, 0xF1, 0xC2, 0x94 ); +DEFINE_GUID(ALL_POWERSCHEMES_GUID, 0x68A1E95E, 0x13EA, 0x41E1, 0x80, 0x11, 0x0C, 0x49, 0x6C, 0xA4, 0x90, 0xB0 ); +DEFINE_GUID(GUID_POWERSCHEME_PERSONALITY, 0x245D8541, 0x3943, 0x4422, 0xB0, 0x25, 0x13, 0xA7, 0x84, 0xF6, 0x79, 0xB7 ); +DEFINE_GUID(GUID_ACTIVE_POWERSCHEME, 0x31F9F286, 0x5084, 0x42FE, 0xB7, 0x20, 0x2B, 0x02, 0x64, 0x99, 0x37, 0x63 ); +DEFINE_GUID(GUID_VIDEO_SUBGROUP, 0x7516B95F, 0xF776, 0x4464, 0x8C, 0x53, 0x06, 0x16, 0x7F, 0x40, 0xCC, 0x99 ); +DEFINE_GUID(GUID_VIDEO_POWERDOWN_TIMEOUT, 0x3C0BC021, 0xC8A8, 0x4E07, 0xA9, 0x73, 0x6B, 0x14, 0xCB, 0xCB, 0x2B, 0x7E ); +DEFINE_GUID(GUID_VIDEO_ANNOYANCE_TIMEOUT, 0x82DBCF2D, 0xCD67, 0x40C5, 0xBF, 0xDC, 0x9F, 0x1A, 0x5C, 0xCD, 0x46, 0x63 ); +DEFINE_GUID(GUID_VIDEO_ADAPTIVE_PERCENT_INCREASE, 0xEED904DF, 0xB142, 0x4183, 0xB1, 0x0B, 0x5A, 0x11, 0x97, 0xA3, 0x78, 0x64 ); +DEFINE_GUID(GUID_VIDEO_DIM_TIMEOUT, 0x17aaa29b, 0x8b43, 0x4b94, 0xaa, 0xfe, 0x35, 0xf6, 0x4d, 0xaa, 0xf1, 0xee); +DEFINE_GUID(GUID_VIDEO_ADAPTIVE_POWERDOWN, 0x90959D22, 0xD6A1, 0x49B9, 0xAF, 0x93, 0xBC, 0xE8, 0x85, 0xAD, 0x33, 0x5B ); +DEFINE_GUID(GUID_MONITOR_POWER_ON, 0x02731015, 0x4510, 0x4526, 0x99, 0xE6, 0xE5, 0xA1, 0x7E, 0xBD, 0x1A, 0xEA ); +DEFINE_GUID(GUID_DEVICE_POWER_POLICY_VIDEO_BRIGHTNESS, 0xaded5e82L, 0xb909, 0x4619, 0x99, 0x49, 0xf5, 0xd7, 0x1d, 0xac, 0x0b, 0xcb); +DEFINE_GUID(GUID_DEVICE_POWER_POLICY_VIDEO_DIM_BRIGHTNESS, 0xf1fbfde2, 0xa960, 0x4165, 0x9f, 0x88, 0x50, 0x66, 0x79, 0x11, 0xce, 0x96); +DEFINE_GUID(GUID_VIDEO_CURRENT_MONITOR_BRIGHTNESS, 0x8ffee2c6, 0x2d01, 0x46be, 0xad, 0xb9, 0x39, 0x8a, 0xdd, 0xc5, 0xb4, 0xff); +DEFINE_GUID(GUID_VIDEO_ADAPTIVE_DISPLAY_BRIGHTNESS, 0xFBD9AA66, 0x9553, 0x4097, 0xBA, 0x44, 0xED, 0x6E, 0x9D, 0x65, 0xEA, 0xB8); +DEFINE_GUID(GUID_SESSION_DISPLAY_STATE, 0x73A5E93A, 0x5BB1, 0x4F93, 0x89, 0x5B, 0xDB, 0xD0, 0xDA, 0x85, 0x59, 0x67 ); +DEFINE_GUID(GUID_CONSOLE_DISPLAY_STATE, 0x6fe69556, 0x704a, 0x47a0, 0x8f, 0x24, 0xc2, 0x8d, 0x93, 0x6f, 0xda, 0x47); +DEFINE_GUID(GUID_ALLOW_DISPLAY_REQUIRED, 0xA9CEB8DA, 0xCD46, 0x44FB, 0xA9, 0x8B, 0x02, 0xAF, 0x69, 0xDE, 0x46, 0x23 ); +DEFINE_GUID(GUID_DISK_SUBGROUP, 0x0012EE47, 0x9041, 0x4B5D, 0x9B, 0x77, 0x53, 0x5F, 0xBA, 0x8B, 0x14, 0x42 ); +DEFINE_GUID(GUID_DISK_POWERDOWN_TIMEOUT, 0x6738E2C4, 0xE8A5, 0x4A42, 0xB1, 0x6A, 0xE0, 0x40, 0xE7, 0x69, 0x75, 0x6E ); +DEFINE_GUID(GUID_DISK_BURST_IGNORE_THRESHOLD, 0x80e3c60e, 0xbb94, 0x4ad8, 0xbb, 0xe0, 0x0d, 0x31, 0x95, 0xef, 0xc6, 0x63 ); +DEFINE_GUID(GUID_DISK_ADAPTIVE_POWERDOWN, 0x396A32E1, 0x499A, 0x40B2, 0x91, 0x24, 0xA9, 0x6A, 0xFE, 0x70, 0x76, 0x67 ); +DEFINE_GUID(GUID_SLEEP_SUBGROUP, 0x238C9FA8, 0x0AAD, 0x41ED, 0x83, 0xF4, 0x97, 0xBE, 0x24, 0x2C, 0x8F, 0x20 ); +DEFINE_GUID(GUID_SLEEP_IDLE_THRESHOLD, 0x81cd32e0, 0x7833, 0x44f3, 0x87, 0x37, 0x70, 0x81, 0xf3, 0x8d, 0x1f, 0x70 ); +DEFINE_GUID(GUID_STANDBY_TIMEOUT, 0x29F6C1DB, 0x86DA, 0x48C5, 0x9F, 0xDB, 0xF2, 0xB6, 0x7B, 0x1F, 0x44, 0xDA ); +DEFINE_GUID(GUID_UNATTEND_SLEEP_TIMEOUT, 0x7bc4a2f9, 0xd8fc, 0x4469, 0xb0, 0x7b, 0x33, 0xeb, 0x78, 0x5a, 0xac, 0xa0 ); +DEFINE_GUID(GUID_HIBERNATE_TIMEOUT, 0x9D7815A6, 0x7EE4, 0x497E, 0x88, 0x88, 0x51, 0x5A, 0x05, 0xF0, 0x23, 0x64 ); +DEFINE_GUID(GUID_HIBERNATE_FASTS4_POLICY, 0x94AC6D29, 0x73CE, 0x41A6, 0x80, 0x9F, 0x63, 0x63, 0xBA, 0x21, 0xB4, 0x7E ); +DEFINE_GUID(GUID_CRITICAL_POWER_TRANSITION, 0xB7A27025, 0xE569, 0x46c2, 0xA5, 0x04, 0x2B, 0x96, 0xCA, 0xD2, 0x25, 0xA1); +DEFINE_GUID(GUID_SYSTEM_AWAYMODE, 0x98A7F580, 0x01F7, 0x48AA, 0x9C, 0x0F, 0x44, 0x35, 0x2C, 0x29, 0xE5, 0xC0 ); +DEFINE_GUID(GUID_ALLOW_AWAYMODE, 0x25dfa149, 0x5dd1, 0x4736, 0xb5, 0xab, 0xe8, 0xa3, 0x7b, 0x5b, 0x81, 0x87 ); +DEFINE_GUID(GUID_ALLOW_STANDBY_STATES, 0xabfc2519, 0x3608, 0x4c2a, 0x94, 0xea, 0x17, 0x1b, 0x0e, 0xd5, 0x46, 0xab ); +DEFINE_GUID(GUID_ALLOW_RTC_WAKE, 0xBD3B718A, 0x0680, 0x4D9D, 0x8A, 0xB2, 0xE1, 0xD2, 0xB4, 0xAC, 0x80, 0x6D ); +DEFINE_GUID(GUID_ALLOW_SYSTEM_REQUIRED, 0xA4B195F5, 0x8225, 0x47D8, 0x80, 0x12, 0x9D, 0x41, 0x36, 0x97, 0x86, 0xE2 ); +DEFINE_GUID(GUID_SYSTEM_BUTTON_SUBGROUP, 0x4F971E89, 0xEEBD, 0x4455, 0xA8, 0xDE, 0x9E, 0x59, 0x04, 0x0E, 0x73, 0x47 ); +DEFINE_GUID(GUID_POWERBUTTON_ACTION, 0x7648EFA3, 0xDD9C, 0x4E3E, 0xB5, 0x66, 0x50, 0xF9, 0x29, 0x38, 0x62, 0x80 ); +DEFINE_GUID(GUID_POWERBUTTON_ACTION_FLAGS, 0x857E7FAC, 0x034B, 0x4704, 0xAB, 0xB1, 0xBC, 0xA5, 0x4A, 0xA3, 0x14, 0x78 ); +DEFINE_GUID(GUID_SLEEPBUTTON_ACTION, 0x96996BC0, 0xAD50, 0x47EC, 0x92, 0x3B, 0x6F, 0x41, 0x87, 0x4D, 0xD9, 0xEB ); +DEFINE_GUID(GUID_SLEEPBUTTON_ACTION_FLAGS, 0x2A160AB1, 0xB69D, 0x4743, 0xB7, 0x18, 0xBF, 0x14, 0x41, 0xD5, 0xE4, 0x93 ); +DEFINE_GUID(GUID_USERINTERFACEBUTTON_ACTION, 0xA7066653, 0x8D6C, 0x40A8, 0x91, 0x0E, 0xA1, 0xF5, 0x4B, 0x84, 0xC7, 0xE5 ); +DEFINE_GUID(GUID_LIDCLOSE_ACTION, 0x5CA83367, 0x6E45, 0x459F, 0xA2, 0x7B, 0x47, 0x6B, 0x1D, 0x01, 0xC9, 0x36 ); +DEFINE_GUID(GUID_LIDCLOSE_ACTION_FLAGS, 0x97E969AC, 0x0D6C, 0x4D08, 0x92, 0x7C, 0xD7, 0xBD, 0x7A, 0xD7, 0x85, 0x7B ); +DEFINE_GUID(GUID_LIDOPEN_POWERSTATE, 0x99FF10E7, 0x23B1, 0x4C07, 0xA9, 0xD1, 0x5C, 0x32, 0x06, 0xD7, 0x41, 0xB4 ); +DEFINE_GUID(GUID_BATTERY_SUBGROUP, 0xE73A048D, 0xBF27, 0x4F12, 0x97, 0x31, 0x8B, 0x20, 0x76, 0xE8, 0x89, 0x1F ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_ACTION_0, 0x637EA02F, 0xBBCB, 0x4015, 0x8E, 0x2C, 0xA1, 0xC7, 0xB9, 0xC0, 0xB5, 0x46 ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_LEVEL_0, 0x9A66D8D7, 0x4FF7, 0x4EF9, 0xB5, 0xA2, 0x5A, 0x32, 0x6C, 0xA2, 0xA4, 0x69 ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_FLAGS_0, 0x5dbb7c9f, 0x38e9, 0x40d2, 0x97, 0x49, 0x4f, 0x8a, 0x0e, 0x9f, 0x64, 0x0f ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_ACTION_1, 0xD8742DCB, 0x3E6A, 0x4B3C, 0xB3, 0xFE, 0x37, 0x46, 0x23, 0xCD, 0xCF, 0x06 ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_LEVEL_1, 0x8183BA9A, 0xE910, 0x48DA, 0x87, 0x69, 0x14, 0xAE, 0x6D, 0xC1, 0x17, 0x0A ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_FLAGS_1, 0xbcded951, 0x187b, 0x4d05, 0xbc, 0xcc, 0xf7, 0xe5, 0x19, 0x60, 0xc2, 0x58 ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_ACTION_2, 0x421CBA38, 0x1A8E, 0x4881, 0xAC, 0x89, 0xE3, 0x3A, 0x8B, 0x04, 0xEC, 0xE4 ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_LEVEL_2, 0x07A07CA2, 0xADAF, 0x40D7, 0xB0, 0x77, 0x53, 0x3A, 0xAD, 0xED, 0x1B, 0xFA ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_FLAGS_2, 0x7fd2f0c4, 0xfeb7, 0x4da3, 0x81, 0x17, 0xe3, 0xfb, 0xed, 0xc4, 0x65, 0x82 ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_ACTION_3, 0x80472613, 0x9780, 0x455E, 0xB3, 0x08, 0x72, 0xD3, 0x00, 0x3C, 0xF2, 0xF8 ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_LEVEL_3, 0x58AFD5A6, 0xC2DD, 0x47D2, 0x9F, 0xBF, 0xEF, 0x70, 0xCC, 0x5C, 0x59, 0x65 ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_FLAGS_3, 0x73613ccf, 0xdbfa, 0x4279, 0x83, 0x56, 0x49, 0x35, 0xf6, 0xbf, 0x62, 0xf3 ); +DEFINE_GUID(GUID_PROCESSOR_SETTINGS_SUBGROUP, 0x54533251, 0x82BE, 0x4824, 0x96, 0xC1, 0x47, 0xB6, 0x0B, 0x74, 0x0D, 0x00 ); +DEFINE_GUID(GUID_PROCESSOR_THROTTLE_POLICY, 0x57027304, 0x4AF6, 0x4104, 0x92, 0x60, 0xE3, 0xD9, 0x52, 0x48, 0xFC, 0x36 ); +DEFINE_GUID(GUID_PROCESSOR_THROTTLE_MAXIMUM, 0xBC5038F7, 0x23E0, 0x4960, 0x96, 0xDA, 0x33, 0xAB, 0xAF, 0x59, 0x35, 0xEC ); +DEFINE_GUID(GUID_PROCESSOR_THROTTLE_MINIMUM, 0x893DEE8E, 0x2BEF, 0x41E0, 0x89, 0xC6, 0xB5, 0x5D, 0x09, 0x29, 0x96, 0x4C ); +DEFINE_GUID(GUID_PROCESSOR_ALLOW_THROTTLING, 0x3b04d4fd, 0x1cc7, 0x4f23, 0xab, 0x1c, 0xd1, 0x33, 0x78, 0x19, 0xc4, 0xbb ); +DEFINE_GUID(GUID_PROCESSOR_IDLESTATE_POLICY, 0x68f262a7, 0xf621, 0x4069, 0xb9, 0xa5, 0x48, 0x74, 0x16, 0x9b, 0xe2, 0x3c); +DEFINE_GUID(GUID_PROCESSOR_PERFSTATE_POLICY, 0xBBDC3814, 0x18E9, 0x4463, 0x8A, 0x55, 0xD1, 0x97, 0x32, 0x7C, 0x45, 0xC0); +DEFINE_GUID(GUID_PROCESSOR_PERF_INCREASE_THRESHOLD, 0x06cadf0e, 0x64ed, 0x448a, 0x89, 0x27, 0xce, 0x7b, 0xf9, 0x0e, 0xb3, 0x5d ); +DEFINE_GUID(GUID_PROCESSOR_PERF_DECREASE_THRESHOLD, 0x12a0ab44, 0xfe28, 0x4fa9, 0xb3, 0xbd, 0x4b, 0x64, 0xf4, 0x49, 0x60, 0xa6 ); +DEFINE_GUID(GUID_PROCESSOR_PERF_INCREASE_POLICY, 0x465e1f50, 0xb610, 0x473a, 0xab, 0x58, 0x0, 0xd1, 0x7, 0x7d, 0xc4, 0x18); +DEFINE_GUID(GUID_PROCESSOR_PERF_DECREASE_POLICY, 0x40fbefc7, 0x2e9d, 0x4d25, 0xa1, 0x85, 0xc, 0xfd, 0x85, 0x74, 0xba, 0xc6); +DEFINE_GUID(GUID_PROCESSOR_PERF_INCREASE_TIME, 0x984cf492, 0x3bed, 0x4488, 0xa8, 0xf9, 0x42, 0x86, 0xc9, 0x7b, 0xf5, 0xaa); +DEFINE_GUID(GUID_PROCESSOR_PERF_DECREASE_TIME, 0xd8edeb9b, 0x95cf, 0x4f95, 0xa7, 0x3c, 0xb0, 0x61, 0x97, 0x36, 0x93, 0xc8); +DEFINE_GUID(GUID_PROCESSOR_PERF_TIME_CHECK, 0x4d2b0152, 0x7d5c, 0x498b, 0x88, 0xe2, 0x34, 0x34, 0x53, 0x92, 0xa2, 0xc5); +DEFINE_GUID(GUID_PROCESSOR_PERF_BOOST_POLICY, 0x45bcc044, 0xd885, 0x43e2, 0x86, 0x5, 0xee, 0xe, 0xc6, 0xe9, 0x6b, 0x59); +DEFINE_GUID(GUID_PROCESSOR_IDLE_ALLOW_SCALING, 0x6c2993b0, 0x8f48, 0x481f, 0xbc, 0xc6, 0x0, 0xdd, 0x27, 0x42, 0xaa, 0x6); +DEFINE_GUID(GUID_PROCESSOR_IDLE_DISABLE, 0x5d76a2ca, 0xe8c0, 0x402f, 0xa1, 0x33, 0x21, 0x58, 0x49, 0x2d, 0x58, 0xad); +DEFINE_GUID(GUID_PROCESSOR_IDLE_TIME_CHECK, 0xc4581c31, 0x89ab, 0x4597, 0x8e, 0x2b, 0x9c, 0x9c, 0xab, 0x44, 0xe, 0x6b); +DEFINE_GUID(GUID_PROCESSOR_IDLE_DEMOTE_THRESHOLD, 0x4b92d758, 0x5a24, 0x4851, 0xa4, 0x70, 0x81, 0x5d, 0x78, 0xae, 0xe1, 0x19); +DEFINE_GUID(GUID_PROCESSOR_IDLE_PROMOTE_THRESHOLD, 0x7b224883, 0xb3cc, 0x4d79, 0x81, 0x9f, 0x83, 0x74, 0x15, 0x2c, 0xbe, 0x7c); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_INCREASE_THRESHOLD, 0xdf142941, 0x20f3, 0x4edf, 0x9a, 0x4a, 0x9c, 0x83, 0xd3, 0xd7, 0x17, 0xd1 ); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_DECREASE_THRESHOLD, 0x68dd2f27, 0xa4ce, 0x4e11, 0x84, 0x87, 0x37, 0x94, 0xe4, 0x13, 0x5d, 0xfa); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_INCREASE_POLICY, 0xc7be0679, 0x2817, 0x4d69, 0x9d, 0x02, 0x51, 0x9a, 0x53, 0x7e, 0xd0, 0xc6); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_DECREASE_POLICY, 0x71021b41, 0xc749, 0x4d21, 0xbe, 0x74, 0xa0, 0x0f, 0x33, 0x5d, 0x58, 0x2b); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_MAX_CORES, 0xea062031, 0x0e34, 0x4ff1, 0x9b, 0x6d, 0xeb, 0x10, 0x59, 0x33, 0x40, 0x28); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_MIN_CORES, 0x0cc5b647, 0xc1df, 0x4637, 0x89, 0x1a, 0xde, 0xc3, 0x5c, 0x31, 0x85, 0x83); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_INCREASE_TIME, 0x2ddd5a84, 0x5a71, 0x437e, 0x91, 0x2a, 0xdb, 0x0b, 0x8c, 0x78, 0x87, 0x32); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_DECREASE_TIME, 0xdfd10d17, 0xd5eb, 0x45dd, 0x87, 0x7a, 0x9a, 0x34, 0xdd, 0xd1, 0x5c, 0x82); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_AFFINITY_HISTORY_DECREASE_FACTOR, 0x8f7b45e3, 0xc393, 0x480a, 0x87, 0x8c, 0xf6, 0x7a, 0xc3, 0xd0, 0x70, 0x82); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_AFFINITY_HISTORY_THRESHOLD, 0x5b33697b, 0xe89d, 0x4d38, 0xaa, 0x46, 0x9e, 0x7d, 0xfb, 0x7c, 0xd2, 0xf9); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_AFFINITY_WEIGHTING, 0xe70867f1, 0xfa2f, 0x4f4e, 0xae, 0xa1, 0x4d, 0x8a, 0x0b, 0xa2, 0x3b, 0x20); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_HISTORY_DECREASE_FACTOR, 0x1299023c, 0xbc28, 0x4f0a, 0x81, 0xec, 0xd3, 0x29, 0x5a, 0x8d, 0x81, 0x5d); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_HISTORY_THRESHOLD, 0x9ac18e92, 0xaa3c, 0x4e27, 0xb3, 0x07, 0x01, 0xae, 0x37, 0x30, 0x71, 0x29); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_WEIGHTING, 0x8809c2d8, 0xb155, 0x42d4, 0xbc, 0xda, 0x0d, 0x34, 0x56, 0x51, 0xb1, 0xdb); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_THRESHOLD, 0x943c8cb6, 0x6f93, 0x4227, 0xad, 0x87, 0xe9, 0xa3, 0xfe, 0xec, 0x08, 0xd1); +DEFINE_GUID(GUID_PROCESSOR_PARKING_CORE_OVERRIDE, 0xa55612aa, 0xf624, 0x42c6, 0xa4, 0x43, 0x73, 0x97, 0xd0, 0x64, 0xc0, 0x4f); +DEFINE_GUID(GUID_PROCESSOR_PARKING_PERF_STATE, 0x447235c7, 0x6a8d, 0x4cc0, 0x8e, 0x24, 0x9e, 0xaf, 0x70, 0xb9, 0x6e, 0x2b); +DEFINE_GUID(GUID_PROCESSOR_PERF_HISTORY, 0x7d24baa7, 0x0b84, 0x480f, 0x84, 0x0c, 0x1b, 0x07, 0x43, 0xc0, 0x0f, 0x5f); +DEFINE_GUID(GUID_SYSTEM_COOLING_POLICY, 0x94D3A615, 0xA899, 0x4AC5, 0xAE, 0x2B, 0xE4, 0xD8, 0xF6, 0x34, 0x36, 0x7F); +DEFINE_GUID(GUID_LOCK_CONSOLE_ON_WAKE, 0x0E796BDB, 0x100D, 0x47D6, 0xA2, 0xD5, 0xF7, 0xD2, 0xDA, 0xA5, 0x1F, 0x51 ); +DEFINE_GUID(GUID_DEVICE_IDLE_POLICY, 0x4faab71a, 0x92e5, 0x4726, 0xb5, 0x31, 0x22, 0x45, 0x59, 0x67, 0x2d, 0x19 ); +DEFINE_GUID(GUID_ACDC_POWER_SOURCE, 0x5D3E9A59, 0xE9D5, 0x4B00, 0xA6, 0xBD, 0xFF, 0x34, 0xFF, 0x51, 0x65, 0x48 ); +DEFINE_GUID(GUID_LIDSWITCH_STATE_CHANGE, 0xBA3E0F4D, 0xB817, 0x4094, 0xA2, 0xD1, 0xD5, 0x63, 0x79, 0xE6, 0xA0, 0xF3 ); +DEFINE_GUID(GUID_BATTERY_PERCENTAGE_REMAINING, 0xA7AD8041, 0xB45A, 0x4CAE, 0x87, 0xA3, 0xEE, 0xCB, 0xB4, 0x68, 0xA9, 0xE1 ); +DEFINE_GUID(GUID_IDLE_BACKGROUND_TASK, 0x515C31D8, 0xF734, 0x163D, 0xA0, 0xFD, 0x11, 0xA0, 0x8C, 0x91, 0xE8, 0xF1 ); +DEFINE_GUID(GUID_BACKGROUND_TASK_NOTIFICATION, 0xCF23F240, 0x2A54, 0x48D8, 0xB1, 0x14, 0xDE, 0x15, 0x18, 0xFF, 0x05, 0x2E ); +DEFINE_GUID(GUID_APPLAUNCH_BUTTON, 0x1A689231, 0x7399, 0x4E9A, 0x8F, 0x99, 0xB7, 0x1F, 0x99, 0x9D, 0xB3, 0xFA ); +DEFINE_GUID(GUID_PCIEXPRESS_SETTINGS_SUBGROUP, 0x501a4d13, 0x42af,0x4429, 0x9f, 0xd1, 0xa8, 0x21, 0x8c, 0x26, 0x8e, 0x20 ); +DEFINE_GUID(GUID_PCIEXPRESS_ASPM_POLICY, 0xee12f906, 0xd277, 0x404b, 0xb6, 0xda, 0xe5, 0xfa, 0x1a, 0x57, 0x6d, 0xf5 ); +DEFINE_GUID(GUID_ENABLE_SWITCH_FORCED_SHUTDOWN, 0x833a6b62, 0xdfa4, 0x46d1, 0x82, 0xf8, 0xe0, 0x9e, 0x34, 0xd0, 0x29, 0xd6 ); + +#define PERFSTATE_POLICY_CHANGE_IDEAL 0 +#define PERFSTATE_POLICY_CHANGE_SINGLE 1 +#define PERFSTATE_POLICY_CHANGE_ROCKET 2 +#define PERFSTATE_POLICY_CHANGE_MAX PERFSTATE_POLICY_CHANGE_ROCKET + +#define PROCESSOR_PERF_BOOST_POLICY_DISABLED 0 +#define PROCESSOR_PERF_BOOST_POLICY_MAX 100 + +#define POWER_DEVICE_IDLE_POLICY_PERFORMANCE 0 +#define POWER_DEVICE_IDLE_POLICY_CONSERVATIVE 1 + +typedef VOID +(NTAPI REQUEST_POWER_COMPLETE)( + IN struct _DEVICE_OBJECT *DeviceObject, + IN UCHAR MinorFunction, + IN POWER_STATE PowerState, + IN PVOID Context, + IN struct _IO_STATUS_BLOCK *IoStatus); +typedef REQUEST_POWER_COMPLETE *PREQUEST_POWER_COMPLETE; + +typedef +NTSTATUS +(NTAPI POWER_SETTING_CALLBACK)( + IN LPCGUID SettingGuid, + IN PVOID Value, + IN ULONG ValueLength, + IN OUT PVOID Context OPTIONAL); +typedef POWER_SETTING_CALLBACK *PPOWER_SETTING_CALLBACK; + + diff --git a/reactos/include/xdk/ppc/ke.h b/reactos/include/xdk/ppc/ke.h new file mode 100644 index 00000000000..b3a81bc7aa9 --- /dev/null +++ b/reactos/include/xdk/ppc/ke.h @@ -0,0 +1,107 @@ +$if (_WDMDDK_) + +/* Interrupt request levels */ +#define PASSIVE_LEVEL 0 +#define LOW_LEVEL 0 +#define APC_LEVEL 1 +#define DISPATCH_LEVEL 2 +#define PROFILE_LEVEL 27 +#define CLOCK1_LEVEL 28 +#define CLOCK2_LEVEL 28 +#define IPI_LEVEL 29 +#define POWER_LEVEL 30 +#define HIGH_LEVEL 31 + +// +// Used to contain PFNs and PFN counts +// +typedef ULONG PFN_COUNT; +typedef ULONG PFN_NUMBER, *PPFN_NUMBER; +typedef LONG SPFN_NUMBER, *PSPFN_NUMBER; + + +typedef struct _KFLOATING_SAVE { + ULONG Dummy; +} KFLOATING_SAVE, *PKFLOATING_SAVE; + +typedef struct _KPCR_TIB { + PVOID ExceptionList; /* 00 */ + PVOID StackBase; /* 04 */ + PVOID StackLimit; /* 08 */ + PVOID SubSystemTib; /* 0C */ + _ANONYMOUS_UNION union { + PVOID FiberData; /* 10 */ + ULONG Version; /* 10 */ + } DUMMYUNIONNAME; + PVOID ArbitraryUserPointer; /* 14 */ + struct _KPCR_TIB *Self; /* 18 */ +} KPCR_TIB, *PKPCR_TIB; /* 1C */ + +#define PCR_MINOR_VERSION 1 +#define PCR_MAJOR_VERSION 1 + +typedef struct _KPCR { + KPCR_TIB Tib; /* 00 */ + struct _KPCR *Self; /* 1C */ + struct _KPRCB *Prcb; /* 20 */ + KIRQL Irql; /* 24 */ + ULONG IRR; /* 28 */ + ULONG IrrActive; /* 2C */ + ULONG IDR; /* 30 */ + PVOID KdVersionBlock; /* 34 */ + PUSHORT IDT; /* 38 */ + PUSHORT GDT; /* 3C */ + struct _KTSS *TSS; /* 40 */ + USHORT MajorVersion; /* 44 */ + USHORT MinorVersion; /* 46 */ + KAFFINITY SetMember; /* 48 */ + ULONG StallScaleFactor; /* 4C */ + UCHAR SpareUnused; /* 50 */ + UCHAR Number; /* 51 */ +} KPCR, *PKPCR; /* 54 */ + +#define KeGetPcr() PCR + +#define YieldProcessor() __asm__ __volatile__("nop"); + +FORCEINLINE +ULONG +NTAPI +KeGetCurrentProcessorNumber(VOID) +{ + ULONG Number; + __asm__ __volatile__ ( + "lwz %0, %c1(12)\n" + : "=r" (Number) + : "i" (FIELD_OFFSET(KPCR, Number)) + ); + return Number; +} + +NTHALAPI +VOID +FASTCALL +KfLowerIrql( + IN KIRQL NewIrql); +#define KeLowerIrql(a) KfLowerIrql(a) + +NTHALAPI +KIRQL +FASTCALL +KfRaiseIrql( + IN KIRQL NewIrql); +#define KeRaiseIrql(a,b) *(b) = KfRaiseIrql(a) + +NTHALAPI +KIRQL +NTAPI +KeRaiseIrqlToDpcLevel(VOID); + +NTHALAPI +KIRQL +NTAPI +KeRaiseIrqlToSynchLevel(VOID); + +$endif + + diff --git a/reactos/include/xdk/psfuncs.h b/reactos/include/xdk/psfuncs.h new file mode 100644 index 00000000000..48666e64ab8 --- /dev/null +++ b/reactos/include/xdk/psfuncs.h @@ -0,0 +1,184 @@ +/****************************************************************************** + * Process Manager Functions * + ******************************************************************************/ +$if (_WDMDDK_) + +NTKERNELAPI +NTSTATUS +NTAPI +PsWrapApcWow64Thread( + IN OUT PVOID *ApcContext, + IN OUT PVOID *ApcRoutine); + +/* + * PEPROCESS + * PsGetCurrentProcess(VOID) + */ +#define PsGetCurrentProcess IoGetCurrentProcess + +#if !defined(_PSGETCURRENTTHREAD_) +#define _PSGETCURRENTTHREAD_ +FORCEINLINE +PETHREAD +NTAPI +PsGetCurrentThread(VOID) +{ + return (PETHREAD)KeGetCurrentThread(); +} +#endif /* !_PSGETCURRENTTHREAD_ */ + +$endif /* _WDMDDK_ */ +$if (_NTDDK_) + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtOpenProcess( + OUT PHANDLE ProcessHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN PCLIENT_ID ClientId OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtQueryInformationProcess( + IN HANDLE ProcessHandle, + IN PROCESSINFOCLASS ProcessInformationClass, + OUT PVOID ProcessInformation OPTIONAL, + IN ULONG ProcessInformationLength, + OUT PULONG ReturnLength OPTIONAL); +$endif /* _NTDDK_ */ + +#if (NTDDI_VERSION >= NTDDI_WIN2K) + +$if (_WDMDDK_) +NTKERNELAPI +NTSTATUS +NTAPI +PsCreateSystemThread( + OUT PHANDLE ThreadHandle, + IN ULONG DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, + IN HANDLE ProcessHandle OPTIONAL, + OUT PCLIENT_ID ClientId OPTIONAL, + IN PKSTART_ROUTINE StartRoutine, + IN PVOID StartContext OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +PsTerminateSystemThread( + IN NTSTATUS ExitStatus); + +$endif /* _WDMDDK_ */ +$if (_NTDDK_) + +NTKERNELAPI +NTSTATUS +NTAPI +PsSetCreateProcessNotifyRoutine( + IN PCREATE_PROCESS_NOTIFY_ROUTINE NotifyRoutine, + IN BOOLEAN Remove); + +NTKERNELAPI +NTSTATUS +NTAPI +PsSetCreateThreadNotifyRoutine( + IN PCREATE_THREAD_NOTIFY_ROUTINE NotifyRoutine); + +NTKERNELAPI +NTSTATUS +NTAPI +PsSetLoadImageNotifyRoutine( + IN PLOAD_IMAGE_NOTIFY_ROUTINE NotifyRoutine); + +NTKERNELAPI +HANDLE +NTAPI +PsGetCurrentProcessId(VOID); + +NTKERNELAPI +HANDLE +NTAPI +PsGetCurrentThreadId(VOID); + +NTKERNELAPI +BOOLEAN +NTAPI +PsGetVersion( + OUT PULONG MajorVersion OPTIONAL, + OUT PULONG MinorVersion OPTIONAL, + OUT PULONG BuildNumber OPTIONAL, + OUT PUNICODE_STRING CSDVersion OPTIONAL); +$endif /* _NTDDK_ */ + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ + +$if (_NTDDK_) +#if (NTDDI_VERSION >= NTDDI_WINXP) + +NTKERNELAPI +HANDLE +NTAPI +PsGetProcessId( + IN PEPROCESS Process); + +NTKERNELAPI +HANDLE +NTAPI +PsGetThreadId( + IN PETHREAD Thread); + +NTKERNELAPI +NTSTATUS +NTAPI +PsRemoveCreateThreadNotifyRoutine( + IN PCREATE_THREAD_NOTIFY_ROUTINE NotifyRoutine); + +NTKERNELAPI +NTSTATUS +NTAPI +PsRemoveLoadImageNotifyRoutine( + IN PLOAD_IMAGE_NOTIFY_ROUTINE NotifyRoutine); + +NTKERNELAPI +LONGLONG +NTAPI +PsGetProcessCreateTimeQuadPart( + IN PEPROCESS Process); + +#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ + +#if (NTDDI_VERSION >= NTDDI_WS03) +NTKERNELAPI +HANDLE +NTAPI +PsGetThreadProcessId( + IN PETHREAD Thread); +#endif /* (NTDDI_VERSION >= NTDDI_WS03) */ + +#if (NTDDI_VERSION >= NTDDI_VISTA) + +NTKERNELAPI +BOOLEAN +NTAPI +PsSetCurrentThreadPrefetching( + IN BOOLEAN Prefetching); + +NTKERNELAPI +BOOLEAN +NTAPI +PsIsCurrentThreadPrefetching(VOID); + +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + +#if (NTDDI_VERSION >= NTDDI_VISTASP1) +NTKERNELAPI +NTSTATUS +NTAPI +PsSetCreateProcessNotifyRoutineEx( + IN PCREATE_PROCESS_NOTIFY_ROUTINE_EX NotifyRoutine, + IN BOOLEAN Remove); +#endif /* (NTDDI_VERSION >= NTDDI_VISTASP1) */ +$endif diff --git a/reactos/include/xdk/pstypes.h b/reactos/include/xdk/pstypes.h new file mode 100644 index 00000000000..adda1fb12b5 --- /dev/null +++ b/reactos/include/xdk/pstypes.h @@ -0,0 +1,451 @@ +/****************************************************************************** + * Process Manager Types * + ******************************************************************************/ +$if (_WDMDDK_) + +#define QUOTA_LIMITS_HARDWS_MIN_ENABLE 0x00000001 +#define QUOTA_LIMITS_HARDWS_MIN_DISABLE 0x00000002 +#define QUOTA_LIMITS_HARDWS_MAX_ENABLE 0x00000004 +#define QUOTA_LIMITS_HARDWS_MAX_DISABLE 0x00000008 +#define QUOTA_LIMITS_USE_DEFAULT_LIMITS 0x00000010 + +/* Thread Access Rights */ +#define THREAD_TERMINATE 0x0001 +#define THREAD_SUSPEND_RESUME 0x0002 +#define THREAD_ALERT 0x0004 +#define THREAD_GET_CONTEXT 0x0008 +#define THREAD_SET_CONTEXT 0x0010 +#define THREAD_SET_INFORMATION 0x0020 +#define THREAD_SET_LIMITED_INFORMATION 0x0400 +#define THREAD_QUERY_LIMITED_INFORMATION 0x0800 + +#define PROCESS_DUP_HANDLE (0x0040) + +#if (NTDDI_VERSION >= NTDDI_VISTA) +#define PROCESS_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0xFFFF) +#else +#define PROCESS_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0xFFF) +#endif + +#if (NTDDI_VERSION >= NTDDI_VISTA) +#define THREAD_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0xFFFF) +#else +#define THREAD_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3FF) +#endif + +#define LOW_PRIORITY 0 +#define LOW_REALTIME_PRIORITY 16 +#define HIGH_PRIORITY 31 +#define MAXIMUM_PRIORITY 32 + +$endif /* _WDMDDK_ */ +$if (_NTDDK_) + +#define QUOTA_LIMITS_HARDWS_MIN_ENABLE 0x00000001 +#define QUOTA_LIMITS_HARDWS_MIN_DISABLE 0x00000002 +#define QUOTA_LIMITS_HARDWS_MAX_ENABLE 0x00000004 +#define QUOTA_LIMITS_HARDWS_MAX_DISABLE 0x00000008 +#define QUOTA_LIMITS_USE_DEFAULT_LIMITS 0x00000010 + +typedef struct _QUOTA_LIMITS { + SIZE_T PagedPoolLimit; + SIZE_T NonPagedPoolLimit; + SIZE_T MinimumWorkingSetSize; + SIZE_T MaximumWorkingSetSize; + SIZE_T PagefileLimit; + LARGE_INTEGER TimeLimit; +} QUOTA_LIMITS, *PQUOTA_LIMITS; + +typedef union _RATE_QUOTA_LIMIT { + ULONG RateData; + struct { + ULONG RatePercent:7; + ULONG Reserved0:25; + } DUMMYSTRUCTNAME; +} RATE_QUOTA_LIMIT, *PRATE_QUOTA_LIMIT; + +typedef struct _QUOTA_LIMITS_EX { + SIZE_T PagedPoolLimit; + SIZE_T NonPagedPoolLimit; + SIZE_T MinimumWorkingSetSize; + SIZE_T MaximumWorkingSetSize; + SIZE_T PagefileLimit; + LARGE_INTEGER TimeLimit; + SIZE_T WorkingSetLimit; + SIZE_T Reserved2; + SIZE_T Reserved3; + SIZE_T Reserved4; + ULONG Flags; + RATE_QUOTA_LIMIT CpuRateLimit; +} QUOTA_LIMITS_EX, *PQUOTA_LIMITS_EX; + +typedef struct _IO_COUNTERS { + ULONGLONG ReadOperationCount; + ULONGLONG WriteOperationCount; + ULONGLONG OtherOperationCount; + ULONGLONG ReadTransferCount; + ULONGLONG WriteTransferCount; + ULONGLONG OtherTransferCount; +} IO_COUNTERS, *PIO_COUNTERS; + +typedef struct _VM_COUNTERS { + SIZE_T PeakVirtualSize; + SIZE_T VirtualSize; + ULONG PageFaultCount; + SIZE_T PeakWorkingSetSize; + SIZE_T WorkingSetSize; + SIZE_T QuotaPeakPagedPoolUsage; + SIZE_T QuotaPagedPoolUsage; + SIZE_T QuotaPeakNonPagedPoolUsage; + SIZE_T QuotaNonPagedPoolUsage; + SIZE_T PagefileUsage; + SIZE_T PeakPagefileUsage; +} VM_COUNTERS, *PVM_COUNTERS; + +typedef struct _VM_COUNTERS_EX { + SIZE_T PeakVirtualSize; + SIZE_T VirtualSize; + ULONG PageFaultCount; + SIZE_T PeakWorkingSetSize; + SIZE_T WorkingSetSize; + SIZE_T QuotaPeakPagedPoolUsage; + SIZE_T QuotaPagedPoolUsage; + SIZE_T QuotaPeakNonPagedPoolUsage; + SIZE_T QuotaNonPagedPoolUsage; + SIZE_T PagefileUsage; + SIZE_T PeakPagefileUsage; + SIZE_T PrivateUsage; +} VM_COUNTERS_EX, *PVM_COUNTERS_EX; + +#define MAX_HW_COUNTERS 16 +#define THREAD_PROFILING_FLAG_DISPATCH 0x00000001 + +typedef enum _HARDWARE_COUNTER_TYPE { + PMCCounter, + MaxHardwareCounterType +} HARDWARE_COUNTER_TYPE, *PHARDWARE_COUNTER_TYPE; + +typedef struct _HARDWARE_COUNTER { + HARDWARE_COUNTER_TYPE Type; + ULONG Reserved; + ULONG64 Index; +} HARDWARE_COUNTER, *PHARDWARE_COUNTER; + +typedef struct _POOLED_USAGE_AND_LIMITS { + SIZE_T PeakPagedPoolUsage; + SIZE_T PagedPoolUsage; + SIZE_T PagedPoolLimit; + SIZE_T PeakNonPagedPoolUsage; + SIZE_T NonPagedPoolUsage; + SIZE_T NonPagedPoolLimit; + SIZE_T PeakPagefileUsage; + SIZE_T PagefileUsage; + SIZE_T PagefileLimit; +} POOLED_USAGE_AND_LIMITS, *PPOOLED_USAGE_AND_LIMITS; + +typedef struct _PROCESS_ACCESS_TOKEN { + HANDLE Token; + HANDLE Thread; +} PROCESS_ACCESS_TOKEN, *PPROCESS_ACCESS_TOKEN; + +#define PROCESS_EXCEPTION_PORT_ALL_STATE_BITS 0x00000003UL +#define PROCESS_EXCEPTION_PORT_ALL_STATE_FLAGS ((ULONG_PTR)((1UL << PROCESS_EXCEPTION_PORT_ALL_STATE_BITS) - 1)) + +typedef struct _PROCESS_EXCEPTION_PORT { + IN HANDLE ExceptionPortHandle; + IN OUT ULONG StateFlags; +} PROCESS_EXCEPTION_PORT, *PPROCESS_EXCEPTION_PORT; + +typedef VOID +(NTAPI *PCREATE_PROCESS_NOTIFY_ROUTINE)( + IN HANDLE ParentId, + IN HANDLE ProcessId, + IN BOOLEAN Create); + +typedef struct _PS_CREATE_NOTIFY_INFO { + IN SIZE_T Size; + union { + IN ULONG Flags; + struct { + IN ULONG FileOpenNameAvailable:1; + IN ULONG Reserved:31; + }; + }; + IN HANDLE ParentProcessId; + IN CLIENT_ID CreatingThreadId; + IN OUT struct _FILE_OBJECT *FileObject; + IN PCUNICODE_STRING ImageFileName; + IN PCUNICODE_STRING CommandLine OPTIONAL; + IN OUT NTSTATUS CreationStatus; +} PS_CREATE_NOTIFY_INFO, *PPS_CREATE_NOTIFY_INFO; + +typedef VOID +(NTAPI *PCREATE_PROCESS_NOTIFY_ROUTINE_EX)( + IN OUT PEPROCESS Process, + IN HANDLE ProcessId, + IN PPS_CREATE_NOTIFY_INFO CreateInfo OPTIONAL); + +typedef VOID +(NTAPI *PCREATE_THREAD_NOTIFY_ROUTINE)( + IN HANDLE ProcessId, + IN HANDLE ThreadId, + IN BOOLEAN Create); + +#define IMAGE_ADDRESSING_MODE_32BIT 3 + +typedef struct _IMAGE_INFO { + _ANONYMOUS_UNION union { + ULONG Properties; + _ANONYMOUS_STRUCT struct { + ULONG ImageAddressingMode:8; + ULONG SystemModeImage:1; + ULONG ImageMappedToAllPids:1; + ULONG ExtendedInfoPresent:1; + ULONG Reserved:21; + } DUMMYSTRUCTNAME; + } DUMMYUNIONNAME; + PVOID ImageBase; + ULONG ImageSelector; + SIZE_T ImageSize; + ULONG ImageSectionNumber; +} IMAGE_INFO, *PIMAGE_INFO; + +typedef struct _IMAGE_INFO_EX { + SIZE_T Size; + IMAGE_INFO ImageInfo; + struct _FILE_OBJECT *FileObject; +} IMAGE_INFO_EX, *PIMAGE_INFO_EX; + +typedef VOID +(NTAPI *PLOAD_IMAGE_NOTIFY_ROUTINE)( + IN PUNICODE_STRING FullImageName, + IN HANDLE ProcessId, + IN PIMAGE_INFO ImageInfo); + +#define THREAD_CSWITCH_PMU_DISABLE FALSE +#define THREAD_CSWITCH_PMU_ENABLE TRUE + +#define PROCESS_LUID_DOSDEVICES_ONLY 0x00000001 + +#define PROCESS_HANDLE_TRACING_MAX_STACKS 16 + +typedef struct _NT_TIB { + struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList; + PVOID StackBase; + PVOID StackLimit; + PVOID SubSystemTib; + _ANONYMOUS_UNION union { + PVOID FiberData; + ULONG Version; + } DUMMYUNIONNAME; + PVOID ArbitraryUserPointer; + struct _NT_TIB *Self; +} NT_TIB, *PNT_TIB; + +typedef struct _NT_TIB32 { + ULONG ExceptionList; + ULONG StackBase; + ULONG StackLimit; + ULONG SubSystemTib; + __GNU_EXTENSION union { + ULONG FiberData; + ULONG Version; + }; + ULONG ArbitraryUserPointer; + ULONG Self; +} NT_TIB32,*PNT_TIB32; + +typedef struct _NT_TIB64 { + ULONG64 ExceptionList; + ULONG64 StackBase; + ULONG64 StackLimit; + ULONG64 SubSystemTib; + __GNU_EXTENSION union { + ULONG64 FiberData; + ULONG Version; + }; + ULONG64 ArbitraryUserPointer; + ULONG64 Self; +} NT_TIB64,*PNT_TIB64; + +typedef enum _PROCESSINFOCLASS { + ProcessBasicInformation, + ProcessQuotaLimits, + ProcessIoCounters, + ProcessVmCounters, + ProcessTimes, + ProcessBasePriority, + ProcessRaisePriority, + ProcessDebugPort, + ProcessExceptionPort, + ProcessAccessToken, + ProcessLdtInformation, + ProcessLdtSize, + ProcessDefaultHardErrorMode, + ProcessIoPortHandlers, + ProcessPooledUsageAndLimits, + ProcessWorkingSetWatch, + ProcessUserModeIOPL, + ProcessEnableAlignmentFaultFixup, + ProcessPriorityClass, + ProcessWx86Information, + ProcessHandleCount, + ProcessAffinityMask, + ProcessPriorityBoost, + ProcessDeviceMap, + ProcessSessionInformation, + ProcessForegroundInformation, + ProcessWow64Information, + ProcessImageFileName, + ProcessLUIDDeviceMapsEnabled, + ProcessBreakOnTermination, + ProcessDebugObjectHandle, + ProcessDebugFlags, + ProcessHandleTracing, + ProcessIoPriority, + ProcessExecuteFlags, + ProcessTlsInformation, + ProcessCookie, + ProcessImageInformation, + ProcessCycleTime, + ProcessPagePriority, + ProcessInstrumentationCallback, + ProcessThreadStackAllocation, + ProcessWorkingSetWatchEx, + ProcessImageFileNameWin32, + ProcessImageFileMapping, + ProcessAffinityUpdateMode, + ProcessMemoryAllocationMode, + ProcessGroupInformation, + ProcessTokenVirtualizationEnabled, + ProcessConsoleHostProcess, + ProcessWindowInformation, + MaxProcessInfoClass +} PROCESSINFOCLASS; + +typedef enum _THREADINFOCLASS { + ThreadBasicInformation, + ThreadTimes, + ThreadPriority, + ThreadBasePriority, + ThreadAffinityMask, + ThreadImpersonationToken, + ThreadDescriptorTableEntry, + ThreadEnableAlignmentFaultFixup, + ThreadEventPair_Reusable, + ThreadQuerySetWin32StartAddress, + ThreadZeroTlsCell, + ThreadPerformanceCount, + ThreadAmILastThread, + ThreadIdealProcessor, + ThreadPriorityBoost, + ThreadSetTlsArrayAddress, + ThreadIsIoPending, + ThreadHideFromDebugger, + ThreadBreakOnTermination, + ThreadSwitchLegacyState, + ThreadIsTerminated, + ThreadLastSystemCall, + ThreadIoPriority, + ThreadCycleTime, + ThreadPagePriority, + ThreadActualBasePriority, + ThreadTebInformation, + ThreadCSwitchMon, + ThreadCSwitchPmu, + ThreadWow64Context, + ThreadGroupInformation, + ThreadUmsInformation, + ThreadCounterProfiling, + ThreadIdealProcessorEx, + MaxThreadInfoClass +} THREADINFOCLASS; + +typedef struct _PAGE_PRIORITY_INFORMATION { + ULONG PagePriority; +} PAGE_PRIORITY_INFORMATION, *PPAGE_PRIORITY_INFORMATION; + +typedef struct _PROCESS_WS_WATCH_INFORMATION { + PVOID FaultingPc; + PVOID FaultingVa; +} PROCESS_WS_WATCH_INFORMATION, *PPROCESS_WS_WATCH_INFORMATION; + +typedef struct _PROCESS_BASIC_INFORMATION { + NTSTATUS ExitStatus; + struct _PEB *PebBaseAddress; + ULONG_PTR AffinityMask; + KPRIORITY BasePriority; + ULONG_PTR UniqueProcessId; + ULONG_PTR InheritedFromUniqueProcessId; +} PROCESS_BASIC_INFORMATION,*PPROCESS_BASIC_INFORMATION; + +typedef struct _PROCESS_EXTENDED_BASIC_INFORMATION { + SIZE_T Size; + PROCESS_BASIC_INFORMATION BasicInfo; + union { + ULONG Flags; + struct { + ULONG IsProtectedProcess:1; + ULONG IsWow64Process:1; + ULONG IsProcessDeleting:1; + ULONG IsCrossSessionCreate:1; + ULONG SpareBits:28; + } DUMMYSTRUCTNAME; + } DUMMYUNIONNAME; +} PROCESS_EXTENDED_BASIC_INFORMATION, *PPROCESS_EXTENDED_BASIC_INFORMATION; + +typedef struct _PROCESS_DEVICEMAP_INFORMATION { + __GNU_EXTENSION union { + struct { + HANDLE DirectoryHandle; + } Set; + struct { + ULONG DriveMap; + UCHAR DriveType[32]; + } Query; + }; +} PROCESS_DEVICEMAP_INFORMATION, *PPROCESS_DEVICEMAP_INFORMATION; + +typedef struct _PROCESS_DEVICEMAP_INFORMATION_EX { + union { + struct { + HANDLE DirectoryHandle; + } Set; + struct { + ULONG DriveMap; + UCHAR DriveType[32]; + } Query; + } DUMMYUNIONNAME; + ULONG Flags; +} PROCESS_DEVICEMAP_INFORMATION_EX, *PPROCESS_DEVICEMAP_INFORMATION_EX; + +typedef struct _PROCESS_SESSION_INFORMATION { + ULONG SessionId; +} PROCESS_SESSION_INFORMATION, *PPROCESS_SESSION_INFORMATION; + +typedef struct _PROCESS_HANDLE_TRACING_ENABLE { + ULONG Flags; +} PROCESS_HANDLE_TRACING_ENABLE, *PPROCESS_HANDLE_TRACING_ENABLE; + +typedef struct _PROCESS_HANDLE_TRACING_ENABLE_EX { + ULONG Flags; + ULONG TotalSlots; +} PROCESS_HANDLE_TRACING_ENABLE_EX, *PPROCESS_HANDLE_TRACING_ENABLE_EX; + +typedef struct _PROCESS_HANDLE_TRACING_ENTRY { + HANDLE Handle; + CLIENT_ID ClientId; + ULONG Type; + PVOID Stacks[PROCESS_HANDLE_TRACING_MAX_STACKS]; +} PROCESS_HANDLE_TRACING_ENTRY, *PPROCESS_HANDLE_TRACING_ENTRY; + +typedef struct _PROCESS_HANDLE_TRACING_QUERY { + HANDLE Handle; + ULONG TotalTraces; + PROCESS_HANDLE_TRACING_ENTRY HandleTrace[1]; +} PROCESS_HANDLE_TRACING_QUERY, *PPROCESS_HANDLE_TRACING_QUERY; + +extern NTKERNELAPI PEPROCESS PsInitialSystemProcess; + +$endif /* _NTDDK_ */ + diff --git a/reactos/include/xdk/rtlfuncs.h b/reactos/include/xdk/rtlfuncs.h new file mode 100644 index 00000000000..a5302dcea9f --- /dev/null +++ b/reactos/include/xdk/rtlfuncs.h @@ -0,0 +1,2259 @@ +/****************************************************************************** + * Runtime Library Functions * + ******************************************************************************/ + +$if (_WDMDDK_) + +#if !defined(MIDL_PASS) && !defined(SORTPP_PASS) + +#define RTL_STATIC_LIST_HEAD(x) LIST_ENTRY x = { &x, &x } + +FORCEINLINE +VOID +InitializeListHead( + OUT PLIST_ENTRY ListHead) +{ + ListHead->Flink = ListHead->Blink = ListHead; +} + +BOOLEAN +FORCEINLINE +IsListEmpty( + IN CONST LIST_ENTRY * ListHead) +{ + return (BOOLEAN)(ListHead->Flink == ListHead); +} + +FORCEINLINE +BOOLEAN +RemoveEntryList( + IN PLIST_ENTRY Entry) +{ + PLIST_ENTRY OldFlink; + PLIST_ENTRY OldBlink; + + OldFlink = Entry->Flink; + OldBlink = Entry->Blink; + OldFlink->Blink = OldBlink; + OldBlink->Flink = OldFlink; + return (BOOLEAN)(OldFlink == OldBlink); +} + +FORCEINLINE +PLIST_ENTRY +RemoveHeadList( + IN OUT PLIST_ENTRY ListHead) +{ + PLIST_ENTRY Flink; + PLIST_ENTRY Entry; + + Entry = ListHead->Flink; + Flink = Entry->Flink; + ListHead->Flink = Flink; + Flink->Blink = ListHead; + return Entry; +} + +FORCEINLINE +PLIST_ENTRY +RemoveTailList( + IN OUT PLIST_ENTRY ListHead) +{ + PLIST_ENTRY Blink; + PLIST_ENTRY Entry; + + Entry = ListHead->Blink; + Blink = Entry->Blink; + ListHead->Blink = Blink; + Blink->Flink = ListHead; + return Entry; +} + +FORCEINLINE +VOID +InsertTailList( + IN OUT PLIST_ENTRY ListHead, + IN OUT PLIST_ENTRY Entry) +{ + PLIST_ENTRY OldBlink; + OldBlink = ListHead->Blink; + Entry->Flink = ListHead; + Entry->Blink = OldBlink; + OldBlink->Flink = Entry; + ListHead->Blink = Entry; +} + +FORCEINLINE +VOID +InsertHeadList( + IN OUT PLIST_ENTRY ListHead, + IN OUT PLIST_ENTRY Entry) +{ + PLIST_ENTRY OldFlink; + OldFlink = ListHead->Flink; + Entry->Flink = OldFlink; + Entry->Blink = ListHead; + OldFlink->Blink = Entry; + ListHead->Flink = Entry; +} + +FORCEINLINE +VOID +AppendTailList( + IN OUT PLIST_ENTRY ListHead, + IN OUT PLIST_ENTRY ListToAppend) +{ + PLIST_ENTRY ListEnd = ListHead->Blink; + + ListHead->Blink->Flink = ListToAppend; + ListHead->Blink = ListToAppend->Blink; + ListToAppend->Blink->Flink = ListHead; + ListToAppend->Blink = ListEnd; +} + +FORCEINLINE +PSINGLE_LIST_ENTRY +PopEntryList( + IN OUT PSINGLE_LIST_ENTRY ListHead) +{ + PSINGLE_LIST_ENTRY FirstEntry; + FirstEntry = ListHead->Next; + if (FirstEntry != NULL) { + ListHead->Next = FirstEntry->Next; + } + return FirstEntry; +} + +FORCEINLINE +VOID +PushEntryList( + IN OUT PSINGLE_LIST_ENTRY ListHead, + IN OUT PSINGLE_LIST_ENTRY Entry) +{ + Entry->Next = ListHead->Next; + ListHead->Next = Entry; +} + +#endif /* !defined(MIDL_PASS) && !defined(SORTPP_PASS) */ + +NTSYSAPI +VOID +NTAPI +RtlAssert( + IN PVOID FailedAssertion, + IN PVOID FileName, + IN ULONG LineNumber, + IN PSTR Message); + +/* VOID + * RtlCopyMemory( + * IN VOID UNALIGNED *Destination, + * IN CONST VOID UNALIGNED *Source, + * IN SIZE_T Length) + */ +#define RtlCopyMemory(Destination, Source, Length) \ + memcpy(Destination, Source, Length) + +#define RtlCopyBytes RtlCopyMemory + +#if defined(_M_AMD64) +NTSYSAPI +VOID +NTAPI +RtlCopyMemoryNonTemporal( + VOID UNALIGNED *Destination, + CONST VOID UNALIGNED *Source, + SIZE_T Length); +#else +#define RtlCopyMemoryNonTemporal RtlCopyMemory +#endif + +/* BOOLEAN + * RtlEqualLuid( + * IN PLUID Luid1, + * IN PLUID Luid2) + */ +#define RtlEqualLuid(Luid1, Luid2) \ + (((Luid1)->LowPart == (Luid2)->LowPart) && ((Luid1)->HighPart == (Luid2)->HighPart)) + +/* ULONG + * RtlEqualMemory( + * IN VOID UNALIGNED *Destination, + * IN CONST VOID UNALIGNED *Source, + * IN SIZE_T Length) + */ +#define RtlEqualMemory(Destination, Source, Length) \ + (!memcmp(Destination, Source, Length)) + +/* VOID + * RtlFillMemory( + * IN VOID UNALIGNED *Destination, + * IN SIZE_T Length, + * IN UCHAR Fill) + */ +#define RtlFillMemory(Destination, Length, Fill) \ + memset(Destination, Fill, Length) + +#define RtlFillBytes RtlFillMemory + +NTSYSAPI +VOID +NTAPI +RtlFreeUnicodeString( + IN OUT PUNICODE_STRING UnicodeString); + +NTSYSAPI +NTSTATUS +NTAPI +RtlGUIDFromString( + IN PUNICODE_STRING GuidString, + OUT GUID *Guid); + +NTSYSAPI +VOID +NTAPI +RtlInitUnicodeString( + IN OUT PUNICODE_STRING DestinationString, + IN PCWSTR SourceString OPTIONAL); + +/* VOID + * RtlMoveMemory( + * IN VOID UNALIGNED *Destination, + * IN CONST VOID UNALIGNED *Source, + * IN SIZE_T Length) + */ +#define RtlMoveMemory(Destination, Source, Length) \ + memmove(Destination, Source, Length) + +NTSYSAPI +NTSTATUS +NTAPI +RtlStringFromGUID( + IN REFGUID Guid, + OUT PUNICODE_STRING GuidString); + +/* VOID + * RtlZeroMemory( + * IN VOID UNALIGNED *Destination, + * IN SIZE_T Length) + */ +#define RtlZeroMemory(Destination, Length) \ + memset(Destination, 0, Length) + +#define RtlZeroBytes RtlZeroMemory + +$endif +#if (NTDDI_VERSION >= NTDDI_WIN2K) + +$if (_NTIFS_) +NTSYSAPI +PVOID +NTAPI +RtlAllocateHeap( + IN HANDLE HeapHandle, + IN ULONG Flags OPTIONAL, + IN SIZE_T Size); + +NTSYSAPI +BOOLEAN +NTAPI +RtlFreeHeap( + IN PVOID HeapHandle, + IN ULONG Flags OPTIONAL, + IN PVOID BaseAddress); + +$endif + +$if (_NTDDK_) + +#ifndef RTL_USE_AVL_TABLES + +NTSYSAPI +VOID +NTAPI +RtlInitializeGenericTable( + OUT PRTL_GENERIC_TABLE Table, + IN PRTL_GENERIC_COMPARE_ROUTINE CompareRoutine, + IN PRTL_GENERIC_ALLOCATE_ROUTINE AllocateRoutine, + IN PRTL_GENERIC_FREE_ROUTINE FreeRoutine, + IN PVOID TableContext OPTIONAL); + +NTSYSAPI +PVOID +NTAPI +RtlInsertElementGenericTable( + IN PRTL_GENERIC_TABLE Table, + IN PVOID Buffer, + IN CLONG BufferSize, + OUT PBOOLEAN NewElement OPTIONAL); + +NTSYSAPI +PVOID +NTAPI +RtlInsertElementGenericTableFull( + IN PRTL_GENERIC_TABLE Table, + IN PVOID Buffer, + IN CLONG BufferSize, + OUT PBOOLEAN NewElement OPTIONAL, + IN PVOID NodeOrParent, + IN TABLE_SEARCH_RESULT SearchResult); + +NTSYSAPI +BOOLEAN +NTAPI +RtlDeleteElementGenericTable( + IN PRTL_GENERIC_TABLE Table, + IN PVOID Buffer); + +NTSYSAPI +PVOID +NTAPI +RtlLookupElementGenericTable( + IN PRTL_GENERIC_TABLE Table, + IN PVOID Buffer); + +NTSYSAPI +PVOID +NTAPI +RtlLookupElementGenericTableFull( + IN PRTL_GENERIC_TABLE Table, + IN PVOID Buffer, + OUT PVOID *NodeOrParent, + OUT TABLE_SEARCH_RESULT *SearchResult); + +NTSYSAPI +PVOID +NTAPI +RtlEnumerateGenericTable( + IN PRTL_GENERIC_TABLE Table, + IN BOOLEAN Restart); + +NTSYSAPI +PVOID +NTAPI +RtlEnumerateGenericTableWithoutSplaying( + IN PRTL_GENERIC_TABLE Table, + IN OUT PVOID *RestartKey); + +NTSYSAPI +PVOID +NTAPI +RtlGetElementGenericTable( + IN PRTL_GENERIC_TABLE Table, + IN ULONG I); + +NTSYSAPI +ULONG +NTAPI +RtlNumberGenericTableElements( + IN PRTL_GENERIC_TABLE Table); + +NTSYSAPI +BOOLEAN +NTAPI +RtlIsGenericTableEmpty( + IN PRTL_GENERIC_TABLE Table); + +#endif /* !RTL_USE_AVL_TABLES */ + +#define RTL_STACK_WALKING_MODE_FRAMES_TO_SKIP_SHIFT 8 + +NTSYSAPI +PRTL_SPLAY_LINKS +NTAPI +RtlSplay( + IN OUT PRTL_SPLAY_LINKS Links); + +NTSYSAPI +PRTL_SPLAY_LINKS +NTAPI +RtlDelete( + IN PRTL_SPLAY_LINKS Links); + +NTSYSAPI +VOID +NTAPI +RtlDeleteNoSplay( + IN PRTL_SPLAY_LINKS Links, + IN OUT PRTL_SPLAY_LINKS *Root); + +NTSYSAPI +PRTL_SPLAY_LINKS +NTAPI +RtlSubtreeSuccessor( + IN PRTL_SPLAY_LINKS Links); + +NTSYSAPI +PRTL_SPLAY_LINKS +NTAPI +RtlSubtreePredecessor( + IN PRTL_SPLAY_LINKS Links); + +NTSYSAPI +PRTL_SPLAY_LINKS +NTAPI +RtlRealSuccessor( + IN PRTL_SPLAY_LINKS Links); + +NTSYSAPI +PRTL_SPLAY_LINKS +NTAPI +RtlRealPredecessor( + IN PRTL_SPLAY_LINKS Links); + +NTSYSAPI +BOOLEAN +NTAPI +RtlPrefixUnicodeString( + IN PCUNICODE_STRING String1, + IN PCUNICODE_STRING String2, + IN BOOLEAN CaseInSensitive); + +NTSYSAPI +VOID +NTAPI +RtlUpperString( + IN OUT PSTRING DestinationString, + IN const PSTRING SourceString); + +NTSYSAPI +NTSTATUS +NTAPI +RtlUpcaseUnicodeString( + IN OUT PUNICODE_STRING DestinationString, + IN PCUNICODE_STRING SourceString, + IN BOOLEAN AllocateDestinationString); + +NTSYSAPI +VOID +NTAPI +RtlMapGenericMask( + IN OUT PACCESS_MASK AccessMask, + IN PGENERIC_MAPPING GenericMapping); + +NTSYSAPI +NTSTATUS +NTAPI +RtlVolumeDeviceToDosName( + IN PVOID VolumeDeviceObject, + OUT PUNICODE_STRING DosName); + +NTSYSAPI +NTSTATUS +NTAPI +RtlGetVersion( + IN OUT PRTL_OSVERSIONINFOW lpVersionInformation); + +NTSYSAPI +NTSTATUS +NTAPI +RtlVerifyVersionInfo( + IN PRTL_OSVERSIONINFOEXW VersionInfo, + IN ULONG TypeMask, + IN ULONGLONG ConditionMask); + +NTSYSAPI +LONG +NTAPI +RtlCompareString( + IN const PSTRING String1, + IN const PSTRING String2, + IN BOOLEAN CaseInSensitive); + +NTSYSAPI +VOID +NTAPI +RtlCopyString( + OUT PSTRING DestinationString, + IN const PSTRING SourceString OPTIONAL); + +NTSYSAPI +BOOLEAN +NTAPI +RtlEqualString( + IN const PSTRING String1, + IN const PSTRING String2, + IN BOOLEAN CaseInSensitive); + +NTSYSAPI +NTSTATUS +NTAPI +RtlCharToInteger( + IN PCSZ String, + IN ULONG Base OPTIONAL, + OUT PULONG Value); + +NTSYSAPI +CHAR +NTAPI +RtlUpperChar( + IN CHAR Character); + +NTSYSAPI +ULONG +NTAPI +RtlWalkFrameChain( + OUT PVOID *Callers, + IN ULONG Count, + IN ULONG Flags); + +$endif + +$if (_WDMDDK_) +NTSYSAPI +BOOLEAN +NTAPI +RtlAreBitsClear( + IN PRTL_BITMAP BitMapHeader, + IN ULONG StartingIndex, + IN ULONG Length); + +NTSYSAPI +BOOLEAN +NTAPI +RtlAreBitsSet( + IN PRTL_BITMAP BitMapHeader, + IN ULONG StartingIndex, + IN ULONG Length); + +NTSYSAPI +NTSTATUS +NTAPI +RtlAnsiStringToUnicodeString( + IN OUT PUNICODE_STRING DestinationString, + IN PANSI_STRING SourceString, + IN BOOLEAN AllocateDestinationString); + +NTSYSAPI +ULONG +NTAPI +RtlxAnsiStringToUnicodeSize( + IN PCANSI_STRING AnsiString); + +#define RtlAnsiStringToUnicodeSize(String) ( \ + NLS_MB_CODE_PAGE_TAG ? \ + RtlxAnsiStringToUnicodeSize(String) : \ + ((String)->Length + sizeof(ANSI_NULL)) * sizeof(WCHAR) \ +) + +NTSYSAPI +NTSTATUS +NTAPI +RtlAppendUnicodeStringToString( + IN OUT PUNICODE_STRING Destination, + IN PCUNICODE_STRING Source); + +NTSYSAPI +NTSTATUS +NTAPI +RtlAppendUnicodeToString( + IN OUT PUNICODE_STRING Destination, + IN PCWSTR Source); + +NTSYSAPI +NTSTATUS +NTAPI +RtlCheckRegistryKey( + IN ULONG RelativeTo, + IN PWSTR Path); + +NTSYSAPI +VOID +NTAPI +RtlClearAllBits( + IN PRTL_BITMAP BitMapHeader); + +NTSYSAPI +VOID +NTAPI +RtlClearBits( + IN PRTL_BITMAP BitMapHeader, + IN ULONG StartingIndex, + IN ULONG NumberToClear); + +NTSYSAPI +SIZE_T +NTAPI +RtlCompareMemory( + IN CONST VOID *Source1, + IN CONST VOID *Source2, + IN SIZE_T Length); + +NTSYSAPI +LONG +NTAPI +RtlCompareUnicodeString( + IN PCUNICODE_STRING String1, + IN PCUNICODE_STRING String2, + IN BOOLEAN CaseInSensitive); + +NTSYSAPI +LONG +NTAPI +RtlCompareUnicodeStrings( + IN PCWCH String1, + IN SIZE_T String1Length, + IN PCWCH String2, + IN SIZE_T String2Length, + IN BOOLEAN CaseInSensitive); + +NTSYSAPI +VOID +NTAPI +RtlCopyUnicodeString( + IN OUT PUNICODE_STRING DestinationString, + IN PCUNICODE_STRING SourceString OPTIONAL); + +NTSYSAPI +NTSTATUS +NTAPI +RtlCreateRegistryKey( + IN ULONG RelativeTo, + IN PWSTR Path); + +NTSYSAPI +NTSTATUS +NTAPI +RtlCreateSecurityDescriptor( + IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor, + IN ULONG Revision); + +NTSYSAPI +NTSTATUS +NTAPI +RtlDeleteRegistryValue( + IN ULONG RelativeTo, + IN PCWSTR Path, + IN PCWSTR ValueName); + +NTSYSAPI +BOOLEAN +NTAPI +RtlEqualUnicodeString( + IN CONST UNICODE_STRING *String1, + IN CONST UNICODE_STRING *String2, + IN BOOLEAN CaseInSensitive); + +#if !defined(_AMD64_) && !defined(_IA64_) +NTSYSAPI +LARGE_INTEGER +NTAPI +RtlExtendedIntegerMultiply( + IN LARGE_INTEGER Multiplicand, + IN LONG Multiplier); + +NTSYSAPI +LARGE_INTEGER +NTAPI +RtlExtendedLargeIntegerDivide( + IN LARGE_INTEGER Dividend, + IN ULONG Divisor, + OUT PULONG Remainder OPTIONAL); +#endif + +#if defined(_X86_) || defined(_IA64_) +NTSYSAPI +LARGE_INTEGER +NTAPI +RtlExtendedMagicDivide( + IN LARGE_INTEGER Dividend, + IN LARGE_INTEGER MagicDivisor, + IN CCHAR ShiftCount); +#endif + +NTSYSAPI +VOID +NTAPI +RtlFreeAnsiString( + IN PANSI_STRING AnsiString); + +NTSYSAPI +ULONG +NTAPI +RtlFindClearBits( + IN PRTL_BITMAP BitMapHeader, + IN ULONG NumberToFind, + IN ULONG HintIndex); + +NTSYSAPI +ULONG +NTAPI +RtlFindClearBitsAndSet( + IN PRTL_BITMAP BitMapHeader, + IN ULONG NumberToFind, + IN ULONG HintIndex); + +NTSYSAPI +ULONG +NTAPI +RtlFindFirstRunClear( + IN PRTL_BITMAP BitMapHeader, + OUT PULONG StartingIndex); + +NTSYSAPI +ULONG +NTAPI +RtlFindClearRuns( + IN PRTL_BITMAP BitMapHeader, + OUT PRTL_BITMAP_RUN RunArray, + IN ULONG SizeOfRunArray, + IN BOOLEAN LocateLongestRuns); + +NTSYSAPI +ULONG +NTAPI +RtlFindLastBackwardRunClear( + IN PRTL_BITMAP BitMapHeader, + IN ULONG FromIndex, + OUT PULONG StartingRunIndex); + +NTSYSAPI +CCHAR +NTAPI +RtlFindLeastSignificantBit( + IN ULONGLONG Set); + +NTSYSAPI +ULONG +NTAPI +RtlFindLongestRunClear( + IN PRTL_BITMAP BitMapHeader, + OUT PULONG StartingIndex); + +NTSYSAPI +CCHAR +NTAPI +RtlFindMostSignificantBit( + IN ULONGLONG Set); + +NTSYSAPI +ULONG +NTAPI +RtlFindNextForwardRunClear( + IN PRTL_BITMAP BitMapHeader, + IN ULONG FromIndex, + OUT PULONG StartingRunIndex); + +NTSYSAPI +ULONG +NTAPI +RtlFindSetBits( + IN PRTL_BITMAP BitMapHeader, + IN ULONG NumberToFind, + IN ULONG HintIndex); + +NTSYSAPI +ULONG +NTAPI +RtlFindSetBitsAndClear( + IN PRTL_BITMAP BitMapHeader, + IN ULONG NumberToFind, + IN ULONG HintIndex); + +NTSYSAPI +VOID +NTAPI +RtlInitAnsiString( + IN OUT PANSI_STRING DestinationString, + IN PCSZ SourceString); + +NTSYSAPI +VOID +NTAPI +RtlInitializeBitMap( + IN PRTL_BITMAP BitMapHeader, + IN PULONG BitMapBuffer, + IN ULONG SizeOfBitMap); + +NTSYSAPI +VOID +NTAPI +RtlInitString( + IN OUT PSTRING DestinationString, + IN PCSZ SourceString); + +NTSYSAPI +NTSTATUS +NTAPI +RtlIntegerToUnicodeString( + IN ULONG Value, + IN ULONG Base OPTIONAL, + IN OUT PUNICODE_STRING String); + +NTSYSAPI +NTSTATUS +NTAPI +RtlInt64ToUnicodeString( + IN ULONGLONG Value, + IN ULONG Base OPTIONAL, + IN OUT PUNICODE_STRING String); + +#ifdef _WIN64 +#define RtlIntPtrToUnicodeString(Value, Base, String) \ + RtlInt64ToUnicodeString(Value, Base, String) +#else +#define RtlIntPtrToUnicodeString(Value, Base, String) \ + RtlIntegerToUnicodeString(Value, Base, String) +#endif + +/* BOOLEAN + * RtlIsZeroLuid( + * IN PLUID L1); + */ +#define RtlIsZeroLuid(_L1) \ + ((BOOLEAN) ((!(_L1)->LowPart) && (!(_L1)->HighPart))) + +NTSYSAPI +ULONG +NTAPI +RtlLengthSecurityDescriptor( + IN PSECURITY_DESCRIPTOR SecurityDescriptor); + +NTSYSAPI +ULONG +NTAPI +RtlNumberOfClearBits( + IN PRTL_BITMAP BitMapHeader); + +NTSYSAPI +ULONG +NTAPI +RtlNumberOfSetBits( + IN PRTL_BITMAP BitMapHeader); + +NTSYSAPI +NTSTATUS +NTAPI +RtlQueryRegistryValues( + IN ULONG RelativeTo, + IN PCWSTR Path, + IN OUT PRTL_QUERY_REGISTRY_TABLE QueryTable, + IN PVOID Context OPTIONAL, + IN PVOID Environment OPTIONAL); + +#define SHORT_SIZE (sizeof(USHORT)) +#define SHORT_MASK (SHORT_SIZE - 1) +#define LONG_SIZE (sizeof(LONG)) +#define LONGLONG_SIZE (sizeof(LONGLONG)) +#define LONG_MASK (LONG_SIZE - 1) +#define LONGLONG_MASK (LONGLONG_SIZE - 1) +#define LOWBYTE_MASK 0x00FF + +#define FIRSTBYTE(VALUE) ((VALUE) & LOWBYTE_MASK) +#define SECONDBYTE(VALUE) (((VALUE) >> 8) & LOWBYTE_MASK) +#define THIRDBYTE(VALUE) (((VALUE) >> 16) & LOWBYTE_MASK) +#define FOURTHBYTE(VALUE) (((VALUE) >> 24) & LOWBYTE_MASK) + +NTSYSAPI +VOID +NTAPI +RtlSetAllBits( + IN PRTL_BITMAP BitMapHeader); + +NTSYSAPI +VOID +NTAPI +RtlSetBits( + IN PRTL_BITMAP BitMapHeader, + IN ULONG StartingIndex, + IN ULONG NumberToSet); + +NTSYSAPI +NTSTATUS +NTAPI +RtlSetDaclSecurityDescriptor( + IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor, + IN BOOLEAN DaclPresent, + IN PACL Dacl OPTIONAL, + IN BOOLEAN DaclDefaulted OPTIONAL); + +#if defined(_AMD64_) + +/* VOID + * RtlStoreUlong( + * IN PULONG Address, + * IN ULONG Value); + */ +#define RtlStoreUlong(Address,Value) \ + *(ULONG UNALIGNED *)(Address) = (Value) + +/* VOID + * RtlStoreUlonglong( + * IN OUT PULONGLONG Address, + * ULONGLONG Value); + */ +#define RtlStoreUlonglong(Address,Value) \ + *(ULONGLONG UNALIGNED *)(Address) = (Value) + +/* VOID + * RtlStoreUshort( + * IN PUSHORT Address, + * IN USHORT Value); + */ +#define RtlStoreUshort(Address,Value) \ + *(USHORT UNALIGNED *)(Address) = (Value) + +/* VOID + * RtlRetrieveUshort( + * PUSHORT DestinationAddress, + * PUSHORT SourceAddress); + */ +#define RtlRetrieveUshort(DestAddress,SrcAddress) \ + *(USHORT UNALIGNED *)(DestAddress) = *(USHORT)(SrcAddress) + +/* VOID + * RtlRetrieveUlong( + * PULONG DestinationAddress, + * PULONG SourceAddress); + */ +#define RtlRetrieveUlong(DestAddress,SrcAddress) \ + *(ULONG UNALIGNED *)(DestAddress) = *(PULONG)(SrcAddress) + +#else + +#define RtlStoreUlong(Address,Value) \ + if ((ULONG_PTR)(Address) & LONG_MASK) { \ + ((PUCHAR) (Address))[LONG_LEAST_SIGNIFICANT_BIT] = (UCHAR)(FIRSTBYTE(Value)); \ + ((PUCHAR) (Address))[LONG_3RD_MOST_SIGNIFICANT_BIT] = (UCHAR)(SECONDBYTE(Value)); \ + ((PUCHAR) (Address))[LONG_2ND_MOST_SIGNIFICANT_BIT] = (UCHAR)(THIRDBYTE(Value)); \ + ((PUCHAR) (Address))[LONG_MOST_SIGNIFICANT_BIT] = (UCHAR)(FOURTHBYTE(Value)); \ + } \ + else { \ + *((PULONG)(Address)) = (ULONG) (Value); \ + } + +#define RtlStoreUlonglong(Address,Value) \ + if ((ULONG_PTR)(Address) & LONGLONG_MASK) { \ + RtlStoreUlong((ULONG_PTR)(Address), \ + (ULONGLONG)(Value) & 0xFFFFFFFF); \ + RtlStoreUlong((ULONG_PTR)(Address)+sizeof(ULONG), \ + (ULONGLONG)(Value) >> 32); \ + } else { \ + *((PULONGLONG)(Address)) = (ULONGLONG)(Value); \ + } + +#define RtlStoreUshort(Address,Value) \ + if ((ULONG_PTR)(Address) & SHORT_MASK) { \ + ((PUCHAR) (Address))[SHORT_LEAST_SIGNIFICANT_BIT] = (UCHAR)(FIRSTBYTE(Value)); \ + ((PUCHAR) (Address))[SHORT_MOST_SIGNIFICANT_BIT ] = (UCHAR)(SECONDBYTE(Value)); \ + } \ + else { \ + *((PUSHORT) (Address)) = (USHORT)Value; \ + } + +#define RtlRetrieveUshort(DestAddress,SrcAddress) \ + if ((ULONG_PTR)(SrcAddress) & LONG_MASK) \ + { \ + ((PUCHAR)(DestAddress))[0]=((PUCHAR)(SrcAddress))[0]; \ + ((PUCHAR)(DestAddress))[1]=((PUCHAR)(SrcAddress))[1]; \ + } \ + else \ + { \ + *((PUSHORT)(DestAddress))=*((PUSHORT)(SrcAddress)); \ + } + +#define RtlRetrieveUlong(DestAddress,SrcAddress) \ + if ((ULONG_PTR)(SrcAddress) & LONG_MASK) \ + { \ + ((PUCHAR)(DestAddress))[0]=((PUCHAR)(SrcAddress))[0]; \ + ((PUCHAR)(DestAddress))[1]=((PUCHAR)(SrcAddress))[1]; \ + ((PUCHAR)(DestAddress))[2]=((PUCHAR)(SrcAddress))[2]; \ + ((PUCHAR)(DestAddress))[3]=((PUCHAR)(SrcAddress))[3]; \ + } \ + else \ + { \ + *((PULONG)(DestAddress))=*((PULONG)(SrcAddress)); \ + } + +#endif /* defined(_AMD64_) */ + +#ifdef _WIN64 +/* VOID + * RtlStoreUlongPtr( + * IN OUT PULONG_PTR Address, + * IN ULONG_PTR Value); + */ +#define RtlStoreUlongPtr(Address,Value) RtlStoreUlonglong(Address,Value) +#else +#define RtlStoreUlongPtr(Address,Value) RtlStoreUlong(Address,Value) +#endif /* _WIN64 */ + + +NTSYSAPI +BOOLEAN +NTAPI +RtlTimeFieldsToTime( + IN PTIME_FIELDS TimeFields, + IN PLARGE_INTEGER Time); + +NTSYSAPI +VOID +NTAPI +RtlTimeToTimeFields( + IN PLARGE_INTEGER Time, + IN PTIME_FIELDS TimeFields); + +NTSYSAPI +ULONG +FASTCALL +RtlUlongByteSwap( + IN ULONG Source); + +NTSYSAPI +ULONGLONG +FASTCALL +RtlUlonglongByteSwap( + IN ULONGLONG Source); + +NTSYSAPI +NTSTATUS +NTAPI +RtlUnicodeStringToAnsiString( + IN OUT PANSI_STRING DestinationString, + IN PCUNICODE_STRING SourceString, + IN BOOLEAN AllocateDestinationString); + +NTSYSAPI +ULONG +NTAPI +RtlxUnicodeStringToAnsiSize( + IN PCUNICODE_STRING UnicodeString); + +#define RtlUnicodeStringToAnsiSize(String) ( \ + NLS_MB_CODE_PAGE_TAG ? \ + RtlxUnicodeStringToAnsiSize(String) : \ + ((String)->Length + sizeof(UNICODE_NULL)) / sizeof(WCHAR) \ +) + +NTSYSAPI +NTSTATUS +NTAPI +RtlUnicodeStringToInteger( + IN PCUNICODE_STRING String, + IN ULONG Base OPTIONAL, + OUT PULONG Value); + +NTSYSAPI +WCHAR +NTAPI +RtlUpcaseUnicodeChar( + IN WCHAR SourceCharacter); + +NTSYSAPI +USHORT +FASTCALL +RtlUshortByteSwap( + IN USHORT Source); + +NTSYSAPI +BOOLEAN +NTAPI +RtlValidRelativeSecurityDescriptor( + IN PSECURITY_DESCRIPTOR SecurityDescriptorInput, + IN ULONG SecurityDescriptorLength, + IN SECURITY_INFORMATION RequiredInformation); + +NTSYSAPI +BOOLEAN +NTAPI +RtlValidSecurityDescriptor( + IN PSECURITY_DESCRIPTOR SecurityDescriptor); + +NTSYSAPI +NTSTATUS +NTAPI +RtlWriteRegistryValue( + IN ULONG RelativeTo, + IN PCWSTR Path, + IN PCWSTR ValueName, + IN ULONG ValueType, + IN PVOID ValueData, + IN ULONG ValueLength); + +$endif + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ + +$if (_WDMDDK_) + +#if (NTDDI_VERSION >= NTDDI_WIN2KSP3) +NTSYSAPI +VOID +FASTCALL +RtlPrefetchMemoryNonTemporal( + IN PVOID Source, + IN SIZE_T Length); +#endif + +$endif + +#if (NTDDI_VERSION >= NTDDI_WINXP) + +$if (_NTDDK_) + +NTSYSAPI +VOID +NTAPI +RtlInitializeGenericTableAvl( + OUT PRTL_AVL_TABLE Table, + IN PRTL_AVL_COMPARE_ROUTINE CompareRoutine, + IN PRTL_AVL_ALLOCATE_ROUTINE AllocateRoutine, + IN PRTL_AVL_FREE_ROUTINE FreeRoutine, + IN PVOID TableContext OPTIONAL); + +NTSYSAPI +PVOID +NTAPI +RtlInsertElementGenericTableAvl( + IN PRTL_AVL_TABLE Table, + IN PVOID Buffer, + IN CLONG BufferSize, + OUT PBOOLEAN NewElement OPTIONAL); + +NTSYSAPI +PVOID +NTAPI +RtlInsertElementGenericTableFullAvl( + IN PRTL_AVL_TABLE Table, + IN PVOID Buffer, + IN CLONG BufferSize, + OUT PBOOLEAN NewElement OPTIONAL, + IN PVOID NodeOrParent, + IN TABLE_SEARCH_RESULT SearchResult); + +NTSYSAPI +BOOLEAN +NTAPI +RtlDeleteElementGenericTableAvl( + IN PRTL_AVL_TABLE Table, + IN PVOID Buffer); + +NTSYSAPI +PVOID +NTAPI +RtlLookupElementGenericTableAvl( + IN PRTL_AVL_TABLE Table, + IN PVOID Buffer); + +NTSYSAPI +PVOID +NTAPI +RtlLookupElementGenericTableFullAvl( + IN PRTL_AVL_TABLE Table, + IN PVOID Buffer, + OUT PVOID *NodeOrParent, + OUT TABLE_SEARCH_RESULT *SearchResult); + +NTSYSAPI +PVOID +NTAPI +RtlEnumerateGenericTableAvl( + IN PRTL_AVL_TABLE Table, + IN BOOLEAN Restart); + +NTSYSAPI +PVOID +NTAPI +RtlEnumerateGenericTableWithoutSplayingAvl( + IN PRTL_AVL_TABLE Table, + IN OUT PVOID *RestartKey); + +NTSYSAPI +PVOID +NTAPI +RtlLookupFirstMatchingElementGenericTableAvl( + IN PRTL_AVL_TABLE Table, + IN PVOID Buffer, + OUT PVOID *RestartKey); + +NTSYSAPI +PVOID +NTAPI +RtlEnumerateGenericTableLikeADirectory( + IN PRTL_AVL_TABLE Table, + IN PRTL_AVL_MATCH_FUNCTION MatchFunction OPTIONAL, + IN PVOID MatchData OPTIONAL, + IN ULONG NextFlag, + IN OUT PVOID *RestartKey, + IN OUT PULONG DeleteCount, + IN PVOID Buffer); + +NTSYSAPI +PVOID +NTAPI +RtlGetElementGenericTableAvl( + IN PRTL_AVL_TABLE Table, + IN ULONG I); + +NTSYSAPI +ULONG +NTAPI +RtlNumberGenericTableElementsAvl( + IN PRTL_AVL_TABLE Table); + +NTSYSAPI +BOOLEAN +NTAPI +RtlIsGenericTableEmptyAvl( + IN PRTL_AVL_TABLE Table); + +$endif + +$if (_WDMDDK_) + +NTSYSAPI +VOID +NTAPI +RtlClearBit( + PRTL_BITMAP BitMapHeader, + ULONG BitNumber); + +NTSYSAPI +WCHAR +NTAPI +RtlDowncaseUnicodeChar( + IN WCHAR SourceCharacter); + +NTSYSAPI +VOID +NTAPI +RtlSetBit( + PRTL_BITMAP BitMapHeader, + ULONG BitNumber); + +NTSYSAPI +BOOLEAN +NTAPI +RtlTestBit( + IN PRTL_BITMAP BitMapHeader, + IN ULONG BitNumber); + +NTSYSAPI +NTSTATUS +NTAPI +RtlHashUnicodeString( + IN CONST UNICODE_STRING *String, + IN BOOLEAN CaseInSensitive, + IN ULONG HashAlgorithm, + OUT PULONG HashValue); + +$endif + +#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ + +#if (NTDDI_VERSION >= NTDDI_VISTA) + +$if (_NTDDK_) + +NTSYSAPI +VOID +NTAPI +RtlRunOnceInitialize( + OUT PRTL_RUN_ONCE RunOnce); + +NTSYSAPI +NTSTATUS +NTAPI +RtlRunOnceExecuteOnce( + IN OUT PRTL_RUN_ONCE RunOnce, + IN PRTL_RUN_ONCE_INIT_FN InitFn, + IN OUT PVOID Parameter OPTIONAL, + OUT PVOID *Context OPTIONAL); + +NTSYSAPI +NTSTATUS +NTAPI +RtlRunOnceBeginInitialize( + IN OUT PRTL_RUN_ONCE RunOnce, + IN ULONG Flags, + OUT PVOID *Context OPTIONAL); + +NTSYSAPI +NTSTATUS +NTAPI +RtlRunOnceComplete( + IN OUT PRTL_RUN_ONCE RunOnce, + IN ULONG Flags, + IN PVOID Context OPTIONAL); + +NTSYSAPI +BOOLEAN +NTAPI +RtlGetProductInfo( + IN ULONG OSMajorVersion, + IN ULONG OSMinorVersion, + IN ULONG SpMajorVersion, + IN ULONG SpMinorVersion, + OUT PULONG ReturnedProductType); + +$endif + +$if (_WDMDDK_) + +NTSYSAPI +ULONG +NTAPI +RtlNumberOfSetBitsUlongPtr( + IN ULONG_PTR Target); + +NTSYSAPI +ULONGLONG +NTAPI +RtlIoDecodeMemIoResource( + IN struct _IO_RESOURCE_DESCRIPTOR *Descriptor, + OUT PULONGLONG Alignment OPTIONAL, + OUT PULONGLONG MinimumAddress OPTIONAL, + OUT PULONGLONG MaximumAddress OPTIONAL); + +NTSYSAPI +NTSTATUS +NTAPI +RtlIoEncodeMemIoResource( + IN struct _IO_RESOURCE_DESCRIPTOR *Descriptor, + IN UCHAR Type, + IN ULONGLONG Length, + IN ULONGLONG Alignment, + IN ULONGLONG MinimumAddress, + IN ULONGLONG MaximumAddress); + +NTSYSAPI +ULONGLONG +NTAPI +RtlCmDecodeMemIoResource( + IN struct _CM_PARTIAL_RESOURCE_DESCRIPTOR *Descriptor, + OUT PULONGLONG Start OPTIONAL); + +NTSYSAPI +NTSTATUS +NTAPI +RtlFindClosestEncodableLength( + IN ULONGLONG SourceLength, + OUT PULONGLONG TargetLength); + +NTSYSAPI +NTSTATUS +NTAPI +RtlCmEncodeMemIoResource( + IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor, + IN UCHAR Type, + IN ULONGLONG Length, + IN ULONGLONG Start); + +$endif + +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + +#if (NTDDI_VERSION >= NTDDI_WIN7) + +$if (_NTDDK_) + +NTSYSAPI +BOOLEAN +NTAPI +RtlCreateHashTable( + IN OUT PRTL_DYNAMIC_HASH_TABLE *HashTable OPTIONAL, + IN ULONG Shift, + IN ULONG Flags); + +NTSYSAPI +VOID +NTAPI +RtlDeleteHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable); + +NTSYSAPI +BOOLEAN +NTAPI +RtlInsertEntryHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable, + IN PRTL_DYNAMIC_HASH_TABLE_ENTRY Entry, + IN ULONG_PTR Signature, + IN OUT PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context OPTIONAL); + +NTSYSAPI +BOOLEAN +NTAPI +RtlRemoveEntryHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable, + IN PRTL_DYNAMIC_HASH_TABLE_ENTRY Entry, + IN OUT PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context OPTIONAL); + +NTSYSAPI +PRTL_DYNAMIC_HASH_TABLE_ENTRY +NTAPI +RtlLookupEntryHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable, + IN ULONG_PTR Signature, + OUT PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context OPTIONAL); + +NTSYSAPI +PRTL_DYNAMIC_HASH_TABLE_ENTRY +NTAPI +RtlGetNextEntryHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable, + IN PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context); + +NTSYSAPI +BOOLEAN +NTAPI +RtlInitEnumerationHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable, + OUT PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator); + +NTSYSAPI +PRTL_DYNAMIC_HASH_TABLE_ENTRY +NTAPI +RtlEnumerateEntryHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable, + IN OUT PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator); + +NTSYSAPI +VOID +NTAPI +RtlEndEnumerationHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable, + IN OUT PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator); + +NTSYSAPI +BOOLEAN +NTAPI +RtlInitWeakEnumerationHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable, + OUT PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator); + +NTSYSAPI +PRTL_DYNAMIC_HASH_TABLE_ENTRY +NTAPI +RtlWeaklyEnumerateEntryHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable, + IN OUT PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator); + +NTSYSAPI +VOID +NTAPI +RtlEndWeakEnumerationHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable, + IN OUT PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator); + +NTSYSAPI +BOOLEAN +NTAPI +RtlExpandHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable); + +NTSYSAPI +BOOLEAN +NTAPI +RtlContractHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable); + +$endif + +$if (_WDMDDK_) + +NTSYSAPI +NTSTATUS +NTAPI +RtlUnicodeToUTF8N( + OUT PCHAR UTF8StringDestination, + IN ULONG UTF8StringMaxByteCount, + OUT PULONG UTF8StringActualByteCount, + IN PCWCH UnicodeStringSource, + IN ULONG UnicodeStringByteCount); + +NTSYSAPI +NTSTATUS +NTAPI +RtlUTF8ToUnicodeN( + OUT PWSTR UnicodeStringDestination, + IN ULONG UnicodeStringMaxByteCount, + OUT PULONG UnicodeStringActualByteCount, + IN PCCH UTF8StringSource, + IN ULONG UTF8StringByteCount); + +NTSYSAPI +ULONG64 +NTAPI +RtlGetEnabledExtendedFeatures( + IN ULONG64 FeatureMask); + +$endif + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + +$if (_WDMDDK_) + +#if !defined(MIDL_PASS) +/* inline funftions */ +//DECLSPEC_DEPRECATED_DDK_WINXP +static __inline +LARGE_INTEGER +NTAPI_INLINE +RtlConvertLongToLargeInteger( + IN LONG SignedInteger) +{ + LARGE_INTEGER ret; + ret.QuadPart = SignedInteger; + return ret; +} + +//DECLSPEC_DEPRECATED_DDK_WINXP +static __inline +LARGE_INTEGER +NTAPI_INLINE +RtlConvertUlongToLargeInteger( + IN ULONG UnsignedInteger) +{ + LARGE_INTEGER ret; + ret.QuadPart = UnsignedInteger; + return ret; +} + +//DECLSPEC_DEPRECATED_DDK_WINXP +static __inline +LARGE_INTEGER +NTAPI_INLINE +RtlLargeIntegerShiftLeft( + IN LARGE_INTEGER LargeInteger, + IN CCHAR ShiftCount) +{ + LARGE_INTEGER Result; + + Result.QuadPart = LargeInteger.QuadPart << ShiftCount; + return Result; +} + +//DECLSPEC_DEPRECATED_DDK_WINXP +static __inline +LARGE_INTEGER +NTAPI_INLINE +RtlLargeIntegerShiftRight( + IN LARGE_INTEGER LargeInteger, + IN CCHAR ShiftCount) +{ + LARGE_INTEGER Result; + + Result.QuadPart = (ULONG64)LargeInteger.QuadPart >> ShiftCount; + return Result; +} + +//DECLSPEC_DEPRECATED_DDK +static __inline +ULONG +NTAPI_INLINE +RtlEnlargedUnsignedDivide( + IN ULARGE_INTEGER Dividend, + IN ULONG Divisor, + IN OUT PULONG Remainder) +{ + if (Remainder) + *Remainder = (ULONG)(Dividend.QuadPart % Divisor); + return (ULONG)(Dividend.QuadPart / Divisor); +} + +//DECLSPEC_DEPRECATED_DDK +static __inline +LARGE_INTEGER +NTAPI_INLINE +RtlLargeIntegerNegate( + IN LARGE_INTEGER Subtrahend) +{ + LARGE_INTEGER Difference; + + Difference.QuadPart = -Subtrahend.QuadPart; + return Difference; +} + +//DECLSPEC_DEPRECATED_DDK +static __inline +LARGE_INTEGER +NTAPI_INLINE +RtlLargeIntegerSubtract( + IN LARGE_INTEGER Minuend, + IN LARGE_INTEGER Subtrahend) +{ + LARGE_INTEGER Difference; + + Difference.QuadPart = Minuend.QuadPart - Subtrahend.QuadPart; + return Difference; +} + +//DECLSPEC_DEPRECATED_DDK +static __inline +LARGE_INTEGER +NTAPI_INLINE +RtlEnlargedUnsignedMultiply( + IN ULONG Multiplicand, + IN ULONG Multiplier) +{ + LARGE_INTEGER ret; + ret.QuadPart = (ULONGLONG)Multiplicand * (ULONGLONG)Multiplier; + return ret; +} + +//DECLSPEC_DEPRECATED_DDK +static __inline +LARGE_INTEGER +NTAPI_INLINE +RtlEnlargedIntegerMultiply( + IN LONG Multiplicand, + IN LONG Multiplier) +{ + LARGE_INTEGER ret; + ret.QuadPart = (LONGLONG)Multiplicand * (ULONGLONG)Multiplier; + return ret; +} + +FORCEINLINE +VOID +RtlInitEmptyAnsiString( + OUT PANSI_STRING AnsiString, + IN PCHAR Buffer, + IN USHORT BufferSize) +{ + AnsiString->Length = 0; + AnsiString->MaximumLength = BufferSize; + AnsiString->Buffer = Buffer; +} + +FORCEINLINE +VOID +RtlInitEmptyUnicodeString( + OUT PUNICODE_STRING UnicodeString, + IN PWSTR Buffer, + IN USHORT BufferSize) +{ + UnicodeString->Length = 0; + UnicodeString->MaximumLength = BufferSize; + UnicodeString->Buffer = Buffer; +} +$endif + +#if defined(_AMD64_) || defined(_IA64_) + +$if (_WDMDDK_) + +static __inline +LARGE_INTEGER +NTAPI_INLINE +RtlExtendedIntegerMultiply( + IN LARGE_INTEGER Multiplicand, + IN LONG Multiplier) +{ + LARGE_INTEGER ret; + ret.QuadPart = Multiplicand.QuadPart * Multiplier; + return ret; +} + +static __inline +LARGE_INTEGER +NTAPI_INLINE +RtlExtendedLargeIntegerDivide( + IN LARGE_INTEGER Dividend, + IN ULONG Divisor, + OUT PULONG Remainder OPTIONAL) +{ + LARGE_INTEGER ret; + ret.QuadPart = (ULONG64)Dividend.QuadPart / Divisor; + if (Remainder) + *Remainder = (ULONG)(Dividend.QuadPart % Divisor); + return ret; +} + +$endif + +$if (_NTDDK_) + +//DECLSPEC_DEPRECATED_DDK_WINXP +FORCEINLINE +LARGE_INTEGER +NTAPI_INLINE +RtlLargeIntegerDivide( + IN LARGE_INTEGER Dividend, + IN LARGE_INTEGER Divisor, + OUT PLARGE_INTEGER Remainder OPTIONAL) +{ + LARGE_INTEGER ret; + ret.QuadPart = Dividend.QuadPart / Divisor.QuadPart; + if (Remainder) + Remainder->QuadPart = Dividend.QuadPart % Divisor.QuadPart; + return ret; +} + +#else + +#if (NTDDI_VERSION >= NTDDI_WIN2K) +NTSYSAPI +LARGE_INTEGER +NTAPI +RtlLargeIntegerDivide( + IN LARGE_INTEGER Dividend, + IN LARGE_INTEGER Divisor, + OUT PLARGE_INTEGER Remainder OPTIONAL); +#endif + +$endif + +#endif /* defined(_AMD64_) || defined(_IA64_) */ + +$if (_WDMDDK_) + +#if defined(_AMD64_) + +#define MultiplyHigh __mulh +#define UnsignedMultiplyHigh __umulh + +//DECLSPEC_DEPRECATED_DDK +static __inline +LARGE_INTEGER +NTAPI_INLINE +RtlExtendedMagicDivide( + IN LARGE_INTEGER Dividend, + IN LARGE_INTEGER MagicDivisor, + IN CCHAR ShiftCount) +{ + LARGE_INTEGER ret; + ULONG64 ret64; + BOOLEAN Pos; + Pos = (Dividend.QuadPart >= 0); + ret64 = UnsignedMultiplyHigh(Pos ? Dividend.QuadPart : -Dividend.QuadPart, + MagicDivisor.QuadPart); + ret64 >>= ShiftCount; + ret.QuadPart = Pos ? ret64 : -ret64; + return ret; +} +#endif + +//DECLSPEC_DEPRECATED_DDK +static __inline +LARGE_INTEGER +NTAPI_INLINE +RtlLargeIntegerAdd( + IN LARGE_INTEGER Addend1, + IN LARGE_INTEGER Addend2) +{ + LARGE_INTEGER ret; + ret.QuadPart = Addend1.QuadPart + Addend2.QuadPart; + return ret; +} + +/* VOID + * RtlLargeIntegerAnd( + * IN OUT LARGE_INTEGER Result, + * IN LARGE_INTEGER Source, + * IN LARGE_INTEGER Mask); + */ +#define RtlLargeIntegerAnd(Result, Source, Mask) \ + Result.QuadPart = Source.QuadPart & Mask.QuadPart + +//DECLSPEC_DEPRECATED_DDK +static __inline +LARGE_INTEGER +NTAPI_INLINE +RtlLargeIntegerArithmeticShift( + IN LARGE_INTEGER LargeInteger, + IN CCHAR ShiftCount) +{ + LARGE_INTEGER ret; + ret.QuadPart = LargeInteger.QuadPart >> ShiftCount; + return ret; +} + +/* BOOLEAN + * RtlLargeIntegerEqualTo( + * IN LARGE_INTEGER Operand1, + * IN LARGE_INTEGER Operand2); + */ +#define RtlLargeIntegerEqualTo(X,Y) \ + (!(((X).LowPart ^ (Y).LowPart) | ((X).HighPart ^ (Y).HighPart))) + +FORCEINLINE +PVOID +RtlSecureZeroMemory( + OUT PVOID Pointer, + IN SIZE_T Size) +{ + volatile char* vptr = (volatile char*)Pointer; +#if defined(_M_AMD64) + __stosb((PUCHAR)vptr, 0, Size); +#else + char * endptr = (char *)vptr + Size; + while (vptr < endptr) { + *vptr = 0; vptr++; + } +#endif + return Pointer; +} + +#if defined(_M_AMD64) +FORCEINLINE +BOOLEAN +RtlCheckBit( + IN PRTL_BITMAP BitMapHeader, + IN ULONG BitPosition) +{ + return BitTest64((LONG64 CONST*)BitMapHeader->Buffer, (LONG64)BitPosition); +} +#else +#define RtlCheckBit(BMH,BP) (((((PLONG)(BMH)->Buffer)[(BP)/32]) >> ((BP)%32)) & 0x1) +#endif /* defined(_M_AMD64) */ + +#define RtlLargeIntegerGreaterThan(X,Y) ( \ + (((X).HighPart == (Y).HighPart) && ((X).LowPart > (Y).LowPart)) || \ + ((X).HighPart > (Y).HighPart) \ +) + +#define RtlLargeIntegerGreaterThanOrEqualTo(X,Y) ( \ + (((X).HighPart == (Y).HighPart) && ((X).LowPart >= (Y).LowPart)) || \ + ((X).HighPart > (Y).HighPart) \ +) + +#define RtlLargeIntegerNotEqualTo(X,Y) ( \ + (((X).LowPart ^ (Y).LowPart) | ((X).HighPart ^ (Y).HighPart)) \ +) + +#define RtlLargeIntegerLessThan(X,Y) ( \ + (((X).HighPart == (Y).HighPart) && ((X).LowPart < (Y).LowPart)) || \ + ((X).HighPart < (Y).HighPart) \ +) + +#define RtlLargeIntegerLessThanOrEqualTo(X,Y) ( \ + (((X).HighPart == (Y).HighPart) && ((X).LowPart <= (Y).LowPart)) || \ + ((X).HighPart < (Y).HighPart) \ +) + +#define RtlLargeIntegerGreaterThanZero(X) ( \ + (((X).HighPart == 0) && ((X).LowPart > 0)) || \ + ((X).HighPart > 0 ) \ +) + +#define RtlLargeIntegerGreaterOrEqualToZero(X) ( (X).HighPart >= 0 ) + +#define RtlLargeIntegerEqualToZero(X) ( !((X).LowPart | (X).HighPart) ) + +#define RtlLargeIntegerNotEqualToZero(X) ( ((X).LowPart | (X).HighPart) ) + +#define RtlLargeIntegerLessThanZero(X) ( ((X).HighPart < 0) ) + +#define RtlLargeIntegerLessOrEqualToZero(X) ( ((X).HighPart < 0) || !((X).LowPart | (X).HighPart) ) + +#endif /* !defined(MIDL_PASS) */ + +/* Byte Swap Functions */ +#if (defined(_M_IX86) && (_MSC_FULL_VER > 13009037 || defined(__GNUC__))) || \ + ((defined(_M_AMD64) || defined(_M_IA64)) \ + && (_MSC_FULL_VER > 13009175 || defined(__GNUC__))) + +#define RtlUshortByteSwap(_x) _byteswap_ushort((USHORT)(_x)) +#define RtlUlongByteSwap(_x) _byteswap_ulong((_x)) +#define RtlUlonglongByteSwap(_x) _byteswap_uint64((_x)) + +#endif + +#if DBG + +#define ASSERT(exp) \ + (VOID)((!(exp)) ? \ + RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, NULL ), FALSE : TRUE) + +#define ASSERTMSG(msg, exp) \ + (VOID)((!(exp)) ? \ + RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, msg ), FALSE : TRUE) + +#define RTL_SOFT_ASSERT(exp) \ + (VOID)((!(exp)) ? \ + DbgPrint("%s(%d): Soft assertion failed\n Expression: %s\n", __FILE__, __LINE__, #exp), FALSE : TRUE) + +#define RTL_SOFT_ASSERTMSG(msg, exp) \ + (VOID)((!(exp)) ? \ + DbgPrint("%s(%d): Soft assertion failed\n Expression: %s\n Message: %s\n", __FILE__, __LINE__, #exp, (msg)), FALSE : TRUE) + +#define RTL_VERIFY(exp) ASSERT(exp) +#define RTL_VERIFYMSG(msg, exp) ASSERTMSG(msg, exp) + +#define RTL_SOFT_VERIFY(exp) RTL_SOFT_ASSERT(exp) +#define RTL_SOFT_VERIFYMSG(msg, exp) RTL_SOFT_ASSERTMSG(msg, exp) + +#if defined(_MSC_VER) + +#define NT_ASSERT(exp) \ + ((!(exp)) ? \ + (__annotation(L"Debug", L"AssertFail", L#exp), \ + DbgRaiseAssertionFailure(), FALSE) : TRUE) + +#define NT_ASSERTMSG(msg, exp) \ + ((!(exp)) ? \ + (__annotation(L"Debug", L"AssertFail", L##msg), \ + DbgRaiseAssertionFailure(), FALSE) : TRUE) + +#define NT_ASSERTMSGW(msg, exp) \ + ((!(exp)) ? \ + (__annotation(L"Debug", L"AssertFail", msg), \ + DbgRaiseAssertionFailure(), FALSE) : TRUE) + +#define NT_VERIFY NT_ASSERT +#define NT_VERIFYMSG NT_ASSERTMSG +#define NT_VERIFYMSGW NT_ASSERTMSGW + +#else + +/* GCC doesn't support __annotation (nor PDB) */ +#define NT_ASSERT(exp) \ + (VOID)((!(exp)) ? (DbgRaiseAssertionFailure(), FALSE) : TRUE) + +#define NT_ASSERTMSG NT_ASSERT +#define NT_ASSERTMSGW NT_ASSERT + +#endif + +#else /* !DBG */ + +#define ASSERT(exp) ((VOID) 0) +#define ASSERTMSG(msg, exp) ((VOID) 0) + +#define RTL_SOFT_ASSERT(exp) ((VOID) 0) +#define RTL_SOFT_ASSERTMSG(msg, exp) ((VOID) 0) + +#define RTL_VERIFY(exp) ((exp) ? TRUE : FALSE) +#define RTL_VERIFYMSG(msg, exp) ((exp) ? TRUE : FALSE) + +#define RTL_SOFT_VERIFY(exp) ((exp) ? TRUE : FALSE) +#define RTL_SOFT_VERIFYMSG(msg, exp) ((exp) ? TRUE : FALSE) + +#define NT_ASSERT(exp) ((VOID)0) +#define NT_ASSERTMSG(msg, exp) ((VOID)0) +#define NT_ASSERTMSGW(msg, exp) ((VOID)0) + +#define NT_VERIFY(_exp) ((_exp) ? TRUE : FALSE) +#define NT_VERIFYMSG(_msg, _exp ) ((_exp) ? TRUE : FALSE) +#define NT_VERIFYMSGW(_msg, _exp) ((_exp) ? TRUE : FALSE) + +#endif /* DBG */ + +#define InitializeListHead32(ListHead) (\ + (ListHead)->Flink = (ListHead)->Blink = PtrToUlong((ListHead))) + +#if !defined(_WINBASE_) + +#if defined(_WIN64) && (defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_) || defined(_NTOSP_)) + +NTKERNELAPI +VOID +InitializeSListHead( + OUT PSLIST_HEADER SListHead); + +#else + +VOID +FORCEINLINE +InitializeSListHead( + OUT PSLIST_HEADER SListHead) +{ +#if defined(_IA64_) + ULONG64 FeatureBits; +#endif + +#if defined(_WIN64) + if (((ULONG_PTR)SListHead & 0xf) != 0) { + RtlRaiseStatus(STATUS_DATATYPE_MISALIGNMENT); + } +#endif + RtlZeroMemory(SListHead, sizeof(SLIST_HEADER)); +#if defined(_IA64_) + FeatureBits = __getReg(CV_IA64_CPUID4); + if ((FeatureBits & KF_16BYTE_INSTR) != 0) { + SListHead->Header16.HeaderType = 1; + SListHead->Header16.Init = 1; + } +#endif +} + +#endif + +#if defined(_WIN64) + +#define InterlockedPopEntrySList(Head) \ + ExpInterlockedPopEntrySList(Head) + +#define InterlockedPushEntrySList(Head, Entry) \ + ExpInterlockedPushEntrySList(Head, Entry) + +#define InterlockedFlushSList(Head) \ + ExpInterlockedFlushSList(Head) + +#define QueryDepthSList(Head) \ + ExQueryDepthSList(Head) + +#else /* !defined(_WIN64) */ + +NTKERNELAPI +PSLIST_ENTRY +FASTCALL +InterlockedPopEntrySList( + IN PSLIST_HEADER ListHead); + +NTKERNELAPI +PSLIST_ENTRY +FASTCALL +InterlockedPushEntrySList( + IN PSLIST_HEADER ListHead, + IN PSLIST_ENTRY ListEntry); + +#define InterlockedFlushSList(ListHead) \ + ExInterlockedFlushSList(ListHead) + +#define QueryDepthSList(Head) \ + ExQueryDepthSList(Head) + +#endif /* !defined(_WIN64) */ + +#endif /* !defined(_WINBASE_) */ + +#define RTL_CONTEXT_EX_OFFSET(ContextEx, Chunk) ((ContextEx)->Chunk.Offset) +#define RTL_CONTEXT_EX_LENGTH(ContextEx, Chunk) ((ContextEx)->Chunk.Length) +#define RTL_CONTEXT_EX_CHUNK(Base, Layout, Chunk) \ + ((PVOID)((PCHAR)(Base) + RTL_CONTEXT_EX_OFFSET(Layout, Chunk))) +#define RTL_CONTEXT_OFFSET(Context, Chunk) \ + RTL_CONTEXT_EX_OFFSET((PCONTEXT_EX)(Context + 1), Chunk) +#define RTL_CONTEXT_LENGTH(Context, Chunk) \ + RTL_CONTEXT_EX_LENGTH((PCONTEXT_EX)(Context + 1), Chunk) +#define RTL_CONTEXT_CHUNK(Context, Chunk) \ + RTL_CONTEXT_EX_CHUNK((PCONTEXT_EX)(Context + 1), \ + (PCONTEXT_EX)(Context + 1), \ + Chunk) + +BOOLEAN +RTLVERLIB_DDI(RtlIsNtDdiVersionAvailable)( + IN ULONG Version); + +BOOLEAN +RTLVERLIB_DDI(RtlIsServicePackVersionInstalled)( + IN ULONG Version); + +#ifndef RtlIsNtDdiVersionAvailable +#define RtlIsNtDdiVersionAvailable WdmlibRtlIsNtDdiVersionAvailable +#endif + +#ifndef RtlIsServicePackVersionInstalled +#define RtlIsServicePackVersionInstalled WdmlibRtlIsServicePackVersionInstalled +#endif + +#define RtlInterlockedSetBits(Flags, Flag) \ + InterlockedOr((PLONG)(Flags), Flag) + +#define RtlInterlockedAndBits(Flags, Flag) \ + InterlockedAnd((PLONG)(Flags), Flag) + +#define RtlInterlockedClearBits(Flags, Flag) \ + RtlInterlockedAndBits(Flags, ~(Flag)) + +#define RtlInterlockedXorBits(Flags, Flag) \ + InterlockedXor(Flags, Flag) + +#define RtlInterlockedSetBitsDiscardReturn(Flags, Flag) \ + (VOID) RtlInterlockedSetBits(Flags, Flag) + +#define RtlInterlockedAndBitsDiscardReturn(Flags, Flag) \ + (VOID) RtlInterlockedAndBits(Flags, Flag) + +#define RtlInterlockedClearBitsDiscardReturn(Flags, Flag) \ + RtlInterlockedAndBitsDiscardReturn(Flags, ~(Flag)) + +$endif + +$if (_NTDDK_) + +#ifdef RTL_USE_AVL_TABLES + +#define RtlInitializeGenericTable RtlInitializeGenericTableAvl +#define RtlInsertElementGenericTable RtlInsertElementGenericTableAvl +#define RtlInsertElementGenericTableFull RtlInsertElementGenericTableFullAvl +#define RtlDeleteElementGenericTable RtlDeleteElementGenericTableAvl +#define RtlLookupElementGenericTable RtlLookupElementGenericTableAvl +#define RtlLookupElementGenericTableFull RtlLookupElementGenericTableFullAvl +#define RtlEnumerateGenericTable RtlEnumerateGenericTableAvl +#define RtlEnumerateGenericTableWithoutSplaying RtlEnumerateGenericTableWithoutSplayingAvl +#define RtlGetElementGenericTable RtlGetElementGenericTableAvl +#define RtlNumberGenericTableElements RtlNumberGenericTableElementsAvl +#define RtlIsGenericTableEmpty RtlIsGenericTableEmptyAvl + +#endif /* RTL_USE_AVL_TABLES */ + +#define RtlInitializeSplayLinks(Links) { \ + PRTL_SPLAY_LINKS _SplayLinks; \ + _SplayLinks = (PRTL_SPLAY_LINKS)(Links); \ + _SplayLinks->Parent = _SplayLinks; \ + _SplayLinks->LeftChild = NULL; \ + _SplayLinks->RightChild = NULL; \ +} + +#define RtlIsLeftChild(Links) \ + (RtlLeftChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links)) + +#define RtlIsRightChild(Links) \ + (RtlRightChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links)) + +#define RtlRightChild(Links) \ + ((PRTL_SPLAY_LINKS)(Links))->RightChild + +#define RtlIsRoot(Links) \ + (RtlParent(Links) == (PRTL_SPLAY_LINKS)(Links)) + +#define RtlLeftChild(Links) \ + ((PRTL_SPLAY_LINKS)(Links))->LeftChild + +#define RtlParent(Links) \ + ((PRTL_SPLAY_LINKS)(Links))->Parent + +#define RtlInsertAsLeftChild(ParentLinks,ChildLinks) \ + { \ + PRTL_SPLAY_LINKS _SplayParent; \ + PRTL_SPLAY_LINKS _SplayChild; \ + _SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \ + _SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks); \ + _SplayParent->LeftChild = _SplayChild; \ + _SplayChild->Parent = _SplayParent; \ + } + +#define RtlInsertAsRightChild(ParentLinks,ChildLinks) \ + { \ + PRTL_SPLAY_LINKS _SplayParent; \ + PRTL_SPLAY_LINKS _SplayChild; \ + _SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \ + _SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks); \ + _SplayParent->RightChild = _SplayChild; \ + _SplayChild->Parent = _SplayParent; \ + } + +#if !defined(MIDL_PASS) + +FORCEINLINE +LUID +NTAPI_INLINE +RtlConvertLongToLuid( + IN LONG Val) +{ + LUID Luid; + LARGE_INTEGER Temp; + + Temp.QuadPart = Val; + Luid.LowPart = Temp.u.LowPart; + Luid.HighPart = Temp.u.HighPart; + return Luid; +} + +FORCEINLINE +LUID +NTAPI_INLINE +RtlConvertUlongToLuid( + IN ULONG Val) +{ + LUID Luid; + + Luid.LowPart = Val; + Luid.HighPart = 0; + return Luid; +} + +#endif /* !defined(MIDL_PASS) */ + +#if (defined(_M_AMD64) || defined(_M_IA64)) && !defined(_REALLY_GET_CALLERS_CALLER_) +#define RtlGetCallersAddress(CallersAddress, CallersCaller) \ + *CallersAddress = (PVOID)_ReturnAddress(); \ + *CallersCaller = NULL; +#else +#if (NTDDI_VERSION >= NTDDI_WIN2K) +NTSYSAPI +VOID +NTAPI +RtlGetCallersAddress( + OUT PVOID *CallersAddress, + OUT PVOID *CallersCaller); +#endif +#endif + +#if !defined(MIDL_PASS) && !defined(SORTPP_PASS) + +#if (NTDDI_VERSION >= NTDDI_WIN7) + +FORCEINLINE +VOID +NTAPI +RtlInitHashTableContext( + IN OUT PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context) +{ + Context->ChainHead = NULL; + Context->PrevLinkage = NULL; +} + +FORCEINLINE +VOID +NTAPI +RtlInitHashTableContextFromEnumerator( + IN OUT PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context, + IN PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator) +{ + Context->ChainHead = Enumerator->ChainHead; + Context->PrevLinkage = Enumerator->HashEntry.Linkage.Blink; +} + +FORCEINLINE +VOID +NTAPI +RtlReleaseHashTableContext( + IN OUT PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context) +{ + UNREFERENCED_PARAMETER(Context); + return; +} + +FORCEINLINE +ULONG +NTAPI +RtlTotalBucketsHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable) +{ + return HashTable->TableSize; +} + +FORCEINLINE +ULONG +NTAPI +RtlNonEmptyBucketsHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable) +{ + return HashTable->NonEmptyBuckets; +} + +FORCEINLINE +ULONG +NTAPI +RtlEmptyBucketsHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable) +{ + return HashTable->TableSize - HashTable->NonEmptyBuckets; +} + +FORCEINLINE +ULONG +NTAPI +RtlTotalEntriesHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable) +{ + return HashTable->NumEntries; +} + +FORCEINLINE +ULONG +NTAPI +RtlActiveEnumeratorsHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable) +{ + return HashTable->NumEnumerators; +} + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + +#endif /* !defined(MIDL_PASS) && !defined(SORTPP_PASS) */ + +$endif diff --git a/reactos/include/xdk/rtltypes.h b/reactos/include/xdk/rtltypes.h new file mode 100644 index 00000000000..ab74f7016c1 --- /dev/null +++ b/reactos/include/xdk/rtltypes.h @@ -0,0 +1,448 @@ +/****************************************************************************** + * Runtime Library Types * + ******************************************************************************/ + +$if (_WDMDDK_) +#define RTL_REGISTRY_ABSOLUTE 0 +#define RTL_REGISTRY_SERVICES 1 +#define RTL_REGISTRY_CONTROL 2 +#define RTL_REGISTRY_WINDOWS_NT 3 +#define RTL_REGISTRY_DEVICEMAP 4 +#define RTL_REGISTRY_USER 5 +#define RTL_REGISTRY_MAXIMUM 6 +#define RTL_REGISTRY_HANDLE 0x40000000 +#define RTL_REGISTRY_OPTIONAL 0x80000000 + +/* RTL_QUERY_REGISTRY_TABLE.Flags */ +#define RTL_QUERY_REGISTRY_SUBKEY 0x00000001 +#define RTL_QUERY_REGISTRY_TOPKEY 0x00000002 +#define RTL_QUERY_REGISTRY_REQUIRED 0x00000004 +#define RTL_QUERY_REGISTRY_NOVALUE 0x00000008 +#define RTL_QUERY_REGISTRY_NOEXPAND 0x00000010 +#define RTL_QUERY_REGISTRY_DIRECT 0x00000020 +#define RTL_QUERY_REGISTRY_DELETE 0x00000040 + +#define HASH_STRING_ALGORITHM_DEFAULT 0 +#define HASH_STRING_ALGORITHM_X65599 1 +#define HASH_STRING_ALGORITHM_INVALID 0xffffffff + +typedef struct _RTL_BITMAP { + ULONG SizeOfBitMap; + PULONG Buffer; +} RTL_BITMAP, *PRTL_BITMAP; + +typedef struct _RTL_BITMAP_RUN { + ULONG StartingIndex; + ULONG NumberOfBits; +} RTL_BITMAP_RUN, *PRTL_BITMAP_RUN; + +typedef NTSTATUS +(NTAPI *PRTL_QUERY_REGISTRY_ROUTINE)( + IN PWSTR ValueName, + IN ULONG ValueType, + IN PVOID ValueData, + IN ULONG ValueLength, + IN PVOID Context, + IN PVOID EntryContext); + +typedef struct _RTL_QUERY_REGISTRY_TABLE { + PRTL_QUERY_REGISTRY_ROUTINE QueryRoutine; + ULONG Flags; + PCWSTR Name; + PVOID EntryContext; + ULONG DefaultType; + PVOID DefaultData; + ULONG DefaultLength; +} RTL_QUERY_REGISTRY_TABLE, *PRTL_QUERY_REGISTRY_TABLE; + +typedef struct _TIME_FIELDS { + CSHORT Year; + CSHORT Month; + CSHORT Day; + CSHORT Hour; + CSHORT Minute; + CSHORT Second; + CSHORT Milliseconds; + CSHORT Weekday; +} TIME_FIELDS, *PTIME_FIELDS; + +/* Slist Header */ +#ifndef _SLIST_HEADER_ +#define _SLIST_HEADER_ + +#if defined(_WIN64) + +typedef struct DECLSPEC_ALIGN(16) _SLIST_ENTRY { + struct _SLIST_ENTRY *Next; +} SLIST_ENTRY, *PSLIST_ENTRY; + +typedef struct _SLIST_ENTRY32 { + ULONG Next; +} SLIST_ENTRY32, *PSLIST_ENTRY32; + +typedef union DECLSPEC_ALIGN(16) _SLIST_HEADER { + struct { + ULONGLONG Alignment; + ULONGLONG Region; + } DUMMYSTRUCTNAME; + struct { + ULONGLONG Depth:16; + ULONGLONG Sequence:9; + ULONGLONG NextEntry:39; + ULONGLONG HeaderType:1; + ULONGLONG Init:1; + ULONGLONG Reserved:59; + ULONGLONG Region:3; + } Header8; + struct { + ULONGLONG Depth:16; + ULONGLONG Sequence:48; + ULONGLONG HeaderType:1; + ULONGLONG Init:1; + ULONGLONG Reserved:2; + ULONGLONG NextEntry:60; + } Header16; + struct { + ULONGLONG Depth:16; + ULONGLONG Sequence:48; + ULONGLONG HeaderType:1; + ULONGLONG Reserved:3; + ULONGLONG NextEntry:60; + } HeaderX64; +} SLIST_HEADER, *PSLIST_HEADER; + +typedef union _SLIST_HEADER32 { + ULONGLONG Alignment; + struct { + SLIST_ENTRY32 Next; + USHORT Depth; + USHORT Sequence; + } DUMMYSTRUCTNAME; +} SLIST_HEADER32, *PSLIST_HEADER32; + +#else + +#define SLIST_ENTRY SINGLE_LIST_ENTRY +#define _SLIST_ENTRY _SINGLE_LIST_ENTRY +#define PSLIST_ENTRY PSINGLE_LIST_ENTRY + +typedef SLIST_ENTRY SLIST_ENTRY32, *PSLIST_ENTRY32; + +typedef union _SLIST_HEADER { + ULONGLONG Alignment; + struct { + SLIST_ENTRY Next; + USHORT Depth; + USHORT Sequence; + } DUMMYSTRUCTNAME; +} SLIST_HEADER, *PSLIST_HEADER; + +typedef SLIST_HEADER SLIST_HEADER32, *PSLIST_HEADER32; + +#endif /* defined(_WIN64) */ + +#endif /* _SLIST_HEADER_ */ + +/* MS definition is broken! */ +extern BOOLEAN NTSYSAPI NlsMbCodePageTag; +extern BOOLEAN NTSYSAPI NlsMbOemCodePageTag; +#define NLS_MB_CODE_PAGE_TAG NlsMbCodePageTag +#define NLS_MB_OEM_CODE_PAGE_TAG NlsMbOemCodePageTag + +#define SHORT_LEAST_SIGNIFICANT_BIT 0 +#define SHORT_MOST_SIGNIFICANT_BIT 1 + +#define LONG_LEAST_SIGNIFICANT_BIT 0 +#define LONG_3RD_MOST_SIGNIFICANT_BIT 1 +#define LONG_2ND_MOST_SIGNIFICANT_BIT 2 +#define LONG_MOST_SIGNIFICANT_BIT 3 + +#define RTLVERLIB_DDI(x) Wdmlib##x + +typedef BOOLEAN +(*PFN_RTL_IS_NTDDI_VERSION_AVAILABLE)( + IN ULONG Version); + +typedef BOOLEAN +(*PFN_RTL_IS_SERVICE_PACK_VERSION_INSTALLED)( + IN ULONG Version); + +$endif + +$if (_NTDDK_) + +#ifndef _RTL_RUN_ONCE_DEF +#define _RTL_RUN_ONCE_DEF + +#define RTL_RUN_ONCE_INIT {0} + +#define RTL_RUN_ONCE_CHECK_ONLY 0x00000001UL +#define RTL_RUN_ONCE_ASYNC 0x00000002UL +#define RTL_RUN_ONCE_INIT_FAILED 0x00000004UL + +#define RTL_RUN_ONCE_CTX_RESERVED_BITS 2 + +#define RTL_HASH_ALLOCATED_HEADER 0x00000001 + +#define RTL_HASH_RESERVED_SIGNATURE 0 + +/* RtlVerifyVersionInfo() ComparisonType */ + +#define VER_EQUAL 1 +#define VER_GREATER 2 +#define VER_GREATER_EQUAL 3 +#define VER_LESS 4 +#define VER_LESS_EQUAL 5 +#define VER_AND 6 +#define VER_OR 7 + +#define VER_CONDITION_MASK 7 +#define VER_NUM_BITS_PER_CONDITION_MASK 3 + +/* RtlVerifyVersionInfo() TypeMask */ + +#define VER_MINORVERSION 0x0000001 +#define VER_MAJORVERSION 0x0000002 +#define VER_BUILDNUMBER 0x0000004 +#define VER_PLATFORMID 0x0000008 +#define VER_SERVICEPACKMINOR 0x0000010 +#define VER_SERVICEPACKMAJOR 0x0000020 +#define VER_SUITENAME 0x0000040 +#define VER_PRODUCT_TYPE 0x0000080 + +#define VER_NT_WORKSTATION 0x0000001 +#define VER_NT_DOMAIN_CONTROLLER 0x0000002 +#define VER_NT_SERVER 0x0000003 + +#define VER_PLATFORM_WIN32s 0 +#define VER_PLATFORM_WIN32_WINDOWS 1 +#define VER_PLATFORM_WIN32_NT 2 + +typedef union _RTL_RUN_ONCE { + PVOID Ptr; +} RTL_RUN_ONCE, *PRTL_RUN_ONCE; + +typedef ULONG /* LOGICAL */ +(NTAPI *PRTL_RUN_ONCE_INIT_FN) ( + IN OUT PRTL_RUN_ONCE RunOnce, + IN OUT PVOID Parameter OPTIONAL, + IN OUT PVOID *Context OPTIONAL); + +#endif /* _RTL_RUN_ONCE_DEF */ + +typedef enum _TABLE_SEARCH_RESULT { + TableEmptyTree, + TableFoundNode, + TableInsertAsLeft, + TableInsertAsRight +} TABLE_SEARCH_RESULT; + +typedef enum _RTL_GENERIC_COMPARE_RESULTS { + GenericLessThan, + GenericGreaterThan, + GenericEqual +} RTL_GENERIC_COMPARE_RESULTS; + +// Forwarder +struct _RTL_AVL_TABLE; + +typedef RTL_GENERIC_COMPARE_RESULTS +(NTAPI *PRTL_AVL_COMPARE_ROUTINE) ( + IN struct _RTL_AVL_TABLE *Table, + IN PVOID FirstStruct, + IN PVOID SecondStruct); + +typedef PVOID +(NTAPI *PRTL_AVL_ALLOCATE_ROUTINE) ( + IN struct _RTL_AVL_TABLE *Table, + IN CLONG ByteSize); + +typedef VOID +(NTAPI *PRTL_AVL_FREE_ROUTINE) ( + IN struct _RTL_AVL_TABLE *Table, + IN PVOID Buffer); + +typedef NTSTATUS +(NTAPI *PRTL_AVL_MATCH_FUNCTION) ( + IN struct _RTL_AVL_TABLE *Table, + IN PVOID UserData, + IN PVOID MatchData); + +typedef struct _RTL_BALANCED_LINKS { + struct _RTL_BALANCED_LINKS *Parent; + struct _RTL_BALANCED_LINKS *LeftChild; + struct _RTL_BALANCED_LINKS *RightChild; + CHAR Balance; + UCHAR Reserved[3]; +} RTL_BALANCED_LINKS, *PRTL_BALANCED_LINKS; + +typedef struct _RTL_AVL_TABLE { + RTL_BALANCED_LINKS BalancedRoot; + PVOID OrderedPointer; + ULONG WhichOrderedElement; + ULONG NumberGenericTableElements; + ULONG DepthOfTree; + PRTL_BALANCED_LINKS RestartKey; + ULONG DeleteCount; + PRTL_AVL_COMPARE_ROUTINE CompareRoutine; + PRTL_AVL_ALLOCATE_ROUTINE AllocateRoutine; + PRTL_AVL_FREE_ROUTINE FreeRoutine; + PVOID TableContext; +} RTL_AVL_TABLE, *PRTL_AVL_TABLE; + +#ifndef RTL_USE_AVL_TABLES + +struct _RTL_GENERIC_TABLE; + +typedef RTL_GENERIC_COMPARE_RESULTS +(NTAPI *PRTL_GENERIC_COMPARE_ROUTINE) ( + IN struct _RTL_GENERIC_TABLE *Table, + IN PVOID FirstStruct, + IN PVOID SecondStruct); + +typedef PVOID +(NTAPI *PRTL_GENERIC_ALLOCATE_ROUTINE) ( + IN struct _RTL_GENERIC_TABLE *Table, + IN CLONG ByteSize); + +typedef VOID +(NTAPI *PRTL_GENERIC_FREE_ROUTINE) ( + IN struct _RTL_GENERIC_TABLE *Table, + IN PVOID Buffer); + +typedef struct _RTL_SPLAY_LINKS { + struct _RTL_SPLAY_LINKS *Parent; + struct _RTL_SPLAY_LINKS *LeftChild; + struct _RTL_SPLAY_LINKS *RightChild; +} RTL_SPLAY_LINKS, *PRTL_SPLAY_LINKS; + +typedef struct _RTL_GENERIC_TABLE { + PRTL_SPLAY_LINKS TableRoot; + LIST_ENTRY InsertOrderList; + PLIST_ENTRY OrderedPointer; + ULONG WhichOrderedElement; + ULONG NumberGenericTableElements; + PRTL_GENERIC_COMPARE_ROUTINE CompareRoutine; + PRTL_GENERIC_ALLOCATE_ROUTINE AllocateRoutine; + PRTL_GENERIC_FREE_ROUTINE FreeRoutine; + PVOID TableContext; +} RTL_GENERIC_TABLE, *PRTL_GENERIC_TABLE; + +#endif /* !RTL_USE_AVL_TABLES */ + +#ifdef RTL_USE_AVL_TABLES + +#undef PRTL_GENERIC_COMPARE_ROUTINE +#undef RTL_GENERIC_COMPARE_ROUTINE +#undef PRTL_GENERIC_ALLOCATE_ROUTINE +#undef RTL_GENERIC_ALLOCATE_ROUTINE +#undef PRTL_GENERIC_FREE_ROUTINE +#undef RTL_GENERIC_FREE_ROUTINE +#undef RTL_GENERIC_TABLE +#undef PRTL_GENERIC_TABLE + +#define PRTL_GENERIC_COMPARE_ROUTINE PRTL_AVL_COMPARE_ROUTINE +#define RTL_GENERIC_COMPARE_ROUTINE RTL_AVL_COMPARE_ROUTINE +#define PRTL_GENERIC_ALLOCATE_ROUTINE PRTL_AVL_ALLOCATE_ROUTINE +#define RTL_GENERIC_ALLOCATE_ROUTINE RTL_AVL_ALLOCATE_ROUTINE +#define PRTL_GENERIC_FREE_ROUTINE PRTL_AVL_FREE_ROUTINE +#define RTL_GENERIC_FREE_ROUTINE RTL_AVL_FREE_ROUTINE +#define RTL_GENERIC_TABLE RTL_AVL_TABLE +#define PRTL_GENERIC_TABLE PRTL_AVL_TABLE + +#endif /* RTL_USE_AVL_TABLES */ + +typedef struct _RTL_DYNAMIC_HASH_TABLE_ENTRY { + LIST_ENTRY Linkage; + ULONG_PTR Signature; +} RTL_DYNAMIC_HASH_TABLE_ENTRY, *PRTL_DYNAMIC_HASH_TABLE_ENTRY; + +typedef struct _RTL_DYNAMIC_HASH_TABLE_CONTEXT { + PLIST_ENTRY ChainHead; + PLIST_ENTRY PrevLinkage; + ULONG_PTR Signature; +} RTL_DYNAMIC_HASH_TABLE_CONTEXT, *PRTL_DYNAMIC_HASH_TABLE_CONTEXT; + +typedef struct _RTL_DYNAMIC_HASH_TABLE_ENUMERATOR { + RTL_DYNAMIC_HASH_TABLE_ENTRY HashEntry; + PLIST_ENTRY ChainHead; + ULONG BucketIndex; +} RTL_DYNAMIC_HASH_TABLE_ENUMERATOR, *PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR; + +typedef struct _RTL_DYNAMIC_HASH_TABLE { + ULONG Flags; + ULONG Shift; + ULONG TableSize; + ULONG Pivot; + ULONG DivisorMask; + ULONG NumEntries; + ULONG NonEmptyBuckets; + ULONG NumEnumerators; + PVOID Directory; +} RTL_DYNAMIC_HASH_TABLE, *PRTL_DYNAMIC_HASH_TABLE; + +typedef struct _OSVERSIONINFOA { + ULONG dwOSVersionInfoSize; + ULONG dwMajorVersion; + ULONG dwMinorVersion; + ULONG dwBuildNumber; + ULONG dwPlatformId; + CHAR szCSDVersion[128]; +} OSVERSIONINFOA, *POSVERSIONINFOA, *LPOSVERSIONINFOA; + +typedef struct _OSVERSIONINFOW { + ULONG dwOSVersionInfoSize; + ULONG dwMajorVersion; + ULONG dwMinorVersion; + ULONG dwBuildNumber; + ULONG dwPlatformId; + WCHAR szCSDVersion[128]; +} OSVERSIONINFOW, *POSVERSIONINFOW, *LPOSVERSIONINFOW, RTL_OSVERSIONINFOW, *PRTL_OSVERSIONINFOW; + +typedef struct _OSVERSIONINFOEXA { + ULONG dwOSVersionInfoSize; + ULONG dwMajorVersion; + ULONG dwMinorVersion; + ULONG dwBuildNumber; + ULONG dwPlatformId; + CHAR szCSDVersion[128]; + USHORT wServicePackMajor; + USHORT wServicePackMinor; + USHORT wSuiteMask; + UCHAR wProductType; + UCHAR wReserved; +} OSVERSIONINFOEXA, *POSVERSIONINFOEXA, *LPOSVERSIONINFOEXA; + +typedef struct _OSVERSIONINFOEXW { + ULONG dwOSVersionInfoSize; + ULONG dwMajorVersion; + ULONG dwMinorVersion; + ULONG dwBuildNumber; + ULONG dwPlatformId; + WCHAR szCSDVersion[128]; + USHORT wServicePackMajor; + USHORT wServicePackMinor; + USHORT wSuiteMask; + UCHAR wProductType; + UCHAR wReserved; +} OSVERSIONINFOEXW, *POSVERSIONINFOEXW, *LPOSVERSIONINFOEXW, RTL_OSVERSIONINFOEXW, *PRTL_OSVERSIONINFOEXW; + +#ifdef UNICODE +typedef OSVERSIONINFOEXW OSVERSIONINFOEX; +typedef POSVERSIONINFOEXW POSVERSIONINFOEX; +typedef LPOSVERSIONINFOEXW LPOSVERSIONINFOEX; +typedef OSVERSIONINFOW OSVERSIONINFO; +typedef POSVERSIONINFOW POSVERSIONINFO; +typedef LPOSVERSIONINFOW LPOSVERSIONINFO; +#else +typedef OSVERSIONINFOEXA OSVERSIONINFOEX; +typedef POSVERSIONINFOEXA POSVERSIONINFOEX; +typedef LPOSVERSIONINFOEXA LPOSVERSIONINFOEX; +typedef OSVERSIONINFOA OSVERSIONINFO; +typedef POSVERSIONINFOA POSVERSIONINFO; +typedef LPOSVERSIONINFOA LPOSVERSIONINFO; +#endif /* UNICODE */ + +#define HASH_ENTRY_KEY(x) ((x)->Signature) + +$endif diff --git a/reactos/include/xdk/sefuncs.h b/reactos/include/xdk/sefuncs.h new file mode 100644 index 00000000000..6c8922024ec --- /dev/null +++ b/reactos/include/xdk/sefuncs.h @@ -0,0 +1,144 @@ +/****************************************************************************** + * Security Manager Functions * + ******************************************************************************/ + +#if (NTDDI_VERSION >= NTDDI_WIN2K) +$if (_NTDDK_) +NTKERNELAPI +BOOLEAN +NTAPI +SeSinglePrivilegeCheck( + IN LUID PrivilegeValue, + IN KPROCESSOR_MODE PreviousMode); +$endif + +$if (_WDMDDK_) +NTKERNELAPI +BOOLEAN +NTAPI +SeAccessCheck( + IN PSECURITY_DESCRIPTOR SecurityDescriptor, + IN PSECURITY_SUBJECT_CONTEXT SubjectSecurityContext, + IN BOOLEAN SubjectContextLocked, + IN ACCESS_MASK DesiredAccess, + IN ACCESS_MASK PreviouslyGrantedAccess, + OUT PPRIVILEGE_SET *Privileges OPTIONAL, + IN PGENERIC_MAPPING GenericMapping, + IN KPROCESSOR_MODE AccessMode, + OUT PACCESS_MASK GrantedAccess, + OUT PNTSTATUS AccessStatus); + +NTKERNELAPI +NTSTATUS +NTAPI +SeAssignSecurity( + IN PSECURITY_DESCRIPTOR ParentDescriptor OPTIONAL, + IN PSECURITY_DESCRIPTOR ExplicitDescriptor OPTIONAL, + OUT PSECURITY_DESCRIPTOR *NewDescriptor, + IN BOOLEAN IsDirectoryObject, + IN PSECURITY_SUBJECT_CONTEXT SubjectContext, + IN PGENERIC_MAPPING GenericMapping, + IN POOL_TYPE PoolType); + +NTKERNELAPI +NTSTATUS +NTAPI +SeAssignSecurityEx( + IN PSECURITY_DESCRIPTOR ParentDescriptor OPTIONAL, + IN PSECURITY_DESCRIPTOR ExplicitDescriptor OPTIONAL, + OUT PSECURITY_DESCRIPTOR *NewDescriptor, + IN GUID *ObjectType OPTIONAL, + IN BOOLEAN IsDirectoryObject, + IN ULONG AutoInheritFlags, + IN PSECURITY_SUBJECT_CONTEXT SubjectContext, + IN PGENERIC_MAPPING GenericMapping, + IN POOL_TYPE PoolType); + +NTKERNELAPI +NTSTATUS +NTAPI +SeDeassignSecurity( + IN OUT PSECURITY_DESCRIPTOR *SecurityDescriptor); + +NTKERNELAPI +BOOLEAN +NTAPI +SeValidSecurityDescriptor( + IN ULONG Length, + IN PSECURITY_DESCRIPTOR SecurityDescriptor); + +NTKERNELAPI +ULONG +NTAPI +SeObjectCreateSaclAccessBits( + IN PSECURITY_DESCRIPTOR SecurityDescriptor); + +NTKERNELAPI +VOID +NTAPI +SeReleaseSubjectContext( + IN OUT PSECURITY_SUBJECT_CONTEXT SubjectContext); + +NTKERNELAPI +VOID +NTAPI +SeUnlockSubjectContext( + IN PSECURITY_SUBJECT_CONTEXT SubjectContext); + +NTKERNELAPI +VOID +NTAPI +SeCaptureSubjectContext( + OUT PSECURITY_SUBJECT_CONTEXT SubjectContext); + +NTKERNELAPI +VOID +NTAPI +SeLockSubjectContext( + IN PSECURITY_SUBJECT_CONTEXT SubjectContext); +$endif + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ + +$if (_WDMDDK_) +#if (NTDDI_VERSION >= NTDDI_WS03SP1) + +NTSTATUS +NTAPI +SeSetAuditParameter( + IN OUT PSE_ADT_PARAMETER_ARRAY AuditParameters, + IN SE_ADT_PARAMETER_TYPE Type, + IN ULONG Index, + IN PVOID Data); + +NTSTATUS +NTAPI +SeReportSecurityEvent( + IN ULONG Flags, + IN PUNICODE_STRING SourceName, + IN PSID UserSid OPTIONAL, + IN PSE_ADT_PARAMETER_ARRAY AuditParameters); + +#endif /* (NTDDI_VERSION >= NTDDI_WS03SP1) */ + +#if (NTDDI_VERSION >= NTDDI_VISTA) + +NTKERNELAPI +ULONG +NTAPI +SeComputeAutoInheritByObjectType( + IN PVOID ObjectType, + IN PSECURITY_DESCRIPTOR SecurityDescriptor OPTIONAL, + IN PSECURITY_DESCRIPTOR ParentSecurityDescriptor OPTIONAL); + +#ifdef SE_NTFS_WORLD_CACHE +VOID +NTAPI +SeGetWorldRights( + IN PSECURITY_DESCRIPTOR SecurityDescriptor, + IN PGENERIC_MAPPING GenericMapping, + OUT PACCESS_MASK GrantedAccess); +#endif /* SE_NTFS_WORLD_CACHE */ + +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ +$endif diff --git a/reactos/include/xdk/setypes.h b/reactos/include/xdk/setypes.h new file mode 100644 index 00000000000..6892aee0d2d --- /dev/null +++ b/reactos/include/xdk/setypes.h @@ -0,0 +1,396 @@ +/****************************************************************************** + * Security Manager Types * + ******************************************************************************/ +$if (_NTDDK_) +#define SE_UNSOLICITED_INPUT_PRIVILEGE 6 + +typedef enum _WELL_KNOWN_SID_TYPE { + WinNullSid = 0, + WinWorldSid = 1, + WinLocalSid = 2, + WinCreatorOwnerSid = 3, + WinCreatorGroupSid = 4, + WinCreatorOwnerServerSid = 5, + WinCreatorGroupServerSid = 6, + WinNtAuthoritySid = 7, + WinDialupSid = 8, + WinNetworkSid = 9, + WinBatchSid = 10, + WinInteractiveSid = 11, + WinServiceSid = 12, + WinAnonymousSid = 13, + WinProxySid = 14, + WinEnterpriseControllersSid = 15, + WinSelfSid = 16, + WinAuthenticatedUserSid = 17, + WinRestrictedCodeSid = 18, + WinTerminalServerSid = 19, + WinRemoteLogonIdSid = 20, + WinLogonIdsSid = 21, + WinLocalSystemSid = 22, + WinLocalServiceSid = 23, + WinNetworkServiceSid = 24, + WinBuiltinDomainSid = 25, + WinBuiltinAdministratorsSid = 26, + WinBuiltinUsersSid = 27, + WinBuiltinGuestsSid = 28, + WinBuiltinPowerUsersSid = 29, + WinBuiltinAccountOperatorsSid = 30, + WinBuiltinSystemOperatorsSid = 31, + WinBuiltinPrintOperatorsSid = 32, + WinBuiltinBackupOperatorsSid = 33, + WinBuiltinReplicatorSid = 34, + WinBuiltinPreWindows2000CompatibleAccessSid = 35, + WinBuiltinRemoteDesktopUsersSid = 36, + WinBuiltinNetworkConfigurationOperatorsSid = 37, + WinAccountAdministratorSid = 38, + WinAccountGuestSid = 39, + WinAccountKrbtgtSid = 40, + WinAccountDomainAdminsSid = 41, + WinAccountDomainUsersSid = 42, + WinAccountDomainGuestsSid = 43, + WinAccountComputersSid = 44, + WinAccountControllersSid = 45, + WinAccountCertAdminsSid = 46, + WinAccountSchemaAdminsSid = 47, + WinAccountEnterpriseAdminsSid = 48, + WinAccountPolicyAdminsSid = 49, + WinAccountRasAndIasServersSid = 50, + WinNTLMAuthenticationSid = 51, + WinDigestAuthenticationSid = 52, + WinSChannelAuthenticationSid = 53, + WinThisOrganizationSid = 54, + WinOtherOrganizationSid = 55, + WinBuiltinIncomingForestTrustBuildersSid = 56, + WinBuiltinPerfMonitoringUsersSid = 57, + WinBuiltinPerfLoggingUsersSid = 58, + WinBuiltinAuthorizationAccessSid = 59, + WinBuiltinTerminalServerLicenseServersSid = 60, + WinBuiltinDCOMUsersSid = 61, + WinBuiltinIUsersSid = 62, + WinIUserSid = 63, + WinBuiltinCryptoOperatorsSid = 64, + WinUntrustedLabelSid = 65, + WinLowLabelSid = 66, + WinMediumLabelSid = 67, + WinHighLabelSid = 68, + WinSystemLabelSid = 69, + WinWriteRestrictedCodeSid = 70, + WinCreatorOwnerRightsSid = 71, + WinCacheablePrincipalsGroupSid = 72, + WinNonCacheablePrincipalsGroupSid = 73, + WinEnterpriseReadonlyControllersSid = 74, + WinAccountReadonlyControllersSid = 75, + WinBuiltinEventLogReadersGroup = 76, + WinNewEnterpriseReadonlyControllersSid = 77, + WinBuiltinCertSvcDComAccessGroup = 78, + WinMediumPlusLabelSid = 79, + WinLocalLogonSid = 80, + WinConsoleLogonSid = 81, + WinThisOrganizationCertificateSid = 82, +} WELL_KNOWN_SID_TYPE; +$endif + +$if (_WDMDDK_) +/* Simple types */ +typedef PVOID PSECURITY_DESCRIPTOR; +typedef ULONG SECURITY_INFORMATION, *PSECURITY_INFORMATION; +typedef ULONG ACCESS_MASK, *PACCESS_MASK; +typedef PVOID PACCESS_TOKEN; +typedef PVOID PSID; + +#define DELETE 0x00010000L +#define READ_CONTROL 0x00020000L +#define WRITE_DAC 0x00040000L +#define WRITE_OWNER 0x00080000L +#define SYNCHRONIZE 0x00100000L +#define STANDARD_RIGHTS_REQUIRED 0x000F0000L +#define STANDARD_RIGHTS_READ READ_CONTROL +#define STANDARD_RIGHTS_WRITE READ_CONTROL +#define STANDARD_RIGHTS_EXECUTE READ_CONTROL +#define STANDARD_RIGHTS_ALL 0x001F0000L +#define SPECIFIC_RIGHTS_ALL 0x0000FFFFL +#define ACCESS_SYSTEM_SECURITY 0x01000000L +#define MAXIMUM_ALLOWED 0x02000000L +#define GENERIC_READ 0x80000000L +#define GENERIC_WRITE 0x40000000L +#define GENERIC_EXECUTE 0x20000000L +#define GENERIC_ALL 0x10000000L + +typedef struct _GENERIC_MAPPING { + ACCESS_MASK GenericRead; + ACCESS_MASK GenericWrite; + ACCESS_MASK GenericExecute; + ACCESS_MASK GenericAll; +} GENERIC_MAPPING, *PGENERIC_MAPPING; + +#define ACL_REVISION 2 +#define ACL_REVISION_DS 4 + +#define ACL_REVISION1 1 +#define ACL_REVISION2 2 +#define ACL_REVISION3 3 +#define ACL_REVISION4 4 +#define MIN_ACL_REVISION ACL_REVISION2 +#define MAX_ACL_REVISION ACL_REVISION4 + +typedef struct _ACL { + UCHAR AclRevision; + UCHAR Sbz1; + USHORT AclSize; + USHORT AceCount; + USHORT Sbz2; +} ACL, *PACL; + +/* Current security descriptor revision value */ +#define SECURITY_DESCRIPTOR_REVISION (1) +#define SECURITY_DESCRIPTOR_REVISION1 (1) + +/* Privilege attributes */ +#define SE_PRIVILEGE_ENABLED_BY_DEFAULT (0x00000001L) +#define SE_PRIVILEGE_ENABLED (0x00000002L) +#define SE_PRIVILEGE_REMOVED (0X00000004L) +#define SE_PRIVILEGE_USED_FOR_ACCESS (0x80000000L) + +#define SE_PRIVILEGE_VALID_ATTRIBUTES (SE_PRIVILEGE_ENABLED_BY_DEFAULT | \ + SE_PRIVILEGE_ENABLED | \ + SE_PRIVILEGE_REMOVED | \ + SE_PRIVILEGE_USED_FOR_ACCESS) + +#include +typedef struct _LUID_AND_ATTRIBUTES { + LUID Luid; + ULONG Attributes; +} LUID_AND_ATTRIBUTES, *PLUID_AND_ATTRIBUTES; +#include + +typedef LUID_AND_ATTRIBUTES LUID_AND_ATTRIBUTES_ARRAY[ANYSIZE_ARRAY]; +typedef LUID_AND_ATTRIBUTES_ARRAY *PLUID_AND_ATTRIBUTES_ARRAY; + +/* Privilege sets */ +#define PRIVILEGE_SET_ALL_NECESSARY (1) + +typedef struct _PRIVILEGE_SET { + ULONG PrivilegeCount; + ULONG Control; + LUID_AND_ATTRIBUTES Privilege[ANYSIZE_ARRAY]; +} PRIVILEGE_SET,*PPRIVILEGE_SET; + +typedef enum _SECURITY_IMPERSONATION_LEVEL { + SecurityAnonymous, + SecurityIdentification, + SecurityImpersonation, + SecurityDelegation +} SECURITY_IMPERSONATION_LEVEL, * PSECURITY_IMPERSONATION_LEVEL; + +#define SECURITY_MAX_IMPERSONATION_LEVEL SecurityDelegation +#define SECURITY_MIN_IMPERSONATION_LEVEL SecurityAnonymous +#define DEFAULT_IMPERSONATION_LEVEL SecurityImpersonation +#define VALID_IMPERSONATION_LEVEL(Level) (((Level) >= SECURITY_MIN_IMPERSONATION_LEVEL) && ((Level) <= SECURITY_MAX_IMPERSONATION_LEVEL)) + +#define SECURITY_DYNAMIC_TRACKING (TRUE) +#define SECURITY_STATIC_TRACKING (FALSE) + +typedef BOOLEAN SECURITY_CONTEXT_TRACKING_MODE, *PSECURITY_CONTEXT_TRACKING_MODE; + +typedef struct _SECURITY_QUALITY_OF_SERVICE { + ULONG Length; + SECURITY_IMPERSONATION_LEVEL ImpersonationLevel; + SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode; + BOOLEAN EffectiveOnly; +} SECURITY_QUALITY_OF_SERVICE, *PSECURITY_QUALITY_OF_SERVICE; + +typedef struct _SE_IMPERSONATION_STATE { + PACCESS_TOKEN Token; + BOOLEAN CopyOnOpen; + BOOLEAN EffectiveOnly; + SECURITY_IMPERSONATION_LEVEL Level; +} SE_IMPERSONATION_STATE, *PSE_IMPERSONATION_STATE; + +#define OWNER_SECURITY_INFORMATION (0x00000001L) +#define GROUP_SECURITY_INFORMATION (0x00000002L) +#define DACL_SECURITY_INFORMATION (0x00000004L) +#define SACL_SECURITY_INFORMATION (0x00000008L) +#define LABEL_SECURITY_INFORMATION (0x00000010L) + +#define PROTECTED_DACL_SECURITY_INFORMATION (0x80000000L) +#define PROTECTED_SACL_SECURITY_INFORMATION (0x40000000L) +#define UNPROTECTED_DACL_SECURITY_INFORMATION (0x20000000L) +#define UNPROTECTED_SACL_SECURITY_INFORMATION (0x10000000L) + +typedef enum _SECURITY_OPERATION_CODE { + SetSecurityDescriptor, + QuerySecurityDescriptor, + DeleteSecurityDescriptor, + AssignSecurityDescriptor +} SECURITY_OPERATION_CODE, *PSECURITY_OPERATION_CODE; + +#define INITIAL_PRIVILEGE_COUNT 3 + +typedef struct _INITIAL_PRIVILEGE_SET { + ULONG PrivilegeCount; + ULONG Control; + LUID_AND_ATTRIBUTES Privilege[INITIAL_PRIVILEGE_COUNT]; +} INITIAL_PRIVILEGE_SET, * PINITIAL_PRIVILEGE_SET; + +#define SE_MIN_WELL_KNOWN_PRIVILEGE 2 +#define SE_CREATE_TOKEN_PRIVILEGE 2 +#define SE_ASSIGNPRIMARYTOKEN_PRIVILEGE 3 +#define SE_LOCK_MEMORY_PRIVILEGE 4 +#define SE_INCREASE_QUOTA_PRIVILEGE 5 +#define SE_MACHINE_ACCOUNT_PRIVILEGE 6 +#define SE_TCB_PRIVILEGE 7 +#define SE_SECURITY_PRIVILEGE 8 +#define SE_TAKE_OWNERSHIP_PRIVILEGE 9 +#define SE_LOAD_DRIVER_PRIVILEGE 10 +#define SE_SYSTEM_PROFILE_PRIVILEGE 11 +#define SE_SYSTEMTIME_PRIVILEGE 12 +#define SE_PROF_SINGLE_PROCESS_PRIVILEGE 13 +#define SE_INC_BASE_PRIORITY_PRIVILEGE 14 +#define SE_CREATE_PAGEFILE_PRIVILEGE 15 +#define SE_CREATE_PERMANENT_PRIVILEGE 16 +#define SE_BACKUP_PRIVILEGE 17 +#define SE_RESTORE_PRIVILEGE 18 +#define SE_SHUTDOWN_PRIVILEGE 19 +#define SE_DEBUG_PRIVILEGE 20 +#define SE_AUDIT_PRIVILEGE 21 +#define SE_SYSTEM_ENVIRONMENT_PRIVILEGE 22 +#define SE_CHANGE_NOTIFY_PRIVILEGE 23 +#define SE_REMOTE_SHUTDOWN_PRIVILEGE 24 +#define SE_UNDOCK_PRIVILEGE 25 +#define SE_SYNC_AGENT_PRIVILEGE 26 +#define SE_ENABLE_DELEGATION_PRIVILEGE 27 +#define SE_MANAGE_VOLUME_PRIVILEGE 28 +#define SE_IMPERSONATE_PRIVILEGE 29 +#define SE_CREATE_GLOBAL_PRIVILEGE 30 +#define SE_TRUSTED_CREDMAN_ACCESS_PRIVILEGE 31 +#define SE_RELABEL_PRIVILEGE 32 +#define SE_INC_WORKING_SET_PRIVILEGE 33 +#define SE_TIME_ZONE_PRIVILEGE 34 +#define SE_CREATE_SYMBOLIC_LINK_PRIVILEGE 35 +#define SE_MAX_WELL_KNOWN_PRIVILEGE SE_CREATE_SYMBOLIC_LINK_PRIVILEGE + +typedef struct _SECURITY_SUBJECT_CONTEXT { + PACCESS_TOKEN ClientToken; + SECURITY_IMPERSONATION_LEVEL ImpersonationLevel; + PACCESS_TOKEN PrimaryToken; + PVOID ProcessAuditId; +} SECURITY_SUBJECT_CONTEXT, *PSECURITY_SUBJECT_CONTEXT; + +typedef struct _ACCESS_STATE { + LUID OperationID; + BOOLEAN SecurityEvaluated; + BOOLEAN GenerateAudit; + BOOLEAN GenerateOnClose; + BOOLEAN PrivilegesAllocated; + ULONG Flags; + ACCESS_MASK RemainingDesiredAccess; + ACCESS_MASK PreviouslyGrantedAccess; + ACCESS_MASK OriginalDesiredAccess; + SECURITY_SUBJECT_CONTEXT SubjectSecurityContext; + PSECURITY_DESCRIPTOR SecurityDescriptor; + PVOID AuxData; + union { + INITIAL_PRIVILEGE_SET InitialPrivilegeSet; + PRIVILEGE_SET PrivilegeSet; + } Privileges; + BOOLEAN AuditPrivileges; + UNICODE_STRING ObjectName; + UNICODE_STRING ObjectTypeName; +} ACCESS_STATE, *PACCESS_STATE; + +typedef VOID +(NTAPI *PNTFS_DEREF_EXPORTED_SECURITY_DESCRIPTOR)( + IN PVOID Vcb, + IN PSECURITY_DESCRIPTOR SecurityDescriptor); + +#ifndef _NTLSA_IFS_ + +#ifndef _NTLSA_AUDIT_ +#define _NTLSA_AUDIT_ + +#define SE_MAX_AUDIT_PARAMETERS 32 +#define SE_MAX_GENERIC_AUDIT_PARAMETERS 28 + +#define SE_ADT_OBJECT_ONLY 0x1 + +#define SE_ADT_PARAMETERS_SELF_RELATIVE 0x00000001 +#define SE_ADT_PARAMETERS_SEND_TO_LSA 0x00000002 +#define SE_ADT_PARAMETER_EXTENSIBLE_AUDIT 0x00000004 +#define SE_ADT_PARAMETER_GENERIC_AUDIT 0x00000008 +#define SE_ADT_PARAMETER_WRITE_SYNCHRONOUS 0x00000010 + +#define LSAP_SE_ADT_PARAMETER_ARRAY_TRUE_SIZE(Parameters) \ + ( sizeof(SE_ADT_PARAMETER_ARRAY) - sizeof(SE_ADT_PARAMETER_ARRAY_ENTRY) * \ + (SE_MAX_AUDIT_PARAMETERS - Parameters->ParameterCount) ) + +typedef enum _SE_ADT_PARAMETER_TYPE { + SeAdtParmTypeNone = 0, + SeAdtParmTypeString, + SeAdtParmTypeFileSpec, + SeAdtParmTypeUlong, + SeAdtParmTypeSid, + SeAdtParmTypeLogonId, + SeAdtParmTypeNoLogonId, + SeAdtParmTypeAccessMask, + SeAdtParmTypePrivs, + SeAdtParmTypeObjectTypes, + SeAdtParmTypeHexUlong, + SeAdtParmTypePtr, + SeAdtParmTypeTime, + SeAdtParmTypeGuid, + SeAdtParmTypeLuid, + SeAdtParmTypeHexInt64, + SeAdtParmTypeStringList, + SeAdtParmTypeSidList, + SeAdtParmTypeDuration, + SeAdtParmTypeUserAccountControl, + SeAdtParmTypeNoUac, + SeAdtParmTypeMessage, + SeAdtParmTypeDateTime, + SeAdtParmTypeSockAddr, + SeAdtParmTypeSD, + SeAdtParmTypeLogonHours, + SeAdtParmTypeLogonIdNoSid, + SeAdtParmTypeUlongNoConv, + SeAdtParmTypeSockAddrNoPort, + SeAdtParmTypeAccessReason +} SE_ADT_PARAMETER_TYPE, *PSE_ADT_PARAMETER_TYPE; + +typedef struct _SE_ADT_OBJECT_TYPE { + GUID ObjectType; + USHORT Flags; + USHORT Level; + ACCESS_MASK AccessMask; +} SE_ADT_OBJECT_TYPE, *PSE_ADT_OBJECT_TYPE; + +typedef struct _SE_ADT_PARAMETER_ARRAY_ENTRY { + SE_ADT_PARAMETER_TYPE Type; + ULONG Length; + ULONG_PTR Data[2]; + PVOID Address; +} SE_ADT_PARAMETER_ARRAY_ENTRY, *PSE_ADT_PARAMETER_ARRAY_ENTRY; + +typedef struct _SE_ADT_ACCESS_REASON { + ACCESS_MASK AccessMask; + ULONG AccessReasons[32]; + ULONG ObjectTypeIndex; + ULONG AccessGranted; + PSECURITY_DESCRIPTOR SecurityDescriptor; +} SE_ADT_ACCESS_REASON, *PSE_ADT_ACCESS_REASON; + +typedef struct _SE_ADT_PARAMETER_ARRAY { + ULONG CategoryId; + ULONG AuditId; + ULONG ParameterCount; + ULONG Length; + USHORT FlatSubCategoryId; + USHORT Type; + ULONG Flags; + SE_ADT_PARAMETER_ARRAY_ENTRY Parameters[ SE_MAX_AUDIT_PARAMETERS ]; +} SE_ADT_PARAMETER_ARRAY, *PSE_ADT_PARAMETER_ARRAY; + +#endif /* !_NTLSA_AUDIT_ */ +#endif /* !_NTLSA_IFS_ */ +$endif + diff --git a/reactos/include/xdk/wdm.template.h b/reactos/include/xdk/wdm.template.h new file mode 100644 index 00000000000..1005bf13d94 --- /dev/null +++ b/reactos/include/xdk/wdm.template.h @@ -0,0 +1,243 @@ +/* + * wdm.h + * + * Windows NT WDM Driver Developer Kit + * + * This file is part of the ReactOS DDK package. + * + * Contributors: + * Amine Khaldi + * Timo Kreuzer (timo.kreuzer@reactos.org) + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAIMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + */ +#pragma once + +#ifndef _WDMDDK_ +#define _WDMDDK_ + +/* Included via ntddk.h? */ +#ifndef _NTDDK_ +#define _NTDDK_ +#define _WDM_INCLUDED_ +#define _DDK_DRIVER_ +#define NO_INTERLOCKED_INTRINSICS +#endif /* _NTDDK_ */ + +/* Dependencies */ +#define NT_INCLUDED +#include +#include +#include +#include + +#ifndef GUID_DEFINED +#include +#endif + +#ifdef _MAC +#ifndef _INC_STRING +#include +#endif /* _INC_STRING */ +#else +#include +#endif /* _MAC */ + +#ifndef _KTMTYPES_ +typedef GUID UOW, *PUOW; +#endif + +typedef GUID *PGUID; + +#if (NTDDI_VERSION >= NTDDI_WINXP) +#include +#endif + +#include "intrin.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_NTHALDLL_) && !defined(_BLDR_) +#define NTHALAPI DECLSPEC_IMPORT +#else +#define NTHALAPI +#endif + +/* For ReactOS */ +#if !defined(_NTOSKRNL_) && !defined(_BLDR_) +#define NTKERNELAPI DECLSPEC_IMPORT +#else +#define NTKERNELAPI +#endif + +#if defined(_X86_) && !defined(_NTHAL_) +#define _DECL_HAL_KE_IMPORT DECLSPEC_IMPORT +#elif defined(_X86_) +#define _DECL_HAL_KE_IMPORT +#else +#define _DECL_HAL_KE_IMPORT NTKERNELAPI +#endif + +#if defined(_WIN64) +#define POINTER_ALIGNMENT DECLSPEC_ALIGN(8) +#else +#define POINTER_ALIGNMENT +#endif + +/* Helper macro to enable gcc's extension. */ +#ifndef __GNU_EXTENSION +#ifdef __GNUC__ +#define __GNU_EXTENSION __extension__ +#else +#define __GNU_EXTENSION +#endif +#endif + +#if defined(_MSC_VER) + +/* Disable some warnings */ +#pragma warning(disable:4115) /* Named type definition in parentheses */ +#pragma warning(disable:4201) /* Nameless unions and structs */ +#pragma warning(disable:4214) /* Bit fields of other types than int */ +#pragma warning(disable:4820) /* Padding added, due to alignemnet requirement */ + +/* Indicate if #pragma alloc_text() is supported */ +#if defined(_M_IX86) || defined(_M_AMD64) || defined(_M_IA64) +#define ALLOC_PRAGMA 1 +#endif + +/* Indicate if #pragma data_seg() is supported */ +#if defined(_M_IX86) || defined(_M_AMD64) +#define ALLOC_DATA_PRAGMA 1 +#endif + +#endif + +/* Forward declarations */ +struct _IRP; +struct _MDL; +struct _KAPC; +struct _KDPC; +struct _FILE_OBJECT; +struct _DMA_ADAPTER; +struct _DEVICE_OBJECT; +struct _DRIVER_OBJECT; +struct _IO_STATUS_BLOCK; +struct _DEVICE_DESCRIPTION; +struct _SCATTER_GATHER_LIST; +struct _DRIVE_LAYOUT_INFORMATION; +struct _COMPRESSED_DATA_INFO; +struct _IO_RESOURCE_DESCRIPTOR; + +/* Structures not exposed to drivers */ +typedef struct _OBJECT_TYPE *POBJECT_TYPE; +typedef struct _HAL_DISPATCH_TABLE *PHAL_DISPATCH_TABLE; +typedef struct _HAL_PRIVATE_DISPATCH_TABLE *PHAL_PRIVATE_DISPATCH_TABLE; +typedef struct _CALLBACK_OBJECT *PCALLBACK_OBJECT; +typedef struct _EPROCESS *PEPROCESS; +typedef struct _ETHREAD *PETHREAD; +typedef struct _IO_TIMER *PIO_TIMER; +typedef struct _KINTERRUPT *PKINTERRUPT; +typedef struct _KPROCESS *PKPROCESS; +typedef struct _KTHREAD *PKTHREAD, *PRKTHREAD; +typedef struct _CONTEXT *PCONTEXT; + +#if defined(USE_DMA_MACROS) && !defined(_NTHAL_) && ( defined(_NTDDK_) || defined(_NTDRIVER_) || defined(_NTOSP_)) +typedef struct _DMA_ADAPTER *PADAPTER_OBJECT; +#elif defined(_WDM_INCLUDED_) +typedef struct _DMA_ADAPTER *PADAPTER_OBJECT; +#else +typedef struct _ADAPTER_OBJECT *PADAPTER_OBJECT; +#endif + +#ifndef DEFINE_GUIDEX +#ifdef _MSC_VER +#define DEFINE_GUIDEX(name) EXTERN_C const CDECL GUID name +#else +#define DEFINE_GUIDEX(name) EXTERN_C const GUID name +#endif +#endif /* DEFINE_GUIDEX */ + +#ifndef STATICGUIDOF +#define STATICGUIDOF(guid) STATIC_##guid +#endif + +/* GUID Comparison */ +#ifndef __IID_ALIGNED__ +#define __IID_ALIGNED__ +#ifdef __cplusplus +inline int IsEqualGUIDAligned(REFGUID guid1, REFGUID guid2) +{ + return ( (*(PLONGLONG)(&guid1) == *(PLONGLONG)(&guid2)) && + (*((PLONGLONG)(&guid1) + 1) == *((PLONGLONG)(&guid2) + 1)) ); +} +#else +#define IsEqualGUIDAligned(guid1, guid2) \ + ( (*(PLONGLONG)(guid1) == *(PLONGLONG)(guid2)) && \ + (*((PLONGLONG)(guid1) + 1) == *((PLONGLONG)(guid2) + 1)) ) +#endif /* __cplusplus */ +#endif /* !__IID_ALIGNED__ */ + + +$define (_WDMDDK_) +$include (interlocked.h) +$include (rtltypes.h) +$include (ketypes.h) +$include (mmtypes.h) +$include (extypes.h) +$include (setypes.h) +$include (potypes.h) +$include (cmtypes.h) +$include (iotypes.h) +$include (obtypes.h) +$include (pstypes.h) +$include (wmitypes.h) + +#if defined(_M_IX86) +$include(x86/ke.h) +#elif defined(_M_AMD64) +$include(amd64/ke.h) +#elif defined(_M_IA64) +$include(ia64/ke.h) +#elif defined(_M_PPC) +$include(ppc/ke.h) +#elif defined(_M_MIPS) +$include(mips/ke.h) +#elif defined(_M_ARM) +$include(arm/ke.h) +#else +#error Unknown Architecture +#endif + +$include (rtlfuncs.h) +$include (kefuncs.h) +$include (mmfuncs.h) +$include (sefuncs.h) +$include (cmfuncs.h) +$include (iofuncs.h) +$include (pofuncs.h) +$include (exfuncs.h) +$include (obfuncs.h) +$include (psfuncs.h) +$include (wmifuncs.h) +$include (kdfuncs.h) +$include (halfuncs.h) +$include (nttmapi.h) +$include (zwfuncs.h) + +#ifdef __cplusplus +} +#endif + +#endif /* !_WDMDDK_ */ diff --git a/reactos/include/xdk/wmifuncs.h b/reactos/include/xdk/wmifuncs.h new file mode 100644 index 00000000000..6279a55ff90 --- /dev/null +++ b/reactos/include/xdk/wmifuncs.h @@ -0,0 +1,152 @@ +/****************************************************************************** + * WMI Library Support Functions * + ******************************************************************************/ + +#ifdef RUN_WPP +#if (NTDDI_VERSION >= NTDDI_WINXP) +NTKERNELAPI +NTSTATUS +__cdecl +WmiTraceMessage( + IN TRACEHANDLE LoggerHandle, + IN ULONG MessageFlags, + IN LPGUID MessageGuid, + IN USHORT MessageNumber, + IN ...); +#endif +#endif /* RUN_WPP */ + + #if (NTDDI_VERSION >= NTDDI_WINXP) + +NTKERNELAPI +NTSTATUS +NTAPI +WmiQueryTraceInformation( + IN TRACE_INFORMATION_CLASS TraceInformationClass, + OUT PVOID TraceInformation, + IN ULONG TraceInformationLength, + OUT PULONG RequiredLength OPTIONAL, + IN PVOID Buffer OPTIONAL); + +#if 0 +/* FIXME: Get va_list from where? */ +NTKERNELAPI +NTSTATUS +__cdecl +WmiTraceMessageVa( + IN TRACEHANDLE LoggerHandle, + IN ULONG MessageFlags, + IN LPGUID MessageGuid, + IN USHORT MessageNumber, + IN va_list MessageArgList); +#endif + +#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ + +#ifndef TRACE_INFORMATION_CLASS_DEFINE + +#if (NTDDI_VERSION >= NTDDI_WINXP) +NTKERNELAPI +NTSTATUS +NTAPI +WmiQueryTraceInformation( + IN TRACE_INFORMATION_CLASS TraceInformationClass, + OUT PVOID TraceInformation, + IN ULONG TraceInformationLength, + OUT PULONG RequiredLength OPTIONAL, + IN PVOID Buffer OPTIONAL); +#endif + +#define TRACE_INFORMATION_CLASS_DEFINE + +#endif /* TRACE_INFOPRMATION_CLASS_DEFINE */ + +#if (NTDDI_VERSION >= NTDDI_VISTA) + +NTSTATUS +NTKERNELAPI +NTAPI +EtwRegister( + IN LPCGUID ProviderId, + IN PETWENABLECALLBACK EnableCallback OPTIONAL, + IN PVOID CallbackContext OPTIONAL, + OUT PREGHANDLE RegHandle); + +NTSTATUS +NTKERNELAPI +NTAPI +EtwUnregister( + IN REGHANDLE RegHandle); + +BOOLEAN +NTKERNELAPI +NTAPI +EtwEventEnabled( + IN REGHANDLE RegHandle, + IN PCEVENT_DESCRIPTOR EventDescriptor); + +BOOLEAN +NTKERNELAPI +NTAPI +EtwProviderEnabled( + IN REGHANDLE RegHandle, + IN UCHAR Level, + IN ULONGLONG Keyword); + +NTSTATUS +NTKERNELAPI +NTAPI +EtwActivityIdControl( + IN ULONG ControlCode, + IN OUT LPGUID ActivityId); + +NTSTATUS +NTKERNELAPI +NTAPI +EtwWrite( + IN REGHANDLE RegHandle, + IN PCEVENT_DESCRIPTOR EventDescriptor, + IN LPCGUID ActivityId OPTIONAL, + IN ULONG UserDataCount, + IN PEVENT_DATA_DESCRIPTOR UserData OPTIONAL); + +NTSTATUS +NTKERNELAPI +NTAPI +EtwWriteTransfer( + IN REGHANDLE RegHandle, + IN PCEVENT_DESCRIPTOR EventDescriptor, + IN LPCGUID ActivityId OPTIONAL, + IN LPCGUID RelatedActivityId OPTIONAL, + IN ULONG UserDataCount, + IN PEVENT_DATA_DESCRIPTOR UserData OPTIONAL); + +NTSTATUS +NTKERNELAPI +NTAPI +EtwWriteString( + IN REGHANDLE RegHandle, + IN UCHAR Level, + IN ULONGLONG Keyword, + IN LPCGUID ActivityId OPTIONAL, + IN PCWSTR String); + +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + +#if (NTDDI_VERSION >= NTDDI_WIN7) +NTSTATUS +NTKERNELAPI +NTAPI +EtwWriteEx( + IN REGHANDLE RegHandle, + IN PCEVENT_DESCRIPTOR EventDescriptor, + IN ULONG64 Filter, + IN ULONG Flags, + IN LPCGUID ActivityId OPTIONAL, + IN LPCGUID RelatedActivityId OPTIONAL, + IN ULONG UserDataCount, + IN PEVENT_DATA_DESCRIPTOR UserData OPTIONAL); +#endif + + + diff --git a/reactos/include/xdk/wmitypes.h b/reactos/include/xdk/wmitypes.h new file mode 100644 index 00000000000..c4fd0bac146 --- /dev/null +++ b/reactos/include/xdk/wmitypes.h @@ -0,0 +1,62 @@ +/****************************************************************************** + * WMI Library Support Types * + ******************************************************************************/ + +#ifdef RUN_WPP +#include +#include +#endif + +#ifndef _TRACEHANDLE_DEFINED +#define _TRACEHANDLE_DEFINED +typedef ULONG64 TRACEHANDLE, *PTRACEHANDLE; +#endif + +#ifndef TRACE_INFORMATION_CLASS_DEFINE + +typedef struct _ETW_TRACE_SESSION_SETTINGS { + ULONG Version; + ULONG BufferSize; + ULONG MinimumBuffers; + ULONG MaximumBuffers; + ULONG LoggerMode; + ULONG FlushTimer; + ULONG FlushThreshold; + ULONG ClockType; +} ETW_TRACE_SESSION_SETTINGS, *PETW_TRACE_SESSION_SETTINGS; + +typedef enum _TRACE_INFORMATION_CLASS { + TraceIdClass, + TraceHandleClass, + TraceEnableFlagsClass, + TraceEnableLevelClass, + GlobalLoggerHandleClass, + EventLoggerHandleClass, + AllLoggerHandlesClass, + TraceHandleByNameClass, + LoggerEventsLostClass, + TraceSessionSettingsClass, + LoggerEventsLoggedClass, + MaxTraceInformationClass +} TRACE_INFORMATION_CLASS; + +#endif /* TRACE_INFORMATION_CLASS_DEFINE */ + +#ifndef _ETW_KM_ +#define _ETW_KM_ +#endif + +#include + +typedef VOID +(NTAPI *PETWENABLECALLBACK)( + IN LPCGUID SourceId, + IN ULONG ControlCode, + IN UCHAR Level, + IN ULONGLONG MatchAnyKeyword, + IN ULONGLONG MatchAllKeyword, + IN PEVENT_FILTER_DESCRIPTOR FilterData OPTIONAL, + IN OUT PVOID CallbackContext OPTIONAL); + +#define EVENT_WRITE_FLAG_NO_FAULTING 0x00000001 + diff --git a/reactos/include/xdk/x86/ke.h b/reactos/include/xdk/x86/ke.h new file mode 100644 index 00000000000..19d42740ee4 --- /dev/null +++ b/reactos/include/xdk/x86/ke.h @@ -0,0 +1,288 @@ +$if (_WDMDDK_) +/** Kernel definitions for x86 **/ + +/* Interrupt request levels */ +#define PASSIVE_LEVEL 0 +#define LOW_LEVEL 0 +#define APC_LEVEL 1 +#define DISPATCH_LEVEL 2 +#define CMCI_LEVEL 5 +#define PROFILE_LEVEL 27 +#define CLOCK1_LEVEL 28 +#define CLOCK2_LEVEL 28 +#define IPI_LEVEL 29 +#define POWER_LEVEL 30 +#define HIGH_LEVEL 31 +#define CLOCK_LEVEL CLOCK2_LEVEL + +#define KIP0PCRADDRESS 0xffdff000 +#define KI_USER_SHARED_DATA 0xffdf0000 +#define SharedUserData ((KUSER_SHARED_DATA * CONST)KI_USER_SHARED_DATA) + +#define PAGE_SIZE 0x1000 +#define PAGE_SHIFT 12L +#define KeGetDcacheFillSize() 1L + +#define EFLAG_SIGN 0x8000 +#define EFLAG_ZERO 0x4000 +#define EFLAG_SELECT (EFLAG_SIGN | EFLAG_ZERO) + +#define RESULT_NEGATIVE ((EFLAG_SIGN & ~EFLAG_ZERO) & EFLAG_SELECT) +#define RESULT_ZERO ((~EFLAG_SIGN & EFLAG_ZERO) & EFLAG_SELECT) +#define RESULT_POSITIVE ((~EFLAG_SIGN & ~EFLAG_ZERO) & EFLAG_SELECT) + + +typedef struct _KFLOATING_SAVE { + ULONG ControlWord; + ULONG StatusWord; + ULONG ErrorOffset; + ULONG ErrorSelector; + ULONG DataOffset; + ULONG DataSelector; + ULONG Cr0NpxState; + ULONG Spare1; +} KFLOATING_SAVE, *PKFLOATING_SAVE; + +extern NTKERNELAPI volatile KSYSTEM_TIME KeTickCount; + +#define YieldProcessor _mm_pause + +FORCEINLINE +VOID +KeMemoryBarrier(VOID) +{ + volatile LONG Barrier; +#if defined(__GNUC__) + __asm__ __volatile__ ("xchg %%eax, %0" : : "m" (Barrier) : "%eax"); +#elif defined(_MSC_VER) + __asm xchg [Barrier], eax +#endif +} + +NTHALAPI +KIRQL +NTAPI +KeGetCurrentIrql(VOID); + +NTHALAPI +VOID +FASTCALL +KfLowerIrql( + IN KIRQL NewIrql); +#define KeLowerIrql(a) KfLowerIrql(a) + +NTHALAPI +KIRQL +FASTCALL +KfRaiseIrql( + IN KIRQL NewIrql); +#define KeRaiseIrql(a,b) *(b) = KfRaiseIrql(a) + +NTHALAPI +KIRQL +NTAPI +KeRaiseIrqlToDpcLevel(VOID); + +NTHALAPI +KIRQL +NTAPI +KeRaiseIrqlToSynchLevel(VOID); + +NTHALAPI +KIRQL +FASTCALL +KfAcquireSpinLock( + IN OUT PKSPIN_LOCK SpinLock); +#define KeAcquireSpinLock(a,b) *(b) = KfAcquireSpinLock(a) + +NTHALAPI +VOID +FASTCALL +KfReleaseSpinLock( + IN OUT PKSPIN_LOCK SpinLock, + IN KIRQL NewIrql); +#define KeReleaseSpinLock(a,b) KfReleaseSpinLock(a,b) + +NTKERNELAPI +VOID +FASTCALL +KefAcquireSpinLockAtDpcLevel( + IN OUT PKSPIN_LOCK SpinLock); +#define KeAcquireSpinLockAtDpcLevel(SpinLock) KefAcquireSpinLockAtDpcLevel(SpinLock) + +NTKERNELAPI +VOID +FASTCALL +KefReleaseSpinLockFromDpcLevel( + IN OUT PKSPIN_LOCK SpinLock); +#define KeReleaseSpinLockFromDpcLevel(SpinLock) KefReleaseSpinLockFromDpcLevel(SpinLock) + +NTSYSAPI +PKTHREAD +NTAPI +KeGetCurrentThread(VOID); + +NTKERNELAPI +NTSTATUS +NTAPI +KeSaveFloatingPointState( + OUT PKFLOATING_SAVE FloatSave); + +NTKERNELAPI +NTSTATUS +NTAPI +KeRestoreFloatingPointState( + IN PKFLOATING_SAVE FloatSave); + +/* VOID + * KeFlushIoBuffers( + * IN PMDL Mdl, + * IN BOOLEAN ReadOperation, + * IN BOOLEAN DmaOperation) + */ +#define KeFlushIoBuffers(_Mdl, _ReadOperation, _DmaOperation) + +/* x86 and x64 performs a 0x2C interrupt */ +#define DbgRaiseAssertionFailure __int2c + +FORCEINLINE +VOID +_KeQueryTickCount( + OUT PLARGE_INTEGER CurrentCount) +{ + for (;;) { + CurrentCount->HighPart = KeTickCount.High1Time; + CurrentCount->LowPart = KeTickCount.LowPart; + if (CurrentCount->HighPart == KeTickCount.High2Time) break; + YieldProcessor(); + } +} +#define KeQueryTickCount(CurrentCount) _KeQueryTickCount(CurrentCount) + +$endif /* _WDMDDK_ */ +$if (_NTDDK_) + +#define PAUSE_PROCESSOR YieldProcessor(); + +#define KERNEL_STACK_SIZE 12288 +#define KERNEL_LARGE_STACK_SIZE 61440 +#define KERNEL_LARGE_STACK_COMMIT 12288 + +#define SIZE_OF_80387_REGISTERS 80 + +#if !defined(RC_INVOKED) + +#define CONTEXT_i386 0x10000 +#define CONTEXT_i486 0x10000 +#define CONTEXT_CONTROL (CONTEXT_i386|0x00000001L) +#define CONTEXT_INTEGER (CONTEXT_i386|0x00000002L) +#define CONTEXT_SEGMENTS (CONTEXT_i386|0x00000004L) +#define CONTEXT_FLOATING_POINT (CONTEXT_i386|0x00000008L) +#define CONTEXT_DEBUG_REGISTERS (CONTEXT_i386|0x00000010L) +#define CONTEXT_EXTENDED_REGISTERS (CONTEXT_i386|0x00000020L) + +#define CONTEXT_FULL (CONTEXT_CONTROL|CONTEXT_INTEGER|CONTEXT_SEGMENTS) +#define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | \ + CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS | \ + CONTEXT_EXTENDED_REGISTERS) + +#define CONTEXT_XSTATE (CONTEXT_i386 | 0x00000040L) + +#endif /* !defined(RC_INVOKED) */ + +typedef struct _FLOATING_SAVE_AREA { + ULONG ControlWord; + ULONG StatusWord; + ULONG TagWord; + ULONG ErrorOffset; + ULONG ErrorSelector; + ULONG DataOffset; + ULONG DataSelector; + UCHAR RegisterArea[SIZE_OF_80387_REGISTERS]; + ULONG Cr0NpxState; +} FLOATING_SAVE_AREA, *PFLOATING_SAVE_AREA; + +#include "pshpack4.h" +typedef struct _CONTEXT { + ULONG ContextFlags; + ULONG Dr0; + ULONG Dr1; + ULONG Dr2; + ULONG Dr3; + ULONG Dr6; + ULONG Dr7; + FLOATING_SAVE_AREA FloatSave; + ULONG SegGs; + ULONG SegFs; + ULONG SegEs; + ULONG SegDs; + ULONG Edi; + ULONG Esi; + ULONG Ebx; + ULONG Edx; + ULONG Ecx; + ULONG Eax; + ULONG Ebp; + ULONG Eip; + ULONG SegCs; + ULONG EFlags; + ULONG Esp; + ULONG SegSs; + UCHAR ExtendedRegisters[MAXIMUM_SUPPORTED_EXTENSION]; +} CONTEXT; +#include "poppack.h" + +#define KeGetPcr() PCR + +#define PCR_MINOR_VERSION 1 +#define PCR_MAJOR_VERSION 1 + +typedef struct _KPCR { + union { + NT_TIB NtTib; + struct { + struct _EXCEPTION_REGISTRATION_RECORD *Used_ExceptionList; + PVOID Used_StackBase; + PVOID Spare2; + PVOID TssCopy; + ULONG ContextSwitches; + KAFFINITY SetMemberCopy; + PVOID Used_Self; + }; + }; + struct _KPCR *SelfPcr; + struct _KPRCB *Prcb; + KIRQL Irql; + ULONG IRR; + ULONG IrrActive; + ULONG IDR; + PVOID KdVersionBlock; + struct _KIDTENTRY *IDT; + struct _KGDTENTRY *GDT; + struct _KTSS *TSS; + USHORT MajorVersion; + USHORT MinorVersion; + KAFFINITY SetMember; + ULONG StallScaleFactor; + UCHAR SpareUnused; + UCHAR Number; + UCHAR Spare0; + UCHAR SecondLevelCacheAssociativity; + ULONG VdmAlert; + ULONG KernelReserved[14]; + ULONG SecondLevelCacheSize; + ULONG HalReserved[16]; +} KPCR, *PKPCR; + +FORCEINLINE +ULONG +KeGetCurrentProcessorNumber(VOID) +{ + return (ULONG)__readfsbyte(FIELD_OFFSET(KPCR, Number)); +} + +$endif /* _NTDDK_ */ + + + + diff --git a/reactos/include/xdk/x86/mm.h b/reactos/include/xdk/x86/mm.h new file mode 100644 index 00000000000..d2cddd13701 --- /dev/null +++ b/reactos/include/xdk/x86/mm.h @@ -0,0 +1,24 @@ +$if (_NTDDK_) + +extern NTKERNELAPI PVOID MmHighestUserAddress; +extern NTKERNELAPI PVOID MmSystemRangeStart; +extern NTKERNELAPI ULONG MmUserProbeAddress; + +#define MM_HIGHEST_USER_ADDRESS MmHighestUserAddress +#define MM_SYSTEM_RANGE_START MmSystemRangeStart +#if defined(_LOCAL_COPY_USER_PROBE_ADDRESS_) +#define MM_USER_PROBE_ADDRESS _LOCAL_COPY_USER_PROBE_ADDRESS_ +extern ULONG _LOCAL_COPY_USER_PROBE_ADDRESS_; +#else +#define MM_USER_PROBE_ADDRESS MmUserProbeAddress +#endif +#define MM_LOWEST_USER_ADDRESS (PVOID)0x10000 +#define MM_KSEG0_BASE MM_SYSTEM_RANGE_START +#define MM_SYSTEM_SPACE_END 0xFFFFFFFF +#if !defined (_X86PAE_) +#define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xC0800000 +#else +#define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xC0C00000 +#endif + +$endif /* _NTDDK_ */ diff --git a/reactos/include/xdk/zwfuncs.h b/reactos/include/xdk/zwfuncs.h new file mode 100644 index 00000000000..3299df523ee --- /dev/null +++ b/reactos/include/xdk/zwfuncs.h @@ -0,0 +1,820 @@ +/****************************************************************************** + * ZwXxx Functions * + ******************************************************************************/ + +$if (_WDMDDK_) + +/* Constants */ +#define NtCurrentProcess() ( (HANDLE)(LONG_PTR) -1 ) +#define ZwCurrentProcess() NtCurrentProcess() +#define NtCurrentThread() ( (HANDLE)(LONG_PTR) -2 ) +#define ZwCurrentThread() NtCurrentThread() + +$endif + +$if (_NTDDK_) + +NTSYSAPI +NTSTATUS +NTAPI +ZwAllocateLocallyUniqueId( + OUT PLUID Luid); + +NTSYSAPI +NTSTATUS +NTAPI +ZwTerminateProcess( + IN HANDLE ProcessHandle OPTIONAL, + IN NTSTATUS ExitStatus); + +NTSYSAPI +NTSTATUS +NTAPI +ZwOpenProcess( + OUT PHANDLE ProcessHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN PCLIENT_ID ClientId OPTIONAL); + +$endif + +#if (NTDDI_VERSION >= NTDDI_WIN2K) + +$if (_NTDDK_) + +NTSTATUS +NTAPI +ZwCancelTimer( + IN HANDLE TimerHandle, + OUT PBOOLEAN CurrentState OPTIONAL); + +NTSTATUS +NTAPI +ZwCreateTimer( + OUT PHANDLE TimerHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, + IN TIMER_TYPE TimerType); + +NTSTATUS +NTAPI +ZwOpenTimer( + OUT PHANDLE TimerHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes); + +NTSYSAPI +NTSTATUS +NTAPI +ZwSetInformationThread( + IN HANDLE ThreadHandle, + IN THREADINFOCLASS ThreadInformationClass, + IN PVOID ThreadInformation, + IN ULONG ThreadInformationLength); + +NTSTATUS +NTAPI +ZwSetTimer( + IN HANDLE TimerHandle, + IN PLARGE_INTEGER DueTime, + IN PTIMER_APC_ROUTINE TimerApcRoutine OPTIONAL, + IN PVOID TimerContext OPTIONAL, + IN BOOLEAN ResumeTimer, + IN LONG Period OPTIONAL, + OUT PBOOLEAN PreviousState OPTIONAL); + +NTSYSAPI +NTSTATUS +NTAPI +ZwDisplayString( + IN PUNICODE_STRING String); + +NTSYSAPI +NTSTATUS +NTAPI +ZwPowerInformation( + IN POWER_INFORMATION_LEVEL PowerInformationLevel, + IN PVOID InputBuffer OPTIONAL, + IN ULONG InputBufferLength, + OUT PVOID OutputBuffer OPTIONAL, + IN ULONG OutputBufferLength); + +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryVolumeInformationFile( + IN HANDLE FileHandle, + OUT PIO_STATUS_BLOCK IoStatusBlock, + OUT PVOID FsInformation, + IN ULONG Length, + IN FS_INFORMATION_CLASS FsInformationClass); + +NTSYSAPI +NTSTATUS +NTAPI +ZwDeviceIoControlFile( + IN HANDLE FileHandle, + IN HANDLE Event OPTIONAL, + IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, + IN PVOID ApcContext OPTIONAL, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN ULONG IoControlCode, + IN PVOID InputBuffer OPTIONAL, + IN ULONG InputBufferLength, + OUT PVOID OutputBuffer OPTIONAL, + IN ULONG OutputBufferLength); + +$endif + +$if (_WDMDDK_) + +NTSYSAPI +NTSTATUS +NTAPI +ZwClose( + IN HANDLE Handle); + +NTSYSAPI +NTSTATUS +NTAPI +ZwCreateDirectoryObject( + OUT PHANDLE DirectoryHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes); + +NTSYSAPI +NTSTATUS +NTAPI +ZwCreateFile( + OUT PHANDLE FileHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN PLARGE_INTEGER AllocationSize OPTIONAL, + IN ULONG FileAttributes, + IN ULONG ShareAccess, + IN ULONG CreateDisposition, + IN ULONG CreateOptions, + IN PVOID EaBuffer OPTIONAL, + IN ULONG EaLength); + +NTSYSAPI +NTSTATUS +NTAPI +ZwCreateKey( + OUT PHANDLE KeyHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN ULONG TitleIndex, + IN PUNICODE_STRING Class OPTIONAL, + IN ULONG CreateOptions, + OUT PULONG Disposition OPTIONAL); + +NTSYSAPI +NTSTATUS +NTAPI +ZwCreateSection( + OUT PHANDLE SectionHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, + IN PLARGE_INTEGER MaximumSize OPTIONAL, + IN ULONG SectionPageProtection, + IN ULONG AllocationAttributes, + IN HANDLE FileHandle OPTIONAL); + +NTSYSAPI +NTSTATUS +NTAPI +ZwDeleteKey( + IN HANDLE KeyHandle); + +NTSYSAPI +NTSTATUS +NTAPI +ZwDeleteValueKey( + IN HANDLE KeyHandle, + IN PUNICODE_STRING ValueName); + +NTSYSAPI +NTSTATUS +NTAPI +ZwEnumerateKey( + IN HANDLE KeyHandle, + IN ULONG Index, + IN KEY_INFORMATION_CLASS KeyInformationClass, + OUT PVOID KeyInformation OPTIONAL, + IN ULONG Length, + OUT PULONG ResultLength); + +NTSYSAPI +NTSTATUS +NTAPI +ZwEnumerateValueKey( + IN HANDLE KeyHandle, + IN ULONG Index, + IN KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass, + OUT PVOID KeyValueInformation OPTIONAL, + IN ULONG Length, + OUT PULONG ResultLength); + +NTSYSAPI +NTSTATUS +NTAPI +ZwFlushKey( + IN HANDLE KeyHandle); + +NTSYSAPI +NTSTATUS +NTAPI +ZwLoadDriver( + IN PUNICODE_STRING DriverServiceName); + +NTSYSAPI +NTSTATUS +NTAPI +ZwMakeTemporaryObject( + IN HANDLE Handle); + +NTSYSAPI +NTSTATUS +NTAPI +ZwMapViewOfSection( + IN HANDLE SectionHandle, + IN HANDLE ProcessHandle, + IN OUT PVOID *BaseAddress, + IN ULONG_PTR ZeroBits, + IN SIZE_T CommitSize, + IN OUT PLARGE_INTEGER SectionOffset OPTIONAL, + IN OUT PSIZE_T ViewSize, + IN SECTION_INHERIT InheritDisposition, + IN ULONG AllocationType, + IN ULONG Protect); + +NTSYSAPI +NTSTATUS +NTAPI +ZwOpenFile( + OUT PHANDLE FileHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN ULONG ShareAccess, + IN ULONG OpenOptions); + +NTSYSAPI +NTSTATUS +NTAPI +ZwOpenKey( + OUT PHANDLE KeyHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes); + +NTSYSAPI +NTSTATUS +NTAPI +ZwOpenSection( + OUT PHANDLE SectionHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes); + +NTSYSAPI +NTSTATUS +NTAPI +ZwOpenSymbolicLinkObject( + OUT PHANDLE LinkHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes); + +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryInformationFile( + IN HANDLE FileHandle, + OUT PIO_STATUS_BLOCK IoStatusBlock, + OUT PVOID FileInformation, + IN ULONG Length, + IN FILE_INFORMATION_CLASS FileInformationClass); + +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryKey( + IN HANDLE KeyHandle, + IN KEY_INFORMATION_CLASS KeyInformationClass, + OUT PVOID KeyInformation OPTIONAL, + IN ULONG Length, + OUT PULONG ResultLength); + +NTSYSAPI +NTSTATUS +NTAPI +ZwQuerySymbolicLinkObject( + IN HANDLE LinkHandle, + IN OUT PUNICODE_STRING LinkTarget, + OUT PULONG ReturnedLength OPTIONAL); + +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryValueKey( + IN HANDLE KeyHandle, + IN PUNICODE_STRING ValueName, + IN KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass, + OUT PVOID KeyValueInformation OPTIONAL, + IN ULONG Length, + OUT PULONG ResultLength); + +NTSYSAPI +NTSTATUS +NTAPI +ZwReadFile( + IN HANDLE FileHandle, + IN HANDLE Event OPTIONAL, + IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, + IN PVOID ApcContext OPTIONAL, + OUT PIO_STATUS_BLOCK IoStatusBlock, + OUT PVOID Buffer, + IN ULONG Length, + IN PLARGE_INTEGER ByteOffset OPTIONAL, + IN PULONG Key OPTIONAL); + +NTSYSAPI +NTSTATUS +NTAPI +ZwSetInformationFile( + IN HANDLE FileHandle, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN PVOID FileInformation, + IN ULONG Length, + IN FILE_INFORMATION_CLASS FileInformationClass); + +NTSYSAPI +NTSTATUS +NTAPI +ZwSetValueKey( + IN HANDLE KeyHandle, + IN PUNICODE_STRING ValueName, + IN ULONG TitleIndex OPTIONAL, + IN ULONG Type, + IN PVOID Data OPTIONAL, + IN ULONG DataSize); + +NTSYSAPI +NTSTATUS +NTAPI +ZwUnloadDriver( + IN PUNICODE_STRING DriverServiceName); + +NTSYSAPI +NTSTATUS +NTAPI +ZwUnmapViewOfSection( + IN HANDLE ProcessHandle, + IN PVOID BaseAddress OPTIONAL); + +NTSYSAPI +NTSTATUS +NTAPI +ZwWriteFile( + IN HANDLE FileHandle, + IN HANDLE Event OPTIONAL, + IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, + IN PVOID ApcContext OPTIONAL, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN PVOID Buffer, + IN ULONG Length, + IN PLARGE_INTEGER ByteOffset OPTIONAL, + IN PULONG Key OPTIONAL); + +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryFullAttributesFile( + IN POBJECT_ATTRIBUTES ObjectAttributes, + OUT PFILE_NETWORK_OPEN_INFORMATION FileInformation); + +$endif + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ + +$if (_WDMDDK_) + +#if (NTDDI_VERSION >= NTDDI_WS03) +NTSYSCALLAPI +NTSTATUS +NTAPI +ZwOpenEvent( + OUT PHANDLE EventHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes); +#endif + +#if (NTDDI_VERSION >= NTDDI_VISTA) + +NTSYSAPI +NTSTATUS +ZwCreateKeyTransacted( + OUT PHANDLE KeyHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN ULONG TitleIndex, + IN PUNICODE_STRING Class OPTIONAL, + IN ULONG CreateOptions, + IN HANDLE TransactionHandle, + OUT PULONG Disposition OPTIONAL); + +NTSYSAPI +NTSTATUS +NTAPI +ZwOpenKeyTransacted( + OUT PHANDLE KeyHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN HANDLE TransactionHandle); + +NTSYSCALLAPI +NTSTATUS +NTAPI +ZwCreateTransactionManager( + OUT PHANDLE TmHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, + IN PUNICODE_STRING LogFileName OPTIONAL, + IN ULONG CreateOptions OPTIONAL, + IN ULONG CommitStrength OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +ZwOpenTransactionManager( + OUT PHANDLE TmHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, + IN PUNICODE_STRING LogFileName OPTIONAL, + IN LPGUID TmIdentity OPTIONAL, + IN ULONG OpenOptions OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +ZwRollforwardTransactionManager( + IN HANDLE TransactionManagerHandle, + IN PLARGE_INTEGER TmVirtualClock OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +ZwRecoverTransactionManager( + IN HANDLE TransactionManagerHandle); + +NTSYSCALLAPI +NTSTATUS +NTAPI +ZwQueryInformationTransactionManager( + IN HANDLE TransactionManagerHandle, + IN TRANSACTIONMANAGER_INFORMATION_CLASS TransactionManagerInformationClass, + OUT PVOID TransactionManagerInformation, + IN ULONG TransactionManagerInformationLength, + OUT PULONG ReturnLength OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +ZwSetInformationTransactionManager( + IN HANDLE TmHandle, + IN TRANSACTIONMANAGER_INFORMATION_CLASS TransactionManagerInformationClass, + IN PVOID TransactionManagerInformation, + IN ULONG TransactionManagerInformationLength); + +NTSYSCALLAPI +NTSTATUS +NTAPI +ZwEnumerateTransactionObject( + IN HANDLE RootObjectHandle OPTIONAL, + IN KTMOBJECT_TYPE QueryType, + IN OUT PKTMOBJECT_CURSOR ObjectCursor, + IN ULONG ObjectCursorLength, + OUT PULONG ReturnLength); + +NTSYSCALLAPI +NTSTATUS +NTAPI +ZwCreateTransaction( + OUT PHANDLE TransactionHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, + IN LPGUID Uow OPTIONAL, + IN HANDLE TmHandle OPTIONAL, + IN ULONG CreateOptions OPTIONAL, + IN ULONG IsolationLevel OPTIONAL, + IN ULONG IsolationFlags OPTIONAL, + IN PLARGE_INTEGER Timeout OPTIONAL, + IN PUNICODE_STRING Description OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +ZwOpenTransaction( + OUT PHANDLE TransactionHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, + IN LPGUID Uow, + IN HANDLE TmHandle OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +ZwQueryInformationTransaction( + IN HANDLE TransactionHandle, + IN TRANSACTION_INFORMATION_CLASS TransactionInformationClass, + OUT PVOID TransactionInformation, + IN ULONG TransactionInformationLength, + OUT PULONG ReturnLength OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +ZwSetInformationTransaction( + IN HANDLE TransactionHandle, + IN TRANSACTION_INFORMATION_CLASS TransactionInformationClass, + IN PVOID TransactionInformation, + IN ULONG TransactionInformationLength); + +NTSYSCALLAPI +NTSTATUS +NTAPI +ZwCommitTransaction( + IN HANDLE TransactionHandle, + IN BOOLEAN Wait); + +NTSYSCALLAPI +NTSTATUS +NTAPI +ZwRollbackTransaction( + IN HANDLE TransactionHandle, + IN BOOLEAN Wait); + +NTSYSCALLAPI +NTSTATUS +NTAPI +ZwCreateResourceManager( + OUT PHANDLE ResourceManagerHandle, + IN ACCESS_MASK DesiredAccess, + IN HANDLE TmHandle, + IN LPGUID ResourceManagerGuid OPTIONAL, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, + IN ULONG CreateOptions OPTIONAL, + IN PUNICODE_STRING Description OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +ZwOpenResourceManager( + OUT PHANDLE ResourceManagerHandle, + IN ACCESS_MASK DesiredAccess, + IN HANDLE TmHandle, + IN LPGUID ResourceManagerGuid, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +ZwRecoverResourceManager( + IN HANDLE ResourceManagerHandle); + +NTSYSCALLAPI +NTSTATUS +NTAPI +ZwGetNotificationResourceManager( + IN HANDLE ResourceManagerHandle, + OUT PTRANSACTION_NOTIFICATION TransactionNotification, + IN ULONG NotificationLength, + IN PLARGE_INTEGER Timeout, + IN PULONG ReturnLength OPTIONAL, + IN ULONG Asynchronous, + IN ULONG_PTR AsynchronousContext OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +ZwQueryInformationResourceManager( + IN HANDLE ResourceManagerHandle, + IN RESOURCEMANAGER_INFORMATION_CLASS ResourceManagerInformationClass, + OUT PVOID ResourceManagerInformation, + IN ULONG ResourceManagerInformationLength, + IN PULONG ReturnLength OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +ZwSetInformationResourceManager( + IN HANDLE ResourceManagerHandle, + IN RESOURCEMANAGER_INFORMATION_CLASS ResourceManagerInformationClass, + IN PVOID ResourceManagerInformation, + IN ULONG ResourceManagerInformationLength); + +NTSYSCALLAPI +NTSTATUS +NTAPI +ZwCreateEnlistment( + OUT PHANDLE EnlistmentHandle, + IN ACCESS_MASK DesiredAccess, + IN HANDLE ResourceManagerHandle, + IN HANDLE TransactionHandle, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, + IN ULONG CreateOptions OPTIONAL, + IN NOTIFICATION_MASK NotificationMask, + IN PVOID EnlistmentKey OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +ZwOpenEnlistment( + OUT PHANDLE EnlistmentHandle, + IN ACCESS_MASK DesiredAccess, + IN HANDLE RmHandle, + IN LPGUID EnlistmentGuid, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +ZwQueryInformationEnlistment( + IN HANDLE EnlistmentHandle, + IN ENLISTMENT_INFORMATION_CLASS EnlistmentInformationClass, + OUT PVOID EnlistmentInformation, + IN ULONG EnlistmentInformationLength, + IN PULONG ReturnLength OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +ZwSetInformationEnlistment( + IN HANDLE EnlistmentHandle, + IN ENLISTMENT_INFORMATION_CLASS EnlistmentInformationClass, + IN PVOID EnlistmentInformation, + IN ULONG EnlistmentInformationLength); + +NTSYSCALLAPI +NTSTATUS +NTAPI +ZwRecoverEnlistment( + IN HANDLE EnlistmentHandle, + IN PVOID EnlistmentKey OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +ZwPrePrepareEnlistment( + IN HANDLE EnlistmentHandle, + IN PLARGE_INTEGER TmVirtualClock OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +ZwPrepareEnlistment( + IN HANDLE EnlistmentHandle, + IN PLARGE_INTEGER TmVirtualClock OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +ZwCommitEnlistment( + IN HANDLE EnlistmentHandle, + IN PLARGE_INTEGER TmVirtualClock OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +ZwRollbackEnlistment( + IN HANDLE EnlistmentHandle, + IN PLARGE_INTEGER TmVirtualClock OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +ZwPrePrepareComplete( + IN HANDLE EnlistmentHandle, + IN PLARGE_INTEGER TmVirtualClock OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +ZwPrepareComplete( + IN HANDLE EnlistmentHandle, + IN PLARGE_INTEGER TmVirtualClock OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +ZwCommitComplete( + IN HANDLE EnlistmentHandle, + IN PLARGE_INTEGER TmVirtualClock OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +ZwReadOnlyEnlistment( + IN HANDLE EnlistmentHandle, + IN PLARGE_INTEGER TmVirtualClock OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +ZwRollbackComplete( + IN HANDLE EnlistmentHandle, + IN PLARGE_INTEGER TmVirtualClock OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +ZwSinglePhaseReject( + IN HANDLE EnlistmentHandle, + IN PLARGE_INTEGER TmVirtualClock OPTIONAL); + + +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + +$endif + +#if (NTDDI_VERSION >= NTDDI_WIN7) + +$if (_NTDDK_) +NTSTATUS +NTAPI +ZwSetTimerEx( + IN HANDLE TimerHandle, + IN TIMER_SET_INFORMATION_CLASS TimerSetInformationClass, + IN OUT PVOID TimerSetInformation, + IN ULONG TimerSetInformationLength); +$endif + +$if (_WDMDDK_) + +NTSYSAPI +NTSTATUS +NTAPI +ZwOpenKeyEx( + OUT PHANDLE KeyHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN ULONG OpenOptions); + +NTSYSAPI +NTSTATUS +NTAPI +ZwOpenKeyTransactedEx( + OUT PHANDLE KeyHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN ULONG OpenOptions, + IN HANDLE TransactionHandle); + +NTSYSAPI +NTSTATUS +NTAPI +ZwNotifyChangeMultipleKeys( + IN HANDLE MasterKeyHandle, + IN ULONG Count OPTIONAL, + IN OBJECT_ATTRIBUTES SubordinateObjects[] OPTIONAL, + IN HANDLE Event OPTIONAL, + IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, + IN PVOID ApcContext OPTIONAL, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN ULONG CompletionFilter, + IN BOOLEAN WatchTree, + OUT PVOID Buffer OPTIONAL, + IN ULONG BufferSize, + IN BOOLEAN Asynchronous); + +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryMultipleValueKey( + IN HANDLE KeyHandle, + IN OUT PKEY_VALUE_ENTRY ValueEntries, + IN ULONG EntryCount, + OUT PVOID ValueBuffer, + IN OUT PULONG BufferLength, + OUT PULONG RequiredBufferLength OPTIONAL); + +NTSYSAPI +NTSTATUS +NTAPI +ZwRenameKey( + IN HANDLE KeyHandle, + IN PUNICODE_STRING NewName); + +NTSYSAPI +NTSTATUS +NTAPI +ZwSetInformationKey( + IN HANDLE KeyHandle, + IN KEY_SET_INFORMATION_CLASS KeySetInformationClass, + IN PVOID KeySetInformation, + IN ULONG KeySetInformationLength); + +$endif + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + From 4656583b216dc175aecb3bb04c76861afd77d15d Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 29 Mar 2010 02:48:28 +0000 Subject: [PATCH 070/134] Reintegrate header branch part 4/x - don't prepend ddk/ before the header includes - move atsmedia.h to psdk - add mce.h, devpropdef.h, evntprov.h, ntiologc.h to psdk - replace ntstatus.h svn path=/trunk/; revision=46548 --- reactos/drivers/directx/dxapi/dxapi_driver.h | 12 +- reactos/drivers/directx/dxg/dxg_int.h | 10 +- reactos/include/ddk/atsmedia.h | 17 - reactos/include/ddk/mce.h | 1074 +++++++++ reactos/include/psdk/atsmedia.h | 7 + reactos/include/psdk/devpropdef.h | 84 + reactos/include/psdk/evntprov.h | 335 +++ reactos/include/psdk/ntiologc.h | 152 ++ reactos/include/psdk/ntstatus.h | 2223 +++++++++--------- reactos/include/{ddk => psdk}/tvout.h | 58 +- 10 files changed, 2825 insertions(+), 1147 deletions(-) delete mode 100644 reactos/include/ddk/atsmedia.h create mode 100644 reactos/include/ddk/mce.h create mode 100644 reactos/include/psdk/atsmedia.h create mode 100644 reactos/include/psdk/devpropdef.h create mode 100644 reactos/include/psdk/evntprov.h create mode 100644 reactos/include/psdk/ntiologc.h rename reactos/include/{ddk => psdk}/tvout.h (81%) diff --git a/reactos/drivers/directx/dxapi/dxapi_driver.h b/reactos/drivers/directx/dxapi/dxapi_driver.h index 322d6d1d67f..996353c7f2d 100644 --- a/reactos/drivers/directx/dxapi/dxapi_driver.h +++ b/reactos/drivers/directx/dxapi/dxapi_driver.h @@ -1,10 +1,10 @@ /* DDK/NDK/SDK Headers */ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include @@ -16,7 +16,7 @@ #include -#include +#include /* Prototypes */ VOID DxGetVersionNumber(PVOID lpvInBuffer, LPDDGETVERSIONNUMBER lpvOutBuffer); diff --git a/reactos/drivers/directx/dxg/dxg_int.h b/reactos/drivers/directx/dxg/dxg_int.h index b457e6d5c3d..ccb2204a781 100644 --- a/reactos/drivers/directx/dxg/dxg_int.h +++ b/reactos/drivers/directx/dxg/dxg_int.h @@ -1,9 +1,9 @@ /* DDK/NDK/SDK Headers */ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include /* Win32 Headers */ #define WINBASEAPI diff --git a/reactos/include/ddk/atsmedia.h b/reactos/include/ddk/atsmedia.h deleted file mode 100644 index 744a4654870..00000000000 --- a/reactos/include/ddk/atsmedia.h +++ /dev/null @@ -1,17 +0,0 @@ - -/* $Id: $ - * - * COPYRIGHT: This file is in the public domain. - * PROJECT: ReactOS kernel - * FILE: - * PURPOSE: headers - * PROGRAMMER: Magnus Olsen (greatlrd) - * - */ - -#if !defined(_ATSCMEDIA_) -#define _ATSCMEDIA_ -#define BDANETWORKTYPE_ATSC DEFINE_GUIDNAMED(BDANETWORKTYPE_ATSC) -#define STATIC_BDANETWORKTYPE_ATSC 0x71985F51, 0x1CA1, 0x11D3, 0x9C, 0xC8, 0x0, 0xC0, 0x4F, 0x79, 0x71, 0xE0 -DEFINE_GUIDSTRUCT("71985F51-1CA1-11D3-9CC8-00C04F7971E0", BDANETWORKTYPE_ATSC); -#endif diff --git a/reactos/include/ddk/mce.h b/reactos/include/ddk/mce.h new file mode 100644 index 00000000000..e2d8407da10 --- /dev/null +++ b/reactos/include/ddk/mce.h @@ -0,0 +1,1074 @@ +#pragma once + +#if defined(_X86_) || defined(_IA64_) || defined(_AMD64_) + +typedef union _MCI_ADDR { + struct { + ULONG Address; + ULONG Reserved; + } DUMMYSTRUCTNAME; + ULONGLONG QuadPart; +} MCI_ADDR, *PMCI_ADDR; + +typedef enum { + HAL_MCE_RECORD, + HAL_MCA_RECORD +} MCA_EXCEPTION_TYPE; + +#if defined(_AMD64_) + +#if (NTDDI_VERSION <= NTDDI_WINXP) + +typedef union _MCI_STATS { + struct { + USHORT McaCod; + USHORT ModelErrorCode; + ULONG OtherInfo:25; + ULONG Damage:1; + ULONG AddressValid:1; + ULONG MiscValid:1; + ULONG Enabled:1; + ULONG Uncorrected:1; + ULONG OverFlow:1; + ULONG Valid:1; + } MciStatus; + ULONG64 QuadPart; +} MCI_STATS, *PMCI_STATS; + +#else + +typedef union _MCI_STATS { + struct { + USHORT McaErrorCode; + USHORT ModelErrorCode; + ULONG OtherInformation:25; + ULONG ContextCorrupt:1; + ULONG AddressValid:1; + ULONG MiscValid:1; + ULONG ErrorEnabled:1; + ULONG UncorrectedError:1; + ULONG StatusOverFlow:1; + ULONG Valid:1; + } MciStatus; + ULONG64 QuadPart; +} MCI_STATS, *PMCI_STATS; + +#endif /* (NTDDI_VERSION <= NTDDI_WINXP) */ + +#endif /* defined(_AMD64_) */ + +#if defined(_X86_) +typedef union _MCI_STATS { + struct { + USHORT McaCod; + USHORT MsCod; + ULONG OtherInfo:25; + ULONG Damage:1; + ULONG AddressValid:1; + ULONG MiscValid:1; + ULONG Enabled:1; + ULONG UnCorrected:1; + ULONG OverFlow:1; + ULONG Valid:1; + } MciStats; + ULONGLONG QuadPart; +} MCI_STATS, *PMCI_STATS; +#endif + +#define MCA_EXTREG_V2MAX 24 + +#if defined(_X86_) || defined(_AMD64_) + +#if (NTDDI_VERSION >= NTDDI_WINXP) + +typedef struct _MCA_EXCEPTION { + ULONG VersionNumber; + MCA_EXCEPTION_TYPE ExceptionType; + LARGE_INTEGER TimeStamp; + ULONG ProcessorNumber; + ULONG Reserved1; + union { + struct { + UCHAR BankNumber; + UCHAR Reserved2[7]; + MCI_STATS Status; + MCI_ADDR Address; + ULONGLONG Misc; + } Mca; + struct { + ULONGLONG Address; + ULONGLONG Type; + } Mce; + } u; + ULONG ExtCnt; + ULONG Reserved3; + ULONGLONG ExtReg[MCA_EXTREG_V2MAX]; +} MCA_EXCEPTION, *PMCA_EXCEPTION; + +#else + +typedef struct _MCA_EXCEPTION { + ULONG VersionNumber; + MCA_EXCEPTION_TYPE ExceptionType; + LARGE_INTEGER TimeStamp; + ULONG ProcessorNumber; + ULONG Reserved1; + union { + struct { + UCHAR BankNumber; + UCHAR Reserved2[7]; + MCI_STATS Status; + MCI_ADDR Address; + ULONGLONG Misc; + } Mca; + struct { + ULONGLONG Address; + ULONGLONG Type; + } Mce; + } u; +} MCA_EXCEPTION, *PMCA_EXCEPTION; + +#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ + +typedef MCA_EXCEPTION CMC_EXCEPTION, *PCMC_EXCEPTION; +typedef MCA_EXCEPTION CPE_EXCEPTION, *PCPE_EXCEPTION; + +#if (NTDDI_VERSION >= NTDDI_WINXP) +#define MCA_EXCEPTION_V1_SIZE FIELD_OFFSET(MCA_EXCEPTION, ExtCnt) +#define MCA_EXCEPTION_V2_SIZE sizeof(struct _MCA_EXCEPTION) +#endif + +#endif /* defined(_X86_) || defined(_AMD64_) */ + +#if defined(_AMD64_) || defined(_IA64_) + +typedef UCHAR ERROR_SEVERITY, *PERROR_SEVERITY; + +typedef enum _ERROR_SEVERITY_VALUE { + ErrorRecoverable = 0, + ErrorFatal = 1, + ErrorCorrected = 2, + ErrorOthers = 3, +} ERROR_SEVERITY_VALUE; + +#endif + +#if defined(_IA64_) + +typedef union _ERROR_REVISION { + USHORT Revision; + struct { + UCHAR Minor; + UCHAR Major; + } DUMMYSTRUCTNAME; +} ERROR_REVISION, *PERROR_REVISION; + +#if (NTDDI_VERSION > NTDDI_WINXP) +#define ERROR_MAJOR_REVISION_SAL_03_00 0 +#define ERROR_MINOR_REVISION_SAL_03_00 2 +#define ERROR_REVISION_SAL_03_00 {ERROR_MINOR_REVISION_SAL_03_00,ERROR_MAJOR_REVISION_SAL_03_00} +#define ERROR_FIXED_SECTION_REVISION {2,0} +#else +#define ERROR_REVISION_SAL_03_00 {2,0} +#endif /* (NTDDI_VERSION > NTDDI_WINXP) */ + +typedef union _ERROR_TIMESTAMP { + ULONGLONG TimeStamp; + struct { + UCHAR Seconds; + UCHAR Minutes; + UCHAR Hours; + UCHAR Reserved; + UCHAR Day; + UCHAR Month; + UCHAR Year; + UCHAR Century; + } DUMMYSTRUCTNAME; +} ERROR_TIMESTAMP, *PERROR_TIMESTAMP; + +typedef struct _ERROR_GUID { + ULONG Data1; + USHORT Data2; + USHORT Data3; + UCHAR Data4[8]; +} ERROR_GUID, *PERROR_GUID; + +typedef ERROR_GUID _ERROR_DEVICE_GUID; +typedef _ERROR_DEVICE_GUID ERROR_DEVICE_GUID, *PERROR_DEVICE_GUID; + +typedef ERROR_GUID _ERROR_PLATFORM_GUID; +typedef _ERROR_PLATFORM_GUID ERROR_PLATFORM_GUID, *PERROR_PLATFORM_GUID; + +typedef union _ERROR_RECORD_VALID { + UCHAR Valid; + struct { + UCHAR OemPlatformID:1; + UCHAR Reserved:7; + } DUMMYSTRUCTNAME; +} ERROR_RECORD_VALID, *PERROR_RECORD_VALID; + +typedef struct _ERROR_RECORD_HEADER { + ULONGLONG Id; + ERROR_REVISION Revision; + ERROR_SEVERITY ErrorSeverity; + ERROR_RECORD_VALID Valid; + ULONG Length; + ERROR_TIMESTAMP TimeStamp; + UCHAR OemPlatformId[16]; +} ERROR_RECORD_HEADER, *PERROR_RECORD_HEADER; + +typedef union _ERROR_RECOVERY_INFO { + UCHAR RecoveryInfo; + struct { + UCHAR Corrected:1; + UCHAR NotContained:1; + UCHAR Reset:1; + UCHAR Reserved:4; + UCHAR Valid:1; + } DUMMYSTRUCTNAME; +} ERROR_RECOVERY_INFO, *PERROR_RECOVERY_INFO; + +typedef struct _ERROR_SECTION_HEADER { + ERROR_DEVICE_GUID Guid; + ERROR_REVISION Revision; + ERROR_RECOVERY_INFO RecoveryInfo; + UCHAR Reserved; + ULONG Length; +} ERROR_SECTION_HEADER, *PERROR_SECTION_HEADER; + +#if !defined(__midl) && defined(_MSC_EXTENSIONS) +__inline +USHORT +NTAPI +GetFwMceLogProcessorNumber( + PERROR_RECORD_HEADER Log) +{ + PERROR_SECTION_HEADER section = (PERROR_SECTION_HEADER)((ULONG64)Log + sizeof(*Log)); + USHORT lid = (USHORT)((UCHAR)(section->Reserved)); + lid |= (USHORT)((UCHAR)(Log->TimeStamp.Reserved) << 8); + return( lid ); +} +#endif + +#define ERROR_PROCESSOR_GUID {0xe429faf1, 0x3cb7, 0x11d4, {0xbc, 0xa7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81}} + +typedef union _ERROR_MODINFO_VALID { + ULONGLONG Valid; + struct { + ULONGLONG CheckInfo:1; + ULONGLONG RequestorIdentifier:1; + ULONGLONG ResponderIdentifier:1; + ULONGLONG TargetIdentifier:1; + ULONGLONG PreciseIP:1; + ULONGLONG Reserved:59; + } DUMMYSTRUCTNAME; +} ERROR_MODINFO_VALID, *PERROR_MODINFO_VALID; + +typedef enum _ERROR_CHECK_IS { + isIA64 = 0, + isIA32 = 1, +} ERROR_CHECK_IS; + +typedef enum _ERROR_CACHE_CHECK_OPERATION { + CacheUnknownOp = 0, + CacheLoad = 1, + CacheStore = 2, + CacheInstructionFetch = 3, + CacheDataPrefetch = 4, + CacheSnoop = 5, + CacheCastOut = 6, + CacheMoveIn = 7, +} ERROR_CACHE_CHECK_OPERATION; + +typedef enum _ERROR_CACHE_CHECK_MESI { + CacheInvalid = 0, + CacheHeldShared = 1, + CacheHeldExclusive = 2, + CacheModified = 3, +} ERROR_CACHE_CHECK_MESI; + +#if (NTDDI_VERSION >= NTDDI_VISTA) + +typedef union _ERROR_CACHE_CHECK { + ULONGLONG CacheCheck; + struct { + ULONGLONG Operation:4; + ULONGLONG Level:2; + ULONGLONG Reserved1:2; + ULONGLONG DataLine:1; + ULONGLONG TagLine:1; + ULONGLONG DataCache:1; + ULONGLONG InstructionCache:1; + ULONGLONG MESI:3; + ULONGLONG MESIValid:1; + ULONGLONG Way:5; + ULONGLONG WayIndexValid:1; + ULONGLONG Reserved2:1; + ULONGLONG DP:1; + ULONGLONG Reserved3:8; + ULONGLONG Index:20; + ULONGLONG Reserved4:2; + ULONGLONG InstructionSet:1; + ULONGLONG InstructionSetValid:1; + ULONGLONG PrivilegeLevel:2; + ULONGLONG PrivilegeLevelValid:1; + ULONGLONG MachineCheckCorrected:1; + ULONGLONG TargetAddressValid:1; + ULONGLONG RequestIdValid:1; + ULONGLONG ResponderIdValid:1; + ULONGLONG PreciseIPValid:1; + } DUMMYSTRUCTNAME; +} ERROR_CACHE_CHECK, *PERROR_CACHE_CHECK; + +# else + +typedef union _ERROR_CACHE_CHECK { + ULONGLONG CacheCheck; + struct { + ULONGLONG Operation:4; + ULONGLONG Level:2; + ULONGLONG Reserved1:2; + ULONGLONG DataLine:1; + ULONGLONG TagLine:1; + ULONGLONG DataCache:1; + ULONGLONG InstructionCache:1; + ULONGLONG MESI:3; + ULONGLONG MESIValid:1; + ULONGLONG Way:5; + ULONGLONG WayIndexValid:1; + ULONGLONG Reserved2:10; + ULONGLONG Index:20; + ULONGLONG Reserved3:2; + ULONGLONG InstructionSet:1; + ULONGLONG InstructionSetValid:1; + ULONGLONG PrivilegeLevel:2; + ULONGLONG PrivilegeLevelValid:1; + ULONGLONG MachineCheckCorrected:1; + ULONGLONG TargetAddressValid:1; + ULONGLONG RequestIdValid:1; + ULONGLONG ResponderIdValid:1; + ULONGLONG PreciseIPValid:1; + } DUMMYSTRUCTNAME; +} ERROR_CACHE_CHECK, *PERROR_CACHE_CHECK; + +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + +typedef enum _ERROR_TLB_CHECK_OPERATION { + TlbUnknownOp = 0, + TlbAccessWithLoad = 1, + TlbAccessWithStore = 2, + TlbAccessWithInstructionFetch = 3, + TlbAccessWithDataPrefetch = 4, + TlbShootDown = 5, + TlbProbe = 6, + TlbVhptFill = 7, + TlbPurge = 8, +} ERROR_TLB_CHECK_OPERATION; + +typedef union _ERROR_TLB_CHECK { + ULONGLONG TlbCheck; + struct { + ULONGLONG TRSlot:8; + ULONGLONG TRSlotValid:1; + ULONGLONG Reserved1:1; + ULONGLONG Level:2; + ULONGLONG Reserved2:4; + ULONGLONG DataTransReg:1; + ULONGLONG InstructionTransReg:1; + ULONGLONG DataTransCache:1; + ULONGLONG InstructionTransCache:1; + ULONGLONG Operation:4; + ULONGLONG Reserved3:30; + ULONGLONG InstructionSet:1; + ULONGLONG InstructionSetValid:1; + ULONGLONG PrivilegeLevel:2; + ULONGLONG PrivilegeLevelValid:1; + ULONGLONG MachineCheckCorrected:1; + ULONGLONG TargetAddressValid:1; + ULONGLONG RequestIdValid:1; + ULONGLONG ResponderIdValid:1; + ULONGLONG PreciseIPValid:1; + } DUMMYSTRUCTNAME; +} ERROR_TLB_CHECK, *PERROR_TLB_CHECK; + +typedef enum _ERROR_BUS_CHECK_OPERATION { + BusUnknownOp = 0, + BusPartialRead = 1, + BusPartialWrite = 2, + BusFullLineRead = 3, + BusFullLineWrite = 4, + BusWriteBack = 5, + BusSnoopProbe = 6, + BusIncomingPtcG = 7, + BusWriteCoalescing = 8, +} ERROR_BUS_CHECK_OPERATION; + +#if (NTDDI_VERSION >= NTDDI_VISTA) + +typedef union _ERROR_BUS_CHECK { + ULONGLONG BusCheck; + struct { + ULONGLONG Size:5; + ULONGLONG Internal:1; + ULONGLONG External:1; + ULONGLONG CacheTransfer:1; + ULONGLONG Type:8; + ULONGLONG Severity:5; + ULONGLONG Hierarchy:2; + ULONGLONG DP:1; + ULONGLONG Status:8; + ULONGLONG Reserved1:22; + ULONGLONG InstructionSet:1; + ULONGLONG InstructionSetValid:1; + ULONGLONG PrivilegeLevel:2; + ULONGLONG PrivilegeLevelValid:1; + ULONGLONG MachineCheckCorrected:1; + ULONGLONG TargetAddressValid:1; + ULONGLONG RequestIdValid:1; + ULONGLONG ResponderIdValid:1; + ULONGLONG PreciseIPValid:1; + } DUMMYSTRUCTNAME; +} ERROR_BUS_CHECK, *PERROR_BUS_CHECK; + +#else + +typedef union _ERROR_BUS_CHECK { + ULONGLONG BusCheck; + struct { + ULONGLONG Size:5; + ULONGLONG Internal:1; + ULONGLONG External:1; + ULONGLONG CacheTransfer:1; + ULONGLONG Type:8; + ULONGLONG Severity:5; + ULONGLONG Hierarchy:2; + ULONGLONG Reserved1:1; + ULONGLONG Status:8; + ULONGLONG Reserved2:22; + ULONGLONG InstructionSet:1; + ULONGLONG InstructionSetValid:1; + ULONGLONG PrivilegeLevel:2; + ULONGLONG PrivilegeLevelValid:1; + ULONGLONG MachineCheckCorrected:1; + ULONGLONG TargetAddressValid:1; + ULONGLONG RequestIdValid:1; + ULONGLONG ResponderIdValid:1; + ULONGLONG PreciseIPValid:1; + } DUMMYSTRUCTNAME; +} ERROR_BUS_CHECK, *PERROR_BUS_CHECK; + +#endif + +typedef enum _ERROR_REGFILE_CHECK_IDENTIFIER { + RegFileUnknownId = 0, + GeneralRegisterBank1 = 1, + GeneralRegisterBank0 = 2, + FloatingPointRegister = 3, + BranchRegister = 4, + PredicateRegister = 5, + ApplicationRegister = 6, + ControlRegister = 7, + RegionRegister = 8, + ProtectionKeyRegister = 9, + DataBreakPointRegister = 10, + InstructionBreakPointRegister = 11, + PerformanceMonitorControlRegister = 12, + PerformanceMonitorDataRegister = 13, +} ERROR_REGFILE_CHECK_IDENTIFIER; + +typedef enum _ERROR_REGFILE_CHECK_OPERATION { + RegFileUnknownOp = 0, + RegFileRead = 1, + RegFileWrite = 2, +} ERROR_REGFILE_CHECK_OPERATION; + +typedef union _ERROR_REGFILE_CHECK { + ULONGLONG RegFileCheck; + struct { + ULONGLONG Identifier:4; + ULONGLONG Operation:4; + ULONGLONG RegisterNumber:7; + ULONGLONG RegisterNumberValid:1; + ULONGLONG Reserved1:38; + ULONGLONG InstructionSet:1; + ULONGLONG InstructionSetValid:1; + ULONGLONG PrivilegeLevel:2; + ULONGLONG PrivilegeLevelValid:1; + ULONGLONG MachineCheckCorrected:1; + ULONGLONG Reserved2:3; + ULONGLONG PreciseIPValid:1; + } DUMMYSTRUCTNAME; +} ERROR_REGFILE_CHECK, *PERROR_REGFILE_CHECK; + +#if (NTDDK_VERSION <= WINXP) +typedef enum _ERROR_MS_CHECK_OPERATION { + MsUnknownOp = 0, + MsReadOrLoad = 1, + MsWriteOrStore = 2 +} ERROR_MS_CHECK_OPERATION; +#else +typedef enum _ERROR_MS_CHECK_OPERATION { + MsUnknownOp = 0, + MsReadOrLoad = 1, + MsWriteOrStore = 2, + MsOverTemperature = 3, + MsNormalTemperature = 4 +} ERROR_MS_CHECK_OPERATION; +#endif + +typedef union _ERROR_MS_CHECK { + ULONGLONG MsCheck; + struct { + ULONGLONG StructureIdentifier:5; + ULONGLONG Level:3; + ULONGLONG ArrayId:4; + ULONGLONG Operation:4; + ULONGLONG Way:6; + ULONGLONG WayValid:1; + ULONGLONG IndexValid:1; + ULONGLONG Reserved1:8; + ULONGLONG Index:8; + ULONGLONG Reserved2:14; + ULONGLONG InstructionSet:1; + ULONGLONG InstructionSetValid:1; + ULONGLONG PrivilegeLevel:2; + ULONGLONG PrivilegeLevelValid:1; + ULONGLONG MachineCheckCorrected:1; + ULONGLONG TargetAddressValid:1; + ULONGLONG RequestIdValid:1; + ULONGLONG ResponderIdValid:1; + ULONGLONG PreciseIPValid:1; + } DUMMYSTRUCTNAME; +} ERROR_MS_CHECK, *PERROR_MS_CHECK; + +typedef union _ERROR_CHECK_INFO { + ULONGLONG CheckInfo; + ERROR_CACHE_CHECK CacheCheck; + ERROR_TLB_CHECK TlbCheck; + ERROR_BUS_CHECK BusCheck; + ERROR_REGFILE_CHECK RegFileCheck; + ERROR_MS_CHECK MsCheck; +} ERROR_CHECK_INFO, *PERROR_CHECK_INFO; + +typedef struct _ERROR_MODINFO { + ERROR_MODINFO_VALID Valid; + ERROR_CHECK_INFO CheckInfo; + ULONGLONG RequestorId; + ULONGLONG ResponderId; + ULONGLONG TargetId; + ULONGLONG PreciseIP; +} ERROR_MODINFO, *PERROR_MODINFO; + +typedef union _ERROR_PROCESSOR_VALID { + ULONGLONG Valid; + struct { + ULONGLONG ErrorMap:1; + ULONGLONG StateParameter:1; + ULONGLONG CRLid:1; + ULONGLONG StaticStruct:1; + ULONGLONG CacheCheckNum:4; + ULONGLONG TlbCheckNum:4; + ULONGLONG BusCheckNum:4; + ULONGLONG RegFileCheckNum:4; + ULONGLONG MsCheckNum:4; + ULONGLONG CpuIdInfo:1; + ULONGLONG Reserved:39; + } DUMMYSTRUCTNAME; +} ERROR_PROCESSOR_VALID, *PERROR_PROCESSOR_VALID; + +typedef union _ERROR_PROCESSOR_ERROR_MAP { + ULONGLONG ErrorMap; + struct { + ULONGLONG Cid:4; + ULONGLONG Tid:4; + ULONGLONG Eic:4; + ULONGLONG Edc:4; + ULONGLONG Eit:4; + ULONGLONG Edt:4; + ULONGLONG Ebh:4; + ULONGLONG Erf:4; + ULONGLONG Ems:16; + ULONGLONG Reserved:16; + } DUMMYSTRUCTNAME; +} ERROR_PROCESSOR_ERROR_MAP, *PERROR_PROCESSOR_ERROR_MAP; + +typedef ERROR_PROCESSOR_ERROR_MAP _ERROR_PROCESSOR_LEVEL_INDEX; +typedef _ERROR_PROCESSOR_LEVEL_INDEX ERROR_PROCESSOR_LEVEL_INDEX, *PERROR_PROCESSOR_LEVEL_INDEX; + +typedef union _ERROR_PROCESSOR_STATE_PARAMETER { + ULONGLONG StateParameter; + struct { + ULONGLONG reserved0:2; + ULONGLONG rz:1; + ULONGLONG ra:1; + ULONGLONG me:1; + ULONGLONG mn:1; + ULONGLONG sy:1; + ULONGLONG co:1; + ULONGLONG ci:1; + ULONGLONG us:1; + ULONGLONG hd:1; + ULONGLONG tl:1; + ULONGLONG mi:1; + ULONGLONG pi:1; + ULONGLONG pm:1; + ULONGLONG dy:1; + ULONGLONG in:1; + ULONGLONG rs:1; + ULONGLONG cm:1; + ULONGLONG ex:1; + ULONGLONG cr:1; + ULONGLONG pc:1; + ULONGLONG dr:1; + ULONGLONG tr:1; + ULONGLONG rr:1; + ULONGLONG ar:1; + ULONGLONG br:1; + ULONGLONG pr:1; + ULONGLONG fp:1; + ULONGLONG b1:1; + ULONGLONG b0:1; + ULONGLONG gr:1; + ULONGLONG dsize:16; + ULONGLONG reserved1:11; + ULONGLONG cc:1; + ULONGLONG tc:1; + ULONGLONG bc:1; + ULONGLONG rc:1; + ULONGLONG uc:1; + } DUMMYSTRUCTNAME; +} ERROR_PROCESSOR_STATE_PARAMETER, *PERROR_PROCESSOR_STATE_PARAMETER; + +typedef union _PROCESSOR_LOCAL_ID { + ULONGLONG LocalId; + struct { + ULONGLONG reserved:16; + ULONGLONG eid:8; + ULONGLONG id:8; + ULONGLONG ignored:32; + } DUMMYSTRUCTNAME; +} PROCESSOR_LOCAL_ID, *PPROCESSOR_LOCAL_ID; + +typedef struct _ERROR_PROCESSOR_MS { + ULONGLONG MsError[1]; +} ERROR_PROCESSOR_MS, *PERROR_PROCESSOR_MS; + +typedef struct _ERROR_PROCESSOR_CPUID_INFO { + ULONGLONG CpuId0; + ULONGLONG CpuId1; + ULONGLONG CpuId2; + ULONGLONG CpuId3; + ULONGLONG CpuId4; + ULONGLONG Reserved; +} ERROR_PROCESSOR_CPUID_INFO, *PERROR_PROCESSOR_CPUID_INFO; + +typedef union _ERROR_PROCESSOR_STATIC_INFO_VALID { + ULONGLONG Valid; + struct { + ULONGLONG MinState:1; + ULONGLONG BR:1; + ULONGLONG CR:1; + ULONGLONG AR:1; + ULONGLONG RR:1; + ULONGLONG FR:1; + ULONGLONG Reserved:58; + } DUMMYSTRUCTNAME; +} ERROR_PROCESSOR_STATIC_INFO_VALID, *PERROR_PROCESSOR_STATIC_INFO_VALID; + +typedef struct _ERROR_PROCESSOR_STATIC_INFO { + ERROR_PROCESSOR_STATIC_INFO_VALID Valid; + UCHAR MinState[1024]; + ULONGLONG BR[8]; + ULONGLONG CR[128]; + ULONGLONG AR[128]; + ULONGLONG RR[8]; + ULONGLONG FR[2 * 128]; +} ERROR_PROCESSOR_STATIC_INFO, *PERROR_PROCESSOR_STATIC_INFO; + +typedef struct _ERROR_PROCESSOR { + ERROR_SECTION_HEADER Header; + ERROR_PROCESSOR_VALID Valid; + ERROR_PROCESSOR_ERROR_MAP ErrorMap; + ERROR_PROCESSOR_STATE_PARAMETER StateParameter; + PROCESSOR_LOCAL_ID CRLid; +} ERROR_PROCESSOR, *PERROR_PROCESSOR; + +#define ERROR_PROCESSOR_STATE_PARAMETER_CACHE_CHECK_SHIFT 59 +#define ERROR_PROCESSOR_STATE_PARAMETER_CACHE_CHECK_MASK 0x1 +#define ERROR_PROCESSOR_STATE_PARAMETER_TLB_CHECK_SHIFT 60 +#define ERROR_PROCESSOR_STATE_PARAMETER_TLB_CHECK_MASK 0x1 +#define ERROR_PROCESSOR_STATE_PARAMETER_BUS_CHECK_SHIFT 61 +#define ERROR_PROCESSOR_STATE_PARAMETER_BUS_CHECK_MASK 0x1 +#define ERROR_PROCESSOR_STATE_PARAMETER_REG_CHECK_SHIFT 62 +#define ERROR_PROCESSOR_STATE_PARAMETER_REG_CHECK_MASK 0x1 +#define ERROR_PROCESSOR_STATE_PARAMETER_MICROARCH_CHECK_SHIFT 63 +#define ERROR_PROCESSOR_STATE_PARAMETER_MICROARCH_CHECK_MASK 0x1 + +#define ERROR_PROCESSOR_STATE_PARAMETER_UNKNOWN_CHECK_SHIFT ERROR_PROCESSOR_STATE_PARAMETER_MICROARCH_CHECK_SHIFT +#define ERROR_PROCESSOR_STATE_PARAMETER_UNKNOWN_CHECK_MASK ERROR_PROCESSOR_STATE_PARAMETER_MICROARCH_CHECK_MASK + +typedef enum _ERR_TYPES { + ERR_INTERNAL = 1, + ERR_BUS = 16, + ERR_MEM = 4, + ERR_TLB = 5, + ERR_CACHE = 6, + ERR_FUNCTION = 7, + ERR_SELFTEST = 8, + ERR_FLOW = 9, + ERR_MAP = 17, + ERR_IMPROPER = 18, + ERR_UNIMPL = 19, + ERR_LOL = 20, + ERR_RESPONSE = 21, + ERR_PARITY = 22, + ERR_PROTOCOL = 23, + ERR_ERROR = 24, + ERR_TIMEOUT = 25, + ERR_POISONED = 26, +} _ERR_TYPE; + +typedef union _ERROR_STATUS { + ULONGLONG Status; + struct { + ULONGLONG Reserved0:8; + ULONGLONG Type:8; + ULONGLONG Address:1; + ULONGLONG Control:1; + ULONGLONG Data:1; + ULONGLONG Responder:1; + ULONGLONG Requestor:1; + ULONGLONG FirstError:1; + ULONGLONG Overflow:1; + ULONGLONG Reserved1:41; + } DUMMYSTRUCTNAME; +} ERROR_STATUS, *PERROR_STATUS; + +typedef struct _ERROR_OEM_DATA { + USHORT Length; +} ERROR_OEM_DATA, *PERROR_OEM_DATA; + +typedef union _ERROR_BUS_SPECIFIC_DATA { + ULONGLONG BusSpecificData; + struct { + ULONGLONG LockAsserted:1; + ULONGLONG DeferLogged:1; + ULONGLONG IOQEmpty:1; + ULONGLONG DeferredTransaction:1; + ULONGLONG RetriedTransaction:1; + ULONGLONG MemoryClaimedTransaction:1; + ULONGLONG IOClaimedTransaction:1; + ULONGLONG ResponseParitySignal:1; + ULONGLONG DeferSignal:1; + ULONGLONG HitMSignal:1; + ULONGLONG HitSignal:1; + ULONGLONG RequestBusFirstCycle:6; + ULONGLONG RequestBusSecondCycle:6; + ULONGLONG AddressParityBusFirstCycle:2; + ULONGLONG AddressParityBusSecondCycle:2; + ULONGLONG ResponseBus:3; + ULONGLONG RequestParitySignalFirstCycle:1; + ULONGLONG RequestParitySignalSecondCycle:1; + ULONGLONG Reserved:32; + } DUMMYSTRUCTNAME; +} ERROR_BUS_SPECIFIC_DATA, *PERROR_BUS_SPECIFIC_DATA; + +#define ERROR_MEMORY_GUID {0xe429faf2, 0x3cb7, 0x11d4, {0xbc, 0xa7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81}} + +typedef union _ERROR_MEMORY_VALID { + ULONGLONG Valid; + struct { + ULONGLONG ErrorStatus:1; + ULONGLONG PhysicalAddress:1; + ULONGLONG AddressMask:1; + ULONGLONG Node:1; + ULONGLONG Card:1; + ULONGLONG Module:1; + ULONGLONG Bank:1; + ULONGLONG Device:1; + ULONGLONG Row:1; + ULONGLONG Column:1; + ULONGLONG BitPosition:1; + ULONGLONG RequestorId:1; + ULONGLONG ResponderId:1; + ULONGLONG TargetId:1; + ULONGLONG BusSpecificData:1; + ULONGLONG OemId:1; + ULONGLONG OemData:1; + ULONGLONG Reserved:47; + } DUMMYSTRUCTNAME; +} ERROR_MEMORY_VALID, *PERROR_MEMORY_VALID; + +typedef struct _ERROR_MEMORY { + ERROR_SECTION_HEADER Header; + ERROR_MEMORY_VALID Valid; + ERROR_STATUS ErrorStatus; + ULONGLONG PhysicalAddress; + ULONGLONG PhysicalAddressMask; + USHORT Node; + USHORT Card; + USHORT Module; + USHORT Bank; + USHORT Device; + USHORT Row; + USHORT Column; + USHORT BitPosition; + ULONGLONG RequestorId; + ULONGLONG ResponderId; + ULONGLONG TargetId; + ULONGLONG BusSpecificData; + UCHAR OemId[16]; + ERROR_OEM_DATA OemData; +} ERROR_MEMORY, *PERROR_MEMORY; + +#define ERROR_PCI_BUS_GUID {0xe429faf4, 0x3cb7, 0x11d4, {0xbc, 0xa7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81}} + +typedef union _ERROR_PCI_BUS_VALID { + ULONGLONG Valid; + struct { + ULONGLONG ErrorStatus:1; + ULONGLONG ErrorType:1; + ULONGLONG Id:1; + ULONGLONG Address:1; + ULONGLONG Data:1; + ULONGLONG CmdType:1; + ULONGLONG RequestorId:1; + ULONGLONG ResponderId:1; + ULONGLONG TargetId:1; + ULONGLONG OemId:1; + ULONGLONG OemData:1; + ULONGLONG Reserved:53; + } DUMMYSTRUCTNAME; +} ERROR_PCI_BUS_VALID, *PERROR_PCI_BUS_VALID; + +typedef struct _ERROR_PCI_BUS_TYPE { + UCHAR Type; + UCHAR Reserved; +} ERROR_PCI_BUS_TYPE, *PERROR_PCI_BUS_TYPE; + +#define PciBusUnknownError ((UCHAR)0) +#define PciBusDataParityError ((UCHAR)1) +#define PciBusSystemError ((UCHAR)2) +#define PciBusMasterAbort ((UCHAR)3) +#define PciBusTimeOut ((UCHAR)4) +#define PciMasterDataParityError ((UCHAR)5) +#define PciAddressParityError ((UCHAR)6) +#define PciCommandParityError ((UCHAR)7) + +typedef struct _ERROR_PCI_BUS_ID { + UCHAR BusNumber; + UCHAR SegmentNumber; +} ERROR_PCI_BUS_ID, *PERROR_PCI_BUS_ID; + +typedef struct _ERROR_PCI_BUS { + ERROR_SECTION_HEADER Header; + ERROR_PCI_BUS_VALID Valid; + ERROR_STATUS ErrorStatus; + ERROR_PCI_BUS_TYPE Type; + ERROR_PCI_BUS_ID Id; + UCHAR Reserved[4]; + ULONGLONG Address; + ULONGLONG Data; + ULONGLONG CmdType; + ULONGLONG RequestorId; + ULONGLONG ResponderId; + ULONGLONG TargetId; + UCHAR OemId[16]; + ERROR_OEM_DATA OemData; +} ERROR_PCI_BUS, *PERROR_PCI_BUS; + +#define ERROR_PCI_COMPONENT_GUID {0xe429faf6, 0x3cb7, 0x11d4, {0xbc, 0xa7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81}} + +typedef union _ERROR_PCI_COMPONENT_VALID { + ULONGLONG Valid; + struct { + ULONGLONG ErrorStatus:1; + ULONGLONG Info:1; + ULONGLONG MemoryMappedRegistersPairs:1; + ULONGLONG ProgrammedIORegistersPairs:1; + ULONGLONG RegistersDataPairs:1; + ULONGLONG OemData:1; + ULONGLONG Reserved:58; + } DUMMYSTRUCTNAME; +} ERROR_PCI_COMPONENT_VALID, *PERROR_PCI_COMPONENT_VALID; + +typedef struct _ERROR_PCI_COMPONENT_INFO { + USHORT VendorId; + USHORT DeviceId; + UCHAR ClassCodeInterface; + UCHAR ClassCodeSubClass; + UCHAR ClassCodeBaseClass; + UCHAR FunctionNumber; + UCHAR DeviceNumber; + UCHAR BusNumber; + UCHAR SegmentNumber; + UCHAR Reserved0; + ULONG Reserved1; +} ERROR_PCI_COMPONENT_INFO, *PERROR_PCI_COMPONENT_INFO; + +typedef struct _ERROR_PCI_COMPONENT { + ERROR_SECTION_HEADER Header; + ERROR_PCI_COMPONENT_VALID Valid; + ERROR_STATUS ErrorStatus; + ERROR_PCI_COMPONENT_INFO Info; + ULONG MemoryMappedRegistersPairs; + ULONG ProgrammedIORegistersPairs; +} ERROR_PCI_COMPONENT, *PERROR_PCI_COMPONENT; + +#define ERROR_SYSTEM_EVENT_LOG_GUID {0xe429faf3, 0x3cb7, 0x11d4, {0xbc, 0xa7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81}} + +typedef union _ERROR_SYSTEM_EVENT_LOG_VALID { + ULONGLONG Valid; + struct { + ULONGLONG RecordId:1; + ULONGLONG RecordType:1; + ULONGLONG GeneratorId:1; + ULONGLONG EVMRev:1; + ULONGLONG SensorType:1; + ULONGLONG SensorNum:1; + ULONGLONG EventDirType:1; + ULONGLONG EventData1:1; + ULONGLONG EventData2:1; + ULONGLONG EventData3:1; + ULONGLONG Reserved:54; + } DUMMYSTRUCTNAME; +} ERROR_SYSTEM_EVENT_LOG_VALID, *PSYSTEM_EVENT_LOG_VALID; + +typedef struct _ERROR_SYSTEM_EVENT_LOG { + ERROR_SECTION_HEADER Header; + ERROR_SYSTEM_EVENT_LOG_VALID Valid; + USHORT RecordId; + UCHAR RecordType; + ULONG TimeStamp; + USHORT GeneratorId; + UCHAR EVMRevision; + UCHAR SensorType; + UCHAR SensorNumber; + UCHAR EventDir; + UCHAR Data1; + UCHAR Data2; + UCHAR Data3; +} ERROR_SYSTEM_EVENT_LOG, *PERROR_SYSTEM_EVENT_LOG; + +#define ERROR_SMBIOS_GUID {0xe429faf5, 0x3cb7, 0x11d4, {0xbc, 0xa7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81}} + +typedef union _ERROR_SMBIOS_VALID { + ULONGLONG Valid; + struct { + ULONGLONG EventType:1; + ULONGLONG Length:1; + ULONGLONG TimeStamp:1; + ULONGLONG OemData:1; + ULONGLONG Reserved:60; + } DUMMYSTRUCTNAME; +} ERROR_SMBIOS_VALID, *PERROR_SMBIOS_VALID; + +typedef UCHAR ERROR_SMBIOS_EVENT_TYPE, *PERROR_SMBIOS_EVENT_TYPE; + +typedef struct _ERROR_SMBIOS { + ERROR_SECTION_HEADER Header; + ERROR_SMBIOS_VALID Valid; + ERROR_SMBIOS_EVENT_TYPE EventType; + UCHAR Length; + ERROR_TIMESTAMP TimeStamp; + ERROR_OEM_DATA OemData; +} ERROR_SMBIOS, *PERROR_SMBIOS; + +#define ERROR_PLATFORM_SPECIFIC_GUID {0xe429faf7, 0x3cb7, 0x11d4, {0xbc, 0xa7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81}} + +typedef union _ERROR_PLATFORM_SPECIFIC_VALID { + ULONGLONG Valid; + struct { + ULONGLONG ErrorStatus:1; + ULONGLONG RequestorId:1; + ULONGLONG ResponderId:1; + ULONGLONG TargetId:1; + ULONGLONG BusSpecificData:1; + ULONGLONG OemId:1; + ULONGLONG OemData:1; + ULONGLONG OemDevicePath:1; + ULONGLONG Reserved:56; + } DUMMYSTRUCTNAME; +} ERROR_PLATFORM_SPECIFIC_VALID, *PERROR_PLATFORM_SPECIFIC_VALID; + +typedef struct _ERROR_PLATFORM_SPECIFIC { + ERROR_SECTION_HEADER Header; + ERROR_PLATFORM_SPECIFIC_VALID Valid; + ERROR_STATUS ErrorStatus; + ULONGLONG RequestorId; + ULONGLONG ResponderId; + ULONGLONG TargetId; + ERROR_BUS_SPECIFIC_DATA BusSpecificData; + UCHAR OemId[16]; + ERROR_OEM_DATA OemData; +} ERROR_PLATFORM_SPECIFIC, *PERROR_PLATFORM_SPECIFIC; + +#define ERROR_PLATFORM_BUS_GUID {0xe429faf9, 0x3cb7, 0x11d4, {0xbc, 0xa7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81}} + +typedef union _ERROR_PLATFORM_BUS_VALID { + ULONGLONG Valid; + struct { + ULONGLONG ErrorStatus:1; + ULONGLONG RequestorId:1; + ULONGLONG ResponderId:1; + ULONGLONG TargetId:1; + ULONGLONG BusSpecificData:1; + ULONGLONG OemId:1; + ULONGLONG OemData:1; + ULONGLONG OemDevicePath:1; + ULONGLONG Reserved:56; + } DUMMYSTRUCTNAME; +} ERROR_PLATFORM_BUS_VALID, *PERROR_PLATFORM_BUS_VALID; + +typedef struct _ERROR_PLATFORM_BUS { + ERROR_SECTION_HEADER Header; + ERROR_PLATFORM_BUS_VALID Valid; + ERROR_STATUS ErrorStatus; + ULONGLONG RequestorId; + ULONGLONG ResponderId; + ULONGLONG TargetId; + ERROR_BUS_SPECIFIC_DATA BusSpecificData; + UCHAR OemId[16]; + ERROR_OEM_DATA OemData; +} ERROR_PLATFORM_BUS, *PERROR_PLATFORM_BUS; + +#define ERROR_PLATFORM_HOST_CONTROLLER_GUID {0xe429faf8, 0x3cb7, 0x11d4, {0xbc, 0xa7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81}} + +typedef union _ERROR_PLATFORM_HOST_CONTROLLER_VALID { + ULONGLONG Valid; + struct { + ULONGLONG ErrorStatus:1; + ULONGLONG RequestorId:1; + ULONGLONG ResponderId:1; + ULONGLONG TargetId:1; + ULONGLONG BusSpecificData:1; + ULONGLONG OemId:1; + ULONGLONG OemData:1; + ULONGLONG OemDevicePath:1; + ULONGLONG Reserved:56; + } DUMMYSTRUCTNAME; +} ERROR_PLATFORM_HOST_CONTROLLER_VALID, *PERROR_PLATFORM_HOST_CONTROLLER_VALID; + +typedef struct _ERROR_PLATFORM_HOST_CONTROLLER { + ERROR_SECTION_HEADER Header; + ERROR_PCI_COMPONENT_VALID Valid; + ERROR_STATUS ErrorStatus; + ULONGLONG RequestorId; + ULONGLONG ResponderId; + ULONGLONG TargetId; + ERROR_BUS_SPECIFIC_DATA BusSpecificData; + UCHAR OemId[16]; + ERROR_OEM_DATA OemData; +} ERROR_PLATFORM_HOST_CONTROLLER, *PERROR_PLATFORM_HOST_CONTROLLER; + +typedef ERROR_RECORD_HEADER ERROR_LOGRECORD, *PERROR_LOGRECORD; +typedef ERROR_RECORD_HEADER MCA_EXCEPTION, *PMCA_EXCEPTION; +typedef ERROR_RECORD_HEADER CMC_EXCEPTION, *PCMC_EXCEPTION; +typedef ERROR_RECORD_HEADER CPE_EXCEPTION, *PCPE_EXCEPTION; +#if (NTDDI_VERSION > NTDDI_WINXP) +typedef ERROR_RECORD_HEADER INIT_EXCEPTION, *PINIT_EXCEPTION; +#endif + +#endif /* defined(_IA64_) */ + +#endif /* defined(_X86_) || defined(_IA64_) || defined(_AMD64_) */ diff --git a/reactos/include/psdk/atsmedia.h b/reactos/include/psdk/atsmedia.h new file mode 100644 index 00000000000..6f22e570d82 --- /dev/null +++ b/reactos/include/psdk/atsmedia.h @@ -0,0 +1,7 @@ +#pragma once + +#define BDANETWORKTYPE_ATSC DEFINE_GUIDNAMED(BDANETWORKTYPE_ATSC) + +#define STATIC_BDANETWORKTYPE_ATSC 0x71985F51, 0x1CA1, 0x11D3, 0x9C, 0xC8, 0x0, 0xC0, 0x4F, 0x79, 0x71, 0xE0 + +DEFINE_GUIDSTRUCT("71985F51-1CA1-11D3-9CC8-00C04F7971E0", BDANETWORKTYPE_ATSC); diff --git a/reactos/include/psdk/devpropdef.h b/reactos/include/psdk/devpropdef.h new file mode 100644 index 00000000000..49e4c91974a --- /dev/null +++ b/reactos/include/psdk/devpropdef.h @@ -0,0 +1,84 @@ +#ifndef _DEVPROPDEF_H_ +#define _DEVPROPDEF_H_ + +typedef ULONG DEVPROPTYPE, *PDEVPROPTYPE; + +#define DEVPROP_TYPEMOD_ARRAY 0x00001000 +#define DEVPROP_TYPEMOD_LIST 0x00002000 + +#define DEVPROP_TYPE_EMPTY 0x00000000 +#define DEVPROP_TYPE_NULL 0x00000001 +#define DEVPROP_TYPE_SBYTE 0x00000002 +#define DEVPROP_TYPE_BYTE 0x00000003 +#define DEVPROP_TYPE_INT16 0x00000004 +#define DEVPROP_TYPE_UINT16 0x00000005 +#define DEVPROP_TYPE_INT32 0x00000006 +#define DEVPROP_TYPE_UINT32 0x00000007 +#define DEVPROP_TYPE_INT64 0x00000008 +#define DEVPROP_TYPE_UINT64 0x00000009 +#define DEVPROP_TYPE_FLOAT 0x0000000A +#define DEVPROP_TYPE_DOUBLE 0x0000000B +#define DEVPROP_TYPE_DECIMAL 0x0000000C +#define DEVPROP_TYPE_GUID 0x0000000D +#define DEVPROP_TYPE_CURRENCY 0x0000000E +#define DEVPROP_TYPE_DATE 0x0000000F +#define DEVPROP_TYPE_FILETIME 0x00000010 +#define DEVPROP_TYPE_BOOLEAN 0x00000011 +#define DEVPROP_TYPE_STRING 0x00000012 +#define DEVPROP_TYPE_STRING_LIST (DEVPROP_TYPE_STRING|DEVPROP_TYPEMOD_LIST) +#define DEVPROP_TYPE_SECURITY_DESCRIPTOR 0x00000013 +#define DEVPROP_TYPE_SECURITY_DESCRIPTOR_STRING 0x00000014 +#define DEVPROP_TYPE_DEVPROPKEY 0x00000015 +#define DEVPROP_TYPE_DEVPROPTYPE 0x00000016 +#define DEVPROP_TYPE_BINARY (DEVPROP_TYPE_BYTE|DEVPROP_TYPEMOD_ARRAY) +#define DEVPROP_TYPE_ERROR 0x00000017 +#define DEVPROP_TYPE_NTSTATUS 0x00000018 +#define DEVPROP_TYPE_STRING_INDIRECT 0x00000019 + +#define MAX_DEVPROP_TYPE 0x00000019 +#define MAX_DEVPROP_TYPEMOD 0x00002000 + +#define DEVPROP_MASK_TYPE 0x00000FFF +#define DEVPROP_MASK_TYPEMOD 0x0000F000 + +typedef CHAR DEVPROP_BOOLEAN, *PDEVPROP_BOOLEAN; + +#define DEVPROP_TRUE ((DEVPROP_BOOLEAN)-1) +#define DEVPROP_FALSE ((DEVPROP_BOOLEAN) 0) + +#ifndef DEVPROPKEY_DEFINED +#define DEVPROPKEY_DEFINED + +typedef GUID DEVPROPGUID, *PDEVPROPGUID; +typedef ULONG DEVPROPID, *PDEVPROPID; + +typedef struct _DEVPROPKEY { + DEVPROPGUID fmtid; + DEVPROPID pid; +} DEVPROPKEY, *PDEVPROPKEY; + +#endif /* DEVPROPKEY_DEFINED */ + +#define DEVPROPID_FIRST_USABLE 2 + +#endif /* _DEVPROPDEF_H_ */ + +#ifdef DEFINE_DEVPROPKEY +#undef DEFINE_DEVPROPKEY +#endif +#ifdef INITGUID +#define DEFINE_DEVPROPKEY(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8, pid) EXTERN_C const DEVPROPKEY DECLSPEC_SELECTANY name = {{ l, w1, w2, {b1, b2, b3, b4, b5, b6, b7, b8}}, pid} +#else +#define DEFINE_DEVPROPKEY(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8, pid) EXTERN_C const DEVPROPKEY name +#endif /* INITGUID */ + +#ifndef IsEqualDevPropKey + +#ifdef __cplusplus +#define IsEqualDevPropKey(a, b) (((a).pid == (b).pid) && IsEqualIID((a).fmtid, (b).fmtid)) +#else +#define IsEqualDevPropKey(a, b) (((a).pid == (b).pid) && IsEqualIID(&(a).fmtid, &(b).fmtid)) +#endif + +#endif /* !IsEqualDevPropKey */ + diff --git a/reactos/include/psdk/evntprov.h b/reactos/include/psdk/evntprov.h new file mode 100644 index 00000000000..69cc7ce94cf --- /dev/null +++ b/reactos/include/psdk/evntprov.h @@ -0,0 +1,335 @@ +#pragma once + +#ifndef EVNTAPI +#ifndef MIDL_PASS +#ifdef _EVNT_SOURCE_ +#define EVNTAPI __stdcall +#else +#define EVNTAPI DECLSPEC_IMPORT __stdcall +#endif /* _EVNT_SOURCE_ */ +#endif /* MIDL_PASS */ +#endif /* EVNTAPI */ + +#ifdef __cplusplus +extern "C" { +#endif + +#define EVENT_MIN_LEVEL (0) +#define EVENT_MAX_LEVEL (0xff) + +#define EVENT_ACTIVITY_CTRL_GET_ID (1) +#define EVENT_ACTIVITY_CTRL_SET_ID (2) +#define EVENT_ACTIVITY_CTRL_CREATE_ID (3) +#define EVENT_ACTIVITY_CTRL_GET_SET_ID (4) +#define EVENT_ACTIVITY_CTRL_CREATE_SET_ID (5) + +typedef ULONGLONG REGHANDLE, *PREGHANDLE; + +#define MAX_EVENT_DATA_DESCRIPTORS (128) +#define MAX_EVENT_FILTER_DATA_SIZE (1024) + +#define EVENT_FILTER_TYPE_SCHEMATIZED (0x80000000) + +typedef struct _EVENT_DATA_DESCRIPTOR { + ULONGLONG Ptr; + ULONG Size; + ULONG Reserved; +} EVENT_DATA_DESCRIPTOR, *PEVENT_DATA_DESCRIPTOR; + +typedef struct _EVENT_DESCRIPTOR { + USHORT Id; + UCHAR Version; + UCHAR Channel; + UCHAR Level; + UCHAR Opcode; + USHORT Task; + ULONGLONG Keyword; +} EVENT_DESCRIPTOR, *PEVENT_DESCRIPTOR; +typedef const EVENT_DESCRIPTOR *PCEVENT_DESCRIPTOR; + +typedef struct _EVENT_FILTER_DESCRIPTOR { + ULONGLONG Ptr; + ULONG Size; + ULONG Type; +} EVENT_FILTER_DESCRIPTOR, *PEVENT_FILTER_DESCRIPTOR; + +typedef struct _EVENT_FILTER_HEADER { + USHORT Id; + UCHAR Version; + UCHAR Reserved[5]; + ULONGLONG InstanceId; + ULONG Size; + ULONG NextOffset; +} EVENT_FILTER_HEADER, *PEVENT_FILTER_HEADER; + +#ifndef _ETW_KM_ + +typedef VOID +(NTAPI *PENABLECALLBACK)( + IN LPCGUID SourceId, + IN ULONG IsEnabled, + IN UCHAR Level, + IN ULONGLONG MatchAnyKeyword, + IN ULONGLONG MatchAllKeyword, + IN PEVENT_FILTER_DESCRIPTOR FilterData OPTIONAL, + IN OUT PVOID CallbackContext OPTIONAL); + +#if (WINVER >= _WIN32_WINNT_VISTA) +ULONG +EVNTAPI +EventRegister( + IN LPCGUID ProviderId, + IN PENABLECALLBACK EnableCallback OPTIONAL, + IN PVOID CallbackContext OPTIONAL, + OUT PREGHANDLE RegHandle); + +ULONG +EVNTAPI +EventUnregister( + IN REGHANDLE RegHandle); + +BOOLEAN +EVNTAPI +EventEnabled( + IN REGHANDLE RegHandle, + IN PCEVENT_DESCRIPTOR EventDescriptor); + +BOOLEAN +EVNTAPI +EventProviderEnabled( + IN REGHANDLE RegHandle, + IN UCHAR Level, + IN ULONGLONG Keyword); + +ULONG +EVNTAPI +EventWrite( + IN REGHANDLE RegHandle, + IN PCEVENT_DESCRIPTOR EventDescriptor, + IN ULONG UserDataCount, + IN PEVENT_DATA_DESCRIPTOR UserData); + +ULONG +EVNTAPI +EventWriteTransfer( + IN REGHANDLE RegHandle, + IN PCEVENT_DESCRIPTOR EventDescriptor, + IN LPCGUID ActivityId OPTIONAL, + IN LPCGUID RelatedActivityId OPTIONAL, + IN ULONG UserDataCount, + IN PEVENT_DATA_DESCRIPTOR UserData OPTIONAL); + +ULONG +EVNTAPI +EventWriteString( + IN REGHANDLE RegHandle, + IN UCHAR Level, + IN ULONGLONG Keyword, + IN PCWSTR String); + +ULONG +EVNTAPI +EventActivityIdControl( + IN ULONG ControlCode, + IN OUT LPGUID ActivityId); + +#endif /* (WINVER >= _WIN32_WINNT_VISTA) */ + +#if (WINVER >= _WIN32_WINNT_WIN7) +ULONG +EVNTAPI +EventWriteEx( + IN REGHANDLE RegHandle, + IN PCEVENT_DESCRIPTOR EventDescriptor, + IN ULONG64 Filter, + IN ULONG Flags, + IN LPCGUID ActivityId OPTIONAL, + IN LPCGUID RelatedActivityId OPTIONAL, + IN ULONG UserDataCount, + IN PEVENT_DATA_DESCRIPTOR UserData OPTIONAL); +#endif + +#endif // _ETW_KM_ + +FORCEINLINE +VOID +EventDataDescCreate( + OUT PEVENT_DATA_DESCRIPTOR EventDataDescriptor, + IN const VOID* DataPtr, + IN ULONG DataSize) +{ + EventDataDescriptor->Ptr = (ULONGLONG)(ULONG_PTR)DataPtr; + EventDataDescriptor->Size = DataSize; + EventDataDescriptor->Reserved = 0; +} + +FORCEINLINE +VOID +EventDescCreate( + OUT PEVENT_DESCRIPTOR EventDescriptor, + IN USHORT Id, + IN UCHAR Version, + IN UCHAR Channel, + IN UCHAR Level, + IN USHORT Task, + IN UCHAR Opcode, + IN ULONGLONG Keyword) +{ + EventDescriptor->Id = Id; + EventDescriptor->Version = Version; + EventDescriptor->Channel = Channel; + EventDescriptor->Level = Level; + EventDescriptor->Task = Task; + EventDescriptor->Opcode = Opcode; + EventDescriptor->Keyword = Keyword; +} + +FORCEINLINE +VOID +EventDescZero( + OUT PEVENT_DESCRIPTOR EventDescriptor) +{ + memset(EventDescriptor, 0, sizeof(EVENT_DESCRIPTOR)); +} + +FORCEINLINE +USHORT +EventDescGetId( + IN PCEVENT_DESCRIPTOR EventDescriptor) +{ + return (EventDescriptor->Id); +} + +FORCEINLINE +UCHAR +EventDescGetVersion( + IN PCEVENT_DESCRIPTOR EventDescriptor) +{ + return (EventDescriptor->Version); +} + +FORCEINLINE +USHORT +EventDescGetTask( + IN PCEVENT_DESCRIPTOR EventDescriptor) +{ + return (EventDescriptor->Task); +} + +FORCEINLINE +UCHAR +EventDescGetOpcode( + IN PCEVENT_DESCRIPTOR EventDescriptor) +{ + return (EventDescriptor->Opcode); +} + +FORCEINLINE +UCHAR +EventDescGetChannel( + IN PCEVENT_DESCRIPTOR EventDescriptor) +{ + return (EventDescriptor->Channel); +} + +FORCEINLINE +UCHAR +EventDescGetLevel( + IN PCEVENT_DESCRIPTOR EventDescriptor) +{ + return (EventDescriptor->Level); +} + +FORCEINLINE +ULONGLONG +EventDescGetKeyword( + IN PCEVENT_DESCRIPTOR EventDescriptor) +{ + return (EventDescriptor->Keyword); +} + +FORCEINLINE +PEVENT_DESCRIPTOR +EventDescSetId( + IN PEVENT_DESCRIPTOR EventDescriptor, + IN USHORT Id) +{ + EventDescriptor->Id = Id; + return (EventDescriptor); +} + +FORCEINLINE +PEVENT_DESCRIPTOR +EventDescSetVersion( + IN PEVENT_DESCRIPTOR EventDescriptor, + IN UCHAR Version) +{ + EventDescriptor->Version = Version; + return (EventDescriptor); +} + +FORCEINLINE +PEVENT_DESCRIPTOR +EventDescSetTask( + IN PEVENT_DESCRIPTOR EventDescriptor, + IN USHORT Task) +{ + EventDescriptor->Task = Task; + return (EventDescriptor); +} + +FORCEINLINE +PEVENT_DESCRIPTOR +EventDescSetOpcode( + IN PEVENT_DESCRIPTOR EventDescriptor, + IN UCHAR Opcode) +{ + EventDescriptor->Opcode = Opcode; + return (EventDescriptor); +} + +FORCEINLINE +PEVENT_DESCRIPTOR +EventDescSetLevel( + IN PEVENT_DESCRIPTOR EventDescriptor, + IN UCHAR Level) +{ + EventDescriptor->Level = Level; + return (EventDescriptor); +} + +FORCEINLINE +PEVENT_DESCRIPTOR +EventDescSetChannel( + IN PEVENT_DESCRIPTOR EventDescriptor, + IN UCHAR Channel) +{ + EventDescriptor->Channel = Channel; + return (EventDescriptor); +} + +FORCEINLINE +PEVENT_DESCRIPTOR +EventDescSetKeyword( + IN PEVENT_DESCRIPTOR EventDescriptor, + IN ULONGLONG Keyword) +{ + EventDescriptor->Keyword = Keyword; + return (EventDescriptor); +} + + +FORCEINLINE +PEVENT_DESCRIPTOR +EventDescOrKeyword( + IN PEVENT_DESCRIPTOR EventDescriptor, + IN ULONGLONG Keyword) +{ + EventDescriptor->Keyword |= Keyword; + return (EventDescriptor); +} + +#ifdef __cplusplus +} +#endif + diff --git a/reactos/include/psdk/ntiologc.h b/reactos/include/psdk/ntiologc.h new file mode 100644 index 00000000000..b807315bf8b --- /dev/null +++ b/reactos/include/psdk/ntiologc.h @@ -0,0 +1,152 @@ +#pragma once + +#define FACILITY_RPC_RUNTIME 0x2 +#define FACILITY_RPC_STUBS 0x3 +#define FACILITY_IO_ERROR_CODE 0x4 +#define FACILITY_MCA_ERROR_CODE 0x5 + +#define IO_ERR_RETRY_SUCCEEDED ((NTSTATUS)0x00040001L) +#define IO_ERR_INSUFFICIENT_RESOURCES ((NTSTATUS)0xC0040002L) +#define IO_ERR_CONFIGURATION_ERROR ((NTSTATUS)0xC0040003L) +#define IO_ERR_DRIVER_ERROR ((NTSTATUS)0xC0040004L) +#define IO_ERR_PARITY ((NTSTATUS)0xC0040005L) +#define IO_ERR_SEEK_ERROR ((NTSTATUS)0xC0040006L) +#define IO_ERR_BAD_BLOCK ((NTSTATUS)0xC0040007L) +#define IO_ERR_OVERRUN_ERROR ((NTSTATUS)0xC0040008L) +#define IO_ERR_TIMEOUT ((NTSTATUS)0xC0040009L) +#define IO_ERR_SEQUENCE ((NTSTATUS)0xC004000AL) +#define IO_ERR_CONTROLLER_ERROR ((NTSTATUS)0xC004000BL) +#define IO_ERR_INTERNAL_ERROR ((NTSTATUS)0xC004000CL) +#define IO_ERR_INCORRECT_IRQL ((NTSTATUS)0xC004000DL) +#define IO_ERR_INVALID_IOBASE ((NTSTATUS)0xC004000EL) +#define IO_ERR_NOT_READY ((NTSTATUS)0xC004000FL) +#define IO_ERR_INVALID_REQUEST ((NTSTATUS)0xC0040010L) +#define IO_ERR_VERSION ((NTSTATUS)0xC0040011L) +#define IO_ERR_LAYERED_FAILURE ((NTSTATUS)0xC0040012L) +#define IO_ERR_RESET ((NTSTATUS)0xC0040013L) +#define IO_ERR_PROTOCOL ((NTSTATUS)0xC0040014L) +#define IO_ERR_MEMORY_CONFLICT_DETECTED ((NTSTATUS)0xC0040015L) +#define IO_ERR_PORT_CONFLICT_DETECTED ((NTSTATUS)0xC0040016L) +#define IO_ERR_DMA_CONFLICT_DETECTED ((NTSTATUS)0xC0040017L) +#define IO_ERR_IRQ_CONFLICT_DETECTED ((NTSTATUS)0xC0040018L) +#define IO_ERR_BAD_FIRMWARE ((NTSTATUS)0xC0040019L) +#define IO_WRN_BAD_FIRMWARE ((NTSTATUS)0x8004001AL) +#define IO_ERR_DMA_RESOURCE_CONFLICT ((NTSTATUS)0xC004001BL) +#define IO_ERR_INTERRUPT_RESOURCE_CONFLICT ((NTSTATUS)0xC004001CL) +#define IO_ERR_MEMORY_RESOURCE_CONFLICT ((NTSTATUS)0xC004001DL) +#define IO_ERR_PORT_RESOURCE_CONFLICT ((NTSTATUS)0xC004001EL) +#define IO_BAD_BLOCK_WITH_NAME ((NTSTATUS)0xC004001FL) +#define IO_WRITE_CACHE_ENABLED ((NTSTATUS)0x80040020L) +#define IO_RECOVERED_VIA_ECC ((NTSTATUS)0x80040021L) +#define IO_WRITE_CACHE_DISABLED ((NTSTATUS)0x80040022L) +#define IO_FILE_QUOTA_THRESHOLD ((NTSTATUS)0x40040024L) +#define IO_FILE_QUOTA_LIMIT ((NTSTATUS)0x40040025L) +#define IO_FILE_QUOTA_STARTED ((NTSTATUS)0x40040026L) +#define IO_FILE_QUOTA_SUCCEEDED ((NTSTATUS)0x40040027L) +#define IO_FILE_QUOTA_FAILED ((NTSTATUS)0x80040028L) +#define IO_FILE_SYSTEM_CORRUPT ((NTSTATUS)0xC0040029L) +#define IO_FILE_QUOTA_CORRUPT ((NTSTATUS)0xC004002AL) +#define IO_SYSTEM_SLEEP_FAILED ((NTSTATUS)0xC004002BL) +#define IO_DUMP_POINTER_FAILURE ((NTSTATUS)0xC004002CL) +#define IO_DUMP_DRIVER_LOAD_FAILURE ((NTSTATUS)0xC004002DL) +#define IO_DUMP_INITIALIZATION_FAILURE ((NTSTATUS)0xC004002EL) +#define IO_DUMP_DUMPFILE_CONFLICT ((NTSTATUS)0xC004002FL) +#define IO_DUMP_DIRECT_CONFIG_FAILED ((NTSTATUS)0xC0040030L) +#define IO_DUMP_PAGE_CONFIG_FAILED ((NTSTATUS)0xC0040031L) +#define IO_LOST_DELAYED_WRITE ((NTSTATUS)0x80040032L) +#define IO_WARNING_PAGING_FAILURE ((NTSTATUS)0x80040033L) +#define IO_WRN_FAILURE_PREDICTED ((NTSTATUS)0x80040034L) +#define IO_WARNING_INTERRUPT_STILL_PENDING ((NTSTATUS)0x80040035L) +#define IO_DRIVER_CANCEL_TIMEOUT ((NTSTATUS)0x80040036L) +#define IO_FILE_SYSTEM_CORRUPT_WITH_NAME ((NTSTATUS)0xC0040037L) +#define IO_WARNING_ALLOCATION_FAILED ((NTSTATUS)0x80040038L) +#define IO_WARNING_LOG_FLUSH_FAILED ((NTSTATUS)0x80040039L) +#define IO_WARNING_DUPLICATE_SIGNATURE ((NTSTATUS)0x8004003AL) +#define IO_WARNING_DUPLICATE_PATH ((NTSTATUS)0x8004003BL) +#define IO_ERR_THREAD_STUCK_IN_DEVICE_DRIVER ((NTSTATUS)0xC004006CL) +#define IO_ERR_PORT_TIMEOUT ((NTSTATUS)0xC0040075L) +#define IO_WARNING_BUS_RESET ((NTSTATUS)0x80040076L) +#define IO_INFO_THROTTLE_COMPLETE ((NTSTATUS)0x40040077L) +#define IO_WARNING_RESET ((NTSTATUS)0x80040081L) +#define IO_FILE_SYSTEM_REPAIR_SUCCESS ((NTSTATUS)0x80040082L) +#define IO_FILE_SYSTEM_REPAIR_FAILED ((NTSTATUS)0xC0040083L) +#define IO_WARNING_WRITE_FUA_PROBLEM ((NTSTATUS)0x80040084L) +#define IO_CDROM_EXCLUSIVE_LOCK ((NTSTATUS)0x40040085L) +#define IO_FILE_SYSTEM_TXF_RECOVERY_FAILURE ((NTSTATUS)0x80040086L) +#define IO_FILE_SYSTEM_TXF_LOG_FULL_HANDLING_FAILED ((NTSTATUS)0xC0040087L) +#define IO_FILE_SYSTEM_TXF_RESOURCE_MANAGER_RESET ((NTSTATUS)0x80040088L) +#define IO_FILE_SYSTEM_TXF_RESOURCE_MANAGER_START_FAILED ((NTSTATUS)0xC0040089L) +#define IO_FILE_SYSTEM_TXF_RESOURCE_MANAGER_SHUT_DOWN ((NTSTATUS)0xC004008AL) +#define IO_LOST_DELAYED_WRITE_NETWORK_DISCONNECTED ((NTSTATUS)0x8004008BL) +#define IO_LOST_DELAYED_WRITE_NETWORK_SERVER_ERROR ((NTSTATUS)0x8004008CL) +#define IO_LOST_DELAYED_WRITE_NETWORK_LOCAL_DISK_ERROR ((NTSTATUS)0x8004008DL) + +#define MCA_WARNING_CACHE ((NTSTATUS)0x8005003CL) +#define MCA_ERROR_CACHE ((NTSTATUS)0xC005003DL) +#define MCA_WARNING_TLB ((NTSTATUS)0x8005003EL) +#define MCA_ERROR_TLB ((NTSTATUS)0xC005003FL) +#define MCA_WARNING_CPU_BUS ((NTSTATUS)0x80050040L) +#define MCA_ERROR_CPU_BUS ((NTSTATUS)0xC0050041L) +#define MCA_WARNING_REGISTER_FILE ((NTSTATUS)0x80050042L) +#define MCA_ERROR_REGISTER_FILE ((NTSTATUS)0xC0050043L) +#define MCA_WARNING_MAS ((NTSTATUS)0x80050044L) +#define MCA_ERROR_MAS ((NTSTATUS)0xC0050045L) +#define MCA_WARNING_MEM_UNKNOWN ((NTSTATUS)0x80050046L) +#define MCA_ERROR_MEM_UNKNOWN ((NTSTATUS)0xC0050047L) +#define MCA_WARNING_MEM_1_2 ((NTSTATUS)0x80050048L) +#define MCA_ERROR_MEM_1_2 ((NTSTATUS)0xC0050049L) +#define MCA_WARNING_MEM_1_2_5 ((NTSTATUS)0x8005004AL) +#define MCA_ERROR_MEM_1_2_5 ((NTSTATUS)0xC005004BL) +#define MCA_WARNING_MEM_1_2_5_4 ((NTSTATUS)0x8005004CL) +#define MCA_ERROR_MEM_1_2_5_4 ((NTSTATUS)0xC005004DL) +#define MCA_WARNING_SYSTEM_EVENT ((NTSTATUS)0x8005004EL) +#define MCA_ERROR_SYSTEM_EVENT ((NTSTATUS)0xC005004FL) +#define MCA_WARNING_PCI_BUS_PARITY ((NTSTATUS)0x80050050L) +#define MCA_ERROR_PCI_BUS_PARITY ((NTSTATUS)0xC0050051L) +#define MCA_WARNING_PCI_BUS_PARITY_NO_INFO ((NTSTATUS)0x80050052L) +#define MCA_ERROR_PCI_BUS_PARITY_NO_INFO ((NTSTATUS)0xC0050053L) +#define MCA_WARNING_PCI_BUS_SERR ((NTSTATUS)0x80050054L) +#define MCA_ERROR_PCI_BUS_SERR ((NTSTATUS)0xC0050055L) +#define MCA_WARNING_PCI_BUS_SERR_NO_INFO ((NTSTATUS)0x80050056L) +#define MCA_ERROR_PCI_BUS_SERR_NO_INFO ((NTSTATUS)0xC0050057L) +#define MCA_WARNING_PCI_BUS_MASTER_ABORT ((NTSTATUS)0x80050058L) +#define MCA_ERROR_PCI_BUS_MASTER_ABORT ((NTSTATUS)0xC0050059L) +#define MCA_WARNING_PCI_BUS_MASTER_ABORT_NO_INFO ((NTSTATUS)0x8005005AL) +#define MCA_ERROR_PCI_BUS_MASTER_ABORT_NO_INFO ((NTSTATUS)0xC005005BL) +#define MCA_WARNING_PCI_BUS_TIMEOUT ((NTSTATUS)0x8005005CL) +#define MCA_ERROR_PCI_BUS_TIMEOUT ((NTSTATUS)0xC005005DL) +#define MCA_WARNING_PCI_BUS_TIMEOUT_NO_INFO ((NTSTATUS)0x8005005EL) +#define MCA_ERROR_PCI_BUS_TIMEOUT_NO_INFO ((NTSTATUS)0xC005005FL) +#define MCA_WARNING_PCI_BUS_UNKNOWN ((NTSTATUS)0x80050060L) +#define MCA_ERROR_PCI_BUS_UNKNOWN ((NTSTATUS)0xC0050061L) +#define MCA_WARNING_PCI_DEVICE ((NTSTATUS)0x80050062L) +#define MCA_ERROR_PCI_DEVICE ((NTSTATUS)0xC0050063L) +#define MCA_WARNING_SMBIOS ((NTSTATUS)0x80050064L) +#define MCA_ERROR_SMBIOS ((NTSTATUS)0xC0050065L) +#define MCA_WARNING_PLATFORM_SPECIFIC ((NTSTATUS)0x80050066L) +#define MCA_ERROR_PLATFORM_SPECIFIC ((NTSTATUS)0xC0050067L) +#define MCA_WARNING_UNKNOWN ((NTSTATUS)0x80050068L) +#define MCA_ERROR_UNKNOWN ((NTSTATUS)0xC0050069L) +#define MCA_WARNING_UNKNOWN_NO_CPU ((NTSTATUS)0x8005006AL) +#define MCA_ERROR_UNKNOWN_NO_CPU ((NTSTATUS)0xC005006BL) +#define MCA_WARNING_CMC_THRESHOLD_EXCEEDED ((NTSTATUS)0x8005006DL) +#define MCA_WARNING_CPE_THRESHOLD_EXCEEDED ((NTSTATUS)0x8005006EL) +#define MCA_WARNING_CPU_THERMAL_THROTTLED ((NTSTATUS)0x8005006FL) +#define MCA_INFO_CPU_THERMAL_THROTTLING_REMOVED ((NTSTATUS)0x40050070L) +#define MCA_WARNING_CPU ((NTSTATUS)0x80050071L) +#define MCA_ERROR_CPU ((NTSTATUS)0xC0050072L) +#define MCA_INFO_NO_MORE_CORRECTED_ERROR_LOGS ((NTSTATUS)0x40050073L) +#define MCA_INFO_MEMORY_PAGE_MARKED_BAD ((NTSTATUS)0x40050074L) +#define MCA_MEMORYHIERARCHY_ERROR ((NTSTATUS)0xC0050078L) +#define MCA_TLB_ERROR ((NTSTATUS)0xC0050079L) +#define MCA_BUS_ERROR ((NTSTATUS)0xC005007AL) +#define MCA_BUS_TIMEOUT_ERROR ((NTSTATUS)0xC005007BL) +#define MCA_INTERNALTIMER_ERROR ((NTSTATUS)0xC005007CL) +#define MCA_MICROCODE_ROM_PARITY_ERROR ((NTSTATUS)0xC005007EL) +#define MCA_EXTERNAL_ERROR ((NTSTATUS)0xC005007FL) +#define MCA_FRC_ERROR ((NTSTATUS)0xC0050080L) + +#define STATUS_SEVERITY_SUCCESS 0x0 +#define STATUS_SEVERITY_INFORMATIONAL 0x1 +#define STATUS_SEVERITY_WARNING 0x2 +#define STATUS_SEVERITY_ERROR 0x3 diff --git a/reactos/include/psdk/ntstatus.h b/reactos/include/psdk/ntstatus.h index 688f996d3ff..9237221473c 100644 --- a/reactos/include/psdk/ntstatus.h +++ b/reactos/include/psdk/ntstatus.h @@ -27,1096 +27,1149 @@ extern "C" { #endif +#ifndef WIN32_NO_STATUS + +#define FACILITY_DEBUGGER 0x1 +#define FACILITY_RPC_RUNTIME 0x2 +#define FACILITY_RPC_STUBS 0x3 +#define FACILITY_IO_ERROR_CODE 0x4 +#define FACILITY_TERMINAL_SERVER 0xA +#define FACILITY_USB_ERROR_CODE 0x10 +#define FACILITY_HID_ERROR_CODE 0x11 +#define FACILITY_FIREWIRE_ERROR_CODE 0x12 +#define FACILITY_CLUSTER_ERROR_CODE 0x13 +#define FACILITY_ACPI_ERROR_CODE 0x14 +#define FACILITY_SXS_ERROR_CODE 0x15 + +/* Debug codes */ + +#define DBG_EXCEPTION_HANDLED ((NTSTATUS)0x00010001) +#define DBG_CONTINUE ((NTSTATUS)0x00010002) +#define DBG_REPLY_LATER ((NTSTATUS)0x40010001) +#define DBG_UNABLE_TO_PROVIDE_HANDLE ((NTSTATUS)0x40010002) +#define DBG_TERMINATE_THREAD ((NTSTATUS)0x40010003) +#define DBG_TERMINATE_PROCESS ((NTSTATUS)0x40010004) +#define DBG_CONTROL_C ((NTSTATUS)0x40010005) +#define DBG_PRINTEXCEPTION_C ((NTSTATUS)0x40010006) +#define DBG_RIPEXCEPTION ((NTSTATUS)0x40010007) +#define DBG_CONTROL_BREAK ((NTSTATUS)0x40010008) +#define DBG_COMMAND_EXCEPTION ((NTSTATUS)0x40010009) +#define DBG_EXCEPTION_NOT_HANDLED ((NTSTATUS)0x80010001) +#define DBG_NO_STATE_CHANGE ((NTSTATUS)0xC0010001) +#define DBG_APP_NOT_IDLE ((NTSTATUS)0xC0010002) + +/* Exception codes */ + #if !defined(STATUS_SUCCESS) -#define STATUS_SUCCESS ((NTSTATUS)0x00000000L) -#endif /* !STATUS_SUCCESS */ -#define FACILITY_DEBUGGER 0x1 -#define FACILITY_RPC_RUNTIME 0x2 -#define FACILITY_RPC_STUBS 0x3 -#define FACILITY_IO_ERROR_CODE 0x4 -#define FACILITY_TERMINAL_SERVER 0xA -#define FACILITY_USB_ERROR_CODE 0x10 -#define FACILITY_HID_ERROR_CODE 0x11 -#define FACILITY_FIREWIRE_ERROR_CODE 0x12 -#define FACILITY_CLUSTER_ERROR_CODE 0x13 -#define FACILITY_ACPI_ERROR_CODE 0x14 -#define FACILITY_SXS_ERROR_CODE 0x15 -#define STATUS_SEVERITY_SUCCESS 0x0 -#define STATUS_SEVERITY_INFORMATIONAL 0x1 -#define STATUS_SEVERITY_WARNING 0x2 -#define STATUS_SEVERITY_ERROR 0x3 -#define STATUS_WAIT_0 ((NTSTATUS)0x00000000L) -#define STATUS_WAIT_1 ((NTSTATUS)0x00000001L) -#define STATUS_WAIT_2 ((NTSTATUS)0x00000002L) -#define STATUS_WAIT_3 ((NTSTATUS)0x00000003L) -#define STATUS_WAIT_63 ((NTSTATUS)0x0000003FL) -#define STATUS_ABANDONED ((NTSTATUS)0x00000080L) -#define STATUS_ABANDONED_WAIT_0 ((NTSTATUS)0x00000080L) -#define STATUS_ABANDONED_WAIT_63 ((NTSTATUS)0x000000BFL) -#define STATUS_USER_APC ((NTSTATUS)0x000000C0L) -#define STATUS_KERNEL_APC ((NTSTATUS)0x00000100L) -#define STATUS_ALERTED ((NTSTATUS)0x00000101L) -#define STATUS_TIMEOUT ((NTSTATUS)0x00000102L) -#define STATUS_PENDING ((NTSTATUS)0x00000103L) -#define STATUS_REPARSE ((NTSTATUS)0x00000104L) -#define STATUS_MORE_ENTRIES ((NTSTATUS)0x00000105L) -#define STATUS_NOT_ALL_ASSIGNED ((NTSTATUS)0x00000106L) -#define STATUS_SOME_NOT_MAPPED ((NTSTATUS)0x00000107L) -#define STATUS_OPLOCK_BREAK_IN_PROGRESS ((NTSTATUS)0x00000108L) -#define STATUS_VOLUME_MOUNTED ((NTSTATUS)0x00000109L) -#define STATUS_RXACT_COMMITTED ((NTSTATUS)0x0000010AL) -#define STATUS_NOTIFY_CLEANUP ((NTSTATUS)0x0000010BL) -#define STATUS_NOTIFY_ENUM_DIR ((NTSTATUS)0x0000010CL) -#define STATUS_NO_QUOTAS_FOR_ACCOUNT ((NTSTATUS)0x0000010DL) -#define STATUS_PRIMARY_TRANSPORT_CONNECT_FAILED ((NTSTATUS)0x0000010EL) -#define STATUS_PAGE_FAULT_TRANSITION ((NTSTATUS)0x00000110L) -#define STATUS_PAGE_FAULT_DEMAND_ZERO ((NTSTATUS)0x00000111L) -#define STATUS_PAGE_FAULT_COPY_ON_WRITE ((NTSTATUS)0x00000112L) -#define STATUS_PAGE_FAULT_GUARD_PAGE ((NTSTATUS)0x00000113L) -#define STATUS_PAGE_FAULT_PAGING_FILE ((NTSTATUS)0x00000114L) -#define STATUS_CACHE_PAGE_LOCKED ((NTSTATUS)0x00000115L) -#define STATUS_CRASH_DUMP ((NTSTATUS)0x00000116L) -#define STATUS_BUFFER_ALL_ZEROS ((NTSTATUS)0x00000117L) -#define STATUS_REPARSE_OBJECT ((NTSTATUS)0x00000118L) -#define STATUS_RESOURCE_REQUIREMENTS_CHANGED ((NTSTATUS)0x00000119L) -#define STATUS_TRANSLATION_COMPLETE ((NTSTATUS)0x00000120L) -#define STATUS_DS_MEMBERSHIP_EVALUATED_LOCALLY ((NTSTATUS)0x00000121L) -#define STATUS_NOTHING_TO_TERMINATE ((NTSTATUS)0x00000122L) -#define STATUS_PROCESS_NOT_IN_JOB ((NTSTATUS)0x00000123L) -#define STATUS_PROCESS_IN_JOB ((NTSTATUS)0x00000124L) -#define STATUS_OBJECT_NAME_EXISTS ((NTSTATUS)0x40000000L) -#define STATUS_THREAD_WAS_SUSPENDED ((NTSTATUS)0x40000001L) -#define STATUS_WORKING_SET_LIMIT_RANGE ((NTSTATUS)0x40000002L) -#define STATUS_IMAGE_NOT_AT_BASE ((NTSTATUS)0x40000003L) -#define STATUS_RXACT_STATE_CREATED ((NTSTATUS)0x40000004L) -#define STATUS_SEGMENT_NOTIFICATION ((NTSTATUS)0x40000005L) -#define STATUS_LOCAL_USER_SESSION_KEY ((NTSTATUS)0x40000006L) -#define STATUS_BAD_CURRENT_DIRECTORY ((NTSTATUS)0x40000007L) -#define STATUS_SERIAL_MORE_WRITES ((NTSTATUS)0x40000008L) -#define STATUS_REGISTRY_RECOVERED ((NTSTATUS)0x40000009L) -#define STATUS_FT_READ_RECOVERY_FROM_BACKUP ((NTSTATUS)0x4000000AL) -#define STATUS_FT_WRITE_RECOVERY ((NTSTATUS)0x4000000BL) -#define STATUS_SERIAL_COUNTER_TIMEOUT ((NTSTATUS)0x4000000CL) -#define STATUS_NULL_LM_PASSWORD ((NTSTATUS)0x4000000DL) -#define STATUS_IMAGE_MACHINE_TYPE_MISMATCH ((NTSTATUS)0x4000000EL) -#define STATUS_RECEIVE_PARTIAL ((NTSTATUS)0x4000000FL) -#define STATUS_RECEIVE_EXPEDITED ((NTSTATUS)0x40000010L) -#define STATUS_RECEIVE_PARTIAL_EXPEDITED ((NTSTATUS)0x40000011L) -#define STATUS_EVENT_DONE ((NTSTATUS)0x40000012L) -#define STATUS_EVENT_PENDING ((NTSTATUS)0x40000013L) -#define STATUS_CHECKING_FILE_SYSTEM ((NTSTATUS)0x40000014L) -#define STATUS_FATAL_APP_EXIT ((NTSTATUS)0x40000015L) -#define STATUS_PREDEFINED_HANDLE ((NTSTATUS)0x40000016L) -#define STATUS_WAS_UNLOCKED ((NTSTATUS)0x40000017L) -#define STATUS_SERVICE_NOTIFICATION ((NTSTATUS)0x40000018L) -#define STATUS_WAS_LOCKED ((NTSTATUS)0x40000019L) -#define STATUS_LOG_HARD_ERROR ((NTSTATUS)0x4000001AL) -#define STATUS_ALREADY_WIN32 ((NTSTATUS)0x4000001BL) -#define STATUS_WX86_UNSIMULATE ((NTSTATUS)0x4000001CL) -#define STATUS_WX86_CONTINUE ((NTSTATUS)0x4000001DL) -#define STATUS_WX86_SINGLE_STEP ((NTSTATUS)0x4000001EL) -#define STATUS_WX86_BREAKPOINT ((NTSTATUS)0x4000001FL) -#define STATUS_WX86_EXCEPTION_CONTINUE ((NTSTATUS)0x40000020L) -#define STATUS_WX86_EXCEPTION_LASTCHANCE ((NTSTATUS)0x40000021L) -#define STATUS_WX86_EXCEPTION_CHAIN ((NTSTATUS)0x40000022L) -#define STATUS_IMAGE_MACHINE_TYPE_MISMATCH_EXE ((NTSTATUS)0x40000023L) -#define STATUS_NO_YIELD_PERFORMED ((NTSTATUS)0x40000024L) -#define STATUS_TIMER_RESUME_IGNORED ((NTSTATUS)0x40000025L) -#define STATUS_ARBITRATION_UNHANDLED ((NTSTATUS)0x40000026L) -#define STATUS_CARDBUS_NOT_SUPPORTED ((NTSTATUS)0x40000027L) -#define STATUS_WX86_CREATEWX86TIB ((NTSTATUS)0x40000028L) -#define STATUS_MP_PROCESSOR_MISMATCH ((NTSTATUS)0x40000029L) -#define STATUS_HIBERNATED ((NTSTATUS)0x4000002AL) -#define STATUS_RESUME_HIBERNATION ((NTSTATUS)0x4000002BL) -#define STATUS_GUARD_PAGE_VIOLATION ((NTSTATUS)0x80000001L) -#define STATUS_DATATYPE_MISALIGNMENT ((NTSTATUS)0x80000002L) -#define STATUS_BREAKPOINT ((NTSTATUS)0x80000003L) -#define STATUS_SINGLE_STEP ((NTSTATUS)0x80000004L) -#define STATUS_BUFFER_OVERFLOW ((NTSTATUS)0x80000005L) -#define STATUS_NO_MORE_FILES ((NTSTATUS)0x80000006L) -#define STATUS_WAKE_SYSTEM_DEBUGGER ((NTSTATUS)0x80000007L) -#define STATUS_HANDLES_CLOSED ((NTSTATUS)0x8000000AL) -#define STATUS_NO_INHERITANCE ((NTSTATUS)0x8000000BL) -#define STATUS_GUID_SUBSTITUTION_MADE ((NTSTATUS)0x8000000CL) -#define STATUS_PARTIAL_COPY ((NTSTATUS)0x8000000DL) -#define STATUS_DEVICE_PAPER_EMPTY ((NTSTATUS)0x8000000EL) -#define STATUS_DEVICE_POWERED_OFF ((NTSTATUS)0x8000000FL) -#define STATUS_DEVICE_OFF_LINE ((NTSTATUS)0x80000010L) -#define STATUS_DEVICE_BUSY ((NTSTATUS)0x80000011L) -#define STATUS_NO_MORE_EAS ((NTSTATUS)0x80000012L) -#define STATUS_INVALID_EA_NAME ((NTSTATUS)0x80000013L) -#define STATUS_EA_LIST_INCONSISTENT ((NTSTATUS)0x80000014L) -#define STATUS_INVALID_EA_FLAG ((NTSTATUS)0x80000015L) -#define STATUS_VERIFY_REQUIRED ((NTSTATUS)0x80000016L) -#define STATUS_EXTRANEOUS_INFORMATION ((NTSTATUS)0x80000017L) -#define STATUS_RXACT_COMMIT_NECESSARY ((NTSTATUS)0x80000018L) -#define STATUS_NO_MORE_ENTRIES ((NTSTATUS)0x8000001AL) -#define STATUS_FILEMARK_DETECTED ((NTSTATUS)0x8000001BL) -#define STATUS_MEDIA_CHANGED ((NTSTATUS)0x8000001CL) -#define STATUS_BUS_RESET ((NTSTATUS)0x8000001DL) -#define STATUS_END_OF_MEDIA ((NTSTATUS)0x8000001EL) -#define STATUS_BEGINNING_OF_MEDIA ((NTSTATUS)0x8000001FL) -#define STATUS_MEDIA_CHECK ((NTSTATUS)0x80000020L) -#define STATUS_SETMARK_DETECTED ((NTSTATUS)0x80000021L) -#define STATUS_NO_DATA_DETECTED ((NTSTATUS)0x80000022L) -#define STATUS_REDIRECTOR_HAS_OPEN_HANDLES ((NTSTATUS)0x80000023L) -#define STATUS_SERVER_HAS_OPEN_HANDLES ((NTSTATUS)0x80000024L) -#define STATUS_ALREADY_DISCONNECTED ((NTSTATUS)0x80000025L) -#define STATUS_LONGJUMP ((NTSTATUS)0x80000026L) -#define STATUS_CLEANER_CARTRIDGE_INSTALLED ((NTSTATUS)0x80000027L) -#define STATUS_PLUGPLAY_QUERY_VETOED ((NTSTATUS)0x80000028L) -#define STATUS_UNWIND_CONSOLIDATE ((NTSTATUS)0x80000029L) -#define STATUS_CLUSTER_NODE_ALREADY_UP ((NTSTATUS)0x80130001L) -#define STATUS_CLUSTER_NODE_ALREADY_DOWN ((NTSTATUS)0x80130002L) -#define STATUS_CLUSTER_NETWORK_ALREADY_ONLINE ((NTSTATUS)0x80130003L) -#define STATUS_CLUSTER_NETWORK_ALREADY_OFFLINE ((NTSTATUS)0x80130004L) -#define STATUS_CLUSTER_NODE_ALREADY_MEMBER ((NTSTATUS)0x80130005L) -#define STATUS_UNSUCCESSFUL ((NTSTATUS)0xC0000001L) -#define STATUS_NOT_IMPLEMENTED ((NTSTATUS)0xC0000002L) -#define STATUS_INVALID_INFO_CLASS ((NTSTATUS)0xC0000003L) -#define STATUS_INFO_LENGTH_MISMATCH ((NTSTATUS)0xC0000004L) -#define STATUS_ACCESS_VIOLATION ((NTSTATUS)0xC0000005L) -#define STATUS_IN_PAGE_ERROR ((NTSTATUS)0xC0000006L) -#define STATUS_PAGEFILE_QUOTA ((NTSTATUS)0xC0000007L) -#define STATUS_INVALID_HANDLE ((NTSTATUS)0xC0000008L) -#define STATUS_BAD_INITIAL_STACK ((NTSTATUS)0xC0000009L) -#define STATUS_BAD_INITIAL_PC ((NTSTATUS)0xC000000AL) -#define STATUS_INVALID_CID ((NTSTATUS)0xC000000BL) -#define STATUS_TIMER_NOT_CANCELED ((NTSTATUS)0xC000000CL) -#define STATUS_INVALID_PARAMETER ((NTSTATUS)0xC000000DL) -#define STATUS_NO_SUCH_DEVICE ((NTSTATUS)0xC000000EL) -#define STATUS_NO_SUCH_FILE ((NTSTATUS)0xC000000FL) -#define STATUS_INVALID_DEVICE_REQUEST ((NTSTATUS)0xC0000010L) -#define STATUS_END_OF_FILE ((NTSTATUS)0xC0000011L) -#define STATUS_WRONG_VOLUME ((NTSTATUS)0xC0000012L) -#define STATUS_NO_MEDIA_IN_DEVICE ((NTSTATUS)0xC0000013L) -#define STATUS_UNRECOGNIZED_MEDIA ((NTSTATUS)0xC0000014L) -#define STATUS_NONEXISTENT_SECTOR ((NTSTATUS)0xC0000015L) -#define STATUS_MORE_PROCESSING_REQUIRED ((NTSTATUS)0xC0000016L) -#define STATUS_NO_MEMORY ((NTSTATUS)0xC0000017L) -#define STATUS_CONFLICTING_ADDRESSES ((NTSTATUS)0xC0000018L) -#define STATUS_NOT_MAPPED_VIEW ((NTSTATUS)0xC0000019L) -#define STATUS_UNABLE_TO_FREE_VM ((NTSTATUS)0xC000001AL) -#define STATUS_UNABLE_TO_DELETE_SECTION ((NTSTATUS)0xC000001BL) -#define STATUS_INVALID_SYSTEM_SERVICE ((NTSTATUS)0xC000001CL) -#define STATUS_ILLEGAL_INSTRUCTION ((NTSTATUS)0xC000001DL) -#define STATUS_INVALID_LOCK_SEQUENCE ((NTSTATUS)0xC000001EL) -#define STATUS_INVALID_VIEW_SIZE ((NTSTATUS)0xC000001FL) -#define STATUS_INVALID_FILE_FOR_SECTION ((NTSTATUS)0xC0000020L) -#define STATUS_ALREADY_COMMITTED ((NTSTATUS)0xC0000021L) -#define STATUS_ACCESS_DENIED ((NTSTATUS)0xC0000022L) -#define STATUS_BUFFER_TOO_SMALL ((NTSTATUS)0xC0000023L) -#define STATUS_OBJECT_TYPE_MISMATCH ((NTSTATUS)0xC0000024L) -#define STATUS_NONCONTINUABLE_EXCEPTION ((NTSTATUS)0xC0000025L) -#define STATUS_INVALID_DISPOSITION ((NTSTATUS)0xC0000026L) -#define STATUS_UNWIND ((NTSTATUS)0xC0000027L) -#define STATUS_BAD_STACK ((NTSTATUS)0xC0000028L) -#define STATUS_INVALID_UNWIND_TARGET ((NTSTATUS)0xC0000029L) -#define STATUS_NOT_LOCKED ((NTSTATUS)0xC000002AL) -#define STATUS_PARITY_ERROR ((NTSTATUS)0xC000002BL) -#define STATUS_UNABLE_TO_DECOMMIT_VM ((NTSTATUS)0xC000002CL) -#define STATUS_NOT_COMMITTED ((NTSTATUS)0xC000002DL) -#define STATUS_INVALID_PORT_ATTRIBUTES ((NTSTATUS)0xC000002EL) -#define STATUS_PORT_MESSAGE_TOO_LONG ((NTSTATUS)0xC000002FL) -#define STATUS_INVALID_PARAMETER_MIX ((NTSTATUS)0xC0000030L) -#define STATUS_INVALID_QUOTA_LOWER ((NTSTATUS)0xC0000031L) -#define STATUS_DISK_CORRUPT_ERROR ((NTSTATUS)0xC0000032L) -#define STATUS_OBJECT_NAME_INVALID ((NTSTATUS)0xC0000033L) -#define STATUS_OBJECT_NAME_NOT_FOUND ((NTSTATUS)0xC0000034L) -#define STATUS_OBJECT_NAME_COLLISION ((NTSTATUS)0xC0000035L) -#define STATUS_PORT_DISCONNECTED ((NTSTATUS)0xC0000037L) -#define STATUS_DEVICE_ALREADY_ATTACHED ((NTSTATUS)0xC0000038L) -#define STATUS_OBJECT_PATH_INVALID ((NTSTATUS)0xC0000039L) -#define STATUS_OBJECT_PATH_NOT_FOUND ((NTSTATUS)0xC000003AL) -#define STATUS_OBJECT_PATH_SYNTAX_BAD ((NTSTATUS)0xC000003BL) -#define STATUS_DATA_OVERRUN ((NTSTATUS)0xC000003CL) -#define STATUS_DATA_LATE_ERROR ((NTSTATUS)0xC000003DL) -#define STATUS_DATA_ERROR ((NTSTATUS)0xC000003EL) -#define STATUS_CRC_ERROR ((NTSTATUS)0xC000003FL) -#define STATUS_SECTION_TOO_BIG ((NTSTATUS)0xC0000040L) -#define STATUS_PORT_CONNECTION_REFUSED ((NTSTATUS)0xC0000041L) -#define STATUS_INVALID_PORT_HANDLE ((NTSTATUS)0xC0000042L) -#define STATUS_SHARING_VIOLATION ((NTSTATUS)0xC0000043L) -#define STATUS_QUOTA_EXCEEDED ((NTSTATUS)0xC0000044L) -#define STATUS_INVALID_PAGE_PROTECTION ((NTSTATUS)0xC0000045L) -#define STATUS_MUTANT_NOT_OWNED ((NTSTATUS)0xC0000046L) -#define STATUS_SEMAPHORE_LIMIT_EXCEEDED ((NTSTATUS)0xC0000047L) -#define STATUS_PORT_ALREADY_SET ((NTSTATUS)0xC0000048L) -#define STATUS_SECTION_NOT_IMAGE ((NTSTATUS)0xC0000049L) -#define STATUS_SUSPEND_COUNT_EXCEEDED ((NTSTATUS)0xC000004AL) -#define STATUS_THREAD_IS_TERMINATING ((NTSTATUS)0xC000004BL) -#define STATUS_BAD_WORKING_SET_LIMIT ((NTSTATUS)0xC000004CL) -#define STATUS_INCOMPATIBLE_FILE_MAP ((NTSTATUS)0xC000004DL) -#define STATUS_SECTION_PROTECTION ((NTSTATUS)0xC000004EL) -#define STATUS_EAS_NOT_SUPPORTED ((NTSTATUS)0xC000004FL) -#define STATUS_EA_TOO_LARGE ((NTSTATUS)0xC0000050L) -#define STATUS_NONEXISTENT_EA_ENTRY ((NTSTATUS)0xC0000051L) -#define STATUS_NO_EAS_ON_FILE ((NTSTATUS)0xC0000052L) -#define STATUS_EA_CORRUPT_ERROR ((NTSTATUS)0xC0000053L) -#define STATUS_FILE_LOCK_CONFLICT ((NTSTATUS)0xC0000054L) -#define STATUS_LOCK_NOT_GRANTED ((NTSTATUS)0xC0000055L) -#define STATUS_DELETE_PENDING ((NTSTATUS)0xC0000056L) -#define STATUS_CTL_FILE_NOT_SUPPORTED ((NTSTATUS)0xC0000057L) -#define STATUS_UNKNOWN_REVISION ((NTSTATUS)0xC0000058L) -#define STATUS_REVISION_MISMATCH ((NTSTATUS)0xC0000059L) -#define STATUS_INVALID_OWNER ((NTSTATUS)0xC000005AL) -#define STATUS_INVALID_PRIMARY_GROUP ((NTSTATUS)0xC000005BL) -#define STATUS_NO_IMPERSONATION_TOKEN ((NTSTATUS)0xC000005CL) -#define STATUS_CANT_DISABLE_MANDATORY ((NTSTATUS)0xC000005DL) -#define STATUS_NO_LOGON_SERVERS ((NTSTATUS)0xC000005EL) -#define STATUS_NO_SUCH_LOGON_SESSION ((NTSTATUS)0xC000005FL) -#define STATUS_NO_SUCH_PRIVILEGE ((NTSTATUS)0xC0000060L) -#define STATUS_PRIVILEGE_NOT_HELD ((NTSTATUS)0xC0000061L) -#define STATUS_INVALID_ACCOUNT_NAME ((NTSTATUS)0xC0000062L) -#define STATUS_USER_EXISTS ((NTSTATUS)0xC0000063L) -#define STATUS_NO_SUCH_USER ((NTSTATUS)0xC0000064L) -#define STATUS_GROUP_EXISTS ((NTSTATUS)0xC0000065L) -#define STATUS_NO_SUCH_GROUP ((NTSTATUS)0xC0000066L) -#define STATUS_MEMBER_IN_GROUP ((NTSTATUS)0xC0000067L) -#define STATUS_MEMBER_NOT_IN_GROUP ((NTSTATUS)0xC0000068L) -#define STATUS_LAST_ADMIN ((NTSTATUS)0xC0000069L) -#define STATUS_WRONG_PASSWORD ((NTSTATUS)0xC000006AL) -#define STATUS_ILL_FORMED_PASSWORD ((NTSTATUS)0xC000006BL) -#define STATUS_PASSWORD_RESTRICTION ((NTSTATUS)0xC000006CL) -#define STATUS_LOGON_FAILURE ((NTSTATUS)0xC000006DL) -#define STATUS_ACCOUNT_RESTRICTION ((NTSTATUS)0xC000006EL) -#define STATUS_INVALID_LOGON_HOURS ((NTSTATUS)0xC000006FL) -#define STATUS_INVALID_WORKSTATION ((NTSTATUS)0xC0000070L) -#define STATUS_PASSWORD_EXPIRED ((NTSTATUS)0xC0000071L) -#define STATUS_ACCOUNT_DISABLED ((NTSTATUS)0xC0000072L) -#define STATUS_NONE_MAPPED ((NTSTATUS)0xC0000073L) -#define STATUS_TOO_MANY_LUIDS_REQUESTED ((NTSTATUS)0xC0000074L) -#define STATUS_LUIDS_EXHAUSTED ((NTSTATUS)0xC0000075L) -#define STATUS_INVALID_SUB_AUTHORITY ((NTSTATUS)0xC0000076L) -#define STATUS_INVALID_ACL ((NTSTATUS)0xC0000077L) -#define STATUS_INVALID_SID ((NTSTATUS)0xC0000078L) -#define STATUS_INVALID_SECURITY_DESCR ((NTSTATUS)0xC0000079L) -#define STATUS_PROCEDURE_NOT_FOUND ((NTSTATUS)0xC000007AL) -#define STATUS_INVALID_IMAGE_FORMAT ((NTSTATUS)0xC000007BL) -#define STATUS_NO_TOKEN ((NTSTATUS)0xC000007CL) -#define STATUS_BAD_INHERITANCE_ACL ((NTSTATUS)0xC000007DL) -#define STATUS_RANGE_NOT_LOCKED ((NTSTATUS)0xC000007EL) -#define STATUS_DISK_FULL ((NTSTATUS)0xC000007FL) -#define STATUS_SERVER_DISABLED ((NTSTATUS)0xC0000080L) -#define STATUS_SERVER_NOT_DISABLED ((NTSTATUS)0xC0000081L) -#define STATUS_TOO_MANY_GUIDS_REQUESTED ((NTSTATUS)0xC0000082L) -#define STATUS_GUIDS_EXHAUSTED ((NTSTATUS)0xC0000083L) -#define STATUS_INVALID_ID_AUTHORITY ((NTSTATUS)0xC0000084L) -#define STATUS_AGENTS_EXHAUSTED ((NTSTATUS)0xC0000085L) -#define STATUS_INVALID_VOLUME_LABEL ((NTSTATUS)0xC0000086L) -#define STATUS_SECTION_NOT_EXTENDED ((NTSTATUS)0xC0000087L) -#define STATUS_NOT_MAPPED_DATA ((NTSTATUS)0xC0000088L) -#define STATUS_RESOURCE_DATA_NOT_FOUND ((NTSTATUS)0xC0000089L) -#define STATUS_RESOURCE_TYPE_NOT_FOUND ((NTSTATUS)0xC000008AL) -#define STATUS_RESOURCE_NAME_NOT_FOUND ((NTSTATUS)0xC000008BL) -#define STATUS_ARRAY_BOUNDS_EXCEEDED ((NTSTATUS)0xC000008CL) -#define STATUS_FLOAT_DENORMAL_OPERAND ((NTSTATUS)0xC000008DL) -#define STATUS_FLOAT_DIVIDE_BY_ZERO ((NTSTATUS)0xC000008EL) -#define STATUS_FLOAT_INEXACT_RESULT ((NTSTATUS)0xC000008FL) -#define STATUS_FLOAT_INVALID_OPERATION ((NTSTATUS)0xC0000090L) -#define STATUS_FLOAT_OVERFLOW ((NTSTATUS)0xC0000091L) -#define STATUS_FLOAT_STACK_CHECK ((NTSTATUS)0xC0000092L) -#define STATUS_FLOAT_UNDERFLOW ((NTSTATUS)0xC0000093L) -#define STATUS_INTEGER_DIVIDE_BY_ZERO ((NTSTATUS)0xC0000094L) -#define STATUS_INTEGER_OVERFLOW ((NTSTATUS)0xC0000095L) -#define STATUS_PRIVILEGED_INSTRUCTION ((NTSTATUS)0xC0000096L) -#define STATUS_TOO_MANY_PAGING_FILES ((NTSTATUS)0xC0000097L) -#define STATUS_FILE_INVALID ((NTSTATUS)0xC0000098L) -#define STATUS_ALLOTTED_SPACE_EXCEEDED ((NTSTATUS)0xC0000099L) -#define STATUS_INSUFFICIENT_RESOURCES ((NTSTATUS)0xC000009AL) -#define STATUS_DFS_EXIT_PATH_FOUND ((NTSTATUS)0xC000009BL) -#define STATUS_DEVICE_DATA_ERROR ((NTSTATUS)0xC000009CL) -#define STATUS_DEVICE_NOT_CONNECTED ((NTSTATUS)0xC000009DL) -#define STATUS_DEVICE_POWER_FAILURE ((NTSTATUS)0xC000009EL) -#define STATUS_FREE_VM_NOT_AT_BASE ((NTSTATUS)0xC000009FL) -#define STATUS_MEMORY_NOT_ALLOCATED ((NTSTATUS)0xC00000A0L) -#define STATUS_WORKING_SET_QUOTA ((NTSTATUS)0xC00000A1L) -#define STATUS_MEDIA_WRITE_PROTECTED ((NTSTATUS)0xC00000A2L) -#define STATUS_DEVICE_NOT_READY ((NTSTATUS)0xC00000A3L) -#define STATUS_INVALID_GROUP_ATTRIBUTES ((NTSTATUS)0xC00000A4L) -#define STATUS_BAD_IMPERSONATION_LEVEL ((NTSTATUS)0xC00000A5L) -#define STATUS_CANT_OPEN_ANONYMOUS ((NTSTATUS)0xC00000A6L) -#define STATUS_BAD_VALIDATION_CLASS ((NTSTATUS)0xC00000A7L) -#define STATUS_BAD_TOKEN_TYPE ((NTSTATUS)0xC00000A8L) -#define STATUS_BAD_MASTER_BOOT_RECORD ((NTSTATUS)0xC00000A9L) -#define STATUS_INSTRUCTION_MISALIGNMENT ((NTSTATUS)0xC00000AAL) -#define STATUS_INSTANCE_NOT_AVAILABLE ((NTSTATUS)0xC00000ABL) -#define STATUS_PIPE_NOT_AVAILABLE ((NTSTATUS)0xC00000ACL) -#define STATUS_INVALID_PIPE_STATE ((NTSTATUS)0xC00000ADL) -#define STATUS_PIPE_BUSY ((NTSTATUS)0xC00000AEL) -#define STATUS_ILLEGAL_FUNCTION ((NTSTATUS)0xC00000AFL) -#define STATUS_PIPE_DISCONNECTED ((NTSTATUS)0xC00000B0L) -#define STATUS_PIPE_CLOSING ((NTSTATUS)0xC00000B1L) -#define STATUS_PIPE_CONNECTED ((NTSTATUS)0xC00000B2L) -#define STATUS_PIPE_LISTENING ((NTSTATUS)0xC00000B3L) -#define STATUS_INVALID_READ_MODE ((NTSTATUS)0xC00000B4L) -#define STATUS_IO_TIMEOUT ((NTSTATUS)0xC00000B5L) -#define STATUS_FILE_FORCED_CLOSED ((NTSTATUS)0xC00000B6L) -#define STATUS_PROFILING_NOT_STARTED ((NTSTATUS)0xC00000B7L) -#define STATUS_PROFILING_NOT_STOPPED ((NTSTATUS)0xC00000B8L) -#define STATUS_COULD_NOT_INTERPRET ((NTSTATUS)0xC00000B9L) -#define STATUS_FILE_IS_A_DIRECTORY ((NTSTATUS)0xC00000BAL) -#define STATUS_NOT_SUPPORTED ((NTSTATUS)0xC00000BBL) -#define STATUS_REMOTE_NOT_LISTENING ((NTSTATUS)0xC00000BCL) -#define STATUS_DUPLICATE_NAME ((NTSTATUS)0xC00000BDL) -#define STATUS_BAD_NETWORK_PATH ((NTSTATUS)0xC00000BEL) -#define STATUS_NETWORK_BUSY ((NTSTATUS)0xC00000BFL) -#define STATUS_DEVICE_DOES_NOT_EXIST ((NTSTATUS)0xC00000C0L) -#define STATUS_TOO_MANY_COMMANDS ((NTSTATUS)0xC00000C1L) -#define STATUS_ADAPTER_HARDWARE_ERROR ((NTSTATUS)0xC00000C2L) -#define STATUS_INVALID_NETWORK_RESPONSE ((NTSTATUS)0xC00000C3L) -#define STATUS_UNEXPECTED_NETWORK_ERROR ((NTSTATUS)0xC00000C4L) -#define STATUS_BAD_REMOTE_ADAPTER ((NTSTATUS)0xC00000C5L) -#define STATUS_PRINT_QUEUE_FULL ((NTSTATUS)0xC00000C6L) -#define STATUS_NO_SPOOL_SPACE ((NTSTATUS)0xC00000C7L) -#define STATUS_PRINT_CANCELLED ((NTSTATUS)0xC00000C8L) -#define STATUS_NETWORK_NAME_DELETED ((NTSTATUS)0xC00000C9L) -#define STATUS_NETWORK_ACCESS_DENIED ((NTSTATUS)0xC00000CAL) -#define STATUS_BAD_DEVICE_TYPE ((NTSTATUS)0xC00000CBL) -#define STATUS_BAD_NETWORK_NAME ((NTSTATUS)0xC00000CCL) -#define STATUS_TOO_MANY_NAMES ((NTSTATUS)0xC00000CDL) -#define STATUS_TOO_MANY_SESSIONS ((NTSTATUS)0xC00000CEL) -#define STATUS_SHARING_PAUSED ((NTSTATUS)0xC00000CFL) -#define STATUS_REQUEST_NOT_ACCEPTED ((NTSTATUS)0xC00000D0L) -#define STATUS_REDIRECTOR_PAUSED ((NTSTATUS)0xC00000D1L) -#define STATUS_NET_WRITE_FAULT ((NTSTATUS)0xC00000D2L) -#define STATUS_PROFILING_AT_LIMIT ((NTSTATUS)0xC00000D3L) -#define STATUS_NOT_SAME_DEVICE ((NTSTATUS)0xC00000D4L) -#define STATUS_FILE_RENAMED ((NTSTATUS)0xC00000D5L) -#define STATUS_VIRTUAL_CIRCUIT_CLOSED ((NTSTATUS)0xC00000D6L) -#define STATUS_NO_SECURITY_ON_OBJECT ((NTSTATUS)0xC00000D7L) -#define STATUS_CANT_WAIT ((NTSTATUS)0xC00000D8L) -#define STATUS_PIPE_EMPTY ((NTSTATUS)0xC00000D9L) -#define STATUS_CANT_ACCESS_DOMAIN_INFO ((NTSTATUS)0xC00000DAL) -#define STATUS_CANT_TERMINATE_SELF ((NTSTATUS)0xC00000DBL) -#define STATUS_INVALID_SERVER_STATE ((NTSTATUS)0xC00000DCL) -#define STATUS_INVALID_DOMAIN_STATE ((NTSTATUS)0xC00000DDL) -#define STATUS_INVALID_DOMAIN_ROLE ((NTSTATUS)0xC00000DEL) -#define STATUS_NO_SUCH_DOMAIN ((NTSTATUS)0xC00000DFL) -#define STATUS_DOMAIN_EXISTS ((NTSTATUS)0xC00000E0L) -#define STATUS_DOMAIN_LIMIT_EXCEEDED ((NTSTATUS)0xC00000E1L) -#define STATUS_OPLOCK_NOT_GRANTED ((NTSTATUS)0xC00000E2L) -#define STATUS_INVALID_OPLOCK_PROTOCOL ((NTSTATUS)0xC00000E3L) -#define STATUS_INTERNAL_DB_CORRUPTION ((NTSTATUS)0xC00000E4L) -#define STATUS_INTERNAL_ERROR ((NTSTATUS)0xC00000E5L) -#define STATUS_GENERIC_NOT_MAPPED ((NTSTATUS)0xC00000E6L) -#define STATUS_BAD_DESCRIPTOR_FORMAT ((NTSTATUS)0xC00000E7L) -#define STATUS_INVALID_USER_BUFFER ((NTSTATUS)0xC00000E8L) -#define STATUS_UNEXPECTED_IO_ERROR ((NTSTATUS)0xC00000E9L) -#define STATUS_UNEXPECTED_MM_CREATE_ERR ((NTSTATUS)0xC00000EAL) -#define STATUS_UNEXPECTED_MM_MAP_ERROR ((NTSTATUS)0xC00000EBL) -#define STATUS_UNEXPECTED_MM_EXTEND_ERR ((NTSTATUS)0xC00000ECL) -#define STATUS_NOT_LOGON_PROCESS ((NTSTATUS)0xC00000EDL) -#define STATUS_LOGON_SESSION_EXISTS ((NTSTATUS)0xC00000EEL) -#define STATUS_INVALID_PARAMETER_1 ((NTSTATUS)0xC00000EFL) -#define STATUS_INVALID_PARAMETER_2 ((NTSTATUS)0xC00000F0L) -#define STATUS_INVALID_PARAMETER_3 ((NTSTATUS)0xC00000F1L) -#define STATUS_INVALID_PARAMETER_4 ((NTSTATUS)0xC00000F2L) -#define STATUS_INVALID_PARAMETER_5 ((NTSTATUS)0xC00000F3L) -#define STATUS_INVALID_PARAMETER_6 ((NTSTATUS)0xC00000F4L) -#define STATUS_INVALID_PARAMETER_7 ((NTSTATUS)0xC00000F5L) -#define STATUS_INVALID_PARAMETER_8 ((NTSTATUS)0xC00000F6L) -#define STATUS_INVALID_PARAMETER_9 ((NTSTATUS)0xC00000F7L) -#define STATUS_INVALID_PARAMETER_10 ((NTSTATUS)0xC00000F8L) -#define STATUS_INVALID_PARAMETER_11 ((NTSTATUS)0xC00000F9L) -#define STATUS_INVALID_PARAMETER_12 ((NTSTATUS)0xC00000FAL) -#define STATUS_REDIRECTOR_NOT_STARTED ((NTSTATUS)0xC00000FBL) -#define STATUS_REDIRECTOR_STARTED ((NTSTATUS)0xC00000FCL) -#define STATUS_STACK_OVERFLOW ((NTSTATUS)0xC00000FDL) -#define STATUS_NO_SUCH_PACKAGE ((NTSTATUS)0xC00000FEL) -#define STATUS_BAD_FUNCTION_TABLE ((NTSTATUS)0xC00000FFL) -#define STATUS_VARIABLE_NOT_FOUND ((NTSTATUS)0xC0000100L) -#define STATUS_DIRECTORY_NOT_EMPTY ((NTSTATUS)0xC0000101L) -#define STATUS_FILE_CORRUPT_ERROR ((NTSTATUS)0xC0000102L) -#define STATUS_NOT_A_DIRECTORY ((NTSTATUS)0xC0000103L) -#define STATUS_BAD_LOGON_SESSION_STATE ((NTSTATUS)0xC0000104L) -#define STATUS_LOGON_SESSION_COLLISION ((NTSTATUS)0xC0000105L) -#define STATUS_NAME_TOO_LONG ((NTSTATUS)0xC0000106L) -#define STATUS_FILES_OPEN ((NTSTATUS)0xC0000107L) -#define STATUS_CONNECTION_IN_USE ((NTSTATUS)0xC0000108L) -#define STATUS_MESSAGE_NOT_FOUND ((NTSTATUS)0xC0000109L) -#define STATUS_PROCESS_IS_TERMINATING ((NTSTATUS)0xC000010AL) -#define STATUS_INVALID_LOGON_TYPE ((NTSTATUS)0xC000010BL) -#define STATUS_NO_GUID_TRANSLATION ((NTSTATUS)0xC000010CL) -#define STATUS_CANNOT_IMPERSONATE ((NTSTATUS)0xC000010DL) -#define STATUS_IMAGE_ALREADY_LOADED ((NTSTATUS)0xC000010EL) -#define STATUS_ABIOS_NOT_PRESENT ((NTSTATUS)0xC000010FL) -#define STATUS_ABIOS_LID_NOT_EXIST ((NTSTATUS)0xC0000110L) -#define STATUS_ABIOS_LID_ALREADY_OWNED ((NTSTATUS)0xC0000111L) -#define STATUS_ABIOS_NOT_LID_OWNER ((NTSTATUS)0xC0000112L) -#define STATUS_ABIOS_INVALID_COMMAND ((NTSTATUS)0xC0000113L) -#define STATUS_ABIOS_INVALID_LID ((NTSTATUS)0xC0000114L) -#define STATUS_ABIOS_SELECTOR_NOT_AVAILABLE ((NTSTATUS)0xC0000115L) -#define STATUS_ABIOS_INVALID_SELECTOR ((NTSTATUS)0xC0000116L) -#define STATUS_NO_LDT ((NTSTATUS)0xC0000117L) -#define STATUS_INVALID_LDT_SIZE ((NTSTATUS)0xC0000118L) -#define STATUS_INVALID_LDT_OFFSET ((NTSTATUS)0xC0000119L) -#define STATUS_INVALID_LDT_DESCRIPTOR ((NTSTATUS)0xC000011AL) -#define STATUS_INVALID_IMAGE_NE_FORMAT ((NTSTATUS)0xC000011BL) -#define STATUS_RXACT_INVALID_STATE ((NTSTATUS)0xC000011CL) -#define STATUS_RXACT_COMMIT_FAILURE ((NTSTATUS)0xC000011DL) -#define STATUS_MAPPED_FILE_SIZE_ZERO ((NTSTATUS)0xC000011EL) -#define STATUS_TOO_MANY_OPENED_FILES ((NTSTATUS)0xC000011FL) -#define STATUS_CANCELLED ((NTSTATUS)0xC0000120L) -#define STATUS_CANNOT_DELETE ((NTSTATUS)0xC0000121L) -#define STATUS_INVALID_COMPUTER_NAME ((NTSTATUS)0xC0000122L) -#define STATUS_FILE_DELETED ((NTSTATUS)0xC0000123L) -#define STATUS_SPECIAL_ACCOUNT ((NTSTATUS)0xC0000124L) -#define STATUS_SPECIAL_GROUP ((NTSTATUS)0xC0000125L) -#define STATUS_SPECIAL_USER ((NTSTATUS)0xC0000126L) -#define STATUS_MEMBERS_PRIMARY_GROUP ((NTSTATUS)0xC0000127L) -#define STATUS_FILE_CLOSED ((NTSTATUS)0xC0000128L) -#define STATUS_TOO_MANY_THREADS ((NTSTATUS)0xC0000129L) -#define STATUS_THREAD_NOT_IN_PROCESS ((NTSTATUS)0xC000012AL) -#define STATUS_TOKEN_ALREADY_IN_USE ((NTSTATUS)0xC000012BL) -#define STATUS_PAGEFILE_QUOTA_EXCEEDED ((NTSTATUS)0xC000012CL) -#define STATUS_COMMITMENT_LIMIT ((NTSTATUS)0xC000012DL) -#define STATUS_INVALID_IMAGE_LE_FORMAT ((NTSTATUS)0xC000012EL) -#define STATUS_INVALID_IMAGE_NOT_MZ ((NTSTATUS)0xC000012FL) -#define STATUS_INVALID_IMAGE_PROTECT ((NTSTATUS)0xC0000130L) -#define STATUS_INVALID_IMAGE_WIN_16 ((NTSTATUS)0xC0000131L) -#define STATUS_LOGON_SERVER_CONFLICT ((NTSTATUS)0xC0000132L) -#define STATUS_TIME_DIFFERENCE_AT_DC ((NTSTATUS)0xC0000133L) -#define STATUS_SYNCHRONIZATION_REQUIRED ((NTSTATUS)0xC0000134L) -#define STATUS_DLL_NOT_FOUND ((NTSTATUS)0xC0000135L) -#define STATUS_OPEN_FAILED ((NTSTATUS)0xC0000136L) -#define STATUS_IO_PRIVILEGE_FAILED ((NTSTATUS)0xC0000137L) -#define STATUS_ORDINAL_NOT_FOUND ((NTSTATUS)0xC0000138L) -#define STATUS_ENTRYPOINT_NOT_FOUND ((NTSTATUS)0xC0000139L) -#define STATUS_CONTROL_C_EXIT ((NTSTATUS)0xC000013AL) -#define STATUS_LOCAL_DISCONNECT ((NTSTATUS)0xC000013BL) -#define STATUS_REMOTE_DISCONNECT ((NTSTATUS)0xC000013CL) -#define STATUS_REMOTE_RESOURCES ((NTSTATUS)0xC000013DL) -#define STATUS_LINK_FAILED ((NTSTATUS)0xC000013EL) -#define STATUS_LINK_TIMEOUT ((NTSTATUS)0xC000013FL) -#define STATUS_INVALID_CONNECTION ((NTSTATUS)0xC0000140L) -#define STATUS_INVALID_ADDRESS ((NTSTATUS)0xC0000141L) -#define STATUS_DLL_INIT_FAILED ((NTSTATUS)0xC0000142L) -#define STATUS_MISSING_SYSTEMFILE ((NTSTATUS)0xC0000143L) -#define STATUS_UNHANDLED_EXCEPTION ((NTSTATUS)0xC0000144L) -#define STATUS_APP_INIT_FAILURE ((NTSTATUS)0xC0000145L) -#define STATUS_PAGEFILE_CREATE_FAILED ((NTSTATUS)0xC0000146L) -#define STATUS_NO_PAGEFILE ((NTSTATUS)0xC0000147L) -#define STATUS_INVALID_LEVEL ((NTSTATUS)0xC0000148L) -#define STATUS_WRONG_PASSWORD_CORE ((NTSTATUS)0xC0000149L) -#define STATUS_ILLEGAL_FLOAT_CONTEXT ((NTSTATUS)0xC000014AL) -#define STATUS_PIPE_BROKEN ((NTSTATUS)0xC000014BL) -#define STATUS_REGISTRY_CORRUPT ((NTSTATUS)0xC000014CL) -#define STATUS_REGISTRY_IO_FAILED ((NTSTATUS)0xC000014DL) -#define STATUS_NO_EVENT_PAIR ((NTSTATUS)0xC000014EL) -#define STATUS_UNRECOGNIZED_VOLUME ((NTSTATUS)0xC000014FL) -#define STATUS_SERIAL_NO_DEVICE_INITED ((NTSTATUS)0xC0000150L) -#define STATUS_NO_SUCH_ALIAS ((NTSTATUS)0xC0000151L) -#define STATUS_MEMBER_NOT_IN_ALIAS ((NTSTATUS)0xC0000152L) -#define STATUS_MEMBER_IN_ALIAS ((NTSTATUS)0xC0000153L) -#define STATUS_ALIAS_EXISTS ((NTSTATUS)0xC0000154L) -#define STATUS_LOGON_NOT_GRANTED ((NTSTATUS)0xC0000155L) -#define STATUS_TOO_MANY_SECRETS ((NTSTATUS)0xC0000156L) -#define STATUS_SECRET_TOO_LONG ((NTSTATUS)0xC0000157L) -#define STATUS_INTERNAL_DB_ERROR ((NTSTATUS)0xC0000158L) -#define STATUS_FULLSCREEN_MODE ((NTSTATUS)0xC0000159L) -#define STATUS_TOO_MANY_CONTEXT_IDS ((NTSTATUS)0xC000015AL) -#define STATUS_LOGON_TYPE_NOT_GRANTED ((NTSTATUS)0xC000015BL) -#define STATUS_NOT_REGISTRY_FILE ((NTSTATUS)0xC000015CL) -#define STATUS_NT_CROSS_ENCRYPTION_REQUIRED ((NTSTATUS)0xC000015DL) -#define STATUS_DOMAIN_CTRLR_CONFIG_ERROR ((NTSTATUS)0xC000015EL) -#define STATUS_FT_MISSING_MEMBER ((NTSTATUS)0xC000015FL) -#define STATUS_ILL_FORMED_SERVICE_ENTRY ((NTSTATUS)0xC0000160L) -#define STATUS_ILLEGAL_CHARACTER ((NTSTATUS)0xC0000161L) -#define STATUS_UNMAPPABLE_CHARACTER ((NTSTATUS)0xC0000162L) -#define STATUS_UNDEFINED_CHARACTER ((NTSTATUS)0xC0000163L) -#define STATUS_FLOPPY_VOLUME ((NTSTATUS)0xC0000164L) -#define STATUS_FLOPPY_ID_MARK_NOT_FOUND ((NTSTATUS)0xC0000165L) -#define STATUS_FLOPPY_WRONG_CYLINDER ((NTSTATUS)0xC0000166L) -#define STATUS_FLOPPY_UNKNOWN_ERROR ((NTSTATUS)0xC0000167L) -#define STATUS_FLOPPY_BAD_REGISTERS ((NTSTATUS)0xC0000168L) -#define STATUS_DISK_RECALIBRATE_FAILED ((NTSTATUS)0xC0000169L) -#define STATUS_DISK_OPERATION_FAILED ((NTSTATUS)0xC000016AL) -#define STATUS_DISK_RESET_FAILED ((NTSTATUS)0xC000016BL) -#define STATUS_SHARED_IRQ_BUSY ((NTSTATUS)0xC000016CL) -#define STATUS_FT_ORPHANING ((NTSTATUS)0xC000016DL) -#define STATUS_BIOS_FAILED_TO_CONNECT_INTERRUPT ((NTSTATUS)0xC000016EL) -#define STATUS_PARTITION_FAILURE ((NTSTATUS)0xC0000172L) -#define STATUS_INVALID_BLOCK_LENGTH ((NTSTATUS)0xC0000173L) -#define STATUS_DEVICE_NOT_PARTITIONED ((NTSTATUS)0xC0000174L) -#define STATUS_UNABLE_TO_LOCK_MEDIA ((NTSTATUS)0xC0000175L) -#define STATUS_UNABLE_TO_UNLOAD_MEDIA ((NTSTATUS)0xC0000176L) -#define STATUS_EOM_OVERFLOW ((NTSTATUS)0xC0000177L) -#define STATUS_NO_MEDIA ((NTSTATUS)0xC0000178L) -#define STATUS_NO_SUCH_MEMBER ((NTSTATUS)0xC000017AL) -#define STATUS_INVALID_MEMBER ((NTSTATUS)0xC000017BL) -#define STATUS_KEY_DELETED ((NTSTATUS)0xC000017CL) -#define STATUS_NO_LOG_SPACE ((NTSTATUS)0xC000017DL) -#define STATUS_TOO_MANY_SIDS ((NTSTATUS)0xC000017EL) -#define STATUS_LM_CROSS_ENCRYPTION_REQUIRED ((NTSTATUS)0xC000017FL) -#define STATUS_KEY_HAS_CHILDREN ((NTSTATUS)0xC0000180L) -#define STATUS_CHILD_MUST_BE_VOLATILE ((NTSTATUS)0xC0000181L) -#define STATUS_DEVICE_CONFIGURATION_ERROR ((NTSTATUS)0xC0000182L) -#define STATUS_DRIVER_INTERNAL_ERROR ((NTSTATUS)0xC0000183L) -#define STATUS_INVALID_DEVICE_STATE ((NTSTATUS)0xC0000184L) -#define STATUS_IO_DEVICE_ERROR ((NTSTATUS)0xC0000185L) -#define STATUS_DEVICE_PROTOCOL_ERROR ((NTSTATUS)0xC0000186L) -#define STATUS_BACKUP_CONTROLLER ((NTSTATUS)0xC0000187L) -#define STATUS_LOG_FILE_FULL ((NTSTATUS)0xC0000188L) -#define STATUS_TOO_LATE ((NTSTATUS)0xC0000189L) -#define STATUS_NO_TRUST_LSA_SECRET ((NTSTATUS)0xC000018AL) -#define STATUS_NO_TRUST_SAM_ACCOUNT ((NTSTATUS)0xC000018BL) -#define STATUS_TRUSTED_DOMAIN_FAILURE ((NTSTATUS)0xC000018CL) -#define STATUS_TRUSTED_RELATIONSHIP_FAILURE ((NTSTATUS)0xC000018DL) -#define STATUS_EVENTLOG_FILE_CORRUPT ((NTSTATUS)0xC000018EL) -#define STATUS_EVENTLOG_CANT_START ((NTSTATUS)0xC000018FL) -#define STATUS_TRUST_FAILURE ((NTSTATUS)0xC0000190L) -#define STATUS_MUTANT_LIMIT_EXCEEDED ((NTSTATUS)0xC0000191L) -#define STATUS_NETLOGON_NOT_STARTED ((NTSTATUS)0xC0000192L) -#define STATUS_ACCOUNT_EXPIRED ((NTSTATUS)0xC0000193L) -#define STATUS_POSSIBLE_DEADLOCK ((NTSTATUS)0xC0000194L) -#define STATUS_NETWORK_CREDENTIAL_CONFLICT ((NTSTATUS)0xC0000195L) -#define STATUS_REMOTE_SESSION_LIMIT ((NTSTATUS)0xC0000196L) -#define STATUS_EVENTLOG_FILE_CHANGED ((NTSTATUS)0xC0000197L) -#define STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT ((NTSTATUS)0xC0000198L) -#define STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT ((NTSTATUS)0xC0000199L) -#define STATUS_NOLOGON_SERVER_TRUST_ACCOUNT ((NTSTATUS)0xC000019AL) -#define STATUS_DOMAIN_TRUST_INCONSISTENT ((NTSTATUS)0xC000019BL) -#define STATUS_FS_DRIVER_REQUIRED ((NTSTATUS)0xC000019CL) -#define STATUS_NO_USER_SESSION_KEY ((NTSTATUS)0xC0000202L) -#define STATUS_USER_SESSION_DELETED ((NTSTATUS)0xC0000203L) -#define STATUS_RESOURCE_LANG_NOT_FOUND ((NTSTATUS)0xC0000204L) -#define STATUS_INSUFF_SERVER_RESOURCES ((NTSTATUS)0xC0000205L) -#define STATUS_INVALID_BUFFER_SIZE ((NTSTATUS)0xC0000206L) -#define STATUS_INVALID_ADDRESS_COMPONENT ((NTSTATUS)0xC0000207L) -#define STATUS_INVALID_ADDRESS_WILDCARD ((NTSTATUS)0xC0000208L) -#define STATUS_TOO_MANY_ADDRESSES ((NTSTATUS)0xC0000209L) -#define STATUS_ADDRESS_ALREADY_EXISTS ((NTSTATUS)0xC000020AL) -#define STATUS_ADDRESS_CLOSED ((NTSTATUS)0xC000020BL) -#define STATUS_CONNECTION_DISCONNECTED ((NTSTATUS)0xC000020CL) -#define STATUS_CONNECTION_RESET ((NTSTATUS)0xC000020DL) -#define STATUS_TOO_MANY_NODES ((NTSTATUS)0xC000020EL) -#define STATUS_TRANSACTION_ABORTED ((NTSTATUS)0xC000020FL) -#define STATUS_TRANSACTION_TIMED_OUT ((NTSTATUS)0xC0000210L) -#define STATUS_TRANSACTION_NO_RELEASE ((NTSTATUS)0xC0000211L) -#define STATUS_TRANSACTION_NO_MATCH ((NTSTATUS)0xC0000212L) -#define STATUS_TRANSACTION_RESPONDED ((NTSTATUS)0xC0000213L) -#define STATUS_TRANSACTION_INVALID_ID ((NTSTATUS)0xC0000214L) -#define STATUS_TRANSACTION_INVALID_TYPE ((NTSTATUS)0xC0000215L) -#define STATUS_NOT_SERVER_SESSION ((NTSTATUS)0xC0000216L) -#define STATUS_NOT_CLIENT_SESSION ((NTSTATUS)0xC0000217L) -#define STATUS_CANNOT_LOAD_REGISTRY_FILE ((NTSTATUS)0xC0000218L) -#define STATUS_DEBUG_ATTACH_FAILED ((NTSTATUS)0xC0000219L) -#define STATUS_SYSTEM_PROCESS_TERMINATED ((NTSTATUS)0xC000021AL) -#define STATUS_DATA_NOT_ACCEPTED ((NTSTATUS)0xC000021BL) -#define STATUS_NO_BROWSER_SERVERS_FOUND ((NTSTATUS)0xC000021CL) -#define STATUS_VDM_HARD_ERROR ((NTSTATUS)0xC000021DL) -#define STATUS_DRIVER_CANCEL_TIMEOUT ((NTSTATUS)0xC000021EL) -#define STATUS_REPLY_MESSAGE_MISMATCH ((NTSTATUS)0xC000021FL) -#define STATUS_MAPPED_ALIGNMENT ((NTSTATUS)0xC0000220L) -#define STATUS_IMAGE_CHECKSUM_MISMATCH ((NTSTATUS)0xC0000221L) -#define STATUS_LOST_WRITEBEHIND_DATA ((NTSTATUS)0xC0000222L) -#define STATUS_CLIENT_SERVER_PARAMETERS_INVALID ((NTSTATUS)0xC0000223L) -#define STATUS_PASSWORD_MUST_CHANGE ((NTSTATUS)0xC0000224L) -#define STATUS_NOT_FOUND ((NTSTATUS)0xC0000225L) -#define STATUS_NOT_TINY_STREAM ((NTSTATUS)0xC0000226L) -#define STATUS_RECOVERY_FAILURE ((NTSTATUS)0xC0000227L) -#define STATUS_STACK_OVERFLOW_READ ((NTSTATUS)0xC0000228L) -#define STATUS_FAIL_CHECK ((NTSTATUS)0xC0000229L) -#define STATUS_DUPLICATE_OBJECTID ((NTSTATUS)0xC000022AL) -#define STATUS_OBJECTID_EXISTS ((NTSTATUS)0xC000022BL) -#define STATUS_CONVERT_TO_LARGE ((NTSTATUS)0xC000022CL) -#define STATUS_RETRY ((NTSTATUS)0xC000022DL) -#define STATUS_FOUND_OUT_OF_SCOPE ((NTSTATUS)0xC000022EL) -#define STATUS_ALLOCATE_BUCKET ((NTSTATUS)0xC000022FL) -#define STATUS_PROPSET_NOT_FOUND ((NTSTATUS)0xC0000230L) -#define STATUS_MARSHALL_OVERFLOW ((NTSTATUS)0xC0000231L) -#define STATUS_INVALID_VARIANT ((NTSTATUS)0xC0000232L) -#define STATUS_DOMAIN_CONTROLLER_NOT_FOUND ((NTSTATUS)0xC0000233L) -#define STATUS_ACCOUNT_LOCKED_OUT ((NTSTATUS)0xC0000234L) -#define STATUS_HANDLE_NOT_CLOSABLE ((NTSTATUS)0xC0000235L) -#define STATUS_CONNECTION_REFUSED ((NTSTATUS)0xC0000236L) -#define STATUS_GRACEFUL_DISCONNECT ((NTSTATUS)0xC0000237L) -#define STATUS_ADDRESS_ALREADY_ASSOCIATED ((NTSTATUS)0xC0000238L) -#define STATUS_ADDRESS_NOT_ASSOCIATED ((NTSTATUS)0xC0000239L) -#define STATUS_CONNECTION_INVALID ((NTSTATUS)0xC000023AL) -#define STATUS_CONNECTION_ACTIVE ((NTSTATUS)0xC000023BL) -#define STATUS_NETWORK_UNREACHABLE ((NTSTATUS)0xC000023CL) -#define STATUS_HOST_UNREACHABLE ((NTSTATUS)0xC000023DL) -#define STATUS_PROTOCOL_UNREACHABLE ((NTSTATUS)0xC000023EL) -#define STATUS_PORT_UNREACHABLE ((NTSTATUS)0xC000023FL) -#define STATUS_REQUEST_ABORTED ((NTSTATUS)0xC0000240L) -#define STATUS_CONNECTION_ABORTED ((NTSTATUS)0xC0000241L) -#define STATUS_BAD_COMPRESSION_BUFFER ((NTSTATUS)0xC0000242L) -#define STATUS_USER_MAPPED_FILE ((NTSTATUS)0xC0000243L) -#define STATUS_AUDIT_FAILED ((NTSTATUS)0xC0000244L) -#define STATUS_TIMER_RESOLUTION_NOT_SET ((NTSTATUS)0xC0000245L) -#define STATUS_CONNECTION_COUNT_LIMIT ((NTSTATUS)0xC0000246L) -#define STATUS_LOGIN_TIME_RESTRICTION ((NTSTATUS)0xC0000247L) -#define STATUS_LOGIN_WKSTA_RESTRICTION ((NTSTATUS)0xC0000248L) -#define STATUS_IMAGE_MP_UP_MISMATCH ((NTSTATUS)0xC0000249L) -#define STATUS_INSUFFICIENT_LOGON_INFO ((NTSTATUS)0xC0000250L) -#define STATUS_BAD_DLL_ENTRYPOINT ((NTSTATUS)0xC0000251L) -#define STATUS_BAD_SERVICE_ENTRYPOINT ((NTSTATUS)0xC0000252L) -#define STATUS_LPC_REPLY_LOST ((NTSTATUS)0xC0000253L) -#define STATUS_IP_ADDRESS_CONFLICT1 ((NTSTATUS)0xC0000254L) -#define STATUS_IP_ADDRESS_CONFLICT2 ((NTSTATUS)0xC0000255L) -#define STATUS_REGISTRY_QUOTA_LIMIT ((NTSTATUS)0xC0000256L) -#define STATUS_PATH_NOT_COVERED ((NTSTATUS)0xC0000257L) -#define STATUS_NO_CALLBACK_ACTIVE ((NTSTATUS)0xC0000258L) -#define STATUS_LICENSE_QUOTA_EXCEEDED ((NTSTATUS)0xC0000259L) -#define STATUS_PWD_TOO_SHORT ((NTSTATUS)0xC000025AL) -#define STATUS_PWD_TOO_RECENT ((NTSTATUS)0xC000025BL) -#define STATUS_PWD_HISTORY_CONFLICT ((NTSTATUS)0xC000025CL) -#define STATUS_PLUGPLAY_NO_DEVICE ((NTSTATUS)0xC000025EL) -#define STATUS_UNSUPPORTED_COMPRESSION ((NTSTATUS)0xC000025FL) -#define STATUS_INVALID_HW_PROFILE ((NTSTATUS)0xC0000260L) -#define STATUS_INVALID_PLUGPLAY_DEVICE_PATH ((NTSTATUS)0xC0000261L) -#define STATUS_DRIVER_ORDINAL_NOT_FOUND ((NTSTATUS)0xC0000262L) -#define STATUS_DRIVER_ENTRYPOINT_NOT_FOUND ((NTSTATUS)0xC0000263L) -#define STATUS_RESOURCE_NOT_OWNED ((NTSTATUS)0xC0000264L) -#define STATUS_TOO_MANY_LINKS ((NTSTATUS)0xC0000265L) -#define STATUS_QUOTA_LIST_INCONSISTENT ((NTSTATUS)0xC0000266L) -#define STATUS_FILE_IS_OFFLINE ((NTSTATUS)0xC0000267L) -#define STATUS_EVALUATION_EXPIRATION ((NTSTATUS)0xC0000268L) -#define STATUS_ILLEGAL_DLL_RELOCATION ((NTSTATUS)0xC0000269L) -#define STATUS_LICENSE_VIOLATION ((NTSTATUS)0xC000026AL) -#define STATUS_DLL_INIT_FAILED_LOGOFF ((NTSTATUS)0xC000026BL) -#define STATUS_DRIVER_UNABLE_TO_LOAD ((NTSTATUS)0xC000026CL) -#define STATUS_DFS_UNAVAILABLE ((NTSTATUS)0xC000026DL) -#define STATUS_VOLUME_DISMOUNTED ((NTSTATUS)0xC000026EL) -#define STATUS_WX86_INTERNAL_ERROR ((NTSTATUS)0xC000026FL) -#define STATUS_WX86_FLOAT_STACK_CHECK ((NTSTATUS)0xC0000270L) -#define STATUS_VALIDATE_CONTINUE ((NTSTATUS)0xC0000271L) -#define STATUS_NO_MATCH ((NTSTATUS)0xC0000272L) -#define STATUS_NO_MORE_MATCHES ((NTSTATUS)0xC0000273L) -#define STATUS_NOT_A_REPARSE_POINT ((NTSTATUS)0xC0000275L) -#define STATUS_IO_REPARSE_TAG_INVALID ((NTSTATUS)0xC0000276L) -#define STATUS_IO_REPARSE_TAG_MISMATCH ((NTSTATUS)0xC0000277L) -#define STATUS_IO_REPARSE_DATA_INVALID ((NTSTATUS)0xC0000278L) -#define STATUS_IO_REPARSE_TAG_NOT_HANDLED ((NTSTATUS)0xC0000279L) -#define STATUS_REPARSE_POINT_NOT_RESOLVED ((NTSTATUS)0xC0000280L) -#define STATUS_DIRECTORY_IS_A_REPARSE_POINT ((NTSTATUS)0xC0000281L) -#define STATUS_RANGE_LIST_CONFLICT ((NTSTATUS)0xC0000282L) -#define STATUS_SOURCE_ELEMENT_EMPTY ((NTSTATUS)0xC0000283L) -#define STATUS_DESTINATION_ELEMENT_FULL ((NTSTATUS)0xC0000284L) -#define STATUS_ILLEGAL_ELEMENT_ADDRESS ((NTSTATUS)0xC0000285L) -#define STATUS_MAGAZINE_NOT_PRESENT ((NTSTATUS)0xC0000286L) -#define STATUS_REINITIALIZATION_NEEDED ((NTSTATUS)0xC0000287L) -#define STATUS_DEVICE_REQUIRES_CLEANING ((NTSTATUS)0x80000288L) -#define STATUS_DEVICE_DOOR_OPEN ((NTSTATUS)0x80000289L) -#define STATUS_ENCRYPTION_FAILED ((NTSTATUS)0xC000028AL) -#define STATUS_DECRYPTION_FAILED ((NTSTATUS)0xC000028BL) -#define STATUS_RANGE_NOT_FOUND ((NTSTATUS)0xC000028CL) -#define STATUS_NO_RECOVERY_POLICY ((NTSTATUS)0xC000028DL) -#define STATUS_NO_EFS ((NTSTATUS)0xC000028EL) -#define STATUS_WRONG_EFS ((NTSTATUS)0xC000028FL) -#define STATUS_NO_USER_KEYS ((NTSTATUS)0xC0000290L) -#define STATUS_FILE_NOT_ENCRYPTED ((NTSTATUS)0xC0000291L) -#define STATUS_NOT_EXPORT_FORMAT ((NTSTATUS)0xC0000292L) -#define STATUS_FILE_ENCRYPTED ((NTSTATUS)0xC0000293L) -#define STATUS_WAKE_SYSTEM ((NTSTATUS)0x40000294L) -#define STATUS_WMI_GUID_NOT_FOUND ((NTSTATUS)0xC0000295L) -#define STATUS_WMI_INSTANCE_NOT_FOUND ((NTSTATUS)0xC0000296L) -#define STATUS_WMI_ITEMID_NOT_FOUND ((NTSTATUS)0xC0000297L) -#define STATUS_WMI_TRY_AGAIN ((NTSTATUS)0xC0000298L) -#define STATUS_SHARED_POLICY ((NTSTATUS)0xC0000299L) -#define STATUS_POLICY_OBJECT_NOT_FOUND ((NTSTATUS)0xC000029AL) -#define STATUS_POLICY_ONLY_IN_DS ((NTSTATUS)0xC000029BL) -#define STATUS_VOLUME_NOT_UPGRADED ((NTSTATUS)0xC000029CL) -#define STATUS_REMOTE_STORAGE_NOT_ACTIVE ((NTSTATUS)0xC000029DL) -#define STATUS_REMOTE_STORAGE_MEDIA_ERROR ((NTSTATUS)0xC000029EL) -#define STATUS_NO_TRACKING_SERVICE ((NTSTATUS)0xC000029FL) -#define STATUS_SERVER_SID_MISMATCH ((NTSTATUS)0xC00002A0L) -#define STATUS_DS_NO_ATTRIBUTE_OR_VALUE ((NTSTATUS)0xC00002A1L) -#define STATUS_DS_INVALID_ATTRIBUTE_SYNTAX ((NTSTATUS)0xC00002A2L) -#define STATUS_DS_ATTRIBUTE_TYPE_UNDEFINED ((NTSTATUS)0xC00002A3L) -#define STATUS_DS_ATTRIBUTE_OR_VALUE_EXISTS ((NTSTATUS)0xC00002A4L) -#define STATUS_DS_BUSY ((NTSTATUS)0xC00002A5L) -#define STATUS_DS_UNAVAILABLE ((NTSTATUS)0xC00002A6L) -#define STATUS_DS_NO_RIDS_ALLOCATED ((NTSTATUS)0xC00002A7L) -#define STATUS_DS_NO_MORE_RIDS ((NTSTATUS)0xC00002A8L) -#define STATUS_DS_INCORRECT_ROLE_OWNER ((NTSTATUS)0xC00002A9L) -#define STATUS_DS_RIDMGR_INIT_ERROR ((NTSTATUS)0xC00002AAL) -#define STATUS_DS_OBJ_CLASS_VIOLATION ((NTSTATUS)0xC00002ABL) -#define STATUS_DS_CANT_ON_NON_LEAF ((NTSTATUS)0xC00002ACL) -#define STATUS_DS_CANT_ON_RDN ((NTSTATUS)0xC00002ADL) -#define STATUS_DS_CANT_MOD_OBJ_CLASS ((NTSTATUS)0xC00002AEL) -#define STATUS_DS_CROSS_DOM_MOVE_FAILED ((NTSTATUS)0xC00002AFL) -#define STATUS_DS_GC_NOT_AVAILABLE ((NTSTATUS)0xC00002B0L) -#define STATUS_DIRECTORY_SERVICE_REQUIRED ((NTSTATUS)0xC00002B1L) -#define STATUS_REPARSE_ATTRIBUTE_CONFLICT ((NTSTATUS)0xC00002B2L) -#define STATUS_CANT_ENABLE_DENY_ONLY ((NTSTATUS)0xC00002B3L) -#define STATUS_FLOAT_MULTIPLE_FAULTS ((NTSTATUS)0xC00002B4L) -#define STATUS_FLOAT_MULTIPLE_TRAPS ((NTSTATUS)0xC00002B5L) -#define STATUS_DEVICE_REMOVED ((NTSTATUS)0xC00002B6L) -#define STATUS_JOURNAL_DELETE_IN_PROGRESS ((NTSTATUS)0xC00002B7L) -#define STATUS_JOURNAL_NOT_ACTIVE ((NTSTATUS)0xC00002B8L) -#define STATUS_NOINTERFACE ((NTSTATUS)0xC00002B9L) -#define STATUS_DS_ADMIN_LIMIT_EXCEEDED ((NTSTATUS)0xC00002C1L) -#define STATUS_DRIVER_FAILED_SLEEP ((NTSTATUS)0xC00002C2L) -#define STATUS_MUTUAL_AUTHENTICATION_FAILED ((NTSTATUS)0xC00002C3L) -#define STATUS_CORRUPT_SYSTEM_FILE ((NTSTATUS)0xC00002C4L) -#define STATUS_DATATYPE_MISALIGNMENT_ERROR ((NTSTATUS)0xC00002C5L) -#define STATUS_WMI_READ_ONLY ((NTSTATUS)0xC00002C6L) -#define STATUS_WMI_SET_FAILURE ((NTSTATUS)0xC00002C7L) -#define STATUS_COMMITMENT_MINIMUM ((NTSTATUS)0xC00002C8L) -#define STATUS_REG_NAT_CONSUMPTION ((NTSTATUS)0xC00002C9L) -#define STATUS_TRANSPORT_FULL ((NTSTATUS)0xC00002CAL) -#define STATUS_DS_SAM_INIT_FAILURE ((NTSTATUS)0xC00002CBL) -#define STATUS_ONLY_IF_CONNECTED ((NTSTATUS)0xC00002CCL) -#define STATUS_DS_SENSITIVE_GROUP_VIOLATION ((NTSTATUS)0xC00002CDL) -#define STATUS_PNP_RESTART_ENUMERATION ((NTSTATUS)0xC00002CEL) -#define STATUS_JOURNAL_ENTRY_DELETED ((NTSTATUS)0xC00002CFL) -#define STATUS_DS_CANT_MOD_PRIMARYGROUPID ((NTSTATUS)0xC00002D0L) -#define STATUS_SYSTEM_IMAGE_BAD_SIGNATURE ((NTSTATUS)0xC00002D1L) -#define STATUS_PNP_REBOOT_REQUIRED ((NTSTATUS)0xC00002D2L) -#define STATUS_POWER_STATE_INVALID ((NTSTATUS)0xC00002D3L) -#define STATUS_DS_INVALID_GROUP_TYPE ((NTSTATUS)0xC00002D4L) -#define STATUS_DS_NO_NEST_GLOBALGROUP_IN_MIXEDDOMAIN ((NTSTATUS)0xC00002D5L) -#define STATUS_DS_NO_NEST_LOCALGROUP_IN_MIXEDDOMAIN ((NTSTATUS)0xC00002D6L) -#define STATUS_DS_GLOBAL_CANT_HAVE_LOCAL_MEMBER ((NTSTATUS)0xC00002D7L) -#define STATUS_DS_GLOBAL_CANT_HAVE_UNIVERSAL_MEMBER ((NTSTATUS)0xC00002D8L) -#define STATUS_DS_UNIVERSAL_CANT_HAVE_LOCAL_MEMBER ((NTSTATUS)0xC00002D9L) -#define STATUS_DS_GLOBAL_CANT_HAVE_CROSSDOMAIN_MEMBER ((NTSTATUS)0xC00002DAL) -#define STATUS_DS_LOCAL_CANT_HAVE_CROSSDOMAIN_LOCAL_MEMBER ((NTSTATUS)0xC00002DBL) -#define STATUS_DS_HAVE_PRIMARY_MEMBERS ((NTSTATUS)0xC00002DCL) -#define STATUS_WMI_NOT_SUPPORTED ((NTSTATUS)0xC00002DDL) -#define STATUS_INSUFFICIENT_POWER ((NTSTATUS)0xC00002DEL) -#define STATUS_SAM_NEED_BOOTKEY_PASSWORD ((NTSTATUS)0xC00002DFL) -#define STATUS_SAM_NEED_BOOTKEY_FLOPPY ((NTSTATUS)0xC00002E0L) -#define STATUS_DS_CANT_START ((NTSTATUS)0xC00002E1L) -#define STATUS_DS_INIT_FAILURE ((NTSTATUS)0xC00002E2L) -#define STATUS_SAM_INIT_FAILURE ((NTSTATUS)0xC00002E3L) -#define STATUS_DS_GC_REQUIRED ((NTSTATUS)0xC00002E4L) -#define STATUS_DS_LOCAL_MEMBER_OF_LOCAL_ONLY ((NTSTATUS)0xC00002E5L) -#define STATUS_DS_NO_FPO_IN_UNIVERSAL_GROUPS ((NTSTATUS)0xC00002E6L) -#define STATUS_DS_MACHINE_ACCOUNT_QUOTA_EXCEEDED ((NTSTATUS)0xC00002E7L) -#define STATUS_MULTIPLE_FAULT_VIOLATION ((NTSTATUS)0xC00002E8L) -#define STATUS_CURRENT_DOMAIN_NOT_ALLOWED ((NTSTATUS)0xC00002E9L) -#define STATUS_CANNOT_MAKE ((NTSTATUS)0xC00002EAL) -#define STATUS_SYSTEM_SHUTDOWN ((NTSTATUS)0xC00002EBL) -#define STATUS_DS_INIT_FAILURE_CONSOLE ((NTSTATUS)0xC00002ECL) -#define STATUS_DS_SAM_INIT_FAILURE_CONSOLE ((NTSTATUS)0xC00002EDL) -#define STATUS_UNFINISHED_CONTEXT_DELETED ((NTSTATUS)0xC00002EEL) -#define STATUS_NO_TGT_REPLY ((NTSTATUS)0xC00002EFL) -#define STATUS_OBJECTID_NOT_FOUND ((NTSTATUS)0xC00002F0L) -#define STATUS_NO_IP_ADDRESSES ((NTSTATUS)0xC00002F1L) -#define STATUS_WRONG_CREDENTIAL_HANDLE ((NTSTATUS)0xC00002F2L) -#define STATUS_CRYPTO_SYSTEM_INVALID ((NTSTATUS)0xC00002F3L) -#define STATUS_MAX_REFERRALS_EXCEEDED ((NTSTATUS)0xC00002F4L) -#define STATUS_MUST_BE_KDC ((NTSTATUS)0xC00002F5L) -#define STATUS_STRONG_CRYPTO_NOT_SUPPORTED ((NTSTATUS)0xC00002F6L) -#define STATUS_TOO_MANY_PRINCIPALS ((NTSTATUS)0xC00002F7L) -#define STATUS_NO_PA_DATA ((NTSTATUS)0xC00002F8L) -#define STATUS_PKINIT_NAME_MISMATCH ((NTSTATUS)0xC00002F9L) -#define STATUS_SMARTCARD_LOGON_REQUIRED ((NTSTATUS)0xC00002FAL) -#define STATUS_KDC_INVALID_REQUEST ((NTSTATUS)0xC00002FBL) -#define STATUS_KDC_UNABLE_TO_REFER ((NTSTATUS)0xC00002FCL) -#define STATUS_KDC_UNKNOWN_ETYPE ((NTSTATUS)0xC00002FDL) -#define STATUS_SHUTDOWN_IN_PROGRESS ((NTSTATUS)0xC00002FEL) -#define STATUS_SERVER_SHUTDOWN_IN_PROGRESS ((NTSTATUS)0xC00002FFL) -#define STATUS_NOT_SUPPORTED_ON_SBS ((NTSTATUS)0xC0000300L) -#define STATUS_WMI_GUID_DISCONNECTED ((NTSTATUS)0xC0000301L) -#define STATUS_WMI_ALREADY_DISABLED ((NTSTATUS)0xC0000302L) -#define STATUS_WMI_ALREADY_ENABLED ((NTSTATUS)0xC0000303L) -#define STATUS_MFT_TOO_FRAGMENTED ((NTSTATUS)0xC0000304L) -#define STATUS_COPY_PROTECTION_FAILURE ((NTSTATUS)0xC0000305L) -#define STATUS_CSS_AUTHENTICATION_FAILURE ((NTSTATUS)0xC0000306L) -#define STATUS_CSS_KEY_NOT_PRESENT ((NTSTATUS)0xC0000307L) -#define STATUS_CSS_KEY_NOT_ESTABLISHED ((NTSTATUS)0xC0000308L) -#define STATUS_CSS_SCRAMBLED_SECTOR ((NTSTATUS)0xC0000309L) -#define STATUS_CSS_REGION_MISMATCH ((NTSTATUS)0xC000030AL) -#define STATUS_CSS_RESETS_EXHAUSTED ((NTSTATUS)0xC000030BL) -#define STATUS_PKINIT_FAILURE ((NTSTATUS)0xC0000320L) -#define STATUS_SMARTCARD_SUBSYSTEM_FAILURE ((NTSTATUS)0xC0000321L) -#define STATUS_NO_KERB_KEY ((NTSTATUS)0xC0000322L) -#define STATUS_HOST_DOWN ((NTSTATUS)0xC0000350L) -#define STATUS_UNSUPPORTED_PREAUTH ((NTSTATUS)0xC0000351L) -#define STATUS_EFS_ALG_BLOB_TOO_BIG ((NTSTATUS)0xC0000352L) -#define STATUS_PORT_NOT_SET ((NTSTATUS)0xC0000353L) -#define STATUS_DEBUGGER_INACTIVE ((NTSTATUS)0xC0000354L) -#define STATUS_DS_VERSION_CHECK_FAILURE ((NTSTATUS)0xC0000355L) -#define STATUS_AUDITING_DISABLED ((NTSTATUS)0xC0000356L) -#define STATUS_PRENT4_MACHINE_ACCOUNT ((NTSTATUS)0xC0000357L) -#define STATUS_DS_AG_CANT_HAVE_UNIVERSAL_MEMBER ((NTSTATUS)0xC0000358L) -#define STATUS_INVALID_IMAGE_WIN_32 ((NTSTATUS)0xC0000359L) -#define STATUS_INVALID_IMAGE_WIN_64 ((NTSTATUS)0xC000035AL) -#define STATUS_BAD_BINDINGS ((NTSTATUS)0xC000035BL) -#define STATUS_NETWORK_SESSION_EXPIRED ((NTSTATUS)0xC000035CL) -#define STATUS_APPHELP_BLOCK ((NTSTATUS)0xC000035DL) -#define STATUS_ALL_SIDS_FILTERED ((NTSTATUS)0xC000035EL) -#define STATUS_NOT_SAFE_MODE_DRIVER ((NTSTATUS)0xC000035FL) -#define STATUS_ACCESS_DISABLED_BY_POLICY_DEFAULT ((NTSTATUS)0xC0000361L) -#define STATUS_ACCESS_DISABLED_BY_POLICY_PATH ((NTSTATUS)0xC0000362L) -#define STATUS_ACCESS_DISABLED_BY_POLICY_PUBLISHER ((NTSTATUS)0xC0000363L) -#define STATUS_ACCESS_DISABLED_BY_POLICY_OTHER ((NTSTATUS)0xC0000364L) -#define STATUS_FAILED_DRIVER_ENTRY ((NTSTATUS)0xC0000365L) -#define STATUS_DEVICE_ENUMERATION_ERROR ((NTSTATUS)0xC0000366L) -#define STATUS_WAIT_FOR_OPLOCK ((NTSTATUS)0x00000367L) -#define STATUS_MOUNT_POINT_NOT_RESOLVED ((NTSTATUS)0xC0000368L) -#define STATUS_INVALID_DEVICE_OBJECT_PARAMETER ((NTSTATUS)0xC0000369L) -#define STATUS_MCA_OCCURED ((NTSTATUS)0xC000036AL) -#define STATUS_DRIVER_BLOCKED_CRITICAL ((NTSTATUS)0xC000036BL) -#define STATUS_DRIVER_BLOCKED ((NTSTATUS)0xC000036CL) -#define STATUS_DRIVER_DATABASE_ERROR ((NTSTATUS)0xC000036DL) -#define STATUS_SYSTEM_HIVE_TOO_LARGE ((NTSTATUS)0xC000036EL) -#define STATUS_INVALID_IMPORT_OF_NON_DLL ((NTSTATUS)0xC000036FL) -#define STATUS_DS_SHUTTING_DOWN ((NTSTATUS)0x40000370L) -#define STATUS_SMARTCARD_WRONG_PIN ((NTSTATUS)0xC0000380L) -#define STATUS_SMARTCARD_CARD_BLOCKED ((NTSTATUS)0xC0000381L) -#define STATUS_SMARTCARD_CARD_NOT_AUTHENTICATED ((NTSTATUS)0xC0000382L) -#define STATUS_SMARTCARD_NO_CARD ((NTSTATUS)0xC0000383L) -#define STATUS_SMARTCARD_NO_KEY_CONTAINER ((NTSTATUS)0xC0000384L) -#define STATUS_SMARTCARD_NO_CERTIFICATE ((NTSTATUS)0xC0000385L) -#define STATUS_SMARTCARD_NO_KEYSET ((NTSTATUS)0xC0000386L) -#define STATUS_SMARTCARD_IO_ERROR ((NTSTATUS)0xC0000387L) -#define STATUS_DOWNGRADE_DETECTED ((NTSTATUS)0xC0000388L) -#define STATUS_SMARTCARD_CERT_REVOKED ((NTSTATUS)0xC0000389L) -#define STATUS_ISSUING_CA_UNTRUSTED ((NTSTATUS)0xC000038AL) -#define STATUS_REVOCATION_OFFLINE_C ((NTSTATUS)0xC000038BL) -#define STATUS_PKINIT_CLIENT_FAILURE ((NTSTATUS)0xC000038CL) -#define STATUS_SMARTCARD_CERT_EXPIRED ((NTSTATUS)0xC000038DL) -#define STATUS_DRIVER_FAILED_PRIOR_UNLOAD ((NTSTATUS)0xC000038EL) -#define STATUS_ASSERTION_FAILURE ((NTSTATUS)0xC0000420L) -#define STATUS_CALLBACK_POP_STACK ((NTSTATUS)0xC0000423L) -#define STATUS_WOW_ASSERTION ((NTSTATUS)0xC0009898L) -#define RPC_NT_INVALID_STRING_BINDING ((NTSTATUS)0xC0020001L) -#define RPC_NT_WRONG_KIND_OF_BINDING ((NTSTATUS)0xC0020002L) -#define RPC_NT_INVALID_BINDING ((NTSTATUS)0xC0020003L) -#define RPC_NT_PROTSEQ_NOT_SUPPORTED ((NTSTATUS)0xC0020004L) -#define RPC_NT_INVALID_RPC_PROTSEQ ((NTSTATUS)0xC0020005L) -#define RPC_NT_INVALID_STRING_UUID ((NTSTATUS)0xC0020006L) -#define RPC_NT_INVALID_ENDPOINT_FORMAT ((NTSTATUS)0xC0020007L) -#define RPC_NT_INVALID_NET_ADDR ((NTSTATUS)0xC0020008L) -#define RPC_NT_NO_ENDPOINT_FOUND ((NTSTATUS)0xC0020009L) -#define RPC_NT_INVALID_TIMEOUT ((NTSTATUS)0xC002000AL) -#define RPC_NT_OBJECT_NOT_FOUND ((NTSTATUS)0xC002000BL) -#define RPC_NT_ALREADY_REGISTERED ((NTSTATUS)0xC002000CL) -#define RPC_NT_TYPE_ALREADY_REGISTERED ((NTSTATUS)0xC002000DL) -#define RPC_NT_ALREADY_LISTENING ((NTSTATUS)0xC002000EL) -#define RPC_NT_NO_PROTSEQS_REGISTERED ((NTSTATUS)0xC002000FL) -#define RPC_NT_NOT_LISTENING ((NTSTATUS)0xC0020010L) -#define RPC_NT_UNKNOWN_MGR_TYPE ((NTSTATUS)0xC0020011L) -#define RPC_NT_UNKNOWN_IF ((NTSTATUS)0xC0020012L) -#define RPC_NT_NO_BINDINGS ((NTSTATUS)0xC0020013L) -#define RPC_NT_NO_PROTSEQS ((NTSTATUS)0xC0020014L) -#define RPC_NT_CANT_CREATE_ENDPOINT ((NTSTATUS)0xC0020015L) -#define RPC_NT_OUT_OF_RESOURCES ((NTSTATUS)0xC0020016L) -#define RPC_NT_SERVER_UNAVAILABLE ((NTSTATUS)0xC0020017L) -#define RPC_NT_SERVER_TOO_BUSY ((NTSTATUS)0xC0020018L) -#define RPC_NT_INVALID_NETWORK_OPTIONS ((NTSTATUS)0xC0020019L) -#define RPC_NT_NO_CALL_ACTIVE ((NTSTATUS)0xC002001AL) -#define RPC_NT_CALL_FAILED ((NTSTATUS)0xC002001BL) -#define RPC_NT_CALL_FAILED_DNE ((NTSTATUS)0xC002001CL) -#define RPC_NT_PROTOCOL_ERROR ((NTSTATUS)0xC002001DL) -#define RPC_NT_UNSUPPORTED_TRANS_SYN ((NTSTATUS)0xC002001FL) -#define RPC_NT_UNSUPPORTED_TYPE ((NTSTATUS)0xC0020021L) -#define RPC_NT_INVALID_TAG ((NTSTATUS)0xC0020022L) -#define RPC_NT_INVALID_BOUND ((NTSTATUS)0xC0020023L) -#define RPC_NT_NO_ENTRY_NAME ((NTSTATUS)0xC0020024L) -#define RPC_NT_INVALID_NAME_SYNTAX ((NTSTATUS)0xC0020025L) -#define RPC_NT_UNSUPPORTED_NAME_SYNTAX ((NTSTATUS)0xC0020026L) -#define RPC_NT_UUID_NO_ADDRESS ((NTSTATUS)0xC0020028L) -#define RPC_NT_DUPLICATE_ENDPOINT ((NTSTATUS)0xC0020029L) -#define RPC_NT_UNKNOWN_AUTHN_TYPE ((NTSTATUS)0xC002002AL) -#define RPC_NT_MAX_CALLS_TOO_SMALL ((NTSTATUS)0xC002002BL) -#define RPC_NT_STRING_TOO_LONG ((NTSTATUS)0xC002002CL) -#define RPC_NT_PROTSEQ_NOT_FOUND ((NTSTATUS)0xC002002DL) -#define RPC_NT_PROCNUM_OUT_OF_RANGE ((NTSTATUS)0xC002002EL) -#define RPC_NT_BINDING_HAS_NO_AUTH ((NTSTATUS)0xC002002FL) -#define RPC_NT_UNKNOWN_AUTHN_SERVICE ((NTSTATUS)0xC0020030L) -#define RPC_NT_UNKNOWN_AUTHN_LEVEL ((NTSTATUS)0xC0020031L) -#define RPC_NT_INVALID_AUTH_IDENTITY ((NTSTATUS)0xC0020032L) -#define RPC_NT_UNKNOWN_AUTHZ_SERVICE ((NTSTATUS)0xC0020033L) -#define EPT_NT_INVALID_ENTRY ((NTSTATUS)0xC0020034L) -#define EPT_NT_CANT_PERFORM_OP ((NTSTATUS)0xC0020035L) -#define EPT_NT_NOT_REGISTERED ((NTSTATUS)0xC0020036L) -#define RPC_NT_NOTHING_TO_EXPORT ((NTSTATUS)0xC0020037L) -#define RPC_NT_INCOMPLETE_NAME ((NTSTATUS)0xC0020038L) -#define RPC_NT_INVALID_VERS_OPTION ((NTSTATUS)0xC0020039L) -#define RPC_NT_NO_MORE_MEMBERS ((NTSTATUS)0xC002003AL) -#define RPC_NT_NOT_ALL_OBJS_UNEXPORTED ((NTSTATUS)0xC002003BL) -#define RPC_NT_INTERFACE_NOT_FOUND ((NTSTATUS)0xC002003CL) -#define RPC_NT_ENTRY_ALREADY_EXISTS ((NTSTATUS)0xC002003DL) -#define RPC_NT_ENTRY_NOT_FOUND ((NTSTATUS)0xC002003EL) -#define RPC_NT_NAME_SERVICE_UNAVAILABLE ((NTSTATUS)0xC002003FL) -#define RPC_NT_INVALID_NAF_ID ((NTSTATUS)0xC0020040L) -#define RPC_NT_CANNOT_SUPPORT ((NTSTATUS)0xC0020041L) -#define RPC_NT_NO_CONTEXT_AVAILABLE ((NTSTATUS)0xC0020042L) -#define RPC_NT_INTERNAL_ERROR ((NTSTATUS)0xC0020043L) -#define RPC_NT_ZERO_DIVIDE ((NTSTATUS)0xC0020044L) -#define RPC_NT_ADDRESS_ERROR ((NTSTATUS)0xC0020045L) -#define RPC_NT_FP_DIV_ZERO ((NTSTATUS)0xC0020046L) -#define RPC_NT_FP_UNDERFLOW ((NTSTATUS)0xC0020047L) -#define RPC_NT_FP_OVERFLOW ((NTSTATUS)0xC0020048L) -#define RPC_NT_NO_MORE_ENTRIES ((NTSTATUS)0xC0030001L) -#define RPC_NT_SS_CHAR_TRANS_OPEN_FAIL ((NTSTATUS)0xC0030002L) -#define RPC_NT_SS_CHAR_TRANS_SHORT_FILE ((NTSTATUS)0xC0030003L) -#define RPC_NT_SS_IN_NULL_CONTEXT ((NTSTATUS)0xC0030004L) -#define RPC_NT_SS_CONTEXT_MISMATCH ((NTSTATUS)0xC0030005L) -#define RPC_NT_SS_CONTEXT_DAMAGED ((NTSTATUS)0xC0030006L) -#define RPC_NT_SS_HANDLES_MISMATCH ((NTSTATUS)0xC0030007L) -#define RPC_NT_SS_CANNOT_GET_CALL_HANDLE ((NTSTATUS)0xC0030008L) -#define RPC_NT_NULL_REF_POINTER ((NTSTATUS)0xC0030009L) -#define RPC_NT_ENUM_VALUE_OUT_OF_RANGE ((NTSTATUS)0xC003000AL) -#define RPC_NT_BYTE_COUNT_TOO_SMALL ((NTSTATUS)0xC003000BL) -#define RPC_NT_BAD_STUB_DATA ((NTSTATUS)0xC003000CL) -#define RPC_NT_CALL_IN_PROGRESS ((NTSTATUS)0xC0020049L) -#define RPC_NT_NO_MORE_BINDINGS ((NTSTATUS)0xC002004AL) -#define RPC_NT_GROUP_MEMBER_NOT_FOUND ((NTSTATUS)0xC002004BL) -#define EPT_NT_CANT_CREATE ((NTSTATUS)0xC002004CL) -#define RPC_NT_INVALID_OBJECT ((NTSTATUS)0xC002004DL) -#define RPC_NT_NO_INTERFACES ((NTSTATUS)0xC002004FL) -#define RPC_NT_CALL_CANCELLED ((NTSTATUS)0xC0020050L) -#define RPC_NT_BINDING_INCOMPLETE ((NTSTATUS)0xC0020051L) -#define RPC_NT_COMM_FAILURE ((NTSTATUS)0xC0020052L) -#define RPC_NT_UNSUPPORTED_AUTHN_LEVEL ((NTSTATUS)0xC0020053L) -#define RPC_NT_NO_PRINC_NAME ((NTSTATUS)0xC0020054L) -#define RPC_NT_NOT_RPC_ERROR ((NTSTATUS)0xC0020055L) -#define RPC_NT_UUID_LOCAL_ONLY ((NTSTATUS)0x40020056L) -#define RPC_NT_SEC_PKG_ERROR ((NTSTATUS)0xC0020057L) -#define RPC_NT_NOT_CANCELLED ((NTSTATUS)0xC0020058L) -#define RPC_NT_INVALID_ES_ACTION ((NTSTATUS)0xC0030059L) -#define RPC_NT_WRONG_ES_VERSION ((NTSTATUS)0xC003005AL) -#define RPC_NT_WRONG_STUB_VERSION ((NTSTATUS)0xC003005BL) -#define RPC_NT_INVALID_PIPE_OBJECT ((NTSTATUS)0xC003005CL) -#define RPC_NT_INVALID_PIPE_OPERATION ((NTSTATUS)0xC003005DL) -#define RPC_NT_WRONG_PIPE_VERSION ((NTSTATUS)0xC003005EL) -#define RPC_NT_PIPE_CLOSED ((NTSTATUS)0xC003005FL) -#define RPC_NT_PIPE_DISCIPLINE_ERROR ((NTSTATUS)0xC0030060L) -#define RPC_NT_PIPE_EMPTY ((NTSTATUS)0xC0030061L) -#define RPC_NT_INVALID_ASYNC_HANDLE ((NTSTATUS)0xC0020062L) -#define RPC_NT_INVALID_ASYNC_CALL ((NTSTATUS)0xC0020063L) -#define RPC_NT_SEND_INCOMPLETE ((NTSTATUS)0x400200AFL) -#define STATUS_ACPI_INVALID_OPCODE ((NTSTATUS)0xC0140001L) -#define STATUS_ACPI_STACK_OVERFLOW ((NTSTATUS)0xC0140002L) -#define STATUS_ACPI_ASSERT_FAILED ((NTSTATUS)0xC0140003L) -#define STATUS_ACPI_INVALID_INDEX ((NTSTATUS)0xC0140004L) -#define STATUS_ACPI_INVALID_ARGUMENT ((NTSTATUS)0xC0140005L) -#define STATUS_ACPI_FATAL ((NTSTATUS)0xC0140006L) -#define STATUS_ACPI_INVALID_SUPERNAME ((NTSTATUS)0xC0140007L) -#define STATUS_ACPI_INVALID_ARGTYPE ((NTSTATUS)0xC0140008L) -#define STATUS_ACPI_INVALID_OBJTYPE ((NTSTATUS)0xC0140009L) -#define STATUS_ACPI_INVALID_TARGETTYPE ((NTSTATUS)0xC014000AL) -#define STATUS_ACPI_INCORRECT_ARGUMENT_COUNT ((NTSTATUS)0xC014000BL) -#define STATUS_ACPI_ADDRESS_NOT_MAPPED ((NTSTATUS)0xC014000CL) -#define STATUS_ACPI_INVALID_EVENTTYPE ((NTSTATUS)0xC014000DL) -#define STATUS_ACPI_HANDLER_COLLISION ((NTSTATUS)0xC014000EL) -#define STATUS_ACPI_INVALID_DATA ((NTSTATUS)0xC014000FL) -#define STATUS_ACPI_INVALID_REGION ((NTSTATUS)0xC0140010L) -#define STATUS_ACPI_INVALID_ACCESS_SIZE ((NTSTATUS)0xC0140011L) -#define STATUS_ACPI_ACQUIRE_GLOBAL_LOCK ((NTSTATUS)0xC0140012L) -#define STATUS_ACPI_ALREADY_INITIALIZED ((NTSTATUS)0xC0140013L) -#define STATUS_ACPI_NOT_INITIALIZED ((NTSTATUS)0xC0140014L) -#define STATUS_ACPI_INVALID_MUTEX_LEVEL ((NTSTATUS)0xC0140015L) -#define STATUS_ACPI_MUTEX_NOT_OWNED ((NTSTATUS)0xC0140016L) -#define STATUS_ACPI_MUTEX_NOT_OWNER ((NTSTATUS)0xC0140017L) -#define STATUS_ACPI_RS_ACCESS ((NTSTATUS)0xC0140018L) -#define STATUS_ACPI_INVALID_TABLE ((NTSTATUS)0xC0140019L) -#define STATUS_ACPI_REG_HANDLER_FAILED ((NTSTATUS)0xC0140020L) -#define STATUS_ACPI_POWER_REQUEST_FAILED ((NTSTATUS)0xC0140021L) -#define STATUS_CTX_WINSTATION_NAME_INVALID ((NTSTATUS)0xC00A0001L) -#define STATUS_CTX_INVALID_PD ((NTSTATUS)0xC00A0002L) -#define STATUS_CTX_PD_NOT_FOUND ((NTSTATUS)0xC00A0003L) -#define STATUS_CTX_CDM_CONNECT ((NTSTATUS)0x400A0004L) -#define STATUS_CTX_CDM_DISCONNECT ((NTSTATUS)0x400A0005L) -#define STATUS_CTX_CLOSE_PENDING ((NTSTATUS)0xC00A0006L) -#define STATUS_CTX_NO_OUTBUF ((NTSTATUS)0xC00A0007L) -#define STATUS_CTX_MODEM_INF_NOT_FOUND ((NTSTATUS)0xC00A0008L) -#define STATUS_CTX_INVALID_MODEMNAME ((NTSTATUS)0xC00A0009L) -#define STATUS_CTX_RESPONSE_ERROR ((NTSTATUS)0xC00A000AL) -#define STATUS_CTX_MODEM_RESPONSE_TIMEOUT ((NTSTATUS)0xC00A000BL) -#define STATUS_CTX_MODEM_RESPONSE_NO_CARRIER ((NTSTATUS)0xC00A000CL) -#define STATUS_CTX_MODEM_RESPONSE_NO_DIALTONE ((NTSTATUS)0xC00A000DL) -#define STATUS_CTX_MODEM_RESPONSE_BUSY ((NTSTATUS)0xC00A000EL) -#define STATUS_CTX_MODEM_RESPONSE_VOICE ((NTSTATUS)0xC00A000FL) -#define STATUS_CTX_TD_ERROR ((NTSTATUS)0xC00A0010L) -#define STATUS_CTX_LICENSE_CLIENT_INVALID ((NTSTATUS)0xC00A0012L) -#define STATUS_CTX_LICENSE_NOT_AVAILABLE ((NTSTATUS)0xC00A0013L) -#define STATUS_CTX_LICENSE_EXPIRED ((NTSTATUS)0xC00A0014L) -#define STATUS_CTX_WINSTATION_NOT_FOUND ((NTSTATUS)0xC00A0015L) -#define STATUS_CTX_WINSTATION_NAME_COLLISION ((NTSTATUS)0xC00A0016L) -#define STATUS_CTX_WINSTATION_BUSY ((NTSTATUS)0xC00A0017L) -#define STATUS_CTX_BAD_VIDEO_MODE ((NTSTATUS)0xC00A0018L) -#define STATUS_CTX_GRAPHICS_INVALID ((NTSTATUS)0xC00A0022L) -#define STATUS_CTX_NOT_CONSOLE ((NTSTATUS)0xC00A0024L) -#define STATUS_CTX_CLIENT_QUERY_TIMEOUT ((NTSTATUS)0xC00A0026L) -#define STATUS_CTX_CONSOLE_DISCONNECT ((NTSTATUS)0xC00A0027L) -#define STATUS_CTX_CONSOLE_CONNECT ((NTSTATUS)0xC00A0028L) -#define STATUS_CTX_SHADOW_DENIED ((NTSTATUS)0xC00A002AL) -#define STATUS_CTX_WINSTATION_ACCESS_DENIED ((NTSTATUS)0xC00A002BL) -#define STATUS_CTX_INVALID_WD ((NTSTATUS)0xC00A002EL) -#define STATUS_CTX_WD_NOT_FOUND ((NTSTATUS)0xC00A002FL) -#define STATUS_CTX_SHADOW_INVALID ((NTSTATUS)0xC00A0030L) -#define STATUS_CTX_SHADOW_DISABLED ((NTSTATUS)0xC00A0031L) -#define STATUS_RDP_PROTOCOL_ERROR ((NTSTATUS)0xC00A0032L) -#define STATUS_CTX_CLIENT_LICENSE_NOT_SET ((NTSTATUS)0xC00A0033L) -#define STATUS_CTX_CLIENT_LICENSE_IN_USE ((NTSTATUS)0xC00A0034L) -#define STATUS_CTX_SHADOW_ENDED_BY_MODE_CHANGE ((NTSTATUS)0xC00A0035L) -#define STATUS_CTX_SHADOW_NOT_RUNNING ((NTSTATUS)0xC00A0036L) -#define STATUS_PNP_BAD_MPS_TABLE ((NTSTATUS)0xC0040035L) -#define STATUS_PNP_TRANSLATION_FAILED ((NTSTATUS)0xC0040036L) -#define STATUS_PNP_IRQ_TRANSLATION_FAILED ((NTSTATUS)0xC0040037L) -#define STATUS_SXS_SECTION_NOT_FOUND ((NTSTATUS)0xC0150001L) -#define STATUS_SXS_CANT_GEN_ACTCTX ((NTSTATUS)0xC0150002L) -#define STATUS_SXS_INVALID_ACTCTXDATA_FORMAT ((NTSTATUS)0xC0150003L) -#define STATUS_SXS_ASSEMBLY_NOT_FOUND ((NTSTATUS)0xC0150004L) -#define STATUS_SXS_MANIFEST_FORMAT_ERROR ((NTSTATUS)0xC0150005L) -#define STATUS_SXS_MANIFEST_PARSE_ERROR ((NTSTATUS)0xC0150006L) -#define STATUS_SXS_ACTIVATION_CONTEXT_DISABLED ((NTSTATUS)0xC0150007L) -#define STATUS_SXS_KEY_NOT_FOUND ((NTSTATUS)0xC0150008L) -#define STATUS_SXS_VERSION_CONFLICT ((NTSTATUS)0xC0150009L) -#define STATUS_SXS_WRONG_SECTION_TYPE ((NTSTATUS)0xC015000AL) -#define STATUS_SXS_THREAD_QUERIES_DISABLED ((NTSTATUS)0xC015000BL) -#define STATUS_SXS_ASSEMBLY_MISSING ((NTSTATUS)0xC015000CL) -#define STATUS_SXS_RELEASE_ACTIVATION_CONTEXT ((NTSTATUS)0x4015000DL) -#define STATUS_SXS_PROCESS_DEFAULT_ALREADY_SET ((NTSTATUS)0xC015000EL) -#define STATUS_SXS_EARLY_DEACTIVATION ((NTSTATUS)0xC015000FL) -#define STATUS_SXS_INVALID_DEACTIVATION ((NTSTATUS)0xC0150010L) -#define STATUS_SXS_MULTIPLE_DEACTIVATION ((NTSTATUS)0xC0150011L) -#define STATUS_SXS_SYSTEM_DEFAULT_ACTIVATION_CONTEXT_EMPTY ((NTSTATUS)0xC0150012L) -#define STATUS_SXS_PROCESS_TERMINATION_REQUESTED ((NTSTATUS)0xC0150013L) -#define STATUS_CLUSTER_INVALID_NODE ((NTSTATUS)0xC0130001L) -#define STATUS_CLUSTER_NODE_EXISTS ((NTSTATUS)0xC0130002L) -#define STATUS_CLUSTER_JOIN_IN_PROGRESS ((NTSTATUS)0xC0130003L) -#define STATUS_CLUSTER_NODE_NOT_FOUND ((NTSTATUS)0xC0130004L) -#define STATUS_CLUSTER_LOCAL_NODE_NOT_FOUND ((NTSTATUS)0xC0130005L) -#define STATUS_CLUSTER_NETWORK_EXISTS ((NTSTATUS)0xC0130006L) -#define STATUS_CLUSTER_NETWORK_NOT_FOUND ((NTSTATUS)0xC0130007L) -#define STATUS_CLUSTER_NETINTERFACE_EXISTS ((NTSTATUS)0xC0130008L) -#define STATUS_CLUSTER_NETINTERFACE_NOT_FOUND ((NTSTATUS)0xC0130009L) -#define STATUS_CLUSTER_INVALID_REQUEST ((NTSTATUS)0xC013000AL) -#define STATUS_CLUSTER_INVALID_NETWORK_PROVIDER ((NTSTATUS)0xC013000BL) -#define STATUS_CLUSTER_NODE_DOWN ((NTSTATUS)0xC013000CL) -#define STATUS_CLUSTER_NODE_UNREACHABLE ((NTSTATUS)0xC013000DL) -#define STATUS_CLUSTER_NODE_NOT_MEMBER ((NTSTATUS)0xC013000EL) -#define STATUS_CLUSTER_JOIN_NOT_IN_PROGRESS ((NTSTATUS)0xC013000FL) -#define STATUS_CLUSTER_INVALID_NETWORK ((NTSTATUS)0xC0130010L) -#define STATUS_CLUSTER_NO_NET_ADAPTERS ((NTSTATUS)0xC0130011L) -#define STATUS_CLUSTER_NODE_UP ((NTSTATUS)0xC0130012L) -#define STATUS_CLUSTER_NODE_PAUSED ((NTSTATUS)0xC0130013L) -#define STATUS_CLUSTER_NODE_NOT_PAUSED ((NTSTATUS)0xC0130014L) -#define STATUS_CLUSTER_NO_SECURITY_CONTEXT ((NTSTATUS)0xC0130015L) -#define STATUS_CLUSTER_NETWORK_NOT_INTERNAL ((NTSTATUS)0xC0130016L) -#define STATUS_CLUSTER_POISONED ((NTSTATUS)0xC0130017L) +#define STATUS_SUCCESS ((NTSTATUS)0x00000000) +#endif +#define STATUS_SEVERITY_SUCCESS 0x0 +#define STATUS_SEVERITY_INFORMATIONAL 0x1 +#define STATUS_SEVERITY_WARNING 0x2 +#define STATUS_SEVERITY_ERROR 0x3 -/* -* Debug codes -*/ +#define STATUS_WAIT_1 ((NTSTATUS)0x00000001) +#define STATUS_WAIT_2 ((NTSTATUS)0x00000002) +#define STATUS_WAIT_3 ((NTSTATUS)0x00000003) +#define STATUS_WAIT_63 ((NTSTATUS)0x0000003f) +#define STATUS_ABANDONED ((NTSTATUS)0x00000080) +#define STATUS_ABANDONED_WAIT_63 ((NTSTATUS)0x000000BF) +#define STATUS_USER_APC ((NTSTATUS)0x000000C0) +#define STATUS_KERNEL_APC ((NTSTATUS)0x00000100) +#define STATUS_ALERTED ((NTSTATUS)0x00000101) +#define STATUS_TIMEOUT ((NTSTATUS)0x00000102) +#define STATUS_PENDING ((NTSTATUS)0x00000103) +#define STATUS_REPARSE ((NTSTATUS)0x00000104) +#define STATUS_MORE_ENTRIES ((NTSTATUS)0x00000105) +#define STATUS_NOT_ALL_ASSIGNED ((NTSTATUS)0x00000106) +#define STATUS_SOME_NOT_MAPPED ((NTSTATUS)0x00000107) +#define STATUS_OPLOCK_BREAK_IN_PROGRESS ((NTSTATUS)0x00000108) +#define STATUS_VOLUME_MOUNTED ((NTSTATUS)0x00000109) +#define STATUS_RXACT_COMMITTED ((NTSTATUS)0x0000010A) +#define STATUS_NOTIFY_CLEANUP ((NTSTATUS)0x0000010B) +#define STATUS_NOTIFY_ENUM_DIR ((NTSTATUS)0x0000010C) +#define STATUS_NO_QUOTAS_FOR_ACCOUNT ((NTSTATUS)0x0000010D) +#define STATUS_PRIMARY_TRANSPORT_CONNECT_FAILED ((NTSTATUS)0x0000010E) +#define STATUS_PAGE_FAULT_TRANSITION ((NTSTATUS)0x00000110) +#define STATUS_PAGE_FAULT_DEMAND_ZERO ((NTSTATUS)0x00000111) +#define STATUS_PAGE_FAULT_COPY_ON_WRITE ((NTSTATUS)0x00000112) +#define STATUS_PAGE_FAULT_GUARD_PAGE ((NTSTATUS)0x00000113) +#define STATUS_PAGE_FAULT_PAGING_FILE ((NTSTATUS)0x00000114) +#define STATUS_CACHE_PAGE_LOCKED ((NTSTATUS)0x00000115) +#define STATUS_CRASH_DUMP ((NTSTATUS)0x00000116) +#define STATUS_BUFFER_ALL_ZEROS ((NTSTATUS)0x00000117) +#define STATUS_REPARSE_OBJECT ((NTSTATUS)0x00000118) +#define STATUS_RESOURCE_REQUIREMENTS_CHANGED ((NTSTATUS)0x00000119) +#define STATUS_TRANSLATION_COMPLETE ((NTSTATUS)0x00000120) +#define STATUS_DS_MEMBERSHIP_EVALUATED_LOCALLY ((NTSTATUS)0x00000121) +#define STATUS_NOTHING_TO_TERMINATE ((NTSTATUS)0x00000122) +#define STATUS_PROCESS_NOT_IN_JOB ((NTSTATUS)0x00000123) +#define STATUS_PROCESS_IN_JOB ((NTSTATUS)0x00000124) +#define STATUS_VOLSNAP_HIBERNATE_READY ((NTSTATUS)0x00000125) +#define STATUS_FSFILTER_OP_COMPLETED_SUCCESSFULLY ((NTSTATUS)0x00000126) -#define DBG_EXCEPTION_HANDLED ((NTSTATUS)0x00010001) -#define DBG_CONTINUE ((NTSTATUS)0x00010002) -#define DBG_REPLY_LATER ((NTSTATUS)0x40010001) -#define DBG_UNABLE_TO_PROVIDE_HANDLE ((NTSTATUS)0x40010002) -#define DBG_TERMINATE_THREAD ((NTSTATUS)0x40010003) -#define DBG_TERMINATE_PROCESS ((NTSTATUS)0x40010004) -#define DBG_CONTROL_C ((NTSTATUS)0x40010005) -#define DBG_PRINTEXCEPTION_C ((NTSTATUS)0x40010006) -#define DBG_RIPEXCEPTION ((NTSTATUS)0x40010007) -#define DBG_CONTROL_BREAK ((NTSTATUS)0x40010008) -#define DBG_COMMAND_EXCEPTION ((NTSTATUS)0x40010009) -#define DBG_EXCEPTION_NOT_HANDLED ((NTSTATUS)0x80010001) -#define DBG_NO_STATE_CHANGE ((NTSTATUS)0xC0010001) -#define DBG_APP_NOT_IDLE ((NTSTATUS)0xC0010002) +#define STATUS_OBJECT_NAME_EXISTS ((NTSTATUS)0x40000000) +#define STATUS_THREAD_WAS_SUSPENDED ((NTSTATUS)0x40000001) +#define STATUS_WORKING_SET_LIMIT_RANGE ((NTSTATUS)0x40000002) +#define STATUS_IMAGE_NOT_AT_BASE ((NTSTATUS)0x40000003) +#define STATUS_RXACT_STATE_CREATED ((NTSTATUS)0x40000004) +#define STATUS_SEGMENT_NOTIFICATION ((NTSTATUS)0x40000005) +#define STATUS_LOCAL_USER_SESSION_KEY ((NTSTATUS)0x40000006) +#define STATUS_BAD_CURRENT_DIRECTORY ((NTSTATUS)0x40000007) +#define STATUS_SERIAL_MORE_WRITES ((NTSTATUS)0x40000008) +#define STATUS_REGISTRY_RECOVERED ((NTSTATUS)0x40000009) +#define STATUS_FT_READ_RECOVERY_FROM_BACKUP ((NTSTATUS)0x4000000A) +#define STATUS_FT_WRITE_RECOVERY ((NTSTATUS)0x4000000B) +#define STATUS_SERIAL_COUNTER_TIMEOUT ((NTSTATUS)0x4000000C) +#define STATUS_NULL_LM_PASSWORD ((NTSTATUS)0x4000000D) +#define STATUS_IMAGE_MACHINE_TYPE_MISMATCH ((NTSTATUS)0x4000000E) +#define STATUS_RECEIVE_PARTIAL ((NTSTATUS)0x4000000F) +#define STATUS_RECEIVE_EXPEDITED ((NTSTATUS)0x40000010) +#define STATUS_RECEIVE_PARTIAL_EXPEDITED ((NTSTATUS)0x40000011) +#define STATUS_EVENT_DONE ((NTSTATUS)0x40000012) +#define STATUS_EVENT_PENDING ((NTSTATUS)0x40000013) +#define STATUS_CHECKING_FILE_SYSTEM ((NTSTATUS)0x40000014) +#define STATUS_FATAL_APP_EXIT ((NTSTATUS)0x40000015) +#define STATUS_PREDEFINED_HANDLE ((NTSTATUS)0x40000016) +#define STATUS_WAS_UNLOCKED ((NTSTATUS)0x40000017) +#define STATUS_SERVICE_NOTIFICATION ((NTSTATUS)0x40000018) +#define STATUS_WAS_LOCKED ((NTSTATUS)0x40000019) +#define STATUS_LOG_HARD_ERROR ((NTSTATUS)0x4000001A) +#define STATUS_ALREADY_WIN32 ((NTSTATUS)0x4000001B) +#define STATUS_WX86_UNSIMULATE ((NTSTATUS)0x4000001C) +#define STATUS_WX86_CONTINUE ((NTSTATUS)0x4000001D) +#define STATUS_WX86_SINGLE_STEP ((NTSTATUS)0x4000001E) +#define STATUS_WX86_BREAKPOINT ((NTSTATUS)0x4000001F) +#define STATUS_WX86_EXCEPTION_CONTINUE ((NTSTATUS)0x40000020) +#define STATUS_WX86_EXCEPTION_LASTCHANCE ((NTSTATUS)0x40000021) +#define STATUS_WX86_EXCEPTION_CHAIN ((NTSTATUS)0x40000022) +#define STATUS_IMAGE_MACHINE_TYPE_MISMATCH_EXE ((NTSTATUS)0x40000023) +#define STATUS_NO_YIELD_PERFORMED ((NTSTATUS)0x40000024) +#define STATUS_TIMER_RESUME_IGNORED ((NTSTATUS)0x40000025) +#define STATUS_ARBITRATION_UNHANDLED ((NTSTATUS)0x40000026) +#define STATUS_CARDBUS_NOT_SUPPORTED ((NTSTATUS)0x40000027) +#define STATUS_WX86_CREATEWX86TIB ((NTSTATUS)0x40000028) +#define STATUS_MP_PROCESSOR_MISMATCH ((NTSTATUS)0x40000029) +#define STATUS_HIBERNATED ((NTSTATUS)0x4000002A) +#define STATUS_RESUME_HIBERNATION ((NTSTATUS)0x4000002B) +#define STATUS_FIRMWARE_UPDATED ((NTSTATUS)0x4000002C) +#define STATUS_WAKE_SYSTEM ((NTSTATUS)0x40000294) +#define STATUS_DS_SHUTTING_DOWN ((NTSTATUS)0x40000370) + +#define RPC_NT_UUID_LOCAL_ONLY ((NTSTATUS)0x40020056) +#define RPC_NT_SEND_INCOMPLETE ((NTSTATUS)0x400200AF) + +#define STATUS_CTX_CDM_CONNECT ((NTSTATUS)0x400A0004) +#define STATUS_CTX_CDM_DISCONNECT ((NTSTATUS)0x400A0005) + +#define STATUS_SXS_RELEASE_ACTIVATION_CONTEXT ((NTSTATUS)0x4015000D) + +#define STATUS_GUARD_PAGE_VIOLATION ((NTSTATUS)0x80000001) +#define STATUS_DATATYPE_MISALIGNMENT ((NTSTATUS)0x80000002) +#define STATUS_BREAKPOINT ((NTSTATUS)0x80000003) +#define STATUS_SINGLE_STEP ((NTSTATUS)0x80000004) +#define STATUS_BUFFER_OVERFLOW ((NTSTATUS)0x80000005) +#define STATUS_NO_MORE_FILES ((NTSTATUS)0x80000006) +#define STATUS_WAKE_SYSTEM_DEBUGGER ((NTSTATUS)0x80000007) + +#define STATUS_HANDLES_CLOSED ((NTSTATUS)0x8000000A) +#define STATUS_NO_INHERITANCE ((NTSTATUS)0x8000000B) +#define STATUS_GUID_SUBSTITUTION_MADE ((NTSTATUS)0x8000000C) +#define STATUS_PARTIAL_COPY ((NTSTATUS)0x8000000D) +#define STATUS_DEVICE_PAPER_EMPTY ((NTSTATUS)0x8000000E) +#define STATUS_DEVICE_POWERED_OFF ((NTSTATUS)0x8000000F) +#define STATUS_DEVICE_OFF_LINE ((NTSTATUS)0x80000010) +#define STATUS_DEVICE_BUSY ((NTSTATUS)0x80000011) +#define STATUS_NO_MORE_EAS ((NTSTATUS)0x80000012) +#define STATUS_INVALID_EA_NAME ((NTSTATUS)0x80000013) +#define STATUS_EA_LIST_INCONSISTENT ((NTSTATUS)0x80000014) +#define STATUS_INVALID_EA_FLAG ((NTSTATUS)0x80000015) +#define STATUS_VERIFY_REQUIRED ((NTSTATUS)0x80000016) +#define STATUS_EXTRANEOUS_INFORMATION ((NTSTATUS)0x80000017) +#define STATUS_RXACT_COMMIT_NECESSARY ((NTSTATUS)0x80000018) +#define STATUS_NO_MORE_ENTRIES ((NTSTATUS)0x8000001A) +#define STATUS_FILEMARK_DETECTED ((NTSTATUS)0x8000001B) +#define STATUS_MEDIA_CHANGED ((NTSTATUS)0x8000001C) +#define STATUS_BUS_RESET ((NTSTATUS)0x8000001D) +#define STATUS_END_OF_MEDIA ((NTSTATUS)0x8000001E) +#define STATUS_BEGINNING_OF_MEDIA ((NTSTATUS)0x8000001F) +#define STATUS_MEDIA_CHECK ((NTSTATUS)0x80000020) +#define STATUS_SETMARK_DETECTED ((NTSTATUS)0x80000021) +#define STATUS_NO_DATA_DETECTED ((NTSTATUS)0x80000022) +#define STATUS_REDIRECTOR_HAS_OPEN_HANDLES ((NTSTATUS)0x80000023) +#define STATUS_SERVER_HAS_OPEN_HANDLES ((NTSTATUS)0x80000024) +#define STATUS_ALREADY_DISCONNECTED ((NTSTATUS)0x80000025) +#define STATUS_LONGJUMP ((NTSTATUS)0x80000026) +#define STATUS_CLEANER_CARTRIDGE_INSTALLED ((NTSTATUS)0x80000027) +#define STATUS_PLUGPLAY_QUERY_VETOED ((NTSTATUS)0x80000028) +#define STATUS_UNWIND_CONSOLIDATE ((NTSTATUS)0x80000029) +#define STATUS_REGISTRY_HIVE_RECOVERED ((NTSTATUS)0x8000002A) +#define STATUS_DLL_MIGHT_BE_INSECURE ((NTSTATUS)0x8000002B) +#define STATUS_DLL_MIGHT_BE_INCOMPATIBLE ((NTSTATUS)0x8000002C) + +#define STATUS_DEVICE_REQUIRES_CLEANING ((NTSTATUS)0x80000288) +#define STATUS_DEVICE_DOOR_OPEN ((NTSTATUS)0x80000289) + +#define STATUS_CLUSTER_NODE_ALREADY_UP ((NTSTATUS)0x80130001) +#define STATUS_CLUSTER_NODE_ALREADY_DOWN ((NTSTATUS)0x80130002) +#define STATUS_CLUSTER_NETWORK_ALREADY_ONLINE ((NTSTATUS)0x80130003) +#define STATUS_CLUSTER_NETWORK_ALREADY_OFFLINE ((NTSTATUS)0x80130004) +#define STATUS_CLUSTER_NODE_ALREADY_MEMBER ((NTSTATUS)0x80130005) + +#define STATUS_WAIT_0 ((NTSTATUS)0x00000000) +#define STATUS_UNSUCCESSFUL ((NTSTATUS)0xC0000001) +#define STATUS_NOT_IMPLEMENTED ((NTSTATUS)0xC0000002) +#define STATUS_INVALID_INFO_CLASS ((NTSTATUS)0xC0000003) +#define STATUS_INFO_LENGTH_MISMATCH ((NTSTATUS)0xC0000004) +#define STATUS_ACCESS_VIOLATION ((NTSTATUS)0xC0000005) +#define STATUS_IN_PAGE_ERROR ((NTSTATUS)0xC0000006) +#define STATUS_PAGEFILE_QUOTA ((NTSTATUS)0xC0000007) +#define STATUS_INVALID_HANDLE ((NTSTATUS)0xC0000008) +#define STATUS_BAD_INITIAL_STACK ((NTSTATUS)0xC0000009) +#define STATUS_BAD_INITIAL_PC ((NTSTATUS)0xC000000A) +#define STATUS_INVALID_CID ((NTSTATUS)0xC000000B) +#define STATUS_TIMER_NOT_CANCELED ((NTSTATUS)0xC000000C) +#define STATUS_INVALID_PARAMETER ((NTSTATUS)0xC000000D) +#define STATUS_NO_SUCH_DEVICE ((NTSTATUS)0xC000000E) +#define STATUS_NO_SUCH_FILE ((NTSTATUS)0xC000000F) +#define STATUS_INVALID_DEVICE_REQUEST ((NTSTATUS)0xC0000010) +#define STATUS_END_OF_FILE ((NTSTATUS)0xC0000011) +#define STATUS_WRONG_VOLUME ((NTSTATUS)0xC0000012) +#define STATUS_NO_MEDIA_IN_DEVICE ((NTSTATUS)0xC0000013) +#define STATUS_UNRECOGNIZED_MEDIA ((NTSTATUS)0xC0000014) +#define STATUS_NONEXISTENT_SECTOR ((NTSTATUS)0xC0000015) +#define STATUS_MORE_PROCESSING_REQUIRED ((NTSTATUS)0xC0000016) +#define STATUS_NO_MEMORY ((NTSTATUS)0xC0000017) +#define STATUS_CONFLICTING_ADDRESSES ((NTSTATUS)0xC0000018) +#define STATUS_NOT_MAPPED_VIEW ((NTSTATUS)0xC0000019) +#define STATUS_UNABLE_TO_FREE_VM ((NTSTATUS)0xC000001A) +#define STATUS_UNABLE_TO_DELETE_SECTION ((NTSTATUS)0xC000001B) +#define STATUS_INVALID_SYSTEM_SERVICE ((NTSTATUS)0xC000001C) +#define STATUS_ILLEGAL_INSTRUCTION ((NTSTATUS)0xC000001D) +#define STATUS_INVALID_LOCK_SEQUENCE ((NTSTATUS)0xC000001E) +#define STATUS_INVALID_VIEW_SIZE ((NTSTATUS)0xC000001F) +#define STATUS_INVALID_FILE_FOR_SECTION ((NTSTATUS)0xC0000020) +#define STATUS_ALREADY_COMMITTED ((NTSTATUS)0xC0000021) +#define STATUS_ACCESS_DENIED ((NTSTATUS)0xC0000022) +#define STATUS_BUFFER_TOO_SMALL ((NTSTATUS)0xC0000023) +#define STATUS_OBJECT_TYPE_MISMATCH ((NTSTATUS)0xC0000024) +#define STATUS_NONCONTINUABLE_EXCEPTION ((NTSTATUS)0xC0000025) +#define STATUS_INVALID_DISPOSITION ((NTSTATUS)0xC0000026) +#define STATUS_UNWIND ((NTSTATUS)0xC0000027) +#define STATUS_BAD_STACK ((NTSTATUS)0xC0000028) +#define STATUS_INVALID_UNWIND_TARGET ((NTSTATUS)0xC0000029) +#define STATUS_NOT_LOCKED ((NTSTATUS)0xC000002A) +#define STATUS_PARITY_ERROR ((NTSTATUS)0xC000002B) +#define STATUS_UNABLE_TO_DECOMMIT_VM ((NTSTATUS)0xC000002C) +#define STATUS_NOT_COMMITTED ((NTSTATUS)0xC000002D) +#define STATUS_INVALID_PORT_ATTRIBUTES ((NTSTATUS)0xC000002E) +#define STATUS_PORT_MESSAGE_TOO_LONG ((NTSTATUS)0xC000002F) +#define STATUS_INVALID_PARAMETER_MIX ((NTSTATUS)0xC0000030) +#define STATUS_INVALID_QUOTA_LOWER ((NTSTATUS)0xC0000031) +#define STATUS_DISK_CORRUPT_ERROR ((NTSTATUS)0xC0000032) +#define STATUS_OBJECT_NAME_INVALID ((NTSTATUS)0xC0000033) +#define STATUS_OBJECT_NAME_NOT_FOUND ((NTSTATUS)0xC0000034) +#define STATUS_OBJECT_NAME_COLLISION ((NTSTATUS)0xC0000035) +#define STATUS_PORT_DISCONNECTED ((NTSTATUS)0xC0000037) +#define STATUS_DEVICE_ALREADY_ATTACHED ((NTSTATUS)0xC0000038) +#define STATUS_OBJECT_PATH_INVALID ((NTSTATUS)0xC0000039) +#define STATUS_OBJECT_PATH_NOT_FOUND ((NTSTATUS)0xC000003A) +#define STATUS_OBJECT_PATH_SYNTAX_BAD ((NTSTATUS)0xC000003B) +#define STATUS_DATA_OVERRUN ((NTSTATUS)0xC000003C) +#define STATUS_DATA_LATE_ERROR ((NTSTATUS)0xC000003D) +#define STATUS_DATA_ERROR ((NTSTATUS)0xC000003E) +#define STATUS_CRC_ERROR ((NTSTATUS)0xC000003F) +#define STATUS_SECTION_TOO_BIG ((NTSTATUS)0xC0000040) +#define STATUS_PORT_CONNECTION_REFUSED ((NTSTATUS)0xC0000041) +#define STATUS_INVALID_PORT_HANDLE ((NTSTATUS)0xC0000042) +#define STATUS_SHARING_VIOLATION ((NTSTATUS)0xC0000043) +#define STATUS_QUOTA_EXCEEDED ((NTSTATUS)0xC0000044) +#define STATUS_INVALID_PAGE_PROTECTION ((NTSTATUS)0xC0000045) +#define STATUS_MUTANT_NOT_OWNED ((NTSTATUS)0xC0000046) +#define STATUS_SEMAPHORE_LIMIT_EXCEEDED ((NTSTATUS)0xC0000047) +#define STATUS_PORT_ALREADY_SET ((NTSTATUS)0xC0000048) +#define STATUS_SECTION_NOT_IMAGE ((NTSTATUS)0xC0000049) +#define STATUS_SUSPEND_COUNT_EXCEEDED ((NTSTATUS)0xC000004A) +#define STATUS_THREAD_IS_TERMINATING ((NTSTATUS)0xC000004B) +#define STATUS_BAD_WORKING_SET_LIMIT ((NTSTATUS)0xC000004C) +#define STATUS_INCOMPATIBLE_FILE_MAP ((NTSTATUS)0xC000004D) +#define STATUS_SECTION_PROTECTION ((NTSTATUS)0xC000004E) +#define STATUS_EAS_NOT_SUPPORTED ((NTSTATUS)0xC000004F) +#define STATUS_EA_TOO_LARGE ((NTSTATUS)0xC0000050) +#define STATUS_NONEXISTENT_EA_ENTRY ((NTSTATUS)0xC0000051) +#define STATUS_NO_EAS_ON_FILE ((NTSTATUS)0xC0000052) +#define STATUS_EA_CORRUPT_ERROR ((NTSTATUS)0xC0000053) +#define STATUS_FILE_LOCK_CONFLICT ((NTSTATUS)0xC0000054) +#define STATUS_LOCK_NOT_GRANTED ((NTSTATUS)0xC0000055) +#define STATUS_DELETE_PENDING ((NTSTATUS)0xC0000056) +#define STATUS_CTL_FILE_NOT_SUPPORTED ((NTSTATUS)0xC0000057) +#define STATUS_UNKNOWN_REVISION ((NTSTATUS)0xC0000058) +#define STATUS_REVISION_MISMATCH ((NTSTATUS)0xC0000059) +#define STATUS_INVALID_OWNER ((NTSTATUS)0xC000005A) +#define STATUS_INVALID_PRIMARY_GROUP ((NTSTATUS)0xC000005B) +#define STATUS_NO_IMPERSONATION_TOKEN ((NTSTATUS)0xC000005C) +#define STATUS_CANT_DISABLE_MANDATORY ((NTSTATUS)0xC000005D) +#define STATUS_NO_LOGON_SERVERS ((NTSTATUS)0xC000005E) +#define STATUS_NO_SUCH_LOGON_SESSION ((NTSTATUS)0xC000005F) +#define STATUS_NO_SUCH_PRIVILEGE ((NTSTATUS)0xC0000060) +#define STATUS_PRIVILEGE_NOT_HELD ((NTSTATUS)0xC0000061) +#define STATUS_INVALID_ACCOUNT_NAME ((NTSTATUS)0xC0000062) +#define STATUS_USER_EXISTS ((NTSTATUS)0xC0000063) +#define STATUS_NO_SUCH_USER ((NTSTATUS)0xC0000064) +#define STATUS_GROUP_EXISTS ((NTSTATUS)0xC0000065) +#define STATUS_NO_SUCH_GROUP ((NTSTATUS)0xC0000066) +#define STATUS_MEMBER_IN_GROUP ((NTSTATUS)0xC0000067) +#define STATUS_MEMBER_NOT_IN_GROUP ((NTSTATUS)0xC0000068) +#define STATUS_LAST_ADMIN ((NTSTATUS)0xC0000069) +#define STATUS_WRONG_PASSWORD ((NTSTATUS)0xC000006A) +#define STATUS_ILL_FORMED_PASSWORD ((NTSTATUS)0xC000006B) +#define STATUS_PASSWORD_RESTRICTION ((NTSTATUS)0xC000006C) +#define STATUS_LOGON_FAILURE ((NTSTATUS)0xC000006D) +#define STATUS_ACCOUNT_RESTRICTION ((NTSTATUS)0xC000006E) +#define STATUS_INVALID_LOGON_HOURS ((NTSTATUS)0xC000006F) +#define STATUS_INVALID_WORKSTATION ((NTSTATUS)0xC0000070) +#define STATUS_PASSWORD_EXPIRED ((NTSTATUS)0xC0000071) +#define STATUS_ACCOUNT_DISABLED ((NTSTATUS)0xC0000072) +#define STATUS_NONE_MAPPED ((NTSTATUS)0xC0000073) +#define STATUS_TOO_MANY_LUIDS_REQUESTED ((NTSTATUS)0xC0000074) +#define STATUS_LUIDS_EXHAUSTED ((NTSTATUS)0xC0000075) +#define STATUS_INVALID_SUB_AUTHORITY ((NTSTATUS)0xC0000076) +#define STATUS_INVALID_ACL ((NTSTATUS)0xC0000077) +#define STATUS_INVALID_SID ((NTSTATUS)0xC0000078) +#define STATUS_INVALID_SECURITY_DESCR ((NTSTATUS)0xC0000079) +#define STATUS_PROCEDURE_NOT_FOUND ((NTSTATUS)0xC000007A) +#define STATUS_INVALID_IMAGE_FORMAT ((NTSTATUS)0xC000007B) +#define STATUS_NO_TOKEN ((NTSTATUS)0xC000007C) +#define STATUS_BAD_INHERITANCE_ACL ((NTSTATUS)0xC000007D) +#define STATUS_RANGE_NOT_LOCKED ((NTSTATUS)0xC000007E) +#define STATUS_DISK_FULL ((NTSTATUS)0xC000007F) +#define STATUS_SERVER_DISABLED ((NTSTATUS)0xC0000080) +#define STATUS_SERVER_NOT_DISABLED ((NTSTATUS)0xC0000081) +#define STATUS_TOO_MANY_GUIDS_REQUESTED ((NTSTATUS)0xC0000082) +#define STATUS_GUIDS_EXHAUSTED ((NTSTATUS)0xC0000083) +#define STATUS_INVALID_ID_AUTHORITY ((NTSTATUS)0xC0000084) +#define STATUS_AGENTS_EXHAUSTED ((NTSTATUS)0xC0000085) +#define STATUS_INVALID_VOLUME_LABEL ((NTSTATUS)0xC0000086) +#define STATUS_SECTION_NOT_EXTENDED ((NTSTATUS)0xC0000087) +#define STATUS_NOT_MAPPED_DATA ((NTSTATUS)0xC0000088) +#define STATUS_RESOURCE_DATA_NOT_FOUND ((NTSTATUS)0xC0000089) +#define STATUS_RESOURCE_TYPE_NOT_FOUND ((NTSTATUS)0xC000008A) +#define STATUS_RESOURCE_NAME_NOT_FOUND ((NTSTATUS)0xC000008B) +#define STATUS_ARRAY_BOUNDS_EXCEEDED ((NTSTATUS)0xC000008C) +#define STATUS_FLOAT_DENORMAL_OPERAND ((NTSTATUS)0xC000008D) +#define STATUS_FLOAT_DIVIDE_BY_ZERO ((NTSTATUS)0xC000008E) +#define STATUS_FLOAT_INEXACT_RESULT ((NTSTATUS)0xC000008F) +#define STATUS_FLOAT_INVALID_OPERATION ((NTSTATUS)0xC0000090) +#define STATUS_FLOAT_OVERFLOW ((NTSTATUS)0xC0000091) +#define STATUS_FLOAT_STACK_CHECK ((NTSTATUS)0xC0000092) +#define STATUS_FLOAT_UNDERFLOW ((NTSTATUS)0xC0000093) +#define STATUS_INTEGER_DIVIDE_BY_ZERO ((NTSTATUS)0xC0000094) +#define STATUS_INTEGER_OVERFLOW ((NTSTATUS)0xC0000095) +#define STATUS_PRIVILEGED_INSTRUCTION ((NTSTATUS)0xC0000096) +#define STATUS_TOO_MANY_PAGING_FILES ((NTSTATUS)0xC0000097) +#define STATUS_FILE_INVALID ((NTSTATUS)0xC0000098) +#define STATUS_ALLOTTED_SPACE_EXCEEDED ((NTSTATUS)0xC0000099) +#define STATUS_INSUFFICIENT_RESOURCES ((NTSTATUS)0xC000009A) +#define STATUS_DFS_EXIT_PATH_FOUND ((NTSTATUS)0xC000009B) +#define STATUS_DEVICE_DATA_ERROR ((NTSTATUS)0xC000009C) +#define STATUS_DEVICE_NOT_CONNECTED ((NTSTATUS)0xC000009D) +#define STATUS_DEVICE_POWER_FAILURE ((NTSTATUS)0xC000009E) +#define STATUS_FREE_VM_NOT_AT_BASE ((NTSTATUS)0xC000009F) +#define STATUS_MEMORY_NOT_ALLOCATED ((NTSTATUS)0xC00000A0) +#define STATUS_WORKING_SET_QUOTA ((NTSTATUS)0xC00000A1) +#define STATUS_MEDIA_WRITE_PROTECTED ((NTSTATUS)0xC00000A2) +#define STATUS_DEVICE_NOT_READY ((NTSTATUS)0xC00000A3) +#define STATUS_INVALID_GROUP_ATTRIBUTES ((NTSTATUS)0xC00000A4) +#define STATUS_BAD_IMPERSONATION_LEVEL ((NTSTATUS)0xC00000A5) +#define STATUS_CANT_OPEN_ANONYMOUS ((NTSTATUS)0xC00000A6) +#define STATUS_BAD_VALIDATION_CLASS ((NTSTATUS)0xC00000A7) +#define STATUS_BAD_TOKEN_TYPE ((NTSTATUS)0xC00000A8) +#define STATUS_BAD_MASTER_BOOT_RECORD ((NTSTATUS)0xC00000A9) +#define STATUS_INSTRUCTION_MISALIGNMENT ((NTSTATUS)0xC00000AA) +#define STATUS_INSTANCE_NOT_AVAILABLE ((NTSTATUS)0xC00000AB) +#define STATUS_PIPE_NOT_AVAILABLE ((NTSTATUS)0xC00000AC) +#define STATUS_INVALID_PIPE_STATE ((NTSTATUS)0xC00000AD) +#define STATUS_PIPE_BUSY ((NTSTATUS)0xC00000AE) +#define STATUS_ILLEGAL_FUNCTION ((NTSTATUS)0xC00000AF) +#define STATUS_PIPE_DISCONNECTED ((NTSTATUS)0xC00000B0) +#define STATUS_PIPE_CLOSING ((NTSTATUS)0xC00000B1) +#define STATUS_PIPE_CONNECTED ((NTSTATUS)0xC00000B2) +#define STATUS_PIPE_LISTENING ((NTSTATUS)0xC00000B3) +#define STATUS_INVALID_READ_MODE ((NTSTATUS)0xC00000B4) +#define STATUS_IO_TIMEOUT ((NTSTATUS)0xC00000B5) +#define STATUS_FILE_FORCED_CLOSED ((NTSTATUS)0xC00000B6) +#define STATUS_PROFILING_NOT_STARTED ((NTSTATUS)0xC00000B7) +#define STATUS_PROFILING_NOT_STOPPED ((NTSTATUS)0xC00000B8) +#define STATUS_COULD_NOT_INTERPRET ((NTSTATUS)0xC00000B9) +#define STATUS_FILE_IS_A_DIRECTORY ((NTSTATUS)0xC00000BA) +#define STATUS_NOT_SUPPORTED ((NTSTATUS)0xC00000BB) +#define STATUS_REMOTE_NOT_LISTENING ((NTSTATUS)0xC00000BC) +#define STATUS_DUPLICATE_NAME ((NTSTATUS)0xC00000BD) +#define STATUS_BAD_NETWORK_PATH ((NTSTATUS)0xC00000BE) +#define STATUS_NETWORK_BUSY ((NTSTATUS)0xC00000BF) +#define STATUS_DEVICE_DOES_NOT_EXIST ((NTSTATUS)0xC00000C0) +#define STATUS_TOO_MANY_COMMANDS ((NTSTATUS)0xC00000C1) +#define STATUS_ADAPTER_HARDWARE_ERROR ((NTSTATUS)0xC00000C2) +#define STATUS_INVALID_NETWORK_RESPONSE ((NTSTATUS)0xC00000C3) +#define STATUS_UNEXPECTED_NETWORK_ERROR ((NTSTATUS)0xC00000C4) +#define STATUS_BAD_REMOTE_ADAPTER ((NTSTATUS)0xC00000C5) +#define STATUS_PRINT_QUEUE_FULL ((NTSTATUS)0xC00000C6) +#define STATUS_NO_SPOOL_SPACE ((NTSTATUS)0xC00000C7) +#define STATUS_PRINT_CANCELLED ((NTSTATUS)0xC00000C8) +#define STATUS_NETWORK_NAME_DELETED ((NTSTATUS)0xC00000C9) +#define STATUS_NETWORK_ACCESS_DENIED ((NTSTATUS)0xC00000CA) +#define STATUS_BAD_DEVICE_TYPE ((NTSTATUS)0xC00000CB) +#define STATUS_BAD_NETWORK_NAME ((NTSTATUS)0xC00000CC) +#define STATUS_TOO_MANY_NAMES ((NTSTATUS)0xC00000CD) +#define STATUS_TOO_MANY_SESSIONS ((NTSTATUS)0xC00000CE) +#define STATUS_SHARING_PAUSED ((NTSTATUS)0xC00000CF) +#define STATUS_REQUEST_NOT_ACCEPTED ((NTSTATUS)0xC00000D0) +#define STATUS_REDIRECTOR_PAUSED ((NTSTATUS)0xC00000D1) +#define STATUS_NET_WRITE_FAULT ((NTSTATUS)0xC00000D2) +#define STATUS_PROFILING_AT_LIMIT ((NTSTATUS)0xC00000D3) +#define STATUS_NOT_SAME_DEVICE ((NTSTATUS)0xC00000D4) +#define STATUS_FILE_RENAMED ((NTSTATUS)0xC00000D5) +#define STATUS_VIRTUAL_CIRCUIT_CLOSED ((NTSTATUS)0xC00000D6) +#define STATUS_NO_SECURITY_ON_OBJECT ((NTSTATUS)0xC00000D7) +#define STATUS_CANT_WAIT ((NTSTATUS)0xC00000D8) +#define STATUS_PIPE_EMPTY ((NTSTATUS)0xC00000D9) +#define STATUS_CANT_ACCESS_DOMAIN_INFO ((NTSTATUS)0xC00000DA) +#define STATUS_CANT_TERMINATE_SELF ((NTSTATUS)0xC00000DB) +#define STATUS_INVALID_SERVER_STATE ((NTSTATUS)0xC00000DC) +#define STATUS_INVALID_DOMAIN_STATE ((NTSTATUS)0xC00000DD) +#define STATUS_INVALID_DOMAIN_ROLE ((NTSTATUS)0xC00000DE) +#define STATUS_NO_SUCH_DOMAIN ((NTSTATUS)0xC00000DF) +#define STATUS_DOMAIN_EXISTS ((NTSTATUS)0xC00000E0) +#define STATUS_DOMAIN_LIMIT_EXCEEDED ((NTSTATUS)0xC00000E1) +#define STATUS_OPLOCK_NOT_GRANTED ((NTSTATUS)0xC00000E2) +#define STATUS_INVALID_OPLOCK_PROTOCOL ((NTSTATUS)0xC00000E3) +#define STATUS_INTERNAL_DB_CORRUPTION ((NTSTATUS)0xC00000E4) +#define STATUS_INTERNAL_ERROR ((NTSTATUS)0xC00000E5) +#define STATUS_GENERIC_NOT_MAPPED ((NTSTATUS)0xC00000E6) +#define STATUS_BAD_DESCRIPTOR_FORMAT ((NTSTATUS)0xC00000E7) +#define STATUS_INVALID_USER_BUFFER ((NTSTATUS)0xC00000E8) +#define STATUS_UNEXPECTED_IO_ERROR ((NTSTATUS)0xC00000E9) +#define STATUS_UNEXPECTED_MM_CREATE_ERR ((NTSTATUS)0xC00000EA) +#define STATUS_UNEXPECTED_MM_MAP_ERROR ((NTSTATUS)0xC00000EB) +#define STATUS_UNEXPECTED_MM_EXTEND_ERR ((NTSTATUS)0xC00000EC) +#define STATUS_NOT_LOGON_PROCESS ((NTSTATUS)0xC00000ED) +#define STATUS_LOGON_SESSION_EXISTS ((NTSTATUS)0xC00000EE) +#define STATUS_INVALID_PARAMETER_1 ((NTSTATUS)0xC00000EF) +#define STATUS_INVALID_PARAMETER_2 ((NTSTATUS)0xC00000F0) +#define STATUS_INVALID_PARAMETER_3 ((NTSTATUS)0xC00000F1) +#define STATUS_INVALID_PARAMETER_4 ((NTSTATUS)0xC00000F2) +#define STATUS_INVALID_PARAMETER_5 ((NTSTATUS)0xC00000F3) +#define STATUS_INVALID_PARAMETER_6 ((NTSTATUS)0xC00000F4) +#define STATUS_INVALID_PARAMETER_7 ((NTSTATUS)0xC00000F5) +#define STATUS_INVALID_PARAMETER_8 ((NTSTATUS)0xC00000F6) +#define STATUS_INVALID_PARAMETER_9 ((NTSTATUS)0xC00000F7) +#define STATUS_INVALID_PARAMETER_10 ((NTSTATUS)0xC00000F8) +#define STATUS_INVALID_PARAMETER_11 ((NTSTATUS)0xC00000F9) +#define STATUS_INVALID_PARAMETER_12 ((NTSTATUS)0xC00000FA) +#define STATUS_REDIRECTOR_NOT_STARTED ((NTSTATUS)0xC00000FB) +#define STATUS_REDIRECTOR_STARTED ((NTSTATUS)0xC00000FC) +#define STATUS_STACK_OVERFLOW ((NTSTATUS)0xC00000FD) +#define STATUS_NO_SUCH_PACKAGE ((NTSTATUS)0xC00000FE) +#define STATUS_BAD_FUNCTION_TABLE ((NTSTATUS)0xC00000FF) +#define STATUS_VARIABLE_NOT_FOUND ((NTSTATUS)0xC0000100) +#define STATUS_DIRECTORY_NOT_EMPTY ((NTSTATUS)0xC0000101) +#define STATUS_FILE_CORRUPT_ERROR ((NTSTATUS)0xC0000102) +#define STATUS_NOT_A_DIRECTORY ((NTSTATUS)0xC0000103) +#define STATUS_BAD_LOGON_SESSION_STATE ((NTSTATUS)0xC0000104) +#define STATUS_LOGON_SESSION_COLLISION ((NTSTATUS)0xC0000105) +#define STATUS_NAME_TOO_LONG ((NTSTATUS)0xC0000106) +#define STATUS_FILES_OPEN ((NTSTATUS)0xC0000107) +#define STATUS_CONNECTION_IN_USE ((NTSTATUS)0xC0000108) +#define STATUS_MESSAGE_NOT_FOUND ((NTSTATUS)0xC0000109) +#define STATUS_PROCESS_IS_TERMINATING ((NTSTATUS)0xC000010A) +#define STATUS_INVALID_LOGON_TYPE ((NTSTATUS)0xC000010B) +#define STATUS_NO_GUID_TRANSLATION ((NTSTATUS)0xC000010C) +#define STATUS_CANNOT_IMPERSONATE ((NTSTATUS)0xC000010D) +#define STATUS_IMAGE_ALREADY_LOADED ((NTSTATUS)0xC000010E) +#define STATUS_ABIOS_NOT_PRESENT ((NTSTATUS)0xC000010F) +#define STATUS_ABIOS_LID_NOT_EXIST ((NTSTATUS)0xC0000110) +#define STATUS_ABIOS_LID_ALREADY_OWNED ((NTSTATUS)0xC0000111) +#define STATUS_ABIOS_NOT_LID_OWNER ((NTSTATUS)0xC0000112) +#define STATUS_ABIOS_INVALID_COMMAND ((NTSTATUS)0xC0000113) +#define STATUS_ABIOS_INVALID_LID ((NTSTATUS)0xC0000114) +#define STATUS_ABIOS_SELECTOR_NOT_AVAILABLE ((NTSTATUS)0xC0000115) +#define STATUS_ABIOS_INVALID_SELECTOR ((NTSTATUS)0xC0000116) +#define STATUS_NO_LDT ((NTSTATUS)0xC0000117) +#define STATUS_INVALID_LDT_SIZE ((NTSTATUS)0xC0000118) +#define STATUS_INVALID_LDT_OFFSET ((NTSTATUS)0xC0000119) +#define STATUS_INVALID_LDT_DESCRIPTOR ((NTSTATUS)0xC000011A) +#define STATUS_INVALID_IMAGE_NE_FORMAT ((NTSTATUS)0xC000011B) +#define STATUS_RXACT_INVALID_STATE ((NTSTATUS)0xC000011C) +#define STATUS_RXACT_COMMIT_FAILURE ((NTSTATUS)0xC000011D) +#define STATUS_MAPPED_FILE_SIZE_ZERO ((NTSTATUS)0xC000011E) +#define STATUS_TOO_MANY_OPENED_FILES ((NTSTATUS)0xC000011F) +#define STATUS_CANCELLED ((NTSTATUS)0xC0000120) +#define STATUS_CANNOT_DELETE ((NTSTATUS)0xC0000121) +#define STATUS_INVALID_COMPUTER_NAME ((NTSTATUS)0xC0000122) +#define STATUS_FILE_DELETED ((NTSTATUS)0xC0000123) +#define STATUS_SPECIAL_ACCOUNT ((NTSTATUS)0xC0000124) +#define STATUS_SPECIAL_GROUP ((NTSTATUS)0xC0000125) +#define STATUS_SPECIAL_USER ((NTSTATUS)0xC0000126) +#define STATUS_MEMBERS_PRIMARY_GROUP ((NTSTATUS)0xC0000127) +#define STATUS_FILE_CLOSED ((NTSTATUS)0xC0000128) +#define STATUS_TOO_MANY_THREADS ((NTSTATUS)0xC0000129) +#define STATUS_THREAD_NOT_IN_PROCESS ((NTSTATUS)0xC000012A) +#define STATUS_TOKEN_ALREADY_IN_USE ((NTSTATUS)0xC000012B) +#define STATUS_PAGEFILE_QUOTA_EXCEEDED ((NTSTATUS)0xC000012C) +#define STATUS_COMMITMENT_LIMIT ((NTSTATUS)0xC000012D) +#define STATUS_INVALID_IMAGE_LE_FORMAT ((NTSTATUS)0xC000012E) +#define STATUS_INVALID_IMAGE_NOT_MZ ((NTSTATUS)0xC000012F) +#define STATUS_INVALID_IMAGE_PROTECT ((NTSTATUS)0xC0000130) +#define STATUS_INVALID_IMAGE_WIN_16 ((NTSTATUS)0xC0000131) +#define STATUS_LOGON_SERVER_CONFLICT ((NTSTATUS)0xC0000132) +#define STATUS_TIME_DIFFERENCE_AT_DC ((NTSTATUS)0xC0000133) +#define STATUS_SYNCHRONIZATION_REQUIRED ((NTSTATUS)0xC0000134) +#define STATUS_DLL_NOT_FOUND ((NTSTATUS)0xC0000135) +#define STATUS_OPEN_FAILED ((NTSTATUS)0xC0000136) +#define STATUS_IO_PRIVILEGE_FAILED ((NTSTATUS)0xC0000137) +#define STATUS_ORDINAL_NOT_FOUND ((NTSTATUS)0xC0000138) +#define STATUS_ENTRYPOINT_NOT_FOUND ((NTSTATUS)0xC0000139) +#define STATUS_CONTROL_C_EXIT ((NTSTATUS)0xC000013A) +#define STATUS_LOCAL_DISCONNECT ((NTSTATUS)0xC000013B) +#define STATUS_REMOTE_DISCONNECT ((NTSTATUS)0xC000013C) +#define STATUS_REMOTE_RESOURCES ((NTSTATUS)0xC000013D) +#define STATUS_LINK_FAILED ((NTSTATUS)0xC000013E) +#define STATUS_LINK_TIMEOUT ((NTSTATUS)0xC000013F) +#define STATUS_INVALID_CONNECTION ((NTSTATUS)0xC0000140) +#define STATUS_INVALID_ADDRESS ((NTSTATUS)0xC0000141) +#define STATUS_DLL_INIT_FAILED ((NTSTATUS)0xC0000142) +#define STATUS_MISSING_SYSTEMFILE ((NTSTATUS)0xC0000143) +#define STATUS_UNHANDLED_EXCEPTION ((NTSTATUS)0xC0000144) +#define STATUS_APP_INIT_FAILURE ((NTSTATUS)0xC0000145) +#define STATUS_PAGEFILE_CREATE_FAILED ((NTSTATUS)0xC0000146) +#define STATUS_NO_PAGEFILE ((NTSTATUS)0xC0000147) +#define STATUS_INVALID_LEVEL ((NTSTATUS)0xC0000148) +#define STATUS_WRONG_PASSWORD_CORE ((NTSTATUS)0xC0000149) +#define STATUS_ILLEGAL_FLOAT_CONTEXT ((NTSTATUS)0xC000014A) +#define STATUS_PIPE_BROKEN ((NTSTATUS)0xC000014B) +#define STATUS_REGISTRY_CORRUPT ((NTSTATUS)0xC000014C) +#define STATUS_REGISTRY_IO_FAILED ((NTSTATUS)0xC000014D) +#define STATUS_NO_EVENT_PAIR ((NTSTATUS)0xC000014E) +#define STATUS_UNRECOGNIZED_VOLUME ((NTSTATUS)0xC000014F) +#define STATUS_SERIAL_NO_DEVICE_INITED ((NTSTATUS)0xC0000150) +#define STATUS_NO_SUCH_ALIAS ((NTSTATUS)0xC0000151) +#define STATUS_MEMBER_NOT_IN_ALIAS ((NTSTATUS)0xC0000152) +#define STATUS_MEMBER_IN_ALIAS ((NTSTATUS)0xC0000153) +#define STATUS_ALIAS_EXISTS ((NTSTATUS)0xC0000154) +#define STATUS_LOGON_NOT_GRANTED ((NTSTATUS)0xC0000155) +#define STATUS_TOO_MANY_SECRETS ((NTSTATUS)0xC0000156) +#define STATUS_SECRET_TOO_LONG ((NTSTATUS)0xC0000157) +#define STATUS_INTERNAL_DB_ERROR ((NTSTATUS)0xC0000158) +#define STATUS_FULLSCREEN_MODE ((NTSTATUS)0xC0000159) +#define STATUS_TOO_MANY_CONTEXT_IDS ((NTSTATUS)0xC000015A) +#define STATUS_LOGON_TYPE_NOT_GRANTED ((NTSTATUS)0xC000015B) +#define STATUS_NOT_REGISTRY_FILE ((NTSTATUS)0xC000015C) +#define STATUS_NT_CROSS_ENCRYPTION_REQUIRED ((NTSTATUS)0xC000015D) +#define STATUS_DOMAIN_CTRLR_CONFIG_ERROR ((NTSTATUS)0xC000015E) +#define STATUS_FT_MISSING_MEMBER ((NTSTATUS)0xC000015F) +#define STATUS_ILL_FORMED_SERVICE_ENTRY ((NTSTATUS)0xC0000160) +#define STATUS_ILLEGAL_CHARACTER ((NTSTATUS)0xC0000161) +#define STATUS_UNMAPPABLE_CHARACTER ((NTSTATUS)0xC0000162) +#define STATUS_UNDEFINED_CHARACTER ((NTSTATUS)0xC0000163) +#define STATUS_FLOPPY_VOLUME ((NTSTATUS)0xC0000164) +#define STATUS_FLOPPY_ID_MARK_NOT_FOUND ((NTSTATUS)0xC0000165) +#define STATUS_FLOPPY_WRONG_CYLINDER ((NTSTATUS)0xC0000166) +#define STATUS_FLOPPY_UNKNOWN_ERROR ((NTSTATUS)0xC0000167) +#define STATUS_FLOPPY_BAD_REGISTERS ((NTSTATUS)0xC0000168) +#define STATUS_DISK_RECALIBRATE_FAILED ((NTSTATUS)0xC0000169) +#define STATUS_DISK_OPERATION_FAILED ((NTSTATUS)0xC000016A) +#define STATUS_DISK_RESET_FAILED ((NTSTATUS)0xC000016B) +#define STATUS_SHARED_IRQ_BUSY ((NTSTATUS)0xC000016C) +#define STATUS_FT_ORPHANING ((NTSTATUS)0xC000016D) +#define STATUS_BIOS_FAILED_TO_CONNECT_INTERRUPT ((NTSTATUS)0xC000016E) + +#define STATUS_PARTITION_FAILURE ((NTSTATUS)0xC0000172) +#define STATUS_INVALID_BLOCK_LENGTH ((NTSTATUS)0xC0000173) +#define STATUS_DEVICE_NOT_PARTITIONED ((NTSTATUS)0xC0000174) +#define STATUS_UNABLE_TO_LOCK_MEDIA ((NTSTATUS)0xC0000175) +#define STATUS_UNABLE_TO_UNLOAD_MEDIA ((NTSTATUS)0xC0000176) +#define STATUS_EOM_OVERFLOW ((NTSTATUS)0xC0000177) +#define STATUS_NO_MEDIA ((NTSTATUS)0xC0000178) +#define STATUS_NO_SUCH_MEMBER ((NTSTATUS)0xC000017A) +#define STATUS_INVALID_MEMBER ((NTSTATUS)0xC000017B) +#define STATUS_KEY_DELETED ((NTSTATUS)0xC000017C) +#define STATUS_NO_LOG_SPACE ((NTSTATUS)0xC000017D) +#define STATUS_TOO_MANY_SIDS ((NTSTATUS)0xC000017E) +#define STATUS_LM_CROSS_ENCRYPTION_REQUIRED ((NTSTATUS)0xC000017F) +#define STATUS_KEY_HAS_CHILDREN ((NTSTATUS)0xC0000180) +#define STATUS_CHILD_MUST_BE_VOLATILE ((NTSTATUS)0xC0000181) +#define STATUS_DEVICE_CONFIGURATION_ERROR ((NTSTATUS)0xC0000182) +#define STATUS_DRIVER_INTERNAL_ERROR ((NTSTATUS)0xC0000183) +#define STATUS_INVALID_DEVICE_STATE ((NTSTATUS)0xC0000184) +#define STATUS_IO_DEVICE_ERROR ((NTSTATUS)0xC0000185) +#define STATUS_DEVICE_PROTOCOL_ERROR ((NTSTATUS)0xC0000186) +#define STATUS_BACKUP_CONTROLLER ((NTSTATUS)0xC0000187) +#define STATUS_LOG_FILE_FULL ((NTSTATUS)0xC0000188) +#define STATUS_TOO_LATE ((NTSTATUS)0xC0000189) +#define STATUS_NO_TRUST_LSA_SECRET ((NTSTATUS)0xC000018A) +#define STATUS_NO_TRUST_SAM_ACCOUNT ((NTSTATUS)0xC000018B) +#define STATUS_TRUSTED_DOMAIN_FAILURE ((NTSTATUS)0xC000018C) +#define STATUS_TRUSTED_RELATIONSHIP_FAILURE ((NTSTATUS)0xC000018D) +#define STATUS_EVENTLOG_FILE_CORRUPT ((NTSTATUS)0xC000018E) +#define STATUS_EVENTLOG_CANT_START ((NTSTATUS)0xC000018F) +#define STATUS_TRUST_FAILURE ((NTSTATUS)0xC0000190) +#define STATUS_MUTANT_LIMIT_EXCEEDED ((NTSTATUS)0xC0000191) +#define STATUS_NETLOGON_NOT_STARTED ((NTSTATUS)0xC0000192) +#define STATUS_ACCOUNT_EXPIRED ((NTSTATUS)0xC0000193) +#define STATUS_POSSIBLE_DEADLOCK ((NTSTATUS)0xC0000194) +#define STATUS_NETWORK_CREDENTIAL_CONFLICT ((NTSTATUS)0xC0000195) +#define STATUS_REMOTE_SESSION_LIMIT ((NTSTATUS)0xC0000196) +#define STATUS_EVENTLOG_FILE_CHANGED ((NTSTATUS)0xC0000197) +#define STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT ((NTSTATUS)0xC0000198) +#define STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT ((NTSTATUS)0xC0000199) +#define STATUS_NOLOGON_SERVER_TRUST_ACCOUNT ((NTSTATUS)0xC000019A) +#define STATUS_DOMAIN_TRUST_INCONSISTENT ((NTSTATUS)0xC000019B) +#define STATUS_FS_DRIVER_REQUIRED ((NTSTATUS)0xC000019C) +#define STATUS_NO_USER_SESSION_KEY ((NTSTATUS)0xC0000202) +#define STATUS_USER_SESSION_DELETED ((NTSTATUS)0xC0000203) +#define STATUS_RESOURCE_LANG_NOT_FOUND ((NTSTATUS)0xC0000204) +#define STATUS_INSUFF_SERVER_RESOURCES ((NTSTATUS)0xC0000205) +#define STATUS_INVALID_BUFFER_SIZE ((NTSTATUS)0xC0000206) +#define STATUS_INVALID_ADDRESS_COMPONENT ((NTSTATUS)0xC0000207) +#define STATUS_INVALID_ADDRESS_WILDCARD ((NTSTATUS)0xC0000208) +#define STATUS_TOO_MANY_ADDRESSES ((NTSTATUS)0xC0000209) +#define STATUS_ADDRESS_ALREADY_EXISTS ((NTSTATUS)0xC000020A) +#define STATUS_ADDRESS_CLOSED ((NTSTATUS)0xC000020B) +#define STATUS_CONNECTION_DISCONNECTED ((NTSTATUS)0xC000020C) +#define STATUS_CONNECTION_RESET ((NTSTATUS)0xC000020D) +#define STATUS_TOO_MANY_NODES ((NTSTATUS)0xC000020E) +#define STATUS_TRANSACTION_ABORTED ((NTSTATUS)0xC000020F) +#define STATUS_TRANSACTION_TIMED_OUT ((NTSTATUS)0xC0000210) +#define STATUS_TRANSACTION_NO_RELEASE ((NTSTATUS)0xC0000211) +#define STATUS_TRANSACTION_NO_MATCH ((NTSTATUS)0xC0000212) +#define STATUS_TRANSACTION_RESPONDED ((NTSTATUS)0xC0000213) +#define STATUS_TRANSACTION_INVALID_ID ((NTSTATUS)0xC0000214) +#define STATUS_TRANSACTION_INVALID_TYPE ((NTSTATUS)0xC0000215) +#define STATUS_NOT_SERVER_SESSION ((NTSTATUS)0xC0000216) +#define STATUS_NOT_CLIENT_SESSION ((NTSTATUS)0xC0000217) +#define STATUS_CANNOT_LOAD_REGISTRY_FILE ((NTSTATUS)0xC0000218) +#define STATUS_DEBUG_ATTACH_FAILED ((NTSTATUS)0xC0000219) +#define STATUS_SYSTEM_PROCESS_TERMINATED ((NTSTATUS)0xC000021A) +#define STATUS_DATA_NOT_ACCEPTED ((NTSTATUS)0xC000021B) +#define STATUS_NO_BROWSER_SERVERS_FOUND ((NTSTATUS)0xC000021C) +#define STATUS_VDM_HARD_ERROR ((NTSTATUS)0xC000021D) +#define STATUS_DRIVER_CANCEL_TIMEOUT ((NTSTATUS)0xC000021E) +#define STATUS_REPLY_MESSAGE_MISMATCH ((NTSTATUS)0xC000021F) +#define STATUS_MAPPED_ALIGNMENT ((NTSTATUS)0xC0000220) +#define STATUS_IMAGE_CHECKSUM_MISMATCH ((NTSTATUS)0xC0000221) +#define STATUS_LOST_WRITEBEHIND_DATA ((NTSTATUS)0xC0000222) +#define STATUS_CLIENT_SERVER_PARAMETERS_INVALID ((NTSTATUS)0xC0000223) +#define STATUS_PASSWORD_MUST_CHANGE ((NTSTATUS)0xC0000224) +#define STATUS_NOT_FOUND ((NTSTATUS)0xC0000225) +#define STATUS_NOT_TINY_STREAM ((NTSTATUS)0xC0000226) +#define STATUS_RECOVERY_FAILURE ((NTSTATUS)0xC0000227) +#define STATUS_STACK_OVERFLOW_READ ((NTSTATUS)0xC0000228) +#define STATUS_FAIL_CHECK ((NTSTATUS)0xC0000229) +#define STATUS_DUPLICATE_OBJECTID ((NTSTATUS)0xC000022A) +#define STATUS_OBJECTID_EXISTS ((NTSTATUS)0xC000022B) +#define STATUS_CONVERT_TO_LARGE ((NTSTATUS)0xC000022C) +#define STATUS_RETRY ((NTSTATUS)0xC000022D) +#define STATUS_FOUND_OUT_OF_SCOPE ((NTSTATUS)0xC000022E) +#define STATUS_ALLOCATE_BUCKET ((NTSTATUS)0xC000022F) +#define STATUS_PROPSET_NOT_FOUND ((NTSTATUS)0xC0000230) +#define STATUS_MARSHALL_OVERFLOW ((NTSTATUS)0xC0000231) +#define STATUS_INVALID_VARIANT ((NTSTATUS)0xC0000232) +#define STATUS_DOMAIN_CONTROLLER_NOT_FOUND ((NTSTATUS)0xC0000233) +#define STATUS_ACCOUNT_LOCKED_OUT ((NTSTATUS)0xC0000234) +#define STATUS_HANDLE_NOT_CLOSABLE ((NTSTATUS)0xC0000235) +#define STATUS_CONNECTION_REFUSED ((NTSTATUS)0xC0000236) +#define STATUS_GRACEFUL_DISCONNECT ((NTSTATUS)0xC0000237) +#define STATUS_ADDRESS_ALREADY_ASSOCIATED ((NTSTATUS)0xC0000238) +#define STATUS_ADDRESS_NOT_ASSOCIATED ((NTSTATUS)0xC0000239) +#define STATUS_CONNECTION_INVALID ((NTSTATUS)0xC000023A) +#define STATUS_CONNECTION_ACTIVE ((NTSTATUS)0xC000023B) +#define STATUS_NETWORK_UNREACHABLE ((NTSTATUS)0xC000023C) +#define STATUS_HOST_UNREACHABLE ((NTSTATUS)0xC000023D) +#define STATUS_PROTOCOL_UNREACHABLE ((NTSTATUS)0xC000023E) +#define STATUS_PORT_UNREACHABLE ((NTSTATUS)0xC000023F) +#define STATUS_REQUEST_ABORTED ((NTSTATUS)0xC0000240) +#define STATUS_CONNECTION_ABORTED ((NTSTATUS)0xC0000241) +#define STATUS_BAD_COMPRESSION_BUFFER ((NTSTATUS)0xC0000242) +#define STATUS_USER_MAPPED_FILE ((NTSTATUS)0xC0000243) +#define STATUS_AUDIT_FAILED ((NTSTATUS)0xC0000244) +#define STATUS_TIMER_RESOLUTION_NOT_SET ((NTSTATUS)0xC0000245) +#define STATUS_CONNECTION_COUNT_LIMIT ((NTSTATUS)0xC0000246) +#define STATUS_LOGIN_TIME_RESTRICTION ((NTSTATUS)0xC0000247) +#define STATUS_LOGIN_WKSTA_RESTRICTION ((NTSTATUS)0xC0000248) +#define STATUS_IMAGE_MP_UP_MISMATCH ((NTSTATUS)0xC0000249) +#define STATUS_INSUFFICIENT_LOGON_INFO ((NTSTATUS)0xC0000250) +#define STATUS_BAD_DLL_ENTRYPOINT ((NTSTATUS)0xC0000251) +#define STATUS_BAD_SERVICE_ENTRYPOINT ((NTSTATUS)0xC0000252) +#define STATUS_LPC_REPLY_LOST ((NTSTATUS)0xC0000253) +#define STATUS_IP_ADDRESS_CONFLICT1 ((NTSTATUS)0xC0000254) +#define STATUS_IP_ADDRESS_CONFLICT2 ((NTSTATUS)0xC0000255) +#define STATUS_REGISTRY_QUOTA_LIMIT ((NTSTATUS)0xC0000256) +#define STATUS_PATH_NOT_COVERED ((NTSTATUS)0xC0000257) +#define STATUS_NO_CALLBACK_ACTIVE ((NTSTATUS)0xC0000258) +#define STATUS_LICENSE_QUOTA_EXCEEDED ((NTSTATUS)0xC0000259) +#define STATUS_PWD_TOO_SHORT ((NTSTATUS)0xC000025A) +#define STATUS_PWD_TOO_RECENT ((NTSTATUS)0xC000025B) +#define STATUS_PWD_HISTORY_CONFLICT ((NTSTATUS)0xC000025C) +#define STATUS_PLUGPLAY_NO_DEVICE ((NTSTATUS)0xC000025E) +#define STATUS_UNSUPPORTED_COMPRESSION ((NTSTATUS)0xC000025F) +#define STATUS_INVALID_HW_PROFILE ((NTSTATUS)0xC0000260) +#define STATUS_INVALID_PLUGPLAY_DEVICE_PATH ((NTSTATUS)0xC0000261) +#define STATUS_DRIVER_ORDINAL_NOT_FOUND ((NTSTATUS)0xC0000262) +#define STATUS_DRIVER_ENTRYPOINT_NOT_FOUND ((NTSTATUS)0xC0000263) +#define STATUS_RESOURCE_NOT_OWNED ((NTSTATUS)0xC0000264) +#define STATUS_TOO_MANY_LINKS ((NTSTATUS)0xC0000265) +#define STATUS_QUOTA_LIST_INCONSISTENT ((NTSTATUS)0xC0000266) +#define STATUS_FILE_IS_OFFLINE ((NTSTATUS)0xC0000267) +#define STATUS_EVALUATION_EXPIRATION ((NTSTATUS)0xC0000268) +#define STATUS_ILLEGAL_DLL_RELOCATION ((NTSTATUS)0xC0000269) +#define STATUS_LICENSE_VIOLATION ((NTSTATUS)0xC000026A) +#define STATUS_DLL_INIT_FAILED_LOGOFF ((NTSTATUS)0xC000026B) +#define STATUS_DRIVER_UNABLE_TO_LOAD ((NTSTATUS)0xC000026C) +#define STATUS_DFS_UNAVAILABLE ((NTSTATUS)0xC000026D) +#define STATUS_VOLUME_DISMOUNTED ((NTSTATUS)0xC000026E) +#define STATUS_WX86_INTERNAL_ERROR ((NTSTATUS)0xC000026F) +#define STATUS_WX86_FLOAT_STACK_CHECK ((NTSTATUS)0xC0000270) +#define STATUS_VALIDATE_CONTINUE ((NTSTATUS)0xC0000271) +#define STATUS_NO_MATCH ((NTSTATUS)0xC0000272) +#define STATUS_NO_MORE_MATCHES ((NTSTATUS)0xC0000273) +#define STATUS_NOT_A_REPARSE_POINT ((NTSTATUS)0xC0000275) +#define STATUS_IO_REPARSE_TAG_INVALID ((NTSTATUS)0xC0000276) +#define STATUS_IO_REPARSE_TAG_MISMATCH ((NTSTATUS)0xC0000277) +#define STATUS_IO_REPARSE_DATA_INVALID ((NTSTATUS)0xC0000278) +#define STATUS_IO_REPARSE_TAG_NOT_HANDLED ((NTSTATUS)0xC0000279) +#define STATUS_REPARSE_POINT_NOT_RESOLVED ((NTSTATUS)0xC0000280) +#define STATUS_DIRECTORY_IS_A_REPARSE_POINT ((NTSTATUS)0xC0000281) +#define STATUS_RANGE_LIST_CONFLICT ((NTSTATUS)0xC0000282) +#define STATUS_SOURCE_ELEMENT_EMPTY ((NTSTATUS)0xC0000283) +#define STATUS_DESTINATION_ELEMENT_FULL ((NTSTATUS)0xC0000284) +#define STATUS_ILLEGAL_ELEMENT_ADDRESS ((NTSTATUS)0xC0000285) +#define STATUS_MAGAZINE_NOT_PRESENT ((NTSTATUS)0xC0000286) +#define STATUS_REINITIALIZATION_NEEDED ((NTSTATUS)0xC0000287) +#define STATUS_ENCRYPTION_FAILED ((NTSTATUS)0xC000028A) +#define STATUS_DECRYPTION_FAILED ((NTSTATUS)0xC000028B) +#define STATUS_RANGE_NOT_FOUND ((NTSTATUS)0xC000028C) +#define STATUS_NO_RECOVERY_POLICY ((NTSTATUS)0xC000028D) +#define STATUS_NO_EFS ((NTSTATUS)0xC000028E) +#define STATUS_WRONG_EFS ((NTSTATUS)0xC000028F) +#define STATUS_NO_USER_KEYS ((NTSTATUS)0xC0000290) +#define STATUS_FILE_NOT_ENCRYPTED ((NTSTATUS)0xC0000291) +#define STATUS_NOT_EXPORT_FORMAT ((NTSTATUS)0xC0000292) +#define STATUS_FILE_ENCRYPTED ((NTSTATUS)0xC0000293) +#define STATUS_WMI_GUID_NOT_FOUND ((NTSTATUS)0xC0000295) +#define STATUS_WMI_INSTANCE_NOT_FOUND ((NTSTATUS)0xC0000296) +#define STATUS_WMI_ITEMID_NOT_FOUND ((NTSTATUS)0xC0000297) +#define STATUS_WMI_TRY_AGAIN ((NTSTATUS)0xC0000298) +#define STATUS_SHARED_POLICY ((NTSTATUS)0xC0000299) +#define STATUS_POLICY_OBJECT_NOT_FOUND ((NTSTATUS)0xC000029A) +#define STATUS_POLICY_ONLY_IN_DS ((NTSTATUS)0xC000029B) +#define STATUS_VOLUME_NOT_UPGRADED ((NTSTATUS)0xC000029C) +#define STATUS_REMOTE_STORAGE_NOT_ACTIVE ((NTSTATUS)0xC000029D) +#define STATUS_REMOTE_STORAGE_MEDIA_ERROR ((NTSTATUS)0xC000029E) +#define STATUS_NO_TRACKING_SERVICE ((NTSTATUS)0xC000029F) +#define STATUS_SERVER_SID_MISMATCH ((NTSTATUS)0xC00002A0) +#define STATUS_DS_NO_ATTRIBUTE_OR_VALUE ((NTSTATUS)0xC00002A1) +#define STATUS_DS_INVALID_ATTRIBUTE_SYNTAX ((NTSTATUS)0xC00002A2) +#define STATUS_DS_ATTRIBUTE_TYPE_UNDEFINED ((NTSTATUS)0xC00002A3) +#define STATUS_DS_ATTRIBUTE_OR_VALUE_EXISTS ((NTSTATUS)0xC00002A4) +#define STATUS_DS_BUSY ((NTSTATUS)0xC00002A5) +#define STATUS_DS_UNAVAILABLE ((NTSTATUS)0xC00002A6) +#define STATUS_DS_NO_RIDS_ALLOCATED ((NTSTATUS)0xC00002A7) +#define STATUS_DS_NO_MORE_RIDS ((NTSTATUS)0xC00002A8) +#define STATUS_DS_INCORRECT_ROLE_OWNER ((NTSTATUS)0xC00002A9) +#define STATUS_DS_RIDMGR_INIT_ERROR ((NTSTATUS)0xC00002AA) +#define STATUS_DS_OBJ_CLASS_VIOLATION ((NTSTATUS)0xC00002AB) +#define STATUS_DS_CANT_ON_NON_LEAF ((NTSTATUS)0xC00002AC) +#define STATUS_DS_CANT_ON_RDN ((NTSTATUS)0xC00002AD) +#define STATUS_DS_CANT_MOD_OBJ_CLASS ((NTSTATUS)0xC00002AE) +#define STATUS_DS_CROSS_DOM_MOVE_FAILED ((NTSTATUS)0xC00002AF) +#define STATUS_DS_GC_NOT_AVAILABLE ((NTSTATUS)0xC00002B0) +#define STATUS_DIRECTORY_SERVICE_REQUIRED ((NTSTATUS)0xC00002B1) +#define STATUS_REPARSE_ATTRIBUTE_CONFLICT ((NTSTATUS)0xC00002B2) +#define STATUS_CANT_ENABLE_DENY_ONLY ((NTSTATUS)0xC00002B3) +#define STATUS_FLOAT_MULTIPLE_FAULTS ((NTSTATUS)0xC00002B4) +#define STATUS_FLOAT_MULTIPLE_TRAPS ((NTSTATUS)0xC00002B5) +#define STATUS_DEVICE_REMOVED ((NTSTATUS)0xC00002B6) +#define STATUS_JOURNAL_DELETE_IN_PROGRESS ((NTSTATUS)0xC00002B7) +#define STATUS_JOURNAL_NOT_ACTIVE ((NTSTATUS)0xC00002B8) +#define STATUS_NOINTERFACE ((NTSTATUS)0xC00002B9) +#define STATUS_DS_ADMIN_LIMIT_EXCEEDED ((NTSTATUS)0xC00002C1) +#define STATUS_DRIVER_FAILED_SLEEP ((NTSTATUS)0xC00002C2) +#define STATUS_MUTUAL_AUTHENTICATION_FAILED ((NTSTATUS)0xC00002C3) +#define STATUS_CORRUPT_SYSTEM_FILE ((NTSTATUS)0xC00002C4) +#define STATUS_DATATYPE_MISALIGNMENT_ERROR ((NTSTATUS)0xC00002C5) +#define STATUS_WMI_READ_ONLY ((NTSTATUS)0xC00002C6) +#define STATUS_WMI_SET_FAILURE ((NTSTATUS)0xC00002C7) +#define STATUS_COMMITMENT_MINIMUM ((NTSTATUS)0xC00002C8) +#define STATUS_REG_NAT_CONSUMPTION ((NTSTATUS)0xC00002C9) +#define STATUS_TRANSPORT_FULL ((NTSTATUS)0xC00002CA) +#define STATUS_DS_SAM_INIT_FAILURE ((NTSTATUS)0xC00002CB) +#define STATUS_ONLY_IF_CONNECTED ((NTSTATUS)0xC00002CC) +#define STATUS_DS_SENSITIVE_GROUP_VIOLATION ((NTSTATUS)0xC00002CD) +#define STATUS_PNP_RESTART_ENUMERATION ((NTSTATUS)0xC00002CE) +#define STATUS_JOURNAL_ENTRY_DELETED ((NTSTATUS)0xC00002CF) +#define STATUS_DS_CANT_MOD_PRIMARYGROUPID ((NTSTATUS)0xC00002D0) +#define STATUS_SYSTEM_IMAGE_BAD_SIGNATURE ((NTSTATUS)0xC00002D1) +#define STATUS_PNP_REBOOT_REQUIRED ((NTSTATUS)0xC00002D2) +#define STATUS_POWER_STATE_INVALID ((NTSTATUS)0xC00002D3) +#define STATUS_DS_INVALID_GROUP_TYPE ((NTSTATUS)0xC00002D4) +#define STATUS_DS_NO_NEST_GLOBALGROUP_IN_MIXEDDOMAIN ((NTSTATUS)0xC00002D5) +#define STATUS_DS_NO_NEST_LOCALGROUP_IN_MIXEDDOMAIN ((NTSTATUS)0xC00002D6) +#define STATUS_DS_GLOBAL_CANT_HAVE_LOCAL_MEMBER ((NTSTATUS)0xC00002D7) +#define STATUS_DS_GLOBAL_CANT_HAVE_UNIVERSAL_MEMBER ((NTSTATUS)0xC00002D8) +#define STATUS_DS_UNIVERSAL_CANT_HAVE_LOCAL_MEMBER ((NTSTATUS)0xC00002D9) +#define STATUS_DS_GLOBAL_CANT_HAVE_CROSSDOMAIN_MEMBER ((NTSTATUS)0xC00002DA) +#define STATUS_DS_LOCAL_CANT_HAVE_CROSSDOMAIN_LOCAL_MEMBER ((NTSTATUS)0xC00002DB) +#define STATUS_DS_HAVE_PRIMARY_MEMBERS ((NTSTATUS)0xC00002DC) +#define STATUS_WMI_NOT_SUPPORTED ((NTSTATUS)0xC00002DD) +#define STATUS_INSUFFICIENT_POWER ((NTSTATUS)0xC00002DE) +#define STATUS_SAM_NEED_BOOTKEY_PASSWORD ((NTSTATUS)0xC00002DF) +#define STATUS_SAM_NEED_BOOTKEY_FLOPPY ((NTSTATUS)0xC00002E0) +#define STATUS_DS_CANT_START ((NTSTATUS)0xC00002E1) +#define STATUS_DS_INIT_FAILURE ((NTSTATUS)0xC00002E2) +#define STATUS_SAM_INIT_FAILURE ((NTSTATUS)0xC00002E3) +#define STATUS_DS_GC_REQUIRED ((NTSTATUS)0xC00002E4) +#define STATUS_DS_LOCAL_MEMBER_OF_LOCAL_ONLY ((NTSTATUS)0xC00002E5) +#define STATUS_DS_NO_FPO_IN_UNIVERSAL_GROUPS ((NTSTATUS)0xC00002E6) +#define STATUS_DS_MACHINE_ACCOUNT_QUOTA_EXCEEDED ((NTSTATUS)0xC00002E7) +#define STATUS_MULTIPLE_FAULT_VIOLATION ((NTSTATUS)0xC00002E8) +#define STATUS_CURRENT_DOMAIN_NOT_ALLOWED ((NTSTATUS)0xC00002E9) +#define STATUS_CANNOT_MAKE ((NTSTATUS)0xC00002EA) +#define STATUS_SYSTEM_SHUTDOWN ((NTSTATUS)0xC00002EB) +#define STATUS_DS_INIT_FAILURE_CONSOLE ((NTSTATUS)0xC00002EC) +#define STATUS_DS_SAM_INIT_FAILURE_CONSOLE ((NTSTATUS)0xC00002ED) +#define STATUS_UNFINISHED_CONTEXT_DELETED ((NTSTATUS)0xC00002EE) +#define STATUS_NO_TGT_REPLY ((NTSTATUS)0xC00002EF) +#define STATUS_OBJECTID_NOT_FOUND ((NTSTATUS)0xC00002F0) +#define STATUS_NO_IP_ADDRESSES ((NTSTATUS)0xC00002F1) +#define STATUS_WRONG_CREDENTIAL_HANDLE ((NTSTATUS)0xC00002F2) +#define STATUS_CRYPTO_SYSTEM_INVALID ((NTSTATUS)0xC00002F3) +#define STATUS_MAX_REFERRALS_EXCEEDED ((NTSTATUS)0xC00002F4) +#define STATUS_MUST_BE_KDC ((NTSTATUS)0xC00002F5) +#define STATUS_STRONG_CRYPTO_NOT_SUPPORTED ((NTSTATUS)0xC00002F6) +#define STATUS_TOO_MANY_PRINCIPALS ((NTSTATUS)0xC00002F7) +#define STATUS_NO_PA_DATA ((NTSTATUS)0xC00002F8) +#define STATUS_PKINIT_NAME_MISMATCH ((NTSTATUS)0xC00002F9) +#define STATUS_SMARTCARD_LOGON_REQUIRED ((NTSTATUS)0xC00002FA) +#define STATUS_KDC_INVALID_REQUEST ((NTSTATUS)0xC00002FB) +#define STATUS_KDC_UNABLE_TO_REFER ((NTSTATUS)0xC00002FC) +#define STATUS_KDC_UNKNOWN_ETYPE ((NTSTATUS)0xC00002FD) +#define STATUS_SHUTDOWN_IN_PROGRESS ((NTSTATUS)0xC00002FE) +#define STATUS_SERVER_SHUTDOWN_IN_PROGRESS ((NTSTATUS)0xC00002FF) +#define STATUS_NOT_SUPPORTED_ON_SBS ((NTSTATUS)0xC0000300) +#define STATUS_WMI_GUID_DISCONNECTED ((NTSTATUS)0xC0000301) +#define STATUS_WMI_ALREADY_DISABLED ((NTSTATUS)0xC0000302) +#define STATUS_WMI_ALREADY_ENABLED ((NTSTATUS)0xC0000303) +#define STATUS_MFT_TOO_FRAGMENTED ((NTSTATUS)0xC0000304) +#define STATUS_COPY_PROTECTION_FAILURE ((NTSTATUS)0xC0000305) +#define STATUS_CSS_AUTHENTICATION_FAILURE ((NTSTATUS)0xC0000306) +#define STATUS_CSS_KEY_NOT_PRESENT ((NTSTATUS)0xC0000307) +#define STATUS_CSS_KEY_NOT_ESTABLISHED ((NTSTATUS)0xC0000308) +#define STATUS_CSS_SCRAMBLED_SECTOR ((NTSTATUS)0xC0000309) +#define STATUS_CSS_REGION_MISMATCH ((NTSTATUS)0xC000030A) +#define STATUS_CSS_RESETS_EXHAUSTED ((NTSTATUS)0xC000030B) +#define STATUS_PKINIT_FAILURE ((NTSTATUS)0xC0000320) +#define STATUS_SMARTCARD_SUBSYSTEM_FAILURE ((NTSTATUS)0xC0000321) +#define STATUS_NO_KERB_KEY ((NTSTATUS)0xC0000322) +#define STATUS_HOST_DOWN ((NTSTATUS)0xC0000350) +#define STATUS_UNSUPPORTED_PREAUTH ((NTSTATUS)0xC0000351) +#define STATUS_EFS_ALG_BLOB_TOO_BIG ((NTSTATUS)0xC0000352) +#define STATUS_PORT_NOT_SET ((NTSTATUS)0xC0000353) +#define STATUS_DEBUGGER_INACTIVE ((NTSTATUS)0xC0000354) +#define STATUS_DS_VERSION_CHECK_FAILURE ((NTSTATUS)0xC0000355) +#define STATUS_AUDITING_DISABLED ((NTSTATUS)0xC0000356) +#define STATUS_PRENT4_MACHINE_ACCOUNT ((NTSTATUS)0xC0000357) +#define STATUS_DS_AG_CANT_HAVE_UNIVERSAL_MEMBER ((NTSTATUS)0xC0000358) +#define STATUS_INVALID_IMAGE_WIN_32 ((NTSTATUS)0xC0000359) +#define STATUS_INVALID_IMAGE_WIN_64 ((NTSTATUS)0xC000035A) +#define STATUS_BAD_BINDINGS ((NTSTATUS)0xC000035B) +#define STATUS_NETWORK_SESSION_EXPIRED ((NTSTATUS)0xC000035C) +#define STATUS_APPHELP_BLOCK ((NTSTATUS)0xC000035D) +#define STATUS_ALL_SIDS_FILTERED ((NTSTATUS)0xC000035E) +#define STATUS_NOT_SAFE_MODE_DRIVER ((NTSTATUS)0xC000035F) +#define STATUS_ACCESS_DISABLED_BY_POLICY_DEFAULT ((NTSTATUS)0xC0000361) +#define STATUS_ACCESS_DISABLED_BY_POLICY_PATH ((NTSTATUS)0xC0000362) +#define STATUS_ACCESS_DISABLED_BY_POLICY_PUBLISHER ((NTSTATUS)0xC0000363) +#define STATUS_ACCESS_DISABLED_BY_POLICY_OTHER ((NTSTATUS)0xC0000364) +#define STATUS_FAILED_DRIVER_ENTRY ((NTSTATUS)0xC0000365) +#define STATUS_DEVICE_ENUMERATION_ERROR ((NTSTATUS)0xC0000366) +#define STATUS_WAIT_FOR_OPLOCK ((NTSTATUS)0x00000367) +#define STATUS_MOUNT_POINT_NOT_RESOLVED ((NTSTATUS)0xC0000368) +#define STATUS_INVALID_DEVICE_OBJECT_PARAMETER ((NTSTATUS)0xC0000369) +#define STATUS_MCA_OCCURED ((NTSTATUS)0xC000036A) +#define STATUS_DRIVER_BLOCKED_CRITICAL ((NTSTATUS)0xC000036B) +#define STATUS_DRIVER_BLOCKED ((NTSTATUS)0xC000036C) +#define STATUS_DRIVER_DATABASE_ERROR ((NTSTATUS)0xC000036D) +#define STATUS_SYSTEM_HIVE_TOO_LARGE ((NTSTATUS)0xC000036E) +#define STATUS_INVALID_IMPORT_OF_NON_DLL ((NTSTATUS)0xC000036F) +#define STATUS_SMARTCARD_WRONG_PIN ((NTSTATUS)0xC0000380) +#define STATUS_SMARTCARD_CARD_BLOCKED ((NTSTATUS)0xC0000381) +#define STATUS_SMARTCARD_CARD_NOT_AUTHENTICATED ((NTSTATUS)0xC0000382) +#define STATUS_SMARTCARD_NO_CARD ((NTSTATUS)0xC0000383) +#define STATUS_SMARTCARD_NO_KEY_CONTAINER ((NTSTATUS)0xC0000384) +#define STATUS_SMARTCARD_NO_CERTIFICATE ((NTSTATUS)0xC0000385) +#define STATUS_SMARTCARD_NO_KEYSET ((NTSTATUS)0xC0000386) +#define STATUS_SMARTCARD_IO_ERROR ((NTSTATUS)0xC0000387) +#define STATUS_DOWNGRADE_DETECTED ((NTSTATUS)0xC0000388) +#define STATUS_SMARTCARD_CERT_REVOKED ((NTSTATUS)0xC0000389) +#define STATUS_ISSUING_CA_UNTRUSTED ((NTSTATUS)0xC000038A) +#define STATUS_REVOCATION_OFFLINE_C ((NTSTATUS)0xC000038B) +#define STATUS_PKINIT_CLIENT_FAILURE ((NTSTATUS)0xC000038C) +#define STATUS_SMARTCARD_CERT_EXPIRED ((NTSTATUS)0xC000038D) +#define STATUS_DRIVER_FAILED_PRIOR_UNLOAD ((NTSTATUS)0xC000038E) +#define STATUS_SMARTCARD_SILENT_CONTEXT ((NTSTATUS)0xC000038F) +#define STATUS_PER_USER_TRUST_QUOTA_EXCEEDED ((NTSTATUS)0xC0000401) +#define STATUS_ALL_USER_TRUST_QUOTA_EXCEEDED ((NTSTATUS)0xC0000402) +#define STATUS_USER_DELETE_TRUST_QUOTA_EXCEEDED ((NTSTATUS)0xC0000403) +#define STATUS_DS_NAME_NOT_UNIQUE ((NTSTATUS)0xC0000404) +#define STATUS_DS_DUPLICATE_ID_FOUND ((NTSTATUS)0xC0000405) +#define STATUS_DS_GROUP_CONVERSION_ERROR ((NTSTATUS)0xC0000406) +#define STATUS_VOLSNAP_PREPARE_HIBERNATE ((NTSTATUS)0xC0000407) +#define STATUS_USER2USER_REQUIRED ((NTSTATUS)0xC0000408) +#define STATUS_STACK_BUFFER_OVERRUN ((NTSTATUS)0xC0000409) +#define STATUS_NO_S4U_PROT_SUPPORT ((NTSTATUS)0xC000040A) +#define STATUS_CROSSREALM_DELEGATION_FAILURE ((NTSTATUS)0xC000040B) +#define STATUS_REVOCATION_OFFLINE_KDC ((NTSTATUS)0xC000040C) +#define STATUS_ISSUING_CA_UNTRUSTED_KDC ((NTSTATUS)0xC000040D) +#define STATUS_KDC_CERT_EXPIRED ((NTSTATUS)0xC000040E) +#define STATUS_KDC_CERT_REVOKED ((NTSTATUS)0xC000040F) +#define STATUS_PARAMETER_QUOTA_EXCEEDED ((NTSTATUS)0xC0000410) +#define STATUS_HIBERNATION_FAILURE ((NTSTATUS)0xC0000411) +#define STATUS_DELAY_LOAD_FAILED ((NTSTATUS)0xC0000412) +#define STATUS_AUTHENTICATION_FIREWALL_FAILED ((NTSTATUS)0xC0000413) +#define STATUS_VDM_DISALLOWED ((NTSTATUS)0xC0000414) +#define STATUS_HUNG_DISPLAY_DRIVER_THREAD ((NTSTATUS)0xC0000415) +#define STATUS_ASSERTION_FAILURE ((NTSTATUS)0xC0000420L) +#define STATUS_CALLBACK_POP_STACK ((NTSTATUS)0xC0000423) +#define STATUS_WOW_ASSERTION ((NTSTATUS)0xC0009898) + +#define RPC_NT_INVALID_STRING_BINDING ((NTSTATUS)0xC0020001) +#define RPC_NT_WRONG_KIND_OF_BINDING ((NTSTATUS)0xC0020002) +#define RPC_NT_INVALID_BINDING ((NTSTATUS)0xC0020003) +#define RPC_NT_PROTSEQ_NOT_SUPPORTED ((NTSTATUS)0xC0020004) +#define RPC_NT_INVALID_RPC_PROTSEQ ((NTSTATUS)0xC0020005) +#define RPC_NT_INVALID_STRING_UUID ((NTSTATUS)0xC0020006) +#define RPC_NT_INVALID_ENDPOINT_FORMAT ((NTSTATUS)0xC0020007) +#define RPC_NT_INVALID_NET_ADDR ((NTSTATUS)0xC0020008) +#define RPC_NT_NO_ENDPOINT_FOUND ((NTSTATUS)0xC0020009) +#define RPC_NT_INVALID_TIMEOUT ((NTSTATUS)0xC002000A) +#define RPC_NT_OBJECT_NOT_FOUND ((NTSTATUS)0xC002000B) +#define RPC_NT_ALREADY_REGISTERED ((NTSTATUS)0xC002000C) +#define RPC_NT_TYPE_ALREADY_REGISTERED ((NTSTATUS)0xC002000D) +#define RPC_NT_ALREADY_LISTENING ((NTSTATUS)0xC002000E) +#define RPC_NT_NO_PROTSEQS_REGISTERED ((NTSTATUS)0xC002000F) +#define RPC_NT_NOT_LISTENING ((NTSTATUS)0xC0020010) +#define RPC_NT_UNKNOWN_MGR_TYPE ((NTSTATUS)0xC0020011) +#define RPC_NT_UNKNOWN_IF ((NTSTATUS)0xC0020012) +#define RPC_NT_NO_BINDINGS ((NTSTATUS)0xC0020013) +#define RPC_NT_NO_PROTSEQS ((NTSTATUS)0xC0020014) +#define RPC_NT_CANT_CREATE_ENDPOINT ((NTSTATUS)0xC0020015) +#define RPC_NT_OUT_OF_RESOURCES ((NTSTATUS)0xC0020016) +#define RPC_NT_SERVER_UNAVAILABLE ((NTSTATUS)0xC0020017) +#define RPC_NT_SERVER_TOO_BUSY ((NTSTATUS)0xC0020018) +#define RPC_NT_INVALID_NETWORK_OPTIONS ((NTSTATUS)0xC0020019) +#define RPC_NT_NO_CALL_ACTIVE ((NTSTATUS)0xC002001A) +#define RPC_NT_CALL_FAILED ((NTSTATUS)0xC002001B) +#define RPC_NT_CALL_FAILED_DNE ((NTSTATUS)0xC002001C) +#define RPC_NT_PROTOCOL_ERROR ((NTSTATUS)0xC002001D) +#define RPC_NT_UNSUPPORTED_TRANS_SYN ((NTSTATUS)0xC002001F) +#define RPC_NT_UNSUPPORTED_TYPE ((NTSTATUS)0xC0020021) +#define RPC_NT_INVALID_TAG ((NTSTATUS)0xC0020022) +#define RPC_NT_INVALID_BOUND ((NTSTATUS)0xC0020023) +#define RPC_NT_NO_ENTRY_NAME ((NTSTATUS)0xC0020024) +#define RPC_NT_INVALID_NAME_SYNTAX ((NTSTATUS)0xC0020025) +#define RPC_NT_UNSUPPORTED_NAME_SYNTAX ((NTSTATUS)0xC0020026) +#define RPC_NT_UUID_NO_ADDRESS ((NTSTATUS)0xC0020028) +#define RPC_NT_DUPLICATE_ENDPOINT ((NTSTATUS)0xC0020029) +#define RPC_NT_UNKNOWN_AUTHN_TYPE ((NTSTATUS)0xC002002A) +#define RPC_NT_MAX_CALLS_TOO_SMALL ((NTSTATUS)0xC002002B) +#define RPC_NT_STRING_TOO_LONG ((NTSTATUS)0xC002002C) +#define RPC_NT_PROTSEQ_NOT_FOUND ((NTSTATUS)0xC002002D) +#define RPC_NT_PROCNUM_OUT_OF_RANGE ((NTSTATUS)0xC002002E) +#define RPC_NT_BINDING_HAS_NO_AUTH ((NTSTATUS)0xC002002F) +#define RPC_NT_UNKNOWN_AUTHN_SERVICE ((NTSTATUS)0xC0020030) +#define RPC_NT_UNKNOWN_AUTHN_LEVEL ((NTSTATUS)0xC0020031) +#define RPC_NT_INVALID_AUTH_IDENTITY ((NTSTATUS)0xC0020032) +#define RPC_NT_UNKNOWN_AUTHZ_SERVICE ((NTSTATUS)0xC0020033) +#define EPT_NT_INVALID_ENTRY ((NTSTATUS)0xC0020034) +#define EPT_NT_CANT_PERFORM_OP ((NTSTATUS)0xC0020035) +#define EPT_NT_NOT_REGISTERED ((NTSTATUS)0xC0020036) +#define RPC_NT_NOTHING_TO_EXPORT ((NTSTATUS)0xC0020037) +#define RPC_NT_INCOMPLETE_NAME ((NTSTATUS)0xC0020038) +#define RPC_NT_INVALID_VERS_OPTION ((NTSTATUS)0xC0020039) +#define RPC_NT_NO_MORE_MEMBERS ((NTSTATUS)0xC002003A) +#define RPC_NT_NOT_ALL_OBJS_UNEXPORTED ((NTSTATUS)0xC002003B) +#define RPC_NT_INTERFACE_NOT_FOUND ((NTSTATUS)0xC002003C) +#define RPC_NT_ENTRY_ALREADY_EXISTS ((NTSTATUS)0xC002003D) +#define RPC_NT_ENTRY_NOT_FOUND ((NTSTATUS)0xC002003E) +#define RPC_NT_NAME_SERVICE_UNAVAILABLE ((NTSTATUS)0xC002003F) +#define RPC_NT_INVALID_NAF_ID ((NTSTATUS)0xC0020040) +#define RPC_NT_CANNOT_SUPPORT ((NTSTATUS)0xC0020041) +#define RPC_NT_NO_CONTEXT_AVAILABLE ((NTSTATUS)0xC0020042) +#define RPC_NT_INTERNAL_ERROR ((NTSTATUS)0xC0020043) +#define RPC_NT_ZERO_DIVIDE ((NTSTATUS)0xC0020044) +#define RPC_NT_ADDRESS_ERROR ((NTSTATUS)0xC0020045) +#define RPC_NT_FP_DIV_ZERO ((NTSTATUS)0xC0020046) +#define RPC_NT_FP_UNDERFLOW ((NTSTATUS)0xC0020047) +#define RPC_NT_FP_OVERFLOW ((NTSTATUS)0xC0020048) +#define RPC_NT_CALL_IN_PROGRESS ((NTSTATUS)0xC0020049) +#define RPC_NT_NO_MORE_BINDINGS ((NTSTATUS)0xC002004A) +#define RPC_NT_GROUP_MEMBER_NOT_FOUND ((NTSTATUS)0xC002004B) +#define EPT_NT_CANT_CREATE ((NTSTATUS)0xC002004C) +#define RPC_NT_INVALID_OBJECT ((NTSTATUS)0xC002004D) +#define RPC_NT_NO_INTERFACES ((NTSTATUS)0xC002004F) +#define RPC_NT_CALL_CANCELLED ((NTSTATUS)0xC0020050) +#define RPC_NT_BINDING_INCOMPLETE ((NTSTATUS)0xC0020051) +#define RPC_NT_COMM_FAILURE ((NTSTATUS)0xC0020052) +#define RPC_NT_UNSUPPORTED_AUTHN_LEVEL ((NTSTATUS)0xC0020053) +#define RPC_NT_NO_PRINC_NAME ((NTSTATUS)0xC0020054) +#define RPC_NT_NOT_RPC_ERROR ((NTSTATUS)0xC0020055) +#define RPC_NT_SEC_PKG_ERROR ((NTSTATUS)0xC0020057) +#define RPC_NT_NOT_CANCELLED ((NTSTATUS)0xC0020058) +#define RPC_NT_INVALID_ASYNC_HANDLE ((NTSTATUS)0xC0020062) +#define RPC_NT_INVALID_ASYNC_CALL ((NTSTATUS)0xC0020063) + +#define RPC_NT_NO_MORE_ENTRIES ((NTSTATUS)0xC0030001) +#define RPC_NT_SS_CHAR_TRANS_OPEN_FAIL ((NTSTATUS)0xC0030002) +#define RPC_NT_SS_CHAR_TRANS_SHORT_FILE ((NTSTATUS)0xC0030003) +#define RPC_NT_SS_IN_NULL_CONTEXT ((NTSTATUS)0xC0030004) +#define RPC_NT_SS_CONTEXT_MISMATCH ((NTSTATUS)0xC0030005) +#define RPC_NT_SS_CONTEXT_DAMAGED ((NTSTATUS)0xC0030006) +#define RPC_NT_SS_HANDLES_MISMATCH ((NTSTATUS)0xC0030007) +#define RPC_NT_SS_CANNOT_GET_CALL_HANDLE ((NTSTATUS)0xC0030008) +#define RPC_NT_NULL_REF_POINTER ((NTSTATUS)0xC0030009) +#define RPC_NT_ENUM_VALUE_OUT_OF_RANGE ((NTSTATUS)0xC003000A) +#define RPC_NT_BYTE_COUNT_TOO_SMALL ((NTSTATUS)0xC003000B) +#define RPC_NT_BAD_STUB_DATA ((NTSTATUS)0xC003000C) +#define RPC_NT_INVALID_ES_ACTION ((NTSTATUS)0xC0030059) +#define RPC_NT_WRONG_ES_VERSION ((NTSTATUS)0xC003005A) +#define RPC_NT_WRONG_STUB_VERSION ((NTSTATUS)0xC003005B) +#define RPC_NT_INVALID_PIPE_OBJECT ((NTSTATUS)0xC003005C) +#define RPC_NT_INVALID_PIPE_OPERATION ((NTSTATUS)0xC003005D) +#define RPC_NT_WRONG_PIPE_VERSION ((NTSTATUS)0xC003005E) +#define RPC_NT_PIPE_CLOSED ((NTSTATUS)0xC003005F) +#define RPC_NT_PIPE_DISCIPLINE_ERROR ((NTSTATUS)0xC0030060) +#define RPC_NT_PIPE_EMPTY ((NTSTATUS)0xC0030061) + +#define STATUS_PNP_BAD_MPS_TABLE ((NTSTATUS)0xC0040035) +#define STATUS_PNP_TRANSLATION_FAILED ((NTSTATUS)0xC0040036) +#define STATUS_PNP_IRQ_TRANSLATION_FAILED ((NTSTATUS)0xC0040037) +#define STATUS_PNP_INVALID_ID ((NTSTATUS)0xC0040038) + +#define STATUS_ACPI_INVALID_OPCODE ((NTSTATUS)0xC0140001L) +#define STATUS_ACPI_STACK_OVERFLOW ((NTSTATUS)0xC0140002L) +#define STATUS_ACPI_ASSERT_FAILED ((NTSTATUS)0xC0140003L) +#define STATUS_ACPI_INVALID_INDEX ((NTSTATUS)0xC0140004L) +#define STATUS_ACPI_INVALID_ARGUMENT ((NTSTATUS)0xC0140005L) +#define STATUS_ACPI_FATAL ((NTSTATUS)0xC0140006L) +#define STATUS_ACPI_INVALID_SUPERNAME ((NTSTATUS)0xC0140007L) +#define STATUS_ACPI_INVALID_ARGTYPE ((NTSTATUS)0xC0140008L) +#define STATUS_ACPI_INVALID_OBJTYPE ((NTSTATUS)0xC0140009L) +#define STATUS_ACPI_INVALID_TARGETTYPE ((NTSTATUS)0xC014000AL) +#define STATUS_ACPI_INCORRECT_ARGUMENT_COUNT ((NTSTATUS)0xC014000BL) +#define STATUS_ACPI_ADDRESS_NOT_MAPPED ((NTSTATUS)0xC014000CL) +#define STATUS_ACPI_INVALID_EVENTTYPE ((NTSTATUS)0xC014000DL) +#define STATUS_ACPI_HANDLER_COLLISION ((NTSTATUS)0xC014000EL) +#define STATUS_ACPI_INVALID_DATA ((NTSTATUS)0xC014000FL) +#define STATUS_ACPI_INVALID_REGION ((NTSTATUS)0xC0140010L) +#define STATUS_ACPI_INVALID_ACCESS_SIZE ((NTSTATUS)0xC0140011L) +#define STATUS_ACPI_ACQUIRE_GLOBAL_LOCK ((NTSTATUS)0xC0140012L) +#define STATUS_ACPI_ALREADY_INITIALIZED ((NTSTATUS)0xC0140013L) +#define STATUS_ACPI_NOT_INITIALIZED ((NTSTATUS)0xC0140014L) +#define STATUS_ACPI_INVALID_MUTEX_LEVEL ((NTSTATUS)0xC0140015L) +#define STATUS_ACPI_MUTEX_NOT_OWNED ((NTSTATUS)0xC0140016L) +#define STATUS_ACPI_MUTEX_NOT_OWNER ((NTSTATUS)0xC0140017L) +#define STATUS_ACPI_RS_ACCESS ((NTSTATUS)0xC0140018L) +#define STATUS_ACPI_INVALID_TABLE ((NTSTATUS)0xC0140019L) +#define STATUS_ACPI_REG_HANDLER_FAILED ((NTSTATUS)0xC0140020L) +#define STATUS_ACPI_POWER_REQUEST_FAILED ((NTSTATUS)0xC0140021L) + +#define STATUS_CTX_WINSTATION_NAME_INVALID ((NTSTATUS)0xC00A0001) +#define STATUS_CTX_INVALID_PD ((NTSTATUS)0xC00A0002) +#define STATUS_CTX_PD_NOT_FOUND ((NTSTATUS)0xC00A0003) +#define STATUS_CTX_CLOSE_PENDING ((NTSTATUS)0xC00A0006) +#define STATUS_CTX_NO_OUTBUF ((NTSTATUS)0xC00A0007) +#define STATUS_CTX_MODEM_INF_NOT_FOUND ((NTSTATUS)0xC00A0008) +#define STATUS_CTX_INVALID_MODEMNAME ((NTSTATUS)0xC00A0009) +#define STATUS_CTX_RESPONSE_ERROR ((NTSTATUS)0xC00A000A) +#define STATUS_CTX_MODEM_RESPONSE_TIMEOUT ((NTSTATUS)0xC00A000B) +#define STATUS_CTX_MODEM_RESPONSE_NO_CARRIER ((NTSTATUS)0xC00A000C) +#define STATUS_CTX_MODEM_RESPONSE_NO_DIALTONE ((NTSTATUS)0xC00A000D) +#define STATUS_CTX_MODEM_RESPONSE_BUSY ((NTSTATUS)0xC00A000E) +#define STATUS_CTX_MODEM_RESPONSE_VOICE ((NTSTATUS)0xC00A000F) +#define STATUS_CTX_TD_ERROR ((NTSTATUS)0xC00A0010) +#define STATUS_CTX_LICENSE_CLIENT_INVALID ((NTSTATUS)0xC00A0012) +#define STATUS_CTX_LICENSE_NOT_AVAILABLE ((NTSTATUS)0xC00A0013) +#define STATUS_CTX_LICENSE_EXPIRED ((NTSTATUS)0xC00A0014) +#define STATUS_CTX_WINSTATION_NOT_FOUND ((NTSTATUS)0xC00A0015) +#define STATUS_CTX_WINSTATION_NAME_COLLISION ((NTSTATUS)0xC00A0016) +#define STATUS_CTX_WINSTATION_BUSY ((NTSTATUS)0xC00A0017) +#define STATUS_CTX_BAD_VIDEO_MODE ((NTSTATUS)0xC00A0018) +#define STATUS_CTX_GRAPHICS_INVALID ((NTSTATUS)0xC00A0022) +#define STATUS_CTX_NOT_CONSOLE ((NTSTATUS)0xC00A0024) +#define STATUS_CTX_CLIENT_QUERY_TIMEOUT ((NTSTATUS)0xC00A0026) +#define STATUS_CTX_CONSOLE_DISCONNECT ((NTSTATUS)0xC00A0027) +#define STATUS_CTX_CONSOLE_CONNECT ((NTSTATUS)0xC00A0028) +#define STATUS_CTX_SHADOW_DENIED ((NTSTATUS)0xC00A002A) +#define STATUS_CTX_WINSTATION_ACCESS_DENIED ((NTSTATUS)0xC00A002B) +#define STATUS_CTX_INVALID_WD ((NTSTATUS)0xC00A002E) +#define STATUS_CTX_WD_NOT_FOUND ((NTSTATUS)0xC00A002F) +#define STATUS_CTX_SHADOW_INVALID ((NTSTATUS)0xC00A0030) +#define STATUS_CTX_SHADOW_DISABLED ((NTSTATUS)0xC00A0031) +#define STATUS_RDP_PROTOCOL_ERROR ((NTSTATUS)0xC00A0032) +#define STATUS_CTX_CLIENT_LICENSE_NOT_SET ((NTSTATUS)0xC00A0033) +#define STATUS_CTX_CLIENT_LICENSE_IN_USE ((NTSTATUS)0xC00A0034) +#define STATUS_CTX_SHADOW_ENDED_BY_MODE_CHANGE ((NTSTATUS)0xC00A0035) +#define STATUS_CTX_SHADOW_NOT_RUNNING ((NTSTATUS)0xC00A0036) + +#define STATUS_CLUSTER_INVALID_NODE ((NTSTATUS)0xC0130001) +#define STATUS_CLUSTER_NODE_EXISTS ((NTSTATUS)0xC0130002) +#define STATUS_CLUSTER_JOIN_IN_PROGRESS ((NTSTATUS)0xC0130003) +#define STATUS_CLUSTER_NODE_NOT_FOUND ((NTSTATUS)0xC0130004) +#define STATUS_CLUSTER_LOCAL_NODE_NOT_FOUND ((NTSTATUS)0xC0130005) +#define STATUS_CLUSTER_NETWORK_EXISTS ((NTSTATUS)0xC0130006) +#define STATUS_CLUSTER_NETWORK_NOT_FOUND ((NTSTATUS)0xC0130007) +#define STATUS_CLUSTER_NETINTERFACE_EXISTS ((NTSTATUS)0xC0130008) +#define STATUS_CLUSTER_NETINTERFACE_NOT_FOUND ((NTSTATUS)0xC0130009) +#define STATUS_CLUSTER_INVALID_REQUEST ((NTSTATUS)0xC013000A) +#define STATUS_CLUSTER_INVALID_NETWORK_PROVIDER ((NTSTATUS)0xC013000B) +#define STATUS_CLUSTER_NODE_DOWN ((NTSTATUS)0xC013000C) +#define STATUS_CLUSTER_NODE_UNREACHABLE ((NTSTATUS)0xC013000D) +#define STATUS_CLUSTER_NODE_NOT_MEMBER ((NTSTATUS)0xC013000E) +#define STATUS_CLUSTER_JOIN_NOT_IN_PROGRESS ((NTSTATUS)0xC013000F) +#define STATUS_CLUSTER_INVALID_NETWORK ((NTSTATUS)0xC0130010) +#define STATUS_CLUSTER_NO_NET_ADAPTERS ((NTSTATUS)0xC0130011) +#define STATUS_CLUSTER_NODE_UP ((NTSTATUS)0xC0130012) +#define STATUS_CLUSTER_NODE_PAUSED ((NTSTATUS)0xC0130013) +#define STATUS_CLUSTER_NODE_NOT_PAUSED ((NTSTATUS)0xC0130014) +#define STATUS_CLUSTER_NO_SECURITY_CONTEXT ((NTSTATUS)0xC0130015) +#define STATUS_CLUSTER_NETWORK_NOT_INTERNAL ((NTSTATUS)0xC0130016) +#define STATUS_CLUSTER_POISONED ((NTSTATUS)0xC0130017) + +#define STATUS_SXS_SECTION_NOT_FOUND ((NTSTATUS)0xC0150001) +#define STATUS_SXS_CANT_GEN_ACTCTX ((NTSTATUS)0xC0150002) +#define STATUS_SXS_INVALID_ACTCTXDATA_FORMAT ((NTSTATUS)0xC0150003) +#define STATUS_SXS_ASSEMBLY_NOT_FOUND ((NTSTATUS)0xC0150004) +#define STATUS_SXS_MANIFEST_FORMAT_ERROR ((NTSTATUS)0xC0150005) +#define STATUS_SXS_MANIFEST_PARSE_ERROR ((NTSTATUS)0xC0150006) +#define STATUS_SXS_ACTIVATION_CONTEXT_DISABLED ((NTSTATUS)0xC0150007) +#define STATUS_SXS_KEY_NOT_FOUND ((NTSTATUS)0xC0150008) +#define STATUS_SXS_VERSION_CONFLICT ((NTSTATUS)0xC0150009) +#define STATUS_SXS_WRONG_SECTION_TYPE ((NTSTATUS)0xC015000A) +#define STATUS_SXS_THREAD_QUERIES_DISABLED ((NTSTATUS)0xC015000B) +#define STATUS_SXS_ASSEMBLY_MISSING ((NTSTATUS)0xC015000C) +#define STATUS_SXS_PROCESS_DEFAULT_ALREADY_SET ((NTSTATUS)0xC015000E) +#define STATUS_SXS_EARLY_DEACTIVATION ((NTSTATUS)0xC015000F) +#define STATUS_SXS_INVALID_DEACTIVATION ((NTSTATUS)0xC0150010) +#define STATUS_SXS_MULTIPLE_DEACTIVATION ((NTSTATUS)0xC0150011) +#define STATUS_SXS_SYSTEM_DEFAULT_ACTIVATION_CONTEXT_EMPTY ((NTSTATUS)0xC0150012) +#define STATUS_SXS_PROCESS_TERMINATION_REQUESTED ((NTSTATUS)0xC0150013) +#define STATUS_SXS_CORRUPT_ACTIVATION_STACK ((NTSTATUS)0xC0150014) +#define STATUS_SXS_CORRUPTION ((NTSTATUS)0xC0150015) + +#endif /* WIN32_NO_STATUS */ #ifdef __cplusplus } #endif -#endif +#endif /* _NTSTATUS_ */ diff --git a/reactos/include/ddk/tvout.h b/reactos/include/psdk/tvout.h similarity index 81% rename from reactos/include/ddk/tvout.h rename to reactos/include/psdk/tvout.h index d2e33c20aa0..817461406d5 100644 --- a/reactos/include/ddk/tvout.h +++ b/reactos/include/psdk/tvout.h @@ -20,14 +20,7 @@ * */ -#ifndef __TVOUT_H -#define __TVOUT_H - - -#if _MSC_VER > 1000 #pragma once -#endif - #ifndef GUID_DEFINED #include @@ -84,30 +77,27 @@ #define VP_CP_CMD_CHANGE 0x00000004 typedef struct _VIDEOPARAMETERS { - GUID Guid; - ULONG dwOffset; - ULONG dwCommand; - ULONG dwFlags; - ULONG dwMode; - ULONG dwTVStandard; - ULONG dwAvailableModes; - ULONG dwAvailableTVStandard; - ULONG dwFlickerFilter; - ULONG dwOverScanX; - ULONG dwOverScanY; - ULONG dwMaxUnscaledX; - ULONG dwMaxUnscaledY; - ULONG dwPositionX; - ULONG dwPositionY; - ULONG dwBrightness; - ULONG dwContrast; - ULONG dwCPType; - ULONG dwCPCommand; - ULONG dwCPStandard; - ULONG dwCPKey; - ULONG bCP_APSTriggerBits; - UCHAR bOEMCopyProtection[256]; -} VIDEOPARAMETERS, *PVIDEOPARAMETERS, FAR *LPVIDEOPARAMETERS; - - -#endif /* __TVOUT_H */ + GUID Guid; + ULONG dwOffset; + ULONG dwCommand; + ULONG dwFlags; + ULONG dwMode; + ULONG dwTVStandard; + ULONG dwAvailableModes; + ULONG dwAvailableTVStandard; + ULONG dwFlickerFilter; + ULONG dwOverScanX; + ULONG dwOverScanY; + ULONG dwMaxUnscaledX; + ULONG dwMaxUnscaledY; + ULONG dwPositionX; + ULONG dwPositionY; + ULONG dwBrightness; + ULONG dwContrast; + ULONG dwCPType; + ULONG dwCPCommand; + ULONG dwCPStandard; + ULONG dwCPKey; + ULONG bCP_APSTriggerBits; + UCHAR bOEMCopyProtection[256]; +} VIDEOPARAMETERS, *PVIDEOPARAMETERS, *LPVIDEOPARAMETERS; From d16419c3dac681b81a418149c2d91f8da611bf42 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 29 Mar 2010 02:51:02 +0000 Subject: [PATCH 071/134] fix build svn path=/trunk/; revision=46549 --- reactos/subsystems/win32/win32k/pch.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/reactos/subsystems/win32/win32k/pch.h b/reactos/subsystems/win32/win32k/pch.h index 3eae2acdda9..4bbbeb9c148 100644 --- a/reactos/subsystems/win32/win32k/pch.h +++ b/reactos/subsystems/win32/win32k/pch.h @@ -13,11 +13,11 @@ #define _NO_COM /* DDK/NDK/SDK Headers */ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include /* Win32 Headers */ /* FIXME: Defines in winbase.h that we need... */ From acc9e3e78a4ee2aaa05c0ea698c64e4ace8f3337 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Mon, 29 Mar 2010 02:59:44 +0000 Subject: [PATCH 072/134] [NTOSKRNL] - Set the IRP_SYNCHRONOUS_API flag on IRPs created by IoBuildSynchronousFsdRequest svn path=/trunk/; revision=46550 --- reactos/ntoskrnl/io/iomgr/irp.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/reactos/ntoskrnl/io/iomgr/irp.c b/reactos/ntoskrnl/io/iomgr/irp.c index 0863f58907b..30107c16949 100644 --- a/reactos/ntoskrnl/io/iomgr/irp.c +++ b/reactos/ntoskrnl/io/iomgr/irp.c @@ -966,9 +966,12 @@ IoBuildSynchronousFsdRequest(IN ULONG MajorFunction, IoStatusBlock ); if (!Irp) return NULL; - /* Set the Event which makes it Syncronous */ + /* Associate the caller's event object with this IRP */ Irp->UserEvent = Event; + /* Set the synchronous flag */ + Irp->Flags |= IRP_SYNCHRONOUS_API; + /* Sync IRPs are queued to requestor thread's irp cancel/cleanup list */ IoQueueThreadIrp(Irp); return Irp; From 1a929a8b218e190c32d3ced03823407c42a3cdce Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 29 Mar 2010 03:16:25 +0000 Subject: [PATCH 073/134] Reintegrate header branch part 5/x - Formatting and properties - delete xmldsodid.h svn path=/trunk/; revision=46551 --- reactos/include/ddk/wmilib.h | 38 ++++++++++++++-------------- reactos/include/ddk/xmldsodid.h | 10 -------- reactos/include/ndk/pstypes.h | 2 +- reactos/include/ndk/rtlfuncs.h | 24 +++++++++--------- reactos/include/psdk/usbioctl.h | 2 ++ reactos/subsystems/subsystems.rbuild | 6 ++--- 6 files changed, 37 insertions(+), 45 deletions(-) delete mode 100644 reactos/include/ddk/xmldsodid.h diff --git a/reactos/include/ddk/wmilib.h b/reactos/include/ddk/wmilib.h index 22bb087a2a7..a0a5bdc5f22 100644 --- a/reactos/include/ddk/wmilib.h +++ b/reactos/include/ddk/wmilib.h @@ -30,6 +30,14 @@ typedef NTSTATUS OUT PUNICODE_STRING *RegistryPath OPTIONAL, IN OUT PUNICODE_STRING MofResourceName, OUT PDEVICE_OBJECT *Pdo OPTIONAL); + +typedef NTSTATUS +(NTAPI *PWMI_FUNCTION_CONTROL) ( + IN OUT PDEVICE_OBJECT DeviceObject, + IN OUT PIRP Irp, + IN ULONG GuidIndex, + IN WMIENABLEDISABLECONTROL Function, + IN BOOLEAN Enable); typedef NTSTATUS (NTAPI *PWMI_QUERY_DATABLOCK) ( @@ -42,6 +50,17 @@ typedef NTSTATUS IN ULONG BufferAvail, OUT PUCHAR Buffer OPTIONAL); +typedef NTSTATUS +(NTAPI *PWMI_EXECUTE_METHOD) ( + IN OUT PDEVICE_OBJECT DeviceObject, + IN OUT PIRP Irp, + IN ULONG GuidIndex, + IN ULONG InstanceIndex, + IN ULONG MethodId, + IN ULONG InBufferSize, + IN ULONG OutBufferSize, + IN OUT PUCHAR Buffer); + typedef NTSTATUS (NTAPI *PWMI_SET_DATABLOCK) ( IN OUT PDEVICE_OBJECT DeviceObject, @@ -61,25 +80,6 @@ typedef NTSTATUS IN ULONG BufferSize, IN PUCHAR Buffer); -typedef NTSTATUS -(NTAPI *PWMI_EXECUTE_METHOD) ( - IN OUT PDEVICE_OBJECT DeviceObject, - IN OUT PIRP Irp, - IN ULONG GuidIndex, - IN ULONG InstanceIndex, - IN ULONG MethodId, - IN ULONG InBufferSize, - IN ULONG OutBufferSize, - IN OUT PUCHAR Buffer); - -typedef NTSTATUS -(NTAPI *PWMI_FUNCTION_CONTROL) ( - IN OUT PDEVICE_OBJECT DeviceObject, - IN OUT PIRP Irp, - IN ULONG GuidIndex, - IN WMIENABLEDISABLECONTROL Function, - IN BOOLEAN Enable); - typedef struct _WMILIB_CONTEXT { ULONG GuidCount; PWMIGUIDREGINFO GuidList; diff --git a/reactos/include/ddk/xmldsodid.h b/reactos/include/ddk/xmldsodid.h deleted file mode 100644 index d80d1463f92..00000000000 --- a/reactos/include/ddk/xmldsodid.h +++ /dev/null @@ -1,10 +0,0 @@ - -#ifndef __XMLDSODID_H__ -#define __XMLDSODID_H__ -#define DISPID_XOBJ_MIN 0x00010000 -#define DISPID_XOBJ_MAX 0x0001FFFF -#define DISPID_XOBJ_BASE DISPID_XOBJ_MIN -#define DISPID_XMLDSO DISPID_XOBJ_BASE -#define DISPID_XMLDSO_DOCUMENT DISPID_XMLDSO + 1 -#define DISPID_XMLDSO_JAVADSOCOMPATIBLE DISPID_XMLDSO_DOCUMENT + 1 -#endif \ No newline at end of file diff --git a/reactos/include/ndk/pstypes.h b/reactos/include/ndk/pstypes.h index d423b7a2df2..43b44680960 100644 --- a/reactos/include/ndk/pstypes.h +++ b/reactos/include/ndk/pstypes.h @@ -703,7 +703,7 @@ typedef struct _PROCESS_BASIC_INFORMATION KPRIORITY BasePriority; ULONG_PTR UniqueProcessId; ULONG_PTR InheritedFromUniqueProcessId; -} PROCESS_BASIC_INFORMATION,*PPROCESS_BASIC_INFORMATION; +} PROCESS_BASIC_INFORMATION, *PPROCESS_BASIC_INFORMATION; typedef struct _PROCESS_ACCESS_TOKEN { diff --git a/reactos/include/ndk/rtlfuncs.h b/reactos/include/ndk/rtlfuncs.h index 210dd2fffc5..18aa4749ad4 100644 --- a/reactos/include/ndk/rtlfuncs.h +++ b/reactos/include/ndk/rtlfuncs.h @@ -1690,6 +1690,18 @@ RtlDuplicateUnicodeString( OUT PUNICODE_STRING DestinationString ); +// +// Memory Functions +// +NTSYSAPI +VOID +NTAPI +RtlFillMemoryUlong( + IN PVOID Destination, + IN ULONG Length, + IN ULONG Fill +); + #endif NTSYSAPI @@ -1912,18 +1924,6 @@ RtlLookupAtomInAtomTable( OUT PRTL_ATOM Atom ); -// -// Memory Functions -// -NTSYSAPI -VOID -NTAPI -RtlFillMemoryUlong( - IN PVOID Destination, - IN ULONG Length, - IN ULONG Fill -); - // // Process Management Functions // diff --git a/reactos/include/psdk/usbioctl.h b/reactos/include/psdk/usbioctl.h index 69541cb0052..d9aebda5d3f 100644 --- a/reactos/include/psdk/usbioctl.h +++ b/reactos/include/psdk/usbioctl.h @@ -665,6 +665,8 @@ typedef struct _USB_DEVICE_PERFORMANCE_INFO { #include +#endif /* USB_KERNEL_IOCTL */ + #ifdef __cplusplus } #endif diff --git a/reactos/subsystems/subsystems.rbuild b/reactos/subsystems/subsystems.rbuild index 8dc879444d4..3bbdd8c4034 100644 --- a/reactos/subsystems/subsystems.rbuild +++ b/reactos/subsystems/subsystems.rbuild @@ -2,9 +2,9 @@ - - - + + + From dabbfbee68fa85dcadeee86ede58612dc5e55cfa Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 29 Mar 2010 03:49:11 +0000 Subject: [PATCH 074/134] Reintegrate header branch part 6/x ntdef.h and winnt.h: add GROUP_AFFINITY, formatting svn path=/trunk/; revision=46552 --- reactos/include/psdk/ntdef.h | 296 ++++++++++------------------------- reactos/include/psdk/winnt.h | 6 + 2 files changed, 89 insertions(+), 213 deletions(-) diff --git a/reactos/include/psdk/ntdef.h b/reactos/include/psdk/ntdef.h index a0aae3ec3a3..fdc365085b2 100644 --- a/reactos/include/psdk/ntdef.h +++ b/reactos/include/psdk/ntdef.h @@ -1,15 +1,13 @@ -#ifndef _NTDEF_H -#define _NTDEF_H +#ifndef _NTDEF_ +#define _NTDEF_ -// -// Dependencies -// +/* Dependencies */ #include #include #include #include -// FIXME: Should we include these here? +// FIXME: Shouldn't be included! #include #include @@ -24,11 +22,8 @@ typedef unsigned long POINTER_64; // FIXME! HACK!!! +/* Pseudo Modifiers for Input Parameters */ - -// -// Pseudo Modifiers for Input Parameters -// #ifndef IN #define IN #endif @@ -54,29 +49,21 @@ typedef unsigned long POINTER_64; // FIXME! HACK!!! #endif -// -// Defines the "size" of an any-size array -// +/* Defines the "size" of an any-size array */ #ifndef ANYSIZE_ARRAY #define ANYSIZE_ARRAY 1 #endif -// -// Constant modifier -// +/* Constant modifier */ #ifndef CONST #define CONST const #endif -// -// TRUE/FALSE -// +/* TRUE/FALSE */ #define FALSE 0 #define TRUE 1 -// -// NULL/NULL64 -// +/* NULL/NULL64 */ #ifndef NULL #ifdef __cplusplus #define NULL 0 @@ -85,22 +72,8 @@ typedef unsigned long POINTER_64; // FIXME! HACK!!! #define NULL ((void *)0) #define NULL64 ((void * POINTER_64)0) #endif -#endif // NULL +#endif /* NULL */ -typedef enum _EVENT_TYPE { - NotificationEvent, - SynchronizationEvent -} EVENT_TYPE; - -typedef enum _TIMER_TYPE { - NotificationTimer, - SynchronizationTimer -} TIMER_TYPE; - -typedef enum _WAIT_TYPE { - WaitAll, - WaitAny -} WAIT_TYPE; // // FIXME @@ -171,35 +144,27 @@ typedef enum _WAIT_TYPE { #define ARGUMENT_PRESENT(ArgumentPointer) \ ((CHAR*)((ULONG_PTR)(ArgumentPointer)) != (CHAR*)NULL) -// -// Returns the base address of a structure from a structure member -// +/* Returns the base address of a structure from a structure member */ #ifndef CONTAINING_RECORD #define CONTAINING_RECORD(address, type, field) \ ((type *)(((ULONG_PTR)address) - (ULONG_PTR)(&(((type *)0)->field)))) #endif -// -// Returns the byte offset of the specified structure's member -// +/* Returns the byte offset of the specified structure's member */ #ifndef __GNUC__ #define FIELD_OFFSET(Type, Field) ((LONG)(LONG_PTR)&(((Type*) 0)->Field)) #else #define FIELD_OFFSET(Type, Field) __builtin_offsetof(Type, Field) #endif -// -// Returns the type's alignment -// +/* Returns the type's alignment */ #if defined(_MSC_VER) && (_MSC_VER >= 1300) #define TYPE_ALIGNMENT(t) __alignof(t) #else #define TYPE_ALIGNMENT(t) FIELD_OFFSET( struct { char x; t test; }, test ) #endif -// -// Calling Conventions -// +/* Calling Conventions */ #if defined(_M_IX86) #define FASTCALL __fastcall #else @@ -208,21 +173,13 @@ typedef enum _WAIT_TYPE { #define NTAPI __stdcall -// -// Used by the DDK exclusively , don't put in drivers -// -#define DDKAPI __stdcall // Use NTAPI instead -#define DDKCDECLAPI __cdecl // Just use __cdecl -// -// Import and Export Specifiers -// +/* Import and Export Specifiers */ -// Done the same way as in windef.h for now +/* Done the same way as in windef.h for now */ #define DECLSPEC_IMPORT __declspec(dllimport) #define DECLSPEC_NORETURN __declspec(noreturn) - #ifndef DECLSPEC_ADDRSAFE #if (_MSC_VER >= 1200) && (defined(_M_ALPHA) || defined(_M_AXP64)) #define DECLSPEC_ADDRSAFE __declspec(address_safe) @@ -243,9 +200,7 @@ typedef enum _WAIT_TYPE { #endif #endif -// -// Inlines -// +/* Inlines */ #ifndef FORCEINLINE #if (_MSC_VER >= 1200) #define FORCEINLINE __forceinline @@ -272,9 +227,7 @@ typedef enum _WAIT_TYPE { #define NTAPI_INLINE #endif -// -// Use to specify structure alignment -// +/* Use to specify structure alignment */ #ifndef DECLSPEC_ALIGN #if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(MIDL_PASS) #define DECLSPEC_ALIGN(x) __declspec(align(x)) @@ -285,21 +238,13 @@ typedef enum _WAIT_TYPE { #endif #endif - - -// -// Use to silence unused variable warnings when it is intentional -// +/* Use to silence unused variable warnings when it is intentional */ #define UNREFERENCED_PARAMETER(P) {(P)=(P);} #define UNREFERENCED_LOCAL_VARIABLE(L) {(L)=(L);} #define DBG_UNREFERENCED_PARAMETER(P) #define DBG_UNREFERENCED_LOCAL_VARIABLE(L) - - -// -// min/max helper macros -// +/* min/max helper macros */ #ifndef NOMINMAX #ifndef min @@ -310,25 +255,17 @@ typedef enum _WAIT_TYPE { #define max(a,b) (((a) > (b)) ? (a) : (b)) #endif -#endif // NOMINMAX +#endif /* NOMINMAX */ - - -// -// Tell windef.h that we have defined some basic types -// +/* Tell windef.h that we have defined some basic types */ #define BASETYPES -// -// Void Pointers -// +/* Void Pointers */ typedef void *PVOID; //typedef void * POINTER_64 PVOID64; typedef PVOID PVOID64; // FIXME! -// -// Handle Type -// +/* Handle Type */ #ifdef STRICT typedef void *HANDLE; #define DECLARE_HANDLE(n) typedef struct n##__{int i;}*n @@ -338,9 +275,7 @@ typedef PVOID HANDLE; #endif typedef HANDLE *PHANDLE; -// -// Upper-Case Versions of Some Standard C Types -// +/* Upper-Case Versions of Some Standard C Types */ #ifndef VOID #define VOID void typedef char CHAR; @@ -352,47 +287,25 @@ typedef int INT; #endif typedef double DOUBLE; -// -// Used to store a non-float 8 byte aligned structure -// -typedef struct _QUAD -{ - _ANONYMOUS_UNION union - { - __GNU_EXTENSION __int64 UseThisFieldToCopy; - double DoNotUseThisField; - }; -} QUAD, *PQUAD, UQUAD, *PUQUAD; - - -// -// Unsigned Types -// +/* Unsigned Types */ typedef unsigned char UCHAR, *PUCHAR; typedef unsigned short USHORT, *PUSHORT; typedef unsigned long ULONG, *PULONG; typedef CONST UCHAR *PCUCHAR; typedef CONST USHORT *PCUSHORT; typedef CONST ULONG *PCULONG; - typedef UCHAR FCHAR; typedef USHORT FSHORT; typedef ULONG FLONG; -typedef UCHAR BOOLEAN; -typedef BOOLEAN *PBOOLEAN; - +typedef UCHAR BOOLEAN, *PBOOLEAN; typedef ULONG LOGICAL; typedef ULONG *PLOGICAL; -// -// Signed Types -// +/* Signed Types */ typedef SHORT *PSHORT; typedef LONG *PLONG; - typedef LONG NTSTATUS; typedef NTSTATUS *PNTSTATUS; - typedef signed char SCHAR; typedef SCHAR *PSCHAR; @@ -401,22 +314,15 @@ typedef SCHAR *PSCHAR; typedef LONG HRESULT; #endif -// -// 64-bit types -// +/* 64-bit types */ __GNU_EXTENSION typedef __int64 LONGLONG, *PLONGLONG; __GNU_EXTENSION typedef unsigned __int64 ULONGLONG, *PULONGLONG; typedef ULONGLONG DWORDLONG, *PDWORDLONG; -// -// Update Sequence Number -// +/* Update Sequence Number */ typedef LONGLONG USN; - -// -// ANSI (Multi-byte Character) types -// +/* ANSI (Multi-byte Character) types */ typedef CHAR *PCHAR, *LPCH, *PCH; typedef CONST CHAR *LPCCH, *PCCH; typedef CHAR *NPSTR, *LPSTR, *PSTR; @@ -425,15 +331,11 @@ typedef CONST PSTR *PCZPSTR; typedef CONST CHAR *LPCSTR, *PCSTR; typedef PCSTR *PZPCSTR; -// -// Pointer to an Asciiz string -// +/* Pointer to an Asciiz string */ typedef CHAR *PSZ; typedef CONST char *PCSZ; -// -// UNICODE (Wide Character) types -// +/* UNICODE (Wide Character) types */ typedef wchar_t WCHAR; typedef WCHAR *PWCHAR, *LPWCH, *PWCH; typedef CONST WCHAR *LPCWCH, *PCWCH; @@ -445,25 +347,27 @@ typedef CONST WCHAR *LPCWSTR, *PCWSTR; typedef PCWSTR *PZPCWSTR; typedef CONST WCHAR UNALIGNED *LPCUWSTR, *PCUWSTR; -// -// Cardinal Data Types -// +/* Cardinal Data Types */ typedef char CCHAR, *PCCHAR; typedef short CSHORT, *PCSHORT; typedef ULONG CLONG, *PCLONG; -// -// NLS basics (Locale and Language Ids) -// +/* NLS basics (Locale and Language Ids) */ typedef ULONG LCID; typedef PULONG PLCID; typedef USHORT LANGID; +/* Used to store a non-float 8 byte aligned structure */ +typedef struct _QUAD +{ + _ANONYMOUS_UNION union + { + __GNU_EXTENSION __int64 UseThisFieldToCopy; + double DoNotUseThisField; + } DUMMYUNIONNAME; +} QUAD, *PQUAD, UQUAD, *PUQUAD; - -// -// Large Integer Unions -// +/* Large Integer Unions */ #if defined(MIDL_PASS) typedef struct _LARGE_INTEGER { #else @@ -478,7 +382,7 @@ typedef union _LARGE_INTEGER { ULONG LowPart; LONG HighPart; } u; -#endif //MIDL_PASS +#endif /* MIDL_PASS */ LONGLONG QuadPart; } LARGE_INTEGER, *PLARGE_INTEGER; @@ -496,40 +400,26 @@ typedef union _ULARGE_INTEGER { ULONG LowPart; ULONG HighPart; } u; -#endif //MIDL_PASS +#endif /* MIDL_PASS */ ULONGLONG QuadPart; } ULARGE_INTEGER, *PULARGE_INTEGER; -// -// Physical Addresses are always treated as 64-bit wide -// +/* Physical Addresses are always treated as 64-bit wide */ typedef LARGE_INTEGER PHYSICAL_ADDRESS, *PPHYSICAL_ADDRESS; - - -// -// Locally Unique Identifier -// +/* Locally Unique Identifier */ typedef struct _LUID { ULONG LowPart; LONG HighPart; } LUID, *PLUID; - - -// -// Native API Return Value Macros -// +/* Native API Return Value Macros */ #define NT_SUCCESS(Status) (((NTSTATUS)(Status)) >= 0) #define NT_INFORMATION(Status) ((((ULONG)(Status)) >> 30) == 1) #define NT_WARNING(Status) ((((ULONG)(Status)) >> 30) == 2) #define NT_ERROR(Status) ((((ULONG)(Status)) >> 30) == 3) - - -// -// String Types -// +/* String Types */ typedef struct _UNICODE_STRING { USHORT Length; USHORT MaximumLength; @@ -575,9 +465,7 @@ typedef struct _STRING64 { UNICODE_STRING64, *PUNICODE_STRING64, ANSI_STRING64, *PANSI_STRING64; -// -// LangID and NLS -// +/* LangID and NLS */ #define MAKELANGID(p, s) ((((USHORT)(s)) << 10) | (USHORT)(p)) #define PRIMARYLANGID(lgid) ((USHORT)(lgid) & 0x3ff) #define SUBLANGID(lgid) ((USHORT)(lgid) >> 10) @@ -594,10 +482,7 @@ typedef struct _STRING64 { #define SORTVERSIONFROMLCID(lcid) ((USHORT)((((ULONG)(lcid)) >> 20) & 0xf)) - -// -// Object Attributes -// +/* Object Attributes */ typedef struct _OBJECT_ATTRIBUTES { ULONG Length; HANDLE RootDirectory; @@ -608,9 +493,7 @@ typedef struct _OBJECT_ATTRIBUTES { } OBJECT_ATTRIBUTES, *POBJECT_ATTRIBUTES; typedef CONST OBJECT_ATTRIBUTES *PCOBJECT_ATTRIBUTES; -// -// Values for the Attributes member -// +/* Values for the Attributes member */ #define OBJ_INHERIT 0x00000002 #define OBJ_PERMANENT 0x00000010 #define OBJ_EXCLUSIVE 0x00000020 @@ -621,9 +504,7 @@ typedef CONST OBJECT_ATTRIBUTES *PCOBJECT_ATTRIBUTES; #define OBJ_FORCE_ACCESS_CHECK 0x00000400 #define OBJ_VALID_ATTRIBUTES 0x000007F2 -// -// Helper Macro -// +/* Helper Macro */ #define InitializeObjectAttributes(p,n,a,r,s) { \ (p)->Length = sizeof(OBJECT_ATTRIBUTES); \ (p)->RootDirectory = (r); \ @@ -633,22 +514,29 @@ typedef CONST OBJECT_ATTRIBUTES *PCOBJECT_ATTRIBUTES; (p)->SecurityQualityOfService = NULL; \ } - - -// -// Product Types -// +/* Product Types */ typedef enum _NT_PRODUCT_TYPE { NtProductWinNt = 1, NtProductLanManNt, NtProductServer } NT_PRODUCT_TYPE, *PNT_PRODUCT_TYPE; +typedef enum _EVENT_TYPE { + NotificationEvent, + SynchronizationEvent +} EVENT_TYPE; +typedef enum _TIMER_TYPE { + NotificationTimer, + SynchronizationTimer +} TIMER_TYPE; -// -// Doubly Linked Lists -// +typedef enum _WAIT_TYPE { + WaitAll, + WaitAny +} WAIT_TYPE; + +/* Doubly Linked Lists */ typedef struct _LIST_ENTRY { struct _LIST_ENTRY *Flink; struct _LIST_ENTRY *Blink; @@ -666,14 +554,11 @@ typedef struct LIST_ENTRY64 ULONGLONG Blink; } LIST_ENTRY64, *PLIST_ENTRY64; -// -// Singly Linked Lists -// +/* Singly Linked Lists */ typedef struct _SINGLE_LIST_ENTRY { struct _SINGLE_LIST_ENTRY *Next; } SINGLE_LIST_ENTRY, *PSINGLE_LIST_ENTRY; - typedef struct _PROCESSOR_NUMBER { USHORT Group; UCHAR Number; @@ -681,16 +566,19 @@ typedef struct _PROCESSOR_NUMBER { } PROCESSOR_NUMBER, *PPROCESSOR_NUMBER; typedef EXCEPTION_DISPOSITION -(DDKAPI *PEXCEPTION_ROUTINE)( +(NTAPI *PEXCEPTION_ROUTINE)( IN struct _EXCEPTION_RECORD *ExceptionRecord, IN PVOID EstablisherFrame, IN OUT struct _CONTEXT *ContextRecord, IN OUT PVOID DispatcherContext); +typedef struct _GROUP_AFFINITY { + KAFFINITY Mask; + USHORT Group; + USHORT Reserved[3]; +} GROUP_AFFINITY, *PGROUP_AFFINITY; -// -// Helper Macros -// +/* Helper Macros */ #define RTL_CONSTANT_STRING(s) { sizeof(s)-sizeof((s)[0]), sizeof(s), s } #define RTL_FIELD_SIZE(type, field) (sizeof(((type *)0)->field)) @@ -704,11 +592,7 @@ typedef EXCEPTION_DISPOSITION #endif #define ARRAYSIZE(A) RTL_NUMBER_OF_V2(A) - - -// -// Type Limits -// +/* Type Limits */ #define MINCHAR 0x80 #define MAXCHAR 0x7f #define MINSHORT 0x8000 @@ -720,29 +604,17 @@ typedef EXCEPTION_DISPOSITION #define MAXULONG 0xffffffff #define MAXLONGLONG (0x7fffffffffffffffLL) - - -// -// Multiplication and Shift Operations -// +/* Multiplication and Shift Operations */ #define Int32x32To64(a,b) ((LONGLONG)(a)*(LONGLONG)(b)) #define UInt32x32To64(a,b) ((DWORDLONG)(a)*(DWORDLONG)(b)) #define Int64ShllMod32(a,b) ((DWORDLONG)(a)<<(b)) #define Int64ShraMod32(a,b) ((LONGLONG)(a)>>(b)) #define Int64ShrlMod32(a,b) ((DWORDLONG)(a)>>(b)) - - -// -// C_ASSERT Definition -// +/* C_ASSERT Definition */ #define C_ASSERT(expr) extern char (*c_assert(void)) [(expr) ? 1 : -1] - - -// -// Primary language IDs. -// +/* Primary language IDs. */ #define LANG_NEUTRAL 0x00 #define LANG_INVARIANT 0x7f @@ -873,6 +745,4 @@ typedef EXCEPTION_DISPOSITION #define LANG_YORUBA 0x6a #define LANG_ZULU 0x35 - - -#endif /* _NTDEF_H */ +#endif /* _NTDEF_ */ diff --git a/reactos/include/psdk/winnt.h b/reactos/include/psdk/winnt.h index bd0fac136b9..f856b079970 100644 --- a/reactos/include/psdk/winnt.h +++ b/reactos/include/psdk/winnt.h @@ -3411,6 +3411,12 @@ typedef LONG struct _EXCEPTION_POINTERS *ExceptionInfo ); +typedef struct _GROUP_AFFINITY { + KAFFINITY Mask; + WORD Group; + WORD Reserved[3]; +} GROUP_AFFINITY, *PGROUP_AFFINITY; + typedef struct _EVENTLOGRECORD { DWORD Length; DWORD Reserved; From b359df2f326d78ff1df8b40b165833cceb7fd579 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 29 Mar 2010 03:52:10 +0000 Subject: [PATCH 075/134] Reintegrate header branch part 7/x Merge the rest and see what happens.... svn path=/trunk/; revision=46553 --- .../drivers/filesystems/ext2/inc/ext2fsd.h | 3 + reactos/drivers/serial/serial/serial.h | 9 - reactos/include/ddk/bdasup.h | 262 +- reactos/include/ddk/csq.h | 2 + reactos/include/ddk/ntddk.h | 5601 +++++-- reactos/include/ddk/ntifs.h | 4756 +++--- reactos/include/ddk/ntimage.h | 17 +- reactos/include/ddk/wdm.h | 12133 +++++++++++----- reactos/include/ndk/ketypes.h | 23 - reactos/include/ndk/peb_teb.h | 6 +- reactos/include/psdk/ktmtypes.h | 3 + reactos/ntoskrnl/include/ntoskrnl.h | 1 - reactos/ntoskrnl/mm/mminit.c | 2 +- 13 files changed, 14946 insertions(+), 7872 deletions(-) diff --git a/reactos/drivers/filesystems/ext2/inc/ext2fsd.h b/reactos/drivers/filesystems/ext2/inc/ext2fsd.h index bf2b784fb86..dcf35d996ef 100644 --- a/reactos/drivers/filesystems/ext2/inc/ext2fsd.h +++ b/reactos/drivers/filesystems/ext2/inc/ext2fsd.h @@ -42,8 +42,11 @@ typedef unsigned char BYTE; /* REACTOS FIXME */ #undef DeleteFile /* This is deprecated and should be changed in the EXT2FS driver. */ + +/* FIXME : Those two definitions already exist in wdm.h #define RtlLargeIntegerLessThan(a, b) (a).QuadPart < (b).QuadPart #define RtlLargeIntegerGreaterThan(a, b) (a).QuadPart > (b).QuadPart +*/ // the following include files should be in the inc sub-dir associated with this driver diff --git a/reactos/drivers/serial/serial/serial.h b/reactos/drivers/serial/serial/serial.h index de94b291138..b6ed661226c 100644 --- a/reactos/drivers/serial/serial/serial.h +++ b/reactos/drivers/serial/serial/serial.h @@ -17,15 +17,6 @@ #define PST_RS232 1 #define COMMPROP_INITIALIZED 0xE73CF52E -#ifndef _NTIFS_ -/* Why is it only defined in ntifs.h file? */ -NTSTATUS NTAPI -IoAttachDeviceToDeviceStackSafe( - IN PDEVICE_OBJECT SourceDevice, - IN PDEVICE_OBJECT TargetDevice, - OUT PDEVICE_OBJECT *AttachedToDeviceObject); -#endif - typedef enum { dsStopped, diff --git a/reactos/include/ddk/bdasup.h b/reactos/include/ddk/bdasup.h index 0bdd590d337..373ccdbdcbf 100644 --- a/reactos/include/ddk/bdasup.h +++ b/reactos/include/ddk/bdasup.h @@ -1,8 +1,12 @@ +#pragma once + +#if (NTDDI_VERSION >= NTDDI_WINXP) + #if defined(__cplusplus) extern "C" { #endif -/* Helper macro to enable gcc's extension. */ +/* Helper macro to enable gcc's extension. */ #ifndef __GNU_EXTENSION #ifdef __GNUC__ #define __GNU_EXTENSION __extension__ @@ -12,150 +16,190 @@ extern "C" { #endif #define STDMETHODCALLTYPE __stdcall + +#ifndef _WDMDDK_ typedef GUID *PGUID; +#endif /* Types */ -typedef struct _BDA_PIN_PAIRING -{ - ULONG ulInputPin; - ULONG ulOutputPin; - ULONG ulcMaxInputsPerOutput; - ULONG ulcMinInputsPerOutput; - ULONG ulcMaxOutputsPerInput; - ULONG ulcMinOutputsPerInput; - ULONG ulcTopologyJoints; - const ULONG *pTopologyJoints; +typedef ULONG BDA_TOPOLOGY_JOINT, *PBDA_TOPOLOGY_JOINT; + +typedef struct _BDA_PIN_PAIRING { + ULONG ulInputPin; + ULONG ulOutputPin; + ULONG ulcMaxInputsPerOutput; + ULONG ulcMinInputsPerOutput; + ULONG ulcMaxOutputsPerInput; + ULONG ulcMinOutputsPerInput; + ULONG ulcTopologyJoints; + const ULONG *pTopologyJoints; } BDA_PIN_PAIRING, *PBDA_PIN_PAIRING; -typedef struct _BDA_FILTER_TEMPLATE -{ - const KSFILTER_DESCRIPTOR *pFilterDescriptor; - ULONG ulcPinPairs; - const BDA_PIN_PAIRING *pPinPairs; +typedef struct _BDA_FILTER_TEMPLATE { + const KSFILTER_DESCRIPTOR *pFilterDescriptor; + ULONG ulcPinPairs; + const BDA_PIN_PAIRING *pPinPairs; } BDA_FILTER_TEMPLATE, *PBDA_FILTER_TEMPLATE; +typedef struct _KSM_PIN_PAIR { + KSMETHOD Method; + ULONG InputPinId; + ULONG OutputPinId; + ULONG Reserved; +} KSM_PIN_PAIR, * PKSM_PIN_PAIR; -typedef struct _KSM_PIN -{ - KSMETHOD Method; - __GNU_EXTENSION union - { - ULONG PinId; - ULONG PinType; - }; - ULONG Reserved; +typedef struct _KSM_PIN { + KSMETHOD Method; + __GNU_EXTENSION union { + ULONG PinId; + ULONG PinType; + }; + ULONG Reserved; } KSM_PIN, * PKSM_PIN; /* Functions */ -STDMETHODIMP_(NTSTATUS) BdaCheckChanges(IN PIRP Irp); -STDMETHODIMP_(NTSTATUS) BdaCommitChanges(IN PIRP Irp); +STDMETHODIMP_(NTSTATUS) +BdaCheckChanges( + IN PIRP Irp); -STDMETHODIMP_(NTSTATUS) BdaCreateFilterFactory( - IN PKSDEVICE pKSDevice, - IN const KSFILTER_DESCRIPTOR *pFilterDescriptor, - IN const BDA_FILTER_TEMPLATE *pBdaFilterTemplate); +STDMETHODIMP_(NTSTATUS) +BdaCommitChanges( + IN PIRP Irp); -STDMETHODIMP_(NTSTATUS) BdaCreateFilterFactoryEx( - IN PKSDEVICE pKSDevice, - IN const KSFILTER_DESCRIPTOR *pFilterDescriptor, - IN const BDA_FILTER_TEMPLATE *pBdaFilterTemplate, - OUT PKSFILTERFACTORY *ppKSFilterFactory); +STDMETHODIMP_(NTSTATUS) +BdaCreateFilterFactory( + IN PKSDEVICE pKSDevice, + IN const KSFILTER_DESCRIPTOR *pFilterDescriptor, + IN const BDA_FILTER_TEMPLATE *pBdaFilterTemplate); -STDMETHODIMP_(NTSTATUS) BdaCreatePin( - IN PKSFILTER pKSFilter, - IN ULONG ulPinType, - OUT ULONG *pulPinId); +STDMETHODIMP_(NTSTATUS) +BdaCreateFilterFactoryEx( + IN PKSDEVICE pKSDevice, + IN const KSFILTER_DESCRIPTOR *pFilterDescriptor, + IN const BDA_FILTER_TEMPLATE *pBdaFilterTemplate, + OUT PKSFILTERFACTORY *ppKSFilterFactory); -STDMETHODIMP_(NTSTATUS) BdaCreateTopology( - IN PKSFILTER pKSFilter, - IN ULONG InputPinId, - IN ULONG OutputPinId); +STDMETHODIMP_(NTSTATUS) +BdaCreatePin( + IN PKSFILTER pKSFilter, + IN ULONG ulPinType, + OUT ULONG *pulPinId); -STDMETHODIMP_(NTSTATUS) BdaDeletePin( - IN PKSFILTER pKSFilter, - IN ULONG *pulPinId); +STDMETHODIMP_(NTSTATUS) +BdaCreateTopology( + IN PKSFILTER pKSFilter, + IN ULONG InputPinId, + IN ULONG OutputPinId); -STDMETHODIMP_(NTSTATUS) BdaFilterFactoryUpdateCacheData( - IN PKSFILTERFACTORY pFilterFactory, - IN const KSFILTER_DESCRIPTOR *pFilterDescriptor OPTIONAL); +STDMETHODIMP_(NTSTATUS) +BdaDeletePin( + IN PKSFILTER pKSFilter, + IN ULONG *pulPinId); -STDMETHODIMP_(NTSTATUS) BdaGetChangeState( - IN PIRP Irp, - OUT BDA_CHANGE_STATE *pChangeState); +STDMETHODIMP_(NTSTATUS) +BdaFilterFactoryUpdateCacheData( + IN PKSFILTERFACTORY pFilterFactory, + IN const KSFILTER_DESCRIPTOR *pFilterDescriptor OPTIONAL); -STDMETHODIMP_(NTSTATUS) BdaInitFilter( - IN PKSFILTER pKSFilter, - IN const BDA_FILTER_TEMPLATE *pBdaFilterTemplate); +STDMETHODIMP_(NTSTATUS) +BdaGetChangeState( + IN PIRP Irp, + OUT BDA_CHANGE_STATE *pChangeState); -STDMETHODIMP_(NTSTATUS) BdaMethodCreatePin( - IN PIRP Irp, - IN KSMETHOD *pKSMethod, - OUT ULONG *pulPinFactoryID); +STDMETHODIMP_(NTSTATUS) +BdaInitFilter( + IN PKSFILTER pKSFilter, + IN const BDA_FILTER_TEMPLATE *pBdaFilterTemplate); -STDMETHODIMP_(NTSTATUS) BdaMethodCreateTopology( - IN PIRP Irp, - IN KSMETHOD *pKSMethod, - OPTIONAL PVOID pvIgnored); +STDMETHODIMP_(NTSTATUS) +BdaMethodCreatePin( + IN PIRP Irp, + IN KSMETHOD *pKSMethod, + OUT ULONG *pulPinFactoryID); -STDMETHODIMP_(NTSTATUS) BdaMethodDeletePin( - IN PIRP Irp, - IN KSMETHOD *pKSMethod, - OPTIONAL PVOID pvIgnored); +STDMETHODIMP_(NTSTATUS) +BdaMethodCreateTopology( + IN PIRP Irp, + IN KSMETHOD *pKSMethod, + OPTIONAL PVOID pvIgnored); -STDMETHODIMP_(NTSTATUS) BdaPropertyGetControllingPinId( - IN PIRP Irp, - IN KSP_BDA_NODE_PIN *pProperty, - OUT ULONG *pulControllingPinId); +STDMETHODIMP_(NTSTATUS) +BdaMethodDeletePin( + IN PIRP Irp, + IN KSMETHOD *pKSMethod, + OPTIONAL PVOID pvIgnored); -STDMETHODIMP_(NTSTATUS) BdaPropertyGetPinControl( - IN PIRP Irp, - IN KSPROPERTY *pKSProperty, - OUT ULONG *pulProperty); +STDMETHODIMP_(NTSTATUS) +BdaPropertyGetControllingPinId( + IN PIRP Irp, + IN KSP_BDA_NODE_PIN *pProperty, + OUT ULONG *pulControllingPinId); -STDMETHODIMP_(NTSTATUS) BdaPropertyNodeDescriptors( - IN PIRP Irp, - IN KSPROPERTY *pKSProperty, - OUT BDANODE_DESCRIPTOR *pNodeDescriptorProperty); +STDMETHODIMP_(NTSTATUS) +BdaPropertyGetPinControl( + IN PIRP Irp, + IN KSPROPERTY *pKSProperty, + OUT ULONG *pulProperty); -STDMETHODIMP_(NTSTATUS) BdaPropertyNodeEvents( - IN PIRP Irp, - IN KSP_NODE *pKSProperty, - OUT GUID *pguidProperty); +STDMETHODIMP_(NTSTATUS) +BdaPropertyNodeDescriptors( + IN PIRP Irp, + IN KSPROPERTY *pKSProperty, + OUT BDANODE_DESCRIPTOR *pNodeDescriptorProperty); -STDMETHODIMP_(NTSTATUS) BdaPropertyNodeMethods( - IN PIRP Irp, - IN KSP_NODE *pKSProperty, - OUT GUID *pguidProperty); +STDMETHODIMP_(NTSTATUS) +BdaPropertyNodeEvents( + IN PIRP Irp, + IN KSP_NODE *pKSProperty, + OUT GUID *pguidProperty); -STDMETHODIMP_(NTSTATUS) BdaPropertyNodeProperties( - IN PIRP Irp, - IN KSP_NODE *pKSProperty, - OUT GUID *pguidProperty); +STDMETHODIMP_(NTSTATUS) +BdaPropertyNodeMethods( + IN PIRP Irp, + IN KSP_NODE *pKSProperty, + OUT GUID *pguidProperty); -STDMETHODIMP_(NTSTATUS) BdaPropertyNodeTypes( - IN PIRP Irp, - IN KSPROPERTY *pKSProperty, - OUT ULONG *pulProperty); +STDMETHODIMP_(NTSTATUS) +BdaPropertyNodeProperties( + IN PIRP Irp, + IN KSP_NODE *pKSProperty, + OUT GUID *pguidProperty); -STDMETHODIMP_(NTSTATUS) BdaPropertyPinTypes( - IN PIRP Irp, - IN KSPROPERTY *pKSProperty, - OUT ULONG *pulProperty); +STDMETHODIMP_(NTSTATUS) +BdaPropertyNodeTypes( + IN PIRP Irp, + IN KSPROPERTY *pKSProperty, + OUT ULONG *pulProperty); -STDMETHODIMP_(NTSTATUS) BdaPropertyTemplateConnections( - IN PIRP Irp, - IN KSPROPERTY *pKSProperty, - OUT KSTOPOLOGY_CONNECTION *pConnectionProperty); +STDMETHODIMP_(NTSTATUS) +BdaPropertyPinTypes( + IN PIRP Irp, + IN KSPROPERTY *pKSProperty, + OUT ULONG *pulProperty); -STDMETHODIMP_(NTSTATUS) BdaStartChanges(IN PIRP Irp); -STDMETHODIMP_(NTSTATUS) BdaUninitFilter(IN PKSFILTER pKSFilter); +STDMETHODIMP_(NTSTATUS) +BdaPropertyTemplateConnections( + IN PIRP Irp, + IN KSPROPERTY *pKSProperty, + OUT KSTOPOLOGY_CONNECTION *pConnectionProperty); -STDMETHODIMP_(NTSTATUS) BdaValidateNodeProperty( - IN PIRP Irp, - IN KSPROPERTY *pKSProperty); +STDMETHODIMP_(NTSTATUS) +BdaStartChanges( + IN PIRP Irp); + +STDMETHODIMP_(NTSTATUS) +BdaUninitFilter( + IN PKSFILTER pKSFilter); + +STDMETHODIMP_(NTSTATUS) +BdaValidateNodeProperty( + IN PIRP Irp, + IN KSPROPERTY *pKSProperty); #if defined(__cplusplus) } #endif + +#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ diff --git a/reactos/include/ddk/csq.h b/reactos/include/ddk/csq.h index 99056f610a8..cf7b2c14ce3 100644 --- a/reactos/include/ddk/csq.h +++ b/reactos/include/ddk/csq.h @@ -229,9 +229,11 @@ typedef struct _IO_CSQ_IRP_CONTEXT { } * */ +#ifndef IO_TYPE_CSQ_EX typedef NTSTATUS (NTAPI *PIO_CSQ_INSERT_IRP_EX) (struct _IO_CSQ *Csq, PIRP Irp, PVOID InsertContext); +#endif /* * CANCEL-SAFE QUEUE DDIs diff --git a/reactos/include/ddk/ntddk.h b/reactos/include/ddk/ntddk.h index 0475b3acc85..61c23d3077a 100644 --- a/reactos/include/ddk/ntddk.h +++ b/reactos/include/ddk/ntddk.h @@ -1,12 +1,13 @@ /* * ntddk.h * - * Windows Device Driver Kit + * Windows NT Device Driver Kit * - * This file is part of the w32api package. + * This file is part of the ReactOS DDK package. * * Contributors: - * Created by Casper S. Hornstrup + * Amine Khaldi + * Timo Kreuzer (timo.kreuzer@reactos.org) * * THIS SOFTWARE IS NOT COPYRIGHTED * @@ -18,13 +19,10 @@ * DISCLAIMED. This includes but is not limited to warranties of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * DEFINES: - * DBG - Debugging enabled/disabled (0/1) - * POOL_TAGGING - Enable pool tagging - * _X86_ - X86 environment */ -#ifndef _NTDDK_ +#pragma once + #define _NTDDK_ #if !defined(_NTHAL_) && !defined(_NTIFS_) @@ -41,6 +39,7 @@ #include #include #include +#include /* FIXME #include @@ -55,39 +54,128 @@ extern "C" { #endif +/* GUID and UUID */ +#ifndef _NTLSA_IFS_ +#ifndef _NTLSA_AUDIT_ +#define _NTLSA_AUDIT_ + +#ifndef GUID_DEFINED +#include +#endif + +#endif /* _NTLSA_AUDIT_ */ +#endif /* _NTLSA_IFS_ */ + +typedef GUID UUID; + struct _LOADER_PARAMETER_BLOCK; struct _CREATE_DISK; struct _DRIVE_LAYOUT_INFORMATION_EX; struct _SET_PARTITION_INFORMATION_EX; -// -// GUID and UUID -// -#ifndef GUID_DEFINED -#include -#endif -typedef GUID UUID; - typedef struct _BUS_HANDLER *PBUS_HANDLER; +typedef struct _DEVICE_HANDLER_OBJECT *PDEVICE_HANDLER_OBJECT; +#if defined(_NTHAL_INCLUDED_) +typedef struct _KAFFINITY_EX *PKAFFINITY_EX; +#endif +typedef struct _PEB *PPEB; -#define EXCEPTION_READ_FAULT 0 -#define EXCEPTION_WRITE_FAULT 1 -#define EXCEPTION_EXECUTE_FAULT 8 +#ifndef _NTIMAGE_ -#if (NTDDI_VERSION >= NTDDI_VISTA) -extern NTSYSAPI volatile CCHAR KeNumberProcessors; -#elif (NTDDI_VERSION >= NTDDI_WINXP) -extern NTSYSAPI CCHAR KeNumberProcessors; +typedef struct _IMAGE_NT_HEADERS *PIMAGE_NT_HEADERS32; +typedef struct _IMAGE_NT_HEADERS64 *PIMAGE_NT_HEADERS64; + +#ifdef _WIN64 +typedef PIMAGE_NT_HEADERS64 PIMAGE_NT_HEADERS; #else -extern PCCHAR KeNumberProcessors; +typedef PIMAGE_NT_HEADERS32 PIMAGE_NT_HEADERS; #endif -#define MAX_WOW64_SHARED_ENTRIES 16 +#endif /* _NTIMAGE_ */ -#define NX_SUPPORT_POLICY_ALWAYSOFF 0 -#define NX_SUPPORT_POLICY_ALWAYSON 1 -#define NX_SUPPORT_POLICY_OPTIN 2 -#define NX_SUPPORT_POLICY_OPTOUT 3 +/****************************************************************************** + * Executive Types * + ******************************************************************************/ + +typedef struct _ZONE_SEGMENT_HEADER { + SINGLE_LIST_ENTRY SegmentList; + PVOID Reserved; +} ZONE_SEGMENT_HEADER, *PZONE_SEGMENT_HEADER; + +typedef struct _ZONE_HEADER { + SINGLE_LIST_ENTRY FreeList; + SINGLE_LIST_ENTRY SegmentList; + ULONG BlockSize; + ULONG TotalSegmentSize; +} ZONE_HEADER, *PZONE_HEADER; + +#define PROTECTED_POOL 0x80000000 + + +/****************************************************************************** + * I/O Manager Types * + ******************************************************************************/ + +/* DEVICE_OBJECT.Flags */ +#define DO_DEVICE_HAS_NAME 0x00000040 +#define DO_SYSTEM_BOOT_PARTITION 0x00000100 +#define DO_LONG_TERM_REQUESTS 0x00000200 +#define DO_NEVER_LAST_DEVICE 0x00000400 +#define DO_LOW_PRIORITY_FILESYSTEM 0x00010000 +#define DO_SUPPORTS_TRANSACTIONS 0x00040000 +#define DO_FORCE_NEITHER_IO 0x00080000 +#define DO_VOLUME_DEVICE_OBJECT 0x00100000 +#define DO_SYSTEM_SYSTEM_PARTITION 0x00200000 +#define DO_SYSTEM_CRITICAL_PARTITION 0x00400000 +#define DO_DISALLOW_EXECUTE 0x00800000 + +#ifndef _ARC_DDK_ +#define _ARC_DDK_ +typedef enum _CONFIGURATION_TYPE { + ArcSystem, + CentralProcessor, + FloatingPointProcessor, + PrimaryIcache, + PrimaryDcache, + SecondaryIcache, + SecondaryDcache, + SecondaryCache, + EisaAdapter, + TcAdapter, + ScsiAdapter, + DtiAdapter, + MultiFunctionAdapter, + DiskController, + TapeController, + CdromController, + WormController, + SerialController, + NetworkController, + DisplayController, + ParallelController, + PointerController, + KeyboardController, + AudioController, + OtherController, + DiskPeripheral, + FloppyDiskPeripheral, + TapePeripheral, + ModemPeripheral, + MonitorPeripheral, + PrinterPeripheral, + PointerPeripheral, + KeyboardPeripheral, + TerminalPeripheral, + OtherPeripheral, + LinePeripheral, + NetworkPeripheral, + SystemMemory, + DockingInformation, + RealModeIrqRoutingTable, + RealModePCIEnumeration, + MaximumType +} CONFIGURATION_TYPE, *PCONFIGURATION_TYPE; +#endif /* !_ARC_DDK_ */ /* ** IRP function codes @@ -122,102 +210,118 @@ extern PCCHAR KeNumberProcessors; #define IRP_MN_QUERY_LEGACY_BUS_INFORMATION 0x18 -typedef struct _IO_COUNTERS { - ULONGLONG ReadOperationCount; - ULONGLONG WriteOperationCount; - ULONGLONG OtherOperationCount; - ULONGLONG ReadTransferCount; - ULONGLONG WriteTransferCount; - ULONGLONG OtherTransferCount; -} IO_COUNTERS, *PIO_COUNTERS; +#define IO_CHECK_CREATE_PARAMETERS 0x0200 +#define IO_ATTACH_DEVICE 0x0400 +#define IO_IGNORE_SHARE_ACCESS_CHECK 0x0800 -typedef struct _VM_COUNTERS { - SIZE_T PeakVirtualSize; - SIZE_T VirtualSize; - ULONG PageFaultCount; - SIZE_T PeakWorkingSetSize; - SIZE_T WorkingSetSize; - SIZE_T QuotaPeakPagedPoolUsage; - SIZE_T QuotaPagedPoolUsage; - SIZE_T QuotaPeakNonPagedPoolUsage; - SIZE_T QuotaNonPagedPoolUsage; - SIZE_T PagefileUsage; - SIZE_T PeakPagefileUsage; -} VM_COUNTERS, *PVM_COUNTERS; +typedef +NTSTATUS +(NTAPI *PIO_QUERY_DEVICE_ROUTINE)( + IN PVOID Context, + IN PUNICODE_STRING PathName, + IN INTERFACE_TYPE BusType, + IN ULONG BusNumber, + IN PKEY_VALUE_FULL_INFORMATION *BusInformation, + IN CONFIGURATION_TYPE ControllerType, + IN ULONG ControllerNumber, + IN PKEY_VALUE_FULL_INFORMATION *ControllerInformation, + IN CONFIGURATION_TYPE PeripheralType, + IN ULONG PeripheralNumber, + IN PKEY_VALUE_FULL_INFORMATION *PeripheralInformation); -typedef struct _VM_COUNTERS_EX -{ - SIZE_T PeakVirtualSize; - SIZE_T VirtualSize; - ULONG PageFaultCount; - SIZE_T PeakWorkingSetSize; - SIZE_T WorkingSetSize; - SIZE_T QuotaPeakPagedPoolUsage; - SIZE_T QuotaPagedPoolUsage; - SIZE_T QuotaPeakNonPagedPoolUsage; - SIZE_T QuotaNonPagedPoolUsage; - SIZE_T PagefileUsage; - SIZE_T PeakPagefileUsage; - SIZE_T PrivateUsage; -} VM_COUNTERS_EX, *PVM_COUNTERS_EX; +typedef enum _IO_QUERY_DEVICE_DATA_FORMAT { + IoQueryDeviceIdentifier = 0, + IoQueryDeviceConfigurationData, + IoQueryDeviceComponentInformation, + IoQueryDeviceMaxData +} IO_QUERY_DEVICE_DATA_FORMAT, *PIO_QUERY_DEVICE_DATA_FORMAT; -typedef struct _POOLED_USAGE_AND_LIMITS -{ - SIZE_T PeakPagedPoolUsage; - SIZE_T PagedPoolUsage; - SIZE_T PagedPoolLimit; - SIZE_T PeakNonPagedPoolUsage; - SIZE_T NonPagedPoolUsage; - SIZE_T NonPagedPoolLimit; - SIZE_T PeakPagefileUsage; - SIZE_T PagefileUsage; - SIZE_T PagefileLimit; -} POOLED_USAGE_AND_LIMITS, *PPOOLED_USAGE_AND_LIMITS; +typedef VOID +(NTAPI *PDRIVER_REINITIALIZE)( + IN struct _DRIVER_OBJECT *DriverObject, + IN PVOID Context OPTIONAL, + IN ULONG Count); -/* DEVICE_OBJECT.Flags */ - -#define DO_VERIFY_VOLUME 0x00000002 -#define DO_BUFFERED_IO 0x00000004 -#define DO_EXCLUSIVE 0x00000008 -#define DO_DIRECT_IO 0x00000010 -#define DO_MAP_IO_BUFFER 0x00000020 -#define DO_DEVICE_HAS_NAME 0x00000040 -#define DO_DEVICE_INITIALIZING 0x00000080 -#define DO_SYSTEM_BOOT_PARTITION 0x00000100 -#define DO_LONG_TERM_REQUESTS 0x00000200 -#define DO_NEVER_LAST_DEVICE 0x00000400 -#define DO_SHUTDOWN_REGISTERED 0x00000800 -#define DO_BUS_ENUMERATED_DEVICE 0x00001000 -#define DO_POWER_PAGABLE 0x00002000 -#define DO_POWER_INRUSH 0x00004000 -#define DO_LOW_PRIORITY_FILESYSTEM 0x00010000 -#define DO_SUPPORTS_TRANSACTIONS 0x00040000 -#define DO_FORCE_NEITHER_IO 0x00080000 -#define DO_VOLUME_DEVICE_OBJECT 0x00100000 -#define DO_SYSTEM_SYSTEM_PARTITION 0x00200000 -#define DO_SYSTEM_CRITICAL_PARTITION 0x00400000 -#define DO_DISALLOW_EXECUTE 0x00800000 +typedef struct _CONTROLLER_OBJECT { + CSHORT Type; + CSHORT Size; + PVOID ControllerExtension; + KDEVICE_QUEUE DeviceWaitQueue; + ULONG Spare1; + LARGE_INTEGER Spare2; +} CONTROLLER_OBJECT, *PCONTROLLER_OBJECT; #define DRVO_REINIT_REGISTERED 0x00000008 #define DRVO_INITIALIZED 0x00000010 #define DRVO_BOOTREINIT_REGISTERED 0x00000020 #define DRVO_LEGACY_RESOURCES 0x00000040 -typedef enum _ARBITER_REQUEST_SOURCE { - ArbiterRequestUndefined = -1, - ArbiterRequestLegacyReported, - ArbiterRequestHalReported, - ArbiterRequestLegacyAssigned, - ArbiterRequestPnpDetected, - ArbiterRequestPnpEnumerated -} ARBITER_REQUEST_SOURCE; +typedef struct _CONFIGURATION_INFORMATION { + ULONG DiskCount; + ULONG FloppyCount; + ULONG CdRomCount; + ULONG TapeCount; + ULONG ScsiPortCount; + ULONG SerialCount; + ULONG ParallelCount; + BOOLEAN AtDiskPrimaryAddressClaimed; + BOOLEAN AtDiskSecondaryAddressClaimed; + ULONG Version; + ULONG MediumChangerCount; +} CONFIGURATION_INFORMATION, *PCONFIGURATION_INFORMATION; -typedef enum _ARBITER_RESULT { - ArbiterResultUndefined = -1, - ArbiterResultSuccess, - ArbiterResultExternalConflict, - ArbiterResultNullRequest -} ARBITER_RESULT; +typedef struct _DISK_SIGNATURE { + ULONG PartitionStyle; + _ANONYMOUS_UNION union { + struct { + ULONG Signature; + ULONG CheckSum; + } Mbr; + struct { + GUID DiskId; + } Gpt; + } DUMMYUNIONNAME; +} DISK_SIGNATURE, *PDISK_SIGNATURE; + +typedef struct _TXN_PARAMETER_BLOCK { + USHORT Length; + USHORT TxFsContext; + PVOID TransactionObject; +} TXN_PARAMETER_BLOCK, *PTXN_PARAMETER_BLOCK; + +#define TXF_MINIVERSION_DEFAULT_VIEW (0xFFFE) + +typedef struct _IO_DRIVER_CREATE_CONTEXT { + CSHORT Size; + struct _ECP_LIST *ExtraCreateParameter; + PVOID DeviceObjectHint; + PTXN_PARAMETER_BLOCK TxnParameters; +} IO_DRIVER_CREATE_CONTEXT, *PIO_DRIVER_CREATE_CONTEXT; + +typedef struct _AGP_TARGET_BUS_INTERFACE_STANDARD { + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; + PGET_SET_DEVICE_DATA SetBusData; + PGET_SET_DEVICE_DATA GetBusData; + UCHAR CapabilityID; +} AGP_TARGET_BUS_INTERFACE_STANDARD, *PAGP_TARGET_BUS_INTERFACE_STANDARD; + +typedef NTSTATUS +(NTAPI *PGET_LOCATION_STRING)( + IN OUT PVOID Context OPTIONAL, + OUT PWCHAR *LocationStrings); + +typedef struct _PNP_LOCATION_INTERFACE { + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; + PGET_LOCATION_STRING GetLocationString; +} PNP_LOCATION_INTERFACE, *PPNP_LOCATION_INTERFACE; typedef enum _ARBITER_ACTION { ArbiterActionTestAllocation, @@ -238,39 +342,69 @@ typedef struct _ARBITER_CONFLICT_INFO { ULONGLONG End; } ARBITER_CONFLICT_INFO, *PARBITER_CONFLICT_INFO; +typedef struct _ARBITER_TEST_ALLOCATION_PARAMETERS { + IN OUT PLIST_ENTRY ArbitrationList; + IN ULONG AllocateFromCount; + IN PCM_PARTIAL_RESOURCE_DESCRIPTOR AllocateFrom; +} ARBITER_TEST_ALLOCATION_PARAMETERS, *PARBITER_TEST_ALLOCATION_PARAMETERS; + +typedef struct _ARBITER_RETEST_ALLOCATION_PARAMETERS { + IN OUT PLIST_ENTRY ArbitrationList; + IN ULONG AllocateFromCount; + IN PCM_PARTIAL_RESOURCE_DESCRIPTOR AllocateFrom; +} ARBITER_RETEST_ALLOCATION_PARAMETERS, *PARBITER_RETEST_ALLOCATION_PARAMETERS; + +typedef struct _ARBITER_BOOT_ALLOCATION_PARAMETERS { + IN OUT PLIST_ENTRY ArbitrationList; +} ARBITER_BOOT_ALLOCATION_PARAMETERS, *PARBITER_BOOT_ALLOCATION_PARAMETERS; + +typedef struct _ARBITER_QUERY_ALLOCATED_RESOURCES_PARAMETERS { + OUT PCM_PARTIAL_RESOURCE_LIST *AllocatedResources; +} ARBITER_QUERY_ALLOCATED_RESOURCES_PARAMETERS, *PARBITER_QUERY_ALLOCATED_RESOURCES_PARAMETERS; + +typedef struct _ARBITER_QUERY_CONFLICT_PARAMETERS { + IN PDEVICE_OBJECT PhysicalDeviceObject; + IN PIO_RESOURCE_DESCRIPTOR ConflictingResource; + OUT PULONG ConflictCount; + OUT PARBITER_CONFLICT_INFO *Conflicts; +} ARBITER_QUERY_CONFLICT_PARAMETERS, *PARBITER_QUERY_CONFLICT_PARAMETERS; + +typedef struct _ARBITER_QUERY_ARBITRATE_PARAMETERS { + IN PLIST_ENTRY ArbitrationList; +} ARBITER_QUERY_ARBITRATE_PARAMETERS, *PARBITER_QUERY_ARBITRATE_PARAMETERS; + +typedef struct _ARBITER_ADD_RESERVED_PARAMETERS { + IN PDEVICE_OBJECT ReserveDevice; +} ARBITER_ADD_RESERVED_PARAMETERS, *PARBITER_ADD_RESERVED_PARAMETERS; + typedef struct _ARBITER_PARAMETERS { union { - struct { - IN OUT PLIST_ENTRY ArbitrationList; - IN ULONG AllocateFromCount; - IN PCM_PARTIAL_RESOURCE_DESCRIPTOR AllocateFrom; - } TestAllocation; - struct { - IN OUT PLIST_ENTRY ArbitrationList; - IN ULONG AllocateFromCount; - IN PCM_PARTIAL_RESOURCE_DESCRIPTOR AllocateFrom; - } RetestAllocation; - struct { - IN OUT PLIST_ENTRY ArbitrationList; - } BootAllocation; - struct { - OUT PCM_PARTIAL_RESOURCE_LIST *AllocatedResources; - } QueryAllocatedResources; - struct { - IN PDEVICE_OBJECT PhysicalDeviceObject; - IN PIO_RESOURCE_DESCRIPTOR ConflictingResource; - OUT PULONG ConflictCount; - OUT PARBITER_CONFLICT_INFO *Conflicts; - } QueryConflict; - struct { - IN PLIST_ENTRY ArbitrationList; - } QueryArbitrate; - struct { - IN PDEVICE_OBJECT ReserveDevice; - } AddReserved; + ARBITER_TEST_ALLOCATION_PARAMETERS TestAllocation; + ARBITER_RETEST_ALLOCATION_PARAMETERS RetestAllocation; + ARBITER_BOOT_ALLOCATION_PARAMETERS BootAllocation; + ARBITER_QUERY_ALLOCATED_RESOURCES_PARAMETERS QueryAllocatedResources; + ARBITER_QUERY_CONFLICT_PARAMETERS QueryConflict; + ARBITER_QUERY_ARBITRATE_PARAMETERS QueryArbitrate; + ARBITER_ADD_RESERVED_PARAMETERS AddReserved; } Parameters; } ARBITER_PARAMETERS, *PARBITER_PARAMETERS; +typedef enum _ARBITER_REQUEST_SOURCE { + ArbiterRequestUndefined = -1, + ArbiterRequestLegacyReported, + ArbiterRequestHalReported, + ArbiterRequestLegacyAssigned, + ArbiterRequestPnpDetected, + ArbiterRequestPnpEnumerated +} ARBITER_REQUEST_SOURCE; + +typedef enum _ARBITER_RESULT { + ArbiterResultUndefined = -1, + ArbiterResultSuccess, + ArbiterResultExternalConflict, + ArbiterResultNullRequest +} ARBITER_RESULT; + #define ARBITER_FLAG_BOOT_CONFIG 0x00000001 typedef struct _ARBITER_LIST_ENTRY { @@ -307,6 +441,826 @@ typedef struct _ARBITER_INTERFACE { ULONG Flags; } ARBITER_INTERFACE, *PARBITER_INTERFACE; +typedef enum _RESOURCE_TRANSLATION_DIRECTION { + TranslateChildToParent, + TranslateParentToChild +} RESOURCE_TRANSLATION_DIRECTION; + +typedef NTSTATUS +(NTAPI *PTRANSLATE_RESOURCE_HANDLER)( + IN OUT PVOID Context OPTIONAL, + IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Source, + IN RESOURCE_TRANSLATION_DIRECTION Direction, + IN ULONG AlternativesCount OPTIONAL, + IN IO_RESOURCE_DESCRIPTOR Alternatives[], + IN PDEVICE_OBJECT PhysicalDeviceObject, + OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR Target); + +typedef NTSTATUS +(NTAPI *PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER)( + IN OUT PVOID Context OPTIONAL, + IN PIO_RESOURCE_DESCRIPTOR Source, + IN PDEVICE_OBJECT PhysicalDeviceObject, + OUT PULONG TargetCount, + OUT PIO_RESOURCE_DESCRIPTOR *Target); + +typedef struct _TRANSLATOR_INTERFACE { + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; + PTRANSLATE_RESOURCE_HANDLER TranslateResources; + PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER TranslateResourceRequirements; +} TRANSLATOR_INTERFACE, *PTRANSLATOR_INTERFACE; + +typedef struct _PCI_AGP_CAPABILITY { + PCI_CAPABILITIES_HEADER Header; + USHORT Minor:4; + USHORT Major:4; + USHORT Rsvd1:8; + struct _PCI_AGP_STATUS { + ULONG Rate:3; + ULONG Agp3Mode:1; + ULONG FastWrite:1; + ULONG FourGB:1; + ULONG HostTransDisable:1; + ULONG Gart64:1; + ULONG ITA_Coherent:1; + ULONG SideBandAddressing:1; + ULONG CalibrationCycle:3; + ULONG AsyncRequestSize:3; + ULONG Rsvd1:1; + ULONG Isoch:1; + ULONG Rsvd2:6; + ULONG RequestQueueDepthMaximum:8; + } AGPStatus; + struct _PCI_AGP_COMMAND { + ULONG Rate:3; + ULONG Rsvd1:1; + ULONG FastWriteEnable:1; + ULONG FourGBEnable:1; + ULONG Rsvd2:1; + ULONG Gart64:1; + ULONG AGPEnable:1; + ULONG SBAEnable:1; + ULONG CalibrationCycle:3; + ULONG AsyncReqSize:3; + ULONG Rsvd3:8; + ULONG RequestQueueDepth:8; + } AGPCommand; +} PCI_AGP_CAPABILITY, *PPCI_AGP_CAPABILITY; + +typedef enum _EXTENDED_AGP_REGISTER { + IsochStatus, + AgpControl, + ApertureSize, + AperturePageSize, + GartLow, + GartHigh, + IsochCommand +} EXTENDED_AGP_REGISTER, *PEXTENDED_AGP_REGISTER; + +typedef struct _PCI_AGP_ISOCH_STATUS { + ULONG ErrorCode:2; + ULONG Rsvd1:1; + ULONG Isoch_L:3; + ULONG Isoch_Y:2; + ULONG Isoch_N:8; + ULONG Rsvd2:16; +} PCI_AGP_ISOCH_STATUS, *PPCI_AGP_ISOCH_STATUS; + +typedef struct _PCI_AGP_CONTROL { + ULONG Rsvd1:7; + ULONG GTLB_Enable:1; + ULONG AP_Enable:1; + ULONG CAL_Disable:1; + ULONG Rsvd2:22; +} PCI_AGP_CONTROL, *PPCI_AGP_CONTROL; + +typedef struct _PCI_AGP_APERTURE_PAGE_SIZE { + USHORT PageSizeMask:11; + USHORT Rsvd1:1; + USHORT PageSizeSelect:4; +} PCI_AGP_APERTURE_PAGE_SIZE, *PPCI_AGP_APERTURE_PAGE_SIZE; + +typedef struct _PCI_AGP_ISOCH_COMMAND { + USHORT Rsvd1:6; + USHORT Isoch_Y:2; + USHORT Isoch_N:8; +} PCI_AGP_ISOCH_COMMAND, *PPCI_AGP_ISOCH_COMMAND; + +typedef struct PCI_AGP_EXTENDED_CAPABILITY { + PCI_AGP_ISOCH_STATUS IsochStatus; + PCI_AGP_CONTROL AgpControl; + USHORT ApertureSize; + PCI_AGP_APERTURE_PAGE_SIZE AperturePageSize; + ULONG GartLow; + ULONG GartHigh; + PCI_AGP_ISOCH_COMMAND IsochCommand; +} PCI_AGP_EXTENDED_CAPABILITY, *PPCI_AGP_EXTENDED_CAPABILITY; + +#define PCI_AGP_RATE_1X 0x1 +#define PCI_AGP_RATE_2X 0x2 +#define PCI_AGP_RATE_4X 0x4 + +#define PCIX_MODE_CONVENTIONAL_PCI 0x0 +#define PCIX_MODE1_66MHZ 0x1 +#define PCIX_MODE1_100MHZ 0x2 +#define PCIX_MODE1_133MHZ 0x3 +#define PCIX_MODE2_266_66MHZ 0x9 +#define PCIX_MODE2_266_100MHZ 0xA +#define PCIX_MODE2_266_133MHZ 0xB +#define PCIX_MODE2_533_66MHZ 0xD +#define PCIX_MODE2_533_100MHZ 0xE +#define PCIX_MODE2_533_133MHZ 0xF + +#define PCIX_VERSION_MODE1_ONLY 0x0 +#define PCIX_VERSION_MODE2_ECC 0x1 +#define PCIX_VERSION_DUAL_MODE_ECC 0x2 + +typedef struct _PCIX_BRIDGE_CAPABILITY { + PCI_CAPABILITIES_HEADER Header; + union { + struct { + USHORT Bus64Bit:1; + USHORT Bus133MHzCapable:1; + USHORT SplitCompletionDiscarded:1; + USHORT UnexpectedSplitCompletion:1; + USHORT SplitCompletionOverrun:1; + USHORT SplitRequestDelayed:1; + USHORT BusModeFrequency:4; + USHORT Rsvd:2; + USHORT Version:2; + USHORT Bus266MHzCapable:1; + USHORT Bus533MHzCapable:1; + } DUMMYSTRUCTNAME; + USHORT AsUSHORT; + } SecondaryStatus; + union { + struct { + ULONG FunctionNumber:3; + ULONG DeviceNumber:5; + ULONG BusNumber:8; + ULONG Device64Bit:1; + ULONG Device133MHzCapable:1; + ULONG SplitCompletionDiscarded:1; + ULONG UnexpectedSplitCompletion:1; + ULONG SplitCompletionOverrun:1; + ULONG SplitRequestDelayed:1; + ULONG Rsvd:7; + ULONG DIMCapable:1; + ULONG Device266MHzCapable:1; + ULONG Device533MHzCapable:1; + } DUMMYSTRUCTNAME; + ULONG AsULONG; + } BridgeStatus; + USHORT UpstreamSplitTransactionCapacity; + USHORT UpstreamSplitTransactionLimit; + USHORT DownstreamSplitTransactionCapacity; + USHORT DownstreamSplitTransactionLimit; + union { + struct { + ULONG SelectSecondaryRegisters:1; + ULONG ErrorPresentInOtherBank:1; + ULONG AdditionalCorrectableError:1; + ULONG AdditionalUncorrectableError:1; + ULONG ErrorPhase:3; + ULONG ErrorCorrected:1; + ULONG Syndrome:8; + ULONG ErrorFirstCommand:4; + ULONG ErrorSecondCommand:4; + ULONG ErrorUpperAttributes:4; + ULONG ControlUpdateEnable:1; + ULONG Rsvd:1; + ULONG DisableSingleBitCorrection:1; + ULONG EccMode:1; + } DUMMYSTRUCTNAME; + ULONG AsULONG; + } EccControlStatus; + ULONG EccFirstAddress; + ULONG EccSecondAddress; + ULONG EccAttribute; +} PCIX_BRIDGE_CAPABILITY, *PPCIX_BRIDGE_CAPABILITY; + +typedef struct _PCI_SUBSYSTEM_IDS_CAPABILITY { + PCI_CAPABILITIES_HEADER Header; + USHORT Reserved; + USHORT SubVendorID; + USHORT SubSystemID; +} PCI_SUBSYSTEM_IDS_CAPABILITY, *PPCI_SUBSYSTEM_IDS_CAPABILITY; + +#define OSC_FIRMWARE_FAILURE 0x02 +#define OSC_UNRECOGNIZED_UUID 0x04 +#define OSC_UNRECOGNIZED_REVISION 0x08 +#define OSC_CAPABILITIES_MASKED 0x10 + +#define PCI_ROOT_BUS_OSC_METHOD_CAPABILITY_REVISION 0x01 + +typedef struct _PCI_ROOT_BUS_OSC_SUPPORT_FIELD { + union { + struct { + ULONG ExtendedConfigOpRegions:1; + ULONG ActiveStatePowerManagement:1; + ULONG ClockPowerManagement:1; + ULONG SegmentGroups:1; + ULONG MessageSignaledInterrupts:1; + ULONG WindowsHardwareErrorArchitecture:1; + ULONG Reserved:26; + } DUMMYSTRUCTNAME; + ULONG AsULONG; + } u; +} PCI_ROOT_BUS_OSC_SUPPORT_FIELD, *PPCI_ROOT_BUS_OSC_SUPPORT_FIELD; + +typedef struct _PCI_ROOT_BUS_OSC_CONTROL_FIELD { + union { + struct { + ULONG ExpressNativeHotPlug:1; + ULONG ShpcNativeHotPlug:1; + ULONG ExpressNativePME:1; + ULONG ExpressAdvancedErrorReporting:1; + ULONG ExpressCapabilityStructure:1; + ULONG Reserved:27; + } DUMMYSTRUCTNAME; + ULONG AsULONG; + } u; +} PCI_ROOT_BUS_OSC_CONTROL_FIELD, *PPCI_ROOT_BUS_OSC_CONTROL_FIELD; + +typedef enum _PCI_HARDWARE_INTERFACE { + PciConventional, + PciXMode1, + PciXMode2, + PciExpress +} PCI_HARDWARE_INTERFACE, *PPCI_HARDWARE_INTERFACE; + +typedef enum { + BusWidth32Bits, + BusWidth64Bits +} PCI_BUS_WIDTH; + +typedef struct _PCI_ROOT_BUS_HARDWARE_CAPABILITY { + PCI_HARDWARE_INTERFACE SecondaryInterface; + struct { + BOOLEAN BusCapabilitiesFound; + ULONG CurrentSpeedAndMode; + ULONG SupportedSpeedsAndModes; + BOOLEAN DeviceIDMessagingCapable; + PCI_BUS_WIDTH SecondaryBusWidth; + } DUMMYSTRUCTNAME; + PCI_ROOT_BUS_OSC_SUPPORT_FIELD OscFeatureSupport; + PCI_ROOT_BUS_OSC_CONTROL_FIELD OscControlRequest; + PCI_ROOT_BUS_OSC_CONTROL_FIELD OscControlGranted; +} PCI_ROOT_BUS_HARDWARE_CAPABILITY, *PPCI_ROOT_BUS_HARDWARE_CAPABILITY; + +typedef union _PCI_EXPRESS_CAPABILITIES_REGISTER { + struct { + USHORT CapabilityVersion:4; + USHORT DeviceType:4; + USHORT SlotImplemented:1; + USHORT InterruptMessageNumber:5; + USHORT Rsvd:2; + } DUMMYSTRUCTNAME; + USHORT AsUSHORT; +} PCI_EXPRESS_CAPABILITIES_REGISTER, *PPCI_EXPRESS_CAPABILITIES_REGISTER; + +typedef union _PCI_EXPRESS_DEVICE_CAPABILITIES_REGISTER { + struct { + ULONG MaxPayloadSizeSupported:3; + ULONG PhantomFunctionsSupported:2; + ULONG ExtendedTagSupported:1; + ULONG L0sAcceptableLatency:3; + ULONG L1AcceptableLatency:3; + ULONG Undefined:3; + ULONG RoleBasedErrorReporting:1; + ULONG Rsvd1:2; + ULONG CapturedSlotPowerLimit:8; + ULONG CapturedSlotPowerLimitScale:2; + ULONG Rsvd2:4; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_DEVICE_CAPABILITIES_REGISTER, *PPCI_EXPRESS_DEVICE_CAPABILITIES_REGISTER; + +#define PCI_EXPRESS_AER_DEVICE_CONTROL_MASK 0x07; + +typedef union _PCI_EXPRESS_DEVICE_CONTROL_REGISTER { + struct { + USHORT CorrectableErrorEnable:1; + USHORT NonFatalErrorEnable:1; + USHORT FatalErrorEnable:1; + USHORT UnsupportedRequestErrorEnable:1; + USHORT EnableRelaxedOrder:1; + USHORT MaxPayloadSize:3; + USHORT ExtendedTagEnable:1; + USHORT PhantomFunctionsEnable:1; + USHORT AuxPowerEnable:1; + USHORT NoSnoopEnable:1; + USHORT MaxReadRequestSize:3; + USHORT BridgeConfigRetryEnable:1; + } DUMMYSTRUCTNAME; + USHORT AsUSHORT; +} PCI_EXPRESS_DEVICE_CONTROL_REGISTER, *PPCI_EXPRESS_DEVICE_CONTROL_REGISTER; + +#define PCI_EXPRESS_AER_DEVICE_STATUS_MASK 0x0F; + +typedef union _PCI_EXPRESS_DEVICE_STATUS_REGISTER { + struct { + USHORT CorrectableErrorDetected:1; + USHORT NonFatalErrorDetected:1; + USHORT FatalErrorDetected:1; + USHORT UnsupportedRequestDetected:1; + USHORT AuxPowerDetected:1; + USHORT TransactionsPending:1; + USHORT Rsvd:10; + } DUMMYSTRUCTNAME; + USHORT AsUSHORT; +} PCI_EXPRESS_DEVICE_STATUS_REGISTER, *PPCI_EXPRESS_DEVICE_STATUS_REGISTER; + +typedef union _PCI_EXPRESS_LINK_CAPABILITIES_REGISTER { + struct { + ULONG MaximumLinkSpeed:4; + ULONG MaximumLinkWidth:6; + ULONG ActiveStatePMSupport:2; + ULONG L0sExitLatency:3; + ULONG L1ExitLatency:3; + ULONG ClockPowerManagement:1; + ULONG SurpriseDownErrorReportingCapable:1; + ULONG DataLinkLayerActiveReportingCapable:1; + ULONG Rsvd:3; + ULONG PortNumber:8; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_LINK_CAPABILITIES_REGISTER, *PPCI_EXPRESS_LINK_CAPABILITIES_REGISTER; + +typedef union _PCI_EXPRESS_LINK_CONTROL_REGISTER { + struct { + USHORT ActiveStatePMControl:2; + USHORT Rsvd1:1; + USHORT ReadCompletionBoundary:1; + USHORT LinkDisable:1; + USHORT RetrainLink:1; + USHORT CommonClockConfig:1; + USHORT ExtendedSynch:1; + USHORT EnableClockPowerManagement:1; + USHORT Rsvd2:7; + } DUMMYSTRUCTNAME; + USHORT AsUSHORT; +} PCI_EXPRESS_LINK_CONTROL_REGISTER, *PPCI_EXPRESS_LINK_CONTROL_REGISTER; + +typedef union _PCI_EXPRESS_LINK_STATUS_REGISTER { + struct { + USHORT LinkSpeed:4; + USHORT LinkWidth:6; + USHORT Undefined:1; + USHORT LinkTraining:1; + USHORT SlotClockConfig:1; + USHORT DataLinkLayerActive:1; + USHORT Rsvd:2; + } DUMMYSTRUCTNAME; + USHORT AsUSHORT; +} PCI_EXPRESS_LINK_STATUS_REGISTER, *PPCI_EXPRESS_LINK_STATUS_REGISTER; + +typedef union _PCI_EXPRESS_SLOT_CAPABILITIES_REGISTER { + struct { + ULONG AttentionButtonPresent:1; + ULONG PowerControllerPresent:1; + ULONG MRLSensorPresent:1; + ULONG AttentionIndicatorPresent:1; + ULONG PowerIndicatorPresent:1; + ULONG HotPlugSurprise:1; + ULONG HotPlugCapable:1; + ULONG SlotPowerLimit:8; + ULONG SlotPowerLimitScale:2; + ULONG ElectromechanicalLockPresent:1; + ULONG NoCommandCompletedSupport:1; + ULONG PhysicalSlotNumber:13; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_SLOT_CAPABILITIES_REGISTER, *PPCI_EXPRESS_SLOT_CAPABILITIES_REGISTER; + +typedef union _PCI_EXPRESS_SLOT_CONTROL_REGISTER { + struct { + USHORT AttentionButtonEnable:1; + USHORT PowerFaultDetectEnable:1; + USHORT MRLSensorEnable:1; + USHORT PresenceDetectEnable:1; + USHORT CommandCompletedEnable:1; + USHORT HotPlugInterruptEnable:1; + USHORT AttentionIndicatorControl:2; + USHORT PowerIndicatorControl:2; + USHORT PowerControllerControl:1; + USHORT ElectromechanicalLockControl:1; + USHORT DataLinkStateChangeEnable:1; + USHORT Rsvd:3; + } DUMMYSTRUCTNAME; + USHORT AsUSHORT; +} PCI_EXPRESS_SLOT_CONTROL_REGISTER, *PPCI_EXPRESS_SLOT_CONTROL_REGISTER; + +typedef union _PCI_EXPRESS_SLOT_STATUS_REGISTER { + struct { + USHORT AttentionButtonPressed:1; + USHORT PowerFaultDetected:1; + USHORT MRLSensorChanged:1; + USHORT PresenceDetectChanged:1; + USHORT CommandCompleted:1; + USHORT MRLSensorState:1; + USHORT PresenceDetectState:1; + USHORT ElectromechanicalLockEngaged:1; + USHORT DataLinkStateChanged:1; + USHORT Rsvd:7; + } DUMMYSTRUCTNAME; + USHORT AsUSHORT; +} PCI_EXPRESS_SLOT_STATUS_REGISTER, *PPCI_EXPRESS_SLOT_STATUS_REGISTER; + +typedef union _PCI_EXPRESS_ROOT_CONTROL_REGISTER { + struct { + USHORT CorrectableSerrEnable:1; + USHORT NonFatalSerrEnable:1; + USHORT FatalSerrEnable:1; + USHORT PMEInterruptEnable:1; + USHORT CRSSoftwareVisibilityEnable:1; + USHORT Rsvd:11; + } DUMMYSTRUCTNAME; + USHORT AsUSHORT; +} PCI_EXPRESS_ROOT_CONTROL_REGISTER, *PPCI_EXPRESS_ROOT_CONTROL_REGISTER; + +typedef union _PCI_EXPRESS_ROOT_CAPABILITIES_REGISTER { + struct { + USHORT CRSSoftwareVisibility:1; + USHORT Rsvd:15; + } DUMMYSTRUCTNAME; + USHORT AsUSHORT; +} PCI_EXPRESS_ROOT_CAPABILITIES_REGISTER, *PPCI_EXPRESS_ROOT_CAPABILITIES_REGISTER; + +typedef union _PCI_EXPRESS_ROOT_STATUS_REGISTER { + struct { + ULONG PMERequestorId:16; + ULONG PMEStatus:1; + ULONG PMEPending:1; + ULONG Rsvd:14; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_ROOT_STATUS_REGISTER, *PPCI_EXPRESS_ROOT_STATUS_REGISTER; + +typedef struct _PCI_EXPRESS_CAPABILITY { + PCI_CAPABILITIES_HEADER Header; + PCI_EXPRESS_CAPABILITIES_REGISTER ExpressCapabilities; + PCI_EXPRESS_DEVICE_CAPABILITIES_REGISTER DeviceCapabilities; + PCI_EXPRESS_DEVICE_CONTROL_REGISTER DeviceControl; + PCI_EXPRESS_DEVICE_STATUS_REGISTER DeviceStatus; + PCI_EXPRESS_LINK_CAPABILITIES_REGISTER LinkCapabilities; + PCI_EXPRESS_LINK_CONTROL_REGISTER LinkControl; + PCI_EXPRESS_LINK_STATUS_REGISTER LinkStatus; + PCI_EXPRESS_SLOT_CAPABILITIES_REGISTER SlotCapabilities; + PCI_EXPRESS_SLOT_CONTROL_REGISTER SlotControl; + PCI_EXPRESS_SLOT_STATUS_REGISTER SlotStatus; + PCI_EXPRESS_ROOT_CONTROL_REGISTER RootControl; + PCI_EXPRESS_ROOT_CAPABILITIES_REGISTER RootCapabilities; + PCI_EXPRESS_ROOT_STATUS_REGISTER RootStatus; +} PCI_EXPRESS_CAPABILITY, *PPCI_EXPRESS_CAPABILITY; + +typedef enum { + MRLClosed = 0, + MRLOpen +} PCI_EXPRESS_MRL_STATE; + +typedef enum { + SlotEmpty = 0, + CardPresent +} PCI_EXPRESS_CARD_PRESENCE; + +typedef enum { + IndicatorOn = 1, + IndicatorBlink, + IndicatorOff +} PCI_EXPRESS_INDICATOR_STATE; + +typedef enum { + PowerOn = 0, + PowerOff +} PCI_EXPRESS_POWER_STATE; + +typedef enum { + L0sEntrySupport = 1, + L0sAndL1EntrySupport = 3 +} PCI_EXPRESS_ASPM_SUPPORT; + +typedef enum { + L0sAndL1EntryDisabled, + L0sEntryEnabled, + L1EntryEnabled, + L0sAndL1EntryEnabled +} PCI_EXPRESS_ASPM_CONTROL; + +typedef enum { + L0s_Below64ns = 0, + L0s_64ns_128ns, + L0s_128ns_256ns, + L0s_256ns_512ns, + L0s_512ns_1us, + L0s_1us_2us, + L0s_2us_4us, + L0s_Above4us +} PCI_EXPRESS_L0s_EXIT_LATENCY; + +typedef enum { + L1_Below1us = 0, + L1_1us_2us, + L1_2us_4us, + L1_4us_8us, + L1_8us_16us, + L1_16us_32us, + L1_32us_64us, + L1_Above64us +} PCI_EXPRESS_L1_EXIT_LATENCY; + +typedef enum { + PciExpressEndpoint = 0, + PciExpressLegacyEndpoint, + PciExpressRootPort = 4, + PciExpressUpstreamSwitchPort, + PciExpressDownstreamSwitchPort, + PciExpressToPciXBridge, + PciXToExpressBridge, + PciExpressRootComplexIntegratedEndpoint, + PciExpressRootComplexEventCollector +} PCI_EXPRESS_DEVICE_TYPE; + +typedef enum { + MaxPayload128Bytes = 0, + MaxPayload256Bytes, + MaxPayload512Bytes, + MaxPayload1024Bytes, + MaxPayload2048Bytes, + MaxPayload4096Bytes +} PCI_EXPRESS_MAX_PAYLOAD_SIZE; + +typedef union _PCI_EXPRESS_PME_REQUESTOR_ID { + struct { + USHORT FunctionNumber:3; + USHORT DeviceNumber:5; + USHORT BusNumber:8; + } DUMMYSTRUCTNAME; + USHORT AsUSHORT; +} PCI_EXPRESS_PME_REQUESTOR_ID, *PPCI_EXPRESS_PME_REQUESTOR_ID; + +#if defined(_WIN64) + +#ifndef USE_DMA_MACROS +#define USE_DMA_MACROS +#endif + +#ifndef NO_LEGACY_DRIVERS +#define NO_LEGACY_DRIVERS +#endif + +#endif /* defined(_WIN64) */ + +typedef enum _PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR_TYPE { + ResourceTypeSingle = 0, + ResourceTypeRange, + ResourceTypeExtendedCounterConfiguration, + ResourceTypeOverflow, + ResourceTypeMax +} PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR_TYPE; + +typedef struct _PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR { + PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR_TYPE Type; + ULONG Flags; + union { + ULONG CounterIndex; + ULONG ExtendedRegisterAddress; + struct { + ULONG Begin; + ULONG End; + } Range; + } u; +} PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR, *PPHYSICAL_COUNTER_RESOURCE_DESCRIPTOR; + +typedef struct _PHYSICAL_COUNTER_RESOURCE_LIST { + ULONG Count; + PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR Descriptors[ANYSIZE_ARRAY]; +} PHYSICAL_COUNTER_RESOURCE_LIST, *PPHYSICAL_COUNTER_RESOURCE_LIST; + +typedef VOID +(NTAPI *PciPin2Line)( + IN struct _BUS_HANDLER *BusHandler, + IN struct _BUS_HANDLER *RootHandler, + IN PCI_SLOT_NUMBER SlotNumber, + IN PPCI_COMMON_CONFIG PciData); + +typedef VOID +(NTAPI *PciLine2Pin)( + IN struct _BUS_HANDLER *BusHandler, + IN struct _BUS_HANDLER *RootHandler, + IN PCI_SLOT_NUMBER SlotNumber, + IN PPCI_COMMON_CONFIG PciNewData, + IN PPCI_COMMON_CONFIG PciOldData); + +typedef VOID +(NTAPI *PciReadWriteConfig)( + IN struct _BUS_HANDLER *BusHandler, + IN PCI_SLOT_NUMBER Slot, + IN PVOID Buffer, + IN ULONG Offset, + IN ULONG Length); + +#define PCI_DATA_TAG ' ICP' +#define PCI_DATA_VERSION 1 + +typedef struct _PCIBUSDATA { + ULONG Tag; + ULONG Version; + PciReadWriteConfig ReadConfig; + PciReadWriteConfig WriteConfig; + PciPin2Line Pin2Line; + PciLine2Pin Line2Pin; + PCI_SLOT_NUMBER ParentSlot; + PVOID Reserved[4]; +} PCIBUSDATA, *PPCIBUSDATA; + +#ifndef _PCIINTRF_X_ +#define _PCIINTRF_X_ + +typedef ULONG +(NTAPI *PCI_READ_WRITE_CONFIG)( + IN PVOID Context, + IN ULONG BusOffset, + IN ULONG Slot, + IN PVOID Buffer, + IN ULONG Offset, + IN ULONG Length); + +typedef VOID +(NTAPI *PCI_PIN_TO_LINE)( + IN PVOID Context, + IN PPCI_COMMON_CONFIG PciData); + +typedef VOID +(NTAPI *PCI_LINE_TO_PIN)( + IN PVOID Context, + IN PPCI_COMMON_CONFIG PciNewData, + IN PPCI_COMMON_CONFIG PciOldData); + +typedef VOID +(NTAPI *PCI_ROOT_BUS_CAPABILITY)( + IN PVOID Context, + OUT PPCI_ROOT_BUS_HARDWARE_CAPABILITY HardwareCapability); + +typedef VOID +(NTAPI *PCI_EXPRESS_WAKE_CONTROL)( + IN PVOID Context, + IN BOOLEAN EnableWake); + +typedef struct _PCI_BUS_INTERFACE_STANDARD { + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; + PCI_READ_WRITE_CONFIG ReadConfig; + PCI_READ_WRITE_CONFIG WriteConfig; + PCI_PIN_TO_LINE PinToLine; + PCI_LINE_TO_PIN LineToPin; + PCI_ROOT_BUS_CAPABILITY RootBusCapability; + PCI_EXPRESS_WAKE_CONTROL ExpressWakeControl; +} PCI_BUS_INTERFACE_STANDARD, *PPCI_BUS_INTERFACE_STANDARD; + +#define PCI_BUS_INTERFACE_STANDARD_VERSION 1 + +#endif /* _PCIINTRF_X_ */ + +#if (NTDDI_VERSION >= NTDDI_WIN7) + +#define FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL_EX 0x00004000 +#define FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL_EX 0x00008000 +#define FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK_EX \ + (FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL_EX | \ + FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL_EX) + +#define FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL_DEPRECATED 0x00000200 +#define FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL_DEPRECATED 0x00000300 +#define FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK_DEPRECATED 0x00000300 + +#else + +#define FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL 0x00000200 +#define FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL 0x00000300 +#define FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK 0x00000300 + +#define FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL_EX FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL +#define FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL_EX FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL +#define FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK_EX FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + +#define FILE_CHARACTERISTICS_PROPAGATED ( FILE_REMOVABLE_MEDIA | \ + FILE_READ_ONLY_DEVICE | \ + FILE_FLOPPY_DISKETTE | \ + FILE_WRITE_ONCE_MEDIA | \ + FILE_DEVICE_SECURE_OPEN ) + +typedef struct _FILE_ALIGNMENT_INFORMATION { + ULONG AlignmentRequirement; +} FILE_ALIGNMENT_INFORMATION, *PFILE_ALIGNMENT_INFORMATION; + +typedef struct _FILE_NAME_INFORMATION { + ULONG FileNameLength; + WCHAR FileName[1]; +} FILE_NAME_INFORMATION, *PFILE_NAME_INFORMATION; + + +typedef struct _FILE_ATTRIBUTE_TAG_INFORMATION { + ULONG FileAttributes; + ULONG ReparseTag; +} FILE_ATTRIBUTE_TAG_INFORMATION, *PFILE_ATTRIBUTE_TAG_INFORMATION; + +typedef struct _FILE_DISPOSITION_INFORMATION { + BOOLEAN DeleteFile; +} FILE_DISPOSITION_INFORMATION, *PFILE_DISPOSITION_INFORMATION; + +typedef struct _FILE_END_OF_FILE_INFORMATION { + LARGE_INTEGER EndOfFile; +} FILE_END_OF_FILE_INFORMATION, *PFILE_END_OF_FILE_INFORMATION; + +typedef struct _FILE_VALID_DATA_LENGTH_INFORMATION { + LARGE_INTEGER ValidDataLength; +} FILE_VALID_DATA_LENGTH_INFORMATION, *PFILE_VALID_DATA_LENGTH_INFORMATION; + +typedef struct _FILE_FS_LABEL_INFORMATION { + ULONG VolumeLabelLength; + WCHAR VolumeLabel[1]; +} FILE_FS_LABEL_INFORMATION, *PFILE_FS_LABEL_INFORMATION; + +typedef struct _FILE_FS_VOLUME_INFORMATION { + LARGE_INTEGER VolumeCreationTime; + ULONG VolumeSerialNumber; + ULONG VolumeLabelLength; + BOOLEAN SupportsObjects; + WCHAR VolumeLabel[1]; +} FILE_FS_VOLUME_INFORMATION, *PFILE_FS_VOLUME_INFORMATION; + +typedef struct _FILE_FS_SIZE_INFORMATION { + LARGE_INTEGER TotalAllocationUnits; + LARGE_INTEGER AvailableAllocationUnits; + ULONG SectorsPerAllocationUnit; + ULONG BytesPerSector; +} FILE_FS_SIZE_INFORMATION, *PFILE_FS_SIZE_INFORMATION; + +typedef struct _FILE_FS_FULL_SIZE_INFORMATION { + LARGE_INTEGER TotalAllocationUnits; + LARGE_INTEGER CallerAvailableAllocationUnits; + LARGE_INTEGER ActualAvailableAllocationUnits; + ULONG SectorsPerAllocationUnit; + ULONG BytesPerSector; +} FILE_FS_FULL_SIZE_INFORMATION, *PFILE_FS_FULL_SIZE_INFORMATION; + +typedef struct _FILE_FS_OBJECTID_INFORMATION { + UCHAR ObjectId[16]; + UCHAR ExtendedInfo[48]; +} FILE_FS_OBJECTID_INFORMATION, *PFILE_FS_OBJECTID_INFORMATION; + +typedef union _FILE_SEGMENT_ELEMENT { + PVOID64 Buffer; + ULONGLONG Alignment; +}FILE_SEGMENT_ELEMENT, *PFILE_SEGMENT_ELEMENT; + +#define IOCTL_AVIO_ALLOCATE_STREAM CTL_CODE(FILE_DEVICE_AVIO, 1, METHOD_BUFFERED, FILE_SPECIAL_ACCESS) +#define IOCTL_AVIO_FREE_STREAM CTL_CODE(FILE_DEVICE_AVIO, 2, METHOD_BUFFERED, FILE_SPECIAL_ACCESS) +#define IOCTL_AVIO_MODIFY_STREAM CTL_CODE(FILE_DEVICE_AVIO, 3, METHOD_BUFFERED, FILE_SPECIAL_ACCESS) + +typedef enum _BUS_DATA_TYPE { + ConfigurationSpaceUndefined = -1, + Cmos, + EisaConfiguration, + Pos, + CbusConfiguration, + PCIConfiguration, + VMEConfiguration, + NuBusConfiguration, + PCMCIAConfiguration, + MPIConfiguration, + MPSAConfiguration, + PNPISAConfiguration, + SgiInternalConfiguration, + MaximumBusDataType +} BUS_DATA_TYPE, *PBUS_DATA_TYPE; + +/* Hardware Abstraction Layer Types */ + +typedef BOOLEAN +(NTAPI *PHAL_RESET_DISPLAY_PARAMETERS)( + IN ULONG Columns, + IN ULONG Rows); + +typedef PBUS_HANDLER +(FASTCALL *pHalHandlerForBus)( + IN INTERFACE_TYPE InterfaceType, + IN ULONG BusNumber); + +typedef VOID +(FASTCALL *pHalReferenceBusHandler)( + IN PBUS_HANDLER BusHandler); + typedef enum _HAL_QUERY_INFORMATION_CLASS { HalInstalledBusInformation, HalProfileSourceInformation, @@ -353,92 +1307,18 @@ typedef enum _HAL_SET_INFORMATION_CLASS { HalProfileDpgoSourceInterruptHandler } HAL_SET_INFORMATION_CLASS, *PHAL_SET_INFORMATION_CLASS; -typedef struct _HAL_PROFILE_SOURCE_INTERVAL { - KPROFILE_SOURCE Source; - ULONG_PTR Interval; -} HAL_PROFILE_SOURCE_INTERVAL, *PHAL_PROFILE_SOURCE_INTERVAL; - -typedef struct _HAL_PROFILE_SOURCE_INFORMATION { - KPROFILE_SOURCE Source; - BOOLEAN Supported; - ULONG Interval; -} HAL_PROFILE_SOURCE_INFORMATION, *PHAL_PROFILE_SOURCE_INFORMATION; - -typedef struct _MAP_REGISTER_ENTRY { - PVOID MapRegister; - BOOLEAN WriteToDevice; -} MAP_REGISTER_ENTRY, *PMAP_REGISTER_ENTRY; - -typedef struct _DEBUG_DEVICE_ADDRESS { - UCHAR Type; - BOOLEAN Valid; - UCHAR Reserved[2]; - PUCHAR TranslatedAddress; - ULONG Length; -} DEBUG_DEVICE_ADDRESS, *PDEBUG_DEVICE_ADDRESS; - -typedef struct _DEBUG_MEMORY_REQUIREMENTS { - PHYSICAL_ADDRESS Start; - PHYSICAL_ADDRESS MaxEnd; - PVOID VirtualAddress; - ULONG Length; - BOOLEAN Cached; - BOOLEAN Aligned; -} DEBUG_MEMORY_REQUIREMENTS, *PDEBUG_MEMORY_REQUIREMENTS; - -typedef struct _DEBUG_DEVICE_DESCRIPTOR { - ULONG Bus; - ULONG Slot; - USHORT Segment; - USHORT VendorID; - USHORT DeviceID; - UCHAR BaseClass; - UCHAR SubClass; - UCHAR ProgIf; - BOOLEAN Initialized; - BOOLEAN Configured; - DEBUG_DEVICE_ADDRESS BaseAddress[6]; - DEBUG_MEMORY_REQUIREMENTS Memory; -} DEBUG_DEVICE_DESCRIPTOR, *PDEBUG_DEVICE_DESCRIPTOR; - -typedef struct _PM_DISPATCH_TABLE { - ULONG Signature; - ULONG Version; - PVOID Function[1]; -} PM_DISPATCH_TABLE, *PPM_DISPATCH_TABLE; - -typedef enum _RESOURCE_TRANSLATION_DIRECTION { - TranslateChildToParent, - TranslateParentToChild -} RESOURCE_TRANSLATION_DIRECTION; +typedef NTSTATUS +(NTAPI *pHalQuerySystemInformation)( + IN HAL_QUERY_INFORMATION_CLASS InformationClass, + IN ULONG BufferSize, + IN OUT PVOID Buffer, + OUT PULONG ReturnedLength); typedef NTSTATUS -(NTAPI *PTRANSLATE_RESOURCE_HANDLER)( - IN OUT PVOID Context, - IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Source, - IN RESOURCE_TRANSLATION_DIRECTION Direction, - IN ULONG AlternativesCount OPTIONAL, - IN IO_RESOURCE_DESCRIPTOR Alternatives[], - IN PDEVICE_OBJECT PhysicalDeviceObject, - OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR Target); - -typedef NTSTATUS -(NTAPI *PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER)( - IN PVOID Context OPTIONAL, - IN PIO_RESOURCE_DESCRIPTOR Source, - IN PDEVICE_OBJECT PhysicalDeviceObject, - OUT PULONG TargetCount, - OUT PIO_RESOURCE_DESCRIPTOR *Target); - -typedef struct _TRANSLATOR_INTERFACE { - USHORT Size; - USHORT Version; - PVOID Context; - PINTERFACE_REFERENCE InterfaceReference; - PINTERFACE_DEREFERENCE InterfaceDereference; - PTRANSLATE_RESOURCE_HANDLER TranslateResources; - PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER TranslateResourceRequirements; -} TRANSLATOR_INTERFACE, *PTRANSLATOR_INTERFACE; +(NTAPI *pHalSetSystemInformation)( + IN HAL_SET_INFORMATION_CLASS InformationClass, + IN ULONG BufferSize, + IN PVOID Buffer); typedef VOID (FASTCALL *pHalExamineMBR)( @@ -469,28 +1349,6 @@ typedef NTSTATUS IN ULONG NumberOfHeads, IN struct _DRIVE_LAYOUT_INFORMATION *PartitionBuffer); -typedef PBUS_HANDLER -(FASTCALL *pHalHandlerForBus)( - IN INTERFACE_TYPE InterfaceType, - IN ULONG BusNumber); - -typedef VOID -(FASTCALL *pHalReferenceBusHandler)( - IN PBUS_HANDLER BusHandler); - -typedef NTSTATUS -(NTAPI *pHalQuerySystemInformation)( - IN HAL_QUERY_INFORMATION_CLASS InformationClass, - IN ULONG BufferSize, - IN OUT PVOID Buffer, - OUT PULONG ReturnedLength); - -typedef NTSTATUS -(NTAPI *pHalSetSystemInformation)( - IN HAL_SET_INFORMATION_CLASS InformationClass, - IN ULONG BufferSize, - IN PVOID Buffer); - typedef NTSTATUS (NTAPI *pHalQueryBusSlots)( IN PBUS_HANDLER BusHandler, @@ -502,6 +1360,12 @@ typedef NTSTATUS (NTAPI *pHalInitPnpDriver)( VOID); +typedef struct _PM_DISPATCH_TABLE { + ULONG Signature; + ULONG Version; + PVOID Function[1]; +} PM_DISPATCH_TABLE, *PPM_DISPATCH_TABLE; + typedef NTSTATUS (NTAPI *pHalInitPowerManagement)( IN PPM_DISPATCH_TABLE PmDriverDispatchTable, @@ -541,12 +1405,7 @@ typedef NTSTATUS IN PHYSICAL_ADDRESS PhysicalAddress, IN LARGE_INTEGER NumberOfBytes); -typedef VOID -(NTAPI *pHalEndOfBoot)( - VOID); - -typedef -BOOLEAN +typedef BOOLEAN (NTAPI *pHalTranslateBusAddress)( IN INTERFACE_TYPE InterfaceType, IN ULONG BusNumber, @@ -554,8 +1413,7 @@ BOOLEAN IN OUT PULONG AddressSpace, OUT PPHYSICAL_ADDRESS TranslatedAddress); -typedef -NTSTATUS +typedef NTSTATUS (NTAPI *pHalAssignSlotResources)( IN PUNICODE_STRING RegistryPath, IN PUNICODE_STRING DriverClassName OPTIONAL, @@ -566,23 +1424,24 @@ NTSTATUS IN ULONG SlotNumber, IN OUT PCM_RESOURCE_LIST *AllocatedResources); -typedef -VOID +typedef VOID (NTAPI *pHalHaltSystem)( VOID); -typedef -BOOLEAN +typedef BOOLEAN (NTAPI *pHalResetDisplay)( VOID); -typedef -UCHAR +typedef struct _MAP_REGISTER_ENTRY { + PVOID MapRegister; + BOOLEAN WriteToDevice; +} MAP_REGISTER_ENTRY, *PMAP_REGISTER_ENTRY; + +typedef UCHAR (NTAPI *pHalVectorToIDTEntry)( ULONG Vector); -typedef -BOOLEAN +typedef BOOLEAN (NTAPI *pHalFindBusAddressTranslation)( IN PHYSICAL_ADDRESS BusAddress, IN OUT PULONG AddressSpace, @@ -590,94 +1449,33 @@ BOOLEAN IN OUT PULONG_PTR Context, IN BOOLEAN NextBus); -typedef -NTSTATUS -(NTAPI *pKdSetupPciDeviceForDebugging)( - IN PVOID LoaderBlock OPTIONAL, - IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice); +typedef VOID +(NTAPI *pHalEndOfBoot)( + VOID); -typedef -NTSTATUS -(NTAPI *pKdReleasePciDeviceForDebugging)( - IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice); - -typedef -PVOID -(NTAPI *pKdGetAcpiTablePhase0)( - IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock, - IN ULONG Signature); - -typedef -PVOID +typedef PVOID (NTAPI *pHalGetAcpiTable)( IN ULONG Signature, IN PCSTR OemId OPTIONAL, IN PCSTR OemTableId OPTIONAL); - -typedef -VOID -(NTAPI *pKdCheckPowerButton)( - VOID); -#if (NTDDI_VERSION >= NTDDI_VISTA) -typedef -PVOID -(NTAPI *pKdMapPhysicalMemory64)( - IN PHYSICAL_ADDRESS PhysicalAddress, - IN ULONG NumberPages, - IN BOOLEAN FlushCurrentTLB); +#if defined(_IA64_) +typedef NTSTATUS +(*pHalGetErrorCapList)( + IN OUT PULONG CapsListLength, + IN OUT PUCHAR ErrorCapList); -typedef -VOID -(NTAPI *pKdUnmapVirtualAddress)( - IN PVOID VirtualAddress, - IN ULONG NumberPages, - IN BOOLEAN FlushCurrentTLB); -#else -typedef -PVOID -(NTAPI *pKdMapPhysicalMemory64)( - IN PHYSICAL_ADDRESS PhysicalAddress, - IN ULONG NumberPages); - -typedef -VOID -(NTAPI *pKdUnmapVirtualAddress)( - IN PVOID VirtualAddress, - IN ULONG NumberPages); +typedef NTSTATUS +(*pHalInjectError)( + IN ULONG BufferLength, + IN PUCHAR Buffer); #endif - -typedef -ULONG -(NTAPI *pKdGetPciDataByOffset)( - IN ULONG BusNumber, - IN ULONG SlotNumber, - OUT PVOID Buffer, - IN ULONG Offset, - IN ULONG Length); - -typedef -ULONG -(NTAPI *pKdSetPciDataByOffset)( - IN ULONG BusNumber, - IN ULONG SlotNumber, - IN PVOID Buffer, - IN ULONG Offset, - IN ULONG Length); - -typedef BOOLEAN -(NTAPI *PHAL_RESET_DISPLAY_PARAMETERS)( - IN ULONG Columns, - IN ULONG Rows); - -typedef -VOID +typedef VOID (NTAPI *PCI_ERROR_HANDLER_CALLBACK)( VOID); -typedef -VOID +typedef VOID (NTAPI *pHalSetPciErrorHandlerCallback)( IN PCI_ERROR_HANDLER_CALLBACK Callback); @@ -751,78 +1549,706 @@ extern NTKERNELAPI HAL_DISPATCH HalDispatchTable; #define HalMirrorPhysicalMemory HALDISPATCH->HalMirrorPhysicalMemory #define HalEndOfBoot HALDISPATCH->HalEndOfBoot #define HalMirrorVerify HALDISPATCH->HalMirrorVerify - -typedef struct _FILE_ALIGNMENT_INFORMATION { - ULONG AlignmentRequirement; -} FILE_ALIGNMENT_INFORMATION, *PFILE_ALIGNMENT_INFORMATION; - -typedef struct _FILE_NAME_INFORMATION { - ULONG FileNameLength; - WCHAR FileName[1]; -} FILE_NAME_INFORMATION, *PFILE_NAME_INFORMATION; - - -typedef struct _FILE_ATTRIBUTE_TAG_INFORMATION { - ULONG FileAttributes; - ULONG ReparseTag; -} FILE_ATTRIBUTE_TAG_INFORMATION, *PFILE_ATTRIBUTE_TAG_INFORMATION; - -typedef struct _FILE_DISPOSITION_INFORMATION { - BOOLEAN DeleteFile; -} FILE_DISPOSITION_INFORMATION, *PFILE_DISPOSITION_INFORMATION; - -typedef struct _FILE_END_OF_FILE_INFORMATION { - LARGE_INTEGER EndOfFile; -} FILE_END_OF_FILE_INFORMATION, *PFILE_END_OF_FILE_INFORMATION; - -typedef struct _FILE_VALID_DATA_LENGTH_INFORMATION { - LARGE_INTEGER ValidDataLength; -} FILE_VALID_DATA_LENGTH_INFORMATION, *PFILE_VALID_DATA_LENGTH_INFORMATION; - -typedef union _FILE_SEGMENT_ELEMENT { - PVOID64 Buffer; - ULONGLONG Alignment; -}FILE_SEGMENT_ELEMENT, *PFILE_SEGMENT_ELEMENT; - -#define SE_UNSOLICITED_INPUT_PRIVILEGE 6 - -#if (NTDDI_VERSION >= NTDDI_WIN2K) -NTSYSAPI -ULONGLONG -NTAPI -VerSetConditionMask( - IN ULONGLONG ConditionMask, - IN ULONG TypeMask, - IN UCHAR Condition); +#define HalGetCachedAcpiTable HALDISPATCH->HalGetCachedAcpiTable +#define HalSetPciErrorHandlerCallback HALDISPATCH->HalSetPciErrorHandlerCallback +#if defined(_IA64_) +#define HalGetErrorCapList HALDISPATCH->HalGetErrorCapList +#define HalInjectError HALDISPATCH->HalInjectError #endif -#define VER_SET_CONDITION(ConditionMask, TypeBitMask, ComparisonType) \ - ((ConditionMask) = VerSetConditionMask((ConditionMask), \ - (TypeBitMask), (ComparisonType))) +typedef struct _HAL_BUS_INFORMATION { + INTERFACE_TYPE BusType; + BUS_DATA_TYPE ConfigurationType; + ULONG BusNumber; + ULONG Reserved; +} HAL_BUS_INFORMATION, *PHAL_BUS_INFORMATION; -/* RtlVerifyVersionInfo() TypeMask */ +typedef struct _HAL_PROFILE_SOURCE_INFORMATION { + KPROFILE_SOURCE Source; + BOOLEAN Supported; + ULONG Interval; +} HAL_PROFILE_SOURCE_INFORMATION, *PHAL_PROFILE_SOURCE_INFORMATION; -#define VER_MINORVERSION 0x0000001 -#define VER_MAJORVERSION 0x0000002 -#define VER_BUILDNUMBER 0x0000004 -#define VER_PLATFORMID 0x0000008 -#define VER_SERVICEPACKMINOR 0x0000010 -#define VER_SERVICEPACKMAJOR 0x0000020 -#define VER_SUITENAME 0x0000040 -#define VER_PRODUCT_TYPE 0x0000080 +typedef struct _HAL_PROFILE_SOURCE_INFORMATION_EX { + KPROFILE_SOURCE Source; + BOOLEAN Supported; + ULONG_PTR Interval; + ULONG_PTR DefInterval; + ULONG_PTR MaxInterval; + ULONG_PTR MinInterval; +} HAL_PROFILE_SOURCE_INFORMATION_EX, *PHAL_PROFILE_SOURCE_INFORMATION_EX; -/* RtlVerifyVersionInfo() ComparisonType */ +typedef struct _HAL_PROFILE_SOURCE_INTERVAL { + KPROFILE_SOURCE Source; + ULONG_PTR Interval; +} HAL_PROFILE_SOURCE_INTERVAL, *PHAL_PROFILE_SOURCE_INTERVAL; -#define VER_EQUAL 1 -#define VER_GREATER 2 -#define VER_GREATER_EQUAL 3 -#define VER_LESS 4 -#define VER_LESS_EQUAL 5 -#define VER_AND 6 -#define VER_OR 7 +typedef struct _HAL_PROFILE_SOURCE_LIST { + KPROFILE_SOURCE Source; + PWSTR Description; +} HAL_PROFILE_SOURCE_LIST, *PHAL_PROFILE_SOURCE_LIST; -#define VER_CONDITION_MASK 7 -#define VER_NUM_BITS_PER_CONDITION_MASK 3 +typedef enum _HAL_DISPLAY_BIOS_INFORMATION { + HalDisplayInt10Bios, + HalDisplayEmulatedBios, + HalDisplayNoBios +} HAL_DISPLAY_BIOS_INFORMATION, *PHAL_DISPLAY_BIOS_INFORMATION; + +typedef struct _HAL_POWER_INFORMATION { + ULONG TBD; +} HAL_POWER_INFORMATION, *PHAL_POWER_INFORMATION; + +typedef struct _HAL_PROCESSOR_SPEED_INFO { + ULONG ProcessorSpeed; +} HAL_PROCESSOR_SPEED_INFORMATION, *PHAL_PROCESSOR_SPEED_INFORMATION; + +typedef struct _HAL_CALLBACKS { + PCALLBACK_OBJECT SetSystemInformation; + PCALLBACK_OBJECT BusCheck; +} HAL_CALLBACKS, *PHAL_CALLBACKS; + +typedef struct _HAL_PROCESSOR_FEATURE { + ULONG UsableFeatureBits; +} HAL_PROCESSOR_FEATURE; + +typedef NTSTATUS +(NTAPI *PHALIOREADWRITEHANDLER)( + IN BOOLEAN fRead, + IN ULONG dwAddr, + IN ULONG dwSize, + IN OUT PULONG pdwData); + +typedef struct _HAL_AMLI_BAD_IO_ADDRESS_LIST { + ULONG BadAddrBegin; + ULONG BadAddrSize; + ULONG OSVersionTrigger; + PHALIOREADWRITEHANDLER IOHandler; +} HAL_AMLI_BAD_IO_ADDRESS_LIST, *PHAL_AMLI_BAD_IO_ADDRESS_LIST; + +#if defined(_X86_) || defined(_IA64_) || defined(_AMD64_) + +typedef VOID +(NTAPI *PHALMCAINTERFACELOCK)( + VOID); + +typedef VOID +(NTAPI *PHALMCAINTERFACEUNLOCK)( + VOID); + +typedef NTSTATUS +(NTAPI *PHALMCAINTERFACEREADREGISTER)( + IN UCHAR BankNumber, + IN OUT PVOID Exception); + +typedef struct _HAL_MCA_INTERFACE { + PHALMCAINTERFACELOCK Lock; + PHALMCAINTERFACEUNLOCK Unlock; + PHALMCAINTERFACEREADREGISTER ReadRegister; +} HAL_MCA_INTERFACE; + +typedef enum { + ApicDestinationModePhysical = 1, + ApicDestinationModeLogicalFlat, + ApicDestinationModeLogicalClustered, + ApicDestinationModeUnknown +} HAL_APIC_DESTINATION_MODE, *PHAL_APIC_DESTINATION_MODE; + +#if defined(_AMD64_) + +struct _KTRAP_FRAME; +struct _KEXCEPTION_FRAME; + +typedef ERROR_SEVERITY +(NTAPI *PDRIVER_EXCPTN_CALLBACK)( + IN PVOID Context, + IN struct _KTRAP_FRAME *TrapFrame, + IN struct _KEXCEPTION_FRAME *ExceptionFrame, + IN PMCA_EXCEPTION Exception); + +#endif + +#if defined(_X86_) || defined(_IA64_) +typedef +#if defined(_IA64_) +ERROR_SEVERITY +#else +VOID +#endif +(NTAPI *PDRIVER_EXCPTN_CALLBACK)( + IN PVOID Context, + IN PMCA_EXCEPTION BankLog); +#endif + +typedef PDRIVER_EXCPTN_CALLBACK PDRIVER_MCA_EXCEPTION_CALLBACK; + +typedef struct _MCA_DRIVER_INFO { + PDRIVER_MCA_EXCEPTION_CALLBACK ExceptionCallback; + PKDEFERRED_ROUTINE DpcCallback; + PVOID DeviceContext; +} MCA_DRIVER_INFO, *PMCA_DRIVER_INFO; + +typedef struct _HAL_ERROR_INFO { + ULONG Version; + ULONG InitMaxSize; + ULONG McaMaxSize; + ULONG McaPreviousEventsCount; + ULONG McaCorrectedEventsCount; + ULONG McaKernelDeliveryFails; + ULONG McaDriverDpcQueueFails; + ULONG McaReserved; + ULONG CmcMaxSize; + ULONG CmcPollingInterval; + ULONG CmcInterruptsCount; + ULONG CmcKernelDeliveryFails; + ULONG CmcDriverDpcQueueFails; + ULONG CmcGetStateFails; + ULONG CmcClearStateFails; + ULONG CmcReserved; + ULONGLONG CmcLogId; + ULONG CpeMaxSize; + ULONG CpePollingInterval; + ULONG CpeInterruptsCount; + ULONG CpeKernelDeliveryFails; + ULONG CpeDriverDpcQueueFails; + ULONG CpeGetStateFails; + ULONG CpeClearStateFails; + ULONG CpeInterruptSources; + ULONGLONG CpeLogId; + ULONGLONG KernelReserved[4]; +} HAL_ERROR_INFO, *PHAL_ERROR_INFO; + +#define HAL_MCE_INTERRUPTS_BASED ((ULONG)-1) +#define HAL_MCE_DISABLED ((ULONG)0) + +#define HAL_CMC_INTERRUPTS_BASED HAL_MCE_INTERRUPTS_BASED +#define HAL_CMC_DISABLED HAL_MCE_DISABLED + +#define HAL_CPE_INTERRUPTS_BASED HAL_MCE_INTERRUPTS_BASED +#define HAL_CPE_DISABLED HAL_MCE_DISABLED + +#define HAL_MCA_INTERRUPTS_BASED HAL_MCE_INTERRUPTS_BASED +#define HAL_MCA_DISABLED HAL_MCE_DISABLED + +typedef VOID +(NTAPI *PDRIVER_CMC_EXCEPTION_CALLBACK)( + IN PVOID Context, + IN PCMC_EXCEPTION CmcLog); + +typedef VOID +(NTAPI *PDRIVER_CPE_EXCEPTION_CALLBACK)( + IN PVOID Context, + IN PCPE_EXCEPTION CmcLog); + +typedef struct _CMC_DRIVER_INFO { + PDRIVER_CMC_EXCEPTION_CALLBACK ExceptionCallback; + PKDEFERRED_ROUTINE DpcCallback; + PVOID DeviceContext; +} CMC_DRIVER_INFO, *PCMC_DRIVER_INFO; + +typedef struct _CPE_DRIVER_INFO { + PDRIVER_CPE_EXCEPTION_CALLBACK ExceptionCallback; + PKDEFERRED_ROUTINE DpcCallback; + PVOID DeviceContext; +} CPE_DRIVER_INFO, *PCPE_DRIVER_INFO; + +#endif // defined(_X86_) || defined(_IA64_) || defined(_AMD64_) + +#if defined(_IA64_) + +typedef NTSTATUS +(*HALSENDCROSSPARTITIONIPI)( + IN USHORT ProcessorID, + IN UCHAR HardwareVector); + +typedef NTSTATUS +(*HALRESERVECROSSPARTITIONINTERRUPTVECTOR)( + OUT PULONG Vector, + OUT PKIRQL Irql, + IN OUT PGROUP_AFFINITY Affinity, + OUT PUCHAR HardwareVector); + +typedef VOID +(*HALFREECROSSPARTITIONINTERRUPTVECTOR)( + IN ULONG Vector, + IN PGROUP_AFFINITY Affinity); + +typedef struct _HAL_CROSS_PARTITION_IPI_INTERFACE { + HALSENDCROSSPARTITIONIPI HalSendCrossPartitionIpi; + HALRESERVECROSSPARTITIONINTERRUPTVECTOR HalReserveCrossPartitionInterruptVector; + HALFREECROSSPARTITIONINTERRUPTVECTOR HalFreeCrossPartitionInterruptVector; +} HAL_CROSS_PARTITION_IPI_INTERFACE; + +#define HAL_CROSS_PARTITION_IPI_INTERFACE_MINIMUM_SIZE \ + FIELD_OFFSET(HAL_CROSS_PARTITION_IPI_INTERFACE, \ + HalFreeCrossPartitionInterruptVector) + +#endif /* defined(_IA64_) */ + +typedef struct _HAL_PLATFORM_INFORMATION { + ULONG PlatformFlags; +} HAL_PLATFORM_INFORMATION, *PHAL_PLATFORM_INFORMATION; + +#define HAL_PLATFORM_DISABLE_WRITE_COMBINING 0x01L +#define HAL_PLATFORM_DISABLE_PTCG 0x04L +#define HAL_PLATFORM_DISABLE_UC_MAIN_MEMORY 0x08L +#define HAL_PLATFORM_ENABLE_WRITE_COMBINING_MMIO 0x10L +#define HAL_PLATFORM_ACPI_TABLES_CACHED 0x20L + +/****************************************************************************** + * Kernel Types * + ******************************************************************************/ + +#define NX_SUPPORT_POLICY_ALWAYSOFF 0 +#define NX_SUPPORT_POLICY_ALWAYSON 1 +#define NX_SUPPORT_POLICY_OPTIN 2 +#define NX_SUPPORT_POLICY_OPTOUT 3 + +typedef VOID +(NTAPI *PEXPAND_STACK_CALLOUT)( + IN PVOID Parameter OPTIONAL); + +typedef VOID +(NTAPI *PTIMER_APC_ROUTINE)( + IN PVOID TimerContext, + IN ULONG TimerLowValue, + IN LONG TimerHighValue); + +typedef enum _TIMER_SET_INFORMATION_CLASS { + TimerSetCoalescableTimer, + MaxTimerInfoClass +} TIMER_SET_INFORMATION_CLASS; + +#if (NTDDI_VERSION >= NTDDI_WIN7) +typedef struct _TIMER_SET_COALESCABLE_TIMER_INFO { + IN LARGE_INTEGER DueTime; + IN PTIMER_APC_ROUTINE TimerApcRoutine OPTIONAL; + IN PVOID TimerContext OPTIONAL; + IN struct _COUNTED_REASON_CONTEXT *WakeContext OPTIONAL; + IN ULONG Period OPTIONAL; + IN ULONG TolerableDelay; + OUT PBOOLEAN PreviousState OPTIONAL; +} TIMER_SET_COALESCABLE_TIMER_INFO, *PTIMER_SET_COALESCABLE_TIMER_INFO; +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + +#define XSTATE_LEGACY_FLOATING_POINT 0 +#define XSTATE_LEGACY_SSE 1 +#define XSTATE_GSSE 2 + +#define XSTATE_MASK_LEGACY_FLOATING_POINT (1i64 << (XSTATE_LEGACY_FLOATING_POINT)) +#define XSTATE_MASK_LEGACY_SSE (1i64 << (XSTATE_LEGACY_SSE)) +#define XSTATE_MASK_LEGACY (XSTATE_MASK_LEGACY_FLOATING_POINT | XSTATE_MASK_LEGACY_SSE) +#define XSTATE_MASK_GSSE (1i64 << (XSTATE_GSSE)) + +#define MAXIMUM_XSTATE_FEATURES 64 + +typedef struct _XSTATE_FEATURE { + ULONG Offset; + ULONG Size; +} XSTATE_FEATURE, *PXSTATE_FEATURE; + +typedef struct _XSTATE_CONFIGURATION { + ULONG64 EnabledFeatures; + ULONG Size; + ULONG OptimizedSave:1; + XSTATE_FEATURE Features[MAXIMUM_XSTATE_FEATURES]; +} XSTATE_CONFIGURATION, *PXSTATE_CONFIGURATION; + +#define MAX_WOW64_SHARED_ENTRIES 16 + +typedef struct _KUSER_SHARED_DATA { + ULONG TickCountLowDeprecated; + ULONG TickCountMultiplier; + volatile KSYSTEM_TIME InterruptTime; + volatile KSYSTEM_TIME SystemTime; + volatile KSYSTEM_TIME TimeZoneBias; + USHORT ImageNumberLow; + USHORT ImageNumberHigh; + WCHAR NtSystemRoot[260]; + ULONG MaxStackTraceDepth; + ULONG CryptoExponent; + ULONG TimeZoneId; + ULONG LargePageMinimum; + ULONG Reserved2[7]; + NT_PRODUCT_TYPE NtProductType; + BOOLEAN ProductTypeIsValid; + ULONG NtMajorVersion; + ULONG NtMinorVersion; + BOOLEAN ProcessorFeatures[PROCESSOR_FEATURE_MAX]; + ULONG Reserved1; + ULONG Reserved3; + volatile ULONG TimeSlip; + ALTERNATIVE_ARCHITECTURE_TYPE AlternativeArchitecture; + ULONG AltArchitecturePad[1]; + LARGE_INTEGER SystemExpirationDate; + ULONG SuiteMask; + BOOLEAN KdDebuggerEnabled; +#if (NTDDI_VERSION >= NTDDI_WINXPSP2) + UCHAR NXSupportPolicy; +#endif + volatile ULONG ActiveConsoleId; + volatile ULONG DismountCount; + ULONG ComPlusPackage; + ULONG LastSystemRITEventTickCount; + ULONG NumberOfPhysicalPages; + BOOLEAN SafeBootMode; +#if (NTDDI_VERSION >= NTDDI_WIN7) + union { + UCHAR TscQpcData; + struct { + UCHAR TscQpcEnabled:1; + UCHAR TscQpcSpareFlag:1; + UCHAR TscQpcShift:6; + } DUMMYSTRUCTNAME; + } DUMMYUNIONNAME; + UCHAR TscQpcPad[2]; +#endif +#if (NTDDI_VERSION >= NTDDI_VISTA) + union { + ULONG SharedDataFlags; + struct { + ULONG DbgErrorPortPresent:1; + ULONG DbgElevationEnabled:1; + ULONG DbgVirtEnabled:1; + ULONG DbgInstallerDetectEnabled:1; + ULONG DbgSystemDllRelocated:1; + ULONG DbgDynProcessorEnabled:1; + ULONG DbgSEHValidationEnabled:1; + ULONG SpareBits:25; + } DUMMYSTRUCTNAME2; + } DUMMYUNIONNAME2; +#else + ULONG TraceLogging; +#endif + ULONG DataFlagsPad[1]; + ULONGLONG TestRetInstruction; + ULONG SystemCall; + ULONG SystemCallReturn; + ULONGLONG SystemCallPad[3]; + _ANONYMOUS_UNION union { + volatile KSYSTEM_TIME TickCount; + volatile ULONG64 TickCountQuad; + _ANONYMOUS_STRUCT struct { + ULONG ReservedTickCountOverlay[3]; + ULONG TickCountPad[1]; + } DUMMYSTRUCTNAME; + } DUMMYUNIONNAME3; + ULONG Cookie; + ULONG CookiePad[1]; +#if (NTDDI_VERSION >= NTDDI_WS03) + LONGLONG ConsoleSessionForegroundProcessId; + ULONG Wow64SharedInformation[MAX_WOW64_SHARED_ENTRIES]; +#endif +#if (NTDDI_VERSION >= NTDDI_VISTA) +#if (NTDDI_VERSION >= NTDDI_WIN7) + USHORT UserModeGlobalLogger[16]; +#else + USHORT UserModeGlobalLogger[8]; + ULONG HeapTracingPid[2]; + ULONG CritSecTracingPid[2]; +#endif + ULONG ImageFileExecutionOptions; +#if (NTDDI_VERSION >= NTDDI_VISTASP1) + ULONG LangGenerationCount; +#else + /* 4 bytes padding */ +#endif + ULONGLONG Reserved5; + volatile ULONG64 InterruptTimeBias; +#endif +#if (NTDDI_VERSION >= NTDDI_WIN7) + volatile ULONG64 TscQpcBias; + volatile ULONG ActiveProcessorCount; + volatile USHORT ActiveGroupCount; + USHORT Reserved4; + volatile ULONG AitSamplingValue; + volatile ULONG AppCompatFlag; + ULONGLONG SystemDllNativeRelocation; + ULONG SystemDllWowRelocation; + ULONG XStatePad[1]; + XSTATE_CONFIGURATION XState; +#endif +} KUSER_SHARED_DATA, *PKUSER_SHARED_DATA; + +#if (NTDDI_VERSION >= NTDDI_VISTA) +extern NTSYSAPI volatile CCHAR KeNumberProcessors; +#elif (NTDDI_VERSION >= NTDDI_WINXP) +extern NTSYSAPI CCHAR KeNumberProcessors; +#else +extern PCCHAR KeNumberProcessors; +#endif + + +/****************************************************************************** + * Kernel Debugger Types * + ******************************************************************************/ +typedef struct _DEBUG_DEVICE_ADDRESS { + UCHAR Type; + BOOLEAN Valid; + UCHAR Reserved[2]; + PUCHAR TranslatedAddress; + ULONG Length; +} DEBUG_DEVICE_ADDRESS, *PDEBUG_DEVICE_ADDRESS; + +typedef struct _DEBUG_MEMORY_REQUIREMENTS { + PHYSICAL_ADDRESS Start; + PHYSICAL_ADDRESS MaxEnd; + PVOID VirtualAddress; + ULONG Length; + BOOLEAN Cached; + BOOLEAN Aligned; +} DEBUG_MEMORY_REQUIREMENTS, *PDEBUG_MEMORY_REQUIREMENTS; + +typedef struct _DEBUG_DEVICE_DESCRIPTOR { + ULONG Bus; + ULONG Slot; + USHORT Segment; + USHORT VendorID; + USHORT DeviceID; + UCHAR BaseClass; + UCHAR SubClass; + UCHAR ProgIf; + BOOLEAN Initialized; + BOOLEAN Configured; + DEBUG_DEVICE_ADDRESS BaseAddress[6]; + DEBUG_MEMORY_REQUIREMENTS Memory; +} DEBUG_DEVICE_DESCRIPTOR, *PDEBUG_DEVICE_DESCRIPTOR; + +typedef NTSTATUS +(NTAPI *pKdSetupPciDeviceForDebugging)( + IN PVOID LoaderBlock OPTIONAL, + IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice); + +typedef NTSTATUS +(NTAPI *pKdReleasePciDeviceForDebugging)( + IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice); + +typedef PVOID +(NTAPI *pKdGetAcpiTablePhase0)( + IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock, + IN ULONG Signature); + +typedef VOID +(NTAPI *pKdCheckPowerButton)( + VOID); + +#if (NTDDI_VERSION >= NTDDI_VISTA) +typedef PVOID +(NTAPI *pKdMapPhysicalMemory64)( + IN PHYSICAL_ADDRESS PhysicalAddress, + IN ULONG NumberPages, + IN BOOLEAN FlushCurrentTLB); + +typedef VOID +(NTAPI *pKdUnmapVirtualAddress)( + IN PVOID VirtualAddress, + IN ULONG NumberPages, + IN BOOLEAN FlushCurrentTLB); +#else +typedef PVOID +(NTAPI *pKdMapPhysicalMemory64)( + IN PHYSICAL_ADDRESS PhysicalAddress, + IN ULONG NumberPages); + +typedef VOID +(NTAPI *pKdUnmapVirtualAddress)( + IN PVOID VirtualAddress, + IN ULONG NumberPages); +#endif + +typedef ULONG +(NTAPI *pKdGetPciDataByOffset)( + IN ULONG BusNumber, + IN ULONG SlotNumber, + OUT PVOID Buffer, + IN ULONG Offset, + IN ULONG Length); + +typedef ULONG +(NTAPI *pKdSetPciDataByOffset)( + IN ULONG BusNumber, + IN ULONG SlotNumber, + IN PVOID Buffer, + IN ULONG Offset, + IN ULONG Length); +/****************************************************************************** + * Memory manager Types * + ******************************************************************************/ + +typedef struct _PHYSICAL_MEMORY_RANGE { + PHYSICAL_ADDRESS BaseAddress; + LARGE_INTEGER NumberOfBytes; +} PHYSICAL_MEMORY_RANGE, *PPHYSICAL_MEMORY_RANGE; + +typedef NTSTATUS +(NTAPI *PMM_ROTATE_COPY_CALLBACK_FUNCTION)( + IN PMDL DestinationMdl, + IN PMDL SourceMdl, + IN PVOID Context); + +typedef enum _MM_ROTATE_DIRECTION { + MmToFrameBuffer, + MmToFrameBufferNoCopy, + MmToRegularMemory, + MmToRegularMemoryNoCopy, + MmMaximumRotateDirection +} MM_ROTATE_DIRECTION, *PMM_ROTATE_DIRECTION; + + +/****************************************************************************** + * Process Manager Types * + ******************************************************************************/ + +#define QUOTA_LIMITS_HARDWS_MIN_ENABLE 0x00000001 +#define QUOTA_LIMITS_HARDWS_MIN_DISABLE 0x00000002 +#define QUOTA_LIMITS_HARDWS_MAX_ENABLE 0x00000004 +#define QUOTA_LIMITS_HARDWS_MAX_DISABLE 0x00000008 +#define QUOTA_LIMITS_USE_DEFAULT_LIMITS 0x00000010 + +typedef struct _QUOTA_LIMITS { + SIZE_T PagedPoolLimit; + SIZE_T NonPagedPoolLimit; + SIZE_T MinimumWorkingSetSize; + SIZE_T MaximumWorkingSetSize; + SIZE_T PagefileLimit; + LARGE_INTEGER TimeLimit; +} QUOTA_LIMITS, *PQUOTA_LIMITS; + +typedef union _RATE_QUOTA_LIMIT { + ULONG RateData; + struct { + ULONG RatePercent:7; + ULONG Reserved0:25; + } DUMMYSTRUCTNAME; +} RATE_QUOTA_LIMIT, *PRATE_QUOTA_LIMIT; + +typedef struct _QUOTA_LIMITS_EX { + SIZE_T PagedPoolLimit; + SIZE_T NonPagedPoolLimit; + SIZE_T MinimumWorkingSetSize; + SIZE_T MaximumWorkingSetSize; + SIZE_T PagefileLimit; + LARGE_INTEGER TimeLimit; + SIZE_T WorkingSetLimit; + SIZE_T Reserved2; + SIZE_T Reserved3; + SIZE_T Reserved4; + ULONG Flags; + RATE_QUOTA_LIMIT CpuRateLimit; +} QUOTA_LIMITS_EX, *PQUOTA_LIMITS_EX; + +typedef struct _IO_COUNTERS { + ULONGLONG ReadOperationCount; + ULONGLONG WriteOperationCount; + ULONGLONG OtherOperationCount; + ULONGLONG ReadTransferCount; + ULONGLONG WriteTransferCount; + ULONGLONG OtherTransferCount; +} IO_COUNTERS, *PIO_COUNTERS; + +typedef struct _VM_COUNTERS { + SIZE_T PeakVirtualSize; + SIZE_T VirtualSize; + ULONG PageFaultCount; + SIZE_T PeakWorkingSetSize; + SIZE_T WorkingSetSize; + SIZE_T QuotaPeakPagedPoolUsage; + SIZE_T QuotaPagedPoolUsage; + SIZE_T QuotaPeakNonPagedPoolUsage; + SIZE_T QuotaNonPagedPoolUsage; + SIZE_T PagefileUsage; + SIZE_T PeakPagefileUsage; +} VM_COUNTERS, *PVM_COUNTERS; + +typedef struct _VM_COUNTERS_EX { + SIZE_T PeakVirtualSize; + SIZE_T VirtualSize; + ULONG PageFaultCount; + SIZE_T PeakWorkingSetSize; + SIZE_T WorkingSetSize; + SIZE_T QuotaPeakPagedPoolUsage; + SIZE_T QuotaPagedPoolUsage; + SIZE_T QuotaPeakNonPagedPoolUsage; + SIZE_T QuotaNonPagedPoolUsage; + SIZE_T PagefileUsage; + SIZE_T PeakPagefileUsage; + SIZE_T PrivateUsage; +} VM_COUNTERS_EX, *PVM_COUNTERS_EX; + +#define MAX_HW_COUNTERS 16 +#define THREAD_PROFILING_FLAG_DISPATCH 0x00000001 + +typedef enum _HARDWARE_COUNTER_TYPE { + PMCCounter, + MaxHardwareCounterType +} HARDWARE_COUNTER_TYPE, *PHARDWARE_COUNTER_TYPE; + +typedef struct _HARDWARE_COUNTER { + HARDWARE_COUNTER_TYPE Type; + ULONG Reserved; + ULONG64 Index; +} HARDWARE_COUNTER, *PHARDWARE_COUNTER; + +typedef struct _POOLED_USAGE_AND_LIMITS { + SIZE_T PeakPagedPoolUsage; + SIZE_T PagedPoolUsage; + SIZE_T PagedPoolLimit; + SIZE_T PeakNonPagedPoolUsage; + SIZE_T NonPagedPoolUsage; + SIZE_T NonPagedPoolLimit; + SIZE_T PeakPagefileUsage; + SIZE_T PagefileUsage; + SIZE_T PagefileLimit; +} POOLED_USAGE_AND_LIMITS, *PPOOLED_USAGE_AND_LIMITS; + +typedef struct _PROCESS_ACCESS_TOKEN { + HANDLE Token; + HANDLE Thread; +} PROCESS_ACCESS_TOKEN, *PPROCESS_ACCESS_TOKEN; + +#define PROCESS_EXCEPTION_PORT_ALL_STATE_BITS 0x00000003UL +#define PROCESS_EXCEPTION_PORT_ALL_STATE_FLAGS ((ULONG_PTR)((1UL << PROCESS_EXCEPTION_PORT_ALL_STATE_BITS) - 1)) + +typedef struct _PROCESS_EXCEPTION_PORT { + IN HANDLE ExceptionPortHandle; + IN OUT ULONG StateFlags; +} PROCESS_EXCEPTION_PORT, *PPROCESS_EXCEPTION_PORT; + +typedef VOID +(NTAPI *PCREATE_PROCESS_NOTIFY_ROUTINE)( + IN HANDLE ParentId, + IN HANDLE ProcessId, + IN BOOLEAN Create); + +typedef struct _PS_CREATE_NOTIFY_INFO { + IN SIZE_T Size; + union { + IN ULONG Flags; + struct { + IN ULONG FileOpenNameAvailable:1; + IN ULONG Reserved:31; + }; + }; + IN HANDLE ParentProcessId; + IN CLIENT_ID CreatingThreadId; + IN OUT struct _FILE_OBJECT *FileObject; + IN PCUNICODE_STRING ImageFileName; + IN PCUNICODE_STRING CommandLine OPTIONAL; + IN OUT NTSTATUS CreationStatus; +} PS_CREATE_NOTIFY_INFO, *PPS_CREATE_NOTIFY_INFO; + +typedef VOID +(NTAPI *PCREATE_PROCESS_NOTIFY_ROUTINE_EX)( + IN OUT PEPROCESS Process, + IN HANDLE ProcessId, + IN PPS_CREATE_NOTIFY_INFO CreateInfo OPTIONAL); + +typedef VOID +(NTAPI *PCREATE_THREAD_NOTIFY_ROUTINE)( + IN HANDLE ProcessId, + IN HANDLE ThreadId, + IN BOOLEAN Create); + +#define IMAGE_ADDRESSING_MODE_32BIT 3 typedef struct _IMAGE_INFO { _ANONYMOUS_UNION union { @@ -832,7 +2258,7 @@ typedef struct _IMAGE_INFO { ULONG SystemModeImage:1; ULONG ImageMappedToAllPids:1; ULONG ExtendedInfoPresent:1; - ULONG Reserved:22; + ULONG Reserved:21; } DUMMYSTRUCTNAME; } DUMMYUNIONNAME; PVOID ImageBase; @@ -841,24 +2267,24 @@ typedef struct _IMAGE_INFO { ULONG ImageSectionNumber; } IMAGE_INFO, *PIMAGE_INFO; -#define IMAGE_ADDRESSING_MODE_32BIT 3 +typedef struct _IMAGE_INFO_EX { + SIZE_T Size; + IMAGE_INFO ImageInfo; + struct _FILE_OBJECT *FileObject; +} IMAGE_INFO_EX, *PIMAGE_INFO_EX; -typedef enum _BUS_DATA_TYPE { - ConfigurationSpaceUndefined = -1, - Cmos, - EisaConfiguration, - Pos, - CbusConfiguration, - PCIConfiguration, - VMEConfiguration, - NuBusConfiguration, - PCMCIAConfiguration, - MPIConfiguration, - MPSAConfiguration, - PNPISAConfiguration, - SgiInternalConfiguration, - MaximumBusDataType -} BUS_DATA_TYPE, *PBUS_DATA_TYPE; +typedef VOID +(NTAPI *PLOAD_IMAGE_NOTIFY_ROUTINE)( + IN PUNICODE_STRING FullImageName, + IN HANDLE ProcessId, + IN PIMAGE_INFO ImageInfo); + +#define THREAD_CSWITCH_PMU_DISABLE FALSE +#define THREAD_CSWITCH_PMU_ENABLE TRUE + +#define PROCESS_LUID_DOSDEVICES_ONLY 0x00000001 + +#define PROCESS_HANDLE_TRACING_MAX_STACKS 16 typedef struct _NT_TIB { struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList; @@ -992,6 +2418,15 @@ typedef enum _THREADINFOCLASS { MaxThreadInfoClass } THREADINFOCLASS; +typedef struct _PAGE_PRIORITY_INFORMATION { + ULONG PagePriority; +} PAGE_PRIORITY_INFORMATION, *PPAGE_PRIORITY_INFORMATION; + +typedef struct _PROCESS_WS_WATCH_INFORMATION { + PVOID FaultingPc; + PVOID FaultingVa; +} PROCESS_WS_WATCH_INFORMATION, *PPROCESS_WS_WATCH_INFORMATION; + typedef struct _PROCESS_BASIC_INFORMATION { NTSTATUS ExitStatus; struct _PEB *PebBaseAddress; @@ -1001,10 +2436,20 @@ typedef struct _PROCESS_BASIC_INFORMATION { ULONG_PTR InheritedFromUniqueProcessId; } PROCESS_BASIC_INFORMATION,*PPROCESS_BASIC_INFORMATION; -typedef struct _PROCESS_WS_WATCH_INFORMATION { - PVOID FaultingPc; - PVOID FaultingVa; -} PROCESS_WS_WATCH_INFORMATION, *PPROCESS_WS_WATCH_INFORMATION; +typedef struct _PROCESS_EXTENDED_BASIC_INFORMATION { + SIZE_T Size; + PROCESS_BASIC_INFORMATION BasicInfo; + union { + ULONG Flags; + struct { + ULONG IsProtectedProcess:1; + ULONG IsWow64Process:1; + ULONG IsProcessDeleting:1; + ULONG IsCrossSessionCreate:1; + ULONG SpareBits:28; + } DUMMYSTRUCTNAME; + } DUMMYUNIONNAME; +} PROCESS_EXTENDED_BASIC_INFORMATION, *PPROCESS_EXTENDED_BASIC_INFORMATION; typedef struct _PROCESS_DEVICEMAP_INFORMATION { __GNU_EXTENSION union { @@ -1018,514 +2463,263 @@ typedef struct _PROCESS_DEVICEMAP_INFORMATION { }; } PROCESS_DEVICEMAP_INFORMATION, *PPROCESS_DEVICEMAP_INFORMATION; -typedef struct _KERNEL_USER_TIMES { - LARGE_INTEGER CreateTime; - LARGE_INTEGER ExitTime; - LARGE_INTEGER KernelTime; - LARGE_INTEGER UserTime; -} KERNEL_USER_TIMES, *PKERNEL_USER_TIMES; - -typedef struct _PROCESS_ACCESS_TOKEN { - HANDLE Token; - HANDLE Thread; -} PROCESS_ACCESS_TOKEN, *PPROCESS_ACCESS_TOKEN; +typedef struct _PROCESS_DEVICEMAP_INFORMATION_EX { + union { + struct { + HANDLE DirectoryHandle; + } Set; + struct { + ULONG DriveMap; + UCHAR DriveType[32]; + } Query; + } DUMMYUNIONNAME; + ULONG Flags; +} PROCESS_DEVICEMAP_INFORMATION_EX, *PPROCESS_DEVICEMAP_INFORMATION_EX; typedef struct _PROCESS_SESSION_INFORMATION { ULONG SessionId; } PROCESS_SESSION_INFORMATION, *PPROCESS_SESSION_INFORMATION; -typedef enum _IO_QUERY_DEVICE_DATA_FORMAT { - IoQueryDeviceIdentifier = 0, - IoQueryDeviceConfigurationData, - IoQueryDeviceComponentInformation, - IoQueryDeviceMaxData -} IO_QUERY_DEVICE_DATA_FORMAT, *PIO_QUERY_DEVICE_DATA_FORMAT; +typedef struct _PROCESS_HANDLE_TRACING_ENABLE { + ULONG Flags; +} PROCESS_HANDLE_TRACING_ENABLE, *PPROCESS_HANDLE_TRACING_ENABLE; -typedef struct _DISK_SIGNATURE { - ULONG PartitionStyle; - _ANONYMOUS_UNION union { - struct { - ULONG Signature; - ULONG CheckSum; - } Mbr; - struct { - GUID DiskId; - } Gpt; - } DUMMYUNIONNAME; -} DISK_SIGNATURE, *PDISK_SIGNATURE; +typedef struct _PROCESS_HANDLE_TRACING_ENABLE_EX { + ULONG Flags; + ULONG TotalSlots; +} PROCESS_HANDLE_TRACING_ENABLE_EX, *PPROCESS_HANDLE_TRACING_ENABLE_EX; -typedef ULONG_PTR -(NTAPI *PDRIVER_VERIFIER_THUNK_ROUTINE)( - IN PVOID Context); +typedef struct _PROCESS_HANDLE_TRACING_ENTRY { + HANDLE Handle; + CLIENT_ID ClientId; + ULONG Type; + PVOID Stacks[PROCESS_HANDLE_TRACING_MAX_STACKS]; +} PROCESS_HANDLE_TRACING_ENTRY, *PPROCESS_HANDLE_TRACING_ENTRY; -typedef struct _DRIVER_VERIFIER_THUNK_PAIRS { - PDRIVER_VERIFIER_THUNK_ROUTINE PristineRoutine; - PDRIVER_VERIFIER_THUNK_ROUTINE NewRoutine; -} DRIVER_VERIFIER_THUNK_PAIRS, *PDRIVER_VERIFIER_THUNK_PAIRS; +typedef struct _PROCESS_HANDLE_TRACING_QUERY { + HANDLE Handle; + ULONG TotalTraces; + PROCESS_HANDLE_TRACING_ENTRY HandleTrace[1]; +} PROCESS_HANDLE_TRACING_QUERY, *PPROCESS_HANDLE_TRACING_QUERY; -#define DRIVER_VERIFIER_SPECIAL_POOLING 0x0001 -#define DRIVER_VERIFIER_FORCE_IRQL_CHECKING 0x0002 -#define DRIVER_VERIFIER_INJECT_ALLOCATION_FAILURES 0x0004 -#define DRIVER_VERIFIER_TRACK_POOL_ALLOCATIONS 0x0008 -#define DRIVER_VERIFIER_IO_CHECKING 0x0010 +extern NTKERNELAPI PEPROCESS PsInitialSystemProcess; + + +/****************************************************************************** + * Runtime Library Types * + ******************************************************************************/ + + + +#ifndef _RTL_RUN_ONCE_DEF +#define _RTL_RUN_ONCE_DEF + +#define RTL_RUN_ONCE_INIT {0} + +#define RTL_RUN_ONCE_CHECK_ONLY 0x00000001UL +#define RTL_RUN_ONCE_ASYNC 0x00000002UL +#define RTL_RUN_ONCE_INIT_FAILED 0x00000004UL + +#define RTL_RUN_ONCE_CTX_RESERVED_BITS 2 + +#define RTL_HASH_ALLOCATED_HEADER 0x00000001 + +#define RTL_HASH_RESERVED_SIGNATURE 0 + +/* RtlVerifyVersionInfo() ComparisonType */ + +#define VER_EQUAL 1 +#define VER_GREATER 2 +#define VER_GREATER_EQUAL 3 +#define VER_LESS 4 +#define VER_LESS_EQUAL 5 +#define VER_AND 6 +#define VER_OR 7 + +#define VER_CONDITION_MASK 7 +#define VER_NUM_BITS_PER_CONDITION_MASK 3 + +/* RtlVerifyVersionInfo() TypeMask */ + +#define VER_MINORVERSION 0x0000001 +#define VER_MAJORVERSION 0x0000002 +#define VER_BUILDNUMBER 0x0000004 +#define VER_PLATFORMID 0x0000008 +#define VER_SERVICEPACKMINOR 0x0000010 +#define VER_SERVICEPACKMAJOR 0x0000020 +#define VER_SUITENAME 0x0000040 +#define VER_PRODUCT_TYPE 0x0000080 + +#define VER_NT_WORKSTATION 0x0000001 +#define VER_NT_DOMAIN_CONTROLLER 0x0000002 +#define VER_NT_SERVER 0x0000003 + +#define VER_PLATFORM_WIN32s 0 +#define VER_PLATFORM_WIN32_WINDOWS 1 +#define VER_PLATFORM_WIN32_NT 2 + +typedef union _RTL_RUN_ONCE { + PVOID Ptr; +} RTL_RUN_ONCE, *PRTL_RUN_ONCE; + +typedef ULONG /* LOGICAL */ +(NTAPI *PRTL_RUN_ONCE_INIT_FN) ( + IN OUT PRTL_RUN_ONCE RunOnce, + IN OUT PVOID Parameter OPTIONAL, + IN OUT PVOID *Context OPTIONAL); + +#endif /* _RTL_RUN_ONCE_DEF */ + +typedef enum _TABLE_SEARCH_RESULT { + TableEmptyTree, + TableFoundNode, + TableInsertAsLeft, + TableInsertAsRight +} TABLE_SEARCH_RESULT; + +typedef enum _RTL_GENERIC_COMPARE_RESULTS { + GenericLessThan, + GenericGreaterThan, + GenericEqual +} RTL_GENERIC_COMPARE_RESULTS; + +// Forwarder +struct _RTL_AVL_TABLE; + +typedef RTL_GENERIC_COMPARE_RESULTS +(NTAPI *PRTL_AVL_COMPARE_ROUTINE) ( + IN struct _RTL_AVL_TABLE *Table, + IN PVOID FirstStruct, + IN PVOID SecondStruct); + +typedef PVOID +(NTAPI *PRTL_AVL_ALLOCATE_ROUTINE) ( + IN struct _RTL_AVL_TABLE *Table, + IN CLONG ByteSize); typedef VOID -(NTAPI *PTIMER_APC_ROUTINE)( - IN PVOID TimerContext, - IN ULONG TimerLowValue, - IN LONG TimerHighValue); +(NTAPI *PRTL_AVL_FREE_ROUTINE) ( + IN struct _RTL_AVL_TABLE *Table, + IN PVOID Buffer); -typedef struct _KUSER_SHARED_DATA -{ - ULONG TickCountLowDeprecated; - ULONG TickCountMultiplier; - volatile KSYSTEM_TIME InterruptTime; - volatile KSYSTEM_TIME SystemTime; - volatile KSYSTEM_TIME TimeZoneBias; - USHORT ImageNumberLow; - USHORT ImageNumberHigh; - WCHAR NtSystemRoot[260]; - ULONG MaxStackTraceDepth; - ULONG CryptoExponent; - ULONG TimeZoneId; - ULONG LargePageMinimum; - ULONG Reserved2[7]; - NT_PRODUCT_TYPE NtProductType; - BOOLEAN ProductTypeIsValid; - ULONG NtMajorVersion; - ULONG NtMinorVersion; - BOOLEAN ProcessorFeatures[PROCESSOR_FEATURE_MAX]; - ULONG Reserved1; - ULONG Reserved3; - volatile ULONG TimeSlip; - ALTERNATIVE_ARCHITECTURE_TYPE AlternativeArchitecture; - ULONG AltArchitecturePad[1]; - LARGE_INTEGER SystemExpirationDate; - ULONG SuiteMask; - BOOLEAN KdDebuggerEnabled; -#if (NTDDI_VERSION >= NTDDI_WINXPSP2) - UCHAR NXSupportPolicy; -#endif - volatile ULONG ActiveConsoleId; - volatile ULONG DismountCount; - ULONG ComPlusPackage; - ULONG LastSystemRITEventTickCount; - ULONG NumberOfPhysicalPages; - BOOLEAN SafeBootMode; -#if (NTDDI_VERSION >= NTDDI_WIN7) - union { - UCHAR TscQpcData; - struct { - UCHAR TscQpcEnabled:1; - UCHAR TscQpcSpareFlag:1; - UCHAR TscQpcShift:6; - } DUMMYSTRUCTNAME; - } DUMMYUNIONNAME; - UCHAR TscQpcPad[2]; -#endif -#if (NTDDI_VERSION >= NTDDI_VISTA) - union { - ULONG SharedDataFlags; - struct { - ULONG DbgErrorPortPresent:1; - ULONG DbgElevationEnabled:1; - ULONG DbgVirtEnabled:1; - ULONG DbgInstallerDetectEnabled:1; - ULONG DbgSystemDllRelocated:1; - ULONG DbgDynProcessorEnabled:1; - ULONG DbgSEHValidationEnabled:1; - ULONG SpareBits:25; - } DUMMYSTRUCTNAME2; - } DUMMYUNIONNAME2; -#else - ULONG TraceLogging; -#endif - ULONG DataFlagsPad[1]; - ULONGLONG TestRetInstruction; - ULONG SystemCall; - ULONG SystemCallReturn; - ULONGLONG SystemCallPad[3]; - _ANONYMOUS_UNION union { - volatile KSYSTEM_TIME TickCount; - volatile ULONG64 TickCountQuad; - _ANONYMOUS_STRUCT struct { - ULONG ReservedTickCountOverlay[3]; - ULONG TickCountPad[1]; - } DUMMYSTRUCTNAME; - } DUMMYUNIONNAME3; - ULONG Cookie; - ULONG CookiePad[1]; -#if (NTDDI_VERSION >= NTDDI_WS03) - LONGLONG ConsoleSessionForegroundProcessId; - ULONG Wow64SharedInformation[MAX_WOW64_SHARED_ENTRIES]; -#endif -#if (NTDDI_VERSION >= NTDDI_VISTA) -#if (NTDDI_VERSION >= NTDDI_WIN7) - USHORT UserModeGlobalLogger[16]; -#else - USHORT UserModeGlobalLogger[8]; - ULONG HeapTracingPid[2]; - ULONG CritSecTracingPid[2]; -#endif - ULONG ImageFileExecutionOptions; -#if (NTDDI_VERSION >= NTDDI_VISTASP1) - ULONG LangGenerationCount; -#else - /* 4 bytes padding */ -#endif - ULONGLONG Reserved5; - volatile ULONG64 InterruptTimeBias; -#endif -#if (NTDDI_VERSION >= NTDDI_WIN7) - volatile ULONG64 TscQpcBias; - volatile ULONG ActiveProcessorCount; - volatile USHORT ActiveGroupCount; - USHORT Reserved4; - volatile ULONG AitSamplingValue; - volatile ULONG AppCompatFlag; - ULONGLONG SystemDllNativeRelocation; - ULONG SystemDllWowRelocation; - ULONG XStatePad[1]; - XSTATE_CONFIGURATION XState; -#endif -} KUSER_SHARED_DATA, *PKUSER_SHARED_DATA; +typedef NTSTATUS +(NTAPI *PRTL_AVL_MATCH_FUNCTION) ( + IN struct _RTL_AVL_TABLE *Table, + IN PVOID UserData, + IN PVOID MatchData); -extern NTKERNELAPI PVOID MmHighestUserAddress; -extern NTKERNELAPI PVOID MmSystemRangeStart; -extern NTKERNELAPI ULONG MmUserProbeAddress; +typedef struct _RTL_BALANCED_LINKS { + struct _RTL_BALANCED_LINKS *Parent; + struct _RTL_BALANCED_LINKS *LeftChild; + struct _RTL_BALANCED_LINKS *RightChild; + CHAR Balance; + UCHAR Reserved[3]; +} RTL_BALANCED_LINKS, *PRTL_BALANCED_LINKS; +typedef struct _RTL_AVL_TABLE { + RTL_BALANCED_LINKS BalancedRoot; + PVOID OrderedPointer; + ULONG WhichOrderedElement; + ULONG NumberGenericTableElements; + ULONG DepthOfTree; + PRTL_BALANCED_LINKS RestartKey; + ULONG DeleteCount; + PRTL_AVL_COMPARE_ROUTINE CompareRoutine; + PRTL_AVL_ALLOCATE_ROUTINE AllocateRoutine; + PRTL_AVL_FREE_ROUTINE FreeRoutine; + PVOID TableContext; +} RTL_AVL_TABLE, *PRTL_AVL_TABLE; -#ifdef _X86_ +#ifndef RTL_USE_AVL_TABLES -#define MM_HIGHEST_USER_ADDRESS MmHighestUserAddress -#define MM_SYSTEM_RANGE_START MmSystemRangeStart -#if defined(_LOCAL_COPY_USER_PROBE_ADDRESS_) -#define MM_USER_PROBE_ADDRESS _LOCAL_COPY_USER_PROBE_ADDRESS_ -extern ULONG _LOCAL_COPY_USER_PROBE_ADDRESS_; -#else -#define MM_USER_PROBE_ADDRESS MmUserProbeAddress -#endif -#define MM_LOWEST_USER_ADDRESS (PVOID)0x10000 -#define MM_KSEG0_BASE MM_SYSTEM_RANGE_START -#define MM_SYSTEM_SPACE_END 0xFFFFFFFF -#if !defined (_X86PAE_) -#define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xC0800000 -#else -#define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xC0C00000 -#endif +struct _RTL_GENERIC_TABLE; -#define KeGetPcr() PCR +typedef RTL_GENERIC_COMPARE_RESULTS +(NTAPI *PRTL_GENERIC_COMPARE_ROUTINE) ( + IN struct _RTL_GENERIC_TABLE *Table, + IN PVOID FirstStruct, + IN PVOID SecondStruct); -#define KERNEL_STACK_SIZE 12288 -#define KERNEL_LARGE_STACK_SIZE 61440 -#define KERNEL_LARGE_STACK_COMMIT 12288 +typedef PVOID +(NTAPI *PRTL_GENERIC_ALLOCATE_ROUTINE) ( + IN struct _RTL_GENERIC_TABLE *Table, + IN CLONG ByteSize); -#define SIZE_OF_80387_REGISTERS 80 +typedef VOID +(NTAPI *PRTL_GENERIC_FREE_ROUTINE) ( + IN struct _RTL_GENERIC_TABLE *Table, + IN PVOID Buffer); -#define PCR_MINOR_VERSION 1 -#define PCR_MAJOR_VERSION 1 +typedef struct _RTL_SPLAY_LINKS { + struct _RTL_SPLAY_LINKS *Parent; + struct _RTL_SPLAY_LINKS *LeftChild; + struct _RTL_SPLAY_LINKS *RightChild; +} RTL_SPLAY_LINKS, *PRTL_SPLAY_LINKS; -#if !defined(RC_INVOKED) +typedef struct _RTL_GENERIC_TABLE { + PRTL_SPLAY_LINKS TableRoot; + LIST_ENTRY InsertOrderList; + PLIST_ENTRY OrderedPointer; + ULONG WhichOrderedElement; + ULONG NumberGenericTableElements; + PRTL_GENERIC_COMPARE_ROUTINE CompareRoutine; + PRTL_GENERIC_ALLOCATE_ROUTINE AllocateRoutine; + PRTL_GENERIC_FREE_ROUTINE FreeRoutine; + PVOID TableContext; +} RTL_GENERIC_TABLE, *PRTL_GENERIC_TABLE; -#define CONTEXT_i386 0x10000 -#define CONTEXT_i486 0x10000 -#define CONTEXT_CONTROL (CONTEXT_i386|0x00000001L) -#define CONTEXT_INTEGER (CONTEXT_i386|0x00000002L) -#define CONTEXT_SEGMENTS (CONTEXT_i386|0x00000004L) -#define CONTEXT_FLOATING_POINT (CONTEXT_i386|0x00000008L) -#define CONTEXT_DEBUG_REGISTERS (CONTEXT_i386|0x00000010L) -#define CONTEXT_EXTENDED_REGISTERS (CONTEXT_i386|0x00000020L) +#endif /* !RTL_USE_AVL_TABLES */ -#define CONTEXT_FULL (CONTEXT_CONTROL|CONTEXT_INTEGER|CONTEXT_SEGMENTS) +#ifdef RTL_USE_AVL_TABLES -#endif /* !defined(RC_INVOKED) */ +#undef PRTL_GENERIC_COMPARE_ROUTINE +#undef RTL_GENERIC_COMPARE_ROUTINE +#undef PRTL_GENERIC_ALLOCATE_ROUTINE +#undef RTL_GENERIC_ALLOCATE_ROUTINE +#undef PRTL_GENERIC_FREE_ROUTINE +#undef RTL_GENERIC_FREE_ROUTINE +#undef RTL_GENERIC_TABLE +#undef PRTL_GENERIC_TABLE -typedef struct _KPCR { - union { - NT_TIB NtTib; - struct { - struct _EXCEPTION_REGISTRATION_RECORD *Used_ExceptionList; - PVOID Used_StackBase; - PVOID Spare2; - PVOID TssCopy; - ULONG ContextSwitches; - KAFFINITY SetMemberCopy; - PVOID Used_Self; - }; - }; - struct _KPCR *SelfPcr; - struct _KPRCB *Prcb; - KIRQL Irql; - ULONG IRR; - ULONG IrrActive; - ULONG IDR; - PVOID KdVersionBlock; - struct _KIDTENTRY *IDT; - struct _KGDTENTRY *GDT; - struct _KTSS *TSS; - USHORT MajorVersion; - USHORT MinorVersion; - KAFFINITY SetMember; - ULONG StallScaleFactor; - UCHAR SpareUnused; - UCHAR Number; - UCHAR Spare0; - UCHAR SecondLevelCacheAssociativity; - ULONG VdmAlert; - ULONG KernelReserved[14]; - ULONG SecondLevelCacheSize; - ULONG HalReserved[16]; -} KPCR, *PKPCR; +#define PRTL_GENERIC_COMPARE_ROUTINE PRTL_AVL_COMPARE_ROUTINE +#define RTL_GENERIC_COMPARE_ROUTINE RTL_AVL_COMPARE_ROUTINE +#define PRTL_GENERIC_ALLOCATE_ROUTINE PRTL_AVL_ALLOCATE_ROUTINE +#define RTL_GENERIC_ALLOCATE_ROUTINE RTL_AVL_ALLOCATE_ROUTINE +#define PRTL_GENERIC_FREE_ROUTINE PRTL_AVL_FREE_ROUTINE +#define RTL_GENERIC_FREE_ROUTINE RTL_AVL_FREE_ROUTINE +#define RTL_GENERIC_TABLE RTL_AVL_TABLE +#define PRTL_GENERIC_TABLE PRTL_AVL_TABLE -FORCEINLINE -ULONG -KeGetCurrentProcessorNumber(VOID) -{ - return (ULONG)__readfsbyte(FIELD_OFFSET(KPCR, Number)); -} +#endif /* RTL_USE_AVL_TABLES */ -typedef struct _FLOATING_SAVE_AREA { - ULONG ControlWord; - ULONG StatusWord; - ULONG TagWord; - ULONG ErrorOffset; - ULONG ErrorSelector; - ULONG DataOffset; - ULONG DataSelector; - UCHAR RegisterArea[SIZE_OF_80387_REGISTERS]; - ULONG Cr0NpxState; -} FLOATING_SAVE_AREA, *PFLOATING_SAVE_AREA; +typedef struct _RTL_DYNAMIC_HASH_TABLE_ENTRY { + LIST_ENTRY Linkage; + ULONG_PTR Signature; +} RTL_DYNAMIC_HASH_TABLE_ENTRY, *PRTL_DYNAMIC_HASH_TABLE_ENTRY; -#include "pshpack4.h" -typedef struct _CONTEXT { - ULONG ContextFlags; - ULONG Dr0; - ULONG Dr1; - ULONG Dr2; - ULONG Dr3; - ULONG Dr6; - ULONG Dr7; - FLOATING_SAVE_AREA FloatSave; - ULONG SegGs; - ULONG SegFs; - ULONG SegEs; - ULONG SegDs; - ULONG Edi; - ULONG Esi; - ULONG Ebx; - ULONG Edx; - ULONG Ecx; - ULONG Eax; - ULONG Ebp; - ULONG Eip; - ULONG SegCs; - ULONG EFlags; - ULONG Esp; - ULONG SegSs; - UCHAR ExtendedRegisters[MAXIMUM_SUPPORTED_EXTENSION]; -} CONTEXT; -#include "poppack.h" +typedef struct _RTL_DYNAMIC_HASH_TABLE_CONTEXT { + PLIST_ENTRY ChainHead; + PLIST_ENTRY PrevLinkage; + ULONG_PTR Signature; +} RTL_DYNAMIC_HASH_TABLE_CONTEXT, *PRTL_DYNAMIC_HASH_TABLE_CONTEXT; -#endif /* _X86_ */ +typedef struct _RTL_DYNAMIC_HASH_TABLE_ENUMERATOR { + RTL_DYNAMIC_HASH_TABLE_ENTRY HashEntry; + PLIST_ENTRY ChainHead; + ULONG BucketIndex; +} RTL_DYNAMIC_HASH_TABLE_ENUMERATOR, *PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR; -#ifdef _AMD64_ - -#define PTI_SHIFT 12L -#define PDI_SHIFT 21L -#define PPI_SHIFT 30L -#define PXI_SHIFT 39L -#define PTE_PER_PAGE 512 -#define PDE_PER_PAGE 512 -#define PPE_PER_PAGE 512 -#define PXE_PER_PAGE 512 -#define PTI_MASK_AMD64 (PTE_PER_PAGE - 1) -#define PDI_MASK_AMD64 (PDE_PER_PAGE - 1) -#define PPI_MASK (PPE_PER_PAGE - 1) -#define PXI_MASK (PXE_PER_PAGE - 1) - -#define PXE_BASE 0xFFFFF6FB7DBED000ULL -#define PXE_SELFMAP 0xFFFFF6FB7DBEDF68ULL -#define PPE_BASE 0xFFFFF6FB7DA00000ULL -#define PDE_BASE 0xFFFFF6FB40000000ULL -#define PTE_BASE 0xFFFFF68000000000ULL -#define PXE_TOP 0xFFFFF6FB7DBEDFFFULL -#define PPE_TOP 0xFFFFF6FB7DBFFFFFULL -#define PDE_TOP 0xFFFFF6FB7FFFFFFFULL -#define PTE_TOP 0xFFFFF6FFFFFFFFFFULL - -#define MM_HIGHEST_USER_ADDRESS MmHighestUserAddress -#define MM_SYSTEM_RANGE_START MmSystemRangeStart -#define MM_USER_PROBE_ADDRESS MmUserProbeAddress -#define MM_LOWEST_USER_ADDRESS (PVOID)0x10000 -#define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xFFFF080000000000ULL -#define KI_USER_SHARED_DATA 0xFFFFF78000000000ULL - -typedef struct DECLSPEC_ALIGN(16) _CONTEXT { - ULONG64 P1Home; - ULONG64 P2Home; - ULONG64 P3Home; - ULONG64 P4Home; - ULONG64 P5Home; - ULONG64 P6Home; - - /* Control flags */ - ULONG ContextFlags; - ULONG MxCsr; - - /* Segment */ - USHORT SegCs; - USHORT SegDs; - USHORT SegEs; - USHORT SegFs; - USHORT SegGs; - USHORT SegSs; - ULONG EFlags; - - /* Debug */ - ULONG64 Dr0; - ULONG64 Dr1; - ULONG64 Dr2; - ULONG64 Dr3; - ULONG64 Dr6; - ULONG64 Dr7; - - /* Integer */ - ULONG64 Rax; - ULONG64 Rcx; - ULONG64 Rdx; - ULONG64 Rbx; - ULONG64 Rsp; - ULONG64 Rbp; - ULONG64 Rsi; - ULONG64 Rdi; - ULONG64 R8; - ULONG64 R9; - ULONG64 R10; - ULONG64 R11; - ULONG64 R12; - ULONG64 R13; - ULONG64 R14; - ULONG64 R15; - - /* Counter */ - ULONG64 Rip; - - /* Floating point */ - union { - XMM_SAVE_AREA32 FltSave; - struct { - M128A Header[2]; - M128A Legacy[8]; - M128A Xmm0; - M128A Xmm1; - M128A Xmm2; - M128A Xmm3; - M128A Xmm4; - M128A Xmm5; - M128A Xmm6; - M128A Xmm7; - M128A Xmm8; - M128A Xmm9; - M128A Xmm10; - M128A Xmm11; - M128A Xmm12; - M128A Xmm13; - M128A Xmm14; - M128A Xmm15; - } DUMMYSTRUCTNAME; - } DUMMYUNIONNAME; - - /* Vector */ - M128A VectorRegister[26]; - ULONG64 VectorControl; - - /* Debug control */ - ULONG64 DebugControl; - ULONG64 LastBranchToRip; - ULONG64 LastBranchFromRip; - ULONG64 LastExceptionToRip; - ULONG64 LastExceptionFromRip; -} CONTEXT; - -typedef struct _KPCR -{ - _ANONYMOUS_UNION union - { - NT_TIB NtTib; - _ANONYMOUS_STRUCT struct - { - union _KGDTENTRY64 *GdtBase; - struct _KTSS64 *TssBase; - ULONG64 UserRsp; - struct _KPCR *Self; - struct _KPRCB *CurrentPrcb; - PKSPIN_LOCK_QUEUE LockArray; - PVOID Used_Self; - }; - }; - union _KIDTENTRY64 *IdtBase; - ULONG64 Unused[2]; - KIRQL Irql; - UCHAR SecondLevelCacheAssociativity; - UCHAR ObsoleteNumber; - UCHAR Fill0; - ULONG Unused0[3]; - USHORT MajorVersion; - USHORT MinorVersion; - ULONG StallScaleFactor; - PVOID Unused1[3]; - ULONG KernelReserved[15]; - ULONG SecondLevelCacheSize; - ULONG HalReserved[16]; - ULONG Unused2; - PVOID KdVersionBlock; - PVOID Unused3; - ULONG PcrAlign1[24]; -} KPCR, *PKPCR; - -FORCEINLINE -PKPCR -KeGetPcr(VOID) -{ - return (PKPCR)__readgsqword(FIELD_OFFSET(KPCR, Self)); -} - -FORCEINLINE -ULONG -KeGetCurrentProcessorNumber(VOID) -{ - return (ULONG)__readgsword(0x184); -} - -#if !defined(RC_INVOKED) - -#define CONTEXT_AMD64 0x100000 - -#define CONTEXT_CONTROL (CONTEXT_AMD64 | 0x1L) -#define CONTEXT_INTEGER (CONTEXT_AMD64 | 0x2L) -#define CONTEXT_SEGMENTS (CONTEXT_AMD64 | 0x4L) -#define CONTEXT_FLOATING_POINT (CONTEXT_AMD64 | 0x8L) -#define CONTEXT_DEBUG_REGISTERS (CONTEXT_AMD64 | 0x10L) - -#define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT) -#define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS) - -#define CONTEXT_XSTATE (CONTEXT_AMD64 | 0x20L) - -#define CONTEXT_EXCEPTION_ACTIVE 0x8000000 -#define CONTEXT_SERVICE_ACTIVE 0x10000000 -#define CONTEXT_EXCEPTION_REQUEST 0x40000000 -#define CONTEXT_EXCEPTION_REPORTING 0x80000000 - -#endif /* RC_INVOKED */ - -#endif /* _AMD64_ */ - -typedef enum _INTERLOCKED_RESULT { - ResultNegative = RESULT_NEGATIVE, - ResultZero = RESULT_ZERO, - ResultPositive = RESULT_POSITIVE -} INTERLOCKED_RESULT; +typedef struct _RTL_DYNAMIC_HASH_TABLE { + ULONG Flags; + ULONG Shift; + ULONG TableSize; + ULONG Pivot; + ULONG DivisorMask; + ULONG NumEntries; + ULONG NonEmptyBuckets; + ULONG NumEnumerators; + PVOID Directory; +} RTL_DYNAMIC_HASH_TABLE, *PRTL_DYNAMIC_HASH_TABLE; typedef struct _OSVERSIONINFOA { ULONG dwOSVersionInfoSize; @@ -1589,24 +2783,461 @@ typedef POSVERSIONINFOA POSVERSIONINFO; typedef LPOSVERSIONINFOA LPOSVERSIONINFO; #endif /* UNICODE */ -/* Executive Types */ +#define HASH_ENTRY_KEY(x) ((x)->Signature) -#define PROTECTED_POOL 0x80000000 +/****************************************************************************** + * Security Manager Types * + ******************************************************************************/ +#define SE_UNSOLICITED_INPUT_PRIVILEGE 6 -typedef struct _ZONE_SEGMENT_HEADER { - SINGLE_LIST_ENTRY SegmentList; - PVOID Reserved; -} ZONE_SEGMENT_HEADER, *PZONE_SEGMENT_HEADER; +typedef enum _WELL_KNOWN_SID_TYPE { + WinNullSid = 0, + WinWorldSid = 1, + WinLocalSid = 2, + WinCreatorOwnerSid = 3, + WinCreatorGroupSid = 4, + WinCreatorOwnerServerSid = 5, + WinCreatorGroupServerSid = 6, + WinNtAuthoritySid = 7, + WinDialupSid = 8, + WinNetworkSid = 9, + WinBatchSid = 10, + WinInteractiveSid = 11, + WinServiceSid = 12, + WinAnonymousSid = 13, + WinProxySid = 14, + WinEnterpriseControllersSid = 15, + WinSelfSid = 16, + WinAuthenticatedUserSid = 17, + WinRestrictedCodeSid = 18, + WinTerminalServerSid = 19, + WinRemoteLogonIdSid = 20, + WinLogonIdsSid = 21, + WinLocalSystemSid = 22, + WinLocalServiceSid = 23, + WinNetworkServiceSid = 24, + WinBuiltinDomainSid = 25, + WinBuiltinAdministratorsSid = 26, + WinBuiltinUsersSid = 27, + WinBuiltinGuestsSid = 28, + WinBuiltinPowerUsersSid = 29, + WinBuiltinAccountOperatorsSid = 30, + WinBuiltinSystemOperatorsSid = 31, + WinBuiltinPrintOperatorsSid = 32, + WinBuiltinBackupOperatorsSid = 33, + WinBuiltinReplicatorSid = 34, + WinBuiltinPreWindows2000CompatibleAccessSid = 35, + WinBuiltinRemoteDesktopUsersSid = 36, + WinBuiltinNetworkConfigurationOperatorsSid = 37, + WinAccountAdministratorSid = 38, + WinAccountGuestSid = 39, + WinAccountKrbtgtSid = 40, + WinAccountDomainAdminsSid = 41, + WinAccountDomainUsersSid = 42, + WinAccountDomainGuestsSid = 43, + WinAccountComputersSid = 44, + WinAccountControllersSid = 45, + WinAccountCertAdminsSid = 46, + WinAccountSchemaAdminsSid = 47, + WinAccountEnterpriseAdminsSid = 48, + WinAccountPolicyAdminsSid = 49, + WinAccountRasAndIasServersSid = 50, + WinNTLMAuthenticationSid = 51, + WinDigestAuthenticationSid = 52, + WinSChannelAuthenticationSid = 53, + WinThisOrganizationSid = 54, + WinOtherOrganizationSid = 55, + WinBuiltinIncomingForestTrustBuildersSid = 56, + WinBuiltinPerfMonitoringUsersSid = 57, + WinBuiltinPerfLoggingUsersSid = 58, + WinBuiltinAuthorizationAccessSid = 59, + WinBuiltinTerminalServerLicenseServersSid = 60, + WinBuiltinDCOMUsersSid = 61, + WinBuiltinIUsersSid = 62, + WinIUserSid = 63, + WinBuiltinCryptoOperatorsSid = 64, + WinUntrustedLabelSid = 65, + WinLowLabelSid = 66, + WinMediumLabelSid = 67, + WinHighLabelSid = 68, + WinSystemLabelSid = 69, + WinWriteRestrictedCodeSid = 70, + WinCreatorOwnerRightsSid = 71, + WinCacheablePrincipalsGroupSid = 72, + WinNonCacheablePrincipalsGroupSid = 73, + WinEnterpriseReadonlyControllersSid = 74, + WinAccountReadonlyControllersSid = 75, + WinBuiltinEventLogReadersGroup = 76, + WinNewEnterpriseReadonlyControllersSid = 77, + WinBuiltinCertSvcDComAccessGroup = 78, + WinMediumPlusLabelSid = 79, + WinLocalLogonSid = 80, + WinConsoleLogonSid = 81, + WinThisOrganizationCertificateSid = 82, +} WELL_KNOWN_SID_TYPE; -typedef struct _ZONE_HEADER { - SINGLE_LIST_ENTRY FreeList; - SINGLE_LIST_ENTRY SegmentList; - ULONG BlockSize; - ULONG TotalSegmentSize; -} ZONE_HEADER, *PZONE_HEADER; -/* Executive Functions */ +#if defined(_M_IX86) + +#define PAUSE_PROCESSOR YieldProcessor(); + +#define KERNEL_STACK_SIZE 12288 +#define KERNEL_LARGE_STACK_SIZE 61440 +#define KERNEL_LARGE_STACK_COMMIT 12288 + +#define SIZE_OF_80387_REGISTERS 80 + +#if !defined(RC_INVOKED) + +#define CONTEXT_i386 0x10000 +#define CONTEXT_i486 0x10000 +#define CONTEXT_CONTROL (CONTEXT_i386|0x00000001L) +#define CONTEXT_INTEGER (CONTEXT_i386|0x00000002L) +#define CONTEXT_SEGMENTS (CONTEXT_i386|0x00000004L) +#define CONTEXT_FLOATING_POINT (CONTEXT_i386|0x00000008L) +#define CONTEXT_DEBUG_REGISTERS (CONTEXT_i386|0x00000010L) +#define CONTEXT_EXTENDED_REGISTERS (CONTEXT_i386|0x00000020L) + +#define CONTEXT_FULL (CONTEXT_CONTROL|CONTEXT_INTEGER|CONTEXT_SEGMENTS) +#define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | \ + CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS | \ + CONTEXT_EXTENDED_REGISTERS) + +#define CONTEXT_XSTATE (CONTEXT_i386 | 0x00000040L) + +#endif /* !defined(RC_INVOKED) */ + +typedef struct _FLOATING_SAVE_AREA { + ULONG ControlWord; + ULONG StatusWord; + ULONG TagWord; + ULONG ErrorOffset; + ULONG ErrorSelector; + ULONG DataOffset; + ULONG DataSelector; + UCHAR RegisterArea[SIZE_OF_80387_REGISTERS]; + ULONG Cr0NpxState; +} FLOATING_SAVE_AREA, *PFLOATING_SAVE_AREA; + +#include "pshpack4.h" +typedef struct _CONTEXT { + ULONG ContextFlags; + ULONG Dr0; + ULONG Dr1; + ULONG Dr2; + ULONG Dr3; + ULONG Dr6; + ULONG Dr7; + FLOATING_SAVE_AREA FloatSave; + ULONG SegGs; + ULONG SegFs; + ULONG SegEs; + ULONG SegDs; + ULONG Edi; + ULONG Esi; + ULONG Ebx; + ULONG Edx; + ULONG Ecx; + ULONG Eax; + ULONG Ebp; + ULONG Eip; + ULONG SegCs; + ULONG EFlags; + ULONG Esp; + ULONG SegSs; + UCHAR ExtendedRegisters[MAXIMUM_SUPPORTED_EXTENSION]; +} CONTEXT; +#include "poppack.h" + +#define KeGetPcr() PCR + +#define PCR_MINOR_VERSION 1 +#define PCR_MAJOR_VERSION 1 + +typedef struct _KPCR { + union { + NT_TIB NtTib; + struct { + struct _EXCEPTION_REGISTRATION_RECORD *Used_ExceptionList; + PVOID Used_StackBase; + PVOID Spare2; + PVOID TssCopy; + ULONG ContextSwitches; + KAFFINITY SetMemberCopy; + PVOID Used_Self; + }; + }; + struct _KPCR *SelfPcr; + struct _KPRCB *Prcb; + KIRQL Irql; + ULONG IRR; + ULONG IrrActive; + ULONG IDR; + PVOID KdVersionBlock; + struct _KIDTENTRY *IDT; + struct _KGDTENTRY *GDT; + struct _KTSS *TSS; + USHORT MajorVersion; + USHORT MinorVersion; + KAFFINITY SetMember; + ULONG StallScaleFactor; + UCHAR SpareUnused; + UCHAR Number; + UCHAR Spare0; + UCHAR SecondLevelCacheAssociativity; + ULONG VdmAlert; + ULONG KernelReserved[14]; + ULONG SecondLevelCacheSize; + ULONG HalReserved[16]; +} KPCR, *PKPCR; + +FORCEINLINE +ULONG +KeGetCurrentProcessorNumber(VOID) +{ + return (ULONG)__readfsbyte(FIELD_OFFSET(KPCR, Number)); +} + + + + + + +extern NTKERNELAPI PVOID MmHighestUserAddress; +extern NTKERNELAPI PVOID MmSystemRangeStart; +extern NTKERNELAPI ULONG MmUserProbeAddress; + +#define MM_HIGHEST_USER_ADDRESS MmHighestUserAddress +#define MM_SYSTEM_RANGE_START MmSystemRangeStart +#if defined(_LOCAL_COPY_USER_PROBE_ADDRESS_) +#define MM_USER_PROBE_ADDRESS _LOCAL_COPY_USER_PROBE_ADDRESS_ +extern ULONG _LOCAL_COPY_USER_PROBE_ADDRESS_; +#else +#define MM_USER_PROBE_ADDRESS MmUserProbeAddress +#endif +#define MM_LOWEST_USER_ADDRESS (PVOID)0x10000 +#define MM_KSEG0_BASE MM_SYSTEM_RANGE_START +#define MM_SYSTEM_SPACE_END 0xFFFFFFFF +#if !defined (_X86PAE_) +#define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xC0800000 +#else +#define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xC0C00000 +#endif + +#elif defined(_M_AMD64) + +#define PAUSE_PROCESSOR YieldProcessor(); + +#define KERNEL_STACK_SIZE 0x6000 +#define KERNEL_LARGE_STACK_SIZE 0x12000 +#define KERNEL_LARGE_STACK_COMMIT KERNEL_STACK_SIZE + +#define KERNEL_MCA_EXCEPTION_STACK_SIZE 0x2000 + +#define EXCEPTION_READ_FAULT 0 +#define EXCEPTION_WRITE_FAULT 1 +#define EXCEPTION_EXECUTE_FAULT 8 + +#if !defined(RC_INVOKED) + +#define CONTEXT_AMD64 0x100000 + +#define CONTEXT_CONTROL (CONTEXT_AMD64 | 0x1L) +#define CONTEXT_INTEGER (CONTEXT_AMD64 | 0x2L) +#define CONTEXT_SEGMENTS (CONTEXT_AMD64 | 0x4L) +#define CONTEXT_FLOATING_POINT (CONTEXT_AMD64 | 0x8L) +#define CONTEXT_DEBUG_REGISTERS (CONTEXT_AMD64 | 0x10L) + +#define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT) +#define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS) + +#define CONTEXT_XSTATE (CONTEXT_AMD64 | 0x20L) + +#define CONTEXT_EXCEPTION_ACTIVE 0x8000000 +#define CONTEXT_SERVICE_ACTIVE 0x10000000 +#define CONTEXT_EXCEPTION_REQUEST 0x40000000 +#define CONTEXT_EXCEPTION_REPORTING 0x80000000 + +#endif /* !defined(RC_INVOKED) */ + +#define INITIAL_MXCSR 0x1f80 +#define INITIAL_FPCSR 0x027f + +typedef struct DECLSPEC_ALIGN(16) _CONTEXT { + ULONG64 P1Home; + ULONG64 P2Home; + ULONG64 P3Home; + ULONG64 P4Home; + ULONG64 P5Home; + ULONG64 P6Home; + ULONG ContextFlags; + ULONG MxCsr; + USHORT SegCs; + USHORT SegDs; + USHORT SegEs; + USHORT SegFs; + USHORT SegGs; + USHORT SegSs; + ULONG EFlags; + ULONG64 Dr0; + ULONG64 Dr1; + ULONG64 Dr2; + ULONG64 Dr3; + ULONG64 Dr6; + ULONG64 Dr7; + ULONG64 Rax; + ULONG64 Rcx; + ULONG64 Rdx; + ULONG64 Rbx; + ULONG64 Rsp; + ULONG64 Rbp; + ULONG64 Rsi; + ULONG64 Rdi; + ULONG64 R8; + ULONG64 R9; + ULONG64 R10; + ULONG64 R11; + ULONG64 R12; + ULONG64 R13; + ULONG64 R14; + ULONG64 R15; + ULONG64 Rip; + union { + XMM_SAVE_AREA32 FltSave; + struct { + M128A Header[2]; + M128A Legacy[8]; + M128A Xmm0; + M128A Xmm1; + M128A Xmm2; + M128A Xmm3; + M128A Xmm4; + M128A Xmm5; + M128A Xmm6; + M128A Xmm7; + M128A Xmm8; + M128A Xmm9; + M128A Xmm10; + M128A Xmm11; + M128A Xmm12; + M128A Xmm13; + M128A Xmm14; + M128A Xmm15; + } DUMMYSTRUCTNAME; + } DUMMYUNIONNAME; + M128A VectorRegister[26]; + ULONG64 VectorControl; + ULONG64 DebugControl; + ULONG64 LastBranchToRip; + ULONG64 LastBranchFromRip; + ULONG64 LastExceptionToRip; + ULONG64 LastExceptionFromRip; +} CONTEXT; + +#define PCR_MINOR_VERSION 1 +#define PCR_MAJOR_VERSION 1 + +typedef struct _KPCR +{ + _ANONYMOUS_UNION union + { + NT_TIB NtTib; + _ANONYMOUS_STRUCT struct + { + union _KGDTENTRY64 *GdtBase; + struct _KTSS64 *TssBase; + ULONG64 UserRsp; + struct _KPCR *Self; + struct _KPRCB *CurrentPrcb; + PKSPIN_LOCK_QUEUE LockArray; + PVOID Used_Self; + }; + }; + union _KIDTENTRY64 *IdtBase; + ULONG64 Unused[2]; + KIRQL Irql; + UCHAR SecondLevelCacheAssociativity; + UCHAR ObsoleteNumber; + UCHAR Fill0; + ULONG Unused0[3]; + USHORT MajorVersion; + USHORT MinorVersion; + ULONG StallScaleFactor; + PVOID Unused1[3]; + ULONG KernelReserved[15]; + ULONG SecondLevelCacheSize; + ULONG HalReserved[16]; + ULONG Unused2; + PVOID KdVersionBlock; + PVOID Unused3; + ULONG PcrAlign1[24]; +} KPCR, *PKPCR; + +FORCEINLINE +PKPCR +KeGetPcr(VOID) +{ + return (PKPCR)__readgsqword(FIELD_OFFSET(KPCR, Self)); +} + +FORCEINLINE +ULONG +KeGetCurrentProcessorNumber(VOID) +{ + return (ULONG)__readgsword(0x184); +} + + +#define PTI_SHIFT 12L +#define PDI_SHIFT 21L +#define PPI_SHIFT 30L +#define PXI_SHIFT 39L +#define PTE_PER_PAGE 512 +#define PDE_PER_PAGE 512 +#define PPE_PER_PAGE 512 +#define PXE_PER_PAGE 512 +#define PTI_MASK_AMD64 (PTE_PER_PAGE - 1) +#define PDI_MASK_AMD64 (PDE_PER_PAGE - 1) +#define PPI_MASK (PPE_PER_PAGE - 1) +#define PXI_MASK (PXE_PER_PAGE - 1) + +#define PXE_BASE 0xFFFFF6FB7DBED000ULL +#define PXE_SELFMAP 0xFFFFF6FB7DBEDF68ULL +#define PPE_BASE 0xFFFFF6FB7DA00000ULL +#define PDE_BASE 0xFFFFF6FB40000000ULL +#define PTE_BASE 0xFFFFF68000000000ULL +#define PXE_TOP 0xFFFFF6FB7DBEDFFFULL +#define PPE_TOP 0xFFFFF6FB7DBFFFFFULL +#define PDE_TOP 0xFFFFF6FB7FFFFFFFULL +#define PTE_TOP 0xFFFFF6FFFFFFFFFFULL + +extern NTKERNELAPI PVOID MmHighestUserAddress; +extern NTKERNELAPI PVOID MmSystemRangeStart; +extern NTKERNELAPI ULONG64 MmUserProbeAddress; + +#define MM_HIGHEST_USER_ADDRESS MmHighestUserAddress +#define MM_SYSTEM_RANGE_START MmSystemRangeStart +#define MM_USER_PROBE_ADDRESS MmUserProbeAddress +#define MM_LOWEST_USER_ADDRESS (PVOID)0x10000 +#define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xFFFF080000000000ULL + + +#elif defined(_M_IA64) + +#elif defined(_M_PPC) + + +#elif defined(_M_MIPS) + +#elif defined(_M_ARM) +#else +#error Unknown Architecture +#endif + +/****************************************************************************** + * Executive Functions * + ******************************************************************************/ static __inline PVOID ExAllocateFromZone( IN PZONE_HEADER Zone) @@ -1618,8 +3249,8 @@ ExAllocateFromZone( static __inline PVOID ExFreeToZone( - IN PZONE_HEADER Zone, - IN PVOID Block) + IN PZONE_HEADER Zone, + IN PVOID Block) { ((PSINGLE_LIST_ENTRY) Block)->Next = Zone->FreeList.Next; Zone->FreeList.Next = ((PSINGLE_LIST_ENTRY) Block); @@ -1672,8 +3303,36 @@ ExFreeToZone( #define ExIsResourceAcquired ExIsResourceAcquiredSharedLite #define ExReleaseResourceForThread ExReleaseResourceForThreadLite -#if (NTDDI_VERSION >= NTDDI_WIN2K) +typedef enum _INTERLOCKED_RESULT { + ResultNegative = RESULT_NEGATIVE, + ResultZero = RESULT_ZERO, + ResultPositive = RESULT_POSITIVE +} INTERLOCKED_RESULT; +#ifdef _X86_ +NTKERNELAPI +INTERLOCKED_RESULT +FASTCALL +Exfi386InterlockedIncrementLong( + IN OUT LONG volatile *Addend); + +NTKERNELAPI +INTERLOCKED_RESULT +FASTCALL +Exfi386InterlockedDecrementLong( + IN PLONG Addend); + +NTKERNELAPI +ULONG +FASTCALL +Exfi386InterlockedExchangeUlong( + IN PULONG Target, + IN ULONG Value); +#endif + + + +#if (NTDDI_VERSION >= NTDDI_WIN2K) NTKERNELAPI NTSTATUS NTAPI @@ -1710,315 +3369,28 @@ NTKERNELAPI DECLSPEC_NORETURN VOID NTAPI -ExRaiseAccessViolation( - VOID); +ExRaiseAccessViolation(VOID); NTKERNELAPI DECLSPEC_NORETURN VOID NTAPI -ExRaiseDatatypeMisalignment( - VOID); +ExRaiseDatatypeMisalignment(VOID); -#endif -#ifdef _X86_ +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ -NTKERNELAPI -INTERLOCKED_RESULT -FASTCALL -Exfi386InterlockedIncrementLong( - IN OUT LONG volatile *Addend); - -NTKERNELAPI -INTERLOCKED_RESULT -FASTCALL -Exfi386InterlockedDecrementLong( - IN PLONG Addend); - -NTKERNELAPI -ULONG -FASTCALL -Exfi386InterlockedExchangeUlong( - IN PULONG Target, - IN ULONG Value); - -#endif /* _X86_ */ - -#ifndef _ARC_DDK_ -#define _ARC_DDK_ -typedef enum _CONFIGURATION_TYPE { - ArcSystem, - CentralProcessor, - FloatingPointProcessor, - PrimaryIcache, - PrimaryDcache, - SecondaryIcache, - SecondaryDcache, - SecondaryCache, - EisaAdapter, - TcAdapter, - ScsiAdapter, - DtiAdapter, - MultiFunctionAdapter, - DiskController, - TapeController, - CdromController, - WormController, - SerialController, - NetworkController, - DisplayController, - ParallelController, - PointerController, - KeyboardController, - AudioController, - OtherController, - DiskPeripheral, - FloppyDiskPeripheral, - TapePeripheral, - ModemPeripheral, - MonitorPeripheral, - PrinterPeripheral, - PointerPeripheral, - KeyboardPeripheral, - TerminalPeripheral, - OtherPeripheral, - LinePeripheral, - NetworkPeripheral, - SystemMemory, - DockingInformation, - RealModeIrqRoutingTable, - RealModePCIEnumeration, - MaximumType -} CONFIGURATION_TYPE, *PCONFIGURATION_TYPE; -#endif /* !_ARC_DDK_ */ - -typedef struct _CONTROLLER_OBJECT { - CSHORT Type; - CSHORT Size; - PVOID ControllerExtension; - KDEVICE_QUEUE DeviceWaitQueue; - ULONG Spare1; - LARGE_INTEGER Spare2; -} CONTROLLER_OBJECT, *PCONTROLLER_OBJECT; - -typedef struct _CONFIGURATION_INFORMATION { - ULONG DiskCount; - ULONG FloppyCount; - ULONG CdRomCount; - ULONG TapeCount; - ULONG ScsiPortCount; - ULONG SerialCount; - ULONG ParallelCount; - BOOLEAN AtDiskPrimaryAddressClaimed; - BOOLEAN AtDiskSecondaryAddressClaimed; - ULONG Version; - ULONG MediumChangerCount; -} CONFIGURATION_INFORMATION, *PCONFIGURATION_INFORMATION; - -typedef -NTSTATUS -(NTAPI *PIO_QUERY_DEVICE_ROUTINE)( - IN PVOID Context, - IN PUNICODE_STRING PathName, - IN INTERFACE_TYPE BusType, - IN ULONG BusNumber, - IN PKEY_VALUE_FULL_INFORMATION *BusInformation, - IN CONFIGURATION_TYPE ControllerType, - IN ULONG ControllerNumber, - IN PKEY_VALUE_FULL_INFORMATION *ControllerInformation, - IN CONFIGURATION_TYPE PeripheralType, - IN ULONG PeripheralNumber, - IN PKEY_VALUE_FULL_INFORMATION *PeripheralInformation); - -typedef -VOID -(NTAPI DRIVER_REINITIALIZE)( - IN struct _DRIVER_OBJECT *DriverObject, - IN PVOID Context, - IN ULONG Count); - -typedef DRIVER_REINITIALIZE *PDRIVER_REINITIALIZE; - -/** Filesystem runtime library routines **/ - -#if (NTDDI_VERSION >= NTDDI_WIN2K) -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlIsTotalDeviceFailure( - IN NTSTATUS Status); -#endif - -/* Hardware Abstraction Layer Types */ - -typedef VOID -(NTAPI *PciPin2Line)( - IN struct _BUS_HANDLER *BusHandler, - IN struct _BUS_HANDLER *RootHandler, - IN PCI_SLOT_NUMBER SlotNumber, - IN PPCI_COMMON_CONFIG PciData); - -typedef VOID -(NTAPI *PciLine2Pin)( - IN struct _BUS_HANDLER *BusHandler, - IN struct _BUS_HANDLER *RootHandler, - IN PCI_SLOT_NUMBER SlotNumber, - IN PPCI_COMMON_CONFIG PciNewData, - IN PPCI_COMMON_CONFIG PciOldData); - -typedef VOID -(NTAPI *PciReadWriteConfig)( - IN struct _BUS_HANDLER *BusHandler, - IN PCI_SLOT_NUMBER Slot, - IN PVOID Buffer, - IN ULONG Offset, - IN ULONG Length); - -#define PCI_DATA_TAG ' ICP' -#define PCI_DATA_VERSION 1 - -typedef struct _PCIBUSDATA { - ULONG Tag; - ULONG Version; - PciReadWriteConfig ReadConfig; - PciReadWriteConfig WriteConfig; - PciPin2Line Pin2Line; - PciLine2Pin Line2Pin; - PCI_SLOT_NUMBER ParentSlot; - PVOID Reserved[4]; -} PCIBUSDATA, *PPCIBUSDATA; /* Hardware Abstraction Layer Functions */ -#if !defined(NO_LEGACY_DRIVERS) - #if (NTDDI_VERSION >= NTDDI_WIN2K) -NTHALAPI -NTSTATUS -NTAPI -HalAssignSlotResources( - IN PUNICODE_STRING RegistryPath, - IN PUNICODE_STRING DriverClassName, - IN PDRIVER_OBJECT DriverObject, - IN PDEVICE_OBJECT DeviceObject, - IN INTERFACE_TYPE BusType, - IN ULONG BusNumber, - IN ULONG SlotNumber, - IN OUT PCM_RESOURCE_LIST *AllocatedResources); +#if defined(USE_DMA_MACROS) && !defined(_NTHAL_) && (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_) -NTHALAPI -ULONG -NTAPI -HalGetInterruptVector( - IN INTERFACE_TYPE InterfaceType, - IN ULONG BusNumber, - IN ULONG BusInterruptLevel, - IN ULONG BusInterruptVector, - OUT PKIRQL Irql, - OUT PKAFFINITY Affinity); +/* Nothing here */ -NTHALAPI -ULONG -NTAPI -HalSetBusData( - IN BUS_DATA_TYPE BusDataType, - IN ULONG BusNumber, - IN ULONG SlotNumber, - IN PVOID Buffer, - IN ULONG Length); +#else /* USE_DMA_MACROS ... */ -#endif - -#endif /* !defined(NO_LEGACY_DRIVERS) */ - -#if (NTDDI_VERSION >= NTDDI_WIN2K) - -NTHALAPI -PADAPTER_OBJECT -NTAPI -HalGetAdapter( - IN PDEVICE_DESCRIPTION DeviceDescription, - IN OUT PULONG NumberOfMapRegisters); - -NTHALAPI -BOOLEAN -NTAPI -HalMakeBeep( - IN ULONG Frequency); - -VOID -NTAPI -HalPutDmaAdapter( - IN PADAPTER_OBJECT DmaAdapter); - -NTHALAPI -VOID -NTAPI -HalAcquireDisplayOwnership( - IN PHAL_RESET_DISPLAY_PARAMETERS ResetDisplayParameters); - -NTHALAPI -ULONG -NTAPI -HalGetBusData( - IN BUS_DATA_TYPE BusDataType, - IN ULONG BusNumber, - IN ULONG SlotNumber, - OUT PVOID Buffer, - IN ULONG Length); - -NTHALAPI -ULONG -NTAPI -HalGetBusDataByOffset( - IN BUS_DATA_TYPE BusDataType, - IN ULONG BusNumber, - IN ULONG SlotNumber, - OUT PVOID Buffer, - IN ULONG Offset, - IN ULONG Length); - -NTHALAPI -ULONG -NTAPI -HalSetBusDataByOffset( - IN BUS_DATA_TYPE BusDataType, - IN ULONG BusNumber, - IN ULONG SlotNumber, - IN PVOID Buffer, - IN ULONG Offset, - IN ULONG Length); - -NTHALAPI -BOOLEAN -NTAPI -HalTranslateBusAddress( - IN INTERFACE_TYPE InterfaceType, - IN ULONG BusNumber, - IN PHYSICAL_ADDRESS BusAddress, - IN OUT PULONG AddressSpace, - OUT PPHYSICAL_ADDRESS TranslatedAddress); - -#endif - -#if (NTDDI_VERSION >= NTDDI_WINXP) -NTKERNELAPI -VOID -FASTCALL -HalExamineMBR( - IN PDEVICE_OBJECT DeviceObject, - IN ULONG SectorSize, - IN ULONG MBRTypeIdentifier, - OUT PVOID *Buffer); -#endif - -#if defined(USE_DMA_MACROS) && !defined(_NTHAL_) && (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_) -// nothing here -#else - -#if (NTDDI_VERSION >= NTDDI_WIN2K) //DECLSPEC_DEPRECATED_DDK NTHALAPI VOID @@ -2084,12 +3456,207 @@ HalAllocateAdapterChannel( IN ULONG NumberOfMapRegisters, IN PDRIVER_CONTROL ExecutionRoutine); +#endif /* USE_DMA_MACROS ... */ + +#if !defined(NO_LEGACY_DRIVERS) +NTHALAPI +NTSTATUS +NTAPI +HalAssignSlotResources( + IN PUNICODE_STRING RegistryPath, + IN PUNICODE_STRING DriverClassName, + IN PDRIVER_OBJECT DriverObject, + IN PDEVICE_OBJECT DeviceObject, + IN INTERFACE_TYPE BusType, + IN ULONG BusNumber, + IN ULONG SlotNumber, + IN OUT PCM_RESOURCE_LIST *AllocatedResources); + +NTHALAPI +ULONG +NTAPI +HalGetInterruptVector( + IN INTERFACE_TYPE InterfaceType, + IN ULONG BusNumber, + IN ULONG BusInterruptLevel, + IN ULONG BusInterruptVector, + OUT PKIRQL Irql, + OUT PKAFFINITY Affinity); + +NTHALAPI +ULONG +NTAPI +HalSetBusData( + IN BUS_DATA_TYPE BusDataType, + IN ULONG BusNumber, + IN ULONG SlotNumber, + IN PVOID Buffer, + IN ULONG Length); + +NTHALAPI +ULONG +NTAPI +HalGetBusData( + IN BUS_DATA_TYPE BusDataType, + IN ULONG BusNumber, + IN ULONG SlotNumber, + OUT PVOID Buffer, + IN ULONG Length); + +NTHALAPI +BOOLEAN +NTAPI +HalMakeBeep( + IN ULONG Frequency); +#endif /* !defined(NO_LEGACY_DRIVERS) */ + +NTHALAPI +PADAPTER_OBJECT +NTAPI +HalGetAdapter( + IN PDEVICE_DESCRIPTION DeviceDescription, + OUT PULONG NumberOfMapRegisters); + +VOID +NTAPI +HalPutDmaAdapter( + IN PADAPTER_OBJECT DmaAdapter); + +NTHALAPI +VOID +NTAPI +HalAcquireDisplayOwnership( + IN PHAL_RESET_DISPLAY_PARAMETERS ResetDisplayParameters); + +NTHALAPI +ULONG +NTAPI +HalGetBusDataByOffset( + IN BUS_DATA_TYPE BusDataType, + IN ULONG BusNumber, + IN ULONG SlotNumber, + OUT PVOID Buffer, + IN ULONG Offset, + IN ULONG Length); + +NTHALAPI +ULONG +NTAPI +HalSetBusDataByOffset( + IN BUS_DATA_TYPE BusDataType, + IN ULONG BusNumber, + IN ULONG SlotNumber, + IN PVOID Buffer, + IN ULONG Offset, + IN ULONG Length); + +NTHALAPI +BOOLEAN +NTAPI +HalTranslateBusAddress( + IN INTERFACE_TYPE InterfaceType, + IN ULONG BusNumber, + IN PHYSICAL_ADDRESS BusAddress, + IN OUT PULONG AddressSpace, + OUT PPHYSICAL_ADDRESS TranslatedAddress); + +NTHALAPI +PVOID +NTAPI +HalAllocateCrashDumpRegisters( + IN PADAPTER_OBJECT AdapterObject, + IN OUT PULONG NumberOfMapRegisters); + +NTSTATUS +NTAPI +HalGetScatterGatherList( + IN PADAPTER_OBJECT DmaAdapter, + IN PDEVICE_OBJECT DeviceObject, + IN PMDL Mdl, + IN PVOID CurrentVa, + IN ULONG Length, + IN PDRIVER_LIST_CONTROL ExecutionRoutine, + IN PVOID Context, + IN BOOLEAN WriteToDevice); + +VOID +NTAPI +HalPutScatterGatherList( + IN PADAPTER_OBJECT DmaAdapter, + IN PSCATTER_GATHER_LIST ScatterGather, + IN BOOLEAN WriteToDevice); + #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ -#endif /* defined(USE_DMA_MACROS) && !defined(_NTHAL_) && (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_) */ +#if (NTDDI_VERSION >= NTDDI_WINXP) +NTKERNELAPI +VOID +FASTCALL +HalExamineMBR( + IN PDEVICE_OBJECT DeviceObject, + IN ULONG SectorSize, + IN ULONG MBRTypeIdentifier, + OUT PVOID *Buffer); +#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ -/* I/O Manager Functions */ +#if (NTDDI_VERSION >= NTDDI_WIN7) +NTSTATUS +NTAPI +HalAllocateHardwareCounters( + IN PGROUP_AFFINITY GroupAffinty, + IN ULONG GroupCount, + IN PPHYSICAL_COUNTER_RESOURCE_LIST ResourceList, + OUT PHANDLE CounterSetHandle); + +NTSTATUS +NTAPI +HalFreeHardwareCounters( + IN HANDLE CounterSetHandle); + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + +#if defined(_IA64_) +#if (NTDDI_VERSION >= NTDDI_WIN2K) +NTHALAPI +ULONG +NTAPI +HalGetDmaAlignmentRequirement(VOID); +#endif +#endif /* defined(_IA64_) */ + +#if defined(_M_IX86) || defined(_M_AMD64) +#define HalGetDmaAlignmentRequirement() 1L +#endif + +#if (NTDDI_VERSION >= NTDDI_WIN7) + +typedef struct _WHEA_ERROR_SOURCE_DESCRIPTOR *PWHEA_ERROR_SOURCE_DESCRIPTOR; +typedef struct _WHEA_ERROR_RECORD *PWHEA_ERROR_RECORD; + +NTHALAPI +VOID +NTAPI +HalBugCheckSystem( + IN PWHEA_ERROR_SOURCE_DESCRIPTOR ErrorSource, + IN PWHEA_ERROR_RECORD ErrorRecord); + +#else + +typedef struct _WHEA_ERROR_RECORD *PWHEA_ERROR_RECORD; + +NTHALAPI +VOID +NTAPI +HalBugCheckSystem( + IN PWHEA_ERROR_RECORD ErrorRecord); + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + + +/****************************************************************************** + * I/O Manager Functions * + ******************************************************************************/ /* * VOID IoAssignArcName( * IN PUNICODE_STRING ArcName, @@ -2105,8 +3672,19 @@ HalAllocateAdapterChannel( */ #define IoDeassignArcName IoDeleteSymbolicLink -#if (NTDDI_VERSION >= NTDDI_WIN2K) +VOID +FORCEINLINE +NTAPI +IoInitializeDriverCreateContext( + PIO_DRIVER_CREATE_CONTEXT DriverContext) +{ + RtlZeroMemory(DriverContext, sizeof(IO_DRIVER_CREATE_CONTEXT)); + DriverContext->Size = sizeof(IO_DRIVER_CREATE_CONTEXT); +} + + +#if (NTDDI_VERSION >= NTDDI_WIN2K) #if !(defined(USE_DMA_MACROS) && (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_)) NTKERNELAPI NTSTATUS @@ -2119,6 +3697,7 @@ IoAllocateAdapterChannel( IN PVOID Context); #endif +#if !defined(DMA_MACROS_DEFINED) //DECLSPEC_DEPRECATED_DDK NTHALAPI PHYSICAL_ADDRESS @@ -2130,6 +3709,7 @@ IoMapTransfer( IN PVOID CurrentVa, IN OUT PULONG Length, IN BOOLEAN WriteToDevice); +#endif NTKERNELAPI VOID @@ -2161,8 +3741,7 @@ IoFreeController( NTKERNELAPI PCONFIGURATION_INFORMATION NTAPI -IoGetConfigurationInformation( - VOID); +IoGetConfigurationInformation(VOID); NTKERNELAPI PDEVICE_OBJECT @@ -2180,8 +3759,7 @@ IoCancelFileOpen( NTKERNELAPI PGENERIC_MAPPING NTAPI -IoGetFileObjectGenericMapping( - VOID); +IoGetFileObjectGenericMapping(VOID); NTKERNELAPI PIRP @@ -2253,7 +3831,7 @@ IoReportDetectedDevice( IN PCM_RESOURCE_LIST ResourceList OPTIONAL, IN PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirements OPTIONAL, IN BOOLEAN ResourceAssigned, - IN OUT PDEVICE_OBJECT *DeviceObject); + IN OUT PDEVICE_OBJECT *DeviceObject OPTIONAL); NTKERNELAPI NTSTATUS @@ -2299,9 +3877,59 @@ IoAssignResources( IN PIO_RESOURCE_REQUIREMENTS_LIST RequestedResources OPTIONAL, IN OUT PCM_RESOURCE_LIST *AllocatedResources); +NTKERNELAPI +BOOLEAN +NTAPI +IoSetThreadHardErrorMode( + IN BOOLEAN EnableHardErrors); + #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ +#if (NTDDI_VERSION >= NTDDI_WIN2KSP3) + +NTKERNELAPI +BOOLEAN +NTAPI +IoIsFileOriginRemote( + IN PFILE_OBJECT FileObject); + +NTKERNELAPI +NTSTATUS +NTAPI +IoSetFileOrigin( + IN PFILE_OBJECT FileObject, + IN BOOLEAN Remote); + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2KSP3) */ + #if (NTDDI_VERSION >= NTDDI_WINXP) +NTKERNELAPI +NTSTATUS +FASTCALL +IoReadPartitionTable( + IN PDEVICE_OBJECT DeviceObject, + IN ULONG SectorSize, + IN BOOLEAN ReturnRecognizedPartitions, + OUT struct _DRIVE_LAYOUT_INFORMATION **PartitionBuffer); + +NTKERNELAPI +NTSTATUS +FASTCALL +IoSetPartitionInformation( + IN PDEVICE_OBJECT DeviceObject, + IN ULONG SectorSize, + IN ULONG PartitionNumber, + IN ULONG PartitionType); + +NTKERNELAPI +NTSTATUS +FASTCALL +IoWritePartitionTable( + IN PDEVICE_OBJECT DeviceObject, + IN ULONG SectorSize, + IN ULONG SectorsPerTrack, + IN ULONG NumberOfHeads, + IN struct _DRIVE_LAYOUT_INFORMATION *PartitionBuffer); NTKERNELAPI NTSTATUS @@ -2318,30 +3946,12 @@ IoReadDiskSignature( IN ULONG BytesPerSector, OUT PDISK_SIGNATURE Signature); -NTKERNELAPI -NTSTATUS -FASTCALL -IoReadPartitionTable( - IN PDEVICE_OBJECT DeviceObject, - IN ULONG SectorSize, - IN BOOLEAN ReturnRecognizedPartitions, - OUT struct _DRIVE_LAYOUT_INFORMATION **PartitionBuffer); - NTKERNELAPI NTSTATUS NTAPI IoReadPartitionTableEx( IN PDEVICE_OBJECT DeviceObject, - IN struct _DRIVE_LAYOUT_INFORMATION_EX **PartitionBuffer); - -NTKERNELAPI -NTSTATUS -FASTCALL -IoSetPartitionInformation( - IN PDEVICE_OBJECT DeviceObject, - IN ULONG SectorSize, - IN ULONG PartitionNumber, - IN ULONG PartitionType); + OUT struct _DRIVE_LAYOUT_INFORMATION_EX **PartitionBuffer); NTKERNELAPI NTSTATUS @@ -2357,12 +3967,6 @@ NTAPI IoSetSystemPartition( IN PUNICODE_STRING VolumeNameString); -NTKERNELAPI -BOOLEAN -NTAPI -IoSetThreadHardErrorMode( - IN BOOLEAN EnableHardErrors); - NTKERNELAPI NTSTATUS NTAPI @@ -2377,16 +3981,6 @@ IoVolumeDeviceToDosName( IN PVOID VolumeDeviceObject, OUT PUNICODE_STRING DosName); -NTKERNELAPI -NTSTATUS -FASTCALL -IoWritePartitionTable( - IN PDEVICE_OBJECT DeviceObject, - IN ULONG SectorSize, - IN ULONG SectorsPerTrack, - IN ULONG NumberOfHeads, - IN struct _DRIVE_LAYOUT_INFORMATION *PartitionBuffer); - NTKERNELAPI NTSTATUS NTAPI @@ -2394,10 +3988,130 @@ IoWritePartitionTableEx( IN PDEVICE_OBJECT DeviceObject, IN struct _DRIVE_LAYOUT_INFORMATION_EX *DriveLayout); +NTKERNELAPI +NTSTATUS +NTAPI +IoCreateFileSpecifyDeviceObjectHint( + OUT PHANDLE FileHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN PLARGE_INTEGER AllocationSize OPTIONAL, + IN ULONG FileAttributes, + IN ULONG ShareAccess, + IN ULONG Disposition, + IN ULONG CreateOptions, + IN PVOID EaBuffer OPTIONAL, + IN ULONG EaLength, + IN CREATE_FILE_TYPE CreateFileType, + IN PVOID InternalParameters OPTIONAL, + IN ULONG Options, + IN PVOID DeviceObject OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +IoAttachDeviceToDeviceStackSafe( + IN PDEVICE_OBJECT SourceDevice, + IN PDEVICE_OBJECT TargetDevice, + OUT PDEVICE_OBJECT *AttachedToDeviceObject); + #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ -/** Kernel debugger routines **/ +#if (NTDDI_VERSION >= NTDDI_WS03) +NTKERNELAPI +IO_PAGING_PRIORITY +FASTCALL +IoGetPagingIoPriority( + IN PIRP Irp); + +#endif /* (NTDDI_VERSION >= NTDDI_WS03) */ + +#if (NTDDI_VERSION >= NTDDI_WS03SP1) +BOOLEAN +NTAPI +IoTranslateBusAddress( + IN INTERFACE_TYPE InterfaceType, + IN ULONG BusNumber, + IN PHYSICAL_ADDRESS BusAddress, + IN OUT PULONG AddressSpace, + OUT PPHYSICAL_ADDRESS TranslatedAddress); +#endif + +#if (NTDDI_VERSION >= NTDDI_VISTA) +NTKERNELAPI +NTSTATUS +NTAPI +IoUpdateDiskGeometry( + IN PDEVICE_OBJECT DeviceObject, + IN struct _DISK_GEOMETRY_EX* OldDiskGeometry, + IN struct _DISK_GEOMETRY_EX* NewDiskGeometry); + +PTXN_PARAMETER_BLOCK +NTAPI +IoGetTransactionParameterBlock( + IN PFILE_OBJECT FileObject); + +NTKERNELAPI +NTSTATUS +NTAPI +IoCreateFileEx( + OUT PHANDLE FileHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN PLARGE_INTEGER AllocationSize OPTIONAL, + IN ULONG FileAttributes, + IN ULONG ShareAccess, + IN ULONG Disposition, + IN ULONG CreateOptions, + IN PVOID EaBuffer OPTIONAL, + IN ULONG EaLength, + IN CREATE_FILE_TYPE CreateFileType, + IN PVOID InternalParameters OPTIONAL, + IN ULONG Options, + IN PIO_DRIVER_CREATE_CONTEXT DriverContext OPTIONAL); + +NTSTATUS +NTAPI +IoSetIrpExtraCreateParameter( + IN OUT PIRP Irp, + IN struct _ECP_LIST *ExtraCreateParameter); + +VOID +NTAPI +IoClearIrpExtraCreateParameter( + IN OUT PIRP Irp); + +NTSTATUS +NTAPI +IoGetIrpExtraCreateParameter( + IN PIRP Irp, + OUT struct _ECP_LIST **ExtraCreateParameter OPTIONAL); + +BOOLEAN +NTAPI +IoIsFileObjectIgnoringSharing( + IN PFILE_OBJECT FileObject); + + +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + + +#if (NTDDI_VERSION >= NTDDI_WIN7) +NTSTATUS +NTAPI +IoSetFileObjectIgnoreSharing( + IN PFILE_OBJECT FileObject); + + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + + +/****************************************************************************** + * Kernel Debugger Functions * + ******************************************************************************/ NTSYSAPI ULONG NTAPI @@ -2406,16 +4120,25 @@ DbgPrompt( OUT PCH Response, IN ULONG MaximumResponseLength); -/* Kernel Functions */ +/****************************************************************************** + * Kernel Functions * + ******************************************************************************/ +NTKERNELAPI +VOID +FASTCALL +KeInvalidateRangeAllCaches( + IN PVOID BaseAddress, + IN ULONG Length); + #if (NTDDI_VERSION >= NTDDI_WIN2K) NTKERNELAPI -DECLSPEC_NORETURN VOID NTAPI -KeBugCheck( - IN ULONG BugCheckCode); +KeSetImportanceDpc( + IN OUT PRKDPC Dpc, + IN KDPC_IMPORTANCE Importance); NTKERNELAPI LONG @@ -2432,24 +4155,204 @@ KeSetBasePriorityThread( IN OUT PRKTHREAD Thread, IN LONG Increment); -#endif +NTKERNELAPI +VOID +NTAPI +KeEnterCriticalRegion(VOID); -/* Memory Manager Types */ +NTKERNELAPI +VOID +NTAPI +KeLeaveCriticalRegion(VOID); -typedef struct _PHYSICAL_MEMORY_RANGE { - PHYSICAL_ADDRESS BaseAddress; - LARGE_INTEGER NumberOfBytes; -} PHYSICAL_MEMORY_RANGE, *PPHYSICAL_MEMORY_RANGE; +NTKERNELAPI +DECLSPEC_NORETURN +VOID +NTAPI +KeBugCheck( + IN ULONG BugCheckCode); -/* Memory Manager Functions */ + +#if defined(SINGLE_GROUP_LEGACY_API) + + +NTKERNELAPI +VOID +NTAPI +KeSetTargetProcessorDpc( + IN OUT PRKDPC Dpc, + IN CCHAR Number); + +NTKERNELAPI +KAFFINITY +NTAPI +KeQueryActiveProcessors(VOID); + +#endif /* defined(SINGLE_GROUP_LEGACY_API) */ + + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ + +#if (NTDDI_VERSION >= NTDDI_WINXP) +NTKERNELAPI +BOOLEAN +NTAPI +KeAreApcsDisabled(VOID); + + +#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ + + +#if (NTDDI_VERSION >= NTDDI_WS03) + + +NTKERNELAPI +BOOLEAN +NTAPI +KeInvalidateAllCaches(VOID); + +#endif /* (NTDDI_VERSION >= NTDDI_WS03) */ + +#if (NTDDI_VERSION >= NTDDI_WS03SP1) + +NTKERNELAPI +NTSTATUS +NTAPI +KeExpandKernelStackAndCallout( + IN PEXPAND_STACK_CALLOUT Callout, + IN PVOID Parameter OPTIONAL, + IN SIZE_T Size); + +NTKERNELAPI +VOID +NTAPI +KeEnterGuardedRegion(VOID); + +NTKERNELAPI +VOID +NTAPI +KeLeaveGuardedRegion(VOID); + + +#endif /* (NTDDI_VERSION >= NTDDI_WS03SP1) */ + +#if (NTDDI_VERSION >= NTDDI_VISTA) + + +#if defined(SINGLE_GROUP_LEGACY_API) +NTKERNELAPI +ULONG +NTAPI +KeQueryActiveProcessorCount( + OUT PKAFFINITY ActiveProcessors OPTIONAL); + +NTKERNELAPI +ULONG +NTAPI +KeQueryMaximumProcessorCount(VOID); + +#endif /* SINGLE_GROUP_LEGACY_API */ + +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + + +#if (NTDDI_VERSION >= NTDDI_WIN7) + +NTKERNELAPI +ULONG +NTAPI +KeQueryActiveProcessorCountEx( + IN USHORT GroupNumber); + +NTKERNELAPI +ULONG +NTAPI +KeQueryMaximumProcessorCountEx( + IN USHORT GroupNumber); + +NTKERNELAPI +USHORT +NTAPI +KeQueryActiveGroupCount(VOID); + +NTKERNELAPI +USHORT +NTAPI +KeQueryMaximumGroupCount(VOID); + +NTKERNELAPI +KAFFINITY +NTAPI +KeQueryGroupAffinity( + IN USHORT GroupNumber); + +NTKERNELAPI +ULONG +NTAPI +KeGetCurrentProcessorNumberEx( + OUT PPROCESSOR_NUMBER ProcNumber OPTIONAL); + +NTKERNELAPI +VOID +NTAPI +KeQueryNodeActiveAffinity( + IN USHORT NodeNumber, + OUT PGROUP_AFFINITY Affinity OPTIONAL, + OUT PUSHORT Count OPTIONAL); + +NTKERNELAPI +USHORT +NTAPI +KeQueryNodeMaximumProcessorCount( + IN USHORT NodeNumber); + +NTKERNELAPI +USHORT +NTAPI +KeQueryHighestNodeNumber(VOID); + +NTKERNELAPI +USHORT +NTAPI +KeGetCurrentNodeNumber(VOID); + +NTKERNELAPI +NTSTATUS +NTAPI +KeQueryLogicalProcessorRelationship( + IN PPROCESSOR_NUMBER ProcessorNumber OPTIONAL, + IN LOGICAL_PROCESSOR_RELATIONSHIP RelationshipType, + OUT PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX Information OPTIONAL, + IN OUT PULONG Length); + +NTKERNELAPI +NTSTATUS +NTAPI +KeSetHardwareCounterConfiguration( + IN PHARDWARE_COUNTER CounterArray, + IN ULONG Count); + +NTKERNELAPI +NTSTATUS +NTAPI +KeQueryHardwareCounterConfiguration( + OUT PHARDWARE_COUNTER CounterArray, + IN ULONG MaximumCount, + OUT PULONG Count); + + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + + +/****************************************************************************** + * Memory manager Functions * + ******************************************************************************/ #if (NTDDI_VERSION >= NTDDI_WIN2K) - NTKERNELAPI PPHYSICAL_MEMORY_RANGE NTAPI -MmGetPhysicalMemoryRanges( - VOID); +MmGetPhysicalMemoryRanges(VOID); NTKERNELAPI PHYSICAL_ADDRESS @@ -2523,8 +4426,7 @@ MmIsAddressValid( NTKERNELAPI BOOLEAN NTAPI -MmIsThisAnNtAsSystem( - VOID); +MmIsThisAnNtAsSystem(VOID); NTKERNELAPI VOID @@ -2572,9 +4474,144 @@ MmUnmapVideoDisplay( IN PVOID BaseAddress, IN SIZE_T NumberOfBytes); +NTKERNELAPI +NTSTATUS +NTAPI +MmAddPhysicalMemory( + IN PPHYSICAL_ADDRESS StartAddress, + IN OUT PLARGE_INTEGER NumberOfBytes); + +NTKERNELAPI +PVOID +NTAPI +MmAllocateContiguousMemory( + IN SIZE_T NumberOfBytes, + IN PHYSICAL_ADDRESS HighestAcceptableAddress); + +NTKERNELAPI +PVOID +NTAPI +MmAllocateContiguousMemorySpecifyCache( + IN SIZE_T NumberOfBytes, + IN PHYSICAL_ADDRESS LowestAcceptableAddress, + IN PHYSICAL_ADDRESS HighestAcceptableAddress, + IN PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL, + IN MEMORY_CACHING_TYPE CacheType); + +NTKERNELAPI +PVOID +NTAPI +MmAllocateContiguousMemorySpecifyCacheNode( + IN SIZE_T NumberOfBytes, + IN PHYSICAL_ADDRESS LowestAcceptableAddress, + IN PHYSICAL_ADDRESS HighestAcceptableAddress, + IN PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL, + IN MEMORY_CACHING_TYPE CacheType, + IN NODE_REQUIREMENT PreferredNode); + +NTKERNELAPI +VOID +NTAPI +MmFreeContiguousMemory( + IN PVOID BaseAddress); + +NTKERNELAPI +VOID +NTAPI +MmFreeContiguousMemorySpecifyCache( + IN PVOID BaseAddress, + IN SIZE_T NumberOfBytes, + IN MEMORY_CACHING_TYPE CacheType); + + #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ -/* NtXxx Functions */ +#if (NTDDI_VERSION >= NTDDI_WINXP) + +NTKERNELAPI +NTSTATUS +NTAPI +MmAdvanceMdl( + IN OUT PMDL Mdl, + IN ULONG NumberOfBytes); + +NTKERNELAPI +PVOID +NTAPI +MmAllocateMappingAddress( + IN SIZE_T NumberOfBytes, + IN ULONG PoolTag); + +NTKERNELAPI +VOID +NTAPI +MmFreeMappingAddress( + IN PVOID BaseAddress, + IN ULONG PoolTag); + +NTKERNELAPI +NTSTATUS +NTAPI +MmIsVerifierEnabled( + OUT PULONG VerifierFlags); + +NTKERNELAPI +PVOID +NTAPI +MmMapLockedPagesWithReservedMapping( + IN PVOID MappingAddress, + IN ULONG PoolTag, + IN PMDL MemoryDescriptorList, + IN MEMORY_CACHING_TYPE CacheType); + +NTKERNELAPI +NTSTATUS +NTAPI +MmProtectMdlSystemAddress( + IN PMDL MemoryDescriptorList, + IN ULONG NewProtect); + +NTKERNELAPI +VOID +NTAPI +MmUnmapReservedMapping( + IN PVOID BaseAddress, + IN ULONG PoolTag, + IN PMDL MemoryDescriptorList); + +NTKERNELAPI +NTSTATUS +NTAPI +MmAddVerifierThunks( + IN PVOID ThunkBuffer, + IN ULONG ThunkBufferSize); + +#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ + +#if (NTDDI_VERSION >= NTDDI_WS03) +NTKERNELAPI +NTSTATUS +NTAPI +MmCreateMirror(VOID); +#endif + + +#if (NTDDI_VERSION >= NTDDI_VISTA) +NTSTATUS +NTAPI +MmRotatePhysicalView( + IN PVOID VirtualAddress, + IN OUT PSIZE_T NumberOfBytes, + IN PMDLX NewMdl OPTIONAL, + IN MM_ROTATE_DIRECTION Direction, + IN PMM_ROTATE_COPY_CALLBACK_FUNCTION CopyFunction, + IN PVOID Context OPTIONAL); + +#endif + +/****************************************************************************** + * Process Manager Functions * + ******************************************************************************/ NTSYSCALLAPI NTSTATUS @@ -2595,35 +4632,15 @@ NtQueryInformationProcess( IN ULONG ProcessInformationLength, OUT PULONG ReturnLength OPTIONAL); -/** Process manager types **/ - -typedef VOID -(NTAPI *PCREATE_PROCESS_NOTIFY_ROUTINE)( - IN HANDLE ParentId, - IN HANDLE ProcessId, - IN BOOLEAN Create); - -typedef VOID -(NTAPI *PCREATE_THREAD_NOTIFY_ROUTINE)( - IN HANDLE ProcessId, - IN HANDLE ThreadId, - IN BOOLEAN Create); - -typedef VOID -(NTAPI *PLOAD_IMAGE_NOTIFY_ROUTINE)( - IN PUNICODE_STRING FullImageName, - IN HANDLE ProcessId, - IN PIMAGE_INFO ImageInfo); - -/** Process manager routines **/ - #if (NTDDI_VERSION >= NTDDI_WIN2K) + NTKERNELAPI NTSTATUS NTAPI -PsSetLoadImageNotifyRoutine( - IN PLOAD_IMAGE_NOTIFY_ROUTINE NotifyRoutine); +PsSetCreateProcessNotifyRoutine( + IN PCREATE_PROCESS_NOTIFY_ROUTINE NotifyRoutine, + IN BOOLEAN Remove); NTKERNELAPI NTSTATUS @@ -2634,21 +4651,18 @@ PsSetCreateThreadNotifyRoutine( NTKERNELAPI NTSTATUS NTAPI -PsSetCreateProcessNotifyRoutine( - IN PCREATE_PROCESS_NOTIFY_ROUTINE NotifyRoutine, - IN BOOLEAN Remove); +PsSetLoadImageNotifyRoutine( + IN PLOAD_IMAGE_NOTIFY_ROUTINE NotifyRoutine); NTKERNELAPI HANDLE NTAPI -PsGetCurrentProcessId( - VOID); +PsGetCurrentProcessId(VOID); NTKERNELAPI HANDLE NTAPI -PsGetCurrentThreadId( - VOID); +PsGetCurrentThreadId(VOID); NTKERNELAPI BOOLEAN @@ -2669,6 +4683,12 @@ NTAPI PsGetProcessId( IN PEPROCESS Process); +NTKERNELAPI +HANDLE +NTAPI +PsGetThreadId( + IN PETHREAD Thread); + NTKERNELAPI NTSTATUS NTAPI @@ -2681,102 +4701,187 @@ NTAPI PsRemoveLoadImageNotifyRoutine( IN PLOAD_IMAGE_NOTIFY_ROUTINE NotifyRoutine); +NTKERNELAPI +LONGLONG +NTAPI +PsGetProcessCreateTimeQuadPart( + IN PEPROCESS Process); + #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ -extern NTKERNELAPI PEPROCESS PsInitialSystemProcess; +#if (NTDDI_VERSION >= NTDDI_WS03) +NTKERNELAPI +HANDLE +NTAPI +PsGetThreadProcessId( + IN PETHREAD Thread); +#endif /* (NTDDI_VERSION >= NTDDI_WS03) */ -/* RTL Types */ +#if (NTDDI_VERSION >= NTDDI_VISTA) -typedef struct _RTL_SPLAY_LINKS { - struct _RTL_SPLAY_LINKS *Parent; - struct _RTL_SPLAY_LINKS *LeftChild; - struct _RTL_SPLAY_LINKS *RightChild; -} RTL_SPLAY_LINKS, *PRTL_SPLAY_LINKS; +NTKERNELAPI +BOOLEAN +NTAPI +PsSetCurrentThreadPrefetching( + IN BOOLEAN Prefetching); -/* RTL Functions */ +NTKERNELAPI +BOOLEAN +NTAPI +PsIsCurrentThreadPrefetching(VOID); -#if (defined(_M_AMD64) || defined(_M_IA64)) && !defined(_REALLY_GET_CALLERS_CALLER_) +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ -#define RtlGetCallersAddress(CallersAddress, CallersCaller) \ - *CallersAddress = (PVOID)_ReturnAddress(); \ - *CallersCaller = NULL; -#else +#if (NTDDI_VERSION >= NTDDI_VISTASP1) +NTKERNELAPI +NTSTATUS +NTAPI +PsSetCreateProcessNotifyRoutineEx( + IN PCREATE_PROCESS_NOTIFY_ROUTINE_EX NotifyRoutine, + IN BOOLEAN Remove); +#endif /* (NTDDI_VERSION >= NTDDI_VISTASP1) */ +/****************************************************************************** + * Runtime Library Functions * + ******************************************************************************/ #if (NTDDI_VERSION >= NTDDI_WIN2K) + + + +#ifndef RTL_USE_AVL_TABLES + NTSYSAPI VOID NTAPI -RtlGetCallersAddress( - OUT PVOID *CallersAddress, - OUT PVOID *CallersCaller); -#endif +RtlInitializeGenericTable( + OUT PRTL_GENERIC_TABLE Table, + IN PRTL_GENERIC_COMPARE_ROUTINE CompareRoutine, + IN PRTL_GENERIC_ALLOCATE_ROUTINE AllocateRoutine, + IN PRTL_GENERIC_FREE_ROUTINE FreeRoutine, + IN PVOID TableContext OPTIONAL); -#endif - -#if !defined(MIDL_PASS) - -FORCEINLINE -LUID -NTAPI_INLINE -RtlConvertLongToLuid( - IN LONG Val) -{ - LUID Luid; - LARGE_INTEGER Temp; - - Temp.QuadPart = Val; - Luid.LowPart = Temp.u.LowPart; - Luid.HighPart = Temp.u.HighPart; - return Luid; -} - -FORCEINLINE -LUID -NTAPI_INLINE -RtlConvertUlongToLuid( - IN ULONG Val) -{ - LUID Luid; - - Luid.LowPart = Val; - Luid.HighPart = 0; - return Luid; -} - -#endif - -#if defined(_AMD64_) || defined(_IA64_) -//DECLSPEC_DEPRECATED_DDK_WINXP -__inline -LARGE_INTEGER -NTAPI_INLINE -RtlLargeIntegerDivide( - IN LARGE_INTEGER Dividend, - IN LARGE_INTEGER Divisor, - OUT PLARGE_INTEGER Remainder OPTIONAL) -{ - LARGE_INTEGER ret; - ret.QuadPart = Dividend.QuadPart / Divisor.QuadPart; - if (Remainder) - Remainder->QuadPart = Dividend.QuadPart % Divisor.QuadPart; - return ret; -} - -#else - -#if (NTDDI_VERSION >= NTDDI_WIN2K) NTSYSAPI -LARGE_INTEGER +PVOID NTAPI -RtlLargeIntegerDivide( - IN LARGE_INTEGER Dividend, - IN LARGE_INTEGER Divisor, - OUT PLARGE_INTEGER Remainder OPTIONAL); -#endif +RtlInsertElementGenericTable( + IN PRTL_GENERIC_TABLE Table, + IN PVOID Buffer, + IN CLONG BufferSize, + OUT PBOOLEAN NewElement OPTIONAL); -#endif /* defined(_AMD64_) || defined(_IA64_) */ +NTSYSAPI +PVOID +NTAPI +RtlInsertElementGenericTableFull( + IN PRTL_GENERIC_TABLE Table, + IN PVOID Buffer, + IN CLONG BufferSize, + OUT PBOOLEAN NewElement OPTIONAL, + IN PVOID NodeOrParent, + IN TABLE_SEARCH_RESULT SearchResult); -#if (NTDDI_VERSION >= NTDDI_WIN2K) +NTSYSAPI +BOOLEAN +NTAPI +RtlDeleteElementGenericTable( + IN PRTL_GENERIC_TABLE Table, + IN PVOID Buffer); + +NTSYSAPI +PVOID +NTAPI +RtlLookupElementGenericTable( + IN PRTL_GENERIC_TABLE Table, + IN PVOID Buffer); + +NTSYSAPI +PVOID +NTAPI +RtlLookupElementGenericTableFull( + IN PRTL_GENERIC_TABLE Table, + IN PVOID Buffer, + OUT PVOID *NodeOrParent, + OUT TABLE_SEARCH_RESULT *SearchResult); + +NTSYSAPI +PVOID +NTAPI +RtlEnumerateGenericTable( + IN PRTL_GENERIC_TABLE Table, + IN BOOLEAN Restart); + +NTSYSAPI +PVOID +NTAPI +RtlEnumerateGenericTableWithoutSplaying( + IN PRTL_GENERIC_TABLE Table, + IN OUT PVOID *RestartKey); + +NTSYSAPI +PVOID +NTAPI +RtlGetElementGenericTable( + IN PRTL_GENERIC_TABLE Table, + IN ULONG I); + +NTSYSAPI +ULONG +NTAPI +RtlNumberGenericTableElements( + IN PRTL_GENERIC_TABLE Table); + +NTSYSAPI +BOOLEAN +NTAPI +RtlIsGenericTableEmpty( + IN PRTL_GENERIC_TABLE Table); + +#endif /* !RTL_USE_AVL_TABLES */ + +#define RTL_STACK_WALKING_MODE_FRAMES_TO_SKIP_SHIFT 8 + +NTSYSAPI +PRTL_SPLAY_LINKS +NTAPI +RtlSplay( + IN OUT PRTL_SPLAY_LINKS Links); + +NTSYSAPI +PRTL_SPLAY_LINKS +NTAPI +RtlDelete( + IN PRTL_SPLAY_LINKS Links); + +NTSYSAPI +VOID +NTAPI +RtlDeleteNoSplay( + IN PRTL_SPLAY_LINKS Links, + IN OUT PRTL_SPLAY_LINKS *Root); + +NTSYSAPI +PRTL_SPLAY_LINKS +NTAPI +RtlSubtreeSuccessor( + IN PRTL_SPLAY_LINKS Links); + +NTSYSAPI +PRTL_SPLAY_LINKS +NTAPI +RtlSubtreePredecessor( + IN PRTL_SPLAY_LINKS Links); + +NTSYSAPI +PRTL_SPLAY_LINKS +NTAPI +RtlRealSuccessor( + IN PRTL_SPLAY_LINKS Links); + +NTSYSAPI +PRTL_SPLAY_LINKS +NTAPI +RtlRealPredecessor( + IN PRTL_SPLAY_LINKS Links); NTSYSAPI BOOLEAN @@ -2835,7 +4940,7 @@ NTAPI RtlCompareString( IN const PSTRING String1, IN const PSTRING String2, - BOOLEAN CaseInSensitive); + IN BOOLEAN CaseInSensitive); NTSYSAPI VOID @@ -2874,9 +4979,513 @@ RtlWalkFrameChain( IN ULONG Count, IN ULONG Flags); + + #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ -/* Security reference monitor routines */ + +#if (NTDDI_VERSION >= NTDDI_WINXP) + + +NTSYSAPI +VOID +NTAPI +RtlInitializeGenericTableAvl( + OUT PRTL_AVL_TABLE Table, + IN PRTL_AVL_COMPARE_ROUTINE CompareRoutine, + IN PRTL_AVL_ALLOCATE_ROUTINE AllocateRoutine, + IN PRTL_AVL_FREE_ROUTINE FreeRoutine, + IN PVOID TableContext OPTIONAL); + +NTSYSAPI +PVOID +NTAPI +RtlInsertElementGenericTableAvl( + IN PRTL_AVL_TABLE Table, + IN PVOID Buffer, + IN CLONG BufferSize, + OUT PBOOLEAN NewElement OPTIONAL); + +NTSYSAPI +PVOID +NTAPI +RtlInsertElementGenericTableFullAvl( + IN PRTL_AVL_TABLE Table, + IN PVOID Buffer, + IN CLONG BufferSize, + OUT PBOOLEAN NewElement OPTIONAL, + IN PVOID NodeOrParent, + IN TABLE_SEARCH_RESULT SearchResult); + +NTSYSAPI +BOOLEAN +NTAPI +RtlDeleteElementGenericTableAvl( + IN PRTL_AVL_TABLE Table, + IN PVOID Buffer); + +NTSYSAPI +PVOID +NTAPI +RtlLookupElementGenericTableAvl( + IN PRTL_AVL_TABLE Table, + IN PVOID Buffer); + +NTSYSAPI +PVOID +NTAPI +RtlLookupElementGenericTableFullAvl( + IN PRTL_AVL_TABLE Table, + IN PVOID Buffer, + OUT PVOID *NodeOrParent, + OUT TABLE_SEARCH_RESULT *SearchResult); + +NTSYSAPI +PVOID +NTAPI +RtlEnumerateGenericTableAvl( + IN PRTL_AVL_TABLE Table, + IN BOOLEAN Restart); + +NTSYSAPI +PVOID +NTAPI +RtlEnumerateGenericTableWithoutSplayingAvl( + IN PRTL_AVL_TABLE Table, + IN OUT PVOID *RestartKey); + +NTSYSAPI +PVOID +NTAPI +RtlLookupFirstMatchingElementGenericTableAvl( + IN PRTL_AVL_TABLE Table, + IN PVOID Buffer, + OUT PVOID *RestartKey); + +NTSYSAPI +PVOID +NTAPI +RtlEnumerateGenericTableLikeADirectory( + IN PRTL_AVL_TABLE Table, + IN PRTL_AVL_MATCH_FUNCTION MatchFunction OPTIONAL, + IN PVOID MatchData OPTIONAL, + IN ULONG NextFlag, + IN OUT PVOID *RestartKey, + IN OUT PULONG DeleteCount, + IN PVOID Buffer); + +NTSYSAPI +PVOID +NTAPI +RtlGetElementGenericTableAvl( + IN PRTL_AVL_TABLE Table, + IN ULONG I); + +NTSYSAPI +ULONG +NTAPI +RtlNumberGenericTableElementsAvl( + IN PRTL_AVL_TABLE Table); + +NTSYSAPI +BOOLEAN +NTAPI +RtlIsGenericTableEmptyAvl( + IN PRTL_AVL_TABLE Table); + + + +#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ + +#if (NTDDI_VERSION >= NTDDI_VISTA) + + +NTSYSAPI +VOID +NTAPI +RtlRunOnceInitialize( + OUT PRTL_RUN_ONCE RunOnce); + +NTSYSAPI +NTSTATUS +NTAPI +RtlRunOnceExecuteOnce( + IN OUT PRTL_RUN_ONCE RunOnce, + IN PRTL_RUN_ONCE_INIT_FN InitFn, + IN OUT PVOID Parameter OPTIONAL, + OUT PVOID *Context OPTIONAL); + +NTSYSAPI +NTSTATUS +NTAPI +RtlRunOnceBeginInitialize( + IN OUT PRTL_RUN_ONCE RunOnce, + IN ULONG Flags, + OUT PVOID *Context OPTIONAL); + +NTSYSAPI +NTSTATUS +NTAPI +RtlRunOnceComplete( + IN OUT PRTL_RUN_ONCE RunOnce, + IN ULONG Flags, + IN PVOID Context OPTIONAL); + +NTSYSAPI +BOOLEAN +NTAPI +RtlGetProductInfo( + IN ULONG OSMajorVersion, + IN ULONG OSMinorVersion, + IN ULONG SpMajorVersion, + IN ULONG SpMinorVersion, + OUT PULONG ReturnedProductType); + + + +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + +#if (NTDDI_VERSION >= NTDDI_WIN7) + + +NTSYSAPI +BOOLEAN +NTAPI +RtlCreateHashTable( + IN OUT PRTL_DYNAMIC_HASH_TABLE *HashTable OPTIONAL, + IN ULONG Shift, + IN ULONG Flags); + +NTSYSAPI +VOID +NTAPI +RtlDeleteHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable); + +NTSYSAPI +BOOLEAN +NTAPI +RtlInsertEntryHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable, + IN PRTL_DYNAMIC_HASH_TABLE_ENTRY Entry, + IN ULONG_PTR Signature, + IN OUT PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context OPTIONAL); + +NTSYSAPI +BOOLEAN +NTAPI +RtlRemoveEntryHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable, + IN PRTL_DYNAMIC_HASH_TABLE_ENTRY Entry, + IN OUT PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context OPTIONAL); + +NTSYSAPI +PRTL_DYNAMIC_HASH_TABLE_ENTRY +NTAPI +RtlLookupEntryHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable, + IN ULONG_PTR Signature, + OUT PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context OPTIONAL); + +NTSYSAPI +PRTL_DYNAMIC_HASH_TABLE_ENTRY +NTAPI +RtlGetNextEntryHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable, + IN PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context); + +NTSYSAPI +BOOLEAN +NTAPI +RtlInitEnumerationHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable, + OUT PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator); + +NTSYSAPI +PRTL_DYNAMIC_HASH_TABLE_ENTRY +NTAPI +RtlEnumerateEntryHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable, + IN OUT PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator); + +NTSYSAPI +VOID +NTAPI +RtlEndEnumerationHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable, + IN OUT PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator); + +NTSYSAPI +BOOLEAN +NTAPI +RtlInitWeakEnumerationHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable, + OUT PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator); + +NTSYSAPI +PRTL_DYNAMIC_HASH_TABLE_ENTRY +NTAPI +RtlWeaklyEnumerateEntryHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable, + IN OUT PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator); + +NTSYSAPI +VOID +NTAPI +RtlEndWeakEnumerationHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable, + IN OUT PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator); + +NTSYSAPI +BOOLEAN +NTAPI +RtlExpandHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable); + +NTSYSAPI +BOOLEAN +NTAPI +RtlContractHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable); + + + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + + +#if defined(_AMD64_) || defined(_IA64_) + + + +//DECLSPEC_DEPRECATED_DDK_WINXP +FORCEINLINE +LARGE_INTEGER +NTAPI_INLINE +RtlLargeIntegerDivide( + IN LARGE_INTEGER Dividend, + IN LARGE_INTEGER Divisor, + OUT PLARGE_INTEGER Remainder OPTIONAL) +{ + LARGE_INTEGER ret; + ret.QuadPart = Dividend.QuadPart / Divisor.QuadPart; + if (Remainder) + Remainder->QuadPart = Dividend.QuadPart % Divisor.QuadPart; + return ret; +} + +#else + +#if (NTDDI_VERSION >= NTDDI_WIN2K) +NTSYSAPI +LARGE_INTEGER +NTAPI +RtlLargeIntegerDivide( + IN LARGE_INTEGER Dividend, + IN LARGE_INTEGER Divisor, + OUT PLARGE_INTEGER Remainder OPTIONAL); +#endif + + +#endif /* defined(_AMD64_) || defined(_IA64_) */ + + + +#ifdef RTL_USE_AVL_TABLES + +#define RtlInitializeGenericTable RtlInitializeGenericTableAvl +#define RtlInsertElementGenericTable RtlInsertElementGenericTableAvl +#define RtlInsertElementGenericTableFull RtlInsertElementGenericTableFullAvl +#define RtlDeleteElementGenericTable RtlDeleteElementGenericTableAvl +#define RtlLookupElementGenericTable RtlLookupElementGenericTableAvl +#define RtlLookupElementGenericTableFull RtlLookupElementGenericTableFullAvl +#define RtlEnumerateGenericTable RtlEnumerateGenericTableAvl +#define RtlEnumerateGenericTableWithoutSplaying RtlEnumerateGenericTableWithoutSplayingAvl +#define RtlGetElementGenericTable RtlGetElementGenericTableAvl +#define RtlNumberGenericTableElements RtlNumberGenericTableElementsAvl +#define RtlIsGenericTableEmpty RtlIsGenericTableEmptyAvl + +#endif /* RTL_USE_AVL_TABLES */ + +#define RtlInitializeSplayLinks(Links) { \ + PRTL_SPLAY_LINKS _SplayLinks; \ + _SplayLinks = (PRTL_SPLAY_LINKS)(Links); \ + _SplayLinks->Parent = _SplayLinks; \ + _SplayLinks->LeftChild = NULL; \ + _SplayLinks->RightChild = NULL; \ +} + +#define RtlIsLeftChild(Links) \ + (RtlLeftChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links)) + +#define RtlIsRightChild(Links) \ + (RtlRightChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links)) + +#define RtlRightChild(Links) \ + ((PRTL_SPLAY_LINKS)(Links))->RightChild + +#define RtlIsRoot(Links) \ + (RtlParent(Links) == (PRTL_SPLAY_LINKS)(Links)) + +#define RtlLeftChild(Links) \ + ((PRTL_SPLAY_LINKS)(Links))->LeftChild + +#define RtlParent(Links) \ + ((PRTL_SPLAY_LINKS)(Links))->Parent + +#define RtlInsertAsLeftChild(ParentLinks,ChildLinks) \ + { \ + PRTL_SPLAY_LINKS _SplayParent; \ + PRTL_SPLAY_LINKS _SplayChild; \ + _SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \ + _SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks); \ + _SplayParent->LeftChild = _SplayChild; \ + _SplayChild->Parent = _SplayParent; \ + } + +#define RtlInsertAsRightChild(ParentLinks,ChildLinks) \ + { \ + PRTL_SPLAY_LINKS _SplayParent; \ + PRTL_SPLAY_LINKS _SplayChild; \ + _SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \ + _SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks); \ + _SplayParent->RightChild = _SplayChild; \ + _SplayChild->Parent = _SplayParent; \ + } + +#if !defined(MIDL_PASS) + +FORCEINLINE +LUID +NTAPI_INLINE +RtlConvertLongToLuid( + IN LONG Val) +{ + LUID Luid; + LARGE_INTEGER Temp; + + Temp.QuadPart = Val; + Luid.LowPart = Temp.u.LowPart; + Luid.HighPart = Temp.u.HighPart; + return Luid; +} + +FORCEINLINE +LUID +NTAPI_INLINE +RtlConvertUlongToLuid( + IN ULONG Val) +{ + LUID Luid; + + Luid.LowPart = Val; + Luid.HighPart = 0; + return Luid; +} + +#endif /* !defined(MIDL_PASS) */ + +#if (defined(_M_AMD64) || defined(_M_IA64)) && !defined(_REALLY_GET_CALLERS_CALLER_) +#define RtlGetCallersAddress(CallersAddress, CallersCaller) \ + *CallersAddress = (PVOID)_ReturnAddress(); \ + *CallersCaller = NULL; +#else +#if (NTDDI_VERSION >= NTDDI_WIN2K) +NTSYSAPI +VOID +NTAPI +RtlGetCallersAddress( + OUT PVOID *CallersAddress, + OUT PVOID *CallersCaller); +#endif +#endif + +#if !defined(MIDL_PASS) && !defined(SORTPP_PASS) + +#if (NTDDI_VERSION >= NTDDI_WIN7) + +FORCEINLINE +VOID +NTAPI +RtlInitHashTableContext( + IN OUT PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context) +{ + Context->ChainHead = NULL; + Context->PrevLinkage = NULL; +} + +FORCEINLINE +VOID +NTAPI +RtlInitHashTableContextFromEnumerator( + IN OUT PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context, + IN PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator) +{ + Context->ChainHead = Enumerator->ChainHead; + Context->PrevLinkage = Enumerator->HashEntry.Linkage.Blink; +} + +FORCEINLINE +VOID +NTAPI +RtlReleaseHashTableContext( + IN OUT PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context) +{ + UNREFERENCED_PARAMETER(Context); + return; +} + +FORCEINLINE +ULONG +NTAPI +RtlTotalBucketsHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable) +{ + return HashTable->TableSize; +} + +FORCEINLINE +ULONG +NTAPI +RtlNonEmptyBucketsHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable) +{ + return HashTable->NonEmptyBuckets; +} + +FORCEINLINE +ULONG +NTAPI +RtlEmptyBucketsHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable) +{ + return HashTable->TableSize - HashTable->NonEmptyBuckets; +} + +FORCEINLINE +ULONG +NTAPI +RtlTotalEntriesHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable) +{ + return HashTable->NumEntries; +} + +FORCEINLINE +ULONG +NTAPI +RtlActiveEnumeratorsHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable) +{ + return HashTable->NumEnumerators; +} + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + +#endif /* !defined(MIDL_PASS) && !defined(SORTPP_PASS) */ + +/****************************************************************************** + * Security Manager Functions * + ******************************************************************************/ #if (NTDDI_VERSION >= NTDDI_WIN2K) NTKERNELAPI @@ -2885,12 +5494,42 @@ NTAPI SeSinglePrivilegeCheck( IN LUID PrivilegeValue, IN KPROCESSOR_MODE PreviousMode); -#endif -/* ZwXxx Functions */ + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ + +/****************************************************************************** + * ZwXxx Functions * + ******************************************************************************/ + + + +NTSYSAPI +NTSTATUS +NTAPI +ZwAllocateLocallyUniqueId( + OUT PLUID Luid); + +NTSYSAPI +NTSTATUS +NTAPI +ZwTerminateProcess( + IN HANDLE ProcessHandle OPTIONAL, + IN NTSTATUS ExitStatus); + +NTSYSAPI +NTSTATUS +NTAPI +ZwOpenProcess( + OUT PHANDLE ProcessHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN PCLIENT_ID ClientId OPTIONAL); + #if (NTDDI_VERSION >= NTDDI_WIN2K) + NTSTATUS NTAPI ZwCancelTimer( @@ -2932,12 +5571,190 @@ ZwSetTimer( IN LONG Period OPTIONAL, OUT PBOOLEAN PreviousState OPTIONAL); +NTSYSAPI +NTSTATUS +NTAPI +ZwDisplayString( + IN PUNICODE_STRING String); + +NTSYSAPI +NTSTATUS +NTAPI +ZwPowerInformation( + IN POWER_INFORMATION_LEVEL PowerInformationLevel, + IN PVOID InputBuffer OPTIONAL, + IN ULONG InputBufferLength, + OUT PVOID OutputBuffer OPTIONAL, + IN ULONG OutputBufferLength); + +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryVolumeInformationFile( + IN HANDLE FileHandle, + OUT PIO_STATUS_BLOCK IoStatusBlock, + OUT PVOID FsInformation, + IN ULONG Length, + IN FS_INFORMATION_CLASS FsInformationClass); + +NTSYSAPI +NTSTATUS +NTAPI +ZwDeviceIoControlFile( + IN HANDLE FileHandle, + IN HANDLE Event OPTIONAL, + IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, + IN PVOID ApcContext OPTIONAL, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN ULONG IoControlCode, + IN PVOID InputBuffer OPTIONAL, + IN ULONG InputBufferLength, + OUT PVOID OutputBuffer OPTIONAL, + IN ULONG OutputBufferLength); + + + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ + + +#if (NTDDI_VERSION >= NTDDI_WIN7) + +NTSTATUS +NTAPI +ZwSetTimerEx( + IN HANDLE TimerHandle, + IN TIMER_SET_INFORMATION_CLASS TimerSetInformationClass, + IN OUT PVOID TimerSetInformation, + IN ULONG TimerSetInformationLength); + + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + + + +/* UNSORTED */ + +#define VER_SET_CONDITION(ConditionMask, TypeBitMask, ComparisonType) \ + ((ConditionMask) = VerSetConditionMask((ConditionMask), \ + (TypeBitMask), (ComparisonType))) + +#if (NTDDI_VERSION >= NTDDI_WIN2K) +NTSYSAPI +ULONGLONG +NTAPI +VerSetConditionMask( + IN ULONGLONG ConditionMask, + IN ULONG TypeMask, + IN UCHAR Condition); #endif +typedef struct _KERNEL_USER_TIMES { + LARGE_INTEGER CreateTime; + LARGE_INTEGER ExitTime; + LARGE_INTEGER KernelTime; + LARGE_INTEGER UserTime; +} KERNEL_USER_TIMES, *PKERNEL_USER_TIMES; + +/* NtXxx Functions */ + +typedef enum _SYSTEM_FIRMWARE_TABLE_ACTION { + SystemFirmwareTable_Enumerate, + SystemFirmwareTable_Get +} SYSTEM_FIRMWARE_TABLE_ACTION; + +typedef struct _SYSTEM_FIRMWARE_TABLE_INFORMATION { + ULONG ProviderSignature; + SYSTEM_FIRMWARE_TABLE_ACTION Action; + ULONG TableID; + ULONG TableBufferLength; + UCHAR TableBuffer[ANYSIZE_ARRAY]; +} SYSTEM_FIRMWARE_TABLE_INFORMATION, *PSYSTEM_FIRMWARE_TABLE_INFORMATION; + +typedef NTSTATUS +(__cdecl *PFNFTH)( + IN OUT PSYSTEM_FIRMWARE_TABLE_INFORMATION SystemFirmwareTableInfo); + +typedef struct _SYSTEM_FIRMWARE_TABLE_HANDLER { + ULONG ProviderSignature; + BOOLEAN Register; + PFNFTH FirmwareTableHandler; + PVOID DriverObject; +} SYSTEM_FIRMWARE_TABLE_HANDLER, *PSYSTEM_FIRMWARE_TABLE_HANDLER; + +typedef ULONG_PTR +(NTAPI *PDRIVER_VERIFIER_THUNK_ROUTINE)( + IN PVOID Context); + +typedef struct _DRIVER_VERIFIER_THUNK_PAIRS { + PDRIVER_VERIFIER_THUNK_ROUTINE PristineRoutine; + PDRIVER_VERIFIER_THUNK_ROUTINE NewRoutine; +} DRIVER_VERIFIER_THUNK_PAIRS, *PDRIVER_VERIFIER_THUNK_PAIRS; + +#define DRIVER_VERIFIER_SPECIAL_POOLING 0x0001 +#define DRIVER_VERIFIER_FORCE_IRQL_CHECKING 0x0002 +#define DRIVER_VERIFIER_INJECT_ALLOCATION_FAILURES 0x0004 +#define DRIVER_VERIFIER_TRACK_POOL_ALLOCATIONS 0x0008 +#define DRIVER_VERIFIER_IO_CHECKING 0x0010 + +#define SHARED_GLOBAL_FLAGS_ERROR_PORT_V 0x0 +#define SHARED_GLOBAL_FLAGS_ERROR_PORT (1UL << SHARED_GLOBAL_FLAGS_ERROR_PORT_V) + +#define SHARED_GLOBAL_FLAGS_ELEVATION_ENABLED_V 0x1 +#define SHARED_GLOBAL_FLAGS_ELEVATION_ENABLED (1UL << SHARED_GLOBAL_FLAGS_ELEVATION_ENABLED_V) + +#define SHARED_GLOBAL_FLAGS_VIRT_ENABLED_V 0x2 +#define SHARED_GLOBAL_FLAGS_VIRT_ENABLED (1UL << SHARED_GLOBAL_FLAGS_VIRT_ENABLED_V) + +#define SHARED_GLOBAL_FLAGS_INSTALLER_DETECT_ENABLED_V 0x3 +#define SHARED_GLOBAL_FLAGS_INSTALLER_DETECT_ENABLED \ + (1UL << SHARED_GLOBAL_FLAGS_INSTALLER_DETECT_ENABLED_V) + +#define SHARED_GLOBAL_FLAGS_SPARE_V 0x4 +#define SHARED_GLOBAL_FLAGS_SPARE \ + (1UL << SHARED_GLOBAL_FLAGS_SPARE_V) + +#define SHARED_GLOBAL_FLAGS_DYNAMIC_PROC_ENABLED_V 0x5 +#define SHARED_GLOBAL_FLAGS_DYNAMIC_PROC_ENABLED \ + (1UL << SHARED_GLOBAL_FLAGS_DYNAMIC_PROC_ENABLED_V) + +#define SHARED_GLOBAL_FLAGS_SEH_VALIDATION_ENABLED_V 0x6 +#define SHARED_GLOBAL_FLAGS_SEH_VALIDATION_ENABLED \ + (1UL << SHARED_GLOBAL_FLAGS_SEH_VALIDATION_ENABLED_V) + +#define EX_INIT_BITS(Flags, Bit) \ + *((Flags)) |= (Bit) // Safe to use before concurrently accessible + +#define EX_TEST_SET_BIT(Flags, Bit) \ + InterlockedBitTestAndSet ((PLONG)(Flags), (Bit)) + +#define EX_TEST_CLEAR_BIT(Flags, Bit) \ + InterlockedBitTestAndReset ((PLONG)(Flags), (Bit)) + +#define PCCARD_MAP_ERROR 0x01 +#define PCCARD_DEVICE_PCI 0x10 + +#define PCCARD_SCAN_DISABLED 0x01 +#define PCCARD_MAP_ZERO 0x02 +#define PCCARD_NO_TIMER 0x03 +#define PCCARD_NO_PIC 0x04 +#define PCCARD_NO_LEGACY_BASE 0x05 +#define PCCARD_DUP_LEGACY_BASE 0x06 +#define PCCARD_NO_CONTROLLERS 0x07 + +#define MAXIMUM_EXPANSION_SIZE (KERNEL_LARGE_STACK_SIZE - (PAGE_SIZE / 2)) + +/* Filesystem runtime library routines */ + +#if (NTDDI_VERSION >= NTDDI_WIN2K) +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlIsTotalDeviceFailure( + IN NTSTATUS Status); +#endif + +/* FIXME : These definitions below doesn't belong to NTDDK */ #ifdef __cplusplus } #endif - - -#endif /* _NTDDK_ */ diff --git a/reactos/include/ddk/ntifs.h b/reactos/include/ddk/ntifs.h index 5f032726d38..7e14da769e7 100644 --- a/reactos/include/ddk/ntifs.h +++ b/reactos/include/ddk/ntifs.h @@ -25,32 +25,10 @@ #define _NTIFS_INCLUDED_ #define _GNU_NTIFS_ -/* Helper macro to enable gcc's extension. */ -#ifndef __GNU_EXTENSION -#ifdef __GNUC__ -#define __GNU_EXTENSION __extension__ -#else -#define __GNU_EXTENSION -#endif -#endif - #ifdef __cplusplus extern "C" { #endif -#if !defined(_NTHALDLL_) && !defined(_BLDR_) -#define NTHALAPI DECLSPEC_IMPORT -#else -#define NTHALAPI -#endif - -/* For ReactOS */ -#if !defined(_NTOSKRNL_) && !defined(_BLDR_) -#define NTKERNELAPI DECLSPEC_IMPORT -#else -#define NTKERNELAPI -#endif - /* Dependencies */ #include #include @@ -76,16 +54,6 @@ extern "C" { #define ClearFlag(_F,_SF) ((_F) &= ~(_SF)) #endif -#define PsGetCurrentProcess IoGetCurrentProcess - -#if (NTDDI_VERSION >= NTDDI_VISTA) -extern NTSYSAPI volatile CCHAR KeNumberProcessors; -#elif (NTDDI_VERSION >= NTDDI_WINXP) -extern NTSYSAPI CCHAR KeNumberProcessors; -#else -extern PCCHAR KeNumberProcessors; -#endif - typedef UNICODE_STRING LSA_UNICODE_STRING, *PLSA_UNICODE_STRING; typedef STRING LSA_STRING, *PLSA_STRING; typedef OBJECT_ATTRIBUTES LSA_OBJECT_ATTRIBUTES, *PLSA_OBJECT_ATTRIBUTES; @@ -751,8 +719,6 @@ typedef enum _OBJECT_INFORMATION_CLASS { MaxObjectInfoClass /* FIXME, not in WDK */ } OBJECT_INFORMATION_CLASS; -#if (NTDDI_VERSION >= NTDDI_NT4) - NTSYSCALLAPI NTSTATUS NTAPI @@ -763,8 +729,6 @@ NtQueryObject( IN ULONG ObjectInformationLength, OUT PULONG ReturnLength OPTIONAL); -#endif - #if (NTDDI_VERSION >= NTDDI_WIN2K) NTSYSCALLAPI @@ -2414,95 +2378,11 @@ extern const PRTL_REALLOCATE_STRING_ROUTINE RtlReallocateStringRoutine; #define RTL_SYSTEM_VOLUME_INFORMATION_FOLDER L"System Volume Information" -#define DEVICE_TYPE ULONG - -#define FILE_DEVICE_BEEP 0x00000001 -#define FILE_DEVICE_CD_ROM 0x00000002 -#define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003 -#define FILE_DEVICE_CONTROLLER 0x00000004 -#define FILE_DEVICE_DATALINK 0x00000005 -#define FILE_DEVICE_DFS 0x00000006 -#define FILE_DEVICE_DISK 0x00000007 -#define FILE_DEVICE_DISK_FILE_SYSTEM 0x00000008 -#define FILE_DEVICE_FILE_SYSTEM 0x00000009 -#define FILE_DEVICE_INPORT_PORT 0x0000000a -#define FILE_DEVICE_KEYBOARD 0x0000000b -#define FILE_DEVICE_MAILSLOT 0x0000000c -#define FILE_DEVICE_MIDI_IN 0x0000000d -#define FILE_DEVICE_MIDI_OUT 0x0000000e -#define FILE_DEVICE_MOUSE 0x0000000f -#define FILE_DEVICE_MULTI_UNC_PROVIDER 0x00000010 -#define FILE_DEVICE_NAMED_PIPE 0x00000011 -#define FILE_DEVICE_NETWORK 0x00000012 -#define FILE_DEVICE_NETWORK_BROWSER 0x00000013 -#define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014 -#define FILE_DEVICE_NULL 0x00000015 -#define FILE_DEVICE_PARALLEL_PORT 0x00000016 -#define FILE_DEVICE_PHYSICAL_NETCARD 0x00000017 -#define FILE_DEVICE_PRINTER 0x00000018 -#define FILE_DEVICE_SCANNER 0x00000019 -#define FILE_DEVICE_SERIAL_MOUSE_PORT 0x0000001a -#define FILE_DEVICE_SERIAL_PORT 0x0000001b -#define FILE_DEVICE_SCREEN 0x0000001c -#define FILE_DEVICE_SOUND 0x0000001d -#define FILE_DEVICE_STREAMS 0x0000001e -#define FILE_DEVICE_TAPE 0x0000001f -#define FILE_DEVICE_TAPE_FILE_SYSTEM 0x00000020 -#define FILE_DEVICE_TRANSPORT 0x00000021 -#define FILE_DEVICE_UNKNOWN 0x00000022 -#define FILE_DEVICE_VIDEO 0x00000023 -#define FILE_DEVICE_VIRTUAL_DISK 0x00000024 -#define FILE_DEVICE_WAVE_IN 0x00000025 -#define FILE_DEVICE_WAVE_OUT 0x00000026 -#define FILE_DEVICE_8042_PORT 0x00000027 -#define FILE_DEVICE_NETWORK_REDIRECTOR 0x00000028 -#define FILE_DEVICE_BATTERY 0x00000029 -#define FILE_DEVICE_BUS_EXTENDER 0x0000002a -#define FILE_DEVICE_MODEM 0x0000002b -#define FILE_DEVICE_VDM 0x0000002c -#define FILE_DEVICE_MASS_STORAGE 0x0000002d -#define FILE_DEVICE_SMB 0x0000002e -#define FILE_DEVICE_KS 0x0000002f -#define FILE_DEVICE_CHANGER 0x00000030 -#define FILE_DEVICE_SMARTCARD 0x00000031 -#define FILE_DEVICE_ACPI 0x00000032 -#define FILE_DEVICE_DVD 0x00000033 -#define FILE_DEVICE_FULLSCREEN_VIDEO 0x00000034 -#define FILE_DEVICE_DFS_FILE_SYSTEM 0x00000035 -#define FILE_DEVICE_DFS_VOLUME 0x00000036 -#define FILE_DEVICE_SERENUM 0x00000037 -#define FILE_DEVICE_TERMSRV 0x00000038 -#define FILE_DEVICE_KSEC 0x00000039 -#define FILE_DEVICE_FIPS 0x0000003A -#define FILE_DEVICE_INFINIBAND 0x0000003B -#define FILE_DEVICE_VMBUS 0x0000003E -#define FILE_DEVICE_CRYPT_PROVIDER 0x0000003F -#define FILE_DEVICE_WPD 0x00000040 -#define FILE_DEVICE_BLUETOOTH 0x00000041 -#define FILE_DEVICE_MT_COMPOSITE 0x00000042 -#define FILE_DEVICE_MT_TRANSPORT 0x00000043 -#define FILE_DEVICE_BIOMETRIC 0x00000044 -#define FILE_DEVICE_PMI 0x00000045 - -#define CTL_CODE(DeviceType, Function, Method, Access) \ - (((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method)) - -#define DEVICE_TYPE_FROM_CTL_CODE(ctl) (((ULONG) (ctl & 0xffff0000)) >> 16) - #define METHOD_FROM_CTL_CODE(ctrlCode) ((ULONG)(ctrlCode & 3)) -#define METHOD_BUFFERED 0 -#define METHOD_IN_DIRECT 1 -#define METHOD_OUT_DIRECT 2 -#define METHOD_NEITHER 3 #define METHOD_DIRECT_TO_HARDWARE METHOD_IN_DIRECT #define METHOD_DIRECT_FROM_HARDWARE METHOD_OUT_DIRECT -#define FILE_ANY_ACCESS 0x00000000 -#define FILE_SPECIAL_ACCESS FILE_ANY_ACCESS -#define FILE_READ_ACCESS 0x00000001 -#define FILE_WRITE_ACCESS 0x00000002 - typedef ULONG LSA_OPERATIONAL_MODE, *PLSA_OPERATIONAL_MODE; typedef enum _SECURITY_LOGON_TYPE { @@ -4673,6 +4553,8 @@ typedef struct _KAPC_STATE { #define KAPC_STATE_ACTUAL_LENGTH (FIELD_OFFSET(KAPC_STATE, UserApcPending) + sizeof(BOOLEAN)) +#define ASSERT_QUEUE(Q) ASSERT(((Q)->Header.Type & KOBJECT_TYPE_MASK) == QueueObject); + typedef struct _KQUEUE { DISPATCHER_HEADER Header; LIST_ENTRY EntryListHead; @@ -4807,7 +4689,7 @@ FASTCALL KeAcquireQueuedSpinLock( IN OUT KSPIN_LOCK_QUEUE_NUMBER Number); -NTHALAPI +_DECL_HAL_KE_IMPORT VOID FASTCALL KeReleaseQueuedSpinLock( @@ -5022,24 +4904,6 @@ typedef NTSTATUS #if (NTDDI_VERSION >= NTDDI_WIN2K) -NTKERNELAPI -VOID -NTAPI -SeCaptureSubjectContext( - OUT PSECURITY_SUBJECT_CONTEXT SubjectContext); - -NTKERNELAPI -VOID -NTAPI -SeLockSubjectContext( - IN PSECURITY_SUBJECT_CONTEXT SubjectContext); - -NTKERNELAPI -VOID -NTAPI -SeUnlockSubjectContext( - IN PSECURITY_SUBJECT_CONTEXT SubjectContext); - NTKERNELAPI VOID NTAPI @@ -5453,18 +5317,6 @@ SeLocateProcessImageName( extern NTKERNELAPI PSE_EXPORTS SeExports; -#if !defined(_PSGETCURRENTTHREAD_) -#define _PSGETCURRENTTHREAD_ - -FORCEINLINE -PETHREAD -PsGetCurrentThread( - VOID) -{ - return (PETHREAD)KeGetCurrentThread(); -} -#endif - #if (NTDDI_VERSION >= NTDDI_WIN2K) NTKERNELAPI @@ -5534,7 +5386,20 @@ PsReturnPoolQuota( IN POOL_TYPE PoolType, IN ULONG_PTR Amount); -#endif +NTKERNELAPI +NTSTATUS +NTAPI +PsAssignImpersonationToken( + IN PETHREAD Thread, + IN HANDLE Token OPTIONAL); + +NTKERNELAPI +HANDLE +NTAPI +PsReferencePrimaryToken( + IN OUT PEPROCESS Process); + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ #if (NTDDI_VERSION >= NTDDI_WINXP) @@ -5823,18 +5688,6 @@ IoPageRead( IN PKEVENT Event, OUT PIO_STATUS_BLOCK IoStatusBlock); -NTKERNELAPI -PDEVICE_OBJECT -NTAPI -IoGetAttachedDevice( - IN PDEVICE_OBJECT DeviceObject); - -NTKERNELAPI -PDEVICE_OBJECT -NTAPI -IoGetAttachedDeviceReference( - IN PDEVICE_OBJECT DeviceObject); - NTKERNELAPI PDEVICE_OBJECT NTAPI @@ -5951,42 +5804,6 @@ NTAPI IoSetTopLevelIrp( IN PIRP Irp OPTIONAL); -NTKERNELAPI -VOID -NTAPI -IoStartNextPacket( - IN PDEVICE_OBJECT DeviceObject, - IN BOOLEAN Cancelable); - -NTKERNELAPI -VOID -NTAPI -IoStartNextPacketByKey( - IN PDEVICE_OBJECT DeviceObject, - IN BOOLEAN Cancelable, - IN ULONG Key); - -NTKERNELAPI -VOID -NTAPI -IoStartPacket( - IN PDEVICE_OBJECT DeviceObject, - IN PIRP Irp, - IN PULONG Key OPTIONAL, - IN PDRIVER_CANCEL CancelFunction OPTIONAL); - -NTKERNELAPI -VOID -NTAPI -IoStartTimer( - IN PDEVICE_OBJECT DeviceObject); - -NTKERNELAPI -VOID -NTAPI -IoStopTimer( - IN PDEVICE_OBJECT DeviceObject); - NTKERNELAPI NTSTATUS NTAPI @@ -6023,12 +5840,6 @@ IoVerifyVolume( IN PDEVICE_OBJECT DeviceObject, IN BOOLEAN AllowRawMount); -NTKERNELAPI -VOID -NTAPI -IoWriteErrorLogEntry( - IN PVOID ElEntry); - NTKERNELAPI NTSTATUS NTAPI @@ -6055,13 +5866,6 @@ IoQueryFileDosDeviceName( IN PFILE_OBJECT FileObject, OUT POBJECT_NAME_INFORMATION *ObjectNameInformation); -VOID -NTAPI -IoSetStartIoAttributes( - IN PDEVICE_OBJECT DeviceObject, - IN BOOLEAN DeferredStartIo, - IN BOOLEAN NonCancelable); - NTKERNELAPI NTSTATUS NTAPI @@ -6160,53 +5964,6 @@ typedef struct _IO_PRIORITY_INFO { #define PO_CB_LID_SWITCH_STATE 4 #define PO_CB_PROCESSOR_POWER_POLICY 5 -#if (NTDDI_VERSION >= NTDDI_WIN2K) - -NTKERNELAPI -PVOID -NTAPI -PoRegisterSystemState( - IN OUT PVOID StateHandle OPTIONAL, - IN EXECUTION_STATE Flags); - -NTKERNELAPI -VOID -NTAPI -PoUnregisterSystemState( - IN OUT PVOID StateHandle); - -NTKERNELAPI -POWER_STATE -NTAPI -PoSetPowerState( - IN PDEVICE_OBJECT DeviceObject, - IN POWER_STATE_TYPE Type, - IN POWER_STATE State); - -NTKERNELAPI -NTSTATUS -NTAPI -PoCallDriver( - IN PDEVICE_OBJECT DeviceObject, - IN OUT PIRP Irp); - -NTKERNELAPI -VOID -NTAPI -PoStartNextPowerIrp( - IN OUT PIRP Irp); - -NTKERNELAPI -PULONG -NTAPI -PoRegisterDeviceForIdleDetection( - IN PDEVICE_OBJECT DeviceObject, - IN ULONG ConservationIdleTime, - IN ULONG PerformanceIdleTime, - IN DEVICE_POWER_STATE State); - -#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ - #if (NTDDI_VERSION >= NTDDI_WINXP) NTKERNELAPI NTSTATUS @@ -6215,84 +5972,6 @@ PoQueueShutdownWorkItem( IN OUT PWORK_QUEUE_ITEM WorkItem); #endif -#if (NTDDI_VERSION >= NTDDI_VISTA) - -NTKERNELAPI -NTSTATUS -NTAPI -PoRegisterPowerSettingCallback( - IN PDEVICE_OBJECT DeviceObject OPTIONAL, - IN LPCGUID SettingGuid, - IN PPOWER_SETTING_CALLBACK Callback, - IN PVOID Context OPTIONAL, - OUT PVOID *Handle); - -NTKERNELAPI -NTSTATUS -PoUnregisterPowerSettingCallback( - IN OUT PVOID Handle); - -#endif - -#if (NTDDI_VERSION >= NTDDI_WIN6SP1) -NTKERNELAPI -VOID -NTAPI -PoSetDeviceBusyEx( - IN OUT PULONG IdlePointer); -#endif - -#if (NTDDI_VERSION >= NTDDI_WIN7) - -NTKERNELAPI -NTSTATUS -NTAPI -PoCreatePowerRequest( - OUT PVOID *PowerRequest, - IN PDEVICE_OBJECT DeviceObject, - IN PCOUNTED_REASON_CONTEXT Context); - -NTKERNELAPI -NTSTATUS -NTAPI -PoSetPowerRequest( - IN OUT PVOID PowerRequest, - IN POWER_REQUEST_TYPE Type); - -NTKERNELAPI -NTSTATUS -NTAPI -PoClearPowerRequest( - IN OUT PVOID PowerRequest, - IN POWER_REQUEST_TYPE Type); - -NTKERNELAPI -VOID -NTAPI -PoDeletePowerRequest( - IN OUT PVOID PowerRequest); - -NTKERNELAPI -VOID -NTAPI -PoStartDeviceBusy( - IN OUT PULONG IdlePointer); - -NTKERNELAPI -VOID -NTAPI -PoEndDeviceBusy( - IN OUT PULONG IdlePointer); - -NTKERNELAPI -BOOLEAN -NTAPI -PoQueryWatchdogTime( - IN PDEVICE_OBJECT Pdo, - OUT PULONG SecondsRemaining); - -#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ - #if defined(_IA64_) #if (NTDDI_VERSION >= NTDDI_WIN2K) //DECLSPEC_DEPRECATED_DDK @@ -6568,6 +6247,188 @@ typedef struct _FILE_LOCK { LONG volatile LockRequestsInProgress; } FILE_LOCK, *PFILE_LOCK; +typedef struct _TUNNEL { + FAST_MUTEX Mutex; + PRTL_SPLAY_LINKS Cache; + LIST_ENTRY TimerQueue; + USHORT NumEntries; +} TUNNEL, *PTUNNEL; + +typedef enum _FSRTL_COMPARISON_RESULT { + LessThan = -1, + EqualTo = 0, + GreaterThan = 1 +} FSRTL_COMPARISON_RESULT; + +#define FSRTL_FAT_LEGAL 0x01 +#define FSRTL_HPFS_LEGAL 0x02 +#define FSRTL_NTFS_LEGAL 0x04 +#define FSRTL_WILD_CHARACTER 0x08 +#define FSRTL_OLE_LEGAL 0x10 +#define FSRTL_NTFS_STREAM_LEGAL (FSRTL_NTFS_LEGAL | FSRTL_OLE_LEGAL) + +typedef struct _BASE_MCB { + ULONG MaximumPairCount; + ULONG PairCount; + USHORT PoolType; + USHORT Flags; + PVOID Mapping; +} BASE_MCB, *PBASE_MCB; + +typedef struct _LARGE_MCB { + PKGUARDED_MUTEX GuardedMutex; + BASE_MCB BaseMcb; +} LARGE_MCB, *PLARGE_MCB; + +#define MCB_FLAG_RAISE_ON_ALLOCATION_FAILURE 1 + +typedef struct _MCB { + LARGE_MCB DummyFieldThatSizesThisStructureCorrectly; +} MCB, *PMCB; + +typedef PVOID OPLOCK, *POPLOCK; + +typedef VOID +(NTAPI *POPLOCK_WAIT_COMPLETE_ROUTINE) ( + IN PVOID Context, + IN PIRP Irp); + +typedef VOID +(NTAPI *POPLOCK_FS_PREPOST_IRP) ( + IN PVOID Context, + IN PIRP Irp); + +#if (NTDDI_VERSION >= NTDDI_VISTASP1) +#define OPLOCK_FLAG_COMPLETE_IF_OPLOCKED 0x00000001 +#endif + +#if (NTDDI_VERSION >= NTDDI_WIN7) +#define OPLOCK_FLAG_OPLOCK_KEY_CHECK_ONLY 0x00000002 +#define OPLOCK_FLAG_BACK_OUT_ATOMIC_OPLOCK 0x00000004 +#define OPLOCK_FLAG_IGNORE_OPLOCK_KEYS 0x00000008 +#define OPLOCK_FSCTRL_FLAG_ALL_KEYS_MATCH 0x00000001 +#endif + +#if (NTDDI_VERSION >= NTDDI_WIN7) + +typedef struct _OPLOCK_KEY_ECP_CONTEXT { + GUID OplockKey; + ULONG Reserved; +} OPLOCK_KEY_ECP_CONTEXT, *POPLOCK_KEY_ECP_CONTEXT; + +DEFINE_GUID( GUID_ECP_OPLOCK_KEY, 0x48850596, 0x3050, 0x4be7, 0x98, 0x63, 0xfe, 0xc3, 0x50, 0xce, 0x8d, 0x7f ); + +#endif + +#define FSRTL_VOLUME_DISMOUNT 1 +#define FSRTL_VOLUME_DISMOUNT_FAILED 2 +#define FSRTL_VOLUME_LOCK 3 +#define FSRTL_VOLUME_LOCK_FAILED 4 +#define FSRTL_VOLUME_UNLOCK 5 +#define FSRTL_VOLUME_MOUNT 6 +#define FSRTL_VOLUME_NEEDS_CHKDSK 7 +#define FSRTL_VOLUME_WORM_NEAR_FULL 8 +#define FSRTL_VOLUME_WEARING_OUT 9 +#define FSRTL_VOLUME_FORCED_CLOSED 10 +#define FSRTL_VOLUME_INFO_MAKE_COMPAT 11 +#define FSRTL_VOLUME_PREPARING_EJECT 12 +#define FSRTL_VOLUME_CHANGE_SIZE 13 +#define FSRTL_VOLUME_BACKGROUND_FORMAT 14 + +typedef PVOID PNOTIFY_SYNC; + +typedef BOOLEAN +(NTAPI *PCHECK_FOR_TRAVERSE_ACCESS) ( + IN PVOID NotifyContext, + IN PVOID TargetContext OPTIONAL, + IN PSECURITY_SUBJECT_CONTEXT SubjectContext); + +typedef BOOLEAN +(NTAPI *PFILTER_REPORT_CHANGE) ( + IN PVOID NotifyContext, + IN PVOID FilterContext); + +typedef VOID +(NTAPI *PFSRTL_STACK_OVERFLOW_ROUTINE) ( + IN PVOID Context, + IN PKEVENT Event); + +#if (NTDDI_VERSION >= NTDDI_VISTA) + +#define FSRTL_UNC_PROVIDER_FLAGS_MAILSLOTS_SUPPORTED 0x00000001 +#define FSRTL_UNC_PROVIDER_FLAGS_CSC_ENABLED 0x00000002 +#define FSRTL_UNC_PROVIDER_FLAGS_DOMAIN_SVC_AWARE 0x00000004 + +#define FSRTL_ALLOCATE_ECPLIST_FLAG_CHARGE_QUOTA 0x00000001 + +#define FSRTL_ALLOCATE_ECP_FLAG_CHARGE_QUOTA 0x00000001 +#define FSRTL_ALLOCATE_ECP_FLAG_NONPAGED_POOL 0x00000002 + +#define FSRTL_ECP_LOOKASIDE_FLAG_NONPAGED_POOL 0x00000002 + +#define FSRTL_VIRTDISK_FULLY_ALLOCATED 0x00000001 +#define FSRTL_VIRTDISK_NO_DRIVE_LETTER 0x00000002 + +typedef struct _FSRTL_MUP_PROVIDER_INFO_LEVEL_1 { + ULONG32 ProviderId; +} FSRTL_MUP_PROVIDER_INFO_LEVEL_1, *PFSRTL_MUP_PROVIDER_INFO_LEVEL_1; + +typedef struct _FSRTL_MUP_PROVIDER_INFO_LEVEL_2 { + ULONG32 ProviderId; + UNICODE_STRING ProviderName; +} FSRTL_MUP_PROVIDER_INFO_LEVEL_2, *PFSRTL_MUP_PROVIDER_INFO_LEVEL_2; + +typedef VOID +(*PFSRTL_EXTRA_CREATE_PARAMETER_CLEANUP_CALLBACK) ( + IN OUT PVOID EcpContext, + IN LPCGUID EcpType); + +typedef struct _ECP_LIST ECP_LIST, *PECP_LIST; + +typedef ULONG FSRTL_ALLOCATE_ECPLIST_FLAGS; +typedef ULONG FSRTL_ALLOCATE_ECP_FLAGS; +typedef ULONG FSRTL_ECP_LOOKASIDE_FLAGS; + +typedef enum _FSRTL_CHANGE_BACKING_TYPE { + ChangeDataControlArea, + ChangeImageControlArea, + ChangeSharedCacheMap +} FSRTL_CHANGE_BACKING_TYPE, *PFSRTL_CHANGE_BACKING_TYPE; + +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + +typedef struct _FSRTL_PER_FILE_CONTEXT { + LIST_ENTRY Links; + PVOID OwnerId; + PVOID InstanceId; + PFREE_FUNCTION FreeCallback; +} FSRTL_PER_FILE_CONTEXT, *PFSRTL_PER_FILE_CONTEXT; + +typedef struct _FSRTL_PER_STREAM_CONTEXT { + LIST_ENTRY Links; + PVOID OwnerId; + PVOID InstanceId; + PFREE_FUNCTION FreeCallback; +} FSRTL_PER_STREAM_CONTEXT, *PFSRTL_PER_STREAM_CONTEXT; + +#if (NTDDI_VERSION >= NTDDI_WIN2K) +typedef VOID +(*PFN_FSRTLTEARDOWNPERSTREAMCONTEXTS) ( + IN PFSRTL_ADVANCED_FCB_HEADER AdvancedHeader); +#endif + +typedef struct _FSRTL_PER_FILEOBJECT_CONTEXT { + LIST_ENTRY Links; + PVOID OwnerId; + PVOID InstanceId; +} FSRTL_PER_FILEOBJECT_CONTEXT, *PFSRTL_PER_FILEOBJECT_CONTEXT; + +#define FsRtlEnterFileSystem KeEnterCriticalRegion +#define FsRtlExitFileSystem KeLeaveCriticalRegion + +#define FSRTL_CC_FLUSH_ERROR_FLAG_NO_HARD_ERROR 0x1 +#define FSRTL_CC_FLUSH_ERROR_FLAG_NO_LOG_ENTRY 0x2 + #if (NTDDI_VERSION >= NTDDI_WIN2K) NTKERNELAPI @@ -6845,15 +6706,2181 @@ FsRtlPrivateLock( IN PVOID Context, IN BOOLEAN AlreadySynchronized); +NTKERNELAPI +VOID +NTAPI +FsRtlInitializeTunnelCache( + IN PTUNNEL Cache); + +NTKERNELAPI +VOID +NTAPI +FsRtlAddToTunnelCache( + IN PTUNNEL Cache, + IN ULONGLONG DirectoryKey, + IN PUNICODE_STRING ShortName, + IN PUNICODE_STRING LongName, + IN BOOLEAN KeyByShortName, + IN ULONG DataLength, + IN PVOID Data); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlFindInTunnelCache( + IN PTUNNEL Cache, + IN ULONGLONG DirectoryKey, + IN PUNICODE_STRING Name, + OUT PUNICODE_STRING ShortName, + OUT PUNICODE_STRING LongName, + IN OUT PULONG DataLength, + OUT PVOID Data); + +NTKERNELAPI +VOID +NTAPI +FsRtlDeleteKeyFromTunnelCache( + IN PTUNNEL Cache, + IN ULONGLONG DirectoryKey); + +NTKERNELAPI +VOID +NTAPI +FsRtlDeleteTunnelCache( + IN PTUNNEL Cache); + +NTKERNELAPI +VOID +NTAPI +FsRtlDissectDbcs( + IN ANSI_STRING Name, + OUT PANSI_STRING FirstPart, + OUT PANSI_STRING RemainingPart); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlDoesDbcsContainWildCards( + IN PANSI_STRING Name); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlIsDbcsInExpression( + IN PANSI_STRING Expression, + IN PANSI_STRING Name); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlIsFatDbcsLegal( + IN ANSI_STRING DbcsName, + IN BOOLEAN WildCardsPermissible, + IN BOOLEAN PathNamePermissible, + IN BOOLEAN LeadingBackslashPermissible); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlIsHpfsDbcsLegal( + IN ANSI_STRING DbcsName, + IN BOOLEAN WildCardsPermissible, + IN BOOLEAN PathNamePermissible, + IN BOOLEAN LeadingBackslashPermissible); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlNormalizeNtstatus( + IN NTSTATUS Exception, + IN NTSTATUS GenericException); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlIsNtstatusExpected( + IN NTSTATUS Ntstatus); + +NTKERNELAPI +PERESOURCE +NTAPI +FsRtlAllocateResource( + VOID); + +NTKERNELAPI +VOID +NTAPI +FsRtlInitializeLargeMcb( + IN PLARGE_MCB Mcb, + IN POOL_TYPE PoolType); + +NTKERNELAPI +VOID +NTAPI +FsRtlUninitializeLargeMcb( + IN PLARGE_MCB Mcb); + +NTKERNELAPI +VOID +NTAPI +FsRtlResetLargeMcb( + IN PLARGE_MCB Mcb, + IN BOOLEAN SelfSynchronized); + +NTKERNELAPI +VOID +NTAPI +FsRtlTruncateLargeMcb( + IN PLARGE_MCB Mcb, + IN LONGLONG Vbn); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlAddLargeMcbEntry( + IN PLARGE_MCB Mcb, + IN LONGLONG Vbn, + IN LONGLONG Lbn, + IN LONGLONG SectorCount); + +NTKERNELAPI +VOID +NTAPI +FsRtlRemoveLargeMcbEntry( + IN PLARGE_MCB Mcb, + IN LONGLONG Vbn, + IN LONGLONG SectorCount); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlLookupLargeMcbEntry( + IN PLARGE_MCB Mcb, + IN LONGLONG Vbn, + OUT PLONGLONG Lbn OPTIONAL, + OUT PLONGLONG SectorCountFromLbn OPTIONAL, + OUT PLONGLONG StartingLbn OPTIONAL, + OUT PLONGLONG SectorCountFromStartingLbn OPTIONAL, + OUT PULONG Index OPTIONAL); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlLookupLastLargeMcbEntry( + IN PLARGE_MCB Mcb, + OUT PLONGLONG Vbn, + OUT PLONGLONG Lbn); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlLookupLastLargeMcbEntryAndIndex( + IN PLARGE_MCB OpaqueMcb, + OUT PLONGLONG LargeVbn, + OUT PLONGLONG LargeLbn, + OUT PULONG Index); + +NTKERNELAPI +ULONG +NTAPI +FsRtlNumberOfRunsInLargeMcb( + IN PLARGE_MCB Mcb); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlGetNextLargeMcbEntry( + IN PLARGE_MCB Mcb, + IN ULONG RunIndex, + OUT PLONGLONG Vbn, + OUT PLONGLONG Lbn, + OUT PLONGLONG SectorCount); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlSplitLargeMcb( + IN PLARGE_MCB Mcb, + IN LONGLONG Vbn, + IN LONGLONG Amount); + +NTKERNELAPI +VOID +NTAPI +FsRtlInitializeMcb( + IN PMCB Mcb, + IN POOL_TYPE PoolType); + +NTKERNELAPI +VOID +NTAPI +FsRtlUninitializeMcb( + IN PMCB Mcb); + +NTKERNELAPI +VOID +NTAPI +FsRtlTruncateMcb( + IN PMCB Mcb, + IN VBN Vbn); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlAddMcbEntry( + IN PMCB Mcb, + IN VBN Vbn, + IN LBN Lbn, + IN ULONG SectorCount); + +NTKERNELAPI +VOID +NTAPI +FsRtlRemoveMcbEntry( + IN PMCB Mcb, + IN VBN Vbn, + IN ULONG SectorCount); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlLookupMcbEntry( + IN PMCB Mcb, + IN VBN Vbn, + OUT PLBN Lbn, + OUT PULONG SectorCount OPTIONAL, + OUT PULONG Index); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlLookupLastMcbEntry( + IN PMCB Mcb, + OUT PVBN Vbn, + OUT PLBN Lbn); + +NTKERNELAPI +ULONG +NTAPI +FsRtlNumberOfRunsInMcb( + IN PMCB Mcb); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlGetNextMcbEntry( + IN PMCB Mcb, + IN ULONG RunIndex, + OUT PVBN Vbn, + OUT PLBN Lbn, + OUT PULONG SectorCount); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlBalanceReads( + IN PDEVICE_OBJECT TargetDevice); + +NTKERNELAPI +VOID +NTAPI +FsRtlInitializeOplock( + IN OUT POPLOCK Oplock); + +NTKERNELAPI +VOID +NTAPI +FsRtlUninitializeOplock( + IN OUT POPLOCK Oplock); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlOplockFsctrl( + IN POPLOCK Oplock, + IN PIRP Irp, + IN ULONG OpenCount); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlCheckOplock( + IN POPLOCK Oplock, + IN PIRP Irp, + IN PVOID Context, + IN POPLOCK_WAIT_COMPLETE_ROUTINE CompletionRoutine OPTIONAL, + IN POPLOCK_FS_PREPOST_IRP PostIrpRoutine OPTIONAL); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlOplockIsFastIoPossible( + IN POPLOCK Oplock); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlCurrentBatchOplock( + IN POPLOCK Oplock); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlNotifyVolumeEvent( + IN PFILE_OBJECT FileObject, + IN ULONG EventCode); + +NTKERNELAPI +VOID +NTAPI +FsRtlNotifyInitializeSync( + IN PNOTIFY_SYNC *NotifySync); + +NTKERNELAPI +VOID +NTAPI +FsRtlNotifyUninitializeSync( + IN PNOTIFY_SYNC *NotifySync); + +NTKERNELAPI +VOID +NTAPI +FsRtlNotifyFullChangeDirectory( + IN PNOTIFY_SYNC NotifySync, + IN PLIST_ENTRY NotifyList, + IN PVOID FsContext, + IN PSTRING FullDirectoryName, + IN BOOLEAN WatchTree, + IN BOOLEAN IgnoreBuffer, + IN ULONG CompletionFilter, + IN PIRP NotifyIrp OPTIONAL, + IN PCHECK_FOR_TRAVERSE_ACCESS TraverseCallback OPTIONAL, + IN PSECURITY_SUBJECT_CONTEXT SubjectContext OPTIONAL); + +NTKERNELAPI +VOID +NTAPI +FsRtlNotifyFilterReportChange( + IN PNOTIFY_SYNC NotifySync, + IN PLIST_ENTRY NotifyList, + IN PSTRING FullTargetName, + IN USHORT TargetNameOffset, + IN PSTRING StreamName OPTIONAL, + IN PSTRING NormalizedParentName OPTIONAL, + IN ULONG FilterMatch, + IN ULONG Action, + IN PVOID TargetContext OPTIONAL, + IN PVOID FilterContext OPTIONAL); + +NTKERNELAPI +VOID +NTAPI +FsRtlNotifyFullReportChange( + IN PNOTIFY_SYNC NotifySync, + IN PLIST_ENTRY NotifyList, + IN PSTRING FullTargetName, + IN USHORT TargetNameOffset, + IN PSTRING StreamName OPTIONAL, + IN PSTRING NormalizedParentName OPTIONAL, + IN ULONG FilterMatch, + IN ULONG Action, + IN PVOID TargetContext OPTIONAL); + +NTKERNELAPI +VOID +NTAPI +FsRtlNotifyCleanup( + IN PNOTIFY_SYNC NotifySync, + IN PLIST_ENTRY NotifyList, + IN PVOID FsContext); + +NTKERNELAPI +VOID +NTAPI +FsRtlDissectName( + IN UNICODE_STRING Name, + OUT PUNICODE_STRING FirstPart, + OUT PUNICODE_STRING RemainingPart); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlDoesNameContainWildCards( + IN PUNICODE_STRING Name); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlAreNamesEqual( + IN PCUNICODE_STRING Name1, + IN PCUNICODE_STRING Name2, + IN BOOLEAN IgnoreCase, + IN PCWCH UpcaseTable OPTIONAL); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlIsNameInExpression( + IN PUNICODE_STRING Expression, + IN PUNICODE_STRING Name, + IN BOOLEAN IgnoreCase, + IN PWCHAR UpcaseTable OPTIONAL); + +NTKERNELAPI +VOID +NTAPI +FsRtlPostPagingFileStackOverflow( + IN PVOID Context, + IN PKEVENT Event, + IN PFSRTL_STACK_OVERFLOW_ROUTINE StackOverflowRoutine); + +NTKERNELAPI +VOID +NTAPI +FsRtlPostStackOverflow ( + IN PVOID Context, + IN PKEVENT Event, + IN PFSRTL_STACK_OVERFLOW_ROUTINE StackOverflowRoutine); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlRegisterUncProvider( + OUT PHANDLE MupHandle, + IN PUNICODE_STRING RedirectorDeviceName, + IN BOOLEAN MailslotsSupported); + +NTKERNELAPI +VOID +NTAPI +FsRtlDeregisterUncProvider( + IN HANDLE Handle); + +NTKERNELAPI +VOID +NTAPI +FsRtlTeardownPerStreamContexts( + IN PFSRTL_ADVANCED_FCB_HEADER AdvancedHeader); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlCreateSectionForDataScan( + OUT PHANDLE SectionHandle, + OUT PVOID *SectionObject, + OUT PLARGE_INTEGER SectionFileSize OPTIONAL, + IN PFILE_OBJECT FileObject, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, + IN PLARGE_INTEGER MaximumSize OPTIONAL, + IN ULONG SectionPageProtection, + IN ULONG AllocationAttributes, + IN ULONG Flags); + #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ +#if (NTDDI_VERSION >= NTDDI_WINXP) + +NTKERNELAPI +VOID +NTAPI +FsRtlNotifyFilterChangeDirectory( + IN PNOTIFY_SYNC NotifySync, + IN PLIST_ENTRY NotifyList, + IN PVOID FsContext, + IN PSTRING FullDirectoryName, + IN BOOLEAN WatchTree, + IN BOOLEAN IgnoreBuffer, + IN ULONG CompletionFilter, + IN PIRP NotifyIrp OPTIONAL, + IN PCHECK_FOR_TRAVERSE_ACCESS TraverseCallback OPTIONAL, + IN PSECURITY_SUBJECT_CONTEXT SubjectContext OPTIONAL, + IN PFILTER_REPORT_CHANGE FilterCallback OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlInsertPerStreamContext( + IN PFSRTL_ADVANCED_FCB_HEADER PerStreamContext, + IN PFSRTL_PER_STREAM_CONTEXT Ptr); + +NTKERNELAPI +PFSRTL_PER_STREAM_CONTEXT +NTAPI +FsRtlLookupPerStreamContextInternal( + IN PFSRTL_ADVANCED_FCB_HEADER StreamContext, + IN PVOID OwnerId OPTIONAL, + IN PVOID InstanceId OPTIONAL); + +NTKERNELAPI +PFSRTL_PER_STREAM_CONTEXT +NTAPI +FsRtlRemovePerStreamContext( + IN PFSRTL_ADVANCED_FCB_HEADER StreamContext, + IN PVOID OwnerId OPTIONAL, + IN PVOID InstanceId OPTIONAL); + +NTKERNELAPI +VOID +NTAPI +FsRtlIncrementCcFastReadNotPossible( + VOID); + +NTKERNELAPI +VOID +NTAPI +FsRtlIncrementCcFastReadWait( + VOID); + +NTKERNELAPI +VOID +NTAPI +FsRtlIncrementCcFastReadNoWait( + VOID); + +NTKERNELAPI +VOID +NTAPI +FsRtlIncrementCcFastReadResourceMiss( + VOID); + +NTKERNELAPI +LOGICAL +NTAPI +FsRtlIsPagingFile( + IN PFILE_OBJECT FileObject); + +#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ + +#if (NTDDI_VERSION >= NTDDI_WS03) + +NTKERNELAPI +VOID +NTAPI +FsRtlInitializeBaseMcb( + IN PBASE_MCB Mcb, + IN POOL_TYPE PoolType); + +NTKERNELAPI +VOID +NTAPI +FsRtlUninitializeBaseMcb( + IN PBASE_MCB Mcb); + +NTKERNELAPI +VOID +NTAPI +FsRtlResetBaseMcb( + IN PBASE_MCB Mcb); + +NTKERNELAPI +VOID +NTAPI +FsRtlTruncateBaseMcb( + IN PBASE_MCB Mcb, + IN LONGLONG Vbn); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlAddBaseMcbEntry( + IN PBASE_MCB Mcb, + IN LONGLONG Vbn, + IN LONGLONG Lbn, + IN LONGLONG SectorCount); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlRemoveBaseMcbEntry( + IN PBASE_MCB Mcb, + IN LONGLONG Vbn, + IN LONGLONG SectorCount); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlLookupBaseMcbEntry( + IN PBASE_MCB Mcb, + IN LONGLONG Vbn, + OUT PLONGLONG Lbn OPTIONAL, + OUT PLONGLONG SectorCountFromLbn OPTIONAL, + OUT PLONGLONG StartingLbn OPTIONAL, + OUT PLONGLONG SectorCountFromStartingLbn OPTIONAL, + OUT PULONG Index OPTIONAL); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlLookupLastBaseMcbEntry( + IN PBASE_MCB Mcb, + OUT PLONGLONG Vbn, + OUT PLONGLONG Lbn); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlLookupLastBaseMcbEntryAndIndex( + IN PBASE_MCB OpaqueMcb, + IN OUT PLONGLONG LargeVbn, + IN OUT PLONGLONG LargeLbn, + IN OUT PULONG Index); + +NTKERNELAPI +ULONG +NTAPI +FsRtlNumberOfRunsInBaseMcb( + IN PBASE_MCB Mcb); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlGetNextBaseMcbEntry( + IN PBASE_MCB Mcb, + IN ULONG RunIndex, + OUT PLONGLONG Vbn, + OUT PLONGLONG Lbn, + OUT PLONGLONG SectorCount); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlSplitBaseMcb( + IN PBASE_MCB Mcb, + IN LONGLONG Vbn, + IN LONGLONG Amount); + +#endif /* (NTDDI_VERSION >= NTDDI_WS03) */ + +#if (NTDDI_VERSION >= NTDDI_VISTA) + +BOOLEAN +NTAPI +FsRtlInitializeBaseMcbEx( + IN PBASE_MCB Mcb, + IN POOL_TYPE PoolType, + IN USHORT Flags); + +NTSTATUS +NTAPI +FsRtlAddBaseMcbEntryEx( + IN PBASE_MCB Mcb, + IN LONGLONG Vbn, + IN LONGLONG Lbn, + IN LONGLONG SectorCount); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlCurrentOplock( + IN POPLOCK Oplock); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlOplockBreakToNone( + IN OUT POPLOCK Oplock, + IN PIO_STACK_LOCATION IrpSp OPTIONAL, + IN PIRP Irp, + IN PVOID Context OPTIONAL, + IN POPLOCK_WAIT_COMPLETE_ROUTINE CompletionRoutine OPTIONAL, + IN POPLOCK_FS_PREPOST_IRP PostIrpRoutine OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlNotifyVolumeEventEx( + IN PFILE_OBJECT FileObject, + IN ULONG EventCode, + IN PTARGET_DEVICE_CUSTOM_NOTIFICATION Event); + +NTKERNELAPI +VOID +NTAPI +FsRtlNotifyCleanupAll( + IN PNOTIFY_SYNC NotifySync, + IN PLIST_ENTRY NotifyList); + +NTSTATUS +NTAPI +FsRtlRegisterUncProviderEx( + OUT PHANDLE MupHandle, + IN PUNICODE_STRING RedirDevName, + IN PDEVICE_OBJECT DeviceObject, + IN ULONG Flags); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlCancellableWaitForSingleObject( + IN PVOID Object, + IN PLARGE_INTEGER Timeout OPTIONAL, + IN PIRP Irp OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlCancellableWaitForMultipleObjects( + IN ULONG Count, + IN PVOID ObjectArray[], + IN WAIT_TYPE WaitType, + IN PLARGE_INTEGER Timeout OPTIONAL, + IN PKWAIT_BLOCK WaitBlockArray OPTIONAL, + IN PIRP Irp OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlMupGetProviderInfoFromFileObject( + IN PFILE_OBJECT pFileObject, + IN ULONG Level, + OUT PVOID pBuffer, + IN OUT PULONG pBufferSize); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlMupGetProviderIdFromName( + IN PUNICODE_STRING pProviderName, + OUT PULONG32 pProviderId); + +NTKERNELAPI +VOID +NTAPI +FsRtlIncrementCcFastMdlReadWait( + VOID); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlValidateReparsePointBuffer( + IN ULONG BufferLength, + IN PREPARSE_DATA_BUFFER ReparseBuffer); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlRemoveDotsFromPath( + IN OUT PWSTR OriginalString, + IN USHORT PathLength, + OUT USHORT *NewLength); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlAllocateExtraCreateParameterList( + IN FSRTL_ALLOCATE_ECPLIST_FLAGS Flags, + OUT PECP_LIST *EcpList); + +NTKERNELAPI +VOID +NTAPI +FsRtlFreeExtraCreateParameterList( + IN PECP_LIST EcpList); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlAllocateExtraCreateParameter( + IN LPCGUID EcpType, + IN ULONG SizeOfContext, + IN FSRTL_ALLOCATE_ECP_FLAGS Flags, + IN PFSRTL_EXTRA_CREATE_PARAMETER_CLEANUP_CALLBACK CleanupCallback OPTIONAL, + IN ULONG PoolTag, + OUT PVOID *EcpContext); + +NTKERNELAPI +VOID +NTAPI +FsRtlFreeExtraCreateParameter( + IN PVOID EcpContext); + +NTKERNELAPI +VOID +NTAPI +FsRtlInitExtraCreateParameterLookasideList( + IN OUT PVOID Lookaside, + IN FSRTL_ECP_LOOKASIDE_FLAGS Flags, + IN SIZE_T Size, + IN ULONG Tag); + +VOID +NTAPI +FsRtlDeleteExtraCreateParameterLookasideList( + IN OUT PVOID Lookaside, + IN FSRTL_ECP_LOOKASIDE_FLAGS Flags); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlAllocateExtraCreateParameterFromLookasideList( + IN LPCGUID EcpType, + IN ULONG SizeOfContext, + IN FSRTL_ALLOCATE_ECP_FLAGS Flags, + IN PFSRTL_EXTRA_CREATE_PARAMETER_CLEANUP_CALLBACK CleanupCallback OPTIONAL, + IN OUT PVOID LookasideList, + OUT PVOID *EcpContext); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlInsertExtraCreateParameter( + IN OUT PECP_LIST EcpList, + IN OUT PVOID EcpContext); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlFindExtraCreateParameter( + IN PECP_LIST EcpList, + IN LPCGUID EcpType, + OUT PVOID *EcpContext OPTIONAL, + OUT ULONG *EcpContextSize OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlRemoveExtraCreateParameter( + IN OUT PECP_LIST EcpList, + IN LPCGUID EcpType, + OUT PVOID *EcpContext, + OUT ULONG *EcpContextSize OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlGetEcpListFromIrp( + IN PIRP Irp, + OUT PECP_LIST *EcpList OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlSetEcpListIntoIrp( + IN OUT PIRP Irp, + IN PECP_LIST EcpList); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlGetNextExtraCreateParameter( + IN PECP_LIST EcpList, + IN PVOID CurrentEcpContext OPTIONAL, + OUT LPGUID NextEcpType OPTIONAL, + OUT PVOID *NextEcpContext OPTIONAL, + OUT ULONG *NextEcpContextSize OPTIONAL); + +NTKERNELAPI +VOID +NTAPI +FsRtlAcknowledgeEcp( + IN PVOID EcpContext); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlIsEcpAcknowledged( + IN PVOID EcpContext); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlIsEcpFromUserMode( + IN PVOID EcpContext); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlChangeBackingFileObject( + IN PFILE_OBJECT CurrentFileObject OPTIONAL, + IN PFILE_OBJECT NewFileObject, + IN FSRTL_CHANGE_BACKING_TYPE ChangeBackingType, + IN ULONG Flags); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlLogCcFlushError( + IN PUNICODE_STRING FileName, + IN PDEVICE_OBJECT DeviceObject, + IN PSECTION_OBJECT_POINTERS SectionObjectPointer, + IN NTSTATUS FlushError, + IN ULONG Flags); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlAreVolumeStartupApplicationsComplete( + VOID); + +NTKERNELAPI +ULONG +NTAPI +FsRtlQueryMaximumVirtualDiskNestingLevel( + VOID); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlGetVirtualDiskNestingLevel( + IN PDEVICE_OBJECT DeviceObject, + OUT PULONG NestingLevel, + OUT PULONG NestingFlags OPTIONAL); + +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + +#if (NTDDI_VERSION >= NTDDI_VISTASP1) +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlCheckOplockEx( + IN POPLOCK Oplock, + IN PIRP Irp, + IN ULONG Flags, + IN PVOID Context OPTIONAL, + IN POPLOCK_WAIT_COMPLETE_ROUTINE CompletionRoutine OPTIONAL, + IN POPLOCK_FS_PREPOST_IRP PostIrpRoutine OPTIONAL); + +#endif + #if (NTDDI_VERSION >= NTDDI_WIN7) + NTKERNELAPI BOOLEAN NTAPI FsRtlAreThereCurrentOrInProgressFileLocks( IN PFILE_LOCK FileLock); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlOplockIsSharedRequest( + IN PIRP Irp); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlOplockBreakH( + IN POPLOCK Oplock, + IN PIRP Irp, + IN ULONG Flags, + IN PVOID Context OPTIONAL, + IN POPLOCK_WAIT_COMPLETE_ROUTINE CompletionRoutine OPTIONAL, + IN POPLOCK_FS_PREPOST_IRP PostIrpRoutine OPTIONAL); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlCurrentOplockH( + IN POPLOCK Oplock); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlOplockBreakToNoneEx( + IN OUT POPLOCK Oplock, + IN PIRP Irp, + IN ULONG Flags, + IN PVOID Context OPTIONAL, + IN POPLOCK_WAIT_COMPLETE_ROUTINE CompletionRoutine OPTIONAL, + IN POPLOCK_FS_PREPOST_IRP PostIrpRoutine OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlOplockFsctrlEx( + IN POPLOCK Oplock, + IN PIRP Irp, + IN ULONG OpenCount, + IN ULONG Flags); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlOplockKeysEqual( + IN PFILE_OBJECT Fo1 OPTIONAL, + IN PFILE_OBJECT Fo2 OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlInitializeExtraCreateParameterList( + IN OUT PECP_LIST EcpList); + +NTKERNELAPI +VOID +NTAPI +FsRtlInitializeExtraCreateParameter( + IN PECP_HEADER Ecp, + IN ULONG EcpFlags, + IN PFSRTL_EXTRA_CREATE_PARAMETER_CLEANUP_CALLBACK CleanupCallback OPTIONAL, + IN ULONG TotalSize, + IN LPCGUID EcpType, + IN PVOID ListAllocatedFrom OPTIONAL); + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlInsertPerFileContext( + IN PVOID* PerFileContextPointer, + IN PFSRTL_PER_FILE_CONTEXT Ptr); + +NTKERNELAPI +PFSRTL_PER_FILE_CONTEXT +NTAPI +FsRtlLookupPerFileContext( + IN PVOID* PerFileContextPointer, + IN PVOID OwnerId OPTIONAL, + IN PVOID InstanceId OPTIONAL); + +NTKERNELAPI +PFSRTL_PER_FILE_CONTEXT +NTAPI +FsRtlRemovePerFileContext( + IN PVOID* PerFileContextPointer, + IN PVOID OwnerId OPTIONAL, + IN PVOID InstanceId OPTIONAL); + +NTKERNELAPI +VOID +NTAPI +FsRtlTeardownPerFileContexts( + IN PVOID* PerFileContextPointer); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlInsertPerFileObjectContext( + IN PFILE_OBJECT FileObject, + IN PFSRTL_PER_FILEOBJECT_CONTEXT Ptr); + +NTKERNELAPI +PFSRTL_PER_FILEOBJECT_CONTEXT +NTAPI +FsRtlLookupPerFileObjectContext( + IN PFILE_OBJECT FileObject, + IN PVOID OwnerId OPTIONAL, + IN PVOID InstanceId OPTIONAL); + +NTKERNELAPI +PFSRTL_PER_FILEOBJECT_CONTEXT +NTAPI +FsRtlRemovePerFileObjectContext( + IN PFILE_OBJECT FileObject, + IN PVOID OwnerId OPTIONAL, + IN PVOID InstanceId OPTIONAL); + +#define FsRtlFastLock(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11) ( \ + FsRtlPrivateLock(A1, A2, A3, A4, A5, A6, A7, A8, A9, NULL, A10, A11) \ +) + +#define FsRtlAreThereCurrentFileLocks(FL) ( \ + ((FL)->FastIoIsQuestionable) \ +) + +#define FsRtlIncrementLockRequestsInProgress(FL) { \ + ASSERT( (FL)->LockRequestsInProgress >= 0 ); \ + (void) \ + (InterlockedIncrement((LONG volatile *)&((FL)->LockRequestsInProgress)));\ +} + +#define FsRtlDecrementLockRequestsInProgress(FL) { \ + ASSERT( (FL)->LockRequestsInProgress > 0 ); \ + (void) \ + (InterlockedDecrement((LONG volatile *)&((FL)->LockRequestsInProgress)));\ +} + +extern NTKERNELAPI PUSHORT NlsOemLeadByteInfo; +#define NLS_OEM_LEAD_BYTE_INFO NlsOemLeadByteInfo + +#ifdef NLS_MB_CODE_PAGE_TAG +#undef NLS_MB_CODE_PAGE_TAG #endif +#define NLS_MB_CODE_PAGE_TAG NlsMbOemCodePageTag + +/* GCC compatible definition, MS one is retarded */ +extern NTKERNELAPI const UCHAR * const FsRtlLegalAnsiCharacterArray; +#define LEGAL_ANSI_CHARACTER_ARRAY FsRtlLegalAnsiCharacterArray + +#define FsRtlIsAnsiCharacterWild(C) ( \ + FlagOn(FsRtlLegalAnsiCharacterArray[(UCHAR)(C)], FSRTL_WILD_CHARACTER ) \ +) + +#define FsRtlIsAnsiCharacterLegalFat(C, WILD) ( \ + FlagOn(FsRtlLegalAnsiCharacterArray[(UCHAR)(C)], (FSRTL_FAT_LEGAL) | \ + ((WILD) ? FSRTL_WILD_CHARACTER : 0 )) \ +) + +#define FsRtlIsAnsiCharacterLegalHpfs(C, WILD) ( \ + FlagOn(FsRtlLegalAnsiCharacterArray[(UCHAR)(C)], (FSRTL_HPFS_LEGAL) | \ + ((WILD) ? FSRTL_WILD_CHARACTER : 0 )) \ +) + +#define FsRtlIsAnsiCharacterLegalNtfs(C, WILD) ( \ + FlagOn(FsRtlLegalAnsiCharacterArray[(UCHAR)(C)], (FSRTL_NTFS_LEGAL) | \ + ((WILD) ? FSRTL_WILD_CHARACTER : 0 )) \ +) + +#define FsRtlIsAnsiCharacterLegalNtfsStream(C,WILD_OK) ( \ + FsRtlTestAnsiCharacter((C), TRUE, (WILD_OK), FSRTL_NTFS_STREAM_LEGAL) \ +) + +#define FsRtlIsAnsiCharacterLegal(C,FLAGS) ( \ + FsRtlTestAnsiCharacter((C), TRUE, FALSE, (FLAGS)) \ +) + +#define FsRtlTestAnsiCharacter(C, DEFAULT_RET, WILD_OK, FLAGS) ( \ + ((SCHAR)(C) < 0) ? DEFAULT_RET : \ + FlagOn( LEGAL_ANSI_CHARACTER_ARRAY[(C)], \ + (FLAGS) | \ + ((WILD_OK) ? FSRTL_WILD_CHARACTER : 0) ) \ +) + +#define FsRtlIsLeadDbcsCharacter(DBCS_CHAR) ( \ + (BOOLEAN)((UCHAR)(DBCS_CHAR) < 0x80 ? FALSE : \ + (NLS_MB_CODE_PAGE_TAG && \ + (NLS_OEM_LEAD_BYTE_INFO[(UCHAR)(DBCS_CHAR)] != 0))) \ +) + +#define FsRtlIsUnicodeCharacterWild(C) ( \ + (((C) >= 0x40) ? \ + FALSE : \ + FlagOn(FsRtlLegalAnsiCharacterArray[(C)], FSRTL_WILD_CHARACTER )) \ +) + +#define FsRtlInitPerFileContext( _fc, _owner, _inst, _cb) \ + ((_fc)->OwnerId = (_owner), \ + (_fc)->InstanceId = (_inst), \ + (_fc)->FreeCallback = (_cb)) + +#define FsRtlGetPerFileContextPointer(_fo) \ + (FsRtlSupportsPerFileContexts(_fo) ? \ + FsRtlGetPerStreamContextPointer(_fo)->FileContextSupportPointer : \ + NULL) + +#define FsRtlSupportsPerFileContexts(_fo) \ + ((FsRtlGetPerStreamContextPointer(_fo) != NULL) && \ + (FsRtlGetPerStreamContextPointer(_fo)->Version >= FSRTL_FCB_HEADER_V1) && \ + (FsRtlGetPerStreamContextPointer(_fo)->FileContextSupportPointer != NULL)) + +#define FsRtlSetupAdvancedHeaderEx( _advhdr, _fmutx, _fctxptr ) \ +{ \ + FsRtlSetupAdvancedHeader( _advhdr, _fmutx ); \ + if ((_fctxptr) != NULL) { \ + (_advhdr)->FileContextSupportPointer = (_fctxptr); \ + } \ +} + +#define FsRtlGetPerStreamContextPointer(FO) ( \ + (PFSRTL_ADVANCED_FCB_HEADER)(FO)->FsContext \ +) + +#define FsRtlInitPerStreamContext(PSC, O, I, FC) ( \ + (PSC)->OwnerId = (O), \ + (PSC)->InstanceId = (I), \ + (PSC)->FreeCallback = (FC) \ +) + +#define FsRtlSupportsPerStreamContexts(FO) ( \ + (BOOLEAN)((NULL != FsRtlGetPerStreamContextPointer(FO) && \ + FlagOn(FsRtlGetPerStreamContextPointer(FO)->Flags2, \ + FSRTL_FLAG2_SUPPORTS_FILTER_CONTEXTS)) \ +) + +#define FsRtlLookupPerStreamContext(_sc, _oid, _iid) \ + (((NULL != (_sc)) && \ + FlagOn((_sc)->Flags2,FSRTL_FLAG2_SUPPORTS_FILTER_CONTEXTS) && \ + !IsListEmpty(&(_sc)->FilterContexts)) ? \ + FsRtlLookupPerStreamContextInternal((_sc), (_oid), (_iid)) : \ + NULL) + +VOID +FORCEINLINE +NTAPI +FsRtlSetupAdvancedHeader( + IN PVOID AdvHdr, + IN PFAST_MUTEX FMutex ) +{ + PFSRTL_ADVANCED_FCB_HEADER localAdvHdr = (PFSRTL_ADVANCED_FCB_HEADER)AdvHdr; + + localAdvHdr->Flags |= FSRTL_FLAG_ADVANCED_HEADER; + localAdvHdr->Flags2 |= FSRTL_FLAG2_SUPPORTS_FILTER_CONTEXTS; +#if (NTDDI_VERSION >= NTDDI_VISTA) + localAdvHdr->Version = FSRTL_FCB_HEADER_V1; +#else + localAdvHdr->Version = FSRTL_FCB_HEADER_V0; +#endif + InitializeListHead( &localAdvHdr->FilterContexts ); + if (FMutex != NULL) { + localAdvHdr->FastMutex = FMutex; + } +#if (NTDDI_VERSION >= NTDDI_VISTA) + *((PULONG_PTR)(&localAdvHdr->PushLock)) = 0; + localAdvHdr->FileContextSupportPointer = NULL; +#endif +} + +#define FsRtlInitPerFileObjectContext(_fc, _owner, _inst) \ + ((_fc)->OwnerId = (_owner), (_fc)->InstanceId = (_inst)) + +#define FsRtlCompleteRequest(IRP,STATUS) { \ + (IRP)->IoStatus.Status = (STATUS); \ + IoCompleteRequest( (IRP), IO_DISK_INCREMENT ); \ +} + +#if (NTDDI_VERSION >= NTDDI_WIN7) +typedef struct _ECP_HEADER ECP_HEADER, *PECP_HEADER; +#endif + +#if (NTDDI_VERSION >= NTDDI_VISTA) + +typedef enum _NETWORK_OPEN_LOCATION_QUALIFIER { + NetworkOpenLocationAny, + NetworkOpenLocationRemote, + NetworkOpenLocationLoopback +} NETWORK_OPEN_LOCATION_QUALIFIER; + +typedef enum _NETWORK_OPEN_INTEGRITY_QUALIFIER { + NetworkOpenIntegrityAny, + NetworkOpenIntegrityNone, + NetworkOpenIntegritySigned, + NetworkOpenIntegrityEncrypted, + NetworkOpenIntegrityMaximum +} NETWORK_OPEN_INTEGRITY_QUALIFIER; + +#if (NTDDI_VERSION >= NTDDI_WIN7) + +#define NETWORK_OPEN_ECP_IN_FLAG_DISABLE_HANDLE_COLLAPSING 0x1 +#define NETWORK_OPEN_ECP_IN_FLAG_DISABLE_HANDLE_DURABILITY 0x2 +#define NETWORK_OPEN_ECP_IN_FLAG_FORCE_BUFFERED_SYNCHRONOUS_IO_HACK 0x80000000 + +typedef struct _NETWORK_OPEN_ECP_CONTEXT { + USHORT Size; + USHORT Reserved; + struct { + struct { + NETWORK_OPEN_LOCATION_QUALIFIER Location; + NETWORK_OPEN_INTEGRITY_QUALIFIER Integrity; + ULONG Flags; + } in; + struct { + NETWORK_OPEN_LOCATION_QUALIFIER Location; + NETWORK_OPEN_INTEGRITY_QUALIFIER Integrity; + ULONG Flags; + } out; + } DUMMYSTRUCTNAME; +} NETWORK_OPEN_ECP_CONTEXT, *PNETWORK_OPEN_ECP_CONTEXT; + +typedef struct _NETWORK_OPEN_ECP_CONTEXT_V0 { + USHORT Size; + USHORT Reserved; + struct { + struct { + NETWORK_OPEN_LOCATION_QUALIFIER Location; + NETWORK_OPEN_INTEGRITY_QUALIFIER Integrity; + } in; + struct { + NETWORK_OPEN_LOCATION_QUALIFIER Location; + NETWORK_OPEN_INTEGRITY_QUALIFIER Integrity; + } out; + } DUMMYSTRUCTNAME; +} NETWORK_OPEN_ECP_CONTEXT_V0, *PNETWORK_OPEN_ECP_CONTEXT_V0; + +#elif (NTDDI_VERSION >= NTDDI_VISTA) +typedef struct _NETWORK_OPEN_ECP_CONTEXT { + USHORT Size; + USHORT Reserved; + struct { + struct { + NETWORK_OPEN_LOCATION_QUALIFIER Location; + NETWORK_OPEN_INTEGRITY_QUALIFIER Integrity; + } in; + struct { + NETWORK_OPEN_LOCATION_QUALIFIER Location; + NETWORK_OPEN_INTEGRITY_QUALIFIER Integrity; + } out; + } DUMMYSTRUCTNAME; +} NETWORK_OPEN_ECP_CONTEXT, *PNETWORK_OPEN_ECP_CONTEXT; +#endif + +DEFINE_GUID(GUID_ECP_NETWORK_OPEN_CONTEXT, 0xc584edbf, 0x00df, 0x4d28, 0xb8, 0x84, 0x35, 0xba, 0xca, 0x89, 0x11, 0xe8 ); + +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + + +#if (NTDDI_VERSION >= NTDDI_VISTA) + +typedef struct _PREFETCH_OPEN_ECP_CONTEXT { + PVOID Context; +} PREFETCH_OPEN_ECP_CONTEXT, *PPREFETCH_OPEN_ECP_CONTEXT; + +DEFINE_GUID(GUID_ECP_PREFETCH_OPEN, 0xe1777b21, 0x847e, 0x4837, 0xaa, 0x45, 0x64, 0x16, 0x1d, 0x28, 0x6, 0x55 ); + +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + +#if (NTDDI_VERSION >= NTDDI_WIN7) + +DEFINE_GUID (GUID_ECP_NFS_OPEN, 0xf326d30c, 0xe5f8, 0x4fe7, 0xab, 0x74, 0xf5, 0xa3, 0x19, 0x6d, 0x92, 0xdb); +DEFINE_GUID(GUID_ECP_SRV_OPEN, 0xbebfaebc, 0xaabf, 0x489d, 0x9d, 0x2c, 0xe9, 0xe3, 0x61, 0x10, 0x28, 0x53 ); + +typedef struct sockaddr_storage *PSOCKADDR_STORAGE_NFS; + +typedef struct _NFS_OPEN_ECP_CONTEXT { + PUNICODE_STRING ExportAlias; + PSOCKADDR_STORAGE_NFS ClientSocketAddress; +} NFS_OPEN_ECP_CONTEXT, *PNFS_OPEN_ECP_CONTEXT, **PPNFS_OPEN_ECP_CONTEXT; + +typedef struct _SRV_OPEN_ECP_CONTEXT { + PUNICODE_STRING ShareName; + PSOCKADDR_STORAGE_NFS SocketAddress; + BOOLEAN OplockBlockState; + BOOLEAN OplockAppState; + BOOLEAN OplockFinalState; +} SRV_OPEN_ECP_CONTEXT, *PSRV_OPEN_ECP_CONTEXT; + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + +#define VACB_MAPPING_GRANULARITY (0x40000) +#define VACB_OFFSET_SHIFT (18) + +typedef struct _PUBLIC_BCB { + CSHORT NodeTypeCode; + CSHORT NodeByteSize; + ULONG MappedLength; + LARGE_INTEGER MappedFileOffset; +} PUBLIC_BCB, *PPUBLIC_BCB; + +typedef struct _CC_FILE_SIZES { + LARGE_INTEGER AllocationSize; + LARGE_INTEGER FileSize; + LARGE_INTEGER ValidDataLength; +} CC_FILE_SIZES, *PCC_FILE_SIZES; + +typedef BOOLEAN +(NTAPI *PACQUIRE_FOR_LAZY_WRITE) ( + IN PVOID Context, + IN BOOLEAN Wait); + +typedef VOID +(NTAPI *PRELEASE_FROM_LAZY_WRITE) ( + IN PVOID Context); + +typedef BOOLEAN +(NTAPI *PACQUIRE_FOR_READ_AHEAD) ( + IN PVOID Context, + IN BOOLEAN Wait); + +typedef VOID +(NTAPI *PRELEASE_FROM_READ_AHEAD) ( + IN PVOID Context); + +typedef struct _CACHE_MANAGER_CALLBACKS { + PACQUIRE_FOR_LAZY_WRITE AcquireForLazyWrite; + PRELEASE_FROM_LAZY_WRITE ReleaseFromLazyWrite; + PACQUIRE_FOR_READ_AHEAD AcquireForReadAhead; + PRELEASE_FROM_READ_AHEAD ReleaseFromReadAhead; +} CACHE_MANAGER_CALLBACKS, *PCACHE_MANAGER_CALLBACKS; + +typedef struct _CACHE_UNINITIALIZE_EVENT { + struct _CACHE_UNINITIALIZE_EVENT *Next; + KEVENT Event; +} CACHE_UNINITIALIZE_EVENT, *PCACHE_UNINITIALIZE_EVENT; + +typedef VOID +(NTAPI *PDIRTY_PAGE_ROUTINE) ( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN PLARGE_INTEGER OldestLsn, + IN PLARGE_INTEGER NewestLsn, + IN PVOID Context1, + IN PVOID Context2); + +typedef VOID +(NTAPI *PFLUSH_TO_LSN) ( + IN PVOID LogHandle, + IN LARGE_INTEGER Lsn); + +typedef VOID +(NTAPI *PCC_POST_DEFERRED_WRITE) ( + IN PVOID Context1, + IN PVOID Context2); + +#define CcIsFileCached(FO) ( \ + ((FO)->SectionObjectPointer != NULL) && \ + (((PSECTION_OBJECT_POINTERS)(FO)->SectionObjectPointer)->SharedCacheMap != NULL) \ +) + +extern ULONG CcFastMdlReadWait; + +#if (NTDDI_VERSION >= NTDDI_WIN2K) + +NTKERNELAPI +VOID +NTAPI +CcInitializeCacheMap( + IN PFILE_OBJECT FileObject, + IN PCC_FILE_SIZES FileSizes, + IN BOOLEAN PinAccess, + IN PCACHE_MANAGER_CALLBACKS Callbacks, + IN PVOID LazyWriteContext); + +NTKERNELAPI +BOOLEAN +NTAPI +CcUninitializeCacheMap( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER TruncateSize OPTIONAL, + IN PCACHE_UNINITIALIZE_EVENT UninitializeCompleteEvent OPTIONAL); + +NTKERNELAPI +VOID +NTAPI +CcSetFileSizes( + IN PFILE_OBJECT FileObject, + IN PCC_FILE_SIZES FileSizes); + +NTKERNELAPI +VOID +NTAPI +CcSetDirtyPageThreshold( + IN PFILE_OBJECT FileObject, + IN ULONG DirtyPageThreshold); + +NTKERNELAPI +VOID +NTAPI +CcFlushCache( + IN PSECTION_OBJECT_POINTERS SectionObjectPointer, + IN PLARGE_INTEGER FileOffset OPTIONAL, + IN ULONG Length, + OUT PIO_STATUS_BLOCK IoStatus OPTIONAL); + +NTKERNELAPI +LARGE_INTEGER +NTAPI +CcGetFlushedValidData( + IN PSECTION_OBJECT_POINTERS SectionObjectPointer, + IN BOOLEAN BcbListHeld); + +NTKERNELAPI +BOOLEAN +NTAPI +CcZeroData( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER StartOffset, + IN PLARGE_INTEGER EndOffset, + IN BOOLEAN Wait); + +NTKERNELAPI +PVOID +NTAPI +CcRemapBcb( + IN PVOID Bcb); + +NTKERNELAPI +VOID +NTAPI +CcRepinBcb( + IN PVOID Bcb); + +NTKERNELAPI +VOID +NTAPI +CcUnpinRepinnedBcb( + IN PVOID Bcb, + IN BOOLEAN WriteThrough, + OUT PIO_STATUS_BLOCK IoStatus); + +NTKERNELAPI +PFILE_OBJECT +NTAPI +CcGetFileObjectFromSectionPtrs( + IN PSECTION_OBJECT_POINTERS SectionObjectPointer); + +NTKERNELAPI +PFILE_OBJECT +NTAPI +CcGetFileObjectFromBcb( + IN PVOID Bcb); + +NTKERNELAPI +BOOLEAN +NTAPI +CcCanIWrite( + IN PFILE_OBJECT FileObject, + IN ULONG BytesToWrite, + IN BOOLEAN Wait, + IN BOOLEAN Retrying); + +NTKERNELAPI +VOID +NTAPI +CcDeferWrite( + IN PFILE_OBJECT FileObject, + IN PCC_POST_DEFERRED_WRITE PostRoutine, + IN PVOID Context1, + IN PVOID Context2, + IN ULONG BytesToWrite, + IN BOOLEAN Retrying); + +NTKERNELAPI +BOOLEAN +NTAPI +CcCopyRead( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN BOOLEAN Wait, + OUT PVOID Buffer, + OUT PIO_STATUS_BLOCK IoStatus); + +NTKERNELAPI +VOID +NTAPI +CcFastCopyRead( + IN PFILE_OBJECT FileObject, + IN ULONG FileOffset, + IN ULONG Length, + IN ULONG PageCount, + OUT PVOID Buffer, + OUT PIO_STATUS_BLOCK IoStatus); + +NTKERNELAPI +BOOLEAN +NTAPI +CcCopyWrite( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN BOOLEAN Wait, + IN PVOID Buffer); + +NTKERNELAPI +VOID +NTAPI +CcFastCopyWrite( + IN PFILE_OBJECT FileObject, + IN ULONG FileOffset, + IN ULONG Length, + IN PVOID Buffer); + +NTKERNELAPI +VOID +NTAPI +CcMdlRead( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + OUT PMDL *MdlChain, + OUT PIO_STATUS_BLOCK IoStatus); + +NTKERNELAPI +VOID +NTAPI +CcMdlReadComplete( + IN PFILE_OBJECT FileObject, + IN PMDL MdlChain); + +NTKERNELAPI +VOID +NTAPI +CcPrepareMdlWrite( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + OUT PMDL *MdlChain, + OUT PIO_STATUS_BLOCK IoStatus); + +NTKERNELAPI +VOID +NTAPI +CcMdlWriteComplete( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN PMDL MdlChain); + +NTKERNELAPI +VOID +NTAPI +CcScheduleReadAhead( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length); + +NTKERNELAPI +NTSTATUS +NTAPI +CcWaitForCurrentLazyWriterActivity( + VOID); + +NTKERNELAPI +VOID +NTAPI +CcSetReadAheadGranularity( + IN PFILE_OBJECT FileObject, + IN ULONG Granularity); + +NTKERNELAPI +BOOLEAN +NTAPI +CcPinRead( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN ULONG Flags, + OUT PVOID *Bcb, + OUT PVOID *Buffer); + +NTKERNELAPI +BOOLEAN +NTAPI +CcPinMappedData( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN ULONG Flags, + IN OUT PVOID *Bcb); + +NTKERNELAPI +BOOLEAN +NTAPI +CcPreparePinWrite( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN BOOLEAN Zero, + IN ULONG Flags, + OUT PVOID *Bcb, + OUT PVOID *Buffer); + +NTKERNELAPI +VOID +NTAPI +CcSetDirtyPinnedData( + IN PVOID BcbVoid, + IN PLARGE_INTEGER Lsn OPTIONAL); + +NTKERNELAPI +VOID +NTAPI +CcUnpinData( + IN PVOID Bcb); + +NTKERNELAPI +VOID +NTAPI +CcSetBcbOwnerPointer( + IN PVOID Bcb, + IN PVOID OwnerPointer); + +NTKERNELAPI +VOID +NTAPI +CcUnpinDataForThread( + IN PVOID Bcb, + IN ERESOURCE_THREAD ResourceThreadId); + +NTKERNELAPI +VOID +NTAPI +CcSetAdditionalCacheAttributes( + IN PFILE_OBJECT FileObject, + IN BOOLEAN DisableReadAhead, + IN BOOLEAN DisableWriteBehind); + +NTKERNELAPI +BOOLEAN +NTAPI +CcIsThereDirtyData( + IN PVPB Vpb); + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ + +#if (NTDDI_VERSION >= NTDDI_WINXP) + +NTKERNELAPI +VOID +NTAPI +CcMdlWriteAbort( + IN PFILE_OBJECT FileObject, + IN PMDL MdlChain); + +NTKERNELAPI +VOID +NTAPI +CcSetLogHandleForFile( + IN PFILE_OBJECT FileObject, + IN PVOID LogHandle, + IN PFLUSH_TO_LSN FlushToLsnRoutine); + +NTKERNELAPI +LARGE_INTEGER +NTAPI +CcGetDirtyPages( + IN PVOID LogHandle, + IN PDIRTY_PAGE_ROUTINE DirtyPageRoutine, + IN PVOID Context1, + IN PVOID Context2); + +#endif + +#if (NTDDI_VERSION >= NTDDI_WINXP) +NTKERNELAPI +BOOLEAN +NTAPI +CcMapData( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN ULONG Flags, + OUT PVOID *Bcb, + OUT PVOID *Buffer); +#elif (NTDDI_VERSION >= NTDDI_WIN2K) +NTKERNELAPI +BOOLEAN +NTAPI +CcMapData( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN BOOLEAN Wait, + OUT PVOID *Bcb, + OUT PVOID *Buffer); +#endif + +#if (NTDDI_VERSION >= NTDDI_VISTA) + +NTKERNELAPI +NTSTATUS +NTAPI +CcSetFileSizesEx( + IN PFILE_OBJECT FileObject, + IN PCC_FILE_SIZES FileSizes); + +NTKERNELAPI +PFILE_OBJECT +NTAPI +CcGetFileObjectFromSectionPtrsRef( + IN PSECTION_OBJECT_POINTERS SectionObjectPointer); + +NTKERNELAPI +VOID +NTAPI +CcSetParallelFlushFile( + IN PFILE_OBJECT FileObject, + IN BOOLEAN EnableParallelFlush); + +NTKERNELAPI +BOOLEAN +CcIsThereDirtyDataEx( + IN PVPB Vpb, + IN PULONG NumberOfDirtyPages OPTIONAL); + +#endif + +#if (NTDDI_VERSION >= NTDDI_WIN7) +NTKERNELAPI +VOID +NTAPI +CcCoherencyFlushAndPurgeCache( + IN PSECTION_OBJECT_POINTERS SectionObjectPointer, + IN PLARGE_INTEGER FileOffset OPTIONAL, + IN ULONG Length, + OUT PIO_STATUS_BLOCK IoStatus, + IN ULONG Flags OPTIONAL); +#endif + +#define CcGetFileSizePointer(FO) ( \ + ((PLARGE_INTEGER)((FO)->SectionObjectPointer->SharedCacheMap) + 1) \ +) + +#define UNINITIALIZE_CACHE_MAPS (1) +#define DO_NOT_RETRY_PURGE (2) +#define DO_NOT_PURGE_DIRTY_PAGES (0x4) + +#define CC_FLUSH_AND_PURGE_NO_PURGE (0x1) + +#if (NTDDI_VERSION >= NTDDI_VISTA) +NTKERNELAPI +BOOLEAN +NTAPI +CcPurgeCacheSection( + IN PSECTION_OBJECT_POINTERS SectionObjectPointer, + IN PLARGE_INTEGER FileOffset OPTIONAL, + IN ULONG Length, + IN ULONG Flags); +#elif (NTDDI_VERSION >= NTDDI_WIN2K) +NTKERNELAPI +BOOLEAN +NTAPI +CcPurgeCacheSection( + IN PSECTION_OBJECT_POINTERS SectionObjectPointer, + IN PLARGE_INTEGER FileOffset OPTIONAL, + IN ULONG Length, + IN BOOLEAN UninitializeCacheMaps); +#endif + +#if (NTDDI_VERSION >= NTDDI_WIN7) +NTKERNELAPI +BOOLEAN +NTAPI +CcCopyWriteWontFlush( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length); +#else +#define CcCopyWriteWontFlush(FO, FOFF, LEN) ((LEN) <= 0x10000) +#endif + +#define CcReadAhead(FO, FOFF, LEN) ( \ + if ((LEN) >= 256) { \ + CcScheduleReadAhead((FO), (FOFF), (LEN)); \ + } \ +) + +#define PIN_WAIT (1) +#define PIN_EXCLUSIVE (2) +#define PIN_NO_READ (4) +#define PIN_IF_BCB (8) +#define PIN_CALLER_TRACKS_DIRTY_DATA (32) +#define PIN_HIGH_PRIORITY (64) + +#define MAP_WAIT 1 +#define MAP_NO_READ (16) +#define MAP_HIGH_PRIORITY (64) + +#define IOCTL_REDIR_QUERY_PATH CTL_CODE(FILE_DEVICE_NETWORK_FILE_SYSTEM, 99, METHOD_NEITHER, FILE_ANY_ACCESS) +#define IOCTL_REDIR_QUERY_PATH_EX CTL_CODE(FILE_DEVICE_NETWORK_FILE_SYSTEM, 100, METHOD_NEITHER, FILE_ANY_ACCESS) + +typedef struct _QUERY_PATH_REQUEST { + ULONG PathNameLength; + PIO_SECURITY_CONTEXT SecurityContext; + WCHAR FilePathName[1]; +} QUERY_PATH_REQUEST, *PQUERY_PATH_REQUEST; + +typedef struct _QUERY_PATH_REQUEST_EX { + PIO_SECURITY_CONTEXT pSecurityContext; + ULONG EaLength; + PVOID pEaBuffer; + UNICODE_STRING PathName; + UNICODE_STRING DomainServiceName; + ULONG_PTR Reserved[ 3 ]; +} QUERY_PATH_REQUEST_EX, *PQUERY_PATH_REQUEST_EX; + +typedef struct _QUERY_PATH_RESPONSE { + ULONG LengthAccepted; +} QUERY_PATH_RESPONSE, *PQUERY_PATH_RESPONSE; + +#define VOLSNAPCONTROLTYPE 0x00000053 +#define IOCTL_VOLSNAP_FLUSH_AND_HOLD_WRITES CTL_CODE(VOLSNAPCONTROLTYPE, 0, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) + +#if (NTDDI_VERSION >= NTDDI_WIN2K) + +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryObject( + IN HANDLE Handle OPTIONAL, + IN OBJECT_INFORMATION_CLASS ObjectInformationClass, + OUT PVOID ObjectInformation OPTIONAL, + IN ULONG ObjectInformationLength, + OUT PULONG ReturnLength OPTIONAL); + +NTSYSAPI +NTSTATUS +NTAPI +ZwNotifyChangeKey( + IN HANDLE KeyHandle, + IN HANDLE EventHandle OPTIONAL, + IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, + IN PVOID ApcContext OPTIONAL, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN ULONG NotifyFilter, + IN BOOLEAN WatchSubtree, + OUT PVOID Buffer, + IN ULONG BufferLength, + IN BOOLEAN Asynchronous); + +NTSYSAPI +NTSTATUS +NTAPI +ZwCreateEvent( + OUT PHANDLE EventHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, + IN EVENT_TYPE EventType, + IN BOOLEAN InitialState); + +NTSYSAPI +NTSTATUS +NTAPI +ZwDeleteFile( + IN POBJECT_ATTRIBUTES ObjectAttributes); + +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryDirectoryFile( + IN HANDLE FileHandle, + IN HANDLE Event OPTIONAL, + IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, + IN PVOID ApcContext OPTIONAL, + OUT PIO_STATUS_BLOCK IoStatusBlock, + OUT PVOID FileInformation, + IN ULONG Length, + IN FILE_INFORMATION_CLASS FileInformationClass, + IN BOOLEAN ReturnSingleEntry, + IN PUNICODE_STRING FileName OPTIONAL, + IN BOOLEAN RestartScan); + +NTSYSAPI +NTSTATUS +NTAPI +ZwSetVolumeInformationFile( + IN HANDLE FileHandle, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN PVOID FsInformation, + IN ULONG Length, + IN FS_INFORMATION_CLASS FsInformationClass); + +NTSYSAPI +NTSTATUS +NTAPI +ZwFsControlFile( + IN HANDLE FileHandle, + IN HANDLE Event OPTIONAL, + IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, + IN PVOID ApcContext OPTIONAL, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN ULONG FsControlCode, + IN PVOID InputBuffer OPTIONAL, + IN ULONG InputBufferLength, + OUT PVOID OutputBuffer OPTIONAL, + IN ULONG OutputBufferLength); + +NTSYSAPI +NTSTATUS +NTAPI +ZwDuplicateObject( + IN HANDLE SourceProcessHandle, + IN HANDLE SourceHandle, + IN HANDLE TargetProcessHandle OPTIONAL, + OUT PHANDLE TargetHandle OPTIONAL, + IN ACCESS_MASK DesiredAccess, + IN ULONG HandleAttributes, + IN ULONG Options); + +NTSYSAPI +NTSTATUS +NTAPI +ZwOpenDirectoryObject( + OUT PHANDLE DirectoryHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes); + +NTSYSAPI +NTSTATUS +NTAPI +ZwAllocateVirtualMemory( + IN HANDLE ProcessHandle, + IN OUT PVOID *BaseAddress, + IN ULONG_PTR ZeroBits, + IN OUT PSIZE_T RegionSize, + IN ULONG AllocationType, + IN ULONG Protect); + +NTSYSAPI +NTSTATUS +NTAPI +ZwFreeVirtualMemory( + IN HANDLE ProcessHandle, + IN OUT PVOID *BaseAddress, + IN OUT PSIZE_T RegionSize, + IN ULONG FreeType); + +NTSYSAPI +NTSTATUS +NTAPI +ZwWaitForSingleObject( + IN HANDLE Handle, + IN BOOLEAN Alertable, + IN PLARGE_INTEGER Timeout OPTIONAL); + +NTSYSAPI +NTSTATUS +NTAPI +ZwSetEvent( + IN HANDLE EventHandle, + OUT PLONG PreviousState OPTIONAL); + +NTSYSAPI +NTSTATUS +NTAPI +ZwFlushVirtualMemory( + IN HANDLE ProcessHandle, + IN OUT PVOID *BaseAddress, + IN OUT PSIZE_T RegionSize, + OUT PIO_STATUS_BLOCK IoStatusBlock); + +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryInformationToken( + IN HANDLE TokenHandle, + IN TOKEN_INFORMATION_CLASS TokenInformationClass, + OUT PVOID TokenInformation, + IN ULONG Length, + OUT PULONG ResultLength); + +NTSYSAPI +NTSTATUS +NTAPI +ZwSetSecurityObject( + IN HANDLE Handle, + IN SECURITY_INFORMATION SecurityInformation, + IN PSECURITY_DESCRIPTOR SecurityDescriptor); + +NTSYSAPI +NTSTATUS +NTAPI +ZwQuerySecurityObject( + IN HANDLE FileHandle, + IN SECURITY_INFORMATION SecurityInformation, + OUT PSECURITY_DESCRIPTOR SecurityDescriptor, + IN ULONG Length, + OUT PULONG ResultLength); + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ + +#if (NTDDI_VERSION >= NTDDI_WINXP) + +NTSYSAPI +NTSTATUS +NTAPI +ZwOpenProcessTokenEx( + IN HANDLE ProcessHandle, + IN ACCESS_MASK DesiredAccess, + IN ULONG HandleAttributes, + OUT PHANDLE TokenHandle); + +NTSYSAPI +NTSTATUS +NTAPI +ZwOpenThreadTokenEx( + IN HANDLE ThreadHandle, + IN ACCESS_MASK DesiredAccess, + IN BOOLEAN OpenAsSelf, + IN ULONG HandleAttributes, + OUT PHANDLE TokenHandle); + +#endif + +#if (NTDDI_VERSION >= NTDDI_VISTA) + +NTSYSAPI +NTSTATUS +NTAPI +ZwLockFile( + IN HANDLE FileHandle, + IN HANDLE Event OPTIONAL, + IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, + IN PVOID ApcContext OPTIONAL, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN PLARGE_INTEGER ByteOffset, + IN PLARGE_INTEGER Length, + IN ULONG Key, + IN BOOLEAN FailImmediately, + IN BOOLEAN ExclusiveLock); + +NTSYSAPI +NTSTATUS +NTAPI +ZwUnlockFile( + IN HANDLE FileHandle, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN PLARGE_INTEGER ByteOffset, + IN PLARGE_INTEGER Length, + IN ULONG Key); + +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryQuotaInformationFile( + IN HANDLE FileHandle, + OUT PIO_STATUS_BLOCK IoStatusBlock, + OUT PVOID Buffer, + IN ULONG Length, + IN BOOLEAN ReturnSingleEntry, + IN PVOID SidList, + IN ULONG SidListLength, + IN PSID StartSid OPTIONAL, + IN BOOLEAN RestartScan); + +NTSYSAPI +NTSTATUS +NTAPI +ZwSetQuotaInformationFile( + IN HANDLE FileHandle, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN PVOID Buffer, + IN ULONG Length); + +NTSYSAPI +NTSTATUS +NTAPI +ZwFlushBuffersFile( + IN HANDLE FileHandle, + OUT PIO_STATUS_BLOCK IoStatusBlock); + +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + +#if (NTDDI_VERSION >= NTDDI_WIN7) +NTSYSAPI +NTSTATUS +NTAPI +ZwSetInformationToken( + IN HANDLE TokenHandle, + IN TOKEN_INFORMATION_CLASS TokenInformationClass, + IN PVOID TokenInformation, + IN ULONG TokenInformationLength); +#endif + +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryEaFile( + IN HANDLE FileHandle, + OUT PIO_STATUS_BLOCK IoStatusBlock, + OUT PVOID Buffer, + IN ULONG Length, + IN BOOLEAN ReturnSingleEntry, + IN PVOID EaList OPTIONAL, + IN ULONG EaListLength, + IN PULONG EaIndex OPTIONAL, + IN BOOLEAN RestartScan); + +NTSYSAPI +NTSTATUS +NTAPI +ZwSetEaFile( + IN HANDLE FileHandle, + OUT PIO_STATUS_BLOCK IoStatusBlock, + OUT PVOID Buffer, + IN ULONG Length); + +NTSYSAPI +NTSTATUS +NTAPI +ZwDuplicateToken( + IN HANDLE ExistingTokenHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN BOOLEAN EffectiveOnly, + IN TOKEN_TYPE TokenType, + OUT PHANDLE NewTokenHandle); #pragma pack(push,4) @@ -6863,11 +8890,6 @@ FsRtlAreThereCurrentOrInProgressFileLocks( #include "csq.h" -#ifdef _NTOSKRNL_ -extern PUCHAR FsRtlLegalAnsiCharacterArray; -#else -extern DECLSPEC_IMPORT PUCHAR FsRtlLegalAnsiCharacterArray; -#endif extern PACL SePublicDefaultDacl; extern PACL SeSystemDefaultDacl; @@ -6890,30 +8912,11 @@ extern PACL SeSystemDefaultDacl; #define FILE_VC_QUOTAS_LOG_VIOLATIONS 0x00000004 -#define FSRTL_VOLUME_DISMOUNT 1 -#define FSRTL_VOLUME_DISMOUNT_FAILED 2 -#define FSRTL_VOLUME_LOCK 3 -#define FSRTL_VOLUME_LOCK_FAILED 4 -#define FSRTL_VOLUME_UNLOCK 5 -#define FSRTL_VOLUME_MOUNT 6 - -#define FSRTL_WILD_CHARACTER 0x08 - -#define FSRTL_FAT_LEGAL 0x01 -#define FSRTL_HPFS_LEGAL 0x02 -#define FSRTL_NTFS_LEGAL 0x04 -#define FSRTL_WILD_CHARACTER 0x08 -#define FSRTL_OLE_LEGAL 0x10 -#define FSRTL_NTFS_STREAM_LEGAL 0x14 - #ifdef _X86_ #define HARDWARE_PTE HARDWARE_PTE_X86 #define PHARDWARE_PTE PHARDWARE_PTE_X86 #endif -#define IO_CHECK_CREATE_PARAMETERS 0x0200 -#define IO_ATTACH_DEVICE 0x0400 - #define IO_ATTACH_DEVICE_API 0x80000000 #define IO_TYPE_APC 18 @@ -6932,8 +8935,6 @@ extern PACL SeSystemDefaultDacl; #define MEM_DOS_LIM 0x40000000 -#define MCB_FLAG_RAISE_ON_ALLOCATION_FAILURE 1 - #define OB_TYPE_TYPE 1 #define OB_TYPE_DIRECTORY 2 #define OB_TYPE_SYMBOLIC_LINK 3 @@ -6958,23 +8959,12 @@ extern PACL SeSystemDefaultDacl; #define OB_TYPE_IO_COMPLETION 22 #define OB_TYPE_FILE 23 -#define PIN_WAIT (1) -#define PIN_EXCLUSIVE (2) -#define PIN_NO_READ (4) -#define PIN_IF_BCB (8) - #define SEC_BASED 0x00200000 -#define SECURITY_WORLD_SID_AUTHORITY {0,0,0,0,0,1} -#define SECURITY_WORLD_RID (0x00000000L) - /* end winnt.h */ #define TOKEN_HAS_ADMIN_GROUP 0x08 -#define VACB_MAPPING_GRANULARITY (0x40000) -#define VACB_OFFSET_SHIFT (18) - #if (VER_PRODUCTBUILD >= 1381) #define FSCTL_GET_HFS_INFORMATION CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 31, METHOD_BUFFERED, FILE_ANY_ACCESS) #endif /* (VER_PRODUCTBUILD >= 1381) */ @@ -7001,18 +8991,6 @@ extern PACL SeSystemDefaultDacl; #define FSCTL_NETWORK_SET_DOMAIN_NAME CTL_CODE(FILE_DEVICE_NETWORK_FILE_SYSTEM, 120, METHOD_BUFFERED, FILE_ANY_ACCESS) #define FSCTL_NETWORK_REMOTE_BOOT_INIT_SCRT CTL_CODE(FILE_DEVICE_NETWORK_FILE_SYSTEM, 250, METHOD_BUFFERED, FILE_ANY_ACCESS) -#define IOCTL_REDIR_QUERY_PATH CTL_CODE(FILE_DEVICE_NETWORK_FILE_SYSTEM, 99, METHOD_NEITHER, FILE_ANY_ACCESS) - -typedef PVOID OPLOCK, *POPLOCK; - -// -// Forwarders -// -struct _RTL_AVL_TABLE; -struct _RTL_GENERIC_TABLE; - -typedef PVOID PNOTIFY_SYNC; - typedef enum _FILE_STORAGE_TYPE { StorageTypeDefault = 1, StorageTypeDirectory, @@ -7048,17 +9026,6 @@ typedef struct _BITMAP_RANGE { PULONG Bitmap; } BITMAP_RANGE, *PBITMAP_RANGE; -typedef struct _CACHE_UNINITIALIZE_EVENT { - struct _CACHE_UNINITIALIZE_EVENT *Next; - KEVENT Event; -} CACHE_UNINITIALIZE_EVENT, *PCACHE_UNINITIALIZE_EVENT; - -typedef struct _CC_FILE_SIZES { - LARGE_INTEGER AllocationSize; - LARGE_INTEGER FileSize; - LARGE_INTEGER ValidDataLength; -} CC_FILE_SIZES, *PCC_FILE_SIZES; - typedef struct _FILE_COPY_ON_WRITE_INFORMATION { BOOLEAN ReplaceIfExists; HANDLE RootDirectory; @@ -7081,49 +9048,6 @@ typedef struct _FILE_FULL_DIRECTORY_INFORMATION { WCHAR FileName[ANYSIZE_ARRAY]; } FILE_FULL_DIRECTORY_INFORMATION, *PFILE_FULL_DIRECTORY_INFORMATION; -typedef struct _FILE_FS_FULL_SIZE_INFORMATION { - LARGE_INTEGER TotalAllocationUnits; - LARGE_INTEGER CallerAvailableAllocationUnits; - LARGE_INTEGER ActualAvailableAllocationUnits; - ULONG SectorsPerAllocationUnit; - ULONG BytesPerSector; -} FILE_FS_FULL_SIZE_INFORMATION, *PFILE_FS_FULL_SIZE_INFORMATION; - -typedef struct _FILE_FS_LABEL_INFORMATION { - ULONG VolumeLabelLength; - WCHAR VolumeLabel[1]; -} FILE_FS_LABEL_INFORMATION, *PFILE_FS_LABEL_INFORMATION; - -#if (VER_PRODUCTBUILD >= 2195) - -typedef struct _FILE_FS_OBJECT_ID_INFORMATION { - UCHAR ObjectId[16]; - UCHAR ExtendedInfo[48]; -} FILE_FS_OBJECT_ID_INFORMATION, *PFILE_FS_OBJECT_ID_INFORMATION; - -#endif /* (VER_PRODUCTBUILD >= 2195) */ - -typedef struct _FILE_FS_SIZE_INFORMATION { - LARGE_INTEGER TotalAllocationUnits; - LARGE_INTEGER AvailableAllocationUnits; - ULONG SectorsPerAllocationUnit; - ULONG BytesPerSector; -} FILE_FS_SIZE_INFORMATION, *PFILE_FS_SIZE_INFORMATION; - -typedef struct _FILE_FS_VOLUME_INFORMATION { - LARGE_INTEGER VolumeCreationTime; - ULONG VolumeSerialNumber; - ULONG VolumeLabelLength; - BOOLEAN SupportsObjects; - WCHAR VolumeLabel[1]; -} FILE_FS_VOLUME_INFORMATION, *PFILE_FS_VOLUME_INFORMATION; - -typedef struct _FILE_FS_OBJECTID_INFORMATION -{ - UCHAR ObjectId[16]; - UCHAR ExtendedInfo[48]; -} FILE_FS_OBJECTID_INFORMATION, *PFILE_FS_OBJECTID_INFORMATION; - /* raw internal file lock struct returned from FsRtlGetNextFileLock */ typedef struct _FILE_SHARED_LOCK_ENTRY { PVOID Unknown1; @@ -7208,51 +9132,6 @@ typedef struct _FILE_OLE_STATE_BITS_INFORMATION { ULONG StateBitsMask; } FILE_OLE_STATE_BITS_INFORMATION, *PFILE_OLE_STATE_BITS_INFORMATION; -typedef enum _FSRTL_COMPARISON_RESULT -{ - LessThan = -1, - EqualTo = 0, - GreaterThan = 1 -} FSRTL_COMPARISON_RESULT; - -#if (VER_PRODUCTBUILD >= 2600) - -typedef struct _FSRTL_PER_STREAM_CONTEXT { - LIST_ENTRY Links; - PVOID OwnerId; - PVOID InstanceId; - PFREE_FUNCTION FreeCallback; -} FSRTL_PER_STREAM_CONTEXT, *PFSRTL_PER_STREAM_CONTEXT; - -typedef struct _FSRTL_PER_FILEOBJECT_CONTEXT -{ - LIST_ENTRY Links; - PVOID OwnerId; - PVOID InstanceId; -} FSRTL_PER_FILEOBJECT_CONTEXT, *PFSRTL_PER_FILEOBJECT_CONTEXT; - -#endif /* (VER_PRODUCTBUILD >= 2600) */ - -typedef struct _BASE_MCB -{ - ULONG MaximumPairCount; - ULONG PairCount; - USHORT PoolType; - USHORT Flags; - PVOID Mapping; -} BASE_MCB, *PBASE_MCB; - -typedef struct _LARGE_MCB -{ - PKGUARDED_MUTEX GuardedMutex; - BASE_MCB BaseMcb; -} LARGE_MCB, *PLARGE_MCB; - -typedef struct _MCB -{ - LARGE_MCB DummyFieldThatSizesThisStructureCorrectly; -} MCB, *PMCB; - typedef struct _MAPPING_PAIR { ULONGLONG Vcn; ULONGLONG Lcn; @@ -7264,8 +9143,6 @@ typedef struct _GET_RETRIEVAL_DESCRIPTOR { MAPPING_PAIR Pair[1]; } GET_RETRIEVAL_DESCRIPTOR, *PGET_RETRIEVAL_DESCRIPTOR; -#define ASSERT_QUEUE(Q) ASSERT(((Q)->Header.Type & KOBJECT_TYPE_MASK) == QueueObject); - typedef struct _MBCB { CSHORT NodeTypeCode; CSHORT NodeIsInZone; @@ -7328,189 +9205,6 @@ typedef struct _OBJECT_ALL_TYPES_INFO { OBJECT_TYPE_INFO ObjectsTypeInfo[1]; } OBJECT_ALL_TYPES_INFO, *POBJECT_ALL_TYPES_INFO; -typedef enum _RTL_GENERIC_COMPARE_RESULTS -{ - GenericLessThan, - GenericGreaterThan, - GenericEqual -} RTL_GENERIC_COMPARE_RESULTS; - -typedef enum _TABLE_SEARCH_RESULT -{ - TableEmptyTree, - TableFoundNode, - TableInsertAsLeft, - TableInsertAsRight -} TABLE_SEARCH_RESULT; - -typedef NTSTATUS -(NTAPI *PRTL_AVL_MATCH_FUNCTION)( - struct _RTL_AVL_TABLE *Table, - PVOID UserData, - PVOID MatchData -); - -typedef RTL_GENERIC_COMPARE_RESULTS -(NTAPI *PRTL_AVL_COMPARE_ROUTINE) ( - struct _RTL_AVL_TABLE *Table, - PVOID FirstStruct, - PVOID SecondStruct -); - -typedef RTL_GENERIC_COMPARE_RESULTS -(NTAPI *PRTL_GENERIC_COMPARE_ROUTINE) ( - struct _RTL_GENERIC_TABLE *Table, - PVOID FirstStruct, - PVOID SecondStruct -); - -typedef PVOID -(NTAPI *PRTL_GENERIC_ALLOCATE_ROUTINE) ( - struct _RTL_GENERIC_TABLE *Table, - CLONG ByteSize -); - -typedef VOID -(NTAPI *PRTL_GENERIC_FREE_ROUTINE) ( - struct _RTL_GENERIC_TABLE *Table, - PVOID Buffer -); - -typedef PVOID -(NTAPI *PRTL_AVL_ALLOCATE_ROUTINE) ( - struct _RTL_AVL_TABLE *Table, - CLONG ByteSize -); - -typedef VOID -(NTAPI *PRTL_AVL_FREE_ROUTINE) ( - struct _RTL_AVL_TABLE *Table, - PVOID Buffer -); - -typedef struct _PUBLIC_BCB { - CSHORT NodeTypeCode; - CSHORT NodeByteSize; - ULONG MappedLength; - LARGE_INTEGER MappedFileOffset; -} PUBLIC_BCB, *PPUBLIC_BCB; - -typedef struct _QUERY_PATH_REQUEST { - ULONG PathNameLength; - PIO_SECURITY_CONTEXT SecurityContext; - WCHAR FilePathName[1]; -} QUERY_PATH_REQUEST, *PQUERY_PATH_REQUEST; - -typedef struct _QUERY_PATH_RESPONSE { - ULONG LengthAccepted; -} QUERY_PATH_RESPONSE, *PQUERY_PATH_RESPONSE; - -typedef struct _RTL_BALANCED_LINKS -{ - struct _RTL_BALANCED_LINKS *Parent; - struct _RTL_BALANCED_LINKS *LeftChild; - struct _RTL_BALANCED_LINKS *RightChild; - CHAR Balance; - UCHAR Reserved[3]; -} RTL_BALANCED_LINKS, *PRTL_BALANCED_LINKS; - -typedef struct _RTL_GENERIC_TABLE -{ - PRTL_SPLAY_LINKS TableRoot; - LIST_ENTRY InsertOrderList; - PLIST_ENTRY OrderedPointer; - ULONG WhichOrderedElement; - ULONG NumberGenericTableElements; - PRTL_GENERIC_COMPARE_ROUTINE CompareRoutine; - PRTL_GENERIC_ALLOCATE_ROUTINE AllocateRoutine; - PRTL_GENERIC_FREE_ROUTINE FreeRoutine; - PVOID TableContext; -} RTL_GENERIC_TABLE, *PRTL_GENERIC_TABLE; - -#undef PRTL_GENERIC_COMPARE_ROUTINE -#undef PRTL_GENERIC_ALLOCATE_ROUTINE -#undef PRTL_GENERIC_FREE_ROUTINE -#undef RTL_GENERIC_TABLE -#undef PRTL_GENERIC_TABLE - -#define PRTL_GENERIC_COMPARE_ROUTINE PRTL_AVL_COMPARE_ROUTINE -#define PRTL_GENERIC_ALLOCATE_ROUTINE PRTL_AVL_ALLOCATE_ROUTINE -#define PRTL_GENERIC_FREE_ROUTINE PRTL_AVL_FREE_ROUTINE -#define RTL_GENERIC_TABLE RTL_AVL_TABLE -#define PRTL_GENERIC_TABLE PRTL_AVL_TABLE - -#define RtlInitializeGenericTable RtlInitializeGenericTableAvl -#define RtlInsertElementGenericTable RtlInsertElementGenericTableAvl -#define RtlInsertElementGenericTableFull RtlInsertElementGenericTableFullAvl -#define RtlDeleteElementGenericTable RtlDeleteElementGenericTableAvl -#define RtlLookupElementGenericTable RtlLookupElementGenericTableAvl -#define RtlLookupElementGenericTableFull RtlLookupElementGenericTableFullAvl -#define RtlEnumerateGenericTable RtlEnumerateGenericTableAvl -#define RtlEnumerateGenericTableWithoutSplaying RtlEnumerateGenericTableWithoutSplayingAvl -#define RtlGetElementGenericTable RtlGetElementGenericTableAvl -#define RtlNumberGenericTableElements RtlNumberGenericTableElementsAvl -#define RtlIsGenericTableEmpty RtlIsGenericTableEmptyAvl - -typedef struct _RTL_AVL_TABLE -{ - RTL_BALANCED_LINKS BalancedRoot; - PVOID OrderedPointer; - ULONG WhichOrderedElement; - ULONG NumberGenericTableElements; - ULONG DepthOfTree; - PRTL_BALANCED_LINKS RestartKey; - ULONG DeleteCount; - PRTL_AVL_COMPARE_ROUTINE CompareRoutine; - PRTL_AVL_ALLOCATE_ROUTINE AllocateRoutine; - PRTL_AVL_FREE_ROUTINE FreeRoutine; - PVOID TableContext; -} RTL_AVL_TABLE, *PRTL_AVL_TABLE; - -NTSYSAPI -VOID -NTAPI -RtlInitializeGenericTableAvl( - PRTL_AVL_TABLE Table, - PRTL_AVL_COMPARE_ROUTINE CompareRoutine, - PRTL_AVL_ALLOCATE_ROUTINE AllocateRoutine, - PRTL_AVL_FREE_ROUTINE FreeRoutine, - PVOID TableContext -); - -NTSYSAPI -PVOID -NTAPI -RtlInsertElementGenericTableAvl ( - PRTL_AVL_TABLE Table, - PVOID Buffer, - CLONG BufferSize, - PBOOLEAN NewElement OPTIONAL - ); - -NTSYSAPI -BOOLEAN -NTAPI -RtlDeleteElementGenericTableAvl ( - PRTL_AVL_TABLE Table, - PVOID Buffer - ); - -NTSYSAPI -PVOID -NTAPI -RtlLookupElementGenericTableAvl ( - PRTL_AVL_TABLE Table, - PVOID Buffer - ); - -NTSYSAPI -PVOID -NTAPI -RtlEnumerateGenericTableWithoutSplayingAvl ( - PRTL_AVL_TABLE Table, - PVOID *RestartKey - ); - #if defined(USE_LPC6432) #define LPC_CLIENT_ID CLIENT_ID64 #define LPC_SIZE_T ULONGLONG @@ -7575,13 +9269,6 @@ typedef struct _REMOTE_PORT_VIEW LPC_PVOID ViewBase; } REMOTE_PORT_VIEW, *PREMOTE_PORT_VIEW; -typedef struct _TUNNEL { - FAST_MUTEX Mutex; - PRTL_SPLAY_LINKS Cache; - LIST_ENTRY TimerQueue; - USHORT NumEntries; -} TUNNEL, *PTUNNEL; - typedef struct _VAD_HEADER { PVOID StartVPN; PVOID EndVPN; @@ -7596,150 +9283,6 @@ typedef struct _VAD_HEADER { LIST_ENTRY Secured; } VAD_HEADER, *PVAD_HEADER; -#if (VER_PRODUCTBUILD >= 2600) - -typedef BOOLEAN -(NTAPI *PFILTER_REPORT_CHANGE) ( - IN PVOID NotifyContext, - IN PVOID FilterContext -); - -#endif - -NTKERNELAPI -BOOLEAN -NTAPI -CcCanIWrite ( - IN PFILE_OBJECT FileObject, - IN ULONG BytesToWrite, - IN BOOLEAN Wait, - IN BOOLEAN Retrying -); - -NTKERNELAPI -BOOLEAN -NTAPI -CcCopyRead ( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN BOOLEAN Wait, - OUT PVOID Buffer, - OUT PIO_STATUS_BLOCK IoStatus -); - -NTKERNELAPI -BOOLEAN -NTAPI -CcCopyWrite ( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN BOOLEAN Wait, - IN PVOID Buffer -); - -#define CcCopyWriteWontFlush(FO, FOFF, LEN) ((LEN) <= 0x10000) - -typedef VOID (NTAPI *PCC_POST_DEFERRED_WRITE) ( - IN PVOID Context1, - IN PVOID Context2 -); - -NTKERNELAPI -VOID -NTAPI -CcDeferWrite ( - IN PFILE_OBJECT FileObject, - IN PCC_POST_DEFERRED_WRITE PostRoutine, - IN PVOID Context1, - IN PVOID Context2, - IN ULONG BytesToWrite, - IN BOOLEAN Retrying -); - -NTKERNELAPI -VOID -NTAPI -CcFastCopyRead ( - IN PFILE_OBJECT FileObject, - IN ULONG FileOffset, - IN ULONG Length, - IN ULONG PageCount, - OUT PVOID Buffer, - OUT PIO_STATUS_BLOCK IoStatus -); - -NTKERNELAPI -VOID -NTAPI -CcFastCopyWrite ( - IN PFILE_OBJECT FileObject, - IN ULONG FileOffset, - IN ULONG Length, - IN PVOID Buffer -); - -NTKERNELAPI -VOID -NTAPI -CcFlushCache ( - IN PSECTION_OBJECT_POINTERS SectionObjectPointer, - IN PLARGE_INTEGER FileOffset OPTIONAL, - IN ULONG Length, - OUT PIO_STATUS_BLOCK IoStatus OPTIONAL -); - -typedef VOID (NTAPI *PDIRTY_PAGE_ROUTINE) ( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN PLARGE_INTEGER OldestLsn, - IN PLARGE_INTEGER NewestLsn, - IN PVOID Context1, - IN PVOID Context2 -); - -NTKERNELAPI -LARGE_INTEGER -NTAPI -CcGetDirtyPages ( - IN PVOID LogHandle, - IN PDIRTY_PAGE_ROUTINE DirtyPageRoutine, - IN PVOID Context1, - IN PVOID Context2 -); - -NTKERNELAPI -PFILE_OBJECT -NTAPI -CcGetFileObjectFromBcb ( - IN PVOID Bcb -); - -NTKERNELAPI -PFILE_OBJECT -NTAPI -CcGetFileObjectFromSectionPtrs ( - IN PSECTION_OBJECT_POINTERS SectionObjectPointer -); - -#define CcGetFileSizePointer(FO) ( \ - ((PLARGE_INTEGER)((FO)->SectionObjectPointer->SharedCacheMap) + 1) \ -) - -#if (VER_PRODUCTBUILD >= 2195) - -NTKERNELAPI -LARGE_INTEGER -NTAPI -CcGetFlushedValidData ( - IN PSECTION_OBJECT_POINTERS SectionObjectPointer, - IN BOOLEAN BcbListHeld -); - -#endif /* (VER_PRODUCTBUILD >= 2195) */ - NTKERNELAPI LARGE_INTEGER NTAPI @@ -7748,428 +9291,6 @@ CcGetLsnForFileObject ( OUT PLARGE_INTEGER OldestLsn OPTIONAL ); -typedef BOOLEAN (NTAPI *PACQUIRE_FOR_LAZY_WRITE) ( - IN PVOID Context, - IN BOOLEAN Wait -); - -typedef VOID (NTAPI *PRELEASE_FROM_LAZY_WRITE) ( - IN PVOID Context -); - -typedef BOOLEAN (NTAPI *PACQUIRE_FOR_READ_AHEAD) ( - IN PVOID Context, - IN BOOLEAN Wait -); - -typedef VOID (NTAPI *PRELEASE_FROM_READ_AHEAD) ( - IN PVOID Context -); - -typedef struct _CACHE_MANAGER_CALLBACKS { - PACQUIRE_FOR_LAZY_WRITE AcquireForLazyWrite; - PRELEASE_FROM_LAZY_WRITE ReleaseFromLazyWrite; - PACQUIRE_FOR_READ_AHEAD AcquireForReadAhead; - PRELEASE_FROM_READ_AHEAD ReleaseFromReadAhead; -} CACHE_MANAGER_CALLBACKS, *PCACHE_MANAGER_CALLBACKS; - -NTKERNELAPI -VOID -NTAPI -CcInitializeCacheMap ( - IN PFILE_OBJECT FileObject, - IN PCC_FILE_SIZES FileSizes, - IN BOOLEAN PinAccess, - IN PCACHE_MANAGER_CALLBACKS Callbacks, - IN PVOID LazyWriteContext -); - -#define CcIsFileCached(FO) ( \ - ((FO)->SectionObjectPointer != NULL) && \ - (((PSECTION_OBJECT_POINTERS)(FO)->SectionObjectPointer)->SharedCacheMap != NULL) \ -) - -extern ULONG CcFastMdlReadWait; - -NTKERNELAPI -BOOLEAN -NTAPI -CcIsThereDirtyData ( - IN PVPB Vpb -); - -NTKERNELAPI -BOOLEAN -NTAPI -CcMapData ( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN ULONG Flags, - OUT PVOID *Bcb, - OUT PVOID *Buffer -); - -NTKERNELAPI -VOID -NTAPI -CcMdlRead ( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - OUT PMDL *MdlChain, - OUT PIO_STATUS_BLOCK IoStatus -); - -NTKERNELAPI -VOID -NTAPI -CcMdlReadComplete ( - IN PFILE_OBJECT FileObject, - IN PMDL MdlChain -); - -NTKERNELAPI -VOID -NTAPI -CcMdlWriteComplete ( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN PMDL MdlChain -); - -#define MAP_WAIT 1 - -NTKERNELAPI -BOOLEAN -NTAPI -CcPinMappedData ( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN ULONG Flags, - IN OUT PVOID *Bcb -); - -NTKERNELAPI -BOOLEAN -NTAPI -CcPinRead ( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN ULONG Flags, - OUT PVOID *Bcb, - OUT PVOID *Buffer -); - -NTKERNELAPI -VOID -NTAPI -CcPrepareMdlWrite ( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - OUT PMDL *MdlChain, - OUT PIO_STATUS_BLOCK IoStatus -); - -NTKERNELAPI -BOOLEAN -NTAPI -CcPreparePinWrite ( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN BOOLEAN Zero, - IN ULONG Flags, - OUT PVOID *Bcb, - OUT PVOID *Buffer -); - -NTKERNELAPI -BOOLEAN -NTAPI -CcPurgeCacheSection ( - IN PSECTION_OBJECT_POINTERS SectionObjectPointer, - IN PLARGE_INTEGER FileOffset OPTIONAL, - IN ULONG Length, - IN BOOLEAN UninitializeCacheMaps -); - -#define CcReadAhead(FO, FOFF, LEN) ( \ - if ((LEN) >= 256) { \ - CcScheduleReadAhead((FO), (FOFF), (LEN)); \ - } \ -) - -#if (VER_PRODUCTBUILD >= 2195) - -NTKERNELAPI -PVOID -NTAPI -CcRemapBcb ( - IN PVOID Bcb -); - -#endif /* (VER_PRODUCTBUILD >= 2195) */ - -NTKERNELAPI -VOID -NTAPI -CcRepinBcb ( - IN PVOID Bcb -); - -NTKERNELAPI -VOID -NTAPI -CcScheduleReadAhead ( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length -); - -NTKERNELAPI -VOID -NTAPI -CcSetAdditionalCacheAttributes ( - IN PFILE_OBJECT FileObject, - IN BOOLEAN DisableReadAhead, - IN BOOLEAN DisableWriteBehind -); - -NTKERNELAPI -VOID -NTAPI -CcSetBcbOwnerPointer ( - IN PVOID Bcb, - IN PVOID OwnerPointer -); - -NTKERNELAPI -VOID -NTAPI -CcSetDirtyPageThreshold ( - IN PFILE_OBJECT FileObject, - IN ULONG DirtyPageThreshold -); - -NTKERNELAPI -VOID -NTAPI -CcSetDirtyPinnedData ( - IN PVOID BcbVoid, - IN PLARGE_INTEGER Lsn OPTIONAL -); - -NTKERNELAPI -VOID -NTAPI -CcSetFileSizes ( - IN PFILE_OBJECT FileObject, - IN PCC_FILE_SIZES FileSizes -); - -typedef VOID (NTAPI *PFLUSH_TO_LSN) ( - IN PVOID LogHandle, - IN LARGE_INTEGER Lsn -); - -NTKERNELAPI -VOID -NTAPI -CcSetLogHandleForFile ( - IN PFILE_OBJECT FileObject, - IN PVOID LogHandle, - IN PFLUSH_TO_LSN FlushToLsnRoutine -); - -NTKERNELAPI -VOID -NTAPI -CcSetReadAheadGranularity ( - IN PFILE_OBJECT FileObject, - IN ULONG Granularity /* default: PAGE_SIZE */ - /* allowed: 2^n * PAGE_SIZE */ -); - -NTKERNELAPI -BOOLEAN -NTAPI -CcUninitializeCacheMap ( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER TruncateSize OPTIONAL, - IN PCACHE_UNINITIALIZE_EVENT UninitializeCompleteEvent OPTIONAL -); - -NTKERNELAPI -VOID -NTAPI -CcUnpinData ( - IN PVOID Bcb -); - -NTKERNELAPI -VOID -NTAPI -CcUnpinDataForThread ( - IN PVOID Bcb, - IN ERESOURCE_THREAD ResourceThreadId -); - -NTKERNELAPI -VOID -NTAPI -CcUnpinRepinnedBcb ( - IN PVOID Bcb, - IN BOOLEAN WriteThrough, - OUT PIO_STATUS_BLOCK IoStatus -); - -#if (VER_PRODUCTBUILD >= 2195) - -NTKERNELAPI -NTSTATUS -NTAPI -CcWaitForCurrentLazyWriterActivity ( - VOID -); - -#endif /* (VER_PRODUCTBUILD >= 2195) */ - -NTKERNELAPI -BOOLEAN -NTAPI -CcZeroData ( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER StartOffset, - IN PLARGE_INTEGER EndOffset, - IN BOOLEAN Wait -); - -#if (VER_PRODUCTBUILD >= 2600) - -#ifndef __NTOSKRNL__ -NTKERNELAPI -VOID -FASTCALL -ExInitializeRundownProtection ( - IN PEX_RUNDOWN_REF RunRef -); - -NTKERNELAPI -VOID -FASTCALL -ExReInitializeRundownProtection ( - IN PEX_RUNDOWN_REF RunRef -); - -NTKERNELAPI -BOOLEAN -FASTCALL -ExAcquireRundownProtection ( - IN PEX_RUNDOWN_REF RunRef -); - -NTKERNELAPI -BOOLEAN -FASTCALL -ExAcquireRundownProtectionEx ( - IN PEX_RUNDOWN_REF RunRef, - IN ULONG Count -); - -NTKERNELAPI -VOID -FASTCALL -ExReleaseRundownProtection ( - IN PEX_RUNDOWN_REF RunRef -); - -NTKERNELAPI -VOID -FASTCALL -ExReleaseRundownProtectionEx ( - IN PEX_RUNDOWN_REF RunRef, - IN ULONG Count -); - -NTKERNELAPI -VOID -FASTCALL -ExRundownCompleted ( - IN PEX_RUNDOWN_REF RunRef -); - -NTKERNELAPI -VOID -FASTCALL -ExWaitForRundownProtectionRelease ( - IN PEX_RUNDOWN_REF RunRef -); - -#endif -#endif /* (VER_PRODUCTBUILD >= 2600) */ - - -#define FsRtlSetupAdvancedHeader( _advhdr, _fmutx ) \ -{ \ - SetFlag( (_advhdr)->Flags, FSRTL_FLAG_ADVANCED_HEADER ); \ - SetFlag( (_advhdr)->Flags2, FSRTL_FLAG2_SUPPORTS_FILTER_CONTEXTS ); \ - (_advhdr)->Version = FSRTL_FCB_HEADER_V1; \ - InitializeListHead( &(_advhdr)->FilterContexts ); \ - if ((_fmutx) != NULL) { \ - (_advhdr)->FastMutex = (_fmutx); \ - } \ - *((PULONG_PTR)(&(_advhdr)->PushLock)) = 0; \ - /*ExInitializePushLock( &(_advhdr)->PushLock ); API Not avaliable downlevel*/\ - (_advhdr)->FileContextSupportPointer = NULL; \ -} - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlAddBaseMcbEntry ( - IN PBASE_MCB Mcb, - IN LONGLONG Vbn, - IN LONGLONG Lbn, - IN LONGLONG SectorCount -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlAddLargeMcbEntry ( - IN PLARGE_MCB Mcb, - IN LONGLONG Vbn, - IN LONGLONG Lbn, - IN LONGLONG SectorCount -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlAddMcbEntry ( - IN PMCB Mcb, - IN VBN Vbn, - IN LBN Lbn, - IN ULONG SectorCount -); - -NTKERNELAPI -VOID -NTAPI -FsRtlAddToTunnelCache ( - IN PTUNNEL Cache, - IN ULONGLONG DirectoryKey, - IN PUNICODE_STRING ShortName, - IN PUNICODE_STRING LongName, - IN BOOLEAN KeyByShortName, - IN ULONG DataLength, - IN PVOID Data -); - NTKERNELAPI PVOID NTAPI @@ -8204,251 +9325,6 @@ FsRtlAllocatePoolWithTag ( IN ULONG Tag ); -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlAreNamesEqual ( - IN PCUNICODE_STRING Name1, - IN PCUNICODE_STRING Name2, - IN BOOLEAN IgnoreCase, - IN PCWCH UpcaseTable OPTIONAL -); - -#define FsRtlAreThereCurrentFileLocks(FL) ( \ - ((FL)->FastIoIsQuestionable) \ -) - -typedef -VOID -(NTAPI*POPLOCK_WAIT_COMPLETE_ROUTINE) ( - IN PVOID Context, - IN PIRP Irp -); - -typedef -VOID -(NTAPI*POPLOCK_FS_PREPOST_IRP) ( - IN PVOID Context, - IN PIRP Irp -); - -NTKERNELAPI -NTSTATUS -NTAPI -FsRtlCheckOplock ( - IN POPLOCK Oplock, - IN PIRP Irp, - IN PVOID Context, - IN POPLOCK_WAIT_COMPLETE_ROUTINE CompletionRoutine OPTIONAL, - IN POPLOCK_FS_PREPOST_IRP PostIrpRoutine OPTIONAL -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlCurrentBatchOplock ( - IN POPLOCK Oplock -); - -NTKERNELAPI -VOID -NTAPI -FsRtlDeleteKeyFromTunnelCache ( - IN PTUNNEL Cache, - IN ULONGLONG DirectoryKey -); - -NTKERNELAPI -VOID -NTAPI -FsRtlDeleteTunnelCache ( - IN PTUNNEL Cache -); - -NTKERNELAPI -VOID -NTAPI -FsRtlDeregisterUncProvider ( - IN HANDLE Handle -); - -NTKERNELAPI -VOID -NTAPI -FsRtlDissectDbcs ( - IN ANSI_STRING Name, - OUT PANSI_STRING FirstPart, - OUT PANSI_STRING RemainingPart -); - -NTKERNELAPI -VOID -NTAPI -FsRtlDissectName ( - IN UNICODE_STRING Name, - OUT PUNICODE_STRING FirstPart, - OUT PUNICODE_STRING RemainingPart -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlDoesDbcsContainWildCards ( - IN PANSI_STRING Name -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlDoesNameContainWildCards ( - IN PUNICODE_STRING Name -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlIsFatDbcsLegal ( - IN ANSI_STRING DbcsName, - IN BOOLEAN WildCardsPermissible, - IN BOOLEAN PathNamePermissible, - IN BOOLEAN LeadingBackslashPermissible - ); - - -#define FsRtlCompleteRequest(IRP,STATUS) { \ - (IRP)->IoStatus.Status = (STATUS); \ - IoCompleteRequest( (IRP), IO_DISK_INCREMENT ); \ -} - -#define FsRtlEnterFileSystem KeEnterCriticalRegion - -#define FsRtlExitFileSystem KeLeaveCriticalRegion - -#define FsRtlFastLock(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11) ( \ - FsRtlPrivateLock(A1, A2, A3, A4, A5, A6, A7, A8, A9, NULL, A10, A11) \ -) - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlFindInTunnelCache ( - IN PTUNNEL Cache, - IN ULONGLONG DirectoryKey, - IN PUNICODE_STRING Name, - OUT PUNICODE_STRING ShortName, - OUT PUNICODE_STRING LongName, - IN OUT PULONG DataLength, - OUT PVOID Data -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlGetNextBaseMcbEntry ( - IN PBASE_MCB Mcb, - IN ULONG RunIndex, - OUT PLONGLONG Vbn, - OUT PLONGLONG Lbn, - OUT PLONGLONG SectorCount -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlGetNextLargeMcbEntry ( - IN PLARGE_MCB Mcb, - IN ULONG RunIndex, - OUT PLONGLONG Vbn, - OUT PLONGLONG Lbn, - OUT PLONGLONG SectorCount -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlGetNextMcbEntry ( - IN PMCB Mcb, - IN ULONG RunIndex, - OUT PVBN Vbn, - OUT PLBN Lbn, - OUT PULONG SectorCount -); - -#define FsRtlGetPerStreamContextPointer(FO) ( \ - (PFSRTL_ADVANCED_FCB_HEADER)(FO)->FsContext \ -) - -NTKERNELAPI -VOID -NTAPI -FsRtlInitializeBaseMcb ( - IN PBASE_MCB Mcb, - IN POOL_TYPE PoolType -); - -NTKERNELAPI -VOID -NTAPI -FsRtlInitializeLargeMcb ( - IN PLARGE_MCB Mcb, - IN POOL_TYPE PoolType -); - -NTKERNELAPI -VOID -NTAPI -FsRtlInitializeMcb ( - IN PMCB Mcb, - IN POOL_TYPE PoolType -); - -NTKERNELAPI -VOID -NTAPI -FsRtlInitializeOplock ( - IN OUT POPLOCK Oplock -); - -NTKERNELAPI -VOID -NTAPI -FsRtlInitializeTunnelCache ( - IN PTUNNEL Cache -); - -#define FsRtlInitPerStreamContext(PSC, O, I, FC) ( \ - (PSC)->OwnerId = (O), \ - (PSC)->InstanceId = (I), \ - (PSC)->FreeCallback = (FC) \ -) - -NTKERNELAPI -NTSTATUS -NTAPI -FsRtlInsertPerStreamContext ( - IN PFSRTL_ADVANCED_FCB_HEADER PerStreamContext, - IN PFSRTL_PER_STREAM_CONTEXT Ptr -); - -#define FsRtlIsAnsiCharacterLegalFat(C, WILD) ( \ - FlagOn(FsRtlLegalAnsiCharacterArray[(UCHAR)(C)], (FSRTL_FAT_LEGAL) | \ - ((WILD) ? FSRTL_WILD_CHARACTER : 0 )) \ -) - -#define FsRtlIsAnsiCharacterLegalHpfs(C, WILD) ( \ - FlagOn(FsRtlLegalAnsiCharacterArray[(UCHAR)(C)], (FSRTL_HPFS_LEGAL) | \ - ((WILD) ? FSRTL_WILD_CHARACTER : 0 )) \ -) - -#define FsRtlIsAnsiCharacterLegalNtfs(C, WILD) ( \ - FlagOn(FsRtlLegalAnsiCharacterArray[(UCHAR)(C)], (FSRTL_NTFS_LEGAL) | \ - ((WILD) ? FSRTL_WILD_CHARACTER : 0 )) \ -) - -#define FsRtlIsAnsiCharacterWild(C) ( \ - FlagOn(FsRtlLegalAnsiCharacterArray[(UCHAR)(C)], FSRTL_WILD_CHARACTER ) \ -) - NTKERNELAPI BOOLEAN NTAPI @@ -8459,142 +9335,6 @@ FsRtlIsFatDbcsLegal ( IN BOOLEAN LeadingBackslashPermissible ); -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlIsHpfsDbcsLegal ( - IN ANSI_STRING DbcsName, - IN BOOLEAN WildCardsPermissible, - IN BOOLEAN PathNamePermissible, - IN BOOLEAN LeadingBackslashPermissible -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlIsNameInExpression ( - IN PUNICODE_STRING Expression, - IN PUNICODE_STRING Name, - IN BOOLEAN IgnoreCase, - IN PWCHAR UpcaseTable OPTIONAL -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlIsNtstatusExpected ( - IN NTSTATUS Ntstatus -); - -#define NLS_OEM_LEAD_BYTE_INFO NlsOemLeadByteInfo - -extern PUSHORT NlsOemLeadByteInfo; - -#define FsRtlIsLeadDbcsCharacter(DBCS_CHAR) ( \ - (BOOLEAN)((UCHAR)(DBCS_CHAR) < 0x80 ? FALSE : \ - (NLS_MB_CODE_PAGE_TAG && \ - (NLS_OEM_LEAD_BYTE_INFO[(UCHAR)(DBCS_CHAR)] != 0))) \ -) - -#define FsRtlIsUnicodeCharacterWild(C) ( \ - (((C) >= 0x40) ? \ - FALSE : \ - FlagOn(FsRtlLegalAnsiCharacterArray[(C)], FSRTL_WILD_CHARACTER )) \ -) - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlLookupBaseMcbEntry ( - IN PBASE_MCB Mcb, - IN LONGLONG Vbn, - OUT PLONGLONG Lbn OPTIONAL, - OUT PLONGLONG SectorCountFromLbn OPTIONAL, - OUT PLONGLONG StartingLbn OPTIONAL, - OUT PLONGLONG SectorCountFromStartingLbn OPTIONAL, - OUT PULONG Index OPTIONAL -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlLookupLargeMcbEntry ( - IN PLARGE_MCB Mcb, - IN LONGLONG Vbn, - OUT PLONGLONG Lbn OPTIONAL, - OUT PLONGLONG SectorCountFromLbn OPTIONAL, - OUT PLONGLONG StartingLbn OPTIONAL, - OUT PLONGLONG SectorCountFromStartingLbn OPTIONAL, - OUT PULONG Index OPTIONAL -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlLookupLastBaseMcbEntry ( - IN PBASE_MCB Mcb, - OUT PLONGLONG Vbn, - OUT PLONGLONG Lbn -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlLookupLastLargeMcbEntry ( - IN PLARGE_MCB Mcb, - OUT PLONGLONG Vbn, - OUT PLONGLONG Lbn -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlLookupLastMcbEntry ( - IN PMCB Mcb, - OUT PVBN Vbn, - OUT PLBN Lbn -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlLookupLastBaseMcbEntryAndIndex ( - IN PBASE_MCB OpaqueMcb, - IN OUT PLONGLONG LargeVbn, - IN OUT PLONGLONG LargeLbn, - IN OUT PULONG Index -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlLookupLastLargeMcbEntryAndIndex ( - IN PLARGE_MCB OpaqueMcb, - OUT PLONGLONG LargeVbn, - OUT PLONGLONG LargeLbn, - OUT PULONG Index -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlLookupMcbEntry ( - IN PMCB Mcb, - IN VBN Vbn, - OUT PLBN Lbn, - OUT PULONG SectorCount OPTIONAL, - OUT PULONG Index -); - -NTKERNELAPI -PFSRTL_PER_STREAM_CONTEXT -NTAPI -FsRtlLookupPerStreamContextInternal ( - IN PFSRTL_ADVANCED_FCB_HEADER StreamContext, - IN PVOID OwnerId OPTIONAL, - IN PVOID InstanceId OPTIONAL -); - NTKERNELAPI BOOLEAN NTAPI @@ -8612,14 +9352,6 @@ FsRtlMdlWriteComplete ( IN PMDL MdlChain ); -NTKERNELAPI -NTSTATUS -NTAPI -FsRtlNormalizeNtstatus ( - IN NTSTATUS Exception, - IN NTSTATUS GenericException -); - NTKERNELAPI VOID NTAPI @@ -8633,315 +9365,6 @@ FsRtlNotifyChangeDirectory ( IN PIRP NotifyIrp ); -NTKERNELAPI -VOID -NTAPI -FsRtlNotifyCleanup ( - IN PNOTIFY_SYNC NotifySync, - IN PLIST_ENTRY NotifyList, - IN PVOID FsContext -); - -typedef BOOLEAN (NTAPI *PCHECK_FOR_TRAVERSE_ACCESS) ( - IN PVOID NotifyContext, - IN PVOID TargetContext, - IN PSECURITY_SUBJECT_CONTEXT SubjectContext -); - -NTKERNELAPI -VOID -NTAPI -FsRtlNotifyFilterChangeDirectory ( - IN PNOTIFY_SYNC NotifySync, - IN PLIST_ENTRY NotifyList, - IN PVOID FsContext, - IN PSTRING FullDirectoryName, - IN BOOLEAN WatchTree, - IN BOOLEAN IgnoreBuffer, - IN ULONG CompletionFilter, - IN PIRP NotifyIrp, - IN PCHECK_FOR_TRAVERSE_ACCESS TraverseCallback OPTIONAL, - IN PSECURITY_SUBJECT_CONTEXT SubjectContext OPTIONAL, - IN PFILTER_REPORT_CHANGE FilterCallback OPTIONAL); - -NTKERNELAPI -VOID -NTAPI -FsRtlNotifyFilterReportChange ( - IN PNOTIFY_SYNC NotifySync, - IN PLIST_ENTRY NotifyList, - IN PSTRING FullTargetName, - IN USHORT TargetNameOffset, - IN PSTRING StreamName OPTIONAL, - IN PSTRING NormalizedParentName OPTIONAL, - IN ULONG FilterMatch, - IN ULONG Action, - IN PVOID TargetContext, - IN PVOID FilterContext); - -NTKERNELAPI -VOID -NTAPI -FsRtlNotifyFullChangeDirectory ( - IN PNOTIFY_SYNC NotifySync, - IN PLIST_ENTRY NotifyList, - IN PVOID FsContext, - IN PSTRING FullDirectoryName, - IN BOOLEAN WatchTree, - IN BOOLEAN IgnoreBuffer, - IN ULONG CompletionFilter, - IN PIRP NotifyIrp, - IN PCHECK_FOR_TRAVERSE_ACCESS TraverseCallback OPTIONAL, - IN PSECURITY_SUBJECT_CONTEXT SubjectContext OPTIONAL -); - -NTKERNELAPI -VOID -NTAPI -FsRtlNotifyFullReportChange ( - IN PNOTIFY_SYNC NotifySync, - IN PLIST_ENTRY NotifyList, - IN PSTRING FullTargetName, - IN USHORT TargetNameOffset, - IN PSTRING StreamName OPTIONAL, - IN PSTRING NormalizedParentName OPTIONAL, - IN ULONG FilterMatch, - IN ULONG Action, - IN PVOID TargetContext -); - -NTKERNELAPI -VOID -NTAPI -FsRtlNotifyInitializeSync ( - IN PNOTIFY_SYNC *NotifySync -); - -NTKERNELAPI -VOID -NTAPI -FsRtlNotifyUninitializeSync ( - IN PNOTIFY_SYNC *NotifySync -); - -#if (VER_PRODUCTBUILD >= 2195) - -NTKERNELAPI -NTSTATUS -NTAPI -FsRtlNotifyVolumeEvent ( - IN PFILE_OBJECT FileObject, - IN ULONG EventCode -); - -#endif /* (VER_PRODUCTBUILD >= 2195) */ - -NTKERNELAPI -ULONG -NTAPI -FsRtlNumberOfRunsInBaseMcb ( - IN PBASE_MCB Mcb -); - -NTKERNELAPI -ULONG -NTAPI -FsRtlNumberOfRunsInLargeMcb ( - IN PLARGE_MCB Mcb -); - -NTKERNELAPI -ULONG -NTAPI -FsRtlNumberOfRunsInMcb ( - IN PMCB Mcb -); - -NTKERNELAPI -NTSTATUS -NTAPI -FsRtlOplockFsctrl ( - IN POPLOCK Oplock, - IN PIRP Irp, - IN ULONG OpenCount -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlOplockIsFastIoPossible ( - IN POPLOCK Oplock -); - -typedef VOID -(NTAPI *PFSRTL_STACK_OVERFLOW_ROUTINE) ( - IN PVOID Context, - IN PKEVENT Event -); - -NTKERNELAPI -VOID -NTAPI -FsRtlPostPagingFileStackOverflow ( - IN PVOID Context, - IN PKEVENT Event, - IN PFSRTL_STACK_OVERFLOW_ROUTINE StackOverflowRoutine -); - -NTKERNELAPI -VOID -NTAPI -FsRtlPostStackOverflow ( - IN PVOID Context, - IN PKEVENT Event, - IN PFSRTL_STACK_OVERFLOW_ROUTINE StackOverflowRoutine -); - -NTKERNELAPI -NTSTATUS -NTAPI -FsRtlRegisterUncProvider ( - IN OUT PHANDLE MupHandle, - IN PUNICODE_STRING RedirectorDeviceName, - IN BOOLEAN MailslotsSupported -); - -NTKERNELAPI -VOID -NTAPI -FsRtlRemoveBaseMcbEntry ( - IN PBASE_MCB Mcb, - IN LONGLONG Vbn, - IN LONGLONG SectorCount -); - -NTKERNELAPI -VOID -NTAPI -FsRtlRemoveLargeMcbEntry ( - IN PLARGE_MCB Mcb, - IN LONGLONG Vbn, - IN LONGLONG SectorCount -); - -NTKERNELAPI -VOID -NTAPI -FsRtlRemoveMcbEntry ( - IN PMCB Mcb, - IN VBN Vbn, - IN ULONG SectorCount -); - -NTKERNELAPI -PFSRTL_PER_STREAM_CONTEXT -NTAPI -FsRtlRemovePerStreamContext ( - IN PFSRTL_ADVANCED_FCB_HEADER StreamContext, - IN PVOID OwnerId OPTIONAL, - IN PVOID InstanceId OPTIONAL -); - -NTKERNELAPI -VOID -NTAPI -FsRtlResetBaseMcb ( - IN PBASE_MCB Mcb -); - -NTKERNELAPI -VOID -NTAPI -FsRtlResetLargeMcb ( - IN PLARGE_MCB Mcb, - IN BOOLEAN SelfSynchronized -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlSplitBaseMcb ( - IN PBASE_MCB Mcb, - IN LONGLONG Vbn, - IN LONGLONG Amount -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlSplitLargeMcb ( - IN PLARGE_MCB Mcb, - IN LONGLONG Vbn, - IN LONGLONG Amount -); - -#define FsRtlSupportsPerStreamContexts(FO) ( \ - (BOOLEAN)((NULL != FsRtlGetPerStreamContextPointer(FO) && \ - FlagOn(FsRtlGetPerStreamContextPointer(FO)->Flags2, \ - FSRTL_FLAG2_SUPPORTS_FILTER_CONTEXTS)) \ -) - -NTKERNELAPI -VOID -NTAPI -FsRtlTruncateBaseMcb ( - IN PBASE_MCB Mcb, - IN LONGLONG Vbn -); - -NTKERNELAPI -VOID -NTAPI -FsRtlTruncateLargeMcb ( - IN PLARGE_MCB Mcb, - IN LONGLONG Vbn -); - -NTKERNELAPI -VOID -NTAPI -FsRtlTruncateMcb ( - IN PMCB Mcb, - IN VBN Vbn -); - -NTKERNELAPI -VOID -NTAPI -FsRtlUninitializeBaseMcb ( - IN PBASE_MCB Mcb -); - -NTKERNELAPI -VOID -NTAPI -FsRtlUninitializeLargeMcb ( - IN PLARGE_MCB Mcb -); - -NTKERNELAPI -VOID -NTAPI -FsRtlUninitializeMcb ( - IN PMCB Mcb -); - -NTKERNELAPI -VOID -NTAPI -FsRtlUninitializeOplock ( - IN OUT POPLOCK Oplock -); - -NTKERNELAPI -NTSTATUS -NTAPI -IoAttachDeviceToDeviceStackSafe( - IN PDEVICE_OBJECT SourceDevice, - IN PDEVICE_OBJECT TargetDevice, - OUT PDEVICE_OBJECT *AttachedToDeviceObject -); - NTKERNELAPI NTSTATUS NTAPI @@ -8978,23 +9401,6 @@ ObReferenceObjectByName ( OUT PVOID *Object ); -#if (NTDDI_VERSION >= NTDDI_WIN2K) - -NTKERNELAPI -NTSTATUS -NTAPI -PsAssignImpersonationToken( - IN PETHREAD Thread, - IN HANDLE Token OPTIONAL); - -NTKERNELAPI -HANDLE -NTAPI -PsReferencePrimaryToken( - IN OUT PEPROCESS Process); - -#endif - #define PsDereferenceImpersonationToken(T) \ {if (ARGUMENT_PRESENT(T)) { \ (ObDereferenceObject((T))); \ @@ -9012,14 +9418,6 @@ PsLookupProcessThreadByCid ( OUT PETHREAD *Thread ); -NTSYSAPI -VOID -NTAPI -RtlSecondsSince1970ToTime ( - IN ULONG SecondsSince1970, - OUT PLARGE_INTEGER Time -); - NTSYSAPI NTSTATUS NTAPI @@ -9030,105 +9428,6 @@ RtlSetSaclSecurityDescriptor ( IN BOOLEAN SaclDefaulted ); -NTSYSAPI -NTSTATUS -NTAPI -RtlUnicodeStringToCountedOemString ( - IN OUT POEM_STRING DestinationString, - IN PCUNICODE_STRING SourceString, - IN BOOLEAN AllocateDestinationString -); - -/* RTL Splay Tree Functions */ -NTSYSAPI -PRTL_SPLAY_LINKS -NTAPI -RtlSplay(PRTL_SPLAY_LINKS Links); - -NTSYSAPI -PRTL_SPLAY_LINKS -NTAPI -RtlDelete(PRTL_SPLAY_LINKS Links); - -NTSYSAPI -VOID -NTAPI -RtlDeleteNoSplay( - PRTL_SPLAY_LINKS Links, - PRTL_SPLAY_LINKS *Root -); - -NTSYSAPI -PRTL_SPLAY_LINKS -NTAPI -RtlSubtreeSuccessor(PRTL_SPLAY_LINKS Links); - -NTSYSAPI -PRTL_SPLAY_LINKS -NTAPI -RtlSubtreePredecessor(PRTL_SPLAY_LINKS Links); - -NTSYSAPI -PRTL_SPLAY_LINKS -NTAPI -RtlRealSuccessor(PRTL_SPLAY_LINKS Links); - -NTSYSAPI -PRTL_SPLAY_LINKS -NTAPI -RtlRealPredecessor(PRTL_SPLAY_LINKS Links); - -#define RtlIsLeftChild(Links) \ - (RtlLeftChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links)) - -#define RtlIsRightChild(Links) \ - (RtlRightChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links)) - -#define RtlRightChild(Links) \ - ((PRTL_SPLAY_LINKS)(Links))->RightChild - -#define RtlIsRoot(Links) \ - (RtlParent(Links) == (PRTL_SPLAY_LINKS)(Links)) - -#define RtlLeftChild(Links) \ - ((PRTL_SPLAY_LINKS)(Links))->LeftChild - -#define RtlParent(Links) \ - ((PRTL_SPLAY_LINKS)(Links))->Parent - -#define RtlInitializeSplayLinks(Links) \ - { \ - PRTL_SPLAY_LINKS _SplayLinks; \ - _SplayLinks = (PRTL_SPLAY_LINKS)(Links); \ - _SplayLinks->Parent = _SplayLinks; \ - _SplayLinks->LeftChild = NULL; \ - _SplayLinks->RightChild = NULL; \ - } - -#define RtlInsertAsLeftChild(ParentLinks,ChildLinks) \ - { \ - PRTL_SPLAY_LINKS _SplayParent; \ - PRTL_SPLAY_LINKS _SplayChild; \ - _SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \ - _SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks); \ - _SplayParent->LeftChild = _SplayChild; \ - _SplayChild->Parent = _SplayParent; \ - } - -#define RtlInsertAsRightChild(ParentLinks,ChildLinks) \ - { \ - PRTL_SPLAY_LINKS _SplayParent; \ - PRTL_SPLAY_LINKS _SplayChild; \ - _SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \ - _SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks); \ - _SplayParent->RightChild = _SplayChild; \ - _SplayChild->Parent = _SplayParent; \ - } - -// -// RTL time functions -// - #define SeEnableAccessToExports() SeExports = *(PSE_EXPORTS *)SeExports; #if (VER_PRODUCTBUILD >= 2195) @@ -9154,18 +9453,6 @@ ZwAlertThread ( IN HANDLE ThreadHandle ); -NTSYSAPI -NTSTATUS -NTAPI -ZwAllocateVirtualMemory ( - IN HANDLE ProcessHandle, - IN OUT PVOID *BaseAddress, - IN ULONG_PTR ZeroBits, - IN OUT PSIZE_T RegionSize, - IN ULONG AllocationType, - IN ULONG Protect -); - NTSYSAPI NTSTATUS NTAPI @@ -9211,19 +9498,6 @@ ZwCloseObjectAuditAlarm ( IN BOOLEAN GenerateOnClose ); -NTSYSAPI -NTSTATUS -NTAPI -ZwCreateSection ( - OUT PHANDLE SectionHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, - IN PLARGE_INTEGER MaximumSize OPTIONAL, - IN ULONG SectionPageProtection, - IN ULONG AllocationAttributes, - IN HANDLE FileHandle OPTIONAL -); - NTSYSAPI NTSTATUS NTAPI @@ -9234,71 +9508,6 @@ ZwCreateSymbolicLinkObject ( IN PUNICODE_STRING TargetName ); -NTSYSAPI -NTSTATUS -NTAPI -ZwDeleteFile ( - IN POBJECT_ATTRIBUTES ObjectAttributes -); - -NTSYSAPI -NTSTATUS -NTAPI -ZwDeleteValueKey ( - IN HANDLE Handle, - IN PUNICODE_STRING Name -); - - -#if (NTDDI_VERSION >= NTDDI_WIN2K) -NTSYSAPI -NTSTATUS -NTAPI -ZwDeviceIoControlFile ( - IN HANDLE FileHandle, - IN HANDLE Event OPTIONAL, - IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, - IN PVOID ApcContext OPTIONAL, - OUT PIO_STATUS_BLOCK IoStatusBlock, - IN ULONG IoControlCode, - IN PVOID InputBuffer OPTIONAL, - IN ULONG InputBufferLength, - OUT PVOID OutputBuffer OPTIONAL, - IN ULONG OutputBufferLength); -#endif - -NTSYSAPI -NTSTATUS -NTAPI -ZwDisplayString ( - IN PUNICODE_STRING String -); - -NTSYSAPI -NTSTATUS -NTAPI -ZwDuplicateObject ( - IN HANDLE SourceProcessHandle, - IN HANDLE SourceHandle, - IN HANDLE TargetProcessHandle OPTIONAL, - OUT PHANDLE TargetHandle OPTIONAL, - IN ACCESS_MASK DesiredAccess, - IN ULONG HandleAttributes, - IN ULONG Options -); - -NTSYSAPI -NTSTATUS -NTAPI -ZwDuplicateToken ( - IN HANDLE ExistingTokenHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes, - IN BOOLEAN EffectiveOnly, - IN TOKEN_TYPE TokenType, - OUT PHANDLE NewTokenHandle -); - NTSYSAPI NTSTATUS NTAPI @@ -9318,46 +9527,6 @@ ZwFlushBuffersFile( #if (VER_PRODUCTBUILD >= 2195) -NTSYSAPI -NTSTATUS -NTAPI -ZwFlushVirtualMemory ( - IN HANDLE ProcessHandle, - IN OUT PVOID *BaseAddress, - IN OUT PULONG FlushSize, - OUT PIO_STATUS_BLOCK IoStatusBlock -); - -#endif /* (VER_PRODUCTBUILD >= 2195) */ - -NTSYSAPI -NTSTATUS -NTAPI -ZwFreeVirtualMemory ( - IN HANDLE ProcessHandle, - IN OUT PVOID *BaseAddress, - IN OUT PSIZE_T RegionSize, - IN ULONG FreeType -); - -NTSYSAPI -NTSTATUS -NTAPI -ZwFsControlFile ( - IN HANDLE FileHandle, - IN HANDLE Event OPTIONAL, - IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, - IN PVOID ApcContext OPTIONAL, - OUT PIO_STATUS_BLOCK IoStatusBlock, - IN ULONG FsControlCode, - IN PVOID InputBuffer OPTIONAL, - IN ULONG InputBufferLength, - OUT PVOID OutputBuffer OPTIONAL, - IN ULONG OutputBufferLength -); - -#if (VER_PRODUCTBUILD >= 2195) - NTSYSAPI NTSTATUS NTAPI @@ -9370,14 +9539,6 @@ ZwInitiatePowerAction ( #endif /* (VER_PRODUCTBUILD >= 2195) */ -NTSYSAPI -NTSTATUS -NTAPI -ZwLoadDriver ( - /* "\\Registry\\Machine\\System\\CurrentControlSet\\Services\\" */ - IN PUNICODE_STRING RegistryPath -); - NTSYSAPI NTSTATUS NTAPI @@ -9386,41 +9547,6 @@ ZwLoadKey ( IN POBJECT_ATTRIBUTES FileObjectAttributes ); -NTSYSAPI -NTSTATUS -NTAPI -ZwNotifyChangeKey ( - IN HANDLE KeyHandle, - IN HANDLE EventHandle OPTIONAL, - IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, - IN PVOID ApcContext OPTIONAL, - OUT PIO_STATUS_BLOCK IoStatusBlock, - IN ULONG NotifyFilter, - IN BOOLEAN WatchSubtree, - IN PVOID Buffer, - IN ULONG BufferLength, - IN BOOLEAN Asynchronous -); - -NTSYSAPI -NTSTATUS -NTAPI -ZwOpenDirectoryObject ( - OUT PHANDLE DirectoryHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes -); - -NTSYSAPI -NTSTATUS -NTAPI -ZwOpenProcess ( - OUT PHANDLE ProcessHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes, - IN PCLIENT_ID ClientId OPTIONAL -); - NTSYSAPI NTSTATUS NTAPI @@ -9450,21 +9576,6 @@ ZwOpenThreadToken ( OUT PHANDLE TokenHandle ); -#if (VER_PRODUCTBUILD >= 2195) - -NTSYSAPI -NTSTATUS -NTAPI -ZwPowerInformation ( - IN POWER_INFORMATION_LEVEL PowerInformationLevel, - IN PVOID InputBuffer OPTIONAL, - IN ULONG InputBufferLength, - OUT PVOID OutputBuffer OPTIONAL, - IN ULONG OutputBufferLength -); - -#endif /* (VER_PRODUCTBUILD >= 2195) */ - NTSYSAPI NTSTATUS NTAPI @@ -9481,23 +9592,6 @@ ZwQueryDefaultLocale ( OUT PLCID Locale ); -NTSYSAPI -NTSTATUS -NTAPI -ZwQueryDirectoryFile ( - IN HANDLE FileHandle, - IN HANDLE Event OPTIONAL, - IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, - IN PVOID ApcContext OPTIONAL, - OUT PIO_STATUS_BLOCK IoStatusBlock, - OUT PVOID FileInformation, - IN ULONG Length, - IN FILE_INFORMATION_CLASS FileInformationClass, - IN BOOLEAN ReturnSingleEntry, - IN PUNICODE_STRING FileName OPTIONAL, - IN BOOLEAN RestartScan -); - #if (VER_PRODUCTBUILD >= 2195) NTSYSAPI @@ -9513,21 +9607,6 @@ ZwQueryDirectoryObject ( OUT PULONG ReturnLength OPTIONAL ); -NTSYSAPI -NTSTATUS -NTAPI -ZwQueryEaFile ( - IN HANDLE FileHandle, - OUT PIO_STATUS_BLOCK IoStatusBlock, - OUT PVOID Buffer, - IN ULONG Length, - IN BOOLEAN ReturnSingleEntry, - IN PVOID EaList OPTIONAL, - IN ULONG EaListLength, - IN PULONG EaIndex OPTIONAL, - IN BOOLEAN RestartScan -); - #endif /* (VER_PRODUCTBUILD >= 2195) */ NTSYSAPI @@ -9541,39 +9620,6 @@ ZwQueryInformationProcess ( OUT PULONG ReturnLength OPTIONAL ); -NTSYSAPI -NTSTATUS -NTAPI -ZwQueryInformationToken ( - IN HANDLE TokenHandle, - IN TOKEN_INFORMATION_CLASS TokenInformationClass, - OUT PVOID TokenInformation, - IN ULONG Length, - OUT PULONG ResultLength -); - -NTSYSAPI -NTSTATUS -NTAPI -ZwQuerySecurityObject ( - IN HANDLE FileHandle, - IN SECURITY_INFORMATION SecurityInformation, - OUT PSECURITY_DESCRIPTOR SecurityDescriptor, - IN ULONG Length, - OUT PULONG ResultLength -); - -NTSYSAPI -NTSTATUS -NTAPI -ZwQueryVolumeInformationFile ( - IN HANDLE FileHandle, - OUT PIO_STATUS_BLOCK IoStatusBlock, - OUT PVOID FsInformation, - IN ULONG Length, - IN FS_INFORMATION_CLASS FsInformationClass -); - NTSYSAPI NTSTATUS NTAPI @@ -9629,26 +9675,8 @@ ZwSetDefaultUILanguage ( IN LANGID LanguageId ); -NTSYSAPI -NTSTATUS -NTAPI -ZwSetEaFile ( - IN HANDLE FileHandle, - OUT PIO_STATUS_BLOCK IoStatusBlock, - OUT PVOID Buffer, - IN ULONG Length -); - #endif /* (VER_PRODUCTBUILD >= 2195) */ -NTSYSAPI -NTSTATUS -NTAPI -ZwSetEvent ( - IN HANDLE EventHandle, - OUT PLONG PreviousState OPTIONAL -); - NTSYSAPI NTSTATUS NTAPI @@ -9659,19 +9687,6 @@ ZwSetInformationProcess ( IN ULONG ProcessInformationLength ); -#if (VER_PRODUCTBUILD >= 2195) - -NTSYSAPI -NTSTATUS -NTAPI -ZwSetSecurityObject ( - IN HANDLE Handle, - IN SECURITY_INFORMATION SecurityInformation, - IN PSECURITY_DESCRIPTOR SecurityDescriptor -); - -#endif /* (VER_PRODUCTBUILD >= 2195) */ - NTSYSAPI NTSTATUS NTAPI @@ -9680,37 +9695,6 @@ ZwSetSystemTime ( OUT PLARGE_INTEGER OldTime OPTIONAL ); -#if (VER_PRODUCTBUILD >= 2195) - -NTSYSAPI -NTSTATUS -NTAPI -ZwSetVolumeInformationFile ( - IN HANDLE FileHandle, - OUT PIO_STATUS_BLOCK IoStatusBlock, - IN PVOID FsInformation, - IN ULONG Length, - IN FS_INFORMATION_CLASS FsInformationClass -); - -#endif /* (VER_PRODUCTBUILD >= 2195) */ - -NTSYSAPI -NTSTATUS -NTAPI -ZwTerminateProcess ( - IN HANDLE ProcessHandle OPTIONAL, - IN NTSTATUS ExitStatus -); - -NTSYSAPI -NTSTATUS -NTAPI -ZwUnloadDriver ( - /* "\\Registry\\Machine\\System\\CurrentControlSet\\Services\\" */ - IN PUNICODE_STRING RegistryPath -); - NTSYSAPI NTSTATUS NTAPI @@ -9718,16 +9702,6 @@ ZwUnloadKey ( IN POBJECT_ATTRIBUTES KeyObjectAttributes ); -#if (NTDDI_VERSION >= NTDDI_WIN2K) -NTSYSAPI -NTSTATUS -NTAPI -ZwWaitForSingleObject ( - IN HANDLE Handle, - IN BOOLEAN Alertable, - IN PLARGE_INTEGER Timeout OPTIONAL); -#endif - NTSYSAPI NTSTATUS NTAPI diff --git a/reactos/include/ddk/ntimage.h b/reactos/include/ddk/ntimage.h index e008a2daa94..8df984763f7 100644 --- a/reactos/include/ddk/ntimage.h +++ b/reactos/include/ddk/ntimage.h @@ -394,22 +394,33 @@ typedef struct _IMAGE_NT_HEADERS64 { ULONG Signature; IMAGE_FILE_HEADER FileHeader; IMAGE_OPTIONAL_HEADER64 OptionalHeader; -} IMAGE_NT_HEADERS64, *PIMAGE_NT_HEADERS64; +} IMAGE_NT_HEADERS64; typedef struct _IMAGE_NT_HEADERS { ULONG Signature; IMAGE_FILE_HEADER FileHeader; IMAGE_OPTIONAL_HEADER32 OptionalHeader; -} IMAGE_NT_HEADERS32, *PIMAGE_NT_HEADERS32; +} IMAGE_NT_HEADERS32; #ifdef _WIN64 typedef IMAGE_NT_HEADERS64 IMAGE_NT_HEADERS; -typedef PIMAGE_NT_HEADERS64 PIMAGE_NT_HEADERS; #else typedef IMAGE_NT_HEADERS32 IMAGE_NT_HEADERS; +#endif + +#ifndef _NTDDK_ + +typedef struct _IMAGE_NT_HEADERS *PIMAGE_NT_HEADERS32; +typedef struct _IMAGE_NT_HEADERS64 *PIMAGE_NT_HEADERS64; + +#ifdef _WIN64 +typedef PIMAGE_NT_HEADERS64 PIMAGE_NT_HEADERS; +#else typedef PIMAGE_NT_HEADERS32 PIMAGE_NT_HEADERS; #endif +#endif /* _NTDDK_ */ + // // Retreives the first image section header from the Nt Header // diff --git a/reactos/include/ddk/wdm.h b/reactos/include/ddk/wdm.h index 7e97ea08c1d..2742d758ed8 100644 --- a/reactos/include/ddk/wdm.h +++ b/reactos/include/ddk/wdm.h @@ -38,10 +38,25 @@ #include #include #include +#include #ifndef GUID_DEFINED #include -#endif /* GUID_DEFINED */ +#endif + +#ifdef _MAC +#ifndef _INC_STRING +#include +#endif /* _INC_STRING */ +#else +#include +#endif /* _MAC */ + +#ifndef _KTMTYPES_ +typedef GUID UOW, *PUOW; +#endif + +typedef GUID *PGUID; #if (NTDDI_VERSION >= NTDDI_WINXP) #include @@ -91,6 +106,12 @@ extern "C" { #if defined(_MSC_VER) +/* Disable some warnings */ +#pragma warning(disable:4115) /* Named type definition in parentheses */ +#pragma warning(disable:4201) /* Nameless unions and structs */ +#pragma warning(disable:4214) /* Bit fields of other types than int */ +#pragma warning(disable:4820) /* Padding added, due to alignemnet requirement */ + /* Indicate if #pragma alloc_text() is supported */ #if defined(_M_IX86) || defined(_M_AMD64) || defined(_M_IA64) #define ALLOC_PRAGMA 1 @@ -123,17 +144,51 @@ struct _IO_RESOURCE_DESCRIPTOR; typedef struct _OBJECT_TYPE *POBJECT_TYPE; typedef struct _HAL_DISPATCH_TABLE *PHAL_DISPATCH_TABLE; typedef struct _HAL_PRIVATE_DISPATCH_TABLE *PHAL_PRIVATE_DISPATCH_TABLE; -typedef struct _DEVICE_HANDLER_OBJECT *PDEVICE_HANDLER_OBJECT; -typedef struct _ADAPTER_OBJECT *PADAPTER_OBJECT; typedef struct _CALLBACK_OBJECT *PCALLBACK_OBJECT; -typedef struct _ETHREAD *PETHREAD; typedef struct _EPROCESS *PEPROCESS; +typedef struct _ETHREAD *PETHREAD; typedef struct _IO_TIMER *PIO_TIMER; typedef struct _KINTERRUPT *PKINTERRUPT; typedef struct _KPROCESS *PKPROCESS; typedef struct _KTHREAD *PKTHREAD, *PRKTHREAD; typedef struct _CONTEXT *PCONTEXT; +#if defined(USE_DMA_MACROS) && !defined(_NTHAL_) && ( defined(_NTDDK_) || defined(_NTDRIVER_) || defined(_NTOSP_)) +typedef struct _DMA_ADAPTER *PADAPTER_OBJECT; +#elif defined(_WDM_INCLUDED_) +typedef struct _DMA_ADAPTER *PADAPTER_OBJECT; +#else +typedef struct _ADAPTER_OBJECT *PADAPTER_OBJECT; +#endif + +#ifndef DEFINE_GUIDEX +#ifdef _MSC_VER +#define DEFINE_GUIDEX(name) EXTERN_C const CDECL GUID name +#else +#define DEFINE_GUIDEX(name) EXTERN_C const GUID name +#endif +#endif /* DEFINE_GUIDEX */ + +#ifndef STATICGUIDOF +#define STATICGUIDOF(guid) STATIC_##guid +#endif + +/* GUID Comparison */ +#ifndef __IID_ALIGNED__ +#define __IID_ALIGNED__ +#ifdef __cplusplus +inline int IsEqualGUIDAligned(REFGUID guid1, REFGUID guid2) +{ + return ( (*(PLONGLONG)(&guid1) == *(PLONGLONG)(&guid2)) && + (*((PLONGLONG)(&guid1) + 1) == *((PLONGLONG)(&guid2) + 1)) ); +} +#else +#define IsEqualGUIDAligned(guid1, guid2) \ + ( (*(PLONGLONG)(guid1) == *(PLONGLONG)(guid2)) && \ + (*((PLONGLONG)(guid1) + 1) == *((PLONGLONG)(guid2) + 1)) ) +#endif /* __cplusplus */ +#endif /* !__IID_ALIGNED__ */ + /****************************************************************************** * INTERLOCKED Functions * @@ -145,42 +200,44 @@ typedef struct _CONTEXT *PCONTEXT; #if defined(__GNUC__) static __inline__ BOOLEAN -InterlockedBitTestAndSet(IN LONG volatile *Base, - IN LONG Bit) +InterlockedBitTestAndSet( + IN LONG volatile *Base, + IN LONG Bit) { #if defined(_M_IX86) - LONG OldBit; - __asm__ __volatile__("lock " - "btsl %2,%1\n\t" - "sbbl %0,%0\n\t" - :"=r" (OldBit),"+m" (*Base) - :"Ir" (Bit) - : "memory"); - return OldBit; + LONG OldBit; + __asm__ __volatile__("lock " + "btsl %2,%1\n\t" + "sbbl %0,%0\n\t" + :"=r" (OldBit),"+m" (*Base) + :"Ir" (Bit) + : "memory"); + return OldBit; #else - return (_InterlockedOr(Base, 1 << Bit) >> Bit) & 1; + return (_InterlockedOr(Base, 1 << Bit) >> Bit) & 1; #endif } static __inline__ BOOLEAN -InterlockedBitTestAndReset(IN LONG volatile *Base, - IN LONG Bit) +InterlockedBitTestAndReset( + IN LONG volatile *Base, + IN LONG Bit) { #if defined(_M_IX86) - LONG OldBit; - __asm__ __volatile__("lock " - "btrl %2,%1\n\t" - "sbbl %0,%0\n\t" - :"=r" (OldBit),"+m" (*Base) - :"Ir" (Bit) - : "memory"); - return OldBit; + LONG OldBit; + __asm__ __volatile__("lock " + "btrl %2,%1\n\t" + "sbbl %0,%0\n\t" + :"=r" (OldBit),"+m" (*Base) + :"Ir" (Bit) + : "memory"); + return OldBit; #else - return (_InterlockedAnd(Base, ~(1 << Bit)) >> Bit) & 1; + return (_InterlockedAnd(Base, ~(1 << Bit)) >> Bit) & 1; #endif } -#endif +#endif /* defined(__GNUC__) */ #define BitScanForward _BitScanForward #define BitScanReverse _BitScanReverse @@ -192,6 +249,10 @@ InterlockedBitTestAndReset(IN LONG volatile *Base, #define InterlockedBitTestAndReset _interlockedbittestandreset #ifdef _M_AMD64 +#define BitTest64 _bittest64 +#define BitTestAndComplement64 _bittestandcomplement64 +#define BitTestAndSet64 _bittestandset64 +#define BitTestAndReset64 _bittestandreset64 #define InterlockedBitTestAndSet64 _interlockedbittestandset64 #define InterlockedBitTestAndReset64 _interlockedbittestandreset64 #endif @@ -218,8 +279,8 @@ LONG FASTCALL InterlockedCompareExchange( IN OUT LONG volatile *Destination, - IN LONG Exchange, - IN LONG Comparand); + IN LONG Exchange, + IN LONG Comparand); NTKERNELAPI LONG @@ -235,7 +296,7 @@ InterlockedExchangeAdd( IN OUT LONG volatile *Addend, IN LONG Value); -#else // !defined(NO_INTERLOCKED_INTRINSICS) +#else /* !defined(NO_INTERLOCKED_INTRINSICS) */ #define InterlockedExchange _InterlockedExchange #define InterlockedIncrement _InterlockedIncrement @@ -246,9 +307,9 @@ InterlockedExchangeAdd( #define InterlockedAnd _InterlockedAnd #define InterlockedXor _InterlockedXor -#endif // !defined(NO_INTERLOCKED_INTRINSICS) +#endif /* !defined(NO_INTERLOCKED_INTRINSICS) */ -#endif // defined (_X86_) +#endif /* defined (_X86_) */ #if !defined (_WIN64) /* @@ -311,10 +372,10 @@ InterlockedExchangeAdd( FORCEINLINE LONG64 InterlockedAdd64( - IN OUT LONG64 volatile *Addend, - IN LONG64 Value) + IN OUT LONG64 volatile *Addend, + IN LONG64 Value) { - return InterlockedExchangeAdd64(Addend, Value) + Value; + return InterlockedExchangeAdd64(Addend, Value) + Value; } //#endif #endif @@ -350,43 +411,43 @@ InterlockedAdd64( #define HASH_STRING_ALGORITHM_INVALID 0xffffffff typedef struct _RTL_BITMAP { - ULONG SizeOfBitMap; - PULONG Buffer; + ULONG SizeOfBitMap; + PULONG Buffer; } RTL_BITMAP, *PRTL_BITMAP; typedef struct _RTL_BITMAP_RUN { - ULONG StartingIndex; - ULONG NumberOfBits; + ULONG StartingIndex; + ULONG NumberOfBits; } RTL_BITMAP_RUN, *PRTL_BITMAP_RUN; typedef NTSTATUS -(DDKAPI *PRTL_QUERY_REGISTRY_ROUTINE)( - IN PWSTR ValueName, - IN ULONG ValueType, - IN PVOID ValueData, - IN ULONG ValueLength, - IN PVOID Context, - IN PVOID EntryContext); +(NTAPI *PRTL_QUERY_REGISTRY_ROUTINE)( + IN PWSTR ValueName, + IN ULONG ValueType, + IN PVOID ValueData, + IN ULONG ValueLength, + IN PVOID Context, + IN PVOID EntryContext); typedef struct _RTL_QUERY_REGISTRY_TABLE { - PRTL_QUERY_REGISTRY_ROUTINE QueryRoutine; - ULONG Flags; - PCWSTR Name; - PVOID EntryContext; - ULONG DefaultType; - PVOID DefaultData; - ULONG DefaultLength; + PRTL_QUERY_REGISTRY_ROUTINE QueryRoutine; + ULONG Flags; + PCWSTR Name; + PVOID EntryContext; + ULONG DefaultType; + PVOID DefaultData; + ULONG DefaultLength; } RTL_QUERY_REGISTRY_TABLE, *PRTL_QUERY_REGISTRY_TABLE; typedef struct _TIME_FIELDS { - CSHORT Year; - CSHORT Month; - CSHORT Day; - CSHORT Hour; - CSHORT Minute; - CSHORT Second; - CSHORT Milliseconds; - CSHORT Weekday; + CSHORT Year; + CSHORT Month; + CSHORT Day; + CSHORT Hour; + CSHORT Minute; + CSHORT Second; + CSHORT Milliseconds; + CSHORT Weekday; } TIME_FIELDS, *PTIME_FIELDS; /* Slist Header */ @@ -394,60 +455,101 @@ typedef struct _TIME_FIELDS { #define _SLIST_HEADER_ #if defined(_WIN64) -typedef struct DECLSPEC_ALIGN(16) _SLIST_ENTRY *PSLIST_ENTRY; + typedef struct DECLSPEC_ALIGN(16) _SLIST_ENTRY { - PSLIST_ENTRY Next; -} SLIST_ENTRY; + struct _SLIST_ENTRY *Next; +} SLIST_ENTRY, *PSLIST_ENTRY; + +typedef struct _SLIST_ENTRY32 { + ULONG Next; +} SLIST_ENTRY32, *PSLIST_ENTRY32; + typedef union DECLSPEC_ALIGN(16) _SLIST_HEADER { - struct { - ULONGLONG Alignment; - ULONGLONG Region; - } DUMMYSTRUCTNAME; - struct { - ULONGLONG Depth:16; - ULONGLONG Sequence:9; - ULONGLONG NextEntry:39; - ULONGLONG HeaderType:1; - ULONGLONG Init:1; - ULONGLONG Reserved:59; - ULONGLONG Region:3; - } Header8; - struct { - ULONGLONG Depth:16; - ULONGLONG Sequence:48; - ULONGLONG HeaderType:1; - ULONGLONG Init:1; - ULONGLONG Reserved:2; - ULONGLONG NextEntry:60; - } Header16; + struct { + ULONGLONG Alignment; + ULONGLONG Region; + } DUMMYSTRUCTNAME; + struct { + ULONGLONG Depth:16; + ULONGLONG Sequence:9; + ULONGLONG NextEntry:39; + ULONGLONG HeaderType:1; + ULONGLONG Init:1; + ULONGLONG Reserved:59; + ULONGLONG Region:3; + } Header8; + struct { + ULONGLONG Depth:16; + ULONGLONG Sequence:48; + ULONGLONG HeaderType:1; + ULONGLONG Init:1; + ULONGLONG Reserved:2; + ULONGLONG NextEntry:60; + } Header16; + struct { + ULONGLONG Depth:16; + ULONGLONG Sequence:48; + ULONGLONG HeaderType:1; + ULONGLONG Reserved:3; + ULONGLONG NextEntry:60; + } HeaderX64; } SLIST_HEADER, *PSLIST_HEADER; + +typedef union _SLIST_HEADER32 { + ULONGLONG Alignment; + struct { + SLIST_ENTRY32 Next; + USHORT Depth; + USHORT Sequence; + } DUMMYSTRUCTNAME; +} SLIST_HEADER32, *PSLIST_HEADER32; + #else + #define SLIST_ENTRY SINGLE_LIST_ENTRY #define _SLIST_ENTRY _SINGLE_LIST_ENTRY #define PSLIST_ENTRY PSINGLE_LIST_ENTRY + +typedef SLIST_ENTRY SLIST_ENTRY32, *PSLIST_ENTRY32; + typedef union _SLIST_HEADER { - ULONGLONG Alignment; - struct { - SLIST_ENTRY Next; - USHORT Depth; - USHORT Sequence; - } DUMMYSTRUCTNAME; + ULONGLONG Alignment; + struct { + SLIST_ENTRY Next; + USHORT Depth; + USHORT Sequence; + } DUMMYSTRUCTNAME; } SLIST_HEADER, *PSLIST_HEADER; -#endif + +typedef SLIST_HEADER SLIST_HEADER32, *PSLIST_HEADER32; + +#endif /* defined(_WIN64) */ #endif /* _SLIST_HEADER_ */ - -/* HACK HACK HACK - GCC (or perhaps LD) is messing this up */ -#if defined(_NTSYSTEM_) || defined(__GNUC__) +/* MS definition is broken! */ +extern BOOLEAN NTSYSAPI NlsMbCodePageTag; +extern BOOLEAN NTSYSAPI NlsMbOemCodePageTag; #define NLS_MB_CODE_PAGE_TAG NlsMbCodePageTag #define NLS_MB_OEM_CODE_PAGE_TAG NlsMbOemCodePageTag -#else -#define NLS_MB_CODE_PAGE_TAG (*NlsMbCodePageTag) -#define NLS_MB_OEM_CODE_PAGE_TAG (*NlsMbOemCodePageTag) -#endif /* _NT_SYSTEM */ -extern BOOLEAN NTSYSAPI NLS_MB_CODE_PAGE_TAG; -extern BOOLEAN NTSYSAPI NLS_MB_OEM_CODE_PAGE_TAG; + +#define SHORT_LEAST_SIGNIFICANT_BIT 0 +#define SHORT_MOST_SIGNIFICANT_BIT 1 + +#define LONG_LEAST_SIGNIFICANT_BIT 0 +#define LONG_3RD_MOST_SIGNIFICANT_BIT 1 +#define LONG_2ND_MOST_SIGNIFICANT_BIT 2 +#define LONG_MOST_SIGNIFICANT_BIT 3 + +#define RTLVERLIB_DDI(x) Wdmlib##x + +typedef BOOLEAN +(*PFN_RTL_IS_NTDDI_VERSION_AVAILABLE)( + IN ULONG Version); + +typedef BOOLEAN +(*PFN_RTL_IS_SERVICE_PACK_VERSION_INSTALLED)( + IN ULONG Version); /****************************************************************************** @@ -458,39 +560,139 @@ typedef UCHAR KIRQL, *PKIRQL; typedef CCHAR KPROCESSOR_MODE; typedef LONG KPRIORITY; -typedef ULONG EXECUTION_STATE; - typedef enum _MODE { KernelMode, UserMode, MaximumMode } MODE; -/* Processor features */ -#define PF_FLOATING_POINT_PRECISION_ERRATA 0 -#define PF_FLOATING_POINT_EMULATED 1 -#define PF_COMPARE_EXCHANGE_DOUBLE 2 -#define PF_MMX_INSTRUCTIONS_AVAILABLE 3 -#define PF_PPC_MOVEMEM_64BIT_OK 4 -#define PF_ALPHA_BYTE_INSTRUCTIONS 5 -#define PF_XMMI_INSTRUCTIONS_AVAILABLE 6 -#define PF_3DNOW_INSTRUCTIONS_AVAILABLE 7 -#define PF_RDTSC_INSTRUCTION_AVAILABLE 8 -#define PF_PAE_ENABLED 9 -#define PF_XMMI64_INSTRUCTIONS_AVAILABLE 10 -#define PF_SSE_DAZ_MODE_AVAILABLE 11 -#define PF_NX_ENABLED 12 -#define PF_SSE3_INSTRUCTIONS_AVAILABLE 13 -#define PF_COMPARE_EXCHANGE128 14 -#define PF_COMPARE64_EXCHANGE128 15 -#define PF_CHANNELS_ENABLED 16 -#define PF_XSAVE_ENABLED 17 +#define CACHE_FULLY_ASSOCIATIVE 0xFF +#define MAXIMUM_SUSPEND_COUNT MAXCHAR + +#define EVENT_QUERY_STATE (0x0001) +#define EVENT_MODIFY_STATE (0x0002) +#define EVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3) + +#define LTP_PC_SMT 0x1 + +#if (NTDDI_VERSION < NTDDI_WIN7) || defined(_X86_) || !defined(NT_PROCESSOR_GROUPS) +#define SINGLE_GROUP_LEGACY_API 1 +#endif + +#define SEMAPHORE_QUERY_STATE (0x0001) +#define SEMAPHORE_MODIFY_STATE (0x0002) +#define SEMAPHORE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3) + +typedef enum _LOGICAL_PROCESSOR_RELATIONSHIP { + RelationProcessorCore, + RelationNumaNode, + RelationCache, + RelationProcessorPackage, + RelationGroup, + RelationAll = 0xffff +} LOGICAL_PROCESSOR_RELATIONSHIP; + +typedef enum _PROCESSOR_CACHE_TYPE { + CacheUnified, + CacheInstruction, + CacheData, + CacheTrace +} PROCESSOR_CACHE_TYPE; + +typedef struct _CACHE_DESCRIPTOR { + UCHAR Level; + UCHAR Associativity; + USHORT LineSize; + ULONG Size; + PROCESSOR_CACHE_TYPE Type; +} CACHE_DESCRIPTOR, *PCACHE_DESCRIPTOR; + +typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION { + ULONG_PTR ProcessorMask; + LOGICAL_PROCESSOR_RELATIONSHIP Relationship; + union { + struct { + UCHAR Flags; + } ProcessorCore; + struct { + ULONG NodeNumber; + } NumaNode; + CACHE_DESCRIPTOR Cache; + ULONGLONG Reserved[2]; + } DUMMYUNIONNAME; +} SYSTEM_LOGICAL_PROCESSOR_INFORMATION, *PSYSTEM_LOGICAL_PROCESSOR_INFORMATION; + +typedef struct _PROCESSOR_RELATIONSHIP { + UCHAR Flags; + UCHAR Reserved[21]; + USHORT GroupCount; + GROUP_AFFINITY GroupMask[ANYSIZE_ARRAY]; +} PROCESSOR_RELATIONSHIP, *PPROCESSOR_RELATIONSHIP; + +typedef struct _NUMA_NODE_RELATIONSHIP { + ULONG NodeNumber; + UCHAR Reserved[20]; + GROUP_AFFINITY GroupMask; +} NUMA_NODE_RELATIONSHIP, *PNUMA_NODE_RELATIONSHIP; + +typedef struct _CACHE_RELATIONSHIP { + UCHAR Level; + UCHAR Associativity; + USHORT LineSize; + ULONG CacheSize; + PROCESSOR_CACHE_TYPE Type; + UCHAR Reserved[20]; + GROUP_AFFINITY GroupMask; +} CACHE_RELATIONSHIP, *PCACHE_RELATIONSHIP; + +typedef struct _PROCESSOR_GROUP_INFO { + UCHAR MaximumProcessorCount; + UCHAR ActiveProcessorCount; + UCHAR Reserved[38]; + KAFFINITY ActiveProcessorMask; +} PROCESSOR_GROUP_INFO, *PPROCESSOR_GROUP_INFO; + +typedef struct _GROUP_RELATIONSHIP { + USHORT MaximumGroupCount; + USHORT ActiveGroupCount; + UCHAR Reserved[20]; + PROCESSOR_GROUP_INFO GroupInfo[ANYSIZE_ARRAY]; +} GROUP_RELATIONSHIP, *PGROUP_RELATIONSHIP; + +typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX { + LOGICAL_PROCESSOR_RELATIONSHIP Relationship; + ULONG Size; + union { + PROCESSOR_RELATIONSHIP Processor; + NUMA_NODE_RELATIONSHIP NumaNode; + CACHE_RELATIONSHIP Cache; + GROUP_RELATIONSHIP Group; + } DUMMYUNIONNAME; +} SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX, *PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX;; + +/* Processor features */ +#define PF_FLOATING_POINT_PRECISION_ERRATA 0 +#define PF_FLOATING_POINT_EMULATED 1 +#define PF_COMPARE_EXCHANGE_DOUBLE 2 +#define PF_MMX_INSTRUCTIONS_AVAILABLE 3 +#define PF_PPC_MOVEMEM_64BIT_OK 4 +#define PF_ALPHA_BYTE_INSTRUCTIONS 5 +#define PF_XMMI_INSTRUCTIONS_AVAILABLE 6 +#define PF_3DNOW_INSTRUCTIONS_AVAILABLE 7 +#define PF_RDTSC_INSTRUCTION_AVAILABLE 8 +#define PF_PAE_ENABLED 9 +#define PF_XMMI64_INSTRUCTIONS_AVAILABLE 10 +#define PF_SSE_DAZ_MODE_AVAILABLE 11 +#define PF_NX_ENABLED 12 +#define PF_SSE3_INSTRUCTIONS_AVAILABLE 13 +#define PF_COMPARE_EXCHANGE128 14 +#define PF_COMPARE64_EXCHANGE128 15 +#define PF_CHANNELS_ENABLED 16 +#define PF_XSAVE_ENABLED 17 -#define MAXIMUM_SUPPORTED_EXTENSION 512 #define MAXIMUM_WAIT_OBJECTS 64 -#define ASSERT_APC(Object) \ - ASSERT((Object)->Type == ApcObject) +#define ASSERT_APC(Object) NT_ASSERT((Object)->Type == ApcObject) #define ASSERT_DPC(Object) \ ASSERT(((Object)->Type == 0) || \ @@ -498,25 +700,25 @@ typedef enum _MODE { ((Object)->Type == ThreadedDpcObject)) #define ASSERT_GATE(object) \ - ASSERT((((object)->Header.Type & KOBJECT_TYPE_MASK) == GateObject) || \ - (((object)->Header.Type & KOBJECT_TYPE_MASK) == EventSynchronizationObject)) + NT_ASSERT((((object)->Header.Type & KOBJECT_TYPE_MASK) == GateObject) || \ + (((object)->Header.Type & KOBJECT_TYPE_MASK) == EventSynchronizationObject)) #define ASSERT_DEVICE_QUEUE(Object) \ - ASSERT((Object)->Type == DeviceQueueObject) + NT_ASSERT((Object)->Type == DeviceQueueObject) #define ASSERT_TIMER(E) \ - ASSERT(((E)->Header.Type == TimerNotificationObject) || \ - ((E)->Header.Type == TimerSynchronizationObject)) + NT_ASSERT(((E)->Header.Type == TimerNotificationObject) || \ + ((E)->Header.Type == TimerSynchronizationObject)) #define ASSERT_MUTANT(E) \ - ASSERT((E)->Header.Type == MutantObject) + NT_ASSERT((E)->Header.Type == MutantObject) #define ASSERT_SEMAPHORE(E) \ - ASSERT((E)->Header.Type == SemaphoreObject) + NT_ASSERT((E)->Header.Type == SemaphoreObject) #define ASSERT_EVENT(E) \ - ASSERT(((E)->Header.Type == NotificationEvent) || \ - ((E)->Header.Type == SynchronizationEvent)) + NT_ASSERT(((E)->Header.Type == NotificationEvent) || \ + ((E)->Header.Type == SynchronizationEvent)) #define DPC_NORMAL 0 #define DPC_THREADED 1 @@ -526,6 +728,9 @@ typedef enum _MODE { #define GM_LOCK_WAITER_WOKEN 0x2 #define GM_LOCK_WAITER_INC 0x4 +#define LOCK_QUEUE_WAIT_BIT 0 +#define LOCK_QUEUE_OWNER_BIT 1 + #define LOCK_QUEUE_WAIT 1 #define LOCK_QUEUE_OWNER 2 #define LOCK_QUEUE_TIMER_LOCK_SHIFT 4 @@ -549,43 +754,59 @@ typedef enum _MODE { #define MAXIMUM_PROCESSORS MAXIMUM_PROC_PER_GROUP /* Exception Records */ -#define EXCEPTION_NONCONTINUABLE 1 +#define EXCEPTION_NONCONTINUABLE 1 #define EXCEPTION_MAXIMUM_PARAMETERS 15 +#define EXCEPTION_DIVIDED_BY_ZERO 0 +#define EXCEPTION_DEBUG 1 +#define EXCEPTION_NMI 2 +#define EXCEPTION_INT3 3 +#define EXCEPTION_BOUND_CHECK 5 +#define EXCEPTION_INVALID_OPCODE 6 +#define EXCEPTION_NPX_NOT_AVAILABLE 7 +#define EXCEPTION_DOUBLE_FAULT 8 +#define EXCEPTION_NPX_OVERRUN 9 +#define EXCEPTION_INVALID_TSS 0x0A +#define EXCEPTION_SEGMENT_NOT_PRESENT 0x0B +#define EXCEPTION_STACK_FAULT 0x0C +#define EXCEPTION_GP_FAULT 0x0D +#define EXCEPTION_RESERVED_TRAP 0x0F +#define EXCEPTION_NPX_ERROR 0x010 +#define EXCEPTION_ALIGNMENT_CHECK 0x011 + typedef struct _EXCEPTION_RECORD { - NTSTATUS ExceptionCode; - ULONG ExceptionFlags; - struct _EXCEPTION_RECORD *ExceptionRecord; - PVOID ExceptionAddress; - ULONG NumberParameters; - ULONG_PTR ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS]; + NTSTATUS ExceptionCode; + ULONG ExceptionFlags; + struct _EXCEPTION_RECORD *ExceptionRecord; + PVOID ExceptionAddress; + ULONG NumberParameters; + ULONG_PTR ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS]; } EXCEPTION_RECORD, *PEXCEPTION_RECORD; typedef struct _EXCEPTION_RECORD32 { - NTSTATUS ExceptionCode; - ULONG ExceptionFlags; - ULONG ExceptionRecord; - ULONG ExceptionAddress; - ULONG NumberParameters; - ULONG ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS]; + NTSTATUS ExceptionCode; + ULONG ExceptionFlags; + ULONG ExceptionRecord; + ULONG ExceptionAddress; + ULONG NumberParameters; + ULONG ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS]; } EXCEPTION_RECORD32, *PEXCEPTION_RECORD32; typedef struct _EXCEPTION_RECORD64 { - NTSTATUS ExceptionCode; - ULONG ExceptionFlags; - ULONG64 ExceptionRecord; - ULONG64 ExceptionAddress; - ULONG NumberParameters; - ULONG __unusedAlignment; - ULONG64 ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS]; + NTSTATUS ExceptionCode; + ULONG ExceptionFlags; + ULONG64 ExceptionRecord; + ULONG64 ExceptionAddress; + ULONG NumberParameters; + ULONG __unusedAlignment; + ULONG64 ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS]; } EXCEPTION_RECORD64, *PEXCEPTION_RECORD64; typedef struct _EXCEPTION_POINTERS { - PEXCEPTION_RECORD ExceptionRecord; - PCONTEXT ContextRecord; + PEXCEPTION_RECORD ExceptionRecord; + PCONTEXT ContextRecord; } EXCEPTION_POINTERS, *PEXCEPTION_POINTERS; - typedef enum _KBUGCHECK_CALLBACK_REASON { KbCallbackInvalid, KbCallbackReserved1, @@ -597,19 +818,56 @@ typedef enum _KBUGCHECK_CALLBACK_REASON { struct _KBUGCHECK_REASON_CALLBACK_RECORD; typedef VOID -(DDKAPI *PKBUGCHECK_REASON_CALLBACK_ROUTINE)( - IN KBUGCHECK_CALLBACK_REASON Reason, - IN struct _KBUGCHECK_REASON_CALLBACK_RECORD *Record, - IN OUT PVOID ReasonSpecificData, - IN ULONG ReasonSpecificDataLength); +(NTAPI KBUGCHECK_REASON_CALLBACK_ROUTINE)( + IN KBUGCHECK_CALLBACK_REASON Reason, + IN struct _KBUGCHECK_REASON_CALLBACK_RECORD *Record, + IN OUT PVOID ReasonSpecificData, + IN ULONG ReasonSpecificDataLength); +typedef KBUGCHECK_REASON_CALLBACK_ROUTINE *PKBUGCHECK_REASON_CALLBACK_ROUTINE; + +typedef struct _KBUGCHECK_ADD_PAGES { + IN OUT PVOID Context; + IN OUT ULONG Flags; + IN ULONG BugCheckCode; + OUT ULONG_PTR Address; + OUT ULONG_PTR Count; +} KBUGCHECK_ADD_PAGES, *PKBUGCHECK_ADD_PAGES; + +typedef struct _KBUGCHECK_SECONDARY_DUMP_DATA { + IN PVOID InBuffer; + IN ULONG InBufferLength; + IN ULONG MaximumAllowed; + OUT GUID Guid; + OUT PVOID OutBuffer; + OUT ULONG OutBufferLength; +} KBUGCHECK_SECONDARY_DUMP_DATA, *PKBUGCHECK_SECONDARY_DUMP_DATA; + +typedef enum _KBUGCHECK_DUMP_IO_TYPE { + KbDumpIoInvalid, + KbDumpIoHeader, + KbDumpIoBody, + KbDumpIoSecondaryData, + KbDumpIoComplete +} KBUGCHECK_DUMP_IO_TYPE; + +typedef struct _KBUGCHECK_DUMP_IO { + IN ULONG64 Offset; + IN PVOID Buffer; + IN ULONG BufferLength; + IN KBUGCHECK_DUMP_IO_TYPE Type; +} KBUGCHECK_DUMP_IO, *PKBUGCHECK_DUMP_IO; + +#define KB_ADD_PAGES_FLAG_VIRTUAL_ADDRESS 0x00000001UL +#define KB_ADD_PAGES_FLAG_PHYSICAL_ADDRESS 0x00000002UL +#define KB_ADD_PAGES_FLAG_ADDITIONAL_RANGES_EXIST 0x80000000UL typedef struct _KBUGCHECK_REASON_CALLBACK_RECORD { - LIST_ENTRY Entry; - PKBUGCHECK_REASON_CALLBACK_ROUTINE CallbackRoutine; - PUCHAR Component; - ULONG_PTR Checksum; - KBUGCHECK_CALLBACK_REASON Reason; - UCHAR State; + LIST_ENTRY Entry; + PKBUGCHECK_REASON_CALLBACK_ROUTINE CallbackRoutine; + PUCHAR Component; + ULONG_PTR Checksum; + KBUGCHECK_CALLBACK_REASON Reason; + UCHAR State; } KBUGCHECK_REASON_CALLBACK_RECORD, *PKBUGCHECK_REASON_CALLBACK_RECORD; typedef enum _KBUGCHECK_BUFFER_DUMP_STATE { @@ -621,39 +879,52 @@ typedef enum _KBUGCHECK_BUFFER_DUMP_STATE { } KBUGCHECK_BUFFER_DUMP_STATE; typedef VOID -(DDKAPI *PKBUGCHECK_CALLBACK_ROUTINE)( - IN PVOID Buffer, - IN ULONG Length); +(NTAPI KBUGCHECK_CALLBACK_ROUTINE)( + IN PVOID Buffer, + IN ULONG Length); +typedef KBUGCHECK_CALLBACK_ROUTINE *PKBUGCHECK_CALLBACK_ROUTINE; typedef struct _KBUGCHECK_CALLBACK_RECORD { - LIST_ENTRY Entry; - PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine; - PVOID Buffer; - ULONG Length; - PUCHAR Component; - ULONG_PTR Checksum; - UCHAR State; + LIST_ENTRY Entry; + PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine; + PVOID Buffer; + ULONG Length; + PUCHAR Component; + ULONG_PTR Checksum; + UCHAR State; } KBUGCHECK_CALLBACK_RECORD, *PKBUGCHECK_CALLBACK_RECORD; typedef BOOLEAN -(DDKAPI *PNMI_CALLBACK)( - IN PVOID Context, - IN BOOLEAN Handled); +(NTAPI NMI_CALLBACK)( + IN PVOID Context, + IN BOOLEAN Handled); +typedef NMI_CALLBACK *PNMI_CALLBACK; -typedef enum _TRACE_INFORMATION_CLASS { - TraceIdClass, - TraceHandleClass, - TraceEnableFlagsClass, - TraceEnableLevelClass, - GlobalLoggerHandleClass, - EventLoggerHandleClass, - AllLoggerHandlesClass, - TraceHandleByNameClass, - LoggerEventsLostClass, - TraceSessionSettingsClass, - LoggerEventsLoggedClass, - MaxTraceInformationClass -} TRACE_INFORMATION_CLASS; +typedef enum _KE_PROCESSOR_CHANGE_NOTIFY_STATE { + KeProcessorAddStartNotify = 0, + KeProcessorAddCompleteNotify, + KeProcessorAddFailureNotify +} KE_PROCESSOR_CHANGE_NOTIFY_STATE; + +typedef struct _KE_PROCESSOR_CHANGE_NOTIFY_CONTEXT { + KE_PROCESSOR_CHANGE_NOTIFY_STATE State; + ULONG NtNumber; + NTSTATUS Status; +#if (NTDDI_VERSION >= NTDDI_WIN7) + PROCESSOR_NUMBER ProcNumber; +#endif +} KE_PROCESSOR_CHANGE_NOTIFY_CONTEXT, *PKE_PROCESSOR_CHANGE_NOTIFY_CONTEXT; + +typedef VOID +(NTAPI PROCESSOR_CALLBACK_FUNCTION)( + IN PVOID CallbackContext, + IN PKE_PROCESSOR_CHANGE_NOTIFY_CONTEXT ChangeContext, + IN OUT PNTSTATUS OperationStatus); +typedef PROCESSOR_CALLBACK_FUNCTION *PPROCESSOR_CALLBACK_FUNCTION; + +#define KE_PROCESSOR_CHANGE_ADD_EXISTING 1 + +#define INVALID_PROCESSOR_INDEX 0xffffffff typedef enum _KINTERRUPT_POLARITY { InterruptPolarityUnknown, @@ -751,55 +1022,50 @@ typedef enum _KINTERRUPT_MODE { #define THREAD_WAIT_OBJECTS 3 typedef VOID -(DDKAPI *PKINTERRUPT_ROUTINE)( +(NTAPI KSTART_ROUTINE)( + IN PVOID StartContext); +typedef KSTART_ROUTINE *PKSTART_ROUTINE; + +typedef VOID +(NTAPI *PKINTERRUPT_ROUTINE)( VOID); +typedef BOOLEAN +(NTAPI KSERVICE_ROUTINE)( + IN struct _KINTERRUPT *Interrupt, + IN PVOID ServiceContext); +typedef KSERVICE_ROUTINE *PKSERVICE_ROUTINE; + +typedef BOOLEAN +(NTAPI KMESSAGE_SERVICE_ROUTINE)( + IN struct _KINTERRUPT *Interrupt, + IN PVOID ServiceContext, + IN ULONG MessageID); +typedef KMESSAGE_SERVICE_ROUTINE *PKMESSAGE_SERVICE_ROUTINE; + typedef enum _KD_OPTION { - KD_OPTION_SET_BLOCK_ENABLE, + KD_OPTION_SET_BLOCK_ENABLE, } KD_OPTION; -typedef enum _INTERFACE_TYPE { - InterfaceTypeUndefined = -1, - Internal, - Isa, - Eisa, - MicroChannel, - TurboChannel, - PCIBus, - VMEBus, - NuBus, - PCMCIABus, - CBus, - MPIBus, - MPSABus, - ProcessorInternal, - InternalPowerBus, - PNPISABus, - PNPBus, - Vmcs, - MaximumInterfaceType -} INTERFACE_TYPE, *PINTERFACE_TYPE; +typedef VOID +(NTAPI *PKNORMAL_ROUTINE)( + IN PVOID NormalContext OPTIONAL, + IN PVOID SystemArgument1 OPTIONAL, + IN PVOID SystemArgument2 OPTIONAL); typedef VOID -(DDKAPI *PKNORMAL_ROUTINE)( - IN PVOID NormalContext, - IN PVOID SystemArgument1, - IN PVOID SystemArgument2); +(NTAPI *PKRUNDOWN_ROUTINE)( + IN struct _KAPC *Apc); typedef VOID -(DDKAPI *PKRUNDOWN_ROUTINE)( - IN struct _KAPC *Apc); +(NTAPI *PKKERNEL_ROUTINE)( + IN struct _KAPC *Apc, + IN OUT PKNORMAL_ROUTINE *NormalRoutine OPTIONAL, + IN OUT PVOID *NormalContext OPTIONAL, + IN OUT PVOID *SystemArgument1 OPTIONAL, + IN OUT PVOID *SystemArgument2 OPTIONAL); -typedef VOID -(DDKAPI *PKKERNEL_ROUTINE)( - IN struct _KAPC *Apc, - IN OUT PKNORMAL_ROUTINE *NormalRoutine, - IN OUT PVOID *NormalContext, - IN OUT PVOID *SystemArgument1, - IN OUT PVOID *SystemArgument2); - -typedef struct _KAPC -{ +typedef struct _KAPC { UCHAR Type; UCHAR SpareByte0; UCHAR Size; @@ -818,38 +1084,62 @@ typedef struct _KAPC BOOLEAN Inserted; } KAPC, *PKAPC, *RESTRICTED_POINTER PRKAPC; +#define KAPC_OFFSET_TO_SPARE_BYTE0 FIELD_OFFSET(KAPC, SpareByte0) +#define KAPC_OFFSET_TO_SPARE_BYTE1 FIELD_OFFSET(KAPC, SpareByte1) +#define KAPC_OFFSET_TO_SPARE_LONG FIELD_OFFSET(KAPC, SpareLong0) +#define KAPC_OFFSET_TO_SYSTEMARGUMENT1 FIELD_OFFSET(KAPC, SystemArgument1) +#define KAPC_OFFSET_TO_SYSTEMARGUMENT2 FIELD_OFFSET(KAPC, SystemArgument2) +#define KAPC_OFFSET_TO_APCSTATEINDEX FIELD_OFFSET(KAPC, ApcStateIndex) +#define KAPC_ACTUAL_LENGTH (FIELD_OFFSET(KAPC, Inserted) + sizeof(BOOLEAN)) + typedef struct _KDEVICE_QUEUE_ENTRY { - LIST_ENTRY DeviceListEntry; - ULONG SortKey; - BOOLEAN Inserted; + LIST_ENTRY DeviceListEntry; + ULONG SortKey; + BOOLEAN Inserted; } KDEVICE_QUEUE_ENTRY, *PKDEVICE_QUEUE_ENTRY, *RESTRICTED_POINTER PRKDEVICE_QUEUE_ENTRY; typedef PVOID PKIPI_CONTEXT; -typedef -VOID +typedef VOID (NTAPI *PKIPI_WORKER)( - IN PKIPI_CONTEXT PacketContext, - IN PVOID Parameter1, - IN PVOID Parameter2, - IN PVOID Parameter3); + IN OUT PKIPI_CONTEXT PacketContext, + IN PVOID Parameter1 OPTIONAL, + IN PVOID Parameter2 OPTIONAL, + IN PVOID Parameter3 OPTIONAL); -typedef -ULONG_PTR -(NTAPI *PKIPI_BROADCAST_WORKER)( - IN ULONG_PTR Argument); +typedef struct _KIPI_COUNTS { + ULONG Freeze; + ULONG Packet; + ULONG DPC; + ULONG APC; + ULONG FlushSingleTb; + ULONG FlushMultipleTb; + ULONG FlushEntireTb; + ULONG GenericCall; + ULONG ChangeColor; + ULONG SweepDcache; + ULONG SweepIcache; + ULONG SweepIcacheRange; + ULONG FlushIoBuffers; + ULONG GratuitousDPC; +} KIPI_COUNTS, *PKIPI_COUNTS; + +typedef ULONG_PTR +(NTAPI KIPI_BROADCAST_WORKER)( + IN ULONG_PTR Argument); +typedef KIPI_BROADCAST_WORKER *PKIPI_BROADCAST_WORKER; typedef ULONG_PTR KSPIN_LOCK, *PKSPIN_LOCK; typedef struct _KSPIN_LOCK_QUEUE { - struct _KSPIN_LOCK_QUEUE *volatile Next; - PKSPIN_LOCK volatile Lock; + struct _KSPIN_LOCK_QUEUE *volatile Next; + PKSPIN_LOCK volatile Lock; } KSPIN_LOCK_QUEUE, *PKSPIN_LOCK_QUEUE; typedef struct _KLOCK_QUEUE_HANDLE { - KSPIN_LOCK_QUEUE LockQueue; - KIRQL OldIrql; + KSPIN_LOCK_QUEUE LockQueue; + KIRQL OldIrql; } KLOCK_QUEUE_HANDLE, *PKLOCK_QUEUE_HANDLE; #if defined(_AMD64_) @@ -900,14 +1190,14 @@ typedef enum _KSPIN_LOCK_QUEUE_NUMBER { LockQueueMaximumLock = LockQueueTimerTableLock + LOCK_QUEUE_TIMER_TABLE_LOCKS } KSPIN_LOCK_QUEUE_NUMBER, *PKSPIN_LOCK_QUEUE_NUMBER; -#endif +#endif /* defined(_AMD64_) */ typedef VOID -(DDKAPI *PKDEFERRED_ROUTINE)( - IN struct _KDPC *Dpc, - IN PVOID DeferredContext, - IN PVOID SystemArgument1, - IN PVOID SystemArgument2); +(NTAPI *PKDEFERRED_ROUTINE)( + IN struct _KDPC *Dpc, + IN PVOID DeferredContext OPTIONAL, + IN PVOID SystemArgument1 OPTIONAL, + IN PVOID SystemArgument2 OPTIONAL); typedef enum _KDPC_IMPORTANCE { LowImportance, @@ -916,17 +1206,16 @@ typedef enum _KDPC_IMPORTANCE { MediumHighImportance } KDPC_IMPORTANCE; -typedef struct _KDPC -{ - UCHAR Type; - UCHAR Importance; - volatile USHORT Number; - LIST_ENTRY DpcListEntry; - PKDEFERRED_ROUTINE DeferredRoutine; - PVOID DeferredContext; - PVOID SystemArgument1; - PVOID SystemArgument2; - volatile PVOID DpcData; +typedef struct _KDPC { + UCHAR Type; + UCHAR Importance; + volatile USHORT Number; + LIST_ENTRY DpcListEntry; + PKDEFERRED_ROUTINE DeferredRoutine; + PVOID DeferredContext; + PVOID SystemArgument1; + PVOID SystemArgument2; + volatile PVOID DpcData; } KDPC, *PKDPC, *RESTRICTED_POINTER PRKDPC; typedef struct _KDPC_WATCHDOG_INFORMATION { @@ -946,126 +1235,124 @@ typedef struct _KDEVICE_QUEUE { union { BOOLEAN Busy; struct { - LONG64 Reserved : 8; - LONG64 Hint : 56; + LONG64 Reserved:8; + LONG64 Hint:56; }; }; #else BOOLEAN Busy; #endif - } KDEVICE_QUEUE, *PKDEVICE_QUEUE, *RESTRICTED_POINTER PRKDEVICE_QUEUE; #define TIMER_EXPIRED_INDEX_BITS 6 #define TIMER_PROCESSOR_INDEX_BITS 5 + typedef struct _DISPATCHER_HEADER { - _ANONYMOUS_UNION union { - _ANONYMOUS_STRUCT struct { - UCHAR Type; - _ANONYMOUS_UNION union { - _ANONYMOUS_UNION union { - UCHAR TimerControlFlags; - _ANONYMOUS_STRUCT struct { - UCHAR Absolute:1; - UCHAR Coalescable:1; - UCHAR KeepShifting:1; - UCHAR EncodedTolerableDelay:5; - } DUMMYSTRUCTNAME; - } DUMMYUNIONNAME; - UCHAR Abandoned; + _ANONYMOUS_UNION union { + _ANONYMOUS_STRUCT struct { + UCHAR Type; + _ANONYMOUS_UNION union { + _ANONYMOUS_UNION union { + UCHAR TimerControlFlags; + _ANONYMOUS_STRUCT struct { + UCHAR Absolute:1; + UCHAR Coalescable:1; + UCHAR KeepShifting:1; + UCHAR EncodedTolerableDelay:5; + } DUMMYSTRUCTNAME; + } DUMMYUNIONNAME; + UCHAR Abandoned; #if (NTDDI_VERSION < NTDDI_WIN7) - UCHAR NpxIrql; + UCHAR NpxIrql; #endif - BOOLEAN Signalling; - } DUMMYUNIONNAME; - _ANONYMOUS_UNION union { - _ANONYMOUS_UNION union { - UCHAR ThreadControlFlags; - _ANONYMOUS_STRUCT struct { - UCHAR CpuThrottled:1; - UCHAR CycleProfiling:1; - UCHAR CounterProfiling:1; - UCHAR Reserved:5; - } DUMMYSTRUCTNAME; - } DUMMYUNIONNAME; - UCHAR Size; - UCHAR Hand; - } DUMMYUNIONNAME2; - _ANONYMOUS_UNION union { + BOOLEAN Signalling; + } DUMMYUNIONNAME; + _ANONYMOUS_UNION union { + _ANONYMOUS_UNION union { + UCHAR ThreadControlFlags; + _ANONYMOUS_STRUCT struct { + UCHAR CpuThrottled:1; + UCHAR CycleProfiling:1; + UCHAR CounterProfiling:1; + UCHAR Reserved:5; + } DUMMYSTRUCTNAME; + } DUMMYUNIONNAME; + UCHAR Size; + UCHAR Hand; + } DUMMYUNIONNAME2; + _ANONYMOUS_UNION union { #if (NTDDI_VERSION >= NTDDI_WIN7) - _ANONYMOUS_UNION union { - UCHAR TimerMiscFlags; - _ANONYMOUS_STRUCT struct { + _ANONYMOUS_UNION union { + UCHAR TimerMiscFlags; + _ANONYMOUS_STRUCT struct { #if !defined(_X86_) - UCHAR Index:TIMER_EXPIRED_INDEX_BITS; + UCHAR Index:TIMER_EXPIRED_INDEX_BITS; #else - UCHAR Index:1; - UCHAR Processor:TIMER_PROCESSOR_INDEX_BITS; + UCHAR Index:1; + UCHAR Processor:TIMER_PROCESSOR_INDEX_BITS; #endif - UCHAR Inserted:1; - volatile UCHAR Expired:1; - } DUMMYSTRUCTNAME; - } DUMMYUNIONNAME; + UCHAR Inserted:1; + volatile UCHAR Expired:1; + } DUMMYSTRUCTNAME; + } DUMMYUNIONNAME; #else - /* Pre Win7 compatibility fix to latest WDK */ - UCHAR Inserted; + /* Pre Win7 compatibility fix to latest WDK */ + UCHAR Inserted; #endif - _ANONYMOUS_UNION union { - BOOLEAN DebugActive; - _ANONYMOUS_STRUCT struct { - BOOLEAN ActiveDR7:1; - BOOLEAN Instrumented:1; - BOOLEAN Reserved2:4; - BOOLEAN UmsScheduled:1; - BOOLEAN UmsPrimary:1; - } DUMMYSTRUCTNAME; - } DUMMYUNIONNAME; /* should probably be DUMMYUNIONNAME2, but this is what WDK says */ - BOOLEAN DpcActive; - } DUMMYUNIONNAME3; - } DUMMYSTRUCTNAME; - volatile LONG Lock; - } DUMMYUNIONNAME; - LONG SignalState; - LIST_ENTRY WaitListHead; + _ANONYMOUS_UNION union { + BOOLEAN DebugActive; + _ANONYMOUS_STRUCT struct { + BOOLEAN ActiveDR7:1; + BOOLEAN Instrumented:1; + BOOLEAN Reserved2:4; + BOOLEAN UmsScheduled:1; + BOOLEAN UmsPrimary:1; + } DUMMYSTRUCTNAME; + } DUMMYUNIONNAME; /* should probably be DUMMYUNIONNAME2, but this is what WDK says */ + BOOLEAN DpcActive; + } DUMMYUNIONNAME3; + } DUMMYSTRUCTNAME; + volatile LONG Lock; + } DUMMYUNIONNAME; + LONG SignalState; + LIST_ENTRY WaitListHead; } DISPATCHER_HEADER, *PDISPATCHER_HEADER; typedef struct _KEVENT { - DISPATCHER_HEADER Header; + DISPATCHER_HEADER Header; } KEVENT, *PKEVENT, *RESTRICTED_POINTER PRKEVENT; typedef struct _KSEMAPHORE { - DISPATCHER_HEADER Header; - LONG Limit; + DISPATCHER_HEADER Header; + LONG Limit; } KSEMAPHORE, *PKSEMAPHORE, *RESTRICTED_POINTER PRKSEMAPHORE; -typedef struct _KGATE -{ - DISPATCHER_HEADER Header; +#define KSEMAPHORE_ACTUAL_LENGTH (FIELD_OFFSET(KSEMAPHORE, Limit) + sizeof(LONG)) + +typedef struct _KGATE { + DISPATCHER_HEADER Header; } KGATE, *PKGATE, *RESTRICTED_POINTER PRKGATE; -typedef struct _KGUARDED_MUTEX -{ - volatile LONG Count; - PKTHREAD Owner; - ULONG Contention; - KGATE Gate; - __GNU_EXTENSION union - { - __GNU_EXTENSION struct - { - SHORT KernelApcDisable; - SHORT SpecialApcDisable; - }; - ULONG CombinedApcDisable; +typedef struct _KGUARDED_MUTEX { + volatile LONG Count; + PKTHREAD Owner; + ULONG Contention; + KGATE Gate; + __GNU_EXTENSION union { + __GNU_EXTENSION struct { + SHORT KernelApcDisable; + SHORT SpecialApcDisable; }; + ULONG CombinedApcDisable; + }; } KGUARDED_MUTEX, *PKGUARDED_MUTEX; typedef struct _KMUTANT { - DISPATCHER_HEADER Header; - LIST_ENTRY MutantListEntry; - struct _KTHREAD *RESTRICTED_POINTER OwnerThread; - BOOLEAN Abandoned; - UCHAR ApcDisable; + DISPATCHER_HEADER Header; + LIST_ENTRY MutantListEntry; + struct _KTHREAD *RESTRICTED_POINTER OwnerThread; + BOOLEAN Abandoned; + UCHAR ApcDisable; } KMUTANT, *PKMUTANT, *RESTRICTED_POINTER PRKMUTANT, KMUTEX, *PKMUTEX, *RESTRICTED_POINTER PRKMUTEX; #define TIMER_TABLE_SIZE 512 @@ -1082,9 +1369,17 @@ typedef struct _KTIMER { ULONG Period; } KTIMER, *PKTIMER, *RESTRICTED_POINTER PRKTIMER; +typedef enum _LOCK_OPERATION { + IoReadAccess, + IoWriteAccess, + IoModifyAccess +} LOCK_OPERATION; + +#define KTIMER_ACTUAL_LENGTH (FIELD_OFFSET(KTIMER, Period) + sizeof(LONG)) + typedef BOOLEAN -(DDKAPI *PKSYNCHRONIZE_ROUTINE)( - IN PVOID SynchronizeContext); +(NTAPI *PKSYNCHRONIZE_ROUTINE)( + IN PVOID SynchronizeContext); typedef enum _POOL_TYPE { NonPagedPool, @@ -1104,29 +1399,41 @@ typedef enum _POOL_TYPE { NonPagedPoolCacheAlignedMustSSession } POOL_TYPE; -typedef enum _ALTERNATIVE_ARCHITECTURE_TYPE -{ - StandardDesign, - NEC98x86, - EndAlternatives +typedef enum _ALTERNATIVE_ARCHITECTURE_TYPE { + StandardDesign, + NEC98x86, + EndAlternatives } ALTERNATIVE_ARCHITECTURE_TYPE; -typedef struct _KSYSTEM_TIME -{ - ULONG LowPart; - LONG High1Time; - LONG High2Time; +#ifndef _X86_ + +#ifndef IsNEC_98 +#define IsNEC_98 (FALSE) +#endif + +#ifndef IsNotNEC_98 +#define IsNotNEC_98 (TRUE) +#endif + +#ifndef SetNEC_98 +#define SetNEC_98 +#endif + +#ifndef SetNotNEC_98 +#define SetNotNEC_98 +#endif + +#endif + +typedef struct _KSYSTEM_TIME { + ULONG LowPart; + LONG High1Time; + LONG High2Time; } KSYSTEM_TIME, *PKSYSTEM_TIME; -typedef struct _PNP_BUS_INFORMATION { - GUID BusTypeGuid; - INTERFACE_TYPE LegacyBusType; - ULONG BusNumber; -} PNP_BUS_INFORMATION, *PPNP_BUS_INFORMATION; - typedef struct DECLSPEC_ALIGN(16) _M128A { - ULONGLONG Low; - LONGLONG High; + ULONGLONG Low; + LONGLONG High; } M128A, *PM128A; typedef struct DECLSPEC_ALIGN(16) _XSAVE_FORMAT { @@ -1155,18 +1462,110 @@ typedef struct DECLSPEC_ALIGN(16) _XSAVE_FORMAT { #endif } XSAVE_FORMAT, *PXSAVE_FORMAT; +typedef struct DECLSPEC_ALIGN(8) _XSAVE_AREA_HEADER { + ULONG64 Mask; + ULONG64 Reserved[7]; +} XSAVE_AREA_HEADER, *PXSAVE_AREA_HEADER; + +typedef struct DECLSPEC_ALIGN(16) _XSAVE_AREA { + XSAVE_FORMAT LegacyState; + XSAVE_AREA_HEADER Header; +} XSAVE_AREA, *PXSAVE_AREA; + +typedef struct _XSTATE_CONTEXT { + ULONG64 Mask; + ULONG Length; + ULONG Reserved1; + PXSAVE_AREA Area; +#if defined(_X86_) + ULONG Reserved2; +#endif + PVOID Buffer; +#if defined(_X86_) + ULONG Reserved3; +#endif +} XSTATE_CONTEXT, *PXSTATE_CONTEXT; + +typedef struct _XSTATE_SAVE { +#if defined(_AMD64_) + struct _XSTATE_SAVE* Prev; + struct _KTHREAD* Thread; + UCHAR Level; + XSTATE_CONTEXT XStateContext; +#elif defined(_IA64_) + ULONG Dummy; +#elif defined(_X86_) + union { + struct { + LONG64 Reserved1; + ULONG Reserved2; + struct _XSTATE_SAVE* Prev; + PXSAVE_AREA Reserved3; + struct _KTHREAD* Thread; + PVOID Reserved4; + UCHAR Level; + }; + XSTATE_CONTEXT XStateContext; + }; +#endif +} XSTATE_SAVE, *PXSTATE_SAVE; + +#ifdef _X86_ + +#define MAXIMUM_SUPPORTED_EXTENSION 512 + +#if !defined(__midl) && !defined(MIDL_PASS) +C_ASSERT(sizeof(XSAVE_FORMAT) == MAXIMUM_SUPPORTED_EXTENSION); +#endif + +#endif /* _X86_ */ + +#define XSAVE_ALIGN 64 +#define MINIMAL_XSTATE_AREA_LENGTH sizeof(XSAVE_AREA) + +#if !defined(__midl) && !defined(MIDL_PASS) +C_ASSERT((sizeof(XSAVE_FORMAT) & (XSAVE_ALIGN - 1)) == 0); +C_ASSERT((FIELD_OFFSET(XSAVE_AREA, Header) & (XSAVE_ALIGN - 1)) == 0); +C_ASSERT(MINIMAL_XSTATE_AREA_LENGTH == 512 + 64); +#endif + +typedef struct _CONTEXT_CHUNK { + LONG Offset; + ULONG Length; +} CONTEXT_CHUNK, *PCONTEXT_CHUNK; + +typedef struct _CONTEXT_EX { + CONTEXT_CHUNK All; + CONTEXT_CHUNK Legacy; + CONTEXT_CHUNK XState; +} CONTEXT_EX, *PCONTEXT_EX; + +#define CONTEXT_EX_LENGTH ALIGN_UP_BY(sizeof(CONTEXT_EX), STACK_ALIGN) + +#if (NTDDI_VERSION >= NTDDI_VISTA) +extern NTSYSAPI volatile CCHAR KeNumberProcessors; +#elif (NTDDI_VERSION >= NTDDI_WINXP) +extern NTSYSAPI CCHAR KeNumberProcessors; +#else +extern PCCHAR KeNumberProcessors; +#endif /****************************************************************************** * Memory manager Types * ******************************************************************************/ -#define MM_DONT_ZERO_ALLOCATION 0x00000001 -#define MM_ALLOCATE_FROM_LOCAL_NODE_ONLY 0x00000002 -#define MM_ALLOCATE_FULLY_REQUIRED 0x00000004 -#define MM_ALLOCATE_NO_WAIT 0x00000008 -#define MM_ALLOCATE_PREFER_CONTIGUOUS 0x00000010 -#define MM_ALLOCATE_REQUIRE_CONTIGUOUS_CHUNKS 0x00000020 +#if (NTDDI_VERSION >= NTDDI_WIN2K) +typedef ULONG NODE_REQUIREMENT; +#define MM_ANY_NODE_OK 0x80000000 +#endif + +#define MM_DONT_ZERO_ALLOCATION 0x00000001 +#define MM_ALLOCATE_FROM_LOCAL_NODE_ONLY 0x00000002 +#define MM_ALLOCATE_FULLY_REQUIRED 0x00000004 +#define MM_ALLOCATE_NO_WAIT 0x00000008 +#define MM_ALLOCATE_PREFER_CONTIGUOUS 0x00000010 +#define MM_ALLOCATE_REQUIRE_CONTIGUOUS_CHUNKS 0x00000020 #define MDL_MAPPED_TO_SYSTEM_VA 0x0001 #define MDL_PAGES_LOCKED 0x0002 @@ -1249,8 +1648,8 @@ typedef struct DECLSPEC_ALIGN(16) _XSAVE_FORMAT { /* Section map options */ typedef enum _SECTION_INHERIT { - ViewShare = 1, - ViewUnmap = 2 + ViewShare = 1, + ViewUnmap = 2 } SECTION_INHERIT; typedef ULONG PFN_COUNT; @@ -1258,14 +1657,14 @@ typedef LONG_PTR SPFN_NUMBER, *PSPFN_NUMBER; typedef ULONG_PTR PFN_NUMBER, *PPFN_NUMBER; typedef struct _MDL { - struct _MDL *Next; - CSHORT Size; - CSHORT MdlFlags; - struct _EPROCESS *Process; - PVOID MappedSystemVa; - PVOID StartVa; - ULONG ByteCount; - ULONG ByteOffset; + struct _MDL *Next; + CSHORT Size; + CSHORT MdlFlags; + struct _EPROCESS *Process; + PVOID MappedSystemVa; + PVOID StartVa; + ULONG ByteCount; + ULONG ByteOffset; } MDL, *PMDL; typedef MDL *PMDLX; @@ -1289,18 +1688,15 @@ typedef enum _MM_PAGE_PRIORITY { HighPagePriority = 32 } MM_PAGE_PRIORITY; -typedef enum _LOCK_OPERATION { - IoReadAccess, - IoWriteAccess, - IoModifyAccess -} LOCK_OPERATION; - typedef enum _MM_SYSTEM_SIZE { MmSmallSystem, MmMediumSystem, MmLargeSystem } MM_SYSTEMSIZE; +extern NTKERNELAPI BOOLEAN Mm64BitPhysicalAddress; +extern PVOID MmBadPointer; + /****************************************************************************** * Executive Types * @@ -1310,12 +1706,6 @@ typedef enum _MM_SYSTEM_SIZE { #define EX_RUNDOWN_COUNT_SHIFT 0x1 #define EX_RUNDOWN_COUNT_INC (1 << EX_RUNDOWN_COUNT_SHIFT) -#ifdef _WIN64 -#define PORT_MAXIMUM_MESSAGE_LENGTH 512 -#else -#define PORT_MAXIMUM_MESSAGE_LENGTH 256 -#endif - typedef struct _FAST_MUTEX { volatile LONG Count; PKTHREAD Owner; @@ -1325,35 +1715,35 @@ typedef struct _FAST_MUTEX { } FAST_MUTEX, *PFAST_MUTEX; typedef enum _SUITE_TYPE { - SmallBusiness, - Enterprise, - BackOffice, - CommunicationServer, - TerminalServer, - SmallBusinessRestricted, - EmbeddedNT, - DataCenter, - SingleUserTS, - Personal, - Blade, - EmbeddedRestricted, - SecurityAppliance, - StorageServer, - ComputeServer, - WHServer, - MaxSuiteType + SmallBusiness, + Enterprise, + BackOffice, + CommunicationServer, + TerminalServer, + SmallBusinessRestricted, + EmbeddedNT, + DataCenter, + SingleUserTS, + Personal, + Blade, + EmbeddedRestricted, + SecurityAppliance, + StorageServer, + ComputeServer, + WHServer, + MaxSuiteType } SUITE_TYPE; typedef enum _EX_POOL_PRIORITY { - LowPoolPriority, - LowPoolPrioritySpecialPoolOverrun = 8, - LowPoolPrioritySpecialPoolUnderrun = 9, - NormalPoolPriority = 16, - NormalPoolPrioritySpecialPoolOverrun = 24, - NormalPoolPrioritySpecialPoolUnderrun = 25, - HighPoolPriority = 32, - HighPoolPrioritySpecialPoolOverrun = 40, - HighPoolPrioritySpecialPoolUnderrun = 41 + LowPoolPriority, + LowPoolPrioritySpecialPoolOverrun = 8, + LowPoolPrioritySpecialPoolUnderrun = 9, + NormalPoolPriority = 16, + NormalPoolPrioritySpecialPoolOverrun = 24, + NormalPoolPrioritySpecialPoolUnderrun = 25, + HighPoolPriority = 32, + HighPoolPrioritySpecialPoolOverrun = 40, + HighPoolPrioritySpecialPoolUnderrun = 41 } EX_POOL_PRIORITY; #if !defined(_WIN64) && (defined(_NTDDK_) || defined(_NTIFS_) || defined(_NDIS_)) @@ -1365,32 +1755,33 @@ typedef enum _EX_POOL_PRIORITY { typedef struct _LOOKASIDE_LIST_EX *PLOOKASIDE_LIST_EX; typedef PVOID -(DDKAPI *PALLOCATE_FUNCTION)( - IN POOL_TYPE PoolType, - IN SIZE_T NumberOfBytes, - IN ULONG Tag); +(NTAPI *PALLOCATE_FUNCTION)( + IN POOL_TYPE PoolType, + IN SIZE_T NumberOfBytes, + IN ULONG Tag); typedef PVOID -(DDKAPI *PALLOCATE_FUNCTION_EX)( - IN POOL_TYPE PoolType, - IN SIZE_T NumberOfBytes, - IN ULONG Tag, - IN OUT PLOOKASIDE_LIST_EX Lookaside); +(NTAPI *PALLOCATE_FUNCTION_EX)( + IN POOL_TYPE PoolType, + IN SIZE_T NumberOfBytes, + IN ULONG Tag, + IN OUT PLOOKASIDE_LIST_EX Lookaside); typedef VOID -(DDKAPI *PFREE_FUNCTION)( - IN PVOID Buffer); +(NTAPI *PFREE_FUNCTION)( + IN PVOID Buffer); typedef VOID -(DDKAPI *PFREE_FUNCTION_EX)( - IN PVOID Buffer, - IN OUT PLOOKASIDE_LIST_EX Lookaside); +(NTAPI *PFREE_FUNCTION_EX)( + IN PVOID Buffer, + IN OUT PLOOKASIDE_LIST_EX Lookaside); typedef VOID -(DDKAPI *PCALLBACK_FUNCTION)( - IN PVOID CallbackContext, - IN PVOID Argument1, - IN PVOID Argument2); +(NTAPI CALLBACK_FUNCTION)( + IN PVOID CallbackContext OPTIONAL, + IN PVOID Argument1 OPTIONAL, + IN PVOID Argument2 OPTIONAL); +typedef CALLBACK_FUNCTION *PCALLBACK_FUNCTION; #define GENERAL_LOOKASIDE_LAYOUT \ union { \ @@ -1433,50 +1824,149 @@ typedef VOID ULONG Future[2]; typedef struct LOOKASIDE_ALIGN _GENERAL_LOOKASIDE { - GENERAL_LOOKASIDE_LAYOUT + GENERAL_LOOKASIDE_LAYOUT } GENERAL_LOOKASIDE, *PGENERAL_LOOKASIDE; typedef struct _GENERAL_LOOKASIDE_POOL { - GENERAL_LOOKASIDE_LAYOUT + GENERAL_LOOKASIDE_LAYOUT } GENERAL_LOOKASIDE_POOL, *PGENERAL_LOOKASIDE_POOL; +#define LOOKASIDE_CHECK(f) \ + C_ASSERT(FIELD_OFFSET(GENERAL_LOOKASIDE,f) == FIELD_OFFSET(GENERAL_LOOKASIDE_POOL,f)) + +LOOKASIDE_CHECK(TotalFrees); +LOOKASIDE_CHECK(Tag); +LOOKASIDE_CHECK(Future); + typedef struct _PAGED_LOOKASIDE_LIST { - GENERAL_LOOKASIDE L; + GENERAL_LOOKASIDE L; #if !defined(_AMD64_) && !defined(_IA64_) - FAST_MUTEX Lock__ObsoleteButDoNotDelete; + FAST_MUTEX Lock__ObsoleteButDoNotDelete; #endif } PAGED_LOOKASIDE_LIST, *PPAGED_LOOKASIDE_LIST; typedef struct LOOKASIDE_ALIGN _NPAGED_LOOKASIDE_LIST { - GENERAL_LOOKASIDE L; + GENERAL_LOOKASIDE L; #if !defined(_AMD64_) && !defined(_IA64_) - KSPIN_LOCK Lock__ObsoleteButDoNotDelete; + KSPIN_LOCK Lock__ObsoleteButDoNotDelete; #endif } NPAGED_LOOKASIDE_LIST, *PNPAGED_LOOKASIDE_LIST; +#define LOOKASIDE_MINIMUM_BLOCK_SIZE (RTL_SIZEOF_THROUGH_FIELD (SLIST_ENTRY, Next)) + typedef struct _LOOKASIDE_LIST_EX { - GENERAL_LOOKASIDE_POOL L; + GENERAL_LOOKASIDE_POOL L; } LOOKASIDE_LIST_EX; +#if (NTDDI_VERSION >= NTDDI_VISTA) + +#define EX_LOOKASIDE_LIST_EX_FLAGS_RAISE_ON_FAIL 0x00000001UL +#define EX_LOOKASIDE_LIST_EX_FLAGS_FAIL_NO_RAISE 0x00000002UL + +#define EX_MAXIMUM_LOOKASIDE_DEPTH_BASE 256 +#define EX_MAXIMUM_LOOKASIDE_DEPTH_LIMIT 1024 + +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + typedef struct _EX_RUNDOWN_REF { - __GNU_EXTENSION union { - volatile ULONG_PTR Count; - volatile PVOID Ptr; - }; + __GNU_EXTENSION union { + volatile ULONG_PTR Count; + volatile PVOID Ptr; + }; } EX_RUNDOWN_REF, *PEX_RUNDOWN_REF; -typedef struct _EX_RUNDOWN_REF_CACHE_AWARE *PEX_RUNDOWN_REF_CACHE_AWARE; +typedef struct _EX_RUNDOWN_REF_CACHE_AWARE *PEX_RUNDOWN_REF_CACHE_AWARE; + +typedef enum _WORK_QUEUE_TYPE { + CriticalWorkQueue, + DelayedWorkQueue, + HyperCriticalWorkQueue, + MaximumWorkQueue +} WORK_QUEUE_TYPE; typedef VOID -(DDKAPI *PWORKER_THREAD_ROUTINE)( +(NTAPI WORKER_THREAD_ROUTINE)( IN PVOID Parameter); +typedef WORKER_THREAD_ROUTINE *PWORKER_THREAD_ROUTINE; typedef struct _WORK_QUEUE_ITEM { - LIST_ENTRY List; - PWORKER_THREAD_ROUTINE WorkerRoutine; - volatile PVOID Parameter; + LIST_ENTRY List; + PWORKER_THREAD_ROUTINE WorkerRoutine; + volatile PVOID Parameter; } WORK_QUEUE_ITEM, *PWORK_QUEUE_ITEM; +typedef ULONG_PTR ERESOURCE_THREAD, *PERESOURCE_THREAD; + +typedef struct _OWNER_ENTRY { + ERESOURCE_THREAD OwnerThread; + union { + struct { + ULONG IoPriorityBoosted:1; + ULONG OwnerReferenced:1; + ULONG OwnerCount:30; + }; + ULONG TableSize; + }; +} OWNER_ENTRY, *POWNER_ENTRY; + +typedef struct _ERESOURCE { + LIST_ENTRY SystemResourcesList; + POWNER_ENTRY OwnerTable; + SHORT ActiveCount; + USHORT Flag; + volatile PKSEMAPHORE SharedWaiters; + volatile PKEVENT ExclusiveWaiters; + OWNER_ENTRY OwnerEntry; + ULONG ActiveEntries; + ULONG ContentionCount; + ULONG NumberOfSharedWaiters; + ULONG NumberOfExclusiveWaiters; +#if defined(_WIN64) + PVOID Reserved2; +#endif + __GNU_EXTENSION union { + PVOID Address; + ULONG_PTR CreatorBackTraceIndex; + }; + KSPIN_LOCK SpinLock; +} ERESOURCE, *PERESOURCE; + +/* ERESOURCE.Flag */ +#define ResourceNeverExclusive 0x0010 +#define ResourceReleaseByOtherThread 0x0020 +#define ResourceOwnedExclusive 0x0080 + +#define RESOURCE_HASH_TABLE_SIZE 64 + +typedef struct _RESOURCE_HASH_ENTRY { + LIST_ENTRY ListEntry; + PVOID Address; + ULONG ContentionCount; + ULONG Number; +} RESOURCE_HASH_ENTRY, *PRESOURCE_HASH_ENTRY; + +typedef struct _RESOURCE_PERFORMANCE_DATA { + ULONG ActiveResourceCount; + ULONG TotalResourceCount; + ULONG ExclusiveAcquire; + ULONG SharedFirstLevel; + ULONG SharedSecondLevel; + ULONG StarveFirstLevel; + ULONG StarveSecondLevel; + ULONG WaitForExclusive; + ULONG OwnerTableExpands; + ULONG MaximumTableExpand; + LIST_ENTRY HashTable[RESOURCE_HASH_TABLE_SIZE]; +} RESOURCE_PERFORMANCE_DATA, *PRESOURCE_PERFORMANCE_DATA; + +/* Global debug flag */ +#if DEVL +extern ULONG NtGlobalFlag; +#define IF_NTOS_DEBUG(FlagName) if (NtGlobalFlag & (FLG_##FlagName)) +#else +#define IF_NTOS_DEBUG(FlagName) if(FALSE) +#endif + /****************************************************************************** * Security Manager Types * @@ -1508,10 +1998,10 @@ typedef PVOID PSID; #define GENERIC_ALL 0x10000000L typedef struct _GENERIC_MAPPING { - ACCESS_MASK GenericRead; - ACCESS_MASK GenericWrite; - ACCESS_MASK GenericExecute; - ACCESS_MASK GenericAll; + ACCESS_MASK GenericRead; + ACCESS_MASK GenericWrite; + ACCESS_MASK GenericExecute; + ACCESS_MASK GenericAll; } GENERIC_MAPPING, *PGENERIC_MAPPING; #define ACL_REVISION 2 @@ -1525,11 +2015,11 @@ typedef struct _GENERIC_MAPPING { #define MAX_ACL_REVISION ACL_REVISION4 typedef struct _ACL { - UCHAR AclRevision; - UCHAR Sbz1; - USHORT AclSize; - USHORT AceCount; - USHORT Sbz2; + UCHAR AclRevision; + UCHAR Sbz1; + USHORT AclSize; + USHORT AceCount; + USHORT Sbz2; } ACL, *PACL; /* Current security descriptor revision value */ @@ -1549,8 +2039,8 @@ typedef struct _ACL { #include typedef struct _LUID_AND_ATTRIBUTES { - LUID Luid; - ULONG Attributes; + LUID Luid; + ULONG Attributes; } LUID_AND_ATTRIBUTES, *PLUID_AND_ATTRIBUTES; #include @@ -1561,16 +2051,16 @@ typedef LUID_AND_ATTRIBUTES_ARRAY *PLUID_AND_ATTRIBUTES_ARRAY; #define PRIVILEGE_SET_ALL_NECESSARY (1) typedef struct _PRIVILEGE_SET { - ULONG PrivilegeCount; - ULONG Control; - LUID_AND_ATTRIBUTES Privilege[ANYSIZE_ARRAY]; + ULONG PrivilegeCount; + ULONG Control; + LUID_AND_ATTRIBUTES Privilege[ANYSIZE_ARRAY]; } PRIVILEGE_SET,*PPRIVILEGE_SET; typedef enum _SECURITY_IMPERSONATION_LEVEL { - SecurityAnonymous, - SecurityIdentification, - SecurityImpersonation, - SecurityDelegation + SecurityAnonymous, + SecurityIdentification, + SecurityImpersonation, + SecurityDelegation } SECURITY_IMPERSONATION_LEVEL, * PSECURITY_IMPERSONATION_LEVEL; #define SECURITY_MAX_IMPERSONATION_LEVEL SecurityDelegation @@ -1584,17 +2074,17 @@ typedef enum _SECURITY_IMPERSONATION_LEVEL { typedef BOOLEAN SECURITY_CONTEXT_TRACKING_MODE, *PSECURITY_CONTEXT_TRACKING_MODE; typedef struct _SECURITY_QUALITY_OF_SERVICE { - ULONG Length; - SECURITY_IMPERSONATION_LEVEL ImpersonationLevel; - SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode; - BOOLEAN EffectiveOnly; + ULONG Length; + SECURITY_IMPERSONATION_LEVEL ImpersonationLevel; + SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode; + BOOLEAN EffectiveOnly; } SECURITY_QUALITY_OF_SERVICE, *PSECURITY_QUALITY_OF_SERVICE; typedef struct _SE_IMPERSONATION_STATE { - PACCESS_TOKEN Token; - BOOLEAN CopyOnOpen; - BOOLEAN EffectiveOnly; - SECURITY_IMPERSONATION_LEVEL Level; + PACCESS_TOKEN Token; + BOOLEAN CopyOnOpen; + BOOLEAN EffectiveOnly; + SECURITY_IMPERSONATION_LEVEL Level; } SE_IMPERSONATION_STATE, *PSE_IMPERSONATION_STATE; #define OWNER_SECURITY_INFORMATION (0x00000001L) @@ -1618,9 +2108,9 @@ typedef enum _SECURITY_OPERATION_CODE { #define INITIAL_PRIVILEGE_COUNT 3 typedef struct _INITIAL_PRIVILEGE_SET { - ULONG PrivilegeCount; - ULONG Control; - LUID_AND_ATTRIBUTES Privilege[INITIAL_PRIVILEGE_COUNT]; + ULONG PrivilegeCount; + ULONG Control; + LUID_AND_ATTRIBUTES Privilege[INITIAL_PRIVILEGE_COUNT]; } INITIAL_PRIVILEGE_SET, * PINITIAL_PRIVILEGE_SET; #define SE_MIN_WELL_KNOWN_PRIVILEGE 2 @@ -1661,35 +2151,38 @@ typedef struct _INITIAL_PRIVILEGE_SET { #define SE_MAX_WELL_KNOWN_PRIVILEGE SE_CREATE_SYMBOLIC_LINK_PRIVILEGE typedef struct _SECURITY_SUBJECT_CONTEXT { - PACCESS_TOKEN ClientToken; - SECURITY_IMPERSONATION_LEVEL ImpersonationLevel; - PACCESS_TOKEN PrimaryToken; - PVOID ProcessAuditId; + PACCESS_TOKEN ClientToken; + SECURITY_IMPERSONATION_LEVEL ImpersonationLevel; + PACCESS_TOKEN PrimaryToken; + PVOID ProcessAuditId; } SECURITY_SUBJECT_CONTEXT, *PSECURITY_SUBJECT_CONTEXT; typedef struct _ACCESS_STATE { - LUID OperationID; - BOOLEAN SecurityEvaluated; - BOOLEAN GenerateAudit; - BOOLEAN GenerateOnClose; - BOOLEAN PrivilegesAllocated; - ULONG Flags; - ACCESS_MASK RemainingDesiredAccess; - ACCESS_MASK PreviouslyGrantedAccess; - ACCESS_MASK OriginalDesiredAccess; - SECURITY_SUBJECT_CONTEXT SubjectSecurityContext; - PSECURITY_DESCRIPTOR SecurityDescriptor; - PVOID AuxData; + LUID OperationID; + BOOLEAN SecurityEvaluated; + BOOLEAN GenerateAudit; + BOOLEAN GenerateOnClose; + BOOLEAN PrivilegesAllocated; + ULONG Flags; + ACCESS_MASK RemainingDesiredAccess; + ACCESS_MASK PreviouslyGrantedAccess; + ACCESS_MASK OriginalDesiredAccess; + SECURITY_SUBJECT_CONTEXT SubjectSecurityContext; + PSECURITY_DESCRIPTOR SecurityDescriptor; + PVOID AuxData; union { - INITIAL_PRIVILEGE_SET InitialPrivilegeSet; - PRIVILEGE_SET PrivilegeSet; + INITIAL_PRIVILEGE_SET InitialPrivilegeSet; + PRIVILEGE_SET PrivilegeSet; } Privileges; - - BOOLEAN AuditPrivileges; - UNICODE_STRING ObjectName; - UNICODE_STRING ObjectTypeName; + BOOLEAN AuditPrivileges; + UNICODE_STRING ObjectName; + UNICODE_STRING ObjectTypeName; } ACCESS_STATE, *PACCESS_STATE; +typedef VOID +(NTAPI *PNTFS_DEREF_EXPORTED_SECURITY_DESCRIPTOR)( + IN PVOID Vcb, + IN PSECURITY_DESCRIPTOR SecurityDescriptor); #ifndef _NTLSA_IFS_ @@ -1760,8 +2253,8 @@ typedef struct _SE_ADT_PARAMETER_ARRAY_ENTRY { typedef struct _SE_ADT_ACCESS_REASON { ACCESS_MASK AccessMask; - ULONG AccessReasons[32]; - ULONG ObjectTypeIndex; + ULONG AccessReasons[32]; + ULONG ObjectTypeIndex; ULONG AccessGranted; PSECURITY_DESCRIPTOR SecurityDescriptor; } SE_ADT_ACCESS_REASON, *PSE_ADT_ACCESS_REASON; @@ -1780,7 +2273,6 @@ typedef struct _SE_ADT_PARAMETER_ARRAY { #endif /* !_NTLSA_AUDIT_ */ #endif /* !_NTLSA_IFS_ */ - /****************************************************************************** * Power Management Support Types * ******************************************************************************/ @@ -1788,99 +2280,112 @@ typedef struct _SE_ADT_PARAMETER_ARRAY { #ifndef _PO_DDK_ #define _PO_DDK_ +#define PO_CB_SYSTEM_POWER_POLICY 0 +#define PO_CB_AC_STATUS 1 +#define PO_CB_BUTTON_COLLISION 2 +#define PO_CB_SYSTEM_STATE_LOCK 3 +#define PO_CB_LID_SWITCH_STATE 4 +#define PO_CB_PROCESSOR_POWER_POLICY 5 + /* Power States/Levels */ typedef enum _SYSTEM_POWER_STATE { - PowerSystemUnspecified, - PowerSystemWorking, - PowerSystemSleeping1, - PowerSystemSleeping2, - PowerSystemSleeping3, - PowerSystemHibernate, - PowerSystemShutdown, - PowerSystemMaximum + PowerSystemUnspecified = 0, + PowerSystemWorking, + PowerSystemSleeping1, + PowerSystemSleeping2, + PowerSystemSleeping3, + PowerSystemHibernate, + PowerSystemShutdown, + PowerSystemMaximum } SYSTEM_POWER_STATE, *PSYSTEM_POWER_STATE; #define POWER_SYSTEM_MAXIMUM PowerSystemMaximum typedef enum _POWER_INFORMATION_LEVEL { - SystemPowerPolicyAc, - SystemPowerPolicyDc, - VerifySystemPolicyAc, - VerifySystemPolicyDc, - SystemPowerCapabilities, - SystemBatteryState, - SystemPowerStateHandler, - ProcessorStateHandler, - SystemPowerPolicyCurrent, - AdministratorPowerPolicy, - SystemReserveHiberFile, - ProcessorInformation, - SystemPowerInformation, - ProcessorStateHandler2, - LastWakeTime, - LastSleepTime, - SystemExecutionState, - SystemPowerStateNotifyHandler, - ProcessorPowerPolicyAc, - ProcessorPowerPolicyDc, - VerifyProcessorPowerPolicyAc, - VerifyProcessorPowerPolicyDc, - ProcessorPowerPolicyCurrent, - SystemPowerStateLogging, - SystemPowerLoggingEntry, - SetPowerSettingValue, - NotifyUserPowerSetting, - PowerInformationLevelUnused0, - PowerInformationLevelUnused1, - SystemVideoState, - TraceApplicationPowerMessage, - TraceApplicationPowerMessageEnd, - ProcessorPerfStates, - ProcessorIdleStates, - ProcessorCap, - SystemWakeSource, - SystemHiberFileInformation, - TraceServicePowerMessage, - ProcessorLoad, - PowerShutdownNotification, - MonitorCapabilities, - SessionPowerInit, - SessionDisplayState, - PowerRequestCreate, - PowerRequestAction, - GetPowerRequestList, - ProcessorInformationEx, - NotifyUserModeLegacyPowerEvent, - GroupPark, - ProcessorIdleDomains, - WakeTimerList, - SystemHiberFileSize, - PowerInformationLevelMaximum + SystemPowerPolicyAc, + SystemPowerPolicyDc, + VerifySystemPolicyAc, + VerifySystemPolicyDc, + SystemPowerCapabilities, + SystemBatteryState, + SystemPowerStateHandler, + ProcessorStateHandler, + SystemPowerPolicyCurrent, + AdministratorPowerPolicy, + SystemReserveHiberFile, + ProcessorInformation, + SystemPowerInformation, + ProcessorStateHandler2, + LastWakeTime, + LastSleepTime, + SystemExecutionState, + SystemPowerStateNotifyHandler, + ProcessorPowerPolicyAc, + ProcessorPowerPolicyDc, + VerifyProcessorPowerPolicyAc, + VerifyProcessorPowerPolicyDc, + ProcessorPowerPolicyCurrent, + SystemPowerStateLogging, + SystemPowerLoggingEntry, + SetPowerSettingValue, + NotifyUserPowerSetting, + PowerInformationLevelUnused0, + PowerInformationLevelUnused1, + SystemVideoState, + TraceApplicationPowerMessage, + TraceApplicationPowerMessageEnd, + ProcessorPerfStates, + ProcessorIdleStates, + ProcessorCap, + SystemWakeSource, + SystemHiberFileInformation, + TraceServicePowerMessage, + ProcessorLoad, + PowerShutdownNotification, + MonitorCapabilities, + SessionPowerInit, + SessionDisplayState, + PowerRequestCreate, + PowerRequestAction, + GetPowerRequestList, + ProcessorInformationEx, + NotifyUserModeLegacyPowerEvent, + GroupPark, + ProcessorIdleDomains, + WakeTimerList, + SystemHiberFileSize, + PowerInformationLevelMaximum } POWER_INFORMATION_LEVEL; typedef enum { - PowerActionNone, - PowerActionReserved, - PowerActionSleep, - PowerActionHibernate, - PowerActionShutdown, - PowerActionShutdownReset, - PowerActionShutdownOff, - PowerActionWarmEject + PowerActionNone = 0, + PowerActionReserved, + PowerActionSleep, + PowerActionHibernate, + PowerActionShutdown, + PowerActionShutdownReset, + PowerActionShutdownOff, + PowerActionWarmEject } POWER_ACTION, *PPOWER_ACTION; typedef enum _DEVICE_POWER_STATE { - PowerDeviceUnspecified, - PowerDeviceD0, - PowerDeviceD1, - PowerDeviceD2, - PowerDeviceD3, - PowerDeviceMaximum + PowerDeviceUnspecified = 0, + PowerDeviceD0, + PowerDeviceD1, + PowerDeviceD2, + PowerDeviceD3, + PowerDeviceMaximum } DEVICE_POWER_STATE, *PDEVICE_POWER_STATE; +typedef enum _MONITOR_DISPLAY_STATE { + PowerMonitorOff = 0, + PowerMonitorOn, + PowerMonitorDim +} MONITOR_DISPLAY_STATE, *PMONITOR_DISPLAY_STATE; + typedef union _POWER_STATE { - SYSTEM_POWER_STATE SystemState; - DEVICE_POWER_STATE DeviceState; + SYSTEM_POWER_STATE SystemState; + DEVICE_POWER_STATE DeviceState; } POWER_STATE, *PPOWER_STATE; typedef enum _POWER_STATE_TYPE { @@ -1888,39 +2393,297 @@ typedef enum _POWER_STATE_TYPE { DevicePowerState } POWER_STATE_TYPE, *PPOWER_STATE_TYPE; +#if (NTDDI_VERSION >= NTDDI_VISTA) +typedef struct _SYSTEM_POWER_STATE_CONTEXT { + union { + struct { + ULONG Reserved1:8; + ULONG TargetSystemState:4; + ULONG EffectiveSystemState:4; + ULONG CurrentSystemState:4; + ULONG IgnoreHibernationPath:1; + ULONG PseudoTransition:1; + ULONG Reserved2:10; + } DUMMYSTRUCTNAME; + ULONG ContextAsUlong; + } DUMMYUNIONNAME; +} SYSTEM_POWER_STATE_CONTEXT, *PSYSTEM_POWER_STATE_CONTEXT; +#endif + +#if (NTDDI_VERSION >= NTDDI_WIN7) +typedef struct _COUNTED_REASON_CONTEXT { + ULONG Version; + ULONG Flags; + union { + struct { + UNICODE_STRING ResourceFileName; + USHORT ResourceReasonId; + ULONG StringCount; + PUNICODE_STRING ReasonStrings; + } DUMMYSTRUCTNAME; + UNICODE_STRING SimpleString; + } DUMMYUNIONNAME; +} COUNTED_REASON_CONTEXT, *PCOUNTED_REASON_CONTEXT; +#endif + +#define IOCTL_QUERY_DEVICE_POWER_STATE \ + CTL_CODE(FILE_DEVICE_BATTERY, 0x0, METHOD_BUFFERED, FILE_READ_ACCESS) + +#define IOCTL_SET_DEVICE_WAKE \ + CTL_CODE(FILE_DEVICE_BATTERY, 0x1, METHOD_BUFFERED, FILE_WRITE_ACCESS) + +#define IOCTL_CANCEL_DEVICE_WAKE \ + CTL_CODE(FILE_DEVICE_BATTERY, 0x2, METHOD_BUFFERED, FILE_WRITE_ACCESS) + +#define ES_SYSTEM_REQUIRED 0x00000001 +#define ES_DISPLAY_REQUIRED 0x00000002 +#define ES_USER_PRESENT 0x00000004 +#define ES_CONTINUOUS 0x80000000 + +typedef ULONG EXECUTION_STATE, *PEXECUTION_STATE; + +typedef enum { + LT_DONT_CARE, + LT_LOWEST_LATENCY +} LATENCY_TIME; + +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN7) +#define DIAGNOSTIC_REASON_VERSION 0 +#define DIAGNOSTIC_REASON_SIMPLE_STRING 0x00000001 +#define DIAGNOSTIC_REASON_DETAILED_STRING 0x00000002 +#define DIAGNOSTIC_REASON_NOT_SPECIFIED 0x80000000 +#define DIAGNOSTIC_REASON_INVALID_FLAGS (~0x80000003) +#endif + +#define POWER_REQUEST_CONTEXT_VERSION 0 +#define POWER_REQUEST_CONTEXT_SIMPLE_STRING 0x00000001 +#define POWER_REQUEST_CONTEXT_DETAILED_STRING 0x00000002 + +#define PowerRequestMaximum 3 + +typedef enum _POWER_REQUEST_TYPE { + PowerRequestDisplayRequired, + PowerRequestSystemRequired, + PowerRequestAwayModeRequired +} POWER_REQUEST_TYPE, *PPOWER_REQUEST_TYPE; + +#if (NTDDI_VERSION >= NTDDI_WINXP) + +#define PDCAP_D0_SUPPORTED 0x00000001 +#define PDCAP_D1_SUPPORTED 0x00000002 +#define PDCAP_D2_SUPPORTED 0x00000004 +#define PDCAP_D3_SUPPORTED 0x00000008 +#define PDCAP_WAKE_FROM_D0_SUPPORTED 0x00000010 +#define PDCAP_WAKE_FROM_D1_SUPPORTED 0x00000020 +#define PDCAP_WAKE_FROM_D2_SUPPORTED 0x00000040 +#define PDCAP_WAKE_FROM_D3_SUPPORTED 0x00000080 +#define PDCAP_WARM_EJECT_SUPPORTED 0x00000100 + +typedef struct CM_Power_Data_s { + ULONG PD_Size; + DEVICE_POWER_STATE PD_MostRecentPowerState; + ULONG PD_Capabilities; + ULONG PD_D1Latency; + ULONG PD_D2Latency; + ULONG PD_D3Latency; + DEVICE_POWER_STATE PD_PowerStateMapping[PowerSystemMaximum]; + SYSTEM_POWER_STATE PD_DeepestSystemWake; +} CM_POWER_DATA, *PCM_POWER_DATA; + +#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ + +typedef enum _SYSTEM_POWER_CONDITION { + PoAc, + PoDc, + PoHot, + PoConditionMaximum +} SYSTEM_POWER_CONDITION; + +typedef struct _SET_POWER_SETTING_VALUE { + ULONG Version; + GUID Guid; + SYSTEM_POWER_CONDITION PowerCondition; + ULONG DataLength; + UCHAR Data[ANYSIZE_ARRAY]; +} SET_POWER_SETTING_VALUE, *PSET_POWER_SETTING_VALUE; + +#define POWER_SETTING_VALUE_VERSION (0x1) + +typedef struct _NOTIFY_USER_POWER_SETTING { + GUID Guid; +} NOTIFY_USER_POWER_SETTING, *PNOTIFY_USER_POWER_SETTING; + +typedef struct _APPLICATIONLAUNCH_SETTING_VALUE { + LARGE_INTEGER ActivationTime; + ULONG Flags; + ULONG ButtonInstanceID; +} APPLICATIONLAUNCH_SETTING_VALUE, *PAPPLICATIONLAUNCH_SETTING_VALUE; + +typedef enum _POWER_PLATFORM_ROLE { + PlatformRoleUnspecified = 0, + PlatformRoleDesktop, + PlatformRoleMobile, + PlatformRoleWorkstation, + PlatformRoleEnterpriseServer, + PlatformRoleSOHOServer, + PlatformRoleAppliancePC, + PlatformRolePerformanceServer, + PlatformRoleMaximum +} POWER_PLATFORM_ROLE; + #if (NTDDI_VERSION >= NTDDI_WINXP) || !defined(_BATCLASS_) typedef struct { - ULONG Granularity; - ULONG Capacity; + ULONG Granularity; + ULONG Capacity; } BATTERY_REPORTING_SCALE, *PBATTERY_REPORTING_SCALE; #endif /* (NTDDI_VERSION >= NTDDI_WINXP) || !defined(_BATCLASS_) */ #endif /* !_PO_DDK_ */ +#define CORE_PARKING_POLICY_CHANGE_IDEAL 0 +#define CORE_PARKING_POLICY_CHANGE_SINGLE 1 +#define CORE_PARKING_POLICY_CHANGE_ROCKET 2 +#define CORE_PARKING_POLICY_CHANGE_MAX CORE_PARKING_POLICY_CHANGE_ROCKET + +DEFINE_GUID(GUID_MAX_POWER_SAVINGS, 0xA1841308, 0x3541, 0x4FAB, 0xBC, 0x81, 0xF7, 0x15, 0x56, 0xF2, 0x0B, 0x4A ); +DEFINE_GUID(GUID_MIN_POWER_SAVINGS, 0x8C5E7FDA, 0xE8BF, 0x4A96, 0x9A, 0x85, 0xA6, 0xE2, 0x3A, 0x8C, 0x63, 0x5C ); +DEFINE_GUID(GUID_TYPICAL_POWER_SAVINGS, 0x381B4222, 0xF694, 0x41F0, 0x96, 0x85, 0xFF, 0x5B, 0xB2, 0x60, 0xDF, 0x2E ); +DEFINE_GUID(NO_SUBGROUP_GUID, 0xFEA3413E, 0x7E05, 0x4911, 0x9A, 0x71, 0x70, 0x03, 0x31, 0xF1, 0xC2, 0x94 ); +DEFINE_GUID(ALL_POWERSCHEMES_GUID, 0x68A1E95E, 0x13EA, 0x41E1, 0x80, 0x11, 0x0C, 0x49, 0x6C, 0xA4, 0x90, 0xB0 ); +DEFINE_GUID(GUID_POWERSCHEME_PERSONALITY, 0x245D8541, 0x3943, 0x4422, 0xB0, 0x25, 0x13, 0xA7, 0x84, 0xF6, 0x79, 0xB7 ); +DEFINE_GUID(GUID_ACTIVE_POWERSCHEME, 0x31F9F286, 0x5084, 0x42FE, 0xB7, 0x20, 0x2B, 0x02, 0x64, 0x99, 0x37, 0x63 ); +DEFINE_GUID(GUID_VIDEO_SUBGROUP, 0x7516B95F, 0xF776, 0x4464, 0x8C, 0x53, 0x06, 0x16, 0x7F, 0x40, 0xCC, 0x99 ); +DEFINE_GUID(GUID_VIDEO_POWERDOWN_TIMEOUT, 0x3C0BC021, 0xC8A8, 0x4E07, 0xA9, 0x73, 0x6B, 0x14, 0xCB, 0xCB, 0x2B, 0x7E ); +DEFINE_GUID(GUID_VIDEO_ANNOYANCE_TIMEOUT, 0x82DBCF2D, 0xCD67, 0x40C5, 0xBF, 0xDC, 0x9F, 0x1A, 0x5C, 0xCD, 0x46, 0x63 ); +DEFINE_GUID(GUID_VIDEO_ADAPTIVE_PERCENT_INCREASE, 0xEED904DF, 0xB142, 0x4183, 0xB1, 0x0B, 0x5A, 0x11, 0x97, 0xA3, 0x78, 0x64 ); +DEFINE_GUID(GUID_VIDEO_DIM_TIMEOUT, 0x17aaa29b, 0x8b43, 0x4b94, 0xaa, 0xfe, 0x35, 0xf6, 0x4d, 0xaa, 0xf1, 0xee); +DEFINE_GUID(GUID_VIDEO_ADAPTIVE_POWERDOWN, 0x90959D22, 0xD6A1, 0x49B9, 0xAF, 0x93, 0xBC, 0xE8, 0x85, 0xAD, 0x33, 0x5B ); +DEFINE_GUID(GUID_MONITOR_POWER_ON, 0x02731015, 0x4510, 0x4526, 0x99, 0xE6, 0xE5, 0xA1, 0x7E, 0xBD, 0x1A, 0xEA ); +DEFINE_GUID(GUID_DEVICE_POWER_POLICY_VIDEO_BRIGHTNESS, 0xaded5e82L, 0xb909, 0x4619, 0x99, 0x49, 0xf5, 0xd7, 0x1d, 0xac, 0x0b, 0xcb); +DEFINE_GUID(GUID_DEVICE_POWER_POLICY_VIDEO_DIM_BRIGHTNESS, 0xf1fbfde2, 0xa960, 0x4165, 0x9f, 0x88, 0x50, 0x66, 0x79, 0x11, 0xce, 0x96); +DEFINE_GUID(GUID_VIDEO_CURRENT_MONITOR_BRIGHTNESS, 0x8ffee2c6, 0x2d01, 0x46be, 0xad, 0xb9, 0x39, 0x8a, 0xdd, 0xc5, 0xb4, 0xff); +DEFINE_GUID(GUID_VIDEO_ADAPTIVE_DISPLAY_BRIGHTNESS, 0xFBD9AA66, 0x9553, 0x4097, 0xBA, 0x44, 0xED, 0x6E, 0x9D, 0x65, 0xEA, 0xB8); +DEFINE_GUID(GUID_SESSION_DISPLAY_STATE, 0x73A5E93A, 0x5BB1, 0x4F93, 0x89, 0x5B, 0xDB, 0xD0, 0xDA, 0x85, 0x59, 0x67 ); +DEFINE_GUID(GUID_CONSOLE_DISPLAY_STATE, 0x6fe69556, 0x704a, 0x47a0, 0x8f, 0x24, 0xc2, 0x8d, 0x93, 0x6f, 0xda, 0x47); +DEFINE_GUID(GUID_ALLOW_DISPLAY_REQUIRED, 0xA9CEB8DA, 0xCD46, 0x44FB, 0xA9, 0x8B, 0x02, 0xAF, 0x69, 0xDE, 0x46, 0x23 ); +DEFINE_GUID(GUID_DISK_SUBGROUP, 0x0012EE47, 0x9041, 0x4B5D, 0x9B, 0x77, 0x53, 0x5F, 0xBA, 0x8B, 0x14, 0x42 ); +DEFINE_GUID(GUID_DISK_POWERDOWN_TIMEOUT, 0x6738E2C4, 0xE8A5, 0x4A42, 0xB1, 0x6A, 0xE0, 0x40, 0xE7, 0x69, 0x75, 0x6E ); +DEFINE_GUID(GUID_DISK_BURST_IGNORE_THRESHOLD, 0x80e3c60e, 0xbb94, 0x4ad8, 0xbb, 0xe0, 0x0d, 0x31, 0x95, 0xef, 0xc6, 0x63 ); +DEFINE_GUID(GUID_DISK_ADAPTIVE_POWERDOWN, 0x396A32E1, 0x499A, 0x40B2, 0x91, 0x24, 0xA9, 0x6A, 0xFE, 0x70, 0x76, 0x67 ); +DEFINE_GUID(GUID_SLEEP_SUBGROUP, 0x238C9FA8, 0x0AAD, 0x41ED, 0x83, 0xF4, 0x97, 0xBE, 0x24, 0x2C, 0x8F, 0x20 ); +DEFINE_GUID(GUID_SLEEP_IDLE_THRESHOLD, 0x81cd32e0, 0x7833, 0x44f3, 0x87, 0x37, 0x70, 0x81, 0xf3, 0x8d, 0x1f, 0x70 ); +DEFINE_GUID(GUID_STANDBY_TIMEOUT, 0x29F6C1DB, 0x86DA, 0x48C5, 0x9F, 0xDB, 0xF2, 0xB6, 0x7B, 0x1F, 0x44, 0xDA ); +DEFINE_GUID(GUID_UNATTEND_SLEEP_TIMEOUT, 0x7bc4a2f9, 0xd8fc, 0x4469, 0xb0, 0x7b, 0x33, 0xeb, 0x78, 0x5a, 0xac, 0xa0 ); +DEFINE_GUID(GUID_HIBERNATE_TIMEOUT, 0x9D7815A6, 0x7EE4, 0x497E, 0x88, 0x88, 0x51, 0x5A, 0x05, 0xF0, 0x23, 0x64 ); +DEFINE_GUID(GUID_HIBERNATE_FASTS4_POLICY, 0x94AC6D29, 0x73CE, 0x41A6, 0x80, 0x9F, 0x63, 0x63, 0xBA, 0x21, 0xB4, 0x7E ); +DEFINE_GUID(GUID_CRITICAL_POWER_TRANSITION, 0xB7A27025, 0xE569, 0x46c2, 0xA5, 0x04, 0x2B, 0x96, 0xCA, 0xD2, 0x25, 0xA1); +DEFINE_GUID(GUID_SYSTEM_AWAYMODE, 0x98A7F580, 0x01F7, 0x48AA, 0x9C, 0x0F, 0x44, 0x35, 0x2C, 0x29, 0xE5, 0xC0 ); +DEFINE_GUID(GUID_ALLOW_AWAYMODE, 0x25dfa149, 0x5dd1, 0x4736, 0xb5, 0xab, 0xe8, 0xa3, 0x7b, 0x5b, 0x81, 0x87 ); +DEFINE_GUID(GUID_ALLOW_STANDBY_STATES, 0xabfc2519, 0x3608, 0x4c2a, 0x94, 0xea, 0x17, 0x1b, 0x0e, 0xd5, 0x46, 0xab ); +DEFINE_GUID(GUID_ALLOW_RTC_WAKE, 0xBD3B718A, 0x0680, 0x4D9D, 0x8A, 0xB2, 0xE1, 0xD2, 0xB4, 0xAC, 0x80, 0x6D ); +DEFINE_GUID(GUID_ALLOW_SYSTEM_REQUIRED, 0xA4B195F5, 0x8225, 0x47D8, 0x80, 0x12, 0x9D, 0x41, 0x36, 0x97, 0x86, 0xE2 ); +DEFINE_GUID(GUID_SYSTEM_BUTTON_SUBGROUP, 0x4F971E89, 0xEEBD, 0x4455, 0xA8, 0xDE, 0x9E, 0x59, 0x04, 0x0E, 0x73, 0x47 ); +DEFINE_GUID(GUID_POWERBUTTON_ACTION, 0x7648EFA3, 0xDD9C, 0x4E3E, 0xB5, 0x66, 0x50, 0xF9, 0x29, 0x38, 0x62, 0x80 ); +DEFINE_GUID(GUID_POWERBUTTON_ACTION_FLAGS, 0x857E7FAC, 0x034B, 0x4704, 0xAB, 0xB1, 0xBC, 0xA5, 0x4A, 0xA3, 0x14, 0x78 ); +DEFINE_GUID(GUID_SLEEPBUTTON_ACTION, 0x96996BC0, 0xAD50, 0x47EC, 0x92, 0x3B, 0x6F, 0x41, 0x87, 0x4D, 0xD9, 0xEB ); +DEFINE_GUID(GUID_SLEEPBUTTON_ACTION_FLAGS, 0x2A160AB1, 0xB69D, 0x4743, 0xB7, 0x18, 0xBF, 0x14, 0x41, 0xD5, 0xE4, 0x93 ); +DEFINE_GUID(GUID_USERINTERFACEBUTTON_ACTION, 0xA7066653, 0x8D6C, 0x40A8, 0x91, 0x0E, 0xA1, 0xF5, 0x4B, 0x84, 0xC7, 0xE5 ); +DEFINE_GUID(GUID_LIDCLOSE_ACTION, 0x5CA83367, 0x6E45, 0x459F, 0xA2, 0x7B, 0x47, 0x6B, 0x1D, 0x01, 0xC9, 0x36 ); +DEFINE_GUID(GUID_LIDCLOSE_ACTION_FLAGS, 0x97E969AC, 0x0D6C, 0x4D08, 0x92, 0x7C, 0xD7, 0xBD, 0x7A, 0xD7, 0x85, 0x7B ); +DEFINE_GUID(GUID_LIDOPEN_POWERSTATE, 0x99FF10E7, 0x23B1, 0x4C07, 0xA9, 0xD1, 0x5C, 0x32, 0x06, 0xD7, 0x41, 0xB4 ); +DEFINE_GUID(GUID_BATTERY_SUBGROUP, 0xE73A048D, 0xBF27, 0x4F12, 0x97, 0x31, 0x8B, 0x20, 0x76, 0xE8, 0x89, 0x1F ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_ACTION_0, 0x637EA02F, 0xBBCB, 0x4015, 0x8E, 0x2C, 0xA1, 0xC7, 0xB9, 0xC0, 0xB5, 0x46 ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_LEVEL_0, 0x9A66D8D7, 0x4FF7, 0x4EF9, 0xB5, 0xA2, 0x5A, 0x32, 0x6C, 0xA2, 0xA4, 0x69 ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_FLAGS_0, 0x5dbb7c9f, 0x38e9, 0x40d2, 0x97, 0x49, 0x4f, 0x8a, 0x0e, 0x9f, 0x64, 0x0f ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_ACTION_1, 0xD8742DCB, 0x3E6A, 0x4B3C, 0xB3, 0xFE, 0x37, 0x46, 0x23, 0xCD, 0xCF, 0x06 ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_LEVEL_1, 0x8183BA9A, 0xE910, 0x48DA, 0x87, 0x69, 0x14, 0xAE, 0x6D, 0xC1, 0x17, 0x0A ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_FLAGS_1, 0xbcded951, 0x187b, 0x4d05, 0xbc, 0xcc, 0xf7, 0xe5, 0x19, 0x60, 0xc2, 0x58 ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_ACTION_2, 0x421CBA38, 0x1A8E, 0x4881, 0xAC, 0x89, 0xE3, 0x3A, 0x8B, 0x04, 0xEC, 0xE4 ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_LEVEL_2, 0x07A07CA2, 0xADAF, 0x40D7, 0xB0, 0x77, 0x53, 0x3A, 0xAD, 0xED, 0x1B, 0xFA ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_FLAGS_2, 0x7fd2f0c4, 0xfeb7, 0x4da3, 0x81, 0x17, 0xe3, 0xfb, 0xed, 0xc4, 0x65, 0x82 ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_ACTION_3, 0x80472613, 0x9780, 0x455E, 0xB3, 0x08, 0x72, 0xD3, 0x00, 0x3C, 0xF2, 0xF8 ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_LEVEL_3, 0x58AFD5A6, 0xC2DD, 0x47D2, 0x9F, 0xBF, 0xEF, 0x70, 0xCC, 0x5C, 0x59, 0x65 ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_FLAGS_3, 0x73613ccf, 0xdbfa, 0x4279, 0x83, 0x56, 0x49, 0x35, 0xf6, 0xbf, 0x62, 0xf3 ); +DEFINE_GUID(GUID_PROCESSOR_SETTINGS_SUBGROUP, 0x54533251, 0x82BE, 0x4824, 0x96, 0xC1, 0x47, 0xB6, 0x0B, 0x74, 0x0D, 0x00 ); +DEFINE_GUID(GUID_PROCESSOR_THROTTLE_POLICY, 0x57027304, 0x4AF6, 0x4104, 0x92, 0x60, 0xE3, 0xD9, 0x52, 0x48, 0xFC, 0x36 ); +DEFINE_GUID(GUID_PROCESSOR_THROTTLE_MAXIMUM, 0xBC5038F7, 0x23E0, 0x4960, 0x96, 0xDA, 0x33, 0xAB, 0xAF, 0x59, 0x35, 0xEC ); +DEFINE_GUID(GUID_PROCESSOR_THROTTLE_MINIMUM, 0x893DEE8E, 0x2BEF, 0x41E0, 0x89, 0xC6, 0xB5, 0x5D, 0x09, 0x29, 0x96, 0x4C ); +DEFINE_GUID(GUID_PROCESSOR_ALLOW_THROTTLING, 0x3b04d4fd, 0x1cc7, 0x4f23, 0xab, 0x1c, 0xd1, 0x33, 0x78, 0x19, 0xc4, 0xbb ); +DEFINE_GUID(GUID_PROCESSOR_IDLESTATE_POLICY, 0x68f262a7, 0xf621, 0x4069, 0xb9, 0xa5, 0x48, 0x74, 0x16, 0x9b, 0xe2, 0x3c); +DEFINE_GUID(GUID_PROCESSOR_PERFSTATE_POLICY, 0xBBDC3814, 0x18E9, 0x4463, 0x8A, 0x55, 0xD1, 0x97, 0x32, 0x7C, 0x45, 0xC0); +DEFINE_GUID(GUID_PROCESSOR_PERF_INCREASE_THRESHOLD, 0x06cadf0e, 0x64ed, 0x448a, 0x89, 0x27, 0xce, 0x7b, 0xf9, 0x0e, 0xb3, 0x5d ); +DEFINE_GUID(GUID_PROCESSOR_PERF_DECREASE_THRESHOLD, 0x12a0ab44, 0xfe28, 0x4fa9, 0xb3, 0xbd, 0x4b, 0x64, 0xf4, 0x49, 0x60, 0xa6 ); +DEFINE_GUID(GUID_PROCESSOR_PERF_INCREASE_POLICY, 0x465e1f50, 0xb610, 0x473a, 0xab, 0x58, 0x0, 0xd1, 0x7, 0x7d, 0xc4, 0x18); +DEFINE_GUID(GUID_PROCESSOR_PERF_DECREASE_POLICY, 0x40fbefc7, 0x2e9d, 0x4d25, 0xa1, 0x85, 0xc, 0xfd, 0x85, 0x74, 0xba, 0xc6); +DEFINE_GUID(GUID_PROCESSOR_PERF_INCREASE_TIME, 0x984cf492, 0x3bed, 0x4488, 0xa8, 0xf9, 0x42, 0x86, 0xc9, 0x7b, 0xf5, 0xaa); +DEFINE_GUID(GUID_PROCESSOR_PERF_DECREASE_TIME, 0xd8edeb9b, 0x95cf, 0x4f95, 0xa7, 0x3c, 0xb0, 0x61, 0x97, 0x36, 0x93, 0xc8); +DEFINE_GUID(GUID_PROCESSOR_PERF_TIME_CHECK, 0x4d2b0152, 0x7d5c, 0x498b, 0x88, 0xe2, 0x34, 0x34, 0x53, 0x92, 0xa2, 0xc5); +DEFINE_GUID(GUID_PROCESSOR_PERF_BOOST_POLICY, 0x45bcc044, 0xd885, 0x43e2, 0x86, 0x5, 0xee, 0xe, 0xc6, 0xe9, 0x6b, 0x59); +DEFINE_GUID(GUID_PROCESSOR_IDLE_ALLOW_SCALING, 0x6c2993b0, 0x8f48, 0x481f, 0xbc, 0xc6, 0x0, 0xdd, 0x27, 0x42, 0xaa, 0x6); +DEFINE_GUID(GUID_PROCESSOR_IDLE_DISABLE, 0x5d76a2ca, 0xe8c0, 0x402f, 0xa1, 0x33, 0x21, 0x58, 0x49, 0x2d, 0x58, 0xad); +DEFINE_GUID(GUID_PROCESSOR_IDLE_TIME_CHECK, 0xc4581c31, 0x89ab, 0x4597, 0x8e, 0x2b, 0x9c, 0x9c, 0xab, 0x44, 0xe, 0x6b); +DEFINE_GUID(GUID_PROCESSOR_IDLE_DEMOTE_THRESHOLD, 0x4b92d758, 0x5a24, 0x4851, 0xa4, 0x70, 0x81, 0x5d, 0x78, 0xae, 0xe1, 0x19); +DEFINE_GUID(GUID_PROCESSOR_IDLE_PROMOTE_THRESHOLD, 0x7b224883, 0xb3cc, 0x4d79, 0x81, 0x9f, 0x83, 0x74, 0x15, 0x2c, 0xbe, 0x7c); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_INCREASE_THRESHOLD, 0xdf142941, 0x20f3, 0x4edf, 0x9a, 0x4a, 0x9c, 0x83, 0xd3, 0xd7, 0x17, 0xd1 ); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_DECREASE_THRESHOLD, 0x68dd2f27, 0xa4ce, 0x4e11, 0x84, 0x87, 0x37, 0x94, 0xe4, 0x13, 0x5d, 0xfa); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_INCREASE_POLICY, 0xc7be0679, 0x2817, 0x4d69, 0x9d, 0x02, 0x51, 0x9a, 0x53, 0x7e, 0xd0, 0xc6); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_DECREASE_POLICY, 0x71021b41, 0xc749, 0x4d21, 0xbe, 0x74, 0xa0, 0x0f, 0x33, 0x5d, 0x58, 0x2b); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_MAX_CORES, 0xea062031, 0x0e34, 0x4ff1, 0x9b, 0x6d, 0xeb, 0x10, 0x59, 0x33, 0x40, 0x28); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_MIN_CORES, 0x0cc5b647, 0xc1df, 0x4637, 0x89, 0x1a, 0xde, 0xc3, 0x5c, 0x31, 0x85, 0x83); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_INCREASE_TIME, 0x2ddd5a84, 0x5a71, 0x437e, 0x91, 0x2a, 0xdb, 0x0b, 0x8c, 0x78, 0x87, 0x32); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_DECREASE_TIME, 0xdfd10d17, 0xd5eb, 0x45dd, 0x87, 0x7a, 0x9a, 0x34, 0xdd, 0xd1, 0x5c, 0x82); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_AFFINITY_HISTORY_DECREASE_FACTOR, 0x8f7b45e3, 0xc393, 0x480a, 0x87, 0x8c, 0xf6, 0x7a, 0xc3, 0xd0, 0x70, 0x82); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_AFFINITY_HISTORY_THRESHOLD, 0x5b33697b, 0xe89d, 0x4d38, 0xaa, 0x46, 0x9e, 0x7d, 0xfb, 0x7c, 0xd2, 0xf9); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_AFFINITY_WEIGHTING, 0xe70867f1, 0xfa2f, 0x4f4e, 0xae, 0xa1, 0x4d, 0x8a, 0x0b, 0xa2, 0x3b, 0x20); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_HISTORY_DECREASE_FACTOR, 0x1299023c, 0xbc28, 0x4f0a, 0x81, 0xec, 0xd3, 0x29, 0x5a, 0x8d, 0x81, 0x5d); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_HISTORY_THRESHOLD, 0x9ac18e92, 0xaa3c, 0x4e27, 0xb3, 0x07, 0x01, 0xae, 0x37, 0x30, 0x71, 0x29); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_WEIGHTING, 0x8809c2d8, 0xb155, 0x42d4, 0xbc, 0xda, 0x0d, 0x34, 0x56, 0x51, 0xb1, 0xdb); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_THRESHOLD, 0x943c8cb6, 0x6f93, 0x4227, 0xad, 0x87, 0xe9, 0xa3, 0xfe, 0xec, 0x08, 0xd1); +DEFINE_GUID(GUID_PROCESSOR_PARKING_CORE_OVERRIDE, 0xa55612aa, 0xf624, 0x42c6, 0xa4, 0x43, 0x73, 0x97, 0xd0, 0x64, 0xc0, 0x4f); +DEFINE_GUID(GUID_PROCESSOR_PARKING_PERF_STATE, 0x447235c7, 0x6a8d, 0x4cc0, 0x8e, 0x24, 0x9e, 0xaf, 0x70, 0xb9, 0x6e, 0x2b); +DEFINE_GUID(GUID_PROCESSOR_PERF_HISTORY, 0x7d24baa7, 0x0b84, 0x480f, 0x84, 0x0c, 0x1b, 0x07, 0x43, 0xc0, 0x0f, 0x5f); +DEFINE_GUID(GUID_SYSTEM_COOLING_POLICY, 0x94D3A615, 0xA899, 0x4AC5, 0xAE, 0x2B, 0xE4, 0xD8, 0xF6, 0x34, 0x36, 0x7F); +DEFINE_GUID(GUID_LOCK_CONSOLE_ON_WAKE, 0x0E796BDB, 0x100D, 0x47D6, 0xA2, 0xD5, 0xF7, 0xD2, 0xDA, 0xA5, 0x1F, 0x51 ); +DEFINE_GUID(GUID_DEVICE_IDLE_POLICY, 0x4faab71a, 0x92e5, 0x4726, 0xb5, 0x31, 0x22, 0x45, 0x59, 0x67, 0x2d, 0x19 ); +DEFINE_GUID(GUID_ACDC_POWER_SOURCE, 0x5D3E9A59, 0xE9D5, 0x4B00, 0xA6, 0xBD, 0xFF, 0x34, 0xFF, 0x51, 0x65, 0x48 ); +DEFINE_GUID(GUID_LIDSWITCH_STATE_CHANGE, 0xBA3E0F4D, 0xB817, 0x4094, 0xA2, 0xD1, 0xD5, 0x63, 0x79, 0xE6, 0xA0, 0xF3 ); +DEFINE_GUID(GUID_BATTERY_PERCENTAGE_REMAINING, 0xA7AD8041, 0xB45A, 0x4CAE, 0x87, 0xA3, 0xEE, 0xCB, 0xB4, 0x68, 0xA9, 0xE1 ); +DEFINE_GUID(GUID_IDLE_BACKGROUND_TASK, 0x515C31D8, 0xF734, 0x163D, 0xA0, 0xFD, 0x11, 0xA0, 0x8C, 0x91, 0xE8, 0xF1 ); +DEFINE_GUID(GUID_BACKGROUND_TASK_NOTIFICATION, 0xCF23F240, 0x2A54, 0x48D8, 0xB1, 0x14, 0xDE, 0x15, 0x18, 0xFF, 0x05, 0x2E ); +DEFINE_GUID(GUID_APPLAUNCH_BUTTON, 0x1A689231, 0x7399, 0x4E9A, 0x8F, 0x99, 0xB7, 0x1F, 0x99, 0x9D, 0xB3, 0xFA ); +DEFINE_GUID(GUID_PCIEXPRESS_SETTINGS_SUBGROUP, 0x501a4d13, 0x42af,0x4429, 0x9f, 0xd1, 0xa8, 0x21, 0x8c, 0x26, 0x8e, 0x20 ); +DEFINE_GUID(GUID_PCIEXPRESS_ASPM_POLICY, 0xee12f906, 0xd277, 0x404b, 0xb6, 0xda, 0xe5, 0xfa, 0x1a, 0x57, 0x6d, 0xf5 ); +DEFINE_GUID(GUID_ENABLE_SWITCH_FORCED_SHUTDOWN, 0x833a6b62, 0xdfa4, 0x46d1, 0x82, 0xf8, 0xe0, 0x9e, 0x34, 0xd0, 0x29, 0xd6 ); + +#define PERFSTATE_POLICY_CHANGE_IDEAL 0 +#define PERFSTATE_POLICY_CHANGE_SINGLE 1 +#define PERFSTATE_POLICY_CHANGE_ROCKET 2 +#define PERFSTATE_POLICY_CHANGE_MAX PERFSTATE_POLICY_CHANGE_ROCKET + +#define PROCESSOR_PERF_BOOST_POLICY_DISABLED 0 +#define PROCESSOR_PERF_BOOST_POLICY_MAX 100 + +#define POWER_DEVICE_IDLE_POLICY_PERFORMANCE 0 +#define POWER_DEVICE_IDLE_POLICY_CONSERVATIVE 1 + typedef VOID -(DDKAPI *PREQUEST_POWER_COMPLETE)( +(NTAPI REQUEST_POWER_COMPLETE)( IN struct _DEVICE_OBJECT *DeviceObject, IN UCHAR MinorFunction, IN POWER_STATE PowerState, IN PVOID Context, IN struct _IO_STATUS_BLOCK *IoStatus); +typedef REQUEST_POWER_COMPLETE *PREQUEST_POWER_COMPLETE; typedef NTSTATUS -(DDKAPI POWER_SETTING_CALLBACK)( +(NTAPI POWER_SETTING_CALLBACK)( IN LPCGUID SettingGuid, IN PVOID Value, IN ULONG ValueLength, IN OUT PVOID Context OPTIONAL); - typedef POWER_SETTING_CALLBACK *PPOWER_SETTING_CALLBACK; -#define PO_CB_SYSTEM_POWER_POLICY 0 -#define PO_CB_AC_STATUS 1 -#define PO_CB_BUTTON_COLLISION 2 -#define PO_CB_SYSTEM_STATE_LOCK 3 -#define PO_CB_LID_SWITCH_STATE 4 -#define PO_CB_PROCESSOR_POWER_POLICY 5 /****************************************************************************** * Configuration Manager Types * @@ -1936,11 +2699,11 @@ typedef int CM_RESOURCE_TYPE; #define CmResourceTypeDma 4 #define CmResourceTypeDeviceSpecific 5 #define CmResourceTypeBusNumber 6 -#define CmResourceTypeNonArbitrated 128 -#define CmResourceTypeConfigData 128 -#define CmResourceTypeDevicePrivate 129 -#define CmResourceTypePcCardConfig 130 -#define CmResourceTypeMfCardConfig 131 +#define CmResourceTypeNonArbitrated 128 +#define CmResourceTypeConfigData 128 +#define CmResourceTypeDevicePrivate 129 +#define CmResourceTypePcCardConfig 130 +#define CmResourceTypeMfCardConfig 131 /* KEY_VALUE_Xxx.Type */ #define REG_NONE 0 @@ -1954,9 +2717,9 @@ typedef int CM_RESOURCE_TYPE; #define REG_MULTI_SZ 7 #define REG_RESOURCE_LIST 8 #define REG_FULL_RESOURCE_DESCRIPTOR 9 -#define REG_RESOURCE_REQUIREMENTS_LIST 10 -#define REG_QWORD 11 -#define REG_QWORD_LITTLE_ENDIAN 11 +#define REG_RESOURCE_REQUIREMENTS_LIST 10 +#define REG_QWORD 11 +#define REG_QWORD_LITTLE_ENDIAN 11 /* Registry Access Rights */ #define KEY_QUERY_VALUE (0x0001) @@ -2012,6 +2775,15 @@ typedef int CM_RESOURCE_TYPE; REG_OPTION_BACKUP_RESTORE |\ REG_OPTION_OPEN_LINK) +#define REG_OPEN_LEGAL_OPTION \ + (REG_OPTION_RESERVED |\ + REG_OPTION_BACKUP_RESTORE |\ + REG_OPTION_OPEN_LINK) + +#define REG_STANDARD_FORMAT 1 +#define REG_LATEST_FORMAT 2 +#define REG_NO_COMPRESSION 4 + /* Key creation/open disposition */ #define REG_CREATED_NEW_KEY (0x00000001L) #define REG_OPENED_EXISTING_KEY (0x00000002L) @@ -2027,6 +2799,7 @@ typedef int CM_RESOURCE_TYPE; #define REG_HIVE_EXACT_FILE_GROWTH (0x00000080L) #define REG_HIVE_NO_RM (0x00000100L) #define REG_HIVE_SINGLE_LOG (0x00000200L) +#define REG_BOOT_HIVE (0x00000400L) /* Unload Flags */ #define REG_FORCE_UNLOAD 1 @@ -2043,27 +2816,6 @@ typedef int CM_RESOURCE_TYPE; REG_NOTIFY_CHANGE_LAST_SET |\ REG_NOTIFY_CHANGE_SECURITY) -typedef struct _CM_FLOPPY_DEVICE_DATA { - USHORT Version; - USHORT Revision; - CHAR Size[8]; - ULONG MaxDensity; - ULONG MountDensity; - UCHAR StepRateHeadUnloadTime; - UCHAR HeadLoadTime; - UCHAR MotorOffTime; - UCHAR SectorLengthCode; - UCHAR SectorPerTrack; - UCHAR ReadWriteGapLength; - UCHAR DataTransferLength; - UCHAR FormatGapLength; - UCHAR FormatFillCharacter; - UCHAR HeadSettleTime; - UCHAR MotorSettleTime; - UCHAR MaximumTrackValue; - UCHAR DataTransferRate; -} CM_FLOPPY_DEVICE_DATA, *PCM_FLOPPY_DEVICE_DATA; - #include typedef struct _CM_PARTIAL_RESOURCE_DESCRIPTOR { UCHAR Type; @@ -2163,15 +2915,15 @@ typedef struct _CM_PARTIAL_RESOURCE_DESCRIPTOR { #define CmResourceTypeDeviceSpecific 5 #define CmResourceTypeBusNumber 6 #define CmResourceTypeMemoryLarge 7 -#define CmResourceTypeNonArbitrated 128 -#define CmResourceTypeConfigData 128 -#define CmResourceTypeDevicePrivate 129 -#define CmResourceTypePcCardConfig 130 -#define CmResourceTypeMfCardConfig 131 +#define CmResourceTypeNonArbitrated 128 +#define CmResourceTypeConfigData 128 +#define CmResourceTypeDevicePrivate 129 +#define CmResourceTypePcCardConfig 130 +#define CmResourceTypeMfCardConfig 131 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.ShareDisposition */ typedef enum _CM_SHARE_DISPOSITION { - CmResourceShareUndetermined, + CmResourceShareUndetermined = 0, CmResourceShareDeviceExclusive, CmResourceShareDriverExclusive, CmResourceShareShared @@ -2194,6 +2946,10 @@ typedef enum _CM_SHARE_DISPOSITION { #define CM_RESOURCE_INTERRUPT_MESSAGE 0x0002 #define CM_RESOURCE_INTERRUPT_POLICY_INCLUDED 0x0004 +#define CM_RESOURCE_INTERRUPT_LEVEL_LATCHED_BITS 0x0001 + +#define CM_RESOURCE_INTERRUPT_MESSAGE_TOKEN ((ULONG)-2) + /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypeMemory */ #define CM_RESOURCE_MEMORY_READ_WRITE 0x0000 #define CM_RESOURCE_MEMORY_READ_ONLY 0x0001 @@ -2207,6 +2963,15 @@ typedef enum _CM_SHARE_DISPOSITION { #define CM_RESOURCE_MEMORY_BAR 0x0080 #define CM_RESOURCE_MEMORY_COMPAT_FOR_INACCESSIBLE_RANGE 0x0100 +#define CM_RESOURCE_MEMORY_LARGE 0x0E00 +#define CM_RESOURCE_MEMORY_LARGE_40 0x0200 +#define CM_RESOURCE_MEMORY_LARGE_48 0x0400 +#define CM_RESOURCE_MEMORY_LARGE_64 0x0800 + +#define CM_RESOURCE_MEMORY_LARGE_40_MAXLEN 0x000000FFFFFFFF00 +#define CM_RESOURCE_MEMORY_LARGE_48_MAXLEN 0x0000FFFFFFFF0000 +#define CM_RESOURCE_MEMORY_LARGE_64_MAXLEN 0xFFFFFFFF00000000 + /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypeDma */ #define CM_RESOURCE_DMA_8 0x0000 #define CM_RESOURCE_DMA_16 0x0001 @@ -2217,33 +2982,92 @@ typedef enum _CM_SHARE_DISPOSITION { #define CM_RESOURCE_DMA_TYPE_B 0x0020 #define CM_RESOURCE_DMA_TYPE_F 0x0040 +typedef struct _DEVICE_FLAGS { + ULONG Failed:1; + ULONG ReadOnly:1; + ULONG Removable:1; + ULONG ConsoleIn:1; + ULONG ConsoleOut:1; + ULONG Input:1; + ULONG Output:1; +} DEVICE_FLAGS, *PDEVICE_FLAGS; + +typedef enum _INTERFACE_TYPE { + InterfaceTypeUndefined = -1, + Internal, + Isa, + Eisa, + MicroChannel, + TurboChannel, + PCIBus, + VMEBus, + NuBus, + PCMCIABus, + CBus, + MPIBus, + MPSABus, + ProcessorInternal, + InternalPowerBus, + PNPISABus, + PNPBus, + Vmcs, + MaximumInterfaceType +} INTERFACE_TYPE, *PINTERFACE_TYPE; + +typedef struct _CM_COMPONENT_INFORMATION { + DEVICE_FLAGS Flags; + ULONG Version; + ULONG Key; + KAFFINITY AffinityMask; +} CM_COMPONENT_INFORMATION, *PCM_COMPONENT_INFORMATION; + +typedef struct _CM_ROM_BLOCK { + ULONG Address; + ULONG Size; +} CM_ROM_BLOCK, *PCM_ROM_BLOCK; + typedef struct _CM_PARTIAL_RESOURCE_LIST { - USHORT Version; - USHORT Revision; - ULONG Count; + USHORT Version; + USHORT Revision; + ULONG Count; CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1]; } CM_PARTIAL_RESOURCE_LIST, *PCM_PARTIAL_RESOURCE_LIST; typedef struct _CM_FULL_RESOURCE_DESCRIPTOR { - INTERFACE_TYPE InterfaceType; - ULONG BusNumber; - CM_PARTIAL_RESOURCE_LIST PartialResourceList; + INTERFACE_TYPE InterfaceType; + ULONG BusNumber; + CM_PARTIAL_RESOURCE_LIST PartialResourceList; } CM_FULL_RESOURCE_DESCRIPTOR, *PCM_FULL_RESOURCE_DESCRIPTOR; typedef struct _CM_RESOURCE_LIST { - ULONG Count; - CM_FULL_RESOURCE_DESCRIPTOR List[1]; + ULONG Count; + CM_FULL_RESOURCE_DESCRIPTOR List[1]; } CM_RESOURCE_LIST, *PCM_RESOURCE_LIST; +typedef struct _PNP_BUS_INFORMATION { + GUID BusTypeGuid; + INTERFACE_TYPE LegacyBusType; + ULONG BusNumber; +} PNP_BUS_INFORMATION, *PPNP_BUS_INFORMATION; + #include + typedef struct _CM_INT13_DRIVE_PARAMETER { - USHORT DriveSelect; - ULONG MaxCylinders; - USHORT SectorsPerTrack; - USHORT MaxHeads; - USHORT NumberDrives; + USHORT DriveSelect; + ULONG MaxCylinders; + USHORT SectorsPerTrack; + USHORT MaxHeads; + USHORT NumberDrives; } CM_INT13_DRIVE_PARAMETER, *PCM_INT13_DRIVE_PARAMETER; +typedef struct _CM_MCA_POS_DATA { + USHORT AdapterId; + UCHAR PosData1; + UCHAR PosData2; + UCHAR PosData3; + UCHAR PosData4; +} CM_MCA_POS_DATA, *PCM_MCA_POS_DATA; + typedef struct _CM_PNP_BIOS_DEVICE_NODE { USHORT Size; UCHAR Node; @@ -2267,154 +3091,150 @@ typedef struct _CM_PNP_BIOS_INSTALLATION_CHECK { USHORT RealModeDataBaseAddress; ULONG ProtectedModeDataBaseAddress; } CM_PNP_BIOS_INSTALLATION_CHECK, *PCM_PNP_BIOS_INSTALLATION_CHECK; + #include typedef struct _CM_DISK_GEOMETRY_DEVICE_DATA { - ULONG BytesPerSector; - ULONG NumberOfCylinders; - ULONG SectorsPerTrack; - ULONG NumberOfHeads; + ULONG BytesPerSector; + ULONG NumberOfCylinders; + ULONG SectorsPerTrack; + ULONG NumberOfHeads; } CM_DISK_GEOMETRY_DEVICE_DATA, *PCM_DISK_GEOMETRY_DEVICE_DATA; typedef struct _CM_KEYBOARD_DEVICE_DATA { - USHORT Version; - USHORT Revision; - UCHAR Type; - UCHAR Subtype; - USHORT KeyboardFlags; + USHORT Version; + USHORT Revision; + UCHAR Type; + UCHAR Subtype; + USHORT KeyboardFlags; } CM_KEYBOARD_DEVICE_DATA, *PCM_KEYBOARD_DEVICE_DATA; -typedef struct _CM_MCA_POS_DATA { - USHORT AdapterId; - UCHAR PosData1; - UCHAR PosData2; - UCHAR PosData3; - UCHAR PosData4; -} CM_MCA_POS_DATA, *PCM_MCA_POS_DATA; - -#if (NTDDI_VERSION >= NTDDI_WINXP) -typedef struct CM_Power_Data_s { - ULONG PD_Size; - DEVICE_POWER_STATE PD_MostRecentPowerState; - ULONG PD_Capabilities; - ULONG PD_D1Latency; - ULONG PD_D2Latency; - ULONG PD_D3Latency; - DEVICE_POWER_STATE PD_PowerStateMapping[PowerSystemMaximum]; - SYSTEM_POWER_STATE PD_DeepestSystemWake; -} CM_POWER_DATA, *PCM_POWER_DATA; - -#define PDCAP_D0_SUPPORTED 0x00000001 -#define PDCAP_D1_SUPPORTED 0x00000002 -#define PDCAP_D2_SUPPORTED 0x00000004 -#define PDCAP_D3_SUPPORTED 0x00000008 -#define PDCAP_WAKE_FROM_D0_SUPPORTED 0x00000010 -#define PDCAP_WAKE_FROM_D1_SUPPORTED 0x00000020 -#define PDCAP_WAKE_FROM_D2_SUPPORTED 0x00000040 -#define PDCAP_WAKE_FROM_D3_SUPPORTED 0x00000080 -#define PDCAP_WARM_EJECT_SUPPORTED 0x00000100 - -#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ - typedef struct _CM_SCSI_DEVICE_DATA { - USHORT Version; - USHORT Revision; - UCHAR HostIdentifier; + USHORT Version; + USHORT Revision; + UCHAR HostIdentifier; } CM_SCSI_DEVICE_DATA, *PCM_SCSI_DEVICE_DATA; +typedef struct _CM_VIDEO_DEVICE_DATA { + USHORT Version; + USHORT Revision; + ULONG VideoClock; +} CM_VIDEO_DEVICE_DATA, *PCM_VIDEO_DEVICE_DATA; + +typedef struct _CM_SONIC_DEVICE_DATA { + USHORT Version; + USHORT Revision; + USHORT DataConfigurationRegister; + UCHAR EthernetAddress[8]; +} CM_SONIC_DEVICE_DATA, *PCM_SONIC_DEVICE_DATA; + typedef struct _CM_SERIAL_DEVICE_DATA { - USHORT Version; - USHORT Revision; - ULONG BaudClock; + USHORT Version; + USHORT Revision; + ULONG BaudClock; } CM_SERIAL_DEVICE_DATA, *PCM_SERIAL_DEVICE_DATA; +typedef struct _CM_MONITOR_DEVICE_DATA { + USHORT Version; + USHORT Revision; + USHORT HorizontalScreenSize; + USHORT VerticalScreenSize; + USHORT HorizontalResolution; + USHORT VerticalResolution; + USHORT HorizontalDisplayTimeLow; + USHORT HorizontalDisplayTime; + USHORT HorizontalDisplayTimeHigh; + USHORT HorizontalBackPorchLow; + USHORT HorizontalBackPorch; + USHORT HorizontalBackPorchHigh; + USHORT HorizontalFrontPorchLow; + USHORT HorizontalFrontPorch; + USHORT HorizontalFrontPorchHigh; + USHORT HorizontalSyncLow; + USHORT HorizontalSync; + USHORT HorizontalSyncHigh; + USHORT VerticalBackPorchLow; + USHORT VerticalBackPorch; + USHORT VerticalBackPorchHigh; + USHORT VerticalFrontPorchLow; + USHORT VerticalFrontPorch; + USHORT VerticalFrontPorchHigh; + USHORT VerticalSyncLow; + USHORT VerticalSync; + USHORT VerticalSyncHigh; +} CM_MONITOR_DEVICE_DATA, *PCM_MONITOR_DEVICE_DATA; + +typedef struct _CM_FLOPPY_DEVICE_DATA { + USHORT Version; + USHORT Revision; + CHAR Size[8]; + ULONG MaxDensity; + ULONG MountDensity; + UCHAR StepRateHeadUnloadTime; + UCHAR HeadLoadTime; + UCHAR MotorOffTime; + UCHAR SectorLengthCode; + UCHAR SectorPerTrack; + UCHAR ReadWriteGapLength; + UCHAR DataTransferLength; + UCHAR FormatGapLength; + UCHAR FormatFillCharacter; + UCHAR HeadSettleTime; + UCHAR MotorSettleTime; + UCHAR MaximumTrackValue; + UCHAR DataTransferRate; +} CM_FLOPPY_DEVICE_DATA, *PCM_FLOPPY_DEVICE_DATA; + typedef enum _KEY_INFORMATION_CLASS { KeyBasicInformation, KeyNodeInformation, KeyFullInformation, KeyNameInformation, KeyCachedInformation, - KeyFlagsInformation + KeyFlagsInformation, + KeyVirtualizationInformation, + KeyHandleTagsInformation, + MaxKeyInfoClass } KEY_INFORMATION_CLASS; typedef struct _KEY_BASIC_INFORMATION { - LARGE_INTEGER LastWriteTime; - ULONG TitleIndex; - ULONG NameLength; - WCHAR Name[1]; + LARGE_INTEGER LastWriteTime; + ULONG TitleIndex; + ULONG NameLength; + WCHAR Name[1]; } KEY_BASIC_INFORMATION, *PKEY_BASIC_INFORMATION; +typedef struct _KEY_CONTROL_FLAGS_INFORMATION { + ULONG ControlFlags; +} KEY_CONTROL_FLAGS_INFORMATION, *PKEY_CONTROL_FLAGS_INFORMATION; + typedef struct _KEY_FULL_INFORMATION { - LARGE_INTEGER LastWriteTime; - ULONG TitleIndex; - ULONG ClassOffset; - ULONG ClassLength; - ULONG SubKeys; - ULONG MaxNameLen; - ULONG MaxClassLen; - ULONG Values; - ULONG MaxValueNameLen; - ULONG MaxValueDataLen; - WCHAR Class[1]; + LARGE_INTEGER LastWriteTime; + ULONG TitleIndex; + ULONG ClassOffset; + ULONG ClassLength; + ULONG SubKeys; + ULONG MaxNameLen; + ULONG MaxClassLen; + ULONG Values; + ULONG MaxValueNameLen; + ULONG MaxValueDataLen; + WCHAR Class[1]; } KEY_FULL_INFORMATION, *PKEY_FULL_INFORMATION; +typedef struct _KEY_HANDLE_TAGS_INFORMATION { + ULONG HandleTags; +} KEY_HANDLE_TAGS_INFORMATION, *PKEY_HANDLE_TAGS_INFORMATION; + typedef struct _KEY_NODE_INFORMATION { - LARGE_INTEGER LastWriteTime; - ULONG TitleIndex; - ULONG ClassOffset; - ULONG ClassLength; - ULONG NameLength; - WCHAR Name[1]; + LARGE_INTEGER LastWriteTime; + ULONG TitleIndex; + ULONG ClassOffset; + ULONG ClassLength; + ULONG NameLength; + WCHAR Name[1]; } KEY_NODE_INFORMATION, *PKEY_NODE_INFORMATION; -typedef struct _KEY_VALUE_BASIC_INFORMATION { - ULONG TitleIndex; - ULONG Type; - ULONG NameLength; - WCHAR Name[1]; -} KEY_VALUE_BASIC_INFORMATION, *PKEY_VALUE_BASIC_INFORMATION; - -typedef struct _KEY_VALUE_FULL_INFORMATION { - ULONG TitleIndex; - ULONG Type; - ULONG DataOffset; - ULONG DataLength; - ULONG NameLength; - WCHAR Name[1]; -} KEY_VALUE_FULL_INFORMATION, *PKEY_VALUE_FULL_INFORMATION; - -typedef struct _KEY_VALUE_PARTIAL_INFORMATION { - ULONG TitleIndex; - ULONG Type; - ULONG DataLength; - UCHAR Data[1]; -} KEY_VALUE_PARTIAL_INFORMATION, *PKEY_VALUE_PARTIAL_INFORMATION; - -typedef struct _KEY_VALUE_PARTIAL_INFORMATION_ALIGN64 { - ULONG Type; - ULONG DataLength; - UCHAR Data[1]; -} KEY_VALUE_PARTIAL_INFORMATION_ALIGN64, *PKEY_VALUE_PARTIAL_INFORMATION_ALIGN64; - -typedef struct _KEY_VALUE_ENTRY { - PUNICODE_STRING ValueName; - ULONG DataLength; - ULONG DataOffset; - ULONG Type; -} KEY_VALUE_ENTRY, *PKEY_VALUE_ENTRY; - -typedef enum _KEY_VALUE_INFORMATION_CLASS { - KeyValueBasicInformation, - KeyValueFullInformation, - KeyValuePartialInformation, - KeyValueFullInformationAlign64, - KeyValuePartialInformationAlign64 -} KEY_VALUE_INFORMATION_CLASS; - -typedef struct _KEY_WRITE_TIME_INFORMATION { - LARGE_INTEGER LastWriteTime; -} KEY_WRITE_TIME_INFORMATION, *PKEY_WRITE_TIME_INFORMATION; - typedef enum _KEY_SET_INFORMATION_CLASS { KeyWriteTimeInformation, KeyWow64FlagsInformation, @@ -2425,6 +3245,65 @@ typedef enum _KEY_SET_INFORMATION_CLASS { MaxKeySetInfoClass } KEY_SET_INFORMATION_CLASS; +typedef struct _KEY_SET_VIRTUALIZATION_INFORMATION { + ULONG VirtualTarget:1; + ULONG VirtualStore:1; + ULONG VirtualSource:1; + ULONG Reserved:29; +} KEY_SET_VIRTUALIZATION_INFORMATION, *PKEY_SET_VIRTUALIZATION_INFORMATION; + +typedef struct _KEY_VALUE_BASIC_INFORMATION { + ULONG TitleIndex; + ULONG Type; + ULONG NameLength; + WCHAR Name[1]; +} KEY_VALUE_BASIC_INFORMATION, *PKEY_VALUE_BASIC_INFORMATION; + +typedef struct _KEY_VALUE_FULL_INFORMATION { + ULONG TitleIndex; + ULONG Type; + ULONG DataOffset; + ULONG DataLength; + ULONG NameLength; + WCHAR Name[1]; +} KEY_VALUE_FULL_INFORMATION, *PKEY_VALUE_FULL_INFORMATION; + +typedef struct _KEY_VALUE_PARTIAL_INFORMATION { + ULONG TitleIndex; + ULONG Type; + ULONG DataLength; + UCHAR Data[1]; +} KEY_VALUE_PARTIAL_INFORMATION, *PKEY_VALUE_PARTIAL_INFORMATION; + +typedef struct _KEY_VALUE_PARTIAL_INFORMATION_ALIGN64 { + ULONG Type; + ULONG DataLength; + UCHAR Data[1]; +} KEY_VALUE_PARTIAL_INFORMATION_ALIGN64, *PKEY_VALUE_PARTIAL_INFORMATION_ALIGN64; + +typedef struct _KEY_VALUE_ENTRY { + PUNICODE_STRING ValueName; + ULONG DataLength; + ULONG DataOffset; + ULONG Type; +} KEY_VALUE_ENTRY, *PKEY_VALUE_ENTRY; + +typedef enum _KEY_VALUE_INFORMATION_CLASS { + KeyValueBasicInformation, + KeyValueFullInformation, + KeyValuePartialInformation, + KeyValueFullInformationAlign64, + KeyValuePartialInformationAlign64 +} KEY_VALUE_INFORMATION_CLASS; + +typedef struct _KEY_WOW64_FLAGS_INFORMATION { + ULONG UserFlags; +} KEY_WOW64_FLAGS_INFORMATION, *PKEY_WOW64_FLAGS_INFORMATION; + +typedef struct _KEY_WRITE_TIME_INFORMATION { + LARGE_INTEGER LastWriteTime; +} KEY_WRITE_TIME_INFORMATION, *PKEY_WRITE_TIME_INFORMATION; + typedef enum _REG_NOTIFY_CLASS { RegNtDeleteKey, RegNtPreDeleteKey = RegNtDeleteKey, @@ -2488,11 +3367,11 @@ typedef enum _REG_NOTIFY_CLASS { } REG_NOTIFY_CLASS, *PREG_NOTIFY_CLASS; typedef NTSTATUS -(NTAPI *PEX_CALLBACK_FUNCTION)( - IN PVOID CallbackContext, - IN PVOID Argument1, - IN PVOID Argument2 -); +(NTAPI EX_CALLBACK_FUNCTION)( + IN PVOID CallbackContext, + IN PVOID Argument1, + IN PVOID Argument2); +typedef EX_CALLBACK_FUNCTION *PEX_CALLBACK_FUNCTION; typedef struct _REG_DELETE_KEY_INFORMATION { PVOID Object; @@ -2594,6 +3473,54 @@ typedef struct _REG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION { PVOID Reserved; } REG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION, *PREG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION; +typedef struct _REG_RENAME_KEY_INFORMATION { + PVOID Object; + PUNICODE_STRING NewName; + PVOID CallContext; + PVOID ObjectContext; + PVOID Reserved; +} REG_RENAME_KEY_INFORMATION, *PREG_RENAME_KEY_INFORMATION; + +typedef struct _REG_CREATE_KEY_INFORMATION { + PUNICODE_STRING CompleteName; + PVOID RootObject; + PVOID ObjectType; + ULONG CreateOptions; + PUNICODE_STRING Class; + PVOID SecurityDescriptor; + PVOID SecurityQualityOfService; + ACCESS_MASK DesiredAccess; + ACCESS_MASK GrantedAccess; + PULONG Disposition; + PVOID *ResultObject; + PVOID CallContext; + PVOID RootObjectContext; + PVOID Transaction; + PVOID Reserved; +} REG_CREATE_KEY_INFORMATION, REG_OPEN_KEY_INFORMATION,*PREG_CREATE_KEY_INFORMATION, *PREG_OPEN_KEY_INFORMATION; + +typedef struct _REG_CREATE_KEY_INFORMATION_V1 { + PUNICODE_STRING CompleteName; + PVOID RootObject; + PVOID ObjectType; + ULONG Options; + PUNICODE_STRING Class; + PVOID SecurityDescriptor; + PVOID SecurityQualityOfService; + ACCESS_MASK DesiredAccess; + ACCESS_MASK GrantedAccess; + PULONG Disposition; + PVOID *ResultObject; + PVOID CallContext; + PVOID RootObjectContext; + PVOID Transaction; + ULONG_PTR Version; + PUNICODE_STRING RemainingName; + ULONG Wow64Flags; + ULONG Attributes; + KPROCESSOR_MODE CheckAccessMode; +} REG_CREATE_KEY_INFORMATION_V1, REG_OPEN_KEY_INFORMATION_V1,*PREG_CREATE_KEY_INFORMATION_V1, *PREG_OPEN_KEY_INFORMATION_V1; + typedef struct _REG_PRE_CREATE_KEY_INFORMATION { PUNICODE_STRING CompleteName; } REG_PRE_CREATE_KEY_INFORMATION, REG_PRE_OPEN_KEY_INFORMATION,*PREG_PRE_CREATE_KEY_INFORMATION, *PREG_PRE_OPEN_KEY_INFORMATION;; @@ -2621,151 +3548,180 @@ typedef struct _REG_KEY_HANDLE_CLOSE_INFORMATION { PVOID Reserved; } REG_KEY_HANDLE_CLOSE_INFORMATION, *PREG_KEY_HANDLE_CLOSE_INFORMATION; +#if (NTDDI_VERSION >= NTDDI_VISTA) + +typedef struct _REG_LOAD_KEY_INFORMATION { + PVOID Object; + PUNICODE_STRING KeyName; + PUNICODE_STRING SourceFile; + ULONG Flags; + PVOID TrustClassObject; + PVOID UserEvent; + ACCESS_MASK DesiredAccess; + PHANDLE RootHandle; + PVOID CallContext; + PVOID ObjectContext; + PVOID Reserved; +} REG_LOAD_KEY_INFORMATION, *PREG_LOAD_KEY_INFORMATION; + +typedef struct _REG_UNLOAD_KEY_INFORMATION { + PVOID Object; + PVOID UserEvent; + PVOID CallContext; + PVOID ObjectContext; + PVOID Reserved; +} REG_UNLOAD_KEY_INFORMATION, *PREG_UNLOAD_KEY_INFORMATION; + +typedef struct _REG_CALLBACK_CONTEXT_CLEANUP_INFORMATION { + PVOID Object; + PVOID ObjectContext; + PVOID Reserved; +} REG_CALLBACK_CONTEXT_CLEANUP_INFORMATION, *PREG_CALLBACK_CONTEXT_CLEANUP_INFORMATION; + +typedef struct _REG_QUERY_KEY_SECURITY_INFORMATION { + PVOID Object; + PSECURITY_INFORMATION SecurityInformation; + PSECURITY_DESCRIPTOR SecurityDescriptor; + PULONG Length; + PVOID CallContext; + PVOID ObjectContext; + PVOID Reserved; +} REG_QUERY_KEY_SECURITY_INFORMATION, *PREG_QUERY_KEY_SECURITY_INFORMATION; + +typedef struct _REG_SET_KEY_SECURITY_INFORMATION { + PVOID Object; + PSECURITY_INFORMATION SecurityInformation; + PSECURITY_DESCRIPTOR SecurityDescriptor; + PVOID CallContext; + PVOID ObjectContext; + PVOID Reserved; +} REG_SET_KEY_SECURITY_INFORMATION, *PREG_SET_KEY_SECURITY_INFORMATION; + +typedef struct _REG_RESTORE_KEY_INFORMATION { + PVOID Object; + HANDLE FileHandle; + ULONG Flags; + PVOID CallContext; + PVOID ObjectContext; + PVOID Reserved; +} REG_RESTORE_KEY_INFORMATION, *PREG_RESTORE_KEY_INFORMATION; + +typedef struct _REG_SAVE_KEY_INFORMATION { + PVOID Object; + HANDLE FileHandle; + ULONG Format; + PVOID CallContext; + PVOID ObjectContext; + PVOID Reserved; +} REG_SAVE_KEY_INFORMATION, *PREG_SAVE_KEY_INFORMATION; + +typedef struct _REG_REPLACE_KEY_INFORMATION { + PVOID Object; + PUNICODE_STRING OldFileName; + PUNICODE_STRING NewFileName; + PVOID CallContext; + PVOID ObjectContext; + PVOID Reserved; +} REG_REPLACE_KEY_INFORMATION, *PREG_REPLACE_KEY_INFORMATION; + +#endif /* NTDDI_VERSION >= NTDDI_VISTA */ + +#define SERVICE_KERNEL_DRIVER 0x00000001 +#define SERVICE_FILE_SYSTEM_DRIVER 0x00000002 +#define SERVICE_ADAPTER 0x00000004 +#define SERVICE_RECOGNIZER_DRIVER 0x00000008 + +#define SERVICE_DRIVER (SERVICE_KERNEL_DRIVER | \ + SERVICE_FILE_SYSTEM_DRIVER | \ + SERVICE_RECOGNIZER_DRIVER) + +#define SERVICE_WIN32_OWN_PROCESS 0x00000010 +#define SERVICE_WIN32_SHARE_PROCESS 0x00000020 +#define SERVICE_WIN32 (SERVICE_WIN32_OWN_PROCESS | \ + SERVICE_WIN32_SHARE_PROCESS) + +#define SERVICE_INTERACTIVE_PROCESS 0x00000100 + +#define SERVICE_TYPE_ALL (SERVICE_WIN32 | \ + SERVICE_ADAPTER | \ + SERVICE_DRIVER | \ + SERVICE_INTERACTIVE_PROCESS) + +/* Service Start Types */ +#define SERVICE_BOOT_START 0x00000000 +#define SERVICE_SYSTEM_START 0x00000001 +#define SERVICE_AUTO_START 0x00000002 +#define SERVICE_DEMAND_START 0x00000003 +#define SERVICE_DISABLED 0x00000004 + +#define SERVICE_ERROR_IGNORE 0x00000000 +#define SERVICE_ERROR_NORMAL 0x00000001 +#define SERVICE_ERROR_SEVERE 0x00000002 +#define SERVICE_ERROR_CRITICAL 0x00000003 + +typedef enum _CM_SERVICE_NODE_TYPE { + DriverType = SERVICE_KERNEL_DRIVER, + FileSystemType = SERVICE_FILE_SYSTEM_DRIVER, + Win32ServiceOwnProcess = SERVICE_WIN32_OWN_PROCESS, + Win32ServiceShareProcess = SERVICE_WIN32_SHARE_PROCESS, + AdapterType = SERVICE_ADAPTER, + RecognizerType = SERVICE_RECOGNIZER_DRIVER +} SERVICE_NODE_TYPE; + +typedef enum _CM_SERVICE_LOAD_TYPE { + BootLoad = SERVICE_BOOT_START, + SystemLoad = SERVICE_SYSTEM_START, + AutoLoad = SERVICE_AUTO_START, + DemandLoad = SERVICE_DEMAND_START, + DisableLoad = SERVICE_DISABLED +} SERVICE_LOAD_TYPE; + +typedef enum _CM_ERROR_CONTROL_TYPE { + IgnoreError = SERVICE_ERROR_IGNORE, + NormalError = SERVICE_ERROR_NORMAL, + SevereError = SERVICE_ERROR_SEVERE, + CriticalError = SERVICE_ERROR_CRITICAL +} SERVICE_ERROR_TYPE; + +#define CM_SERVICE_NETWORK_BOOT_LOAD 0x00000001 +#define CM_SERVICE_VIRTUAL_DISK_BOOT_LOAD 0x00000002 +#define CM_SERVICE_USB_DISK_BOOT_LOAD 0x00000004 + +#define CM_SERVICE_VALID_PROMOTION_MASK (CM_SERVICE_NETWORK_BOOT_LOAD | \ + CM_SERVICE_VIRTUAL_DISK_BOOT_LOAD | \ + CM_SERVICE_USB_DISK_BOOT_LOAD) + /****************************************************************************** * I/O Manager Types * ******************************************************************************/ - /* PCI_COMMON_CONFIG.Command */ -#define PCI_ENABLE_IO_SPACE 0x0001 -#define PCI_ENABLE_MEMORY_SPACE 0x0002 -#define PCI_ENABLE_BUS_MASTER 0x0004 -#define PCI_ENABLE_SPECIAL_CYCLES 0x0008 -#define PCI_ENABLE_WRITE_AND_INVALIDATE 0x0010 -#define PCI_ENABLE_VGA_COMPATIBLE_PALETTE 0x0020 -#define PCI_ENABLE_PARITY 0x0040 -#define PCI_ENABLE_WAIT_CYCLE 0x0080 -#define PCI_ENABLE_SERR 0x0100 -#define PCI_ENABLE_FAST_BACK_TO_BACK 0x0200 -#define PCI_DISABLE_LEVEL_INTERRUPT 0x0400 +#define WDM_MAJORVERSION 0x06 +#define WDM_MINORVERSION 0x00 -/* PCI_COMMON_CONFIG.Status */ -#define PCI_STATUS_INTERRUPT_PENDING 0x0008 -#define PCI_STATUS_CAPABILITIES_LIST 0x0010 -#define PCI_STATUS_66MHZ_CAPABLE 0x0020 -#define PCI_STATUS_UDF_SUPPORTED 0x0040 -#define PCI_STATUS_FAST_BACK_TO_BACK 0x0080 -#define PCI_STATUS_DATA_PARITY_DETECTED 0x0100 -#define PCI_STATUS_DEVSEL 0x0600 -#define PCI_STATUS_SIGNALED_TARGET_ABORT 0x0800 -#define PCI_STATUS_RECEIVED_TARGET_ABORT 0x1000 -#define PCI_STATUS_RECEIVED_MASTER_ABORT 0x2000 -#define PCI_STATUS_SIGNALED_SYSTEM_ERROR 0x4000 -#define PCI_STATUS_DETECTED_PARITY_ERROR 0x8000 +#if defined(_WIN64) -/* PCI_COMMON_CONFIG.HeaderType */ -#define PCI_MULTIFUNCTION 0x80 -#define PCI_DEVICE_TYPE 0x00 -#define PCI_BRIDGE_TYPE 0x01 -#define PCI_CARDBUS_BRIDGE_TYPE 0x02 +#ifndef USE_DMA_MACROS +#define USE_DMA_MACROS +#endif -#define PCI_CONFIGURATION_TYPE(PciData) \ - (((PPCI_COMMON_CONFIG) (PciData))->HeaderType & ~PCI_MULTIFUNCTION) +#ifndef NO_LEGACY_DRIVERS +#define NO_LEGACY_DRIVERS +#endif -#define PCI_MULTIFUNCTION_DEVICE(PciData) \ - ((((PPCI_COMMON_CONFIG) (PciData))->HeaderType & PCI_MULTIFUNCTION) != 0) +#endif /* defined(_WIN64) */ -/* PCI device classes */ -#define PCI_CLASS_PRE_20 0x00 -#define PCI_CLASS_MASS_STORAGE_CTLR 0x01 -#define PCI_CLASS_NETWORK_CTLR 0x02 -#define PCI_CLASS_DISPLAY_CTLR 0x03 -#define PCI_CLASS_MULTIMEDIA_DEV 0x04 -#define PCI_CLASS_MEMORY_CTLR 0x05 -#define PCI_CLASS_BRIDGE_DEV 0x06 -#define PCI_CLASS_SIMPLE_COMMS_CTLR 0x07 -#define PCI_CLASS_BASE_SYSTEM_DEV 0x08 -#define PCI_CLASS_INPUT_DEV 0x09 -#define PCI_CLASS_DOCKING_STATION 0x0a -#define PCI_CLASS_PROCESSOR 0x0b -#define PCI_CLASS_SERIAL_BUS_CTLR 0x0c -#define PCI_CLASS_WIRELESS_CTLR 0x0d -#define PCI_CLASS_INTELLIGENT_IO_CTLR 0x0e -#define PCI_CLASS_SATELLITE_COMMS_CTLR 0x0f -#define PCI_CLASS_ENCRYPTION_DECRYPTION 0x10 -#define PCI_CLASS_DATA_ACQ_SIGNAL_PROC 0x11 +#define STATUS_CONTINUE_COMPLETION STATUS_SUCCESS -/* PCI device subclasses for class 0 */ -#define PCI_SUBCLASS_PRE_20_NON_VGA 0x00 -#define PCI_SUBCLASS_PRE_20_VGA 0x01 - -/* PCI device subclasses for class 1 (mass storage controllers)*/ -#define PCI_SUBCLASS_MSC_SCSI_BUS_CTLR 0x00 -#define PCI_SUBCLASS_MSC_IDE_CTLR 0x01 -#define PCI_SUBCLASS_MSC_FLOPPY_CTLR 0x02 -#define PCI_SUBCLASS_MSC_IPI_CTLR 0x03 -#define PCI_SUBCLASS_MSC_RAID_CTLR 0x04 -#define PCI_SUBCLASS_MSC_OTHER 0x80 - -/* PCI device subclasses for class 2 (network controllers)*/ -#define PCI_SUBCLASS_NET_ETHERNET_CTLR 0x00 -#define PCI_SUBCLASS_NET_TOKEN_RING_CTLR 0x01 -#define PCI_SUBCLASS_NET_FDDI_CTLR 0x02 -#define PCI_SUBCLASS_NET_ATM_CTLR 0x03 -#define PCI_SUBCLASS_NET_ISDN_CTLR 0x04 -#define PCI_SUBCLASS_NET_OTHER 0x80 - -/* PCI device subclasses for class 3 (display controllers)*/ -#define PCI_SUBCLASS_VID_VGA_CTLR 0x00 -#define PCI_SUBCLASS_VID_XGA_CTLR 0x01 -#define PCI_SUBCLASS_VID_3D_CTLR 0x02 -#define PCI_SUBCLASS_VID_OTHER 0x80 - -/* PCI device subclasses for class 4 (multimedia device)*/ -#define PCI_SUBCLASS_MM_VIDEO_DEV 0x00 -#define PCI_SUBCLASS_MM_AUDIO_DEV 0x01 -#define PCI_SUBCLASS_MM_TELEPHONY_DEV 0x02 -#define PCI_SUBCLASS_MM_OTHER 0x80 - -/* PCI device subclasses for class 5 (memory controller)*/ -#define PCI_SUBCLASS_MEM_RAM 0x00 -#define PCI_SUBCLASS_MEM_FLASH 0x01 -#define PCI_SUBCLASS_MEM_OTHER 0x80 - -/* PCI device subclasses for class 6 (bridge device)*/ -#define PCI_SUBCLASS_BR_HOST 0x00 -#define PCI_SUBCLASS_BR_ISA 0x01 -#define PCI_SUBCLASS_BR_EISA 0x02 -#define PCI_SUBCLASS_BR_MCA 0x03 -#define PCI_SUBCLASS_BR_PCI_TO_PCI 0x04 -#define PCI_SUBCLASS_BR_PCMCIA 0x05 -#define PCI_SUBCLASS_BR_NUBUS 0x06 -#define PCI_SUBCLASS_BR_CARDBUS 0x07 -#define PCI_SUBCLASS_BR_RACEWAY 0x08 -#define PCI_SUBCLASS_BR_OTHER 0x80 - -/* PCI device subclasses for class C (serial bus controller)*/ -#define PCI_SUBCLASS_SB_IEEE1394 0x00 -#define PCI_SUBCLASS_SB_ACCESS 0x01 -#define PCI_SUBCLASS_SB_SSA 0x02 -#define PCI_SUBCLASS_SB_USB 0x03 -#define PCI_SUBCLASS_SB_FIBRE_CHANNEL 0x04 -#define PCI_SUBCLASS_SB_SMBUS 0x05 - -#define PCI_MAX_DEVICES 32 -#define PCI_MAX_FUNCTION 8 -#define PCI_MAX_BRIDGE_NUMBER 0xFF -#define PCI_INVALID_VENDORID 0xFFFF -#define PCI_COMMON_HDR_LENGTH (FIELD_OFFSET(PCI_COMMON_CONFIG, DeviceSpecific)) - -#define PCI_ADDRESS_IO_SPACE 0x00000001 -#define PCI_ADDRESS_MEMORY_TYPE_MASK 0x00000006 -#define PCI_ADDRESS_MEMORY_PREFETCHABLE 0x00000008 -#define PCI_ADDRESS_IO_ADDRESS_MASK 0xfffffffc -#define PCI_ADDRESS_MEMORY_ADDRESS_MASK 0xfffffff0 -#define PCI_ADDRESS_ROM_ADDRESS_MASK 0xfffff800 - -#define PCI_TYPE_32BIT 0 -#define PCI_TYPE_20BIT 2 -#define PCI_TYPE_64BIT 4 +#define CONNECT_FULLY_SPECIFIED 0x1 +#define CONNECT_LINE_BASED 0x2 +#define CONNECT_MESSAGE_BASED 0x3 +#define CONNECT_FULLY_SPECIFIED_GROUP 0x4 +#define CONNECT_CURRENT_VERSION 0x4 #define POOL_COLD_ALLOCATION 256 #define POOL_QUOTA_FAIL_INSTEAD_OF_RAISE 8 #define POOL_RAISE_IF_ALLOCATION_FAILURE 16 -#define PCI_TYPE0_ADDRESSES 6 -#define PCI_TYPE1_ADDRESSES 2 -#define PCI_TYPE2_ADDRESSES 5 - #define IO_TYPE_ADAPTER 1 #define IO_TYPE_CONTROLLER 2 #define IO_TYPE_DEVICE 3 @@ -2789,47 +3745,6 @@ typedef struct _REG_KEY_HANDLE_CLOSE_INFORMATION { #define IO_RESOURCE_DEFAULT 0x02 #define IO_RESOURCE_ALTERNATIVE 0x08 -/* DEVICE_OBJECT.Flags */ -#define DO_VERIFY_VOLUME 0x00000002 -#define DO_BUFFERED_IO 0x00000004 -#define DO_EXCLUSIVE 0x00000008 -#define DO_DIRECT_IO 0x00000010 -#define DO_MAP_IO_BUFFER 0x00000020 -#define DO_DEVICE_INITIALIZING 0x00000080 -#define DO_SHUTDOWN_REGISTERED 0x00000800 -#define DO_BUS_ENUMERATED_DEVICE 0x00001000 -#define DO_POWER_PAGABLE 0x00002000 -#define DO_POWER_INRUSH 0x00004000 - -/* DEVICE_OBJECT.Characteristics */ -#define FILE_REMOVABLE_MEDIA 0x00000001 -#define FILE_READ_ONLY_DEVICE 0x00000002 -#define FILE_FLOPPY_DISKETTE 0x00000004 -#define FILE_WRITE_ONCE_MEDIA 0x00000008 -#define FILE_REMOTE_DEVICE 0x00000010 -#define FILE_DEVICE_IS_MOUNTED 0x00000020 -#define FILE_VIRTUAL_VOLUME 0x00000040 -#define FILE_AUTOGENERATED_DEVICE_NAME 0x00000080 -#define FILE_DEVICE_SECURE_OPEN 0x00000100 -#define FILE_CHARACTERISTIC_PNP_DEVICE 0x00000800 -#define FILE_CHARACTERISTIC_TS_DEVICE 0x00001000 -#define FILE_CHARACTERISTIC_WEBDAV_DEVICE 0x00002000 - -/* DEVICE_OBJECT.AlignmentRequirement */ -#define FILE_BYTE_ALIGNMENT 0x00000000 -#define FILE_WORD_ALIGNMENT 0x00000001 -#define FILE_LONG_ALIGNMENT 0x00000003 -#define FILE_QUAD_ALIGNMENT 0x00000007 -#define FILE_OCTA_ALIGNMENT 0x0000000f -#define FILE_32_BYTE_ALIGNMENT 0x0000001f -#define FILE_64_BYTE_ALIGNMENT 0x0000003f -#define FILE_128_BYTE_ALIGNMENT 0x0000007f -#define FILE_256_BYTE_ALIGNMENT 0x000000ff -#define FILE_512_BYTE_ALIGNMENT 0x000001ff - -/* DEVICE_OBJECT.DeviceType */ -#define DEVICE_TYPE ULONG - #define FILE_DEVICE_BEEP 0x00000001 #define FILE_DEVICE_CD_ROM 0x00000002 #define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003 @@ -2898,6 +3813,44 @@ typedef struct _REG_KEY_HANDLE_CLOSE_INFORMATION { #define FILE_DEVICE_BIOMETRIC 0x00000044 #define FILE_DEVICE_PMI 0x00000045 +#if defined(NT_PROCESSOR_GROUPS) + +typedef USHORT IRQ_DEVICE_POLICY, *PIRQ_DEVICE_POLICY; + +typedef enum _IRQ_DEVICE_POLICY_USHORT { + IrqPolicyMachineDefault = 0, + IrqPolicyAllCloseProcessors = 1, + IrqPolicyOneCloseProcessor = 2, + IrqPolicyAllProcessorsInMachine = 3, + IrqPolicyAllProcessorsInGroup = 3, + IrqPolicySpecifiedProcessors = 4, + IrqPolicySpreadMessagesAcrossAllProcessors = 5}; + +#else /* defined(NT_PROCESSOR_GROUPS) */ + +typedef enum _IRQ_DEVICE_POLICY { + IrqPolicyMachineDefault = 0, + IrqPolicyAllCloseProcessors, + IrqPolicyOneCloseProcessor, + IrqPolicyAllProcessorsInMachine, + IrqPolicySpecifiedProcessors, + IrqPolicySpreadMessagesAcrossAllProcessors +} IRQ_DEVICE_POLICY, *PIRQ_DEVICE_POLICY; + +#endif + +typedef enum _IRQ_PRIORITY { + IrqPriorityUndefined = 0, + IrqPriorityLow, + IrqPriorityNormal, + IrqPriorityHigh +} IRQ_PRIORITY, *PIRQ_PRIORITY; + +typedef enum _IRQ_GROUP_POLICY { + GroupAffinityAllGroupZero = 0, + GroupAffinityDontCare +} IRQ_GROUP_POLICY, *PIRQ_GROUP_POLICY; + #define MAXIMUM_VOLUME_LABEL_LENGTH (32 * sizeof(WCHAR)) typedef struct _OBJECT_HANDLE_INFORMATION { @@ -2906,24 +3859,20 @@ typedef struct _OBJECT_HANDLE_INFORMATION { } OBJECT_HANDLE_INFORMATION, *POBJECT_HANDLE_INFORMATION; typedef struct _CLIENT_ID { - HANDLE UniqueProcess; - HANDLE UniqueThread; + HANDLE UniqueProcess; + HANDLE UniqueThread; } CLIENT_ID, *PCLIENT_ID; -typedef VOID -(DDKAPI *PKSTART_ROUTINE)( - IN PVOID StartContext); - typedef struct _VPB { - CSHORT Type; - CSHORT Size; - USHORT Flags; - USHORT VolumeLabelLength; - struct _DEVICE_OBJECT *DeviceObject; - struct _DEVICE_OBJECT *RealDevice; - ULONG SerialNumber; - ULONG ReferenceCount; - WCHAR VolumeLabel[MAXIMUM_VOLUME_LABEL_LENGTH / sizeof(WCHAR)]; + CSHORT Type; + CSHORT Size; + USHORT Flags; + USHORT VolumeLabelLength; + struct _DEVICE_OBJECT *DeviceObject; + struct _DEVICE_OBJECT *RealDevice; + ULONG SerialNumber; + ULONG ReferenceCount; + WCHAR VolumeLabel[MAXIMUM_VOLUME_LABEL_LENGTH / sizeof(WCHAR)]; } VPB, *PVPB; typedef enum _IO_ALLOCATION_ACTION { @@ -2933,190 +3882,370 @@ typedef enum _IO_ALLOCATION_ACTION { } IO_ALLOCATION_ACTION, *PIO_ALLOCATION_ACTION; typedef IO_ALLOCATION_ACTION -(DDKAPI *PDRIVER_CONTROL)( - IN struct _DEVICE_OBJECT *DeviceObject, - IN struct _IRP *Irp, - IN PVOID MapRegisterBase, - IN PVOID Context); +(NTAPI DRIVER_CONTROL)( + IN struct _DEVICE_OBJECT *DeviceObject, + IN struct _IRP *Irp, + IN PVOID MapRegisterBase, + IN PVOID Context); +typedef DRIVER_CONTROL *PDRIVER_CONTROL; typedef struct _WAIT_CONTEXT_BLOCK { - KDEVICE_QUEUE_ENTRY WaitQueueEntry; - PDRIVER_CONTROL DeviceRoutine; - PVOID DeviceContext; - ULONG NumberOfMapRegisters; - PVOID DeviceObject; - PVOID CurrentIrp; - PKDPC BufferChainingDpc; + KDEVICE_QUEUE_ENTRY WaitQueueEntry; + PDRIVER_CONTROL DeviceRoutine; + PVOID DeviceContext; + ULONG NumberOfMapRegisters; + PVOID DeviceObject; + PVOID CurrentIrp; + PKDPC BufferChainingDpc; } WAIT_CONTEXT_BLOCK, *PWAIT_CONTEXT_BLOCK; +/* DEVICE_OBJECT.Flags */ +#define DO_VERIFY_VOLUME 0x00000002 +#define DO_BUFFERED_IO 0x00000004 +#define DO_EXCLUSIVE 0x00000008 +#define DO_DIRECT_IO 0x00000010 +#define DO_MAP_IO_BUFFER 0x00000020 +#define DO_DEVICE_INITIALIZING 0x00000080 +#define DO_SHUTDOWN_REGISTERED 0x00000800 +#define DO_BUS_ENUMERATED_DEVICE 0x00001000 +#define DO_POWER_PAGABLE 0x00002000 +#define DO_POWER_INRUSH 0x00004000 + +/* DEVICE_OBJECT.Characteristics */ +#define FILE_REMOVABLE_MEDIA 0x00000001 +#define FILE_READ_ONLY_DEVICE 0x00000002 +#define FILE_FLOPPY_DISKETTE 0x00000004 +#define FILE_WRITE_ONCE_MEDIA 0x00000008 +#define FILE_REMOTE_DEVICE 0x00000010 +#define FILE_DEVICE_IS_MOUNTED 0x00000020 +#define FILE_VIRTUAL_VOLUME 0x00000040 +#define FILE_AUTOGENERATED_DEVICE_NAME 0x00000080 +#define FILE_DEVICE_SECURE_OPEN 0x00000100 +#define FILE_CHARACTERISTIC_PNP_DEVICE 0x00000800 +#define FILE_CHARACTERISTIC_TS_DEVICE 0x00001000 +#define FILE_CHARACTERISTIC_WEBDAV_DEVICE 0x00002000 + +/* DEVICE_OBJECT.AlignmentRequirement */ +#define FILE_BYTE_ALIGNMENT 0x00000000 +#define FILE_WORD_ALIGNMENT 0x00000001 +#define FILE_LONG_ALIGNMENT 0x00000003 +#define FILE_QUAD_ALIGNMENT 0x00000007 +#define FILE_OCTA_ALIGNMENT 0x0000000f +#define FILE_32_BYTE_ALIGNMENT 0x0000001f +#define FILE_64_BYTE_ALIGNMENT 0x0000003f +#define FILE_128_BYTE_ALIGNMENT 0x0000007f +#define FILE_256_BYTE_ALIGNMENT 0x000000ff +#define FILE_512_BYTE_ALIGNMENT 0x000001ff + +/* DEVICE_OBJECT.DeviceType */ +#define DEVICE_TYPE ULONG + typedef struct _DEVICE_OBJECT { - CSHORT Type; - USHORT Size; - LONG ReferenceCount; - struct _DRIVER_OBJECT *DriverObject; - struct _DEVICE_OBJECT *NextDevice; - struct _DEVICE_OBJECT *AttachedDevice; - struct _IRP *CurrentIrp; - PIO_TIMER Timer; - ULONG Flags; - ULONG Characteristics; - volatile PVPB Vpb; - PVOID DeviceExtension; - DEVICE_TYPE DeviceType; - CCHAR StackSize; + CSHORT Type; + USHORT Size; + LONG ReferenceCount; + struct _DRIVER_OBJECT *DriverObject; + struct _DEVICE_OBJECT *NextDevice; + struct _DEVICE_OBJECT *AttachedDevice; + struct _IRP *CurrentIrp; + PIO_TIMER Timer; + ULONG Flags; + ULONG Characteristics; + volatile PVPB Vpb; + PVOID DeviceExtension; + DEVICE_TYPE DeviceType; + CCHAR StackSize; union { - LIST_ENTRY ListEntry; - WAIT_CONTEXT_BLOCK Wcb; + LIST_ENTRY ListEntry; + WAIT_CONTEXT_BLOCK Wcb; } Queue; - ULONG AlignmentRequirement; - KDEVICE_QUEUE DeviceQueue; - KDPC Dpc; - ULONG ActiveThreadCount; - PSECURITY_DESCRIPTOR SecurityDescriptor; - KEVENT DeviceLock; - USHORT SectorSize; - USHORT Spare1; - struct _DEVOBJ_EXTENSION *DeviceObjectExtension; - PVOID Reserved; + ULONG AlignmentRequirement; + KDEVICE_QUEUE DeviceQueue; + KDPC Dpc; + ULONG ActiveThreadCount; + PSECURITY_DESCRIPTOR SecurityDescriptor; + KEVENT DeviceLock; + USHORT SectorSize; + USHORT Spare1; + struct _DEVOBJ_EXTENSION *DeviceObjectExtension; + PVOID Reserved; } DEVICE_OBJECT, *PDEVICE_OBJECT; +typedef enum _IO_SESSION_STATE { + IoSessionStateCreated = 1, + IoSessionStateInitialized, + IoSessionStateConnected, + IoSessionStateDisconnected, + IoSessionStateDisconnectedLoggedOn, + IoSessionStateLoggedOn, + IoSessionStateLoggedOff, + IoSessionStateTerminated, + IoSessionStateMax +} IO_SESSION_STATE, *PIO_SESSION_STATE; + +typedef enum _IO_COMPLETION_ROUTINE_RESULT { + ContinueCompletion = STATUS_CONTINUE_COMPLETION, + StopCompletion = STATUS_MORE_PROCESSING_REQUIRED +} IO_COMPLETION_ROUTINE_RESULT, *PIO_COMPLETION_ROUTINE_RESULT; + +typedef struct _IO_INTERRUPT_MESSAGE_INFO_ENTRY { + PHYSICAL_ADDRESS MessageAddress; + KAFFINITY TargetProcessorSet; + PKINTERRUPT InterruptObject; + ULONG MessageData; + ULONG Vector; + KIRQL Irql; + KINTERRUPT_MODE Mode; + KINTERRUPT_POLARITY Polarity; +} IO_INTERRUPT_MESSAGE_INFO_ENTRY, *PIO_INTERRUPT_MESSAGE_INFO_ENTRY; + +typedef struct _IO_INTERRUPT_MESSAGE_INFO { + KIRQL UnifiedIrql; + ULONG MessageCount; + IO_INTERRUPT_MESSAGE_INFO_ENTRY MessageInfo[1]; +} IO_INTERRUPT_MESSAGE_INFO, *PIO_INTERRUPT_MESSAGE_INFO; + +typedef struct _IO_CONNECT_INTERRUPT_FULLY_SPECIFIED_PARAMETERS { + IN PDEVICE_OBJECT PhysicalDeviceObject; + OUT PKINTERRUPT *InterruptObject; + IN PKSERVICE_ROUTINE ServiceRoutine; + IN PVOID ServiceContext; + IN PKSPIN_LOCK SpinLock OPTIONAL; + IN KIRQL SynchronizeIrql; + IN BOOLEAN FloatingSave; + IN BOOLEAN ShareVector; + IN ULONG Vector; + IN KIRQL Irql; + IN KINTERRUPT_MODE InterruptMode; + IN KAFFINITY ProcessorEnableMask; + IN USHORT Group; +} IO_CONNECT_INTERRUPT_FULLY_SPECIFIED_PARAMETERS, *PIO_CONNECT_INTERRUPT_FULLY_SPECIFIED_PARAMETERS; + +typedef struct _IO_CONNECT_INTERRUPT_LINE_BASED_PARAMETERS { + IN PDEVICE_OBJECT PhysicalDeviceObject; + OUT PKINTERRUPT *InterruptObject; + IN PKSERVICE_ROUTINE ServiceRoutine; + IN PVOID ServiceContext; + IN PKSPIN_LOCK SpinLock OPTIONAL; + IN KIRQL SynchronizeIrql OPTIONAL; + IN BOOLEAN FloatingSave; +} IO_CONNECT_INTERRUPT_LINE_BASED_PARAMETERS, *PIO_CONNECT_INTERRUPT_LINE_BASED_PARAMETERS; + +typedef struct _IO_CONNECT_INTERRUPT_MESSAGE_BASED_PARAMETERS { + IN PDEVICE_OBJECT PhysicalDeviceObject; + union { + OUT PVOID *Generic; + OUT PIO_INTERRUPT_MESSAGE_INFO *InterruptMessageTable; + OUT PKINTERRUPT *InterruptObject; + } ConnectionContext; + IN PKMESSAGE_SERVICE_ROUTINE MessageServiceRoutine; + IN PVOID ServiceContext; + IN PKSPIN_LOCK SpinLock OPTIONAL; + IN KIRQL SynchronizeIrql OPTIONAL; + IN BOOLEAN FloatingSave; + IN PKSERVICE_ROUTINE FallBackServiceRoutine OPTIONAL; +} IO_CONNECT_INTERRUPT_MESSAGE_BASED_PARAMETERS, *PIO_CONNECT_INTERRUPT_MESSAGE_BASED_PARAMETERS; + +typedef struct _IO_CONNECT_INTERRUPT_PARAMETERS { + IN OUT ULONG Version; + union { + IO_CONNECT_INTERRUPT_FULLY_SPECIFIED_PARAMETERS FullySpecified; + IO_CONNECT_INTERRUPT_LINE_BASED_PARAMETERS LineBased; + IO_CONNECT_INTERRUPT_MESSAGE_BASED_PARAMETERS MessageBased; + }; +} IO_CONNECT_INTERRUPT_PARAMETERS, *PIO_CONNECT_INTERRUPT_PARAMETERS; + +typedef struct _IO_DISCONNECT_INTERRUPT_PARAMETERS { + IN ULONG Version; + union { + IN PVOID Generic; + IN PKINTERRUPT InterruptObject; + IN PIO_INTERRUPT_MESSAGE_INFO InterruptMessageTable; + } ConnectionContext; +} IO_DISCONNECT_INTERRUPT_PARAMETERS, *PIO_DISCONNECT_INTERRUPT_PARAMETERS; + +typedef enum _IO_ACCESS_TYPE { + ReadAccess, + WriteAccess, + ModifyAccess +} IO_ACCESS_TYPE; + +typedef enum _IO_ACCESS_MODE { + SequentialAccess, + RandomAccess +} IO_ACCESS_MODE; + +typedef enum _IO_CONTAINER_NOTIFICATION_CLASS { + IoSessionStateNotification, + IoMaxContainerNotificationClass +} IO_CONTAINER_NOTIFICATION_CLASS; + +typedef struct _IO_SESSION_STATE_NOTIFICATION { + ULONG Size; + ULONG Flags; + PVOID IoObject; + ULONG EventMask; + PVOID Context; +} IO_SESSION_STATE_NOTIFICATION, *PIO_SESSION_STATE_NOTIFICATION; + +typedef enum _IO_CONTAINER_INFORMATION_CLASS { + IoSessionStateInformation, + IoMaxContainerInformationClass +} IO_CONTAINER_INFORMATION_CLASS; + +typedef struct _IO_SESSION_STATE_INFORMATION { + ULONG SessionId; + IO_SESSION_STATE SessionState; + BOOLEAN LocalSession; +} IO_SESSION_STATE_INFORMATION, *PIO_SESSION_STATE_INFORMATION; + +#if (NTDDI_VERSION >= NTDDI_WIN7) + +typedef NTSTATUS +(NTAPI *PIO_CONTAINER_NOTIFICATION_FUNCTION)( + VOID); + +typedef NTSTATUS +(NTAPI IO_SESSION_NOTIFICATION_FUNCTION)( + IN PVOID SessionObject, + IN PVOID IoObject, + IN ULONG Event, + IN PVOID Context, + IN PVOID NotificationPayload, + IN ULONG PayloadLength); + +typedef IO_SESSION_NOTIFICATION_FUNCTION *PIO_SESSION_NOTIFICATION_FUNCTION; + +#endif + typedef struct _IO_REMOVE_LOCK_TRACKING_BLOCK * PIO_REMOVE_LOCK_TRACKING_BLOCK; typedef struct _IO_REMOVE_LOCK_COMMON_BLOCK { - BOOLEAN Removed; - BOOLEAN Reserved[3]; - volatile LONG IoCount; - KEVENT RemoveEvent; + BOOLEAN Removed; + BOOLEAN Reserved[3]; + volatile LONG IoCount; + KEVENT RemoveEvent; } IO_REMOVE_LOCK_COMMON_BLOCK; typedef struct _IO_REMOVE_LOCK_DBG_BLOCK { - LONG Signature; - LONG HighWatermark; - LONGLONG MaxLockedTicks; - LONG AllocateTag; - LIST_ENTRY LockList; - KSPIN_LOCK Spin; - volatile LONG LowMemoryCount; - ULONG Reserved1[4]; - PVOID Reserved2; - PIO_REMOVE_LOCK_TRACKING_BLOCK Blocks; + LONG Signature; + LONG HighWatermark; + LONGLONG MaxLockedTicks; + LONG AllocateTag; + LIST_ENTRY LockList; + KSPIN_LOCK Spin; + volatile LONG LowMemoryCount; + ULONG Reserved1[4]; + PVOID Reserved2; + PIO_REMOVE_LOCK_TRACKING_BLOCK Blocks; } IO_REMOVE_LOCK_DBG_BLOCK; typedef struct _IO_REMOVE_LOCK { - IO_REMOVE_LOCK_COMMON_BLOCK Common; + IO_REMOVE_LOCK_COMMON_BLOCK Common; #if DBG - IO_REMOVE_LOCK_DBG_BLOCK Dbg; + IO_REMOVE_LOCK_DBG_BLOCK Dbg; #endif } IO_REMOVE_LOCK, *PIO_REMOVE_LOCK; typedef struct _IO_WORKITEM *PIO_WORKITEM; typedef VOID -(DDKAPI IO_WORKITEM_ROUTINE)( - IN PDEVICE_OBJECT DeviceObject, - IN PVOID Context); +(NTAPI IO_WORKITEM_ROUTINE)( + IN PDEVICE_OBJECT DeviceObject, + IN PVOID Context); typedef IO_WORKITEM_ROUTINE *PIO_WORKITEM_ROUTINE; +typedef VOID +(NTAPI IO_WORKITEM_ROUTINE_EX)( + IN PVOID IoObject, + IN PVOID Context OPTIONAL, + IN PIO_WORKITEM IoWorkItem); +typedef IO_WORKITEM_ROUTINE_EX *PIO_WORKITEM_ROUTINE_EX; + typedef struct _SHARE_ACCESS { - ULONG OpenCount; - ULONG Readers; - ULONG Writers; - ULONG Deleters; - ULONG SharedRead; - ULONG SharedWrite; - ULONG SharedDelete; + ULONG OpenCount; + ULONG Readers; + ULONG Writers; + ULONG Deleters; + ULONG SharedRead; + ULONG SharedWrite; + ULONG SharedDelete; } SHARE_ACCESS, *PSHARE_ACCESS; /* While MS WDK uses inheritance in C++, we cannot do this with gcc, as inheritance, even from a struct renders the type non-POD. So we use this hack */ #define PCI_COMMON_HEADER_LAYOUT \ - USHORT VendorID; \ - USHORT DeviceID; \ - USHORT Command; \ - USHORT Status; \ - UCHAR RevisionID; \ - UCHAR ProgIf; \ - UCHAR SubClass; \ - UCHAR BaseClass; \ - UCHAR CacheLineSize; \ - UCHAR LatencyTimer; \ - UCHAR HeaderType; \ - UCHAR BIST; \ + USHORT VendorID; \ + USHORT DeviceID; \ + USHORT Command; \ + USHORT Status; \ + UCHAR RevisionID; \ + UCHAR ProgIf; \ + UCHAR SubClass; \ + UCHAR BaseClass; \ + UCHAR CacheLineSize; \ + UCHAR LatencyTimer; \ + UCHAR HeaderType; \ + UCHAR BIST; \ union { \ struct _PCI_HEADER_TYPE_0 { \ - ULONG BaseAddresses[PCI_TYPE0_ADDRESSES]; \ - ULONG CIS; \ - USHORT SubVendorID; \ - USHORT SubSystemID; \ - ULONG ROMBaseAddress; \ - UCHAR CapabilitiesPtr; \ - UCHAR Reserved1[3]; \ - ULONG Reserved2; \ - UCHAR InterruptLine; \ - UCHAR InterruptPin; \ - UCHAR MinimumGrant; \ - UCHAR MaximumLatency; \ + ULONG BaseAddresses[PCI_TYPE0_ADDRESSES]; \ + ULONG CIS; \ + USHORT SubVendorID; \ + USHORT SubSystemID; \ + ULONG ROMBaseAddress; \ + UCHAR CapabilitiesPtr; \ + UCHAR Reserved1[3]; \ + ULONG Reserved2; \ + UCHAR InterruptLine; \ + UCHAR InterruptPin; \ + UCHAR MinimumGrant; \ + UCHAR MaximumLatency; \ } type0; \ struct _PCI_HEADER_TYPE_1 { \ - ULONG BaseAddresses[PCI_TYPE1_ADDRESSES]; \ - UCHAR PrimaryBus; \ - UCHAR SecondaryBus; \ - UCHAR SubordinateBus; \ - UCHAR SecondaryLatency; \ - UCHAR IOBase; \ - UCHAR IOLimit; \ - USHORT SecondaryStatus; \ - USHORT MemoryBase; \ - USHORT MemoryLimit; \ - USHORT PrefetchBase; \ - USHORT PrefetchLimit; \ - ULONG PrefetchBaseUpper32; \ - ULONG PrefetchLimitUpper32; \ - USHORT IOBaseUpper16; \ - USHORT IOLimitUpper16; \ - UCHAR CapabilitiesPtr; \ - UCHAR Reserved1[3]; \ - ULONG ROMBaseAddress; \ - UCHAR InterruptLine; \ - UCHAR InterruptPin; \ - USHORT BridgeControl; \ + ULONG BaseAddresses[PCI_TYPE1_ADDRESSES]; \ + UCHAR PrimaryBus; \ + UCHAR SecondaryBus; \ + UCHAR SubordinateBus; \ + UCHAR SecondaryLatency; \ + UCHAR IOBase; \ + UCHAR IOLimit; \ + USHORT SecondaryStatus; \ + USHORT MemoryBase; \ + USHORT MemoryLimit; \ + USHORT PrefetchBase; \ + USHORT PrefetchLimit; \ + ULONG PrefetchBaseUpper32; \ + ULONG PrefetchLimitUpper32; \ + USHORT IOBaseUpper16; \ + USHORT IOLimitUpper16; \ + UCHAR CapabilitiesPtr; \ + UCHAR Reserved1[3]; \ + ULONG ROMBaseAddress; \ + UCHAR InterruptLine; \ + UCHAR InterruptPin; \ + USHORT BridgeControl; \ } type1; \ struct _PCI_HEADER_TYPE_2 { \ - ULONG SocketRegistersBaseAddress; \ - UCHAR CapabilitiesPtr; \ - UCHAR Reserved; \ - USHORT SecondaryStatus; \ - UCHAR PrimaryBus; \ - UCHAR SecondaryBus; \ - UCHAR SubordinateBus; \ - UCHAR SecondaryLatency; \ - struct { \ - ULONG Base; \ - ULONG Limit; \ + ULONG SocketRegistersBaseAddress; \ + UCHAR CapabilitiesPtr; \ + UCHAR Reserved; \ + USHORT SecondaryStatus; \ + UCHAR PrimaryBus; \ + UCHAR SecondaryBus; \ + UCHAR SubordinateBus; \ + UCHAR SecondaryLatency; \ + struct { \ + ULONG Base; \ + ULONG Limit; \ } Range[PCI_TYPE2_ADDRESSES-1]; \ - UCHAR InterruptLine; \ - UCHAR InterruptPin; \ - USHORT BridgeControl; \ + UCHAR InterruptLine; \ + UCHAR InterruptPin; \ + USHORT BridgeControl; \ } type2; \ } u; -typedef struct _PCI_COMMON_HEADER { - PCI_COMMON_HEADER_LAYOUT -} PCI_COMMON_HEADER, *PPCI_COMMON_HEADER; - -#ifdef __cplusplus -typedef struct _PCI_COMMON_CONFIG { - PCI_COMMON_HEADER_LAYOUT - UCHAR DeviceSpecific[192]; -} PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG; -#else -typedef struct _PCI_COMMON_CONFIG { - PCI_COMMON_HEADER DUMMYSTRUCTNAME; - UCHAR DeviceSpecific[192]; -} PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG; -#endif - typedef enum _CREATE_FILE_TYPE { CreateFileTypeNone, CreateFileTypeNamedPipe, @@ -3131,39 +4260,54 @@ typedef enum _CREATE_FILE_TYPE { typedef struct _IO_STATUS_BLOCK { _ANONYMOUS_UNION union { - NTSTATUS Status; - PVOID Pointer; + NTSTATUS Status; + PVOID Pointer; } DUMMYUNIONNAME; - ULONG_PTR Information; + ULONG_PTR Information; } IO_STATUS_BLOCK, *PIO_STATUS_BLOCK; -typedef struct _PCI_SLOT_NUMBER { - union { - struct { - ULONG DeviceNumber : 5; - ULONG FunctionNumber : 3; - ULONG Reserved : 24; - } bits; - ULONG AsULONG; - } u; -} PCI_SLOT_NUMBER, *PPCI_SLOT_NUMBER; +#if defined(_WIN64) +typedef struct _IO_STATUS_BLOCK32 { + NTSTATUS Status; + ULONG Information; +} IO_STATUS_BLOCK32, *PIO_STATUS_BLOCK32; +#endif typedef VOID -(DDKAPI *PIO_APC_ROUTINE)( +(NTAPI *PIO_APC_ROUTINE)( IN PVOID ApcContext, IN PIO_STATUS_BLOCK IoStatusBlock, IN ULONG Reserved); -typedef VOID -(DDKAPI *WMI_NOTIFICATION_CALLBACK)( - PVOID Wnode, - PVOID Context); - -#define WMIREG_ACTION_REGISTER 1 -#define WMIREG_ACTION_DEREGISTER 2 -#define WMIREG_ACTION_REREGISTER 3 -#define WMIREG_ACTION_UPDATE_GUIDS 4 -#define WMIREG_ACTION_BLOCK_IRPS 5 +#define PIO_APC_ROUTINE_DEFINED + +typedef enum _IO_SESSION_EVENT { + IoSessionEventIgnore = 0, + IoSessionEventCreated, + IoSessionEventTerminated, + IoSessionEventConnected, + IoSessionEventDisconnected, + IoSessionEventLogon, + IoSessionEventLogoff, + IoSessionEventMax +} IO_SESSION_EVENT, *PIO_SESSION_EVENT; + +#define IO_SESSION_STATE_ALL_EVENTS 0xffffffff +#define IO_SESSION_STATE_CREATION_EVENT 0x00000001 +#define IO_SESSION_STATE_TERMINATION_EVENT 0x00000002 +#define IO_SESSION_STATE_CONNECT_EVENT 0x00000004 +#define IO_SESSION_STATE_DISCONNECT_EVENT 0x00000008 +#define IO_SESSION_STATE_LOGON_EVENT 0x00000010 +#define IO_SESSION_STATE_LOGOFF_EVENT 0x00000020 + +#define IO_SESSION_STATE_VALID_EVENT_MASK 0x0000003f + +#define IO_SESSION_MAX_PAYLOAD_SIZE 256L + +typedef struct _IO_SESSION_CONNECT_INFO { + ULONG SessionId; + BOOLEAN LocalSession; +} IO_SESSION_CONNECT_INFO, *PIO_SESSION_CONNECT_INFO; #define EVENT_INCREMENT 1 #define IO_NO_INCREMENT 0 @@ -3183,105 +4327,148 @@ typedef VOID #define MM_MAXIMUM_DISK_IO_SIZE (0x10000) typedef struct _BOOTDISK_INFORMATION { - LONGLONG BootPartitionOffset; - LONGLONG SystemPartitionOffset; - ULONG BootDeviceSignature; - ULONG SystemDeviceSignature; + LONGLONG BootPartitionOffset; + LONGLONG SystemPartitionOffset; + ULONG BootDeviceSignature; + ULONG SystemDeviceSignature; } BOOTDISK_INFORMATION, *PBOOTDISK_INFORMATION; typedef struct _BOOTDISK_INFORMATION_EX { - LONGLONG BootPartitionOffset; - LONGLONG SystemPartitionOffset; - ULONG BootDeviceSignature; - ULONG SystemDeviceSignature; - GUID BootDeviceGuid; - GUID SystemDeviceGuid; - BOOLEAN BootDeviceIsGpt; - BOOLEAN SystemDeviceIsGpt; + LONGLONG BootPartitionOffset; + LONGLONG SystemPartitionOffset; + ULONG BootDeviceSignature; + ULONG SystemDeviceSignature; + GUID BootDeviceGuid; + GUID SystemDeviceGuid; + BOOLEAN BootDeviceIsGpt; + BOOLEAN SystemDeviceIsGpt; } BOOTDISK_INFORMATION_EX, *PBOOTDISK_INFORMATION_EX; -typedef struct _EISA_MEMORY_TYPE { - UCHAR ReadWrite : 1; - UCHAR Cached : 1; - UCHAR Reserved0 : 1; - UCHAR Type : 2; - UCHAR Shared : 1; - UCHAR Reserved1 : 1; - UCHAR MoreEntries : 1; -} EISA_MEMORY_TYPE, *PEISA_MEMORY_TYPE; +#if (NTDDI_VERSION >= NTDDI_WIN7) + +typedef struct _LOADER_PARTITION_INFORMATION_EX { + ULONG PartitionStyle; + ULONG PartitionNumber; + union { + ULONG Signature; + GUID DeviceId; + }; + ULONG Flags; +} LOADER_PARTITION_INFORMATION_EX, *PLOADER_PARTITION_INFORMATION_EX; + +typedef struct _BOOTDISK_INFORMATION_LITE { + ULONG NumberEntries; + LOADER_PARTITION_INFORMATION_EX Entries[1]; +} BOOTDISK_INFORMATION_LITE, *PBOOTDISK_INFORMATION_LITE; + +#else + +#if (NTDDI_VERSION >= NTDDI_VISTA) +typedef struct _BOOTDISK_INFORMATION_LITE { + ULONG BootDeviceSignature; + ULONG SystemDeviceSignature; + GUID BootDeviceGuid; + GUID SystemDeviceGuid; + BOOLEAN BootDeviceIsGpt; + BOOLEAN SystemDeviceIsGpt; +} BOOTDISK_INFORMATION_LITE, *PBOOTDISK_INFORMATION_LITE; +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ #include + +typedef struct _EISA_MEMORY_TYPE { + UCHAR ReadWrite:1; + UCHAR Cached:1; + UCHAR Reserved0:1; + UCHAR Type:2; + UCHAR Shared:1; + UCHAR Reserved1:1; + UCHAR MoreEntries:1; +} EISA_MEMORY_TYPE, *PEISA_MEMORY_TYPE; + typedef struct _EISA_MEMORY_CONFIGURATION { - EISA_MEMORY_TYPE ConfigurationByte; - UCHAR DataSize; - USHORT AddressLowWord; - UCHAR AddressHighByte; - USHORT MemorySize; + EISA_MEMORY_TYPE ConfigurationByte; + UCHAR DataSize; + USHORT AddressLowWord; + UCHAR AddressHighByte; + USHORT MemorySize; } EISA_MEMORY_CONFIGURATION, *PEISA_MEMORY_CONFIGURATION; -#include typedef struct _EISA_IRQ_DESCRIPTOR { - UCHAR Interrupt : 4; - UCHAR Reserved : 1; - UCHAR LevelTriggered : 1; - UCHAR Shared : 1; - UCHAR MoreEntries : 1; + UCHAR Interrupt:4; + UCHAR Reserved:1; + UCHAR LevelTriggered:1; + UCHAR Shared:1; + UCHAR MoreEntries:1; } EISA_IRQ_DESCRIPTOR, *PEISA_IRQ_DESCRIPTOR; typedef struct _EISA_IRQ_CONFIGURATION { - EISA_IRQ_DESCRIPTOR ConfigurationByte; - UCHAR Reserved; + EISA_IRQ_DESCRIPTOR ConfigurationByte; + UCHAR Reserved; } EISA_IRQ_CONFIGURATION, *PEISA_IRQ_CONFIGURATION; typedef struct _DMA_CONFIGURATION_BYTE0 { - UCHAR Channel : 3; - UCHAR Reserved : 3; - UCHAR Shared : 1; - UCHAR MoreEntries : 1; + UCHAR Channel:3; + UCHAR Reserved:3; + UCHAR Shared:1; + UCHAR MoreEntries:1; } DMA_CONFIGURATION_BYTE0; typedef struct _DMA_CONFIGURATION_BYTE1 { - UCHAR Reserved0 : 2; - UCHAR TransferSize : 2; - UCHAR Timing : 2; - UCHAR Reserved1 : 2; + UCHAR Reserved0:2; + UCHAR TransferSize:2; + UCHAR Timing:2; + UCHAR Reserved1:2; } DMA_CONFIGURATION_BYTE1; typedef struct _EISA_DMA_CONFIGURATION { - DMA_CONFIGURATION_BYTE0 ConfigurationByte0; - DMA_CONFIGURATION_BYTE1 ConfigurationByte1; + DMA_CONFIGURATION_BYTE0 ConfigurationByte0; + DMA_CONFIGURATION_BYTE1 ConfigurationByte1; } EISA_DMA_CONFIGURATION, *PEISA_DMA_CONFIGURATION; -#include typedef struct _EISA_PORT_DESCRIPTOR { - UCHAR NumberPorts : 5; - UCHAR Reserved : 1; - UCHAR Shared : 1; - UCHAR MoreEntries : 1; + UCHAR NumberPorts:5; + UCHAR Reserved:1; + UCHAR Shared:1; + UCHAR MoreEntries:1; } EISA_PORT_DESCRIPTOR, *PEISA_PORT_DESCRIPTOR; typedef struct _EISA_PORT_CONFIGURATION { - EISA_PORT_DESCRIPTOR Configuration; - USHORT PortAddress; + EISA_PORT_DESCRIPTOR Configuration; + USHORT PortAddress; } EISA_PORT_CONFIGURATION, *PEISA_PORT_CONFIGURATION; -#include + +typedef struct _CM_EISA_SLOT_INFORMATION { + UCHAR ReturnCode; + UCHAR ReturnFlags; + UCHAR MajorRevision; + UCHAR MinorRevision; + USHORT Checksum; + UCHAR NumberFunctions; + UCHAR FunctionInformation; + ULONG CompressedId; +} CM_EISA_SLOT_INFORMATION, *PCM_EISA_SLOT_INFORMATION; typedef struct _CM_EISA_FUNCTION_INFORMATION { - ULONG CompressedId; - UCHAR IdSlotFlags1; - UCHAR IdSlotFlags2; - UCHAR MinorRevision; - UCHAR MajorRevision; - UCHAR Selections[26]; - UCHAR FunctionFlags; - UCHAR TypeString[80]; - EISA_MEMORY_CONFIGURATION EisaMemory[9]; - EISA_IRQ_CONFIGURATION EisaIrq[7]; - EISA_DMA_CONFIGURATION EisaDma[4]; - EISA_PORT_CONFIGURATION EisaPort[20]; - UCHAR InitializationData[60]; + ULONG CompressedId; + UCHAR IdSlotFlags1; + UCHAR IdSlotFlags2; + UCHAR MinorRevision; + UCHAR MajorRevision; + UCHAR Selections[26]; + UCHAR FunctionFlags; + UCHAR TypeString[80]; + EISA_MEMORY_CONFIGURATION EisaMemory[9]; + EISA_IRQ_CONFIGURATION EisaIrq[7]; + EISA_DMA_CONFIGURATION EisaDma[4]; + EISA_PORT_CONFIGURATION EisaPort[20]; + UCHAR InitializationData[60]; } CM_EISA_FUNCTION_INFORMATION, *PCM_EISA_FUNCTION_INFORMATION; +#include + /* CM_EISA_FUNCTION_INFORMATION.FunctionFlags */ #define EISA_FUNCTION_ENABLED 0x80 @@ -3296,16 +4483,9 @@ typedef struct _CM_EISA_FUNCTION_INFORMATION { (EISA_HAS_PORT_RANGE + EISA_HAS_DMA_ENTRY + EISA_HAS_IRQ_ENTRY \ + EISA_HAS_MEMORY_ENTRY + EISA_HAS_TYPE_ENTRY) -typedef struct _CM_EISA_SLOT_INFORMATION { - UCHAR ReturnCode; - UCHAR ReturnFlags; - UCHAR MajorRevision; - UCHAR MinorRevision; - USHORT Checksum; - UCHAR NumberFunctions; - UCHAR FunctionInformation; - ULONG CompressedId; -} CM_EISA_SLOT_INFORMATION, *PCM_EISA_SLOT_INFORMATION; +#define EISA_MORE_ENTRIES 0x80 +#define EISA_SYSTEM_MEMORY 0x00 +#define EISA_MEMORY_TYPE_RAM 0x01 /* CM_EISA_SLOT_INFORMATION.ReturnCode */ @@ -3320,34 +4500,76 @@ typedef struct _CM_EISA_SLOT_INFORMATION { */ typedef VOID -(DDKAPI *PINTERFACE_REFERENCE)( - PVOID Context); +(NTAPI *PINTERFACE_REFERENCE)( + PVOID Context); typedef VOID -(DDKAPI *PINTERFACE_DEREFERENCE)( +(NTAPI *PINTERFACE_DEREFERENCE)( PVOID Context); typedef BOOLEAN -(DDKAPI *PTRANSLATE_BUS_ADDRESS)( - IN PVOID Context, - IN PHYSICAL_ADDRESS BusAddress, - IN ULONG Length, - IN OUT PULONG AddressSpace, +(NTAPI TRANSLATE_BUS_ADDRESS)( + IN PVOID Context, + IN PHYSICAL_ADDRESS BusAddress, + IN ULONG Length, + IN OUT PULONG AddressSpace, OUT PPHYSICAL_ADDRESS TranslatedAddress); +typedef TRANSLATE_BUS_ADDRESS *PTRANSLATE_BUS_ADDRESS; typedef struct _DMA_ADAPTER* -(DDKAPI *PGET_DMA_ADAPTER)( - IN PVOID Context, - IN struct _DEVICE_DESCRIPTION *DeviceDescriptor, - OUT PULONG NumberOfMapRegisters); +(NTAPI GET_DMA_ADAPTER)( + IN PVOID Context, + IN struct _DEVICE_DESCRIPTION *DeviceDescriptor, + OUT PULONG NumberOfMapRegisters); +typedef GET_DMA_ADAPTER *PGET_DMA_ADAPTER; typedef ULONG -(DDKAPI *PGET_SET_DEVICE_DATA)( - IN PVOID Context, - IN ULONG DataType, - IN PVOID Buffer, - IN ULONG Offset, - IN ULONG Length); +(NTAPI GET_SET_DEVICE_DATA)( + IN PVOID Context, + IN ULONG DataType, + IN PVOID Buffer, + IN ULONG Offset, + IN ULONG Length); +typedef GET_SET_DEVICE_DATA *PGET_SET_DEVICE_DATA; + +typedef enum _DEVICE_INSTALL_STATE { + InstallStateInstalled, + InstallStateNeedsReinstall, + InstallStateFailedInstall, + InstallStateFinishInstall +} DEVICE_INSTALL_STATE, *PDEVICE_INSTALL_STATE; + +typedef struct _LEGACY_BUS_INFORMATION { + GUID BusTypeGuid; + INTERFACE_TYPE LegacyBusType; + ULONG BusNumber; +} LEGACY_BUS_INFORMATION, *PLEGACY_BUS_INFORMATION; + +typedef enum _DEVICE_REMOVAL_POLICY { + RemovalPolicyExpectNoRemoval = 1, + RemovalPolicyExpectOrderlyRemoval = 2, + RemovalPolicyExpectSurpriseRemoval = 3 +} DEVICE_REMOVAL_POLICY, *PDEVICE_REMOVAL_POLICY; + +typedef VOID +(NTAPI*PREENUMERATE_SELF)( + IN PVOID Context); + +typedef struct _REENUMERATE_SELF_INTERFACE_STANDARD { + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; + PREENUMERATE_SELF SurpriseRemoveAndReenumerateSelf; +} REENUMERATE_SELF_INTERFACE_STANDARD, *PREENUMERATE_SELF_INTERFACE_STANDARD; + +typedef VOID +(NTAPI *PIO_DEVICE_EJECT_CALLBACK)( + IN NTSTATUS Status, + IN OUT PVOID Context OPTIONAL); + +#define PCI_DEVICE_PRESENT_INTERFACE_VERSION 1 /* PCI_DEVICE_PRESENCE_PARAMETERS.Flags */ #define PCI_USE_SUBSYSTEM_IDS 0x00000001 @@ -3359,283 +4581,116 @@ typedef ULONG #define PCI_USE_LOCAL_DEVICE 0x00000040 typedef struct _PCI_DEVICE_PRESENCE_PARAMETERS { - ULONG Size; - ULONG Flags; - USHORT VendorID; - USHORT DeviceID; - UCHAR RevisionID; - USHORT SubVendorID; - USHORT SubSystemID; - UCHAR BaseClass; - UCHAR SubClass; - UCHAR ProgIf; + ULONG Size; + ULONG Flags; + USHORT VendorID; + USHORT DeviceID; + UCHAR RevisionID; + USHORT SubVendorID; + USHORT SubSystemID; + UCHAR BaseClass; + UCHAR SubClass; + UCHAR ProgIf; } PCI_DEVICE_PRESENCE_PARAMETERS, *PPCI_DEVICE_PRESENCE_PARAMETERS; typedef BOOLEAN -(DDKAPI *PPCI_IS_DEVICE_PRESENT)( - IN USHORT VendorID, - IN USHORT DeviceID, - IN UCHAR RevisionID, - IN USHORT SubVendorID, - IN USHORT SubSystemID, - IN ULONG Flags); +(NTAPI PCI_IS_DEVICE_PRESENT)( + IN USHORT VendorID, + IN USHORT DeviceID, + IN UCHAR RevisionID, + IN USHORT SubVendorID, + IN USHORT SubSystemID, + IN ULONG Flags); +typedef PCI_IS_DEVICE_PRESENT *PPCI_IS_DEVICE_PRESENT; typedef BOOLEAN -(DDKAPI *PPCI_IS_DEVICE_PRESENT_EX)( +(NTAPI PCI_IS_DEVICE_PRESENT_EX)( IN PVOID Context, IN PPCI_DEVICE_PRESENCE_PARAMETERS Parameters); +typedef PCI_IS_DEVICE_PRESENT_EX *PPCI_IS_DEVICE_PRESENT_EX; typedef struct _BUS_INTERFACE_STANDARD { - USHORT Size; - USHORT Version; - PVOID Context; - PINTERFACE_REFERENCE InterfaceReference; - PINTERFACE_DEREFERENCE InterfaceDereference; - PTRANSLATE_BUS_ADDRESS TranslateBusAddress; - PGET_DMA_ADAPTER GetDmaAdapter; - PGET_SET_DEVICE_DATA SetBusData; - PGET_SET_DEVICE_DATA GetBusData; + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; + PTRANSLATE_BUS_ADDRESS TranslateBusAddress; + PGET_DMA_ADAPTER GetDmaAdapter; + PGET_SET_DEVICE_DATA SetBusData; + PGET_SET_DEVICE_DATA GetBusData; } BUS_INTERFACE_STANDARD, *PBUS_INTERFACE_STANDARD; typedef struct _PCI_DEVICE_PRESENT_INTERFACE { - USHORT Size; - USHORT Version; - PVOID Context; - PINTERFACE_REFERENCE InterfaceReference; - PINTERFACE_DEREFERENCE InterfaceDereference; - PPCI_IS_DEVICE_PRESENT IsDevicePresent; - PPCI_IS_DEVICE_PRESENT_EX IsDevicePresentEx; + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; + PPCI_IS_DEVICE_PRESENT IsDevicePresent; + PPCI_IS_DEVICE_PRESENT_EX IsDevicePresentEx; } PCI_DEVICE_PRESENT_INTERFACE, *PPCI_DEVICE_PRESENT_INTERFACE; -typedef -BOOLEAN -(*PGPE_SERVICE_ROUTINE2)( - PVOID ObjectContext, - PVOID ServiceContext -); - -typedef -NTSTATUS -(*PGPE_CONNECT_VECTOR2)( - PVOID Context, - ULONG GpeNumber, - KINTERRUPT_MODE Mode, - BOOLEAN Shareable, - PGPE_SERVICE_ROUTINE2 ServiceRoutine, - PVOID ServiceContext, - PVOID *ObjectContext -); - -typedef -NTSTATUS -(*PGPE_DISCONNECT_VECTOR2)( - PVOID Context, - PVOID ObjectContext -); - -typedef -NTSTATUS -(*PGPE_ENABLE_EVENT2)( - PVOID Context, - PVOID ObjectContext -); - -typedef -NTSTATUS -(*PGPE_DISABLE_EVENT2)( - PVOID Context, - PVOID ObjectContext -); - -typedef -NTSTATUS -(*PGPE_CLEAR_STATUS2)( - PVOID Context, - PVOID ObjectContext -); - -typedef -VOID -(*PDEVICE_NOTIFY_CALLBACK2)( - PVOID NotificationContext, - ULONG NotifyCode -); - -typedef -NTSTATUS -(*PREGISTER_FOR_DEVICE_NOTIFICATIONS2)( - PVOID Context, - PDEVICE_NOTIFY_CALLBACK2 NotificationHandler, - PVOID NotificationContext -); - -typedef -VOID -(*PUNREGISTER_FOR_DEVICE_NOTIFICATIONS2)( - PVOID Context -); - -typedef struct -{ - USHORT Size; - USHORT Version; - PVOID Context; - PINTERFACE_REFERENCE InterfaceReference; - PINTERFACE_DEREFERENCE InterfaceDereference; - PGPE_CONNECT_VECTOR2 GpeConnectVector; - PGPE_DISCONNECT_VECTOR2 GpeDisconnectVector; - PGPE_ENABLE_EVENT2 GpeEnableEvent; - PGPE_DISABLE_EVENT2 GpeDisableEvent; - PGPE_CLEAR_STATUS2 GpeClearStatus; - PREGISTER_FOR_DEVICE_NOTIFICATIONS2 RegisterForDeviceNotifications; - PUNREGISTER_FOR_DEVICE_NOTIFICATIONS2 UnregisterForDeviceNotifications; -} ACPI_INTERFACE_STANDARD2, *PACPI_INTERFACE_STANDARD2; - -typedef -BOOLEAN -(*PGPE_SERVICE_ROUTINE)( - PDEVICE_OBJECT ObjectContext, - PVOID ServiceContext -); - -typedef -NTSTATUS -(*PGPE_CONNECT_VECTOR)( - PDEVICE_OBJECT Context, - ULONG GpeNumber, - KINTERRUPT_MODE Mode, - BOOLEAN Shareable, - PGPE_SERVICE_ROUTINE ServiceRoutine, - PVOID ServiceContext, - PVOID *ObjectContext -); - -typedef -NTSTATUS -(*PGPE_DISCONNECT_VECTOR)( - PDEVICE_OBJECT Context, - PVOID ObjectContext -); - -typedef -NTSTATUS -(*PGPE_ENABLE_EVENT)( - PDEVICE_OBJECT Context, - PVOID ObjectContext -); - -typedef -NTSTATUS -(*PGPE_DISABLE_EVENT)( - PDEVICE_OBJECT Context, - PVOID ObjectContext -); - -typedef -NTSTATUS -(*PGPE_CLEAR_STATUS)( - PDEVICE_OBJECT Context, - PVOID ObjectContext -); - -typedef -VOID -(*PDEVICE_NOTIFY_CALLBACK)( - PVOID NotificationContext, - ULONG NotifyCode -); - -typedef -NTSTATUS -(*PREGISTER_FOR_DEVICE_NOTIFICATIONS)( - PDEVICE_OBJECT Context, - PDEVICE_NOTIFY_CALLBACK NotificationHandler, - PVOID NotificationContext -); - -typedef -VOID -(*PUNREGISTER_FOR_DEVICE_NOTIFICATIONS)( - PDEVICE_OBJECT Context, - PDEVICE_NOTIFY_CALLBACK NotificationHandler -); - -typedef struct -{ - USHORT Size; - USHORT Version; - PVOID Context; - PINTERFACE_REFERENCE InterfaceReference; - PINTERFACE_DEREFERENCE InterfaceDereference; - PGPE_CONNECT_VECTOR GpeConnectVector; - PGPE_DISCONNECT_VECTOR GpeDisconnectVector; - PGPE_ENABLE_EVENT GpeEnableEvent; - PGPE_DISABLE_EVENT GpeDisableEvent; - PGPE_CLEAR_STATUS GpeClearStatus; - PREGISTER_FOR_DEVICE_NOTIFICATIONS RegisterForDeviceNotifications; - PUNREGISTER_FOR_DEVICE_NOTIFICATIONS UnregisterForDeviceNotifications; -} ACPI_INTERFACE_STANDARD, *PACPI_INTERFACE_STANDARD; - typedef struct _DEVICE_CAPABILITIES { - USHORT Size; - USHORT Version; - ULONG DeviceD1 : 1; - ULONG DeviceD2 : 1; - ULONG LockSupported : 1; - ULONG EjectSupported : 1; - ULONG Removable : 1; - ULONG DockDevice : 1; - ULONG UniqueID : 1; - ULONG SilentInstall : 1; - ULONG RawDeviceOK : 1; - ULONG SurpriseRemovalOK : 1; - ULONG WakeFromD0 : 1; - ULONG WakeFromD1 : 1; - ULONG WakeFromD2 : 1; - ULONG WakeFromD3 : 1; - ULONG HardwareDisabled : 1; - ULONG NonDynamic : 1; - ULONG WarmEjectSupported : 1; - ULONG NoDisplayInUI : 1; - ULONG Reserved : 14; - ULONG Address; - ULONG UINumber; - DEVICE_POWER_STATE DeviceState[PowerSystemMaximum]; - SYSTEM_POWER_STATE SystemWake; - DEVICE_POWER_STATE DeviceWake; - ULONG D1Latency; - ULONG D2Latency; - ULONG D3Latency; + USHORT Size; + USHORT Version; + ULONG DeviceD1:1; + ULONG DeviceD2:1; + ULONG LockSupported:1; + ULONG EjectSupported:1; + ULONG Removable:1; + ULONG DockDevice:1; + ULONG UniqueID:1; + ULONG SilentInstall:1; + ULONG RawDeviceOK:1; + ULONG SurpriseRemovalOK:1; + ULONG WakeFromD0:1; + ULONG WakeFromD1:1; + ULONG WakeFromD2:1; + ULONG WakeFromD3:1; + ULONG HardwareDisabled:1; + ULONG NonDynamic:1; + ULONG WarmEjectSupported:1; + ULONG NoDisplayInUI:1; + ULONG Reserved:14; + ULONG Address; + ULONG UINumber; + DEVICE_POWER_STATE DeviceState[PowerSystemMaximum]; + SYSTEM_POWER_STATE SystemWake; + DEVICE_POWER_STATE DeviceWake; + ULONG D1Latency; + ULONG D2Latency; + ULONG D3Latency; } DEVICE_CAPABILITIES, *PDEVICE_CAPABILITIES; typedef struct _DEVICE_INTERFACE_CHANGE_NOTIFICATION { - USHORT Version; - USHORT Size; - GUID Event; - GUID InterfaceClassGuid; - PUNICODE_STRING SymbolicLinkName; + USHORT Version; + USHORT Size; + GUID Event; + GUID InterfaceClassGuid; + PUNICODE_STRING SymbolicLinkName; } DEVICE_INTERFACE_CHANGE_NOTIFICATION, *PDEVICE_INTERFACE_CHANGE_NOTIFICATION; typedef struct _HWPROFILE_CHANGE_NOTIFICATION { - USHORT Version; - USHORT Size; - GUID Event; + USHORT Version; + USHORT Size; + GUID Event; } HWPROFILE_CHANGE_NOTIFICATION, *PHWPROFILE_CHANGE_NOTIFICATION; #undef INTERFACE typedef struct _INTERFACE { - USHORT Size; - USHORT Version; - PVOID Context; - PINTERFACE_REFERENCE InterfaceReference; - PINTERFACE_DEREFERENCE InterfaceDereference; + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; } INTERFACE, *PINTERFACE; typedef struct _PLUGPLAY_NOTIFICATION_HEADER { - USHORT Version; - USHORT Size; - GUID Event; + USHORT Version; + USHORT Size; + GUID Event; } PLUGPLAY_NOTIFICATION_HEADER, *PPLUGPLAY_NOTIFICATION_HEADER; typedef ULONG PNP_DEVICE_STATE, *PPNP_DEVICE_STATE; @@ -3650,21 +4705,154 @@ typedef ULONG PNP_DEVICE_STATE, *PPNP_DEVICE_STATE; #define PNP_DEVICE_NOT_DISABLEABLE 0x00000020 typedef struct _TARGET_DEVICE_CUSTOM_NOTIFICATION { - USHORT Version; - USHORT Size; - GUID Event; - struct _FILE_OBJECT *FileObject; - LONG NameBufferOffset; - UCHAR CustomDataBuffer[1]; + USHORT Version; + USHORT Size; + GUID Event; + struct _FILE_OBJECT *FileObject; + LONG NameBufferOffset; + UCHAR CustomDataBuffer[1]; } TARGET_DEVICE_CUSTOM_NOTIFICATION, *PTARGET_DEVICE_CUSTOM_NOTIFICATION; typedef struct _TARGET_DEVICE_REMOVAL_NOTIFICATION { - USHORT Version; - USHORT Size; - GUID Event; - struct _FILE_OBJECT *FileObject; + USHORT Version; + USHORT Size; + GUID Event; + struct _FILE_OBJECT *FileObject; } TARGET_DEVICE_REMOVAL_NOTIFICATION, *PTARGET_DEVICE_REMOVAL_NOTIFICATION; +#if (NTDDI_VERSION >= NTDDI_VISTA) +#include +#define PLUGPLAY_PROPERTY_PERSISTENT 0x00000001 +#endif + +#define PNP_REPLACE_NO_MAP MAXLONGLONG + +typedef NTSTATUS +(NTAPI *PREPLACE_MAP_MEMORY)( + IN PHYSICAL_ADDRESS TargetPhysicalAddress, + IN PHYSICAL_ADDRESS SparePhysicalAddress, + IN OUT PLARGE_INTEGER NumberOfBytes, + OUT PVOID *TargetAddress, + OUT PVOID *SpareAddress); + +typedef struct _PNP_REPLACE_MEMORY_LIST { + ULONG AllocatedCount; + ULONG Count; + ULONGLONG TotalLength; + struct { + PHYSICAL_ADDRESS Address; + ULONGLONG Length; + } Ranges[ANYSIZE_ARRAY]; +} PNP_REPLACE_MEMORY_LIST, *PPNP_REPLACE_MEMORY_LIST; + +typedef struct _PNP_REPLACE_PROCESSOR_LIST { + PKAFFINITY Affinity; + ULONG GroupCount; + ULONG AllocatedCount; + ULONG Count; + ULONG ApicIds[ANYSIZE_ARRAY]; +} PNP_REPLACE_PROCESSOR_LIST, *PPNP_REPLACE_PROCESSOR_LIST; + +typedef struct _PNP_REPLACE_PROCESSOR_LIST_V1 { + KAFFINITY AffinityMask; + ULONG AllocatedCount; + ULONG Count; + ULONG ApicIds[ANYSIZE_ARRAY]; +} PNP_REPLACE_PROCESSOR_LIST_V1, *PPNP_REPLACE_PROCESSOR_LIST_V1; + +#define PNP_REPLACE_PARAMETERS_VERSION 2 + +typedef struct _PNP_REPLACE_PARAMETERS { + ULONG Size; + ULONG Version; + ULONG64 Target; + ULONG64 Spare; + PPNP_REPLACE_PROCESSOR_LIST TargetProcessors; + PPNP_REPLACE_PROCESSOR_LIST SpareProcessors; + PPNP_REPLACE_MEMORY_LIST TargetMemory; + PPNP_REPLACE_MEMORY_LIST SpareMemory; + PREPLACE_MAP_MEMORY MapMemory; +} PNP_REPLACE_PARAMETERS, *PPNP_REPLACE_PARAMETERS; + +typedef VOID +(NTAPI *PREPLACE_UNLOAD)( + VOID); + +typedef NTSTATUS +(NTAPI *PREPLACE_BEGIN)( + IN PPNP_REPLACE_PARAMETERS Parameters, + OUT PVOID *Context); + +typedef NTSTATUS +(NTAPI *PREPLACE_END)( + IN PVOID Context); + +typedef NTSTATUS +(NTAPI *PREPLACE_MIRROR_PHYSICAL_MEMORY)( + IN PVOID Context, + IN PHYSICAL_ADDRESS PhysicalAddress, + IN LARGE_INTEGER ByteCount); + +typedef NTSTATUS +(NTAPI *PREPLACE_SET_PROCESSOR_ID)( + IN PVOID Context, + IN ULONG ApicId, + IN BOOLEAN Target); + +typedef NTSTATUS +(NTAPI *PREPLACE_SWAP)( + IN PVOID Context); + +typedef NTSTATUS +(NTAPI *PREPLACE_INITIATE_HARDWARE_MIRROR)( + IN PVOID Context); + +typedef NTSTATUS +(NTAPI *PREPLACE_MIRROR_PLATFORM_MEMORY)( + IN PVOID Context); + +typedef NTSTATUS +(NTAPI *PREPLACE_GET_MEMORY_DESTINATION)( + IN PVOID Context, + IN PHYSICAL_ADDRESS SourceAddress, + OUT PPHYSICAL_ADDRESS DestinationAddress); + +typedef NTSTATUS +(NTAPI *PREPLACE_ENABLE_DISABLE_HARDWARE_QUIESCE)( + IN PVOID Context, + IN BOOLEAN Enable); + +#define PNP_REPLACE_DRIVER_INTERFACE_VERSION 1 +#define PNP_REPLACE_DRIVER_INTERFACE_MINIMUM_SIZE \ + FIELD_OFFSET(PNP_REPLACE_DRIVER_INTERFACE, InitiateHardwareMirror) + +#define PNP_REPLACE_MEMORY_SUPPORTED 0x0001 +#define PNP_REPLACE_PROCESSOR_SUPPORTED 0x0002 +#define PNP_REPLACE_HARDWARE_MEMORY_MIRRORING 0x0004 +#define PNP_REPLACE_HARDWARE_PAGE_COPY 0x0008 +#define PNP_REPLACE_HARDWARE_QUIESCE 0x0010 + +typedef struct _PNP_REPLACE_DRIVER_INTERFACE { + ULONG Size; + ULONG Version; + ULONG Flags; + PREPLACE_UNLOAD Unload; + PREPLACE_BEGIN BeginReplace; + PREPLACE_END EndReplace; + PREPLACE_MIRROR_PHYSICAL_MEMORY MirrorPhysicalMemory; + PREPLACE_SET_PROCESSOR_ID SetProcessorId; + PREPLACE_SWAP Swap; + PREPLACE_INITIATE_HARDWARE_MIRROR InitiateHardwareMirror; + PREPLACE_MIRROR_PLATFORM_MEMORY MirrorPlatformMemory; + PREPLACE_GET_MEMORY_DESTINATION GetMemoryDestination; + PREPLACE_ENABLE_DISABLE_HARDWARE_QUIESCE EnableDisableHardwareQuiesce; +} PNP_REPLACE_DRIVER_INTERFACE, *PPNP_REPLACE_DRIVER_INTERFACE; + +typedef NTSTATUS +(NTAPI *PREPLACE_DRIVER_INIT)( + IN OUT PPNP_REPLACE_DRIVER_INTERFACE Interface, + IN PVOID Unused); + typedef enum _DEVICE_USAGE_NOTIFICATION_TYPE { DeviceUsageTypeUndefined, DeviceUsageTypePaging, @@ -3673,9 +4861,9 @@ typedef enum _DEVICE_USAGE_NOTIFICATION_TYPE { } DEVICE_USAGE_NOTIFICATION_TYPE; typedef struct _POWER_SEQUENCE { - ULONG SequenceD1; - ULONG SequenceD2; - ULONG SequenceD3; + ULONG SequenceD1; + ULONG SequenceD2; + ULONG SequenceD3; } POWER_SEQUENCE, *PPOWER_SEQUENCE; typedef enum { @@ -3711,16 +4899,27 @@ typedef enum _IO_NOTIFICATION_EVENT_CATEGORY { EventCategoryTargetDeviceChange } IO_NOTIFICATION_EVENT_CATEGORY; +typedef enum _IO_PRIORITY_HINT { + IoPriorityVeryLow = 0, + IoPriorityLow, + IoPriorityNormal, + IoPriorityHigh, + IoPriorityCritical, + MaxIoPriorityTypes +} IO_PRIORITY_HINT; + #define PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES 0x00000001 typedef NTSTATUS -(DDKAPI *PDRIVER_NOTIFICATION_CALLBACK_ROUTINE)( +(NTAPI DRIVER_NOTIFICATION_CALLBACK_ROUTINE)( IN PVOID NotificationStructure, IN PVOID Context); +typedef DRIVER_NOTIFICATION_CALLBACK_ROUTINE *PDRIVER_NOTIFICATION_CALLBACK_ROUTINE; typedef VOID -(DDKAPI *PDEVICE_CHANGE_COMPLETE_CALLBACK)( +(NTAPI DEVICE_CHANGE_COMPLETE_CALLBACK)( IN PVOID Context); +typedef DEVICE_CHANGE_COMPLETE_CALLBACK *PDEVICE_CHANGE_COMPLETE_CALLBACK; typedef enum _FILE_INFORMATION_CLASS { FileDirectoryInformation = 1, @@ -3782,35 +4981,59 @@ typedef enum _FILE_INFORMATION_CLASS { } FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS; typedef struct _FILE_POSITION_INFORMATION { - LARGE_INTEGER CurrentByteOffset; + LARGE_INTEGER CurrentByteOffset; } FILE_POSITION_INFORMATION, *PFILE_POSITION_INFORMATION; -#include typedef struct _FILE_BASIC_INFORMATION { - LARGE_INTEGER CreationTime; - LARGE_INTEGER LastAccessTime; - LARGE_INTEGER LastWriteTime; - LARGE_INTEGER ChangeTime; - ULONG FileAttributes; + LARGE_INTEGER CreationTime; + LARGE_INTEGER LastAccessTime; + LARGE_INTEGER LastWriteTime; + LARGE_INTEGER ChangeTime; + ULONG FileAttributes; } FILE_BASIC_INFORMATION, *PFILE_BASIC_INFORMATION; -#include + +typedef struct _FILE_IO_PRIORITY_HINT_INFORMATION { + IO_PRIORITY_HINT PriorityHint; +} FILE_IO_PRIORITY_HINT_INFORMATION, *PFILE_IO_PRIORITY_HINT_INFORMATION; + +typedef struct _FILE_IO_COMPLETION_NOTIFICATION_INFORMATION { + ULONG Flags; +} FILE_IO_COMPLETION_NOTIFICATION_INFORMATION, *PFILE_IO_COMPLETION_NOTIFICATION_INFORMATION; + +typedef struct _FILE_IOSTATUSBLOCK_RANGE_INFORMATION { + PUCHAR IoStatusBlockRange; + ULONG Length; +} FILE_IOSTATUSBLOCK_RANGE_INFORMATION, *PFILE_IOSTATUSBLOCK_RANGE_INFORMATION; + +typedef struct _FILE_IS_REMOTE_DEVICE_INFORMATION { + BOOLEAN IsRemote; +} FILE_IS_REMOTE_DEVICE_INFORMATION, *PFILE_IS_REMOTE_DEVICE_INFORMATION; + +typedef struct _FILE_NUMA_NODE_INFORMATION { + USHORT NodeNumber; +} FILE_NUMA_NODE_INFORMATION, *PFILE_NUMA_NODE_INFORMATION; + +typedef struct _FILE_PROCESS_IDS_USING_FILE_INFORMATION { + ULONG NumberOfProcessIdsInList; + ULONG_PTR ProcessIdList[1]; +} FILE_PROCESS_IDS_USING_FILE_INFORMATION, *PFILE_PROCESS_IDS_USING_FILE_INFORMATION; typedef struct _FILE_STANDARD_INFORMATION { - LARGE_INTEGER AllocationSize; - LARGE_INTEGER EndOfFile; - ULONG NumberOfLinks; - BOOLEAN DeletePending; - BOOLEAN Directory; + LARGE_INTEGER AllocationSize; + LARGE_INTEGER EndOfFile; + ULONG NumberOfLinks; + BOOLEAN DeletePending; + BOOLEAN Directory; } FILE_STANDARD_INFORMATION, *PFILE_STANDARD_INFORMATION; typedef struct _FILE_NETWORK_OPEN_INFORMATION { - LARGE_INTEGER CreationTime; - LARGE_INTEGER LastAccessTime; - LARGE_INTEGER LastWriteTime; - LARGE_INTEGER ChangeTime; - LARGE_INTEGER AllocationSize; - LARGE_INTEGER EndOfFile; - ULONG FileAttributes; + LARGE_INTEGER CreationTime; + LARGE_INTEGER LastAccessTime; + LARGE_INTEGER LastWriteTime; + LARGE_INTEGER ChangeTime; + LARGE_INTEGER AllocationSize; + LARGE_INTEGER EndOfFile; + ULONG FileAttributes; } FILE_NETWORK_OPEN_INFORMATION, *PFILE_NETWORK_OPEN_INFORMATION; typedef enum _FSINFOCLASS { @@ -3828,321 +5051,329 @@ typedef enum _FSINFOCLASS { } FS_INFORMATION_CLASS, *PFS_INFORMATION_CLASS; typedef struct _FILE_FS_DEVICE_INFORMATION { - DEVICE_TYPE DeviceType; - ULONG Characteristics; + DEVICE_TYPE DeviceType; + ULONG Characteristics; } FILE_FS_DEVICE_INFORMATION, *PFILE_FS_DEVICE_INFORMATION; typedef struct _FILE_FULL_EA_INFORMATION { - ULONG NextEntryOffset; - UCHAR Flags; - UCHAR EaNameLength; - USHORT EaValueLength; - CHAR EaName[1]; + ULONG NextEntryOffset; + UCHAR Flags; + UCHAR EaNameLength; + USHORT EaValueLength; + CHAR EaName[1]; } FILE_FULL_EA_INFORMATION, *PFILE_FULL_EA_INFORMATION; +typedef struct _FILE_SFIO_RESERVE_INFORMATION { + ULONG RequestsPerPeriod; + ULONG Period; + BOOLEAN RetryFailures; + BOOLEAN Discardable; + ULONG RequestSize; + ULONG NumOutstandingRequests; +} FILE_SFIO_RESERVE_INFORMATION, *PFILE_SFIO_RESERVE_INFORMATION; + +typedef struct _FILE_SFIO_VOLUME_INFORMATION { + ULONG MaximumRequestsPerPeriod; + ULONG MinimumPeriod; + ULONG MinimumTransferSize; +} FILE_SFIO_VOLUME_INFORMATION, *PFILE_SFIO_VOLUME_INFORMATION; + +#define FILE_SKIP_COMPLETION_PORT_ON_SUCCESS 0x1 +#define FILE_SKIP_SET_EVENT_ON_HANDLE 0x2 +#define FILE_SKIP_SET_USER_EVENT_ON_FAST_IO 0x4 + #define FM_LOCK_BIT (0x1) #define FM_LOCK_BIT_V (0x0) #define FM_LOCK_WAITER_WOKEN (0x2) #define FM_LOCK_WAITER_INC (0x4) -typedef ULONG_PTR ERESOURCE_THREAD, *PERESOURCE_THREAD; - -typedef struct _OWNER_ENTRY { - ERESOURCE_THREAD OwnerThread; - _ANONYMOUS_UNION union { - LONG OwnerCount; - ULONG TableSize; - } DUMMYUNIONNAME; -} OWNER_ENTRY, *POWNER_ENTRY; - -typedef struct _ERESOURCE -{ - LIST_ENTRY SystemResourcesList; - POWNER_ENTRY OwnerTable; - SHORT ActiveCount; - USHORT Flag; - volatile PKSEMAPHORE SharedWaiters; - volatile PKEVENT ExclusiveWaiters; - OWNER_ENTRY OwnerEntry; - ULONG ActiveEntries; - ULONG ContentionCount; - ULONG NumberOfSharedWaiters; - ULONG NumberOfExclusiveWaiters; - __GNU_EXTENSION union - { - PVOID Address; - ULONG_PTR CreatorBackTraceIndex; - }; - KSPIN_LOCK SpinLock; -} ERESOURCE, *PERESOURCE; - -/* ERESOURCE.Flag */ -#define ResourceNeverExclusive 0x0010 -#define ResourceReleaseByOtherThread 0x0020 -#define ResourceOwnedExclusive 0x0080 - -#define RESOURCE_HASH_TABLE_SIZE 64 +typedef BOOLEAN +(NTAPI FAST_IO_CHECK_IF_POSSIBLE)( + IN struct _FILE_OBJECT *FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN BOOLEAN Wait, + IN ULONG LockKey, + IN BOOLEAN CheckForReadOperation, + OUT PIO_STATUS_BLOCK IoStatus, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_CHECK_IF_POSSIBLE *PFAST_IO_CHECK_IF_POSSIBLE; typedef BOOLEAN -(DDKAPI *PFAST_IO_CHECK_IF_POSSIBLE)( - IN struct _FILE_OBJECT *FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN BOOLEAN Wait, - IN ULONG LockKey, - IN BOOLEAN CheckForReadOperation, - OUT PIO_STATUS_BLOCK IoStatus, - IN struct _DEVICE_OBJECT *DeviceObject); +(NTAPI FAST_IO_READ)( + IN struct _FILE_OBJECT *FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN BOOLEAN Wait, + IN ULONG LockKey, + OUT PVOID Buffer, + OUT PIO_STATUS_BLOCK IoStatus, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_READ *PFAST_IO_READ; typedef BOOLEAN -(DDKAPI *PFAST_IO_READ)( - IN struct _FILE_OBJECT *FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN BOOLEAN Wait, - IN ULONG LockKey, - OUT PVOID Buffer, - OUT PIO_STATUS_BLOCK IoStatus, - IN struct _DEVICE_OBJECT *DeviceObject); +(NTAPI FAST_IO_WRITE)( + IN struct _FILE_OBJECT *FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN BOOLEAN Wait, + IN ULONG LockKey, + IN PVOID Buffer, + OUT PIO_STATUS_BLOCK IoStatus, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_WRITE *PFAST_IO_WRITE; typedef BOOLEAN -(DDKAPI *PFAST_IO_WRITE)( - IN struct _FILE_OBJECT *FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN BOOLEAN Wait, - IN ULONG LockKey, - IN PVOID Buffer, - OUT PIO_STATUS_BLOCK IoStatus, - IN struct _DEVICE_OBJECT *DeviceObject); +(NTAPI FAST_IO_QUERY_BASIC_INFO)( + IN struct _FILE_OBJECT *FileObject, + IN BOOLEAN Wait, + OUT PFILE_BASIC_INFORMATION Buffer, + OUT PIO_STATUS_BLOCK IoStatus, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_QUERY_BASIC_INFO *PFAST_IO_QUERY_BASIC_INFO; typedef BOOLEAN -(DDKAPI *PFAST_IO_QUERY_BASIC_INFO)( - IN struct _FILE_OBJECT *FileObject, - IN BOOLEAN Wait, - OUT PFILE_BASIC_INFORMATION Buffer, - OUT PIO_STATUS_BLOCK IoStatus, - IN struct _DEVICE_OBJECT *DeviceObject); +(NTAPI FAST_IO_QUERY_STANDARD_INFO)( + IN struct _FILE_OBJECT *FileObject, + IN BOOLEAN Wait, + OUT PFILE_STANDARD_INFORMATION Buffer, + OUT PIO_STATUS_BLOCK IoStatus, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_QUERY_STANDARD_INFO *PFAST_IO_QUERY_STANDARD_INFO; typedef BOOLEAN -(DDKAPI *PFAST_IO_QUERY_STANDARD_INFO)( - IN struct _FILE_OBJECT *FileObject, - IN BOOLEAN Wait, - OUT PFILE_STANDARD_INFORMATION Buffer, - OUT PIO_STATUS_BLOCK IoStatus, - IN struct _DEVICE_OBJECT *DeviceObject); +(NTAPI FAST_IO_LOCK)( + IN struct _FILE_OBJECT *FileObject, + IN PLARGE_INTEGER FileOffset, + IN PLARGE_INTEGER Length, + PEPROCESS ProcessId, + ULONG Key, + BOOLEAN FailImmediately, + BOOLEAN ExclusiveLock, + OUT PIO_STATUS_BLOCK IoStatus, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_LOCK *PFAST_IO_LOCK; typedef BOOLEAN -(DDKAPI *PFAST_IO_LOCK)( - IN struct _FILE_OBJECT *FileObject, - IN PLARGE_INTEGER FileOffset, - IN PLARGE_INTEGER Length, - PEPROCESS ProcessId, - ULONG Key, - BOOLEAN FailImmediately, - BOOLEAN ExclusiveLock, - OUT PIO_STATUS_BLOCK IoStatus, - IN struct _DEVICE_OBJECT *DeviceObject); +(NTAPI FAST_IO_UNLOCK_SINGLE)( + IN struct _FILE_OBJECT *FileObject, + IN PLARGE_INTEGER FileOffset, + IN PLARGE_INTEGER Length, + PEPROCESS ProcessId, + ULONG Key, + OUT PIO_STATUS_BLOCK IoStatus, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_UNLOCK_SINGLE *PFAST_IO_UNLOCK_SINGLE; typedef BOOLEAN -(DDKAPI *PFAST_IO_UNLOCK_SINGLE)( - IN struct _FILE_OBJECT *FileObject, - IN PLARGE_INTEGER FileOffset, - IN PLARGE_INTEGER Length, - PEPROCESS ProcessId, - ULONG Key, - OUT PIO_STATUS_BLOCK IoStatus, - IN struct _DEVICE_OBJECT *DeviceObject); +(NTAPI FAST_IO_UNLOCK_ALL)( + IN struct _FILE_OBJECT *FileObject, + PEPROCESS ProcessId, + OUT PIO_STATUS_BLOCK IoStatus, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_UNLOCK_ALL *PFAST_IO_UNLOCK_ALL; typedef BOOLEAN -(DDKAPI *PFAST_IO_UNLOCK_ALL)( - IN struct _FILE_OBJECT *FileObject, - PEPROCESS ProcessId, - OUT PIO_STATUS_BLOCK IoStatus, - IN struct _DEVICE_OBJECT *DeviceObject); +(NTAPI FAST_IO_UNLOCK_ALL_BY_KEY)( + IN struct _FILE_OBJECT *FileObject, + PVOID ProcessId, + ULONG Key, + OUT PIO_STATUS_BLOCK IoStatus, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_UNLOCK_ALL_BY_KEY *PFAST_IO_UNLOCK_ALL_BY_KEY; typedef BOOLEAN -(DDKAPI *PFAST_IO_UNLOCK_ALL_BY_KEY)( - IN struct _FILE_OBJECT *FileObject, - PVOID ProcessId, - ULONG Key, - OUT PIO_STATUS_BLOCK IoStatus, - IN struct _DEVICE_OBJECT *DeviceObject); - -typedef BOOLEAN -(DDKAPI *PFAST_IO_DEVICE_CONTROL)( - IN struct _FILE_OBJECT *FileObject, - IN BOOLEAN Wait, - IN PVOID InputBuffer OPTIONAL, - IN ULONG InputBufferLength, - OUT PVOID OutputBuffer OPTIONAL, - IN ULONG OutputBufferLength, - IN ULONG IoControlCode, - OUT PIO_STATUS_BLOCK IoStatus, - IN struct _DEVICE_OBJECT *DeviceObject); +(NTAPI FAST_IO_DEVICE_CONTROL)( + IN struct _FILE_OBJECT *FileObject, + IN BOOLEAN Wait, + IN PVOID InputBuffer OPTIONAL, + IN ULONG InputBufferLength, + OUT PVOID OutputBuffer OPTIONAL, + IN ULONG OutputBufferLength, + IN ULONG IoControlCode, + OUT PIO_STATUS_BLOCK IoStatus, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_DEVICE_CONTROL *PFAST_IO_DEVICE_CONTROL; typedef VOID -(DDKAPI *PFAST_IO_ACQUIRE_FILE)( - IN struct _FILE_OBJECT *FileObject); +(NTAPI FAST_IO_ACQUIRE_FILE)( + IN struct _FILE_OBJECT *FileObject); +typedef FAST_IO_ACQUIRE_FILE *PFAST_IO_ACQUIRE_FILE; typedef VOID -(DDKAPI *PFAST_IO_RELEASE_FILE)( - IN struct _FILE_OBJECT *FileObject); +(NTAPI FAST_IO_RELEASE_FILE)( + IN struct _FILE_OBJECT *FileObject); +typedef FAST_IO_RELEASE_FILE *PFAST_IO_RELEASE_FILE; typedef VOID -(DDKAPI *PFAST_IO_DETACH_DEVICE)( - IN struct _DEVICE_OBJECT *SourceDevice, - IN struct _DEVICE_OBJECT *TargetDevice); +(NTAPI FAST_IO_DETACH_DEVICE)( + IN struct _DEVICE_OBJECT *SourceDevice, + IN struct _DEVICE_OBJECT *TargetDevice); +typedef FAST_IO_DETACH_DEVICE *PFAST_IO_DETACH_DEVICE; typedef BOOLEAN -(DDKAPI *PFAST_IO_QUERY_NETWORK_OPEN_INFO)( - IN struct _FILE_OBJECT *FileObject, - IN BOOLEAN Wait, - OUT struct _FILE_NETWORK_OPEN_INFORMATION *Buffer, - OUT struct _IO_STATUS_BLOCK *IoStatus, - IN struct _DEVICE_OBJECT *DeviceObject); +(NTAPI FAST_IO_QUERY_NETWORK_OPEN_INFO)( + IN struct _FILE_OBJECT *FileObject, + IN BOOLEAN Wait, + OUT struct _FILE_NETWORK_OPEN_INFORMATION *Buffer, + OUT struct _IO_STATUS_BLOCK *IoStatus, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_QUERY_NETWORK_OPEN_INFO *PFAST_IO_QUERY_NETWORK_OPEN_INFO; typedef NTSTATUS -(DDKAPI *PFAST_IO_ACQUIRE_FOR_MOD_WRITE)( - IN struct _FILE_OBJECT *FileObject, - IN PLARGE_INTEGER EndingOffset, - OUT struct _ERESOURCE **ResourceToRelease, - IN struct _DEVICE_OBJECT *DeviceObject); +(NTAPI FAST_IO_ACQUIRE_FOR_MOD_WRITE)( + IN struct _FILE_OBJECT *FileObject, + IN PLARGE_INTEGER EndingOffset, + OUT struct _ERESOURCE **ResourceToRelease, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_ACQUIRE_FOR_MOD_WRITE *PFAST_IO_ACQUIRE_FOR_MOD_WRITE; typedef BOOLEAN -(DDKAPI *PFAST_IO_MDL_READ)( - IN struct _FILE_OBJECT *FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN ULONG LockKey, - OUT PMDL *MdlChain, - OUT PIO_STATUS_BLOCK IoStatus, - IN struct _DEVICE_OBJECT *DeviceObject); +(NTAPI FAST_IO_MDL_READ)( + IN struct _FILE_OBJECT *FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN ULONG LockKey, + OUT PMDL *MdlChain, + OUT PIO_STATUS_BLOCK IoStatus, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_MDL_READ *PFAST_IO_MDL_READ; typedef BOOLEAN -(DDKAPI *PFAST_IO_MDL_READ_COMPLETE)( +(NTAPI FAST_IO_MDL_READ_COMPLETE)( IN struct _FILE_OBJECT *FileObject, IN PMDL MdlChain, IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_MDL_READ_COMPLETE *PFAST_IO_MDL_READ_COMPLETE; typedef BOOLEAN -(DDKAPI *PFAST_IO_PREPARE_MDL_WRITE)( - IN struct _FILE_OBJECT *FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN ULONG LockKey, - OUT PMDL *MdlChain, - OUT PIO_STATUS_BLOCK IoStatus, - IN struct _DEVICE_OBJECT *DeviceObject); +(NTAPI FAST_IO_PREPARE_MDL_WRITE)( + IN struct _FILE_OBJECT *FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN ULONG LockKey, + OUT PMDL *MdlChain, + OUT PIO_STATUS_BLOCK IoStatus, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_PREPARE_MDL_WRITE *PFAST_IO_PREPARE_MDL_WRITE; typedef BOOLEAN -(DDKAPI *PFAST_IO_MDL_WRITE_COMPLETE)( - IN struct _FILE_OBJECT *FileObject, - IN PLARGE_INTEGER FileOffset, - IN PMDL MdlChain, - IN struct _DEVICE_OBJECT *DeviceObject); +(NTAPI FAST_IO_MDL_WRITE_COMPLETE)( + IN struct _FILE_OBJECT *FileObject, + IN PLARGE_INTEGER FileOffset, + IN PMDL MdlChain, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_MDL_WRITE_COMPLETE *PFAST_IO_MDL_WRITE_COMPLETE; typedef BOOLEAN -(DDKAPI *PFAST_IO_READ_COMPRESSED)( - IN struct _FILE_OBJECT *FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN ULONG LockKey, - OUT PVOID Buffer, - OUT PMDL *MdlChain, - OUT PIO_STATUS_BLOCK IoStatus, - OUT struct _COMPRESSED_DATA_INFO *CompressedDataInfo, - IN ULONG CompressedDataInfoLength, - IN struct _DEVICE_OBJECT *DeviceObject); +(NTAPI FAST_IO_READ_COMPRESSED)( + IN struct _FILE_OBJECT *FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN ULONG LockKey, + OUT PVOID Buffer, + OUT PMDL *MdlChain, + OUT PIO_STATUS_BLOCK IoStatus, + OUT struct _COMPRESSED_DATA_INFO *CompressedDataInfo, + IN ULONG CompressedDataInfoLength, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_READ_COMPRESSED *PFAST_IO_READ_COMPRESSED; typedef BOOLEAN -(DDKAPI *PFAST_IO_WRITE_COMPRESSED)( - IN struct _FILE_OBJECT *FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN ULONG LockKey, - IN PVOID Buffer, - OUT PMDL *MdlChain, - OUT PIO_STATUS_BLOCK IoStatus, - IN struct _COMPRESSED_DATA_INFO *CompressedDataInfo, - IN ULONG CompressedDataInfoLength, - IN struct _DEVICE_OBJECT *DeviceObject); +(NTAPI FAST_IO_WRITE_COMPRESSED)( + IN struct _FILE_OBJECT *FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN ULONG LockKey, + IN PVOID Buffer, + OUT PMDL *MdlChain, + OUT PIO_STATUS_BLOCK IoStatus, + IN struct _COMPRESSED_DATA_INFO *CompressedDataInfo, + IN ULONG CompressedDataInfoLength, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_WRITE_COMPRESSED *PFAST_IO_WRITE_COMPRESSED; typedef BOOLEAN -(DDKAPI *PFAST_IO_MDL_READ_COMPLETE_COMPRESSED)( - IN struct _FILE_OBJECT *FileObject, - IN PMDL MdlChain, - IN struct _DEVICE_OBJECT *DeviceObject); +(NTAPI FAST_IO_MDL_READ_COMPLETE_COMPRESSED)( + IN struct _FILE_OBJECT *FileObject, + IN PMDL MdlChain, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_MDL_READ_COMPLETE_COMPRESSED *PFAST_IO_MDL_READ_COMPLETE_COMPRESSED; typedef BOOLEAN -(DDKAPI *PFAST_IO_MDL_WRITE_COMPLETE_COMPRESSED)( - IN struct _FILE_OBJECT *FileObject, - IN PLARGE_INTEGER FileOffset, - IN PMDL MdlChain, - IN struct _DEVICE_OBJECT *DeviceObject); +(NTAPI FAST_IO_MDL_WRITE_COMPLETE_COMPRESSED)( + IN struct _FILE_OBJECT *FileObject, + IN PLARGE_INTEGER FileOffset, + IN PMDL MdlChain, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_MDL_WRITE_COMPLETE_COMPRESSED *PFAST_IO_MDL_WRITE_COMPLETE_COMPRESSED; typedef BOOLEAN -(DDKAPI *PFAST_IO_QUERY_OPEN)( - IN struct _IRP *Irp, - OUT PFILE_NETWORK_OPEN_INFORMATION NetworkInformation, - IN struct _DEVICE_OBJECT *DeviceObject); +(NTAPI FAST_IO_QUERY_OPEN)( + IN struct _IRP *Irp, + OUT PFILE_NETWORK_OPEN_INFORMATION NetworkInformation, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_QUERY_OPEN *PFAST_IO_QUERY_OPEN; typedef NTSTATUS -(DDKAPI *PFAST_IO_RELEASE_FOR_MOD_WRITE)( - IN struct _FILE_OBJECT *FileObject, - IN struct _ERESOURCE *ResourceToRelease, - IN struct _DEVICE_OBJECT *DeviceObject); +(NTAPI FAST_IO_RELEASE_FOR_MOD_WRITE)( + IN struct _FILE_OBJECT *FileObject, + IN struct _ERESOURCE *ResourceToRelease, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_RELEASE_FOR_MOD_WRITE *PFAST_IO_RELEASE_FOR_MOD_WRITE; typedef NTSTATUS -(DDKAPI *PFAST_IO_ACQUIRE_FOR_CCFLUSH)( - IN struct _FILE_OBJECT *FileObject, - IN struct _DEVICE_OBJECT *DeviceObject); +(NTAPI FAST_IO_ACQUIRE_FOR_CCFLUSH)( + IN struct _FILE_OBJECT *FileObject, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_ACQUIRE_FOR_CCFLUSH *PFAST_IO_ACQUIRE_FOR_CCFLUSH; typedef NTSTATUS -(DDKAPI *PFAST_IO_RELEASE_FOR_CCFLUSH) ( - IN struct _FILE_OBJECT *FileObject, - IN struct _DEVICE_OBJECT *DeviceObject); +(NTAPI FAST_IO_RELEASE_FOR_CCFLUSH)( + IN struct _FILE_OBJECT *FileObject, + IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_RELEASE_FOR_CCFLUSH *PFAST_IO_RELEASE_FOR_CCFLUSH; typedef struct _FAST_IO_DISPATCH { - ULONG SizeOfFastIoDispatch; - PFAST_IO_CHECK_IF_POSSIBLE FastIoCheckIfPossible; - PFAST_IO_READ FastIoRead; - PFAST_IO_WRITE FastIoWrite; - PFAST_IO_QUERY_BASIC_INFO FastIoQueryBasicInfo; - PFAST_IO_QUERY_STANDARD_INFO FastIoQueryStandardInfo; - PFAST_IO_LOCK FastIoLock; - PFAST_IO_UNLOCK_SINGLE FastIoUnlockSingle; - PFAST_IO_UNLOCK_ALL FastIoUnlockAll; - PFAST_IO_UNLOCK_ALL_BY_KEY FastIoUnlockAllByKey; - PFAST_IO_DEVICE_CONTROL FastIoDeviceControl; - PFAST_IO_ACQUIRE_FILE AcquireFileForNtCreateSection; - PFAST_IO_RELEASE_FILE ReleaseFileForNtCreateSection; - PFAST_IO_DETACH_DEVICE FastIoDetachDevice; - PFAST_IO_QUERY_NETWORK_OPEN_INFO FastIoQueryNetworkOpenInfo; - PFAST_IO_ACQUIRE_FOR_MOD_WRITE AcquireForModWrite; - PFAST_IO_MDL_READ MdlRead; - PFAST_IO_MDL_READ_COMPLETE MdlReadComplete; - PFAST_IO_PREPARE_MDL_WRITE PrepareMdlWrite; - PFAST_IO_MDL_WRITE_COMPLETE MdlWriteComplete; - PFAST_IO_READ_COMPRESSED FastIoReadCompressed; - PFAST_IO_WRITE_COMPRESSED FastIoWriteCompressed; - PFAST_IO_MDL_READ_COMPLETE_COMPRESSED MdlReadCompleteCompressed; - PFAST_IO_MDL_WRITE_COMPLETE_COMPRESSED MdlWriteCompleteCompressed; - PFAST_IO_QUERY_OPEN FastIoQueryOpen; - PFAST_IO_RELEASE_FOR_MOD_WRITE ReleaseForModWrite; - PFAST_IO_ACQUIRE_FOR_CCFLUSH AcquireForCcFlush; - PFAST_IO_RELEASE_FOR_CCFLUSH ReleaseForCcFlush; + ULONG SizeOfFastIoDispatch; + PFAST_IO_CHECK_IF_POSSIBLE FastIoCheckIfPossible; + PFAST_IO_READ FastIoRead; + PFAST_IO_WRITE FastIoWrite; + PFAST_IO_QUERY_BASIC_INFO FastIoQueryBasicInfo; + PFAST_IO_QUERY_STANDARD_INFO FastIoQueryStandardInfo; + PFAST_IO_LOCK FastIoLock; + PFAST_IO_UNLOCK_SINGLE FastIoUnlockSingle; + PFAST_IO_UNLOCK_ALL FastIoUnlockAll; + PFAST_IO_UNLOCK_ALL_BY_KEY FastIoUnlockAllByKey; + PFAST_IO_DEVICE_CONTROL FastIoDeviceControl; + PFAST_IO_ACQUIRE_FILE AcquireFileForNtCreateSection; + PFAST_IO_RELEASE_FILE ReleaseFileForNtCreateSection; + PFAST_IO_DETACH_DEVICE FastIoDetachDevice; + PFAST_IO_QUERY_NETWORK_OPEN_INFO FastIoQueryNetworkOpenInfo; + PFAST_IO_ACQUIRE_FOR_MOD_WRITE AcquireForModWrite; + PFAST_IO_MDL_READ MdlRead; + PFAST_IO_MDL_READ_COMPLETE MdlReadComplete; + PFAST_IO_PREPARE_MDL_WRITE PrepareMdlWrite; + PFAST_IO_MDL_WRITE_COMPLETE MdlWriteComplete; + PFAST_IO_READ_COMPRESSED FastIoReadCompressed; + PFAST_IO_WRITE_COMPRESSED FastIoWriteCompressed; + PFAST_IO_MDL_READ_COMPLETE_COMPRESSED MdlReadCompleteCompressed; + PFAST_IO_MDL_WRITE_COMPLETE_COMPRESSED MdlWriteCompleteCompressed; + PFAST_IO_QUERY_OPEN FastIoQueryOpen; + PFAST_IO_RELEASE_FOR_MOD_WRITE ReleaseForModWrite; + PFAST_IO_ACQUIRE_FOR_CCFLUSH AcquireForCcFlush; + PFAST_IO_RELEASE_FOR_CCFLUSH ReleaseForCcFlush; } FAST_IO_DISPATCH, *PFAST_IO_DISPATCH; typedef struct _SECTION_OBJECT_POINTERS { - PVOID DataSectionObject; - PVOID SharedCacheMap; - PVOID ImageSectionObject; + PVOID DataSectionObject; + PVOID SharedCacheMap; + PVOID ImageSectionObject; } SECTION_OBJECT_POINTERS, *PSECTION_OBJECT_POINTERS; typedef struct _IO_COMPLETION_CONTEXT { - PVOID Port; - PVOID Key; + PVOID Port; + PVOID Key; } IO_COMPLETION_CONTEXT, *PIO_COMPLETION_CONTEXT; /* FILE_OBJECT.Flags */ @@ -4175,6 +5406,7 @@ typedef struct _IO_COMPLETION_CONTEXT { #define FO_SKIP_COMPLETION_PORT 0x02000000 #define FO_SKIP_SET_EVENT 0x04000000 #define FO_SKIP_SET_FAST_IO 0x08000000 +#define FO_FLAGS_VALID_ONLY_DURING_CREATE FO_DISALLOW_EXCLUSIVE /* VPB.Flags */ #define VPB_MOUNTED 0x0001 @@ -4189,12 +5421,18 @@ typedef struct _IO_COMPLETION_CONTEXT { #define SL_FORCE_ACCESS_CHECK 0x01 #define SL_OPEN_PAGING_FILE 0x02 #define SL_OPEN_TARGET_DIRECTORY 0x04 +#define SL_STOP_ON_SYMLINK 0x08 #define SL_CASE_SENSITIVE 0x80 #define SL_KEY_SPECIFIED 0x01 #define SL_OVERRIDE_VERIFY_VOLUME 0x02 #define SL_WRITE_THROUGH 0x04 #define SL_FT_SEQUENTIAL_WRITE 0x08 +#define SL_FORCE_DIRECT_WRITE 0x10 +#define SL_REALTIME_STREAM 0x20 + +#define SL_READ_ACCESS_GRANTED 0x01 +#define SL_WRITE_ACCESS_GRANTED 0x04 #define SL_FAIL_IMMEDIATELY 0x01 #define SL_EXCLUSIVE_LOCK 0x02 @@ -4212,6 +5450,8 @@ typedef struct _IO_COMPLETION_CONTEXT { #define DEVICE_TYPE_FROM_CTL_CODE(ctl) (((ULONG) (ctl & 0xffff0000)) >> 16) +#define METHOD_FROM_CTL_CODE(ctrlCode) ((ULONG)(ctrlCode & 3)) + #define IRP_NOCACHE 0x00000001 #define IRP_PAGING_IO 0x00000002 #define IRP_MOUNT_COMPLETION 0x00000002 @@ -4297,6 +5537,9 @@ typedef struct _IO_COMPLETION_CONTEXT { #define IRP_MN_QUERY_BUS_INFORMATION 0x15 #define IRP_MN_DEVICE_USAGE_NOTIFICATION 0x16 #define IRP_MN_SURPRISE_REMOVAL 0x17 +#if (NTDDI_VERSION >= NTDDI_WIN7) +#define IRP_MN_DEVICE_ENUMERATED 0x19 +#endif #define IRP_MN_WAIT_WAKE 0x00 #define IRP_MN_POWER_SEQUENCE 0x01 @@ -4316,63 +5559,62 @@ typedef struct _IO_COMPLETION_CONTEXT { #define IRP_MN_REGINFO_EX 0x0b -typedef struct _FILE_OBJECT -{ - CSHORT Type; - CSHORT Size; - PDEVICE_OBJECT DeviceObject; - PVPB Vpb; - PVOID FsContext; - PVOID FsContext2; - PSECTION_OBJECT_POINTERS SectionObjectPointer; - PVOID PrivateCacheMap; - NTSTATUS FinalStatus; - struct _FILE_OBJECT *RelatedFileObject; - BOOLEAN LockOperation; - BOOLEAN DeletePending; - BOOLEAN ReadAccess; - BOOLEAN WriteAccess; - BOOLEAN DeleteAccess; - BOOLEAN SharedRead; - BOOLEAN SharedWrite; - BOOLEAN SharedDelete; - ULONG Flags; - UNICODE_STRING FileName; - LARGE_INTEGER CurrentByteOffset; - volatile ULONG Waiters; - volatile ULONG Busy; - PVOID LastLock; - KEVENT Lock; - KEVENT Event; - volatile PIO_COMPLETION_CONTEXT CompletionContext; - KSPIN_LOCK IrpListLock; - LIST_ENTRY IrpList; - volatile PVOID FileObjectExtension; +typedef struct _FILE_OBJECT { + CSHORT Type; + CSHORT Size; + PDEVICE_OBJECT DeviceObject; + PVPB Vpb; + PVOID FsContext; + PVOID FsContext2; + PSECTION_OBJECT_POINTERS SectionObjectPointer; + PVOID PrivateCacheMap; + NTSTATUS FinalStatus; + struct _FILE_OBJECT *RelatedFileObject; + BOOLEAN LockOperation; + BOOLEAN DeletePending; + BOOLEAN ReadAccess; + BOOLEAN WriteAccess; + BOOLEAN DeleteAccess; + BOOLEAN SharedRead; + BOOLEAN SharedWrite; + BOOLEAN SharedDelete; + ULONG Flags; + UNICODE_STRING FileName; + LARGE_INTEGER CurrentByteOffset; + volatile ULONG Waiters; + volatile ULONG Busy; + PVOID LastLock; + KEVENT Lock; + KEVENT Event; + volatile PIO_COMPLETION_CONTEXT CompletionContext; + KSPIN_LOCK IrpListLock; + LIST_ENTRY IrpList; + volatile PVOID FileObjectExtension; } FILE_OBJECT, *PFILE_OBJECT; typedef struct _IO_ERROR_LOG_PACKET { - UCHAR MajorFunctionCode; - UCHAR RetryCount; - USHORT DumpDataSize; - USHORT NumberOfStrings; - USHORT StringOffset; - USHORT EventCategory; - NTSTATUS ErrorCode; - ULONG UniqueErrorValue; - NTSTATUS FinalStatus; - ULONG SequenceNumber; - ULONG IoControlCode; - LARGE_INTEGER DeviceOffset; - ULONG DumpData[1]; + UCHAR MajorFunctionCode; + UCHAR RetryCount; + USHORT DumpDataSize; + USHORT NumberOfStrings; + USHORT StringOffset; + USHORT EventCategory; + NTSTATUS ErrorCode; + ULONG UniqueErrorValue; + NTSTATUS FinalStatus; + ULONG SequenceNumber; + ULONG IoControlCode; + LARGE_INTEGER DeviceOffset; + ULONG DumpData[1]; } IO_ERROR_LOG_PACKET, *PIO_ERROR_LOG_PACKET; typedef struct _IO_ERROR_LOG_MESSAGE { - USHORT Type; - USHORT Size; - USHORT DriverNameLength; - LARGE_INTEGER TimeStamp; - ULONG DriverNameOffset; - IO_ERROR_LOG_PACKET EntryData; + USHORT Type; + USHORT Size; + USHORT DriverNameLength; + LARGE_INTEGER TimeStamp; + ULONG DriverNameOffset; + IO_ERROR_LOG_PACKET EntryData; } IO_ERROR_LOG_MESSAGE, *PIO_ERROR_LOG_MESSAGE; #define ERROR_LOG_LIMIT_SIZE 240 @@ -4388,6 +5630,12 @@ typedef struct _IO_ERROR_LOG_MESSAGE { #define ERROR_LOG_MAXIMUM_SIZE (IO_ERROR_LOG_MESSAGE_LENGTH - \ IO_ERROR_LOG_MESSAGE_HEADER_LENGTH) +#ifdef _WIN64 +#define PORT_MAXIMUM_MESSAGE_LENGTH 512 +#else +#define PORT_MAXIMUM_MESSAGE_LENGTH 256 +#endif + typedef enum _DMA_WIDTH { Width8Bits, Width16Bits, @@ -4411,22 +5659,22 @@ typedef enum _DMA_SPEED { #define DEVICE_DESCRIPTION_VERSION2 0x0002 typedef struct _DEVICE_DESCRIPTION { - ULONG Version; - BOOLEAN Master; - BOOLEAN ScatterGather; - BOOLEAN DemandMode; - BOOLEAN AutoInitialize; - BOOLEAN Dma32BitAddresses; - BOOLEAN IgnoreCount; - BOOLEAN Reserved1; - BOOLEAN Dma64BitAddresses; - ULONG BusNumber; - ULONG DmaChannel; - INTERFACE_TYPE InterfaceType; - DMA_WIDTH DmaWidth; - DMA_SPEED DmaSpeed; - ULONG MaximumLength; - ULONG DmaPort; + ULONG Version; + BOOLEAN Master; + BOOLEAN ScatterGather; + BOOLEAN DemandMode; + BOOLEAN AutoInitialize; + BOOLEAN Dma32BitAddresses; + BOOLEAN IgnoreCount; + BOOLEAN Reserved1; + BOOLEAN Dma64BitAddresses; + ULONG BusNumber; + ULONG DmaChannel; + INTERFACE_TYPE InterfaceType; + DMA_WIDTH DmaWidth; + DMA_SPEED DmaSpeed; + ULONG MaximumLength; + ULONG DmaPort; } DEVICE_DESCRIPTION, *PDEVICE_DESCRIPTION; typedef enum _DEVICE_RELATION_TYPE { @@ -4440,21 +5688,20 @@ typedef enum _DEVICE_RELATION_TYPE { } DEVICE_RELATION_TYPE, *PDEVICE_RELATION_TYPE; typedef struct _DEVICE_RELATIONS { - ULONG Count; + ULONG Count; PDEVICE_OBJECT Objects[1]; } DEVICE_RELATIONS, *PDEVICE_RELATIONS; -typedef struct _DEVOBJ_EXTENSION -{ - CSHORT Type; - USHORT Size; - PDEVICE_OBJECT DeviceObject; +typedef struct _DEVOBJ_EXTENSION { + CSHORT Type; + USHORT Size; + PDEVICE_OBJECT DeviceObject; } DEVOBJ_EXTENSION, *PDEVOBJ_EXTENSION; typedef struct _SCATTER_GATHER_ELEMENT { - PHYSICAL_ADDRESS Address; - ULONG Length; - ULONG_PTR Reserved; + PHYSICAL_ADDRESS Address; + ULONG Length; + ULONG_PTR Reserved; } SCATTER_GATHER_ELEMENT, *PSCATTER_GATHER_ELEMENT; #if defined(_MSC_EXTENSIONS) @@ -4464,9 +5711,9 @@ typedef struct _SCATTER_GATHER_ELEMENT { #endif #pragma warning(disable:4200) typedef struct _SCATTER_GATHER_LIST { - ULONG NumberOfElements; - ULONG_PTR Reserved; - SCATTER_GATHER_ELEMENT Elements[1]; + ULONG NumberOfElements; + ULONG_PTR Reserved; + SCATTER_GATHER_ELEMENT Elements[1]; } SCATTER_GATHER_LIST, *PSCATTER_GATHER_LIST; #if _MSC_VER >= 1200 @@ -4483,16 +5730,16 @@ typedef struct _SCATTER_GATHER_LIST SCATTER_GATHER_LIST, *PSCATTER_GATHER_LIST; #endif typedef NTSTATUS -(DDKAPI DRIVER_ADD_DEVICE)( - IN struct _DRIVER_OBJECT *DriverObject, - IN struct _DEVICE_OBJECT *PhysicalDeviceObject); +(NTAPI DRIVER_ADD_DEVICE)( + IN struct _DRIVER_OBJECT *DriverObject, + IN struct _DEVICE_OBJECT *PhysicalDeviceObject); typedef DRIVER_ADD_DEVICE *PDRIVER_ADD_DEVICE; typedef struct _DRIVER_EXTENSION { - struct _DRIVER_OBJECT *DriverObject; - PDRIVER_ADD_DEVICE AddDevice; - ULONG Count; - UNICODE_STRING ServiceKeyName; + struct _DRIVER_OBJECT *DriverObject; + PDRIVER_ADD_DEVICE AddDevice; + ULONG Count; + UNICODE_STRING ServiceKeyName; } DRIVER_EXTENSION, *PDRIVER_EXTENSION; #define DRVO_UNLOAD_INVOKED 0x00000001 @@ -4500,320 +5747,319 @@ typedef struct _DRIVER_EXTENSION { #define DRVO_BUILTIN_DRIVER 0x00000004 typedef NTSTATUS -(DDKAPI DRIVER_INITIALIZE)( - IN struct _DRIVER_OBJECT *DriverObject, - IN PUNICODE_STRING RegistryPath); +(NTAPI DRIVER_INITIALIZE)( + IN struct _DRIVER_OBJECT *DriverObject, + IN PUNICODE_STRING RegistryPath); typedef DRIVER_INITIALIZE *PDRIVER_INITIALIZE; typedef VOID -(DDKAPI DRIVER_STARTIO)( - IN struct _DEVICE_OBJECT *DeviceObject, - IN struct _IRP *Irp); +(NTAPI DRIVER_STARTIO)( + IN struct _DEVICE_OBJECT *DeviceObject, + IN struct _IRP *Irp); typedef DRIVER_STARTIO *PDRIVER_STARTIO; typedef VOID -(DDKAPI DRIVER_UNLOAD)( - IN struct _DRIVER_OBJECT *DriverObject); +(NTAPI DRIVER_UNLOAD)( + IN struct _DRIVER_OBJECT *DriverObject); typedef DRIVER_UNLOAD *PDRIVER_UNLOAD; typedef NTSTATUS -(DDKAPI DRIVER_DISPATCH)( - IN struct _DEVICE_OBJECT *DeviceObject, - IN struct _IRP *Irp); +(NTAPI DRIVER_DISPATCH)( + IN struct _DEVICE_OBJECT *DeviceObject, + IN struct _IRP *Irp); typedef DRIVER_DISPATCH *PDRIVER_DISPATCH; typedef struct _DRIVER_OBJECT { - CSHORT Type; - CSHORT Size; - PDEVICE_OBJECT DeviceObject; - ULONG Flags; - PVOID DriverStart; - ULONG DriverSize; - PVOID DriverSection; - PDRIVER_EXTENSION DriverExtension; - UNICODE_STRING DriverName; - PUNICODE_STRING HardwareDatabase; + CSHORT Type; + CSHORT Size; + PDEVICE_OBJECT DeviceObject; + ULONG Flags; + PVOID DriverStart; + ULONG DriverSize; + PVOID DriverSection; + PDRIVER_EXTENSION DriverExtension; + UNICODE_STRING DriverName; + PUNICODE_STRING HardwareDatabase; struct _FAST_IO_DISPATCH *FastIoDispatch; - PDRIVER_INITIALIZE DriverInit; - PDRIVER_STARTIO DriverStartIo; - PDRIVER_UNLOAD DriverUnload; - PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION + 1]; -} DRIVER_OBJECT; -typedef struct _DRIVER_OBJECT *PDRIVER_OBJECT; + PDRIVER_INITIALIZE DriverInit; + PDRIVER_STARTIO DriverStartIo; + PDRIVER_UNLOAD DriverUnload; + PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION + 1]; +} DRIVER_OBJECT, *PDRIVER_OBJECT; typedef struct _DMA_ADAPTER { - USHORT Version; - USHORT Size; - struct _DMA_OPERATIONS* DmaOperations; + USHORT Version; + USHORT Size; + struct _DMA_OPERATIONS* DmaOperations; } DMA_ADAPTER, *PDMA_ADAPTER; typedef VOID -(DDKAPI *PPUT_DMA_ADAPTER)( - IN PDMA_ADAPTER DmaAdapter); +(NTAPI *PPUT_DMA_ADAPTER)( + IN PDMA_ADAPTER DmaAdapter); typedef PVOID -(DDKAPI *PALLOCATE_COMMON_BUFFER)( - IN PDMA_ADAPTER DmaAdapter, - IN ULONG Length, - OUT PPHYSICAL_ADDRESS LogicalAddress, - IN BOOLEAN CacheEnabled); +(NTAPI *PALLOCATE_COMMON_BUFFER)( + IN PDMA_ADAPTER DmaAdapter, + IN ULONG Length, + OUT PPHYSICAL_ADDRESS LogicalAddress, + IN BOOLEAN CacheEnabled); typedef VOID -(DDKAPI *PFREE_COMMON_BUFFER)( - IN PDMA_ADAPTER DmaAdapter, - IN ULONG Length, - IN PHYSICAL_ADDRESS LogicalAddress, - IN PVOID VirtualAddress, - IN BOOLEAN CacheEnabled); +(NTAPI *PFREE_COMMON_BUFFER)( + IN PDMA_ADAPTER DmaAdapter, + IN ULONG Length, + IN PHYSICAL_ADDRESS LogicalAddress, + IN PVOID VirtualAddress, + IN BOOLEAN CacheEnabled); typedef NTSTATUS -(DDKAPI *PALLOCATE_ADAPTER_CHANNEL)( - IN PDMA_ADAPTER DmaAdapter, - IN PDEVICE_OBJECT DeviceObject, - IN ULONG NumberOfMapRegisters, - IN PDRIVER_CONTROL ExecutionRoutine, - IN PVOID Context); +(NTAPI *PALLOCATE_ADAPTER_CHANNEL)( + IN PDMA_ADAPTER DmaAdapter, + IN PDEVICE_OBJECT DeviceObject, + IN ULONG NumberOfMapRegisters, + IN PDRIVER_CONTROL ExecutionRoutine, + IN PVOID Context); typedef BOOLEAN -(DDKAPI *PFLUSH_ADAPTER_BUFFERS)( - IN PDMA_ADAPTER DmaAdapter, - IN PMDL Mdl, - IN PVOID MapRegisterBase, - IN PVOID CurrentVa, - IN ULONG Length, - IN BOOLEAN WriteToDevice); +(NTAPI *PFLUSH_ADAPTER_BUFFERS)( + IN PDMA_ADAPTER DmaAdapter, + IN PMDL Mdl, + IN PVOID MapRegisterBase, + IN PVOID CurrentVa, + IN ULONG Length, + IN BOOLEAN WriteToDevice); typedef VOID -(DDKAPI *PFREE_ADAPTER_CHANNEL)( - IN PDMA_ADAPTER DmaAdapter); +(NTAPI *PFREE_ADAPTER_CHANNEL)( + IN PDMA_ADAPTER DmaAdapter); typedef VOID -(DDKAPI *PFREE_MAP_REGISTERS)( - IN PDMA_ADAPTER DmaAdapter, - PVOID MapRegisterBase, - ULONG NumberOfMapRegisters); +(NTAPI *PFREE_MAP_REGISTERS)( + IN PDMA_ADAPTER DmaAdapter, + PVOID MapRegisterBase, + ULONG NumberOfMapRegisters); typedef PHYSICAL_ADDRESS -(DDKAPI *PMAP_TRANSFER)( - IN PDMA_ADAPTER DmaAdapter, - IN PMDL Mdl, - IN PVOID MapRegisterBase, - IN PVOID CurrentVa, - IN OUT PULONG Length, - IN BOOLEAN WriteToDevice); +(NTAPI *PMAP_TRANSFER)( + IN PDMA_ADAPTER DmaAdapter, + IN PMDL Mdl, + IN PVOID MapRegisterBase, + IN PVOID CurrentVa, + IN OUT PULONG Length, + IN BOOLEAN WriteToDevice); typedef ULONG -(DDKAPI *PGET_DMA_ALIGNMENT)( - IN PDMA_ADAPTER DmaAdapter); +(NTAPI *PGET_DMA_ALIGNMENT)( + IN PDMA_ADAPTER DmaAdapter); typedef ULONG -(DDKAPI *PREAD_DMA_COUNTER)( - IN PDMA_ADAPTER DmaAdapter); +(NTAPI *PREAD_DMA_COUNTER)( + IN PDMA_ADAPTER DmaAdapter); typedef VOID -(DDKAPI *PDRIVER_LIST_CONTROL)( - IN struct _DEVICE_OBJECT *DeviceObject, - IN struct _IRP *Irp, - IN struct _SCATTER_GATHER_LIST *ScatterGather, - IN PVOID Context); +(NTAPI DRIVER_LIST_CONTROL)( + IN struct _DEVICE_OBJECT *DeviceObject, + IN struct _IRP *Irp, + IN struct _SCATTER_GATHER_LIST *ScatterGather, + IN PVOID Context); +typedef DRIVER_LIST_CONTROL *PDRIVER_LIST_CONTROL; typedef NTSTATUS -(DDKAPI *PGET_SCATTER_GATHER_LIST)( - IN PDMA_ADAPTER DmaAdapter, - IN PDEVICE_OBJECT DeviceObject, - IN PMDL Mdl, - IN PVOID CurrentVa, - IN ULONG Length, - IN PDRIVER_LIST_CONTROL ExecutionRoutine, - IN PVOID Context, - IN BOOLEAN WriteToDevice); +(NTAPI *PGET_SCATTER_GATHER_LIST)( + IN PDMA_ADAPTER DmaAdapter, + IN PDEVICE_OBJECT DeviceObject, + IN PMDL Mdl, + IN PVOID CurrentVa, + IN ULONG Length, + IN PDRIVER_LIST_CONTROL ExecutionRoutine, + IN PVOID Context, + IN BOOLEAN WriteToDevice); typedef VOID -(DDKAPI *PPUT_SCATTER_GATHER_LIST)( - IN PDMA_ADAPTER DmaAdapter, - IN PSCATTER_GATHER_LIST ScatterGather, - IN BOOLEAN WriteToDevice); +(NTAPI *PPUT_SCATTER_GATHER_LIST)( + IN PDMA_ADAPTER DmaAdapter, + IN PSCATTER_GATHER_LIST ScatterGather, + IN BOOLEAN WriteToDevice); typedef NTSTATUS -(DDKAPI *PCALCULATE_SCATTER_GATHER_LIST_SIZE)( - IN PDMA_ADAPTER DmaAdapter, - IN PMDL Mdl OPTIONAL, - IN PVOID CurrentVa, - IN ULONG Length, - OUT PULONG ScatterGatherListSize, - OUT PULONG pNumberOfMapRegisters OPTIONAL); +(NTAPI *PCALCULATE_SCATTER_GATHER_LIST_SIZE)( + IN PDMA_ADAPTER DmaAdapter, + IN PMDL Mdl OPTIONAL, + IN PVOID CurrentVa, + IN ULONG Length, + OUT PULONG ScatterGatherListSize, + OUT PULONG pNumberOfMapRegisters OPTIONAL); typedef NTSTATUS -(DDKAPI *PBUILD_SCATTER_GATHER_LIST)( - IN PDMA_ADAPTER DmaAdapter, - IN PDEVICE_OBJECT DeviceObject, - IN PMDL Mdl, - IN PVOID CurrentVa, - IN ULONG Length, - IN PDRIVER_LIST_CONTROL ExecutionRoutine, - IN PVOID Context, - IN BOOLEAN WriteToDevice, - IN PVOID ScatterGatherBuffer, - IN ULONG ScatterGatherLength); +(NTAPI *PBUILD_SCATTER_GATHER_LIST)( + IN PDMA_ADAPTER DmaAdapter, + IN PDEVICE_OBJECT DeviceObject, + IN PMDL Mdl, + IN PVOID CurrentVa, + IN ULONG Length, + IN PDRIVER_LIST_CONTROL ExecutionRoutine, + IN PVOID Context, + IN BOOLEAN WriteToDevice, + IN PVOID ScatterGatherBuffer, + IN ULONG ScatterGatherLength); typedef NTSTATUS -(DDKAPI *PBUILD_MDL_FROM_SCATTER_GATHER_LIST)( - IN PDMA_ADAPTER DmaAdapter, - IN PSCATTER_GATHER_LIST ScatterGather, - IN PMDL OriginalMdl, - OUT PMDL *TargetMdl); +(NTAPI *PBUILD_MDL_FROM_SCATTER_GATHER_LIST)( + IN PDMA_ADAPTER DmaAdapter, + IN PSCATTER_GATHER_LIST ScatterGather, + IN PMDL OriginalMdl, + OUT PMDL *TargetMdl); typedef struct _DMA_OPERATIONS { - ULONG Size; - PPUT_DMA_ADAPTER PutDmaAdapter; - PALLOCATE_COMMON_BUFFER AllocateCommonBuffer; - PFREE_COMMON_BUFFER FreeCommonBuffer; - PALLOCATE_ADAPTER_CHANNEL AllocateAdapterChannel; - PFLUSH_ADAPTER_BUFFERS FlushAdapterBuffers; - PFREE_ADAPTER_CHANNEL FreeAdapterChannel; - PFREE_MAP_REGISTERS FreeMapRegisters; - PMAP_TRANSFER MapTransfer; - PGET_DMA_ALIGNMENT GetDmaAlignment; - PREAD_DMA_COUNTER ReadDmaCounter; - PGET_SCATTER_GATHER_LIST GetScatterGatherList; - PPUT_SCATTER_GATHER_LIST PutScatterGatherList; - PCALCULATE_SCATTER_GATHER_LIST_SIZE CalculateScatterGatherList; - PBUILD_SCATTER_GATHER_LIST BuildScatterGatherList; - PBUILD_MDL_FROM_SCATTER_GATHER_LIST BuildMdlFromScatterGatherList; + ULONG Size; + PPUT_DMA_ADAPTER PutDmaAdapter; + PALLOCATE_COMMON_BUFFER AllocateCommonBuffer; + PFREE_COMMON_BUFFER FreeCommonBuffer; + PALLOCATE_ADAPTER_CHANNEL AllocateAdapterChannel; + PFLUSH_ADAPTER_BUFFERS FlushAdapterBuffers; + PFREE_ADAPTER_CHANNEL FreeAdapterChannel; + PFREE_MAP_REGISTERS FreeMapRegisters; + PMAP_TRANSFER MapTransfer; + PGET_DMA_ALIGNMENT GetDmaAlignment; + PREAD_DMA_COUNTER ReadDmaCounter; + PGET_SCATTER_GATHER_LIST GetScatterGatherList; + PPUT_SCATTER_GATHER_LIST PutScatterGatherList; + PCALCULATE_SCATTER_GATHER_LIST_SIZE CalculateScatterGatherList; + PBUILD_SCATTER_GATHER_LIST BuildScatterGatherList; + PBUILD_MDL_FROM_SCATTER_GATHER_LIST BuildMdlFromScatterGatherList; } DMA_OPERATIONS, *PDMA_OPERATIONS; typedef struct _IO_RESOURCE_DESCRIPTOR { - UCHAR Option; - UCHAR Type; - UCHAR ShareDisposition; - UCHAR Spare1; - USHORT Flags; - USHORT Spare2; + UCHAR Option; + UCHAR Type; + UCHAR ShareDisposition; + UCHAR Spare1; + USHORT Flags; + USHORT Spare2; union { struct { - ULONG Length; - ULONG Alignment; - PHYSICAL_ADDRESS MinimumAddress; - PHYSICAL_ADDRESS MaximumAddress; + ULONG Length; + ULONG Alignment; + PHYSICAL_ADDRESS MinimumAddress; + PHYSICAL_ADDRESS MaximumAddress; } Port; struct { - ULONG Length; - ULONG Alignment; - PHYSICAL_ADDRESS MinimumAddress; - PHYSICAL_ADDRESS MaximumAddress; + ULONG Length; + ULONG Alignment; + PHYSICAL_ADDRESS MinimumAddress; + PHYSICAL_ADDRESS MaximumAddress; } Memory; struct { - ULONG MinimumVector; - ULONG MaximumVector; + ULONG MinimumVector; + ULONG MaximumVector; } Interrupt; struct { - ULONG MinimumChannel; - ULONG MaximumChannel; + ULONG MinimumChannel; + ULONG MaximumChannel; } Dma; struct { - ULONG Length; - ULONG Alignment; - PHYSICAL_ADDRESS MinimumAddress; - PHYSICAL_ADDRESS MaximumAddress; + ULONG Length; + ULONG Alignment; + PHYSICAL_ADDRESS MinimumAddress; + PHYSICAL_ADDRESS MaximumAddress; } Generic; struct { - ULONG Data[3]; + ULONG Data[3]; } DevicePrivate; struct { - ULONG Length; - ULONG MinBusNumber; - ULONG MaxBusNumber; - ULONG Reserved; + ULONG Length; + ULONG MinBusNumber; + ULONG MaxBusNumber; + ULONG Reserved; } BusNumber; struct { - ULONG Priority; - ULONG Reserved1; - ULONG Reserved2; + ULONG Priority; + ULONG Reserved1; + ULONG Reserved2; } ConfigData; } u; } IO_RESOURCE_DESCRIPTOR, *PIO_RESOURCE_DESCRIPTOR; typedef struct _IO_RESOURCE_LIST { - USHORT Version; - USHORT Revision; - ULONG Count; - IO_RESOURCE_DESCRIPTOR Descriptors[1]; + USHORT Version; + USHORT Revision; + ULONG Count; + IO_RESOURCE_DESCRIPTOR Descriptors[1]; } IO_RESOURCE_LIST, *PIO_RESOURCE_LIST; typedef struct _IO_RESOURCE_REQUIREMENTS_LIST { - ULONG ListSize; - INTERFACE_TYPE InterfaceType; - ULONG BusNumber; - ULONG SlotNumber; - ULONG Reserved[3]; - ULONG AlternativeLists; - IO_RESOURCE_LIST List[1]; + ULONG ListSize; + INTERFACE_TYPE InterfaceType; + ULONG BusNumber; + ULONG SlotNumber; + ULONG Reserved[3]; + ULONG AlternativeLists; + IO_RESOURCE_LIST List[1]; } IO_RESOURCE_REQUIREMENTS_LIST, *PIO_RESOURCE_REQUIREMENTS_LIST; typedef VOID -(DDKAPI DRIVER_CANCEL)( - IN struct _DEVICE_OBJECT *DeviceObject, - IN struct _IRP *Irp); +(NTAPI DRIVER_CANCEL)( + IN struct _DEVICE_OBJECT *DeviceObject, + IN struct _IRP *Irp); typedef DRIVER_CANCEL *PDRIVER_CANCEL; typedef struct _IRP { - CSHORT Type; - USHORT Size; - struct _MDL *MdlAddress; - ULONG Flags; + CSHORT Type; + USHORT Size; + struct _MDL *MdlAddress; + ULONG Flags; union { - struct _IRP *MasterIrp; - volatile LONG IrpCount; - PVOID SystemBuffer; + struct _IRP *MasterIrp; + volatile LONG IrpCount; + PVOID SystemBuffer; } AssociatedIrp; - LIST_ENTRY ThreadListEntry; - IO_STATUS_BLOCK IoStatus; - KPROCESSOR_MODE RequestorMode; - BOOLEAN PendingReturned; - CHAR StackCount; - CHAR CurrentLocation; - BOOLEAN Cancel; - KIRQL CancelIrql; - CCHAR ApcEnvironment; - UCHAR AllocationFlags; - PIO_STATUS_BLOCK UserIosb; - PKEVENT UserEvent; - union { - struct { - _ANONYMOUS_UNION union { - PIO_APC_ROUTINE UserApcRoutine; - PVOID IssuingProcess; - } DUMMYUNIONNAME; - PVOID UserApcContext; - } AsynchronousParameters; - LARGE_INTEGER AllocationSize; - } Overlay; - volatile PDRIVER_CANCEL CancelRoutine; - PVOID UserBuffer; + LIST_ENTRY ThreadListEntry; + IO_STATUS_BLOCK IoStatus; + KPROCESSOR_MODE RequestorMode; + BOOLEAN PendingReturned; + CHAR StackCount; + CHAR CurrentLocation; + BOOLEAN Cancel; + KIRQL CancelIrql; + CCHAR ApcEnvironment; + UCHAR AllocationFlags; + PIO_STATUS_BLOCK UserIosb; + PKEVENT UserEvent; union { struct { _ANONYMOUS_UNION union { - KDEVICE_QUEUE_ENTRY DeviceQueueEntry; + PIO_APC_ROUTINE UserApcRoutine; + PVOID IssuingProcess; + } DUMMYUNIONNAME; + PVOID UserApcContext; + } AsynchronousParameters; + LARGE_INTEGER AllocationSize; + } Overlay; + volatile PDRIVER_CANCEL CancelRoutine; + PVOID UserBuffer; + union { + struct { + _ANONYMOUS_UNION union { + KDEVICE_QUEUE_ENTRY DeviceQueueEntry; _ANONYMOUS_STRUCT struct { - PVOID DriverContext[4]; + PVOID DriverContext[4]; } DUMMYSTRUCTNAME; } DUMMYUNIONNAME; - PETHREAD Thread; - PCHAR AuxiliaryBuffer; + PETHREAD Thread; + PCHAR AuxiliaryBuffer; _ANONYMOUS_STRUCT struct { - LIST_ENTRY ListEntry; + LIST_ENTRY ListEntry; _ANONYMOUS_UNION union { - struct _IO_STACK_LOCATION *CurrentStackLocation; - ULONG PacketType; + struct _IO_STACK_LOCATION *CurrentStackLocation; + ULONG PacketType; } DUMMYUNIONNAME; } DUMMYSTRUCTNAME; - struct _FILE_OBJECT *OriginalFileObject; + struct _FILE_OBJECT *OriginalFileObject; } Overlay; - KAPC Apc; - PVOID CompletionKey; + KAPC Apc; + PVOID CompletionKey; } Tail; -} IRP; -typedef struct _IRP *PIRP; +} IRP, *PIRP; typedef enum _IO_PAGING_PRIORITY { IoPagingPriorityInvalid, @@ -4824,93 +6070,96 @@ typedef enum _IO_PAGING_PRIORITY { } IO_PAGING_PRIORITY; typedef NTSTATUS -(DDKAPI IO_COMPLETION_ROUTINE)( - IN struct _DEVICE_OBJECT *DeviceObject, - IN struct _IRP *Irp, - IN PVOID Context); +(NTAPI IO_COMPLETION_ROUTINE)( + IN struct _DEVICE_OBJECT *DeviceObject, + IN struct _IRP *Irp, + IN PVOID Context); typedef IO_COMPLETION_ROUTINE *PIO_COMPLETION_ROUTINE; typedef VOID -(DDKAPI *PIO_DPC_ROUTINE)( - IN struct _KDPC *Dpc, - IN struct _DEVICE_OBJECT *DeviceObject, - IN struct _IRP *Irp, - IN PVOID Context); +(NTAPI IO_DPC_ROUTINE)( + IN struct _KDPC *Dpc, + IN struct _DEVICE_OBJECT *DeviceObject, + IN struct _IRP *Irp, + IN PVOID Context); +typedef IO_DPC_ROUTINE *PIO_DPC_ROUTINE; typedef NTSTATUS -(DDKAPI *PMM_DLL_INITIALIZE)( - IN PUNICODE_STRING RegistryPath); +(NTAPI *PMM_DLL_INITIALIZE)( + IN PUNICODE_STRING RegistryPath); typedef NTSTATUS -(DDKAPI *PMM_DLL_UNLOAD)( +(NTAPI *PMM_DLL_UNLOAD)( VOID); -typedef BOOLEAN -(DDKAPI KSERVICE_ROUTINE)( - IN struct _KINTERRUPT *Interrupt, - IN PVOID ServiceContext); -typedef KSERVICE_ROUTINE *PKSERVICE_ROUTINE; - typedef VOID -(DDKAPI *PIO_TIMER_ROUTINE)( - IN struct _DEVICE_OBJECT *DeviceObject, - IN PVOID Context); +(NTAPI IO_TIMER_ROUTINE)( + IN struct _DEVICE_OBJECT *DeviceObject, + IN PVOID Context); +typedef IO_TIMER_ROUTINE *PIO_TIMER_ROUTINE; typedef struct _IO_SECURITY_CONTEXT { - PSECURITY_QUALITY_OF_SERVICE SecurityQos; - PACCESS_STATE AccessState; - ACCESS_MASK DesiredAccess; - ULONG FullCreateOptions; + PSECURITY_QUALITY_OF_SERVICE SecurityQos; + PACCESS_STATE AccessState; + ACCESS_MASK DesiredAccess; + ULONG FullCreateOptions; } IO_SECURITY_CONTEXT, *PIO_SECURITY_CONTEXT; struct _IO_CSQ; typedef struct _IO_CSQ_IRP_CONTEXT { - ULONG Type; - struct _IRP *Irp; - struct _IO_CSQ *Csq; + ULONG Type; + struct _IRP *Irp; + struct _IO_CSQ *Csq; } IO_CSQ_IRP_CONTEXT, *PIO_CSQ_IRP_CONTEXT; typedef VOID -(DDKAPI *PIO_CSQ_INSERT_IRP)( - IN struct _IO_CSQ *Csq, - IN PIRP Irp); +(NTAPI *PIO_CSQ_INSERT_IRP)( + IN struct _IO_CSQ *Csq, + IN PIRP Irp); + +typedef NTSTATUS +(NTAPI IO_CSQ_INSERT_IRP_EX)( + IN struct _IO_CSQ *Csq, + IN PIRP Irp, + IN PVOID InsertContext); +typedef IO_CSQ_INSERT_IRP_EX *PIO_CSQ_INSERT_IRP_EX; typedef VOID -(DDKAPI *PIO_CSQ_REMOVE_IRP)( - IN struct _IO_CSQ *Csq, - IN PIRP Irp); +(NTAPI *PIO_CSQ_REMOVE_IRP)( + IN struct _IO_CSQ *Csq, + IN PIRP Irp); typedef PIRP -(DDKAPI *PIO_CSQ_PEEK_NEXT_IRP)( - IN struct _IO_CSQ *Csq, - IN PIRP Irp, - IN PVOID PeekContext); +(NTAPI *PIO_CSQ_PEEK_NEXT_IRP)( + IN struct _IO_CSQ *Csq, + IN PIRP Irp, + IN PVOID PeekContext); typedef VOID -(DDKAPI *PIO_CSQ_ACQUIRE_LOCK)( - IN struct _IO_CSQ *Csq, - OUT PKIRQL Irql); +(NTAPI *PIO_CSQ_ACQUIRE_LOCK)( + IN struct _IO_CSQ *Csq, + OUT PKIRQL Irql); typedef VOID -(DDKAPI *PIO_CSQ_RELEASE_LOCK)( - IN struct _IO_CSQ *Csq, - IN KIRQL Irql); +(NTAPI *PIO_CSQ_RELEASE_LOCK)( + IN struct _IO_CSQ *Csq, + IN KIRQL Irql); typedef VOID -(DDKAPI *PIO_CSQ_COMPLETE_CANCELED_IRP)( - IN struct _IO_CSQ *Csq, - IN PIRP Irp); +(NTAPI *PIO_CSQ_COMPLETE_CANCELED_IRP)( + IN struct _IO_CSQ *Csq, + IN PIRP Irp); typedef struct _IO_CSQ { - ULONG Type; - PIO_CSQ_INSERT_IRP CsqInsertIrp; - PIO_CSQ_REMOVE_IRP CsqRemoveIrp; - PIO_CSQ_PEEK_NEXT_IRP CsqPeekNextIrp; - PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock; - PIO_CSQ_RELEASE_LOCK CsqReleaseLock; - PIO_CSQ_COMPLETE_CANCELED_IRP CsqCompleteCanceledIrp; - PVOID ReservePointer; + ULONG Type; + PIO_CSQ_INSERT_IRP CsqInsertIrp; + PIO_CSQ_REMOVE_IRP CsqRemoveIrp; + PIO_CSQ_PEEK_NEXT_IRP CsqPeekNextIrp; + PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock; + PIO_CSQ_RELEASE_LOCK CsqReleaseLock; + PIO_CSQ_COMPLETE_CANCELED_IRP CsqCompleteCanceledIrp; + PVOID ReservePointer; } IO_CSQ, *PIO_CSQ; typedef enum _BUS_QUERY_ID_TYPE { @@ -4926,198 +6175,321 @@ typedef enum _DEVICE_TEXT_TYPE { DeviceTextLocationInformation } DEVICE_TEXT_TYPE, *PDEVICE_TEXT_TYPE; -typedef enum _WORK_QUEUE_TYPE { - CriticalWorkQueue, - DelayedWorkQueue, - HyperCriticalWorkQueue, - MaximumWorkQueue -} WORK_QUEUE_TYPE; +typedef BOOLEAN +(NTAPI *PGPE_SERVICE_ROUTINE)( + PVOID, + PVOID); + +typedef NTSTATUS +(NTAPI *PGPE_CONNECT_VECTOR)( + PDEVICE_OBJECT, + ULONG, + KINTERRUPT_MODE, + BOOLEAN, + PGPE_SERVICE_ROUTINE, + PVOID, + PVOID); + +typedef NTSTATUS +(NTAPI *PGPE_DISCONNECT_VECTOR)( + PVOID); + +typedef NTSTATUS +(NTAPI *PGPE_ENABLE_EVENT)( + PDEVICE_OBJECT, + PVOID); + +typedef NTSTATUS +(NTAPI *PGPE_DISABLE_EVENT)( + PDEVICE_OBJECT, + PVOID); + +typedef NTSTATUS +(NTAPI *PGPE_CLEAR_STATUS)( + PDEVICE_OBJECT, + PVOID); + +typedef VOID +(NTAPI *PDEVICE_NOTIFY_CALLBACK)( + PVOID, + ULONG); + +typedef NTSTATUS +(NTAPI *PREGISTER_FOR_DEVICE_NOTIFICATIONS)( + PDEVICE_OBJECT, + PDEVICE_NOTIFY_CALLBACK, + PVOID); + +typedef VOID +(NTAPI *PUNREGISTER_FOR_DEVICE_NOTIFICATIONS)( + PDEVICE_OBJECT, + PDEVICE_NOTIFY_CALLBACK); + +typedef struct _ACPI_INTERFACE_STANDARD { + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; + PGPE_CONNECT_VECTOR GpeConnectVector; + PGPE_DISCONNECT_VECTOR GpeDisconnectVector; + PGPE_ENABLE_EVENT GpeEnableEvent; + PGPE_DISABLE_EVENT GpeDisableEvent; + PGPE_CLEAR_STATUS GpeClearStatus; + PREGISTER_FOR_DEVICE_NOTIFICATIONS RegisterForDeviceNotifications; + PUNREGISTER_FOR_DEVICE_NOTIFICATIONS UnregisterForDeviceNotifications; +} ACPI_INTERFACE_STANDARD, *PACPI_INTERFACE_STANDARD; + +typedef BOOLEAN +(NTAPI *PGPE_SERVICE_ROUTINE2)( + PVOID ObjectContext, + PVOID ServiceContext); + +typedef NTSTATUS +(NTAPI *PGPE_CONNECT_VECTOR2)( + PVOID Context, + ULONG GpeNumber, + KINTERRUPT_MODE Mode, + BOOLEAN Shareable, + PGPE_SERVICE_ROUTINE ServiceRoutine, + PVOID ServiceContext, + PVOID *ObjectContext); + +typedef NTSTATUS +(NTAPI *PGPE_DISCONNECT_VECTOR2)( + PVOID Context, + PVOID ObjectContext); + +typedef NTSTATUS +(NTAPI *PGPE_ENABLE_EVENT2)( + PVOID Context, + PVOID ObjectContext); + +typedef NTSTATUS +(NTAPI *PGPE_DISABLE_EVENT2)( + PVOID Context, + PVOID ObjectContext); + +typedef NTSTATUS +(NTAPI *PGPE_CLEAR_STATUS2)( + PVOID Context, + PVOID ObjectContext); + +typedef VOID +(NTAPI *PDEVICE_NOTIFY_CALLBACK2)( + PVOID NotificationContext, + ULONG NotifyCode); + +typedef NTSTATUS +(NTAPI *PREGISTER_FOR_DEVICE_NOTIFICATIONS2)( + PVOID Context, + PDEVICE_NOTIFY_CALLBACK2 NotificationHandler, + PVOID NotificationContext); + +typedef VOID +(NTAPI *PUNREGISTER_FOR_DEVICE_NOTIFICATIONS2)( + PVOID Context); + +typedef struct _ACPI_INTERFACE_STANDARD2 { + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; + PGPE_CONNECT_VECTOR2 GpeConnectVector; + PGPE_DISCONNECT_VECTOR2 GpeDisconnectVector; + PGPE_ENABLE_EVENT2 GpeEnableEvent; + PGPE_DISABLE_EVENT2 GpeDisableEvent; + PGPE_CLEAR_STATUS2 GpeClearStatus; + PREGISTER_FOR_DEVICE_NOTIFICATIONS2 RegisterForDeviceNotifications; + PUNREGISTER_FOR_DEVICE_NOTIFICATIONS2 UnregisterForDeviceNotifications; +} ACPI_INTERFACE_STANDARD2, *PACPI_INTERFACE_STANDARD2; #if !defined(_AMD64_) && !defined(_IA64_) #include #endif typedef struct _IO_STACK_LOCATION { - UCHAR MajorFunction; - UCHAR MinorFunction; - UCHAR Flags; - UCHAR Control; + UCHAR MajorFunction; + UCHAR MinorFunction; + UCHAR Flags; + UCHAR Control; union { struct { - PIO_SECURITY_CONTEXT SecurityContext; - ULONG Options; - USHORT POINTER_ALIGNMENT FileAttributes; - USHORT ShareAccess; - ULONG POINTER_ALIGNMENT EaLength; + PIO_SECURITY_CONTEXT SecurityContext; + ULONG Options; + USHORT POINTER_ALIGNMENT FileAttributes; + USHORT ShareAccess; + ULONG POINTER_ALIGNMENT EaLength; } Create; struct { - ULONG Length; - ULONG POINTER_ALIGNMENT Key; - LARGE_INTEGER ByteOffset; + ULONG Length; + ULONG POINTER_ALIGNMENT Key; + LARGE_INTEGER ByteOffset; } Read; struct { - ULONG Length; - ULONG POINTER_ALIGNMENT Key; - LARGE_INTEGER ByteOffset; + ULONG Length; + ULONG POINTER_ALIGNMENT Key; + LARGE_INTEGER ByteOffset; } Write; struct { - ULONG Length; - PUNICODE_STRING FileName; - FILE_INFORMATION_CLASS FileInformationClass; - ULONG FileIndex; + ULONG Length; + PUNICODE_STRING FileName; + FILE_INFORMATION_CLASS FileInformationClass; + ULONG FileIndex; } QueryDirectory; struct { - ULONG Length; - ULONG CompletionFilter; + ULONG Length; + ULONG CompletionFilter; } NotifyDirectory; struct { - ULONG Length; - FILE_INFORMATION_CLASS POINTER_ALIGNMENT FileInformationClass; + ULONG Length; + FILE_INFORMATION_CLASS POINTER_ALIGNMENT FileInformationClass; } QueryFile; struct { - ULONG Length; - FILE_INFORMATION_CLASS POINTER_ALIGNMENT FileInformationClass; - PFILE_OBJECT FileObject; + ULONG Length; + FILE_INFORMATION_CLASS POINTER_ALIGNMENT FileInformationClass; + PFILE_OBJECT FileObject; _ANONYMOUS_UNION union { _ANONYMOUS_STRUCT struct { - BOOLEAN ReplaceIfExists; - BOOLEAN AdvanceOnly; + BOOLEAN ReplaceIfExists; + BOOLEAN AdvanceOnly; } DUMMYSTRUCTNAME; - ULONG ClusterCount; - HANDLE DeleteHandle; + ULONG ClusterCount; + HANDLE DeleteHandle; } DUMMYUNIONNAME; } SetFile; struct { - ULONG Length; - PVOID EaList; - ULONG EaListLength; - ULONG EaIndex; + ULONG Length; + PVOID EaList; + ULONG EaListLength; + ULONG EaIndex; } QueryEa; struct { - ULONG Length; + ULONG Length; } SetEa; struct { - ULONG Length; - FS_INFORMATION_CLASS POINTER_ALIGNMENT FsInformationClass; + ULONG Length; + FS_INFORMATION_CLASS POINTER_ALIGNMENT FsInformationClass; } QueryVolume; struct { - ULONG Length; - FS_INFORMATION_CLASS FsInformationClass; + ULONG Length; + FS_INFORMATION_CLASS FsInformationClass; } SetVolume; struct { - ULONG OutputBufferLength; - ULONG InputBufferLength; - ULONG FsControlCode; - PVOID Type3InputBuffer; + ULONG OutputBufferLength; + ULONG InputBufferLength; + ULONG FsControlCode; + PVOID Type3InputBuffer; } FileSystemControl; struct { - PLARGE_INTEGER Length; - ULONG Key; - LARGE_INTEGER ByteOffset; + PLARGE_INTEGER Length; + ULONG Key; + LARGE_INTEGER ByteOffset; } LockControl; struct { - ULONG OutputBufferLength; - ULONG POINTER_ALIGNMENT InputBufferLength; - ULONG POINTER_ALIGNMENT IoControlCode; - PVOID Type3InputBuffer; + ULONG OutputBufferLength; + ULONG POINTER_ALIGNMENT InputBufferLength; + ULONG POINTER_ALIGNMENT IoControlCode; + PVOID Type3InputBuffer; } DeviceIoControl; struct { - SECURITY_INFORMATION SecurityInformation; - ULONG POINTER_ALIGNMENT Length; + SECURITY_INFORMATION SecurityInformation; + ULONG POINTER_ALIGNMENT Length; } QuerySecurity; struct { - SECURITY_INFORMATION SecurityInformation; - PSECURITY_DESCRIPTOR SecurityDescriptor; + SECURITY_INFORMATION SecurityInformation; + PSECURITY_DESCRIPTOR SecurityDescriptor; } SetSecurity; struct { - PVPB Vpb; - PDEVICE_OBJECT DeviceObject; + PVPB Vpb; + PDEVICE_OBJECT DeviceObject; } MountVolume; struct { - PVPB Vpb; - PDEVICE_OBJECT DeviceObject; + PVPB Vpb; + PDEVICE_OBJECT DeviceObject; } VerifyVolume; struct { - struct _SCSI_REQUEST_BLOCK *Srb; + struct _SCSI_REQUEST_BLOCK *Srb; } Scsi; struct { - ULONG Length; - PSID StartSid; - struct _FILE_GET_QUOTA_INFORMATION *SidList; - ULONG SidListLength; + ULONG Length; + PSID StartSid; + struct _FILE_GET_QUOTA_INFORMATION *SidList; + ULONG SidListLength; } QueryQuota; struct { - ULONG Length; + ULONG Length; } SetQuota; struct { - DEVICE_RELATION_TYPE Type; + DEVICE_RELATION_TYPE Type; } QueryDeviceRelations; struct { - CONST GUID *InterfaceType; - USHORT Size; - USHORT Version; - PINTERFACE Interface; - PVOID InterfaceSpecificData; + CONST GUID *InterfaceType; + USHORT Size; + USHORT Version; + PINTERFACE Interface; + PVOID InterfaceSpecificData; } QueryInterface; struct { - PDEVICE_CAPABILITIES Capabilities; + PDEVICE_CAPABILITIES Capabilities; } DeviceCapabilities; struct { - PIO_RESOURCE_REQUIREMENTS_LIST IoResourceRequirementList; + PIO_RESOURCE_REQUIREMENTS_LIST IoResourceRequirementList; } FilterResourceRequirements; struct { - ULONG WhichSpace; - PVOID Buffer; - ULONG Offset; - ULONG POINTER_ALIGNMENT Length; + ULONG WhichSpace; + PVOID Buffer; + ULONG Offset; + ULONG POINTER_ALIGNMENT Length; } ReadWriteConfig; struct { - BOOLEAN Lock; + BOOLEAN Lock; } SetLock; struct { - BUS_QUERY_ID_TYPE IdType; + BUS_QUERY_ID_TYPE IdType; } QueryId; struct { - DEVICE_TEXT_TYPE DeviceTextType; - LCID POINTER_ALIGNMENT LocaleId; + DEVICE_TEXT_TYPE DeviceTextType; + LCID POINTER_ALIGNMENT LocaleId; } QueryDeviceText; struct { - BOOLEAN InPath; - BOOLEAN Reserved[3]; - DEVICE_USAGE_NOTIFICATION_TYPE POINTER_ALIGNMENT Type; + BOOLEAN InPath; + BOOLEAN Reserved[3]; + DEVICE_USAGE_NOTIFICATION_TYPE POINTER_ALIGNMENT Type; } UsageNotification; struct { - SYSTEM_POWER_STATE PowerState; + SYSTEM_POWER_STATE PowerState; } WaitWake; struct { - PPOWER_SEQUENCE PowerSequence; + PPOWER_SEQUENCE PowerSequence; } PowerSequence; struct { - ULONG SystemContext; - POWER_STATE_TYPE POINTER_ALIGNMENT Type; - POWER_STATE POINTER_ALIGNMENT State; - POWER_ACTION POINTER_ALIGNMENT ShutdownType; + ULONG SystemContext; + POWER_STATE_TYPE POINTER_ALIGNMENT Type; + POWER_STATE POINTER_ALIGNMENT State; + POWER_ACTION POINTER_ALIGNMENT ShutdownType; } Power; struct { - PCM_RESOURCE_LIST AllocatedResources; - PCM_RESOURCE_LIST AllocatedResourcesTranslated; + PCM_RESOURCE_LIST AllocatedResources; + PCM_RESOURCE_LIST AllocatedResourcesTranslated; } StartDevice; struct { - ULONG_PTR ProviderId; - PVOID DataPath; - ULONG BufferSize; - PVOID Buffer; + ULONG_PTR ProviderId; + PVOID DataPath; + ULONG BufferSize; + PVOID Buffer; } WMI; struct { - PVOID Argument1; - PVOID Argument2; - PVOID Argument3; - PVOID Argument4; + PVOID Argument1; + PVOID Argument2; + PVOID Argument3; + PVOID Argument4; } Others; } Parameters; - PDEVICE_OBJECT DeviceObject; - PFILE_OBJECT FileObject; - PIO_COMPLETION_ROUTINE CompletionRoutine; - PVOID Context; + PDEVICE_OBJECT DeviceObject; + PFILE_OBJECT FileObject; + PIO_COMPLETION_ROUTINE CompletionRoutine; + PVOID Context; } IO_STACK_LOCATION, *PIO_STACK_LOCATION; #if !defined(_AMD64_) && !defined(_IA64_) #include @@ -5131,16 +6503,13 @@ typedef struct _IO_STACK_LOCATION { #define SL_INVOKE_ON_SUCCESS 0x40 #define SL_INVOKE_ON_ERROR 0x80 -/* IO_STACK_LOCATION.Parameters.ReadWriteControl.WhichSpace */ - -#define PCI_WHICHSPACE_CONFIG 0x0 -#define PCI_WHICHSPACE_ROM 0x52696350 /* 'PciR' */ - #define METHOD_BUFFERED 0 #define METHOD_IN_DIRECT 1 #define METHOD_OUT_DIRECT 2 #define METHOD_NEITHER 3 +#define METHOD_DIRECT_TO_HARDWARE METHOD_IN_DIRECT +#define METHOD_DIRECT_FROM_HARDWARE METHOD_OUT_DIRECT #define FILE_SUPERSEDED 0x00000000 #define FILE_OPENED 0x00000001 @@ -5187,6 +6556,7 @@ typedef struct _IO_STACK_LOCATION { #define FILE_ATTRIBUTE_OFFLINE 0x00001000 #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000 #define FILE_ATTRIBUTE_ENCRYPTED 0x00004000 +#define FILE_ATTRIBUTE_VIRTUAL 0x00010000 #define FILE_ATTRIBUTE_VALID_FLAGS 0x00007fb7 #define FILE_ATTRIBUTE_VALID_SET_FLAGS 0x000031a7 @@ -5220,6 +6590,10 @@ typedef struct _IO_STACK_LOCATION { #define FILE_OPEN_BY_FILE_ID 0x00002000 #define FILE_OPEN_FOR_BACKUP_INTENT 0x00004000 #define FILE_NO_COMPRESSION 0x00008000 +#if (NTDDI_VERSION >= NTDDI_WIN7) +#define FILE_OPEN_REQUIRING_OPLOCK 0x00010000 +#define FILE_DISALLOW_EXCLUSIVE 0x00020000 +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ #define FILE_RESERVE_OPFILTER 0x00100000 #define FILE_OPEN_REPARSE_POINT 0x00200000 #define FILE_OPEN_NO_RECALL 0x00400000 @@ -5258,15 +6632,926 @@ typedef struct _IO_STACK_LOCATION { /* end winnt.h */ +#define WMIREG_ACTION_REGISTER 1 +#define WMIREG_ACTION_DEREGISTER 2 +#define WMIREG_ACTION_REREGISTER 3 +#define WMIREG_ACTION_UPDATE_GUIDS 4 +#define WMIREG_ACTION_BLOCK_IRPS 5 + +#define WMIREGISTER 0 +#define WMIUPDATE 1 + +typedef VOID +(NTAPI FWMI_NOTIFICATION_CALLBACK)( + PVOID Wnode, + PVOID Context); +typedef FWMI_NOTIFICATION_CALLBACK *WMI_NOTIFICATION_CALLBACK; + +#ifndef _PCI_X_ +#define _PCI_X_ + +typedef struct _PCI_SLOT_NUMBER { + union { + struct { + ULONG DeviceNumber:5; + ULONG FunctionNumber:3; + ULONG Reserved:24; + } bits; + ULONG AsULONG; + } u; +} PCI_SLOT_NUMBER, *PPCI_SLOT_NUMBER; + +#define PCI_TYPE0_ADDRESSES 6 +#define PCI_TYPE1_ADDRESSES 2 +#define PCI_TYPE2_ADDRESSES 5 + +typedef struct _PCI_COMMON_HEADER { + PCI_COMMON_HEADER_LAYOUT +} PCI_COMMON_HEADER, *PPCI_COMMON_HEADER; + +#ifdef __cplusplus +typedef struct _PCI_COMMON_CONFIG { + PCI_COMMON_HEADER_LAYOUT + UCHAR DeviceSpecific[192]; +} PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG; +#else +typedef struct _PCI_COMMON_CONFIG { + PCI_COMMON_HEADER DUMMYSTRUCTNAME; + UCHAR DeviceSpecific[192]; +} PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG; +#endif + +#define PCI_COMMON_HDR_LENGTH (FIELD_OFFSET(PCI_COMMON_CONFIG, DeviceSpecific)) + +#define PCI_EXTENDED_CONFIG_LENGTH 0x1000 + +#define PCI_MAX_DEVICES 32 +#define PCI_MAX_FUNCTION 8 +#define PCI_MAX_BRIDGE_NUMBER 0xFF +#define PCI_INVALID_VENDORID 0xFFFF + +/* PCI_COMMON_CONFIG.HeaderType */ +#define PCI_MULTIFUNCTION 0x80 +#define PCI_DEVICE_TYPE 0x00 +#define PCI_BRIDGE_TYPE 0x01 +#define PCI_CARDBUS_BRIDGE_TYPE 0x02 + +#define PCI_CONFIGURATION_TYPE(PciData) \ + (((PPCI_COMMON_CONFIG) (PciData))->HeaderType & ~PCI_MULTIFUNCTION) + +#define PCI_MULTIFUNCTION_DEVICE(PciData) \ + ((((PPCI_COMMON_CONFIG) (PciData))->HeaderType & PCI_MULTIFUNCTION) != 0) + +/* PCI_COMMON_CONFIG.Command */ +#define PCI_ENABLE_IO_SPACE 0x0001 +#define PCI_ENABLE_MEMORY_SPACE 0x0002 +#define PCI_ENABLE_BUS_MASTER 0x0004 +#define PCI_ENABLE_SPECIAL_CYCLES 0x0008 +#define PCI_ENABLE_WRITE_AND_INVALIDATE 0x0010 +#define PCI_ENABLE_VGA_COMPATIBLE_PALETTE 0x0020 +#define PCI_ENABLE_PARITY 0x0040 +#define PCI_ENABLE_WAIT_CYCLE 0x0080 +#define PCI_ENABLE_SERR 0x0100 +#define PCI_ENABLE_FAST_BACK_TO_BACK 0x0200 +#define PCI_DISABLE_LEVEL_INTERRUPT 0x0400 + +/* PCI_COMMON_CONFIG.Status */ +#define PCI_STATUS_INTERRUPT_PENDING 0x0008 +#define PCI_STATUS_CAPABILITIES_LIST 0x0010 +#define PCI_STATUS_66MHZ_CAPABLE 0x0020 +#define PCI_STATUS_UDF_SUPPORTED 0x0040 +#define PCI_STATUS_FAST_BACK_TO_BACK 0x0080 +#define PCI_STATUS_DATA_PARITY_DETECTED 0x0100 +#define PCI_STATUS_DEVSEL 0x0600 +#define PCI_STATUS_SIGNALED_TARGET_ABORT 0x0800 +#define PCI_STATUS_RECEIVED_TARGET_ABORT 0x1000 +#define PCI_STATUS_RECEIVED_MASTER_ABORT 0x2000 +#define PCI_STATUS_SIGNALED_SYSTEM_ERROR 0x4000 +#define PCI_STATUS_DETECTED_PARITY_ERROR 0x8000 + +/* IO_STACK_LOCATION.Parameters.ReadWriteControl.WhichSpace */ + +#define PCI_WHICHSPACE_CONFIG 0x0 +#define PCI_WHICHSPACE_ROM 0x52696350 /* 'PciR' */ + +#define PCI_CAPABILITY_ID_POWER_MANAGEMENT 0x01 +#define PCI_CAPABILITY_ID_AGP 0x02 +#define PCI_CAPABILITY_ID_VPD 0x03 +#define PCI_CAPABILITY_ID_SLOT_ID 0x04 +#define PCI_CAPABILITY_ID_MSI 0x05 +#define PCI_CAPABILITY_ID_CPCI_HOTSWAP 0x06 +#define PCI_CAPABILITY_ID_PCIX 0x07 +#define PCI_CAPABILITY_ID_HYPERTRANSPORT 0x08 +#define PCI_CAPABILITY_ID_VENDOR_SPECIFIC 0x09 +#define PCI_CAPABILITY_ID_DEBUG_PORT 0x0A +#define PCI_CAPABILITY_ID_CPCI_RES_CTRL 0x0B +#define PCI_CAPABILITY_ID_SHPC 0x0C +#define PCI_CAPABILITY_ID_P2P_SSID 0x0D +#define PCI_CAPABILITY_ID_AGP_TARGET 0x0E +#define PCI_CAPABILITY_ID_SECURE 0x0F +#define PCI_CAPABILITY_ID_PCI_EXPRESS 0x10 +#define PCI_CAPABILITY_ID_MSIX 0x11 + +typedef struct _PCI_CAPABILITIES_HEADER { + UCHAR CapabilityID; + UCHAR Next; +} PCI_CAPABILITIES_HEADER, *PPCI_CAPABILITIES_HEADER; + +typedef struct _PCI_PMC { + UCHAR Version:3; + UCHAR PMEClock:1; + UCHAR Rsvd1:1; + UCHAR DeviceSpecificInitialization:1; + UCHAR Rsvd2:2; + struct _PM_SUPPORT { + UCHAR Rsvd2:1; + UCHAR D1:1; + UCHAR D2:1; + UCHAR PMED0:1; + UCHAR PMED1:1; + UCHAR PMED2:1; + UCHAR PMED3Hot:1; + UCHAR PMED3Cold:1; + } Support; +} PCI_PMC, *PPCI_PMC; + +typedef struct _PCI_PMCSR { + USHORT PowerState:2; + USHORT Rsvd1:6; + USHORT PMEEnable:1; + USHORT DataSelect:4; + USHORT DataScale:2; + USHORT PMEStatus:1; +} PCI_PMCSR, *PPCI_PMCSR; + +typedef struct _PCI_PMCSR_BSE { + UCHAR Rsvd1:6; + UCHAR D3HotSupportsStopClock:1; + UCHAR BusPowerClockControlEnabled:1; +} PCI_PMCSR_BSE, *PPCI_PMCSR_BSE; + +typedef struct _PCI_PM_CAPABILITY { + PCI_CAPABILITIES_HEADER Header; + union { + PCI_PMC Capabilities; + USHORT AsUSHORT; + } PMC; + union { + PCI_PMCSR ControlStatus; + USHORT AsUSHORT; + } PMCSR; + union { + PCI_PMCSR_BSE BridgeSupport; + UCHAR AsUCHAR; + } PMCSR_BSE; + UCHAR Data; +} PCI_PM_CAPABILITY, *PPCI_PM_CAPABILITY; + +typedef struct { + PCI_CAPABILITIES_HEADER Header; + union { + struct { + USHORT DataParityErrorRecoveryEnable:1; + USHORT EnableRelaxedOrdering:1; + USHORT MaxMemoryReadByteCount:2; + USHORT MaxOutstandingSplitTransactions:3; + USHORT Reserved:9; + } bits; + USHORT AsUSHORT; + } Command; + union { + struct { + ULONG FunctionNumber:3; + ULONG DeviceNumber:5; + ULONG BusNumber:8; + ULONG Device64Bit:1; + ULONG Capable133MHz:1; + ULONG SplitCompletionDiscarded:1; + ULONG UnexpectedSplitCompletion:1; + ULONG DeviceComplexity:1; + ULONG DesignedMaxMemoryReadByteCount:2; + ULONG DesignedMaxOutstandingSplitTransactions:3; + ULONG DesignedMaxCumulativeReadSize:3; + ULONG ReceivedSplitCompletionErrorMessage:1; + ULONG CapablePCIX266:1; + ULONG CapablePCIX533:1; + } bits; + ULONG AsULONG; + } Status; +} PCI_X_CAPABILITY, *PPCI_X_CAPABILITY; + +#define PCI_EXPRESS_ADVANCED_ERROR_REPORTING_CAP_ID 0x0001 +#define PCI_EXPRESS_VIRTUAL_CHANNEL_CAP_ID 0x0002 +#define PCI_EXPRESS_DEVICE_SERIAL_NUMBER_CAP_ID 0x0003 +#define PCI_EXPRESS_POWER_BUDGETING_CAP_ID 0x0004 +#define PCI_EXPRESS_RC_LINK_DECLARATION_CAP_ID 0x0005 +#define PCI_EXPRESS_RC_INTERNAL_LINK_CONTROL_CAP_ID 0x0006 +#define PCI_EXPRESS_RC_EVENT_COLLECTOR_ENDPOINT_ASSOCIATION_CAP_ID 0x0007 +#define PCI_EXPRESS_MFVC_CAP_ID 0x0008 +#define PCI_EXPRESS_VC_AND_MFVC_CAP_ID 0x0009 +#define PCI_EXPRESS_RCRB_HEADER_CAP_ID 0x000A +#define PCI_EXPRESS_SINGLE_ROOT_IO_VIRTUALIZATION_CAP_ID 0x0010 + +typedef struct _PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER { + USHORT CapabilityID; + USHORT Version:4; + USHORT Next:12; +} PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER, *PPCI_EXPRESS_ENHANCED_CAPABILITY_HEADER; + +typedef struct _PCI_EXPRESS_SERIAL_NUMBER_CAPABILITY { + PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Header; + ULONG LowSerialNumber; + ULONG HighSerialNumber; +} PCI_EXPRESS_SERIAL_NUMBER_CAPABILITY, *PPCI_EXPRESS_SERIAL_NUMBER_CAPABILITY; + +typedef union _PCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS { + struct { + ULONG Undefined:1; + ULONG Reserved1:3; + ULONG DataLinkProtocolError:1; + ULONG SurpriseDownError:1; + ULONG Reserved2:6; + ULONG PoisonedTLP:1; + ULONG FlowControlProtocolError:1; + ULONG CompletionTimeout:1; + ULONG CompleterAbort:1; + ULONG UnexpectedCompletion:1; + ULONG ReceiverOverflow:1; + ULONG MalformedTLP:1; + ULONG ECRCError:1; + ULONG UnsupportedRequestError:1; + ULONG Reserved3:11; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS, *PPCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS; + +typedef union _PCI_EXPRESS_UNCORRECTABLE_ERROR_MASK { + struct { + ULONG Undefined:1; + ULONG Reserved1:3; + ULONG DataLinkProtocolError:1; + ULONG SurpriseDownError:1; + ULONG Reserved2:6; + ULONG PoisonedTLP:1; + ULONG FlowControlProtocolError:1; + ULONG CompletionTimeout:1; + ULONG CompleterAbort:1; + ULONG UnexpectedCompletion:1; + ULONG ReceiverOverflow:1; + ULONG MalformedTLP:1; + ULONG ECRCError:1; + ULONG UnsupportedRequestError:1; + ULONG Reserved3:11; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_UNCORRECTABLE_ERROR_MASK, *PPCI_EXPRESS_UNCORRECTABLE_ERROR_MASK; + +typedef union _PCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY { + struct { + ULONG Undefined:1; + ULONG Reserved1:3; + ULONG DataLinkProtocolError:1; + ULONG SurpriseDownError:1; + ULONG Reserved2:6; + ULONG PoisonedTLP:1; + ULONG FlowControlProtocolError:1; + ULONG CompletionTimeout:1; + ULONG CompleterAbort:1; + ULONG UnexpectedCompletion:1; + ULONG ReceiverOverflow:1; + ULONG MalformedTLP:1; + ULONG ECRCError:1; + ULONG UnsupportedRequestError:1; + ULONG Reserved3:11; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY, *PPCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY; + +typedef union _PCI_EXPRESS_CORRECTABLE_ERROR_STATUS { + struct { + ULONG ReceiverError:1; + ULONG Reserved1:5; + ULONG BadTLP:1; + ULONG BadDLLP:1; + ULONG ReplayNumRollover:1; + ULONG Reserved2:3; + ULONG ReplayTimerTimeout:1; + ULONG AdvisoryNonFatalError:1; + ULONG Reserved3:18; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_CORRECTABLE_ERROR_STATUS, *PPCI_CORRECTABLE_ERROR_STATUS; + +typedef union _PCI_EXPRESS_CORRECTABLE_ERROR_MASK { + struct { + ULONG ReceiverError:1; + ULONG Reserved1:5; + ULONG BadTLP:1; + ULONG BadDLLP:1; + ULONG ReplayNumRollover:1; + ULONG Reserved2:3; + ULONG ReplayTimerTimeout:1; + ULONG AdvisoryNonFatalError:1; + ULONG Reserved3:18; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_CORRECTABLE_ERROR_MASK, *PPCI_CORRECTABLE_ERROR_MASK; + +typedef union _PCI_EXPRESS_AER_CAPABILITIES { + struct { + ULONG FirstErrorPointer:5; + ULONG ECRCGenerationCapable:1; + ULONG ECRCGenerationEnable:1; + ULONG ECRCCheckCapable:1; + ULONG ECRCCheckEnable:1; + ULONG Reserved:23; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_AER_CAPABILITIES, *PPCI_EXPRESS_AER_CAPABILITIES; + +typedef union _PCI_EXPRESS_ROOT_ERROR_COMMAND { + struct { + ULONG CorrectableErrorReportingEnable:1; + ULONG NonFatalErrorReportingEnable:1; + ULONG FatalErrorReportingEnable:1; + ULONG Reserved:29; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_ROOT_ERROR_COMMAND, *PPCI_EXPRESS_ROOT_ERROR_COMMAND; + +typedef union _PCI_EXPRESS_ROOT_ERROR_STATUS { + struct { + ULONG CorrectableErrorReceived:1; + ULONG MultipleCorrectableErrorsReceived:1; + ULONG UncorrectableErrorReceived:1; + ULONG MultipleUncorrectableErrorsReceived:1; + ULONG FirstUncorrectableFatal:1; + ULONG NonFatalErrorMessagesReceived:1; + ULONG FatalErrorMessagesReceived:1; + ULONG Reserved:20; + ULONG AdvancedErrorInterruptMessageNumber:5; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_ROOT_ERROR_STATUS, *PPCI_EXPRESS_ROOT_ERROR_STATUS; + +typedef union _PCI_EXPRESS_ERROR_SOURCE_ID { + struct { + USHORT CorrectableSourceIdFun:3; + USHORT CorrectableSourceIdDev:5; + USHORT CorrectableSourceIdBus:8; + USHORT UncorrectableSourceIdFun:3; + USHORT UncorrectableSourceIdDev:5; + USHORT UncorrectableSourceIdBus:8; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_ERROR_SOURCE_ID, *PPCI_EXPRESS_ERROR_SOURCE_ID; + +typedef union _PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_STATUS { + struct { + ULONG TargetAbortOnSplitCompletion:1; + ULONG MasterAbortOnSplitCompletion:1; + ULONG ReceivedTargetAbort:1; + ULONG ReceivedMasterAbort:1; + ULONG RsvdZ:1; + ULONG UnexpectedSplitCompletionError:1; + ULONG UncorrectableSplitCompletion:1; + ULONG UncorrectableDataError:1; + ULONG UncorrectableAttributeError:1; + ULONG UncorrectableAddressError:1; + ULONG DelayedTransactionDiscardTimerExpired:1; + ULONG PERRAsserted:1; + ULONG SERRAsserted:1; + ULONG InternalBridgeError:1; + ULONG Reserved:18; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_STATUS, *PPCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_STATUS; + +typedef union _PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_MASK { + struct { + ULONG TargetAbortOnSplitCompletion:1; + ULONG MasterAbortOnSplitCompletion:1; + ULONG ReceivedTargetAbort:1; + ULONG ReceivedMasterAbort:1; + ULONG RsvdZ:1; + ULONG UnexpectedSplitCompletionError:1; + ULONG UncorrectableSplitCompletion:1; + ULONG UncorrectableDataError:1; + ULONG UncorrectableAttributeError:1; + ULONG UncorrectableAddressError:1; + ULONG DelayedTransactionDiscardTimerExpired:1; + ULONG PERRAsserted:1; + ULONG SERRAsserted:1; + ULONG InternalBridgeError:1; + ULONG Reserved:18; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_MASK, *PPCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_MASK; + +typedef union _PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_SEVERITY { + struct { + ULONG TargetAbortOnSplitCompletion:1; + ULONG MasterAbortOnSplitCompletion:1; + ULONG ReceivedTargetAbort:1; + ULONG ReceivedMasterAbort:1; + ULONG RsvdZ:1; + ULONG UnexpectedSplitCompletionError:1; + ULONG UncorrectableSplitCompletion:1; + ULONG UncorrectableDataError:1; + ULONG UncorrectableAttributeError:1; + ULONG UncorrectableAddressError:1; + ULONG DelayedTransactionDiscardTimerExpired:1; + ULONG PERRAsserted:1; + ULONG SERRAsserted:1; + ULONG InternalBridgeError:1; + ULONG Reserved:18; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_SEVERITY, *PPCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_SEVERITY; + +typedef union _PCI_EXPRESS_SEC_AER_CAPABILITIES { + struct { + ULONG SecondaryUncorrectableFirstErrorPtr:5; + ULONG Reserved:27; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_SEC_AER_CAPABILITIES, *PPCI_EXPRESS_SEC_AER_CAPABILITIES; + +#define ROOT_CMD_ENABLE_CORRECTABLE_ERROR_REPORTING 0x00000001 +#define ROOT_CMD_ENABLE_NONFATAL_ERROR_REPORTING 0x00000002 +#define ROOT_CMD_ENABLE_FATAL_ERROR_REPORTING 0x00000004 + +#define ROOT_CMD_ERROR_REPORTING_ENABLE_MASK \ + (ROOT_CMD_ENABLE_FATAL_ERROR_REPORTING | \ + ROOT_CMD_ENABLE_NONFATAL_ERROR_REPORTING | \ + ROOT_CMD_ENABLE_CORRECTABLE_ERROR_REPORTING) + +typedef struct _PCI_EXPRESS_AER_CAPABILITY { + PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Header; + PCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS UncorrectableErrorStatus; + PCI_EXPRESS_UNCORRECTABLE_ERROR_MASK UncorrectableErrorMask; + PCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY UncorrectableErrorSeverity; + PCI_EXPRESS_CORRECTABLE_ERROR_STATUS CorrectableErrorStatus; + PCI_EXPRESS_CORRECTABLE_ERROR_MASK CorrectableErrorMask; + PCI_EXPRESS_AER_CAPABILITIES CapabilitiesAndControl; + ULONG HeaderLog[4]; + PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_STATUS SecUncorrectableErrorStatus; + PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_MASK SecUncorrectableErrorMask; + PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_SEVERITY SecUncorrectableErrorSeverity; + PCI_EXPRESS_SEC_AER_CAPABILITIES SecCapabilitiesAndControl; + ULONG SecHeaderLog[4]; +} PCI_EXPRESS_AER_CAPABILITY, *PPCI_EXPRESS_AER_CAPABILITY; + +typedef struct _PCI_EXPRESS_ROOTPORT_AER_CAPABILITY { + PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Header; + PCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS UncorrectableErrorStatus; + PCI_EXPRESS_UNCORRECTABLE_ERROR_MASK UncorrectableErrorMask; + PCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY UncorrectableErrorSeverity; + PCI_EXPRESS_CORRECTABLE_ERROR_STATUS CorrectableErrorStatus; + PCI_EXPRESS_CORRECTABLE_ERROR_MASK CorrectableErrorMask; + PCI_EXPRESS_AER_CAPABILITIES CapabilitiesAndControl; + ULONG HeaderLog[4]; + PCI_EXPRESS_ROOT_ERROR_COMMAND RootErrorCommand; + PCI_EXPRESS_ROOT_ERROR_STATUS RootErrorStatus; + PCI_EXPRESS_ERROR_SOURCE_ID ErrorSourceId; +} PCI_EXPRESS_ROOTPORT_AER_CAPABILITY, *PPCI_EXPRESS_ROOTPORT_AER_CAPABILITY; + +typedef struct _PCI_EXPRESS_BRIDGE_AER_CAPABILITY { + PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Header; + PCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS UncorrectableErrorStatus; + PCI_EXPRESS_UNCORRECTABLE_ERROR_MASK UncorrectableErrorMask; + PCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY UncorrectableErrorSeverity; + PCI_EXPRESS_CORRECTABLE_ERROR_STATUS CorrectableErrorStatus; + PCI_EXPRESS_CORRECTABLE_ERROR_MASK CorrectableErrorMask; + PCI_EXPRESS_AER_CAPABILITIES CapabilitiesAndControl; + ULONG HeaderLog[4]; + PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_STATUS SecUncorrectableErrorStatus; + PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_MASK SecUncorrectableErrorMask; + PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_SEVERITY SecUncorrectableErrorSeverity; + PCI_EXPRESS_SEC_AER_CAPABILITIES SecCapabilitiesAndControl; + ULONG SecHeaderLog[4]; +} PCI_EXPRESS_BRIDGE_AER_CAPABILITY, *PPCI_EXPRESS_BRIDGE_AER_CAPABILITY; + +typedef union _PCI_EXPRESS_SRIOV_CAPS { + struct { + ULONG VFMigrationCapable:1; + ULONG Reserved1:20; + ULONG VFMigrationInterruptNumber:11; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_SRIOV_CAPS, *PPCI_EXPRESS_SRIOV_CAPS; + +typedef union _PCI_EXPRESS_SRIOV_CONTROL { + struct { + USHORT VFEnable:1; + USHORT VFMigrationEnable:1; + USHORT VFMigrationInterruptEnable:1; + USHORT VFMemorySpaceEnable:1; + USHORT ARICapableHierarchy:1; + USHORT Reserved1:11; + } DUMMYSTRUCTNAME; + USHORT AsUSHORT; +} PCI_EXPRESS_SRIOV_CONTROL, *PPCI_EXPRESS_SRIOV_CONTROL; + +typedef union _PCI_EXPRESS_SRIOV_STATUS { + struct { + USHORT VFMigrationStatus:1; + USHORT Reserved1:15; + } DUMMYSTRUCTNAME; + USHORT AsUSHORT; +} PCI_EXPRESS_SRIOV_STATUS, *PPCI_EXPRESS_SRIOV_STATUS; + +typedef union _PCI_EXPRESS_SRIOV_MIGRATION_STATE_ARRAY { + struct { + ULONG VFMigrationStateBIR:3; + ULONG VFMigrationStateOffset:29; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_SRIOV_MIGRATION_STATE_ARRAY, *PPCI_EXPRESS_SRIOV_MIGRATION_STATE_ARRAY; + +typedef struct _PCI_EXPRESS_SRIOV_CAPABILITY { + PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Header; + PCI_EXPRESS_SRIOV_CAPS SRIOVCapabilities; + PCI_EXPRESS_SRIOV_CONTROL SRIOVControl; + PCI_EXPRESS_SRIOV_STATUS SRIOVStatus; + USHORT InitialVFs; + USHORT TotalVFs; + USHORT NumVFs; + UCHAR FunctionDependencyLink; + UCHAR RsvdP1; + USHORT FirstVFOffset; + USHORT VFStride; + USHORT RsvdP2; + USHORT VFDeviceId; + ULONG SupportedPageSizes; + ULONG SystemPageSize; + ULONG BaseAddresses[PCI_TYPE0_ADDRESSES]; + PCI_EXPRESS_SRIOV_MIGRATION_STATE_ARRAY VFMigrationStateArrayOffset; +} PCI_EXPRESS_SRIOV_CAPABILITY, *PPCI_EXPRESS_SRIOV_CAPABILITY; + +/* PCI device classes */ +#define PCI_CLASS_PRE_20 0x00 +#define PCI_CLASS_MASS_STORAGE_CTLR 0x01 +#define PCI_CLASS_NETWORK_CTLR 0x02 +#define PCI_CLASS_DISPLAY_CTLR 0x03 +#define PCI_CLASS_MULTIMEDIA_DEV 0x04 +#define PCI_CLASS_MEMORY_CTLR 0x05 +#define PCI_CLASS_BRIDGE_DEV 0x06 +#define PCI_CLASS_SIMPLE_COMMS_CTLR 0x07 +#define PCI_CLASS_BASE_SYSTEM_DEV 0x08 +#define PCI_CLASS_INPUT_DEV 0x09 +#define PCI_CLASS_DOCKING_STATION 0x0a +#define PCI_CLASS_PROCESSOR 0x0b +#define PCI_CLASS_SERIAL_BUS_CTLR 0x0c +#define PCI_CLASS_WIRELESS_CTLR 0x0d +#define PCI_CLASS_INTELLIGENT_IO_CTLR 0x0e +#define PCI_CLASS_SATELLITE_COMMS_CTLR 0x0f +#define PCI_CLASS_ENCRYPTION_DECRYPTION 0x10 +#define PCI_CLASS_DATA_ACQ_SIGNAL_PROC 0x11 +#define PCI_CLASS_NOT_DEFINED 0xff + +/* PCI device subclasses for class 0 */ +#define PCI_SUBCLASS_PRE_20_NON_VGA 0x00 +#define PCI_SUBCLASS_PRE_20_VGA 0x01 + +/* PCI device subclasses for class 1 (mass storage controllers)*/ +#define PCI_SUBCLASS_MSC_SCSI_BUS_CTLR 0x00 +#define PCI_SUBCLASS_MSC_IDE_CTLR 0x01 +#define PCI_SUBCLASS_MSC_FLOPPY_CTLR 0x02 +#define PCI_SUBCLASS_MSC_IPI_CTLR 0x03 +#define PCI_SUBCLASS_MSC_RAID_CTLR 0x04 +#define PCI_SUBCLASS_MSC_OTHER 0x80 + +/* PCI device subclasses for class 2 (network controllers)*/ +#define PCI_SUBCLASS_NET_ETHERNET_CTLR 0x00 +#define PCI_SUBCLASS_NET_TOKEN_RING_CTLR 0x01 +#define PCI_SUBCLASS_NET_FDDI_CTLR 0x02 +#define PCI_SUBCLASS_NET_ATM_CTLR 0x03 +#define PCI_SUBCLASS_NET_ISDN_CTLR 0x04 +#define PCI_SUBCLASS_NET_OTHER 0x80 + +/* PCI device subclasses for class 3 (display controllers)*/ +#define PCI_SUBCLASS_VID_VGA_CTLR 0x00 +#define PCI_SUBCLASS_VID_XGA_CTLR 0x01 +#define PCI_SUBCLASS_VID_3D_CTLR 0x02 +#define PCI_SUBCLASS_VID_OTHER 0x80 + +/* PCI device subclasses for class 4 (multimedia device)*/ +#define PCI_SUBCLASS_MM_VIDEO_DEV 0x00 +#define PCI_SUBCLASS_MM_AUDIO_DEV 0x01 +#define PCI_SUBCLASS_MM_TELEPHONY_DEV 0x02 +#define PCI_SUBCLASS_MM_OTHER 0x80 + +/* PCI device subclasses for class 5 (memory controller)*/ +#define PCI_SUBCLASS_MEM_RAM 0x00 +#define PCI_SUBCLASS_MEM_FLASH 0x01 +#define PCI_SUBCLASS_MEM_OTHER 0x80 + +/* PCI device subclasses for class 6 (bridge device)*/ +#define PCI_SUBCLASS_BR_HOST 0x00 +#define PCI_SUBCLASS_BR_ISA 0x01 +#define PCI_SUBCLASS_BR_EISA 0x02 +#define PCI_SUBCLASS_BR_MCA 0x03 +#define PCI_SUBCLASS_BR_PCI_TO_PCI 0x04 +#define PCI_SUBCLASS_BR_PCMCIA 0x05 +#define PCI_SUBCLASS_BR_NUBUS 0x06 +#define PCI_SUBCLASS_BR_CARDBUS 0x07 +#define PCI_SUBCLASS_BR_RACEWAY 0x08 +#define PCI_SUBCLASS_BR_OTHER 0x80 + +#define PCI_SUBCLASS_COM_SERIAL 0x00 +#define PCI_SUBCLASS_COM_PARALLEL 0x01 +#define PCI_SUBCLASS_COM_MULTIPORT 0x02 +#define PCI_SUBCLASS_COM_MODEM 0x03 +#define PCI_SUBCLASS_COM_OTHER 0x80 + +#define PCI_SUBCLASS_SYS_INTERRUPT_CTLR 0x00 +#define PCI_SUBCLASS_SYS_DMA_CTLR 0x01 +#define PCI_SUBCLASS_SYS_SYSTEM_TIMER 0x02 +#define PCI_SUBCLASS_SYS_REAL_TIME_CLOCK 0x03 +#define PCI_SUBCLASS_SYS_GEN_HOTPLUG_CTLR 0x04 +#define PCI_SUBCLASS_SYS_SDIO_CTRL 0x05 +#define PCI_SUBCLASS_SYS_OTHER 0x80 + +#define PCI_SUBCLASS_INP_KEYBOARD 0x00 +#define PCI_SUBCLASS_INP_DIGITIZER 0x01 +#define PCI_SUBCLASS_INP_MOUSE 0x02 +#define PCI_SUBCLASS_INP_SCANNER 0x03 +#define PCI_SUBCLASS_INP_GAMEPORT 0x04 +#define PCI_SUBCLASS_INP_OTHER 0x80 + +#define PCI_SUBCLASS_DOC_GENERIC 0x00 +#define PCI_SUBCLASS_DOC_OTHER 0x80 + +#define PCI_SUBCLASS_PROC_386 0x00 +#define PCI_SUBCLASS_PROC_486 0x01 +#define PCI_SUBCLASS_PROC_PENTIUM 0x02 +#define PCI_SUBCLASS_PROC_ALPHA 0x10 +#define PCI_SUBCLASS_PROC_POWERPC 0x20 +#define PCI_SUBCLASS_PROC_COPROCESSOR 0x40 + +/* PCI device subclasses for class C (serial bus controller)*/ +#define PCI_SUBCLASS_SB_IEEE1394 0x00 +#define PCI_SUBCLASS_SB_ACCESS 0x01 +#define PCI_SUBCLASS_SB_SSA 0x02 +#define PCI_SUBCLASS_SB_USB 0x03 +#define PCI_SUBCLASS_SB_FIBRE_CHANNEL 0x04 +#define PCI_SUBCLASS_SB_SMBUS 0x05 + +#define PCI_SUBCLASS_WIRELESS_IRDA 0x00 +#define PCI_SUBCLASS_WIRELESS_CON_IR 0x01 +#define PCI_SUBCLASS_WIRELESS_RF 0x10 +#define PCI_SUBCLASS_WIRELESS_OTHER 0x80 + +#define PCI_SUBCLASS_INTIO_I2O 0x00 + +#define PCI_SUBCLASS_SAT_TV 0x01 +#define PCI_SUBCLASS_SAT_AUDIO 0x02 +#define PCI_SUBCLASS_SAT_VOICE 0x03 +#define PCI_SUBCLASS_SAT_DATA 0x04 + +#define PCI_SUBCLASS_CRYPTO_NET_COMP 0x00 +#define PCI_SUBCLASS_CRYPTO_ENTERTAINMENT 0x10 +#define PCI_SUBCLASS_CRYPTO_OTHER 0x80 + +#define PCI_SUBCLASS_DASP_DPIO 0x00 +#define PCI_SUBCLASS_DASP_OTHER 0x80 + +#define PCI_ADDRESS_IO_SPACE 0x00000001 +#define PCI_ADDRESS_MEMORY_TYPE_MASK 0x00000006 +#define PCI_ADDRESS_MEMORY_PREFETCHABLE 0x00000008 +#define PCI_ADDRESS_IO_ADDRESS_MASK 0xfffffffc +#define PCI_ADDRESS_MEMORY_ADDRESS_MASK 0xfffffff0 +#define PCI_ADDRESS_ROM_ADDRESS_MASK 0xfffff800 + +#define PCI_TYPE_32BIT 0 +#define PCI_TYPE_20BIT 2 +#define PCI_TYPE_64BIT 4 + +#define PCI_ROMADDRESS_ENABLED 0x00000001 + +#endif /* _PCI_X_ */ + +#define PCI_EXPRESS_LINK_QUIESCENT_INTERFACE_VERSION 1 + +typedef NTSTATUS +(NTAPI PCI_EXPRESS_ENTER_LINK_QUIESCENT_MODE)( + IN OUT PVOID Context); +typedef PCI_EXPRESS_ENTER_LINK_QUIESCENT_MODE *PPCI_EXPRESS_ENTER_LINK_QUIESCENT_MODE; + +typedef NTSTATUS +(NTAPI PCI_EXPRESS_EXIT_LINK_QUIESCENT_MODE)( + IN OUT PVOID Context); +typedef PCI_EXPRESS_EXIT_LINK_QUIESCENT_MODE *PPCI_EXPRESS_EXIT_LINK_QUIESCENT_MODE; + +typedef struct _PCI_EXPRESS_LINK_QUIESCENT_INTERFACE { + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; + PPCI_EXPRESS_ENTER_LINK_QUIESCENT_MODE PciExpressEnterLinkQuiescentMode; + PPCI_EXPRESS_EXIT_LINK_QUIESCENT_MODE PciExpressExitLinkQuiescentMode; +} PCI_EXPRESS_LINK_QUIESCENT_INTERFACE, *PPCI_EXPRESS_LINK_QUIESCENT_INTERFACE; + +#define PCI_EXPRESS_ROOT_PORT_INTERFACE_VERSION 1 + +typedef ULONG +(NTAPI *PPCI_EXPRESS_ROOT_PORT_READ_CONFIG_SPACE)( + IN PVOID Context, + OUT PVOID Buffer, + IN ULONG Offset, + IN ULONG Length); + +typedef ULONG +(NTAPI *PPCI_EXPRESS_ROOT_PORT_WRITE_CONFIG_SPACE)( + IN PVOID Context, + IN PVOID Buffer, + IN ULONG Offset, + IN ULONG Length); + +typedef struct _PCI_EXPRESS_ROOT_PORT_INTERFACE { + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; + PPCI_EXPRESS_ROOT_PORT_READ_CONFIG_SPACE ReadConfigSpace; + PPCI_EXPRESS_ROOT_PORT_WRITE_CONFIG_SPACE WriteConfigSpace; +} PCI_EXPRESS_ROOT_PORT_INTERFACE, *PPCI_EXPRESS_ROOT_PORT_INTERFACE; + +#define PCI_MSIX_TABLE_CONFIG_INTERFACE_VERSION 1 + +typedef NTSTATUS +(NTAPI PCI_MSIX_SET_ENTRY)( + IN PVOID Context, + IN ULONG TableEntry, + IN ULONG MessageNumber); +typedef PCI_MSIX_SET_ENTRY *PPCI_MSIX_SET_ENTRY; + +typedef NTSTATUS +(NTAPI PCI_MSIX_MASKUNMASK_ENTRY)( + IN PVOID Context, + IN ULONG TableEntry); +typedef PCI_MSIX_MASKUNMASK_ENTRY *PPCI_MSIX_MASKUNMASK_ENTRY; + +typedef NTSTATUS +(NTAPI PCI_MSIX_GET_ENTRY)( + IN PVOID Context, + IN ULONG TableEntry, + OUT PULONG MessageNumber, + OUT PBOOLEAN Masked); +typedef PCI_MSIX_GET_ENTRY *PPCI_MSIX_GET_ENTRY; + +typedef NTSTATUS +(NTAPI PCI_MSIX_GET_TABLE_SIZE)( + IN PVOID Context, + OUT PULONG TableSize); +typedef PCI_MSIX_GET_TABLE_SIZE *PPCI_MSIX_GET_TABLE_SIZE; + +typedef struct _PCI_MSIX_TABLE_CONFIG_INTERFACE { + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; + PPCI_MSIX_SET_ENTRY SetTableEntry; + PPCI_MSIX_MASKUNMASK_ENTRY MaskTableEntry; + PPCI_MSIX_MASKUNMASK_ENTRY UnmaskTableEntry; + PPCI_MSIX_GET_ENTRY GetTableEntry; + PPCI_MSIX_GET_TABLE_SIZE GetTableSize; +} PCI_MSIX_TABLE_CONFIG_INTERFACE, *PPCI_MSIX_TABLE_CONFIG_INTERFACE; + +#define PCI_MSIX_TABLE_CONFIG_MINIMUM_SIZE \ + RTL_SIZEOF_THROUGH_FIELD(PCI_MSIX_TABLE_CONFIG_INTERFACE, UnmaskTableEntry) + /****************************************************************************** * Object Manager Types * ******************************************************************************/ +#define MAXIMUM_FILENAME_LENGTH 256 +#define OBJ_NAME_PATH_SEPARATOR ((WCHAR)L'\\') + +#define OBJECT_TYPE_CREATE 0x0001 +#define OBJECT_TYPE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0x1) + +#define DIRECTORY_QUERY 0x0001 +#define DIRECTORY_TRAVERSE 0x0002 +#define DIRECTORY_CREATE_OBJECT 0x0004 +#define DIRECTORY_CREATE_SUBDIRECTORY 0x0008 +#define DIRECTORY_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0xF) + +#define SYMBOLIC_LINK_QUERY 0x0001 +#define SYMBOLIC_LINK_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0x1) + +#define DUPLICATE_CLOSE_SOURCE 0x00000001 +#define DUPLICATE_SAME_ACCESS 0x00000002 +#define DUPLICATE_SAME_ATTRIBUTES 0x00000004 + +#define OB_FLT_REGISTRATION_VERSION_0100 0x0100 +#define OB_FLT_REGISTRATION_VERSION OB_FLT_REGISTRATION_VERSION_0100 + +typedef ULONG OB_OPERATION; + +#define OB_OPERATION_HANDLE_CREATE 0x00000001 +#define OB_OPERATION_HANDLE_DUPLICATE 0x00000002 + +typedef struct _OB_PRE_CREATE_HANDLE_INFORMATION { + IN OUT ACCESS_MASK DesiredAccess; + IN ACCESS_MASK OriginalDesiredAccess; +} OB_PRE_CREATE_HANDLE_INFORMATION, *POB_PRE_CREATE_HANDLE_INFORMATION; + +typedef struct _OB_PRE_DUPLICATE_HANDLE_INFORMATION { + IN OUT ACCESS_MASK DesiredAccess; + IN ACCESS_MASK OriginalDesiredAccess; + IN PVOID SourceProcess; + IN PVOID TargetProcess; +} OB_PRE_DUPLICATE_HANDLE_INFORMATION, *POB_PRE_DUPLICATE_HANDLE_INFORMATION; + +typedef union _OB_PRE_OPERATION_PARAMETERS { + IN OUT OB_PRE_CREATE_HANDLE_INFORMATION CreateHandleInformation; + IN OUT OB_PRE_DUPLICATE_HANDLE_INFORMATION DuplicateHandleInformation; +} OB_PRE_OPERATION_PARAMETERS, *POB_PRE_OPERATION_PARAMETERS; + +typedef struct _OB_PRE_OPERATION_INFORMATION { + IN OB_OPERATION Operation; + union { + IN ULONG Flags; + struct { + IN ULONG KernelHandle:1; + IN ULONG Reserved:31; + }; + }; + IN PVOID Object; + IN POBJECT_TYPE ObjectType; + OUT PVOID CallContext; + IN POB_PRE_OPERATION_PARAMETERS Parameters; +} OB_PRE_OPERATION_INFORMATION, *POB_PRE_OPERATION_INFORMATION; + +typedef struct _OB_POST_CREATE_HANDLE_INFORMATION { + IN ACCESS_MASK GrantedAccess; +} OB_POST_CREATE_HANDLE_INFORMATION, *POB_POST_CREATE_HANDLE_INFORMATION; + +typedef struct _OB_POST_DUPLICATE_HANDLE_INFORMATION { + IN ACCESS_MASK GrantedAccess; +} OB_POST_DUPLICATE_HANDLE_INFORMATION, *POB_POST_DUPLICATE_HANDLE_INFORMATION; + +typedef union _OB_POST_OPERATION_PARAMETERS { + IN OB_POST_CREATE_HANDLE_INFORMATION CreateHandleInformation; + IN OB_POST_DUPLICATE_HANDLE_INFORMATION DuplicateHandleInformation; +} OB_POST_OPERATION_PARAMETERS, *POB_POST_OPERATION_PARAMETERS; + +typedef struct _OB_POST_OPERATION_INFORMATION { + IN OB_OPERATION Operation; + union { + IN ULONG Flags; + struct { + IN ULONG KernelHandle:1; + IN ULONG Reserved:31; + }; + }; + IN PVOID Object; + IN POBJECT_TYPE ObjectType; + IN PVOID CallContext; + IN NTSTATUS ReturnStatus; + IN POB_POST_OPERATION_PARAMETERS Parameters; +} OB_POST_OPERATION_INFORMATION,*POB_POST_OPERATION_INFORMATION; + +typedef enum _OB_PREOP_CALLBACK_STATUS { + OB_PREOP_SUCCESS +} OB_PREOP_CALLBACK_STATUS, *POB_PREOP_CALLBACK_STATUS; + +typedef OB_PREOP_CALLBACK_STATUS +(NTAPI *POB_PRE_OPERATION_CALLBACK)( + IN PVOID RegistrationContext, + IN OUT POB_PRE_OPERATION_INFORMATION OperationInformation); + +typedef VOID +(NTAPI *POB_POST_OPERATION_CALLBACK)( + IN PVOID RegistrationContext, + IN POB_POST_OPERATION_INFORMATION OperationInformation); + +typedef struct _OB_OPERATION_REGISTRATION { + IN POBJECT_TYPE *ObjectType; + IN OB_OPERATION Operations; + IN POB_PRE_OPERATION_CALLBACK PreOperation; + IN POB_POST_OPERATION_CALLBACK PostOperation; +} OB_OPERATION_REGISTRATION, *POB_OPERATION_REGISTRATION; + +typedef struct _OB_CALLBACK_REGISTRATION { + IN USHORT Version; + IN USHORT OperationRegistrationCount; + IN UNICODE_STRING Altitude; + IN PVOID RegistrationContext; + IN OB_OPERATION_REGISTRATION *OperationRegistration; +} OB_CALLBACK_REGISTRATION, *POB_CALLBACK_REGISTRATION; + typedef struct _OBJECT_NAME_INFORMATION { - UNICODE_STRING Name; + UNICODE_STRING Name; } OBJECT_NAME_INFORMATION, *POBJECT_NAME_INFORMATION; /* Exported object types */ +extern POBJECT_TYPE NTSYSAPI CmKeyObjectType; extern POBJECT_TYPE NTSYSAPI ExEventObjectType; extern POBJECT_TYPE NTSYSAPI ExSemaphoreObjectType; extern POBJECT_TYPE NTSYSAPI IoFileObjectType; @@ -5285,16 +7570,6 @@ extern POBJECT_TYPE NTSYSAPI PsProcessType; #define QUOTA_LIMITS_HARDWS_MAX_DISABLE 0x00000008 #define QUOTA_LIMITS_USE_DEFAULT_LIMITS 0x00000010 -/* Process Qoutas */ -typedef struct _QUOTA_LIMITS { - SIZE_T PagedPoolLimit; - SIZE_T NonPagedPoolLimit; - SIZE_T MinimumWorkingSetSize; - SIZE_T MaximumWorkingSetSize; - SIZE_T PagefileLimit; - LARGE_INTEGER TimeLimit; -} QUOTA_LIMITS, *PQUOTA_LIMITS; - /* Thread Access Rights */ #define THREAD_TERMINATE 0x0001 #define THREAD_SUSPEND_RESUME 0x0002 @@ -5319,18 +7594,76 @@ typedef struct _QUOTA_LIMITS { #define THREAD_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3FF) #endif -#define ES_SYSTEM_REQUIRED 0x00000001 -#define ES_DISPLAY_REQUIRED 0x00000002 -#define ES_USER_PRESENT 0x00000004 -#define ES_CONTINUOUS 0x80000000 - #define LOW_PRIORITY 0 #define LOW_REALTIME_PRIORITY 16 #define HIGH_PRIORITY 31 #define MAXIMUM_PRIORITY 32 -#ifdef _X86_ +/****************************************************************************** + * WMI Library Support Types * + ******************************************************************************/ + +#ifdef RUN_WPP +#include +#include +#endif + +#ifndef _TRACEHANDLE_DEFINED +#define _TRACEHANDLE_DEFINED +typedef ULONG64 TRACEHANDLE, *PTRACEHANDLE; +#endif + +#ifndef TRACE_INFORMATION_CLASS_DEFINE + +typedef struct _ETW_TRACE_SESSION_SETTINGS { + ULONG Version; + ULONG BufferSize; + ULONG MinimumBuffers; + ULONG MaximumBuffers; + ULONG LoggerMode; + ULONG FlushTimer; + ULONG FlushThreshold; + ULONG ClockType; +} ETW_TRACE_SESSION_SETTINGS, *PETW_TRACE_SESSION_SETTINGS; + +typedef enum _TRACE_INFORMATION_CLASS { + TraceIdClass, + TraceHandleClass, + TraceEnableFlagsClass, + TraceEnableLevelClass, + GlobalLoggerHandleClass, + EventLoggerHandleClass, + AllLoggerHandlesClass, + TraceHandleByNameClass, + LoggerEventsLostClass, + TraceSessionSettingsClass, + LoggerEventsLoggedClass, + MaxTraceInformationClass +} TRACE_INFORMATION_CLASS; + +#endif /* TRACE_INFORMATION_CLASS_DEFINE */ + +#ifndef _ETW_KM_ +#define _ETW_KM_ +#endif + +#include + +typedef VOID +(NTAPI *PETWENABLECALLBACK)( + IN LPCGUID SourceId, + IN ULONG ControlCode, + IN UCHAR Level, + IN ULONGLONG MatchAnyKeyword, + IN ULONGLONG MatchAllKeyword, + IN PEVENT_FILTER_DESCRIPTOR FilterData OPTIONAL, + IN OUT PVOID CallbackContext OPTIONAL); + +#define EVENT_WRITE_FLAG_NO_FAULTING 0x00000001 + + +#if defined(_M_IX86) /** Kernel definitions for x86 **/ /* Interrupt request levels */ @@ -5345,11 +7678,11 @@ typedef struct _QUOTA_LIMITS { #define IPI_LEVEL 29 #define POWER_LEVEL 30 #define HIGH_LEVEL 31 -#define CLOCK_LEVEL (CLOCK2_LEVEL) +#define CLOCK_LEVEL CLOCK2_LEVEL -#define KIP0PCRADDRESS 0xffdff000 +#define KIP0PCRADDRESS 0xffdff000 #define KI_USER_SHARED_DATA 0xffdf0000 -#define SharedUserData ((KUSER_SHARED_DATA * CONST) KI_USER_SHARED_DATA) +#define SharedUserData ((KUSER_SHARED_DATA * CONST)KI_USER_SHARED_DATA) #define PAGE_SIZE 0x1000 #define PAGE_SHIFT 12L @@ -5365,14 +7698,14 @@ typedef struct _QUOTA_LIMITS { typedef struct _KFLOATING_SAVE { - ULONG ControlWord; - ULONG StatusWord; - ULONG ErrorOffset; - ULONG ErrorSelector; - ULONG DataOffset; - ULONG DataSelector; - ULONG Cr0NpxState; - ULONG Spare1; + ULONG ControlWord; + ULONG StatusWord; + ULONG ErrorOffset; + ULONG ErrorSelector; + ULONG DataOffset; + ULONG DataSelector; + ULONG Cr0NpxState; + ULONG Spare1; } KFLOATING_SAVE, *PKFLOATING_SAVE; extern NTKERNELAPI volatile KSYSTEM_TIME KeTickCount; @@ -5381,8 +7714,7 @@ extern NTKERNELAPI volatile KSYSTEM_TIME KeTickCount; FORCEINLINE VOID -KeMemoryBarrier( - VOID) +KeMemoryBarrier(VOID) { volatile LONG Barrier; #if defined(__GNUC__) @@ -5392,78 +7724,80 @@ KeMemoryBarrier( #endif } +NTHALAPI +KIRQL +NTAPI +KeGetCurrentIrql(VOID); + NTHALAPI VOID FASTCALL KfLowerIrql( - IN KIRQL NewIrql); + IN KIRQL NewIrql); #define KeLowerIrql(a) KfLowerIrql(a) NTHALAPI KIRQL FASTCALL KfRaiseIrql( - IN KIRQL NewIrql); + IN KIRQL NewIrql); #define KeRaiseIrql(a,b) *(b) = KfRaiseIrql(a) NTHALAPI KIRQL -DDKAPI -KeRaiseIrqlToDpcLevel( - VOID); +NTAPI +KeRaiseIrqlToDpcLevel(VOID); NTHALAPI KIRQL -DDKAPI -KeRaiseIrqlToSynchLevel( - VOID); +NTAPI +KeRaiseIrqlToSynchLevel(VOID); NTHALAPI KIRQL FASTCALL KfAcquireSpinLock( - IN PKSPIN_LOCK SpinLock); -#define KeAcquireSpinLock(a,b) *(b) = KfAcquireSpinLock(a) + IN OUT PKSPIN_LOCK SpinLock); +#define KeAcquireSpinLock(a,b) *(b) = KfAcquireSpinLock(a) NTHALAPI VOID FASTCALL KfReleaseSpinLock( - IN PKSPIN_LOCK SpinLock, + IN OUT PKSPIN_LOCK SpinLock, IN KIRQL NewIrql); -#define KeReleaseSpinLock(a,b) KfReleaseSpinLock(a,b) +#define KeReleaseSpinLock(a,b) KfReleaseSpinLock(a,b) NTKERNELAPI VOID FASTCALL KefAcquireSpinLockAtDpcLevel( - IN PKSPIN_LOCK SpinLock); + IN OUT PKSPIN_LOCK SpinLock); #define KeAcquireSpinLockAtDpcLevel(SpinLock) KefAcquireSpinLockAtDpcLevel(SpinLock) NTKERNELAPI VOID FASTCALL KefReleaseSpinLockFromDpcLevel( - IN PKSPIN_LOCK SpinLock); + IN OUT PKSPIN_LOCK SpinLock); #define KeReleaseSpinLockFromDpcLevel(SpinLock) KefReleaseSpinLockFromDpcLevel(SpinLock) NTSYSAPI PKTHREAD NTAPI -KeGetCurrentThread( - VOID); +KeGetCurrentThread(VOID); NTKERNELAPI NTSTATUS NTAPI KeSaveFloatingPointState( - OUT PKFLOATING_SAVE FloatSave); + OUT PKFLOATING_SAVE FloatSave); NTKERNELAPI NTSTATUS NTAPI KeRestoreFloatingPointState( - IN PKFLOATING_SAVE FloatSave); + IN PKFLOATING_SAVE FloatSave); /* VOID * KeFlushIoBuffers( @@ -5481,24 +7815,355 @@ VOID _KeQueryTickCount( OUT PLARGE_INTEGER CurrentCount) { - for (;;) - { - CurrentCount->HighPart = KeTickCount.High1Time; - CurrentCount->LowPart = KeTickCount.LowPart; - if (CurrentCount->HighPart == KeTickCount.High2Time) break; - YieldProcessor(); - } + for (;;) { + CurrentCount->HighPart = KeTickCount.High1Time; + CurrentCount->LowPart = KeTickCount.LowPart; + if (CurrentCount->HighPart == KeTickCount.High2Time) break; + YieldProcessor(); + } } #define KeQueryTickCount(CurrentCount) _KeQueryTickCount(CurrentCount) -#endif /* _X86_ */ + +#elif defined(_M_AMD64) +/** Kernel definitions for AMD64 **/ + +/* Interrupt request levels */ +#define PASSIVE_LEVEL 0 +#define LOW_LEVEL 0 +#define APC_LEVEL 1 +#define DISPATCH_LEVEL 2 +#define CMCI_LEVEL 5 +#define CLOCK_LEVEL 13 +#define IPI_LEVEL 14 +#define DRS_LEVEL 14 +#define POWER_LEVEL 14 +#define PROFILE_LEVEL 15 +#define HIGH_LEVEL 15 + +#define KI_USER_SHARED_DATA 0xFFFFF78000000000ULL +#define SharedUserData ((PKUSER_SHARED_DATA const)KI_USER_SHARED_DATA) +#define SharedInterruptTime (KI_USER_SHARED_DATA + 0x8) +#define SharedSystemTime (KI_USER_SHARED_DATA + 0x14) +#define SharedTickCount (KI_USER_SHARED_DATA + 0x320) + +#define PAGE_SIZE 0x1000 +#define PAGE_SHIFT 12L + +#define EFLAG_SIGN 0x8000 +#define EFLAG_ZERO 0x4000 +#define EFLAG_SELECT (EFLAG_SIGN | EFLAG_ZERO) + +#define RESULT_NEGATIVE ((EFLAG_SIGN & ~EFLAG_ZERO) & EFLAG_SELECT) +#define RESULT_ZERO ((~EFLAG_SIGN & EFLAG_ZERO) & EFLAG_SELECT) +#define RESULT_POSITIVE ((~EFLAG_SIGN & ~EFLAG_ZERO) & EFLAG_SELECT) + + +typedef struct _KFLOATING_SAVE { + ULONG Dummy; +} KFLOATING_SAVE, *PKFLOATING_SAVE; + +typedef XSAVE_FORMAT XMM_SAVE_AREA32, *PXMM_SAVE_AREA32; + +#define KeQueryInterruptTime() \ + (*(volatile ULONG64*)SharedInterruptTime) + +#define KeQuerySystemTime(CurrentCount) \ + *(ULONG64*)(CurrentCount) = *(volatile ULONG64*)SharedSystemTime + +#define KeQueryTickCount(CurrentCount) \ + *(ULONG64*)(CurrentCount) = *(volatile ULONG64*)SharedTickCount + +#define KeGetDcacheFillSize() 1L + +#define YieldProcessor _mm_pause + +FORCEINLINE +KIRQL +KeGetCurrentIrql(VOID) +{ + return (KIRQL)__readcr8(); +} + +FORCEINLINE +VOID +KeLowerIrql(IN KIRQL NewIrql) +{ + //ASSERT(KeGetCurrentIrql() >= NewIrql); + __writecr8(NewIrql); +} + +FORCEINLINE +KIRQL +KfRaiseIrql(IN KIRQL NewIrql) +{ + KIRQL OldIrql; + + OldIrql = __readcr8(); + //ASSERT(OldIrql <= NewIrql); + __writecr8(NewIrql); + return OldIrql; +} +#define KeRaiseIrql(a,b) *(b) = KfRaiseIrql(a) + +FORCEINLINE +KIRQL +KeRaiseIrqlToDpcLevel(VOID) +{ + return KfRaiseIrql(DISPATCH_LEVEL); +} + +FORCEINLINE +KIRQL +KeRaiseIrqlToSynchLevel(VOID) +{ + return KfRaiseIrql(12); // SYNCH_LEVEL = IPI_LEVEL - 2 +} + +FORCEINLINE +PKTHREAD +KeGetCurrentThread(VOID) +{ + return (struct _KTHREAD *)__readgsqword(0x188); +} + +/* VOID + * KeFlushIoBuffers( + * IN PMDL Mdl, + * IN BOOLEAN ReadOperation, + * IN BOOLEAN DmaOperation) + */ +#define KeFlushIoBuffers(_Mdl, _ReadOperation, _DmaOperation) + +/* x86 and x64 performs a 0x2C interrupt */ +#define DbgRaiseAssertionFailure __int2c + +#elif defined(_M_IA64) +/** Kernel definitions for IA64 **/ + +/* Interrupt request levels */ +#define PASSIVE_LEVEL 0 +#define LOW_LEVEL 0 +#define APC_LEVEL 1 +#define DISPATCH_LEVEL 2 +#define CMC_LEVEL 3 +#define DEVICE_LEVEL_BASE 4 +#define PC_LEVEL 12 +#define IPI_LEVEL 14 +#define DRS_LEVEL 14 +#define CLOCK_LEVEL 13 +#define POWER_LEVEL 15 +#define PROFILE_LEVEL 15 +#define HIGH_LEVEL 15 + +#define KI_USER_SHARED_DATA ((ULONG_PTR)(KADDRESS_BASE + 0xFFFE0000)) +extern volatile LARGE_INTEGER KeTickCount; + +#define PAUSE_PROCESSOR __yield(); + +FORCEINLINE +VOID +KeFlushWriteBuffer(VOID) +{ + __mf (); + return; +} + +NTSYSAPI +PKTHREAD +NTAPI +KeGetCurrentThread(VOID); + + +#elif defined(_M_PPC) + +/* Interrupt request levels */ +#define PASSIVE_LEVEL 0 +#define LOW_LEVEL 0 +#define APC_LEVEL 1 +#define DISPATCH_LEVEL 2 +#define PROFILE_LEVEL 27 +#define CLOCK1_LEVEL 28 +#define CLOCK2_LEVEL 28 +#define IPI_LEVEL 29 +#define POWER_LEVEL 30 +#define HIGH_LEVEL 31 + +// +// Used to contain PFNs and PFN counts +// +typedef ULONG PFN_COUNT; +typedef ULONG PFN_NUMBER, *PPFN_NUMBER; +typedef LONG SPFN_NUMBER, *PSPFN_NUMBER; + + +typedef struct _KFLOATING_SAVE { + ULONG Dummy; +} KFLOATING_SAVE, *PKFLOATING_SAVE; + +typedef struct _KPCR_TIB { + PVOID ExceptionList; /* 00 */ + PVOID StackBase; /* 04 */ + PVOID StackLimit; /* 08 */ + PVOID SubSystemTib; /* 0C */ + _ANONYMOUS_UNION union { + PVOID FiberData; /* 10 */ + ULONG Version; /* 10 */ + } DUMMYUNIONNAME; + PVOID ArbitraryUserPointer; /* 14 */ + struct _KPCR_TIB *Self; /* 18 */ +} KPCR_TIB, *PKPCR_TIB; /* 1C */ + +#define PCR_MINOR_VERSION 1 +#define PCR_MAJOR_VERSION 1 + +typedef struct _KPCR { + KPCR_TIB Tib; /* 00 */ + struct _KPCR *Self; /* 1C */ + struct _KPRCB *Prcb; /* 20 */ + KIRQL Irql; /* 24 */ + ULONG IRR; /* 28 */ + ULONG IrrActive; /* 2C */ + ULONG IDR; /* 30 */ + PVOID KdVersionBlock; /* 34 */ + PUSHORT IDT; /* 38 */ + PUSHORT GDT; /* 3C */ + struct _KTSS *TSS; /* 40 */ + USHORT MajorVersion; /* 44 */ + USHORT MinorVersion; /* 46 */ + KAFFINITY SetMember; /* 48 */ + ULONG StallScaleFactor; /* 4C */ + UCHAR SpareUnused; /* 50 */ + UCHAR Number; /* 51 */ +} KPCR, *PKPCR; /* 54 */ + +#define KeGetPcr() PCR + +#define YieldProcessor() __asm__ __volatile__("nop"); + +FORCEINLINE +ULONG +NTAPI +KeGetCurrentProcessorNumber(VOID) +{ + ULONG Number; + __asm__ __volatile__ ( + "lwz %0, %c1(12)\n" + : "=r" (Number) + : "i" (FIELD_OFFSET(KPCR, Number)) + ); + return Number; +} + +NTHALAPI +VOID +FASTCALL +KfLowerIrql( + IN KIRQL NewIrql); +#define KeLowerIrql(a) KfLowerIrql(a) + +NTHALAPI +KIRQL +FASTCALL +KfRaiseIrql( + IN KIRQL NewIrql); +#define KeRaiseIrql(a,b) *(b) = KfRaiseIrql(a) + +NTHALAPI +KIRQL +NTAPI +KeRaiseIrqlToDpcLevel(VOID); + +NTHALAPI +KIRQL +NTAPI +KeRaiseIrqlToSynchLevel(VOID); + + + +#elif defined(_M_MIPS) +#error MIPS Headers are totally incorrect + +// +// Used to contain PFNs and PFN counts +// +typedef ULONG PFN_COUNT; +typedef ULONG PFN_NUMBER, *PPFN_NUMBER; +typedef LONG SPFN_NUMBER, *PSPFN_NUMBER; + +#define PASSIVE_LEVEL 0 +#define APC_LEVEL 1 +#define DISPATCH_LEVEL 2 +#define PROFILE_LEVEL 27 +#define IPI_LEVEL 29 +#define HIGH_LEVEL 31 + +typedef struct _KPCR { + struct _KPRCB *Prcb; /* 20 */ + KIRQL Irql; /* 24 */ + ULONG IRR; /* 28 */ + ULONG IDR; /* 30 */ +} KPCR, *PKPCR; + +#define KeGetPcr() PCR + +typedef struct _KFLOATING_SAVE { +} KFLOATING_SAVE, *PKFLOATING_SAVE; + +static __inline +ULONG +NTAPI +KeGetCurrentProcessorNumber(VOID) +{ + return 0; +} + +#define YieldProcessor() __asm__ __volatile__("nop"); + +#define KeLowerIrql(a) KfLowerIrql(a) +#define KeRaiseIrql(a,b) *(b) = KfRaiseIrql(a) + +NTKERNELAPI +VOID +NTAPI +KfLowerIrql( + IN KIRQL NewIrql); + +NTKERNELAPI +KIRQL +NTAPI +KfRaiseIrql( + IN KIRQL NewIrql); + +NTKERNELAPI +KIRQL +NTAPI +KeRaiseIrqlToDpcLevel(VOID); + +NTKERNELAPI +KIRQL +NTAPI +KeRaiseIrqlToSynchLevel(VOID); + + +#elif defined(_M_ARM) +#include +#else +#error Unknown Architecture +#endif + /****************************************************************************** * Runtime Library Functions * ******************************************************************************/ + +#if !defined(MIDL_PASS) && !defined(SORTPP_PASS) + +#define RTL_STATIC_LIST_HEAD(x) LIST_ENTRY x = { &x, &x } + FORCEINLINE VOID InitializeListHead( @@ -5507,11 +8172,78 @@ InitializeListHead( ListHead->Flink = ListHead->Blink = ListHead; } +BOOLEAN +FORCEINLINE +IsListEmpty( + IN CONST LIST_ENTRY * ListHead) +{ + return (BOOLEAN)(ListHead->Flink == ListHead); +} + +FORCEINLINE +BOOLEAN +RemoveEntryList( + IN PLIST_ENTRY Entry) +{ + PLIST_ENTRY OldFlink; + PLIST_ENTRY OldBlink; + + OldFlink = Entry->Flink; + OldBlink = Entry->Blink; + OldFlink->Blink = OldBlink; + OldBlink->Flink = OldFlink; + return (BOOLEAN)(OldFlink == OldBlink); +} + +FORCEINLINE +PLIST_ENTRY +RemoveHeadList( + IN OUT PLIST_ENTRY ListHead) +{ + PLIST_ENTRY Flink; + PLIST_ENTRY Entry; + + Entry = ListHead->Flink; + Flink = Entry->Flink; + ListHead->Flink = Flink; + Flink->Blink = ListHead; + return Entry; +} + +FORCEINLINE +PLIST_ENTRY +RemoveTailList( + IN OUT PLIST_ENTRY ListHead) +{ + PLIST_ENTRY Blink; + PLIST_ENTRY Entry; + + Entry = ListHead->Blink; + Blink = Entry->Blink; + ListHead->Blink = Blink; + Blink->Flink = ListHead; + return Entry; +} + +FORCEINLINE +VOID +InsertTailList( + IN OUT PLIST_ENTRY ListHead, + IN OUT PLIST_ENTRY Entry) +{ + PLIST_ENTRY OldBlink; + OldBlink = ListHead->Blink; + Entry->Flink = ListHead; + Entry->Blink = OldBlink; + OldBlink->Flink = Entry; + ListHead->Blink = Entry; +} + FORCEINLINE VOID InsertHeadList( - IN OUT PLIST_ENTRY ListHead, - IN OUT PLIST_ENTRY Entry) + IN OUT PLIST_ENTRY ListHead, + IN OUT PLIST_ENTRY Entry) { PLIST_ENTRY OldFlink; OldFlink = ListHead->Flink; @@ -5523,24 +8255,16 @@ InsertHeadList( FORCEINLINE VOID -InsertTailList( - IN OUT PLIST_ENTRY ListHead, - IN OUT PLIST_ENTRY Entry) +AppendTailList( + IN OUT PLIST_ENTRY ListHead, + IN OUT PLIST_ENTRY ListToAppend) { - PLIST_ENTRY OldBlink; - OldBlink = ListHead->Blink; - Entry->Flink = ListHead; - Entry->Blink = OldBlink; - OldBlink->Flink = Entry; - ListHead->Blink = Entry; -} + PLIST_ENTRY ListEnd = ListHead->Blink; -BOOLEAN -FORCEINLINE -IsListEmpty( - IN CONST LIST_ENTRY * ListHead) -{ - return (BOOLEAN)(ListHead->Flink == ListHead); + ListHead->Blink->Flink = ListToAppend; + ListHead->Blink = ListToAppend->Blink; + ListToAppend->Blink->Flink = ListHead; + ListToAppend->Blink = ListEnd; } FORCEINLINE @@ -5566,59 +8290,16 @@ PushEntryList( ListHead->Next = Entry; } -FORCEINLINE -BOOLEAN -RemoveEntryList( - IN PLIST_ENTRY Entry) -{ - PLIST_ENTRY OldFlink; - PLIST_ENTRY OldBlink; - - OldFlink = Entry->Flink; - OldBlink = Entry->Blink; - OldFlink->Blink = OldBlink; - OldBlink->Flink = OldFlink; - return (BOOLEAN)(OldFlink == OldBlink); -} - -FORCEINLINE -PLIST_ENTRY -RemoveHeadList( - IN OUT PLIST_ENTRY ListHead) -{ - PLIST_ENTRY Flink; - PLIST_ENTRY Entry; - - Entry = ListHead->Flink; - Flink = Entry->Flink; - ListHead->Flink = Flink; - Flink->Blink = ListHead; - return Entry; -} - -FORCEINLINE -PLIST_ENTRY -RemoveTailList( - IN OUT PLIST_ENTRY ListHead) -{ - PLIST_ENTRY Blink; - PLIST_ENTRY Entry; - - Entry = ListHead->Blink; - Blink = Entry->Blink; - ListHead->Blink = Blink; - Blink->Flink = ListHead; - return Entry; -} +#endif /* !defined(MIDL_PASS) && !defined(SORTPP_PASS) */ NTSYSAPI VOID NTAPI RtlAssert( - IN PVOID FailedAssertion, - IN PVOID FileName, - IN ULONG LineNumber, - IN PSTR Message); + IN PVOID FailedAssertion, + IN PVOID FileName, + IN ULONG LineNumber, + IN PSTR Message); /* VOID * RtlCopyMemory( @@ -5636,9 +8317,9 @@ NTSYSAPI VOID NTAPI RtlCopyMemoryNonTemporal( - VOID UNALIGNED *Destination, - CONST VOID UNALIGNED *Source, - SIZE_T Length); + VOID UNALIGNED *Destination, + CONST VOID UNALIGNED *Source, + SIZE_T Length); #else #define RtlCopyMemoryNonTemporal RtlCopyMemory #endif @@ -5675,21 +8356,21 @@ NTSYSAPI VOID NTAPI RtlFreeUnicodeString( - IN OUT PUNICODE_STRING UnicodeString); + IN OUT PUNICODE_STRING UnicodeString); NTSYSAPI NTSTATUS NTAPI RtlGUIDFromString( - IN PUNICODE_STRING GuidString, - OUT GUID *Guid); + IN PUNICODE_STRING GuidString, + OUT GUID *Guid); NTSYSAPI VOID NTAPI RtlInitUnicodeString( - IN OUT PUNICODE_STRING DestinationString, - IN PCWSTR SourceString OPTIONAL); + IN OUT PUNICODE_STRING DestinationString, + IN PCWSTR SourceString OPTIONAL); /* VOID * RtlMoveMemory( @@ -5704,8 +8385,8 @@ NTSYSAPI NTSTATUS NTAPI RtlStringFromGUID( - IN REFGUID Guid, - OUT PUNICODE_STRING GuidString); + IN REFGUID Guid, + OUT PUNICODE_STRING GuidString); /* VOID * RtlZeroMemory( @@ -5717,37 +8398,39 @@ RtlStringFromGUID( #define RtlZeroBytes RtlZeroMemory - #if (NTDDI_VERSION >= NTDDI_WIN2K) + + + NTSYSAPI BOOLEAN NTAPI RtlAreBitsClear( - IN PRTL_BITMAP BitMapHeader, - IN ULONG StartingIndex, - IN ULONG Length); + IN PRTL_BITMAP BitMapHeader, + IN ULONG StartingIndex, + IN ULONG Length); NTSYSAPI BOOLEAN NTAPI RtlAreBitsSet( - IN PRTL_BITMAP BitMapHeader, - IN ULONG StartingIndex, - IN ULONG Length); + IN PRTL_BITMAP BitMapHeader, + IN ULONG StartingIndex, + IN ULONG Length); NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString( - IN OUT PUNICODE_STRING DestinationString, - IN PANSI_STRING SourceString, - IN BOOLEAN AllocateDestinationString); + IN OUT PUNICODE_STRING DestinationString, + IN PANSI_STRING SourceString, + IN BOOLEAN AllocateDestinationString); NTSYSAPI ULONG NTAPI RtlxAnsiStringToUnicodeSize( - IN PCANSI_STRING AnsiString); + IN PCANSI_STRING AnsiString); #define RtlAnsiStringToUnicodeSize(String) ( \ NLS_MB_CODE_PAGE_TAG ? \ @@ -5759,107 +8442,107 @@ NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString( - IN OUT PUNICODE_STRING Destination, - IN PCUNICODE_STRING Source); + IN OUT PUNICODE_STRING Destination, + IN PCUNICODE_STRING Source); NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeToString( - IN OUT PUNICODE_STRING Destination, - IN PCWSTR Source); + IN OUT PUNICODE_STRING Destination, + IN PCWSTR Source); NTSYSAPI NTSTATUS NTAPI RtlCheckRegistryKey( - IN ULONG RelativeTo, - IN PWSTR Path); + IN ULONG RelativeTo, + IN PWSTR Path); NTSYSAPI VOID NTAPI RtlClearAllBits( - IN PRTL_BITMAP BitMapHeader); + IN PRTL_BITMAP BitMapHeader); NTSYSAPI VOID NTAPI RtlClearBits( - IN PRTL_BITMAP BitMapHeader, - IN ULONG StartingIndex, - IN ULONG NumberToClear); + IN PRTL_BITMAP BitMapHeader, + IN ULONG StartingIndex, + IN ULONG NumberToClear); NTSYSAPI SIZE_T NTAPI RtlCompareMemory( - IN CONST VOID *Source1, - IN CONST VOID *Source2, - IN SIZE_T Length); + IN CONST VOID *Source1, + IN CONST VOID *Source2, + IN SIZE_T Length); NTSYSAPI LONG NTAPI RtlCompareUnicodeString( - IN PCUNICODE_STRING String1, - IN PCUNICODE_STRING String2, - IN BOOLEAN CaseInSensitive); + IN PCUNICODE_STRING String1, + IN PCUNICODE_STRING String2, + IN BOOLEAN CaseInSensitive); NTSYSAPI LONG NTAPI RtlCompareUnicodeStrings( - IN PCWCH String1, - IN SIZE_T String1Length, - IN PCWCH String2, - IN SIZE_T String2Length, - IN BOOLEAN CaseInSensitive); + IN PCWCH String1, + IN SIZE_T String1Length, + IN PCWCH String2, + IN SIZE_T String2Length, + IN BOOLEAN CaseInSensitive); NTSYSAPI VOID NTAPI RtlCopyUnicodeString( - IN OUT PUNICODE_STRING DestinationString, - IN PCUNICODE_STRING SourceString); + IN OUT PUNICODE_STRING DestinationString, + IN PCUNICODE_STRING SourceString OPTIONAL); NTSYSAPI NTSTATUS NTAPI RtlCreateRegistryKey( - IN ULONG RelativeTo, - IN PWSTR Path); + IN ULONG RelativeTo, + IN PWSTR Path); NTSYSAPI NTSTATUS NTAPI RtlCreateSecurityDescriptor( - IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor, - IN ULONG Revision); + IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor, + IN ULONG Revision); NTSYSAPI NTSTATUS NTAPI RtlDeleteRegistryValue( - IN ULONG RelativeTo, - IN PCWSTR Path, - IN PCWSTR ValueName); + IN ULONG RelativeTo, + IN PCWSTR Path, + IN PCWSTR ValueName); NTSYSAPI BOOLEAN NTAPI RtlEqualUnicodeString( - IN CONST UNICODE_STRING *String1, - IN CONST UNICODE_STRING *String2, - IN BOOLEAN CaseInSensitive); + IN CONST UNICODE_STRING *String1, + IN CONST UNICODE_STRING *String2, + IN BOOLEAN CaseInSensitive); #if !defined(_AMD64_) && !defined(_IA64_) NTSYSAPI LARGE_INTEGER NTAPI RtlExtendedIntegerMultiply( - IN LARGE_INTEGER Multiplicand, - IN LONG Multiplier); + IN LARGE_INTEGER Multiplicand, + IN LONG Multiplier); NTSYSAPI LARGE_INTEGER @@ -5867,7 +8550,7 @@ NTAPI RtlExtendedLargeIntegerDivide( IN LARGE_INTEGER Dividend, IN ULONG Divisor, - IN OUT PULONG Remainder); + OUT PULONG Remainder OPTIONAL); #endif #if defined(_X86_) || defined(_IA64_) @@ -5884,137 +8567,128 @@ NTSYSAPI VOID NTAPI RtlFreeAnsiString( - IN PANSI_STRING AnsiString); + IN PANSI_STRING AnsiString); NTSYSAPI ULONG NTAPI RtlFindClearBits( - IN PRTL_BITMAP BitMapHeader, - IN ULONG NumberToFind, - IN ULONG HintIndex); + IN PRTL_BITMAP BitMapHeader, + IN ULONG NumberToFind, + IN ULONG HintIndex); NTSYSAPI ULONG NTAPI RtlFindClearBitsAndSet( - IN PRTL_BITMAP BitMapHeader, - IN ULONG NumberToFind, - IN ULONG HintIndex); + IN PRTL_BITMAP BitMapHeader, + IN ULONG NumberToFind, + IN ULONG HintIndex); NTSYSAPI ULONG NTAPI RtlFindFirstRunClear( - IN PRTL_BITMAP BitMapHeader, - OUT PULONG StartingIndex); + IN PRTL_BITMAP BitMapHeader, + OUT PULONG StartingIndex); NTSYSAPI ULONG NTAPI RtlFindClearRuns( - IN PRTL_BITMAP BitMapHeader, - OUT PRTL_BITMAP_RUN RunArray, - IN ULONG SizeOfRunArray, - IN BOOLEAN LocateLongestRuns); + IN PRTL_BITMAP BitMapHeader, + OUT PRTL_BITMAP_RUN RunArray, + IN ULONG SizeOfRunArray, + IN BOOLEAN LocateLongestRuns); NTSYSAPI ULONG NTAPI RtlFindLastBackwardRunClear( - IN PRTL_BITMAP BitMapHeader, - IN ULONG FromIndex, - OUT PULONG StartingRunIndex); + IN PRTL_BITMAP BitMapHeader, + IN ULONG FromIndex, + OUT PULONG StartingRunIndex); NTSYSAPI CCHAR NTAPI RtlFindLeastSignificantBit( - IN ULONGLONG Set); + IN ULONGLONG Set); NTSYSAPI ULONG NTAPI RtlFindLongestRunClear( - IN PRTL_BITMAP BitMapHeader, - OUT PULONG StartingIndex); + IN PRTL_BITMAP BitMapHeader, + OUT PULONG StartingIndex); NTSYSAPI CCHAR NTAPI RtlFindMostSignificantBit( - IN ULONGLONG Set); + IN ULONGLONG Set); NTSYSAPI ULONG NTAPI RtlFindNextForwardRunClear( - IN PRTL_BITMAP BitMapHeader, - IN ULONG FromIndex, - OUT PULONG StartingRunIndex); + IN PRTL_BITMAP BitMapHeader, + IN ULONG FromIndex, + OUT PULONG StartingRunIndex); NTSYSAPI ULONG NTAPI RtlFindSetBits( - IN PRTL_BITMAP BitMapHeader, - IN ULONG NumberToFind, - IN ULONG HintIndex); + IN PRTL_BITMAP BitMapHeader, + IN ULONG NumberToFind, + IN ULONG HintIndex); NTSYSAPI ULONG NTAPI RtlFindSetBitsAndClear( - IN PRTL_BITMAP BitMapHeader, - IN ULONG NumberToFind, - IN ULONG HintIndex); - -NTSYSAPI -NTSTATUS -NTAPI -RtlHashUnicodeString( - IN CONST UNICODE_STRING *String, - IN BOOLEAN CaseInSensitive, - IN ULONG HashAlgorithm, - OUT PULONG HashValue); + IN PRTL_BITMAP BitMapHeader, + IN ULONG NumberToFind, + IN ULONG HintIndex); NTSYSAPI VOID NTAPI RtlInitAnsiString( - IN OUT PANSI_STRING DestinationString, - IN PCSZ SourceString); + IN OUT PANSI_STRING DestinationString, + IN PCSZ SourceString); NTSYSAPI VOID NTAPI RtlInitializeBitMap( - IN PRTL_BITMAP BitMapHeader, - IN PULONG BitMapBuffer, - IN ULONG SizeOfBitMap); + IN PRTL_BITMAP BitMapHeader, + IN PULONG BitMapBuffer, + IN ULONG SizeOfBitMap); NTSYSAPI VOID NTAPI RtlInitString( - IN OUT PSTRING DestinationString, - IN PCSZ SourceString); + IN OUT PSTRING DestinationString, + IN PCSZ SourceString); NTSYSAPI NTSTATUS NTAPI RtlIntegerToUnicodeString( - IN ULONG Value, - IN ULONG Base OPTIONAL, - IN OUT PUNICODE_STRING String); + IN ULONG Value, + IN ULONG Base OPTIONAL, + IN OUT PUNICODE_STRING String); NTSYSAPI NTSTATUS NTAPI RtlInt64ToUnicodeString( - IN ULONGLONG Value, - IN ULONG Base OPTIONAL, - IN OUT PUNICODE_STRING String); + IN ULONGLONG Value, + IN ULONG Base OPTIONAL, + IN OUT PUNICODE_STRING String); #ifdef _WIN64 #define RtlIntPtrToUnicodeString(Value, Base, String) \ @@ -6035,42 +8709,151 @@ NTSYSAPI ULONG NTAPI RtlLengthSecurityDescriptor( - IN PSECURITY_DESCRIPTOR SecurityDescriptor); + IN PSECURITY_DESCRIPTOR SecurityDescriptor); NTSYSAPI ULONG NTAPI RtlNumberOfClearBits( - IN PRTL_BITMAP BitMapHeader); + IN PRTL_BITMAP BitMapHeader); NTSYSAPI ULONG NTAPI RtlNumberOfSetBits( - IN PRTL_BITMAP BitMapHeader); + IN PRTL_BITMAP BitMapHeader); NTSYSAPI NTSTATUS NTAPI RtlQueryRegistryValues( - IN ULONG RelativeTo, - IN PCWSTR Path, - IN PRTL_QUERY_REGISTRY_TABLE QueryTable, - IN PVOID Context, - IN PVOID Environment OPTIONAL); + IN ULONG RelativeTo, + IN PCWSTR Path, + IN OUT PRTL_QUERY_REGISTRY_TABLE QueryTable, + IN PVOID Context OPTIONAL, + IN PVOID Environment OPTIONAL); +#define SHORT_SIZE (sizeof(USHORT)) +#define SHORT_MASK (SHORT_SIZE - 1) #define LONG_SIZE (sizeof(LONG)) +#define LONGLONG_SIZE (sizeof(LONGLONG)) #define LONG_MASK (LONG_SIZE - 1) +#define LONGLONG_MASK (LONGLONG_SIZE - 1) +#define LOWBYTE_MASK 0x00FF + +#define FIRSTBYTE(VALUE) ((VALUE) & LOWBYTE_MASK) +#define SECONDBYTE(VALUE) (((VALUE) >> 8) & LOWBYTE_MASK) +#define THIRDBYTE(VALUE) (((VALUE) >> 16) & LOWBYTE_MASK) +#define FOURTHBYTE(VALUE) (((VALUE) >> 24) & LOWBYTE_MASK) + +NTSYSAPI +VOID +NTAPI +RtlSetAllBits( + IN PRTL_BITMAP BitMapHeader); + +NTSYSAPI +VOID +NTAPI +RtlSetBits( + IN PRTL_BITMAP BitMapHeader, + IN ULONG StartingIndex, + IN ULONG NumberToSet); + +NTSYSAPI +NTSTATUS +NTAPI +RtlSetDaclSecurityDescriptor( + IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor, + IN BOOLEAN DaclPresent, + IN PACL Dacl OPTIONAL, + IN BOOLEAN DaclDefaulted OPTIONAL); + +#if defined(_AMD64_) + +/* VOID + * RtlStoreUlong( + * IN PULONG Address, + * IN ULONG Value); + */ +#define RtlStoreUlong(Address,Value) \ + *(ULONG UNALIGNED *)(Address) = (Value) + +/* VOID + * RtlStoreUlonglong( + * IN OUT PULONGLONG Address, + * ULONGLONG Value); + */ +#define RtlStoreUlonglong(Address,Value) \ + *(ULONGLONG UNALIGNED *)(Address) = (Value) + +/* VOID + * RtlStoreUshort( + * IN PUSHORT Address, + * IN USHORT Value); + */ +#define RtlStoreUshort(Address,Value) \ + *(USHORT UNALIGNED *)(Address) = (Value) + +/* VOID + * RtlRetrieveUshort( + * PUSHORT DestinationAddress, + * PUSHORT SourceAddress); + */ +#define RtlRetrieveUshort(DestAddress,SrcAddress) \ + *(USHORT UNALIGNED *)(DestAddress) = *(USHORT)(SrcAddress) /* VOID * RtlRetrieveUlong( - * PULONG DestinationAddress, - * PULONG SourceAddress); + * PULONG DestinationAddress, + * PULONG SourceAddress); */ -#if defined(_AMD64_) #define RtlRetrieveUlong(DestAddress,SrcAddress) \ *(ULONG UNALIGNED *)(DestAddress) = *(PULONG)(SrcAddress) + #else + +#define RtlStoreUlong(Address,Value) \ + if ((ULONG_PTR)(Address) & LONG_MASK) { \ + ((PUCHAR) (Address))[LONG_LEAST_SIGNIFICANT_BIT] = (UCHAR)(FIRSTBYTE(Value)); \ + ((PUCHAR) (Address))[LONG_3RD_MOST_SIGNIFICANT_BIT] = (UCHAR)(SECONDBYTE(Value)); \ + ((PUCHAR) (Address))[LONG_2ND_MOST_SIGNIFICANT_BIT] = (UCHAR)(THIRDBYTE(Value)); \ + ((PUCHAR) (Address))[LONG_MOST_SIGNIFICANT_BIT] = (UCHAR)(FOURTHBYTE(Value)); \ + } \ + else { \ + *((PULONG)(Address)) = (ULONG) (Value); \ + } + +#define RtlStoreUlonglong(Address,Value) \ + if ((ULONG_PTR)(Address) & LONGLONG_MASK) { \ + RtlStoreUlong((ULONG_PTR)(Address), \ + (ULONGLONG)(Value) & 0xFFFFFFFF); \ + RtlStoreUlong((ULONG_PTR)(Address)+sizeof(ULONG), \ + (ULONGLONG)(Value) >> 32); \ + } else { \ + *((PULONGLONG)(Address)) = (ULONGLONG)(Value); \ + } + +#define RtlStoreUshort(Address,Value) \ + if ((ULONG_PTR)(Address) & SHORT_MASK) { \ + ((PUCHAR) (Address))[SHORT_LEAST_SIGNIFICANT_BIT] = (UCHAR)(FIRSTBYTE(Value)); \ + ((PUCHAR) (Address))[SHORT_MOST_SIGNIFICANT_BIT ] = (UCHAR)(SECONDBYTE(Value)); \ + } \ + else { \ + *((PUSHORT) (Address)) = (USHORT)Value; \ + } + +#define RtlRetrieveUshort(DestAddress,SrcAddress) \ + if ((ULONG_PTR)(SrcAddress) & LONG_MASK) \ + { \ + ((PUCHAR)(DestAddress))[0]=((PUCHAR)(SrcAddress))[0]; \ + ((PUCHAR)(DestAddress))[1]=((PUCHAR)(SrcAddress))[1]; \ + } \ + else \ + { \ + *((PUSHORT)(DestAddress))=*((PUSHORT)(SrcAddress)); \ + } + #define RtlRetrieveUlong(DestAddress,SrcAddress) \ if ((ULONG_PTR)(SrcAddress) & LONG_MASK) \ { \ @@ -6083,164 +8866,60 @@ RtlQueryRegistryValues( { \ *((PULONG)(DestAddress))=*((PULONG)(SrcAddress)); \ } -#endif -/* VOID - * RtlRetrieveUshort( - * PUSHORT DestinationAddress, - * PUSHORT SourceAddress); - */ -#if defined(_AMD64_) -#define RtlRetrieveUshort(DestAddress,SrcAddress) \ - *(USHORT UNALIGNED *)(DestAddress) = *(USHORT)(SrcAddress) -#else -#define RtlRetrieveUshort(DestAddress,SrcAddress) \ - if ((ULONG_PTR)(SrcAddress) & LONG_MASK) \ - { \ - ((PUCHAR)(DestAddress))[0]=((PUCHAR)(SrcAddress))[0]; \ - ((PUCHAR)(DestAddress))[1]=((PUCHAR)(SrcAddress))[1]; \ - } \ - else \ - { \ - *((PUSHORT)(DestAddress))=*((PUSHORT)(SrcAddress)); \ - } -#endif - -NTSYSAPI -VOID -NTAPI -RtlSetAllBits( - IN PRTL_BITMAP BitMapHeader); - -NTSYSAPI -VOID -NTAPI -RtlSetBits( - IN PRTL_BITMAP BitMapHeader, - IN ULONG StartingIndex, - IN ULONG NumberToSet); - -NTSYSAPI -NTSTATUS -NTAPI -RtlSetDaclSecurityDescriptor( - IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor, - IN BOOLEAN DaclPresent, - IN PACL Dacl OPTIONAL, - IN BOOLEAN DaclDefaulted OPTIONAL); - -/* VOID - * RtlStoreUlong( - * IN PULONG Address, - * IN ULONG Value); - */ -#if defined(_AMD64_) -#define RtlStoreUlong(Address,Value) \ - *(ULONG UNALIGNED *)(Address) = (Value) -#else -#define RtlStoreUlong(Address,Value) \ - if ((ULONG_PTR)(Address) & LONG_MASK) { \ - ((PUCHAR) (Address))[LONG_LEAST_SIGNIFICANT_BIT] = (UCHAR)(FIRSTBYTE(Value)); \ - ((PUCHAR) (Address))[LONG_3RD_MOST_SIGNIFICANT_BIT] = (UCHAR)(SECONDBYTE(Value)); \ - ((PUCHAR) (Address))[LONG_2ND_MOST_SIGNIFICANT_BIT] = (UCHAR)(THIRDBYTE(Value)); \ - ((PUCHAR) (Address))[LONG_MOST_SIGNIFICANT_BIT] = (UCHAR)(FOURTHBYTE(Value)); \ - } \ - else { \ - *((PULONG)(Address)) = (ULONG) (Value); \ - } -#endif - -/* VOID - * RtlStoreUlonglong( - * IN OUT PULONGLONG Address, - * ULONGLONG Value); - */ -#if defined(_AMD64_) -#define RtlStoreUlonglong(Address,Value) \ - *(ULONGLONG UNALIGNED *)(Address) = (Value) -#else -#define RtlStoreUlonglong(Address,Value) \ - if ((ULONG_PTR)(Address) & LONGLONG_MASK) { \ - RtlStoreUlong((ULONG_PTR)(Address), \ - (ULONGLONG)(Value) & 0xFFFFFFFF); \ - RtlStoreUlong((ULONG_PTR)(Address)+sizeof(ULONG), \ - (ULONGLONG)(Value) >> 32); \ - } else { \ - *((PULONGLONG)(Address)) = (ULONGLONG)(Value); \ - } -#endif +#endif /* defined(_AMD64_) */ +#ifdef _WIN64 /* VOID * RtlStoreUlongPtr( * IN OUT PULONG_PTR Address, * IN ULONG_PTR Value); */ -#ifdef _WIN64 -#define RtlStoreUlongPtr(Address,Value) \ - RtlStoreUlonglong(Address,Value) +#define RtlStoreUlongPtr(Address,Value) RtlStoreUlonglong(Address,Value) #else -#define RtlStoreUlongPtr(Address,Value) \ - RtlStoreUlong(Address,Value) -#endif +#define RtlStoreUlongPtr(Address,Value) RtlStoreUlong(Address,Value) +#endif /* _WIN64 */ -/* VOID - * RtlStoreUshort( - * IN PUSHORT Address, - * IN USHORT Value); - */ -#if defined(_AMD64_) -#define RtlStoreUshort(Address,Value) \ - *(USHORT UNALIGNED *)(Address) = (Value) -#else -#define RtlStoreUshort(Address,Value) \ - if ((ULONG_PTR)(Address) & SHORT_MASK) { \ - ((PUCHAR) (Address))[SHORT_LEAST_SIGNIFICANT_BIT] = (UCHAR)(FIRSTBYTE(Value)); \ - ((PUCHAR) (Address))[SHORT_MOST_SIGNIFICANT_BIT ] = (UCHAR)(SECONDBYTE(Value)); \ - } \ - else { \ - *((PUSHORT) (Address)) = (USHORT)Value; \ - } -#endif NTSYSAPI BOOLEAN NTAPI RtlTimeFieldsToTime( - IN PTIME_FIELDS TimeFields, - IN PLARGE_INTEGER Time); + IN PTIME_FIELDS TimeFields, + IN PLARGE_INTEGER Time); NTSYSAPI VOID NTAPI RtlTimeToTimeFields( - IN PLARGE_INTEGER Time, - IN PTIME_FIELDS TimeFields); + IN PLARGE_INTEGER Time, + IN PTIME_FIELDS TimeFields); NTSYSAPI ULONG FASTCALL RtlUlongByteSwap( - IN ULONG Source); + IN ULONG Source); NTSYSAPI ULONGLONG FASTCALL RtlUlonglongByteSwap( - IN ULONGLONG Source); + IN ULONGLONG Source); NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToAnsiString( - IN OUT PANSI_STRING DestinationString, - IN PCUNICODE_STRING SourceString, - IN BOOLEAN AllocateDestinationString); + IN OUT PANSI_STRING DestinationString, + IN PCUNICODE_STRING SourceString, + IN BOOLEAN AllocateDestinationString); NTSYSAPI ULONG NTAPI RtlxUnicodeStringToAnsiSize( - IN PCUNICODE_STRING UnicodeString); + IN PCUNICODE_STRING UnicodeString); #define RtlUnicodeStringToAnsiSize(String) ( \ NLS_MB_CODE_PAGE_TAG ? \ @@ -6252,130 +8931,193 @@ NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToInteger( - IN PCUNICODE_STRING String, - IN ULONG Base OPTIONAL, - OUT PULONG Value); + IN PCUNICODE_STRING String, + IN ULONG Base OPTIONAL, + OUT PULONG Value); NTSYSAPI WCHAR NTAPI RtlUpcaseUnicodeChar( - IN WCHAR SourceCharacter); + IN WCHAR SourceCharacter); NTSYSAPI USHORT FASTCALL RtlUshortByteSwap( - IN USHORT Source); + IN USHORT Source); NTSYSAPI BOOLEAN NTAPI RtlValidRelativeSecurityDescriptor( - IN PSECURITY_DESCRIPTOR SecurityDescriptorInput, - IN ULONG SecurityDescriptorLength, - IN SECURITY_INFORMATION RequiredInformation); + IN PSECURITY_DESCRIPTOR SecurityDescriptorInput, + IN ULONG SecurityDescriptorLength, + IN SECURITY_INFORMATION RequiredInformation); NTSYSAPI BOOLEAN NTAPI RtlValidSecurityDescriptor( - IN PSECURITY_DESCRIPTOR SecurityDescriptor); + IN PSECURITY_DESCRIPTOR SecurityDescriptor); NTSYSAPI NTSTATUS NTAPI RtlWriteRegistryValue( - IN ULONG RelativeTo, - IN PCWSTR Path, - IN PCWSTR ValueName, - IN ULONG ValueType, - IN PVOID ValueData, - IN ULONG ValueLength); + IN ULONG RelativeTo, + IN PCWSTR Path, + IN PCWSTR ValueName, + IN ULONG ValueType, + IN PVOID ValueData, + IN ULONG ValueLength); + + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ -#endif // (NTDDI_VERSION >= NTDDI_WIN2K) #if (NTDDI_VERSION >= NTDDI_WIN2KSP3) NTSYSAPI VOID FASTCALL RtlPrefetchMemoryNonTemporal( - IN PVOID Source, - IN SIZE_T Length); + IN PVOID Source, + IN SIZE_T Length); #endif + #if (NTDDI_VERSION >= NTDDI_WINXP) + + + NTSYSAPI VOID NTAPI RtlClearBit( - PRTL_BITMAP BitMapHeader, - ULONG BitNumber); + PRTL_BITMAP BitMapHeader, + ULONG BitNumber); NTSYSAPI WCHAR NTAPI RtlDowncaseUnicodeChar( - IN WCHAR SourceCharacter); + IN WCHAR SourceCharacter); NTSYSAPI VOID NTAPI RtlSetBit( - PRTL_BITMAP BitMapHeader, - ULONG BitNumber); + PRTL_BITMAP BitMapHeader, + ULONG BitNumber); NTSYSAPI BOOLEAN NTAPI RtlTestBit( - IN PRTL_BITMAP BitMapHeader, - IN ULONG BitNumber); + IN PRTL_BITMAP BitMapHeader, + IN ULONG BitNumber); -#endif // (NTDDI_VERSION >= NTDDI_WINXP) +NTSYSAPI +NTSTATUS +NTAPI +RtlHashUnicodeString( + IN CONST UNICODE_STRING *String, + IN BOOLEAN CaseInSensitive, + IN ULONG HashAlgorithm, + OUT PULONG HashValue); + + +#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ #if (NTDDI_VERSION >= NTDDI_VISTA) + + + NTSYSAPI ULONG NTAPI RtlNumberOfSetBitsUlongPtr( - IN ULONG_PTR Target); + IN ULONG_PTR Target); NTSYSAPI ULONGLONG NTAPI -RtlIoDecodeMemIoResource ( - IN struct _IO_RESOURCE_DESCRIPTOR *Descriptor, - OUT PULONGLONG Alignment OPTIONAL, - OUT PULONGLONG MinimumAddress OPTIONAL, - OUT PULONGLONG MaximumAddress OPTIONAL); +RtlIoDecodeMemIoResource( + IN struct _IO_RESOURCE_DESCRIPTOR *Descriptor, + OUT PULONGLONG Alignment OPTIONAL, + OUT PULONGLONG MinimumAddress OPTIONAL, + OUT PULONGLONG MaximumAddress OPTIONAL); NTSYSAPI NTSTATUS NTAPI RtlIoEncodeMemIoResource( - IN struct _IO_RESOURCE_DESCRIPTOR *Descriptor, - IN UCHAR Type, - IN ULONGLONG Length, - IN ULONGLONG Alignment, - IN ULONGLONG MinimumAddress, - IN ULONGLONG MaximumAddress); + IN struct _IO_RESOURCE_DESCRIPTOR *Descriptor, + IN UCHAR Type, + IN ULONGLONG Length, + IN ULONGLONG Alignment, + IN ULONGLONG MinimumAddress, + IN ULONGLONG MaximumAddress); NTSYSAPI ULONGLONG NTAPI RtlCmDecodeMemIoResource( - IN struct _CM_PARTIAL_RESOURCE_DESCRIPTOR *Descriptor, - OUT PULONGLONG Start OPTIONAL); + IN struct _CM_PARTIAL_RESOURCE_DESCRIPTOR *Descriptor, + OUT PULONGLONG Start OPTIONAL); NTSYSAPI NTSTATUS NTAPI RtlFindClosestEncodableLength( - IN ULONGLONG SourceLength, - OUT PULONGLONG TargetLength); + IN ULONGLONG SourceLength, + OUT PULONGLONG TargetLength); + +NTSYSAPI +NTSTATUS +NTAPI +RtlCmEncodeMemIoResource( + IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor, + IN UCHAR Type, + IN ULONGLONG Length, + IN ULONGLONG Start); + + +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + +#if (NTDDI_VERSION >= NTDDI_WIN7) + + + +NTSYSAPI +NTSTATUS +NTAPI +RtlUnicodeToUTF8N( + OUT PCHAR UTF8StringDestination, + IN ULONG UTF8StringMaxByteCount, + OUT PULONG UTF8StringActualByteCount, + IN PCWCH UnicodeStringSource, + IN ULONG UnicodeStringByteCount); + +NTSYSAPI +NTSTATUS +NTAPI +RtlUTF8ToUnicodeN( + OUT PWSTR UnicodeStringDestination, + IN ULONG UnicodeStringMaxByteCount, + OUT PULONG UnicodeStringActualByteCount, + IN PCCH UTF8StringSource, + IN ULONG UTF8StringByteCount); + +NTSYSAPI +ULONG64 +NTAPI +RtlGetEnabledExtendedFeatures( + IN ULONG64 FeatureMask); + + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ -#endif #if !defined(MIDL_PASS) /* inline funftions */ @@ -6383,11 +9125,12 @@ RtlFindClosestEncodableLength( static __inline LARGE_INTEGER NTAPI_INLINE -RtlConvertLongToLargeInteger(LONG SignedInteger) +RtlConvertLongToLargeInteger( + IN LONG SignedInteger) { - LARGE_INTEGER ret; - ret.QuadPart = SignedInteger; - return ret; + LARGE_INTEGER ret; + ret.QuadPart = SignedInteger; + return ret; } //DECLSPEC_DEPRECATED_DDK_WINXP @@ -6395,11 +9138,39 @@ static __inline LARGE_INTEGER NTAPI_INLINE RtlConvertUlongToLargeInteger( - ULONG UnsignedInteger) + IN ULONG UnsignedInteger) { - LARGE_INTEGER ret; - ret.QuadPart = UnsignedInteger; - return ret; + LARGE_INTEGER ret; + ret.QuadPart = UnsignedInteger; + return ret; +} + +//DECLSPEC_DEPRECATED_DDK_WINXP +static __inline +LARGE_INTEGER +NTAPI_INLINE +RtlLargeIntegerShiftLeft( + IN LARGE_INTEGER LargeInteger, + IN CCHAR ShiftCount) +{ + LARGE_INTEGER Result; + + Result.QuadPart = LargeInteger.QuadPart << ShiftCount; + return Result; +} + +//DECLSPEC_DEPRECATED_DDK_WINXP +static __inline +LARGE_INTEGER +NTAPI_INLINE +RtlLargeIntegerShiftRight( + IN LARGE_INTEGER LargeInteger, + IN CCHAR ShiftCount) +{ + LARGE_INTEGER Result; + + Result.QuadPart = (ULONG64)LargeInteger.QuadPart >> ShiftCount; + return Result; } //DECLSPEC_DEPRECATED_DDK @@ -6407,13 +9178,40 @@ static __inline ULONG NTAPI_INLINE RtlEnlargedUnsignedDivide( - IN ULARGE_INTEGER Dividend, - IN ULONG Divisor, - IN OUT PULONG Remainder) + IN ULARGE_INTEGER Dividend, + IN ULONG Divisor, + IN OUT PULONG Remainder) { - if (Remainder) - *Remainder = (ULONG)(Dividend.QuadPart % Divisor); - return (ULONG)(Dividend.QuadPart / Divisor); + if (Remainder) + *Remainder = (ULONG)(Dividend.QuadPart % Divisor); + return (ULONG)(Dividend.QuadPart / Divisor); +} + +//DECLSPEC_DEPRECATED_DDK +static __inline +LARGE_INTEGER +NTAPI_INLINE +RtlLargeIntegerNegate( + IN LARGE_INTEGER Subtrahend) +{ + LARGE_INTEGER Difference; + + Difference.QuadPart = -Subtrahend.QuadPart; + return Difference; +} + +//DECLSPEC_DEPRECATED_DDK +static __inline +LARGE_INTEGER +NTAPI_INLINE +RtlLargeIntegerSubtract( + IN LARGE_INTEGER Minuend, + IN LARGE_INTEGER Subtrahend) +{ + LARGE_INTEGER Difference; + + Difference.QuadPart = Minuend.QuadPart - Subtrahend.QuadPart; + return Difference; } //DECLSPEC_DEPRECATED_DDK @@ -6421,12 +9219,12 @@ static __inline LARGE_INTEGER NTAPI_INLINE RtlEnlargedUnsignedMultiply( - IN ULONG Multiplicand, - IN ULONG Multiplier) + IN ULONG Multiplicand, + IN ULONG Multiplier) { - LARGE_INTEGER ret; - ret.QuadPart = (ULONGLONG)Multiplicand * (ULONGLONG)Multiplier; - return ret; + LARGE_INTEGER ret; + ret.QuadPart = (ULONGLONG)Multiplicand * (ULONGLONG)Multiplier; + return ret; } //DECLSPEC_DEPRECATED_DDK @@ -6434,65 +9232,72 @@ static __inline LARGE_INTEGER NTAPI_INLINE RtlEnlargedIntegerMultiply( - IN LONG Multiplicand, - IN LONG Multiplier) + IN LONG Multiplicand, + IN LONG Multiplier) { - LARGE_INTEGER ret; - ret.QuadPart = (LONGLONG)Multiplicand * (ULONGLONG)Multiplier; - return ret; + LARGE_INTEGER ret; + ret.QuadPart = (LONGLONG)Multiplicand * (ULONGLONG)Multiplier; + return ret; } FORCEINLINE VOID -RtlInitEmptyAnsiString(OUT PANSI_STRING AnsiString, - IN PCHAR Buffer, - IN USHORT BufferSize) +RtlInitEmptyAnsiString( + OUT PANSI_STRING AnsiString, + IN PCHAR Buffer, + IN USHORT BufferSize) { - AnsiString->Length = 0; - AnsiString->MaximumLength = BufferSize; - AnsiString->Buffer = Buffer; + AnsiString->Length = 0; + AnsiString->MaximumLength = BufferSize; + AnsiString->Buffer = Buffer; } FORCEINLINE VOID RtlInitEmptyUnicodeString( - OUT PUNICODE_STRING UnicodeString, - IN PWSTR Buffer, - IN USHORT BufferSize) + OUT PUNICODE_STRING UnicodeString, + IN PWSTR Buffer, + IN USHORT BufferSize) { - UnicodeString->Length = 0; - UnicodeString->MaximumLength = BufferSize; - UnicodeString->Buffer = Buffer; + UnicodeString->Length = 0; + UnicodeString->MaximumLength = BufferSize; + UnicodeString->Buffer = Buffer; } #if defined(_AMD64_) || defined(_IA64_) + + static __inline LARGE_INTEGER NTAPI_INLINE RtlExtendedIntegerMultiply( - LARGE_INTEGER Multiplicand, - LONG Multiplier) + IN LARGE_INTEGER Multiplicand, + IN LONG Multiplier) { - LARGE_INTEGER ret; - ret.QuadPart = Multiplicand.QuadPart * Multiplier; - return ret; + LARGE_INTEGER ret; + ret.QuadPart = Multiplicand.QuadPart * Multiplier; + return ret; } static __inline LARGE_INTEGER NTAPI_INLINE RtlExtendedLargeIntegerDivide( - LARGE_INTEGER Dividend, - ULONG Divisor, - PULONG Remainder) + IN LARGE_INTEGER Dividend, + IN ULONG Divisor, + OUT PULONG Remainder OPTIONAL) { - LARGE_INTEGER ret; - ret.QuadPart = (ULONG64)Dividend.QuadPart / Divisor; - if (Remainder) - *Remainder = (ULONG)(Dividend.QuadPart % Divisor); - return ret; + LARGE_INTEGER ret; + ret.QuadPart = (ULONG64)Dividend.QuadPart / Divisor; + if (Remainder) + *Remainder = (ULONG)(Dividend.QuadPart % Divisor); + return ret; } -#endif + + + +#endif /* defined(_AMD64_) || defined(_IA64_) */ + #if defined(_AMD64_) @@ -6504,19 +9309,19 @@ static __inline LARGE_INTEGER NTAPI_INLINE RtlExtendedMagicDivide( - IN LARGE_INTEGER Dividend, - IN LARGE_INTEGER MagicDivisor, - IN CCHAR ShiftCount) + IN LARGE_INTEGER Dividend, + IN LARGE_INTEGER MagicDivisor, + IN CCHAR ShiftCount) { - LARGE_INTEGER ret; - ULONG64 ret64; - BOOLEAN Pos; - Pos = (Dividend.QuadPart >= 0); - ret64 = UnsignedMultiplyHigh(Pos ? Dividend.QuadPart : -Dividend.QuadPart, - MagicDivisor.QuadPart); - ret64 >>= ShiftCount; - ret.QuadPart = Pos ? ret64 : -ret64; - return ret; + LARGE_INTEGER ret; + ULONG64 ret64; + BOOLEAN Pos; + Pos = (Dividend.QuadPart >= 0); + ret64 = UnsignedMultiplyHigh(Pos ? Dividend.QuadPart : -Dividend.QuadPart, + MagicDivisor.QuadPart); + ret64 >>= ShiftCount; + ret.QuadPart = Pos ? ret64 : -ret64; + return ret; } #endif @@ -6525,12 +9330,12 @@ static __inline LARGE_INTEGER NTAPI_INLINE RtlLargeIntegerAdd( - IN LARGE_INTEGER Addend1, - IN LARGE_INTEGER Addend2) + IN LARGE_INTEGER Addend1, + IN LARGE_INTEGER Addend2) { - LARGE_INTEGER ret; - ret.QuadPart = Addend1.QuadPart + Addend2.QuadPart; - return ret; + LARGE_INTEGER ret; + ret.QuadPart = Addend1.QuadPart + Addend2.QuadPart; + return ret; } /* VOID @@ -6547,12 +9352,12 @@ static __inline LARGE_INTEGER NTAPI_INLINE RtlLargeIntegerArithmeticShift( - IN LARGE_INTEGER LargeInteger, - IN CCHAR ShiftCount) + IN LARGE_INTEGER LargeInteger, + IN CCHAR ShiftCount) { - LARGE_INTEGER ret; - ret.QuadPart = LargeInteger.QuadPart >> ShiftCount; - return ret; + LARGE_INTEGER ret; + ret.QuadPart = LargeInteger.QuadPart >> ShiftCount; + return ret; } /* BOOLEAN @@ -6566,36 +9371,74 @@ RtlLargeIntegerArithmeticShift( FORCEINLINE PVOID RtlSecureZeroMemory( - OUT PVOID Pointer, - IN SIZE_T Size) + OUT PVOID Pointer, + IN SIZE_T Size) { - volatile char* vptr = (volatile char*)Pointer; + volatile char* vptr = (volatile char*)Pointer; #if defined(_M_AMD64) - __stosb((PUCHAR)vptr, 0, Size); + __stosb((PUCHAR)vptr, 0, Size); #else - char * endptr = (char *)vptr + Size; - while (vptr < endptr) - { - *vptr = 0; vptr++; - } + char * endptr = (char *)vptr + Size; + while (vptr < endptr) { + *vptr = 0; vptr++; + } #endif - return Pointer; + return Pointer; } #if defined(_M_AMD64) FORCEINLINE -ULONG +BOOLEAN RtlCheckBit( - IN PRTL_BITMAP BitMapHeader, - IN ULONG BitPosition) + IN PRTL_BITMAP BitMapHeader, + IN ULONG BitPosition) { - return BitTest((LONG CONST*)BitMapHeader->Buffer, BitPosition); + return BitTest64((LONG64 CONST*)BitMapHeader->Buffer, (LONG64)BitPosition); } #else #define RtlCheckBit(BMH,BP) (((((PLONG)(BMH)->Buffer)[(BP)/32]) >> ((BP)%32)) & 0x1) -#endif // defined(_M_AMD64) +#endif /* defined(_M_AMD64) */ -#endif // !defined(MIDL_PASS) +#define RtlLargeIntegerGreaterThan(X,Y) ( \ + (((X).HighPart == (Y).HighPart) && ((X).LowPart > (Y).LowPart)) || \ + ((X).HighPart > (Y).HighPart) \ +) + +#define RtlLargeIntegerGreaterThanOrEqualTo(X,Y) ( \ + (((X).HighPart == (Y).HighPart) && ((X).LowPart >= (Y).LowPart)) || \ + ((X).HighPart > (Y).HighPart) \ +) + +#define RtlLargeIntegerNotEqualTo(X,Y) ( \ + (((X).LowPart ^ (Y).LowPart) | ((X).HighPart ^ (Y).HighPart)) \ +) + +#define RtlLargeIntegerLessThan(X,Y) ( \ + (((X).HighPart == (Y).HighPart) && ((X).LowPart < (Y).LowPart)) || \ + ((X).HighPart < (Y).HighPart) \ +) + +#define RtlLargeIntegerLessThanOrEqualTo(X,Y) ( \ + (((X).HighPart == (Y).HighPart) && ((X).LowPart <= (Y).LowPart)) || \ + ((X).HighPart < (Y).HighPart) \ +) + +#define RtlLargeIntegerGreaterThanZero(X) ( \ + (((X).HighPart == 0) && ((X).LowPart > 0)) || \ + ((X).HighPart > 0 ) \ +) + +#define RtlLargeIntegerGreaterOrEqualToZero(X) ( (X).HighPart >= 0 ) + +#define RtlLargeIntegerEqualToZero(X) ( !((X).LowPart | (X).HighPart) ) + +#define RtlLargeIntegerNotEqualToZero(X) ( ((X).LowPart | (X).HighPart) ) + +#define RtlLargeIntegerLessThanZero(X) ( ((X).HighPart < 0) ) + +#define RtlLargeIntegerLessOrEqualToZero(X) ( ((X).HighPart < 0) || !((X).LowPart | (X).HighPart) ) + +#endif /* !defined(MIDL_PASS) */ /* Byte Swap Functions */ #if (defined(_M_IX86) && (_MSC_FULL_VER > 13009037 || defined(__GNUC__))) || \ @@ -6649,6 +9492,10 @@ RtlCheckBit( (__annotation(L"Debug", L"AssertFail", msg), \ DbgRaiseAssertionFailure(), FALSE) : TRUE) +#define NT_VERIFY NT_ASSERT +#define NT_VERIFYMSG NT_ASSERTMSG +#define NT_VERIFYMSGW NT_ASSERTMSGW + #else /* GCC doesn't support __annotation (nor PDB) */ @@ -6674,12 +9521,19 @@ RtlCheckBit( #define RTL_SOFT_VERIFY(exp) ((exp) ? TRUE : FALSE) #define RTL_SOFT_VERIFYMSG(msg, exp) ((exp) ? TRUE : FALSE) -#define NT_ASSERT(exp) ((VOID)0) -#define NT_ASSERTMSG(exp) ((VOID)0) -#define NT_ASSERTMSGW(exp) ((VOID)0) +#define NT_ASSERT(exp) ((VOID)0) +#define NT_ASSERTMSG(msg, exp) ((VOID)0) +#define NT_ASSERTMSGW(msg, exp) ((VOID)0) + +#define NT_VERIFY(_exp) ((_exp) ? TRUE : FALSE) +#define NT_VERIFYMSG(_msg, _exp ) ((_exp) ? TRUE : FALSE) +#define NT_VERIFYMSGW(_msg, _exp) ((_exp) ? TRUE : FALSE) #endif /* DBG */ +#define InitializeListHead32(ListHead) (\ + (ListHead)->Flink = (ListHead)->Blink = PtrToUlong((ListHead))) + #if !defined(_WINBASE_) #if defined(_WIN64) && (defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_) || defined(_NTOSP_)) @@ -6697,25 +9551,21 @@ InitializeSListHead( OUT PSLIST_HEADER SListHead) { #if defined(_IA64_) - ULONG64 FeatureBits; + ULONG64 FeatureBits; #endif #if defined(_WIN64) - if (((ULONG_PTR)SListHead & 0xf) != 0) - { - RtlRaiseStatus(STATUS_DATATYPE_MISALIGNMENT); - } + if (((ULONG_PTR)SListHead & 0xf) != 0) { + RtlRaiseStatus(STATUS_DATATYPE_MISALIGNMENT); + } #endif - - RtlZeroMemory(SListHead, sizeof(SLIST_HEADER)); - + RtlZeroMemory(SListHead, sizeof(SLIST_HEADER)); #if defined(_IA64_) - FeatureBits = __getReg(CV_IA64_CPUID4); - if ((FeatureBits & KF_16BYTE_INSTR) != 0) - { - SListHead->Header16.HeaderType = 1; - SListHead->Header16.Init = 1; - } + FeatureBits = __getReg(CV_IA64_CPUID4); + if ((FeatureBits & KF_16BYTE_INSTR) != 0) { + SListHead->Header16.HeaderType = 1; + SListHead->Header16.Init = 1; + } #endif } @@ -6741,14 +9591,14 @@ NTKERNELAPI PSLIST_ENTRY FASTCALL InterlockedPopEntrySList( - IN PSLIST_HEADER ListHead); + IN PSLIST_HEADER ListHead); NTKERNELAPI PSLIST_ENTRY FASTCALL InterlockedPushEntrySList( - IN PSLIST_HEADER ListHead, - IN PSLIST_ENTRY ListEntry); + IN PSLIST_HEADER ListHead, + IN PSLIST_ENTRY ListEntry); #define InterlockedFlushSList(ListHead) \ ExInterlockedFlushSList(ListHead) @@ -6760,23 +9610,68 @@ InterlockedPushEntrySList( #endif /* !defined(_WINBASE_) */ +#define RTL_CONTEXT_EX_OFFSET(ContextEx, Chunk) ((ContextEx)->Chunk.Offset) +#define RTL_CONTEXT_EX_LENGTH(ContextEx, Chunk) ((ContextEx)->Chunk.Length) +#define RTL_CONTEXT_EX_CHUNK(Base, Layout, Chunk) \ + ((PVOID)((PCHAR)(Base) + RTL_CONTEXT_EX_OFFSET(Layout, Chunk))) +#define RTL_CONTEXT_OFFSET(Context, Chunk) \ + RTL_CONTEXT_EX_OFFSET((PCONTEXT_EX)(Context + 1), Chunk) +#define RTL_CONTEXT_LENGTH(Context, Chunk) \ + RTL_CONTEXT_EX_LENGTH((PCONTEXT_EX)(Context + 1), Chunk) +#define RTL_CONTEXT_CHUNK(Context, Chunk) \ + RTL_CONTEXT_EX_CHUNK((PCONTEXT_EX)(Context + 1), \ + (PCONTEXT_EX)(Context + 1), \ + Chunk) + +BOOLEAN +RTLVERLIB_DDI(RtlIsNtDdiVersionAvailable)( + IN ULONG Version); + +BOOLEAN +RTLVERLIB_DDI(RtlIsServicePackVersionInstalled)( + IN ULONG Version); + +#ifndef RtlIsNtDdiVersionAvailable +#define RtlIsNtDdiVersionAvailable WdmlibRtlIsNtDdiVersionAvailable +#endif + +#ifndef RtlIsServicePackVersionInstalled +#define RtlIsServicePackVersionInstalled WdmlibRtlIsServicePackVersionInstalled +#endif + +#define RtlInterlockedSetBits(Flags, Flag) \ + InterlockedOr((PLONG)(Flags), Flag) + +#define RtlInterlockedAndBits(Flags, Flag) \ + InterlockedAnd((PLONG)(Flags), Flag) + +#define RtlInterlockedClearBits(Flags, Flag) \ + RtlInterlockedAndBits(Flags, ~(Flag)) + +#define RtlInterlockedXorBits(Flags, Flag) \ + InterlockedXor(Flags, Flag) + +#define RtlInterlockedSetBitsDiscardReturn(Flags, Flag) \ + (VOID) RtlInterlockedSetBits(Flags, Flag) + +#define RtlInterlockedAndBitsDiscardReturn(Flags, Flag) \ + (VOID) RtlInterlockedAndBits(Flags, Flag) + +#define RtlInterlockedClearBitsDiscardReturn(Flags, Flag) \ + RtlInterlockedAndBitsDiscardReturn(Flags, ~(Flag)) + + /****************************************************************************** * Kernel Functions * ******************************************************************************/ -NTHALAPI -KIRQL -NTAPI -KeGetCurrentIrql( - VOID); - NTKERNELAPI VOID NTAPI KeInitializeEvent( - OUT PRKEVENT Event, - IN EVENT_TYPE Type, - IN BOOLEAN State); + OUT PRKEVENT Event, + IN EVENT_TYPE Type, + IN BOOLEAN State); NTKERNELAPI VOID @@ -6786,6 +9681,8 @@ KeClearEvent( #if (NTDDI_VERSION >= NTDDI_WIN2K) + +#if defined(_NTDDK_) || defined(_NTIFS_) NTKERNELAPI VOID NTAPI @@ -6793,6 +9690,7 @@ ProbeForRead( IN CONST VOID *Address, /* CONST is added */ IN SIZE_T Length, IN ULONG Alignment); +#endif /* defined(_NTDDK_) || defined(_NTIFS_) */ NTKERNELAPI VOID @@ -6802,7 +9700,9 @@ ProbeForWrite( IN SIZE_T Length, IN ULONG Alignment); + #if defined(SINGLE_GROUP_LEGACY_API) + NTKERNELAPI VOID NTAPI @@ -6812,7 +9712,7 @@ NTKERNELAPI VOID NTAPI KeSetSystemAffinityThread( - IN KAFFINITY Affinity); + IN KAFFINITY Affinity); NTKERNELAPI VOID @@ -6824,37 +9724,67 @@ KeSetTargetProcessorDpc( NTKERNELAPI KAFFINITY NTAPI -KeQueryActiveProcessors( - VOID); -#endif +KeQueryActiveProcessors(VOID); + + +#endif /* defined(SINGLE_GROUP_LEGACY_API) */ #if !defined(_M_AMD64) NTKERNELAPI ULONGLONG NTAPI -KeQueryInterruptTime( - VOID); +KeQueryInterruptTime(VOID); NTKERNELAPI VOID NTAPI KeQuerySystemTime( - OUT PLARGE_INTEGER CurrentTime); + OUT PLARGE_INTEGER CurrentTime); #endif /* !_M_AMD64 */ +#if !defined(_X86_) +NTKERNELAPI +KIRQL +NTAPI +KeAcquireSpinLockRaiseToDpc( + IN OUT PKSPIN_LOCK SpinLock); + +#define KeAcquireSpinLock(SpinLock, OldIrql) \ + *(OldIrql) = KeAcquireSpinLockRaiseToDpc(SpinLock) + +NTKERNELAPI +VOID +NTAPI +KeAcquireSpinLockAtDpcLevel( + IN OUT PKSPIN_LOCK SpinLock); + +NTKERNELAPI +VOID +NTAPI +KeReleaseSpinLock( + IN OUT PKSPIN_LOCK SpinLock, + IN KIRQL NewIrql); + +NTKERNELAPI +VOID +NTAPI +KeReleaseSpinLockFromDpcLevel( + IN OUT PKSPIN_LOCK SpinLock); +#endif /* !_X86_ */ + #if defined(_X86_) && (defined(_WDM_INCLUDED_) || defined(WIN9X_COMPAT_SPINLOCK)) NTKERNELAPI VOID NTAPI KeInitializeSpinLock( - IN PKSPIN_LOCK SpinLock); + IN PKSPIN_LOCK SpinLock); #else FORCEINLINE VOID KeInitializeSpinLock(IN PKSPIN_LOCK SpinLock) { - /* Clear the lock */ - *SpinLock = 0; + /* Clear the lock */ + *SpinLock = 0; } #endif @@ -6863,11 +9793,11 @@ DECLSPEC_NORETURN VOID NTAPI KeBugCheckEx( - IN ULONG BugCheckCode, - IN ULONG_PTR BugCheckParameter1, - IN ULONG_PTR BugCheckParameter2, - IN ULONG_PTR BugCheckParameter3, - IN ULONG_PTR BugCheckParameter4); + IN ULONG BugCheckCode, + IN ULONG_PTR BugCheckParameter1, + IN ULONG_PTR BugCheckParameter2, + IN ULONG_PTR BugCheckParameter3, + IN ULONG_PTR BugCheckParameter4); NTKERNELAPI BOOLEAN @@ -6898,66 +9828,66 @@ NTKERNELAPI VOID NTAPI KeInitializeDeviceQueue( - OUT PKDEVICE_QUEUE DeviceQueue); + OUT PKDEVICE_QUEUE DeviceQueue); NTKERNELAPI VOID NTAPI KeInitializeDpc( - OUT PRKDPC Dpc, - IN PKDEFERRED_ROUTINE DeferredRoutine, - IN PVOID DeferredContext OPTIONAL); + OUT PRKDPC Dpc, + IN PKDEFERRED_ROUTINE DeferredRoutine, + IN PVOID DeferredContext OPTIONAL); NTKERNELAPI VOID NTAPI KeInitializeMutex( - OUT PRKMUTEX Mutex, - IN ULONG Level); + OUT PRKMUTEX Mutex, + IN ULONG Level); NTKERNELAPI VOID NTAPI KeInitializeSemaphore( - OUT PRKSEMAPHORE Semaphore, - IN LONG Count, - IN LONG Limit); + OUT PRKSEMAPHORE Semaphore, + IN LONG Count, + IN LONG Limit); NTKERNELAPI VOID NTAPI KeInitializeTimer( - OUT PKTIMER Timer); + OUT PKTIMER Timer); NTKERNELAPI VOID NTAPI KeInitializeTimerEx( - OUT PKTIMER Timer, - IN TIMER_TYPE Type); + OUT PKTIMER Timer, + IN TIMER_TYPE Type); NTKERNELAPI BOOLEAN NTAPI KeInsertByKeyDeviceQueue( - IN OUT PKDEVICE_QUEUE DeviceQueue, - IN OUT PKDEVICE_QUEUE_ENTRY DeviceQueueEntry, - IN ULONG SortKey); + IN OUT PKDEVICE_QUEUE DeviceQueue, + IN OUT PKDEVICE_QUEUE_ENTRY DeviceQueueEntry, + IN ULONG SortKey); NTKERNELAPI BOOLEAN NTAPI KeInsertDeviceQueue( - IN OUT PKDEVICE_QUEUE DeviceQueue, - IN OUT PKDEVICE_QUEUE_ENTRY DeviceQueueEntry); + IN OUT PKDEVICE_QUEUE DeviceQueue, + IN OUT PKDEVICE_QUEUE_ENTRY DeviceQueueEntry); NTKERNELAPI BOOLEAN NTAPI KeInsertQueueDpc( - IN OUT PRKDPC Dpc, - IN PVOID SystemArgument1 OPTIONAL, - IN PVOID SystemArgument2 OPTIONAL); + IN OUT PRKDPC Dpc, + IN PVOID SystemArgument1 OPTIONAL, + IN PVOID SystemArgument2 OPTIONAL); NTKERNELAPI VOID @@ -6968,168 +9898,166 @@ NTHALAPI LARGE_INTEGER NTAPI KeQueryPerformanceCounter( - OUT PLARGE_INTEGER PerformanceFrequency OPTIONAL); + OUT PLARGE_INTEGER PerformanceFrequency OPTIONAL); NTKERNELAPI KPRIORITY NTAPI KeQueryPriorityThread( - IN PRKTHREAD Thread); + IN PRKTHREAD Thread); NTKERNELAPI ULONG NTAPI -KeQueryTimeIncrement( - VOID); +KeQueryTimeIncrement(VOID); NTKERNELAPI LONG NTAPI KeReadStateEvent( - IN PRKEVENT Event); + IN PRKEVENT Event); NTKERNELAPI LONG NTAPI KeReadStateMutex( - IN PRKMUTEX Mutex); - + IN PRKMUTEX Mutex); NTKERNELAPI LONG NTAPI KeReadStateSemaphore( - IN PRKSEMAPHORE Semaphore); + IN PRKSEMAPHORE Semaphore); NTKERNELAPI BOOLEAN NTAPI KeReadStateTimer( - IN PKTIMER Timer); + IN PKTIMER Timer); NTKERNELAPI BOOLEAN NTAPI KeRegisterBugCheckCallback( - OUT PKBUGCHECK_CALLBACK_RECORD CallbackRecord, - IN PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine, - IN PVOID Buffer, - IN ULONG Length, - IN PUCHAR Component); + OUT PKBUGCHECK_CALLBACK_RECORD CallbackRecord, + IN PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine, + IN PVOID Buffer, + IN ULONG Length, + IN PUCHAR Component); NTKERNELAPI LONG NTAPI KeReleaseMutex( - IN OUT PRKMUTEX Mutex, - IN BOOLEAN Wait); + IN OUT PRKMUTEX Mutex, + IN BOOLEAN Wait); NTKERNELAPI LONG NTAPI KeReleaseSemaphore( - IN OUT PRKSEMAPHORE Semaphore, - IN KPRIORITY Increment, - IN LONG Adjustment, - IN BOOLEAN Wait); + IN OUT PRKSEMAPHORE Semaphore, + IN KPRIORITY Increment, + IN LONG Adjustment, + IN BOOLEAN Wait); NTKERNELAPI PKDEVICE_QUEUE_ENTRY NTAPI KeRemoveByKeyDeviceQueue( - IN OUT PKDEVICE_QUEUE DeviceQueue, - IN ULONG SortKey); + IN OUT PKDEVICE_QUEUE DeviceQueue, + IN ULONG SortKey); NTKERNELAPI PKDEVICE_QUEUE_ENTRY NTAPI KeRemoveDeviceQueue( - IN OUT PKDEVICE_QUEUE DeviceQueue); + IN OUT PKDEVICE_QUEUE DeviceQueue); NTKERNELAPI BOOLEAN NTAPI KeRemoveEntryDeviceQueue( - IN OUT PKDEVICE_QUEUE DeviceQueue, - IN OUT PKDEVICE_QUEUE_ENTRY DeviceQueueEntry); + IN OUT PKDEVICE_QUEUE DeviceQueue, + IN OUT PKDEVICE_QUEUE_ENTRY DeviceQueueEntry); NTKERNELAPI BOOLEAN NTAPI KeRemoveQueueDpc( - IN OUT PRKDPC Dpc); + IN OUT PRKDPC Dpc); NTKERNELAPI LONG NTAPI KeResetEvent( - IN OUT PRKEVENT Event); + IN OUT PRKEVENT Event); NTKERNELAPI LONG NTAPI KeSetEvent( - IN OUT PRKEVENT Event, - IN KPRIORITY Increment, - IN BOOLEAN Wait); + IN OUT PRKEVENT Event, + IN KPRIORITY Increment, + IN BOOLEAN Wait); NTKERNELAPI VOID NTAPI KeSetImportanceDpc( - IN OUT PRKDPC Dpc, - IN KDPC_IMPORTANCE Importance); + IN OUT PRKDPC Dpc, + IN KDPC_IMPORTANCE Importance); NTKERNELAPI KPRIORITY NTAPI KeSetPriorityThread( - IN OUT PKTHREAD Thread, - IN KPRIORITY Priority); + IN OUT PKTHREAD Thread, + IN KPRIORITY Priority); NTKERNELAPI BOOLEAN NTAPI KeSetTimer( - IN OUT PKTIMER Timer, - IN LARGE_INTEGER DueTime, - IN PKDPC Dpc OPTIONAL); + IN OUT PKTIMER Timer, + IN LARGE_INTEGER DueTime, + IN PKDPC Dpc OPTIONAL); NTKERNELAPI BOOLEAN NTAPI KeSetTimerEx( - IN OUT PKTIMER Timer, - IN LARGE_INTEGER DueTime, - IN LONG Period OPTIONAL, - IN PKDPC Dpc OPTIONAL); + IN OUT PKTIMER Timer, + IN LARGE_INTEGER DueTime, + IN LONG Period OPTIONAL, + IN PKDPC Dpc OPTIONAL); NTHALAPI VOID NTAPI KeStallExecutionProcessor( - IN ULONG MicroSeconds); + IN ULONG MicroSeconds); NTKERNELAPI BOOLEAN NTAPI KeSynchronizeExecution( - IN OUT PKINTERRUPT Interrupt, - IN PKSYNCHRONIZE_ROUTINE SynchronizeRoutine, - IN PVOID SynchronizeContext OPTIONAL); + IN OUT PKINTERRUPT Interrupt, + IN PKSYNCHRONIZE_ROUTINE SynchronizeRoutine, + IN PVOID SynchronizeContext OPTIONAL); NTKERNELAPI NTSTATUS NTAPI KeWaitForMultipleObjects( - IN ULONG Count, - IN PVOID Object[], - IN WAIT_TYPE WaitType, - IN KWAIT_REASON WaitReason, - IN KPROCESSOR_MODE WaitMode, - IN BOOLEAN Alertable, - IN PLARGE_INTEGER Timeout OPTIONAL, - OUT PKWAIT_BLOCK WaitBlockArray OPTIONAL); + IN ULONG Count, + IN PVOID Object[], + IN WAIT_TYPE WaitType, + IN KWAIT_REASON WaitReason, + IN KPROCESSOR_MODE WaitMode, + IN BOOLEAN Alertable, + IN PLARGE_INTEGER Timeout OPTIONAL, + OUT PKWAIT_BLOCK WaitBlockArray OPTIONAL); #define KeWaitForMutexObject KeWaitForSingleObject @@ -7137,11 +10065,11 @@ NTKERNELAPI NTSTATUS NTAPI KeWaitForSingleObject( - IN PVOID Object, - IN KWAIT_REASON WaitReason, - IN KPROCESSOR_MODE WaitMode, - IN BOOLEAN Alertable, - IN PLARGE_INTEGER Timeout OPTIONAL); + IN PVOID Object, + IN KWAIT_REASON WaitReason, + IN KPROCESSOR_MODE WaitMode, + IN BOOLEAN Alertable, + IN PLARGE_INTEGER Timeout OPTIONAL); #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ @@ -7158,14 +10086,14 @@ NTKERNELAPI VOID FASTCALL KeAcquireInStackQueuedSpinLockAtDpcLevel( - IN OUT PKSPIN_LOCK SpinLock, - OUT PKLOCK_QUEUE_HANDLE LockHandle); + IN OUT PKSPIN_LOCK SpinLock, + OUT PKLOCK_QUEUE_HANDLE LockHandle); NTKERNELAPI KIRQL NTAPI KeAcquireInterruptSpinLock( - IN OUT PKINTERRUPT Interrupt); + IN OUT PKINTERRUPT Interrupt); NTKERNELAPI BOOLEAN @@ -7188,14 +10116,14 @@ NTKERNELAPI VOID FASTCALL KeReleaseInStackQueuedSpinLockFromDpcLevel( - IN PKLOCK_QUEUE_HANDLE LockHandle); + IN PKLOCK_QUEUE_HANDLE LockHandle); NTKERNELAPI VOID NTAPI KeReleaseInterruptSpinLock( - IN OUT PKINTERRUPT Interrupt, - IN KIRQL OldIrql); + IN OUT PKINTERRUPT Interrupt, + IN KIRQL OldIrql); NTKERNELAPI PKDEVICE_QUEUE_ENTRY @@ -7232,13 +10160,10 @@ KeRegisterBugCheckReasonCallback( #endif /* (NTDDI_VERSION >= NTDDI_WINXPSP1) */ #if (NTDDI_VERSION >= NTDDI_WINXPSP2) - NTKERNELAPI VOID NTAPI -KeFlushQueuedDpcs( - VOID); - +KeFlushQueuedDpcs(VOID); #endif /* (NTDDI_VERSION >= NTDDI_WINXPSP2) */ #if (NTDDI_VERSION >= NTDDI_WS03) @@ -7290,10 +10215,12 @@ FASTCALL KeTestSpinLock( IN PKSPIN_LOCK SpinLock); + #endif /* (NTDDI_VERSION >= NTDDI_WS03) */ #if (NTDDI_VERSION >= NTDDI_WS03SP1) + NTKERNELAPI BOOLEAN FASTCALL @@ -7303,64 +10230,53 @@ KeTryToAcquireSpinLockAtDpcLevel( NTKERNELAPI BOOLEAN NTAPI -KeAreAllApcsDisabled( - VOID); +KeAreAllApcsDisabled(VOID); NTKERNELAPI VOID FASTCALL KeAcquireGuardedMutex( - IN OUT PKGUARDED_MUTEX GuardedMutex -); + IN OUT PKGUARDED_MUTEX GuardedMutex); NTKERNELAPI VOID FASTCALL KeAcquireGuardedMutexUnsafe( - IN OUT PKGUARDED_MUTEX GuardedMutex -); + IN OUT PKGUARDED_MUTEX GuardedMutex); NTKERNELAPI VOID NTAPI -KeEnterGuardedRegion( - VOID -); +KeEnterGuardedRegion(VOID); NTKERNELAPI VOID NTAPI -KeLeaveGuardedRegion( - VOID -); +KeLeaveGuardedRegion(VOID); NTKERNELAPI VOID FASTCALL KeInitializeGuardedMutex( - OUT PKGUARDED_MUTEX GuardedMutex -); + OUT PKGUARDED_MUTEX GuardedMutex); NTKERNELAPI VOID FASTCALL KeReleaseGuardedMutexUnsafe( - IN OUT PKGUARDED_MUTEX GuardedMutex -); + IN OUT PKGUARDED_MUTEX GuardedMutex); NTKERNELAPI VOID FASTCALL KeReleaseGuardedMutex( - IN OUT PKGUARDED_MUTEX GuardedMutex -); + IN OUT PKGUARDED_MUTEX GuardedMutex); NTKERNELAPI BOOLEAN FASTCALL KeTryToAcquireGuardedMutex( - IN OUT PKGUARDED_MUTEX GuardedMutex -); + IN OUT PKGUARDED_MUTEX GuardedMutex); #endif /* (NTDDI_VERSION >= NTDDI_WS03SP1) */ @@ -7386,12 +10302,19 @@ KeQueryDpcWatchdogInformation( OUT PKDPC_WATCHDOG_INFORMATION WatchdogInformation); #if defined(SINGLE_GROUP_LEGACY_API) + NTKERNELAPI KAFFINITY NTAPI KeSetSystemAffinityThreadEx( IN KAFFINITY Affinity); +NTKERNELAPI +VOID +NTAPI +KeRevertToUserAffinityThreadEx( + IN KAFFINITY Affinity); + NTKERNELAPI ULONG NTAPI @@ -7401,11 +10324,10 @@ KeQueryActiveProcessorCount( NTKERNELAPI ULONG NTAPI -KeQueryMaximumProcessorCount( - VOID); -#endif +KeQueryMaximumProcessorCount(VOID); +#endif /* SINGLE_GROUP_LEGACY_API */ -#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ #if (NTDDI_VERSION >= NTDDI_WS08) @@ -7423,6 +10345,7 @@ KeDeregisterProcessorChangeCallback( #if (NTDDI_VERSION >= NTDDI_WIN7) + ULONG64 NTAPI KeQueryTotalCycleTimeProcess( @@ -7468,8 +10391,7 @@ KeSetCoalescableTimer( NTKERNELAPI ULONGLONG NTAPI -KeQueryUnbiasedInterruptTime( - VOID); +KeQueryUnbiasedInterruptTime(VOID); NTKERNELAPI ULONG @@ -7486,19 +10408,17 @@ KeQueryMaximumProcessorCountEx( NTKERNELAPI USHORT NTAPI -KeQueryActiveGroupCount( - VOID); +KeQueryActiveGroupCount(VOID); NTKERNELAPI USHORT NTAPI -KeQueryMaximumGroupCount( - VOID); +KeQueryMaximumGroupCount(VOID); NTKERNELAPI KAFFINITY NTAPI -KeQueryGroupAffinity +KeQueryGroupAffinity( IN USHORT GroupNumber); NTKERNELAPI @@ -7524,14 +10444,12 @@ KeQueryNodeMaximumProcessorCount( NTKERNELAPI USHORT NTAPI -KeQueryHighestNodeNumber( - VOID); +KeQueryHighestNodeNumber(VOID); NTKERNELAPI USHORT NTAPI -KeGetCurrentNodeNumber( - VOID); +KeGetCurrentNodeNumber(VOID); NTKERNELAPI NTSTATUS @@ -7555,7 +10473,18 @@ NTAPI KeRestoreExtendedProcessorState( IN PXSTATE_SAVE XStateSave); -#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ +NTSTATUS +NTAPI +KeGetProcessorNumberFromIndex( + IN ULONG ProcIndex, + OUT PPROCESSOR_NUMBER ProcNumber); + +ULONG +NTAPI +KeGetProcessorIndexFromNumber( + IN PPROCESSOR_NUMBER ProcNumber); + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ #if !defined(_IA64_) NTHALAPI @@ -7590,17 +10519,14 @@ KeFlushWriteBuffer(VOID); #define PAGED_CODE() -#endif +#endif /* DBG */ #define PAGED_CODE_LOCKED() NOP_FUNCTION; /****************************************************************************** * Memory manager Functions * ******************************************************************************/ - -/* - * Alignment Macros - */ +/* Alignment Macros */ #define ALIGN_DOWN_BY(size, align) \ ((ULONG_PTR)(size) & ~((ULONG_PTR)(align) - 1)) @@ -7625,6 +10551,22 @@ KeFlushWriteBuffer(VOID); #define ALIGN_UP_POINTER(ptr, type) \ ALIGN_UP_POINTER_BY(ptr, sizeof(type)) +#ifndef FIELD_OFFSET +#define FIELD_OFFSET(type, field) ((ULONG)&(((type *)0)->field)) +#endif + +#ifndef FIELD_SIZE +#define FIELD_SIZE(type, field) (sizeof(((type *)0)->field)) +#endif + +#define POOL_TAGGING 1 + +#if DBG +#define IF_DEBUG if (TRUE) +#else +#define IF_DEBUG if (FALSE) +#endif /* DBG */ + /* ULONG * BYTE_OFFSET( * IN PVOID Va) @@ -7637,7 +10579,7 @@ KeFlushWriteBuffer(VOID); * IN ULONG Size) */ #define BYTES_TO_PAGES(Size) \ - (((Size) >> PAGE_SHIFT) + (((Size) & (PAGE_SIZE - 1)) != 0)) + (((Size) + PAGE_SIZE - 1) >> PAGE_SHIFT) /* PVOID * PAGE_ALIGN( @@ -7662,6 +10604,9 @@ KeFlushWriteBuffer(VOID); ((ULONG) ((((ULONG_PTR) (_Va) & (PAGE_SIZE - 1)) \ + (_Size) + (PAGE_SIZE - 1)) >> PAGE_SHIFT)) +#define COMPUTE_PAGES_SPANNED(Va, Size) \ + ADDRESS_AND_SIZE_TO_SPAN_PAGES(Va,Size) + /* * ULONG * MmGetMdlByteCount( @@ -7678,6 +10623,8 @@ KeFlushWriteBuffer(VOID); #define MmGetMdlByteOffset(_Mdl) \ ((_Mdl)->ByteOffset) +#define MmGetMdlBaseVa(Mdl) ((Mdl)->StartVa) + /* * PPFN_NUMBER * MmGetMdlPfnArray( @@ -7758,56 +10705,56 @@ NTKERNELAPI PVOID NTAPI MmAllocateContiguousMemory( - IN SIZE_T NumberOfBytes, - IN PHYSICAL_ADDRESS HighestAcceptableAddress); + IN SIZE_T NumberOfBytes, + IN PHYSICAL_ADDRESS HighestAcceptableAddress); NTKERNELAPI PVOID NTAPI MmAllocateContiguousMemorySpecifyCache( - IN SIZE_T NumberOfBytes, - IN PHYSICAL_ADDRESS LowestAcceptableAddress, - IN PHYSICAL_ADDRESS HighestAcceptableAddress, - IN PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL, - IN MEMORY_CACHING_TYPE CacheType); + IN SIZE_T NumberOfBytes, + IN PHYSICAL_ADDRESS LowestAcceptableAddress, + IN PHYSICAL_ADDRESS HighestAcceptableAddress, + IN PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL, + IN MEMORY_CACHING_TYPE CacheType); NTKERNELAPI PMDL NTAPI MmAllocatePagesForMdl( - IN PHYSICAL_ADDRESS LowAddress, - IN PHYSICAL_ADDRESS HighAddress, - IN PHYSICAL_ADDRESS SkipBytes, - IN SIZE_T TotalBytes); + IN PHYSICAL_ADDRESS LowAddress, + IN PHYSICAL_ADDRESS HighAddress, + IN PHYSICAL_ADDRESS SkipBytes, + IN SIZE_T TotalBytes); NTKERNELAPI VOID NTAPI MmBuildMdlForNonPagedPool( - IN OUT PMDLX MemoryDescriptorList); + IN OUT PMDLX MemoryDescriptorList); //DECLSPEC_DEPRECATED_DDK NTKERNELAPI PMDL NTAPI MmCreateMdl( - IN PMDL MemoryDescriptorList OPTIONAL, - IN PVOID Base, - IN SIZE_T Length); + IN PMDL MemoryDescriptorList OPTIONAL, + IN PVOID Base, + IN SIZE_T Length); NTKERNELAPI VOID NTAPI MmFreeContiguousMemory( - IN PVOID BaseAddress); + IN PVOID BaseAddress); NTKERNELAPI VOID NTAPI MmFreeContiguousMemorySpecifyCache( - IN PVOID BaseAddress, - IN SIZE_T NumberOfBytes, - IN MEMORY_CACHING_TYPE CacheType); + IN PVOID BaseAddress, + IN SIZE_T NumberOfBytes, + IN MEMORY_CACHING_TYPE CacheType); NTKERNELAPI VOID @@ -7819,7 +10766,7 @@ NTKERNELAPI PVOID NTAPI MmGetSystemRoutineAddress( - IN PUNICODE_STRING SystemRoutineName); + IN PUNICODE_STRING SystemRoutineName); NTKERNELAPI LOGICAL @@ -7831,22 +10778,22 @@ NTKERNELAPI PVOID NTAPI MmLockPagableDataSection( - IN PVOID AddressWithinSection); + IN PVOID AddressWithinSection); NTKERNELAPI PVOID NTAPI MmMapIoSpace( - IN PHYSICAL_ADDRESS PhysicalAddress, - IN SIZE_T NumberOfBytes, - IN MEMORY_CACHING_TYPE CacheEnable); + IN PHYSICAL_ADDRESS PhysicalAddress, + IN SIZE_T NumberOfBytes, + IN MEMORY_CACHING_TYPE CacheEnable); NTKERNELAPI PVOID NTAPI MmMapLockedPages( - IN PMDL MemoryDescriptorList, - IN KPROCESSOR_MODE AccessMode); + IN PMDL MemoryDescriptorList, + IN KPROCESSOR_MODE AccessMode); NTKERNELAPI PVOID @@ -7863,71 +10810,81 @@ NTKERNELAPI PVOID NTAPI MmPageEntireDriver( - IN PVOID AddressWithinSection); + IN PVOID AddressWithinSection); NTKERNELAPI VOID NTAPI MmProbeAndLockPages( - IN OUT PMDL MemoryDescriptorList, - IN KPROCESSOR_MODE AccessMode, - IN LOCK_OPERATION Operation); + IN OUT PMDL MemoryDescriptorList, + IN KPROCESSOR_MODE AccessMode, + IN LOCK_OPERATION Operation); NTKERNELAPI MM_SYSTEMSIZE NTAPI -MmQuerySystemSize( - VOID); +MmQuerySystemSize(VOID); NTKERNELAPI VOID NTAPI MmResetDriverPaging( - IN PVOID AddressWithinSection); + IN PVOID AddressWithinSection); NTKERNELAPI SIZE_T NTAPI MmSizeOfMdl( - IN PVOID Base, - IN SIZE_T Length); + IN PVOID Base, + IN SIZE_T Length); NTKERNELAPI VOID NTAPI MmUnlockPagableImageSection( - IN PVOID ImageSectionHandle); + IN PVOID ImageSectionHandle); NTKERNELAPI VOID NTAPI MmUnlockPages( - IN OUT PMDL MemoryDescriptorList); + IN OUT PMDL MemoryDescriptorList); NTKERNELAPI VOID NTAPI MmUnmapIoSpace( - IN PVOID BaseAddress, - IN SIZE_T NumberOfBytes); + IN PVOID BaseAddress, + IN SIZE_T NumberOfBytes); NTKERNELAPI VOID NTAPI MmProbeAndLockProcessPages( - IN OUT PMDL MemoryDescriptorList, - IN PEPROCESS Process, - IN KPROCESSOR_MODE AccessMode, - IN LOCK_OPERATION Operation); + IN OUT PMDL MemoryDescriptorList, + IN PEPROCESS Process, + IN KPROCESSOR_MODE AccessMode, + IN LOCK_OPERATION Operation); NTKERNELAPI VOID NTAPI MmUnmapLockedPages( - IN PVOID BaseAddress, - IN PMDL MemoryDescriptorList); + IN PVOID BaseAddress, + IN PMDL MemoryDescriptorList); -#endif +NTKERNELAPI +PVOID +NTAPI +MmAllocateContiguousMemorySpecifyCacheNode( + IN SIZE_T NumberOfBytes, + IN PHYSICAL_ADDRESS LowestAcceptableAddress, + IN PHYSICAL_ADDRESS HighestAcceptableAddress, + IN PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL, + IN MEMORY_CACHING_TYPE CacheType, + IN NODE_REQUIREMENT PreferredNode); + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ #if (NTDDI_VERSION >= NTDDI_WINXP) @@ -7935,53 +10892,69 @@ NTKERNELAPI NTSTATUS NTAPI MmAdvanceMdl( - IN OUT PMDL Mdl, - IN ULONG NumberOfBytes); + IN OUT PMDL Mdl, + IN ULONG NumberOfBytes); NTKERNELAPI PVOID NTAPI MmAllocateMappingAddress( - IN SIZE_T NumberOfBytes, - IN ULONG PoolTag); + IN SIZE_T NumberOfBytes, + IN ULONG PoolTag); NTKERNELAPI VOID NTAPI MmFreeMappingAddress( - IN PVOID BaseAddress, - IN ULONG PoolTag); + IN PVOID BaseAddress, + IN ULONG PoolTag); NTKERNELAPI NTSTATUS NTAPI MmIsVerifierEnabled( - OUT PULONG VerifierFlags); + OUT PULONG VerifierFlags); NTKERNELAPI PVOID NTAPI MmMapLockedPagesWithReservedMapping( - IN PVOID MappingAddress, - IN ULONG PoolTag, - IN PMDL MemoryDescriptorList, - IN MEMORY_CACHING_TYPE CacheType); + IN PVOID MappingAddress, + IN ULONG PoolTag, + IN PMDL MemoryDescriptorList, + IN MEMORY_CACHING_TYPE CacheType); NTKERNELAPI NTSTATUS NTAPI MmProtectMdlSystemAddress( - IN PMDL MemoryDescriptorList, - IN ULONG NewProtect); + IN PMDL MemoryDescriptorList, + IN ULONG NewProtect); NTKERNELAPI VOID NTAPI MmUnmapReservedMapping( - IN PVOID BaseAddress, - IN ULONG PoolTag, - IN PMDL MemoryDescriptorList); + IN PVOID BaseAddress, + IN ULONG PoolTag, + IN PMDL MemoryDescriptorList); +NTKERNELAPI +NTSTATUS +NTAPI +MmAddVerifierThunks( + IN PVOID ThunkBuffer, + IN ULONG ThunkBufferSize); + +#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ + +#if (NTDDI_VERSION >= NTDDI_WS03) +NTKERNELAPI +LOGICAL +NTAPI +MmIsIoSpaceActive( + IN PHYSICAL_ADDRESS StartAddress, + IN SIZE_T NumberOfBytes); #endif #if (NTDDI_VERSION >= NTDDI_WS03SP1) @@ -7997,6 +10970,15 @@ MmAllocatePagesForMdlEx( IN ULONG Flags); #endif +#if (NTDDI_VERSION >= NTDDI_VISTA) + +NTKERNELAPI +LOGICAL +NTAPI +MmIsDriverVerifyingByAddress( + IN PVOID AddressWithinSection); +#endif + /****************************************************************************** * Security Manager Functions * ******************************************************************************/ @@ -8007,42 +10989,42 @@ NTKERNELAPI BOOLEAN NTAPI SeAccessCheck( - IN PSECURITY_DESCRIPTOR SecurityDescriptor, - IN PSECURITY_SUBJECT_CONTEXT SubjectSecurityContext, - IN BOOLEAN SubjectContextLocked, - IN ACCESS_MASK DesiredAccess, - IN ACCESS_MASK PreviouslyGrantedAccess, - OUT PPRIVILEGE_SET *Privileges OPTIONAL, - IN PGENERIC_MAPPING GenericMapping, - IN KPROCESSOR_MODE AccessMode, - OUT PACCESS_MASK GrantedAccess, - OUT PNTSTATUS AccessStatus); + IN PSECURITY_DESCRIPTOR SecurityDescriptor, + IN PSECURITY_SUBJECT_CONTEXT SubjectSecurityContext, + IN BOOLEAN SubjectContextLocked, + IN ACCESS_MASK DesiredAccess, + IN ACCESS_MASK PreviouslyGrantedAccess, + OUT PPRIVILEGE_SET *Privileges OPTIONAL, + IN PGENERIC_MAPPING GenericMapping, + IN KPROCESSOR_MODE AccessMode, + OUT PACCESS_MASK GrantedAccess, + OUT PNTSTATUS AccessStatus); NTKERNELAPI NTSTATUS NTAPI SeAssignSecurity( - IN PSECURITY_DESCRIPTOR ParentDescriptor OPTIONAL, - IN PSECURITY_DESCRIPTOR ExplicitDescriptor OPTIONAL, - OUT PSECURITY_DESCRIPTOR *NewDescriptor, - IN BOOLEAN IsDirectoryObject, - IN PSECURITY_SUBJECT_CONTEXT SubjectContext, - IN PGENERIC_MAPPING GenericMapping, - IN POOL_TYPE PoolType); + IN PSECURITY_DESCRIPTOR ParentDescriptor OPTIONAL, + IN PSECURITY_DESCRIPTOR ExplicitDescriptor OPTIONAL, + OUT PSECURITY_DESCRIPTOR *NewDescriptor, + IN BOOLEAN IsDirectoryObject, + IN PSECURITY_SUBJECT_CONTEXT SubjectContext, + IN PGENERIC_MAPPING GenericMapping, + IN POOL_TYPE PoolType); NTKERNELAPI NTSTATUS NTAPI SeAssignSecurityEx( - IN PSECURITY_DESCRIPTOR ParentDescriptor OPTIONAL, - IN PSECURITY_DESCRIPTOR ExplicitDescriptor OPTIONAL, - OUT PSECURITY_DESCRIPTOR *NewDescriptor, - IN GUID *ObjectType OPTIONAL, - IN BOOLEAN IsDirectoryObject, - IN ULONG AutoInheritFlags, - IN PSECURITY_SUBJECT_CONTEXT SubjectContext, - IN PGENERIC_MAPPING GenericMapping, - IN POOL_TYPE PoolType); + IN PSECURITY_DESCRIPTOR ParentDescriptor OPTIONAL, + IN PSECURITY_DESCRIPTOR ExplicitDescriptor OPTIONAL, + OUT PSECURITY_DESCRIPTOR *NewDescriptor, + IN GUID *ObjectType OPTIONAL, + IN BOOLEAN IsDirectoryObject, + IN ULONG AutoInheritFlags, + IN PSECURITY_SUBJECT_CONTEXT SubjectContext, + IN PGENERIC_MAPPING GenericMapping, + IN POOL_TYPE PoolType); NTKERNELAPI NTSTATUS @@ -8129,7 +11111,6 @@ SeGetWorldRights( #endif /* SE_NTFS_WORLD_CACHE */ #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ - /****************************************************************************** * Configuration Manager Functions * ******************************************************************************/ @@ -8139,22 +11120,103 @@ NTKERNELAPI NTSTATUS NTAPI CmRegisterCallback( - IN PEX_CALLBACK_FUNCTION Function, - IN PVOID Context OPTIONAL, - OUT PLARGE_INTEGER Cookie); + IN PEX_CALLBACK_FUNCTION Function, + IN PVOID Context OPTIONAL, + OUT PLARGE_INTEGER Cookie); NTKERNELAPI NTSTATUS NTAPI CmUnRegisterCallback( - IN LARGE_INTEGER Cookie); + IN LARGE_INTEGER Cookie); #endif +#if (NTDDI_VERSION >= NTDDI_VISTA) + +NTKERNELAPI +NTSTATUS +NTAPI +CmRegisterCallbackEx( + PEX_CALLBACK_FUNCTION Function, + PCUNICODE_STRING Altitude, + PVOID Driver, + PVOID Context, + PLARGE_INTEGER Cookie, + PVOID Reserved); + +NTKERNELAPI +VOID +NTAPI +CmGetCallbackVersion( + OUT PULONG Major OPTIONAL, + OUT PULONG Minor OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +CmSetCallbackObjectContext( + IN OUT PVOID Object, + IN PLARGE_INTEGER Cookie, + IN PVOID NewContext, + OUT PVOID *OldContext OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +CmCallbackGetKeyObjectID( + IN PLARGE_INTEGER Cookie, + IN PVOID Object, + OUT PULONG_PTR ObjectID OPTIONAL, + OUT PCUNICODE_STRING *ObjectName OPTIONAL); + +NTKERNELAPI +PVOID +NTAPI +CmGetBoundTransaction( + IN PLARGE_INTEGER Cookie, + IN PVOID Object); + +#endif // NTDDI_VERSION >= NTDDI_VISTA + /****************************************************************************** * I/O Manager Functions * ******************************************************************************/ + +/* + * NTSTATUS + * IoAcquireRemoveLock( + * IN PIO_REMOVE_LOCK RemoveLock, + * IN OPTIONAL PVOID Tag) + */ +#if DBG +#define IoAcquireRemoveLock(RemoveLock, Tag) \ + IoAcquireRemoveLockEx(RemoveLock, Tag, __FILE__, __LINE__, sizeof (IO_REMOVE_LOCK)) +#else +#define IoAcquireRemoveLock(RemoveLock, Tag) \ + IoAcquireRemoveLockEx(RemoveLock, Tag, "", 1, sizeof (IO_REMOVE_LOCK)) +#endif + +/* + * VOID + * IoAdjustPagingPathCount( + * IN PLONG Count, + * IN BOOLEAN Increment) + */ +#define IoAdjustPagingPathCount(_Count, \ + _Increment) \ +{ \ + if (_Increment) \ + { \ + InterlockedIncrement(_Count); \ + } \ + else \ + { \ + InterlockedDecrement(_Count); \ + } \ +} + #if !defined(_M_AMD64) NTHALAPI VOID @@ -8297,9 +11359,9 @@ NTKERNELAPI VOID NTAPI WRITE_REGISTER_BUFFER_ULONG( - IN PULONG Register, - IN PULONG Buffer, - IN ULONG Count); + IN PULONG Register, + IN PULONG Buffer, + IN ULONG Count); NTKERNELAPI VOID @@ -8327,8 +11389,8 @@ NTKERNELAPI VOID NTAPI WRITE_REGISTER_USHORT( - IN PUSHORT Register, - IN USHORT Value); + IN PUSHORT Register, + IN USHORT Value); #else @@ -8339,17 +11401,17 @@ READ_PORT_BUFFER_UCHAR( IN PUCHAR Buffer, IN ULONG Count) { - __inbytestring((USHORT)(ULONG_PTR)Port, Buffer, Count); + __inbytestring((USHORT)(ULONG_PTR)Port, Buffer, Count); } FORCEINLINE VOID READ_PORT_BUFFER_ULONG( - IN PULONG Port, - IN PULONG Buffer, - IN ULONG Count) + IN PULONG Port, + IN PULONG Buffer, + IN ULONG Count) { - __indwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count); + __indwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count); } FORCEINLINE @@ -8359,7 +11421,7 @@ READ_PORT_BUFFER_USHORT( IN PUSHORT Buffer, IN ULONG Count) { - __inwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count); + __inwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count); } FORCEINLINE @@ -8367,7 +11429,7 @@ UCHAR READ_PORT_UCHAR( IN PUCHAR Port) { - return __inbyte((USHORT)(ULONG_PTR)Port); + return __inbyte((USHORT)(ULONG_PTR)Port); } FORCEINLINE @@ -8375,7 +11437,7 @@ ULONG READ_PORT_ULONG( IN PULONG Port) { - return __indword((USHORT)(ULONG_PTR)Port); + return __indword((USHORT)(ULONG_PTR)Port); } FORCEINLINE @@ -8383,7 +11445,7 @@ USHORT READ_PORT_USHORT( IN PUSHORT Port) { - return __inword((USHORT)(ULONG_PTR)Port); + return __inword((USHORT)(ULONG_PTR)Port); } FORCEINLINE @@ -8393,27 +11455,27 @@ READ_REGISTER_BUFFER_UCHAR( IN PUCHAR Buffer, IN ULONG Count) { - __movsb(Register, Buffer, Count); + __movsb(Register, Buffer, Count); } FORCEINLINE VOID READ_REGISTER_BUFFER_ULONG( - IN PULONG Register, - IN PULONG Buffer, - IN ULONG Count) + IN PULONG Register, + IN PULONG Buffer, + IN ULONG Count) { - __movsd(Register, Buffer, Count); + __movsd(Register, Buffer, Count); } FORCEINLINE VOID READ_REGISTER_BUFFER_USHORT( - IN PUSHORT Register, - IN PUSHORT Buffer, - IN ULONG Count) + IN PUSHORT Register, + IN PUSHORT Buffer, + IN ULONG Count) { - __movsw(Register, Buffer, Count); + __movsw(Register, Buffer, Count); } FORCEINLINE @@ -8421,7 +11483,7 @@ UCHAR READ_REGISTER_UCHAR( IN volatile UCHAR *Register) { - return *Register; + return *Register; } FORCEINLINE @@ -8429,7 +11491,7 @@ ULONG READ_REGISTER_ULONG( IN volatile ULONG *Register) { - return *Register; + return *Register; } FORCEINLINE @@ -8437,7 +11499,7 @@ USHORT READ_REGISTER_USHORT( IN volatile USHORT *Register) { - return *Register; + return *Register; } FORCEINLINE @@ -8447,7 +11509,7 @@ WRITE_PORT_BUFFER_UCHAR( IN PUCHAR Buffer, IN ULONG Count) { - __outbytestring((USHORT)(ULONG_PTR)Port, Buffer, Count); + __outbytestring((USHORT)(ULONG_PTR)Port, Buffer, Count); } FORCEINLINE @@ -8457,7 +11519,7 @@ WRITE_PORT_BUFFER_ULONG( IN PULONG Buffer, IN ULONG Count) { - __outdwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count); + __outdwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count); } FORCEINLINE @@ -8467,7 +11529,7 @@ WRITE_PORT_BUFFER_USHORT( IN PUSHORT Buffer, IN ULONG Count) { - __outwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count); + __outwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count); } FORCEINLINE @@ -8476,7 +11538,7 @@ WRITE_PORT_UCHAR( IN PUCHAR Port, IN UCHAR Value) { - __outbyte((USHORT)(ULONG_PTR)Port, Value); + __outbyte((USHORT)(ULONG_PTR)Port, Value); } FORCEINLINE @@ -8485,7 +11547,7 @@ WRITE_PORT_ULONG( IN PULONG Port, IN ULONG Value) { - __outdword((USHORT)(ULONG_PTR)Port, Value); + __outdword((USHORT)(ULONG_PTR)Port, Value); } FORCEINLINE @@ -8494,7 +11556,7 @@ WRITE_PORT_USHORT( IN PUSHORT Port, IN USHORT Value) { - __outword((USHORT)(ULONG_PTR)Port, Value); + __outword((USHORT)(ULONG_PTR)Port, Value); } FORCEINLINE @@ -8504,9 +11566,9 @@ WRITE_REGISTER_BUFFER_UCHAR( IN PUCHAR Buffer, IN ULONG Count) { - LONG Synch; - __movsb(Register, Buffer, Count); - InterlockedOr(&Synch, 1); + LONG Synch; + __movsb(Register, Buffer, Count); + InterlockedOr(&Synch, 1); } FORCEINLINE @@ -8516,9 +11578,9 @@ WRITE_REGISTER_BUFFER_ULONG( IN PULONG Buffer, IN ULONG Count) { - LONG Synch; - __movsd(Register, Buffer, Count); - InterlockedOr(&Synch, 1); + LONG Synch; + __movsd(Register, Buffer, Count); + InterlockedOr(&Synch, 1); } FORCEINLINE @@ -8528,9 +11590,9 @@ WRITE_REGISTER_BUFFER_USHORT( IN PUSHORT Buffer, IN ULONG Count) { - LONG Synch; - __movsw(Register, Buffer, Count); - InterlockedOr(&Synch, 1); + LONG Synch; + __movsw(Register, Buffer, Count); + InterlockedOr(&Synch, 1); } FORCEINLINE @@ -8539,9 +11601,9 @@ WRITE_REGISTER_UCHAR( IN volatile UCHAR *Register, IN UCHAR Value) { - LONG Synch; - *Register = Value; - InterlockedOr(&Synch, 1); + LONG Synch; + *Register = Value; + InterlockedOr(&Synch, 1); } FORCEINLINE @@ -8550,9 +11612,9 @@ WRITE_REGISTER_ULONG( IN volatile ULONG *Register, IN ULONG Value) { - LONG Synch; - *Register = Value; - InterlockedOr(&Synch, 1); + LONG Synch; + *Register = Value; + InterlockedOr(&Synch, 1); } FORCEINLINE @@ -8561,9 +11623,9 @@ WRITE_REGISTER_USHORT( IN volatile USHORT *Register, IN USHORT Value) { - LONG Sync; - *Register = Value; - InterlockedOr(&Sync, 1); + LONG Sync; + *Register = Value; + InterlockedOr(&Sync, 1); } #endif @@ -8575,254 +11637,218 @@ WRITE_REGISTER_USHORT( FORCEINLINE NTSTATUS IoAllocateAdapterChannel( - IN PDMA_ADAPTER DmaAdapter, - IN PDEVICE_OBJECT DeviceObject, - IN ULONG NumberOfMapRegisters, - IN PDRIVER_CONTROL ExecutionRoutine, - IN PVOID Context) + IN PDMA_ADAPTER DmaAdapter, + IN PDEVICE_OBJECT DeviceObject, + IN ULONG NumberOfMapRegisters, + IN PDRIVER_CONTROL ExecutionRoutine, + IN PVOID Context) { - PALLOCATE_ADAPTER_CHANNEL AllocateAdapterChannel; - AllocateAdapterChannel = - *(DmaAdapter)->DmaOperations->AllocateAdapterChannel; - ASSERT(AllocateAdapterChannel); - return AllocateAdapterChannel(DmaAdapter, - DeviceObject, - NumberOfMapRegisters, - ExecutionRoutine, - Context ); + PALLOCATE_ADAPTER_CHANNEL AllocateAdapterChannel; + AllocateAdapterChannel = + *(DmaAdapter)->DmaOperations->AllocateAdapterChannel; + ASSERT(AllocateAdapterChannel); + return AllocateAdapterChannel(DmaAdapter, + DeviceObject, + NumberOfMapRegisters, + ExecutionRoutine, + Context ); } FORCEINLINE BOOLEAN NTAPI IoFlushAdapterBuffers( - IN PDMA_ADAPTER DmaAdapter, - IN PMDL Mdl, - IN PVOID MapRegisterBase, - IN PVOID CurrentVa, - IN ULONG Length, - IN BOOLEAN WriteToDevice) + IN PDMA_ADAPTER DmaAdapter, + IN PMDL Mdl, + IN PVOID MapRegisterBase, + IN PVOID CurrentVa, + IN ULONG Length, + IN BOOLEAN WriteToDevice) { - PFLUSH_ADAPTER_BUFFERS FlushAdapterBuffers; - FlushAdapterBuffers = *(DmaAdapter)->DmaOperations->FlushAdapterBuffers; - ASSERT(FlushAdapterBuffers); - return FlushAdapterBuffers(DmaAdapter, - Mdl, - MapRegisterBase, - CurrentVa, - Length, - WriteToDevice); + PFLUSH_ADAPTER_BUFFERS FlushAdapterBuffers; + FlushAdapterBuffers = *(DmaAdapter)->DmaOperations->FlushAdapterBuffers; + ASSERT(FlushAdapterBuffers); + return FlushAdapterBuffers(DmaAdapter, + Mdl, + MapRegisterBase, + CurrentVa, + Length, + WriteToDevice); } FORCEINLINE VOID NTAPI IoFreeAdapterChannel( - IN PDMA_ADAPTER DmaAdapter) + IN PDMA_ADAPTER DmaAdapter) { - PFREE_ADAPTER_CHANNEL FreeAdapterChannel; - FreeAdapterChannel = *(DmaAdapter)->DmaOperations->FreeAdapterChannel; - ASSERT(FreeAdapterChannel); - FreeAdapterChannel(DmaAdapter); + PFREE_ADAPTER_CHANNEL FreeAdapterChannel; + FreeAdapterChannel = *(DmaAdapter)->DmaOperations->FreeAdapterChannel; + ASSERT(FreeAdapterChannel); + FreeAdapterChannel(DmaAdapter); } FORCEINLINE VOID NTAPI IoFreeMapRegisters( - IN PDMA_ADAPTER DmaAdapter, - IN PVOID MapRegisterBase, - IN ULONG NumberOfMapRegisters) + IN PDMA_ADAPTER DmaAdapter, + IN PVOID MapRegisterBase, + IN ULONG NumberOfMapRegisters) { - PFREE_MAP_REGISTERS FreeMapRegisters; - FreeMapRegisters = *(DmaAdapter)->DmaOperations->FreeMapRegisters; - ASSERT(FreeMapRegisters); - FreeMapRegisters(DmaAdapter, MapRegisterBase, NumberOfMapRegisters); + PFREE_MAP_REGISTERS FreeMapRegisters; + FreeMapRegisters = *(DmaAdapter)->DmaOperations->FreeMapRegisters; + ASSERT(FreeMapRegisters); + FreeMapRegisters(DmaAdapter, MapRegisterBase, NumberOfMapRegisters); } FORCEINLINE PHYSICAL_ADDRESS NTAPI IoMapTransfer( - IN PDMA_ADAPTER DmaAdapter, - IN PMDL Mdl, - IN PVOID MapRegisterBase, - IN PVOID CurrentVa, - IN OUT PULONG Length, - IN BOOLEAN WriteToDevice) + IN PDMA_ADAPTER DmaAdapter, + IN PMDL Mdl, + IN PVOID MapRegisterBase, + IN PVOID CurrentVa, + IN OUT PULONG Length, + IN BOOLEAN WriteToDevice) { - PMAP_TRANSFER MapTransfer; + PMAP_TRANSFER MapTransfer; - MapTransfer = *(DmaAdapter)->DmaOperations->MapTransfer; - ASSERT(MapTransfer); - return MapTransfer(DmaAdapter, - Mdl, - MapRegisterBase, - CurrentVa, - Length, - WriteToDevice); + MapTransfer = *(DmaAdapter)->DmaOperations->MapTransfer; + ASSERT(MapTransfer); + return MapTransfer(DmaAdapter, + Mdl, + MapRegisterBase, + CurrentVa, + Length, + WriteToDevice); } #endif #if (NTDDI_VERSION >= NTDDI_WIN2K) + NTKERNELAPI VOID NTAPI IoAcquireCancelSpinLock( - OUT PKIRQL Irql); + OUT PKIRQL Irql); NTKERNELAPI NTSTATUS NTAPI IoAcquireRemoveLockEx( - IN PIO_REMOVE_LOCK RemoveLock, - IN PVOID Tag OPTIONAL, - IN PCSTR File, - IN ULONG Line, - IN ULONG RemlockSize); -#endif - -/* - * NTSTATUS - * IoAcquireRemoveLock( - * IN PIO_REMOVE_LOCK RemoveLock, - * IN OPTIONAL PVOID Tag) - */ -#if DBG -#define IoAcquireRemoveLock(RemoveLock, Tag) \ - IoAcquireRemoveLockEx(RemoveLock, Tag, __FILE__, __LINE__, sizeof (IO_REMOVE_LOCK)) -#else -#define IoAcquireRemoveLock(RemoveLock, Tag) \ - IoAcquireRemoveLockEx(RemoveLock, Tag, "", 1, sizeof (IO_REMOVE_LOCK)) -#endif - -/* - * VOID - * IoAdjustPagingPathCount( - * IN PLONG Count, - * IN BOOLEAN Increment) - */ -#define IoAdjustPagingPathCount(_Count, \ - _Increment) \ -{ \ - if (_Increment) \ - { \ - InterlockedIncrement(_Count); \ - } \ - else \ - { \ - InterlockedDecrement(_Count); \ - } \ -} - -#if (NTDDI_VERSION >= NTDDI_WIN2K) - + IN PIO_REMOVE_LOCK RemoveLock, + IN PVOID Tag OPTIONAL, + IN PCSTR File, + IN ULONG Line, + IN ULONG RemlockSize); NTKERNELAPI NTSTATUS NTAPI IoAllocateDriverObjectExtension( - IN PDRIVER_OBJECT DriverObject, - IN PVOID ClientIdentificationAddress, - IN ULONG DriverObjectExtensionSize, - OUT PVOID *DriverObjectExtension); + IN PDRIVER_OBJECT DriverObject, + IN PVOID ClientIdentificationAddress, + IN ULONG DriverObjectExtensionSize, + OUT PVOID *DriverObjectExtension); NTKERNELAPI PVOID NTAPI IoAllocateErrorLogEntry( - IN PVOID IoObject, - IN UCHAR EntrySize); + IN PVOID IoObject, + IN UCHAR EntrySize); NTKERNELAPI PIRP NTAPI IoAllocateIrp( - IN CCHAR StackSize, - IN BOOLEAN ChargeQuota); + IN CCHAR StackSize, + IN BOOLEAN ChargeQuota); NTKERNELAPI PMDL NTAPI IoAllocateMdl( - IN PVOID VirtualAddress OPTIONAL, - IN ULONG Length, - IN BOOLEAN SecondaryBuffer, - IN BOOLEAN ChargeQuota, - IN OUT PIRP Irp OPTIONAL); + IN PVOID VirtualAddress OPTIONAL, + IN ULONG Length, + IN BOOLEAN SecondaryBuffer, + IN BOOLEAN ChargeQuota, + IN OUT PIRP Irp OPTIONAL); NTKERNELAPI PIO_WORKITEM NTAPI IoAllocateWorkItem( - IN PDEVICE_OBJECT DeviceObject); + IN PDEVICE_OBJECT DeviceObject); NTKERNELAPI NTSTATUS NTAPI IoAttachDevice( - IN PDEVICE_OBJECT SourceDevice, - IN PUNICODE_STRING TargetDevice, - OUT PDEVICE_OBJECT *AttachedDevice); + IN PDEVICE_OBJECT SourceDevice, + IN PUNICODE_STRING TargetDevice, + OUT PDEVICE_OBJECT *AttachedDevice); NTKERNELAPI PDEVICE_OBJECT NTAPI IoAttachDeviceToDeviceStack( - IN PDEVICE_OBJECT SourceDevice, - IN PDEVICE_OBJECT TargetDevice); + IN PDEVICE_OBJECT SourceDevice, + IN PDEVICE_OBJECT TargetDevice); NTKERNELAPI PIRP NTAPI IoBuildAsynchronousFsdRequest( - IN ULONG MajorFunction, - IN PDEVICE_OBJECT DeviceObject, - IN OUT PVOID Buffer OPTIONAL, - IN ULONG Length OPTIONAL, - IN PLARGE_INTEGER StartingOffset OPTIONAL, - IN PIO_STATUS_BLOCK IoStatusBlock OPTIONAL); + IN ULONG MajorFunction, + IN PDEVICE_OBJECT DeviceObject, + IN OUT PVOID Buffer OPTIONAL, + IN ULONG Length OPTIONAL, + IN PLARGE_INTEGER StartingOffset OPTIONAL, + IN PIO_STATUS_BLOCK IoStatusBlock OPTIONAL); NTKERNELAPI PIRP NTAPI IoBuildDeviceIoControlRequest( - IN ULONG IoControlCode, - IN PDEVICE_OBJECT DeviceObject, - IN PVOID InputBuffer OPTIONAL, - IN ULONG InputBufferLength, - OUT PVOID OutputBuffer OPTIONAL, - IN ULONG OutputBufferLength, - IN BOOLEAN InternalDeviceIoControl, - IN PKEVENT Event, - OUT PIO_STATUS_BLOCK IoStatusBlock); + IN ULONG IoControlCode, + IN PDEVICE_OBJECT DeviceObject, + IN PVOID InputBuffer OPTIONAL, + IN ULONG InputBufferLength, + OUT PVOID OutputBuffer OPTIONAL, + IN ULONG OutputBufferLength, + IN BOOLEAN InternalDeviceIoControl, + IN PKEVENT Event, + OUT PIO_STATUS_BLOCK IoStatusBlock); NTKERNELAPI VOID NTAPI IoBuildPartialMdl( - IN PMDL SourceMdl, - IN OUT PMDL TargetMdl, - IN PVOID VirtualAddress, - IN ULONG Length); + IN PMDL SourceMdl, + IN OUT PMDL TargetMdl, + IN PVOID VirtualAddress, + IN ULONG Length); NTKERNELAPI PIRP NTAPI IoBuildSynchronousFsdRequest( - IN ULONG MajorFunction, - IN PDEVICE_OBJECT DeviceObject, - IN OUT PVOID Buffer OPTIONAL, - IN ULONG Length OPTIONAL, - IN PLARGE_INTEGER StartingOffset OPTIONAL, - IN PKEVENT Event, - OUT PIO_STATUS_BLOCK IoStatusBlock); + IN ULONG MajorFunction, + IN PDEVICE_OBJECT DeviceObject, + IN OUT PVOID Buffer OPTIONAL, + IN ULONG Length OPTIONAL, + IN PLARGE_INTEGER StartingOffset OPTIONAL, + IN PKEVENT Event, + OUT PIO_STATUS_BLOCK IoStatusBlock); NTKERNELAPI NTSTATUS FASTCALL IofCallDriver( - IN PDEVICE_OBJECT DeviceObject, - IN OUT PIRP Irp); + IN PDEVICE_OBJECT DeviceObject, + IN OUT PIRP Irp); #define IoCallDriver IofCallDriver NTKERNELAPI @@ -8837,52 +11863,52 @@ NTKERNELAPI BOOLEAN NTAPI IoCancelIrp( - IN PIRP Irp); + IN PIRP Irp); NTKERNELAPI NTSTATUS NTAPI IoCheckShareAccess( - IN ACCESS_MASK DesiredAccess, - IN ULONG DesiredShareAccess, - IN OUT PFILE_OBJECT FileObject, - IN OUT PSHARE_ACCESS ShareAccess, - IN BOOLEAN Update); + IN ACCESS_MASK DesiredAccess, + IN ULONG DesiredShareAccess, + IN OUT PFILE_OBJECT FileObject, + IN OUT PSHARE_ACCESS ShareAccess, + IN BOOLEAN Update); NTKERNELAPI VOID FASTCALL IofCompleteRequest( - IN PIRP Irp, - IN CCHAR PriorityBoost); + IN PIRP Irp, + IN CCHAR PriorityBoost); NTKERNELAPI NTSTATUS NTAPI IoConnectInterrupt( - OUT PKINTERRUPT *InterruptObject, - IN PKSERVICE_ROUTINE ServiceRoutine, - IN PVOID ServiceContext OPTIONAL, - IN PKSPIN_LOCK SpinLock OPTIONAL, - IN ULONG Vector, - IN KIRQL Irql, - IN KIRQL SynchronizeIrql, - IN KINTERRUPT_MODE InterruptMode, - IN BOOLEAN ShareVector, - IN KAFFINITY ProcessorEnableMask, - IN BOOLEAN FloatingSave); + OUT PKINTERRUPT *InterruptObject, + IN PKSERVICE_ROUTINE ServiceRoutine, + IN PVOID ServiceContext OPTIONAL, + IN PKSPIN_LOCK SpinLock OPTIONAL, + IN ULONG Vector, + IN KIRQL Irql, + IN KIRQL SynchronizeIrql, + IN KINTERRUPT_MODE InterruptMode, + IN BOOLEAN ShareVector, + IN KAFFINITY ProcessorEnableMask, + IN BOOLEAN FloatingSave); NTKERNELAPI NTSTATUS NTAPI IoCreateDevice( - IN PDRIVER_OBJECT DriverObject, - IN ULONG DeviceExtensionSize, - IN PUNICODE_STRING DeviceName OPTIONAL, - IN DEVICE_TYPE DeviceType, - IN ULONG DeviceCharacteristics, - IN BOOLEAN Exclusive, - OUT PDEVICE_OBJECT *DeviceObject); + IN PDRIVER_OBJECT DriverObject, + IN ULONG DeviceExtensionSize, + IN PUNICODE_STRING DeviceName OPTIONAL, + IN DEVICE_TYPE DeviceType, + IN ULONG DeviceCharacteristics, + IN BOOLEAN Exclusive, + OUT PDEVICE_OBJECT *DeviceObject); NTKERNELAPI NTSTATUS @@ -8907,53 +11933,53 @@ NTKERNELAPI PKEVENT NTAPI IoCreateNotificationEvent( - IN PUNICODE_STRING EventName, - OUT PHANDLE EventHandle); + IN PUNICODE_STRING EventName, + OUT PHANDLE EventHandle); NTKERNELAPI NTSTATUS NTAPI IoCreateSymbolicLink( - IN PUNICODE_STRING SymbolicLinkName, - IN PUNICODE_STRING DeviceName); + IN PUNICODE_STRING SymbolicLinkName, + IN PUNICODE_STRING DeviceName); NTKERNELAPI PKEVENT NTAPI IoCreateSynchronizationEvent( - IN PUNICODE_STRING EventName, - OUT PHANDLE EventHandle); + IN PUNICODE_STRING EventName, + OUT PHANDLE EventHandle); NTKERNELAPI NTSTATUS NTAPI IoCreateUnprotectedSymbolicLink( - IN PUNICODE_STRING SymbolicLinkName, - IN PUNICODE_STRING DeviceName); + IN PUNICODE_STRING SymbolicLinkName, + IN PUNICODE_STRING DeviceName); NTKERNELAPI VOID NTAPI IoDeleteDevice( - IN PDEVICE_OBJECT DeviceObject); + IN PDEVICE_OBJECT DeviceObject); NTKERNELAPI NTSTATUS NTAPI IoDeleteSymbolicLink( - IN PUNICODE_STRING SymbolicLinkName); + IN PUNICODE_STRING SymbolicLinkName); NTKERNELAPI VOID NTAPI IoDetachDevice( - IN OUT PDEVICE_OBJECT TargetDevice); + IN OUT PDEVICE_OBJECT TargetDevice); NTKERNELAPI VOID NTAPI IoDisconnectInterrupt( - IN PKINTERRUPT InterruptObject); + IN PKINTERRUPT InterruptObject); NTKERNELAPI VOID @@ -8983,359 +12009,375 @@ NTKERNELAPI PDEVICE_OBJECT NTAPI IoGetAttachedDeviceReference( - IN PDEVICE_OBJECT DeviceObject); + IN PDEVICE_OBJECT DeviceObject); NTKERNELAPI NTSTATUS NTAPI IoGetBootDiskInformation( - IN OUT PBOOTDISK_INFORMATION BootDiskInformation, - IN ULONG Size); + IN OUT PBOOTDISK_INFORMATION BootDiskInformation, + IN ULONG Size); NTKERNELAPI NTSTATUS NTAPI IoGetDeviceInterfaceAlias( - IN PUNICODE_STRING SymbolicLinkName, - IN CONST GUID *AliasInterfaceClassGuid, - OUT PUNICODE_STRING AliasSymbolicLinkName); + IN PUNICODE_STRING SymbolicLinkName, + IN CONST GUID *AliasInterfaceClassGuid, + OUT PUNICODE_STRING AliasSymbolicLinkName); NTKERNELAPI PEPROCESS NTAPI -IoGetCurrentProcess( - VOID); +IoGetCurrentProcess(VOID); NTKERNELAPI NTSTATUS NTAPI IoGetDeviceInterfaces( - IN CONST GUID *InterfaceClassGuid, - IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL, - IN ULONG Flags, - OUT PWSTR *SymbolicLinkList); + IN CONST GUID *InterfaceClassGuid, + IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL, + IN ULONG Flags, + OUT PWSTR *SymbolicLinkList); NTKERNELAPI NTSTATUS NTAPI IoGetDeviceObjectPointer( - IN PUNICODE_STRING ObjectName, - IN ACCESS_MASK DesiredAccess, - OUT PFILE_OBJECT *FileObject, - OUT PDEVICE_OBJECT *DeviceObject); + IN PUNICODE_STRING ObjectName, + IN ACCESS_MASK DesiredAccess, + OUT PFILE_OBJECT *FileObject, + OUT PDEVICE_OBJECT *DeviceObject); NTKERNELAPI NTSTATUS NTAPI IoGetDeviceProperty( - IN PDEVICE_OBJECT DeviceObject, - IN DEVICE_REGISTRY_PROPERTY DeviceProperty, - IN ULONG BufferLength, - OUT PVOID PropertyBuffer, - OUT PULONG ResultLength); + IN PDEVICE_OBJECT DeviceObject, + IN DEVICE_REGISTRY_PROPERTY DeviceProperty, + IN ULONG BufferLength, + OUT PVOID PropertyBuffer, + OUT PULONG ResultLength); NTKERNELAPI PDMA_ADAPTER NTAPI IoGetDmaAdapter( - IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL, - IN PDEVICE_DESCRIPTION DeviceDescription, - IN OUT PULONG NumberOfMapRegisters); + IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL, + IN PDEVICE_DESCRIPTION DeviceDescription, + IN OUT PULONG NumberOfMapRegisters); NTKERNELAPI PVOID NTAPI IoGetDriverObjectExtension( - IN PDRIVER_OBJECT DriverObject, - IN PVOID ClientIdentificationAddress); + IN PDRIVER_OBJECT DriverObject, + IN PVOID ClientIdentificationAddress); NTKERNELAPI PVOID NTAPI -IoGetInitialStack( - VOID); +IoGetInitialStack(VOID); NTKERNELAPI PDEVICE_OBJECT NTAPI IoGetRelatedDeviceObject( - IN PFILE_OBJECT FileObject); + IN PFILE_OBJECT FileObject); NTKERNELAPI VOID NTAPI IoQueueWorkItem( - IN PIO_WORKITEM IoWorkItem, - IN PIO_WORKITEM_ROUTINE WorkerRoutine, - IN WORK_QUEUE_TYPE QueueType, - IN PVOID Context OPTIONAL); + IN PIO_WORKITEM IoWorkItem, + IN PIO_WORKITEM_ROUTINE WorkerRoutine, + IN WORK_QUEUE_TYPE QueueType, + IN PVOID Context OPTIONAL); NTKERNELAPI VOID NTAPI IoInitializeIrp( - IN OUT PIRP Irp, - IN USHORT PacketSize, - IN CCHAR StackSize); + IN OUT PIRP Irp, + IN USHORT PacketSize, + IN CCHAR StackSize); NTKERNELAPI VOID NTAPI IoInitializeRemoveLockEx( - IN PIO_REMOVE_LOCK Lock, - IN ULONG AllocateTag, - IN ULONG MaxLockedMinutes, - IN ULONG HighWatermark, - IN ULONG RemlockSize); + IN PIO_REMOVE_LOCK Lock, + IN ULONG AllocateTag, + IN ULONG MaxLockedMinutes, + IN ULONG HighWatermark, + IN ULONG RemlockSize); NTKERNELAPI NTSTATUS NTAPI IoInitializeTimer( - IN PDEVICE_OBJECT DeviceObject, - IN PIO_TIMER_ROUTINE TimerRoutine, - IN PVOID Context OPTIONAL); + IN PDEVICE_OBJECT DeviceObject, + IN PIO_TIMER_ROUTINE TimerRoutine, + IN PVOID Context OPTIONAL); NTKERNELAPI VOID NTAPI IoInvalidateDeviceRelations( - IN PDEVICE_OBJECT DeviceObject, - IN DEVICE_RELATION_TYPE Type); + IN PDEVICE_OBJECT DeviceObject, + IN DEVICE_RELATION_TYPE Type); NTKERNELAPI VOID NTAPI IoInvalidateDeviceState( - IN PDEVICE_OBJECT PhysicalDeviceObject); + IN PDEVICE_OBJECT PhysicalDeviceObject); NTKERNELAPI BOOLEAN NTAPI IoIsWdmVersionAvailable( - IN UCHAR MajorVersion, - IN UCHAR MinorVersion); + IN UCHAR MajorVersion, + IN UCHAR MinorVersion); NTKERNELAPI NTSTATUS NTAPI IoOpenDeviceInterfaceRegistryKey( - IN PUNICODE_STRING SymbolicLinkName, - IN ACCESS_MASK DesiredAccess, - OUT PHANDLE DeviceInterfaceKey); + IN PUNICODE_STRING SymbolicLinkName, + IN ACCESS_MASK DesiredAccess, + OUT PHANDLE DeviceInterfaceKey); NTKERNELAPI NTSTATUS NTAPI IoOpenDeviceRegistryKey( - IN PDEVICE_OBJECT DeviceObject, - IN ULONG DevInstKeyType, - IN ACCESS_MASK DesiredAccess, - OUT PHANDLE DevInstRegKey); + IN PDEVICE_OBJECT DeviceObject, + IN ULONG DevInstKeyType, + IN ACCESS_MASK DesiredAccess, + OUT PHANDLE DevInstRegKey); NTKERNELAPI NTSTATUS NTAPI IoRegisterDeviceInterface( - IN PDEVICE_OBJECT PhysicalDeviceObject, - IN CONST GUID *InterfaceClassGuid, - IN PUNICODE_STRING ReferenceString OPTIONAL, - OUT PUNICODE_STRING SymbolicLinkName); + IN PDEVICE_OBJECT PhysicalDeviceObject, + IN CONST GUID *InterfaceClassGuid, + IN PUNICODE_STRING ReferenceString OPTIONAL, + OUT PUNICODE_STRING SymbolicLinkName); NTKERNELAPI NTSTATUS NTAPI IoRegisterPlugPlayNotification( - IN IO_NOTIFICATION_EVENT_CATEGORY EventCategory, - IN ULONG EventCategoryFlags, - IN PVOID EventCategoryData OPTIONAL, - IN PDRIVER_OBJECT DriverObject, - IN PDRIVER_NOTIFICATION_CALLBACK_ROUTINE CallbackRoutine, - IN OUT PVOID Context OPTIONAL, - OUT PVOID *NotificationEntry); + IN IO_NOTIFICATION_EVENT_CATEGORY EventCategory, + IN ULONG EventCategoryFlags, + IN PVOID EventCategoryData OPTIONAL, + IN PDRIVER_OBJECT DriverObject, + IN PDRIVER_NOTIFICATION_CALLBACK_ROUTINE CallbackRoutine, + IN OUT PVOID Context OPTIONAL, + OUT PVOID *NotificationEntry); NTKERNELAPI NTSTATUS NTAPI IoRegisterShutdownNotification( - IN PDEVICE_OBJECT DeviceObject); + IN PDEVICE_OBJECT DeviceObject); NTKERNELAPI VOID NTAPI IoReleaseCancelSpinLock( - IN KIRQL Irql); + IN KIRQL Irql); NTKERNELAPI VOID NTAPI IoReleaseRemoveLockAndWaitEx( - IN PIO_REMOVE_LOCK RemoveLock, - IN PVOID Tag OPTIONAL, - IN ULONG RemlockSize); + IN PIO_REMOVE_LOCK RemoveLock, + IN PVOID Tag OPTIONAL, + IN ULONG RemlockSize); NTKERNELAPI VOID NTAPI IoReleaseRemoveLockEx( - IN PIO_REMOVE_LOCK RemoveLock, - IN PVOID Tag OPTIONAL, - IN ULONG RemlockSize); + IN PIO_REMOVE_LOCK RemoveLock, + IN PVOID Tag OPTIONAL, + IN ULONG RemlockSize); NTKERNELAPI VOID NTAPI IoRemoveShareAccess( - IN PFILE_OBJECT FileObject, - IN OUT PSHARE_ACCESS ShareAccess); + IN PFILE_OBJECT FileObject, + IN OUT PSHARE_ACCESS ShareAccess); NTKERNELAPI NTSTATUS NTAPI IoReportTargetDeviceChange( - IN PDEVICE_OBJECT PhysicalDeviceObject, - IN PVOID NotificationStructure); + IN PDEVICE_OBJECT PhysicalDeviceObject, + IN PVOID NotificationStructure); NTKERNELAPI NTSTATUS NTAPI IoReportTargetDeviceChangeAsynchronous( - IN PDEVICE_OBJECT PhysicalDeviceObject, - IN PVOID NotificationStructure, - IN PDEVICE_CHANGE_COMPLETE_CALLBACK Callback OPTIONAL, - IN PVOID Context OPTIONAL); + IN PDEVICE_OBJECT PhysicalDeviceObject, + IN PVOID NotificationStructure, + IN PDEVICE_CHANGE_COMPLETE_CALLBACK Callback OPTIONAL, + IN PVOID Context OPTIONAL); NTKERNELAPI VOID NTAPI IoRequestDeviceEject( - IN PDEVICE_OBJECT PhysicalDeviceObject); + IN PDEVICE_OBJECT PhysicalDeviceObject); NTKERNELAPI VOID NTAPI IoReuseIrp( - IN OUT PIRP Irp, - IN NTSTATUS Status); + IN OUT PIRP Irp, + IN NTSTATUS Status); NTKERNELAPI NTSTATUS NTAPI IoSetDeviceInterfaceState( - IN PUNICODE_STRING SymbolicLinkName, - IN BOOLEAN Enable); + IN PUNICODE_STRING SymbolicLinkName, + IN BOOLEAN Enable); NTKERNELAPI VOID NTAPI IoSetShareAccess( - IN ACCESS_MASK DesiredAccess, - IN ULONG DesiredShareAccess, - IN OUT PFILE_OBJECT FileObject, - OUT PSHARE_ACCESS ShareAccess); + IN ACCESS_MASK DesiredAccess, + IN ULONG DesiredShareAccess, + IN OUT PFILE_OBJECT FileObject, + OUT PSHARE_ACCESS ShareAccess); NTKERNELAPI VOID NTAPI IoStartNextPacket( - IN PDEVICE_OBJECT DeviceObject, - IN BOOLEAN Cancelable); + IN PDEVICE_OBJECT DeviceObject, + IN BOOLEAN Cancelable); NTKERNELAPI VOID NTAPI IoStartNextPacketByKey( - IN PDEVICE_OBJECT DeviceObject, - IN BOOLEAN Cancelable, - IN ULONG Key); + IN PDEVICE_OBJECT DeviceObject, + IN BOOLEAN Cancelable, + IN ULONG Key); NTKERNELAPI VOID NTAPI IoStartPacket( - IN PDEVICE_OBJECT DeviceObject, - IN PIRP Irp, - IN PULONG Key OPTIONAL, - IN PDRIVER_CANCEL CancelFunction OPTIONAL); + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp, + IN PULONG Key OPTIONAL, + IN PDRIVER_CANCEL CancelFunction OPTIONAL); NTKERNELAPI VOID NTAPI IoStartTimer( - IN PDEVICE_OBJECT DeviceObject); + IN PDEVICE_OBJECT DeviceObject); NTKERNELAPI VOID NTAPI IoStopTimer( - IN PDEVICE_OBJECT DeviceObject); + IN PDEVICE_OBJECT DeviceObject); NTKERNELAPI NTSTATUS NTAPI IoUnregisterPlugPlayNotification( - IN PVOID NotificationEntry); + IN PVOID NotificationEntry); NTKERNELAPI VOID NTAPI IoUnregisterShutdownNotification( - IN PDEVICE_OBJECT DeviceObject); + IN PDEVICE_OBJECT DeviceObject); NTKERNELAPI VOID NTAPI IoUpdateShareAccess( - IN PFILE_OBJECT FileObject, - IN OUT PSHARE_ACCESS ShareAccess); + IN PFILE_OBJECT FileObject, + IN OUT PSHARE_ACCESS ShareAccess); NTKERNELAPI NTSTATUS NTAPI IoWMIAllocateInstanceIds( - IN GUID *Guid, - IN ULONG InstanceCount, - OUT ULONG *FirstInstanceId); + IN GUID *Guid, + IN ULONG InstanceCount, + OUT ULONG *FirstInstanceId); NTKERNELAPI NTSTATUS NTAPI IoWMIQuerySingleInstanceMultiple( - IN PVOID *DataBlockObjectList, - IN PUNICODE_STRING InstanceNames, - IN ULONG ObjectCount, - IN OUT ULONG *InOutBufferSize, - OUT PVOID OutBuffer); + IN PVOID *DataBlockObjectList, + IN PUNICODE_STRING InstanceNames, + IN ULONG ObjectCount, + IN OUT ULONG *InOutBufferSize, + OUT PVOID OutBuffer); NTKERNELAPI NTSTATUS NTAPI IoWMIRegistrationControl( - IN PDEVICE_OBJECT DeviceObject, - IN ULONG Action); + IN PDEVICE_OBJECT DeviceObject, + IN ULONG Action); NTKERNELAPI NTSTATUS NTAPI IoWMISuggestInstanceName( - IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL, - IN PUNICODE_STRING SymbolicLinkName OPTIONAL, - IN BOOLEAN CombineNames, - OUT PUNICODE_STRING SuggestedInstanceName); + IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL, + IN PUNICODE_STRING SymbolicLinkName OPTIONAL, + IN BOOLEAN CombineNames, + OUT PUNICODE_STRING SuggestedInstanceName); NTKERNELAPI NTSTATUS NTAPI IoWMIWriteEvent( - IN PVOID WnodeEventItem); + IN OUT PVOID WnodeEventItem); NTKERNELAPI VOID NTAPI IoWriteErrorLogEntry( - IN PVOID ElEntry); + IN PVOID ElEntry); + +NTKERNELAPI +PIRP +NTAPI +IoGetTopLevelIrp(VOID); + +NTKERNELAPI +NTSTATUS +NTAPI +IoRegisterLastChanceShutdownNotification( + IN PDEVICE_OBJECT DeviceObject); + +NTKERNELAPI +VOID +NTAPI +IoSetTopLevelIrp( + IN PIRP Irp OPTIONAL); + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ -#endif #if (NTDDI_VERSION >= NTDDI_WINXP) @@ -9370,15 +12412,15 @@ NTKERNELAPI PIRP NTAPI IoCsqRemoveNextIrp( - IN PIO_CSQ Csq, - IN PVOID PeekContext); + IN PIO_CSQ Csq, + IN PVOID PeekContext OPTIONAL); NTKERNELAPI BOOLEAN NTAPI IoForwardIrpSynchronously( - IN PDEVICE_OBJECT DeviceObject, - IN PIRP Irp); + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp); #define IoForwardAndCatchIrp IoForwardIrpSynchronously @@ -9386,119 +12428,347 @@ NTKERNELAPI VOID NTAPI IoFreeErrorLogEntry( - PVOID ElEntry); + PVOID ElEntry); NTKERNELAPI NTSTATUS NTAPI IoSetCompletionRoutineEx( - IN PDEVICE_OBJECT DeviceObject, - IN PIRP Irp, - IN PIO_COMPLETION_ROUTINE CompletionRoutine, - IN PVOID Context, - IN BOOLEAN InvokeOnSuccess, - IN BOOLEAN InvokeOnError, - IN BOOLEAN InvokeOnCancel); + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp, + IN PIO_COMPLETION_ROUTINE CompletionRoutine, + IN PVOID Context, + IN BOOLEAN InvokeOnSuccess, + IN BOOLEAN InvokeOnError, + IN BOOLEAN InvokeOnCancel); VOID NTAPI IoSetStartIoAttributes( - IN PDEVICE_OBJECT DeviceObject, - IN BOOLEAN DeferredStartIo, - IN BOOLEAN NonCancelable); + IN PDEVICE_OBJECT DeviceObject, + IN BOOLEAN DeferredStartIo, + IN BOOLEAN NonCancelable); NTKERNELAPI NTSTATUS NTAPI IoWMIDeviceObjectToInstanceName( - IN PVOID DataBlockObject, - IN PDEVICE_OBJECT DeviceObject, - OUT PUNICODE_STRING InstanceName); + IN PVOID DataBlockObject, + IN PDEVICE_OBJECT DeviceObject, + OUT PUNICODE_STRING InstanceName); NTKERNELAPI NTSTATUS NTAPI IoWMIExecuteMethod( - IN PVOID DataBlockObject, - IN PUNICODE_STRING InstanceName, - IN ULONG MethodId, - IN ULONG InBufferSize, - IN OUT PULONG OutBufferSize, - IN OUT PUCHAR InOutBuffer); + IN PVOID DataBlockObject, + IN PUNICODE_STRING InstanceName, + IN ULONG MethodId, + IN ULONG InBufferSize, + IN OUT PULONG OutBufferSize, + IN OUT PUCHAR InOutBuffer); NTKERNELAPI NTSTATUS NTAPI IoWMIHandleToInstanceName( - IN PVOID DataBlockObject, - IN HANDLE FileHandle, - OUT PUNICODE_STRING InstanceName); + IN PVOID DataBlockObject, + IN HANDLE FileHandle, + OUT PUNICODE_STRING InstanceName); NTKERNELAPI NTSTATUS NTAPI IoWMIOpenBlock( - IN GUID *DataBlockGuid, - IN ULONG DesiredAccess, - OUT PVOID *DataBlockObject); + IN GUID *DataBlockGuid, + IN ULONG DesiredAccess, + OUT PVOID *DataBlockObject); NTKERNELAPI NTSTATUS NTAPI IoWMIQueryAllData( - IN PVOID DataBlockObject, - IN OUT ULONG *InOutBufferSize, - OUT PVOID OutBuffer); + IN PVOID DataBlockObject, + IN OUT ULONG *InOutBufferSize, + OUT PVOID OutBuffer); NTKERNELAPI NTSTATUS NTAPI IoWMIQueryAllDataMultiple( - IN PVOID *DataBlockObjectList, - IN ULONG ObjectCount, - IN OUT ULONG *InOutBufferSize, - OUT PVOID OutBuffer); + IN PVOID *DataBlockObjectList, + IN ULONG ObjectCount, + IN OUT ULONG *InOutBufferSize, + OUT PVOID OutBuffer); NTKERNELAPI NTSTATUS NTAPI IoWMIQuerySingleInstance( - IN PVOID DataBlockObject, - IN PUNICODE_STRING InstanceName, - IN OUT ULONG *InOutBufferSize, + IN PVOID DataBlockObject, + IN PUNICODE_STRING InstanceName, + IN OUT ULONG *InOutBufferSize, OUT PVOID OutBuffer); NTKERNELAPI NTSTATUS NTAPI IoWMISetNotificationCallback( - IN OUT PVOID Object, - IN WMI_NOTIFICATION_CALLBACK Callback, - IN PVOID Context OPTIONAL); + IN OUT PVOID Object, + IN WMI_NOTIFICATION_CALLBACK Callback, + IN PVOID Context OPTIONAL); NTKERNELAPI NTSTATUS NTAPI IoWMISetSingleInstance( - IN PVOID DataBlockObject, - IN PUNICODE_STRING InstanceName, - IN ULONG Version, - IN ULONG ValueBufferSize, - IN PVOID ValueBuffer); + IN PVOID DataBlockObject, + IN PUNICODE_STRING InstanceName, + IN ULONG Version, + IN ULONG ValueBufferSize, + IN PVOID ValueBuffer); NTKERNELAPI NTSTATUS NTAPI IoWMISetSingleItem( - IN PVOID DataBlockObject, - IN PUNICODE_STRING InstanceName, - IN ULONG DataItemId, - IN ULONG Version, - IN ULONG ValueBufferSize, - IN PVOID ValueBuffer); + IN PVOID DataBlockObject, + IN PUNICODE_STRING InstanceName, + IN ULONG DataItemId, + IN ULONG Version, + IN ULONG ValueBufferSize, + IN PVOID ValueBuffer); +#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ +#if (NTDDI_VERSION >= NTDDI_WINXPSP1) +NTKERNELAPI +NTSTATUS +NTAPI +IoValidateDeviceIoControlAccess( + IN PIRP Irp, + IN ULONG RequiredAccess); #endif +#if (NTDDI_VERSION >= NTDDI_WS03) + +NTKERNELAPI +NTSTATUS +NTAPI +IoCsqInitializeEx( + IN PIO_CSQ Csq, + IN PIO_CSQ_INSERT_IRP_EX CsqInsertIrp, + IN PIO_CSQ_REMOVE_IRP CsqRemoveIrp, + IN PIO_CSQ_PEEK_NEXT_IRP CsqPeekNextIrp, + IN PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock, + IN PIO_CSQ_RELEASE_LOCK CsqReleaseLock, + IN PIO_CSQ_COMPLETE_CANCELED_IRP CsqCompleteCanceledIrp); + +NTKERNELAPI +NTSTATUS +NTAPI +IoCsqInsertIrpEx( + IN PIO_CSQ Csq, + IN PIRP Irp, + IN PIO_CSQ_IRP_CONTEXT Context OPTIONAL, + IN PVOID InsertContext OPTIONAL); +#endif /* (NTDDI_VERSION >= NTDDI_WS03) */ + + +#if (NTDDI_VERSION >= NTDDI_VISTA) + +NTKERNELAPI +NTSTATUS +NTAPI +IoGetBootDiskInformationLite( + OUT PBOOTDISK_INFORMATION_LITE *BootDiskInformation); + +NTKERNELAPI +NTSTATUS +NTAPI +IoCheckShareAccessEx( + IN ACCESS_MASK DesiredAccess, + IN ULONG DesiredShareAccess, + IN OUT PFILE_OBJECT FileObject, + IN OUT PSHARE_ACCESS ShareAccess, + IN BOOLEAN Update, + IN PBOOLEAN WritePermission); + +NTKERNELAPI +NTSTATUS +NTAPI +IoConnectInterruptEx( + IN OUT PIO_CONNECT_INTERRUPT_PARAMETERS Parameters); + +NTKERNELAPI +VOID +NTAPI +IoDisconnectInterruptEx( + IN PIO_DISCONNECT_INTERRUPT_PARAMETERS Parameters); + +LOGICAL +NTAPI +IoWithinStackLimits( + IN ULONG_PTR RegionStart, + IN SIZE_T RegionSize); + +NTKERNELAPI +VOID +NTAPI +IoSetShareAccessEx( + IN ACCESS_MASK DesiredAccess, + IN ULONG DesiredShareAccess, + IN OUT PFILE_OBJECT FileObject, + OUT PSHARE_ACCESS ShareAccess, + IN PBOOLEAN WritePermission); + +ULONG +NTAPI +IoSizeofWorkItem(VOID); + +VOID +NTAPI +IoInitializeWorkItem( + IN PVOID IoObject, + IN PIO_WORKITEM IoWorkItem); + +VOID +NTAPI +IoUninitializeWorkItem( + IN PIO_WORKITEM IoWorkItem); + +VOID +NTAPI +IoQueueWorkItemEx( + IN PIO_WORKITEM IoWorkItem, + IN PIO_WORKITEM_ROUTINE_EX WorkerRoutine, + IN WORK_QUEUE_TYPE QueueType, + IN PVOID Context OPTIONAL); + +IO_PRIORITY_HINT +NTAPI +IoGetIoPriorityHint( + IN PIRP Irp); + +NTSTATUS +NTAPI +IoSetIoPriorityHint( + IN PIRP Irp, + IN IO_PRIORITY_HINT PriorityHint); + +NTSTATUS +NTAPI +IoAllocateSfioStreamIdentifier( + IN PFILE_OBJECT FileObject, + IN ULONG Length, + IN PVOID Signature, + OUT PVOID *StreamIdentifier); + +PVOID +NTAPI +IoGetSfioStreamIdentifier( + IN PFILE_OBJECT FileObject, + IN PVOID Signature); + +NTSTATUS +NTAPI +IoFreeSfioStreamIdentifier( + IN PFILE_OBJECT FileObject, + IN PVOID Signature); + +NTKERNELAPI +NTSTATUS +NTAPI +IoRequestDeviceEjectEx( + IN PDEVICE_OBJECT PhysicalDeviceObject, + IN PIO_DEVICE_EJECT_CALLBACK Callback OPTIONAL, + IN PVOID Context OPTIONAL, + IN PDRIVER_OBJECT DriverObject OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +IoSetDevicePropertyData( + IN PDEVICE_OBJECT Pdo, + IN CONST DEVPROPKEY *PropertyKey, + IN LCID Lcid, + IN ULONG Flags, + IN DEVPROPTYPE Type, + IN ULONG Size, + IN PVOID Data OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +IoGetDevicePropertyData( + PDEVICE_OBJECT Pdo, + CONST DEVPROPKEY *PropertyKey, + LCID Lcid, + ULONG Flags, + ULONG Size, + PVOID Data, + PULONG RequiredSize, + PDEVPROPTYPE Type); + +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + +#define IoCallDriverStackSafeDefault(a, b) IoCallDriver(a, b) + +#if (NTDDI_VERSION >= NTDDI_WS08) +NTKERNELAPI +NTSTATUS +NTAPI +IoReplacePartitionUnit( + IN PDEVICE_OBJECT TargetPdo, + IN PDEVICE_OBJECT SparePdo, + IN ULONG Flags); +#endif + +#if (NTDDI_VERSION >= NTDDI_WIN7) + +NTKERNELAPI +NTSTATUS +NTAPI +IoGetAffinityInterrupt( + IN PKINTERRUPT InterruptObject, + OUT PGROUP_AFFINITY GroupAffinity); + +NTSTATUS +NTAPI +IoGetContainerInformation( + IN IO_CONTAINER_INFORMATION_CLASS InformationClass, + IN PVOID ContainerObject OPTIONAL, + IN OUT PVOID Buffer OPTIONAL, + IN ULONG BufferLength); + +NTSTATUS +NTAPI +IoRegisterContainerNotification( + IN IO_CONTAINER_NOTIFICATION_CLASS NotificationClass, + IN PIO_CONTAINER_NOTIFICATION_FUNCTION CallbackFunction, + IN PVOID NotificationInformation OPTIONAL, + IN ULONG NotificationInformationLength, + OUT PVOID CallbackRegistration); + +VOID +NTAPI +IoUnregisterContainerNotification( + IN PVOID CallbackRegistration); + +NTKERNELAPI +NTSTATUS +NTAPI +IoUnregisterPlugPlayNotificationEx( + IN PVOID NotificationEntry); + +NTKERNELAPI +NTSTATUS +NTAPI +IoGetDeviceNumaNode( + IN PDEVICE_OBJECT Pdo, + OUT PUSHORT NodeNumber); + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + #if defined(_WIN64) NTKERNELAPI ULONG @@ -9519,7 +12789,7 @@ IoWMIDeviceObjectToProviderId( FORCEINLINE VOID -IoSkipCurrentIrpStackLocation ( +IoSkipCurrentIrpStackLocation( IN OUT PIRP Irp) { ASSERT(Irp->CurrentLocation <= Irp->StackCount); @@ -9529,7 +12799,7 @@ IoSkipCurrentIrpStackLocation ( FORCEINLINE VOID -IoSetNextIrpStackLocation ( +IoSetNextIrpStackLocation( IN OUT PIRP Irp) { ASSERT(Irp->CurrentLocation > 0); @@ -9618,12 +12888,10 @@ IoSetCompletionRoutine( IoReleaseRemoveLockAndWaitEx(_RemoveLock, _Tag, sizeof(IO_REMOVE_LOCK)) #if defined(_WIN64) - NTKERNELAPI BOOLEAN IoIs32bitProcess( - IN PIRP Irp OPTIONAL); - + IN PIRP Irp OPTIONAL); #endif #define PLUGPLAY_REGKEY_DEVICE 1 @@ -9697,7 +12965,7 @@ IoInitializeDpcRequest( FORCEINLINE VOID IoCopyCurrentIrpStackLocationToNext( - IN PIRP Irp) + IN OUT PIRP Irp) { PIO_STACK_LOCATION irpSp; PIO_STACK_LOCATION nextIrpSp; @@ -9711,13 +12979,12 @@ NTKERNELAPI VOID NTAPI IoGetStackLimits( - OUT PULONG_PTR LowLimit, - OUT PULONG_PTR HighLimit); + OUT PULONG_PTR LowLimit, + OUT PULONG_PTR HighLimit); FORCEINLINE ULONG_PTR -IoGetRemainingStackSize( - VOID) +IoGetRemainingStackSize(VOID) { ULONG_PTR End, Begin; ULONG_PTR Result; @@ -9727,6 +12994,19 @@ IoGetRemainingStackSize( return Result; } +#if (NTDDI_VERSION >= NTDDI_WS03) +VOID +FORCEINLINE +IoInitializeThreadedDpcRequest( + IN PDEVICE_OBJECT DeviceObject, + IN PIO_DPC_ROUTINE DpcRoutine) +{ + KeInitializeThreadedDpc(&DeviceObject->Dpc, + (PKDEFERRED_ROUTINE) DpcRoutine, + DeviceObject ); +} +#endif + /****************************************************************************** * Power Management Support Functions * ******************************************************************************/ @@ -9739,17 +13019,17 @@ NTKERNELAPI NTSTATUS NTAPI PoCallDriver( - IN struct _DEVICE_OBJECT *DeviceObject, - IN OUT struct _IRP *Irp); + IN struct _DEVICE_OBJECT *DeviceObject, + IN OUT struct _IRP *Irp); NTKERNELAPI PULONG NTAPI PoRegisterDeviceForIdleDetection( - IN struct _DEVICE_OBJECT *DeviceObject, - IN ULONG ConservationIdleTime, - IN ULONG PerformanceIdleTime, - IN DEVICE_POWER_STATE State); + IN struct _DEVICE_OBJECT *DeviceObject, + IN ULONG ConservationIdleTime, + IN ULONG PerformanceIdleTime, + IN DEVICE_POWER_STATE State); NTKERNELAPI PVOID @@ -9762,26 +13042,26 @@ NTKERNELAPI NTSTATUS NTAPI PoRequestPowerIrp( - IN struct _DEVICE_OBJECT *DeviceObject, - IN UCHAR MinorFunction, - IN POWER_STATE PowerState, - IN PREQUEST_POWER_COMPLETE CompletionFunction OPTIONAL, - IN PVOID Context OPTIONAL, - OUT struct _IRP **Irp OPTIONAL); + IN struct _DEVICE_OBJECT *DeviceObject, + IN UCHAR MinorFunction, + IN POWER_STATE PowerState, + IN PREQUEST_POWER_COMPLETE CompletionFunction OPTIONAL, + IN PVOID Context OPTIONAL, + OUT struct _IRP **Irp OPTIONAL); NTKERNELAPI POWER_STATE NTAPI PoSetPowerState( - IN struct _DEVICE_OBJECT *DeviceObject, - IN POWER_STATE_TYPE Type, - IN POWER_STATE State); + IN struct _DEVICE_OBJECT *DeviceObject, + IN POWER_STATE_TYPE Type, + IN POWER_STATE State); NTKERNELAPI VOID NTAPI PoSetSystemState( - IN EXECUTION_STATE Flags); + IN EXECUTION_STATE Flags); NTKERNELAPI VOID @@ -9836,16 +13116,15 @@ PoUnregisterPowerSettingCallback( #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ #if (NTDDI_VERSION >= NTDDI_VISTASP1) - NTKERNELAPI VOID NTAPI PoSetDeviceBusyEx( IN OUT PULONG IdlePointer); - #endif /* (NTDDI_VERSION >= NTDDI_VISTASP1) */ #if (NTDDI_VERSION >= NTDDI_WIN7) + NTKERNELAPI VOID NTAPI @@ -9910,19 +13189,64 @@ PoCreatePowerRequest( #define ExInitializeSListHead InitializeSListHead -#if defined(_X86_) -#if defined(_NTHAL_) +#if defined(_NTHAL_) && defined(_X86_) + +NTKERNELAPI +VOID +FASTCALL +ExiAcquireFastMutex( + IN OUT PFAST_MUTEX FastMutex); + +NTKERNELAPI +VOID +FASTCALL +ExiReleaseFastMutex( + IN OUT PFAST_MUTEX FastMutex); + +NTKERNELAPI +BOOLEAN +FASTCALL +ExiTryToAcquireFastMutex( + IN OUT PFAST_MUTEX FastMutex); + #define ExAcquireFastMutex ExiAcquireFastMutex #define ExReleaseFastMutex ExiReleaseFastMutex #define ExTryToAcquireFastMutex ExiTryToAcquireFastMutex -#endif + +#else + +#if (NTDDI_VERSION >= NTDDI_WIN2K) + +NTKERNELAPI +VOID +FASTCALL +ExAcquireFastMutex( + IN OUT PFAST_MUTEX FastMutex); + +NTKERNELAPI +VOID +FASTCALL +ExReleaseFastMutex( + IN OUT PFAST_MUTEX FastMutex); + +NTKERNELAPI +BOOLEAN +FASTCALL +ExTryToAcquireFastMutex( + IN OUT PFAST_MUTEX FastMutex); + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ + +#endif /* defined(_NTHAL_) && defined(_X86_) */ + +#if defined(_X86_) #define ExInterlockedAddUlong ExfInterlockedAddUlong #define ExInterlockedInsertHeadList ExfInterlockedInsertHeadList #define ExInterlockedInsertTailList ExfInterlockedInsertTailList #define ExInterlockedRemoveHeadList ExfInterlockedRemoveHeadList #define ExInterlockedPopEntryList ExfInterlockedPopEntryList #define ExInterlockedPushEntryList ExfInterlockedPushEntryList -#endif +#endif /* defined(_X86_) */ #if defined(_WIN64) @@ -9936,25 +13260,25 @@ FORCEINLINE USHORT ExQueryDepthSList(IN PSLIST_HEADER ListHead) { - return (USHORT)(ListHead->Alignment & 0xffff); + return (USHORT)(ListHead->Alignment & 0xffff); } #endif NTKERNELAPI PSLIST_ENTRY ExpInterlockedFlushSList( - PSLIST_HEADER ListHead); + PSLIST_HEADER ListHead); NTKERNELAPI PSLIST_ENTRY ExpInterlockedPopEntrySList( - PSLIST_HEADER ListHead); + PSLIST_HEADER ListHead); NTKERNELAPI PSLIST_ENTRY ExpInterlockedPushEntrySList( - PSLIST_HEADER ListHead, - PSLIST_ENTRY ListEntry); + PSLIST_HEADER ListHead, + PSLIST_ENTRY ListEntry); #define ExInterlockedFlushSList(Head) \ ExpInterlockedFlushSList(Head) @@ -9963,7 +13287,7 @@ ExpInterlockedPushEntrySList( #define ExInterlockedPushEntrySList(Head, Entry, Lock) \ ExpInterlockedPushEntrySList(Head, Entry) -#else // !defined(_WIN64) +#else /* !defined(_WIN64) */ #define ExQueryDepthSList(listhead) (listhead)->Depth @@ -9971,37 +13295,90 @@ NTKERNELAPI PSINGLE_LIST_ENTRY FASTCALL ExInterlockedFlushSList( - IN PSLIST_HEADER ListHead); + IN OUT PSLIST_HEADER ListHead); + +#endif /* !defined(_WIN64) */ #if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_) + NTKERNELAPI PSINGLE_LIST_ENTRY FASTCALL ExInterlockedPopEntrySList( - IN PSLIST_HEADER ListHead, - IN PKSPIN_LOCK Lock); + IN PSLIST_HEADER ListHead, + IN PKSPIN_LOCK Lock); NTKERNELAPI PSINGLE_LIST_ENTRY FASTCALL ExInterlockedPushEntrySList( - IN PSLIST_HEADER ListHead, - IN PSINGLE_LIST_ENTRY ListEntry, - IN PKSPIN_LOCK Lock); -#else + IN PSLIST_HEADER ListHead, + IN PSINGLE_LIST_ENTRY ListEntry, + IN PKSPIN_LOCK Lock); + +NTKERNELAPI +PVOID +NTAPI +ExAllocateFromPagedLookasideList( + IN OUT PPAGED_LOOKASIDE_LIST Lookaside); + +NTKERNELAPI +VOID +NTAPI +ExFreeToPagedLookasideList( + IN OUT PPAGED_LOOKASIDE_LIST Lookaside, + IN PVOID Entry); + +#else /* !_WIN2K_COMPAT_SLIST_USAGE */ + +#if !defined(_WIN64) #define ExInterlockedPopEntrySList(_ListHead, _Lock) \ InterlockedPopEntrySList(_ListHead) #define ExInterlockedPushEntrySList(_ListHead, _ListEntry, _Lock) \ InterlockedPushEntrySList(_ListHead, _ListEntry) -#endif // _WIN2K_COMPAT_SLIST_USAGE +#endif + +static __inline +PVOID +ExAllocateFromPagedLookasideList( + IN OUT PPAGED_LOOKASIDE_LIST Lookaside) +{ + PVOID Entry; + + Lookaside->L.TotalAllocates++; + Entry = InterlockedPopEntrySList(&Lookaside->L.ListHead); + if (Entry == NULL) { + Lookaside->L.AllocateMisses++; + Entry = (Lookaside->L.Allocate)(Lookaside->L.Type, + Lookaside->L.Size, + Lookaside->L.Tag); + } + return Entry; +} + +static __inline +VOID +ExFreeToPagedLookasideList( + IN OUT PPAGED_LOOKASIDE_LIST Lookaside, + IN PVOID Entry) +{ + Lookaside->L.TotalFrees++; + if (ExQueryDepthSList(&Lookaside->L.ListHead) >= Lookaside->L.Depth) { + Lookaside->L.FreeMisses++; + (Lookaside->L.Free)(Entry); + } else { + InterlockedPushEntrySList(&Lookaside->L.ListHead, (PSLIST_ENTRY)Entry); + } +} + +#endif /* _WIN2K_COMPAT_SLIST_USAGE */ -#endif // !defined(_WIN64) /* ERESOURCE_THREAD * ExGetCurrentResourceThread( * VOID); */ -#define ExGetCurrentResourceThread() ((ERESOURCE_THREAD)PsGetCurrentThread()) +#define ExGetCurrentResourceThread() ((ULONG_PTR)PsGetCurrentThread()) #define ExReleaseResource(R) (ExReleaseResourceLite(R)) @@ -10032,220 +13409,193 @@ ExInitializeFastMutex( #if (NTDDI_VERSION >= NTDDI_WIN2K) -NTKERNELAPI -VOID -FASTCALL -ExAcquireFastMutex( - IN OUT PFAST_MUTEX FastMutex); - -NTKERNELAPI -VOID -FASTCALL -ExReleaseFastMutex( - IN OUT PFAST_MUTEX FastMutex); - -NTKERNELAPI -BOOLEAN -FASTCALL -ExTryToAcquireFastMutex( - IN OUT PFAST_MUTEX FastMutex); - NTKERNELAPI VOID FASTCALL ExAcquireFastMutexUnsafe( - IN OUT PFAST_MUTEX FastMutex); + IN OUT PFAST_MUTEX FastMutex); NTKERNELAPI VOID FASTCALL ExReleaseFastMutexUnsafe( - IN OUT PFAST_MUTEX FastMutex); + IN OUT PFAST_MUTEX FastMutex); NTKERNELAPI BOOLEAN NTAPI ExAcquireResourceExclusiveLite( - IN PERESOURCE Resource, - IN BOOLEAN Wait); + IN OUT PERESOURCE Resource, + IN BOOLEAN Wait); NTKERNELAPI BOOLEAN NTAPI ExAcquireResourceSharedLite( - IN PERESOURCE Resource, - IN BOOLEAN Wait); + IN OUT PERESOURCE Resource, + IN BOOLEAN Wait); NTKERNELAPI BOOLEAN NTAPI ExAcquireSharedStarveExclusive( - IN PERESOURCE Resource, - IN BOOLEAN Wait); + IN OUT PERESOURCE Resource, + IN BOOLEAN Wait); NTKERNELAPI BOOLEAN NTAPI ExAcquireSharedWaitForExclusive( - IN PERESOURCE Resource, - IN BOOLEAN Wait); + IN OUT PERESOURCE Resource, + IN BOOLEAN Wait); NTKERNELAPI PVOID NTAPI ExAllocatePool( - IN POOL_TYPE PoolType, - IN SIZE_T NumberOfBytes); - -#ifdef POOL_TAGGING -#define ExAllocatePool(p,n) ExAllocatePoolWithTag(p,n,' kdD') -#endif /* POOL_TAGGING */ + IN POOL_TYPE PoolType, + IN SIZE_T NumberOfBytes); NTKERNELAPI PVOID NTAPI ExAllocatePoolWithQuota( - IN POOL_TYPE PoolType, - IN SIZE_T NumberOfBytes); - -#ifdef POOL_TAGGING -#define ExAllocatePoolWithQuota(p,n) ExAllocatePoolWithQuotaTag(p,n,' kdD') -#endif /* POOL_TAGGING */ + IN POOL_TYPE PoolType, + IN SIZE_T NumberOfBytes); NTKERNELAPI PVOID NTAPI ExAllocatePoolWithQuotaTag( - IN POOL_TYPE PoolType, - IN SIZE_T NumberOfBytes, - IN ULONG Tag); + IN POOL_TYPE PoolType, + IN SIZE_T NumberOfBytes, + IN ULONG Tag); #ifndef POOL_TAGGING #define ExAllocatePoolWithQuotaTag(a,b,c) ExAllocatePoolWithQuota(a,b) -#endif /* POOL_TAGGING */ +#endif NTKERNELAPI PVOID NTAPI ExAllocatePoolWithTag( - IN POOL_TYPE PoolType, - IN SIZE_T NumberOfBytes, - IN ULONG Tag); + IN POOL_TYPE PoolType, + IN SIZE_T NumberOfBytes, + IN ULONG Tag); + +#ifndef POOL_TAGGING +#define ExAllocatePoolWithTag(a,b,c) ExAllocatePool(a,b) +#endif NTKERNELAPI PVOID NTAPI ExAllocatePoolWithTagPriority( - IN POOL_TYPE PoolType, - IN SIZE_T NumberOfBytes, - IN ULONG Tag, - IN EX_POOL_PRIORITY Priority); + IN POOL_TYPE PoolType, + IN SIZE_T NumberOfBytes, + IN ULONG Tag, + IN EX_POOL_PRIORITY Priority); NTKERNELAPI VOID NTAPI ExConvertExclusiveToSharedLite( - IN PERESOURCE Resource); + IN OUT PERESOURCE Resource); NTKERNELAPI NTSTATUS NTAPI ExCreateCallback( - OUT PCALLBACK_OBJECT *CallbackObject, - IN POBJECT_ATTRIBUTES ObjectAttributes, - IN BOOLEAN Create, - IN BOOLEAN AllowMultipleCallbacks); + OUT PCALLBACK_OBJECT *CallbackObject, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN BOOLEAN Create, + IN BOOLEAN AllowMultipleCallbacks); NTKERNELAPI VOID NTAPI ExDeleteNPagedLookasideList( - IN PNPAGED_LOOKASIDE_LIST Lookaside); + IN OUT PNPAGED_LOOKASIDE_LIST Lookaside); NTKERNELAPI VOID NTAPI ExDeletePagedLookasideList( - IN PPAGED_LOOKASIDE_LIST Lookaside); + IN PPAGED_LOOKASIDE_LIST Lookaside); NTKERNELAPI NTSTATUS NTAPI ExDeleteResourceLite( - IN PERESOURCE Resource); + IN OUT PERESOURCE Resource); NTKERNELAPI VOID NTAPI ExFreePool( - IN PVOID P); - -#ifdef POOL_TAGGING -#define ExFreePool(P) ExFreePoolWithTag(P, 0) -#endif + IN PVOID P); NTKERNELAPI VOID NTAPI ExFreePoolWithTag( - IN PVOID P, - IN ULONG Tag); + IN PVOID P, + IN ULONG Tag); NTKERNELAPI ULONG NTAPI ExGetExclusiveWaiterCount( - IN PERESOURCE Resource); + IN PERESOURCE Resource); NTKERNELAPI KPROCESSOR_MODE NTAPI -ExGetPreviousMode( - VOID); +ExGetPreviousMode(VOID); NTKERNELAPI ULONG NTAPI ExGetSharedWaiterCount( - IN PERESOURCE Resource); + IN PERESOURCE Resource); NTKERNELAPI VOID NTAPI ExInitializeNPagedLookasideList( - IN PNPAGED_LOOKASIDE_LIST Lookaside, - IN PALLOCATE_FUNCTION Allocate OPTIONAL, - IN PFREE_FUNCTION Free OPTIONAL, - IN ULONG Flags, - IN SIZE_T Size, - IN ULONG Tag, - IN USHORT Depth); + IN PNPAGED_LOOKASIDE_LIST Lookaside, + IN PALLOCATE_FUNCTION Allocate OPTIONAL, + IN PFREE_FUNCTION Free OPTIONAL, + IN ULONG Flags, + IN SIZE_T Size, + IN ULONG Tag, + IN USHORT Depth); NTKERNELAPI VOID NTAPI ExInitializePagedLookasideList( - IN PPAGED_LOOKASIDE_LIST Lookaside, - IN PALLOCATE_FUNCTION Allocate OPTIONAL, - IN PFREE_FUNCTION Free OPTIONAL, - IN ULONG Flags, - IN SIZE_T Size, - IN ULONG Tag, - IN USHORT Depth); + IN PPAGED_LOOKASIDE_LIST Lookaside, + IN PALLOCATE_FUNCTION Allocate OPTIONAL, + IN PFREE_FUNCTION Free OPTIONAL, + IN ULONG Flags, + IN SIZE_T Size, + IN ULONG Tag, + IN USHORT Depth); NTKERNELAPI NTSTATUS NTAPI ExInitializeResourceLite( - IN PERESOURCE Resource); + OUT PERESOURCE Resource); NTKERNELAPI LARGE_INTEGER NTAPI ExInterlockedAddLargeInteger( - IN PLARGE_INTEGER Addend, - IN LARGE_INTEGER Increment, - IN PKSPIN_LOCK Lock); + IN PLARGE_INTEGER Addend, + IN LARGE_INTEGER Increment, + IN PKSPIN_LOCK Lock); #if defined(_WIN64) #define ExInterlockedAddLargeStatistic(Addend, Increment) \ @@ -10259,89 +13609,96 @@ NTKERNELAPI ULONG FASTCALL ExInterlockedAddUlong( - IN PULONG Addend, - IN ULONG Increment, - PKSPIN_LOCK Lock); + IN PULONG Addend, + IN ULONG Increment, + IN OUT PKSPIN_LOCK Lock); #if defined(_AMD64_) || defined(_IA64_) + #define ExInterlockedCompareExchange64(Destination, Exchange, Comperand, Lock) \ InterlockedCompareExchange64(Destination, *(Exchange), *(Comperand)) + #elif defined(_X86_) + NTKERNELAPI LONGLONG FASTCALL ExfInterlockedCompareExchange64( - IN OUT LONGLONG volatile *Destination, - IN PLONGLONG Exchange, - IN PLONGLONG Comperand); + IN OUT LONGLONG volatile *Destination, + IN PLONGLONG Exchange, + IN PLONGLONG Comperand); + #define ExInterlockedCompareExchange64(Destination, Exchange, Comperand, Lock) \ ExfInterlockedCompareExchange64(Destination, Exchange, Comperand) + #else + NTKERNELAPI LONGLONG FASTCALL ExInterlockedCompareExchange64( - IN OUT LONGLONG volatile *Destination, - IN PLONGLONG Exchange, - IN PLONGLONG Comparand, - IN PKSPIN_LOCK Lock); -#endif + IN OUT LONGLONG volatile *Destination, + IN PLONGLONG Exchange, + IN PLONGLONG Comparand, + IN PKSPIN_LOCK Lock); + +#endif /* defined(_AMD64_) || defined(_IA64_) */ NTKERNELAPI PLIST_ENTRY FASTCALL ExInterlockedInsertHeadList( - IN PLIST_ENTRY ListHead, - IN PLIST_ENTRY ListEntry, - IN PKSPIN_LOCK Lock); + IN OUT PLIST_ENTRY ListHead, + IN OUT PLIST_ENTRY ListEntry, + IN OUT PKSPIN_LOCK Lock); NTKERNELAPI PLIST_ENTRY FASTCALL ExInterlockedInsertTailList( - IN PLIST_ENTRY ListHead, - IN PLIST_ENTRY ListEntry, - IN PKSPIN_LOCK Lock); + IN OUT PLIST_ENTRY ListHead, + IN OUT PLIST_ENTRY ListEntry, + IN OUT PKSPIN_LOCK Lock); NTKERNELAPI PSINGLE_LIST_ENTRY FASTCALL ExInterlockedPopEntryList( - IN PSINGLE_LIST_ENTRY ListHead, - IN PKSPIN_LOCK Lock); + IN OUT PSINGLE_LIST_ENTRY ListHead, + IN OUT PKSPIN_LOCK Lock); NTKERNELAPI PSINGLE_LIST_ENTRY FASTCALL ExInterlockedPushEntryList( - IN PSINGLE_LIST_ENTRY ListHead, - IN PSINGLE_LIST_ENTRY ListEntry, - IN PKSPIN_LOCK Lock); + IN OUT PSINGLE_LIST_ENTRY ListHead, + IN OUT PSINGLE_LIST_ENTRY ListEntry, + IN OUT PKSPIN_LOCK Lock); NTKERNELAPI PLIST_ENTRY FASTCALL ExInterlockedRemoveHeadList( - IN PLIST_ENTRY ListHead, - IN PKSPIN_LOCK Lock); + IN OUT PLIST_ENTRY ListHead, + IN OUT PKSPIN_LOCK Lock); NTKERNELAPI BOOLEAN NTAPI ExIsProcessorFeaturePresent( - IN ULONG ProcessorFeature); + IN ULONG ProcessorFeature); NTKERNELAPI BOOLEAN NTAPI ExIsResourceAcquiredExclusiveLite( - IN PERESOURCE Resource); + IN PERESOURCE Resource); NTKERNELAPI ULONG NTAPI ExIsResourceAcquiredSharedLite( - IN PERESOURCE Resource); + IN PERESOURCE Resource); #define ExIsResourceAcquiredLite ExIsResourceAcquiredSharedLite @@ -10349,243 +13706,368 @@ NTKERNELAPI VOID NTAPI ExLocalTimeToSystemTime( - IN PLARGE_INTEGER LocalTime, - OUT PLARGE_INTEGER SystemTime); + IN PLARGE_INTEGER LocalTime, + OUT PLARGE_INTEGER SystemTime); NTKERNELAPI VOID NTAPI ExNotifyCallback( - IN PCALLBACK_OBJECT CallbackObject, - IN PVOID Argument1, - IN PVOID Argument2); + IN PCALLBACK_OBJECT CallbackObject, + IN PVOID Argument1 OPTIONAL, + IN PVOID Argument2 OPTIONAL); NTKERNELAPI VOID NTAPI ExQueueWorkItem( - IN PWORK_QUEUE_ITEM WorkItem, - IN WORK_QUEUE_TYPE QueueType); + IN OUT PWORK_QUEUE_ITEM WorkItem, + IN WORK_QUEUE_TYPE QueueType); NTKERNELAPI DECLSPEC_NORETURN VOID NTAPI ExRaiseStatus( - IN NTSTATUS Status); + IN NTSTATUS Status); NTKERNELAPI PVOID NTAPI ExRegisterCallback( - IN PCALLBACK_OBJECT CallbackObject, - IN PCALLBACK_FUNCTION CallbackFunction, - IN PVOID CallbackContext); + IN PCALLBACK_OBJECT CallbackObject, + IN PCALLBACK_FUNCTION CallbackFunction, + IN PVOID CallbackContext OPTIONAL); NTKERNELAPI NTSTATUS NTAPI ExReinitializeResourceLite( - IN PERESOURCE Resource); + IN OUT PERESOURCE Resource); NTKERNELAPI VOID NTAPI ExReleaseResourceForThreadLite( - IN PERESOURCE Resource, - IN ERESOURCE_THREAD ResourceThreadId); + IN OUT PERESOURCE Resource, + IN ERESOURCE_THREAD ResourceThreadId); NTKERNELAPI VOID FASTCALL ExReleaseResourceLite( - IN PERESOURCE Resource); + IN OUT PERESOURCE Resource); NTKERNELAPI VOID NTAPI ExSetResourceOwnerPointer( - IN PERESOURCE Resource, - IN PVOID OwnerPointer); + IN OUT PERESOURCE Resource, + IN PVOID OwnerPointer); NTKERNELAPI ULONG NTAPI ExSetTimerResolution( - IN ULONG DesiredTime, - IN BOOLEAN SetResolution); + IN ULONG DesiredTime, + IN BOOLEAN SetResolution); NTKERNELAPI VOID NTAPI ExSystemTimeToLocalTime( - IN PLARGE_INTEGER SystemTime, - OUT PLARGE_INTEGER LocalTime); + IN PLARGE_INTEGER SystemTime, + OUT PLARGE_INTEGER LocalTime); NTKERNELAPI VOID NTAPI ExUnregisterCallback( - IN PVOID CbRegistration); + IN OUT PVOID CbRegistration); - -#endif // (NTDDI_VERSION >= NTDDI_WIN2K) +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ #if (NTDDI_VERSION >= NTDDI_WINXP) + NTKERNELAPI BOOLEAN FASTCALL ExAcquireRundownProtection( - IN OUT PEX_RUNDOWN_REF RunRef); + IN OUT PEX_RUNDOWN_REF RunRef); NTKERNELAPI VOID FASTCALL ExInitializeRundownProtection( - OUT PEX_RUNDOWN_REF RunRef); + OUT PEX_RUNDOWN_REF RunRef); NTKERNELAPI VOID FASTCALL ExReInitializeRundownProtection( - OUT PEX_RUNDOWN_REF RunRef); + IN OUT PEX_RUNDOWN_REF RunRef); NTKERNELAPI VOID FASTCALL ExReleaseRundownProtection( - IN OUT PEX_RUNDOWN_REF RunRef); + IN OUT PEX_RUNDOWN_REF RunRef); NTKERNELAPI VOID FASTCALL ExRundownCompleted( - OUT PEX_RUNDOWN_REF RunRef); + OUT PEX_RUNDOWN_REF RunRef); NTKERNELAPI BOOLEAN NTAPI ExVerifySuite( - IN SUITE_TYPE SuiteType); + IN SUITE_TYPE SuiteType); NTKERNELAPI VOID FASTCALL ExWaitForRundownProtectionRelease( - IN OUT PEX_RUNDOWN_REF RunRef); + IN OUT PEX_RUNDOWN_REF RunRef); -#endif // (NTDDI_VERSION >= NTDDI_WINXP) +#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ #if (NTDDI_VERSION >= NTDDI_WINXPSP2) + NTKERNELAPI BOOLEAN FASTCALL ExAcquireRundownProtectionEx( - IN OUT PEX_RUNDOWN_REF RunRef, - IN ULONG Count); + IN OUT PEX_RUNDOWN_REF RunRef, + IN ULONG Count); NTKERNELAPI VOID FASTCALL ExReleaseRundownProtectionEx( - IN OUT PEX_RUNDOWN_REF RunRef, - IN ULONG Count); -#endif // (NTDDI_VERSION >= NTDDI_WINXPSP2) + IN OUT PEX_RUNDOWN_REF RunRef, + IN ULONG Count); + +#endif /* (NTDDI_VERSION >= NTDDI_WINXPSP2) */ #if (NTDDI_VERSION >= NTDDI_WS03SP1) + NTKERNELAPI PEX_RUNDOWN_REF_CACHE_AWARE NTAPI ExAllocateCacheAwareRundownProtection( - IN POOL_TYPE PoolType, - IN ULONG PoolTag); + IN POOL_TYPE PoolType, + IN ULONG PoolTag); NTKERNELAPI SIZE_T NTAPI ExSizeOfRundownProtectionCacheAware(VOID); -#endif // (NTDDI_VERSION >= NTDDI_WS03SP1) + +NTKERNELAPI +PVOID +NTAPI +ExEnterCriticalRegionAndAcquireResourceShared( + IN OUT PERESOURCE Resource); + +NTKERNELAPI +PVOID +NTAPI +ExEnterCriticalRegionAndAcquireResourceExclusive( + IN OUT PERESOURCE Resource); + +NTKERNELAPI +PVOID +NTAPI +ExEnterCriticalRegionAndAcquireSharedWaitForExclusive( + IN OUT PERESOURCE Resource); + +NTKERNELAPI +VOID +FASTCALL +ExReleaseResourceAndLeaveCriticalRegion( + IN OUT PERESOURCE Resource); + +NTKERNELAPI +VOID +NTAPI +ExInitializeRundownProtectionCacheAware( + OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware, + IN SIZE_T RunRefSize); + +NTKERNELAPI +VOID +NTAPI +ExFreeCacheAwareRundownProtection( + IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware); + +NTKERNELAPI +BOOLEAN +FASTCALL +ExAcquireRundownProtectionCacheAware( + IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware); + +NTKERNELAPI +VOID +FASTCALL +ExReleaseRundownProtectionCacheAware( + IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware); + +NTKERNELAPI +BOOLEAN +FASTCALL +ExAcquireRundownProtectionCacheAwareEx( + IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware, + IN ULONG Count); + +NTKERNELAPI +VOID +FASTCALL +ExReleaseRundownProtectionCacheAwareEx( + IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRef, + IN ULONG Count); + +NTKERNELAPI +VOID +FASTCALL +ExWaitForRundownProtectionReleaseCacheAware( + IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRef); + +NTKERNELAPI +VOID +FASTCALL +ExReInitializeRundownProtectionCacheAware( + IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware); + +NTKERNELAPI +VOID +FASTCALL +ExRundownCompletedCacheAware( + IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware); + +#endif /* (NTDDI_VERSION >= NTDDI_WS03SP1) */ #if (NTDDI_VERSION >= NTDDI_VISTA) + NTKERNELAPI NTSTATUS NTAPI ExInitializeLookasideListEx( - OUT PLOOKASIDE_LIST_EX Lookaside, - IN PALLOCATE_FUNCTION_EX Allocate OPTIONAL, - IN PFREE_FUNCTION_EX Free OPTIONAL, - IN POOL_TYPE PoolType, - IN ULONG Flags, - IN SIZE_T Size, - IN ULONG Tag, - IN USHORT Depth); -#endif + OUT PLOOKASIDE_LIST_EX Lookaside, + IN PALLOCATE_FUNCTION_EX Allocate OPTIONAL, + IN PFREE_FUNCTION_EX Free OPTIONAL, + IN POOL_TYPE PoolType, + IN ULONG Flags, + IN SIZE_T Size, + IN ULONG Tag, + IN USHORT Depth); -#if !defined(MIDL_PASS) +NTKERNELAPI +VOID +NTAPI +ExDeleteLookasideListEx( + IN OUT PLOOKASIDE_LIST_EX Lookaside); + +NTKERNELAPI +VOID +NTAPI +ExFlushLookasideListEx( + IN OUT PLOOKASIDE_LIST_EX Lookaside); + +FORCEINLINE +PVOID +ExAllocateFromLookasideListEx( + IN OUT PLOOKASIDE_LIST_EX Lookaside) +{ + PVOID Entry; + + Lookaside->L.TotalAllocates += 1; + Entry = InterlockedPopEntrySList(&Lookaside->L.ListHead); + if (Entry == NULL) { + Lookaside->L.AllocateMisses += 1; + Entry = (Lookaside->L.AllocateEx)(Lookaside->L.Type, + Lookaside->L.Size, + Lookaside->L.Tag, + Lookaside); + } + return Entry; +} + +FORCEINLINE +VOID +ExFreeToLookasideListEx( + IN OUT PLOOKASIDE_LIST_EX Lookaside, + IN PVOID Entry) +{ + Lookaside->L.TotalFrees += 1; + if (ExQueryDepthSList(&Lookaside->L.ListHead) >= Lookaside->L.Depth) { + Lookaside->L.FreeMisses += 1; + (Lookaside->L.FreeEx)(Entry, Lookaside); + } else { + InterlockedPushEntrySList(&Lookaside->L.ListHead, (PSLIST_ENTRY)Entry); + } + return; +} + +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + +#if (NTDDI_VERSION >= NTDDI_WIN7) + +NTKERNELAPI +VOID +NTAPI +ExSetResourceOwnerPointerEx( + IN OUT PERESOURCE Resource, + IN PVOID OwnerPointer, + IN ULONG Flags); + +#define FLAG_OWNER_POINTER_IS_THREAD 0x1 + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ static __inline PVOID ExAllocateFromNPagedLookasideList( - IN PNPAGED_LOOKASIDE_LIST Lookaside) + IN OUT PNPAGED_LOOKASIDE_LIST Lookaside) { - PVOID Entry; + PVOID Entry; - Lookaside->L.TotalAllocates++; - Entry = InterlockedPopEntrySList(&Lookaside->L.ListHead); - if (Entry == NULL) { - Lookaside->L.AllocateMisses++; - Entry = (Lookaside->L.Allocate)(Lookaside->L.Type, - Lookaside->L.Size, - Lookaside->L.Tag); - } - return Entry; -} - -static __inline PVOID -ExAllocateFromPagedLookasideList( - IN PPAGED_LOOKASIDE_LIST Lookaside) -{ - PVOID Entry; - - Lookaside->L.TotalAllocates++; - Entry = InterlockedPopEntrySList(&Lookaside->L.ListHead); - if (Entry == NULL) { - Lookaside->L.AllocateMisses++; - Entry = (Lookaside->L.Allocate)(Lookaside->L.Type, - Lookaside->L.Size, - Lookaside->L.Tag); - } - return Entry; + Lookaside->L.TotalAllocates++; +#if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_) + Entry = ExInterlockedPopEntrySList(&Lookaside->L.ListHead, + &Lookaside->Lock__ObsoleteButDoNotDelete); +#else + Entry = InterlockedPopEntrySList(&Lookaside->L.ListHead); +#endif + if (Entry == NULL) { + Lookaside->L.AllocateMisses++; + Entry = (Lookaside->L.Allocate)(Lookaside->L.Type, + Lookaside->L.Size, + Lookaside->L.Tag); + } + return Entry; } static __inline VOID ExFreeToNPagedLookasideList( - IN PNPAGED_LOOKASIDE_LIST Lookaside, - IN PVOID Entry) + IN OUT PNPAGED_LOOKASIDE_LIST Lookaside, + IN PVOID Entry) { - Lookaside->L.TotalFrees++; - if (ExQueryDepthSList(&Lookaside->L.ListHead) >= Lookaside->L.Depth) { - Lookaside->L.FreeMisses++; - (Lookaside->L.Free)(Entry); - } else { - InterlockedPushEntrySList(&Lookaside->L.ListHead, (PSLIST_ENTRY)Entry); - } + Lookaside->L.TotalFrees++; + if (ExQueryDepthSList(&Lookaside->L.ListHead) >= Lookaside->L.Depth) { + Lookaside->L.FreeMisses++; + (Lookaside->L.Free)(Entry); + } else { +#if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_) + ExInterlockedPushEntrySList(&Lookaside->L.ListHead, + (PSLIST_ENTRY)Entry, + &Lookaside->Lock__ObsoleteButDoNotDelete); +#else + InterlockedPushEntrySList(&Lookaside->L.ListHead, (PSLIST_ENTRY)Entry); +#endif + } } -static __inline VOID -ExFreeToPagedLookasideList( - IN PPAGED_LOOKASIDE_LIST Lookaside, - IN PVOID Entry) -{ - Lookaside->L.TotalFrees++; - if (ExQueryDepthSList(&Lookaside->L.ListHead) >= Lookaside->L.Depth) { - Lookaside->L.FreeMisses++; - (Lookaside->L.Free)(Entry); - } else { - InterlockedPushEntrySList(&Lookaside->L.ListHead, (PSLIST_ENTRY)Entry); - } -} - -#endif // !defined(MIDL_PASS) /****************************************************************************** * Object Manager Functions * @@ -10630,7 +14112,7 @@ NTKERNELAPI NTSTATUS NTAPI ObReferenceObjectByPointer( - IN PVOID Object, + IN PVOID Object, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType OPTIONAL, IN KPROCESSOR_MODE AccessMode); @@ -10644,10 +14126,99 @@ ObReleaseObjectSecurity( #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ +#if (NTDDI_VERSION >= NTDDI_VISTA) +NTKERNELAPI +VOID +NTAPI +ObDereferenceObjectDeferDelete( + IN PVOID Object); +#endif + +#if (NTDDI_VERSION >= NTDDI_VISTASP1) +NTKERNELAPI +NTSTATUS +NTAPI +ObRegisterCallbacks( + IN POB_CALLBACK_REGISTRATION CallbackRegistration, + OUT PVOID *RegistrationHandle); + +NTKERNELAPI +VOID +NTAPI +ObUnRegisterCallbacks( + IN PVOID RegistrationHandle); + +NTKERNELAPI +USHORT +NTAPI +ObGetFilterVersion(VOID); + +#endif /* (NTDDI_VERSION >= NTDDI_VISTASP1) */ + +#if (NTDDI_VERSION >= NTDDI_WIN7) + +NTKERNELAPI +NTSTATUS +NTAPI +ObReferenceObjectByHandleWithTag( + IN HANDLE Handle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_TYPE ObjectType OPTIONAL, + IN KPROCESSOR_MODE AccessMode, + IN ULONG Tag, + OUT PVOID *Object, + OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL); + +NTKERNELAPI +LONG_PTR +FASTCALL +ObfReferenceObjectWithTag( + IN PVOID Object, + IN ULONG Tag); + +NTKERNELAPI +NTSTATUS +NTAPI +ObReferenceObjectByPointerWithTag( + IN PVOID Object, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_TYPE ObjectType OPTIONAL, + IN KPROCESSOR_MODE AccessMode, + IN ULONG Tag); + +NTKERNELAPI +LONG_PTR +FASTCALL +ObfDereferenceObjectWithTag( + IN PVOID Object, + IN ULONG Tag); + +NTKERNELAPI +VOID +NTAPI +ObDereferenceObjectDeferDeleteWithTag( + IN PVOID Object, + IN ULONG Tag); + +#define ObDereferenceObject ObfDereferenceObject +#define ObReferenceObject ObfReferenceObject +#define ObDereferenceObjectWithTag ObfDereferenceObjectWithTag +#define ObReferenceObjectWithTag ObfReferenceObjectWithTag + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + + /****************************************************************************** * Process Manager Functions * ******************************************************************************/ +NTKERNELAPI +NTSTATUS +NTAPI +PsWrapApcWow64Thread( + IN OUT PVOID *ApcContext, + IN OUT PVOID *ApcRoutine); + /* * PEPROCESS * PsGetCurrentProcess(VOID) @@ -10655,19 +14226,16 @@ ObReleaseObjectSecurity( #define PsGetCurrentProcess IoGetCurrentProcess #if !defined(_PSGETCURRENTTHREAD_) - #define _PSGETCURRENTTHREAD_ - FORCEINLINE PETHREAD NTAPI -PsGetCurrentThread ( - VOID) +PsGetCurrentThread(VOID) { return (PETHREAD)KeGetCurrentThread(); } +#endif /* !_PSGETCURRENTTHREAD_ */ -#endif #if (NTDDI_VERSION >= NTDDI_WIN2K) @@ -10675,41 +14243,40 @@ NTKERNELAPI NTSTATUS NTAPI PsCreateSystemThread( - OUT PHANDLE ThreadHandle, - IN ULONG DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, - IN HANDLE ProcessHandle OPTIONAL, - OUT PCLIENT_ID ClientId OPTIONAL, - IN PKSTART_ROUTINE StartRoutine, - IN PVOID StartContext OPTIONAL); + OUT PHANDLE ThreadHandle, + IN ULONG DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, + IN HANDLE ProcessHandle OPTIONAL, + OUT PCLIENT_ID ClientId OPTIONAL, + IN PKSTART_ROUTINE StartRoutine, + IN PVOID StartContext OPTIONAL); NTKERNELAPI NTSTATUS NTAPI PsTerminateSystemThread( - IN NTSTATUS ExitStatus); + IN NTSTATUS ExitStatus); -#endif + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ /****************************************************************************** * WMI Library Support Functions * ******************************************************************************/ #ifdef RUN_WPP - #if (NTDDI_VERSION >= NTDDI_WINXP) NTKERNELAPI NTSTATUS -DDKCDECLAPI +__cdecl WmiTraceMessage( - IN TRACEHANDLE LoggerHandle, - IN ULONG MessageFlags, - IN LPGUID MessageGuid, - IN USHORT MessageNumber, + IN TRACEHANDLE LoggerHandle, + IN ULONG MessageFlags, + IN LPGUID MessageGuid, + IN USHORT MessageNumber, IN ...); #endif - -#endif +#endif /* RUN_WPP */ #if (NTDDI_VERSION >= NTDDI_WINXP) @@ -10717,82 +14284,167 @@ NTKERNELAPI NTSTATUS NTAPI WmiQueryTraceInformation( - IN TRACE_INFORMATION_CLASS TraceInformationClass, - OUT PVOID TraceInformation, - IN ULONG TraceInformationLength, - OUT PULONG RequiredLength OPTIONAL, - IN PVOID Buffer OPTIONAL); + IN TRACE_INFORMATION_CLASS TraceInformationClass, + OUT PVOID TraceInformation, + IN ULONG TraceInformationLength, + OUT PULONG RequiredLength OPTIONAL, + IN PVOID Buffer OPTIONAL); #if 0 /* FIXME: Get va_list from where? */ NTKERNELAPI NTSTATUS -DDKCDECLAPI +__cdecl WmiTraceMessageVa( - IN TRACEHANDLE LoggerHandle, - IN ULONG MessageFlags, - IN LPGUID MessageGuid, - IN USHORT MessageNumber, - IN va_list MessageArgList); + IN TRACEHANDLE LoggerHandle, + IN ULONG MessageFlags, + IN LPGUID MessageGuid, + IN USHORT MessageNumber, + IN va_list MessageArgList); #endif +#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ + +#ifndef TRACE_INFORMATION_CLASS_DEFINE + +#if (NTDDI_VERSION >= NTDDI_WINXP) +NTKERNELAPI +NTSTATUS +NTAPI +WmiQueryTraceInformation( + IN TRACE_INFORMATION_CLASS TraceInformationClass, + OUT PVOID TraceInformation, + IN ULONG TraceInformationLength, + OUT PULONG RequiredLength OPTIONAL, + IN PVOID Buffer OPTIONAL); #endif +#define TRACE_INFORMATION_CLASS_DEFINE + +#endif /* TRACE_INFOPRMATION_CLASS_DEFINE */ + +#if (NTDDI_VERSION >= NTDDI_VISTA) + +NTSTATUS +NTKERNELAPI +NTAPI +EtwRegister( + IN LPCGUID ProviderId, + IN PETWENABLECALLBACK EnableCallback OPTIONAL, + IN PVOID CallbackContext OPTIONAL, + OUT PREGHANDLE RegHandle); + +NTSTATUS +NTKERNELAPI +NTAPI +EtwUnregister( + IN REGHANDLE RegHandle); + +BOOLEAN +NTKERNELAPI +NTAPI +EtwEventEnabled( + IN REGHANDLE RegHandle, + IN PCEVENT_DESCRIPTOR EventDescriptor); + +BOOLEAN +NTKERNELAPI +NTAPI +EtwProviderEnabled( + IN REGHANDLE RegHandle, + IN UCHAR Level, + IN ULONGLONG Keyword); + +NTSTATUS +NTKERNELAPI +NTAPI +EtwActivityIdControl( + IN ULONG ControlCode, + IN OUT LPGUID ActivityId); + +NTSTATUS +NTKERNELAPI +NTAPI +EtwWrite( + IN REGHANDLE RegHandle, + IN PCEVENT_DESCRIPTOR EventDescriptor, + IN LPCGUID ActivityId OPTIONAL, + IN ULONG UserDataCount, + IN PEVENT_DATA_DESCRIPTOR UserData OPTIONAL); + +NTSTATUS +NTKERNELAPI +NTAPI +EtwWriteTransfer( + IN REGHANDLE RegHandle, + IN PCEVENT_DESCRIPTOR EventDescriptor, + IN LPCGUID ActivityId OPTIONAL, + IN LPCGUID RelatedActivityId OPTIONAL, + IN ULONG UserDataCount, + IN PEVENT_DATA_DESCRIPTOR UserData OPTIONAL); + +NTSTATUS +NTKERNELAPI +NTAPI +EtwWriteString( + IN REGHANDLE RegHandle, + IN UCHAR Level, + IN ULONGLONG Keyword, + IN LPCGUID ActivityId OPTIONAL, + IN PCWSTR String); + +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + +#if (NTDDI_VERSION >= NTDDI_WIN7) +NTSTATUS +NTKERNELAPI +NTAPI +EtwWriteEx( + IN REGHANDLE RegHandle, + IN PCEVENT_DESCRIPTOR EventDescriptor, + IN ULONG64 Filter, + IN ULONG Flags, + IN LPCGUID ActivityId OPTIONAL, + IN LPCGUID RelatedActivityId OPTIONAL, + IN ULONG UserDataCount, + IN PEVENT_DATA_DESCRIPTOR UserData OPTIONAL); +#endif + + + /****************************************************************************** * Kernel Debugger Functions * ******************************************************************************/ #ifndef _DBGNT_ + ULONG -DDKCDECLAPI +__cdecl DbgPrint( - IN PCSTR Format, + IN PCSTR Format, + IN ...); + +#if (NTDDI_VERSION >= NTDDI_WIN2K) +NTSYSAPI +ULONG +__cdecl +DbgPrintReturnControlC( + IN PCCH Format, IN ...); #endif -#if DBG +#if (NTDDI_VERSION >= NTDDI_WINXP) -#define KdPrint(_x_) DbgPrint _x_ -#define KdPrintEx(_x_) DbgPrintEx _x_ -#define vKdPrintExWithPrefix(_x_) vDbgPrintExWithPrefix _x_ -#define KdBreakPoint() DbgBreakPoint() -#define KdBreakPointWithStatus(s) DbgBreakPointWithStatus(s) - -#else /* !DBG */ - -#define KdPrint(_x_) -#define KdPrintEx(_x_) -#define vKdPrintExWithPrefix(_x_) -#define KdBreakPoint() -#define KdBreakPointWithStatus(s) - -#endif /* !DBG */ - -#if defined(__GNUC__) - -extern NTKERNELAPI BOOLEAN KdDebuggerNotPresent; -extern NTKERNELAPI BOOLEAN KdDebuggerEnabled; -#define KD_DEBUGGER_ENABLED KdDebuggerEnabled -#define KD_DEBUGGER_NOT_PRESENT KdDebuggerNotPresent - -#elif defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_) || defined(_WDMDDK_) || defined(_NTOSP_) - -extern NTKERNELAPI PBOOLEAN KdDebuggerNotPresent; -extern NTKERNELAPI PBOOLEAN KdDebuggerEnabled; -#define KD_DEBUGGER_ENABLED *KdDebuggerEnabled -#define KD_DEBUGGER_NOT_PRESENT *KdDebuggerNotPresent - -#else - -extern BOOLEAN KdDebuggerNotPresent; -extern BOOLEAN KdDebuggerEnabled; -#define KD_DEBUGGER_ENABLED KdDebuggerEnabled -#define KD_DEBUGGER_NOT_PRESENT KdDebuggerNotPresent - -#endif +NTSYSAPI +ULONG +__cdecl +DbgPrintEx( + IN ULONG ComponentId, + IN ULONG Level, + IN PCSTR Format, + IN ...); #ifdef _VA_LIST_DEFINED -#if (NTDDI_VERSION >= NTDDI_WINXP) NTSYSAPI ULONG @@ -10813,84 +14465,120 @@ vDbgPrintExWithPrefix( IN PCCH Format, IN va_list ap); +#endif /* _VA_LIST_DEFINED */ + +NTSYSAPI +NTSTATUS +NTAPI +DbgQueryDebugFilterState( + IN ULONG ComponentId, + IN ULONG Level); + +NTSYSAPI +NTSTATUS +NTAPI +DbgSetDebugFilterState( + IN ULONG ComponentId, + IN ULONG Level, + IN BOOLEAN State); + +#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ + +#if (NTDDI_VERSION >= NTDDI_VISTA) + +typedef VOID +(*PDEBUG_PRINT_CALLBACK)( + IN PSTRING Output, + IN ULONG ComponentId, + IN ULONG Level); + +NTSYSAPI +NTSTATUS +NTAPI +DbgSetDebugPrintCallback( + IN PDEBUG_PRINT_CALLBACK DebugPrintCallback, + IN BOOLEAN Enable); + +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + +#endif /* _DBGNT_ */ + +#if DBG + +#define KdPrint(_x_) DbgPrint _x_ +#define KdPrintEx(_x_) DbgPrintEx _x_ +#define vKdPrintEx(_x_) vDbgPrintEx _x_ +#define vKdPrintExWithPrefix(_x_) vDbgPrintExWithPrefix _x_ +#define KdBreakPoint() DbgBreakPoint() +#define KdBreakPointWithStatus(s) DbgBreakPointWithStatus(s) + +#else /* !DBG */ + +#define KdPrint(_x_) +#define KdPrintEx(_x_) +#define vKdPrintEx(_x_) +#define vKdPrintExWithPrefix(_x_) +#define KdBreakPoint() +#define KdBreakPointWithStatus(s) + +#endif /* !DBG */ + +#if defined(__GNUC__) + +extern NTKERNELAPI BOOLEAN KdDebuggerNotPresent; +extern NTKERNELAPI BOOLEAN KdDebuggerEnabled; +#define KD_DEBUGGER_ENABLED KdDebuggerEnabled +#define KD_DEBUGGER_NOT_PRESENT KdDebuggerNotPresent + +#elif defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_) || defined(_WDMDDK_) || defined(_NTOSP_) + +extern NTKERNELAPI PBOOLEAN KdDebuggerNotPresent; +extern NTKERNELAPI PBOOLEAN KdDebuggerEnabled; +#define KD_DEBUGGER_ENABLED *KdDebuggerEnabled +#define KD_DEBUGGER_NOT_PRESENT *KdDebuggerNotPresent + +#else + +extern BOOLEAN KdDebuggerNotPresent; +extern BOOLEAN KdDebuggerEnabled; +#define KD_DEBUGGER_ENABLED KdDebuggerEnabled +#define KD_DEBUGGER_NOT_PRESENT KdDebuggerNotPresent + #endif -#endif // _VA_LIST_DEFINED #if (NTDDI_VERSION >= NTDDI_WIN2K) NTKERNELAPI NTSTATUS NTAPI -KdDisableDebugger( - VOID); +KdDisableDebugger(VOID); NTKERNELAPI NTSTATUS NTAPI -KdEnableDebugger( - VOID); +KdEnableDebugger(VOID); #if (_MSC_FULL_VER >= 150030729) && !defined(IMPORT_NATIVE_DBG_BREAK) #define DbgBreakPoint __debugbreak #else VOID NTAPI -DbgBreakPoint( - VOID); +DbgBreakPoint(VOID); #endif NTSYSAPI VOID NTAPI DbgBreakPointWithStatus( - IN ULONG Status); + IN ULONG Status); -NTSYSAPI -ULONG -DDKCDECLAPI -DbgPrintReturnControlC( - IN PCCH Format, - IN ...); - -#endif - -#if (NTDDI_VERSION >= NTDDI_WINXP) - -NTSYSAPI -ULONG -DDKCDECLAPI -DbgPrintEx( - IN ULONG ComponentId, - IN ULONG Level, - IN PCSTR Format, - IN ...); - -NTSYSAPI -NTSTATUS -NTAPI -DbgQueryDebugFilterState( - IN ULONG ComponentId, - IN ULONG Level); - -NTSYSAPI -NTSTATUS -NTAPI -DbgSetDebugFilterState( - IN ULONG ComponentId, - IN ULONG Level, - IN BOOLEAN State); - -#endif +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ #if (NTDDI_VERSION >= NTDDI_WS03) - NTKERNELAPI BOOLEAN NTAPI -KdRefreshDebuggerNotPresent( - VOID -); - +KdRefreshDebuggerNotPresent(VOID); #endif #if (NTDDI_VERSION >= NTDDI_WS03SP1) @@ -10905,16 +14593,20 @@ KdChangeOption( OUT PVOID OutBuffer, OUT PULONG OutBufferNeeded OPTIONAL); #endif +/* Hardware Abstraction Layer Functions */ + +#if (NTDDI_VERSION >= NTDDI_WIN2K) #if defined(USE_DMA_MACROS) && !defined(_NTHAL_) && (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_) + FORCEINLINE PVOID NTAPI HalAllocateCommonBuffer( IN PDMA_ADAPTER DmaAdapter, - IN ULONG Length, - OUT PPHYSICAL_ADDRESS LogicalAddress, - IN BOOLEAN CacheEnabled) + IN ULONG Length, + OUT PPHYSICAL_ADDRESS LogicalAddress, + IN BOOLEAN CacheEnabled) { PALLOCATE_COMMON_BUFFER allocateCommonBuffer; PVOID commonBuffer; @@ -10930,10 +14622,10 @@ VOID NTAPI HalFreeCommonBuffer( IN PDMA_ADAPTER DmaAdapter, - IN ULONG Length, - IN PHYSICAL_ADDRESS LogicalAddress, - IN PVOID VirtualAddress, - IN BOOLEAN CacheEnabled) + IN ULONG Length, + IN PHYSICAL_ADDRESS LogicalAddress, + IN PVOID VirtualAddress, + IN BOOLEAN CacheEnabled) { PFREE_COMMON_BUFFER freeCommonBuffer; @@ -10957,14 +14649,224 @@ HalReadDmaCounter( return counter; } -#endif +FORCEINLINE +ULONG +HalGetDmaAlignment( + IN PDMA_ADAPTER DmaAdapter) +{ + PGET_DMA_ALIGNMENT getDmaAlignment; + ULONG alignment; + getDmaAlignment = *(DmaAdapter)->DmaOperations->GetDmaAlignment; + ASSERT( getDmaAlignment != NULL ); + alignment = getDmaAlignment( DmaAdapter ); + return alignment; +} + +#endif /* USE_DMA_MACROS ... */ +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ #ifndef _NTTMAPI_ #define _NTTMAPI_ #include +#define TRANSACTIONMANAGER_QUERY_INFORMATION (0x0001) +#define TRANSACTIONMANAGER_SET_INFORMATION (0x0002) +#define TRANSACTIONMANAGER_RECOVER (0x0004) +#define TRANSACTIONMANAGER_RENAME (0x0008) +#define TRANSACTIONMANAGER_CREATE_RM (0x0010) +#define TRANSACTIONMANAGER_BIND_TRANSACTION (0x0020) + +#define TRANSACTIONMANAGER_GENERIC_READ (STANDARD_RIGHTS_READ |\ + TRANSACTIONMANAGER_QUERY_INFORMATION) + +#define TRANSACTIONMANAGER_GENERIC_WRITE (STANDARD_RIGHTS_WRITE |\ + TRANSACTIONMANAGER_SET_INFORMATION |\ + TRANSACTIONMANAGER_RECOVER |\ + TRANSACTIONMANAGER_RENAME |\ + TRANSACTIONMANAGER_CREATE_RM) + +#define TRANSACTIONMANAGER_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE) + +#define TRANSACTIONMANAGER_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED |\ + TRANSACTIONMANAGER_GENERIC_READ |\ + TRANSACTIONMANAGER_GENERIC_WRITE |\ + TRANSACTIONMANAGER_GENERIC_EXECUTE |\ + TRANSACTIONMANAGER_BIND_TRANSACTION) + +#define TRANSACTION_QUERY_INFORMATION (0x0001) +#define TRANSACTION_SET_INFORMATION (0x0002) +#define TRANSACTION_ENLIST (0x0004) +#define TRANSACTION_COMMIT (0x0008) +#define TRANSACTION_ROLLBACK (0x0010) +#define TRANSACTION_PROPAGATE (0x0020) +#define TRANSACTION_RIGHT_RESERVED1 (0x0040) + +#define TRANSACTION_GENERIC_READ (STANDARD_RIGHTS_READ |\ + TRANSACTION_QUERY_INFORMATION |\ + SYNCHRONIZE) + +#define TRANSACTION_GENERIC_WRITE (STANDARD_RIGHTS_WRITE |\ + TRANSACTION_SET_INFORMATION |\ + TRANSACTION_COMMIT |\ + TRANSACTION_ENLIST |\ + TRANSACTION_ROLLBACK |\ + TRANSACTION_PROPAGATE |\ + SYNCHRONIZE) + +#define TRANSACTION_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE |\ + TRANSACTION_COMMIT |\ + TRANSACTION_ROLLBACK |\ + SYNCHRONIZE) + +#define TRANSACTION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED |\ + TRANSACTION_GENERIC_READ |\ + TRANSACTION_GENERIC_WRITE |\ + TRANSACTION_GENERIC_EXECUTE) + +#define TRANSACTION_RESOURCE_MANAGER_RIGHTS (TRANSACTION_GENERIC_READ |\ + STANDARD_RIGHTS_WRITE |\ + TRANSACTION_SET_INFORMATION |\ + TRANSACTION_ENLIST |\ + TRANSACTION_ROLLBACK |\ + TRANSACTION_PROPAGATE |\ + SYNCHRONIZE) + +#define RESOURCEMANAGER_QUERY_INFORMATION (0x0001) +#define RESOURCEMANAGER_SET_INFORMATION (0x0002) +#define RESOURCEMANAGER_RECOVER (0x0004) +#define RESOURCEMANAGER_ENLIST (0x0008) +#define RESOURCEMANAGER_GET_NOTIFICATION (0x0010) +#define RESOURCEMANAGER_REGISTER_PROTOCOL (0x0020) +#define RESOURCEMANAGER_COMPLETE_PROPAGATION (0x0040) + +#define RESOURCEMANAGER_GENERIC_READ (STANDARD_RIGHTS_READ |\ + RESOURCEMANAGER_QUERY_INFORMATION |\ + SYNCHRONIZE) + +#define RESOURCEMANAGER_GENERIC_WRITE (STANDARD_RIGHTS_WRITE |\ + RESOURCEMANAGER_SET_INFORMATION |\ + RESOURCEMANAGER_RECOVER |\ + RESOURCEMANAGER_ENLIST |\ + RESOURCEMANAGER_GET_NOTIFICATION |\ + RESOURCEMANAGER_REGISTER_PROTOCOL |\ + RESOURCEMANAGER_COMPLETE_PROPAGATION |\ + SYNCHRONIZE) + +#define RESOURCEMANAGER_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE |\ + RESOURCEMANAGER_RECOVER |\ + RESOURCEMANAGER_ENLIST |\ + RESOURCEMANAGER_GET_NOTIFICATION |\ + RESOURCEMANAGER_COMPLETE_PROPAGATION |\ + SYNCHRONIZE) + +#define RESOURCEMANAGER_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED |\ + RESOURCEMANAGER_GENERIC_READ |\ + RESOURCEMANAGER_GENERIC_WRITE |\ + RESOURCEMANAGER_GENERIC_EXECUTE) + +#define ENLISTMENT_QUERY_INFORMATION (0x0001) +#define ENLISTMENT_SET_INFORMATION (0x0002) +#define ENLISTMENT_RECOVER (0x0004) +#define ENLISTMENT_SUBORDINATE_RIGHTS (0x0008) +#define ENLISTMENT_SUPERIOR_RIGHTS (0x0010) + +#define ENLISTMENT_GENERIC_READ (STANDARD_RIGHTS_READ |\ + ENLISTMENT_QUERY_INFORMATION) + +#define ENLISTMENT_GENERIC_WRITE (STANDARD_RIGHTS_WRITE |\ + ENLISTMENT_SET_INFORMATION |\ + ENLISTMENT_RECOVER |\ + ENLISTMENT_SUBORDINATE_RIGHTS |\ + ENLISTMENT_SUPERIOR_RIGHTS) + +#define ENLISTMENT_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE |\ + ENLISTMENT_RECOVER |\ + ENLISTMENT_SUBORDINATE_RIGHTS |\ + ENLISTMENT_SUPERIOR_RIGHTS) + +#define ENLISTMENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED |\ + ENLISTMENT_GENERIC_READ |\ + ENLISTMENT_GENERIC_WRITE |\ + ENLISTMENT_GENERIC_EXECUTE) + +typedef enum _TRANSACTION_OUTCOME { + TransactionOutcomeUndetermined = 1, + TransactionOutcomeCommitted, + TransactionOutcomeAborted, +} TRANSACTION_OUTCOME; + + +typedef enum _TRANSACTION_STATE { + TransactionStateNormal = 1, + TransactionStateIndoubt, + TransactionStateCommittedNotify, +} TRANSACTION_STATE; + + +typedef struct _TRANSACTION_BASIC_INFORMATION { + GUID TransactionId; + ULONG State; + ULONG Outcome; +} TRANSACTION_BASIC_INFORMATION, *PTRANSACTION_BASIC_INFORMATION; + +typedef struct _TRANSACTIONMANAGER_BASIC_INFORMATION { + GUID TmIdentity; + LARGE_INTEGER VirtualClock; +} TRANSACTIONMANAGER_BASIC_INFORMATION, *PTRANSACTIONMANAGER_BASIC_INFORMATION; + +typedef struct _TRANSACTIONMANAGER_LOG_INFORMATION { + GUID LogIdentity; +} TRANSACTIONMANAGER_LOG_INFORMATION, *PTRANSACTIONMANAGER_LOG_INFORMATION; + +typedef struct _TRANSACTIONMANAGER_LOGPATH_INFORMATION { + ULONG LogPathLength; + WCHAR LogPath[1]; +} TRANSACTIONMANAGER_LOGPATH_INFORMATION, *PTRANSACTIONMANAGER_LOGPATH_INFORMATION; + +typedef struct _TRANSACTIONMANAGER_RECOVERY_INFORMATION { + ULONGLONG LastRecoveredLsn; +} TRANSACTIONMANAGER_RECOVERY_INFORMATION, *PTRANSACTIONMANAGER_RECOVERY_INFORMATION; + +typedef struct _TRANSACTION_PROPERTIES_INFORMATION { + ULONG IsolationLevel; + ULONG IsolationFlags; + LARGE_INTEGER Timeout; + ULONG Outcome; + ULONG DescriptionLength; + WCHAR Description[1]; +} TRANSACTION_PROPERTIES_INFORMATION, *PTRANSACTION_PROPERTIES_INFORMATION; + +typedef struct _TRANSACTION_BIND_INFORMATION { + HANDLE TmHandle; +} TRANSACTION_BIND_INFORMATION, *PTRANSACTION_BIND_INFORMATION; + +typedef struct _TRANSACTION_ENLISTMENT_PAIR { + GUID EnlistmentId; + GUID ResourceManagerId; +} TRANSACTION_ENLISTMENT_PAIR, *PTRANSACTION_ENLISTMENT_PAIR; + +typedef struct _TRANSACTION_ENLISTMENTS_INFORMATION { + ULONG NumberOfEnlistments; + TRANSACTION_ENLISTMENT_PAIR EnlistmentPair[1]; +} TRANSACTION_ENLISTMENTS_INFORMATION, *PTRANSACTION_ENLISTMENTS_INFORMATION; + +typedef struct _TRANSACTION_SUPERIOR_ENLISTMENT_INFORMATION { + TRANSACTION_ENLISTMENT_PAIR SuperiorEnlistmentPair; +} TRANSACTION_SUPERIOR_ENLISTMENT_INFORMATION, *PTRANSACTION_SUPERIOR_ENLISTMENT_INFORMATION; + +typedef struct _RESOURCEMANAGER_BASIC_INFORMATION { + GUID ResourceManagerId; + ULONG DescriptionLength; + WCHAR Description[1]; +} RESOURCEMANAGER_BASIC_INFORMATION, *PRESOURCEMANAGER_BASIC_INFORMATION; + +typedef struct _RESOURCEMANAGER_COMPLETION_INFORMATION { + HANDLE IoCompletionPortHandle; + ULONG_PTR CompletionKey; +} RESOURCEMANAGER_COMPLETION_INFORMATION, *PRESOURCEMANAGER_COMPLETION_INFORMATION; + typedef enum _KTMOBJECT_TYPE { KTMOBJECT_TRANSACTION, KTMOBJECT_TRANSACTION_MANAGER, @@ -10998,66 +14900,480 @@ typedef enum _RESOURCEMANAGER_INFORMATION_CLASS { ResourceManagerCompletionInformation, } RESOURCEMANAGER_INFORMATION_CLASS; +typedef struct _ENLISTMENT_BASIC_INFORMATION { + GUID EnlistmentId; + GUID TransactionId; + GUID ResourceManagerId; +} ENLISTMENT_BASIC_INFORMATION, *PENLISTMENT_BASIC_INFORMATION; + +typedef struct _ENLISTMENT_CRM_INFORMATION { + GUID CrmTransactionManagerId; + GUID CrmResourceManagerId; + GUID CrmEnlistmentId; +} ENLISTMENT_CRM_INFORMATION, *PENLISTMENT_CRM_INFORMATION; + typedef enum _ENLISTMENT_INFORMATION_CLASS { EnlistmentBasicInformation, EnlistmentRecoveryInformation, EnlistmentCrmInformation } ENLISTMENT_INFORMATION_CLASS; +typedef struct _TRANSACTION_LIST_ENTRY { +#if defined(__cplusplus) + ::UOW UOW; +#else + UOW UOW; +#endif +} TRANSACTION_LIST_ENTRY, *PTRANSACTION_LIST_ENTRY; + +typedef struct _TRANSACTION_LIST_INFORMATION { + ULONG NumberOfTransactions; + TRANSACTION_LIST_ENTRY TransactionInformation[1]; +} TRANSACTION_LIST_INFORMATION, *PTRANSACTION_LIST_INFORMATION; + +typedef NTSTATUS +(NTAPI *PFN_NT_CREATE_TRANSACTION)( + OUT PHANDLE TransactionHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, + IN LPGUID Uow OPTIONAL, + IN HANDLE TmHandle OPTIONAL, + IN ULONG CreateOptions OPTIONAL, + IN ULONG IsolationLevel OPTIONAL, + IN ULONG IsolationFlags OPTIONAL, + IN PLARGE_INTEGER Timeout OPTIONAL, + IN PUNICODE_STRING Description OPTIONAL); + +typedef NTSTATUS +(NTAPI *PFN_NT_OPEN_TRANSACTION)( + OUT PHANDLE TransactionHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN LPGUID Uow OPTIONAL, + IN HANDLE TmHandle OPTIONAL); + +typedef NTSTATUS +(NTAPI *PFN_NT_QUERY_INFORMATION_TRANSACTION)( + IN HANDLE TransactionHandle, + IN TRANSACTION_INFORMATION_CLASS TransactionInformationClass, + OUT PVOID TransactionInformation, + IN ULONG TransactionInformationLength, + OUT PULONG ReturnLength OPTIONAL); + +typedef NTSTATUS +(NTAPI *PFN_NT_SET_INFORMATION_TRANSACTION)( + IN HANDLE TransactionHandle, + IN TRANSACTION_INFORMATION_CLASS TransactionInformationClass, + IN PVOID TransactionInformation, + IN ULONG TransactionInformationLength); + +typedef NTSTATUS +(NTAPI *PFN_NT_COMMIT_TRANSACTION)( + IN HANDLE TransactionHandle, + IN BOOLEAN Wait); + +typedef NTSTATUS +(NTAPI *PFN_NT_ROLLBACK_TRANSACTION)( + IN HANDLE TransactionHandle, + IN BOOLEAN Wait); + +#if (NTDDI_VERSION >= NTDDI_VISTA) + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtCreateTransactionManager( + OUT PHANDLE TmHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, + IN PUNICODE_STRING LogFileName OPTIONAL, + IN ULONG CreateOptions OPTIONAL, + IN ULONG CommitStrength OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtOpenTransactionManager( + OUT PHANDLE TmHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, + IN PUNICODE_STRING LogFileName OPTIONAL, + IN LPGUID TmIdentity OPTIONAL, + IN ULONG OpenOptions OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtRenameTransactionManager( + IN PUNICODE_STRING LogFileName, + IN LPGUID ExistingTransactionManagerGuid); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtRollforwardTransactionManager( + IN HANDLE TransactionManagerHandle, + IN PLARGE_INTEGER TmVirtualClock OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtRecoverTransactionManager( + IN HANDLE TransactionManagerHandle); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtQueryInformationTransactionManager( + IN HANDLE TransactionManagerHandle, + IN TRANSACTIONMANAGER_INFORMATION_CLASS TransactionManagerInformationClass, + OUT PVOID TransactionManagerInformation, + IN ULONG TransactionManagerInformationLength, + OUT PULONG ReturnLength); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtSetInformationTransactionManager( + IN HANDLE TmHandle OPTIONAL, + IN TRANSACTIONMANAGER_INFORMATION_CLASS TransactionManagerInformationClass, + IN PVOID TransactionManagerInformation, + IN ULONG TransactionManagerInformationLength); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtEnumerateTransactionObject( + IN HANDLE RootObjectHandle OPTIONAL, + IN KTMOBJECT_TYPE QueryType, + IN OUT PKTMOBJECT_CURSOR ObjectCursor, + IN ULONG ObjectCursorLength, + OUT PULONG ReturnLength); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtCreateTransaction( + OUT PHANDLE TransactionHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, + IN LPGUID Uow OPTIONAL, + IN HANDLE TmHandle OPTIONAL, + IN ULONG CreateOptions OPTIONAL, + IN ULONG IsolationLevel OPTIONAL, + IN ULONG IsolationFlags OPTIONAL, + IN PLARGE_INTEGER Timeout OPTIONAL, + IN PUNICODE_STRING Description OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtOpenTransaction( + OUT PHANDLE TransactionHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN LPGUID Uow, + IN HANDLE TmHandle OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtQueryInformationTransaction( + IN HANDLE TransactionHandle, + IN TRANSACTION_INFORMATION_CLASS TransactionInformationClass, + OUT PVOID TransactionInformation, + IN ULONG TransactionInformationLength, + OUT PULONG ReturnLength OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtSetInformationTransaction( + IN HANDLE TransactionHandle, + IN TRANSACTION_INFORMATION_CLASS TransactionInformationClass, + IN PVOID TransactionInformation, + IN ULONG TransactionInformationLength); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtCommitTransaction( + IN HANDLE TransactionHandle, + IN BOOLEAN Wait); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtRollbackTransaction( + IN HANDLE TransactionHandle, + IN BOOLEAN Wait); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtCreateEnlistment( + OUT PHANDLE EnlistmentHandle, + IN ACCESS_MASK DesiredAccess, + IN HANDLE ResourceManagerHandle, + IN HANDLE TransactionHandle, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, + IN ULONG CreateOptions OPTIONAL, + IN NOTIFICATION_MASK NotificationMask, + IN PVOID EnlistmentKey OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtOpenEnlistment( + OUT PHANDLE EnlistmentHandle, + IN ACCESS_MASK DesiredAccess, + IN HANDLE ResourceManagerHandle, + IN LPGUID EnlistmentGuid, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtQueryInformationEnlistment( + IN HANDLE EnlistmentHandle, + IN ENLISTMENT_INFORMATION_CLASS EnlistmentInformationClass, + OUT PVOID EnlistmentInformation, + IN ULONG EnlistmentInformationLength, + OUT PULONG ReturnLength); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtSetInformationEnlistment( + IN HANDLE EnlistmentHandle OPTIONAL, + IN ENLISTMENT_INFORMATION_CLASS EnlistmentInformationClass, + IN PVOID EnlistmentInformation, + IN ULONG EnlistmentInformationLength); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtRecoverEnlistment( + IN HANDLE EnlistmentHandle, + IN PVOID EnlistmentKey OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtPrePrepareEnlistment( + IN HANDLE EnlistmentHandle, + IN PLARGE_INTEGER TmVirtualClock OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtPrepareEnlistment( + IN HANDLE EnlistmentHandle, + IN PLARGE_INTEGER TmVirtualClock OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtCommitEnlistment( + IN HANDLE EnlistmentHandle, + IN PLARGE_INTEGER TmVirtualClock OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtRollbackEnlistment( + IN HANDLE EnlistmentHandle, + IN PLARGE_INTEGER TmVirtualClock OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtPrePrepareComplete( + IN HANDLE EnlistmentHandle, + IN PLARGE_INTEGER TmVirtualClock OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtPrepareComplete( + IN HANDLE EnlistmentHandle, + IN PLARGE_INTEGER TmVirtualClock OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtCommitComplete( + IN HANDLE EnlistmentHandle, + IN PLARGE_INTEGER TmVirtualClock OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtReadOnlyEnlistment( + IN HANDLE EnlistmentHandle, + IN PLARGE_INTEGER TmVirtualClock OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtRollbackComplete( + IN HANDLE EnlistmentHandle, + IN PLARGE_INTEGER TmVirtualClock OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtSinglePhaseReject( + IN HANDLE EnlistmentHandle, + IN PLARGE_INTEGER TmVirtualClock OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtCreateResourceManager( + OUT PHANDLE ResourceManagerHandle, + IN ACCESS_MASK DesiredAccess, + IN HANDLE TmHandle, + IN LPGUID RmGuid, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, + IN ULONG CreateOptions OPTIONAL, + IN PUNICODE_STRING Description OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtOpenResourceManager( + OUT PHANDLE ResourceManagerHandle, + IN ACCESS_MASK DesiredAccess, + IN HANDLE TmHandle, + IN LPGUID ResourceManagerGuid OPTIONAL, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtRecoverResourceManager( + IN HANDLE ResourceManagerHandle); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtGetNotificationResourceManager( + IN HANDLE ResourceManagerHandle, + OUT PTRANSACTION_NOTIFICATION TransactionNotification, + IN ULONG NotificationLength, + IN PLARGE_INTEGER Timeout OPTIONAL, + OUT PULONG ReturnLength OPTIONAL, + IN ULONG Asynchronous, + IN ULONG_PTR AsynchronousContext OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtQueryInformationResourceManager( + IN HANDLE ResourceManagerHandle, + IN RESOURCEMANAGER_INFORMATION_CLASS ResourceManagerInformationClass, + OUT PVOID ResourceManagerInformation, + IN ULONG ResourceManagerInformationLength, + OUT PULONG ReturnLength OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtSetInformationResourceManager( + IN HANDLE ResourceManagerHandle, + IN RESOURCEMANAGER_INFORMATION_CLASS ResourceManagerInformationClass, + IN PVOID ResourceManagerInformation, + IN ULONG ResourceManagerInformationLength); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtRegisterProtocolAddressInformation( + IN HANDLE ResourceManager, + IN PCRM_PROTOCOL_ID ProtocolId, + IN ULONG ProtocolInformationSize, + IN PVOID ProtocolInformation, + IN ULONG CreateOptions OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtPropagationComplete( + IN HANDLE ResourceManagerHandle, + IN ULONG RequestCookie, + IN ULONG BufferLength, + IN PVOID Buffer); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtPropagationFailed( + IN HANDLE ResourceManagerHandle, + IN ULONG RequestCookie, + IN NTSTATUS PropStatus); + +#endif /* NTDDI_VERSION >= NTDDI_VISTA */ + #endif /* !_NTTMAPI_ */ /****************************************************************************** * ZwXxx Functions * ******************************************************************************/ + /* Constants */ #define NtCurrentProcess() ( (HANDLE)(LONG_PTR) -1 ) #define ZwCurrentProcess() NtCurrentProcess() #define NtCurrentThread() ( (HANDLE)(LONG_PTR) -2 ) #define ZwCurrentThread() NtCurrentThread() + + #if (NTDDI_VERSION >= NTDDI_WIN2K) + + NTSYSAPI NTSTATUS NTAPI ZwClose( - IN HANDLE Handle); + IN HANDLE Handle); NTSYSAPI NTSTATUS NTAPI ZwCreateDirectoryObject( - OUT PHANDLE DirectoryHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes); + OUT PHANDLE DirectoryHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes); NTSYSAPI NTSTATUS NTAPI ZwCreateFile( - OUT PHANDLE FileHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes, - OUT PIO_STATUS_BLOCK IoStatusBlock, - IN PLARGE_INTEGER AllocationSize OPTIONAL, - IN ULONG FileAttributes, - IN ULONG ShareAccess, - IN ULONG CreateDisposition, - IN ULONG CreateOptions, - IN PVOID EaBuffer OPTIONAL, - IN ULONG EaLength); + OUT PHANDLE FileHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN PLARGE_INTEGER AllocationSize OPTIONAL, + IN ULONG FileAttributes, + IN ULONG ShareAccess, + IN ULONG CreateDisposition, + IN ULONG CreateOptions, + IN PVOID EaBuffer OPTIONAL, + IN ULONG EaLength); NTSYSAPI NTSTATUS NTAPI ZwCreateKey( - OUT PHANDLE KeyHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes, - IN ULONG TitleIndex, - IN PUNICODE_STRING Class OPTIONAL, - IN ULONG CreateOptions, - OUT PULONG Disposition OPTIONAL); + OUT PHANDLE KeyHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN ULONG TitleIndex, + IN PUNICODE_STRING Class OPTIONAL, + IN ULONG CreateOptions, + OUT PULONG Disposition OPTIONAL); NTSYSAPI NTSTATUS @@ -11081,7 +15397,7 @@ NTSYSAPI NTSTATUS NTAPI ZwDeleteValueKey( - IN HANDLE KeyHandle, + IN HANDLE KeyHandle, IN PUNICODE_STRING ValueName); NTSYSAPI @@ -11110,7 +15426,7 @@ NTSYSAPI NTSTATUS NTAPI ZwFlushKey( - IN HANDLE KeyHandle); + IN HANDLE KeyHandle); NTSYSAPI NTSTATUS @@ -11122,22 +15438,22 @@ NTSYSAPI NTSTATUS NTAPI ZwMakeTemporaryObject( - IN HANDLE Handle); + IN HANDLE Handle); NTSYSAPI NTSTATUS NTAPI ZwMapViewOfSection( - IN HANDLE SectionHandle, - IN HANDLE ProcessHandle, - IN OUT PVOID *BaseAddress, - IN ULONG_PTR ZeroBits, - IN SIZE_T CommitSize, - IN OUT PLARGE_INTEGER SectionOffset OPTIONAL, - IN OUT PSIZE_T ViewSize, - IN SECTION_INHERIT InheritDisposition, - IN ULONG AllocationType, - IN ULONG Protect); + IN HANDLE SectionHandle, + IN HANDLE ProcessHandle, + IN OUT PVOID *BaseAddress, + IN ULONG_PTR ZeroBits, + IN SIZE_T CommitSize, + IN OUT PLARGE_INTEGER SectionOffset OPTIONAL, + IN OUT PSIZE_T ViewSize, + IN SECTION_INHERIT InheritDisposition, + IN ULONG AllocationType, + IN ULONG Protect); NTSYSAPI NTSTATUS @@ -11154,35 +15470,35 @@ NTSYSAPI NTSTATUS NTAPI ZwOpenKey( - OUT PHANDLE KeyHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes); + OUT PHANDLE KeyHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes); NTSYSAPI NTSTATUS NTAPI ZwOpenSection( - OUT PHANDLE SectionHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes); + OUT PHANDLE SectionHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes); NTSYSAPI NTSTATUS NTAPI ZwOpenSymbolicLinkObject( - OUT PHANDLE LinkHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes); + OUT PHANDLE LinkHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes); NTSYSAPI NTSTATUS NTAPI ZwQueryInformationFile( - IN HANDLE FileHandle, - OUT PIO_STATUS_BLOCK IoStatusBlock, - OUT PVOID FileInformation, - IN ULONG Length, - IN FILE_INFORMATION_CLASS FileInformationClass); + IN HANDLE FileHandle, + OUT PIO_STATUS_BLOCK IoStatusBlock, + OUT PVOID FileInformation, + IN ULONG Length, + IN FILE_INFORMATION_CLASS FileInformationClass); NTSYSAPI NTSTATUS @@ -11198,9 +15514,9 @@ NTSYSAPI NTSTATUS NTAPI ZwQuerySymbolicLinkObject( - IN HANDLE LinkHandle, - IN OUT PUNICODE_STRING LinkTarget, - OUT PULONG ReturnedLength OPTIONAL); + IN HANDLE LinkHandle, + IN OUT PUNICODE_STRING LinkTarget, + OUT PULONG ReturnedLength OPTIONAL); NTSYSAPI NTSTATUS @@ -11217,36 +15533,36 @@ NTSYSAPI NTSTATUS NTAPI ZwReadFile( - IN HANDLE FileHandle, - IN HANDLE Event OPTIONAL, - IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, - IN PVOID ApcContext OPTIONAL, - OUT PIO_STATUS_BLOCK IoStatusBlock, - OUT PVOID Buffer, - IN ULONG Length, - IN PLARGE_INTEGER ByteOffset OPTIONAL, - IN PULONG Key OPTIONAL); + IN HANDLE FileHandle, + IN HANDLE Event OPTIONAL, + IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, + IN PVOID ApcContext OPTIONAL, + OUT PIO_STATUS_BLOCK IoStatusBlock, + OUT PVOID Buffer, + IN ULONG Length, + IN PLARGE_INTEGER ByteOffset OPTIONAL, + IN PULONG Key OPTIONAL); NTSYSAPI NTSTATUS NTAPI ZwSetInformationFile( - IN HANDLE FileHandle, - OUT PIO_STATUS_BLOCK IoStatusBlock, - IN PVOID FileInformation, - IN ULONG Length, - IN FILE_INFORMATION_CLASS FileInformationClass); + IN HANDLE FileHandle, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN PVOID FileInformation, + IN ULONG Length, + IN FILE_INFORMATION_CLASS FileInformationClass); NTSYSAPI NTSTATUS NTAPI ZwSetValueKey( - IN HANDLE KeyHandle, - IN PUNICODE_STRING ValueName, - IN ULONG TitleIndex OPTIONAL, - IN ULONG Type, - IN PVOID Data OPTIONAL, - IN ULONG DataSize); + IN HANDLE KeyHandle, + IN PUNICODE_STRING ValueName, + IN ULONG TitleIndex OPTIONAL, + IN ULONG Type, + IN PVOID Data OPTIONAL, + IN ULONG DataSize); NTSYSAPI NTSTATUS @@ -11258,22 +15574,22 @@ NTSYSAPI NTSTATUS NTAPI ZwUnmapViewOfSection( - IN HANDLE ProcessHandle, - IN PVOID BaseAddress OPTIONAL); + IN HANDLE ProcessHandle, + IN PVOID BaseAddress OPTIONAL); NTSYSAPI NTSTATUS NTAPI ZwWriteFile( - IN HANDLE FileHandle, - IN HANDLE Event OPTIONAL, - IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, - IN PVOID ApcContext OPTIONAL, - OUT PIO_STATUS_BLOCK IoStatusBlock, - IN PVOID Buffer, - IN ULONG Length, - IN PLARGE_INTEGER ByteOffset OPTIONAL, - IN PULONG Key OPTIONAL); + IN HANDLE FileHandle, + IN HANDLE Event OPTIONAL, + IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, + IN PVOID ApcContext OPTIONAL, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN PVOID Buffer, + IN ULONG Length, + IN PLARGE_INTEGER ByteOffset OPTIONAL, + IN PULONG Key OPTIONAL); NTSYSAPI NTSTATUS @@ -11282,10 +15598,11 @@ ZwQueryFullAttributesFile( IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PFILE_NETWORK_OPEN_INFORMATION FileInformation); -#endif -#if (NTDDI_VERSION >= NTDDI_WIN2003) +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ + +#if (NTDDI_VERSION >= NTDDI_WS03) NTSYSCALLAPI NTSTATUS NTAPI @@ -11293,7 +15610,6 @@ ZwOpenEvent( OUT PHANDLE EventHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes); - #endif #if (NTDDI_VERSION >= NTDDI_VISTA) @@ -11620,10 +15936,13 @@ ZwSinglePhaseReject( IN PLARGE_INTEGER TmVirtualClock OPTIONAL); -#endif +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + #if (NTDDI_VERSION >= NTDDI_WIN7) + + NTSYSAPI NTSTATUS NTAPI @@ -11687,78 +16006,8 @@ ZwSetInformationKey( IN PVOID KeySetInformation, IN ULONG KeySetInformationLength); -#endif - -/****************************************************************************** - * Unsorted * - ******************************************************************************/ - -/* GUID Comparison */ -#ifndef __IID_ALIGNED__ -#define __IID_ALIGNED__ -#ifdef __cplusplus -inline int IsEqualGUIDAligned(REFGUID guid1, REFGUID guid2) -{ - return ( (*(PLONGLONG)(&guid1) == *(PLONGLONG)(&guid2)) && - (*((PLONGLONG)(&guid1) + 1) == *((PLONGLONG)(&guid2) + 1)) ); -} -#else -#define IsEqualGUIDAligned(guid1, guid2) \ - ( (*(PLONGLONG)(guid1) == *(PLONGLONG)(guid2)) && \ - (*((PLONGLONG)(guid1) + 1) == *((PLONGLONG)(guid2) + 1)) ) -#endif /* __cplusplus */ -#endif /* !__IID_ALIGNED__ */ - -typedef enum { - LT_DONT_CARE, - LT_LOWEST_LATENCY -} LATENCY_TIME; - -#define MAXIMUM_SUSPEND_COUNT MAXCHAR - -#define MAXIMUM_FILENAME_LENGTH 256 - -#define OBJ_NAME_PATH_SEPARATOR ((WCHAR)L'\\') - -#define OBJECT_TYPE_CREATE (0x0001) -#define OBJECT_TYPE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0x1) - -#define DIRECTORY_QUERY (0x0001) -#define DIRECTORY_TRAVERSE (0x0002) -#define DIRECTORY_CREATE_OBJECT (0x0004) -#define DIRECTORY_CREATE_SUBDIRECTORY (0x0008) -#define DIRECTORY_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0xF) - -#define EVENT_QUERY_STATE (0x0001) -#define EVENT_MODIFY_STATE (0x0002) -#define EVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3) - -#define SEMAPHORE_QUERY_STATE (0x0001) -#define SEMAPHORE_MODIFY_STATE (0x0002) -#define SEMAPHORE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3) - -#define SYMBOLIC_LINK_QUERY 0x0001 -#define SYMBOLIC_LINK_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0x1) - -#define DUPLICATE_CLOSE_SOURCE 0x00000001 -#define DUPLICATE_SAME_ACCESS 0x00000002 -#define DUPLICATE_SAME_ATTRIBUTES 0x00000004 - -/* Global debug flag */ -extern ULONG NtGlobalFlag; - -/* Service Start Types */ -#define SERVICE_BOOT_START 0x00000000 -#define SERVICE_SYSTEM_START 0x00000001 -#define SERVICE_AUTO_START 0x00000002 -#define SERVICE_DEMAND_START 0x00000003 -#define SERVICE_DISABLED 0x00000004 - -#ifndef _TRACEHANDLE_DEFINED -#define _TRACEHANDLE_DEFINED -typedef ULONG64 TRACEHANDLE, *PTRACEHANDLE; -#endif +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ #ifdef __cplusplus diff --git a/reactos/include/ndk/ketypes.h b/reactos/include/ndk/ketypes.h index d4ae1c545f0..67985379372 100644 --- a/reactos/include/ndk/ketypes.h +++ b/reactos/include/ndk/ketypes.h @@ -546,17 +546,6 @@ typedef enum _KAPC_ENVIRONMENT InsertApcEnvironment } KAPC_ENVIRONMENT; -// -// CPU Cache Types -// -typedef enum _PROCESSOR_CACHE_TYPE -{ - CacheUnified, - CacheInstruction, - CacheData, - CacheTrace, -} PROCESSOR_CACHE_TYPE; - // // PRCB DPC Data // @@ -577,18 +566,6 @@ typedef struct _PP_LOOKASIDE_LIST struct _GENERAL_LOOKASIDE *L; } PP_LOOKASIDE_LIST, *PPP_LOOKASIDE_LIST; -// -// CPU Cache Descriptor -// -typedef struct _CACHE_DESCRIPTOR -{ - UCHAR Level; - UCHAR Associativity; - USHORT LineSize; - ULONG Size; - PROCESSOR_CACHE_TYPE Type; -} CACHE_DESCRIPTOR, *PCACHE_DESCRIPTOR; - // // Architectural Types // diff --git a/reactos/include/ndk/peb_teb.h b/reactos/include/ndk/peb_teb.h index 38791b31a21..ec4b2d33617 100644 --- a/reactos/include/ndk/peb_teb.h +++ b/reactos/include/ndk/peb_teb.h @@ -1,4 +1,3 @@ - #define PASTE2(x,y) x##y #define PASTE(x,y) PASTE2(x,y) @@ -19,6 +18,10 @@ #define GDI_HANDLE_BUFFER_SIZE 34 #endif +#if defined(_NTDDK_INCLUDED_) || defined(_NTIFS_) +#define PPEB PPEB_RENAMED +#endif + typedef struct STRUCT(_PEB) { BOOLEAN InheritedAddressSpace; @@ -152,6 +155,7 @@ typedef struct STRUCT(_PEB) #endif } STRUCT(PEB), *STRUCT(PPEB); +#undef PPEB #if defined(_WIN64) && !defined(EXPLICIT_32BIT) C_ASSERT(FIELD_OFFSET(STRUCT(PEB), Mutant) == 0x08); diff --git a/reactos/include/psdk/ktmtypes.h b/reactos/include/psdk/ktmtypes.h index 77cf5782858..90b042f3f0b 100644 --- a/reactos/include/psdk/ktmtypes.h +++ b/reactos/include/psdk/ktmtypes.h @@ -72,7 +72,10 @@ #define MAX_TRANSACTION_DESCRIPTION_LENGTH 64 #define MAX_RESOURCEMANAGER_DESCRIPTION_LENGTH 64 +#ifndef _WDMDDK_ typedef GUID UOW, *PUOW; +#endif + typedef GUID CRM_PROTOCOL_ID, *PCRM_PROTOCOL_ID; typedef ULONG NOTIFICATION_MASK; typedef ULONG SAVEPOINT_ID, *PSAVEPOINT_ID; diff --git a/reactos/ntoskrnl/include/ntoskrnl.h b/reactos/ntoskrnl/include/ntoskrnl.h index f1052ed38df..3b56d34afac 100644 --- a/reactos/ntoskrnl/include/ntoskrnl.h +++ b/reactos/ntoskrnl/include/ntoskrnl.h @@ -19,7 +19,6 @@ /* DDK/IFS/NDK Headers */ #define _REALLY_GET_CALLERS_CALLER -#define SINGLE_GROUP_LEGACY_API #include #include #include diff --git a/reactos/ntoskrnl/mm/mminit.c b/reactos/ntoskrnl/mm/mminit.c index 6a3492415c0..8a9fd4297c3 100644 --- a/reactos/ntoskrnl/mm/mminit.c +++ b/reactos/ntoskrnl/mm/mminit.c @@ -48,7 +48,7 @@ MemType[] = "LoaderXIPRom " }; -PBOOLEAN Mm64BitPhysicalAddress = FALSE; +BOOLEAN Mm64BitPhysicalAddress = FALSE; ULONG MmReadClusterSize; // // 0 | 1 is on/off paging, 2 is undocumented From 59f2edfce78245e51111bb61fd708cff81d2cc77 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 29 Mar 2010 04:14:34 +0000 Subject: [PATCH 076/134] revert r46552 and r46553 svn path=/trunk/; revision=46554 --- .../drivers/filesystems/ext2/inc/ext2fsd.h | 3 - reactos/drivers/serial/serial/serial.h | 9 + reactos/include/ddk/bdasup.h | 262 +- reactos/include/ddk/csq.h | 2 - reactos/include/ddk/ntddk.h | 5611 ++----- reactos/include/ddk/ntifs.h | 4756 +++--- reactos/include/ddk/ntimage.h | 17 +- reactos/include/ddk/wdm.h | 12085 +++++----------- reactos/include/ndk/ketypes.h | 23 + reactos/include/ndk/peb_teb.h | 6 +- reactos/include/psdk/ktmtypes.h | 3 - reactos/include/psdk/ntdef.h | 296 +- reactos/include/psdk/winnt.h | 6 - reactos/ntoskrnl/include/ntoskrnl.h | 1 + reactos/ntoskrnl/mm/mminit.c | 2 +- 15 files changed, 8066 insertions(+), 15016 deletions(-) diff --git a/reactos/drivers/filesystems/ext2/inc/ext2fsd.h b/reactos/drivers/filesystems/ext2/inc/ext2fsd.h index dcf35d996ef..bf2b784fb86 100644 --- a/reactos/drivers/filesystems/ext2/inc/ext2fsd.h +++ b/reactos/drivers/filesystems/ext2/inc/ext2fsd.h @@ -42,11 +42,8 @@ typedef unsigned char BYTE; /* REACTOS FIXME */ #undef DeleteFile /* This is deprecated and should be changed in the EXT2FS driver. */ - -/* FIXME : Those two definitions already exist in wdm.h #define RtlLargeIntegerLessThan(a, b) (a).QuadPart < (b).QuadPart #define RtlLargeIntegerGreaterThan(a, b) (a).QuadPart > (b).QuadPart -*/ // the following include files should be in the inc sub-dir associated with this driver diff --git a/reactos/drivers/serial/serial/serial.h b/reactos/drivers/serial/serial/serial.h index b6ed661226c..de94b291138 100644 --- a/reactos/drivers/serial/serial/serial.h +++ b/reactos/drivers/serial/serial/serial.h @@ -17,6 +17,15 @@ #define PST_RS232 1 #define COMMPROP_INITIALIZED 0xE73CF52E +#ifndef _NTIFS_ +/* Why is it only defined in ntifs.h file? */ +NTSTATUS NTAPI +IoAttachDeviceToDeviceStackSafe( + IN PDEVICE_OBJECT SourceDevice, + IN PDEVICE_OBJECT TargetDevice, + OUT PDEVICE_OBJECT *AttachedToDeviceObject); +#endif + typedef enum { dsStopped, diff --git a/reactos/include/ddk/bdasup.h b/reactos/include/ddk/bdasup.h index 373ccdbdcbf..0bdd590d337 100644 --- a/reactos/include/ddk/bdasup.h +++ b/reactos/include/ddk/bdasup.h @@ -1,12 +1,8 @@ -#pragma once - -#if (NTDDI_VERSION >= NTDDI_WINXP) - #if defined(__cplusplus) extern "C" { #endif -/* Helper macro to enable gcc's extension. */ +/* Helper macro to enable gcc's extension. */ #ifndef __GNU_EXTENSION #ifdef __GNUC__ #define __GNU_EXTENSION __extension__ @@ -16,190 +12,150 @@ extern "C" { #endif #define STDMETHODCALLTYPE __stdcall - -#ifndef _WDMDDK_ typedef GUID *PGUID; -#endif /* Types */ -typedef ULONG BDA_TOPOLOGY_JOINT, *PBDA_TOPOLOGY_JOINT; - -typedef struct _BDA_PIN_PAIRING { - ULONG ulInputPin; - ULONG ulOutputPin; - ULONG ulcMaxInputsPerOutput; - ULONG ulcMinInputsPerOutput; - ULONG ulcMaxOutputsPerInput; - ULONG ulcMinOutputsPerInput; - ULONG ulcTopologyJoints; - const ULONG *pTopologyJoints; +typedef struct _BDA_PIN_PAIRING +{ + ULONG ulInputPin; + ULONG ulOutputPin; + ULONG ulcMaxInputsPerOutput; + ULONG ulcMinInputsPerOutput; + ULONG ulcMaxOutputsPerInput; + ULONG ulcMinOutputsPerInput; + ULONG ulcTopologyJoints; + const ULONG *pTopologyJoints; } BDA_PIN_PAIRING, *PBDA_PIN_PAIRING; -typedef struct _BDA_FILTER_TEMPLATE { - const KSFILTER_DESCRIPTOR *pFilterDescriptor; - ULONG ulcPinPairs; - const BDA_PIN_PAIRING *pPinPairs; +typedef struct _BDA_FILTER_TEMPLATE +{ + const KSFILTER_DESCRIPTOR *pFilterDescriptor; + ULONG ulcPinPairs; + const BDA_PIN_PAIRING *pPinPairs; } BDA_FILTER_TEMPLATE, *PBDA_FILTER_TEMPLATE; -typedef struct _KSM_PIN_PAIR { - KSMETHOD Method; - ULONG InputPinId; - ULONG OutputPinId; - ULONG Reserved; -} KSM_PIN_PAIR, * PKSM_PIN_PAIR; -typedef struct _KSM_PIN { - KSMETHOD Method; - __GNU_EXTENSION union { - ULONG PinId; - ULONG PinType; - }; - ULONG Reserved; +typedef struct _KSM_PIN +{ + KSMETHOD Method; + __GNU_EXTENSION union + { + ULONG PinId; + ULONG PinType; + }; + ULONG Reserved; } KSM_PIN, * PKSM_PIN; /* Functions */ -STDMETHODIMP_(NTSTATUS) -BdaCheckChanges( - IN PIRP Irp); +STDMETHODIMP_(NTSTATUS) BdaCheckChanges(IN PIRP Irp); +STDMETHODIMP_(NTSTATUS) BdaCommitChanges(IN PIRP Irp); -STDMETHODIMP_(NTSTATUS) -BdaCommitChanges( - IN PIRP Irp); +STDMETHODIMP_(NTSTATUS) BdaCreateFilterFactory( + IN PKSDEVICE pKSDevice, + IN const KSFILTER_DESCRIPTOR *pFilterDescriptor, + IN const BDA_FILTER_TEMPLATE *pBdaFilterTemplate); -STDMETHODIMP_(NTSTATUS) -BdaCreateFilterFactory( - IN PKSDEVICE pKSDevice, - IN const KSFILTER_DESCRIPTOR *pFilterDescriptor, - IN const BDA_FILTER_TEMPLATE *pBdaFilterTemplate); +STDMETHODIMP_(NTSTATUS) BdaCreateFilterFactoryEx( + IN PKSDEVICE pKSDevice, + IN const KSFILTER_DESCRIPTOR *pFilterDescriptor, + IN const BDA_FILTER_TEMPLATE *pBdaFilterTemplate, + OUT PKSFILTERFACTORY *ppKSFilterFactory); -STDMETHODIMP_(NTSTATUS) -BdaCreateFilterFactoryEx( - IN PKSDEVICE pKSDevice, - IN const KSFILTER_DESCRIPTOR *pFilterDescriptor, - IN const BDA_FILTER_TEMPLATE *pBdaFilterTemplate, - OUT PKSFILTERFACTORY *ppKSFilterFactory); +STDMETHODIMP_(NTSTATUS) BdaCreatePin( + IN PKSFILTER pKSFilter, + IN ULONG ulPinType, + OUT ULONG *pulPinId); -STDMETHODIMP_(NTSTATUS) -BdaCreatePin( - IN PKSFILTER pKSFilter, - IN ULONG ulPinType, - OUT ULONG *pulPinId); +STDMETHODIMP_(NTSTATUS) BdaCreateTopology( + IN PKSFILTER pKSFilter, + IN ULONG InputPinId, + IN ULONG OutputPinId); -STDMETHODIMP_(NTSTATUS) -BdaCreateTopology( - IN PKSFILTER pKSFilter, - IN ULONG InputPinId, - IN ULONG OutputPinId); +STDMETHODIMP_(NTSTATUS) BdaDeletePin( + IN PKSFILTER pKSFilter, + IN ULONG *pulPinId); -STDMETHODIMP_(NTSTATUS) -BdaDeletePin( - IN PKSFILTER pKSFilter, - IN ULONG *pulPinId); +STDMETHODIMP_(NTSTATUS) BdaFilterFactoryUpdateCacheData( + IN PKSFILTERFACTORY pFilterFactory, + IN const KSFILTER_DESCRIPTOR *pFilterDescriptor OPTIONAL); -STDMETHODIMP_(NTSTATUS) -BdaFilterFactoryUpdateCacheData( - IN PKSFILTERFACTORY pFilterFactory, - IN const KSFILTER_DESCRIPTOR *pFilterDescriptor OPTIONAL); +STDMETHODIMP_(NTSTATUS) BdaGetChangeState( + IN PIRP Irp, + OUT BDA_CHANGE_STATE *pChangeState); -STDMETHODIMP_(NTSTATUS) -BdaGetChangeState( - IN PIRP Irp, - OUT BDA_CHANGE_STATE *pChangeState); +STDMETHODIMP_(NTSTATUS) BdaInitFilter( + IN PKSFILTER pKSFilter, + IN const BDA_FILTER_TEMPLATE *pBdaFilterTemplate); -STDMETHODIMP_(NTSTATUS) -BdaInitFilter( - IN PKSFILTER pKSFilter, - IN const BDA_FILTER_TEMPLATE *pBdaFilterTemplate); +STDMETHODIMP_(NTSTATUS) BdaMethodCreatePin( + IN PIRP Irp, + IN KSMETHOD *pKSMethod, + OUT ULONG *pulPinFactoryID); -STDMETHODIMP_(NTSTATUS) -BdaMethodCreatePin( - IN PIRP Irp, - IN KSMETHOD *pKSMethod, - OUT ULONG *pulPinFactoryID); +STDMETHODIMP_(NTSTATUS) BdaMethodCreateTopology( + IN PIRP Irp, + IN KSMETHOD *pKSMethod, + OPTIONAL PVOID pvIgnored); -STDMETHODIMP_(NTSTATUS) -BdaMethodCreateTopology( - IN PIRP Irp, - IN KSMETHOD *pKSMethod, - OPTIONAL PVOID pvIgnored); +STDMETHODIMP_(NTSTATUS) BdaMethodDeletePin( + IN PIRP Irp, + IN KSMETHOD *pKSMethod, + OPTIONAL PVOID pvIgnored); -STDMETHODIMP_(NTSTATUS) -BdaMethodDeletePin( - IN PIRP Irp, - IN KSMETHOD *pKSMethod, - OPTIONAL PVOID pvIgnored); +STDMETHODIMP_(NTSTATUS) BdaPropertyGetControllingPinId( + IN PIRP Irp, + IN KSP_BDA_NODE_PIN *pProperty, + OUT ULONG *pulControllingPinId); -STDMETHODIMP_(NTSTATUS) -BdaPropertyGetControllingPinId( - IN PIRP Irp, - IN KSP_BDA_NODE_PIN *pProperty, - OUT ULONG *pulControllingPinId); +STDMETHODIMP_(NTSTATUS) BdaPropertyGetPinControl( + IN PIRP Irp, + IN KSPROPERTY *pKSProperty, + OUT ULONG *pulProperty); -STDMETHODIMP_(NTSTATUS) -BdaPropertyGetPinControl( - IN PIRP Irp, - IN KSPROPERTY *pKSProperty, - OUT ULONG *pulProperty); +STDMETHODIMP_(NTSTATUS) BdaPropertyNodeDescriptors( + IN PIRP Irp, + IN KSPROPERTY *pKSProperty, + OUT BDANODE_DESCRIPTOR *pNodeDescriptorProperty); -STDMETHODIMP_(NTSTATUS) -BdaPropertyNodeDescriptors( - IN PIRP Irp, - IN KSPROPERTY *pKSProperty, - OUT BDANODE_DESCRIPTOR *pNodeDescriptorProperty); +STDMETHODIMP_(NTSTATUS) BdaPropertyNodeEvents( + IN PIRP Irp, + IN KSP_NODE *pKSProperty, + OUT GUID *pguidProperty); -STDMETHODIMP_(NTSTATUS) -BdaPropertyNodeEvents( - IN PIRP Irp, - IN KSP_NODE *pKSProperty, - OUT GUID *pguidProperty); +STDMETHODIMP_(NTSTATUS) BdaPropertyNodeMethods( + IN PIRP Irp, + IN KSP_NODE *pKSProperty, + OUT GUID *pguidProperty); -STDMETHODIMP_(NTSTATUS) -BdaPropertyNodeMethods( - IN PIRP Irp, - IN KSP_NODE *pKSProperty, - OUT GUID *pguidProperty); +STDMETHODIMP_(NTSTATUS) BdaPropertyNodeProperties( + IN PIRP Irp, + IN KSP_NODE *pKSProperty, + OUT GUID *pguidProperty); -STDMETHODIMP_(NTSTATUS) -BdaPropertyNodeProperties( - IN PIRP Irp, - IN KSP_NODE *pKSProperty, - OUT GUID *pguidProperty); +STDMETHODIMP_(NTSTATUS) BdaPropertyNodeTypes( + IN PIRP Irp, + IN KSPROPERTY *pKSProperty, + OUT ULONG *pulProperty); -STDMETHODIMP_(NTSTATUS) -BdaPropertyNodeTypes( - IN PIRP Irp, - IN KSPROPERTY *pKSProperty, - OUT ULONG *pulProperty); +STDMETHODIMP_(NTSTATUS) BdaPropertyPinTypes( + IN PIRP Irp, + IN KSPROPERTY *pKSProperty, + OUT ULONG *pulProperty); -STDMETHODIMP_(NTSTATUS) -BdaPropertyPinTypes( - IN PIRP Irp, - IN KSPROPERTY *pKSProperty, - OUT ULONG *pulProperty); +STDMETHODIMP_(NTSTATUS) BdaPropertyTemplateConnections( + IN PIRP Irp, + IN KSPROPERTY *pKSProperty, + OUT KSTOPOLOGY_CONNECTION *pConnectionProperty); -STDMETHODIMP_(NTSTATUS) -BdaPropertyTemplateConnections( - IN PIRP Irp, - IN KSPROPERTY *pKSProperty, - OUT KSTOPOLOGY_CONNECTION *pConnectionProperty); +STDMETHODIMP_(NTSTATUS) BdaStartChanges(IN PIRP Irp); +STDMETHODIMP_(NTSTATUS) BdaUninitFilter(IN PKSFILTER pKSFilter); -STDMETHODIMP_(NTSTATUS) -BdaStartChanges( - IN PIRP Irp); - -STDMETHODIMP_(NTSTATUS) -BdaUninitFilter( - IN PKSFILTER pKSFilter); - -STDMETHODIMP_(NTSTATUS) -BdaValidateNodeProperty( - IN PIRP Irp, - IN KSPROPERTY *pKSProperty); +STDMETHODIMP_(NTSTATUS) BdaValidateNodeProperty( + IN PIRP Irp, + IN KSPROPERTY *pKSProperty); #if defined(__cplusplus) } #endif - -#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ diff --git a/reactos/include/ddk/csq.h b/reactos/include/ddk/csq.h index cf7b2c14ce3..99056f610a8 100644 --- a/reactos/include/ddk/csq.h +++ b/reactos/include/ddk/csq.h @@ -229,11 +229,9 @@ typedef struct _IO_CSQ_IRP_CONTEXT { } * */ -#ifndef IO_TYPE_CSQ_EX typedef NTSTATUS (NTAPI *PIO_CSQ_INSERT_IRP_EX) (struct _IO_CSQ *Csq, PIRP Irp, PVOID InsertContext); -#endif /* * CANCEL-SAFE QUEUE DDIs diff --git a/reactos/include/ddk/ntddk.h b/reactos/include/ddk/ntddk.h index 61c23d3077a..0475b3acc85 100644 --- a/reactos/include/ddk/ntddk.h +++ b/reactos/include/ddk/ntddk.h @@ -1,13 +1,12 @@ /* * ntddk.h * - * Windows NT Device Driver Kit + * Windows Device Driver Kit * - * This file is part of the ReactOS DDK package. + * This file is part of the w32api package. * * Contributors: - * Amine Khaldi - * Timo Kreuzer (timo.kreuzer@reactos.org) + * Created by Casper S. Hornstrup * * THIS SOFTWARE IS NOT COPYRIGHTED * @@ -19,10 +18,13 @@ * DISCLAIMED. This includes but is not limited to warranties of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * + * DEFINES: + * DBG - Debugging enabled/disabled (0/1) + * POOL_TAGGING - Enable pool tagging + * _X86_ - X86 environment */ -#pragma once - +#ifndef _NTDDK_ #define _NTDDK_ #if !defined(_NTHAL_) && !defined(_NTIFS_) @@ -39,7 +41,6 @@ #include #include #include -#include /* FIXME #include @@ -54,128 +55,39 @@ extern "C" { #endif -/* GUID and UUID */ -#ifndef _NTLSA_IFS_ -#ifndef _NTLSA_AUDIT_ -#define _NTLSA_AUDIT_ - -#ifndef GUID_DEFINED -#include -#endif - -#endif /* _NTLSA_AUDIT_ */ -#endif /* _NTLSA_IFS_ */ - -typedef GUID UUID; - struct _LOADER_PARAMETER_BLOCK; struct _CREATE_DISK; struct _DRIVE_LAYOUT_INFORMATION_EX; struct _SET_PARTITION_INFORMATION_EX; +// +// GUID and UUID +// +#ifndef GUID_DEFINED +#include +#endif +typedef GUID UUID; + typedef struct _BUS_HANDLER *PBUS_HANDLER; -typedef struct _DEVICE_HANDLER_OBJECT *PDEVICE_HANDLER_OBJECT; -#if defined(_NTHAL_INCLUDED_) -typedef struct _KAFFINITY_EX *PKAFFINITY_EX; -#endif -typedef struct _PEB *PPEB; -#ifndef _NTIMAGE_ +#define EXCEPTION_READ_FAULT 0 +#define EXCEPTION_WRITE_FAULT 1 +#define EXCEPTION_EXECUTE_FAULT 8 -typedef struct _IMAGE_NT_HEADERS *PIMAGE_NT_HEADERS32; -typedef struct _IMAGE_NT_HEADERS64 *PIMAGE_NT_HEADERS64; - -#ifdef _WIN64 -typedef PIMAGE_NT_HEADERS64 PIMAGE_NT_HEADERS; +#if (NTDDI_VERSION >= NTDDI_VISTA) +extern NTSYSAPI volatile CCHAR KeNumberProcessors; +#elif (NTDDI_VERSION >= NTDDI_WINXP) +extern NTSYSAPI CCHAR KeNumberProcessors; #else -typedef PIMAGE_NT_HEADERS32 PIMAGE_NT_HEADERS; +extern PCCHAR KeNumberProcessors; #endif -#endif /* _NTIMAGE_ */ +#define MAX_WOW64_SHARED_ENTRIES 16 -/****************************************************************************** - * Executive Types * - ******************************************************************************/ - -typedef struct _ZONE_SEGMENT_HEADER { - SINGLE_LIST_ENTRY SegmentList; - PVOID Reserved; -} ZONE_SEGMENT_HEADER, *PZONE_SEGMENT_HEADER; - -typedef struct _ZONE_HEADER { - SINGLE_LIST_ENTRY FreeList; - SINGLE_LIST_ENTRY SegmentList; - ULONG BlockSize; - ULONG TotalSegmentSize; -} ZONE_HEADER, *PZONE_HEADER; - -#define PROTECTED_POOL 0x80000000 - - -/****************************************************************************** - * I/O Manager Types * - ******************************************************************************/ - -/* DEVICE_OBJECT.Flags */ -#define DO_DEVICE_HAS_NAME 0x00000040 -#define DO_SYSTEM_BOOT_PARTITION 0x00000100 -#define DO_LONG_TERM_REQUESTS 0x00000200 -#define DO_NEVER_LAST_DEVICE 0x00000400 -#define DO_LOW_PRIORITY_FILESYSTEM 0x00010000 -#define DO_SUPPORTS_TRANSACTIONS 0x00040000 -#define DO_FORCE_NEITHER_IO 0x00080000 -#define DO_VOLUME_DEVICE_OBJECT 0x00100000 -#define DO_SYSTEM_SYSTEM_PARTITION 0x00200000 -#define DO_SYSTEM_CRITICAL_PARTITION 0x00400000 -#define DO_DISALLOW_EXECUTE 0x00800000 - -#ifndef _ARC_DDK_ -#define _ARC_DDK_ -typedef enum _CONFIGURATION_TYPE { - ArcSystem, - CentralProcessor, - FloatingPointProcessor, - PrimaryIcache, - PrimaryDcache, - SecondaryIcache, - SecondaryDcache, - SecondaryCache, - EisaAdapter, - TcAdapter, - ScsiAdapter, - DtiAdapter, - MultiFunctionAdapter, - DiskController, - TapeController, - CdromController, - WormController, - SerialController, - NetworkController, - DisplayController, - ParallelController, - PointerController, - KeyboardController, - AudioController, - OtherController, - DiskPeripheral, - FloppyDiskPeripheral, - TapePeripheral, - ModemPeripheral, - MonitorPeripheral, - PrinterPeripheral, - PointerPeripheral, - KeyboardPeripheral, - TerminalPeripheral, - OtherPeripheral, - LinePeripheral, - NetworkPeripheral, - SystemMemory, - DockingInformation, - RealModeIrqRoutingTable, - RealModePCIEnumeration, - MaximumType -} CONFIGURATION_TYPE, *PCONFIGURATION_TYPE; -#endif /* !_ARC_DDK_ */ +#define NX_SUPPORT_POLICY_ALWAYSOFF 0 +#define NX_SUPPORT_POLICY_ALWAYSON 1 +#define NX_SUPPORT_POLICY_OPTIN 2 +#define NX_SUPPORT_POLICY_OPTOUT 3 /* ** IRP function codes @@ -210,118 +122,102 @@ typedef enum _CONFIGURATION_TYPE { #define IRP_MN_QUERY_LEGACY_BUS_INFORMATION 0x18 -#define IO_CHECK_CREATE_PARAMETERS 0x0200 -#define IO_ATTACH_DEVICE 0x0400 -#define IO_IGNORE_SHARE_ACCESS_CHECK 0x0800 +typedef struct _IO_COUNTERS { + ULONGLONG ReadOperationCount; + ULONGLONG WriteOperationCount; + ULONGLONG OtherOperationCount; + ULONGLONG ReadTransferCount; + ULONGLONG WriteTransferCount; + ULONGLONG OtherTransferCount; +} IO_COUNTERS, *PIO_COUNTERS; -typedef -NTSTATUS -(NTAPI *PIO_QUERY_DEVICE_ROUTINE)( - IN PVOID Context, - IN PUNICODE_STRING PathName, - IN INTERFACE_TYPE BusType, - IN ULONG BusNumber, - IN PKEY_VALUE_FULL_INFORMATION *BusInformation, - IN CONFIGURATION_TYPE ControllerType, - IN ULONG ControllerNumber, - IN PKEY_VALUE_FULL_INFORMATION *ControllerInformation, - IN CONFIGURATION_TYPE PeripheralType, - IN ULONG PeripheralNumber, - IN PKEY_VALUE_FULL_INFORMATION *PeripheralInformation); +typedef struct _VM_COUNTERS { + SIZE_T PeakVirtualSize; + SIZE_T VirtualSize; + ULONG PageFaultCount; + SIZE_T PeakWorkingSetSize; + SIZE_T WorkingSetSize; + SIZE_T QuotaPeakPagedPoolUsage; + SIZE_T QuotaPagedPoolUsage; + SIZE_T QuotaPeakNonPagedPoolUsage; + SIZE_T QuotaNonPagedPoolUsage; + SIZE_T PagefileUsage; + SIZE_T PeakPagefileUsage; +} VM_COUNTERS, *PVM_COUNTERS; -typedef enum _IO_QUERY_DEVICE_DATA_FORMAT { - IoQueryDeviceIdentifier = 0, - IoQueryDeviceConfigurationData, - IoQueryDeviceComponentInformation, - IoQueryDeviceMaxData -} IO_QUERY_DEVICE_DATA_FORMAT, *PIO_QUERY_DEVICE_DATA_FORMAT; +typedef struct _VM_COUNTERS_EX +{ + SIZE_T PeakVirtualSize; + SIZE_T VirtualSize; + ULONG PageFaultCount; + SIZE_T PeakWorkingSetSize; + SIZE_T WorkingSetSize; + SIZE_T QuotaPeakPagedPoolUsage; + SIZE_T QuotaPagedPoolUsage; + SIZE_T QuotaPeakNonPagedPoolUsage; + SIZE_T QuotaNonPagedPoolUsage; + SIZE_T PagefileUsage; + SIZE_T PeakPagefileUsage; + SIZE_T PrivateUsage; +} VM_COUNTERS_EX, *PVM_COUNTERS_EX; -typedef VOID -(NTAPI *PDRIVER_REINITIALIZE)( - IN struct _DRIVER_OBJECT *DriverObject, - IN PVOID Context OPTIONAL, - IN ULONG Count); +typedef struct _POOLED_USAGE_AND_LIMITS +{ + SIZE_T PeakPagedPoolUsage; + SIZE_T PagedPoolUsage; + SIZE_T PagedPoolLimit; + SIZE_T PeakNonPagedPoolUsage; + SIZE_T NonPagedPoolUsage; + SIZE_T NonPagedPoolLimit; + SIZE_T PeakPagefileUsage; + SIZE_T PagefileUsage; + SIZE_T PagefileLimit; +} POOLED_USAGE_AND_LIMITS, *PPOOLED_USAGE_AND_LIMITS; -typedef struct _CONTROLLER_OBJECT { - CSHORT Type; - CSHORT Size; - PVOID ControllerExtension; - KDEVICE_QUEUE DeviceWaitQueue; - ULONG Spare1; - LARGE_INTEGER Spare2; -} CONTROLLER_OBJECT, *PCONTROLLER_OBJECT; +/* DEVICE_OBJECT.Flags */ + +#define DO_VERIFY_VOLUME 0x00000002 +#define DO_BUFFERED_IO 0x00000004 +#define DO_EXCLUSIVE 0x00000008 +#define DO_DIRECT_IO 0x00000010 +#define DO_MAP_IO_BUFFER 0x00000020 +#define DO_DEVICE_HAS_NAME 0x00000040 +#define DO_DEVICE_INITIALIZING 0x00000080 +#define DO_SYSTEM_BOOT_PARTITION 0x00000100 +#define DO_LONG_TERM_REQUESTS 0x00000200 +#define DO_NEVER_LAST_DEVICE 0x00000400 +#define DO_SHUTDOWN_REGISTERED 0x00000800 +#define DO_BUS_ENUMERATED_DEVICE 0x00001000 +#define DO_POWER_PAGABLE 0x00002000 +#define DO_POWER_INRUSH 0x00004000 +#define DO_LOW_PRIORITY_FILESYSTEM 0x00010000 +#define DO_SUPPORTS_TRANSACTIONS 0x00040000 +#define DO_FORCE_NEITHER_IO 0x00080000 +#define DO_VOLUME_DEVICE_OBJECT 0x00100000 +#define DO_SYSTEM_SYSTEM_PARTITION 0x00200000 +#define DO_SYSTEM_CRITICAL_PARTITION 0x00400000 +#define DO_DISALLOW_EXECUTE 0x00800000 #define DRVO_REINIT_REGISTERED 0x00000008 #define DRVO_INITIALIZED 0x00000010 #define DRVO_BOOTREINIT_REGISTERED 0x00000020 #define DRVO_LEGACY_RESOURCES 0x00000040 -typedef struct _CONFIGURATION_INFORMATION { - ULONG DiskCount; - ULONG FloppyCount; - ULONG CdRomCount; - ULONG TapeCount; - ULONG ScsiPortCount; - ULONG SerialCount; - ULONG ParallelCount; - BOOLEAN AtDiskPrimaryAddressClaimed; - BOOLEAN AtDiskSecondaryAddressClaimed; - ULONG Version; - ULONG MediumChangerCount; -} CONFIGURATION_INFORMATION, *PCONFIGURATION_INFORMATION; +typedef enum _ARBITER_REQUEST_SOURCE { + ArbiterRequestUndefined = -1, + ArbiterRequestLegacyReported, + ArbiterRequestHalReported, + ArbiterRequestLegacyAssigned, + ArbiterRequestPnpDetected, + ArbiterRequestPnpEnumerated +} ARBITER_REQUEST_SOURCE; -typedef struct _DISK_SIGNATURE { - ULONG PartitionStyle; - _ANONYMOUS_UNION union { - struct { - ULONG Signature; - ULONG CheckSum; - } Mbr; - struct { - GUID DiskId; - } Gpt; - } DUMMYUNIONNAME; -} DISK_SIGNATURE, *PDISK_SIGNATURE; - -typedef struct _TXN_PARAMETER_BLOCK { - USHORT Length; - USHORT TxFsContext; - PVOID TransactionObject; -} TXN_PARAMETER_BLOCK, *PTXN_PARAMETER_BLOCK; - -#define TXF_MINIVERSION_DEFAULT_VIEW (0xFFFE) - -typedef struct _IO_DRIVER_CREATE_CONTEXT { - CSHORT Size; - struct _ECP_LIST *ExtraCreateParameter; - PVOID DeviceObjectHint; - PTXN_PARAMETER_BLOCK TxnParameters; -} IO_DRIVER_CREATE_CONTEXT, *PIO_DRIVER_CREATE_CONTEXT; - -typedef struct _AGP_TARGET_BUS_INTERFACE_STANDARD { - USHORT Size; - USHORT Version; - PVOID Context; - PINTERFACE_REFERENCE InterfaceReference; - PINTERFACE_DEREFERENCE InterfaceDereference; - PGET_SET_DEVICE_DATA SetBusData; - PGET_SET_DEVICE_DATA GetBusData; - UCHAR CapabilityID; -} AGP_TARGET_BUS_INTERFACE_STANDARD, *PAGP_TARGET_BUS_INTERFACE_STANDARD; - -typedef NTSTATUS -(NTAPI *PGET_LOCATION_STRING)( - IN OUT PVOID Context OPTIONAL, - OUT PWCHAR *LocationStrings); - -typedef struct _PNP_LOCATION_INTERFACE { - USHORT Size; - USHORT Version; - PVOID Context; - PINTERFACE_REFERENCE InterfaceReference; - PINTERFACE_DEREFERENCE InterfaceDereference; - PGET_LOCATION_STRING GetLocationString; -} PNP_LOCATION_INTERFACE, *PPNP_LOCATION_INTERFACE; +typedef enum _ARBITER_RESULT { + ArbiterResultUndefined = -1, + ArbiterResultSuccess, + ArbiterResultExternalConflict, + ArbiterResultNullRequest +} ARBITER_RESULT; typedef enum _ARBITER_ACTION { ArbiterActionTestAllocation, @@ -342,69 +238,39 @@ typedef struct _ARBITER_CONFLICT_INFO { ULONGLONG End; } ARBITER_CONFLICT_INFO, *PARBITER_CONFLICT_INFO; -typedef struct _ARBITER_TEST_ALLOCATION_PARAMETERS { - IN OUT PLIST_ENTRY ArbitrationList; - IN ULONG AllocateFromCount; - IN PCM_PARTIAL_RESOURCE_DESCRIPTOR AllocateFrom; -} ARBITER_TEST_ALLOCATION_PARAMETERS, *PARBITER_TEST_ALLOCATION_PARAMETERS; - -typedef struct _ARBITER_RETEST_ALLOCATION_PARAMETERS { - IN OUT PLIST_ENTRY ArbitrationList; - IN ULONG AllocateFromCount; - IN PCM_PARTIAL_RESOURCE_DESCRIPTOR AllocateFrom; -} ARBITER_RETEST_ALLOCATION_PARAMETERS, *PARBITER_RETEST_ALLOCATION_PARAMETERS; - -typedef struct _ARBITER_BOOT_ALLOCATION_PARAMETERS { - IN OUT PLIST_ENTRY ArbitrationList; -} ARBITER_BOOT_ALLOCATION_PARAMETERS, *PARBITER_BOOT_ALLOCATION_PARAMETERS; - -typedef struct _ARBITER_QUERY_ALLOCATED_RESOURCES_PARAMETERS { - OUT PCM_PARTIAL_RESOURCE_LIST *AllocatedResources; -} ARBITER_QUERY_ALLOCATED_RESOURCES_PARAMETERS, *PARBITER_QUERY_ALLOCATED_RESOURCES_PARAMETERS; - -typedef struct _ARBITER_QUERY_CONFLICT_PARAMETERS { - IN PDEVICE_OBJECT PhysicalDeviceObject; - IN PIO_RESOURCE_DESCRIPTOR ConflictingResource; - OUT PULONG ConflictCount; - OUT PARBITER_CONFLICT_INFO *Conflicts; -} ARBITER_QUERY_CONFLICT_PARAMETERS, *PARBITER_QUERY_CONFLICT_PARAMETERS; - -typedef struct _ARBITER_QUERY_ARBITRATE_PARAMETERS { - IN PLIST_ENTRY ArbitrationList; -} ARBITER_QUERY_ARBITRATE_PARAMETERS, *PARBITER_QUERY_ARBITRATE_PARAMETERS; - -typedef struct _ARBITER_ADD_RESERVED_PARAMETERS { - IN PDEVICE_OBJECT ReserveDevice; -} ARBITER_ADD_RESERVED_PARAMETERS, *PARBITER_ADD_RESERVED_PARAMETERS; - typedef struct _ARBITER_PARAMETERS { union { - ARBITER_TEST_ALLOCATION_PARAMETERS TestAllocation; - ARBITER_RETEST_ALLOCATION_PARAMETERS RetestAllocation; - ARBITER_BOOT_ALLOCATION_PARAMETERS BootAllocation; - ARBITER_QUERY_ALLOCATED_RESOURCES_PARAMETERS QueryAllocatedResources; - ARBITER_QUERY_CONFLICT_PARAMETERS QueryConflict; - ARBITER_QUERY_ARBITRATE_PARAMETERS QueryArbitrate; - ARBITER_ADD_RESERVED_PARAMETERS AddReserved; + struct { + IN OUT PLIST_ENTRY ArbitrationList; + IN ULONG AllocateFromCount; + IN PCM_PARTIAL_RESOURCE_DESCRIPTOR AllocateFrom; + } TestAllocation; + struct { + IN OUT PLIST_ENTRY ArbitrationList; + IN ULONG AllocateFromCount; + IN PCM_PARTIAL_RESOURCE_DESCRIPTOR AllocateFrom; + } RetestAllocation; + struct { + IN OUT PLIST_ENTRY ArbitrationList; + } BootAllocation; + struct { + OUT PCM_PARTIAL_RESOURCE_LIST *AllocatedResources; + } QueryAllocatedResources; + struct { + IN PDEVICE_OBJECT PhysicalDeviceObject; + IN PIO_RESOURCE_DESCRIPTOR ConflictingResource; + OUT PULONG ConflictCount; + OUT PARBITER_CONFLICT_INFO *Conflicts; + } QueryConflict; + struct { + IN PLIST_ENTRY ArbitrationList; + } QueryArbitrate; + struct { + IN PDEVICE_OBJECT ReserveDevice; + } AddReserved; } Parameters; } ARBITER_PARAMETERS, *PARBITER_PARAMETERS; -typedef enum _ARBITER_REQUEST_SOURCE { - ArbiterRequestUndefined = -1, - ArbiterRequestLegacyReported, - ArbiterRequestHalReported, - ArbiterRequestLegacyAssigned, - ArbiterRequestPnpDetected, - ArbiterRequestPnpEnumerated -} ARBITER_REQUEST_SOURCE; - -typedef enum _ARBITER_RESULT { - ArbiterResultUndefined = -1, - ArbiterResultSuccess, - ArbiterResultExternalConflict, - ArbiterResultNullRequest -} ARBITER_RESULT; - #define ARBITER_FLAG_BOOT_CONFIG 0x00000001 typedef struct _ARBITER_LIST_ENTRY { @@ -441,826 +307,6 @@ typedef struct _ARBITER_INTERFACE { ULONG Flags; } ARBITER_INTERFACE, *PARBITER_INTERFACE; -typedef enum _RESOURCE_TRANSLATION_DIRECTION { - TranslateChildToParent, - TranslateParentToChild -} RESOURCE_TRANSLATION_DIRECTION; - -typedef NTSTATUS -(NTAPI *PTRANSLATE_RESOURCE_HANDLER)( - IN OUT PVOID Context OPTIONAL, - IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Source, - IN RESOURCE_TRANSLATION_DIRECTION Direction, - IN ULONG AlternativesCount OPTIONAL, - IN IO_RESOURCE_DESCRIPTOR Alternatives[], - IN PDEVICE_OBJECT PhysicalDeviceObject, - OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR Target); - -typedef NTSTATUS -(NTAPI *PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER)( - IN OUT PVOID Context OPTIONAL, - IN PIO_RESOURCE_DESCRIPTOR Source, - IN PDEVICE_OBJECT PhysicalDeviceObject, - OUT PULONG TargetCount, - OUT PIO_RESOURCE_DESCRIPTOR *Target); - -typedef struct _TRANSLATOR_INTERFACE { - USHORT Size; - USHORT Version; - PVOID Context; - PINTERFACE_REFERENCE InterfaceReference; - PINTERFACE_DEREFERENCE InterfaceDereference; - PTRANSLATE_RESOURCE_HANDLER TranslateResources; - PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER TranslateResourceRequirements; -} TRANSLATOR_INTERFACE, *PTRANSLATOR_INTERFACE; - -typedef struct _PCI_AGP_CAPABILITY { - PCI_CAPABILITIES_HEADER Header; - USHORT Minor:4; - USHORT Major:4; - USHORT Rsvd1:8; - struct _PCI_AGP_STATUS { - ULONG Rate:3; - ULONG Agp3Mode:1; - ULONG FastWrite:1; - ULONG FourGB:1; - ULONG HostTransDisable:1; - ULONG Gart64:1; - ULONG ITA_Coherent:1; - ULONG SideBandAddressing:1; - ULONG CalibrationCycle:3; - ULONG AsyncRequestSize:3; - ULONG Rsvd1:1; - ULONG Isoch:1; - ULONG Rsvd2:6; - ULONG RequestQueueDepthMaximum:8; - } AGPStatus; - struct _PCI_AGP_COMMAND { - ULONG Rate:3; - ULONG Rsvd1:1; - ULONG FastWriteEnable:1; - ULONG FourGBEnable:1; - ULONG Rsvd2:1; - ULONG Gart64:1; - ULONG AGPEnable:1; - ULONG SBAEnable:1; - ULONG CalibrationCycle:3; - ULONG AsyncReqSize:3; - ULONG Rsvd3:8; - ULONG RequestQueueDepth:8; - } AGPCommand; -} PCI_AGP_CAPABILITY, *PPCI_AGP_CAPABILITY; - -typedef enum _EXTENDED_AGP_REGISTER { - IsochStatus, - AgpControl, - ApertureSize, - AperturePageSize, - GartLow, - GartHigh, - IsochCommand -} EXTENDED_AGP_REGISTER, *PEXTENDED_AGP_REGISTER; - -typedef struct _PCI_AGP_ISOCH_STATUS { - ULONG ErrorCode:2; - ULONG Rsvd1:1; - ULONG Isoch_L:3; - ULONG Isoch_Y:2; - ULONG Isoch_N:8; - ULONG Rsvd2:16; -} PCI_AGP_ISOCH_STATUS, *PPCI_AGP_ISOCH_STATUS; - -typedef struct _PCI_AGP_CONTROL { - ULONG Rsvd1:7; - ULONG GTLB_Enable:1; - ULONG AP_Enable:1; - ULONG CAL_Disable:1; - ULONG Rsvd2:22; -} PCI_AGP_CONTROL, *PPCI_AGP_CONTROL; - -typedef struct _PCI_AGP_APERTURE_PAGE_SIZE { - USHORT PageSizeMask:11; - USHORT Rsvd1:1; - USHORT PageSizeSelect:4; -} PCI_AGP_APERTURE_PAGE_SIZE, *PPCI_AGP_APERTURE_PAGE_SIZE; - -typedef struct _PCI_AGP_ISOCH_COMMAND { - USHORT Rsvd1:6; - USHORT Isoch_Y:2; - USHORT Isoch_N:8; -} PCI_AGP_ISOCH_COMMAND, *PPCI_AGP_ISOCH_COMMAND; - -typedef struct PCI_AGP_EXTENDED_CAPABILITY { - PCI_AGP_ISOCH_STATUS IsochStatus; - PCI_AGP_CONTROL AgpControl; - USHORT ApertureSize; - PCI_AGP_APERTURE_PAGE_SIZE AperturePageSize; - ULONG GartLow; - ULONG GartHigh; - PCI_AGP_ISOCH_COMMAND IsochCommand; -} PCI_AGP_EXTENDED_CAPABILITY, *PPCI_AGP_EXTENDED_CAPABILITY; - -#define PCI_AGP_RATE_1X 0x1 -#define PCI_AGP_RATE_2X 0x2 -#define PCI_AGP_RATE_4X 0x4 - -#define PCIX_MODE_CONVENTIONAL_PCI 0x0 -#define PCIX_MODE1_66MHZ 0x1 -#define PCIX_MODE1_100MHZ 0x2 -#define PCIX_MODE1_133MHZ 0x3 -#define PCIX_MODE2_266_66MHZ 0x9 -#define PCIX_MODE2_266_100MHZ 0xA -#define PCIX_MODE2_266_133MHZ 0xB -#define PCIX_MODE2_533_66MHZ 0xD -#define PCIX_MODE2_533_100MHZ 0xE -#define PCIX_MODE2_533_133MHZ 0xF - -#define PCIX_VERSION_MODE1_ONLY 0x0 -#define PCIX_VERSION_MODE2_ECC 0x1 -#define PCIX_VERSION_DUAL_MODE_ECC 0x2 - -typedef struct _PCIX_BRIDGE_CAPABILITY { - PCI_CAPABILITIES_HEADER Header; - union { - struct { - USHORT Bus64Bit:1; - USHORT Bus133MHzCapable:1; - USHORT SplitCompletionDiscarded:1; - USHORT UnexpectedSplitCompletion:1; - USHORT SplitCompletionOverrun:1; - USHORT SplitRequestDelayed:1; - USHORT BusModeFrequency:4; - USHORT Rsvd:2; - USHORT Version:2; - USHORT Bus266MHzCapable:1; - USHORT Bus533MHzCapable:1; - } DUMMYSTRUCTNAME; - USHORT AsUSHORT; - } SecondaryStatus; - union { - struct { - ULONG FunctionNumber:3; - ULONG DeviceNumber:5; - ULONG BusNumber:8; - ULONG Device64Bit:1; - ULONG Device133MHzCapable:1; - ULONG SplitCompletionDiscarded:1; - ULONG UnexpectedSplitCompletion:1; - ULONG SplitCompletionOverrun:1; - ULONG SplitRequestDelayed:1; - ULONG Rsvd:7; - ULONG DIMCapable:1; - ULONG Device266MHzCapable:1; - ULONG Device533MHzCapable:1; - } DUMMYSTRUCTNAME; - ULONG AsULONG; - } BridgeStatus; - USHORT UpstreamSplitTransactionCapacity; - USHORT UpstreamSplitTransactionLimit; - USHORT DownstreamSplitTransactionCapacity; - USHORT DownstreamSplitTransactionLimit; - union { - struct { - ULONG SelectSecondaryRegisters:1; - ULONG ErrorPresentInOtherBank:1; - ULONG AdditionalCorrectableError:1; - ULONG AdditionalUncorrectableError:1; - ULONG ErrorPhase:3; - ULONG ErrorCorrected:1; - ULONG Syndrome:8; - ULONG ErrorFirstCommand:4; - ULONG ErrorSecondCommand:4; - ULONG ErrorUpperAttributes:4; - ULONG ControlUpdateEnable:1; - ULONG Rsvd:1; - ULONG DisableSingleBitCorrection:1; - ULONG EccMode:1; - } DUMMYSTRUCTNAME; - ULONG AsULONG; - } EccControlStatus; - ULONG EccFirstAddress; - ULONG EccSecondAddress; - ULONG EccAttribute; -} PCIX_BRIDGE_CAPABILITY, *PPCIX_BRIDGE_CAPABILITY; - -typedef struct _PCI_SUBSYSTEM_IDS_CAPABILITY { - PCI_CAPABILITIES_HEADER Header; - USHORT Reserved; - USHORT SubVendorID; - USHORT SubSystemID; -} PCI_SUBSYSTEM_IDS_CAPABILITY, *PPCI_SUBSYSTEM_IDS_CAPABILITY; - -#define OSC_FIRMWARE_FAILURE 0x02 -#define OSC_UNRECOGNIZED_UUID 0x04 -#define OSC_UNRECOGNIZED_REVISION 0x08 -#define OSC_CAPABILITIES_MASKED 0x10 - -#define PCI_ROOT_BUS_OSC_METHOD_CAPABILITY_REVISION 0x01 - -typedef struct _PCI_ROOT_BUS_OSC_SUPPORT_FIELD { - union { - struct { - ULONG ExtendedConfigOpRegions:1; - ULONG ActiveStatePowerManagement:1; - ULONG ClockPowerManagement:1; - ULONG SegmentGroups:1; - ULONG MessageSignaledInterrupts:1; - ULONG WindowsHardwareErrorArchitecture:1; - ULONG Reserved:26; - } DUMMYSTRUCTNAME; - ULONG AsULONG; - } u; -} PCI_ROOT_BUS_OSC_SUPPORT_FIELD, *PPCI_ROOT_BUS_OSC_SUPPORT_FIELD; - -typedef struct _PCI_ROOT_BUS_OSC_CONTROL_FIELD { - union { - struct { - ULONG ExpressNativeHotPlug:1; - ULONG ShpcNativeHotPlug:1; - ULONG ExpressNativePME:1; - ULONG ExpressAdvancedErrorReporting:1; - ULONG ExpressCapabilityStructure:1; - ULONG Reserved:27; - } DUMMYSTRUCTNAME; - ULONG AsULONG; - } u; -} PCI_ROOT_BUS_OSC_CONTROL_FIELD, *PPCI_ROOT_BUS_OSC_CONTROL_FIELD; - -typedef enum _PCI_HARDWARE_INTERFACE { - PciConventional, - PciXMode1, - PciXMode2, - PciExpress -} PCI_HARDWARE_INTERFACE, *PPCI_HARDWARE_INTERFACE; - -typedef enum { - BusWidth32Bits, - BusWidth64Bits -} PCI_BUS_WIDTH; - -typedef struct _PCI_ROOT_BUS_HARDWARE_CAPABILITY { - PCI_HARDWARE_INTERFACE SecondaryInterface; - struct { - BOOLEAN BusCapabilitiesFound; - ULONG CurrentSpeedAndMode; - ULONG SupportedSpeedsAndModes; - BOOLEAN DeviceIDMessagingCapable; - PCI_BUS_WIDTH SecondaryBusWidth; - } DUMMYSTRUCTNAME; - PCI_ROOT_BUS_OSC_SUPPORT_FIELD OscFeatureSupport; - PCI_ROOT_BUS_OSC_CONTROL_FIELD OscControlRequest; - PCI_ROOT_BUS_OSC_CONTROL_FIELD OscControlGranted; -} PCI_ROOT_BUS_HARDWARE_CAPABILITY, *PPCI_ROOT_BUS_HARDWARE_CAPABILITY; - -typedef union _PCI_EXPRESS_CAPABILITIES_REGISTER { - struct { - USHORT CapabilityVersion:4; - USHORT DeviceType:4; - USHORT SlotImplemented:1; - USHORT InterruptMessageNumber:5; - USHORT Rsvd:2; - } DUMMYSTRUCTNAME; - USHORT AsUSHORT; -} PCI_EXPRESS_CAPABILITIES_REGISTER, *PPCI_EXPRESS_CAPABILITIES_REGISTER; - -typedef union _PCI_EXPRESS_DEVICE_CAPABILITIES_REGISTER { - struct { - ULONG MaxPayloadSizeSupported:3; - ULONG PhantomFunctionsSupported:2; - ULONG ExtendedTagSupported:1; - ULONG L0sAcceptableLatency:3; - ULONG L1AcceptableLatency:3; - ULONG Undefined:3; - ULONG RoleBasedErrorReporting:1; - ULONG Rsvd1:2; - ULONG CapturedSlotPowerLimit:8; - ULONG CapturedSlotPowerLimitScale:2; - ULONG Rsvd2:4; - } DUMMYSTRUCTNAME; - ULONG AsULONG; -} PCI_EXPRESS_DEVICE_CAPABILITIES_REGISTER, *PPCI_EXPRESS_DEVICE_CAPABILITIES_REGISTER; - -#define PCI_EXPRESS_AER_DEVICE_CONTROL_MASK 0x07; - -typedef union _PCI_EXPRESS_DEVICE_CONTROL_REGISTER { - struct { - USHORT CorrectableErrorEnable:1; - USHORT NonFatalErrorEnable:1; - USHORT FatalErrorEnable:1; - USHORT UnsupportedRequestErrorEnable:1; - USHORT EnableRelaxedOrder:1; - USHORT MaxPayloadSize:3; - USHORT ExtendedTagEnable:1; - USHORT PhantomFunctionsEnable:1; - USHORT AuxPowerEnable:1; - USHORT NoSnoopEnable:1; - USHORT MaxReadRequestSize:3; - USHORT BridgeConfigRetryEnable:1; - } DUMMYSTRUCTNAME; - USHORT AsUSHORT; -} PCI_EXPRESS_DEVICE_CONTROL_REGISTER, *PPCI_EXPRESS_DEVICE_CONTROL_REGISTER; - -#define PCI_EXPRESS_AER_DEVICE_STATUS_MASK 0x0F; - -typedef union _PCI_EXPRESS_DEVICE_STATUS_REGISTER { - struct { - USHORT CorrectableErrorDetected:1; - USHORT NonFatalErrorDetected:1; - USHORT FatalErrorDetected:1; - USHORT UnsupportedRequestDetected:1; - USHORT AuxPowerDetected:1; - USHORT TransactionsPending:1; - USHORT Rsvd:10; - } DUMMYSTRUCTNAME; - USHORT AsUSHORT; -} PCI_EXPRESS_DEVICE_STATUS_REGISTER, *PPCI_EXPRESS_DEVICE_STATUS_REGISTER; - -typedef union _PCI_EXPRESS_LINK_CAPABILITIES_REGISTER { - struct { - ULONG MaximumLinkSpeed:4; - ULONG MaximumLinkWidth:6; - ULONG ActiveStatePMSupport:2; - ULONG L0sExitLatency:3; - ULONG L1ExitLatency:3; - ULONG ClockPowerManagement:1; - ULONG SurpriseDownErrorReportingCapable:1; - ULONG DataLinkLayerActiveReportingCapable:1; - ULONG Rsvd:3; - ULONG PortNumber:8; - } DUMMYSTRUCTNAME; - ULONG AsULONG; -} PCI_EXPRESS_LINK_CAPABILITIES_REGISTER, *PPCI_EXPRESS_LINK_CAPABILITIES_REGISTER; - -typedef union _PCI_EXPRESS_LINK_CONTROL_REGISTER { - struct { - USHORT ActiveStatePMControl:2; - USHORT Rsvd1:1; - USHORT ReadCompletionBoundary:1; - USHORT LinkDisable:1; - USHORT RetrainLink:1; - USHORT CommonClockConfig:1; - USHORT ExtendedSynch:1; - USHORT EnableClockPowerManagement:1; - USHORT Rsvd2:7; - } DUMMYSTRUCTNAME; - USHORT AsUSHORT; -} PCI_EXPRESS_LINK_CONTROL_REGISTER, *PPCI_EXPRESS_LINK_CONTROL_REGISTER; - -typedef union _PCI_EXPRESS_LINK_STATUS_REGISTER { - struct { - USHORT LinkSpeed:4; - USHORT LinkWidth:6; - USHORT Undefined:1; - USHORT LinkTraining:1; - USHORT SlotClockConfig:1; - USHORT DataLinkLayerActive:1; - USHORT Rsvd:2; - } DUMMYSTRUCTNAME; - USHORT AsUSHORT; -} PCI_EXPRESS_LINK_STATUS_REGISTER, *PPCI_EXPRESS_LINK_STATUS_REGISTER; - -typedef union _PCI_EXPRESS_SLOT_CAPABILITIES_REGISTER { - struct { - ULONG AttentionButtonPresent:1; - ULONG PowerControllerPresent:1; - ULONG MRLSensorPresent:1; - ULONG AttentionIndicatorPresent:1; - ULONG PowerIndicatorPresent:1; - ULONG HotPlugSurprise:1; - ULONG HotPlugCapable:1; - ULONG SlotPowerLimit:8; - ULONG SlotPowerLimitScale:2; - ULONG ElectromechanicalLockPresent:1; - ULONG NoCommandCompletedSupport:1; - ULONG PhysicalSlotNumber:13; - } DUMMYSTRUCTNAME; - ULONG AsULONG; -} PCI_EXPRESS_SLOT_CAPABILITIES_REGISTER, *PPCI_EXPRESS_SLOT_CAPABILITIES_REGISTER; - -typedef union _PCI_EXPRESS_SLOT_CONTROL_REGISTER { - struct { - USHORT AttentionButtonEnable:1; - USHORT PowerFaultDetectEnable:1; - USHORT MRLSensorEnable:1; - USHORT PresenceDetectEnable:1; - USHORT CommandCompletedEnable:1; - USHORT HotPlugInterruptEnable:1; - USHORT AttentionIndicatorControl:2; - USHORT PowerIndicatorControl:2; - USHORT PowerControllerControl:1; - USHORT ElectromechanicalLockControl:1; - USHORT DataLinkStateChangeEnable:1; - USHORT Rsvd:3; - } DUMMYSTRUCTNAME; - USHORT AsUSHORT; -} PCI_EXPRESS_SLOT_CONTROL_REGISTER, *PPCI_EXPRESS_SLOT_CONTROL_REGISTER; - -typedef union _PCI_EXPRESS_SLOT_STATUS_REGISTER { - struct { - USHORT AttentionButtonPressed:1; - USHORT PowerFaultDetected:1; - USHORT MRLSensorChanged:1; - USHORT PresenceDetectChanged:1; - USHORT CommandCompleted:1; - USHORT MRLSensorState:1; - USHORT PresenceDetectState:1; - USHORT ElectromechanicalLockEngaged:1; - USHORT DataLinkStateChanged:1; - USHORT Rsvd:7; - } DUMMYSTRUCTNAME; - USHORT AsUSHORT; -} PCI_EXPRESS_SLOT_STATUS_REGISTER, *PPCI_EXPRESS_SLOT_STATUS_REGISTER; - -typedef union _PCI_EXPRESS_ROOT_CONTROL_REGISTER { - struct { - USHORT CorrectableSerrEnable:1; - USHORT NonFatalSerrEnable:1; - USHORT FatalSerrEnable:1; - USHORT PMEInterruptEnable:1; - USHORT CRSSoftwareVisibilityEnable:1; - USHORT Rsvd:11; - } DUMMYSTRUCTNAME; - USHORT AsUSHORT; -} PCI_EXPRESS_ROOT_CONTROL_REGISTER, *PPCI_EXPRESS_ROOT_CONTROL_REGISTER; - -typedef union _PCI_EXPRESS_ROOT_CAPABILITIES_REGISTER { - struct { - USHORT CRSSoftwareVisibility:1; - USHORT Rsvd:15; - } DUMMYSTRUCTNAME; - USHORT AsUSHORT; -} PCI_EXPRESS_ROOT_CAPABILITIES_REGISTER, *PPCI_EXPRESS_ROOT_CAPABILITIES_REGISTER; - -typedef union _PCI_EXPRESS_ROOT_STATUS_REGISTER { - struct { - ULONG PMERequestorId:16; - ULONG PMEStatus:1; - ULONG PMEPending:1; - ULONG Rsvd:14; - } DUMMYSTRUCTNAME; - ULONG AsULONG; -} PCI_EXPRESS_ROOT_STATUS_REGISTER, *PPCI_EXPRESS_ROOT_STATUS_REGISTER; - -typedef struct _PCI_EXPRESS_CAPABILITY { - PCI_CAPABILITIES_HEADER Header; - PCI_EXPRESS_CAPABILITIES_REGISTER ExpressCapabilities; - PCI_EXPRESS_DEVICE_CAPABILITIES_REGISTER DeviceCapabilities; - PCI_EXPRESS_DEVICE_CONTROL_REGISTER DeviceControl; - PCI_EXPRESS_DEVICE_STATUS_REGISTER DeviceStatus; - PCI_EXPRESS_LINK_CAPABILITIES_REGISTER LinkCapabilities; - PCI_EXPRESS_LINK_CONTROL_REGISTER LinkControl; - PCI_EXPRESS_LINK_STATUS_REGISTER LinkStatus; - PCI_EXPRESS_SLOT_CAPABILITIES_REGISTER SlotCapabilities; - PCI_EXPRESS_SLOT_CONTROL_REGISTER SlotControl; - PCI_EXPRESS_SLOT_STATUS_REGISTER SlotStatus; - PCI_EXPRESS_ROOT_CONTROL_REGISTER RootControl; - PCI_EXPRESS_ROOT_CAPABILITIES_REGISTER RootCapabilities; - PCI_EXPRESS_ROOT_STATUS_REGISTER RootStatus; -} PCI_EXPRESS_CAPABILITY, *PPCI_EXPRESS_CAPABILITY; - -typedef enum { - MRLClosed = 0, - MRLOpen -} PCI_EXPRESS_MRL_STATE; - -typedef enum { - SlotEmpty = 0, - CardPresent -} PCI_EXPRESS_CARD_PRESENCE; - -typedef enum { - IndicatorOn = 1, - IndicatorBlink, - IndicatorOff -} PCI_EXPRESS_INDICATOR_STATE; - -typedef enum { - PowerOn = 0, - PowerOff -} PCI_EXPRESS_POWER_STATE; - -typedef enum { - L0sEntrySupport = 1, - L0sAndL1EntrySupport = 3 -} PCI_EXPRESS_ASPM_SUPPORT; - -typedef enum { - L0sAndL1EntryDisabled, - L0sEntryEnabled, - L1EntryEnabled, - L0sAndL1EntryEnabled -} PCI_EXPRESS_ASPM_CONTROL; - -typedef enum { - L0s_Below64ns = 0, - L0s_64ns_128ns, - L0s_128ns_256ns, - L0s_256ns_512ns, - L0s_512ns_1us, - L0s_1us_2us, - L0s_2us_4us, - L0s_Above4us -} PCI_EXPRESS_L0s_EXIT_LATENCY; - -typedef enum { - L1_Below1us = 0, - L1_1us_2us, - L1_2us_4us, - L1_4us_8us, - L1_8us_16us, - L1_16us_32us, - L1_32us_64us, - L1_Above64us -} PCI_EXPRESS_L1_EXIT_LATENCY; - -typedef enum { - PciExpressEndpoint = 0, - PciExpressLegacyEndpoint, - PciExpressRootPort = 4, - PciExpressUpstreamSwitchPort, - PciExpressDownstreamSwitchPort, - PciExpressToPciXBridge, - PciXToExpressBridge, - PciExpressRootComplexIntegratedEndpoint, - PciExpressRootComplexEventCollector -} PCI_EXPRESS_DEVICE_TYPE; - -typedef enum { - MaxPayload128Bytes = 0, - MaxPayload256Bytes, - MaxPayload512Bytes, - MaxPayload1024Bytes, - MaxPayload2048Bytes, - MaxPayload4096Bytes -} PCI_EXPRESS_MAX_PAYLOAD_SIZE; - -typedef union _PCI_EXPRESS_PME_REQUESTOR_ID { - struct { - USHORT FunctionNumber:3; - USHORT DeviceNumber:5; - USHORT BusNumber:8; - } DUMMYSTRUCTNAME; - USHORT AsUSHORT; -} PCI_EXPRESS_PME_REQUESTOR_ID, *PPCI_EXPRESS_PME_REQUESTOR_ID; - -#if defined(_WIN64) - -#ifndef USE_DMA_MACROS -#define USE_DMA_MACROS -#endif - -#ifndef NO_LEGACY_DRIVERS -#define NO_LEGACY_DRIVERS -#endif - -#endif /* defined(_WIN64) */ - -typedef enum _PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR_TYPE { - ResourceTypeSingle = 0, - ResourceTypeRange, - ResourceTypeExtendedCounterConfiguration, - ResourceTypeOverflow, - ResourceTypeMax -} PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR_TYPE; - -typedef struct _PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR { - PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR_TYPE Type; - ULONG Flags; - union { - ULONG CounterIndex; - ULONG ExtendedRegisterAddress; - struct { - ULONG Begin; - ULONG End; - } Range; - } u; -} PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR, *PPHYSICAL_COUNTER_RESOURCE_DESCRIPTOR; - -typedef struct _PHYSICAL_COUNTER_RESOURCE_LIST { - ULONG Count; - PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR Descriptors[ANYSIZE_ARRAY]; -} PHYSICAL_COUNTER_RESOURCE_LIST, *PPHYSICAL_COUNTER_RESOURCE_LIST; - -typedef VOID -(NTAPI *PciPin2Line)( - IN struct _BUS_HANDLER *BusHandler, - IN struct _BUS_HANDLER *RootHandler, - IN PCI_SLOT_NUMBER SlotNumber, - IN PPCI_COMMON_CONFIG PciData); - -typedef VOID -(NTAPI *PciLine2Pin)( - IN struct _BUS_HANDLER *BusHandler, - IN struct _BUS_HANDLER *RootHandler, - IN PCI_SLOT_NUMBER SlotNumber, - IN PPCI_COMMON_CONFIG PciNewData, - IN PPCI_COMMON_CONFIG PciOldData); - -typedef VOID -(NTAPI *PciReadWriteConfig)( - IN struct _BUS_HANDLER *BusHandler, - IN PCI_SLOT_NUMBER Slot, - IN PVOID Buffer, - IN ULONG Offset, - IN ULONG Length); - -#define PCI_DATA_TAG ' ICP' -#define PCI_DATA_VERSION 1 - -typedef struct _PCIBUSDATA { - ULONG Tag; - ULONG Version; - PciReadWriteConfig ReadConfig; - PciReadWriteConfig WriteConfig; - PciPin2Line Pin2Line; - PciLine2Pin Line2Pin; - PCI_SLOT_NUMBER ParentSlot; - PVOID Reserved[4]; -} PCIBUSDATA, *PPCIBUSDATA; - -#ifndef _PCIINTRF_X_ -#define _PCIINTRF_X_ - -typedef ULONG -(NTAPI *PCI_READ_WRITE_CONFIG)( - IN PVOID Context, - IN ULONG BusOffset, - IN ULONG Slot, - IN PVOID Buffer, - IN ULONG Offset, - IN ULONG Length); - -typedef VOID -(NTAPI *PCI_PIN_TO_LINE)( - IN PVOID Context, - IN PPCI_COMMON_CONFIG PciData); - -typedef VOID -(NTAPI *PCI_LINE_TO_PIN)( - IN PVOID Context, - IN PPCI_COMMON_CONFIG PciNewData, - IN PPCI_COMMON_CONFIG PciOldData); - -typedef VOID -(NTAPI *PCI_ROOT_BUS_CAPABILITY)( - IN PVOID Context, - OUT PPCI_ROOT_BUS_HARDWARE_CAPABILITY HardwareCapability); - -typedef VOID -(NTAPI *PCI_EXPRESS_WAKE_CONTROL)( - IN PVOID Context, - IN BOOLEAN EnableWake); - -typedef struct _PCI_BUS_INTERFACE_STANDARD { - USHORT Size; - USHORT Version; - PVOID Context; - PINTERFACE_REFERENCE InterfaceReference; - PINTERFACE_DEREFERENCE InterfaceDereference; - PCI_READ_WRITE_CONFIG ReadConfig; - PCI_READ_WRITE_CONFIG WriteConfig; - PCI_PIN_TO_LINE PinToLine; - PCI_LINE_TO_PIN LineToPin; - PCI_ROOT_BUS_CAPABILITY RootBusCapability; - PCI_EXPRESS_WAKE_CONTROL ExpressWakeControl; -} PCI_BUS_INTERFACE_STANDARD, *PPCI_BUS_INTERFACE_STANDARD; - -#define PCI_BUS_INTERFACE_STANDARD_VERSION 1 - -#endif /* _PCIINTRF_X_ */ - -#if (NTDDI_VERSION >= NTDDI_WIN7) - -#define FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL_EX 0x00004000 -#define FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL_EX 0x00008000 -#define FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK_EX \ - (FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL_EX | \ - FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL_EX) - -#define FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL_DEPRECATED 0x00000200 -#define FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL_DEPRECATED 0x00000300 -#define FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK_DEPRECATED 0x00000300 - -#else - -#define FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL 0x00000200 -#define FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL 0x00000300 -#define FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK 0x00000300 - -#define FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL_EX FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL -#define FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL_EX FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL -#define FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK_EX FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK - -#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ - -#define FILE_CHARACTERISTICS_PROPAGATED ( FILE_REMOVABLE_MEDIA | \ - FILE_READ_ONLY_DEVICE | \ - FILE_FLOPPY_DISKETTE | \ - FILE_WRITE_ONCE_MEDIA | \ - FILE_DEVICE_SECURE_OPEN ) - -typedef struct _FILE_ALIGNMENT_INFORMATION { - ULONG AlignmentRequirement; -} FILE_ALIGNMENT_INFORMATION, *PFILE_ALIGNMENT_INFORMATION; - -typedef struct _FILE_NAME_INFORMATION { - ULONG FileNameLength; - WCHAR FileName[1]; -} FILE_NAME_INFORMATION, *PFILE_NAME_INFORMATION; - - -typedef struct _FILE_ATTRIBUTE_TAG_INFORMATION { - ULONG FileAttributes; - ULONG ReparseTag; -} FILE_ATTRIBUTE_TAG_INFORMATION, *PFILE_ATTRIBUTE_TAG_INFORMATION; - -typedef struct _FILE_DISPOSITION_INFORMATION { - BOOLEAN DeleteFile; -} FILE_DISPOSITION_INFORMATION, *PFILE_DISPOSITION_INFORMATION; - -typedef struct _FILE_END_OF_FILE_INFORMATION { - LARGE_INTEGER EndOfFile; -} FILE_END_OF_FILE_INFORMATION, *PFILE_END_OF_FILE_INFORMATION; - -typedef struct _FILE_VALID_DATA_LENGTH_INFORMATION { - LARGE_INTEGER ValidDataLength; -} FILE_VALID_DATA_LENGTH_INFORMATION, *PFILE_VALID_DATA_LENGTH_INFORMATION; - -typedef struct _FILE_FS_LABEL_INFORMATION { - ULONG VolumeLabelLength; - WCHAR VolumeLabel[1]; -} FILE_FS_LABEL_INFORMATION, *PFILE_FS_LABEL_INFORMATION; - -typedef struct _FILE_FS_VOLUME_INFORMATION { - LARGE_INTEGER VolumeCreationTime; - ULONG VolumeSerialNumber; - ULONG VolumeLabelLength; - BOOLEAN SupportsObjects; - WCHAR VolumeLabel[1]; -} FILE_FS_VOLUME_INFORMATION, *PFILE_FS_VOLUME_INFORMATION; - -typedef struct _FILE_FS_SIZE_INFORMATION { - LARGE_INTEGER TotalAllocationUnits; - LARGE_INTEGER AvailableAllocationUnits; - ULONG SectorsPerAllocationUnit; - ULONG BytesPerSector; -} FILE_FS_SIZE_INFORMATION, *PFILE_FS_SIZE_INFORMATION; - -typedef struct _FILE_FS_FULL_SIZE_INFORMATION { - LARGE_INTEGER TotalAllocationUnits; - LARGE_INTEGER CallerAvailableAllocationUnits; - LARGE_INTEGER ActualAvailableAllocationUnits; - ULONG SectorsPerAllocationUnit; - ULONG BytesPerSector; -} FILE_FS_FULL_SIZE_INFORMATION, *PFILE_FS_FULL_SIZE_INFORMATION; - -typedef struct _FILE_FS_OBJECTID_INFORMATION { - UCHAR ObjectId[16]; - UCHAR ExtendedInfo[48]; -} FILE_FS_OBJECTID_INFORMATION, *PFILE_FS_OBJECTID_INFORMATION; - -typedef union _FILE_SEGMENT_ELEMENT { - PVOID64 Buffer; - ULONGLONG Alignment; -}FILE_SEGMENT_ELEMENT, *PFILE_SEGMENT_ELEMENT; - -#define IOCTL_AVIO_ALLOCATE_STREAM CTL_CODE(FILE_DEVICE_AVIO, 1, METHOD_BUFFERED, FILE_SPECIAL_ACCESS) -#define IOCTL_AVIO_FREE_STREAM CTL_CODE(FILE_DEVICE_AVIO, 2, METHOD_BUFFERED, FILE_SPECIAL_ACCESS) -#define IOCTL_AVIO_MODIFY_STREAM CTL_CODE(FILE_DEVICE_AVIO, 3, METHOD_BUFFERED, FILE_SPECIAL_ACCESS) - -typedef enum _BUS_DATA_TYPE { - ConfigurationSpaceUndefined = -1, - Cmos, - EisaConfiguration, - Pos, - CbusConfiguration, - PCIConfiguration, - VMEConfiguration, - NuBusConfiguration, - PCMCIAConfiguration, - MPIConfiguration, - MPSAConfiguration, - PNPISAConfiguration, - SgiInternalConfiguration, - MaximumBusDataType -} BUS_DATA_TYPE, *PBUS_DATA_TYPE; - -/* Hardware Abstraction Layer Types */ - -typedef BOOLEAN -(NTAPI *PHAL_RESET_DISPLAY_PARAMETERS)( - IN ULONG Columns, - IN ULONG Rows); - -typedef PBUS_HANDLER -(FASTCALL *pHalHandlerForBus)( - IN INTERFACE_TYPE InterfaceType, - IN ULONG BusNumber); - -typedef VOID -(FASTCALL *pHalReferenceBusHandler)( - IN PBUS_HANDLER BusHandler); - typedef enum _HAL_QUERY_INFORMATION_CLASS { HalInstalledBusInformation, HalProfileSourceInformation, @@ -1307,18 +353,92 @@ typedef enum _HAL_SET_INFORMATION_CLASS { HalProfileDpgoSourceInterruptHandler } HAL_SET_INFORMATION_CLASS, *PHAL_SET_INFORMATION_CLASS; -typedef NTSTATUS -(NTAPI *pHalQuerySystemInformation)( - IN HAL_QUERY_INFORMATION_CLASS InformationClass, - IN ULONG BufferSize, - IN OUT PVOID Buffer, - OUT PULONG ReturnedLength); +typedef struct _HAL_PROFILE_SOURCE_INTERVAL { + KPROFILE_SOURCE Source; + ULONG_PTR Interval; +} HAL_PROFILE_SOURCE_INTERVAL, *PHAL_PROFILE_SOURCE_INTERVAL; + +typedef struct _HAL_PROFILE_SOURCE_INFORMATION { + KPROFILE_SOURCE Source; + BOOLEAN Supported; + ULONG Interval; +} HAL_PROFILE_SOURCE_INFORMATION, *PHAL_PROFILE_SOURCE_INFORMATION; + +typedef struct _MAP_REGISTER_ENTRY { + PVOID MapRegister; + BOOLEAN WriteToDevice; +} MAP_REGISTER_ENTRY, *PMAP_REGISTER_ENTRY; + +typedef struct _DEBUG_DEVICE_ADDRESS { + UCHAR Type; + BOOLEAN Valid; + UCHAR Reserved[2]; + PUCHAR TranslatedAddress; + ULONG Length; +} DEBUG_DEVICE_ADDRESS, *PDEBUG_DEVICE_ADDRESS; + +typedef struct _DEBUG_MEMORY_REQUIREMENTS { + PHYSICAL_ADDRESS Start; + PHYSICAL_ADDRESS MaxEnd; + PVOID VirtualAddress; + ULONG Length; + BOOLEAN Cached; + BOOLEAN Aligned; +} DEBUG_MEMORY_REQUIREMENTS, *PDEBUG_MEMORY_REQUIREMENTS; + +typedef struct _DEBUG_DEVICE_DESCRIPTOR { + ULONG Bus; + ULONG Slot; + USHORT Segment; + USHORT VendorID; + USHORT DeviceID; + UCHAR BaseClass; + UCHAR SubClass; + UCHAR ProgIf; + BOOLEAN Initialized; + BOOLEAN Configured; + DEBUG_DEVICE_ADDRESS BaseAddress[6]; + DEBUG_MEMORY_REQUIREMENTS Memory; +} DEBUG_DEVICE_DESCRIPTOR, *PDEBUG_DEVICE_DESCRIPTOR; + +typedef struct _PM_DISPATCH_TABLE { + ULONG Signature; + ULONG Version; + PVOID Function[1]; +} PM_DISPATCH_TABLE, *PPM_DISPATCH_TABLE; + +typedef enum _RESOURCE_TRANSLATION_DIRECTION { + TranslateChildToParent, + TranslateParentToChild +} RESOURCE_TRANSLATION_DIRECTION; typedef NTSTATUS -(NTAPI *pHalSetSystemInformation)( - IN HAL_SET_INFORMATION_CLASS InformationClass, - IN ULONG BufferSize, - IN PVOID Buffer); +(NTAPI *PTRANSLATE_RESOURCE_HANDLER)( + IN OUT PVOID Context, + IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Source, + IN RESOURCE_TRANSLATION_DIRECTION Direction, + IN ULONG AlternativesCount OPTIONAL, + IN IO_RESOURCE_DESCRIPTOR Alternatives[], + IN PDEVICE_OBJECT PhysicalDeviceObject, + OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR Target); + +typedef NTSTATUS +(NTAPI *PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER)( + IN PVOID Context OPTIONAL, + IN PIO_RESOURCE_DESCRIPTOR Source, + IN PDEVICE_OBJECT PhysicalDeviceObject, + OUT PULONG TargetCount, + OUT PIO_RESOURCE_DESCRIPTOR *Target); + +typedef struct _TRANSLATOR_INTERFACE { + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; + PTRANSLATE_RESOURCE_HANDLER TranslateResources; + PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER TranslateResourceRequirements; +} TRANSLATOR_INTERFACE, *PTRANSLATOR_INTERFACE; typedef VOID (FASTCALL *pHalExamineMBR)( @@ -1349,6 +469,28 @@ typedef NTSTATUS IN ULONG NumberOfHeads, IN struct _DRIVE_LAYOUT_INFORMATION *PartitionBuffer); +typedef PBUS_HANDLER +(FASTCALL *pHalHandlerForBus)( + IN INTERFACE_TYPE InterfaceType, + IN ULONG BusNumber); + +typedef VOID +(FASTCALL *pHalReferenceBusHandler)( + IN PBUS_HANDLER BusHandler); + +typedef NTSTATUS +(NTAPI *pHalQuerySystemInformation)( + IN HAL_QUERY_INFORMATION_CLASS InformationClass, + IN ULONG BufferSize, + IN OUT PVOID Buffer, + OUT PULONG ReturnedLength); + +typedef NTSTATUS +(NTAPI *pHalSetSystemInformation)( + IN HAL_SET_INFORMATION_CLASS InformationClass, + IN ULONG BufferSize, + IN PVOID Buffer); + typedef NTSTATUS (NTAPI *pHalQueryBusSlots)( IN PBUS_HANDLER BusHandler, @@ -1360,12 +502,6 @@ typedef NTSTATUS (NTAPI *pHalInitPnpDriver)( VOID); -typedef struct _PM_DISPATCH_TABLE { - ULONG Signature; - ULONG Version; - PVOID Function[1]; -} PM_DISPATCH_TABLE, *PPM_DISPATCH_TABLE; - typedef NTSTATUS (NTAPI *pHalInitPowerManagement)( IN PPM_DISPATCH_TABLE PmDriverDispatchTable, @@ -1405,7 +541,12 @@ typedef NTSTATUS IN PHYSICAL_ADDRESS PhysicalAddress, IN LARGE_INTEGER NumberOfBytes); -typedef BOOLEAN +typedef VOID +(NTAPI *pHalEndOfBoot)( + VOID); + +typedef +BOOLEAN (NTAPI *pHalTranslateBusAddress)( IN INTERFACE_TYPE InterfaceType, IN ULONG BusNumber, @@ -1413,7 +554,8 @@ typedef BOOLEAN IN OUT PULONG AddressSpace, OUT PPHYSICAL_ADDRESS TranslatedAddress); -typedef NTSTATUS +typedef +NTSTATUS (NTAPI *pHalAssignSlotResources)( IN PUNICODE_STRING RegistryPath, IN PUNICODE_STRING DriverClassName OPTIONAL, @@ -1424,24 +566,23 @@ typedef NTSTATUS IN ULONG SlotNumber, IN OUT PCM_RESOURCE_LIST *AllocatedResources); -typedef VOID +typedef +VOID (NTAPI *pHalHaltSystem)( VOID); -typedef BOOLEAN +typedef +BOOLEAN (NTAPI *pHalResetDisplay)( VOID); -typedef struct _MAP_REGISTER_ENTRY { - PVOID MapRegister; - BOOLEAN WriteToDevice; -} MAP_REGISTER_ENTRY, *PMAP_REGISTER_ENTRY; - -typedef UCHAR +typedef +UCHAR (NTAPI *pHalVectorToIDTEntry)( ULONG Vector); -typedef BOOLEAN +typedef +BOOLEAN (NTAPI *pHalFindBusAddressTranslation)( IN PHYSICAL_ADDRESS BusAddress, IN OUT PULONG AddressSpace, @@ -1449,33 +590,94 @@ typedef BOOLEAN IN OUT PULONG_PTR Context, IN BOOLEAN NextBus); -typedef VOID -(NTAPI *pHalEndOfBoot)( - VOID); +typedef +NTSTATUS +(NTAPI *pKdSetupPciDeviceForDebugging)( + IN PVOID LoaderBlock OPTIONAL, + IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice); -typedef PVOID +typedef +NTSTATUS +(NTAPI *pKdReleasePciDeviceForDebugging)( + IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice); + +typedef +PVOID +(NTAPI *pKdGetAcpiTablePhase0)( + IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock, + IN ULONG Signature); + +typedef +PVOID (NTAPI *pHalGetAcpiTable)( IN ULONG Signature, IN PCSTR OemId OPTIONAL, IN PCSTR OemTableId OPTIONAL); + +typedef +VOID +(NTAPI *pKdCheckPowerButton)( + VOID); -#if defined(_IA64_) -typedef NTSTATUS -(*pHalGetErrorCapList)( - IN OUT PULONG CapsListLength, - IN OUT PUCHAR ErrorCapList); +#if (NTDDI_VERSION >= NTDDI_VISTA) +typedef +PVOID +(NTAPI *pKdMapPhysicalMemory64)( + IN PHYSICAL_ADDRESS PhysicalAddress, + IN ULONG NumberPages, + IN BOOLEAN FlushCurrentTLB); -typedef NTSTATUS -(*pHalInjectError)( - IN ULONG BufferLength, - IN PUCHAR Buffer); +typedef +VOID +(NTAPI *pKdUnmapVirtualAddress)( + IN PVOID VirtualAddress, + IN ULONG NumberPages, + IN BOOLEAN FlushCurrentTLB); +#else +typedef +PVOID +(NTAPI *pKdMapPhysicalMemory64)( + IN PHYSICAL_ADDRESS PhysicalAddress, + IN ULONG NumberPages); + +typedef +VOID +(NTAPI *pKdUnmapVirtualAddress)( + IN PVOID VirtualAddress, + IN ULONG NumberPages); #endif -typedef VOID + +typedef +ULONG +(NTAPI *pKdGetPciDataByOffset)( + IN ULONG BusNumber, + IN ULONG SlotNumber, + OUT PVOID Buffer, + IN ULONG Offset, + IN ULONG Length); + +typedef +ULONG +(NTAPI *pKdSetPciDataByOffset)( + IN ULONG BusNumber, + IN ULONG SlotNumber, + IN PVOID Buffer, + IN ULONG Offset, + IN ULONG Length); + +typedef BOOLEAN +(NTAPI *PHAL_RESET_DISPLAY_PARAMETERS)( + IN ULONG Columns, + IN ULONG Rows); + +typedef +VOID (NTAPI *PCI_ERROR_HANDLER_CALLBACK)( VOID); -typedef VOID +typedef +VOID (NTAPI *pHalSetPciErrorHandlerCallback)( IN PCI_ERROR_HANDLER_CALLBACK Callback); @@ -1549,706 +751,78 @@ extern NTKERNELAPI HAL_DISPATCH HalDispatchTable; #define HalMirrorPhysicalMemory HALDISPATCH->HalMirrorPhysicalMemory #define HalEndOfBoot HALDISPATCH->HalEndOfBoot #define HalMirrorVerify HALDISPATCH->HalMirrorVerify -#define HalGetCachedAcpiTable HALDISPATCH->HalGetCachedAcpiTable -#define HalSetPciErrorHandlerCallback HALDISPATCH->HalSetPciErrorHandlerCallback -#if defined(_IA64_) -#define HalGetErrorCapList HALDISPATCH->HalGetErrorCapList -#define HalInjectError HALDISPATCH->HalInjectError + +typedef struct _FILE_ALIGNMENT_INFORMATION { + ULONG AlignmentRequirement; +} FILE_ALIGNMENT_INFORMATION, *PFILE_ALIGNMENT_INFORMATION; + +typedef struct _FILE_NAME_INFORMATION { + ULONG FileNameLength; + WCHAR FileName[1]; +} FILE_NAME_INFORMATION, *PFILE_NAME_INFORMATION; + + +typedef struct _FILE_ATTRIBUTE_TAG_INFORMATION { + ULONG FileAttributes; + ULONG ReparseTag; +} FILE_ATTRIBUTE_TAG_INFORMATION, *PFILE_ATTRIBUTE_TAG_INFORMATION; + +typedef struct _FILE_DISPOSITION_INFORMATION { + BOOLEAN DeleteFile; +} FILE_DISPOSITION_INFORMATION, *PFILE_DISPOSITION_INFORMATION; + +typedef struct _FILE_END_OF_FILE_INFORMATION { + LARGE_INTEGER EndOfFile; +} FILE_END_OF_FILE_INFORMATION, *PFILE_END_OF_FILE_INFORMATION; + +typedef struct _FILE_VALID_DATA_LENGTH_INFORMATION { + LARGE_INTEGER ValidDataLength; +} FILE_VALID_DATA_LENGTH_INFORMATION, *PFILE_VALID_DATA_LENGTH_INFORMATION; + +typedef union _FILE_SEGMENT_ELEMENT { + PVOID64 Buffer; + ULONGLONG Alignment; +}FILE_SEGMENT_ELEMENT, *PFILE_SEGMENT_ELEMENT; + +#define SE_UNSOLICITED_INPUT_PRIVILEGE 6 + +#if (NTDDI_VERSION >= NTDDI_WIN2K) +NTSYSAPI +ULONGLONG +NTAPI +VerSetConditionMask( + IN ULONGLONG ConditionMask, + IN ULONG TypeMask, + IN UCHAR Condition); #endif -typedef struct _HAL_BUS_INFORMATION { - INTERFACE_TYPE BusType; - BUS_DATA_TYPE ConfigurationType; - ULONG BusNumber; - ULONG Reserved; -} HAL_BUS_INFORMATION, *PHAL_BUS_INFORMATION; - -typedef struct _HAL_PROFILE_SOURCE_INFORMATION { - KPROFILE_SOURCE Source; - BOOLEAN Supported; - ULONG Interval; -} HAL_PROFILE_SOURCE_INFORMATION, *PHAL_PROFILE_SOURCE_INFORMATION; - -typedef struct _HAL_PROFILE_SOURCE_INFORMATION_EX { - KPROFILE_SOURCE Source; - BOOLEAN Supported; - ULONG_PTR Interval; - ULONG_PTR DefInterval; - ULONG_PTR MaxInterval; - ULONG_PTR MinInterval; -} HAL_PROFILE_SOURCE_INFORMATION_EX, *PHAL_PROFILE_SOURCE_INFORMATION_EX; - -typedef struct _HAL_PROFILE_SOURCE_INTERVAL { - KPROFILE_SOURCE Source; - ULONG_PTR Interval; -} HAL_PROFILE_SOURCE_INTERVAL, *PHAL_PROFILE_SOURCE_INTERVAL; - -typedef struct _HAL_PROFILE_SOURCE_LIST { - KPROFILE_SOURCE Source; - PWSTR Description; -} HAL_PROFILE_SOURCE_LIST, *PHAL_PROFILE_SOURCE_LIST; - -typedef enum _HAL_DISPLAY_BIOS_INFORMATION { - HalDisplayInt10Bios, - HalDisplayEmulatedBios, - HalDisplayNoBios -} HAL_DISPLAY_BIOS_INFORMATION, *PHAL_DISPLAY_BIOS_INFORMATION; - -typedef struct _HAL_POWER_INFORMATION { - ULONG TBD; -} HAL_POWER_INFORMATION, *PHAL_POWER_INFORMATION; - -typedef struct _HAL_PROCESSOR_SPEED_INFO { - ULONG ProcessorSpeed; -} HAL_PROCESSOR_SPEED_INFORMATION, *PHAL_PROCESSOR_SPEED_INFORMATION; - -typedef struct _HAL_CALLBACKS { - PCALLBACK_OBJECT SetSystemInformation; - PCALLBACK_OBJECT BusCheck; -} HAL_CALLBACKS, *PHAL_CALLBACKS; - -typedef struct _HAL_PROCESSOR_FEATURE { - ULONG UsableFeatureBits; -} HAL_PROCESSOR_FEATURE; - -typedef NTSTATUS -(NTAPI *PHALIOREADWRITEHANDLER)( - IN BOOLEAN fRead, - IN ULONG dwAddr, - IN ULONG dwSize, - IN OUT PULONG pdwData); - -typedef struct _HAL_AMLI_BAD_IO_ADDRESS_LIST { - ULONG BadAddrBegin; - ULONG BadAddrSize; - ULONG OSVersionTrigger; - PHALIOREADWRITEHANDLER IOHandler; -} HAL_AMLI_BAD_IO_ADDRESS_LIST, *PHAL_AMLI_BAD_IO_ADDRESS_LIST; - -#if defined(_X86_) || defined(_IA64_) || defined(_AMD64_) - -typedef VOID -(NTAPI *PHALMCAINTERFACELOCK)( - VOID); - -typedef VOID -(NTAPI *PHALMCAINTERFACEUNLOCK)( - VOID); - -typedef NTSTATUS -(NTAPI *PHALMCAINTERFACEREADREGISTER)( - IN UCHAR BankNumber, - IN OUT PVOID Exception); - -typedef struct _HAL_MCA_INTERFACE { - PHALMCAINTERFACELOCK Lock; - PHALMCAINTERFACEUNLOCK Unlock; - PHALMCAINTERFACEREADREGISTER ReadRegister; -} HAL_MCA_INTERFACE; - -typedef enum { - ApicDestinationModePhysical = 1, - ApicDestinationModeLogicalFlat, - ApicDestinationModeLogicalClustered, - ApicDestinationModeUnknown -} HAL_APIC_DESTINATION_MODE, *PHAL_APIC_DESTINATION_MODE; - -#if defined(_AMD64_) - -struct _KTRAP_FRAME; -struct _KEXCEPTION_FRAME; - -typedef ERROR_SEVERITY -(NTAPI *PDRIVER_EXCPTN_CALLBACK)( - IN PVOID Context, - IN struct _KTRAP_FRAME *TrapFrame, - IN struct _KEXCEPTION_FRAME *ExceptionFrame, - IN PMCA_EXCEPTION Exception); - -#endif - -#if defined(_X86_) || defined(_IA64_) -typedef -#if defined(_IA64_) -ERROR_SEVERITY -#else -VOID -#endif -(NTAPI *PDRIVER_EXCPTN_CALLBACK)( - IN PVOID Context, - IN PMCA_EXCEPTION BankLog); -#endif - -typedef PDRIVER_EXCPTN_CALLBACK PDRIVER_MCA_EXCEPTION_CALLBACK; - -typedef struct _MCA_DRIVER_INFO { - PDRIVER_MCA_EXCEPTION_CALLBACK ExceptionCallback; - PKDEFERRED_ROUTINE DpcCallback; - PVOID DeviceContext; -} MCA_DRIVER_INFO, *PMCA_DRIVER_INFO; - -typedef struct _HAL_ERROR_INFO { - ULONG Version; - ULONG InitMaxSize; - ULONG McaMaxSize; - ULONG McaPreviousEventsCount; - ULONG McaCorrectedEventsCount; - ULONG McaKernelDeliveryFails; - ULONG McaDriverDpcQueueFails; - ULONG McaReserved; - ULONG CmcMaxSize; - ULONG CmcPollingInterval; - ULONG CmcInterruptsCount; - ULONG CmcKernelDeliveryFails; - ULONG CmcDriverDpcQueueFails; - ULONG CmcGetStateFails; - ULONG CmcClearStateFails; - ULONG CmcReserved; - ULONGLONG CmcLogId; - ULONG CpeMaxSize; - ULONG CpePollingInterval; - ULONG CpeInterruptsCount; - ULONG CpeKernelDeliveryFails; - ULONG CpeDriverDpcQueueFails; - ULONG CpeGetStateFails; - ULONG CpeClearStateFails; - ULONG CpeInterruptSources; - ULONGLONG CpeLogId; - ULONGLONG KernelReserved[4]; -} HAL_ERROR_INFO, *PHAL_ERROR_INFO; - -#define HAL_MCE_INTERRUPTS_BASED ((ULONG)-1) -#define HAL_MCE_DISABLED ((ULONG)0) - -#define HAL_CMC_INTERRUPTS_BASED HAL_MCE_INTERRUPTS_BASED -#define HAL_CMC_DISABLED HAL_MCE_DISABLED - -#define HAL_CPE_INTERRUPTS_BASED HAL_MCE_INTERRUPTS_BASED -#define HAL_CPE_DISABLED HAL_MCE_DISABLED - -#define HAL_MCA_INTERRUPTS_BASED HAL_MCE_INTERRUPTS_BASED -#define HAL_MCA_DISABLED HAL_MCE_DISABLED - -typedef VOID -(NTAPI *PDRIVER_CMC_EXCEPTION_CALLBACK)( - IN PVOID Context, - IN PCMC_EXCEPTION CmcLog); - -typedef VOID -(NTAPI *PDRIVER_CPE_EXCEPTION_CALLBACK)( - IN PVOID Context, - IN PCPE_EXCEPTION CmcLog); - -typedef struct _CMC_DRIVER_INFO { - PDRIVER_CMC_EXCEPTION_CALLBACK ExceptionCallback; - PKDEFERRED_ROUTINE DpcCallback; - PVOID DeviceContext; -} CMC_DRIVER_INFO, *PCMC_DRIVER_INFO; - -typedef struct _CPE_DRIVER_INFO { - PDRIVER_CPE_EXCEPTION_CALLBACK ExceptionCallback; - PKDEFERRED_ROUTINE DpcCallback; - PVOID DeviceContext; -} CPE_DRIVER_INFO, *PCPE_DRIVER_INFO; - -#endif // defined(_X86_) || defined(_IA64_) || defined(_AMD64_) - -#if defined(_IA64_) - -typedef NTSTATUS -(*HALSENDCROSSPARTITIONIPI)( - IN USHORT ProcessorID, - IN UCHAR HardwareVector); - -typedef NTSTATUS -(*HALRESERVECROSSPARTITIONINTERRUPTVECTOR)( - OUT PULONG Vector, - OUT PKIRQL Irql, - IN OUT PGROUP_AFFINITY Affinity, - OUT PUCHAR HardwareVector); - -typedef VOID -(*HALFREECROSSPARTITIONINTERRUPTVECTOR)( - IN ULONG Vector, - IN PGROUP_AFFINITY Affinity); - -typedef struct _HAL_CROSS_PARTITION_IPI_INTERFACE { - HALSENDCROSSPARTITIONIPI HalSendCrossPartitionIpi; - HALRESERVECROSSPARTITIONINTERRUPTVECTOR HalReserveCrossPartitionInterruptVector; - HALFREECROSSPARTITIONINTERRUPTVECTOR HalFreeCrossPartitionInterruptVector; -} HAL_CROSS_PARTITION_IPI_INTERFACE; - -#define HAL_CROSS_PARTITION_IPI_INTERFACE_MINIMUM_SIZE \ - FIELD_OFFSET(HAL_CROSS_PARTITION_IPI_INTERFACE, \ - HalFreeCrossPartitionInterruptVector) - -#endif /* defined(_IA64_) */ - -typedef struct _HAL_PLATFORM_INFORMATION { - ULONG PlatformFlags; -} HAL_PLATFORM_INFORMATION, *PHAL_PLATFORM_INFORMATION; - -#define HAL_PLATFORM_DISABLE_WRITE_COMBINING 0x01L -#define HAL_PLATFORM_DISABLE_PTCG 0x04L -#define HAL_PLATFORM_DISABLE_UC_MAIN_MEMORY 0x08L -#define HAL_PLATFORM_ENABLE_WRITE_COMBINING_MMIO 0x10L -#define HAL_PLATFORM_ACPI_TABLES_CACHED 0x20L - -/****************************************************************************** - * Kernel Types * - ******************************************************************************/ - -#define NX_SUPPORT_POLICY_ALWAYSOFF 0 -#define NX_SUPPORT_POLICY_ALWAYSON 1 -#define NX_SUPPORT_POLICY_OPTIN 2 -#define NX_SUPPORT_POLICY_OPTOUT 3 - -typedef VOID -(NTAPI *PEXPAND_STACK_CALLOUT)( - IN PVOID Parameter OPTIONAL); - -typedef VOID -(NTAPI *PTIMER_APC_ROUTINE)( - IN PVOID TimerContext, - IN ULONG TimerLowValue, - IN LONG TimerHighValue); - -typedef enum _TIMER_SET_INFORMATION_CLASS { - TimerSetCoalescableTimer, - MaxTimerInfoClass -} TIMER_SET_INFORMATION_CLASS; - -#if (NTDDI_VERSION >= NTDDI_WIN7) -typedef struct _TIMER_SET_COALESCABLE_TIMER_INFO { - IN LARGE_INTEGER DueTime; - IN PTIMER_APC_ROUTINE TimerApcRoutine OPTIONAL; - IN PVOID TimerContext OPTIONAL; - IN struct _COUNTED_REASON_CONTEXT *WakeContext OPTIONAL; - IN ULONG Period OPTIONAL; - IN ULONG TolerableDelay; - OUT PBOOLEAN PreviousState OPTIONAL; -} TIMER_SET_COALESCABLE_TIMER_INFO, *PTIMER_SET_COALESCABLE_TIMER_INFO; -#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ - -#define XSTATE_LEGACY_FLOATING_POINT 0 -#define XSTATE_LEGACY_SSE 1 -#define XSTATE_GSSE 2 - -#define XSTATE_MASK_LEGACY_FLOATING_POINT (1i64 << (XSTATE_LEGACY_FLOATING_POINT)) -#define XSTATE_MASK_LEGACY_SSE (1i64 << (XSTATE_LEGACY_SSE)) -#define XSTATE_MASK_LEGACY (XSTATE_MASK_LEGACY_FLOATING_POINT | XSTATE_MASK_LEGACY_SSE) -#define XSTATE_MASK_GSSE (1i64 << (XSTATE_GSSE)) - -#define MAXIMUM_XSTATE_FEATURES 64 - -typedef struct _XSTATE_FEATURE { - ULONG Offset; - ULONG Size; -} XSTATE_FEATURE, *PXSTATE_FEATURE; - -typedef struct _XSTATE_CONFIGURATION { - ULONG64 EnabledFeatures; - ULONG Size; - ULONG OptimizedSave:1; - XSTATE_FEATURE Features[MAXIMUM_XSTATE_FEATURES]; -} XSTATE_CONFIGURATION, *PXSTATE_CONFIGURATION; - -#define MAX_WOW64_SHARED_ENTRIES 16 - -typedef struct _KUSER_SHARED_DATA { - ULONG TickCountLowDeprecated; - ULONG TickCountMultiplier; - volatile KSYSTEM_TIME InterruptTime; - volatile KSYSTEM_TIME SystemTime; - volatile KSYSTEM_TIME TimeZoneBias; - USHORT ImageNumberLow; - USHORT ImageNumberHigh; - WCHAR NtSystemRoot[260]; - ULONG MaxStackTraceDepth; - ULONG CryptoExponent; - ULONG TimeZoneId; - ULONG LargePageMinimum; - ULONG Reserved2[7]; - NT_PRODUCT_TYPE NtProductType; - BOOLEAN ProductTypeIsValid; - ULONG NtMajorVersion; - ULONG NtMinorVersion; - BOOLEAN ProcessorFeatures[PROCESSOR_FEATURE_MAX]; - ULONG Reserved1; - ULONG Reserved3; - volatile ULONG TimeSlip; - ALTERNATIVE_ARCHITECTURE_TYPE AlternativeArchitecture; - ULONG AltArchitecturePad[1]; - LARGE_INTEGER SystemExpirationDate; - ULONG SuiteMask; - BOOLEAN KdDebuggerEnabled; -#if (NTDDI_VERSION >= NTDDI_WINXPSP2) - UCHAR NXSupportPolicy; -#endif - volatile ULONG ActiveConsoleId; - volatile ULONG DismountCount; - ULONG ComPlusPackage; - ULONG LastSystemRITEventTickCount; - ULONG NumberOfPhysicalPages; - BOOLEAN SafeBootMode; -#if (NTDDI_VERSION >= NTDDI_WIN7) - union { - UCHAR TscQpcData; - struct { - UCHAR TscQpcEnabled:1; - UCHAR TscQpcSpareFlag:1; - UCHAR TscQpcShift:6; - } DUMMYSTRUCTNAME; - } DUMMYUNIONNAME; - UCHAR TscQpcPad[2]; -#endif -#if (NTDDI_VERSION >= NTDDI_VISTA) - union { - ULONG SharedDataFlags; - struct { - ULONG DbgErrorPortPresent:1; - ULONG DbgElevationEnabled:1; - ULONG DbgVirtEnabled:1; - ULONG DbgInstallerDetectEnabled:1; - ULONG DbgSystemDllRelocated:1; - ULONG DbgDynProcessorEnabled:1; - ULONG DbgSEHValidationEnabled:1; - ULONG SpareBits:25; - } DUMMYSTRUCTNAME2; - } DUMMYUNIONNAME2; -#else - ULONG TraceLogging; -#endif - ULONG DataFlagsPad[1]; - ULONGLONG TestRetInstruction; - ULONG SystemCall; - ULONG SystemCallReturn; - ULONGLONG SystemCallPad[3]; - _ANONYMOUS_UNION union { - volatile KSYSTEM_TIME TickCount; - volatile ULONG64 TickCountQuad; - _ANONYMOUS_STRUCT struct { - ULONG ReservedTickCountOverlay[3]; - ULONG TickCountPad[1]; - } DUMMYSTRUCTNAME; - } DUMMYUNIONNAME3; - ULONG Cookie; - ULONG CookiePad[1]; -#if (NTDDI_VERSION >= NTDDI_WS03) - LONGLONG ConsoleSessionForegroundProcessId; - ULONG Wow64SharedInformation[MAX_WOW64_SHARED_ENTRIES]; -#endif -#if (NTDDI_VERSION >= NTDDI_VISTA) -#if (NTDDI_VERSION >= NTDDI_WIN7) - USHORT UserModeGlobalLogger[16]; -#else - USHORT UserModeGlobalLogger[8]; - ULONG HeapTracingPid[2]; - ULONG CritSecTracingPid[2]; -#endif - ULONG ImageFileExecutionOptions; -#if (NTDDI_VERSION >= NTDDI_VISTASP1) - ULONG LangGenerationCount; -#else - /* 4 bytes padding */ -#endif - ULONGLONG Reserved5; - volatile ULONG64 InterruptTimeBias; -#endif -#if (NTDDI_VERSION >= NTDDI_WIN7) - volatile ULONG64 TscQpcBias; - volatile ULONG ActiveProcessorCount; - volatile USHORT ActiveGroupCount; - USHORT Reserved4; - volatile ULONG AitSamplingValue; - volatile ULONG AppCompatFlag; - ULONGLONG SystemDllNativeRelocation; - ULONG SystemDllWowRelocation; - ULONG XStatePad[1]; - XSTATE_CONFIGURATION XState; -#endif -} KUSER_SHARED_DATA, *PKUSER_SHARED_DATA; - -#if (NTDDI_VERSION >= NTDDI_VISTA) -extern NTSYSAPI volatile CCHAR KeNumberProcessors; -#elif (NTDDI_VERSION >= NTDDI_WINXP) -extern NTSYSAPI CCHAR KeNumberProcessors; -#else -extern PCCHAR KeNumberProcessors; -#endif - - -/****************************************************************************** - * Kernel Debugger Types * - ******************************************************************************/ -typedef struct _DEBUG_DEVICE_ADDRESS { - UCHAR Type; - BOOLEAN Valid; - UCHAR Reserved[2]; - PUCHAR TranslatedAddress; - ULONG Length; -} DEBUG_DEVICE_ADDRESS, *PDEBUG_DEVICE_ADDRESS; - -typedef struct _DEBUG_MEMORY_REQUIREMENTS { - PHYSICAL_ADDRESS Start; - PHYSICAL_ADDRESS MaxEnd; - PVOID VirtualAddress; - ULONG Length; - BOOLEAN Cached; - BOOLEAN Aligned; -} DEBUG_MEMORY_REQUIREMENTS, *PDEBUG_MEMORY_REQUIREMENTS; - -typedef struct _DEBUG_DEVICE_DESCRIPTOR { - ULONG Bus; - ULONG Slot; - USHORT Segment; - USHORT VendorID; - USHORT DeviceID; - UCHAR BaseClass; - UCHAR SubClass; - UCHAR ProgIf; - BOOLEAN Initialized; - BOOLEAN Configured; - DEBUG_DEVICE_ADDRESS BaseAddress[6]; - DEBUG_MEMORY_REQUIREMENTS Memory; -} DEBUG_DEVICE_DESCRIPTOR, *PDEBUG_DEVICE_DESCRIPTOR; - -typedef NTSTATUS -(NTAPI *pKdSetupPciDeviceForDebugging)( - IN PVOID LoaderBlock OPTIONAL, - IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice); - -typedef NTSTATUS -(NTAPI *pKdReleasePciDeviceForDebugging)( - IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice); - -typedef PVOID -(NTAPI *pKdGetAcpiTablePhase0)( - IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock, - IN ULONG Signature); - -typedef VOID -(NTAPI *pKdCheckPowerButton)( - VOID); - -#if (NTDDI_VERSION >= NTDDI_VISTA) -typedef PVOID -(NTAPI *pKdMapPhysicalMemory64)( - IN PHYSICAL_ADDRESS PhysicalAddress, - IN ULONG NumberPages, - IN BOOLEAN FlushCurrentTLB); - -typedef VOID -(NTAPI *pKdUnmapVirtualAddress)( - IN PVOID VirtualAddress, - IN ULONG NumberPages, - IN BOOLEAN FlushCurrentTLB); -#else -typedef PVOID -(NTAPI *pKdMapPhysicalMemory64)( - IN PHYSICAL_ADDRESS PhysicalAddress, - IN ULONG NumberPages); - -typedef VOID -(NTAPI *pKdUnmapVirtualAddress)( - IN PVOID VirtualAddress, - IN ULONG NumberPages); -#endif - -typedef ULONG -(NTAPI *pKdGetPciDataByOffset)( - IN ULONG BusNumber, - IN ULONG SlotNumber, - OUT PVOID Buffer, - IN ULONG Offset, - IN ULONG Length); - -typedef ULONG -(NTAPI *pKdSetPciDataByOffset)( - IN ULONG BusNumber, - IN ULONG SlotNumber, - IN PVOID Buffer, - IN ULONG Offset, - IN ULONG Length); -/****************************************************************************** - * Memory manager Types * - ******************************************************************************/ - -typedef struct _PHYSICAL_MEMORY_RANGE { - PHYSICAL_ADDRESS BaseAddress; - LARGE_INTEGER NumberOfBytes; -} PHYSICAL_MEMORY_RANGE, *PPHYSICAL_MEMORY_RANGE; - -typedef NTSTATUS -(NTAPI *PMM_ROTATE_COPY_CALLBACK_FUNCTION)( - IN PMDL DestinationMdl, - IN PMDL SourceMdl, - IN PVOID Context); - -typedef enum _MM_ROTATE_DIRECTION { - MmToFrameBuffer, - MmToFrameBufferNoCopy, - MmToRegularMemory, - MmToRegularMemoryNoCopy, - MmMaximumRotateDirection -} MM_ROTATE_DIRECTION, *PMM_ROTATE_DIRECTION; - - -/****************************************************************************** - * Process Manager Types * - ******************************************************************************/ - -#define QUOTA_LIMITS_HARDWS_MIN_ENABLE 0x00000001 -#define QUOTA_LIMITS_HARDWS_MIN_DISABLE 0x00000002 -#define QUOTA_LIMITS_HARDWS_MAX_ENABLE 0x00000004 -#define QUOTA_LIMITS_HARDWS_MAX_DISABLE 0x00000008 -#define QUOTA_LIMITS_USE_DEFAULT_LIMITS 0x00000010 - -typedef struct _QUOTA_LIMITS { - SIZE_T PagedPoolLimit; - SIZE_T NonPagedPoolLimit; - SIZE_T MinimumWorkingSetSize; - SIZE_T MaximumWorkingSetSize; - SIZE_T PagefileLimit; - LARGE_INTEGER TimeLimit; -} QUOTA_LIMITS, *PQUOTA_LIMITS; - -typedef union _RATE_QUOTA_LIMIT { - ULONG RateData; - struct { - ULONG RatePercent:7; - ULONG Reserved0:25; - } DUMMYSTRUCTNAME; -} RATE_QUOTA_LIMIT, *PRATE_QUOTA_LIMIT; - -typedef struct _QUOTA_LIMITS_EX { - SIZE_T PagedPoolLimit; - SIZE_T NonPagedPoolLimit; - SIZE_T MinimumWorkingSetSize; - SIZE_T MaximumWorkingSetSize; - SIZE_T PagefileLimit; - LARGE_INTEGER TimeLimit; - SIZE_T WorkingSetLimit; - SIZE_T Reserved2; - SIZE_T Reserved3; - SIZE_T Reserved4; - ULONG Flags; - RATE_QUOTA_LIMIT CpuRateLimit; -} QUOTA_LIMITS_EX, *PQUOTA_LIMITS_EX; - -typedef struct _IO_COUNTERS { - ULONGLONG ReadOperationCount; - ULONGLONG WriteOperationCount; - ULONGLONG OtherOperationCount; - ULONGLONG ReadTransferCount; - ULONGLONG WriteTransferCount; - ULONGLONG OtherTransferCount; -} IO_COUNTERS, *PIO_COUNTERS; - -typedef struct _VM_COUNTERS { - SIZE_T PeakVirtualSize; - SIZE_T VirtualSize; - ULONG PageFaultCount; - SIZE_T PeakWorkingSetSize; - SIZE_T WorkingSetSize; - SIZE_T QuotaPeakPagedPoolUsage; - SIZE_T QuotaPagedPoolUsage; - SIZE_T QuotaPeakNonPagedPoolUsage; - SIZE_T QuotaNonPagedPoolUsage; - SIZE_T PagefileUsage; - SIZE_T PeakPagefileUsage; -} VM_COUNTERS, *PVM_COUNTERS; - -typedef struct _VM_COUNTERS_EX { - SIZE_T PeakVirtualSize; - SIZE_T VirtualSize; - ULONG PageFaultCount; - SIZE_T PeakWorkingSetSize; - SIZE_T WorkingSetSize; - SIZE_T QuotaPeakPagedPoolUsage; - SIZE_T QuotaPagedPoolUsage; - SIZE_T QuotaPeakNonPagedPoolUsage; - SIZE_T QuotaNonPagedPoolUsage; - SIZE_T PagefileUsage; - SIZE_T PeakPagefileUsage; - SIZE_T PrivateUsage; -} VM_COUNTERS_EX, *PVM_COUNTERS_EX; - -#define MAX_HW_COUNTERS 16 -#define THREAD_PROFILING_FLAG_DISPATCH 0x00000001 - -typedef enum _HARDWARE_COUNTER_TYPE { - PMCCounter, - MaxHardwareCounterType -} HARDWARE_COUNTER_TYPE, *PHARDWARE_COUNTER_TYPE; - -typedef struct _HARDWARE_COUNTER { - HARDWARE_COUNTER_TYPE Type; - ULONG Reserved; - ULONG64 Index; -} HARDWARE_COUNTER, *PHARDWARE_COUNTER; - -typedef struct _POOLED_USAGE_AND_LIMITS { - SIZE_T PeakPagedPoolUsage; - SIZE_T PagedPoolUsage; - SIZE_T PagedPoolLimit; - SIZE_T PeakNonPagedPoolUsage; - SIZE_T NonPagedPoolUsage; - SIZE_T NonPagedPoolLimit; - SIZE_T PeakPagefileUsage; - SIZE_T PagefileUsage; - SIZE_T PagefileLimit; -} POOLED_USAGE_AND_LIMITS, *PPOOLED_USAGE_AND_LIMITS; - -typedef struct _PROCESS_ACCESS_TOKEN { - HANDLE Token; - HANDLE Thread; -} PROCESS_ACCESS_TOKEN, *PPROCESS_ACCESS_TOKEN; - -#define PROCESS_EXCEPTION_PORT_ALL_STATE_BITS 0x00000003UL -#define PROCESS_EXCEPTION_PORT_ALL_STATE_FLAGS ((ULONG_PTR)((1UL << PROCESS_EXCEPTION_PORT_ALL_STATE_BITS) - 1)) - -typedef struct _PROCESS_EXCEPTION_PORT { - IN HANDLE ExceptionPortHandle; - IN OUT ULONG StateFlags; -} PROCESS_EXCEPTION_PORT, *PPROCESS_EXCEPTION_PORT; - -typedef VOID -(NTAPI *PCREATE_PROCESS_NOTIFY_ROUTINE)( - IN HANDLE ParentId, - IN HANDLE ProcessId, - IN BOOLEAN Create); - -typedef struct _PS_CREATE_NOTIFY_INFO { - IN SIZE_T Size; - union { - IN ULONG Flags; - struct { - IN ULONG FileOpenNameAvailable:1; - IN ULONG Reserved:31; - }; - }; - IN HANDLE ParentProcessId; - IN CLIENT_ID CreatingThreadId; - IN OUT struct _FILE_OBJECT *FileObject; - IN PCUNICODE_STRING ImageFileName; - IN PCUNICODE_STRING CommandLine OPTIONAL; - IN OUT NTSTATUS CreationStatus; -} PS_CREATE_NOTIFY_INFO, *PPS_CREATE_NOTIFY_INFO; - -typedef VOID -(NTAPI *PCREATE_PROCESS_NOTIFY_ROUTINE_EX)( - IN OUT PEPROCESS Process, - IN HANDLE ProcessId, - IN PPS_CREATE_NOTIFY_INFO CreateInfo OPTIONAL); - -typedef VOID -(NTAPI *PCREATE_THREAD_NOTIFY_ROUTINE)( - IN HANDLE ProcessId, - IN HANDLE ThreadId, - IN BOOLEAN Create); - -#define IMAGE_ADDRESSING_MODE_32BIT 3 +#define VER_SET_CONDITION(ConditionMask, TypeBitMask, ComparisonType) \ + ((ConditionMask) = VerSetConditionMask((ConditionMask), \ + (TypeBitMask), (ComparisonType))) + +/* RtlVerifyVersionInfo() TypeMask */ + +#define VER_MINORVERSION 0x0000001 +#define VER_MAJORVERSION 0x0000002 +#define VER_BUILDNUMBER 0x0000004 +#define VER_PLATFORMID 0x0000008 +#define VER_SERVICEPACKMINOR 0x0000010 +#define VER_SERVICEPACKMAJOR 0x0000020 +#define VER_SUITENAME 0x0000040 +#define VER_PRODUCT_TYPE 0x0000080 + +/* RtlVerifyVersionInfo() ComparisonType */ + +#define VER_EQUAL 1 +#define VER_GREATER 2 +#define VER_GREATER_EQUAL 3 +#define VER_LESS 4 +#define VER_LESS_EQUAL 5 +#define VER_AND 6 +#define VER_OR 7 + +#define VER_CONDITION_MASK 7 +#define VER_NUM_BITS_PER_CONDITION_MASK 3 typedef struct _IMAGE_INFO { _ANONYMOUS_UNION union { @@ -2258,7 +832,7 @@ typedef struct _IMAGE_INFO { ULONG SystemModeImage:1; ULONG ImageMappedToAllPids:1; ULONG ExtendedInfoPresent:1; - ULONG Reserved:21; + ULONG Reserved:22; } DUMMYSTRUCTNAME; } DUMMYUNIONNAME; PVOID ImageBase; @@ -2267,24 +841,24 @@ typedef struct _IMAGE_INFO { ULONG ImageSectionNumber; } IMAGE_INFO, *PIMAGE_INFO; -typedef struct _IMAGE_INFO_EX { - SIZE_T Size; - IMAGE_INFO ImageInfo; - struct _FILE_OBJECT *FileObject; -} IMAGE_INFO_EX, *PIMAGE_INFO_EX; +#define IMAGE_ADDRESSING_MODE_32BIT 3 -typedef VOID -(NTAPI *PLOAD_IMAGE_NOTIFY_ROUTINE)( - IN PUNICODE_STRING FullImageName, - IN HANDLE ProcessId, - IN PIMAGE_INFO ImageInfo); - -#define THREAD_CSWITCH_PMU_DISABLE FALSE -#define THREAD_CSWITCH_PMU_ENABLE TRUE - -#define PROCESS_LUID_DOSDEVICES_ONLY 0x00000001 - -#define PROCESS_HANDLE_TRACING_MAX_STACKS 16 +typedef enum _BUS_DATA_TYPE { + ConfigurationSpaceUndefined = -1, + Cmos, + EisaConfiguration, + Pos, + CbusConfiguration, + PCIConfiguration, + VMEConfiguration, + NuBusConfiguration, + PCMCIAConfiguration, + MPIConfiguration, + MPSAConfiguration, + PNPISAConfiguration, + SgiInternalConfiguration, + MaximumBusDataType +} BUS_DATA_TYPE, *PBUS_DATA_TYPE; typedef struct _NT_TIB { struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList; @@ -2418,15 +992,6 @@ typedef enum _THREADINFOCLASS { MaxThreadInfoClass } THREADINFOCLASS; -typedef struct _PAGE_PRIORITY_INFORMATION { - ULONG PagePriority; -} PAGE_PRIORITY_INFORMATION, *PPAGE_PRIORITY_INFORMATION; - -typedef struct _PROCESS_WS_WATCH_INFORMATION { - PVOID FaultingPc; - PVOID FaultingVa; -} PROCESS_WS_WATCH_INFORMATION, *PPROCESS_WS_WATCH_INFORMATION; - typedef struct _PROCESS_BASIC_INFORMATION { NTSTATUS ExitStatus; struct _PEB *PebBaseAddress; @@ -2436,20 +1001,10 @@ typedef struct _PROCESS_BASIC_INFORMATION { ULONG_PTR InheritedFromUniqueProcessId; } PROCESS_BASIC_INFORMATION,*PPROCESS_BASIC_INFORMATION; -typedef struct _PROCESS_EXTENDED_BASIC_INFORMATION { - SIZE_T Size; - PROCESS_BASIC_INFORMATION BasicInfo; - union { - ULONG Flags; - struct { - ULONG IsProtectedProcess:1; - ULONG IsWow64Process:1; - ULONG IsProcessDeleting:1; - ULONG IsCrossSessionCreate:1; - ULONG SpareBits:28; - } DUMMYSTRUCTNAME; - } DUMMYUNIONNAME; -} PROCESS_EXTENDED_BASIC_INFORMATION, *PPROCESS_EXTENDED_BASIC_INFORMATION; +typedef struct _PROCESS_WS_WATCH_INFORMATION { + PVOID FaultingPc; + PVOID FaultingVa; +} PROCESS_WS_WATCH_INFORMATION, *PPROCESS_WS_WATCH_INFORMATION; typedef struct _PROCESS_DEVICEMAP_INFORMATION { __GNU_EXTENSION union { @@ -2463,263 +1018,514 @@ typedef struct _PROCESS_DEVICEMAP_INFORMATION { }; } PROCESS_DEVICEMAP_INFORMATION, *PPROCESS_DEVICEMAP_INFORMATION; -typedef struct _PROCESS_DEVICEMAP_INFORMATION_EX { - union { - struct { - HANDLE DirectoryHandle; - } Set; - struct { - ULONG DriveMap; - UCHAR DriveType[32]; - } Query; - } DUMMYUNIONNAME; - ULONG Flags; -} PROCESS_DEVICEMAP_INFORMATION_EX, *PPROCESS_DEVICEMAP_INFORMATION_EX; +typedef struct _KERNEL_USER_TIMES { + LARGE_INTEGER CreateTime; + LARGE_INTEGER ExitTime; + LARGE_INTEGER KernelTime; + LARGE_INTEGER UserTime; +} KERNEL_USER_TIMES, *PKERNEL_USER_TIMES; + +typedef struct _PROCESS_ACCESS_TOKEN { + HANDLE Token; + HANDLE Thread; +} PROCESS_ACCESS_TOKEN, *PPROCESS_ACCESS_TOKEN; typedef struct _PROCESS_SESSION_INFORMATION { ULONG SessionId; } PROCESS_SESSION_INFORMATION, *PPROCESS_SESSION_INFORMATION; -typedef struct _PROCESS_HANDLE_TRACING_ENABLE { - ULONG Flags; -} PROCESS_HANDLE_TRACING_ENABLE, *PPROCESS_HANDLE_TRACING_ENABLE; +typedef enum _IO_QUERY_DEVICE_DATA_FORMAT { + IoQueryDeviceIdentifier = 0, + IoQueryDeviceConfigurationData, + IoQueryDeviceComponentInformation, + IoQueryDeviceMaxData +} IO_QUERY_DEVICE_DATA_FORMAT, *PIO_QUERY_DEVICE_DATA_FORMAT; -typedef struct _PROCESS_HANDLE_TRACING_ENABLE_EX { - ULONG Flags; - ULONG TotalSlots; -} PROCESS_HANDLE_TRACING_ENABLE_EX, *PPROCESS_HANDLE_TRACING_ENABLE_EX; +typedef struct _DISK_SIGNATURE { + ULONG PartitionStyle; + _ANONYMOUS_UNION union { + struct { + ULONG Signature; + ULONG CheckSum; + } Mbr; + struct { + GUID DiskId; + } Gpt; + } DUMMYUNIONNAME; +} DISK_SIGNATURE, *PDISK_SIGNATURE; -typedef struct _PROCESS_HANDLE_TRACING_ENTRY { - HANDLE Handle; - CLIENT_ID ClientId; - ULONG Type; - PVOID Stacks[PROCESS_HANDLE_TRACING_MAX_STACKS]; -} PROCESS_HANDLE_TRACING_ENTRY, *PPROCESS_HANDLE_TRACING_ENTRY; +typedef ULONG_PTR +(NTAPI *PDRIVER_VERIFIER_THUNK_ROUTINE)( + IN PVOID Context); -typedef struct _PROCESS_HANDLE_TRACING_QUERY { - HANDLE Handle; - ULONG TotalTraces; - PROCESS_HANDLE_TRACING_ENTRY HandleTrace[1]; -} PROCESS_HANDLE_TRACING_QUERY, *PPROCESS_HANDLE_TRACING_QUERY; +typedef struct _DRIVER_VERIFIER_THUNK_PAIRS { + PDRIVER_VERIFIER_THUNK_ROUTINE PristineRoutine; + PDRIVER_VERIFIER_THUNK_ROUTINE NewRoutine; +} DRIVER_VERIFIER_THUNK_PAIRS, *PDRIVER_VERIFIER_THUNK_PAIRS; -extern NTKERNELAPI PEPROCESS PsInitialSystemProcess; - - -/****************************************************************************** - * Runtime Library Types * - ******************************************************************************/ - - - -#ifndef _RTL_RUN_ONCE_DEF -#define _RTL_RUN_ONCE_DEF - -#define RTL_RUN_ONCE_INIT {0} - -#define RTL_RUN_ONCE_CHECK_ONLY 0x00000001UL -#define RTL_RUN_ONCE_ASYNC 0x00000002UL -#define RTL_RUN_ONCE_INIT_FAILED 0x00000004UL - -#define RTL_RUN_ONCE_CTX_RESERVED_BITS 2 - -#define RTL_HASH_ALLOCATED_HEADER 0x00000001 - -#define RTL_HASH_RESERVED_SIGNATURE 0 - -/* RtlVerifyVersionInfo() ComparisonType */ - -#define VER_EQUAL 1 -#define VER_GREATER 2 -#define VER_GREATER_EQUAL 3 -#define VER_LESS 4 -#define VER_LESS_EQUAL 5 -#define VER_AND 6 -#define VER_OR 7 - -#define VER_CONDITION_MASK 7 -#define VER_NUM_BITS_PER_CONDITION_MASK 3 - -/* RtlVerifyVersionInfo() TypeMask */ - -#define VER_MINORVERSION 0x0000001 -#define VER_MAJORVERSION 0x0000002 -#define VER_BUILDNUMBER 0x0000004 -#define VER_PLATFORMID 0x0000008 -#define VER_SERVICEPACKMINOR 0x0000010 -#define VER_SERVICEPACKMAJOR 0x0000020 -#define VER_SUITENAME 0x0000040 -#define VER_PRODUCT_TYPE 0x0000080 - -#define VER_NT_WORKSTATION 0x0000001 -#define VER_NT_DOMAIN_CONTROLLER 0x0000002 -#define VER_NT_SERVER 0x0000003 - -#define VER_PLATFORM_WIN32s 0 -#define VER_PLATFORM_WIN32_WINDOWS 1 -#define VER_PLATFORM_WIN32_NT 2 - -typedef union _RTL_RUN_ONCE { - PVOID Ptr; -} RTL_RUN_ONCE, *PRTL_RUN_ONCE; - -typedef ULONG /* LOGICAL */ -(NTAPI *PRTL_RUN_ONCE_INIT_FN) ( - IN OUT PRTL_RUN_ONCE RunOnce, - IN OUT PVOID Parameter OPTIONAL, - IN OUT PVOID *Context OPTIONAL); - -#endif /* _RTL_RUN_ONCE_DEF */ - -typedef enum _TABLE_SEARCH_RESULT { - TableEmptyTree, - TableFoundNode, - TableInsertAsLeft, - TableInsertAsRight -} TABLE_SEARCH_RESULT; - -typedef enum _RTL_GENERIC_COMPARE_RESULTS { - GenericLessThan, - GenericGreaterThan, - GenericEqual -} RTL_GENERIC_COMPARE_RESULTS; - -// Forwarder -struct _RTL_AVL_TABLE; - -typedef RTL_GENERIC_COMPARE_RESULTS -(NTAPI *PRTL_AVL_COMPARE_ROUTINE) ( - IN struct _RTL_AVL_TABLE *Table, - IN PVOID FirstStruct, - IN PVOID SecondStruct); - -typedef PVOID -(NTAPI *PRTL_AVL_ALLOCATE_ROUTINE) ( - IN struct _RTL_AVL_TABLE *Table, - IN CLONG ByteSize); +#define DRIVER_VERIFIER_SPECIAL_POOLING 0x0001 +#define DRIVER_VERIFIER_FORCE_IRQL_CHECKING 0x0002 +#define DRIVER_VERIFIER_INJECT_ALLOCATION_FAILURES 0x0004 +#define DRIVER_VERIFIER_TRACK_POOL_ALLOCATIONS 0x0008 +#define DRIVER_VERIFIER_IO_CHECKING 0x0010 typedef VOID -(NTAPI *PRTL_AVL_FREE_ROUTINE) ( - IN struct _RTL_AVL_TABLE *Table, - IN PVOID Buffer); +(NTAPI *PTIMER_APC_ROUTINE)( + IN PVOID TimerContext, + IN ULONG TimerLowValue, + IN LONG TimerHighValue); -typedef NTSTATUS -(NTAPI *PRTL_AVL_MATCH_FUNCTION) ( - IN struct _RTL_AVL_TABLE *Table, - IN PVOID UserData, - IN PVOID MatchData); +typedef struct _KUSER_SHARED_DATA +{ + ULONG TickCountLowDeprecated; + ULONG TickCountMultiplier; + volatile KSYSTEM_TIME InterruptTime; + volatile KSYSTEM_TIME SystemTime; + volatile KSYSTEM_TIME TimeZoneBias; + USHORT ImageNumberLow; + USHORT ImageNumberHigh; + WCHAR NtSystemRoot[260]; + ULONG MaxStackTraceDepth; + ULONG CryptoExponent; + ULONG TimeZoneId; + ULONG LargePageMinimum; + ULONG Reserved2[7]; + NT_PRODUCT_TYPE NtProductType; + BOOLEAN ProductTypeIsValid; + ULONG NtMajorVersion; + ULONG NtMinorVersion; + BOOLEAN ProcessorFeatures[PROCESSOR_FEATURE_MAX]; + ULONG Reserved1; + ULONG Reserved3; + volatile ULONG TimeSlip; + ALTERNATIVE_ARCHITECTURE_TYPE AlternativeArchitecture; + ULONG AltArchitecturePad[1]; + LARGE_INTEGER SystemExpirationDate; + ULONG SuiteMask; + BOOLEAN KdDebuggerEnabled; +#if (NTDDI_VERSION >= NTDDI_WINXPSP2) + UCHAR NXSupportPolicy; +#endif + volatile ULONG ActiveConsoleId; + volatile ULONG DismountCount; + ULONG ComPlusPackage; + ULONG LastSystemRITEventTickCount; + ULONG NumberOfPhysicalPages; + BOOLEAN SafeBootMode; +#if (NTDDI_VERSION >= NTDDI_WIN7) + union { + UCHAR TscQpcData; + struct { + UCHAR TscQpcEnabled:1; + UCHAR TscQpcSpareFlag:1; + UCHAR TscQpcShift:6; + } DUMMYSTRUCTNAME; + } DUMMYUNIONNAME; + UCHAR TscQpcPad[2]; +#endif +#if (NTDDI_VERSION >= NTDDI_VISTA) + union { + ULONG SharedDataFlags; + struct { + ULONG DbgErrorPortPresent:1; + ULONG DbgElevationEnabled:1; + ULONG DbgVirtEnabled:1; + ULONG DbgInstallerDetectEnabled:1; + ULONG DbgSystemDllRelocated:1; + ULONG DbgDynProcessorEnabled:1; + ULONG DbgSEHValidationEnabled:1; + ULONG SpareBits:25; + } DUMMYSTRUCTNAME2; + } DUMMYUNIONNAME2; +#else + ULONG TraceLogging; +#endif + ULONG DataFlagsPad[1]; + ULONGLONG TestRetInstruction; + ULONG SystemCall; + ULONG SystemCallReturn; + ULONGLONG SystemCallPad[3]; + _ANONYMOUS_UNION union { + volatile KSYSTEM_TIME TickCount; + volatile ULONG64 TickCountQuad; + _ANONYMOUS_STRUCT struct { + ULONG ReservedTickCountOverlay[3]; + ULONG TickCountPad[1]; + } DUMMYSTRUCTNAME; + } DUMMYUNIONNAME3; + ULONG Cookie; + ULONG CookiePad[1]; +#if (NTDDI_VERSION >= NTDDI_WS03) + LONGLONG ConsoleSessionForegroundProcessId; + ULONG Wow64SharedInformation[MAX_WOW64_SHARED_ENTRIES]; +#endif +#if (NTDDI_VERSION >= NTDDI_VISTA) +#if (NTDDI_VERSION >= NTDDI_WIN7) + USHORT UserModeGlobalLogger[16]; +#else + USHORT UserModeGlobalLogger[8]; + ULONG HeapTracingPid[2]; + ULONG CritSecTracingPid[2]; +#endif + ULONG ImageFileExecutionOptions; +#if (NTDDI_VERSION >= NTDDI_VISTASP1) + ULONG LangGenerationCount; +#else + /* 4 bytes padding */ +#endif + ULONGLONG Reserved5; + volatile ULONG64 InterruptTimeBias; +#endif +#if (NTDDI_VERSION >= NTDDI_WIN7) + volatile ULONG64 TscQpcBias; + volatile ULONG ActiveProcessorCount; + volatile USHORT ActiveGroupCount; + USHORT Reserved4; + volatile ULONG AitSamplingValue; + volatile ULONG AppCompatFlag; + ULONGLONG SystemDllNativeRelocation; + ULONG SystemDllWowRelocation; + ULONG XStatePad[1]; + XSTATE_CONFIGURATION XState; +#endif +} KUSER_SHARED_DATA, *PKUSER_SHARED_DATA; -typedef struct _RTL_BALANCED_LINKS { - struct _RTL_BALANCED_LINKS *Parent; - struct _RTL_BALANCED_LINKS *LeftChild; - struct _RTL_BALANCED_LINKS *RightChild; - CHAR Balance; - UCHAR Reserved[3]; -} RTL_BALANCED_LINKS, *PRTL_BALANCED_LINKS; +extern NTKERNELAPI PVOID MmHighestUserAddress; +extern NTKERNELAPI PVOID MmSystemRangeStart; +extern NTKERNELAPI ULONG MmUserProbeAddress; -typedef struct _RTL_AVL_TABLE { - RTL_BALANCED_LINKS BalancedRoot; - PVOID OrderedPointer; - ULONG WhichOrderedElement; - ULONG NumberGenericTableElements; - ULONG DepthOfTree; - PRTL_BALANCED_LINKS RestartKey; - ULONG DeleteCount; - PRTL_AVL_COMPARE_ROUTINE CompareRoutine; - PRTL_AVL_ALLOCATE_ROUTINE AllocateRoutine; - PRTL_AVL_FREE_ROUTINE FreeRoutine; - PVOID TableContext; -} RTL_AVL_TABLE, *PRTL_AVL_TABLE; -#ifndef RTL_USE_AVL_TABLES +#ifdef _X86_ -struct _RTL_GENERIC_TABLE; +#define MM_HIGHEST_USER_ADDRESS MmHighestUserAddress +#define MM_SYSTEM_RANGE_START MmSystemRangeStart +#if defined(_LOCAL_COPY_USER_PROBE_ADDRESS_) +#define MM_USER_PROBE_ADDRESS _LOCAL_COPY_USER_PROBE_ADDRESS_ +extern ULONG _LOCAL_COPY_USER_PROBE_ADDRESS_; +#else +#define MM_USER_PROBE_ADDRESS MmUserProbeAddress +#endif +#define MM_LOWEST_USER_ADDRESS (PVOID)0x10000 +#define MM_KSEG0_BASE MM_SYSTEM_RANGE_START +#define MM_SYSTEM_SPACE_END 0xFFFFFFFF +#if !defined (_X86PAE_) +#define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xC0800000 +#else +#define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xC0C00000 +#endif -typedef RTL_GENERIC_COMPARE_RESULTS -(NTAPI *PRTL_GENERIC_COMPARE_ROUTINE) ( - IN struct _RTL_GENERIC_TABLE *Table, - IN PVOID FirstStruct, - IN PVOID SecondStruct); +#define KeGetPcr() PCR -typedef PVOID -(NTAPI *PRTL_GENERIC_ALLOCATE_ROUTINE) ( - IN struct _RTL_GENERIC_TABLE *Table, - IN CLONG ByteSize); +#define KERNEL_STACK_SIZE 12288 +#define KERNEL_LARGE_STACK_SIZE 61440 +#define KERNEL_LARGE_STACK_COMMIT 12288 -typedef VOID -(NTAPI *PRTL_GENERIC_FREE_ROUTINE) ( - IN struct _RTL_GENERIC_TABLE *Table, - IN PVOID Buffer); +#define SIZE_OF_80387_REGISTERS 80 -typedef struct _RTL_SPLAY_LINKS { - struct _RTL_SPLAY_LINKS *Parent; - struct _RTL_SPLAY_LINKS *LeftChild; - struct _RTL_SPLAY_LINKS *RightChild; -} RTL_SPLAY_LINKS, *PRTL_SPLAY_LINKS; +#define PCR_MINOR_VERSION 1 +#define PCR_MAJOR_VERSION 1 -typedef struct _RTL_GENERIC_TABLE { - PRTL_SPLAY_LINKS TableRoot; - LIST_ENTRY InsertOrderList; - PLIST_ENTRY OrderedPointer; - ULONG WhichOrderedElement; - ULONG NumberGenericTableElements; - PRTL_GENERIC_COMPARE_ROUTINE CompareRoutine; - PRTL_GENERIC_ALLOCATE_ROUTINE AllocateRoutine; - PRTL_GENERIC_FREE_ROUTINE FreeRoutine; - PVOID TableContext; -} RTL_GENERIC_TABLE, *PRTL_GENERIC_TABLE; +#if !defined(RC_INVOKED) -#endif /* !RTL_USE_AVL_TABLES */ +#define CONTEXT_i386 0x10000 +#define CONTEXT_i486 0x10000 +#define CONTEXT_CONTROL (CONTEXT_i386|0x00000001L) +#define CONTEXT_INTEGER (CONTEXT_i386|0x00000002L) +#define CONTEXT_SEGMENTS (CONTEXT_i386|0x00000004L) +#define CONTEXT_FLOATING_POINT (CONTEXT_i386|0x00000008L) +#define CONTEXT_DEBUG_REGISTERS (CONTEXT_i386|0x00000010L) +#define CONTEXT_EXTENDED_REGISTERS (CONTEXT_i386|0x00000020L) -#ifdef RTL_USE_AVL_TABLES +#define CONTEXT_FULL (CONTEXT_CONTROL|CONTEXT_INTEGER|CONTEXT_SEGMENTS) -#undef PRTL_GENERIC_COMPARE_ROUTINE -#undef RTL_GENERIC_COMPARE_ROUTINE -#undef PRTL_GENERIC_ALLOCATE_ROUTINE -#undef RTL_GENERIC_ALLOCATE_ROUTINE -#undef PRTL_GENERIC_FREE_ROUTINE -#undef RTL_GENERIC_FREE_ROUTINE -#undef RTL_GENERIC_TABLE -#undef PRTL_GENERIC_TABLE +#endif /* !defined(RC_INVOKED) */ -#define PRTL_GENERIC_COMPARE_ROUTINE PRTL_AVL_COMPARE_ROUTINE -#define RTL_GENERIC_COMPARE_ROUTINE RTL_AVL_COMPARE_ROUTINE -#define PRTL_GENERIC_ALLOCATE_ROUTINE PRTL_AVL_ALLOCATE_ROUTINE -#define RTL_GENERIC_ALLOCATE_ROUTINE RTL_AVL_ALLOCATE_ROUTINE -#define PRTL_GENERIC_FREE_ROUTINE PRTL_AVL_FREE_ROUTINE -#define RTL_GENERIC_FREE_ROUTINE RTL_AVL_FREE_ROUTINE -#define RTL_GENERIC_TABLE RTL_AVL_TABLE -#define PRTL_GENERIC_TABLE PRTL_AVL_TABLE +typedef struct _KPCR { + union { + NT_TIB NtTib; + struct { + struct _EXCEPTION_REGISTRATION_RECORD *Used_ExceptionList; + PVOID Used_StackBase; + PVOID Spare2; + PVOID TssCopy; + ULONG ContextSwitches; + KAFFINITY SetMemberCopy; + PVOID Used_Self; + }; + }; + struct _KPCR *SelfPcr; + struct _KPRCB *Prcb; + KIRQL Irql; + ULONG IRR; + ULONG IrrActive; + ULONG IDR; + PVOID KdVersionBlock; + struct _KIDTENTRY *IDT; + struct _KGDTENTRY *GDT; + struct _KTSS *TSS; + USHORT MajorVersion; + USHORT MinorVersion; + KAFFINITY SetMember; + ULONG StallScaleFactor; + UCHAR SpareUnused; + UCHAR Number; + UCHAR Spare0; + UCHAR SecondLevelCacheAssociativity; + ULONG VdmAlert; + ULONG KernelReserved[14]; + ULONG SecondLevelCacheSize; + ULONG HalReserved[16]; +} KPCR, *PKPCR; -#endif /* RTL_USE_AVL_TABLES */ +FORCEINLINE +ULONG +KeGetCurrentProcessorNumber(VOID) +{ + return (ULONG)__readfsbyte(FIELD_OFFSET(KPCR, Number)); +} -typedef struct _RTL_DYNAMIC_HASH_TABLE_ENTRY { - LIST_ENTRY Linkage; - ULONG_PTR Signature; -} RTL_DYNAMIC_HASH_TABLE_ENTRY, *PRTL_DYNAMIC_HASH_TABLE_ENTRY; +typedef struct _FLOATING_SAVE_AREA { + ULONG ControlWord; + ULONG StatusWord; + ULONG TagWord; + ULONG ErrorOffset; + ULONG ErrorSelector; + ULONG DataOffset; + ULONG DataSelector; + UCHAR RegisterArea[SIZE_OF_80387_REGISTERS]; + ULONG Cr0NpxState; +} FLOATING_SAVE_AREA, *PFLOATING_SAVE_AREA; -typedef struct _RTL_DYNAMIC_HASH_TABLE_CONTEXT { - PLIST_ENTRY ChainHead; - PLIST_ENTRY PrevLinkage; - ULONG_PTR Signature; -} RTL_DYNAMIC_HASH_TABLE_CONTEXT, *PRTL_DYNAMIC_HASH_TABLE_CONTEXT; +#include "pshpack4.h" +typedef struct _CONTEXT { + ULONG ContextFlags; + ULONG Dr0; + ULONG Dr1; + ULONG Dr2; + ULONG Dr3; + ULONG Dr6; + ULONG Dr7; + FLOATING_SAVE_AREA FloatSave; + ULONG SegGs; + ULONG SegFs; + ULONG SegEs; + ULONG SegDs; + ULONG Edi; + ULONG Esi; + ULONG Ebx; + ULONG Edx; + ULONG Ecx; + ULONG Eax; + ULONG Ebp; + ULONG Eip; + ULONG SegCs; + ULONG EFlags; + ULONG Esp; + ULONG SegSs; + UCHAR ExtendedRegisters[MAXIMUM_SUPPORTED_EXTENSION]; +} CONTEXT; +#include "poppack.h" -typedef struct _RTL_DYNAMIC_HASH_TABLE_ENUMERATOR { - RTL_DYNAMIC_HASH_TABLE_ENTRY HashEntry; - PLIST_ENTRY ChainHead; - ULONG BucketIndex; -} RTL_DYNAMIC_HASH_TABLE_ENUMERATOR, *PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR; +#endif /* _X86_ */ -typedef struct _RTL_DYNAMIC_HASH_TABLE { - ULONG Flags; - ULONG Shift; - ULONG TableSize; - ULONG Pivot; - ULONG DivisorMask; - ULONG NumEntries; - ULONG NonEmptyBuckets; - ULONG NumEnumerators; - PVOID Directory; -} RTL_DYNAMIC_HASH_TABLE, *PRTL_DYNAMIC_HASH_TABLE; +#ifdef _AMD64_ + +#define PTI_SHIFT 12L +#define PDI_SHIFT 21L +#define PPI_SHIFT 30L +#define PXI_SHIFT 39L +#define PTE_PER_PAGE 512 +#define PDE_PER_PAGE 512 +#define PPE_PER_PAGE 512 +#define PXE_PER_PAGE 512 +#define PTI_MASK_AMD64 (PTE_PER_PAGE - 1) +#define PDI_MASK_AMD64 (PDE_PER_PAGE - 1) +#define PPI_MASK (PPE_PER_PAGE - 1) +#define PXI_MASK (PXE_PER_PAGE - 1) + +#define PXE_BASE 0xFFFFF6FB7DBED000ULL +#define PXE_SELFMAP 0xFFFFF6FB7DBEDF68ULL +#define PPE_BASE 0xFFFFF6FB7DA00000ULL +#define PDE_BASE 0xFFFFF6FB40000000ULL +#define PTE_BASE 0xFFFFF68000000000ULL +#define PXE_TOP 0xFFFFF6FB7DBEDFFFULL +#define PPE_TOP 0xFFFFF6FB7DBFFFFFULL +#define PDE_TOP 0xFFFFF6FB7FFFFFFFULL +#define PTE_TOP 0xFFFFF6FFFFFFFFFFULL + +#define MM_HIGHEST_USER_ADDRESS MmHighestUserAddress +#define MM_SYSTEM_RANGE_START MmSystemRangeStart +#define MM_USER_PROBE_ADDRESS MmUserProbeAddress +#define MM_LOWEST_USER_ADDRESS (PVOID)0x10000 +#define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xFFFF080000000000ULL +#define KI_USER_SHARED_DATA 0xFFFFF78000000000ULL + +typedef struct DECLSPEC_ALIGN(16) _CONTEXT { + ULONG64 P1Home; + ULONG64 P2Home; + ULONG64 P3Home; + ULONG64 P4Home; + ULONG64 P5Home; + ULONG64 P6Home; + + /* Control flags */ + ULONG ContextFlags; + ULONG MxCsr; + + /* Segment */ + USHORT SegCs; + USHORT SegDs; + USHORT SegEs; + USHORT SegFs; + USHORT SegGs; + USHORT SegSs; + ULONG EFlags; + + /* Debug */ + ULONG64 Dr0; + ULONG64 Dr1; + ULONG64 Dr2; + ULONG64 Dr3; + ULONG64 Dr6; + ULONG64 Dr7; + + /* Integer */ + ULONG64 Rax; + ULONG64 Rcx; + ULONG64 Rdx; + ULONG64 Rbx; + ULONG64 Rsp; + ULONG64 Rbp; + ULONG64 Rsi; + ULONG64 Rdi; + ULONG64 R8; + ULONG64 R9; + ULONG64 R10; + ULONG64 R11; + ULONG64 R12; + ULONG64 R13; + ULONG64 R14; + ULONG64 R15; + + /* Counter */ + ULONG64 Rip; + + /* Floating point */ + union { + XMM_SAVE_AREA32 FltSave; + struct { + M128A Header[2]; + M128A Legacy[8]; + M128A Xmm0; + M128A Xmm1; + M128A Xmm2; + M128A Xmm3; + M128A Xmm4; + M128A Xmm5; + M128A Xmm6; + M128A Xmm7; + M128A Xmm8; + M128A Xmm9; + M128A Xmm10; + M128A Xmm11; + M128A Xmm12; + M128A Xmm13; + M128A Xmm14; + M128A Xmm15; + } DUMMYSTRUCTNAME; + } DUMMYUNIONNAME; + + /* Vector */ + M128A VectorRegister[26]; + ULONG64 VectorControl; + + /* Debug control */ + ULONG64 DebugControl; + ULONG64 LastBranchToRip; + ULONG64 LastBranchFromRip; + ULONG64 LastExceptionToRip; + ULONG64 LastExceptionFromRip; +} CONTEXT; + +typedef struct _KPCR +{ + _ANONYMOUS_UNION union + { + NT_TIB NtTib; + _ANONYMOUS_STRUCT struct + { + union _KGDTENTRY64 *GdtBase; + struct _KTSS64 *TssBase; + ULONG64 UserRsp; + struct _KPCR *Self; + struct _KPRCB *CurrentPrcb; + PKSPIN_LOCK_QUEUE LockArray; + PVOID Used_Self; + }; + }; + union _KIDTENTRY64 *IdtBase; + ULONG64 Unused[2]; + KIRQL Irql; + UCHAR SecondLevelCacheAssociativity; + UCHAR ObsoleteNumber; + UCHAR Fill0; + ULONG Unused0[3]; + USHORT MajorVersion; + USHORT MinorVersion; + ULONG StallScaleFactor; + PVOID Unused1[3]; + ULONG KernelReserved[15]; + ULONG SecondLevelCacheSize; + ULONG HalReserved[16]; + ULONG Unused2; + PVOID KdVersionBlock; + PVOID Unused3; + ULONG PcrAlign1[24]; +} KPCR, *PKPCR; + +FORCEINLINE +PKPCR +KeGetPcr(VOID) +{ + return (PKPCR)__readgsqword(FIELD_OFFSET(KPCR, Self)); +} + +FORCEINLINE +ULONG +KeGetCurrentProcessorNumber(VOID) +{ + return (ULONG)__readgsword(0x184); +} + +#if !defined(RC_INVOKED) + +#define CONTEXT_AMD64 0x100000 + +#define CONTEXT_CONTROL (CONTEXT_AMD64 | 0x1L) +#define CONTEXT_INTEGER (CONTEXT_AMD64 | 0x2L) +#define CONTEXT_SEGMENTS (CONTEXT_AMD64 | 0x4L) +#define CONTEXT_FLOATING_POINT (CONTEXT_AMD64 | 0x8L) +#define CONTEXT_DEBUG_REGISTERS (CONTEXT_AMD64 | 0x10L) + +#define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT) +#define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS) + +#define CONTEXT_XSTATE (CONTEXT_AMD64 | 0x20L) + +#define CONTEXT_EXCEPTION_ACTIVE 0x8000000 +#define CONTEXT_SERVICE_ACTIVE 0x10000000 +#define CONTEXT_EXCEPTION_REQUEST 0x40000000 +#define CONTEXT_EXCEPTION_REPORTING 0x80000000 + +#endif /* RC_INVOKED */ + +#endif /* _AMD64_ */ + +typedef enum _INTERLOCKED_RESULT { + ResultNegative = RESULT_NEGATIVE, + ResultZero = RESULT_ZERO, + ResultPositive = RESULT_POSITIVE +} INTERLOCKED_RESULT; typedef struct _OSVERSIONINFOA { ULONG dwOSVersionInfoSize; @@ -2783,461 +1589,24 @@ typedef POSVERSIONINFOA POSVERSIONINFO; typedef LPOSVERSIONINFOA LPOSVERSIONINFO; #endif /* UNICODE */ -#define HASH_ENTRY_KEY(x) ((x)->Signature) +/* Executive Types */ -/****************************************************************************** - * Security Manager Types * - ******************************************************************************/ -#define SE_UNSOLICITED_INPUT_PRIVILEGE 6 +#define PROTECTED_POOL 0x80000000 -typedef enum _WELL_KNOWN_SID_TYPE { - WinNullSid = 0, - WinWorldSid = 1, - WinLocalSid = 2, - WinCreatorOwnerSid = 3, - WinCreatorGroupSid = 4, - WinCreatorOwnerServerSid = 5, - WinCreatorGroupServerSid = 6, - WinNtAuthoritySid = 7, - WinDialupSid = 8, - WinNetworkSid = 9, - WinBatchSid = 10, - WinInteractiveSid = 11, - WinServiceSid = 12, - WinAnonymousSid = 13, - WinProxySid = 14, - WinEnterpriseControllersSid = 15, - WinSelfSid = 16, - WinAuthenticatedUserSid = 17, - WinRestrictedCodeSid = 18, - WinTerminalServerSid = 19, - WinRemoteLogonIdSid = 20, - WinLogonIdsSid = 21, - WinLocalSystemSid = 22, - WinLocalServiceSid = 23, - WinNetworkServiceSid = 24, - WinBuiltinDomainSid = 25, - WinBuiltinAdministratorsSid = 26, - WinBuiltinUsersSid = 27, - WinBuiltinGuestsSid = 28, - WinBuiltinPowerUsersSid = 29, - WinBuiltinAccountOperatorsSid = 30, - WinBuiltinSystemOperatorsSid = 31, - WinBuiltinPrintOperatorsSid = 32, - WinBuiltinBackupOperatorsSid = 33, - WinBuiltinReplicatorSid = 34, - WinBuiltinPreWindows2000CompatibleAccessSid = 35, - WinBuiltinRemoteDesktopUsersSid = 36, - WinBuiltinNetworkConfigurationOperatorsSid = 37, - WinAccountAdministratorSid = 38, - WinAccountGuestSid = 39, - WinAccountKrbtgtSid = 40, - WinAccountDomainAdminsSid = 41, - WinAccountDomainUsersSid = 42, - WinAccountDomainGuestsSid = 43, - WinAccountComputersSid = 44, - WinAccountControllersSid = 45, - WinAccountCertAdminsSid = 46, - WinAccountSchemaAdminsSid = 47, - WinAccountEnterpriseAdminsSid = 48, - WinAccountPolicyAdminsSid = 49, - WinAccountRasAndIasServersSid = 50, - WinNTLMAuthenticationSid = 51, - WinDigestAuthenticationSid = 52, - WinSChannelAuthenticationSid = 53, - WinThisOrganizationSid = 54, - WinOtherOrganizationSid = 55, - WinBuiltinIncomingForestTrustBuildersSid = 56, - WinBuiltinPerfMonitoringUsersSid = 57, - WinBuiltinPerfLoggingUsersSid = 58, - WinBuiltinAuthorizationAccessSid = 59, - WinBuiltinTerminalServerLicenseServersSid = 60, - WinBuiltinDCOMUsersSid = 61, - WinBuiltinIUsersSid = 62, - WinIUserSid = 63, - WinBuiltinCryptoOperatorsSid = 64, - WinUntrustedLabelSid = 65, - WinLowLabelSid = 66, - WinMediumLabelSid = 67, - WinHighLabelSid = 68, - WinSystemLabelSid = 69, - WinWriteRestrictedCodeSid = 70, - WinCreatorOwnerRightsSid = 71, - WinCacheablePrincipalsGroupSid = 72, - WinNonCacheablePrincipalsGroupSid = 73, - WinEnterpriseReadonlyControllersSid = 74, - WinAccountReadonlyControllersSid = 75, - WinBuiltinEventLogReadersGroup = 76, - WinNewEnterpriseReadonlyControllersSid = 77, - WinBuiltinCertSvcDComAccessGroup = 78, - WinMediumPlusLabelSid = 79, - WinLocalLogonSid = 80, - WinConsoleLogonSid = 81, - WinThisOrganizationCertificateSid = 82, -} WELL_KNOWN_SID_TYPE; +typedef struct _ZONE_SEGMENT_HEADER { + SINGLE_LIST_ENTRY SegmentList; + PVOID Reserved; +} ZONE_SEGMENT_HEADER, *PZONE_SEGMENT_HEADER; +typedef struct _ZONE_HEADER { + SINGLE_LIST_ENTRY FreeList; + SINGLE_LIST_ENTRY SegmentList; + ULONG BlockSize; + ULONG TotalSegmentSize; +} ZONE_HEADER, *PZONE_HEADER; +/* Executive Functions */ -#if defined(_M_IX86) - -#define PAUSE_PROCESSOR YieldProcessor(); - -#define KERNEL_STACK_SIZE 12288 -#define KERNEL_LARGE_STACK_SIZE 61440 -#define KERNEL_LARGE_STACK_COMMIT 12288 - -#define SIZE_OF_80387_REGISTERS 80 - -#if !defined(RC_INVOKED) - -#define CONTEXT_i386 0x10000 -#define CONTEXT_i486 0x10000 -#define CONTEXT_CONTROL (CONTEXT_i386|0x00000001L) -#define CONTEXT_INTEGER (CONTEXT_i386|0x00000002L) -#define CONTEXT_SEGMENTS (CONTEXT_i386|0x00000004L) -#define CONTEXT_FLOATING_POINT (CONTEXT_i386|0x00000008L) -#define CONTEXT_DEBUG_REGISTERS (CONTEXT_i386|0x00000010L) -#define CONTEXT_EXTENDED_REGISTERS (CONTEXT_i386|0x00000020L) - -#define CONTEXT_FULL (CONTEXT_CONTROL|CONTEXT_INTEGER|CONTEXT_SEGMENTS) -#define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | \ - CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS | \ - CONTEXT_EXTENDED_REGISTERS) - -#define CONTEXT_XSTATE (CONTEXT_i386 | 0x00000040L) - -#endif /* !defined(RC_INVOKED) */ - -typedef struct _FLOATING_SAVE_AREA { - ULONG ControlWord; - ULONG StatusWord; - ULONG TagWord; - ULONG ErrorOffset; - ULONG ErrorSelector; - ULONG DataOffset; - ULONG DataSelector; - UCHAR RegisterArea[SIZE_OF_80387_REGISTERS]; - ULONG Cr0NpxState; -} FLOATING_SAVE_AREA, *PFLOATING_SAVE_AREA; - -#include "pshpack4.h" -typedef struct _CONTEXT { - ULONG ContextFlags; - ULONG Dr0; - ULONG Dr1; - ULONG Dr2; - ULONG Dr3; - ULONG Dr6; - ULONG Dr7; - FLOATING_SAVE_AREA FloatSave; - ULONG SegGs; - ULONG SegFs; - ULONG SegEs; - ULONG SegDs; - ULONG Edi; - ULONG Esi; - ULONG Ebx; - ULONG Edx; - ULONG Ecx; - ULONG Eax; - ULONG Ebp; - ULONG Eip; - ULONG SegCs; - ULONG EFlags; - ULONG Esp; - ULONG SegSs; - UCHAR ExtendedRegisters[MAXIMUM_SUPPORTED_EXTENSION]; -} CONTEXT; -#include "poppack.h" - -#define KeGetPcr() PCR - -#define PCR_MINOR_VERSION 1 -#define PCR_MAJOR_VERSION 1 - -typedef struct _KPCR { - union { - NT_TIB NtTib; - struct { - struct _EXCEPTION_REGISTRATION_RECORD *Used_ExceptionList; - PVOID Used_StackBase; - PVOID Spare2; - PVOID TssCopy; - ULONG ContextSwitches; - KAFFINITY SetMemberCopy; - PVOID Used_Self; - }; - }; - struct _KPCR *SelfPcr; - struct _KPRCB *Prcb; - KIRQL Irql; - ULONG IRR; - ULONG IrrActive; - ULONG IDR; - PVOID KdVersionBlock; - struct _KIDTENTRY *IDT; - struct _KGDTENTRY *GDT; - struct _KTSS *TSS; - USHORT MajorVersion; - USHORT MinorVersion; - KAFFINITY SetMember; - ULONG StallScaleFactor; - UCHAR SpareUnused; - UCHAR Number; - UCHAR Spare0; - UCHAR SecondLevelCacheAssociativity; - ULONG VdmAlert; - ULONG KernelReserved[14]; - ULONG SecondLevelCacheSize; - ULONG HalReserved[16]; -} KPCR, *PKPCR; - -FORCEINLINE -ULONG -KeGetCurrentProcessorNumber(VOID) -{ - return (ULONG)__readfsbyte(FIELD_OFFSET(KPCR, Number)); -} - - - - - - -extern NTKERNELAPI PVOID MmHighestUserAddress; -extern NTKERNELAPI PVOID MmSystemRangeStart; -extern NTKERNELAPI ULONG MmUserProbeAddress; - -#define MM_HIGHEST_USER_ADDRESS MmHighestUserAddress -#define MM_SYSTEM_RANGE_START MmSystemRangeStart -#if defined(_LOCAL_COPY_USER_PROBE_ADDRESS_) -#define MM_USER_PROBE_ADDRESS _LOCAL_COPY_USER_PROBE_ADDRESS_ -extern ULONG _LOCAL_COPY_USER_PROBE_ADDRESS_; -#else -#define MM_USER_PROBE_ADDRESS MmUserProbeAddress -#endif -#define MM_LOWEST_USER_ADDRESS (PVOID)0x10000 -#define MM_KSEG0_BASE MM_SYSTEM_RANGE_START -#define MM_SYSTEM_SPACE_END 0xFFFFFFFF -#if !defined (_X86PAE_) -#define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xC0800000 -#else -#define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xC0C00000 -#endif - -#elif defined(_M_AMD64) - -#define PAUSE_PROCESSOR YieldProcessor(); - -#define KERNEL_STACK_SIZE 0x6000 -#define KERNEL_LARGE_STACK_SIZE 0x12000 -#define KERNEL_LARGE_STACK_COMMIT KERNEL_STACK_SIZE - -#define KERNEL_MCA_EXCEPTION_STACK_SIZE 0x2000 - -#define EXCEPTION_READ_FAULT 0 -#define EXCEPTION_WRITE_FAULT 1 -#define EXCEPTION_EXECUTE_FAULT 8 - -#if !defined(RC_INVOKED) - -#define CONTEXT_AMD64 0x100000 - -#define CONTEXT_CONTROL (CONTEXT_AMD64 | 0x1L) -#define CONTEXT_INTEGER (CONTEXT_AMD64 | 0x2L) -#define CONTEXT_SEGMENTS (CONTEXT_AMD64 | 0x4L) -#define CONTEXT_FLOATING_POINT (CONTEXT_AMD64 | 0x8L) -#define CONTEXT_DEBUG_REGISTERS (CONTEXT_AMD64 | 0x10L) - -#define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT) -#define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS) - -#define CONTEXT_XSTATE (CONTEXT_AMD64 | 0x20L) - -#define CONTEXT_EXCEPTION_ACTIVE 0x8000000 -#define CONTEXT_SERVICE_ACTIVE 0x10000000 -#define CONTEXT_EXCEPTION_REQUEST 0x40000000 -#define CONTEXT_EXCEPTION_REPORTING 0x80000000 - -#endif /* !defined(RC_INVOKED) */ - -#define INITIAL_MXCSR 0x1f80 -#define INITIAL_FPCSR 0x027f - -typedef struct DECLSPEC_ALIGN(16) _CONTEXT { - ULONG64 P1Home; - ULONG64 P2Home; - ULONG64 P3Home; - ULONG64 P4Home; - ULONG64 P5Home; - ULONG64 P6Home; - ULONG ContextFlags; - ULONG MxCsr; - USHORT SegCs; - USHORT SegDs; - USHORT SegEs; - USHORT SegFs; - USHORT SegGs; - USHORT SegSs; - ULONG EFlags; - ULONG64 Dr0; - ULONG64 Dr1; - ULONG64 Dr2; - ULONG64 Dr3; - ULONG64 Dr6; - ULONG64 Dr7; - ULONG64 Rax; - ULONG64 Rcx; - ULONG64 Rdx; - ULONG64 Rbx; - ULONG64 Rsp; - ULONG64 Rbp; - ULONG64 Rsi; - ULONG64 Rdi; - ULONG64 R8; - ULONG64 R9; - ULONG64 R10; - ULONG64 R11; - ULONG64 R12; - ULONG64 R13; - ULONG64 R14; - ULONG64 R15; - ULONG64 Rip; - union { - XMM_SAVE_AREA32 FltSave; - struct { - M128A Header[2]; - M128A Legacy[8]; - M128A Xmm0; - M128A Xmm1; - M128A Xmm2; - M128A Xmm3; - M128A Xmm4; - M128A Xmm5; - M128A Xmm6; - M128A Xmm7; - M128A Xmm8; - M128A Xmm9; - M128A Xmm10; - M128A Xmm11; - M128A Xmm12; - M128A Xmm13; - M128A Xmm14; - M128A Xmm15; - } DUMMYSTRUCTNAME; - } DUMMYUNIONNAME; - M128A VectorRegister[26]; - ULONG64 VectorControl; - ULONG64 DebugControl; - ULONG64 LastBranchToRip; - ULONG64 LastBranchFromRip; - ULONG64 LastExceptionToRip; - ULONG64 LastExceptionFromRip; -} CONTEXT; - -#define PCR_MINOR_VERSION 1 -#define PCR_MAJOR_VERSION 1 - -typedef struct _KPCR -{ - _ANONYMOUS_UNION union - { - NT_TIB NtTib; - _ANONYMOUS_STRUCT struct - { - union _KGDTENTRY64 *GdtBase; - struct _KTSS64 *TssBase; - ULONG64 UserRsp; - struct _KPCR *Self; - struct _KPRCB *CurrentPrcb; - PKSPIN_LOCK_QUEUE LockArray; - PVOID Used_Self; - }; - }; - union _KIDTENTRY64 *IdtBase; - ULONG64 Unused[2]; - KIRQL Irql; - UCHAR SecondLevelCacheAssociativity; - UCHAR ObsoleteNumber; - UCHAR Fill0; - ULONG Unused0[3]; - USHORT MajorVersion; - USHORT MinorVersion; - ULONG StallScaleFactor; - PVOID Unused1[3]; - ULONG KernelReserved[15]; - ULONG SecondLevelCacheSize; - ULONG HalReserved[16]; - ULONG Unused2; - PVOID KdVersionBlock; - PVOID Unused3; - ULONG PcrAlign1[24]; -} KPCR, *PKPCR; - -FORCEINLINE -PKPCR -KeGetPcr(VOID) -{ - return (PKPCR)__readgsqword(FIELD_OFFSET(KPCR, Self)); -} - -FORCEINLINE -ULONG -KeGetCurrentProcessorNumber(VOID) -{ - return (ULONG)__readgsword(0x184); -} - - -#define PTI_SHIFT 12L -#define PDI_SHIFT 21L -#define PPI_SHIFT 30L -#define PXI_SHIFT 39L -#define PTE_PER_PAGE 512 -#define PDE_PER_PAGE 512 -#define PPE_PER_PAGE 512 -#define PXE_PER_PAGE 512 -#define PTI_MASK_AMD64 (PTE_PER_PAGE - 1) -#define PDI_MASK_AMD64 (PDE_PER_PAGE - 1) -#define PPI_MASK (PPE_PER_PAGE - 1) -#define PXI_MASK (PXE_PER_PAGE - 1) - -#define PXE_BASE 0xFFFFF6FB7DBED000ULL -#define PXE_SELFMAP 0xFFFFF6FB7DBEDF68ULL -#define PPE_BASE 0xFFFFF6FB7DA00000ULL -#define PDE_BASE 0xFFFFF6FB40000000ULL -#define PTE_BASE 0xFFFFF68000000000ULL -#define PXE_TOP 0xFFFFF6FB7DBEDFFFULL -#define PPE_TOP 0xFFFFF6FB7DBFFFFFULL -#define PDE_TOP 0xFFFFF6FB7FFFFFFFULL -#define PTE_TOP 0xFFFFF6FFFFFFFFFFULL - -extern NTKERNELAPI PVOID MmHighestUserAddress; -extern NTKERNELAPI PVOID MmSystemRangeStart; -extern NTKERNELAPI ULONG64 MmUserProbeAddress; - -#define MM_HIGHEST_USER_ADDRESS MmHighestUserAddress -#define MM_SYSTEM_RANGE_START MmSystemRangeStart -#define MM_USER_PROBE_ADDRESS MmUserProbeAddress -#define MM_LOWEST_USER_ADDRESS (PVOID)0x10000 -#define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xFFFF080000000000ULL - - -#elif defined(_M_IA64) - -#elif defined(_M_PPC) - - -#elif defined(_M_MIPS) - -#elif defined(_M_ARM) -#else -#error Unknown Architecture -#endif - -/****************************************************************************** - * Executive Functions * - ******************************************************************************/ static __inline PVOID ExAllocateFromZone( IN PZONE_HEADER Zone) @@ -3249,8 +1618,8 @@ ExAllocateFromZone( static __inline PVOID ExFreeToZone( - IN PZONE_HEADER Zone, - IN PVOID Block) + IN PZONE_HEADER Zone, + IN PVOID Block) { ((PSINGLE_LIST_ENTRY) Block)->Next = Zone->FreeList.Next; Zone->FreeList.Next = ((PSINGLE_LIST_ENTRY) Block); @@ -3303,36 +1672,8 @@ ExFreeToZone( #define ExIsResourceAcquired ExIsResourceAcquiredSharedLite #define ExReleaseResourceForThread ExReleaseResourceForThreadLite -typedef enum _INTERLOCKED_RESULT { - ResultNegative = RESULT_NEGATIVE, - ResultZero = RESULT_ZERO, - ResultPositive = RESULT_POSITIVE -} INTERLOCKED_RESULT; - -#ifdef _X86_ -NTKERNELAPI -INTERLOCKED_RESULT -FASTCALL -Exfi386InterlockedIncrementLong( - IN OUT LONG volatile *Addend); - -NTKERNELAPI -INTERLOCKED_RESULT -FASTCALL -Exfi386InterlockedDecrementLong( - IN PLONG Addend); - -NTKERNELAPI -ULONG -FASTCALL -Exfi386InterlockedExchangeUlong( - IN PULONG Target, - IN ULONG Value); -#endif - - - #if (NTDDI_VERSION >= NTDDI_WIN2K) + NTKERNELAPI NTSTATUS NTAPI @@ -3369,28 +1710,315 @@ NTKERNELAPI DECLSPEC_NORETURN VOID NTAPI -ExRaiseAccessViolation(VOID); +ExRaiseAccessViolation( + VOID); NTKERNELAPI DECLSPEC_NORETURN VOID NTAPI -ExRaiseDatatypeMisalignment(VOID); +ExRaiseDatatypeMisalignment( + VOID); +#endif -#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ +#ifdef _X86_ +NTKERNELAPI +INTERLOCKED_RESULT +FASTCALL +Exfi386InterlockedIncrementLong( + IN OUT LONG volatile *Addend); + +NTKERNELAPI +INTERLOCKED_RESULT +FASTCALL +Exfi386InterlockedDecrementLong( + IN PLONG Addend); + +NTKERNELAPI +ULONG +FASTCALL +Exfi386InterlockedExchangeUlong( + IN PULONG Target, + IN ULONG Value); + +#endif /* _X86_ */ + +#ifndef _ARC_DDK_ +#define _ARC_DDK_ +typedef enum _CONFIGURATION_TYPE { + ArcSystem, + CentralProcessor, + FloatingPointProcessor, + PrimaryIcache, + PrimaryDcache, + SecondaryIcache, + SecondaryDcache, + SecondaryCache, + EisaAdapter, + TcAdapter, + ScsiAdapter, + DtiAdapter, + MultiFunctionAdapter, + DiskController, + TapeController, + CdromController, + WormController, + SerialController, + NetworkController, + DisplayController, + ParallelController, + PointerController, + KeyboardController, + AudioController, + OtherController, + DiskPeripheral, + FloppyDiskPeripheral, + TapePeripheral, + ModemPeripheral, + MonitorPeripheral, + PrinterPeripheral, + PointerPeripheral, + KeyboardPeripheral, + TerminalPeripheral, + OtherPeripheral, + LinePeripheral, + NetworkPeripheral, + SystemMemory, + DockingInformation, + RealModeIrqRoutingTable, + RealModePCIEnumeration, + MaximumType +} CONFIGURATION_TYPE, *PCONFIGURATION_TYPE; +#endif /* !_ARC_DDK_ */ + +typedef struct _CONTROLLER_OBJECT { + CSHORT Type; + CSHORT Size; + PVOID ControllerExtension; + KDEVICE_QUEUE DeviceWaitQueue; + ULONG Spare1; + LARGE_INTEGER Spare2; +} CONTROLLER_OBJECT, *PCONTROLLER_OBJECT; + +typedef struct _CONFIGURATION_INFORMATION { + ULONG DiskCount; + ULONG FloppyCount; + ULONG CdRomCount; + ULONG TapeCount; + ULONG ScsiPortCount; + ULONG SerialCount; + ULONG ParallelCount; + BOOLEAN AtDiskPrimaryAddressClaimed; + BOOLEAN AtDiskSecondaryAddressClaimed; + ULONG Version; + ULONG MediumChangerCount; +} CONFIGURATION_INFORMATION, *PCONFIGURATION_INFORMATION; + +typedef +NTSTATUS +(NTAPI *PIO_QUERY_DEVICE_ROUTINE)( + IN PVOID Context, + IN PUNICODE_STRING PathName, + IN INTERFACE_TYPE BusType, + IN ULONG BusNumber, + IN PKEY_VALUE_FULL_INFORMATION *BusInformation, + IN CONFIGURATION_TYPE ControllerType, + IN ULONG ControllerNumber, + IN PKEY_VALUE_FULL_INFORMATION *ControllerInformation, + IN CONFIGURATION_TYPE PeripheralType, + IN ULONG PeripheralNumber, + IN PKEY_VALUE_FULL_INFORMATION *PeripheralInformation); + +typedef +VOID +(NTAPI DRIVER_REINITIALIZE)( + IN struct _DRIVER_OBJECT *DriverObject, + IN PVOID Context, + IN ULONG Count); + +typedef DRIVER_REINITIALIZE *PDRIVER_REINITIALIZE; + +/** Filesystem runtime library routines **/ + +#if (NTDDI_VERSION >= NTDDI_WIN2K) +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlIsTotalDeviceFailure( + IN NTSTATUS Status); +#endif + +/* Hardware Abstraction Layer Types */ + +typedef VOID +(NTAPI *PciPin2Line)( + IN struct _BUS_HANDLER *BusHandler, + IN struct _BUS_HANDLER *RootHandler, + IN PCI_SLOT_NUMBER SlotNumber, + IN PPCI_COMMON_CONFIG PciData); + +typedef VOID +(NTAPI *PciLine2Pin)( + IN struct _BUS_HANDLER *BusHandler, + IN struct _BUS_HANDLER *RootHandler, + IN PCI_SLOT_NUMBER SlotNumber, + IN PPCI_COMMON_CONFIG PciNewData, + IN PPCI_COMMON_CONFIG PciOldData); + +typedef VOID +(NTAPI *PciReadWriteConfig)( + IN struct _BUS_HANDLER *BusHandler, + IN PCI_SLOT_NUMBER Slot, + IN PVOID Buffer, + IN ULONG Offset, + IN ULONG Length); + +#define PCI_DATA_TAG ' ICP' +#define PCI_DATA_VERSION 1 + +typedef struct _PCIBUSDATA { + ULONG Tag; + ULONG Version; + PciReadWriteConfig ReadConfig; + PciReadWriteConfig WriteConfig; + PciPin2Line Pin2Line; + PciLine2Pin Line2Pin; + PCI_SLOT_NUMBER ParentSlot; + PVOID Reserved[4]; +} PCIBUSDATA, *PPCIBUSDATA; /* Hardware Abstraction Layer Functions */ +#if !defined(NO_LEGACY_DRIVERS) + #if (NTDDI_VERSION >= NTDDI_WIN2K) -#if defined(USE_DMA_MACROS) && !defined(_NTHAL_) && (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_) +NTHALAPI +NTSTATUS +NTAPI +HalAssignSlotResources( + IN PUNICODE_STRING RegistryPath, + IN PUNICODE_STRING DriverClassName, + IN PDRIVER_OBJECT DriverObject, + IN PDEVICE_OBJECT DeviceObject, + IN INTERFACE_TYPE BusType, + IN ULONG BusNumber, + IN ULONG SlotNumber, + IN OUT PCM_RESOURCE_LIST *AllocatedResources); -/* Nothing here */ +NTHALAPI +ULONG +NTAPI +HalGetInterruptVector( + IN INTERFACE_TYPE InterfaceType, + IN ULONG BusNumber, + IN ULONG BusInterruptLevel, + IN ULONG BusInterruptVector, + OUT PKIRQL Irql, + OUT PKAFFINITY Affinity); -#else /* USE_DMA_MACROS ... */ +NTHALAPI +ULONG +NTAPI +HalSetBusData( + IN BUS_DATA_TYPE BusDataType, + IN ULONG BusNumber, + IN ULONG SlotNumber, + IN PVOID Buffer, + IN ULONG Length); +#endif + +#endif /* !defined(NO_LEGACY_DRIVERS) */ + +#if (NTDDI_VERSION >= NTDDI_WIN2K) + +NTHALAPI +PADAPTER_OBJECT +NTAPI +HalGetAdapter( + IN PDEVICE_DESCRIPTION DeviceDescription, + IN OUT PULONG NumberOfMapRegisters); + +NTHALAPI +BOOLEAN +NTAPI +HalMakeBeep( + IN ULONG Frequency); + +VOID +NTAPI +HalPutDmaAdapter( + IN PADAPTER_OBJECT DmaAdapter); + +NTHALAPI +VOID +NTAPI +HalAcquireDisplayOwnership( + IN PHAL_RESET_DISPLAY_PARAMETERS ResetDisplayParameters); + +NTHALAPI +ULONG +NTAPI +HalGetBusData( + IN BUS_DATA_TYPE BusDataType, + IN ULONG BusNumber, + IN ULONG SlotNumber, + OUT PVOID Buffer, + IN ULONG Length); + +NTHALAPI +ULONG +NTAPI +HalGetBusDataByOffset( + IN BUS_DATA_TYPE BusDataType, + IN ULONG BusNumber, + IN ULONG SlotNumber, + OUT PVOID Buffer, + IN ULONG Offset, + IN ULONG Length); + +NTHALAPI +ULONG +NTAPI +HalSetBusDataByOffset( + IN BUS_DATA_TYPE BusDataType, + IN ULONG BusNumber, + IN ULONG SlotNumber, + IN PVOID Buffer, + IN ULONG Offset, + IN ULONG Length); + +NTHALAPI +BOOLEAN +NTAPI +HalTranslateBusAddress( + IN INTERFACE_TYPE InterfaceType, + IN ULONG BusNumber, + IN PHYSICAL_ADDRESS BusAddress, + IN OUT PULONG AddressSpace, + OUT PPHYSICAL_ADDRESS TranslatedAddress); + +#endif + +#if (NTDDI_VERSION >= NTDDI_WINXP) +NTKERNELAPI +VOID +FASTCALL +HalExamineMBR( + IN PDEVICE_OBJECT DeviceObject, + IN ULONG SectorSize, + IN ULONG MBRTypeIdentifier, + OUT PVOID *Buffer); +#endif + +#if defined(USE_DMA_MACROS) && !defined(_NTHAL_) && (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_) +// nothing here +#else + +#if (NTDDI_VERSION >= NTDDI_WIN2K) //DECLSPEC_DEPRECATED_DDK NTHALAPI VOID @@ -3456,207 +2084,12 @@ HalAllocateAdapterChannel( IN ULONG NumberOfMapRegisters, IN PDRIVER_CONTROL ExecutionRoutine); -#endif /* USE_DMA_MACROS ... */ - -#if !defined(NO_LEGACY_DRIVERS) -NTHALAPI -NTSTATUS -NTAPI -HalAssignSlotResources( - IN PUNICODE_STRING RegistryPath, - IN PUNICODE_STRING DriverClassName, - IN PDRIVER_OBJECT DriverObject, - IN PDEVICE_OBJECT DeviceObject, - IN INTERFACE_TYPE BusType, - IN ULONG BusNumber, - IN ULONG SlotNumber, - IN OUT PCM_RESOURCE_LIST *AllocatedResources); - -NTHALAPI -ULONG -NTAPI -HalGetInterruptVector( - IN INTERFACE_TYPE InterfaceType, - IN ULONG BusNumber, - IN ULONG BusInterruptLevel, - IN ULONG BusInterruptVector, - OUT PKIRQL Irql, - OUT PKAFFINITY Affinity); - -NTHALAPI -ULONG -NTAPI -HalSetBusData( - IN BUS_DATA_TYPE BusDataType, - IN ULONG BusNumber, - IN ULONG SlotNumber, - IN PVOID Buffer, - IN ULONG Length); - -NTHALAPI -ULONG -NTAPI -HalGetBusData( - IN BUS_DATA_TYPE BusDataType, - IN ULONG BusNumber, - IN ULONG SlotNumber, - OUT PVOID Buffer, - IN ULONG Length); - -NTHALAPI -BOOLEAN -NTAPI -HalMakeBeep( - IN ULONG Frequency); -#endif /* !defined(NO_LEGACY_DRIVERS) */ - -NTHALAPI -PADAPTER_OBJECT -NTAPI -HalGetAdapter( - IN PDEVICE_DESCRIPTION DeviceDescription, - OUT PULONG NumberOfMapRegisters); - -VOID -NTAPI -HalPutDmaAdapter( - IN PADAPTER_OBJECT DmaAdapter); - -NTHALAPI -VOID -NTAPI -HalAcquireDisplayOwnership( - IN PHAL_RESET_DISPLAY_PARAMETERS ResetDisplayParameters); - -NTHALAPI -ULONG -NTAPI -HalGetBusDataByOffset( - IN BUS_DATA_TYPE BusDataType, - IN ULONG BusNumber, - IN ULONG SlotNumber, - OUT PVOID Buffer, - IN ULONG Offset, - IN ULONG Length); - -NTHALAPI -ULONG -NTAPI -HalSetBusDataByOffset( - IN BUS_DATA_TYPE BusDataType, - IN ULONG BusNumber, - IN ULONG SlotNumber, - IN PVOID Buffer, - IN ULONG Offset, - IN ULONG Length); - -NTHALAPI -BOOLEAN -NTAPI -HalTranslateBusAddress( - IN INTERFACE_TYPE InterfaceType, - IN ULONG BusNumber, - IN PHYSICAL_ADDRESS BusAddress, - IN OUT PULONG AddressSpace, - OUT PPHYSICAL_ADDRESS TranslatedAddress); - -NTHALAPI -PVOID -NTAPI -HalAllocateCrashDumpRegisters( - IN PADAPTER_OBJECT AdapterObject, - IN OUT PULONG NumberOfMapRegisters); - -NTSTATUS -NTAPI -HalGetScatterGatherList( - IN PADAPTER_OBJECT DmaAdapter, - IN PDEVICE_OBJECT DeviceObject, - IN PMDL Mdl, - IN PVOID CurrentVa, - IN ULONG Length, - IN PDRIVER_LIST_CONTROL ExecutionRoutine, - IN PVOID Context, - IN BOOLEAN WriteToDevice); - -VOID -NTAPI -HalPutScatterGatherList( - IN PADAPTER_OBJECT DmaAdapter, - IN PSCATTER_GATHER_LIST ScatterGather, - IN BOOLEAN WriteToDevice); - #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ -#if (NTDDI_VERSION >= NTDDI_WINXP) -NTKERNELAPI -VOID -FASTCALL -HalExamineMBR( - IN PDEVICE_OBJECT DeviceObject, - IN ULONG SectorSize, - IN ULONG MBRTypeIdentifier, - OUT PVOID *Buffer); -#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ +#endif /* defined(USE_DMA_MACROS) && !defined(_NTHAL_) && (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_) */ -#if (NTDDI_VERSION >= NTDDI_WIN7) +/* I/O Manager Functions */ -NTSTATUS -NTAPI -HalAllocateHardwareCounters( - IN PGROUP_AFFINITY GroupAffinty, - IN ULONG GroupCount, - IN PPHYSICAL_COUNTER_RESOURCE_LIST ResourceList, - OUT PHANDLE CounterSetHandle); - -NTSTATUS -NTAPI -HalFreeHardwareCounters( - IN HANDLE CounterSetHandle); - -#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ - -#if defined(_IA64_) -#if (NTDDI_VERSION >= NTDDI_WIN2K) -NTHALAPI -ULONG -NTAPI -HalGetDmaAlignmentRequirement(VOID); -#endif -#endif /* defined(_IA64_) */ - -#if defined(_M_IX86) || defined(_M_AMD64) -#define HalGetDmaAlignmentRequirement() 1L -#endif - -#if (NTDDI_VERSION >= NTDDI_WIN7) - -typedef struct _WHEA_ERROR_SOURCE_DESCRIPTOR *PWHEA_ERROR_SOURCE_DESCRIPTOR; -typedef struct _WHEA_ERROR_RECORD *PWHEA_ERROR_RECORD; - -NTHALAPI -VOID -NTAPI -HalBugCheckSystem( - IN PWHEA_ERROR_SOURCE_DESCRIPTOR ErrorSource, - IN PWHEA_ERROR_RECORD ErrorRecord); - -#else - -typedef struct _WHEA_ERROR_RECORD *PWHEA_ERROR_RECORD; - -NTHALAPI -VOID -NTAPI -HalBugCheckSystem( - IN PWHEA_ERROR_RECORD ErrorRecord); - -#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ - - -/****************************************************************************** - * I/O Manager Functions * - ******************************************************************************/ /* * VOID IoAssignArcName( * IN PUNICODE_STRING ArcName, @@ -3672,19 +2105,8 @@ HalBugCheckSystem( */ #define IoDeassignArcName IoDeleteSymbolicLink -VOID -FORCEINLINE -NTAPI -IoInitializeDriverCreateContext( - PIO_DRIVER_CREATE_CONTEXT DriverContext) -{ - RtlZeroMemory(DriverContext, sizeof(IO_DRIVER_CREATE_CONTEXT)); - DriverContext->Size = sizeof(IO_DRIVER_CREATE_CONTEXT); -} - - - #if (NTDDI_VERSION >= NTDDI_WIN2K) + #if !(defined(USE_DMA_MACROS) && (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_)) NTKERNELAPI NTSTATUS @@ -3697,7 +2119,6 @@ IoAllocateAdapterChannel( IN PVOID Context); #endif -#if !defined(DMA_MACROS_DEFINED) //DECLSPEC_DEPRECATED_DDK NTHALAPI PHYSICAL_ADDRESS @@ -3709,7 +2130,6 @@ IoMapTransfer( IN PVOID CurrentVa, IN OUT PULONG Length, IN BOOLEAN WriteToDevice); -#endif NTKERNELAPI VOID @@ -3741,7 +2161,8 @@ IoFreeController( NTKERNELAPI PCONFIGURATION_INFORMATION NTAPI -IoGetConfigurationInformation(VOID); +IoGetConfigurationInformation( + VOID); NTKERNELAPI PDEVICE_OBJECT @@ -3759,7 +2180,8 @@ IoCancelFileOpen( NTKERNELAPI PGENERIC_MAPPING NTAPI -IoGetFileObjectGenericMapping(VOID); +IoGetFileObjectGenericMapping( + VOID); NTKERNELAPI PIRP @@ -3831,7 +2253,7 @@ IoReportDetectedDevice( IN PCM_RESOURCE_LIST ResourceList OPTIONAL, IN PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirements OPTIONAL, IN BOOLEAN ResourceAssigned, - IN OUT PDEVICE_OBJECT *DeviceObject OPTIONAL); + IN OUT PDEVICE_OBJECT *DeviceObject); NTKERNELAPI NTSTATUS @@ -3877,59 +2299,9 @@ IoAssignResources( IN PIO_RESOURCE_REQUIREMENTS_LIST RequestedResources OPTIONAL, IN OUT PCM_RESOURCE_LIST *AllocatedResources); -NTKERNELAPI -BOOLEAN -NTAPI -IoSetThreadHardErrorMode( - IN BOOLEAN EnableHardErrors); - #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ -#if (NTDDI_VERSION >= NTDDI_WIN2KSP3) - -NTKERNELAPI -BOOLEAN -NTAPI -IoIsFileOriginRemote( - IN PFILE_OBJECT FileObject); - -NTKERNELAPI -NTSTATUS -NTAPI -IoSetFileOrigin( - IN PFILE_OBJECT FileObject, - IN BOOLEAN Remote); - -#endif /* (NTDDI_VERSION >= NTDDI_WIN2KSP3) */ - #if (NTDDI_VERSION >= NTDDI_WINXP) -NTKERNELAPI -NTSTATUS -FASTCALL -IoReadPartitionTable( - IN PDEVICE_OBJECT DeviceObject, - IN ULONG SectorSize, - IN BOOLEAN ReturnRecognizedPartitions, - OUT struct _DRIVE_LAYOUT_INFORMATION **PartitionBuffer); - -NTKERNELAPI -NTSTATUS -FASTCALL -IoSetPartitionInformation( - IN PDEVICE_OBJECT DeviceObject, - IN ULONG SectorSize, - IN ULONG PartitionNumber, - IN ULONG PartitionType); - -NTKERNELAPI -NTSTATUS -FASTCALL -IoWritePartitionTable( - IN PDEVICE_OBJECT DeviceObject, - IN ULONG SectorSize, - IN ULONG SectorsPerTrack, - IN ULONG NumberOfHeads, - IN struct _DRIVE_LAYOUT_INFORMATION *PartitionBuffer); NTKERNELAPI NTSTATUS @@ -3946,12 +2318,30 @@ IoReadDiskSignature( IN ULONG BytesPerSector, OUT PDISK_SIGNATURE Signature); +NTKERNELAPI +NTSTATUS +FASTCALL +IoReadPartitionTable( + IN PDEVICE_OBJECT DeviceObject, + IN ULONG SectorSize, + IN BOOLEAN ReturnRecognizedPartitions, + OUT struct _DRIVE_LAYOUT_INFORMATION **PartitionBuffer); + NTKERNELAPI NTSTATUS NTAPI IoReadPartitionTableEx( IN PDEVICE_OBJECT DeviceObject, - OUT struct _DRIVE_LAYOUT_INFORMATION_EX **PartitionBuffer); + IN struct _DRIVE_LAYOUT_INFORMATION_EX **PartitionBuffer); + +NTKERNELAPI +NTSTATUS +FASTCALL +IoSetPartitionInformation( + IN PDEVICE_OBJECT DeviceObject, + IN ULONG SectorSize, + IN ULONG PartitionNumber, + IN ULONG PartitionType); NTKERNELAPI NTSTATUS @@ -3967,6 +2357,12 @@ NTAPI IoSetSystemPartition( IN PUNICODE_STRING VolumeNameString); +NTKERNELAPI +BOOLEAN +NTAPI +IoSetThreadHardErrorMode( + IN BOOLEAN EnableHardErrors); + NTKERNELAPI NTSTATUS NTAPI @@ -3981,6 +2377,16 @@ IoVolumeDeviceToDosName( IN PVOID VolumeDeviceObject, OUT PUNICODE_STRING DosName); +NTKERNELAPI +NTSTATUS +FASTCALL +IoWritePartitionTable( + IN PDEVICE_OBJECT DeviceObject, + IN ULONG SectorSize, + IN ULONG SectorsPerTrack, + IN ULONG NumberOfHeads, + IN struct _DRIVE_LAYOUT_INFORMATION *PartitionBuffer); + NTKERNELAPI NTSTATUS NTAPI @@ -3988,130 +2394,10 @@ IoWritePartitionTableEx( IN PDEVICE_OBJECT DeviceObject, IN struct _DRIVE_LAYOUT_INFORMATION_EX *DriveLayout); -NTKERNELAPI -NTSTATUS -NTAPI -IoCreateFileSpecifyDeviceObjectHint( - OUT PHANDLE FileHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes, - OUT PIO_STATUS_BLOCK IoStatusBlock, - IN PLARGE_INTEGER AllocationSize OPTIONAL, - IN ULONG FileAttributes, - IN ULONG ShareAccess, - IN ULONG Disposition, - IN ULONG CreateOptions, - IN PVOID EaBuffer OPTIONAL, - IN ULONG EaLength, - IN CREATE_FILE_TYPE CreateFileType, - IN PVOID InternalParameters OPTIONAL, - IN ULONG Options, - IN PVOID DeviceObject OPTIONAL); - -NTKERNELAPI -NTSTATUS -NTAPI -IoAttachDeviceToDeviceStackSafe( - IN PDEVICE_OBJECT SourceDevice, - IN PDEVICE_OBJECT TargetDevice, - OUT PDEVICE_OBJECT *AttachedToDeviceObject); - #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ +/** Kernel debugger routines **/ -#if (NTDDI_VERSION >= NTDDI_WS03) -NTKERNELAPI -IO_PAGING_PRIORITY -FASTCALL -IoGetPagingIoPriority( - IN PIRP Irp); - -#endif /* (NTDDI_VERSION >= NTDDI_WS03) */ - -#if (NTDDI_VERSION >= NTDDI_WS03SP1) -BOOLEAN -NTAPI -IoTranslateBusAddress( - IN INTERFACE_TYPE InterfaceType, - IN ULONG BusNumber, - IN PHYSICAL_ADDRESS BusAddress, - IN OUT PULONG AddressSpace, - OUT PPHYSICAL_ADDRESS TranslatedAddress); -#endif - -#if (NTDDI_VERSION >= NTDDI_VISTA) -NTKERNELAPI -NTSTATUS -NTAPI -IoUpdateDiskGeometry( - IN PDEVICE_OBJECT DeviceObject, - IN struct _DISK_GEOMETRY_EX* OldDiskGeometry, - IN struct _DISK_GEOMETRY_EX* NewDiskGeometry); - -PTXN_PARAMETER_BLOCK -NTAPI -IoGetTransactionParameterBlock( - IN PFILE_OBJECT FileObject); - -NTKERNELAPI -NTSTATUS -NTAPI -IoCreateFileEx( - OUT PHANDLE FileHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes, - OUT PIO_STATUS_BLOCK IoStatusBlock, - IN PLARGE_INTEGER AllocationSize OPTIONAL, - IN ULONG FileAttributes, - IN ULONG ShareAccess, - IN ULONG Disposition, - IN ULONG CreateOptions, - IN PVOID EaBuffer OPTIONAL, - IN ULONG EaLength, - IN CREATE_FILE_TYPE CreateFileType, - IN PVOID InternalParameters OPTIONAL, - IN ULONG Options, - IN PIO_DRIVER_CREATE_CONTEXT DriverContext OPTIONAL); - -NTSTATUS -NTAPI -IoSetIrpExtraCreateParameter( - IN OUT PIRP Irp, - IN struct _ECP_LIST *ExtraCreateParameter); - -VOID -NTAPI -IoClearIrpExtraCreateParameter( - IN OUT PIRP Irp); - -NTSTATUS -NTAPI -IoGetIrpExtraCreateParameter( - IN PIRP Irp, - OUT struct _ECP_LIST **ExtraCreateParameter OPTIONAL); - -BOOLEAN -NTAPI -IoIsFileObjectIgnoringSharing( - IN PFILE_OBJECT FileObject); - - -#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ - - -#if (NTDDI_VERSION >= NTDDI_WIN7) -NTSTATUS -NTAPI -IoSetFileObjectIgnoreSharing( - IN PFILE_OBJECT FileObject); - - -#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ - - -/****************************************************************************** - * Kernel Debugger Functions * - ******************************************************************************/ NTSYSAPI ULONG NTAPI @@ -4120,25 +2406,16 @@ DbgPrompt( OUT PCH Response, IN ULONG MaximumResponseLength); -/****************************************************************************** - * Kernel Functions * - ******************************************************************************/ -NTKERNELAPI -VOID -FASTCALL -KeInvalidateRangeAllCaches( - IN PVOID BaseAddress, - IN ULONG Length); - +/* Kernel Functions */ #if (NTDDI_VERSION >= NTDDI_WIN2K) NTKERNELAPI +DECLSPEC_NORETURN VOID NTAPI -KeSetImportanceDpc( - IN OUT PRKDPC Dpc, - IN KDPC_IMPORTANCE Importance); +KeBugCheck( + IN ULONG BugCheckCode); NTKERNELAPI LONG @@ -4155,204 +2432,24 @@ KeSetBasePriorityThread( IN OUT PRKTHREAD Thread, IN LONG Increment); -NTKERNELAPI -VOID -NTAPI -KeEnterCriticalRegion(VOID); +#endif -NTKERNELAPI -VOID -NTAPI -KeLeaveCriticalRegion(VOID); +/* Memory Manager Types */ -NTKERNELAPI -DECLSPEC_NORETURN -VOID -NTAPI -KeBugCheck( - IN ULONG BugCheckCode); +typedef struct _PHYSICAL_MEMORY_RANGE { + PHYSICAL_ADDRESS BaseAddress; + LARGE_INTEGER NumberOfBytes; +} PHYSICAL_MEMORY_RANGE, *PPHYSICAL_MEMORY_RANGE; - -#if defined(SINGLE_GROUP_LEGACY_API) - - -NTKERNELAPI -VOID -NTAPI -KeSetTargetProcessorDpc( - IN OUT PRKDPC Dpc, - IN CCHAR Number); - -NTKERNELAPI -KAFFINITY -NTAPI -KeQueryActiveProcessors(VOID); - -#endif /* defined(SINGLE_GROUP_LEGACY_API) */ - - -#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ - -#if (NTDDI_VERSION >= NTDDI_WINXP) -NTKERNELAPI -BOOLEAN -NTAPI -KeAreApcsDisabled(VOID); - - -#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ - - -#if (NTDDI_VERSION >= NTDDI_WS03) - - -NTKERNELAPI -BOOLEAN -NTAPI -KeInvalidateAllCaches(VOID); - -#endif /* (NTDDI_VERSION >= NTDDI_WS03) */ - -#if (NTDDI_VERSION >= NTDDI_WS03SP1) - -NTKERNELAPI -NTSTATUS -NTAPI -KeExpandKernelStackAndCallout( - IN PEXPAND_STACK_CALLOUT Callout, - IN PVOID Parameter OPTIONAL, - IN SIZE_T Size); - -NTKERNELAPI -VOID -NTAPI -KeEnterGuardedRegion(VOID); - -NTKERNELAPI -VOID -NTAPI -KeLeaveGuardedRegion(VOID); - - -#endif /* (NTDDI_VERSION >= NTDDI_WS03SP1) */ - -#if (NTDDI_VERSION >= NTDDI_VISTA) - - -#if defined(SINGLE_GROUP_LEGACY_API) -NTKERNELAPI -ULONG -NTAPI -KeQueryActiveProcessorCount( - OUT PKAFFINITY ActiveProcessors OPTIONAL); - -NTKERNELAPI -ULONG -NTAPI -KeQueryMaximumProcessorCount(VOID); - -#endif /* SINGLE_GROUP_LEGACY_API */ - -#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ - - -#if (NTDDI_VERSION >= NTDDI_WIN7) - -NTKERNELAPI -ULONG -NTAPI -KeQueryActiveProcessorCountEx( - IN USHORT GroupNumber); - -NTKERNELAPI -ULONG -NTAPI -KeQueryMaximumProcessorCountEx( - IN USHORT GroupNumber); - -NTKERNELAPI -USHORT -NTAPI -KeQueryActiveGroupCount(VOID); - -NTKERNELAPI -USHORT -NTAPI -KeQueryMaximumGroupCount(VOID); - -NTKERNELAPI -KAFFINITY -NTAPI -KeQueryGroupAffinity( - IN USHORT GroupNumber); - -NTKERNELAPI -ULONG -NTAPI -KeGetCurrentProcessorNumberEx( - OUT PPROCESSOR_NUMBER ProcNumber OPTIONAL); - -NTKERNELAPI -VOID -NTAPI -KeQueryNodeActiveAffinity( - IN USHORT NodeNumber, - OUT PGROUP_AFFINITY Affinity OPTIONAL, - OUT PUSHORT Count OPTIONAL); - -NTKERNELAPI -USHORT -NTAPI -KeQueryNodeMaximumProcessorCount( - IN USHORT NodeNumber); - -NTKERNELAPI -USHORT -NTAPI -KeQueryHighestNodeNumber(VOID); - -NTKERNELAPI -USHORT -NTAPI -KeGetCurrentNodeNumber(VOID); - -NTKERNELAPI -NTSTATUS -NTAPI -KeQueryLogicalProcessorRelationship( - IN PPROCESSOR_NUMBER ProcessorNumber OPTIONAL, - IN LOGICAL_PROCESSOR_RELATIONSHIP RelationshipType, - OUT PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX Information OPTIONAL, - IN OUT PULONG Length); - -NTKERNELAPI -NTSTATUS -NTAPI -KeSetHardwareCounterConfiguration( - IN PHARDWARE_COUNTER CounterArray, - IN ULONG Count); - -NTKERNELAPI -NTSTATUS -NTAPI -KeQueryHardwareCounterConfiguration( - OUT PHARDWARE_COUNTER CounterArray, - IN ULONG MaximumCount, - OUT PULONG Count); - - -#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ - - -/****************************************************************************** - * Memory manager Functions * - ******************************************************************************/ +/* Memory Manager Functions */ #if (NTDDI_VERSION >= NTDDI_WIN2K) + NTKERNELAPI PPHYSICAL_MEMORY_RANGE NTAPI -MmGetPhysicalMemoryRanges(VOID); +MmGetPhysicalMemoryRanges( + VOID); NTKERNELAPI PHYSICAL_ADDRESS @@ -4426,7 +2523,8 @@ MmIsAddressValid( NTKERNELAPI BOOLEAN NTAPI -MmIsThisAnNtAsSystem(VOID); +MmIsThisAnNtAsSystem( + VOID); NTKERNELAPI VOID @@ -4474,144 +2572,9 @@ MmUnmapVideoDisplay( IN PVOID BaseAddress, IN SIZE_T NumberOfBytes); -NTKERNELAPI -NTSTATUS -NTAPI -MmAddPhysicalMemory( - IN PPHYSICAL_ADDRESS StartAddress, - IN OUT PLARGE_INTEGER NumberOfBytes); - -NTKERNELAPI -PVOID -NTAPI -MmAllocateContiguousMemory( - IN SIZE_T NumberOfBytes, - IN PHYSICAL_ADDRESS HighestAcceptableAddress); - -NTKERNELAPI -PVOID -NTAPI -MmAllocateContiguousMemorySpecifyCache( - IN SIZE_T NumberOfBytes, - IN PHYSICAL_ADDRESS LowestAcceptableAddress, - IN PHYSICAL_ADDRESS HighestAcceptableAddress, - IN PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL, - IN MEMORY_CACHING_TYPE CacheType); - -NTKERNELAPI -PVOID -NTAPI -MmAllocateContiguousMemorySpecifyCacheNode( - IN SIZE_T NumberOfBytes, - IN PHYSICAL_ADDRESS LowestAcceptableAddress, - IN PHYSICAL_ADDRESS HighestAcceptableAddress, - IN PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL, - IN MEMORY_CACHING_TYPE CacheType, - IN NODE_REQUIREMENT PreferredNode); - -NTKERNELAPI -VOID -NTAPI -MmFreeContiguousMemory( - IN PVOID BaseAddress); - -NTKERNELAPI -VOID -NTAPI -MmFreeContiguousMemorySpecifyCache( - IN PVOID BaseAddress, - IN SIZE_T NumberOfBytes, - IN MEMORY_CACHING_TYPE CacheType); - - #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ -#if (NTDDI_VERSION >= NTDDI_WINXP) - -NTKERNELAPI -NTSTATUS -NTAPI -MmAdvanceMdl( - IN OUT PMDL Mdl, - IN ULONG NumberOfBytes); - -NTKERNELAPI -PVOID -NTAPI -MmAllocateMappingAddress( - IN SIZE_T NumberOfBytes, - IN ULONG PoolTag); - -NTKERNELAPI -VOID -NTAPI -MmFreeMappingAddress( - IN PVOID BaseAddress, - IN ULONG PoolTag); - -NTKERNELAPI -NTSTATUS -NTAPI -MmIsVerifierEnabled( - OUT PULONG VerifierFlags); - -NTKERNELAPI -PVOID -NTAPI -MmMapLockedPagesWithReservedMapping( - IN PVOID MappingAddress, - IN ULONG PoolTag, - IN PMDL MemoryDescriptorList, - IN MEMORY_CACHING_TYPE CacheType); - -NTKERNELAPI -NTSTATUS -NTAPI -MmProtectMdlSystemAddress( - IN PMDL MemoryDescriptorList, - IN ULONG NewProtect); - -NTKERNELAPI -VOID -NTAPI -MmUnmapReservedMapping( - IN PVOID BaseAddress, - IN ULONG PoolTag, - IN PMDL MemoryDescriptorList); - -NTKERNELAPI -NTSTATUS -NTAPI -MmAddVerifierThunks( - IN PVOID ThunkBuffer, - IN ULONG ThunkBufferSize); - -#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ - -#if (NTDDI_VERSION >= NTDDI_WS03) -NTKERNELAPI -NTSTATUS -NTAPI -MmCreateMirror(VOID); -#endif - - -#if (NTDDI_VERSION >= NTDDI_VISTA) -NTSTATUS -NTAPI -MmRotatePhysicalView( - IN PVOID VirtualAddress, - IN OUT PSIZE_T NumberOfBytes, - IN PMDLX NewMdl OPTIONAL, - IN MM_ROTATE_DIRECTION Direction, - IN PMM_ROTATE_COPY_CALLBACK_FUNCTION CopyFunction, - IN PVOID Context OPTIONAL); - -#endif - -/****************************************************************************** - * Process Manager Functions * - ******************************************************************************/ +/* NtXxx Functions */ NTSYSCALLAPI NTSTATUS @@ -4632,15 +2595,35 @@ NtQueryInformationProcess( IN ULONG ProcessInformationLength, OUT PULONG ReturnLength OPTIONAL); -#if (NTDDI_VERSION >= NTDDI_WIN2K) +/** Process manager types **/ +typedef VOID +(NTAPI *PCREATE_PROCESS_NOTIFY_ROUTINE)( + IN HANDLE ParentId, + IN HANDLE ProcessId, + IN BOOLEAN Create); + +typedef VOID +(NTAPI *PCREATE_THREAD_NOTIFY_ROUTINE)( + IN HANDLE ProcessId, + IN HANDLE ThreadId, + IN BOOLEAN Create); + +typedef VOID +(NTAPI *PLOAD_IMAGE_NOTIFY_ROUTINE)( + IN PUNICODE_STRING FullImageName, + IN HANDLE ProcessId, + IN PIMAGE_INFO ImageInfo); + +/** Process manager routines **/ + +#if (NTDDI_VERSION >= NTDDI_WIN2K) NTKERNELAPI NTSTATUS NTAPI -PsSetCreateProcessNotifyRoutine( - IN PCREATE_PROCESS_NOTIFY_ROUTINE NotifyRoutine, - IN BOOLEAN Remove); +PsSetLoadImageNotifyRoutine( + IN PLOAD_IMAGE_NOTIFY_ROUTINE NotifyRoutine); NTKERNELAPI NTSTATUS @@ -4651,18 +2634,21 @@ PsSetCreateThreadNotifyRoutine( NTKERNELAPI NTSTATUS NTAPI -PsSetLoadImageNotifyRoutine( - IN PLOAD_IMAGE_NOTIFY_ROUTINE NotifyRoutine); +PsSetCreateProcessNotifyRoutine( + IN PCREATE_PROCESS_NOTIFY_ROUTINE NotifyRoutine, + IN BOOLEAN Remove); NTKERNELAPI HANDLE NTAPI -PsGetCurrentProcessId(VOID); +PsGetCurrentProcessId( + VOID); NTKERNELAPI HANDLE NTAPI -PsGetCurrentThreadId(VOID); +PsGetCurrentThreadId( + VOID); NTKERNELAPI BOOLEAN @@ -4683,12 +2669,6 @@ NTAPI PsGetProcessId( IN PEPROCESS Process); -NTKERNELAPI -HANDLE -NTAPI -PsGetThreadId( - IN PETHREAD Thread); - NTKERNELAPI NTSTATUS NTAPI @@ -4701,187 +2681,102 @@ NTAPI PsRemoveLoadImageNotifyRoutine( IN PLOAD_IMAGE_NOTIFY_ROUTINE NotifyRoutine); -NTKERNELAPI -LONGLONG -NTAPI -PsGetProcessCreateTimeQuadPart( - IN PEPROCESS Process); - #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ -#if (NTDDI_VERSION >= NTDDI_WS03) -NTKERNELAPI -HANDLE -NTAPI -PsGetThreadProcessId( - IN PETHREAD Thread); -#endif /* (NTDDI_VERSION >= NTDDI_WS03) */ +extern NTKERNELAPI PEPROCESS PsInitialSystemProcess; -#if (NTDDI_VERSION >= NTDDI_VISTA) +/* RTL Types */ -NTKERNELAPI -BOOLEAN -NTAPI -PsSetCurrentThreadPrefetching( - IN BOOLEAN Prefetching); +typedef struct _RTL_SPLAY_LINKS { + struct _RTL_SPLAY_LINKS *Parent; + struct _RTL_SPLAY_LINKS *LeftChild; + struct _RTL_SPLAY_LINKS *RightChild; +} RTL_SPLAY_LINKS, *PRTL_SPLAY_LINKS; -NTKERNELAPI -BOOLEAN -NTAPI -PsIsCurrentThreadPrefetching(VOID); +/* RTL Functions */ -#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ +#if (defined(_M_AMD64) || defined(_M_IA64)) && !defined(_REALLY_GET_CALLERS_CALLER_) -#if (NTDDI_VERSION >= NTDDI_VISTASP1) -NTKERNELAPI -NTSTATUS -NTAPI -PsSetCreateProcessNotifyRoutineEx( - IN PCREATE_PROCESS_NOTIFY_ROUTINE_EX NotifyRoutine, - IN BOOLEAN Remove); -#endif /* (NTDDI_VERSION >= NTDDI_VISTASP1) */ -/****************************************************************************** - * Runtime Library Functions * - ******************************************************************************/ +#define RtlGetCallersAddress(CallersAddress, CallersCaller) \ + *CallersAddress = (PVOID)_ReturnAddress(); \ + *CallersCaller = NULL; +#else #if (NTDDI_VERSION >= NTDDI_WIN2K) - - - -#ifndef RTL_USE_AVL_TABLES - NTSYSAPI VOID NTAPI -RtlInitializeGenericTable( - OUT PRTL_GENERIC_TABLE Table, - IN PRTL_GENERIC_COMPARE_ROUTINE CompareRoutine, - IN PRTL_GENERIC_ALLOCATE_ROUTINE AllocateRoutine, - IN PRTL_GENERIC_FREE_ROUTINE FreeRoutine, - IN PVOID TableContext OPTIONAL); +RtlGetCallersAddress( + OUT PVOID *CallersAddress, + OUT PVOID *CallersCaller); +#endif +#endif + +#if !defined(MIDL_PASS) + +FORCEINLINE +LUID +NTAPI_INLINE +RtlConvertLongToLuid( + IN LONG Val) +{ + LUID Luid; + LARGE_INTEGER Temp; + + Temp.QuadPart = Val; + Luid.LowPart = Temp.u.LowPart; + Luid.HighPart = Temp.u.HighPart; + return Luid; +} + +FORCEINLINE +LUID +NTAPI_INLINE +RtlConvertUlongToLuid( + IN ULONG Val) +{ + LUID Luid; + + Luid.LowPart = Val; + Luid.HighPart = 0; + return Luid; +} + +#endif + +#if defined(_AMD64_) || defined(_IA64_) +//DECLSPEC_DEPRECATED_DDK_WINXP +__inline +LARGE_INTEGER +NTAPI_INLINE +RtlLargeIntegerDivide( + IN LARGE_INTEGER Dividend, + IN LARGE_INTEGER Divisor, + OUT PLARGE_INTEGER Remainder OPTIONAL) +{ + LARGE_INTEGER ret; + ret.QuadPart = Dividend.QuadPart / Divisor.QuadPart; + if (Remainder) + Remainder->QuadPart = Dividend.QuadPart % Divisor.QuadPart; + return ret; +} + +#else + +#if (NTDDI_VERSION >= NTDDI_WIN2K) NTSYSAPI -PVOID +LARGE_INTEGER NTAPI -RtlInsertElementGenericTable( - IN PRTL_GENERIC_TABLE Table, - IN PVOID Buffer, - IN CLONG BufferSize, - OUT PBOOLEAN NewElement OPTIONAL); +RtlLargeIntegerDivide( + IN LARGE_INTEGER Dividend, + IN LARGE_INTEGER Divisor, + OUT PLARGE_INTEGER Remainder OPTIONAL); +#endif -NTSYSAPI -PVOID -NTAPI -RtlInsertElementGenericTableFull( - IN PRTL_GENERIC_TABLE Table, - IN PVOID Buffer, - IN CLONG BufferSize, - OUT PBOOLEAN NewElement OPTIONAL, - IN PVOID NodeOrParent, - IN TABLE_SEARCH_RESULT SearchResult); +#endif /* defined(_AMD64_) || defined(_IA64_) */ -NTSYSAPI -BOOLEAN -NTAPI -RtlDeleteElementGenericTable( - IN PRTL_GENERIC_TABLE Table, - IN PVOID Buffer); - -NTSYSAPI -PVOID -NTAPI -RtlLookupElementGenericTable( - IN PRTL_GENERIC_TABLE Table, - IN PVOID Buffer); - -NTSYSAPI -PVOID -NTAPI -RtlLookupElementGenericTableFull( - IN PRTL_GENERIC_TABLE Table, - IN PVOID Buffer, - OUT PVOID *NodeOrParent, - OUT TABLE_SEARCH_RESULT *SearchResult); - -NTSYSAPI -PVOID -NTAPI -RtlEnumerateGenericTable( - IN PRTL_GENERIC_TABLE Table, - IN BOOLEAN Restart); - -NTSYSAPI -PVOID -NTAPI -RtlEnumerateGenericTableWithoutSplaying( - IN PRTL_GENERIC_TABLE Table, - IN OUT PVOID *RestartKey); - -NTSYSAPI -PVOID -NTAPI -RtlGetElementGenericTable( - IN PRTL_GENERIC_TABLE Table, - IN ULONG I); - -NTSYSAPI -ULONG -NTAPI -RtlNumberGenericTableElements( - IN PRTL_GENERIC_TABLE Table); - -NTSYSAPI -BOOLEAN -NTAPI -RtlIsGenericTableEmpty( - IN PRTL_GENERIC_TABLE Table); - -#endif /* !RTL_USE_AVL_TABLES */ - -#define RTL_STACK_WALKING_MODE_FRAMES_TO_SKIP_SHIFT 8 - -NTSYSAPI -PRTL_SPLAY_LINKS -NTAPI -RtlSplay( - IN OUT PRTL_SPLAY_LINKS Links); - -NTSYSAPI -PRTL_SPLAY_LINKS -NTAPI -RtlDelete( - IN PRTL_SPLAY_LINKS Links); - -NTSYSAPI -VOID -NTAPI -RtlDeleteNoSplay( - IN PRTL_SPLAY_LINKS Links, - IN OUT PRTL_SPLAY_LINKS *Root); - -NTSYSAPI -PRTL_SPLAY_LINKS -NTAPI -RtlSubtreeSuccessor( - IN PRTL_SPLAY_LINKS Links); - -NTSYSAPI -PRTL_SPLAY_LINKS -NTAPI -RtlSubtreePredecessor( - IN PRTL_SPLAY_LINKS Links); - -NTSYSAPI -PRTL_SPLAY_LINKS -NTAPI -RtlRealSuccessor( - IN PRTL_SPLAY_LINKS Links); - -NTSYSAPI -PRTL_SPLAY_LINKS -NTAPI -RtlRealPredecessor( - IN PRTL_SPLAY_LINKS Links); +#if (NTDDI_VERSION >= NTDDI_WIN2K) NTSYSAPI BOOLEAN @@ -4940,7 +2835,7 @@ NTAPI RtlCompareString( IN const PSTRING String1, IN const PSTRING String2, - IN BOOLEAN CaseInSensitive); + BOOLEAN CaseInSensitive); NTSYSAPI VOID @@ -4979,513 +2874,9 @@ RtlWalkFrameChain( IN ULONG Count, IN ULONG Flags); - - #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ - -#if (NTDDI_VERSION >= NTDDI_WINXP) - - -NTSYSAPI -VOID -NTAPI -RtlInitializeGenericTableAvl( - OUT PRTL_AVL_TABLE Table, - IN PRTL_AVL_COMPARE_ROUTINE CompareRoutine, - IN PRTL_AVL_ALLOCATE_ROUTINE AllocateRoutine, - IN PRTL_AVL_FREE_ROUTINE FreeRoutine, - IN PVOID TableContext OPTIONAL); - -NTSYSAPI -PVOID -NTAPI -RtlInsertElementGenericTableAvl( - IN PRTL_AVL_TABLE Table, - IN PVOID Buffer, - IN CLONG BufferSize, - OUT PBOOLEAN NewElement OPTIONAL); - -NTSYSAPI -PVOID -NTAPI -RtlInsertElementGenericTableFullAvl( - IN PRTL_AVL_TABLE Table, - IN PVOID Buffer, - IN CLONG BufferSize, - OUT PBOOLEAN NewElement OPTIONAL, - IN PVOID NodeOrParent, - IN TABLE_SEARCH_RESULT SearchResult); - -NTSYSAPI -BOOLEAN -NTAPI -RtlDeleteElementGenericTableAvl( - IN PRTL_AVL_TABLE Table, - IN PVOID Buffer); - -NTSYSAPI -PVOID -NTAPI -RtlLookupElementGenericTableAvl( - IN PRTL_AVL_TABLE Table, - IN PVOID Buffer); - -NTSYSAPI -PVOID -NTAPI -RtlLookupElementGenericTableFullAvl( - IN PRTL_AVL_TABLE Table, - IN PVOID Buffer, - OUT PVOID *NodeOrParent, - OUT TABLE_SEARCH_RESULT *SearchResult); - -NTSYSAPI -PVOID -NTAPI -RtlEnumerateGenericTableAvl( - IN PRTL_AVL_TABLE Table, - IN BOOLEAN Restart); - -NTSYSAPI -PVOID -NTAPI -RtlEnumerateGenericTableWithoutSplayingAvl( - IN PRTL_AVL_TABLE Table, - IN OUT PVOID *RestartKey); - -NTSYSAPI -PVOID -NTAPI -RtlLookupFirstMatchingElementGenericTableAvl( - IN PRTL_AVL_TABLE Table, - IN PVOID Buffer, - OUT PVOID *RestartKey); - -NTSYSAPI -PVOID -NTAPI -RtlEnumerateGenericTableLikeADirectory( - IN PRTL_AVL_TABLE Table, - IN PRTL_AVL_MATCH_FUNCTION MatchFunction OPTIONAL, - IN PVOID MatchData OPTIONAL, - IN ULONG NextFlag, - IN OUT PVOID *RestartKey, - IN OUT PULONG DeleteCount, - IN PVOID Buffer); - -NTSYSAPI -PVOID -NTAPI -RtlGetElementGenericTableAvl( - IN PRTL_AVL_TABLE Table, - IN ULONG I); - -NTSYSAPI -ULONG -NTAPI -RtlNumberGenericTableElementsAvl( - IN PRTL_AVL_TABLE Table); - -NTSYSAPI -BOOLEAN -NTAPI -RtlIsGenericTableEmptyAvl( - IN PRTL_AVL_TABLE Table); - - - -#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ - -#if (NTDDI_VERSION >= NTDDI_VISTA) - - -NTSYSAPI -VOID -NTAPI -RtlRunOnceInitialize( - OUT PRTL_RUN_ONCE RunOnce); - -NTSYSAPI -NTSTATUS -NTAPI -RtlRunOnceExecuteOnce( - IN OUT PRTL_RUN_ONCE RunOnce, - IN PRTL_RUN_ONCE_INIT_FN InitFn, - IN OUT PVOID Parameter OPTIONAL, - OUT PVOID *Context OPTIONAL); - -NTSYSAPI -NTSTATUS -NTAPI -RtlRunOnceBeginInitialize( - IN OUT PRTL_RUN_ONCE RunOnce, - IN ULONG Flags, - OUT PVOID *Context OPTIONAL); - -NTSYSAPI -NTSTATUS -NTAPI -RtlRunOnceComplete( - IN OUT PRTL_RUN_ONCE RunOnce, - IN ULONG Flags, - IN PVOID Context OPTIONAL); - -NTSYSAPI -BOOLEAN -NTAPI -RtlGetProductInfo( - IN ULONG OSMajorVersion, - IN ULONG OSMinorVersion, - IN ULONG SpMajorVersion, - IN ULONG SpMinorVersion, - OUT PULONG ReturnedProductType); - - - -#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ - -#if (NTDDI_VERSION >= NTDDI_WIN7) - - -NTSYSAPI -BOOLEAN -NTAPI -RtlCreateHashTable( - IN OUT PRTL_DYNAMIC_HASH_TABLE *HashTable OPTIONAL, - IN ULONG Shift, - IN ULONG Flags); - -NTSYSAPI -VOID -NTAPI -RtlDeleteHashTable( - IN PRTL_DYNAMIC_HASH_TABLE HashTable); - -NTSYSAPI -BOOLEAN -NTAPI -RtlInsertEntryHashTable( - IN PRTL_DYNAMIC_HASH_TABLE HashTable, - IN PRTL_DYNAMIC_HASH_TABLE_ENTRY Entry, - IN ULONG_PTR Signature, - IN OUT PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context OPTIONAL); - -NTSYSAPI -BOOLEAN -NTAPI -RtlRemoveEntryHashTable( - IN PRTL_DYNAMIC_HASH_TABLE HashTable, - IN PRTL_DYNAMIC_HASH_TABLE_ENTRY Entry, - IN OUT PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context OPTIONAL); - -NTSYSAPI -PRTL_DYNAMIC_HASH_TABLE_ENTRY -NTAPI -RtlLookupEntryHashTable( - IN PRTL_DYNAMIC_HASH_TABLE HashTable, - IN ULONG_PTR Signature, - OUT PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context OPTIONAL); - -NTSYSAPI -PRTL_DYNAMIC_HASH_TABLE_ENTRY -NTAPI -RtlGetNextEntryHashTable( - IN PRTL_DYNAMIC_HASH_TABLE HashTable, - IN PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context); - -NTSYSAPI -BOOLEAN -NTAPI -RtlInitEnumerationHashTable( - IN PRTL_DYNAMIC_HASH_TABLE HashTable, - OUT PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator); - -NTSYSAPI -PRTL_DYNAMIC_HASH_TABLE_ENTRY -NTAPI -RtlEnumerateEntryHashTable( - IN PRTL_DYNAMIC_HASH_TABLE HashTable, - IN OUT PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator); - -NTSYSAPI -VOID -NTAPI -RtlEndEnumerationHashTable( - IN PRTL_DYNAMIC_HASH_TABLE HashTable, - IN OUT PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator); - -NTSYSAPI -BOOLEAN -NTAPI -RtlInitWeakEnumerationHashTable( - IN PRTL_DYNAMIC_HASH_TABLE HashTable, - OUT PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator); - -NTSYSAPI -PRTL_DYNAMIC_HASH_TABLE_ENTRY -NTAPI -RtlWeaklyEnumerateEntryHashTable( - IN PRTL_DYNAMIC_HASH_TABLE HashTable, - IN OUT PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator); - -NTSYSAPI -VOID -NTAPI -RtlEndWeakEnumerationHashTable( - IN PRTL_DYNAMIC_HASH_TABLE HashTable, - IN OUT PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator); - -NTSYSAPI -BOOLEAN -NTAPI -RtlExpandHashTable( - IN PRTL_DYNAMIC_HASH_TABLE HashTable); - -NTSYSAPI -BOOLEAN -NTAPI -RtlContractHashTable( - IN PRTL_DYNAMIC_HASH_TABLE HashTable); - - - -#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ - - -#if defined(_AMD64_) || defined(_IA64_) - - - -//DECLSPEC_DEPRECATED_DDK_WINXP -FORCEINLINE -LARGE_INTEGER -NTAPI_INLINE -RtlLargeIntegerDivide( - IN LARGE_INTEGER Dividend, - IN LARGE_INTEGER Divisor, - OUT PLARGE_INTEGER Remainder OPTIONAL) -{ - LARGE_INTEGER ret; - ret.QuadPart = Dividend.QuadPart / Divisor.QuadPart; - if (Remainder) - Remainder->QuadPart = Dividend.QuadPart % Divisor.QuadPart; - return ret; -} - -#else - -#if (NTDDI_VERSION >= NTDDI_WIN2K) -NTSYSAPI -LARGE_INTEGER -NTAPI -RtlLargeIntegerDivide( - IN LARGE_INTEGER Dividend, - IN LARGE_INTEGER Divisor, - OUT PLARGE_INTEGER Remainder OPTIONAL); -#endif - - -#endif /* defined(_AMD64_) || defined(_IA64_) */ - - - -#ifdef RTL_USE_AVL_TABLES - -#define RtlInitializeGenericTable RtlInitializeGenericTableAvl -#define RtlInsertElementGenericTable RtlInsertElementGenericTableAvl -#define RtlInsertElementGenericTableFull RtlInsertElementGenericTableFullAvl -#define RtlDeleteElementGenericTable RtlDeleteElementGenericTableAvl -#define RtlLookupElementGenericTable RtlLookupElementGenericTableAvl -#define RtlLookupElementGenericTableFull RtlLookupElementGenericTableFullAvl -#define RtlEnumerateGenericTable RtlEnumerateGenericTableAvl -#define RtlEnumerateGenericTableWithoutSplaying RtlEnumerateGenericTableWithoutSplayingAvl -#define RtlGetElementGenericTable RtlGetElementGenericTableAvl -#define RtlNumberGenericTableElements RtlNumberGenericTableElementsAvl -#define RtlIsGenericTableEmpty RtlIsGenericTableEmptyAvl - -#endif /* RTL_USE_AVL_TABLES */ - -#define RtlInitializeSplayLinks(Links) { \ - PRTL_SPLAY_LINKS _SplayLinks; \ - _SplayLinks = (PRTL_SPLAY_LINKS)(Links); \ - _SplayLinks->Parent = _SplayLinks; \ - _SplayLinks->LeftChild = NULL; \ - _SplayLinks->RightChild = NULL; \ -} - -#define RtlIsLeftChild(Links) \ - (RtlLeftChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links)) - -#define RtlIsRightChild(Links) \ - (RtlRightChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links)) - -#define RtlRightChild(Links) \ - ((PRTL_SPLAY_LINKS)(Links))->RightChild - -#define RtlIsRoot(Links) \ - (RtlParent(Links) == (PRTL_SPLAY_LINKS)(Links)) - -#define RtlLeftChild(Links) \ - ((PRTL_SPLAY_LINKS)(Links))->LeftChild - -#define RtlParent(Links) \ - ((PRTL_SPLAY_LINKS)(Links))->Parent - -#define RtlInsertAsLeftChild(ParentLinks,ChildLinks) \ - { \ - PRTL_SPLAY_LINKS _SplayParent; \ - PRTL_SPLAY_LINKS _SplayChild; \ - _SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \ - _SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks); \ - _SplayParent->LeftChild = _SplayChild; \ - _SplayChild->Parent = _SplayParent; \ - } - -#define RtlInsertAsRightChild(ParentLinks,ChildLinks) \ - { \ - PRTL_SPLAY_LINKS _SplayParent; \ - PRTL_SPLAY_LINKS _SplayChild; \ - _SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \ - _SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks); \ - _SplayParent->RightChild = _SplayChild; \ - _SplayChild->Parent = _SplayParent; \ - } - -#if !defined(MIDL_PASS) - -FORCEINLINE -LUID -NTAPI_INLINE -RtlConvertLongToLuid( - IN LONG Val) -{ - LUID Luid; - LARGE_INTEGER Temp; - - Temp.QuadPart = Val; - Luid.LowPart = Temp.u.LowPart; - Luid.HighPart = Temp.u.HighPart; - return Luid; -} - -FORCEINLINE -LUID -NTAPI_INLINE -RtlConvertUlongToLuid( - IN ULONG Val) -{ - LUID Luid; - - Luid.LowPart = Val; - Luid.HighPart = 0; - return Luid; -} - -#endif /* !defined(MIDL_PASS) */ - -#if (defined(_M_AMD64) || defined(_M_IA64)) && !defined(_REALLY_GET_CALLERS_CALLER_) -#define RtlGetCallersAddress(CallersAddress, CallersCaller) \ - *CallersAddress = (PVOID)_ReturnAddress(); \ - *CallersCaller = NULL; -#else -#if (NTDDI_VERSION >= NTDDI_WIN2K) -NTSYSAPI -VOID -NTAPI -RtlGetCallersAddress( - OUT PVOID *CallersAddress, - OUT PVOID *CallersCaller); -#endif -#endif - -#if !defined(MIDL_PASS) && !defined(SORTPP_PASS) - -#if (NTDDI_VERSION >= NTDDI_WIN7) - -FORCEINLINE -VOID -NTAPI -RtlInitHashTableContext( - IN OUT PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context) -{ - Context->ChainHead = NULL; - Context->PrevLinkage = NULL; -} - -FORCEINLINE -VOID -NTAPI -RtlInitHashTableContextFromEnumerator( - IN OUT PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context, - IN PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator) -{ - Context->ChainHead = Enumerator->ChainHead; - Context->PrevLinkage = Enumerator->HashEntry.Linkage.Blink; -} - -FORCEINLINE -VOID -NTAPI -RtlReleaseHashTableContext( - IN OUT PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context) -{ - UNREFERENCED_PARAMETER(Context); - return; -} - -FORCEINLINE -ULONG -NTAPI -RtlTotalBucketsHashTable( - IN PRTL_DYNAMIC_HASH_TABLE HashTable) -{ - return HashTable->TableSize; -} - -FORCEINLINE -ULONG -NTAPI -RtlNonEmptyBucketsHashTable( - IN PRTL_DYNAMIC_HASH_TABLE HashTable) -{ - return HashTable->NonEmptyBuckets; -} - -FORCEINLINE -ULONG -NTAPI -RtlEmptyBucketsHashTable( - IN PRTL_DYNAMIC_HASH_TABLE HashTable) -{ - return HashTable->TableSize - HashTable->NonEmptyBuckets; -} - -FORCEINLINE -ULONG -NTAPI -RtlTotalEntriesHashTable( - IN PRTL_DYNAMIC_HASH_TABLE HashTable) -{ - return HashTable->NumEntries; -} - -FORCEINLINE -ULONG -NTAPI -RtlActiveEnumeratorsHashTable( - IN PRTL_DYNAMIC_HASH_TABLE HashTable) -{ - return HashTable->NumEnumerators; -} - -#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ - -#endif /* !defined(MIDL_PASS) && !defined(SORTPP_PASS) */ - -/****************************************************************************** - * Security Manager Functions * - ******************************************************************************/ +/* Security reference monitor routines */ #if (NTDDI_VERSION >= NTDDI_WIN2K) NTKERNELAPI @@ -5494,42 +2885,12 @@ NTAPI SeSinglePrivilegeCheck( IN LUID PrivilegeValue, IN KPROCESSOR_MODE PreviousMode); +#endif - -#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ - -/****************************************************************************** - * ZwXxx Functions * - ******************************************************************************/ - - - -NTSYSAPI -NTSTATUS -NTAPI -ZwAllocateLocallyUniqueId( - OUT PLUID Luid); - -NTSYSAPI -NTSTATUS -NTAPI -ZwTerminateProcess( - IN HANDLE ProcessHandle OPTIONAL, - IN NTSTATUS ExitStatus); - -NTSYSAPI -NTSTATUS -NTAPI -ZwOpenProcess( - OUT PHANDLE ProcessHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes, - IN PCLIENT_ID ClientId OPTIONAL); - +/* ZwXxx Functions */ #if (NTDDI_VERSION >= NTDDI_WIN2K) - NTSTATUS NTAPI ZwCancelTimer( @@ -5571,190 +2932,12 @@ ZwSetTimer( IN LONG Period OPTIONAL, OUT PBOOLEAN PreviousState OPTIONAL); -NTSYSAPI -NTSTATUS -NTAPI -ZwDisplayString( - IN PUNICODE_STRING String); - -NTSYSAPI -NTSTATUS -NTAPI -ZwPowerInformation( - IN POWER_INFORMATION_LEVEL PowerInformationLevel, - IN PVOID InputBuffer OPTIONAL, - IN ULONG InputBufferLength, - OUT PVOID OutputBuffer OPTIONAL, - IN ULONG OutputBufferLength); - -NTSYSAPI -NTSTATUS -NTAPI -ZwQueryVolumeInformationFile( - IN HANDLE FileHandle, - OUT PIO_STATUS_BLOCK IoStatusBlock, - OUT PVOID FsInformation, - IN ULONG Length, - IN FS_INFORMATION_CLASS FsInformationClass); - -NTSYSAPI -NTSTATUS -NTAPI -ZwDeviceIoControlFile( - IN HANDLE FileHandle, - IN HANDLE Event OPTIONAL, - IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, - IN PVOID ApcContext OPTIONAL, - OUT PIO_STATUS_BLOCK IoStatusBlock, - IN ULONG IoControlCode, - IN PVOID InputBuffer OPTIONAL, - IN ULONG InputBufferLength, - OUT PVOID OutputBuffer OPTIONAL, - IN ULONG OutputBufferLength); - - - -#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ - - -#if (NTDDI_VERSION >= NTDDI_WIN7) - -NTSTATUS -NTAPI -ZwSetTimerEx( - IN HANDLE TimerHandle, - IN TIMER_SET_INFORMATION_CLASS TimerSetInformationClass, - IN OUT PVOID TimerSetInformation, - IN ULONG TimerSetInformationLength); - - -#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ - - - -/* UNSORTED */ - -#define VER_SET_CONDITION(ConditionMask, TypeBitMask, ComparisonType) \ - ((ConditionMask) = VerSetConditionMask((ConditionMask), \ - (TypeBitMask), (ComparisonType))) - -#if (NTDDI_VERSION >= NTDDI_WIN2K) -NTSYSAPI -ULONGLONG -NTAPI -VerSetConditionMask( - IN ULONGLONG ConditionMask, - IN ULONG TypeMask, - IN UCHAR Condition); #endif -typedef struct _KERNEL_USER_TIMES { - LARGE_INTEGER CreateTime; - LARGE_INTEGER ExitTime; - LARGE_INTEGER KernelTime; - LARGE_INTEGER UserTime; -} KERNEL_USER_TIMES, *PKERNEL_USER_TIMES; - -/* NtXxx Functions */ - -typedef enum _SYSTEM_FIRMWARE_TABLE_ACTION { - SystemFirmwareTable_Enumerate, - SystemFirmwareTable_Get -} SYSTEM_FIRMWARE_TABLE_ACTION; - -typedef struct _SYSTEM_FIRMWARE_TABLE_INFORMATION { - ULONG ProviderSignature; - SYSTEM_FIRMWARE_TABLE_ACTION Action; - ULONG TableID; - ULONG TableBufferLength; - UCHAR TableBuffer[ANYSIZE_ARRAY]; -} SYSTEM_FIRMWARE_TABLE_INFORMATION, *PSYSTEM_FIRMWARE_TABLE_INFORMATION; - -typedef NTSTATUS -(__cdecl *PFNFTH)( - IN OUT PSYSTEM_FIRMWARE_TABLE_INFORMATION SystemFirmwareTableInfo); - -typedef struct _SYSTEM_FIRMWARE_TABLE_HANDLER { - ULONG ProviderSignature; - BOOLEAN Register; - PFNFTH FirmwareTableHandler; - PVOID DriverObject; -} SYSTEM_FIRMWARE_TABLE_HANDLER, *PSYSTEM_FIRMWARE_TABLE_HANDLER; - -typedef ULONG_PTR -(NTAPI *PDRIVER_VERIFIER_THUNK_ROUTINE)( - IN PVOID Context); - -typedef struct _DRIVER_VERIFIER_THUNK_PAIRS { - PDRIVER_VERIFIER_THUNK_ROUTINE PristineRoutine; - PDRIVER_VERIFIER_THUNK_ROUTINE NewRoutine; -} DRIVER_VERIFIER_THUNK_PAIRS, *PDRIVER_VERIFIER_THUNK_PAIRS; - -#define DRIVER_VERIFIER_SPECIAL_POOLING 0x0001 -#define DRIVER_VERIFIER_FORCE_IRQL_CHECKING 0x0002 -#define DRIVER_VERIFIER_INJECT_ALLOCATION_FAILURES 0x0004 -#define DRIVER_VERIFIER_TRACK_POOL_ALLOCATIONS 0x0008 -#define DRIVER_VERIFIER_IO_CHECKING 0x0010 - -#define SHARED_GLOBAL_FLAGS_ERROR_PORT_V 0x0 -#define SHARED_GLOBAL_FLAGS_ERROR_PORT (1UL << SHARED_GLOBAL_FLAGS_ERROR_PORT_V) - -#define SHARED_GLOBAL_FLAGS_ELEVATION_ENABLED_V 0x1 -#define SHARED_GLOBAL_FLAGS_ELEVATION_ENABLED (1UL << SHARED_GLOBAL_FLAGS_ELEVATION_ENABLED_V) - -#define SHARED_GLOBAL_FLAGS_VIRT_ENABLED_V 0x2 -#define SHARED_GLOBAL_FLAGS_VIRT_ENABLED (1UL << SHARED_GLOBAL_FLAGS_VIRT_ENABLED_V) - -#define SHARED_GLOBAL_FLAGS_INSTALLER_DETECT_ENABLED_V 0x3 -#define SHARED_GLOBAL_FLAGS_INSTALLER_DETECT_ENABLED \ - (1UL << SHARED_GLOBAL_FLAGS_INSTALLER_DETECT_ENABLED_V) - -#define SHARED_GLOBAL_FLAGS_SPARE_V 0x4 -#define SHARED_GLOBAL_FLAGS_SPARE \ - (1UL << SHARED_GLOBAL_FLAGS_SPARE_V) - -#define SHARED_GLOBAL_FLAGS_DYNAMIC_PROC_ENABLED_V 0x5 -#define SHARED_GLOBAL_FLAGS_DYNAMIC_PROC_ENABLED \ - (1UL << SHARED_GLOBAL_FLAGS_DYNAMIC_PROC_ENABLED_V) - -#define SHARED_GLOBAL_FLAGS_SEH_VALIDATION_ENABLED_V 0x6 -#define SHARED_GLOBAL_FLAGS_SEH_VALIDATION_ENABLED \ - (1UL << SHARED_GLOBAL_FLAGS_SEH_VALIDATION_ENABLED_V) - -#define EX_INIT_BITS(Flags, Bit) \ - *((Flags)) |= (Bit) // Safe to use before concurrently accessible - -#define EX_TEST_SET_BIT(Flags, Bit) \ - InterlockedBitTestAndSet ((PLONG)(Flags), (Bit)) - -#define EX_TEST_CLEAR_BIT(Flags, Bit) \ - InterlockedBitTestAndReset ((PLONG)(Flags), (Bit)) - -#define PCCARD_MAP_ERROR 0x01 -#define PCCARD_DEVICE_PCI 0x10 - -#define PCCARD_SCAN_DISABLED 0x01 -#define PCCARD_MAP_ZERO 0x02 -#define PCCARD_NO_TIMER 0x03 -#define PCCARD_NO_PIC 0x04 -#define PCCARD_NO_LEGACY_BASE 0x05 -#define PCCARD_DUP_LEGACY_BASE 0x06 -#define PCCARD_NO_CONTROLLERS 0x07 - -#define MAXIMUM_EXPANSION_SIZE (KERNEL_LARGE_STACK_SIZE - (PAGE_SIZE / 2)) - -/* Filesystem runtime library routines */ - -#if (NTDDI_VERSION >= NTDDI_WIN2K) -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlIsTotalDeviceFailure( - IN NTSTATUS Status); -#endif - -/* FIXME : These definitions below doesn't belong to NTDDK */ #ifdef __cplusplus } #endif + + +#endif /* _NTDDK_ */ diff --git a/reactos/include/ddk/ntifs.h b/reactos/include/ddk/ntifs.h index 7e14da769e7..5f032726d38 100644 --- a/reactos/include/ddk/ntifs.h +++ b/reactos/include/ddk/ntifs.h @@ -25,10 +25,32 @@ #define _NTIFS_INCLUDED_ #define _GNU_NTIFS_ +/* Helper macro to enable gcc's extension. */ +#ifndef __GNU_EXTENSION +#ifdef __GNUC__ +#define __GNU_EXTENSION __extension__ +#else +#define __GNU_EXTENSION +#endif +#endif + #ifdef __cplusplus extern "C" { #endif +#if !defined(_NTHALDLL_) && !defined(_BLDR_) +#define NTHALAPI DECLSPEC_IMPORT +#else +#define NTHALAPI +#endif + +/* For ReactOS */ +#if !defined(_NTOSKRNL_) && !defined(_BLDR_) +#define NTKERNELAPI DECLSPEC_IMPORT +#else +#define NTKERNELAPI +#endif + /* Dependencies */ #include #include @@ -54,6 +76,16 @@ extern "C" { #define ClearFlag(_F,_SF) ((_F) &= ~(_SF)) #endif +#define PsGetCurrentProcess IoGetCurrentProcess + +#if (NTDDI_VERSION >= NTDDI_VISTA) +extern NTSYSAPI volatile CCHAR KeNumberProcessors; +#elif (NTDDI_VERSION >= NTDDI_WINXP) +extern NTSYSAPI CCHAR KeNumberProcessors; +#else +extern PCCHAR KeNumberProcessors; +#endif + typedef UNICODE_STRING LSA_UNICODE_STRING, *PLSA_UNICODE_STRING; typedef STRING LSA_STRING, *PLSA_STRING; typedef OBJECT_ATTRIBUTES LSA_OBJECT_ATTRIBUTES, *PLSA_OBJECT_ATTRIBUTES; @@ -719,6 +751,8 @@ typedef enum _OBJECT_INFORMATION_CLASS { MaxObjectInfoClass /* FIXME, not in WDK */ } OBJECT_INFORMATION_CLASS; +#if (NTDDI_VERSION >= NTDDI_NT4) + NTSYSCALLAPI NTSTATUS NTAPI @@ -729,6 +763,8 @@ NtQueryObject( IN ULONG ObjectInformationLength, OUT PULONG ReturnLength OPTIONAL); +#endif + #if (NTDDI_VERSION >= NTDDI_WIN2K) NTSYSCALLAPI @@ -2378,11 +2414,95 @@ extern const PRTL_REALLOCATE_STRING_ROUTINE RtlReallocateStringRoutine; #define RTL_SYSTEM_VOLUME_INFORMATION_FOLDER L"System Volume Information" +#define DEVICE_TYPE ULONG + +#define FILE_DEVICE_BEEP 0x00000001 +#define FILE_DEVICE_CD_ROM 0x00000002 +#define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003 +#define FILE_DEVICE_CONTROLLER 0x00000004 +#define FILE_DEVICE_DATALINK 0x00000005 +#define FILE_DEVICE_DFS 0x00000006 +#define FILE_DEVICE_DISK 0x00000007 +#define FILE_DEVICE_DISK_FILE_SYSTEM 0x00000008 +#define FILE_DEVICE_FILE_SYSTEM 0x00000009 +#define FILE_DEVICE_INPORT_PORT 0x0000000a +#define FILE_DEVICE_KEYBOARD 0x0000000b +#define FILE_DEVICE_MAILSLOT 0x0000000c +#define FILE_DEVICE_MIDI_IN 0x0000000d +#define FILE_DEVICE_MIDI_OUT 0x0000000e +#define FILE_DEVICE_MOUSE 0x0000000f +#define FILE_DEVICE_MULTI_UNC_PROVIDER 0x00000010 +#define FILE_DEVICE_NAMED_PIPE 0x00000011 +#define FILE_DEVICE_NETWORK 0x00000012 +#define FILE_DEVICE_NETWORK_BROWSER 0x00000013 +#define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014 +#define FILE_DEVICE_NULL 0x00000015 +#define FILE_DEVICE_PARALLEL_PORT 0x00000016 +#define FILE_DEVICE_PHYSICAL_NETCARD 0x00000017 +#define FILE_DEVICE_PRINTER 0x00000018 +#define FILE_DEVICE_SCANNER 0x00000019 +#define FILE_DEVICE_SERIAL_MOUSE_PORT 0x0000001a +#define FILE_DEVICE_SERIAL_PORT 0x0000001b +#define FILE_DEVICE_SCREEN 0x0000001c +#define FILE_DEVICE_SOUND 0x0000001d +#define FILE_DEVICE_STREAMS 0x0000001e +#define FILE_DEVICE_TAPE 0x0000001f +#define FILE_DEVICE_TAPE_FILE_SYSTEM 0x00000020 +#define FILE_DEVICE_TRANSPORT 0x00000021 +#define FILE_DEVICE_UNKNOWN 0x00000022 +#define FILE_DEVICE_VIDEO 0x00000023 +#define FILE_DEVICE_VIRTUAL_DISK 0x00000024 +#define FILE_DEVICE_WAVE_IN 0x00000025 +#define FILE_DEVICE_WAVE_OUT 0x00000026 +#define FILE_DEVICE_8042_PORT 0x00000027 +#define FILE_DEVICE_NETWORK_REDIRECTOR 0x00000028 +#define FILE_DEVICE_BATTERY 0x00000029 +#define FILE_DEVICE_BUS_EXTENDER 0x0000002a +#define FILE_DEVICE_MODEM 0x0000002b +#define FILE_DEVICE_VDM 0x0000002c +#define FILE_DEVICE_MASS_STORAGE 0x0000002d +#define FILE_DEVICE_SMB 0x0000002e +#define FILE_DEVICE_KS 0x0000002f +#define FILE_DEVICE_CHANGER 0x00000030 +#define FILE_DEVICE_SMARTCARD 0x00000031 +#define FILE_DEVICE_ACPI 0x00000032 +#define FILE_DEVICE_DVD 0x00000033 +#define FILE_DEVICE_FULLSCREEN_VIDEO 0x00000034 +#define FILE_DEVICE_DFS_FILE_SYSTEM 0x00000035 +#define FILE_DEVICE_DFS_VOLUME 0x00000036 +#define FILE_DEVICE_SERENUM 0x00000037 +#define FILE_DEVICE_TERMSRV 0x00000038 +#define FILE_DEVICE_KSEC 0x00000039 +#define FILE_DEVICE_FIPS 0x0000003A +#define FILE_DEVICE_INFINIBAND 0x0000003B +#define FILE_DEVICE_VMBUS 0x0000003E +#define FILE_DEVICE_CRYPT_PROVIDER 0x0000003F +#define FILE_DEVICE_WPD 0x00000040 +#define FILE_DEVICE_BLUETOOTH 0x00000041 +#define FILE_DEVICE_MT_COMPOSITE 0x00000042 +#define FILE_DEVICE_MT_TRANSPORT 0x00000043 +#define FILE_DEVICE_BIOMETRIC 0x00000044 +#define FILE_DEVICE_PMI 0x00000045 + +#define CTL_CODE(DeviceType, Function, Method, Access) \ + (((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method)) + +#define DEVICE_TYPE_FROM_CTL_CODE(ctl) (((ULONG) (ctl & 0xffff0000)) >> 16) + #define METHOD_FROM_CTL_CODE(ctrlCode) ((ULONG)(ctrlCode & 3)) +#define METHOD_BUFFERED 0 +#define METHOD_IN_DIRECT 1 +#define METHOD_OUT_DIRECT 2 +#define METHOD_NEITHER 3 #define METHOD_DIRECT_TO_HARDWARE METHOD_IN_DIRECT #define METHOD_DIRECT_FROM_HARDWARE METHOD_OUT_DIRECT +#define FILE_ANY_ACCESS 0x00000000 +#define FILE_SPECIAL_ACCESS FILE_ANY_ACCESS +#define FILE_READ_ACCESS 0x00000001 +#define FILE_WRITE_ACCESS 0x00000002 + typedef ULONG LSA_OPERATIONAL_MODE, *PLSA_OPERATIONAL_MODE; typedef enum _SECURITY_LOGON_TYPE { @@ -4553,8 +4673,6 @@ typedef struct _KAPC_STATE { #define KAPC_STATE_ACTUAL_LENGTH (FIELD_OFFSET(KAPC_STATE, UserApcPending) + sizeof(BOOLEAN)) -#define ASSERT_QUEUE(Q) ASSERT(((Q)->Header.Type & KOBJECT_TYPE_MASK) == QueueObject); - typedef struct _KQUEUE { DISPATCHER_HEADER Header; LIST_ENTRY EntryListHead; @@ -4689,7 +4807,7 @@ FASTCALL KeAcquireQueuedSpinLock( IN OUT KSPIN_LOCK_QUEUE_NUMBER Number); -_DECL_HAL_KE_IMPORT +NTHALAPI VOID FASTCALL KeReleaseQueuedSpinLock( @@ -4904,6 +5022,24 @@ typedef NTSTATUS #if (NTDDI_VERSION >= NTDDI_WIN2K) +NTKERNELAPI +VOID +NTAPI +SeCaptureSubjectContext( + OUT PSECURITY_SUBJECT_CONTEXT SubjectContext); + +NTKERNELAPI +VOID +NTAPI +SeLockSubjectContext( + IN PSECURITY_SUBJECT_CONTEXT SubjectContext); + +NTKERNELAPI +VOID +NTAPI +SeUnlockSubjectContext( + IN PSECURITY_SUBJECT_CONTEXT SubjectContext); + NTKERNELAPI VOID NTAPI @@ -5317,6 +5453,18 @@ SeLocateProcessImageName( extern NTKERNELAPI PSE_EXPORTS SeExports; +#if !defined(_PSGETCURRENTTHREAD_) +#define _PSGETCURRENTTHREAD_ + +FORCEINLINE +PETHREAD +PsGetCurrentThread( + VOID) +{ + return (PETHREAD)KeGetCurrentThread(); +} +#endif + #if (NTDDI_VERSION >= NTDDI_WIN2K) NTKERNELAPI @@ -5386,20 +5534,7 @@ PsReturnPoolQuota( IN POOL_TYPE PoolType, IN ULONG_PTR Amount); -NTKERNELAPI -NTSTATUS -NTAPI -PsAssignImpersonationToken( - IN PETHREAD Thread, - IN HANDLE Token OPTIONAL); - -NTKERNELAPI -HANDLE -NTAPI -PsReferencePrimaryToken( - IN OUT PEPROCESS Process); - -#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ +#endif #if (NTDDI_VERSION >= NTDDI_WINXP) @@ -5688,6 +5823,18 @@ IoPageRead( IN PKEVENT Event, OUT PIO_STATUS_BLOCK IoStatusBlock); +NTKERNELAPI +PDEVICE_OBJECT +NTAPI +IoGetAttachedDevice( + IN PDEVICE_OBJECT DeviceObject); + +NTKERNELAPI +PDEVICE_OBJECT +NTAPI +IoGetAttachedDeviceReference( + IN PDEVICE_OBJECT DeviceObject); + NTKERNELAPI PDEVICE_OBJECT NTAPI @@ -5804,6 +5951,42 @@ NTAPI IoSetTopLevelIrp( IN PIRP Irp OPTIONAL); +NTKERNELAPI +VOID +NTAPI +IoStartNextPacket( + IN PDEVICE_OBJECT DeviceObject, + IN BOOLEAN Cancelable); + +NTKERNELAPI +VOID +NTAPI +IoStartNextPacketByKey( + IN PDEVICE_OBJECT DeviceObject, + IN BOOLEAN Cancelable, + IN ULONG Key); + +NTKERNELAPI +VOID +NTAPI +IoStartPacket( + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp, + IN PULONG Key OPTIONAL, + IN PDRIVER_CANCEL CancelFunction OPTIONAL); + +NTKERNELAPI +VOID +NTAPI +IoStartTimer( + IN PDEVICE_OBJECT DeviceObject); + +NTKERNELAPI +VOID +NTAPI +IoStopTimer( + IN PDEVICE_OBJECT DeviceObject); + NTKERNELAPI NTSTATUS NTAPI @@ -5840,6 +6023,12 @@ IoVerifyVolume( IN PDEVICE_OBJECT DeviceObject, IN BOOLEAN AllowRawMount); +NTKERNELAPI +VOID +NTAPI +IoWriteErrorLogEntry( + IN PVOID ElEntry); + NTKERNELAPI NTSTATUS NTAPI @@ -5866,6 +6055,13 @@ IoQueryFileDosDeviceName( IN PFILE_OBJECT FileObject, OUT POBJECT_NAME_INFORMATION *ObjectNameInformation); +VOID +NTAPI +IoSetStartIoAttributes( + IN PDEVICE_OBJECT DeviceObject, + IN BOOLEAN DeferredStartIo, + IN BOOLEAN NonCancelable); + NTKERNELAPI NTSTATUS NTAPI @@ -5964,6 +6160,53 @@ typedef struct _IO_PRIORITY_INFO { #define PO_CB_LID_SWITCH_STATE 4 #define PO_CB_PROCESSOR_POWER_POLICY 5 +#if (NTDDI_VERSION >= NTDDI_WIN2K) + +NTKERNELAPI +PVOID +NTAPI +PoRegisterSystemState( + IN OUT PVOID StateHandle OPTIONAL, + IN EXECUTION_STATE Flags); + +NTKERNELAPI +VOID +NTAPI +PoUnregisterSystemState( + IN OUT PVOID StateHandle); + +NTKERNELAPI +POWER_STATE +NTAPI +PoSetPowerState( + IN PDEVICE_OBJECT DeviceObject, + IN POWER_STATE_TYPE Type, + IN POWER_STATE State); + +NTKERNELAPI +NTSTATUS +NTAPI +PoCallDriver( + IN PDEVICE_OBJECT DeviceObject, + IN OUT PIRP Irp); + +NTKERNELAPI +VOID +NTAPI +PoStartNextPowerIrp( + IN OUT PIRP Irp); + +NTKERNELAPI +PULONG +NTAPI +PoRegisterDeviceForIdleDetection( + IN PDEVICE_OBJECT DeviceObject, + IN ULONG ConservationIdleTime, + IN ULONG PerformanceIdleTime, + IN DEVICE_POWER_STATE State); + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ + #if (NTDDI_VERSION >= NTDDI_WINXP) NTKERNELAPI NTSTATUS @@ -5972,6 +6215,84 @@ PoQueueShutdownWorkItem( IN OUT PWORK_QUEUE_ITEM WorkItem); #endif +#if (NTDDI_VERSION >= NTDDI_VISTA) + +NTKERNELAPI +NTSTATUS +NTAPI +PoRegisterPowerSettingCallback( + IN PDEVICE_OBJECT DeviceObject OPTIONAL, + IN LPCGUID SettingGuid, + IN PPOWER_SETTING_CALLBACK Callback, + IN PVOID Context OPTIONAL, + OUT PVOID *Handle); + +NTKERNELAPI +NTSTATUS +PoUnregisterPowerSettingCallback( + IN OUT PVOID Handle); + +#endif + +#if (NTDDI_VERSION >= NTDDI_WIN6SP1) +NTKERNELAPI +VOID +NTAPI +PoSetDeviceBusyEx( + IN OUT PULONG IdlePointer); +#endif + +#if (NTDDI_VERSION >= NTDDI_WIN7) + +NTKERNELAPI +NTSTATUS +NTAPI +PoCreatePowerRequest( + OUT PVOID *PowerRequest, + IN PDEVICE_OBJECT DeviceObject, + IN PCOUNTED_REASON_CONTEXT Context); + +NTKERNELAPI +NTSTATUS +NTAPI +PoSetPowerRequest( + IN OUT PVOID PowerRequest, + IN POWER_REQUEST_TYPE Type); + +NTKERNELAPI +NTSTATUS +NTAPI +PoClearPowerRequest( + IN OUT PVOID PowerRequest, + IN POWER_REQUEST_TYPE Type); + +NTKERNELAPI +VOID +NTAPI +PoDeletePowerRequest( + IN OUT PVOID PowerRequest); + +NTKERNELAPI +VOID +NTAPI +PoStartDeviceBusy( + IN OUT PULONG IdlePointer); + +NTKERNELAPI +VOID +NTAPI +PoEndDeviceBusy( + IN OUT PULONG IdlePointer); + +NTKERNELAPI +BOOLEAN +NTAPI +PoQueryWatchdogTime( + IN PDEVICE_OBJECT Pdo, + OUT PULONG SecondsRemaining); + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + #if defined(_IA64_) #if (NTDDI_VERSION >= NTDDI_WIN2K) //DECLSPEC_DEPRECATED_DDK @@ -6247,188 +6568,6 @@ typedef struct _FILE_LOCK { LONG volatile LockRequestsInProgress; } FILE_LOCK, *PFILE_LOCK; -typedef struct _TUNNEL { - FAST_MUTEX Mutex; - PRTL_SPLAY_LINKS Cache; - LIST_ENTRY TimerQueue; - USHORT NumEntries; -} TUNNEL, *PTUNNEL; - -typedef enum _FSRTL_COMPARISON_RESULT { - LessThan = -1, - EqualTo = 0, - GreaterThan = 1 -} FSRTL_COMPARISON_RESULT; - -#define FSRTL_FAT_LEGAL 0x01 -#define FSRTL_HPFS_LEGAL 0x02 -#define FSRTL_NTFS_LEGAL 0x04 -#define FSRTL_WILD_CHARACTER 0x08 -#define FSRTL_OLE_LEGAL 0x10 -#define FSRTL_NTFS_STREAM_LEGAL (FSRTL_NTFS_LEGAL | FSRTL_OLE_LEGAL) - -typedef struct _BASE_MCB { - ULONG MaximumPairCount; - ULONG PairCount; - USHORT PoolType; - USHORT Flags; - PVOID Mapping; -} BASE_MCB, *PBASE_MCB; - -typedef struct _LARGE_MCB { - PKGUARDED_MUTEX GuardedMutex; - BASE_MCB BaseMcb; -} LARGE_MCB, *PLARGE_MCB; - -#define MCB_FLAG_RAISE_ON_ALLOCATION_FAILURE 1 - -typedef struct _MCB { - LARGE_MCB DummyFieldThatSizesThisStructureCorrectly; -} MCB, *PMCB; - -typedef PVOID OPLOCK, *POPLOCK; - -typedef VOID -(NTAPI *POPLOCK_WAIT_COMPLETE_ROUTINE) ( - IN PVOID Context, - IN PIRP Irp); - -typedef VOID -(NTAPI *POPLOCK_FS_PREPOST_IRP) ( - IN PVOID Context, - IN PIRP Irp); - -#if (NTDDI_VERSION >= NTDDI_VISTASP1) -#define OPLOCK_FLAG_COMPLETE_IF_OPLOCKED 0x00000001 -#endif - -#if (NTDDI_VERSION >= NTDDI_WIN7) -#define OPLOCK_FLAG_OPLOCK_KEY_CHECK_ONLY 0x00000002 -#define OPLOCK_FLAG_BACK_OUT_ATOMIC_OPLOCK 0x00000004 -#define OPLOCK_FLAG_IGNORE_OPLOCK_KEYS 0x00000008 -#define OPLOCK_FSCTRL_FLAG_ALL_KEYS_MATCH 0x00000001 -#endif - -#if (NTDDI_VERSION >= NTDDI_WIN7) - -typedef struct _OPLOCK_KEY_ECP_CONTEXT { - GUID OplockKey; - ULONG Reserved; -} OPLOCK_KEY_ECP_CONTEXT, *POPLOCK_KEY_ECP_CONTEXT; - -DEFINE_GUID( GUID_ECP_OPLOCK_KEY, 0x48850596, 0x3050, 0x4be7, 0x98, 0x63, 0xfe, 0xc3, 0x50, 0xce, 0x8d, 0x7f ); - -#endif - -#define FSRTL_VOLUME_DISMOUNT 1 -#define FSRTL_VOLUME_DISMOUNT_FAILED 2 -#define FSRTL_VOLUME_LOCK 3 -#define FSRTL_VOLUME_LOCK_FAILED 4 -#define FSRTL_VOLUME_UNLOCK 5 -#define FSRTL_VOLUME_MOUNT 6 -#define FSRTL_VOLUME_NEEDS_CHKDSK 7 -#define FSRTL_VOLUME_WORM_NEAR_FULL 8 -#define FSRTL_VOLUME_WEARING_OUT 9 -#define FSRTL_VOLUME_FORCED_CLOSED 10 -#define FSRTL_VOLUME_INFO_MAKE_COMPAT 11 -#define FSRTL_VOLUME_PREPARING_EJECT 12 -#define FSRTL_VOLUME_CHANGE_SIZE 13 -#define FSRTL_VOLUME_BACKGROUND_FORMAT 14 - -typedef PVOID PNOTIFY_SYNC; - -typedef BOOLEAN -(NTAPI *PCHECK_FOR_TRAVERSE_ACCESS) ( - IN PVOID NotifyContext, - IN PVOID TargetContext OPTIONAL, - IN PSECURITY_SUBJECT_CONTEXT SubjectContext); - -typedef BOOLEAN -(NTAPI *PFILTER_REPORT_CHANGE) ( - IN PVOID NotifyContext, - IN PVOID FilterContext); - -typedef VOID -(NTAPI *PFSRTL_STACK_OVERFLOW_ROUTINE) ( - IN PVOID Context, - IN PKEVENT Event); - -#if (NTDDI_VERSION >= NTDDI_VISTA) - -#define FSRTL_UNC_PROVIDER_FLAGS_MAILSLOTS_SUPPORTED 0x00000001 -#define FSRTL_UNC_PROVIDER_FLAGS_CSC_ENABLED 0x00000002 -#define FSRTL_UNC_PROVIDER_FLAGS_DOMAIN_SVC_AWARE 0x00000004 - -#define FSRTL_ALLOCATE_ECPLIST_FLAG_CHARGE_QUOTA 0x00000001 - -#define FSRTL_ALLOCATE_ECP_FLAG_CHARGE_QUOTA 0x00000001 -#define FSRTL_ALLOCATE_ECP_FLAG_NONPAGED_POOL 0x00000002 - -#define FSRTL_ECP_LOOKASIDE_FLAG_NONPAGED_POOL 0x00000002 - -#define FSRTL_VIRTDISK_FULLY_ALLOCATED 0x00000001 -#define FSRTL_VIRTDISK_NO_DRIVE_LETTER 0x00000002 - -typedef struct _FSRTL_MUP_PROVIDER_INFO_LEVEL_1 { - ULONG32 ProviderId; -} FSRTL_MUP_PROVIDER_INFO_LEVEL_1, *PFSRTL_MUP_PROVIDER_INFO_LEVEL_1; - -typedef struct _FSRTL_MUP_PROVIDER_INFO_LEVEL_2 { - ULONG32 ProviderId; - UNICODE_STRING ProviderName; -} FSRTL_MUP_PROVIDER_INFO_LEVEL_2, *PFSRTL_MUP_PROVIDER_INFO_LEVEL_2; - -typedef VOID -(*PFSRTL_EXTRA_CREATE_PARAMETER_CLEANUP_CALLBACK) ( - IN OUT PVOID EcpContext, - IN LPCGUID EcpType); - -typedef struct _ECP_LIST ECP_LIST, *PECP_LIST; - -typedef ULONG FSRTL_ALLOCATE_ECPLIST_FLAGS; -typedef ULONG FSRTL_ALLOCATE_ECP_FLAGS; -typedef ULONG FSRTL_ECP_LOOKASIDE_FLAGS; - -typedef enum _FSRTL_CHANGE_BACKING_TYPE { - ChangeDataControlArea, - ChangeImageControlArea, - ChangeSharedCacheMap -} FSRTL_CHANGE_BACKING_TYPE, *PFSRTL_CHANGE_BACKING_TYPE; - -#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ - -typedef struct _FSRTL_PER_FILE_CONTEXT { - LIST_ENTRY Links; - PVOID OwnerId; - PVOID InstanceId; - PFREE_FUNCTION FreeCallback; -} FSRTL_PER_FILE_CONTEXT, *PFSRTL_PER_FILE_CONTEXT; - -typedef struct _FSRTL_PER_STREAM_CONTEXT { - LIST_ENTRY Links; - PVOID OwnerId; - PVOID InstanceId; - PFREE_FUNCTION FreeCallback; -} FSRTL_PER_STREAM_CONTEXT, *PFSRTL_PER_STREAM_CONTEXT; - -#if (NTDDI_VERSION >= NTDDI_WIN2K) -typedef VOID -(*PFN_FSRTLTEARDOWNPERSTREAMCONTEXTS) ( - IN PFSRTL_ADVANCED_FCB_HEADER AdvancedHeader); -#endif - -typedef struct _FSRTL_PER_FILEOBJECT_CONTEXT { - LIST_ENTRY Links; - PVOID OwnerId; - PVOID InstanceId; -} FSRTL_PER_FILEOBJECT_CONTEXT, *PFSRTL_PER_FILEOBJECT_CONTEXT; - -#define FsRtlEnterFileSystem KeEnterCriticalRegion -#define FsRtlExitFileSystem KeLeaveCriticalRegion - -#define FSRTL_CC_FLUSH_ERROR_FLAG_NO_HARD_ERROR 0x1 -#define FSRTL_CC_FLUSH_ERROR_FLAG_NO_LOG_ENTRY 0x2 - #if (NTDDI_VERSION >= NTDDI_WIN2K) NTKERNELAPI @@ -6706,2181 +6845,15 @@ FsRtlPrivateLock( IN PVOID Context, IN BOOLEAN AlreadySynchronized); -NTKERNELAPI -VOID -NTAPI -FsRtlInitializeTunnelCache( - IN PTUNNEL Cache); - -NTKERNELAPI -VOID -NTAPI -FsRtlAddToTunnelCache( - IN PTUNNEL Cache, - IN ULONGLONG DirectoryKey, - IN PUNICODE_STRING ShortName, - IN PUNICODE_STRING LongName, - IN BOOLEAN KeyByShortName, - IN ULONG DataLength, - IN PVOID Data); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlFindInTunnelCache( - IN PTUNNEL Cache, - IN ULONGLONG DirectoryKey, - IN PUNICODE_STRING Name, - OUT PUNICODE_STRING ShortName, - OUT PUNICODE_STRING LongName, - IN OUT PULONG DataLength, - OUT PVOID Data); - -NTKERNELAPI -VOID -NTAPI -FsRtlDeleteKeyFromTunnelCache( - IN PTUNNEL Cache, - IN ULONGLONG DirectoryKey); - -NTKERNELAPI -VOID -NTAPI -FsRtlDeleteTunnelCache( - IN PTUNNEL Cache); - -NTKERNELAPI -VOID -NTAPI -FsRtlDissectDbcs( - IN ANSI_STRING Name, - OUT PANSI_STRING FirstPart, - OUT PANSI_STRING RemainingPart); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlDoesDbcsContainWildCards( - IN PANSI_STRING Name); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlIsDbcsInExpression( - IN PANSI_STRING Expression, - IN PANSI_STRING Name); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlIsFatDbcsLegal( - IN ANSI_STRING DbcsName, - IN BOOLEAN WildCardsPermissible, - IN BOOLEAN PathNamePermissible, - IN BOOLEAN LeadingBackslashPermissible); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlIsHpfsDbcsLegal( - IN ANSI_STRING DbcsName, - IN BOOLEAN WildCardsPermissible, - IN BOOLEAN PathNamePermissible, - IN BOOLEAN LeadingBackslashPermissible); - -NTKERNELAPI -NTSTATUS -NTAPI -FsRtlNormalizeNtstatus( - IN NTSTATUS Exception, - IN NTSTATUS GenericException); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlIsNtstatusExpected( - IN NTSTATUS Ntstatus); - -NTKERNELAPI -PERESOURCE -NTAPI -FsRtlAllocateResource( - VOID); - -NTKERNELAPI -VOID -NTAPI -FsRtlInitializeLargeMcb( - IN PLARGE_MCB Mcb, - IN POOL_TYPE PoolType); - -NTKERNELAPI -VOID -NTAPI -FsRtlUninitializeLargeMcb( - IN PLARGE_MCB Mcb); - -NTKERNELAPI -VOID -NTAPI -FsRtlResetLargeMcb( - IN PLARGE_MCB Mcb, - IN BOOLEAN SelfSynchronized); - -NTKERNELAPI -VOID -NTAPI -FsRtlTruncateLargeMcb( - IN PLARGE_MCB Mcb, - IN LONGLONG Vbn); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlAddLargeMcbEntry( - IN PLARGE_MCB Mcb, - IN LONGLONG Vbn, - IN LONGLONG Lbn, - IN LONGLONG SectorCount); - -NTKERNELAPI -VOID -NTAPI -FsRtlRemoveLargeMcbEntry( - IN PLARGE_MCB Mcb, - IN LONGLONG Vbn, - IN LONGLONG SectorCount); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlLookupLargeMcbEntry( - IN PLARGE_MCB Mcb, - IN LONGLONG Vbn, - OUT PLONGLONG Lbn OPTIONAL, - OUT PLONGLONG SectorCountFromLbn OPTIONAL, - OUT PLONGLONG StartingLbn OPTIONAL, - OUT PLONGLONG SectorCountFromStartingLbn OPTIONAL, - OUT PULONG Index OPTIONAL); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlLookupLastLargeMcbEntry( - IN PLARGE_MCB Mcb, - OUT PLONGLONG Vbn, - OUT PLONGLONG Lbn); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlLookupLastLargeMcbEntryAndIndex( - IN PLARGE_MCB OpaqueMcb, - OUT PLONGLONG LargeVbn, - OUT PLONGLONG LargeLbn, - OUT PULONG Index); - -NTKERNELAPI -ULONG -NTAPI -FsRtlNumberOfRunsInLargeMcb( - IN PLARGE_MCB Mcb); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlGetNextLargeMcbEntry( - IN PLARGE_MCB Mcb, - IN ULONG RunIndex, - OUT PLONGLONG Vbn, - OUT PLONGLONG Lbn, - OUT PLONGLONG SectorCount); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlSplitLargeMcb( - IN PLARGE_MCB Mcb, - IN LONGLONG Vbn, - IN LONGLONG Amount); - -NTKERNELAPI -VOID -NTAPI -FsRtlInitializeMcb( - IN PMCB Mcb, - IN POOL_TYPE PoolType); - -NTKERNELAPI -VOID -NTAPI -FsRtlUninitializeMcb( - IN PMCB Mcb); - -NTKERNELAPI -VOID -NTAPI -FsRtlTruncateMcb( - IN PMCB Mcb, - IN VBN Vbn); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlAddMcbEntry( - IN PMCB Mcb, - IN VBN Vbn, - IN LBN Lbn, - IN ULONG SectorCount); - -NTKERNELAPI -VOID -NTAPI -FsRtlRemoveMcbEntry( - IN PMCB Mcb, - IN VBN Vbn, - IN ULONG SectorCount); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlLookupMcbEntry( - IN PMCB Mcb, - IN VBN Vbn, - OUT PLBN Lbn, - OUT PULONG SectorCount OPTIONAL, - OUT PULONG Index); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlLookupLastMcbEntry( - IN PMCB Mcb, - OUT PVBN Vbn, - OUT PLBN Lbn); - -NTKERNELAPI -ULONG -NTAPI -FsRtlNumberOfRunsInMcb( - IN PMCB Mcb); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlGetNextMcbEntry( - IN PMCB Mcb, - IN ULONG RunIndex, - OUT PVBN Vbn, - OUT PLBN Lbn, - OUT PULONG SectorCount); - -NTKERNELAPI -NTSTATUS -NTAPI -FsRtlBalanceReads( - IN PDEVICE_OBJECT TargetDevice); - -NTKERNELAPI -VOID -NTAPI -FsRtlInitializeOplock( - IN OUT POPLOCK Oplock); - -NTKERNELAPI -VOID -NTAPI -FsRtlUninitializeOplock( - IN OUT POPLOCK Oplock); - -NTKERNELAPI -NTSTATUS -NTAPI -FsRtlOplockFsctrl( - IN POPLOCK Oplock, - IN PIRP Irp, - IN ULONG OpenCount); - -NTKERNELAPI -NTSTATUS -NTAPI -FsRtlCheckOplock( - IN POPLOCK Oplock, - IN PIRP Irp, - IN PVOID Context, - IN POPLOCK_WAIT_COMPLETE_ROUTINE CompletionRoutine OPTIONAL, - IN POPLOCK_FS_PREPOST_IRP PostIrpRoutine OPTIONAL); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlOplockIsFastIoPossible( - IN POPLOCK Oplock); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlCurrentBatchOplock( - IN POPLOCK Oplock); - -NTKERNELAPI -NTSTATUS -NTAPI -FsRtlNotifyVolumeEvent( - IN PFILE_OBJECT FileObject, - IN ULONG EventCode); - -NTKERNELAPI -VOID -NTAPI -FsRtlNotifyInitializeSync( - IN PNOTIFY_SYNC *NotifySync); - -NTKERNELAPI -VOID -NTAPI -FsRtlNotifyUninitializeSync( - IN PNOTIFY_SYNC *NotifySync); - -NTKERNELAPI -VOID -NTAPI -FsRtlNotifyFullChangeDirectory( - IN PNOTIFY_SYNC NotifySync, - IN PLIST_ENTRY NotifyList, - IN PVOID FsContext, - IN PSTRING FullDirectoryName, - IN BOOLEAN WatchTree, - IN BOOLEAN IgnoreBuffer, - IN ULONG CompletionFilter, - IN PIRP NotifyIrp OPTIONAL, - IN PCHECK_FOR_TRAVERSE_ACCESS TraverseCallback OPTIONAL, - IN PSECURITY_SUBJECT_CONTEXT SubjectContext OPTIONAL); - -NTKERNELAPI -VOID -NTAPI -FsRtlNotifyFilterReportChange( - IN PNOTIFY_SYNC NotifySync, - IN PLIST_ENTRY NotifyList, - IN PSTRING FullTargetName, - IN USHORT TargetNameOffset, - IN PSTRING StreamName OPTIONAL, - IN PSTRING NormalizedParentName OPTIONAL, - IN ULONG FilterMatch, - IN ULONG Action, - IN PVOID TargetContext OPTIONAL, - IN PVOID FilterContext OPTIONAL); - -NTKERNELAPI -VOID -NTAPI -FsRtlNotifyFullReportChange( - IN PNOTIFY_SYNC NotifySync, - IN PLIST_ENTRY NotifyList, - IN PSTRING FullTargetName, - IN USHORT TargetNameOffset, - IN PSTRING StreamName OPTIONAL, - IN PSTRING NormalizedParentName OPTIONAL, - IN ULONG FilterMatch, - IN ULONG Action, - IN PVOID TargetContext OPTIONAL); - -NTKERNELAPI -VOID -NTAPI -FsRtlNotifyCleanup( - IN PNOTIFY_SYNC NotifySync, - IN PLIST_ENTRY NotifyList, - IN PVOID FsContext); - -NTKERNELAPI -VOID -NTAPI -FsRtlDissectName( - IN UNICODE_STRING Name, - OUT PUNICODE_STRING FirstPart, - OUT PUNICODE_STRING RemainingPart); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlDoesNameContainWildCards( - IN PUNICODE_STRING Name); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlAreNamesEqual( - IN PCUNICODE_STRING Name1, - IN PCUNICODE_STRING Name2, - IN BOOLEAN IgnoreCase, - IN PCWCH UpcaseTable OPTIONAL); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlIsNameInExpression( - IN PUNICODE_STRING Expression, - IN PUNICODE_STRING Name, - IN BOOLEAN IgnoreCase, - IN PWCHAR UpcaseTable OPTIONAL); - -NTKERNELAPI -VOID -NTAPI -FsRtlPostPagingFileStackOverflow( - IN PVOID Context, - IN PKEVENT Event, - IN PFSRTL_STACK_OVERFLOW_ROUTINE StackOverflowRoutine); - -NTKERNELAPI -VOID -NTAPI -FsRtlPostStackOverflow ( - IN PVOID Context, - IN PKEVENT Event, - IN PFSRTL_STACK_OVERFLOW_ROUTINE StackOverflowRoutine); - -NTKERNELAPI -NTSTATUS -NTAPI -FsRtlRegisterUncProvider( - OUT PHANDLE MupHandle, - IN PUNICODE_STRING RedirectorDeviceName, - IN BOOLEAN MailslotsSupported); - -NTKERNELAPI -VOID -NTAPI -FsRtlDeregisterUncProvider( - IN HANDLE Handle); - -NTKERNELAPI -VOID -NTAPI -FsRtlTeardownPerStreamContexts( - IN PFSRTL_ADVANCED_FCB_HEADER AdvancedHeader); - -NTKERNELAPI -NTSTATUS -NTAPI -FsRtlCreateSectionForDataScan( - OUT PHANDLE SectionHandle, - OUT PVOID *SectionObject, - OUT PLARGE_INTEGER SectionFileSize OPTIONAL, - IN PFILE_OBJECT FileObject, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, - IN PLARGE_INTEGER MaximumSize OPTIONAL, - IN ULONG SectionPageProtection, - IN ULONG AllocationAttributes, - IN ULONG Flags); - #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ -#if (NTDDI_VERSION >= NTDDI_WINXP) - -NTKERNELAPI -VOID -NTAPI -FsRtlNotifyFilterChangeDirectory( - IN PNOTIFY_SYNC NotifySync, - IN PLIST_ENTRY NotifyList, - IN PVOID FsContext, - IN PSTRING FullDirectoryName, - IN BOOLEAN WatchTree, - IN BOOLEAN IgnoreBuffer, - IN ULONG CompletionFilter, - IN PIRP NotifyIrp OPTIONAL, - IN PCHECK_FOR_TRAVERSE_ACCESS TraverseCallback OPTIONAL, - IN PSECURITY_SUBJECT_CONTEXT SubjectContext OPTIONAL, - IN PFILTER_REPORT_CHANGE FilterCallback OPTIONAL); - -NTKERNELAPI -NTSTATUS -NTAPI -FsRtlInsertPerStreamContext( - IN PFSRTL_ADVANCED_FCB_HEADER PerStreamContext, - IN PFSRTL_PER_STREAM_CONTEXT Ptr); - -NTKERNELAPI -PFSRTL_PER_STREAM_CONTEXT -NTAPI -FsRtlLookupPerStreamContextInternal( - IN PFSRTL_ADVANCED_FCB_HEADER StreamContext, - IN PVOID OwnerId OPTIONAL, - IN PVOID InstanceId OPTIONAL); - -NTKERNELAPI -PFSRTL_PER_STREAM_CONTEXT -NTAPI -FsRtlRemovePerStreamContext( - IN PFSRTL_ADVANCED_FCB_HEADER StreamContext, - IN PVOID OwnerId OPTIONAL, - IN PVOID InstanceId OPTIONAL); - -NTKERNELAPI -VOID -NTAPI -FsRtlIncrementCcFastReadNotPossible( - VOID); - -NTKERNELAPI -VOID -NTAPI -FsRtlIncrementCcFastReadWait( - VOID); - -NTKERNELAPI -VOID -NTAPI -FsRtlIncrementCcFastReadNoWait( - VOID); - -NTKERNELAPI -VOID -NTAPI -FsRtlIncrementCcFastReadResourceMiss( - VOID); - -NTKERNELAPI -LOGICAL -NTAPI -FsRtlIsPagingFile( - IN PFILE_OBJECT FileObject); - -#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ - -#if (NTDDI_VERSION >= NTDDI_WS03) - -NTKERNELAPI -VOID -NTAPI -FsRtlInitializeBaseMcb( - IN PBASE_MCB Mcb, - IN POOL_TYPE PoolType); - -NTKERNELAPI -VOID -NTAPI -FsRtlUninitializeBaseMcb( - IN PBASE_MCB Mcb); - -NTKERNELAPI -VOID -NTAPI -FsRtlResetBaseMcb( - IN PBASE_MCB Mcb); - -NTKERNELAPI -VOID -NTAPI -FsRtlTruncateBaseMcb( - IN PBASE_MCB Mcb, - IN LONGLONG Vbn); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlAddBaseMcbEntry( - IN PBASE_MCB Mcb, - IN LONGLONG Vbn, - IN LONGLONG Lbn, - IN LONGLONG SectorCount); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlRemoveBaseMcbEntry( - IN PBASE_MCB Mcb, - IN LONGLONG Vbn, - IN LONGLONG SectorCount); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlLookupBaseMcbEntry( - IN PBASE_MCB Mcb, - IN LONGLONG Vbn, - OUT PLONGLONG Lbn OPTIONAL, - OUT PLONGLONG SectorCountFromLbn OPTIONAL, - OUT PLONGLONG StartingLbn OPTIONAL, - OUT PLONGLONG SectorCountFromStartingLbn OPTIONAL, - OUT PULONG Index OPTIONAL); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlLookupLastBaseMcbEntry( - IN PBASE_MCB Mcb, - OUT PLONGLONG Vbn, - OUT PLONGLONG Lbn); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlLookupLastBaseMcbEntryAndIndex( - IN PBASE_MCB OpaqueMcb, - IN OUT PLONGLONG LargeVbn, - IN OUT PLONGLONG LargeLbn, - IN OUT PULONG Index); - -NTKERNELAPI -ULONG -NTAPI -FsRtlNumberOfRunsInBaseMcb( - IN PBASE_MCB Mcb); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlGetNextBaseMcbEntry( - IN PBASE_MCB Mcb, - IN ULONG RunIndex, - OUT PLONGLONG Vbn, - OUT PLONGLONG Lbn, - OUT PLONGLONG SectorCount); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlSplitBaseMcb( - IN PBASE_MCB Mcb, - IN LONGLONG Vbn, - IN LONGLONG Amount); - -#endif /* (NTDDI_VERSION >= NTDDI_WS03) */ - -#if (NTDDI_VERSION >= NTDDI_VISTA) - -BOOLEAN -NTAPI -FsRtlInitializeBaseMcbEx( - IN PBASE_MCB Mcb, - IN POOL_TYPE PoolType, - IN USHORT Flags); - -NTSTATUS -NTAPI -FsRtlAddBaseMcbEntryEx( - IN PBASE_MCB Mcb, - IN LONGLONG Vbn, - IN LONGLONG Lbn, - IN LONGLONG SectorCount); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlCurrentOplock( - IN POPLOCK Oplock); - -NTKERNELAPI -NTSTATUS -NTAPI -FsRtlOplockBreakToNone( - IN OUT POPLOCK Oplock, - IN PIO_STACK_LOCATION IrpSp OPTIONAL, - IN PIRP Irp, - IN PVOID Context OPTIONAL, - IN POPLOCK_WAIT_COMPLETE_ROUTINE CompletionRoutine OPTIONAL, - IN POPLOCK_FS_PREPOST_IRP PostIrpRoutine OPTIONAL); - -NTKERNELAPI -NTSTATUS -NTAPI -FsRtlNotifyVolumeEventEx( - IN PFILE_OBJECT FileObject, - IN ULONG EventCode, - IN PTARGET_DEVICE_CUSTOM_NOTIFICATION Event); - -NTKERNELAPI -VOID -NTAPI -FsRtlNotifyCleanupAll( - IN PNOTIFY_SYNC NotifySync, - IN PLIST_ENTRY NotifyList); - -NTSTATUS -NTAPI -FsRtlRegisterUncProviderEx( - OUT PHANDLE MupHandle, - IN PUNICODE_STRING RedirDevName, - IN PDEVICE_OBJECT DeviceObject, - IN ULONG Flags); - -NTKERNELAPI -NTSTATUS -NTAPI -FsRtlCancellableWaitForSingleObject( - IN PVOID Object, - IN PLARGE_INTEGER Timeout OPTIONAL, - IN PIRP Irp OPTIONAL); - -NTKERNELAPI -NTSTATUS -NTAPI -FsRtlCancellableWaitForMultipleObjects( - IN ULONG Count, - IN PVOID ObjectArray[], - IN WAIT_TYPE WaitType, - IN PLARGE_INTEGER Timeout OPTIONAL, - IN PKWAIT_BLOCK WaitBlockArray OPTIONAL, - IN PIRP Irp OPTIONAL); - -NTKERNELAPI -NTSTATUS -NTAPI -FsRtlMupGetProviderInfoFromFileObject( - IN PFILE_OBJECT pFileObject, - IN ULONG Level, - OUT PVOID pBuffer, - IN OUT PULONG pBufferSize); - -NTKERNELAPI -NTSTATUS -NTAPI -FsRtlMupGetProviderIdFromName( - IN PUNICODE_STRING pProviderName, - OUT PULONG32 pProviderId); - -NTKERNELAPI -VOID -NTAPI -FsRtlIncrementCcFastMdlReadWait( - VOID); - -NTKERNELAPI -NTSTATUS -NTAPI -FsRtlValidateReparsePointBuffer( - IN ULONG BufferLength, - IN PREPARSE_DATA_BUFFER ReparseBuffer); - -NTKERNELAPI -NTSTATUS -NTAPI -FsRtlRemoveDotsFromPath( - IN OUT PWSTR OriginalString, - IN USHORT PathLength, - OUT USHORT *NewLength); - -NTKERNELAPI -NTSTATUS -NTAPI -FsRtlAllocateExtraCreateParameterList( - IN FSRTL_ALLOCATE_ECPLIST_FLAGS Flags, - OUT PECP_LIST *EcpList); - -NTKERNELAPI -VOID -NTAPI -FsRtlFreeExtraCreateParameterList( - IN PECP_LIST EcpList); - -NTKERNELAPI -NTSTATUS -NTAPI -FsRtlAllocateExtraCreateParameter( - IN LPCGUID EcpType, - IN ULONG SizeOfContext, - IN FSRTL_ALLOCATE_ECP_FLAGS Flags, - IN PFSRTL_EXTRA_CREATE_PARAMETER_CLEANUP_CALLBACK CleanupCallback OPTIONAL, - IN ULONG PoolTag, - OUT PVOID *EcpContext); - -NTKERNELAPI -VOID -NTAPI -FsRtlFreeExtraCreateParameter( - IN PVOID EcpContext); - -NTKERNELAPI -VOID -NTAPI -FsRtlInitExtraCreateParameterLookasideList( - IN OUT PVOID Lookaside, - IN FSRTL_ECP_LOOKASIDE_FLAGS Flags, - IN SIZE_T Size, - IN ULONG Tag); - -VOID -NTAPI -FsRtlDeleteExtraCreateParameterLookasideList( - IN OUT PVOID Lookaside, - IN FSRTL_ECP_LOOKASIDE_FLAGS Flags); - -NTKERNELAPI -NTSTATUS -NTAPI -FsRtlAllocateExtraCreateParameterFromLookasideList( - IN LPCGUID EcpType, - IN ULONG SizeOfContext, - IN FSRTL_ALLOCATE_ECP_FLAGS Flags, - IN PFSRTL_EXTRA_CREATE_PARAMETER_CLEANUP_CALLBACK CleanupCallback OPTIONAL, - IN OUT PVOID LookasideList, - OUT PVOID *EcpContext); - -NTKERNELAPI -NTSTATUS -NTAPI -FsRtlInsertExtraCreateParameter( - IN OUT PECP_LIST EcpList, - IN OUT PVOID EcpContext); - -NTKERNELAPI -NTSTATUS -NTAPI -FsRtlFindExtraCreateParameter( - IN PECP_LIST EcpList, - IN LPCGUID EcpType, - OUT PVOID *EcpContext OPTIONAL, - OUT ULONG *EcpContextSize OPTIONAL); - -NTKERNELAPI -NTSTATUS -NTAPI -FsRtlRemoveExtraCreateParameter( - IN OUT PECP_LIST EcpList, - IN LPCGUID EcpType, - OUT PVOID *EcpContext, - OUT ULONG *EcpContextSize OPTIONAL); - -NTKERNELAPI -NTSTATUS -NTAPI -FsRtlGetEcpListFromIrp( - IN PIRP Irp, - OUT PECP_LIST *EcpList OPTIONAL); - -NTKERNELAPI -NTSTATUS -NTAPI -FsRtlSetEcpListIntoIrp( - IN OUT PIRP Irp, - IN PECP_LIST EcpList); - -NTKERNELAPI -NTSTATUS -NTAPI -FsRtlGetNextExtraCreateParameter( - IN PECP_LIST EcpList, - IN PVOID CurrentEcpContext OPTIONAL, - OUT LPGUID NextEcpType OPTIONAL, - OUT PVOID *NextEcpContext OPTIONAL, - OUT ULONG *NextEcpContextSize OPTIONAL); - -NTKERNELAPI -VOID -NTAPI -FsRtlAcknowledgeEcp( - IN PVOID EcpContext); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlIsEcpAcknowledged( - IN PVOID EcpContext); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlIsEcpFromUserMode( - IN PVOID EcpContext); - -NTKERNELAPI -NTSTATUS -NTAPI -FsRtlChangeBackingFileObject( - IN PFILE_OBJECT CurrentFileObject OPTIONAL, - IN PFILE_OBJECT NewFileObject, - IN FSRTL_CHANGE_BACKING_TYPE ChangeBackingType, - IN ULONG Flags); - -NTKERNELAPI -NTSTATUS -NTAPI -FsRtlLogCcFlushError( - IN PUNICODE_STRING FileName, - IN PDEVICE_OBJECT DeviceObject, - IN PSECTION_OBJECT_POINTERS SectionObjectPointer, - IN NTSTATUS FlushError, - IN ULONG Flags); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlAreVolumeStartupApplicationsComplete( - VOID); - -NTKERNELAPI -ULONG -NTAPI -FsRtlQueryMaximumVirtualDiskNestingLevel( - VOID); - -NTKERNELAPI -NTSTATUS -NTAPI -FsRtlGetVirtualDiskNestingLevel( - IN PDEVICE_OBJECT DeviceObject, - OUT PULONG NestingLevel, - OUT PULONG NestingFlags OPTIONAL); - -#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ - -#if (NTDDI_VERSION >= NTDDI_VISTASP1) -NTKERNELAPI -NTSTATUS -NTAPI -FsRtlCheckOplockEx( - IN POPLOCK Oplock, - IN PIRP Irp, - IN ULONG Flags, - IN PVOID Context OPTIONAL, - IN POPLOCK_WAIT_COMPLETE_ROUTINE CompletionRoutine OPTIONAL, - IN POPLOCK_FS_PREPOST_IRP PostIrpRoutine OPTIONAL); - -#endif - #if (NTDDI_VERSION >= NTDDI_WIN7) - NTKERNELAPI BOOLEAN NTAPI FsRtlAreThereCurrentOrInProgressFileLocks( IN PFILE_LOCK FileLock); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlOplockIsSharedRequest( - IN PIRP Irp); - -NTKERNELAPI -NTSTATUS -NTAPI -FsRtlOplockBreakH( - IN POPLOCK Oplock, - IN PIRP Irp, - IN ULONG Flags, - IN PVOID Context OPTIONAL, - IN POPLOCK_WAIT_COMPLETE_ROUTINE CompletionRoutine OPTIONAL, - IN POPLOCK_FS_PREPOST_IRP PostIrpRoutine OPTIONAL); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlCurrentOplockH( - IN POPLOCK Oplock); - -NTKERNELAPI -NTSTATUS -NTAPI -FsRtlOplockBreakToNoneEx( - IN OUT POPLOCK Oplock, - IN PIRP Irp, - IN ULONG Flags, - IN PVOID Context OPTIONAL, - IN POPLOCK_WAIT_COMPLETE_ROUTINE CompletionRoutine OPTIONAL, - IN POPLOCK_FS_PREPOST_IRP PostIrpRoutine OPTIONAL); - -NTKERNELAPI -NTSTATUS -NTAPI -FsRtlOplockFsctrlEx( - IN POPLOCK Oplock, - IN PIRP Irp, - IN ULONG OpenCount, - IN ULONG Flags); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlOplockKeysEqual( - IN PFILE_OBJECT Fo1 OPTIONAL, - IN PFILE_OBJECT Fo2 OPTIONAL); - -NTKERNELAPI -NTSTATUS -NTAPI -FsRtlInitializeExtraCreateParameterList( - IN OUT PECP_LIST EcpList); - -NTKERNELAPI -VOID -NTAPI -FsRtlInitializeExtraCreateParameter( - IN PECP_HEADER Ecp, - IN ULONG EcpFlags, - IN PFSRTL_EXTRA_CREATE_PARAMETER_CLEANUP_CALLBACK CleanupCallback OPTIONAL, - IN ULONG TotalSize, - IN LPCGUID EcpType, - IN PVOID ListAllocatedFrom OPTIONAL); - -#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ - -NTKERNELAPI -NTSTATUS -NTAPI -FsRtlInsertPerFileContext( - IN PVOID* PerFileContextPointer, - IN PFSRTL_PER_FILE_CONTEXT Ptr); - -NTKERNELAPI -PFSRTL_PER_FILE_CONTEXT -NTAPI -FsRtlLookupPerFileContext( - IN PVOID* PerFileContextPointer, - IN PVOID OwnerId OPTIONAL, - IN PVOID InstanceId OPTIONAL); - -NTKERNELAPI -PFSRTL_PER_FILE_CONTEXT -NTAPI -FsRtlRemovePerFileContext( - IN PVOID* PerFileContextPointer, - IN PVOID OwnerId OPTIONAL, - IN PVOID InstanceId OPTIONAL); - -NTKERNELAPI -VOID -NTAPI -FsRtlTeardownPerFileContexts( - IN PVOID* PerFileContextPointer); - -NTKERNELAPI -NTSTATUS -NTAPI -FsRtlInsertPerFileObjectContext( - IN PFILE_OBJECT FileObject, - IN PFSRTL_PER_FILEOBJECT_CONTEXT Ptr); - -NTKERNELAPI -PFSRTL_PER_FILEOBJECT_CONTEXT -NTAPI -FsRtlLookupPerFileObjectContext( - IN PFILE_OBJECT FileObject, - IN PVOID OwnerId OPTIONAL, - IN PVOID InstanceId OPTIONAL); - -NTKERNELAPI -PFSRTL_PER_FILEOBJECT_CONTEXT -NTAPI -FsRtlRemovePerFileObjectContext( - IN PFILE_OBJECT FileObject, - IN PVOID OwnerId OPTIONAL, - IN PVOID InstanceId OPTIONAL); - -#define FsRtlFastLock(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11) ( \ - FsRtlPrivateLock(A1, A2, A3, A4, A5, A6, A7, A8, A9, NULL, A10, A11) \ -) - -#define FsRtlAreThereCurrentFileLocks(FL) ( \ - ((FL)->FastIoIsQuestionable) \ -) - -#define FsRtlIncrementLockRequestsInProgress(FL) { \ - ASSERT( (FL)->LockRequestsInProgress >= 0 ); \ - (void) \ - (InterlockedIncrement((LONG volatile *)&((FL)->LockRequestsInProgress)));\ -} - -#define FsRtlDecrementLockRequestsInProgress(FL) { \ - ASSERT( (FL)->LockRequestsInProgress > 0 ); \ - (void) \ - (InterlockedDecrement((LONG volatile *)&((FL)->LockRequestsInProgress)));\ -} - -extern NTKERNELAPI PUSHORT NlsOemLeadByteInfo; -#define NLS_OEM_LEAD_BYTE_INFO NlsOemLeadByteInfo - -#ifdef NLS_MB_CODE_PAGE_TAG -#undef NLS_MB_CODE_PAGE_TAG #endif -#define NLS_MB_CODE_PAGE_TAG NlsMbOemCodePageTag - -/* GCC compatible definition, MS one is retarded */ -extern NTKERNELAPI const UCHAR * const FsRtlLegalAnsiCharacterArray; -#define LEGAL_ANSI_CHARACTER_ARRAY FsRtlLegalAnsiCharacterArray - -#define FsRtlIsAnsiCharacterWild(C) ( \ - FlagOn(FsRtlLegalAnsiCharacterArray[(UCHAR)(C)], FSRTL_WILD_CHARACTER ) \ -) - -#define FsRtlIsAnsiCharacterLegalFat(C, WILD) ( \ - FlagOn(FsRtlLegalAnsiCharacterArray[(UCHAR)(C)], (FSRTL_FAT_LEGAL) | \ - ((WILD) ? FSRTL_WILD_CHARACTER : 0 )) \ -) - -#define FsRtlIsAnsiCharacterLegalHpfs(C, WILD) ( \ - FlagOn(FsRtlLegalAnsiCharacterArray[(UCHAR)(C)], (FSRTL_HPFS_LEGAL) | \ - ((WILD) ? FSRTL_WILD_CHARACTER : 0 )) \ -) - -#define FsRtlIsAnsiCharacterLegalNtfs(C, WILD) ( \ - FlagOn(FsRtlLegalAnsiCharacterArray[(UCHAR)(C)], (FSRTL_NTFS_LEGAL) | \ - ((WILD) ? FSRTL_WILD_CHARACTER : 0 )) \ -) - -#define FsRtlIsAnsiCharacterLegalNtfsStream(C,WILD_OK) ( \ - FsRtlTestAnsiCharacter((C), TRUE, (WILD_OK), FSRTL_NTFS_STREAM_LEGAL) \ -) - -#define FsRtlIsAnsiCharacterLegal(C,FLAGS) ( \ - FsRtlTestAnsiCharacter((C), TRUE, FALSE, (FLAGS)) \ -) - -#define FsRtlTestAnsiCharacter(C, DEFAULT_RET, WILD_OK, FLAGS) ( \ - ((SCHAR)(C) < 0) ? DEFAULT_RET : \ - FlagOn( LEGAL_ANSI_CHARACTER_ARRAY[(C)], \ - (FLAGS) | \ - ((WILD_OK) ? FSRTL_WILD_CHARACTER : 0) ) \ -) - -#define FsRtlIsLeadDbcsCharacter(DBCS_CHAR) ( \ - (BOOLEAN)((UCHAR)(DBCS_CHAR) < 0x80 ? FALSE : \ - (NLS_MB_CODE_PAGE_TAG && \ - (NLS_OEM_LEAD_BYTE_INFO[(UCHAR)(DBCS_CHAR)] != 0))) \ -) - -#define FsRtlIsUnicodeCharacterWild(C) ( \ - (((C) >= 0x40) ? \ - FALSE : \ - FlagOn(FsRtlLegalAnsiCharacterArray[(C)], FSRTL_WILD_CHARACTER )) \ -) - -#define FsRtlInitPerFileContext( _fc, _owner, _inst, _cb) \ - ((_fc)->OwnerId = (_owner), \ - (_fc)->InstanceId = (_inst), \ - (_fc)->FreeCallback = (_cb)) - -#define FsRtlGetPerFileContextPointer(_fo) \ - (FsRtlSupportsPerFileContexts(_fo) ? \ - FsRtlGetPerStreamContextPointer(_fo)->FileContextSupportPointer : \ - NULL) - -#define FsRtlSupportsPerFileContexts(_fo) \ - ((FsRtlGetPerStreamContextPointer(_fo) != NULL) && \ - (FsRtlGetPerStreamContextPointer(_fo)->Version >= FSRTL_FCB_HEADER_V1) && \ - (FsRtlGetPerStreamContextPointer(_fo)->FileContextSupportPointer != NULL)) - -#define FsRtlSetupAdvancedHeaderEx( _advhdr, _fmutx, _fctxptr ) \ -{ \ - FsRtlSetupAdvancedHeader( _advhdr, _fmutx ); \ - if ((_fctxptr) != NULL) { \ - (_advhdr)->FileContextSupportPointer = (_fctxptr); \ - } \ -} - -#define FsRtlGetPerStreamContextPointer(FO) ( \ - (PFSRTL_ADVANCED_FCB_HEADER)(FO)->FsContext \ -) - -#define FsRtlInitPerStreamContext(PSC, O, I, FC) ( \ - (PSC)->OwnerId = (O), \ - (PSC)->InstanceId = (I), \ - (PSC)->FreeCallback = (FC) \ -) - -#define FsRtlSupportsPerStreamContexts(FO) ( \ - (BOOLEAN)((NULL != FsRtlGetPerStreamContextPointer(FO) && \ - FlagOn(FsRtlGetPerStreamContextPointer(FO)->Flags2, \ - FSRTL_FLAG2_SUPPORTS_FILTER_CONTEXTS)) \ -) - -#define FsRtlLookupPerStreamContext(_sc, _oid, _iid) \ - (((NULL != (_sc)) && \ - FlagOn((_sc)->Flags2,FSRTL_FLAG2_SUPPORTS_FILTER_CONTEXTS) && \ - !IsListEmpty(&(_sc)->FilterContexts)) ? \ - FsRtlLookupPerStreamContextInternal((_sc), (_oid), (_iid)) : \ - NULL) - -VOID -FORCEINLINE -NTAPI -FsRtlSetupAdvancedHeader( - IN PVOID AdvHdr, - IN PFAST_MUTEX FMutex ) -{ - PFSRTL_ADVANCED_FCB_HEADER localAdvHdr = (PFSRTL_ADVANCED_FCB_HEADER)AdvHdr; - - localAdvHdr->Flags |= FSRTL_FLAG_ADVANCED_HEADER; - localAdvHdr->Flags2 |= FSRTL_FLAG2_SUPPORTS_FILTER_CONTEXTS; -#if (NTDDI_VERSION >= NTDDI_VISTA) - localAdvHdr->Version = FSRTL_FCB_HEADER_V1; -#else - localAdvHdr->Version = FSRTL_FCB_HEADER_V0; -#endif - InitializeListHead( &localAdvHdr->FilterContexts ); - if (FMutex != NULL) { - localAdvHdr->FastMutex = FMutex; - } -#if (NTDDI_VERSION >= NTDDI_VISTA) - *((PULONG_PTR)(&localAdvHdr->PushLock)) = 0; - localAdvHdr->FileContextSupportPointer = NULL; -#endif -} - -#define FsRtlInitPerFileObjectContext(_fc, _owner, _inst) \ - ((_fc)->OwnerId = (_owner), (_fc)->InstanceId = (_inst)) - -#define FsRtlCompleteRequest(IRP,STATUS) { \ - (IRP)->IoStatus.Status = (STATUS); \ - IoCompleteRequest( (IRP), IO_DISK_INCREMENT ); \ -} - -#if (NTDDI_VERSION >= NTDDI_WIN7) -typedef struct _ECP_HEADER ECP_HEADER, *PECP_HEADER; -#endif - -#if (NTDDI_VERSION >= NTDDI_VISTA) - -typedef enum _NETWORK_OPEN_LOCATION_QUALIFIER { - NetworkOpenLocationAny, - NetworkOpenLocationRemote, - NetworkOpenLocationLoopback -} NETWORK_OPEN_LOCATION_QUALIFIER; - -typedef enum _NETWORK_OPEN_INTEGRITY_QUALIFIER { - NetworkOpenIntegrityAny, - NetworkOpenIntegrityNone, - NetworkOpenIntegritySigned, - NetworkOpenIntegrityEncrypted, - NetworkOpenIntegrityMaximum -} NETWORK_OPEN_INTEGRITY_QUALIFIER; - -#if (NTDDI_VERSION >= NTDDI_WIN7) - -#define NETWORK_OPEN_ECP_IN_FLAG_DISABLE_HANDLE_COLLAPSING 0x1 -#define NETWORK_OPEN_ECP_IN_FLAG_DISABLE_HANDLE_DURABILITY 0x2 -#define NETWORK_OPEN_ECP_IN_FLAG_FORCE_BUFFERED_SYNCHRONOUS_IO_HACK 0x80000000 - -typedef struct _NETWORK_OPEN_ECP_CONTEXT { - USHORT Size; - USHORT Reserved; - struct { - struct { - NETWORK_OPEN_LOCATION_QUALIFIER Location; - NETWORK_OPEN_INTEGRITY_QUALIFIER Integrity; - ULONG Flags; - } in; - struct { - NETWORK_OPEN_LOCATION_QUALIFIER Location; - NETWORK_OPEN_INTEGRITY_QUALIFIER Integrity; - ULONG Flags; - } out; - } DUMMYSTRUCTNAME; -} NETWORK_OPEN_ECP_CONTEXT, *PNETWORK_OPEN_ECP_CONTEXT; - -typedef struct _NETWORK_OPEN_ECP_CONTEXT_V0 { - USHORT Size; - USHORT Reserved; - struct { - struct { - NETWORK_OPEN_LOCATION_QUALIFIER Location; - NETWORK_OPEN_INTEGRITY_QUALIFIER Integrity; - } in; - struct { - NETWORK_OPEN_LOCATION_QUALIFIER Location; - NETWORK_OPEN_INTEGRITY_QUALIFIER Integrity; - } out; - } DUMMYSTRUCTNAME; -} NETWORK_OPEN_ECP_CONTEXT_V0, *PNETWORK_OPEN_ECP_CONTEXT_V0; - -#elif (NTDDI_VERSION >= NTDDI_VISTA) -typedef struct _NETWORK_OPEN_ECP_CONTEXT { - USHORT Size; - USHORT Reserved; - struct { - struct { - NETWORK_OPEN_LOCATION_QUALIFIER Location; - NETWORK_OPEN_INTEGRITY_QUALIFIER Integrity; - } in; - struct { - NETWORK_OPEN_LOCATION_QUALIFIER Location; - NETWORK_OPEN_INTEGRITY_QUALIFIER Integrity; - } out; - } DUMMYSTRUCTNAME; -} NETWORK_OPEN_ECP_CONTEXT, *PNETWORK_OPEN_ECP_CONTEXT; -#endif - -DEFINE_GUID(GUID_ECP_NETWORK_OPEN_CONTEXT, 0xc584edbf, 0x00df, 0x4d28, 0xb8, 0x84, 0x35, 0xba, 0xca, 0x89, 0x11, 0xe8 ); - -#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ - - -#if (NTDDI_VERSION >= NTDDI_VISTA) - -typedef struct _PREFETCH_OPEN_ECP_CONTEXT { - PVOID Context; -} PREFETCH_OPEN_ECP_CONTEXT, *PPREFETCH_OPEN_ECP_CONTEXT; - -DEFINE_GUID(GUID_ECP_PREFETCH_OPEN, 0xe1777b21, 0x847e, 0x4837, 0xaa, 0x45, 0x64, 0x16, 0x1d, 0x28, 0x6, 0x55 ); - -#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ - -#if (NTDDI_VERSION >= NTDDI_WIN7) - -DEFINE_GUID (GUID_ECP_NFS_OPEN, 0xf326d30c, 0xe5f8, 0x4fe7, 0xab, 0x74, 0xf5, 0xa3, 0x19, 0x6d, 0x92, 0xdb); -DEFINE_GUID(GUID_ECP_SRV_OPEN, 0xbebfaebc, 0xaabf, 0x489d, 0x9d, 0x2c, 0xe9, 0xe3, 0x61, 0x10, 0x28, 0x53 ); - -typedef struct sockaddr_storage *PSOCKADDR_STORAGE_NFS; - -typedef struct _NFS_OPEN_ECP_CONTEXT { - PUNICODE_STRING ExportAlias; - PSOCKADDR_STORAGE_NFS ClientSocketAddress; -} NFS_OPEN_ECP_CONTEXT, *PNFS_OPEN_ECP_CONTEXT, **PPNFS_OPEN_ECP_CONTEXT; - -typedef struct _SRV_OPEN_ECP_CONTEXT { - PUNICODE_STRING ShareName; - PSOCKADDR_STORAGE_NFS SocketAddress; - BOOLEAN OplockBlockState; - BOOLEAN OplockAppState; - BOOLEAN OplockFinalState; -} SRV_OPEN_ECP_CONTEXT, *PSRV_OPEN_ECP_CONTEXT; - -#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ - -#define VACB_MAPPING_GRANULARITY (0x40000) -#define VACB_OFFSET_SHIFT (18) - -typedef struct _PUBLIC_BCB { - CSHORT NodeTypeCode; - CSHORT NodeByteSize; - ULONG MappedLength; - LARGE_INTEGER MappedFileOffset; -} PUBLIC_BCB, *PPUBLIC_BCB; - -typedef struct _CC_FILE_SIZES { - LARGE_INTEGER AllocationSize; - LARGE_INTEGER FileSize; - LARGE_INTEGER ValidDataLength; -} CC_FILE_SIZES, *PCC_FILE_SIZES; - -typedef BOOLEAN -(NTAPI *PACQUIRE_FOR_LAZY_WRITE) ( - IN PVOID Context, - IN BOOLEAN Wait); - -typedef VOID -(NTAPI *PRELEASE_FROM_LAZY_WRITE) ( - IN PVOID Context); - -typedef BOOLEAN -(NTAPI *PACQUIRE_FOR_READ_AHEAD) ( - IN PVOID Context, - IN BOOLEAN Wait); - -typedef VOID -(NTAPI *PRELEASE_FROM_READ_AHEAD) ( - IN PVOID Context); - -typedef struct _CACHE_MANAGER_CALLBACKS { - PACQUIRE_FOR_LAZY_WRITE AcquireForLazyWrite; - PRELEASE_FROM_LAZY_WRITE ReleaseFromLazyWrite; - PACQUIRE_FOR_READ_AHEAD AcquireForReadAhead; - PRELEASE_FROM_READ_AHEAD ReleaseFromReadAhead; -} CACHE_MANAGER_CALLBACKS, *PCACHE_MANAGER_CALLBACKS; - -typedef struct _CACHE_UNINITIALIZE_EVENT { - struct _CACHE_UNINITIALIZE_EVENT *Next; - KEVENT Event; -} CACHE_UNINITIALIZE_EVENT, *PCACHE_UNINITIALIZE_EVENT; - -typedef VOID -(NTAPI *PDIRTY_PAGE_ROUTINE) ( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN PLARGE_INTEGER OldestLsn, - IN PLARGE_INTEGER NewestLsn, - IN PVOID Context1, - IN PVOID Context2); - -typedef VOID -(NTAPI *PFLUSH_TO_LSN) ( - IN PVOID LogHandle, - IN LARGE_INTEGER Lsn); - -typedef VOID -(NTAPI *PCC_POST_DEFERRED_WRITE) ( - IN PVOID Context1, - IN PVOID Context2); - -#define CcIsFileCached(FO) ( \ - ((FO)->SectionObjectPointer != NULL) && \ - (((PSECTION_OBJECT_POINTERS)(FO)->SectionObjectPointer)->SharedCacheMap != NULL) \ -) - -extern ULONG CcFastMdlReadWait; - -#if (NTDDI_VERSION >= NTDDI_WIN2K) - -NTKERNELAPI -VOID -NTAPI -CcInitializeCacheMap( - IN PFILE_OBJECT FileObject, - IN PCC_FILE_SIZES FileSizes, - IN BOOLEAN PinAccess, - IN PCACHE_MANAGER_CALLBACKS Callbacks, - IN PVOID LazyWriteContext); - -NTKERNELAPI -BOOLEAN -NTAPI -CcUninitializeCacheMap( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER TruncateSize OPTIONAL, - IN PCACHE_UNINITIALIZE_EVENT UninitializeCompleteEvent OPTIONAL); - -NTKERNELAPI -VOID -NTAPI -CcSetFileSizes( - IN PFILE_OBJECT FileObject, - IN PCC_FILE_SIZES FileSizes); - -NTKERNELAPI -VOID -NTAPI -CcSetDirtyPageThreshold( - IN PFILE_OBJECT FileObject, - IN ULONG DirtyPageThreshold); - -NTKERNELAPI -VOID -NTAPI -CcFlushCache( - IN PSECTION_OBJECT_POINTERS SectionObjectPointer, - IN PLARGE_INTEGER FileOffset OPTIONAL, - IN ULONG Length, - OUT PIO_STATUS_BLOCK IoStatus OPTIONAL); - -NTKERNELAPI -LARGE_INTEGER -NTAPI -CcGetFlushedValidData( - IN PSECTION_OBJECT_POINTERS SectionObjectPointer, - IN BOOLEAN BcbListHeld); - -NTKERNELAPI -BOOLEAN -NTAPI -CcZeroData( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER StartOffset, - IN PLARGE_INTEGER EndOffset, - IN BOOLEAN Wait); - -NTKERNELAPI -PVOID -NTAPI -CcRemapBcb( - IN PVOID Bcb); - -NTKERNELAPI -VOID -NTAPI -CcRepinBcb( - IN PVOID Bcb); - -NTKERNELAPI -VOID -NTAPI -CcUnpinRepinnedBcb( - IN PVOID Bcb, - IN BOOLEAN WriteThrough, - OUT PIO_STATUS_BLOCK IoStatus); - -NTKERNELAPI -PFILE_OBJECT -NTAPI -CcGetFileObjectFromSectionPtrs( - IN PSECTION_OBJECT_POINTERS SectionObjectPointer); - -NTKERNELAPI -PFILE_OBJECT -NTAPI -CcGetFileObjectFromBcb( - IN PVOID Bcb); - -NTKERNELAPI -BOOLEAN -NTAPI -CcCanIWrite( - IN PFILE_OBJECT FileObject, - IN ULONG BytesToWrite, - IN BOOLEAN Wait, - IN BOOLEAN Retrying); - -NTKERNELAPI -VOID -NTAPI -CcDeferWrite( - IN PFILE_OBJECT FileObject, - IN PCC_POST_DEFERRED_WRITE PostRoutine, - IN PVOID Context1, - IN PVOID Context2, - IN ULONG BytesToWrite, - IN BOOLEAN Retrying); - -NTKERNELAPI -BOOLEAN -NTAPI -CcCopyRead( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN BOOLEAN Wait, - OUT PVOID Buffer, - OUT PIO_STATUS_BLOCK IoStatus); - -NTKERNELAPI -VOID -NTAPI -CcFastCopyRead( - IN PFILE_OBJECT FileObject, - IN ULONG FileOffset, - IN ULONG Length, - IN ULONG PageCount, - OUT PVOID Buffer, - OUT PIO_STATUS_BLOCK IoStatus); - -NTKERNELAPI -BOOLEAN -NTAPI -CcCopyWrite( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN BOOLEAN Wait, - IN PVOID Buffer); - -NTKERNELAPI -VOID -NTAPI -CcFastCopyWrite( - IN PFILE_OBJECT FileObject, - IN ULONG FileOffset, - IN ULONG Length, - IN PVOID Buffer); - -NTKERNELAPI -VOID -NTAPI -CcMdlRead( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - OUT PMDL *MdlChain, - OUT PIO_STATUS_BLOCK IoStatus); - -NTKERNELAPI -VOID -NTAPI -CcMdlReadComplete( - IN PFILE_OBJECT FileObject, - IN PMDL MdlChain); - -NTKERNELAPI -VOID -NTAPI -CcPrepareMdlWrite( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - OUT PMDL *MdlChain, - OUT PIO_STATUS_BLOCK IoStatus); - -NTKERNELAPI -VOID -NTAPI -CcMdlWriteComplete( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN PMDL MdlChain); - -NTKERNELAPI -VOID -NTAPI -CcScheduleReadAhead( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length); - -NTKERNELAPI -NTSTATUS -NTAPI -CcWaitForCurrentLazyWriterActivity( - VOID); - -NTKERNELAPI -VOID -NTAPI -CcSetReadAheadGranularity( - IN PFILE_OBJECT FileObject, - IN ULONG Granularity); - -NTKERNELAPI -BOOLEAN -NTAPI -CcPinRead( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN ULONG Flags, - OUT PVOID *Bcb, - OUT PVOID *Buffer); - -NTKERNELAPI -BOOLEAN -NTAPI -CcPinMappedData( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN ULONG Flags, - IN OUT PVOID *Bcb); - -NTKERNELAPI -BOOLEAN -NTAPI -CcPreparePinWrite( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN BOOLEAN Zero, - IN ULONG Flags, - OUT PVOID *Bcb, - OUT PVOID *Buffer); - -NTKERNELAPI -VOID -NTAPI -CcSetDirtyPinnedData( - IN PVOID BcbVoid, - IN PLARGE_INTEGER Lsn OPTIONAL); - -NTKERNELAPI -VOID -NTAPI -CcUnpinData( - IN PVOID Bcb); - -NTKERNELAPI -VOID -NTAPI -CcSetBcbOwnerPointer( - IN PVOID Bcb, - IN PVOID OwnerPointer); - -NTKERNELAPI -VOID -NTAPI -CcUnpinDataForThread( - IN PVOID Bcb, - IN ERESOURCE_THREAD ResourceThreadId); - -NTKERNELAPI -VOID -NTAPI -CcSetAdditionalCacheAttributes( - IN PFILE_OBJECT FileObject, - IN BOOLEAN DisableReadAhead, - IN BOOLEAN DisableWriteBehind); - -NTKERNELAPI -BOOLEAN -NTAPI -CcIsThereDirtyData( - IN PVPB Vpb); - -#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ - -#if (NTDDI_VERSION >= NTDDI_WINXP) - -NTKERNELAPI -VOID -NTAPI -CcMdlWriteAbort( - IN PFILE_OBJECT FileObject, - IN PMDL MdlChain); - -NTKERNELAPI -VOID -NTAPI -CcSetLogHandleForFile( - IN PFILE_OBJECT FileObject, - IN PVOID LogHandle, - IN PFLUSH_TO_LSN FlushToLsnRoutine); - -NTKERNELAPI -LARGE_INTEGER -NTAPI -CcGetDirtyPages( - IN PVOID LogHandle, - IN PDIRTY_PAGE_ROUTINE DirtyPageRoutine, - IN PVOID Context1, - IN PVOID Context2); - -#endif - -#if (NTDDI_VERSION >= NTDDI_WINXP) -NTKERNELAPI -BOOLEAN -NTAPI -CcMapData( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN ULONG Flags, - OUT PVOID *Bcb, - OUT PVOID *Buffer); -#elif (NTDDI_VERSION >= NTDDI_WIN2K) -NTKERNELAPI -BOOLEAN -NTAPI -CcMapData( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN BOOLEAN Wait, - OUT PVOID *Bcb, - OUT PVOID *Buffer); -#endif - -#if (NTDDI_VERSION >= NTDDI_VISTA) - -NTKERNELAPI -NTSTATUS -NTAPI -CcSetFileSizesEx( - IN PFILE_OBJECT FileObject, - IN PCC_FILE_SIZES FileSizes); - -NTKERNELAPI -PFILE_OBJECT -NTAPI -CcGetFileObjectFromSectionPtrsRef( - IN PSECTION_OBJECT_POINTERS SectionObjectPointer); - -NTKERNELAPI -VOID -NTAPI -CcSetParallelFlushFile( - IN PFILE_OBJECT FileObject, - IN BOOLEAN EnableParallelFlush); - -NTKERNELAPI -BOOLEAN -CcIsThereDirtyDataEx( - IN PVPB Vpb, - IN PULONG NumberOfDirtyPages OPTIONAL); - -#endif - -#if (NTDDI_VERSION >= NTDDI_WIN7) -NTKERNELAPI -VOID -NTAPI -CcCoherencyFlushAndPurgeCache( - IN PSECTION_OBJECT_POINTERS SectionObjectPointer, - IN PLARGE_INTEGER FileOffset OPTIONAL, - IN ULONG Length, - OUT PIO_STATUS_BLOCK IoStatus, - IN ULONG Flags OPTIONAL); -#endif - -#define CcGetFileSizePointer(FO) ( \ - ((PLARGE_INTEGER)((FO)->SectionObjectPointer->SharedCacheMap) + 1) \ -) - -#define UNINITIALIZE_CACHE_MAPS (1) -#define DO_NOT_RETRY_PURGE (2) -#define DO_NOT_PURGE_DIRTY_PAGES (0x4) - -#define CC_FLUSH_AND_PURGE_NO_PURGE (0x1) - -#if (NTDDI_VERSION >= NTDDI_VISTA) -NTKERNELAPI -BOOLEAN -NTAPI -CcPurgeCacheSection( - IN PSECTION_OBJECT_POINTERS SectionObjectPointer, - IN PLARGE_INTEGER FileOffset OPTIONAL, - IN ULONG Length, - IN ULONG Flags); -#elif (NTDDI_VERSION >= NTDDI_WIN2K) -NTKERNELAPI -BOOLEAN -NTAPI -CcPurgeCacheSection( - IN PSECTION_OBJECT_POINTERS SectionObjectPointer, - IN PLARGE_INTEGER FileOffset OPTIONAL, - IN ULONG Length, - IN BOOLEAN UninitializeCacheMaps); -#endif - -#if (NTDDI_VERSION >= NTDDI_WIN7) -NTKERNELAPI -BOOLEAN -NTAPI -CcCopyWriteWontFlush( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length); -#else -#define CcCopyWriteWontFlush(FO, FOFF, LEN) ((LEN) <= 0x10000) -#endif - -#define CcReadAhead(FO, FOFF, LEN) ( \ - if ((LEN) >= 256) { \ - CcScheduleReadAhead((FO), (FOFF), (LEN)); \ - } \ -) - -#define PIN_WAIT (1) -#define PIN_EXCLUSIVE (2) -#define PIN_NO_READ (4) -#define PIN_IF_BCB (8) -#define PIN_CALLER_TRACKS_DIRTY_DATA (32) -#define PIN_HIGH_PRIORITY (64) - -#define MAP_WAIT 1 -#define MAP_NO_READ (16) -#define MAP_HIGH_PRIORITY (64) - -#define IOCTL_REDIR_QUERY_PATH CTL_CODE(FILE_DEVICE_NETWORK_FILE_SYSTEM, 99, METHOD_NEITHER, FILE_ANY_ACCESS) -#define IOCTL_REDIR_QUERY_PATH_EX CTL_CODE(FILE_DEVICE_NETWORK_FILE_SYSTEM, 100, METHOD_NEITHER, FILE_ANY_ACCESS) - -typedef struct _QUERY_PATH_REQUEST { - ULONG PathNameLength; - PIO_SECURITY_CONTEXT SecurityContext; - WCHAR FilePathName[1]; -} QUERY_PATH_REQUEST, *PQUERY_PATH_REQUEST; - -typedef struct _QUERY_PATH_REQUEST_EX { - PIO_SECURITY_CONTEXT pSecurityContext; - ULONG EaLength; - PVOID pEaBuffer; - UNICODE_STRING PathName; - UNICODE_STRING DomainServiceName; - ULONG_PTR Reserved[ 3 ]; -} QUERY_PATH_REQUEST_EX, *PQUERY_PATH_REQUEST_EX; - -typedef struct _QUERY_PATH_RESPONSE { - ULONG LengthAccepted; -} QUERY_PATH_RESPONSE, *PQUERY_PATH_RESPONSE; - -#define VOLSNAPCONTROLTYPE 0x00000053 -#define IOCTL_VOLSNAP_FLUSH_AND_HOLD_WRITES CTL_CODE(VOLSNAPCONTROLTYPE, 0, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) - -#if (NTDDI_VERSION >= NTDDI_WIN2K) - -NTSYSAPI -NTSTATUS -NTAPI -ZwQueryObject( - IN HANDLE Handle OPTIONAL, - IN OBJECT_INFORMATION_CLASS ObjectInformationClass, - OUT PVOID ObjectInformation OPTIONAL, - IN ULONG ObjectInformationLength, - OUT PULONG ReturnLength OPTIONAL); - -NTSYSAPI -NTSTATUS -NTAPI -ZwNotifyChangeKey( - IN HANDLE KeyHandle, - IN HANDLE EventHandle OPTIONAL, - IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, - IN PVOID ApcContext OPTIONAL, - OUT PIO_STATUS_BLOCK IoStatusBlock, - IN ULONG NotifyFilter, - IN BOOLEAN WatchSubtree, - OUT PVOID Buffer, - IN ULONG BufferLength, - IN BOOLEAN Asynchronous); - -NTSYSAPI -NTSTATUS -NTAPI -ZwCreateEvent( - OUT PHANDLE EventHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, - IN EVENT_TYPE EventType, - IN BOOLEAN InitialState); - -NTSYSAPI -NTSTATUS -NTAPI -ZwDeleteFile( - IN POBJECT_ATTRIBUTES ObjectAttributes); - -NTSYSAPI -NTSTATUS -NTAPI -ZwQueryDirectoryFile( - IN HANDLE FileHandle, - IN HANDLE Event OPTIONAL, - IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, - IN PVOID ApcContext OPTIONAL, - OUT PIO_STATUS_BLOCK IoStatusBlock, - OUT PVOID FileInformation, - IN ULONG Length, - IN FILE_INFORMATION_CLASS FileInformationClass, - IN BOOLEAN ReturnSingleEntry, - IN PUNICODE_STRING FileName OPTIONAL, - IN BOOLEAN RestartScan); - -NTSYSAPI -NTSTATUS -NTAPI -ZwSetVolumeInformationFile( - IN HANDLE FileHandle, - OUT PIO_STATUS_BLOCK IoStatusBlock, - IN PVOID FsInformation, - IN ULONG Length, - IN FS_INFORMATION_CLASS FsInformationClass); - -NTSYSAPI -NTSTATUS -NTAPI -ZwFsControlFile( - IN HANDLE FileHandle, - IN HANDLE Event OPTIONAL, - IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, - IN PVOID ApcContext OPTIONAL, - OUT PIO_STATUS_BLOCK IoStatusBlock, - IN ULONG FsControlCode, - IN PVOID InputBuffer OPTIONAL, - IN ULONG InputBufferLength, - OUT PVOID OutputBuffer OPTIONAL, - IN ULONG OutputBufferLength); - -NTSYSAPI -NTSTATUS -NTAPI -ZwDuplicateObject( - IN HANDLE SourceProcessHandle, - IN HANDLE SourceHandle, - IN HANDLE TargetProcessHandle OPTIONAL, - OUT PHANDLE TargetHandle OPTIONAL, - IN ACCESS_MASK DesiredAccess, - IN ULONG HandleAttributes, - IN ULONG Options); - -NTSYSAPI -NTSTATUS -NTAPI -ZwOpenDirectoryObject( - OUT PHANDLE DirectoryHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes); - -NTSYSAPI -NTSTATUS -NTAPI -ZwAllocateVirtualMemory( - IN HANDLE ProcessHandle, - IN OUT PVOID *BaseAddress, - IN ULONG_PTR ZeroBits, - IN OUT PSIZE_T RegionSize, - IN ULONG AllocationType, - IN ULONG Protect); - -NTSYSAPI -NTSTATUS -NTAPI -ZwFreeVirtualMemory( - IN HANDLE ProcessHandle, - IN OUT PVOID *BaseAddress, - IN OUT PSIZE_T RegionSize, - IN ULONG FreeType); - -NTSYSAPI -NTSTATUS -NTAPI -ZwWaitForSingleObject( - IN HANDLE Handle, - IN BOOLEAN Alertable, - IN PLARGE_INTEGER Timeout OPTIONAL); - -NTSYSAPI -NTSTATUS -NTAPI -ZwSetEvent( - IN HANDLE EventHandle, - OUT PLONG PreviousState OPTIONAL); - -NTSYSAPI -NTSTATUS -NTAPI -ZwFlushVirtualMemory( - IN HANDLE ProcessHandle, - IN OUT PVOID *BaseAddress, - IN OUT PSIZE_T RegionSize, - OUT PIO_STATUS_BLOCK IoStatusBlock); - -NTSYSAPI -NTSTATUS -NTAPI -ZwQueryInformationToken( - IN HANDLE TokenHandle, - IN TOKEN_INFORMATION_CLASS TokenInformationClass, - OUT PVOID TokenInformation, - IN ULONG Length, - OUT PULONG ResultLength); - -NTSYSAPI -NTSTATUS -NTAPI -ZwSetSecurityObject( - IN HANDLE Handle, - IN SECURITY_INFORMATION SecurityInformation, - IN PSECURITY_DESCRIPTOR SecurityDescriptor); - -NTSYSAPI -NTSTATUS -NTAPI -ZwQuerySecurityObject( - IN HANDLE FileHandle, - IN SECURITY_INFORMATION SecurityInformation, - OUT PSECURITY_DESCRIPTOR SecurityDescriptor, - IN ULONG Length, - OUT PULONG ResultLength); - -#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ - -#if (NTDDI_VERSION >= NTDDI_WINXP) - -NTSYSAPI -NTSTATUS -NTAPI -ZwOpenProcessTokenEx( - IN HANDLE ProcessHandle, - IN ACCESS_MASK DesiredAccess, - IN ULONG HandleAttributes, - OUT PHANDLE TokenHandle); - -NTSYSAPI -NTSTATUS -NTAPI -ZwOpenThreadTokenEx( - IN HANDLE ThreadHandle, - IN ACCESS_MASK DesiredAccess, - IN BOOLEAN OpenAsSelf, - IN ULONG HandleAttributes, - OUT PHANDLE TokenHandle); - -#endif - -#if (NTDDI_VERSION >= NTDDI_VISTA) - -NTSYSAPI -NTSTATUS -NTAPI -ZwLockFile( - IN HANDLE FileHandle, - IN HANDLE Event OPTIONAL, - IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, - IN PVOID ApcContext OPTIONAL, - OUT PIO_STATUS_BLOCK IoStatusBlock, - IN PLARGE_INTEGER ByteOffset, - IN PLARGE_INTEGER Length, - IN ULONG Key, - IN BOOLEAN FailImmediately, - IN BOOLEAN ExclusiveLock); - -NTSYSAPI -NTSTATUS -NTAPI -ZwUnlockFile( - IN HANDLE FileHandle, - OUT PIO_STATUS_BLOCK IoStatusBlock, - IN PLARGE_INTEGER ByteOffset, - IN PLARGE_INTEGER Length, - IN ULONG Key); - -NTSYSAPI -NTSTATUS -NTAPI -ZwQueryQuotaInformationFile( - IN HANDLE FileHandle, - OUT PIO_STATUS_BLOCK IoStatusBlock, - OUT PVOID Buffer, - IN ULONG Length, - IN BOOLEAN ReturnSingleEntry, - IN PVOID SidList, - IN ULONG SidListLength, - IN PSID StartSid OPTIONAL, - IN BOOLEAN RestartScan); - -NTSYSAPI -NTSTATUS -NTAPI -ZwSetQuotaInformationFile( - IN HANDLE FileHandle, - OUT PIO_STATUS_BLOCK IoStatusBlock, - IN PVOID Buffer, - IN ULONG Length); - -NTSYSAPI -NTSTATUS -NTAPI -ZwFlushBuffersFile( - IN HANDLE FileHandle, - OUT PIO_STATUS_BLOCK IoStatusBlock); - -#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ - -#if (NTDDI_VERSION >= NTDDI_WIN7) -NTSYSAPI -NTSTATUS -NTAPI -ZwSetInformationToken( - IN HANDLE TokenHandle, - IN TOKEN_INFORMATION_CLASS TokenInformationClass, - IN PVOID TokenInformation, - IN ULONG TokenInformationLength); -#endif - -NTSYSAPI -NTSTATUS -NTAPI -ZwQueryEaFile( - IN HANDLE FileHandle, - OUT PIO_STATUS_BLOCK IoStatusBlock, - OUT PVOID Buffer, - IN ULONG Length, - IN BOOLEAN ReturnSingleEntry, - IN PVOID EaList OPTIONAL, - IN ULONG EaListLength, - IN PULONG EaIndex OPTIONAL, - IN BOOLEAN RestartScan); - -NTSYSAPI -NTSTATUS -NTAPI -ZwSetEaFile( - IN HANDLE FileHandle, - OUT PIO_STATUS_BLOCK IoStatusBlock, - OUT PVOID Buffer, - IN ULONG Length); - -NTSYSAPI -NTSTATUS -NTAPI -ZwDuplicateToken( - IN HANDLE ExistingTokenHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes, - IN BOOLEAN EffectiveOnly, - IN TOKEN_TYPE TokenType, - OUT PHANDLE NewTokenHandle); #pragma pack(push,4) @@ -8890,6 +6863,11 @@ ZwDuplicateToken( #include "csq.h" +#ifdef _NTOSKRNL_ +extern PUCHAR FsRtlLegalAnsiCharacterArray; +#else +extern DECLSPEC_IMPORT PUCHAR FsRtlLegalAnsiCharacterArray; +#endif extern PACL SePublicDefaultDacl; extern PACL SeSystemDefaultDacl; @@ -8912,11 +6890,30 @@ extern PACL SeSystemDefaultDacl; #define FILE_VC_QUOTAS_LOG_VIOLATIONS 0x00000004 +#define FSRTL_VOLUME_DISMOUNT 1 +#define FSRTL_VOLUME_DISMOUNT_FAILED 2 +#define FSRTL_VOLUME_LOCK 3 +#define FSRTL_VOLUME_LOCK_FAILED 4 +#define FSRTL_VOLUME_UNLOCK 5 +#define FSRTL_VOLUME_MOUNT 6 + +#define FSRTL_WILD_CHARACTER 0x08 + +#define FSRTL_FAT_LEGAL 0x01 +#define FSRTL_HPFS_LEGAL 0x02 +#define FSRTL_NTFS_LEGAL 0x04 +#define FSRTL_WILD_CHARACTER 0x08 +#define FSRTL_OLE_LEGAL 0x10 +#define FSRTL_NTFS_STREAM_LEGAL 0x14 + #ifdef _X86_ #define HARDWARE_PTE HARDWARE_PTE_X86 #define PHARDWARE_PTE PHARDWARE_PTE_X86 #endif +#define IO_CHECK_CREATE_PARAMETERS 0x0200 +#define IO_ATTACH_DEVICE 0x0400 + #define IO_ATTACH_DEVICE_API 0x80000000 #define IO_TYPE_APC 18 @@ -8935,6 +6932,8 @@ extern PACL SeSystemDefaultDacl; #define MEM_DOS_LIM 0x40000000 +#define MCB_FLAG_RAISE_ON_ALLOCATION_FAILURE 1 + #define OB_TYPE_TYPE 1 #define OB_TYPE_DIRECTORY 2 #define OB_TYPE_SYMBOLIC_LINK 3 @@ -8959,12 +6958,23 @@ extern PACL SeSystemDefaultDacl; #define OB_TYPE_IO_COMPLETION 22 #define OB_TYPE_FILE 23 +#define PIN_WAIT (1) +#define PIN_EXCLUSIVE (2) +#define PIN_NO_READ (4) +#define PIN_IF_BCB (8) + #define SEC_BASED 0x00200000 +#define SECURITY_WORLD_SID_AUTHORITY {0,0,0,0,0,1} +#define SECURITY_WORLD_RID (0x00000000L) + /* end winnt.h */ #define TOKEN_HAS_ADMIN_GROUP 0x08 +#define VACB_MAPPING_GRANULARITY (0x40000) +#define VACB_OFFSET_SHIFT (18) + #if (VER_PRODUCTBUILD >= 1381) #define FSCTL_GET_HFS_INFORMATION CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 31, METHOD_BUFFERED, FILE_ANY_ACCESS) #endif /* (VER_PRODUCTBUILD >= 1381) */ @@ -8991,6 +7001,18 @@ extern PACL SeSystemDefaultDacl; #define FSCTL_NETWORK_SET_DOMAIN_NAME CTL_CODE(FILE_DEVICE_NETWORK_FILE_SYSTEM, 120, METHOD_BUFFERED, FILE_ANY_ACCESS) #define FSCTL_NETWORK_REMOTE_BOOT_INIT_SCRT CTL_CODE(FILE_DEVICE_NETWORK_FILE_SYSTEM, 250, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define IOCTL_REDIR_QUERY_PATH CTL_CODE(FILE_DEVICE_NETWORK_FILE_SYSTEM, 99, METHOD_NEITHER, FILE_ANY_ACCESS) + +typedef PVOID OPLOCK, *POPLOCK; + +// +// Forwarders +// +struct _RTL_AVL_TABLE; +struct _RTL_GENERIC_TABLE; + +typedef PVOID PNOTIFY_SYNC; + typedef enum _FILE_STORAGE_TYPE { StorageTypeDefault = 1, StorageTypeDirectory, @@ -9026,6 +7048,17 @@ typedef struct _BITMAP_RANGE { PULONG Bitmap; } BITMAP_RANGE, *PBITMAP_RANGE; +typedef struct _CACHE_UNINITIALIZE_EVENT { + struct _CACHE_UNINITIALIZE_EVENT *Next; + KEVENT Event; +} CACHE_UNINITIALIZE_EVENT, *PCACHE_UNINITIALIZE_EVENT; + +typedef struct _CC_FILE_SIZES { + LARGE_INTEGER AllocationSize; + LARGE_INTEGER FileSize; + LARGE_INTEGER ValidDataLength; +} CC_FILE_SIZES, *PCC_FILE_SIZES; + typedef struct _FILE_COPY_ON_WRITE_INFORMATION { BOOLEAN ReplaceIfExists; HANDLE RootDirectory; @@ -9048,6 +7081,49 @@ typedef struct _FILE_FULL_DIRECTORY_INFORMATION { WCHAR FileName[ANYSIZE_ARRAY]; } FILE_FULL_DIRECTORY_INFORMATION, *PFILE_FULL_DIRECTORY_INFORMATION; +typedef struct _FILE_FS_FULL_SIZE_INFORMATION { + LARGE_INTEGER TotalAllocationUnits; + LARGE_INTEGER CallerAvailableAllocationUnits; + LARGE_INTEGER ActualAvailableAllocationUnits; + ULONG SectorsPerAllocationUnit; + ULONG BytesPerSector; +} FILE_FS_FULL_SIZE_INFORMATION, *PFILE_FS_FULL_SIZE_INFORMATION; + +typedef struct _FILE_FS_LABEL_INFORMATION { + ULONG VolumeLabelLength; + WCHAR VolumeLabel[1]; +} FILE_FS_LABEL_INFORMATION, *PFILE_FS_LABEL_INFORMATION; + +#if (VER_PRODUCTBUILD >= 2195) + +typedef struct _FILE_FS_OBJECT_ID_INFORMATION { + UCHAR ObjectId[16]; + UCHAR ExtendedInfo[48]; +} FILE_FS_OBJECT_ID_INFORMATION, *PFILE_FS_OBJECT_ID_INFORMATION; + +#endif /* (VER_PRODUCTBUILD >= 2195) */ + +typedef struct _FILE_FS_SIZE_INFORMATION { + LARGE_INTEGER TotalAllocationUnits; + LARGE_INTEGER AvailableAllocationUnits; + ULONG SectorsPerAllocationUnit; + ULONG BytesPerSector; +} FILE_FS_SIZE_INFORMATION, *PFILE_FS_SIZE_INFORMATION; + +typedef struct _FILE_FS_VOLUME_INFORMATION { + LARGE_INTEGER VolumeCreationTime; + ULONG VolumeSerialNumber; + ULONG VolumeLabelLength; + BOOLEAN SupportsObjects; + WCHAR VolumeLabel[1]; +} FILE_FS_VOLUME_INFORMATION, *PFILE_FS_VOLUME_INFORMATION; + +typedef struct _FILE_FS_OBJECTID_INFORMATION +{ + UCHAR ObjectId[16]; + UCHAR ExtendedInfo[48]; +} FILE_FS_OBJECTID_INFORMATION, *PFILE_FS_OBJECTID_INFORMATION; + /* raw internal file lock struct returned from FsRtlGetNextFileLock */ typedef struct _FILE_SHARED_LOCK_ENTRY { PVOID Unknown1; @@ -9132,6 +7208,51 @@ typedef struct _FILE_OLE_STATE_BITS_INFORMATION { ULONG StateBitsMask; } FILE_OLE_STATE_BITS_INFORMATION, *PFILE_OLE_STATE_BITS_INFORMATION; +typedef enum _FSRTL_COMPARISON_RESULT +{ + LessThan = -1, + EqualTo = 0, + GreaterThan = 1 +} FSRTL_COMPARISON_RESULT; + +#if (VER_PRODUCTBUILD >= 2600) + +typedef struct _FSRTL_PER_STREAM_CONTEXT { + LIST_ENTRY Links; + PVOID OwnerId; + PVOID InstanceId; + PFREE_FUNCTION FreeCallback; +} FSRTL_PER_STREAM_CONTEXT, *PFSRTL_PER_STREAM_CONTEXT; + +typedef struct _FSRTL_PER_FILEOBJECT_CONTEXT +{ + LIST_ENTRY Links; + PVOID OwnerId; + PVOID InstanceId; +} FSRTL_PER_FILEOBJECT_CONTEXT, *PFSRTL_PER_FILEOBJECT_CONTEXT; + +#endif /* (VER_PRODUCTBUILD >= 2600) */ + +typedef struct _BASE_MCB +{ + ULONG MaximumPairCount; + ULONG PairCount; + USHORT PoolType; + USHORT Flags; + PVOID Mapping; +} BASE_MCB, *PBASE_MCB; + +typedef struct _LARGE_MCB +{ + PKGUARDED_MUTEX GuardedMutex; + BASE_MCB BaseMcb; +} LARGE_MCB, *PLARGE_MCB; + +typedef struct _MCB +{ + LARGE_MCB DummyFieldThatSizesThisStructureCorrectly; +} MCB, *PMCB; + typedef struct _MAPPING_PAIR { ULONGLONG Vcn; ULONGLONG Lcn; @@ -9143,6 +7264,8 @@ typedef struct _GET_RETRIEVAL_DESCRIPTOR { MAPPING_PAIR Pair[1]; } GET_RETRIEVAL_DESCRIPTOR, *PGET_RETRIEVAL_DESCRIPTOR; +#define ASSERT_QUEUE(Q) ASSERT(((Q)->Header.Type & KOBJECT_TYPE_MASK) == QueueObject); + typedef struct _MBCB { CSHORT NodeTypeCode; CSHORT NodeIsInZone; @@ -9205,6 +7328,189 @@ typedef struct _OBJECT_ALL_TYPES_INFO { OBJECT_TYPE_INFO ObjectsTypeInfo[1]; } OBJECT_ALL_TYPES_INFO, *POBJECT_ALL_TYPES_INFO; +typedef enum _RTL_GENERIC_COMPARE_RESULTS +{ + GenericLessThan, + GenericGreaterThan, + GenericEqual +} RTL_GENERIC_COMPARE_RESULTS; + +typedef enum _TABLE_SEARCH_RESULT +{ + TableEmptyTree, + TableFoundNode, + TableInsertAsLeft, + TableInsertAsRight +} TABLE_SEARCH_RESULT; + +typedef NTSTATUS +(NTAPI *PRTL_AVL_MATCH_FUNCTION)( + struct _RTL_AVL_TABLE *Table, + PVOID UserData, + PVOID MatchData +); + +typedef RTL_GENERIC_COMPARE_RESULTS +(NTAPI *PRTL_AVL_COMPARE_ROUTINE) ( + struct _RTL_AVL_TABLE *Table, + PVOID FirstStruct, + PVOID SecondStruct +); + +typedef RTL_GENERIC_COMPARE_RESULTS +(NTAPI *PRTL_GENERIC_COMPARE_ROUTINE) ( + struct _RTL_GENERIC_TABLE *Table, + PVOID FirstStruct, + PVOID SecondStruct +); + +typedef PVOID +(NTAPI *PRTL_GENERIC_ALLOCATE_ROUTINE) ( + struct _RTL_GENERIC_TABLE *Table, + CLONG ByteSize +); + +typedef VOID +(NTAPI *PRTL_GENERIC_FREE_ROUTINE) ( + struct _RTL_GENERIC_TABLE *Table, + PVOID Buffer +); + +typedef PVOID +(NTAPI *PRTL_AVL_ALLOCATE_ROUTINE) ( + struct _RTL_AVL_TABLE *Table, + CLONG ByteSize +); + +typedef VOID +(NTAPI *PRTL_AVL_FREE_ROUTINE) ( + struct _RTL_AVL_TABLE *Table, + PVOID Buffer +); + +typedef struct _PUBLIC_BCB { + CSHORT NodeTypeCode; + CSHORT NodeByteSize; + ULONG MappedLength; + LARGE_INTEGER MappedFileOffset; +} PUBLIC_BCB, *PPUBLIC_BCB; + +typedef struct _QUERY_PATH_REQUEST { + ULONG PathNameLength; + PIO_SECURITY_CONTEXT SecurityContext; + WCHAR FilePathName[1]; +} QUERY_PATH_REQUEST, *PQUERY_PATH_REQUEST; + +typedef struct _QUERY_PATH_RESPONSE { + ULONG LengthAccepted; +} QUERY_PATH_RESPONSE, *PQUERY_PATH_RESPONSE; + +typedef struct _RTL_BALANCED_LINKS +{ + struct _RTL_BALANCED_LINKS *Parent; + struct _RTL_BALANCED_LINKS *LeftChild; + struct _RTL_BALANCED_LINKS *RightChild; + CHAR Balance; + UCHAR Reserved[3]; +} RTL_BALANCED_LINKS, *PRTL_BALANCED_LINKS; + +typedef struct _RTL_GENERIC_TABLE +{ + PRTL_SPLAY_LINKS TableRoot; + LIST_ENTRY InsertOrderList; + PLIST_ENTRY OrderedPointer; + ULONG WhichOrderedElement; + ULONG NumberGenericTableElements; + PRTL_GENERIC_COMPARE_ROUTINE CompareRoutine; + PRTL_GENERIC_ALLOCATE_ROUTINE AllocateRoutine; + PRTL_GENERIC_FREE_ROUTINE FreeRoutine; + PVOID TableContext; +} RTL_GENERIC_TABLE, *PRTL_GENERIC_TABLE; + +#undef PRTL_GENERIC_COMPARE_ROUTINE +#undef PRTL_GENERIC_ALLOCATE_ROUTINE +#undef PRTL_GENERIC_FREE_ROUTINE +#undef RTL_GENERIC_TABLE +#undef PRTL_GENERIC_TABLE + +#define PRTL_GENERIC_COMPARE_ROUTINE PRTL_AVL_COMPARE_ROUTINE +#define PRTL_GENERIC_ALLOCATE_ROUTINE PRTL_AVL_ALLOCATE_ROUTINE +#define PRTL_GENERIC_FREE_ROUTINE PRTL_AVL_FREE_ROUTINE +#define RTL_GENERIC_TABLE RTL_AVL_TABLE +#define PRTL_GENERIC_TABLE PRTL_AVL_TABLE + +#define RtlInitializeGenericTable RtlInitializeGenericTableAvl +#define RtlInsertElementGenericTable RtlInsertElementGenericTableAvl +#define RtlInsertElementGenericTableFull RtlInsertElementGenericTableFullAvl +#define RtlDeleteElementGenericTable RtlDeleteElementGenericTableAvl +#define RtlLookupElementGenericTable RtlLookupElementGenericTableAvl +#define RtlLookupElementGenericTableFull RtlLookupElementGenericTableFullAvl +#define RtlEnumerateGenericTable RtlEnumerateGenericTableAvl +#define RtlEnumerateGenericTableWithoutSplaying RtlEnumerateGenericTableWithoutSplayingAvl +#define RtlGetElementGenericTable RtlGetElementGenericTableAvl +#define RtlNumberGenericTableElements RtlNumberGenericTableElementsAvl +#define RtlIsGenericTableEmpty RtlIsGenericTableEmptyAvl + +typedef struct _RTL_AVL_TABLE +{ + RTL_BALANCED_LINKS BalancedRoot; + PVOID OrderedPointer; + ULONG WhichOrderedElement; + ULONG NumberGenericTableElements; + ULONG DepthOfTree; + PRTL_BALANCED_LINKS RestartKey; + ULONG DeleteCount; + PRTL_AVL_COMPARE_ROUTINE CompareRoutine; + PRTL_AVL_ALLOCATE_ROUTINE AllocateRoutine; + PRTL_AVL_FREE_ROUTINE FreeRoutine; + PVOID TableContext; +} RTL_AVL_TABLE, *PRTL_AVL_TABLE; + +NTSYSAPI +VOID +NTAPI +RtlInitializeGenericTableAvl( + PRTL_AVL_TABLE Table, + PRTL_AVL_COMPARE_ROUTINE CompareRoutine, + PRTL_AVL_ALLOCATE_ROUTINE AllocateRoutine, + PRTL_AVL_FREE_ROUTINE FreeRoutine, + PVOID TableContext +); + +NTSYSAPI +PVOID +NTAPI +RtlInsertElementGenericTableAvl ( + PRTL_AVL_TABLE Table, + PVOID Buffer, + CLONG BufferSize, + PBOOLEAN NewElement OPTIONAL + ); + +NTSYSAPI +BOOLEAN +NTAPI +RtlDeleteElementGenericTableAvl ( + PRTL_AVL_TABLE Table, + PVOID Buffer + ); + +NTSYSAPI +PVOID +NTAPI +RtlLookupElementGenericTableAvl ( + PRTL_AVL_TABLE Table, + PVOID Buffer + ); + +NTSYSAPI +PVOID +NTAPI +RtlEnumerateGenericTableWithoutSplayingAvl ( + PRTL_AVL_TABLE Table, + PVOID *RestartKey + ); + #if defined(USE_LPC6432) #define LPC_CLIENT_ID CLIENT_ID64 #define LPC_SIZE_T ULONGLONG @@ -9269,6 +7575,13 @@ typedef struct _REMOTE_PORT_VIEW LPC_PVOID ViewBase; } REMOTE_PORT_VIEW, *PREMOTE_PORT_VIEW; +typedef struct _TUNNEL { + FAST_MUTEX Mutex; + PRTL_SPLAY_LINKS Cache; + LIST_ENTRY TimerQueue; + USHORT NumEntries; +} TUNNEL, *PTUNNEL; + typedef struct _VAD_HEADER { PVOID StartVPN; PVOID EndVPN; @@ -9283,6 +7596,150 @@ typedef struct _VAD_HEADER { LIST_ENTRY Secured; } VAD_HEADER, *PVAD_HEADER; +#if (VER_PRODUCTBUILD >= 2600) + +typedef BOOLEAN +(NTAPI *PFILTER_REPORT_CHANGE) ( + IN PVOID NotifyContext, + IN PVOID FilterContext +); + +#endif + +NTKERNELAPI +BOOLEAN +NTAPI +CcCanIWrite ( + IN PFILE_OBJECT FileObject, + IN ULONG BytesToWrite, + IN BOOLEAN Wait, + IN BOOLEAN Retrying +); + +NTKERNELAPI +BOOLEAN +NTAPI +CcCopyRead ( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN BOOLEAN Wait, + OUT PVOID Buffer, + OUT PIO_STATUS_BLOCK IoStatus +); + +NTKERNELAPI +BOOLEAN +NTAPI +CcCopyWrite ( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN BOOLEAN Wait, + IN PVOID Buffer +); + +#define CcCopyWriteWontFlush(FO, FOFF, LEN) ((LEN) <= 0x10000) + +typedef VOID (NTAPI *PCC_POST_DEFERRED_WRITE) ( + IN PVOID Context1, + IN PVOID Context2 +); + +NTKERNELAPI +VOID +NTAPI +CcDeferWrite ( + IN PFILE_OBJECT FileObject, + IN PCC_POST_DEFERRED_WRITE PostRoutine, + IN PVOID Context1, + IN PVOID Context2, + IN ULONG BytesToWrite, + IN BOOLEAN Retrying +); + +NTKERNELAPI +VOID +NTAPI +CcFastCopyRead ( + IN PFILE_OBJECT FileObject, + IN ULONG FileOffset, + IN ULONG Length, + IN ULONG PageCount, + OUT PVOID Buffer, + OUT PIO_STATUS_BLOCK IoStatus +); + +NTKERNELAPI +VOID +NTAPI +CcFastCopyWrite ( + IN PFILE_OBJECT FileObject, + IN ULONG FileOffset, + IN ULONG Length, + IN PVOID Buffer +); + +NTKERNELAPI +VOID +NTAPI +CcFlushCache ( + IN PSECTION_OBJECT_POINTERS SectionObjectPointer, + IN PLARGE_INTEGER FileOffset OPTIONAL, + IN ULONG Length, + OUT PIO_STATUS_BLOCK IoStatus OPTIONAL +); + +typedef VOID (NTAPI *PDIRTY_PAGE_ROUTINE) ( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN PLARGE_INTEGER OldestLsn, + IN PLARGE_INTEGER NewestLsn, + IN PVOID Context1, + IN PVOID Context2 +); + +NTKERNELAPI +LARGE_INTEGER +NTAPI +CcGetDirtyPages ( + IN PVOID LogHandle, + IN PDIRTY_PAGE_ROUTINE DirtyPageRoutine, + IN PVOID Context1, + IN PVOID Context2 +); + +NTKERNELAPI +PFILE_OBJECT +NTAPI +CcGetFileObjectFromBcb ( + IN PVOID Bcb +); + +NTKERNELAPI +PFILE_OBJECT +NTAPI +CcGetFileObjectFromSectionPtrs ( + IN PSECTION_OBJECT_POINTERS SectionObjectPointer +); + +#define CcGetFileSizePointer(FO) ( \ + ((PLARGE_INTEGER)((FO)->SectionObjectPointer->SharedCacheMap) + 1) \ +) + +#if (VER_PRODUCTBUILD >= 2195) + +NTKERNELAPI +LARGE_INTEGER +NTAPI +CcGetFlushedValidData ( + IN PSECTION_OBJECT_POINTERS SectionObjectPointer, + IN BOOLEAN BcbListHeld +); + +#endif /* (VER_PRODUCTBUILD >= 2195) */ + NTKERNELAPI LARGE_INTEGER NTAPI @@ -9291,6 +7748,428 @@ CcGetLsnForFileObject ( OUT PLARGE_INTEGER OldestLsn OPTIONAL ); +typedef BOOLEAN (NTAPI *PACQUIRE_FOR_LAZY_WRITE) ( + IN PVOID Context, + IN BOOLEAN Wait +); + +typedef VOID (NTAPI *PRELEASE_FROM_LAZY_WRITE) ( + IN PVOID Context +); + +typedef BOOLEAN (NTAPI *PACQUIRE_FOR_READ_AHEAD) ( + IN PVOID Context, + IN BOOLEAN Wait +); + +typedef VOID (NTAPI *PRELEASE_FROM_READ_AHEAD) ( + IN PVOID Context +); + +typedef struct _CACHE_MANAGER_CALLBACKS { + PACQUIRE_FOR_LAZY_WRITE AcquireForLazyWrite; + PRELEASE_FROM_LAZY_WRITE ReleaseFromLazyWrite; + PACQUIRE_FOR_READ_AHEAD AcquireForReadAhead; + PRELEASE_FROM_READ_AHEAD ReleaseFromReadAhead; +} CACHE_MANAGER_CALLBACKS, *PCACHE_MANAGER_CALLBACKS; + +NTKERNELAPI +VOID +NTAPI +CcInitializeCacheMap ( + IN PFILE_OBJECT FileObject, + IN PCC_FILE_SIZES FileSizes, + IN BOOLEAN PinAccess, + IN PCACHE_MANAGER_CALLBACKS Callbacks, + IN PVOID LazyWriteContext +); + +#define CcIsFileCached(FO) ( \ + ((FO)->SectionObjectPointer != NULL) && \ + (((PSECTION_OBJECT_POINTERS)(FO)->SectionObjectPointer)->SharedCacheMap != NULL) \ +) + +extern ULONG CcFastMdlReadWait; + +NTKERNELAPI +BOOLEAN +NTAPI +CcIsThereDirtyData ( + IN PVPB Vpb +); + +NTKERNELAPI +BOOLEAN +NTAPI +CcMapData ( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN ULONG Flags, + OUT PVOID *Bcb, + OUT PVOID *Buffer +); + +NTKERNELAPI +VOID +NTAPI +CcMdlRead ( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + OUT PMDL *MdlChain, + OUT PIO_STATUS_BLOCK IoStatus +); + +NTKERNELAPI +VOID +NTAPI +CcMdlReadComplete ( + IN PFILE_OBJECT FileObject, + IN PMDL MdlChain +); + +NTKERNELAPI +VOID +NTAPI +CcMdlWriteComplete ( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN PMDL MdlChain +); + +#define MAP_WAIT 1 + +NTKERNELAPI +BOOLEAN +NTAPI +CcPinMappedData ( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN ULONG Flags, + IN OUT PVOID *Bcb +); + +NTKERNELAPI +BOOLEAN +NTAPI +CcPinRead ( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN ULONG Flags, + OUT PVOID *Bcb, + OUT PVOID *Buffer +); + +NTKERNELAPI +VOID +NTAPI +CcPrepareMdlWrite ( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + OUT PMDL *MdlChain, + OUT PIO_STATUS_BLOCK IoStatus +); + +NTKERNELAPI +BOOLEAN +NTAPI +CcPreparePinWrite ( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN BOOLEAN Zero, + IN ULONG Flags, + OUT PVOID *Bcb, + OUT PVOID *Buffer +); + +NTKERNELAPI +BOOLEAN +NTAPI +CcPurgeCacheSection ( + IN PSECTION_OBJECT_POINTERS SectionObjectPointer, + IN PLARGE_INTEGER FileOffset OPTIONAL, + IN ULONG Length, + IN BOOLEAN UninitializeCacheMaps +); + +#define CcReadAhead(FO, FOFF, LEN) ( \ + if ((LEN) >= 256) { \ + CcScheduleReadAhead((FO), (FOFF), (LEN)); \ + } \ +) + +#if (VER_PRODUCTBUILD >= 2195) + +NTKERNELAPI +PVOID +NTAPI +CcRemapBcb ( + IN PVOID Bcb +); + +#endif /* (VER_PRODUCTBUILD >= 2195) */ + +NTKERNELAPI +VOID +NTAPI +CcRepinBcb ( + IN PVOID Bcb +); + +NTKERNELAPI +VOID +NTAPI +CcScheduleReadAhead ( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length +); + +NTKERNELAPI +VOID +NTAPI +CcSetAdditionalCacheAttributes ( + IN PFILE_OBJECT FileObject, + IN BOOLEAN DisableReadAhead, + IN BOOLEAN DisableWriteBehind +); + +NTKERNELAPI +VOID +NTAPI +CcSetBcbOwnerPointer ( + IN PVOID Bcb, + IN PVOID OwnerPointer +); + +NTKERNELAPI +VOID +NTAPI +CcSetDirtyPageThreshold ( + IN PFILE_OBJECT FileObject, + IN ULONG DirtyPageThreshold +); + +NTKERNELAPI +VOID +NTAPI +CcSetDirtyPinnedData ( + IN PVOID BcbVoid, + IN PLARGE_INTEGER Lsn OPTIONAL +); + +NTKERNELAPI +VOID +NTAPI +CcSetFileSizes ( + IN PFILE_OBJECT FileObject, + IN PCC_FILE_SIZES FileSizes +); + +typedef VOID (NTAPI *PFLUSH_TO_LSN) ( + IN PVOID LogHandle, + IN LARGE_INTEGER Lsn +); + +NTKERNELAPI +VOID +NTAPI +CcSetLogHandleForFile ( + IN PFILE_OBJECT FileObject, + IN PVOID LogHandle, + IN PFLUSH_TO_LSN FlushToLsnRoutine +); + +NTKERNELAPI +VOID +NTAPI +CcSetReadAheadGranularity ( + IN PFILE_OBJECT FileObject, + IN ULONG Granularity /* default: PAGE_SIZE */ + /* allowed: 2^n * PAGE_SIZE */ +); + +NTKERNELAPI +BOOLEAN +NTAPI +CcUninitializeCacheMap ( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER TruncateSize OPTIONAL, + IN PCACHE_UNINITIALIZE_EVENT UninitializeCompleteEvent OPTIONAL +); + +NTKERNELAPI +VOID +NTAPI +CcUnpinData ( + IN PVOID Bcb +); + +NTKERNELAPI +VOID +NTAPI +CcUnpinDataForThread ( + IN PVOID Bcb, + IN ERESOURCE_THREAD ResourceThreadId +); + +NTKERNELAPI +VOID +NTAPI +CcUnpinRepinnedBcb ( + IN PVOID Bcb, + IN BOOLEAN WriteThrough, + OUT PIO_STATUS_BLOCK IoStatus +); + +#if (VER_PRODUCTBUILD >= 2195) + +NTKERNELAPI +NTSTATUS +NTAPI +CcWaitForCurrentLazyWriterActivity ( + VOID +); + +#endif /* (VER_PRODUCTBUILD >= 2195) */ + +NTKERNELAPI +BOOLEAN +NTAPI +CcZeroData ( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER StartOffset, + IN PLARGE_INTEGER EndOffset, + IN BOOLEAN Wait +); + +#if (VER_PRODUCTBUILD >= 2600) + +#ifndef __NTOSKRNL__ +NTKERNELAPI +VOID +FASTCALL +ExInitializeRundownProtection ( + IN PEX_RUNDOWN_REF RunRef +); + +NTKERNELAPI +VOID +FASTCALL +ExReInitializeRundownProtection ( + IN PEX_RUNDOWN_REF RunRef +); + +NTKERNELAPI +BOOLEAN +FASTCALL +ExAcquireRundownProtection ( + IN PEX_RUNDOWN_REF RunRef +); + +NTKERNELAPI +BOOLEAN +FASTCALL +ExAcquireRundownProtectionEx ( + IN PEX_RUNDOWN_REF RunRef, + IN ULONG Count +); + +NTKERNELAPI +VOID +FASTCALL +ExReleaseRundownProtection ( + IN PEX_RUNDOWN_REF RunRef +); + +NTKERNELAPI +VOID +FASTCALL +ExReleaseRundownProtectionEx ( + IN PEX_RUNDOWN_REF RunRef, + IN ULONG Count +); + +NTKERNELAPI +VOID +FASTCALL +ExRundownCompleted ( + IN PEX_RUNDOWN_REF RunRef +); + +NTKERNELAPI +VOID +FASTCALL +ExWaitForRundownProtectionRelease ( + IN PEX_RUNDOWN_REF RunRef +); + +#endif +#endif /* (VER_PRODUCTBUILD >= 2600) */ + + +#define FsRtlSetupAdvancedHeader( _advhdr, _fmutx ) \ +{ \ + SetFlag( (_advhdr)->Flags, FSRTL_FLAG_ADVANCED_HEADER ); \ + SetFlag( (_advhdr)->Flags2, FSRTL_FLAG2_SUPPORTS_FILTER_CONTEXTS ); \ + (_advhdr)->Version = FSRTL_FCB_HEADER_V1; \ + InitializeListHead( &(_advhdr)->FilterContexts ); \ + if ((_fmutx) != NULL) { \ + (_advhdr)->FastMutex = (_fmutx); \ + } \ + *((PULONG_PTR)(&(_advhdr)->PushLock)) = 0; \ + /*ExInitializePushLock( &(_advhdr)->PushLock ); API Not avaliable downlevel*/\ + (_advhdr)->FileContextSupportPointer = NULL; \ +} + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlAddBaseMcbEntry ( + IN PBASE_MCB Mcb, + IN LONGLONG Vbn, + IN LONGLONG Lbn, + IN LONGLONG SectorCount +); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlAddLargeMcbEntry ( + IN PLARGE_MCB Mcb, + IN LONGLONG Vbn, + IN LONGLONG Lbn, + IN LONGLONG SectorCount +); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlAddMcbEntry ( + IN PMCB Mcb, + IN VBN Vbn, + IN LBN Lbn, + IN ULONG SectorCount +); + +NTKERNELAPI +VOID +NTAPI +FsRtlAddToTunnelCache ( + IN PTUNNEL Cache, + IN ULONGLONG DirectoryKey, + IN PUNICODE_STRING ShortName, + IN PUNICODE_STRING LongName, + IN BOOLEAN KeyByShortName, + IN ULONG DataLength, + IN PVOID Data +); + NTKERNELAPI PVOID NTAPI @@ -9325,6 +8204,251 @@ FsRtlAllocatePoolWithTag ( IN ULONG Tag ); +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlAreNamesEqual ( + IN PCUNICODE_STRING Name1, + IN PCUNICODE_STRING Name2, + IN BOOLEAN IgnoreCase, + IN PCWCH UpcaseTable OPTIONAL +); + +#define FsRtlAreThereCurrentFileLocks(FL) ( \ + ((FL)->FastIoIsQuestionable) \ +) + +typedef +VOID +(NTAPI*POPLOCK_WAIT_COMPLETE_ROUTINE) ( + IN PVOID Context, + IN PIRP Irp +); + +typedef +VOID +(NTAPI*POPLOCK_FS_PREPOST_IRP) ( + IN PVOID Context, + IN PIRP Irp +); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlCheckOplock ( + IN POPLOCK Oplock, + IN PIRP Irp, + IN PVOID Context, + IN POPLOCK_WAIT_COMPLETE_ROUTINE CompletionRoutine OPTIONAL, + IN POPLOCK_FS_PREPOST_IRP PostIrpRoutine OPTIONAL +); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlCurrentBatchOplock ( + IN POPLOCK Oplock +); + +NTKERNELAPI +VOID +NTAPI +FsRtlDeleteKeyFromTunnelCache ( + IN PTUNNEL Cache, + IN ULONGLONG DirectoryKey +); + +NTKERNELAPI +VOID +NTAPI +FsRtlDeleteTunnelCache ( + IN PTUNNEL Cache +); + +NTKERNELAPI +VOID +NTAPI +FsRtlDeregisterUncProvider ( + IN HANDLE Handle +); + +NTKERNELAPI +VOID +NTAPI +FsRtlDissectDbcs ( + IN ANSI_STRING Name, + OUT PANSI_STRING FirstPart, + OUT PANSI_STRING RemainingPart +); + +NTKERNELAPI +VOID +NTAPI +FsRtlDissectName ( + IN UNICODE_STRING Name, + OUT PUNICODE_STRING FirstPart, + OUT PUNICODE_STRING RemainingPart +); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlDoesDbcsContainWildCards ( + IN PANSI_STRING Name +); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlDoesNameContainWildCards ( + IN PUNICODE_STRING Name +); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlIsFatDbcsLegal ( + IN ANSI_STRING DbcsName, + IN BOOLEAN WildCardsPermissible, + IN BOOLEAN PathNamePermissible, + IN BOOLEAN LeadingBackslashPermissible + ); + + +#define FsRtlCompleteRequest(IRP,STATUS) { \ + (IRP)->IoStatus.Status = (STATUS); \ + IoCompleteRequest( (IRP), IO_DISK_INCREMENT ); \ +} + +#define FsRtlEnterFileSystem KeEnterCriticalRegion + +#define FsRtlExitFileSystem KeLeaveCriticalRegion + +#define FsRtlFastLock(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11) ( \ + FsRtlPrivateLock(A1, A2, A3, A4, A5, A6, A7, A8, A9, NULL, A10, A11) \ +) + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlFindInTunnelCache ( + IN PTUNNEL Cache, + IN ULONGLONG DirectoryKey, + IN PUNICODE_STRING Name, + OUT PUNICODE_STRING ShortName, + OUT PUNICODE_STRING LongName, + IN OUT PULONG DataLength, + OUT PVOID Data +); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlGetNextBaseMcbEntry ( + IN PBASE_MCB Mcb, + IN ULONG RunIndex, + OUT PLONGLONG Vbn, + OUT PLONGLONG Lbn, + OUT PLONGLONG SectorCount +); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlGetNextLargeMcbEntry ( + IN PLARGE_MCB Mcb, + IN ULONG RunIndex, + OUT PLONGLONG Vbn, + OUT PLONGLONG Lbn, + OUT PLONGLONG SectorCount +); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlGetNextMcbEntry ( + IN PMCB Mcb, + IN ULONG RunIndex, + OUT PVBN Vbn, + OUT PLBN Lbn, + OUT PULONG SectorCount +); + +#define FsRtlGetPerStreamContextPointer(FO) ( \ + (PFSRTL_ADVANCED_FCB_HEADER)(FO)->FsContext \ +) + +NTKERNELAPI +VOID +NTAPI +FsRtlInitializeBaseMcb ( + IN PBASE_MCB Mcb, + IN POOL_TYPE PoolType +); + +NTKERNELAPI +VOID +NTAPI +FsRtlInitializeLargeMcb ( + IN PLARGE_MCB Mcb, + IN POOL_TYPE PoolType +); + +NTKERNELAPI +VOID +NTAPI +FsRtlInitializeMcb ( + IN PMCB Mcb, + IN POOL_TYPE PoolType +); + +NTKERNELAPI +VOID +NTAPI +FsRtlInitializeOplock ( + IN OUT POPLOCK Oplock +); + +NTKERNELAPI +VOID +NTAPI +FsRtlInitializeTunnelCache ( + IN PTUNNEL Cache +); + +#define FsRtlInitPerStreamContext(PSC, O, I, FC) ( \ + (PSC)->OwnerId = (O), \ + (PSC)->InstanceId = (I), \ + (PSC)->FreeCallback = (FC) \ +) + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlInsertPerStreamContext ( + IN PFSRTL_ADVANCED_FCB_HEADER PerStreamContext, + IN PFSRTL_PER_STREAM_CONTEXT Ptr +); + +#define FsRtlIsAnsiCharacterLegalFat(C, WILD) ( \ + FlagOn(FsRtlLegalAnsiCharacterArray[(UCHAR)(C)], (FSRTL_FAT_LEGAL) | \ + ((WILD) ? FSRTL_WILD_CHARACTER : 0 )) \ +) + +#define FsRtlIsAnsiCharacterLegalHpfs(C, WILD) ( \ + FlagOn(FsRtlLegalAnsiCharacterArray[(UCHAR)(C)], (FSRTL_HPFS_LEGAL) | \ + ((WILD) ? FSRTL_WILD_CHARACTER : 0 )) \ +) + +#define FsRtlIsAnsiCharacterLegalNtfs(C, WILD) ( \ + FlagOn(FsRtlLegalAnsiCharacterArray[(UCHAR)(C)], (FSRTL_NTFS_LEGAL) | \ + ((WILD) ? FSRTL_WILD_CHARACTER : 0 )) \ +) + +#define FsRtlIsAnsiCharacterWild(C) ( \ + FlagOn(FsRtlLegalAnsiCharacterArray[(UCHAR)(C)], FSRTL_WILD_CHARACTER ) \ +) + NTKERNELAPI BOOLEAN NTAPI @@ -9335,6 +8459,142 @@ FsRtlIsFatDbcsLegal ( IN BOOLEAN LeadingBackslashPermissible ); +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlIsHpfsDbcsLegal ( + IN ANSI_STRING DbcsName, + IN BOOLEAN WildCardsPermissible, + IN BOOLEAN PathNamePermissible, + IN BOOLEAN LeadingBackslashPermissible +); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlIsNameInExpression ( + IN PUNICODE_STRING Expression, + IN PUNICODE_STRING Name, + IN BOOLEAN IgnoreCase, + IN PWCHAR UpcaseTable OPTIONAL +); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlIsNtstatusExpected ( + IN NTSTATUS Ntstatus +); + +#define NLS_OEM_LEAD_BYTE_INFO NlsOemLeadByteInfo + +extern PUSHORT NlsOemLeadByteInfo; + +#define FsRtlIsLeadDbcsCharacter(DBCS_CHAR) ( \ + (BOOLEAN)((UCHAR)(DBCS_CHAR) < 0x80 ? FALSE : \ + (NLS_MB_CODE_PAGE_TAG && \ + (NLS_OEM_LEAD_BYTE_INFO[(UCHAR)(DBCS_CHAR)] != 0))) \ +) + +#define FsRtlIsUnicodeCharacterWild(C) ( \ + (((C) >= 0x40) ? \ + FALSE : \ + FlagOn(FsRtlLegalAnsiCharacterArray[(C)], FSRTL_WILD_CHARACTER )) \ +) + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlLookupBaseMcbEntry ( + IN PBASE_MCB Mcb, + IN LONGLONG Vbn, + OUT PLONGLONG Lbn OPTIONAL, + OUT PLONGLONG SectorCountFromLbn OPTIONAL, + OUT PLONGLONG StartingLbn OPTIONAL, + OUT PLONGLONG SectorCountFromStartingLbn OPTIONAL, + OUT PULONG Index OPTIONAL +); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlLookupLargeMcbEntry ( + IN PLARGE_MCB Mcb, + IN LONGLONG Vbn, + OUT PLONGLONG Lbn OPTIONAL, + OUT PLONGLONG SectorCountFromLbn OPTIONAL, + OUT PLONGLONG StartingLbn OPTIONAL, + OUT PLONGLONG SectorCountFromStartingLbn OPTIONAL, + OUT PULONG Index OPTIONAL +); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlLookupLastBaseMcbEntry ( + IN PBASE_MCB Mcb, + OUT PLONGLONG Vbn, + OUT PLONGLONG Lbn +); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlLookupLastLargeMcbEntry ( + IN PLARGE_MCB Mcb, + OUT PLONGLONG Vbn, + OUT PLONGLONG Lbn +); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlLookupLastMcbEntry ( + IN PMCB Mcb, + OUT PVBN Vbn, + OUT PLBN Lbn +); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlLookupLastBaseMcbEntryAndIndex ( + IN PBASE_MCB OpaqueMcb, + IN OUT PLONGLONG LargeVbn, + IN OUT PLONGLONG LargeLbn, + IN OUT PULONG Index +); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlLookupLastLargeMcbEntryAndIndex ( + IN PLARGE_MCB OpaqueMcb, + OUT PLONGLONG LargeVbn, + OUT PLONGLONG LargeLbn, + OUT PULONG Index +); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlLookupMcbEntry ( + IN PMCB Mcb, + IN VBN Vbn, + OUT PLBN Lbn, + OUT PULONG SectorCount OPTIONAL, + OUT PULONG Index +); + +NTKERNELAPI +PFSRTL_PER_STREAM_CONTEXT +NTAPI +FsRtlLookupPerStreamContextInternal ( + IN PFSRTL_ADVANCED_FCB_HEADER StreamContext, + IN PVOID OwnerId OPTIONAL, + IN PVOID InstanceId OPTIONAL +); + NTKERNELAPI BOOLEAN NTAPI @@ -9352,6 +8612,14 @@ FsRtlMdlWriteComplete ( IN PMDL MdlChain ); +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlNormalizeNtstatus ( + IN NTSTATUS Exception, + IN NTSTATUS GenericException +); + NTKERNELAPI VOID NTAPI @@ -9365,6 +8633,315 @@ FsRtlNotifyChangeDirectory ( IN PIRP NotifyIrp ); +NTKERNELAPI +VOID +NTAPI +FsRtlNotifyCleanup ( + IN PNOTIFY_SYNC NotifySync, + IN PLIST_ENTRY NotifyList, + IN PVOID FsContext +); + +typedef BOOLEAN (NTAPI *PCHECK_FOR_TRAVERSE_ACCESS) ( + IN PVOID NotifyContext, + IN PVOID TargetContext, + IN PSECURITY_SUBJECT_CONTEXT SubjectContext +); + +NTKERNELAPI +VOID +NTAPI +FsRtlNotifyFilterChangeDirectory ( + IN PNOTIFY_SYNC NotifySync, + IN PLIST_ENTRY NotifyList, + IN PVOID FsContext, + IN PSTRING FullDirectoryName, + IN BOOLEAN WatchTree, + IN BOOLEAN IgnoreBuffer, + IN ULONG CompletionFilter, + IN PIRP NotifyIrp, + IN PCHECK_FOR_TRAVERSE_ACCESS TraverseCallback OPTIONAL, + IN PSECURITY_SUBJECT_CONTEXT SubjectContext OPTIONAL, + IN PFILTER_REPORT_CHANGE FilterCallback OPTIONAL); + +NTKERNELAPI +VOID +NTAPI +FsRtlNotifyFilterReportChange ( + IN PNOTIFY_SYNC NotifySync, + IN PLIST_ENTRY NotifyList, + IN PSTRING FullTargetName, + IN USHORT TargetNameOffset, + IN PSTRING StreamName OPTIONAL, + IN PSTRING NormalizedParentName OPTIONAL, + IN ULONG FilterMatch, + IN ULONG Action, + IN PVOID TargetContext, + IN PVOID FilterContext); + +NTKERNELAPI +VOID +NTAPI +FsRtlNotifyFullChangeDirectory ( + IN PNOTIFY_SYNC NotifySync, + IN PLIST_ENTRY NotifyList, + IN PVOID FsContext, + IN PSTRING FullDirectoryName, + IN BOOLEAN WatchTree, + IN BOOLEAN IgnoreBuffer, + IN ULONG CompletionFilter, + IN PIRP NotifyIrp, + IN PCHECK_FOR_TRAVERSE_ACCESS TraverseCallback OPTIONAL, + IN PSECURITY_SUBJECT_CONTEXT SubjectContext OPTIONAL +); + +NTKERNELAPI +VOID +NTAPI +FsRtlNotifyFullReportChange ( + IN PNOTIFY_SYNC NotifySync, + IN PLIST_ENTRY NotifyList, + IN PSTRING FullTargetName, + IN USHORT TargetNameOffset, + IN PSTRING StreamName OPTIONAL, + IN PSTRING NormalizedParentName OPTIONAL, + IN ULONG FilterMatch, + IN ULONG Action, + IN PVOID TargetContext +); + +NTKERNELAPI +VOID +NTAPI +FsRtlNotifyInitializeSync ( + IN PNOTIFY_SYNC *NotifySync +); + +NTKERNELAPI +VOID +NTAPI +FsRtlNotifyUninitializeSync ( + IN PNOTIFY_SYNC *NotifySync +); + +#if (VER_PRODUCTBUILD >= 2195) + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlNotifyVolumeEvent ( + IN PFILE_OBJECT FileObject, + IN ULONG EventCode +); + +#endif /* (VER_PRODUCTBUILD >= 2195) */ + +NTKERNELAPI +ULONG +NTAPI +FsRtlNumberOfRunsInBaseMcb ( + IN PBASE_MCB Mcb +); + +NTKERNELAPI +ULONG +NTAPI +FsRtlNumberOfRunsInLargeMcb ( + IN PLARGE_MCB Mcb +); + +NTKERNELAPI +ULONG +NTAPI +FsRtlNumberOfRunsInMcb ( + IN PMCB Mcb +); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlOplockFsctrl ( + IN POPLOCK Oplock, + IN PIRP Irp, + IN ULONG OpenCount +); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlOplockIsFastIoPossible ( + IN POPLOCK Oplock +); + +typedef VOID +(NTAPI *PFSRTL_STACK_OVERFLOW_ROUTINE) ( + IN PVOID Context, + IN PKEVENT Event +); + +NTKERNELAPI +VOID +NTAPI +FsRtlPostPagingFileStackOverflow ( + IN PVOID Context, + IN PKEVENT Event, + IN PFSRTL_STACK_OVERFLOW_ROUTINE StackOverflowRoutine +); + +NTKERNELAPI +VOID +NTAPI +FsRtlPostStackOverflow ( + IN PVOID Context, + IN PKEVENT Event, + IN PFSRTL_STACK_OVERFLOW_ROUTINE StackOverflowRoutine +); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlRegisterUncProvider ( + IN OUT PHANDLE MupHandle, + IN PUNICODE_STRING RedirectorDeviceName, + IN BOOLEAN MailslotsSupported +); + +NTKERNELAPI +VOID +NTAPI +FsRtlRemoveBaseMcbEntry ( + IN PBASE_MCB Mcb, + IN LONGLONG Vbn, + IN LONGLONG SectorCount +); + +NTKERNELAPI +VOID +NTAPI +FsRtlRemoveLargeMcbEntry ( + IN PLARGE_MCB Mcb, + IN LONGLONG Vbn, + IN LONGLONG SectorCount +); + +NTKERNELAPI +VOID +NTAPI +FsRtlRemoveMcbEntry ( + IN PMCB Mcb, + IN VBN Vbn, + IN ULONG SectorCount +); + +NTKERNELAPI +PFSRTL_PER_STREAM_CONTEXT +NTAPI +FsRtlRemovePerStreamContext ( + IN PFSRTL_ADVANCED_FCB_HEADER StreamContext, + IN PVOID OwnerId OPTIONAL, + IN PVOID InstanceId OPTIONAL +); + +NTKERNELAPI +VOID +NTAPI +FsRtlResetBaseMcb ( + IN PBASE_MCB Mcb +); + +NTKERNELAPI +VOID +NTAPI +FsRtlResetLargeMcb ( + IN PLARGE_MCB Mcb, + IN BOOLEAN SelfSynchronized +); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlSplitBaseMcb ( + IN PBASE_MCB Mcb, + IN LONGLONG Vbn, + IN LONGLONG Amount +); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlSplitLargeMcb ( + IN PLARGE_MCB Mcb, + IN LONGLONG Vbn, + IN LONGLONG Amount +); + +#define FsRtlSupportsPerStreamContexts(FO) ( \ + (BOOLEAN)((NULL != FsRtlGetPerStreamContextPointer(FO) && \ + FlagOn(FsRtlGetPerStreamContextPointer(FO)->Flags2, \ + FSRTL_FLAG2_SUPPORTS_FILTER_CONTEXTS)) \ +) + +NTKERNELAPI +VOID +NTAPI +FsRtlTruncateBaseMcb ( + IN PBASE_MCB Mcb, + IN LONGLONG Vbn +); + +NTKERNELAPI +VOID +NTAPI +FsRtlTruncateLargeMcb ( + IN PLARGE_MCB Mcb, + IN LONGLONG Vbn +); + +NTKERNELAPI +VOID +NTAPI +FsRtlTruncateMcb ( + IN PMCB Mcb, + IN VBN Vbn +); + +NTKERNELAPI +VOID +NTAPI +FsRtlUninitializeBaseMcb ( + IN PBASE_MCB Mcb +); + +NTKERNELAPI +VOID +NTAPI +FsRtlUninitializeLargeMcb ( + IN PLARGE_MCB Mcb +); + +NTKERNELAPI +VOID +NTAPI +FsRtlUninitializeMcb ( + IN PMCB Mcb +); + +NTKERNELAPI +VOID +NTAPI +FsRtlUninitializeOplock ( + IN OUT POPLOCK Oplock +); + +NTKERNELAPI +NTSTATUS +NTAPI +IoAttachDeviceToDeviceStackSafe( + IN PDEVICE_OBJECT SourceDevice, + IN PDEVICE_OBJECT TargetDevice, + OUT PDEVICE_OBJECT *AttachedToDeviceObject +); + NTKERNELAPI NTSTATUS NTAPI @@ -9401,6 +8978,23 @@ ObReferenceObjectByName ( OUT PVOID *Object ); +#if (NTDDI_VERSION >= NTDDI_WIN2K) + +NTKERNELAPI +NTSTATUS +NTAPI +PsAssignImpersonationToken( + IN PETHREAD Thread, + IN HANDLE Token OPTIONAL); + +NTKERNELAPI +HANDLE +NTAPI +PsReferencePrimaryToken( + IN OUT PEPROCESS Process); + +#endif + #define PsDereferenceImpersonationToken(T) \ {if (ARGUMENT_PRESENT(T)) { \ (ObDereferenceObject((T))); \ @@ -9418,6 +9012,14 @@ PsLookupProcessThreadByCid ( OUT PETHREAD *Thread ); +NTSYSAPI +VOID +NTAPI +RtlSecondsSince1970ToTime ( + IN ULONG SecondsSince1970, + OUT PLARGE_INTEGER Time +); + NTSYSAPI NTSTATUS NTAPI @@ -9428,6 +9030,105 @@ RtlSetSaclSecurityDescriptor ( IN BOOLEAN SaclDefaulted ); +NTSYSAPI +NTSTATUS +NTAPI +RtlUnicodeStringToCountedOemString ( + IN OUT POEM_STRING DestinationString, + IN PCUNICODE_STRING SourceString, + IN BOOLEAN AllocateDestinationString +); + +/* RTL Splay Tree Functions */ +NTSYSAPI +PRTL_SPLAY_LINKS +NTAPI +RtlSplay(PRTL_SPLAY_LINKS Links); + +NTSYSAPI +PRTL_SPLAY_LINKS +NTAPI +RtlDelete(PRTL_SPLAY_LINKS Links); + +NTSYSAPI +VOID +NTAPI +RtlDeleteNoSplay( + PRTL_SPLAY_LINKS Links, + PRTL_SPLAY_LINKS *Root +); + +NTSYSAPI +PRTL_SPLAY_LINKS +NTAPI +RtlSubtreeSuccessor(PRTL_SPLAY_LINKS Links); + +NTSYSAPI +PRTL_SPLAY_LINKS +NTAPI +RtlSubtreePredecessor(PRTL_SPLAY_LINKS Links); + +NTSYSAPI +PRTL_SPLAY_LINKS +NTAPI +RtlRealSuccessor(PRTL_SPLAY_LINKS Links); + +NTSYSAPI +PRTL_SPLAY_LINKS +NTAPI +RtlRealPredecessor(PRTL_SPLAY_LINKS Links); + +#define RtlIsLeftChild(Links) \ + (RtlLeftChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links)) + +#define RtlIsRightChild(Links) \ + (RtlRightChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links)) + +#define RtlRightChild(Links) \ + ((PRTL_SPLAY_LINKS)(Links))->RightChild + +#define RtlIsRoot(Links) \ + (RtlParent(Links) == (PRTL_SPLAY_LINKS)(Links)) + +#define RtlLeftChild(Links) \ + ((PRTL_SPLAY_LINKS)(Links))->LeftChild + +#define RtlParent(Links) \ + ((PRTL_SPLAY_LINKS)(Links))->Parent + +#define RtlInitializeSplayLinks(Links) \ + { \ + PRTL_SPLAY_LINKS _SplayLinks; \ + _SplayLinks = (PRTL_SPLAY_LINKS)(Links); \ + _SplayLinks->Parent = _SplayLinks; \ + _SplayLinks->LeftChild = NULL; \ + _SplayLinks->RightChild = NULL; \ + } + +#define RtlInsertAsLeftChild(ParentLinks,ChildLinks) \ + { \ + PRTL_SPLAY_LINKS _SplayParent; \ + PRTL_SPLAY_LINKS _SplayChild; \ + _SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \ + _SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks); \ + _SplayParent->LeftChild = _SplayChild; \ + _SplayChild->Parent = _SplayParent; \ + } + +#define RtlInsertAsRightChild(ParentLinks,ChildLinks) \ + { \ + PRTL_SPLAY_LINKS _SplayParent; \ + PRTL_SPLAY_LINKS _SplayChild; \ + _SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \ + _SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks); \ + _SplayParent->RightChild = _SplayChild; \ + _SplayChild->Parent = _SplayParent; \ + } + +// +// RTL time functions +// + #define SeEnableAccessToExports() SeExports = *(PSE_EXPORTS *)SeExports; #if (VER_PRODUCTBUILD >= 2195) @@ -9453,6 +9154,18 @@ ZwAlertThread ( IN HANDLE ThreadHandle ); +NTSYSAPI +NTSTATUS +NTAPI +ZwAllocateVirtualMemory ( + IN HANDLE ProcessHandle, + IN OUT PVOID *BaseAddress, + IN ULONG_PTR ZeroBits, + IN OUT PSIZE_T RegionSize, + IN ULONG AllocationType, + IN ULONG Protect +); + NTSYSAPI NTSTATUS NTAPI @@ -9498,6 +9211,19 @@ ZwCloseObjectAuditAlarm ( IN BOOLEAN GenerateOnClose ); +NTSYSAPI +NTSTATUS +NTAPI +ZwCreateSection ( + OUT PHANDLE SectionHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, + IN PLARGE_INTEGER MaximumSize OPTIONAL, + IN ULONG SectionPageProtection, + IN ULONG AllocationAttributes, + IN HANDLE FileHandle OPTIONAL +); + NTSYSAPI NTSTATUS NTAPI @@ -9508,6 +9234,71 @@ ZwCreateSymbolicLinkObject ( IN PUNICODE_STRING TargetName ); +NTSYSAPI +NTSTATUS +NTAPI +ZwDeleteFile ( + IN POBJECT_ATTRIBUTES ObjectAttributes +); + +NTSYSAPI +NTSTATUS +NTAPI +ZwDeleteValueKey ( + IN HANDLE Handle, + IN PUNICODE_STRING Name +); + + +#if (NTDDI_VERSION >= NTDDI_WIN2K) +NTSYSAPI +NTSTATUS +NTAPI +ZwDeviceIoControlFile ( + IN HANDLE FileHandle, + IN HANDLE Event OPTIONAL, + IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, + IN PVOID ApcContext OPTIONAL, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN ULONG IoControlCode, + IN PVOID InputBuffer OPTIONAL, + IN ULONG InputBufferLength, + OUT PVOID OutputBuffer OPTIONAL, + IN ULONG OutputBufferLength); +#endif + +NTSYSAPI +NTSTATUS +NTAPI +ZwDisplayString ( + IN PUNICODE_STRING String +); + +NTSYSAPI +NTSTATUS +NTAPI +ZwDuplicateObject ( + IN HANDLE SourceProcessHandle, + IN HANDLE SourceHandle, + IN HANDLE TargetProcessHandle OPTIONAL, + OUT PHANDLE TargetHandle OPTIONAL, + IN ACCESS_MASK DesiredAccess, + IN ULONG HandleAttributes, + IN ULONG Options +); + +NTSYSAPI +NTSTATUS +NTAPI +ZwDuplicateToken ( + IN HANDLE ExistingTokenHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN BOOLEAN EffectiveOnly, + IN TOKEN_TYPE TokenType, + OUT PHANDLE NewTokenHandle +); + NTSYSAPI NTSTATUS NTAPI @@ -9527,6 +9318,46 @@ ZwFlushBuffersFile( #if (VER_PRODUCTBUILD >= 2195) +NTSYSAPI +NTSTATUS +NTAPI +ZwFlushVirtualMemory ( + IN HANDLE ProcessHandle, + IN OUT PVOID *BaseAddress, + IN OUT PULONG FlushSize, + OUT PIO_STATUS_BLOCK IoStatusBlock +); + +#endif /* (VER_PRODUCTBUILD >= 2195) */ + +NTSYSAPI +NTSTATUS +NTAPI +ZwFreeVirtualMemory ( + IN HANDLE ProcessHandle, + IN OUT PVOID *BaseAddress, + IN OUT PSIZE_T RegionSize, + IN ULONG FreeType +); + +NTSYSAPI +NTSTATUS +NTAPI +ZwFsControlFile ( + IN HANDLE FileHandle, + IN HANDLE Event OPTIONAL, + IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, + IN PVOID ApcContext OPTIONAL, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN ULONG FsControlCode, + IN PVOID InputBuffer OPTIONAL, + IN ULONG InputBufferLength, + OUT PVOID OutputBuffer OPTIONAL, + IN ULONG OutputBufferLength +); + +#if (VER_PRODUCTBUILD >= 2195) + NTSYSAPI NTSTATUS NTAPI @@ -9539,6 +9370,14 @@ ZwInitiatePowerAction ( #endif /* (VER_PRODUCTBUILD >= 2195) */ +NTSYSAPI +NTSTATUS +NTAPI +ZwLoadDriver ( + /* "\\Registry\\Machine\\System\\CurrentControlSet\\Services\\" */ + IN PUNICODE_STRING RegistryPath +); + NTSYSAPI NTSTATUS NTAPI @@ -9547,6 +9386,41 @@ ZwLoadKey ( IN POBJECT_ATTRIBUTES FileObjectAttributes ); +NTSYSAPI +NTSTATUS +NTAPI +ZwNotifyChangeKey ( + IN HANDLE KeyHandle, + IN HANDLE EventHandle OPTIONAL, + IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, + IN PVOID ApcContext OPTIONAL, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN ULONG NotifyFilter, + IN BOOLEAN WatchSubtree, + IN PVOID Buffer, + IN ULONG BufferLength, + IN BOOLEAN Asynchronous +); + +NTSYSAPI +NTSTATUS +NTAPI +ZwOpenDirectoryObject ( + OUT PHANDLE DirectoryHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes +); + +NTSYSAPI +NTSTATUS +NTAPI +ZwOpenProcess ( + OUT PHANDLE ProcessHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN PCLIENT_ID ClientId OPTIONAL +); + NTSYSAPI NTSTATUS NTAPI @@ -9576,6 +9450,21 @@ ZwOpenThreadToken ( OUT PHANDLE TokenHandle ); +#if (VER_PRODUCTBUILD >= 2195) + +NTSYSAPI +NTSTATUS +NTAPI +ZwPowerInformation ( + IN POWER_INFORMATION_LEVEL PowerInformationLevel, + IN PVOID InputBuffer OPTIONAL, + IN ULONG InputBufferLength, + OUT PVOID OutputBuffer OPTIONAL, + IN ULONG OutputBufferLength +); + +#endif /* (VER_PRODUCTBUILD >= 2195) */ + NTSYSAPI NTSTATUS NTAPI @@ -9592,6 +9481,23 @@ ZwQueryDefaultLocale ( OUT PLCID Locale ); +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryDirectoryFile ( + IN HANDLE FileHandle, + IN HANDLE Event OPTIONAL, + IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, + IN PVOID ApcContext OPTIONAL, + OUT PIO_STATUS_BLOCK IoStatusBlock, + OUT PVOID FileInformation, + IN ULONG Length, + IN FILE_INFORMATION_CLASS FileInformationClass, + IN BOOLEAN ReturnSingleEntry, + IN PUNICODE_STRING FileName OPTIONAL, + IN BOOLEAN RestartScan +); + #if (VER_PRODUCTBUILD >= 2195) NTSYSAPI @@ -9607,6 +9513,21 @@ ZwQueryDirectoryObject ( OUT PULONG ReturnLength OPTIONAL ); +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryEaFile ( + IN HANDLE FileHandle, + OUT PIO_STATUS_BLOCK IoStatusBlock, + OUT PVOID Buffer, + IN ULONG Length, + IN BOOLEAN ReturnSingleEntry, + IN PVOID EaList OPTIONAL, + IN ULONG EaListLength, + IN PULONG EaIndex OPTIONAL, + IN BOOLEAN RestartScan +); + #endif /* (VER_PRODUCTBUILD >= 2195) */ NTSYSAPI @@ -9620,6 +9541,39 @@ ZwQueryInformationProcess ( OUT PULONG ReturnLength OPTIONAL ); +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryInformationToken ( + IN HANDLE TokenHandle, + IN TOKEN_INFORMATION_CLASS TokenInformationClass, + OUT PVOID TokenInformation, + IN ULONG Length, + OUT PULONG ResultLength +); + +NTSYSAPI +NTSTATUS +NTAPI +ZwQuerySecurityObject ( + IN HANDLE FileHandle, + IN SECURITY_INFORMATION SecurityInformation, + OUT PSECURITY_DESCRIPTOR SecurityDescriptor, + IN ULONG Length, + OUT PULONG ResultLength +); + +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryVolumeInformationFile ( + IN HANDLE FileHandle, + OUT PIO_STATUS_BLOCK IoStatusBlock, + OUT PVOID FsInformation, + IN ULONG Length, + IN FS_INFORMATION_CLASS FsInformationClass +); + NTSYSAPI NTSTATUS NTAPI @@ -9675,8 +9629,26 @@ ZwSetDefaultUILanguage ( IN LANGID LanguageId ); +NTSYSAPI +NTSTATUS +NTAPI +ZwSetEaFile ( + IN HANDLE FileHandle, + OUT PIO_STATUS_BLOCK IoStatusBlock, + OUT PVOID Buffer, + IN ULONG Length +); + #endif /* (VER_PRODUCTBUILD >= 2195) */ +NTSYSAPI +NTSTATUS +NTAPI +ZwSetEvent ( + IN HANDLE EventHandle, + OUT PLONG PreviousState OPTIONAL +); + NTSYSAPI NTSTATUS NTAPI @@ -9687,6 +9659,19 @@ ZwSetInformationProcess ( IN ULONG ProcessInformationLength ); +#if (VER_PRODUCTBUILD >= 2195) + +NTSYSAPI +NTSTATUS +NTAPI +ZwSetSecurityObject ( + IN HANDLE Handle, + IN SECURITY_INFORMATION SecurityInformation, + IN PSECURITY_DESCRIPTOR SecurityDescriptor +); + +#endif /* (VER_PRODUCTBUILD >= 2195) */ + NTSYSAPI NTSTATUS NTAPI @@ -9695,6 +9680,37 @@ ZwSetSystemTime ( OUT PLARGE_INTEGER OldTime OPTIONAL ); +#if (VER_PRODUCTBUILD >= 2195) + +NTSYSAPI +NTSTATUS +NTAPI +ZwSetVolumeInformationFile ( + IN HANDLE FileHandle, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN PVOID FsInformation, + IN ULONG Length, + IN FS_INFORMATION_CLASS FsInformationClass +); + +#endif /* (VER_PRODUCTBUILD >= 2195) */ + +NTSYSAPI +NTSTATUS +NTAPI +ZwTerminateProcess ( + IN HANDLE ProcessHandle OPTIONAL, + IN NTSTATUS ExitStatus +); + +NTSYSAPI +NTSTATUS +NTAPI +ZwUnloadDriver ( + /* "\\Registry\\Machine\\System\\CurrentControlSet\\Services\\" */ + IN PUNICODE_STRING RegistryPath +); + NTSYSAPI NTSTATUS NTAPI @@ -9702,6 +9718,16 @@ ZwUnloadKey ( IN POBJECT_ATTRIBUTES KeyObjectAttributes ); +#if (NTDDI_VERSION >= NTDDI_WIN2K) +NTSYSAPI +NTSTATUS +NTAPI +ZwWaitForSingleObject ( + IN HANDLE Handle, + IN BOOLEAN Alertable, + IN PLARGE_INTEGER Timeout OPTIONAL); +#endif + NTSYSAPI NTSTATUS NTAPI diff --git a/reactos/include/ddk/ntimage.h b/reactos/include/ddk/ntimage.h index 8df984763f7..e008a2daa94 100644 --- a/reactos/include/ddk/ntimage.h +++ b/reactos/include/ddk/ntimage.h @@ -394,33 +394,22 @@ typedef struct _IMAGE_NT_HEADERS64 { ULONG Signature; IMAGE_FILE_HEADER FileHeader; IMAGE_OPTIONAL_HEADER64 OptionalHeader; -} IMAGE_NT_HEADERS64; +} IMAGE_NT_HEADERS64, *PIMAGE_NT_HEADERS64; typedef struct _IMAGE_NT_HEADERS { ULONG Signature; IMAGE_FILE_HEADER FileHeader; IMAGE_OPTIONAL_HEADER32 OptionalHeader; -} IMAGE_NT_HEADERS32; +} IMAGE_NT_HEADERS32, *PIMAGE_NT_HEADERS32; #ifdef _WIN64 typedef IMAGE_NT_HEADERS64 IMAGE_NT_HEADERS; -#else -typedef IMAGE_NT_HEADERS32 IMAGE_NT_HEADERS; -#endif - -#ifndef _NTDDK_ - -typedef struct _IMAGE_NT_HEADERS *PIMAGE_NT_HEADERS32; -typedef struct _IMAGE_NT_HEADERS64 *PIMAGE_NT_HEADERS64; - -#ifdef _WIN64 typedef PIMAGE_NT_HEADERS64 PIMAGE_NT_HEADERS; #else +typedef IMAGE_NT_HEADERS32 IMAGE_NT_HEADERS; typedef PIMAGE_NT_HEADERS32 PIMAGE_NT_HEADERS; #endif -#endif /* _NTDDK_ */ - // // Retreives the first image section header from the Nt Header // diff --git a/reactos/include/ddk/wdm.h b/reactos/include/ddk/wdm.h index 2742d758ed8..7e97ea08c1d 100644 --- a/reactos/include/ddk/wdm.h +++ b/reactos/include/ddk/wdm.h @@ -38,25 +38,10 @@ #include #include #include -#include #ifndef GUID_DEFINED #include -#endif - -#ifdef _MAC -#ifndef _INC_STRING -#include -#endif /* _INC_STRING */ -#else -#include -#endif /* _MAC */ - -#ifndef _KTMTYPES_ -typedef GUID UOW, *PUOW; -#endif - -typedef GUID *PGUID; +#endif /* GUID_DEFINED */ #if (NTDDI_VERSION >= NTDDI_WINXP) #include @@ -106,12 +91,6 @@ extern "C" { #if defined(_MSC_VER) -/* Disable some warnings */ -#pragma warning(disable:4115) /* Named type definition in parentheses */ -#pragma warning(disable:4201) /* Nameless unions and structs */ -#pragma warning(disable:4214) /* Bit fields of other types than int */ -#pragma warning(disable:4820) /* Padding added, due to alignemnet requirement */ - /* Indicate if #pragma alloc_text() is supported */ #if defined(_M_IX86) || defined(_M_AMD64) || defined(_M_IA64) #define ALLOC_PRAGMA 1 @@ -144,51 +123,17 @@ struct _IO_RESOURCE_DESCRIPTOR; typedef struct _OBJECT_TYPE *POBJECT_TYPE; typedef struct _HAL_DISPATCH_TABLE *PHAL_DISPATCH_TABLE; typedef struct _HAL_PRIVATE_DISPATCH_TABLE *PHAL_PRIVATE_DISPATCH_TABLE; +typedef struct _DEVICE_HANDLER_OBJECT *PDEVICE_HANDLER_OBJECT; +typedef struct _ADAPTER_OBJECT *PADAPTER_OBJECT; typedef struct _CALLBACK_OBJECT *PCALLBACK_OBJECT; -typedef struct _EPROCESS *PEPROCESS; typedef struct _ETHREAD *PETHREAD; +typedef struct _EPROCESS *PEPROCESS; typedef struct _IO_TIMER *PIO_TIMER; typedef struct _KINTERRUPT *PKINTERRUPT; typedef struct _KPROCESS *PKPROCESS; typedef struct _KTHREAD *PKTHREAD, *PRKTHREAD; typedef struct _CONTEXT *PCONTEXT; -#if defined(USE_DMA_MACROS) && !defined(_NTHAL_) && ( defined(_NTDDK_) || defined(_NTDRIVER_) || defined(_NTOSP_)) -typedef struct _DMA_ADAPTER *PADAPTER_OBJECT; -#elif defined(_WDM_INCLUDED_) -typedef struct _DMA_ADAPTER *PADAPTER_OBJECT; -#else -typedef struct _ADAPTER_OBJECT *PADAPTER_OBJECT; -#endif - -#ifndef DEFINE_GUIDEX -#ifdef _MSC_VER -#define DEFINE_GUIDEX(name) EXTERN_C const CDECL GUID name -#else -#define DEFINE_GUIDEX(name) EXTERN_C const GUID name -#endif -#endif /* DEFINE_GUIDEX */ - -#ifndef STATICGUIDOF -#define STATICGUIDOF(guid) STATIC_##guid -#endif - -/* GUID Comparison */ -#ifndef __IID_ALIGNED__ -#define __IID_ALIGNED__ -#ifdef __cplusplus -inline int IsEqualGUIDAligned(REFGUID guid1, REFGUID guid2) -{ - return ( (*(PLONGLONG)(&guid1) == *(PLONGLONG)(&guid2)) && - (*((PLONGLONG)(&guid1) + 1) == *((PLONGLONG)(&guid2) + 1)) ); -} -#else -#define IsEqualGUIDAligned(guid1, guid2) \ - ( (*(PLONGLONG)(guid1) == *(PLONGLONG)(guid2)) && \ - (*((PLONGLONG)(guid1) + 1) == *((PLONGLONG)(guid2) + 1)) ) -#endif /* __cplusplus */ -#endif /* !__IID_ALIGNED__ */ - /****************************************************************************** * INTERLOCKED Functions * @@ -200,44 +145,42 @@ inline int IsEqualGUIDAligned(REFGUID guid1, REFGUID guid2) #if defined(__GNUC__) static __inline__ BOOLEAN -InterlockedBitTestAndSet( - IN LONG volatile *Base, - IN LONG Bit) +InterlockedBitTestAndSet(IN LONG volatile *Base, + IN LONG Bit) { #if defined(_M_IX86) - LONG OldBit; - __asm__ __volatile__("lock " - "btsl %2,%1\n\t" - "sbbl %0,%0\n\t" - :"=r" (OldBit),"+m" (*Base) - :"Ir" (Bit) - : "memory"); - return OldBit; + LONG OldBit; + __asm__ __volatile__("lock " + "btsl %2,%1\n\t" + "sbbl %0,%0\n\t" + :"=r" (OldBit),"+m" (*Base) + :"Ir" (Bit) + : "memory"); + return OldBit; #else - return (_InterlockedOr(Base, 1 << Bit) >> Bit) & 1; + return (_InterlockedOr(Base, 1 << Bit) >> Bit) & 1; #endif } static __inline__ BOOLEAN -InterlockedBitTestAndReset( - IN LONG volatile *Base, - IN LONG Bit) +InterlockedBitTestAndReset(IN LONG volatile *Base, + IN LONG Bit) { #if defined(_M_IX86) - LONG OldBit; - __asm__ __volatile__("lock " - "btrl %2,%1\n\t" - "sbbl %0,%0\n\t" - :"=r" (OldBit),"+m" (*Base) - :"Ir" (Bit) - : "memory"); - return OldBit; + LONG OldBit; + __asm__ __volatile__("lock " + "btrl %2,%1\n\t" + "sbbl %0,%0\n\t" + :"=r" (OldBit),"+m" (*Base) + :"Ir" (Bit) + : "memory"); + return OldBit; #else - return (_InterlockedAnd(Base, ~(1 << Bit)) >> Bit) & 1; + return (_InterlockedAnd(Base, ~(1 << Bit)) >> Bit) & 1; #endif } -#endif /* defined(__GNUC__) */ +#endif #define BitScanForward _BitScanForward #define BitScanReverse _BitScanReverse @@ -249,10 +192,6 @@ InterlockedBitTestAndReset( #define InterlockedBitTestAndReset _interlockedbittestandreset #ifdef _M_AMD64 -#define BitTest64 _bittest64 -#define BitTestAndComplement64 _bittestandcomplement64 -#define BitTestAndSet64 _bittestandset64 -#define BitTestAndReset64 _bittestandreset64 #define InterlockedBitTestAndSet64 _interlockedbittestandset64 #define InterlockedBitTestAndReset64 _interlockedbittestandreset64 #endif @@ -279,8 +218,8 @@ LONG FASTCALL InterlockedCompareExchange( IN OUT LONG volatile *Destination, - IN LONG Exchange, - IN LONG Comparand); + IN LONG Exchange, + IN LONG Comparand); NTKERNELAPI LONG @@ -296,7 +235,7 @@ InterlockedExchangeAdd( IN OUT LONG volatile *Addend, IN LONG Value); -#else /* !defined(NO_INTERLOCKED_INTRINSICS) */ +#else // !defined(NO_INTERLOCKED_INTRINSICS) #define InterlockedExchange _InterlockedExchange #define InterlockedIncrement _InterlockedIncrement @@ -307,9 +246,9 @@ InterlockedExchangeAdd( #define InterlockedAnd _InterlockedAnd #define InterlockedXor _InterlockedXor -#endif /* !defined(NO_INTERLOCKED_INTRINSICS) */ +#endif // !defined(NO_INTERLOCKED_INTRINSICS) -#endif /* defined (_X86_) */ +#endif // defined (_X86_) #if !defined (_WIN64) /* @@ -372,10 +311,10 @@ InterlockedExchangeAdd( FORCEINLINE LONG64 InterlockedAdd64( - IN OUT LONG64 volatile *Addend, - IN LONG64 Value) + IN OUT LONG64 volatile *Addend, + IN LONG64 Value) { - return InterlockedExchangeAdd64(Addend, Value) + Value; + return InterlockedExchangeAdd64(Addend, Value) + Value; } //#endif #endif @@ -411,43 +350,43 @@ InterlockedAdd64( #define HASH_STRING_ALGORITHM_INVALID 0xffffffff typedef struct _RTL_BITMAP { - ULONG SizeOfBitMap; - PULONG Buffer; + ULONG SizeOfBitMap; + PULONG Buffer; } RTL_BITMAP, *PRTL_BITMAP; typedef struct _RTL_BITMAP_RUN { - ULONG StartingIndex; - ULONG NumberOfBits; + ULONG StartingIndex; + ULONG NumberOfBits; } RTL_BITMAP_RUN, *PRTL_BITMAP_RUN; typedef NTSTATUS -(NTAPI *PRTL_QUERY_REGISTRY_ROUTINE)( - IN PWSTR ValueName, - IN ULONG ValueType, - IN PVOID ValueData, - IN ULONG ValueLength, - IN PVOID Context, - IN PVOID EntryContext); +(DDKAPI *PRTL_QUERY_REGISTRY_ROUTINE)( + IN PWSTR ValueName, + IN ULONG ValueType, + IN PVOID ValueData, + IN ULONG ValueLength, + IN PVOID Context, + IN PVOID EntryContext); typedef struct _RTL_QUERY_REGISTRY_TABLE { - PRTL_QUERY_REGISTRY_ROUTINE QueryRoutine; - ULONG Flags; - PCWSTR Name; - PVOID EntryContext; - ULONG DefaultType; - PVOID DefaultData; - ULONG DefaultLength; + PRTL_QUERY_REGISTRY_ROUTINE QueryRoutine; + ULONG Flags; + PCWSTR Name; + PVOID EntryContext; + ULONG DefaultType; + PVOID DefaultData; + ULONG DefaultLength; } RTL_QUERY_REGISTRY_TABLE, *PRTL_QUERY_REGISTRY_TABLE; typedef struct _TIME_FIELDS { - CSHORT Year; - CSHORT Month; - CSHORT Day; - CSHORT Hour; - CSHORT Minute; - CSHORT Second; - CSHORT Milliseconds; - CSHORT Weekday; + CSHORT Year; + CSHORT Month; + CSHORT Day; + CSHORT Hour; + CSHORT Minute; + CSHORT Second; + CSHORT Milliseconds; + CSHORT Weekday; } TIME_FIELDS, *PTIME_FIELDS; /* Slist Header */ @@ -455,101 +394,60 @@ typedef struct _TIME_FIELDS { #define _SLIST_HEADER_ #if defined(_WIN64) - +typedef struct DECLSPEC_ALIGN(16) _SLIST_ENTRY *PSLIST_ENTRY; typedef struct DECLSPEC_ALIGN(16) _SLIST_ENTRY { - struct _SLIST_ENTRY *Next; -} SLIST_ENTRY, *PSLIST_ENTRY; - -typedef struct _SLIST_ENTRY32 { - ULONG Next; -} SLIST_ENTRY32, *PSLIST_ENTRY32; - + PSLIST_ENTRY Next; +} SLIST_ENTRY; typedef union DECLSPEC_ALIGN(16) _SLIST_HEADER { - struct { - ULONGLONG Alignment; - ULONGLONG Region; - } DUMMYSTRUCTNAME; - struct { - ULONGLONG Depth:16; - ULONGLONG Sequence:9; - ULONGLONG NextEntry:39; - ULONGLONG HeaderType:1; - ULONGLONG Init:1; - ULONGLONG Reserved:59; - ULONGLONG Region:3; - } Header8; - struct { - ULONGLONG Depth:16; - ULONGLONG Sequence:48; - ULONGLONG HeaderType:1; - ULONGLONG Init:1; - ULONGLONG Reserved:2; - ULONGLONG NextEntry:60; - } Header16; - struct { - ULONGLONG Depth:16; - ULONGLONG Sequence:48; - ULONGLONG HeaderType:1; - ULONGLONG Reserved:3; - ULONGLONG NextEntry:60; - } HeaderX64; + struct { + ULONGLONG Alignment; + ULONGLONG Region; + } DUMMYSTRUCTNAME; + struct { + ULONGLONG Depth:16; + ULONGLONG Sequence:9; + ULONGLONG NextEntry:39; + ULONGLONG HeaderType:1; + ULONGLONG Init:1; + ULONGLONG Reserved:59; + ULONGLONG Region:3; + } Header8; + struct { + ULONGLONG Depth:16; + ULONGLONG Sequence:48; + ULONGLONG HeaderType:1; + ULONGLONG Init:1; + ULONGLONG Reserved:2; + ULONGLONG NextEntry:60; + } Header16; } SLIST_HEADER, *PSLIST_HEADER; - -typedef union _SLIST_HEADER32 { - ULONGLONG Alignment; - struct { - SLIST_ENTRY32 Next; - USHORT Depth; - USHORT Sequence; - } DUMMYSTRUCTNAME; -} SLIST_HEADER32, *PSLIST_HEADER32; - #else - #define SLIST_ENTRY SINGLE_LIST_ENTRY #define _SLIST_ENTRY _SINGLE_LIST_ENTRY #define PSLIST_ENTRY PSINGLE_LIST_ENTRY - -typedef SLIST_ENTRY SLIST_ENTRY32, *PSLIST_ENTRY32; - typedef union _SLIST_HEADER { - ULONGLONG Alignment; - struct { - SLIST_ENTRY Next; - USHORT Depth; - USHORT Sequence; - } DUMMYSTRUCTNAME; + ULONGLONG Alignment; + struct { + SLIST_ENTRY Next; + USHORT Depth; + USHORT Sequence; + } DUMMYSTRUCTNAME; } SLIST_HEADER, *PSLIST_HEADER; - -typedef SLIST_HEADER SLIST_HEADER32, *PSLIST_HEADER32; - -#endif /* defined(_WIN64) */ +#endif #endif /* _SLIST_HEADER_ */ -/* MS definition is broken! */ -extern BOOLEAN NTSYSAPI NlsMbCodePageTag; -extern BOOLEAN NTSYSAPI NlsMbOemCodePageTag; + +/* HACK HACK HACK - GCC (or perhaps LD) is messing this up */ +#if defined(_NTSYSTEM_) || defined(__GNUC__) #define NLS_MB_CODE_PAGE_TAG NlsMbCodePageTag #define NLS_MB_OEM_CODE_PAGE_TAG NlsMbOemCodePageTag - -#define SHORT_LEAST_SIGNIFICANT_BIT 0 -#define SHORT_MOST_SIGNIFICANT_BIT 1 - -#define LONG_LEAST_SIGNIFICANT_BIT 0 -#define LONG_3RD_MOST_SIGNIFICANT_BIT 1 -#define LONG_2ND_MOST_SIGNIFICANT_BIT 2 -#define LONG_MOST_SIGNIFICANT_BIT 3 - -#define RTLVERLIB_DDI(x) Wdmlib##x - -typedef BOOLEAN -(*PFN_RTL_IS_NTDDI_VERSION_AVAILABLE)( - IN ULONG Version); - -typedef BOOLEAN -(*PFN_RTL_IS_SERVICE_PACK_VERSION_INSTALLED)( - IN ULONG Version); +#else +#define NLS_MB_CODE_PAGE_TAG (*NlsMbCodePageTag) +#define NLS_MB_OEM_CODE_PAGE_TAG (*NlsMbOemCodePageTag) +#endif /* _NT_SYSTEM */ +extern BOOLEAN NTSYSAPI NLS_MB_CODE_PAGE_TAG; +extern BOOLEAN NTSYSAPI NLS_MB_OEM_CODE_PAGE_TAG; /****************************************************************************** @@ -560,139 +458,39 @@ typedef UCHAR KIRQL, *PKIRQL; typedef CCHAR KPROCESSOR_MODE; typedef LONG KPRIORITY; +typedef ULONG EXECUTION_STATE; + typedef enum _MODE { KernelMode, UserMode, MaximumMode } MODE; -#define CACHE_FULLY_ASSOCIATIVE 0xFF -#define MAXIMUM_SUSPEND_COUNT MAXCHAR - -#define EVENT_QUERY_STATE (0x0001) -#define EVENT_MODIFY_STATE (0x0002) -#define EVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3) - -#define LTP_PC_SMT 0x1 - -#if (NTDDI_VERSION < NTDDI_WIN7) || defined(_X86_) || !defined(NT_PROCESSOR_GROUPS) -#define SINGLE_GROUP_LEGACY_API 1 -#endif - -#define SEMAPHORE_QUERY_STATE (0x0001) -#define SEMAPHORE_MODIFY_STATE (0x0002) -#define SEMAPHORE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3) - -typedef enum _LOGICAL_PROCESSOR_RELATIONSHIP { - RelationProcessorCore, - RelationNumaNode, - RelationCache, - RelationProcessorPackage, - RelationGroup, - RelationAll = 0xffff -} LOGICAL_PROCESSOR_RELATIONSHIP; - -typedef enum _PROCESSOR_CACHE_TYPE { - CacheUnified, - CacheInstruction, - CacheData, - CacheTrace -} PROCESSOR_CACHE_TYPE; - -typedef struct _CACHE_DESCRIPTOR { - UCHAR Level; - UCHAR Associativity; - USHORT LineSize; - ULONG Size; - PROCESSOR_CACHE_TYPE Type; -} CACHE_DESCRIPTOR, *PCACHE_DESCRIPTOR; - -typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION { - ULONG_PTR ProcessorMask; - LOGICAL_PROCESSOR_RELATIONSHIP Relationship; - union { - struct { - UCHAR Flags; - } ProcessorCore; - struct { - ULONG NodeNumber; - } NumaNode; - CACHE_DESCRIPTOR Cache; - ULONGLONG Reserved[2]; - } DUMMYUNIONNAME; -} SYSTEM_LOGICAL_PROCESSOR_INFORMATION, *PSYSTEM_LOGICAL_PROCESSOR_INFORMATION; - -typedef struct _PROCESSOR_RELATIONSHIP { - UCHAR Flags; - UCHAR Reserved[21]; - USHORT GroupCount; - GROUP_AFFINITY GroupMask[ANYSIZE_ARRAY]; -} PROCESSOR_RELATIONSHIP, *PPROCESSOR_RELATIONSHIP; - -typedef struct _NUMA_NODE_RELATIONSHIP { - ULONG NodeNumber; - UCHAR Reserved[20]; - GROUP_AFFINITY GroupMask; -} NUMA_NODE_RELATIONSHIP, *PNUMA_NODE_RELATIONSHIP; - -typedef struct _CACHE_RELATIONSHIP { - UCHAR Level; - UCHAR Associativity; - USHORT LineSize; - ULONG CacheSize; - PROCESSOR_CACHE_TYPE Type; - UCHAR Reserved[20]; - GROUP_AFFINITY GroupMask; -} CACHE_RELATIONSHIP, *PCACHE_RELATIONSHIP; - -typedef struct _PROCESSOR_GROUP_INFO { - UCHAR MaximumProcessorCount; - UCHAR ActiveProcessorCount; - UCHAR Reserved[38]; - KAFFINITY ActiveProcessorMask; -} PROCESSOR_GROUP_INFO, *PPROCESSOR_GROUP_INFO; - -typedef struct _GROUP_RELATIONSHIP { - USHORT MaximumGroupCount; - USHORT ActiveGroupCount; - UCHAR Reserved[20]; - PROCESSOR_GROUP_INFO GroupInfo[ANYSIZE_ARRAY]; -} GROUP_RELATIONSHIP, *PGROUP_RELATIONSHIP; - -typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX { - LOGICAL_PROCESSOR_RELATIONSHIP Relationship; - ULONG Size; - union { - PROCESSOR_RELATIONSHIP Processor; - NUMA_NODE_RELATIONSHIP NumaNode; - CACHE_RELATIONSHIP Cache; - GROUP_RELATIONSHIP Group; - } DUMMYUNIONNAME; -} SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX, *PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX;; - /* Processor features */ -#define PF_FLOATING_POINT_PRECISION_ERRATA 0 -#define PF_FLOATING_POINT_EMULATED 1 -#define PF_COMPARE_EXCHANGE_DOUBLE 2 -#define PF_MMX_INSTRUCTIONS_AVAILABLE 3 -#define PF_PPC_MOVEMEM_64BIT_OK 4 -#define PF_ALPHA_BYTE_INSTRUCTIONS 5 -#define PF_XMMI_INSTRUCTIONS_AVAILABLE 6 -#define PF_3DNOW_INSTRUCTIONS_AVAILABLE 7 -#define PF_RDTSC_INSTRUCTION_AVAILABLE 8 -#define PF_PAE_ENABLED 9 -#define PF_XMMI64_INSTRUCTIONS_AVAILABLE 10 -#define PF_SSE_DAZ_MODE_AVAILABLE 11 -#define PF_NX_ENABLED 12 -#define PF_SSE3_INSTRUCTIONS_AVAILABLE 13 -#define PF_COMPARE_EXCHANGE128 14 -#define PF_COMPARE64_EXCHANGE128 15 -#define PF_CHANNELS_ENABLED 16 -#define PF_XSAVE_ENABLED 17 +#define PF_FLOATING_POINT_PRECISION_ERRATA 0 +#define PF_FLOATING_POINT_EMULATED 1 +#define PF_COMPARE_EXCHANGE_DOUBLE 2 +#define PF_MMX_INSTRUCTIONS_AVAILABLE 3 +#define PF_PPC_MOVEMEM_64BIT_OK 4 +#define PF_ALPHA_BYTE_INSTRUCTIONS 5 +#define PF_XMMI_INSTRUCTIONS_AVAILABLE 6 +#define PF_3DNOW_INSTRUCTIONS_AVAILABLE 7 +#define PF_RDTSC_INSTRUCTION_AVAILABLE 8 +#define PF_PAE_ENABLED 9 +#define PF_XMMI64_INSTRUCTIONS_AVAILABLE 10 +#define PF_SSE_DAZ_MODE_AVAILABLE 11 +#define PF_NX_ENABLED 12 +#define PF_SSE3_INSTRUCTIONS_AVAILABLE 13 +#define PF_COMPARE_EXCHANGE128 14 +#define PF_COMPARE64_EXCHANGE128 15 +#define PF_CHANNELS_ENABLED 16 +#define PF_XSAVE_ENABLED 17 +#define MAXIMUM_SUPPORTED_EXTENSION 512 #define MAXIMUM_WAIT_OBJECTS 64 -#define ASSERT_APC(Object) NT_ASSERT((Object)->Type == ApcObject) +#define ASSERT_APC(Object) \ + ASSERT((Object)->Type == ApcObject) #define ASSERT_DPC(Object) \ ASSERT(((Object)->Type == 0) || \ @@ -700,25 +498,25 @@ typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX { ((Object)->Type == ThreadedDpcObject)) #define ASSERT_GATE(object) \ - NT_ASSERT((((object)->Header.Type & KOBJECT_TYPE_MASK) == GateObject) || \ - (((object)->Header.Type & KOBJECT_TYPE_MASK) == EventSynchronizationObject)) + ASSERT((((object)->Header.Type & KOBJECT_TYPE_MASK) == GateObject) || \ + (((object)->Header.Type & KOBJECT_TYPE_MASK) == EventSynchronizationObject)) #define ASSERT_DEVICE_QUEUE(Object) \ - NT_ASSERT((Object)->Type == DeviceQueueObject) + ASSERT((Object)->Type == DeviceQueueObject) #define ASSERT_TIMER(E) \ - NT_ASSERT(((E)->Header.Type == TimerNotificationObject) || \ - ((E)->Header.Type == TimerSynchronizationObject)) + ASSERT(((E)->Header.Type == TimerNotificationObject) || \ + ((E)->Header.Type == TimerSynchronizationObject)) #define ASSERT_MUTANT(E) \ - NT_ASSERT((E)->Header.Type == MutantObject) + ASSERT((E)->Header.Type == MutantObject) #define ASSERT_SEMAPHORE(E) \ - NT_ASSERT((E)->Header.Type == SemaphoreObject) + ASSERT((E)->Header.Type == SemaphoreObject) #define ASSERT_EVENT(E) \ - NT_ASSERT(((E)->Header.Type == NotificationEvent) || \ - ((E)->Header.Type == SynchronizationEvent)) + ASSERT(((E)->Header.Type == NotificationEvent) || \ + ((E)->Header.Type == SynchronizationEvent)) #define DPC_NORMAL 0 #define DPC_THREADED 1 @@ -728,9 +526,6 @@ typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX { #define GM_LOCK_WAITER_WOKEN 0x2 #define GM_LOCK_WAITER_INC 0x4 -#define LOCK_QUEUE_WAIT_BIT 0 -#define LOCK_QUEUE_OWNER_BIT 1 - #define LOCK_QUEUE_WAIT 1 #define LOCK_QUEUE_OWNER 2 #define LOCK_QUEUE_TIMER_LOCK_SHIFT 4 @@ -754,59 +549,43 @@ typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX { #define MAXIMUM_PROCESSORS MAXIMUM_PROC_PER_GROUP /* Exception Records */ -#define EXCEPTION_NONCONTINUABLE 1 +#define EXCEPTION_NONCONTINUABLE 1 #define EXCEPTION_MAXIMUM_PARAMETERS 15 -#define EXCEPTION_DIVIDED_BY_ZERO 0 -#define EXCEPTION_DEBUG 1 -#define EXCEPTION_NMI 2 -#define EXCEPTION_INT3 3 -#define EXCEPTION_BOUND_CHECK 5 -#define EXCEPTION_INVALID_OPCODE 6 -#define EXCEPTION_NPX_NOT_AVAILABLE 7 -#define EXCEPTION_DOUBLE_FAULT 8 -#define EXCEPTION_NPX_OVERRUN 9 -#define EXCEPTION_INVALID_TSS 0x0A -#define EXCEPTION_SEGMENT_NOT_PRESENT 0x0B -#define EXCEPTION_STACK_FAULT 0x0C -#define EXCEPTION_GP_FAULT 0x0D -#define EXCEPTION_RESERVED_TRAP 0x0F -#define EXCEPTION_NPX_ERROR 0x010 -#define EXCEPTION_ALIGNMENT_CHECK 0x011 - typedef struct _EXCEPTION_RECORD { - NTSTATUS ExceptionCode; - ULONG ExceptionFlags; - struct _EXCEPTION_RECORD *ExceptionRecord; - PVOID ExceptionAddress; - ULONG NumberParameters; - ULONG_PTR ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS]; + NTSTATUS ExceptionCode; + ULONG ExceptionFlags; + struct _EXCEPTION_RECORD *ExceptionRecord; + PVOID ExceptionAddress; + ULONG NumberParameters; + ULONG_PTR ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS]; } EXCEPTION_RECORD, *PEXCEPTION_RECORD; typedef struct _EXCEPTION_RECORD32 { - NTSTATUS ExceptionCode; - ULONG ExceptionFlags; - ULONG ExceptionRecord; - ULONG ExceptionAddress; - ULONG NumberParameters; - ULONG ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS]; + NTSTATUS ExceptionCode; + ULONG ExceptionFlags; + ULONG ExceptionRecord; + ULONG ExceptionAddress; + ULONG NumberParameters; + ULONG ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS]; } EXCEPTION_RECORD32, *PEXCEPTION_RECORD32; typedef struct _EXCEPTION_RECORD64 { - NTSTATUS ExceptionCode; - ULONG ExceptionFlags; - ULONG64 ExceptionRecord; - ULONG64 ExceptionAddress; - ULONG NumberParameters; - ULONG __unusedAlignment; - ULONG64 ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS]; + NTSTATUS ExceptionCode; + ULONG ExceptionFlags; + ULONG64 ExceptionRecord; + ULONG64 ExceptionAddress; + ULONG NumberParameters; + ULONG __unusedAlignment; + ULONG64 ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS]; } EXCEPTION_RECORD64, *PEXCEPTION_RECORD64; typedef struct _EXCEPTION_POINTERS { - PEXCEPTION_RECORD ExceptionRecord; - PCONTEXT ContextRecord; + PEXCEPTION_RECORD ExceptionRecord; + PCONTEXT ContextRecord; } EXCEPTION_POINTERS, *PEXCEPTION_POINTERS; + typedef enum _KBUGCHECK_CALLBACK_REASON { KbCallbackInvalid, KbCallbackReserved1, @@ -818,56 +597,19 @@ typedef enum _KBUGCHECK_CALLBACK_REASON { struct _KBUGCHECK_REASON_CALLBACK_RECORD; typedef VOID -(NTAPI KBUGCHECK_REASON_CALLBACK_ROUTINE)( - IN KBUGCHECK_CALLBACK_REASON Reason, - IN struct _KBUGCHECK_REASON_CALLBACK_RECORD *Record, - IN OUT PVOID ReasonSpecificData, - IN ULONG ReasonSpecificDataLength); -typedef KBUGCHECK_REASON_CALLBACK_ROUTINE *PKBUGCHECK_REASON_CALLBACK_ROUTINE; - -typedef struct _KBUGCHECK_ADD_PAGES { - IN OUT PVOID Context; - IN OUT ULONG Flags; - IN ULONG BugCheckCode; - OUT ULONG_PTR Address; - OUT ULONG_PTR Count; -} KBUGCHECK_ADD_PAGES, *PKBUGCHECK_ADD_PAGES; - -typedef struct _KBUGCHECK_SECONDARY_DUMP_DATA { - IN PVOID InBuffer; - IN ULONG InBufferLength; - IN ULONG MaximumAllowed; - OUT GUID Guid; - OUT PVOID OutBuffer; - OUT ULONG OutBufferLength; -} KBUGCHECK_SECONDARY_DUMP_DATA, *PKBUGCHECK_SECONDARY_DUMP_DATA; - -typedef enum _KBUGCHECK_DUMP_IO_TYPE { - KbDumpIoInvalid, - KbDumpIoHeader, - KbDumpIoBody, - KbDumpIoSecondaryData, - KbDumpIoComplete -} KBUGCHECK_DUMP_IO_TYPE; - -typedef struct _KBUGCHECK_DUMP_IO { - IN ULONG64 Offset; - IN PVOID Buffer; - IN ULONG BufferLength; - IN KBUGCHECK_DUMP_IO_TYPE Type; -} KBUGCHECK_DUMP_IO, *PKBUGCHECK_DUMP_IO; - -#define KB_ADD_PAGES_FLAG_VIRTUAL_ADDRESS 0x00000001UL -#define KB_ADD_PAGES_FLAG_PHYSICAL_ADDRESS 0x00000002UL -#define KB_ADD_PAGES_FLAG_ADDITIONAL_RANGES_EXIST 0x80000000UL +(DDKAPI *PKBUGCHECK_REASON_CALLBACK_ROUTINE)( + IN KBUGCHECK_CALLBACK_REASON Reason, + IN struct _KBUGCHECK_REASON_CALLBACK_RECORD *Record, + IN OUT PVOID ReasonSpecificData, + IN ULONG ReasonSpecificDataLength); typedef struct _KBUGCHECK_REASON_CALLBACK_RECORD { - LIST_ENTRY Entry; - PKBUGCHECK_REASON_CALLBACK_ROUTINE CallbackRoutine; - PUCHAR Component; - ULONG_PTR Checksum; - KBUGCHECK_CALLBACK_REASON Reason; - UCHAR State; + LIST_ENTRY Entry; + PKBUGCHECK_REASON_CALLBACK_ROUTINE CallbackRoutine; + PUCHAR Component; + ULONG_PTR Checksum; + KBUGCHECK_CALLBACK_REASON Reason; + UCHAR State; } KBUGCHECK_REASON_CALLBACK_RECORD, *PKBUGCHECK_REASON_CALLBACK_RECORD; typedef enum _KBUGCHECK_BUFFER_DUMP_STATE { @@ -879,52 +621,39 @@ typedef enum _KBUGCHECK_BUFFER_DUMP_STATE { } KBUGCHECK_BUFFER_DUMP_STATE; typedef VOID -(NTAPI KBUGCHECK_CALLBACK_ROUTINE)( - IN PVOID Buffer, - IN ULONG Length); -typedef KBUGCHECK_CALLBACK_ROUTINE *PKBUGCHECK_CALLBACK_ROUTINE; +(DDKAPI *PKBUGCHECK_CALLBACK_ROUTINE)( + IN PVOID Buffer, + IN ULONG Length); typedef struct _KBUGCHECK_CALLBACK_RECORD { - LIST_ENTRY Entry; - PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine; - PVOID Buffer; - ULONG Length; - PUCHAR Component; - ULONG_PTR Checksum; - UCHAR State; + LIST_ENTRY Entry; + PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine; + PVOID Buffer; + ULONG Length; + PUCHAR Component; + ULONG_PTR Checksum; + UCHAR State; } KBUGCHECK_CALLBACK_RECORD, *PKBUGCHECK_CALLBACK_RECORD; typedef BOOLEAN -(NTAPI NMI_CALLBACK)( - IN PVOID Context, - IN BOOLEAN Handled); -typedef NMI_CALLBACK *PNMI_CALLBACK; +(DDKAPI *PNMI_CALLBACK)( + IN PVOID Context, + IN BOOLEAN Handled); -typedef enum _KE_PROCESSOR_CHANGE_NOTIFY_STATE { - KeProcessorAddStartNotify = 0, - KeProcessorAddCompleteNotify, - KeProcessorAddFailureNotify -} KE_PROCESSOR_CHANGE_NOTIFY_STATE; - -typedef struct _KE_PROCESSOR_CHANGE_NOTIFY_CONTEXT { - KE_PROCESSOR_CHANGE_NOTIFY_STATE State; - ULONG NtNumber; - NTSTATUS Status; -#if (NTDDI_VERSION >= NTDDI_WIN7) - PROCESSOR_NUMBER ProcNumber; -#endif -} KE_PROCESSOR_CHANGE_NOTIFY_CONTEXT, *PKE_PROCESSOR_CHANGE_NOTIFY_CONTEXT; - -typedef VOID -(NTAPI PROCESSOR_CALLBACK_FUNCTION)( - IN PVOID CallbackContext, - IN PKE_PROCESSOR_CHANGE_NOTIFY_CONTEXT ChangeContext, - IN OUT PNTSTATUS OperationStatus); -typedef PROCESSOR_CALLBACK_FUNCTION *PPROCESSOR_CALLBACK_FUNCTION; - -#define KE_PROCESSOR_CHANGE_ADD_EXISTING 1 - -#define INVALID_PROCESSOR_INDEX 0xffffffff +typedef enum _TRACE_INFORMATION_CLASS { + TraceIdClass, + TraceHandleClass, + TraceEnableFlagsClass, + TraceEnableLevelClass, + GlobalLoggerHandleClass, + EventLoggerHandleClass, + AllLoggerHandlesClass, + TraceHandleByNameClass, + LoggerEventsLostClass, + TraceSessionSettingsClass, + LoggerEventsLoggedClass, + MaxTraceInformationClass +} TRACE_INFORMATION_CLASS; typedef enum _KINTERRUPT_POLARITY { InterruptPolarityUnknown, @@ -1022,50 +751,55 @@ typedef enum _KINTERRUPT_MODE { #define THREAD_WAIT_OBJECTS 3 typedef VOID -(NTAPI KSTART_ROUTINE)( - IN PVOID StartContext); -typedef KSTART_ROUTINE *PKSTART_ROUTINE; - -typedef VOID -(NTAPI *PKINTERRUPT_ROUTINE)( +(DDKAPI *PKINTERRUPT_ROUTINE)( VOID); -typedef BOOLEAN -(NTAPI KSERVICE_ROUTINE)( - IN struct _KINTERRUPT *Interrupt, - IN PVOID ServiceContext); -typedef KSERVICE_ROUTINE *PKSERVICE_ROUTINE; - -typedef BOOLEAN -(NTAPI KMESSAGE_SERVICE_ROUTINE)( - IN struct _KINTERRUPT *Interrupt, - IN PVOID ServiceContext, - IN ULONG MessageID); -typedef KMESSAGE_SERVICE_ROUTINE *PKMESSAGE_SERVICE_ROUTINE; - typedef enum _KD_OPTION { - KD_OPTION_SET_BLOCK_ENABLE, + KD_OPTION_SET_BLOCK_ENABLE, } KD_OPTION; -typedef VOID -(NTAPI *PKNORMAL_ROUTINE)( - IN PVOID NormalContext OPTIONAL, - IN PVOID SystemArgument1 OPTIONAL, - IN PVOID SystemArgument2 OPTIONAL); +typedef enum _INTERFACE_TYPE { + InterfaceTypeUndefined = -1, + Internal, + Isa, + Eisa, + MicroChannel, + TurboChannel, + PCIBus, + VMEBus, + NuBus, + PCMCIABus, + CBus, + MPIBus, + MPSABus, + ProcessorInternal, + InternalPowerBus, + PNPISABus, + PNPBus, + Vmcs, + MaximumInterfaceType +} INTERFACE_TYPE, *PINTERFACE_TYPE; typedef VOID -(NTAPI *PKRUNDOWN_ROUTINE)( - IN struct _KAPC *Apc); +(DDKAPI *PKNORMAL_ROUTINE)( + IN PVOID NormalContext, + IN PVOID SystemArgument1, + IN PVOID SystemArgument2); typedef VOID -(NTAPI *PKKERNEL_ROUTINE)( - IN struct _KAPC *Apc, - IN OUT PKNORMAL_ROUTINE *NormalRoutine OPTIONAL, - IN OUT PVOID *NormalContext OPTIONAL, - IN OUT PVOID *SystemArgument1 OPTIONAL, - IN OUT PVOID *SystemArgument2 OPTIONAL); +(DDKAPI *PKRUNDOWN_ROUTINE)( + IN struct _KAPC *Apc); -typedef struct _KAPC { +typedef VOID +(DDKAPI *PKKERNEL_ROUTINE)( + IN struct _KAPC *Apc, + IN OUT PKNORMAL_ROUTINE *NormalRoutine, + IN OUT PVOID *NormalContext, + IN OUT PVOID *SystemArgument1, + IN OUT PVOID *SystemArgument2); + +typedef struct _KAPC +{ UCHAR Type; UCHAR SpareByte0; UCHAR Size; @@ -1084,62 +818,38 @@ typedef struct _KAPC { BOOLEAN Inserted; } KAPC, *PKAPC, *RESTRICTED_POINTER PRKAPC; -#define KAPC_OFFSET_TO_SPARE_BYTE0 FIELD_OFFSET(KAPC, SpareByte0) -#define KAPC_OFFSET_TO_SPARE_BYTE1 FIELD_OFFSET(KAPC, SpareByte1) -#define KAPC_OFFSET_TO_SPARE_LONG FIELD_OFFSET(KAPC, SpareLong0) -#define KAPC_OFFSET_TO_SYSTEMARGUMENT1 FIELD_OFFSET(KAPC, SystemArgument1) -#define KAPC_OFFSET_TO_SYSTEMARGUMENT2 FIELD_OFFSET(KAPC, SystemArgument2) -#define KAPC_OFFSET_TO_APCSTATEINDEX FIELD_OFFSET(KAPC, ApcStateIndex) -#define KAPC_ACTUAL_LENGTH (FIELD_OFFSET(KAPC, Inserted) + sizeof(BOOLEAN)) - typedef struct _KDEVICE_QUEUE_ENTRY { - LIST_ENTRY DeviceListEntry; - ULONG SortKey; - BOOLEAN Inserted; + LIST_ENTRY DeviceListEntry; + ULONG SortKey; + BOOLEAN Inserted; } KDEVICE_QUEUE_ENTRY, *PKDEVICE_QUEUE_ENTRY, *RESTRICTED_POINTER PRKDEVICE_QUEUE_ENTRY; typedef PVOID PKIPI_CONTEXT; -typedef VOID +typedef +VOID (NTAPI *PKIPI_WORKER)( - IN OUT PKIPI_CONTEXT PacketContext, - IN PVOID Parameter1 OPTIONAL, - IN PVOID Parameter2 OPTIONAL, - IN PVOID Parameter3 OPTIONAL); + IN PKIPI_CONTEXT PacketContext, + IN PVOID Parameter1, + IN PVOID Parameter2, + IN PVOID Parameter3); -typedef struct _KIPI_COUNTS { - ULONG Freeze; - ULONG Packet; - ULONG DPC; - ULONG APC; - ULONG FlushSingleTb; - ULONG FlushMultipleTb; - ULONG FlushEntireTb; - ULONG GenericCall; - ULONG ChangeColor; - ULONG SweepDcache; - ULONG SweepIcache; - ULONG SweepIcacheRange; - ULONG FlushIoBuffers; - ULONG GratuitousDPC; -} KIPI_COUNTS, *PKIPI_COUNTS; - -typedef ULONG_PTR -(NTAPI KIPI_BROADCAST_WORKER)( - IN ULONG_PTR Argument); -typedef KIPI_BROADCAST_WORKER *PKIPI_BROADCAST_WORKER; +typedef +ULONG_PTR +(NTAPI *PKIPI_BROADCAST_WORKER)( + IN ULONG_PTR Argument); typedef ULONG_PTR KSPIN_LOCK, *PKSPIN_LOCK; typedef struct _KSPIN_LOCK_QUEUE { - struct _KSPIN_LOCK_QUEUE *volatile Next; - PKSPIN_LOCK volatile Lock; + struct _KSPIN_LOCK_QUEUE *volatile Next; + PKSPIN_LOCK volatile Lock; } KSPIN_LOCK_QUEUE, *PKSPIN_LOCK_QUEUE; typedef struct _KLOCK_QUEUE_HANDLE { - KSPIN_LOCK_QUEUE LockQueue; - KIRQL OldIrql; + KSPIN_LOCK_QUEUE LockQueue; + KIRQL OldIrql; } KLOCK_QUEUE_HANDLE, *PKLOCK_QUEUE_HANDLE; #if defined(_AMD64_) @@ -1190,14 +900,14 @@ typedef enum _KSPIN_LOCK_QUEUE_NUMBER { LockQueueMaximumLock = LockQueueTimerTableLock + LOCK_QUEUE_TIMER_TABLE_LOCKS } KSPIN_LOCK_QUEUE_NUMBER, *PKSPIN_LOCK_QUEUE_NUMBER; -#endif /* defined(_AMD64_) */ +#endif typedef VOID -(NTAPI *PKDEFERRED_ROUTINE)( - IN struct _KDPC *Dpc, - IN PVOID DeferredContext OPTIONAL, - IN PVOID SystemArgument1 OPTIONAL, - IN PVOID SystemArgument2 OPTIONAL); +(DDKAPI *PKDEFERRED_ROUTINE)( + IN struct _KDPC *Dpc, + IN PVOID DeferredContext, + IN PVOID SystemArgument1, + IN PVOID SystemArgument2); typedef enum _KDPC_IMPORTANCE { LowImportance, @@ -1206,16 +916,17 @@ typedef enum _KDPC_IMPORTANCE { MediumHighImportance } KDPC_IMPORTANCE; -typedef struct _KDPC { - UCHAR Type; - UCHAR Importance; - volatile USHORT Number; - LIST_ENTRY DpcListEntry; - PKDEFERRED_ROUTINE DeferredRoutine; - PVOID DeferredContext; - PVOID SystemArgument1; - PVOID SystemArgument2; - volatile PVOID DpcData; +typedef struct _KDPC +{ + UCHAR Type; + UCHAR Importance; + volatile USHORT Number; + LIST_ENTRY DpcListEntry; + PKDEFERRED_ROUTINE DeferredRoutine; + PVOID DeferredContext; + PVOID SystemArgument1; + PVOID SystemArgument2; + volatile PVOID DpcData; } KDPC, *PKDPC, *RESTRICTED_POINTER PRKDPC; typedef struct _KDPC_WATCHDOG_INFORMATION { @@ -1235,124 +946,126 @@ typedef struct _KDEVICE_QUEUE { union { BOOLEAN Busy; struct { - LONG64 Reserved:8; - LONG64 Hint:56; + LONG64 Reserved : 8; + LONG64 Hint : 56; }; }; #else BOOLEAN Busy; #endif + } KDEVICE_QUEUE, *PKDEVICE_QUEUE, *RESTRICTED_POINTER PRKDEVICE_QUEUE; #define TIMER_EXPIRED_INDEX_BITS 6 #define TIMER_PROCESSOR_INDEX_BITS 5 - typedef struct _DISPATCHER_HEADER { - _ANONYMOUS_UNION union { - _ANONYMOUS_STRUCT struct { - UCHAR Type; - _ANONYMOUS_UNION union { - _ANONYMOUS_UNION union { - UCHAR TimerControlFlags; - _ANONYMOUS_STRUCT struct { - UCHAR Absolute:1; - UCHAR Coalescable:1; - UCHAR KeepShifting:1; - UCHAR EncodedTolerableDelay:5; - } DUMMYSTRUCTNAME; - } DUMMYUNIONNAME; - UCHAR Abandoned; + _ANONYMOUS_UNION union { + _ANONYMOUS_STRUCT struct { + UCHAR Type; + _ANONYMOUS_UNION union { + _ANONYMOUS_UNION union { + UCHAR TimerControlFlags; + _ANONYMOUS_STRUCT struct { + UCHAR Absolute:1; + UCHAR Coalescable:1; + UCHAR KeepShifting:1; + UCHAR EncodedTolerableDelay:5; + } DUMMYSTRUCTNAME; + } DUMMYUNIONNAME; + UCHAR Abandoned; #if (NTDDI_VERSION < NTDDI_WIN7) - UCHAR NpxIrql; + UCHAR NpxIrql; #endif - BOOLEAN Signalling; - } DUMMYUNIONNAME; - _ANONYMOUS_UNION union { - _ANONYMOUS_UNION union { - UCHAR ThreadControlFlags; - _ANONYMOUS_STRUCT struct { - UCHAR CpuThrottled:1; - UCHAR CycleProfiling:1; - UCHAR CounterProfiling:1; - UCHAR Reserved:5; - } DUMMYSTRUCTNAME; - } DUMMYUNIONNAME; - UCHAR Size; - UCHAR Hand; - } DUMMYUNIONNAME2; - _ANONYMOUS_UNION union { + BOOLEAN Signalling; + } DUMMYUNIONNAME; + _ANONYMOUS_UNION union { + _ANONYMOUS_UNION union { + UCHAR ThreadControlFlags; + _ANONYMOUS_STRUCT struct { + UCHAR CpuThrottled:1; + UCHAR CycleProfiling:1; + UCHAR CounterProfiling:1; + UCHAR Reserved:5; + } DUMMYSTRUCTNAME; + } DUMMYUNIONNAME; + UCHAR Size; + UCHAR Hand; + } DUMMYUNIONNAME2; + _ANONYMOUS_UNION union { #if (NTDDI_VERSION >= NTDDI_WIN7) - _ANONYMOUS_UNION union { - UCHAR TimerMiscFlags; - _ANONYMOUS_STRUCT struct { + _ANONYMOUS_UNION union { + UCHAR TimerMiscFlags; + _ANONYMOUS_STRUCT struct { #if !defined(_X86_) - UCHAR Index:TIMER_EXPIRED_INDEX_BITS; + UCHAR Index:TIMER_EXPIRED_INDEX_BITS; #else - UCHAR Index:1; - UCHAR Processor:TIMER_PROCESSOR_INDEX_BITS; + UCHAR Index:1; + UCHAR Processor:TIMER_PROCESSOR_INDEX_BITS; #endif - UCHAR Inserted:1; - volatile UCHAR Expired:1; - } DUMMYSTRUCTNAME; - } DUMMYUNIONNAME; + UCHAR Inserted:1; + volatile UCHAR Expired:1; + } DUMMYSTRUCTNAME; + } DUMMYUNIONNAME; #else - /* Pre Win7 compatibility fix to latest WDK */ - UCHAR Inserted; + /* Pre Win7 compatibility fix to latest WDK */ + UCHAR Inserted; #endif - _ANONYMOUS_UNION union { - BOOLEAN DebugActive; - _ANONYMOUS_STRUCT struct { - BOOLEAN ActiveDR7:1; - BOOLEAN Instrumented:1; - BOOLEAN Reserved2:4; - BOOLEAN UmsScheduled:1; - BOOLEAN UmsPrimary:1; - } DUMMYSTRUCTNAME; - } DUMMYUNIONNAME; /* should probably be DUMMYUNIONNAME2, but this is what WDK says */ - BOOLEAN DpcActive; - } DUMMYUNIONNAME3; - } DUMMYSTRUCTNAME; - volatile LONG Lock; - } DUMMYUNIONNAME; - LONG SignalState; - LIST_ENTRY WaitListHead; + _ANONYMOUS_UNION union { + BOOLEAN DebugActive; + _ANONYMOUS_STRUCT struct { + BOOLEAN ActiveDR7:1; + BOOLEAN Instrumented:1; + BOOLEAN Reserved2:4; + BOOLEAN UmsScheduled:1; + BOOLEAN UmsPrimary:1; + } DUMMYSTRUCTNAME; + } DUMMYUNIONNAME; /* should probably be DUMMYUNIONNAME2, but this is what WDK says */ + BOOLEAN DpcActive; + } DUMMYUNIONNAME3; + } DUMMYSTRUCTNAME; + volatile LONG Lock; + } DUMMYUNIONNAME; + LONG SignalState; + LIST_ENTRY WaitListHead; } DISPATCHER_HEADER, *PDISPATCHER_HEADER; typedef struct _KEVENT { - DISPATCHER_HEADER Header; + DISPATCHER_HEADER Header; } KEVENT, *PKEVENT, *RESTRICTED_POINTER PRKEVENT; typedef struct _KSEMAPHORE { - DISPATCHER_HEADER Header; - LONG Limit; + DISPATCHER_HEADER Header; + LONG Limit; } KSEMAPHORE, *PKSEMAPHORE, *RESTRICTED_POINTER PRKSEMAPHORE; -#define KSEMAPHORE_ACTUAL_LENGTH (FIELD_OFFSET(KSEMAPHORE, Limit) + sizeof(LONG)) - -typedef struct _KGATE { - DISPATCHER_HEADER Header; +typedef struct _KGATE +{ + DISPATCHER_HEADER Header; } KGATE, *PKGATE, *RESTRICTED_POINTER PRKGATE; -typedef struct _KGUARDED_MUTEX { - volatile LONG Count; - PKTHREAD Owner; - ULONG Contention; - KGATE Gate; - __GNU_EXTENSION union { - __GNU_EXTENSION struct { - SHORT KernelApcDisable; - SHORT SpecialApcDisable; +typedef struct _KGUARDED_MUTEX +{ + volatile LONG Count; + PKTHREAD Owner; + ULONG Contention; + KGATE Gate; + __GNU_EXTENSION union + { + __GNU_EXTENSION struct + { + SHORT KernelApcDisable; + SHORT SpecialApcDisable; + }; + ULONG CombinedApcDisable; }; - ULONG CombinedApcDisable; - }; } KGUARDED_MUTEX, *PKGUARDED_MUTEX; typedef struct _KMUTANT { - DISPATCHER_HEADER Header; - LIST_ENTRY MutantListEntry; - struct _KTHREAD *RESTRICTED_POINTER OwnerThread; - BOOLEAN Abandoned; - UCHAR ApcDisable; + DISPATCHER_HEADER Header; + LIST_ENTRY MutantListEntry; + struct _KTHREAD *RESTRICTED_POINTER OwnerThread; + BOOLEAN Abandoned; + UCHAR ApcDisable; } KMUTANT, *PKMUTANT, *RESTRICTED_POINTER PRKMUTANT, KMUTEX, *PKMUTEX, *RESTRICTED_POINTER PRKMUTEX; #define TIMER_TABLE_SIZE 512 @@ -1369,17 +1082,9 @@ typedef struct _KTIMER { ULONG Period; } KTIMER, *PKTIMER, *RESTRICTED_POINTER PRKTIMER; -typedef enum _LOCK_OPERATION { - IoReadAccess, - IoWriteAccess, - IoModifyAccess -} LOCK_OPERATION; - -#define KTIMER_ACTUAL_LENGTH (FIELD_OFFSET(KTIMER, Period) + sizeof(LONG)) - typedef BOOLEAN -(NTAPI *PKSYNCHRONIZE_ROUTINE)( - IN PVOID SynchronizeContext); +(DDKAPI *PKSYNCHRONIZE_ROUTINE)( + IN PVOID SynchronizeContext); typedef enum _POOL_TYPE { NonPagedPool, @@ -1399,41 +1104,29 @@ typedef enum _POOL_TYPE { NonPagedPoolCacheAlignedMustSSession } POOL_TYPE; -typedef enum _ALTERNATIVE_ARCHITECTURE_TYPE { - StandardDesign, - NEC98x86, - EndAlternatives +typedef enum _ALTERNATIVE_ARCHITECTURE_TYPE +{ + StandardDesign, + NEC98x86, + EndAlternatives } ALTERNATIVE_ARCHITECTURE_TYPE; -#ifndef _X86_ - -#ifndef IsNEC_98 -#define IsNEC_98 (FALSE) -#endif - -#ifndef IsNotNEC_98 -#define IsNotNEC_98 (TRUE) -#endif - -#ifndef SetNEC_98 -#define SetNEC_98 -#endif - -#ifndef SetNotNEC_98 -#define SetNotNEC_98 -#endif - -#endif - -typedef struct _KSYSTEM_TIME { - ULONG LowPart; - LONG High1Time; - LONG High2Time; +typedef struct _KSYSTEM_TIME +{ + ULONG LowPart; + LONG High1Time; + LONG High2Time; } KSYSTEM_TIME, *PKSYSTEM_TIME; +typedef struct _PNP_BUS_INFORMATION { + GUID BusTypeGuid; + INTERFACE_TYPE LegacyBusType; + ULONG BusNumber; +} PNP_BUS_INFORMATION, *PPNP_BUS_INFORMATION; + typedef struct DECLSPEC_ALIGN(16) _M128A { - ULONGLONG Low; - LONGLONG High; + ULONGLONG Low; + LONGLONG High; } M128A, *PM128A; typedef struct DECLSPEC_ALIGN(16) _XSAVE_FORMAT { @@ -1462,110 +1155,18 @@ typedef struct DECLSPEC_ALIGN(16) _XSAVE_FORMAT { #endif } XSAVE_FORMAT, *PXSAVE_FORMAT; -typedef struct DECLSPEC_ALIGN(8) _XSAVE_AREA_HEADER { - ULONG64 Mask; - ULONG64 Reserved[7]; -} XSAVE_AREA_HEADER, *PXSAVE_AREA_HEADER; - -typedef struct DECLSPEC_ALIGN(16) _XSAVE_AREA { - XSAVE_FORMAT LegacyState; - XSAVE_AREA_HEADER Header; -} XSAVE_AREA, *PXSAVE_AREA; - -typedef struct _XSTATE_CONTEXT { - ULONG64 Mask; - ULONG Length; - ULONG Reserved1; - PXSAVE_AREA Area; -#if defined(_X86_) - ULONG Reserved2; -#endif - PVOID Buffer; -#if defined(_X86_) - ULONG Reserved3; -#endif -} XSTATE_CONTEXT, *PXSTATE_CONTEXT; - -typedef struct _XSTATE_SAVE { -#if defined(_AMD64_) - struct _XSTATE_SAVE* Prev; - struct _KTHREAD* Thread; - UCHAR Level; - XSTATE_CONTEXT XStateContext; -#elif defined(_IA64_) - ULONG Dummy; -#elif defined(_X86_) - union { - struct { - LONG64 Reserved1; - ULONG Reserved2; - struct _XSTATE_SAVE* Prev; - PXSAVE_AREA Reserved3; - struct _KTHREAD* Thread; - PVOID Reserved4; - UCHAR Level; - }; - XSTATE_CONTEXT XStateContext; - }; -#endif -} XSTATE_SAVE, *PXSTATE_SAVE; - -#ifdef _X86_ - -#define MAXIMUM_SUPPORTED_EXTENSION 512 - -#if !defined(__midl) && !defined(MIDL_PASS) -C_ASSERT(sizeof(XSAVE_FORMAT) == MAXIMUM_SUPPORTED_EXTENSION); -#endif - -#endif /* _X86_ */ - -#define XSAVE_ALIGN 64 -#define MINIMAL_XSTATE_AREA_LENGTH sizeof(XSAVE_AREA) - -#if !defined(__midl) && !defined(MIDL_PASS) -C_ASSERT((sizeof(XSAVE_FORMAT) & (XSAVE_ALIGN - 1)) == 0); -C_ASSERT((FIELD_OFFSET(XSAVE_AREA, Header) & (XSAVE_ALIGN - 1)) == 0); -C_ASSERT(MINIMAL_XSTATE_AREA_LENGTH == 512 + 64); -#endif - -typedef struct _CONTEXT_CHUNK { - LONG Offset; - ULONG Length; -} CONTEXT_CHUNK, *PCONTEXT_CHUNK; - -typedef struct _CONTEXT_EX { - CONTEXT_CHUNK All; - CONTEXT_CHUNK Legacy; - CONTEXT_CHUNK XState; -} CONTEXT_EX, *PCONTEXT_EX; - -#define CONTEXT_EX_LENGTH ALIGN_UP_BY(sizeof(CONTEXT_EX), STACK_ALIGN) - -#if (NTDDI_VERSION >= NTDDI_VISTA) -extern NTSYSAPI volatile CCHAR KeNumberProcessors; -#elif (NTDDI_VERSION >= NTDDI_WINXP) -extern NTSYSAPI CCHAR KeNumberProcessors; -#else -extern PCCHAR KeNumberProcessors; -#endif /****************************************************************************** * Memory manager Types * ******************************************************************************/ -#if (NTDDI_VERSION >= NTDDI_WIN2K) -typedef ULONG NODE_REQUIREMENT; -#define MM_ANY_NODE_OK 0x80000000 -#endif - -#define MM_DONT_ZERO_ALLOCATION 0x00000001 -#define MM_ALLOCATE_FROM_LOCAL_NODE_ONLY 0x00000002 -#define MM_ALLOCATE_FULLY_REQUIRED 0x00000004 -#define MM_ALLOCATE_NO_WAIT 0x00000008 -#define MM_ALLOCATE_PREFER_CONTIGUOUS 0x00000010 -#define MM_ALLOCATE_REQUIRE_CONTIGUOUS_CHUNKS 0x00000020 +#define MM_DONT_ZERO_ALLOCATION 0x00000001 +#define MM_ALLOCATE_FROM_LOCAL_NODE_ONLY 0x00000002 +#define MM_ALLOCATE_FULLY_REQUIRED 0x00000004 +#define MM_ALLOCATE_NO_WAIT 0x00000008 +#define MM_ALLOCATE_PREFER_CONTIGUOUS 0x00000010 +#define MM_ALLOCATE_REQUIRE_CONTIGUOUS_CHUNKS 0x00000020 #define MDL_MAPPED_TO_SYSTEM_VA 0x0001 #define MDL_PAGES_LOCKED 0x0002 @@ -1648,8 +1249,8 @@ typedef ULONG NODE_REQUIREMENT; /* Section map options */ typedef enum _SECTION_INHERIT { - ViewShare = 1, - ViewUnmap = 2 + ViewShare = 1, + ViewUnmap = 2 } SECTION_INHERIT; typedef ULONG PFN_COUNT; @@ -1657,14 +1258,14 @@ typedef LONG_PTR SPFN_NUMBER, *PSPFN_NUMBER; typedef ULONG_PTR PFN_NUMBER, *PPFN_NUMBER; typedef struct _MDL { - struct _MDL *Next; - CSHORT Size; - CSHORT MdlFlags; - struct _EPROCESS *Process; - PVOID MappedSystemVa; - PVOID StartVa; - ULONG ByteCount; - ULONG ByteOffset; + struct _MDL *Next; + CSHORT Size; + CSHORT MdlFlags; + struct _EPROCESS *Process; + PVOID MappedSystemVa; + PVOID StartVa; + ULONG ByteCount; + ULONG ByteOffset; } MDL, *PMDL; typedef MDL *PMDLX; @@ -1688,15 +1289,18 @@ typedef enum _MM_PAGE_PRIORITY { HighPagePriority = 32 } MM_PAGE_PRIORITY; +typedef enum _LOCK_OPERATION { + IoReadAccess, + IoWriteAccess, + IoModifyAccess +} LOCK_OPERATION; + typedef enum _MM_SYSTEM_SIZE { MmSmallSystem, MmMediumSystem, MmLargeSystem } MM_SYSTEMSIZE; -extern NTKERNELAPI BOOLEAN Mm64BitPhysicalAddress; -extern PVOID MmBadPointer; - /****************************************************************************** * Executive Types * @@ -1706,6 +1310,12 @@ extern PVOID MmBadPointer; #define EX_RUNDOWN_COUNT_SHIFT 0x1 #define EX_RUNDOWN_COUNT_INC (1 << EX_RUNDOWN_COUNT_SHIFT) +#ifdef _WIN64 +#define PORT_MAXIMUM_MESSAGE_LENGTH 512 +#else +#define PORT_MAXIMUM_MESSAGE_LENGTH 256 +#endif + typedef struct _FAST_MUTEX { volatile LONG Count; PKTHREAD Owner; @@ -1715,35 +1325,35 @@ typedef struct _FAST_MUTEX { } FAST_MUTEX, *PFAST_MUTEX; typedef enum _SUITE_TYPE { - SmallBusiness, - Enterprise, - BackOffice, - CommunicationServer, - TerminalServer, - SmallBusinessRestricted, - EmbeddedNT, - DataCenter, - SingleUserTS, - Personal, - Blade, - EmbeddedRestricted, - SecurityAppliance, - StorageServer, - ComputeServer, - WHServer, - MaxSuiteType + SmallBusiness, + Enterprise, + BackOffice, + CommunicationServer, + TerminalServer, + SmallBusinessRestricted, + EmbeddedNT, + DataCenter, + SingleUserTS, + Personal, + Blade, + EmbeddedRestricted, + SecurityAppliance, + StorageServer, + ComputeServer, + WHServer, + MaxSuiteType } SUITE_TYPE; typedef enum _EX_POOL_PRIORITY { - LowPoolPriority, - LowPoolPrioritySpecialPoolOverrun = 8, - LowPoolPrioritySpecialPoolUnderrun = 9, - NormalPoolPriority = 16, - NormalPoolPrioritySpecialPoolOverrun = 24, - NormalPoolPrioritySpecialPoolUnderrun = 25, - HighPoolPriority = 32, - HighPoolPrioritySpecialPoolOverrun = 40, - HighPoolPrioritySpecialPoolUnderrun = 41 + LowPoolPriority, + LowPoolPrioritySpecialPoolOverrun = 8, + LowPoolPrioritySpecialPoolUnderrun = 9, + NormalPoolPriority = 16, + NormalPoolPrioritySpecialPoolOverrun = 24, + NormalPoolPrioritySpecialPoolUnderrun = 25, + HighPoolPriority = 32, + HighPoolPrioritySpecialPoolOverrun = 40, + HighPoolPrioritySpecialPoolUnderrun = 41 } EX_POOL_PRIORITY; #if !defined(_WIN64) && (defined(_NTDDK_) || defined(_NTIFS_) || defined(_NDIS_)) @@ -1755,33 +1365,32 @@ typedef enum _EX_POOL_PRIORITY { typedef struct _LOOKASIDE_LIST_EX *PLOOKASIDE_LIST_EX; typedef PVOID -(NTAPI *PALLOCATE_FUNCTION)( - IN POOL_TYPE PoolType, - IN SIZE_T NumberOfBytes, - IN ULONG Tag); +(DDKAPI *PALLOCATE_FUNCTION)( + IN POOL_TYPE PoolType, + IN SIZE_T NumberOfBytes, + IN ULONG Tag); typedef PVOID -(NTAPI *PALLOCATE_FUNCTION_EX)( - IN POOL_TYPE PoolType, - IN SIZE_T NumberOfBytes, - IN ULONG Tag, - IN OUT PLOOKASIDE_LIST_EX Lookaside); +(DDKAPI *PALLOCATE_FUNCTION_EX)( + IN POOL_TYPE PoolType, + IN SIZE_T NumberOfBytes, + IN ULONG Tag, + IN OUT PLOOKASIDE_LIST_EX Lookaside); typedef VOID -(NTAPI *PFREE_FUNCTION)( - IN PVOID Buffer); +(DDKAPI *PFREE_FUNCTION)( + IN PVOID Buffer); typedef VOID -(NTAPI *PFREE_FUNCTION_EX)( - IN PVOID Buffer, - IN OUT PLOOKASIDE_LIST_EX Lookaside); +(DDKAPI *PFREE_FUNCTION_EX)( + IN PVOID Buffer, + IN OUT PLOOKASIDE_LIST_EX Lookaside); typedef VOID -(NTAPI CALLBACK_FUNCTION)( - IN PVOID CallbackContext OPTIONAL, - IN PVOID Argument1 OPTIONAL, - IN PVOID Argument2 OPTIONAL); -typedef CALLBACK_FUNCTION *PCALLBACK_FUNCTION; +(DDKAPI *PCALLBACK_FUNCTION)( + IN PVOID CallbackContext, + IN PVOID Argument1, + IN PVOID Argument2); #define GENERAL_LOOKASIDE_LAYOUT \ union { \ @@ -1824,149 +1433,50 @@ typedef CALLBACK_FUNCTION *PCALLBACK_FUNCTION; ULONG Future[2]; typedef struct LOOKASIDE_ALIGN _GENERAL_LOOKASIDE { - GENERAL_LOOKASIDE_LAYOUT + GENERAL_LOOKASIDE_LAYOUT } GENERAL_LOOKASIDE, *PGENERAL_LOOKASIDE; typedef struct _GENERAL_LOOKASIDE_POOL { - GENERAL_LOOKASIDE_LAYOUT + GENERAL_LOOKASIDE_LAYOUT } GENERAL_LOOKASIDE_POOL, *PGENERAL_LOOKASIDE_POOL; -#define LOOKASIDE_CHECK(f) \ - C_ASSERT(FIELD_OFFSET(GENERAL_LOOKASIDE,f) == FIELD_OFFSET(GENERAL_LOOKASIDE_POOL,f)) - -LOOKASIDE_CHECK(TotalFrees); -LOOKASIDE_CHECK(Tag); -LOOKASIDE_CHECK(Future); - typedef struct _PAGED_LOOKASIDE_LIST { - GENERAL_LOOKASIDE L; + GENERAL_LOOKASIDE L; #if !defined(_AMD64_) && !defined(_IA64_) - FAST_MUTEX Lock__ObsoleteButDoNotDelete; + FAST_MUTEX Lock__ObsoleteButDoNotDelete; #endif } PAGED_LOOKASIDE_LIST, *PPAGED_LOOKASIDE_LIST; typedef struct LOOKASIDE_ALIGN _NPAGED_LOOKASIDE_LIST { - GENERAL_LOOKASIDE L; + GENERAL_LOOKASIDE L; #if !defined(_AMD64_) && !defined(_IA64_) - KSPIN_LOCK Lock__ObsoleteButDoNotDelete; + KSPIN_LOCK Lock__ObsoleteButDoNotDelete; #endif } NPAGED_LOOKASIDE_LIST, *PNPAGED_LOOKASIDE_LIST; -#define LOOKASIDE_MINIMUM_BLOCK_SIZE (RTL_SIZEOF_THROUGH_FIELD (SLIST_ENTRY, Next)) - typedef struct _LOOKASIDE_LIST_EX { - GENERAL_LOOKASIDE_POOL L; + GENERAL_LOOKASIDE_POOL L; } LOOKASIDE_LIST_EX; -#if (NTDDI_VERSION >= NTDDI_VISTA) - -#define EX_LOOKASIDE_LIST_EX_FLAGS_RAISE_ON_FAIL 0x00000001UL -#define EX_LOOKASIDE_LIST_EX_FLAGS_FAIL_NO_RAISE 0x00000002UL - -#define EX_MAXIMUM_LOOKASIDE_DEPTH_BASE 256 -#define EX_MAXIMUM_LOOKASIDE_DEPTH_LIMIT 1024 - -#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ - typedef struct _EX_RUNDOWN_REF { - __GNU_EXTENSION union { - volatile ULONG_PTR Count; - volatile PVOID Ptr; - }; + __GNU_EXTENSION union { + volatile ULONG_PTR Count; + volatile PVOID Ptr; + }; } EX_RUNDOWN_REF, *PEX_RUNDOWN_REF; -typedef struct _EX_RUNDOWN_REF_CACHE_AWARE *PEX_RUNDOWN_REF_CACHE_AWARE; - -typedef enum _WORK_QUEUE_TYPE { - CriticalWorkQueue, - DelayedWorkQueue, - HyperCriticalWorkQueue, - MaximumWorkQueue -} WORK_QUEUE_TYPE; +typedef struct _EX_RUNDOWN_REF_CACHE_AWARE *PEX_RUNDOWN_REF_CACHE_AWARE; typedef VOID -(NTAPI WORKER_THREAD_ROUTINE)( +(DDKAPI *PWORKER_THREAD_ROUTINE)( IN PVOID Parameter); -typedef WORKER_THREAD_ROUTINE *PWORKER_THREAD_ROUTINE; typedef struct _WORK_QUEUE_ITEM { - LIST_ENTRY List; - PWORKER_THREAD_ROUTINE WorkerRoutine; - volatile PVOID Parameter; + LIST_ENTRY List; + PWORKER_THREAD_ROUTINE WorkerRoutine; + volatile PVOID Parameter; } WORK_QUEUE_ITEM, *PWORK_QUEUE_ITEM; -typedef ULONG_PTR ERESOURCE_THREAD, *PERESOURCE_THREAD; - -typedef struct _OWNER_ENTRY { - ERESOURCE_THREAD OwnerThread; - union { - struct { - ULONG IoPriorityBoosted:1; - ULONG OwnerReferenced:1; - ULONG OwnerCount:30; - }; - ULONG TableSize; - }; -} OWNER_ENTRY, *POWNER_ENTRY; - -typedef struct _ERESOURCE { - LIST_ENTRY SystemResourcesList; - POWNER_ENTRY OwnerTable; - SHORT ActiveCount; - USHORT Flag; - volatile PKSEMAPHORE SharedWaiters; - volatile PKEVENT ExclusiveWaiters; - OWNER_ENTRY OwnerEntry; - ULONG ActiveEntries; - ULONG ContentionCount; - ULONG NumberOfSharedWaiters; - ULONG NumberOfExclusiveWaiters; -#if defined(_WIN64) - PVOID Reserved2; -#endif - __GNU_EXTENSION union { - PVOID Address; - ULONG_PTR CreatorBackTraceIndex; - }; - KSPIN_LOCK SpinLock; -} ERESOURCE, *PERESOURCE; - -/* ERESOURCE.Flag */ -#define ResourceNeverExclusive 0x0010 -#define ResourceReleaseByOtherThread 0x0020 -#define ResourceOwnedExclusive 0x0080 - -#define RESOURCE_HASH_TABLE_SIZE 64 - -typedef struct _RESOURCE_HASH_ENTRY { - LIST_ENTRY ListEntry; - PVOID Address; - ULONG ContentionCount; - ULONG Number; -} RESOURCE_HASH_ENTRY, *PRESOURCE_HASH_ENTRY; - -typedef struct _RESOURCE_PERFORMANCE_DATA { - ULONG ActiveResourceCount; - ULONG TotalResourceCount; - ULONG ExclusiveAcquire; - ULONG SharedFirstLevel; - ULONG SharedSecondLevel; - ULONG StarveFirstLevel; - ULONG StarveSecondLevel; - ULONG WaitForExclusive; - ULONG OwnerTableExpands; - ULONG MaximumTableExpand; - LIST_ENTRY HashTable[RESOURCE_HASH_TABLE_SIZE]; -} RESOURCE_PERFORMANCE_DATA, *PRESOURCE_PERFORMANCE_DATA; - -/* Global debug flag */ -#if DEVL -extern ULONG NtGlobalFlag; -#define IF_NTOS_DEBUG(FlagName) if (NtGlobalFlag & (FLG_##FlagName)) -#else -#define IF_NTOS_DEBUG(FlagName) if(FALSE) -#endif - /****************************************************************************** * Security Manager Types * @@ -1998,10 +1508,10 @@ typedef PVOID PSID; #define GENERIC_ALL 0x10000000L typedef struct _GENERIC_MAPPING { - ACCESS_MASK GenericRead; - ACCESS_MASK GenericWrite; - ACCESS_MASK GenericExecute; - ACCESS_MASK GenericAll; + ACCESS_MASK GenericRead; + ACCESS_MASK GenericWrite; + ACCESS_MASK GenericExecute; + ACCESS_MASK GenericAll; } GENERIC_MAPPING, *PGENERIC_MAPPING; #define ACL_REVISION 2 @@ -2015,11 +1525,11 @@ typedef struct _GENERIC_MAPPING { #define MAX_ACL_REVISION ACL_REVISION4 typedef struct _ACL { - UCHAR AclRevision; - UCHAR Sbz1; - USHORT AclSize; - USHORT AceCount; - USHORT Sbz2; + UCHAR AclRevision; + UCHAR Sbz1; + USHORT AclSize; + USHORT AceCount; + USHORT Sbz2; } ACL, *PACL; /* Current security descriptor revision value */ @@ -2039,8 +1549,8 @@ typedef struct _ACL { #include typedef struct _LUID_AND_ATTRIBUTES { - LUID Luid; - ULONG Attributes; + LUID Luid; + ULONG Attributes; } LUID_AND_ATTRIBUTES, *PLUID_AND_ATTRIBUTES; #include @@ -2051,16 +1561,16 @@ typedef LUID_AND_ATTRIBUTES_ARRAY *PLUID_AND_ATTRIBUTES_ARRAY; #define PRIVILEGE_SET_ALL_NECESSARY (1) typedef struct _PRIVILEGE_SET { - ULONG PrivilegeCount; - ULONG Control; - LUID_AND_ATTRIBUTES Privilege[ANYSIZE_ARRAY]; + ULONG PrivilegeCount; + ULONG Control; + LUID_AND_ATTRIBUTES Privilege[ANYSIZE_ARRAY]; } PRIVILEGE_SET,*PPRIVILEGE_SET; typedef enum _SECURITY_IMPERSONATION_LEVEL { - SecurityAnonymous, - SecurityIdentification, - SecurityImpersonation, - SecurityDelegation + SecurityAnonymous, + SecurityIdentification, + SecurityImpersonation, + SecurityDelegation } SECURITY_IMPERSONATION_LEVEL, * PSECURITY_IMPERSONATION_LEVEL; #define SECURITY_MAX_IMPERSONATION_LEVEL SecurityDelegation @@ -2074,17 +1584,17 @@ typedef enum _SECURITY_IMPERSONATION_LEVEL { typedef BOOLEAN SECURITY_CONTEXT_TRACKING_MODE, *PSECURITY_CONTEXT_TRACKING_MODE; typedef struct _SECURITY_QUALITY_OF_SERVICE { - ULONG Length; - SECURITY_IMPERSONATION_LEVEL ImpersonationLevel; - SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode; - BOOLEAN EffectiveOnly; + ULONG Length; + SECURITY_IMPERSONATION_LEVEL ImpersonationLevel; + SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode; + BOOLEAN EffectiveOnly; } SECURITY_QUALITY_OF_SERVICE, *PSECURITY_QUALITY_OF_SERVICE; typedef struct _SE_IMPERSONATION_STATE { - PACCESS_TOKEN Token; - BOOLEAN CopyOnOpen; - BOOLEAN EffectiveOnly; - SECURITY_IMPERSONATION_LEVEL Level; + PACCESS_TOKEN Token; + BOOLEAN CopyOnOpen; + BOOLEAN EffectiveOnly; + SECURITY_IMPERSONATION_LEVEL Level; } SE_IMPERSONATION_STATE, *PSE_IMPERSONATION_STATE; #define OWNER_SECURITY_INFORMATION (0x00000001L) @@ -2108,9 +1618,9 @@ typedef enum _SECURITY_OPERATION_CODE { #define INITIAL_PRIVILEGE_COUNT 3 typedef struct _INITIAL_PRIVILEGE_SET { - ULONG PrivilegeCount; - ULONG Control; - LUID_AND_ATTRIBUTES Privilege[INITIAL_PRIVILEGE_COUNT]; + ULONG PrivilegeCount; + ULONG Control; + LUID_AND_ATTRIBUTES Privilege[INITIAL_PRIVILEGE_COUNT]; } INITIAL_PRIVILEGE_SET, * PINITIAL_PRIVILEGE_SET; #define SE_MIN_WELL_KNOWN_PRIVILEGE 2 @@ -2151,38 +1661,35 @@ typedef struct _INITIAL_PRIVILEGE_SET { #define SE_MAX_WELL_KNOWN_PRIVILEGE SE_CREATE_SYMBOLIC_LINK_PRIVILEGE typedef struct _SECURITY_SUBJECT_CONTEXT { - PACCESS_TOKEN ClientToken; - SECURITY_IMPERSONATION_LEVEL ImpersonationLevel; - PACCESS_TOKEN PrimaryToken; - PVOID ProcessAuditId; + PACCESS_TOKEN ClientToken; + SECURITY_IMPERSONATION_LEVEL ImpersonationLevel; + PACCESS_TOKEN PrimaryToken; + PVOID ProcessAuditId; } SECURITY_SUBJECT_CONTEXT, *PSECURITY_SUBJECT_CONTEXT; typedef struct _ACCESS_STATE { - LUID OperationID; - BOOLEAN SecurityEvaluated; - BOOLEAN GenerateAudit; - BOOLEAN GenerateOnClose; - BOOLEAN PrivilegesAllocated; - ULONG Flags; - ACCESS_MASK RemainingDesiredAccess; - ACCESS_MASK PreviouslyGrantedAccess; - ACCESS_MASK OriginalDesiredAccess; - SECURITY_SUBJECT_CONTEXT SubjectSecurityContext; - PSECURITY_DESCRIPTOR SecurityDescriptor; - PVOID AuxData; + LUID OperationID; + BOOLEAN SecurityEvaluated; + BOOLEAN GenerateAudit; + BOOLEAN GenerateOnClose; + BOOLEAN PrivilegesAllocated; + ULONG Flags; + ACCESS_MASK RemainingDesiredAccess; + ACCESS_MASK PreviouslyGrantedAccess; + ACCESS_MASK OriginalDesiredAccess; + SECURITY_SUBJECT_CONTEXT SubjectSecurityContext; + PSECURITY_DESCRIPTOR SecurityDescriptor; + PVOID AuxData; union { - INITIAL_PRIVILEGE_SET InitialPrivilegeSet; - PRIVILEGE_SET PrivilegeSet; + INITIAL_PRIVILEGE_SET InitialPrivilegeSet; + PRIVILEGE_SET PrivilegeSet; } Privileges; - BOOLEAN AuditPrivileges; - UNICODE_STRING ObjectName; - UNICODE_STRING ObjectTypeName; + + BOOLEAN AuditPrivileges; + UNICODE_STRING ObjectName; + UNICODE_STRING ObjectTypeName; } ACCESS_STATE, *PACCESS_STATE; -typedef VOID -(NTAPI *PNTFS_DEREF_EXPORTED_SECURITY_DESCRIPTOR)( - IN PVOID Vcb, - IN PSECURITY_DESCRIPTOR SecurityDescriptor); #ifndef _NTLSA_IFS_ @@ -2253,8 +1760,8 @@ typedef struct _SE_ADT_PARAMETER_ARRAY_ENTRY { typedef struct _SE_ADT_ACCESS_REASON { ACCESS_MASK AccessMask; - ULONG AccessReasons[32]; - ULONG ObjectTypeIndex; + ULONG AccessReasons[32]; + ULONG ObjectTypeIndex; ULONG AccessGranted; PSECURITY_DESCRIPTOR SecurityDescriptor; } SE_ADT_ACCESS_REASON, *PSE_ADT_ACCESS_REASON; @@ -2273,6 +1780,7 @@ typedef struct _SE_ADT_PARAMETER_ARRAY { #endif /* !_NTLSA_AUDIT_ */ #endif /* !_NTLSA_IFS_ */ + /****************************************************************************** * Power Management Support Types * ******************************************************************************/ @@ -2280,112 +1788,99 @@ typedef struct _SE_ADT_PARAMETER_ARRAY { #ifndef _PO_DDK_ #define _PO_DDK_ -#define PO_CB_SYSTEM_POWER_POLICY 0 -#define PO_CB_AC_STATUS 1 -#define PO_CB_BUTTON_COLLISION 2 -#define PO_CB_SYSTEM_STATE_LOCK 3 -#define PO_CB_LID_SWITCH_STATE 4 -#define PO_CB_PROCESSOR_POWER_POLICY 5 - /* Power States/Levels */ typedef enum _SYSTEM_POWER_STATE { - PowerSystemUnspecified = 0, - PowerSystemWorking, - PowerSystemSleeping1, - PowerSystemSleeping2, - PowerSystemSleeping3, - PowerSystemHibernate, - PowerSystemShutdown, - PowerSystemMaximum + PowerSystemUnspecified, + PowerSystemWorking, + PowerSystemSleeping1, + PowerSystemSleeping2, + PowerSystemSleeping3, + PowerSystemHibernate, + PowerSystemShutdown, + PowerSystemMaximum } SYSTEM_POWER_STATE, *PSYSTEM_POWER_STATE; #define POWER_SYSTEM_MAXIMUM PowerSystemMaximum typedef enum _POWER_INFORMATION_LEVEL { - SystemPowerPolicyAc, - SystemPowerPolicyDc, - VerifySystemPolicyAc, - VerifySystemPolicyDc, - SystemPowerCapabilities, - SystemBatteryState, - SystemPowerStateHandler, - ProcessorStateHandler, - SystemPowerPolicyCurrent, - AdministratorPowerPolicy, - SystemReserveHiberFile, - ProcessorInformation, - SystemPowerInformation, - ProcessorStateHandler2, - LastWakeTime, - LastSleepTime, - SystemExecutionState, - SystemPowerStateNotifyHandler, - ProcessorPowerPolicyAc, - ProcessorPowerPolicyDc, - VerifyProcessorPowerPolicyAc, - VerifyProcessorPowerPolicyDc, - ProcessorPowerPolicyCurrent, - SystemPowerStateLogging, - SystemPowerLoggingEntry, - SetPowerSettingValue, - NotifyUserPowerSetting, - PowerInformationLevelUnused0, - PowerInformationLevelUnused1, - SystemVideoState, - TraceApplicationPowerMessage, - TraceApplicationPowerMessageEnd, - ProcessorPerfStates, - ProcessorIdleStates, - ProcessorCap, - SystemWakeSource, - SystemHiberFileInformation, - TraceServicePowerMessage, - ProcessorLoad, - PowerShutdownNotification, - MonitorCapabilities, - SessionPowerInit, - SessionDisplayState, - PowerRequestCreate, - PowerRequestAction, - GetPowerRequestList, - ProcessorInformationEx, - NotifyUserModeLegacyPowerEvent, - GroupPark, - ProcessorIdleDomains, - WakeTimerList, - SystemHiberFileSize, - PowerInformationLevelMaximum + SystemPowerPolicyAc, + SystemPowerPolicyDc, + VerifySystemPolicyAc, + VerifySystemPolicyDc, + SystemPowerCapabilities, + SystemBatteryState, + SystemPowerStateHandler, + ProcessorStateHandler, + SystemPowerPolicyCurrent, + AdministratorPowerPolicy, + SystemReserveHiberFile, + ProcessorInformation, + SystemPowerInformation, + ProcessorStateHandler2, + LastWakeTime, + LastSleepTime, + SystemExecutionState, + SystemPowerStateNotifyHandler, + ProcessorPowerPolicyAc, + ProcessorPowerPolicyDc, + VerifyProcessorPowerPolicyAc, + VerifyProcessorPowerPolicyDc, + ProcessorPowerPolicyCurrent, + SystemPowerStateLogging, + SystemPowerLoggingEntry, + SetPowerSettingValue, + NotifyUserPowerSetting, + PowerInformationLevelUnused0, + PowerInformationLevelUnused1, + SystemVideoState, + TraceApplicationPowerMessage, + TraceApplicationPowerMessageEnd, + ProcessorPerfStates, + ProcessorIdleStates, + ProcessorCap, + SystemWakeSource, + SystemHiberFileInformation, + TraceServicePowerMessage, + ProcessorLoad, + PowerShutdownNotification, + MonitorCapabilities, + SessionPowerInit, + SessionDisplayState, + PowerRequestCreate, + PowerRequestAction, + GetPowerRequestList, + ProcessorInformationEx, + NotifyUserModeLegacyPowerEvent, + GroupPark, + ProcessorIdleDomains, + WakeTimerList, + SystemHiberFileSize, + PowerInformationLevelMaximum } POWER_INFORMATION_LEVEL; typedef enum { - PowerActionNone = 0, - PowerActionReserved, - PowerActionSleep, - PowerActionHibernate, - PowerActionShutdown, - PowerActionShutdownReset, - PowerActionShutdownOff, - PowerActionWarmEject + PowerActionNone, + PowerActionReserved, + PowerActionSleep, + PowerActionHibernate, + PowerActionShutdown, + PowerActionShutdownReset, + PowerActionShutdownOff, + PowerActionWarmEject } POWER_ACTION, *PPOWER_ACTION; typedef enum _DEVICE_POWER_STATE { - PowerDeviceUnspecified = 0, - PowerDeviceD0, - PowerDeviceD1, - PowerDeviceD2, - PowerDeviceD3, - PowerDeviceMaximum + PowerDeviceUnspecified, + PowerDeviceD0, + PowerDeviceD1, + PowerDeviceD2, + PowerDeviceD3, + PowerDeviceMaximum } DEVICE_POWER_STATE, *PDEVICE_POWER_STATE; -typedef enum _MONITOR_DISPLAY_STATE { - PowerMonitorOff = 0, - PowerMonitorOn, - PowerMonitorDim -} MONITOR_DISPLAY_STATE, *PMONITOR_DISPLAY_STATE; - typedef union _POWER_STATE { - SYSTEM_POWER_STATE SystemState; - DEVICE_POWER_STATE DeviceState; + SYSTEM_POWER_STATE SystemState; + DEVICE_POWER_STATE DeviceState; } POWER_STATE, *PPOWER_STATE; typedef enum _POWER_STATE_TYPE { @@ -2393,297 +1888,39 @@ typedef enum _POWER_STATE_TYPE { DevicePowerState } POWER_STATE_TYPE, *PPOWER_STATE_TYPE; -#if (NTDDI_VERSION >= NTDDI_VISTA) -typedef struct _SYSTEM_POWER_STATE_CONTEXT { - union { - struct { - ULONG Reserved1:8; - ULONG TargetSystemState:4; - ULONG EffectiveSystemState:4; - ULONG CurrentSystemState:4; - ULONG IgnoreHibernationPath:1; - ULONG PseudoTransition:1; - ULONG Reserved2:10; - } DUMMYSTRUCTNAME; - ULONG ContextAsUlong; - } DUMMYUNIONNAME; -} SYSTEM_POWER_STATE_CONTEXT, *PSYSTEM_POWER_STATE_CONTEXT; -#endif - -#if (NTDDI_VERSION >= NTDDI_WIN7) -typedef struct _COUNTED_REASON_CONTEXT { - ULONG Version; - ULONG Flags; - union { - struct { - UNICODE_STRING ResourceFileName; - USHORT ResourceReasonId; - ULONG StringCount; - PUNICODE_STRING ReasonStrings; - } DUMMYSTRUCTNAME; - UNICODE_STRING SimpleString; - } DUMMYUNIONNAME; -} COUNTED_REASON_CONTEXT, *PCOUNTED_REASON_CONTEXT; -#endif - -#define IOCTL_QUERY_DEVICE_POWER_STATE \ - CTL_CODE(FILE_DEVICE_BATTERY, 0x0, METHOD_BUFFERED, FILE_READ_ACCESS) - -#define IOCTL_SET_DEVICE_WAKE \ - CTL_CODE(FILE_DEVICE_BATTERY, 0x1, METHOD_BUFFERED, FILE_WRITE_ACCESS) - -#define IOCTL_CANCEL_DEVICE_WAKE \ - CTL_CODE(FILE_DEVICE_BATTERY, 0x2, METHOD_BUFFERED, FILE_WRITE_ACCESS) - -#define ES_SYSTEM_REQUIRED 0x00000001 -#define ES_DISPLAY_REQUIRED 0x00000002 -#define ES_USER_PRESENT 0x00000004 -#define ES_CONTINUOUS 0x80000000 - -typedef ULONG EXECUTION_STATE, *PEXECUTION_STATE; - -typedef enum { - LT_DONT_CARE, - LT_LOWEST_LATENCY -} LATENCY_TIME; - -#if (_WIN32_WINNT >= _WIN32_WINNT_WIN7) -#define DIAGNOSTIC_REASON_VERSION 0 -#define DIAGNOSTIC_REASON_SIMPLE_STRING 0x00000001 -#define DIAGNOSTIC_REASON_DETAILED_STRING 0x00000002 -#define DIAGNOSTIC_REASON_NOT_SPECIFIED 0x80000000 -#define DIAGNOSTIC_REASON_INVALID_FLAGS (~0x80000003) -#endif - -#define POWER_REQUEST_CONTEXT_VERSION 0 -#define POWER_REQUEST_CONTEXT_SIMPLE_STRING 0x00000001 -#define POWER_REQUEST_CONTEXT_DETAILED_STRING 0x00000002 - -#define PowerRequestMaximum 3 - -typedef enum _POWER_REQUEST_TYPE { - PowerRequestDisplayRequired, - PowerRequestSystemRequired, - PowerRequestAwayModeRequired -} POWER_REQUEST_TYPE, *PPOWER_REQUEST_TYPE; - -#if (NTDDI_VERSION >= NTDDI_WINXP) - -#define PDCAP_D0_SUPPORTED 0x00000001 -#define PDCAP_D1_SUPPORTED 0x00000002 -#define PDCAP_D2_SUPPORTED 0x00000004 -#define PDCAP_D3_SUPPORTED 0x00000008 -#define PDCAP_WAKE_FROM_D0_SUPPORTED 0x00000010 -#define PDCAP_WAKE_FROM_D1_SUPPORTED 0x00000020 -#define PDCAP_WAKE_FROM_D2_SUPPORTED 0x00000040 -#define PDCAP_WAKE_FROM_D3_SUPPORTED 0x00000080 -#define PDCAP_WARM_EJECT_SUPPORTED 0x00000100 - -typedef struct CM_Power_Data_s { - ULONG PD_Size; - DEVICE_POWER_STATE PD_MostRecentPowerState; - ULONG PD_Capabilities; - ULONG PD_D1Latency; - ULONG PD_D2Latency; - ULONG PD_D3Latency; - DEVICE_POWER_STATE PD_PowerStateMapping[PowerSystemMaximum]; - SYSTEM_POWER_STATE PD_DeepestSystemWake; -} CM_POWER_DATA, *PCM_POWER_DATA; - -#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ - -typedef enum _SYSTEM_POWER_CONDITION { - PoAc, - PoDc, - PoHot, - PoConditionMaximum -} SYSTEM_POWER_CONDITION; - -typedef struct _SET_POWER_SETTING_VALUE { - ULONG Version; - GUID Guid; - SYSTEM_POWER_CONDITION PowerCondition; - ULONG DataLength; - UCHAR Data[ANYSIZE_ARRAY]; -} SET_POWER_SETTING_VALUE, *PSET_POWER_SETTING_VALUE; - -#define POWER_SETTING_VALUE_VERSION (0x1) - -typedef struct _NOTIFY_USER_POWER_SETTING { - GUID Guid; -} NOTIFY_USER_POWER_SETTING, *PNOTIFY_USER_POWER_SETTING; - -typedef struct _APPLICATIONLAUNCH_SETTING_VALUE { - LARGE_INTEGER ActivationTime; - ULONG Flags; - ULONG ButtonInstanceID; -} APPLICATIONLAUNCH_SETTING_VALUE, *PAPPLICATIONLAUNCH_SETTING_VALUE; - -typedef enum _POWER_PLATFORM_ROLE { - PlatformRoleUnspecified = 0, - PlatformRoleDesktop, - PlatformRoleMobile, - PlatformRoleWorkstation, - PlatformRoleEnterpriseServer, - PlatformRoleSOHOServer, - PlatformRoleAppliancePC, - PlatformRolePerformanceServer, - PlatformRoleMaximum -} POWER_PLATFORM_ROLE; - #if (NTDDI_VERSION >= NTDDI_WINXP) || !defined(_BATCLASS_) typedef struct { - ULONG Granularity; - ULONG Capacity; + ULONG Granularity; + ULONG Capacity; } BATTERY_REPORTING_SCALE, *PBATTERY_REPORTING_SCALE; #endif /* (NTDDI_VERSION >= NTDDI_WINXP) || !defined(_BATCLASS_) */ #endif /* !_PO_DDK_ */ -#define CORE_PARKING_POLICY_CHANGE_IDEAL 0 -#define CORE_PARKING_POLICY_CHANGE_SINGLE 1 -#define CORE_PARKING_POLICY_CHANGE_ROCKET 2 -#define CORE_PARKING_POLICY_CHANGE_MAX CORE_PARKING_POLICY_CHANGE_ROCKET - -DEFINE_GUID(GUID_MAX_POWER_SAVINGS, 0xA1841308, 0x3541, 0x4FAB, 0xBC, 0x81, 0xF7, 0x15, 0x56, 0xF2, 0x0B, 0x4A ); -DEFINE_GUID(GUID_MIN_POWER_SAVINGS, 0x8C5E7FDA, 0xE8BF, 0x4A96, 0x9A, 0x85, 0xA6, 0xE2, 0x3A, 0x8C, 0x63, 0x5C ); -DEFINE_GUID(GUID_TYPICAL_POWER_SAVINGS, 0x381B4222, 0xF694, 0x41F0, 0x96, 0x85, 0xFF, 0x5B, 0xB2, 0x60, 0xDF, 0x2E ); -DEFINE_GUID(NO_SUBGROUP_GUID, 0xFEA3413E, 0x7E05, 0x4911, 0x9A, 0x71, 0x70, 0x03, 0x31, 0xF1, 0xC2, 0x94 ); -DEFINE_GUID(ALL_POWERSCHEMES_GUID, 0x68A1E95E, 0x13EA, 0x41E1, 0x80, 0x11, 0x0C, 0x49, 0x6C, 0xA4, 0x90, 0xB0 ); -DEFINE_GUID(GUID_POWERSCHEME_PERSONALITY, 0x245D8541, 0x3943, 0x4422, 0xB0, 0x25, 0x13, 0xA7, 0x84, 0xF6, 0x79, 0xB7 ); -DEFINE_GUID(GUID_ACTIVE_POWERSCHEME, 0x31F9F286, 0x5084, 0x42FE, 0xB7, 0x20, 0x2B, 0x02, 0x64, 0x99, 0x37, 0x63 ); -DEFINE_GUID(GUID_VIDEO_SUBGROUP, 0x7516B95F, 0xF776, 0x4464, 0x8C, 0x53, 0x06, 0x16, 0x7F, 0x40, 0xCC, 0x99 ); -DEFINE_GUID(GUID_VIDEO_POWERDOWN_TIMEOUT, 0x3C0BC021, 0xC8A8, 0x4E07, 0xA9, 0x73, 0x6B, 0x14, 0xCB, 0xCB, 0x2B, 0x7E ); -DEFINE_GUID(GUID_VIDEO_ANNOYANCE_TIMEOUT, 0x82DBCF2D, 0xCD67, 0x40C5, 0xBF, 0xDC, 0x9F, 0x1A, 0x5C, 0xCD, 0x46, 0x63 ); -DEFINE_GUID(GUID_VIDEO_ADAPTIVE_PERCENT_INCREASE, 0xEED904DF, 0xB142, 0x4183, 0xB1, 0x0B, 0x5A, 0x11, 0x97, 0xA3, 0x78, 0x64 ); -DEFINE_GUID(GUID_VIDEO_DIM_TIMEOUT, 0x17aaa29b, 0x8b43, 0x4b94, 0xaa, 0xfe, 0x35, 0xf6, 0x4d, 0xaa, 0xf1, 0xee); -DEFINE_GUID(GUID_VIDEO_ADAPTIVE_POWERDOWN, 0x90959D22, 0xD6A1, 0x49B9, 0xAF, 0x93, 0xBC, 0xE8, 0x85, 0xAD, 0x33, 0x5B ); -DEFINE_GUID(GUID_MONITOR_POWER_ON, 0x02731015, 0x4510, 0x4526, 0x99, 0xE6, 0xE5, 0xA1, 0x7E, 0xBD, 0x1A, 0xEA ); -DEFINE_GUID(GUID_DEVICE_POWER_POLICY_VIDEO_BRIGHTNESS, 0xaded5e82L, 0xb909, 0x4619, 0x99, 0x49, 0xf5, 0xd7, 0x1d, 0xac, 0x0b, 0xcb); -DEFINE_GUID(GUID_DEVICE_POWER_POLICY_VIDEO_DIM_BRIGHTNESS, 0xf1fbfde2, 0xa960, 0x4165, 0x9f, 0x88, 0x50, 0x66, 0x79, 0x11, 0xce, 0x96); -DEFINE_GUID(GUID_VIDEO_CURRENT_MONITOR_BRIGHTNESS, 0x8ffee2c6, 0x2d01, 0x46be, 0xad, 0xb9, 0x39, 0x8a, 0xdd, 0xc5, 0xb4, 0xff); -DEFINE_GUID(GUID_VIDEO_ADAPTIVE_DISPLAY_BRIGHTNESS, 0xFBD9AA66, 0x9553, 0x4097, 0xBA, 0x44, 0xED, 0x6E, 0x9D, 0x65, 0xEA, 0xB8); -DEFINE_GUID(GUID_SESSION_DISPLAY_STATE, 0x73A5E93A, 0x5BB1, 0x4F93, 0x89, 0x5B, 0xDB, 0xD0, 0xDA, 0x85, 0x59, 0x67 ); -DEFINE_GUID(GUID_CONSOLE_DISPLAY_STATE, 0x6fe69556, 0x704a, 0x47a0, 0x8f, 0x24, 0xc2, 0x8d, 0x93, 0x6f, 0xda, 0x47); -DEFINE_GUID(GUID_ALLOW_DISPLAY_REQUIRED, 0xA9CEB8DA, 0xCD46, 0x44FB, 0xA9, 0x8B, 0x02, 0xAF, 0x69, 0xDE, 0x46, 0x23 ); -DEFINE_GUID(GUID_DISK_SUBGROUP, 0x0012EE47, 0x9041, 0x4B5D, 0x9B, 0x77, 0x53, 0x5F, 0xBA, 0x8B, 0x14, 0x42 ); -DEFINE_GUID(GUID_DISK_POWERDOWN_TIMEOUT, 0x6738E2C4, 0xE8A5, 0x4A42, 0xB1, 0x6A, 0xE0, 0x40, 0xE7, 0x69, 0x75, 0x6E ); -DEFINE_GUID(GUID_DISK_BURST_IGNORE_THRESHOLD, 0x80e3c60e, 0xbb94, 0x4ad8, 0xbb, 0xe0, 0x0d, 0x31, 0x95, 0xef, 0xc6, 0x63 ); -DEFINE_GUID(GUID_DISK_ADAPTIVE_POWERDOWN, 0x396A32E1, 0x499A, 0x40B2, 0x91, 0x24, 0xA9, 0x6A, 0xFE, 0x70, 0x76, 0x67 ); -DEFINE_GUID(GUID_SLEEP_SUBGROUP, 0x238C9FA8, 0x0AAD, 0x41ED, 0x83, 0xF4, 0x97, 0xBE, 0x24, 0x2C, 0x8F, 0x20 ); -DEFINE_GUID(GUID_SLEEP_IDLE_THRESHOLD, 0x81cd32e0, 0x7833, 0x44f3, 0x87, 0x37, 0x70, 0x81, 0xf3, 0x8d, 0x1f, 0x70 ); -DEFINE_GUID(GUID_STANDBY_TIMEOUT, 0x29F6C1DB, 0x86DA, 0x48C5, 0x9F, 0xDB, 0xF2, 0xB6, 0x7B, 0x1F, 0x44, 0xDA ); -DEFINE_GUID(GUID_UNATTEND_SLEEP_TIMEOUT, 0x7bc4a2f9, 0xd8fc, 0x4469, 0xb0, 0x7b, 0x33, 0xeb, 0x78, 0x5a, 0xac, 0xa0 ); -DEFINE_GUID(GUID_HIBERNATE_TIMEOUT, 0x9D7815A6, 0x7EE4, 0x497E, 0x88, 0x88, 0x51, 0x5A, 0x05, 0xF0, 0x23, 0x64 ); -DEFINE_GUID(GUID_HIBERNATE_FASTS4_POLICY, 0x94AC6D29, 0x73CE, 0x41A6, 0x80, 0x9F, 0x63, 0x63, 0xBA, 0x21, 0xB4, 0x7E ); -DEFINE_GUID(GUID_CRITICAL_POWER_TRANSITION, 0xB7A27025, 0xE569, 0x46c2, 0xA5, 0x04, 0x2B, 0x96, 0xCA, 0xD2, 0x25, 0xA1); -DEFINE_GUID(GUID_SYSTEM_AWAYMODE, 0x98A7F580, 0x01F7, 0x48AA, 0x9C, 0x0F, 0x44, 0x35, 0x2C, 0x29, 0xE5, 0xC0 ); -DEFINE_GUID(GUID_ALLOW_AWAYMODE, 0x25dfa149, 0x5dd1, 0x4736, 0xb5, 0xab, 0xe8, 0xa3, 0x7b, 0x5b, 0x81, 0x87 ); -DEFINE_GUID(GUID_ALLOW_STANDBY_STATES, 0xabfc2519, 0x3608, 0x4c2a, 0x94, 0xea, 0x17, 0x1b, 0x0e, 0xd5, 0x46, 0xab ); -DEFINE_GUID(GUID_ALLOW_RTC_WAKE, 0xBD3B718A, 0x0680, 0x4D9D, 0x8A, 0xB2, 0xE1, 0xD2, 0xB4, 0xAC, 0x80, 0x6D ); -DEFINE_GUID(GUID_ALLOW_SYSTEM_REQUIRED, 0xA4B195F5, 0x8225, 0x47D8, 0x80, 0x12, 0x9D, 0x41, 0x36, 0x97, 0x86, 0xE2 ); -DEFINE_GUID(GUID_SYSTEM_BUTTON_SUBGROUP, 0x4F971E89, 0xEEBD, 0x4455, 0xA8, 0xDE, 0x9E, 0x59, 0x04, 0x0E, 0x73, 0x47 ); -DEFINE_GUID(GUID_POWERBUTTON_ACTION, 0x7648EFA3, 0xDD9C, 0x4E3E, 0xB5, 0x66, 0x50, 0xF9, 0x29, 0x38, 0x62, 0x80 ); -DEFINE_GUID(GUID_POWERBUTTON_ACTION_FLAGS, 0x857E7FAC, 0x034B, 0x4704, 0xAB, 0xB1, 0xBC, 0xA5, 0x4A, 0xA3, 0x14, 0x78 ); -DEFINE_GUID(GUID_SLEEPBUTTON_ACTION, 0x96996BC0, 0xAD50, 0x47EC, 0x92, 0x3B, 0x6F, 0x41, 0x87, 0x4D, 0xD9, 0xEB ); -DEFINE_GUID(GUID_SLEEPBUTTON_ACTION_FLAGS, 0x2A160AB1, 0xB69D, 0x4743, 0xB7, 0x18, 0xBF, 0x14, 0x41, 0xD5, 0xE4, 0x93 ); -DEFINE_GUID(GUID_USERINTERFACEBUTTON_ACTION, 0xA7066653, 0x8D6C, 0x40A8, 0x91, 0x0E, 0xA1, 0xF5, 0x4B, 0x84, 0xC7, 0xE5 ); -DEFINE_GUID(GUID_LIDCLOSE_ACTION, 0x5CA83367, 0x6E45, 0x459F, 0xA2, 0x7B, 0x47, 0x6B, 0x1D, 0x01, 0xC9, 0x36 ); -DEFINE_GUID(GUID_LIDCLOSE_ACTION_FLAGS, 0x97E969AC, 0x0D6C, 0x4D08, 0x92, 0x7C, 0xD7, 0xBD, 0x7A, 0xD7, 0x85, 0x7B ); -DEFINE_GUID(GUID_LIDOPEN_POWERSTATE, 0x99FF10E7, 0x23B1, 0x4C07, 0xA9, 0xD1, 0x5C, 0x32, 0x06, 0xD7, 0x41, 0xB4 ); -DEFINE_GUID(GUID_BATTERY_SUBGROUP, 0xE73A048D, 0xBF27, 0x4F12, 0x97, 0x31, 0x8B, 0x20, 0x76, 0xE8, 0x89, 0x1F ); -DEFINE_GUID(GUID_BATTERY_DISCHARGE_ACTION_0, 0x637EA02F, 0xBBCB, 0x4015, 0x8E, 0x2C, 0xA1, 0xC7, 0xB9, 0xC0, 0xB5, 0x46 ); -DEFINE_GUID(GUID_BATTERY_DISCHARGE_LEVEL_0, 0x9A66D8D7, 0x4FF7, 0x4EF9, 0xB5, 0xA2, 0x5A, 0x32, 0x6C, 0xA2, 0xA4, 0x69 ); -DEFINE_GUID(GUID_BATTERY_DISCHARGE_FLAGS_0, 0x5dbb7c9f, 0x38e9, 0x40d2, 0x97, 0x49, 0x4f, 0x8a, 0x0e, 0x9f, 0x64, 0x0f ); -DEFINE_GUID(GUID_BATTERY_DISCHARGE_ACTION_1, 0xD8742DCB, 0x3E6A, 0x4B3C, 0xB3, 0xFE, 0x37, 0x46, 0x23, 0xCD, 0xCF, 0x06 ); -DEFINE_GUID(GUID_BATTERY_DISCHARGE_LEVEL_1, 0x8183BA9A, 0xE910, 0x48DA, 0x87, 0x69, 0x14, 0xAE, 0x6D, 0xC1, 0x17, 0x0A ); -DEFINE_GUID(GUID_BATTERY_DISCHARGE_FLAGS_1, 0xbcded951, 0x187b, 0x4d05, 0xbc, 0xcc, 0xf7, 0xe5, 0x19, 0x60, 0xc2, 0x58 ); -DEFINE_GUID(GUID_BATTERY_DISCHARGE_ACTION_2, 0x421CBA38, 0x1A8E, 0x4881, 0xAC, 0x89, 0xE3, 0x3A, 0x8B, 0x04, 0xEC, 0xE4 ); -DEFINE_GUID(GUID_BATTERY_DISCHARGE_LEVEL_2, 0x07A07CA2, 0xADAF, 0x40D7, 0xB0, 0x77, 0x53, 0x3A, 0xAD, 0xED, 0x1B, 0xFA ); -DEFINE_GUID(GUID_BATTERY_DISCHARGE_FLAGS_2, 0x7fd2f0c4, 0xfeb7, 0x4da3, 0x81, 0x17, 0xe3, 0xfb, 0xed, 0xc4, 0x65, 0x82 ); -DEFINE_GUID(GUID_BATTERY_DISCHARGE_ACTION_3, 0x80472613, 0x9780, 0x455E, 0xB3, 0x08, 0x72, 0xD3, 0x00, 0x3C, 0xF2, 0xF8 ); -DEFINE_GUID(GUID_BATTERY_DISCHARGE_LEVEL_3, 0x58AFD5A6, 0xC2DD, 0x47D2, 0x9F, 0xBF, 0xEF, 0x70, 0xCC, 0x5C, 0x59, 0x65 ); -DEFINE_GUID(GUID_BATTERY_DISCHARGE_FLAGS_3, 0x73613ccf, 0xdbfa, 0x4279, 0x83, 0x56, 0x49, 0x35, 0xf6, 0xbf, 0x62, 0xf3 ); -DEFINE_GUID(GUID_PROCESSOR_SETTINGS_SUBGROUP, 0x54533251, 0x82BE, 0x4824, 0x96, 0xC1, 0x47, 0xB6, 0x0B, 0x74, 0x0D, 0x00 ); -DEFINE_GUID(GUID_PROCESSOR_THROTTLE_POLICY, 0x57027304, 0x4AF6, 0x4104, 0x92, 0x60, 0xE3, 0xD9, 0x52, 0x48, 0xFC, 0x36 ); -DEFINE_GUID(GUID_PROCESSOR_THROTTLE_MAXIMUM, 0xBC5038F7, 0x23E0, 0x4960, 0x96, 0xDA, 0x33, 0xAB, 0xAF, 0x59, 0x35, 0xEC ); -DEFINE_GUID(GUID_PROCESSOR_THROTTLE_MINIMUM, 0x893DEE8E, 0x2BEF, 0x41E0, 0x89, 0xC6, 0xB5, 0x5D, 0x09, 0x29, 0x96, 0x4C ); -DEFINE_GUID(GUID_PROCESSOR_ALLOW_THROTTLING, 0x3b04d4fd, 0x1cc7, 0x4f23, 0xab, 0x1c, 0xd1, 0x33, 0x78, 0x19, 0xc4, 0xbb ); -DEFINE_GUID(GUID_PROCESSOR_IDLESTATE_POLICY, 0x68f262a7, 0xf621, 0x4069, 0xb9, 0xa5, 0x48, 0x74, 0x16, 0x9b, 0xe2, 0x3c); -DEFINE_GUID(GUID_PROCESSOR_PERFSTATE_POLICY, 0xBBDC3814, 0x18E9, 0x4463, 0x8A, 0x55, 0xD1, 0x97, 0x32, 0x7C, 0x45, 0xC0); -DEFINE_GUID(GUID_PROCESSOR_PERF_INCREASE_THRESHOLD, 0x06cadf0e, 0x64ed, 0x448a, 0x89, 0x27, 0xce, 0x7b, 0xf9, 0x0e, 0xb3, 0x5d ); -DEFINE_GUID(GUID_PROCESSOR_PERF_DECREASE_THRESHOLD, 0x12a0ab44, 0xfe28, 0x4fa9, 0xb3, 0xbd, 0x4b, 0x64, 0xf4, 0x49, 0x60, 0xa6 ); -DEFINE_GUID(GUID_PROCESSOR_PERF_INCREASE_POLICY, 0x465e1f50, 0xb610, 0x473a, 0xab, 0x58, 0x0, 0xd1, 0x7, 0x7d, 0xc4, 0x18); -DEFINE_GUID(GUID_PROCESSOR_PERF_DECREASE_POLICY, 0x40fbefc7, 0x2e9d, 0x4d25, 0xa1, 0x85, 0xc, 0xfd, 0x85, 0x74, 0xba, 0xc6); -DEFINE_GUID(GUID_PROCESSOR_PERF_INCREASE_TIME, 0x984cf492, 0x3bed, 0x4488, 0xa8, 0xf9, 0x42, 0x86, 0xc9, 0x7b, 0xf5, 0xaa); -DEFINE_GUID(GUID_PROCESSOR_PERF_DECREASE_TIME, 0xd8edeb9b, 0x95cf, 0x4f95, 0xa7, 0x3c, 0xb0, 0x61, 0x97, 0x36, 0x93, 0xc8); -DEFINE_GUID(GUID_PROCESSOR_PERF_TIME_CHECK, 0x4d2b0152, 0x7d5c, 0x498b, 0x88, 0xe2, 0x34, 0x34, 0x53, 0x92, 0xa2, 0xc5); -DEFINE_GUID(GUID_PROCESSOR_PERF_BOOST_POLICY, 0x45bcc044, 0xd885, 0x43e2, 0x86, 0x5, 0xee, 0xe, 0xc6, 0xe9, 0x6b, 0x59); -DEFINE_GUID(GUID_PROCESSOR_IDLE_ALLOW_SCALING, 0x6c2993b0, 0x8f48, 0x481f, 0xbc, 0xc6, 0x0, 0xdd, 0x27, 0x42, 0xaa, 0x6); -DEFINE_GUID(GUID_PROCESSOR_IDLE_DISABLE, 0x5d76a2ca, 0xe8c0, 0x402f, 0xa1, 0x33, 0x21, 0x58, 0x49, 0x2d, 0x58, 0xad); -DEFINE_GUID(GUID_PROCESSOR_IDLE_TIME_CHECK, 0xc4581c31, 0x89ab, 0x4597, 0x8e, 0x2b, 0x9c, 0x9c, 0xab, 0x44, 0xe, 0x6b); -DEFINE_GUID(GUID_PROCESSOR_IDLE_DEMOTE_THRESHOLD, 0x4b92d758, 0x5a24, 0x4851, 0xa4, 0x70, 0x81, 0x5d, 0x78, 0xae, 0xe1, 0x19); -DEFINE_GUID(GUID_PROCESSOR_IDLE_PROMOTE_THRESHOLD, 0x7b224883, 0xb3cc, 0x4d79, 0x81, 0x9f, 0x83, 0x74, 0x15, 0x2c, 0xbe, 0x7c); -DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_INCREASE_THRESHOLD, 0xdf142941, 0x20f3, 0x4edf, 0x9a, 0x4a, 0x9c, 0x83, 0xd3, 0xd7, 0x17, 0xd1 ); -DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_DECREASE_THRESHOLD, 0x68dd2f27, 0xa4ce, 0x4e11, 0x84, 0x87, 0x37, 0x94, 0xe4, 0x13, 0x5d, 0xfa); -DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_INCREASE_POLICY, 0xc7be0679, 0x2817, 0x4d69, 0x9d, 0x02, 0x51, 0x9a, 0x53, 0x7e, 0xd0, 0xc6); -DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_DECREASE_POLICY, 0x71021b41, 0xc749, 0x4d21, 0xbe, 0x74, 0xa0, 0x0f, 0x33, 0x5d, 0x58, 0x2b); -DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_MAX_CORES, 0xea062031, 0x0e34, 0x4ff1, 0x9b, 0x6d, 0xeb, 0x10, 0x59, 0x33, 0x40, 0x28); -DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_MIN_CORES, 0x0cc5b647, 0xc1df, 0x4637, 0x89, 0x1a, 0xde, 0xc3, 0x5c, 0x31, 0x85, 0x83); -DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_INCREASE_TIME, 0x2ddd5a84, 0x5a71, 0x437e, 0x91, 0x2a, 0xdb, 0x0b, 0x8c, 0x78, 0x87, 0x32); -DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_DECREASE_TIME, 0xdfd10d17, 0xd5eb, 0x45dd, 0x87, 0x7a, 0x9a, 0x34, 0xdd, 0xd1, 0x5c, 0x82); -DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_AFFINITY_HISTORY_DECREASE_FACTOR, 0x8f7b45e3, 0xc393, 0x480a, 0x87, 0x8c, 0xf6, 0x7a, 0xc3, 0xd0, 0x70, 0x82); -DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_AFFINITY_HISTORY_THRESHOLD, 0x5b33697b, 0xe89d, 0x4d38, 0xaa, 0x46, 0x9e, 0x7d, 0xfb, 0x7c, 0xd2, 0xf9); -DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_AFFINITY_WEIGHTING, 0xe70867f1, 0xfa2f, 0x4f4e, 0xae, 0xa1, 0x4d, 0x8a, 0x0b, 0xa2, 0x3b, 0x20); -DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_HISTORY_DECREASE_FACTOR, 0x1299023c, 0xbc28, 0x4f0a, 0x81, 0xec, 0xd3, 0x29, 0x5a, 0x8d, 0x81, 0x5d); -DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_HISTORY_THRESHOLD, 0x9ac18e92, 0xaa3c, 0x4e27, 0xb3, 0x07, 0x01, 0xae, 0x37, 0x30, 0x71, 0x29); -DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_WEIGHTING, 0x8809c2d8, 0xb155, 0x42d4, 0xbc, 0xda, 0x0d, 0x34, 0x56, 0x51, 0xb1, 0xdb); -DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_THRESHOLD, 0x943c8cb6, 0x6f93, 0x4227, 0xad, 0x87, 0xe9, 0xa3, 0xfe, 0xec, 0x08, 0xd1); -DEFINE_GUID(GUID_PROCESSOR_PARKING_CORE_OVERRIDE, 0xa55612aa, 0xf624, 0x42c6, 0xa4, 0x43, 0x73, 0x97, 0xd0, 0x64, 0xc0, 0x4f); -DEFINE_GUID(GUID_PROCESSOR_PARKING_PERF_STATE, 0x447235c7, 0x6a8d, 0x4cc0, 0x8e, 0x24, 0x9e, 0xaf, 0x70, 0xb9, 0x6e, 0x2b); -DEFINE_GUID(GUID_PROCESSOR_PERF_HISTORY, 0x7d24baa7, 0x0b84, 0x480f, 0x84, 0x0c, 0x1b, 0x07, 0x43, 0xc0, 0x0f, 0x5f); -DEFINE_GUID(GUID_SYSTEM_COOLING_POLICY, 0x94D3A615, 0xA899, 0x4AC5, 0xAE, 0x2B, 0xE4, 0xD8, 0xF6, 0x34, 0x36, 0x7F); -DEFINE_GUID(GUID_LOCK_CONSOLE_ON_WAKE, 0x0E796BDB, 0x100D, 0x47D6, 0xA2, 0xD5, 0xF7, 0xD2, 0xDA, 0xA5, 0x1F, 0x51 ); -DEFINE_GUID(GUID_DEVICE_IDLE_POLICY, 0x4faab71a, 0x92e5, 0x4726, 0xb5, 0x31, 0x22, 0x45, 0x59, 0x67, 0x2d, 0x19 ); -DEFINE_GUID(GUID_ACDC_POWER_SOURCE, 0x5D3E9A59, 0xE9D5, 0x4B00, 0xA6, 0xBD, 0xFF, 0x34, 0xFF, 0x51, 0x65, 0x48 ); -DEFINE_GUID(GUID_LIDSWITCH_STATE_CHANGE, 0xBA3E0F4D, 0xB817, 0x4094, 0xA2, 0xD1, 0xD5, 0x63, 0x79, 0xE6, 0xA0, 0xF3 ); -DEFINE_GUID(GUID_BATTERY_PERCENTAGE_REMAINING, 0xA7AD8041, 0xB45A, 0x4CAE, 0x87, 0xA3, 0xEE, 0xCB, 0xB4, 0x68, 0xA9, 0xE1 ); -DEFINE_GUID(GUID_IDLE_BACKGROUND_TASK, 0x515C31D8, 0xF734, 0x163D, 0xA0, 0xFD, 0x11, 0xA0, 0x8C, 0x91, 0xE8, 0xF1 ); -DEFINE_GUID(GUID_BACKGROUND_TASK_NOTIFICATION, 0xCF23F240, 0x2A54, 0x48D8, 0xB1, 0x14, 0xDE, 0x15, 0x18, 0xFF, 0x05, 0x2E ); -DEFINE_GUID(GUID_APPLAUNCH_BUTTON, 0x1A689231, 0x7399, 0x4E9A, 0x8F, 0x99, 0xB7, 0x1F, 0x99, 0x9D, 0xB3, 0xFA ); -DEFINE_GUID(GUID_PCIEXPRESS_SETTINGS_SUBGROUP, 0x501a4d13, 0x42af,0x4429, 0x9f, 0xd1, 0xa8, 0x21, 0x8c, 0x26, 0x8e, 0x20 ); -DEFINE_GUID(GUID_PCIEXPRESS_ASPM_POLICY, 0xee12f906, 0xd277, 0x404b, 0xb6, 0xda, 0xe5, 0xfa, 0x1a, 0x57, 0x6d, 0xf5 ); -DEFINE_GUID(GUID_ENABLE_SWITCH_FORCED_SHUTDOWN, 0x833a6b62, 0xdfa4, 0x46d1, 0x82, 0xf8, 0xe0, 0x9e, 0x34, 0xd0, 0x29, 0xd6 ); - -#define PERFSTATE_POLICY_CHANGE_IDEAL 0 -#define PERFSTATE_POLICY_CHANGE_SINGLE 1 -#define PERFSTATE_POLICY_CHANGE_ROCKET 2 -#define PERFSTATE_POLICY_CHANGE_MAX PERFSTATE_POLICY_CHANGE_ROCKET - -#define PROCESSOR_PERF_BOOST_POLICY_DISABLED 0 -#define PROCESSOR_PERF_BOOST_POLICY_MAX 100 - -#define POWER_DEVICE_IDLE_POLICY_PERFORMANCE 0 -#define POWER_DEVICE_IDLE_POLICY_CONSERVATIVE 1 - typedef VOID -(NTAPI REQUEST_POWER_COMPLETE)( +(DDKAPI *PREQUEST_POWER_COMPLETE)( IN struct _DEVICE_OBJECT *DeviceObject, IN UCHAR MinorFunction, IN POWER_STATE PowerState, IN PVOID Context, IN struct _IO_STATUS_BLOCK *IoStatus); -typedef REQUEST_POWER_COMPLETE *PREQUEST_POWER_COMPLETE; typedef NTSTATUS -(NTAPI POWER_SETTING_CALLBACK)( +(DDKAPI POWER_SETTING_CALLBACK)( IN LPCGUID SettingGuid, IN PVOID Value, IN ULONG ValueLength, IN OUT PVOID Context OPTIONAL); + typedef POWER_SETTING_CALLBACK *PPOWER_SETTING_CALLBACK; +#define PO_CB_SYSTEM_POWER_POLICY 0 +#define PO_CB_AC_STATUS 1 +#define PO_CB_BUTTON_COLLISION 2 +#define PO_CB_SYSTEM_STATE_LOCK 3 +#define PO_CB_LID_SWITCH_STATE 4 +#define PO_CB_PROCESSOR_POWER_POLICY 5 /****************************************************************************** * Configuration Manager Types * @@ -2699,11 +1936,11 @@ typedef int CM_RESOURCE_TYPE; #define CmResourceTypeDma 4 #define CmResourceTypeDeviceSpecific 5 #define CmResourceTypeBusNumber 6 -#define CmResourceTypeNonArbitrated 128 -#define CmResourceTypeConfigData 128 -#define CmResourceTypeDevicePrivate 129 -#define CmResourceTypePcCardConfig 130 -#define CmResourceTypeMfCardConfig 131 +#define CmResourceTypeNonArbitrated 128 +#define CmResourceTypeConfigData 128 +#define CmResourceTypeDevicePrivate 129 +#define CmResourceTypePcCardConfig 130 +#define CmResourceTypeMfCardConfig 131 /* KEY_VALUE_Xxx.Type */ #define REG_NONE 0 @@ -2717,9 +1954,9 @@ typedef int CM_RESOURCE_TYPE; #define REG_MULTI_SZ 7 #define REG_RESOURCE_LIST 8 #define REG_FULL_RESOURCE_DESCRIPTOR 9 -#define REG_RESOURCE_REQUIREMENTS_LIST 10 -#define REG_QWORD 11 -#define REG_QWORD_LITTLE_ENDIAN 11 +#define REG_RESOURCE_REQUIREMENTS_LIST 10 +#define REG_QWORD 11 +#define REG_QWORD_LITTLE_ENDIAN 11 /* Registry Access Rights */ #define KEY_QUERY_VALUE (0x0001) @@ -2775,15 +2012,6 @@ typedef int CM_RESOURCE_TYPE; REG_OPTION_BACKUP_RESTORE |\ REG_OPTION_OPEN_LINK) -#define REG_OPEN_LEGAL_OPTION \ - (REG_OPTION_RESERVED |\ - REG_OPTION_BACKUP_RESTORE |\ - REG_OPTION_OPEN_LINK) - -#define REG_STANDARD_FORMAT 1 -#define REG_LATEST_FORMAT 2 -#define REG_NO_COMPRESSION 4 - /* Key creation/open disposition */ #define REG_CREATED_NEW_KEY (0x00000001L) #define REG_OPENED_EXISTING_KEY (0x00000002L) @@ -2799,7 +2027,6 @@ typedef int CM_RESOURCE_TYPE; #define REG_HIVE_EXACT_FILE_GROWTH (0x00000080L) #define REG_HIVE_NO_RM (0x00000100L) #define REG_HIVE_SINGLE_LOG (0x00000200L) -#define REG_BOOT_HIVE (0x00000400L) /* Unload Flags */ #define REG_FORCE_UNLOAD 1 @@ -2816,6 +2043,27 @@ typedef int CM_RESOURCE_TYPE; REG_NOTIFY_CHANGE_LAST_SET |\ REG_NOTIFY_CHANGE_SECURITY) +typedef struct _CM_FLOPPY_DEVICE_DATA { + USHORT Version; + USHORT Revision; + CHAR Size[8]; + ULONG MaxDensity; + ULONG MountDensity; + UCHAR StepRateHeadUnloadTime; + UCHAR HeadLoadTime; + UCHAR MotorOffTime; + UCHAR SectorLengthCode; + UCHAR SectorPerTrack; + UCHAR ReadWriteGapLength; + UCHAR DataTransferLength; + UCHAR FormatGapLength; + UCHAR FormatFillCharacter; + UCHAR HeadSettleTime; + UCHAR MotorSettleTime; + UCHAR MaximumTrackValue; + UCHAR DataTransferRate; +} CM_FLOPPY_DEVICE_DATA, *PCM_FLOPPY_DEVICE_DATA; + #include typedef struct _CM_PARTIAL_RESOURCE_DESCRIPTOR { UCHAR Type; @@ -2915,15 +2163,15 @@ typedef struct _CM_PARTIAL_RESOURCE_DESCRIPTOR { #define CmResourceTypeDeviceSpecific 5 #define CmResourceTypeBusNumber 6 #define CmResourceTypeMemoryLarge 7 -#define CmResourceTypeNonArbitrated 128 -#define CmResourceTypeConfigData 128 -#define CmResourceTypeDevicePrivate 129 -#define CmResourceTypePcCardConfig 130 -#define CmResourceTypeMfCardConfig 131 +#define CmResourceTypeNonArbitrated 128 +#define CmResourceTypeConfigData 128 +#define CmResourceTypeDevicePrivate 129 +#define CmResourceTypePcCardConfig 130 +#define CmResourceTypeMfCardConfig 131 /* CM_PARTIAL_RESOURCE_DESCRIPTOR.ShareDisposition */ typedef enum _CM_SHARE_DISPOSITION { - CmResourceShareUndetermined = 0, + CmResourceShareUndetermined, CmResourceShareDeviceExclusive, CmResourceShareDriverExclusive, CmResourceShareShared @@ -2946,10 +2194,6 @@ typedef enum _CM_SHARE_DISPOSITION { #define CM_RESOURCE_INTERRUPT_MESSAGE 0x0002 #define CM_RESOURCE_INTERRUPT_POLICY_INCLUDED 0x0004 -#define CM_RESOURCE_INTERRUPT_LEVEL_LATCHED_BITS 0x0001 - -#define CM_RESOURCE_INTERRUPT_MESSAGE_TOKEN ((ULONG)-2) - /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypeMemory */ #define CM_RESOURCE_MEMORY_READ_WRITE 0x0000 #define CM_RESOURCE_MEMORY_READ_ONLY 0x0001 @@ -2963,15 +2207,6 @@ typedef enum _CM_SHARE_DISPOSITION { #define CM_RESOURCE_MEMORY_BAR 0x0080 #define CM_RESOURCE_MEMORY_COMPAT_FOR_INACCESSIBLE_RANGE 0x0100 -#define CM_RESOURCE_MEMORY_LARGE 0x0E00 -#define CM_RESOURCE_MEMORY_LARGE_40 0x0200 -#define CM_RESOURCE_MEMORY_LARGE_48 0x0400 -#define CM_RESOURCE_MEMORY_LARGE_64 0x0800 - -#define CM_RESOURCE_MEMORY_LARGE_40_MAXLEN 0x000000FFFFFFFF00 -#define CM_RESOURCE_MEMORY_LARGE_48_MAXLEN 0x0000FFFFFFFF0000 -#define CM_RESOURCE_MEMORY_LARGE_64_MAXLEN 0xFFFFFFFF00000000 - /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypeDma */ #define CM_RESOURCE_DMA_8 0x0000 #define CM_RESOURCE_DMA_16 0x0001 @@ -2982,92 +2217,33 @@ typedef enum _CM_SHARE_DISPOSITION { #define CM_RESOURCE_DMA_TYPE_B 0x0020 #define CM_RESOURCE_DMA_TYPE_F 0x0040 -typedef struct _DEVICE_FLAGS { - ULONG Failed:1; - ULONG ReadOnly:1; - ULONG Removable:1; - ULONG ConsoleIn:1; - ULONG ConsoleOut:1; - ULONG Input:1; - ULONG Output:1; -} DEVICE_FLAGS, *PDEVICE_FLAGS; - -typedef enum _INTERFACE_TYPE { - InterfaceTypeUndefined = -1, - Internal, - Isa, - Eisa, - MicroChannel, - TurboChannel, - PCIBus, - VMEBus, - NuBus, - PCMCIABus, - CBus, - MPIBus, - MPSABus, - ProcessorInternal, - InternalPowerBus, - PNPISABus, - PNPBus, - Vmcs, - MaximumInterfaceType -} INTERFACE_TYPE, *PINTERFACE_TYPE; - -typedef struct _CM_COMPONENT_INFORMATION { - DEVICE_FLAGS Flags; - ULONG Version; - ULONG Key; - KAFFINITY AffinityMask; -} CM_COMPONENT_INFORMATION, *PCM_COMPONENT_INFORMATION; - -typedef struct _CM_ROM_BLOCK { - ULONG Address; - ULONG Size; -} CM_ROM_BLOCK, *PCM_ROM_BLOCK; - typedef struct _CM_PARTIAL_RESOURCE_LIST { - USHORT Version; - USHORT Revision; - ULONG Count; + USHORT Version; + USHORT Revision; + ULONG Count; CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1]; } CM_PARTIAL_RESOURCE_LIST, *PCM_PARTIAL_RESOURCE_LIST; typedef struct _CM_FULL_RESOURCE_DESCRIPTOR { - INTERFACE_TYPE InterfaceType; - ULONG BusNumber; - CM_PARTIAL_RESOURCE_LIST PartialResourceList; + INTERFACE_TYPE InterfaceType; + ULONG BusNumber; + CM_PARTIAL_RESOURCE_LIST PartialResourceList; } CM_FULL_RESOURCE_DESCRIPTOR, *PCM_FULL_RESOURCE_DESCRIPTOR; typedef struct _CM_RESOURCE_LIST { - ULONG Count; - CM_FULL_RESOURCE_DESCRIPTOR List[1]; + ULONG Count; + CM_FULL_RESOURCE_DESCRIPTOR List[1]; } CM_RESOURCE_LIST, *PCM_RESOURCE_LIST; -typedef struct _PNP_BUS_INFORMATION { - GUID BusTypeGuid; - INTERFACE_TYPE LegacyBusType; - ULONG BusNumber; -} PNP_BUS_INFORMATION, *PPNP_BUS_INFORMATION; - #include - typedef struct _CM_INT13_DRIVE_PARAMETER { - USHORT DriveSelect; - ULONG MaxCylinders; - USHORT SectorsPerTrack; - USHORT MaxHeads; - USHORT NumberDrives; + USHORT DriveSelect; + ULONG MaxCylinders; + USHORT SectorsPerTrack; + USHORT MaxHeads; + USHORT NumberDrives; } CM_INT13_DRIVE_PARAMETER, *PCM_INT13_DRIVE_PARAMETER; -typedef struct _CM_MCA_POS_DATA { - USHORT AdapterId; - UCHAR PosData1; - UCHAR PosData2; - UCHAR PosData3; - UCHAR PosData4; -} CM_MCA_POS_DATA, *PCM_MCA_POS_DATA; - typedef struct _CM_PNP_BIOS_DEVICE_NODE { USHORT Size; UCHAR Node; @@ -3091,201 +2267,140 @@ typedef struct _CM_PNP_BIOS_INSTALLATION_CHECK { USHORT RealModeDataBaseAddress; ULONG ProtectedModeDataBaseAddress; } CM_PNP_BIOS_INSTALLATION_CHECK, *PCM_PNP_BIOS_INSTALLATION_CHECK; - #include typedef struct _CM_DISK_GEOMETRY_DEVICE_DATA { - ULONG BytesPerSector; - ULONG NumberOfCylinders; - ULONG SectorsPerTrack; - ULONG NumberOfHeads; + ULONG BytesPerSector; + ULONG NumberOfCylinders; + ULONG SectorsPerTrack; + ULONG NumberOfHeads; } CM_DISK_GEOMETRY_DEVICE_DATA, *PCM_DISK_GEOMETRY_DEVICE_DATA; typedef struct _CM_KEYBOARD_DEVICE_DATA { - USHORT Version; - USHORT Revision; - UCHAR Type; - UCHAR Subtype; - USHORT KeyboardFlags; + USHORT Version; + USHORT Revision; + UCHAR Type; + UCHAR Subtype; + USHORT KeyboardFlags; } CM_KEYBOARD_DEVICE_DATA, *PCM_KEYBOARD_DEVICE_DATA; +typedef struct _CM_MCA_POS_DATA { + USHORT AdapterId; + UCHAR PosData1; + UCHAR PosData2; + UCHAR PosData3; + UCHAR PosData4; +} CM_MCA_POS_DATA, *PCM_MCA_POS_DATA; + +#if (NTDDI_VERSION >= NTDDI_WINXP) +typedef struct CM_Power_Data_s { + ULONG PD_Size; + DEVICE_POWER_STATE PD_MostRecentPowerState; + ULONG PD_Capabilities; + ULONG PD_D1Latency; + ULONG PD_D2Latency; + ULONG PD_D3Latency; + DEVICE_POWER_STATE PD_PowerStateMapping[PowerSystemMaximum]; + SYSTEM_POWER_STATE PD_DeepestSystemWake; +} CM_POWER_DATA, *PCM_POWER_DATA; + +#define PDCAP_D0_SUPPORTED 0x00000001 +#define PDCAP_D1_SUPPORTED 0x00000002 +#define PDCAP_D2_SUPPORTED 0x00000004 +#define PDCAP_D3_SUPPORTED 0x00000008 +#define PDCAP_WAKE_FROM_D0_SUPPORTED 0x00000010 +#define PDCAP_WAKE_FROM_D1_SUPPORTED 0x00000020 +#define PDCAP_WAKE_FROM_D2_SUPPORTED 0x00000040 +#define PDCAP_WAKE_FROM_D3_SUPPORTED 0x00000080 +#define PDCAP_WARM_EJECT_SUPPORTED 0x00000100 + +#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ + typedef struct _CM_SCSI_DEVICE_DATA { - USHORT Version; - USHORT Revision; - UCHAR HostIdentifier; + USHORT Version; + USHORT Revision; + UCHAR HostIdentifier; } CM_SCSI_DEVICE_DATA, *PCM_SCSI_DEVICE_DATA; -typedef struct _CM_VIDEO_DEVICE_DATA { - USHORT Version; - USHORT Revision; - ULONG VideoClock; -} CM_VIDEO_DEVICE_DATA, *PCM_VIDEO_DEVICE_DATA; - -typedef struct _CM_SONIC_DEVICE_DATA { - USHORT Version; - USHORT Revision; - USHORT DataConfigurationRegister; - UCHAR EthernetAddress[8]; -} CM_SONIC_DEVICE_DATA, *PCM_SONIC_DEVICE_DATA; - typedef struct _CM_SERIAL_DEVICE_DATA { - USHORT Version; - USHORT Revision; - ULONG BaudClock; + USHORT Version; + USHORT Revision; + ULONG BaudClock; } CM_SERIAL_DEVICE_DATA, *PCM_SERIAL_DEVICE_DATA; -typedef struct _CM_MONITOR_DEVICE_DATA { - USHORT Version; - USHORT Revision; - USHORT HorizontalScreenSize; - USHORT VerticalScreenSize; - USHORT HorizontalResolution; - USHORT VerticalResolution; - USHORT HorizontalDisplayTimeLow; - USHORT HorizontalDisplayTime; - USHORT HorizontalDisplayTimeHigh; - USHORT HorizontalBackPorchLow; - USHORT HorizontalBackPorch; - USHORT HorizontalBackPorchHigh; - USHORT HorizontalFrontPorchLow; - USHORT HorizontalFrontPorch; - USHORT HorizontalFrontPorchHigh; - USHORT HorizontalSyncLow; - USHORT HorizontalSync; - USHORT HorizontalSyncHigh; - USHORT VerticalBackPorchLow; - USHORT VerticalBackPorch; - USHORT VerticalBackPorchHigh; - USHORT VerticalFrontPorchLow; - USHORT VerticalFrontPorch; - USHORT VerticalFrontPorchHigh; - USHORT VerticalSyncLow; - USHORT VerticalSync; - USHORT VerticalSyncHigh; -} CM_MONITOR_DEVICE_DATA, *PCM_MONITOR_DEVICE_DATA; - -typedef struct _CM_FLOPPY_DEVICE_DATA { - USHORT Version; - USHORT Revision; - CHAR Size[8]; - ULONG MaxDensity; - ULONG MountDensity; - UCHAR StepRateHeadUnloadTime; - UCHAR HeadLoadTime; - UCHAR MotorOffTime; - UCHAR SectorLengthCode; - UCHAR SectorPerTrack; - UCHAR ReadWriteGapLength; - UCHAR DataTransferLength; - UCHAR FormatGapLength; - UCHAR FormatFillCharacter; - UCHAR HeadSettleTime; - UCHAR MotorSettleTime; - UCHAR MaximumTrackValue; - UCHAR DataTransferRate; -} CM_FLOPPY_DEVICE_DATA, *PCM_FLOPPY_DEVICE_DATA; - typedef enum _KEY_INFORMATION_CLASS { KeyBasicInformation, KeyNodeInformation, KeyFullInformation, KeyNameInformation, KeyCachedInformation, - KeyFlagsInformation, - KeyVirtualizationInformation, - KeyHandleTagsInformation, - MaxKeyInfoClass + KeyFlagsInformation } KEY_INFORMATION_CLASS; typedef struct _KEY_BASIC_INFORMATION { - LARGE_INTEGER LastWriteTime; - ULONG TitleIndex; - ULONG NameLength; - WCHAR Name[1]; + LARGE_INTEGER LastWriteTime; + ULONG TitleIndex; + ULONG NameLength; + WCHAR Name[1]; } KEY_BASIC_INFORMATION, *PKEY_BASIC_INFORMATION; -typedef struct _KEY_CONTROL_FLAGS_INFORMATION { - ULONG ControlFlags; -} KEY_CONTROL_FLAGS_INFORMATION, *PKEY_CONTROL_FLAGS_INFORMATION; - typedef struct _KEY_FULL_INFORMATION { - LARGE_INTEGER LastWriteTime; - ULONG TitleIndex; - ULONG ClassOffset; - ULONG ClassLength; - ULONG SubKeys; - ULONG MaxNameLen; - ULONG MaxClassLen; - ULONG Values; - ULONG MaxValueNameLen; - ULONG MaxValueDataLen; - WCHAR Class[1]; + LARGE_INTEGER LastWriteTime; + ULONG TitleIndex; + ULONG ClassOffset; + ULONG ClassLength; + ULONG SubKeys; + ULONG MaxNameLen; + ULONG MaxClassLen; + ULONG Values; + ULONG MaxValueNameLen; + ULONG MaxValueDataLen; + WCHAR Class[1]; } KEY_FULL_INFORMATION, *PKEY_FULL_INFORMATION; -typedef struct _KEY_HANDLE_TAGS_INFORMATION { - ULONG HandleTags; -} KEY_HANDLE_TAGS_INFORMATION, *PKEY_HANDLE_TAGS_INFORMATION; - typedef struct _KEY_NODE_INFORMATION { - LARGE_INTEGER LastWriteTime; - ULONG TitleIndex; - ULONG ClassOffset; - ULONG ClassLength; - ULONG NameLength; - WCHAR Name[1]; + LARGE_INTEGER LastWriteTime; + ULONG TitleIndex; + ULONG ClassOffset; + ULONG ClassLength; + ULONG NameLength; + WCHAR Name[1]; } KEY_NODE_INFORMATION, *PKEY_NODE_INFORMATION; -typedef enum _KEY_SET_INFORMATION_CLASS { - KeyWriteTimeInformation, - KeyWow64FlagsInformation, - KeyControlFlagsInformation, - KeySetVirtualizationInformation, - KeySetDebugInformation, - KeySetHandleTagsInformation, - MaxKeySetInfoClass -} KEY_SET_INFORMATION_CLASS; - -typedef struct _KEY_SET_VIRTUALIZATION_INFORMATION { - ULONG VirtualTarget:1; - ULONG VirtualStore:1; - ULONG VirtualSource:1; - ULONG Reserved:29; -} KEY_SET_VIRTUALIZATION_INFORMATION, *PKEY_SET_VIRTUALIZATION_INFORMATION; - typedef struct _KEY_VALUE_BASIC_INFORMATION { - ULONG TitleIndex; - ULONG Type; - ULONG NameLength; - WCHAR Name[1]; + ULONG TitleIndex; + ULONG Type; + ULONG NameLength; + WCHAR Name[1]; } KEY_VALUE_BASIC_INFORMATION, *PKEY_VALUE_BASIC_INFORMATION; typedef struct _KEY_VALUE_FULL_INFORMATION { - ULONG TitleIndex; - ULONG Type; - ULONG DataOffset; - ULONG DataLength; - ULONG NameLength; - WCHAR Name[1]; + ULONG TitleIndex; + ULONG Type; + ULONG DataOffset; + ULONG DataLength; + ULONG NameLength; + WCHAR Name[1]; } KEY_VALUE_FULL_INFORMATION, *PKEY_VALUE_FULL_INFORMATION; typedef struct _KEY_VALUE_PARTIAL_INFORMATION { - ULONG TitleIndex; - ULONG Type; - ULONG DataLength; - UCHAR Data[1]; + ULONG TitleIndex; + ULONG Type; + ULONG DataLength; + UCHAR Data[1]; } KEY_VALUE_PARTIAL_INFORMATION, *PKEY_VALUE_PARTIAL_INFORMATION; typedef struct _KEY_VALUE_PARTIAL_INFORMATION_ALIGN64 { - ULONG Type; - ULONG DataLength; - UCHAR Data[1]; + ULONG Type; + ULONG DataLength; + UCHAR Data[1]; } KEY_VALUE_PARTIAL_INFORMATION_ALIGN64, *PKEY_VALUE_PARTIAL_INFORMATION_ALIGN64; typedef struct _KEY_VALUE_ENTRY { - PUNICODE_STRING ValueName; - ULONG DataLength; - ULONG DataOffset; - ULONG Type; + PUNICODE_STRING ValueName; + ULONG DataLength; + ULONG DataOffset; + ULONG Type; } KEY_VALUE_ENTRY, *PKEY_VALUE_ENTRY; typedef enum _KEY_VALUE_INFORMATION_CLASS { @@ -3296,14 +2411,20 @@ typedef enum _KEY_VALUE_INFORMATION_CLASS { KeyValuePartialInformationAlign64 } KEY_VALUE_INFORMATION_CLASS; -typedef struct _KEY_WOW64_FLAGS_INFORMATION { - ULONG UserFlags; -} KEY_WOW64_FLAGS_INFORMATION, *PKEY_WOW64_FLAGS_INFORMATION; - typedef struct _KEY_WRITE_TIME_INFORMATION { - LARGE_INTEGER LastWriteTime; + LARGE_INTEGER LastWriteTime; } KEY_WRITE_TIME_INFORMATION, *PKEY_WRITE_TIME_INFORMATION; +typedef enum _KEY_SET_INFORMATION_CLASS { + KeyWriteTimeInformation, + KeyWow64FlagsInformation, + KeyControlFlagsInformation, + KeySetVirtualizationInformation, + KeySetDebugInformation, + KeySetHandleTagsInformation, + MaxKeySetInfoClass +} KEY_SET_INFORMATION_CLASS; + typedef enum _REG_NOTIFY_CLASS { RegNtDeleteKey, RegNtPreDeleteKey = RegNtDeleteKey, @@ -3367,11 +2488,11 @@ typedef enum _REG_NOTIFY_CLASS { } REG_NOTIFY_CLASS, *PREG_NOTIFY_CLASS; typedef NTSTATUS -(NTAPI EX_CALLBACK_FUNCTION)( - IN PVOID CallbackContext, - IN PVOID Argument1, - IN PVOID Argument2); -typedef EX_CALLBACK_FUNCTION *PEX_CALLBACK_FUNCTION; +(NTAPI *PEX_CALLBACK_FUNCTION)( + IN PVOID CallbackContext, + IN PVOID Argument1, + IN PVOID Argument2 +); typedef struct _REG_DELETE_KEY_INFORMATION { PVOID Object; @@ -3473,54 +2594,6 @@ typedef struct _REG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION { PVOID Reserved; } REG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION, *PREG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION; -typedef struct _REG_RENAME_KEY_INFORMATION { - PVOID Object; - PUNICODE_STRING NewName; - PVOID CallContext; - PVOID ObjectContext; - PVOID Reserved; -} REG_RENAME_KEY_INFORMATION, *PREG_RENAME_KEY_INFORMATION; - -typedef struct _REG_CREATE_KEY_INFORMATION { - PUNICODE_STRING CompleteName; - PVOID RootObject; - PVOID ObjectType; - ULONG CreateOptions; - PUNICODE_STRING Class; - PVOID SecurityDescriptor; - PVOID SecurityQualityOfService; - ACCESS_MASK DesiredAccess; - ACCESS_MASK GrantedAccess; - PULONG Disposition; - PVOID *ResultObject; - PVOID CallContext; - PVOID RootObjectContext; - PVOID Transaction; - PVOID Reserved; -} REG_CREATE_KEY_INFORMATION, REG_OPEN_KEY_INFORMATION,*PREG_CREATE_KEY_INFORMATION, *PREG_OPEN_KEY_INFORMATION; - -typedef struct _REG_CREATE_KEY_INFORMATION_V1 { - PUNICODE_STRING CompleteName; - PVOID RootObject; - PVOID ObjectType; - ULONG Options; - PUNICODE_STRING Class; - PVOID SecurityDescriptor; - PVOID SecurityQualityOfService; - ACCESS_MASK DesiredAccess; - ACCESS_MASK GrantedAccess; - PULONG Disposition; - PVOID *ResultObject; - PVOID CallContext; - PVOID RootObjectContext; - PVOID Transaction; - ULONG_PTR Version; - PUNICODE_STRING RemainingName; - ULONG Wow64Flags; - ULONG Attributes; - KPROCESSOR_MODE CheckAccessMode; -} REG_CREATE_KEY_INFORMATION_V1, REG_OPEN_KEY_INFORMATION_V1,*PREG_CREATE_KEY_INFORMATION_V1, *PREG_OPEN_KEY_INFORMATION_V1; - typedef struct _REG_PRE_CREATE_KEY_INFORMATION { PUNICODE_STRING CompleteName; } REG_PRE_CREATE_KEY_INFORMATION, REG_PRE_OPEN_KEY_INFORMATION,*PREG_PRE_CREATE_KEY_INFORMATION, *PREG_PRE_OPEN_KEY_INFORMATION;; @@ -3548,180 +2621,151 @@ typedef struct _REG_KEY_HANDLE_CLOSE_INFORMATION { PVOID Reserved; } REG_KEY_HANDLE_CLOSE_INFORMATION, *PREG_KEY_HANDLE_CLOSE_INFORMATION; -#if (NTDDI_VERSION >= NTDDI_VISTA) - -typedef struct _REG_LOAD_KEY_INFORMATION { - PVOID Object; - PUNICODE_STRING KeyName; - PUNICODE_STRING SourceFile; - ULONG Flags; - PVOID TrustClassObject; - PVOID UserEvent; - ACCESS_MASK DesiredAccess; - PHANDLE RootHandle; - PVOID CallContext; - PVOID ObjectContext; - PVOID Reserved; -} REG_LOAD_KEY_INFORMATION, *PREG_LOAD_KEY_INFORMATION; - -typedef struct _REG_UNLOAD_KEY_INFORMATION { - PVOID Object; - PVOID UserEvent; - PVOID CallContext; - PVOID ObjectContext; - PVOID Reserved; -} REG_UNLOAD_KEY_INFORMATION, *PREG_UNLOAD_KEY_INFORMATION; - -typedef struct _REG_CALLBACK_CONTEXT_CLEANUP_INFORMATION { - PVOID Object; - PVOID ObjectContext; - PVOID Reserved; -} REG_CALLBACK_CONTEXT_CLEANUP_INFORMATION, *PREG_CALLBACK_CONTEXT_CLEANUP_INFORMATION; - -typedef struct _REG_QUERY_KEY_SECURITY_INFORMATION { - PVOID Object; - PSECURITY_INFORMATION SecurityInformation; - PSECURITY_DESCRIPTOR SecurityDescriptor; - PULONG Length; - PVOID CallContext; - PVOID ObjectContext; - PVOID Reserved; -} REG_QUERY_KEY_SECURITY_INFORMATION, *PREG_QUERY_KEY_SECURITY_INFORMATION; - -typedef struct _REG_SET_KEY_SECURITY_INFORMATION { - PVOID Object; - PSECURITY_INFORMATION SecurityInformation; - PSECURITY_DESCRIPTOR SecurityDescriptor; - PVOID CallContext; - PVOID ObjectContext; - PVOID Reserved; -} REG_SET_KEY_SECURITY_INFORMATION, *PREG_SET_KEY_SECURITY_INFORMATION; - -typedef struct _REG_RESTORE_KEY_INFORMATION { - PVOID Object; - HANDLE FileHandle; - ULONG Flags; - PVOID CallContext; - PVOID ObjectContext; - PVOID Reserved; -} REG_RESTORE_KEY_INFORMATION, *PREG_RESTORE_KEY_INFORMATION; - -typedef struct _REG_SAVE_KEY_INFORMATION { - PVOID Object; - HANDLE FileHandle; - ULONG Format; - PVOID CallContext; - PVOID ObjectContext; - PVOID Reserved; -} REG_SAVE_KEY_INFORMATION, *PREG_SAVE_KEY_INFORMATION; - -typedef struct _REG_REPLACE_KEY_INFORMATION { - PVOID Object; - PUNICODE_STRING OldFileName; - PUNICODE_STRING NewFileName; - PVOID CallContext; - PVOID ObjectContext; - PVOID Reserved; -} REG_REPLACE_KEY_INFORMATION, *PREG_REPLACE_KEY_INFORMATION; - -#endif /* NTDDI_VERSION >= NTDDI_VISTA */ - -#define SERVICE_KERNEL_DRIVER 0x00000001 -#define SERVICE_FILE_SYSTEM_DRIVER 0x00000002 -#define SERVICE_ADAPTER 0x00000004 -#define SERVICE_RECOGNIZER_DRIVER 0x00000008 - -#define SERVICE_DRIVER (SERVICE_KERNEL_DRIVER | \ - SERVICE_FILE_SYSTEM_DRIVER | \ - SERVICE_RECOGNIZER_DRIVER) - -#define SERVICE_WIN32_OWN_PROCESS 0x00000010 -#define SERVICE_WIN32_SHARE_PROCESS 0x00000020 -#define SERVICE_WIN32 (SERVICE_WIN32_OWN_PROCESS | \ - SERVICE_WIN32_SHARE_PROCESS) - -#define SERVICE_INTERACTIVE_PROCESS 0x00000100 - -#define SERVICE_TYPE_ALL (SERVICE_WIN32 | \ - SERVICE_ADAPTER | \ - SERVICE_DRIVER | \ - SERVICE_INTERACTIVE_PROCESS) - -/* Service Start Types */ -#define SERVICE_BOOT_START 0x00000000 -#define SERVICE_SYSTEM_START 0x00000001 -#define SERVICE_AUTO_START 0x00000002 -#define SERVICE_DEMAND_START 0x00000003 -#define SERVICE_DISABLED 0x00000004 - -#define SERVICE_ERROR_IGNORE 0x00000000 -#define SERVICE_ERROR_NORMAL 0x00000001 -#define SERVICE_ERROR_SEVERE 0x00000002 -#define SERVICE_ERROR_CRITICAL 0x00000003 - -typedef enum _CM_SERVICE_NODE_TYPE { - DriverType = SERVICE_KERNEL_DRIVER, - FileSystemType = SERVICE_FILE_SYSTEM_DRIVER, - Win32ServiceOwnProcess = SERVICE_WIN32_OWN_PROCESS, - Win32ServiceShareProcess = SERVICE_WIN32_SHARE_PROCESS, - AdapterType = SERVICE_ADAPTER, - RecognizerType = SERVICE_RECOGNIZER_DRIVER -} SERVICE_NODE_TYPE; - -typedef enum _CM_SERVICE_LOAD_TYPE { - BootLoad = SERVICE_BOOT_START, - SystemLoad = SERVICE_SYSTEM_START, - AutoLoad = SERVICE_AUTO_START, - DemandLoad = SERVICE_DEMAND_START, - DisableLoad = SERVICE_DISABLED -} SERVICE_LOAD_TYPE; - -typedef enum _CM_ERROR_CONTROL_TYPE { - IgnoreError = SERVICE_ERROR_IGNORE, - NormalError = SERVICE_ERROR_NORMAL, - SevereError = SERVICE_ERROR_SEVERE, - CriticalError = SERVICE_ERROR_CRITICAL -} SERVICE_ERROR_TYPE; - -#define CM_SERVICE_NETWORK_BOOT_LOAD 0x00000001 -#define CM_SERVICE_VIRTUAL_DISK_BOOT_LOAD 0x00000002 -#define CM_SERVICE_USB_DISK_BOOT_LOAD 0x00000004 - -#define CM_SERVICE_VALID_PROMOTION_MASK (CM_SERVICE_NETWORK_BOOT_LOAD | \ - CM_SERVICE_VIRTUAL_DISK_BOOT_LOAD | \ - CM_SERVICE_USB_DISK_BOOT_LOAD) - /****************************************************************************** * I/O Manager Types * ******************************************************************************/ -#define WDM_MAJORVERSION 0x06 -#define WDM_MINORVERSION 0x00 + /* PCI_COMMON_CONFIG.Command */ +#define PCI_ENABLE_IO_SPACE 0x0001 +#define PCI_ENABLE_MEMORY_SPACE 0x0002 +#define PCI_ENABLE_BUS_MASTER 0x0004 +#define PCI_ENABLE_SPECIAL_CYCLES 0x0008 +#define PCI_ENABLE_WRITE_AND_INVALIDATE 0x0010 +#define PCI_ENABLE_VGA_COMPATIBLE_PALETTE 0x0020 +#define PCI_ENABLE_PARITY 0x0040 +#define PCI_ENABLE_WAIT_CYCLE 0x0080 +#define PCI_ENABLE_SERR 0x0100 +#define PCI_ENABLE_FAST_BACK_TO_BACK 0x0200 +#define PCI_DISABLE_LEVEL_INTERRUPT 0x0400 -#if defined(_WIN64) +/* PCI_COMMON_CONFIG.Status */ +#define PCI_STATUS_INTERRUPT_PENDING 0x0008 +#define PCI_STATUS_CAPABILITIES_LIST 0x0010 +#define PCI_STATUS_66MHZ_CAPABLE 0x0020 +#define PCI_STATUS_UDF_SUPPORTED 0x0040 +#define PCI_STATUS_FAST_BACK_TO_BACK 0x0080 +#define PCI_STATUS_DATA_PARITY_DETECTED 0x0100 +#define PCI_STATUS_DEVSEL 0x0600 +#define PCI_STATUS_SIGNALED_TARGET_ABORT 0x0800 +#define PCI_STATUS_RECEIVED_TARGET_ABORT 0x1000 +#define PCI_STATUS_RECEIVED_MASTER_ABORT 0x2000 +#define PCI_STATUS_SIGNALED_SYSTEM_ERROR 0x4000 +#define PCI_STATUS_DETECTED_PARITY_ERROR 0x8000 -#ifndef USE_DMA_MACROS -#define USE_DMA_MACROS -#endif +/* PCI_COMMON_CONFIG.HeaderType */ +#define PCI_MULTIFUNCTION 0x80 +#define PCI_DEVICE_TYPE 0x00 +#define PCI_BRIDGE_TYPE 0x01 +#define PCI_CARDBUS_BRIDGE_TYPE 0x02 -#ifndef NO_LEGACY_DRIVERS -#define NO_LEGACY_DRIVERS -#endif +#define PCI_CONFIGURATION_TYPE(PciData) \ + (((PPCI_COMMON_CONFIG) (PciData))->HeaderType & ~PCI_MULTIFUNCTION) -#endif /* defined(_WIN64) */ +#define PCI_MULTIFUNCTION_DEVICE(PciData) \ + ((((PPCI_COMMON_CONFIG) (PciData))->HeaderType & PCI_MULTIFUNCTION) != 0) -#define STATUS_CONTINUE_COMPLETION STATUS_SUCCESS +/* PCI device classes */ +#define PCI_CLASS_PRE_20 0x00 +#define PCI_CLASS_MASS_STORAGE_CTLR 0x01 +#define PCI_CLASS_NETWORK_CTLR 0x02 +#define PCI_CLASS_DISPLAY_CTLR 0x03 +#define PCI_CLASS_MULTIMEDIA_DEV 0x04 +#define PCI_CLASS_MEMORY_CTLR 0x05 +#define PCI_CLASS_BRIDGE_DEV 0x06 +#define PCI_CLASS_SIMPLE_COMMS_CTLR 0x07 +#define PCI_CLASS_BASE_SYSTEM_DEV 0x08 +#define PCI_CLASS_INPUT_DEV 0x09 +#define PCI_CLASS_DOCKING_STATION 0x0a +#define PCI_CLASS_PROCESSOR 0x0b +#define PCI_CLASS_SERIAL_BUS_CTLR 0x0c +#define PCI_CLASS_WIRELESS_CTLR 0x0d +#define PCI_CLASS_INTELLIGENT_IO_CTLR 0x0e +#define PCI_CLASS_SATELLITE_COMMS_CTLR 0x0f +#define PCI_CLASS_ENCRYPTION_DECRYPTION 0x10 +#define PCI_CLASS_DATA_ACQ_SIGNAL_PROC 0x11 -#define CONNECT_FULLY_SPECIFIED 0x1 -#define CONNECT_LINE_BASED 0x2 -#define CONNECT_MESSAGE_BASED 0x3 -#define CONNECT_FULLY_SPECIFIED_GROUP 0x4 -#define CONNECT_CURRENT_VERSION 0x4 +/* PCI device subclasses for class 0 */ +#define PCI_SUBCLASS_PRE_20_NON_VGA 0x00 +#define PCI_SUBCLASS_PRE_20_VGA 0x01 + +/* PCI device subclasses for class 1 (mass storage controllers)*/ +#define PCI_SUBCLASS_MSC_SCSI_BUS_CTLR 0x00 +#define PCI_SUBCLASS_MSC_IDE_CTLR 0x01 +#define PCI_SUBCLASS_MSC_FLOPPY_CTLR 0x02 +#define PCI_SUBCLASS_MSC_IPI_CTLR 0x03 +#define PCI_SUBCLASS_MSC_RAID_CTLR 0x04 +#define PCI_SUBCLASS_MSC_OTHER 0x80 + +/* PCI device subclasses for class 2 (network controllers)*/ +#define PCI_SUBCLASS_NET_ETHERNET_CTLR 0x00 +#define PCI_SUBCLASS_NET_TOKEN_RING_CTLR 0x01 +#define PCI_SUBCLASS_NET_FDDI_CTLR 0x02 +#define PCI_SUBCLASS_NET_ATM_CTLR 0x03 +#define PCI_SUBCLASS_NET_ISDN_CTLR 0x04 +#define PCI_SUBCLASS_NET_OTHER 0x80 + +/* PCI device subclasses for class 3 (display controllers)*/ +#define PCI_SUBCLASS_VID_VGA_CTLR 0x00 +#define PCI_SUBCLASS_VID_XGA_CTLR 0x01 +#define PCI_SUBCLASS_VID_3D_CTLR 0x02 +#define PCI_SUBCLASS_VID_OTHER 0x80 + +/* PCI device subclasses for class 4 (multimedia device)*/ +#define PCI_SUBCLASS_MM_VIDEO_DEV 0x00 +#define PCI_SUBCLASS_MM_AUDIO_DEV 0x01 +#define PCI_SUBCLASS_MM_TELEPHONY_DEV 0x02 +#define PCI_SUBCLASS_MM_OTHER 0x80 + +/* PCI device subclasses for class 5 (memory controller)*/ +#define PCI_SUBCLASS_MEM_RAM 0x00 +#define PCI_SUBCLASS_MEM_FLASH 0x01 +#define PCI_SUBCLASS_MEM_OTHER 0x80 + +/* PCI device subclasses for class 6 (bridge device)*/ +#define PCI_SUBCLASS_BR_HOST 0x00 +#define PCI_SUBCLASS_BR_ISA 0x01 +#define PCI_SUBCLASS_BR_EISA 0x02 +#define PCI_SUBCLASS_BR_MCA 0x03 +#define PCI_SUBCLASS_BR_PCI_TO_PCI 0x04 +#define PCI_SUBCLASS_BR_PCMCIA 0x05 +#define PCI_SUBCLASS_BR_NUBUS 0x06 +#define PCI_SUBCLASS_BR_CARDBUS 0x07 +#define PCI_SUBCLASS_BR_RACEWAY 0x08 +#define PCI_SUBCLASS_BR_OTHER 0x80 + +/* PCI device subclasses for class C (serial bus controller)*/ +#define PCI_SUBCLASS_SB_IEEE1394 0x00 +#define PCI_SUBCLASS_SB_ACCESS 0x01 +#define PCI_SUBCLASS_SB_SSA 0x02 +#define PCI_SUBCLASS_SB_USB 0x03 +#define PCI_SUBCLASS_SB_FIBRE_CHANNEL 0x04 +#define PCI_SUBCLASS_SB_SMBUS 0x05 + +#define PCI_MAX_DEVICES 32 +#define PCI_MAX_FUNCTION 8 +#define PCI_MAX_BRIDGE_NUMBER 0xFF +#define PCI_INVALID_VENDORID 0xFFFF +#define PCI_COMMON_HDR_LENGTH (FIELD_OFFSET(PCI_COMMON_CONFIG, DeviceSpecific)) + +#define PCI_ADDRESS_IO_SPACE 0x00000001 +#define PCI_ADDRESS_MEMORY_TYPE_MASK 0x00000006 +#define PCI_ADDRESS_MEMORY_PREFETCHABLE 0x00000008 +#define PCI_ADDRESS_IO_ADDRESS_MASK 0xfffffffc +#define PCI_ADDRESS_MEMORY_ADDRESS_MASK 0xfffffff0 +#define PCI_ADDRESS_ROM_ADDRESS_MASK 0xfffff800 + +#define PCI_TYPE_32BIT 0 +#define PCI_TYPE_20BIT 2 +#define PCI_TYPE_64BIT 4 #define POOL_COLD_ALLOCATION 256 #define POOL_QUOTA_FAIL_INSTEAD_OF_RAISE 8 #define POOL_RAISE_IF_ALLOCATION_FAILURE 16 +#define PCI_TYPE0_ADDRESSES 6 +#define PCI_TYPE1_ADDRESSES 2 +#define PCI_TYPE2_ADDRESSES 5 + #define IO_TYPE_ADAPTER 1 #define IO_TYPE_CONTROLLER 2 #define IO_TYPE_DEVICE 3 @@ -3745,6 +2789,47 @@ typedef enum _CM_ERROR_CONTROL_TYPE { #define IO_RESOURCE_DEFAULT 0x02 #define IO_RESOURCE_ALTERNATIVE 0x08 +/* DEVICE_OBJECT.Flags */ +#define DO_VERIFY_VOLUME 0x00000002 +#define DO_BUFFERED_IO 0x00000004 +#define DO_EXCLUSIVE 0x00000008 +#define DO_DIRECT_IO 0x00000010 +#define DO_MAP_IO_BUFFER 0x00000020 +#define DO_DEVICE_INITIALIZING 0x00000080 +#define DO_SHUTDOWN_REGISTERED 0x00000800 +#define DO_BUS_ENUMERATED_DEVICE 0x00001000 +#define DO_POWER_PAGABLE 0x00002000 +#define DO_POWER_INRUSH 0x00004000 + +/* DEVICE_OBJECT.Characteristics */ +#define FILE_REMOVABLE_MEDIA 0x00000001 +#define FILE_READ_ONLY_DEVICE 0x00000002 +#define FILE_FLOPPY_DISKETTE 0x00000004 +#define FILE_WRITE_ONCE_MEDIA 0x00000008 +#define FILE_REMOTE_DEVICE 0x00000010 +#define FILE_DEVICE_IS_MOUNTED 0x00000020 +#define FILE_VIRTUAL_VOLUME 0x00000040 +#define FILE_AUTOGENERATED_DEVICE_NAME 0x00000080 +#define FILE_DEVICE_SECURE_OPEN 0x00000100 +#define FILE_CHARACTERISTIC_PNP_DEVICE 0x00000800 +#define FILE_CHARACTERISTIC_TS_DEVICE 0x00001000 +#define FILE_CHARACTERISTIC_WEBDAV_DEVICE 0x00002000 + +/* DEVICE_OBJECT.AlignmentRequirement */ +#define FILE_BYTE_ALIGNMENT 0x00000000 +#define FILE_WORD_ALIGNMENT 0x00000001 +#define FILE_LONG_ALIGNMENT 0x00000003 +#define FILE_QUAD_ALIGNMENT 0x00000007 +#define FILE_OCTA_ALIGNMENT 0x0000000f +#define FILE_32_BYTE_ALIGNMENT 0x0000001f +#define FILE_64_BYTE_ALIGNMENT 0x0000003f +#define FILE_128_BYTE_ALIGNMENT 0x0000007f +#define FILE_256_BYTE_ALIGNMENT 0x000000ff +#define FILE_512_BYTE_ALIGNMENT 0x000001ff + +/* DEVICE_OBJECT.DeviceType */ +#define DEVICE_TYPE ULONG + #define FILE_DEVICE_BEEP 0x00000001 #define FILE_DEVICE_CD_ROM 0x00000002 #define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003 @@ -3813,44 +2898,6 @@ typedef enum _CM_ERROR_CONTROL_TYPE { #define FILE_DEVICE_BIOMETRIC 0x00000044 #define FILE_DEVICE_PMI 0x00000045 -#if defined(NT_PROCESSOR_GROUPS) - -typedef USHORT IRQ_DEVICE_POLICY, *PIRQ_DEVICE_POLICY; - -typedef enum _IRQ_DEVICE_POLICY_USHORT { - IrqPolicyMachineDefault = 0, - IrqPolicyAllCloseProcessors = 1, - IrqPolicyOneCloseProcessor = 2, - IrqPolicyAllProcessorsInMachine = 3, - IrqPolicyAllProcessorsInGroup = 3, - IrqPolicySpecifiedProcessors = 4, - IrqPolicySpreadMessagesAcrossAllProcessors = 5}; - -#else /* defined(NT_PROCESSOR_GROUPS) */ - -typedef enum _IRQ_DEVICE_POLICY { - IrqPolicyMachineDefault = 0, - IrqPolicyAllCloseProcessors, - IrqPolicyOneCloseProcessor, - IrqPolicyAllProcessorsInMachine, - IrqPolicySpecifiedProcessors, - IrqPolicySpreadMessagesAcrossAllProcessors -} IRQ_DEVICE_POLICY, *PIRQ_DEVICE_POLICY; - -#endif - -typedef enum _IRQ_PRIORITY { - IrqPriorityUndefined = 0, - IrqPriorityLow, - IrqPriorityNormal, - IrqPriorityHigh -} IRQ_PRIORITY, *PIRQ_PRIORITY; - -typedef enum _IRQ_GROUP_POLICY { - GroupAffinityAllGroupZero = 0, - GroupAffinityDontCare -} IRQ_GROUP_POLICY, *PIRQ_GROUP_POLICY; - #define MAXIMUM_VOLUME_LABEL_LENGTH (32 * sizeof(WCHAR)) typedef struct _OBJECT_HANDLE_INFORMATION { @@ -3859,20 +2906,24 @@ typedef struct _OBJECT_HANDLE_INFORMATION { } OBJECT_HANDLE_INFORMATION, *POBJECT_HANDLE_INFORMATION; typedef struct _CLIENT_ID { - HANDLE UniqueProcess; - HANDLE UniqueThread; + HANDLE UniqueProcess; + HANDLE UniqueThread; } CLIENT_ID, *PCLIENT_ID; +typedef VOID +(DDKAPI *PKSTART_ROUTINE)( + IN PVOID StartContext); + typedef struct _VPB { - CSHORT Type; - CSHORT Size; - USHORT Flags; - USHORT VolumeLabelLength; - struct _DEVICE_OBJECT *DeviceObject; - struct _DEVICE_OBJECT *RealDevice; - ULONG SerialNumber; - ULONG ReferenceCount; - WCHAR VolumeLabel[MAXIMUM_VOLUME_LABEL_LENGTH / sizeof(WCHAR)]; + CSHORT Type; + CSHORT Size; + USHORT Flags; + USHORT VolumeLabelLength; + struct _DEVICE_OBJECT *DeviceObject; + struct _DEVICE_OBJECT *RealDevice; + ULONG SerialNumber; + ULONG ReferenceCount; + WCHAR VolumeLabel[MAXIMUM_VOLUME_LABEL_LENGTH / sizeof(WCHAR)]; } VPB, *PVPB; typedef enum _IO_ALLOCATION_ACTION { @@ -3882,370 +2933,190 @@ typedef enum _IO_ALLOCATION_ACTION { } IO_ALLOCATION_ACTION, *PIO_ALLOCATION_ACTION; typedef IO_ALLOCATION_ACTION -(NTAPI DRIVER_CONTROL)( - IN struct _DEVICE_OBJECT *DeviceObject, - IN struct _IRP *Irp, - IN PVOID MapRegisterBase, - IN PVOID Context); -typedef DRIVER_CONTROL *PDRIVER_CONTROL; +(DDKAPI *PDRIVER_CONTROL)( + IN struct _DEVICE_OBJECT *DeviceObject, + IN struct _IRP *Irp, + IN PVOID MapRegisterBase, + IN PVOID Context); typedef struct _WAIT_CONTEXT_BLOCK { - KDEVICE_QUEUE_ENTRY WaitQueueEntry; - PDRIVER_CONTROL DeviceRoutine; - PVOID DeviceContext; - ULONG NumberOfMapRegisters; - PVOID DeviceObject; - PVOID CurrentIrp; - PKDPC BufferChainingDpc; + KDEVICE_QUEUE_ENTRY WaitQueueEntry; + PDRIVER_CONTROL DeviceRoutine; + PVOID DeviceContext; + ULONG NumberOfMapRegisters; + PVOID DeviceObject; + PVOID CurrentIrp; + PKDPC BufferChainingDpc; } WAIT_CONTEXT_BLOCK, *PWAIT_CONTEXT_BLOCK; -/* DEVICE_OBJECT.Flags */ -#define DO_VERIFY_VOLUME 0x00000002 -#define DO_BUFFERED_IO 0x00000004 -#define DO_EXCLUSIVE 0x00000008 -#define DO_DIRECT_IO 0x00000010 -#define DO_MAP_IO_BUFFER 0x00000020 -#define DO_DEVICE_INITIALIZING 0x00000080 -#define DO_SHUTDOWN_REGISTERED 0x00000800 -#define DO_BUS_ENUMERATED_DEVICE 0x00001000 -#define DO_POWER_PAGABLE 0x00002000 -#define DO_POWER_INRUSH 0x00004000 - -/* DEVICE_OBJECT.Characteristics */ -#define FILE_REMOVABLE_MEDIA 0x00000001 -#define FILE_READ_ONLY_DEVICE 0x00000002 -#define FILE_FLOPPY_DISKETTE 0x00000004 -#define FILE_WRITE_ONCE_MEDIA 0x00000008 -#define FILE_REMOTE_DEVICE 0x00000010 -#define FILE_DEVICE_IS_MOUNTED 0x00000020 -#define FILE_VIRTUAL_VOLUME 0x00000040 -#define FILE_AUTOGENERATED_DEVICE_NAME 0x00000080 -#define FILE_DEVICE_SECURE_OPEN 0x00000100 -#define FILE_CHARACTERISTIC_PNP_DEVICE 0x00000800 -#define FILE_CHARACTERISTIC_TS_DEVICE 0x00001000 -#define FILE_CHARACTERISTIC_WEBDAV_DEVICE 0x00002000 - -/* DEVICE_OBJECT.AlignmentRequirement */ -#define FILE_BYTE_ALIGNMENT 0x00000000 -#define FILE_WORD_ALIGNMENT 0x00000001 -#define FILE_LONG_ALIGNMENT 0x00000003 -#define FILE_QUAD_ALIGNMENT 0x00000007 -#define FILE_OCTA_ALIGNMENT 0x0000000f -#define FILE_32_BYTE_ALIGNMENT 0x0000001f -#define FILE_64_BYTE_ALIGNMENT 0x0000003f -#define FILE_128_BYTE_ALIGNMENT 0x0000007f -#define FILE_256_BYTE_ALIGNMENT 0x000000ff -#define FILE_512_BYTE_ALIGNMENT 0x000001ff - -/* DEVICE_OBJECT.DeviceType */ -#define DEVICE_TYPE ULONG - typedef struct _DEVICE_OBJECT { - CSHORT Type; - USHORT Size; - LONG ReferenceCount; - struct _DRIVER_OBJECT *DriverObject; - struct _DEVICE_OBJECT *NextDevice; - struct _DEVICE_OBJECT *AttachedDevice; - struct _IRP *CurrentIrp; - PIO_TIMER Timer; - ULONG Flags; - ULONG Characteristics; - volatile PVPB Vpb; - PVOID DeviceExtension; - DEVICE_TYPE DeviceType; - CCHAR StackSize; + CSHORT Type; + USHORT Size; + LONG ReferenceCount; + struct _DRIVER_OBJECT *DriverObject; + struct _DEVICE_OBJECT *NextDevice; + struct _DEVICE_OBJECT *AttachedDevice; + struct _IRP *CurrentIrp; + PIO_TIMER Timer; + ULONG Flags; + ULONG Characteristics; + volatile PVPB Vpb; + PVOID DeviceExtension; + DEVICE_TYPE DeviceType; + CCHAR StackSize; union { - LIST_ENTRY ListEntry; - WAIT_CONTEXT_BLOCK Wcb; + LIST_ENTRY ListEntry; + WAIT_CONTEXT_BLOCK Wcb; } Queue; - ULONG AlignmentRequirement; - KDEVICE_QUEUE DeviceQueue; - KDPC Dpc; - ULONG ActiveThreadCount; - PSECURITY_DESCRIPTOR SecurityDescriptor; - KEVENT DeviceLock; - USHORT SectorSize; - USHORT Spare1; - struct _DEVOBJ_EXTENSION *DeviceObjectExtension; - PVOID Reserved; + ULONG AlignmentRequirement; + KDEVICE_QUEUE DeviceQueue; + KDPC Dpc; + ULONG ActiveThreadCount; + PSECURITY_DESCRIPTOR SecurityDescriptor; + KEVENT DeviceLock; + USHORT SectorSize; + USHORT Spare1; + struct _DEVOBJ_EXTENSION *DeviceObjectExtension; + PVOID Reserved; } DEVICE_OBJECT, *PDEVICE_OBJECT; -typedef enum _IO_SESSION_STATE { - IoSessionStateCreated = 1, - IoSessionStateInitialized, - IoSessionStateConnected, - IoSessionStateDisconnected, - IoSessionStateDisconnectedLoggedOn, - IoSessionStateLoggedOn, - IoSessionStateLoggedOff, - IoSessionStateTerminated, - IoSessionStateMax -} IO_SESSION_STATE, *PIO_SESSION_STATE; - -typedef enum _IO_COMPLETION_ROUTINE_RESULT { - ContinueCompletion = STATUS_CONTINUE_COMPLETION, - StopCompletion = STATUS_MORE_PROCESSING_REQUIRED -} IO_COMPLETION_ROUTINE_RESULT, *PIO_COMPLETION_ROUTINE_RESULT; - -typedef struct _IO_INTERRUPT_MESSAGE_INFO_ENTRY { - PHYSICAL_ADDRESS MessageAddress; - KAFFINITY TargetProcessorSet; - PKINTERRUPT InterruptObject; - ULONG MessageData; - ULONG Vector; - KIRQL Irql; - KINTERRUPT_MODE Mode; - KINTERRUPT_POLARITY Polarity; -} IO_INTERRUPT_MESSAGE_INFO_ENTRY, *PIO_INTERRUPT_MESSAGE_INFO_ENTRY; - -typedef struct _IO_INTERRUPT_MESSAGE_INFO { - KIRQL UnifiedIrql; - ULONG MessageCount; - IO_INTERRUPT_MESSAGE_INFO_ENTRY MessageInfo[1]; -} IO_INTERRUPT_MESSAGE_INFO, *PIO_INTERRUPT_MESSAGE_INFO; - -typedef struct _IO_CONNECT_INTERRUPT_FULLY_SPECIFIED_PARAMETERS { - IN PDEVICE_OBJECT PhysicalDeviceObject; - OUT PKINTERRUPT *InterruptObject; - IN PKSERVICE_ROUTINE ServiceRoutine; - IN PVOID ServiceContext; - IN PKSPIN_LOCK SpinLock OPTIONAL; - IN KIRQL SynchronizeIrql; - IN BOOLEAN FloatingSave; - IN BOOLEAN ShareVector; - IN ULONG Vector; - IN KIRQL Irql; - IN KINTERRUPT_MODE InterruptMode; - IN KAFFINITY ProcessorEnableMask; - IN USHORT Group; -} IO_CONNECT_INTERRUPT_FULLY_SPECIFIED_PARAMETERS, *PIO_CONNECT_INTERRUPT_FULLY_SPECIFIED_PARAMETERS; - -typedef struct _IO_CONNECT_INTERRUPT_LINE_BASED_PARAMETERS { - IN PDEVICE_OBJECT PhysicalDeviceObject; - OUT PKINTERRUPT *InterruptObject; - IN PKSERVICE_ROUTINE ServiceRoutine; - IN PVOID ServiceContext; - IN PKSPIN_LOCK SpinLock OPTIONAL; - IN KIRQL SynchronizeIrql OPTIONAL; - IN BOOLEAN FloatingSave; -} IO_CONNECT_INTERRUPT_LINE_BASED_PARAMETERS, *PIO_CONNECT_INTERRUPT_LINE_BASED_PARAMETERS; - -typedef struct _IO_CONNECT_INTERRUPT_MESSAGE_BASED_PARAMETERS { - IN PDEVICE_OBJECT PhysicalDeviceObject; - union { - OUT PVOID *Generic; - OUT PIO_INTERRUPT_MESSAGE_INFO *InterruptMessageTable; - OUT PKINTERRUPT *InterruptObject; - } ConnectionContext; - IN PKMESSAGE_SERVICE_ROUTINE MessageServiceRoutine; - IN PVOID ServiceContext; - IN PKSPIN_LOCK SpinLock OPTIONAL; - IN KIRQL SynchronizeIrql OPTIONAL; - IN BOOLEAN FloatingSave; - IN PKSERVICE_ROUTINE FallBackServiceRoutine OPTIONAL; -} IO_CONNECT_INTERRUPT_MESSAGE_BASED_PARAMETERS, *PIO_CONNECT_INTERRUPT_MESSAGE_BASED_PARAMETERS; - -typedef struct _IO_CONNECT_INTERRUPT_PARAMETERS { - IN OUT ULONG Version; - union { - IO_CONNECT_INTERRUPT_FULLY_SPECIFIED_PARAMETERS FullySpecified; - IO_CONNECT_INTERRUPT_LINE_BASED_PARAMETERS LineBased; - IO_CONNECT_INTERRUPT_MESSAGE_BASED_PARAMETERS MessageBased; - }; -} IO_CONNECT_INTERRUPT_PARAMETERS, *PIO_CONNECT_INTERRUPT_PARAMETERS; - -typedef struct _IO_DISCONNECT_INTERRUPT_PARAMETERS { - IN ULONG Version; - union { - IN PVOID Generic; - IN PKINTERRUPT InterruptObject; - IN PIO_INTERRUPT_MESSAGE_INFO InterruptMessageTable; - } ConnectionContext; -} IO_DISCONNECT_INTERRUPT_PARAMETERS, *PIO_DISCONNECT_INTERRUPT_PARAMETERS; - -typedef enum _IO_ACCESS_TYPE { - ReadAccess, - WriteAccess, - ModifyAccess -} IO_ACCESS_TYPE; - -typedef enum _IO_ACCESS_MODE { - SequentialAccess, - RandomAccess -} IO_ACCESS_MODE; - -typedef enum _IO_CONTAINER_NOTIFICATION_CLASS { - IoSessionStateNotification, - IoMaxContainerNotificationClass -} IO_CONTAINER_NOTIFICATION_CLASS; - -typedef struct _IO_SESSION_STATE_NOTIFICATION { - ULONG Size; - ULONG Flags; - PVOID IoObject; - ULONG EventMask; - PVOID Context; -} IO_SESSION_STATE_NOTIFICATION, *PIO_SESSION_STATE_NOTIFICATION; - -typedef enum _IO_CONTAINER_INFORMATION_CLASS { - IoSessionStateInformation, - IoMaxContainerInformationClass -} IO_CONTAINER_INFORMATION_CLASS; - -typedef struct _IO_SESSION_STATE_INFORMATION { - ULONG SessionId; - IO_SESSION_STATE SessionState; - BOOLEAN LocalSession; -} IO_SESSION_STATE_INFORMATION, *PIO_SESSION_STATE_INFORMATION; - -#if (NTDDI_VERSION >= NTDDI_WIN7) - -typedef NTSTATUS -(NTAPI *PIO_CONTAINER_NOTIFICATION_FUNCTION)( - VOID); - -typedef NTSTATUS -(NTAPI IO_SESSION_NOTIFICATION_FUNCTION)( - IN PVOID SessionObject, - IN PVOID IoObject, - IN ULONG Event, - IN PVOID Context, - IN PVOID NotificationPayload, - IN ULONG PayloadLength); - -typedef IO_SESSION_NOTIFICATION_FUNCTION *PIO_SESSION_NOTIFICATION_FUNCTION; - -#endif - typedef struct _IO_REMOVE_LOCK_TRACKING_BLOCK * PIO_REMOVE_LOCK_TRACKING_BLOCK; typedef struct _IO_REMOVE_LOCK_COMMON_BLOCK { - BOOLEAN Removed; - BOOLEAN Reserved[3]; - volatile LONG IoCount; - KEVENT RemoveEvent; + BOOLEAN Removed; + BOOLEAN Reserved[3]; + volatile LONG IoCount; + KEVENT RemoveEvent; } IO_REMOVE_LOCK_COMMON_BLOCK; typedef struct _IO_REMOVE_LOCK_DBG_BLOCK { - LONG Signature; - LONG HighWatermark; - LONGLONG MaxLockedTicks; - LONG AllocateTag; - LIST_ENTRY LockList; - KSPIN_LOCK Spin; - volatile LONG LowMemoryCount; - ULONG Reserved1[4]; - PVOID Reserved2; - PIO_REMOVE_LOCK_TRACKING_BLOCK Blocks; + LONG Signature; + LONG HighWatermark; + LONGLONG MaxLockedTicks; + LONG AllocateTag; + LIST_ENTRY LockList; + KSPIN_LOCK Spin; + volatile LONG LowMemoryCount; + ULONG Reserved1[4]; + PVOID Reserved2; + PIO_REMOVE_LOCK_TRACKING_BLOCK Blocks; } IO_REMOVE_LOCK_DBG_BLOCK; typedef struct _IO_REMOVE_LOCK { - IO_REMOVE_LOCK_COMMON_BLOCK Common; + IO_REMOVE_LOCK_COMMON_BLOCK Common; #if DBG - IO_REMOVE_LOCK_DBG_BLOCK Dbg; + IO_REMOVE_LOCK_DBG_BLOCK Dbg; #endif } IO_REMOVE_LOCK, *PIO_REMOVE_LOCK; typedef struct _IO_WORKITEM *PIO_WORKITEM; typedef VOID -(NTAPI IO_WORKITEM_ROUTINE)( - IN PDEVICE_OBJECT DeviceObject, - IN PVOID Context); +(DDKAPI IO_WORKITEM_ROUTINE)( + IN PDEVICE_OBJECT DeviceObject, + IN PVOID Context); typedef IO_WORKITEM_ROUTINE *PIO_WORKITEM_ROUTINE; -typedef VOID -(NTAPI IO_WORKITEM_ROUTINE_EX)( - IN PVOID IoObject, - IN PVOID Context OPTIONAL, - IN PIO_WORKITEM IoWorkItem); -typedef IO_WORKITEM_ROUTINE_EX *PIO_WORKITEM_ROUTINE_EX; - typedef struct _SHARE_ACCESS { - ULONG OpenCount; - ULONG Readers; - ULONG Writers; - ULONG Deleters; - ULONG SharedRead; - ULONG SharedWrite; - ULONG SharedDelete; + ULONG OpenCount; + ULONG Readers; + ULONG Writers; + ULONG Deleters; + ULONG SharedRead; + ULONG SharedWrite; + ULONG SharedDelete; } SHARE_ACCESS, *PSHARE_ACCESS; /* While MS WDK uses inheritance in C++, we cannot do this with gcc, as inheritance, even from a struct renders the type non-POD. So we use this hack */ #define PCI_COMMON_HEADER_LAYOUT \ - USHORT VendorID; \ - USHORT DeviceID; \ - USHORT Command; \ - USHORT Status; \ - UCHAR RevisionID; \ - UCHAR ProgIf; \ - UCHAR SubClass; \ - UCHAR BaseClass; \ - UCHAR CacheLineSize; \ - UCHAR LatencyTimer; \ - UCHAR HeaderType; \ - UCHAR BIST; \ + USHORT VendorID; \ + USHORT DeviceID; \ + USHORT Command; \ + USHORT Status; \ + UCHAR RevisionID; \ + UCHAR ProgIf; \ + UCHAR SubClass; \ + UCHAR BaseClass; \ + UCHAR CacheLineSize; \ + UCHAR LatencyTimer; \ + UCHAR HeaderType; \ + UCHAR BIST; \ union { \ struct _PCI_HEADER_TYPE_0 { \ - ULONG BaseAddresses[PCI_TYPE0_ADDRESSES]; \ - ULONG CIS; \ - USHORT SubVendorID; \ - USHORT SubSystemID; \ - ULONG ROMBaseAddress; \ - UCHAR CapabilitiesPtr; \ - UCHAR Reserved1[3]; \ - ULONG Reserved2; \ - UCHAR InterruptLine; \ - UCHAR InterruptPin; \ - UCHAR MinimumGrant; \ - UCHAR MaximumLatency; \ + ULONG BaseAddresses[PCI_TYPE0_ADDRESSES]; \ + ULONG CIS; \ + USHORT SubVendorID; \ + USHORT SubSystemID; \ + ULONG ROMBaseAddress; \ + UCHAR CapabilitiesPtr; \ + UCHAR Reserved1[3]; \ + ULONG Reserved2; \ + UCHAR InterruptLine; \ + UCHAR InterruptPin; \ + UCHAR MinimumGrant; \ + UCHAR MaximumLatency; \ } type0; \ struct _PCI_HEADER_TYPE_1 { \ - ULONG BaseAddresses[PCI_TYPE1_ADDRESSES]; \ - UCHAR PrimaryBus; \ - UCHAR SecondaryBus; \ - UCHAR SubordinateBus; \ - UCHAR SecondaryLatency; \ - UCHAR IOBase; \ - UCHAR IOLimit; \ - USHORT SecondaryStatus; \ - USHORT MemoryBase; \ - USHORT MemoryLimit; \ - USHORT PrefetchBase; \ - USHORT PrefetchLimit; \ - ULONG PrefetchBaseUpper32; \ - ULONG PrefetchLimitUpper32; \ - USHORT IOBaseUpper16; \ - USHORT IOLimitUpper16; \ - UCHAR CapabilitiesPtr; \ - UCHAR Reserved1[3]; \ - ULONG ROMBaseAddress; \ - UCHAR InterruptLine; \ - UCHAR InterruptPin; \ - USHORT BridgeControl; \ + ULONG BaseAddresses[PCI_TYPE1_ADDRESSES]; \ + UCHAR PrimaryBus; \ + UCHAR SecondaryBus; \ + UCHAR SubordinateBus; \ + UCHAR SecondaryLatency; \ + UCHAR IOBase; \ + UCHAR IOLimit; \ + USHORT SecondaryStatus; \ + USHORT MemoryBase; \ + USHORT MemoryLimit; \ + USHORT PrefetchBase; \ + USHORT PrefetchLimit; \ + ULONG PrefetchBaseUpper32; \ + ULONG PrefetchLimitUpper32; \ + USHORT IOBaseUpper16; \ + USHORT IOLimitUpper16; \ + UCHAR CapabilitiesPtr; \ + UCHAR Reserved1[3]; \ + ULONG ROMBaseAddress; \ + UCHAR InterruptLine; \ + UCHAR InterruptPin; \ + USHORT BridgeControl; \ } type1; \ struct _PCI_HEADER_TYPE_2 { \ - ULONG SocketRegistersBaseAddress; \ - UCHAR CapabilitiesPtr; \ - UCHAR Reserved; \ - USHORT SecondaryStatus; \ - UCHAR PrimaryBus; \ - UCHAR SecondaryBus; \ - UCHAR SubordinateBus; \ - UCHAR SecondaryLatency; \ - struct { \ - ULONG Base; \ - ULONG Limit; \ + ULONG SocketRegistersBaseAddress; \ + UCHAR CapabilitiesPtr; \ + UCHAR Reserved; \ + USHORT SecondaryStatus; \ + UCHAR PrimaryBus; \ + UCHAR SecondaryBus; \ + UCHAR SubordinateBus; \ + UCHAR SecondaryLatency; \ + struct { \ + ULONG Base; \ + ULONG Limit; \ } Range[PCI_TYPE2_ADDRESSES-1]; \ - UCHAR InterruptLine; \ - UCHAR InterruptPin; \ - USHORT BridgeControl; \ + UCHAR InterruptLine; \ + UCHAR InterruptPin; \ + USHORT BridgeControl; \ } type2; \ } u; +typedef struct _PCI_COMMON_HEADER { + PCI_COMMON_HEADER_LAYOUT +} PCI_COMMON_HEADER, *PPCI_COMMON_HEADER; + +#ifdef __cplusplus +typedef struct _PCI_COMMON_CONFIG { + PCI_COMMON_HEADER_LAYOUT + UCHAR DeviceSpecific[192]; +} PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG; +#else +typedef struct _PCI_COMMON_CONFIG { + PCI_COMMON_HEADER DUMMYSTRUCTNAME; + UCHAR DeviceSpecific[192]; +} PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG; +#endif + typedef enum _CREATE_FILE_TYPE { CreateFileTypeNone, CreateFileTypeNamedPipe, @@ -4260,54 +3131,39 @@ typedef enum _CREATE_FILE_TYPE { typedef struct _IO_STATUS_BLOCK { _ANONYMOUS_UNION union { - NTSTATUS Status; - PVOID Pointer; + NTSTATUS Status; + PVOID Pointer; } DUMMYUNIONNAME; - ULONG_PTR Information; + ULONG_PTR Information; } IO_STATUS_BLOCK, *PIO_STATUS_BLOCK; -#if defined(_WIN64) -typedef struct _IO_STATUS_BLOCK32 { - NTSTATUS Status; - ULONG Information; -} IO_STATUS_BLOCK32, *PIO_STATUS_BLOCK32; -#endif +typedef struct _PCI_SLOT_NUMBER { + union { + struct { + ULONG DeviceNumber : 5; + ULONG FunctionNumber : 3; + ULONG Reserved : 24; + } bits; + ULONG AsULONG; + } u; +} PCI_SLOT_NUMBER, *PPCI_SLOT_NUMBER; typedef VOID -(NTAPI *PIO_APC_ROUTINE)( +(DDKAPI *PIO_APC_ROUTINE)( IN PVOID ApcContext, IN PIO_STATUS_BLOCK IoStatusBlock, IN ULONG Reserved); -#define PIO_APC_ROUTINE_DEFINED - -typedef enum _IO_SESSION_EVENT { - IoSessionEventIgnore = 0, - IoSessionEventCreated, - IoSessionEventTerminated, - IoSessionEventConnected, - IoSessionEventDisconnected, - IoSessionEventLogon, - IoSessionEventLogoff, - IoSessionEventMax -} IO_SESSION_EVENT, *PIO_SESSION_EVENT; - -#define IO_SESSION_STATE_ALL_EVENTS 0xffffffff -#define IO_SESSION_STATE_CREATION_EVENT 0x00000001 -#define IO_SESSION_STATE_TERMINATION_EVENT 0x00000002 -#define IO_SESSION_STATE_CONNECT_EVENT 0x00000004 -#define IO_SESSION_STATE_DISCONNECT_EVENT 0x00000008 -#define IO_SESSION_STATE_LOGON_EVENT 0x00000010 -#define IO_SESSION_STATE_LOGOFF_EVENT 0x00000020 - -#define IO_SESSION_STATE_VALID_EVENT_MASK 0x0000003f - -#define IO_SESSION_MAX_PAYLOAD_SIZE 256L - -typedef struct _IO_SESSION_CONNECT_INFO { - ULONG SessionId; - BOOLEAN LocalSession; -} IO_SESSION_CONNECT_INFO, *PIO_SESSION_CONNECT_INFO; +typedef VOID +(DDKAPI *WMI_NOTIFICATION_CALLBACK)( + PVOID Wnode, + PVOID Context); + +#define WMIREG_ACTION_REGISTER 1 +#define WMIREG_ACTION_DEREGISTER 2 +#define WMIREG_ACTION_REREGISTER 3 +#define WMIREG_ACTION_UPDATE_GUIDS 4 +#define WMIREG_ACTION_BLOCK_IRPS 5 #define EVENT_INCREMENT 1 #define IO_NO_INCREMENT 0 @@ -4327,148 +3183,105 @@ typedef struct _IO_SESSION_CONNECT_INFO { #define MM_MAXIMUM_DISK_IO_SIZE (0x10000) typedef struct _BOOTDISK_INFORMATION { - LONGLONG BootPartitionOffset; - LONGLONG SystemPartitionOffset; - ULONG BootDeviceSignature; - ULONG SystemDeviceSignature; + LONGLONG BootPartitionOffset; + LONGLONG SystemPartitionOffset; + ULONG BootDeviceSignature; + ULONG SystemDeviceSignature; } BOOTDISK_INFORMATION, *PBOOTDISK_INFORMATION; typedef struct _BOOTDISK_INFORMATION_EX { - LONGLONG BootPartitionOffset; - LONGLONG SystemPartitionOffset; - ULONG BootDeviceSignature; - ULONG SystemDeviceSignature; - GUID BootDeviceGuid; - GUID SystemDeviceGuid; - BOOLEAN BootDeviceIsGpt; - BOOLEAN SystemDeviceIsGpt; + LONGLONG BootPartitionOffset; + LONGLONG SystemPartitionOffset; + ULONG BootDeviceSignature; + ULONG SystemDeviceSignature; + GUID BootDeviceGuid; + GUID SystemDeviceGuid; + BOOLEAN BootDeviceIsGpt; + BOOLEAN SystemDeviceIsGpt; } BOOTDISK_INFORMATION_EX, *PBOOTDISK_INFORMATION_EX; -#if (NTDDI_VERSION >= NTDDI_WIN7) - -typedef struct _LOADER_PARTITION_INFORMATION_EX { - ULONG PartitionStyle; - ULONG PartitionNumber; - union { - ULONG Signature; - GUID DeviceId; - }; - ULONG Flags; -} LOADER_PARTITION_INFORMATION_EX, *PLOADER_PARTITION_INFORMATION_EX; - -typedef struct _BOOTDISK_INFORMATION_LITE { - ULONG NumberEntries; - LOADER_PARTITION_INFORMATION_EX Entries[1]; -} BOOTDISK_INFORMATION_LITE, *PBOOTDISK_INFORMATION_LITE; - -#else - -#if (NTDDI_VERSION >= NTDDI_VISTA) -typedef struct _BOOTDISK_INFORMATION_LITE { - ULONG BootDeviceSignature; - ULONG SystemDeviceSignature; - GUID BootDeviceGuid; - GUID SystemDeviceGuid; - BOOLEAN BootDeviceIsGpt; - BOOLEAN SystemDeviceIsGpt; -} BOOTDISK_INFORMATION_LITE, *PBOOTDISK_INFORMATION_LITE; -#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ - -#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ - -#include - typedef struct _EISA_MEMORY_TYPE { - UCHAR ReadWrite:1; - UCHAR Cached:1; - UCHAR Reserved0:1; - UCHAR Type:2; - UCHAR Shared:1; - UCHAR Reserved1:1; - UCHAR MoreEntries:1; + UCHAR ReadWrite : 1; + UCHAR Cached : 1; + UCHAR Reserved0 : 1; + UCHAR Type : 2; + UCHAR Shared : 1; + UCHAR Reserved1 : 1; + UCHAR MoreEntries : 1; } EISA_MEMORY_TYPE, *PEISA_MEMORY_TYPE; +#include typedef struct _EISA_MEMORY_CONFIGURATION { - EISA_MEMORY_TYPE ConfigurationByte; - UCHAR DataSize; - USHORT AddressLowWord; - UCHAR AddressHighByte; - USHORT MemorySize; + EISA_MEMORY_TYPE ConfigurationByte; + UCHAR DataSize; + USHORT AddressLowWord; + UCHAR AddressHighByte; + USHORT MemorySize; } EISA_MEMORY_CONFIGURATION, *PEISA_MEMORY_CONFIGURATION; +#include typedef struct _EISA_IRQ_DESCRIPTOR { - UCHAR Interrupt:4; - UCHAR Reserved:1; - UCHAR LevelTriggered:1; - UCHAR Shared:1; - UCHAR MoreEntries:1; + UCHAR Interrupt : 4; + UCHAR Reserved : 1; + UCHAR LevelTriggered : 1; + UCHAR Shared : 1; + UCHAR MoreEntries : 1; } EISA_IRQ_DESCRIPTOR, *PEISA_IRQ_DESCRIPTOR; typedef struct _EISA_IRQ_CONFIGURATION { - EISA_IRQ_DESCRIPTOR ConfigurationByte; - UCHAR Reserved; + EISA_IRQ_DESCRIPTOR ConfigurationByte; + UCHAR Reserved; } EISA_IRQ_CONFIGURATION, *PEISA_IRQ_CONFIGURATION; typedef struct _DMA_CONFIGURATION_BYTE0 { - UCHAR Channel:3; - UCHAR Reserved:3; - UCHAR Shared:1; - UCHAR MoreEntries:1; + UCHAR Channel : 3; + UCHAR Reserved : 3; + UCHAR Shared : 1; + UCHAR MoreEntries : 1; } DMA_CONFIGURATION_BYTE0; typedef struct _DMA_CONFIGURATION_BYTE1 { - UCHAR Reserved0:2; - UCHAR TransferSize:2; - UCHAR Timing:2; - UCHAR Reserved1:2; + UCHAR Reserved0 : 2; + UCHAR TransferSize : 2; + UCHAR Timing : 2; + UCHAR Reserved1 : 2; } DMA_CONFIGURATION_BYTE1; typedef struct _EISA_DMA_CONFIGURATION { - DMA_CONFIGURATION_BYTE0 ConfigurationByte0; - DMA_CONFIGURATION_BYTE1 ConfigurationByte1; + DMA_CONFIGURATION_BYTE0 ConfigurationByte0; + DMA_CONFIGURATION_BYTE1 ConfigurationByte1; } EISA_DMA_CONFIGURATION, *PEISA_DMA_CONFIGURATION; +#include typedef struct _EISA_PORT_DESCRIPTOR { - UCHAR NumberPorts:5; - UCHAR Reserved:1; - UCHAR Shared:1; - UCHAR MoreEntries:1; + UCHAR NumberPorts : 5; + UCHAR Reserved : 1; + UCHAR Shared : 1; + UCHAR MoreEntries : 1; } EISA_PORT_DESCRIPTOR, *PEISA_PORT_DESCRIPTOR; typedef struct _EISA_PORT_CONFIGURATION { - EISA_PORT_DESCRIPTOR Configuration; - USHORT PortAddress; + EISA_PORT_DESCRIPTOR Configuration; + USHORT PortAddress; } EISA_PORT_CONFIGURATION, *PEISA_PORT_CONFIGURATION; - -typedef struct _CM_EISA_SLOT_INFORMATION { - UCHAR ReturnCode; - UCHAR ReturnFlags; - UCHAR MajorRevision; - UCHAR MinorRevision; - USHORT Checksum; - UCHAR NumberFunctions; - UCHAR FunctionInformation; - ULONG CompressedId; -} CM_EISA_SLOT_INFORMATION, *PCM_EISA_SLOT_INFORMATION; +#include typedef struct _CM_EISA_FUNCTION_INFORMATION { - ULONG CompressedId; - UCHAR IdSlotFlags1; - UCHAR IdSlotFlags2; - UCHAR MinorRevision; - UCHAR MajorRevision; - UCHAR Selections[26]; - UCHAR FunctionFlags; - UCHAR TypeString[80]; - EISA_MEMORY_CONFIGURATION EisaMemory[9]; - EISA_IRQ_CONFIGURATION EisaIrq[7]; - EISA_DMA_CONFIGURATION EisaDma[4]; - EISA_PORT_CONFIGURATION EisaPort[20]; - UCHAR InitializationData[60]; + ULONG CompressedId; + UCHAR IdSlotFlags1; + UCHAR IdSlotFlags2; + UCHAR MinorRevision; + UCHAR MajorRevision; + UCHAR Selections[26]; + UCHAR FunctionFlags; + UCHAR TypeString[80]; + EISA_MEMORY_CONFIGURATION EisaMemory[9]; + EISA_IRQ_CONFIGURATION EisaIrq[7]; + EISA_DMA_CONFIGURATION EisaDma[4]; + EISA_PORT_CONFIGURATION EisaPort[20]; + UCHAR InitializationData[60]; } CM_EISA_FUNCTION_INFORMATION, *PCM_EISA_FUNCTION_INFORMATION; -#include - /* CM_EISA_FUNCTION_INFORMATION.FunctionFlags */ #define EISA_FUNCTION_ENABLED 0x80 @@ -4483,9 +3296,16 @@ typedef struct _CM_EISA_FUNCTION_INFORMATION { (EISA_HAS_PORT_RANGE + EISA_HAS_DMA_ENTRY + EISA_HAS_IRQ_ENTRY \ + EISA_HAS_MEMORY_ENTRY + EISA_HAS_TYPE_ENTRY) -#define EISA_MORE_ENTRIES 0x80 -#define EISA_SYSTEM_MEMORY 0x00 -#define EISA_MEMORY_TYPE_RAM 0x01 +typedef struct _CM_EISA_SLOT_INFORMATION { + UCHAR ReturnCode; + UCHAR ReturnFlags; + UCHAR MajorRevision; + UCHAR MinorRevision; + USHORT Checksum; + UCHAR NumberFunctions; + UCHAR FunctionInformation; + ULONG CompressedId; +} CM_EISA_SLOT_INFORMATION, *PCM_EISA_SLOT_INFORMATION; /* CM_EISA_SLOT_INFORMATION.ReturnCode */ @@ -4500,76 +3320,34 @@ typedef struct _CM_EISA_FUNCTION_INFORMATION { */ typedef VOID -(NTAPI *PINTERFACE_REFERENCE)( - PVOID Context); +(DDKAPI *PINTERFACE_REFERENCE)( + PVOID Context); typedef VOID -(NTAPI *PINTERFACE_DEREFERENCE)( +(DDKAPI *PINTERFACE_DEREFERENCE)( PVOID Context); typedef BOOLEAN -(NTAPI TRANSLATE_BUS_ADDRESS)( - IN PVOID Context, - IN PHYSICAL_ADDRESS BusAddress, - IN ULONG Length, - IN OUT PULONG AddressSpace, +(DDKAPI *PTRANSLATE_BUS_ADDRESS)( + IN PVOID Context, + IN PHYSICAL_ADDRESS BusAddress, + IN ULONG Length, + IN OUT PULONG AddressSpace, OUT PPHYSICAL_ADDRESS TranslatedAddress); -typedef TRANSLATE_BUS_ADDRESS *PTRANSLATE_BUS_ADDRESS; typedef struct _DMA_ADAPTER* -(NTAPI GET_DMA_ADAPTER)( - IN PVOID Context, - IN struct _DEVICE_DESCRIPTION *DeviceDescriptor, - OUT PULONG NumberOfMapRegisters); -typedef GET_DMA_ADAPTER *PGET_DMA_ADAPTER; +(DDKAPI *PGET_DMA_ADAPTER)( + IN PVOID Context, + IN struct _DEVICE_DESCRIPTION *DeviceDescriptor, + OUT PULONG NumberOfMapRegisters); typedef ULONG -(NTAPI GET_SET_DEVICE_DATA)( - IN PVOID Context, - IN ULONG DataType, - IN PVOID Buffer, - IN ULONG Offset, - IN ULONG Length); -typedef GET_SET_DEVICE_DATA *PGET_SET_DEVICE_DATA; - -typedef enum _DEVICE_INSTALL_STATE { - InstallStateInstalled, - InstallStateNeedsReinstall, - InstallStateFailedInstall, - InstallStateFinishInstall -} DEVICE_INSTALL_STATE, *PDEVICE_INSTALL_STATE; - -typedef struct _LEGACY_BUS_INFORMATION { - GUID BusTypeGuid; - INTERFACE_TYPE LegacyBusType; - ULONG BusNumber; -} LEGACY_BUS_INFORMATION, *PLEGACY_BUS_INFORMATION; - -typedef enum _DEVICE_REMOVAL_POLICY { - RemovalPolicyExpectNoRemoval = 1, - RemovalPolicyExpectOrderlyRemoval = 2, - RemovalPolicyExpectSurpriseRemoval = 3 -} DEVICE_REMOVAL_POLICY, *PDEVICE_REMOVAL_POLICY; - -typedef VOID -(NTAPI*PREENUMERATE_SELF)( - IN PVOID Context); - -typedef struct _REENUMERATE_SELF_INTERFACE_STANDARD { - USHORT Size; - USHORT Version; - PVOID Context; - PINTERFACE_REFERENCE InterfaceReference; - PINTERFACE_DEREFERENCE InterfaceDereference; - PREENUMERATE_SELF SurpriseRemoveAndReenumerateSelf; -} REENUMERATE_SELF_INTERFACE_STANDARD, *PREENUMERATE_SELF_INTERFACE_STANDARD; - -typedef VOID -(NTAPI *PIO_DEVICE_EJECT_CALLBACK)( - IN NTSTATUS Status, - IN OUT PVOID Context OPTIONAL); - -#define PCI_DEVICE_PRESENT_INTERFACE_VERSION 1 +(DDKAPI *PGET_SET_DEVICE_DATA)( + IN PVOID Context, + IN ULONG DataType, + IN PVOID Buffer, + IN ULONG Offset, + IN ULONG Length); /* PCI_DEVICE_PRESENCE_PARAMETERS.Flags */ #define PCI_USE_SUBSYSTEM_IDS 0x00000001 @@ -4581,116 +3359,283 @@ typedef VOID #define PCI_USE_LOCAL_DEVICE 0x00000040 typedef struct _PCI_DEVICE_PRESENCE_PARAMETERS { - ULONG Size; - ULONG Flags; - USHORT VendorID; - USHORT DeviceID; - UCHAR RevisionID; - USHORT SubVendorID; - USHORT SubSystemID; - UCHAR BaseClass; - UCHAR SubClass; - UCHAR ProgIf; + ULONG Size; + ULONG Flags; + USHORT VendorID; + USHORT DeviceID; + UCHAR RevisionID; + USHORT SubVendorID; + USHORT SubSystemID; + UCHAR BaseClass; + UCHAR SubClass; + UCHAR ProgIf; } PCI_DEVICE_PRESENCE_PARAMETERS, *PPCI_DEVICE_PRESENCE_PARAMETERS; typedef BOOLEAN -(NTAPI PCI_IS_DEVICE_PRESENT)( - IN USHORT VendorID, - IN USHORT DeviceID, - IN UCHAR RevisionID, - IN USHORT SubVendorID, - IN USHORT SubSystemID, - IN ULONG Flags); -typedef PCI_IS_DEVICE_PRESENT *PPCI_IS_DEVICE_PRESENT; +(DDKAPI *PPCI_IS_DEVICE_PRESENT)( + IN USHORT VendorID, + IN USHORT DeviceID, + IN UCHAR RevisionID, + IN USHORT SubVendorID, + IN USHORT SubSystemID, + IN ULONG Flags); typedef BOOLEAN -(NTAPI PCI_IS_DEVICE_PRESENT_EX)( +(DDKAPI *PPCI_IS_DEVICE_PRESENT_EX)( IN PVOID Context, IN PPCI_DEVICE_PRESENCE_PARAMETERS Parameters); -typedef PCI_IS_DEVICE_PRESENT_EX *PPCI_IS_DEVICE_PRESENT_EX; typedef struct _BUS_INTERFACE_STANDARD { - USHORT Size; - USHORT Version; - PVOID Context; - PINTERFACE_REFERENCE InterfaceReference; - PINTERFACE_DEREFERENCE InterfaceDereference; - PTRANSLATE_BUS_ADDRESS TranslateBusAddress; - PGET_DMA_ADAPTER GetDmaAdapter; - PGET_SET_DEVICE_DATA SetBusData; - PGET_SET_DEVICE_DATA GetBusData; + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; + PTRANSLATE_BUS_ADDRESS TranslateBusAddress; + PGET_DMA_ADAPTER GetDmaAdapter; + PGET_SET_DEVICE_DATA SetBusData; + PGET_SET_DEVICE_DATA GetBusData; } BUS_INTERFACE_STANDARD, *PBUS_INTERFACE_STANDARD; typedef struct _PCI_DEVICE_PRESENT_INTERFACE { - USHORT Size; - USHORT Version; - PVOID Context; - PINTERFACE_REFERENCE InterfaceReference; - PINTERFACE_DEREFERENCE InterfaceDereference; - PPCI_IS_DEVICE_PRESENT IsDevicePresent; - PPCI_IS_DEVICE_PRESENT_EX IsDevicePresentEx; + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; + PPCI_IS_DEVICE_PRESENT IsDevicePresent; + PPCI_IS_DEVICE_PRESENT_EX IsDevicePresentEx; } PCI_DEVICE_PRESENT_INTERFACE, *PPCI_DEVICE_PRESENT_INTERFACE; +typedef +BOOLEAN +(*PGPE_SERVICE_ROUTINE2)( + PVOID ObjectContext, + PVOID ServiceContext +); + +typedef +NTSTATUS +(*PGPE_CONNECT_VECTOR2)( + PVOID Context, + ULONG GpeNumber, + KINTERRUPT_MODE Mode, + BOOLEAN Shareable, + PGPE_SERVICE_ROUTINE2 ServiceRoutine, + PVOID ServiceContext, + PVOID *ObjectContext +); + +typedef +NTSTATUS +(*PGPE_DISCONNECT_VECTOR2)( + PVOID Context, + PVOID ObjectContext +); + +typedef +NTSTATUS +(*PGPE_ENABLE_EVENT2)( + PVOID Context, + PVOID ObjectContext +); + +typedef +NTSTATUS +(*PGPE_DISABLE_EVENT2)( + PVOID Context, + PVOID ObjectContext +); + +typedef +NTSTATUS +(*PGPE_CLEAR_STATUS2)( + PVOID Context, + PVOID ObjectContext +); + +typedef +VOID +(*PDEVICE_NOTIFY_CALLBACK2)( + PVOID NotificationContext, + ULONG NotifyCode +); + +typedef +NTSTATUS +(*PREGISTER_FOR_DEVICE_NOTIFICATIONS2)( + PVOID Context, + PDEVICE_NOTIFY_CALLBACK2 NotificationHandler, + PVOID NotificationContext +); + +typedef +VOID +(*PUNREGISTER_FOR_DEVICE_NOTIFICATIONS2)( + PVOID Context +); + +typedef struct +{ + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; + PGPE_CONNECT_VECTOR2 GpeConnectVector; + PGPE_DISCONNECT_VECTOR2 GpeDisconnectVector; + PGPE_ENABLE_EVENT2 GpeEnableEvent; + PGPE_DISABLE_EVENT2 GpeDisableEvent; + PGPE_CLEAR_STATUS2 GpeClearStatus; + PREGISTER_FOR_DEVICE_NOTIFICATIONS2 RegisterForDeviceNotifications; + PUNREGISTER_FOR_DEVICE_NOTIFICATIONS2 UnregisterForDeviceNotifications; +} ACPI_INTERFACE_STANDARD2, *PACPI_INTERFACE_STANDARD2; + +typedef +BOOLEAN +(*PGPE_SERVICE_ROUTINE)( + PDEVICE_OBJECT ObjectContext, + PVOID ServiceContext +); + +typedef +NTSTATUS +(*PGPE_CONNECT_VECTOR)( + PDEVICE_OBJECT Context, + ULONG GpeNumber, + KINTERRUPT_MODE Mode, + BOOLEAN Shareable, + PGPE_SERVICE_ROUTINE ServiceRoutine, + PVOID ServiceContext, + PVOID *ObjectContext +); + +typedef +NTSTATUS +(*PGPE_DISCONNECT_VECTOR)( + PDEVICE_OBJECT Context, + PVOID ObjectContext +); + +typedef +NTSTATUS +(*PGPE_ENABLE_EVENT)( + PDEVICE_OBJECT Context, + PVOID ObjectContext +); + +typedef +NTSTATUS +(*PGPE_DISABLE_EVENT)( + PDEVICE_OBJECT Context, + PVOID ObjectContext +); + +typedef +NTSTATUS +(*PGPE_CLEAR_STATUS)( + PDEVICE_OBJECT Context, + PVOID ObjectContext +); + +typedef +VOID +(*PDEVICE_NOTIFY_CALLBACK)( + PVOID NotificationContext, + ULONG NotifyCode +); + +typedef +NTSTATUS +(*PREGISTER_FOR_DEVICE_NOTIFICATIONS)( + PDEVICE_OBJECT Context, + PDEVICE_NOTIFY_CALLBACK NotificationHandler, + PVOID NotificationContext +); + +typedef +VOID +(*PUNREGISTER_FOR_DEVICE_NOTIFICATIONS)( + PDEVICE_OBJECT Context, + PDEVICE_NOTIFY_CALLBACK NotificationHandler +); + +typedef struct +{ + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; + PGPE_CONNECT_VECTOR GpeConnectVector; + PGPE_DISCONNECT_VECTOR GpeDisconnectVector; + PGPE_ENABLE_EVENT GpeEnableEvent; + PGPE_DISABLE_EVENT GpeDisableEvent; + PGPE_CLEAR_STATUS GpeClearStatus; + PREGISTER_FOR_DEVICE_NOTIFICATIONS RegisterForDeviceNotifications; + PUNREGISTER_FOR_DEVICE_NOTIFICATIONS UnregisterForDeviceNotifications; +} ACPI_INTERFACE_STANDARD, *PACPI_INTERFACE_STANDARD; + typedef struct _DEVICE_CAPABILITIES { - USHORT Size; - USHORT Version; - ULONG DeviceD1:1; - ULONG DeviceD2:1; - ULONG LockSupported:1; - ULONG EjectSupported:1; - ULONG Removable:1; - ULONG DockDevice:1; - ULONG UniqueID:1; - ULONG SilentInstall:1; - ULONG RawDeviceOK:1; - ULONG SurpriseRemovalOK:1; - ULONG WakeFromD0:1; - ULONG WakeFromD1:1; - ULONG WakeFromD2:1; - ULONG WakeFromD3:1; - ULONG HardwareDisabled:1; - ULONG NonDynamic:1; - ULONG WarmEjectSupported:1; - ULONG NoDisplayInUI:1; - ULONG Reserved:14; - ULONG Address; - ULONG UINumber; - DEVICE_POWER_STATE DeviceState[PowerSystemMaximum]; - SYSTEM_POWER_STATE SystemWake; - DEVICE_POWER_STATE DeviceWake; - ULONG D1Latency; - ULONG D2Latency; - ULONG D3Latency; + USHORT Size; + USHORT Version; + ULONG DeviceD1 : 1; + ULONG DeviceD2 : 1; + ULONG LockSupported : 1; + ULONG EjectSupported : 1; + ULONG Removable : 1; + ULONG DockDevice : 1; + ULONG UniqueID : 1; + ULONG SilentInstall : 1; + ULONG RawDeviceOK : 1; + ULONG SurpriseRemovalOK : 1; + ULONG WakeFromD0 : 1; + ULONG WakeFromD1 : 1; + ULONG WakeFromD2 : 1; + ULONG WakeFromD3 : 1; + ULONG HardwareDisabled : 1; + ULONG NonDynamic : 1; + ULONG WarmEjectSupported : 1; + ULONG NoDisplayInUI : 1; + ULONG Reserved : 14; + ULONG Address; + ULONG UINumber; + DEVICE_POWER_STATE DeviceState[PowerSystemMaximum]; + SYSTEM_POWER_STATE SystemWake; + DEVICE_POWER_STATE DeviceWake; + ULONG D1Latency; + ULONG D2Latency; + ULONG D3Latency; } DEVICE_CAPABILITIES, *PDEVICE_CAPABILITIES; typedef struct _DEVICE_INTERFACE_CHANGE_NOTIFICATION { - USHORT Version; - USHORT Size; - GUID Event; - GUID InterfaceClassGuid; - PUNICODE_STRING SymbolicLinkName; + USHORT Version; + USHORT Size; + GUID Event; + GUID InterfaceClassGuid; + PUNICODE_STRING SymbolicLinkName; } DEVICE_INTERFACE_CHANGE_NOTIFICATION, *PDEVICE_INTERFACE_CHANGE_NOTIFICATION; typedef struct _HWPROFILE_CHANGE_NOTIFICATION { - USHORT Version; - USHORT Size; - GUID Event; + USHORT Version; + USHORT Size; + GUID Event; } HWPROFILE_CHANGE_NOTIFICATION, *PHWPROFILE_CHANGE_NOTIFICATION; #undef INTERFACE typedef struct _INTERFACE { - USHORT Size; - USHORT Version; - PVOID Context; - PINTERFACE_REFERENCE InterfaceReference; - PINTERFACE_DEREFERENCE InterfaceDereference; + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; } INTERFACE, *PINTERFACE; typedef struct _PLUGPLAY_NOTIFICATION_HEADER { - USHORT Version; - USHORT Size; - GUID Event; + USHORT Version; + USHORT Size; + GUID Event; } PLUGPLAY_NOTIFICATION_HEADER, *PPLUGPLAY_NOTIFICATION_HEADER; typedef ULONG PNP_DEVICE_STATE, *PPNP_DEVICE_STATE; @@ -4705,154 +3650,21 @@ typedef ULONG PNP_DEVICE_STATE, *PPNP_DEVICE_STATE; #define PNP_DEVICE_NOT_DISABLEABLE 0x00000020 typedef struct _TARGET_DEVICE_CUSTOM_NOTIFICATION { - USHORT Version; - USHORT Size; - GUID Event; - struct _FILE_OBJECT *FileObject; - LONG NameBufferOffset; - UCHAR CustomDataBuffer[1]; + USHORT Version; + USHORT Size; + GUID Event; + struct _FILE_OBJECT *FileObject; + LONG NameBufferOffset; + UCHAR CustomDataBuffer[1]; } TARGET_DEVICE_CUSTOM_NOTIFICATION, *PTARGET_DEVICE_CUSTOM_NOTIFICATION; typedef struct _TARGET_DEVICE_REMOVAL_NOTIFICATION { - USHORT Version; - USHORT Size; - GUID Event; - struct _FILE_OBJECT *FileObject; + USHORT Version; + USHORT Size; + GUID Event; + struct _FILE_OBJECT *FileObject; } TARGET_DEVICE_REMOVAL_NOTIFICATION, *PTARGET_DEVICE_REMOVAL_NOTIFICATION; -#if (NTDDI_VERSION >= NTDDI_VISTA) -#include -#define PLUGPLAY_PROPERTY_PERSISTENT 0x00000001 -#endif - -#define PNP_REPLACE_NO_MAP MAXLONGLONG - -typedef NTSTATUS -(NTAPI *PREPLACE_MAP_MEMORY)( - IN PHYSICAL_ADDRESS TargetPhysicalAddress, - IN PHYSICAL_ADDRESS SparePhysicalAddress, - IN OUT PLARGE_INTEGER NumberOfBytes, - OUT PVOID *TargetAddress, - OUT PVOID *SpareAddress); - -typedef struct _PNP_REPLACE_MEMORY_LIST { - ULONG AllocatedCount; - ULONG Count; - ULONGLONG TotalLength; - struct { - PHYSICAL_ADDRESS Address; - ULONGLONG Length; - } Ranges[ANYSIZE_ARRAY]; -} PNP_REPLACE_MEMORY_LIST, *PPNP_REPLACE_MEMORY_LIST; - -typedef struct _PNP_REPLACE_PROCESSOR_LIST { - PKAFFINITY Affinity; - ULONG GroupCount; - ULONG AllocatedCount; - ULONG Count; - ULONG ApicIds[ANYSIZE_ARRAY]; -} PNP_REPLACE_PROCESSOR_LIST, *PPNP_REPLACE_PROCESSOR_LIST; - -typedef struct _PNP_REPLACE_PROCESSOR_LIST_V1 { - KAFFINITY AffinityMask; - ULONG AllocatedCount; - ULONG Count; - ULONG ApicIds[ANYSIZE_ARRAY]; -} PNP_REPLACE_PROCESSOR_LIST_V1, *PPNP_REPLACE_PROCESSOR_LIST_V1; - -#define PNP_REPLACE_PARAMETERS_VERSION 2 - -typedef struct _PNP_REPLACE_PARAMETERS { - ULONG Size; - ULONG Version; - ULONG64 Target; - ULONG64 Spare; - PPNP_REPLACE_PROCESSOR_LIST TargetProcessors; - PPNP_REPLACE_PROCESSOR_LIST SpareProcessors; - PPNP_REPLACE_MEMORY_LIST TargetMemory; - PPNP_REPLACE_MEMORY_LIST SpareMemory; - PREPLACE_MAP_MEMORY MapMemory; -} PNP_REPLACE_PARAMETERS, *PPNP_REPLACE_PARAMETERS; - -typedef VOID -(NTAPI *PREPLACE_UNLOAD)( - VOID); - -typedef NTSTATUS -(NTAPI *PREPLACE_BEGIN)( - IN PPNP_REPLACE_PARAMETERS Parameters, - OUT PVOID *Context); - -typedef NTSTATUS -(NTAPI *PREPLACE_END)( - IN PVOID Context); - -typedef NTSTATUS -(NTAPI *PREPLACE_MIRROR_PHYSICAL_MEMORY)( - IN PVOID Context, - IN PHYSICAL_ADDRESS PhysicalAddress, - IN LARGE_INTEGER ByteCount); - -typedef NTSTATUS -(NTAPI *PREPLACE_SET_PROCESSOR_ID)( - IN PVOID Context, - IN ULONG ApicId, - IN BOOLEAN Target); - -typedef NTSTATUS -(NTAPI *PREPLACE_SWAP)( - IN PVOID Context); - -typedef NTSTATUS -(NTAPI *PREPLACE_INITIATE_HARDWARE_MIRROR)( - IN PVOID Context); - -typedef NTSTATUS -(NTAPI *PREPLACE_MIRROR_PLATFORM_MEMORY)( - IN PVOID Context); - -typedef NTSTATUS -(NTAPI *PREPLACE_GET_MEMORY_DESTINATION)( - IN PVOID Context, - IN PHYSICAL_ADDRESS SourceAddress, - OUT PPHYSICAL_ADDRESS DestinationAddress); - -typedef NTSTATUS -(NTAPI *PREPLACE_ENABLE_DISABLE_HARDWARE_QUIESCE)( - IN PVOID Context, - IN BOOLEAN Enable); - -#define PNP_REPLACE_DRIVER_INTERFACE_VERSION 1 -#define PNP_REPLACE_DRIVER_INTERFACE_MINIMUM_SIZE \ - FIELD_OFFSET(PNP_REPLACE_DRIVER_INTERFACE, InitiateHardwareMirror) - -#define PNP_REPLACE_MEMORY_SUPPORTED 0x0001 -#define PNP_REPLACE_PROCESSOR_SUPPORTED 0x0002 -#define PNP_REPLACE_HARDWARE_MEMORY_MIRRORING 0x0004 -#define PNP_REPLACE_HARDWARE_PAGE_COPY 0x0008 -#define PNP_REPLACE_HARDWARE_QUIESCE 0x0010 - -typedef struct _PNP_REPLACE_DRIVER_INTERFACE { - ULONG Size; - ULONG Version; - ULONG Flags; - PREPLACE_UNLOAD Unload; - PREPLACE_BEGIN BeginReplace; - PREPLACE_END EndReplace; - PREPLACE_MIRROR_PHYSICAL_MEMORY MirrorPhysicalMemory; - PREPLACE_SET_PROCESSOR_ID SetProcessorId; - PREPLACE_SWAP Swap; - PREPLACE_INITIATE_HARDWARE_MIRROR InitiateHardwareMirror; - PREPLACE_MIRROR_PLATFORM_MEMORY MirrorPlatformMemory; - PREPLACE_GET_MEMORY_DESTINATION GetMemoryDestination; - PREPLACE_ENABLE_DISABLE_HARDWARE_QUIESCE EnableDisableHardwareQuiesce; -} PNP_REPLACE_DRIVER_INTERFACE, *PPNP_REPLACE_DRIVER_INTERFACE; - -typedef NTSTATUS -(NTAPI *PREPLACE_DRIVER_INIT)( - IN OUT PPNP_REPLACE_DRIVER_INTERFACE Interface, - IN PVOID Unused); - typedef enum _DEVICE_USAGE_NOTIFICATION_TYPE { DeviceUsageTypeUndefined, DeviceUsageTypePaging, @@ -4861,9 +3673,9 @@ typedef enum _DEVICE_USAGE_NOTIFICATION_TYPE { } DEVICE_USAGE_NOTIFICATION_TYPE; typedef struct _POWER_SEQUENCE { - ULONG SequenceD1; - ULONG SequenceD2; - ULONG SequenceD3; + ULONG SequenceD1; + ULONG SequenceD2; + ULONG SequenceD3; } POWER_SEQUENCE, *PPOWER_SEQUENCE; typedef enum { @@ -4899,27 +3711,16 @@ typedef enum _IO_NOTIFICATION_EVENT_CATEGORY { EventCategoryTargetDeviceChange } IO_NOTIFICATION_EVENT_CATEGORY; -typedef enum _IO_PRIORITY_HINT { - IoPriorityVeryLow = 0, - IoPriorityLow, - IoPriorityNormal, - IoPriorityHigh, - IoPriorityCritical, - MaxIoPriorityTypes -} IO_PRIORITY_HINT; - #define PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES 0x00000001 typedef NTSTATUS -(NTAPI DRIVER_NOTIFICATION_CALLBACK_ROUTINE)( +(DDKAPI *PDRIVER_NOTIFICATION_CALLBACK_ROUTINE)( IN PVOID NotificationStructure, IN PVOID Context); -typedef DRIVER_NOTIFICATION_CALLBACK_ROUTINE *PDRIVER_NOTIFICATION_CALLBACK_ROUTINE; typedef VOID -(NTAPI DEVICE_CHANGE_COMPLETE_CALLBACK)( +(DDKAPI *PDEVICE_CHANGE_COMPLETE_CALLBACK)( IN PVOID Context); -typedef DEVICE_CHANGE_COMPLETE_CALLBACK *PDEVICE_CHANGE_COMPLETE_CALLBACK; typedef enum _FILE_INFORMATION_CLASS { FileDirectoryInformation = 1, @@ -4981,59 +3782,35 @@ typedef enum _FILE_INFORMATION_CLASS { } FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS; typedef struct _FILE_POSITION_INFORMATION { - LARGE_INTEGER CurrentByteOffset; + LARGE_INTEGER CurrentByteOffset; } FILE_POSITION_INFORMATION, *PFILE_POSITION_INFORMATION; +#include typedef struct _FILE_BASIC_INFORMATION { - LARGE_INTEGER CreationTime; - LARGE_INTEGER LastAccessTime; - LARGE_INTEGER LastWriteTime; - LARGE_INTEGER ChangeTime; - ULONG FileAttributes; + LARGE_INTEGER CreationTime; + LARGE_INTEGER LastAccessTime; + LARGE_INTEGER LastWriteTime; + LARGE_INTEGER ChangeTime; + ULONG FileAttributes; } FILE_BASIC_INFORMATION, *PFILE_BASIC_INFORMATION; - -typedef struct _FILE_IO_PRIORITY_HINT_INFORMATION { - IO_PRIORITY_HINT PriorityHint; -} FILE_IO_PRIORITY_HINT_INFORMATION, *PFILE_IO_PRIORITY_HINT_INFORMATION; - -typedef struct _FILE_IO_COMPLETION_NOTIFICATION_INFORMATION { - ULONG Flags; -} FILE_IO_COMPLETION_NOTIFICATION_INFORMATION, *PFILE_IO_COMPLETION_NOTIFICATION_INFORMATION; - -typedef struct _FILE_IOSTATUSBLOCK_RANGE_INFORMATION { - PUCHAR IoStatusBlockRange; - ULONG Length; -} FILE_IOSTATUSBLOCK_RANGE_INFORMATION, *PFILE_IOSTATUSBLOCK_RANGE_INFORMATION; - -typedef struct _FILE_IS_REMOTE_DEVICE_INFORMATION { - BOOLEAN IsRemote; -} FILE_IS_REMOTE_DEVICE_INFORMATION, *PFILE_IS_REMOTE_DEVICE_INFORMATION; - -typedef struct _FILE_NUMA_NODE_INFORMATION { - USHORT NodeNumber; -} FILE_NUMA_NODE_INFORMATION, *PFILE_NUMA_NODE_INFORMATION; - -typedef struct _FILE_PROCESS_IDS_USING_FILE_INFORMATION { - ULONG NumberOfProcessIdsInList; - ULONG_PTR ProcessIdList[1]; -} FILE_PROCESS_IDS_USING_FILE_INFORMATION, *PFILE_PROCESS_IDS_USING_FILE_INFORMATION; +#include typedef struct _FILE_STANDARD_INFORMATION { - LARGE_INTEGER AllocationSize; - LARGE_INTEGER EndOfFile; - ULONG NumberOfLinks; - BOOLEAN DeletePending; - BOOLEAN Directory; + LARGE_INTEGER AllocationSize; + LARGE_INTEGER EndOfFile; + ULONG NumberOfLinks; + BOOLEAN DeletePending; + BOOLEAN Directory; } FILE_STANDARD_INFORMATION, *PFILE_STANDARD_INFORMATION; typedef struct _FILE_NETWORK_OPEN_INFORMATION { - LARGE_INTEGER CreationTime; - LARGE_INTEGER LastAccessTime; - LARGE_INTEGER LastWriteTime; - LARGE_INTEGER ChangeTime; - LARGE_INTEGER AllocationSize; - LARGE_INTEGER EndOfFile; - ULONG FileAttributes; + LARGE_INTEGER CreationTime; + LARGE_INTEGER LastAccessTime; + LARGE_INTEGER LastWriteTime; + LARGE_INTEGER ChangeTime; + LARGE_INTEGER AllocationSize; + LARGE_INTEGER EndOfFile; + ULONG FileAttributes; } FILE_NETWORK_OPEN_INFORMATION, *PFILE_NETWORK_OPEN_INFORMATION; typedef enum _FSINFOCLASS { @@ -5051,329 +3828,321 @@ typedef enum _FSINFOCLASS { } FS_INFORMATION_CLASS, *PFS_INFORMATION_CLASS; typedef struct _FILE_FS_DEVICE_INFORMATION { - DEVICE_TYPE DeviceType; - ULONG Characteristics; + DEVICE_TYPE DeviceType; + ULONG Characteristics; } FILE_FS_DEVICE_INFORMATION, *PFILE_FS_DEVICE_INFORMATION; typedef struct _FILE_FULL_EA_INFORMATION { - ULONG NextEntryOffset; - UCHAR Flags; - UCHAR EaNameLength; - USHORT EaValueLength; - CHAR EaName[1]; + ULONG NextEntryOffset; + UCHAR Flags; + UCHAR EaNameLength; + USHORT EaValueLength; + CHAR EaName[1]; } FILE_FULL_EA_INFORMATION, *PFILE_FULL_EA_INFORMATION; -typedef struct _FILE_SFIO_RESERVE_INFORMATION { - ULONG RequestsPerPeriod; - ULONG Period; - BOOLEAN RetryFailures; - BOOLEAN Discardable; - ULONG RequestSize; - ULONG NumOutstandingRequests; -} FILE_SFIO_RESERVE_INFORMATION, *PFILE_SFIO_RESERVE_INFORMATION; - -typedef struct _FILE_SFIO_VOLUME_INFORMATION { - ULONG MaximumRequestsPerPeriod; - ULONG MinimumPeriod; - ULONG MinimumTransferSize; -} FILE_SFIO_VOLUME_INFORMATION, *PFILE_SFIO_VOLUME_INFORMATION; - -#define FILE_SKIP_COMPLETION_PORT_ON_SUCCESS 0x1 -#define FILE_SKIP_SET_EVENT_ON_HANDLE 0x2 -#define FILE_SKIP_SET_USER_EVENT_ON_FAST_IO 0x4 - #define FM_LOCK_BIT (0x1) #define FM_LOCK_BIT_V (0x0) #define FM_LOCK_WAITER_WOKEN (0x2) #define FM_LOCK_WAITER_INC (0x4) -typedef BOOLEAN -(NTAPI FAST_IO_CHECK_IF_POSSIBLE)( - IN struct _FILE_OBJECT *FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN BOOLEAN Wait, - IN ULONG LockKey, - IN BOOLEAN CheckForReadOperation, - OUT PIO_STATUS_BLOCK IoStatus, - IN struct _DEVICE_OBJECT *DeviceObject); -typedef FAST_IO_CHECK_IF_POSSIBLE *PFAST_IO_CHECK_IF_POSSIBLE; +typedef ULONG_PTR ERESOURCE_THREAD, *PERESOURCE_THREAD; + +typedef struct _OWNER_ENTRY { + ERESOURCE_THREAD OwnerThread; + _ANONYMOUS_UNION union { + LONG OwnerCount; + ULONG TableSize; + } DUMMYUNIONNAME; +} OWNER_ENTRY, *POWNER_ENTRY; + +typedef struct _ERESOURCE +{ + LIST_ENTRY SystemResourcesList; + POWNER_ENTRY OwnerTable; + SHORT ActiveCount; + USHORT Flag; + volatile PKSEMAPHORE SharedWaiters; + volatile PKEVENT ExclusiveWaiters; + OWNER_ENTRY OwnerEntry; + ULONG ActiveEntries; + ULONG ContentionCount; + ULONG NumberOfSharedWaiters; + ULONG NumberOfExclusiveWaiters; + __GNU_EXTENSION union + { + PVOID Address; + ULONG_PTR CreatorBackTraceIndex; + }; + KSPIN_LOCK SpinLock; +} ERESOURCE, *PERESOURCE; + +/* ERESOURCE.Flag */ +#define ResourceNeverExclusive 0x0010 +#define ResourceReleaseByOtherThread 0x0020 +#define ResourceOwnedExclusive 0x0080 + +#define RESOURCE_HASH_TABLE_SIZE 64 typedef BOOLEAN -(NTAPI FAST_IO_READ)( - IN struct _FILE_OBJECT *FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN BOOLEAN Wait, - IN ULONG LockKey, - OUT PVOID Buffer, - OUT PIO_STATUS_BLOCK IoStatus, - IN struct _DEVICE_OBJECT *DeviceObject); -typedef FAST_IO_READ *PFAST_IO_READ; +(DDKAPI *PFAST_IO_CHECK_IF_POSSIBLE)( + IN struct _FILE_OBJECT *FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN BOOLEAN Wait, + IN ULONG LockKey, + IN BOOLEAN CheckForReadOperation, + OUT PIO_STATUS_BLOCK IoStatus, + IN struct _DEVICE_OBJECT *DeviceObject); typedef BOOLEAN -(NTAPI FAST_IO_WRITE)( - IN struct _FILE_OBJECT *FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN BOOLEAN Wait, - IN ULONG LockKey, - IN PVOID Buffer, - OUT PIO_STATUS_BLOCK IoStatus, - IN struct _DEVICE_OBJECT *DeviceObject); -typedef FAST_IO_WRITE *PFAST_IO_WRITE; +(DDKAPI *PFAST_IO_READ)( + IN struct _FILE_OBJECT *FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN BOOLEAN Wait, + IN ULONG LockKey, + OUT PVOID Buffer, + OUT PIO_STATUS_BLOCK IoStatus, + IN struct _DEVICE_OBJECT *DeviceObject); typedef BOOLEAN -(NTAPI FAST_IO_QUERY_BASIC_INFO)( - IN struct _FILE_OBJECT *FileObject, - IN BOOLEAN Wait, - OUT PFILE_BASIC_INFORMATION Buffer, - OUT PIO_STATUS_BLOCK IoStatus, - IN struct _DEVICE_OBJECT *DeviceObject); -typedef FAST_IO_QUERY_BASIC_INFO *PFAST_IO_QUERY_BASIC_INFO; +(DDKAPI *PFAST_IO_WRITE)( + IN struct _FILE_OBJECT *FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN BOOLEAN Wait, + IN ULONG LockKey, + IN PVOID Buffer, + OUT PIO_STATUS_BLOCK IoStatus, + IN struct _DEVICE_OBJECT *DeviceObject); typedef BOOLEAN -(NTAPI FAST_IO_QUERY_STANDARD_INFO)( - IN struct _FILE_OBJECT *FileObject, - IN BOOLEAN Wait, - OUT PFILE_STANDARD_INFORMATION Buffer, - OUT PIO_STATUS_BLOCK IoStatus, - IN struct _DEVICE_OBJECT *DeviceObject); -typedef FAST_IO_QUERY_STANDARD_INFO *PFAST_IO_QUERY_STANDARD_INFO; +(DDKAPI *PFAST_IO_QUERY_BASIC_INFO)( + IN struct _FILE_OBJECT *FileObject, + IN BOOLEAN Wait, + OUT PFILE_BASIC_INFORMATION Buffer, + OUT PIO_STATUS_BLOCK IoStatus, + IN struct _DEVICE_OBJECT *DeviceObject); typedef BOOLEAN -(NTAPI FAST_IO_LOCK)( - IN struct _FILE_OBJECT *FileObject, - IN PLARGE_INTEGER FileOffset, - IN PLARGE_INTEGER Length, - PEPROCESS ProcessId, - ULONG Key, - BOOLEAN FailImmediately, - BOOLEAN ExclusiveLock, - OUT PIO_STATUS_BLOCK IoStatus, - IN struct _DEVICE_OBJECT *DeviceObject); -typedef FAST_IO_LOCK *PFAST_IO_LOCK; +(DDKAPI *PFAST_IO_QUERY_STANDARD_INFO)( + IN struct _FILE_OBJECT *FileObject, + IN BOOLEAN Wait, + OUT PFILE_STANDARD_INFORMATION Buffer, + OUT PIO_STATUS_BLOCK IoStatus, + IN struct _DEVICE_OBJECT *DeviceObject); typedef BOOLEAN -(NTAPI FAST_IO_UNLOCK_SINGLE)( - IN struct _FILE_OBJECT *FileObject, - IN PLARGE_INTEGER FileOffset, - IN PLARGE_INTEGER Length, - PEPROCESS ProcessId, - ULONG Key, - OUT PIO_STATUS_BLOCK IoStatus, - IN struct _DEVICE_OBJECT *DeviceObject); -typedef FAST_IO_UNLOCK_SINGLE *PFAST_IO_UNLOCK_SINGLE; +(DDKAPI *PFAST_IO_LOCK)( + IN struct _FILE_OBJECT *FileObject, + IN PLARGE_INTEGER FileOffset, + IN PLARGE_INTEGER Length, + PEPROCESS ProcessId, + ULONG Key, + BOOLEAN FailImmediately, + BOOLEAN ExclusiveLock, + OUT PIO_STATUS_BLOCK IoStatus, + IN struct _DEVICE_OBJECT *DeviceObject); typedef BOOLEAN -(NTAPI FAST_IO_UNLOCK_ALL)( - IN struct _FILE_OBJECT *FileObject, - PEPROCESS ProcessId, - OUT PIO_STATUS_BLOCK IoStatus, - IN struct _DEVICE_OBJECT *DeviceObject); -typedef FAST_IO_UNLOCK_ALL *PFAST_IO_UNLOCK_ALL; +(DDKAPI *PFAST_IO_UNLOCK_SINGLE)( + IN struct _FILE_OBJECT *FileObject, + IN PLARGE_INTEGER FileOffset, + IN PLARGE_INTEGER Length, + PEPROCESS ProcessId, + ULONG Key, + OUT PIO_STATUS_BLOCK IoStatus, + IN struct _DEVICE_OBJECT *DeviceObject); typedef BOOLEAN -(NTAPI FAST_IO_UNLOCK_ALL_BY_KEY)( - IN struct _FILE_OBJECT *FileObject, - PVOID ProcessId, - ULONG Key, - OUT PIO_STATUS_BLOCK IoStatus, - IN struct _DEVICE_OBJECT *DeviceObject); -typedef FAST_IO_UNLOCK_ALL_BY_KEY *PFAST_IO_UNLOCK_ALL_BY_KEY; +(DDKAPI *PFAST_IO_UNLOCK_ALL)( + IN struct _FILE_OBJECT *FileObject, + PEPROCESS ProcessId, + OUT PIO_STATUS_BLOCK IoStatus, + IN struct _DEVICE_OBJECT *DeviceObject); typedef BOOLEAN -(NTAPI FAST_IO_DEVICE_CONTROL)( - IN struct _FILE_OBJECT *FileObject, - IN BOOLEAN Wait, - IN PVOID InputBuffer OPTIONAL, - IN ULONG InputBufferLength, - OUT PVOID OutputBuffer OPTIONAL, - IN ULONG OutputBufferLength, - IN ULONG IoControlCode, - OUT PIO_STATUS_BLOCK IoStatus, - IN struct _DEVICE_OBJECT *DeviceObject); -typedef FAST_IO_DEVICE_CONTROL *PFAST_IO_DEVICE_CONTROL; +(DDKAPI *PFAST_IO_UNLOCK_ALL_BY_KEY)( + IN struct _FILE_OBJECT *FileObject, + PVOID ProcessId, + ULONG Key, + OUT PIO_STATUS_BLOCK IoStatus, + IN struct _DEVICE_OBJECT *DeviceObject); + +typedef BOOLEAN +(DDKAPI *PFAST_IO_DEVICE_CONTROL)( + IN struct _FILE_OBJECT *FileObject, + IN BOOLEAN Wait, + IN PVOID InputBuffer OPTIONAL, + IN ULONG InputBufferLength, + OUT PVOID OutputBuffer OPTIONAL, + IN ULONG OutputBufferLength, + IN ULONG IoControlCode, + OUT PIO_STATUS_BLOCK IoStatus, + IN struct _DEVICE_OBJECT *DeviceObject); typedef VOID -(NTAPI FAST_IO_ACQUIRE_FILE)( - IN struct _FILE_OBJECT *FileObject); -typedef FAST_IO_ACQUIRE_FILE *PFAST_IO_ACQUIRE_FILE; +(DDKAPI *PFAST_IO_ACQUIRE_FILE)( + IN struct _FILE_OBJECT *FileObject); typedef VOID -(NTAPI FAST_IO_RELEASE_FILE)( - IN struct _FILE_OBJECT *FileObject); -typedef FAST_IO_RELEASE_FILE *PFAST_IO_RELEASE_FILE; +(DDKAPI *PFAST_IO_RELEASE_FILE)( + IN struct _FILE_OBJECT *FileObject); typedef VOID -(NTAPI FAST_IO_DETACH_DEVICE)( - IN struct _DEVICE_OBJECT *SourceDevice, - IN struct _DEVICE_OBJECT *TargetDevice); -typedef FAST_IO_DETACH_DEVICE *PFAST_IO_DETACH_DEVICE; +(DDKAPI *PFAST_IO_DETACH_DEVICE)( + IN struct _DEVICE_OBJECT *SourceDevice, + IN struct _DEVICE_OBJECT *TargetDevice); typedef BOOLEAN -(NTAPI FAST_IO_QUERY_NETWORK_OPEN_INFO)( - IN struct _FILE_OBJECT *FileObject, - IN BOOLEAN Wait, - OUT struct _FILE_NETWORK_OPEN_INFORMATION *Buffer, - OUT struct _IO_STATUS_BLOCK *IoStatus, - IN struct _DEVICE_OBJECT *DeviceObject); -typedef FAST_IO_QUERY_NETWORK_OPEN_INFO *PFAST_IO_QUERY_NETWORK_OPEN_INFO; +(DDKAPI *PFAST_IO_QUERY_NETWORK_OPEN_INFO)( + IN struct _FILE_OBJECT *FileObject, + IN BOOLEAN Wait, + OUT struct _FILE_NETWORK_OPEN_INFORMATION *Buffer, + OUT struct _IO_STATUS_BLOCK *IoStatus, + IN struct _DEVICE_OBJECT *DeviceObject); typedef NTSTATUS -(NTAPI FAST_IO_ACQUIRE_FOR_MOD_WRITE)( - IN struct _FILE_OBJECT *FileObject, - IN PLARGE_INTEGER EndingOffset, - OUT struct _ERESOURCE **ResourceToRelease, - IN struct _DEVICE_OBJECT *DeviceObject); -typedef FAST_IO_ACQUIRE_FOR_MOD_WRITE *PFAST_IO_ACQUIRE_FOR_MOD_WRITE; +(DDKAPI *PFAST_IO_ACQUIRE_FOR_MOD_WRITE)( + IN struct _FILE_OBJECT *FileObject, + IN PLARGE_INTEGER EndingOffset, + OUT struct _ERESOURCE **ResourceToRelease, + IN struct _DEVICE_OBJECT *DeviceObject); typedef BOOLEAN -(NTAPI FAST_IO_MDL_READ)( - IN struct _FILE_OBJECT *FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN ULONG LockKey, - OUT PMDL *MdlChain, - OUT PIO_STATUS_BLOCK IoStatus, - IN struct _DEVICE_OBJECT *DeviceObject); -typedef FAST_IO_MDL_READ *PFAST_IO_MDL_READ; +(DDKAPI *PFAST_IO_MDL_READ)( + IN struct _FILE_OBJECT *FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN ULONG LockKey, + OUT PMDL *MdlChain, + OUT PIO_STATUS_BLOCK IoStatus, + IN struct _DEVICE_OBJECT *DeviceObject); typedef BOOLEAN -(NTAPI FAST_IO_MDL_READ_COMPLETE)( +(DDKAPI *PFAST_IO_MDL_READ_COMPLETE)( IN struct _FILE_OBJECT *FileObject, IN PMDL MdlChain, IN struct _DEVICE_OBJECT *DeviceObject); -typedef FAST_IO_MDL_READ_COMPLETE *PFAST_IO_MDL_READ_COMPLETE; typedef BOOLEAN -(NTAPI FAST_IO_PREPARE_MDL_WRITE)( - IN struct _FILE_OBJECT *FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN ULONG LockKey, - OUT PMDL *MdlChain, - OUT PIO_STATUS_BLOCK IoStatus, - IN struct _DEVICE_OBJECT *DeviceObject); -typedef FAST_IO_PREPARE_MDL_WRITE *PFAST_IO_PREPARE_MDL_WRITE; +(DDKAPI *PFAST_IO_PREPARE_MDL_WRITE)( + IN struct _FILE_OBJECT *FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN ULONG LockKey, + OUT PMDL *MdlChain, + OUT PIO_STATUS_BLOCK IoStatus, + IN struct _DEVICE_OBJECT *DeviceObject); typedef BOOLEAN -(NTAPI FAST_IO_MDL_WRITE_COMPLETE)( - IN struct _FILE_OBJECT *FileObject, - IN PLARGE_INTEGER FileOffset, - IN PMDL MdlChain, - IN struct _DEVICE_OBJECT *DeviceObject); -typedef FAST_IO_MDL_WRITE_COMPLETE *PFAST_IO_MDL_WRITE_COMPLETE; +(DDKAPI *PFAST_IO_MDL_WRITE_COMPLETE)( + IN struct _FILE_OBJECT *FileObject, + IN PLARGE_INTEGER FileOffset, + IN PMDL MdlChain, + IN struct _DEVICE_OBJECT *DeviceObject); typedef BOOLEAN -(NTAPI FAST_IO_READ_COMPRESSED)( - IN struct _FILE_OBJECT *FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN ULONG LockKey, - OUT PVOID Buffer, - OUT PMDL *MdlChain, - OUT PIO_STATUS_BLOCK IoStatus, - OUT struct _COMPRESSED_DATA_INFO *CompressedDataInfo, - IN ULONG CompressedDataInfoLength, - IN struct _DEVICE_OBJECT *DeviceObject); -typedef FAST_IO_READ_COMPRESSED *PFAST_IO_READ_COMPRESSED; +(DDKAPI *PFAST_IO_READ_COMPRESSED)( + IN struct _FILE_OBJECT *FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN ULONG LockKey, + OUT PVOID Buffer, + OUT PMDL *MdlChain, + OUT PIO_STATUS_BLOCK IoStatus, + OUT struct _COMPRESSED_DATA_INFO *CompressedDataInfo, + IN ULONG CompressedDataInfoLength, + IN struct _DEVICE_OBJECT *DeviceObject); typedef BOOLEAN -(NTAPI FAST_IO_WRITE_COMPRESSED)( - IN struct _FILE_OBJECT *FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN ULONG LockKey, - IN PVOID Buffer, - OUT PMDL *MdlChain, - OUT PIO_STATUS_BLOCK IoStatus, - IN struct _COMPRESSED_DATA_INFO *CompressedDataInfo, - IN ULONG CompressedDataInfoLength, - IN struct _DEVICE_OBJECT *DeviceObject); -typedef FAST_IO_WRITE_COMPRESSED *PFAST_IO_WRITE_COMPRESSED; +(DDKAPI *PFAST_IO_WRITE_COMPRESSED)( + IN struct _FILE_OBJECT *FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN ULONG LockKey, + IN PVOID Buffer, + OUT PMDL *MdlChain, + OUT PIO_STATUS_BLOCK IoStatus, + IN struct _COMPRESSED_DATA_INFO *CompressedDataInfo, + IN ULONG CompressedDataInfoLength, + IN struct _DEVICE_OBJECT *DeviceObject); typedef BOOLEAN -(NTAPI FAST_IO_MDL_READ_COMPLETE_COMPRESSED)( - IN struct _FILE_OBJECT *FileObject, - IN PMDL MdlChain, - IN struct _DEVICE_OBJECT *DeviceObject); -typedef FAST_IO_MDL_READ_COMPLETE_COMPRESSED *PFAST_IO_MDL_READ_COMPLETE_COMPRESSED; +(DDKAPI *PFAST_IO_MDL_READ_COMPLETE_COMPRESSED)( + IN struct _FILE_OBJECT *FileObject, + IN PMDL MdlChain, + IN struct _DEVICE_OBJECT *DeviceObject); typedef BOOLEAN -(NTAPI FAST_IO_MDL_WRITE_COMPLETE_COMPRESSED)( - IN struct _FILE_OBJECT *FileObject, - IN PLARGE_INTEGER FileOffset, - IN PMDL MdlChain, - IN struct _DEVICE_OBJECT *DeviceObject); -typedef FAST_IO_MDL_WRITE_COMPLETE_COMPRESSED *PFAST_IO_MDL_WRITE_COMPLETE_COMPRESSED; +(DDKAPI *PFAST_IO_MDL_WRITE_COMPLETE_COMPRESSED)( + IN struct _FILE_OBJECT *FileObject, + IN PLARGE_INTEGER FileOffset, + IN PMDL MdlChain, + IN struct _DEVICE_OBJECT *DeviceObject); typedef BOOLEAN -(NTAPI FAST_IO_QUERY_OPEN)( - IN struct _IRP *Irp, - OUT PFILE_NETWORK_OPEN_INFORMATION NetworkInformation, - IN struct _DEVICE_OBJECT *DeviceObject); -typedef FAST_IO_QUERY_OPEN *PFAST_IO_QUERY_OPEN; +(DDKAPI *PFAST_IO_QUERY_OPEN)( + IN struct _IRP *Irp, + OUT PFILE_NETWORK_OPEN_INFORMATION NetworkInformation, + IN struct _DEVICE_OBJECT *DeviceObject); typedef NTSTATUS -(NTAPI FAST_IO_RELEASE_FOR_MOD_WRITE)( - IN struct _FILE_OBJECT *FileObject, - IN struct _ERESOURCE *ResourceToRelease, - IN struct _DEVICE_OBJECT *DeviceObject); -typedef FAST_IO_RELEASE_FOR_MOD_WRITE *PFAST_IO_RELEASE_FOR_MOD_WRITE; +(DDKAPI *PFAST_IO_RELEASE_FOR_MOD_WRITE)( + IN struct _FILE_OBJECT *FileObject, + IN struct _ERESOURCE *ResourceToRelease, + IN struct _DEVICE_OBJECT *DeviceObject); typedef NTSTATUS -(NTAPI FAST_IO_ACQUIRE_FOR_CCFLUSH)( - IN struct _FILE_OBJECT *FileObject, - IN struct _DEVICE_OBJECT *DeviceObject); -typedef FAST_IO_ACQUIRE_FOR_CCFLUSH *PFAST_IO_ACQUIRE_FOR_CCFLUSH; +(DDKAPI *PFAST_IO_ACQUIRE_FOR_CCFLUSH)( + IN struct _FILE_OBJECT *FileObject, + IN struct _DEVICE_OBJECT *DeviceObject); typedef NTSTATUS -(NTAPI FAST_IO_RELEASE_FOR_CCFLUSH)( - IN struct _FILE_OBJECT *FileObject, - IN struct _DEVICE_OBJECT *DeviceObject); -typedef FAST_IO_RELEASE_FOR_CCFLUSH *PFAST_IO_RELEASE_FOR_CCFLUSH; +(DDKAPI *PFAST_IO_RELEASE_FOR_CCFLUSH) ( + IN struct _FILE_OBJECT *FileObject, + IN struct _DEVICE_OBJECT *DeviceObject); typedef struct _FAST_IO_DISPATCH { - ULONG SizeOfFastIoDispatch; - PFAST_IO_CHECK_IF_POSSIBLE FastIoCheckIfPossible; - PFAST_IO_READ FastIoRead; - PFAST_IO_WRITE FastIoWrite; - PFAST_IO_QUERY_BASIC_INFO FastIoQueryBasicInfo; - PFAST_IO_QUERY_STANDARD_INFO FastIoQueryStandardInfo; - PFAST_IO_LOCK FastIoLock; - PFAST_IO_UNLOCK_SINGLE FastIoUnlockSingle; - PFAST_IO_UNLOCK_ALL FastIoUnlockAll; - PFAST_IO_UNLOCK_ALL_BY_KEY FastIoUnlockAllByKey; - PFAST_IO_DEVICE_CONTROL FastIoDeviceControl; - PFAST_IO_ACQUIRE_FILE AcquireFileForNtCreateSection; - PFAST_IO_RELEASE_FILE ReleaseFileForNtCreateSection; - PFAST_IO_DETACH_DEVICE FastIoDetachDevice; - PFAST_IO_QUERY_NETWORK_OPEN_INFO FastIoQueryNetworkOpenInfo; - PFAST_IO_ACQUIRE_FOR_MOD_WRITE AcquireForModWrite; - PFAST_IO_MDL_READ MdlRead; - PFAST_IO_MDL_READ_COMPLETE MdlReadComplete; - PFAST_IO_PREPARE_MDL_WRITE PrepareMdlWrite; - PFAST_IO_MDL_WRITE_COMPLETE MdlWriteComplete; - PFAST_IO_READ_COMPRESSED FastIoReadCompressed; - PFAST_IO_WRITE_COMPRESSED FastIoWriteCompressed; - PFAST_IO_MDL_READ_COMPLETE_COMPRESSED MdlReadCompleteCompressed; - PFAST_IO_MDL_WRITE_COMPLETE_COMPRESSED MdlWriteCompleteCompressed; - PFAST_IO_QUERY_OPEN FastIoQueryOpen; - PFAST_IO_RELEASE_FOR_MOD_WRITE ReleaseForModWrite; - PFAST_IO_ACQUIRE_FOR_CCFLUSH AcquireForCcFlush; - PFAST_IO_RELEASE_FOR_CCFLUSH ReleaseForCcFlush; + ULONG SizeOfFastIoDispatch; + PFAST_IO_CHECK_IF_POSSIBLE FastIoCheckIfPossible; + PFAST_IO_READ FastIoRead; + PFAST_IO_WRITE FastIoWrite; + PFAST_IO_QUERY_BASIC_INFO FastIoQueryBasicInfo; + PFAST_IO_QUERY_STANDARD_INFO FastIoQueryStandardInfo; + PFAST_IO_LOCK FastIoLock; + PFAST_IO_UNLOCK_SINGLE FastIoUnlockSingle; + PFAST_IO_UNLOCK_ALL FastIoUnlockAll; + PFAST_IO_UNLOCK_ALL_BY_KEY FastIoUnlockAllByKey; + PFAST_IO_DEVICE_CONTROL FastIoDeviceControl; + PFAST_IO_ACQUIRE_FILE AcquireFileForNtCreateSection; + PFAST_IO_RELEASE_FILE ReleaseFileForNtCreateSection; + PFAST_IO_DETACH_DEVICE FastIoDetachDevice; + PFAST_IO_QUERY_NETWORK_OPEN_INFO FastIoQueryNetworkOpenInfo; + PFAST_IO_ACQUIRE_FOR_MOD_WRITE AcquireForModWrite; + PFAST_IO_MDL_READ MdlRead; + PFAST_IO_MDL_READ_COMPLETE MdlReadComplete; + PFAST_IO_PREPARE_MDL_WRITE PrepareMdlWrite; + PFAST_IO_MDL_WRITE_COMPLETE MdlWriteComplete; + PFAST_IO_READ_COMPRESSED FastIoReadCompressed; + PFAST_IO_WRITE_COMPRESSED FastIoWriteCompressed; + PFAST_IO_MDL_READ_COMPLETE_COMPRESSED MdlReadCompleteCompressed; + PFAST_IO_MDL_WRITE_COMPLETE_COMPRESSED MdlWriteCompleteCompressed; + PFAST_IO_QUERY_OPEN FastIoQueryOpen; + PFAST_IO_RELEASE_FOR_MOD_WRITE ReleaseForModWrite; + PFAST_IO_ACQUIRE_FOR_CCFLUSH AcquireForCcFlush; + PFAST_IO_RELEASE_FOR_CCFLUSH ReleaseForCcFlush; } FAST_IO_DISPATCH, *PFAST_IO_DISPATCH; typedef struct _SECTION_OBJECT_POINTERS { - PVOID DataSectionObject; - PVOID SharedCacheMap; - PVOID ImageSectionObject; + PVOID DataSectionObject; + PVOID SharedCacheMap; + PVOID ImageSectionObject; } SECTION_OBJECT_POINTERS, *PSECTION_OBJECT_POINTERS; typedef struct _IO_COMPLETION_CONTEXT { - PVOID Port; - PVOID Key; + PVOID Port; + PVOID Key; } IO_COMPLETION_CONTEXT, *PIO_COMPLETION_CONTEXT; /* FILE_OBJECT.Flags */ @@ -5406,7 +4175,6 @@ typedef struct _IO_COMPLETION_CONTEXT { #define FO_SKIP_COMPLETION_PORT 0x02000000 #define FO_SKIP_SET_EVENT 0x04000000 #define FO_SKIP_SET_FAST_IO 0x08000000 -#define FO_FLAGS_VALID_ONLY_DURING_CREATE FO_DISALLOW_EXCLUSIVE /* VPB.Flags */ #define VPB_MOUNTED 0x0001 @@ -5421,18 +4189,12 @@ typedef struct _IO_COMPLETION_CONTEXT { #define SL_FORCE_ACCESS_CHECK 0x01 #define SL_OPEN_PAGING_FILE 0x02 #define SL_OPEN_TARGET_DIRECTORY 0x04 -#define SL_STOP_ON_SYMLINK 0x08 #define SL_CASE_SENSITIVE 0x80 #define SL_KEY_SPECIFIED 0x01 #define SL_OVERRIDE_VERIFY_VOLUME 0x02 #define SL_WRITE_THROUGH 0x04 #define SL_FT_SEQUENTIAL_WRITE 0x08 -#define SL_FORCE_DIRECT_WRITE 0x10 -#define SL_REALTIME_STREAM 0x20 - -#define SL_READ_ACCESS_GRANTED 0x01 -#define SL_WRITE_ACCESS_GRANTED 0x04 #define SL_FAIL_IMMEDIATELY 0x01 #define SL_EXCLUSIVE_LOCK 0x02 @@ -5450,8 +4212,6 @@ typedef struct _IO_COMPLETION_CONTEXT { #define DEVICE_TYPE_FROM_CTL_CODE(ctl) (((ULONG) (ctl & 0xffff0000)) >> 16) -#define METHOD_FROM_CTL_CODE(ctrlCode) ((ULONG)(ctrlCode & 3)) - #define IRP_NOCACHE 0x00000001 #define IRP_PAGING_IO 0x00000002 #define IRP_MOUNT_COMPLETION 0x00000002 @@ -5537,9 +4297,6 @@ typedef struct _IO_COMPLETION_CONTEXT { #define IRP_MN_QUERY_BUS_INFORMATION 0x15 #define IRP_MN_DEVICE_USAGE_NOTIFICATION 0x16 #define IRP_MN_SURPRISE_REMOVAL 0x17 -#if (NTDDI_VERSION >= NTDDI_WIN7) -#define IRP_MN_DEVICE_ENUMERATED 0x19 -#endif #define IRP_MN_WAIT_WAKE 0x00 #define IRP_MN_POWER_SEQUENCE 0x01 @@ -5559,62 +4316,63 @@ typedef struct _IO_COMPLETION_CONTEXT { #define IRP_MN_REGINFO_EX 0x0b -typedef struct _FILE_OBJECT { - CSHORT Type; - CSHORT Size; - PDEVICE_OBJECT DeviceObject; - PVPB Vpb; - PVOID FsContext; - PVOID FsContext2; - PSECTION_OBJECT_POINTERS SectionObjectPointer; - PVOID PrivateCacheMap; - NTSTATUS FinalStatus; - struct _FILE_OBJECT *RelatedFileObject; - BOOLEAN LockOperation; - BOOLEAN DeletePending; - BOOLEAN ReadAccess; - BOOLEAN WriteAccess; - BOOLEAN DeleteAccess; - BOOLEAN SharedRead; - BOOLEAN SharedWrite; - BOOLEAN SharedDelete; - ULONG Flags; - UNICODE_STRING FileName; - LARGE_INTEGER CurrentByteOffset; - volatile ULONG Waiters; - volatile ULONG Busy; - PVOID LastLock; - KEVENT Lock; - KEVENT Event; - volatile PIO_COMPLETION_CONTEXT CompletionContext; - KSPIN_LOCK IrpListLock; - LIST_ENTRY IrpList; - volatile PVOID FileObjectExtension; +typedef struct _FILE_OBJECT +{ + CSHORT Type; + CSHORT Size; + PDEVICE_OBJECT DeviceObject; + PVPB Vpb; + PVOID FsContext; + PVOID FsContext2; + PSECTION_OBJECT_POINTERS SectionObjectPointer; + PVOID PrivateCacheMap; + NTSTATUS FinalStatus; + struct _FILE_OBJECT *RelatedFileObject; + BOOLEAN LockOperation; + BOOLEAN DeletePending; + BOOLEAN ReadAccess; + BOOLEAN WriteAccess; + BOOLEAN DeleteAccess; + BOOLEAN SharedRead; + BOOLEAN SharedWrite; + BOOLEAN SharedDelete; + ULONG Flags; + UNICODE_STRING FileName; + LARGE_INTEGER CurrentByteOffset; + volatile ULONG Waiters; + volatile ULONG Busy; + PVOID LastLock; + KEVENT Lock; + KEVENT Event; + volatile PIO_COMPLETION_CONTEXT CompletionContext; + KSPIN_LOCK IrpListLock; + LIST_ENTRY IrpList; + volatile PVOID FileObjectExtension; } FILE_OBJECT, *PFILE_OBJECT; typedef struct _IO_ERROR_LOG_PACKET { - UCHAR MajorFunctionCode; - UCHAR RetryCount; - USHORT DumpDataSize; - USHORT NumberOfStrings; - USHORT StringOffset; - USHORT EventCategory; - NTSTATUS ErrorCode; - ULONG UniqueErrorValue; - NTSTATUS FinalStatus; - ULONG SequenceNumber; - ULONG IoControlCode; - LARGE_INTEGER DeviceOffset; - ULONG DumpData[1]; + UCHAR MajorFunctionCode; + UCHAR RetryCount; + USHORT DumpDataSize; + USHORT NumberOfStrings; + USHORT StringOffset; + USHORT EventCategory; + NTSTATUS ErrorCode; + ULONG UniqueErrorValue; + NTSTATUS FinalStatus; + ULONG SequenceNumber; + ULONG IoControlCode; + LARGE_INTEGER DeviceOffset; + ULONG DumpData[1]; } IO_ERROR_LOG_PACKET, *PIO_ERROR_LOG_PACKET; typedef struct _IO_ERROR_LOG_MESSAGE { - USHORT Type; - USHORT Size; - USHORT DriverNameLength; - LARGE_INTEGER TimeStamp; - ULONG DriverNameOffset; - IO_ERROR_LOG_PACKET EntryData; + USHORT Type; + USHORT Size; + USHORT DriverNameLength; + LARGE_INTEGER TimeStamp; + ULONG DriverNameOffset; + IO_ERROR_LOG_PACKET EntryData; } IO_ERROR_LOG_MESSAGE, *PIO_ERROR_LOG_MESSAGE; #define ERROR_LOG_LIMIT_SIZE 240 @@ -5630,12 +4388,6 @@ typedef struct _IO_ERROR_LOG_MESSAGE { #define ERROR_LOG_MAXIMUM_SIZE (IO_ERROR_LOG_MESSAGE_LENGTH - \ IO_ERROR_LOG_MESSAGE_HEADER_LENGTH) -#ifdef _WIN64 -#define PORT_MAXIMUM_MESSAGE_LENGTH 512 -#else -#define PORT_MAXIMUM_MESSAGE_LENGTH 256 -#endif - typedef enum _DMA_WIDTH { Width8Bits, Width16Bits, @@ -5659,22 +4411,22 @@ typedef enum _DMA_SPEED { #define DEVICE_DESCRIPTION_VERSION2 0x0002 typedef struct _DEVICE_DESCRIPTION { - ULONG Version; - BOOLEAN Master; - BOOLEAN ScatterGather; - BOOLEAN DemandMode; - BOOLEAN AutoInitialize; - BOOLEAN Dma32BitAddresses; - BOOLEAN IgnoreCount; - BOOLEAN Reserved1; - BOOLEAN Dma64BitAddresses; - ULONG BusNumber; - ULONG DmaChannel; - INTERFACE_TYPE InterfaceType; - DMA_WIDTH DmaWidth; - DMA_SPEED DmaSpeed; - ULONG MaximumLength; - ULONG DmaPort; + ULONG Version; + BOOLEAN Master; + BOOLEAN ScatterGather; + BOOLEAN DemandMode; + BOOLEAN AutoInitialize; + BOOLEAN Dma32BitAddresses; + BOOLEAN IgnoreCount; + BOOLEAN Reserved1; + BOOLEAN Dma64BitAddresses; + ULONG BusNumber; + ULONG DmaChannel; + INTERFACE_TYPE InterfaceType; + DMA_WIDTH DmaWidth; + DMA_SPEED DmaSpeed; + ULONG MaximumLength; + ULONG DmaPort; } DEVICE_DESCRIPTION, *PDEVICE_DESCRIPTION; typedef enum _DEVICE_RELATION_TYPE { @@ -5688,20 +4440,21 @@ typedef enum _DEVICE_RELATION_TYPE { } DEVICE_RELATION_TYPE, *PDEVICE_RELATION_TYPE; typedef struct _DEVICE_RELATIONS { - ULONG Count; + ULONG Count; PDEVICE_OBJECT Objects[1]; } DEVICE_RELATIONS, *PDEVICE_RELATIONS; -typedef struct _DEVOBJ_EXTENSION { - CSHORT Type; - USHORT Size; - PDEVICE_OBJECT DeviceObject; +typedef struct _DEVOBJ_EXTENSION +{ + CSHORT Type; + USHORT Size; + PDEVICE_OBJECT DeviceObject; } DEVOBJ_EXTENSION, *PDEVOBJ_EXTENSION; typedef struct _SCATTER_GATHER_ELEMENT { - PHYSICAL_ADDRESS Address; - ULONG Length; - ULONG_PTR Reserved; + PHYSICAL_ADDRESS Address; + ULONG Length; + ULONG_PTR Reserved; } SCATTER_GATHER_ELEMENT, *PSCATTER_GATHER_ELEMENT; #if defined(_MSC_EXTENSIONS) @@ -5711,9 +4464,9 @@ typedef struct _SCATTER_GATHER_ELEMENT { #endif #pragma warning(disable:4200) typedef struct _SCATTER_GATHER_LIST { - ULONG NumberOfElements; - ULONG_PTR Reserved; - SCATTER_GATHER_ELEMENT Elements[1]; + ULONG NumberOfElements; + ULONG_PTR Reserved; + SCATTER_GATHER_ELEMENT Elements[1]; } SCATTER_GATHER_LIST, *PSCATTER_GATHER_LIST; #if _MSC_VER >= 1200 @@ -5730,16 +4483,16 @@ typedef struct _SCATTER_GATHER_LIST SCATTER_GATHER_LIST, *PSCATTER_GATHER_LIST; #endif typedef NTSTATUS -(NTAPI DRIVER_ADD_DEVICE)( - IN struct _DRIVER_OBJECT *DriverObject, - IN struct _DEVICE_OBJECT *PhysicalDeviceObject); +(DDKAPI DRIVER_ADD_DEVICE)( + IN struct _DRIVER_OBJECT *DriverObject, + IN struct _DEVICE_OBJECT *PhysicalDeviceObject); typedef DRIVER_ADD_DEVICE *PDRIVER_ADD_DEVICE; typedef struct _DRIVER_EXTENSION { - struct _DRIVER_OBJECT *DriverObject; - PDRIVER_ADD_DEVICE AddDevice; - ULONG Count; - UNICODE_STRING ServiceKeyName; + struct _DRIVER_OBJECT *DriverObject; + PDRIVER_ADD_DEVICE AddDevice; + ULONG Count; + UNICODE_STRING ServiceKeyName; } DRIVER_EXTENSION, *PDRIVER_EXTENSION; #define DRVO_UNLOAD_INVOKED 0x00000001 @@ -5747,319 +4500,320 @@ typedef struct _DRIVER_EXTENSION { #define DRVO_BUILTIN_DRIVER 0x00000004 typedef NTSTATUS -(NTAPI DRIVER_INITIALIZE)( - IN struct _DRIVER_OBJECT *DriverObject, - IN PUNICODE_STRING RegistryPath); +(DDKAPI DRIVER_INITIALIZE)( + IN struct _DRIVER_OBJECT *DriverObject, + IN PUNICODE_STRING RegistryPath); typedef DRIVER_INITIALIZE *PDRIVER_INITIALIZE; typedef VOID -(NTAPI DRIVER_STARTIO)( - IN struct _DEVICE_OBJECT *DeviceObject, - IN struct _IRP *Irp); +(DDKAPI DRIVER_STARTIO)( + IN struct _DEVICE_OBJECT *DeviceObject, + IN struct _IRP *Irp); typedef DRIVER_STARTIO *PDRIVER_STARTIO; typedef VOID -(NTAPI DRIVER_UNLOAD)( - IN struct _DRIVER_OBJECT *DriverObject); +(DDKAPI DRIVER_UNLOAD)( + IN struct _DRIVER_OBJECT *DriverObject); typedef DRIVER_UNLOAD *PDRIVER_UNLOAD; typedef NTSTATUS -(NTAPI DRIVER_DISPATCH)( - IN struct _DEVICE_OBJECT *DeviceObject, - IN struct _IRP *Irp); +(DDKAPI DRIVER_DISPATCH)( + IN struct _DEVICE_OBJECT *DeviceObject, + IN struct _IRP *Irp); typedef DRIVER_DISPATCH *PDRIVER_DISPATCH; typedef struct _DRIVER_OBJECT { - CSHORT Type; - CSHORT Size; - PDEVICE_OBJECT DeviceObject; - ULONG Flags; - PVOID DriverStart; - ULONG DriverSize; - PVOID DriverSection; - PDRIVER_EXTENSION DriverExtension; - UNICODE_STRING DriverName; - PUNICODE_STRING HardwareDatabase; + CSHORT Type; + CSHORT Size; + PDEVICE_OBJECT DeviceObject; + ULONG Flags; + PVOID DriverStart; + ULONG DriverSize; + PVOID DriverSection; + PDRIVER_EXTENSION DriverExtension; + UNICODE_STRING DriverName; + PUNICODE_STRING HardwareDatabase; struct _FAST_IO_DISPATCH *FastIoDispatch; - PDRIVER_INITIALIZE DriverInit; - PDRIVER_STARTIO DriverStartIo; - PDRIVER_UNLOAD DriverUnload; - PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION + 1]; -} DRIVER_OBJECT, *PDRIVER_OBJECT; + PDRIVER_INITIALIZE DriverInit; + PDRIVER_STARTIO DriverStartIo; + PDRIVER_UNLOAD DriverUnload; + PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION + 1]; +} DRIVER_OBJECT; +typedef struct _DRIVER_OBJECT *PDRIVER_OBJECT; typedef struct _DMA_ADAPTER { - USHORT Version; - USHORT Size; - struct _DMA_OPERATIONS* DmaOperations; + USHORT Version; + USHORT Size; + struct _DMA_OPERATIONS* DmaOperations; } DMA_ADAPTER, *PDMA_ADAPTER; typedef VOID -(NTAPI *PPUT_DMA_ADAPTER)( - IN PDMA_ADAPTER DmaAdapter); +(DDKAPI *PPUT_DMA_ADAPTER)( + IN PDMA_ADAPTER DmaAdapter); typedef PVOID -(NTAPI *PALLOCATE_COMMON_BUFFER)( - IN PDMA_ADAPTER DmaAdapter, - IN ULONG Length, - OUT PPHYSICAL_ADDRESS LogicalAddress, - IN BOOLEAN CacheEnabled); +(DDKAPI *PALLOCATE_COMMON_BUFFER)( + IN PDMA_ADAPTER DmaAdapter, + IN ULONG Length, + OUT PPHYSICAL_ADDRESS LogicalAddress, + IN BOOLEAN CacheEnabled); typedef VOID -(NTAPI *PFREE_COMMON_BUFFER)( - IN PDMA_ADAPTER DmaAdapter, - IN ULONG Length, - IN PHYSICAL_ADDRESS LogicalAddress, - IN PVOID VirtualAddress, - IN BOOLEAN CacheEnabled); +(DDKAPI *PFREE_COMMON_BUFFER)( + IN PDMA_ADAPTER DmaAdapter, + IN ULONG Length, + IN PHYSICAL_ADDRESS LogicalAddress, + IN PVOID VirtualAddress, + IN BOOLEAN CacheEnabled); typedef NTSTATUS -(NTAPI *PALLOCATE_ADAPTER_CHANNEL)( - IN PDMA_ADAPTER DmaAdapter, - IN PDEVICE_OBJECT DeviceObject, - IN ULONG NumberOfMapRegisters, - IN PDRIVER_CONTROL ExecutionRoutine, - IN PVOID Context); +(DDKAPI *PALLOCATE_ADAPTER_CHANNEL)( + IN PDMA_ADAPTER DmaAdapter, + IN PDEVICE_OBJECT DeviceObject, + IN ULONG NumberOfMapRegisters, + IN PDRIVER_CONTROL ExecutionRoutine, + IN PVOID Context); typedef BOOLEAN -(NTAPI *PFLUSH_ADAPTER_BUFFERS)( - IN PDMA_ADAPTER DmaAdapter, - IN PMDL Mdl, - IN PVOID MapRegisterBase, - IN PVOID CurrentVa, - IN ULONG Length, - IN BOOLEAN WriteToDevice); +(DDKAPI *PFLUSH_ADAPTER_BUFFERS)( + IN PDMA_ADAPTER DmaAdapter, + IN PMDL Mdl, + IN PVOID MapRegisterBase, + IN PVOID CurrentVa, + IN ULONG Length, + IN BOOLEAN WriteToDevice); typedef VOID -(NTAPI *PFREE_ADAPTER_CHANNEL)( - IN PDMA_ADAPTER DmaAdapter); +(DDKAPI *PFREE_ADAPTER_CHANNEL)( + IN PDMA_ADAPTER DmaAdapter); typedef VOID -(NTAPI *PFREE_MAP_REGISTERS)( - IN PDMA_ADAPTER DmaAdapter, - PVOID MapRegisterBase, - ULONG NumberOfMapRegisters); +(DDKAPI *PFREE_MAP_REGISTERS)( + IN PDMA_ADAPTER DmaAdapter, + PVOID MapRegisterBase, + ULONG NumberOfMapRegisters); typedef PHYSICAL_ADDRESS -(NTAPI *PMAP_TRANSFER)( - IN PDMA_ADAPTER DmaAdapter, - IN PMDL Mdl, - IN PVOID MapRegisterBase, - IN PVOID CurrentVa, - IN OUT PULONG Length, - IN BOOLEAN WriteToDevice); +(DDKAPI *PMAP_TRANSFER)( + IN PDMA_ADAPTER DmaAdapter, + IN PMDL Mdl, + IN PVOID MapRegisterBase, + IN PVOID CurrentVa, + IN OUT PULONG Length, + IN BOOLEAN WriteToDevice); typedef ULONG -(NTAPI *PGET_DMA_ALIGNMENT)( - IN PDMA_ADAPTER DmaAdapter); +(DDKAPI *PGET_DMA_ALIGNMENT)( + IN PDMA_ADAPTER DmaAdapter); typedef ULONG -(NTAPI *PREAD_DMA_COUNTER)( - IN PDMA_ADAPTER DmaAdapter); +(DDKAPI *PREAD_DMA_COUNTER)( + IN PDMA_ADAPTER DmaAdapter); typedef VOID -(NTAPI DRIVER_LIST_CONTROL)( - IN struct _DEVICE_OBJECT *DeviceObject, - IN struct _IRP *Irp, - IN struct _SCATTER_GATHER_LIST *ScatterGather, - IN PVOID Context); -typedef DRIVER_LIST_CONTROL *PDRIVER_LIST_CONTROL; +(DDKAPI *PDRIVER_LIST_CONTROL)( + IN struct _DEVICE_OBJECT *DeviceObject, + IN struct _IRP *Irp, + IN struct _SCATTER_GATHER_LIST *ScatterGather, + IN PVOID Context); typedef NTSTATUS -(NTAPI *PGET_SCATTER_GATHER_LIST)( - IN PDMA_ADAPTER DmaAdapter, - IN PDEVICE_OBJECT DeviceObject, - IN PMDL Mdl, - IN PVOID CurrentVa, - IN ULONG Length, - IN PDRIVER_LIST_CONTROL ExecutionRoutine, - IN PVOID Context, - IN BOOLEAN WriteToDevice); +(DDKAPI *PGET_SCATTER_GATHER_LIST)( + IN PDMA_ADAPTER DmaAdapter, + IN PDEVICE_OBJECT DeviceObject, + IN PMDL Mdl, + IN PVOID CurrentVa, + IN ULONG Length, + IN PDRIVER_LIST_CONTROL ExecutionRoutine, + IN PVOID Context, + IN BOOLEAN WriteToDevice); typedef VOID -(NTAPI *PPUT_SCATTER_GATHER_LIST)( - IN PDMA_ADAPTER DmaAdapter, - IN PSCATTER_GATHER_LIST ScatterGather, - IN BOOLEAN WriteToDevice); +(DDKAPI *PPUT_SCATTER_GATHER_LIST)( + IN PDMA_ADAPTER DmaAdapter, + IN PSCATTER_GATHER_LIST ScatterGather, + IN BOOLEAN WriteToDevice); typedef NTSTATUS -(NTAPI *PCALCULATE_SCATTER_GATHER_LIST_SIZE)( - IN PDMA_ADAPTER DmaAdapter, - IN PMDL Mdl OPTIONAL, - IN PVOID CurrentVa, - IN ULONG Length, - OUT PULONG ScatterGatherListSize, - OUT PULONG pNumberOfMapRegisters OPTIONAL); +(DDKAPI *PCALCULATE_SCATTER_GATHER_LIST_SIZE)( + IN PDMA_ADAPTER DmaAdapter, + IN PMDL Mdl OPTIONAL, + IN PVOID CurrentVa, + IN ULONG Length, + OUT PULONG ScatterGatherListSize, + OUT PULONG pNumberOfMapRegisters OPTIONAL); typedef NTSTATUS -(NTAPI *PBUILD_SCATTER_GATHER_LIST)( - IN PDMA_ADAPTER DmaAdapter, - IN PDEVICE_OBJECT DeviceObject, - IN PMDL Mdl, - IN PVOID CurrentVa, - IN ULONG Length, - IN PDRIVER_LIST_CONTROL ExecutionRoutine, - IN PVOID Context, - IN BOOLEAN WriteToDevice, - IN PVOID ScatterGatherBuffer, - IN ULONG ScatterGatherLength); +(DDKAPI *PBUILD_SCATTER_GATHER_LIST)( + IN PDMA_ADAPTER DmaAdapter, + IN PDEVICE_OBJECT DeviceObject, + IN PMDL Mdl, + IN PVOID CurrentVa, + IN ULONG Length, + IN PDRIVER_LIST_CONTROL ExecutionRoutine, + IN PVOID Context, + IN BOOLEAN WriteToDevice, + IN PVOID ScatterGatherBuffer, + IN ULONG ScatterGatherLength); typedef NTSTATUS -(NTAPI *PBUILD_MDL_FROM_SCATTER_GATHER_LIST)( - IN PDMA_ADAPTER DmaAdapter, - IN PSCATTER_GATHER_LIST ScatterGather, - IN PMDL OriginalMdl, - OUT PMDL *TargetMdl); +(DDKAPI *PBUILD_MDL_FROM_SCATTER_GATHER_LIST)( + IN PDMA_ADAPTER DmaAdapter, + IN PSCATTER_GATHER_LIST ScatterGather, + IN PMDL OriginalMdl, + OUT PMDL *TargetMdl); typedef struct _DMA_OPERATIONS { - ULONG Size; - PPUT_DMA_ADAPTER PutDmaAdapter; - PALLOCATE_COMMON_BUFFER AllocateCommonBuffer; - PFREE_COMMON_BUFFER FreeCommonBuffer; - PALLOCATE_ADAPTER_CHANNEL AllocateAdapterChannel; - PFLUSH_ADAPTER_BUFFERS FlushAdapterBuffers; - PFREE_ADAPTER_CHANNEL FreeAdapterChannel; - PFREE_MAP_REGISTERS FreeMapRegisters; - PMAP_TRANSFER MapTransfer; - PGET_DMA_ALIGNMENT GetDmaAlignment; - PREAD_DMA_COUNTER ReadDmaCounter; - PGET_SCATTER_GATHER_LIST GetScatterGatherList; - PPUT_SCATTER_GATHER_LIST PutScatterGatherList; - PCALCULATE_SCATTER_GATHER_LIST_SIZE CalculateScatterGatherList; - PBUILD_SCATTER_GATHER_LIST BuildScatterGatherList; - PBUILD_MDL_FROM_SCATTER_GATHER_LIST BuildMdlFromScatterGatherList; + ULONG Size; + PPUT_DMA_ADAPTER PutDmaAdapter; + PALLOCATE_COMMON_BUFFER AllocateCommonBuffer; + PFREE_COMMON_BUFFER FreeCommonBuffer; + PALLOCATE_ADAPTER_CHANNEL AllocateAdapterChannel; + PFLUSH_ADAPTER_BUFFERS FlushAdapterBuffers; + PFREE_ADAPTER_CHANNEL FreeAdapterChannel; + PFREE_MAP_REGISTERS FreeMapRegisters; + PMAP_TRANSFER MapTransfer; + PGET_DMA_ALIGNMENT GetDmaAlignment; + PREAD_DMA_COUNTER ReadDmaCounter; + PGET_SCATTER_GATHER_LIST GetScatterGatherList; + PPUT_SCATTER_GATHER_LIST PutScatterGatherList; + PCALCULATE_SCATTER_GATHER_LIST_SIZE CalculateScatterGatherList; + PBUILD_SCATTER_GATHER_LIST BuildScatterGatherList; + PBUILD_MDL_FROM_SCATTER_GATHER_LIST BuildMdlFromScatterGatherList; } DMA_OPERATIONS, *PDMA_OPERATIONS; typedef struct _IO_RESOURCE_DESCRIPTOR { - UCHAR Option; - UCHAR Type; - UCHAR ShareDisposition; - UCHAR Spare1; - USHORT Flags; - USHORT Spare2; + UCHAR Option; + UCHAR Type; + UCHAR ShareDisposition; + UCHAR Spare1; + USHORT Flags; + USHORT Spare2; union { struct { - ULONG Length; - ULONG Alignment; - PHYSICAL_ADDRESS MinimumAddress; - PHYSICAL_ADDRESS MaximumAddress; + ULONG Length; + ULONG Alignment; + PHYSICAL_ADDRESS MinimumAddress; + PHYSICAL_ADDRESS MaximumAddress; } Port; struct { - ULONG Length; - ULONG Alignment; - PHYSICAL_ADDRESS MinimumAddress; - PHYSICAL_ADDRESS MaximumAddress; + ULONG Length; + ULONG Alignment; + PHYSICAL_ADDRESS MinimumAddress; + PHYSICAL_ADDRESS MaximumAddress; } Memory; struct { - ULONG MinimumVector; - ULONG MaximumVector; + ULONG MinimumVector; + ULONG MaximumVector; } Interrupt; struct { - ULONG MinimumChannel; - ULONG MaximumChannel; + ULONG MinimumChannel; + ULONG MaximumChannel; } Dma; struct { - ULONG Length; - ULONG Alignment; - PHYSICAL_ADDRESS MinimumAddress; - PHYSICAL_ADDRESS MaximumAddress; + ULONG Length; + ULONG Alignment; + PHYSICAL_ADDRESS MinimumAddress; + PHYSICAL_ADDRESS MaximumAddress; } Generic; struct { - ULONG Data[3]; + ULONG Data[3]; } DevicePrivate; struct { - ULONG Length; - ULONG MinBusNumber; - ULONG MaxBusNumber; - ULONG Reserved; + ULONG Length; + ULONG MinBusNumber; + ULONG MaxBusNumber; + ULONG Reserved; } BusNumber; struct { - ULONG Priority; - ULONG Reserved1; - ULONG Reserved2; + ULONG Priority; + ULONG Reserved1; + ULONG Reserved2; } ConfigData; } u; } IO_RESOURCE_DESCRIPTOR, *PIO_RESOURCE_DESCRIPTOR; typedef struct _IO_RESOURCE_LIST { - USHORT Version; - USHORT Revision; - ULONG Count; - IO_RESOURCE_DESCRIPTOR Descriptors[1]; + USHORT Version; + USHORT Revision; + ULONG Count; + IO_RESOURCE_DESCRIPTOR Descriptors[1]; } IO_RESOURCE_LIST, *PIO_RESOURCE_LIST; typedef struct _IO_RESOURCE_REQUIREMENTS_LIST { - ULONG ListSize; - INTERFACE_TYPE InterfaceType; - ULONG BusNumber; - ULONG SlotNumber; - ULONG Reserved[3]; - ULONG AlternativeLists; - IO_RESOURCE_LIST List[1]; + ULONG ListSize; + INTERFACE_TYPE InterfaceType; + ULONG BusNumber; + ULONG SlotNumber; + ULONG Reserved[3]; + ULONG AlternativeLists; + IO_RESOURCE_LIST List[1]; } IO_RESOURCE_REQUIREMENTS_LIST, *PIO_RESOURCE_REQUIREMENTS_LIST; typedef VOID -(NTAPI DRIVER_CANCEL)( - IN struct _DEVICE_OBJECT *DeviceObject, - IN struct _IRP *Irp); +(DDKAPI DRIVER_CANCEL)( + IN struct _DEVICE_OBJECT *DeviceObject, + IN struct _IRP *Irp); typedef DRIVER_CANCEL *PDRIVER_CANCEL; typedef struct _IRP { - CSHORT Type; - USHORT Size; - struct _MDL *MdlAddress; - ULONG Flags; + CSHORT Type; + USHORT Size; + struct _MDL *MdlAddress; + ULONG Flags; union { - struct _IRP *MasterIrp; - volatile LONG IrpCount; - PVOID SystemBuffer; + struct _IRP *MasterIrp; + volatile LONG IrpCount; + PVOID SystemBuffer; } AssociatedIrp; - LIST_ENTRY ThreadListEntry; - IO_STATUS_BLOCK IoStatus; - KPROCESSOR_MODE RequestorMode; - BOOLEAN PendingReturned; - CHAR StackCount; - CHAR CurrentLocation; - BOOLEAN Cancel; - KIRQL CancelIrql; - CCHAR ApcEnvironment; - UCHAR AllocationFlags; - PIO_STATUS_BLOCK UserIosb; - PKEVENT UserEvent; + LIST_ENTRY ThreadListEntry; + IO_STATUS_BLOCK IoStatus; + KPROCESSOR_MODE RequestorMode; + BOOLEAN PendingReturned; + CHAR StackCount; + CHAR CurrentLocation; + BOOLEAN Cancel; + KIRQL CancelIrql; + CCHAR ApcEnvironment; + UCHAR AllocationFlags; + PIO_STATUS_BLOCK UserIosb; + PKEVENT UserEvent; union { struct { - _ANONYMOUS_UNION union { - PIO_APC_ROUTINE UserApcRoutine; + _ANONYMOUS_UNION union { + PIO_APC_ROUTINE UserApcRoutine; PVOID IssuingProcess; } DUMMYUNIONNAME; - PVOID UserApcContext; + PVOID UserApcContext; } AsynchronousParameters; - LARGE_INTEGER AllocationSize; + LARGE_INTEGER AllocationSize; } Overlay; - volatile PDRIVER_CANCEL CancelRoutine; - PVOID UserBuffer; + volatile PDRIVER_CANCEL CancelRoutine; + PVOID UserBuffer; union { struct { _ANONYMOUS_UNION union { - KDEVICE_QUEUE_ENTRY DeviceQueueEntry; + KDEVICE_QUEUE_ENTRY DeviceQueueEntry; _ANONYMOUS_STRUCT struct { - PVOID DriverContext[4]; + PVOID DriverContext[4]; } DUMMYSTRUCTNAME; } DUMMYUNIONNAME; - PETHREAD Thread; - PCHAR AuxiliaryBuffer; + PETHREAD Thread; + PCHAR AuxiliaryBuffer; _ANONYMOUS_STRUCT struct { - LIST_ENTRY ListEntry; + LIST_ENTRY ListEntry; _ANONYMOUS_UNION union { - struct _IO_STACK_LOCATION *CurrentStackLocation; - ULONG PacketType; + struct _IO_STACK_LOCATION *CurrentStackLocation; + ULONG PacketType; } DUMMYUNIONNAME; } DUMMYSTRUCTNAME; - struct _FILE_OBJECT *OriginalFileObject; + struct _FILE_OBJECT *OriginalFileObject; } Overlay; - KAPC Apc; - PVOID CompletionKey; + KAPC Apc; + PVOID CompletionKey; } Tail; -} IRP, *PIRP; +} IRP; +typedef struct _IRP *PIRP; typedef enum _IO_PAGING_PRIORITY { IoPagingPriorityInvalid, @@ -6070,96 +4824,93 @@ typedef enum _IO_PAGING_PRIORITY { } IO_PAGING_PRIORITY; typedef NTSTATUS -(NTAPI IO_COMPLETION_ROUTINE)( - IN struct _DEVICE_OBJECT *DeviceObject, - IN struct _IRP *Irp, - IN PVOID Context); +(DDKAPI IO_COMPLETION_ROUTINE)( + IN struct _DEVICE_OBJECT *DeviceObject, + IN struct _IRP *Irp, + IN PVOID Context); typedef IO_COMPLETION_ROUTINE *PIO_COMPLETION_ROUTINE; typedef VOID -(NTAPI IO_DPC_ROUTINE)( - IN struct _KDPC *Dpc, - IN struct _DEVICE_OBJECT *DeviceObject, - IN struct _IRP *Irp, - IN PVOID Context); -typedef IO_DPC_ROUTINE *PIO_DPC_ROUTINE; +(DDKAPI *PIO_DPC_ROUTINE)( + IN struct _KDPC *Dpc, + IN struct _DEVICE_OBJECT *DeviceObject, + IN struct _IRP *Irp, + IN PVOID Context); typedef NTSTATUS -(NTAPI *PMM_DLL_INITIALIZE)( - IN PUNICODE_STRING RegistryPath); +(DDKAPI *PMM_DLL_INITIALIZE)( + IN PUNICODE_STRING RegistryPath); typedef NTSTATUS -(NTAPI *PMM_DLL_UNLOAD)( +(DDKAPI *PMM_DLL_UNLOAD)( VOID); +typedef BOOLEAN +(DDKAPI KSERVICE_ROUTINE)( + IN struct _KINTERRUPT *Interrupt, + IN PVOID ServiceContext); +typedef KSERVICE_ROUTINE *PKSERVICE_ROUTINE; + typedef VOID -(NTAPI IO_TIMER_ROUTINE)( - IN struct _DEVICE_OBJECT *DeviceObject, - IN PVOID Context); -typedef IO_TIMER_ROUTINE *PIO_TIMER_ROUTINE; +(DDKAPI *PIO_TIMER_ROUTINE)( + IN struct _DEVICE_OBJECT *DeviceObject, + IN PVOID Context); typedef struct _IO_SECURITY_CONTEXT { - PSECURITY_QUALITY_OF_SERVICE SecurityQos; - PACCESS_STATE AccessState; - ACCESS_MASK DesiredAccess; - ULONG FullCreateOptions; + PSECURITY_QUALITY_OF_SERVICE SecurityQos; + PACCESS_STATE AccessState; + ACCESS_MASK DesiredAccess; + ULONG FullCreateOptions; } IO_SECURITY_CONTEXT, *PIO_SECURITY_CONTEXT; struct _IO_CSQ; typedef struct _IO_CSQ_IRP_CONTEXT { - ULONG Type; - struct _IRP *Irp; - struct _IO_CSQ *Csq; + ULONG Type; + struct _IRP *Irp; + struct _IO_CSQ *Csq; } IO_CSQ_IRP_CONTEXT, *PIO_CSQ_IRP_CONTEXT; typedef VOID -(NTAPI *PIO_CSQ_INSERT_IRP)( - IN struct _IO_CSQ *Csq, - IN PIRP Irp); - -typedef NTSTATUS -(NTAPI IO_CSQ_INSERT_IRP_EX)( - IN struct _IO_CSQ *Csq, - IN PIRP Irp, - IN PVOID InsertContext); -typedef IO_CSQ_INSERT_IRP_EX *PIO_CSQ_INSERT_IRP_EX; +(DDKAPI *PIO_CSQ_INSERT_IRP)( + IN struct _IO_CSQ *Csq, + IN PIRP Irp); typedef VOID -(NTAPI *PIO_CSQ_REMOVE_IRP)( - IN struct _IO_CSQ *Csq, - IN PIRP Irp); +(DDKAPI *PIO_CSQ_REMOVE_IRP)( + IN struct _IO_CSQ *Csq, + IN PIRP Irp); typedef PIRP -(NTAPI *PIO_CSQ_PEEK_NEXT_IRP)( - IN struct _IO_CSQ *Csq, - IN PIRP Irp, - IN PVOID PeekContext); +(DDKAPI *PIO_CSQ_PEEK_NEXT_IRP)( + IN struct _IO_CSQ *Csq, + IN PIRP Irp, + IN PVOID PeekContext); typedef VOID -(NTAPI *PIO_CSQ_ACQUIRE_LOCK)( - IN struct _IO_CSQ *Csq, - OUT PKIRQL Irql); +(DDKAPI *PIO_CSQ_ACQUIRE_LOCK)( + IN struct _IO_CSQ *Csq, + OUT PKIRQL Irql); typedef VOID -(NTAPI *PIO_CSQ_RELEASE_LOCK)( - IN struct _IO_CSQ *Csq, - IN KIRQL Irql); +(DDKAPI *PIO_CSQ_RELEASE_LOCK)( + IN struct _IO_CSQ *Csq, + IN KIRQL Irql); typedef VOID -(NTAPI *PIO_CSQ_COMPLETE_CANCELED_IRP)( - IN struct _IO_CSQ *Csq, - IN PIRP Irp); +(DDKAPI *PIO_CSQ_COMPLETE_CANCELED_IRP)( + IN struct _IO_CSQ *Csq, + IN PIRP Irp); typedef struct _IO_CSQ { - ULONG Type; - PIO_CSQ_INSERT_IRP CsqInsertIrp; - PIO_CSQ_REMOVE_IRP CsqRemoveIrp; - PIO_CSQ_PEEK_NEXT_IRP CsqPeekNextIrp; - PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock; - PIO_CSQ_RELEASE_LOCK CsqReleaseLock; - PIO_CSQ_COMPLETE_CANCELED_IRP CsqCompleteCanceledIrp; - PVOID ReservePointer; + ULONG Type; + PIO_CSQ_INSERT_IRP CsqInsertIrp; + PIO_CSQ_REMOVE_IRP CsqRemoveIrp; + PIO_CSQ_PEEK_NEXT_IRP CsqPeekNextIrp; + PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock; + PIO_CSQ_RELEASE_LOCK CsqReleaseLock; + PIO_CSQ_COMPLETE_CANCELED_IRP CsqCompleteCanceledIrp; + PVOID ReservePointer; } IO_CSQ, *PIO_CSQ; typedef enum _BUS_QUERY_ID_TYPE { @@ -6175,321 +4926,198 @@ typedef enum _DEVICE_TEXT_TYPE { DeviceTextLocationInformation } DEVICE_TEXT_TYPE, *PDEVICE_TEXT_TYPE; -typedef BOOLEAN -(NTAPI *PGPE_SERVICE_ROUTINE)( - PVOID, - PVOID); - -typedef NTSTATUS -(NTAPI *PGPE_CONNECT_VECTOR)( - PDEVICE_OBJECT, - ULONG, - KINTERRUPT_MODE, - BOOLEAN, - PGPE_SERVICE_ROUTINE, - PVOID, - PVOID); - -typedef NTSTATUS -(NTAPI *PGPE_DISCONNECT_VECTOR)( - PVOID); - -typedef NTSTATUS -(NTAPI *PGPE_ENABLE_EVENT)( - PDEVICE_OBJECT, - PVOID); - -typedef NTSTATUS -(NTAPI *PGPE_DISABLE_EVENT)( - PDEVICE_OBJECT, - PVOID); - -typedef NTSTATUS -(NTAPI *PGPE_CLEAR_STATUS)( - PDEVICE_OBJECT, - PVOID); - -typedef VOID -(NTAPI *PDEVICE_NOTIFY_CALLBACK)( - PVOID, - ULONG); - -typedef NTSTATUS -(NTAPI *PREGISTER_FOR_DEVICE_NOTIFICATIONS)( - PDEVICE_OBJECT, - PDEVICE_NOTIFY_CALLBACK, - PVOID); - -typedef VOID -(NTAPI *PUNREGISTER_FOR_DEVICE_NOTIFICATIONS)( - PDEVICE_OBJECT, - PDEVICE_NOTIFY_CALLBACK); - -typedef struct _ACPI_INTERFACE_STANDARD { - USHORT Size; - USHORT Version; - PVOID Context; - PINTERFACE_REFERENCE InterfaceReference; - PINTERFACE_DEREFERENCE InterfaceDereference; - PGPE_CONNECT_VECTOR GpeConnectVector; - PGPE_DISCONNECT_VECTOR GpeDisconnectVector; - PGPE_ENABLE_EVENT GpeEnableEvent; - PGPE_DISABLE_EVENT GpeDisableEvent; - PGPE_CLEAR_STATUS GpeClearStatus; - PREGISTER_FOR_DEVICE_NOTIFICATIONS RegisterForDeviceNotifications; - PUNREGISTER_FOR_DEVICE_NOTIFICATIONS UnregisterForDeviceNotifications; -} ACPI_INTERFACE_STANDARD, *PACPI_INTERFACE_STANDARD; - -typedef BOOLEAN -(NTAPI *PGPE_SERVICE_ROUTINE2)( - PVOID ObjectContext, - PVOID ServiceContext); - -typedef NTSTATUS -(NTAPI *PGPE_CONNECT_VECTOR2)( - PVOID Context, - ULONG GpeNumber, - KINTERRUPT_MODE Mode, - BOOLEAN Shareable, - PGPE_SERVICE_ROUTINE ServiceRoutine, - PVOID ServiceContext, - PVOID *ObjectContext); - -typedef NTSTATUS -(NTAPI *PGPE_DISCONNECT_VECTOR2)( - PVOID Context, - PVOID ObjectContext); - -typedef NTSTATUS -(NTAPI *PGPE_ENABLE_EVENT2)( - PVOID Context, - PVOID ObjectContext); - -typedef NTSTATUS -(NTAPI *PGPE_DISABLE_EVENT2)( - PVOID Context, - PVOID ObjectContext); - -typedef NTSTATUS -(NTAPI *PGPE_CLEAR_STATUS2)( - PVOID Context, - PVOID ObjectContext); - -typedef VOID -(NTAPI *PDEVICE_NOTIFY_CALLBACK2)( - PVOID NotificationContext, - ULONG NotifyCode); - -typedef NTSTATUS -(NTAPI *PREGISTER_FOR_DEVICE_NOTIFICATIONS2)( - PVOID Context, - PDEVICE_NOTIFY_CALLBACK2 NotificationHandler, - PVOID NotificationContext); - -typedef VOID -(NTAPI *PUNREGISTER_FOR_DEVICE_NOTIFICATIONS2)( - PVOID Context); - -typedef struct _ACPI_INTERFACE_STANDARD2 { - USHORT Size; - USHORT Version; - PVOID Context; - PINTERFACE_REFERENCE InterfaceReference; - PINTERFACE_DEREFERENCE InterfaceDereference; - PGPE_CONNECT_VECTOR2 GpeConnectVector; - PGPE_DISCONNECT_VECTOR2 GpeDisconnectVector; - PGPE_ENABLE_EVENT2 GpeEnableEvent; - PGPE_DISABLE_EVENT2 GpeDisableEvent; - PGPE_CLEAR_STATUS2 GpeClearStatus; - PREGISTER_FOR_DEVICE_NOTIFICATIONS2 RegisterForDeviceNotifications; - PUNREGISTER_FOR_DEVICE_NOTIFICATIONS2 UnregisterForDeviceNotifications; -} ACPI_INTERFACE_STANDARD2, *PACPI_INTERFACE_STANDARD2; +typedef enum _WORK_QUEUE_TYPE { + CriticalWorkQueue, + DelayedWorkQueue, + HyperCriticalWorkQueue, + MaximumWorkQueue +} WORK_QUEUE_TYPE; #if !defined(_AMD64_) && !defined(_IA64_) #include #endif typedef struct _IO_STACK_LOCATION { - UCHAR MajorFunction; - UCHAR MinorFunction; - UCHAR Flags; - UCHAR Control; + UCHAR MajorFunction; + UCHAR MinorFunction; + UCHAR Flags; + UCHAR Control; union { struct { - PIO_SECURITY_CONTEXT SecurityContext; - ULONG Options; - USHORT POINTER_ALIGNMENT FileAttributes; - USHORT ShareAccess; - ULONG POINTER_ALIGNMENT EaLength; + PIO_SECURITY_CONTEXT SecurityContext; + ULONG Options; + USHORT POINTER_ALIGNMENT FileAttributes; + USHORT ShareAccess; + ULONG POINTER_ALIGNMENT EaLength; } Create; struct { - ULONG Length; - ULONG POINTER_ALIGNMENT Key; - LARGE_INTEGER ByteOffset; + ULONG Length; + ULONG POINTER_ALIGNMENT Key; + LARGE_INTEGER ByteOffset; } Read; struct { - ULONG Length; - ULONG POINTER_ALIGNMENT Key; - LARGE_INTEGER ByteOffset; + ULONG Length; + ULONG POINTER_ALIGNMENT Key; + LARGE_INTEGER ByteOffset; } Write; struct { - ULONG Length; - PUNICODE_STRING FileName; - FILE_INFORMATION_CLASS FileInformationClass; - ULONG FileIndex; + ULONG Length; + PUNICODE_STRING FileName; + FILE_INFORMATION_CLASS FileInformationClass; + ULONG FileIndex; } QueryDirectory; struct { - ULONG Length; - ULONG CompletionFilter; + ULONG Length; + ULONG CompletionFilter; } NotifyDirectory; struct { - ULONG Length; - FILE_INFORMATION_CLASS POINTER_ALIGNMENT FileInformationClass; + ULONG Length; + FILE_INFORMATION_CLASS POINTER_ALIGNMENT FileInformationClass; } QueryFile; struct { - ULONG Length; - FILE_INFORMATION_CLASS POINTER_ALIGNMENT FileInformationClass; - PFILE_OBJECT FileObject; + ULONG Length; + FILE_INFORMATION_CLASS POINTER_ALIGNMENT FileInformationClass; + PFILE_OBJECT FileObject; _ANONYMOUS_UNION union { _ANONYMOUS_STRUCT struct { - BOOLEAN ReplaceIfExists; - BOOLEAN AdvanceOnly; + BOOLEAN ReplaceIfExists; + BOOLEAN AdvanceOnly; } DUMMYSTRUCTNAME; - ULONG ClusterCount; - HANDLE DeleteHandle; + ULONG ClusterCount; + HANDLE DeleteHandle; } DUMMYUNIONNAME; } SetFile; struct { - ULONG Length; - PVOID EaList; - ULONG EaListLength; - ULONG EaIndex; + ULONG Length; + PVOID EaList; + ULONG EaListLength; + ULONG EaIndex; } QueryEa; struct { - ULONG Length; + ULONG Length; } SetEa; struct { - ULONG Length; - FS_INFORMATION_CLASS POINTER_ALIGNMENT FsInformationClass; + ULONG Length; + FS_INFORMATION_CLASS POINTER_ALIGNMENT FsInformationClass; } QueryVolume; struct { - ULONG Length; - FS_INFORMATION_CLASS FsInformationClass; + ULONG Length; + FS_INFORMATION_CLASS FsInformationClass; } SetVolume; struct { - ULONG OutputBufferLength; - ULONG InputBufferLength; - ULONG FsControlCode; - PVOID Type3InputBuffer; + ULONG OutputBufferLength; + ULONG InputBufferLength; + ULONG FsControlCode; + PVOID Type3InputBuffer; } FileSystemControl; struct { - PLARGE_INTEGER Length; - ULONG Key; - LARGE_INTEGER ByteOffset; + PLARGE_INTEGER Length; + ULONG Key; + LARGE_INTEGER ByteOffset; } LockControl; struct { - ULONG OutputBufferLength; - ULONG POINTER_ALIGNMENT InputBufferLength; - ULONG POINTER_ALIGNMENT IoControlCode; - PVOID Type3InputBuffer; + ULONG OutputBufferLength; + ULONG POINTER_ALIGNMENT InputBufferLength; + ULONG POINTER_ALIGNMENT IoControlCode; + PVOID Type3InputBuffer; } DeviceIoControl; struct { - SECURITY_INFORMATION SecurityInformation; - ULONG POINTER_ALIGNMENT Length; + SECURITY_INFORMATION SecurityInformation; + ULONG POINTER_ALIGNMENT Length; } QuerySecurity; struct { - SECURITY_INFORMATION SecurityInformation; - PSECURITY_DESCRIPTOR SecurityDescriptor; + SECURITY_INFORMATION SecurityInformation; + PSECURITY_DESCRIPTOR SecurityDescriptor; } SetSecurity; struct { - PVPB Vpb; - PDEVICE_OBJECT DeviceObject; + PVPB Vpb; + PDEVICE_OBJECT DeviceObject; } MountVolume; struct { - PVPB Vpb; - PDEVICE_OBJECT DeviceObject; + PVPB Vpb; + PDEVICE_OBJECT DeviceObject; } VerifyVolume; struct { - struct _SCSI_REQUEST_BLOCK *Srb; + struct _SCSI_REQUEST_BLOCK *Srb; } Scsi; struct { - ULONG Length; - PSID StartSid; - struct _FILE_GET_QUOTA_INFORMATION *SidList; - ULONG SidListLength; + ULONG Length; + PSID StartSid; + struct _FILE_GET_QUOTA_INFORMATION *SidList; + ULONG SidListLength; } QueryQuota; struct { - ULONG Length; + ULONG Length; } SetQuota; struct { - DEVICE_RELATION_TYPE Type; + DEVICE_RELATION_TYPE Type; } QueryDeviceRelations; struct { - CONST GUID *InterfaceType; - USHORT Size; - USHORT Version; - PINTERFACE Interface; - PVOID InterfaceSpecificData; + CONST GUID *InterfaceType; + USHORT Size; + USHORT Version; + PINTERFACE Interface; + PVOID InterfaceSpecificData; } QueryInterface; struct { - PDEVICE_CAPABILITIES Capabilities; + PDEVICE_CAPABILITIES Capabilities; } DeviceCapabilities; struct { - PIO_RESOURCE_REQUIREMENTS_LIST IoResourceRequirementList; + PIO_RESOURCE_REQUIREMENTS_LIST IoResourceRequirementList; } FilterResourceRequirements; struct { - ULONG WhichSpace; - PVOID Buffer; - ULONG Offset; - ULONG POINTER_ALIGNMENT Length; + ULONG WhichSpace; + PVOID Buffer; + ULONG Offset; + ULONG POINTER_ALIGNMENT Length; } ReadWriteConfig; struct { - BOOLEAN Lock; + BOOLEAN Lock; } SetLock; struct { - BUS_QUERY_ID_TYPE IdType; + BUS_QUERY_ID_TYPE IdType; } QueryId; struct { - DEVICE_TEXT_TYPE DeviceTextType; - LCID POINTER_ALIGNMENT LocaleId; + DEVICE_TEXT_TYPE DeviceTextType; + LCID POINTER_ALIGNMENT LocaleId; } QueryDeviceText; struct { - BOOLEAN InPath; - BOOLEAN Reserved[3]; - DEVICE_USAGE_NOTIFICATION_TYPE POINTER_ALIGNMENT Type; + BOOLEAN InPath; + BOOLEAN Reserved[3]; + DEVICE_USAGE_NOTIFICATION_TYPE POINTER_ALIGNMENT Type; } UsageNotification; struct { - SYSTEM_POWER_STATE PowerState; + SYSTEM_POWER_STATE PowerState; } WaitWake; struct { - PPOWER_SEQUENCE PowerSequence; + PPOWER_SEQUENCE PowerSequence; } PowerSequence; struct { - ULONG SystemContext; - POWER_STATE_TYPE POINTER_ALIGNMENT Type; - POWER_STATE POINTER_ALIGNMENT State; - POWER_ACTION POINTER_ALIGNMENT ShutdownType; + ULONG SystemContext; + POWER_STATE_TYPE POINTER_ALIGNMENT Type; + POWER_STATE POINTER_ALIGNMENT State; + POWER_ACTION POINTER_ALIGNMENT ShutdownType; } Power; struct { - PCM_RESOURCE_LIST AllocatedResources; - PCM_RESOURCE_LIST AllocatedResourcesTranslated; + PCM_RESOURCE_LIST AllocatedResources; + PCM_RESOURCE_LIST AllocatedResourcesTranslated; } StartDevice; struct { - ULONG_PTR ProviderId; - PVOID DataPath; - ULONG BufferSize; - PVOID Buffer; + ULONG_PTR ProviderId; + PVOID DataPath; + ULONG BufferSize; + PVOID Buffer; } WMI; struct { - PVOID Argument1; - PVOID Argument2; - PVOID Argument3; - PVOID Argument4; + PVOID Argument1; + PVOID Argument2; + PVOID Argument3; + PVOID Argument4; } Others; } Parameters; - PDEVICE_OBJECT DeviceObject; - PFILE_OBJECT FileObject; - PIO_COMPLETION_ROUTINE CompletionRoutine; - PVOID Context; + PDEVICE_OBJECT DeviceObject; + PFILE_OBJECT FileObject; + PIO_COMPLETION_ROUTINE CompletionRoutine; + PVOID Context; } IO_STACK_LOCATION, *PIO_STACK_LOCATION; #if !defined(_AMD64_) && !defined(_IA64_) #include @@ -6503,13 +5131,16 @@ typedef struct _IO_STACK_LOCATION { #define SL_INVOKE_ON_SUCCESS 0x40 #define SL_INVOKE_ON_ERROR 0x80 +/* IO_STACK_LOCATION.Parameters.ReadWriteControl.WhichSpace */ + +#define PCI_WHICHSPACE_CONFIG 0x0 +#define PCI_WHICHSPACE_ROM 0x52696350 /* 'PciR' */ + #define METHOD_BUFFERED 0 #define METHOD_IN_DIRECT 1 #define METHOD_OUT_DIRECT 2 #define METHOD_NEITHER 3 -#define METHOD_DIRECT_TO_HARDWARE METHOD_IN_DIRECT -#define METHOD_DIRECT_FROM_HARDWARE METHOD_OUT_DIRECT #define FILE_SUPERSEDED 0x00000000 #define FILE_OPENED 0x00000001 @@ -6556,7 +5187,6 @@ typedef struct _IO_STACK_LOCATION { #define FILE_ATTRIBUTE_OFFLINE 0x00001000 #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000 #define FILE_ATTRIBUTE_ENCRYPTED 0x00004000 -#define FILE_ATTRIBUTE_VIRTUAL 0x00010000 #define FILE_ATTRIBUTE_VALID_FLAGS 0x00007fb7 #define FILE_ATTRIBUTE_VALID_SET_FLAGS 0x000031a7 @@ -6590,10 +5220,6 @@ typedef struct _IO_STACK_LOCATION { #define FILE_OPEN_BY_FILE_ID 0x00002000 #define FILE_OPEN_FOR_BACKUP_INTENT 0x00004000 #define FILE_NO_COMPRESSION 0x00008000 -#if (NTDDI_VERSION >= NTDDI_WIN7) -#define FILE_OPEN_REQUIRING_OPLOCK 0x00010000 -#define FILE_DISALLOW_EXCLUSIVE 0x00020000 -#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ #define FILE_RESERVE_OPFILTER 0x00100000 #define FILE_OPEN_REPARSE_POINT 0x00200000 #define FILE_OPEN_NO_RECALL 0x00400000 @@ -6632,926 +5258,15 @@ typedef struct _IO_STACK_LOCATION { /* end winnt.h */ -#define WMIREG_ACTION_REGISTER 1 -#define WMIREG_ACTION_DEREGISTER 2 -#define WMIREG_ACTION_REREGISTER 3 -#define WMIREG_ACTION_UPDATE_GUIDS 4 -#define WMIREG_ACTION_BLOCK_IRPS 5 - -#define WMIREGISTER 0 -#define WMIUPDATE 1 - -typedef VOID -(NTAPI FWMI_NOTIFICATION_CALLBACK)( - PVOID Wnode, - PVOID Context); -typedef FWMI_NOTIFICATION_CALLBACK *WMI_NOTIFICATION_CALLBACK; - -#ifndef _PCI_X_ -#define _PCI_X_ - -typedef struct _PCI_SLOT_NUMBER { - union { - struct { - ULONG DeviceNumber:5; - ULONG FunctionNumber:3; - ULONG Reserved:24; - } bits; - ULONG AsULONG; - } u; -} PCI_SLOT_NUMBER, *PPCI_SLOT_NUMBER; - -#define PCI_TYPE0_ADDRESSES 6 -#define PCI_TYPE1_ADDRESSES 2 -#define PCI_TYPE2_ADDRESSES 5 - -typedef struct _PCI_COMMON_HEADER { - PCI_COMMON_HEADER_LAYOUT -} PCI_COMMON_HEADER, *PPCI_COMMON_HEADER; - -#ifdef __cplusplus -typedef struct _PCI_COMMON_CONFIG { - PCI_COMMON_HEADER_LAYOUT - UCHAR DeviceSpecific[192]; -} PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG; -#else -typedef struct _PCI_COMMON_CONFIG { - PCI_COMMON_HEADER DUMMYSTRUCTNAME; - UCHAR DeviceSpecific[192]; -} PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG; -#endif - -#define PCI_COMMON_HDR_LENGTH (FIELD_OFFSET(PCI_COMMON_CONFIG, DeviceSpecific)) - -#define PCI_EXTENDED_CONFIG_LENGTH 0x1000 - -#define PCI_MAX_DEVICES 32 -#define PCI_MAX_FUNCTION 8 -#define PCI_MAX_BRIDGE_NUMBER 0xFF -#define PCI_INVALID_VENDORID 0xFFFF - -/* PCI_COMMON_CONFIG.HeaderType */ -#define PCI_MULTIFUNCTION 0x80 -#define PCI_DEVICE_TYPE 0x00 -#define PCI_BRIDGE_TYPE 0x01 -#define PCI_CARDBUS_BRIDGE_TYPE 0x02 - -#define PCI_CONFIGURATION_TYPE(PciData) \ - (((PPCI_COMMON_CONFIG) (PciData))->HeaderType & ~PCI_MULTIFUNCTION) - -#define PCI_MULTIFUNCTION_DEVICE(PciData) \ - ((((PPCI_COMMON_CONFIG) (PciData))->HeaderType & PCI_MULTIFUNCTION) != 0) - -/* PCI_COMMON_CONFIG.Command */ -#define PCI_ENABLE_IO_SPACE 0x0001 -#define PCI_ENABLE_MEMORY_SPACE 0x0002 -#define PCI_ENABLE_BUS_MASTER 0x0004 -#define PCI_ENABLE_SPECIAL_CYCLES 0x0008 -#define PCI_ENABLE_WRITE_AND_INVALIDATE 0x0010 -#define PCI_ENABLE_VGA_COMPATIBLE_PALETTE 0x0020 -#define PCI_ENABLE_PARITY 0x0040 -#define PCI_ENABLE_WAIT_CYCLE 0x0080 -#define PCI_ENABLE_SERR 0x0100 -#define PCI_ENABLE_FAST_BACK_TO_BACK 0x0200 -#define PCI_DISABLE_LEVEL_INTERRUPT 0x0400 - -/* PCI_COMMON_CONFIG.Status */ -#define PCI_STATUS_INTERRUPT_PENDING 0x0008 -#define PCI_STATUS_CAPABILITIES_LIST 0x0010 -#define PCI_STATUS_66MHZ_CAPABLE 0x0020 -#define PCI_STATUS_UDF_SUPPORTED 0x0040 -#define PCI_STATUS_FAST_BACK_TO_BACK 0x0080 -#define PCI_STATUS_DATA_PARITY_DETECTED 0x0100 -#define PCI_STATUS_DEVSEL 0x0600 -#define PCI_STATUS_SIGNALED_TARGET_ABORT 0x0800 -#define PCI_STATUS_RECEIVED_TARGET_ABORT 0x1000 -#define PCI_STATUS_RECEIVED_MASTER_ABORT 0x2000 -#define PCI_STATUS_SIGNALED_SYSTEM_ERROR 0x4000 -#define PCI_STATUS_DETECTED_PARITY_ERROR 0x8000 - -/* IO_STACK_LOCATION.Parameters.ReadWriteControl.WhichSpace */ - -#define PCI_WHICHSPACE_CONFIG 0x0 -#define PCI_WHICHSPACE_ROM 0x52696350 /* 'PciR' */ - -#define PCI_CAPABILITY_ID_POWER_MANAGEMENT 0x01 -#define PCI_CAPABILITY_ID_AGP 0x02 -#define PCI_CAPABILITY_ID_VPD 0x03 -#define PCI_CAPABILITY_ID_SLOT_ID 0x04 -#define PCI_CAPABILITY_ID_MSI 0x05 -#define PCI_CAPABILITY_ID_CPCI_HOTSWAP 0x06 -#define PCI_CAPABILITY_ID_PCIX 0x07 -#define PCI_CAPABILITY_ID_HYPERTRANSPORT 0x08 -#define PCI_CAPABILITY_ID_VENDOR_SPECIFIC 0x09 -#define PCI_CAPABILITY_ID_DEBUG_PORT 0x0A -#define PCI_CAPABILITY_ID_CPCI_RES_CTRL 0x0B -#define PCI_CAPABILITY_ID_SHPC 0x0C -#define PCI_CAPABILITY_ID_P2P_SSID 0x0D -#define PCI_CAPABILITY_ID_AGP_TARGET 0x0E -#define PCI_CAPABILITY_ID_SECURE 0x0F -#define PCI_CAPABILITY_ID_PCI_EXPRESS 0x10 -#define PCI_CAPABILITY_ID_MSIX 0x11 - -typedef struct _PCI_CAPABILITIES_HEADER { - UCHAR CapabilityID; - UCHAR Next; -} PCI_CAPABILITIES_HEADER, *PPCI_CAPABILITIES_HEADER; - -typedef struct _PCI_PMC { - UCHAR Version:3; - UCHAR PMEClock:1; - UCHAR Rsvd1:1; - UCHAR DeviceSpecificInitialization:1; - UCHAR Rsvd2:2; - struct _PM_SUPPORT { - UCHAR Rsvd2:1; - UCHAR D1:1; - UCHAR D2:1; - UCHAR PMED0:1; - UCHAR PMED1:1; - UCHAR PMED2:1; - UCHAR PMED3Hot:1; - UCHAR PMED3Cold:1; - } Support; -} PCI_PMC, *PPCI_PMC; - -typedef struct _PCI_PMCSR { - USHORT PowerState:2; - USHORT Rsvd1:6; - USHORT PMEEnable:1; - USHORT DataSelect:4; - USHORT DataScale:2; - USHORT PMEStatus:1; -} PCI_PMCSR, *PPCI_PMCSR; - -typedef struct _PCI_PMCSR_BSE { - UCHAR Rsvd1:6; - UCHAR D3HotSupportsStopClock:1; - UCHAR BusPowerClockControlEnabled:1; -} PCI_PMCSR_BSE, *PPCI_PMCSR_BSE; - -typedef struct _PCI_PM_CAPABILITY { - PCI_CAPABILITIES_HEADER Header; - union { - PCI_PMC Capabilities; - USHORT AsUSHORT; - } PMC; - union { - PCI_PMCSR ControlStatus; - USHORT AsUSHORT; - } PMCSR; - union { - PCI_PMCSR_BSE BridgeSupport; - UCHAR AsUCHAR; - } PMCSR_BSE; - UCHAR Data; -} PCI_PM_CAPABILITY, *PPCI_PM_CAPABILITY; - -typedef struct { - PCI_CAPABILITIES_HEADER Header; - union { - struct { - USHORT DataParityErrorRecoveryEnable:1; - USHORT EnableRelaxedOrdering:1; - USHORT MaxMemoryReadByteCount:2; - USHORT MaxOutstandingSplitTransactions:3; - USHORT Reserved:9; - } bits; - USHORT AsUSHORT; - } Command; - union { - struct { - ULONG FunctionNumber:3; - ULONG DeviceNumber:5; - ULONG BusNumber:8; - ULONG Device64Bit:1; - ULONG Capable133MHz:1; - ULONG SplitCompletionDiscarded:1; - ULONG UnexpectedSplitCompletion:1; - ULONG DeviceComplexity:1; - ULONG DesignedMaxMemoryReadByteCount:2; - ULONG DesignedMaxOutstandingSplitTransactions:3; - ULONG DesignedMaxCumulativeReadSize:3; - ULONG ReceivedSplitCompletionErrorMessage:1; - ULONG CapablePCIX266:1; - ULONG CapablePCIX533:1; - } bits; - ULONG AsULONG; - } Status; -} PCI_X_CAPABILITY, *PPCI_X_CAPABILITY; - -#define PCI_EXPRESS_ADVANCED_ERROR_REPORTING_CAP_ID 0x0001 -#define PCI_EXPRESS_VIRTUAL_CHANNEL_CAP_ID 0x0002 -#define PCI_EXPRESS_DEVICE_SERIAL_NUMBER_CAP_ID 0x0003 -#define PCI_EXPRESS_POWER_BUDGETING_CAP_ID 0x0004 -#define PCI_EXPRESS_RC_LINK_DECLARATION_CAP_ID 0x0005 -#define PCI_EXPRESS_RC_INTERNAL_LINK_CONTROL_CAP_ID 0x0006 -#define PCI_EXPRESS_RC_EVENT_COLLECTOR_ENDPOINT_ASSOCIATION_CAP_ID 0x0007 -#define PCI_EXPRESS_MFVC_CAP_ID 0x0008 -#define PCI_EXPRESS_VC_AND_MFVC_CAP_ID 0x0009 -#define PCI_EXPRESS_RCRB_HEADER_CAP_ID 0x000A -#define PCI_EXPRESS_SINGLE_ROOT_IO_VIRTUALIZATION_CAP_ID 0x0010 - -typedef struct _PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER { - USHORT CapabilityID; - USHORT Version:4; - USHORT Next:12; -} PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER, *PPCI_EXPRESS_ENHANCED_CAPABILITY_HEADER; - -typedef struct _PCI_EXPRESS_SERIAL_NUMBER_CAPABILITY { - PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Header; - ULONG LowSerialNumber; - ULONG HighSerialNumber; -} PCI_EXPRESS_SERIAL_NUMBER_CAPABILITY, *PPCI_EXPRESS_SERIAL_NUMBER_CAPABILITY; - -typedef union _PCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS { - struct { - ULONG Undefined:1; - ULONG Reserved1:3; - ULONG DataLinkProtocolError:1; - ULONG SurpriseDownError:1; - ULONG Reserved2:6; - ULONG PoisonedTLP:1; - ULONG FlowControlProtocolError:1; - ULONG CompletionTimeout:1; - ULONG CompleterAbort:1; - ULONG UnexpectedCompletion:1; - ULONG ReceiverOverflow:1; - ULONG MalformedTLP:1; - ULONG ECRCError:1; - ULONG UnsupportedRequestError:1; - ULONG Reserved3:11; - } DUMMYSTRUCTNAME; - ULONG AsULONG; -} PCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS, *PPCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS; - -typedef union _PCI_EXPRESS_UNCORRECTABLE_ERROR_MASK { - struct { - ULONG Undefined:1; - ULONG Reserved1:3; - ULONG DataLinkProtocolError:1; - ULONG SurpriseDownError:1; - ULONG Reserved2:6; - ULONG PoisonedTLP:1; - ULONG FlowControlProtocolError:1; - ULONG CompletionTimeout:1; - ULONG CompleterAbort:1; - ULONG UnexpectedCompletion:1; - ULONG ReceiverOverflow:1; - ULONG MalformedTLP:1; - ULONG ECRCError:1; - ULONG UnsupportedRequestError:1; - ULONG Reserved3:11; - } DUMMYSTRUCTNAME; - ULONG AsULONG; -} PCI_EXPRESS_UNCORRECTABLE_ERROR_MASK, *PPCI_EXPRESS_UNCORRECTABLE_ERROR_MASK; - -typedef union _PCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY { - struct { - ULONG Undefined:1; - ULONG Reserved1:3; - ULONG DataLinkProtocolError:1; - ULONG SurpriseDownError:1; - ULONG Reserved2:6; - ULONG PoisonedTLP:1; - ULONG FlowControlProtocolError:1; - ULONG CompletionTimeout:1; - ULONG CompleterAbort:1; - ULONG UnexpectedCompletion:1; - ULONG ReceiverOverflow:1; - ULONG MalformedTLP:1; - ULONG ECRCError:1; - ULONG UnsupportedRequestError:1; - ULONG Reserved3:11; - } DUMMYSTRUCTNAME; - ULONG AsULONG; -} PCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY, *PPCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY; - -typedef union _PCI_EXPRESS_CORRECTABLE_ERROR_STATUS { - struct { - ULONG ReceiverError:1; - ULONG Reserved1:5; - ULONG BadTLP:1; - ULONG BadDLLP:1; - ULONG ReplayNumRollover:1; - ULONG Reserved2:3; - ULONG ReplayTimerTimeout:1; - ULONG AdvisoryNonFatalError:1; - ULONG Reserved3:18; - } DUMMYSTRUCTNAME; - ULONG AsULONG; -} PCI_EXPRESS_CORRECTABLE_ERROR_STATUS, *PPCI_CORRECTABLE_ERROR_STATUS; - -typedef union _PCI_EXPRESS_CORRECTABLE_ERROR_MASK { - struct { - ULONG ReceiverError:1; - ULONG Reserved1:5; - ULONG BadTLP:1; - ULONG BadDLLP:1; - ULONG ReplayNumRollover:1; - ULONG Reserved2:3; - ULONG ReplayTimerTimeout:1; - ULONG AdvisoryNonFatalError:1; - ULONG Reserved3:18; - } DUMMYSTRUCTNAME; - ULONG AsULONG; -} PCI_EXPRESS_CORRECTABLE_ERROR_MASK, *PPCI_CORRECTABLE_ERROR_MASK; - -typedef union _PCI_EXPRESS_AER_CAPABILITIES { - struct { - ULONG FirstErrorPointer:5; - ULONG ECRCGenerationCapable:1; - ULONG ECRCGenerationEnable:1; - ULONG ECRCCheckCapable:1; - ULONG ECRCCheckEnable:1; - ULONG Reserved:23; - } DUMMYSTRUCTNAME; - ULONG AsULONG; -} PCI_EXPRESS_AER_CAPABILITIES, *PPCI_EXPRESS_AER_CAPABILITIES; - -typedef union _PCI_EXPRESS_ROOT_ERROR_COMMAND { - struct { - ULONG CorrectableErrorReportingEnable:1; - ULONG NonFatalErrorReportingEnable:1; - ULONG FatalErrorReportingEnable:1; - ULONG Reserved:29; - } DUMMYSTRUCTNAME; - ULONG AsULONG; -} PCI_EXPRESS_ROOT_ERROR_COMMAND, *PPCI_EXPRESS_ROOT_ERROR_COMMAND; - -typedef union _PCI_EXPRESS_ROOT_ERROR_STATUS { - struct { - ULONG CorrectableErrorReceived:1; - ULONG MultipleCorrectableErrorsReceived:1; - ULONG UncorrectableErrorReceived:1; - ULONG MultipleUncorrectableErrorsReceived:1; - ULONG FirstUncorrectableFatal:1; - ULONG NonFatalErrorMessagesReceived:1; - ULONG FatalErrorMessagesReceived:1; - ULONG Reserved:20; - ULONG AdvancedErrorInterruptMessageNumber:5; - } DUMMYSTRUCTNAME; - ULONG AsULONG; -} PCI_EXPRESS_ROOT_ERROR_STATUS, *PPCI_EXPRESS_ROOT_ERROR_STATUS; - -typedef union _PCI_EXPRESS_ERROR_SOURCE_ID { - struct { - USHORT CorrectableSourceIdFun:3; - USHORT CorrectableSourceIdDev:5; - USHORT CorrectableSourceIdBus:8; - USHORT UncorrectableSourceIdFun:3; - USHORT UncorrectableSourceIdDev:5; - USHORT UncorrectableSourceIdBus:8; - } DUMMYSTRUCTNAME; - ULONG AsULONG; -} PCI_EXPRESS_ERROR_SOURCE_ID, *PPCI_EXPRESS_ERROR_SOURCE_ID; - -typedef union _PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_STATUS { - struct { - ULONG TargetAbortOnSplitCompletion:1; - ULONG MasterAbortOnSplitCompletion:1; - ULONG ReceivedTargetAbort:1; - ULONG ReceivedMasterAbort:1; - ULONG RsvdZ:1; - ULONG UnexpectedSplitCompletionError:1; - ULONG UncorrectableSplitCompletion:1; - ULONG UncorrectableDataError:1; - ULONG UncorrectableAttributeError:1; - ULONG UncorrectableAddressError:1; - ULONG DelayedTransactionDiscardTimerExpired:1; - ULONG PERRAsserted:1; - ULONG SERRAsserted:1; - ULONG InternalBridgeError:1; - ULONG Reserved:18; - } DUMMYSTRUCTNAME; - ULONG AsULONG; -} PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_STATUS, *PPCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_STATUS; - -typedef union _PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_MASK { - struct { - ULONG TargetAbortOnSplitCompletion:1; - ULONG MasterAbortOnSplitCompletion:1; - ULONG ReceivedTargetAbort:1; - ULONG ReceivedMasterAbort:1; - ULONG RsvdZ:1; - ULONG UnexpectedSplitCompletionError:1; - ULONG UncorrectableSplitCompletion:1; - ULONG UncorrectableDataError:1; - ULONG UncorrectableAttributeError:1; - ULONG UncorrectableAddressError:1; - ULONG DelayedTransactionDiscardTimerExpired:1; - ULONG PERRAsserted:1; - ULONG SERRAsserted:1; - ULONG InternalBridgeError:1; - ULONG Reserved:18; - } DUMMYSTRUCTNAME; - ULONG AsULONG; -} PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_MASK, *PPCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_MASK; - -typedef union _PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_SEVERITY { - struct { - ULONG TargetAbortOnSplitCompletion:1; - ULONG MasterAbortOnSplitCompletion:1; - ULONG ReceivedTargetAbort:1; - ULONG ReceivedMasterAbort:1; - ULONG RsvdZ:1; - ULONG UnexpectedSplitCompletionError:1; - ULONG UncorrectableSplitCompletion:1; - ULONG UncorrectableDataError:1; - ULONG UncorrectableAttributeError:1; - ULONG UncorrectableAddressError:1; - ULONG DelayedTransactionDiscardTimerExpired:1; - ULONG PERRAsserted:1; - ULONG SERRAsserted:1; - ULONG InternalBridgeError:1; - ULONG Reserved:18; - } DUMMYSTRUCTNAME; - ULONG AsULONG; -} PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_SEVERITY, *PPCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_SEVERITY; - -typedef union _PCI_EXPRESS_SEC_AER_CAPABILITIES { - struct { - ULONG SecondaryUncorrectableFirstErrorPtr:5; - ULONG Reserved:27; - } DUMMYSTRUCTNAME; - ULONG AsULONG; -} PCI_EXPRESS_SEC_AER_CAPABILITIES, *PPCI_EXPRESS_SEC_AER_CAPABILITIES; - -#define ROOT_CMD_ENABLE_CORRECTABLE_ERROR_REPORTING 0x00000001 -#define ROOT_CMD_ENABLE_NONFATAL_ERROR_REPORTING 0x00000002 -#define ROOT_CMD_ENABLE_FATAL_ERROR_REPORTING 0x00000004 - -#define ROOT_CMD_ERROR_REPORTING_ENABLE_MASK \ - (ROOT_CMD_ENABLE_FATAL_ERROR_REPORTING | \ - ROOT_CMD_ENABLE_NONFATAL_ERROR_REPORTING | \ - ROOT_CMD_ENABLE_CORRECTABLE_ERROR_REPORTING) - -typedef struct _PCI_EXPRESS_AER_CAPABILITY { - PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Header; - PCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS UncorrectableErrorStatus; - PCI_EXPRESS_UNCORRECTABLE_ERROR_MASK UncorrectableErrorMask; - PCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY UncorrectableErrorSeverity; - PCI_EXPRESS_CORRECTABLE_ERROR_STATUS CorrectableErrorStatus; - PCI_EXPRESS_CORRECTABLE_ERROR_MASK CorrectableErrorMask; - PCI_EXPRESS_AER_CAPABILITIES CapabilitiesAndControl; - ULONG HeaderLog[4]; - PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_STATUS SecUncorrectableErrorStatus; - PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_MASK SecUncorrectableErrorMask; - PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_SEVERITY SecUncorrectableErrorSeverity; - PCI_EXPRESS_SEC_AER_CAPABILITIES SecCapabilitiesAndControl; - ULONG SecHeaderLog[4]; -} PCI_EXPRESS_AER_CAPABILITY, *PPCI_EXPRESS_AER_CAPABILITY; - -typedef struct _PCI_EXPRESS_ROOTPORT_AER_CAPABILITY { - PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Header; - PCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS UncorrectableErrorStatus; - PCI_EXPRESS_UNCORRECTABLE_ERROR_MASK UncorrectableErrorMask; - PCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY UncorrectableErrorSeverity; - PCI_EXPRESS_CORRECTABLE_ERROR_STATUS CorrectableErrorStatus; - PCI_EXPRESS_CORRECTABLE_ERROR_MASK CorrectableErrorMask; - PCI_EXPRESS_AER_CAPABILITIES CapabilitiesAndControl; - ULONG HeaderLog[4]; - PCI_EXPRESS_ROOT_ERROR_COMMAND RootErrorCommand; - PCI_EXPRESS_ROOT_ERROR_STATUS RootErrorStatus; - PCI_EXPRESS_ERROR_SOURCE_ID ErrorSourceId; -} PCI_EXPRESS_ROOTPORT_AER_CAPABILITY, *PPCI_EXPRESS_ROOTPORT_AER_CAPABILITY; - -typedef struct _PCI_EXPRESS_BRIDGE_AER_CAPABILITY { - PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Header; - PCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS UncorrectableErrorStatus; - PCI_EXPRESS_UNCORRECTABLE_ERROR_MASK UncorrectableErrorMask; - PCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY UncorrectableErrorSeverity; - PCI_EXPRESS_CORRECTABLE_ERROR_STATUS CorrectableErrorStatus; - PCI_EXPRESS_CORRECTABLE_ERROR_MASK CorrectableErrorMask; - PCI_EXPRESS_AER_CAPABILITIES CapabilitiesAndControl; - ULONG HeaderLog[4]; - PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_STATUS SecUncorrectableErrorStatus; - PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_MASK SecUncorrectableErrorMask; - PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_SEVERITY SecUncorrectableErrorSeverity; - PCI_EXPRESS_SEC_AER_CAPABILITIES SecCapabilitiesAndControl; - ULONG SecHeaderLog[4]; -} PCI_EXPRESS_BRIDGE_AER_CAPABILITY, *PPCI_EXPRESS_BRIDGE_AER_CAPABILITY; - -typedef union _PCI_EXPRESS_SRIOV_CAPS { - struct { - ULONG VFMigrationCapable:1; - ULONG Reserved1:20; - ULONG VFMigrationInterruptNumber:11; - } DUMMYSTRUCTNAME; - ULONG AsULONG; -} PCI_EXPRESS_SRIOV_CAPS, *PPCI_EXPRESS_SRIOV_CAPS; - -typedef union _PCI_EXPRESS_SRIOV_CONTROL { - struct { - USHORT VFEnable:1; - USHORT VFMigrationEnable:1; - USHORT VFMigrationInterruptEnable:1; - USHORT VFMemorySpaceEnable:1; - USHORT ARICapableHierarchy:1; - USHORT Reserved1:11; - } DUMMYSTRUCTNAME; - USHORT AsUSHORT; -} PCI_EXPRESS_SRIOV_CONTROL, *PPCI_EXPRESS_SRIOV_CONTROL; - -typedef union _PCI_EXPRESS_SRIOV_STATUS { - struct { - USHORT VFMigrationStatus:1; - USHORT Reserved1:15; - } DUMMYSTRUCTNAME; - USHORT AsUSHORT; -} PCI_EXPRESS_SRIOV_STATUS, *PPCI_EXPRESS_SRIOV_STATUS; - -typedef union _PCI_EXPRESS_SRIOV_MIGRATION_STATE_ARRAY { - struct { - ULONG VFMigrationStateBIR:3; - ULONG VFMigrationStateOffset:29; - } DUMMYSTRUCTNAME; - ULONG AsULONG; -} PCI_EXPRESS_SRIOV_MIGRATION_STATE_ARRAY, *PPCI_EXPRESS_SRIOV_MIGRATION_STATE_ARRAY; - -typedef struct _PCI_EXPRESS_SRIOV_CAPABILITY { - PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Header; - PCI_EXPRESS_SRIOV_CAPS SRIOVCapabilities; - PCI_EXPRESS_SRIOV_CONTROL SRIOVControl; - PCI_EXPRESS_SRIOV_STATUS SRIOVStatus; - USHORT InitialVFs; - USHORT TotalVFs; - USHORT NumVFs; - UCHAR FunctionDependencyLink; - UCHAR RsvdP1; - USHORT FirstVFOffset; - USHORT VFStride; - USHORT RsvdP2; - USHORT VFDeviceId; - ULONG SupportedPageSizes; - ULONG SystemPageSize; - ULONG BaseAddresses[PCI_TYPE0_ADDRESSES]; - PCI_EXPRESS_SRIOV_MIGRATION_STATE_ARRAY VFMigrationStateArrayOffset; -} PCI_EXPRESS_SRIOV_CAPABILITY, *PPCI_EXPRESS_SRIOV_CAPABILITY; - -/* PCI device classes */ -#define PCI_CLASS_PRE_20 0x00 -#define PCI_CLASS_MASS_STORAGE_CTLR 0x01 -#define PCI_CLASS_NETWORK_CTLR 0x02 -#define PCI_CLASS_DISPLAY_CTLR 0x03 -#define PCI_CLASS_MULTIMEDIA_DEV 0x04 -#define PCI_CLASS_MEMORY_CTLR 0x05 -#define PCI_CLASS_BRIDGE_DEV 0x06 -#define PCI_CLASS_SIMPLE_COMMS_CTLR 0x07 -#define PCI_CLASS_BASE_SYSTEM_DEV 0x08 -#define PCI_CLASS_INPUT_DEV 0x09 -#define PCI_CLASS_DOCKING_STATION 0x0a -#define PCI_CLASS_PROCESSOR 0x0b -#define PCI_CLASS_SERIAL_BUS_CTLR 0x0c -#define PCI_CLASS_WIRELESS_CTLR 0x0d -#define PCI_CLASS_INTELLIGENT_IO_CTLR 0x0e -#define PCI_CLASS_SATELLITE_COMMS_CTLR 0x0f -#define PCI_CLASS_ENCRYPTION_DECRYPTION 0x10 -#define PCI_CLASS_DATA_ACQ_SIGNAL_PROC 0x11 -#define PCI_CLASS_NOT_DEFINED 0xff - -/* PCI device subclasses for class 0 */ -#define PCI_SUBCLASS_PRE_20_NON_VGA 0x00 -#define PCI_SUBCLASS_PRE_20_VGA 0x01 - -/* PCI device subclasses for class 1 (mass storage controllers)*/ -#define PCI_SUBCLASS_MSC_SCSI_BUS_CTLR 0x00 -#define PCI_SUBCLASS_MSC_IDE_CTLR 0x01 -#define PCI_SUBCLASS_MSC_FLOPPY_CTLR 0x02 -#define PCI_SUBCLASS_MSC_IPI_CTLR 0x03 -#define PCI_SUBCLASS_MSC_RAID_CTLR 0x04 -#define PCI_SUBCLASS_MSC_OTHER 0x80 - -/* PCI device subclasses for class 2 (network controllers)*/ -#define PCI_SUBCLASS_NET_ETHERNET_CTLR 0x00 -#define PCI_SUBCLASS_NET_TOKEN_RING_CTLR 0x01 -#define PCI_SUBCLASS_NET_FDDI_CTLR 0x02 -#define PCI_SUBCLASS_NET_ATM_CTLR 0x03 -#define PCI_SUBCLASS_NET_ISDN_CTLR 0x04 -#define PCI_SUBCLASS_NET_OTHER 0x80 - -/* PCI device subclasses for class 3 (display controllers)*/ -#define PCI_SUBCLASS_VID_VGA_CTLR 0x00 -#define PCI_SUBCLASS_VID_XGA_CTLR 0x01 -#define PCI_SUBCLASS_VID_3D_CTLR 0x02 -#define PCI_SUBCLASS_VID_OTHER 0x80 - -/* PCI device subclasses for class 4 (multimedia device)*/ -#define PCI_SUBCLASS_MM_VIDEO_DEV 0x00 -#define PCI_SUBCLASS_MM_AUDIO_DEV 0x01 -#define PCI_SUBCLASS_MM_TELEPHONY_DEV 0x02 -#define PCI_SUBCLASS_MM_OTHER 0x80 - -/* PCI device subclasses for class 5 (memory controller)*/ -#define PCI_SUBCLASS_MEM_RAM 0x00 -#define PCI_SUBCLASS_MEM_FLASH 0x01 -#define PCI_SUBCLASS_MEM_OTHER 0x80 - -/* PCI device subclasses for class 6 (bridge device)*/ -#define PCI_SUBCLASS_BR_HOST 0x00 -#define PCI_SUBCLASS_BR_ISA 0x01 -#define PCI_SUBCLASS_BR_EISA 0x02 -#define PCI_SUBCLASS_BR_MCA 0x03 -#define PCI_SUBCLASS_BR_PCI_TO_PCI 0x04 -#define PCI_SUBCLASS_BR_PCMCIA 0x05 -#define PCI_SUBCLASS_BR_NUBUS 0x06 -#define PCI_SUBCLASS_BR_CARDBUS 0x07 -#define PCI_SUBCLASS_BR_RACEWAY 0x08 -#define PCI_SUBCLASS_BR_OTHER 0x80 - -#define PCI_SUBCLASS_COM_SERIAL 0x00 -#define PCI_SUBCLASS_COM_PARALLEL 0x01 -#define PCI_SUBCLASS_COM_MULTIPORT 0x02 -#define PCI_SUBCLASS_COM_MODEM 0x03 -#define PCI_SUBCLASS_COM_OTHER 0x80 - -#define PCI_SUBCLASS_SYS_INTERRUPT_CTLR 0x00 -#define PCI_SUBCLASS_SYS_DMA_CTLR 0x01 -#define PCI_SUBCLASS_SYS_SYSTEM_TIMER 0x02 -#define PCI_SUBCLASS_SYS_REAL_TIME_CLOCK 0x03 -#define PCI_SUBCLASS_SYS_GEN_HOTPLUG_CTLR 0x04 -#define PCI_SUBCLASS_SYS_SDIO_CTRL 0x05 -#define PCI_SUBCLASS_SYS_OTHER 0x80 - -#define PCI_SUBCLASS_INP_KEYBOARD 0x00 -#define PCI_SUBCLASS_INP_DIGITIZER 0x01 -#define PCI_SUBCLASS_INP_MOUSE 0x02 -#define PCI_SUBCLASS_INP_SCANNER 0x03 -#define PCI_SUBCLASS_INP_GAMEPORT 0x04 -#define PCI_SUBCLASS_INP_OTHER 0x80 - -#define PCI_SUBCLASS_DOC_GENERIC 0x00 -#define PCI_SUBCLASS_DOC_OTHER 0x80 - -#define PCI_SUBCLASS_PROC_386 0x00 -#define PCI_SUBCLASS_PROC_486 0x01 -#define PCI_SUBCLASS_PROC_PENTIUM 0x02 -#define PCI_SUBCLASS_PROC_ALPHA 0x10 -#define PCI_SUBCLASS_PROC_POWERPC 0x20 -#define PCI_SUBCLASS_PROC_COPROCESSOR 0x40 - -/* PCI device subclasses for class C (serial bus controller)*/ -#define PCI_SUBCLASS_SB_IEEE1394 0x00 -#define PCI_SUBCLASS_SB_ACCESS 0x01 -#define PCI_SUBCLASS_SB_SSA 0x02 -#define PCI_SUBCLASS_SB_USB 0x03 -#define PCI_SUBCLASS_SB_FIBRE_CHANNEL 0x04 -#define PCI_SUBCLASS_SB_SMBUS 0x05 - -#define PCI_SUBCLASS_WIRELESS_IRDA 0x00 -#define PCI_SUBCLASS_WIRELESS_CON_IR 0x01 -#define PCI_SUBCLASS_WIRELESS_RF 0x10 -#define PCI_SUBCLASS_WIRELESS_OTHER 0x80 - -#define PCI_SUBCLASS_INTIO_I2O 0x00 - -#define PCI_SUBCLASS_SAT_TV 0x01 -#define PCI_SUBCLASS_SAT_AUDIO 0x02 -#define PCI_SUBCLASS_SAT_VOICE 0x03 -#define PCI_SUBCLASS_SAT_DATA 0x04 - -#define PCI_SUBCLASS_CRYPTO_NET_COMP 0x00 -#define PCI_SUBCLASS_CRYPTO_ENTERTAINMENT 0x10 -#define PCI_SUBCLASS_CRYPTO_OTHER 0x80 - -#define PCI_SUBCLASS_DASP_DPIO 0x00 -#define PCI_SUBCLASS_DASP_OTHER 0x80 - -#define PCI_ADDRESS_IO_SPACE 0x00000001 -#define PCI_ADDRESS_MEMORY_TYPE_MASK 0x00000006 -#define PCI_ADDRESS_MEMORY_PREFETCHABLE 0x00000008 -#define PCI_ADDRESS_IO_ADDRESS_MASK 0xfffffffc -#define PCI_ADDRESS_MEMORY_ADDRESS_MASK 0xfffffff0 -#define PCI_ADDRESS_ROM_ADDRESS_MASK 0xfffff800 - -#define PCI_TYPE_32BIT 0 -#define PCI_TYPE_20BIT 2 -#define PCI_TYPE_64BIT 4 - -#define PCI_ROMADDRESS_ENABLED 0x00000001 - -#endif /* _PCI_X_ */ - -#define PCI_EXPRESS_LINK_QUIESCENT_INTERFACE_VERSION 1 - -typedef NTSTATUS -(NTAPI PCI_EXPRESS_ENTER_LINK_QUIESCENT_MODE)( - IN OUT PVOID Context); -typedef PCI_EXPRESS_ENTER_LINK_QUIESCENT_MODE *PPCI_EXPRESS_ENTER_LINK_QUIESCENT_MODE; - -typedef NTSTATUS -(NTAPI PCI_EXPRESS_EXIT_LINK_QUIESCENT_MODE)( - IN OUT PVOID Context); -typedef PCI_EXPRESS_EXIT_LINK_QUIESCENT_MODE *PPCI_EXPRESS_EXIT_LINK_QUIESCENT_MODE; - -typedef struct _PCI_EXPRESS_LINK_QUIESCENT_INTERFACE { - USHORT Size; - USHORT Version; - PVOID Context; - PINTERFACE_REFERENCE InterfaceReference; - PINTERFACE_DEREFERENCE InterfaceDereference; - PPCI_EXPRESS_ENTER_LINK_QUIESCENT_MODE PciExpressEnterLinkQuiescentMode; - PPCI_EXPRESS_EXIT_LINK_QUIESCENT_MODE PciExpressExitLinkQuiescentMode; -} PCI_EXPRESS_LINK_QUIESCENT_INTERFACE, *PPCI_EXPRESS_LINK_QUIESCENT_INTERFACE; - -#define PCI_EXPRESS_ROOT_PORT_INTERFACE_VERSION 1 - -typedef ULONG -(NTAPI *PPCI_EXPRESS_ROOT_PORT_READ_CONFIG_SPACE)( - IN PVOID Context, - OUT PVOID Buffer, - IN ULONG Offset, - IN ULONG Length); - -typedef ULONG -(NTAPI *PPCI_EXPRESS_ROOT_PORT_WRITE_CONFIG_SPACE)( - IN PVOID Context, - IN PVOID Buffer, - IN ULONG Offset, - IN ULONG Length); - -typedef struct _PCI_EXPRESS_ROOT_PORT_INTERFACE { - USHORT Size; - USHORT Version; - PVOID Context; - PINTERFACE_REFERENCE InterfaceReference; - PINTERFACE_DEREFERENCE InterfaceDereference; - PPCI_EXPRESS_ROOT_PORT_READ_CONFIG_SPACE ReadConfigSpace; - PPCI_EXPRESS_ROOT_PORT_WRITE_CONFIG_SPACE WriteConfigSpace; -} PCI_EXPRESS_ROOT_PORT_INTERFACE, *PPCI_EXPRESS_ROOT_PORT_INTERFACE; - -#define PCI_MSIX_TABLE_CONFIG_INTERFACE_VERSION 1 - -typedef NTSTATUS -(NTAPI PCI_MSIX_SET_ENTRY)( - IN PVOID Context, - IN ULONG TableEntry, - IN ULONG MessageNumber); -typedef PCI_MSIX_SET_ENTRY *PPCI_MSIX_SET_ENTRY; - -typedef NTSTATUS -(NTAPI PCI_MSIX_MASKUNMASK_ENTRY)( - IN PVOID Context, - IN ULONG TableEntry); -typedef PCI_MSIX_MASKUNMASK_ENTRY *PPCI_MSIX_MASKUNMASK_ENTRY; - -typedef NTSTATUS -(NTAPI PCI_MSIX_GET_ENTRY)( - IN PVOID Context, - IN ULONG TableEntry, - OUT PULONG MessageNumber, - OUT PBOOLEAN Masked); -typedef PCI_MSIX_GET_ENTRY *PPCI_MSIX_GET_ENTRY; - -typedef NTSTATUS -(NTAPI PCI_MSIX_GET_TABLE_SIZE)( - IN PVOID Context, - OUT PULONG TableSize); -typedef PCI_MSIX_GET_TABLE_SIZE *PPCI_MSIX_GET_TABLE_SIZE; - -typedef struct _PCI_MSIX_TABLE_CONFIG_INTERFACE { - USHORT Size; - USHORT Version; - PVOID Context; - PINTERFACE_REFERENCE InterfaceReference; - PINTERFACE_DEREFERENCE InterfaceDereference; - PPCI_MSIX_SET_ENTRY SetTableEntry; - PPCI_MSIX_MASKUNMASK_ENTRY MaskTableEntry; - PPCI_MSIX_MASKUNMASK_ENTRY UnmaskTableEntry; - PPCI_MSIX_GET_ENTRY GetTableEntry; - PPCI_MSIX_GET_TABLE_SIZE GetTableSize; -} PCI_MSIX_TABLE_CONFIG_INTERFACE, *PPCI_MSIX_TABLE_CONFIG_INTERFACE; - -#define PCI_MSIX_TABLE_CONFIG_MINIMUM_SIZE \ - RTL_SIZEOF_THROUGH_FIELD(PCI_MSIX_TABLE_CONFIG_INTERFACE, UnmaskTableEntry) - /****************************************************************************** * Object Manager Types * ******************************************************************************/ -#define MAXIMUM_FILENAME_LENGTH 256 -#define OBJ_NAME_PATH_SEPARATOR ((WCHAR)L'\\') - -#define OBJECT_TYPE_CREATE 0x0001 -#define OBJECT_TYPE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0x1) - -#define DIRECTORY_QUERY 0x0001 -#define DIRECTORY_TRAVERSE 0x0002 -#define DIRECTORY_CREATE_OBJECT 0x0004 -#define DIRECTORY_CREATE_SUBDIRECTORY 0x0008 -#define DIRECTORY_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0xF) - -#define SYMBOLIC_LINK_QUERY 0x0001 -#define SYMBOLIC_LINK_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0x1) - -#define DUPLICATE_CLOSE_SOURCE 0x00000001 -#define DUPLICATE_SAME_ACCESS 0x00000002 -#define DUPLICATE_SAME_ATTRIBUTES 0x00000004 - -#define OB_FLT_REGISTRATION_VERSION_0100 0x0100 -#define OB_FLT_REGISTRATION_VERSION OB_FLT_REGISTRATION_VERSION_0100 - -typedef ULONG OB_OPERATION; - -#define OB_OPERATION_HANDLE_CREATE 0x00000001 -#define OB_OPERATION_HANDLE_DUPLICATE 0x00000002 - -typedef struct _OB_PRE_CREATE_HANDLE_INFORMATION { - IN OUT ACCESS_MASK DesiredAccess; - IN ACCESS_MASK OriginalDesiredAccess; -} OB_PRE_CREATE_HANDLE_INFORMATION, *POB_PRE_CREATE_HANDLE_INFORMATION; - -typedef struct _OB_PRE_DUPLICATE_HANDLE_INFORMATION { - IN OUT ACCESS_MASK DesiredAccess; - IN ACCESS_MASK OriginalDesiredAccess; - IN PVOID SourceProcess; - IN PVOID TargetProcess; -} OB_PRE_DUPLICATE_HANDLE_INFORMATION, *POB_PRE_DUPLICATE_HANDLE_INFORMATION; - -typedef union _OB_PRE_OPERATION_PARAMETERS { - IN OUT OB_PRE_CREATE_HANDLE_INFORMATION CreateHandleInformation; - IN OUT OB_PRE_DUPLICATE_HANDLE_INFORMATION DuplicateHandleInformation; -} OB_PRE_OPERATION_PARAMETERS, *POB_PRE_OPERATION_PARAMETERS; - -typedef struct _OB_PRE_OPERATION_INFORMATION { - IN OB_OPERATION Operation; - union { - IN ULONG Flags; - struct { - IN ULONG KernelHandle:1; - IN ULONG Reserved:31; - }; - }; - IN PVOID Object; - IN POBJECT_TYPE ObjectType; - OUT PVOID CallContext; - IN POB_PRE_OPERATION_PARAMETERS Parameters; -} OB_PRE_OPERATION_INFORMATION, *POB_PRE_OPERATION_INFORMATION; - -typedef struct _OB_POST_CREATE_HANDLE_INFORMATION { - IN ACCESS_MASK GrantedAccess; -} OB_POST_CREATE_HANDLE_INFORMATION, *POB_POST_CREATE_HANDLE_INFORMATION; - -typedef struct _OB_POST_DUPLICATE_HANDLE_INFORMATION { - IN ACCESS_MASK GrantedAccess; -} OB_POST_DUPLICATE_HANDLE_INFORMATION, *POB_POST_DUPLICATE_HANDLE_INFORMATION; - -typedef union _OB_POST_OPERATION_PARAMETERS { - IN OB_POST_CREATE_HANDLE_INFORMATION CreateHandleInformation; - IN OB_POST_DUPLICATE_HANDLE_INFORMATION DuplicateHandleInformation; -} OB_POST_OPERATION_PARAMETERS, *POB_POST_OPERATION_PARAMETERS; - -typedef struct _OB_POST_OPERATION_INFORMATION { - IN OB_OPERATION Operation; - union { - IN ULONG Flags; - struct { - IN ULONG KernelHandle:1; - IN ULONG Reserved:31; - }; - }; - IN PVOID Object; - IN POBJECT_TYPE ObjectType; - IN PVOID CallContext; - IN NTSTATUS ReturnStatus; - IN POB_POST_OPERATION_PARAMETERS Parameters; -} OB_POST_OPERATION_INFORMATION,*POB_POST_OPERATION_INFORMATION; - -typedef enum _OB_PREOP_CALLBACK_STATUS { - OB_PREOP_SUCCESS -} OB_PREOP_CALLBACK_STATUS, *POB_PREOP_CALLBACK_STATUS; - -typedef OB_PREOP_CALLBACK_STATUS -(NTAPI *POB_PRE_OPERATION_CALLBACK)( - IN PVOID RegistrationContext, - IN OUT POB_PRE_OPERATION_INFORMATION OperationInformation); - -typedef VOID -(NTAPI *POB_POST_OPERATION_CALLBACK)( - IN PVOID RegistrationContext, - IN POB_POST_OPERATION_INFORMATION OperationInformation); - -typedef struct _OB_OPERATION_REGISTRATION { - IN POBJECT_TYPE *ObjectType; - IN OB_OPERATION Operations; - IN POB_PRE_OPERATION_CALLBACK PreOperation; - IN POB_POST_OPERATION_CALLBACK PostOperation; -} OB_OPERATION_REGISTRATION, *POB_OPERATION_REGISTRATION; - -typedef struct _OB_CALLBACK_REGISTRATION { - IN USHORT Version; - IN USHORT OperationRegistrationCount; - IN UNICODE_STRING Altitude; - IN PVOID RegistrationContext; - IN OB_OPERATION_REGISTRATION *OperationRegistration; -} OB_CALLBACK_REGISTRATION, *POB_CALLBACK_REGISTRATION; - typedef struct _OBJECT_NAME_INFORMATION { - UNICODE_STRING Name; + UNICODE_STRING Name; } OBJECT_NAME_INFORMATION, *POBJECT_NAME_INFORMATION; /* Exported object types */ -extern POBJECT_TYPE NTSYSAPI CmKeyObjectType; extern POBJECT_TYPE NTSYSAPI ExEventObjectType; extern POBJECT_TYPE NTSYSAPI ExSemaphoreObjectType; extern POBJECT_TYPE NTSYSAPI IoFileObjectType; @@ -7570,6 +5285,16 @@ extern POBJECT_TYPE NTSYSAPI PsProcessType; #define QUOTA_LIMITS_HARDWS_MAX_DISABLE 0x00000008 #define QUOTA_LIMITS_USE_DEFAULT_LIMITS 0x00000010 +/* Process Qoutas */ +typedef struct _QUOTA_LIMITS { + SIZE_T PagedPoolLimit; + SIZE_T NonPagedPoolLimit; + SIZE_T MinimumWorkingSetSize; + SIZE_T MaximumWorkingSetSize; + SIZE_T PagefileLimit; + LARGE_INTEGER TimeLimit; +} QUOTA_LIMITS, *PQUOTA_LIMITS; + /* Thread Access Rights */ #define THREAD_TERMINATE 0x0001 #define THREAD_SUSPEND_RESUME 0x0002 @@ -7594,76 +5319,18 @@ extern POBJECT_TYPE NTSYSAPI PsProcessType; #define THREAD_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3FF) #endif +#define ES_SYSTEM_REQUIRED 0x00000001 +#define ES_DISPLAY_REQUIRED 0x00000002 +#define ES_USER_PRESENT 0x00000004 +#define ES_CONTINUOUS 0x80000000 + #define LOW_PRIORITY 0 #define LOW_REALTIME_PRIORITY 16 #define HIGH_PRIORITY 31 #define MAXIMUM_PRIORITY 32 -/****************************************************************************** - * WMI Library Support Types * - ******************************************************************************/ - -#ifdef RUN_WPP -#include -#include -#endif - -#ifndef _TRACEHANDLE_DEFINED -#define _TRACEHANDLE_DEFINED -typedef ULONG64 TRACEHANDLE, *PTRACEHANDLE; -#endif - -#ifndef TRACE_INFORMATION_CLASS_DEFINE - -typedef struct _ETW_TRACE_SESSION_SETTINGS { - ULONG Version; - ULONG BufferSize; - ULONG MinimumBuffers; - ULONG MaximumBuffers; - ULONG LoggerMode; - ULONG FlushTimer; - ULONG FlushThreshold; - ULONG ClockType; -} ETW_TRACE_SESSION_SETTINGS, *PETW_TRACE_SESSION_SETTINGS; - -typedef enum _TRACE_INFORMATION_CLASS { - TraceIdClass, - TraceHandleClass, - TraceEnableFlagsClass, - TraceEnableLevelClass, - GlobalLoggerHandleClass, - EventLoggerHandleClass, - AllLoggerHandlesClass, - TraceHandleByNameClass, - LoggerEventsLostClass, - TraceSessionSettingsClass, - LoggerEventsLoggedClass, - MaxTraceInformationClass -} TRACE_INFORMATION_CLASS; - -#endif /* TRACE_INFORMATION_CLASS_DEFINE */ - -#ifndef _ETW_KM_ -#define _ETW_KM_ -#endif - -#include - -typedef VOID -(NTAPI *PETWENABLECALLBACK)( - IN LPCGUID SourceId, - IN ULONG ControlCode, - IN UCHAR Level, - IN ULONGLONG MatchAnyKeyword, - IN ULONGLONG MatchAllKeyword, - IN PEVENT_FILTER_DESCRIPTOR FilterData OPTIONAL, - IN OUT PVOID CallbackContext OPTIONAL); - -#define EVENT_WRITE_FLAG_NO_FAULTING 0x00000001 - - -#if defined(_M_IX86) +#ifdef _X86_ /** Kernel definitions for x86 **/ /* Interrupt request levels */ @@ -7678,11 +5345,11 @@ typedef VOID #define IPI_LEVEL 29 #define POWER_LEVEL 30 #define HIGH_LEVEL 31 -#define CLOCK_LEVEL CLOCK2_LEVEL +#define CLOCK_LEVEL (CLOCK2_LEVEL) -#define KIP0PCRADDRESS 0xffdff000 +#define KIP0PCRADDRESS 0xffdff000 #define KI_USER_SHARED_DATA 0xffdf0000 -#define SharedUserData ((KUSER_SHARED_DATA * CONST)KI_USER_SHARED_DATA) +#define SharedUserData ((KUSER_SHARED_DATA * CONST) KI_USER_SHARED_DATA) #define PAGE_SIZE 0x1000 #define PAGE_SHIFT 12L @@ -7698,14 +5365,14 @@ typedef VOID typedef struct _KFLOATING_SAVE { - ULONG ControlWord; - ULONG StatusWord; - ULONG ErrorOffset; - ULONG ErrorSelector; - ULONG DataOffset; - ULONG DataSelector; - ULONG Cr0NpxState; - ULONG Spare1; + ULONG ControlWord; + ULONG StatusWord; + ULONG ErrorOffset; + ULONG ErrorSelector; + ULONG DataOffset; + ULONG DataSelector; + ULONG Cr0NpxState; + ULONG Spare1; } KFLOATING_SAVE, *PKFLOATING_SAVE; extern NTKERNELAPI volatile KSYSTEM_TIME KeTickCount; @@ -7714,7 +5381,8 @@ extern NTKERNELAPI volatile KSYSTEM_TIME KeTickCount; FORCEINLINE VOID -KeMemoryBarrier(VOID) +KeMemoryBarrier( + VOID) { volatile LONG Barrier; #if defined(__GNUC__) @@ -7724,80 +5392,78 @@ KeMemoryBarrier(VOID) #endif } -NTHALAPI -KIRQL -NTAPI -KeGetCurrentIrql(VOID); - NTHALAPI VOID FASTCALL KfLowerIrql( - IN KIRQL NewIrql); + IN KIRQL NewIrql); #define KeLowerIrql(a) KfLowerIrql(a) NTHALAPI KIRQL FASTCALL KfRaiseIrql( - IN KIRQL NewIrql); + IN KIRQL NewIrql); #define KeRaiseIrql(a,b) *(b) = KfRaiseIrql(a) NTHALAPI KIRQL -NTAPI -KeRaiseIrqlToDpcLevel(VOID); +DDKAPI +KeRaiseIrqlToDpcLevel( + VOID); NTHALAPI KIRQL -NTAPI -KeRaiseIrqlToSynchLevel(VOID); +DDKAPI +KeRaiseIrqlToSynchLevel( + VOID); NTHALAPI KIRQL FASTCALL KfAcquireSpinLock( - IN OUT PKSPIN_LOCK SpinLock); -#define KeAcquireSpinLock(a,b) *(b) = KfAcquireSpinLock(a) + IN PKSPIN_LOCK SpinLock); +#define KeAcquireSpinLock(a,b) *(b) = KfAcquireSpinLock(a) NTHALAPI VOID FASTCALL KfReleaseSpinLock( - IN OUT PKSPIN_LOCK SpinLock, + IN PKSPIN_LOCK SpinLock, IN KIRQL NewIrql); -#define KeReleaseSpinLock(a,b) KfReleaseSpinLock(a,b) +#define KeReleaseSpinLock(a,b) KfReleaseSpinLock(a,b) NTKERNELAPI VOID FASTCALL KefAcquireSpinLockAtDpcLevel( - IN OUT PKSPIN_LOCK SpinLock); + IN PKSPIN_LOCK SpinLock); #define KeAcquireSpinLockAtDpcLevel(SpinLock) KefAcquireSpinLockAtDpcLevel(SpinLock) NTKERNELAPI VOID FASTCALL KefReleaseSpinLockFromDpcLevel( - IN OUT PKSPIN_LOCK SpinLock); + IN PKSPIN_LOCK SpinLock); #define KeReleaseSpinLockFromDpcLevel(SpinLock) KefReleaseSpinLockFromDpcLevel(SpinLock) NTSYSAPI PKTHREAD NTAPI -KeGetCurrentThread(VOID); +KeGetCurrentThread( + VOID); NTKERNELAPI NTSTATUS NTAPI KeSaveFloatingPointState( - OUT PKFLOATING_SAVE FloatSave); + OUT PKFLOATING_SAVE FloatSave); NTKERNELAPI NTSTATUS NTAPI KeRestoreFloatingPointState( - IN PKFLOATING_SAVE FloatSave); + IN PKFLOATING_SAVE FloatSave); /* VOID * KeFlushIoBuffers( @@ -7815,355 +5481,24 @@ VOID _KeQueryTickCount( OUT PLARGE_INTEGER CurrentCount) { - for (;;) { - CurrentCount->HighPart = KeTickCount.High1Time; - CurrentCount->LowPart = KeTickCount.LowPart; - if (CurrentCount->HighPart == KeTickCount.High2Time) break; - YieldProcessor(); - } + for (;;) + { + CurrentCount->HighPart = KeTickCount.High1Time; + CurrentCount->LowPart = KeTickCount.LowPart; + if (CurrentCount->HighPart == KeTickCount.High2Time) break; + YieldProcessor(); + } } #define KeQueryTickCount(CurrentCount) _KeQueryTickCount(CurrentCount) +#endif /* _X86_ */ - -#elif defined(_M_AMD64) -/** Kernel definitions for AMD64 **/ - -/* Interrupt request levels */ -#define PASSIVE_LEVEL 0 -#define LOW_LEVEL 0 -#define APC_LEVEL 1 -#define DISPATCH_LEVEL 2 -#define CMCI_LEVEL 5 -#define CLOCK_LEVEL 13 -#define IPI_LEVEL 14 -#define DRS_LEVEL 14 -#define POWER_LEVEL 14 -#define PROFILE_LEVEL 15 -#define HIGH_LEVEL 15 - -#define KI_USER_SHARED_DATA 0xFFFFF78000000000ULL -#define SharedUserData ((PKUSER_SHARED_DATA const)KI_USER_SHARED_DATA) -#define SharedInterruptTime (KI_USER_SHARED_DATA + 0x8) -#define SharedSystemTime (KI_USER_SHARED_DATA + 0x14) -#define SharedTickCount (KI_USER_SHARED_DATA + 0x320) - -#define PAGE_SIZE 0x1000 -#define PAGE_SHIFT 12L - -#define EFLAG_SIGN 0x8000 -#define EFLAG_ZERO 0x4000 -#define EFLAG_SELECT (EFLAG_SIGN | EFLAG_ZERO) - -#define RESULT_NEGATIVE ((EFLAG_SIGN & ~EFLAG_ZERO) & EFLAG_SELECT) -#define RESULT_ZERO ((~EFLAG_SIGN & EFLAG_ZERO) & EFLAG_SELECT) -#define RESULT_POSITIVE ((~EFLAG_SIGN & ~EFLAG_ZERO) & EFLAG_SELECT) - - -typedef struct _KFLOATING_SAVE { - ULONG Dummy; -} KFLOATING_SAVE, *PKFLOATING_SAVE; - -typedef XSAVE_FORMAT XMM_SAVE_AREA32, *PXMM_SAVE_AREA32; - -#define KeQueryInterruptTime() \ - (*(volatile ULONG64*)SharedInterruptTime) - -#define KeQuerySystemTime(CurrentCount) \ - *(ULONG64*)(CurrentCount) = *(volatile ULONG64*)SharedSystemTime - -#define KeQueryTickCount(CurrentCount) \ - *(ULONG64*)(CurrentCount) = *(volatile ULONG64*)SharedTickCount - -#define KeGetDcacheFillSize() 1L - -#define YieldProcessor _mm_pause - -FORCEINLINE -KIRQL -KeGetCurrentIrql(VOID) -{ - return (KIRQL)__readcr8(); -} - -FORCEINLINE -VOID -KeLowerIrql(IN KIRQL NewIrql) -{ - //ASSERT(KeGetCurrentIrql() >= NewIrql); - __writecr8(NewIrql); -} - -FORCEINLINE -KIRQL -KfRaiseIrql(IN KIRQL NewIrql) -{ - KIRQL OldIrql; - - OldIrql = __readcr8(); - //ASSERT(OldIrql <= NewIrql); - __writecr8(NewIrql); - return OldIrql; -} -#define KeRaiseIrql(a,b) *(b) = KfRaiseIrql(a) - -FORCEINLINE -KIRQL -KeRaiseIrqlToDpcLevel(VOID) -{ - return KfRaiseIrql(DISPATCH_LEVEL); -} - -FORCEINLINE -KIRQL -KeRaiseIrqlToSynchLevel(VOID) -{ - return KfRaiseIrql(12); // SYNCH_LEVEL = IPI_LEVEL - 2 -} - -FORCEINLINE -PKTHREAD -KeGetCurrentThread(VOID) -{ - return (struct _KTHREAD *)__readgsqword(0x188); -} - -/* VOID - * KeFlushIoBuffers( - * IN PMDL Mdl, - * IN BOOLEAN ReadOperation, - * IN BOOLEAN DmaOperation) - */ -#define KeFlushIoBuffers(_Mdl, _ReadOperation, _DmaOperation) - -/* x86 and x64 performs a 0x2C interrupt */ -#define DbgRaiseAssertionFailure __int2c - -#elif defined(_M_IA64) -/** Kernel definitions for IA64 **/ - -/* Interrupt request levels */ -#define PASSIVE_LEVEL 0 -#define LOW_LEVEL 0 -#define APC_LEVEL 1 -#define DISPATCH_LEVEL 2 -#define CMC_LEVEL 3 -#define DEVICE_LEVEL_BASE 4 -#define PC_LEVEL 12 -#define IPI_LEVEL 14 -#define DRS_LEVEL 14 -#define CLOCK_LEVEL 13 -#define POWER_LEVEL 15 -#define PROFILE_LEVEL 15 -#define HIGH_LEVEL 15 - -#define KI_USER_SHARED_DATA ((ULONG_PTR)(KADDRESS_BASE + 0xFFFE0000)) -extern volatile LARGE_INTEGER KeTickCount; - -#define PAUSE_PROCESSOR __yield(); - -FORCEINLINE -VOID -KeFlushWriteBuffer(VOID) -{ - __mf (); - return; -} - -NTSYSAPI -PKTHREAD -NTAPI -KeGetCurrentThread(VOID); - - -#elif defined(_M_PPC) - -/* Interrupt request levels */ -#define PASSIVE_LEVEL 0 -#define LOW_LEVEL 0 -#define APC_LEVEL 1 -#define DISPATCH_LEVEL 2 -#define PROFILE_LEVEL 27 -#define CLOCK1_LEVEL 28 -#define CLOCK2_LEVEL 28 -#define IPI_LEVEL 29 -#define POWER_LEVEL 30 -#define HIGH_LEVEL 31 - -// -// Used to contain PFNs and PFN counts -// -typedef ULONG PFN_COUNT; -typedef ULONG PFN_NUMBER, *PPFN_NUMBER; -typedef LONG SPFN_NUMBER, *PSPFN_NUMBER; - - -typedef struct _KFLOATING_SAVE { - ULONG Dummy; -} KFLOATING_SAVE, *PKFLOATING_SAVE; - -typedef struct _KPCR_TIB { - PVOID ExceptionList; /* 00 */ - PVOID StackBase; /* 04 */ - PVOID StackLimit; /* 08 */ - PVOID SubSystemTib; /* 0C */ - _ANONYMOUS_UNION union { - PVOID FiberData; /* 10 */ - ULONG Version; /* 10 */ - } DUMMYUNIONNAME; - PVOID ArbitraryUserPointer; /* 14 */ - struct _KPCR_TIB *Self; /* 18 */ -} KPCR_TIB, *PKPCR_TIB; /* 1C */ - -#define PCR_MINOR_VERSION 1 -#define PCR_MAJOR_VERSION 1 - -typedef struct _KPCR { - KPCR_TIB Tib; /* 00 */ - struct _KPCR *Self; /* 1C */ - struct _KPRCB *Prcb; /* 20 */ - KIRQL Irql; /* 24 */ - ULONG IRR; /* 28 */ - ULONG IrrActive; /* 2C */ - ULONG IDR; /* 30 */ - PVOID KdVersionBlock; /* 34 */ - PUSHORT IDT; /* 38 */ - PUSHORT GDT; /* 3C */ - struct _KTSS *TSS; /* 40 */ - USHORT MajorVersion; /* 44 */ - USHORT MinorVersion; /* 46 */ - KAFFINITY SetMember; /* 48 */ - ULONG StallScaleFactor; /* 4C */ - UCHAR SpareUnused; /* 50 */ - UCHAR Number; /* 51 */ -} KPCR, *PKPCR; /* 54 */ - -#define KeGetPcr() PCR - -#define YieldProcessor() __asm__ __volatile__("nop"); - -FORCEINLINE -ULONG -NTAPI -KeGetCurrentProcessorNumber(VOID) -{ - ULONG Number; - __asm__ __volatile__ ( - "lwz %0, %c1(12)\n" - : "=r" (Number) - : "i" (FIELD_OFFSET(KPCR, Number)) - ); - return Number; -} - -NTHALAPI -VOID -FASTCALL -KfLowerIrql( - IN KIRQL NewIrql); -#define KeLowerIrql(a) KfLowerIrql(a) - -NTHALAPI -KIRQL -FASTCALL -KfRaiseIrql( - IN KIRQL NewIrql); -#define KeRaiseIrql(a,b) *(b) = KfRaiseIrql(a) - -NTHALAPI -KIRQL -NTAPI -KeRaiseIrqlToDpcLevel(VOID); - -NTHALAPI -KIRQL -NTAPI -KeRaiseIrqlToSynchLevel(VOID); - - - -#elif defined(_M_MIPS) -#error MIPS Headers are totally incorrect - -// -// Used to contain PFNs and PFN counts -// -typedef ULONG PFN_COUNT; -typedef ULONG PFN_NUMBER, *PPFN_NUMBER; -typedef LONG SPFN_NUMBER, *PSPFN_NUMBER; - -#define PASSIVE_LEVEL 0 -#define APC_LEVEL 1 -#define DISPATCH_LEVEL 2 -#define PROFILE_LEVEL 27 -#define IPI_LEVEL 29 -#define HIGH_LEVEL 31 - -typedef struct _KPCR { - struct _KPRCB *Prcb; /* 20 */ - KIRQL Irql; /* 24 */ - ULONG IRR; /* 28 */ - ULONG IDR; /* 30 */ -} KPCR, *PKPCR; - -#define KeGetPcr() PCR - -typedef struct _KFLOATING_SAVE { -} KFLOATING_SAVE, *PKFLOATING_SAVE; - -static __inline -ULONG -NTAPI -KeGetCurrentProcessorNumber(VOID) -{ - return 0; -} - -#define YieldProcessor() __asm__ __volatile__("nop"); - -#define KeLowerIrql(a) KfLowerIrql(a) -#define KeRaiseIrql(a,b) *(b) = KfRaiseIrql(a) - -NTKERNELAPI -VOID -NTAPI -KfLowerIrql( - IN KIRQL NewIrql); - -NTKERNELAPI -KIRQL -NTAPI -KfRaiseIrql( - IN KIRQL NewIrql); - -NTKERNELAPI -KIRQL -NTAPI -KeRaiseIrqlToDpcLevel(VOID); - -NTKERNELAPI -KIRQL -NTAPI -KeRaiseIrqlToSynchLevel(VOID); - - -#elif defined(_M_ARM) -#include -#else -#error Unknown Architecture -#endif - /****************************************************************************** * Runtime Library Functions * ******************************************************************************/ - -#if !defined(MIDL_PASS) && !defined(SORTPP_PASS) - -#define RTL_STATIC_LIST_HEAD(x) LIST_ENTRY x = { &x, &x } - FORCEINLINE VOID InitializeListHead( @@ -8172,78 +5507,11 @@ InitializeListHead( ListHead->Flink = ListHead->Blink = ListHead; } -BOOLEAN -FORCEINLINE -IsListEmpty( - IN CONST LIST_ENTRY * ListHead) -{ - return (BOOLEAN)(ListHead->Flink == ListHead); -} - -FORCEINLINE -BOOLEAN -RemoveEntryList( - IN PLIST_ENTRY Entry) -{ - PLIST_ENTRY OldFlink; - PLIST_ENTRY OldBlink; - - OldFlink = Entry->Flink; - OldBlink = Entry->Blink; - OldFlink->Blink = OldBlink; - OldBlink->Flink = OldFlink; - return (BOOLEAN)(OldFlink == OldBlink); -} - -FORCEINLINE -PLIST_ENTRY -RemoveHeadList( - IN OUT PLIST_ENTRY ListHead) -{ - PLIST_ENTRY Flink; - PLIST_ENTRY Entry; - - Entry = ListHead->Flink; - Flink = Entry->Flink; - ListHead->Flink = Flink; - Flink->Blink = ListHead; - return Entry; -} - -FORCEINLINE -PLIST_ENTRY -RemoveTailList( - IN OUT PLIST_ENTRY ListHead) -{ - PLIST_ENTRY Blink; - PLIST_ENTRY Entry; - - Entry = ListHead->Blink; - Blink = Entry->Blink; - ListHead->Blink = Blink; - Blink->Flink = ListHead; - return Entry; -} - -FORCEINLINE -VOID -InsertTailList( - IN OUT PLIST_ENTRY ListHead, - IN OUT PLIST_ENTRY Entry) -{ - PLIST_ENTRY OldBlink; - OldBlink = ListHead->Blink; - Entry->Flink = ListHead; - Entry->Blink = OldBlink; - OldBlink->Flink = Entry; - ListHead->Blink = Entry; -} - FORCEINLINE VOID InsertHeadList( - IN OUT PLIST_ENTRY ListHead, - IN OUT PLIST_ENTRY Entry) + IN OUT PLIST_ENTRY ListHead, + IN OUT PLIST_ENTRY Entry) { PLIST_ENTRY OldFlink; OldFlink = ListHead->Flink; @@ -8255,16 +5523,24 @@ InsertHeadList( FORCEINLINE VOID -AppendTailList( - IN OUT PLIST_ENTRY ListHead, - IN OUT PLIST_ENTRY ListToAppend) +InsertTailList( + IN OUT PLIST_ENTRY ListHead, + IN OUT PLIST_ENTRY Entry) { - PLIST_ENTRY ListEnd = ListHead->Blink; + PLIST_ENTRY OldBlink; + OldBlink = ListHead->Blink; + Entry->Flink = ListHead; + Entry->Blink = OldBlink; + OldBlink->Flink = Entry; + ListHead->Blink = Entry; +} - ListHead->Blink->Flink = ListToAppend; - ListHead->Blink = ListToAppend->Blink; - ListToAppend->Blink->Flink = ListHead; - ListToAppend->Blink = ListEnd; +BOOLEAN +FORCEINLINE +IsListEmpty( + IN CONST LIST_ENTRY * ListHead) +{ + return (BOOLEAN)(ListHead->Flink == ListHead); } FORCEINLINE @@ -8290,16 +5566,59 @@ PushEntryList( ListHead->Next = Entry; } -#endif /* !defined(MIDL_PASS) && !defined(SORTPP_PASS) */ +FORCEINLINE +BOOLEAN +RemoveEntryList( + IN PLIST_ENTRY Entry) +{ + PLIST_ENTRY OldFlink; + PLIST_ENTRY OldBlink; + + OldFlink = Entry->Flink; + OldBlink = Entry->Blink; + OldFlink->Blink = OldBlink; + OldBlink->Flink = OldFlink; + return (BOOLEAN)(OldFlink == OldBlink); +} + +FORCEINLINE +PLIST_ENTRY +RemoveHeadList( + IN OUT PLIST_ENTRY ListHead) +{ + PLIST_ENTRY Flink; + PLIST_ENTRY Entry; + + Entry = ListHead->Flink; + Flink = Entry->Flink; + ListHead->Flink = Flink; + Flink->Blink = ListHead; + return Entry; +} + +FORCEINLINE +PLIST_ENTRY +RemoveTailList( + IN OUT PLIST_ENTRY ListHead) +{ + PLIST_ENTRY Blink; + PLIST_ENTRY Entry; + + Entry = ListHead->Blink; + Blink = Entry->Blink; + ListHead->Blink = Blink; + Blink->Flink = ListHead; + return Entry; +} NTSYSAPI VOID NTAPI RtlAssert( - IN PVOID FailedAssertion, - IN PVOID FileName, - IN ULONG LineNumber, - IN PSTR Message); + IN PVOID FailedAssertion, + IN PVOID FileName, + IN ULONG LineNumber, + IN PSTR Message); /* VOID * RtlCopyMemory( @@ -8317,9 +5636,9 @@ NTSYSAPI VOID NTAPI RtlCopyMemoryNonTemporal( - VOID UNALIGNED *Destination, - CONST VOID UNALIGNED *Source, - SIZE_T Length); + VOID UNALIGNED *Destination, + CONST VOID UNALIGNED *Source, + SIZE_T Length); #else #define RtlCopyMemoryNonTemporal RtlCopyMemory #endif @@ -8356,21 +5675,21 @@ NTSYSAPI VOID NTAPI RtlFreeUnicodeString( - IN OUT PUNICODE_STRING UnicodeString); + IN OUT PUNICODE_STRING UnicodeString); NTSYSAPI NTSTATUS NTAPI RtlGUIDFromString( - IN PUNICODE_STRING GuidString, - OUT GUID *Guid); + IN PUNICODE_STRING GuidString, + OUT GUID *Guid); NTSYSAPI VOID NTAPI RtlInitUnicodeString( - IN OUT PUNICODE_STRING DestinationString, - IN PCWSTR SourceString OPTIONAL); + IN OUT PUNICODE_STRING DestinationString, + IN PCWSTR SourceString OPTIONAL); /* VOID * RtlMoveMemory( @@ -8385,8 +5704,8 @@ NTSYSAPI NTSTATUS NTAPI RtlStringFromGUID( - IN REFGUID Guid, - OUT PUNICODE_STRING GuidString); + IN REFGUID Guid, + OUT PUNICODE_STRING GuidString); /* VOID * RtlZeroMemory( @@ -8398,39 +5717,37 @@ RtlStringFromGUID( #define RtlZeroBytes RtlZeroMemory + #if (NTDDI_VERSION >= NTDDI_WIN2K) - - - NTSYSAPI BOOLEAN NTAPI RtlAreBitsClear( - IN PRTL_BITMAP BitMapHeader, - IN ULONG StartingIndex, - IN ULONG Length); + IN PRTL_BITMAP BitMapHeader, + IN ULONG StartingIndex, + IN ULONG Length); NTSYSAPI BOOLEAN NTAPI RtlAreBitsSet( - IN PRTL_BITMAP BitMapHeader, - IN ULONG StartingIndex, - IN ULONG Length); + IN PRTL_BITMAP BitMapHeader, + IN ULONG StartingIndex, + IN ULONG Length); NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString( - IN OUT PUNICODE_STRING DestinationString, - IN PANSI_STRING SourceString, - IN BOOLEAN AllocateDestinationString); + IN OUT PUNICODE_STRING DestinationString, + IN PANSI_STRING SourceString, + IN BOOLEAN AllocateDestinationString); NTSYSAPI ULONG NTAPI RtlxAnsiStringToUnicodeSize( - IN PCANSI_STRING AnsiString); + IN PCANSI_STRING AnsiString); #define RtlAnsiStringToUnicodeSize(String) ( \ NLS_MB_CODE_PAGE_TAG ? \ @@ -8442,107 +5759,107 @@ NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString( - IN OUT PUNICODE_STRING Destination, - IN PCUNICODE_STRING Source); + IN OUT PUNICODE_STRING Destination, + IN PCUNICODE_STRING Source); NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeToString( - IN OUT PUNICODE_STRING Destination, - IN PCWSTR Source); + IN OUT PUNICODE_STRING Destination, + IN PCWSTR Source); NTSYSAPI NTSTATUS NTAPI RtlCheckRegistryKey( - IN ULONG RelativeTo, - IN PWSTR Path); + IN ULONG RelativeTo, + IN PWSTR Path); NTSYSAPI VOID NTAPI RtlClearAllBits( - IN PRTL_BITMAP BitMapHeader); + IN PRTL_BITMAP BitMapHeader); NTSYSAPI VOID NTAPI RtlClearBits( - IN PRTL_BITMAP BitMapHeader, - IN ULONG StartingIndex, - IN ULONG NumberToClear); + IN PRTL_BITMAP BitMapHeader, + IN ULONG StartingIndex, + IN ULONG NumberToClear); NTSYSAPI SIZE_T NTAPI RtlCompareMemory( - IN CONST VOID *Source1, - IN CONST VOID *Source2, - IN SIZE_T Length); + IN CONST VOID *Source1, + IN CONST VOID *Source2, + IN SIZE_T Length); NTSYSAPI LONG NTAPI RtlCompareUnicodeString( - IN PCUNICODE_STRING String1, - IN PCUNICODE_STRING String2, - IN BOOLEAN CaseInSensitive); + IN PCUNICODE_STRING String1, + IN PCUNICODE_STRING String2, + IN BOOLEAN CaseInSensitive); NTSYSAPI LONG NTAPI RtlCompareUnicodeStrings( - IN PCWCH String1, - IN SIZE_T String1Length, - IN PCWCH String2, - IN SIZE_T String2Length, - IN BOOLEAN CaseInSensitive); + IN PCWCH String1, + IN SIZE_T String1Length, + IN PCWCH String2, + IN SIZE_T String2Length, + IN BOOLEAN CaseInSensitive); NTSYSAPI VOID NTAPI RtlCopyUnicodeString( - IN OUT PUNICODE_STRING DestinationString, - IN PCUNICODE_STRING SourceString OPTIONAL); + IN OUT PUNICODE_STRING DestinationString, + IN PCUNICODE_STRING SourceString); NTSYSAPI NTSTATUS NTAPI RtlCreateRegistryKey( - IN ULONG RelativeTo, - IN PWSTR Path); + IN ULONG RelativeTo, + IN PWSTR Path); NTSYSAPI NTSTATUS NTAPI RtlCreateSecurityDescriptor( - IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor, - IN ULONG Revision); + IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor, + IN ULONG Revision); NTSYSAPI NTSTATUS NTAPI RtlDeleteRegistryValue( - IN ULONG RelativeTo, - IN PCWSTR Path, - IN PCWSTR ValueName); + IN ULONG RelativeTo, + IN PCWSTR Path, + IN PCWSTR ValueName); NTSYSAPI BOOLEAN NTAPI RtlEqualUnicodeString( - IN CONST UNICODE_STRING *String1, - IN CONST UNICODE_STRING *String2, - IN BOOLEAN CaseInSensitive); + IN CONST UNICODE_STRING *String1, + IN CONST UNICODE_STRING *String2, + IN BOOLEAN CaseInSensitive); #if !defined(_AMD64_) && !defined(_IA64_) NTSYSAPI LARGE_INTEGER NTAPI RtlExtendedIntegerMultiply( - IN LARGE_INTEGER Multiplicand, - IN LONG Multiplier); + IN LARGE_INTEGER Multiplicand, + IN LONG Multiplier); NTSYSAPI LARGE_INTEGER @@ -8550,7 +5867,7 @@ NTAPI RtlExtendedLargeIntegerDivide( IN LARGE_INTEGER Dividend, IN ULONG Divisor, - OUT PULONG Remainder OPTIONAL); + IN OUT PULONG Remainder); #endif #if defined(_X86_) || defined(_IA64_) @@ -8567,128 +5884,137 @@ NTSYSAPI VOID NTAPI RtlFreeAnsiString( - IN PANSI_STRING AnsiString); + IN PANSI_STRING AnsiString); NTSYSAPI ULONG NTAPI RtlFindClearBits( - IN PRTL_BITMAP BitMapHeader, - IN ULONG NumberToFind, - IN ULONG HintIndex); + IN PRTL_BITMAP BitMapHeader, + IN ULONG NumberToFind, + IN ULONG HintIndex); NTSYSAPI ULONG NTAPI RtlFindClearBitsAndSet( - IN PRTL_BITMAP BitMapHeader, - IN ULONG NumberToFind, - IN ULONG HintIndex); + IN PRTL_BITMAP BitMapHeader, + IN ULONG NumberToFind, + IN ULONG HintIndex); NTSYSAPI ULONG NTAPI RtlFindFirstRunClear( - IN PRTL_BITMAP BitMapHeader, - OUT PULONG StartingIndex); + IN PRTL_BITMAP BitMapHeader, + OUT PULONG StartingIndex); NTSYSAPI ULONG NTAPI RtlFindClearRuns( - IN PRTL_BITMAP BitMapHeader, - OUT PRTL_BITMAP_RUN RunArray, - IN ULONG SizeOfRunArray, - IN BOOLEAN LocateLongestRuns); + IN PRTL_BITMAP BitMapHeader, + OUT PRTL_BITMAP_RUN RunArray, + IN ULONG SizeOfRunArray, + IN BOOLEAN LocateLongestRuns); NTSYSAPI ULONG NTAPI RtlFindLastBackwardRunClear( - IN PRTL_BITMAP BitMapHeader, - IN ULONG FromIndex, - OUT PULONG StartingRunIndex); + IN PRTL_BITMAP BitMapHeader, + IN ULONG FromIndex, + OUT PULONG StartingRunIndex); NTSYSAPI CCHAR NTAPI RtlFindLeastSignificantBit( - IN ULONGLONG Set); + IN ULONGLONG Set); NTSYSAPI ULONG NTAPI RtlFindLongestRunClear( - IN PRTL_BITMAP BitMapHeader, - OUT PULONG StartingIndex); + IN PRTL_BITMAP BitMapHeader, + OUT PULONG StartingIndex); NTSYSAPI CCHAR NTAPI RtlFindMostSignificantBit( - IN ULONGLONG Set); + IN ULONGLONG Set); NTSYSAPI ULONG NTAPI RtlFindNextForwardRunClear( - IN PRTL_BITMAP BitMapHeader, - IN ULONG FromIndex, - OUT PULONG StartingRunIndex); + IN PRTL_BITMAP BitMapHeader, + IN ULONG FromIndex, + OUT PULONG StartingRunIndex); NTSYSAPI ULONG NTAPI RtlFindSetBits( - IN PRTL_BITMAP BitMapHeader, - IN ULONG NumberToFind, - IN ULONG HintIndex); + IN PRTL_BITMAP BitMapHeader, + IN ULONG NumberToFind, + IN ULONG HintIndex); NTSYSAPI ULONG NTAPI RtlFindSetBitsAndClear( - IN PRTL_BITMAP BitMapHeader, - IN ULONG NumberToFind, - IN ULONG HintIndex); + IN PRTL_BITMAP BitMapHeader, + IN ULONG NumberToFind, + IN ULONG HintIndex); + +NTSYSAPI +NTSTATUS +NTAPI +RtlHashUnicodeString( + IN CONST UNICODE_STRING *String, + IN BOOLEAN CaseInSensitive, + IN ULONG HashAlgorithm, + OUT PULONG HashValue); NTSYSAPI VOID NTAPI RtlInitAnsiString( - IN OUT PANSI_STRING DestinationString, - IN PCSZ SourceString); + IN OUT PANSI_STRING DestinationString, + IN PCSZ SourceString); NTSYSAPI VOID NTAPI RtlInitializeBitMap( - IN PRTL_BITMAP BitMapHeader, - IN PULONG BitMapBuffer, - IN ULONG SizeOfBitMap); + IN PRTL_BITMAP BitMapHeader, + IN PULONG BitMapBuffer, + IN ULONG SizeOfBitMap); NTSYSAPI VOID NTAPI RtlInitString( - IN OUT PSTRING DestinationString, - IN PCSZ SourceString); + IN OUT PSTRING DestinationString, + IN PCSZ SourceString); NTSYSAPI NTSTATUS NTAPI RtlIntegerToUnicodeString( - IN ULONG Value, - IN ULONG Base OPTIONAL, - IN OUT PUNICODE_STRING String); + IN ULONG Value, + IN ULONG Base OPTIONAL, + IN OUT PUNICODE_STRING String); NTSYSAPI NTSTATUS NTAPI RtlInt64ToUnicodeString( - IN ULONGLONG Value, - IN ULONG Base OPTIONAL, - IN OUT PUNICODE_STRING String); + IN ULONGLONG Value, + IN ULONG Base OPTIONAL, + IN OUT PUNICODE_STRING String); #ifdef _WIN64 #define RtlIntPtrToUnicodeString(Value, Base, String) \ @@ -8709,151 +6035,42 @@ NTSYSAPI ULONG NTAPI RtlLengthSecurityDescriptor( - IN PSECURITY_DESCRIPTOR SecurityDescriptor); + IN PSECURITY_DESCRIPTOR SecurityDescriptor); NTSYSAPI ULONG NTAPI RtlNumberOfClearBits( - IN PRTL_BITMAP BitMapHeader); + IN PRTL_BITMAP BitMapHeader); NTSYSAPI ULONG NTAPI RtlNumberOfSetBits( - IN PRTL_BITMAP BitMapHeader); + IN PRTL_BITMAP BitMapHeader); NTSYSAPI NTSTATUS NTAPI RtlQueryRegistryValues( - IN ULONG RelativeTo, - IN PCWSTR Path, - IN OUT PRTL_QUERY_REGISTRY_TABLE QueryTable, - IN PVOID Context OPTIONAL, - IN PVOID Environment OPTIONAL); + IN ULONG RelativeTo, + IN PCWSTR Path, + IN PRTL_QUERY_REGISTRY_TABLE QueryTable, + IN PVOID Context, + IN PVOID Environment OPTIONAL); -#define SHORT_SIZE (sizeof(USHORT)) -#define SHORT_MASK (SHORT_SIZE - 1) #define LONG_SIZE (sizeof(LONG)) -#define LONGLONG_SIZE (sizeof(LONGLONG)) #define LONG_MASK (LONG_SIZE - 1) -#define LONGLONG_MASK (LONGLONG_SIZE - 1) -#define LOWBYTE_MASK 0x00FF - -#define FIRSTBYTE(VALUE) ((VALUE) & LOWBYTE_MASK) -#define SECONDBYTE(VALUE) (((VALUE) >> 8) & LOWBYTE_MASK) -#define THIRDBYTE(VALUE) (((VALUE) >> 16) & LOWBYTE_MASK) -#define FOURTHBYTE(VALUE) (((VALUE) >> 24) & LOWBYTE_MASK) - -NTSYSAPI -VOID -NTAPI -RtlSetAllBits( - IN PRTL_BITMAP BitMapHeader); - -NTSYSAPI -VOID -NTAPI -RtlSetBits( - IN PRTL_BITMAP BitMapHeader, - IN ULONG StartingIndex, - IN ULONG NumberToSet); - -NTSYSAPI -NTSTATUS -NTAPI -RtlSetDaclSecurityDescriptor( - IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor, - IN BOOLEAN DaclPresent, - IN PACL Dacl OPTIONAL, - IN BOOLEAN DaclDefaulted OPTIONAL); - -#if defined(_AMD64_) - -/* VOID - * RtlStoreUlong( - * IN PULONG Address, - * IN ULONG Value); - */ -#define RtlStoreUlong(Address,Value) \ - *(ULONG UNALIGNED *)(Address) = (Value) - -/* VOID - * RtlStoreUlonglong( - * IN OUT PULONGLONG Address, - * ULONGLONG Value); - */ -#define RtlStoreUlonglong(Address,Value) \ - *(ULONGLONG UNALIGNED *)(Address) = (Value) - -/* VOID - * RtlStoreUshort( - * IN PUSHORT Address, - * IN USHORT Value); - */ -#define RtlStoreUshort(Address,Value) \ - *(USHORT UNALIGNED *)(Address) = (Value) - -/* VOID - * RtlRetrieveUshort( - * PUSHORT DestinationAddress, - * PUSHORT SourceAddress); - */ -#define RtlRetrieveUshort(DestAddress,SrcAddress) \ - *(USHORT UNALIGNED *)(DestAddress) = *(USHORT)(SrcAddress) /* VOID * RtlRetrieveUlong( - * PULONG DestinationAddress, - * PULONG SourceAddress); + * PULONG DestinationAddress, + * PULONG SourceAddress); */ +#if defined(_AMD64_) #define RtlRetrieveUlong(DestAddress,SrcAddress) \ *(ULONG UNALIGNED *)(DestAddress) = *(PULONG)(SrcAddress) - #else - -#define RtlStoreUlong(Address,Value) \ - if ((ULONG_PTR)(Address) & LONG_MASK) { \ - ((PUCHAR) (Address))[LONG_LEAST_SIGNIFICANT_BIT] = (UCHAR)(FIRSTBYTE(Value)); \ - ((PUCHAR) (Address))[LONG_3RD_MOST_SIGNIFICANT_BIT] = (UCHAR)(SECONDBYTE(Value)); \ - ((PUCHAR) (Address))[LONG_2ND_MOST_SIGNIFICANT_BIT] = (UCHAR)(THIRDBYTE(Value)); \ - ((PUCHAR) (Address))[LONG_MOST_SIGNIFICANT_BIT] = (UCHAR)(FOURTHBYTE(Value)); \ - } \ - else { \ - *((PULONG)(Address)) = (ULONG) (Value); \ - } - -#define RtlStoreUlonglong(Address,Value) \ - if ((ULONG_PTR)(Address) & LONGLONG_MASK) { \ - RtlStoreUlong((ULONG_PTR)(Address), \ - (ULONGLONG)(Value) & 0xFFFFFFFF); \ - RtlStoreUlong((ULONG_PTR)(Address)+sizeof(ULONG), \ - (ULONGLONG)(Value) >> 32); \ - } else { \ - *((PULONGLONG)(Address)) = (ULONGLONG)(Value); \ - } - -#define RtlStoreUshort(Address,Value) \ - if ((ULONG_PTR)(Address) & SHORT_MASK) { \ - ((PUCHAR) (Address))[SHORT_LEAST_SIGNIFICANT_BIT] = (UCHAR)(FIRSTBYTE(Value)); \ - ((PUCHAR) (Address))[SHORT_MOST_SIGNIFICANT_BIT ] = (UCHAR)(SECONDBYTE(Value)); \ - } \ - else { \ - *((PUSHORT) (Address)) = (USHORT)Value; \ - } - -#define RtlRetrieveUshort(DestAddress,SrcAddress) \ - if ((ULONG_PTR)(SrcAddress) & LONG_MASK) \ - { \ - ((PUCHAR)(DestAddress))[0]=((PUCHAR)(SrcAddress))[0]; \ - ((PUCHAR)(DestAddress))[1]=((PUCHAR)(SrcAddress))[1]; \ - } \ - else \ - { \ - *((PUSHORT)(DestAddress))=*((PUSHORT)(SrcAddress)); \ - } - #define RtlRetrieveUlong(DestAddress,SrcAddress) \ if ((ULONG_PTR)(SrcAddress) & LONG_MASK) \ { \ @@ -8866,60 +6083,164 @@ RtlSetDaclSecurityDescriptor( { \ *((PULONG)(DestAddress))=*((PULONG)(SrcAddress)); \ } +#endif -#endif /* defined(_AMD64_) */ +/* VOID + * RtlRetrieveUshort( + * PUSHORT DestinationAddress, + * PUSHORT SourceAddress); + */ +#if defined(_AMD64_) +#define RtlRetrieveUshort(DestAddress,SrcAddress) \ + *(USHORT UNALIGNED *)(DestAddress) = *(USHORT)(SrcAddress) +#else +#define RtlRetrieveUshort(DestAddress,SrcAddress) \ + if ((ULONG_PTR)(SrcAddress) & LONG_MASK) \ + { \ + ((PUCHAR)(DestAddress))[0]=((PUCHAR)(SrcAddress))[0]; \ + ((PUCHAR)(DestAddress))[1]=((PUCHAR)(SrcAddress))[1]; \ + } \ + else \ + { \ + *((PUSHORT)(DestAddress))=*((PUSHORT)(SrcAddress)); \ + } +#endif + +NTSYSAPI +VOID +NTAPI +RtlSetAllBits( + IN PRTL_BITMAP BitMapHeader); + +NTSYSAPI +VOID +NTAPI +RtlSetBits( + IN PRTL_BITMAP BitMapHeader, + IN ULONG StartingIndex, + IN ULONG NumberToSet); + +NTSYSAPI +NTSTATUS +NTAPI +RtlSetDaclSecurityDescriptor( + IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor, + IN BOOLEAN DaclPresent, + IN PACL Dacl OPTIONAL, + IN BOOLEAN DaclDefaulted OPTIONAL); + +/* VOID + * RtlStoreUlong( + * IN PULONG Address, + * IN ULONG Value); + */ +#if defined(_AMD64_) +#define RtlStoreUlong(Address,Value) \ + *(ULONG UNALIGNED *)(Address) = (Value) +#else +#define RtlStoreUlong(Address,Value) \ + if ((ULONG_PTR)(Address) & LONG_MASK) { \ + ((PUCHAR) (Address))[LONG_LEAST_SIGNIFICANT_BIT] = (UCHAR)(FIRSTBYTE(Value)); \ + ((PUCHAR) (Address))[LONG_3RD_MOST_SIGNIFICANT_BIT] = (UCHAR)(SECONDBYTE(Value)); \ + ((PUCHAR) (Address))[LONG_2ND_MOST_SIGNIFICANT_BIT] = (UCHAR)(THIRDBYTE(Value)); \ + ((PUCHAR) (Address))[LONG_MOST_SIGNIFICANT_BIT] = (UCHAR)(FOURTHBYTE(Value)); \ + } \ + else { \ + *((PULONG)(Address)) = (ULONG) (Value); \ + } +#endif + +/* VOID + * RtlStoreUlonglong( + * IN OUT PULONGLONG Address, + * ULONGLONG Value); + */ +#if defined(_AMD64_) +#define RtlStoreUlonglong(Address,Value) \ + *(ULONGLONG UNALIGNED *)(Address) = (Value) +#else +#define RtlStoreUlonglong(Address,Value) \ + if ((ULONG_PTR)(Address) & LONGLONG_MASK) { \ + RtlStoreUlong((ULONG_PTR)(Address), \ + (ULONGLONG)(Value) & 0xFFFFFFFF); \ + RtlStoreUlong((ULONG_PTR)(Address)+sizeof(ULONG), \ + (ULONGLONG)(Value) >> 32); \ + } else { \ + *((PULONGLONG)(Address)) = (ULONGLONG)(Value); \ + } +#endif -#ifdef _WIN64 /* VOID * RtlStoreUlongPtr( * IN OUT PULONG_PTR Address, * IN ULONG_PTR Value); */ -#define RtlStoreUlongPtr(Address,Value) RtlStoreUlonglong(Address,Value) +#ifdef _WIN64 +#define RtlStoreUlongPtr(Address,Value) \ + RtlStoreUlonglong(Address,Value) #else -#define RtlStoreUlongPtr(Address,Value) RtlStoreUlong(Address,Value) -#endif /* _WIN64 */ +#define RtlStoreUlongPtr(Address,Value) \ + RtlStoreUlong(Address,Value) +#endif +/* VOID + * RtlStoreUshort( + * IN PUSHORT Address, + * IN USHORT Value); + */ +#if defined(_AMD64_) +#define RtlStoreUshort(Address,Value) \ + *(USHORT UNALIGNED *)(Address) = (Value) +#else +#define RtlStoreUshort(Address,Value) \ + if ((ULONG_PTR)(Address) & SHORT_MASK) { \ + ((PUCHAR) (Address))[SHORT_LEAST_SIGNIFICANT_BIT] = (UCHAR)(FIRSTBYTE(Value)); \ + ((PUCHAR) (Address))[SHORT_MOST_SIGNIFICANT_BIT ] = (UCHAR)(SECONDBYTE(Value)); \ + } \ + else { \ + *((PUSHORT) (Address)) = (USHORT)Value; \ + } +#endif NTSYSAPI BOOLEAN NTAPI RtlTimeFieldsToTime( - IN PTIME_FIELDS TimeFields, - IN PLARGE_INTEGER Time); + IN PTIME_FIELDS TimeFields, + IN PLARGE_INTEGER Time); NTSYSAPI VOID NTAPI RtlTimeToTimeFields( - IN PLARGE_INTEGER Time, - IN PTIME_FIELDS TimeFields); + IN PLARGE_INTEGER Time, + IN PTIME_FIELDS TimeFields); NTSYSAPI ULONG FASTCALL RtlUlongByteSwap( - IN ULONG Source); + IN ULONG Source); NTSYSAPI ULONGLONG FASTCALL RtlUlonglongByteSwap( - IN ULONGLONG Source); + IN ULONGLONG Source); NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToAnsiString( - IN OUT PANSI_STRING DestinationString, - IN PCUNICODE_STRING SourceString, - IN BOOLEAN AllocateDestinationString); + IN OUT PANSI_STRING DestinationString, + IN PCUNICODE_STRING SourceString, + IN BOOLEAN AllocateDestinationString); NTSYSAPI ULONG NTAPI RtlxUnicodeStringToAnsiSize( - IN PCUNICODE_STRING UnicodeString); + IN PCUNICODE_STRING UnicodeString); #define RtlUnicodeStringToAnsiSize(String) ( \ NLS_MB_CODE_PAGE_TAG ? \ @@ -8931,193 +6252,130 @@ NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToInteger( - IN PCUNICODE_STRING String, - IN ULONG Base OPTIONAL, - OUT PULONG Value); + IN PCUNICODE_STRING String, + IN ULONG Base OPTIONAL, + OUT PULONG Value); NTSYSAPI WCHAR NTAPI RtlUpcaseUnicodeChar( - IN WCHAR SourceCharacter); + IN WCHAR SourceCharacter); NTSYSAPI USHORT FASTCALL RtlUshortByteSwap( - IN USHORT Source); + IN USHORT Source); NTSYSAPI BOOLEAN NTAPI RtlValidRelativeSecurityDescriptor( - IN PSECURITY_DESCRIPTOR SecurityDescriptorInput, - IN ULONG SecurityDescriptorLength, - IN SECURITY_INFORMATION RequiredInformation); + IN PSECURITY_DESCRIPTOR SecurityDescriptorInput, + IN ULONG SecurityDescriptorLength, + IN SECURITY_INFORMATION RequiredInformation); NTSYSAPI BOOLEAN NTAPI RtlValidSecurityDescriptor( - IN PSECURITY_DESCRIPTOR SecurityDescriptor); + IN PSECURITY_DESCRIPTOR SecurityDescriptor); NTSYSAPI NTSTATUS NTAPI RtlWriteRegistryValue( - IN ULONG RelativeTo, - IN PCWSTR Path, - IN PCWSTR ValueName, - IN ULONG ValueType, - IN PVOID ValueData, - IN ULONG ValueLength); - - -#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ + IN ULONG RelativeTo, + IN PCWSTR Path, + IN PCWSTR ValueName, + IN ULONG ValueType, + IN PVOID ValueData, + IN ULONG ValueLength); +#endif // (NTDDI_VERSION >= NTDDI_WIN2K) #if (NTDDI_VERSION >= NTDDI_WIN2KSP3) NTSYSAPI VOID FASTCALL RtlPrefetchMemoryNonTemporal( - IN PVOID Source, - IN SIZE_T Length); + IN PVOID Source, + IN SIZE_T Length); #endif - #if (NTDDI_VERSION >= NTDDI_WINXP) - - - NTSYSAPI VOID NTAPI RtlClearBit( - PRTL_BITMAP BitMapHeader, - ULONG BitNumber); + PRTL_BITMAP BitMapHeader, + ULONG BitNumber); NTSYSAPI WCHAR NTAPI RtlDowncaseUnicodeChar( - IN WCHAR SourceCharacter); + IN WCHAR SourceCharacter); NTSYSAPI VOID NTAPI RtlSetBit( - PRTL_BITMAP BitMapHeader, - ULONG BitNumber); + PRTL_BITMAP BitMapHeader, + ULONG BitNumber); NTSYSAPI BOOLEAN NTAPI RtlTestBit( - IN PRTL_BITMAP BitMapHeader, - IN ULONG BitNumber); + IN PRTL_BITMAP BitMapHeader, + IN ULONG BitNumber); -NTSYSAPI -NTSTATUS -NTAPI -RtlHashUnicodeString( - IN CONST UNICODE_STRING *String, - IN BOOLEAN CaseInSensitive, - IN ULONG HashAlgorithm, - OUT PULONG HashValue); - - -#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ +#endif // (NTDDI_VERSION >= NTDDI_WINXP) #if (NTDDI_VERSION >= NTDDI_VISTA) - - - NTSYSAPI ULONG NTAPI RtlNumberOfSetBitsUlongPtr( - IN ULONG_PTR Target); + IN ULONG_PTR Target); NTSYSAPI ULONGLONG NTAPI -RtlIoDecodeMemIoResource( - IN struct _IO_RESOURCE_DESCRIPTOR *Descriptor, - OUT PULONGLONG Alignment OPTIONAL, - OUT PULONGLONG MinimumAddress OPTIONAL, - OUT PULONGLONG MaximumAddress OPTIONAL); +RtlIoDecodeMemIoResource ( + IN struct _IO_RESOURCE_DESCRIPTOR *Descriptor, + OUT PULONGLONG Alignment OPTIONAL, + OUT PULONGLONG MinimumAddress OPTIONAL, + OUT PULONGLONG MaximumAddress OPTIONAL); NTSYSAPI NTSTATUS NTAPI RtlIoEncodeMemIoResource( - IN struct _IO_RESOURCE_DESCRIPTOR *Descriptor, - IN UCHAR Type, - IN ULONGLONG Length, - IN ULONGLONG Alignment, - IN ULONGLONG MinimumAddress, - IN ULONGLONG MaximumAddress); + IN struct _IO_RESOURCE_DESCRIPTOR *Descriptor, + IN UCHAR Type, + IN ULONGLONG Length, + IN ULONGLONG Alignment, + IN ULONGLONG MinimumAddress, + IN ULONGLONG MaximumAddress); NTSYSAPI ULONGLONG NTAPI RtlCmDecodeMemIoResource( - IN struct _CM_PARTIAL_RESOURCE_DESCRIPTOR *Descriptor, - OUT PULONGLONG Start OPTIONAL); + IN struct _CM_PARTIAL_RESOURCE_DESCRIPTOR *Descriptor, + OUT PULONGLONG Start OPTIONAL); NTSYSAPI NTSTATUS NTAPI RtlFindClosestEncodableLength( - IN ULONGLONG SourceLength, - OUT PULONGLONG TargetLength); - -NTSYSAPI -NTSTATUS -NTAPI -RtlCmEncodeMemIoResource( - IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor, - IN UCHAR Type, - IN ULONGLONG Length, - IN ULONGLONG Start); - - -#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ - -#if (NTDDI_VERSION >= NTDDI_WIN7) - - - -NTSYSAPI -NTSTATUS -NTAPI -RtlUnicodeToUTF8N( - OUT PCHAR UTF8StringDestination, - IN ULONG UTF8StringMaxByteCount, - OUT PULONG UTF8StringActualByteCount, - IN PCWCH UnicodeStringSource, - IN ULONG UnicodeStringByteCount); - -NTSYSAPI -NTSTATUS -NTAPI -RtlUTF8ToUnicodeN( - OUT PWSTR UnicodeStringDestination, - IN ULONG UnicodeStringMaxByteCount, - OUT PULONG UnicodeStringActualByteCount, - IN PCCH UTF8StringSource, - IN ULONG UTF8StringByteCount); - -NTSYSAPI -ULONG64 -NTAPI -RtlGetEnabledExtendedFeatures( - IN ULONG64 FeatureMask); - - -#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + IN ULONGLONG SourceLength, + OUT PULONGLONG TargetLength); +#endif #if !defined(MIDL_PASS) /* inline funftions */ @@ -9125,12 +6383,11 @@ RtlGetEnabledExtendedFeatures( static __inline LARGE_INTEGER NTAPI_INLINE -RtlConvertLongToLargeInteger( - IN LONG SignedInteger) +RtlConvertLongToLargeInteger(LONG SignedInteger) { - LARGE_INTEGER ret; - ret.QuadPart = SignedInteger; - return ret; + LARGE_INTEGER ret; + ret.QuadPart = SignedInteger; + return ret; } //DECLSPEC_DEPRECATED_DDK_WINXP @@ -9138,39 +6395,11 @@ static __inline LARGE_INTEGER NTAPI_INLINE RtlConvertUlongToLargeInteger( - IN ULONG UnsignedInteger) + ULONG UnsignedInteger) { - LARGE_INTEGER ret; - ret.QuadPart = UnsignedInteger; - return ret; -} - -//DECLSPEC_DEPRECATED_DDK_WINXP -static __inline -LARGE_INTEGER -NTAPI_INLINE -RtlLargeIntegerShiftLeft( - IN LARGE_INTEGER LargeInteger, - IN CCHAR ShiftCount) -{ - LARGE_INTEGER Result; - - Result.QuadPart = LargeInteger.QuadPart << ShiftCount; - return Result; -} - -//DECLSPEC_DEPRECATED_DDK_WINXP -static __inline -LARGE_INTEGER -NTAPI_INLINE -RtlLargeIntegerShiftRight( - IN LARGE_INTEGER LargeInteger, - IN CCHAR ShiftCount) -{ - LARGE_INTEGER Result; - - Result.QuadPart = (ULONG64)LargeInteger.QuadPart >> ShiftCount; - return Result; + LARGE_INTEGER ret; + ret.QuadPart = UnsignedInteger; + return ret; } //DECLSPEC_DEPRECATED_DDK @@ -9178,40 +6407,13 @@ static __inline ULONG NTAPI_INLINE RtlEnlargedUnsignedDivide( - IN ULARGE_INTEGER Dividend, - IN ULONG Divisor, - IN OUT PULONG Remainder) + IN ULARGE_INTEGER Dividend, + IN ULONG Divisor, + IN OUT PULONG Remainder) { - if (Remainder) - *Remainder = (ULONG)(Dividend.QuadPart % Divisor); - return (ULONG)(Dividend.QuadPart / Divisor); -} - -//DECLSPEC_DEPRECATED_DDK -static __inline -LARGE_INTEGER -NTAPI_INLINE -RtlLargeIntegerNegate( - IN LARGE_INTEGER Subtrahend) -{ - LARGE_INTEGER Difference; - - Difference.QuadPart = -Subtrahend.QuadPart; - return Difference; -} - -//DECLSPEC_DEPRECATED_DDK -static __inline -LARGE_INTEGER -NTAPI_INLINE -RtlLargeIntegerSubtract( - IN LARGE_INTEGER Minuend, - IN LARGE_INTEGER Subtrahend) -{ - LARGE_INTEGER Difference; - - Difference.QuadPart = Minuend.QuadPart - Subtrahend.QuadPart; - return Difference; + if (Remainder) + *Remainder = (ULONG)(Dividend.QuadPart % Divisor); + return (ULONG)(Dividend.QuadPart / Divisor); } //DECLSPEC_DEPRECATED_DDK @@ -9219,12 +6421,12 @@ static __inline LARGE_INTEGER NTAPI_INLINE RtlEnlargedUnsignedMultiply( - IN ULONG Multiplicand, - IN ULONG Multiplier) + IN ULONG Multiplicand, + IN ULONG Multiplier) { - LARGE_INTEGER ret; - ret.QuadPart = (ULONGLONG)Multiplicand * (ULONGLONG)Multiplier; - return ret; + LARGE_INTEGER ret; + ret.QuadPart = (ULONGLONG)Multiplicand * (ULONGLONG)Multiplier; + return ret; } //DECLSPEC_DEPRECATED_DDK @@ -9232,72 +6434,65 @@ static __inline LARGE_INTEGER NTAPI_INLINE RtlEnlargedIntegerMultiply( - IN LONG Multiplicand, - IN LONG Multiplier) + IN LONG Multiplicand, + IN LONG Multiplier) { - LARGE_INTEGER ret; - ret.QuadPart = (LONGLONG)Multiplicand * (ULONGLONG)Multiplier; - return ret; + LARGE_INTEGER ret; + ret.QuadPart = (LONGLONG)Multiplicand * (ULONGLONG)Multiplier; + return ret; } FORCEINLINE VOID -RtlInitEmptyAnsiString( - OUT PANSI_STRING AnsiString, - IN PCHAR Buffer, - IN USHORT BufferSize) +RtlInitEmptyAnsiString(OUT PANSI_STRING AnsiString, + IN PCHAR Buffer, + IN USHORT BufferSize) { - AnsiString->Length = 0; - AnsiString->MaximumLength = BufferSize; - AnsiString->Buffer = Buffer; + AnsiString->Length = 0; + AnsiString->MaximumLength = BufferSize; + AnsiString->Buffer = Buffer; } FORCEINLINE VOID RtlInitEmptyUnicodeString( - OUT PUNICODE_STRING UnicodeString, - IN PWSTR Buffer, - IN USHORT BufferSize) + OUT PUNICODE_STRING UnicodeString, + IN PWSTR Buffer, + IN USHORT BufferSize) { - UnicodeString->Length = 0; - UnicodeString->MaximumLength = BufferSize; - UnicodeString->Buffer = Buffer; + UnicodeString->Length = 0; + UnicodeString->MaximumLength = BufferSize; + UnicodeString->Buffer = Buffer; } #if defined(_AMD64_) || defined(_IA64_) - - static __inline LARGE_INTEGER NTAPI_INLINE RtlExtendedIntegerMultiply( - IN LARGE_INTEGER Multiplicand, - IN LONG Multiplier) + LARGE_INTEGER Multiplicand, + LONG Multiplier) { - LARGE_INTEGER ret; - ret.QuadPart = Multiplicand.QuadPart * Multiplier; - return ret; + LARGE_INTEGER ret; + ret.QuadPart = Multiplicand.QuadPart * Multiplier; + return ret; } static __inline LARGE_INTEGER NTAPI_INLINE RtlExtendedLargeIntegerDivide( - IN LARGE_INTEGER Dividend, - IN ULONG Divisor, - OUT PULONG Remainder OPTIONAL) + LARGE_INTEGER Dividend, + ULONG Divisor, + PULONG Remainder) { - LARGE_INTEGER ret; - ret.QuadPart = (ULONG64)Dividend.QuadPart / Divisor; - if (Remainder) - *Remainder = (ULONG)(Dividend.QuadPart % Divisor); - return ret; + LARGE_INTEGER ret; + ret.QuadPart = (ULONG64)Dividend.QuadPart / Divisor; + if (Remainder) + *Remainder = (ULONG)(Dividend.QuadPart % Divisor); + return ret; } - - - -#endif /* defined(_AMD64_) || defined(_IA64_) */ - +#endif #if defined(_AMD64_) @@ -9309,19 +6504,19 @@ static __inline LARGE_INTEGER NTAPI_INLINE RtlExtendedMagicDivide( - IN LARGE_INTEGER Dividend, - IN LARGE_INTEGER MagicDivisor, - IN CCHAR ShiftCount) + IN LARGE_INTEGER Dividend, + IN LARGE_INTEGER MagicDivisor, + IN CCHAR ShiftCount) { - LARGE_INTEGER ret; - ULONG64 ret64; - BOOLEAN Pos; - Pos = (Dividend.QuadPart >= 0); - ret64 = UnsignedMultiplyHigh(Pos ? Dividend.QuadPart : -Dividend.QuadPart, - MagicDivisor.QuadPart); - ret64 >>= ShiftCount; - ret.QuadPart = Pos ? ret64 : -ret64; - return ret; + LARGE_INTEGER ret; + ULONG64 ret64; + BOOLEAN Pos; + Pos = (Dividend.QuadPart >= 0); + ret64 = UnsignedMultiplyHigh(Pos ? Dividend.QuadPart : -Dividend.QuadPart, + MagicDivisor.QuadPart); + ret64 >>= ShiftCount; + ret.QuadPart = Pos ? ret64 : -ret64; + return ret; } #endif @@ -9330,12 +6525,12 @@ static __inline LARGE_INTEGER NTAPI_INLINE RtlLargeIntegerAdd( - IN LARGE_INTEGER Addend1, - IN LARGE_INTEGER Addend2) + IN LARGE_INTEGER Addend1, + IN LARGE_INTEGER Addend2) { - LARGE_INTEGER ret; - ret.QuadPart = Addend1.QuadPart + Addend2.QuadPart; - return ret; + LARGE_INTEGER ret; + ret.QuadPart = Addend1.QuadPart + Addend2.QuadPart; + return ret; } /* VOID @@ -9352,12 +6547,12 @@ static __inline LARGE_INTEGER NTAPI_INLINE RtlLargeIntegerArithmeticShift( - IN LARGE_INTEGER LargeInteger, - IN CCHAR ShiftCount) + IN LARGE_INTEGER LargeInteger, + IN CCHAR ShiftCount) { - LARGE_INTEGER ret; - ret.QuadPart = LargeInteger.QuadPart >> ShiftCount; - return ret; + LARGE_INTEGER ret; + ret.QuadPart = LargeInteger.QuadPart >> ShiftCount; + return ret; } /* BOOLEAN @@ -9371,74 +6566,36 @@ RtlLargeIntegerArithmeticShift( FORCEINLINE PVOID RtlSecureZeroMemory( - OUT PVOID Pointer, - IN SIZE_T Size) + OUT PVOID Pointer, + IN SIZE_T Size) { - volatile char* vptr = (volatile char*)Pointer; + volatile char* vptr = (volatile char*)Pointer; #if defined(_M_AMD64) - __stosb((PUCHAR)vptr, 0, Size); + __stosb((PUCHAR)vptr, 0, Size); #else - char * endptr = (char *)vptr + Size; - while (vptr < endptr) { - *vptr = 0; vptr++; - } + char * endptr = (char *)vptr + Size; + while (vptr < endptr) + { + *vptr = 0; vptr++; + } #endif - return Pointer; + return Pointer; } #if defined(_M_AMD64) FORCEINLINE -BOOLEAN +ULONG RtlCheckBit( - IN PRTL_BITMAP BitMapHeader, - IN ULONG BitPosition) + IN PRTL_BITMAP BitMapHeader, + IN ULONG BitPosition) { - return BitTest64((LONG64 CONST*)BitMapHeader->Buffer, (LONG64)BitPosition); + return BitTest((LONG CONST*)BitMapHeader->Buffer, BitPosition); } #else #define RtlCheckBit(BMH,BP) (((((PLONG)(BMH)->Buffer)[(BP)/32]) >> ((BP)%32)) & 0x1) -#endif /* defined(_M_AMD64) */ +#endif // defined(_M_AMD64) -#define RtlLargeIntegerGreaterThan(X,Y) ( \ - (((X).HighPart == (Y).HighPart) && ((X).LowPart > (Y).LowPart)) || \ - ((X).HighPart > (Y).HighPart) \ -) - -#define RtlLargeIntegerGreaterThanOrEqualTo(X,Y) ( \ - (((X).HighPart == (Y).HighPart) && ((X).LowPart >= (Y).LowPart)) || \ - ((X).HighPart > (Y).HighPart) \ -) - -#define RtlLargeIntegerNotEqualTo(X,Y) ( \ - (((X).LowPart ^ (Y).LowPart) | ((X).HighPart ^ (Y).HighPart)) \ -) - -#define RtlLargeIntegerLessThan(X,Y) ( \ - (((X).HighPart == (Y).HighPart) && ((X).LowPart < (Y).LowPart)) || \ - ((X).HighPart < (Y).HighPart) \ -) - -#define RtlLargeIntegerLessThanOrEqualTo(X,Y) ( \ - (((X).HighPart == (Y).HighPart) && ((X).LowPart <= (Y).LowPart)) || \ - ((X).HighPart < (Y).HighPart) \ -) - -#define RtlLargeIntegerGreaterThanZero(X) ( \ - (((X).HighPart == 0) && ((X).LowPart > 0)) || \ - ((X).HighPart > 0 ) \ -) - -#define RtlLargeIntegerGreaterOrEqualToZero(X) ( (X).HighPart >= 0 ) - -#define RtlLargeIntegerEqualToZero(X) ( !((X).LowPart | (X).HighPart) ) - -#define RtlLargeIntegerNotEqualToZero(X) ( ((X).LowPart | (X).HighPart) ) - -#define RtlLargeIntegerLessThanZero(X) ( ((X).HighPart < 0) ) - -#define RtlLargeIntegerLessOrEqualToZero(X) ( ((X).HighPart < 0) || !((X).LowPart | (X).HighPart) ) - -#endif /* !defined(MIDL_PASS) */ +#endif // !defined(MIDL_PASS) /* Byte Swap Functions */ #if (defined(_M_IX86) && (_MSC_FULL_VER > 13009037 || defined(__GNUC__))) || \ @@ -9492,10 +6649,6 @@ RtlCheckBit( (__annotation(L"Debug", L"AssertFail", msg), \ DbgRaiseAssertionFailure(), FALSE) : TRUE) -#define NT_VERIFY NT_ASSERT -#define NT_VERIFYMSG NT_ASSERTMSG -#define NT_VERIFYMSGW NT_ASSERTMSGW - #else /* GCC doesn't support __annotation (nor PDB) */ @@ -9521,19 +6674,12 @@ RtlCheckBit( #define RTL_SOFT_VERIFY(exp) ((exp) ? TRUE : FALSE) #define RTL_SOFT_VERIFYMSG(msg, exp) ((exp) ? TRUE : FALSE) -#define NT_ASSERT(exp) ((VOID)0) -#define NT_ASSERTMSG(msg, exp) ((VOID)0) -#define NT_ASSERTMSGW(msg, exp) ((VOID)0) - -#define NT_VERIFY(_exp) ((_exp) ? TRUE : FALSE) -#define NT_VERIFYMSG(_msg, _exp ) ((_exp) ? TRUE : FALSE) -#define NT_VERIFYMSGW(_msg, _exp) ((_exp) ? TRUE : FALSE) +#define NT_ASSERT(exp) ((VOID)0) +#define NT_ASSERTMSG(exp) ((VOID)0) +#define NT_ASSERTMSGW(exp) ((VOID)0) #endif /* DBG */ -#define InitializeListHead32(ListHead) (\ - (ListHead)->Flink = (ListHead)->Blink = PtrToUlong((ListHead))) - #if !defined(_WINBASE_) #if defined(_WIN64) && (defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_) || defined(_NTOSP_)) @@ -9551,21 +6697,25 @@ InitializeSListHead( OUT PSLIST_HEADER SListHead) { #if defined(_IA64_) - ULONG64 FeatureBits; + ULONG64 FeatureBits; #endif #if defined(_WIN64) - if (((ULONG_PTR)SListHead & 0xf) != 0) { - RtlRaiseStatus(STATUS_DATATYPE_MISALIGNMENT); - } + if (((ULONG_PTR)SListHead & 0xf) != 0) + { + RtlRaiseStatus(STATUS_DATATYPE_MISALIGNMENT); + } #endif - RtlZeroMemory(SListHead, sizeof(SLIST_HEADER)); + + RtlZeroMemory(SListHead, sizeof(SLIST_HEADER)); + #if defined(_IA64_) - FeatureBits = __getReg(CV_IA64_CPUID4); - if ((FeatureBits & KF_16BYTE_INSTR) != 0) { - SListHead->Header16.HeaderType = 1; - SListHead->Header16.Init = 1; - } + FeatureBits = __getReg(CV_IA64_CPUID4); + if ((FeatureBits & KF_16BYTE_INSTR) != 0) + { + SListHead->Header16.HeaderType = 1; + SListHead->Header16.Init = 1; + } #endif } @@ -9591,14 +6741,14 @@ NTKERNELAPI PSLIST_ENTRY FASTCALL InterlockedPopEntrySList( - IN PSLIST_HEADER ListHead); + IN PSLIST_HEADER ListHead); NTKERNELAPI PSLIST_ENTRY FASTCALL InterlockedPushEntrySList( - IN PSLIST_HEADER ListHead, - IN PSLIST_ENTRY ListEntry); + IN PSLIST_HEADER ListHead, + IN PSLIST_ENTRY ListEntry); #define InterlockedFlushSList(ListHead) \ ExInterlockedFlushSList(ListHead) @@ -9610,68 +6760,23 @@ InterlockedPushEntrySList( #endif /* !defined(_WINBASE_) */ -#define RTL_CONTEXT_EX_OFFSET(ContextEx, Chunk) ((ContextEx)->Chunk.Offset) -#define RTL_CONTEXT_EX_LENGTH(ContextEx, Chunk) ((ContextEx)->Chunk.Length) -#define RTL_CONTEXT_EX_CHUNK(Base, Layout, Chunk) \ - ((PVOID)((PCHAR)(Base) + RTL_CONTEXT_EX_OFFSET(Layout, Chunk))) -#define RTL_CONTEXT_OFFSET(Context, Chunk) \ - RTL_CONTEXT_EX_OFFSET((PCONTEXT_EX)(Context + 1), Chunk) -#define RTL_CONTEXT_LENGTH(Context, Chunk) \ - RTL_CONTEXT_EX_LENGTH((PCONTEXT_EX)(Context + 1), Chunk) -#define RTL_CONTEXT_CHUNK(Context, Chunk) \ - RTL_CONTEXT_EX_CHUNK((PCONTEXT_EX)(Context + 1), \ - (PCONTEXT_EX)(Context + 1), \ - Chunk) - -BOOLEAN -RTLVERLIB_DDI(RtlIsNtDdiVersionAvailable)( - IN ULONG Version); - -BOOLEAN -RTLVERLIB_DDI(RtlIsServicePackVersionInstalled)( - IN ULONG Version); - -#ifndef RtlIsNtDdiVersionAvailable -#define RtlIsNtDdiVersionAvailable WdmlibRtlIsNtDdiVersionAvailable -#endif - -#ifndef RtlIsServicePackVersionInstalled -#define RtlIsServicePackVersionInstalled WdmlibRtlIsServicePackVersionInstalled -#endif - -#define RtlInterlockedSetBits(Flags, Flag) \ - InterlockedOr((PLONG)(Flags), Flag) - -#define RtlInterlockedAndBits(Flags, Flag) \ - InterlockedAnd((PLONG)(Flags), Flag) - -#define RtlInterlockedClearBits(Flags, Flag) \ - RtlInterlockedAndBits(Flags, ~(Flag)) - -#define RtlInterlockedXorBits(Flags, Flag) \ - InterlockedXor(Flags, Flag) - -#define RtlInterlockedSetBitsDiscardReturn(Flags, Flag) \ - (VOID) RtlInterlockedSetBits(Flags, Flag) - -#define RtlInterlockedAndBitsDiscardReturn(Flags, Flag) \ - (VOID) RtlInterlockedAndBits(Flags, Flag) - -#define RtlInterlockedClearBitsDiscardReturn(Flags, Flag) \ - RtlInterlockedAndBitsDiscardReturn(Flags, ~(Flag)) - - /****************************************************************************** * Kernel Functions * ******************************************************************************/ +NTHALAPI +KIRQL +NTAPI +KeGetCurrentIrql( + VOID); + NTKERNELAPI VOID NTAPI KeInitializeEvent( - OUT PRKEVENT Event, - IN EVENT_TYPE Type, - IN BOOLEAN State); + OUT PRKEVENT Event, + IN EVENT_TYPE Type, + IN BOOLEAN State); NTKERNELAPI VOID @@ -9681,8 +6786,6 @@ KeClearEvent( #if (NTDDI_VERSION >= NTDDI_WIN2K) - -#if defined(_NTDDK_) || defined(_NTIFS_) NTKERNELAPI VOID NTAPI @@ -9690,7 +6793,6 @@ ProbeForRead( IN CONST VOID *Address, /* CONST is added */ IN SIZE_T Length, IN ULONG Alignment); -#endif /* defined(_NTDDK_) || defined(_NTIFS_) */ NTKERNELAPI VOID @@ -9700,9 +6802,7 @@ ProbeForWrite( IN SIZE_T Length, IN ULONG Alignment); - #if defined(SINGLE_GROUP_LEGACY_API) - NTKERNELAPI VOID NTAPI @@ -9712,7 +6812,7 @@ NTKERNELAPI VOID NTAPI KeSetSystemAffinityThread( - IN KAFFINITY Affinity); + IN KAFFINITY Affinity); NTKERNELAPI VOID @@ -9724,67 +6824,37 @@ KeSetTargetProcessorDpc( NTKERNELAPI KAFFINITY NTAPI -KeQueryActiveProcessors(VOID); - - -#endif /* defined(SINGLE_GROUP_LEGACY_API) */ +KeQueryActiveProcessors( + VOID); +#endif #if !defined(_M_AMD64) NTKERNELAPI ULONGLONG NTAPI -KeQueryInterruptTime(VOID); +KeQueryInterruptTime( + VOID); NTKERNELAPI VOID NTAPI KeQuerySystemTime( - OUT PLARGE_INTEGER CurrentTime); + OUT PLARGE_INTEGER CurrentTime); #endif /* !_M_AMD64 */ -#if !defined(_X86_) -NTKERNELAPI -KIRQL -NTAPI -KeAcquireSpinLockRaiseToDpc( - IN OUT PKSPIN_LOCK SpinLock); - -#define KeAcquireSpinLock(SpinLock, OldIrql) \ - *(OldIrql) = KeAcquireSpinLockRaiseToDpc(SpinLock) - -NTKERNELAPI -VOID -NTAPI -KeAcquireSpinLockAtDpcLevel( - IN OUT PKSPIN_LOCK SpinLock); - -NTKERNELAPI -VOID -NTAPI -KeReleaseSpinLock( - IN OUT PKSPIN_LOCK SpinLock, - IN KIRQL NewIrql); - -NTKERNELAPI -VOID -NTAPI -KeReleaseSpinLockFromDpcLevel( - IN OUT PKSPIN_LOCK SpinLock); -#endif /* !_X86_ */ - #if defined(_X86_) && (defined(_WDM_INCLUDED_) || defined(WIN9X_COMPAT_SPINLOCK)) NTKERNELAPI VOID NTAPI KeInitializeSpinLock( - IN PKSPIN_LOCK SpinLock); + IN PKSPIN_LOCK SpinLock); #else FORCEINLINE VOID KeInitializeSpinLock(IN PKSPIN_LOCK SpinLock) { - /* Clear the lock */ - *SpinLock = 0; + /* Clear the lock */ + *SpinLock = 0; } #endif @@ -9793,11 +6863,11 @@ DECLSPEC_NORETURN VOID NTAPI KeBugCheckEx( - IN ULONG BugCheckCode, - IN ULONG_PTR BugCheckParameter1, - IN ULONG_PTR BugCheckParameter2, - IN ULONG_PTR BugCheckParameter3, - IN ULONG_PTR BugCheckParameter4); + IN ULONG BugCheckCode, + IN ULONG_PTR BugCheckParameter1, + IN ULONG_PTR BugCheckParameter2, + IN ULONG_PTR BugCheckParameter3, + IN ULONG_PTR BugCheckParameter4); NTKERNELAPI BOOLEAN @@ -9828,66 +6898,66 @@ NTKERNELAPI VOID NTAPI KeInitializeDeviceQueue( - OUT PKDEVICE_QUEUE DeviceQueue); + OUT PKDEVICE_QUEUE DeviceQueue); NTKERNELAPI VOID NTAPI KeInitializeDpc( - OUT PRKDPC Dpc, - IN PKDEFERRED_ROUTINE DeferredRoutine, - IN PVOID DeferredContext OPTIONAL); + OUT PRKDPC Dpc, + IN PKDEFERRED_ROUTINE DeferredRoutine, + IN PVOID DeferredContext OPTIONAL); NTKERNELAPI VOID NTAPI KeInitializeMutex( - OUT PRKMUTEX Mutex, - IN ULONG Level); + OUT PRKMUTEX Mutex, + IN ULONG Level); NTKERNELAPI VOID NTAPI KeInitializeSemaphore( - OUT PRKSEMAPHORE Semaphore, - IN LONG Count, - IN LONG Limit); + OUT PRKSEMAPHORE Semaphore, + IN LONG Count, + IN LONG Limit); NTKERNELAPI VOID NTAPI KeInitializeTimer( - OUT PKTIMER Timer); + OUT PKTIMER Timer); NTKERNELAPI VOID NTAPI KeInitializeTimerEx( - OUT PKTIMER Timer, - IN TIMER_TYPE Type); + OUT PKTIMER Timer, + IN TIMER_TYPE Type); NTKERNELAPI BOOLEAN NTAPI KeInsertByKeyDeviceQueue( - IN OUT PKDEVICE_QUEUE DeviceQueue, - IN OUT PKDEVICE_QUEUE_ENTRY DeviceQueueEntry, - IN ULONG SortKey); + IN OUT PKDEVICE_QUEUE DeviceQueue, + IN OUT PKDEVICE_QUEUE_ENTRY DeviceQueueEntry, + IN ULONG SortKey); NTKERNELAPI BOOLEAN NTAPI KeInsertDeviceQueue( - IN OUT PKDEVICE_QUEUE DeviceQueue, - IN OUT PKDEVICE_QUEUE_ENTRY DeviceQueueEntry); + IN OUT PKDEVICE_QUEUE DeviceQueue, + IN OUT PKDEVICE_QUEUE_ENTRY DeviceQueueEntry); NTKERNELAPI BOOLEAN NTAPI KeInsertQueueDpc( - IN OUT PRKDPC Dpc, - IN PVOID SystemArgument1 OPTIONAL, - IN PVOID SystemArgument2 OPTIONAL); + IN OUT PRKDPC Dpc, + IN PVOID SystemArgument1 OPTIONAL, + IN PVOID SystemArgument2 OPTIONAL); NTKERNELAPI VOID @@ -9898,166 +6968,168 @@ NTHALAPI LARGE_INTEGER NTAPI KeQueryPerformanceCounter( - OUT PLARGE_INTEGER PerformanceFrequency OPTIONAL); + OUT PLARGE_INTEGER PerformanceFrequency OPTIONAL); NTKERNELAPI KPRIORITY NTAPI KeQueryPriorityThread( - IN PRKTHREAD Thread); + IN PRKTHREAD Thread); NTKERNELAPI ULONG NTAPI -KeQueryTimeIncrement(VOID); +KeQueryTimeIncrement( + VOID); NTKERNELAPI LONG NTAPI KeReadStateEvent( - IN PRKEVENT Event); + IN PRKEVENT Event); NTKERNELAPI LONG NTAPI KeReadStateMutex( - IN PRKMUTEX Mutex); + IN PRKMUTEX Mutex); + NTKERNELAPI LONG NTAPI KeReadStateSemaphore( - IN PRKSEMAPHORE Semaphore); + IN PRKSEMAPHORE Semaphore); NTKERNELAPI BOOLEAN NTAPI KeReadStateTimer( - IN PKTIMER Timer); + IN PKTIMER Timer); NTKERNELAPI BOOLEAN NTAPI KeRegisterBugCheckCallback( - OUT PKBUGCHECK_CALLBACK_RECORD CallbackRecord, - IN PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine, - IN PVOID Buffer, - IN ULONG Length, - IN PUCHAR Component); + OUT PKBUGCHECK_CALLBACK_RECORD CallbackRecord, + IN PKBUGCHECK_CALLBACK_ROUTINE CallbackRoutine, + IN PVOID Buffer, + IN ULONG Length, + IN PUCHAR Component); NTKERNELAPI LONG NTAPI KeReleaseMutex( - IN OUT PRKMUTEX Mutex, - IN BOOLEAN Wait); + IN OUT PRKMUTEX Mutex, + IN BOOLEAN Wait); NTKERNELAPI LONG NTAPI KeReleaseSemaphore( - IN OUT PRKSEMAPHORE Semaphore, - IN KPRIORITY Increment, - IN LONG Adjustment, - IN BOOLEAN Wait); + IN OUT PRKSEMAPHORE Semaphore, + IN KPRIORITY Increment, + IN LONG Adjustment, + IN BOOLEAN Wait); NTKERNELAPI PKDEVICE_QUEUE_ENTRY NTAPI KeRemoveByKeyDeviceQueue( - IN OUT PKDEVICE_QUEUE DeviceQueue, - IN ULONG SortKey); + IN OUT PKDEVICE_QUEUE DeviceQueue, + IN ULONG SortKey); NTKERNELAPI PKDEVICE_QUEUE_ENTRY NTAPI KeRemoveDeviceQueue( - IN OUT PKDEVICE_QUEUE DeviceQueue); + IN OUT PKDEVICE_QUEUE DeviceQueue); NTKERNELAPI BOOLEAN NTAPI KeRemoveEntryDeviceQueue( - IN OUT PKDEVICE_QUEUE DeviceQueue, - IN OUT PKDEVICE_QUEUE_ENTRY DeviceQueueEntry); + IN OUT PKDEVICE_QUEUE DeviceQueue, + IN OUT PKDEVICE_QUEUE_ENTRY DeviceQueueEntry); NTKERNELAPI BOOLEAN NTAPI KeRemoveQueueDpc( - IN OUT PRKDPC Dpc); + IN OUT PRKDPC Dpc); NTKERNELAPI LONG NTAPI KeResetEvent( - IN OUT PRKEVENT Event); + IN OUT PRKEVENT Event); NTKERNELAPI LONG NTAPI KeSetEvent( - IN OUT PRKEVENT Event, - IN KPRIORITY Increment, - IN BOOLEAN Wait); + IN OUT PRKEVENT Event, + IN KPRIORITY Increment, + IN BOOLEAN Wait); NTKERNELAPI VOID NTAPI KeSetImportanceDpc( - IN OUT PRKDPC Dpc, - IN KDPC_IMPORTANCE Importance); + IN OUT PRKDPC Dpc, + IN KDPC_IMPORTANCE Importance); NTKERNELAPI KPRIORITY NTAPI KeSetPriorityThread( - IN OUT PKTHREAD Thread, - IN KPRIORITY Priority); + IN OUT PKTHREAD Thread, + IN KPRIORITY Priority); NTKERNELAPI BOOLEAN NTAPI KeSetTimer( - IN OUT PKTIMER Timer, - IN LARGE_INTEGER DueTime, - IN PKDPC Dpc OPTIONAL); + IN OUT PKTIMER Timer, + IN LARGE_INTEGER DueTime, + IN PKDPC Dpc OPTIONAL); NTKERNELAPI BOOLEAN NTAPI KeSetTimerEx( - IN OUT PKTIMER Timer, - IN LARGE_INTEGER DueTime, - IN LONG Period OPTIONAL, - IN PKDPC Dpc OPTIONAL); + IN OUT PKTIMER Timer, + IN LARGE_INTEGER DueTime, + IN LONG Period OPTIONAL, + IN PKDPC Dpc OPTIONAL); NTHALAPI VOID NTAPI KeStallExecutionProcessor( - IN ULONG MicroSeconds); + IN ULONG MicroSeconds); NTKERNELAPI BOOLEAN NTAPI KeSynchronizeExecution( - IN OUT PKINTERRUPT Interrupt, - IN PKSYNCHRONIZE_ROUTINE SynchronizeRoutine, - IN PVOID SynchronizeContext OPTIONAL); + IN OUT PKINTERRUPT Interrupt, + IN PKSYNCHRONIZE_ROUTINE SynchronizeRoutine, + IN PVOID SynchronizeContext OPTIONAL); NTKERNELAPI NTSTATUS NTAPI KeWaitForMultipleObjects( - IN ULONG Count, - IN PVOID Object[], - IN WAIT_TYPE WaitType, - IN KWAIT_REASON WaitReason, - IN KPROCESSOR_MODE WaitMode, - IN BOOLEAN Alertable, - IN PLARGE_INTEGER Timeout OPTIONAL, - OUT PKWAIT_BLOCK WaitBlockArray OPTIONAL); + IN ULONG Count, + IN PVOID Object[], + IN WAIT_TYPE WaitType, + IN KWAIT_REASON WaitReason, + IN KPROCESSOR_MODE WaitMode, + IN BOOLEAN Alertable, + IN PLARGE_INTEGER Timeout OPTIONAL, + OUT PKWAIT_BLOCK WaitBlockArray OPTIONAL); #define KeWaitForMutexObject KeWaitForSingleObject @@ -10065,11 +7137,11 @@ NTKERNELAPI NTSTATUS NTAPI KeWaitForSingleObject( - IN PVOID Object, - IN KWAIT_REASON WaitReason, - IN KPROCESSOR_MODE WaitMode, - IN BOOLEAN Alertable, - IN PLARGE_INTEGER Timeout OPTIONAL); + IN PVOID Object, + IN KWAIT_REASON WaitReason, + IN KPROCESSOR_MODE WaitMode, + IN BOOLEAN Alertable, + IN PLARGE_INTEGER Timeout OPTIONAL); #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ @@ -10086,14 +7158,14 @@ NTKERNELAPI VOID FASTCALL KeAcquireInStackQueuedSpinLockAtDpcLevel( - IN OUT PKSPIN_LOCK SpinLock, - OUT PKLOCK_QUEUE_HANDLE LockHandle); + IN OUT PKSPIN_LOCK SpinLock, + OUT PKLOCK_QUEUE_HANDLE LockHandle); NTKERNELAPI KIRQL NTAPI KeAcquireInterruptSpinLock( - IN OUT PKINTERRUPT Interrupt); + IN OUT PKINTERRUPT Interrupt); NTKERNELAPI BOOLEAN @@ -10116,14 +7188,14 @@ NTKERNELAPI VOID FASTCALL KeReleaseInStackQueuedSpinLockFromDpcLevel( - IN PKLOCK_QUEUE_HANDLE LockHandle); + IN PKLOCK_QUEUE_HANDLE LockHandle); NTKERNELAPI VOID NTAPI KeReleaseInterruptSpinLock( - IN OUT PKINTERRUPT Interrupt, - IN KIRQL OldIrql); + IN OUT PKINTERRUPT Interrupt, + IN KIRQL OldIrql); NTKERNELAPI PKDEVICE_QUEUE_ENTRY @@ -10160,10 +7232,13 @@ KeRegisterBugCheckReasonCallback( #endif /* (NTDDI_VERSION >= NTDDI_WINXPSP1) */ #if (NTDDI_VERSION >= NTDDI_WINXPSP2) + NTKERNELAPI VOID NTAPI -KeFlushQueuedDpcs(VOID); +KeFlushQueuedDpcs( + VOID); + #endif /* (NTDDI_VERSION >= NTDDI_WINXPSP2) */ #if (NTDDI_VERSION >= NTDDI_WS03) @@ -10215,12 +7290,10 @@ FASTCALL KeTestSpinLock( IN PKSPIN_LOCK SpinLock); - #endif /* (NTDDI_VERSION >= NTDDI_WS03) */ #if (NTDDI_VERSION >= NTDDI_WS03SP1) - NTKERNELAPI BOOLEAN FASTCALL @@ -10230,53 +7303,64 @@ KeTryToAcquireSpinLockAtDpcLevel( NTKERNELAPI BOOLEAN NTAPI -KeAreAllApcsDisabled(VOID); +KeAreAllApcsDisabled( + VOID); NTKERNELAPI VOID FASTCALL KeAcquireGuardedMutex( - IN OUT PKGUARDED_MUTEX GuardedMutex); + IN OUT PKGUARDED_MUTEX GuardedMutex +); NTKERNELAPI VOID FASTCALL KeAcquireGuardedMutexUnsafe( - IN OUT PKGUARDED_MUTEX GuardedMutex); + IN OUT PKGUARDED_MUTEX GuardedMutex +); NTKERNELAPI VOID NTAPI -KeEnterGuardedRegion(VOID); +KeEnterGuardedRegion( + VOID +); NTKERNELAPI VOID NTAPI -KeLeaveGuardedRegion(VOID); +KeLeaveGuardedRegion( + VOID +); NTKERNELAPI VOID FASTCALL KeInitializeGuardedMutex( - OUT PKGUARDED_MUTEX GuardedMutex); + OUT PKGUARDED_MUTEX GuardedMutex +); NTKERNELAPI VOID FASTCALL KeReleaseGuardedMutexUnsafe( - IN OUT PKGUARDED_MUTEX GuardedMutex); + IN OUT PKGUARDED_MUTEX GuardedMutex +); NTKERNELAPI VOID FASTCALL KeReleaseGuardedMutex( - IN OUT PKGUARDED_MUTEX GuardedMutex); + IN OUT PKGUARDED_MUTEX GuardedMutex +); NTKERNELAPI BOOLEAN FASTCALL KeTryToAcquireGuardedMutex( - IN OUT PKGUARDED_MUTEX GuardedMutex); + IN OUT PKGUARDED_MUTEX GuardedMutex +); #endif /* (NTDDI_VERSION >= NTDDI_WS03SP1) */ @@ -10302,19 +7386,12 @@ KeQueryDpcWatchdogInformation( OUT PKDPC_WATCHDOG_INFORMATION WatchdogInformation); #if defined(SINGLE_GROUP_LEGACY_API) - NTKERNELAPI KAFFINITY NTAPI KeSetSystemAffinityThreadEx( IN KAFFINITY Affinity); -NTKERNELAPI -VOID -NTAPI -KeRevertToUserAffinityThreadEx( - IN KAFFINITY Affinity); - NTKERNELAPI ULONG NTAPI @@ -10324,10 +7401,11 @@ KeQueryActiveProcessorCount( NTKERNELAPI ULONG NTAPI -KeQueryMaximumProcessorCount(VOID); -#endif /* SINGLE_GROUP_LEGACY_API */ +KeQueryMaximumProcessorCount( + VOID); +#endif -#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ #if (NTDDI_VERSION >= NTDDI_WS08) @@ -10345,7 +7423,6 @@ KeDeregisterProcessorChangeCallback( #if (NTDDI_VERSION >= NTDDI_WIN7) - ULONG64 NTAPI KeQueryTotalCycleTimeProcess( @@ -10391,7 +7468,8 @@ KeSetCoalescableTimer( NTKERNELAPI ULONGLONG NTAPI -KeQueryUnbiasedInterruptTime(VOID); +KeQueryUnbiasedInterruptTime( + VOID); NTKERNELAPI ULONG @@ -10408,17 +7486,19 @@ KeQueryMaximumProcessorCountEx( NTKERNELAPI USHORT NTAPI -KeQueryActiveGroupCount(VOID); +KeQueryActiveGroupCount( + VOID); NTKERNELAPI USHORT NTAPI -KeQueryMaximumGroupCount(VOID); +KeQueryMaximumGroupCount( + VOID); NTKERNELAPI KAFFINITY NTAPI -KeQueryGroupAffinity( +KeQueryGroupAffinity IN USHORT GroupNumber); NTKERNELAPI @@ -10444,12 +7524,14 @@ KeQueryNodeMaximumProcessorCount( NTKERNELAPI USHORT NTAPI -KeQueryHighestNodeNumber(VOID); +KeQueryHighestNodeNumber( + VOID); NTKERNELAPI USHORT NTAPI -KeGetCurrentNodeNumber(VOID); +KeGetCurrentNodeNumber( + VOID); NTKERNELAPI NTSTATUS @@ -10473,18 +7555,7 @@ NTAPI KeRestoreExtendedProcessorState( IN PXSTATE_SAVE XStateSave); -NTSTATUS -NTAPI -KeGetProcessorNumberFromIndex( - IN ULONG ProcIndex, - OUT PPROCESSOR_NUMBER ProcNumber); - -ULONG -NTAPI -KeGetProcessorIndexFromNumber( - IN PPROCESSOR_NUMBER ProcNumber); - -#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ #if !defined(_IA64_) NTHALAPI @@ -10519,14 +7590,17 @@ KeFlushWriteBuffer(VOID); #define PAGED_CODE() -#endif /* DBG */ +#endif #define PAGED_CODE_LOCKED() NOP_FUNCTION; /****************************************************************************** * Memory manager Functions * ******************************************************************************/ -/* Alignment Macros */ + +/* + * Alignment Macros + */ #define ALIGN_DOWN_BY(size, align) \ ((ULONG_PTR)(size) & ~((ULONG_PTR)(align) - 1)) @@ -10551,22 +7625,6 @@ KeFlushWriteBuffer(VOID); #define ALIGN_UP_POINTER(ptr, type) \ ALIGN_UP_POINTER_BY(ptr, sizeof(type)) -#ifndef FIELD_OFFSET -#define FIELD_OFFSET(type, field) ((ULONG)&(((type *)0)->field)) -#endif - -#ifndef FIELD_SIZE -#define FIELD_SIZE(type, field) (sizeof(((type *)0)->field)) -#endif - -#define POOL_TAGGING 1 - -#if DBG -#define IF_DEBUG if (TRUE) -#else -#define IF_DEBUG if (FALSE) -#endif /* DBG */ - /* ULONG * BYTE_OFFSET( * IN PVOID Va) @@ -10579,7 +7637,7 @@ KeFlushWriteBuffer(VOID); * IN ULONG Size) */ #define BYTES_TO_PAGES(Size) \ - (((Size) + PAGE_SIZE - 1) >> PAGE_SHIFT) + (((Size) >> PAGE_SHIFT) + (((Size) & (PAGE_SIZE - 1)) != 0)) /* PVOID * PAGE_ALIGN( @@ -10604,9 +7662,6 @@ KeFlushWriteBuffer(VOID); ((ULONG) ((((ULONG_PTR) (_Va) & (PAGE_SIZE - 1)) \ + (_Size) + (PAGE_SIZE - 1)) >> PAGE_SHIFT)) -#define COMPUTE_PAGES_SPANNED(Va, Size) \ - ADDRESS_AND_SIZE_TO_SPAN_PAGES(Va,Size) - /* * ULONG * MmGetMdlByteCount( @@ -10623,8 +7678,6 @@ KeFlushWriteBuffer(VOID); #define MmGetMdlByteOffset(_Mdl) \ ((_Mdl)->ByteOffset) -#define MmGetMdlBaseVa(Mdl) ((Mdl)->StartVa) - /* * PPFN_NUMBER * MmGetMdlPfnArray( @@ -10705,56 +7758,56 @@ NTKERNELAPI PVOID NTAPI MmAllocateContiguousMemory( - IN SIZE_T NumberOfBytes, - IN PHYSICAL_ADDRESS HighestAcceptableAddress); + IN SIZE_T NumberOfBytes, + IN PHYSICAL_ADDRESS HighestAcceptableAddress); NTKERNELAPI PVOID NTAPI MmAllocateContiguousMemorySpecifyCache( - IN SIZE_T NumberOfBytes, - IN PHYSICAL_ADDRESS LowestAcceptableAddress, - IN PHYSICAL_ADDRESS HighestAcceptableAddress, - IN PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL, - IN MEMORY_CACHING_TYPE CacheType); + IN SIZE_T NumberOfBytes, + IN PHYSICAL_ADDRESS LowestAcceptableAddress, + IN PHYSICAL_ADDRESS HighestAcceptableAddress, + IN PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL, + IN MEMORY_CACHING_TYPE CacheType); NTKERNELAPI PMDL NTAPI MmAllocatePagesForMdl( - IN PHYSICAL_ADDRESS LowAddress, - IN PHYSICAL_ADDRESS HighAddress, - IN PHYSICAL_ADDRESS SkipBytes, - IN SIZE_T TotalBytes); + IN PHYSICAL_ADDRESS LowAddress, + IN PHYSICAL_ADDRESS HighAddress, + IN PHYSICAL_ADDRESS SkipBytes, + IN SIZE_T TotalBytes); NTKERNELAPI VOID NTAPI MmBuildMdlForNonPagedPool( - IN OUT PMDLX MemoryDescriptorList); + IN OUT PMDLX MemoryDescriptorList); //DECLSPEC_DEPRECATED_DDK NTKERNELAPI PMDL NTAPI MmCreateMdl( - IN PMDL MemoryDescriptorList OPTIONAL, - IN PVOID Base, - IN SIZE_T Length); + IN PMDL MemoryDescriptorList OPTIONAL, + IN PVOID Base, + IN SIZE_T Length); NTKERNELAPI VOID NTAPI MmFreeContiguousMemory( - IN PVOID BaseAddress); + IN PVOID BaseAddress); NTKERNELAPI VOID NTAPI MmFreeContiguousMemorySpecifyCache( - IN PVOID BaseAddress, - IN SIZE_T NumberOfBytes, - IN MEMORY_CACHING_TYPE CacheType); + IN PVOID BaseAddress, + IN SIZE_T NumberOfBytes, + IN MEMORY_CACHING_TYPE CacheType); NTKERNELAPI VOID @@ -10766,7 +7819,7 @@ NTKERNELAPI PVOID NTAPI MmGetSystemRoutineAddress( - IN PUNICODE_STRING SystemRoutineName); + IN PUNICODE_STRING SystemRoutineName); NTKERNELAPI LOGICAL @@ -10778,22 +7831,22 @@ NTKERNELAPI PVOID NTAPI MmLockPagableDataSection( - IN PVOID AddressWithinSection); + IN PVOID AddressWithinSection); NTKERNELAPI PVOID NTAPI MmMapIoSpace( - IN PHYSICAL_ADDRESS PhysicalAddress, - IN SIZE_T NumberOfBytes, - IN MEMORY_CACHING_TYPE CacheEnable); + IN PHYSICAL_ADDRESS PhysicalAddress, + IN SIZE_T NumberOfBytes, + IN MEMORY_CACHING_TYPE CacheEnable); NTKERNELAPI PVOID NTAPI MmMapLockedPages( - IN PMDL MemoryDescriptorList, - IN KPROCESSOR_MODE AccessMode); + IN PMDL MemoryDescriptorList, + IN KPROCESSOR_MODE AccessMode); NTKERNELAPI PVOID @@ -10810,81 +7863,71 @@ NTKERNELAPI PVOID NTAPI MmPageEntireDriver( - IN PVOID AddressWithinSection); + IN PVOID AddressWithinSection); NTKERNELAPI VOID NTAPI MmProbeAndLockPages( - IN OUT PMDL MemoryDescriptorList, - IN KPROCESSOR_MODE AccessMode, - IN LOCK_OPERATION Operation); + IN OUT PMDL MemoryDescriptorList, + IN KPROCESSOR_MODE AccessMode, + IN LOCK_OPERATION Operation); NTKERNELAPI MM_SYSTEMSIZE NTAPI -MmQuerySystemSize(VOID); +MmQuerySystemSize( + VOID); NTKERNELAPI VOID NTAPI MmResetDriverPaging( - IN PVOID AddressWithinSection); + IN PVOID AddressWithinSection); NTKERNELAPI SIZE_T NTAPI MmSizeOfMdl( - IN PVOID Base, - IN SIZE_T Length); + IN PVOID Base, + IN SIZE_T Length); NTKERNELAPI VOID NTAPI MmUnlockPagableImageSection( - IN PVOID ImageSectionHandle); + IN PVOID ImageSectionHandle); NTKERNELAPI VOID NTAPI MmUnlockPages( - IN OUT PMDL MemoryDescriptorList); + IN OUT PMDL MemoryDescriptorList); NTKERNELAPI VOID NTAPI MmUnmapIoSpace( - IN PVOID BaseAddress, - IN SIZE_T NumberOfBytes); + IN PVOID BaseAddress, + IN SIZE_T NumberOfBytes); NTKERNELAPI VOID NTAPI MmProbeAndLockProcessPages( - IN OUT PMDL MemoryDescriptorList, - IN PEPROCESS Process, - IN KPROCESSOR_MODE AccessMode, - IN LOCK_OPERATION Operation); + IN OUT PMDL MemoryDescriptorList, + IN PEPROCESS Process, + IN KPROCESSOR_MODE AccessMode, + IN LOCK_OPERATION Operation); NTKERNELAPI VOID NTAPI MmUnmapLockedPages( - IN PVOID BaseAddress, - IN PMDL MemoryDescriptorList); + IN PVOID BaseAddress, + IN PMDL MemoryDescriptorList); -NTKERNELAPI -PVOID -NTAPI -MmAllocateContiguousMemorySpecifyCacheNode( - IN SIZE_T NumberOfBytes, - IN PHYSICAL_ADDRESS LowestAcceptableAddress, - IN PHYSICAL_ADDRESS HighestAcceptableAddress, - IN PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL, - IN MEMORY_CACHING_TYPE CacheType, - IN NODE_REQUIREMENT PreferredNode); - -#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ +#endif #if (NTDDI_VERSION >= NTDDI_WINXP) @@ -10892,69 +7935,53 @@ NTKERNELAPI NTSTATUS NTAPI MmAdvanceMdl( - IN OUT PMDL Mdl, - IN ULONG NumberOfBytes); + IN OUT PMDL Mdl, + IN ULONG NumberOfBytes); NTKERNELAPI PVOID NTAPI MmAllocateMappingAddress( - IN SIZE_T NumberOfBytes, - IN ULONG PoolTag); + IN SIZE_T NumberOfBytes, + IN ULONG PoolTag); NTKERNELAPI VOID NTAPI MmFreeMappingAddress( - IN PVOID BaseAddress, - IN ULONG PoolTag); + IN PVOID BaseAddress, + IN ULONG PoolTag); NTKERNELAPI NTSTATUS NTAPI MmIsVerifierEnabled( - OUT PULONG VerifierFlags); + OUT PULONG VerifierFlags); NTKERNELAPI PVOID NTAPI MmMapLockedPagesWithReservedMapping( - IN PVOID MappingAddress, - IN ULONG PoolTag, - IN PMDL MemoryDescriptorList, - IN MEMORY_CACHING_TYPE CacheType); + IN PVOID MappingAddress, + IN ULONG PoolTag, + IN PMDL MemoryDescriptorList, + IN MEMORY_CACHING_TYPE CacheType); NTKERNELAPI NTSTATUS NTAPI MmProtectMdlSystemAddress( - IN PMDL MemoryDescriptorList, - IN ULONG NewProtect); + IN PMDL MemoryDescriptorList, + IN ULONG NewProtect); NTKERNELAPI VOID NTAPI MmUnmapReservedMapping( - IN PVOID BaseAddress, - IN ULONG PoolTag, - IN PMDL MemoryDescriptorList); + IN PVOID BaseAddress, + IN ULONG PoolTag, + IN PMDL MemoryDescriptorList); -NTKERNELAPI -NTSTATUS -NTAPI -MmAddVerifierThunks( - IN PVOID ThunkBuffer, - IN ULONG ThunkBufferSize); - -#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ - -#if (NTDDI_VERSION >= NTDDI_WS03) -NTKERNELAPI -LOGICAL -NTAPI -MmIsIoSpaceActive( - IN PHYSICAL_ADDRESS StartAddress, - IN SIZE_T NumberOfBytes); #endif #if (NTDDI_VERSION >= NTDDI_WS03SP1) @@ -10970,15 +7997,6 @@ MmAllocatePagesForMdlEx( IN ULONG Flags); #endif -#if (NTDDI_VERSION >= NTDDI_VISTA) - -NTKERNELAPI -LOGICAL -NTAPI -MmIsDriverVerifyingByAddress( - IN PVOID AddressWithinSection); -#endif - /****************************************************************************** * Security Manager Functions * ******************************************************************************/ @@ -10989,42 +8007,42 @@ NTKERNELAPI BOOLEAN NTAPI SeAccessCheck( - IN PSECURITY_DESCRIPTOR SecurityDescriptor, - IN PSECURITY_SUBJECT_CONTEXT SubjectSecurityContext, - IN BOOLEAN SubjectContextLocked, - IN ACCESS_MASK DesiredAccess, - IN ACCESS_MASK PreviouslyGrantedAccess, - OUT PPRIVILEGE_SET *Privileges OPTIONAL, - IN PGENERIC_MAPPING GenericMapping, - IN KPROCESSOR_MODE AccessMode, - OUT PACCESS_MASK GrantedAccess, - OUT PNTSTATUS AccessStatus); + IN PSECURITY_DESCRIPTOR SecurityDescriptor, + IN PSECURITY_SUBJECT_CONTEXT SubjectSecurityContext, + IN BOOLEAN SubjectContextLocked, + IN ACCESS_MASK DesiredAccess, + IN ACCESS_MASK PreviouslyGrantedAccess, + OUT PPRIVILEGE_SET *Privileges OPTIONAL, + IN PGENERIC_MAPPING GenericMapping, + IN KPROCESSOR_MODE AccessMode, + OUT PACCESS_MASK GrantedAccess, + OUT PNTSTATUS AccessStatus); NTKERNELAPI NTSTATUS NTAPI SeAssignSecurity( - IN PSECURITY_DESCRIPTOR ParentDescriptor OPTIONAL, - IN PSECURITY_DESCRIPTOR ExplicitDescriptor OPTIONAL, - OUT PSECURITY_DESCRIPTOR *NewDescriptor, - IN BOOLEAN IsDirectoryObject, - IN PSECURITY_SUBJECT_CONTEXT SubjectContext, - IN PGENERIC_MAPPING GenericMapping, - IN POOL_TYPE PoolType); + IN PSECURITY_DESCRIPTOR ParentDescriptor OPTIONAL, + IN PSECURITY_DESCRIPTOR ExplicitDescriptor OPTIONAL, + OUT PSECURITY_DESCRIPTOR *NewDescriptor, + IN BOOLEAN IsDirectoryObject, + IN PSECURITY_SUBJECT_CONTEXT SubjectContext, + IN PGENERIC_MAPPING GenericMapping, + IN POOL_TYPE PoolType); NTKERNELAPI NTSTATUS NTAPI SeAssignSecurityEx( - IN PSECURITY_DESCRIPTOR ParentDescriptor OPTIONAL, - IN PSECURITY_DESCRIPTOR ExplicitDescriptor OPTIONAL, - OUT PSECURITY_DESCRIPTOR *NewDescriptor, - IN GUID *ObjectType OPTIONAL, - IN BOOLEAN IsDirectoryObject, - IN ULONG AutoInheritFlags, - IN PSECURITY_SUBJECT_CONTEXT SubjectContext, - IN PGENERIC_MAPPING GenericMapping, - IN POOL_TYPE PoolType); + IN PSECURITY_DESCRIPTOR ParentDescriptor OPTIONAL, + IN PSECURITY_DESCRIPTOR ExplicitDescriptor OPTIONAL, + OUT PSECURITY_DESCRIPTOR *NewDescriptor, + IN GUID *ObjectType OPTIONAL, + IN BOOLEAN IsDirectoryObject, + IN ULONG AutoInheritFlags, + IN PSECURITY_SUBJECT_CONTEXT SubjectContext, + IN PGENERIC_MAPPING GenericMapping, + IN POOL_TYPE PoolType); NTKERNELAPI NTSTATUS @@ -11111,6 +8129,7 @@ SeGetWorldRights( #endif /* SE_NTFS_WORLD_CACHE */ #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + /****************************************************************************** * Configuration Manager Functions * ******************************************************************************/ @@ -11120,103 +8139,22 @@ NTKERNELAPI NTSTATUS NTAPI CmRegisterCallback( - IN PEX_CALLBACK_FUNCTION Function, - IN PVOID Context OPTIONAL, - OUT PLARGE_INTEGER Cookie); + IN PEX_CALLBACK_FUNCTION Function, + IN PVOID Context OPTIONAL, + OUT PLARGE_INTEGER Cookie); NTKERNELAPI NTSTATUS NTAPI CmUnRegisterCallback( - IN LARGE_INTEGER Cookie); + IN LARGE_INTEGER Cookie); #endif -#if (NTDDI_VERSION >= NTDDI_VISTA) - -NTKERNELAPI -NTSTATUS -NTAPI -CmRegisterCallbackEx( - PEX_CALLBACK_FUNCTION Function, - PCUNICODE_STRING Altitude, - PVOID Driver, - PVOID Context, - PLARGE_INTEGER Cookie, - PVOID Reserved); - -NTKERNELAPI -VOID -NTAPI -CmGetCallbackVersion( - OUT PULONG Major OPTIONAL, - OUT PULONG Minor OPTIONAL); - -NTKERNELAPI -NTSTATUS -NTAPI -CmSetCallbackObjectContext( - IN OUT PVOID Object, - IN PLARGE_INTEGER Cookie, - IN PVOID NewContext, - OUT PVOID *OldContext OPTIONAL); - -NTKERNELAPI -NTSTATUS -NTAPI -CmCallbackGetKeyObjectID( - IN PLARGE_INTEGER Cookie, - IN PVOID Object, - OUT PULONG_PTR ObjectID OPTIONAL, - OUT PCUNICODE_STRING *ObjectName OPTIONAL); - -NTKERNELAPI -PVOID -NTAPI -CmGetBoundTransaction( - IN PLARGE_INTEGER Cookie, - IN PVOID Object); - -#endif // NTDDI_VERSION >= NTDDI_VISTA - /****************************************************************************** * I/O Manager Functions * ******************************************************************************/ - -/* - * NTSTATUS - * IoAcquireRemoveLock( - * IN PIO_REMOVE_LOCK RemoveLock, - * IN OPTIONAL PVOID Tag) - */ -#if DBG -#define IoAcquireRemoveLock(RemoveLock, Tag) \ - IoAcquireRemoveLockEx(RemoveLock, Tag, __FILE__, __LINE__, sizeof (IO_REMOVE_LOCK)) -#else -#define IoAcquireRemoveLock(RemoveLock, Tag) \ - IoAcquireRemoveLockEx(RemoveLock, Tag, "", 1, sizeof (IO_REMOVE_LOCK)) -#endif - -/* - * VOID - * IoAdjustPagingPathCount( - * IN PLONG Count, - * IN BOOLEAN Increment) - */ -#define IoAdjustPagingPathCount(_Count, \ - _Increment) \ -{ \ - if (_Increment) \ - { \ - InterlockedIncrement(_Count); \ - } \ - else \ - { \ - InterlockedDecrement(_Count); \ - } \ -} - #if !defined(_M_AMD64) NTHALAPI VOID @@ -11359,9 +8297,9 @@ NTKERNELAPI VOID NTAPI WRITE_REGISTER_BUFFER_ULONG( - IN PULONG Register, - IN PULONG Buffer, - IN ULONG Count); + IN PULONG Register, + IN PULONG Buffer, + IN ULONG Count); NTKERNELAPI VOID @@ -11389,8 +8327,8 @@ NTKERNELAPI VOID NTAPI WRITE_REGISTER_USHORT( - IN PUSHORT Register, - IN USHORT Value); + IN PUSHORT Register, + IN USHORT Value); #else @@ -11401,17 +8339,17 @@ READ_PORT_BUFFER_UCHAR( IN PUCHAR Buffer, IN ULONG Count) { - __inbytestring((USHORT)(ULONG_PTR)Port, Buffer, Count); + __inbytestring((USHORT)(ULONG_PTR)Port, Buffer, Count); } FORCEINLINE VOID READ_PORT_BUFFER_ULONG( - IN PULONG Port, - IN PULONG Buffer, - IN ULONG Count) + IN PULONG Port, + IN PULONG Buffer, + IN ULONG Count) { - __indwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count); + __indwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count); } FORCEINLINE @@ -11421,7 +8359,7 @@ READ_PORT_BUFFER_USHORT( IN PUSHORT Buffer, IN ULONG Count) { - __inwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count); + __inwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count); } FORCEINLINE @@ -11429,7 +8367,7 @@ UCHAR READ_PORT_UCHAR( IN PUCHAR Port) { - return __inbyte((USHORT)(ULONG_PTR)Port); + return __inbyte((USHORT)(ULONG_PTR)Port); } FORCEINLINE @@ -11437,7 +8375,7 @@ ULONG READ_PORT_ULONG( IN PULONG Port) { - return __indword((USHORT)(ULONG_PTR)Port); + return __indword((USHORT)(ULONG_PTR)Port); } FORCEINLINE @@ -11445,7 +8383,7 @@ USHORT READ_PORT_USHORT( IN PUSHORT Port) { - return __inword((USHORT)(ULONG_PTR)Port); + return __inword((USHORT)(ULONG_PTR)Port); } FORCEINLINE @@ -11455,27 +8393,27 @@ READ_REGISTER_BUFFER_UCHAR( IN PUCHAR Buffer, IN ULONG Count) { - __movsb(Register, Buffer, Count); + __movsb(Register, Buffer, Count); } FORCEINLINE VOID READ_REGISTER_BUFFER_ULONG( - IN PULONG Register, - IN PULONG Buffer, - IN ULONG Count) + IN PULONG Register, + IN PULONG Buffer, + IN ULONG Count) { - __movsd(Register, Buffer, Count); + __movsd(Register, Buffer, Count); } FORCEINLINE VOID READ_REGISTER_BUFFER_USHORT( - IN PUSHORT Register, - IN PUSHORT Buffer, - IN ULONG Count) + IN PUSHORT Register, + IN PUSHORT Buffer, + IN ULONG Count) { - __movsw(Register, Buffer, Count); + __movsw(Register, Buffer, Count); } FORCEINLINE @@ -11483,7 +8421,7 @@ UCHAR READ_REGISTER_UCHAR( IN volatile UCHAR *Register) { - return *Register; + return *Register; } FORCEINLINE @@ -11491,7 +8429,7 @@ ULONG READ_REGISTER_ULONG( IN volatile ULONG *Register) { - return *Register; + return *Register; } FORCEINLINE @@ -11499,7 +8437,7 @@ USHORT READ_REGISTER_USHORT( IN volatile USHORT *Register) { - return *Register; + return *Register; } FORCEINLINE @@ -11509,7 +8447,7 @@ WRITE_PORT_BUFFER_UCHAR( IN PUCHAR Buffer, IN ULONG Count) { - __outbytestring((USHORT)(ULONG_PTR)Port, Buffer, Count); + __outbytestring((USHORT)(ULONG_PTR)Port, Buffer, Count); } FORCEINLINE @@ -11519,7 +8457,7 @@ WRITE_PORT_BUFFER_ULONG( IN PULONG Buffer, IN ULONG Count) { - __outdwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count); + __outdwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count); } FORCEINLINE @@ -11529,7 +8467,7 @@ WRITE_PORT_BUFFER_USHORT( IN PUSHORT Buffer, IN ULONG Count) { - __outwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count); + __outwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count); } FORCEINLINE @@ -11538,7 +8476,7 @@ WRITE_PORT_UCHAR( IN PUCHAR Port, IN UCHAR Value) { - __outbyte((USHORT)(ULONG_PTR)Port, Value); + __outbyte((USHORT)(ULONG_PTR)Port, Value); } FORCEINLINE @@ -11547,7 +8485,7 @@ WRITE_PORT_ULONG( IN PULONG Port, IN ULONG Value) { - __outdword((USHORT)(ULONG_PTR)Port, Value); + __outdword((USHORT)(ULONG_PTR)Port, Value); } FORCEINLINE @@ -11556,7 +8494,7 @@ WRITE_PORT_USHORT( IN PUSHORT Port, IN USHORT Value) { - __outword((USHORT)(ULONG_PTR)Port, Value); + __outword((USHORT)(ULONG_PTR)Port, Value); } FORCEINLINE @@ -11566,9 +8504,9 @@ WRITE_REGISTER_BUFFER_UCHAR( IN PUCHAR Buffer, IN ULONG Count) { - LONG Synch; - __movsb(Register, Buffer, Count); - InterlockedOr(&Synch, 1); + LONG Synch; + __movsb(Register, Buffer, Count); + InterlockedOr(&Synch, 1); } FORCEINLINE @@ -11578,9 +8516,9 @@ WRITE_REGISTER_BUFFER_ULONG( IN PULONG Buffer, IN ULONG Count) { - LONG Synch; - __movsd(Register, Buffer, Count); - InterlockedOr(&Synch, 1); + LONG Synch; + __movsd(Register, Buffer, Count); + InterlockedOr(&Synch, 1); } FORCEINLINE @@ -11590,9 +8528,9 @@ WRITE_REGISTER_BUFFER_USHORT( IN PUSHORT Buffer, IN ULONG Count) { - LONG Synch; - __movsw(Register, Buffer, Count); - InterlockedOr(&Synch, 1); + LONG Synch; + __movsw(Register, Buffer, Count); + InterlockedOr(&Synch, 1); } FORCEINLINE @@ -11601,9 +8539,9 @@ WRITE_REGISTER_UCHAR( IN volatile UCHAR *Register, IN UCHAR Value) { - LONG Synch; - *Register = Value; - InterlockedOr(&Synch, 1); + LONG Synch; + *Register = Value; + InterlockedOr(&Synch, 1); } FORCEINLINE @@ -11612,9 +8550,9 @@ WRITE_REGISTER_ULONG( IN volatile ULONG *Register, IN ULONG Value) { - LONG Synch; - *Register = Value; - InterlockedOr(&Synch, 1); + LONG Synch; + *Register = Value; + InterlockedOr(&Synch, 1); } FORCEINLINE @@ -11623,9 +8561,9 @@ WRITE_REGISTER_USHORT( IN volatile USHORT *Register, IN USHORT Value) { - LONG Sync; - *Register = Value; - InterlockedOr(&Sync, 1); + LONG Sync; + *Register = Value; + InterlockedOr(&Sync, 1); } #endif @@ -11637,218 +8575,254 @@ WRITE_REGISTER_USHORT( FORCEINLINE NTSTATUS IoAllocateAdapterChannel( - IN PDMA_ADAPTER DmaAdapter, - IN PDEVICE_OBJECT DeviceObject, - IN ULONG NumberOfMapRegisters, - IN PDRIVER_CONTROL ExecutionRoutine, - IN PVOID Context) + IN PDMA_ADAPTER DmaAdapter, + IN PDEVICE_OBJECT DeviceObject, + IN ULONG NumberOfMapRegisters, + IN PDRIVER_CONTROL ExecutionRoutine, + IN PVOID Context) { - PALLOCATE_ADAPTER_CHANNEL AllocateAdapterChannel; - AllocateAdapterChannel = - *(DmaAdapter)->DmaOperations->AllocateAdapterChannel; - ASSERT(AllocateAdapterChannel); - return AllocateAdapterChannel(DmaAdapter, - DeviceObject, - NumberOfMapRegisters, - ExecutionRoutine, - Context ); + PALLOCATE_ADAPTER_CHANNEL AllocateAdapterChannel; + AllocateAdapterChannel = + *(DmaAdapter)->DmaOperations->AllocateAdapterChannel; + ASSERT(AllocateAdapterChannel); + return AllocateAdapterChannel(DmaAdapter, + DeviceObject, + NumberOfMapRegisters, + ExecutionRoutine, + Context ); } FORCEINLINE BOOLEAN NTAPI IoFlushAdapterBuffers( - IN PDMA_ADAPTER DmaAdapter, - IN PMDL Mdl, - IN PVOID MapRegisterBase, - IN PVOID CurrentVa, - IN ULONG Length, - IN BOOLEAN WriteToDevice) + IN PDMA_ADAPTER DmaAdapter, + IN PMDL Mdl, + IN PVOID MapRegisterBase, + IN PVOID CurrentVa, + IN ULONG Length, + IN BOOLEAN WriteToDevice) { - PFLUSH_ADAPTER_BUFFERS FlushAdapterBuffers; - FlushAdapterBuffers = *(DmaAdapter)->DmaOperations->FlushAdapterBuffers; - ASSERT(FlushAdapterBuffers); - return FlushAdapterBuffers(DmaAdapter, - Mdl, - MapRegisterBase, - CurrentVa, - Length, - WriteToDevice); + PFLUSH_ADAPTER_BUFFERS FlushAdapterBuffers; + FlushAdapterBuffers = *(DmaAdapter)->DmaOperations->FlushAdapterBuffers; + ASSERT(FlushAdapterBuffers); + return FlushAdapterBuffers(DmaAdapter, + Mdl, + MapRegisterBase, + CurrentVa, + Length, + WriteToDevice); } FORCEINLINE VOID NTAPI IoFreeAdapterChannel( - IN PDMA_ADAPTER DmaAdapter) + IN PDMA_ADAPTER DmaAdapter) { - PFREE_ADAPTER_CHANNEL FreeAdapterChannel; - FreeAdapterChannel = *(DmaAdapter)->DmaOperations->FreeAdapterChannel; - ASSERT(FreeAdapterChannel); - FreeAdapterChannel(DmaAdapter); + PFREE_ADAPTER_CHANNEL FreeAdapterChannel; + FreeAdapterChannel = *(DmaAdapter)->DmaOperations->FreeAdapterChannel; + ASSERT(FreeAdapterChannel); + FreeAdapterChannel(DmaAdapter); } FORCEINLINE VOID NTAPI IoFreeMapRegisters( - IN PDMA_ADAPTER DmaAdapter, - IN PVOID MapRegisterBase, - IN ULONG NumberOfMapRegisters) + IN PDMA_ADAPTER DmaAdapter, + IN PVOID MapRegisterBase, + IN ULONG NumberOfMapRegisters) { - PFREE_MAP_REGISTERS FreeMapRegisters; - FreeMapRegisters = *(DmaAdapter)->DmaOperations->FreeMapRegisters; - ASSERT(FreeMapRegisters); - FreeMapRegisters(DmaAdapter, MapRegisterBase, NumberOfMapRegisters); + PFREE_MAP_REGISTERS FreeMapRegisters; + FreeMapRegisters = *(DmaAdapter)->DmaOperations->FreeMapRegisters; + ASSERT(FreeMapRegisters); + FreeMapRegisters(DmaAdapter, MapRegisterBase, NumberOfMapRegisters); } FORCEINLINE PHYSICAL_ADDRESS NTAPI IoMapTransfer( - IN PDMA_ADAPTER DmaAdapter, - IN PMDL Mdl, - IN PVOID MapRegisterBase, - IN PVOID CurrentVa, - IN OUT PULONG Length, - IN BOOLEAN WriteToDevice) + IN PDMA_ADAPTER DmaAdapter, + IN PMDL Mdl, + IN PVOID MapRegisterBase, + IN PVOID CurrentVa, + IN OUT PULONG Length, + IN BOOLEAN WriteToDevice) { - PMAP_TRANSFER MapTransfer; + PMAP_TRANSFER MapTransfer; - MapTransfer = *(DmaAdapter)->DmaOperations->MapTransfer; - ASSERT(MapTransfer); - return MapTransfer(DmaAdapter, - Mdl, - MapRegisterBase, - CurrentVa, - Length, - WriteToDevice); + MapTransfer = *(DmaAdapter)->DmaOperations->MapTransfer; + ASSERT(MapTransfer); + return MapTransfer(DmaAdapter, + Mdl, + MapRegisterBase, + CurrentVa, + Length, + WriteToDevice); } #endif #if (NTDDI_VERSION >= NTDDI_WIN2K) - NTKERNELAPI VOID NTAPI IoAcquireCancelSpinLock( - OUT PKIRQL Irql); + OUT PKIRQL Irql); NTKERNELAPI NTSTATUS NTAPI IoAcquireRemoveLockEx( - IN PIO_REMOVE_LOCK RemoveLock, - IN PVOID Tag OPTIONAL, - IN PCSTR File, - IN ULONG Line, - IN ULONG RemlockSize); + IN PIO_REMOVE_LOCK RemoveLock, + IN PVOID Tag OPTIONAL, + IN PCSTR File, + IN ULONG Line, + IN ULONG RemlockSize); +#endif + +/* + * NTSTATUS + * IoAcquireRemoveLock( + * IN PIO_REMOVE_LOCK RemoveLock, + * IN OPTIONAL PVOID Tag) + */ +#if DBG +#define IoAcquireRemoveLock(RemoveLock, Tag) \ + IoAcquireRemoveLockEx(RemoveLock, Tag, __FILE__, __LINE__, sizeof (IO_REMOVE_LOCK)) +#else +#define IoAcquireRemoveLock(RemoveLock, Tag) \ + IoAcquireRemoveLockEx(RemoveLock, Tag, "", 1, sizeof (IO_REMOVE_LOCK)) +#endif + +/* + * VOID + * IoAdjustPagingPathCount( + * IN PLONG Count, + * IN BOOLEAN Increment) + */ +#define IoAdjustPagingPathCount(_Count, \ + _Increment) \ +{ \ + if (_Increment) \ + { \ + InterlockedIncrement(_Count); \ + } \ + else \ + { \ + InterlockedDecrement(_Count); \ + } \ +} + +#if (NTDDI_VERSION >= NTDDI_WIN2K) + NTKERNELAPI NTSTATUS NTAPI IoAllocateDriverObjectExtension( - IN PDRIVER_OBJECT DriverObject, - IN PVOID ClientIdentificationAddress, - IN ULONG DriverObjectExtensionSize, - OUT PVOID *DriverObjectExtension); + IN PDRIVER_OBJECT DriverObject, + IN PVOID ClientIdentificationAddress, + IN ULONG DriverObjectExtensionSize, + OUT PVOID *DriverObjectExtension); NTKERNELAPI PVOID NTAPI IoAllocateErrorLogEntry( - IN PVOID IoObject, - IN UCHAR EntrySize); + IN PVOID IoObject, + IN UCHAR EntrySize); NTKERNELAPI PIRP NTAPI IoAllocateIrp( - IN CCHAR StackSize, - IN BOOLEAN ChargeQuota); + IN CCHAR StackSize, + IN BOOLEAN ChargeQuota); NTKERNELAPI PMDL NTAPI IoAllocateMdl( - IN PVOID VirtualAddress OPTIONAL, - IN ULONG Length, - IN BOOLEAN SecondaryBuffer, - IN BOOLEAN ChargeQuota, - IN OUT PIRP Irp OPTIONAL); + IN PVOID VirtualAddress OPTIONAL, + IN ULONG Length, + IN BOOLEAN SecondaryBuffer, + IN BOOLEAN ChargeQuota, + IN OUT PIRP Irp OPTIONAL); NTKERNELAPI PIO_WORKITEM NTAPI IoAllocateWorkItem( - IN PDEVICE_OBJECT DeviceObject); + IN PDEVICE_OBJECT DeviceObject); NTKERNELAPI NTSTATUS NTAPI IoAttachDevice( - IN PDEVICE_OBJECT SourceDevice, - IN PUNICODE_STRING TargetDevice, - OUT PDEVICE_OBJECT *AttachedDevice); + IN PDEVICE_OBJECT SourceDevice, + IN PUNICODE_STRING TargetDevice, + OUT PDEVICE_OBJECT *AttachedDevice); NTKERNELAPI PDEVICE_OBJECT NTAPI IoAttachDeviceToDeviceStack( - IN PDEVICE_OBJECT SourceDevice, - IN PDEVICE_OBJECT TargetDevice); + IN PDEVICE_OBJECT SourceDevice, + IN PDEVICE_OBJECT TargetDevice); NTKERNELAPI PIRP NTAPI IoBuildAsynchronousFsdRequest( - IN ULONG MajorFunction, - IN PDEVICE_OBJECT DeviceObject, - IN OUT PVOID Buffer OPTIONAL, - IN ULONG Length OPTIONAL, - IN PLARGE_INTEGER StartingOffset OPTIONAL, - IN PIO_STATUS_BLOCK IoStatusBlock OPTIONAL); + IN ULONG MajorFunction, + IN PDEVICE_OBJECT DeviceObject, + IN OUT PVOID Buffer OPTIONAL, + IN ULONG Length OPTIONAL, + IN PLARGE_INTEGER StartingOffset OPTIONAL, + IN PIO_STATUS_BLOCK IoStatusBlock OPTIONAL); NTKERNELAPI PIRP NTAPI IoBuildDeviceIoControlRequest( - IN ULONG IoControlCode, - IN PDEVICE_OBJECT DeviceObject, - IN PVOID InputBuffer OPTIONAL, - IN ULONG InputBufferLength, - OUT PVOID OutputBuffer OPTIONAL, - IN ULONG OutputBufferLength, - IN BOOLEAN InternalDeviceIoControl, - IN PKEVENT Event, - OUT PIO_STATUS_BLOCK IoStatusBlock); + IN ULONG IoControlCode, + IN PDEVICE_OBJECT DeviceObject, + IN PVOID InputBuffer OPTIONAL, + IN ULONG InputBufferLength, + OUT PVOID OutputBuffer OPTIONAL, + IN ULONG OutputBufferLength, + IN BOOLEAN InternalDeviceIoControl, + IN PKEVENT Event, + OUT PIO_STATUS_BLOCK IoStatusBlock); NTKERNELAPI VOID NTAPI IoBuildPartialMdl( - IN PMDL SourceMdl, - IN OUT PMDL TargetMdl, - IN PVOID VirtualAddress, - IN ULONG Length); + IN PMDL SourceMdl, + IN OUT PMDL TargetMdl, + IN PVOID VirtualAddress, + IN ULONG Length); NTKERNELAPI PIRP NTAPI IoBuildSynchronousFsdRequest( - IN ULONG MajorFunction, - IN PDEVICE_OBJECT DeviceObject, - IN OUT PVOID Buffer OPTIONAL, - IN ULONG Length OPTIONAL, - IN PLARGE_INTEGER StartingOffset OPTIONAL, - IN PKEVENT Event, - OUT PIO_STATUS_BLOCK IoStatusBlock); + IN ULONG MajorFunction, + IN PDEVICE_OBJECT DeviceObject, + IN OUT PVOID Buffer OPTIONAL, + IN ULONG Length OPTIONAL, + IN PLARGE_INTEGER StartingOffset OPTIONAL, + IN PKEVENT Event, + OUT PIO_STATUS_BLOCK IoStatusBlock); NTKERNELAPI NTSTATUS FASTCALL IofCallDriver( - IN PDEVICE_OBJECT DeviceObject, - IN OUT PIRP Irp); + IN PDEVICE_OBJECT DeviceObject, + IN OUT PIRP Irp); #define IoCallDriver IofCallDriver NTKERNELAPI @@ -11863,52 +8837,52 @@ NTKERNELAPI BOOLEAN NTAPI IoCancelIrp( - IN PIRP Irp); + IN PIRP Irp); NTKERNELAPI NTSTATUS NTAPI IoCheckShareAccess( - IN ACCESS_MASK DesiredAccess, - IN ULONG DesiredShareAccess, - IN OUT PFILE_OBJECT FileObject, - IN OUT PSHARE_ACCESS ShareAccess, - IN BOOLEAN Update); + IN ACCESS_MASK DesiredAccess, + IN ULONG DesiredShareAccess, + IN OUT PFILE_OBJECT FileObject, + IN OUT PSHARE_ACCESS ShareAccess, + IN BOOLEAN Update); NTKERNELAPI VOID FASTCALL IofCompleteRequest( - IN PIRP Irp, - IN CCHAR PriorityBoost); + IN PIRP Irp, + IN CCHAR PriorityBoost); NTKERNELAPI NTSTATUS NTAPI IoConnectInterrupt( - OUT PKINTERRUPT *InterruptObject, - IN PKSERVICE_ROUTINE ServiceRoutine, - IN PVOID ServiceContext OPTIONAL, - IN PKSPIN_LOCK SpinLock OPTIONAL, - IN ULONG Vector, - IN KIRQL Irql, - IN KIRQL SynchronizeIrql, - IN KINTERRUPT_MODE InterruptMode, - IN BOOLEAN ShareVector, - IN KAFFINITY ProcessorEnableMask, - IN BOOLEAN FloatingSave); + OUT PKINTERRUPT *InterruptObject, + IN PKSERVICE_ROUTINE ServiceRoutine, + IN PVOID ServiceContext OPTIONAL, + IN PKSPIN_LOCK SpinLock OPTIONAL, + IN ULONG Vector, + IN KIRQL Irql, + IN KIRQL SynchronizeIrql, + IN KINTERRUPT_MODE InterruptMode, + IN BOOLEAN ShareVector, + IN KAFFINITY ProcessorEnableMask, + IN BOOLEAN FloatingSave); NTKERNELAPI NTSTATUS NTAPI IoCreateDevice( - IN PDRIVER_OBJECT DriverObject, - IN ULONG DeviceExtensionSize, - IN PUNICODE_STRING DeviceName OPTIONAL, - IN DEVICE_TYPE DeviceType, - IN ULONG DeviceCharacteristics, - IN BOOLEAN Exclusive, - OUT PDEVICE_OBJECT *DeviceObject); + IN PDRIVER_OBJECT DriverObject, + IN ULONG DeviceExtensionSize, + IN PUNICODE_STRING DeviceName OPTIONAL, + IN DEVICE_TYPE DeviceType, + IN ULONG DeviceCharacteristics, + IN BOOLEAN Exclusive, + OUT PDEVICE_OBJECT *DeviceObject); NTKERNELAPI NTSTATUS @@ -11933,53 +8907,53 @@ NTKERNELAPI PKEVENT NTAPI IoCreateNotificationEvent( - IN PUNICODE_STRING EventName, - OUT PHANDLE EventHandle); + IN PUNICODE_STRING EventName, + OUT PHANDLE EventHandle); NTKERNELAPI NTSTATUS NTAPI IoCreateSymbolicLink( - IN PUNICODE_STRING SymbolicLinkName, - IN PUNICODE_STRING DeviceName); + IN PUNICODE_STRING SymbolicLinkName, + IN PUNICODE_STRING DeviceName); NTKERNELAPI PKEVENT NTAPI IoCreateSynchronizationEvent( - IN PUNICODE_STRING EventName, - OUT PHANDLE EventHandle); + IN PUNICODE_STRING EventName, + OUT PHANDLE EventHandle); NTKERNELAPI NTSTATUS NTAPI IoCreateUnprotectedSymbolicLink( - IN PUNICODE_STRING SymbolicLinkName, - IN PUNICODE_STRING DeviceName); + IN PUNICODE_STRING SymbolicLinkName, + IN PUNICODE_STRING DeviceName); NTKERNELAPI VOID NTAPI IoDeleteDevice( - IN PDEVICE_OBJECT DeviceObject); + IN PDEVICE_OBJECT DeviceObject); NTKERNELAPI NTSTATUS NTAPI IoDeleteSymbolicLink( - IN PUNICODE_STRING SymbolicLinkName); + IN PUNICODE_STRING SymbolicLinkName); NTKERNELAPI VOID NTAPI IoDetachDevice( - IN OUT PDEVICE_OBJECT TargetDevice); + IN OUT PDEVICE_OBJECT TargetDevice); NTKERNELAPI VOID NTAPI IoDisconnectInterrupt( - IN PKINTERRUPT InterruptObject); + IN PKINTERRUPT InterruptObject); NTKERNELAPI VOID @@ -12009,375 +8983,359 @@ NTKERNELAPI PDEVICE_OBJECT NTAPI IoGetAttachedDeviceReference( - IN PDEVICE_OBJECT DeviceObject); + IN PDEVICE_OBJECT DeviceObject); NTKERNELAPI NTSTATUS NTAPI IoGetBootDiskInformation( - IN OUT PBOOTDISK_INFORMATION BootDiskInformation, - IN ULONG Size); + IN OUT PBOOTDISK_INFORMATION BootDiskInformation, + IN ULONG Size); NTKERNELAPI NTSTATUS NTAPI IoGetDeviceInterfaceAlias( - IN PUNICODE_STRING SymbolicLinkName, - IN CONST GUID *AliasInterfaceClassGuid, - OUT PUNICODE_STRING AliasSymbolicLinkName); + IN PUNICODE_STRING SymbolicLinkName, + IN CONST GUID *AliasInterfaceClassGuid, + OUT PUNICODE_STRING AliasSymbolicLinkName); NTKERNELAPI PEPROCESS NTAPI -IoGetCurrentProcess(VOID); +IoGetCurrentProcess( + VOID); NTKERNELAPI NTSTATUS NTAPI IoGetDeviceInterfaces( - IN CONST GUID *InterfaceClassGuid, - IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL, - IN ULONG Flags, - OUT PWSTR *SymbolicLinkList); + IN CONST GUID *InterfaceClassGuid, + IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL, + IN ULONG Flags, + OUT PWSTR *SymbolicLinkList); NTKERNELAPI NTSTATUS NTAPI IoGetDeviceObjectPointer( - IN PUNICODE_STRING ObjectName, - IN ACCESS_MASK DesiredAccess, - OUT PFILE_OBJECT *FileObject, - OUT PDEVICE_OBJECT *DeviceObject); + IN PUNICODE_STRING ObjectName, + IN ACCESS_MASK DesiredAccess, + OUT PFILE_OBJECT *FileObject, + OUT PDEVICE_OBJECT *DeviceObject); NTKERNELAPI NTSTATUS NTAPI IoGetDeviceProperty( - IN PDEVICE_OBJECT DeviceObject, - IN DEVICE_REGISTRY_PROPERTY DeviceProperty, - IN ULONG BufferLength, - OUT PVOID PropertyBuffer, - OUT PULONG ResultLength); + IN PDEVICE_OBJECT DeviceObject, + IN DEVICE_REGISTRY_PROPERTY DeviceProperty, + IN ULONG BufferLength, + OUT PVOID PropertyBuffer, + OUT PULONG ResultLength); NTKERNELAPI PDMA_ADAPTER NTAPI IoGetDmaAdapter( - IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL, - IN PDEVICE_DESCRIPTION DeviceDescription, - IN OUT PULONG NumberOfMapRegisters); + IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL, + IN PDEVICE_DESCRIPTION DeviceDescription, + IN OUT PULONG NumberOfMapRegisters); NTKERNELAPI PVOID NTAPI IoGetDriverObjectExtension( - IN PDRIVER_OBJECT DriverObject, - IN PVOID ClientIdentificationAddress); + IN PDRIVER_OBJECT DriverObject, + IN PVOID ClientIdentificationAddress); NTKERNELAPI PVOID NTAPI -IoGetInitialStack(VOID); +IoGetInitialStack( + VOID); NTKERNELAPI PDEVICE_OBJECT NTAPI IoGetRelatedDeviceObject( - IN PFILE_OBJECT FileObject); + IN PFILE_OBJECT FileObject); NTKERNELAPI VOID NTAPI IoQueueWorkItem( - IN PIO_WORKITEM IoWorkItem, - IN PIO_WORKITEM_ROUTINE WorkerRoutine, - IN WORK_QUEUE_TYPE QueueType, - IN PVOID Context OPTIONAL); + IN PIO_WORKITEM IoWorkItem, + IN PIO_WORKITEM_ROUTINE WorkerRoutine, + IN WORK_QUEUE_TYPE QueueType, + IN PVOID Context OPTIONAL); NTKERNELAPI VOID NTAPI IoInitializeIrp( - IN OUT PIRP Irp, - IN USHORT PacketSize, - IN CCHAR StackSize); + IN OUT PIRP Irp, + IN USHORT PacketSize, + IN CCHAR StackSize); NTKERNELAPI VOID NTAPI IoInitializeRemoveLockEx( - IN PIO_REMOVE_LOCK Lock, - IN ULONG AllocateTag, - IN ULONG MaxLockedMinutes, - IN ULONG HighWatermark, - IN ULONG RemlockSize); + IN PIO_REMOVE_LOCK Lock, + IN ULONG AllocateTag, + IN ULONG MaxLockedMinutes, + IN ULONG HighWatermark, + IN ULONG RemlockSize); NTKERNELAPI NTSTATUS NTAPI IoInitializeTimer( - IN PDEVICE_OBJECT DeviceObject, - IN PIO_TIMER_ROUTINE TimerRoutine, - IN PVOID Context OPTIONAL); + IN PDEVICE_OBJECT DeviceObject, + IN PIO_TIMER_ROUTINE TimerRoutine, + IN PVOID Context OPTIONAL); NTKERNELAPI VOID NTAPI IoInvalidateDeviceRelations( - IN PDEVICE_OBJECT DeviceObject, - IN DEVICE_RELATION_TYPE Type); + IN PDEVICE_OBJECT DeviceObject, + IN DEVICE_RELATION_TYPE Type); NTKERNELAPI VOID NTAPI IoInvalidateDeviceState( - IN PDEVICE_OBJECT PhysicalDeviceObject); + IN PDEVICE_OBJECT PhysicalDeviceObject); NTKERNELAPI BOOLEAN NTAPI IoIsWdmVersionAvailable( - IN UCHAR MajorVersion, - IN UCHAR MinorVersion); + IN UCHAR MajorVersion, + IN UCHAR MinorVersion); NTKERNELAPI NTSTATUS NTAPI IoOpenDeviceInterfaceRegistryKey( - IN PUNICODE_STRING SymbolicLinkName, - IN ACCESS_MASK DesiredAccess, - OUT PHANDLE DeviceInterfaceKey); + IN PUNICODE_STRING SymbolicLinkName, + IN ACCESS_MASK DesiredAccess, + OUT PHANDLE DeviceInterfaceKey); NTKERNELAPI NTSTATUS NTAPI IoOpenDeviceRegistryKey( - IN PDEVICE_OBJECT DeviceObject, - IN ULONG DevInstKeyType, - IN ACCESS_MASK DesiredAccess, - OUT PHANDLE DevInstRegKey); + IN PDEVICE_OBJECT DeviceObject, + IN ULONG DevInstKeyType, + IN ACCESS_MASK DesiredAccess, + OUT PHANDLE DevInstRegKey); NTKERNELAPI NTSTATUS NTAPI IoRegisterDeviceInterface( - IN PDEVICE_OBJECT PhysicalDeviceObject, - IN CONST GUID *InterfaceClassGuid, - IN PUNICODE_STRING ReferenceString OPTIONAL, - OUT PUNICODE_STRING SymbolicLinkName); + IN PDEVICE_OBJECT PhysicalDeviceObject, + IN CONST GUID *InterfaceClassGuid, + IN PUNICODE_STRING ReferenceString OPTIONAL, + OUT PUNICODE_STRING SymbolicLinkName); NTKERNELAPI NTSTATUS NTAPI IoRegisterPlugPlayNotification( - IN IO_NOTIFICATION_EVENT_CATEGORY EventCategory, - IN ULONG EventCategoryFlags, - IN PVOID EventCategoryData OPTIONAL, - IN PDRIVER_OBJECT DriverObject, - IN PDRIVER_NOTIFICATION_CALLBACK_ROUTINE CallbackRoutine, - IN OUT PVOID Context OPTIONAL, - OUT PVOID *NotificationEntry); + IN IO_NOTIFICATION_EVENT_CATEGORY EventCategory, + IN ULONG EventCategoryFlags, + IN PVOID EventCategoryData OPTIONAL, + IN PDRIVER_OBJECT DriverObject, + IN PDRIVER_NOTIFICATION_CALLBACK_ROUTINE CallbackRoutine, + IN OUT PVOID Context OPTIONAL, + OUT PVOID *NotificationEntry); NTKERNELAPI NTSTATUS NTAPI IoRegisterShutdownNotification( - IN PDEVICE_OBJECT DeviceObject); + IN PDEVICE_OBJECT DeviceObject); NTKERNELAPI VOID NTAPI IoReleaseCancelSpinLock( - IN KIRQL Irql); + IN KIRQL Irql); NTKERNELAPI VOID NTAPI IoReleaseRemoveLockAndWaitEx( - IN PIO_REMOVE_LOCK RemoveLock, - IN PVOID Tag OPTIONAL, - IN ULONG RemlockSize); + IN PIO_REMOVE_LOCK RemoveLock, + IN PVOID Tag OPTIONAL, + IN ULONG RemlockSize); NTKERNELAPI VOID NTAPI IoReleaseRemoveLockEx( - IN PIO_REMOVE_LOCK RemoveLock, - IN PVOID Tag OPTIONAL, - IN ULONG RemlockSize); + IN PIO_REMOVE_LOCK RemoveLock, + IN PVOID Tag OPTIONAL, + IN ULONG RemlockSize); NTKERNELAPI VOID NTAPI IoRemoveShareAccess( - IN PFILE_OBJECT FileObject, - IN OUT PSHARE_ACCESS ShareAccess); + IN PFILE_OBJECT FileObject, + IN OUT PSHARE_ACCESS ShareAccess); NTKERNELAPI NTSTATUS NTAPI IoReportTargetDeviceChange( - IN PDEVICE_OBJECT PhysicalDeviceObject, - IN PVOID NotificationStructure); + IN PDEVICE_OBJECT PhysicalDeviceObject, + IN PVOID NotificationStructure); NTKERNELAPI NTSTATUS NTAPI IoReportTargetDeviceChangeAsynchronous( - IN PDEVICE_OBJECT PhysicalDeviceObject, - IN PVOID NotificationStructure, - IN PDEVICE_CHANGE_COMPLETE_CALLBACK Callback OPTIONAL, - IN PVOID Context OPTIONAL); + IN PDEVICE_OBJECT PhysicalDeviceObject, + IN PVOID NotificationStructure, + IN PDEVICE_CHANGE_COMPLETE_CALLBACK Callback OPTIONAL, + IN PVOID Context OPTIONAL); NTKERNELAPI VOID NTAPI IoRequestDeviceEject( - IN PDEVICE_OBJECT PhysicalDeviceObject); + IN PDEVICE_OBJECT PhysicalDeviceObject); NTKERNELAPI VOID NTAPI IoReuseIrp( - IN OUT PIRP Irp, - IN NTSTATUS Status); + IN OUT PIRP Irp, + IN NTSTATUS Status); NTKERNELAPI NTSTATUS NTAPI IoSetDeviceInterfaceState( - IN PUNICODE_STRING SymbolicLinkName, - IN BOOLEAN Enable); + IN PUNICODE_STRING SymbolicLinkName, + IN BOOLEAN Enable); NTKERNELAPI VOID NTAPI IoSetShareAccess( - IN ACCESS_MASK DesiredAccess, - IN ULONG DesiredShareAccess, - IN OUT PFILE_OBJECT FileObject, - OUT PSHARE_ACCESS ShareAccess); + IN ACCESS_MASK DesiredAccess, + IN ULONG DesiredShareAccess, + IN OUT PFILE_OBJECT FileObject, + OUT PSHARE_ACCESS ShareAccess); NTKERNELAPI VOID NTAPI IoStartNextPacket( - IN PDEVICE_OBJECT DeviceObject, - IN BOOLEAN Cancelable); + IN PDEVICE_OBJECT DeviceObject, + IN BOOLEAN Cancelable); NTKERNELAPI VOID NTAPI IoStartNextPacketByKey( - IN PDEVICE_OBJECT DeviceObject, - IN BOOLEAN Cancelable, - IN ULONG Key); + IN PDEVICE_OBJECT DeviceObject, + IN BOOLEAN Cancelable, + IN ULONG Key); NTKERNELAPI VOID NTAPI IoStartPacket( - IN PDEVICE_OBJECT DeviceObject, - IN PIRP Irp, - IN PULONG Key OPTIONAL, - IN PDRIVER_CANCEL CancelFunction OPTIONAL); + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp, + IN PULONG Key OPTIONAL, + IN PDRIVER_CANCEL CancelFunction OPTIONAL); NTKERNELAPI VOID NTAPI IoStartTimer( - IN PDEVICE_OBJECT DeviceObject); + IN PDEVICE_OBJECT DeviceObject); NTKERNELAPI VOID NTAPI IoStopTimer( - IN PDEVICE_OBJECT DeviceObject); + IN PDEVICE_OBJECT DeviceObject); NTKERNELAPI NTSTATUS NTAPI IoUnregisterPlugPlayNotification( - IN PVOID NotificationEntry); + IN PVOID NotificationEntry); NTKERNELAPI VOID NTAPI IoUnregisterShutdownNotification( - IN PDEVICE_OBJECT DeviceObject); + IN PDEVICE_OBJECT DeviceObject); NTKERNELAPI VOID NTAPI IoUpdateShareAccess( - IN PFILE_OBJECT FileObject, - IN OUT PSHARE_ACCESS ShareAccess); + IN PFILE_OBJECT FileObject, + IN OUT PSHARE_ACCESS ShareAccess); NTKERNELAPI NTSTATUS NTAPI IoWMIAllocateInstanceIds( - IN GUID *Guid, - IN ULONG InstanceCount, - OUT ULONG *FirstInstanceId); + IN GUID *Guid, + IN ULONG InstanceCount, + OUT ULONG *FirstInstanceId); NTKERNELAPI NTSTATUS NTAPI IoWMIQuerySingleInstanceMultiple( - IN PVOID *DataBlockObjectList, - IN PUNICODE_STRING InstanceNames, - IN ULONG ObjectCount, - IN OUT ULONG *InOutBufferSize, - OUT PVOID OutBuffer); + IN PVOID *DataBlockObjectList, + IN PUNICODE_STRING InstanceNames, + IN ULONG ObjectCount, + IN OUT ULONG *InOutBufferSize, + OUT PVOID OutBuffer); NTKERNELAPI NTSTATUS NTAPI IoWMIRegistrationControl( - IN PDEVICE_OBJECT DeviceObject, - IN ULONG Action); + IN PDEVICE_OBJECT DeviceObject, + IN ULONG Action); NTKERNELAPI NTSTATUS NTAPI IoWMISuggestInstanceName( - IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL, - IN PUNICODE_STRING SymbolicLinkName OPTIONAL, - IN BOOLEAN CombineNames, - OUT PUNICODE_STRING SuggestedInstanceName); + IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL, + IN PUNICODE_STRING SymbolicLinkName OPTIONAL, + IN BOOLEAN CombineNames, + OUT PUNICODE_STRING SuggestedInstanceName); NTKERNELAPI NTSTATUS NTAPI IoWMIWriteEvent( - IN OUT PVOID WnodeEventItem); + IN PVOID WnodeEventItem); NTKERNELAPI VOID NTAPI IoWriteErrorLogEntry( - IN PVOID ElEntry); - -NTKERNELAPI -PIRP -NTAPI -IoGetTopLevelIrp(VOID); - -NTKERNELAPI -NTSTATUS -NTAPI -IoRegisterLastChanceShutdownNotification( - IN PDEVICE_OBJECT DeviceObject); - -NTKERNELAPI -VOID -NTAPI -IoSetTopLevelIrp( - IN PIRP Irp OPTIONAL); - -#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ + IN PVOID ElEntry); +#endif #if (NTDDI_VERSION >= NTDDI_WINXP) @@ -12412,15 +9370,15 @@ NTKERNELAPI PIRP NTAPI IoCsqRemoveNextIrp( - IN PIO_CSQ Csq, - IN PVOID PeekContext OPTIONAL); + IN PIO_CSQ Csq, + IN PVOID PeekContext); NTKERNELAPI BOOLEAN NTAPI IoForwardIrpSynchronously( - IN PDEVICE_OBJECT DeviceObject, - IN PIRP Irp); + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp); #define IoForwardAndCatchIrp IoForwardIrpSynchronously @@ -12428,347 +9386,119 @@ NTKERNELAPI VOID NTAPI IoFreeErrorLogEntry( - PVOID ElEntry); + PVOID ElEntry); NTKERNELAPI NTSTATUS NTAPI IoSetCompletionRoutineEx( - IN PDEVICE_OBJECT DeviceObject, - IN PIRP Irp, - IN PIO_COMPLETION_ROUTINE CompletionRoutine, - IN PVOID Context, - IN BOOLEAN InvokeOnSuccess, - IN BOOLEAN InvokeOnError, - IN BOOLEAN InvokeOnCancel); + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp, + IN PIO_COMPLETION_ROUTINE CompletionRoutine, + IN PVOID Context, + IN BOOLEAN InvokeOnSuccess, + IN BOOLEAN InvokeOnError, + IN BOOLEAN InvokeOnCancel); VOID NTAPI IoSetStartIoAttributes( - IN PDEVICE_OBJECT DeviceObject, - IN BOOLEAN DeferredStartIo, - IN BOOLEAN NonCancelable); + IN PDEVICE_OBJECT DeviceObject, + IN BOOLEAN DeferredStartIo, + IN BOOLEAN NonCancelable); NTKERNELAPI NTSTATUS NTAPI IoWMIDeviceObjectToInstanceName( - IN PVOID DataBlockObject, - IN PDEVICE_OBJECT DeviceObject, - OUT PUNICODE_STRING InstanceName); + IN PVOID DataBlockObject, + IN PDEVICE_OBJECT DeviceObject, + OUT PUNICODE_STRING InstanceName); NTKERNELAPI NTSTATUS NTAPI IoWMIExecuteMethod( - IN PVOID DataBlockObject, - IN PUNICODE_STRING InstanceName, - IN ULONG MethodId, - IN ULONG InBufferSize, - IN OUT PULONG OutBufferSize, - IN OUT PUCHAR InOutBuffer); + IN PVOID DataBlockObject, + IN PUNICODE_STRING InstanceName, + IN ULONG MethodId, + IN ULONG InBufferSize, + IN OUT PULONG OutBufferSize, + IN OUT PUCHAR InOutBuffer); NTKERNELAPI NTSTATUS NTAPI IoWMIHandleToInstanceName( - IN PVOID DataBlockObject, - IN HANDLE FileHandle, - OUT PUNICODE_STRING InstanceName); + IN PVOID DataBlockObject, + IN HANDLE FileHandle, + OUT PUNICODE_STRING InstanceName); NTKERNELAPI NTSTATUS NTAPI IoWMIOpenBlock( - IN GUID *DataBlockGuid, - IN ULONG DesiredAccess, - OUT PVOID *DataBlockObject); + IN GUID *DataBlockGuid, + IN ULONG DesiredAccess, + OUT PVOID *DataBlockObject); NTKERNELAPI NTSTATUS NTAPI IoWMIQueryAllData( - IN PVOID DataBlockObject, - IN OUT ULONG *InOutBufferSize, - OUT PVOID OutBuffer); + IN PVOID DataBlockObject, + IN OUT ULONG *InOutBufferSize, + OUT PVOID OutBuffer); NTKERNELAPI NTSTATUS NTAPI IoWMIQueryAllDataMultiple( - IN PVOID *DataBlockObjectList, - IN ULONG ObjectCount, - IN OUT ULONG *InOutBufferSize, - OUT PVOID OutBuffer); + IN PVOID *DataBlockObjectList, + IN ULONG ObjectCount, + IN OUT ULONG *InOutBufferSize, + OUT PVOID OutBuffer); NTKERNELAPI NTSTATUS NTAPI IoWMIQuerySingleInstance( - IN PVOID DataBlockObject, - IN PUNICODE_STRING InstanceName, - IN OUT ULONG *InOutBufferSize, + IN PVOID DataBlockObject, + IN PUNICODE_STRING InstanceName, + IN OUT ULONG *InOutBufferSize, OUT PVOID OutBuffer); NTKERNELAPI NTSTATUS NTAPI IoWMISetNotificationCallback( - IN OUT PVOID Object, - IN WMI_NOTIFICATION_CALLBACK Callback, - IN PVOID Context OPTIONAL); + IN OUT PVOID Object, + IN WMI_NOTIFICATION_CALLBACK Callback, + IN PVOID Context OPTIONAL); NTKERNELAPI NTSTATUS NTAPI IoWMISetSingleInstance( - IN PVOID DataBlockObject, - IN PUNICODE_STRING InstanceName, - IN ULONG Version, - IN ULONG ValueBufferSize, - IN PVOID ValueBuffer); + IN PVOID DataBlockObject, + IN PUNICODE_STRING InstanceName, + IN ULONG Version, + IN ULONG ValueBufferSize, + IN PVOID ValueBuffer); NTKERNELAPI NTSTATUS NTAPI IoWMISetSingleItem( - IN PVOID DataBlockObject, - IN PUNICODE_STRING InstanceName, - IN ULONG DataItemId, - IN ULONG Version, - IN ULONG ValueBufferSize, - IN PVOID ValueBuffer); -#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ + IN PVOID DataBlockObject, + IN PUNICODE_STRING InstanceName, + IN ULONG DataItemId, + IN ULONG Version, + IN ULONG ValueBufferSize, + IN PVOID ValueBuffer); -#if (NTDDI_VERSION >= NTDDI_WINXPSP1) -NTKERNELAPI -NTSTATUS -NTAPI -IoValidateDeviceIoControlAccess( - IN PIRP Irp, - IN ULONG RequiredAccess); #endif -#if (NTDDI_VERSION >= NTDDI_WS03) - -NTKERNELAPI -NTSTATUS -NTAPI -IoCsqInitializeEx( - IN PIO_CSQ Csq, - IN PIO_CSQ_INSERT_IRP_EX CsqInsertIrp, - IN PIO_CSQ_REMOVE_IRP CsqRemoveIrp, - IN PIO_CSQ_PEEK_NEXT_IRP CsqPeekNextIrp, - IN PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock, - IN PIO_CSQ_RELEASE_LOCK CsqReleaseLock, - IN PIO_CSQ_COMPLETE_CANCELED_IRP CsqCompleteCanceledIrp); - -NTKERNELAPI -NTSTATUS -NTAPI -IoCsqInsertIrpEx( - IN PIO_CSQ Csq, - IN PIRP Irp, - IN PIO_CSQ_IRP_CONTEXT Context OPTIONAL, - IN PVOID InsertContext OPTIONAL); -#endif /* (NTDDI_VERSION >= NTDDI_WS03) */ - - -#if (NTDDI_VERSION >= NTDDI_VISTA) - -NTKERNELAPI -NTSTATUS -NTAPI -IoGetBootDiskInformationLite( - OUT PBOOTDISK_INFORMATION_LITE *BootDiskInformation); - -NTKERNELAPI -NTSTATUS -NTAPI -IoCheckShareAccessEx( - IN ACCESS_MASK DesiredAccess, - IN ULONG DesiredShareAccess, - IN OUT PFILE_OBJECT FileObject, - IN OUT PSHARE_ACCESS ShareAccess, - IN BOOLEAN Update, - IN PBOOLEAN WritePermission); - -NTKERNELAPI -NTSTATUS -NTAPI -IoConnectInterruptEx( - IN OUT PIO_CONNECT_INTERRUPT_PARAMETERS Parameters); - -NTKERNELAPI -VOID -NTAPI -IoDisconnectInterruptEx( - IN PIO_DISCONNECT_INTERRUPT_PARAMETERS Parameters); - -LOGICAL -NTAPI -IoWithinStackLimits( - IN ULONG_PTR RegionStart, - IN SIZE_T RegionSize); - -NTKERNELAPI -VOID -NTAPI -IoSetShareAccessEx( - IN ACCESS_MASK DesiredAccess, - IN ULONG DesiredShareAccess, - IN OUT PFILE_OBJECT FileObject, - OUT PSHARE_ACCESS ShareAccess, - IN PBOOLEAN WritePermission); - -ULONG -NTAPI -IoSizeofWorkItem(VOID); - -VOID -NTAPI -IoInitializeWorkItem( - IN PVOID IoObject, - IN PIO_WORKITEM IoWorkItem); - -VOID -NTAPI -IoUninitializeWorkItem( - IN PIO_WORKITEM IoWorkItem); - -VOID -NTAPI -IoQueueWorkItemEx( - IN PIO_WORKITEM IoWorkItem, - IN PIO_WORKITEM_ROUTINE_EX WorkerRoutine, - IN WORK_QUEUE_TYPE QueueType, - IN PVOID Context OPTIONAL); - -IO_PRIORITY_HINT -NTAPI -IoGetIoPriorityHint( - IN PIRP Irp); - -NTSTATUS -NTAPI -IoSetIoPriorityHint( - IN PIRP Irp, - IN IO_PRIORITY_HINT PriorityHint); - -NTSTATUS -NTAPI -IoAllocateSfioStreamIdentifier( - IN PFILE_OBJECT FileObject, - IN ULONG Length, - IN PVOID Signature, - OUT PVOID *StreamIdentifier); - -PVOID -NTAPI -IoGetSfioStreamIdentifier( - IN PFILE_OBJECT FileObject, - IN PVOID Signature); - -NTSTATUS -NTAPI -IoFreeSfioStreamIdentifier( - IN PFILE_OBJECT FileObject, - IN PVOID Signature); - -NTKERNELAPI -NTSTATUS -NTAPI -IoRequestDeviceEjectEx( - IN PDEVICE_OBJECT PhysicalDeviceObject, - IN PIO_DEVICE_EJECT_CALLBACK Callback OPTIONAL, - IN PVOID Context OPTIONAL, - IN PDRIVER_OBJECT DriverObject OPTIONAL); - -NTKERNELAPI -NTSTATUS -NTAPI -IoSetDevicePropertyData( - IN PDEVICE_OBJECT Pdo, - IN CONST DEVPROPKEY *PropertyKey, - IN LCID Lcid, - IN ULONG Flags, - IN DEVPROPTYPE Type, - IN ULONG Size, - IN PVOID Data OPTIONAL); - -NTKERNELAPI -NTSTATUS -NTAPI -IoGetDevicePropertyData( - PDEVICE_OBJECT Pdo, - CONST DEVPROPKEY *PropertyKey, - LCID Lcid, - ULONG Flags, - ULONG Size, - PVOID Data, - PULONG RequiredSize, - PDEVPROPTYPE Type); - -#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ - -#define IoCallDriverStackSafeDefault(a, b) IoCallDriver(a, b) - -#if (NTDDI_VERSION >= NTDDI_WS08) -NTKERNELAPI -NTSTATUS -NTAPI -IoReplacePartitionUnit( - IN PDEVICE_OBJECT TargetPdo, - IN PDEVICE_OBJECT SparePdo, - IN ULONG Flags); -#endif - -#if (NTDDI_VERSION >= NTDDI_WIN7) - -NTKERNELAPI -NTSTATUS -NTAPI -IoGetAffinityInterrupt( - IN PKINTERRUPT InterruptObject, - OUT PGROUP_AFFINITY GroupAffinity); - -NTSTATUS -NTAPI -IoGetContainerInformation( - IN IO_CONTAINER_INFORMATION_CLASS InformationClass, - IN PVOID ContainerObject OPTIONAL, - IN OUT PVOID Buffer OPTIONAL, - IN ULONG BufferLength); - -NTSTATUS -NTAPI -IoRegisterContainerNotification( - IN IO_CONTAINER_NOTIFICATION_CLASS NotificationClass, - IN PIO_CONTAINER_NOTIFICATION_FUNCTION CallbackFunction, - IN PVOID NotificationInformation OPTIONAL, - IN ULONG NotificationInformationLength, - OUT PVOID CallbackRegistration); - -VOID -NTAPI -IoUnregisterContainerNotification( - IN PVOID CallbackRegistration); - -NTKERNELAPI -NTSTATUS -NTAPI -IoUnregisterPlugPlayNotificationEx( - IN PVOID NotificationEntry); - -NTKERNELAPI -NTSTATUS -NTAPI -IoGetDeviceNumaNode( - IN PDEVICE_OBJECT Pdo, - OUT PUSHORT NodeNumber); - -#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ - #if defined(_WIN64) NTKERNELAPI ULONG @@ -12789,7 +9519,7 @@ IoWMIDeviceObjectToProviderId( FORCEINLINE VOID -IoSkipCurrentIrpStackLocation( +IoSkipCurrentIrpStackLocation ( IN OUT PIRP Irp) { ASSERT(Irp->CurrentLocation <= Irp->StackCount); @@ -12799,7 +9529,7 @@ IoSkipCurrentIrpStackLocation( FORCEINLINE VOID -IoSetNextIrpStackLocation( +IoSetNextIrpStackLocation ( IN OUT PIRP Irp) { ASSERT(Irp->CurrentLocation > 0); @@ -12888,10 +9618,12 @@ IoSetCompletionRoutine( IoReleaseRemoveLockAndWaitEx(_RemoveLock, _Tag, sizeof(IO_REMOVE_LOCK)) #if defined(_WIN64) + NTKERNELAPI BOOLEAN IoIs32bitProcess( - IN PIRP Irp OPTIONAL); + IN PIRP Irp OPTIONAL); + #endif #define PLUGPLAY_REGKEY_DEVICE 1 @@ -12965,7 +9697,7 @@ IoInitializeDpcRequest( FORCEINLINE VOID IoCopyCurrentIrpStackLocationToNext( - IN OUT PIRP Irp) + IN PIRP Irp) { PIO_STACK_LOCATION irpSp; PIO_STACK_LOCATION nextIrpSp; @@ -12979,12 +9711,13 @@ NTKERNELAPI VOID NTAPI IoGetStackLimits( - OUT PULONG_PTR LowLimit, - OUT PULONG_PTR HighLimit); + OUT PULONG_PTR LowLimit, + OUT PULONG_PTR HighLimit); FORCEINLINE ULONG_PTR -IoGetRemainingStackSize(VOID) +IoGetRemainingStackSize( + VOID) { ULONG_PTR End, Begin; ULONG_PTR Result; @@ -12994,19 +9727,6 @@ IoGetRemainingStackSize(VOID) return Result; } -#if (NTDDI_VERSION >= NTDDI_WS03) -VOID -FORCEINLINE -IoInitializeThreadedDpcRequest( - IN PDEVICE_OBJECT DeviceObject, - IN PIO_DPC_ROUTINE DpcRoutine) -{ - KeInitializeThreadedDpc(&DeviceObject->Dpc, - (PKDEFERRED_ROUTINE) DpcRoutine, - DeviceObject ); -} -#endif - /****************************************************************************** * Power Management Support Functions * ******************************************************************************/ @@ -13019,17 +9739,17 @@ NTKERNELAPI NTSTATUS NTAPI PoCallDriver( - IN struct _DEVICE_OBJECT *DeviceObject, - IN OUT struct _IRP *Irp); + IN struct _DEVICE_OBJECT *DeviceObject, + IN OUT struct _IRP *Irp); NTKERNELAPI PULONG NTAPI PoRegisterDeviceForIdleDetection( - IN struct _DEVICE_OBJECT *DeviceObject, - IN ULONG ConservationIdleTime, - IN ULONG PerformanceIdleTime, - IN DEVICE_POWER_STATE State); + IN struct _DEVICE_OBJECT *DeviceObject, + IN ULONG ConservationIdleTime, + IN ULONG PerformanceIdleTime, + IN DEVICE_POWER_STATE State); NTKERNELAPI PVOID @@ -13042,26 +9762,26 @@ NTKERNELAPI NTSTATUS NTAPI PoRequestPowerIrp( - IN struct _DEVICE_OBJECT *DeviceObject, - IN UCHAR MinorFunction, - IN POWER_STATE PowerState, - IN PREQUEST_POWER_COMPLETE CompletionFunction OPTIONAL, - IN PVOID Context OPTIONAL, - OUT struct _IRP **Irp OPTIONAL); + IN struct _DEVICE_OBJECT *DeviceObject, + IN UCHAR MinorFunction, + IN POWER_STATE PowerState, + IN PREQUEST_POWER_COMPLETE CompletionFunction OPTIONAL, + IN PVOID Context OPTIONAL, + OUT struct _IRP **Irp OPTIONAL); NTKERNELAPI POWER_STATE NTAPI PoSetPowerState( - IN struct _DEVICE_OBJECT *DeviceObject, - IN POWER_STATE_TYPE Type, - IN POWER_STATE State); + IN struct _DEVICE_OBJECT *DeviceObject, + IN POWER_STATE_TYPE Type, + IN POWER_STATE State); NTKERNELAPI VOID NTAPI PoSetSystemState( - IN EXECUTION_STATE Flags); + IN EXECUTION_STATE Flags); NTKERNELAPI VOID @@ -13116,15 +9836,16 @@ PoUnregisterPowerSettingCallback( #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ #if (NTDDI_VERSION >= NTDDI_VISTASP1) + NTKERNELAPI VOID NTAPI PoSetDeviceBusyEx( IN OUT PULONG IdlePointer); + #endif /* (NTDDI_VERSION >= NTDDI_VISTASP1) */ #if (NTDDI_VERSION >= NTDDI_WIN7) - NTKERNELAPI VOID NTAPI @@ -13189,64 +9910,19 @@ PoCreatePowerRequest( #define ExInitializeSListHead InitializeSListHead -#if defined(_NTHAL_) && defined(_X86_) - -NTKERNELAPI -VOID -FASTCALL -ExiAcquireFastMutex( - IN OUT PFAST_MUTEX FastMutex); - -NTKERNELAPI -VOID -FASTCALL -ExiReleaseFastMutex( - IN OUT PFAST_MUTEX FastMutex); - -NTKERNELAPI -BOOLEAN -FASTCALL -ExiTryToAcquireFastMutex( - IN OUT PFAST_MUTEX FastMutex); - +#if defined(_X86_) +#if defined(_NTHAL_) #define ExAcquireFastMutex ExiAcquireFastMutex #define ExReleaseFastMutex ExiReleaseFastMutex #define ExTryToAcquireFastMutex ExiTryToAcquireFastMutex - -#else - -#if (NTDDI_VERSION >= NTDDI_WIN2K) - -NTKERNELAPI -VOID -FASTCALL -ExAcquireFastMutex( - IN OUT PFAST_MUTEX FastMutex); - -NTKERNELAPI -VOID -FASTCALL -ExReleaseFastMutex( - IN OUT PFAST_MUTEX FastMutex); - -NTKERNELAPI -BOOLEAN -FASTCALL -ExTryToAcquireFastMutex( - IN OUT PFAST_MUTEX FastMutex); - -#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ - -#endif /* defined(_NTHAL_) && defined(_X86_) */ - -#if defined(_X86_) +#endif #define ExInterlockedAddUlong ExfInterlockedAddUlong #define ExInterlockedInsertHeadList ExfInterlockedInsertHeadList #define ExInterlockedInsertTailList ExfInterlockedInsertTailList #define ExInterlockedRemoveHeadList ExfInterlockedRemoveHeadList #define ExInterlockedPopEntryList ExfInterlockedPopEntryList #define ExInterlockedPushEntryList ExfInterlockedPushEntryList -#endif /* defined(_X86_) */ +#endif #if defined(_WIN64) @@ -13260,25 +9936,25 @@ FORCEINLINE USHORT ExQueryDepthSList(IN PSLIST_HEADER ListHead) { - return (USHORT)(ListHead->Alignment & 0xffff); + return (USHORT)(ListHead->Alignment & 0xffff); } #endif NTKERNELAPI PSLIST_ENTRY ExpInterlockedFlushSList( - PSLIST_HEADER ListHead); + PSLIST_HEADER ListHead); NTKERNELAPI PSLIST_ENTRY ExpInterlockedPopEntrySList( - PSLIST_HEADER ListHead); + PSLIST_HEADER ListHead); NTKERNELAPI PSLIST_ENTRY ExpInterlockedPushEntrySList( - PSLIST_HEADER ListHead, - PSLIST_ENTRY ListEntry); + PSLIST_HEADER ListHead, + PSLIST_ENTRY ListEntry); #define ExInterlockedFlushSList(Head) \ ExpInterlockedFlushSList(Head) @@ -13287,7 +9963,7 @@ ExpInterlockedPushEntrySList( #define ExInterlockedPushEntrySList(Head, Entry, Lock) \ ExpInterlockedPushEntrySList(Head, Entry) -#else /* !defined(_WIN64) */ +#else // !defined(_WIN64) #define ExQueryDepthSList(listhead) (listhead)->Depth @@ -13295,90 +9971,37 @@ NTKERNELAPI PSINGLE_LIST_ENTRY FASTCALL ExInterlockedFlushSList( - IN OUT PSLIST_HEADER ListHead); - -#endif /* !defined(_WIN64) */ + IN PSLIST_HEADER ListHead); #if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_) - NTKERNELAPI PSINGLE_LIST_ENTRY FASTCALL ExInterlockedPopEntrySList( - IN PSLIST_HEADER ListHead, - IN PKSPIN_LOCK Lock); + IN PSLIST_HEADER ListHead, + IN PKSPIN_LOCK Lock); NTKERNELAPI PSINGLE_LIST_ENTRY FASTCALL ExInterlockedPushEntrySList( - IN PSLIST_HEADER ListHead, - IN PSINGLE_LIST_ENTRY ListEntry, - IN PKSPIN_LOCK Lock); - -NTKERNELAPI -PVOID -NTAPI -ExAllocateFromPagedLookasideList( - IN OUT PPAGED_LOOKASIDE_LIST Lookaside); - -NTKERNELAPI -VOID -NTAPI -ExFreeToPagedLookasideList( - IN OUT PPAGED_LOOKASIDE_LIST Lookaside, - IN PVOID Entry); - -#else /* !_WIN2K_COMPAT_SLIST_USAGE */ - -#if !defined(_WIN64) + IN PSLIST_HEADER ListHead, + IN PSINGLE_LIST_ENTRY ListEntry, + IN PKSPIN_LOCK Lock); +#else #define ExInterlockedPopEntrySList(_ListHead, _Lock) \ InterlockedPopEntrySList(_ListHead) #define ExInterlockedPushEntrySList(_ListHead, _ListEntry, _Lock) \ InterlockedPushEntrySList(_ListHead, _ListEntry) -#endif - -static __inline -PVOID -ExAllocateFromPagedLookasideList( - IN OUT PPAGED_LOOKASIDE_LIST Lookaside) -{ - PVOID Entry; - - Lookaside->L.TotalAllocates++; - Entry = InterlockedPopEntrySList(&Lookaside->L.ListHead); - if (Entry == NULL) { - Lookaside->L.AllocateMisses++; - Entry = (Lookaside->L.Allocate)(Lookaside->L.Type, - Lookaside->L.Size, - Lookaside->L.Tag); - } - return Entry; -} - -static __inline -VOID -ExFreeToPagedLookasideList( - IN OUT PPAGED_LOOKASIDE_LIST Lookaside, - IN PVOID Entry) -{ - Lookaside->L.TotalFrees++; - if (ExQueryDepthSList(&Lookaside->L.ListHead) >= Lookaside->L.Depth) { - Lookaside->L.FreeMisses++; - (Lookaside->L.Free)(Entry); - } else { - InterlockedPushEntrySList(&Lookaside->L.ListHead, (PSLIST_ENTRY)Entry); - } -} - -#endif /* _WIN2K_COMPAT_SLIST_USAGE */ +#endif // _WIN2K_COMPAT_SLIST_USAGE +#endif // !defined(_WIN64) /* ERESOURCE_THREAD * ExGetCurrentResourceThread( * VOID); */ -#define ExGetCurrentResourceThread() ((ULONG_PTR)PsGetCurrentThread()) +#define ExGetCurrentResourceThread() ((ERESOURCE_THREAD)PsGetCurrentThread()) #define ExReleaseResource(R) (ExReleaseResourceLite(R)) @@ -13409,193 +10032,220 @@ ExInitializeFastMutex( #if (NTDDI_VERSION >= NTDDI_WIN2K) +NTKERNELAPI +VOID +FASTCALL +ExAcquireFastMutex( + IN OUT PFAST_MUTEX FastMutex); + +NTKERNELAPI +VOID +FASTCALL +ExReleaseFastMutex( + IN OUT PFAST_MUTEX FastMutex); + +NTKERNELAPI +BOOLEAN +FASTCALL +ExTryToAcquireFastMutex( + IN OUT PFAST_MUTEX FastMutex); + NTKERNELAPI VOID FASTCALL ExAcquireFastMutexUnsafe( - IN OUT PFAST_MUTEX FastMutex); + IN OUT PFAST_MUTEX FastMutex); NTKERNELAPI VOID FASTCALL ExReleaseFastMutexUnsafe( - IN OUT PFAST_MUTEX FastMutex); + IN OUT PFAST_MUTEX FastMutex); NTKERNELAPI BOOLEAN NTAPI ExAcquireResourceExclusiveLite( - IN OUT PERESOURCE Resource, - IN BOOLEAN Wait); + IN PERESOURCE Resource, + IN BOOLEAN Wait); NTKERNELAPI BOOLEAN NTAPI ExAcquireResourceSharedLite( - IN OUT PERESOURCE Resource, - IN BOOLEAN Wait); + IN PERESOURCE Resource, + IN BOOLEAN Wait); NTKERNELAPI BOOLEAN NTAPI ExAcquireSharedStarveExclusive( - IN OUT PERESOURCE Resource, - IN BOOLEAN Wait); + IN PERESOURCE Resource, + IN BOOLEAN Wait); NTKERNELAPI BOOLEAN NTAPI ExAcquireSharedWaitForExclusive( - IN OUT PERESOURCE Resource, - IN BOOLEAN Wait); + IN PERESOURCE Resource, + IN BOOLEAN Wait); NTKERNELAPI PVOID NTAPI ExAllocatePool( - IN POOL_TYPE PoolType, - IN SIZE_T NumberOfBytes); + IN POOL_TYPE PoolType, + IN SIZE_T NumberOfBytes); + +#ifdef POOL_TAGGING +#define ExAllocatePool(p,n) ExAllocatePoolWithTag(p,n,' kdD') +#endif /* POOL_TAGGING */ NTKERNELAPI PVOID NTAPI ExAllocatePoolWithQuota( - IN POOL_TYPE PoolType, - IN SIZE_T NumberOfBytes); + IN POOL_TYPE PoolType, + IN SIZE_T NumberOfBytes); + +#ifdef POOL_TAGGING +#define ExAllocatePoolWithQuota(p,n) ExAllocatePoolWithQuotaTag(p,n,' kdD') +#endif /* POOL_TAGGING */ NTKERNELAPI PVOID NTAPI ExAllocatePoolWithQuotaTag( - IN POOL_TYPE PoolType, - IN SIZE_T NumberOfBytes, - IN ULONG Tag); + IN POOL_TYPE PoolType, + IN SIZE_T NumberOfBytes, + IN ULONG Tag); #ifndef POOL_TAGGING #define ExAllocatePoolWithQuotaTag(a,b,c) ExAllocatePoolWithQuota(a,b) -#endif +#endif /* POOL_TAGGING */ NTKERNELAPI PVOID NTAPI ExAllocatePoolWithTag( - IN POOL_TYPE PoolType, - IN SIZE_T NumberOfBytes, - IN ULONG Tag); - -#ifndef POOL_TAGGING -#define ExAllocatePoolWithTag(a,b,c) ExAllocatePool(a,b) -#endif + IN POOL_TYPE PoolType, + IN SIZE_T NumberOfBytes, + IN ULONG Tag); NTKERNELAPI PVOID NTAPI ExAllocatePoolWithTagPriority( - IN POOL_TYPE PoolType, - IN SIZE_T NumberOfBytes, - IN ULONG Tag, - IN EX_POOL_PRIORITY Priority); + IN POOL_TYPE PoolType, + IN SIZE_T NumberOfBytes, + IN ULONG Tag, + IN EX_POOL_PRIORITY Priority); NTKERNELAPI VOID NTAPI ExConvertExclusiveToSharedLite( - IN OUT PERESOURCE Resource); + IN PERESOURCE Resource); NTKERNELAPI NTSTATUS NTAPI ExCreateCallback( - OUT PCALLBACK_OBJECT *CallbackObject, - IN POBJECT_ATTRIBUTES ObjectAttributes, - IN BOOLEAN Create, - IN BOOLEAN AllowMultipleCallbacks); + OUT PCALLBACK_OBJECT *CallbackObject, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN BOOLEAN Create, + IN BOOLEAN AllowMultipleCallbacks); NTKERNELAPI VOID NTAPI ExDeleteNPagedLookasideList( - IN OUT PNPAGED_LOOKASIDE_LIST Lookaside); + IN PNPAGED_LOOKASIDE_LIST Lookaside); NTKERNELAPI VOID NTAPI ExDeletePagedLookasideList( - IN PPAGED_LOOKASIDE_LIST Lookaside); + IN PPAGED_LOOKASIDE_LIST Lookaside); NTKERNELAPI NTSTATUS NTAPI ExDeleteResourceLite( - IN OUT PERESOURCE Resource); + IN PERESOURCE Resource); NTKERNELAPI VOID NTAPI ExFreePool( - IN PVOID P); + IN PVOID P); + +#ifdef POOL_TAGGING +#define ExFreePool(P) ExFreePoolWithTag(P, 0) +#endif NTKERNELAPI VOID NTAPI ExFreePoolWithTag( - IN PVOID P, - IN ULONG Tag); + IN PVOID P, + IN ULONG Tag); NTKERNELAPI ULONG NTAPI ExGetExclusiveWaiterCount( - IN PERESOURCE Resource); + IN PERESOURCE Resource); NTKERNELAPI KPROCESSOR_MODE NTAPI -ExGetPreviousMode(VOID); +ExGetPreviousMode( + VOID); NTKERNELAPI ULONG NTAPI ExGetSharedWaiterCount( - IN PERESOURCE Resource); + IN PERESOURCE Resource); NTKERNELAPI VOID NTAPI ExInitializeNPagedLookasideList( - IN PNPAGED_LOOKASIDE_LIST Lookaside, - IN PALLOCATE_FUNCTION Allocate OPTIONAL, - IN PFREE_FUNCTION Free OPTIONAL, - IN ULONG Flags, - IN SIZE_T Size, - IN ULONG Tag, - IN USHORT Depth); + IN PNPAGED_LOOKASIDE_LIST Lookaside, + IN PALLOCATE_FUNCTION Allocate OPTIONAL, + IN PFREE_FUNCTION Free OPTIONAL, + IN ULONG Flags, + IN SIZE_T Size, + IN ULONG Tag, + IN USHORT Depth); NTKERNELAPI VOID NTAPI ExInitializePagedLookasideList( - IN PPAGED_LOOKASIDE_LIST Lookaside, - IN PALLOCATE_FUNCTION Allocate OPTIONAL, - IN PFREE_FUNCTION Free OPTIONAL, - IN ULONG Flags, - IN SIZE_T Size, - IN ULONG Tag, - IN USHORT Depth); + IN PPAGED_LOOKASIDE_LIST Lookaside, + IN PALLOCATE_FUNCTION Allocate OPTIONAL, + IN PFREE_FUNCTION Free OPTIONAL, + IN ULONG Flags, + IN SIZE_T Size, + IN ULONG Tag, + IN USHORT Depth); NTKERNELAPI NTSTATUS NTAPI ExInitializeResourceLite( - OUT PERESOURCE Resource); + IN PERESOURCE Resource); NTKERNELAPI LARGE_INTEGER NTAPI ExInterlockedAddLargeInteger( - IN PLARGE_INTEGER Addend, - IN LARGE_INTEGER Increment, - IN PKSPIN_LOCK Lock); + IN PLARGE_INTEGER Addend, + IN LARGE_INTEGER Increment, + IN PKSPIN_LOCK Lock); #if defined(_WIN64) #define ExInterlockedAddLargeStatistic(Addend, Increment) \ @@ -13609,96 +10259,89 @@ NTKERNELAPI ULONG FASTCALL ExInterlockedAddUlong( - IN PULONG Addend, - IN ULONG Increment, - IN OUT PKSPIN_LOCK Lock); + IN PULONG Addend, + IN ULONG Increment, + PKSPIN_LOCK Lock); #if defined(_AMD64_) || defined(_IA64_) - #define ExInterlockedCompareExchange64(Destination, Exchange, Comperand, Lock) \ InterlockedCompareExchange64(Destination, *(Exchange), *(Comperand)) - #elif defined(_X86_) - NTKERNELAPI LONGLONG FASTCALL ExfInterlockedCompareExchange64( - IN OUT LONGLONG volatile *Destination, - IN PLONGLONG Exchange, - IN PLONGLONG Comperand); - + IN OUT LONGLONG volatile *Destination, + IN PLONGLONG Exchange, + IN PLONGLONG Comperand); #define ExInterlockedCompareExchange64(Destination, Exchange, Comperand, Lock) \ ExfInterlockedCompareExchange64(Destination, Exchange, Comperand) - #else - NTKERNELAPI LONGLONG FASTCALL ExInterlockedCompareExchange64( - IN OUT LONGLONG volatile *Destination, - IN PLONGLONG Exchange, - IN PLONGLONG Comparand, - IN PKSPIN_LOCK Lock); - -#endif /* defined(_AMD64_) || defined(_IA64_) */ + IN OUT LONGLONG volatile *Destination, + IN PLONGLONG Exchange, + IN PLONGLONG Comparand, + IN PKSPIN_LOCK Lock); +#endif NTKERNELAPI PLIST_ENTRY FASTCALL ExInterlockedInsertHeadList( - IN OUT PLIST_ENTRY ListHead, - IN OUT PLIST_ENTRY ListEntry, - IN OUT PKSPIN_LOCK Lock); + IN PLIST_ENTRY ListHead, + IN PLIST_ENTRY ListEntry, + IN PKSPIN_LOCK Lock); NTKERNELAPI PLIST_ENTRY FASTCALL ExInterlockedInsertTailList( - IN OUT PLIST_ENTRY ListHead, - IN OUT PLIST_ENTRY ListEntry, - IN OUT PKSPIN_LOCK Lock); + IN PLIST_ENTRY ListHead, + IN PLIST_ENTRY ListEntry, + IN PKSPIN_LOCK Lock); NTKERNELAPI PSINGLE_LIST_ENTRY FASTCALL ExInterlockedPopEntryList( - IN OUT PSINGLE_LIST_ENTRY ListHead, - IN OUT PKSPIN_LOCK Lock); + IN PSINGLE_LIST_ENTRY ListHead, + IN PKSPIN_LOCK Lock); NTKERNELAPI PSINGLE_LIST_ENTRY FASTCALL ExInterlockedPushEntryList( - IN OUT PSINGLE_LIST_ENTRY ListHead, - IN OUT PSINGLE_LIST_ENTRY ListEntry, - IN OUT PKSPIN_LOCK Lock); + IN PSINGLE_LIST_ENTRY ListHead, + IN PSINGLE_LIST_ENTRY ListEntry, + IN PKSPIN_LOCK Lock); NTKERNELAPI PLIST_ENTRY FASTCALL ExInterlockedRemoveHeadList( - IN OUT PLIST_ENTRY ListHead, - IN OUT PKSPIN_LOCK Lock); + IN PLIST_ENTRY ListHead, + IN PKSPIN_LOCK Lock); NTKERNELAPI BOOLEAN NTAPI ExIsProcessorFeaturePresent( - IN ULONG ProcessorFeature); + IN ULONG ProcessorFeature); NTKERNELAPI BOOLEAN NTAPI ExIsResourceAcquiredExclusiveLite( - IN PERESOURCE Resource); + IN PERESOURCE Resource); NTKERNELAPI ULONG NTAPI ExIsResourceAcquiredSharedLite( - IN PERESOURCE Resource); + IN PERESOURCE Resource); #define ExIsResourceAcquiredLite ExIsResourceAcquiredSharedLite @@ -13706,368 +10349,243 @@ NTKERNELAPI VOID NTAPI ExLocalTimeToSystemTime( - IN PLARGE_INTEGER LocalTime, - OUT PLARGE_INTEGER SystemTime); + IN PLARGE_INTEGER LocalTime, + OUT PLARGE_INTEGER SystemTime); NTKERNELAPI VOID NTAPI ExNotifyCallback( - IN PCALLBACK_OBJECT CallbackObject, - IN PVOID Argument1 OPTIONAL, - IN PVOID Argument2 OPTIONAL); + IN PCALLBACK_OBJECT CallbackObject, + IN PVOID Argument1, + IN PVOID Argument2); NTKERNELAPI VOID NTAPI ExQueueWorkItem( - IN OUT PWORK_QUEUE_ITEM WorkItem, - IN WORK_QUEUE_TYPE QueueType); + IN PWORK_QUEUE_ITEM WorkItem, + IN WORK_QUEUE_TYPE QueueType); NTKERNELAPI DECLSPEC_NORETURN VOID NTAPI ExRaiseStatus( - IN NTSTATUS Status); + IN NTSTATUS Status); NTKERNELAPI PVOID NTAPI ExRegisterCallback( - IN PCALLBACK_OBJECT CallbackObject, - IN PCALLBACK_FUNCTION CallbackFunction, - IN PVOID CallbackContext OPTIONAL); + IN PCALLBACK_OBJECT CallbackObject, + IN PCALLBACK_FUNCTION CallbackFunction, + IN PVOID CallbackContext); NTKERNELAPI NTSTATUS NTAPI ExReinitializeResourceLite( - IN OUT PERESOURCE Resource); + IN PERESOURCE Resource); NTKERNELAPI VOID NTAPI ExReleaseResourceForThreadLite( - IN OUT PERESOURCE Resource, - IN ERESOURCE_THREAD ResourceThreadId); + IN PERESOURCE Resource, + IN ERESOURCE_THREAD ResourceThreadId); NTKERNELAPI VOID FASTCALL ExReleaseResourceLite( - IN OUT PERESOURCE Resource); + IN PERESOURCE Resource); NTKERNELAPI VOID NTAPI ExSetResourceOwnerPointer( - IN OUT PERESOURCE Resource, - IN PVOID OwnerPointer); + IN PERESOURCE Resource, + IN PVOID OwnerPointer); NTKERNELAPI ULONG NTAPI ExSetTimerResolution( - IN ULONG DesiredTime, - IN BOOLEAN SetResolution); + IN ULONG DesiredTime, + IN BOOLEAN SetResolution); NTKERNELAPI VOID NTAPI ExSystemTimeToLocalTime( - IN PLARGE_INTEGER SystemTime, - OUT PLARGE_INTEGER LocalTime); + IN PLARGE_INTEGER SystemTime, + OUT PLARGE_INTEGER LocalTime); NTKERNELAPI VOID NTAPI ExUnregisterCallback( - IN OUT PVOID CbRegistration); + IN PVOID CbRegistration); -#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ + +#endif // (NTDDI_VERSION >= NTDDI_WIN2K) #if (NTDDI_VERSION >= NTDDI_WINXP) - NTKERNELAPI BOOLEAN FASTCALL ExAcquireRundownProtection( - IN OUT PEX_RUNDOWN_REF RunRef); + IN OUT PEX_RUNDOWN_REF RunRef); NTKERNELAPI VOID FASTCALL ExInitializeRundownProtection( - OUT PEX_RUNDOWN_REF RunRef); + OUT PEX_RUNDOWN_REF RunRef); NTKERNELAPI VOID FASTCALL ExReInitializeRundownProtection( - IN OUT PEX_RUNDOWN_REF RunRef); + OUT PEX_RUNDOWN_REF RunRef); NTKERNELAPI VOID FASTCALL ExReleaseRundownProtection( - IN OUT PEX_RUNDOWN_REF RunRef); + IN OUT PEX_RUNDOWN_REF RunRef); NTKERNELAPI VOID FASTCALL ExRundownCompleted( - OUT PEX_RUNDOWN_REF RunRef); + OUT PEX_RUNDOWN_REF RunRef); NTKERNELAPI BOOLEAN NTAPI ExVerifySuite( - IN SUITE_TYPE SuiteType); + IN SUITE_TYPE SuiteType); NTKERNELAPI VOID FASTCALL ExWaitForRundownProtectionRelease( - IN OUT PEX_RUNDOWN_REF RunRef); + IN OUT PEX_RUNDOWN_REF RunRef); -#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ +#endif // (NTDDI_VERSION >= NTDDI_WINXP) #if (NTDDI_VERSION >= NTDDI_WINXPSP2) - NTKERNELAPI BOOLEAN FASTCALL ExAcquireRundownProtectionEx( - IN OUT PEX_RUNDOWN_REF RunRef, - IN ULONG Count); + IN OUT PEX_RUNDOWN_REF RunRef, + IN ULONG Count); NTKERNELAPI VOID FASTCALL ExReleaseRundownProtectionEx( - IN OUT PEX_RUNDOWN_REF RunRef, - IN ULONG Count); - -#endif /* (NTDDI_VERSION >= NTDDI_WINXPSP2) */ + IN OUT PEX_RUNDOWN_REF RunRef, + IN ULONG Count); +#endif // (NTDDI_VERSION >= NTDDI_WINXPSP2) #if (NTDDI_VERSION >= NTDDI_WS03SP1) - NTKERNELAPI PEX_RUNDOWN_REF_CACHE_AWARE NTAPI ExAllocateCacheAwareRundownProtection( - IN POOL_TYPE PoolType, - IN ULONG PoolTag); + IN POOL_TYPE PoolType, + IN ULONG PoolTag); NTKERNELAPI SIZE_T NTAPI ExSizeOfRundownProtectionCacheAware(VOID); - -NTKERNELAPI -PVOID -NTAPI -ExEnterCriticalRegionAndAcquireResourceShared( - IN OUT PERESOURCE Resource); - -NTKERNELAPI -PVOID -NTAPI -ExEnterCriticalRegionAndAcquireResourceExclusive( - IN OUT PERESOURCE Resource); - -NTKERNELAPI -PVOID -NTAPI -ExEnterCriticalRegionAndAcquireSharedWaitForExclusive( - IN OUT PERESOURCE Resource); - -NTKERNELAPI -VOID -FASTCALL -ExReleaseResourceAndLeaveCriticalRegion( - IN OUT PERESOURCE Resource); - -NTKERNELAPI -VOID -NTAPI -ExInitializeRundownProtectionCacheAware( - OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware, - IN SIZE_T RunRefSize); - -NTKERNELAPI -VOID -NTAPI -ExFreeCacheAwareRundownProtection( - IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware); - -NTKERNELAPI -BOOLEAN -FASTCALL -ExAcquireRundownProtectionCacheAware( - IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware); - -NTKERNELAPI -VOID -FASTCALL -ExReleaseRundownProtectionCacheAware( - IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware); - -NTKERNELAPI -BOOLEAN -FASTCALL -ExAcquireRundownProtectionCacheAwareEx( - IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware, - IN ULONG Count); - -NTKERNELAPI -VOID -FASTCALL -ExReleaseRundownProtectionCacheAwareEx( - IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRef, - IN ULONG Count); - -NTKERNELAPI -VOID -FASTCALL -ExWaitForRundownProtectionReleaseCacheAware( - IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRef); - -NTKERNELAPI -VOID -FASTCALL -ExReInitializeRundownProtectionCacheAware( - IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware); - -NTKERNELAPI -VOID -FASTCALL -ExRundownCompletedCacheAware( - IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware); - -#endif /* (NTDDI_VERSION >= NTDDI_WS03SP1) */ +#endif // (NTDDI_VERSION >= NTDDI_WS03SP1) #if (NTDDI_VERSION >= NTDDI_VISTA) - NTKERNELAPI NTSTATUS NTAPI ExInitializeLookasideListEx( - OUT PLOOKASIDE_LIST_EX Lookaside, - IN PALLOCATE_FUNCTION_EX Allocate OPTIONAL, - IN PFREE_FUNCTION_EX Free OPTIONAL, - IN POOL_TYPE PoolType, - IN ULONG Flags, - IN SIZE_T Size, - IN ULONG Tag, - IN USHORT Depth); + OUT PLOOKASIDE_LIST_EX Lookaside, + IN PALLOCATE_FUNCTION_EX Allocate OPTIONAL, + IN PFREE_FUNCTION_EX Free OPTIONAL, + IN POOL_TYPE PoolType, + IN ULONG Flags, + IN SIZE_T Size, + IN ULONG Tag, + IN USHORT Depth); +#endif -NTKERNELAPI -VOID -NTAPI -ExDeleteLookasideListEx( - IN OUT PLOOKASIDE_LIST_EX Lookaside); - -NTKERNELAPI -VOID -NTAPI -ExFlushLookasideListEx( - IN OUT PLOOKASIDE_LIST_EX Lookaside); - -FORCEINLINE -PVOID -ExAllocateFromLookasideListEx( - IN OUT PLOOKASIDE_LIST_EX Lookaside) -{ - PVOID Entry; - - Lookaside->L.TotalAllocates += 1; - Entry = InterlockedPopEntrySList(&Lookaside->L.ListHead); - if (Entry == NULL) { - Lookaside->L.AllocateMisses += 1; - Entry = (Lookaside->L.AllocateEx)(Lookaside->L.Type, - Lookaside->L.Size, - Lookaside->L.Tag, - Lookaside); - } - return Entry; -} - -FORCEINLINE -VOID -ExFreeToLookasideListEx( - IN OUT PLOOKASIDE_LIST_EX Lookaside, - IN PVOID Entry) -{ - Lookaside->L.TotalFrees += 1; - if (ExQueryDepthSList(&Lookaside->L.ListHead) >= Lookaside->L.Depth) { - Lookaside->L.FreeMisses += 1; - (Lookaside->L.FreeEx)(Entry, Lookaside); - } else { - InterlockedPushEntrySList(&Lookaside->L.ListHead, (PSLIST_ENTRY)Entry); - } - return; -} - -#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ - -#if (NTDDI_VERSION >= NTDDI_WIN7) - -NTKERNELAPI -VOID -NTAPI -ExSetResourceOwnerPointerEx( - IN OUT PERESOURCE Resource, - IN PVOID OwnerPointer, - IN ULONG Flags); - -#define FLAG_OWNER_POINTER_IS_THREAD 0x1 - -#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ +#if !defined(MIDL_PASS) static __inline PVOID ExAllocateFromNPagedLookasideList( - IN OUT PNPAGED_LOOKASIDE_LIST Lookaside) + IN PNPAGED_LOOKASIDE_LIST Lookaside) { - PVOID Entry; + PVOID Entry; - Lookaside->L.TotalAllocates++; -#if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_) - Entry = ExInterlockedPopEntrySList(&Lookaside->L.ListHead, - &Lookaside->Lock__ObsoleteButDoNotDelete); -#else - Entry = InterlockedPopEntrySList(&Lookaside->L.ListHead); -#endif - if (Entry == NULL) { - Lookaside->L.AllocateMisses++; - Entry = (Lookaside->L.Allocate)(Lookaside->L.Type, - Lookaside->L.Size, - Lookaside->L.Tag); - } - return Entry; + Lookaside->L.TotalAllocates++; + Entry = InterlockedPopEntrySList(&Lookaside->L.ListHead); + if (Entry == NULL) { + Lookaside->L.AllocateMisses++; + Entry = (Lookaside->L.Allocate)(Lookaside->L.Type, + Lookaside->L.Size, + Lookaside->L.Tag); + } + return Entry; +} + +static __inline PVOID +ExAllocateFromPagedLookasideList( + IN PPAGED_LOOKASIDE_LIST Lookaside) +{ + PVOID Entry; + + Lookaside->L.TotalAllocates++; + Entry = InterlockedPopEntrySList(&Lookaside->L.ListHead); + if (Entry == NULL) { + Lookaside->L.AllocateMisses++; + Entry = (Lookaside->L.Allocate)(Lookaside->L.Type, + Lookaside->L.Size, + Lookaside->L.Tag); + } + return Entry; } static __inline VOID ExFreeToNPagedLookasideList( - IN OUT PNPAGED_LOOKASIDE_LIST Lookaside, - IN PVOID Entry) + IN PNPAGED_LOOKASIDE_LIST Lookaside, + IN PVOID Entry) { - Lookaside->L.TotalFrees++; - if (ExQueryDepthSList(&Lookaside->L.ListHead) >= Lookaside->L.Depth) { - Lookaside->L.FreeMisses++; - (Lookaside->L.Free)(Entry); - } else { -#if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_) - ExInterlockedPushEntrySList(&Lookaside->L.ListHead, - (PSLIST_ENTRY)Entry, - &Lookaside->Lock__ObsoleteButDoNotDelete); -#else - InterlockedPushEntrySList(&Lookaside->L.ListHead, (PSLIST_ENTRY)Entry); -#endif - } + Lookaside->L.TotalFrees++; + if (ExQueryDepthSList(&Lookaside->L.ListHead) >= Lookaside->L.Depth) { + Lookaside->L.FreeMisses++; + (Lookaside->L.Free)(Entry); + } else { + InterlockedPushEntrySList(&Lookaside->L.ListHead, (PSLIST_ENTRY)Entry); + } } +static __inline VOID +ExFreeToPagedLookasideList( + IN PPAGED_LOOKASIDE_LIST Lookaside, + IN PVOID Entry) +{ + Lookaside->L.TotalFrees++; + if (ExQueryDepthSList(&Lookaside->L.ListHead) >= Lookaside->L.Depth) { + Lookaside->L.FreeMisses++; + (Lookaside->L.Free)(Entry); + } else { + InterlockedPushEntrySList(&Lookaside->L.ListHead, (PSLIST_ENTRY)Entry); + } +} + +#endif // !defined(MIDL_PASS) /****************************************************************************** * Object Manager Functions * @@ -14112,7 +10630,7 @@ NTKERNELAPI NTSTATUS NTAPI ObReferenceObjectByPointer( - IN PVOID Object, + IN PVOID Object, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType OPTIONAL, IN KPROCESSOR_MODE AccessMode); @@ -14126,99 +10644,10 @@ ObReleaseObjectSecurity( #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ -#if (NTDDI_VERSION >= NTDDI_VISTA) -NTKERNELAPI -VOID -NTAPI -ObDereferenceObjectDeferDelete( - IN PVOID Object); -#endif - -#if (NTDDI_VERSION >= NTDDI_VISTASP1) -NTKERNELAPI -NTSTATUS -NTAPI -ObRegisterCallbacks( - IN POB_CALLBACK_REGISTRATION CallbackRegistration, - OUT PVOID *RegistrationHandle); - -NTKERNELAPI -VOID -NTAPI -ObUnRegisterCallbacks( - IN PVOID RegistrationHandle); - -NTKERNELAPI -USHORT -NTAPI -ObGetFilterVersion(VOID); - -#endif /* (NTDDI_VERSION >= NTDDI_VISTASP1) */ - -#if (NTDDI_VERSION >= NTDDI_WIN7) - -NTKERNELAPI -NTSTATUS -NTAPI -ObReferenceObjectByHandleWithTag( - IN HANDLE Handle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_TYPE ObjectType OPTIONAL, - IN KPROCESSOR_MODE AccessMode, - IN ULONG Tag, - OUT PVOID *Object, - OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL); - -NTKERNELAPI -LONG_PTR -FASTCALL -ObfReferenceObjectWithTag( - IN PVOID Object, - IN ULONG Tag); - -NTKERNELAPI -NTSTATUS -NTAPI -ObReferenceObjectByPointerWithTag( - IN PVOID Object, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_TYPE ObjectType OPTIONAL, - IN KPROCESSOR_MODE AccessMode, - IN ULONG Tag); - -NTKERNELAPI -LONG_PTR -FASTCALL -ObfDereferenceObjectWithTag( - IN PVOID Object, - IN ULONG Tag); - -NTKERNELAPI -VOID -NTAPI -ObDereferenceObjectDeferDeleteWithTag( - IN PVOID Object, - IN ULONG Tag); - -#define ObDereferenceObject ObfDereferenceObject -#define ObReferenceObject ObfReferenceObject -#define ObDereferenceObjectWithTag ObfDereferenceObjectWithTag -#define ObReferenceObjectWithTag ObfReferenceObjectWithTag - -#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ - - /****************************************************************************** * Process Manager Functions * ******************************************************************************/ -NTKERNELAPI -NTSTATUS -NTAPI -PsWrapApcWow64Thread( - IN OUT PVOID *ApcContext, - IN OUT PVOID *ApcRoutine); - /* * PEPROCESS * PsGetCurrentProcess(VOID) @@ -14226,16 +10655,19 @@ PsWrapApcWow64Thread( #define PsGetCurrentProcess IoGetCurrentProcess #if !defined(_PSGETCURRENTTHREAD_) + #define _PSGETCURRENTTHREAD_ + FORCEINLINE PETHREAD NTAPI -PsGetCurrentThread(VOID) +PsGetCurrentThread ( + VOID) { return (PETHREAD)KeGetCurrentThread(); } -#endif /* !_PSGETCURRENTTHREAD_ */ +#endif #if (NTDDI_VERSION >= NTDDI_WIN2K) @@ -14243,40 +10675,41 @@ NTKERNELAPI NTSTATUS NTAPI PsCreateSystemThread( - OUT PHANDLE ThreadHandle, - IN ULONG DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, - IN HANDLE ProcessHandle OPTIONAL, - OUT PCLIENT_ID ClientId OPTIONAL, - IN PKSTART_ROUTINE StartRoutine, - IN PVOID StartContext OPTIONAL); + OUT PHANDLE ThreadHandle, + IN ULONG DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, + IN HANDLE ProcessHandle OPTIONAL, + OUT PCLIENT_ID ClientId OPTIONAL, + IN PKSTART_ROUTINE StartRoutine, + IN PVOID StartContext OPTIONAL); NTKERNELAPI NTSTATUS NTAPI PsTerminateSystemThread( - IN NTSTATUS ExitStatus); + IN NTSTATUS ExitStatus); - -#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ +#endif /****************************************************************************** * WMI Library Support Functions * ******************************************************************************/ #ifdef RUN_WPP + #if (NTDDI_VERSION >= NTDDI_WINXP) NTKERNELAPI NTSTATUS -__cdecl +DDKCDECLAPI WmiTraceMessage( - IN TRACEHANDLE LoggerHandle, - IN ULONG MessageFlags, - IN LPGUID MessageGuid, - IN USHORT MessageNumber, + IN TRACEHANDLE LoggerHandle, + IN ULONG MessageFlags, + IN LPGUID MessageGuid, + IN USHORT MessageNumber, IN ...); #endif -#endif /* RUN_WPP */ + +#endif #if (NTDDI_VERSION >= NTDDI_WINXP) @@ -14284,167 +10717,82 @@ NTKERNELAPI NTSTATUS NTAPI WmiQueryTraceInformation( - IN TRACE_INFORMATION_CLASS TraceInformationClass, - OUT PVOID TraceInformation, - IN ULONG TraceInformationLength, - OUT PULONG RequiredLength OPTIONAL, - IN PVOID Buffer OPTIONAL); + IN TRACE_INFORMATION_CLASS TraceInformationClass, + OUT PVOID TraceInformation, + IN ULONG TraceInformationLength, + OUT PULONG RequiredLength OPTIONAL, + IN PVOID Buffer OPTIONAL); #if 0 /* FIXME: Get va_list from where? */ NTKERNELAPI NTSTATUS -__cdecl +DDKCDECLAPI WmiTraceMessageVa( - IN TRACEHANDLE LoggerHandle, - IN ULONG MessageFlags, - IN LPGUID MessageGuid, - IN USHORT MessageNumber, - IN va_list MessageArgList); + IN TRACEHANDLE LoggerHandle, + IN ULONG MessageFlags, + IN LPGUID MessageGuid, + IN USHORT MessageNumber, + IN va_list MessageArgList); #endif -#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ - -#ifndef TRACE_INFORMATION_CLASS_DEFINE - -#if (NTDDI_VERSION >= NTDDI_WINXP) -NTKERNELAPI -NTSTATUS -NTAPI -WmiQueryTraceInformation( - IN TRACE_INFORMATION_CLASS TraceInformationClass, - OUT PVOID TraceInformation, - IN ULONG TraceInformationLength, - OUT PULONG RequiredLength OPTIONAL, - IN PVOID Buffer OPTIONAL); #endif -#define TRACE_INFORMATION_CLASS_DEFINE - -#endif /* TRACE_INFOPRMATION_CLASS_DEFINE */ - -#if (NTDDI_VERSION >= NTDDI_VISTA) - -NTSTATUS -NTKERNELAPI -NTAPI -EtwRegister( - IN LPCGUID ProviderId, - IN PETWENABLECALLBACK EnableCallback OPTIONAL, - IN PVOID CallbackContext OPTIONAL, - OUT PREGHANDLE RegHandle); - -NTSTATUS -NTKERNELAPI -NTAPI -EtwUnregister( - IN REGHANDLE RegHandle); - -BOOLEAN -NTKERNELAPI -NTAPI -EtwEventEnabled( - IN REGHANDLE RegHandle, - IN PCEVENT_DESCRIPTOR EventDescriptor); - -BOOLEAN -NTKERNELAPI -NTAPI -EtwProviderEnabled( - IN REGHANDLE RegHandle, - IN UCHAR Level, - IN ULONGLONG Keyword); - -NTSTATUS -NTKERNELAPI -NTAPI -EtwActivityIdControl( - IN ULONG ControlCode, - IN OUT LPGUID ActivityId); - -NTSTATUS -NTKERNELAPI -NTAPI -EtwWrite( - IN REGHANDLE RegHandle, - IN PCEVENT_DESCRIPTOR EventDescriptor, - IN LPCGUID ActivityId OPTIONAL, - IN ULONG UserDataCount, - IN PEVENT_DATA_DESCRIPTOR UserData OPTIONAL); - -NTSTATUS -NTKERNELAPI -NTAPI -EtwWriteTransfer( - IN REGHANDLE RegHandle, - IN PCEVENT_DESCRIPTOR EventDescriptor, - IN LPCGUID ActivityId OPTIONAL, - IN LPCGUID RelatedActivityId OPTIONAL, - IN ULONG UserDataCount, - IN PEVENT_DATA_DESCRIPTOR UserData OPTIONAL); - -NTSTATUS -NTKERNELAPI -NTAPI -EtwWriteString( - IN REGHANDLE RegHandle, - IN UCHAR Level, - IN ULONGLONG Keyword, - IN LPCGUID ActivityId OPTIONAL, - IN PCWSTR String); - -#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ - -#if (NTDDI_VERSION >= NTDDI_WIN7) -NTSTATUS -NTKERNELAPI -NTAPI -EtwWriteEx( - IN REGHANDLE RegHandle, - IN PCEVENT_DESCRIPTOR EventDescriptor, - IN ULONG64 Filter, - IN ULONG Flags, - IN LPCGUID ActivityId OPTIONAL, - IN LPCGUID RelatedActivityId OPTIONAL, - IN ULONG UserDataCount, - IN PEVENT_DATA_DESCRIPTOR UserData OPTIONAL); -#endif - - - /****************************************************************************** * Kernel Debugger Functions * ******************************************************************************/ #ifndef _DBGNT_ - ULONG -__cdecl +DDKCDECLAPI DbgPrint( - IN PCSTR Format, - IN ...); - -#if (NTDDI_VERSION >= NTDDI_WIN2K) -NTSYSAPI -ULONG -__cdecl -DbgPrintReturnControlC( - IN PCCH Format, + IN PCSTR Format, IN ...); #endif -#if (NTDDI_VERSION >= NTDDI_WINXP) +#if DBG -NTSYSAPI -ULONG -__cdecl -DbgPrintEx( - IN ULONG ComponentId, - IN ULONG Level, - IN PCSTR Format, - IN ...); +#define KdPrint(_x_) DbgPrint _x_ +#define KdPrintEx(_x_) DbgPrintEx _x_ +#define vKdPrintExWithPrefix(_x_) vDbgPrintExWithPrefix _x_ +#define KdBreakPoint() DbgBreakPoint() +#define KdBreakPointWithStatus(s) DbgBreakPointWithStatus(s) + +#else /* !DBG */ + +#define KdPrint(_x_) +#define KdPrintEx(_x_) +#define vKdPrintExWithPrefix(_x_) +#define KdBreakPoint() +#define KdBreakPointWithStatus(s) + +#endif /* !DBG */ + +#if defined(__GNUC__) + +extern NTKERNELAPI BOOLEAN KdDebuggerNotPresent; +extern NTKERNELAPI BOOLEAN KdDebuggerEnabled; +#define KD_DEBUGGER_ENABLED KdDebuggerEnabled +#define KD_DEBUGGER_NOT_PRESENT KdDebuggerNotPresent + +#elif defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_) || defined(_WDMDDK_) || defined(_NTOSP_) + +extern NTKERNELAPI PBOOLEAN KdDebuggerNotPresent; +extern NTKERNELAPI PBOOLEAN KdDebuggerEnabled; +#define KD_DEBUGGER_ENABLED *KdDebuggerEnabled +#define KD_DEBUGGER_NOT_PRESENT *KdDebuggerNotPresent + +#else + +extern BOOLEAN KdDebuggerNotPresent; +extern BOOLEAN KdDebuggerEnabled; +#define KD_DEBUGGER_ENABLED KdDebuggerEnabled +#define KD_DEBUGGER_NOT_PRESENT KdDebuggerNotPresent + +#endif #ifdef _VA_LIST_DEFINED +#if (NTDDI_VERSION >= NTDDI_WINXP) NTSYSAPI ULONG @@ -14465,120 +10813,84 @@ vDbgPrintExWithPrefix( IN PCCH Format, IN va_list ap); -#endif /* _VA_LIST_DEFINED */ - -NTSYSAPI -NTSTATUS -NTAPI -DbgQueryDebugFilterState( - IN ULONG ComponentId, - IN ULONG Level); - -NTSYSAPI -NTSTATUS -NTAPI -DbgSetDebugFilterState( - IN ULONG ComponentId, - IN ULONG Level, - IN BOOLEAN State); - -#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ - -#if (NTDDI_VERSION >= NTDDI_VISTA) - -typedef VOID -(*PDEBUG_PRINT_CALLBACK)( - IN PSTRING Output, - IN ULONG ComponentId, - IN ULONG Level); - -NTSYSAPI -NTSTATUS -NTAPI -DbgSetDebugPrintCallback( - IN PDEBUG_PRINT_CALLBACK DebugPrintCallback, - IN BOOLEAN Enable); - -#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ - -#endif /* _DBGNT_ */ - -#if DBG - -#define KdPrint(_x_) DbgPrint _x_ -#define KdPrintEx(_x_) DbgPrintEx _x_ -#define vKdPrintEx(_x_) vDbgPrintEx _x_ -#define vKdPrintExWithPrefix(_x_) vDbgPrintExWithPrefix _x_ -#define KdBreakPoint() DbgBreakPoint() -#define KdBreakPointWithStatus(s) DbgBreakPointWithStatus(s) - -#else /* !DBG */ - -#define KdPrint(_x_) -#define KdPrintEx(_x_) -#define vKdPrintEx(_x_) -#define vKdPrintExWithPrefix(_x_) -#define KdBreakPoint() -#define KdBreakPointWithStatus(s) - -#endif /* !DBG */ - -#if defined(__GNUC__) - -extern NTKERNELAPI BOOLEAN KdDebuggerNotPresent; -extern NTKERNELAPI BOOLEAN KdDebuggerEnabled; -#define KD_DEBUGGER_ENABLED KdDebuggerEnabled -#define KD_DEBUGGER_NOT_PRESENT KdDebuggerNotPresent - -#elif defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_) || defined(_WDMDDK_) || defined(_NTOSP_) - -extern NTKERNELAPI PBOOLEAN KdDebuggerNotPresent; -extern NTKERNELAPI PBOOLEAN KdDebuggerEnabled; -#define KD_DEBUGGER_ENABLED *KdDebuggerEnabled -#define KD_DEBUGGER_NOT_PRESENT *KdDebuggerNotPresent - -#else - -extern BOOLEAN KdDebuggerNotPresent; -extern BOOLEAN KdDebuggerEnabled; -#define KD_DEBUGGER_ENABLED KdDebuggerEnabled -#define KD_DEBUGGER_NOT_PRESENT KdDebuggerNotPresent - #endif +#endif // _VA_LIST_DEFINED #if (NTDDI_VERSION >= NTDDI_WIN2K) NTKERNELAPI NTSTATUS NTAPI -KdDisableDebugger(VOID); +KdDisableDebugger( + VOID); NTKERNELAPI NTSTATUS NTAPI -KdEnableDebugger(VOID); +KdEnableDebugger( + VOID); #if (_MSC_FULL_VER >= 150030729) && !defined(IMPORT_NATIVE_DBG_BREAK) #define DbgBreakPoint __debugbreak #else VOID NTAPI -DbgBreakPoint(VOID); +DbgBreakPoint( + VOID); #endif NTSYSAPI VOID NTAPI DbgBreakPointWithStatus( - IN ULONG Status); + IN ULONG Status); -#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ +NTSYSAPI +ULONG +DDKCDECLAPI +DbgPrintReturnControlC( + IN PCCH Format, + IN ...); + +#endif + +#if (NTDDI_VERSION >= NTDDI_WINXP) + +NTSYSAPI +ULONG +DDKCDECLAPI +DbgPrintEx( + IN ULONG ComponentId, + IN ULONG Level, + IN PCSTR Format, + IN ...); + +NTSYSAPI +NTSTATUS +NTAPI +DbgQueryDebugFilterState( + IN ULONG ComponentId, + IN ULONG Level); + +NTSYSAPI +NTSTATUS +NTAPI +DbgSetDebugFilterState( + IN ULONG ComponentId, + IN ULONG Level, + IN BOOLEAN State); + +#endif #if (NTDDI_VERSION >= NTDDI_WS03) + NTKERNELAPI BOOLEAN NTAPI -KdRefreshDebuggerNotPresent(VOID); +KdRefreshDebuggerNotPresent( + VOID +); + #endif #if (NTDDI_VERSION >= NTDDI_WS03SP1) @@ -14593,20 +10905,16 @@ KdChangeOption( OUT PVOID OutBuffer, OUT PULONG OutBufferNeeded OPTIONAL); #endif -/* Hardware Abstraction Layer Functions */ - -#if (NTDDI_VERSION >= NTDDI_WIN2K) #if defined(USE_DMA_MACROS) && !defined(_NTHAL_) && (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_) - FORCEINLINE PVOID NTAPI HalAllocateCommonBuffer( IN PDMA_ADAPTER DmaAdapter, - IN ULONG Length, - OUT PPHYSICAL_ADDRESS LogicalAddress, - IN BOOLEAN CacheEnabled) + IN ULONG Length, + OUT PPHYSICAL_ADDRESS LogicalAddress, + IN BOOLEAN CacheEnabled) { PALLOCATE_COMMON_BUFFER allocateCommonBuffer; PVOID commonBuffer; @@ -14622,10 +10930,10 @@ VOID NTAPI HalFreeCommonBuffer( IN PDMA_ADAPTER DmaAdapter, - IN ULONG Length, - IN PHYSICAL_ADDRESS LogicalAddress, - IN PVOID VirtualAddress, - IN BOOLEAN CacheEnabled) + IN ULONG Length, + IN PHYSICAL_ADDRESS LogicalAddress, + IN PVOID VirtualAddress, + IN BOOLEAN CacheEnabled) { PFREE_COMMON_BUFFER freeCommonBuffer; @@ -14649,224 +10957,14 @@ HalReadDmaCounter( return counter; } -FORCEINLINE -ULONG -HalGetDmaAlignment( - IN PDMA_ADAPTER DmaAdapter) -{ - PGET_DMA_ALIGNMENT getDmaAlignment; - ULONG alignment; +#endif - getDmaAlignment = *(DmaAdapter)->DmaOperations->GetDmaAlignment; - ASSERT( getDmaAlignment != NULL ); - alignment = getDmaAlignment( DmaAdapter ); - return alignment; -} - -#endif /* USE_DMA_MACROS ... */ -#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ #ifndef _NTTMAPI_ #define _NTTMAPI_ #include -#define TRANSACTIONMANAGER_QUERY_INFORMATION (0x0001) -#define TRANSACTIONMANAGER_SET_INFORMATION (0x0002) -#define TRANSACTIONMANAGER_RECOVER (0x0004) -#define TRANSACTIONMANAGER_RENAME (0x0008) -#define TRANSACTIONMANAGER_CREATE_RM (0x0010) -#define TRANSACTIONMANAGER_BIND_TRANSACTION (0x0020) - -#define TRANSACTIONMANAGER_GENERIC_READ (STANDARD_RIGHTS_READ |\ - TRANSACTIONMANAGER_QUERY_INFORMATION) - -#define TRANSACTIONMANAGER_GENERIC_WRITE (STANDARD_RIGHTS_WRITE |\ - TRANSACTIONMANAGER_SET_INFORMATION |\ - TRANSACTIONMANAGER_RECOVER |\ - TRANSACTIONMANAGER_RENAME |\ - TRANSACTIONMANAGER_CREATE_RM) - -#define TRANSACTIONMANAGER_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE) - -#define TRANSACTIONMANAGER_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED |\ - TRANSACTIONMANAGER_GENERIC_READ |\ - TRANSACTIONMANAGER_GENERIC_WRITE |\ - TRANSACTIONMANAGER_GENERIC_EXECUTE |\ - TRANSACTIONMANAGER_BIND_TRANSACTION) - -#define TRANSACTION_QUERY_INFORMATION (0x0001) -#define TRANSACTION_SET_INFORMATION (0x0002) -#define TRANSACTION_ENLIST (0x0004) -#define TRANSACTION_COMMIT (0x0008) -#define TRANSACTION_ROLLBACK (0x0010) -#define TRANSACTION_PROPAGATE (0x0020) -#define TRANSACTION_RIGHT_RESERVED1 (0x0040) - -#define TRANSACTION_GENERIC_READ (STANDARD_RIGHTS_READ |\ - TRANSACTION_QUERY_INFORMATION |\ - SYNCHRONIZE) - -#define TRANSACTION_GENERIC_WRITE (STANDARD_RIGHTS_WRITE |\ - TRANSACTION_SET_INFORMATION |\ - TRANSACTION_COMMIT |\ - TRANSACTION_ENLIST |\ - TRANSACTION_ROLLBACK |\ - TRANSACTION_PROPAGATE |\ - SYNCHRONIZE) - -#define TRANSACTION_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE |\ - TRANSACTION_COMMIT |\ - TRANSACTION_ROLLBACK |\ - SYNCHRONIZE) - -#define TRANSACTION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED |\ - TRANSACTION_GENERIC_READ |\ - TRANSACTION_GENERIC_WRITE |\ - TRANSACTION_GENERIC_EXECUTE) - -#define TRANSACTION_RESOURCE_MANAGER_RIGHTS (TRANSACTION_GENERIC_READ |\ - STANDARD_RIGHTS_WRITE |\ - TRANSACTION_SET_INFORMATION |\ - TRANSACTION_ENLIST |\ - TRANSACTION_ROLLBACK |\ - TRANSACTION_PROPAGATE |\ - SYNCHRONIZE) - -#define RESOURCEMANAGER_QUERY_INFORMATION (0x0001) -#define RESOURCEMANAGER_SET_INFORMATION (0x0002) -#define RESOURCEMANAGER_RECOVER (0x0004) -#define RESOURCEMANAGER_ENLIST (0x0008) -#define RESOURCEMANAGER_GET_NOTIFICATION (0x0010) -#define RESOURCEMANAGER_REGISTER_PROTOCOL (0x0020) -#define RESOURCEMANAGER_COMPLETE_PROPAGATION (0x0040) - -#define RESOURCEMANAGER_GENERIC_READ (STANDARD_RIGHTS_READ |\ - RESOURCEMANAGER_QUERY_INFORMATION |\ - SYNCHRONIZE) - -#define RESOURCEMANAGER_GENERIC_WRITE (STANDARD_RIGHTS_WRITE |\ - RESOURCEMANAGER_SET_INFORMATION |\ - RESOURCEMANAGER_RECOVER |\ - RESOURCEMANAGER_ENLIST |\ - RESOURCEMANAGER_GET_NOTIFICATION |\ - RESOURCEMANAGER_REGISTER_PROTOCOL |\ - RESOURCEMANAGER_COMPLETE_PROPAGATION |\ - SYNCHRONIZE) - -#define RESOURCEMANAGER_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE |\ - RESOURCEMANAGER_RECOVER |\ - RESOURCEMANAGER_ENLIST |\ - RESOURCEMANAGER_GET_NOTIFICATION |\ - RESOURCEMANAGER_COMPLETE_PROPAGATION |\ - SYNCHRONIZE) - -#define RESOURCEMANAGER_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED |\ - RESOURCEMANAGER_GENERIC_READ |\ - RESOURCEMANAGER_GENERIC_WRITE |\ - RESOURCEMANAGER_GENERIC_EXECUTE) - -#define ENLISTMENT_QUERY_INFORMATION (0x0001) -#define ENLISTMENT_SET_INFORMATION (0x0002) -#define ENLISTMENT_RECOVER (0x0004) -#define ENLISTMENT_SUBORDINATE_RIGHTS (0x0008) -#define ENLISTMENT_SUPERIOR_RIGHTS (0x0010) - -#define ENLISTMENT_GENERIC_READ (STANDARD_RIGHTS_READ |\ - ENLISTMENT_QUERY_INFORMATION) - -#define ENLISTMENT_GENERIC_WRITE (STANDARD_RIGHTS_WRITE |\ - ENLISTMENT_SET_INFORMATION |\ - ENLISTMENT_RECOVER |\ - ENLISTMENT_SUBORDINATE_RIGHTS |\ - ENLISTMENT_SUPERIOR_RIGHTS) - -#define ENLISTMENT_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE |\ - ENLISTMENT_RECOVER |\ - ENLISTMENT_SUBORDINATE_RIGHTS |\ - ENLISTMENT_SUPERIOR_RIGHTS) - -#define ENLISTMENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED |\ - ENLISTMENT_GENERIC_READ |\ - ENLISTMENT_GENERIC_WRITE |\ - ENLISTMENT_GENERIC_EXECUTE) - -typedef enum _TRANSACTION_OUTCOME { - TransactionOutcomeUndetermined = 1, - TransactionOutcomeCommitted, - TransactionOutcomeAborted, -} TRANSACTION_OUTCOME; - - -typedef enum _TRANSACTION_STATE { - TransactionStateNormal = 1, - TransactionStateIndoubt, - TransactionStateCommittedNotify, -} TRANSACTION_STATE; - - -typedef struct _TRANSACTION_BASIC_INFORMATION { - GUID TransactionId; - ULONG State; - ULONG Outcome; -} TRANSACTION_BASIC_INFORMATION, *PTRANSACTION_BASIC_INFORMATION; - -typedef struct _TRANSACTIONMANAGER_BASIC_INFORMATION { - GUID TmIdentity; - LARGE_INTEGER VirtualClock; -} TRANSACTIONMANAGER_BASIC_INFORMATION, *PTRANSACTIONMANAGER_BASIC_INFORMATION; - -typedef struct _TRANSACTIONMANAGER_LOG_INFORMATION { - GUID LogIdentity; -} TRANSACTIONMANAGER_LOG_INFORMATION, *PTRANSACTIONMANAGER_LOG_INFORMATION; - -typedef struct _TRANSACTIONMANAGER_LOGPATH_INFORMATION { - ULONG LogPathLength; - WCHAR LogPath[1]; -} TRANSACTIONMANAGER_LOGPATH_INFORMATION, *PTRANSACTIONMANAGER_LOGPATH_INFORMATION; - -typedef struct _TRANSACTIONMANAGER_RECOVERY_INFORMATION { - ULONGLONG LastRecoveredLsn; -} TRANSACTIONMANAGER_RECOVERY_INFORMATION, *PTRANSACTIONMANAGER_RECOVERY_INFORMATION; - -typedef struct _TRANSACTION_PROPERTIES_INFORMATION { - ULONG IsolationLevel; - ULONG IsolationFlags; - LARGE_INTEGER Timeout; - ULONG Outcome; - ULONG DescriptionLength; - WCHAR Description[1]; -} TRANSACTION_PROPERTIES_INFORMATION, *PTRANSACTION_PROPERTIES_INFORMATION; - -typedef struct _TRANSACTION_BIND_INFORMATION { - HANDLE TmHandle; -} TRANSACTION_BIND_INFORMATION, *PTRANSACTION_BIND_INFORMATION; - -typedef struct _TRANSACTION_ENLISTMENT_PAIR { - GUID EnlistmentId; - GUID ResourceManagerId; -} TRANSACTION_ENLISTMENT_PAIR, *PTRANSACTION_ENLISTMENT_PAIR; - -typedef struct _TRANSACTION_ENLISTMENTS_INFORMATION { - ULONG NumberOfEnlistments; - TRANSACTION_ENLISTMENT_PAIR EnlistmentPair[1]; -} TRANSACTION_ENLISTMENTS_INFORMATION, *PTRANSACTION_ENLISTMENTS_INFORMATION; - -typedef struct _TRANSACTION_SUPERIOR_ENLISTMENT_INFORMATION { - TRANSACTION_ENLISTMENT_PAIR SuperiorEnlistmentPair; -} TRANSACTION_SUPERIOR_ENLISTMENT_INFORMATION, *PTRANSACTION_SUPERIOR_ENLISTMENT_INFORMATION; - -typedef struct _RESOURCEMANAGER_BASIC_INFORMATION { - GUID ResourceManagerId; - ULONG DescriptionLength; - WCHAR Description[1]; -} RESOURCEMANAGER_BASIC_INFORMATION, *PRESOURCEMANAGER_BASIC_INFORMATION; - -typedef struct _RESOURCEMANAGER_COMPLETION_INFORMATION { - HANDLE IoCompletionPortHandle; - ULONG_PTR CompletionKey; -} RESOURCEMANAGER_COMPLETION_INFORMATION, *PRESOURCEMANAGER_COMPLETION_INFORMATION; - typedef enum _KTMOBJECT_TYPE { KTMOBJECT_TRANSACTION, KTMOBJECT_TRANSACTION_MANAGER, @@ -14900,480 +10998,66 @@ typedef enum _RESOURCEMANAGER_INFORMATION_CLASS { ResourceManagerCompletionInformation, } RESOURCEMANAGER_INFORMATION_CLASS; -typedef struct _ENLISTMENT_BASIC_INFORMATION { - GUID EnlistmentId; - GUID TransactionId; - GUID ResourceManagerId; -} ENLISTMENT_BASIC_INFORMATION, *PENLISTMENT_BASIC_INFORMATION; - -typedef struct _ENLISTMENT_CRM_INFORMATION { - GUID CrmTransactionManagerId; - GUID CrmResourceManagerId; - GUID CrmEnlistmentId; -} ENLISTMENT_CRM_INFORMATION, *PENLISTMENT_CRM_INFORMATION; - typedef enum _ENLISTMENT_INFORMATION_CLASS { EnlistmentBasicInformation, EnlistmentRecoveryInformation, EnlistmentCrmInformation } ENLISTMENT_INFORMATION_CLASS; -typedef struct _TRANSACTION_LIST_ENTRY { -#if defined(__cplusplus) - ::UOW UOW; -#else - UOW UOW; -#endif -} TRANSACTION_LIST_ENTRY, *PTRANSACTION_LIST_ENTRY; - -typedef struct _TRANSACTION_LIST_INFORMATION { - ULONG NumberOfTransactions; - TRANSACTION_LIST_ENTRY TransactionInformation[1]; -} TRANSACTION_LIST_INFORMATION, *PTRANSACTION_LIST_INFORMATION; - -typedef NTSTATUS -(NTAPI *PFN_NT_CREATE_TRANSACTION)( - OUT PHANDLE TransactionHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, - IN LPGUID Uow OPTIONAL, - IN HANDLE TmHandle OPTIONAL, - IN ULONG CreateOptions OPTIONAL, - IN ULONG IsolationLevel OPTIONAL, - IN ULONG IsolationFlags OPTIONAL, - IN PLARGE_INTEGER Timeout OPTIONAL, - IN PUNICODE_STRING Description OPTIONAL); - -typedef NTSTATUS -(NTAPI *PFN_NT_OPEN_TRANSACTION)( - OUT PHANDLE TransactionHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes, - IN LPGUID Uow OPTIONAL, - IN HANDLE TmHandle OPTIONAL); - -typedef NTSTATUS -(NTAPI *PFN_NT_QUERY_INFORMATION_TRANSACTION)( - IN HANDLE TransactionHandle, - IN TRANSACTION_INFORMATION_CLASS TransactionInformationClass, - OUT PVOID TransactionInformation, - IN ULONG TransactionInformationLength, - OUT PULONG ReturnLength OPTIONAL); - -typedef NTSTATUS -(NTAPI *PFN_NT_SET_INFORMATION_TRANSACTION)( - IN HANDLE TransactionHandle, - IN TRANSACTION_INFORMATION_CLASS TransactionInformationClass, - IN PVOID TransactionInformation, - IN ULONG TransactionInformationLength); - -typedef NTSTATUS -(NTAPI *PFN_NT_COMMIT_TRANSACTION)( - IN HANDLE TransactionHandle, - IN BOOLEAN Wait); - -typedef NTSTATUS -(NTAPI *PFN_NT_ROLLBACK_TRANSACTION)( - IN HANDLE TransactionHandle, - IN BOOLEAN Wait); - -#if (NTDDI_VERSION >= NTDDI_VISTA) - -NTSYSCALLAPI -NTSTATUS -NTAPI -NtCreateTransactionManager( - OUT PHANDLE TmHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, - IN PUNICODE_STRING LogFileName OPTIONAL, - IN ULONG CreateOptions OPTIONAL, - IN ULONG CommitStrength OPTIONAL); - -NTSYSCALLAPI -NTSTATUS -NTAPI -NtOpenTransactionManager( - OUT PHANDLE TmHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, - IN PUNICODE_STRING LogFileName OPTIONAL, - IN LPGUID TmIdentity OPTIONAL, - IN ULONG OpenOptions OPTIONAL); - -NTSYSCALLAPI -NTSTATUS -NTAPI -NtRenameTransactionManager( - IN PUNICODE_STRING LogFileName, - IN LPGUID ExistingTransactionManagerGuid); - -NTSYSCALLAPI -NTSTATUS -NTAPI -NtRollforwardTransactionManager( - IN HANDLE TransactionManagerHandle, - IN PLARGE_INTEGER TmVirtualClock OPTIONAL); - -NTSYSCALLAPI -NTSTATUS -NTAPI -NtRecoverTransactionManager( - IN HANDLE TransactionManagerHandle); - -NTSYSCALLAPI -NTSTATUS -NTAPI -NtQueryInformationTransactionManager( - IN HANDLE TransactionManagerHandle, - IN TRANSACTIONMANAGER_INFORMATION_CLASS TransactionManagerInformationClass, - OUT PVOID TransactionManagerInformation, - IN ULONG TransactionManagerInformationLength, - OUT PULONG ReturnLength); - -NTSYSCALLAPI -NTSTATUS -NTAPI -NtSetInformationTransactionManager( - IN HANDLE TmHandle OPTIONAL, - IN TRANSACTIONMANAGER_INFORMATION_CLASS TransactionManagerInformationClass, - IN PVOID TransactionManagerInformation, - IN ULONG TransactionManagerInformationLength); - -NTSYSCALLAPI -NTSTATUS -NTAPI -NtEnumerateTransactionObject( - IN HANDLE RootObjectHandle OPTIONAL, - IN KTMOBJECT_TYPE QueryType, - IN OUT PKTMOBJECT_CURSOR ObjectCursor, - IN ULONG ObjectCursorLength, - OUT PULONG ReturnLength); - -NTSYSCALLAPI -NTSTATUS -NTAPI -NtCreateTransaction( - OUT PHANDLE TransactionHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, - IN LPGUID Uow OPTIONAL, - IN HANDLE TmHandle OPTIONAL, - IN ULONG CreateOptions OPTIONAL, - IN ULONG IsolationLevel OPTIONAL, - IN ULONG IsolationFlags OPTIONAL, - IN PLARGE_INTEGER Timeout OPTIONAL, - IN PUNICODE_STRING Description OPTIONAL); - -NTSYSCALLAPI -NTSTATUS -NTAPI -NtOpenTransaction( - OUT PHANDLE TransactionHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes, - IN LPGUID Uow, - IN HANDLE TmHandle OPTIONAL); - -NTSYSCALLAPI -NTSTATUS -NTAPI -NtQueryInformationTransaction( - IN HANDLE TransactionHandle, - IN TRANSACTION_INFORMATION_CLASS TransactionInformationClass, - OUT PVOID TransactionInformation, - IN ULONG TransactionInformationLength, - OUT PULONG ReturnLength OPTIONAL); - -NTSYSCALLAPI -NTSTATUS -NTAPI -NtSetInformationTransaction( - IN HANDLE TransactionHandle, - IN TRANSACTION_INFORMATION_CLASS TransactionInformationClass, - IN PVOID TransactionInformation, - IN ULONG TransactionInformationLength); - -NTSYSCALLAPI -NTSTATUS -NTAPI -NtCommitTransaction( - IN HANDLE TransactionHandle, - IN BOOLEAN Wait); - -NTSYSCALLAPI -NTSTATUS -NTAPI -NtRollbackTransaction( - IN HANDLE TransactionHandle, - IN BOOLEAN Wait); - -NTSYSCALLAPI -NTSTATUS -NTAPI -NtCreateEnlistment( - OUT PHANDLE EnlistmentHandle, - IN ACCESS_MASK DesiredAccess, - IN HANDLE ResourceManagerHandle, - IN HANDLE TransactionHandle, - IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, - IN ULONG CreateOptions OPTIONAL, - IN NOTIFICATION_MASK NotificationMask, - IN PVOID EnlistmentKey OPTIONAL); - -NTSYSCALLAPI -NTSTATUS -NTAPI -NtOpenEnlistment( - OUT PHANDLE EnlistmentHandle, - IN ACCESS_MASK DesiredAccess, - IN HANDLE ResourceManagerHandle, - IN LPGUID EnlistmentGuid, - IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL); - -NTSYSCALLAPI -NTSTATUS -NTAPI -NtQueryInformationEnlistment( - IN HANDLE EnlistmentHandle, - IN ENLISTMENT_INFORMATION_CLASS EnlistmentInformationClass, - OUT PVOID EnlistmentInformation, - IN ULONG EnlistmentInformationLength, - OUT PULONG ReturnLength); - -NTSYSCALLAPI -NTSTATUS -NTAPI -NtSetInformationEnlistment( - IN HANDLE EnlistmentHandle OPTIONAL, - IN ENLISTMENT_INFORMATION_CLASS EnlistmentInformationClass, - IN PVOID EnlistmentInformation, - IN ULONG EnlistmentInformationLength); - -NTSYSCALLAPI -NTSTATUS -NTAPI -NtRecoverEnlistment( - IN HANDLE EnlistmentHandle, - IN PVOID EnlistmentKey OPTIONAL); - -NTSYSCALLAPI -NTSTATUS -NTAPI -NtPrePrepareEnlistment( - IN HANDLE EnlistmentHandle, - IN PLARGE_INTEGER TmVirtualClock OPTIONAL); - -NTSYSCALLAPI -NTSTATUS -NTAPI -NtPrepareEnlistment( - IN HANDLE EnlistmentHandle, - IN PLARGE_INTEGER TmVirtualClock OPTIONAL); - -NTSYSCALLAPI -NTSTATUS -NTAPI -NtCommitEnlistment( - IN HANDLE EnlistmentHandle, - IN PLARGE_INTEGER TmVirtualClock OPTIONAL); - -NTSYSCALLAPI -NTSTATUS -NTAPI -NtRollbackEnlistment( - IN HANDLE EnlistmentHandle, - IN PLARGE_INTEGER TmVirtualClock OPTIONAL); - -NTSYSCALLAPI -NTSTATUS -NTAPI -NtPrePrepareComplete( - IN HANDLE EnlistmentHandle, - IN PLARGE_INTEGER TmVirtualClock OPTIONAL); - -NTSYSCALLAPI -NTSTATUS -NTAPI -NtPrepareComplete( - IN HANDLE EnlistmentHandle, - IN PLARGE_INTEGER TmVirtualClock OPTIONAL); - -NTSYSCALLAPI -NTSTATUS -NTAPI -NtCommitComplete( - IN HANDLE EnlistmentHandle, - IN PLARGE_INTEGER TmVirtualClock OPTIONAL); - -NTSYSCALLAPI -NTSTATUS -NTAPI -NtReadOnlyEnlistment( - IN HANDLE EnlistmentHandle, - IN PLARGE_INTEGER TmVirtualClock OPTIONAL); - -NTSYSCALLAPI -NTSTATUS -NTAPI -NtRollbackComplete( - IN HANDLE EnlistmentHandle, - IN PLARGE_INTEGER TmVirtualClock OPTIONAL); - -NTSYSCALLAPI -NTSTATUS -NTAPI -NtSinglePhaseReject( - IN HANDLE EnlistmentHandle, - IN PLARGE_INTEGER TmVirtualClock OPTIONAL); - -NTSYSCALLAPI -NTSTATUS -NTAPI -NtCreateResourceManager( - OUT PHANDLE ResourceManagerHandle, - IN ACCESS_MASK DesiredAccess, - IN HANDLE TmHandle, - IN LPGUID RmGuid, - IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, - IN ULONG CreateOptions OPTIONAL, - IN PUNICODE_STRING Description OPTIONAL); - -NTSYSCALLAPI -NTSTATUS -NTAPI -NtOpenResourceManager( - OUT PHANDLE ResourceManagerHandle, - IN ACCESS_MASK DesiredAccess, - IN HANDLE TmHandle, - IN LPGUID ResourceManagerGuid OPTIONAL, - IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL); - -NTSYSCALLAPI -NTSTATUS -NTAPI -NtRecoverResourceManager( - IN HANDLE ResourceManagerHandle); - -NTSYSCALLAPI -NTSTATUS -NTAPI -NtGetNotificationResourceManager( - IN HANDLE ResourceManagerHandle, - OUT PTRANSACTION_NOTIFICATION TransactionNotification, - IN ULONG NotificationLength, - IN PLARGE_INTEGER Timeout OPTIONAL, - OUT PULONG ReturnLength OPTIONAL, - IN ULONG Asynchronous, - IN ULONG_PTR AsynchronousContext OPTIONAL); - -NTSYSCALLAPI -NTSTATUS -NTAPI -NtQueryInformationResourceManager( - IN HANDLE ResourceManagerHandle, - IN RESOURCEMANAGER_INFORMATION_CLASS ResourceManagerInformationClass, - OUT PVOID ResourceManagerInformation, - IN ULONG ResourceManagerInformationLength, - OUT PULONG ReturnLength OPTIONAL); - -NTSYSCALLAPI -NTSTATUS -NTAPI -NtSetInformationResourceManager( - IN HANDLE ResourceManagerHandle, - IN RESOURCEMANAGER_INFORMATION_CLASS ResourceManagerInformationClass, - IN PVOID ResourceManagerInformation, - IN ULONG ResourceManagerInformationLength); - -NTSYSCALLAPI -NTSTATUS -NTAPI -NtRegisterProtocolAddressInformation( - IN HANDLE ResourceManager, - IN PCRM_PROTOCOL_ID ProtocolId, - IN ULONG ProtocolInformationSize, - IN PVOID ProtocolInformation, - IN ULONG CreateOptions OPTIONAL); - -NTSYSCALLAPI -NTSTATUS -NTAPI -NtPropagationComplete( - IN HANDLE ResourceManagerHandle, - IN ULONG RequestCookie, - IN ULONG BufferLength, - IN PVOID Buffer); - -NTSYSCALLAPI -NTSTATUS -NTAPI -NtPropagationFailed( - IN HANDLE ResourceManagerHandle, - IN ULONG RequestCookie, - IN NTSTATUS PropStatus); - -#endif /* NTDDI_VERSION >= NTDDI_VISTA */ - #endif /* !_NTTMAPI_ */ /****************************************************************************** * ZwXxx Functions * ******************************************************************************/ - /* Constants */ #define NtCurrentProcess() ( (HANDLE)(LONG_PTR) -1 ) #define ZwCurrentProcess() NtCurrentProcess() #define NtCurrentThread() ( (HANDLE)(LONG_PTR) -2 ) #define ZwCurrentThread() NtCurrentThread() - - #if (NTDDI_VERSION >= NTDDI_WIN2K) - - NTSYSAPI NTSTATUS NTAPI ZwClose( - IN HANDLE Handle); + IN HANDLE Handle); NTSYSAPI NTSTATUS NTAPI ZwCreateDirectoryObject( - OUT PHANDLE DirectoryHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes); + OUT PHANDLE DirectoryHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes); NTSYSAPI NTSTATUS NTAPI ZwCreateFile( - OUT PHANDLE FileHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes, - OUT PIO_STATUS_BLOCK IoStatusBlock, - IN PLARGE_INTEGER AllocationSize OPTIONAL, - IN ULONG FileAttributes, - IN ULONG ShareAccess, - IN ULONG CreateDisposition, - IN ULONG CreateOptions, - IN PVOID EaBuffer OPTIONAL, - IN ULONG EaLength); + OUT PHANDLE FileHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN PLARGE_INTEGER AllocationSize OPTIONAL, + IN ULONG FileAttributes, + IN ULONG ShareAccess, + IN ULONG CreateDisposition, + IN ULONG CreateOptions, + IN PVOID EaBuffer OPTIONAL, + IN ULONG EaLength); NTSYSAPI NTSTATUS NTAPI ZwCreateKey( - OUT PHANDLE KeyHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes, - IN ULONG TitleIndex, - IN PUNICODE_STRING Class OPTIONAL, - IN ULONG CreateOptions, - OUT PULONG Disposition OPTIONAL); + OUT PHANDLE KeyHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN ULONG TitleIndex, + IN PUNICODE_STRING Class OPTIONAL, + IN ULONG CreateOptions, + OUT PULONG Disposition OPTIONAL); NTSYSAPI NTSTATUS @@ -15397,7 +11081,7 @@ NTSYSAPI NTSTATUS NTAPI ZwDeleteValueKey( - IN HANDLE KeyHandle, + IN HANDLE KeyHandle, IN PUNICODE_STRING ValueName); NTSYSAPI @@ -15426,7 +11110,7 @@ NTSYSAPI NTSTATUS NTAPI ZwFlushKey( - IN HANDLE KeyHandle); + IN HANDLE KeyHandle); NTSYSAPI NTSTATUS @@ -15438,22 +11122,22 @@ NTSYSAPI NTSTATUS NTAPI ZwMakeTemporaryObject( - IN HANDLE Handle); + IN HANDLE Handle); NTSYSAPI NTSTATUS NTAPI ZwMapViewOfSection( - IN HANDLE SectionHandle, - IN HANDLE ProcessHandle, - IN OUT PVOID *BaseAddress, - IN ULONG_PTR ZeroBits, - IN SIZE_T CommitSize, - IN OUT PLARGE_INTEGER SectionOffset OPTIONAL, - IN OUT PSIZE_T ViewSize, - IN SECTION_INHERIT InheritDisposition, - IN ULONG AllocationType, - IN ULONG Protect); + IN HANDLE SectionHandle, + IN HANDLE ProcessHandle, + IN OUT PVOID *BaseAddress, + IN ULONG_PTR ZeroBits, + IN SIZE_T CommitSize, + IN OUT PLARGE_INTEGER SectionOffset OPTIONAL, + IN OUT PSIZE_T ViewSize, + IN SECTION_INHERIT InheritDisposition, + IN ULONG AllocationType, + IN ULONG Protect); NTSYSAPI NTSTATUS @@ -15470,35 +11154,35 @@ NTSYSAPI NTSTATUS NTAPI ZwOpenKey( - OUT PHANDLE KeyHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes); + OUT PHANDLE KeyHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes); NTSYSAPI NTSTATUS NTAPI ZwOpenSection( - OUT PHANDLE SectionHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes); + OUT PHANDLE SectionHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes); NTSYSAPI NTSTATUS NTAPI ZwOpenSymbolicLinkObject( - OUT PHANDLE LinkHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes); + OUT PHANDLE LinkHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes); NTSYSAPI NTSTATUS NTAPI ZwQueryInformationFile( - IN HANDLE FileHandle, - OUT PIO_STATUS_BLOCK IoStatusBlock, - OUT PVOID FileInformation, - IN ULONG Length, - IN FILE_INFORMATION_CLASS FileInformationClass); + IN HANDLE FileHandle, + OUT PIO_STATUS_BLOCK IoStatusBlock, + OUT PVOID FileInformation, + IN ULONG Length, + IN FILE_INFORMATION_CLASS FileInformationClass); NTSYSAPI NTSTATUS @@ -15514,9 +11198,9 @@ NTSYSAPI NTSTATUS NTAPI ZwQuerySymbolicLinkObject( - IN HANDLE LinkHandle, - IN OUT PUNICODE_STRING LinkTarget, - OUT PULONG ReturnedLength OPTIONAL); + IN HANDLE LinkHandle, + IN OUT PUNICODE_STRING LinkTarget, + OUT PULONG ReturnedLength OPTIONAL); NTSYSAPI NTSTATUS @@ -15533,36 +11217,36 @@ NTSYSAPI NTSTATUS NTAPI ZwReadFile( - IN HANDLE FileHandle, - IN HANDLE Event OPTIONAL, - IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, - IN PVOID ApcContext OPTIONAL, - OUT PIO_STATUS_BLOCK IoStatusBlock, - OUT PVOID Buffer, - IN ULONG Length, - IN PLARGE_INTEGER ByteOffset OPTIONAL, - IN PULONG Key OPTIONAL); + IN HANDLE FileHandle, + IN HANDLE Event OPTIONAL, + IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, + IN PVOID ApcContext OPTIONAL, + OUT PIO_STATUS_BLOCK IoStatusBlock, + OUT PVOID Buffer, + IN ULONG Length, + IN PLARGE_INTEGER ByteOffset OPTIONAL, + IN PULONG Key OPTIONAL); NTSYSAPI NTSTATUS NTAPI ZwSetInformationFile( - IN HANDLE FileHandle, - OUT PIO_STATUS_BLOCK IoStatusBlock, - IN PVOID FileInformation, - IN ULONG Length, - IN FILE_INFORMATION_CLASS FileInformationClass); + IN HANDLE FileHandle, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN PVOID FileInformation, + IN ULONG Length, + IN FILE_INFORMATION_CLASS FileInformationClass); NTSYSAPI NTSTATUS NTAPI ZwSetValueKey( - IN HANDLE KeyHandle, - IN PUNICODE_STRING ValueName, - IN ULONG TitleIndex OPTIONAL, - IN ULONG Type, - IN PVOID Data OPTIONAL, - IN ULONG DataSize); + IN HANDLE KeyHandle, + IN PUNICODE_STRING ValueName, + IN ULONG TitleIndex OPTIONAL, + IN ULONG Type, + IN PVOID Data OPTIONAL, + IN ULONG DataSize); NTSYSAPI NTSTATUS @@ -15574,22 +11258,22 @@ NTSYSAPI NTSTATUS NTAPI ZwUnmapViewOfSection( - IN HANDLE ProcessHandle, - IN PVOID BaseAddress OPTIONAL); + IN HANDLE ProcessHandle, + IN PVOID BaseAddress OPTIONAL); NTSYSAPI NTSTATUS NTAPI ZwWriteFile( - IN HANDLE FileHandle, - IN HANDLE Event OPTIONAL, - IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, - IN PVOID ApcContext OPTIONAL, - OUT PIO_STATUS_BLOCK IoStatusBlock, - IN PVOID Buffer, - IN ULONG Length, - IN PLARGE_INTEGER ByteOffset OPTIONAL, - IN PULONG Key OPTIONAL); + IN HANDLE FileHandle, + IN HANDLE Event OPTIONAL, + IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, + IN PVOID ApcContext OPTIONAL, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN PVOID Buffer, + IN ULONG Length, + IN PLARGE_INTEGER ByteOffset OPTIONAL, + IN PULONG Key OPTIONAL); NTSYSAPI NTSTATUS @@ -15598,11 +11282,10 @@ ZwQueryFullAttributesFile( IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PFILE_NETWORK_OPEN_INFORMATION FileInformation); +#endif -#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ +#if (NTDDI_VERSION >= NTDDI_WIN2003) - -#if (NTDDI_VERSION >= NTDDI_WS03) NTSYSCALLAPI NTSTATUS NTAPI @@ -15610,6 +11293,7 @@ ZwOpenEvent( OUT PHANDLE EventHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes); + #endif #if (NTDDI_VERSION >= NTDDI_VISTA) @@ -15936,13 +11620,10 @@ ZwSinglePhaseReject( IN PLARGE_INTEGER TmVirtualClock OPTIONAL); -#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ - +#endif #if (NTDDI_VERSION >= NTDDI_WIN7) - - NTSYSAPI NTSTATUS NTAPI @@ -16006,8 +11687,78 @@ ZwSetInformationKey( IN PVOID KeySetInformation, IN ULONG KeySetInformationLength); +#endif + +/****************************************************************************** + * Unsorted * + ******************************************************************************/ + +/* GUID Comparison */ +#ifndef __IID_ALIGNED__ +#define __IID_ALIGNED__ +#ifdef __cplusplus +inline int IsEqualGUIDAligned(REFGUID guid1, REFGUID guid2) +{ + return ( (*(PLONGLONG)(&guid1) == *(PLONGLONG)(&guid2)) && + (*((PLONGLONG)(&guid1) + 1) == *((PLONGLONG)(&guid2) + 1)) ); +} +#else +#define IsEqualGUIDAligned(guid1, guid2) \ + ( (*(PLONGLONG)(guid1) == *(PLONGLONG)(guid2)) && \ + (*((PLONGLONG)(guid1) + 1) == *((PLONGLONG)(guid2) + 1)) ) +#endif /* __cplusplus */ +#endif /* !__IID_ALIGNED__ */ + +typedef enum { + LT_DONT_CARE, + LT_LOWEST_LATENCY +} LATENCY_TIME; + +#define MAXIMUM_SUSPEND_COUNT MAXCHAR + +#define MAXIMUM_FILENAME_LENGTH 256 + +#define OBJ_NAME_PATH_SEPARATOR ((WCHAR)L'\\') + +#define OBJECT_TYPE_CREATE (0x0001) +#define OBJECT_TYPE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0x1) + +#define DIRECTORY_QUERY (0x0001) +#define DIRECTORY_TRAVERSE (0x0002) +#define DIRECTORY_CREATE_OBJECT (0x0004) +#define DIRECTORY_CREATE_SUBDIRECTORY (0x0008) +#define DIRECTORY_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0xF) + +#define EVENT_QUERY_STATE (0x0001) +#define EVENT_MODIFY_STATE (0x0002) +#define EVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3) + +#define SEMAPHORE_QUERY_STATE (0x0001) +#define SEMAPHORE_MODIFY_STATE (0x0002) +#define SEMAPHORE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3) + +#define SYMBOLIC_LINK_QUERY 0x0001 +#define SYMBOLIC_LINK_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0x1) + +#define DUPLICATE_CLOSE_SOURCE 0x00000001 +#define DUPLICATE_SAME_ACCESS 0x00000002 +#define DUPLICATE_SAME_ATTRIBUTES 0x00000004 + +/* Global debug flag */ +extern ULONG NtGlobalFlag; + +/* Service Start Types */ +#define SERVICE_BOOT_START 0x00000000 +#define SERVICE_SYSTEM_START 0x00000001 +#define SERVICE_AUTO_START 0x00000002 +#define SERVICE_DEMAND_START 0x00000003 +#define SERVICE_DISABLED 0x00000004 + +#ifndef _TRACEHANDLE_DEFINED +#define _TRACEHANDLE_DEFINED +typedef ULONG64 TRACEHANDLE, *PTRACEHANDLE; +#endif -#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ #ifdef __cplusplus diff --git a/reactos/include/ndk/ketypes.h b/reactos/include/ndk/ketypes.h index 67985379372..d4ae1c545f0 100644 --- a/reactos/include/ndk/ketypes.h +++ b/reactos/include/ndk/ketypes.h @@ -546,6 +546,17 @@ typedef enum _KAPC_ENVIRONMENT InsertApcEnvironment } KAPC_ENVIRONMENT; +// +// CPU Cache Types +// +typedef enum _PROCESSOR_CACHE_TYPE +{ + CacheUnified, + CacheInstruction, + CacheData, + CacheTrace, +} PROCESSOR_CACHE_TYPE; + // // PRCB DPC Data // @@ -566,6 +577,18 @@ typedef struct _PP_LOOKASIDE_LIST struct _GENERAL_LOOKASIDE *L; } PP_LOOKASIDE_LIST, *PPP_LOOKASIDE_LIST; +// +// CPU Cache Descriptor +// +typedef struct _CACHE_DESCRIPTOR +{ + UCHAR Level; + UCHAR Associativity; + USHORT LineSize; + ULONG Size; + PROCESSOR_CACHE_TYPE Type; +} CACHE_DESCRIPTOR, *PCACHE_DESCRIPTOR; + // // Architectural Types // diff --git a/reactos/include/ndk/peb_teb.h b/reactos/include/ndk/peb_teb.h index ec4b2d33617..38791b31a21 100644 --- a/reactos/include/ndk/peb_teb.h +++ b/reactos/include/ndk/peb_teb.h @@ -1,3 +1,4 @@ + #define PASTE2(x,y) x##y #define PASTE(x,y) PASTE2(x,y) @@ -18,10 +19,6 @@ #define GDI_HANDLE_BUFFER_SIZE 34 #endif -#if defined(_NTDDK_INCLUDED_) || defined(_NTIFS_) -#define PPEB PPEB_RENAMED -#endif - typedef struct STRUCT(_PEB) { BOOLEAN InheritedAddressSpace; @@ -155,7 +152,6 @@ typedef struct STRUCT(_PEB) #endif } STRUCT(PEB), *STRUCT(PPEB); -#undef PPEB #if defined(_WIN64) && !defined(EXPLICIT_32BIT) C_ASSERT(FIELD_OFFSET(STRUCT(PEB), Mutant) == 0x08); diff --git a/reactos/include/psdk/ktmtypes.h b/reactos/include/psdk/ktmtypes.h index 90b042f3f0b..77cf5782858 100644 --- a/reactos/include/psdk/ktmtypes.h +++ b/reactos/include/psdk/ktmtypes.h @@ -72,10 +72,7 @@ #define MAX_TRANSACTION_DESCRIPTION_LENGTH 64 #define MAX_RESOURCEMANAGER_DESCRIPTION_LENGTH 64 -#ifndef _WDMDDK_ typedef GUID UOW, *PUOW; -#endif - typedef GUID CRM_PROTOCOL_ID, *PCRM_PROTOCOL_ID; typedef ULONG NOTIFICATION_MASK; typedef ULONG SAVEPOINT_ID, *PSAVEPOINT_ID; diff --git a/reactos/include/psdk/ntdef.h b/reactos/include/psdk/ntdef.h index fdc365085b2..a0aae3ec3a3 100644 --- a/reactos/include/psdk/ntdef.h +++ b/reactos/include/psdk/ntdef.h @@ -1,13 +1,15 @@ -#ifndef _NTDEF_ -#define _NTDEF_ +#ifndef _NTDEF_H +#define _NTDEF_H -/* Dependencies */ +// +// Dependencies +// #include #include #include #include -// FIXME: Shouldn't be included! +// FIXME: Should we include these here? #include #include @@ -22,8 +24,11 @@ typedef unsigned long POINTER_64; // FIXME! HACK!!! -/* Pseudo Modifiers for Input Parameters */ + +// +// Pseudo Modifiers for Input Parameters +// #ifndef IN #define IN #endif @@ -49,21 +54,29 @@ typedef unsigned long POINTER_64; // FIXME! HACK!!! #endif -/* Defines the "size" of an any-size array */ +// +// Defines the "size" of an any-size array +// #ifndef ANYSIZE_ARRAY #define ANYSIZE_ARRAY 1 #endif -/* Constant modifier */ +// +// Constant modifier +// #ifndef CONST #define CONST const #endif -/* TRUE/FALSE */ +// +// TRUE/FALSE +// #define FALSE 0 #define TRUE 1 -/* NULL/NULL64 */ +// +// NULL/NULL64 +// #ifndef NULL #ifdef __cplusplus #define NULL 0 @@ -72,8 +85,22 @@ typedef unsigned long POINTER_64; // FIXME! HACK!!! #define NULL ((void *)0) #define NULL64 ((void * POINTER_64)0) #endif -#endif /* NULL */ +#endif // NULL +typedef enum _EVENT_TYPE { + NotificationEvent, + SynchronizationEvent +} EVENT_TYPE; + +typedef enum _TIMER_TYPE { + NotificationTimer, + SynchronizationTimer +} TIMER_TYPE; + +typedef enum _WAIT_TYPE { + WaitAll, + WaitAny +} WAIT_TYPE; // // FIXME @@ -144,27 +171,35 @@ typedef unsigned long POINTER_64; // FIXME! HACK!!! #define ARGUMENT_PRESENT(ArgumentPointer) \ ((CHAR*)((ULONG_PTR)(ArgumentPointer)) != (CHAR*)NULL) -/* Returns the base address of a structure from a structure member */ +// +// Returns the base address of a structure from a structure member +// #ifndef CONTAINING_RECORD #define CONTAINING_RECORD(address, type, field) \ ((type *)(((ULONG_PTR)address) - (ULONG_PTR)(&(((type *)0)->field)))) #endif -/* Returns the byte offset of the specified structure's member */ +// +// Returns the byte offset of the specified structure's member +// #ifndef __GNUC__ #define FIELD_OFFSET(Type, Field) ((LONG)(LONG_PTR)&(((Type*) 0)->Field)) #else #define FIELD_OFFSET(Type, Field) __builtin_offsetof(Type, Field) #endif -/* Returns the type's alignment */ +// +// Returns the type's alignment +// #if defined(_MSC_VER) && (_MSC_VER >= 1300) #define TYPE_ALIGNMENT(t) __alignof(t) #else #define TYPE_ALIGNMENT(t) FIELD_OFFSET( struct { char x; t test; }, test ) #endif -/* Calling Conventions */ +// +// Calling Conventions +// #if defined(_M_IX86) #define FASTCALL __fastcall #else @@ -173,13 +208,21 @@ typedef unsigned long POINTER_64; // FIXME! HACK!!! #define NTAPI __stdcall +// +// Used by the DDK exclusively , don't put in drivers +// +#define DDKAPI __stdcall // Use NTAPI instead +#define DDKCDECLAPI __cdecl // Just use __cdecl -/* Import and Export Specifiers */ +// +// Import and Export Specifiers +// -/* Done the same way as in windef.h for now */ +// Done the same way as in windef.h for now #define DECLSPEC_IMPORT __declspec(dllimport) #define DECLSPEC_NORETURN __declspec(noreturn) + #ifndef DECLSPEC_ADDRSAFE #if (_MSC_VER >= 1200) && (defined(_M_ALPHA) || defined(_M_AXP64)) #define DECLSPEC_ADDRSAFE __declspec(address_safe) @@ -200,7 +243,9 @@ typedef unsigned long POINTER_64; // FIXME! HACK!!! #endif #endif -/* Inlines */ +// +// Inlines +// #ifndef FORCEINLINE #if (_MSC_VER >= 1200) #define FORCEINLINE __forceinline @@ -227,7 +272,9 @@ typedef unsigned long POINTER_64; // FIXME! HACK!!! #define NTAPI_INLINE #endif -/* Use to specify structure alignment */ +// +// Use to specify structure alignment +// #ifndef DECLSPEC_ALIGN #if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(MIDL_PASS) #define DECLSPEC_ALIGN(x) __declspec(align(x)) @@ -238,13 +285,21 @@ typedef unsigned long POINTER_64; // FIXME! HACK!!! #endif #endif -/* Use to silence unused variable warnings when it is intentional */ + + +// +// Use to silence unused variable warnings when it is intentional +// #define UNREFERENCED_PARAMETER(P) {(P)=(P);} #define UNREFERENCED_LOCAL_VARIABLE(L) {(L)=(L);} #define DBG_UNREFERENCED_PARAMETER(P) #define DBG_UNREFERENCED_LOCAL_VARIABLE(L) -/* min/max helper macros */ + + +// +// min/max helper macros +// #ifndef NOMINMAX #ifndef min @@ -255,17 +310,25 @@ typedef unsigned long POINTER_64; // FIXME! HACK!!! #define max(a,b) (((a) > (b)) ? (a) : (b)) #endif -#endif /* NOMINMAX */ +#endif // NOMINMAX -/* Tell windef.h that we have defined some basic types */ + + +// +// Tell windef.h that we have defined some basic types +// #define BASETYPES -/* Void Pointers */ +// +// Void Pointers +// typedef void *PVOID; //typedef void * POINTER_64 PVOID64; typedef PVOID PVOID64; // FIXME! -/* Handle Type */ +// +// Handle Type +// #ifdef STRICT typedef void *HANDLE; #define DECLARE_HANDLE(n) typedef struct n##__{int i;}*n @@ -275,7 +338,9 @@ typedef PVOID HANDLE; #endif typedef HANDLE *PHANDLE; -/* Upper-Case Versions of Some Standard C Types */ +// +// Upper-Case Versions of Some Standard C Types +// #ifndef VOID #define VOID void typedef char CHAR; @@ -287,25 +352,47 @@ typedef int INT; #endif typedef double DOUBLE; -/* Unsigned Types */ +// +// Used to store a non-float 8 byte aligned structure +// +typedef struct _QUAD +{ + _ANONYMOUS_UNION union + { + __GNU_EXTENSION __int64 UseThisFieldToCopy; + double DoNotUseThisField; + }; +} QUAD, *PQUAD, UQUAD, *PUQUAD; + + +// +// Unsigned Types +// typedef unsigned char UCHAR, *PUCHAR; typedef unsigned short USHORT, *PUSHORT; typedef unsigned long ULONG, *PULONG; typedef CONST UCHAR *PCUCHAR; typedef CONST USHORT *PCUSHORT; typedef CONST ULONG *PCULONG; + typedef UCHAR FCHAR; typedef USHORT FSHORT; typedef ULONG FLONG; -typedef UCHAR BOOLEAN, *PBOOLEAN; +typedef UCHAR BOOLEAN; +typedef BOOLEAN *PBOOLEAN; + typedef ULONG LOGICAL; typedef ULONG *PLOGICAL; -/* Signed Types */ +// +// Signed Types +// typedef SHORT *PSHORT; typedef LONG *PLONG; + typedef LONG NTSTATUS; typedef NTSTATUS *PNTSTATUS; + typedef signed char SCHAR; typedef SCHAR *PSCHAR; @@ -314,15 +401,22 @@ typedef SCHAR *PSCHAR; typedef LONG HRESULT; #endif -/* 64-bit types */ +// +// 64-bit types +// __GNU_EXTENSION typedef __int64 LONGLONG, *PLONGLONG; __GNU_EXTENSION typedef unsigned __int64 ULONGLONG, *PULONGLONG; typedef ULONGLONG DWORDLONG, *PDWORDLONG; -/* Update Sequence Number */ +// +// Update Sequence Number +// typedef LONGLONG USN; -/* ANSI (Multi-byte Character) types */ + +// +// ANSI (Multi-byte Character) types +// typedef CHAR *PCHAR, *LPCH, *PCH; typedef CONST CHAR *LPCCH, *PCCH; typedef CHAR *NPSTR, *LPSTR, *PSTR; @@ -331,11 +425,15 @@ typedef CONST PSTR *PCZPSTR; typedef CONST CHAR *LPCSTR, *PCSTR; typedef PCSTR *PZPCSTR; -/* Pointer to an Asciiz string */ +// +// Pointer to an Asciiz string +// typedef CHAR *PSZ; typedef CONST char *PCSZ; -/* UNICODE (Wide Character) types */ +// +// UNICODE (Wide Character) types +// typedef wchar_t WCHAR; typedef WCHAR *PWCHAR, *LPWCH, *PWCH; typedef CONST WCHAR *LPCWCH, *PCWCH; @@ -347,27 +445,25 @@ typedef CONST WCHAR *LPCWSTR, *PCWSTR; typedef PCWSTR *PZPCWSTR; typedef CONST WCHAR UNALIGNED *LPCUWSTR, *PCUWSTR; -/* Cardinal Data Types */ +// +// Cardinal Data Types +// typedef char CCHAR, *PCCHAR; typedef short CSHORT, *PCSHORT; typedef ULONG CLONG, *PCLONG; -/* NLS basics (Locale and Language Ids) */ +// +// NLS basics (Locale and Language Ids) +// typedef ULONG LCID; typedef PULONG PLCID; typedef USHORT LANGID; -/* Used to store a non-float 8 byte aligned structure */ -typedef struct _QUAD -{ - _ANONYMOUS_UNION union - { - __GNU_EXTENSION __int64 UseThisFieldToCopy; - double DoNotUseThisField; - } DUMMYUNIONNAME; -} QUAD, *PQUAD, UQUAD, *PUQUAD; -/* Large Integer Unions */ + +// +// Large Integer Unions +// #if defined(MIDL_PASS) typedef struct _LARGE_INTEGER { #else @@ -382,7 +478,7 @@ typedef union _LARGE_INTEGER { ULONG LowPart; LONG HighPart; } u; -#endif /* MIDL_PASS */ +#endif //MIDL_PASS LONGLONG QuadPart; } LARGE_INTEGER, *PLARGE_INTEGER; @@ -400,26 +496,40 @@ typedef union _ULARGE_INTEGER { ULONG LowPart; ULONG HighPart; } u; -#endif /* MIDL_PASS */ +#endif //MIDL_PASS ULONGLONG QuadPart; } ULARGE_INTEGER, *PULARGE_INTEGER; -/* Physical Addresses are always treated as 64-bit wide */ +// +// Physical Addresses are always treated as 64-bit wide +// typedef LARGE_INTEGER PHYSICAL_ADDRESS, *PPHYSICAL_ADDRESS; -/* Locally Unique Identifier */ + + +// +// Locally Unique Identifier +// typedef struct _LUID { ULONG LowPart; LONG HighPart; } LUID, *PLUID; -/* Native API Return Value Macros */ + + +// +// Native API Return Value Macros +// #define NT_SUCCESS(Status) (((NTSTATUS)(Status)) >= 0) #define NT_INFORMATION(Status) ((((ULONG)(Status)) >> 30) == 1) #define NT_WARNING(Status) ((((ULONG)(Status)) >> 30) == 2) #define NT_ERROR(Status) ((((ULONG)(Status)) >> 30) == 3) -/* String Types */ + + +// +// String Types +// typedef struct _UNICODE_STRING { USHORT Length; USHORT MaximumLength; @@ -465,7 +575,9 @@ typedef struct _STRING64 { UNICODE_STRING64, *PUNICODE_STRING64, ANSI_STRING64, *PANSI_STRING64; -/* LangID and NLS */ +// +// LangID and NLS +// #define MAKELANGID(p, s) ((((USHORT)(s)) << 10) | (USHORT)(p)) #define PRIMARYLANGID(lgid) ((USHORT)(lgid) & 0x3ff) #define SUBLANGID(lgid) ((USHORT)(lgid) >> 10) @@ -482,7 +594,10 @@ typedef struct _STRING64 { #define SORTVERSIONFROMLCID(lcid) ((USHORT)((((ULONG)(lcid)) >> 20) & 0xf)) -/* Object Attributes */ + +// +// Object Attributes +// typedef struct _OBJECT_ATTRIBUTES { ULONG Length; HANDLE RootDirectory; @@ -493,7 +608,9 @@ typedef struct _OBJECT_ATTRIBUTES { } OBJECT_ATTRIBUTES, *POBJECT_ATTRIBUTES; typedef CONST OBJECT_ATTRIBUTES *PCOBJECT_ATTRIBUTES; -/* Values for the Attributes member */ +// +// Values for the Attributes member +// #define OBJ_INHERIT 0x00000002 #define OBJ_PERMANENT 0x00000010 #define OBJ_EXCLUSIVE 0x00000020 @@ -504,7 +621,9 @@ typedef CONST OBJECT_ATTRIBUTES *PCOBJECT_ATTRIBUTES; #define OBJ_FORCE_ACCESS_CHECK 0x00000400 #define OBJ_VALID_ATTRIBUTES 0x000007F2 -/* Helper Macro */ +// +// Helper Macro +// #define InitializeObjectAttributes(p,n,a,r,s) { \ (p)->Length = sizeof(OBJECT_ATTRIBUTES); \ (p)->RootDirectory = (r); \ @@ -514,29 +633,22 @@ typedef CONST OBJECT_ATTRIBUTES *PCOBJECT_ATTRIBUTES; (p)->SecurityQualityOfService = NULL; \ } -/* Product Types */ + + +// +// Product Types +// typedef enum _NT_PRODUCT_TYPE { NtProductWinNt = 1, NtProductLanManNt, NtProductServer } NT_PRODUCT_TYPE, *PNT_PRODUCT_TYPE; -typedef enum _EVENT_TYPE { - NotificationEvent, - SynchronizationEvent -} EVENT_TYPE; -typedef enum _TIMER_TYPE { - NotificationTimer, - SynchronizationTimer -} TIMER_TYPE; -typedef enum _WAIT_TYPE { - WaitAll, - WaitAny -} WAIT_TYPE; - -/* Doubly Linked Lists */ +// +// Doubly Linked Lists +// typedef struct _LIST_ENTRY { struct _LIST_ENTRY *Flink; struct _LIST_ENTRY *Blink; @@ -554,11 +666,14 @@ typedef struct LIST_ENTRY64 ULONGLONG Blink; } LIST_ENTRY64, *PLIST_ENTRY64; -/* Singly Linked Lists */ +// +// Singly Linked Lists +// typedef struct _SINGLE_LIST_ENTRY { struct _SINGLE_LIST_ENTRY *Next; } SINGLE_LIST_ENTRY, *PSINGLE_LIST_ENTRY; + typedef struct _PROCESSOR_NUMBER { USHORT Group; UCHAR Number; @@ -566,19 +681,16 @@ typedef struct _PROCESSOR_NUMBER { } PROCESSOR_NUMBER, *PPROCESSOR_NUMBER; typedef EXCEPTION_DISPOSITION -(NTAPI *PEXCEPTION_ROUTINE)( +(DDKAPI *PEXCEPTION_ROUTINE)( IN struct _EXCEPTION_RECORD *ExceptionRecord, IN PVOID EstablisherFrame, IN OUT struct _CONTEXT *ContextRecord, IN OUT PVOID DispatcherContext); -typedef struct _GROUP_AFFINITY { - KAFFINITY Mask; - USHORT Group; - USHORT Reserved[3]; -} GROUP_AFFINITY, *PGROUP_AFFINITY; -/* Helper Macros */ +// +// Helper Macros +// #define RTL_CONSTANT_STRING(s) { sizeof(s)-sizeof((s)[0]), sizeof(s), s } #define RTL_FIELD_SIZE(type, field) (sizeof(((type *)0)->field)) @@ -592,7 +704,11 @@ typedef struct _GROUP_AFFINITY { #endif #define ARRAYSIZE(A) RTL_NUMBER_OF_V2(A) -/* Type Limits */ + + +// +// Type Limits +// #define MINCHAR 0x80 #define MAXCHAR 0x7f #define MINSHORT 0x8000 @@ -604,17 +720,29 @@ typedef struct _GROUP_AFFINITY { #define MAXULONG 0xffffffff #define MAXLONGLONG (0x7fffffffffffffffLL) -/* Multiplication and Shift Operations */ + + +// +// Multiplication and Shift Operations +// #define Int32x32To64(a,b) ((LONGLONG)(a)*(LONGLONG)(b)) #define UInt32x32To64(a,b) ((DWORDLONG)(a)*(DWORDLONG)(b)) #define Int64ShllMod32(a,b) ((DWORDLONG)(a)<<(b)) #define Int64ShraMod32(a,b) ((LONGLONG)(a)>>(b)) #define Int64ShrlMod32(a,b) ((DWORDLONG)(a)>>(b)) -/* C_ASSERT Definition */ + + +// +// C_ASSERT Definition +// #define C_ASSERT(expr) extern char (*c_assert(void)) [(expr) ? 1 : -1] -/* Primary language IDs. */ + + +// +// Primary language IDs. +// #define LANG_NEUTRAL 0x00 #define LANG_INVARIANT 0x7f @@ -745,4 +873,6 @@ typedef struct _GROUP_AFFINITY { #define LANG_YORUBA 0x6a #define LANG_ZULU 0x35 -#endif /* _NTDEF_ */ + + +#endif /* _NTDEF_H */ diff --git a/reactos/include/psdk/winnt.h b/reactos/include/psdk/winnt.h index f856b079970..bd0fac136b9 100644 --- a/reactos/include/psdk/winnt.h +++ b/reactos/include/psdk/winnt.h @@ -3411,12 +3411,6 @@ typedef LONG struct _EXCEPTION_POINTERS *ExceptionInfo ); -typedef struct _GROUP_AFFINITY { - KAFFINITY Mask; - WORD Group; - WORD Reserved[3]; -} GROUP_AFFINITY, *PGROUP_AFFINITY; - typedef struct _EVENTLOGRECORD { DWORD Length; DWORD Reserved; diff --git a/reactos/ntoskrnl/include/ntoskrnl.h b/reactos/ntoskrnl/include/ntoskrnl.h index 3b56d34afac..f1052ed38df 100644 --- a/reactos/ntoskrnl/include/ntoskrnl.h +++ b/reactos/ntoskrnl/include/ntoskrnl.h @@ -19,6 +19,7 @@ /* DDK/IFS/NDK Headers */ #define _REALLY_GET_CALLERS_CALLER +#define SINGLE_GROUP_LEGACY_API #include #include #include diff --git a/reactos/ntoskrnl/mm/mminit.c b/reactos/ntoskrnl/mm/mminit.c index 8a9fd4297c3..6a3492415c0 100644 --- a/reactos/ntoskrnl/mm/mminit.c +++ b/reactos/ntoskrnl/mm/mminit.c @@ -48,7 +48,7 @@ MemType[] = "LoaderXIPRom " }; -BOOLEAN Mm64BitPhysicalAddress = FALSE; +PBOOLEAN Mm64BitPhysicalAddress = FALSE; ULONG MmReadClusterSize; // // 0 | 1 is on/off paging, 2 is undocumented From 07c9b89e4898648c5c937b9551826efc5d03a91b Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 29 Mar 2010 04:28:32 +0000 Subject: [PATCH 077/134] Move SINGLE_GROUP_LEGACY_API definition to wdm.h svn path=/trunk/; revision=46555 --- reactos/include/ddk/wdm.h | 4 ++++ reactos/ntoskrnl/include/ntoskrnl.h | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/reactos/include/ddk/wdm.h b/reactos/include/ddk/wdm.h index 7e97ea08c1d..74dbadfd52f 100644 --- a/reactos/include/ddk/wdm.h +++ b/reactos/include/ddk/wdm.h @@ -466,6 +466,10 @@ typedef enum _MODE { MaximumMode } MODE; +#if (NTDDI_VERSION < NTDDI_WIN7) || defined(_X86_) || !defined(NT_PROCESSOR_GROUPS) +#define SINGLE_GROUP_LEGACY_API 1 +#endif + /* Processor features */ #define PF_FLOATING_POINT_PRECISION_ERRATA 0 #define PF_FLOATING_POINT_EMULATED 1 diff --git a/reactos/ntoskrnl/include/ntoskrnl.h b/reactos/ntoskrnl/include/ntoskrnl.h index f1052ed38df..3b56d34afac 100644 --- a/reactos/ntoskrnl/include/ntoskrnl.h +++ b/reactos/ntoskrnl/include/ntoskrnl.h @@ -19,7 +19,6 @@ /* DDK/IFS/NDK Headers */ #define _REALLY_GET_CALLERS_CALLER -#define SINGLE_GROUP_LEGACY_API #include #include #include From 77d69ff4d98f4101f08269e4664154cf5599ebef Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 29 Mar 2010 04:49:07 +0000 Subject: [PATCH 078/134] Fix Mm64BitPhysicalAddress svn path=/trunk/; revision=46556 --- reactos/ntoskrnl/mm/mminit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/ntoskrnl/mm/mminit.c b/reactos/ntoskrnl/mm/mminit.c index 6a3492415c0..8a9fd4297c3 100644 --- a/reactos/ntoskrnl/mm/mminit.c +++ b/reactos/ntoskrnl/mm/mminit.c @@ -48,7 +48,7 @@ MemType[] = "LoaderXIPRom " }; -PBOOLEAN Mm64BitPhysicalAddress = FALSE; +BOOLEAN Mm64BitPhysicalAddress = FALSE; ULONG MmReadClusterSize; // // 0 | 1 is on/off paging, 2 is undocumented From 10ba115855db4a8e474fe200c93dddccb30a4407 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 29 Mar 2010 05:03:20 +0000 Subject: [PATCH 079/134] Add definition of PUOW to wdm.h svn path=/trunk/; revision=46557 --- reactos/include/ddk/bdasup.h | 155 ++++++++++++++++---------------- reactos/include/ddk/wdm.h | 4 + reactos/include/psdk/ktmtypes.h | 3 + 3 files changed, 86 insertions(+), 76 deletions(-) diff --git a/reactos/include/ddk/bdasup.h b/reactos/include/ddk/bdasup.h index 0bdd590d337..b74e8ab7e4f 100644 --- a/reactos/include/ddk/bdasup.h +++ b/reactos/include/ddk/bdasup.h @@ -2,7 +2,7 @@ extern "C" { #endif -/* Helper macro to enable gcc's extension. */ +/* Helper macro to enable gcc's extension. */ #ifndef __GNU_EXTENSION #ifdef __GNUC__ #define __GNU_EXTENSION __extension__ @@ -12,39 +12,42 @@ extern "C" { #endif #define STDMETHODCALLTYPE __stdcall + +#ifndef _WDMDDK_ typedef GUID *PGUID; +#endif /* Types */ typedef struct _BDA_PIN_PAIRING { - ULONG ulInputPin; - ULONG ulOutputPin; - ULONG ulcMaxInputsPerOutput; - ULONG ulcMinInputsPerOutput; - ULONG ulcMaxOutputsPerInput; - ULONG ulcMinOutputsPerInput; - ULONG ulcTopologyJoints; - const ULONG *pTopologyJoints; + ULONG ulInputPin; + ULONG ulOutputPin; + ULONG ulcMaxInputsPerOutput; + ULONG ulcMinInputsPerOutput; + ULONG ulcMaxOutputsPerInput; + ULONG ulcMinOutputsPerInput; + ULONG ulcTopologyJoints; + const ULONG *pTopologyJoints; } BDA_PIN_PAIRING, *PBDA_PIN_PAIRING; typedef struct _BDA_FILTER_TEMPLATE { - const KSFILTER_DESCRIPTOR *pFilterDescriptor; - ULONG ulcPinPairs; - const BDA_PIN_PAIRING *pPinPairs; + const KSFILTER_DESCRIPTOR *pFilterDescriptor; + ULONG ulcPinPairs; + const BDA_PIN_PAIRING *pPinPairs; } BDA_FILTER_TEMPLATE, *PBDA_FILTER_TEMPLATE; typedef struct _KSM_PIN { - KSMETHOD Method; + KSMETHOD Method; __GNU_EXTENSION union { - ULONG PinId; - ULONG PinType; - }; - ULONG Reserved; + ULONG PinId; + ULONG PinType; + }; + ULONG Reserved; } KSM_PIN, * PKSM_PIN; /* Functions */ @@ -53,108 +56,108 @@ STDMETHODIMP_(NTSTATUS) BdaCheckChanges(IN PIRP Irp); STDMETHODIMP_(NTSTATUS) BdaCommitChanges(IN PIRP Irp); STDMETHODIMP_(NTSTATUS) BdaCreateFilterFactory( - IN PKSDEVICE pKSDevice, - IN const KSFILTER_DESCRIPTOR *pFilterDescriptor, - IN const BDA_FILTER_TEMPLATE *pBdaFilterTemplate); + IN PKSDEVICE pKSDevice, + IN const KSFILTER_DESCRIPTOR *pFilterDescriptor, + IN const BDA_FILTER_TEMPLATE *pBdaFilterTemplate); STDMETHODIMP_(NTSTATUS) BdaCreateFilterFactoryEx( - IN PKSDEVICE pKSDevice, - IN const KSFILTER_DESCRIPTOR *pFilterDescriptor, - IN const BDA_FILTER_TEMPLATE *pBdaFilterTemplate, - OUT PKSFILTERFACTORY *ppKSFilterFactory); + IN PKSDEVICE pKSDevice, + IN const KSFILTER_DESCRIPTOR *pFilterDescriptor, + IN const BDA_FILTER_TEMPLATE *pBdaFilterTemplate, + OUT PKSFILTERFACTORY *ppKSFilterFactory); STDMETHODIMP_(NTSTATUS) BdaCreatePin( - IN PKSFILTER pKSFilter, - IN ULONG ulPinType, - OUT ULONG *pulPinId); + IN PKSFILTER pKSFilter, + IN ULONG ulPinType, + OUT ULONG *pulPinId); STDMETHODIMP_(NTSTATUS) BdaCreateTopology( - IN PKSFILTER pKSFilter, - IN ULONG InputPinId, - IN ULONG OutputPinId); + IN PKSFILTER pKSFilter, + IN ULONG InputPinId, + IN ULONG OutputPinId); STDMETHODIMP_(NTSTATUS) BdaDeletePin( - IN PKSFILTER pKSFilter, - IN ULONG *pulPinId); + IN PKSFILTER pKSFilter, + IN ULONG *pulPinId); STDMETHODIMP_(NTSTATUS) BdaFilterFactoryUpdateCacheData( - IN PKSFILTERFACTORY pFilterFactory, - IN const KSFILTER_DESCRIPTOR *pFilterDescriptor OPTIONAL); + IN PKSFILTERFACTORY pFilterFactory, + IN const KSFILTER_DESCRIPTOR *pFilterDescriptor OPTIONAL); STDMETHODIMP_(NTSTATUS) BdaGetChangeState( - IN PIRP Irp, - OUT BDA_CHANGE_STATE *pChangeState); + IN PIRP Irp, + OUT BDA_CHANGE_STATE *pChangeState); STDMETHODIMP_(NTSTATUS) BdaInitFilter( - IN PKSFILTER pKSFilter, - IN const BDA_FILTER_TEMPLATE *pBdaFilterTemplate); + IN PKSFILTER pKSFilter, + IN const BDA_FILTER_TEMPLATE *pBdaFilterTemplate); STDMETHODIMP_(NTSTATUS) BdaMethodCreatePin( - IN PIRP Irp, - IN KSMETHOD *pKSMethod, - OUT ULONG *pulPinFactoryID); + IN PIRP Irp, + IN KSMETHOD *pKSMethod, + OUT ULONG *pulPinFactoryID); STDMETHODIMP_(NTSTATUS) BdaMethodCreateTopology( - IN PIRP Irp, - IN KSMETHOD *pKSMethod, - OPTIONAL PVOID pvIgnored); + IN PIRP Irp, + IN KSMETHOD *pKSMethod, + OPTIONAL PVOID pvIgnored); STDMETHODIMP_(NTSTATUS) BdaMethodDeletePin( - IN PIRP Irp, - IN KSMETHOD *pKSMethod, - OPTIONAL PVOID pvIgnored); + IN PIRP Irp, + IN KSMETHOD *pKSMethod, + OPTIONAL PVOID pvIgnored); STDMETHODIMP_(NTSTATUS) BdaPropertyGetControllingPinId( - IN PIRP Irp, - IN KSP_BDA_NODE_PIN *pProperty, - OUT ULONG *pulControllingPinId); + IN PIRP Irp, + IN KSP_BDA_NODE_PIN *pProperty, + OUT ULONG *pulControllingPinId); STDMETHODIMP_(NTSTATUS) BdaPropertyGetPinControl( - IN PIRP Irp, - IN KSPROPERTY *pKSProperty, - OUT ULONG *pulProperty); + IN PIRP Irp, + IN KSPROPERTY *pKSProperty, + OUT ULONG *pulProperty); STDMETHODIMP_(NTSTATUS) BdaPropertyNodeDescriptors( - IN PIRP Irp, - IN KSPROPERTY *pKSProperty, - OUT BDANODE_DESCRIPTOR *pNodeDescriptorProperty); + IN PIRP Irp, + IN KSPROPERTY *pKSProperty, + OUT BDANODE_DESCRIPTOR *pNodeDescriptorProperty); STDMETHODIMP_(NTSTATUS) BdaPropertyNodeEvents( - IN PIRP Irp, - IN KSP_NODE *pKSProperty, - OUT GUID *pguidProperty); + IN PIRP Irp, + IN KSP_NODE *pKSProperty, + OUT GUID *pguidProperty); STDMETHODIMP_(NTSTATUS) BdaPropertyNodeMethods( - IN PIRP Irp, - IN KSP_NODE *pKSProperty, - OUT GUID *pguidProperty); + IN PIRP Irp, + IN KSP_NODE *pKSProperty, + OUT GUID *pguidProperty); STDMETHODIMP_(NTSTATUS) BdaPropertyNodeProperties( - IN PIRP Irp, - IN KSP_NODE *pKSProperty, - OUT GUID *pguidProperty); + IN PIRP Irp, + IN KSP_NODE *pKSProperty, + OUT GUID *pguidProperty); STDMETHODIMP_(NTSTATUS) BdaPropertyNodeTypes( - IN PIRP Irp, - IN KSPROPERTY *pKSProperty, - OUT ULONG *pulProperty); + IN PIRP Irp, + IN KSPROPERTY *pKSProperty, + OUT ULONG *pulProperty); STDMETHODIMP_(NTSTATUS) BdaPropertyPinTypes( - IN PIRP Irp, - IN KSPROPERTY *pKSProperty, - OUT ULONG *pulProperty); + IN PIRP Irp, + IN KSPROPERTY *pKSProperty, + OUT ULONG *pulProperty); STDMETHODIMP_(NTSTATUS) BdaPropertyTemplateConnections( - IN PIRP Irp, - IN KSPROPERTY *pKSProperty, - OUT KSTOPOLOGY_CONNECTION *pConnectionProperty); + IN PIRP Irp, + IN KSPROPERTY *pKSProperty, + OUT KSTOPOLOGY_CONNECTION *pConnectionProperty); STDMETHODIMP_(NTSTATUS) BdaStartChanges(IN PIRP Irp); STDMETHODIMP_(NTSTATUS) BdaUninitFilter(IN PKSFILTER pKSFilter); STDMETHODIMP_(NTSTATUS) BdaValidateNodeProperty( - IN PIRP Irp, - IN KSPROPERTY *pKSProperty); + IN PIRP Irp, + IN KSPROPERTY *pKSProperty); #if defined(__cplusplus) } diff --git a/reactos/include/ddk/wdm.h b/reactos/include/ddk/wdm.h index 74dbadfd52f..526069d8bee 100644 --- a/reactos/include/ddk/wdm.h +++ b/reactos/include/ddk/wdm.h @@ -43,6 +43,10 @@ #include #endif /* GUID_DEFINED */ +#ifndef _KTMTYPES_ +typedef GUID UOW, *PUOW; +#endif + #if (NTDDI_VERSION >= NTDDI_WINXP) #include #endif diff --git a/reactos/include/psdk/ktmtypes.h b/reactos/include/psdk/ktmtypes.h index 77cf5782858..90b042f3f0b 100644 --- a/reactos/include/psdk/ktmtypes.h +++ b/reactos/include/psdk/ktmtypes.h @@ -72,7 +72,10 @@ #define MAX_TRANSACTION_DESCRIPTION_LENGTH 64 #define MAX_RESOURCEMANAGER_DESCRIPTION_LENGTH 64 +#ifndef _WDMDDK_ typedef GUID UOW, *PUOW; +#endif + typedef GUID CRM_PROTOCOL_ID, *PCRM_PROTOCOL_ID; typedef ULONG NOTIFICATION_MASK; typedef ULONG SAVEPOINT_ID, *PSAVEPOINT_ID; From e6421edfc93b6b42b8dd793c712282b530c83bb8 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 29 Mar 2010 05:17:15 +0000 Subject: [PATCH 080/134] Merge bdasup.h svn path=/trunk/; revision=46558 --- reactos/include/ddk/bdasup.h | 109 ++++++++++++++++++++++++----------- 1 file changed, 75 insertions(+), 34 deletions(-) diff --git a/reactos/include/ddk/bdasup.h b/reactos/include/ddk/bdasup.h index b74e8ab7e4f..373ccdbdcbf 100644 --- a/reactos/include/ddk/bdasup.h +++ b/reactos/include/ddk/bdasup.h @@ -1,3 +1,7 @@ +#pragma once + +#if (NTDDI_VERSION >= NTDDI_WINXP) + #if defined(__cplusplus) extern "C" { #endif @@ -19,8 +23,9 @@ typedef GUID *PGUID; /* Types */ -typedef struct _BDA_PIN_PAIRING -{ +typedef ULONG BDA_TOPOLOGY_JOINT, *PBDA_TOPOLOGY_JOINT; + +typedef struct _BDA_PIN_PAIRING { ULONG ulInputPin; ULONG ulOutputPin; ULONG ulcMaxInputsPerOutput; @@ -31,19 +36,22 @@ typedef struct _BDA_PIN_PAIRING const ULONG *pTopologyJoints; } BDA_PIN_PAIRING, *PBDA_PIN_PAIRING; -typedef struct _BDA_FILTER_TEMPLATE -{ +typedef struct _BDA_FILTER_TEMPLATE { const KSFILTER_DESCRIPTOR *pFilterDescriptor; ULONG ulcPinPairs; const BDA_PIN_PAIRING *pPinPairs; } BDA_FILTER_TEMPLATE, *PBDA_FILTER_TEMPLATE; - -typedef struct _KSM_PIN -{ +typedef struct _KSM_PIN_PAIR { KSMETHOD Method; - __GNU_EXTENSION union - { + ULONG InputPinId; + ULONG OutputPinId; + ULONG Reserved; +} KSM_PIN_PAIR, * PKSM_PIN_PAIR; + +typedef struct _KSM_PIN { + KSMETHOD Method; + __GNU_EXTENSION union { ULONG PinId; ULONG PinType; }; @@ -52,113 +60,146 @@ typedef struct _KSM_PIN /* Functions */ -STDMETHODIMP_(NTSTATUS) BdaCheckChanges(IN PIRP Irp); -STDMETHODIMP_(NTSTATUS) BdaCommitChanges(IN PIRP Irp); +STDMETHODIMP_(NTSTATUS) +BdaCheckChanges( + IN PIRP Irp); -STDMETHODIMP_(NTSTATUS) BdaCreateFilterFactory( +STDMETHODIMP_(NTSTATUS) +BdaCommitChanges( + IN PIRP Irp); + +STDMETHODIMP_(NTSTATUS) +BdaCreateFilterFactory( IN PKSDEVICE pKSDevice, IN const KSFILTER_DESCRIPTOR *pFilterDescriptor, IN const BDA_FILTER_TEMPLATE *pBdaFilterTemplate); -STDMETHODIMP_(NTSTATUS) BdaCreateFilterFactoryEx( +STDMETHODIMP_(NTSTATUS) +BdaCreateFilterFactoryEx( IN PKSDEVICE pKSDevice, IN const KSFILTER_DESCRIPTOR *pFilterDescriptor, IN const BDA_FILTER_TEMPLATE *pBdaFilterTemplate, OUT PKSFILTERFACTORY *ppKSFilterFactory); -STDMETHODIMP_(NTSTATUS) BdaCreatePin( +STDMETHODIMP_(NTSTATUS) +BdaCreatePin( IN PKSFILTER pKSFilter, IN ULONG ulPinType, OUT ULONG *pulPinId); -STDMETHODIMP_(NTSTATUS) BdaCreateTopology( +STDMETHODIMP_(NTSTATUS) +BdaCreateTopology( IN PKSFILTER pKSFilter, IN ULONG InputPinId, IN ULONG OutputPinId); -STDMETHODIMP_(NTSTATUS) BdaDeletePin( +STDMETHODIMP_(NTSTATUS) +BdaDeletePin( IN PKSFILTER pKSFilter, IN ULONG *pulPinId); -STDMETHODIMP_(NTSTATUS) BdaFilterFactoryUpdateCacheData( +STDMETHODIMP_(NTSTATUS) +BdaFilterFactoryUpdateCacheData( IN PKSFILTERFACTORY pFilterFactory, IN const KSFILTER_DESCRIPTOR *pFilterDescriptor OPTIONAL); -STDMETHODIMP_(NTSTATUS) BdaGetChangeState( +STDMETHODIMP_(NTSTATUS) +BdaGetChangeState( IN PIRP Irp, OUT BDA_CHANGE_STATE *pChangeState); -STDMETHODIMP_(NTSTATUS) BdaInitFilter( +STDMETHODIMP_(NTSTATUS) +BdaInitFilter( IN PKSFILTER pKSFilter, IN const BDA_FILTER_TEMPLATE *pBdaFilterTemplate); -STDMETHODIMP_(NTSTATUS) BdaMethodCreatePin( +STDMETHODIMP_(NTSTATUS) +BdaMethodCreatePin( IN PIRP Irp, IN KSMETHOD *pKSMethod, OUT ULONG *pulPinFactoryID); -STDMETHODIMP_(NTSTATUS) BdaMethodCreateTopology( +STDMETHODIMP_(NTSTATUS) +BdaMethodCreateTopology( IN PIRP Irp, IN KSMETHOD *pKSMethod, OPTIONAL PVOID pvIgnored); -STDMETHODIMP_(NTSTATUS) BdaMethodDeletePin( +STDMETHODIMP_(NTSTATUS) +BdaMethodDeletePin( IN PIRP Irp, IN KSMETHOD *pKSMethod, OPTIONAL PVOID pvIgnored); -STDMETHODIMP_(NTSTATUS) BdaPropertyGetControllingPinId( +STDMETHODIMP_(NTSTATUS) +BdaPropertyGetControllingPinId( IN PIRP Irp, IN KSP_BDA_NODE_PIN *pProperty, OUT ULONG *pulControllingPinId); -STDMETHODIMP_(NTSTATUS) BdaPropertyGetPinControl( +STDMETHODIMP_(NTSTATUS) +BdaPropertyGetPinControl( IN PIRP Irp, IN KSPROPERTY *pKSProperty, OUT ULONG *pulProperty); -STDMETHODIMP_(NTSTATUS) BdaPropertyNodeDescriptors( +STDMETHODIMP_(NTSTATUS) +BdaPropertyNodeDescriptors( IN PIRP Irp, IN KSPROPERTY *pKSProperty, OUT BDANODE_DESCRIPTOR *pNodeDescriptorProperty); -STDMETHODIMP_(NTSTATUS) BdaPropertyNodeEvents( +STDMETHODIMP_(NTSTATUS) +BdaPropertyNodeEvents( IN PIRP Irp, IN KSP_NODE *pKSProperty, OUT GUID *pguidProperty); -STDMETHODIMP_(NTSTATUS) BdaPropertyNodeMethods( +STDMETHODIMP_(NTSTATUS) +BdaPropertyNodeMethods( IN PIRP Irp, IN KSP_NODE *pKSProperty, OUT GUID *pguidProperty); -STDMETHODIMP_(NTSTATUS) BdaPropertyNodeProperties( +STDMETHODIMP_(NTSTATUS) +BdaPropertyNodeProperties( IN PIRP Irp, IN KSP_NODE *pKSProperty, OUT GUID *pguidProperty); -STDMETHODIMP_(NTSTATUS) BdaPropertyNodeTypes( +STDMETHODIMP_(NTSTATUS) +BdaPropertyNodeTypes( IN PIRP Irp, IN KSPROPERTY *pKSProperty, OUT ULONG *pulProperty); -STDMETHODIMP_(NTSTATUS) BdaPropertyPinTypes( +STDMETHODIMP_(NTSTATUS) +BdaPropertyPinTypes( IN PIRP Irp, IN KSPROPERTY *pKSProperty, OUT ULONG *pulProperty); -STDMETHODIMP_(NTSTATUS) BdaPropertyTemplateConnections( +STDMETHODIMP_(NTSTATUS) +BdaPropertyTemplateConnections( IN PIRP Irp, IN KSPROPERTY *pKSProperty, OUT KSTOPOLOGY_CONNECTION *pConnectionProperty); -STDMETHODIMP_(NTSTATUS) BdaStartChanges(IN PIRP Irp); -STDMETHODIMP_(NTSTATUS) BdaUninitFilter(IN PKSFILTER pKSFilter); +STDMETHODIMP_(NTSTATUS) +BdaStartChanges( + IN PIRP Irp); -STDMETHODIMP_(NTSTATUS) BdaValidateNodeProperty( +STDMETHODIMP_(NTSTATUS) +BdaUninitFilter( + IN PKSFILTER pKSFilter); + +STDMETHODIMP_(NTSTATUS) +BdaValidateNodeProperty( IN PIRP Irp, IN KSPROPERTY *pKSProperty); #if defined(__cplusplus) } #endif + +#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ From 2076e91e49fa781d6d3a2c74cfef85a09c6888b5 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 29 Mar 2010 05:28:59 +0000 Subject: [PATCH 081/134] merge ntdef.h formatting changes svn path=/trunk/; revision=46559 --- reactos/include/psdk/ntdef.h | 233 ++++++++--------------------------- 1 file changed, 54 insertions(+), 179 deletions(-) diff --git a/reactos/include/psdk/ntdef.h b/reactos/include/psdk/ntdef.h index a0aae3ec3a3..3d7bf2b6129 100644 --- a/reactos/include/psdk/ntdef.h +++ b/reactos/include/psdk/ntdef.h @@ -1,15 +1,13 @@ #ifndef _NTDEF_H #define _NTDEF_H -// -// Dependencies -// +/* Dependencies */ #include #include #include #include -// FIXME: Should we include these here? +// FIXME: Shouldn't be included! #include #include @@ -24,11 +22,8 @@ typedef unsigned long POINTER_64; // FIXME! HACK!!! +/* Pseudo Modifiers for Input Parameters */ - -// -// Pseudo Modifiers for Input Parameters -// #ifndef IN #define IN #endif @@ -54,29 +49,21 @@ typedef unsigned long POINTER_64; // FIXME! HACK!!! #endif -// -// Defines the "size" of an any-size array -// +/* Defines the "size" of an any-size array */ #ifndef ANYSIZE_ARRAY #define ANYSIZE_ARRAY 1 #endif -// -// Constant modifier -// +/* Constant modifier */ #ifndef CONST #define CONST const #endif -// -// TRUE/FALSE -// +/* TRUE/FALSE */ #define FALSE 0 #define TRUE 1 -// -// NULL/NULL64 -// +/* NULL/NULL64 */ #ifndef NULL #ifdef __cplusplus #define NULL 0 @@ -85,7 +72,7 @@ typedef unsigned long POINTER_64; // FIXME! HACK!!! #define NULL ((void *)0) #define NULL64 ((void * POINTER_64)0) #endif -#endif // NULL +#endif /* NULL */ typedef enum _EVENT_TYPE { NotificationEvent, @@ -171,35 +158,27 @@ typedef enum _WAIT_TYPE { #define ARGUMENT_PRESENT(ArgumentPointer) \ ((CHAR*)((ULONG_PTR)(ArgumentPointer)) != (CHAR*)NULL) -// -// Returns the base address of a structure from a structure member -// +/* Returns the base address of a structure from a structure member */ #ifndef CONTAINING_RECORD #define CONTAINING_RECORD(address, type, field) \ ((type *)(((ULONG_PTR)address) - (ULONG_PTR)(&(((type *)0)->field)))) #endif -// -// Returns the byte offset of the specified structure's member -// +/* Returns the byte offset of the specified structure's member */ #ifndef __GNUC__ #define FIELD_OFFSET(Type, Field) ((LONG)(LONG_PTR)&(((Type*) 0)->Field)) #else #define FIELD_OFFSET(Type, Field) __builtin_offsetof(Type, Field) #endif -// -// Returns the type's alignment -// +/* Returns the type's alignment */ #if defined(_MSC_VER) && (_MSC_VER >= 1300) #define TYPE_ALIGNMENT(t) __alignof(t) #else #define TYPE_ALIGNMENT(t) FIELD_OFFSET( struct { char x; t test; }, test ) #endif -// -// Calling Conventions -// +/* Calling Conventions */ #if defined(_M_IX86) #define FASTCALL __fastcall #else @@ -214,15 +193,12 @@ typedef enum _WAIT_TYPE { #define DDKAPI __stdcall // Use NTAPI instead #define DDKCDECLAPI __cdecl // Just use __cdecl -// -// Import and Export Specifiers -// +/* Import and Export Specifiers */ -// Done the same way as in windef.h for now +/* Done the same way as in windef.h for now */ #define DECLSPEC_IMPORT __declspec(dllimport) #define DECLSPEC_NORETURN __declspec(noreturn) - #ifndef DECLSPEC_ADDRSAFE #if (_MSC_VER >= 1200) && (defined(_M_ALPHA) || defined(_M_AXP64)) #define DECLSPEC_ADDRSAFE __declspec(address_safe) @@ -243,9 +219,7 @@ typedef enum _WAIT_TYPE { #endif #endif -// -// Inlines -// +/* Inlines */ #ifndef FORCEINLINE #if (_MSC_VER >= 1200) #define FORCEINLINE __forceinline @@ -272,9 +246,7 @@ typedef enum _WAIT_TYPE { #define NTAPI_INLINE #endif -// -// Use to specify structure alignment -// +/* Use to specify structure alignment */ #ifndef DECLSPEC_ALIGN #if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(MIDL_PASS) #define DECLSPEC_ALIGN(x) __declspec(align(x)) @@ -285,21 +257,13 @@ typedef enum _WAIT_TYPE { #endif #endif - - -// -// Use to silence unused variable warnings when it is intentional -// +/* Use to silence unused variable warnings when it is intentional */ #define UNREFERENCED_PARAMETER(P) {(P)=(P);} #define UNREFERENCED_LOCAL_VARIABLE(L) {(L)=(L);} #define DBG_UNREFERENCED_PARAMETER(P) #define DBG_UNREFERENCED_LOCAL_VARIABLE(L) - - -// -// min/max helper macros -// +/* min/max helper macros */ #ifndef NOMINMAX #ifndef min @@ -310,25 +274,17 @@ typedef enum _WAIT_TYPE { #define max(a,b) (((a) > (b)) ? (a) : (b)) #endif -#endif // NOMINMAX +#endif /* NOMINMAX */ - - -// -// Tell windef.h that we have defined some basic types -// +/* Tell windef.h that we have defined some basic types */ #define BASETYPES -// -// Void Pointers -// +/* Void Pointers */ typedef void *PVOID; //typedef void * POINTER_64 PVOID64; typedef PVOID PVOID64; // FIXME! -// -// Handle Type -// +/* Handle Type */ #ifdef STRICT typedef void *HANDLE; #define DECLARE_HANDLE(n) typedef struct n##__{int i;}*n @@ -338,9 +294,7 @@ typedef PVOID HANDLE; #endif typedef HANDLE *PHANDLE; -// -// Upper-Case Versions of Some Standard C Types -// +/* Upper-Case Versions of Some Standard C Types */ #ifndef VOID #define VOID void typedef char CHAR; @@ -365,34 +319,25 @@ typedef struct _QUAD } QUAD, *PQUAD, UQUAD, *PUQUAD; -// -// Unsigned Types -// +/* Unsigned Types */ typedef unsigned char UCHAR, *PUCHAR; typedef unsigned short USHORT, *PUSHORT; typedef unsigned long ULONG, *PULONG; typedef CONST UCHAR *PCUCHAR; typedef CONST USHORT *PCUSHORT; typedef CONST ULONG *PCULONG; - typedef UCHAR FCHAR; typedef USHORT FSHORT; typedef ULONG FLONG; -typedef UCHAR BOOLEAN; -typedef BOOLEAN *PBOOLEAN; - +typedef UCHAR BOOLEAN, *PBOOLEAN; typedef ULONG LOGICAL; typedef ULONG *PLOGICAL; -// -// Signed Types -// +/* Signed Types */ typedef SHORT *PSHORT; typedef LONG *PLONG; - typedef LONG NTSTATUS; typedef NTSTATUS *PNTSTATUS; - typedef signed char SCHAR; typedef SCHAR *PSCHAR; @@ -401,22 +346,15 @@ typedef SCHAR *PSCHAR; typedef LONG HRESULT; #endif -// -// 64-bit types -// +/* 64-bit types */ __GNU_EXTENSION typedef __int64 LONGLONG, *PLONGLONG; __GNU_EXTENSION typedef unsigned __int64 ULONGLONG, *PULONGLONG; typedef ULONGLONG DWORDLONG, *PDWORDLONG; -// -// Update Sequence Number -// +/* Update Sequence Number */ typedef LONGLONG USN; - -// -// ANSI (Multi-byte Character) types -// +/* ANSI (Multi-byte Character) types */ typedef CHAR *PCHAR, *LPCH, *PCH; typedef CONST CHAR *LPCCH, *PCCH; typedef CHAR *NPSTR, *LPSTR, *PSTR; @@ -425,15 +363,11 @@ typedef CONST PSTR *PCZPSTR; typedef CONST CHAR *LPCSTR, *PCSTR; typedef PCSTR *PZPCSTR; -// -// Pointer to an Asciiz string -// +/* Pointer to an Asciiz string */ typedef CHAR *PSZ; typedef CONST char *PCSZ; -// -// UNICODE (Wide Character) types -// +/* UNICODE (Wide Character) types */ typedef wchar_t WCHAR; typedef WCHAR *PWCHAR, *LPWCH, *PWCH; typedef CONST WCHAR *LPCWCH, *PCWCH; @@ -445,25 +379,18 @@ typedef CONST WCHAR *LPCWSTR, *PCWSTR; typedef PCWSTR *PZPCWSTR; typedef CONST WCHAR UNALIGNED *LPCUWSTR, *PCUWSTR; -// -// Cardinal Data Types -// +/* Cardinal Data Types */ typedef char CCHAR, *PCCHAR; typedef short CSHORT, *PCSHORT; typedef ULONG CLONG, *PCLONG; -// -// NLS basics (Locale and Language Ids) -// +/* NLS basics (Locale and Language Ids) */ typedef ULONG LCID; typedef PULONG PLCID; typedef USHORT LANGID; - -// -// Large Integer Unions -// +/* Large Integer Unions */ #if defined(MIDL_PASS) typedef struct _LARGE_INTEGER { #else @@ -478,7 +405,7 @@ typedef union _LARGE_INTEGER { ULONG LowPart; LONG HighPart; } u; -#endif //MIDL_PASS +#endif /* MIDL_PASS */ LONGLONG QuadPart; } LARGE_INTEGER, *PLARGE_INTEGER; @@ -496,40 +423,26 @@ typedef union _ULARGE_INTEGER { ULONG LowPart; ULONG HighPart; } u; -#endif //MIDL_PASS +#endif /* MIDL_PASS */ ULONGLONG QuadPart; } ULARGE_INTEGER, *PULARGE_INTEGER; -// -// Physical Addresses are always treated as 64-bit wide -// +/* Physical Addresses are always treated as 64-bit wide */ typedef LARGE_INTEGER PHYSICAL_ADDRESS, *PPHYSICAL_ADDRESS; - - -// -// Locally Unique Identifier -// +/* Locally Unique Identifier */ typedef struct _LUID { ULONG LowPart; LONG HighPart; } LUID, *PLUID; - - -// -// Native API Return Value Macros -// +/* Native API Return Value Macros */ #define NT_SUCCESS(Status) (((NTSTATUS)(Status)) >= 0) #define NT_INFORMATION(Status) ((((ULONG)(Status)) >> 30) == 1) #define NT_WARNING(Status) ((((ULONG)(Status)) >> 30) == 2) #define NT_ERROR(Status) ((((ULONG)(Status)) >> 30) == 3) - - -// -// String Types -// +/* String Types */ typedef struct _UNICODE_STRING { USHORT Length; USHORT MaximumLength; @@ -575,9 +488,7 @@ typedef struct _STRING64 { UNICODE_STRING64, *PUNICODE_STRING64, ANSI_STRING64, *PANSI_STRING64; -// -// LangID and NLS -// +/* LangID and NLS */ #define MAKELANGID(p, s) ((((USHORT)(s)) << 10) | (USHORT)(p)) #define PRIMARYLANGID(lgid) ((USHORT)(lgid) & 0x3ff) #define SUBLANGID(lgid) ((USHORT)(lgid) >> 10) @@ -594,10 +505,7 @@ typedef struct _STRING64 { #define SORTVERSIONFROMLCID(lcid) ((USHORT)((((ULONG)(lcid)) >> 20) & 0xf)) - -// -// Object Attributes -// +/* Object Attributes */ typedef struct _OBJECT_ATTRIBUTES { ULONG Length; HANDLE RootDirectory; @@ -608,9 +516,7 @@ typedef struct _OBJECT_ATTRIBUTES { } OBJECT_ATTRIBUTES, *POBJECT_ATTRIBUTES; typedef CONST OBJECT_ATTRIBUTES *PCOBJECT_ATTRIBUTES; -// -// Values for the Attributes member -// +/* Values for the Attributes member */ #define OBJ_INHERIT 0x00000002 #define OBJ_PERMANENT 0x00000010 #define OBJ_EXCLUSIVE 0x00000020 @@ -621,9 +527,7 @@ typedef CONST OBJECT_ATTRIBUTES *PCOBJECT_ATTRIBUTES; #define OBJ_FORCE_ACCESS_CHECK 0x00000400 #define OBJ_VALID_ATTRIBUTES 0x000007F2 -// -// Helper Macro -// +/* Helper Macro */ #define InitializeObjectAttributes(p,n,a,r,s) { \ (p)->Length = sizeof(OBJECT_ATTRIBUTES); \ (p)->RootDirectory = (r); \ @@ -633,11 +537,7 @@ typedef CONST OBJECT_ATTRIBUTES *PCOBJECT_ATTRIBUTES; (p)->SecurityQualityOfService = NULL; \ } - - -// -// Product Types -// +/* Product Types */ typedef enum _NT_PRODUCT_TYPE { NtProductWinNt = 1, NtProductLanManNt, @@ -646,9 +546,7 @@ typedef enum _NT_PRODUCT_TYPE { -// -// Doubly Linked Lists -// +/* Doubly Linked Lists */ typedef struct _LIST_ENTRY { struct _LIST_ENTRY *Flink; struct _LIST_ENTRY *Blink; @@ -666,14 +564,11 @@ typedef struct LIST_ENTRY64 ULONGLONG Blink; } LIST_ENTRY64, *PLIST_ENTRY64; -// -// Singly Linked Lists -// +/* Singly Linked Lists */ typedef struct _SINGLE_LIST_ENTRY { struct _SINGLE_LIST_ENTRY *Next; } SINGLE_LIST_ENTRY, *PSINGLE_LIST_ENTRY; - typedef struct _PROCESSOR_NUMBER { USHORT Group; UCHAR Number; @@ -681,16 +576,14 @@ typedef struct _PROCESSOR_NUMBER { } PROCESSOR_NUMBER, *PPROCESSOR_NUMBER; typedef EXCEPTION_DISPOSITION -(DDKAPI *PEXCEPTION_ROUTINE)( +(NTAPI *PEXCEPTION_ROUTINE)( IN struct _EXCEPTION_RECORD *ExceptionRecord, IN PVOID EstablisherFrame, IN OUT struct _CONTEXT *ContextRecord, IN OUT PVOID DispatcherContext); -// -// Helper Macros -// +/* Helper Macros */ #define RTL_CONSTANT_STRING(s) { sizeof(s)-sizeof((s)[0]), sizeof(s), s } #define RTL_FIELD_SIZE(type, field) (sizeof(((type *)0)->field)) @@ -704,11 +597,7 @@ typedef EXCEPTION_DISPOSITION #endif #define ARRAYSIZE(A) RTL_NUMBER_OF_V2(A) - - -// -// Type Limits -// +/* Type Limits */ #define MINCHAR 0x80 #define MAXCHAR 0x7f #define MINSHORT 0x8000 @@ -720,29 +609,17 @@ typedef EXCEPTION_DISPOSITION #define MAXULONG 0xffffffff #define MAXLONGLONG (0x7fffffffffffffffLL) - - -// -// Multiplication and Shift Operations -// +/* Multiplication and Shift Operations */ #define Int32x32To64(a,b) ((LONGLONG)(a)*(LONGLONG)(b)) #define UInt32x32To64(a,b) ((DWORDLONG)(a)*(DWORDLONG)(b)) #define Int64ShllMod32(a,b) ((DWORDLONG)(a)<<(b)) #define Int64ShraMod32(a,b) ((LONGLONG)(a)>>(b)) #define Int64ShrlMod32(a,b) ((DWORDLONG)(a)>>(b)) - - -// -// C_ASSERT Definition -// +/* C_ASSERT Definition */ #define C_ASSERT(expr) extern char (*c_assert(void)) [(expr) ? 1 : -1] - - -// -// Primary language IDs. -// +/* Primary language IDs. */ #define LANG_NEUTRAL 0x00 #define LANG_INVARIANT 0x7f @@ -873,6 +750,4 @@ typedef EXCEPTION_DISPOSITION #define LANG_YORUBA 0x6a #define LANG_ZULU 0x35 - - -#endif /* _NTDEF_H */ +#endif /* _NTDEF_ */ From 65e1cafd2a9e005b45a76344002c7c28fc94a05b Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 29 Mar 2010 05:48:15 +0000 Subject: [PATCH 082/134] Add RtlLargeInteger macros to wdm.h svn path=/trunk/; revision=46560 --- .../drivers/filesystems/ext2/inc/ext2fsd.h | 3 ++ reactos/include/ddk/wdm.h | 41 ++++++++++++++++++- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/reactos/drivers/filesystems/ext2/inc/ext2fsd.h b/reactos/drivers/filesystems/ext2/inc/ext2fsd.h index bf2b784fb86..dcf35d996ef 100644 --- a/reactos/drivers/filesystems/ext2/inc/ext2fsd.h +++ b/reactos/drivers/filesystems/ext2/inc/ext2fsd.h @@ -42,8 +42,11 @@ typedef unsigned char BYTE; /* REACTOS FIXME */ #undef DeleteFile /* This is deprecated and should be changed in the EXT2FS driver. */ + +/* FIXME : Those two definitions already exist in wdm.h #define RtlLargeIntegerLessThan(a, b) (a).QuadPart < (b).QuadPart #define RtlLargeIntegerGreaterThan(a, b) (a).QuadPart > (b).QuadPart +*/ // the following include files should be in the inc sub-dir associated with this driver diff --git a/reactos/include/ddk/wdm.h b/reactos/include/ddk/wdm.h index 526069d8bee..e4aed4f40cf 100644 --- a/reactos/include/ddk/wdm.h +++ b/reactos/include/ddk/wdm.h @@ -6603,7 +6603,46 @@ RtlCheckBit( #define RtlCheckBit(BMH,BP) (((((PLONG)(BMH)->Buffer)[(BP)/32]) >> ((BP)%32)) & 0x1) #endif // defined(_M_AMD64) -#endif // !defined(MIDL_PASS) +#define RtlLargeIntegerGreaterThan(X,Y) ( \ + (((X).HighPart == (Y).HighPart) && ((X).LowPart > (Y).LowPart)) || \ + ((X).HighPart > (Y).HighPart) \ +) + +#define RtlLargeIntegerGreaterThanOrEqualTo(X,Y) ( \ + (((X).HighPart == (Y).HighPart) && ((X).LowPart >= (Y).LowPart)) || \ + ((X).HighPart > (Y).HighPart) \ +) + +#define RtlLargeIntegerNotEqualTo(X,Y) ( \ + (((X).LowPart ^ (Y).LowPart) | ((X).HighPart ^ (Y).HighPart)) \ +) + +#define RtlLargeIntegerLessThan(X,Y) ( \ + (((X).HighPart == (Y).HighPart) && ((X).LowPart < (Y).LowPart)) || \ + ((X).HighPart < (Y).HighPart) \ +) + +#define RtlLargeIntegerLessThanOrEqualTo(X,Y) ( \ + (((X).HighPart == (Y).HighPart) && ((X).LowPart <= (Y).LowPart)) || \ + ((X).HighPart < (Y).HighPart) \ +) + +#define RtlLargeIntegerGreaterThanZero(X) ( \ + (((X).HighPart == 0) && ((X).LowPart > 0)) || \ + ((X).HighPart > 0 ) \ +) + +#define RtlLargeIntegerGreaterOrEqualToZero(X) ( (X).HighPart >= 0 ) + +#define RtlLargeIntegerEqualToZero(X) ( !((X).LowPart | (X).HighPart) ) + +#define RtlLargeIntegerNotEqualToZero(X) ( ((X).LowPart | (X).HighPart) ) + +#define RtlLargeIntegerLessThanZero(X) ( ((X).HighPart < 0) ) + +#define RtlLargeIntegerLessOrEqualToZero(X) ( ((X).HighPart < 0) || !((X).LowPart | (X).HighPart) ) + +#endif /* !defined(MIDL_PASS) */ /* Byte Swap Functions */ #if (defined(_M_IX86) && (_MSC_FULL_VER > 13009037 || defined(__GNUC__))) || \ From 423f6985b223540769eefeba7551295b4576222e Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 29 Mar 2010 07:28:03 +0000 Subject: [PATCH 083/134] merge part of the wdm changes. Mostly formatting and adding a few definitions. svn path=/trunk/; revision=46561 --- reactos/include/ddk/wdm.h | 1658 +++++++++++++++++++++++++++++-------- 1 file changed, 1297 insertions(+), 361 deletions(-) diff --git a/reactos/include/ddk/wdm.h b/reactos/include/ddk/wdm.h index e4aed4f40cf..5304539949c 100644 --- a/reactos/include/ddk/wdm.h +++ b/reactos/include/ddk/wdm.h @@ -41,7 +41,7 @@ #ifndef GUID_DEFINED #include -#endif /* GUID_DEFINED */ +#endif #ifndef _KTMTYPES_ typedef GUID UOW, *PUOW; @@ -95,6 +95,12 @@ extern "C" { #if defined(_MSC_VER) +/* Disable some warnings */ +#pragma warning(disable:4115) /* Named type definition in parentheses */ +#pragma warning(disable:4201) /* Nameless unions and structs */ +#pragma warning(disable:4214) /* Bit fields of other types than int */ +#pragma warning(disable:4820) /* Padding added, due to alignemnet requirement */ + /* Indicate if #pragma alloc_text() is supported */ #if defined(_M_IX86) || defined(_M_AMD64) || defined(_M_IA64) #define ALLOC_PRAGMA 1 @@ -130,8 +136,8 @@ typedef struct _HAL_PRIVATE_DISPATCH_TABLE *PHAL_PRIVATE_DISPATCH_TABLE; typedef struct _DEVICE_HANDLER_OBJECT *PDEVICE_HANDLER_OBJECT; typedef struct _ADAPTER_OBJECT *PADAPTER_OBJECT; typedef struct _CALLBACK_OBJECT *PCALLBACK_OBJECT; -typedef struct _ETHREAD *PETHREAD; typedef struct _EPROCESS *PEPROCESS; +typedef struct _ETHREAD *PETHREAD; typedef struct _IO_TIMER *PIO_TIMER; typedef struct _KINTERRUPT *PKINTERRUPT; typedef struct _KPROCESS *PKPROCESS; @@ -149,7 +155,8 @@ typedef struct _CONTEXT *PCONTEXT; #if defined(__GNUC__) static __inline__ BOOLEAN -InterlockedBitTestAndSet(IN LONG volatile *Base, +InterlockedBitTestAndSet( + IN LONG volatile *Base, IN LONG Bit) { #if defined(_M_IX86) @@ -167,7 +174,8 @@ InterlockedBitTestAndSet(IN LONG volatile *Base, } static __inline__ BOOLEAN -InterlockedBitTestAndReset(IN LONG volatile *Base, +InterlockedBitTestAndReset( + IN LONG volatile *Base, IN LONG Bit) { #if defined(_M_IX86) @@ -184,7 +192,7 @@ InterlockedBitTestAndReset(IN LONG volatile *Base, #endif } -#endif +#endif /* defined(__GNUC__) */ #define BitScanForward _BitScanForward #define BitScanReverse _BitScanReverse @@ -196,6 +204,10 @@ InterlockedBitTestAndReset(IN LONG volatile *Base, #define InterlockedBitTestAndReset _interlockedbittestandreset #ifdef _M_AMD64 +#define BitTest64 _bittest64 +#define BitTestAndComplement64 _bittestandcomplement64 +#define BitTestAndSet64 _bittestandset64 +#define BitTestAndReset64 _bittestandreset64 #define InterlockedBitTestAndSet64 _interlockedbittestandset64 #define InterlockedBitTestAndReset64 _interlockedbittestandreset64 #endif @@ -239,7 +251,7 @@ InterlockedExchangeAdd( IN OUT LONG volatile *Addend, IN LONG Value); -#else // !defined(NO_INTERLOCKED_INTRINSICS) +#else /* !defined(NO_INTERLOCKED_INTRINSICS) */ #define InterlockedExchange _InterlockedExchange #define InterlockedIncrement _InterlockedIncrement @@ -250,9 +262,9 @@ InterlockedExchangeAdd( #define InterlockedAnd _InterlockedAnd #define InterlockedXor _InterlockedXor -#endif // !defined(NO_INTERLOCKED_INTRINSICS) +#endif /* !defined(NO_INTERLOCKED_INTRINSICS) */ -#endif // defined (_X86_) +#endif /* defined (_X86_) */ #if !defined (_WIN64) /* @@ -364,7 +376,7 @@ typedef struct _RTL_BITMAP_RUN { } RTL_BITMAP_RUN, *PRTL_BITMAP_RUN; typedef NTSTATUS -(DDKAPI *PRTL_QUERY_REGISTRY_ROUTINE)( +(NTAPI *PRTL_QUERY_REGISTRY_ROUTINE)( IN PWSTR ValueName, IN ULONG ValueType, IN PVOID ValueData, @@ -398,10 +410,15 @@ typedef struct _TIME_FIELDS { #define _SLIST_HEADER_ #if defined(_WIN64) -typedef struct DECLSPEC_ALIGN(16) _SLIST_ENTRY *PSLIST_ENTRY; + typedef struct DECLSPEC_ALIGN(16) _SLIST_ENTRY { - PSLIST_ENTRY Next; -} SLIST_ENTRY; + struct _SLIST_ENTRY *Next; +} SLIST_ENTRY, *PSLIST_ENTRY; + +typedef struct _SLIST_ENTRY32 { + ULONG Next; +} SLIST_ENTRY32, *PSLIST_ENTRY32; + typedef union DECLSPEC_ALIGN(16) _SLIST_HEADER { struct { ULONGLONG Alignment; @@ -424,11 +441,32 @@ typedef union DECLSPEC_ALIGN(16) _SLIST_HEADER { ULONGLONG Reserved:2; ULONGLONG NextEntry:60; } Header16; + struct { + ULONGLONG Depth:16; + ULONGLONG Sequence:48; + ULONGLONG HeaderType:1; + ULONGLONG Reserved:3; + ULONGLONG NextEntry:60; + } HeaderX64; } SLIST_HEADER, *PSLIST_HEADER; + +typedef union _SLIST_HEADER32 { + ULONGLONG Alignment; + struct { + SLIST_ENTRY32 Next; + USHORT Depth; + USHORT Sequence; + } DUMMYSTRUCTNAME; +} SLIST_HEADER32, *PSLIST_HEADER32; + #else + #define SLIST_ENTRY SINGLE_LIST_ENTRY #define _SLIST_ENTRY _SINGLE_LIST_ENTRY #define PSLIST_ENTRY PSINGLE_LIST_ENTRY + +typedef SLIST_ENTRY SLIST_ENTRY32, *PSLIST_ENTRY32; + typedef union _SLIST_HEADER { ULONGLONG Alignment; struct { @@ -437,7 +475,10 @@ typedef union _SLIST_HEADER { USHORT Sequence; } DUMMYSTRUCTNAME; } SLIST_HEADER, *PSLIST_HEADER; -#endif + +typedef SLIST_HEADER SLIST_HEADER32, *PSLIST_HEADER32; + +#endif /* defined(_WIN64) */ #endif /* _SLIST_HEADER_ */ @@ -497,8 +538,7 @@ typedef enum _MODE { #define MAXIMUM_SUPPORTED_EXTENSION 512 #define MAXIMUM_WAIT_OBJECTS 64 -#define ASSERT_APC(Object) \ - ASSERT((Object)->Type == ApcObject) +#define ASSERT_APC(Object) NT_ASSERT((Object)->Type == ApcObject) #define ASSERT_DPC(Object) \ ASSERT(((Object)->Type == 0) || \ @@ -506,24 +546,24 @@ typedef enum _MODE { ((Object)->Type == ThreadedDpcObject)) #define ASSERT_GATE(object) \ - ASSERT((((object)->Header.Type & KOBJECT_TYPE_MASK) == GateObject) || \ + NT_ASSERT((((object)->Header.Type & KOBJECT_TYPE_MASK) == GateObject) || \ (((object)->Header.Type & KOBJECT_TYPE_MASK) == EventSynchronizationObject)) #define ASSERT_DEVICE_QUEUE(Object) \ - ASSERT((Object)->Type == DeviceQueueObject) + NT_ASSERT((Object)->Type == DeviceQueueObject) #define ASSERT_TIMER(E) \ - ASSERT(((E)->Header.Type == TimerNotificationObject) || \ + NT_ASSERT(((E)->Header.Type == TimerNotificationObject) || \ ((E)->Header.Type == TimerSynchronizationObject)) #define ASSERT_MUTANT(E) \ - ASSERT((E)->Header.Type == MutantObject) + NT_ASSERT((E)->Header.Type == MutantObject) #define ASSERT_SEMAPHORE(E) \ - ASSERT((E)->Header.Type == SemaphoreObject) + NT_ASSERT((E)->Header.Type == SemaphoreObject) #define ASSERT_EVENT(E) \ - ASSERT(((E)->Header.Type == NotificationEvent) || \ + NT_ASSERT(((E)->Header.Type == NotificationEvent) || \ ((E)->Header.Type == SynchronizationEvent)) #define DPC_NORMAL 0 @@ -534,6 +574,9 @@ typedef enum _MODE { #define GM_LOCK_WAITER_WOKEN 0x2 #define GM_LOCK_WAITER_INC 0x4 +#define LOCK_QUEUE_WAIT_BIT 0 +#define LOCK_QUEUE_OWNER_BIT 1 + #define LOCK_QUEUE_WAIT 1 #define LOCK_QUEUE_OWNER 2 #define LOCK_QUEUE_TIMER_LOCK_SHIFT 4 @@ -593,7 +636,6 @@ typedef struct _EXCEPTION_POINTERS { PCONTEXT ContextRecord; } EXCEPTION_POINTERS, *PEXCEPTION_POINTERS; - typedef enum _KBUGCHECK_CALLBACK_REASON { KbCallbackInvalid, KbCallbackReserved1, @@ -605,11 +647,12 @@ typedef enum _KBUGCHECK_CALLBACK_REASON { struct _KBUGCHECK_REASON_CALLBACK_RECORD; typedef VOID -(DDKAPI *PKBUGCHECK_REASON_CALLBACK_ROUTINE)( +(NTAPI KBUGCHECK_REASON_CALLBACK_ROUTINE)( IN KBUGCHECK_CALLBACK_REASON Reason, IN struct _KBUGCHECK_REASON_CALLBACK_RECORD *Record, IN OUT PVOID ReasonSpecificData, IN ULONG ReasonSpecificDataLength); +typedef KBUGCHECK_REASON_CALLBACK_ROUTINE *PKBUGCHECK_REASON_CALLBACK_ROUTINE; typedef struct _KBUGCHECK_REASON_CALLBACK_RECORD { LIST_ENTRY Entry; @@ -629,9 +672,10 @@ typedef enum _KBUGCHECK_BUFFER_DUMP_STATE { } KBUGCHECK_BUFFER_DUMP_STATE; typedef VOID -(DDKAPI *PKBUGCHECK_CALLBACK_ROUTINE)( +(NTAPI KBUGCHECK_CALLBACK_ROUTINE)( IN PVOID Buffer, IN ULONG Length); +typedef KBUGCHECK_CALLBACK_ROUTINE *PKBUGCHECK_CALLBACK_ROUTINE; typedef struct _KBUGCHECK_CALLBACK_RECORD { LIST_ENTRY Entry; @@ -644,9 +688,10 @@ typedef struct _KBUGCHECK_CALLBACK_RECORD { } KBUGCHECK_CALLBACK_RECORD, *PKBUGCHECK_CALLBACK_RECORD; typedef BOOLEAN -(DDKAPI *PNMI_CALLBACK)( +(NTAPI NMI_CALLBACK)( IN PVOID Context, IN BOOLEAN Handled); +typedef NMI_CALLBACK *PNMI_CALLBACK; typedef enum _TRACE_INFORMATION_CLASS { TraceIdClass, @@ -759,7 +804,7 @@ typedef enum _KINTERRUPT_MODE { #define THREAD_WAIT_OBJECTS 3 typedef VOID -(DDKAPI *PKINTERRUPT_ROUTINE)( +(NTAPI *PKINTERRUPT_ROUTINE)( VOID); typedef enum _KD_OPTION { @@ -789,25 +834,24 @@ typedef enum _INTERFACE_TYPE { } INTERFACE_TYPE, *PINTERFACE_TYPE; typedef VOID -(DDKAPI *PKNORMAL_ROUTINE)( - IN PVOID NormalContext, - IN PVOID SystemArgument1, - IN PVOID SystemArgument2); +(NTAPI *PKNORMAL_ROUTINE)( + IN PVOID NormalContext OPTIONAL, + IN PVOID SystemArgument1 OPTIONAL, + IN PVOID SystemArgument2 OPTIONAL); typedef VOID -(DDKAPI *PKRUNDOWN_ROUTINE)( +(NTAPI *PKRUNDOWN_ROUTINE)( IN struct _KAPC *Apc); typedef VOID -(DDKAPI *PKKERNEL_ROUTINE)( +(NTAPI *PKKERNEL_ROUTINE)( IN struct _KAPC *Apc, - IN OUT PKNORMAL_ROUTINE *NormalRoutine, - IN OUT PVOID *NormalContext, - IN OUT PVOID *SystemArgument1, - IN OUT PVOID *SystemArgument2); + IN OUT PKNORMAL_ROUTINE *NormalRoutine OPTIONAL, + IN OUT PVOID *NormalContext OPTIONAL, + IN OUT PVOID *SystemArgument1 OPTIONAL, + IN OUT PVOID *SystemArgument2 OPTIONAL); -typedef struct _KAPC -{ +typedef struct _KAPC { UCHAR Type; UCHAR SpareByte0; UCHAR Size; @@ -835,13 +879,12 @@ typedef struct _KDEVICE_QUEUE_ENTRY { typedef PVOID PKIPI_CONTEXT; -typedef -VOID +typedef VOID (NTAPI *PKIPI_WORKER)( - IN PKIPI_CONTEXT PacketContext, - IN PVOID Parameter1, - IN PVOID Parameter2, - IN PVOID Parameter3); + IN OUT PKIPI_CONTEXT PacketContext, + IN PVOID Parameter1 OPTIONAL, + IN PVOID Parameter2 OPTIONAL, + IN PVOID Parameter3 OPTIONAL); typedef ULONG_PTR @@ -908,14 +951,14 @@ typedef enum _KSPIN_LOCK_QUEUE_NUMBER { LockQueueMaximumLock = LockQueueTimerTableLock + LOCK_QUEUE_TIMER_TABLE_LOCKS } KSPIN_LOCK_QUEUE_NUMBER, *PKSPIN_LOCK_QUEUE_NUMBER; -#endif +#endif /* defined(_AMD64_) */ typedef VOID -(DDKAPI *PKDEFERRED_ROUTINE)( +(NTAPI *PKDEFERRED_ROUTINE)( IN struct _KDPC *Dpc, - IN PVOID DeferredContext, - IN PVOID SystemArgument1, - IN PVOID SystemArgument2); + IN PVOID DeferredContext OPTIONAL, + IN PVOID SystemArgument1 OPTIONAL, + IN PVOID SystemArgument2 OPTIONAL); typedef enum _KDPC_IMPORTANCE { LowImportance, @@ -924,8 +967,7 @@ typedef enum _KDPC_IMPORTANCE { MediumHighImportance } KDPC_IMPORTANCE; -typedef struct _KDPC -{ +typedef struct _KDPC { UCHAR Type; UCHAR Importance; volatile USHORT Number; @@ -961,11 +1003,11 @@ typedef struct _KDEVICE_QUEUE { #else BOOLEAN Busy; #endif - } KDEVICE_QUEUE, *PKDEVICE_QUEUE, *RESTRICTED_POINTER PRKDEVICE_QUEUE; #define TIMER_EXPIRED_INDEX_BITS 6 #define TIMER_PROCESSOR_INDEX_BITS 5 + typedef struct _DISPATCHER_HEADER { _ANONYMOUS_UNION union { _ANONYMOUS_STRUCT struct { @@ -1046,21 +1088,17 @@ typedef struct _KSEMAPHORE { LONG Limit; } KSEMAPHORE, *PKSEMAPHORE, *RESTRICTED_POINTER PRKSEMAPHORE; -typedef struct _KGATE -{ +typedef struct _KGATE { DISPATCHER_HEADER Header; } KGATE, *PKGATE, *RESTRICTED_POINTER PRKGATE; -typedef struct _KGUARDED_MUTEX -{ +typedef struct _KGUARDED_MUTEX { volatile LONG Count; PKTHREAD Owner; ULONG Contention; KGATE Gate; - __GNU_EXTENSION union - { - __GNU_EXTENSION struct - { + __GNU_EXTENSION union { + __GNU_EXTENSION struct { SHORT KernelApcDisable; SHORT SpecialApcDisable; }; @@ -1091,7 +1129,7 @@ typedef struct _KTIMER { } KTIMER, *PKTIMER, *RESTRICTED_POINTER PRKTIMER; typedef BOOLEAN -(DDKAPI *PKSYNCHRONIZE_ROUTINE)( +(NTAPI *PKSYNCHRONIZE_ROUTINE)( IN PVOID SynchronizeContext); typedef enum _POOL_TYPE { @@ -1112,8 +1150,7 @@ typedef enum _POOL_TYPE { NonPagedPoolCacheAlignedMustSSession } POOL_TYPE; -typedef enum _ALTERNATIVE_ARCHITECTURE_TYPE -{ +typedef enum _ALTERNATIVE_ARCHITECTURE_TYPE { StandardDesign, NEC98x86, EndAlternatives @@ -1309,6 +1346,9 @@ typedef enum _MM_SYSTEM_SIZE { MmLargeSystem } MM_SYSTEMSIZE; +extern NTKERNELAPI BOOLEAN Mm64BitPhysicalAddress; +extern PVOID MmBadPointer; + /****************************************************************************** * Executive Types * @@ -1373,32 +1413,33 @@ typedef enum _EX_POOL_PRIORITY { typedef struct _LOOKASIDE_LIST_EX *PLOOKASIDE_LIST_EX; typedef PVOID -(DDKAPI *PALLOCATE_FUNCTION)( +(NTAPI *PALLOCATE_FUNCTION)( IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes, IN ULONG Tag); typedef PVOID -(DDKAPI *PALLOCATE_FUNCTION_EX)( +(NTAPI *PALLOCATE_FUNCTION_EX)( IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes, IN ULONG Tag, IN OUT PLOOKASIDE_LIST_EX Lookaside); typedef VOID -(DDKAPI *PFREE_FUNCTION)( +(NTAPI *PFREE_FUNCTION)( IN PVOID Buffer); typedef VOID -(DDKAPI *PFREE_FUNCTION_EX)( +(NTAPI *PFREE_FUNCTION_EX)( IN PVOID Buffer, IN OUT PLOOKASIDE_LIST_EX Lookaside); typedef VOID -(DDKAPI *PCALLBACK_FUNCTION)( - IN PVOID CallbackContext, - IN PVOID Argument1, - IN PVOID Argument2); +(NTAPI CALLBACK_FUNCTION)( + IN PVOID CallbackContext OPTIONAL, + IN PVOID Argument1 OPTIONAL, + IN PVOID Argument2 OPTIONAL); +typedef CALLBACK_FUNCTION *PCALLBACK_FUNCTION; #define GENERAL_LOOKASIDE_LAYOUT \ union { \ @@ -1448,6 +1489,13 @@ typedef struct _GENERAL_LOOKASIDE_POOL { GENERAL_LOOKASIDE_LAYOUT } GENERAL_LOOKASIDE_POOL, *PGENERAL_LOOKASIDE_POOL; +#define LOOKASIDE_CHECK(f) \ + C_ASSERT(FIELD_OFFSET(GENERAL_LOOKASIDE,f) == FIELD_OFFSET(GENERAL_LOOKASIDE_POOL,f)) + +LOOKASIDE_CHECK(TotalFrees); +LOOKASIDE_CHECK(Tag); +LOOKASIDE_CHECK(Future); + typedef struct _PAGED_LOOKASIDE_LIST { GENERAL_LOOKASIDE L; #if !defined(_AMD64_) && !defined(_IA64_) @@ -1462,10 +1510,22 @@ typedef struct LOOKASIDE_ALIGN _NPAGED_LOOKASIDE_LIST { #endif } NPAGED_LOOKASIDE_LIST, *PNPAGED_LOOKASIDE_LIST; +#define LOOKASIDE_MINIMUM_BLOCK_SIZE (RTL_SIZEOF_THROUGH_FIELD (SLIST_ENTRY, Next)) + typedef struct _LOOKASIDE_LIST_EX { GENERAL_LOOKASIDE_POOL L; } LOOKASIDE_LIST_EX; +#if (NTDDI_VERSION >= NTDDI_VISTA) + +#define EX_LOOKASIDE_LIST_EX_FLAGS_RAISE_ON_FAIL 0x00000001UL +#define EX_LOOKASIDE_LIST_EX_FLAGS_FAIL_NO_RAISE 0x00000002UL + +#define EX_MAXIMUM_LOOKASIDE_DEPTH_BASE 256 +#define EX_MAXIMUM_LOOKASIDE_DEPTH_LIMIT 1024 + +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + typedef struct _EX_RUNDOWN_REF { __GNU_EXTENSION union { volatile ULONG_PTR Count; @@ -1476,8 +1536,9 @@ typedef struct _EX_RUNDOWN_REF { typedef struct _EX_RUNDOWN_REF_CACHE_AWARE *PEX_RUNDOWN_REF_CACHE_AWARE; typedef VOID -(DDKAPI *PWORKER_THREAD_ROUTINE)( +(NTAPI WORKER_THREAD_ROUTINE)( IN PVOID Parameter); +typedef WORKER_THREAD_ROUTINE *PWORKER_THREAD_ROUTINE; typedef struct _WORK_QUEUE_ITEM { LIST_ENTRY List; @@ -1692,12 +1753,15 @@ typedef struct _ACCESS_STATE { INITIAL_PRIVILEGE_SET InitialPrivilegeSet; PRIVILEGE_SET PrivilegeSet; } Privileges; - BOOLEAN AuditPrivileges; UNICODE_STRING ObjectName; UNICODE_STRING ObjectTypeName; } ACCESS_STATE, *PACCESS_STATE; +typedef VOID +(NTAPI *PNTFS_DEREF_EXPORTED_SECURITY_DESCRIPTOR)( + IN PVOID Vcb, + IN PSECURITY_DESCRIPTOR SecurityDescriptor); #ifndef _NTLSA_IFS_ @@ -1788,7 +1852,6 @@ typedef struct _SE_ADT_PARAMETER_ARRAY { #endif /* !_NTLSA_AUDIT_ */ #endif /* !_NTLSA_IFS_ */ - /****************************************************************************** * Power Management Support Types * ******************************************************************************/ @@ -1796,9 +1859,16 @@ typedef struct _SE_ADT_PARAMETER_ARRAY { #ifndef _PO_DDK_ #define _PO_DDK_ +#define PO_CB_SYSTEM_POWER_POLICY 0 +#define PO_CB_AC_STATUS 1 +#define PO_CB_BUTTON_COLLISION 2 +#define PO_CB_SYSTEM_STATE_LOCK 3 +#define PO_CB_LID_SWITCH_STATE 4 +#define PO_CB_PROCESSOR_POWER_POLICY 5 + /* Power States/Levels */ typedef enum _SYSTEM_POWER_STATE { - PowerSystemUnspecified, + PowerSystemUnspecified = 0, PowerSystemWorking, PowerSystemSleeping1, PowerSystemSleeping2, @@ -1867,7 +1937,7 @@ typedef enum _POWER_INFORMATION_LEVEL { } POWER_INFORMATION_LEVEL; typedef enum { - PowerActionNone, + PowerActionNone = 0, PowerActionReserved, PowerActionSleep, PowerActionHibernate, @@ -1878,7 +1948,7 @@ typedef enum { } POWER_ACTION, *PPOWER_ACTION; typedef enum _DEVICE_POWER_STATE { - PowerDeviceUnspecified, + PowerDeviceUnspecified = 0, PowerDeviceD0, PowerDeviceD1, PowerDeviceD2, @@ -1886,6 +1956,12 @@ typedef enum _DEVICE_POWER_STATE { PowerDeviceMaximum } DEVICE_POWER_STATE, *PDEVICE_POWER_STATE; +typedef enum _MONITOR_DISPLAY_STATE { + PowerMonitorOff = 0, + PowerMonitorOn, + PowerMonitorDim +} MONITOR_DISPLAY_STATE, *PMONITOR_DISPLAY_STATE; + typedef union _POWER_STATE { SYSTEM_POWER_STATE SystemState; DEVICE_POWER_STATE DeviceState; @@ -1905,22 +1981,148 @@ typedef struct { #endif /* !_PO_DDK_ */ +#define CORE_PARKING_POLICY_CHANGE_IDEAL 0 +#define CORE_PARKING_POLICY_CHANGE_SINGLE 1 +#define CORE_PARKING_POLICY_CHANGE_ROCKET 2 +#define CORE_PARKING_POLICY_CHANGE_MAX CORE_PARKING_POLICY_CHANGE_ROCKET + +DEFINE_GUID(GUID_MAX_POWER_SAVINGS, 0xA1841308, 0x3541, 0x4FAB, 0xBC, 0x81, 0xF7, 0x15, 0x56, 0xF2, 0x0B, 0x4A ); +DEFINE_GUID(GUID_MIN_POWER_SAVINGS, 0x8C5E7FDA, 0xE8BF, 0x4A96, 0x9A, 0x85, 0xA6, 0xE2, 0x3A, 0x8C, 0x63, 0x5C ); +DEFINE_GUID(GUID_TYPICAL_POWER_SAVINGS, 0x381B4222, 0xF694, 0x41F0, 0x96, 0x85, 0xFF, 0x5B, 0xB2, 0x60, 0xDF, 0x2E ); +DEFINE_GUID(NO_SUBGROUP_GUID, 0xFEA3413E, 0x7E05, 0x4911, 0x9A, 0x71, 0x70, 0x03, 0x31, 0xF1, 0xC2, 0x94 ); +DEFINE_GUID(ALL_POWERSCHEMES_GUID, 0x68A1E95E, 0x13EA, 0x41E1, 0x80, 0x11, 0x0C, 0x49, 0x6C, 0xA4, 0x90, 0xB0 ); +DEFINE_GUID(GUID_POWERSCHEME_PERSONALITY, 0x245D8541, 0x3943, 0x4422, 0xB0, 0x25, 0x13, 0xA7, 0x84, 0xF6, 0x79, 0xB7 ); +DEFINE_GUID(GUID_ACTIVE_POWERSCHEME, 0x31F9F286, 0x5084, 0x42FE, 0xB7, 0x20, 0x2B, 0x02, 0x64, 0x99, 0x37, 0x63 ); +DEFINE_GUID(GUID_VIDEO_SUBGROUP, 0x7516B95F, 0xF776, 0x4464, 0x8C, 0x53, 0x06, 0x16, 0x7F, 0x40, 0xCC, 0x99 ); +DEFINE_GUID(GUID_VIDEO_POWERDOWN_TIMEOUT, 0x3C0BC021, 0xC8A8, 0x4E07, 0xA9, 0x73, 0x6B, 0x14, 0xCB, 0xCB, 0x2B, 0x7E ); +DEFINE_GUID(GUID_VIDEO_ANNOYANCE_TIMEOUT, 0x82DBCF2D, 0xCD67, 0x40C5, 0xBF, 0xDC, 0x9F, 0x1A, 0x5C, 0xCD, 0x46, 0x63 ); +DEFINE_GUID(GUID_VIDEO_ADAPTIVE_PERCENT_INCREASE, 0xEED904DF, 0xB142, 0x4183, 0xB1, 0x0B, 0x5A, 0x11, 0x97, 0xA3, 0x78, 0x64 ); +DEFINE_GUID(GUID_VIDEO_DIM_TIMEOUT, 0x17aaa29b, 0x8b43, 0x4b94, 0xaa, 0xfe, 0x35, 0xf6, 0x4d, 0xaa, 0xf1, 0xee); +DEFINE_GUID(GUID_VIDEO_ADAPTIVE_POWERDOWN, 0x90959D22, 0xD6A1, 0x49B9, 0xAF, 0x93, 0xBC, 0xE8, 0x85, 0xAD, 0x33, 0x5B ); +DEFINE_GUID(GUID_MONITOR_POWER_ON, 0x02731015, 0x4510, 0x4526, 0x99, 0xE6, 0xE5, 0xA1, 0x7E, 0xBD, 0x1A, 0xEA ); +DEFINE_GUID(GUID_DEVICE_POWER_POLICY_VIDEO_BRIGHTNESS, 0xaded5e82L, 0xb909, 0x4619, 0x99, 0x49, 0xf5, 0xd7, 0x1d, 0xac, 0x0b, 0xcb); +DEFINE_GUID(GUID_DEVICE_POWER_POLICY_VIDEO_DIM_BRIGHTNESS, 0xf1fbfde2, 0xa960, 0x4165, 0x9f, 0x88, 0x50, 0x66, 0x79, 0x11, 0xce, 0x96); +DEFINE_GUID(GUID_VIDEO_CURRENT_MONITOR_BRIGHTNESS, 0x8ffee2c6, 0x2d01, 0x46be, 0xad, 0xb9, 0x39, 0x8a, 0xdd, 0xc5, 0xb4, 0xff); +DEFINE_GUID(GUID_VIDEO_ADAPTIVE_DISPLAY_BRIGHTNESS, 0xFBD9AA66, 0x9553, 0x4097, 0xBA, 0x44, 0xED, 0x6E, 0x9D, 0x65, 0xEA, 0xB8); +DEFINE_GUID(GUID_SESSION_DISPLAY_STATE, 0x73A5E93A, 0x5BB1, 0x4F93, 0x89, 0x5B, 0xDB, 0xD0, 0xDA, 0x85, 0x59, 0x67 ); +DEFINE_GUID(GUID_CONSOLE_DISPLAY_STATE, 0x6fe69556, 0x704a, 0x47a0, 0x8f, 0x24, 0xc2, 0x8d, 0x93, 0x6f, 0xda, 0x47); +DEFINE_GUID(GUID_ALLOW_DISPLAY_REQUIRED, 0xA9CEB8DA, 0xCD46, 0x44FB, 0xA9, 0x8B, 0x02, 0xAF, 0x69, 0xDE, 0x46, 0x23 ); +DEFINE_GUID(GUID_DISK_SUBGROUP, 0x0012EE47, 0x9041, 0x4B5D, 0x9B, 0x77, 0x53, 0x5F, 0xBA, 0x8B, 0x14, 0x42 ); +DEFINE_GUID(GUID_DISK_POWERDOWN_TIMEOUT, 0x6738E2C4, 0xE8A5, 0x4A42, 0xB1, 0x6A, 0xE0, 0x40, 0xE7, 0x69, 0x75, 0x6E ); +DEFINE_GUID(GUID_DISK_BURST_IGNORE_THRESHOLD, 0x80e3c60e, 0xbb94, 0x4ad8, 0xbb, 0xe0, 0x0d, 0x31, 0x95, 0xef, 0xc6, 0x63 ); +DEFINE_GUID(GUID_DISK_ADAPTIVE_POWERDOWN, 0x396A32E1, 0x499A, 0x40B2, 0x91, 0x24, 0xA9, 0x6A, 0xFE, 0x70, 0x76, 0x67 ); +DEFINE_GUID(GUID_SLEEP_SUBGROUP, 0x238C9FA8, 0x0AAD, 0x41ED, 0x83, 0xF4, 0x97, 0xBE, 0x24, 0x2C, 0x8F, 0x20 ); +DEFINE_GUID(GUID_SLEEP_IDLE_THRESHOLD, 0x81cd32e0, 0x7833, 0x44f3, 0x87, 0x37, 0x70, 0x81, 0xf3, 0x8d, 0x1f, 0x70 ); +DEFINE_GUID(GUID_STANDBY_TIMEOUT, 0x29F6C1DB, 0x86DA, 0x48C5, 0x9F, 0xDB, 0xF2, 0xB6, 0x7B, 0x1F, 0x44, 0xDA ); +DEFINE_GUID(GUID_UNATTEND_SLEEP_TIMEOUT, 0x7bc4a2f9, 0xd8fc, 0x4469, 0xb0, 0x7b, 0x33, 0xeb, 0x78, 0x5a, 0xac, 0xa0 ); +DEFINE_GUID(GUID_HIBERNATE_TIMEOUT, 0x9D7815A6, 0x7EE4, 0x497E, 0x88, 0x88, 0x51, 0x5A, 0x05, 0xF0, 0x23, 0x64 ); +DEFINE_GUID(GUID_HIBERNATE_FASTS4_POLICY, 0x94AC6D29, 0x73CE, 0x41A6, 0x80, 0x9F, 0x63, 0x63, 0xBA, 0x21, 0xB4, 0x7E ); +DEFINE_GUID(GUID_CRITICAL_POWER_TRANSITION, 0xB7A27025, 0xE569, 0x46c2, 0xA5, 0x04, 0x2B, 0x96, 0xCA, 0xD2, 0x25, 0xA1); +DEFINE_GUID(GUID_SYSTEM_AWAYMODE, 0x98A7F580, 0x01F7, 0x48AA, 0x9C, 0x0F, 0x44, 0x35, 0x2C, 0x29, 0xE5, 0xC0 ); +DEFINE_GUID(GUID_ALLOW_AWAYMODE, 0x25dfa149, 0x5dd1, 0x4736, 0xb5, 0xab, 0xe8, 0xa3, 0x7b, 0x5b, 0x81, 0x87 ); +DEFINE_GUID(GUID_ALLOW_STANDBY_STATES, 0xabfc2519, 0x3608, 0x4c2a, 0x94, 0xea, 0x17, 0x1b, 0x0e, 0xd5, 0x46, 0xab ); +DEFINE_GUID(GUID_ALLOW_RTC_WAKE, 0xBD3B718A, 0x0680, 0x4D9D, 0x8A, 0xB2, 0xE1, 0xD2, 0xB4, 0xAC, 0x80, 0x6D ); +DEFINE_GUID(GUID_ALLOW_SYSTEM_REQUIRED, 0xA4B195F5, 0x8225, 0x47D8, 0x80, 0x12, 0x9D, 0x41, 0x36, 0x97, 0x86, 0xE2 ); +DEFINE_GUID(GUID_SYSTEM_BUTTON_SUBGROUP, 0x4F971E89, 0xEEBD, 0x4455, 0xA8, 0xDE, 0x9E, 0x59, 0x04, 0x0E, 0x73, 0x47 ); +DEFINE_GUID(GUID_POWERBUTTON_ACTION, 0x7648EFA3, 0xDD9C, 0x4E3E, 0xB5, 0x66, 0x50, 0xF9, 0x29, 0x38, 0x62, 0x80 ); +DEFINE_GUID(GUID_POWERBUTTON_ACTION_FLAGS, 0x857E7FAC, 0x034B, 0x4704, 0xAB, 0xB1, 0xBC, 0xA5, 0x4A, 0xA3, 0x14, 0x78 ); +DEFINE_GUID(GUID_SLEEPBUTTON_ACTION, 0x96996BC0, 0xAD50, 0x47EC, 0x92, 0x3B, 0x6F, 0x41, 0x87, 0x4D, 0xD9, 0xEB ); +DEFINE_GUID(GUID_SLEEPBUTTON_ACTION_FLAGS, 0x2A160AB1, 0xB69D, 0x4743, 0xB7, 0x18, 0xBF, 0x14, 0x41, 0xD5, 0xE4, 0x93 ); +DEFINE_GUID(GUID_USERINTERFACEBUTTON_ACTION, 0xA7066653, 0x8D6C, 0x40A8, 0x91, 0x0E, 0xA1, 0xF5, 0x4B, 0x84, 0xC7, 0xE5 ); +DEFINE_GUID(GUID_LIDCLOSE_ACTION, 0x5CA83367, 0x6E45, 0x459F, 0xA2, 0x7B, 0x47, 0x6B, 0x1D, 0x01, 0xC9, 0x36 ); +DEFINE_GUID(GUID_LIDCLOSE_ACTION_FLAGS, 0x97E969AC, 0x0D6C, 0x4D08, 0x92, 0x7C, 0xD7, 0xBD, 0x7A, 0xD7, 0x85, 0x7B ); +DEFINE_GUID(GUID_LIDOPEN_POWERSTATE, 0x99FF10E7, 0x23B1, 0x4C07, 0xA9, 0xD1, 0x5C, 0x32, 0x06, 0xD7, 0x41, 0xB4 ); +DEFINE_GUID(GUID_BATTERY_SUBGROUP, 0xE73A048D, 0xBF27, 0x4F12, 0x97, 0x31, 0x8B, 0x20, 0x76, 0xE8, 0x89, 0x1F ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_ACTION_0, 0x637EA02F, 0xBBCB, 0x4015, 0x8E, 0x2C, 0xA1, 0xC7, 0xB9, 0xC0, 0xB5, 0x46 ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_LEVEL_0, 0x9A66D8D7, 0x4FF7, 0x4EF9, 0xB5, 0xA2, 0x5A, 0x32, 0x6C, 0xA2, 0xA4, 0x69 ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_FLAGS_0, 0x5dbb7c9f, 0x38e9, 0x40d2, 0x97, 0x49, 0x4f, 0x8a, 0x0e, 0x9f, 0x64, 0x0f ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_ACTION_1, 0xD8742DCB, 0x3E6A, 0x4B3C, 0xB3, 0xFE, 0x37, 0x46, 0x23, 0xCD, 0xCF, 0x06 ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_LEVEL_1, 0x8183BA9A, 0xE910, 0x48DA, 0x87, 0x69, 0x14, 0xAE, 0x6D, 0xC1, 0x17, 0x0A ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_FLAGS_1, 0xbcded951, 0x187b, 0x4d05, 0xbc, 0xcc, 0xf7, 0xe5, 0x19, 0x60, 0xc2, 0x58 ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_ACTION_2, 0x421CBA38, 0x1A8E, 0x4881, 0xAC, 0x89, 0xE3, 0x3A, 0x8B, 0x04, 0xEC, 0xE4 ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_LEVEL_2, 0x07A07CA2, 0xADAF, 0x40D7, 0xB0, 0x77, 0x53, 0x3A, 0xAD, 0xED, 0x1B, 0xFA ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_FLAGS_2, 0x7fd2f0c4, 0xfeb7, 0x4da3, 0x81, 0x17, 0xe3, 0xfb, 0xed, 0xc4, 0x65, 0x82 ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_ACTION_3, 0x80472613, 0x9780, 0x455E, 0xB3, 0x08, 0x72, 0xD3, 0x00, 0x3C, 0xF2, 0xF8 ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_LEVEL_3, 0x58AFD5A6, 0xC2DD, 0x47D2, 0x9F, 0xBF, 0xEF, 0x70, 0xCC, 0x5C, 0x59, 0x65 ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_FLAGS_3, 0x73613ccf, 0xdbfa, 0x4279, 0x83, 0x56, 0x49, 0x35, 0xf6, 0xbf, 0x62, 0xf3 ); +DEFINE_GUID(GUID_PROCESSOR_SETTINGS_SUBGROUP, 0x54533251, 0x82BE, 0x4824, 0x96, 0xC1, 0x47, 0xB6, 0x0B, 0x74, 0x0D, 0x00 ); +DEFINE_GUID(GUID_PROCESSOR_THROTTLE_POLICY, 0x57027304, 0x4AF6, 0x4104, 0x92, 0x60, 0xE3, 0xD9, 0x52, 0x48, 0xFC, 0x36 ); +DEFINE_GUID(GUID_PROCESSOR_THROTTLE_MAXIMUM, 0xBC5038F7, 0x23E0, 0x4960, 0x96, 0xDA, 0x33, 0xAB, 0xAF, 0x59, 0x35, 0xEC ); +DEFINE_GUID(GUID_PROCESSOR_THROTTLE_MINIMUM, 0x893DEE8E, 0x2BEF, 0x41E0, 0x89, 0xC6, 0xB5, 0x5D, 0x09, 0x29, 0x96, 0x4C ); +DEFINE_GUID(GUID_PROCESSOR_ALLOW_THROTTLING, 0x3b04d4fd, 0x1cc7, 0x4f23, 0xab, 0x1c, 0xd1, 0x33, 0x78, 0x19, 0xc4, 0xbb ); +DEFINE_GUID(GUID_PROCESSOR_IDLESTATE_POLICY, 0x68f262a7, 0xf621, 0x4069, 0xb9, 0xa5, 0x48, 0x74, 0x16, 0x9b, 0xe2, 0x3c); +DEFINE_GUID(GUID_PROCESSOR_PERFSTATE_POLICY, 0xBBDC3814, 0x18E9, 0x4463, 0x8A, 0x55, 0xD1, 0x97, 0x32, 0x7C, 0x45, 0xC0); +DEFINE_GUID(GUID_PROCESSOR_PERF_INCREASE_THRESHOLD, 0x06cadf0e, 0x64ed, 0x448a, 0x89, 0x27, 0xce, 0x7b, 0xf9, 0x0e, 0xb3, 0x5d ); +DEFINE_GUID(GUID_PROCESSOR_PERF_DECREASE_THRESHOLD, 0x12a0ab44, 0xfe28, 0x4fa9, 0xb3, 0xbd, 0x4b, 0x64, 0xf4, 0x49, 0x60, 0xa6 ); +DEFINE_GUID(GUID_PROCESSOR_PERF_INCREASE_POLICY, 0x465e1f50, 0xb610, 0x473a, 0xab, 0x58, 0x0, 0xd1, 0x7, 0x7d, 0xc4, 0x18); +DEFINE_GUID(GUID_PROCESSOR_PERF_DECREASE_POLICY, 0x40fbefc7, 0x2e9d, 0x4d25, 0xa1, 0x85, 0xc, 0xfd, 0x85, 0x74, 0xba, 0xc6); +DEFINE_GUID(GUID_PROCESSOR_PERF_INCREASE_TIME, 0x984cf492, 0x3bed, 0x4488, 0xa8, 0xf9, 0x42, 0x86, 0xc9, 0x7b, 0xf5, 0xaa); +DEFINE_GUID(GUID_PROCESSOR_PERF_DECREASE_TIME, 0xd8edeb9b, 0x95cf, 0x4f95, 0xa7, 0x3c, 0xb0, 0x61, 0x97, 0x36, 0x93, 0xc8); +DEFINE_GUID(GUID_PROCESSOR_PERF_TIME_CHECK, 0x4d2b0152, 0x7d5c, 0x498b, 0x88, 0xe2, 0x34, 0x34, 0x53, 0x92, 0xa2, 0xc5); +DEFINE_GUID(GUID_PROCESSOR_PERF_BOOST_POLICY, 0x45bcc044, 0xd885, 0x43e2, 0x86, 0x5, 0xee, 0xe, 0xc6, 0xe9, 0x6b, 0x59); +DEFINE_GUID(GUID_PROCESSOR_IDLE_ALLOW_SCALING, 0x6c2993b0, 0x8f48, 0x481f, 0xbc, 0xc6, 0x0, 0xdd, 0x27, 0x42, 0xaa, 0x6); +DEFINE_GUID(GUID_PROCESSOR_IDLE_DISABLE, 0x5d76a2ca, 0xe8c0, 0x402f, 0xa1, 0x33, 0x21, 0x58, 0x49, 0x2d, 0x58, 0xad); +DEFINE_GUID(GUID_PROCESSOR_IDLE_TIME_CHECK, 0xc4581c31, 0x89ab, 0x4597, 0x8e, 0x2b, 0x9c, 0x9c, 0xab, 0x44, 0xe, 0x6b); +DEFINE_GUID(GUID_PROCESSOR_IDLE_DEMOTE_THRESHOLD, 0x4b92d758, 0x5a24, 0x4851, 0xa4, 0x70, 0x81, 0x5d, 0x78, 0xae, 0xe1, 0x19); +DEFINE_GUID(GUID_PROCESSOR_IDLE_PROMOTE_THRESHOLD, 0x7b224883, 0xb3cc, 0x4d79, 0x81, 0x9f, 0x83, 0x74, 0x15, 0x2c, 0xbe, 0x7c); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_INCREASE_THRESHOLD, 0xdf142941, 0x20f3, 0x4edf, 0x9a, 0x4a, 0x9c, 0x83, 0xd3, 0xd7, 0x17, 0xd1 ); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_DECREASE_THRESHOLD, 0x68dd2f27, 0xa4ce, 0x4e11, 0x84, 0x87, 0x37, 0x94, 0xe4, 0x13, 0x5d, 0xfa); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_INCREASE_POLICY, 0xc7be0679, 0x2817, 0x4d69, 0x9d, 0x02, 0x51, 0x9a, 0x53, 0x7e, 0xd0, 0xc6); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_DECREASE_POLICY, 0x71021b41, 0xc749, 0x4d21, 0xbe, 0x74, 0xa0, 0x0f, 0x33, 0x5d, 0x58, 0x2b); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_MAX_CORES, 0xea062031, 0x0e34, 0x4ff1, 0x9b, 0x6d, 0xeb, 0x10, 0x59, 0x33, 0x40, 0x28); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_MIN_CORES, 0x0cc5b647, 0xc1df, 0x4637, 0x89, 0x1a, 0xde, 0xc3, 0x5c, 0x31, 0x85, 0x83); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_INCREASE_TIME, 0x2ddd5a84, 0x5a71, 0x437e, 0x91, 0x2a, 0xdb, 0x0b, 0x8c, 0x78, 0x87, 0x32); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_DECREASE_TIME, 0xdfd10d17, 0xd5eb, 0x45dd, 0x87, 0x7a, 0x9a, 0x34, 0xdd, 0xd1, 0x5c, 0x82); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_AFFINITY_HISTORY_DECREASE_FACTOR, 0x8f7b45e3, 0xc393, 0x480a, 0x87, 0x8c, 0xf6, 0x7a, 0xc3, 0xd0, 0x70, 0x82); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_AFFINITY_HISTORY_THRESHOLD, 0x5b33697b, 0xe89d, 0x4d38, 0xaa, 0x46, 0x9e, 0x7d, 0xfb, 0x7c, 0xd2, 0xf9); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_AFFINITY_WEIGHTING, 0xe70867f1, 0xfa2f, 0x4f4e, 0xae, 0xa1, 0x4d, 0x8a, 0x0b, 0xa2, 0x3b, 0x20); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_HISTORY_DECREASE_FACTOR, 0x1299023c, 0xbc28, 0x4f0a, 0x81, 0xec, 0xd3, 0x29, 0x5a, 0x8d, 0x81, 0x5d); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_HISTORY_THRESHOLD, 0x9ac18e92, 0xaa3c, 0x4e27, 0xb3, 0x07, 0x01, 0xae, 0x37, 0x30, 0x71, 0x29); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_WEIGHTING, 0x8809c2d8, 0xb155, 0x42d4, 0xbc, 0xda, 0x0d, 0x34, 0x56, 0x51, 0xb1, 0xdb); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_THRESHOLD, 0x943c8cb6, 0x6f93, 0x4227, 0xad, 0x87, 0xe9, 0xa3, 0xfe, 0xec, 0x08, 0xd1); +DEFINE_GUID(GUID_PROCESSOR_PARKING_CORE_OVERRIDE, 0xa55612aa, 0xf624, 0x42c6, 0xa4, 0x43, 0x73, 0x97, 0xd0, 0x64, 0xc0, 0x4f); +DEFINE_GUID(GUID_PROCESSOR_PARKING_PERF_STATE, 0x447235c7, 0x6a8d, 0x4cc0, 0x8e, 0x24, 0x9e, 0xaf, 0x70, 0xb9, 0x6e, 0x2b); +DEFINE_GUID(GUID_PROCESSOR_PERF_HISTORY, 0x7d24baa7, 0x0b84, 0x480f, 0x84, 0x0c, 0x1b, 0x07, 0x43, 0xc0, 0x0f, 0x5f); +DEFINE_GUID(GUID_SYSTEM_COOLING_POLICY, 0x94D3A615, 0xA899, 0x4AC5, 0xAE, 0x2B, 0xE4, 0xD8, 0xF6, 0x34, 0x36, 0x7F); +DEFINE_GUID(GUID_LOCK_CONSOLE_ON_WAKE, 0x0E796BDB, 0x100D, 0x47D6, 0xA2, 0xD5, 0xF7, 0xD2, 0xDA, 0xA5, 0x1F, 0x51 ); +DEFINE_GUID(GUID_DEVICE_IDLE_POLICY, 0x4faab71a, 0x92e5, 0x4726, 0xb5, 0x31, 0x22, 0x45, 0x59, 0x67, 0x2d, 0x19 ); +DEFINE_GUID(GUID_ACDC_POWER_SOURCE, 0x5D3E9A59, 0xE9D5, 0x4B00, 0xA6, 0xBD, 0xFF, 0x34, 0xFF, 0x51, 0x65, 0x48 ); +DEFINE_GUID(GUID_LIDSWITCH_STATE_CHANGE, 0xBA3E0F4D, 0xB817, 0x4094, 0xA2, 0xD1, 0xD5, 0x63, 0x79, 0xE6, 0xA0, 0xF3 ); +DEFINE_GUID(GUID_BATTERY_PERCENTAGE_REMAINING, 0xA7AD8041, 0xB45A, 0x4CAE, 0x87, 0xA3, 0xEE, 0xCB, 0xB4, 0x68, 0xA9, 0xE1 ); +DEFINE_GUID(GUID_IDLE_BACKGROUND_TASK, 0x515C31D8, 0xF734, 0x163D, 0xA0, 0xFD, 0x11, 0xA0, 0x8C, 0x91, 0xE8, 0xF1 ); +DEFINE_GUID(GUID_BACKGROUND_TASK_NOTIFICATION, 0xCF23F240, 0x2A54, 0x48D8, 0xB1, 0x14, 0xDE, 0x15, 0x18, 0xFF, 0x05, 0x2E ); +DEFINE_GUID(GUID_APPLAUNCH_BUTTON, 0x1A689231, 0x7399, 0x4E9A, 0x8F, 0x99, 0xB7, 0x1F, 0x99, 0x9D, 0xB3, 0xFA ); +DEFINE_GUID(GUID_PCIEXPRESS_SETTINGS_SUBGROUP, 0x501a4d13, 0x42af,0x4429, 0x9f, 0xd1, 0xa8, 0x21, 0x8c, 0x26, 0x8e, 0x20 ); +DEFINE_GUID(GUID_PCIEXPRESS_ASPM_POLICY, 0xee12f906, 0xd277, 0x404b, 0xb6, 0xda, 0xe5, 0xfa, 0x1a, 0x57, 0x6d, 0xf5 ); +DEFINE_GUID(GUID_ENABLE_SWITCH_FORCED_SHUTDOWN, 0x833a6b62, 0xdfa4, 0x46d1, 0x82, 0xf8, 0xe0, 0x9e, 0x34, 0xd0, 0x29, 0xd6 ); + +#define PERFSTATE_POLICY_CHANGE_IDEAL 0 +#define PERFSTATE_POLICY_CHANGE_SINGLE 1 +#define PERFSTATE_POLICY_CHANGE_ROCKET 2 +#define PERFSTATE_POLICY_CHANGE_MAX PERFSTATE_POLICY_CHANGE_ROCKET + +#define PROCESSOR_PERF_BOOST_POLICY_DISABLED 0 +#define PROCESSOR_PERF_BOOST_POLICY_MAX 100 + +#define POWER_DEVICE_IDLE_POLICY_PERFORMANCE 0 +#define POWER_DEVICE_IDLE_POLICY_CONSERVATIVE 1 + typedef VOID -(DDKAPI *PREQUEST_POWER_COMPLETE)( +(NTAPI REQUEST_POWER_COMPLETE)( IN struct _DEVICE_OBJECT *DeviceObject, IN UCHAR MinorFunction, IN POWER_STATE PowerState, IN PVOID Context, IN struct _IO_STATUS_BLOCK *IoStatus); +typedef REQUEST_POWER_COMPLETE *PREQUEST_POWER_COMPLETE; typedef NTSTATUS -(DDKAPI POWER_SETTING_CALLBACK)( +(NTAPI POWER_SETTING_CALLBACK)( IN LPCGUID SettingGuid, IN PVOID Value, IN ULONG ValueLength, IN OUT PVOID Context OPTIONAL); - typedef POWER_SETTING_CALLBACK *PPOWER_SETTING_CALLBACK; #define PO_CB_SYSTEM_POWER_POLICY 0 @@ -2035,6 +2237,7 @@ typedef int CM_RESOURCE_TYPE; #define REG_HIVE_EXACT_FILE_GROWTH (0x00000080L) #define REG_HIVE_NO_RM (0x00000100L) #define REG_HIVE_SINGLE_LOG (0x00000200L) +#define REG_BOOT_HIVE (0x00000400L) /* Unload Flags */ #define REG_FORCE_UNLOAD 1 @@ -2179,7 +2382,7 @@ typedef struct _CM_PARTIAL_RESOURCE_DESCRIPTOR { /* CM_PARTIAL_RESOURCE_DESCRIPTOR.ShareDisposition */ typedef enum _CM_SHARE_DISPOSITION { - CmResourceShareUndetermined, + CmResourceShareUndetermined = 0, CmResourceShareDeviceExclusive, CmResourceShareDriverExclusive, CmResourceShareShared @@ -2202,6 +2405,10 @@ typedef enum _CM_SHARE_DISPOSITION { #define CM_RESOURCE_INTERRUPT_MESSAGE 0x0002 #define CM_RESOURCE_INTERRUPT_POLICY_INCLUDED 0x0004 +#define CM_RESOURCE_INTERRUPT_LEVEL_LATCHED_BITS 0x0001 + +#define CM_RESOURCE_INTERRUPT_MESSAGE_TOKEN ((ULONG)-2) + /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypeMemory */ #define CM_RESOURCE_MEMORY_READ_WRITE 0x0000 #define CM_RESOURCE_MEMORY_READ_ONLY 0x0001 @@ -2215,6 +2422,15 @@ typedef enum _CM_SHARE_DISPOSITION { #define CM_RESOURCE_MEMORY_BAR 0x0080 #define CM_RESOURCE_MEMORY_COMPAT_FOR_INACCESSIBLE_RANGE 0x0100 +#define CM_RESOURCE_MEMORY_LARGE 0x0E00 +#define CM_RESOURCE_MEMORY_LARGE_40 0x0200 +#define CM_RESOURCE_MEMORY_LARGE_48 0x0400 +#define CM_RESOURCE_MEMORY_LARGE_64 0x0800 + +#define CM_RESOURCE_MEMORY_LARGE_40_MAXLEN 0x000000FFFFFFFF00 +#define CM_RESOURCE_MEMORY_LARGE_48_MAXLEN 0x0000FFFFFFFF0000 +#define CM_RESOURCE_MEMORY_LARGE_64_MAXLEN 0xFFFFFFFF00000000 + /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypeDma */ #define CM_RESOURCE_DMA_8 0x0000 #define CM_RESOURCE_DMA_16 0x0001 @@ -2244,6 +2460,7 @@ typedef struct _CM_RESOURCE_LIST { } CM_RESOURCE_LIST, *PCM_RESOURCE_LIST; #include + typedef struct _CM_INT13_DRIVE_PARAMETER { USHORT DriveSelect; ULONG MaxCylinders; @@ -2275,6 +2492,7 @@ typedef struct _CM_PNP_BIOS_INSTALLATION_CHECK { USHORT RealModeDataBaseAddress; ULONG ProtectedModeDataBaseAddress; } CM_PNP_BIOS_INSTALLATION_CHECK, *PCM_PNP_BIOS_INSTALLATION_CHECK; + #include typedef struct _CM_DISK_GEOMETRY_DEVICE_DATA { @@ -2342,7 +2560,10 @@ typedef enum _KEY_INFORMATION_CLASS { KeyFullInformation, KeyNameInformation, KeyCachedInformation, - KeyFlagsInformation + KeyFlagsInformation, + KeyVirtualizationInformation, + KeyHandleTagsInformation, + MaxKeyInfoClass } KEY_INFORMATION_CLASS; typedef struct _KEY_BASIC_INFORMATION { @@ -2496,11 +2717,11 @@ typedef enum _REG_NOTIFY_CLASS { } REG_NOTIFY_CLASS, *PREG_NOTIFY_CLASS; typedef NTSTATUS -(NTAPI *PEX_CALLBACK_FUNCTION)( +(NTAPI EX_CALLBACK_FUNCTION)( IN PVOID CallbackContext, IN PVOID Argument1, - IN PVOID Argument2 -); + IN PVOID Argument2); +typedef EX_CALLBACK_FUNCTION *PEX_CALLBACK_FUNCTION; typedef struct _REG_DELETE_KEY_INFORMATION { PVOID Object; @@ -2919,7 +3140,7 @@ typedef struct _CLIENT_ID { } CLIENT_ID, *PCLIENT_ID; typedef VOID -(DDKAPI *PKSTART_ROUTINE)( +(NTAPI *PKSTART_ROUTINE)( IN PVOID StartContext); typedef struct _VPB { @@ -2941,11 +3162,12 @@ typedef enum _IO_ALLOCATION_ACTION { } IO_ALLOCATION_ACTION, *PIO_ALLOCATION_ACTION; typedef IO_ALLOCATION_ACTION -(DDKAPI *PDRIVER_CONTROL)( +(NTAPI DRIVER_CONTROL)( IN struct _DEVICE_OBJECT *DeviceObject, IN struct _IRP *Irp, IN PVOID MapRegisterBase, IN PVOID Context); +typedef DRIVER_CONTROL *PDRIVER_CONTROL; typedef struct _WAIT_CONTEXT_BLOCK { KDEVICE_QUEUE_ENTRY WaitQueueEntry; @@ -3020,11 +3242,18 @@ typedef struct _IO_REMOVE_LOCK { typedef struct _IO_WORKITEM *PIO_WORKITEM; typedef VOID -(DDKAPI IO_WORKITEM_ROUTINE)( +(NTAPI IO_WORKITEM_ROUTINE)( IN PDEVICE_OBJECT DeviceObject, IN PVOID Context); typedef IO_WORKITEM_ROUTINE *PIO_WORKITEM_ROUTINE; +typedef VOID +(NTAPI IO_WORKITEM_ROUTINE_EX)( + IN PVOID IoObject, + IN PVOID Context OPTIONAL, + IN PIO_WORKITEM IoWorkItem); +typedef IO_WORKITEM_ROUTINE_EX *PIO_WORKITEM_ROUTINE_EX; + typedef struct _SHARE_ACCESS { ULONG OpenCount; ULONG Readers; @@ -3157,13 +3386,13 @@ typedef struct _PCI_SLOT_NUMBER { } PCI_SLOT_NUMBER, *PPCI_SLOT_NUMBER; typedef VOID -(DDKAPI *PIO_APC_ROUTINE)( +(NTAPI *PIO_APC_ROUTINE)( IN PVOID ApcContext, IN PIO_STATUS_BLOCK IoStatusBlock, IN ULONG Reserved); typedef VOID -(DDKAPI *WMI_NOTIFICATION_CALLBACK)( +(NTAPI *WMI_NOTIFICATION_CALLBACK)( PVOID Wnode, PVOID Context); @@ -3208,6 +3437,39 @@ typedef struct _BOOTDISK_INFORMATION_EX { BOOLEAN SystemDeviceIsGpt; } BOOTDISK_INFORMATION_EX, *PBOOTDISK_INFORMATION_EX; +#if (NTDDI_VERSION >= NTDDI_WIN7) + +typedef struct _LOADER_PARTITION_INFORMATION_EX { + ULONG PartitionStyle; + ULONG PartitionNumber; + union { + ULONG Signature; + GUID DeviceId; + }; + ULONG Flags; +} LOADER_PARTITION_INFORMATION_EX, *PLOADER_PARTITION_INFORMATION_EX; + +typedef struct _BOOTDISK_INFORMATION_LITE { + ULONG NumberEntries; + LOADER_PARTITION_INFORMATION_EX Entries[1]; +} BOOTDISK_INFORMATION_LITE, *PBOOTDISK_INFORMATION_LITE; + +#else + +#if (NTDDI_VERSION >= NTDDI_VISTA) +typedef struct _BOOTDISK_INFORMATION_LITE { + ULONG BootDeviceSignature; + ULONG SystemDeviceSignature; + GUID BootDeviceGuid; + GUID SystemDeviceGuid; + BOOLEAN BootDeviceIsGpt; + BOOLEAN SystemDeviceIsGpt; +} BOOTDISK_INFORMATION_LITE, *PBOOTDISK_INFORMATION_LITE; +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + + typedef struct _EISA_MEMORY_TYPE { UCHAR ReadWrite : 1; UCHAR Cached : 1; @@ -3328,34 +3590,37 @@ typedef struct _CM_EISA_SLOT_INFORMATION { */ typedef VOID -(DDKAPI *PINTERFACE_REFERENCE)( +(NTAPI *PINTERFACE_REFERENCE)( PVOID Context); typedef VOID -(DDKAPI *PINTERFACE_DEREFERENCE)( +(NTAPI *PINTERFACE_DEREFERENCE)( PVOID Context); typedef BOOLEAN -(DDKAPI *PTRANSLATE_BUS_ADDRESS)( +(NTAPI TRANSLATE_BUS_ADDRESS)( IN PVOID Context, IN PHYSICAL_ADDRESS BusAddress, IN ULONG Length, IN OUT PULONG AddressSpace, OUT PPHYSICAL_ADDRESS TranslatedAddress); +typedef TRANSLATE_BUS_ADDRESS *PTRANSLATE_BUS_ADDRESS; typedef struct _DMA_ADAPTER* -(DDKAPI *PGET_DMA_ADAPTER)( +(NTAPI GET_DMA_ADAPTER)( IN PVOID Context, IN struct _DEVICE_DESCRIPTION *DeviceDescriptor, OUT PULONG NumberOfMapRegisters); +typedef GET_DMA_ADAPTER *PGET_DMA_ADAPTER; typedef ULONG -(DDKAPI *PGET_SET_DEVICE_DATA)( +(NTAPI GET_SET_DEVICE_DATA)( IN PVOID Context, IN ULONG DataType, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length); +typedef GET_SET_DEVICE_DATA *PGET_SET_DEVICE_DATA; /* PCI_DEVICE_PRESENCE_PARAMETERS.Flags */ #define PCI_USE_SUBSYSTEM_IDS 0x00000001 @@ -3380,18 +3645,20 @@ typedef struct _PCI_DEVICE_PRESENCE_PARAMETERS { } PCI_DEVICE_PRESENCE_PARAMETERS, *PPCI_DEVICE_PRESENCE_PARAMETERS; typedef BOOLEAN -(DDKAPI *PPCI_IS_DEVICE_PRESENT)( +(NTAPI PCI_IS_DEVICE_PRESENT)( IN USHORT VendorID, IN USHORT DeviceID, IN UCHAR RevisionID, IN USHORT SubVendorID, IN USHORT SubSystemID, IN ULONG Flags); +typedef PCI_IS_DEVICE_PRESENT *PPCI_IS_DEVICE_PRESENT; typedef BOOLEAN -(DDKAPI *PPCI_IS_DEVICE_PRESENT_EX)( +(NTAPI PCI_IS_DEVICE_PRESENT_EX)( IN PVOID Context, IN PPCI_DEVICE_PRESENCE_PARAMETERS Parameters); +typedef PCI_IS_DEVICE_PRESENT_EX *PPCI_IS_DEVICE_PRESENT_EX; typedef struct _BUS_INTERFACE_STANDARD { USHORT Size; @@ -3722,13 +3989,15 @@ typedef enum _IO_NOTIFICATION_EVENT_CATEGORY { #define PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES 0x00000001 typedef NTSTATUS -(DDKAPI *PDRIVER_NOTIFICATION_CALLBACK_ROUTINE)( +(NTAPI DRIVER_NOTIFICATION_CALLBACK_ROUTINE)( IN PVOID NotificationStructure, IN PVOID Context); +typedef DRIVER_NOTIFICATION_CALLBACK_ROUTINE *PDRIVER_NOTIFICATION_CALLBACK_ROUTINE; typedef VOID -(DDKAPI *PDEVICE_CHANGE_COMPLETE_CALLBACK)( +(NTAPI DEVICE_CHANGE_COMPLETE_CALLBACK)( IN PVOID Context); +typedef DEVICE_CHANGE_COMPLETE_CALLBACK *PDEVICE_CHANGE_COMPLETE_CALLBACK; typedef enum _FILE_INFORMATION_CLASS { FileDirectoryInformation = 1, @@ -3892,7 +4161,7 @@ typedef struct _ERESOURCE #define RESOURCE_HASH_TABLE_SIZE 64 typedef BOOLEAN -(DDKAPI *PFAST_IO_CHECK_IF_POSSIBLE)( +(NTAPI FAST_IO_CHECK_IF_POSSIBLE)( IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, @@ -3901,9 +4170,10 @@ typedef BOOLEAN IN BOOLEAN CheckForReadOperation, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_CHECK_IF_POSSIBLE *PFAST_IO_CHECK_IF_POSSIBLE; typedef BOOLEAN -(DDKAPI *PFAST_IO_READ)( +(NTAPI FAST_IO_READ)( IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, @@ -3912,9 +4182,10 @@ typedef BOOLEAN OUT PVOID Buffer, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_READ *PFAST_IO_READ; typedef BOOLEAN -(DDKAPI *PFAST_IO_WRITE)( +(NTAPI FAST_IO_WRITE)( IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, @@ -3923,25 +4194,28 @@ typedef BOOLEAN IN PVOID Buffer, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_WRITE *PFAST_IO_WRITE; typedef BOOLEAN -(DDKAPI *PFAST_IO_QUERY_BASIC_INFO)( +(NTAPI FAST_IO_QUERY_BASIC_INFO)( IN struct _FILE_OBJECT *FileObject, IN BOOLEAN Wait, OUT PFILE_BASIC_INFORMATION Buffer, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_QUERY_BASIC_INFO *PFAST_IO_QUERY_BASIC_INFO; typedef BOOLEAN -(DDKAPI *PFAST_IO_QUERY_STANDARD_INFO)( +(NTAPI FAST_IO_QUERY_STANDARD_INFO)( IN struct _FILE_OBJECT *FileObject, IN BOOLEAN Wait, OUT PFILE_STANDARD_INFORMATION Buffer, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_QUERY_STANDARD_INFO *PFAST_IO_QUERY_STANDARD_INFO; typedef BOOLEAN -(DDKAPI *PFAST_IO_LOCK)( +(NTAPI FAST_IO_LOCK)( IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER FileOffset, IN PLARGE_INTEGER Length, @@ -3951,9 +4225,10 @@ typedef BOOLEAN BOOLEAN ExclusiveLock, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_LOCK *PFAST_IO_LOCK; typedef BOOLEAN -(DDKAPI *PFAST_IO_UNLOCK_SINGLE)( +(NTAPI FAST_IO_UNLOCK_SINGLE)( IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER FileOffset, IN PLARGE_INTEGER Length, @@ -3961,24 +4236,27 @@ typedef BOOLEAN ULONG Key, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_UNLOCK_SINGLE *PFAST_IO_UNLOCK_SINGLE; typedef BOOLEAN -(DDKAPI *PFAST_IO_UNLOCK_ALL)( +(NTAPI FAST_IO_UNLOCK_ALL)( IN struct _FILE_OBJECT *FileObject, PEPROCESS ProcessId, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_UNLOCK_ALL *PFAST_IO_UNLOCK_ALL; typedef BOOLEAN -(DDKAPI *PFAST_IO_UNLOCK_ALL_BY_KEY)( +(NTAPI FAST_IO_UNLOCK_ALL_BY_KEY)( IN struct _FILE_OBJECT *FileObject, PVOID ProcessId, ULONG Key, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_UNLOCK_ALL_BY_KEY *PFAST_IO_UNLOCK_ALL_BY_KEY; typedef BOOLEAN -(DDKAPI *PFAST_IO_DEVICE_CONTROL)( +(NTAPI FAST_IO_DEVICE_CONTROL)( IN struct _FILE_OBJECT *FileObject, IN BOOLEAN Wait, IN PVOID InputBuffer OPTIONAL, @@ -3988,37 +4266,43 @@ typedef BOOLEAN IN ULONG IoControlCode, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_DEVICE_CONTROL *PFAST_IO_DEVICE_CONTROL; typedef VOID -(DDKAPI *PFAST_IO_ACQUIRE_FILE)( +(NTAPI FAST_IO_ACQUIRE_FILE)( IN struct _FILE_OBJECT *FileObject); +typedef FAST_IO_ACQUIRE_FILE *PFAST_IO_ACQUIRE_FILE; typedef VOID -(DDKAPI *PFAST_IO_RELEASE_FILE)( +(NTAPI FAST_IO_RELEASE_FILE)( IN struct _FILE_OBJECT *FileObject); +typedef FAST_IO_RELEASE_FILE *PFAST_IO_RELEASE_FILE; typedef VOID -(DDKAPI *PFAST_IO_DETACH_DEVICE)( +(NTAPI FAST_IO_DETACH_DEVICE)( IN struct _DEVICE_OBJECT *SourceDevice, IN struct _DEVICE_OBJECT *TargetDevice); +typedef FAST_IO_DETACH_DEVICE *PFAST_IO_DETACH_DEVICE; typedef BOOLEAN -(DDKAPI *PFAST_IO_QUERY_NETWORK_OPEN_INFO)( +(NTAPI FAST_IO_QUERY_NETWORK_OPEN_INFO)( IN struct _FILE_OBJECT *FileObject, IN BOOLEAN Wait, OUT struct _FILE_NETWORK_OPEN_INFORMATION *Buffer, OUT struct _IO_STATUS_BLOCK *IoStatus, IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_QUERY_NETWORK_OPEN_INFO *PFAST_IO_QUERY_NETWORK_OPEN_INFO; typedef NTSTATUS -(DDKAPI *PFAST_IO_ACQUIRE_FOR_MOD_WRITE)( +(NTAPI FAST_IO_ACQUIRE_FOR_MOD_WRITE)( IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER EndingOffset, OUT struct _ERESOURCE **ResourceToRelease, IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_ACQUIRE_FOR_MOD_WRITE *PFAST_IO_ACQUIRE_FOR_MOD_WRITE; typedef BOOLEAN -(DDKAPI *PFAST_IO_MDL_READ)( +(NTAPI FAST_IO_MDL_READ)( IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, @@ -4026,15 +4310,17 @@ typedef BOOLEAN OUT PMDL *MdlChain, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_MDL_READ *PFAST_IO_MDL_READ; typedef BOOLEAN -(DDKAPI *PFAST_IO_MDL_READ_COMPLETE)( +(NTAPI FAST_IO_MDL_READ_COMPLETE)( IN struct _FILE_OBJECT *FileObject, IN PMDL MdlChain, IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_MDL_READ_COMPLETE *PFAST_IO_MDL_READ_COMPLETE; typedef BOOLEAN -(DDKAPI *PFAST_IO_PREPARE_MDL_WRITE)( +(NTAPI FAST_IO_PREPARE_MDL_WRITE)( IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, @@ -4042,16 +4328,18 @@ typedef BOOLEAN OUT PMDL *MdlChain, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_PREPARE_MDL_WRITE *PFAST_IO_PREPARE_MDL_WRITE; typedef BOOLEAN -(DDKAPI *PFAST_IO_MDL_WRITE_COMPLETE)( +(NTAPI FAST_IO_MDL_WRITE_COMPLETE)( IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER FileOffset, IN PMDL MdlChain, IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_MDL_WRITE_COMPLETE *PFAST_IO_MDL_WRITE_COMPLETE; typedef BOOLEAN -(DDKAPI *PFAST_IO_READ_COMPRESSED)( +(NTAPI FAST_IO_READ_COMPRESSED)( IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, @@ -4062,9 +4350,10 @@ typedef BOOLEAN OUT struct _COMPRESSED_DATA_INFO *CompressedDataInfo, IN ULONG CompressedDataInfoLength, IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_READ_COMPRESSED *PFAST_IO_READ_COMPRESSED; typedef BOOLEAN -(DDKAPI *PFAST_IO_WRITE_COMPRESSED)( +(NTAPI FAST_IO_WRITE_COMPRESSED)( IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, @@ -4075,41 +4364,48 @@ typedef BOOLEAN IN struct _COMPRESSED_DATA_INFO *CompressedDataInfo, IN ULONG CompressedDataInfoLength, IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_WRITE_COMPRESSED *PFAST_IO_WRITE_COMPRESSED; typedef BOOLEAN -(DDKAPI *PFAST_IO_MDL_READ_COMPLETE_COMPRESSED)( +(NTAPI FAST_IO_MDL_READ_COMPLETE_COMPRESSED)( IN struct _FILE_OBJECT *FileObject, IN PMDL MdlChain, IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_MDL_READ_COMPLETE_COMPRESSED *PFAST_IO_MDL_READ_COMPLETE_COMPRESSED; typedef BOOLEAN -(DDKAPI *PFAST_IO_MDL_WRITE_COMPLETE_COMPRESSED)( +(NTAPI FAST_IO_MDL_WRITE_COMPLETE_COMPRESSED)( IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER FileOffset, IN PMDL MdlChain, IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_MDL_WRITE_COMPLETE_COMPRESSED *PFAST_IO_MDL_WRITE_COMPLETE_COMPRESSED; typedef BOOLEAN -(DDKAPI *PFAST_IO_QUERY_OPEN)( +(NTAPI FAST_IO_QUERY_OPEN)( IN struct _IRP *Irp, OUT PFILE_NETWORK_OPEN_INFORMATION NetworkInformation, IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_QUERY_OPEN *PFAST_IO_QUERY_OPEN; typedef NTSTATUS -(DDKAPI *PFAST_IO_RELEASE_FOR_MOD_WRITE)( +(NTAPI FAST_IO_RELEASE_FOR_MOD_WRITE)( IN struct _FILE_OBJECT *FileObject, IN struct _ERESOURCE *ResourceToRelease, IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_RELEASE_FOR_MOD_WRITE *PFAST_IO_RELEASE_FOR_MOD_WRITE; typedef NTSTATUS -(DDKAPI *PFAST_IO_ACQUIRE_FOR_CCFLUSH)( +(NTAPI FAST_IO_ACQUIRE_FOR_CCFLUSH)( IN struct _FILE_OBJECT *FileObject, IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_ACQUIRE_FOR_CCFLUSH *PFAST_IO_ACQUIRE_FOR_CCFLUSH; typedef NTSTATUS -(DDKAPI *PFAST_IO_RELEASE_FOR_CCFLUSH) ( +(NTAPI FAST_IO_RELEASE_FOR_CCFLUSH)( IN struct _FILE_OBJECT *FileObject, IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_RELEASE_FOR_CCFLUSH *PFAST_IO_RELEASE_FOR_CCFLUSH; typedef struct _FAST_IO_DISPATCH { ULONG SizeOfFastIoDispatch; @@ -4183,6 +4479,7 @@ typedef struct _IO_COMPLETION_CONTEXT { #define FO_SKIP_COMPLETION_PORT 0x02000000 #define FO_SKIP_SET_EVENT 0x04000000 #define FO_SKIP_SET_FAST_IO 0x08000000 +#define FO_FLAGS_VALID_ONLY_DURING_CREATE FO_DISALLOW_EXCLUSIVE /* VPB.Flags */ #define VPB_MOUNTED 0x0001 @@ -4197,12 +4494,18 @@ typedef struct _IO_COMPLETION_CONTEXT { #define SL_FORCE_ACCESS_CHECK 0x01 #define SL_OPEN_PAGING_FILE 0x02 #define SL_OPEN_TARGET_DIRECTORY 0x04 +#define SL_STOP_ON_SYMLINK 0x08 #define SL_CASE_SENSITIVE 0x80 #define SL_KEY_SPECIFIED 0x01 #define SL_OVERRIDE_VERIFY_VOLUME 0x02 #define SL_WRITE_THROUGH 0x04 #define SL_FT_SEQUENTIAL_WRITE 0x08 +#define SL_FORCE_DIRECT_WRITE 0x10 +#define SL_REALTIME_STREAM 0x20 + +#define SL_READ_ACCESS_GRANTED 0x01 +#define SL_WRITE_ACCESS_GRANTED 0x04 #define SL_FAIL_IMMEDIATELY 0x01 #define SL_EXCLUSIVE_LOCK 0x02 @@ -4220,6 +4523,8 @@ typedef struct _IO_COMPLETION_CONTEXT { #define DEVICE_TYPE_FROM_CTL_CODE(ctl) (((ULONG) (ctl & 0xffff0000)) >> 16) +#define METHOD_FROM_CTL_CODE(ctrlCode) ((ULONG)(ctrlCode & 3)) + #define IRP_NOCACHE 0x00000001 #define IRP_PAGING_IO 0x00000002 #define IRP_MOUNT_COMPLETION 0x00000002 @@ -4305,6 +4610,9 @@ typedef struct _IO_COMPLETION_CONTEXT { #define IRP_MN_QUERY_BUS_INFORMATION 0x15 #define IRP_MN_DEVICE_USAGE_NOTIFICATION 0x16 #define IRP_MN_SURPRISE_REMOVAL 0x17 +#if (NTDDI_VERSION >= NTDDI_WIN7) +#define IRP_MN_DEVICE_ENUMERATED 0x19 +#endif #define IRP_MN_WAIT_WAKE 0x00 #define IRP_MN_POWER_SEQUENCE 0x01 @@ -4324,8 +4632,7 @@ typedef struct _IO_COMPLETION_CONTEXT { #define IRP_MN_REGINFO_EX 0x0b -typedef struct _FILE_OBJECT -{ +typedef struct _FILE_OBJECT { CSHORT Type; CSHORT Size; PDEVICE_OBJECT DeviceObject; @@ -4452,8 +4759,7 @@ typedef struct _DEVICE_RELATIONS { PDEVICE_OBJECT Objects[1]; } DEVICE_RELATIONS, *PDEVICE_RELATIONS; -typedef struct _DEVOBJ_EXTENSION -{ +typedef struct _DEVOBJ_EXTENSION { CSHORT Type; USHORT Size; PDEVICE_OBJECT DeviceObject; @@ -4491,7 +4797,7 @@ typedef struct _SCATTER_GATHER_LIST SCATTER_GATHER_LIST, *PSCATTER_GATHER_LIST; #endif typedef NTSTATUS -(DDKAPI DRIVER_ADD_DEVICE)( +(NTAPI DRIVER_ADD_DEVICE)( IN struct _DRIVER_OBJECT *DriverObject, IN struct _DEVICE_OBJECT *PhysicalDeviceObject); typedef DRIVER_ADD_DEVICE *PDRIVER_ADD_DEVICE; @@ -4508,24 +4814,24 @@ typedef struct _DRIVER_EXTENSION { #define DRVO_BUILTIN_DRIVER 0x00000004 typedef NTSTATUS -(DDKAPI DRIVER_INITIALIZE)( +(NTAPI DRIVER_INITIALIZE)( IN struct _DRIVER_OBJECT *DriverObject, IN PUNICODE_STRING RegistryPath); typedef DRIVER_INITIALIZE *PDRIVER_INITIALIZE; typedef VOID -(DDKAPI DRIVER_STARTIO)( +(NTAPI DRIVER_STARTIO)( IN struct _DEVICE_OBJECT *DeviceObject, IN struct _IRP *Irp); typedef DRIVER_STARTIO *PDRIVER_STARTIO; typedef VOID -(DDKAPI DRIVER_UNLOAD)( +(NTAPI DRIVER_UNLOAD)( IN struct _DRIVER_OBJECT *DriverObject); typedef DRIVER_UNLOAD *PDRIVER_UNLOAD; typedef NTSTATUS -(DDKAPI DRIVER_DISPATCH)( +(NTAPI DRIVER_DISPATCH)( IN struct _DEVICE_OBJECT *DeviceObject, IN struct _IRP *Irp); typedef DRIVER_DISPATCH *PDRIVER_DISPATCH; @@ -4546,8 +4852,7 @@ typedef struct _DRIVER_OBJECT { PDRIVER_STARTIO DriverStartIo; PDRIVER_UNLOAD DriverUnload; PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION + 1]; -} DRIVER_OBJECT; -typedef struct _DRIVER_OBJECT *PDRIVER_OBJECT; +} DRIVER_OBJECT, *PDRIVER_OBJECT; typedef struct _DMA_ADAPTER { USHORT Version; @@ -4556,18 +4861,18 @@ typedef struct _DMA_ADAPTER { } DMA_ADAPTER, *PDMA_ADAPTER; typedef VOID -(DDKAPI *PPUT_DMA_ADAPTER)( +(NTAPI *PPUT_DMA_ADAPTER)( IN PDMA_ADAPTER DmaAdapter); typedef PVOID -(DDKAPI *PALLOCATE_COMMON_BUFFER)( +(NTAPI *PALLOCATE_COMMON_BUFFER)( IN PDMA_ADAPTER DmaAdapter, IN ULONG Length, OUT PPHYSICAL_ADDRESS LogicalAddress, IN BOOLEAN CacheEnabled); typedef VOID -(DDKAPI *PFREE_COMMON_BUFFER)( +(NTAPI *PFREE_COMMON_BUFFER)( IN PDMA_ADAPTER DmaAdapter, IN ULONG Length, IN PHYSICAL_ADDRESS LogicalAddress, @@ -4575,7 +4880,7 @@ typedef VOID IN BOOLEAN CacheEnabled); typedef NTSTATUS -(DDKAPI *PALLOCATE_ADAPTER_CHANNEL)( +(NTAPI *PALLOCATE_ADAPTER_CHANNEL)( IN PDMA_ADAPTER DmaAdapter, IN PDEVICE_OBJECT DeviceObject, IN ULONG NumberOfMapRegisters, @@ -4583,7 +4888,7 @@ typedef NTSTATUS IN PVOID Context); typedef BOOLEAN -(DDKAPI *PFLUSH_ADAPTER_BUFFERS)( +(NTAPI *PFLUSH_ADAPTER_BUFFERS)( IN PDMA_ADAPTER DmaAdapter, IN PMDL Mdl, IN PVOID MapRegisterBase, @@ -4592,17 +4897,17 @@ typedef BOOLEAN IN BOOLEAN WriteToDevice); typedef VOID -(DDKAPI *PFREE_ADAPTER_CHANNEL)( +(NTAPI *PFREE_ADAPTER_CHANNEL)( IN PDMA_ADAPTER DmaAdapter); typedef VOID -(DDKAPI *PFREE_MAP_REGISTERS)( +(NTAPI *PFREE_MAP_REGISTERS)( IN PDMA_ADAPTER DmaAdapter, PVOID MapRegisterBase, ULONG NumberOfMapRegisters); typedef PHYSICAL_ADDRESS -(DDKAPI *PMAP_TRANSFER)( +(NTAPI *PMAP_TRANSFER)( IN PDMA_ADAPTER DmaAdapter, IN PMDL Mdl, IN PVOID MapRegisterBase, @@ -4611,22 +4916,23 @@ typedef PHYSICAL_ADDRESS IN BOOLEAN WriteToDevice); typedef ULONG -(DDKAPI *PGET_DMA_ALIGNMENT)( +(NTAPI *PGET_DMA_ALIGNMENT)( IN PDMA_ADAPTER DmaAdapter); typedef ULONG -(DDKAPI *PREAD_DMA_COUNTER)( +(NTAPI *PREAD_DMA_COUNTER)( IN PDMA_ADAPTER DmaAdapter); typedef VOID -(DDKAPI *PDRIVER_LIST_CONTROL)( +(NTAPI DRIVER_LIST_CONTROL)( IN struct _DEVICE_OBJECT *DeviceObject, IN struct _IRP *Irp, IN struct _SCATTER_GATHER_LIST *ScatterGather, IN PVOID Context); +typedef DRIVER_LIST_CONTROL *PDRIVER_LIST_CONTROL; typedef NTSTATUS -(DDKAPI *PGET_SCATTER_GATHER_LIST)( +(NTAPI *PGET_SCATTER_GATHER_LIST)( IN PDMA_ADAPTER DmaAdapter, IN PDEVICE_OBJECT DeviceObject, IN PMDL Mdl, @@ -4637,13 +4943,13 @@ typedef NTSTATUS IN BOOLEAN WriteToDevice); typedef VOID -(DDKAPI *PPUT_SCATTER_GATHER_LIST)( +(NTAPI *PPUT_SCATTER_GATHER_LIST)( IN PDMA_ADAPTER DmaAdapter, IN PSCATTER_GATHER_LIST ScatterGather, IN BOOLEAN WriteToDevice); typedef NTSTATUS -(DDKAPI *PCALCULATE_SCATTER_GATHER_LIST_SIZE)( +(NTAPI *PCALCULATE_SCATTER_GATHER_LIST_SIZE)( IN PDMA_ADAPTER DmaAdapter, IN PMDL Mdl OPTIONAL, IN PVOID CurrentVa, @@ -4652,7 +4958,7 @@ typedef NTSTATUS OUT PULONG pNumberOfMapRegisters OPTIONAL); typedef NTSTATUS -(DDKAPI *PBUILD_SCATTER_GATHER_LIST)( +(NTAPI *PBUILD_SCATTER_GATHER_LIST)( IN PDMA_ADAPTER DmaAdapter, IN PDEVICE_OBJECT DeviceObject, IN PMDL Mdl, @@ -4665,7 +4971,7 @@ typedef NTSTATUS IN ULONG ScatterGatherLength); typedef NTSTATUS -(DDKAPI *PBUILD_MDL_FROM_SCATTER_GATHER_LIST)( +(NTAPI *PBUILD_MDL_FROM_SCATTER_GATHER_LIST)( IN PDMA_ADAPTER DmaAdapter, IN PSCATTER_GATHER_LIST ScatterGather, IN PMDL OriginalMdl, @@ -4759,7 +5065,7 @@ typedef struct _IO_RESOURCE_REQUIREMENTS_LIST { } IO_RESOURCE_REQUIREMENTS_LIST, *PIO_RESOURCE_REQUIREMENTS_LIST; typedef VOID -(DDKAPI DRIVER_CANCEL)( +(NTAPI DRIVER_CANCEL)( IN struct _DEVICE_OBJECT *DeviceObject, IN struct _IRP *Irp); typedef DRIVER_CANCEL *PDRIVER_CANCEL; @@ -4820,8 +5126,7 @@ typedef struct _IRP { KAPC Apc; PVOID CompletionKey; } Tail; -} IRP; -typedef struct _IRP *PIRP; +} IRP, *PIRP; typedef enum _IO_PAGING_PRIORITY { IoPagingPriorityInvalid, @@ -4832,37 +5137,39 @@ typedef enum _IO_PAGING_PRIORITY { } IO_PAGING_PRIORITY; typedef NTSTATUS -(DDKAPI IO_COMPLETION_ROUTINE)( +(NTAPI IO_COMPLETION_ROUTINE)( IN struct _DEVICE_OBJECT *DeviceObject, IN struct _IRP *Irp, IN PVOID Context); typedef IO_COMPLETION_ROUTINE *PIO_COMPLETION_ROUTINE; typedef VOID -(DDKAPI *PIO_DPC_ROUTINE)( +(NTAPI IO_DPC_ROUTINE)( IN struct _KDPC *Dpc, IN struct _DEVICE_OBJECT *DeviceObject, IN struct _IRP *Irp, IN PVOID Context); +typedef IO_DPC_ROUTINE *PIO_DPC_ROUTINE; typedef NTSTATUS -(DDKAPI *PMM_DLL_INITIALIZE)( +(NTAPI *PMM_DLL_INITIALIZE)( IN PUNICODE_STRING RegistryPath); typedef NTSTATUS -(DDKAPI *PMM_DLL_UNLOAD)( +(NTAPI *PMM_DLL_UNLOAD)( VOID); typedef BOOLEAN -(DDKAPI KSERVICE_ROUTINE)( +(NTAPI KSERVICE_ROUTINE)( IN struct _KINTERRUPT *Interrupt, IN PVOID ServiceContext); typedef KSERVICE_ROUTINE *PKSERVICE_ROUTINE; typedef VOID -(DDKAPI *PIO_TIMER_ROUTINE)( +(NTAPI IO_TIMER_ROUTINE)( IN struct _DEVICE_OBJECT *DeviceObject, IN PVOID Context); +typedef IO_TIMER_ROUTINE *PIO_TIMER_ROUTINE; typedef struct _IO_SECURITY_CONTEXT { PSECURITY_QUALITY_OF_SERVICE SecurityQos; @@ -4880,33 +5187,33 @@ typedef struct _IO_CSQ_IRP_CONTEXT { } IO_CSQ_IRP_CONTEXT, *PIO_CSQ_IRP_CONTEXT; typedef VOID -(DDKAPI *PIO_CSQ_INSERT_IRP)( +(NTAPI *PIO_CSQ_INSERT_IRP)( IN struct _IO_CSQ *Csq, IN PIRP Irp); typedef VOID -(DDKAPI *PIO_CSQ_REMOVE_IRP)( +(NTAPI *PIO_CSQ_REMOVE_IRP)( IN struct _IO_CSQ *Csq, IN PIRP Irp); typedef PIRP -(DDKAPI *PIO_CSQ_PEEK_NEXT_IRP)( +(NTAPI *PIO_CSQ_PEEK_NEXT_IRP)( IN struct _IO_CSQ *Csq, IN PIRP Irp, IN PVOID PeekContext); typedef VOID -(DDKAPI *PIO_CSQ_ACQUIRE_LOCK)( +(NTAPI *PIO_CSQ_ACQUIRE_LOCK)( IN struct _IO_CSQ *Csq, OUT PKIRQL Irql); typedef VOID -(DDKAPI *PIO_CSQ_RELEASE_LOCK)( +(NTAPI *PIO_CSQ_RELEASE_LOCK)( IN struct _IO_CSQ *Csq, IN KIRQL Irql); typedef VOID -(DDKAPI *PIO_CSQ_COMPLETE_CANCELED_IRP)( +(NTAPI *PIO_CSQ_COMPLETE_CANCELED_IRP)( IN struct _IO_CSQ *Csq, IN PIRP Irp); @@ -5149,6 +5456,8 @@ typedef struct _IO_STACK_LOCATION { #define METHOD_OUT_DIRECT 2 #define METHOD_NEITHER 3 +#define METHOD_DIRECT_TO_HARDWARE METHOD_IN_DIRECT +#define METHOD_DIRECT_FROM_HARDWARE METHOD_OUT_DIRECT #define FILE_SUPERSEDED 0x00000000 #define FILE_OPENED 0x00000001 @@ -5195,6 +5504,7 @@ typedef struct _IO_STACK_LOCATION { #define FILE_ATTRIBUTE_OFFLINE 0x00001000 #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000 #define FILE_ATTRIBUTE_ENCRYPTED 0x00004000 +#define FILE_ATTRIBUTE_VIRTUAL 0x00010000 #define FILE_ATTRIBUTE_VALID_FLAGS 0x00007fb7 #define FILE_ATTRIBUTE_VALID_SET_FLAGS 0x000031a7 @@ -5228,6 +5538,10 @@ typedef struct _IO_STACK_LOCATION { #define FILE_OPEN_BY_FILE_ID 0x00002000 #define FILE_OPEN_FOR_BACKUP_INTENT 0x00004000 #define FILE_NO_COMPRESSION 0x00008000 +#if (NTDDI_VERSION >= NTDDI_WIN7) +#define FILE_OPEN_REQUIRING_OPLOCK 0x00010000 +#define FILE_DISALLOW_EXCLUSIVE 0x00020000 +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ #define FILE_RESERVE_OPFILTER 0x00100000 #define FILE_OPEN_REPARSE_POINT 0x00200000 #define FILE_OPEN_NO_RECALL 0x00400000 @@ -5275,6 +5589,7 @@ typedef struct _OBJECT_NAME_INFORMATION { } OBJECT_NAME_INFORMATION, *POBJECT_NAME_INFORMATION; /* Exported object types */ +extern POBJECT_TYPE NTSYSAPI CmKeyObjectType; extern POBJECT_TYPE NTSYSAPI ExEventObjectType; extern POBJECT_TYPE NTSYSAPI ExSemaphoreObjectType; extern POBJECT_TYPE NTSYSAPI IoFileObjectType; @@ -5353,7 +5668,7 @@ typedef struct _QUOTA_LIMITS { #define IPI_LEVEL 29 #define POWER_LEVEL 30 #define HIGH_LEVEL 31 -#define CLOCK_LEVEL (CLOCK2_LEVEL) +#define CLOCK_LEVEL CLOCK2_LEVEL #define KIP0PCRADDRESS 0xffdff000 #define KI_USER_SHARED_DATA 0xffdf0000 @@ -5389,8 +5704,7 @@ extern NTKERNELAPI volatile KSYSTEM_TIME KeTickCount; FORCEINLINE VOID -KeMemoryBarrier( - VOID) +KeMemoryBarrier(VOID) { volatile LONG Barrier; #if defined(__GNUC__) @@ -5400,6 +5714,11 @@ KeMemoryBarrier( #endif } +NTHALAPI +KIRQL +NTAPI +KeGetCurrentIrql(VOID); + NTHALAPI VOID FASTCALL @@ -5416,28 +5735,26 @@ KfRaiseIrql( NTHALAPI KIRQL -DDKAPI -KeRaiseIrqlToDpcLevel( - VOID); +NTAPI +KeRaiseIrqlToDpcLevel(VOID); NTHALAPI KIRQL -DDKAPI -KeRaiseIrqlToSynchLevel( - VOID); +NTAPI +KeRaiseIrqlToSynchLevel(VOID); NTHALAPI KIRQL FASTCALL KfAcquireSpinLock( - IN PKSPIN_LOCK SpinLock); + IN OUT PKSPIN_LOCK SpinLock); #define KeAcquireSpinLock(a,b) *(b) = KfAcquireSpinLock(a) NTHALAPI VOID FASTCALL KfReleaseSpinLock( - IN PKSPIN_LOCK SpinLock, + IN OUT PKSPIN_LOCK SpinLock, IN KIRQL NewIrql); #define KeReleaseSpinLock(a,b) KfReleaseSpinLock(a,b) @@ -5445,21 +5762,20 @@ NTKERNELAPI VOID FASTCALL KefAcquireSpinLockAtDpcLevel( - IN PKSPIN_LOCK SpinLock); + IN OUT PKSPIN_LOCK SpinLock); #define KeAcquireSpinLockAtDpcLevel(SpinLock) KefAcquireSpinLockAtDpcLevel(SpinLock) NTKERNELAPI VOID FASTCALL KefReleaseSpinLockFromDpcLevel( - IN PKSPIN_LOCK SpinLock); + IN OUT PKSPIN_LOCK SpinLock); #define KeReleaseSpinLockFromDpcLevel(SpinLock) KefReleaseSpinLockFromDpcLevel(SpinLock) NTSYSAPI PKTHREAD NTAPI -KeGetCurrentThread( - VOID); +KeGetCurrentThread(VOID); NTKERNELAPI NTSTATUS @@ -5489,8 +5805,7 @@ VOID _KeQueryTickCount( OUT PLARGE_INTEGER CurrentCount) { - for (;;) - { + for (;;) { CurrentCount->HighPart = KeTickCount.High1Time; CurrentCount->LowPart = KeTickCount.LowPart; if (CurrentCount->HighPart == KeTickCount.High2Time) break; @@ -5503,9 +5818,6 @@ _KeQueryTickCount( -/****************************************************************************** - * Runtime Library Functions * - ******************************************************************************/ FORCEINLINE VOID @@ -5725,8 +6037,10 @@ RtlStringFromGUID( #define RtlZeroBytes RtlZeroMemory - #if (NTDDI_VERSION >= NTDDI_WIN2K) + + + NTSYSAPI BOOLEAN NTAPI @@ -5829,7 +6143,7 @@ VOID NTAPI RtlCopyUnicodeString( IN OUT PUNICODE_STRING DestinationString, - IN PCUNICODE_STRING SourceString); + IN PCUNICODE_STRING SourceString OPTIONAL); NTSYSAPI NTSTATUS @@ -5875,7 +6189,7 @@ NTAPI RtlExtendedLargeIntegerDivide( IN LARGE_INTEGER Dividend, IN ULONG Divisor, - IN OUT PULONG Remainder); + OUT PULONG Remainder OPTIONAL); #endif #if defined(_X86_) || defined(_IA64_) @@ -6063,12 +6377,17 @@ NTAPI RtlQueryRegistryValues( IN ULONG RelativeTo, IN PCWSTR Path, - IN PRTL_QUERY_REGISTRY_TABLE QueryTable, - IN PVOID Context, + IN OUT PRTL_QUERY_REGISTRY_TABLE QueryTable, + IN PVOID Context OPTIONAL, IN PVOID Environment OPTIONAL); +#define SHORT_SIZE (sizeof(USHORT)) +#define SHORT_MASK (SHORT_SIZE - 1) #define LONG_SIZE (sizeof(LONG)) +#define LONGLONG_SIZE (sizeof(LONGLONG)) #define LONG_MASK (LONG_SIZE - 1) +#define LONGLONG_MASK (LONGLONG_SIZE - 1) +#define LOWBYTE_MASK 0x00FF /* VOID * RtlRetrieveUlong( @@ -6137,15 +6456,50 @@ RtlSetDaclSecurityDescriptor( IN PACL Dacl OPTIONAL, IN BOOLEAN DaclDefaulted OPTIONAL); +#if defined(_AMD64_) + /* VOID * RtlStoreUlong( * IN PULONG Address, * IN ULONG Value); */ -#if defined(_AMD64_) #define RtlStoreUlong(Address,Value) \ *(ULONG UNALIGNED *)(Address) = (Value) + +/* VOID + * RtlStoreUlonglong( + * IN OUT PULONGLONG Address, + * ULONGLONG Value); + */ +#define RtlStoreUlonglong(Address,Value) \ + *(ULONGLONG UNALIGNED *)(Address) = (Value) + +/* VOID + * RtlStoreUshort( + * IN PUSHORT Address, + * IN USHORT Value); + */ +#define RtlStoreUshort(Address,Value) \ + *(USHORT UNALIGNED *)(Address) = (Value) + +/* VOID + * RtlRetrieveUshort( + * PUSHORT DestinationAddress, + * PUSHORT SourceAddress); + */ +#define RtlRetrieveUshort(DestAddress,SrcAddress) \ + *(USHORT UNALIGNED *)(DestAddress) = *(USHORT)(SrcAddress) + +/* VOID + * RtlRetrieveUlong( + * PULONG DestinationAddress, + * PULONG SourceAddress); + */ +#define RtlRetrieveUlong(DestAddress,SrcAddress) \ + *(ULONG UNALIGNED *)(DestAddress) = *(PULONG)(SrcAddress) + #else + #define RtlStoreUlong(Address,Value) \ if ((ULONG_PTR)(Address) & LONG_MASK) { \ ((PUCHAR) (Address))[LONG_LEAST_SIGNIFICANT_BIT] = (UCHAR)(FIRSTBYTE(Value)); \ @@ -6301,7 +6655,9 @@ RtlWriteRegistryValue( IN PVOID ValueData, IN ULONG ValueLength); -#endif // (NTDDI_VERSION >= NTDDI_WIN2K) + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ + #if (NTDDI_VERSION >= NTDDI_WIN2KSP3) NTSYSAPI @@ -6312,7 +6668,11 @@ RtlPrefetchMemoryNonTemporal( IN SIZE_T Length); #endif + #if (NTDDI_VERSION >= NTDDI_WINXP) + + + NTSYSAPI VOID NTAPI @@ -6340,9 +6700,22 @@ RtlTestBit( IN PRTL_BITMAP BitMapHeader, IN ULONG BitNumber); -#endif // (NTDDI_VERSION >= NTDDI_WINXP) +NTSYSAPI +NTSTATUS +NTAPI +RtlHashUnicodeString( + IN CONST UNICODE_STRING *String, + IN BOOLEAN CaseInSensitive, + IN ULONG HashAlgorithm, + OUT PULONG HashValue); + + +#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ #if (NTDDI_VERSION >= NTDDI_VISTA) + + + NTSYSAPI ULONG NTAPI @@ -6383,7 +6756,51 @@ RtlFindClosestEncodableLength( IN ULONGLONG SourceLength, OUT PULONGLONG TargetLength); -#endif +NTSYSAPI +NTSTATUS +NTAPI +RtlCmEncodeMemIoResource( + IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor, + IN UCHAR Type, + IN ULONGLONG Length, + IN ULONGLONG Start); + + +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + +#if (NTDDI_VERSION >= NTDDI_WIN7) + + + +NTSYSAPI +NTSTATUS +NTAPI +RtlUnicodeToUTF8N( + OUT PCHAR UTF8StringDestination, + IN ULONG UTF8StringMaxByteCount, + OUT PULONG UTF8StringActualByteCount, + IN PCWCH UnicodeStringSource, + IN ULONG UnicodeStringByteCount); + +NTSYSAPI +NTSTATUS +NTAPI +RtlUTF8ToUnicodeN( + OUT PWSTR UnicodeStringDestination, + IN ULONG UnicodeStringMaxByteCount, + OUT PULONG UnicodeStringActualByteCount, + IN PCCH UTF8StringSource, + IN ULONG UTF8StringByteCount); + +NTSYSAPI +ULONG64 +NTAPI +RtlGetEnabledExtendedFeatures( + IN ULONG64 FeatureMask); + + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + #if !defined(MIDL_PASS) /* inline funftions */ @@ -6391,7 +6808,8 @@ RtlFindClosestEncodableLength( static __inline LARGE_INTEGER NTAPI_INLINE -RtlConvertLongToLargeInteger(LONG SignedInteger) +RtlConvertLongToLargeInteger( + IN LONG SignedInteger) { LARGE_INTEGER ret; ret.QuadPart = SignedInteger; @@ -6403,7 +6821,7 @@ static __inline LARGE_INTEGER NTAPI_INLINE RtlConvertUlongToLargeInteger( - ULONG UnsignedInteger) + IN ULONG UnsignedInteger) { LARGE_INTEGER ret; ret.QuadPart = UnsignedInteger; @@ -6452,7 +6870,8 @@ RtlEnlargedIntegerMultiply( FORCEINLINE VOID -RtlInitEmptyAnsiString(OUT PANSI_STRING AnsiString, +RtlInitEmptyAnsiString( + OUT PANSI_STRING AnsiString, IN PCHAR Buffer, IN USHORT BufferSize) { @@ -6474,12 +6893,14 @@ RtlInitEmptyUnicodeString( } #if defined(_AMD64_) || defined(_IA64_) + + static __inline LARGE_INTEGER NTAPI_INLINE RtlExtendedIntegerMultiply( - LARGE_INTEGER Multiplicand, - LONG Multiplier) + IN LARGE_INTEGER Multiplicand, + IN LONG Multiplier) { LARGE_INTEGER ret; ret.QuadPart = Multiplicand.QuadPart * Multiplier; @@ -6490,9 +6911,9 @@ static __inline LARGE_INTEGER NTAPI_INLINE RtlExtendedLargeIntegerDivide( - LARGE_INTEGER Dividend, - ULONG Divisor, - PULONG Remainder) + IN LARGE_INTEGER Dividend, + IN ULONG Divisor, + OUT PULONG Remainder OPTIONAL) { LARGE_INTEGER ret; ret.QuadPart = (ULONG64)Dividend.QuadPart / Divisor; @@ -6500,7 +6921,11 @@ RtlExtendedLargeIntegerDivide( *Remainder = (ULONG)(Dividend.QuadPart % Divisor); return ret; } -#endif + + + +#endif /* defined(_AMD64_) || defined(_IA64_) */ + #if defined(_AMD64_) @@ -6582,8 +7007,7 @@ RtlSecureZeroMemory( __stosb((PUCHAR)vptr, 0, Size); #else char * endptr = (char *)vptr + Size; - while (vptr < endptr) - { + while (vptr < endptr) { *vptr = 0; vptr++; } #endif @@ -6592,16 +7016,16 @@ RtlSecureZeroMemory( #if defined(_M_AMD64) FORCEINLINE -ULONG +BOOLEAN RtlCheckBit( IN PRTL_BITMAP BitMapHeader, IN ULONG BitPosition) { - return BitTest((LONG CONST*)BitMapHeader->Buffer, BitPosition); + return BitTest64((LONG64 CONST*)BitMapHeader->Buffer, (LONG64)BitPosition); } #else #define RtlCheckBit(BMH,BP) (((((PLONG)(BMH)->Buffer)[(BP)/32]) >> ((BP)%32)) & 0x1) -#endif // defined(_M_AMD64) +#endif /* defined(_M_AMD64) */ #define RtlLargeIntegerGreaterThan(X,Y) ( \ (((X).HighPart == (Y).HighPart) && ((X).LowPart > (Y).LowPart)) || \ @@ -6725,8 +7149,15 @@ RtlCheckBit( #define NT_ASSERTMSG(exp) ((VOID)0) #define NT_ASSERTMSGW(exp) ((VOID)0) +#define NT_VERIFY(_exp) ((_exp) ? TRUE : FALSE) +#define NT_VERIFYMSG(_msg, _exp ) ((_exp) ? TRUE : FALSE) +#define NT_VERIFYMSGW(_msg, _exp) ((_exp) ? TRUE : FALSE) + #endif /* DBG */ +#define InitializeListHead32(ListHead) (\ + (ListHead)->Flink = (ListHead)->Blink = PtrToUlong((ListHead))) + #if !defined(_WINBASE_) #if defined(_WIN64) && (defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_) || defined(_NTOSP_)) @@ -6748,18 +7179,14 @@ InitializeSListHead( #endif #if defined(_WIN64) - if (((ULONG_PTR)SListHead & 0xf) != 0) - { + if (((ULONG_PTR)SListHead & 0xf) != 0) { RtlRaiseStatus(STATUS_DATATYPE_MISALIGNMENT); } #endif - RtlZeroMemory(SListHead, sizeof(SLIST_HEADER)); - #if defined(_IA64_) FeatureBits = __getReg(CV_IA64_CPUID4); - if ((FeatureBits & KF_16BYTE_INSTR) != 0) - { + if ((FeatureBits & KF_16BYTE_INSTR) != 0) { SListHead->Header16.HeaderType = 1; SListHead->Header16.Init = 1; } @@ -6833,6 +7260,8 @@ KeClearEvent( #if (NTDDI_VERSION >= NTDDI_WIN2K) + +#if defined(_NTDDK_) || defined(_NTIFS_) NTKERNELAPI VOID NTAPI @@ -6840,6 +7269,7 @@ ProbeForRead( IN CONST VOID *Address, /* CONST is added */ IN SIZE_T Length, IN ULONG Alignment); +#endif /* defined(_NTDDK_) || defined(_NTIFS_) */ NTKERNELAPI VOID @@ -6849,7 +7279,9 @@ ProbeForWrite( IN SIZE_T Length, IN ULONG Alignment); + #if defined(SINGLE_GROUP_LEGACY_API) + NTKERNELAPI VOID NTAPI @@ -6871,16 +7303,16 @@ KeSetTargetProcessorDpc( NTKERNELAPI KAFFINITY NTAPI -KeQueryActiveProcessors( - VOID); -#endif +KeQueryActiveProcessors(VOID); + + +#endif /* defined(SINGLE_GROUP_LEGACY_API) */ #if !defined(_M_AMD64) NTKERNELAPI ULONGLONG NTAPI -KeQueryInterruptTime( - VOID); +KeQueryInterruptTime(VOID); NTKERNELAPI VOID @@ -6889,6 +7321,36 @@ KeQuerySystemTime( OUT PLARGE_INTEGER CurrentTime); #endif /* !_M_AMD64 */ +#if !defined(_X86_) +NTKERNELAPI +KIRQL +NTAPI +KeAcquireSpinLockRaiseToDpc( + IN OUT PKSPIN_LOCK SpinLock); + +#define KeAcquireSpinLock(SpinLock, OldIrql) \ + *(OldIrql) = KeAcquireSpinLockRaiseToDpc(SpinLock) + +NTKERNELAPI +VOID +NTAPI +KeAcquireSpinLockAtDpcLevel( + IN OUT PKSPIN_LOCK SpinLock); + +NTKERNELAPI +VOID +NTAPI +KeReleaseSpinLock( + IN OUT PKSPIN_LOCK SpinLock, + IN KIRQL NewIrql); + +NTKERNELAPI +VOID +NTAPI +KeReleaseSpinLockFromDpcLevel( + IN OUT PKSPIN_LOCK SpinLock); +#endif /* !_X86_ */ + #if defined(_X86_) && (defined(_WDM_INCLUDED_) || defined(WIN9X_COMPAT_SPINLOCK)) NTKERNELAPI VOID @@ -7026,8 +7488,7 @@ KeQueryPriorityThread( NTKERNELAPI ULONG NTAPI -KeQueryTimeIncrement( - VOID); +KeQueryTimeIncrement(VOID); NTKERNELAPI LONG @@ -7041,7 +7502,6 @@ NTAPI KeReadStateMutex( IN PRKMUTEX Mutex); - NTKERNELAPI LONG NTAPI @@ -7279,13 +7739,10 @@ KeRegisterBugCheckReasonCallback( #endif /* (NTDDI_VERSION >= NTDDI_WINXPSP1) */ #if (NTDDI_VERSION >= NTDDI_WINXPSP2) - NTKERNELAPI VOID NTAPI -KeFlushQueuedDpcs( - VOID); - +KeFlushQueuedDpcs(VOID); #endif /* (NTDDI_VERSION >= NTDDI_WINXPSP2) */ #if (NTDDI_VERSION >= NTDDI_WS03) @@ -7337,10 +7794,12 @@ FASTCALL KeTestSpinLock( IN PKSPIN_LOCK SpinLock); + #endif /* (NTDDI_VERSION >= NTDDI_WS03) */ #if (NTDDI_VERSION >= NTDDI_WS03SP1) + NTKERNELAPI BOOLEAN FASTCALL @@ -7350,64 +7809,53 @@ KeTryToAcquireSpinLockAtDpcLevel( NTKERNELAPI BOOLEAN NTAPI -KeAreAllApcsDisabled( - VOID); +KeAreAllApcsDisabled(VOID); NTKERNELAPI VOID FASTCALL KeAcquireGuardedMutex( - IN OUT PKGUARDED_MUTEX GuardedMutex -); + IN OUT PKGUARDED_MUTEX GuardedMutex); NTKERNELAPI VOID FASTCALL KeAcquireGuardedMutexUnsafe( - IN OUT PKGUARDED_MUTEX GuardedMutex -); + IN OUT PKGUARDED_MUTEX GuardedMutex); NTKERNELAPI VOID NTAPI -KeEnterGuardedRegion( - VOID -); +KeEnterGuardedRegion(VOID); NTKERNELAPI VOID NTAPI -KeLeaveGuardedRegion( - VOID -); +KeLeaveGuardedRegion(VOID); NTKERNELAPI VOID FASTCALL KeInitializeGuardedMutex( - OUT PKGUARDED_MUTEX GuardedMutex -); + OUT PKGUARDED_MUTEX GuardedMutex); NTKERNELAPI VOID FASTCALL KeReleaseGuardedMutexUnsafe( - IN OUT PKGUARDED_MUTEX GuardedMutex -); + IN OUT PKGUARDED_MUTEX GuardedMutex); NTKERNELAPI VOID FASTCALL KeReleaseGuardedMutex( - IN OUT PKGUARDED_MUTEX GuardedMutex -); + IN OUT PKGUARDED_MUTEX GuardedMutex); NTKERNELAPI BOOLEAN FASTCALL KeTryToAcquireGuardedMutex( - IN OUT PKGUARDED_MUTEX GuardedMutex -); + IN OUT PKGUARDED_MUTEX GuardedMutex); #endif /* (NTDDI_VERSION >= NTDDI_WS03SP1) */ @@ -7433,12 +7881,19 @@ KeQueryDpcWatchdogInformation( OUT PKDPC_WATCHDOG_INFORMATION WatchdogInformation); #if defined(SINGLE_GROUP_LEGACY_API) + NTKERNELAPI KAFFINITY NTAPI KeSetSystemAffinityThreadEx( IN KAFFINITY Affinity); +NTKERNELAPI +VOID +NTAPI +KeRevertToUserAffinityThreadEx( + IN KAFFINITY Affinity); + NTKERNELAPI ULONG NTAPI @@ -7448,9 +7903,8 @@ KeQueryActiveProcessorCount( NTKERNELAPI ULONG NTAPI -KeQueryMaximumProcessorCount( - VOID); -#endif +KeQueryMaximumProcessorCount(VOID); +#endif /* SINGLE_GROUP_LEGACY_API */ #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ @@ -7470,6 +7924,7 @@ KeDeregisterProcessorChangeCallback( #if (NTDDI_VERSION >= NTDDI_WIN7) + ULONG64 NTAPI KeQueryTotalCycleTimeProcess( @@ -7515,8 +7970,7 @@ KeSetCoalescableTimer( NTKERNELAPI ULONGLONG NTAPI -KeQueryUnbiasedInterruptTime( - VOID); +KeQueryUnbiasedInterruptTime(VOID); NTKERNELAPI ULONG @@ -7533,19 +7987,17 @@ KeQueryMaximumProcessorCountEx( NTKERNELAPI USHORT NTAPI -KeQueryActiveGroupCount( - VOID); +KeQueryActiveGroupCount(VOID); NTKERNELAPI USHORT NTAPI -KeQueryMaximumGroupCount( - VOID); +KeQueryMaximumGroupCount(VOID); NTKERNELAPI KAFFINITY NTAPI -KeQueryGroupAffinity +KeQueryGroupAffinity( IN USHORT GroupNumber); NTKERNELAPI @@ -7571,14 +8023,12 @@ KeQueryNodeMaximumProcessorCount( NTKERNELAPI USHORT NTAPI -KeQueryHighestNodeNumber( - VOID); +KeQueryHighestNodeNumber(VOID); NTKERNELAPI USHORT NTAPI -KeGetCurrentNodeNumber( - VOID); +KeGetCurrentNodeNumber(VOID); NTKERNELAPI NTSTATUS @@ -7602,6 +8052,17 @@ NTAPI KeRestoreExtendedProcessorState( IN PXSTATE_SAVE XStateSave); +NTSTATUS +NTAPI +KeGetProcessorNumberFromIndex( + IN ULONG ProcIndex, + OUT PPROCESSOR_NUMBER ProcNumber); + +ULONG +NTAPI +KeGetProcessorIndexFromNumber( + IN PPROCESSOR_NUMBER ProcNumber); + #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ #if !defined(_IA64_) @@ -7637,17 +8098,14 @@ KeFlushWriteBuffer(VOID); #define PAGED_CODE() -#endif +#endif /* DBG */ #define PAGED_CODE_LOCKED() NOP_FUNCTION; /****************************************************************************** * Memory manager Functions * ******************************************************************************/ - -/* - * Alignment Macros - */ +/* Alignment Macros */ #define ALIGN_DOWN_BY(size, align) \ ((ULONG_PTR)(size) & ~((ULONG_PTR)(align) - 1)) @@ -7709,6 +8167,9 @@ KeFlushWriteBuffer(VOID); ((ULONG) ((((ULONG_PTR) (_Va) & (PAGE_SIZE - 1)) \ + (_Size) + (PAGE_SIZE - 1)) >> PAGE_SHIFT)) +#define COMPUTE_PAGES_SPANNED(Va, Size) \ + ADDRESS_AND_SIZE_TO_SPAN_PAGES(Va,Size) + /* * ULONG * MmGetMdlByteCount( @@ -7725,6 +8186,8 @@ KeFlushWriteBuffer(VOID); #define MmGetMdlByteOffset(_Mdl) \ ((_Mdl)->ByteOffset) +#define MmGetMdlBaseVa(Mdl) ((Mdl)->StartVa) + /* * PPFN_NUMBER * MmGetMdlPfnArray( @@ -7923,8 +8386,7 @@ MmProbeAndLockPages( NTKERNELAPI MM_SYSTEMSIZE NTAPI -MmQuerySystemSize( - VOID); +MmQuerySystemSize(VOID); NTKERNELAPI VOID @@ -7974,7 +8436,9 @@ MmUnmapLockedPages( IN PVOID BaseAddress, IN PMDL MemoryDescriptorList); -#endif + + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ #if (NTDDI_VERSION >= NTDDI_WINXP) @@ -8044,6 +8508,15 @@ MmAllocatePagesForMdlEx( IN ULONG Flags); #endif +#if (NTDDI_VERSION >= NTDDI_VISTA) + +NTKERNELAPI +LOGICAL +NTAPI +MmIsDriverVerifyingByAddress( + IN PVOID AddressWithinSection); +#endif + /****************************************************************************** * Security Manager Functions * ******************************************************************************/ @@ -8176,7 +8649,6 @@ SeGetWorldRights( #endif /* SE_NTFS_WORLD_CACHE */ #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ - /****************************************************************************** * Configuration Manager Functions * ******************************************************************************/ @@ -8197,6 +8669,53 @@ CmUnRegisterCallback( IN LARGE_INTEGER Cookie); #endif +#if (NTDDI_VERSION >= NTDDI_VISTA) + +NTKERNELAPI +NTSTATUS +NTAPI +CmRegisterCallbackEx( + PEX_CALLBACK_FUNCTION Function, + PCUNICODE_STRING Altitude, + PVOID Driver, + PVOID Context, + PLARGE_INTEGER Cookie, + PVOID Reserved); + +NTKERNELAPI +VOID +NTAPI +CmGetCallbackVersion( + OUT PULONG Major OPTIONAL, + OUT PULONG Minor OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +CmSetCallbackObjectContext( + IN OUT PVOID Object, + IN PLARGE_INTEGER Cookie, + IN PVOID NewContext, + OUT PVOID *OldContext OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +CmCallbackGetKeyObjectID( + IN PLARGE_INTEGER Cookie, + IN PVOID Object, + OUT PULONG_PTR ObjectID OPTIONAL, + OUT PCUNICODE_STRING *ObjectName OPTIONAL); + +NTKERNELAPI +PVOID +NTAPI +CmGetBoundTransaction( + IN PLARGE_INTEGER Cookie, + IN PVOID Object); + +#endif // NTDDI_VERSION >= NTDDI_VISTA + /****************************************************************************** * I/O Manager Functions * @@ -8712,6 +9231,7 @@ IoMapTransfer( #endif #if (NTDDI_VERSION >= NTDDI_WIN2K) + NTKERNELAPI VOID NTAPI @@ -9050,8 +9570,7 @@ IoGetDeviceInterfaceAlias( NTKERNELAPI PEPROCESS NTAPI -IoGetCurrentProcess( - VOID); +IoGetCurrentProcess(VOID); NTKERNELAPI NTSTATUS @@ -9099,8 +9618,7 @@ IoGetDriverObjectExtension( NTKERNELAPI PVOID NTAPI -IoGetInitialStack( - VOID); +IoGetInitialStack(VOID); NTKERNELAPI PDEVICE_OBJECT @@ -9374,7 +9892,7 @@ NTKERNELAPI NTSTATUS NTAPI IoWMIWriteEvent( - IN PVOID WnodeEventItem); + IN OUT PVOID WnodeEventItem); NTKERNELAPI VOID @@ -9382,7 +9900,25 @@ NTAPI IoWriteErrorLogEntry( IN PVOID ElEntry); -#endif +NTKERNELAPI +PIRP +NTAPI +IoGetTopLevelIrp(VOID); + +NTKERNELAPI +NTSTATUS +NTAPI +IoRegisterLastChanceShutdownNotification( + IN PDEVICE_OBJECT DeviceObject); + +NTKERNELAPI +VOID +NTAPI +IoSetTopLevelIrp( + IN PIRP Irp OPTIONAL); + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ + #if (NTDDI_VERSION >= NTDDI_WINXP) @@ -9418,7 +9954,7 @@ PIRP NTAPI IoCsqRemoveNextIrp( IN PIO_CSQ Csq, - IN PVOID PeekContext); + IN PVOID PeekContext OPTIONAL); NTKERNELAPI BOOLEAN @@ -9546,6 +10082,214 @@ IoWMISetSingleItem( #endif +#if (NTDDI_VERSION >= NTDDI_WS03) + +NTKERNELAPI +NTSTATUS +NTAPI +IoCsqInsertIrpEx( + IN PIO_CSQ Csq, + IN PIRP Irp, + IN PIO_CSQ_IRP_CONTEXT Context OPTIONAL, + IN PVOID InsertContext OPTIONAL); +#endif /* (NTDDI_VERSION >= NTDDI_WS03) */ + + +#if (NTDDI_VERSION >= NTDDI_VISTA) + +NTKERNELAPI +NTSTATUS +NTAPI +IoGetBootDiskInformationLite( + OUT PBOOTDISK_INFORMATION_LITE *BootDiskInformation); + +NTKERNELAPI +NTSTATUS +NTAPI +IoCheckShareAccessEx( + IN ACCESS_MASK DesiredAccess, + IN ULONG DesiredShareAccess, + IN OUT PFILE_OBJECT FileObject, + IN OUT PSHARE_ACCESS ShareAccess, + IN BOOLEAN Update, + IN PBOOLEAN WritePermission); + +NTKERNELAPI +NTSTATUS +NTAPI +IoConnectInterruptEx( + IN OUT PIO_CONNECT_INTERRUPT_PARAMETERS Parameters); + +NTKERNELAPI +VOID +NTAPI +IoDisconnectInterruptEx( + IN PIO_DISCONNECT_INTERRUPT_PARAMETERS Parameters); + +LOGICAL +NTAPI +IoWithinStackLimits( + IN ULONG_PTR RegionStart, + IN SIZE_T RegionSize); + +NTKERNELAPI +VOID +NTAPI +IoSetShareAccessEx( + IN ACCESS_MASK DesiredAccess, + IN ULONG DesiredShareAccess, + IN OUT PFILE_OBJECT FileObject, + OUT PSHARE_ACCESS ShareAccess, + IN PBOOLEAN WritePermission); + +ULONG +NTAPI +IoSizeofWorkItem(VOID); + +VOID +NTAPI +IoInitializeWorkItem( + IN PVOID IoObject, + IN PIO_WORKITEM IoWorkItem); + +VOID +NTAPI +IoUninitializeWorkItem( + IN PIO_WORKITEM IoWorkItem); + +VOID +NTAPI +IoQueueWorkItemEx( + IN PIO_WORKITEM IoWorkItem, + IN PIO_WORKITEM_ROUTINE_EX WorkerRoutine, + IN WORK_QUEUE_TYPE QueueType, + IN PVOID Context OPTIONAL); + +IO_PRIORITY_HINT +NTAPI +IoGetIoPriorityHint( + IN PIRP Irp); + +NTSTATUS +NTAPI +IoSetIoPriorityHint( + IN PIRP Irp, + IN IO_PRIORITY_HINT PriorityHint); + +NTSTATUS +NTAPI +IoAllocateSfioStreamIdentifier( + IN PFILE_OBJECT FileObject, + IN ULONG Length, + IN PVOID Signature, + OUT PVOID *StreamIdentifier); + +PVOID +NTAPI +IoGetSfioStreamIdentifier( + IN PFILE_OBJECT FileObject, + IN PVOID Signature); + +NTSTATUS +NTAPI +IoFreeSfioStreamIdentifier( + IN PFILE_OBJECT FileObject, + IN PVOID Signature); + +NTKERNELAPI +NTSTATUS +NTAPI +IoRequestDeviceEjectEx( + IN PDEVICE_OBJECT PhysicalDeviceObject, + IN PIO_DEVICE_EJECT_CALLBACK Callback OPTIONAL, + IN PVOID Context OPTIONAL, + IN PDRIVER_OBJECT DriverObject OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +IoSetDevicePropertyData( + IN PDEVICE_OBJECT Pdo, + IN CONST DEVPROPKEY *PropertyKey, + IN LCID Lcid, + IN ULONG Flags, + IN DEVPROPTYPE Type, + IN ULONG Size, + IN PVOID Data OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +IoGetDevicePropertyData( + PDEVICE_OBJECT Pdo, + CONST DEVPROPKEY *PropertyKey, + LCID Lcid, + ULONG Flags, + ULONG Size, + PVOID Data, + PULONG RequiredSize, + PDEVPROPTYPE Type); + +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + +#define IoCallDriverStackSafeDefault(a, b) IoCallDriver(a, b) + +#if (NTDDI_VERSION >= NTDDI_WS08) +NTKERNELAPI +NTSTATUS +NTAPI +IoReplacePartitionUnit( + IN PDEVICE_OBJECT TargetPdo, + IN PDEVICE_OBJECT SparePdo, + IN ULONG Flags); +#endif + +#if (NTDDI_VERSION >= NTDDI_WIN7) + +NTKERNELAPI +NTSTATUS +NTAPI +IoGetAffinityInterrupt( + IN PKINTERRUPT InterruptObject, + OUT PGROUP_AFFINITY GroupAffinity); + +NTSTATUS +NTAPI +IoGetContainerInformation( + IN IO_CONTAINER_INFORMATION_CLASS InformationClass, + IN PVOID ContainerObject OPTIONAL, + IN OUT PVOID Buffer OPTIONAL, + IN ULONG BufferLength); + +NTSTATUS +NTAPI +IoRegisterContainerNotification( + IN IO_CONTAINER_NOTIFICATION_CLASS NotificationClass, + IN PIO_CONTAINER_NOTIFICATION_FUNCTION CallbackFunction, + IN PVOID NotificationInformation OPTIONAL, + IN ULONG NotificationInformationLength, + OUT PVOID CallbackRegistration); + +VOID +NTAPI +IoUnregisterContainerNotification( + IN PVOID CallbackRegistration); + +NTKERNELAPI +NTSTATUS +NTAPI +IoUnregisterPlugPlayNotificationEx( + IN PVOID NotificationEntry); + +NTKERNELAPI +NTSTATUS +NTAPI +IoGetDeviceNumaNode( + IN PDEVICE_OBJECT Pdo, + OUT PUSHORT NodeNumber); + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + #if defined(_WIN64) NTKERNELAPI ULONG @@ -9665,12 +10409,10 @@ IoSetCompletionRoutine( IoReleaseRemoveLockAndWaitEx(_RemoveLock, _Tag, sizeof(IO_REMOVE_LOCK)) #if defined(_WIN64) - NTKERNELAPI BOOLEAN IoIs32bitProcess( IN PIRP Irp OPTIONAL); - #endif #define PLUGPLAY_REGKEY_DEVICE 1 @@ -9744,7 +10486,7 @@ IoInitializeDpcRequest( FORCEINLINE VOID IoCopyCurrentIrpStackLocationToNext( - IN PIRP Irp) + IN OUT PIRP Irp) { PIO_STACK_LOCATION irpSp; PIO_STACK_LOCATION nextIrpSp; @@ -9763,8 +10505,7 @@ IoGetStackLimits( FORCEINLINE ULONG_PTR -IoGetRemainingStackSize( - VOID) +IoGetRemainingStackSize(VOID) { ULONG_PTR End, Begin; ULONG_PTR Result; @@ -9774,6 +10515,19 @@ IoGetRemainingStackSize( return Result; } +#if (NTDDI_VERSION >= NTDDI_WS03) +VOID +FORCEINLINE +IoInitializeThreadedDpcRequest( + IN PDEVICE_OBJECT DeviceObject, + IN PIO_DPC_ROUTINE DpcRoutine) +{ + KeInitializeThreadedDpc(&DeviceObject->Dpc, + (PKDEFERRED_ROUTINE) DpcRoutine, + DeviceObject ); +} +#endif + /****************************************************************************** * Power Management Support Functions * ******************************************************************************/ @@ -9883,16 +10637,15 @@ PoUnregisterPowerSettingCallback( #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ #if (NTDDI_VERSION >= NTDDI_VISTASP1) - NTKERNELAPI VOID NTAPI PoSetDeviceBusyEx( IN OUT PULONG IdlePointer); - #endif /* (NTDDI_VERSION >= NTDDI_VISTASP1) */ #if (NTDDI_VERSION >= NTDDI_WIN7) + NTKERNELAPI VOID NTAPI @@ -9969,7 +10722,7 @@ PoCreatePowerRequest( #define ExInterlockedRemoveHeadList ExfInterlockedRemoveHeadList #define ExInterlockedPopEntryList ExfInterlockedPopEntryList #define ExInterlockedPushEntryList ExfInterlockedPushEntryList -#endif +#endif /* defined(_X86_) */ #if defined(_WIN64) @@ -10010,7 +10763,7 @@ ExpInterlockedPushEntrySList( #define ExInterlockedPushEntrySList(Head, Entry, Lock) \ ExpInterlockedPushEntrySList(Head, Entry) -#else // !defined(_WIN64) +#else /* !defined(_WIN64) */ #define ExQueryDepthSList(listhead) (listhead)->Depth @@ -10018,9 +10771,10 @@ NTKERNELAPI PSINGLE_LIST_ENTRY FASTCALL ExInterlockedFlushSList( - IN PSLIST_HEADER ListHead); + IN OUT PSLIST_HEADER ListHead); #if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_) + NTKERNELAPI PSINGLE_LIST_ENTRY FASTCALL @@ -10113,28 +10867,28 @@ NTKERNELAPI BOOLEAN NTAPI ExAcquireResourceExclusiveLite( - IN PERESOURCE Resource, + IN OUT PERESOURCE Resource, IN BOOLEAN Wait); NTKERNELAPI BOOLEAN NTAPI ExAcquireResourceSharedLite( - IN PERESOURCE Resource, + IN OUT PERESOURCE Resource, IN BOOLEAN Wait); NTKERNELAPI BOOLEAN NTAPI ExAcquireSharedStarveExclusive( - IN PERESOURCE Resource, + IN OUT PERESOURCE Resource, IN BOOLEAN Wait); NTKERNELAPI BOOLEAN NTAPI ExAcquireSharedWaitForExclusive( - IN PERESOURCE Resource, + IN OUT PERESOURCE Resource, IN BOOLEAN Wait); NTKERNELAPI @@ -10169,7 +10923,7 @@ ExAllocatePoolWithQuotaTag( #ifndef POOL_TAGGING #define ExAllocatePoolWithQuotaTag(a,b,c) ExAllocatePoolWithQuota(a,b) -#endif /* POOL_TAGGING */ +#endif NTKERNELAPI PVOID @@ -10192,7 +10946,7 @@ NTKERNELAPI VOID NTAPI ExConvertExclusiveToSharedLite( - IN PERESOURCE Resource); + IN OUT PERESOURCE Resource); NTKERNELAPI NTSTATUS @@ -10207,7 +10961,7 @@ NTKERNELAPI VOID NTAPI ExDeleteNPagedLookasideList( - IN PNPAGED_LOOKASIDE_LIST Lookaside); + IN OUT PNPAGED_LOOKASIDE_LIST Lookaside); NTKERNELAPI VOID @@ -10219,7 +10973,7 @@ NTKERNELAPI NTSTATUS NTAPI ExDeleteResourceLite( - IN PERESOURCE Resource); + IN OUT PERESOURCE Resource); NTKERNELAPI VOID @@ -10247,8 +11001,7 @@ ExGetExclusiveWaiterCount( NTKERNELAPI KPROCESSOR_MODE NTAPI -ExGetPreviousMode( - VOID); +ExGetPreviousMode(VOID); NTKERNELAPI ULONG @@ -10284,7 +11037,7 @@ NTKERNELAPI NTSTATUS NTAPI ExInitializeResourceLite( - IN PERESOURCE Resource); + OUT PERESOURCE Resource); NTKERNELAPI LARGE_INTEGER @@ -10308,12 +11061,15 @@ FASTCALL ExInterlockedAddUlong( IN PULONG Addend, IN ULONG Increment, - PKSPIN_LOCK Lock); + IN OUT PKSPIN_LOCK Lock); #if defined(_AMD64_) || defined(_IA64_) + #define ExInterlockedCompareExchange64(Destination, Exchange, Comperand, Lock) \ InterlockedCompareExchange64(Destination, *(Exchange), *(Comperand)) + #elif defined(_X86_) + NTKERNELAPI LONGLONG FASTCALL @@ -10321,9 +11077,12 @@ ExfInterlockedCompareExchange64( IN OUT LONGLONG volatile *Destination, IN PLONGLONG Exchange, IN PLONGLONG Comperand); + #define ExInterlockedCompareExchange64(Destination, Exchange, Comperand, Lock) \ ExfInterlockedCompareExchange64(Destination, Exchange, Comperand) + #else + NTKERNELAPI LONGLONG FASTCALL @@ -10332,45 +11091,46 @@ ExInterlockedCompareExchange64( IN PLONGLONG Exchange, IN PLONGLONG Comparand, IN PKSPIN_LOCK Lock); -#endif + +#endif /* defined(_AMD64_) || defined(_IA64_) */ NTKERNELAPI PLIST_ENTRY FASTCALL ExInterlockedInsertHeadList( - IN PLIST_ENTRY ListHead, - IN PLIST_ENTRY ListEntry, - IN PKSPIN_LOCK Lock); + IN OUT PLIST_ENTRY ListHead, + IN OUT PLIST_ENTRY ListEntry, + IN OUT PKSPIN_LOCK Lock); NTKERNELAPI PLIST_ENTRY FASTCALL ExInterlockedInsertTailList( - IN PLIST_ENTRY ListHead, - IN PLIST_ENTRY ListEntry, - IN PKSPIN_LOCK Lock); + IN OUT PLIST_ENTRY ListHead, + IN OUT PLIST_ENTRY ListEntry, + IN OUT PKSPIN_LOCK Lock); NTKERNELAPI PSINGLE_LIST_ENTRY FASTCALL ExInterlockedPopEntryList( - IN PSINGLE_LIST_ENTRY ListHead, - IN PKSPIN_LOCK Lock); + IN OUT PSINGLE_LIST_ENTRY ListHead, + IN OUT PKSPIN_LOCK Lock); NTKERNELAPI PSINGLE_LIST_ENTRY FASTCALL ExInterlockedPushEntryList( - IN PSINGLE_LIST_ENTRY ListHead, - IN PSINGLE_LIST_ENTRY ListEntry, - IN PKSPIN_LOCK Lock); + IN OUT PSINGLE_LIST_ENTRY ListHead, + IN OUT PSINGLE_LIST_ENTRY ListEntry, + IN OUT PKSPIN_LOCK Lock); NTKERNELAPI PLIST_ENTRY FASTCALL ExInterlockedRemoveHeadList( - IN PLIST_ENTRY ListHead, - IN PKSPIN_LOCK Lock); + IN OUT PLIST_ENTRY ListHead, + IN OUT PKSPIN_LOCK Lock); NTKERNELAPI BOOLEAN @@ -10404,14 +11164,14 @@ VOID NTAPI ExNotifyCallback( IN PCALLBACK_OBJECT CallbackObject, - IN PVOID Argument1, - IN PVOID Argument2); + IN PVOID Argument1 OPTIONAL, + IN PVOID Argument2 OPTIONAL); NTKERNELAPI VOID NTAPI ExQueueWorkItem( - IN PWORK_QUEUE_ITEM WorkItem, + IN OUT PWORK_QUEUE_ITEM WorkItem, IN WORK_QUEUE_TYPE QueueType); NTKERNELAPI @@ -10427,32 +11187,32 @@ NTAPI ExRegisterCallback( IN PCALLBACK_OBJECT CallbackObject, IN PCALLBACK_FUNCTION CallbackFunction, - IN PVOID CallbackContext); + IN PVOID CallbackContext OPTIONAL); NTKERNELAPI NTSTATUS NTAPI ExReinitializeResourceLite( - IN PERESOURCE Resource); + IN OUT PERESOURCE Resource); NTKERNELAPI VOID NTAPI ExReleaseResourceForThreadLite( - IN PERESOURCE Resource, + IN OUT PERESOURCE Resource, IN ERESOURCE_THREAD ResourceThreadId); NTKERNELAPI VOID FASTCALL ExReleaseResourceLite( - IN PERESOURCE Resource); + IN OUT PERESOURCE Resource); NTKERNELAPI VOID NTAPI ExSetResourceOwnerPointer( - IN PERESOURCE Resource, + IN OUT PERESOURCE Resource, IN PVOID OwnerPointer); NTKERNELAPI @@ -10473,12 +11233,12 @@ NTKERNELAPI VOID NTAPI ExUnregisterCallback( - IN PVOID CbRegistration); + IN OUT PVOID CbRegistration); - -#endif // (NTDDI_VERSION >= NTDDI_WIN2K) +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ #if (NTDDI_VERSION >= NTDDI_WINXP) + NTKERNELAPI BOOLEAN FASTCALL @@ -10495,7 +11255,7 @@ NTKERNELAPI VOID FASTCALL ExReInitializeRundownProtection( - OUT PEX_RUNDOWN_REF RunRef); + IN OUT PEX_RUNDOWN_REF RunRef); NTKERNELAPI VOID @@ -10521,9 +11281,10 @@ FASTCALL ExWaitForRundownProtectionRelease( IN OUT PEX_RUNDOWN_REF RunRef); -#endif // (NTDDI_VERSION >= NTDDI_WINXP) +#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ #if (NTDDI_VERSION >= NTDDI_WINXPSP2) + NTKERNELAPI BOOLEAN FASTCALL @@ -10537,9 +11298,11 @@ FASTCALL ExReleaseRundownProtectionEx( IN OUT PEX_RUNDOWN_REF RunRef, IN ULONG Count); -#endif // (NTDDI_VERSION >= NTDDI_WINXPSP2) + +#endif /* (NTDDI_VERSION >= NTDDI_WINXPSP2) */ #if (NTDDI_VERSION >= NTDDI_WS03SP1) + NTKERNELAPI PEX_RUNDOWN_REF_CACHE_AWARE NTAPI @@ -10551,9 +11314,92 @@ NTKERNELAPI SIZE_T NTAPI ExSizeOfRundownProtectionCacheAware(VOID); -#endif // (NTDDI_VERSION >= NTDDI_WS03SP1) + +NTKERNELAPI +PVOID +NTAPI +ExEnterCriticalRegionAndAcquireResourceShared( + IN OUT PERESOURCE Resource); + +NTKERNELAPI +PVOID +NTAPI +ExEnterCriticalRegionAndAcquireResourceExclusive( + IN OUT PERESOURCE Resource); + +NTKERNELAPI +PVOID +NTAPI +ExEnterCriticalRegionAndAcquireSharedWaitForExclusive( + IN OUT PERESOURCE Resource); + +NTKERNELAPI +VOID +FASTCALL +ExReleaseResourceAndLeaveCriticalRegion( + IN OUT PERESOURCE Resource); + +NTKERNELAPI +VOID +NTAPI +ExInitializeRundownProtectionCacheAware( + OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware, + IN SIZE_T RunRefSize); + +NTKERNELAPI +VOID +NTAPI +ExFreeCacheAwareRundownProtection( + IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware); + +NTKERNELAPI +BOOLEAN +FASTCALL +ExAcquireRundownProtectionCacheAware( + IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware); + +NTKERNELAPI +VOID +FASTCALL +ExReleaseRundownProtectionCacheAware( + IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware); + +NTKERNELAPI +BOOLEAN +FASTCALL +ExAcquireRundownProtectionCacheAwareEx( + IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware, + IN ULONG Count); + +NTKERNELAPI +VOID +FASTCALL +ExReleaseRundownProtectionCacheAwareEx( + IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRef, + IN ULONG Count); + +NTKERNELAPI +VOID +FASTCALL +ExWaitForRundownProtectionReleaseCacheAware( + IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRef); + +NTKERNELAPI +VOID +FASTCALL +ExReInitializeRundownProtectionCacheAware( + IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware); + +NTKERNELAPI +VOID +FASTCALL +ExRundownCompletedCacheAware( + IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware); + +#endif /* (NTDDI_VERSION >= NTDDI_WS03SP1) */ #if (NTDDI_VERSION >= NTDDI_VISTA) + NTKERNELAPI NTSTATUS NTAPI @@ -10576,7 +11422,7 @@ ExAllocateFromNPagedLookasideList( { PVOID Entry; - Lookaside->L.TotalAllocates++; + Lookaside->L.TotalAllocates += 1; Entry = InterlockedPopEntrySList(&Lookaside->L.ListHead); if (Entry == NULL) { Lookaside->L.AllocateMisses++; @@ -10606,7 +11452,7 @@ ExAllocateFromPagedLookasideList( static __inline VOID ExFreeToNPagedLookasideList( - IN PNPAGED_LOOKASIDE_LIST Lookaside, + IN OUT PNPAGED_LOOKASIDE_LIST Lookaside, IN PVOID Entry) { Lookaside->L.TotalFrees++; @@ -10691,10 +11537,99 @@ ObReleaseObjectSecurity( #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ +#if (NTDDI_VERSION >= NTDDI_VISTA) +NTKERNELAPI +VOID +NTAPI +ObDereferenceObjectDeferDelete( + IN PVOID Object); +#endif + +#if (NTDDI_VERSION >= NTDDI_VISTASP1) +NTKERNELAPI +NTSTATUS +NTAPI +ObRegisterCallbacks( + IN POB_CALLBACK_REGISTRATION CallbackRegistration, + OUT PVOID *RegistrationHandle); + +NTKERNELAPI +VOID +NTAPI +ObUnRegisterCallbacks( + IN PVOID RegistrationHandle); + +NTKERNELAPI +USHORT +NTAPI +ObGetFilterVersion(VOID); + +#endif /* (NTDDI_VERSION >= NTDDI_VISTASP1) */ + +#if (NTDDI_VERSION >= NTDDI_WIN7) + +NTKERNELAPI +NTSTATUS +NTAPI +ObReferenceObjectByHandleWithTag( + IN HANDLE Handle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_TYPE ObjectType OPTIONAL, + IN KPROCESSOR_MODE AccessMode, + IN ULONG Tag, + OUT PVOID *Object, + OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL); + +NTKERNELAPI +LONG_PTR +FASTCALL +ObfReferenceObjectWithTag( + IN PVOID Object, + IN ULONG Tag); + +NTKERNELAPI +NTSTATUS +NTAPI +ObReferenceObjectByPointerWithTag( + IN PVOID Object, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_TYPE ObjectType OPTIONAL, + IN KPROCESSOR_MODE AccessMode, + IN ULONG Tag); + +NTKERNELAPI +LONG_PTR +FASTCALL +ObfDereferenceObjectWithTag( + IN PVOID Object, + IN ULONG Tag); + +NTKERNELAPI +VOID +NTAPI +ObDereferenceObjectDeferDeleteWithTag( + IN PVOID Object, + IN ULONG Tag); + +#define ObDereferenceObject ObfDereferenceObject +#define ObReferenceObject ObfReferenceObject +#define ObDereferenceObjectWithTag ObfDereferenceObjectWithTag +#define ObReferenceObjectWithTag ObfReferenceObjectWithTag + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + + /****************************************************************************** * Process Manager Functions * ******************************************************************************/ +NTKERNELAPI +NTSTATUS +NTAPI +PsWrapApcWow64Thread( + IN OUT PVOID *ApcContext, + IN OUT PVOID *ApcRoutine); + /* * PEPROCESS * PsGetCurrentProcess(VOID) @@ -10702,19 +11637,16 @@ ObReleaseObjectSecurity( #define PsGetCurrentProcess IoGetCurrentProcess #if !defined(_PSGETCURRENTTHREAD_) - #define _PSGETCURRENTTHREAD_ - FORCEINLINE PETHREAD NTAPI -PsGetCurrentThread ( - VOID) +PsGetCurrentThread(VOID) { return (PETHREAD)KeGetCurrentThread(); } +#endif /* !_PSGETCURRENTTHREAD_ */ -#endif #if (NTDDI_VERSION >= NTDDI_WIN2K) @@ -10736,18 +11668,18 @@ NTAPI PsTerminateSystemThread( IN NTSTATUS ExitStatus); -#endif + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ /****************************************************************************** * WMI Library Support Functions * ******************************************************************************/ #ifdef RUN_WPP - #if (NTDDI_VERSION >= NTDDI_WINXP) NTKERNELAPI NTSTATUS -DDKCDECLAPI +__cdecl WmiTraceMessage( IN TRACEHANDLE LoggerHandle, IN ULONG MessageFlags, @@ -10755,8 +11687,7 @@ WmiTraceMessage( IN USHORT MessageNumber, IN ...); #endif - -#endif +#endif /* RUN_WPP */ #if (NTDDI_VERSION >= NTDDI_WINXP) @@ -10774,7 +11705,7 @@ WmiQueryTraceInformation( /* FIXME: Get va_list from where? */ NTKERNELAPI NTSTATUS -DDKCDECLAPI +__cdecl WmiTraceMessageVa( IN TRACEHANDLE LoggerHandle, IN ULONG MessageFlags, @@ -10790,8 +11721,9 @@ WmiTraceMessageVa( ******************************************************************************/ #ifndef _DBGNT_ + ULONG -DDKCDECLAPI +__cdecl DbgPrint( IN PCSTR Format, IN ...); @@ -10801,6 +11733,7 @@ DbgPrint( #define KdPrint(_x_) DbgPrint _x_ #define KdPrintEx(_x_) DbgPrintEx _x_ +#define vKdPrintEx(_x_) vDbgPrintEx _x_ #define vKdPrintExWithPrefix(_x_) vDbgPrintExWithPrefix _x_ #define KdBreakPoint() DbgBreakPoint() #define KdBreakPointWithStatus(s) DbgBreakPointWithStatus(s) @@ -10809,6 +11742,7 @@ DbgPrint( #define KdPrint(_x_) #define KdPrintEx(_x_) +#define vKdPrintEx(_x_) #define vKdPrintExWithPrefix(_x_) #define KdBreakPoint() #define KdBreakPointWithStatus(s) @@ -10868,22 +11802,19 @@ vDbgPrintExWithPrefix( NTKERNELAPI NTSTATUS NTAPI -KdDisableDebugger( - VOID); +KdDisableDebugger(VOID); NTKERNELAPI NTSTATUS NTAPI -KdEnableDebugger( - VOID); +KdEnableDebugger(VOID); #if (_MSC_FULL_VER >= 150030729) && !defined(IMPORT_NATIVE_DBG_BREAK) #define DbgBreakPoint __debugbreak #else VOID NTAPI -DbgBreakPoint( - VOID); +DbgBreakPoint(VOID); #endif NTSYSAPI @@ -10894,7 +11825,7 @@ DbgBreakPointWithStatus( NTSYSAPI ULONG -DDKCDECLAPI +_cdecl DbgPrintReturnControlC( IN PCCH Format, IN ...); @@ -10905,7 +11836,7 @@ DbgPrintReturnControlC( NTSYSAPI ULONG -DDKCDECLAPI +_cdecl DbgPrintEx( IN ULONG ComponentId, IN ULONG Level, @@ -10930,14 +11861,10 @@ DbgSetDebugFilterState( #endif #if (NTDDI_VERSION >= NTDDI_WS03) - NTKERNELAPI BOOLEAN NTAPI -KdRefreshDebuggerNotPresent( - VOID -); - +KdRefreshDebuggerNotPresent(VOID); #endif #if (NTDDI_VERSION >= NTDDI_WS03SP1) @@ -10954,6 +11881,7 @@ KdChangeOption( #endif #if defined(USE_DMA_MACROS) && !defined(_NTHAL_) && (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_) + FORCEINLINE PVOID NTAPI @@ -11056,14 +11984,19 @@ typedef enum _ENLISTMENT_INFORMATION_CLASS { * ZwXxx Functions * ******************************************************************************/ + /* Constants */ #define NtCurrentProcess() ( (HANDLE)(LONG_PTR) -1 ) #define ZwCurrentProcess() NtCurrentProcess() #define NtCurrentThread() ( (HANDLE)(LONG_PTR) -2 ) #define ZwCurrentThread() NtCurrentThread() + + #if (NTDDI_VERSION >= NTDDI_WIN2K) + + NTSYSAPI NTSTATUS NTAPI @@ -11329,10 +12262,11 @@ ZwQueryFullAttributesFile( IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PFILE_NETWORK_OPEN_INFORMATION FileInformation); -#endif -#if (NTDDI_VERSION >= NTDDI_WIN2003) +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ + +#if (NTDDI_VERSION >= NTDDI_WS03) NTSYSCALLAPI NTSTATUS NTAPI @@ -11340,7 +12274,6 @@ ZwOpenEvent( OUT PHANDLE EventHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes); - #endif #if (NTDDI_VERSION >= NTDDI_VISTA) @@ -11667,10 +12600,13 @@ ZwSinglePhaseReject( IN PLARGE_INTEGER TmVirtualClock OPTIONAL); -#endif +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + #if (NTDDI_VERSION >= NTDDI_WIN7) + + NTSYSAPI NTSTATUS NTAPI From c5e2c557f7d48029cabf5416096832e747a5143e Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 29 Mar 2010 07:37:26 +0000 Subject: [PATCH 084/134] revert r46561 svn path=/trunk/; revision=46562 --- reactos/include/ddk/wdm.h | 1658 ++++++++----------------------------- 1 file changed, 361 insertions(+), 1297 deletions(-) diff --git a/reactos/include/ddk/wdm.h b/reactos/include/ddk/wdm.h index 5304539949c..e4aed4f40cf 100644 --- a/reactos/include/ddk/wdm.h +++ b/reactos/include/ddk/wdm.h @@ -41,7 +41,7 @@ #ifndef GUID_DEFINED #include -#endif +#endif /* GUID_DEFINED */ #ifndef _KTMTYPES_ typedef GUID UOW, *PUOW; @@ -95,12 +95,6 @@ extern "C" { #if defined(_MSC_VER) -/* Disable some warnings */ -#pragma warning(disable:4115) /* Named type definition in parentheses */ -#pragma warning(disable:4201) /* Nameless unions and structs */ -#pragma warning(disable:4214) /* Bit fields of other types than int */ -#pragma warning(disable:4820) /* Padding added, due to alignemnet requirement */ - /* Indicate if #pragma alloc_text() is supported */ #if defined(_M_IX86) || defined(_M_AMD64) || defined(_M_IA64) #define ALLOC_PRAGMA 1 @@ -136,8 +130,8 @@ typedef struct _HAL_PRIVATE_DISPATCH_TABLE *PHAL_PRIVATE_DISPATCH_TABLE; typedef struct _DEVICE_HANDLER_OBJECT *PDEVICE_HANDLER_OBJECT; typedef struct _ADAPTER_OBJECT *PADAPTER_OBJECT; typedef struct _CALLBACK_OBJECT *PCALLBACK_OBJECT; -typedef struct _EPROCESS *PEPROCESS; typedef struct _ETHREAD *PETHREAD; +typedef struct _EPROCESS *PEPROCESS; typedef struct _IO_TIMER *PIO_TIMER; typedef struct _KINTERRUPT *PKINTERRUPT; typedef struct _KPROCESS *PKPROCESS; @@ -155,8 +149,7 @@ typedef struct _CONTEXT *PCONTEXT; #if defined(__GNUC__) static __inline__ BOOLEAN -InterlockedBitTestAndSet( - IN LONG volatile *Base, +InterlockedBitTestAndSet(IN LONG volatile *Base, IN LONG Bit) { #if defined(_M_IX86) @@ -174,8 +167,7 @@ InterlockedBitTestAndSet( } static __inline__ BOOLEAN -InterlockedBitTestAndReset( - IN LONG volatile *Base, +InterlockedBitTestAndReset(IN LONG volatile *Base, IN LONG Bit) { #if defined(_M_IX86) @@ -192,7 +184,7 @@ InterlockedBitTestAndReset( #endif } -#endif /* defined(__GNUC__) */ +#endif #define BitScanForward _BitScanForward #define BitScanReverse _BitScanReverse @@ -204,10 +196,6 @@ InterlockedBitTestAndReset( #define InterlockedBitTestAndReset _interlockedbittestandreset #ifdef _M_AMD64 -#define BitTest64 _bittest64 -#define BitTestAndComplement64 _bittestandcomplement64 -#define BitTestAndSet64 _bittestandset64 -#define BitTestAndReset64 _bittestandreset64 #define InterlockedBitTestAndSet64 _interlockedbittestandset64 #define InterlockedBitTestAndReset64 _interlockedbittestandreset64 #endif @@ -251,7 +239,7 @@ InterlockedExchangeAdd( IN OUT LONG volatile *Addend, IN LONG Value); -#else /* !defined(NO_INTERLOCKED_INTRINSICS) */ +#else // !defined(NO_INTERLOCKED_INTRINSICS) #define InterlockedExchange _InterlockedExchange #define InterlockedIncrement _InterlockedIncrement @@ -262,9 +250,9 @@ InterlockedExchangeAdd( #define InterlockedAnd _InterlockedAnd #define InterlockedXor _InterlockedXor -#endif /* !defined(NO_INTERLOCKED_INTRINSICS) */ +#endif // !defined(NO_INTERLOCKED_INTRINSICS) -#endif /* defined (_X86_) */ +#endif // defined (_X86_) #if !defined (_WIN64) /* @@ -376,7 +364,7 @@ typedef struct _RTL_BITMAP_RUN { } RTL_BITMAP_RUN, *PRTL_BITMAP_RUN; typedef NTSTATUS -(NTAPI *PRTL_QUERY_REGISTRY_ROUTINE)( +(DDKAPI *PRTL_QUERY_REGISTRY_ROUTINE)( IN PWSTR ValueName, IN ULONG ValueType, IN PVOID ValueData, @@ -410,15 +398,10 @@ typedef struct _TIME_FIELDS { #define _SLIST_HEADER_ #if defined(_WIN64) - +typedef struct DECLSPEC_ALIGN(16) _SLIST_ENTRY *PSLIST_ENTRY; typedef struct DECLSPEC_ALIGN(16) _SLIST_ENTRY { - struct _SLIST_ENTRY *Next; -} SLIST_ENTRY, *PSLIST_ENTRY; - -typedef struct _SLIST_ENTRY32 { - ULONG Next; -} SLIST_ENTRY32, *PSLIST_ENTRY32; - + PSLIST_ENTRY Next; +} SLIST_ENTRY; typedef union DECLSPEC_ALIGN(16) _SLIST_HEADER { struct { ULONGLONG Alignment; @@ -441,32 +424,11 @@ typedef union DECLSPEC_ALIGN(16) _SLIST_HEADER { ULONGLONG Reserved:2; ULONGLONG NextEntry:60; } Header16; - struct { - ULONGLONG Depth:16; - ULONGLONG Sequence:48; - ULONGLONG HeaderType:1; - ULONGLONG Reserved:3; - ULONGLONG NextEntry:60; - } HeaderX64; } SLIST_HEADER, *PSLIST_HEADER; - -typedef union _SLIST_HEADER32 { - ULONGLONG Alignment; - struct { - SLIST_ENTRY32 Next; - USHORT Depth; - USHORT Sequence; - } DUMMYSTRUCTNAME; -} SLIST_HEADER32, *PSLIST_HEADER32; - #else - #define SLIST_ENTRY SINGLE_LIST_ENTRY #define _SLIST_ENTRY _SINGLE_LIST_ENTRY #define PSLIST_ENTRY PSINGLE_LIST_ENTRY - -typedef SLIST_ENTRY SLIST_ENTRY32, *PSLIST_ENTRY32; - typedef union _SLIST_HEADER { ULONGLONG Alignment; struct { @@ -475,10 +437,7 @@ typedef union _SLIST_HEADER { USHORT Sequence; } DUMMYSTRUCTNAME; } SLIST_HEADER, *PSLIST_HEADER; - -typedef SLIST_HEADER SLIST_HEADER32, *PSLIST_HEADER32; - -#endif /* defined(_WIN64) */ +#endif #endif /* _SLIST_HEADER_ */ @@ -538,7 +497,8 @@ typedef enum _MODE { #define MAXIMUM_SUPPORTED_EXTENSION 512 #define MAXIMUM_WAIT_OBJECTS 64 -#define ASSERT_APC(Object) NT_ASSERT((Object)->Type == ApcObject) +#define ASSERT_APC(Object) \ + ASSERT((Object)->Type == ApcObject) #define ASSERT_DPC(Object) \ ASSERT(((Object)->Type == 0) || \ @@ -546,24 +506,24 @@ typedef enum _MODE { ((Object)->Type == ThreadedDpcObject)) #define ASSERT_GATE(object) \ - NT_ASSERT((((object)->Header.Type & KOBJECT_TYPE_MASK) == GateObject) || \ + ASSERT((((object)->Header.Type & KOBJECT_TYPE_MASK) == GateObject) || \ (((object)->Header.Type & KOBJECT_TYPE_MASK) == EventSynchronizationObject)) #define ASSERT_DEVICE_QUEUE(Object) \ - NT_ASSERT((Object)->Type == DeviceQueueObject) + ASSERT((Object)->Type == DeviceQueueObject) #define ASSERT_TIMER(E) \ - NT_ASSERT(((E)->Header.Type == TimerNotificationObject) || \ + ASSERT(((E)->Header.Type == TimerNotificationObject) || \ ((E)->Header.Type == TimerSynchronizationObject)) #define ASSERT_MUTANT(E) \ - NT_ASSERT((E)->Header.Type == MutantObject) + ASSERT((E)->Header.Type == MutantObject) #define ASSERT_SEMAPHORE(E) \ - NT_ASSERT((E)->Header.Type == SemaphoreObject) + ASSERT((E)->Header.Type == SemaphoreObject) #define ASSERT_EVENT(E) \ - NT_ASSERT(((E)->Header.Type == NotificationEvent) || \ + ASSERT(((E)->Header.Type == NotificationEvent) || \ ((E)->Header.Type == SynchronizationEvent)) #define DPC_NORMAL 0 @@ -574,9 +534,6 @@ typedef enum _MODE { #define GM_LOCK_WAITER_WOKEN 0x2 #define GM_LOCK_WAITER_INC 0x4 -#define LOCK_QUEUE_WAIT_BIT 0 -#define LOCK_QUEUE_OWNER_BIT 1 - #define LOCK_QUEUE_WAIT 1 #define LOCK_QUEUE_OWNER 2 #define LOCK_QUEUE_TIMER_LOCK_SHIFT 4 @@ -636,6 +593,7 @@ typedef struct _EXCEPTION_POINTERS { PCONTEXT ContextRecord; } EXCEPTION_POINTERS, *PEXCEPTION_POINTERS; + typedef enum _KBUGCHECK_CALLBACK_REASON { KbCallbackInvalid, KbCallbackReserved1, @@ -647,12 +605,11 @@ typedef enum _KBUGCHECK_CALLBACK_REASON { struct _KBUGCHECK_REASON_CALLBACK_RECORD; typedef VOID -(NTAPI KBUGCHECK_REASON_CALLBACK_ROUTINE)( +(DDKAPI *PKBUGCHECK_REASON_CALLBACK_ROUTINE)( IN KBUGCHECK_CALLBACK_REASON Reason, IN struct _KBUGCHECK_REASON_CALLBACK_RECORD *Record, IN OUT PVOID ReasonSpecificData, IN ULONG ReasonSpecificDataLength); -typedef KBUGCHECK_REASON_CALLBACK_ROUTINE *PKBUGCHECK_REASON_CALLBACK_ROUTINE; typedef struct _KBUGCHECK_REASON_CALLBACK_RECORD { LIST_ENTRY Entry; @@ -672,10 +629,9 @@ typedef enum _KBUGCHECK_BUFFER_DUMP_STATE { } KBUGCHECK_BUFFER_DUMP_STATE; typedef VOID -(NTAPI KBUGCHECK_CALLBACK_ROUTINE)( +(DDKAPI *PKBUGCHECK_CALLBACK_ROUTINE)( IN PVOID Buffer, IN ULONG Length); -typedef KBUGCHECK_CALLBACK_ROUTINE *PKBUGCHECK_CALLBACK_ROUTINE; typedef struct _KBUGCHECK_CALLBACK_RECORD { LIST_ENTRY Entry; @@ -688,10 +644,9 @@ typedef struct _KBUGCHECK_CALLBACK_RECORD { } KBUGCHECK_CALLBACK_RECORD, *PKBUGCHECK_CALLBACK_RECORD; typedef BOOLEAN -(NTAPI NMI_CALLBACK)( +(DDKAPI *PNMI_CALLBACK)( IN PVOID Context, IN BOOLEAN Handled); -typedef NMI_CALLBACK *PNMI_CALLBACK; typedef enum _TRACE_INFORMATION_CLASS { TraceIdClass, @@ -804,7 +759,7 @@ typedef enum _KINTERRUPT_MODE { #define THREAD_WAIT_OBJECTS 3 typedef VOID -(NTAPI *PKINTERRUPT_ROUTINE)( +(DDKAPI *PKINTERRUPT_ROUTINE)( VOID); typedef enum _KD_OPTION { @@ -834,24 +789,25 @@ typedef enum _INTERFACE_TYPE { } INTERFACE_TYPE, *PINTERFACE_TYPE; typedef VOID -(NTAPI *PKNORMAL_ROUTINE)( - IN PVOID NormalContext OPTIONAL, - IN PVOID SystemArgument1 OPTIONAL, - IN PVOID SystemArgument2 OPTIONAL); +(DDKAPI *PKNORMAL_ROUTINE)( + IN PVOID NormalContext, + IN PVOID SystemArgument1, + IN PVOID SystemArgument2); typedef VOID -(NTAPI *PKRUNDOWN_ROUTINE)( +(DDKAPI *PKRUNDOWN_ROUTINE)( IN struct _KAPC *Apc); typedef VOID -(NTAPI *PKKERNEL_ROUTINE)( +(DDKAPI *PKKERNEL_ROUTINE)( IN struct _KAPC *Apc, - IN OUT PKNORMAL_ROUTINE *NormalRoutine OPTIONAL, - IN OUT PVOID *NormalContext OPTIONAL, - IN OUT PVOID *SystemArgument1 OPTIONAL, - IN OUT PVOID *SystemArgument2 OPTIONAL); + IN OUT PKNORMAL_ROUTINE *NormalRoutine, + IN OUT PVOID *NormalContext, + IN OUT PVOID *SystemArgument1, + IN OUT PVOID *SystemArgument2); -typedef struct _KAPC { +typedef struct _KAPC +{ UCHAR Type; UCHAR SpareByte0; UCHAR Size; @@ -879,12 +835,13 @@ typedef struct _KDEVICE_QUEUE_ENTRY { typedef PVOID PKIPI_CONTEXT; -typedef VOID +typedef +VOID (NTAPI *PKIPI_WORKER)( - IN OUT PKIPI_CONTEXT PacketContext, - IN PVOID Parameter1 OPTIONAL, - IN PVOID Parameter2 OPTIONAL, - IN PVOID Parameter3 OPTIONAL); + IN PKIPI_CONTEXT PacketContext, + IN PVOID Parameter1, + IN PVOID Parameter2, + IN PVOID Parameter3); typedef ULONG_PTR @@ -951,14 +908,14 @@ typedef enum _KSPIN_LOCK_QUEUE_NUMBER { LockQueueMaximumLock = LockQueueTimerTableLock + LOCK_QUEUE_TIMER_TABLE_LOCKS } KSPIN_LOCK_QUEUE_NUMBER, *PKSPIN_LOCK_QUEUE_NUMBER; -#endif /* defined(_AMD64_) */ +#endif typedef VOID -(NTAPI *PKDEFERRED_ROUTINE)( +(DDKAPI *PKDEFERRED_ROUTINE)( IN struct _KDPC *Dpc, - IN PVOID DeferredContext OPTIONAL, - IN PVOID SystemArgument1 OPTIONAL, - IN PVOID SystemArgument2 OPTIONAL); + IN PVOID DeferredContext, + IN PVOID SystemArgument1, + IN PVOID SystemArgument2); typedef enum _KDPC_IMPORTANCE { LowImportance, @@ -967,7 +924,8 @@ typedef enum _KDPC_IMPORTANCE { MediumHighImportance } KDPC_IMPORTANCE; -typedef struct _KDPC { +typedef struct _KDPC +{ UCHAR Type; UCHAR Importance; volatile USHORT Number; @@ -1003,11 +961,11 @@ typedef struct _KDEVICE_QUEUE { #else BOOLEAN Busy; #endif + } KDEVICE_QUEUE, *PKDEVICE_QUEUE, *RESTRICTED_POINTER PRKDEVICE_QUEUE; #define TIMER_EXPIRED_INDEX_BITS 6 #define TIMER_PROCESSOR_INDEX_BITS 5 - typedef struct _DISPATCHER_HEADER { _ANONYMOUS_UNION union { _ANONYMOUS_STRUCT struct { @@ -1088,17 +1046,21 @@ typedef struct _KSEMAPHORE { LONG Limit; } KSEMAPHORE, *PKSEMAPHORE, *RESTRICTED_POINTER PRKSEMAPHORE; -typedef struct _KGATE { +typedef struct _KGATE +{ DISPATCHER_HEADER Header; } KGATE, *PKGATE, *RESTRICTED_POINTER PRKGATE; -typedef struct _KGUARDED_MUTEX { +typedef struct _KGUARDED_MUTEX +{ volatile LONG Count; PKTHREAD Owner; ULONG Contention; KGATE Gate; - __GNU_EXTENSION union { - __GNU_EXTENSION struct { + __GNU_EXTENSION union + { + __GNU_EXTENSION struct + { SHORT KernelApcDisable; SHORT SpecialApcDisable; }; @@ -1129,7 +1091,7 @@ typedef struct _KTIMER { } KTIMER, *PKTIMER, *RESTRICTED_POINTER PRKTIMER; typedef BOOLEAN -(NTAPI *PKSYNCHRONIZE_ROUTINE)( +(DDKAPI *PKSYNCHRONIZE_ROUTINE)( IN PVOID SynchronizeContext); typedef enum _POOL_TYPE { @@ -1150,7 +1112,8 @@ typedef enum _POOL_TYPE { NonPagedPoolCacheAlignedMustSSession } POOL_TYPE; -typedef enum _ALTERNATIVE_ARCHITECTURE_TYPE { +typedef enum _ALTERNATIVE_ARCHITECTURE_TYPE +{ StandardDesign, NEC98x86, EndAlternatives @@ -1346,9 +1309,6 @@ typedef enum _MM_SYSTEM_SIZE { MmLargeSystem } MM_SYSTEMSIZE; -extern NTKERNELAPI BOOLEAN Mm64BitPhysicalAddress; -extern PVOID MmBadPointer; - /****************************************************************************** * Executive Types * @@ -1413,33 +1373,32 @@ typedef enum _EX_POOL_PRIORITY { typedef struct _LOOKASIDE_LIST_EX *PLOOKASIDE_LIST_EX; typedef PVOID -(NTAPI *PALLOCATE_FUNCTION)( +(DDKAPI *PALLOCATE_FUNCTION)( IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes, IN ULONG Tag); typedef PVOID -(NTAPI *PALLOCATE_FUNCTION_EX)( +(DDKAPI *PALLOCATE_FUNCTION_EX)( IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes, IN ULONG Tag, IN OUT PLOOKASIDE_LIST_EX Lookaside); typedef VOID -(NTAPI *PFREE_FUNCTION)( +(DDKAPI *PFREE_FUNCTION)( IN PVOID Buffer); typedef VOID -(NTAPI *PFREE_FUNCTION_EX)( +(DDKAPI *PFREE_FUNCTION_EX)( IN PVOID Buffer, IN OUT PLOOKASIDE_LIST_EX Lookaside); typedef VOID -(NTAPI CALLBACK_FUNCTION)( - IN PVOID CallbackContext OPTIONAL, - IN PVOID Argument1 OPTIONAL, - IN PVOID Argument2 OPTIONAL); -typedef CALLBACK_FUNCTION *PCALLBACK_FUNCTION; +(DDKAPI *PCALLBACK_FUNCTION)( + IN PVOID CallbackContext, + IN PVOID Argument1, + IN PVOID Argument2); #define GENERAL_LOOKASIDE_LAYOUT \ union { \ @@ -1489,13 +1448,6 @@ typedef struct _GENERAL_LOOKASIDE_POOL { GENERAL_LOOKASIDE_LAYOUT } GENERAL_LOOKASIDE_POOL, *PGENERAL_LOOKASIDE_POOL; -#define LOOKASIDE_CHECK(f) \ - C_ASSERT(FIELD_OFFSET(GENERAL_LOOKASIDE,f) == FIELD_OFFSET(GENERAL_LOOKASIDE_POOL,f)) - -LOOKASIDE_CHECK(TotalFrees); -LOOKASIDE_CHECK(Tag); -LOOKASIDE_CHECK(Future); - typedef struct _PAGED_LOOKASIDE_LIST { GENERAL_LOOKASIDE L; #if !defined(_AMD64_) && !defined(_IA64_) @@ -1510,22 +1462,10 @@ typedef struct LOOKASIDE_ALIGN _NPAGED_LOOKASIDE_LIST { #endif } NPAGED_LOOKASIDE_LIST, *PNPAGED_LOOKASIDE_LIST; -#define LOOKASIDE_MINIMUM_BLOCK_SIZE (RTL_SIZEOF_THROUGH_FIELD (SLIST_ENTRY, Next)) - typedef struct _LOOKASIDE_LIST_EX { GENERAL_LOOKASIDE_POOL L; } LOOKASIDE_LIST_EX; -#if (NTDDI_VERSION >= NTDDI_VISTA) - -#define EX_LOOKASIDE_LIST_EX_FLAGS_RAISE_ON_FAIL 0x00000001UL -#define EX_LOOKASIDE_LIST_EX_FLAGS_FAIL_NO_RAISE 0x00000002UL - -#define EX_MAXIMUM_LOOKASIDE_DEPTH_BASE 256 -#define EX_MAXIMUM_LOOKASIDE_DEPTH_LIMIT 1024 - -#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ - typedef struct _EX_RUNDOWN_REF { __GNU_EXTENSION union { volatile ULONG_PTR Count; @@ -1536,9 +1476,8 @@ typedef struct _EX_RUNDOWN_REF { typedef struct _EX_RUNDOWN_REF_CACHE_AWARE *PEX_RUNDOWN_REF_CACHE_AWARE; typedef VOID -(NTAPI WORKER_THREAD_ROUTINE)( +(DDKAPI *PWORKER_THREAD_ROUTINE)( IN PVOID Parameter); -typedef WORKER_THREAD_ROUTINE *PWORKER_THREAD_ROUTINE; typedef struct _WORK_QUEUE_ITEM { LIST_ENTRY List; @@ -1753,15 +1692,12 @@ typedef struct _ACCESS_STATE { INITIAL_PRIVILEGE_SET InitialPrivilegeSet; PRIVILEGE_SET PrivilegeSet; } Privileges; + BOOLEAN AuditPrivileges; UNICODE_STRING ObjectName; UNICODE_STRING ObjectTypeName; } ACCESS_STATE, *PACCESS_STATE; -typedef VOID -(NTAPI *PNTFS_DEREF_EXPORTED_SECURITY_DESCRIPTOR)( - IN PVOID Vcb, - IN PSECURITY_DESCRIPTOR SecurityDescriptor); #ifndef _NTLSA_IFS_ @@ -1852,6 +1788,7 @@ typedef struct _SE_ADT_PARAMETER_ARRAY { #endif /* !_NTLSA_AUDIT_ */ #endif /* !_NTLSA_IFS_ */ + /****************************************************************************** * Power Management Support Types * ******************************************************************************/ @@ -1859,16 +1796,9 @@ typedef struct _SE_ADT_PARAMETER_ARRAY { #ifndef _PO_DDK_ #define _PO_DDK_ -#define PO_CB_SYSTEM_POWER_POLICY 0 -#define PO_CB_AC_STATUS 1 -#define PO_CB_BUTTON_COLLISION 2 -#define PO_CB_SYSTEM_STATE_LOCK 3 -#define PO_CB_LID_SWITCH_STATE 4 -#define PO_CB_PROCESSOR_POWER_POLICY 5 - /* Power States/Levels */ typedef enum _SYSTEM_POWER_STATE { - PowerSystemUnspecified = 0, + PowerSystemUnspecified, PowerSystemWorking, PowerSystemSleeping1, PowerSystemSleeping2, @@ -1937,7 +1867,7 @@ typedef enum _POWER_INFORMATION_LEVEL { } POWER_INFORMATION_LEVEL; typedef enum { - PowerActionNone = 0, + PowerActionNone, PowerActionReserved, PowerActionSleep, PowerActionHibernate, @@ -1948,7 +1878,7 @@ typedef enum { } POWER_ACTION, *PPOWER_ACTION; typedef enum _DEVICE_POWER_STATE { - PowerDeviceUnspecified = 0, + PowerDeviceUnspecified, PowerDeviceD0, PowerDeviceD1, PowerDeviceD2, @@ -1956,12 +1886,6 @@ typedef enum _DEVICE_POWER_STATE { PowerDeviceMaximum } DEVICE_POWER_STATE, *PDEVICE_POWER_STATE; -typedef enum _MONITOR_DISPLAY_STATE { - PowerMonitorOff = 0, - PowerMonitorOn, - PowerMonitorDim -} MONITOR_DISPLAY_STATE, *PMONITOR_DISPLAY_STATE; - typedef union _POWER_STATE { SYSTEM_POWER_STATE SystemState; DEVICE_POWER_STATE DeviceState; @@ -1981,148 +1905,22 @@ typedef struct { #endif /* !_PO_DDK_ */ -#define CORE_PARKING_POLICY_CHANGE_IDEAL 0 -#define CORE_PARKING_POLICY_CHANGE_SINGLE 1 -#define CORE_PARKING_POLICY_CHANGE_ROCKET 2 -#define CORE_PARKING_POLICY_CHANGE_MAX CORE_PARKING_POLICY_CHANGE_ROCKET - -DEFINE_GUID(GUID_MAX_POWER_SAVINGS, 0xA1841308, 0x3541, 0x4FAB, 0xBC, 0x81, 0xF7, 0x15, 0x56, 0xF2, 0x0B, 0x4A ); -DEFINE_GUID(GUID_MIN_POWER_SAVINGS, 0x8C5E7FDA, 0xE8BF, 0x4A96, 0x9A, 0x85, 0xA6, 0xE2, 0x3A, 0x8C, 0x63, 0x5C ); -DEFINE_GUID(GUID_TYPICAL_POWER_SAVINGS, 0x381B4222, 0xF694, 0x41F0, 0x96, 0x85, 0xFF, 0x5B, 0xB2, 0x60, 0xDF, 0x2E ); -DEFINE_GUID(NO_SUBGROUP_GUID, 0xFEA3413E, 0x7E05, 0x4911, 0x9A, 0x71, 0x70, 0x03, 0x31, 0xF1, 0xC2, 0x94 ); -DEFINE_GUID(ALL_POWERSCHEMES_GUID, 0x68A1E95E, 0x13EA, 0x41E1, 0x80, 0x11, 0x0C, 0x49, 0x6C, 0xA4, 0x90, 0xB0 ); -DEFINE_GUID(GUID_POWERSCHEME_PERSONALITY, 0x245D8541, 0x3943, 0x4422, 0xB0, 0x25, 0x13, 0xA7, 0x84, 0xF6, 0x79, 0xB7 ); -DEFINE_GUID(GUID_ACTIVE_POWERSCHEME, 0x31F9F286, 0x5084, 0x42FE, 0xB7, 0x20, 0x2B, 0x02, 0x64, 0x99, 0x37, 0x63 ); -DEFINE_GUID(GUID_VIDEO_SUBGROUP, 0x7516B95F, 0xF776, 0x4464, 0x8C, 0x53, 0x06, 0x16, 0x7F, 0x40, 0xCC, 0x99 ); -DEFINE_GUID(GUID_VIDEO_POWERDOWN_TIMEOUT, 0x3C0BC021, 0xC8A8, 0x4E07, 0xA9, 0x73, 0x6B, 0x14, 0xCB, 0xCB, 0x2B, 0x7E ); -DEFINE_GUID(GUID_VIDEO_ANNOYANCE_TIMEOUT, 0x82DBCF2D, 0xCD67, 0x40C5, 0xBF, 0xDC, 0x9F, 0x1A, 0x5C, 0xCD, 0x46, 0x63 ); -DEFINE_GUID(GUID_VIDEO_ADAPTIVE_PERCENT_INCREASE, 0xEED904DF, 0xB142, 0x4183, 0xB1, 0x0B, 0x5A, 0x11, 0x97, 0xA3, 0x78, 0x64 ); -DEFINE_GUID(GUID_VIDEO_DIM_TIMEOUT, 0x17aaa29b, 0x8b43, 0x4b94, 0xaa, 0xfe, 0x35, 0xf6, 0x4d, 0xaa, 0xf1, 0xee); -DEFINE_GUID(GUID_VIDEO_ADAPTIVE_POWERDOWN, 0x90959D22, 0xD6A1, 0x49B9, 0xAF, 0x93, 0xBC, 0xE8, 0x85, 0xAD, 0x33, 0x5B ); -DEFINE_GUID(GUID_MONITOR_POWER_ON, 0x02731015, 0x4510, 0x4526, 0x99, 0xE6, 0xE5, 0xA1, 0x7E, 0xBD, 0x1A, 0xEA ); -DEFINE_GUID(GUID_DEVICE_POWER_POLICY_VIDEO_BRIGHTNESS, 0xaded5e82L, 0xb909, 0x4619, 0x99, 0x49, 0xf5, 0xd7, 0x1d, 0xac, 0x0b, 0xcb); -DEFINE_GUID(GUID_DEVICE_POWER_POLICY_VIDEO_DIM_BRIGHTNESS, 0xf1fbfde2, 0xa960, 0x4165, 0x9f, 0x88, 0x50, 0x66, 0x79, 0x11, 0xce, 0x96); -DEFINE_GUID(GUID_VIDEO_CURRENT_MONITOR_BRIGHTNESS, 0x8ffee2c6, 0x2d01, 0x46be, 0xad, 0xb9, 0x39, 0x8a, 0xdd, 0xc5, 0xb4, 0xff); -DEFINE_GUID(GUID_VIDEO_ADAPTIVE_DISPLAY_BRIGHTNESS, 0xFBD9AA66, 0x9553, 0x4097, 0xBA, 0x44, 0xED, 0x6E, 0x9D, 0x65, 0xEA, 0xB8); -DEFINE_GUID(GUID_SESSION_DISPLAY_STATE, 0x73A5E93A, 0x5BB1, 0x4F93, 0x89, 0x5B, 0xDB, 0xD0, 0xDA, 0x85, 0x59, 0x67 ); -DEFINE_GUID(GUID_CONSOLE_DISPLAY_STATE, 0x6fe69556, 0x704a, 0x47a0, 0x8f, 0x24, 0xc2, 0x8d, 0x93, 0x6f, 0xda, 0x47); -DEFINE_GUID(GUID_ALLOW_DISPLAY_REQUIRED, 0xA9CEB8DA, 0xCD46, 0x44FB, 0xA9, 0x8B, 0x02, 0xAF, 0x69, 0xDE, 0x46, 0x23 ); -DEFINE_GUID(GUID_DISK_SUBGROUP, 0x0012EE47, 0x9041, 0x4B5D, 0x9B, 0x77, 0x53, 0x5F, 0xBA, 0x8B, 0x14, 0x42 ); -DEFINE_GUID(GUID_DISK_POWERDOWN_TIMEOUT, 0x6738E2C4, 0xE8A5, 0x4A42, 0xB1, 0x6A, 0xE0, 0x40, 0xE7, 0x69, 0x75, 0x6E ); -DEFINE_GUID(GUID_DISK_BURST_IGNORE_THRESHOLD, 0x80e3c60e, 0xbb94, 0x4ad8, 0xbb, 0xe0, 0x0d, 0x31, 0x95, 0xef, 0xc6, 0x63 ); -DEFINE_GUID(GUID_DISK_ADAPTIVE_POWERDOWN, 0x396A32E1, 0x499A, 0x40B2, 0x91, 0x24, 0xA9, 0x6A, 0xFE, 0x70, 0x76, 0x67 ); -DEFINE_GUID(GUID_SLEEP_SUBGROUP, 0x238C9FA8, 0x0AAD, 0x41ED, 0x83, 0xF4, 0x97, 0xBE, 0x24, 0x2C, 0x8F, 0x20 ); -DEFINE_GUID(GUID_SLEEP_IDLE_THRESHOLD, 0x81cd32e0, 0x7833, 0x44f3, 0x87, 0x37, 0x70, 0x81, 0xf3, 0x8d, 0x1f, 0x70 ); -DEFINE_GUID(GUID_STANDBY_TIMEOUT, 0x29F6C1DB, 0x86DA, 0x48C5, 0x9F, 0xDB, 0xF2, 0xB6, 0x7B, 0x1F, 0x44, 0xDA ); -DEFINE_GUID(GUID_UNATTEND_SLEEP_TIMEOUT, 0x7bc4a2f9, 0xd8fc, 0x4469, 0xb0, 0x7b, 0x33, 0xeb, 0x78, 0x5a, 0xac, 0xa0 ); -DEFINE_GUID(GUID_HIBERNATE_TIMEOUT, 0x9D7815A6, 0x7EE4, 0x497E, 0x88, 0x88, 0x51, 0x5A, 0x05, 0xF0, 0x23, 0x64 ); -DEFINE_GUID(GUID_HIBERNATE_FASTS4_POLICY, 0x94AC6D29, 0x73CE, 0x41A6, 0x80, 0x9F, 0x63, 0x63, 0xBA, 0x21, 0xB4, 0x7E ); -DEFINE_GUID(GUID_CRITICAL_POWER_TRANSITION, 0xB7A27025, 0xE569, 0x46c2, 0xA5, 0x04, 0x2B, 0x96, 0xCA, 0xD2, 0x25, 0xA1); -DEFINE_GUID(GUID_SYSTEM_AWAYMODE, 0x98A7F580, 0x01F7, 0x48AA, 0x9C, 0x0F, 0x44, 0x35, 0x2C, 0x29, 0xE5, 0xC0 ); -DEFINE_GUID(GUID_ALLOW_AWAYMODE, 0x25dfa149, 0x5dd1, 0x4736, 0xb5, 0xab, 0xe8, 0xa3, 0x7b, 0x5b, 0x81, 0x87 ); -DEFINE_GUID(GUID_ALLOW_STANDBY_STATES, 0xabfc2519, 0x3608, 0x4c2a, 0x94, 0xea, 0x17, 0x1b, 0x0e, 0xd5, 0x46, 0xab ); -DEFINE_GUID(GUID_ALLOW_RTC_WAKE, 0xBD3B718A, 0x0680, 0x4D9D, 0x8A, 0xB2, 0xE1, 0xD2, 0xB4, 0xAC, 0x80, 0x6D ); -DEFINE_GUID(GUID_ALLOW_SYSTEM_REQUIRED, 0xA4B195F5, 0x8225, 0x47D8, 0x80, 0x12, 0x9D, 0x41, 0x36, 0x97, 0x86, 0xE2 ); -DEFINE_GUID(GUID_SYSTEM_BUTTON_SUBGROUP, 0x4F971E89, 0xEEBD, 0x4455, 0xA8, 0xDE, 0x9E, 0x59, 0x04, 0x0E, 0x73, 0x47 ); -DEFINE_GUID(GUID_POWERBUTTON_ACTION, 0x7648EFA3, 0xDD9C, 0x4E3E, 0xB5, 0x66, 0x50, 0xF9, 0x29, 0x38, 0x62, 0x80 ); -DEFINE_GUID(GUID_POWERBUTTON_ACTION_FLAGS, 0x857E7FAC, 0x034B, 0x4704, 0xAB, 0xB1, 0xBC, 0xA5, 0x4A, 0xA3, 0x14, 0x78 ); -DEFINE_GUID(GUID_SLEEPBUTTON_ACTION, 0x96996BC0, 0xAD50, 0x47EC, 0x92, 0x3B, 0x6F, 0x41, 0x87, 0x4D, 0xD9, 0xEB ); -DEFINE_GUID(GUID_SLEEPBUTTON_ACTION_FLAGS, 0x2A160AB1, 0xB69D, 0x4743, 0xB7, 0x18, 0xBF, 0x14, 0x41, 0xD5, 0xE4, 0x93 ); -DEFINE_GUID(GUID_USERINTERFACEBUTTON_ACTION, 0xA7066653, 0x8D6C, 0x40A8, 0x91, 0x0E, 0xA1, 0xF5, 0x4B, 0x84, 0xC7, 0xE5 ); -DEFINE_GUID(GUID_LIDCLOSE_ACTION, 0x5CA83367, 0x6E45, 0x459F, 0xA2, 0x7B, 0x47, 0x6B, 0x1D, 0x01, 0xC9, 0x36 ); -DEFINE_GUID(GUID_LIDCLOSE_ACTION_FLAGS, 0x97E969AC, 0x0D6C, 0x4D08, 0x92, 0x7C, 0xD7, 0xBD, 0x7A, 0xD7, 0x85, 0x7B ); -DEFINE_GUID(GUID_LIDOPEN_POWERSTATE, 0x99FF10E7, 0x23B1, 0x4C07, 0xA9, 0xD1, 0x5C, 0x32, 0x06, 0xD7, 0x41, 0xB4 ); -DEFINE_GUID(GUID_BATTERY_SUBGROUP, 0xE73A048D, 0xBF27, 0x4F12, 0x97, 0x31, 0x8B, 0x20, 0x76, 0xE8, 0x89, 0x1F ); -DEFINE_GUID(GUID_BATTERY_DISCHARGE_ACTION_0, 0x637EA02F, 0xBBCB, 0x4015, 0x8E, 0x2C, 0xA1, 0xC7, 0xB9, 0xC0, 0xB5, 0x46 ); -DEFINE_GUID(GUID_BATTERY_DISCHARGE_LEVEL_0, 0x9A66D8D7, 0x4FF7, 0x4EF9, 0xB5, 0xA2, 0x5A, 0x32, 0x6C, 0xA2, 0xA4, 0x69 ); -DEFINE_GUID(GUID_BATTERY_DISCHARGE_FLAGS_0, 0x5dbb7c9f, 0x38e9, 0x40d2, 0x97, 0x49, 0x4f, 0x8a, 0x0e, 0x9f, 0x64, 0x0f ); -DEFINE_GUID(GUID_BATTERY_DISCHARGE_ACTION_1, 0xD8742DCB, 0x3E6A, 0x4B3C, 0xB3, 0xFE, 0x37, 0x46, 0x23, 0xCD, 0xCF, 0x06 ); -DEFINE_GUID(GUID_BATTERY_DISCHARGE_LEVEL_1, 0x8183BA9A, 0xE910, 0x48DA, 0x87, 0x69, 0x14, 0xAE, 0x6D, 0xC1, 0x17, 0x0A ); -DEFINE_GUID(GUID_BATTERY_DISCHARGE_FLAGS_1, 0xbcded951, 0x187b, 0x4d05, 0xbc, 0xcc, 0xf7, 0xe5, 0x19, 0x60, 0xc2, 0x58 ); -DEFINE_GUID(GUID_BATTERY_DISCHARGE_ACTION_2, 0x421CBA38, 0x1A8E, 0x4881, 0xAC, 0x89, 0xE3, 0x3A, 0x8B, 0x04, 0xEC, 0xE4 ); -DEFINE_GUID(GUID_BATTERY_DISCHARGE_LEVEL_2, 0x07A07CA2, 0xADAF, 0x40D7, 0xB0, 0x77, 0x53, 0x3A, 0xAD, 0xED, 0x1B, 0xFA ); -DEFINE_GUID(GUID_BATTERY_DISCHARGE_FLAGS_2, 0x7fd2f0c4, 0xfeb7, 0x4da3, 0x81, 0x17, 0xe3, 0xfb, 0xed, 0xc4, 0x65, 0x82 ); -DEFINE_GUID(GUID_BATTERY_DISCHARGE_ACTION_3, 0x80472613, 0x9780, 0x455E, 0xB3, 0x08, 0x72, 0xD3, 0x00, 0x3C, 0xF2, 0xF8 ); -DEFINE_GUID(GUID_BATTERY_DISCHARGE_LEVEL_3, 0x58AFD5A6, 0xC2DD, 0x47D2, 0x9F, 0xBF, 0xEF, 0x70, 0xCC, 0x5C, 0x59, 0x65 ); -DEFINE_GUID(GUID_BATTERY_DISCHARGE_FLAGS_3, 0x73613ccf, 0xdbfa, 0x4279, 0x83, 0x56, 0x49, 0x35, 0xf6, 0xbf, 0x62, 0xf3 ); -DEFINE_GUID(GUID_PROCESSOR_SETTINGS_SUBGROUP, 0x54533251, 0x82BE, 0x4824, 0x96, 0xC1, 0x47, 0xB6, 0x0B, 0x74, 0x0D, 0x00 ); -DEFINE_GUID(GUID_PROCESSOR_THROTTLE_POLICY, 0x57027304, 0x4AF6, 0x4104, 0x92, 0x60, 0xE3, 0xD9, 0x52, 0x48, 0xFC, 0x36 ); -DEFINE_GUID(GUID_PROCESSOR_THROTTLE_MAXIMUM, 0xBC5038F7, 0x23E0, 0x4960, 0x96, 0xDA, 0x33, 0xAB, 0xAF, 0x59, 0x35, 0xEC ); -DEFINE_GUID(GUID_PROCESSOR_THROTTLE_MINIMUM, 0x893DEE8E, 0x2BEF, 0x41E0, 0x89, 0xC6, 0xB5, 0x5D, 0x09, 0x29, 0x96, 0x4C ); -DEFINE_GUID(GUID_PROCESSOR_ALLOW_THROTTLING, 0x3b04d4fd, 0x1cc7, 0x4f23, 0xab, 0x1c, 0xd1, 0x33, 0x78, 0x19, 0xc4, 0xbb ); -DEFINE_GUID(GUID_PROCESSOR_IDLESTATE_POLICY, 0x68f262a7, 0xf621, 0x4069, 0xb9, 0xa5, 0x48, 0x74, 0x16, 0x9b, 0xe2, 0x3c); -DEFINE_GUID(GUID_PROCESSOR_PERFSTATE_POLICY, 0xBBDC3814, 0x18E9, 0x4463, 0x8A, 0x55, 0xD1, 0x97, 0x32, 0x7C, 0x45, 0xC0); -DEFINE_GUID(GUID_PROCESSOR_PERF_INCREASE_THRESHOLD, 0x06cadf0e, 0x64ed, 0x448a, 0x89, 0x27, 0xce, 0x7b, 0xf9, 0x0e, 0xb3, 0x5d ); -DEFINE_GUID(GUID_PROCESSOR_PERF_DECREASE_THRESHOLD, 0x12a0ab44, 0xfe28, 0x4fa9, 0xb3, 0xbd, 0x4b, 0x64, 0xf4, 0x49, 0x60, 0xa6 ); -DEFINE_GUID(GUID_PROCESSOR_PERF_INCREASE_POLICY, 0x465e1f50, 0xb610, 0x473a, 0xab, 0x58, 0x0, 0xd1, 0x7, 0x7d, 0xc4, 0x18); -DEFINE_GUID(GUID_PROCESSOR_PERF_DECREASE_POLICY, 0x40fbefc7, 0x2e9d, 0x4d25, 0xa1, 0x85, 0xc, 0xfd, 0x85, 0x74, 0xba, 0xc6); -DEFINE_GUID(GUID_PROCESSOR_PERF_INCREASE_TIME, 0x984cf492, 0x3bed, 0x4488, 0xa8, 0xf9, 0x42, 0x86, 0xc9, 0x7b, 0xf5, 0xaa); -DEFINE_GUID(GUID_PROCESSOR_PERF_DECREASE_TIME, 0xd8edeb9b, 0x95cf, 0x4f95, 0xa7, 0x3c, 0xb0, 0x61, 0x97, 0x36, 0x93, 0xc8); -DEFINE_GUID(GUID_PROCESSOR_PERF_TIME_CHECK, 0x4d2b0152, 0x7d5c, 0x498b, 0x88, 0xe2, 0x34, 0x34, 0x53, 0x92, 0xa2, 0xc5); -DEFINE_GUID(GUID_PROCESSOR_PERF_BOOST_POLICY, 0x45bcc044, 0xd885, 0x43e2, 0x86, 0x5, 0xee, 0xe, 0xc6, 0xe9, 0x6b, 0x59); -DEFINE_GUID(GUID_PROCESSOR_IDLE_ALLOW_SCALING, 0x6c2993b0, 0x8f48, 0x481f, 0xbc, 0xc6, 0x0, 0xdd, 0x27, 0x42, 0xaa, 0x6); -DEFINE_GUID(GUID_PROCESSOR_IDLE_DISABLE, 0x5d76a2ca, 0xe8c0, 0x402f, 0xa1, 0x33, 0x21, 0x58, 0x49, 0x2d, 0x58, 0xad); -DEFINE_GUID(GUID_PROCESSOR_IDLE_TIME_CHECK, 0xc4581c31, 0x89ab, 0x4597, 0x8e, 0x2b, 0x9c, 0x9c, 0xab, 0x44, 0xe, 0x6b); -DEFINE_GUID(GUID_PROCESSOR_IDLE_DEMOTE_THRESHOLD, 0x4b92d758, 0x5a24, 0x4851, 0xa4, 0x70, 0x81, 0x5d, 0x78, 0xae, 0xe1, 0x19); -DEFINE_GUID(GUID_PROCESSOR_IDLE_PROMOTE_THRESHOLD, 0x7b224883, 0xb3cc, 0x4d79, 0x81, 0x9f, 0x83, 0x74, 0x15, 0x2c, 0xbe, 0x7c); -DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_INCREASE_THRESHOLD, 0xdf142941, 0x20f3, 0x4edf, 0x9a, 0x4a, 0x9c, 0x83, 0xd3, 0xd7, 0x17, 0xd1 ); -DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_DECREASE_THRESHOLD, 0x68dd2f27, 0xa4ce, 0x4e11, 0x84, 0x87, 0x37, 0x94, 0xe4, 0x13, 0x5d, 0xfa); -DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_INCREASE_POLICY, 0xc7be0679, 0x2817, 0x4d69, 0x9d, 0x02, 0x51, 0x9a, 0x53, 0x7e, 0xd0, 0xc6); -DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_DECREASE_POLICY, 0x71021b41, 0xc749, 0x4d21, 0xbe, 0x74, 0xa0, 0x0f, 0x33, 0x5d, 0x58, 0x2b); -DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_MAX_CORES, 0xea062031, 0x0e34, 0x4ff1, 0x9b, 0x6d, 0xeb, 0x10, 0x59, 0x33, 0x40, 0x28); -DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_MIN_CORES, 0x0cc5b647, 0xc1df, 0x4637, 0x89, 0x1a, 0xde, 0xc3, 0x5c, 0x31, 0x85, 0x83); -DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_INCREASE_TIME, 0x2ddd5a84, 0x5a71, 0x437e, 0x91, 0x2a, 0xdb, 0x0b, 0x8c, 0x78, 0x87, 0x32); -DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_DECREASE_TIME, 0xdfd10d17, 0xd5eb, 0x45dd, 0x87, 0x7a, 0x9a, 0x34, 0xdd, 0xd1, 0x5c, 0x82); -DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_AFFINITY_HISTORY_DECREASE_FACTOR, 0x8f7b45e3, 0xc393, 0x480a, 0x87, 0x8c, 0xf6, 0x7a, 0xc3, 0xd0, 0x70, 0x82); -DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_AFFINITY_HISTORY_THRESHOLD, 0x5b33697b, 0xe89d, 0x4d38, 0xaa, 0x46, 0x9e, 0x7d, 0xfb, 0x7c, 0xd2, 0xf9); -DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_AFFINITY_WEIGHTING, 0xe70867f1, 0xfa2f, 0x4f4e, 0xae, 0xa1, 0x4d, 0x8a, 0x0b, 0xa2, 0x3b, 0x20); -DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_HISTORY_DECREASE_FACTOR, 0x1299023c, 0xbc28, 0x4f0a, 0x81, 0xec, 0xd3, 0x29, 0x5a, 0x8d, 0x81, 0x5d); -DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_HISTORY_THRESHOLD, 0x9ac18e92, 0xaa3c, 0x4e27, 0xb3, 0x07, 0x01, 0xae, 0x37, 0x30, 0x71, 0x29); -DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_WEIGHTING, 0x8809c2d8, 0xb155, 0x42d4, 0xbc, 0xda, 0x0d, 0x34, 0x56, 0x51, 0xb1, 0xdb); -DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_THRESHOLD, 0x943c8cb6, 0x6f93, 0x4227, 0xad, 0x87, 0xe9, 0xa3, 0xfe, 0xec, 0x08, 0xd1); -DEFINE_GUID(GUID_PROCESSOR_PARKING_CORE_OVERRIDE, 0xa55612aa, 0xf624, 0x42c6, 0xa4, 0x43, 0x73, 0x97, 0xd0, 0x64, 0xc0, 0x4f); -DEFINE_GUID(GUID_PROCESSOR_PARKING_PERF_STATE, 0x447235c7, 0x6a8d, 0x4cc0, 0x8e, 0x24, 0x9e, 0xaf, 0x70, 0xb9, 0x6e, 0x2b); -DEFINE_GUID(GUID_PROCESSOR_PERF_HISTORY, 0x7d24baa7, 0x0b84, 0x480f, 0x84, 0x0c, 0x1b, 0x07, 0x43, 0xc0, 0x0f, 0x5f); -DEFINE_GUID(GUID_SYSTEM_COOLING_POLICY, 0x94D3A615, 0xA899, 0x4AC5, 0xAE, 0x2B, 0xE4, 0xD8, 0xF6, 0x34, 0x36, 0x7F); -DEFINE_GUID(GUID_LOCK_CONSOLE_ON_WAKE, 0x0E796BDB, 0x100D, 0x47D6, 0xA2, 0xD5, 0xF7, 0xD2, 0xDA, 0xA5, 0x1F, 0x51 ); -DEFINE_GUID(GUID_DEVICE_IDLE_POLICY, 0x4faab71a, 0x92e5, 0x4726, 0xb5, 0x31, 0x22, 0x45, 0x59, 0x67, 0x2d, 0x19 ); -DEFINE_GUID(GUID_ACDC_POWER_SOURCE, 0x5D3E9A59, 0xE9D5, 0x4B00, 0xA6, 0xBD, 0xFF, 0x34, 0xFF, 0x51, 0x65, 0x48 ); -DEFINE_GUID(GUID_LIDSWITCH_STATE_CHANGE, 0xBA3E0F4D, 0xB817, 0x4094, 0xA2, 0xD1, 0xD5, 0x63, 0x79, 0xE6, 0xA0, 0xF3 ); -DEFINE_GUID(GUID_BATTERY_PERCENTAGE_REMAINING, 0xA7AD8041, 0xB45A, 0x4CAE, 0x87, 0xA3, 0xEE, 0xCB, 0xB4, 0x68, 0xA9, 0xE1 ); -DEFINE_GUID(GUID_IDLE_BACKGROUND_TASK, 0x515C31D8, 0xF734, 0x163D, 0xA0, 0xFD, 0x11, 0xA0, 0x8C, 0x91, 0xE8, 0xF1 ); -DEFINE_GUID(GUID_BACKGROUND_TASK_NOTIFICATION, 0xCF23F240, 0x2A54, 0x48D8, 0xB1, 0x14, 0xDE, 0x15, 0x18, 0xFF, 0x05, 0x2E ); -DEFINE_GUID(GUID_APPLAUNCH_BUTTON, 0x1A689231, 0x7399, 0x4E9A, 0x8F, 0x99, 0xB7, 0x1F, 0x99, 0x9D, 0xB3, 0xFA ); -DEFINE_GUID(GUID_PCIEXPRESS_SETTINGS_SUBGROUP, 0x501a4d13, 0x42af,0x4429, 0x9f, 0xd1, 0xa8, 0x21, 0x8c, 0x26, 0x8e, 0x20 ); -DEFINE_GUID(GUID_PCIEXPRESS_ASPM_POLICY, 0xee12f906, 0xd277, 0x404b, 0xb6, 0xda, 0xe5, 0xfa, 0x1a, 0x57, 0x6d, 0xf5 ); -DEFINE_GUID(GUID_ENABLE_SWITCH_FORCED_SHUTDOWN, 0x833a6b62, 0xdfa4, 0x46d1, 0x82, 0xf8, 0xe0, 0x9e, 0x34, 0xd0, 0x29, 0xd6 ); - -#define PERFSTATE_POLICY_CHANGE_IDEAL 0 -#define PERFSTATE_POLICY_CHANGE_SINGLE 1 -#define PERFSTATE_POLICY_CHANGE_ROCKET 2 -#define PERFSTATE_POLICY_CHANGE_MAX PERFSTATE_POLICY_CHANGE_ROCKET - -#define PROCESSOR_PERF_BOOST_POLICY_DISABLED 0 -#define PROCESSOR_PERF_BOOST_POLICY_MAX 100 - -#define POWER_DEVICE_IDLE_POLICY_PERFORMANCE 0 -#define POWER_DEVICE_IDLE_POLICY_CONSERVATIVE 1 - typedef VOID -(NTAPI REQUEST_POWER_COMPLETE)( +(DDKAPI *PREQUEST_POWER_COMPLETE)( IN struct _DEVICE_OBJECT *DeviceObject, IN UCHAR MinorFunction, IN POWER_STATE PowerState, IN PVOID Context, IN struct _IO_STATUS_BLOCK *IoStatus); -typedef REQUEST_POWER_COMPLETE *PREQUEST_POWER_COMPLETE; typedef NTSTATUS -(NTAPI POWER_SETTING_CALLBACK)( +(DDKAPI POWER_SETTING_CALLBACK)( IN LPCGUID SettingGuid, IN PVOID Value, IN ULONG ValueLength, IN OUT PVOID Context OPTIONAL); + typedef POWER_SETTING_CALLBACK *PPOWER_SETTING_CALLBACK; #define PO_CB_SYSTEM_POWER_POLICY 0 @@ -2237,7 +2035,6 @@ typedef int CM_RESOURCE_TYPE; #define REG_HIVE_EXACT_FILE_GROWTH (0x00000080L) #define REG_HIVE_NO_RM (0x00000100L) #define REG_HIVE_SINGLE_LOG (0x00000200L) -#define REG_BOOT_HIVE (0x00000400L) /* Unload Flags */ #define REG_FORCE_UNLOAD 1 @@ -2382,7 +2179,7 @@ typedef struct _CM_PARTIAL_RESOURCE_DESCRIPTOR { /* CM_PARTIAL_RESOURCE_DESCRIPTOR.ShareDisposition */ typedef enum _CM_SHARE_DISPOSITION { - CmResourceShareUndetermined = 0, + CmResourceShareUndetermined, CmResourceShareDeviceExclusive, CmResourceShareDriverExclusive, CmResourceShareShared @@ -2405,10 +2202,6 @@ typedef enum _CM_SHARE_DISPOSITION { #define CM_RESOURCE_INTERRUPT_MESSAGE 0x0002 #define CM_RESOURCE_INTERRUPT_POLICY_INCLUDED 0x0004 -#define CM_RESOURCE_INTERRUPT_LEVEL_LATCHED_BITS 0x0001 - -#define CM_RESOURCE_INTERRUPT_MESSAGE_TOKEN ((ULONG)-2) - /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypeMemory */ #define CM_RESOURCE_MEMORY_READ_WRITE 0x0000 #define CM_RESOURCE_MEMORY_READ_ONLY 0x0001 @@ -2422,15 +2215,6 @@ typedef enum _CM_SHARE_DISPOSITION { #define CM_RESOURCE_MEMORY_BAR 0x0080 #define CM_RESOURCE_MEMORY_COMPAT_FOR_INACCESSIBLE_RANGE 0x0100 -#define CM_RESOURCE_MEMORY_LARGE 0x0E00 -#define CM_RESOURCE_MEMORY_LARGE_40 0x0200 -#define CM_RESOURCE_MEMORY_LARGE_48 0x0400 -#define CM_RESOURCE_MEMORY_LARGE_64 0x0800 - -#define CM_RESOURCE_MEMORY_LARGE_40_MAXLEN 0x000000FFFFFFFF00 -#define CM_RESOURCE_MEMORY_LARGE_48_MAXLEN 0x0000FFFFFFFF0000 -#define CM_RESOURCE_MEMORY_LARGE_64_MAXLEN 0xFFFFFFFF00000000 - /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypeDma */ #define CM_RESOURCE_DMA_8 0x0000 #define CM_RESOURCE_DMA_16 0x0001 @@ -2460,7 +2244,6 @@ typedef struct _CM_RESOURCE_LIST { } CM_RESOURCE_LIST, *PCM_RESOURCE_LIST; #include - typedef struct _CM_INT13_DRIVE_PARAMETER { USHORT DriveSelect; ULONG MaxCylinders; @@ -2492,7 +2275,6 @@ typedef struct _CM_PNP_BIOS_INSTALLATION_CHECK { USHORT RealModeDataBaseAddress; ULONG ProtectedModeDataBaseAddress; } CM_PNP_BIOS_INSTALLATION_CHECK, *PCM_PNP_BIOS_INSTALLATION_CHECK; - #include typedef struct _CM_DISK_GEOMETRY_DEVICE_DATA { @@ -2560,10 +2342,7 @@ typedef enum _KEY_INFORMATION_CLASS { KeyFullInformation, KeyNameInformation, KeyCachedInformation, - KeyFlagsInformation, - KeyVirtualizationInformation, - KeyHandleTagsInformation, - MaxKeyInfoClass + KeyFlagsInformation } KEY_INFORMATION_CLASS; typedef struct _KEY_BASIC_INFORMATION { @@ -2717,11 +2496,11 @@ typedef enum _REG_NOTIFY_CLASS { } REG_NOTIFY_CLASS, *PREG_NOTIFY_CLASS; typedef NTSTATUS -(NTAPI EX_CALLBACK_FUNCTION)( +(NTAPI *PEX_CALLBACK_FUNCTION)( IN PVOID CallbackContext, IN PVOID Argument1, - IN PVOID Argument2); -typedef EX_CALLBACK_FUNCTION *PEX_CALLBACK_FUNCTION; + IN PVOID Argument2 +); typedef struct _REG_DELETE_KEY_INFORMATION { PVOID Object; @@ -3140,7 +2919,7 @@ typedef struct _CLIENT_ID { } CLIENT_ID, *PCLIENT_ID; typedef VOID -(NTAPI *PKSTART_ROUTINE)( +(DDKAPI *PKSTART_ROUTINE)( IN PVOID StartContext); typedef struct _VPB { @@ -3162,12 +2941,11 @@ typedef enum _IO_ALLOCATION_ACTION { } IO_ALLOCATION_ACTION, *PIO_ALLOCATION_ACTION; typedef IO_ALLOCATION_ACTION -(NTAPI DRIVER_CONTROL)( +(DDKAPI *PDRIVER_CONTROL)( IN struct _DEVICE_OBJECT *DeviceObject, IN struct _IRP *Irp, IN PVOID MapRegisterBase, IN PVOID Context); -typedef DRIVER_CONTROL *PDRIVER_CONTROL; typedef struct _WAIT_CONTEXT_BLOCK { KDEVICE_QUEUE_ENTRY WaitQueueEntry; @@ -3242,18 +3020,11 @@ typedef struct _IO_REMOVE_LOCK { typedef struct _IO_WORKITEM *PIO_WORKITEM; typedef VOID -(NTAPI IO_WORKITEM_ROUTINE)( +(DDKAPI IO_WORKITEM_ROUTINE)( IN PDEVICE_OBJECT DeviceObject, IN PVOID Context); typedef IO_WORKITEM_ROUTINE *PIO_WORKITEM_ROUTINE; -typedef VOID -(NTAPI IO_WORKITEM_ROUTINE_EX)( - IN PVOID IoObject, - IN PVOID Context OPTIONAL, - IN PIO_WORKITEM IoWorkItem); -typedef IO_WORKITEM_ROUTINE_EX *PIO_WORKITEM_ROUTINE_EX; - typedef struct _SHARE_ACCESS { ULONG OpenCount; ULONG Readers; @@ -3386,13 +3157,13 @@ typedef struct _PCI_SLOT_NUMBER { } PCI_SLOT_NUMBER, *PPCI_SLOT_NUMBER; typedef VOID -(NTAPI *PIO_APC_ROUTINE)( +(DDKAPI *PIO_APC_ROUTINE)( IN PVOID ApcContext, IN PIO_STATUS_BLOCK IoStatusBlock, IN ULONG Reserved); typedef VOID -(NTAPI *WMI_NOTIFICATION_CALLBACK)( +(DDKAPI *WMI_NOTIFICATION_CALLBACK)( PVOID Wnode, PVOID Context); @@ -3437,39 +3208,6 @@ typedef struct _BOOTDISK_INFORMATION_EX { BOOLEAN SystemDeviceIsGpt; } BOOTDISK_INFORMATION_EX, *PBOOTDISK_INFORMATION_EX; -#if (NTDDI_VERSION >= NTDDI_WIN7) - -typedef struct _LOADER_PARTITION_INFORMATION_EX { - ULONG PartitionStyle; - ULONG PartitionNumber; - union { - ULONG Signature; - GUID DeviceId; - }; - ULONG Flags; -} LOADER_PARTITION_INFORMATION_EX, *PLOADER_PARTITION_INFORMATION_EX; - -typedef struct _BOOTDISK_INFORMATION_LITE { - ULONG NumberEntries; - LOADER_PARTITION_INFORMATION_EX Entries[1]; -} BOOTDISK_INFORMATION_LITE, *PBOOTDISK_INFORMATION_LITE; - -#else - -#if (NTDDI_VERSION >= NTDDI_VISTA) -typedef struct _BOOTDISK_INFORMATION_LITE { - ULONG BootDeviceSignature; - ULONG SystemDeviceSignature; - GUID BootDeviceGuid; - GUID SystemDeviceGuid; - BOOLEAN BootDeviceIsGpt; - BOOLEAN SystemDeviceIsGpt; -} BOOTDISK_INFORMATION_LITE, *PBOOTDISK_INFORMATION_LITE; -#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ - -#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ - - typedef struct _EISA_MEMORY_TYPE { UCHAR ReadWrite : 1; UCHAR Cached : 1; @@ -3590,37 +3328,34 @@ typedef struct _CM_EISA_SLOT_INFORMATION { */ typedef VOID -(NTAPI *PINTERFACE_REFERENCE)( +(DDKAPI *PINTERFACE_REFERENCE)( PVOID Context); typedef VOID -(NTAPI *PINTERFACE_DEREFERENCE)( +(DDKAPI *PINTERFACE_DEREFERENCE)( PVOID Context); typedef BOOLEAN -(NTAPI TRANSLATE_BUS_ADDRESS)( +(DDKAPI *PTRANSLATE_BUS_ADDRESS)( IN PVOID Context, IN PHYSICAL_ADDRESS BusAddress, IN ULONG Length, IN OUT PULONG AddressSpace, OUT PPHYSICAL_ADDRESS TranslatedAddress); -typedef TRANSLATE_BUS_ADDRESS *PTRANSLATE_BUS_ADDRESS; typedef struct _DMA_ADAPTER* -(NTAPI GET_DMA_ADAPTER)( +(DDKAPI *PGET_DMA_ADAPTER)( IN PVOID Context, IN struct _DEVICE_DESCRIPTION *DeviceDescriptor, OUT PULONG NumberOfMapRegisters); -typedef GET_DMA_ADAPTER *PGET_DMA_ADAPTER; typedef ULONG -(NTAPI GET_SET_DEVICE_DATA)( +(DDKAPI *PGET_SET_DEVICE_DATA)( IN PVOID Context, IN ULONG DataType, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length); -typedef GET_SET_DEVICE_DATA *PGET_SET_DEVICE_DATA; /* PCI_DEVICE_PRESENCE_PARAMETERS.Flags */ #define PCI_USE_SUBSYSTEM_IDS 0x00000001 @@ -3645,20 +3380,18 @@ typedef struct _PCI_DEVICE_PRESENCE_PARAMETERS { } PCI_DEVICE_PRESENCE_PARAMETERS, *PPCI_DEVICE_PRESENCE_PARAMETERS; typedef BOOLEAN -(NTAPI PCI_IS_DEVICE_PRESENT)( +(DDKAPI *PPCI_IS_DEVICE_PRESENT)( IN USHORT VendorID, IN USHORT DeviceID, IN UCHAR RevisionID, IN USHORT SubVendorID, IN USHORT SubSystemID, IN ULONG Flags); -typedef PCI_IS_DEVICE_PRESENT *PPCI_IS_DEVICE_PRESENT; typedef BOOLEAN -(NTAPI PCI_IS_DEVICE_PRESENT_EX)( +(DDKAPI *PPCI_IS_DEVICE_PRESENT_EX)( IN PVOID Context, IN PPCI_DEVICE_PRESENCE_PARAMETERS Parameters); -typedef PCI_IS_DEVICE_PRESENT_EX *PPCI_IS_DEVICE_PRESENT_EX; typedef struct _BUS_INTERFACE_STANDARD { USHORT Size; @@ -3989,15 +3722,13 @@ typedef enum _IO_NOTIFICATION_EVENT_CATEGORY { #define PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES 0x00000001 typedef NTSTATUS -(NTAPI DRIVER_NOTIFICATION_CALLBACK_ROUTINE)( +(DDKAPI *PDRIVER_NOTIFICATION_CALLBACK_ROUTINE)( IN PVOID NotificationStructure, IN PVOID Context); -typedef DRIVER_NOTIFICATION_CALLBACK_ROUTINE *PDRIVER_NOTIFICATION_CALLBACK_ROUTINE; typedef VOID -(NTAPI DEVICE_CHANGE_COMPLETE_CALLBACK)( +(DDKAPI *PDEVICE_CHANGE_COMPLETE_CALLBACK)( IN PVOID Context); -typedef DEVICE_CHANGE_COMPLETE_CALLBACK *PDEVICE_CHANGE_COMPLETE_CALLBACK; typedef enum _FILE_INFORMATION_CLASS { FileDirectoryInformation = 1, @@ -4161,7 +3892,7 @@ typedef struct _ERESOURCE #define RESOURCE_HASH_TABLE_SIZE 64 typedef BOOLEAN -(NTAPI FAST_IO_CHECK_IF_POSSIBLE)( +(DDKAPI *PFAST_IO_CHECK_IF_POSSIBLE)( IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, @@ -4170,10 +3901,9 @@ typedef BOOLEAN IN BOOLEAN CheckForReadOperation, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject); -typedef FAST_IO_CHECK_IF_POSSIBLE *PFAST_IO_CHECK_IF_POSSIBLE; typedef BOOLEAN -(NTAPI FAST_IO_READ)( +(DDKAPI *PFAST_IO_READ)( IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, @@ -4182,10 +3912,9 @@ typedef BOOLEAN OUT PVOID Buffer, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject); -typedef FAST_IO_READ *PFAST_IO_READ; typedef BOOLEAN -(NTAPI FAST_IO_WRITE)( +(DDKAPI *PFAST_IO_WRITE)( IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, @@ -4194,28 +3923,25 @@ typedef BOOLEAN IN PVOID Buffer, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject); -typedef FAST_IO_WRITE *PFAST_IO_WRITE; typedef BOOLEAN -(NTAPI FAST_IO_QUERY_BASIC_INFO)( +(DDKAPI *PFAST_IO_QUERY_BASIC_INFO)( IN struct _FILE_OBJECT *FileObject, IN BOOLEAN Wait, OUT PFILE_BASIC_INFORMATION Buffer, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject); -typedef FAST_IO_QUERY_BASIC_INFO *PFAST_IO_QUERY_BASIC_INFO; typedef BOOLEAN -(NTAPI FAST_IO_QUERY_STANDARD_INFO)( +(DDKAPI *PFAST_IO_QUERY_STANDARD_INFO)( IN struct _FILE_OBJECT *FileObject, IN BOOLEAN Wait, OUT PFILE_STANDARD_INFORMATION Buffer, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject); -typedef FAST_IO_QUERY_STANDARD_INFO *PFAST_IO_QUERY_STANDARD_INFO; typedef BOOLEAN -(NTAPI FAST_IO_LOCK)( +(DDKAPI *PFAST_IO_LOCK)( IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER FileOffset, IN PLARGE_INTEGER Length, @@ -4225,10 +3951,9 @@ typedef BOOLEAN BOOLEAN ExclusiveLock, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject); -typedef FAST_IO_LOCK *PFAST_IO_LOCK; typedef BOOLEAN -(NTAPI FAST_IO_UNLOCK_SINGLE)( +(DDKAPI *PFAST_IO_UNLOCK_SINGLE)( IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER FileOffset, IN PLARGE_INTEGER Length, @@ -4236,27 +3961,24 @@ typedef BOOLEAN ULONG Key, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject); -typedef FAST_IO_UNLOCK_SINGLE *PFAST_IO_UNLOCK_SINGLE; typedef BOOLEAN -(NTAPI FAST_IO_UNLOCK_ALL)( +(DDKAPI *PFAST_IO_UNLOCK_ALL)( IN struct _FILE_OBJECT *FileObject, PEPROCESS ProcessId, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject); -typedef FAST_IO_UNLOCK_ALL *PFAST_IO_UNLOCK_ALL; typedef BOOLEAN -(NTAPI FAST_IO_UNLOCK_ALL_BY_KEY)( +(DDKAPI *PFAST_IO_UNLOCK_ALL_BY_KEY)( IN struct _FILE_OBJECT *FileObject, PVOID ProcessId, ULONG Key, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject); -typedef FAST_IO_UNLOCK_ALL_BY_KEY *PFAST_IO_UNLOCK_ALL_BY_KEY; typedef BOOLEAN -(NTAPI FAST_IO_DEVICE_CONTROL)( +(DDKAPI *PFAST_IO_DEVICE_CONTROL)( IN struct _FILE_OBJECT *FileObject, IN BOOLEAN Wait, IN PVOID InputBuffer OPTIONAL, @@ -4266,43 +3988,37 @@ typedef BOOLEAN IN ULONG IoControlCode, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject); -typedef FAST_IO_DEVICE_CONTROL *PFAST_IO_DEVICE_CONTROL; typedef VOID -(NTAPI FAST_IO_ACQUIRE_FILE)( +(DDKAPI *PFAST_IO_ACQUIRE_FILE)( IN struct _FILE_OBJECT *FileObject); -typedef FAST_IO_ACQUIRE_FILE *PFAST_IO_ACQUIRE_FILE; typedef VOID -(NTAPI FAST_IO_RELEASE_FILE)( +(DDKAPI *PFAST_IO_RELEASE_FILE)( IN struct _FILE_OBJECT *FileObject); -typedef FAST_IO_RELEASE_FILE *PFAST_IO_RELEASE_FILE; typedef VOID -(NTAPI FAST_IO_DETACH_DEVICE)( +(DDKAPI *PFAST_IO_DETACH_DEVICE)( IN struct _DEVICE_OBJECT *SourceDevice, IN struct _DEVICE_OBJECT *TargetDevice); -typedef FAST_IO_DETACH_DEVICE *PFAST_IO_DETACH_DEVICE; typedef BOOLEAN -(NTAPI FAST_IO_QUERY_NETWORK_OPEN_INFO)( +(DDKAPI *PFAST_IO_QUERY_NETWORK_OPEN_INFO)( IN struct _FILE_OBJECT *FileObject, IN BOOLEAN Wait, OUT struct _FILE_NETWORK_OPEN_INFORMATION *Buffer, OUT struct _IO_STATUS_BLOCK *IoStatus, IN struct _DEVICE_OBJECT *DeviceObject); -typedef FAST_IO_QUERY_NETWORK_OPEN_INFO *PFAST_IO_QUERY_NETWORK_OPEN_INFO; typedef NTSTATUS -(NTAPI FAST_IO_ACQUIRE_FOR_MOD_WRITE)( +(DDKAPI *PFAST_IO_ACQUIRE_FOR_MOD_WRITE)( IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER EndingOffset, OUT struct _ERESOURCE **ResourceToRelease, IN struct _DEVICE_OBJECT *DeviceObject); -typedef FAST_IO_ACQUIRE_FOR_MOD_WRITE *PFAST_IO_ACQUIRE_FOR_MOD_WRITE; typedef BOOLEAN -(NTAPI FAST_IO_MDL_READ)( +(DDKAPI *PFAST_IO_MDL_READ)( IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, @@ -4310,17 +4026,15 @@ typedef BOOLEAN OUT PMDL *MdlChain, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject); -typedef FAST_IO_MDL_READ *PFAST_IO_MDL_READ; typedef BOOLEAN -(NTAPI FAST_IO_MDL_READ_COMPLETE)( +(DDKAPI *PFAST_IO_MDL_READ_COMPLETE)( IN struct _FILE_OBJECT *FileObject, IN PMDL MdlChain, IN struct _DEVICE_OBJECT *DeviceObject); -typedef FAST_IO_MDL_READ_COMPLETE *PFAST_IO_MDL_READ_COMPLETE; typedef BOOLEAN -(NTAPI FAST_IO_PREPARE_MDL_WRITE)( +(DDKAPI *PFAST_IO_PREPARE_MDL_WRITE)( IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, @@ -4328,18 +4042,16 @@ typedef BOOLEAN OUT PMDL *MdlChain, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject); -typedef FAST_IO_PREPARE_MDL_WRITE *PFAST_IO_PREPARE_MDL_WRITE; typedef BOOLEAN -(NTAPI FAST_IO_MDL_WRITE_COMPLETE)( +(DDKAPI *PFAST_IO_MDL_WRITE_COMPLETE)( IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER FileOffset, IN PMDL MdlChain, IN struct _DEVICE_OBJECT *DeviceObject); -typedef FAST_IO_MDL_WRITE_COMPLETE *PFAST_IO_MDL_WRITE_COMPLETE; typedef BOOLEAN -(NTAPI FAST_IO_READ_COMPRESSED)( +(DDKAPI *PFAST_IO_READ_COMPRESSED)( IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, @@ -4350,10 +4062,9 @@ typedef BOOLEAN OUT struct _COMPRESSED_DATA_INFO *CompressedDataInfo, IN ULONG CompressedDataInfoLength, IN struct _DEVICE_OBJECT *DeviceObject); -typedef FAST_IO_READ_COMPRESSED *PFAST_IO_READ_COMPRESSED; typedef BOOLEAN -(NTAPI FAST_IO_WRITE_COMPRESSED)( +(DDKAPI *PFAST_IO_WRITE_COMPRESSED)( IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, @@ -4364,48 +4075,41 @@ typedef BOOLEAN IN struct _COMPRESSED_DATA_INFO *CompressedDataInfo, IN ULONG CompressedDataInfoLength, IN struct _DEVICE_OBJECT *DeviceObject); -typedef FAST_IO_WRITE_COMPRESSED *PFAST_IO_WRITE_COMPRESSED; typedef BOOLEAN -(NTAPI FAST_IO_MDL_READ_COMPLETE_COMPRESSED)( +(DDKAPI *PFAST_IO_MDL_READ_COMPLETE_COMPRESSED)( IN struct _FILE_OBJECT *FileObject, IN PMDL MdlChain, IN struct _DEVICE_OBJECT *DeviceObject); -typedef FAST_IO_MDL_READ_COMPLETE_COMPRESSED *PFAST_IO_MDL_READ_COMPLETE_COMPRESSED; typedef BOOLEAN -(NTAPI FAST_IO_MDL_WRITE_COMPLETE_COMPRESSED)( +(DDKAPI *PFAST_IO_MDL_WRITE_COMPLETE_COMPRESSED)( IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER FileOffset, IN PMDL MdlChain, IN struct _DEVICE_OBJECT *DeviceObject); -typedef FAST_IO_MDL_WRITE_COMPLETE_COMPRESSED *PFAST_IO_MDL_WRITE_COMPLETE_COMPRESSED; typedef BOOLEAN -(NTAPI FAST_IO_QUERY_OPEN)( +(DDKAPI *PFAST_IO_QUERY_OPEN)( IN struct _IRP *Irp, OUT PFILE_NETWORK_OPEN_INFORMATION NetworkInformation, IN struct _DEVICE_OBJECT *DeviceObject); -typedef FAST_IO_QUERY_OPEN *PFAST_IO_QUERY_OPEN; typedef NTSTATUS -(NTAPI FAST_IO_RELEASE_FOR_MOD_WRITE)( +(DDKAPI *PFAST_IO_RELEASE_FOR_MOD_WRITE)( IN struct _FILE_OBJECT *FileObject, IN struct _ERESOURCE *ResourceToRelease, IN struct _DEVICE_OBJECT *DeviceObject); -typedef FAST_IO_RELEASE_FOR_MOD_WRITE *PFAST_IO_RELEASE_FOR_MOD_WRITE; typedef NTSTATUS -(NTAPI FAST_IO_ACQUIRE_FOR_CCFLUSH)( +(DDKAPI *PFAST_IO_ACQUIRE_FOR_CCFLUSH)( IN struct _FILE_OBJECT *FileObject, IN struct _DEVICE_OBJECT *DeviceObject); -typedef FAST_IO_ACQUIRE_FOR_CCFLUSH *PFAST_IO_ACQUIRE_FOR_CCFLUSH; typedef NTSTATUS -(NTAPI FAST_IO_RELEASE_FOR_CCFLUSH)( +(DDKAPI *PFAST_IO_RELEASE_FOR_CCFLUSH) ( IN struct _FILE_OBJECT *FileObject, IN struct _DEVICE_OBJECT *DeviceObject); -typedef FAST_IO_RELEASE_FOR_CCFLUSH *PFAST_IO_RELEASE_FOR_CCFLUSH; typedef struct _FAST_IO_DISPATCH { ULONG SizeOfFastIoDispatch; @@ -4479,7 +4183,6 @@ typedef struct _IO_COMPLETION_CONTEXT { #define FO_SKIP_COMPLETION_PORT 0x02000000 #define FO_SKIP_SET_EVENT 0x04000000 #define FO_SKIP_SET_FAST_IO 0x08000000 -#define FO_FLAGS_VALID_ONLY_DURING_CREATE FO_DISALLOW_EXCLUSIVE /* VPB.Flags */ #define VPB_MOUNTED 0x0001 @@ -4494,18 +4197,12 @@ typedef struct _IO_COMPLETION_CONTEXT { #define SL_FORCE_ACCESS_CHECK 0x01 #define SL_OPEN_PAGING_FILE 0x02 #define SL_OPEN_TARGET_DIRECTORY 0x04 -#define SL_STOP_ON_SYMLINK 0x08 #define SL_CASE_SENSITIVE 0x80 #define SL_KEY_SPECIFIED 0x01 #define SL_OVERRIDE_VERIFY_VOLUME 0x02 #define SL_WRITE_THROUGH 0x04 #define SL_FT_SEQUENTIAL_WRITE 0x08 -#define SL_FORCE_DIRECT_WRITE 0x10 -#define SL_REALTIME_STREAM 0x20 - -#define SL_READ_ACCESS_GRANTED 0x01 -#define SL_WRITE_ACCESS_GRANTED 0x04 #define SL_FAIL_IMMEDIATELY 0x01 #define SL_EXCLUSIVE_LOCK 0x02 @@ -4523,8 +4220,6 @@ typedef struct _IO_COMPLETION_CONTEXT { #define DEVICE_TYPE_FROM_CTL_CODE(ctl) (((ULONG) (ctl & 0xffff0000)) >> 16) -#define METHOD_FROM_CTL_CODE(ctrlCode) ((ULONG)(ctrlCode & 3)) - #define IRP_NOCACHE 0x00000001 #define IRP_PAGING_IO 0x00000002 #define IRP_MOUNT_COMPLETION 0x00000002 @@ -4610,9 +4305,6 @@ typedef struct _IO_COMPLETION_CONTEXT { #define IRP_MN_QUERY_BUS_INFORMATION 0x15 #define IRP_MN_DEVICE_USAGE_NOTIFICATION 0x16 #define IRP_MN_SURPRISE_REMOVAL 0x17 -#if (NTDDI_VERSION >= NTDDI_WIN7) -#define IRP_MN_DEVICE_ENUMERATED 0x19 -#endif #define IRP_MN_WAIT_WAKE 0x00 #define IRP_MN_POWER_SEQUENCE 0x01 @@ -4632,7 +4324,8 @@ typedef struct _IO_COMPLETION_CONTEXT { #define IRP_MN_REGINFO_EX 0x0b -typedef struct _FILE_OBJECT { +typedef struct _FILE_OBJECT +{ CSHORT Type; CSHORT Size; PDEVICE_OBJECT DeviceObject; @@ -4759,7 +4452,8 @@ typedef struct _DEVICE_RELATIONS { PDEVICE_OBJECT Objects[1]; } DEVICE_RELATIONS, *PDEVICE_RELATIONS; -typedef struct _DEVOBJ_EXTENSION { +typedef struct _DEVOBJ_EXTENSION +{ CSHORT Type; USHORT Size; PDEVICE_OBJECT DeviceObject; @@ -4797,7 +4491,7 @@ typedef struct _SCATTER_GATHER_LIST SCATTER_GATHER_LIST, *PSCATTER_GATHER_LIST; #endif typedef NTSTATUS -(NTAPI DRIVER_ADD_DEVICE)( +(DDKAPI DRIVER_ADD_DEVICE)( IN struct _DRIVER_OBJECT *DriverObject, IN struct _DEVICE_OBJECT *PhysicalDeviceObject); typedef DRIVER_ADD_DEVICE *PDRIVER_ADD_DEVICE; @@ -4814,24 +4508,24 @@ typedef struct _DRIVER_EXTENSION { #define DRVO_BUILTIN_DRIVER 0x00000004 typedef NTSTATUS -(NTAPI DRIVER_INITIALIZE)( +(DDKAPI DRIVER_INITIALIZE)( IN struct _DRIVER_OBJECT *DriverObject, IN PUNICODE_STRING RegistryPath); typedef DRIVER_INITIALIZE *PDRIVER_INITIALIZE; typedef VOID -(NTAPI DRIVER_STARTIO)( +(DDKAPI DRIVER_STARTIO)( IN struct _DEVICE_OBJECT *DeviceObject, IN struct _IRP *Irp); typedef DRIVER_STARTIO *PDRIVER_STARTIO; typedef VOID -(NTAPI DRIVER_UNLOAD)( +(DDKAPI DRIVER_UNLOAD)( IN struct _DRIVER_OBJECT *DriverObject); typedef DRIVER_UNLOAD *PDRIVER_UNLOAD; typedef NTSTATUS -(NTAPI DRIVER_DISPATCH)( +(DDKAPI DRIVER_DISPATCH)( IN struct _DEVICE_OBJECT *DeviceObject, IN struct _IRP *Irp); typedef DRIVER_DISPATCH *PDRIVER_DISPATCH; @@ -4852,7 +4546,8 @@ typedef struct _DRIVER_OBJECT { PDRIVER_STARTIO DriverStartIo; PDRIVER_UNLOAD DriverUnload; PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION + 1]; -} DRIVER_OBJECT, *PDRIVER_OBJECT; +} DRIVER_OBJECT; +typedef struct _DRIVER_OBJECT *PDRIVER_OBJECT; typedef struct _DMA_ADAPTER { USHORT Version; @@ -4861,18 +4556,18 @@ typedef struct _DMA_ADAPTER { } DMA_ADAPTER, *PDMA_ADAPTER; typedef VOID -(NTAPI *PPUT_DMA_ADAPTER)( +(DDKAPI *PPUT_DMA_ADAPTER)( IN PDMA_ADAPTER DmaAdapter); typedef PVOID -(NTAPI *PALLOCATE_COMMON_BUFFER)( +(DDKAPI *PALLOCATE_COMMON_BUFFER)( IN PDMA_ADAPTER DmaAdapter, IN ULONG Length, OUT PPHYSICAL_ADDRESS LogicalAddress, IN BOOLEAN CacheEnabled); typedef VOID -(NTAPI *PFREE_COMMON_BUFFER)( +(DDKAPI *PFREE_COMMON_BUFFER)( IN PDMA_ADAPTER DmaAdapter, IN ULONG Length, IN PHYSICAL_ADDRESS LogicalAddress, @@ -4880,7 +4575,7 @@ typedef VOID IN BOOLEAN CacheEnabled); typedef NTSTATUS -(NTAPI *PALLOCATE_ADAPTER_CHANNEL)( +(DDKAPI *PALLOCATE_ADAPTER_CHANNEL)( IN PDMA_ADAPTER DmaAdapter, IN PDEVICE_OBJECT DeviceObject, IN ULONG NumberOfMapRegisters, @@ -4888,7 +4583,7 @@ typedef NTSTATUS IN PVOID Context); typedef BOOLEAN -(NTAPI *PFLUSH_ADAPTER_BUFFERS)( +(DDKAPI *PFLUSH_ADAPTER_BUFFERS)( IN PDMA_ADAPTER DmaAdapter, IN PMDL Mdl, IN PVOID MapRegisterBase, @@ -4897,17 +4592,17 @@ typedef BOOLEAN IN BOOLEAN WriteToDevice); typedef VOID -(NTAPI *PFREE_ADAPTER_CHANNEL)( +(DDKAPI *PFREE_ADAPTER_CHANNEL)( IN PDMA_ADAPTER DmaAdapter); typedef VOID -(NTAPI *PFREE_MAP_REGISTERS)( +(DDKAPI *PFREE_MAP_REGISTERS)( IN PDMA_ADAPTER DmaAdapter, PVOID MapRegisterBase, ULONG NumberOfMapRegisters); typedef PHYSICAL_ADDRESS -(NTAPI *PMAP_TRANSFER)( +(DDKAPI *PMAP_TRANSFER)( IN PDMA_ADAPTER DmaAdapter, IN PMDL Mdl, IN PVOID MapRegisterBase, @@ -4916,23 +4611,22 @@ typedef PHYSICAL_ADDRESS IN BOOLEAN WriteToDevice); typedef ULONG -(NTAPI *PGET_DMA_ALIGNMENT)( +(DDKAPI *PGET_DMA_ALIGNMENT)( IN PDMA_ADAPTER DmaAdapter); typedef ULONG -(NTAPI *PREAD_DMA_COUNTER)( +(DDKAPI *PREAD_DMA_COUNTER)( IN PDMA_ADAPTER DmaAdapter); typedef VOID -(NTAPI DRIVER_LIST_CONTROL)( +(DDKAPI *PDRIVER_LIST_CONTROL)( IN struct _DEVICE_OBJECT *DeviceObject, IN struct _IRP *Irp, IN struct _SCATTER_GATHER_LIST *ScatterGather, IN PVOID Context); -typedef DRIVER_LIST_CONTROL *PDRIVER_LIST_CONTROL; typedef NTSTATUS -(NTAPI *PGET_SCATTER_GATHER_LIST)( +(DDKAPI *PGET_SCATTER_GATHER_LIST)( IN PDMA_ADAPTER DmaAdapter, IN PDEVICE_OBJECT DeviceObject, IN PMDL Mdl, @@ -4943,13 +4637,13 @@ typedef NTSTATUS IN BOOLEAN WriteToDevice); typedef VOID -(NTAPI *PPUT_SCATTER_GATHER_LIST)( +(DDKAPI *PPUT_SCATTER_GATHER_LIST)( IN PDMA_ADAPTER DmaAdapter, IN PSCATTER_GATHER_LIST ScatterGather, IN BOOLEAN WriteToDevice); typedef NTSTATUS -(NTAPI *PCALCULATE_SCATTER_GATHER_LIST_SIZE)( +(DDKAPI *PCALCULATE_SCATTER_GATHER_LIST_SIZE)( IN PDMA_ADAPTER DmaAdapter, IN PMDL Mdl OPTIONAL, IN PVOID CurrentVa, @@ -4958,7 +4652,7 @@ typedef NTSTATUS OUT PULONG pNumberOfMapRegisters OPTIONAL); typedef NTSTATUS -(NTAPI *PBUILD_SCATTER_GATHER_LIST)( +(DDKAPI *PBUILD_SCATTER_GATHER_LIST)( IN PDMA_ADAPTER DmaAdapter, IN PDEVICE_OBJECT DeviceObject, IN PMDL Mdl, @@ -4971,7 +4665,7 @@ typedef NTSTATUS IN ULONG ScatterGatherLength); typedef NTSTATUS -(NTAPI *PBUILD_MDL_FROM_SCATTER_GATHER_LIST)( +(DDKAPI *PBUILD_MDL_FROM_SCATTER_GATHER_LIST)( IN PDMA_ADAPTER DmaAdapter, IN PSCATTER_GATHER_LIST ScatterGather, IN PMDL OriginalMdl, @@ -5065,7 +4759,7 @@ typedef struct _IO_RESOURCE_REQUIREMENTS_LIST { } IO_RESOURCE_REQUIREMENTS_LIST, *PIO_RESOURCE_REQUIREMENTS_LIST; typedef VOID -(NTAPI DRIVER_CANCEL)( +(DDKAPI DRIVER_CANCEL)( IN struct _DEVICE_OBJECT *DeviceObject, IN struct _IRP *Irp); typedef DRIVER_CANCEL *PDRIVER_CANCEL; @@ -5126,7 +4820,8 @@ typedef struct _IRP { KAPC Apc; PVOID CompletionKey; } Tail; -} IRP, *PIRP; +} IRP; +typedef struct _IRP *PIRP; typedef enum _IO_PAGING_PRIORITY { IoPagingPriorityInvalid, @@ -5137,39 +4832,37 @@ typedef enum _IO_PAGING_PRIORITY { } IO_PAGING_PRIORITY; typedef NTSTATUS -(NTAPI IO_COMPLETION_ROUTINE)( +(DDKAPI IO_COMPLETION_ROUTINE)( IN struct _DEVICE_OBJECT *DeviceObject, IN struct _IRP *Irp, IN PVOID Context); typedef IO_COMPLETION_ROUTINE *PIO_COMPLETION_ROUTINE; typedef VOID -(NTAPI IO_DPC_ROUTINE)( +(DDKAPI *PIO_DPC_ROUTINE)( IN struct _KDPC *Dpc, IN struct _DEVICE_OBJECT *DeviceObject, IN struct _IRP *Irp, IN PVOID Context); -typedef IO_DPC_ROUTINE *PIO_DPC_ROUTINE; typedef NTSTATUS -(NTAPI *PMM_DLL_INITIALIZE)( +(DDKAPI *PMM_DLL_INITIALIZE)( IN PUNICODE_STRING RegistryPath); typedef NTSTATUS -(NTAPI *PMM_DLL_UNLOAD)( +(DDKAPI *PMM_DLL_UNLOAD)( VOID); typedef BOOLEAN -(NTAPI KSERVICE_ROUTINE)( +(DDKAPI KSERVICE_ROUTINE)( IN struct _KINTERRUPT *Interrupt, IN PVOID ServiceContext); typedef KSERVICE_ROUTINE *PKSERVICE_ROUTINE; typedef VOID -(NTAPI IO_TIMER_ROUTINE)( +(DDKAPI *PIO_TIMER_ROUTINE)( IN struct _DEVICE_OBJECT *DeviceObject, IN PVOID Context); -typedef IO_TIMER_ROUTINE *PIO_TIMER_ROUTINE; typedef struct _IO_SECURITY_CONTEXT { PSECURITY_QUALITY_OF_SERVICE SecurityQos; @@ -5187,33 +4880,33 @@ typedef struct _IO_CSQ_IRP_CONTEXT { } IO_CSQ_IRP_CONTEXT, *PIO_CSQ_IRP_CONTEXT; typedef VOID -(NTAPI *PIO_CSQ_INSERT_IRP)( +(DDKAPI *PIO_CSQ_INSERT_IRP)( IN struct _IO_CSQ *Csq, IN PIRP Irp); typedef VOID -(NTAPI *PIO_CSQ_REMOVE_IRP)( +(DDKAPI *PIO_CSQ_REMOVE_IRP)( IN struct _IO_CSQ *Csq, IN PIRP Irp); typedef PIRP -(NTAPI *PIO_CSQ_PEEK_NEXT_IRP)( +(DDKAPI *PIO_CSQ_PEEK_NEXT_IRP)( IN struct _IO_CSQ *Csq, IN PIRP Irp, IN PVOID PeekContext); typedef VOID -(NTAPI *PIO_CSQ_ACQUIRE_LOCK)( +(DDKAPI *PIO_CSQ_ACQUIRE_LOCK)( IN struct _IO_CSQ *Csq, OUT PKIRQL Irql); typedef VOID -(NTAPI *PIO_CSQ_RELEASE_LOCK)( +(DDKAPI *PIO_CSQ_RELEASE_LOCK)( IN struct _IO_CSQ *Csq, IN KIRQL Irql); typedef VOID -(NTAPI *PIO_CSQ_COMPLETE_CANCELED_IRP)( +(DDKAPI *PIO_CSQ_COMPLETE_CANCELED_IRP)( IN struct _IO_CSQ *Csq, IN PIRP Irp); @@ -5456,8 +5149,6 @@ typedef struct _IO_STACK_LOCATION { #define METHOD_OUT_DIRECT 2 #define METHOD_NEITHER 3 -#define METHOD_DIRECT_TO_HARDWARE METHOD_IN_DIRECT -#define METHOD_DIRECT_FROM_HARDWARE METHOD_OUT_DIRECT #define FILE_SUPERSEDED 0x00000000 #define FILE_OPENED 0x00000001 @@ -5504,7 +5195,6 @@ typedef struct _IO_STACK_LOCATION { #define FILE_ATTRIBUTE_OFFLINE 0x00001000 #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000 #define FILE_ATTRIBUTE_ENCRYPTED 0x00004000 -#define FILE_ATTRIBUTE_VIRTUAL 0x00010000 #define FILE_ATTRIBUTE_VALID_FLAGS 0x00007fb7 #define FILE_ATTRIBUTE_VALID_SET_FLAGS 0x000031a7 @@ -5538,10 +5228,6 @@ typedef struct _IO_STACK_LOCATION { #define FILE_OPEN_BY_FILE_ID 0x00002000 #define FILE_OPEN_FOR_BACKUP_INTENT 0x00004000 #define FILE_NO_COMPRESSION 0x00008000 -#if (NTDDI_VERSION >= NTDDI_WIN7) -#define FILE_OPEN_REQUIRING_OPLOCK 0x00010000 -#define FILE_DISALLOW_EXCLUSIVE 0x00020000 -#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ #define FILE_RESERVE_OPFILTER 0x00100000 #define FILE_OPEN_REPARSE_POINT 0x00200000 #define FILE_OPEN_NO_RECALL 0x00400000 @@ -5589,7 +5275,6 @@ typedef struct _OBJECT_NAME_INFORMATION { } OBJECT_NAME_INFORMATION, *POBJECT_NAME_INFORMATION; /* Exported object types */ -extern POBJECT_TYPE NTSYSAPI CmKeyObjectType; extern POBJECT_TYPE NTSYSAPI ExEventObjectType; extern POBJECT_TYPE NTSYSAPI ExSemaphoreObjectType; extern POBJECT_TYPE NTSYSAPI IoFileObjectType; @@ -5668,7 +5353,7 @@ typedef struct _QUOTA_LIMITS { #define IPI_LEVEL 29 #define POWER_LEVEL 30 #define HIGH_LEVEL 31 -#define CLOCK_LEVEL CLOCK2_LEVEL +#define CLOCK_LEVEL (CLOCK2_LEVEL) #define KIP0PCRADDRESS 0xffdff000 #define KI_USER_SHARED_DATA 0xffdf0000 @@ -5704,7 +5389,8 @@ extern NTKERNELAPI volatile KSYSTEM_TIME KeTickCount; FORCEINLINE VOID -KeMemoryBarrier(VOID) +KeMemoryBarrier( + VOID) { volatile LONG Barrier; #if defined(__GNUC__) @@ -5714,11 +5400,6 @@ KeMemoryBarrier(VOID) #endif } -NTHALAPI -KIRQL -NTAPI -KeGetCurrentIrql(VOID); - NTHALAPI VOID FASTCALL @@ -5735,26 +5416,28 @@ KfRaiseIrql( NTHALAPI KIRQL -NTAPI -KeRaiseIrqlToDpcLevel(VOID); +DDKAPI +KeRaiseIrqlToDpcLevel( + VOID); NTHALAPI KIRQL -NTAPI -KeRaiseIrqlToSynchLevel(VOID); +DDKAPI +KeRaiseIrqlToSynchLevel( + VOID); NTHALAPI KIRQL FASTCALL KfAcquireSpinLock( - IN OUT PKSPIN_LOCK SpinLock); + IN PKSPIN_LOCK SpinLock); #define KeAcquireSpinLock(a,b) *(b) = KfAcquireSpinLock(a) NTHALAPI VOID FASTCALL KfReleaseSpinLock( - IN OUT PKSPIN_LOCK SpinLock, + IN PKSPIN_LOCK SpinLock, IN KIRQL NewIrql); #define KeReleaseSpinLock(a,b) KfReleaseSpinLock(a,b) @@ -5762,20 +5445,21 @@ NTKERNELAPI VOID FASTCALL KefAcquireSpinLockAtDpcLevel( - IN OUT PKSPIN_LOCK SpinLock); + IN PKSPIN_LOCK SpinLock); #define KeAcquireSpinLockAtDpcLevel(SpinLock) KefAcquireSpinLockAtDpcLevel(SpinLock) NTKERNELAPI VOID FASTCALL KefReleaseSpinLockFromDpcLevel( - IN OUT PKSPIN_LOCK SpinLock); + IN PKSPIN_LOCK SpinLock); #define KeReleaseSpinLockFromDpcLevel(SpinLock) KefReleaseSpinLockFromDpcLevel(SpinLock) NTSYSAPI PKTHREAD NTAPI -KeGetCurrentThread(VOID); +KeGetCurrentThread( + VOID); NTKERNELAPI NTSTATUS @@ -5805,7 +5489,8 @@ VOID _KeQueryTickCount( OUT PLARGE_INTEGER CurrentCount) { - for (;;) { + for (;;) + { CurrentCount->HighPart = KeTickCount.High1Time; CurrentCount->LowPart = KeTickCount.LowPart; if (CurrentCount->HighPart == KeTickCount.High2Time) break; @@ -5818,6 +5503,9 @@ _KeQueryTickCount( +/****************************************************************************** + * Runtime Library Functions * + ******************************************************************************/ FORCEINLINE VOID @@ -6037,10 +5725,8 @@ RtlStringFromGUID( #define RtlZeroBytes RtlZeroMemory + #if (NTDDI_VERSION >= NTDDI_WIN2K) - - - NTSYSAPI BOOLEAN NTAPI @@ -6143,7 +5829,7 @@ VOID NTAPI RtlCopyUnicodeString( IN OUT PUNICODE_STRING DestinationString, - IN PCUNICODE_STRING SourceString OPTIONAL); + IN PCUNICODE_STRING SourceString); NTSYSAPI NTSTATUS @@ -6189,7 +5875,7 @@ NTAPI RtlExtendedLargeIntegerDivide( IN LARGE_INTEGER Dividend, IN ULONG Divisor, - OUT PULONG Remainder OPTIONAL); + IN OUT PULONG Remainder); #endif #if defined(_X86_) || defined(_IA64_) @@ -6377,17 +6063,12 @@ NTAPI RtlQueryRegistryValues( IN ULONG RelativeTo, IN PCWSTR Path, - IN OUT PRTL_QUERY_REGISTRY_TABLE QueryTable, - IN PVOID Context OPTIONAL, + IN PRTL_QUERY_REGISTRY_TABLE QueryTable, + IN PVOID Context, IN PVOID Environment OPTIONAL); -#define SHORT_SIZE (sizeof(USHORT)) -#define SHORT_MASK (SHORT_SIZE - 1) #define LONG_SIZE (sizeof(LONG)) -#define LONGLONG_SIZE (sizeof(LONGLONG)) #define LONG_MASK (LONG_SIZE - 1) -#define LONGLONG_MASK (LONGLONG_SIZE - 1) -#define LOWBYTE_MASK 0x00FF /* VOID * RtlRetrieveUlong( @@ -6456,50 +6137,15 @@ RtlSetDaclSecurityDescriptor( IN PACL Dacl OPTIONAL, IN BOOLEAN DaclDefaulted OPTIONAL); -#if defined(_AMD64_) - /* VOID * RtlStoreUlong( * IN PULONG Address, * IN ULONG Value); */ +#if defined(_AMD64_) #define RtlStoreUlong(Address,Value) \ *(ULONG UNALIGNED *)(Address) = (Value) - -/* VOID - * RtlStoreUlonglong( - * IN OUT PULONGLONG Address, - * ULONGLONG Value); - */ -#define RtlStoreUlonglong(Address,Value) \ - *(ULONGLONG UNALIGNED *)(Address) = (Value) - -/* VOID - * RtlStoreUshort( - * IN PUSHORT Address, - * IN USHORT Value); - */ -#define RtlStoreUshort(Address,Value) \ - *(USHORT UNALIGNED *)(Address) = (Value) - -/* VOID - * RtlRetrieveUshort( - * PUSHORT DestinationAddress, - * PUSHORT SourceAddress); - */ -#define RtlRetrieveUshort(DestAddress,SrcAddress) \ - *(USHORT UNALIGNED *)(DestAddress) = *(USHORT)(SrcAddress) - -/* VOID - * RtlRetrieveUlong( - * PULONG DestinationAddress, - * PULONG SourceAddress); - */ -#define RtlRetrieveUlong(DestAddress,SrcAddress) \ - *(ULONG UNALIGNED *)(DestAddress) = *(PULONG)(SrcAddress) - #else - #define RtlStoreUlong(Address,Value) \ if ((ULONG_PTR)(Address) & LONG_MASK) { \ ((PUCHAR) (Address))[LONG_LEAST_SIGNIFICANT_BIT] = (UCHAR)(FIRSTBYTE(Value)); \ @@ -6655,9 +6301,7 @@ RtlWriteRegistryValue( IN PVOID ValueData, IN ULONG ValueLength); - -#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ - +#endif // (NTDDI_VERSION >= NTDDI_WIN2K) #if (NTDDI_VERSION >= NTDDI_WIN2KSP3) NTSYSAPI @@ -6668,11 +6312,7 @@ RtlPrefetchMemoryNonTemporal( IN SIZE_T Length); #endif - #if (NTDDI_VERSION >= NTDDI_WINXP) - - - NTSYSAPI VOID NTAPI @@ -6700,22 +6340,9 @@ RtlTestBit( IN PRTL_BITMAP BitMapHeader, IN ULONG BitNumber); -NTSYSAPI -NTSTATUS -NTAPI -RtlHashUnicodeString( - IN CONST UNICODE_STRING *String, - IN BOOLEAN CaseInSensitive, - IN ULONG HashAlgorithm, - OUT PULONG HashValue); - - -#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ +#endif // (NTDDI_VERSION >= NTDDI_WINXP) #if (NTDDI_VERSION >= NTDDI_VISTA) - - - NTSYSAPI ULONG NTAPI @@ -6756,51 +6383,7 @@ RtlFindClosestEncodableLength( IN ULONGLONG SourceLength, OUT PULONGLONG TargetLength); -NTSYSAPI -NTSTATUS -NTAPI -RtlCmEncodeMemIoResource( - IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor, - IN UCHAR Type, - IN ULONGLONG Length, - IN ULONGLONG Start); - - -#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ - -#if (NTDDI_VERSION >= NTDDI_WIN7) - - - -NTSYSAPI -NTSTATUS -NTAPI -RtlUnicodeToUTF8N( - OUT PCHAR UTF8StringDestination, - IN ULONG UTF8StringMaxByteCount, - OUT PULONG UTF8StringActualByteCount, - IN PCWCH UnicodeStringSource, - IN ULONG UnicodeStringByteCount); - -NTSYSAPI -NTSTATUS -NTAPI -RtlUTF8ToUnicodeN( - OUT PWSTR UnicodeStringDestination, - IN ULONG UnicodeStringMaxByteCount, - OUT PULONG UnicodeStringActualByteCount, - IN PCCH UTF8StringSource, - IN ULONG UTF8StringByteCount); - -NTSYSAPI -ULONG64 -NTAPI -RtlGetEnabledExtendedFeatures( - IN ULONG64 FeatureMask); - - -#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ - +#endif #if !defined(MIDL_PASS) /* inline funftions */ @@ -6808,8 +6391,7 @@ RtlGetEnabledExtendedFeatures( static __inline LARGE_INTEGER NTAPI_INLINE -RtlConvertLongToLargeInteger( - IN LONG SignedInteger) +RtlConvertLongToLargeInteger(LONG SignedInteger) { LARGE_INTEGER ret; ret.QuadPart = SignedInteger; @@ -6821,7 +6403,7 @@ static __inline LARGE_INTEGER NTAPI_INLINE RtlConvertUlongToLargeInteger( - IN ULONG UnsignedInteger) + ULONG UnsignedInteger) { LARGE_INTEGER ret; ret.QuadPart = UnsignedInteger; @@ -6870,8 +6452,7 @@ RtlEnlargedIntegerMultiply( FORCEINLINE VOID -RtlInitEmptyAnsiString( - OUT PANSI_STRING AnsiString, +RtlInitEmptyAnsiString(OUT PANSI_STRING AnsiString, IN PCHAR Buffer, IN USHORT BufferSize) { @@ -6893,14 +6474,12 @@ RtlInitEmptyUnicodeString( } #if defined(_AMD64_) || defined(_IA64_) - - static __inline LARGE_INTEGER NTAPI_INLINE RtlExtendedIntegerMultiply( - IN LARGE_INTEGER Multiplicand, - IN LONG Multiplier) + LARGE_INTEGER Multiplicand, + LONG Multiplier) { LARGE_INTEGER ret; ret.QuadPart = Multiplicand.QuadPart * Multiplier; @@ -6911,9 +6490,9 @@ static __inline LARGE_INTEGER NTAPI_INLINE RtlExtendedLargeIntegerDivide( - IN LARGE_INTEGER Dividend, - IN ULONG Divisor, - OUT PULONG Remainder OPTIONAL) + LARGE_INTEGER Dividend, + ULONG Divisor, + PULONG Remainder) { LARGE_INTEGER ret; ret.QuadPart = (ULONG64)Dividend.QuadPart / Divisor; @@ -6921,11 +6500,7 @@ RtlExtendedLargeIntegerDivide( *Remainder = (ULONG)(Dividend.QuadPart % Divisor); return ret; } - - - -#endif /* defined(_AMD64_) || defined(_IA64_) */ - +#endif #if defined(_AMD64_) @@ -7007,7 +6582,8 @@ RtlSecureZeroMemory( __stosb((PUCHAR)vptr, 0, Size); #else char * endptr = (char *)vptr + Size; - while (vptr < endptr) { + while (vptr < endptr) + { *vptr = 0; vptr++; } #endif @@ -7016,16 +6592,16 @@ RtlSecureZeroMemory( #if defined(_M_AMD64) FORCEINLINE -BOOLEAN +ULONG RtlCheckBit( IN PRTL_BITMAP BitMapHeader, IN ULONG BitPosition) { - return BitTest64((LONG64 CONST*)BitMapHeader->Buffer, (LONG64)BitPosition); + return BitTest((LONG CONST*)BitMapHeader->Buffer, BitPosition); } #else #define RtlCheckBit(BMH,BP) (((((PLONG)(BMH)->Buffer)[(BP)/32]) >> ((BP)%32)) & 0x1) -#endif /* defined(_M_AMD64) */ +#endif // defined(_M_AMD64) #define RtlLargeIntegerGreaterThan(X,Y) ( \ (((X).HighPart == (Y).HighPart) && ((X).LowPart > (Y).LowPart)) || \ @@ -7149,15 +6725,8 @@ RtlCheckBit( #define NT_ASSERTMSG(exp) ((VOID)0) #define NT_ASSERTMSGW(exp) ((VOID)0) -#define NT_VERIFY(_exp) ((_exp) ? TRUE : FALSE) -#define NT_VERIFYMSG(_msg, _exp ) ((_exp) ? TRUE : FALSE) -#define NT_VERIFYMSGW(_msg, _exp) ((_exp) ? TRUE : FALSE) - #endif /* DBG */ -#define InitializeListHead32(ListHead) (\ - (ListHead)->Flink = (ListHead)->Blink = PtrToUlong((ListHead))) - #if !defined(_WINBASE_) #if defined(_WIN64) && (defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_) || defined(_NTOSP_)) @@ -7179,14 +6748,18 @@ InitializeSListHead( #endif #if defined(_WIN64) - if (((ULONG_PTR)SListHead & 0xf) != 0) { + if (((ULONG_PTR)SListHead & 0xf) != 0) + { RtlRaiseStatus(STATUS_DATATYPE_MISALIGNMENT); } #endif + RtlZeroMemory(SListHead, sizeof(SLIST_HEADER)); + #if defined(_IA64_) FeatureBits = __getReg(CV_IA64_CPUID4); - if ((FeatureBits & KF_16BYTE_INSTR) != 0) { + if ((FeatureBits & KF_16BYTE_INSTR) != 0) + { SListHead->Header16.HeaderType = 1; SListHead->Header16.Init = 1; } @@ -7260,8 +6833,6 @@ KeClearEvent( #if (NTDDI_VERSION >= NTDDI_WIN2K) - -#if defined(_NTDDK_) || defined(_NTIFS_) NTKERNELAPI VOID NTAPI @@ -7269,7 +6840,6 @@ ProbeForRead( IN CONST VOID *Address, /* CONST is added */ IN SIZE_T Length, IN ULONG Alignment); -#endif /* defined(_NTDDK_) || defined(_NTIFS_) */ NTKERNELAPI VOID @@ -7279,9 +6849,7 @@ ProbeForWrite( IN SIZE_T Length, IN ULONG Alignment); - #if defined(SINGLE_GROUP_LEGACY_API) - NTKERNELAPI VOID NTAPI @@ -7303,16 +6871,16 @@ KeSetTargetProcessorDpc( NTKERNELAPI KAFFINITY NTAPI -KeQueryActiveProcessors(VOID); - - -#endif /* defined(SINGLE_GROUP_LEGACY_API) */ +KeQueryActiveProcessors( + VOID); +#endif #if !defined(_M_AMD64) NTKERNELAPI ULONGLONG NTAPI -KeQueryInterruptTime(VOID); +KeQueryInterruptTime( + VOID); NTKERNELAPI VOID @@ -7321,36 +6889,6 @@ KeQuerySystemTime( OUT PLARGE_INTEGER CurrentTime); #endif /* !_M_AMD64 */ -#if !defined(_X86_) -NTKERNELAPI -KIRQL -NTAPI -KeAcquireSpinLockRaiseToDpc( - IN OUT PKSPIN_LOCK SpinLock); - -#define KeAcquireSpinLock(SpinLock, OldIrql) \ - *(OldIrql) = KeAcquireSpinLockRaiseToDpc(SpinLock) - -NTKERNELAPI -VOID -NTAPI -KeAcquireSpinLockAtDpcLevel( - IN OUT PKSPIN_LOCK SpinLock); - -NTKERNELAPI -VOID -NTAPI -KeReleaseSpinLock( - IN OUT PKSPIN_LOCK SpinLock, - IN KIRQL NewIrql); - -NTKERNELAPI -VOID -NTAPI -KeReleaseSpinLockFromDpcLevel( - IN OUT PKSPIN_LOCK SpinLock); -#endif /* !_X86_ */ - #if defined(_X86_) && (defined(_WDM_INCLUDED_) || defined(WIN9X_COMPAT_SPINLOCK)) NTKERNELAPI VOID @@ -7488,7 +7026,8 @@ KeQueryPriorityThread( NTKERNELAPI ULONG NTAPI -KeQueryTimeIncrement(VOID); +KeQueryTimeIncrement( + VOID); NTKERNELAPI LONG @@ -7502,6 +7041,7 @@ NTAPI KeReadStateMutex( IN PRKMUTEX Mutex); + NTKERNELAPI LONG NTAPI @@ -7739,10 +7279,13 @@ KeRegisterBugCheckReasonCallback( #endif /* (NTDDI_VERSION >= NTDDI_WINXPSP1) */ #if (NTDDI_VERSION >= NTDDI_WINXPSP2) + NTKERNELAPI VOID NTAPI -KeFlushQueuedDpcs(VOID); +KeFlushQueuedDpcs( + VOID); + #endif /* (NTDDI_VERSION >= NTDDI_WINXPSP2) */ #if (NTDDI_VERSION >= NTDDI_WS03) @@ -7794,12 +7337,10 @@ FASTCALL KeTestSpinLock( IN PKSPIN_LOCK SpinLock); - #endif /* (NTDDI_VERSION >= NTDDI_WS03) */ #if (NTDDI_VERSION >= NTDDI_WS03SP1) - NTKERNELAPI BOOLEAN FASTCALL @@ -7809,53 +7350,64 @@ KeTryToAcquireSpinLockAtDpcLevel( NTKERNELAPI BOOLEAN NTAPI -KeAreAllApcsDisabled(VOID); +KeAreAllApcsDisabled( + VOID); NTKERNELAPI VOID FASTCALL KeAcquireGuardedMutex( - IN OUT PKGUARDED_MUTEX GuardedMutex); + IN OUT PKGUARDED_MUTEX GuardedMutex +); NTKERNELAPI VOID FASTCALL KeAcquireGuardedMutexUnsafe( - IN OUT PKGUARDED_MUTEX GuardedMutex); + IN OUT PKGUARDED_MUTEX GuardedMutex +); NTKERNELAPI VOID NTAPI -KeEnterGuardedRegion(VOID); +KeEnterGuardedRegion( + VOID +); NTKERNELAPI VOID NTAPI -KeLeaveGuardedRegion(VOID); +KeLeaveGuardedRegion( + VOID +); NTKERNELAPI VOID FASTCALL KeInitializeGuardedMutex( - OUT PKGUARDED_MUTEX GuardedMutex); + OUT PKGUARDED_MUTEX GuardedMutex +); NTKERNELAPI VOID FASTCALL KeReleaseGuardedMutexUnsafe( - IN OUT PKGUARDED_MUTEX GuardedMutex); + IN OUT PKGUARDED_MUTEX GuardedMutex +); NTKERNELAPI VOID FASTCALL KeReleaseGuardedMutex( - IN OUT PKGUARDED_MUTEX GuardedMutex); + IN OUT PKGUARDED_MUTEX GuardedMutex +); NTKERNELAPI BOOLEAN FASTCALL KeTryToAcquireGuardedMutex( - IN OUT PKGUARDED_MUTEX GuardedMutex); + IN OUT PKGUARDED_MUTEX GuardedMutex +); #endif /* (NTDDI_VERSION >= NTDDI_WS03SP1) */ @@ -7881,19 +7433,12 @@ KeQueryDpcWatchdogInformation( OUT PKDPC_WATCHDOG_INFORMATION WatchdogInformation); #if defined(SINGLE_GROUP_LEGACY_API) - NTKERNELAPI KAFFINITY NTAPI KeSetSystemAffinityThreadEx( IN KAFFINITY Affinity); -NTKERNELAPI -VOID -NTAPI -KeRevertToUserAffinityThreadEx( - IN KAFFINITY Affinity); - NTKERNELAPI ULONG NTAPI @@ -7903,8 +7448,9 @@ KeQueryActiveProcessorCount( NTKERNELAPI ULONG NTAPI -KeQueryMaximumProcessorCount(VOID); -#endif /* SINGLE_GROUP_LEGACY_API */ +KeQueryMaximumProcessorCount( + VOID); +#endif #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ @@ -7924,7 +7470,6 @@ KeDeregisterProcessorChangeCallback( #if (NTDDI_VERSION >= NTDDI_WIN7) - ULONG64 NTAPI KeQueryTotalCycleTimeProcess( @@ -7970,7 +7515,8 @@ KeSetCoalescableTimer( NTKERNELAPI ULONGLONG NTAPI -KeQueryUnbiasedInterruptTime(VOID); +KeQueryUnbiasedInterruptTime( + VOID); NTKERNELAPI ULONG @@ -7987,17 +7533,19 @@ KeQueryMaximumProcessorCountEx( NTKERNELAPI USHORT NTAPI -KeQueryActiveGroupCount(VOID); +KeQueryActiveGroupCount( + VOID); NTKERNELAPI USHORT NTAPI -KeQueryMaximumGroupCount(VOID); +KeQueryMaximumGroupCount( + VOID); NTKERNELAPI KAFFINITY NTAPI -KeQueryGroupAffinity( +KeQueryGroupAffinity IN USHORT GroupNumber); NTKERNELAPI @@ -8023,12 +7571,14 @@ KeQueryNodeMaximumProcessorCount( NTKERNELAPI USHORT NTAPI -KeQueryHighestNodeNumber(VOID); +KeQueryHighestNodeNumber( + VOID); NTKERNELAPI USHORT NTAPI -KeGetCurrentNodeNumber(VOID); +KeGetCurrentNodeNumber( + VOID); NTKERNELAPI NTSTATUS @@ -8052,17 +7602,6 @@ NTAPI KeRestoreExtendedProcessorState( IN PXSTATE_SAVE XStateSave); -NTSTATUS -NTAPI -KeGetProcessorNumberFromIndex( - IN ULONG ProcIndex, - OUT PPROCESSOR_NUMBER ProcNumber); - -ULONG -NTAPI -KeGetProcessorIndexFromNumber( - IN PPROCESSOR_NUMBER ProcNumber); - #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ #if !defined(_IA64_) @@ -8098,14 +7637,17 @@ KeFlushWriteBuffer(VOID); #define PAGED_CODE() -#endif /* DBG */ +#endif #define PAGED_CODE_LOCKED() NOP_FUNCTION; /****************************************************************************** * Memory manager Functions * ******************************************************************************/ -/* Alignment Macros */ + +/* + * Alignment Macros + */ #define ALIGN_DOWN_BY(size, align) \ ((ULONG_PTR)(size) & ~((ULONG_PTR)(align) - 1)) @@ -8167,9 +7709,6 @@ KeFlushWriteBuffer(VOID); ((ULONG) ((((ULONG_PTR) (_Va) & (PAGE_SIZE - 1)) \ + (_Size) + (PAGE_SIZE - 1)) >> PAGE_SHIFT)) -#define COMPUTE_PAGES_SPANNED(Va, Size) \ - ADDRESS_AND_SIZE_TO_SPAN_PAGES(Va,Size) - /* * ULONG * MmGetMdlByteCount( @@ -8186,8 +7725,6 @@ KeFlushWriteBuffer(VOID); #define MmGetMdlByteOffset(_Mdl) \ ((_Mdl)->ByteOffset) -#define MmGetMdlBaseVa(Mdl) ((Mdl)->StartVa) - /* * PPFN_NUMBER * MmGetMdlPfnArray( @@ -8386,7 +7923,8 @@ MmProbeAndLockPages( NTKERNELAPI MM_SYSTEMSIZE NTAPI -MmQuerySystemSize(VOID); +MmQuerySystemSize( + VOID); NTKERNELAPI VOID @@ -8436,9 +7974,7 @@ MmUnmapLockedPages( IN PVOID BaseAddress, IN PMDL MemoryDescriptorList); - - -#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ +#endif #if (NTDDI_VERSION >= NTDDI_WINXP) @@ -8508,15 +8044,6 @@ MmAllocatePagesForMdlEx( IN ULONG Flags); #endif -#if (NTDDI_VERSION >= NTDDI_VISTA) - -NTKERNELAPI -LOGICAL -NTAPI -MmIsDriverVerifyingByAddress( - IN PVOID AddressWithinSection); -#endif - /****************************************************************************** * Security Manager Functions * ******************************************************************************/ @@ -8649,6 +8176,7 @@ SeGetWorldRights( #endif /* SE_NTFS_WORLD_CACHE */ #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + /****************************************************************************** * Configuration Manager Functions * ******************************************************************************/ @@ -8669,53 +8197,6 @@ CmUnRegisterCallback( IN LARGE_INTEGER Cookie); #endif -#if (NTDDI_VERSION >= NTDDI_VISTA) - -NTKERNELAPI -NTSTATUS -NTAPI -CmRegisterCallbackEx( - PEX_CALLBACK_FUNCTION Function, - PCUNICODE_STRING Altitude, - PVOID Driver, - PVOID Context, - PLARGE_INTEGER Cookie, - PVOID Reserved); - -NTKERNELAPI -VOID -NTAPI -CmGetCallbackVersion( - OUT PULONG Major OPTIONAL, - OUT PULONG Minor OPTIONAL); - -NTKERNELAPI -NTSTATUS -NTAPI -CmSetCallbackObjectContext( - IN OUT PVOID Object, - IN PLARGE_INTEGER Cookie, - IN PVOID NewContext, - OUT PVOID *OldContext OPTIONAL); - -NTKERNELAPI -NTSTATUS -NTAPI -CmCallbackGetKeyObjectID( - IN PLARGE_INTEGER Cookie, - IN PVOID Object, - OUT PULONG_PTR ObjectID OPTIONAL, - OUT PCUNICODE_STRING *ObjectName OPTIONAL); - -NTKERNELAPI -PVOID -NTAPI -CmGetBoundTransaction( - IN PLARGE_INTEGER Cookie, - IN PVOID Object); - -#endif // NTDDI_VERSION >= NTDDI_VISTA - /****************************************************************************** * I/O Manager Functions * @@ -9231,7 +8712,6 @@ IoMapTransfer( #endif #if (NTDDI_VERSION >= NTDDI_WIN2K) - NTKERNELAPI VOID NTAPI @@ -9570,7 +9050,8 @@ IoGetDeviceInterfaceAlias( NTKERNELAPI PEPROCESS NTAPI -IoGetCurrentProcess(VOID); +IoGetCurrentProcess( + VOID); NTKERNELAPI NTSTATUS @@ -9618,7 +9099,8 @@ IoGetDriverObjectExtension( NTKERNELAPI PVOID NTAPI -IoGetInitialStack(VOID); +IoGetInitialStack( + VOID); NTKERNELAPI PDEVICE_OBJECT @@ -9892,7 +9374,7 @@ NTKERNELAPI NTSTATUS NTAPI IoWMIWriteEvent( - IN OUT PVOID WnodeEventItem); + IN PVOID WnodeEventItem); NTKERNELAPI VOID @@ -9900,25 +9382,7 @@ NTAPI IoWriteErrorLogEntry( IN PVOID ElEntry); -NTKERNELAPI -PIRP -NTAPI -IoGetTopLevelIrp(VOID); - -NTKERNELAPI -NTSTATUS -NTAPI -IoRegisterLastChanceShutdownNotification( - IN PDEVICE_OBJECT DeviceObject); - -NTKERNELAPI -VOID -NTAPI -IoSetTopLevelIrp( - IN PIRP Irp OPTIONAL); - -#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ - +#endif #if (NTDDI_VERSION >= NTDDI_WINXP) @@ -9954,7 +9418,7 @@ PIRP NTAPI IoCsqRemoveNextIrp( IN PIO_CSQ Csq, - IN PVOID PeekContext OPTIONAL); + IN PVOID PeekContext); NTKERNELAPI BOOLEAN @@ -10082,214 +9546,6 @@ IoWMISetSingleItem( #endif -#if (NTDDI_VERSION >= NTDDI_WS03) - -NTKERNELAPI -NTSTATUS -NTAPI -IoCsqInsertIrpEx( - IN PIO_CSQ Csq, - IN PIRP Irp, - IN PIO_CSQ_IRP_CONTEXT Context OPTIONAL, - IN PVOID InsertContext OPTIONAL); -#endif /* (NTDDI_VERSION >= NTDDI_WS03) */ - - -#if (NTDDI_VERSION >= NTDDI_VISTA) - -NTKERNELAPI -NTSTATUS -NTAPI -IoGetBootDiskInformationLite( - OUT PBOOTDISK_INFORMATION_LITE *BootDiskInformation); - -NTKERNELAPI -NTSTATUS -NTAPI -IoCheckShareAccessEx( - IN ACCESS_MASK DesiredAccess, - IN ULONG DesiredShareAccess, - IN OUT PFILE_OBJECT FileObject, - IN OUT PSHARE_ACCESS ShareAccess, - IN BOOLEAN Update, - IN PBOOLEAN WritePermission); - -NTKERNELAPI -NTSTATUS -NTAPI -IoConnectInterruptEx( - IN OUT PIO_CONNECT_INTERRUPT_PARAMETERS Parameters); - -NTKERNELAPI -VOID -NTAPI -IoDisconnectInterruptEx( - IN PIO_DISCONNECT_INTERRUPT_PARAMETERS Parameters); - -LOGICAL -NTAPI -IoWithinStackLimits( - IN ULONG_PTR RegionStart, - IN SIZE_T RegionSize); - -NTKERNELAPI -VOID -NTAPI -IoSetShareAccessEx( - IN ACCESS_MASK DesiredAccess, - IN ULONG DesiredShareAccess, - IN OUT PFILE_OBJECT FileObject, - OUT PSHARE_ACCESS ShareAccess, - IN PBOOLEAN WritePermission); - -ULONG -NTAPI -IoSizeofWorkItem(VOID); - -VOID -NTAPI -IoInitializeWorkItem( - IN PVOID IoObject, - IN PIO_WORKITEM IoWorkItem); - -VOID -NTAPI -IoUninitializeWorkItem( - IN PIO_WORKITEM IoWorkItem); - -VOID -NTAPI -IoQueueWorkItemEx( - IN PIO_WORKITEM IoWorkItem, - IN PIO_WORKITEM_ROUTINE_EX WorkerRoutine, - IN WORK_QUEUE_TYPE QueueType, - IN PVOID Context OPTIONAL); - -IO_PRIORITY_HINT -NTAPI -IoGetIoPriorityHint( - IN PIRP Irp); - -NTSTATUS -NTAPI -IoSetIoPriorityHint( - IN PIRP Irp, - IN IO_PRIORITY_HINT PriorityHint); - -NTSTATUS -NTAPI -IoAllocateSfioStreamIdentifier( - IN PFILE_OBJECT FileObject, - IN ULONG Length, - IN PVOID Signature, - OUT PVOID *StreamIdentifier); - -PVOID -NTAPI -IoGetSfioStreamIdentifier( - IN PFILE_OBJECT FileObject, - IN PVOID Signature); - -NTSTATUS -NTAPI -IoFreeSfioStreamIdentifier( - IN PFILE_OBJECT FileObject, - IN PVOID Signature); - -NTKERNELAPI -NTSTATUS -NTAPI -IoRequestDeviceEjectEx( - IN PDEVICE_OBJECT PhysicalDeviceObject, - IN PIO_DEVICE_EJECT_CALLBACK Callback OPTIONAL, - IN PVOID Context OPTIONAL, - IN PDRIVER_OBJECT DriverObject OPTIONAL); - -NTKERNELAPI -NTSTATUS -NTAPI -IoSetDevicePropertyData( - IN PDEVICE_OBJECT Pdo, - IN CONST DEVPROPKEY *PropertyKey, - IN LCID Lcid, - IN ULONG Flags, - IN DEVPROPTYPE Type, - IN ULONG Size, - IN PVOID Data OPTIONAL); - -NTKERNELAPI -NTSTATUS -NTAPI -IoGetDevicePropertyData( - PDEVICE_OBJECT Pdo, - CONST DEVPROPKEY *PropertyKey, - LCID Lcid, - ULONG Flags, - ULONG Size, - PVOID Data, - PULONG RequiredSize, - PDEVPROPTYPE Type); - -#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ - -#define IoCallDriverStackSafeDefault(a, b) IoCallDriver(a, b) - -#if (NTDDI_VERSION >= NTDDI_WS08) -NTKERNELAPI -NTSTATUS -NTAPI -IoReplacePartitionUnit( - IN PDEVICE_OBJECT TargetPdo, - IN PDEVICE_OBJECT SparePdo, - IN ULONG Flags); -#endif - -#if (NTDDI_VERSION >= NTDDI_WIN7) - -NTKERNELAPI -NTSTATUS -NTAPI -IoGetAffinityInterrupt( - IN PKINTERRUPT InterruptObject, - OUT PGROUP_AFFINITY GroupAffinity); - -NTSTATUS -NTAPI -IoGetContainerInformation( - IN IO_CONTAINER_INFORMATION_CLASS InformationClass, - IN PVOID ContainerObject OPTIONAL, - IN OUT PVOID Buffer OPTIONAL, - IN ULONG BufferLength); - -NTSTATUS -NTAPI -IoRegisterContainerNotification( - IN IO_CONTAINER_NOTIFICATION_CLASS NotificationClass, - IN PIO_CONTAINER_NOTIFICATION_FUNCTION CallbackFunction, - IN PVOID NotificationInformation OPTIONAL, - IN ULONG NotificationInformationLength, - OUT PVOID CallbackRegistration); - -VOID -NTAPI -IoUnregisterContainerNotification( - IN PVOID CallbackRegistration); - -NTKERNELAPI -NTSTATUS -NTAPI -IoUnregisterPlugPlayNotificationEx( - IN PVOID NotificationEntry); - -NTKERNELAPI -NTSTATUS -NTAPI -IoGetDeviceNumaNode( - IN PDEVICE_OBJECT Pdo, - OUT PUSHORT NodeNumber); - -#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ - #if defined(_WIN64) NTKERNELAPI ULONG @@ -10409,10 +9665,12 @@ IoSetCompletionRoutine( IoReleaseRemoveLockAndWaitEx(_RemoveLock, _Tag, sizeof(IO_REMOVE_LOCK)) #if defined(_WIN64) + NTKERNELAPI BOOLEAN IoIs32bitProcess( IN PIRP Irp OPTIONAL); + #endif #define PLUGPLAY_REGKEY_DEVICE 1 @@ -10486,7 +9744,7 @@ IoInitializeDpcRequest( FORCEINLINE VOID IoCopyCurrentIrpStackLocationToNext( - IN OUT PIRP Irp) + IN PIRP Irp) { PIO_STACK_LOCATION irpSp; PIO_STACK_LOCATION nextIrpSp; @@ -10505,7 +9763,8 @@ IoGetStackLimits( FORCEINLINE ULONG_PTR -IoGetRemainingStackSize(VOID) +IoGetRemainingStackSize( + VOID) { ULONG_PTR End, Begin; ULONG_PTR Result; @@ -10515,19 +9774,6 @@ IoGetRemainingStackSize(VOID) return Result; } -#if (NTDDI_VERSION >= NTDDI_WS03) -VOID -FORCEINLINE -IoInitializeThreadedDpcRequest( - IN PDEVICE_OBJECT DeviceObject, - IN PIO_DPC_ROUTINE DpcRoutine) -{ - KeInitializeThreadedDpc(&DeviceObject->Dpc, - (PKDEFERRED_ROUTINE) DpcRoutine, - DeviceObject ); -} -#endif - /****************************************************************************** * Power Management Support Functions * ******************************************************************************/ @@ -10637,15 +9883,16 @@ PoUnregisterPowerSettingCallback( #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ #if (NTDDI_VERSION >= NTDDI_VISTASP1) + NTKERNELAPI VOID NTAPI PoSetDeviceBusyEx( IN OUT PULONG IdlePointer); + #endif /* (NTDDI_VERSION >= NTDDI_VISTASP1) */ #if (NTDDI_VERSION >= NTDDI_WIN7) - NTKERNELAPI VOID NTAPI @@ -10722,7 +9969,7 @@ PoCreatePowerRequest( #define ExInterlockedRemoveHeadList ExfInterlockedRemoveHeadList #define ExInterlockedPopEntryList ExfInterlockedPopEntryList #define ExInterlockedPushEntryList ExfInterlockedPushEntryList -#endif /* defined(_X86_) */ +#endif #if defined(_WIN64) @@ -10763,7 +10010,7 @@ ExpInterlockedPushEntrySList( #define ExInterlockedPushEntrySList(Head, Entry, Lock) \ ExpInterlockedPushEntrySList(Head, Entry) -#else /* !defined(_WIN64) */ +#else // !defined(_WIN64) #define ExQueryDepthSList(listhead) (listhead)->Depth @@ -10771,10 +10018,9 @@ NTKERNELAPI PSINGLE_LIST_ENTRY FASTCALL ExInterlockedFlushSList( - IN OUT PSLIST_HEADER ListHead); + IN PSLIST_HEADER ListHead); #if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_) - NTKERNELAPI PSINGLE_LIST_ENTRY FASTCALL @@ -10867,28 +10113,28 @@ NTKERNELAPI BOOLEAN NTAPI ExAcquireResourceExclusiveLite( - IN OUT PERESOURCE Resource, + IN PERESOURCE Resource, IN BOOLEAN Wait); NTKERNELAPI BOOLEAN NTAPI ExAcquireResourceSharedLite( - IN OUT PERESOURCE Resource, + IN PERESOURCE Resource, IN BOOLEAN Wait); NTKERNELAPI BOOLEAN NTAPI ExAcquireSharedStarveExclusive( - IN OUT PERESOURCE Resource, + IN PERESOURCE Resource, IN BOOLEAN Wait); NTKERNELAPI BOOLEAN NTAPI ExAcquireSharedWaitForExclusive( - IN OUT PERESOURCE Resource, + IN PERESOURCE Resource, IN BOOLEAN Wait); NTKERNELAPI @@ -10923,7 +10169,7 @@ ExAllocatePoolWithQuotaTag( #ifndef POOL_TAGGING #define ExAllocatePoolWithQuotaTag(a,b,c) ExAllocatePoolWithQuota(a,b) -#endif +#endif /* POOL_TAGGING */ NTKERNELAPI PVOID @@ -10946,7 +10192,7 @@ NTKERNELAPI VOID NTAPI ExConvertExclusiveToSharedLite( - IN OUT PERESOURCE Resource); + IN PERESOURCE Resource); NTKERNELAPI NTSTATUS @@ -10961,7 +10207,7 @@ NTKERNELAPI VOID NTAPI ExDeleteNPagedLookasideList( - IN OUT PNPAGED_LOOKASIDE_LIST Lookaside); + IN PNPAGED_LOOKASIDE_LIST Lookaside); NTKERNELAPI VOID @@ -10973,7 +10219,7 @@ NTKERNELAPI NTSTATUS NTAPI ExDeleteResourceLite( - IN OUT PERESOURCE Resource); + IN PERESOURCE Resource); NTKERNELAPI VOID @@ -11001,7 +10247,8 @@ ExGetExclusiveWaiterCount( NTKERNELAPI KPROCESSOR_MODE NTAPI -ExGetPreviousMode(VOID); +ExGetPreviousMode( + VOID); NTKERNELAPI ULONG @@ -11037,7 +10284,7 @@ NTKERNELAPI NTSTATUS NTAPI ExInitializeResourceLite( - OUT PERESOURCE Resource); + IN PERESOURCE Resource); NTKERNELAPI LARGE_INTEGER @@ -11061,15 +10308,12 @@ FASTCALL ExInterlockedAddUlong( IN PULONG Addend, IN ULONG Increment, - IN OUT PKSPIN_LOCK Lock); + PKSPIN_LOCK Lock); #if defined(_AMD64_) || defined(_IA64_) - #define ExInterlockedCompareExchange64(Destination, Exchange, Comperand, Lock) \ InterlockedCompareExchange64(Destination, *(Exchange), *(Comperand)) - #elif defined(_X86_) - NTKERNELAPI LONGLONG FASTCALL @@ -11077,12 +10321,9 @@ ExfInterlockedCompareExchange64( IN OUT LONGLONG volatile *Destination, IN PLONGLONG Exchange, IN PLONGLONG Comperand); - #define ExInterlockedCompareExchange64(Destination, Exchange, Comperand, Lock) \ ExfInterlockedCompareExchange64(Destination, Exchange, Comperand) - #else - NTKERNELAPI LONGLONG FASTCALL @@ -11091,46 +10332,45 @@ ExInterlockedCompareExchange64( IN PLONGLONG Exchange, IN PLONGLONG Comparand, IN PKSPIN_LOCK Lock); - -#endif /* defined(_AMD64_) || defined(_IA64_) */ +#endif NTKERNELAPI PLIST_ENTRY FASTCALL ExInterlockedInsertHeadList( - IN OUT PLIST_ENTRY ListHead, - IN OUT PLIST_ENTRY ListEntry, - IN OUT PKSPIN_LOCK Lock); + IN PLIST_ENTRY ListHead, + IN PLIST_ENTRY ListEntry, + IN PKSPIN_LOCK Lock); NTKERNELAPI PLIST_ENTRY FASTCALL ExInterlockedInsertTailList( - IN OUT PLIST_ENTRY ListHead, - IN OUT PLIST_ENTRY ListEntry, - IN OUT PKSPIN_LOCK Lock); + IN PLIST_ENTRY ListHead, + IN PLIST_ENTRY ListEntry, + IN PKSPIN_LOCK Lock); NTKERNELAPI PSINGLE_LIST_ENTRY FASTCALL ExInterlockedPopEntryList( - IN OUT PSINGLE_LIST_ENTRY ListHead, - IN OUT PKSPIN_LOCK Lock); + IN PSINGLE_LIST_ENTRY ListHead, + IN PKSPIN_LOCK Lock); NTKERNELAPI PSINGLE_LIST_ENTRY FASTCALL ExInterlockedPushEntryList( - IN OUT PSINGLE_LIST_ENTRY ListHead, - IN OUT PSINGLE_LIST_ENTRY ListEntry, - IN OUT PKSPIN_LOCK Lock); + IN PSINGLE_LIST_ENTRY ListHead, + IN PSINGLE_LIST_ENTRY ListEntry, + IN PKSPIN_LOCK Lock); NTKERNELAPI PLIST_ENTRY FASTCALL ExInterlockedRemoveHeadList( - IN OUT PLIST_ENTRY ListHead, - IN OUT PKSPIN_LOCK Lock); + IN PLIST_ENTRY ListHead, + IN PKSPIN_LOCK Lock); NTKERNELAPI BOOLEAN @@ -11164,14 +10404,14 @@ VOID NTAPI ExNotifyCallback( IN PCALLBACK_OBJECT CallbackObject, - IN PVOID Argument1 OPTIONAL, - IN PVOID Argument2 OPTIONAL); + IN PVOID Argument1, + IN PVOID Argument2); NTKERNELAPI VOID NTAPI ExQueueWorkItem( - IN OUT PWORK_QUEUE_ITEM WorkItem, + IN PWORK_QUEUE_ITEM WorkItem, IN WORK_QUEUE_TYPE QueueType); NTKERNELAPI @@ -11187,32 +10427,32 @@ NTAPI ExRegisterCallback( IN PCALLBACK_OBJECT CallbackObject, IN PCALLBACK_FUNCTION CallbackFunction, - IN PVOID CallbackContext OPTIONAL); + IN PVOID CallbackContext); NTKERNELAPI NTSTATUS NTAPI ExReinitializeResourceLite( - IN OUT PERESOURCE Resource); + IN PERESOURCE Resource); NTKERNELAPI VOID NTAPI ExReleaseResourceForThreadLite( - IN OUT PERESOURCE Resource, + IN PERESOURCE Resource, IN ERESOURCE_THREAD ResourceThreadId); NTKERNELAPI VOID FASTCALL ExReleaseResourceLite( - IN OUT PERESOURCE Resource); + IN PERESOURCE Resource); NTKERNELAPI VOID NTAPI ExSetResourceOwnerPointer( - IN OUT PERESOURCE Resource, + IN PERESOURCE Resource, IN PVOID OwnerPointer); NTKERNELAPI @@ -11233,12 +10473,12 @@ NTKERNELAPI VOID NTAPI ExUnregisterCallback( - IN OUT PVOID CbRegistration); + IN PVOID CbRegistration); -#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ + +#endif // (NTDDI_VERSION >= NTDDI_WIN2K) #if (NTDDI_VERSION >= NTDDI_WINXP) - NTKERNELAPI BOOLEAN FASTCALL @@ -11255,7 +10495,7 @@ NTKERNELAPI VOID FASTCALL ExReInitializeRundownProtection( - IN OUT PEX_RUNDOWN_REF RunRef); + OUT PEX_RUNDOWN_REF RunRef); NTKERNELAPI VOID @@ -11281,10 +10521,9 @@ FASTCALL ExWaitForRundownProtectionRelease( IN OUT PEX_RUNDOWN_REF RunRef); -#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ +#endif // (NTDDI_VERSION >= NTDDI_WINXP) #if (NTDDI_VERSION >= NTDDI_WINXPSP2) - NTKERNELAPI BOOLEAN FASTCALL @@ -11298,11 +10537,9 @@ FASTCALL ExReleaseRundownProtectionEx( IN OUT PEX_RUNDOWN_REF RunRef, IN ULONG Count); - -#endif /* (NTDDI_VERSION >= NTDDI_WINXPSP2) */ +#endif // (NTDDI_VERSION >= NTDDI_WINXPSP2) #if (NTDDI_VERSION >= NTDDI_WS03SP1) - NTKERNELAPI PEX_RUNDOWN_REF_CACHE_AWARE NTAPI @@ -11314,92 +10551,9 @@ NTKERNELAPI SIZE_T NTAPI ExSizeOfRundownProtectionCacheAware(VOID); - -NTKERNELAPI -PVOID -NTAPI -ExEnterCriticalRegionAndAcquireResourceShared( - IN OUT PERESOURCE Resource); - -NTKERNELAPI -PVOID -NTAPI -ExEnterCriticalRegionAndAcquireResourceExclusive( - IN OUT PERESOURCE Resource); - -NTKERNELAPI -PVOID -NTAPI -ExEnterCriticalRegionAndAcquireSharedWaitForExclusive( - IN OUT PERESOURCE Resource); - -NTKERNELAPI -VOID -FASTCALL -ExReleaseResourceAndLeaveCriticalRegion( - IN OUT PERESOURCE Resource); - -NTKERNELAPI -VOID -NTAPI -ExInitializeRundownProtectionCacheAware( - OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware, - IN SIZE_T RunRefSize); - -NTKERNELAPI -VOID -NTAPI -ExFreeCacheAwareRundownProtection( - IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware); - -NTKERNELAPI -BOOLEAN -FASTCALL -ExAcquireRundownProtectionCacheAware( - IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware); - -NTKERNELAPI -VOID -FASTCALL -ExReleaseRundownProtectionCacheAware( - IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware); - -NTKERNELAPI -BOOLEAN -FASTCALL -ExAcquireRundownProtectionCacheAwareEx( - IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware, - IN ULONG Count); - -NTKERNELAPI -VOID -FASTCALL -ExReleaseRundownProtectionCacheAwareEx( - IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRef, - IN ULONG Count); - -NTKERNELAPI -VOID -FASTCALL -ExWaitForRundownProtectionReleaseCacheAware( - IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRef); - -NTKERNELAPI -VOID -FASTCALL -ExReInitializeRundownProtectionCacheAware( - IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware); - -NTKERNELAPI -VOID -FASTCALL -ExRundownCompletedCacheAware( - IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware); - -#endif /* (NTDDI_VERSION >= NTDDI_WS03SP1) */ +#endif // (NTDDI_VERSION >= NTDDI_WS03SP1) #if (NTDDI_VERSION >= NTDDI_VISTA) - NTKERNELAPI NTSTATUS NTAPI @@ -11422,7 +10576,7 @@ ExAllocateFromNPagedLookasideList( { PVOID Entry; - Lookaside->L.TotalAllocates += 1; + Lookaside->L.TotalAllocates++; Entry = InterlockedPopEntrySList(&Lookaside->L.ListHead); if (Entry == NULL) { Lookaside->L.AllocateMisses++; @@ -11452,7 +10606,7 @@ ExAllocateFromPagedLookasideList( static __inline VOID ExFreeToNPagedLookasideList( - IN OUT PNPAGED_LOOKASIDE_LIST Lookaside, + IN PNPAGED_LOOKASIDE_LIST Lookaside, IN PVOID Entry) { Lookaside->L.TotalFrees++; @@ -11537,99 +10691,10 @@ ObReleaseObjectSecurity( #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ -#if (NTDDI_VERSION >= NTDDI_VISTA) -NTKERNELAPI -VOID -NTAPI -ObDereferenceObjectDeferDelete( - IN PVOID Object); -#endif - -#if (NTDDI_VERSION >= NTDDI_VISTASP1) -NTKERNELAPI -NTSTATUS -NTAPI -ObRegisterCallbacks( - IN POB_CALLBACK_REGISTRATION CallbackRegistration, - OUT PVOID *RegistrationHandle); - -NTKERNELAPI -VOID -NTAPI -ObUnRegisterCallbacks( - IN PVOID RegistrationHandle); - -NTKERNELAPI -USHORT -NTAPI -ObGetFilterVersion(VOID); - -#endif /* (NTDDI_VERSION >= NTDDI_VISTASP1) */ - -#if (NTDDI_VERSION >= NTDDI_WIN7) - -NTKERNELAPI -NTSTATUS -NTAPI -ObReferenceObjectByHandleWithTag( - IN HANDLE Handle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_TYPE ObjectType OPTIONAL, - IN KPROCESSOR_MODE AccessMode, - IN ULONG Tag, - OUT PVOID *Object, - OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL); - -NTKERNELAPI -LONG_PTR -FASTCALL -ObfReferenceObjectWithTag( - IN PVOID Object, - IN ULONG Tag); - -NTKERNELAPI -NTSTATUS -NTAPI -ObReferenceObjectByPointerWithTag( - IN PVOID Object, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_TYPE ObjectType OPTIONAL, - IN KPROCESSOR_MODE AccessMode, - IN ULONG Tag); - -NTKERNELAPI -LONG_PTR -FASTCALL -ObfDereferenceObjectWithTag( - IN PVOID Object, - IN ULONG Tag); - -NTKERNELAPI -VOID -NTAPI -ObDereferenceObjectDeferDeleteWithTag( - IN PVOID Object, - IN ULONG Tag); - -#define ObDereferenceObject ObfDereferenceObject -#define ObReferenceObject ObfReferenceObject -#define ObDereferenceObjectWithTag ObfDereferenceObjectWithTag -#define ObReferenceObjectWithTag ObfReferenceObjectWithTag - -#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ - - /****************************************************************************** * Process Manager Functions * ******************************************************************************/ -NTKERNELAPI -NTSTATUS -NTAPI -PsWrapApcWow64Thread( - IN OUT PVOID *ApcContext, - IN OUT PVOID *ApcRoutine); - /* * PEPROCESS * PsGetCurrentProcess(VOID) @@ -11637,16 +10702,19 @@ PsWrapApcWow64Thread( #define PsGetCurrentProcess IoGetCurrentProcess #if !defined(_PSGETCURRENTTHREAD_) + #define _PSGETCURRENTTHREAD_ + FORCEINLINE PETHREAD NTAPI -PsGetCurrentThread(VOID) +PsGetCurrentThread ( + VOID) { return (PETHREAD)KeGetCurrentThread(); } -#endif /* !_PSGETCURRENTTHREAD_ */ +#endif #if (NTDDI_VERSION >= NTDDI_WIN2K) @@ -11668,18 +10736,18 @@ NTAPI PsTerminateSystemThread( IN NTSTATUS ExitStatus); - -#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ +#endif /****************************************************************************** * WMI Library Support Functions * ******************************************************************************/ #ifdef RUN_WPP + #if (NTDDI_VERSION >= NTDDI_WINXP) NTKERNELAPI NTSTATUS -__cdecl +DDKCDECLAPI WmiTraceMessage( IN TRACEHANDLE LoggerHandle, IN ULONG MessageFlags, @@ -11687,7 +10755,8 @@ WmiTraceMessage( IN USHORT MessageNumber, IN ...); #endif -#endif /* RUN_WPP */ + +#endif #if (NTDDI_VERSION >= NTDDI_WINXP) @@ -11705,7 +10774,7 @@ WmiQueryTraceInformation( /* FIXME: Get va_list from where? */ NTKERNELAPI NTSTATUS -__cdecl +DDKCDECLAPI WmiTraceMessageVa( IN TRACEHANDLE LoggerHandle, IN ULONG MessageFlags, @@ -11721,9 +10790,8 @@ WmiTraceMessageVa( ******************************************************************************/ #ifndef _DBGNT_ - ULONG -__cdecl +DDKCDECLAPI DbgPrint( IN PCSTR Format, IN ...); @@ -11733,7 +10801,6 @@ DbgPrint( #define KdPrint(_x_) DbgPrint _x_ #define KdPrintEx(_x_) DbgPrintEx _x_ -#define vKdPrintEx(_x_) vDbgPrintEx _x_ #define vKdPrintExWithPrefix(_x_) vDbgPrintExWithPrefix _x_ #define KdBreakPoint() DbgBreakPoint() #define KdBreakPointWithStatus(s) DbgBreakPointWithStatus(s) @@ -11742,7 +10809,6 @@ DbgPrint( #define KdPrint(_x_) #define KdPrintEx(_x_) -#define vKdPrintEx(_x_) #define vKdPrintExWithPrefix(_x_) #define KdBreakPoint() #define KdBreakPointWithStatus(s) @@ -11802,19 +10868,22 @@ vDbgPrintExWithPrefix( NTKERNELAPI NTSTATUS NTAPI -KdDisableDebugger(VOID); +KdDisableDebugger( + VOID); NTKERNELAPI NTSTATUS NTAPI -KdEnableDebugger(VOID); +KdEnableDebugger( + VOID); #if (_MSC_FULL_VER >= 150030729) && !defined(IMPORT_NATIVE_DBG_BREAK) #define DbgBreakPoint __debugbreak #else VOID NTAPI -DbgBreakPoint(VOID); +DbgBreakPoint( + VOID); #endif NTSYSAPI @@ -11825,7 +10894,7 @@ DbgBreakPointWithStatus( NTSYSAPI ULONG -_cdecl +DDKCDECLAPI DbgPrintReturnControlC( IN PCCH Format, IN ...); @@ -11836,7 +10905,7 @@ DbgPrintReturnControlC( NTSYSAPI ULONG -_cdecl +DDKCDECLAPI DbgPrintEx( IN ULONG ComponentId, IN ULONG Level, @@ -11861,10 +10930,14 @@ DbgSetDebugFilterState( #endif #if (NTDDI_VERSION >= NTDDI_WS03) + NTKERNELAPI BOOLEAN NTAPI -KdRefreshDebuggerNotPresent(VOID); +KdRefreshDebuggerNotPresent( + VOID +); + #endif #if (NTDDI_VERSION >= NTDDI_WS03SP1) @@ -11881,7 +10954,6 @@ KdChangeOption( #endif #if defined(USE_DMA_MACROS) && !defined(_NTHAL_) && (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_) - FORCEINLINE PVOID NTAPI @@ -11984,19 +11056,14 @@ typedef enum _ENLISTMENT_INFORMATION_CLASS { * ZwXxx Functions * ******************************************************************************/ - /* Constants */ #define NtCurrentProcess() ( (HANDLE)(LONG_PTR) -1 ) #define ZwCurrentProcess() NtCurrentProcess() #define NtCurrentThread() ( (HANDLE)(LONG_PTR) -2 ) #define ZwCurrentThread() NtCurrentThread() - - #if (NTDDI_VERSION >= NTDDI_WIN2K) - - NTSYSAPI NTSTATUS NTAPI @@ -12262,11 +11329,10 @@ ZwQueryFullAttributesFile( IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PFILE_NETWORK_OPEN_INFORMATION FileInformation); +#endif -#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ +#if (NTDDI_VERSION >= NTDDI_WIN2003) - -#if (NTDDI_VERSION >= NTDDI_WS03) NTSYSCALLAPI NTSTATUS NTAPI @@ -12274,6 +11340,7 @@ ZwOpenEvent( OUT PHANDLE EventHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes); + #endif #if (NTDDI_VERSION >= NTDDI_VISTA) @@ -12600,13 +11667,10 @@ ZwSinglePhaseReject( IN PLARGE_INTEGER TmVirtualClock OPTIONAL); -#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ - +#endif #if (NTDDI_VERSION >= NTDDI_WIN7) - - NTSYSAPI NTSTATUS NTAPI From 09ab0eb733787543f632fa47e43655c963c51ac4 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Mon, 29 Mar 2010 08:51:12 +0000 Subject: [PATCH 085/134] [NTOSKRNL] . Revert 46550: Windows does not set this flag. ReactOS shouldn't either. Setting UserEvent is already enough in this case. svn path=/trunk/; revision=46563 --- reactos/ntoskrnl/io/iomgr/irp.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/reactos/ntoskrnl/io/iomgr/irp.c b/reactos/ntoskrnl/io/iomgr/irp.c index 30107c16949..0863f58907b 100644 --- a/reactos/ntoskrnl/io/iomgr/irp.c +++ b/reactos/ntoskrnl/io/iomgr/irp.c @@ -966,12 +966,9 @@ IoBuildSynchronousFsdRequest(IN ULONG MajorFunction, IoStatusBlock ); if (!Irp) return NULL; - /* Associate the caller's event object with this IRP */ + /* Set the Event which makes it Syncronous */ Irp->UserEvent = Event; - /* Set the synchronous flag */ - Irp->Flags |= IRP_SYNCHRONOUS_API; - /* Sync IRPs are queued to requestor thread's irp cancel/cleanup list */ IoQueueThreadIrp(Irp); return Irp; From b8778948ceddd94dba43ae960e66c6ed4dc2becb Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 29 Mar 2010 08:57:45 +0000 Subject: [PATCH 086/134] merge wdm.h second attempt. This time taking more care of vista definitions. svn path=/trunk/; revision=46564 --- reactos/include/ddk/wdm.h | 1450 ++++++++++++++++++++++++++++--------- 1 file changed, 1089 insertions(+), 361 deletions(-) diff --git a/reactos/include/ddk/wdm.h b/reactos/include/ddk/wdm.h index e4aed4f40cf..3308de9c286 100644 --- a/reactos/include/ddk/wdm.h +++ b/reactos/include/ddk/wdm.h @@ -41,7 +41,7 @@ #ifndef GUID_DEFINED #include -#endif /* GUID_DEFINED */ +#endif #ifndef _KTMTYPES_ typedef GUID UOW, *PUOW; @@ -95,6 +95,12 @@ extern "C" { #if defined(_MSC_VER) +/* Disable some warnings */ +#pragma warning(disable:4115) /* Named type definition in parentheses */ +#pragma warning(disable:4201) /* Nameless unions and structs */ +#pragma warning(disable:4214) /* Bit fields of other types than int */ +#pragma warning(disable:4820) /* Padding added, due to alignemnet requirement */ + /* Indicate if #pragma alloc_text() is supported */ #if defined(_M_IX86) || defined(_M_AMD64) || defined(_M_IA64) #define ALLOC_PRAGMA 1 @@ -130,8 +136,8 @@ typedef struct _HAL_PRIVATE_DISPATCH_TABLE *PHAL_PRIVATE_DISPATCH_TABLE; typedef struct _DEVICE_HANDLER_OBJECT *PDEVICE_HANDLER_OBJECT; typedef struct _ADAPTER_OBJECT *PADAPTER_OBJECT; typedef struct _CALLBACK_OBJECT *PCALLBACK_OBJECT; -typedef struct _ETHREAD *PETHREAD; typedef struct _EPROCESS *PEPROCESS; +typedef struct _ETHREAD *PETHREAD; typedef struct _IO_TIMER *PIO_TIMER; typedef struct _KINTERRUPT *PKINTERRUPT; typedef struct _KPROCESS *PKPROCESS; @@ -149,7 +155,8 @@ typedef struct _CONTEXT *PCONTEXT; #if defined(__GNUC__) static __inline__ BOOLEAN -InterlockedBitTestAndSet(IN LONG volatile *Base, +InterlockedBitTestAndSet( + IN LONG volatile *Base, IN LONG Bit) { #if defined(_M_IX86) @@ -167,7 +174,8 @@ InterlockedBitTestAndSet(IN LONG volatile *Base, } static __inline__ BOOLEAN -InterlockedBitTestAndReset(IN LONG volatile *Base, +InterlockedBitTestAndReset( + IN LONG volatile *Base, IN LONG Bit) { #if defined(_M_IX86) @@ -184,7 +192,7 @@ InterlockedBitTestAndReset(IN LONG volatile *Base, #endif } -#endif +#endif /* defined(__GNUC__) */ #define BitScanForward _BitScanForward #define BitScanReverse _BitScanReverse @@ -196,6 +204,10 @@ InterlockedBitTestAndReset(IN LONG volatile *Base, #define InterlockedBitTestAndReset _interlockedbittestandreset #ifdef _M_AMD64 +#define BitTest64 _bittest64 +#define BitTestAndComplement64 _bittestandcomplement64 +#define BitTestAndSet64 _bittestandset64 +#define BitTestAndReset64 _bittestandreset64 #define InterlockedBitTestAndSet64 _interlockedbittestandset64 #define InterlockedBitTestAndReset64 _interlockedbittestandreset64 #endif @@ -239,7 +251,7 @@ InterlockedExchangeAdd( IN OUT LONG volatile *Addend, IN LONG Value); -#else // !defined(NO_INTERLOCKED_INTRINSICS) +#else /* !defined(NO_INTERLOCKED_INTRINSICS) */ #define InterlockedExchange _InterlockedExchange #define InterlockedIncrement _InterlockedIncrement @@ -250,9 +262,9 @@ InterlockedExchangeAdd( #define InterlockedAnd _InterlockedAnd #define InterlockedXor _InterlockedXor -#endif // !defined(NO_INTERLOCKED_INTRINSICS) +#endif /* !defined(NO_INTERLOCKED_INTRINSICS) */ -#endif // defined (_X86_) +#endif /* defined (_X86_) */ #if !defined (_WIN64) /* @@ -364,7 +376,7 @@ typedef struct _RTL_BITMAP_RUN { } RTL_BITMAP_RUN, *PRTL_BITMAP_RUN; typedef NTSTATUS -(DDKAPI *PRTL_QUERY_REGISTRY_ROUTINE)( +(NTAPI *PRTL_QUERY_REGISTRY_ROUTINE)( IN PWSTR ValueName, IN ULONG ValueType, IN PVOID ValueData, @@ -398,10 +410,15 @@ typedef struct _TIME_FIELDS { #define _SLIST_HEADER_ #if defined(_WIN64) -typedef struct DECLSPEC_ALIGN(16) _SLIST_ENTRY *PSLIST_ENTRY; + typedef struct DECLSPEC_ALIGN(16) _SLIST_ENTRY { - PSLIST_ENTRY Next; -} SLIST_ENTRY; + struct _SLIST_ENTRY *Next; +} SLIST_ENTRY, *PSLIST_ENTRY; + +typedef struct _SLIST_ENTRY32 { + ULONG Next; +} SLIST_ENTRY32, *PSLIST_ENTRY32; + typedef union DECLSPEC_ALIGN(16) _SLIST_HEADER { struct { ULONGLONG Alignment; @@ -424,11 +441,32 @@ typedef union DECLSPEC_ALIGN(16) _SLIST_HEADER { ULONGLONG Reserved:2; ULONGLONG NextEntry:60; } Header16; + struct { + ULONGLONG Depth:16; + ULONGLONG Sequence:48; + ULONGLONG HeaderType:1; + ULONGLONG Reserved:3; + ULONGLONG NextEntry:60; + } HeaderX64; } SLIST_HEADER, *PSLIST_HEADER; + +typedef union _SLIST_HEADER32 { + ULONGLONG Alignment; + struct { + SLIST_ENTRY32 Next; + USHORT Depth; + USHORT Sequence; + } DUMMYSTRUCTNAME; +} SLIST_HEADER32, *PSLIST_HEADER32; + #else + #define SLIST_ENTRY SINGLE_LIST_ENTRY #define _SLIST_ENTRY _SINGLE_LIST_ENTRY #define PSLIST_ENTRY PSINGLE_LIST_ENTRY + +typedef SLIST_ENTRY SLIST_ENTRY32, *PSLIST_ENTRY32; + typedef union _SLIST_HEADER { ULONGLONG Alignment; struct { @@ -437,7 +475,10 @@ typedef union _SLIST_HEADER { USHORT Sequence; } DUMMYSTRUCTNAME; } SLIST_HEADER, *PSLIST_HEADER; -#endif + +typedef SLIST_HEADER SLIST_HEADER32, *PSLIST_HEADER32; + +#endif /* defined(_WIN64) */ #endif /* _SLIST_HEADER_ */ @@ -497,8 +538,7 @@ typedef enum _MODE { #define MAXIMUM_SUPPORTED_EXTENSION 512 #define MAXIMUM_WAIT_OBJECTS 64 -#define ASSERT_APC(Object) \ - ASSERT((Object)->Type == ApcObject) +#define ASSERT_APC(Object) NT_ASSERT((Object)->Type == ApcObject) #define ASSERT_DPC(Object) \ ASSERT(((Object)->Type == 0) || \ @@ -506,24 +546,24 @@ typedef enum _MODE { ((Object)->Type == ThreadedDpcObject)) #define ASSERT_GATE(object) \ - ASSERT((((object)->Header.Type & KOBJECT_TYPE_MASK) == GateObject) || \ + NT_ASSERT((((object)->Header.Type & KOBJECT_TYPE_MASK) == GateObject) || \ (((object)->Header.Type & KOBJECT_TYPE_MASK) == EventSynchronizationObject)) #define ASSERT_DEVICE_QUEUE(Object) \ - ASSERT((Object)->Type == DeviceQueueObject) + NT_ASSERT((Object)->Type == DeviceQueueObject) #define ASSERT_TIMER(E) \ - ASSERT(((E)->Header.Type == TimerNotificationObject) || \ + NT_ASSERT(((E)->Header.Type == TimerNotificationObject) || \ ((E)->Header.Type == TimerSynchronizationObject)) #define ASSERT_MUTANT(E) \ - ASSERT((E)->Header.Type == MutantObject) + NT_ASSERT((E)->Header.Type == MutantObject) #define ASSERT_SEMAPHORE(E) \ - ASSERT((E)->Header.Type == SemaphoreObject) + NT_ASSERT((E)->Header.Type == SemaphoreObject) #define ASSERT_EVENT(E) \ - ASSERT(((E)->Header.Type == NotificationEvent) || \ + NT_ASSERT(((E)->Header.Type == NotificationEvent) || \ ((E)->Header.Type == SynchronizationEvent)) #define DPC_NORMAL 0 @@ -534,6 +574,9 @@ typedef enum _MODE { #define GM_LOCK_WAITER_WOKEN 0x2 #define GM_LOCK_WAITER_INC 0x4 +#define LOCK_QUEUE_WAIT_BIT 0 +#define LOCK_QUEUE_OWNER_BIT 1 + #define LOCK_QUEUE_WAIT 1 #define LOCK_QUEUE_OWNER 2 #define LOCK_QUEUE_TIMER_LOCK_SHIFT 4 @@ -593,7 +636,6 @@ typedef struct _EXCEPTION_POINTERS { PCONTEXT ContextRecord; } EXCEPTION_POINTERS, *PEXCEPTION_POINTERS; - typedef enum _KBUGCHECK_CALLBACK_REASON { KbCallbackInvalid, KbCallbackReserved1, @@ -605,11 +647,12 @@ typedef enum _KBUGCHECK_CALLBACK_REASON { struct _KBUGCHECK_REASON_CALLBACK_RECORD; typedef VOID -(DDKAPI *PKBUGCHECK_REASON_CALLBACK_ROUTINE)( +(NTAPI KBUGCHECK_REASON_CALLBACK_ROUTINE)( IN KBUGCHECK_CALLBACK_REASON Reason, IN struct _KBUGCHECK_REASON_CALLBACK_RECORD *Record, IN OUT PVOID ReasonSpecificData, IN ULONG ReasonSpecificDataLength); +typedef KBUGCHECK_REASON_CALLBACK_ROUTINE *PKBUGCHECK_REASON_CALLBACK_ROUTINE; typedef struct _KBUGCHECK_REASON_CALLBACK_RECORD { LIST_ENTRY Entry; @@ -629,9 +672,10 @@ typedef enum _KBUGCHECK_BUFFER_DUMP_STATE { } KBUGCHECK_BUFFER_DUMP_STATE; typedef VOID -(DDKAPI *PKBUGCHECK_CALLBACK_ROUTINE)( +(NTAPI KBUGCHECK_CALLBACK_ROUTINE)( IN PVOID Buffer, IN ULONG Length); +typedef KBUGCHECK_CALLBACK_ROUTINE *PKBUGCHECK_CALLBACK_ROUTINE; typedef struct _KBUGCHECK_CALLBACK_RECORD { LIST_ENTRY Entry; @@ -644,9 +688,10 @@ typedef struct _KBUGCHECK_CALLBACK_RECORD { } KBUGCHECK_CALLBACK_RECORD, *PKBUGCHECK_CALLBACK_RECORD; typedef BOOLEAN -(DDKAPI *PNMI_CALLBACK)( +(NTAPI NMI_CALLBACK)( IN PVOID Context, IN BOOLEAN Handled); +typedef NMI_CALLBACK *PNMI_CALLBACK; typedef enum _TRACE_INFORMATION_CLASS { TraceIdClass, @@ -759,7 +804,7 @@ typedef enum _KINTERRUPT_MODE { #define THREAD_WAIT_OBJECTS 3 typedef VOID -(DDKAPI *PKINTERRUPT_ROUTINE)( +(NTAPI *PKINTERRUPT_ROUTINE)( VOID); typedef enum _KD_OPTION { @@ -789,25 +834,24 @@ typedef enum _INTERFACE_TYPE { } INTERFACE_TYPE, *PINTERFACE_TYPE; typedef VOID -(DDKAPI *PKNORMAL_ROUTINE)( - IN PVOID NormalContext, - IN PVOID SystemArgument1, - IN PVOID SystemArgument2); +(NTAPI *PKNORMAL_ROUTINE)( + IN PVOID NormalContext OPTIONAL, + IN PVOID SystemArgument1 OPTIONAL, + IN PVOID SystemArgument2 OPTIONAL); typedef VOID -(DDKAPI *PKRUNDOWN_ROUTINE)( +(NTAPI *PKRUNDOWN_ROUTINE)( IN struct _KAPC *Apc); typedef VOID -(DDKAPI *PKKERNEL_ROUTINE)( +(NTAPI *PKKERNEL_ROUTINE)( IN struct _KAPC *Apc, - IN OUT PKNORMAL_ROUTINE *NormalRoutine, - IN OUT PVOID *NormalContext, - IN OUT PVOID *SystemArgument1, - IN OUT PVOID *SystemArgument2); + IN OUT PKNORMAL_ROUTINE *NormalRoutine OPTIONAL, + IN OUT PVOID *NormalContext OPTIONAL, + IN OUT PVOID *SystemArgument1 OPTIONAL, + IN OUT PVOID *SystemArgument2 OPTIONAL); -typedef struct _KAPC -{ +typedef struct _KAPC { UCHAR Type; UCHAR SpareByte0; UCHAR Size; @@ -835,13 +879,12 @@ typedef struct _KDEVICE_QUEUE_ENTRY { typedef PVOID PKIPI_CONTEXT; -typedef -VOID +typedef VOID (NTAPI *PKIPI_WORKER)( - IN PKIPI_CONTEXT PacketContext, - IN PVOID Parameter1, - IN PVOID Parameter2, - IN PVOID Parameter3); + IN OUT PKIPI_CONTEXT PacketContext, + IN PVOID Parameter1 OPTIONAL, + IN PVOID Parameter2 OPTIONAL, + IN PVOID Parameter3 OPTIONAL); typedef ULONG_PTR @@ -908,14 +951,14 @@ typedef enum _KSPIN_LOCK_QUEUE_NUMBER { LockQueueMaximumLock = LockQueueTimerTableLock + LOCK_QUEUE_TIMER_TABLE_LOCKS } KSPIN_LOCK_QUEUE_NUMBER, *PKSPIN_LOCK_QUEUE_NUMBER; -#endif +#endif /* defined(_AMD64_) */ typedef VOID -(DDKAPI *PKDEFERRED_ROUTINE)( +(NTAPI *PKDEFERRED_ROUTINE)( IN struct _KDPC *Dpc, - IN PVOID DeferredContext, - IN PVOID SystemArgument1, - IN PVOID SystemArgument2); + IN PVOID DeferredContext OPTIONAL, + IN PVOID SystemArgument1 OPTIONAL, + IN PVOID SystemArgument2 OPTIONAL); typedef enum _KDPC_IMPORTANCE { LowImportance, @@ -924,8 +967,7 @@ typedef enum _KDPC_IMPORTANCE { MediumHighImportance } KDPC_IMPORTANCE; -typedef struct _KDPC -{ +typedef struct _KDPC { UCHAR Type; UCHAR Importance; volatile USHORT Number; @@ -961,11 +1003,11 @@ typedef struct _KDEVICE_QUEUE { #else BOOLEAN Busy; #endif - } KDEVICE_QUEUE, *PKDEVICE_QUEUE, *RESTRICTED_POINTER PRKDEVICE_QUEUE; #define TIMER_EXPIRED_INDEX_BITS 6 #define TIMER_PROCESSOR_INDEX_BITS 5 + typedef struct _DISPATCHER_HEADER { _ANONYMOUS_UNION union { _ANONYMOUS_STRUCT struct { @@ -1046,21 +1088,17 @@ typedef struct _KSEMAPHORE { LONG Limit; } KSEMAPHORE, *PKSEMAPHORE, *RESTRICTED_POINTER PRKSEMAPHORE; -typedef struct _KGATE -{ +typedef struct _KGATE { DISPATCHER_HEADER Header; } KGATE, *PKGATE, *RESTRICTED_POINTER PRKGATE; -typedef struct _KGUARDED_MUTEX -{ +typedef struct _KGUARDED_MUTEX { volatile LONG Count; PKTHREAD Owner; ULONG Contention; KGATE Gate; - __GNU_EXTENSION union - { - __GNU_EXTENSION struct - { + __GNU_EXTENSION union { + __GNU_EXTENSION struct { SHORT KernelApcDisable; SHORT SpecialApcDisable; }; @@ -1091,7 +1129,7 @@ typedef struct _KTIMER { } KTIMER, *PKTIMER, *RESTRICTED_POINTER PRKTIMER; typedef BOOLEAN -(DDKAPI *PKSYNCHRONIZE_ROUTINE)( +(NTAPI *PKSYNCHRONIZE_ROUTINE)( IN PVOID SynchronizeContext); typedef enum _POOL_TYPE { @@ -1112,8 +1150,7 @@ typedef enum _POOL_TYPE { NonPagedPoolCacheAlignedMustSSession } POOL_TYPE; -typedef enum _ALTERNATIVE_ARCHITECTURE_TYPE -{ +typedef enum _ALTERNATIVE_ARCHITECTURE_TYPE { StandardDesign, NEC98x86, EndAlternatives @@ -1309,6 +1346,9 @@ typedef enum _MM_SYSTEM_SIZE { MmLargeSystem } MM_SYSTEMSIZE; +extern NTKERNELAPI BOOLEAN Mm64BitPhysicalAddress; +extern PVOID MmBadPointer; + /****************************************************************************** * Executive Types * @@ -1373,32 +1413,33 @@ typedef enum _EX_POOL_PRIORITY { typedef struct _LOOKASIDE_LIST_EX *PLOOKASIDE_LIST_EX; typedef PVOID -(DDKAPI *PALLOCATE_FUNCTION)( +(NTAPI *PALLOCATE_FUNCTION)( IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes, IN ULONG Tag); typedef PVOID -(DDKAPI *PALLOCATE_FUNCTION_EX)( +(NTAPI *PALLOCATE_FUNCTION_EX)( IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes, IN ULONG Tag, IN OUT PLOOKASIDE_LIST_EX Lookaside); typedef VOID -(DDKAPI *PFREE_FUNCTION)( +(NTAPI *PFREE_FUNCTION)( IN PVOID Buffer); typedef VOID -(DDKAPI *PFREE_FUNCTION_EX)( +(NTAPI *PFREE_FUNCTION_EX)( IN PVOID Buffer, IN OUT PLOOKASIDE_LIST_EX Lookaside); typedef VOID -(DDKAPI *PCALLBACK_FUNCTION)( - IN PVOID CallbackContext, - IN PVOID Argument1, - IN PVOID Argument2); +(NTAPI CALLBACK_FUNCTION)( + IN PVOID CallbackContext OPTIONAL, + IN PVOID Argument1 OPTIONAL, + IN PVOID Argument2 OPTIONAL); +typedef CALLBACK_FUNCTION *PCALLBACK_FUNCTION; #define GENERAL_LOOKASIDE_LAYOUT \ union { \ @@ -1448,6 +1489,13 @@ typedef struct _GENERAL_LOOKASIDE_POOL { GENERAL_LOOKASIDE_LAYOUT } GENERAL_LOOKASIDE_POOL, *PGENERAL_LOOKASIDE_POOL; +#define LOOKASIDE_CHECK(f) \ + C_ASSERT(FIELD_OFFSET(GENERAL_LOOKASIDE,f) == FIELD_OFFSET(GENERAL_LOOKASIDE_POOL,f)) + +LOOKASIDE_CHECK(TotalFrees); +LOOKASIDE_CHECK(Tag); +LOOKASIDE_CHECK(Future); + typedef struct _PAGED_LOOKASIDE_LIST { GENERAL_LOOKASIDE L; #if !defined(_AMD64_) && !defined(_IA64_) @@ -1462,10 +1510,22 @@ typedef struct LOOKASIDE_ALIGN _NPAGED_LOOKASIDE_LIST { #endif } NPAGED_LOOKASIDE_LIST, *PNPAGED_LOOKASIDE_LIST; +#define LOOKASIDE_MINIMUM_BLOCK_SIZE (RTL_SIZEOF_THROUGH_FIELD (SLIST_ENTRY, Next)) + typedef struct _LOOKASIDE_LIST_EX { GENERAL_LOOKASIDE_POOL L; } LOOKASIDE_LIST_EX; +#if (NTDDI_VERSION >= NTDDI_VISTA) + +#define EX_LOOKASIDE_LIST_EX_FLAGS_RAISE_ON_FAIL 0x00000001UL +#define EX_LOOKASIDE_LIST_EX_FLAGS_FAIL_NO_RAISE 0x00000002UL + +#define EX_MAXIMUM_LOOKASIDE_DEPTH_BASE 256 +#define EX_MAXIMUM_LOOKASIDE_DEPTH_LIMIT 1024 + +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + typedef struct _EX_RUNDOWN_REF { __GNU_EXTENSION union { volatile ULONG_PTR Count; @@ -1476,8 +1536,9 @@ typedef struct _EX_RUNDOWN_REF { typedef struct _EX_RUNDOWN_REF_CACHE_AWARE *PEX_RUNDOWN_REF_CACHE_AWARE; typedef VOID -(DDKAPI *PWORKER_THREAD_ROUTINE)( +(NTAPI WORKER_THREAD_ROUTINE)( IN PVOID Parameter); +typedef WORKER_THREAD_ROUTINE *PWORKER_THREAD_ROUTINE; typedef struct _WORK_QUEUE_ITEM { LIST_ENTRY List; @@ -1692,12 +1753,15 @@ typedef struct _ACCESS_STATE { INITIAL_PRIVILEGE_SET InitialPrivilegeSet; PRIVILEGE_SET PrivilegeSet; } Privileges; - BOOLEAN AuditPrivileges; UNICODE_STRING ObjectName; UNICODE_STRING ObjectTypeName; } ACCESS_STATE, *PACCESS_STATE; +typedef VOID +(NTAPI *PNTFS_DEREF_EXPORTED_SECURITY_DESCRIPTOR)( + IN PVOID Vcb, + IN PSECURITY_DESCRIPTOR SecurityDescriptor); #ifndef _NTLSA_IFS_ @@ -1788,7 +1852,6 @@ typedef struct _SE_ADT_PARAMETER_ARRAY { #endif /* !_NTLSA_AUDIT_ */ #endif /* !_NTLSA_IFS_ */ - /****************************************************************************** * Power Management Support Types * ******************************************************************************/ @@ -1796,9 +1859,16 @@ typedef struct _SE_ADT_PARAMETER_ARRAY { #ifndef _PO_DDK_ #define _PO_DDK_ +#define PO_CB_SYSTEM_POWER_POLICY 0 +#define PO_CB_AC_STATUS 1 +#define PO_CB_BUTTON_COLLISION 2 +#define PO_CB_SYSTEM_STATE_LOCK 3 +#define PO_CB_LID_SWITCH_STATE 4 +#define PO_CB_PROCESSOR_POWER_POLICY 5 + /* Power States/Levels */ typedef enum _SYSTEM_POWER_STATE { - PowerSystemUnspecified, + PowerSystemUnspecified = 0, PowerSystemWorking, PowerSystemSleeping1, PowerSystemSleeping2, @@ -1867,7 +1937,7 @@ typedef enum _POWER_INFORMATION_LEVEL { } POWER_INFORMATION_LEVEL; typedef enum { - PowerActionNone, + PowerActionNone = 0, PowerActionReserved, PowerActionSleep, PowerActionHibernate, @@ -1878,7 +1948,7 @@ typedef enum { } POWER_ACTION, *PPOWER_ACTION; typedef enum _DEVICE_POWER_STATE { - PowerDeviceUnspecified, + PowerDeviceUnspecified = 0, PowerDeviceD0, PowerDeviceD1, PowerDeviceD2, @@ -1886,6 +1956,12 @@ typedef enum _DEVICE_POWER_STATE { PowerDeviceMaximum } DEVICE_POWER_STATE, *PDEVICE_POWER_STATE; +typedef enum _MONITOR_DISPLAY_STATE { + PowerMonitorOff = 0, + PowerMonitorOn, + PowerMonitorDim +} MONITOR_DISPLAY_STATE, *PMONITOR_DISPLAY_STATE; + typedef union _POWER_STATE { SYSTEM_POWER_STATE SystemState; DEVICE_POWER_STATE DeviceState; @@ -1905,22 +1981,148 @@ typedef struct { #endif /* !_PO_DDK_ */ +#define CORE_PARKING_POLICY_CHANGE_IDEAL 0 +#define CORE_PARKING_POLICY_CHANGE_SINGLE 1 +#define CORE_PARKING_POLICY_CHANGE_ROCKET 2 +#define CORE_PARKING_POLICY_CHANGE_MAX CORE_PARKING_POLICY_CHANGE_ROCKET + +DEFINE_GUID(GUID_MAX_POWER_SAVINGS, 0xA1841308, 0x3541, 0x4FAB, 0xBC, 0x81, 0xF7, 0x15, 0x56, 0xF2, 0x0B, 0x4A ); +DEFINE_GUID(GUID_MIN_POWER_SAVINGS, 0x8C5E7FDA, 0xE8BF, 0x4A96, 0x9A, 0x85, 0xA6, 0xE2, 0x3A, 0x8C, 0x63, 0x5C ); +DEFINE_GUID(GUID_TYPICAL_POWER_SAVINGS, 0x381B4222, 0xF694, 0x41F0, 0x96, 0x85, 0xFF, 0x5B, 0xB2, 0x60, 0xDF, 0x2E ); +DEFINE_GUID(NO_SUBGROUP_GUID, 0xFEA3413E, 0x7E05, 0x4911, 0x9A, 0x71, 0x70, 0x03, 0x31, 0xF1, 0xC2, 0x94 ); +DEFINE_GUID(ALL_POWERSCHEMES_GUID, 0x68A1E95E, 0x13EA, 0x41E1, 0x80, 0x11, 0x0C, 0x49, 0x6C, 0xA4, 0x90, 0xB0 ); +DEFINE_GUID(GUID_POWERSCHEME_PERSONALITY, 0x245D8541, 0x3943, 0x4422, 0xB0, 0x25, 0x13, 0xA7, 0x84, 0xF6, 0x79, 0xB7 ); +DEFINE_GUID(GUID_ACTIVE_POWERSCHEME, 0x31F9F286, 0x5084, 0x42FE, 0xB7, 0x20, 0x2B, 0x02, 0x64, 0x99, 0x37, 0x63 ); +DEFINE_GUID(GUID_VIDEO_SUBGROUP, 0x7516B95F, 0xF776, 0x4464, 0x8C, 0x53, 0x06, 0x16, 0x7F, 0x40, 0xCC, 0x99 ); +DEFINE_GUID(GUID_VIDEO_POWERDOWN_TIMEOUT, 0x3C0BC021, 0xC8A8, 0x4E07, 0xA9, 0x73, 0x6B, 0x14, 0xCB, 0xCB, 0x2B, 0x7E ); +DEFINE_GUID(GUID_VIDEO_ANNOYANCE_TIMEOUT, 0x82DBCF2D, 0xCD67, 0x40C5, 0xBF, 0xDC, 0x9F, 0x1A, 0x5C, 0xCD, 0x46, 0x63 ); +DEFINE_GUID(GUID_VIDEO_ADAPTIVE_PERCENT_INCREASE, 0xEED904DF, 0xB142, 0x4183, 0xB1, 0x0B, 0x5A, 0x11, 0x97, 0xA3, 0x78, 0x64 ); +DEFINE_GUID(GUID_VIDEO_DIM_TIMEOUT, 0x17aaa29b, 0x8b43, 0x4b94, 0xaa, 0xfe, 0x35, 0xf6, 0x4d, 0xaa, 0xf1, 0xee); +DEFINE_GUID(GUID_VIDEO_ADAPTIVE_POWERDOWN, 0x90959D22, 0xD6A1, 0x49B9, 0xAF, 0x93, 0xBC, 0xE8, 0x85, 0xAD, 0x33, 0x5B ); +DEFINE_GUID(GUID_MONITOR_POWER_ON, 0x02731015, 0x4510, 0x4526, 0x99, 0xE6, 0xE5, 0xA1, 0x7E, 0xBD, 0x1A, 0xEA ); +DEFINE_GUID(GUID_DEVICE_POWER_POLICY_VIDEO_BRIGHTNESS, 0xaded5e82L, 0xb909, 0x4619, 0x99, 0x49, 0xf5, 0xd7, 0x1d, 0xac, 0x0b, 0xcb); +DEFINE_GUID(GUID_DEVICE_POWER_POLICY_VIDEO_DIM_BRIGHTNESS, 0xf1fbfde2, 0xa960, 0x4165, 0x9f, 0x88, 0x50, 0x66, 0x79, 0x11, 0xce, 0x96); +DEFINE_GUID(GUID_VIDEO_CURRENT_MONITOR_BRIGHTNESS, 0x8ffee2c6, 0x2d01, 0x46be, 0xad, 0xb9, 0x39, 0x8a, 0xdd, 0xc5, 0xb4, 0xff); +DEFINE_GUID(GUID_VIDEO_ADAPTIVE_DISPLAY_BRIGHTNESS, 0xFBD9AA66, 0x9553, 0x4097, 0xBA, 0x44, 0xED, 0x6E, 0x9D, 0x65, 0xEA, 0xB8); +DEFINE_GUID(GUID_SESSION_DISPLAY_STATE, 0x73A5E93A, 0x5BB1, 0x4F93, 0x89, 0x5B, 0xDB, 0xD0, 0xDA, 0x85, 0x59, 0x67 ); +DEFINE_GUID(GUID_CONSOLE_DISPLAY_STATE, 0x6fe69556, 0x704a, 0x47a0, 0x8f, 0x24, 0xc2, 0x8d, 0x93, 0x6f, 0xda, 0x47); +DEFINE_GUID(GUID_ALLOW_DISPLAY_REQUIRED, 0xA9CEB8DA, 0xCD46, 0x44FB, 0xA9, 0x8B, 0x02, 0xAF, 0x69, 0xDE, 0x46, 0x23 ); +DEFINE_GUID(GUID_DISK_SUBGROUP, 0x0012EE47, 0x9041, 0x4B5D, 0x9B, 0x77, 0x53, 0x5F, 0xBA, 0x8B, 0x14, 0x42 ); +DEFINE_GUID(GUID_DISK_POWERDOWN_TIMEOUT, 0x6738E2C4, 0xE8A5, 0x4A42, 0xB1, 0x6A, 0xE0, 0x40, 0xE7, 0x69, 0x75, 0x6E ); +DEFINE_GUID(GUID_DISK_BURST_IGNORE_THRESHOLD, 0x80e3c60e, 0xbb94, 0x4ad8, 0xbb, 0xe0, 0x0d, 0x31, 0x95, 0xef, 0xc6, 0x63 ); +DEFINE_GUID(GUID_DISK_ADAPTIVE_POWERDOWN, 0x396A32E1, 0x499A, 0x40B2, 0x91, 0x24, 0xA9, 0x6A, 0xFE, 0x70, 0x76, 0x67 ); +DEFINE_GUID(GUID_SLEEP_SUBGROUP, 0x238C9FA8, 0x0AAD, 0x41ED, 0x83, 0xF4, 0x97, 0xBE, 0x24, 0x2C, 0x8F, 0x20 ); +DEFINE_GUID(GUID_SLEEP_IDLE_THRESHOLD, 0x81cd32e0, 0x7833, 0x44f3, 0x87, 0x37, 0x70, 0x81, 0xf3, 0x8d, 0x1f, 0x70 ); +DEFINE_GUID(GUID_STANDBY_TIMEOUT, 0x29F6C1DB, 0x86DA, 0x48C5, 0x9F, 0xDB, 0xF2, 0xB6, 0x7B, 0x1F, 0x44, 0xDA ); +DEFINE_GUID(GUID_UNATTEND_SLEEP_TIMEOUT, 0x7bc4a2f9, 0xd8fc, 0x4469, 0xb0, 0x7b, 0x33, 0xeb, 0x78, 0x5a, 0xac, 0xa0 ); +DEFINE_GUID(GUID_HIBERNATE_TIMEOUT, 0x9D7815A6, 0x7EE4, 0x497E, 0x88, 0x88, 0x51, 0x5A, 0x05, 0xF0, 0x23, 0x64 ); +DEFINE_GUID(GUID_HIBERNATE_FASTS4_POLICY, 0x94AC6D29, 0x73CE, 0x41A6, 0x80, 0x9F, 0x63, 0x63, 0xBA, 0x21, 0xB4, 0x7E ); +DEFINE_GUID(GUID_CRITICAL_POWER_TRANSITION, 0xB7A27025, 0xE569, 0x46c2, 0xA5, 0x04, 0x2B, 0x96, 0xCA, 0xD2, 0x25, 0xA1); +DEFINE_GUID(GUID_SYSTEM_AWAYMODE, 0x98A7F580, 0x01F7, 0x48AA, 0x9C, 0x0F, 0x44, 0x35, 0x2C, 0x29, 0xE5, 0xC0 ); +DEFINE_GUID(GUID_ALLOW_AWAYMODE, 0x25dfa149, 0x5dd1, 0x4736, 0xb5, 0xab, 0xe8, 0xa3, 0x7b, 0x5b, 0x81, 0x87 ); +DEFINE_GUID(GUID_ALLOW_STANDBY_STATES, 0xabfc2519, 0x3608, 0x4c2a, 0x94, 0xea, 0x17, 0x1b, 0x0e, 0xd5, 0x46, 0xab ); +DEFINE_GUID(GUID_ALLOW_RTC_WAKE, 0xBD3B718A, 0x0680, 0x4D9D, 0x8A, 0xB2, 0xE1, 0xD2, 0xB4, 0xAC, 0x80, 0x6D ); +DEFINE_GUID(GUID_ALLOW_SYSTEM_REQUIRED, 0xA4B195F5, 0x8225, 0x47D8, 0x80, 0x12, 0x9D, 0x41, 0x36, 0x97, 0x86, 0xE2 ); +DEFINE_GUID(GUID_SYSTEM_BUTTON_SUBGROUP, 0x4F971E89, 0xEEBD, 0x4455, 0xA8, 0xDE, 0x9E, 0x59, 0x04, 0x0E, 0x73, 0x47 ); +DEFINE_GUID(GUID_POWERBUTTON_ACTION, 0x7648EFA3, 0xDD9C, 0x4E3E, 0xB5, 0x66, 0x50, 0xF9, 0x29, 0x38, 0x62, 0x80 ); +DEFINE_GUID(GUID_POWERBUTTON_ACTION_FLAGS, 0x857E7FAC, 0x034B, 0x4704, 0xAB, 0xB1, 0xBC, 0xA5, 0x4A, 0xA3, 0x14, 0x78 ); +DEFINE_GUID(GUID_SLEEPBUTTON_ACTION, 0x96996BC0, 0xAD50, 0x47EC, 0x92, 0x3B, 0x6F, 0x41, 0x87, 0x4D, 0xD9, 0xEB ); +DEFINE_GUID(GUID_SLEEPBUTTON_ACTION_FLAGS, 0x2A160AB1, 0xB69D, 0x4743, 0xB7, 0x18, 0xBF, 0x14, 0x41, 0xD5, 0xE4, 0x93 ); +DEFINE_GUID(GUID_USERINTERFACEBUTTON_ACTION, 0xA7066653, 0x8D6C, 0x40A8, 0x91, 0x0E, 0xA1, 0xF5, 0x4B, 0x84, 0xC7, 0xE5 ); +DEFINE_GUID(GUID_LIDCLOSE_ACTION, 0x5CA83367, 0x6E45, 0x459F, 0xA2, 0x7B, 0x47, 0x6B, 0x1D, 0x01, 0xC9, 0x36 ); +DEFINE_GUID(GUID_LIDCLOSE_ACTION_FLAGS, 0x97E969AC, 0x0D6C, 0x4D08, 0x92, 0x7C, 0xD7, 0xBD, 0x7A, 0xD7, 0x85, 0x7B ); +DEFINE_GUID(GUID_LIDOPEN_POWERSTATE, 0x99FF10E7, 0x23B1, 0x4C07, 0xA9, 0xD1, 0x5C, 0x32, 0x06, 0xD7, 0x41, 0xB4 ); +DEFINE_GUID(GUID_BATTERY_SUBGROUP, 0xE73A048D, 0xBF27, 0x4F12, 0x97, 0x31, 0x8B, 0x20, 0x76, 0xE8, 0x89, 0x1F ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_ACTION_0, 0x637EA02F, 0xBBCB, 0x4015, 0x8E, 0x2C, 0xA1, 0xC7, 0xB9, 0xC0, 0xB5, 0x46 ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_LEVEL_0, 0x9A66D8D7, 0x4FF7, 0x4EF9, 0xB5, 0xA2, 0x5A, 0x32, 0x6C, 0xA2, 0xA4, 0x69 ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_FLAGS_0, 0x5dbb7c9f, 0x38e9, 0x40d2, 0x97, 0x49, 0x4f, 0x8a, 0x0e, 0x9f, 0x64, 0x0f ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_ACTION_1, 0xD8742DCB, 0x3E6A, 0x4B3C, 0xB3, 0xFE, 0x37, 0x46, 0x23, 0xCD, 0xCF, 0x06 ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_LEVEL_1, 0x8183BA9A, 0xE910, 0x48DA, 0x87, 0x69, 0x14, 0xAE, 0x6D, 0xC1, 0x17, 0x0A ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_FLAGS_1, 0xbcded951, 0x187b, 0x4d05, 0xbc, 0xcc, 0xf7, 0xe5, 0x19, 0x60, 0xc2, 0x58 ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_ACTION_2, 0x421CBA38, 0x1A8E, 0x4881, 0xAC, 0x89, 0xE3, 0x3A, 0x8B, 0x04, 0xEC, 0xE4 ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_LEVEL_2, 0x07A07CA2, 0xADAF, 0x40D7, 0xB0, 0x77, 0x53, 0x3A, 0xAD, 0xED, 0x1B, 0xFA ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_FLAGS_2, 0x7fd2f0c4, 0xfeb7, 0x4da3, 0x81, 0x17, 0xe3, 0xfb, 0xed, 0xc4, 0x65, 0x82 ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_ACTION_3, 0x80472613, 0x9780, 0x455E, 0xB3, 0x08, 0x72, 0xD3, 0x00, 0x3C, 0xF2, 0xF8 ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_LEVEL_3, 0x58AFD5A6, 0xC2DD, 0x47D2, 0x9F, 0xBF, 0xEF, 0x70, 0xCC, 0x5C, 0x59, 0x65 ); +DEFINE_GUID(GUID_BATTERY_DISCHARGE_FLAGS_3, 0x73613ccf, 0xdbfa, 0x4279, 0x83, 0x56, 0x49, 0x35, 0xf6, 0xbf, 0x62, 0xf3 ); +DEFINE_GUID(GUID_PROCESSOR_SETTINGS_SUBGROUP, 0x54533251, 0x82BE, 0x4824, 0x96, 0xC1, 0x47, 0xB6, 0x0B, 0x74, 0x0D, 0x00 ); +DEFINE_GUID(GUID_PROCESSOR_THROTTLE_POLICY, 0x57027304, 0x4AF6, 0x4104, 0x92, 0x60, 0xE3, 0xD9, 0x52, 0x48, 0xFC, 0x36 ); +DEFINE_GUID(GUID_PROCESSOR_THROTTLE_MAXIMUM, 0xBC5038F7, 0x23E0, 0x4960, 0x96, 0xDA, 0x33, 0xAB, 0xAF, 0x59, 0x35, 0xEC ); +DEFINE_GUID(GUID_PROCESSOR_THROTTLE_MINIMUM, 0x893DEE8E, 0x2BEF, 0x41E0, 0x89, 0xC6, 0xB5, 0x5D, 0x09, 0x29, 0x96, 0x4C ); +DEFINE_GUID(GUID_PROCESSOR_ALLOW_THROTTLING, 0x3b04d4fd, 0x1cc7, 0x4f23, 0xab, 0x1c, 0xd1, 0x33, 0x78, 0x19, 0xc4, 0xbb ); +DEFINE_GUID(GUID_PROCESSOR_IDLESTATE_POLICY, 0x68f262a7, 0xf621, 0x4069, 0xb9, 0xa5, 0x48, 0x74, 0x16, 0x9b, 0xe2, 0x3c); +DEFINE_GUID(GUID_PROCESSOR_PERFSTATE_POLICY, 0xBBDC3814, 0x18E9, 0x4463, 0x8A, 0x55, 0xD1, 0x97, 0x32, 0x7C, 0x45, 0xC0); +DEFINE_GUID(GUID_PROCESSOR_PERF_INCREASE_THRESHOLD, 0x06cadf0e, 0x64ed, 0x448a, 0x89, 0x27, 0xce, 0x7b, 0xf9, 0x0e, 0xb3, 0x5d ); +DEFINE_GUID(GUID_PROCESSOR_PERF_DECREASE_THRESHOLD, 0x12a0ab44, 0xfe28, 0x4fa9, 0xb3, 0xbd, 0x4b, 0x64, 0xf4, 0x49, 0x60, 0xa6 ); +DEFINE_GUID(GUID_PROCESSOR_PERF_INCREASE_POLICY, 0x465e1f50, 0xb610, 0x473a, 0xab, 0x58, 0x0, 0xd1, 0x7, 0x7d, 0xc4, 0x18); +DEFINE_GUID(GUID_PROCESSOR_PERF_DECREASE_POLICY, 0x40fbefc7, 0x2e9d, 0x4d25, 0xa1, 0x85, 0xc, 0xfd, 0x85, 0x74, 0xba, 0xc6); +DEFINE_GUID(GUID_PROCESSOR_PERF_INCREASE_TIME, 0x984cf492, 0x3bed, 0x4488, 0xa8, 0xf9, 0x42, 0x86, 0xc9, 0x7b, 0xf5, 0xaa); +DEFINE_GUID(GUID_PROCESSOR_PERF_DECREASE_TIME, 0xd8edeb9b, 0x95cf, 0x4f95, 0xa7, 0x3c, 0xb0, 0x61, 0x97, 0x36, 0x93, 0xc8); +DEFINE_GUID(GUID_PROCESSOR_PERF_TIME_CHECK, 0x4d2b0152, 0x7d5c, 0x498b, 0x88, 0xe2, 0x34, 0x34, 0x53, 0x92, 0xa2, 0xc5); +DEFINE_GUID(GUID_PROCESSOR_PERF_BOOST_POLICY, 0x45bcc044, 0xd885, 0x43e2, 0x86, 0x5, 0xee, 0xe, 0xc6, 0xe9, 0x6b, 0x59); +DEFINE_GUID(GUID_PROCESSOR_IDLE_ALLOW_SCALING, 0x6c2993b0, 0x8f48, 0x481f, 0xbc, 0xc6, 0x0, 0xdd, 0x27, 0x42, 0xaa, 0x6); +DEFINE_GUID(GUID_PROCESSOR_IDLE_DISABLE, 0x5d76a2ca, 0xe8c0, 0x402f, 0xa1, 0x33, 0x21, 0x58, 0x49, 0x2d, 0x58, 0xad); +DEFINE_GUID(GUID_PROCESSOR_IDLE_TIME_CHECK, 0xc4581c31, 0x89ab, 0x4597, 0x8e, 0x2b, 0x9c, 0x9c, 0xab, 0x44, 0xe, 0x6b); +DEFINE_GUID(GUID_PROCESSOR_IDLE_DEMOTE_THRESHOLD, 0x4b92d758, 0x5a24, 0x4851, 0xa4, 0x70, 0x81, 0x5d, 0x78, 0xae, 0xe1, 0x19); +DEFINE_GUID(GUID_PROCESSOR_IDLE_PROMOTE_THRESHOLD, 0x7b224883, 0xb3cc, 0x4d79, 0x81, 0x9f, 0x83, 0x74, 0x15, 0x2c, 0xbe, 0x7c); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_INCREASE_THRESHOLD, 0xdf142941, 0x20f3, 0x4edf, 0x9a, 0x4a, 0x9c, 0x83, 0xd3, 0xd7, 0x17, 0xd1 ); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_DECREASE_THRESHOLD, 0x68dd2f27, 0xa4ce, 0x4e11, 0x84, 0x87, 0x37, 0x94, 0xe4, 0x13, 0x5d, 0xfa); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_INCREASE_POLICY, 0xc7be0679, 0x2817, 0x4d69, 0x9d, 0x02, 0x51, 0x9a, 0x53, 0x7e, 0xd0, 0xc6); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_DECREASE_POLICY, 0x71021b41, 0xc749, 0x4d21, 0xbe, 0x74, 0xa0, 0x0f, 0x33, 0x5d, 0x58, 0x2b); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_MAX_CORES, 0xea062031, 0x0e34, 0x4ff1, 0x9b, 0x6d, 0xeb, 0x10, 0x59, 0x33, 0x40, 0x28); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_MIN_CORES, 0x0cc5b647, 0xc1df, 0x4637, 0x89, 0x1a, 0xde, 0xc3, 0x5c, 0x31, 0x85, 0x83); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_INCREASE_TIME, 0x2ddd5a84, 0x5a71, 0x437e, 0x91, 0x2a, 0xdb, 0x0b, 0x8c, 0x78, 0x87, 0x32); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_DECREASE_TIME, 0xdfd10d17, 0xd5eb, 0x45dd, 0x87, 0x7a, 0x9a, 0x34, 0xdd, 0xd1, 0x5c, 0x82); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_AFFINITY_HISTORY_DECREASE_FACTOR, 0x8f7b45e3, 0xc393, 0x480a, 0x87, 0x8c, 0xf6, 0x7a, 0xc3, 0xd0, 0x70, 0x82); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_AFFINITY_HISTORY_THRESHOLD, 0x5b33697b, 0xe89d, 0x4d38, 0xaa, 0x46, 0x9e, 0x7d, 0xfb, 0x7c, 0xd2, 0xf9); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_AFFINITY_WEIGHTING, 0xe70867f1, 0xfa2f, 0x4f4e, 0xae, 0xa1, 0x4d, 0x8a, 0x0b, 0xa2, 0x3b, 0x20); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_HISTORY_DECREASE_FACTOR, 0x1299023c, 0xbc28, 0x4f0a, 0x81, 0xec, 0xd3, 0x29, 0x5a, 0x8d, 0x81, 0x5d); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_HISTORY_THRESHOLD, 0x9ac18e92, 0xaa3c, 0x4e27, 0xb3, 0x07, 0x01, 0xae, 0x37, 0x30, 0x71, 0x29); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_WEIGHTING, 0x8809c2d8, 0xb155, 0x42d4, 0xbc, 0xda, 0x0d, 0x34, 0x56, 0x51, 0xb1, 0xdb); +DEFINE_GUID(GUID_PROCESSOR_CORE_PARKING_OVER_UTILIZATION_THRESHOLD, 0x943c8cb6, 0x6f93, 0x4227, 0xad, 0x87, 0xe9, 0xa3, 0xfe, 0xec, 0x08, 0xd1); +DEFINE_GUID(GUID_PROCESSOR_PARKING_CORE_OVERRIDE, 0xa55612aa, 0xf624, 0x42c6, 0xa4, 0x43, 0x73, 0x97, 0xd0, 0x64, 0xc0, 0x4f); +DEFINE_GUID(GUID_PROCESSOR_PARKING_PERF_STATE, 0x447235c7, 0x6a8d, 0x4cc0, 0x8e, 0x24, 0x9e, 0xaf, 0x70, 0xb9, 0x6e, 0x2b); +DEFINE_GUID(GUID_PROCESSOR_PERF_HISTORY, 0x7d24baa7, 0x0b84, 0x480f, 0x84, 0x0c, 0x1b, 0x07, 0x43, 0xc0, 0x0f, 0x5f); +DEFINE_GUID(GUID_SYSTEM_COOLING_POLICY, 0x94D3A615, 0xA899, 0x4AC5, 0xAE, 0x2B, 0xE4, 0xD8, 0xF6, 0x34, 0x36, 0x7F); +DEFINE_GUID(GUID_LOCK_CONSOLE_ON_WAKE, 0x0E796BDB, 0x100D, 0x47D6, 0xA2, 0xD5, 0xF7, 0xD2, 0xDA, 0xA5, 0x1F, 0x51 ); +DEFINE_GUID(GUID_DEVICE_IDLE_POLICY, 0x4faab71a, 0x92e5, 0x4726, 0xb5, 0x31, 0x22, 0x45, 0x59, 0x67, 0x2d, 0x19 ); +DEFINE_GUID(GUID_ACDC_POWER_SOURCE, 0x5D3E9A59, 0xE9D5, 0x4B00, 0xA6, 0xBD, 0xFF, 0x34, 0xFF, 0x51, 0x65, 0x48 ); +DEFINE_GUID(GUID_LIDSWITCH_STATE_CHANGE, 0xBA3E0F4D, 0xB817, 0x4094, 0xA2, 0xD1, 0xD5, 0x63, 0x79, 0xE6, 0xA0, 0xF3 ); +DEFINE_GUID(GUID_BATTERY_PERCENTAGE_REMAINING, 0xA7AD8041, 0xB45A, 0x4CAE, 0x87, 0xA3, 0xEE, 0xCB, 0xB4, 0x68, 0xA9, 0xE1 ); +DEFINE_GUID(GUID_IDLE_BACKGROUND_TASK, 0x515C31D8, 0xF734, 0x163D, 0xA0, 0xFD, 0x11, 0xA0, 0x8C, 0x91, 0xE8, 0xF1 ); +DEFINE_GUID(GUID_BACKGROUND_TASK_NOTIFICATION, 0xCF23F240, 0x2A54, 0x48D8, 0xB1, 0x14, 0xDE, 0x15, 0x18, 0xFF, 0x05, 0x2E ); +DEFINE_GUID(GUID_APPLAUNCH_BUTTON, 0x1A689231, 0x7399, 0x4E9A, 0x8F, 0x99, 0xB7, 0x1F, 0x99, 0x9D, 0xB3, 0xFA ); +DEFINE_GUID(GUID_PCIEXPRESS_SETTINGS_SUBGROUP, 0x501a4d13, 0x42af,0x4429, 0x9f, 0xd1, 0xa8, 0x21, 0x8c, 0x26, 0x8e, 0x20 ); +DEFINE_GUID(GUID_PCIEXPRESS_ASPM_POLICY, 0xee12f906, 0xd277, 0x404b, 0xb6, 0xda, 0xe5, 0xfa, 0x1a, 0x57, 0x6d, 0xf5 ); +DEFINE_GUID(GUID_ENABLE_SWITCH_FORCED_SHUTDOWN, 0x833a6b62, 0xdfa4, 0x46d1, 0x82, 0xf8, 0xe0, 0x9e, 0x34, 0xd0, 0x29, 0xd6 ); + +#define PERFSTATE_POLICY_CHANGE_IDEAL 0 +#define PERFSTATE_POLICY_CHANGE_SINGLE 1 +#define PERFSTATE_POLICY_CHANGE_ROCKET 2 +#define PERFSTATE_POLICY_CHANGE_MAX PERFSTATE_POLICY_CHANGE_ROCKET + +#define PROCESSOR_PERF_BOOST_POLICY_DISABLED 0 +#define PROCESSOR_PERF_BOOST_POLICY_MAX 100 + +#define POWER_DEVICE_IDLE_POLICY_PERFORMANCE 0 +#define POWER_DEVICE_IDLE_POLICY_CONSERVATIVE 1 + typedef VOID -(DDKAPI *PREQUEST_POWER_COMPLETE)( +(NTAPI REQUEST_POWER_COMPLETE)( IN struct _DEVICE_OBJECT *DeviceObject, IN UCHAR MinorFunction, IN POWER_STATE PowerState, IN PVOID Context, IN struct _IO_STATUS_BLOCK *IoStatus); +typedef REQUEST_POWER_COMPLETE *PREQUEST_POWER_COMPLETE; typedef NTSTATUS -(DDKAPI POWER_SETTING_CALLBACK)( +(NTAPI POWER_SETTING_CALLBACK)( IN LPCGUID SettingGuid, IN PVOID Value, IN ULONG ValueLength, IN OUT PVOID Context OPTIONAL); - typedef POWER_SETTING_CALLBACK *PPOWER_SETTING_CALLBACK; #define PO_CB_SYSTEM_POWER_POLICY 0 @@ -2035,6 +2237,7 @@ typedef int CM_RESOURCE_TYPE; #define REG_HIVE_EXACT_FILE_GROWTH (0x00000080L) #define REG_HIVE_NO_RM (0x00000100L) #define REG_HIVE_SINGLE_LOG (0x00000200L) +#define REG_BOOT_HIVE (0x00000400L) /* Unload Flags */ #define REG_FORCE_UNLOAD 1 @@ -2179,7 +2382,7 @@ typedef struct _CM_PARTIAL_RESOURCE_DESCRIPTOR { /* CM_PARTIAL_RESOURCE_DESCRIPTOR.ShareDisposition */ typedef enum _CM_SHARE_DISPOSITION { - CmResourceShareUndetermined, + CmResourceShareUndetermined = 0, CmResourceShareDeviceExclusive, CmResourceShareDriverExclusive, CmResourceShareShared @@ -2202,6 +2405,10 @@ typedef enum _CM_SHARE_DISPOSITION { #define CM_RESOURCE_INTERRUPT_MESSAGE 0x0002 #define CM_RESOURCE_INTERRUPT_POLICY_INCLUDED 0x0004 +#define CM_RESOURCE_INTERRUPT_LEVEL_LATCHED_BITS 0x0001 + +#define CM_RESOURCE_INTERRUPT_MESSAGE_TOKEN ((ULONG)-2) + /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypeMemory */ #define CM_RESOURCE_MEMORY_READ_WRITE 0x0000 #define CM_RESOURCE_MEMORY_READ_ONLY 0x0001 @@ -2215,6 +2422,15 @@ typedef enum _CM_SHARE_DISPOSITION { #define CM_RESOURCE_MEMORY_BAR 0x0080 #define CM_RESOURCE_MEMORY_COMPAT_FOR_INACCESSIBLE_RANGE 0x0100 +#define CM_RESOURCE_MEMORY_LARGE 0x0E00 +#define CM_RESOURCE_MEMORY_LARGE_40 0x0200 +#define CM_RESOURCE_MEMORY_LARGE_48 0x0400 +#define CM_RESOURCE_MEMORY_LARGE_64 0x0800 + +#define CM_RESOURCE_MEMORY_LARGE_40_MAXLEN 0x000000FFFFFFFF00 +#define CM_RESOURCE_MEMORY_LARGE_48_MAXLEN 0x0000FFFFFFFF0000 +#define CM_RESOURCE_MEMORY_LARGE_64_MAXLEN 0xFFFFFFFF00000000 + /* CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags if Type = CmResourceTypeDma */ #define CM_RESOURCE_DMA_8 0x0000 #define CM_RESOURCE_DMA_16 0x0001 @@ -2244,6 +2460,7 @@ typedef struct _CM_RESOURCE_LIST { } CM_RESOURCE_LIST, *PCM_RESOURCE_LIST; #include + typedef struct _CM_INT13_DRIVE_PARAMETER { USHORT DriveSelect; ULONG MaxCylinders; @@ -2275,6 +2492,7 @@ typedef struct _CM_PNP_BIOS_INSTALLATION_CHECK { USHORT RealModeDataBaseAddress; ULONG ProtectedModeDataBaseAddress; } CM_PNP_BIOS_INSTALLATION_CHECK, *PCM_PNP_BIOS_INSTALLATION_CHECK; + #include typedef struct _CM_DISK_GEOMETRY_DEVICE_DATA { @@ -2342,7 +2560,10 @@ typedef enum _KEY_INFORMATION_CLASS { KeyFullInformation, KeyNameInformation, KeyCachedInformation, - KeyFlagsInformation + KeyFlagsInformation, + KeyVirtualizationInformation, + KeyHandleTagsInformation, + MaxKeyInfoClass } KEY_INFORMATION_CLASS; typedef struct _KEY_BASIC_INFORMATION { @@ -2496,11 +2717,11 @@ typedef enum _REG_NOTIFY_CLASS { } REG_NOTIFY_CLASS, *PREG_NOTIFY_CLASS; typedef NTSTATUS -(NTAPI *PEX_CALLBACK_FUNCTION)( +(NTAPI EX_CALLBACK_FUNCTION)( IN PVOID CallbackContext, IN PVOID Argument1, - IN PVOID Argument2 -); + IN PVOID Argument2); +typedef EX_CALLBACK_FUNCTION *PEX_CALLBACK_FUNCTION; typedef struct _REG_DELETE_KEY_INFORMATION { PVOID Object; @@ -2919,7 +3140,7 @@ typedef struct _CLIENT_ID { } CLIENT_ID, *PCLIENT_ID; typedef VOID -(DDKAPI *PKSTART_ROUTINE)( +(NTAPI *PKSTART_ROUTINE)( IN PVOID StartContext); typedef struct _VPB { @@ -2941,11 +3162,12 @@ typedef enum _IO_ALLOCATION_ACTION { } IO_ALLOCATION_ACTION, *PIO_ALLOCATION_ACTION; typedef IO_ALLOCATION_ACTION -(DDKAPI *PDRIVER_CONTROL)( +(NTAPI DRIVER_CONTROL)( IN struct _DEVICE_OBJECT *DeviceObject, IN struct _IRP *Irp, IN PVOID MapRegisterBase, IN PVOID Context); +typedef DRIVER_CONTROL *PDRIVER_CONTROL; typedef struct _WAIT_CONTEXT_BLOCK { KDEVICE_QUEUE_ENTRY WaitQueueEntry; @@ -3020,11 +3242,18 @@ typedef struct _IO_REMOVE_LOCK { typedef struct _IO_WORKITEM *PIO_WORKITEM; typedef VOID -(DDKAPI IO_WORKITEM_ROUTINE)( +(NTAPI IO_WORKITEM_ROUTINE)( IN PDEVICE_OBJECT DeviceObject, IN PVOID Context); typedef IO_WORKITEM_ROUTINE *PIO_WORKITEM_ROUTINE; +typedef VOID +(NTAPI IO_WORKITEM_ROUTINE_EX)( + IN PVOID IoObject, + IN PVOID Context OPTIONAL, + IN PIO_WORKITEM IoWorkItem); +typedef IO_WORKITEM_ROUTINE_EX *PIO_WORKITEM_ROUTINE_EX; + typedef struct _SHARE_ACCESS { ULONG OpenCount; ULONG Readers; @@ -3157,13 +3386,13 @@ typedef struct _PCI_SLOT_NUMBER { } PCI_SLOT_NUMBER, *PPCI_SLOT_NUMBER; typedef VOID -(DDKAPI *PIO_APC_ROUTINE)( +(NTAPI *PIO_APC_ROUTINE)( IN PVOID ApcContext, IN PIO_STATUS_BLOCK IoStatusBlock, IN ULONG Reserved); typedef VOID -(DDKAPI *WMI_NOTIFICATION_CALLBACK)( +(NTAPI *WMI_NOTIFICATION_CALLBACK)( PVOID Wnode, PVOID Context); @@ -3208,6 +3437,39 @@ typedef struct _BOOTDISK_INFORMATION_EX { BOOLEAN SystemDeviceIsGpt; } BOOTDISK_INFORMATION_EX, *PBOOTDISK_INFORMATION_EX; +#if (NTDDI_VERSION >= NTDDI_WIN7) + +typedef struct _LOADER_PARTITION_INFORMATION_EX { + ULONG PartitionStyle; + ULONG PartitionNumber; + union { + ULONG Signature; + GUID DeviceId; + }; + ULONG Flags; +} LOADER_PARTITION_INFORMATION_EX, *PLOADER_PARTITION_INFORMATION_EX; + +typedef struct _BOOTDISK_INFORMATION_LITE { + ULONG NumberEntries; + LOADER_PARTITION_INFORMATION_EX Entries[1]; +} BOOTDISK_INFORMATION_LITE, *PBOOTDISK_INFORMATION_LITE; + +#else + +#if (NTDDI_VERSION >= NTDDI_VISTA) +typedef struct _BOOTDISK_INFORMATION_LITE { + ULONG BootDeviceSignature; + ULONG SystemDeviceSignature; + GUID BootDeviceGuid; + GUID SystemDeviceGuid; + BOOLEAN BootDeviceIsGpt; + BOOLEAN SystemDeviceIsGpt; +} BOOTDISK_INFORMATION_LITE, *PBOOTDISK_INFORMATION_LITE; +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + + typedef struct _EISA_MEMORY_TYPE { UCHAR ReadWrite : 1; UCHAR Cached : 1; @@ -3328,34 +3590,37 @@ typedef struct _CM_EISA_SLOT_INFORMATION { */ typedef VOID -(DDKAPI *PINTERFACE_REFERENCE)( +(NTAPI *PINTERFACE_REFERENCE)( PVOID Context); typedef VOID -(DDKAPI *PINTERFACE_DEREFERENCE)( +(NTAPI *PINTERFACE_DEREFERENCE)( PVOID Context); typedef BOOLEAN -(DDKAPI *PTRANSLATE_BUS_ADDRESS)( +(NTAPI TRANSLATE_BUS_ADDRESS)( IN PVOID Context, IN PHYSICAL_ADDRESS BusAddress, IN ULONG Length, IN OUT PULONG AddressSpace, OUT PPHYSICAL_ADDRESS TranslatedAddress); +typedef TRANSLATE_BUS_ADDRESS *PTRANSLATE_BUS_ADDRESS; typedef struct _DMA_ADAPTER* -(DDKAPI *PGET_DMA_ADAPTER)( +(NTAPI GET_DMA_ADAPTER)( IN PVOID Context, IN struct _DEVICE_DESCRIPTION *DeviceDescriptor, OUT PULONG NumberOfMapRegisters); +typedef GET_DMA_ADAPTER *PGET_DMA_ADAPTER; typedef ULONG -(DDKAPI *PGET_SET_DEVICE_DATA)( +(NTAPI GET_SET_DEVICE_DATA)( IN PVOID Context, IN ULONG DataType, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length); +typedef GET_SET_DEVICE_DATA *PGET_SET_DEVICE_DATA; /* PCI_DEVICE_PRESENCE_PARAMETERS.Flags */ #define PCI_USE_SUBSYSTEM_IDS 0x00000001 @@ -3380,18 +3645,20 @@ typedef struct _PCI_DEVICE_PRESENCE_PARAMETERS { } PCI_DEVICE_PRESENCE_PARAMETERS, *PPCI_DEVICE_PRESENCE_PARAMETERS; typedef BOOLEAN -(DDKAPI *PPCI_IS_DEVICE_PRESENT)( +(NTAPI PCI_IS_DEVICE_PRESENT)( IN USHORT VendorID, IN USHORT DeviceID, IN UCHAR RevisionID, IN USHORT SubVendorID, IN USHORT SubSystemID, IN ULONG Flags); +typedef PCI_IS_DEVICE_PRESENT *PPCI_IS_DEVICE_PRESENT; typedef BOOLEAN -(DDKAPI *PPCI_IS_DEVICE_PRESENT_EX)( +(NTAPI PCI_IS_DEVICE_PRESENT_EX)( IN PVOID Context, IN PPCI_DEVICE_PRESENCE_PARAMETERS Parameters); +typedef PCI_IS_DEVICE_PRESENT_EX *PPCI_IS_DEVICE_PRESENT_EX; typedef struct _BUS_INTERFACE_STANDARD { USHORT Size; @@ -3722,13 +3989,15 @@ typedef enum _IO_NOTIFICATION_EVENT_CATEGORY { #define PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES 0x00000001 typedef NTSTATUS -(DDKAPI *PDRIVER_NOTIFICATION_CALLBACK_ROUTINE)( +(NTAPI DRIVER_NOTIFICATION_CALLBACK_ROUTINE)( IN PVOID NotificationStructure, IN PVOID Context); +typedef DRIVER_NOTIFICATION_CALLBACK_ROUTINE *PDRIVER_NOTIFICATION_CALLBACK_ROUTINE; typedef VOID -(DDKAPI *PDEVICE_CHANGE_COMPLETE_CALLBACK)( +(NTAPI DEVICE_CHANGE_COMPLETE_CALLBACK)( IN PVOID Context); +typedef DEVICE_CHANGE_COMPLETE_CALLBACK *PDEVICE_CHANGE_COMPLETE_CALLBACK; typedef enum _FILE_INFORMATION_CLASS { FileDirectoryInformation = 1, @@ -3892,7 +4161,7 @@ typedef struct _ERESOURCE #define RESOURCE_HASH_TABLE_SIZE 64 typedef BOOLEAN -(DDKAPI *PFAST_IO_CHECK_IF_POSSIBLE)( +(NTAPI FAST_IO_CHECK_IF_POSSIBLE)( IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, @@ -3901,9 +4170,10 @@ typedef BOOLEAN IN BOOLEAN CheckForReadOperation, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_CHECK_IF_POSSIBLE *PFAST_IO_CHECK_IF_POSSIBLE; typedef BOOLEAN -(DDKAPI *PFAST_IO_READ)( +(NTAPI FAST_IO_READ)( IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, @@ -3912,9 +4182,10 @@ typedef BOOLEAN OUT PVOID Buffer, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_READ *PFAST_IO_READ; typedef BOOLEAN -(DDKAPI *PFAST_IO_WRITE)( +(NTAPI FAST_IO_WRITE)( IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, @@ -3923,25 +4194,28 @@ typedef BOOLEAN IN PVOID Buffer, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_WRITE *PFAST_IO_WRITE; typedef BOOLEAN -(DDKAPI *PFAST_IO_QUERY_BASIC_INFO)( +(NTAPI FAST_IO_QUERY_BASIC_INFO)( IN struct _FILE_OBJECT *FileObject, IN BOOLEAN Wait, OUT PFILE_BASIC_INFORMATION Buffer, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_QUERY_BASIC_INFO *PFAST_IO_QUERY_BASIC_INFO; typedef BOOLEAN -(DDKAPI *PFAST_IO_QUERY_STANDARD_INFO)( +(NTAPI FAST_IO_QUERY_STANDARD_INFO)( IN struct _FILE_OBJECT *FileObject, IN BOOLEAN Wait, OUT PFILE_STANDARD_INFORMATION Buffer, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_QUERY_STANDARD_INFO *PFAST_IO_QUERY_STANDARD_INFO; typedef BOOLEAN -(DDKAPI *PFAST_IO_LOCK)( +(NTAPI FAST_IO_LOCK)( IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER FileOffset, IN PLARGE_INTEGER Length, @@ -3951,9 +4225,10 @@ typedef BOOLEAN BOOLEAN ExclusiveLock, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_LOCK *PFAST_IO_LOCK; typedef BOOLEAN -(DDKAPI *PFAST_IO_UNLOCK_SINGLE)( +(NTAPI FAST_IO_UNLOCK_SINGLE)( IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER FileOffset, IN PLARGE_INTEGER Length, @@ -3961,24 +4236,27 @@ typedef BOOLEAN ULONG Key, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_UNLOCK_SINGLE *PFAST_IO_UNLOCK_SINGLE; typedef BOOLEAN -(DDKAPI *PFAST_IO_UNLOCK_ALL)( +(NTAPI FAST_IO_UNLOCK_ALL)( IN struct _FILE_OBJECT *FileObject, PEPROCESS ProcessId, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_UNLOCK_ALL *PFAST_IO_UNLOCK_ALL; typedef BOOLEAN -(DDKAPI *PFAST_IO_UNLOCK_ALL_BY_KEY)( +(NTAPI FAST_IO_UNLOCK_ALL_BY_KEY)( IN struct _FILE_OBJECT *FileObject, PVOID ProcessId, ULONG Key, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_UNLOCK_ALL_BY_KEY *PFAST_IO_UNLOCK_ALL_BY_KEY; typedef BOOLEAN -(DDKAPI *PFAST_IO_DEVICE_CONTROL)( +(NTAPI FAST_IO_DEVICE_CONTROL)( IN struct _FILE_OBJECT *FileObject, IN BOOLEAN Wait, IN PVOID InputBuffer OPTIONAL, @@ -3988,37 +4266,43 @@ typedef BOOLEAN IN ULONG IoControlCode, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_DEVICE_CONTROL *PFAST_IO_DEVICE_CONTROL; typedef VOID -(DDKAPI *PFAST_IO_ACQUIRE_FILE)( +(NTAPI FAST_IO_ACQUIRE_FILE)( IN struct _FILE_OBJECT *FileObject); +typedef FAST_IO_ACQUIRE_FILE *PFAST_IO_ACQUIRE_FILE; typedef VOID -(DDKAPI *PFAST_IO_RELEASE_FILE)( +(NTAPI FAST_IO_RELEASE_FILE)( IN struct _FILE_OBJECT *FileObject); +typedef FAST_IO_RELEASE_FILE *PFAST_IO_RELEASE_FILE; typedef VOID -(DDKAPI *PFAST_IO_DETACH_DEVICE)( +(NTAPI FAST_IO_DETACH_DEVICE)( IN struct _DEVICE_OBJECT *SourceDevice, IN struct _DEVICE_OBJECT *TargetDevice); +typedef FAST_IO_DETACH_DEVICE *PFAST_IO_DETACH_DEVICE; typedef BOOLEAN -(DDKAPI *PFAST_IO_QUERY_NETWORK_OPEN_INFO)( +(NTAPI FAST_IO_QUERY_NETWORK_OPEN_INFO)( IN struct _FILE_OBJECT *FileObject, IN BOOLEAN Wait, OUT struct _FILE_NETWORK_OPEN_INFORMATION *Buffer, OUT struct _IO_STATUS_BLOCK *IoStatus, IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_QUERY_NETWORK_OPEN_INFO *PFAST_IO_QUERY_NETWORK_OPEN_INFO; typedef NTSTATUS -(DDKAPI *PFAST_IO_ACQUIRE_FOR_MOD_WRITE)( +(NTAPI FAST_IO_ACQUIRE_FOR_MOD_WRITE)( IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER EndingOffset, OUT struct _ERESOURCE **ResourceToRelease, IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_ACQUIRE_FOR_MOD_WRITE *PFAST_IO_ACQUIRE_FOR_MOD_WRITE; typedef BOOLEAN -(DDKAPI *PFAST_IO_MDL_READ)( +(NTAPI FAST_IO_MDL_READ)( IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, @@ -4026,15 +4310,17 @@ typedef BOOLEAN OUT PMDL *MdlChain, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_MDL_READ *PFAST_IO_MDL_READ; typedef BOOLEAN -(DDKAPI *PFAST_IO_MDL_READ_COMPLETE)( +(NTAPI FAST_IO_MDL_READ_COMPLETE)( IN struct _FILE_OBJECT *FileObject, IN PMDL MdlChain, IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_MDL_READ_COMPLETE *PFAST_IO_MDL_READ_COMPLETE; typedef BOOLEAN -(DDKAPI *PFAST_IO_PREPARE_MDL_WRITE)( +(NTAPI FAST_IO_PREPARE_MDL_WRITE)( IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, @@ -4042,16 +4328,18 @@ typedef BOOLEAN OUT PMDL *MdlChain, OUT PIO_STATUS_BLOCK IoStatus, IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_PREPARE_MDL_WRITE *PFAST_IO_PREPARE_MDL_WRITE; typedef BOOLEAN -(DDKAPI *PFAST_IO_MDL_WRITE_COMPLETE)( +(NTAPI FAST_IO_MDL_WRITE_COMPLETE)( IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER FileOffset, IN PMDL MdlChain, IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_MDL_WRITE_COMPLETE *PFAST_IO_MDL_WRITE_COMPLETE; typedef BOOLEAN -(DDKAPI *PFAST_IO_READ_COMPRESSED)( +(NTAPI FAST_IO_READ_COMPRESSED)( IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, @@ -4062,9 +4350,10 @@ typedef BOOLEAN OUT struct _COMPRESSED_DATA_INFO *CompressedDataInfo, IN ULONG CompressedDataInfoLength, IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_READ_COMPRESSED *PFAST_IO_READ_COMPRESSED; typedef BOOLEAN -(DDKAPI *PFAST_IO_WRITE_COMPRESSED)( +(NTAPI FAST_IO_WRITE_COMPRESSED)( IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, @@ -4075,41 +4364,48 @@ typedef BOOLEAN IN struct _COMPRESSED_DATA_INFO *CompressedDataInfo, IN ULONG CompressedDataInfoLength, IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_WRITE_COMPRESSED *PFAST_IO_WRITE_COMPRESSED; typedef BOOLEAN -(DDKAPI *PFAST_IO_MDL_READ_COMPLETE_COMPRESSED)( +(NTAPI FAST_IO_MDL_READ_COMPLETE_COMPRESSED)( IN struct _FILE_OBJECT *FileObject, IN PMDL MdlChain, IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_MDL_READ_COMPLETE_COMPRESSED *PFAST_IO_MDL_READ_COMPLETE_COMPRESSED; typedef BOOLEAN -(DDKAPI *PFAST_IO_MDL_WRITE_COMPLETE_COMPRESSED)( +(NTAPI FAST_IO_MDL_WRITE_COMPLETE_COMPRESSED)( IN struct _FILE_OBJECT *FileObject, IN PLARGE_INTEGER FileOffset, IN PMDL MdlChain, IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_MDL_WRITE_COMPLETE_COMPRESSED *PFAST_IO_MDL_WRITE_COMPLETE_COMPRESSED; typedef BOOLEAN -(DDKAPI *PFAST_IO_QUERY_OPEN)( +(NTAPI FAST_IO_QUERY_OPEN)( IN struct _IRP *Irp, OUT PFILE_NETWORK_OPEN_INFORMATION NetworkInformation, IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_QUERY_OPEN *PFAST_IO_QUERY_OPEN; typedef NTSTATUS -(DDKAPI *PFAST_IO_RELEASE_FOR_MOD_WRITE)( +(NTAPI FAST_IO_RELEASE_FOR_MOD_WRITE)( IN struct _FILE_OBJECT *FileObject, IN struct _ERESOURCE *ResourceToRelease, IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_RELEASE_FOR_MOD_WRITE *PFAST_IO_RELEASE_FOR_MOD_WRITE; typedef NTSTATUS -(DDKAPI *PFAST_IO_ACQUIRE_FOR_CCFLUSH)( +(NTAPI FAST_IO_ACQUIRE_FOR_CCFLUSH)( IN struct _FILE_OBJECT *FileObject, IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_ACQUIRE_FOR_CCFLUSH *PFAST_IO_ACQUIRE_FOR_CCFLUSH; typedef NTSTATUS -(DDKAPI *PFAST_IO_RELEASE_FOR_CCFLUSH) ( +(NTAPI FAST_IO_RELEASE_FOR_CCFLUSH)( IN struct _FILE_OBJECT *FileObject, IN struct _DEVICE_OBJECT *DeviceObject); +typedef FAST_IO_RELEASE_FOR_CCFLUSH *PFAST_IO_RELEASE_FOR_CCFLUSH; typedef struct _FAST_IO_DISPATCH { ULONG SizeOfFastIoDispatch; @@ -4183,6 +4479,7 @@ typedef struct _IO_COMPLETION_CONTEXT { #define FO_SKIP_COMPLETION_PORT 0x02000000 #define FO_SKIP_SET_EVENT 0x04000000 #define FO_SKIP_SET_FAST_IO 0x08000000 +#define FO_FLAGS_VALID_ONLY_DURING_CREATE FO_DISALLOW_EXCLUSIVE /* VPB.Flags */ #define VPB_MOUNTED 0x0001 @@ -4197,12 +4494,18 @@ typedef struct _IO_COMPLETION_CONTEXT { #define SL_FORCE_ACCESS_CHECK 0x01 #define SL_OPEN_PAGING_FILE 0x02 #define SL_OPEN_TARGET_DIRECTORY 0x04 +#define SL_STOP_ON_SYMLINK 0x08 #define SL_CASE_SENSITIVE 0x80 #define SL_KEY_SPECIFIED 0x01 #define SL_OVERRIDE_VERIFY_VOLUME 0x02 #define SL_WRITE_THROUGH 0x04 #define SL_FT_SEQUENTIAL_WRITE 0x08 +#define SL_FORCE_DIRECT_WRITE 0x10 +#define SL_REALTIME_STREAM 0x20 + +#define SL_READ_ACCESS_GRANTED 0x01 +#define SL_WRITE_ACCESS_GRANTED 0x04 #define SL_FAIL_IMMEDIATELY 0x01 #define SL_EXCLUSIVE_LOCK 0x02 @@ -4220,6 +4523,8 @@ typedef struct _IO_COMPLETION_CONTEXT { #define DEVICE_TYPE_FROM_CTL_CODE(ctl) (((ULONG) (ctl & 0xffff0000)) >> 16) +#define METHOD_FROM_CTL_CODE(ctrlCode) ((ULONG)(ctrlCode & 3)) + #define IRP_NOCACHE 0x00000001 #define IRP_PAGING_IO 0x00000002 #define IRP_MOUNT_COMPLETION 0x00000002 @@ -4305,6 +4610,9 @@ typedef struct _IO_COMPLETION_CONTEXT { #define IRP_MN_QUERY_BUS_INFORMATION 0x15 #define IRP_MN_DEVICE_USAGE_NOTIFICATION 0x16 #define IRP_MN_SURPRISE_REMOVAL 0x17 +#if (NTDDI_VERSION >= NTDDI_WIN7) +#define IRP_MN_DEVICE_ENUMERATED 0x19 +#endif #define IRP_MN_WAIT_WAKE 0x00 #define IRP_MN_POWER_SEQUENCE 0x01 @@ -4324,8 +4632,7 @@ typedef struct _IO_COMPLETION_CONTEXT { #define IRP_MN_REGINFO_EX 0x0b -typedef struct _FILE_OBJECT -{ +typedef struct _FILE_OBJECT { CSHORT Type; CSHORT Size; PDEVICE_OBJECT DeviceObject; @@ -4452,8 +4759,7 @@ typedef struct _DEVICE_RELATIONS { PDEVICE_OBJECT Objects[1]; } DEVICE_RELATIONS, *PDEVICE_RELATIONS; -typedef struct _DEVOBJ_EXTENSION -{ +typedef struct _DEVOBJ_EXTENSION { CSHORT Type; USHORT Size; PDEVICE_OBJECT DeviceObject; @@ -4491,7 +4797,7 @@ typedef struct _SCATTER_GATHER_LIST SCATTER_GATHER_LIST, *PSCATTER_GATHER_LIST; #endif typedef NTSTATUS -(DDKAPI DRIVER_ADD_DEVICE)( +(NTAPI DRIVER_ADD_DEVICE)( IN struct _DRIVER_OBJECT *DriverObject, IN struct _DEVICE_OBJECT *PhysicalDeviceObject); typedef DRIVER_ADD_DEVICE *PDRIVER_ADD_DEVICE; @@ -4508,24 +4814,24 @@ typedef struct _DRIVER_EXTENSION { #define DRVO_BUILTIN_DRIVER 0x00000004 typedef NTSTATUS -(DDKAPI DRIVER_INITIALIZE)( +(NTAPI DRIVER_INITIALIZE)( IN struct _DRIVER_OBJECT *DriverObject, IN PUNICODE_STRING RegistryPath); typedef DRIVER_INITIALIZE *PDRIVER_INITIALIZE; typedef VOID -(DDKAPI DRIVER_STARTIO)( +(NTAPI DRIVER_STARTIO)( IN struct _DEVICE_OBJECT *DeviceObject, IN struct _IRP *Irp); typedef DRIVER_STARTIO *PDRIVER_STARTIO; typedef VOID -(DDKAPI DRIVER_UNLOAD)( +(NTAPI DRIVER_UNLOAD)( IN struct _DRIVER_OBJECT *DriverObject); typedef DRIVER_UNLOAD *PDRIVER_UNLOAD; typedef NTSTATUS -(DDKAPI DRIVER_DISPATCH)( +(NTAPI DRIVER_DISPATCH)( IN struct _DEVICE_OBJECT *DeviceObject, IN struct _IRP *Irp); typedef DRIVER_DISPATCH *PDRIVER_DISPATCH; @@ -4546,8 +4852,7 @@ typedef struct _DRIVER_OBJECT { PDRIVER_STARTIO DriverStartIo; PDRIVER_UNLOAD DriverUnload; PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION + 1]; -} DRIVER_OBJECT; -typedef struct _DRIVER_OBJECT *PDRIVER_OBJECT; +} DRIVER_OBJECT, *PDRIVER_OBJECT; typedef struct _DMA_ADAPTER { USHORT Version; @@ -4556,18 +4861,18 @@ typedef struct _DMA_ADAPTER { } DMA_ADAPTER, *PDMA_ADAPTER; typedef VOID -(DDKAPI *PPUT_DMA_ADAPTER)( +(NTAPI *PPUT_DMA_ADAPTER)( IN PDMA_ADAPTER DmaAdapter); typedef PVOID -(DDKAPI *PALLOCATE_COMMON_BUFFER)( +(NTAPI *PALLOCATE_COMMON_BUFFER)( IN PDMA_ADAPTER DmaAdapter, IN ULONG Length, OUT PPHYSICAL_ADDRESS LogicalAddress, IN BOOLEAN CacheEnabled); typedef VOID -(DDKAPI *PFREE_COMMON_BUFFER)( +(NTAPI *PFREE_COMMON_BUFFER)( IN PDMA_ADAPTER DmaAdapter, IN ULONG Length, IN PHYSICAL_ADDRESS LogicalAddress, @@ -4575,7 +4880,7 @@ typedef VOID IN BOOLEAN CacheEnabled); typedef NTSTATUS -(DDKAPI *PALLOCATE_ADAPTER_CHANNEL)( +(NTAPI *PALLOCATE_ADAPTER_CHANNEL)( IN PDMA_ADAPTER DmaAdapter, IN PDEVICE_OBJECT DeviceObject, IN ULONG NumberOfMapRegisters, @@ -4583,7 +4888,7 @@ typedef NTSTATUS IN PVOID Context); typedef BOOLEAN -(DDKAPI *PFLUSH_ADAPTER_BUFFERS)( +(NTAPI *PFLUSH_ADAPTER_BUFFERS)( IN PDMA_ADAPTER DmaAdapter, IN PMDL Mdl, IN PVOID MapRegisterBase, @@ -4592,17 +4897,17 @@ typedef BOOLEAN IN BOOLEAN WriteToDevice); typedef VOID -(DDKAPI *PFREE_ADAPTER_CHANNEL)( +(NTAPI *PFREE_ADAPTER_CHANNEL)( IN PDMA_ADAPTER DmaAdapter); typedef VOID -(DDKAPI *PFREE_MAP_REGISTERS)( +(NTAPI *PFREE_MAP_REGISTERS)( IN PDMA_ADAPTER DmaAdapter, PVOID MapRegisterBase, ULONG NumberOfMapRegisters); typedef PHYSICAL_ADDRESS -(DDKAPI *PMAP_TRANSFER)( +(NTAPI *PMAP_TRANSFER)( IN PDMA_ADAPTER DmaAdapter, IN PMDL Mdl, IN PVOID MapRegisterBase, @@ -4611,22 +4916,23 @@ typedef PHYSICAL_ADDRESS IN BOOLEAN WriteToDevice); typedef ULONG -(DDKAPI *PGET_DMA_ALIGNMENT)( +(NTAPI *PGET_DMA_ALIGNMENT)( IN PDMA_ADAPTER DmaAdapter); typedef ULONG -(DDKAPI *PREAD_DMA_COUNTER)( +(NTAPI *PREAD_DMA_COUNTER)( IN PDMA_ADAPTER DmaAdapter); typedef VOID -(DDKAPI *PDRIVER_LIST_CONTROL)( +(NTAPI DRIVER_LIST_CONTROL)( IN struct _DEVICE_OBJECT *DeviceObject, IN struct _IRP *Irp, IN struct _SCATTER_GATHER_LIST *ScatterGather, IN PVOID Context); +typedef DRIVER_LIST_CONTROL *PDRIVER_LIST_CONTROL; typedef NTSTATUS -(DDKAPI *PGET_SCATTER_GATHER_LIST)( +(NTAPI *PGET_SCATTER_GATHER_LIST)( IN PDMA_ADAPTER DmaAdapter, IN PDEVICE_OBJECT DeviceObject, IN PMDL Mdl, @@ -4637,13 +4943,13 @@ typedef NTSTATUS IN BOOLEAN WriteToDevice); typedef VOID -(DDKAPI *PPUT_SCATTER_GATHER_LIST)( +(NTAPI *PPUT_SCATTER_GATHER_LIST)( IN PDMA_ADAPTER DmaAdapter, IN PSCATTER_GATHER_LIST ScatterGather, IN BOOLEAN WriteToDevice); typedef NTSTATUS -(DDKAPI *PCALCULATE_SCATTER_GATHER_LIST_SIZE)( +(NTAPI *PCALCULATE_SCATTER_GATHER_LIST_SIZE)( IN PDMA_ADAPTER DmaAdapter, IN PMDL Mdl OPTIONAL, IN PVOID CurrentVa, @@ -4652,7 +4958,7 @@ typedef NTSTATUS OUT PULONG pNumberOfMapRegisters OPTIONAL); typedef NTSTATUS -(DDKAPI *PBUILD_SCATTER_GATHER_LIST)( +(NTAPI *PBUILD_SCATTER_GATHER_LIST)( IN PDMA_ADAPTER DmaAdapter, IN PDEVICE_OBJECT DeviceObject, IN PMDL Mdl, @@ -4665,7 +4971,7 @@ typedef NTSTATUS IN ULONG ScatterGatherLength); typedef NTSTATUS -(DDKAPI *PBUILD_MDL_FROM_SCATTER_GATHER_LIST)( +(NTAPI *PBUILD_MDL_FROM_SCATTER_GATHER_LIST)( IN PDMA_ADAPTER DmaAdapter, IN PSCATTER_GATHER_LIST ScatterGather, IN PMDL OriginalMdl, @@ -4759,7 +5065,7 @@ typedef struct _IO_RESOURCE_REQUIREMENTS_LIST { } IO_RESOURCE_REQUIREMENTS_LIST, *PIO_RESOURCE_REQUIREMENTS_LIST; typedef VOID -(DDKAPI DRIVER_CANCEL)( +(NTAPI DRIVER_CANCEL)( IN struct _DEVICE_OBJECT *DeviceObject, IN struct _IRP *Irp); typedef DRIVER_CANCEL *PDRIVER_CANCEL; @@ -4820,8 +5126,7 @@ typedef struct _IRP { KAPC Apc; PVOID CompletionKey; } Tail; -} IRP; -typedef struct _IRP *PIRP; +} IRP, *PIRP; typedef enum _IO_PAGING_PRIORITY { IoPagingPriorityInvalid, @@ -4832,37 +5137,39 @@ typedef enum _IO_PAGING_PRIORITY { } IO_PAGING_PRIORITY; typedef NTSTATUS -(DDKAPI IO_COMPLETION_ROUTINE)( +(NTAPI IO_COMPLETION_ROUTINE)( IN struct _DEVICE_OBJECT *DeviceObject, IN struct _IRP *Irp, IN PVOID Context); typedef IO_COMPLETION_ROUTINE *PIO_COMPLETION_ROUTINE; typedef VOID -(DDKAPI *PIO_DPC_ROUTINE)( +(NTAPI IO_DPC_ROUTINE)( IN struct _KDPC *Dpc, IN struct _DEVICE_OBJECT *DeviceObject, IN struct _IRP *Irp, IN PVOID Context); +typedef IO_DPC_ROUTINE *PIO_DPC_ROUTINE; typedef NTSTATUS -(DDKAPI *PMM_DLL_INITIALIZE)( +(NTAPI *PMM_DLL_INITIALIZE)( IN PUNICODE_STRING RegistryPath); typedef NTSTATUS -(DDKAPI *PMM_DLL_UNLOAD)( +(NTAPI *PMM_DLL_UNLOAD)( VOID); typedef BOOLEAN -(DDKAPI KSERVICE_ROUTINE)( +(NTAPI KSERVICE_ROUTINE)( IN struct _KINTERRUPT *Interrupt, IN PVOID ServiceContext); typedef KSERVICE_ROUTINE *PKSERVICE_ROUTINE; typedef VOID -(DDKAPI *PIO_TIMER_ROUTINE)( +(NTAPI IO_TIMER_ROUTINE)( IN struct _DEVICE_OBJECT *DeviceObject, IN PVOID Context); +typedef IO_TIMER_ROUTINE *PIO_TIMER_ROUTINE; typedef struct _IO_SECURITY_CONTEXT { PSECURITY_QUALITY_OF_SERVICE SecurityQos; @@ -4880,33 +5187,33 @@ typedef struct _IO_CSQ_IRP_CONTEXT { } IO_CSQ_IRP_CONTEXT, *PIO_CSQ_IRP_CONTEXT; typedef VOID -(DDKAPI *PIO_CSQ_INSERT_IRP)( +(NTAPI *PIO_CSQ_INSERT_IRP)( IN struct _IO_CSQ *Csq, IN PIRP Irp); typedef VOID -(DDKAPI *PIO_CSQ_REMOVE_IRP)( +(NTAPI *PIO_CSQ_REMOVE_IRP)( IN struct _IO_CSQ *Csq, IN PIRP Irp); typedef PIRP -(DDKAPI *PIO_CSQ_PEEK_NEXT_IRP)( +(NTAPI *PIO_CSQ_PEEK_NEXT_IRP)( IN struct _IO_CSQ *Csq, IN PIRP Irp, IN PVOID PeekContext); typedef VOID -(DDKAPI *PIO_CSQ_ACQUIRE_LOCK)( +(NTAPI *PIO_CSQ_ACQUIRE_LOCK)( IN struct _IO_CSQ *Csq, OUT PKIRQL Irql); typedef VOID -(DDKAPI *PIO_CSQ_RELEASE_LOCK)( +(NTAPI *PIO_CSQ_RELEASE_LOCK)( IN struct _IO_CSQ *Csq, IN KIRQL Irql); typedef VOID -(DDKAPI *PIO_CSQ_COMPLETE_CANCELED_IRP)( +(NTAPI *PIO_CSQ_COMPLETE_CANCELED_IRP)( IN struct _IO_CSQ *Csq, IN PIRP Irp); @@ -5149,6 +5456,8 @@ typedef struct _IO_STACK_LOCATION { #define METHOD_OUT_DIRECT 2 #define METHOD_NEITHER 3 +#define METHOD_DIRECT_TO_HARDWARE METHOD_IN_DIRECT +#define METHOD_DIRECT_FROM_HARDWARE METHOD_OUT_DIRECT #define FILE_SUPERSEDED 0x00000000 #define FILE_OPENED 0x00000001 @@ -5195,6 +5504,7 @@ typedef struct _IO_STACK_LOCATION { #define FILE_ATTRIBUTE_OFFLINE 0x00001000 #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000 #define FILE_ATTRIBUTE_ENCRYPTED 0x00004000 +#define FILE_ATTRIBUTE_VIRTUAL 0x00010000 #define FILE_ATTRIBUTE_VALID_FLAGS 0x00007fb7 #define FILE_ATTRIBUTE_VALID_SET_FLAGS 0x000031a7 @@ -5228,6 +5538,10 @@ typedef struct _IO_STACK_LOCATION { #define FILE_OPEN_BY_FILE_ID 0x00002000 #define FILE_OPEN_FOR_BACKUP_INTENT 0x00004000 #define FILE_NO_COMPRESSION 0x00008000 +#if (NTDDI_VERSION >= NTDDI_WIN7) +#define FILE_OPEN_REQUIRING_OPLOCK 0x00010000 +#define FILE_DISALLOW_EXCLUSIVE 0x00020000 +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ #define FILE_RESERVE_OPFILTER 0x00100000 #define FILE_OPEN_REPARSE_POINT 0x00200000 #define FILE_OPEN_NO_RECALL 0x00400000 @@ -5275,6 +5589,7 @@ typedef struct _OBJECT_NAME_INFORMATION { } OBJECT_NAME_INFORMATION, *POBJECT_NAME_INFORMATION; /* Exported object types */ +extern POBJECT_TYPE NTSYSAPI CmKeyObjectType; extern POBJECT_TYPE NTSYSAPI ExEventObjectType; extern POBJECT_TYPE NTSYSAPI ExSemaphoreObjectType; extern POBJECT_TYPE NTSYSAPI IoFileObjectType; @@ -5353,7 +5668,7 @@ typedef struct _QUOTA_LIMITS { #define IPI_LEVEL 29 #define POWER_LEVEL 30 #define HIGH_LEVEL 31 -#define CLOCK_LEVEL (CLOCK2_LEVEL) +#define CLOCK_LEVEL CLOCK2_LEVEL #define KIP0PCRADDRESS 0xffdff000 #define KI_USER_SHARED_DATA 0xffdf0000 @@ -5389,8 +5704,7 @@ extern NTKERNELAPI volatile KSYSTEM_TIME KeTickCount; FORCEINLINE VOID -KeMemoryBarrier( - VOID) +KeMemoryBarrier(VOID) { volatile LONG Barrier; #if defined(__GNUC__) @@ -5400,6 +5714,11 @@ KeMemoryBarrier( #endif } +NTHALAPI +KIRQL +NTAPI +KeGetCurrentIrql(VOID); + NTHALAPI VOID FASTCALL @@ -5416,28 +5735,26 @@ KfRaiseIrql( NTHALAPI KIRQL -DDKAPI -KeRaiseIrqlToDpcLevel( - VOID); +NTAPI +KeRaiseIrqlToDpcLevel(VOID); NTHALAPI KIRQL -DDKAPI -KeRaiseIrqlToSynchLevel( - VOID); +NTAPI +KeRaiseIrqlToSynchLevel(VOID); NTHALAPI KIRQL FASTCALL KfAcquireSpinLock( - IN PKSPIN_LOCK SpinLock); + IN OUT PKSPIN_LOCK SpinLock); #define KeAcquireSpinLock(a,b) *(b) = KfAcquireSpinLock(a) NTHALAPI VOID FASTCALL KfReleaseSpinLock( - IN PKSPIN_LOCK SpinLock, + IN OUT PKSPIN_LOCK SpinLock, IN KIRQL NewIrql); #define KeReleaseSpinLock(a,b) KfReleaseSpinLock(a,b) @@ -5445,21 +5762,20 @@ NTKERNELAPI VOID FASTCALL KefAcquireSpinLockAtDpcLevel( - IN PKSPIN_LOCK SpinLock); + IN OUT PKSPIN_LOCK SpinLock); #define KeAcquireSpinLockAtDpcLevel(SpinLock) KefAcquireSpinLockAtDpcLevel(SpinLock) NTKERNELAPI VOID FASTCALL KefReleaseSpinLockFromDpcLevel( - IN PKSPIN_LOCK SpinLock); + IN OUT PKSPIN_LOCK SpinLock); #define KeReleaseSpinLockFromDpcLevel(SpinLock) KefReleaseSpinLockFromDpcLevel(SpinLock) NTSYSAPI PKTHREAD NTAPI -KeGetCurrentThread( - VOID); +KeGetCurrentThread(VOID); NTKERNELAPI NTSTATUS @@ -5489,8 +5805,7 @@ VOID _KeQueryTickCount( OUT PLARGE_INTEGER CurrentCount) { - for (;;) - { + for (;;) { CurrentCount->HighPart = KeTickCount.High1Time; CurrentCount->LowPart = KeTickCount.LowPart; if (CurrentCount->HighPart == KeTickCount.High2Time) break; @@ -5503,9 +5818,6 @@ _KeQueryTickCount( -/****************************************************************************** - * Runtime Library Functions * - ******************************************************************************/ FORCEINLINE VOID @@ -5725,8 +6037,10 @@ RtlStringFromGUID( #define RtlZeroBytes RtlZeroMemory - #if (NTDDI_VERSION >= NTDDI_WIN2K) + + + NTSYSAPI BOOLEAN NTAPI @@ -5829,7 +6143,7 @@ VOID NTAPI RtlCopyUnicodeString( IN OUT PUNICODE_STRING DestinationString, - IN PCUNICODE_STRING SourceString); + IN PCUNICODE_STRING SourceString OPTIONAL); NTSYSAPI NTSTATUS @@ -5875,7 +6189,7 @@ NTAPI RtlExtendedLargeIntegerDivide( IN LARGE_INTEGER Dividend, IN ULONG Divisor, - IN OUT PULONG Remainder); + OUT PULONG Remainder OPTIONAL); #endif #if defined(_X86_) || defined(_IA64_) @@ -6063,12 +6377,17 @@ NTAPI RtlQueryRegistryValues( IN ULONG RelativeTo, IN PCWSTR Path, - IN PRTL_QUERY_REGISTRY_TABLE QueryTable, - IN PVOID Context, + IN OUT PRTL_QUERY_REGISTRY_TABLE QueryTable, + IN PVOID Context OPTIONAL, IN PVOID Environment OPTIONAL); +#define SHORT_SIZE (sizeof(USHORT)) +#define SHORT_MASK (SHORT_SIZE - 1) #define LONG_SIZE (sizeof(LONG)) +#define LONGLONG_SIZE (sizeof(LONGLONG)) #define LONG_MASK (LONG_SIZE - 1) +#define LONGLONG_MASK (LONGLONG_SIZE - 1) +#define LOWBYTE_MASK 0x00FF /* VOID * RtlRetrieveUlong( @@ -6137,15 +6456,50 @@ RtlSetDaclSecurityDescriptor( IN PACL Dacl OPTIONAL, IN BOOLEAN DaclDefaulted OPTIONAL); +#if defined(_AMD64_) + /* VOID * RtlStoreUlong( * IN PULONG Address, * IN ULONG Value); */ -#if defined(_AMD64_) #define RtlStoreUlong(Address,Value) \ *(ULONG UNALIGNED *)(Address) = (Value) + +/* VOID + * RtlStoreUlonglong( + * IN OUT PULONGLONG Address, + * ULONGLONG Value); + */ +#define RtlStoreUlonglong(Address,Value) \ + *(ULONGLONG UNALIGNED *)(Address) = (Value) + +/* VOID + * RtlStoreUshort( + * IN PUSHORT Address, + * IN USHORT Value); + */ +#define RtlStoreUshort(Address,Value) \ + *(USHORT UNALIGNED *)(Address) = (Value) + +/* VOID + * RtlRetrieveUshort( + * PUSHORT DestinationAddress, + * PUSHORT SourceAddress); + */ +#define RtlRetrieveUshort(DestAddress,SrcAddress) \ + *(USHORT UNALIGNED *)(DestAddress) = *(USHORT)(SrcAddress) + +/* VOID + * RtlRetrieveUlong( + * PULONG DestinationAddress, + * PULONG SourceAddress); + */ +#define RtlRetrieveUlong(DestAddress,SrcAddress) \ + *(ULONG UNALIGNED *)(DestAddress) = *(PULONG)(SrcAddress) + #else + #define RtlStoreUlong(Address,Value) \ if ((ULONG_PTR)(Address) & LONG_MASK) { \ ((PUCHAR) (Address))[LONG_LEAST_SIGNIFICANT_BIT] = (UCHAR)(FIRSTBYTE(Value)); \ @@ -6301,7 +6655,9 @@ RtlWriteRegistryValue( IN PVOID ValueData, IN ULONG ValueLength); -#endif // (NTDDI_VERSION >= NTDDI_WIN2K) + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ + #if (NTDDI_VERSION >= NTDDI_WIN2KSP3) NTSYSAPI @@ -6312,7 +6668,11 @@ RtlPrefetchMemoryNonTemporal( IN SIZE_T Length); #endif + #if (NTDDI_VERSION >= NTDDI_WINXP) + + + NTSYSAPI VOID NTAPI @@ -6340,9 +6700,22 @@ RtlTestBit( IN PRTL_BITMAP BitMapHeader, IN ULONG BitNumber); -#endif // (NTDDI_VERSION >= NTDDI_WINXP) +NTSYSAPI +NTSTATUS +NTAPI +RtlHashUnicodeString( + IN CONST UNICODE_STRING *String, + IN BOOLEAN CaseInSensitive, + IN ULONG HashAlgorithm, + OUT PULONG HashValue); + + +#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ #if (NTDDI_VERSION >= NTDDI_VISTA) + + + NTSYSAPI ULONG NTAPI @@ -6383,7 +6756,51 @@ RtlFindClosestEncodableLength( IN ULONGLONG SourceLength, OUT PULONGLONG TargetLength); -#endif +NTSYSAPI +NTSTATUS +NTAPI +RtlCmEncodeMemIoResource( + IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor, + IN UCHAR Type, + IN ULONGLONG Length, + IN ULONGLONG Start); + + +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + +#if (NTDDI_VERSION >= NTDDI_WIN7) + + + +NTSYSAPI +NTSTATUS +NTAPI +RtlUnicodeToUTF8N( + OUT PCHAR UTF8StringDestination, + IN ULONG UTF8StringMaxByteCount, + OUT PULONG UTF8StringActualByteCount, + IN PCWCH UnicodeStringSource, + IN ULONG UnicodeStringByteCount); + +NTSYSAPI +NTSTATUS +NTAPI +RtlUTF8ToUnicodeN( + OUT PWSTR UnicodeStringDestination, + IN ULONG UnicodeStringMaxByteCount, + OUT PULONG UnicodeStringActualByteCount, + IN PCCH UTF8StringSource, + IN ULONG UTF8StringByteCount); + +NTSYSAPI +ULONG64 +NTAPI +RtlGetEnabledExtendedFeatures( + IN ULONG64 FeatureMask); + + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + #if !defined(MIDL_PASS) /* inline funftions */ @@ -6391,7 +6808,8 @@ RtlFindClosestEncodableLength( static __inline LARGE_INTEGER NTAPI_INLINE -RtlConvertLongToLargeInteger(LONG SignedInteger) +RtlConvertLongToLargeInteger( + IN LONG SignedInteger) { LARGE_INTEGER ret; ret.QuadPart = SignedInteger; @@ -6403,7 +6821,7 @@ static __inline LARGE_INTEGER NTAPI_INLINE RtlConvertUlongToLargeInteger( - ULONG UnsignedInteger) + IN ULONG UnsignedInteger) { LARGE_INTEGER ret; ret.QuadPart = UnsignedInteger; @@ -6452,7 +6870,8 @@ RtlEnlargedIntegerMultiply( FORCEINLINE VOID -RtlInitEmptyAnsiString(OUT PANSI_STRING AnsiString, +RtlInitEmptyAnsiString( + OUT PANSI_STRING AnsiString, IN PCHAR Buffer, IN USHORT BufferSize) { @@ -6474,12 +6893,14 @@ RtlInitEmptyUnicodeString( } #if defined(_AMD64_) || defined(_IA64_) + + static __inline LARGE_INTEGER NTAPI_INLINE RtlExtendedIntegerMultiply( - LARGE_INTEGER Multiplicand, - LONG Multiplier) + IN LARGE_INTEGER Multiplicand, + IN LONG Multiplier) { LARGE_INTEGER ret; ret.QuadPart = Multiplicand.QuadPart * Multiplier; @@ -6490,9 +6911,9 @@ static __inline LARGE_INTEGER NTAPI_INLINE RtlExtendedLargeIntegerDivide( - LARGE_INTEGER Dividend, - ULONG Divisor, - PULONG Remainder) + IN LARGE_INTEGER Dividend, + IN ULONG Divisor, + OUT PULONG Remainder OPTIONAL) { LARGE_INTEGER ret; ret.QuadPart = (ULONG64)Dividend.QuadPart / Divisor; @@ -6500,7 +6921,11 @@ RtlExtendedLargeIntegerDivide( *Remainder = (ULONG)(Dividend.QuadPart % Divisor); return ret; } -#endif + + + +#endif /* defined(_AMD64_) || defined(_IA64_) */ + #if defined(_AMD64_) @@ -6582,8 +7007,7 @@ RtlSecureZeroMemory( __stosb((PUCHAR)vptr, 0, Size); #else char * endptr = (char *)vptr + Size; - while (vptr < endptr) - { + while (vptr < endptr) { *vptr = 0; vptr++; } #endif @@ -6592,16 +7016,16 @@ RtlSecureZeroMemory( #if defined(_M_AMD64) FORCEINLINE -ULONG +BOOLEAN RtlCheckBit( IN PRTL_BITMAP BitMapHeader, IN ULONG BitPosition) { - return BitTest((LONG CONST*)BitMapHeader->Buffer, BitPosition); + return BitTest64((LONG64 CONST*)BitMapHeader->Buffer, (LONG64)BitPosition); } #else #define RtlCheckBit(BMH,BP) (((((PLONG)(BMH)->Buffer)[(BP)/32]) >> ((BP)%32)) & 0x1) -#endif // defined(_M_AMD64) +#endif /* defined(_M_AMD64) */ #define RtlLargeIntegerGreaterThan(X,Y) ( \ (((X).HighPart == (Y).HighPart) && ((X).LowPart > (Y).LowPart)) || \ @@ -6725,8 +7149,15 @@ RtlCheckBit( #define NT_ASSERTMSG(exp) ((VOID)0) #define NT_ASSERTMSGW(exp) ((VOID)0) +#define NT_VERIFY(_exp) ((_exp) ? TRUE : FALSE) +#define NT_VERIFYMSG(_msg, _exp ) ((_exp) ? TRUE : FALSE) +#define NT_VERIFYMSGW(_msg, _exp) ((_exp) ? TRUE : FALSE) + #endif /* DBG */ +#define InitializeListHead32(ListHead) (\ + (ListHead)->Flink = (ListHead)->Blink = PtrToUlong((ListHead))) + #if !defined(_WINBASE_) #if defined(_WIN64) && (defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_) || defined(_NTOSP_)) @@ -6748,18 +7179,14 @@ InitializeSListHead( #endif #if defined(_WIN64) - if (((ULONG_PTR)SListHead & 0xf) != 0) - { + if (((ULONG_PTR)SListHead & 0xf) != 0) { RtlRaiseStatus(STATUS_DATATYPE_MISALIGNMENT); } #endif - RtlZeroMemory(SListHead, sizeof(SLIST_HEADER)); - #if defined(_IA64_) FeatureBits = __getReg(CV_IA64_CPUID4); - if ((FeatureBits & KF_16BYTE_INSTR) != 0) - { + if ((FeatureBits & KF_16BYTE_INSTR) != 0) { SListHead->Header16.HeaderType = 1; SListHead->Header16.Init = 1; } @@ -6833,6 +7260,8 @@ KeClearEvent( #if (NTDDI_VERSION >= NTDDI_WIN2K) + +#if defined(_NTDDK_) || defined(_NTIFS_) NTKERNELAPI VOID NTAPI @@ -6840,6 +7269,7 @@ ProbeForRead( IN CONST VOID *Address, /* CONST is added */ IN SIZE_T Length, IN ULONG Alignment); +#endif /* defined(_NTDDK_) || defined(_NTIFS_) */ NTKERNELAPI VOID @@ -6849,7 +7279,9 @@ ProbeForWrite( IN SIZE_T Length, IN ULONG Alignment); + #if defined(SINGLE_GROUP_LEGACY_API) + NTKERNELAPI VOID NTAPI @@ -6871,16 +7303,16 @@ KeSetTargetProcessorDpc( NTKERNELAPI KAFFINITY NTAPI -KeQueryActiveProcessors( - VOID); -#endif +KeQueryActiveProcessors(VOID); + + +#endif /* defined(SINGLE_GROUP_LEGACY_API) */ #if !defined(_M_AMD64) NTKERNELAPI ULONGLONG NTAPI -KeQueryInterruptTime( - VOID); +KeQueryInterruptTime(VOID); NTKERNELAPI VOID @@ -6889,6 +7321,36 @@ KeQuerySystemTime( OUT PLARGE_INTEGER CurrentTime); #endif /* !_M_AMD64 */ +#if !defined(_X86_) +NTKERNELAPI +KIRQL +NTAPI +KeAcquireSpinLockRaiseToDpc( + IN OUT PKSPIN_LOCK SpinLock); + +#define KeAcquireSpinLock(SpinLock, OldIrql) \ + *(OldIrql) = KeAcquireSpinLockRaiseToDpc(SpinLock) + +NTKERNELAPI +VOID +NTAPI +KeAcquireSpinLockAtDpcLevel( + IN OUT PKSPIN_LOCK SpinLock); + +NTKERNELAPI +VOID +NTAPI +KeReleaseSpinLock( + IN OUT PKSPIN_LOCK SpinLock, + IN KIRQL NewIrql); + +NTKERNELAPI +VOID +NTAPI +KeReleaseSpinLockFromDpcLevel( + IN OUT PKSPIN_LOCK SpinLock); +#endif /* !_X86_ */ + #if defined(_X86_) && (defined(_WDM_INCLUDED_) || defined(WIN9X_COMPAT_SPINLOCK)) NTKERNELAPI VOID @@ -7026,8 +7488,7 @@ KeQueryPriorityThread( NTKERNELAPI ULONG NTAPI -KeQueryTimeIncrement( - VOID); +KeQueryTimeIncrement(VOID); NTKERNELAPI LONG @@ -7041,7 +7502,6 @@ NTAPI KeReadStateMutex( IN PRKMUTEX Mutex); - NTKERNELAPI LONG NTAPI @@ -7279,13 +7739,10 @@ KeRegisterBugCheckReasonCallback( #endif /* (NTDDI_VERSION >= NTDDI_WINXPSP1) */ #if (NTDDI_VERSION >= NTDDI_WINXPSP2) - NTKERNELAPI VOID NTAPI -KeFlushQueuedDpcs( - VOID); - +KeFlushQueuedDpcs(VOID); #endif /* (NTDDI_VERSION >= NTDDI_WINXPSP2) */ #if (NTDDI_VERSION >= NTDDI_WS03) @@ -7337,10 +7794,12 @@ FASTCALL KeTestSpinLock( IN PKSPIN_LOCK SpinLock); + #endif /* (NTDDI_VERSION >= NTDDI_WS03) */ #if (NTDDI_VERSION >= NTDDI_WS03SP1) + NTKERNELAPI BOOLEAN FASTCALL @@ -7350,64 +7809,53 @@ KeTryToAcquireSpinLockAtDpcLevel( NTKERNELAPI BOOLEAN NTAPI -KeAreAllApcsDisabled( - VOID); +KeAreAllApcsDisabled(VOID); NTKERNELAPI VOID FASTCALL KeAcquireGuardedMutex( - IN OUT PKGUARDED_MUTEX GuardedMutex -); + IN OUT PKGUARDED_MUTEX GuardedMutex); NTKERNELAPI VOID FASTCALL KeAcquireGuardedMutexUnsafe( - IN OUT PKGUARDED_MUTEX GuardedMutex -); + IN OUT PKGUARDED_MUTEX GuardedMutex); NTKERNELAPI VOID NTAPI -KeEnterGuardedRegion( - VOID -); +KeEnterGuardedRegion(VOID); NTKERNELAPI VOID NTAPI -KeLeaveGuardedRegion( - VOID -); +KeLeaveGuardedRegion(VOID); NTKERNELAPI VOID FASTCALL KeInitializeGuardedMutex( - OUT PKGUARDED_MUTEX GuardedMutex -); + OUT PKGUARDED_MUTEX GuardedMutex); NTKERNELAPI VOID FASTCALL KeReleaseGuardedMutexUnsafe( - IN OUT PKGUARDED_MUTEX GuardedMutex -); + IN OUT PKGUARDED_MUTEX GuardedMutex); NTKERNELAPI VOID FASTCALL KeReleaseGuardedMutex( - IN OUT PKGUARDED_MUTEX GuardedMutex -); + IN OUT PKGUARDED_MUTEX GuardedMutex); NTKERNELAPI BOOLEAN FASTCALL KeTryToAcquireGuardedMutex( - IN OUT PKGUARDED_MUTEX GuardedMutex -); + IN OUT PKGUARDED_MUTEX GuardedMutex); #endif /* (NTDDI_VERSION >= NTDDI_WS03SP1) */ @@ -7433,12 +7881,19 @@ KeQueryDpcWatchdogInformation( OUT PKDPC_WATCHDOG_INFORMATION WatchdogInformation); #if defined(SINGLE_GROUP_LEGACY_API) + NTKERNELAPI KAFFINITY NTAPI KeSetSystemAffinityThreadEx( IN KAFFINITY Affinity); +NTKERNELAPI +VOID +NTAPI +KeRevertToUserAffinityThreadEx( + IN KAFFINITY Affinity); + NTKERNELAPI ULONG NTAPI @@ -7448,9 +7903,8 @@ KeQueryActiveProcessorCount( NTKERNELAPI ULONG NTAPI -KeQueryMaximumProcessorCount( - VOID); -#endif +KeQueryMaximumProcessorCount(VOID); +#endif /* SINGLE_GROUP_LEGACY_API */ #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ @@ -7470,6 +7924,7 @@ KeDeregisterProcessorChangeCallback( #if (NTDDI_VERSION >= NTDDI_WIN7) + ULONG64 NTAPI KeQueryTotalCycleTimeProcess( @@ -7515,8 +7970,7 @@ KeSetCoalescableTimer( NTKERNELAPI ULONGLONG NTAPI -KeQueryUnbiasedInterruptTime( - VOID); +KeQueryUnbiasedInterruptTime(VOID); NTKERNELAPI ULONG @@ -7533,19 +7987,17 @@ KeQueryMaximumProcessorCountEx( NTKERNELAPI USHORT NTAPI -KeQueryActiveGroupCount( - VOID); +KeQueryActiveGroupCount(VOID); NTKERNELAPI USHORT NTAPI -KeQueryMaximumGroupCount( - VOID); +KeQueryMaximumGroupCount(VOID); NTKERNELAPI KAFFINITY NTAPI -KeQueryGroupAffinity +KeQueryGroupAffinity( IN USHORT GroupNumber); NTKERNELAPI @@ -7571,14 +8023,12 @@ KeQueryNodeMaximumProcessorCount( NTKERNELAPI USHORT NTAPI -KeQueryHighestNodeNumber( - VOID); +KeQueryHighestNodeNumber(VOID); NTKERNELAPI USHORT NTAPI -KeGetCurrentNodeNumber( - VOID); +KeGetCurrentNodeNumber(VOID); NTKERNELAPI NTSTATUS @@ -7602,6 +8052,17 @@ NTAPI KeRestoreExtendedProcessorState( IN PXSTATE_SAVE XStateSave); +NTSTATUS +NTAPI +KeGetProcessorNumberFromIndex( + IN ULONG ProcIndex, + OUT PPROCESSOR_NUMBER ProcNumber); + +ULONG +NTAPI +KeGetProcessorIndexFromNumber( + IN PPROCESSOR_NUMBER ProcNumber); + #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ #if !defined(_IA64_) @@ -7637,17 +8098,14 @@ KeFlushWriteBuffer(VOID); #define PAGED_CODE() -#endif +#endif /* DBG */ #define PAGED_CODE_LOCKED() NOP_FUNCTION; /****************************************************************************** * Memory manager Functions * ******************************************************************************/ - -/* - * Alignment Macros - */ +/* Alignment Macros */ #define ALIGN_DOWN_BY(size, align) \ ((ULONG_PTR)(size) & ~((ULONG_PTR)(align) - 1)) @@ -7709,6 +8167,9 @@ KeFlushWriteBuffer(VOID); ((ULONG) ((((ULONG_PTR) (_Va) & (PAGE_SIZE - 1)) \ + (_Size) + (PAGE_SIZE - 1)) >> PAGE_SHIFT)) +#define COMPUTE_PAGES_SPANNED(Va, Size) \ + ADDRESS_AND_SIZE_TO_SPAN_PAGES(Va,Size) + /* * ULONG * MmGetMdlByteCount( @@ -7725,6 +8186,8 @@ KeFlushWriteBuffer(VOID); #define MmGetMdlByteOffset(_Mdl) \ ((_Mdl)->ByteOffset) +#define MmGetMdlBaseVa(Mdl) ((Mdl)->StartVa) + /* * PPFN_NUMBER * MmGetMdlPfnArray( @@ -7923,8 +8386,7 @@ MmProbeAndLockPages( NTKERNELAPI MM_SYSTEMSIZE NTAPI -MmQuerySystemSize( - VOID); +MmQuerySystemSize(VOID); NTKERNELAPI VOID @@ -7974,7 +8436,9 @@ MmUnmapLockedPages( IN PVOID BaseAddress, IN PMDL MemoryDescriptorList); -#endif + + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ #if (NTDDI_VERSION >= NTDDI_WINXP) @@ -8044,6 +8508,15 @@ MmAllocatePagesForMdlEx( IN ULONG Flags); #endif +#if (NTDDI_VERSION >= NTDDI_VISTA) + +NTKERNELAPI +LOGICAL +NTAPI +MmIsDriverVerifyingByAddress( + IN PVOID AddressWithinSection); +#endif + /****************************************************************************** * Security Manager Functions * ******************************************************************************/ @@ -8176,7 +8649,6 @@ SeGetWorldRights( #endif /* SE_NTFS_WORLD_CACHE */ #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ - /****************************************************************************** * Configuration Manager Functions * ******************************************************************************/ @@ -8197,6 +8669,53 @@ CmUnRegisterCallback( IN LARGE_INTEGER Cookie); #endif +#if (NTDDI_VERSION >= NTDDI_VISTA) + +NTKERNELAPI +NTSTATUS +NTAPI +CmRegisterCallbackEx( + PEX_CALLBACK_FUNCTION Function, + PCUNICODE_STRING Altitude, + PVOID Driver, + PVOID Context, + PLARGE_INTEGER Cookie, + PVOID Reserved); + +NTKERNELAPI +VOID +NTAPI +CmGetCallbackVersion( + OUT PULONG Major OPTIONAL, + OUT PULONG Minor OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +CmSetCallbackObjectContext( + IN OUT PVOID Object, + IN PLARGE_INTEGER Cookie, + IN PVOID NewContext, + OUT PVOID *OldContext OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +CmCallbackGetKeyObjectID( + IN PLARGE_INTEGER Cookie, + IN PVOID Object, + OUT PULONG_PTR ObjectID OPTIONAL, + OUT PCUNICODE_STRING *ObjectName OPTIONAL); + +NTKERNELAPI +PVOID +NTAPI +CmGetBoundTransaction( + IN PLARGE_INTEGER Cookie, + IN PVOID Object); + +#endif // NTDDI_VERSION >= NTDDI_VISTA + /****************************************************************************** * I/O Manager Functions * @@ -8712,6 +9231,7 @@ IoMapTransfer( #endif #if (NTDDI_VERSION >= NTDDI_WIN2K) + NTKERNELAPI VOID NTAPI @@ -9050,8 +9570,7 @@ IoGetDeviceInterfaceAlias( NTKERNELAPI PEPROCESS NTAPI -IoGetCurrentProcess( - VOID); +IoGetCurrentProcess(VOID); NTKERNELAPI NTSTATUS @@ -9099,8 +9618,7 @@ IoGetDriverObjectExtension( NTKERNELAPI PVOID NTAPI -IoGetInitialStack( - VOID); +IoGetInitialStack(VOID); NTKERNELAPI PDEVICE_OBJECT @@ -9374,7 +9892,7 @@ NTKERNELAPI NTSTATUS NTAPI IoWMIWriteEvent( - IN PVOID WnodeEventItem); + IN OUT PVOID WnodeEventItem); NTKERNELAPI VOID @@ -9382,7 +9900,25 @@ NTAPI IoWriteErrorLogEntry( IN PVOID ElEntry); -#endif +NTKERNELAPI +PIRP +NTAPI +IoGetTopLevelIrp(VOID); + +NTKERNELAPI +NTSTATUS +NTAPI +IoRegisterLastChanceShutdownNotification( + IN PDEVICE_OBJECT DeviceObject); + +NTKERNELAPI +VOID +NTAPI +IoSetTopLevelIrp( + IN PIRP Irp OPTIONAL); + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ + #if (NTDDI_VERSION >= NTDDI_WINXP) @@ -9418,7 +9954,7 @@ PIRP NTAPI IoCsqRemoveNextIrp( IN PIO_CSQ Csq, - IN PVOID PeekContext); + IN PVOID PeekContext OPTIONAL); NTKERNELAPI BOOLEAN @@ -9665,12 +10201,10 @@ IoSetCompletionRoutine( IoReleaseRemoveLockAndWaitEx(_RemoveLock, _Tag, sizeof(IO_REMOVE_LOCK)) #if defined(_WIN64) - NTKERNELAPI BOOLEAN IoIs32bitProcess( IN PIRP Irp OPTIONAL); - #endif #define PLUGPLAY_REGKEY_DEVICE 1 @@ -9744,7 +10278,7 @@ IoInitializeDpcRequest( FORCEINLINE VOID IoCopyCurrentIrpStackLocationToNext( - IN PIRP Irp) + IN OUT PIRP Irp) { PIO_STACK_LOCATION irpSp; PIO_STACK_LOCATION nextIrpSp; @@ -9763,8 +10297,7 @@ IoGetStackLimits( FORCEINLINE ULONG_PTR -IoGetRemainingStackSize( - VOID) +IoGetRemainingStackSize(VOID) { ULONG_PTR End, Begin; ULONG_PTR Result; @@ -9774,6 +10307,19 @@ IoGetRemainingStackSize( return Result; } +#if (NTDDI_VERSION >= NTDDI_WS03) +VOID +FORCEINLINE +IoInitializeThreadedDpcRequest( + IN PDEVICE_OBJECT DeviceObject, + IN PIO_DPC_ROUTINE DpcRoutine) +{ + KeInitializeThreadedDpc(&DeviceObject->Dpc, + (PKDEFERRED_ROUTINE) DpcRoutine, + DeviceObject ); +} +#endif + /****************************************************************************** * Power Management Support Functions * ******************************************************************************/ @@ -9883,16 +10429,15 @@ PoUnregisterPowerSettingCallback( #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ #if (NTDDI_VERSION >= NTDDI_VISTASP1) - NTKERNELAPI VOID NTAPI PoSetDeviceBusyEx( IN OUT PULONG IdlePointer); - #endif /* (NTDDI_VERSION >= NTDDI_VISTASP1) */ #if (NTDDI_VERSION >= NTDDI_WIN7) + NTKERNELAPI VOID NTAPI @@ -9969,7 +10514,7 @@ PoCreatePowerRequest( #define ExInterlockedRemoveHeadList ExfInterlockedRemoveHeadList #define ExInterlockedPopEntryList ExfInterlockedPopEntryList #define ExInterlockedPushEntryList ExfInterlockedPushEntryList -#endif +#endif /* defined(_X86_) */ #if defined(_WIN64) @@ -10010,7 +10555,7 @@ ExpInterlockedPushEntrySList( #define ExInterlockedPushEntrySList(Head, Entry, Lock) \ ExpInterlockedPushEntrySList(Head, Entry) -#else // !defined(_WIN64) +#else /* !defined(_WIN64) */ #define ExQueryDepthSList(listhead) (listhead)->Depth @@ -10018,9 +10563,10 @@ NTKERNELAPI PSINGLE_LIST_ENTRY FASTCALL ExInterlockedFlushSList( - IN PSLIST_HEADER ListHead); + IN OUT PSLIST_HEADER ListHead); #if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_) + NTKERNELAPI PSINGLE_LIST_ENTRY FASTCALL @@ -10113,28 +10659,28 @@ NTKERNELAPI BOOLEAN NTAPI ExAcquireResourceExclusiveLite( - IN PERESOURCE Resource, + IN OUT PERESOURCE Resource, IN BOOLEAN Wait); NTKERNELAPI BOOLEAN NTAPI ExAcquireResourceSharedLite( - IN PERESOURCE Resource, + IN OUT PERESOURCE Resource, IN BOOLEAN Wait); NTKERNELAPI BOOLEAN NTAPI ExAcquireSharedStarveExclusive( - IN PERESOURCE Resource, + IN OUT PERESOURCE Resource, IN BOOLEAN Wait); NTKERNELAPI BOOLEAN NTAPI ExAcquireSharedWaitForExclusive( - IN PERESOURCE Resource, + IN OUT PERESOURCE Resource, IN BOOLEAN Wait); NTKERNELAPI @@ -10169,7 +10715,7 @@ ExAllocatePoolWithQuotaTag( #ifndef POOL_TAGGING #define ExAllocatePoolWithQuotaTag(a,b,c) ExAllocatePoolWithQuota(a,b) -#endif /* POOL_TAGGING */ +#endif NTKERNELAPI PVOID @@ -10192,7 +10738,7 @@ NTKERNELAPI VOID NTAPI ExConvertExclusiveToSharedLite( - IN PERESOURCE Resource); + IN OUT PERESOURCE Resource); NTKERNELAPI NTSTATUS @@ -10207,7 +10753,7 @@ NTKERNELAPI VOID NTAPI ExDeleteNPagedLookasideList( - IN PNPAGED_LOOKASIDE_LIST Lookaside); + IN OUT PNPAGED_LOOKASIDE_LIST Lookaside); NTKERNELAPI VOID @@ -10219,7 +10765,7 @@ NTKERNELAPI NTSTATUS NTAPI ExDeleteResourceLite( - IN PERESOURCE Resource); + IN OUT PERESOURCE Resource); NTKERNELAPI VOID @@ -10247,8 +10793,7 @@ ExGetExclusiveWaiterCount( NTKERNELAPI KPROCESSOR_MODE NTAPI -ExGetPreviousMode( - VOID); +ExGetPreviousMode(VOID); NTKERNELAPI ULONG @@ -10284,7 +10829,7 @@ NTKERNELAPI NTSTATUS NTAPI ExInitializeResourceLite( - IN PERESOURCE Resource); + OUT PERESOURCE Resource); NTKERNELAPI LARGE_INTEGER @@ -10308,12 +10853,15 @@ FASTCALL ExInterlockedAddUlong( IN PULONG Addend, IN ULONG Increment, - PKSPIN_LOCK Lock); + IN OUT PKSPIN_LOCK Lock); #if defined(_AMD64_) || defined(_IA64_) + #define ExInterlockedCompareExchange64(Destination, Exchange, Comperand, Lock) \ InterlockedCompareExchange64(Destination, *(Exchange), *(Comperand)) + #elif defined(_X86_) + NTKERNELAPI LONGLONG FASTCALL @@ -10321,9 +10869,12 @@ ExfInterlockedCompareExchange64( IN OUT LONGLONG volatile *Destination, IN PLONGLONG Exchange, IN PLONGLONG Comperand); + #define ExInterlockedCompareExchange64(Destination, Exchange, Comperand, Lock) \ ExfInterlockedCompareExchange64(Destination, Exchange, Comperand) + #else + NTKERNELAPI LONGLONG FASTCALL @@ -10332,45 +10883,46 @@ ExInterlockedCompareExchange64( IN PLONGLONG Exchange, IN PLONGLONG Comparand, IN PKSPIN_LOCK Lock); -#endif + +#endif /* defined(_AMD64_) || defined(_IA64_) */ NTKERNELAPI PLIST_ENTRY FASTCALL ExInterlockedInsertHeadList( - IN PLIST_ENTRY ListHead, - IN PLIST_ENTRY ListEntry, - IN PKSPIN_LOCK Lock); + IN OUT PLIST_ENTRY ListHead, + IN OUT PLIST_ENTRY ListEntry, + IN OUT PKSPIN_LOCK Lock); NTKERNELAPI PLIST_ENTRY FASTCALL ExInterlockedInsertTailList( - IN PLIST_ENTRY ListHead, - IN PLIST_ENTRY ListEntry, - IN PKSPIN_LOCK Lock); + IN OUT PLIST_ENTRY ListHead, + IN OUT PLIST_ENTRY ListEntry, + IN OUT PKSPIN_LOCK Lock); NTKERNELAPI PSINGLE_LIST_ENTRY FASTCALL ExInterlockedPopEntryList( - IN PSINGLE_LIST_ENTRY ListHead, - IN PKSPIN_LOCK Lock); + IN OUT PSINGLE_LIST_ENTRY ListHead, + IN OUT PKSPIN_LOCK Lock); NTKERNELAPI PSINGLE_LIST_ENTRY FASTCALL ExInterlockedPushEntryList( - IN PSINGLE_LIST_ENTRY ListHead, - IN PSINGLE_LIST_ENTRY ListEntry, - IN PKSPIN_LOCK Lock); + IN OUT PSINGLE_LIST_ENTRY ListHead, + IN OUT PSINGLE_LIST_ENTRY ListEntry, + IN OUT PKSPIN_LOCK Lock); NTKERNELAPI PLIST_ENTRY FASTCALL ExInterlockedRemoveHeadList( - IN PLIST_ENTRY ListHead, - IN PKSPIN_LOCK Lock); + IN OUT PLIST_ENTRY ListHead, + IN OUT PKSPIN_LOCK Lock); NTKERNELAPI BOOLEAN @@ -10404,14 +10956,14 @@ VOID NTAPI ExNotifyCallback( IN PCALLBACK_OBJECT CallbackObject, - IN PVOID Argument1, - IN PVOID Argument2); + IN PVOID Argument1 OPTIONAL, + IN PVOID Argument2 OPTIONAL); NTKERNELAPI VOID NTAPI ExQueueWorkItem( - IN PWORK_QUEUE_ITEM WorkItem, + IN OUT PWORK_QUEUE_ITEM WorkItem, IN WORK_QUEUE_TYPE QueueType); NTKERNELAPI @@ -10427,32 +10979,32 @@ NTAPI ExRegisterCallback( IN PCALLBACK_OBJECT CallbackObject, IN PCALLBACK_FUNCTION CallbackFunction, - IN PVOID CallbackContext); + IN PVOID CallbackContext OPTIONAL); NTKERNELAPI NTSTATUS NTAPI ExReinitializeResourceLite( - IN PERESOURCE Resource); + IN OUT PERESOURCE Resource); NTKERNELAPI VOID NTAPI ExReleaseResourceForThreadLite( - IN PERESOURCE Resource, + IN OUT PERESOURCE Resource, IN ERESOURCE_THREAD ResourceThreadId); NTKERNELAPI VOID FASTCALL ExReleaseResourceLite( - IN PERESOURCE Resource); + IN OUT PERESOURCE Resource); NTKERNELAPI VOID NTAPI ExSetResourceOwnerPointer( - IN PERESOURCE Resource, + IN OUT PERESOURCE Resource, IN PVOID OwnerPointer); NTKERNELAPI @@ -10473,12 +11025,12 @@ NTKERNELAPI VOID NTAPI ExUnregisterCallback( - IN PVOID CbRegistration); + IN OUT PVOID CbRegistration); - -#endif // (NTDDI_VERSION >= NTDDI_WIN2K) +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ #if (NTDDI_VERSION >= NTDDI_WINXP) + NTKERNELAPI BOOLEAN FASTCALL @@ -10495,7 +11047,7 @@ NTKERNELAPI VOID FASTCALL ExReInitializeRundownProtection( - OUT PEX_RUNDOWN_REF RunRef); + IN OUT PEX_RUNDOWN_REF RunRef); NTKERNELAPI VOID @@ -10521,9 +11073,10 @@ FASTCALL ExWaitForRundownProtectionRelease( IN OUT PEX_RUNDOWN_REF RunRef); -#endif // (NTDDI_VERSION >= NTDDI_WINXP) +#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ #if (NTDDI_VERSION >= NTDDI_WINXPSP2) + NTKERNELAPI BOOLEAN FASTCALL @@ -10537,9 +11090,11 @@ FASTCALL ExReleaseRundownProtectionEx( IN OUT PEX_RUNDOWN_REF RunRef, IN ULONG Count); -#endif // (NTDDI_VERSION >= NTDDI_WINXPSP2) + +#endif /* (NTDDI_VERSION >= NTDDI_WINXPSP2) */ #if (NTDDI_VERSION >= NTDDI_WS03SP1) + NTKERNELAPI PEX_RUNDOWN_REF_CACHE_AWARE NTAPI @@ -10551,9 +11106,92 @@ NTKERNELAPI SIZE_T NTAPI ExSizeOfRundownProtectionCacheAware(VOID); -#endif // (NTDDI_VERSION >= NTDDI_WS03SP1) + +NTKERNELAPI +PVOID +NTAPI +ExEnterCriticalRegionAndAcquireResourceShared( + IN OUT PERESOURCE Resource); + +NTKERNELAPI +PVOID +NTAPI +ExEnterCriticalRegionAndAcquireResourceExclusive( + IN OUT PERESOURCE Resource); + +NTKERNELAPI +PVOID +NTAPI +ExEnterCriticalRegionAndAcquireSharedWaitForExclusive( + IN OUT PERESOURCE Resource); + +NTKERNELAPI +VOID +FASTCALL +ExReleaseResourceAndLeaveCriticalRegion( + IN OUT PERESOURCE Resource); + +NTKERNELAPI +VOID +NTAPI +ExInitializeRundownProtectionCacheAware( + OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware, + IN SIZE_T RunRefSize); + +NTKERNELAPI +VOID +NTAPI +ExFreeCacheAwareRundownProtection( + IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware); + +NTKERNELAPI +BOOLEAN +FASTCALL +ExAcquireRundownProtectionCacheAware( + IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware); + +NTKERNELAPI +VOID +FASTCALL +ExReleaseRundownProtectionCacheAware( + IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware); + +NTKERNELAPI +BOOLEAN +FASTCALL +ExAcquireRundownProtectionCacheAwareEx( + IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware, + IN ULONG Count); + +NTKERNELAPI +VOID +FASTCALL +ExReleaseRundownProtectionCacheAwareEx( + IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRef, + IN ULONG Count); + +NTKERNELAPI +VOID +FASTCALL +ExWaitForRundownProtectionReleaseCacheAware( + IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRef); + +NTKERNELAPI +VOID +FASTCALL +ExReInitializeRundownProtectionCacheAware( + IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware); + +NTKERNELAPI +VOID +FASTCALL +ExRundownCompletedCacheAware( + IN OUT PEX_RUNDOWN_REF_CACHE_AWARE RunRefCacheAware); + +#endif /* (NTDDI_VERSION >= NTDDI_WS03SP1) */ #if (NTDDI_VERSION >= NTDDI_VISTA) + NTKERNELAPI NTSTATUS NTAPI @@ -10576,7 +11214,7 @@ ExAllocateFromNPagedLookasideList( { PVOID Entry; - Lookaside->L.TotalAllocates++; + Lookaside->L.TotalAllocates += 1; Entry = InterlockedPopEntrySList(&Lookaside->L.ListHead); if (Entry == NULL) { Lookaside->L.AllocateMisses++; @@ -10606,7 +11244,7 @@ ExAllocateFromPagedLookasideList( static __inline VOID ExFreeToNPagedLookasideList( - IN PNPAGED_LOOKASIDE_LIST Lookaside, + IN OUT PNPAGED_LOOKASIDE_LIST Lookaside, IN PVOID Entry) { Lookaside->L.TotalFrees++; @@ -10691,10 +11329,99 @@ ObReleaseObjectSecurity( #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ +#if (NTDDI_VERSION >= NTDDI_VISTA) +NTKERNELAPI +VOID +NTAPI +ObDereferenceObjectDeferDelete( + IN PVOID Object); +#endif + +#if (NTDDI_VERSION >= NTDDI_VISTASP1) +NTKERNELAPI +NTSTATUS +NTAPI +ObRegisterCallbacks( + IN POB_CALLBACK_REGISTRATION CallbackRegistration, + OUT PVOID *RegistrationHandle); + +NTKERNELAPI +VOID +NTAPI +ObUnRegisterCallbacks( + IN PVOID RegistrationHandle); + +NTKERNELAPI +USHORT +NTAPI +ObGetFilterVersion(VOID); + +#endif /* (NTDDI_VERSION >= NTDDI_VISTASP1) */ + +#if (NTDDI_VERSION >= NTDDI_WIN7) + +NTKERNELAPI +NTSTATUS +NTAPI +ObReferenceObjectByHandleWithTag( + IN HANDLE Handle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_TYPE ObjectType OPTIONAL, + IN KPROCESSOR_MODE AccessMode, + IN ULONG Tag, + OUT PVOID *Object, + OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL); + +NTKERNELAPI +LONG_PTR +FASTCALL +ObfReferenceObjectWithTag( + IN PVOID Object, + IN ULONG Tag); + +NTKERNELAPI +NTSTATUS +NTAPI +ObReferenceObjectByPointerWithTag( + IN PVOID Object, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_TYPE ObjectType OPTIONAL, + IN KPROCESSOR_MODE AccessMode, + IN ULONG Tag); + +NTKERNELAPI +LONG_PTR +FASTCALL +ObfDereferenceObjectWithTag( + IN PVOID Object, + IN ULONG Tag); + +NTKERNELAPI +VOID +NTAPI +ObDereferenceObjectDeferDeleteWithTag( + IN PVOID Object, + IN ULONG Tag); + +#define ObDereferenceObject ObfDereferenceObject +#define ObReferenceObject ObfReferenceObject +#define ObDereferenceObjectWithTag ObfDereferenceObjectWithTag +#define ObReferenceObjectWithTag ObfReferenceObjectWithTag + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + + /****************************************************************************** * Process Manager Functions * ******************************************************************************/ +NTKERNELAPI +NTSTATUS +NTAPI +PsWrapApcWow64Thread( + IN OUT PVOID *ApcContext, + IN OUT PVOID *ApcRoutine); + /* * PEPROCESS * PsGetCurrentProcess(VOID) @@ -10702,19 +11429,16 @@ ObReleaseObjectSecurity( #define PsGetCurrentProcess IoGetCurrentProcess #if !defined(_PSGETCURRENTTHREAD_) - #define _PSGETCURRENTTHREAD_ - FORCEINLINE PETHREAD NTAPI -PsGetCurrentThread ( - VOID) +PsGetCurrentThread(VOID) { return (PETHREAD)KeGetCurrentThread(); } +#endif /* !_PSGETCURRENTTHREAD_ */ -#endif #if (NTDDI_VERSION >= NTDDI_WIN2K) @@ -10736,18 +11460,18 @@ NTAPI PsTerminateSystemThread( IN NTSTATUS ExitStatus); -#endif + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ /****************************************************************************** * WMI Library Support Functions * ******************************************************************************/ #ifdef RUN_WPP - #if (NTDDI_VERSION >= NTDDI_WINXP) NTKERNELAPI NTSTATUS -DDKCDECLAPI +__cdecl WmiTraceMessage( IN TRACEHANDLE LoggerHandle, IN ULONG MessageFlags, @@ -10755,8 +11479,7 @@ WmiTraceMessage( IN USHORT MessageNumber, IN ...); #endif - -#endif +#endif /* RUN_WPP */ #if (NTDDI_VERSION >= NTDDI_WINXP) @@ -10774,7 +11497,7 @@ WmiQueryTraceInformation( /* FIXME: Get va_list from where? */ NTKERNELAPI NTSTATUS -DDKCDECLAPI +__cdecl WmiTraceMessageVa( IN TRACEHANDLE LoggerHandle, IN ULONG MessageFlags, @@ -10790,8 +11513,9 @@ WmiTraceMessageVa( ******************************************************************************/ #ifndef _DBGNT_ + ULONG -DDKCDECLAPI +__cdecl DbgPrint( IN PCSTR Format, IN ...); @@ -10801,6 +11525,7 @@ DbgPrint( #define KdPrint(_x_) DbgPrint _x_ #define KdPrintEx(_x_) DbgPrintEx _x_ +#define vKdPrintEx(_x_) vDbgPrintEx _x_ #define vKdPrintExWithPrefix(_x_) vDbgPrintExWithPrefix _x_ #define KdBreakPoint() DbgBreakPoint() #define KdBreakPointWithStatus(s) DbgBreakPointWithStatus(s) @@ -10809,6 +11534,7 @@ DbgPrint( #define KdPrint(_x_) #define KdPrintEx(_x_) +#define vKdPrintEx(_x_) #define vKdPrintExWithPrefix(_x_) #define KdBreakPoint() #define KdBreakPointWithStatus(s) @@ -10868,22 +11594,19 @@ vDbgPrintExWithPrefix( NTKERNELAPI NTSTATUS NTAPI -KdDisableDebugger( - VOID); +KdDisableDebugger(VOID); NTKERNELAPI NTSTATUS NTAPI -KdEnableDebugger( - VOID); +KdEnableDebugger(VOID); #if (_MSC_FULL_VER >= 150030729) && !defined(IMPORT_NATIVE_DBG_BREAK) #define DbgBreakPoint __debugbreak #else VOID NTAPI -DbgBreakPoint( - VOID); +DbgBreakPoint(VOID); #endif NTSYSAPI @@ -10894,7 +11617,7 @@ DbgBreakPointWithStatus( NTSYSAPI ULONG -DDKCDECLAPI +_cdecl DbgPrintReturnControlC( IN PCCH Format, IN ...); @@ -10905,7 +11628,7 @@ DbgPrintReturnControlC( NTSYSAPI ULONG -DDKCDECLAPI +_cdecl DbgPrintEx( IN ULONG ComponentId, IN ULONG Level, @@ -10930,14 +11653,10 @@ DbgSetDebugFilterState( #endif #if (NTDDI_VERSION >= NTDDI_WS03) - NTKERNELAPI BOOLEAN NTAPI -KdRefreshDebuggerNotPresent( - VOID -); - +KdRefreshDebuggerNotPresent(VOID); #endif #if (NTDDI_VERSION >= NTDDI_WS03SP1) @@ -10954,6 +11673,7 @@ KdChangeOption( #endif #if defined(USE_DMA_MACROS) && !defined(_NTHAL_) && (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_) + FORCEINLINE PVOID NTAPI @@ -11056,14 +11776,19 @@ typedef enum _ENLISTMENT_INFORMATION_CLASS { * ZwXxx Functions * ******************************************************************************/ + /* Constants */ #define NtCurrentProcess() ( (HANDLE)(LONG_PTR) -1 ) #define ZwCurrentProcess() NtCurrentProcess() #define NtCurrentThread() ( (HANDLE)(LONG_PTR) -2 ) #define ZwCurrentThread() NtCurrentThread() + + #if (NTDDI_VERSION >= NTDDI_WIN2K) + + NTSYSAPI NTSTATUS NTAPI @@ -11329,10 +12054,11 @@ ZwQueryFullAttributesFile( IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PFILE_NETWORK_OPEN_INFORMATION FileInformation); -#endif -#if (NTDDI_VERSION >= NTDDI_WIN2003) +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ + +#if (NTDDI_VERSION >= NTDDI_WS03) NTSYSCALLAPI NTSTATUS NTAPI @@ -11340,7 +12066,6 @@ ZwOpenEvent( OUT PHANDLE EventHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes); - #endif #if (NTDDI_VERSION >= NTDDI_VISTA) @@ -11667,10 +12392,13 @@ ZwSinglePhaseReject( IN PLARGE_INTEGER TmVirtualClock OPTIONAL); -#endif +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + #if (NTDDI_VERSION >= NTDDI_WIN7) + + NTSYSAPI NTSTATUS NTAPI From a5f7b08edfe04a8c9f924aed53157c848829c7d2 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 29 Mar 2010 09:15:47 +0000 Subject: [PATCH 087/134] Move IoAttachDeviceToDeviceStackSafe to ntddk.h svn path=/trunk/; revision=46565 --- reactos/drivers/serial/serial/serial.h | 9 --------- reactos/include/ddk/ntddk.h | 8 ++++++++ reactos/include/ddk/ntifs.h | 9 --------- 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/reactos/drivers/serial/serial/serial.h b/reactos/drivers/serial/serial/serial.h index de94b291138..b6ed661226c 100644 --- a/reactos/drivers/serial/serial/serial.h +++ b/reactos/drivers/serial/serial/serial.h @@ -17,15 +17,6 @@ #define PST_RS232 1 #define COMMPROP_INITIALIZED 0xE73CF52E -#ifndef _NTIFS_ -/* Why is it only defined in ntifs.h file? */ -NTSTATUS NTAPI -IoAttachDeviceToDeviceStackSafe( - IN PDEVICE_OBJECT SourceDevice, - IN PDEVICE_OBJECT TargetDevice, - OUT PDEVICE_OBJECT *AttachedToDeviceObject); -#endif - typedef enum { dsStopped, diff --git a/reactos/include/ddk/ntddk.h b/reactos/include/ddk/ntddk.h index 0475b3acc85..4e27091d5c6 100644 --- a/reactos/include/ddk/ntddk.h +++ b/reactos/include/ddk/ntddk.h @@ -2394,6 +2394,14 @@ IoWritePartitionTableEx( IN PDEVICE_OBJECT DeviceObject, IN struct _DRIVE_LAYOUT_INFORMATION_EX *DriveLayout); +NTKERNELAPI +NTSTATUS +NTAPI +IoAttachDeviceToDeviceStackSafe( + IN PDEVICE_OBJECT SourceDevice, + IN PDEVICE_OBJECT TargetDevice, + OUT PDEVICE_OBJECT *AttachedToDeviceObject); + #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ /** Kernel debugger routines **/ diff --git a/reactos/include/ddk/ntifs.h b/reactos/include/ddk/ntifs.h index 5f032726d38..87d0470888c 100644 --- a/reactos/include/ddk/ntifs.h +++ b/reactos/include/ddk/ntifs.h @@ -8933,15 +8933,6 @@ FsRtlUninitializeOplock ( IN OUT POPLOCK Oplock ); -NTKERNELAPI -NTSTATUS -NTAPI -IoAttachDeviceToDeviceStackSafe( - IN PDEVICE_OBJECT SourceDevice, - IN PDEVICE_OBJECT TargetDevice, - OUT PDEVICE_OBJECT *AttachedToDeviceObject -); - NTKERNELAPI NTSTATUS NTAPI From 9ff08ac905e6138506956e47f718b66b2df5f7f6 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 29 Mar 2010 10:35:31 +0000 Subject: [PATCH 088/134] Merge ntdef.h svn path=/trunk/; revision=46566 --- reactos/include/psdk/ntdef.h | 63 +++++++++++++++++------------------- 1 file changed, 29 insertions(+), 34 deletions(-) diff --git a/reactos/include/psdk/ntdef.h b/reactos/include/psdk/ntdef.h index 3d7bf2b6129..fdc365085b2 100644 --- a/reactos/include/psdk/ntdef.h +++ b/reactos/include/psdk/ntdef.h @@ -1,5 +1,5 @@ -#ifndef _NTDEF_H -#define _NTDEF_H +#ifndef _NTDEF_ +#define _NTDEF_ /* Dependencies */ #include @@ -74,20 +74,6 @@ typedef unsigned long POINTER_64; // FIXME! HACK!!! #endif #endif /* NULL */ -typedef enum _EVENT_TYPE { - NotificationEvent, - SynchronizationEvent -} EVENT_TYPE; - -typedef enum _TIMER_TYPE { - NotificationTimer, - SynchronizationTimer -} TIMER_TYPE; - -typedef enum _WAIT_TYPE { - WaitAll, - WaitAny -} WAIT_TYPE; // // FIXME @@ -187,11 +173,6 @@ typedef enum _WAIT_TYPE { #define NTAPI __stdcall -// -// Used by the DDK exclusively , don't put in drivers -// -#define DDKAPI __stdcall // Use NTAPI instead -#define DDKCDECLAPI __cdecl // Just use __cdecl /* Import and Export Specifiers */ @@ -306,19 +287,6 @@ typedef int INT; #endif typedef double DOUBLE; -// -// Used to store a non-float 8 byte aligned structure -// -typedef struct _QUAD -{ - _ANONYMOUS_UNION union - { - __GNU_EXTENSION __int64 UseThisFieldToCopy; - double DoNotUseThisField; - }; -} QUAD, *PQUAD, UQUAD, *PUQUAD; - - /* Unsigned Types */ typedef unsigned char UCHAR, *PUCHAR; typedef unsigned short USHORT, *PUSHORT; @@ -389,6 +357,15 @@ typedef ULONG LCID; typedef PULONG PLCID; typedef USHORT LANGID; +/* Used to store a non-float 8 byte aligned structure */ +typedef struct _QUAD +{ + _ANONYMOUS_UNION union + { + __GNU_EXTENSION __int64 UseThisFieldToCopy; + double DoNotUseThisField; + } DUMMYUNIONNAME; +} QUAD, *PQUAD, UQUAD, *PUQUAD; /* Large Integer Unions */ #if defined(MIDL_PASS) @@ -544,7 +521,20 @@ typedef enum _NT_PRODUCT_TYPE { NtProductServer } NT_PRODUCT_TYPE, *PNT_PRODUCT_TYPE; +typedef enum _EVENT_TYPE { + NotificationEvent, + SynchronizationEvent +} EVENT_TYPE; +typedef enum _TIMER_TYPE { + NotificationTimer, + SynchronizationTimer +} TIMER_TYPE; + +typedef enum _WAIT_TYPE { + WaitAll, + WaitAny +} WAIT_TYPE; /* Doubly Linked Lists */ typedef struct _LIST_ENTRY { @@ -582,6 +572,11 @@ typedef EXCEPTION_DISPOSITION IN OUT struct _CONTEXT *ContextRecord, IN OUT PVOID DispatcherContext); +typedef struct _GROUP_AFFINITY { + KAFFINITY Mask; + USHORT Group; + USHORT Reserved[3]; +} GROUP_AFFINITY, *PGROUP_AFFINITY; /* Helper Macros */ #define RTL_CONSTANT_STRING(s) { sizeof(s)-sizeof((s)[0]), sizeof(s), s } From f3e748eef0992c59a505834ed6a559b989b9f136 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 29 Mar 2010 11:23:09 +0000 Subject: [PATCH 089/134] Merge winnt.h svn path=/trunk/; revision=46567 --- reactos/include/psdk/winnt.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/reactos/include/psdk/winnt.h b/reactos/include/psdk/winnt.h index bd0fac136b9..f856b079970 100644 --- a/reactos/include/psdk/winnt.h +++ b/reactos/include/psdk/winnt.h @@ -3411,6 +3411,12 @@ typedef LONG struct _EXCEPTION_POINTERS *ExceptionInfo ); +typedef struct _GROUP_AFFINITY { + KAFFINITY Mask; + WORD Group; + WORD Reserved[3]; +} GROUP_AFFINITY, *PGROUP_AFFINITY; + typedef struct _EVENTLOGRECORD { DWORD Length; DWORD Reserved; From 6a86d097cb410fc0a770cac46b6fcd09dfd0a7c0 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 29 Mar 2010 11:40:06 +0000 Subject: [PATCH 090/134] Define PPEB in ntddk.h svn path=/trunk/; revision=46568 --- reactos/include/ddk/ntddk.h | 2 ++ reactos/include/ndk/peb_teb.h | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/reactos/include/ddk/ntddk.h b/reactos/include/ddk/ntddk.h index 4e27091d5c6..62c1f7873f1 100644 --- a/reactos/include/ddk/ntddk.h +++ b/reactos/include/ddk/ntddk.h @@ -70,6 +70,8 @@ typedef GUID UUID; typedef struct _BUS_HANDLER *PBUS_HANDLER; +typedef struct _PEB *PPEB; + #define EXCEPTION_READ_FAULT 0 #define EXCEPTION_WRITE_FAULT 1 #define EXCEPTION_EXECUTE_FAULT 8 diff --git a/reactos/include/ndk/peb_teb.h b/reactos/include/ndk/peb_teb.h index 38791b31a21..ec4b2d33617 100644 --- a/reactos/include/ndk/peb_teb.h +++ b/reactos/include/ndk/peb_teb.h @@ -1,4 +1,3 @@ - #define PASTE2(x,y) x##y #define PASTE(x,y) PASTE2(x,y) @@ -19,6 +18,10 @@ #define GDI_HANDLE_BUFFER_SIZE 34 #endif +#if defined(_NTDDK_INCLUDED_) || defined(_NTIFS_) +#define PPEB PPEB_RENAMED +#endif + typedef struct STRUCT(_PEB) { BOOLEAN InheritedAddressSpace; @@ -152,6 +155,7 @@ typedef struct STRUCT(_PEB) #endif } STRUCT(PEB), *STRUCT(PPEB); +#undef PPEB #if defined(_WIN64) && !defined(EXPLICIT_32BIT) C_ASSERT(FIELD_OFFSET(STRUCT(PEB), Mutant) == 0x08); From b44642d7fd16b9991a7ca08253bc329265d41c6a Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Mon, 29 Mar 2010 13:12:16 +0000 Subject: [PATCH 091/134] [MSDVBNP] - Implement IBDA_EthernetFilter, IBDA_IPV4Filter, IBDA_IPV6Filter svn path=/trunk/; revision=46569 --- .../dll/directx/msdvbnp/ethernetfilter.cpp | 169 +++++++++++++++++ reactos/dll/directx/msdvbnp/ipv4.cpp | 170 ++++++++++++++++++ reactos/dll/directx/msdvbnp/ipv6.cpp | 167 +++++++++++++++++ reactos/dll/directx/msdvbnp/msdvbnp.rbuild | 3 + .../dll/directx/msdvbnp/networkprovider.cpp | 53 +++++- reactos/dll/directx/msdvbnp/precomp.h | 24 +++ 6 files changed, 585 insertions(+), 1 deletion(-) create mode 100644 reactos/dll/directx/msdvbnp/ethernetfilter.cpp create mode 100644 reactos/dll/directx/msdvbnp/ipv4.cpp create mode 100644 reactos/dll/directx/msdvbnp/ipv6.cpp diff --git a/reactos/dll/directx/msdvbnp/ethernetfilter.cpp b/reactos/dll/directx/msdvbnp/ethernetfilter.cpp new file mode 100644 index 00000000000..16f6122cc20 --- /dev/null +++ b/reactos/dll/directx/msdvbnp/ethernetfilter.cpp @@ -0,0 +1,169 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS BDA Proxy + * FILE: dll/directx/msdvbnp/ethernetfilter.cpp + * PURPOSE: IBDA_EthernetFilter interface + * + * PROGRAMMERS: Johannes Anderwald (janderwald@reactos.org) + */ +#include "precomp.h" + +class CEthernetFilter : public IBDA_EthernetFilter +{ +public: + STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface); + + STDMETHODIMP_(ULONG) AddRef(); + STDMETHODIMP_(ULONG) Release(); + + //IBDA_EthernetFilter + HRESULT STDMETHODCALLTYPE GetMulticastListSize(ULONG *pulcbAddresses); + HRESULT STDMETHODCALLTYPE PutMulticastList(ULONG ulcbAddresses, BYTE * pAddressList); + HRESULT STDMETHODCALLTYPE GetMulticastList(ULONG *pulcbAddresses, BYTE *pAddressList); + HRESULT STDMETHODCALLTYPE PutMulticastMode(ULONG ulModeMask); + HRESULT STDMETHODCALLTYPE GetMulticastMode(ULONG *pulModeMask); + + + CEthernetFilter(IBDA_NetworkProvider * pNetworkProvider); + virtual ~CEthernetFilter(); + +protected: + IBDA_NetworkProvider * m_pNetworkProvider; + ULONG m_ulcbAddresses; + BYTE * m_pAddressList; + ULONG m_ulModeMask; +}; + +CEthernetFilter::CEthernetFilter( + IBDA_NetworkProvider * pNetworkProvider) : m_pNetworkProvider(pNetworkProvider), + m_ulcbAddresses(0), + m_pAddressList(0), + m_ulModeMask(0) +{ +} + +CEthernetFilter::~CEthernetFilter() +{ + if (m_pAddressList) + CoTaskMemFree(m_pAddressList); +} + +HRESULT +STDMETHODCALLTYPE +CEthernetFilter::QueryInterface( + REFIID InterfaceId, + PVOID* Interface) +{ + assert(m_pNetworkProvider); + return m_pNetworkProvider->QueryInterface(InterfaceId, Interface); +} + +ULONG +STDMETHODCALLTYPE +CEthernetFilter::AddRef() +{ + assert(m_pNetworkProvider); + return m_pNetworkProvider->AddRef(); +} + +ULONG +STDMETHODCALLTYPE +CEthernetFilter::Release() +{ + assert(m_pNetworkProvider); + return m_pNetworkProvider->Release(); +} + +//------------------------------------------------------------------- +//IBDA_EthernetFilter +// + +HRESULT +STDMETHODCALLTYPE +CEthernetFilter::PutMulticastList( + ULONG ulcbAddresses, + BYTE * pAddressList) +{ + if (!ulcbAddresses || !pAddressList) + return E_POINTER; + + if (m_pAddressList) + CoTaskMemFree(m_pAddressList); + + m_pAddressList = (BYTE*)CoTaskMemAlloc(ulcbAddresses); + if (!m_pAddressList) + return E_OUTOFMEMORY; + + CopyMemory(m_pAddressList, pAddressList, ulcbAddresses); + m_ulcbAddresses = ulcbAddresses; + return NOERROR; +} + +HRESULT +STDMETHODCALLTYPE +CEthernetFilter::GetMulticastList( + ULONG *pulcbAddresses, + BYTE *pAddressList) +{ + if (!pulcbAddresses || !pAddressList) + return E_POINTER; + + if (*pulcbAddresses < m_ulcbAddresses) + return E_OUTOFMEMORY; + + CopyMemory(pAddressList, m_pAddressList, m_ulcbAddresses); + *pulcbAddresses = m_ulcbAddresses; + return NOERROR; +} + +HRESULT +STDMETHODCALLTYPE +CEthernetFilter::GetMulticastListSize( + ULONG *pulcbAddresses) +{ + if (!pulcbAddresses) + return E_POINTER; + + *pulcbAddresses = m_ulcbAddresses; + return NOERROR; +} + +HRESULT +STDMETHODCALLTYPE +CEthernetFilter::PutMulticastMode( + ULONG ulModeMask) +{ + m_ulModeMask = ulModeMask; + return NOERROR; +} + +HRESULT +STDMETHODCALLTYPE +CEthernetFilter::GetMulticastMode( + ULONG *pulModeMask) +{ + *pulModeMask = m_ulModeMask; + return NOERROR; +} + +HRESULT +WINAPI +CEthernetFilter_fnConstructor( + IBDA_NetworkProvider * pNetworkProvider, + REFIID riid, + LPVOID * ppv) +{ + CEthernetFilter * filter = new CEthernetFilter(pNetworkProvider); + + if (!filter) + return E_OUTOFMEMORY; + + if (FAILED(filter->QueryInterface(riid, ppv))) + { + /* not supported */ + delete filter; + return E_NOINTERFACE; + } + + return NOERROR; +} diff --git a/reactos/dll/directx/msdvbnp/ipv4.cpp b/reactos/dll/directx/msdvbnp/ipv4.cpp new file mode 100644 index 00000000000..6647558dcf2 --- /dev/null +++ b/reactos/dll/directx/msdvbnp/ipv4.cpp @@ -0,0 +1,170 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS BDA Proxy + * FILE: dll/directx/msdvbnp/ipv4.cpp + * PURPOSE: IBDA_IPV4Filter interface + * + * PROGRAMMERS: Johannes Anderwald (janderwald@reactos.org) + */ +#include "precomp.h" + +class CIPV4Filter : public IBDA_IPV4Filter +{ +public: + STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface); + STDMETHODIMP_(ULONG) AddRef(); + STDMETHODIMP_(ULONG) Release(); + + //IBDA_IPV4Filter + HRESULT STDMETHODCALLTYPE GetMulticastListSize(ULONG *pulcbAddresses); + HRESULT STDMETHODCALLTYPE PutMulticastList(ULONG ulcbAddresses, BYTE * pAddressList); + HRESULT STDMETHODCALLTYPE GetMulticastList(ULONG *pulcbAddresses, BYTE *pAddressList); + HRESULT STDMETHODCALLTYPE PutMulticastMode(ULONG ulModeMask); + HRESULT STDMETHODCALLTYPE GetMulticastMode(ULONG *pulModeMask); + + + CIPV4Filter(IBDA_NetworkProvider * pNetworkProvider); + virtual ~CIPV4Filter(); + +protected: + IBDA_NetworkProvider * m_pNetworkProvider; + ULONG m_ulcbAddresses; + BYTE * m_pAddressList; + ULONG m_ulModeMask; +}; + +CIPV4Filter::CIPV4Filter( + IBDA_NetworkProvider * pNetworkProvider) : m_pNetworkProvider(pNetworkProvider), + m_ulcbAddresses(0), + m_pAddressList(0), + m_ulModeMask(0) +{ +} + +CIPV4Filter::~CIPV4Filter() +{ + if (m_pAddressList) + CoTaskMemFree(m_pAddressList); +} + + +HRESULT +STDMETHODCALLTYPE +CIPV4Filter::QueryInterface( + REFIID InterfaceId, + PVOID* Interface) +{ + assert(m_pNetworkProvider); + return m_pNetworkProvider->QueryInterface(InterfaceId, Interface); +} + +ULONG +STDMETHODCALLTYPE +CIPV4Filter::AddRef() +{ + assert(m_pNetworkProvider); + return m_pNetworkProvider->AddRef(); +} + +ULONG +STDMETHODCALLTYPE +CIPV4Filter::Release() +{ + assert(m_pNetworkProvider); + return m_pNetworkProvider->Release(); +} + +//------------------------------------------------------------------- +//IBDA_IPV4Filter +// + + +HRESULT +STDMETHODCALLTYPE +CIPV4Filter::GetMulticastListSize( + ULONG *pulcbAddresses) +{ + if (!pulcbAddresses) + return E_POINTER; + + *pulcbAddresses = 0; + return NOERROR; +} + +HRESULT +STDMETHODCALLTYPE +CIPV4Filter::PutMulticastList( + ULONG ulcbAddresses, + BYTE * pAddressList) +{ + if (!ulcbAddresses || !pAddressList) + return E_POINTER; + + if (m_pAddressList) + CoTaskMemFree(m_pAddressList); + + m_pAddressList = (BYTE*)CoTaskMemAlloc(ulcbAddresses); + if (!m_pAddressList) + return E_OUTOFMEMORY; + + CopyMemory(m_pAddressList, pAddressList, ulcbAddresses); + m_ulcbAddresses = ulcbAddresses; + return NOERROR; +} + +HRESULT +STDMETHODCALLTYPE +CIPV4Filter::GetMulticastList( + ULONG *pulcbAddresses, + BYTE *pAddressList) +{ + if (!pulcbAddresses || !pAddressList) + return E_POINTER; + + if (*pulcbAddresses < m_ulcbAddresses) + return E_OUTOFMEMORY; + + CopyMemory(pAddressList, m_pAddressList, m_ulcbAddresses); + *pulcbAddresses = m_ulcbAddresses; + return NOERROR; +} + +HRESULT +STDMETHODCALLTYPE +CIPV4Filter::PutMulticastMode( + ULONG ulModeMask) +{ + m_ulModeMask = ulModeMask; + return NOERROR; +} + +HRESULT +STDMETHODCALLTYPE +CIPV4Filter::GetMulticastMode( + ULONG *pulModeMask) +{ + *pulModeMask = m_ulModeMask; + return NOERROR; +} + +HRESULT +WINAPI +CIPV4Filter_fnConstructor( + IBDA_NetworkProvider * pNetworkProvider, + REFIID riid, + LPVOID * ppv) +{ + CIPV4Filter * filter = new CIPV4Filter(pNetworkProvider); + + if (!filter) + return E_OUTOFMEMORY; + + if (FAILED(filter->QueryInterface(riid, ppv))) + { + /* not supported */ + delete filter; + return E_NOINTERFACE; + } + + return NOERROR; +} diff --git a/reactos/dll/directx/msdvbnp/ipv6.cpp b/reactos/dll/directx/msdvbnp/ipv6.cpp new file mode 100644 index 00000000000..6017443a450 --- /dev/null +++ b/reactos/dll/directx/msdvbnp/ipv6.cpp @@ -0,0 +1,167 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS BDA Proxy + * FILE: dll/directx/msdvbnp/ipv6.cpp + * PURPOSE: IBDA_IPV6Filter interface + * + * PROGRAMMERS: Johannes Anderwald (janderwald@reactos.org) + */ +#include "precomp.h" + +class CIPV6Filter : public IBDA_IPV6Filter +{ +public: + STDMETHODIMP QueryInterface( REFIID InterfaceId, PVOID* Interface); + STDMETHODIMP_(ULONG) AddRef(); + STDMETHODIMP_(ULONG) Release(); + + //IBDA_IPV6Filter + HRESULT STDMETHODCALLTYPE GetMulticastListSize(ULONG *pulcbAddresses); + HRESULT STDMETHODCALLTYPE PutMulticastList(ULONG ulcbAddresses, BYTE * pAddressList); + HRESULT STDMETHODCALLTYPE GetMulticastList(ULONG *pulcbAddresses, BYTE *pAddressList); + HRESULT STDMETHODCALLTYPE PutMulticastMode(ULONG ulModeMask); + HRESULT STDMETHODCALLTYPE GetMulticastMode(ULONG *pulModeMask); + + CIPV6Filter(IBDA_NetworkProvider * pNetworkProvider); + virtual ~CIPV6Filter(); + +protected: + IBDA_NetworkProvider * m_pNetworkProvider; + ULONG m_ulcbAddresses; + BYTE * m_pAddressList; + ULONG m_ulModeMask; +}; + +CIPV6Filter::CIPV6Filter( + IBDA_NetworkProvider * pNetworkProvider) : m_pNetworkProvider(pNetworkProvider), + m_ulcbAddresses(0), + m_pAddressList(0), + m_ulModeMask(0) +{ +} + +CIPV6Filter::~CIPV6Filter() +{ + if (m_pAddressList) + CoTaskMemFree(m_pAddressList); +} + +HRESULT +STDMETHODCALLTYPE +CIPV6Filter::QueryInterface( + REFIID InterfaceId, + PVOID* Interface) +{ + assert(m_pNetworkProvider); + return m_pNetworkProvider->QueryInterface(InterfaceId, Interface); +} + +ULONG +STDMETHODCALLTYPE +CIPV6Filter::AddRef() +{ + assert(m_pNetworkProvider); + return m_pNetworkProvider->AddRef(); +} + +ULONG +STDMETHODCALLTYPE +CIPV6Filter::Release() +{ + assert(m_pNetworkProvider); + return m_pNetworkProvider->Release(); +} + +//------------------------------------------------------------------- +//IBDA_IPV6Filter +// + +HRESULT +STDMETHODCALLTYPE +CIPV6Filter::GetMulticastListSize( + ULONG *pulcbAddresses) +{ + if (!pulcbAddresses) + return E_POINTER; + + *pulcbAddresses = 0; + return NOERROR; +} + +HRESULT +STDMETHODCALLTYPE +CIPV6Filter::GetMulticastList( + ULONG *pulcbAddresses, + BYTE *pAddressList) +{ + if (!pulcbAddresses || !pAddressList) + return E_POINTER; + + if (*pulcbAddresses < m_ulcbAddresses) + return E_OUTOFMEMORY; + + CopyMemory(pAddressList, m_pAddressList, m_ulcbAddresses); + *pulcbAddresses = m_ulcbAddresses; + return NOERROR; +} + +HRESULT +STDMETHODCALLTYPE +CIPV6Filter::PutMulticastList( + ULONG ulcbAddresses, + BYTE * pAddressList) +{ + if (!ulcbAddresses || !pAddressList) + return E_POINTER; + + if (m_pAddressList) + CoTaskMemFree(m_pAddressList); + + m_pAddressList = (BYTE*)CoTaskMemAlloc(ulcbAddresses); + if (!m_pAddressList) + return E_OUTOFMEMORY; + + CopyMemory(m_pAddressList, pAddressList, ulcbAddresses); + m_ulcbAddresses = ulcbAddresses; + return NOERROR; +} + +HRESULT +STDMETHODCALLTYPE +CIPV6Filter::PutMulticastMode( + ULONG ulModeMask) +{ + m_ulModeMask = ulModeMask; + return NOERROR; +} + +HRESULT +STDMETHODCALLTYPE +CIPV6Filter::GetMulticastMode( + ULONG *pulModeMask) +{ + *pulModeMask = m_ulModeMask; + return NOERROR; +} + +HRESULT +WINAPI +CIPV6Filter_fnConstructor( + IBDA_NetworkProvider * pNetworkProvider, + REFIID riid, + LPVOID * ppv) +{ + CIPV6Filter * filter = new CIPV6Filter(pNetworkProvider); + + if (!filter) + return E_OUTOFMEMORY; + + if (FAILED(filter->QueryInterface(riid, ppv))) + { + /* not supported */ + delete filter; + return E_NOINTERFACE; + } + + return NOERROR; +} diff --git a/reactos/dll/directx/msdvbnp/msdvbnp.rbuild b/reactos/dll/directx/msdvbnp/msdvbnp.rbuild index 6213d7d8f37..a1cf02ac4f7 100644 --- a/reactos/dll/directx/msdvbnp/msdvbnp.rbuild +++ b/reactos/dll/directx/msdvbnp/msdvbnp.rbuild @@ -22,8 +22,11 @@ classfactory.cpp enum_mediatypes.cpp enumpins.cpp + ethernetfilter.cpp msdvbnp.cpp msdvbnp.rc + ipv4.cpp + ipv6.cpp networkprovider.cpp pin.cpp scanningtuner.cpp diff --git a/reactos/dll/directx/msdvbnp/networkprovider.cpp b/reactos/dll/directx/msdvbnp/networkprovider.cpp index be7fee28cc5..7dea3667142 100644 --- a/reactos/dll/directx/msdvbnp/networkprovider.cpp +++ b/reactos/dll/directx/msdvbnp/networkprovider.cpp @@ -74,6 +74,9 @@ protected: GUID m_ClassID; DeviceFilterStack m_DeviceFilters; IScanningTuner * m_Tuner; + IBDA_IPV6Filter * m_IPV6Filter; + IBDA_IPV4Filter * m_IPV4Filter; + IBDA_EthernetFilter * m_EthernetFilter; }; HRESULT @@ -116,6 +119,51 @@ CNetworkProvider::QueryInterface( return NOERROR; } + if (IsEqualGUID(refiid, IID_IBDA_IPV6Filter)) + { + // construct scanning tuner + if (!m_IPV6Filter) + { + HRESULT hr = CIPV6Filter_fnConstructor((IBDA_NetworkProvider*)this, refiid, (void**)&m_IPV6Filter); + if (FAILED(hr)) + return hr; + } + m_IPV6Filter->AddRef(); + *Output = (IUnknown*)m_IPV6Filter; + + return NOERROR; + } + + if (IsEqualGUID(refiid, IID_IBDA_IPV4Filter)) + { + // construct scanning tuner + if (!m_IPV4Filter) + { + HRESULT hr = CIPV4Filter_fnConstructor((IBDA_NetworkProvider*)this, refiid, (void**)&m_IPV4Filter); + if (FAILED(hr)) + return hr; + } + m_IPV4Filter->AddRef(); + *Output = (IUnknown*)m_IPV4Filter; + + return NOERROR; + } + + if (IsEqualGUID(refiid, IID_IBDA_EthernetFilter)) + { + // construct scanning tuner + if (!m_EthernetFilter) + { + HRESULT hr = CIPV4Filter_fnConstructor((IBDA_NetworkProvider*)this, refiid, (void**)&m_EthernetFilter); + if (FAILED(hr)) + return hr; + } + m_EthernetFilter->AddRef(); + *Output = (IUnknown*)m_EthernetFilter; + + return NOERROR; + } + if (IsEqualGUID(refiid, IID_IBDA_NetworkProvider)) { *Output = (IBDA_NetworkProvider*)(this); @@ -163,7 +211,10 @@ CNetworkProvider::CNetworkProvider(LPCGUID ClassID) : m_Ref(0), m_ReferenceClock(0), m_FilterState(State_Stopped), m_DeviceFilters(), - m_Tuner(0) + m_Tuner(0), + m_IPV6Filter(0), + m_IPV4Filter(0), + m_EthernetFilter(0) { m_Pins[0] = 0; diff --git a/reactos/dll/directx/msdvbnp/precomp.h b/reactos/dll/directx/msdvbnp/precomp.h index 4294d42d198..c9abe7ac000 100644 --- a/reactos/dll/directx/msdvbnp/precomp.h +++ b/reactos/dll/directx/msdvbnp/precomp.h @@ -82,6 +82,30 @@ CEnumMediaTypes_fnConstructor( REFIID riid, LPVOID * ppv); +/* ethernetfilter.cpp */ +HRESULT +WINAPI +CEthernetFilter_fnConstructor( + IBDA_NetworkProvider * pNetworkProvider, + REFIID riid, + LPVOID * ppv); + +/* ipv6.cpp */ +HRESULT +WINAPI +CIPV6Filter_fnConstructor( + IBDA_NetworkProvider * pNetworkProvider, + REFIID riid, + LPVOID * ppv); + +/* ipv4.cpp */ +HRESULT +WINAPI +CIPV4Filter_fnConstructor( + IBDA_NetworkProvider * pNetworkProvider, + REFIID riid, + LPVOID * ppv); + #ifndef _MSC_VER extern const GUID CLSID_DVBTNetworkProvider; #endif From a2645d72f70a30370c08be09a0549500a351a200 Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Mon, 29 Mar 2010 15:18:50 +0000 Subject: [PATCH 092/134] - Add bda.inf, kscaptur.inf svn path=/trunk/; revision=46570 --- reactos/media/inf/bda.inf | Bin 0 -> 17242 bytes reactos/media/inf/inf.rbuild | 2 ++ reactos/media/inf/kscaptur.inf | Bin 0 -> 48292 bytes reactos/media/inf/syssetup.inf.tpl | 1 + 4 files changed, 3 insertions(+) create mode 100644 reactos/media/inf/bda.inf create mode 100644 reactos/media/inf/kscaptur.inf diff --git a/reactos/media/inf/bda.inf b/reactos/media/inf/bda.inf new file mode 100644 index 0000000000000000000000000000000000000000..dab09018b89273be52995adc1eaef73da5b1bad0 GIT binary patch literal 17242 zcmeI4YfoEA5{CQpO8XxWTE1bgv5her@xd2h&<4T+lV~=qB4ZmS3L%kACX07hrp#H^` zRkGwNsFd4w zS-d-X+Z%8)UK=jm`VC(LjW<>DjcQTDEV3uMJMORg-O_JSf4SO}RC)c)d-+QKt}vtm zrB|ZWm8>o4@>beBlBN3k+tS_bz`i_d>+YkManHR~iCD8IqJaMT($L>zrM#E>MiN4) zCtCNq1}|`|sbptRV$apZzor_eo<4Q%Cf44Rc0&1vr`i?n-iyQMx$2y#ELujZS<=Py zPrW23;_`0J8ivDrmF`X95adVeSRJ&ab)IMoc}^rTdOVVb@)JuMCc4t0wQbLh>gR_k zdZl)(6I##|ty^!=An~LU)NV+#A7q8#iy)yc$y-Ca(#CxB-gHfgSZ~=SVzkF4;LLYA zhVwq&Sfu&`$*~n<&y2AjTV!(ifQ#iK*{p?Cq5J#9bAoB&ClN7;2~FM8{~DgrQ4+hk zqlT5)Q{3P3{$ZXNTQ&Bg(Q+XYk9urUuI6KdMTlvXCiyLt3hJBsiWtb-Rg9$vy;Q_V z`nCR`w;&EJgHjSL0&*u|+jRST?xz;_Kf`d)G+4sYmQ^HZj$`xhS>Kz(yylN+N(@_O zc92HmtQ^pMKhz;Vc}OOeu5Fp^X#MF?=X+()4P|4SZbNx7;~vZNkCkDOFLp=d;YnX* zFZB(hmHZ(0x=_Y`r}sU*qeV|edsEUP?`TV3uUw7;-+y$~>W+Gi&&vEPfB&t>*Kp4? zK4L^^60Oo=_hmi46m21B_b)F4)3Rla^oCkp?SQ<)3^GuNd7jmrcu0}(Ql2*WpjmS z^3^a?ns0{2dSrUOXYN>-+|X~B>r3}naZhTriPQP0SFH)(ef7x~is2igmF``v4jHZW zIeGQparuCQ<;%f%udm2%GoRxgn0VvzWMDq(h2}!%(L+-9Y50GO_8+VL`*XEElw4lh z1I0~0(qFaZPlW6G+&&POUY-VGst?ryQt(Y8$vk7O@i=nkv+L*TftbU^57rf1Kt(}U z^b_mqm&m}$MQ{BKM_wg=(RWS$%FH-x8}C&AjY^+KPnh$$k#&*IxRb0oAp3^fgnA)7)?LkQ;Y)1$^Xf@_m>KK+E&F_T4>fZrt^G}?*;CF5_H8M8Gb z=5dK6qpLiY`^@sUBqAPo{XMTxny$IgRwSAmf3qyjy;S7A z7$UB*0?Y-D!8b-VmmSBaYc9|BHFrQ5E?DA~?Nn~4v?{s9Ju&SFC zkz-vEThc9#`*da*S%J5;`*bWx$0afmxTYg@nlk<0&7hA@XG!t;k(Gj0dVPNs1sm%5 z;n$Z%iLo8w(&}2i#NGv@VhtawlQ%Jczzzwn(sK#O6Weh*ZPpW7>hVk?G4-Q=B6HNm$)TOjf3m%wQohh zZ$dY=%Hy>aZ1PrmO79m+I4*9VL(#@#ej4u62;-Pb#p@3PPsX3{`@G^rPa}jlE{FBL zI6mMLVK<4z2lH!27GZ~o?fc1lwBz?^DwI0*(ZlRX{)$J8mto9uqc!BF-m}h_T`ok7 zGaq$&GfE{f%SLd4E7B#S$FN>be;c^79MtOmJRoMvGM%dwt8zYzDP z5An{&@LeTlv*eqGSjs2;;37!P=Db>*Vo9l`U5@ zY(9qbqd0&x#(!5y`x_{k-;4&GCDf{z!jsjmcDJB z;9!)&tZP+s0$P+s;<8dxWw~l#MNZSobh9hXje71J-w>uLSK;Z zE9u#;Y}rt$G`}4^r#`C~llXyw^qwr^dmu>*;Z+R)r>feFhk>rHqzCID0U4^Edd16E(OpGPE0LA0zqj23*=ya_ z&Zg%Hs=+mOgeI}j&~-K7%SpyvJ=>N(s*-hI{7d>$l4n7yX)DLx%>26XEQ`XfxKzXw zOcSHqvMZ+|t*v-c%eRVWJL1HNKy*M4SkV&@7I@BHp*6nvLs7JLWLK!?ycMAw5Dm(& zBny%mqC*z2EzWJ#F6wXKdm<{+*EfxCx=(_~VtrCrubaF&XnbjB-TNfyz;Drj#gN2< ziB{mw+RM2cq6JZdKC+}wXs^Xa>=^HP16}O%GM**rw4*O;)$qrTWKk_$8Bf|@)qDKP zc(zrptS2FAbfur^Jk58FBk|Q@WK$G~N%VsB<$+@or@-2*IF;SXWOdoNg8PbeTb8VN zA9OiAYy63hWB|K*N;EL8firmBQXO{SOmAmc17Sa*@g?pPlkj!oUrw|R{58HqFM-Ec zUcp<=A=mWX@;IQsYU*v$3o$z2``zGoP4$@{C0g}0Bg$#%_ue~s@-MyZ4EH9{SKO#n zQlG2zp2^R{x#x7|Wa|JqwTm;_J#k>qQ#^LGJaQ7X?7S#YC3}HlI03yTsYdgt>Ga3* zpLMT0;xT4bA57Y<3NQ1*L*X%}yqMJtMn;?;=!tre z75*`mI9_o5vv519Y~ts3HK|lZ-ixF+vK4*lxby)x z^WgT-)B4r7o)K}^YsGdn5*N%acpi.inf audio.inf battery.inf + bda.inf cdrom.inf cpu.inf display.inf @@ -13,6 +14,7 @@ intl.inf keyboard.inf ks.inf + kscaptur.inf layout.inf machine.inf msmouse.inf diff --git a/reactos/media/inf/kscaptur.inf b/reactos/media/inf/kscaptur.inf new file mode 100644 index 0000000000000000000000000000000000000000..aa93ffb61b51e1a1b44a4d1fa83799eceaa78a1f GIT binary patch literal 48292 zcmeI5>24f3lE?G&0{aevu>xiQNvm5H8vdZOTbTBN_BFlsq9K)z_KpuhCA;0*@Y~K~ zEOz(*V-!W^omrV#l7L2`u1t~<493M^B>8{;`zCpnoF!MuIC+2d?gSCAEFspVZoMGE&P= zRnph`QP+M~d!KdvP_4h8z@*mu=-!fpeC{CaxjSQrf#Dahe60GXDtnwM`F-*-IZF0j zZ{`wO|07vf$+cutHMaFRN*48NEm=)A^lL@0k^V0xC&{^ft?1Ws@=)((l{nFz75!S% z=fmWigY``G`jmVT>{H#nnm{sG^GUk*^RC9eO1)DJO512WQkz@Jzw2{FpR4-j*Mcxw z()W_CY`SYp4$n>XfKlW9MtwUIMXnv47(W}=eSI^^HolZO7i~U^g4Z`Stjr@pSaEH= zQkmC!?I({NoF!NC{muALa@m#KQ;*;44TMXz3&pqw1xC8ISp)DET3#KYk9PQS*Y-V6P^)Ei7M zgv%3sgCX~x>FQ@)JrZB@-*}KV=+i>7tCGjA|BNjC1HaEI{Zw!JA7ezHpmLzrSlkw4 z35R7VN-Zb^rMwhSFOAJobZ;TmX89e17TSbH?Z*uKUJ5&C0d1fbG)6}*x9!px#5ogH< zNfegpoh0_uNxo^-vD04*y81x!g8tuA$s_4abn7G48z;Xyt-7Y`)ci8BX4AL*v!vja z+I}bOKC8W7COY&~I^liC)?X$+tL>jBm|Oec-MwY7{#leTn)KW9E496?maj$alL=M& z!WwG4tialINIj2HB5kLP$BIXhR*QJYUr*DIt3`e1I&XZjV8smX57K)-%Kk1S^ZN8Y z4PL}pnBtpZd&au=T(!;T_@uILGgp>$_wdG=BL`Tgv1(%ehgO)i_2T}@1v|BGxw2t3vBZop&A^sko-e-@LE@~cVM?9 z`}5U}Hhf7dF*csIkAI7io!wMfXN=GNvhbQ#?) z_{?H-hs3YV=vIyJmf|&sF2=R4u|;;bB&mltvU}>T?Woj4$(xtmW&PgPHLh+;ayLt5 z_wSPJ<65ch4~wSb`c<xZoA+jRQb3fLZsZQc{nb76CA#&_w=%n)y^zkuqLUHwRi9OwCttQ(Z}aWVuHSpIp;djg``!BI zVa!SvpF0nYyq2n-#ihFSFK%geBlkjfh+GEmu~+pqU$$G1^X<*9->hg|xk1so?6OvgHr#5_xjtEE z8flG*m7{DvHCfHJ&U7rVku_p!Zn$-(<7k~J&d&WM<5!-`*Ze`U!`dfv-5>PJ=HvA% z$o*m3GzMB6=_`vF&knyfanLes&lS;L74^3?(yaKCM}MO4(;sh`8ZL>nsBVRm= zYbWV_VK~fq_ea4x{Q4O0LnrAwPSS0>4>V&U)5pf!XAFNhXfT%w+ zU!Lzv^I3B(&<(rcwZO3W-489$jRsX(pa}=vjvnaR=U5NW*6r(ojluLlv4_w4xQ~g| zWrN2yryHKbYlLC(yB`{%8x5*7LOWi%9o^8i_pxrEt=rcP>+%nV@e#s0G9Cgm1pHNU zg6x^a=AJ?~9EaBn!{T>8^g=fpROyB0d~`cHp=-}$oj_Z6K_?LX86tMTGl*m^T}l(2 zx;#9aN8~d)L*6CNuf<-%x{FOsi`^`=K^N-P;dfuOK^GcSX@e#lbX$6$Tc6Wnef4J32864O?T0A@a?yeT-j|Np*Ang-`*k|x5 zXQu=D>~X9EEOx;2*9%S}7xZgKzmY|*@DzUc7~<^cv@5*VWXadng98_jB;LuB+Kalj zrRXME1$?qc+oB?!?AW%WwaFd*rVe^&t9140C|a4Q&dHcXEWOX(#$2(c6}Saafk^ST ziwHw4V#HjBLPU`HC4t6 z=YZeajw|4D@=wT4SW`@ir`uQcI?;7js@LU5Zs~n;Pq?Db-o{)p5)~Fi1;&?kKE|Es z0=o<`vaBu~J5E@4zaNSV&>kawJ{0}AOL=xngmWkljVWV$F|tBBJFX!AWW&Ke(I>nB zkDlohU2*O(hbvgW!s~kIzTpJ)$GP4k{Tkg9uIRJ3F<011(omm1&#h<`ij1OVY3_CD zZn6h>YIZ|>NURAja^GD;ukSngM$Y$LF2cIXV*%_{mT7P#ZXD;Hf?-{gyt3d042xS6 zFY=3`UC3Gb8PT$QgZ}7NhuhutAp4_1nFra7cV?&U`s{Hm|41I%9Ip{+#1Ft5Ko0qh z4L}n83N!M^74taJ{>UVCu`9@>U!6uetK^^6YwYxvVmybcNi>Q5gvcyo-(E6H@%0V` z!LrTRw|7hTHdK0Bp2&{w#e0@yGYOik9~Mb}f0)%t7~I!R`e%pRZArg>Zm>xPibWr$ zjq{bseiOdwOY&#g+gR?gs>nAIY?&piPL6Gku-$bm z96Ft0J6S(ec`x_(kxC(|jLxH<%%jj!%&5_g$RM9k0iA^pjkZK<;Z;)-oke}hqqVq; z=Co`bbQdjG=jp7ftrh9H1GQp$aaVQFz-UPPSavVp5o~hu7hT(A^;xDp-tdmzdyPEY zHhFse;nlx>oE>iWK|cG?IU;&v>r9 z=dKf{KvP&`1vw{s9E0#+LpBHhF~75WpbMFAGZb3VudHV$D9)U4s?e#3Zhqsy1p&w zL>Kq<9q(6}^&igJ4n;nTlX?2lG;xZPE)xFSy2)rjx7k>_cKO^rS~ zmSRf}_1k6}YvLDT%*1BNk|#z+By~$yu<%Os`Gtl^I#-|` zD-Osq^h3r?-fixP_XHg&&lQU|T3i}>ny=(#{611Cs}0dZ_;vId-GtwW?}t{xVpw*z z&A92m*Pc)Z{Y11K3ZkQYq#iwG{nXhhN)q?n~>1CwH(zoJEn%iR$M0z14F%mY3xzl6wX588p4J7k2v^=o!(OPZu+zBBw?2!L z=A?CjXlK8EQC)KDj?^=-`ChqkPu0&IeY5X@m9#z5MvhlGiHVZ)irj4Jll>Xe`1>=G ziJfQfYE5<4`>3A^KC9n^7@etD2U+yzf__W&TcIy!c$Q za-_(^@HBib31PqRX0!_@DVW~!Pp{&C*?uc&IUe7%j{Z0oH+Wk6G0UH^S)|Y4te?cM z?6ET|x&++^#OdhslcS35;z#@_OPv72#=uj_R%}M{YpFYu45h6lIsBjX-0)jb<&$3Q zY4b!{^hh!Ywr|Bb_F8azPF<;;-=yELdT3jd%eaO?n9e4Zo$6UMl3D#dJcpaTi7nTk zmI*$qvgW}`G~@fYyq9pi(7a{;(=wHNM&6!yspkw&c8x3Zl6?6;EmM4M&!3j5$m`Bp z?x8GGv2Pt)n&CD66InY>K`6J|F+R*Y(lugQkvZ{1Ruf&8-5D-z&Do(BsA)@{ZW*dy zOsu)tTAO2;KK5t+Qi{FjuH{QV*X-(%-tqb6cJ+lT^?8|By8_$Mu8a|zEjxQG)vud z6r~6nJ>=BnKA;uvfds!5L8fYeZfN>ieT^*W?wL{2=83nst6K0kM{*Bdrm?TyptZ`g|iBZ zAn^oqUp-4d<8IJaWMRnJBUhFu5O{82P5+T$cGBi~EA;Wcw3R(=Pc}3eyJSI<1Idc` zZh@64K9|6tZmC6{IbrW%o*AK!WDx>^{IpfIZdsS6o5>_(ml3iq$x~y+m#0s@O>A4p zcR}M5w~OQaz>_aoij{QT4Yvq}S%H8D-pW`p2zK4Y;*SOQd9>d^-#F#ry;US+ zJb9k%Oqh5KAB*CgW@zW$69E_tL&N8jqEXj3F%fnECTdOQ4SnI>+vK&b;njUoxv_k( zCyGL4Df&vSUg@sw+xAwa14PbJC4K|cVw}bUV-xp(Ebd#K;PFa5e682M`W=^vX_WRT z=2R}k{^wMm%<#EM8;j9+&xwQmy)^y)GNCAV{B?p!I!0t;^HeRoP}v<9^J_9Tb)%Ao zVq;Mp7XpJnB$vn@d7*f^SP;(rIMvI0#CSF*8dsll8a(0+(P^aGtNQ*n>7~KS&gKmk zo;I@#o-MUpHR|$|nTN%%9jAfJ-!R_{O|h#Nx&`g!VFeqXjos`|Y*!j0J?RhPZ2IUU zA0bi_b0<+JqpfLdJXtc7nOQKhygY5u$TqX^v?Y^xL)XX{M(guLu%~Sv?ri$&*8{R6 zdU`XWSTbzco;ZTu!4u4=urlZ%>^OILewaNWm@~oSc=ycR4)o^q0+Wp}Un`5I7=5vs zoRI*%$o}@v4}_T;+_f!O+bVHS4x~1J`E5%zi(V%-#(yPq6T;CeLVM&u#A$ zg7f~3Mt z^mb3s>U*1x4HR=Qo(cQZpl3LR23Z}6K0E(|t z%(&lGkq+zsw%`ycV7HW!UhvV1pdwf6`p@1YT;ut6PDfeRr#-h0{-?T13?WDpk%8}A zeBe7-5-5J*){Dl;ulmo4oAi|RssGm9Q(YsnfPJOpcv6#Ac&B|8PRY*B{$mQ8hi#x=!I<48@OZ{l%_qY!x>F|J6r25kdn zL?FRT5+Fd+BIE_?InLG?&j_%hpNH$HTvDxwPCupY)Y%`Mm6T-Yvdk_2Du0zYWhl z{9RU>HESUHyR^h}SeLqUAuSnZBFEwje@^pU#N%_5R?48{FhvG6bE@@*CoxcDzD!Suj0|qYp5z|wH`KUsT;0=<9${hbJuXDL^Dd(wbBho zVvWUn+&9CnynZ*l(!CCQCO5;XtoHOcg%;DERy{stHQVEYwfRL-U9}@%Jw8>nr^l&W z-s>?cuRA?Hf$DjWtXeme)eN}!a|o-osUNNEZXEUW$kqsu!x@N8U}rt_c&7xg@bk2} z0!uNL#ov*ybRqq~ik8JTilO>=&zniqhMp4*T2j1;e2}fgo{?aj!}{0|@u2UW_w-K( z#eAqd%yhoXG*OuY`QVrG7>_6YWY%+))I$w1hiRaO+D+iK(^BcuP1-M>H`eiXajiVO zbi5`T9f_gDR{SnRe>`ve)A2^|<-M%+75{nVR`giMWajXBGGmCL#50oqBS7>ljsX!J zMe0o^O!fjccQpxt7`)|Fp=+OT--hoy=I>hy? zl$SxQj}8H=4v(tVi=sq%x$Xib@Lk?JDZ9rC;`IG0_puoB^1I!jhQ8!yXl3{Mf*8kX zrimuCq4rR5C2an=lapUv+^=b537NCl(yZf3Z7~j!r8YRnRzL7jyEslB)8bZrWTy>& z)5MkX_@pCCZQxf&hLHH`IS^0v1-hnn)S|q6wEIVAw|F`i9nVv}U|7#@!^fBUz^|AW z@>;B(j!jzXho)h~hK)D%LErMYQ8Vr=uRjDW`-?wyrCk`~14*0r8f{gknitDzPERi% z;i!rz)sJRX?e4ghdp7l$mDlZ#R~U`7cCE*%tY&wdvT>(+T(UK~;^5~O%r3KgdxFj1 c#Pd8`jinh^SfO<6>Yd78$&<3ERFQ@Hf5=)R{r~^~ literal 0 HcmV?d00001 diff --git a/reactos/media/inf/syssetup.inf.tpl b/reactos/media/inf/syssetup.inf.tpl index f1c7ff67ce6..6683f580928 100644 --- a/reactos/media/inf/syssetup.inf.tpl +++ b/reactos/media/inf/syssetup.inf.tpl @@ -28,6 +28,7 @@ scsi.inf usbport.inf audio.inf ks.inf +bda.inf [RegistrationPhase2] RegisterDlls=OleControlDlls From 4102dbabef82266e0a52d9c90eb635c916d0e256 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Mon, 29 Mar 2010 16:56:42 +0000 Subject: [PATCH 093/134] [NTOSKRNL] - Don't try to detect ACPI in IopEnumerateDetectedDevices because the only reason we got there is because ACPI is NOT present (as reported by IopIsAcpiComputer) svn path=/trunk/; revision=46571 --- reactos/ntoskrnl/io/pnpmgr/pnpmgr.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c b/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c index 71cfde10cab..ff43f2397f8 100644 --- a/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c +++ b/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c @@ -2166,11 +2166,6 @@ IopEnumerateDetectedDevices( const UNICODE_STRING IdentifierPci = RTL_CONSTANT_STRING(L"PCI"); UNICODE_STRING HardwareIdPci = RTL_CONSTANT_STRING(L"*PNP0A03\0"); static ULONG DeviceIndexPci = 0; -#ifdef ENABLE_ACPI - const UNICODE_STRING IdentifierAcpi = RTL_CONSTANT_STRING(L"ACPI BIOS"); - UNICODE_STRING HardwareIdAcpi = RTL_CONSTANT_STRING(L"*PNP0C08\0"); - static ULONG DeviceIndexAcpi = 0; -#endif const UNICODE_STRING IdentifierSerial = RTL_CONSTANT_STRING(L"SerialController"); UNICODE_STRING HardwareIdSerial = RTL_CONSTANT_STRING(L"*PNP0501\0"); static ULONG DeviceIndexSerial = 0; @@ -2460,14 +2455,6 @@ IopEnumerateDetectedDevices( DeviceIndex = DeviceIndexIsa++; IsDeviceDesc = FALSE; } -#ifdef ENABLE_ACPI - else if (RtlCompareUnicodeString(&ValueName, &IdentifierAcpi, FALSE) == 0) - { - pHardwareId = &HardwareIdAcpi; - DeviceIndex = DeviceIndexAcpi++; - IsDeviceDesc = FALSE; - } -#endif else { DPRINT("Unknown device '%wZ'\n", &ValueName); From d42e771516af3ede59617cb4e1bc84012c5b3828 Mon Sep 17 00:00:00 2001 From: Sir Richard Date: Mon, 29 Mar 2010 21:35:31 +0000 Subject: [PATCH 094/134] [HALACPI]: Add project, right now it just builds the normal HAL. The idea is to split the generic HAL into legacy (x86 only) and ACPI (x86+ACPI, or x64). Bus handling, reboot/shutdown, PnP, power management (sleep/resume/hibernate), timer, environment variable, debugging, and initialization code is expected to differ between legacy and ACPI, if not more. svn path=/trunk/; revision=46574 --- reactos/hal/halx86/directory.rbuild | 1 + reactos/hal/halx86/generic/acpi/.gitignore | 0 reactos/hal/halx86/generic/legacy/.gitignore | 0 reactos/hal/halx86/hal.rbuild | 2 +- reactos/hal/halx86/hal_generic.rbuild | 48 +++++++++++++++++++- reactos/hal/halx86/halacpi.rbuild | 20 ++++++++ reactos/hal/halx86/halamd64.rbuild | 2 +- reactos/hal/halx86/halmps.rbuild | 2 +- reactos/hal/halx86/halxbox.rbuild | 2 +- 9 files changed, 72 insertions(+), 5 deletions(-) create mode 100644 reactos/hal/halx86/generic/acpi/.gitignore create mode 100644 reactos/hal/halx86/generic/legacy/.gitignore create mode 100644 reactos/hal/halx86/halacpi.rbuild diff --git a/reactos/hal/halx86/directory.rbuild b/reactos/hal/halx86/directory.rbuild index 81a989facea..abedef8ea1c 100644 --- a/reactos/hal/halx86/directory.rbuild +++ b/reactos/hal/halx86/directory.rbuild @@ -8,6 +8,7 @@ + diff --git a/reactos/hal/halx86/generic/acpi/.gitignore b/reactos/hal/halx86/generic/acpi/.gitignore new file mode 100644 index 00000000000..e69de29bb2d diff --git a/reactos/hal/halx86/generic/legacy/.gitignore b/reactos/hal/halx86/generic/legacy/.gitignore new file mode 100644 index 00000000000..e69de29bb2d diff --git a/reactos/hal/halx86/hal.rbuild b/reactos/hal/halx86/hal.rbuild index 2c672c2f5f4..b551cc3308c 100644 --- a/reactos/hal/halx86/hal.rbuild +++ b/reactos/hal/halx86/hal.rbuild @@ -8,7 +8,7 @@ include - hal_generic + hal_generic_legacy hal_generic_up ntoskrnl libcntpr diff --git a/reactos/hal/halx86/hal_generic.rbuild b/reactos/hal/halx86/hal_generic.rbuild index 154379fa8a9..4fcb90bb3c0 100644 --- a/reactos/hal/halx86/hal_generic.rbuild +++ b/reactos/hal/halx86/hal_generic.rbuild @@ -1,7 +1,53 @@ - + + include + include + + + + + bushndlr.c + isabus.c + halbus.c + pcibus.c + pcidata.c + sysbus.c + + beep.c + bios.c + cmos.c + display.c + dma.c + drive.c + halinit.c + misc.c + profil.c + reboot.c + sysinfo.c + timer.c + usage.c + + + portio.c + systimer.S + trap.S + + + + + x86bios.c + systimer.S + + + + + hal.h + + + + include include diff --git a/reactos/hal/halx86/halacpi.rbuild b/reactos/hal/halx86/halacpi.rbuild new file mode 100644 index 00000000000..7d22a84b79f --- /dev/null +++ b/reactos/hal/halx86/halacpi.rbuild @@ -0,0 +1,20 @@ + + + + + + + include + include + + + hal_generic_acpi + hal_generic_up + ntoskrnl + libcntpr + + halinit_up.c + halup.rc + + + diff --git a/reactos/hal/halx86/halamd64.rbuild b/reactos/hal/halx86/halamd64.rbuild index 4a09aa2c838..6b52fdef9e5 100644 --- a/reactos/hal/halx86/halamd64.rbuild +++ b/reactos/hal/halx86/halamd64.rbuild @@ -10,7 +10,7 @@ - hal_generic + hal_generic_acpi hal_generic_up ntoskrnl diff --git a/reactos/hal/halx86/halmps.rbuild b/reactos/hal/halx86/halmps.rbuild index ad17eac9002..2570cb84620 100644 --- a/reactos/hal/halx86/halmps.rbuild +++ b/reactos/hal/halx86/halmps.rbuild @@ -9,7 +9,7 @@ - hal_generic + hal_generic_legacy hal_generic_mp ntoskrnl libcntpr diff --git a/reactos/hal/halx86/halxbox.rbuild b/reactos/hal/halx86/halxbox.rbuild index cee7f614e90..54423ab9075 100644 --- a/reactos/hal/halx86/halxbox.rbuild +++ b/reactos/hal/halx86/halxbox.rbuild @@ -8,7 +8,7 @@ - hal_generic + hal_generic_legacy hal_generic_up ntoskrnl libcntpr From 98782624bfc77260dbb3b459e5d5bdd398a802fe Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Mon, 29 Mar 2010 23:08:29 +0000 Subject: [PATCH 095/134] - Fix trunk installation breakage introduced in 46570 svn path=/trunk/; revision=46576 --- reactos/media/inf/syssetup.inf.tpl | 1 - 1 file changed, 1 deletion(-) diff --git a/reactos/media/inf/syssetup.inf.tpl b/reactos/media/inf/syssetup.inf.tpl index 6683f580928..f1c7ff67ce6 100644 --- a/reactos/media/inf/syssetup.inf.tpl +++ b/reactos/media/inf/syssetup.inf.tpl @@ -28,7 +28,6 @@ scsi.inf usbport.inf audio.inf ks.inf -bda.inf [RegistrationPhase2] RegisterDlls=OleControlDlls From c0add4aee86b61cb384c10845a1bbadd1dc410a5 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Tue, 30 Mar 2010 03:26:35 +0000 Subject: [PATCH 096/134] [RTL] - Fall back to the default user key if RtlFormatCurrentUserKeyPath fails (perhaps we are in a system process) svn path=/trunk/; revision=46578 --- reactos/lib/rtl/registry.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/reactos/lib/rtl/registry.c b/reactos/lib/rtl/registry.c index e302590ebcc..d6e4458981b 100644 --- a/reactos/lib/rtl/registry.c +++ b/reactos/lib/rtl/registry.c @@ -474,13 +474,23 @@ RtlpGetRegistryHandle(IN ULONG RelativeTo, /* Check if we need the current user key */ if (RelativeTo == RTL_REGISTRY_USER) { - /* Get the path */ + /* Get the user key path */ Status = RtlFormatCurrentUserKeyPath(&KeyPath); - if (!NT_SUCCESS(Status)) return(Status); - /* Append it */ - Status = RtlAppendUnicodeStringToString(&KeyName, &KeyPath); - RtlFreeUnicodeString (&KeyPath); + /* Check if it worked */ + if (NT_SUCCESS(Status)) + { + /* Append the user key path */ + Status = RtlAppendUnicodeStringToString(&KeyName, &KeyPath); + + /* Free the user key path */ + RtlFreeUnicodeString (&KeyPath); + } + else + { + /* It didn't work so fall back to the default user key */ + Status = RtlAppendUnicodeToString(&KeyName, RtlpRegPaths[RTL_REGISTRY_USER]); + } } else { From ce874eb1b40513c27e55cfa035c2795a77fe79f5 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Tue, 30 Mar 2010 05:09:48 +0000 Subject: [PATCH 097/134] add PIO_CSQ_INSERT_IRP_EX to wdm.h svn path=/trunk/; revision=46580 --- reactos/include/ddk/csq.h | 2 ++ reactos/include/ddk/wdm.h | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/reactos/include/ddk/csq.h b/reactos/include/ddk/csq.h index 99056f610a8..cf7b2c14ce3 100644 --- a/reactos/include/ddk/csq.h +++ b/reactos/include/ddk/csq.h @@ -229,9 +229,11 @@ typedef struct _IO_CSQ_IRP_CONTEXT { } * */ +#ifndef IO_TYPE_CSQ_EX typedef NTSTATUS (NTAPI *PIO_CSQ_INSERT_IRP_EX) (struct _IO_CSQ *Csq, PIRP Irp, PVOID InsertContext); +#endif /* * CANCEL-SAFE QUEUE DDIs diff --git a/reactos/include/ddk/wdm.h b/reactos/include/ddk/wdm.h index 3308de9c286..4dd5ae3abc9 100644 --- a/reactos/include/ddk/wdm.h +++ b/reactos/include/ddk/wdm.h @@ -5191,6 +5191,13 @@ typedef VOID IN struct _IO_CSQ *Csq, IN PIRP Irp); +typedef NTSTATUS +(NTAPI IO_CSQ_INSERT_IRP_EX)( + IN struct _IO_CSQ *Csq, + IN PIRP Irp, + IN PVOID InsertContext); +typedef IO_CSQ_INSERT_IRP_EX *PIO_CSQ_INSERT_IRP_EX; + typedef VOID (NTAPI *PIO_CSQ_REMOVE_IRP)( IN struct _IO_CSQ *Csq, From 7809161280f623bab226eb1613594b21e65e445c Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Tue, 30 Mar 2010 05:34:20 +0000 Subject: [PATCH 098/134] Merge the rest from header branch. svn path=/trunk/; revision=46582 --- reactos/include/ddk/ntddk.h | 5565 +++++++++++++++++++++++++-------- reactos/include/ddk/ntifs.h | 4747 ++++++++++++++-------------- reactos/include/ddk/ntimage.h | 17 +- reactos/include/ddk/wdm.h | 5443 ++++++++++++++++++++++++++------ reactos/include/ndk/ketypes.h | 23 - 5 files changed, 11020 insertions(+), 4775 deletions(-) diff --git a/reactos/include/ddk/ntddk.h b/reactos/include/ddk/ntddk.h index 62c1f7873f1..88aa183ea45 100644 --- a/reactos/include/ddk/ntddk.h +++ b/reactos/include/ddk/ntddk.h @@ -1,12 +1,13 @@ /* * ntddk.h * - * Windows Device Driver Kit + * Windows NT Device Driver Kit * - * This file is part of the w32api package. + * This file is part of the ReactOS DDK package. * * Contributors: - * Created by Casper S. Hornstrup + * Amine Khaldi + * Timo Kreuzer (timo.kreuzer@reactos.org) * * THIS SOFTWARE IS NOT COPYRIGHTED * @@ -18,13 +19,10 @@ * DISCLAIMED. This includes but is not limited to warranties of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * DEFINES: - * DBG - Debugging enabled/disabled (0/1) - * POOL_TAGGING - Enable pool tagging - * _X86_ - X86 environment */ -#ifndef _NTDDK_ +#pragma once + #define _NTDDK_ #if !defined(_NTHAL_) && !defined(_NTIFS_) @@ -41,6 +39,7 @@ #include #include #include +#include /* FIXME #include @@ -55,41 +54,128 @@ extern "C" { #endif +/* GUID and UUID */ +#ifndef _NTLSA_IFS_ +#ifndef _NTLSA_AUDIT_ +#define _NTLSA_AUDIT_ + +#ifndef GUID_DEFINED +#include +#endif + +#endif /* _NTLSA_AUDIT_ */ +#endif /* _NTLSA_IFS_ */ + +typedef GUID UUID; + struct _LOADER_PARAMETER_BLOCK; struct _CREATE_DISK; struct _DRIVE_LAYOUT_INFORMATION_EX; struct _SET_PARTITION_INFORMATION_EX; -// -// GUID and UUID -// -#ifndef GUID_DEFINED -#include -#endif -typedef GUID UUID; - typedef struct _BUS_HANDLER *PBUS_HANDLER; - +typedef struct _DEVICE_HANDLER_OBJECT *PDEVICE_HANDLER_OBJECT; +#if defined(_NTHAL_INCLUDED_) +typedef struct _KAFFINITY_EX *PKAFFINITY_EX; +#endif typedef struct _PEB *PPEB; -#define EXCEPTION_READ_FAULT 0 -#define EXCEPTION_WRITE_FAULT 1 -#define EXCEPTION_EXECUTE_FAULT 8 +#ifndef _NTIMAGE_ -#if (NTDDI_VERSION >= NTDDI_VISTA) -extern NTSYSAPI volatile CCHAR KeNumberProcessors; -#elif (NTDDI_VERSION >= NTDDI_WINXP) -extern NTSYSAPI CCHAR KeNumberProcessors; +typedef struct _IMAGE_NT_HEADERS *PIMAGE_NT_HEADERS32; +typedef struct _IMAGE_NT_HEADERS64 *PIMAGE_NT_HEADERS64; + +#ifdef _WIN64 +typedef PIMAGE_NT_HEADERS64 PIMAGE_NT_HEADERS; #else -extern PCCHAR KeNumberProcessors; +typedef PIMAGE_NT_HEADERS32 PIMAGE_NT_HEADERS; #endif -#define MAX_WOW64_SHARED_ENTRIES 16 +#endif /* _NTIMAGE_ */ -#define NX_SUPPORT_POLICY_ALWAYSOFF 0 -#define NX_SUPPORT_POLICY_ALWAYSON 1 -#define NX_SUPPORT_POLICY_OPTIN 2 -#define NX_SUPPORT_POLICY_OPTOUT 3 +/****************************************************************************** + * Executive Types * + ******************************************************************************/ + +typedef struct _ZONE_SEGMENT_HEADER { + SINGLE_LIST_ENTRY SegmentList; + PVOID Reserved; +} ZONE_SEGMENT_HEADER, *PZONE_SEGMENT_HEADER; + +typedef struct _ZONE_HEADER { + SINGLE_LIST_ENTRY FreeList; + SINGLE_LIST_ENTRY SegmentList; + ULONG BlockSize; + ULONG TotalSegmentSize; +} ZONE_HEADER, *PZONE_HEADER; + +#define PROTECTED_POOL 0x80000000 + + +/****************************************************************************** + * I/O Manager Types * + ******************************************************************************/ + +/* DEVICE_OBJECT.Flags */ +#define DO_DEVICE_HAS_NAME 0x00000040 +#define DO_SYSTEM_BOOT_PARTITION 0x00000100 +#define DO_LONG_TERM_REQUESTS 0x00000200 +#define DO_NEVER_LAST_DEVICE 0x00000400 +#define DO_LOW_PRIORITY_FILESYSTEM 0x00010000 +#define DO_SUPPORTS_TRANSACTIONS 0x00040000 +#define DO_FORCE_NEITHER_IO 0x00080000 +#define DO_VOLUME_DEVICE_OBJECT 0x00100000 +#define DO_SYSTEM_SYSTEM_PARTITION 0x00200000 +#define DO_SYSTEM_CRITICAL_PARTITION 0x00400000 +#define DO_DISALLOW_EXECUTE 0x00800000 + +#ifndef _ARC_DDK_ +#define _ARC_DDK_ +typedef enum _CONFIGURATION_TYPE { + ArcSystem, + CentralProcessor, + FloatingPointProcessor, + PrimaryIcache, + PrimaryDcache, + SecondaryIcache, + SecondaryDcache, + SecondaryCache, + EisaAdapter, + TcAdapter, + ScsiAdapter, + DtiAdapter, + MultiFunctionAdapter, + DiskController, + TapeController, + CdromController, + WormController, + SerialController, + NetworkController, + DisplayController, + ParallelController, + PointerController, + KeyboardController, + AudioController, + OtherController, + DiskPeripheral, + FloppyDiskPeripheral, + TapePeripheral, + ModemPeripheral, + MonitorPeripheral, + PrinterPeripheral, + PointerPeripheral, + KeyboardPeripheral, + TerminalPeripheral, + OtherPeripheral, + LinePeripheral, + NetworkPeripheral, + SystemMemory, + DockingInformation, + RealModeIrqRoutingTable, + RealModePCIEnumeration, + MaximumType +} CONFIGURATION_TYPE, *PCONFIGURATION_TYPE; +#endif /* !_ARC_DDK_ */ /* ** IRP function codes @@ -124,102 +210,118 @@ extern PCCHAR KeNumberProcessors; #define IRP_MN_QUERY_LEGACY_BUS_INFORMATION 0x18 -typedef struct _IO_COUNTERS { - ULONGLONG ReadOperationCount; - ULONGLONG WriteOperationCount; - ULONGLONG OtherOperationCount; - ULONGLONG ReadTransferCount; - ULONGLONG WriteTransferCount; - ULONGLONG OtherTransferCount; -} IO_COUNTERS, *PIO_COUNTERS; +#define IO_CHECK_CREATE_PARAMETERS 0x0200 +#define IO_ATTACH_DEVICE 0x0400 +#define IO_IGNORE_SHARE_ACCESS_CHECK 0x0800 -typedef struct _VM_COUNTERS { - SIZE_T PeakVirtualSize; - SIZE_T VirtualSize; - ULONG PageFaultCount; - SIZE_T PeakWorkingSetSize; - SIZE_T WorkingSetSize; - SIZE_T QuotaPeakPagedPoolUsage; - SIZE_T QuotaPagedPoolUsage; - SIZE_T QuotaPeakNonPagedPoolUsage; - SIZE_T QuotaNonPagedPoolUsage; - SIZE_T PagefileUsage; - SIZE_T PeakPagefileUsage; -} VM_COUNTERS, *PVM_COUNTERS; +typedef +NTSTATUS +(NTAPI *PIO_QUERY_DEVICE_ROUTINE)( + IN PVOID Context, + IN PUNICODE_STRING PathName, + IN INTERFACE_TYPE BusType, + IN ULONG BusNumber, + IN PKEY_VALUE_FULL_INFORMATION *BusInformation, + IN CONFIGURATION_TYPE ControllerType, + IN ULONG ControllerNumber, + IN PKEY_VALUE_FULL_INFORMATION *ControllerInformation, + IN CONFIGURATION_TYPE PeripheralType, + IN ULONG PeripheralNumber, + IN PKEY_VALUE_FULL_INFORMATION *PeripheralInformation); -typedef struct _VM_COUNTERS_EX -{ - SIZE_T PeakVirtualSize; - SIZE_T VirtualSize; - ULONG PageFaultCount; - SIZE_T PeakWorkingSetSize; - SIZE_T WorkingSetSize; - SIZE_T QuotaPeakPagedPoolUsage; - SIZE_T QuotaPagedPoolUsage; - SIZE_T QuotaPeakNonPagedPoolUsage; - SIZE_T QuotaNonPagedPoolUsage; - SIZE_T PagefileUsage; - SIZE_T PeakPagefileUsage; - SIZE_T PrivateUsage; -} VM_COUNTERS_EX, *PVM_COUNTERS_EX; +typedef enum _IO_QUERY_DEVICE_DATA_FORMAT { + IoQueryDeviceIdentifier = 0, + IoQueryDeviceConfigurationData, + IoQueryDeviceComponentInformation, + IoQueryDeviceMaxData +} IO_QUERY_DEVICE_DATA_FORMAT, *PIO_QUERY_DEVICE_DATA_FORMAT; -typedef struct _POOLED_USAGE_AND_LIMITS -{ - SIZE_T PeakPagedPoolUsage; - SIZE_T PagedPoolUsage; - SIZE_T PagedPoolLimit; - SIZE_T PeakNonPagedPoolUsage; - SIZE_T NonPagedPoolUsage; - SIZE_T NonPagedPoolLimit; - SIZE_T PeakPagefileUsage; - SIZE_T PagefileUsage; - SIZE_T PagefileLimit; -} POOLED_USAGE_AND_LIMITS, *PPOOLED_USAGE_AND_LIMITS; +typedef VOID +(NTAPI *PDRIVER_REINITIALIZE)( + IN struct _DRIVER_OBJECT *DriverObject, + IN PVOID Context OPTIONAL, + IN ULONG Count); -/* DEVICE_OBJECT.Flags */ - -#define DO_VERIFY_VOLUME 0x00000002 -#define DO_BUFFERED_IO 0x00000004 -#define DO_EXCLUSIVE 0x00000008 -#define DO_DIRECT_IO 0x00000010 -#define DO_MAP_IO_BUFFER 0x00000020 -#define DO_DEVICE_HAS_NAME 0x00000040 -#define DO_DEVICE_INITIALIZING 0x00000080 -#define DO_SYSTEM_BOOT_PARTITION 0x00000100 -#define DO_LONG_TERM_REQUESTS 0x00000200 -#define DO_NEVER_LAST_DEVICE 0x00000400 -#define DO_SHUTDOWN_REGISTERED 0x00000800 -#define DO_BUS_ENUMERATED_DEVICE 0x00001000 -#define DO_POWER_PAGABLE 0x00002000 -#define DO_POWER_INRUSH 0x00004000 -#define DO_LOW_PRIORITY_FILESYSTEM 0x00010000 -#define DO_SUPPORTS_TRANSACTIONS 0x00040000 -#define DO_FORCE_NEITHER_IO 0x00080000 -#define DO_VOLUME_DEVICE_OBJECT 0x00100000 -#define DO_SYSTEM_SYSTEM_PARTITION 0x00200000 -#define DO_SYSTEM_CRITICAL_PARTITION 0x00400000 -#define DO_DISALLOW_EXECUTE 0x00800000 +typedef struct _CONTROLLER_OBJECT { + CSHORT Type; + CSHORT Size; + PVOID ControllerExtension; + KDEVICE_QUEUE DeviceWaitQueue; + ULONG Spare1; + LARGE_INTEGER Spare2; +} CONTROLLER_OBJECT, *PCONTROLLER_OBJECT; #define DRVO_REINIT_REGISTERED 0x00000008 #define DRVO_INITIALIZED 0x00000010 #define DRVO_BOOTREINIT_REGISTERED 0x00000020 #define DRVO_LEGACY_RESOURCES 0x00000040 -typedef enum _ARBITER_REQUEST_SOURCE { - ArbiterRequestUndefined = -1, - ArbiterRequestLegacyReported, - ArbiterRequestHalReported, - ArbiterRequestLegacyAssigned, - ArbiterRequestPnpDetected, - ArbiterRequestPnpEnumerated -} ARBITER_REQUEST_SOURCE; +typedef struct _CONFIGURATION_INFORMATION { + ULONG DiskCount; + ULONG FloppyCount; + ULONG CdRomCount; + ULONG TapeCount; + ULONG ScsiPortCount; + ULONG SerialCount; + ULONG ParallelCount; + BOOLEAN AtDiskPrimaryAddressClaimed; + BOOLEAN AtDiskSecondaryAddressClaimed; + ULONG Version; + ULONG MediumChangerCount; +} CONFIGURATION_INFORMATION, *PCONFIGURATION_INFORMATION; -typedef enum _ARBITER_RESULT { - ArbiterResultUndefined = -1, - ArbiterResultSuccess, - ArbiterResultExternalConflict, - ArbiterResultNullRequest -} ARBITER_RESULT; +typedef struct _DISK_SIGNATURE { + ULONG PartitionStyle; + _ANONYMOUS_UNION union { + struct { + ULONG Signature; + ULONG CheckSum; + } Mbr; + struct { + GUID DiskId; + } Gpt; + } DUMMYUNIONNAME; +} DISK_SIGNATURE, *PDISK_SIGNATURE; + +typedef struct _TXN_PARAMETER_BLOCK { + USHORT Length; + USHORT TxFsContext; + PVOID TransactionObject; +} TXN_PARAMETER_BLOCK, *PTXN_PARAMETER_BLOCK; + +#define TXF_MINIVERSION_DEFAULT_VIEW (0xFFFE) + +typedef struct _IO_DRIVER_CREATE_CONTEXT { + CSHORT Size; + struct _ECP_LIST *ExtraCreateParameter; + PVOID DeviceObjectHint; + PTXN_PARAMETER_BLOCK TxnParameters; +} IO_DRIVER_CREATE_CONTEXT, *PIO_DRIVER_CREATE_CONTEXT; + +typedef struct _AGP_TARGET_BUS_INTERFACE_STANDARD { + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; + PGET_SET_DEVICE_DATA SetBusData; + PGET_SET_DEVICE_DATA GetBusData; + UCHAR CapabilityID; +} AGP_TARGET_BUS_INTERFACE_STANDARD, *PAGP_TARGET_BUS_INTERFACE_STANDARD; + +typedef NTSTATUS +(NTAPI *PGET_LOCATION_STRING)( + IN OUT PVOID Context OPTIONAL, + OUT PWCHAR *LocationStrings); + +typedef struct _PNP_LOCATION_INTERFACE { + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; + PGET_LOCATION_STRING GetLocationString; +} PNP_LOCATION_INTERFACE, *PPNP_LOCATION_INTERFACE; typedef enum _ARBITER_ACTION { ArbiterActionTestAllocation, @@ -240,39 +342,69 @@ typedef struct _ARBITER_CONFLICT_INFO { ULONGLONG End; } ARBITER_CONFLICT_INFO, *PARBITER_CONFLICT_INFO; -typedef struct _ARBITER_PARAMETERS { - union { - struct { +typedef struct _ARBITER_TEST_ALLOCATION_PARAMETERS { IN OUT PLIST_ENTRY ArbitrationList; IN ULONG AllocateFromCount; IN PCM_PARTIAL_RESOURCE_DESCRIPTOR AllocateFrom; - } TestAllocation; - struct { +} ARBITER_TEST_ALLOCATION_PARAMETERS, *PARBITER_TEST_ALLOCATION_PARAMETERS; + +typedef struct _ARBITER_RETEST_ALLOCATION_PARAMETERS { IN OUT PLIST_ENTRY ArbitrationList; IN ULONG AllocateFromCount; IN PCM_PARTIAL_RESOURCE_DESCRIPTOR AllocateFrom; - } RetestAllocation; - struct { +} ARBITER_RETEST_ALLOCATION_PARAMETERS, *PARBITER_RETEST_ALLOCATION_PARAMETERS; + +typedef struct _ARBITER_BOOT_ALLOCATION_PARAMETERS { IN OUT PLIST_ENTRY ArbitrationList; - } BootAllocation; - struct { +} ARBITER_BOOT_ALLOCATION_PARAMETERS, *PARBITER_BOOT_ALLOCATION_PARAMETERS; + +typedef struct _ARBITER_QUERY_ALLOCATED_RESOURCES_PARAMETERS { OUT PCM_PARTIAL_RESOURCE_LIST *AllocatedResources; - } QueryAllocatedResources; - struct { +} ARBITER_QUERY_ALLOCATED_RESOURCES_PARAMETERS, *PARBITER_QUERY_ALLOCATED_RESOURCES_PARAMETERS; + +typedef struct _ARBITER_QUERY_CONFLICT_PARAMETERS { IN PDEVICE_OBJECT PhysicalDeviceObject; IN PIO_RESOURCE_DESCRIPTOR ConflictingResource; OUT PULONG ConflictCount; OUT PARBITER_CONFLICT_INFO *Conflicts; - } QueryConflict; - struct { +} ARBITER_QUERY_CONFLICT_PARAMETERS, *PARBITER_QUERY_CONFLICT_PARAMETERS; + +typedef struct _ARBITER_QUERY_ARBITRATE_PARAMETERS { IN PLIST_ENTRY ArbitrationList; - } QueryArbitrate; - struct { +} ARBITER_QUERY_ARBITRATE_PARAMETERS, *PARBITER_QUERY_ARBITRATE_PARAMETERS; + +typedef struct _ARBITER_ADD_RESERVED_PARAMETERS { IN PDEVICE_OBJECT ReserveDevice; - } AddReserved; +} ARBITER_ADD_RESERVED_PARAMETERS, *PARBITER_ADD_RESERVED_PARAMETERS; + +typedef struct _ARBITER_PARAMETERS { + union { + ARBITER_TEST_ALLOCATION_PARAMETERS TestAllocation; + ARBITER_RETEST_ALLOCATION_PARAMETERS RetestAllocation; + ARBITER_BOOT_ALLOCATION_PARAMETERS BootAllocation; + ARBITER_QUERY_ALLOCATED_RESOURCES_PARAMETERS QueryAllocatedResources; + ARBITER_QUERY_CONFLICT_PARAMETERS QueryConflict; + ARBITER_QUERY_ARBITRATE_PARAMETERS QueryArbitrate; + ARBITER_ADD_RESERVED_PARAMETERS AddReserved; } Parameters; } ARBITER_PARAMETERS, *PARBITER_PARAMETERS; +typedef enum _ARBITER_REQUEST_SOURCE { + ArbiterRequestUndefined = -1, + ArbiterRequestLegacyReported, + ArbiterRequestHalReported, + ArbiterRequestLegacyAssigned, + ArbiterRequestPnpDetected, + ArbiterRequestPnpEnumerated +} ARBITER_REQUEST_SOURCE; + +typedef enum _ARBITER_RESULT { + ArbiterResultUndefined = -1, + ArbiterResultSuccess, + ArbiterResultExternalConflict, + ArbiterResultNullRequest +} ARBITER_RESULT; + #define ARBITER_FLAG_BOOT_CONFIG 0x00000001 typedef struct _ARBITER_LIST_ENTRY { @@ -309,6 +441,826 @@ typedef struct _ARBITER_INTERFACE { ULONG Flags; } ARBITER_INTERFACE, *PARBITER_INTERFACE; +typedef enum _RESOURCE_TRANSLATION_DIRECTION { + TranslateChildToParent, + TranslateParentToChild +} RESOURCE_TRANSLATION_DIRECTION; + +typedef NTSTATUS +(NTAPI *PTRANSLATE_RESOURCE_HANDLER)( + IN OUT PVOID Context OPTIONAL, + IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Source, + IN RESOURCE_TRANSLATION_DIRECTION Direction, + IN ULONG AlternativesCount OPTIONAL, + IN IO_RESOURCE_DESCRIPTOR Alternatives[], + IN PDEVICE_OBJECT PhysicalDeviceObject, + OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR Target); + +typedef NTSTATUS +(NTAPI *PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER)( + IN OUT PVOID Context OPTIONAL, + IN PIO_RESOURCE_DESCRIPTOR Source, + IN PDEVICE_OBJECT PhysicalDeviceObject, + OUT PULONG TargetCount, + OUT PIO_RESOURCE_DESCRIPTOR *Target); + +typedef struct _TRANSLATOR_INTERFACE { + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; + PTRANSLATE_RESOURCE_HANDLER TranslateResources; + PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER TranslateResourceRequirements; +} TRANSLATOR_INTERFACE, *PTRANSLATOR_INTERFACE; + +typedef struct _PCI_AGP_CAPABILITY { + PCI_CAPABILITIES_HEADER Header; + USHORT Minor:4; + USHORT Major:4; + USHORT Rsvd1:8; + struct _PCI_AGP_STATUS { + ULONG Rate:3; + ULONG Agp3Mode:1; + ULONG FastWrite:1; + ULONG FourGB:1; + ULONG HostTransDisable:1; + ULONG Gart64:1; + ULONG ITA_Coherent:1; + ULONG SideBandAddressing:1; + ULONG CalibrationCycle:3; + ULONG AsyncRequestSize:3; + ULONG Rsvd1:1; + ULONG Isoch:1; + ULONG Rsvd2:6; + ULONG RequestQueueDepthMaximum:8; + } AGPStatus; + struct _PCI_AGP_COMMAND { + ULONG Rate:3; + ULONG Rsvd1:1; + ULONG FastWriteEnable:1; + ULONG FourGBEnable:1; + ULONG Rsvd2:1; + ULONG Gart64:1; + ULONG AGPEnable:1; + ULONG SBAEnable:1; + ULONG CalibrationCycle:3; + ULONG AsyncReqSize:3; + ULONG Rsvd3:8; + ULONG RequestQueueDepth:8; + } AGPCommand; +} PCI_AGP_CAPABILITY, *PPCI_AGP_CAPABILITY; + +typedef enum _EXTENDED_AGP_REGISTER { + IsochStatus, + AgpControl, + ApertureSize, + AperturePageSize, + GartLow, + GartHigh, + IsochCommand +} EXTENDED_AGP_REGISTER, *PEXTENDED_AGP_REGISTER; + +typedef struct _PCI_AGP_ISOCH_STATUS { + ULONG ErrorCode:2; + ULONG Rsvd1:1; + ULONG Isoch_L:3; + ULONG Isoch_Y:2; + ULONG Isoch_N:8; + ULONG Rsvd2:16; +} PCI_AGP_ISOCH_STATUS, *PPCI_AGP_ISOCH_STATUS; + +typedef struct _PCI_AGP_CONTROL { + ULONG Rsvd1:7; + ULONG GTLB_Enable:1; + ULONG AP_Enable:1; + ULONG CAL_Disable:1; + ULONG Rsvd2:22; +} PCI_AGP_CONTROL, *PPCI_AGP_CONTROL; + +typedef struct _PCI_AGP_APERTURE_PAGE_SIZE { + USHORT PageSizeMask:11; + USHORT Rsvd1:1; + USHORT PageSizeSelect:4; +} PCI_AGP_APERTURE_PAGE_SIZE, *PPCI_AGP_APERTURE_PAGE_SIZE; + +typedef struct _PCI_AGP_ISOCH_COMMAND { + USHORT Rsvd1:6; + USHORT Isoch_Y:2; + USHORT Isoch_N:8; +} PCI_AGP_ISOCH_COMMAND, *PPCI_AGP_ISOCH_COMMAND; + +typedef struct PCI_AGP_EXTENDED_CAPABILITY { + PCI_AGP_ISOCH_STATUS IsochStatus; + PCI_AGP_CONTROL AgpControl; + USHORT ApertureSize; + PCI_AGP_APERTURE_PAGE_SIZE AperturePageSize; + ULONG GartLow; + ULONG GartHigh; + PCI_AGP_ISOCH_COMMAND IsochCommand; +} PCI_AGP_EXTENDED_CAPABILITY, *PPCI_AGP_EXTENDED_CAPABILITY; + +#define PCI_AGP_RATE_1X 0x1 +#define PCI_AGP_RATE_2X 0x2 +#define PCI_AGP_RATE_4X 0x4 + +#define PCIX_MODE_CONVENTIONAL_PCI 0x0 +#define PCIX_MODE1_66MHZ 0x1 +#define PCIX_MODE1_100MHZ 0x2 +#define PCIX_MODE1_133MHZ 0x3 +#define PCIX_MODE2_266_66MHZ 0x9 +#define PCIX_MODE2_266_100MHZ 0xA +#define PCIX_MODE2_266_133MHZ 0xB +#define PCIX_MODE2_533_66MHZ 0xD +#define PCIX_MODE2_533_100MHZ 0xE +#define PCIX_MODE2_533_133MHZ 0xF + +#define PCIX_VERSION_MODE1_ONLY 0x0 +#define PCIX_VERSION_MODE2_ECC 0x1 +#define PCIX_VERSION_DUAL_MODE_ECC 0x2 + +typedef struct _PCIX_BRIDGE_CAPABILITY { + PCI_CAPABILITIES_HEADER Header; + union { + struct { + USHORT Bus64Bit:1; + USHORT Bus133MHzCapable:1; + USHORT SplitCompletionDiscarded:1; + USHORT UnexpectedSplitCompletion:1; + USHORT SplitCompletionOverrun:1; + USHORT SplitRequestDelayed:1; + USHORT BusModeFrequency:4; + USHORT Rsvd:2; + USHORT Version:2; + USHORT Bus266MHzCapable:1; + USHORT Bus533MHzCapable:1; + } DUMMYSTRUCTNAME; + USHORT AsUSHORT; + } SecondaryStatus; + union { + struct { + ULONG FunctionNumber:3; + ULONG DeviceNumber:5; + ULONG BusNumber:8; + ULONG Device64Bit:1; + ULONG Device133MHzCapable:1; + ULONG SplitCompletionDiscarded:1; + ULONG UnexpectedSplitCompletion:1; + ULONG SplitCompletionOverrun:1; + ULONG SplitRequestDelayed:1; + ULONG Rsvd:7; + ULONG DIMCapable:1; + ULONG Device266MHzCapable:1; + ULONG Device533MHzCapable:1; + } DUMMYSTRUCTNAME; + ULONG AsULONG; + } BridgeStatus; + USHORT UpstreamSplitTransactionCapacity; + USHORT UpstreamSplitTransactionLimit; + USHORT DownstreamSplitTransactionCapacity; + USHORT DownstreamSplitTransactionLimit; + union { + struct { + ULONG SelectSecondaryRegisters:1; + ULONG ErrorPresentInOtherBank:1; + ULONG AdditionalCorrectableError:1; + ULONG AdditionalUncorrectableError:1; + ULONG ErrorPhase:3; + ULONG ErrorCorrected:1; + ULONG Syndrome:8; + ULONG ErrorFirstCommand:4; + ULONG ErrorSecondCommand:4; + ULONG ErrorUpperAttributes:4; + ULONG ControlUpdateEnable:1; + ULONG Rsvd:1; + ULONG DisableSingleBitCorrection:1; + ULONG EccMode:1; + } DUMMYSTRUCTNAME; + ULONG AsULONG; + } EccControlStatus; + ULONG EccFirstAddress; + ULONG EccSecondAddress; + ULONG EccAttribute; +} PCIX_BRIDGE_CAPABILITY, *PPCIX_BRIDGE_CAPABILITY; + +typedef struct _PCI_SUBSYSTEM_IDS_CAPABILITY { + PCI_CAPABILITIES_HEADER Header; + USHORT Reserved; + USHORT SubVendorID; + USHORT SubSystemID; +} PCI_SUBSYSTEM_IDS_CAPABILITY, *PPCI_SUBSYSTEM_IDS_CAPABILITY; + +#define OSC_FIRMWARE_FAILURE 0x02 +#define OSC_UNRECOGNIZED_UUID 0x04 +#define OSC_UNRECOGNIZED_REVISION 0x08 +#define OSC_CAPABILITIES_MASKED 0x10 + +#define PCI_ROOT_BUS_OSC_METHOD_CAPABILITY_REVISION 0x01 + +typedef struct _PCI_ROOT_BUS_OSC_SUPPORT_FIELD { + union { + struct { + ULONG ExtendedConfigOpRegions:1; + ULONG ActiveStatePowerManagement:1; + ULONG ClockPowerManagement:1; + ULONG SegmentGroups:1; + ULONG MessageSignaledInterrupts:1; + ULONG WindowsHardwareErrorArchitecture:1; + ULONG Reserved:26; + } DUMMYSTRUCTNAME; + ULONG AsULONG; + } u; +} PCI_ROOT_BUS_OSC_SUPPORT_FIELD, *PPCI_ROOT_BUS_OSC_SUPPORT_FIELD; + +typedef struct _PCI_ROOT_BUS_OSC_CONTROL_FIELD { + union { + struct { + ULONG ExpressNativeHotPlug:1; + ULONG ShpcNativeHotPlug:1; + ULONG ExpressNativePME:1; + ULONG ExpressAdvancedErrorReporting:1; + ULONG ExpressCapabilityStructure:1; + ULONG Reserved:27; + } DUMMYSTRUCTNAME; + ULONG AsULONG; + } u; +} PCI_ROOT_BUS_OSC_CONTROL_FIELD, *PPCI_ROOT_BUS_OSC_CONTROL_FIELD; + +typedef enum _PCI_HARDWARE_INTERFACE { + PciConventional, + PciXMode1, + PciXMode2, + PciExpress +} PCI_HARDWARE_INTERFACE, *PPCI_HARDWARE_INTERFACE; + +typedef enum { + BusWidth32Bits, + BusWidth64Bits +} PCI_BUS_WIDTH; + +typedef struct _PCI_ROOT_BUS_HARDWARE_CAPABILITY { + PCI_HARDWARE_INTERFACE SecondaryInterface; + struct { + BOOLEAN BusCapabilitiesFound; + ULONG CurrentSpeedAndMode; + ULONG SupportedSpeedsAndModes; + BOOLEAN DeviceIDMessagingCapable; + PCI_BUS_WIDTH SecondaryBusWidth; + } DUMMYSTRUCTNAME; + PCI_ROOT_BUS_OSC_SUPPORT_FIELD OscFeatureSupport; + PCI_ROOT_BUS_OSC_CONTROL_FIELD OscControlRequest; + PCI_ROOT_BUS_OSC_CONTROL_FIELD OscControlGranted; +} PCI_ROOT_BUS_HARDWARE_CAPABILITY, *PPCI_ROOT_BUS_HARDWARE_CAPABILITY; + +typedef union _PCI_EXPRESS_CAPABILITIES_REGISTER { + struct { + USHORT CapabilityVersion:4; + USHORT DeviceType:4; + USHORT SlotImplemented:1; + USHORT InterruptMessageNumber:5; + USHORT Rsvd:2; + } DUMMYSTRUCTNAME; + USHORT AsUSHORT; +} PCI_EXPRESS_CAPABILITIES_REGISTER, *PPCI_EXPRESS_CAPABILITIES_REGISTER; + +typedef union _PCI_EXPRESS_DEVICE_CAPABILITIES_REGISTER { + struct { + ULONG MaxPayloadSizeSupported:3; + ULONG PhantomFunctionsSupported:2; + ULONG ExtendedTagSupported:1; + ULONG L0sAcceptableLatency:3; + ULONG L1AcceptableLatency:3; + ULONG Undefined:3; + ULONG RoleBasedErrorReporting:1; + ULONG Rsvd1:2; + ULONG CapturedSlotPowerLimit:8; + ULONG CapturedSlotPowerLimitScale:2; + ULONG Rsvd2:4; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_DEVICE_CAPABILITIES_REGISTER, *PPCI_EXPRESS_DEVICE_CAPABILITIES_REGISTER; + +#define PCI_EXPRESS_AER_DEVICE_CONTROL_MASK 0x07; + +typedef union _PCI_EXPRESS_DEVICE_CONTROL_REGISTER { + struct { + USHORT CorrectableErrorEnable:1; + USHORT NonFatalErrorEnable:1; + USHORT FatalErrorEnable:1; + USHORT UnsupportedRequestErrorEnable:1; + USHORT EnableRelaxedOrder:1; + USHORT MaxPayloadSize:3; + USHORT ExtendedTagEnable:1; + USHORT PhantomFunctionsEnable:1; + USHORT AuxPowerEnable:1; + USHORT NoSnoopEnable:1; + USHORT MaxReadRequestSize:3; + USHORT BridgeConfigRetryEnable:1; + } DUMMYSTRUCTNAME; + USHORT AsUSHORT; +} PCI_EXPRESS_DEVICE_CONTROL_REGISTER, *PPCI_EXPRESS_DEVICE_CONTROL_REGISTER; + +#define PCI_EXPRESS_AER_DEVICE_STATUS_MASK 0x0F; + +typedef union _PCI_EXPRESS_DEVICE_STATUS_REGISTER { + struct { + USHORT CorrectableErrorDetected:1; + USHORT NonFatalErrorDetected:1; + USHORT FatalErrorDetected:1; + USHORT UnsupportedRequestDetected:1; + USHORT AuxPowerDetected:1; + USHORT TransactionsPending:1; + USHORT Rsvd:10; + } DUMMYSTRUCTNAME; + USHORT AsUSHORT; +} PCI_EXPRESS_DEVICE_STATUS_REGISTER, *PPCI_EXPRESS_DEVICE_STATUS_REGISTER; + +typedef union _PCI_EXPRESS_LINK_CAPABILITIES_REGISTER { + struct { + ULONG MaximumLinkSpeed:4; + ULONG MaximumLinkWidth:6; + ULONG ActiveStatePMSupport:2; + ULONG L0sExitLatency:3; + ULONG L1ExitLatency:3; + ULONG ClockPowerManagement:1; + ULONG SurpriseDownErrorReportingCapable:1; + ULONG DataLinkLayerActiveReportingCapable:1; + ULONG Rsvd:3; + ULONG PortNumber:8; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_LINK_CAPABILITIES_REGISTER, *PPCI_EXPRESS_LINK_CAPABILITIES_REGISTER; + +typedef union _PCI_EXPRESS_LINK_CONTROL_REGISTER { + struct { + USHORT ActiveStatePMControl:2; + USHORT Rsvd1:1; + USHORT ReadCompletionBoundary:1; + USHORT LinkDisable:1; + USHORT RetrainLink:1; + USHORT CommonClockConfig:1; + USHORT ExtendedSynch:1; + USHORT EnableClockPowerManagement:1; + USHORT Rsvd2:7; + } DUMMYSTRUCTNAME; + USHORT AsUSHORT; +} PCI_EXPRESS_LINK_CONTROL_REGISTER, *PPCI_EXPRESS_LINK_CONTROL_REGISTER; + +typedef union _PCI_EXPRESS_LINK_STATUS_REGISTER { + struct { + USHORT LinkSpeed:4; + USHORT LinkWidth:6; + USHORT Undefined:1; + USHORT LinkTraining:1; + USHORT SlotClockConfig:1; + USHORT DataLinkLayerActive:1; + USHORT Rsvd:2; + } DUMMYSTRUCTNAME; + USHORT AsUSHORT; +} PCI_EXPRESS_LINK_STATUS_REGISTER, *PPCI_EXPRESS_LINK_STATUS_REGISTER; + +typedef union _PCI_EXPRESS_SLOT_CAPABILITIES_REGISTER { + struct { + ULONG AttentionButtonPresent:1; + ULONG PowerControllerPresent:1; + ULONG MRLSensorPresent:1; + ULONG AttentionIndicatorPresent:1; + ULONG PowerIndicatorPresent:1; + ULONG HotPlugSurprise:1; + ULONG HotPlugCapable:1; + ULONG SlotPowerLimit:8; + ULONG SlotPowerLimitScale:2; + ULONG ElectromechanicalLockPresent:1; + ULONG NoCommandCompletedSupport:1; + ULONG PhysicalSlotNumber:13; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_SLOT_CAPABILITIES_REGISTER, *PPCI_EXPRESS_SLOT_CAPABILITIES_REGISTER; + +typedef union _PCI_EXPRESS_SLOT_CONTROL_REGISTER { + struct { + USHORT AttentionButtonEnable:1; + USHORT PowerFaultDetectEnable:1; + USHORT MRLSensorEnable:1; + USHORT PresenceDetectEnable:1; + USHORT CommandCompletedEnable:1; + USHORT HotPlugInterruptEnable:1; + USHORT AttentionIndicatorControl:2; + USHORT PowerIndicatorControl:2; + USHORT PowerControllerControl:1; + USHORT ElectromechanicalLockControl:1; + USHORT DataLinkStateChangeEnable:1; + USHORT Rsvd:3; + } DUMMYSTRUCTNAME; + USHORT AsUSHORT; +} PCI_EXPRESS_SLOT_CONTROL_REGISTER, *PPCI_EXPRESS_SLOT_CONTROL_REGISTER; + +typedef union _PCI_EXPRESS_SLOT_STATUS_REGISTER { + struct { + USHORT AttentionButtonPressed:1; + USHORT PowerFaultDetected:1; + USHORT MRLSensorChanged:1; + USHORT PresenceDetectChanged:1; + USHORT CommandCompleted:1; + USHORT MRLSensorState:1; + USHORT PresenceDetectState:1; + USHORT ElectromechanicalLockEngaged:1; + USHORT DataLinkStateChanged:1; + USHORT Rsvd:7; + } DUMMYSTRUCTNAME; + USHORT AsUSHORT; +} PCI_EXPRESS_SLOT_STATUS_REGISTER, *PPCI_EXPRESS_SLOT_STATUS_REGISTER; + +typedef union _PCI_EXPRESS_ROOT_CONTROL_REGISTER { + struct { + USHORT CorrectableSerrEnable:1; + USHORT NonFatalSerrEnable:1; + USHORT FatalSerrEnable:1; + USHORT PMEInterruptEnable:1; + USHORT CRSSoftwareVisibilityEnable:1; + USHORT Rsvd:11; + } DUMMYSTRUCTNAME; + USHORT AsUSHORT; +} PCI_EXPRESS_ROOT_CONTROL_REGISTER, *PPCI_EXPRESS_ROOT_CONTROL_REGISTER; + +typedef union _PCI_EXPRESS_ROOT_CAPABILITIES_REGISTER { + struct { + USHORT CRSSoftwareVisibility:1; + USHORT Rsvd:15; + } DUMMYSTRUCTNAME; + USHORT AsUSHORT; +} PCI_EXPRESS_ROOT_CAPABILITIES_REGISTER, *PPCI_EXPRESS_ROOT_CAPABILITIES_REGISTER; + +typedef union _PCI_EXPRESS_ROOT_STATUS_REGISTER { + struct { + ULONG PMERequestorId:16; + ULONG PMEStatus:1; + ULONG PMEPending:1; + ULONG Rsvd:14; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_ROOT_STATUS_REGISTER, *PPCI_EXPRESS_ROOT_STATUS_REGISTER; + +typedef struct _PCI_EXPRESS_CAPABILITY { + PCI_CAPABILITIES_HEADER Header; + PCI_EXPRESS_CAPABILITIES_REGISTER ExpressCapabilities; + PCI_EXPRESS_DEVICE_CAPABILITIES_REGISTER DeviceCapabilities; + PCI_EXPRESS_DEVICE_CONTROL_REGISTER DeviceControl; + PCI_EXPRESS_DEVICE_STATUS_REGISTER DeviceStatus; + PCI_EXPRESS_LINK_CAPABILITIES_REGISTER LinkCapabilities; + PCI_EXPRESS_LINK_CONTROL_REGISTER LinkControl; + PCI_EXPRESS_LINK_STATUS_REGISTER LinkStatus; + PCI_EXPRESS_SLOT_CAPABILITIES_REGISTER SlotCapabilities; + PCI_EXPRESS_SLOT_CONTROL_REGISTER SlotControl; + PCI_EXPRESS_SLOT_STATUS_REGISTER SlotStatus; + PCI_EXPRESS_ROOT_CONTROL_REGISTER RootControl; + PCI_EXPRESS_ROOT_CAPABILITIES_REGISTER RootCapabilities; + PCI_EXPRESS_ROOT_STATUS_REGISTER RootStatus; +} PCI_EXPRESS_CAPABILITY, *PPCI_EXPRESS_CAPABILITY; + +typedef enum { + MRLClosed = 0, + MRLOpen +} PCI_EXPRESS_MRL_STATE; + +typedef enum { + SlotEmpty = 0, + CardPresent +} PCI_EXPRESS_CARD_PRESENCE; + +typedef enum { + IndicatorOn = 1, + IndicatorBlink, + IndicatorOff +} PCI_EXPRESS_INDICATOR_STATE; + +typedef enum { + PowerOn = 0, + PowerOff +} PCI_EXPRESS_POWER_STATE; + +typedef enum { + L0sEntrySupport = 1, + L0sAndL1EntrySupport = 3 +} PCI_EXPRESS_ASPM_SUPPORT; + +typedef enum { + L0sAndL1EntryDisabled, + L0sEntryEnabled, + L1EntryEnabled, + L0sAndL1EntryEnabled +} PCI_EXPRESS_ASPM_CONTROL; + +typedef enum { + L0s_Below64ns = 0, + L0s_64ns_128ns, + L0s_128ns_256ns, + L0s_256ns_512ns, + L0s_512ns_1us, + L0s_1us_2us, + L0s_2us_4us, + L0s_Above4us +} PCI_EXPRESS_L0s_EXIT_LATENCY; + +typedef enum { + L1_Below1us = 0, + L1_1us_2us, + L1_2us_4us, + L1_4us_8us, + L1_8us_16us, + L1_16us_32us, + L1_32us_64us, + L1_Above64us +} PCI_EXPRESS_L1_EXIT_LATENCY; + +typedef enum { + PciExpressEndpoint = 0, + PciExpressLegacyEndpoint, + PciExpressRootPort = 4, + PciExpressUpstreamSwitchPort, + PciExpressDownstreamSwitchPort, + PciExpressToPciXBridge, + PciXToExpressBridge, + PciExpressRootComplexIntegratedEndpoint, + PciExpressRootComplexEventCollector +} PCI_EXPRESS_DEVICE_TYPE; + +typedef enum { + MaxPayload128Bytes = 0, + MaxPayload256Bytes, + MaxPayload512Bytes, + MaxPayload1024Bytes, + MaxPayload2048Bytes, + MaxPayload4096Bytes +} PCI_EXPRESS_MAX_PAYLOAD_SIZE; + +typedef union _PCI_EXPRESS_PME_REQUESTOR_ID { + struct { + USHORT FunctionNumber:3; + USHORT DeviceNumber:5; + USHORT BusNumber:8; + } DUMMYSTRUCTNAME; + USHORT AsUSHORT; +} PCI_EXPRESS_PME_REQUESTOR_ID, *PPCI_EXPRESS_PME_REQUESTOR_ID; + +#if defined(_WIN64) + +#ifndef USE_DMA_MACROS +#define USE_DMA_MACROS +#endif + +#ifndef NO_LEGACY_DRIVERS +#define NO_LEGACY_DRIVERS +#endif + +#endif /* defined(_WIN64) */ + +typedef enum _PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR_TYPE { + ResourceTypeSingle = 0, + ResourceTypeRange, + ResourceTypeExtendedCounterConfiguration, + ResourceTypeOverflow, + ResourceTypeMax +} PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR_TYPE; + +typedef struct _PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR { + PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR_TYPE Type; + ULONG Flags; + union { + ULONG CounterIndex; + ULONG ExtendedRegisterAddress; + struct { + ULONG Begin; + ULONG End; + } Range; + } u; +} PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR, *PPHYSICAL_COUNTER_RESOURCE_DESCRIPTOR; + +typedef struct _PHYSICAL_COUNTER_RESOURCE_LIST { + ULONG Count; + PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR Descriptors[ANYSIZE_ARRAY]; +} PHYSICAL_COUNTER_RESOURCE_LIST, *PPHYSICAL_COUNTER_RESOURCE_LIST; + +typedef VOID +(NTAPI *PciPin2Line)( + IN struct _BUS_HANDLER *BusHandler, + IN struct _BUS_HANDLER *RootHandler, + IN PCI_SLOT_NUMBER SlotNumber, + IN PPCI_COMMON_CONFIG PciData); + +typedef VOID +(NTAPI *PciLine2Pin)( + IN struct _BUS_HANDLER *BusHandler, + IN struct _BUS_HANDLER *RootHandler, + IN PCI_SLOT_NUMBER SlotNumber, + IN PPCI_COMMON_CONFIG PciNewData, + IN PPCI_COMMON_CONFIG PciOldData); + +typedef VOID +(NTAPI *PciReadWriteConfig)( + IN struct _BUS_HANDLER *BusHandler, + IN PCI_SLOT_NUMBER Slot, + IN PVOID Buffer, + IN ULONG Offset, + IN ULONG Length); + +#define PCI_DATA_TAG ' ICP' +#define PCI_DATA_VERSION 1 + +typedef struct _PCIBUSDATA { + ULONG Tag; + ULONG Version; + PciReadWriteConfig ReadConfig; + PciReadWriteConfig WriteConfig; + PciPin2Line Pin2Line; + PciLine2Pin Line2Pin; + PCI_SLOT_NUMBER ParentSlot; + PVOID Reserved[4]; +} PCIBUSDATA, *PPCIBUSDATA; + +#ifndef _PCIINTRF_X_ +#define _PCIINTRF_X_ + +typedef ULONG +(NTAPI *PCI_READ_WRITE_CONFIG)( + IN PVOID Context, + IN ULONG BusOffset, + IN ULONG Slot, + IN PVOID Buffer, + IN ULONG Offset, + IN ULONG Length); + +typedef VOID +(NTAPI *PCI_PIN_TO_LINE)( + IN PVOID Context, + IN PPCI_COMMON_CONFIG PciData); + +typedef VOID +(NTAPI *PCI_LINE_TO_PIN)( + IN PVOID Context, + IN PPCI_COMMON_CONFIG PciNewData, + IN PPCI_COMMON_CONFIG PciOldData); + +typedef VOID +(NTAPI *PCI_ROOT_BUS_CAPABILITY)( + IN PVOID Context, + OUT PPCI_ROOT_BUS_HARDWARE_CAPABILITY HardwareCapability); + +typedef VOID +(NTAPI *PCI_EXPRESS_WAKE_CONTROL)( + IN PVOID Context, + IN BOOLEAN EnableWake); + +typedef struct _PCI_BUS_INTERFACE_STANDARD { + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; + PCI_READ_WRITE_CONFIG ReadConfig; + PCI_READ_WRITE_CONFIG WriteConfig; + PCI_PIN_TO_LINE PinToLine; + PCI_LINE_TO_PIN LineToPin; + PCI_ROOT_BUS_CAPABILITY RootBusCapability; + PCI_EXPRESS_WAKE_CONTROL ExpressWakeControl; +} PCI_BUS_INTERFACE_STANDARD, *PPCI_BUS_INTERFACE_STANDARD; + +#define PCI_BUS_INTERFACE_STANDARD_VERSION 1 + +#endif /* _PCIINTRF_X_ */ + +#if (NTDDI_VERSION >= NTDDI_WIN7) + +#define FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL_EX 0x00004000 +#define FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL_EX 0x00008000 +#define FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK_EX \ + (FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL_EX | \ + FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL_EX) + +#define FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL_DEPRECATED 0x00000200 +#define FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL_DEPRECATED 0x00000300 +#define FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK_DEPRECATED 0x00000300 + +#else + +#define FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL 0x00000200 +#define FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL 0x00000300 +#define FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK 0x00000300 + +#define FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL_EX FILE_CHARACTERISTICS_EXPECT_ORDERLY_REMOVAL +#define FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL_EX FILE_CHARACTERISTICS_EXPECT_SURPRISE_REMOVAL +#define FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK_EX FILE_CHARACTERISTICS_REMOVAL_POLICY_MASK + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + +#define FILE_CHARACTERISTICS_PROPAGATED ( FILE_REMOVABLE_MEDIA | \ + FILE_READ_ONLY_DEVICE | \ + FILE_FLOPPY_DISKETTE | \ + FILE_WRITE_ONCE_MEDIA | \ + FILE_DEVICE_SECURE_OPEN ) + +typedef struct _FILE_ALIGNMENT_INFORMATION { + ULONG AlignmentRequirement; +} FILE_ALIGNMENT_INFORMATION, *PFILE_ALIGNMENT_INFORMATION; + +typedef struct _FILE_NAME_INFORMATION { + ULONG FileNameLength; + WCHAR FileName[1]; +} FILE_NAME_INFORMATION, *PFILE_NAME_INFORMATION; + + +typedef struct _FILE_ATTRIBUTE_TAG_INFORMATION { + ULONG FileAttributes; + ULONG ReparseTag; +} FILE_ATTRIBUTE_TAG_INFORMATION, *PFILE_ATTRIBUTE_TAG_INFORMATION; + +typedef struct _FILE_DISPOSITION_INFORMATION { + BOOLEAN DeleteFile; +} FILE_DISPOSITION_INFORMATION, *PFILE_DISPOSITION_INFORMATION; + +typedef struct _FILE_END_OF_FILE_INFORMATION { + LARGE_INTEGER EndOfFile; +} FILE_END_OF_FILE_INFORMATION, *PFILE_END_OF_FILE_INFORMATION; + +typedef struct _FILE_VALID_DATA_LENGTH_INFORMATION { + LARGE_INTEGER ValidDataLength; +} FILE_VALID_DATA_LENGTH_INFORMATION, *PFILE_VALID_DATA_LENGTH_INFORMATION; + +typedef struct _FILE_FS_LABEL_INFORMATION { + ULONG VolumeLabelLength; + WCHAR VolumeLabel[1]; +} FILE_FS_LABEL_INFORMATION, *PFILE_FS_LABEL_INFORMATION; + +typedef struct _FILE_FS_VOLUME_INFORMATION { + LARGE_INTEGER VolumeCreationTime; + ULONG VolumeSerialNumber; + ULONG VolumeLabelLength; + BOOLEAN SupportsObjects; + WCHAR VolumeLabel[1]; +} FILE_FS_VOLUME_INFORMATION, *PFILE_FS_VOLUME_INFORMATION; + +typedef struct _FILE_FS_SIZE_INFORMATION { + LARGE_INTEGER TotalAllocationUnits; + LARGE_INTEGER AvailableAllocationUnits; + ULONG SectorsPerAllocationUnit; + ULONG BytesPerSector; +} FILE_FS_SIZE_INFORMATION, *PFILE_FS_SIZE_INFORMATION; + +typedef struct _FILE_FS_FULL_SIZE_INFORMATION { + LARGE_INTEGER TotalAllocationUnits; + LARGE_INTEGER CallerAvailableAllocationUnits; + LARGE_INTEGER ActualAvailableAllocationUnits; + ULONG SectorsPerAllocationUnit; + ULONG BytesPerSector; +} FILE_FS_FULL_SIZE_INFORMATION, *PFILE_FS_FULL_SIZE_INFORMATION; + +typedef struct _FILE_FS_OBJECTID_INFORMATION { + UCHAR ObjectId[16]; + UCHAR ExtendedInfo[48]; +} FILE_FS_OBJECTID_INFORMATION, *PFILE_FS_OBJECTID_INFORMATION; + +typedef union _FILE_SEGMENT_ELEMENT { + PVOID64 Buffer; + ULONGLONG Alignment; +}FILE_SEGMENT_ELEMENT, *PFILE_SEGMENT_ELEMENT; + +#define IOCTL_AVIO_ALLOCATE_STREAM CTL_CODE(FILE_DEVICE_AVIO, 1, METHOD_BUFFERED, FILE_SPECIAL_ACCESS) +#define IOCTL_AVIO_FREE_STREAM CTL_CODE(FILE_DEVICE_AVIO, 2, METHOD_BUFFERED, FILE_SPECIAL_ACCESS) +#define IOCTL_AVIO_MODIFY_STREAM CTL_CODE(FILE_DEVICE_AVIO, 3, METHOD_BUFFERED, FILE_SPECIAL_ACCESS) + +typedef enum _BUS_DATA_TYPE { + ConfigurationSpaceUndefined = -1, + Cmos, + EisaConfiguration, + Pos, + CbusConfiguration, + PCIConfiguration, + VMEConfiguration, + NuBusConfiguration, + PCMCIAConfiguration, + MPIConfiguration, + MPSAConfiguration, + PNPISAConfiguration, + SgiInternalConfiguration, + MaximumBusDataType +} BUS_DATA_TYPE, *PBUS_DATA_TYPE; + +/* Hardware Abstraction Layer Types */ + +typedef BOOLEAN +(NTAPI *PHAL_RESET_DISPLAY_PARAMETERS)( + IN ULONG Columns, + IN ULONG Rows); + +typedef PBUS_HANDLER +(FASTCALL *pHalHandlerForBus)( + IN INTERFACE_TYPE InterfaceType, + IN ULONG BusNumber); + +typedef VOID +(FASTCALL *pHalReferenceBusHandler)( + IN PBUS_HANDLER BusHandler); + typedef enum _HAL_QUERY_INFORMATION_CLASS { HalInstalledBusInformation, HalProfileSourceInformation, @@ -355,92 +1307,18 @@ typedef enum _HAL_SET_INFORMATION_CLASS { HalProfileDpgoSourceInterruptHandler } HAL_SET_INFORMATION_CLASS, *PHAL_SET_INFORMATION_CLASS; -typedef struct _HAL_PROFILE_SOURCE_INTERVAL { - KPROFILE_SOURCE Source; - ULONG_PTR Interval; -} HAL_PROFILE_SOURCE_INTERVAL, *PHAL_PROFILE_SOURCE_INTERVAL; - -typedef struct _HAL_PROFILE_SOURCE_INFORMATION { - KPROFILE_SOURCE Source; - BOOLEAN Supported; - ULONG Interval; -} HAL_PROFILE_SOURCE_INFORMATION, *PHAL_PROFILE_SOURCE_INFORMATION; - -typedef struct _MAP_REGISTER_ENTRY { - PVOID MapRegister; - BOOLEAN WriteToDevice; -} MAP_REGISTER_ENTRY, *PMAP_REGISTER_ENTRY; - -typedef struct _DEBUG_DEVICE_ADDRESS { - UCHAR Type; - BOOLEAN Valid; - UCHAR Reserved[2]; - PUCHAR TranslatedAddress; - ULONG Length; -} DEBUG_DEVICE_ADDRESS, *PDEBUG_DEVICE_ADDRESS; - -typedef struct _DEBUG_MEMORY_REQUIREMENTS { - PHYSICAL_ADDRESS Start; - PHYSICAL_ADDRESS MaxEnd; - PVOID VirtualAddress; - ULONG Length; - BOOLEAN Cached; - BOOLEAN Aligned; -} DEBUG_MEMORY_REQUIREMENTS, *PDEBUG_MEMORY_REQUIREMENTS; - -typedef struct _DEBUG_DEVICE_DESCRIPTOR { - ULONG Bus; - ULONG Slot; - USHORT Segment; - USHORT VendorID; - USHORT DeviceID; - UCHAR BaseClass; - UCHAR SubClass; - UCHAR ProgIf; - BOOLEAN Initialized; - BOOLEAN Configured; - DEBUG_DEVICE_ADDRESS BaseAddress[6]; - DEBUG_MEMORY_REQUIREMENTS Memory; -} DEBUG_DEVICE_DESCRIPTOR, *PDEBUG_DEVICE_DESCRIPTOR; - -typedef struct _PM_DISPATCH_TABLE { - ULONG Signature; - ULONG Version; - PVOID Function[1]; -} PM_DISPATCH_TABLE, *PPM_DISPATCH_TABLE; - -typedef enum _RESOURCE_TRANSLATION_DIRECTION { - TranslateChildToParent, - TranslateParentToChild -} RESOURCE_TRANSLATION_DIRECTION; +typedef NTSTATUS +(NTAPI *pHalQuerySystemInformation)( + IN HAL_QUERY_INFORMATION_CLASS InformationClass, + IN ULONG BufferSize, + IN OUT PVOID Buffer, + OUT PULONG ReturnedLength); typedef NTSTATUS -(NTAPI *PTRANSLATE_RESOURCE_HANDLER)( - IN OUT PVOID Context, - IN PCM_PARTIAL_RESOURCE_DESCRIPTOR Source, - IN RESOURCE_TRANSLATION_DIRECTION Direction, - IN ULONG AlternativesCount OPTIONAL, - IN IO_RESOURCE_DESCRIPTOR Alternatives[], - IN PDEVICE_OBJECT PhysicalDeviceObject, - OUT PCM_PARTIAL_RESOURCE_DESCRIPTOR Target); - -typedef NTSTATUS -(NTAPI *PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER)( - IN PVOID Context OPTIONAL, - IN PIO_RESOURCE_DESCRIPTOR Source, - IN PDEVICE_OBJECT PhysicalDeviceObject, - OUT PULONG TargetCount, - OUT PIO_RESOURCE_DESCRIPTOR *Target); - -typedef struct _TRANSLATOR_INTERFACE { - USHORT Size; - USHORT Version; - PVOID Context; - PINTERFACE_REFERENCE InterfaceReference; - PINTERFACE_DEREFERENCE InterfaceDereference; - PTRANSLATE_RESOURCE_HANDLER TranslateResources; - PTRANSLATE_RESOURCE_REQUIREMENTS_HANDLER TranslateResourceRequirements; -} TRANSLATOR_INTERFACE, *PTRANSLATOR_INTERFACE; +(NTAPI *pHalSetSystemInformation)( + IN HAL_SET_INFORMATION_CLASS InformationClass, + IN ULONG BufferSize, + IN PVOID Buffer); typedef VOID (FASTCALL *pHalExamineMBR)( @@ -471,28 +1349,6 @@ typedef NTSTATUS IN ULONG NumberOfHeads, IN struct _DRIVE_LAYOUT_INFORMATION *PartitionBuffer); -typedef PBUS_HANDLER -(FASTCALL *pHalHandlerForBus)( - IN INTERFACE_TYPE InterfaceType, - IN ULONG BusNumber); - -typedef VOID -(FASTCALL *pHalReferenceBusHandler)( - IN PBUS_HANDLER BusHandler); - -typedef NTSTATUS -(NTAPI *pHalQuerySystemInformation)( - IN HAL_QUERY_INFORMATION_CLASS InformationClass, - IN ULONG BufferSize, - IN OUT PVOID Buffer, - OUT PULONG ReturnedLength); - -typedef NTSTATUS -(NTAPI *pHalSetSystemInformation)( - IN HAL_SET_INFORMATION_CLASS InformationClass, - IN ULONG BufferSize, - IN PVOID Buffer); - typedef NTSTATUS (NTAPI *pHalQueryBusSlots)( IN PBUS_HANDLER BusHandler, @@ -504,6 +1360,12 @@ typedef NTSTATUS (NTAPI *pHalInitPnpDriver)( VOID); +typedef struct _PM_DISPATCH_TABLE { + ULONG Signature; + ULONG Version; + PVOID Function[1]; +} PM_DISPATCH_TABLE, *PPM_DISPATCH_TABLE; + typedef NTSTATUS (NTAPI *pHalInitPowerManagement)( IN PPM_DISPATCH_TABLE PmDriverDispatchTable, @@ -543,12 +1405,7 @@ typedef NTSTATUS IN PHYSICAL_ADDRESS PhysicalAddress, IN LARGE_INTEGER NumberOfBytes); -typedef VOID -(NTAPI *pHalEndOfBoot)( - VOID); - -typedef -BOOLEAN +typedef BOOLEAN (NTAPI *pHalTranslateBusAddress)( IN INTERFACE_TYPE InterfaceType, IN ULONG BusNumber, @@ -556,8 +1413,7 @@ BOOLEAN IN OUT PULONG AddressSpace, OUT PPHYSICAL_ADDRESS TranslatedAddress); -typedef -NTSTATUS +typedef NTSTATUS (NTAPI *pHalAssignSlotResources)( IN PUNICODE_STRING RegistryPath, IN PUNICODE_STRING DriverClassName OPTIONAL, @@ -568,23 +1424,24 @@ NTSTATUS IN ULONG SlotNumber, IN OUT PCM_RESOURCE_LIST *AllocatedResources); -typedef -VOID +typedef VOID (NTAPI *pHalHaltSystem)( VOID); -typedef -BOOLEAN +typedef BOOLEAN (NTAPI *pHalResetDisplay)( VOID); -typedef -UCHAR +typedef struct _MAP_REGISTER_ENTRY { + PVOID MapRegister; + BOOLEAN WriteToDevice; +} MAP_REGISTER_ENTRY, *PMAP_REGISTER_ENTRY; + +typedef UCHAR (NTAPI *pHalVectorToIDTEntry)( ULONG Vector); -typedef -BOOLEAN +typedef BOOLEAN (NTAPI *pHalFindBusAddressTranslation)( IN PHYSICAL_ADDRESS BusAddress, IN OUT PULONG AddressSpace, @@ -592,94 +1449,33 @@ BOOLEAN IN OUT PULONG_PTR Context, IN BOOLEAN NextBus); -typedef -NTSTATUS -(NTAPI *pKdSetupPciDeviceForDebugging)( - IN PVOID LoaderBlock OPTIONAL, - IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice); +typedef VOID +(NTAPI *pHalEndOfBoot)( + VOID); -typedef -NTSTATUS -(NTAPI *pKdReleasePciDeviceForDebugging)( - IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice); - -typedef -PVOID -(NTAPI *pKdGetAcpiTablePhase0)( - IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock, - IN ULONG Signature); - -typedef -PVOID +typedef PVOID (NTAPI *pHalGetAcpiTable)( IN ULONG Signature, IN PCSTR OemId OPTIONAL, IN PCSTR OemTableId OPTIONAL); -typedef -VOID -(NTAPI *pKdCheckPowerButton)( - VOID); +#if defined(_IA64_) +typedef NTSTATUS +(*pHalGetErrorCapList)( + IN OUT PULONG CapsListLength, + IN OUT PUCHAR ErrorCapList); -#if (NTDDI_VERSION >= NTDDI_VISTA) -typedef -PVOID -(NTAPI *pKdMapPhysicalMemory64)( - IN PHYSICAL_ADDRESS PhysicalAddress, - IN ULONG NumberPages, - IN BOOLEAN FlushCurrentTLB); - -typedef -VOID -(NTAPI *pKdUnmapVirtualAddress)( - IN PVOID VirtualAddress, - IN ULONG NumberPages, - IN BOOLEAN FlushCurrentTLB); -#else -typedef -PVOID -(NTAPI *pKdMapPhysicalMemory64)( - IN PHYSICAL_ADDRESS PhysicalAddress, - IN ULONG NumberPages); - -typedef -VOID -(NTAPI *pKdUnmapVirtualAddress)( - IN PVOID VirtualAddress, - IN ULONG NumberPages); +typedef NTSTATUS +(*pHalInjectError)( + IN ULONG BufferLength, + IN PUCHAR Buffer); #endif - -typedef -ULONG -(NTAPI *pKdGetPciDataByOffset)( - IN ULONG BusNumber, - IN ULONG SlotNumber, - OUT PVOID Buffer, - IN ULONG Offset, - IN ULONG Length); - -typedef -ULONG -(NTAPI *pKdSetPciDataByOffset)( - IN ULONG BusNumber, - IN ULONG SlotNumber, - IN PVOID Buffer, - IN ULONG Offset, - IN ULONG Length); - -typedef BOOLEAN -(NTAPI *PHAL_RESET_DISPLAY_PARAMETERS)( - IN ULONG Columns, - IN ULONG Rows); - -typedef -VOID +typedef VOID (NTAPI *PCI_ERROR_HANDLER_CALLBACK)( VOID); -typedef -VOID +typedef VOID (NTAPI *pHalSetPciErrorHandlerCallback)( IN PCI_ERROR_HANDLER_CALLBACK Callback); @@ -753,78 +1549,706 @@ extern NTKERNELAPI HAL_DISPATCH HalDispatchTable; #define HalMirrorPhysicalMemory HALDISPATCH->HalMirrorPhysicalMemory #define HalEndOfBoot HALDISPATCH->HalEndOfBoot #define HalMirrorVerify HALDISPATCH->HalMirrorVerify - -typedef struct _FILE_ALIGNMENT_INFORMATION { - ULONG AlignmentRequirement; -} FILE_ALIGNMENT_INFORMATION, *PFILE_ALIGNMENT_INFORMATION; - -typedef struct _FILE_NAME_INFORMATION { - ULONG FileNameLength; - WCHAR FileName[1]; -} FILE_NAME_INFORMATION, *PFILE_NAME_INFORMATION; - - -typedef struct _FILE_ATTRIBUTE_TAG_INFORMATION { - ULONG FileAttributes; - ULONG ReparseTag; -} FILE_ATTRIBUTE_TAG_INFORMATION, *PFILE_ATTRIBUTE_TAG_INFORMATION; - -typedef struct _FILE_DISPOSITION_INFORMATION { - BOOLEAN DeleteFile; -} FILE_DISPOSITION_INFORMATION, *PFILE_DISPOSITION_INFORMATION; - -typedef struct _FILE_END_OF_FILE_INFORMATION { - LARGE_INTEGER EndOfFile; -} FILE_END_OF_FILE_INFORMATION, *PFILE_END_OF_FILE_INFORMATION; - -typedef struct _FILE_VALID_DATA_LENGTH_INFORMATION { - LARGE_INTEGER ValidDataLength; -} FILE_VALID_DATA_LENGTH_INFORMATION, *PFILE_VALID_DATA_LENGTH_INFORMATION; - -typedef union _FILE_SEGMENT_ELEMENT { - PVOID64 Buffer; - ULONGLONG Alignment; -}FILE_SEGMENT_ELEMENT, *PFILE_SEGMENT_ELEMENT; - -#define SE_UNSOLICITED_INPUT_PRIVILEGE 6 - -#if (NTDDI_VERSION >= NTDDI_WIN2K) -NTSYSAPI -ULONGLONG -NTAPI -VerSetConditionMask( - IN ULONGLONG ConditionMask, - IN ULONG TypeMask, - IN UCHAR Condition); +#define HalGetCachedAcpiTable HALDISPATCH->HalGetCachedAcpiTable +#define HalSetPciErrorHandlerCallback HALDISPATCH->HalSetPciErrorHandlerCallback +#if defined(_IA64_) +#define HalGetErrorCapList HALDISPATCH->HalGetErrorCapList +#define HalInjectError HALDISPATCH->HalInjectError #endif -#define VER_SET_CONDITION(ConditionMask, TypeBitMask, ComparisonType) \ - ((ConditionMask) = VerSetConditionMask((ConditionMask), \ - (TypeBitMask), (ComparisonType))) +typedef struct _HAL_BUS_INFORMATION { + INTERFACE_TYPE BusType; + BUS_DATA_TYPE ConfigurationType; + ULONG BusNumber; + ULONG Reserved; +} HAL_BUS_INFORMATION, *PHAL_BUS_INFORMATION; -/* RtlVerifyVersionInfo() TypeMask */ +typedef struct _HAL_PROFILE_SOURCE_INFORMATION { + KPROFILE_SOURCE Source; + BOOLEAN Supported; + ULONG Interval; +} HAL_PROFILE_SOURCE_INFORMATION, *PHAL_PROFILE_SOURCE_INFORMATION; -#define VER_MINORVERSION 0x0000001 -#define VER_MAJORVERSION 0x0000002 -#define VER_BUILDNUMBER 0x0000004 -#define VER_PLATFORMID 0x0000008 -#define VER_SERVICEPACKMINOR 0x0000010 -#define VER_SERVICEPACKMAJOR 0x0000020 -#define VER_SUITENAME 0x0000040 -#define VER_PRODUCT_TYPE 0x0000080 +typedef struct _HAL_PROFILE_SOURCE_INFORMATION_EX { + KPROFILE_SOURCE Source; + BOOLEAN Supported; + ULONG_PTR Interval; + ULONG_PTR DefInterval; + ULONG_PTR MaxInterval; + ULONG_PTR MinInterval; +} HAL_PROFILE_SOURCE_INFORMATION_EX, *PHAL_PROFILE_SOURCE_INFORMATION_EX; -/* RtlVerifyVersionInfo() ComparisonType */ +typedef struct _HAL_PROFILE_SOURCE_INTERVAL { + KPROFILE_SOURCE Source; + ULONG_PTR Interval; +} HAL_PROFILE_SOURCE_INTERVAL, *PHAL_PROFILE_SOURCE_INTERVAL; -#define VER_EQUAL 1 -#define VER_GREATER 2 -#define VER_GREATER_EQUAL 3 -#define VER_LESS 4 -#define VER_LESS_EQUAL 5 -#define VER_AND 6 -#define VER_OR 7 +typedef struct _HAL_PROFILE_SOURCE_LIST { + KPROFILE_SOURCE Source; + PWSTR Description; +} HAL_PROFILE_SOURCE_LIST, *PHAL_PROFILE_SOURCE_LIST; -#define VER_CONDITION_MASK 7 -#define VER_NUM_BITS_PER_CONDITION_MASK 3 +typedef enum _HAL_DISPLAY_BIOS_INFORMATION { + HalDisplayInt10Bios, + HalDisplayEmulatedBios, + HalDisplayNoBios +} HAL_DISPLAY_BIOS_INFORMATION, *PHAL_DISPLAY_BIOS_INFORMATION; + +typedef struct _HAL_POWER_INFORMATION { + ULONG TBD; +} HAL_POWER_INFORMATION, *PHAL_POWER_INFORMATION; + +typedef struct _HAL_PROCESSOR_SPEED_INFO { + ULONG ProcessorSpeed; +} HAL_PROCESSOR_SPEED_INFORMATION, *PHAL_PROCESSOR_SPEED_INFORMATION; + +typedef struct _HAL_CALLBACKS { + PCALLBACK_OBJECT SetSystemInformation; + PCALLBACK_OBJECT BusCheck; +} HAL_CALLBACKS, *PHAL_CALLBACKS; + +typedef struct _HAL_PROCESSOR_FEATURE { + ULONG UsableFeatureBits; +} HAL_PROCESSOR_FEATURE; + +typedef NTSTATUS +(NTAPI *PHALIOREADWRITEHANDLER)( + IN BOOLEAN fRead, + IN ULONG dwAddr, + IN ULONG dwSize, + IN OUT PULONG pdwData); + +typedef struct _HAL_AMLI_BAD_IO_ADDRESS_LIST { + ULONG BadAddrBegin; + ULONG BadAddrSize; + ULONG OSVersionTrigger; + PHALIOREADWRITEHANDLER IOHandler; +} HAL_AMLI_BAD_IO_ADDRESS_LIST, *PHAL_AMLI_BAD_IO_ADDRESS_LIST; + +#if defined(_X86_) || defined(_IA64_) || defined(_AMD64_) + +typedef VOID +(NTAPI *PHALMCAINTERFACELOCK)( + VOID); + +typedef VOID +(NTAPI *PHALMCAINTERFACEUNLOCK)( + VOID); + +typedef NTSTATUS +(NTAPI *PHALMCAINTERFACEREADREGISTER)( + IN UCHAR BankNumber, + IN OUT PVOID Exception); + +typedef struct _HAL_MCA_INTERFACE { + PHALMCAINTERFACELOCK Lock; + PHALMCAINTERFACEUNLOCK Unlock; + PHALMCAINTERFACEREADREGISTER ReadRegister; +} HAL_MCA_INTERFACE; + +typedef enum { + ApicDestinationModePhysical = 1, + ApicDestinationModeLogicalFlat, + ApicDestinationModeLogicalClustered, + ApicDestinationModeUnknown +} HAL_APIC_DESTINATION_MODE, *PHAL_APIC_DESTINATION_MODE; + +#if defined(_AMD64_) + +struct _KTRAP_FRAME; +struct _KEXCEPTION_FRAME; + +typedef ERROR_SEVERITY +(NTAPI *PDRIVER_EXCPTN_CALLBACK)( + IN PVOID Context, + IN struct _KTRAP_FRAME *TrapFrame, + IN struct _KEXCEPTION_FRAME *ExceptionFrame, + IN PMCA_EXCEPTION Exception); + +#endif + +#if defined(_X86_) || defined(_IA64_) +typedef +#if defined(_IA64_) +ERROR_SEVERITY +#else +VOID +#endif +(NTAPI *PDRIVER_EXCPTN_CALLBACK)( + IN PVOID Context, + IN PMCA_EXCEPTION BankLog); +#endif + +typedef PDRIVER_EXCPTN_CALLBACK PDRIVER_MCA_EXCEPTION_CALLBACK; + +typedef struct _MCA_DRIVER_INFO { + PDRIVER_MCA_EXCEPTION_CALLBACK ExceptionCallback; + PKDEFERRED_ROUTINE DpcCallback; + PVOID DeviceContext; +} MCA_DRIVER_INFO, *PMCA_DRIVER_INFO; + +typedef struct _HAL_ERROR_INFO { + ULONG Version; + ULONG InitMaxSize; + ULONG McaMaxSize; + ULONG McaPreviousEventsCount; + ULONG McaCorrectedEventsCount; + ULONG McaKernelDeliveryFails; + ULONG McaDriverDpcQueueFails; + ULONG McaReserved; + ULONG CmcMaxSize; + ULONG CmcPollingInterval; + ULONG CmcInterruptsCount; + ULONG CmcKernelDeliveryFails; + ULONG CmcDriverDpcQueueFails; + ULONG CmcGetStateFails; + ULONG CmcClearStateFails; + ULONG CmcReserved; + ULONGLONG CmcLogId; + ULONG CpeMaxSize; + ULONG CpePollingInterval; + ULONG CpeInterruptsCount; + ULONG CpeKernelDeliveryFails; + ULONG CpeDriverDpcQueueFails; + ULONG CpeGetStateFails; + ULONG CpeClearStateFails; + ULONG CpeInterruptSources; + ULONGLONG CpeLogId; + ULONGLONG KernelReserved[4]; +} HAL_ERROR_INFO, *PHAL_ERROR_INFO; + +#define HAL_MCE_INTERRUPTS_BASED ((ULONG)-1) +#define HAL_MCE_DISABLED ((ULONG)0) + +#define HAL_CMC_INTERRUPTS_BASED HAL_MCE_INTERRUPTS_BASED +#define HAL_CMC_DISABLED HAL_MCE_DISABLED + +#define HAL_CPE_INTERRUPTS_BASED HAL_MCE_INTERRUPTS_BASED +#define HAL_CPE_DISABLED HAL_MCE_DISABLED + +#define HAL_MCA_INTERRUPTS_BASED HAL_MCE_INTERRUPTS_BASED +#define HAL_MCA_DISABLED HAL_MCE_DISABLED + +typedef VOID +(NTAPI *PDRIVER_CMC_EXCEPTION_CALLBACK)( + IN PVOID Context, + IN PCMC_EXCEPTION CmcLog); + +typedef VOID +(NTAPI *PDRIVER_CPE_EXCEPTION_CALLBACK)( + IN PVOID Context, + IN PCPE_EXCEPTION CmcLog); + +typedef struct _CMC_DRIVER_INFO { + PDRIVER_CMC_EXCEPTION_CALLBACK ExceptionCallback; + PKDEFERRED_ROUTINE DpcCallback; + PVOID DeviceContext; +} CMC_DRIVER_INFO, *PCMC_DRIVER_INFO; + +typedef struct _CPE_DRIVER_INFO { + PDRIVER_CPE_EXCEPTION_CALLBACK ExceptionCallback; + PKDEFERRED_ROUTINE DpcCallback; + PVOID DeviceContext; +} CPE_DRIVER_INFO, *PCPE_DRIVER_INFO; + +#endif // defined(_X86_) || defined(_IA64_) || defined(_AMD64_) + +#if defined(_IA64_) + +typedef NTSTATUS +(*HALSENDCROSSPARTITIONIPI)( + IN USHORT ProcessorID, + IN UCHAR HardwareVector); + +typedef NTSTATUS +(*HALRESERVECROSSPARTITIONINTERRUPTVECTOR)( + OUT PULONG Vector, + OUT PKIRQL Irql, + IN OUT PGROUP_AFFINITY Affinity, + OUT PUCHAR HardwareVector); + +typedef VOID +(*HALFREECROSSPARTITIONINTERRUPTVECTOR)( + IN ULONG Vector, + IN PGROUP_AFFINITY Affinity); + +typedef struct _HAL_CROSS_PARTITION_IPI_INTERFACE { + HALSENDCROSSPARTITIONIPI HalSendCrossPartitionIpi; + HALRESERVECROSSPARTITIONINTERRUPTVECTOR HalReserveCrossPartitionInterruptVector; + HALFREECROSSPARTITIONINTERRUPTVECTOR HalFreeCrossPartitionInterruptVector; +} HAL_CROSS_PARTITION_IPI_INTERFACE; + +#define HAL_CROSS_PARTITION_IPI_INTERFACE_MINIMUM_SIZE \ + FIELD_OFFSET(HAL_CROSS_PARTITION_IPI_INTERFACE, \ + HalFreeCrossPartitionInterruptVector) + +#endif /* defined(_IA64_) */ + +typedef struct _HAL_PLATFORM_INFORMATION { + ULONG PlatformFlags; +} HAL_PLATFORM_INFORMATION, *PHAL_PLATFORM_INFORMATION; + +#define HAL_PLATFORM_DISABLE_WRITE_COMBINING 0x01L +#define HAL_PLATFORM_DISABLE_PTCG 0x04L +#define HAL_PLATFORM_DISABLE_UC_MAIN_MEMORY 0x08L +#define HAL_PLATFORM_ENABLE_WRITE_COMBINING_MMIO 0x10L +#define HAL_PLATFORM_ACPI_TABLES_CACHED 0x20L + +/****************************************************************************** + * Kernel Types * + ******************************************************************************/ + +#define NX_SUPPORT_POLICY_ALWAYSOFF 0 +#define NX_SUPPORT_POLICY_ALWAYSON 1 +#define NX_SUPPORT_POLICY_OPTIN 2 +#define NX_SUPPORT_POLICY_OPTOUT 3 + +typedef VOID +(NTAPI *PEXPAND_STACK_CALLOUT)( + IN PVOID Parameter OPTIONAL); + +typedef VOID +(NTAPI *PTIMER_APC_ROUTINE)( + IN PVOID TimerContext, + IN ULONG TimerLowValue, + IN LONG TimerHighValue); + +typedef enum _TIMER_SET_INFORMATION_CLASS { + TimerSetCoalescableTimer, + MaxTimerInfoClass +} TIMER_SET_INFORMATION_CLASS; + +#if (NTDDI_VERSION >= NTDDI_WIN7) +typedef struct _TIMER_SET_COALESCABLE_TIMER_INFO { + IN LARGE_INTEGER DueTime; + IN PTIMER_APC_ROUTINE TimerApcRoutine OPTIONAL; + IN PVOID TimerContext OPTIONAL; + IN struct _COUNTED_REASON_CONTEXT *WakeContext OPTIONAL; + IN ULONG Period OPTIONAL; + IN ULONG TolerableDelay; + OUT PBOOLEAN PreviousState OPTIONAL; +} TIMER_SET_COALESCABLE_TIMER_INFO, *PTIMER_SET_COALESCABLE_TIMER_INFO; +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + +#define XSTATE_LEGACY_FLOATING_POINT 0 +#define XSTATE_LEGACY_SSE 1 +#define XSTATE_GSSE 2 + +#define XSTATE_MASK_LEGACY_FLOATING_POINT (1i64 << (XSTATE_LEGACY_FLOATING_POINT)) +#define XSTATE_MASK_LEGACY_SSE (1i64 << (XSTATE_LEGACY_SSE)) +#define XSTATE_MASK_LEGACY (XSTATE_MASK_LEGACY_FLOATING_POINT | XSTATE_MASK_LEGACY_SSE) +#define XSTATE_MASK_GSSE (1i64 << (XSTATE_GSSE)) + +#define MAXIMUM_XSTATE_FEATURES 64 + +typedef struct _XSTATE_FEATURE { + ULONG Offset; + ULONG Size; +} XSTATE_FEATURE, *PXSTATE_FEATURE; + +typedef struct _XSTATE_CONFIGURATION { + ULONG64 EnabledFeatures; + ULONG Size; + ULONG OptimizedSave:1; + XSTATE_FEATURE Features[MAXIMUM_XSTATE_FEATURES]; +} XSTATE_CONFIGURATION, *PXSTATE_CONFIGURATION; + +#define MAX_WOW64_SHARED_ENTRIES 16 + +typedef struct _KUSER_SHARED_DATA { + ULONG TickCountLowDeprecated; + ULONG TickCountMultiplier; + volatile KSYSTEM_TIME InterruptTime; + volatile KSYSTEM_TIME SystemTime; + volatile KSYSTEM_TIME TimeZoneBias; + USHORT ImageNumberLow; + USHORT ImageNumberHigh; + WCHAR NtSystemRoot[260]; + ULONG MaxStackTraceDepth; + ULONG CryptoExponent; + ULONG TimeZoneId; + ULONG LargePageMinimum; + ULONG Reserved2[7]; + NT_PRODUCT_TYPE NtProductType; + BOOLEAN ProductTypeIsValid; + ULONG NtMajorVersion; + ULONG NtMinorVersion; + BOOLEAN ProcessorFeatures[PROCESSOR_FEATURE_MAX]; + ULONG Reserved1; + ULONG Reserved3; + volatile ULONG TimeSlip; + ALTERNATIVE_ARCHITECTURE_TYPE AlternativeArchitecture; + ULONG AltArchitecturePad[1]; + LARGE_INTEGER SystemExpirationDate; + ULONG SuiteMask; + BOOLEAN KdDebuggerEnabled; +#if (NTDDI_VERSION >= NTDDI_WINXPSP2) + UCHAR NXSupportPolicy; +#endif + volatile ULONG ActiveConsoleId; + volatile ULONG DismountCount; + ULONG ComPlusPackage; + ULONG LastSystemRITEventTickCount; + ULONG NumberOfPhysicalPages; + BOOLEAN SafeBootMode; +#if (NTDDI_VERSION >= NTDDI_WIN7) + union { + UCHAR TscQpcData; + struct { + UCHAR TscQpcEnabled:1; + UCHAR TscQpcSpareFlag:1; + UCHAR TscQpcShift:6; + } DUMMYSTRUCTNAME; + } DUMMYUNIONNAME; + UCHAR TscQpcPad[2]; +#endif +#if (NTDDI_VERSION >= NTDDI_VISTA) + union { + ULONG SharedDataFlags; + struct { + ULONG DbgErrorPortPresent:1; + ULONG DbgElevationEnabled:1; + ULONG DbgVirtEnabled:1; + ULONG DbgInstallerDetectEnabled:1; + ULONG DbgSystemDllRelocated:1; + ULONG DbgDynProcessorEnabled:1; + ULONG DbgSEHValidationEnabled:1; + ULONG SpareBits:25; + } DUMMYSTRUCTNAME2; + } DUMMYUNIONNAME2; +#else + ULONG TraceLogging; +#endif + ULONG DataFlagsPad[1]; + ULONGLONG TestRetInstruction; + ULONG SystemCall; + ULONG SystemCallReturn; + ULONGLONG SystemCallPad[3]; + _ANONYMOUS_UNION union { + volatile KSYSTEM_TIME TickCount; + volatile ULONG64 TickCountQuad; + _ANONYMOUS_STRUCT struct { + ULONG ReservedTickCountOverlay[3]; + ULONG TickCountPad[1]; + } DUMMYSTRUCTNAME; + } DUMMYUNIONNAME3; + ULONG Cookie; + ULONG CookiePad[1]; +#if (NTDDI_VERSION >= NTDDI_WS03) + LONGLONG ConsoleSessionForegroundProcessId; + ULONG Wow64SharedInformation[MAX_WOW64_SHARED_ENTRIES]; +#endif +#if (NTDDI_VERSION >= NTDDI_VISTA) +#if (NTDDI_VERSION >= NTDDI_WIN7) + USHORT UserModeGlobalLogger[16]; +#else + USHORT UserModeGlobalLogger[8]; + ULONG HeapTracingPid[2]; + ULONG CritSecTracingPid[2]; +#endif + ULONG ImageFileExecutionOptions; +#if (NTDDI_VERSION >= NTDDI_VISTASP1) + ULONG LangGenerationCount; +#else + /* 4 bytes padding */ +#endif + ULONGLONG Reserved5; + volatile ULONG64 InterruptTimeBias; +#endif +#if (NTDDI_VERSION >= NTDDI_WIN7) + volatile ULONG64 TscQpcBias; + volatile ULONG ActiveProcessorCount; + volatile USHORT ActiveGroupCount; + USHORT Reserved4; + volatile ULONG AitSamplingValue; + volatile ULONG AppCompatFlag; + ULONGLONG SystemDllNativeRelocation; + ULONG SystemDllWowRelocation; + ULONG XStatePad[1]; + XSTATE_CONFIGURATION XState; +#endif +} KUSER_SHARED_DATA, *PKUSER_SHARED_DATA; + +#if (NTDDI_VERSION >= NTDDI_VISTA) +extern NTSYSAPI volatile CCHAR KeNumberProcessors; +#elif (NTDDI_VERSION >= NTDDI_WINXP) +extern NTSYSAPI CCHAR KeNumberProcessors; +#else +extern PCCHAR KeNumberProcessors; +#endif + + +/****************************************************************************** + * Kernel Debugger Types * + ******************************************************************************/ +typedef struct _DEBUG_DEVICE_ADDRESS { + UCHAR Type; + BOOLEAN Valid; + UCHAR Reserved[2]; + PUCHAR TranslatedAddress; + ULONG Length; +} DEBUG_DEVICE_ADDRESS, *PDEBUG_DEVICE_ADDRESS; + +typedef struct _DEBUG_MEMORY_REQUIREMENTS { + PHYSICAL_ADDRESS Start; + PHYSICAL_ADDRESS MaxEnd; + PVOID VirtualAddress; + ULONG Length; + BOOLEAN Cached; + BOOLEAN Aligned; +} DEBUG_MEMORY_REQUIREMENTS, *PDEBUG_MEMORY_REQUIREMENTS; + +typedef struct _DEBUG_DEVICE_DESCRIPTOR { + ULONG Bus; + ULONG Slot; + USHORT Segment; + USHORT VendorID; + USHORT DeviceID; + UCHAR BaseClass; + UCHAR SubClass; + UCHAR ProgIf; + BOOLEAN Initialized; + BOOLEAN Configured; + DEBUG_DEVICE_ADDRESS BaseAddress[6]; + DEBUG_MEMORY_REQUIREMENTS Memory; +} DEBUG_DEVICE_DESCRIPTOR, *PDEBUG_DEVICE_DESCRIPTOR; + +typedef NTSTATUS +(NTAPI *pKdSetupPciDeviceForDebugging)( + IN PVOID LoaderBlock OPTIONAL, + IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice); + +typedef NTSTATUS +(NTAPI *pKdReleasePciDeviceForDebugging)( + IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice); + +typedef PVOID +(NTAPI *pKdGetAcpiTablePhase0)( + IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock, + IN ULONG Signature); + +typedef VOID +(NTAPI *pKdCheckPowerButton)( + VOID); + +#if (NTDDI_VERSION >= NTDDI_VISTA) +typedef PVOID +(NTAPI *pKdMapPhysicalMemory64)( + IN PHYSICAL_ADDRESS PhysicalAddress, + IN ULONG NumberPages, + IN BOOLEAN FlushCurrentTLB); + +typedef VOID +(NTAPI *pKdUnmapVirtualAddress)( + IN PVOID VirtualAddress, + IN ULONG NumberPages, + IN BOOLEAN FlushCurrentTLB); +#else +typedef PVOID +(NTAPI *pKdMapPhysicalMemory64)( + IN PHYSICAL_ADDRESS PhysicalAddress, + IN ULONG NumberPages); + +typedef VOID +(NTAPI *pKdUnmapVirtualAddress)( + IN PVOID VirtualAddress, + IN ULONG NumberPages); +#endif + +typedef ULONG +(NTAPI *pKdGetPciDataByOffset)( + IN ULONG BusNumber, + IN ULONG SlotNumber, + OUT PVOID Buffer, + IN ULONG Offset, + IN ULONG Length); + +typedef ULONG +(NTAPI *pKdSetPciDataByOffset)( + IN ULONG BusNumber, + IN ULONG SlotNumber, + IN PVOID Buffer, + IN ULONG Offset, + IN ULONG Length); +/****************************************************************************** + * Memory manager Types * + ******************************************************************************/ + +typedef struct _PHYSICAL_MEMORY_RANGE { + PHYSICAL_ADDRESS BaseAddress; + LARGE_INTEGER NumberOfBytes; +} PHYSICAL_MEMORY_RANGE, *PPHYSICAL_MEMORY_RANGE; + +typedef NTSTATUS +(NTAPI *PMM_ROTATE_COPY_CALLBACK_FUNCTION)( + IN PMDL DestinationMdl, + IN PMDL SourceMdl, + IN PVOID Context); + +typedef enum _MM_ROTATE_DIRECTION { + MmToFrameBuffer, + MmToFrameBufferNoCopy, + MmToRegularMemory, + MmToRegularMemoryNoCopy, + MmMaximumRotateDirection +} MM_ROTATE_DIRECTION, *PMM_ROTATE_DIRECTION; + + +/****************************************************************************** + * Process Manager Types * + ******************************************************************************/ + +#define QUOTA_LIMITS_HARDWS_MIN_ENABLE 0x00000001 +#define QUOTA_LIMITS_HARDWS_MIN_DISABLE 0x00000002 +#define QUOTA_LIMITS_HARDWS_MAX_ENABLE 0x00000004 +#define QUOTA_LIMITS_HARDWS_MAX_DISABLE 0x00000008 +#define QUOTA_LIMITS_USE_DEFAULT_LIMITS 0x00000010 + +typedef struct _QUOTA_LIMITS { + SIZE_T PagedPoolLimit; + SIZE_T NonPagedPoolLimit; + SIZE_T MinimumWorkingSetSize; + SIZE_T MaximumWorkingSetSize; + SIZE_T PagefileLimit; + LARGE_INTEGER TimeLimit; +} QUOTA_LIMITS, *PQUOTA_LIMITS; + +typedef union _RATE_QUOTA_LIMIT { + ULONG RateData; + struct { + ULONG RatePercent:7; + ULONG Reserved0:25; + } DUMMYSTRUCTNAME; +} RATE_QUOTA_LIMIT, *PRATE_QUOTA_LIMIT; + +typedef struct _QUOTA_LIMITS_EX { + SIZE_T PagedPoolLimit; + SIZE_T NonPagedPoolLimit; + SIZE_T MinimumWorkingSetSize; + SIZE_T MaximumWorkingSetSize; + SIZE_T PagefileLimit; + LARGE_INTEGER TimeLimit; + SIZE_T WorkingSetLimit; + SIZE_T Reserved2; + SIZE_T Reserved3; + SIZE_T Reserved4; + ULONG Flags; + RATE_QUOTA_LIMIT CpuRateLimit; +} QUOTA_LIMITS_EX, *PQUOTA_LIMITS_EX; + +typedef struct _IO_COUNTERS { + ULONGLONG ReadOperationCount; + ULONGLONG WriteOperationCount; + ULONGLONG OtherOperationCount; + ULONGLONG ReadTransferCount; + ULONGLONG WriteTransferCount; + ULONGLONG OtherTransferCount; +} IO_COUNTERS, *PIO_COUNTERS; + +typedef struct _VM_COUNTERS { + SIZE_T PeakVirtualSize; + SIZE_T VirtualSize; + ULONG PageFaultCount; + SIZE_T PeakWorkingSetSize; + SIZE_T WorkingSetSize; + SIZE_T QuotaPeakPagedPoolUsage; + SIZE_T QuotaPagedPoolUsage; + SIZE_T QuotaPeakNonPagedPoolUsage; + SIZE_T QuotaNonPagedPoolUsage; + SIZE_T PagefileUsage; + SIZE_T PeakPagefileUsage; +} VM_COUNTERS, *PVM_COUNTERS; + +typedef struct _VM_COUNTERS_EX { + SIZE_T PeakVirtualSize; + SIZE_T VirtualSize; + ULONG PageFaultCount; + SIZE_T PeakWorkingSetSize; + SIZE_T WorkingSetSize; + SIZE_T QuotaPeakPagedPoolUsage; + SIZE_T QuotaPagedPoolUsage; + SIZE_T QuotaPeakNonPagedPoolUsage; + SIZE_T QuotaNonPagedPoolUsage; + SIZE_T PagefileUsage; + SIZE_T PeakPagefileUsage; + SIZE_T PrivateUsage; +} VM_COUNTERS_EX, *PVM_COUNTERS_EX; + +#define MAX_HW_COUNTERS 16 +#define THREAD_PROFILING_FLAG_DISPATCH 0x00000001 + +typedef enum _HARDWARE_COUNTER_TYPE { + PMCCounter, + MaxHardwareCounterType +} HARDWARE_COUNTER_TYPE, *PHARDWARE_COUNTER_TYPE; + +typedef struct _HARDWARE_COUNTER { + HARDWARE_COUNTER_TYPE Type; + ULONG Reserved; + ULONG64 Index; +} HARDWARE_COUNTER, *PHARDWARE_COUNTER; + +typedef struct _POOLED_USAGE_AND_LIMITS { + SIZE_T PeakPagedPoolUsage; + SIZE_T PagedPoolUsage; + SIZE_T PagedPoolLimit; + SIZE_T PeakNonPagedPoolUsage; + SIZE_T NonPagedPoolUsage; + SIZE_T NonPagedPoolLimit; + SIZE_T PeakPagefileUsage; + SIZE_T PagefileUsage; + SIZE_T PagefileLimit; +} POOLED_USAGE_AND_LIMITS, *PPOOLED_USAGE_AND_LIMITS; + +typedef struct _PROCESS_ACCESS_TOKEN { + HANDLE Token; + HANDLE Thread; +} PROCESS_ACCESS_TOKEN, *PPROCESS_ACCESS_TOKEN; + +#define PROCESS_EXCEPTION_PORT_ALL_STATE_BITS 0x00000003UL +#define PROCESS_EXCEPTION_PORT_ALL_STATE_FLAGS ((ULONG_PTR)((1UL << PROCESS_EXCEPTION_PORT_ALL_STATE_BITS) - 1)) + +typedef struct _PROCESS_EXCEPTION_PORT { + IN HANDLE ExceptionPortHandle; + IN OUT ULONG StateFlags; +} PROCESS_EXCEPTION_PORT, *PPROCESS_EXCEPTION_PORT; + +typedef VOID +(NTAPI *PCREATE_PROCESS_NOTIFY_ROUTINE)( + IN HANDLE ParentId, + IN HANDLE ProcessId, + IN BOOLEAN Create); + +typedef struct _PS_CREATE_NOTIFY_INFO { + IN SIZE_T Size; + union { + IN ULONG Flags; + struct { + IN ULONG FileOpenNameAvailable:1; + IN ULONG Reserved:31; + }; + }; + IN HANDLE ParentProcessId; + IN CLIENT_ID CreatingThreadId; + IN OUT struct _FILE_OBJECT *FileObject; + IN PCUNICODE_STRING ImageFileName; + IN PCUNICODE_STRING CommandLine OPTIONAL; + IN OUT NTSTATUS CreationStatus; +} PS_CREATE_NOTIFY_INFO, *PPS_CREATE_NOTIFY_INFO; + +typedef VOID +(NTAPI *PCREATE_PROCESS_NOTIFY_ROUTINE_EX)( + IN OUT PEPROCESS Process, + IN HANDLE ProcessId, + IN PPS_CREATE_NOTIFY_INFO CreateInfo OPTIONAL); + +typedef VOID +(NTAPI *PCREATE_THREAD_NOTIFY_ROUTINE)( + IN HANDLE ProcessId, + IN HANDLE ThreadId, + IN BOOLEAN Create); + +#define IMAGE_ADDRESSING_MODE_32BIT 3 typedef struct _IMAGE_INFO { _ANONYMOUS_UNION union { @@ -834,7 +2258,7 @@ typedef struct _IMAGE_INFO { ULONG SystemModeImage:1; ULONG ImageMappedToAllPids:1; ULONG ExtendedInfoPresent:1; - ULONG Reserved:22; + ULONG Reserved:21; } DUMMYSTRUCTNAME; } DUMMYUNIONNAME; PVOID ImageBase; @@ -843,24 +2267,24 @@ typedef struct _IMAGE_INFO { ULONG ImageSectionNumber; } IMAGE_INFO, *PIMAGE_INFO; -#define IMAGE_ADDRESSING_MODE_32BIT 3 +typedef struct _IMAGE_INFO_EX { + SIZE_T Size; + IMAGE_INFO ImageInfo; + struct _FILE_OBJECT *FileObject; +} IMAGE_INFO_EX, *PIMAGE_INFO_EX; -typedef enum _BUS_DATA_TYPE { - ConfigurationSpaceUndefined = -1, - Cmos, - EisaConfiguration, - Pos, - CbusConfiguration, - PCIConfiguration, - VMEConfiguration, - NuBusConfiguration, - PCMCIAConfiguration, - MPIConfiguration, - MPSAConfiguration, - PNPISAConfiguration, - SgiInternalConfiguration, - MaximumBusDataType -} BUS_DATA_TYPE, *PBUS_DATA_TYPE; +typedef VOID +(NTAPI *PLOAD_IMAGE_NOTIFY_ROUTINE)( + IN PUNICODE_STRING FullImageName, + IN HANDLE ProcessId, + IN PIMAGE_INFO ImageInfo); + +#define THREAD_CSWITCH_PMU_DISABLE FALSE +#define THREAD_CSWITCH_PMU_ENABLE TRUE + +#define PROCESS_LUID_DOSDEVICES_ONLY 0x00000001 + +#define PROCESS_HANDLE_TRACING_MAX_STACKS 16 typedef struct _NT_TIB { struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList; @@ -994,6 +2418,15 @@ typedef enum _THREADINFOCLASS { MaxThreadInfoClass } THREADINFOCLASS; +typedef struct _PAGE_PRIORITY_INFORMATION { + ULONG PagePriority; +} PAGE_PRIORITY_INFORMATION, *PPAGE_PRIORITY_INFORMATION; + +typedef struct _PROCESS_WS_WATCH_INFORMATION { + PVOID FaultingPc; + PVOID FaultingVa; +} PROCESS_WS_WATCH_INFORMATION, *PPROCESS_WS_WATCH_INFORMATION; + typedef struct _PROCESS_BASIC_INFORMATION { NTSTATUS ExitStatus; struct _PEB *PebBaseAddress; @@ -1003,10 +2436,20 @@ typedef struct _PROCESS_BASIC_INFORMATION { ULONG_PTR InheritedFromUniqueProcessId; } PROCESS_BASIC_INFORMATION,*PPROCESS_BASIC_INFORMATION; -typedef struct _PROCESS_WS_WATCH_INFORMATION { - PVOID FaultingPc; - PVOID FaultingVa; -} PROCESS_WS_WATCH_INFORMATION, *PPROCESS_WS_WATCH_INFORMATION; +typedef struct _PROCESS_EXTENDED_BASIC_INFORMATION { + SIZE_T Size; + PROCESS_BASIC_INFORMATION BasicInfo; + union { + ULONG Flags; + struct { + ULONG IsProtectedProcess:1; + ULONG IsWow64Process:1; + ULONG IsProcessDeleting:1; + ULONG IsCrossSessionCreate:1; + ULONG SpareBits:28; + } DUMMYSTRUCTNAME; + } DUMMYUNIONNAME; +} PROCESS_EXTENDED_BASIC_INFORMATION, *PPROCESS_EXTENDED_BASIC_INFORMATION; typedef struct _PROCESS_DEVICEMAP_INFORMATION { __GNU_EXTENSION union { @@ -1020,514 +2463,263 @@ typedef struct _PROCESS_DEVICEMAP_INFORMATION { }; } PROCESS_DEVICEMAP_INFORMATION, *PPROCESS_DEVICEMAP_INFORMATION; -typedef struct _KERNEL_USER_TIMES { - LARGE_INTEGER CreateTime; - LARGE_INTEGER ExitTime; - LARGE_INTEGER KernelTime; - LARGE_INTEGER UserTime; -} KERNEL_USER_TIMES, *PKERNEL_USER_TIMES; - -typedef struct _PROCESS_ACCESS_TOKEN { - HANDLE Token; - HANDLE Thread; -} PROCESS_ACCESS_TOKEN, *PPROCESS_ACCESS_TOKEN; +typedef struct _PROCESS_DEVICEMAP_INFORMATION_EX { + union { + struct { + HANDLE DirectoryHandle; + } Set; + struct { + ULONG DriveMap; + UCHAR DriveType[32]; + } Query; + } DUMMYUNIONNAME; + ULONG Flags; +} PROCESS_DEVICEMAP_INFORMATION_EX, *PPROCESS_DEVICEMAP_INFORMATION_EX; typedef struct _PROCESS_SESSION_INFORMATION { ULONG SessionId; } PROCESS_SESSION_INFORMATION, *PPROCESS_SESSION_INFORMATION; -typedef enum _IO_QUERY_DEVICE_DATA_FORMAT { - IoQueryDeviceIdentifier = 0, - IoQueryDeviceConfigurationData, - IoQueryDeviceComponentInformation, - IoQueryDeviceMaxData -} IO_QUERY_DEVICE_DATA_FORMAT, *PIO_QUERY_DEVICE_DATA_FORMAT; +typedef struct _PROCESS_HANDLE_TRACING_ENABLE { + ULONG Flags; +} PROCESS_HANDLE_TRACING_ENABLE, *PPROCESS_HANDLE_TRACING_ENABLE; -typedef struct _DISK_SIGNATURE { - ULONG PartitionStyle; - _ANONYMOUS_UNION union { - struct { - ULONG Signature; - ULONG CheckSum; - } Mbr; - struct { - GUID DiskId; - } Gpt; - } DUMMYUNIONNAME; -} DISK_SIGNATURE, *PDISK_SIGNATURE; +typedef struct _PROCESS_HANDLE_TRACING_ENABLE_EX { + ULONG Flags; + ULONG TotalSlots; +} PROCESS_HANDLE_TRACING_ENABLE_EX, *PPROCESS_HANDLE_TRACING_ENABLE_EX; -typedef ULONG_PTR -(NTAPI *PDRIVER_VERIFIER_THUNK_ROUTINE)( - IN PVOID Context); +typedef struct _PROCESS_HANDLE_TRACING_ENTRY { + HANDLE Handle; + CLIENT_ID ClientId; + ULONG Type; + PVOID Stacks[PROCESS_HANDLE_TRACING_MAX_STACKS]; +} PROCESS_HANDLE_TRACING_ENTRY, *PPROCESS_HANDLE_TRACING_ENTRY; -typedef struct _DRIVER_VERIFIER_THUNK_PAIRS { - PDRIVER_VERIFIER_THUNK_ROUTINE PristineRoutine; - PDRIVER_VERIFIER_THUNK_ROUTINE NewRoutine; -} DRIVER_VERIFIER_THUNK_PAIRS, *PDRIVER_VERIFIER_THUNK_PAIRS; +typedef struct _PROCESS_HANDLE_TRACING_QUERY { + HANDLE Handle; + ULONG TotalTraces; + PROCESS_HANDLE_TRACING_ENTRY HandleTrace[1]; +} PROCESS_HANDLE_TRACING_QUERY, *PPROCESS_HANDLE_TRACING_QUERY; -#define DRIVER_VERIFIER_SPECIAL_POOLING 0x0001 -#define DRIVER_VERIFIER_FORCE_IRQL_CHECKING 0x0002 -#define DRIVER_VERIFIER_INJECT_ALLOCATION_FAILURES 0x0004 -#define DRIVER_VERIFIER_TRACK_POOL_ALLOCATIONS 0x0008 -#define DRIVER_VERIFIER_IO_CHECKING 0x0010 +extern NTKERNELAPI PEPROCESS PsInitialSystemProcess; + + +/****************************************************************************** + * Runtime Library Types * + ******************************************************************************/ + + + +#ifndef _RTL_RUN_ONCE_DEF +#define _RTL_RUN_ONCE_DEF + +#define RTL_RUN_ONCE_INIT {0} + +#define RTL_RUN_ONCE_CHECK_ONLY 0x00000001UL +#define RTL_RUN_ONCE_ASYNC 0x00000002UL +#define RTL_RUN_ONCE_INIT_FAILED 0x00000004UL + +#define RTL_RUN_ONCE_CTX_RESERVED_BITS 2 + +#define RTL_HASH_ALLOCATED_HEADER 0x00000001 + +#define RTL_HASH_RESERVED_SIGNATURE 0 + +/* RtlVerifyVersionInfo() ComparisonType */ + +#define VER_EQUAL 1 +#define VER_GREATER 2 +#define VER_GREATER_EQUAL 3 +#define VER_LESS 4 +#define VER_LESS_EQUAL 5 +#define VER_AND 6 +#define VER_OR 7 + +#define VER_CONDITION_MASK 7 +#define VER_NUM_BITS_PER_CONDITION_MASK 3 + +/* RtlVerifyVersionInfo() TypeMask */ + +#define VER_MINORVERSION 0x0000001 +#define VER_MAJORVERSION 0x0000002 +#define VER_BUILDNUMBER 0x0000004 +#define VER_PLATFORMID 0x0000008 +#define VER_SERVICEPACKMINOR 0x0000010 +#define VER_SERVICEPACKMAJOR 0x0000020 +#define VER_SUITENAME 0x0000040 +#define VER_PRODUCT_TYPE 0x0000080 + +#define VER_NT_WORKSTATION 0x0000001 +#define VER_NT_DOMAIN_CONTROLLER 0x0000002 +#define VER_NT_SERVER 0x0000003 + +#define VER_PLATFORM_WIN32s 0 +#define VER_PLATFORM_WIN32_WINDOWS 1 +#define VER_PLATFORM_WIN32_NT 2 + +typedef union _RTL_RUN_ONCE { + PVOID Ptr; +} RTL_RUN_ONCE, *PRTL_RUN_ONCE; + +typedef ULONG /* LOGICAL */ +(NTAPI *PRTL_RUN_ONCE_INIT_FN) ( + IN OUT PRTL_RUN_ONCE RunOnce, + IN OUT PVOID Parameter OPTIONAL, + IN OUT PVOID *Context OPTIONAL); + +#endif /* _RTL_RUN_ONCE_DEF */ + +typedef enum _TABLE_SEARCH_RESULT { + TableEmptyTree, + TableFoundNode, + TableInsertAsLeft, + TableInsertAsRight +} TABLE_SEARCH_RESULT; + +typedef enum _RTL_GENERIC_COMPARE_RESULTS { + GenericLessThan, + GenericGreaterThan, + GenericEqual +} RTL_GENERIC_COMPARE_RESULTS; + +// Forwarder +struct _RTL_AVL_TABLE; + +typedef RTL_GENERIC_COMPARE_RESULTS +(NTAPI *PRTL_AVL_COMPARE_ROUTINE) ( + IN struct _RTL_AVL_TABLE *Table, + IN PVOID FirstStruct, + IN PVOID SecondStruct); + +typedef PVOID +(NTAPI *PRTL_AVL_ALLOCATE_ROUTINE) ( + IN struct _RTL_AVL_TABLE *Table, + IN CLONG ByteSize); typedef VOID -(NTAPI *PTIMER_APC_ROUTINE)( - IN PVOID TimerContext, - IN ULONG TimerLowValue, - IN LONG TimerHighValue); +(NTAPI *PRTL_AVL_FREE_ROUTINE) ( + IN struct _RTL_AVL_TABLE *Table, + IN PVOID Buffer); -typedef struct _KUSER_SHARED_DATA -{ - ULONG TickCountLowDeprecated; - ULONG TickCountMultiplier; - volatile KSYSTEM_TIME InterruptTime; - volatile KSYSTEM_TIME SystemTime; - volatile KSYSTEM_TIME TimeZoneBias; - USHORT ImageNumberLow; - USHORT ImageNumberHigh; - WCHAR NtSystemRoot[260]; - ULONG MaxStackTraceDepth; - ULONG CryptoExponent; - ULONG TimeZoneId; - ULONG LargePageMinimum; - ULONG Reserved2[7]; - NT_PRODUCT_TYPE NtProductType; - BOOLEAN ProductTypeIsValid; - ULONG NtMajorVersion; - ULONG NtMinorVersion; - BOOLEAN ProcessorFeatures[PROCESSOR_FEATURE_MAX]; - ULONG Reserved1; - ULONG Reserved3; - volatile ULONG TimeSlip; - ALTERNATIVE_ARCHITECTURE_TYPE AlternativeArchitecture; - ULONG AltArchitecturePad[1]; - LARGE_INTEGER SystemExpirationDate; - ULONG SuiteMask; - BOOLEAN KdDebuggerEnabled; -#if (NTDDI_VERSION >= NTDDI_WINXPSP2) - UCHAR NXSupportPolicy; -#endif - volatile ULONG ActiveConsoleId; - volatile ULONG DismountCount; - ULONG ComPlusPackage; - ULONG LastSystemRITEventTickCount; - ULONG NumberOfPhysicalPages; - BOOLEAN SafeBootMode; -#if (NTDDI_VERSION >= NTDDI_WIN7) - union { - UCHAR TscQpcData; - struct { - UCHAR TscQpcEnabled:1; - UCHAR TscQpcSpareFlag:1; - UCHAR TscQpcShift:6; - } DUMMYSTRUCTNAME; - } DUMMYUNIONNAME; - UCHAR TscQpcPad[2]; -#endif -#if (NTDDI_VERSION >= NTDDI_VISTA) - union { - ULONG SharedDataFlags; - struct { - ULONG DbgErrorPortPresent:1; - ULONG DbgElevationEnabled:1; - ULONG DbgVirtEnabled:1; - ULONG DbgInstallerDetectEnabled:1; - ULONG DbgSystemDllRelocated:1; - ULONG DbgDynProcessorEnabled:1; - ULONG DbgSEHValidationEnabled:1; - ULONG SpareBits:25; - } DUMMYSTRUCTNAME2; - } DUMMYUNIONNAME2; -#else - ULONG TraceLogging; -#endif - ULONG DataFlagsPad[1]; - ULONGLONG TestRetInstruction; - ULONG SystemCall; - ULONG SystemCallReturn; - ULONGLONG SystemCallPad[3]; - _ANONYMOUS_UNION union { - volatile KSYSTEM_TIME TickCount; - volatile ULONG64 TickCountQuad; - _ANONYMOUS_STRUCT struct { - ULONG ReservedTickCountOverlay[3]; - ULONG TickCountPad[1]; - } DUMMYSTRUCTNAME; - } DUMMYUNIONNAME3; - ULONG Cookie; - ULONG CookiePad[1]; -#if (NTDDI_VERSION >= NTDDI_WS03) - LONGLONG ConsoleSessionForegroundProcessId; - ULONG Wow64SharedInformation[MAX_WOW64_SHARED_ENTRIES]; -#endif -#if (NTDDI_VERSION >= NTDDI_VISTA) -#if (NTDDI_VERSION >= NTDDI_WIN7) - USHORT UserModeGlobalLogger[16]; -#else - USHORT UserModeGlobalLogger[8]; - ULONG HeapTracingPid[2]; - ULONG CritSecTracingPid[2]; -#endif - ULONG ImageFileExecutionOptions; -#if (NTDDI_VERSION >= NTDDI_VISTASP1) - ULONG LangGenerationCount; -#else - /* 4 bytes padding */ -#endif - ULONGLONG Reserved5; - volatile ULONG64 InterruptTimeBias; -#endif -#if (NTDDI_VERSION >= NTDDI_WIN7) - volatile ULONG64 TscQpcBias; - volatile ULONG ActiveProcessorCount; - volatile USHORT ActiveGroupCount; - USHORT Reserved4; - volatile ULONG AitSamplingValue; - volatile ULONG AppCompatFlag; - ULONGLONG SystemDllNativeRelocation; - ULONG SystemDllWowRelocation; - ULONG XStatePad[1]; - XSTATE_CONFIGURATION XState; -#endif -} KUSER_SHARED_DATA, *PKUSER_SHARED_DATA; +typedef NTSTATUS +(NTAPI *PRTL_AVL_MATCH_FUNCTION) ( + IN struct _RTL_AVL_TABLE *Table, + IN PVOID UserData, + IN PVOID MatchData); -extern NTKERNELAPI PVOID MmHighestUserAddress; -extern NTKERNELAPI PVOID MmSystemRangeStart; -extern NTKERNELAPI ULONG MmUserProbeAddress; +typedef struct _RTL_BALANCED_LINKS { + struct _RTL_BALANCED_LINKS *Parent; + struct _RTL_BALANCED_LINKS *LeftChild; + struct _RTL_BALANCED_LINKS *RightChild; + CHAR Balance; + UCHAR Reserved[3]; +} RTL_BALANCED_LINKS, *PRTL_BALANCED_LINKS; +typedef struct _RTL_AVL_TABLE { + RTL_BALANCED_LINKS BalancedRoot; + PVOID OrderedPointer; + ULONG WhichOrderedElement; + ULONG NumberGenericTableElements; + ULONG DepthOfTree; + PRTL_BALANCED_LINKS RestartKey; + ULONG DeleteCount; + PRTL_AVL_COMPARE_ROUTINE CompareRoutine; + PRTL_AVL_ALLOCATE_ROUTINE AllocateRoutine; + PRTL_AVL_FREE_ROUTINE FreeRoutine; + PVOID TableContext; +} RTL_AVL_TABLE, *PRTL_AVL_TABLE; -#ifdef _X86_ +#ifndef RTL_USE_AVL_TABLES -#define MM_HIGHEST_USER_ADDRESS MmHighestUserAddress -#define MM_SYSTEM_RANGE_START MmSystemRangeStart -#if defined(_LOCAL_COPY_USER_PROBE_ADDRESS_) -#define MM_USER_PROBE_ADDRESS _LOCAL_COPY_USER_PROBE_ADDRESS_ -extern ULONG _LOCAL_COPY_USER_PROBE_ADDRESS_; -#else -#define MM_USER_PROBE_ADDRESS MmUserProbeAddress -#endif -#define MM_LOWEST_USER_ADDRESS (PVOID)0x10000 -#define MM_KSEG0_BASE MM_SYSTEM_RANGE_START -#define MM_SYSTEM_SPACE_END 0xFFFFFFFF -#if !defined (_X86PAE_) -#define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xC0800000 -#else -#define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xC0C00000 -#endif +struct _RTL_GENERIC_TABLE; -#define KeGetPcr() PCR +typedef RTL_GENERIC_COMPARE_RESULTS +(NTAPI *PRTL_GENERIC_COMPARE_ROUTINE) ( + IN struct _RTL_GENERIC_TABLE *Table, + IN PVOID FirstStruct, + IN PVOID SecondStruct); -#define KERNEL_STACK_SIZE 12288 -#define KERNEL_LARGE_STACK_SIZE 61440 -#define KERNEL_LARGE_STACK_COMMIT 12288 +typedef PVOID +(NTAPI *PRTL_GENERIC_ALLOCATE_ROUTINE) ( + IN struct _RTL_GENERIC_TABLE *Table, + IN CLONG ByteSize); -#define SIZE_OF_80387_REGISTERS 80 +typedef VOID +(NTAPI *PRTL_GENERIC_FREE_ROUTINE) ( + IN struct _RTL_GENERIC_TABLE *Table, + IN PVOID Buffer); -#define PCR_MINOR_VERSION 1 -#define PCR_MAJOR_VERSION 1 +typedef struct _RTL_SPLAY_LINKS { + struct _RTL_SPLAY_LINKS *Parent; + struct _RTL_SPLAY_LINKS *LeftChild; + struct _RTL_SPLAY_LINKS *RightChild; +} RTL_SPLAY_LINKS, *PRTL_SPLAY_LINKS; -#if !defined(RC_INVOKED) +typedef struct _RTL_GENERIC_TABLE { + PRTL_SPLAY_LINKS TableRoot; + LIST_ENTRY InsertOrderList; + PLIST_ENTRY OrderedPointer; + ULONG WhichOrderedElement; + ULONG NumberGenericTableElements; + PRTL_GENERIC_COMPARE_ROUTINE CompareRoutine; + PRTL_GENERIC_ALLOCATE_ROUTINE AllocateRoutine; + PRTL_GENERIC_FREE_ROUTINE FreeRoutine; + PVOID TableContext; +} RTL_GENERIC_TABLE, *PRTL_GENERIC_TABLE; -#define CONTEXT_i386 0x10000 -#define CONTEXT_i486 0x10000 -#define CONTEXT_CONTROL (CONTEXT_i386|0x00000001L) -#define CONTEXT_INTEGER (CONTEXT_i386|0x00000002L) -#define CONTEXT_SEGMENTS (CONTEXT_i386|0x00000004L) -#define CONTEXT_FLOATING_POINT (CONTEXT_i386|0x00000008L) -#define CONTEXT_DEBUG_REGISTERS (CONTEXT_i386|0x00000010L) -#define CONTEXT_EXTENDED_REGISTERS (CONTEXT_i386|0x00000020L) +#endif /* !RTL_USE_AVL_TABLES */ -#define CONTEXT_FULL (CONTEXT_CONTROL|CONTEXT_INTEGER|CONTEXT_SEGMENTS) +#ifdef RTL_USE_AVL_TABLES -#endif /* !defined(RC_INVOKED) */ +#undef PRTL_GENERIC_COMPARE_ROUTINE +#undef RTL_GENERIC_COMPARE_ROUTINE +#undef PRTL_GENERIC_ALLOCATE_ROUTINE +#undef RTL_GENERIC_ALLOCATE_ROUTINE +#undef PRTL_GENERIC_FREE_ROUTINE +#undef RTL_GENERIC_FREE_ROUTINE +#undef RTL_GENERIC_TABLE +#undef PRTL_GENERIC_TABLE -typedef struct _KPCR { - union { - NT_TIB NtTib; - struct { - struct _EXCEPTION_REGISTRATION_RECORD *Used_ExceptionList; - PVOID Used_StackBase; - PVOID Spare2; - PVOID TssCopy; - ULONG ContextSwitches; - KAFFINITY SetMemberCopy; - PVOID Used_Self; - }; - }; - struct _KPCR *SelfPcr; - struct _KPRCB *Prcb; - KIRQL Irql; - ULONG IRR; - ULONG IrrActive; - ULONG IDR; - PVOID KdVersionBlock; - struct _KIDTENTRY *IDT; - struct _KGDTENTRY *GDT; - struct _KTSS *TSS; - USHORT MajorVersion; - USHORT MinorVersion; - KAFFINITY SetMember; - ULONG StallScaleFactor; - UCHAR SpareUnused; - UCHAR Number; - UCHAR Spare0; - UCHAR SecondLevelCacheAssociativity; - ULONG VdmAlert; - ULONG KernelReserved[14]; - ULONG SecondLevelCacheSize; - ULONG HalReserved[16]; -} KPCR, *PKPCR; +#define PRTL_GENERIC_COMPARE_ROUTINE PRTL_AVL_COMPARE_ROUTINE +#define RTL_GENERIC_COMPARE_ROUTINE RTL_AVL_COMPARE_ROUTINE +#define PRTL_GENERIC_ALLOCATE_ROUTINE PRTL_AVL_ALLOCATE_ROUTINE +#define RTL_GENERIC_ALLOCATE_ROUTINE RTL_AVL_ALLOCATE_ROUTINE +#define PRTL_GENERIC_FREE_ROUTINE PRTL_AVL_FREE_ROUTINE +#define RTL_GENERIC_FREE_ROUTINE RTL_AVL_FREE_ROUTINE +#define RTL_GENERIC_TABLE RTL_AVL_TABLE +#define PRTL_GENERIC_TABLE PRTL_AVL_TABLE -FORCEINLINE -ULONG -KeGetCurrentProcessorNumber(VOID) -{ - return (ULONG)__readfsbyte(FIELD_OFFSET(KPCR, Number)); -} +#endif /* RTL_USE_AVL_TABLES */ -typedef struct _FLOATING_SAVE_AREA { - ULONG ControlWord; - ULONG StatusWord; - ULONG TagWord; - ULONG ErrorOffset; - ULONG ErrorSelector; - ULONG DataOffset; - ULONG DataSelector; - UCHAR RegisterArea[SIZE_OF_80387_REGISTERS]; - ULONG Cr0NpxState; -} FLOATING_SAVE_AREA, *PFLOATING_SAVE_AREA; +typedef struct _RTL_DYNAMIC_HASH_TABLE_ENTRY { + LIST_ENTRY Linkage; + ULONG_PTR Signature; +} RTL_DYNAMIC_HASH_TABLE_ENTRY, *PRTL_DYNAMIC_HASH_TABLE_ENTRY; -#include "pshpack4.h" -typedef struct _CONTEXT { - ULONG ContextFlags; - ULONG Dr0; - ULONG Dr1; - ULONG Dr2; - ULONG Dr3; - ULONG Dr6; - ULONG Dr7; - FLOATING_SAVE_AREA FloatSave; - ULONG SegGs; - ULONG SegFs; - ULONG SegEs; - ULONG SegDs; - ULONG Edi; - ULONG Esi; - ULONG Ebx; - ULONG Edx; - ULONG Ecx; - ULONG Eax; - ULONG Ebp; - ULONG Eip; - ULONG SegCs; - ULONG EFlags; - ULONG Esp; - ULONG SegSs; - UCHAR ExtendedRegisters[MAXIMUM_SUPPORTED_EXTENSION]; -} CONTEXT; -#include "poppack.h" +typedef struct _RTL_DYNAMIC_HASH_TABLE_CONTEXT { + PLIST_ENTRY ChainHead; + PLIST_ENTRY PrevLinkage; + ULONG_PTR Signature; +} RTL_DYNAMIC_HASH_TABLE_CONTEXT, *PRTL_DYNAMIC_HASH_TABLE_CONTEXT; -#endif /* _X86_ */ +typedef struct _RTL_DYNAMIC_HASH_TABLE_ENUMERATOR { + RTL_DYNAMIC_HASH_TABLE_ENTRY HashEntry; + PLIST_ENTRY ChainHead; + ULONG BucketIndex; +} RTL_DYNAMIC_HASH_TABLE_ENUMERATOR, *PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR; -#ifdef _AMD64_ - -#define PTI_SHIFT 12L -#define PDI_SHIFT 21L -#define PPI_SHIFT 30L -#define PXI_SHIFT 39L -#define PTE_PER_PAGE 512 -#define PDE_PER_PAGE 512 -#define PPE_PER_PAGE 512 -#define PXE_PER_PAGE 512 -#define PTI_MASK_AMD64 (PTE_PER_PAGE - 1) -#define PDI_MASK_AMD64 (PDE_PER_PAGE - 1) -#define PPI_MASK (PPE_PER_PAGE - 1) -#define PXI_MASK (PXE_PER_PAGE - 1) - -#define PXE_BASE 0xFFFFF6FB7DBED000ULL -#define PXE_SELFMAP 0xFFFFF6FB7DBEDF68ULL -#define PPE_BASE 0xFFFFF6FB7DA00000ULL -#define PDE_BASE 0xFFFFF6FB40000000ULL -#define PTE_BASE 0xFFFFF68000000000ULL -#define PXE_TOP 0xFFFFF6FB7DBEDFFFULL -#define PPE_TOP 0xFFFFF6FB7DBFFFFFULL -#define PDE_TOP 0xFFFFF6FB7FFFFFFFULL -#define PTE_TOP 0xFFFFF6FFFFFFFFFFULL - -#define MM_HIGHEST_USER_ADDRESS MmHighestUserAddress -#define MM_SYSTEM_RANGE_START MmSystemRangeStart -#define MM_USER_PROBE_ADDRESS MmUserProbeAddress -#define MM_LOWEST_USER_ADDRESS (PVOID)0x10000 -#define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xFFFF080000000000ULL -#define KI_USER_SHARED_DATA 0xFFFFF78000000000ULL - -typedef struct DECLSPEC_ALIGN(16) _CONTEXT { - ULONG64 P1Home; - ULONG64 P2Home; - ULONG64 P3Home; - ULONG64 P4Home; - ULONG64 P5Home; - ULONG64 P6Home; - - /* Control flags */ - ULONG ContextFlags; - ULONG MxCsr; - - /* Segment */ - USHORT SegCs; - USHORT SegDs; - USHORT SegEs; - USHORT SegFs; - USHORT SegGs; - USHORT SegSs; - ULONG EFlags; - - /* Debug */ - ULONG64 Dr0; - ULONG64 Dr1; - ULONG64 Dr2; - ULONG64 Dr3; - ULONG64 Dr6; - ULONG64 Dr7; - - /* Integer */ - ULONG64 Rax; - ULONG64 Rcx; - ULONG64 Rdx; - ULONG64 Rbx; - ULONG64 Rsp; - ULONG64 Rbp; - ULONG64 Rsi; - ULONG64 Rdi; - ULONG64 R8; - ULONG64 R9; - ULONG64 R10; - ULONG64 R11; - ULONG64 R12; - ULONG64 R13; - ULONG64 R14; - ULONG64 R15; - - /* Counter */ - ULONG64 Rip; - - /* Floating point */ - union { - XMM_SAVE_AREA32 FltSave; - struct { - M128A Header[2]; - M128A Legacy[8]; - M128A Xmm0; - M128A Xmm1; - M128A Xmm2; - M128A Xmm3; - M128A Xmm4; - M128A Xmm5; - M128A Xmm6; - M128A Xmm7; - M128A Xmm8; - M128A Xmm9; - M128A Xmm10; - M128A Xmm11; - M128A Xmm12; - M128A Xmm13; - M128A Xmm14; - M128A Xmm15; - } DUMMYSTRUCTNAME; - } DUMMYUNIONNAME; - - /* Vector */ - M128A VectorRegister[26]; - ULONG64 VectorControl; - - /* Debug control */ - ULONG64 DebugControl; - ULONG64 LastBranchToRip; - ULONG64 LastBranchFromRip; - ULONG64 LastExceptionToRip; - ULONG64 LastExceptionFromRip; -} CONTEXT; - -typedef struct _KPCR -{ - _ANONYMOUS_UNION union - { - NT_TIB NtTib; - _ANONYMOUS_STRUCT struct - { - union _KGDTENTRY64 *GdtBase; - struct _KTSS64 *TssBase; - ULONG64 UserRsp; - struct _KPCR *Self; - struct _KPRCB *CurrentPrcb; - PKSPIN_LOCK_QUEUE LockArray; - PVOID Used_Self; - }; - }; - union _KIDTENTRY64 *IdtBase; - ULONG64 Unused[2]; - KIRQL Irql; - UCHAR SecondLevelCacheAssociativity; - UCHAR ObsoleteNumber; - UCHAR Fill0; - ULONG Unused0[3]; - USHORT MajorVersion; - USHORT MinorVersion; - ULONG StallScaleFactor; - PVOID Unused1[3]; - ULONG KernelReserved[15]; - ULONG SecondLevelCacheSize; - ULONG HalReserved[16]; - ULONG Unused2; - PVOID KdVersionBlock; - PVOID Unused3; - ULONG PcrAlign1[24]; -} KPCR, *PKPCR; - -FORCEINLINE -PKPCR -KeGetPcr(VOID) -{ - return (PKPCR)__readgsqword(FIELD_OFFSET(KPCR, Self)); -} - -FORCEINLINE -ULONG -KeGetCurrentProcessorNumber(VOID) -{ - return (ULONG)__readgsword(0x184); -} - -#if !defined(RC_INVOKED) - -#define CONTEXT_AMD64 0x100000 - -#define CONTEXT_CONTROL (CONTEXT_AMD64 | 0x1L) -#define CONTEXT_INTEGER (CONTEXT_AMD64 | 0x2L) -#define CONTEXT_SEGMENTS (CONTEXT_AMD64 | 0x4L) -#define CONTEXT_FLOATING_POINT (CONTEXT_AMD64 | 0x8L) -#define CONTEXT_DEBUG_REGISTERS (CONTEXT_AMD64 | 0x10L) - -#define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT) -#define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS) - -#define CONTEXT_XSTATE (CONTEXT_AMD64 | 0x20L) - -#define CONTEXT_EXCEPTION_ACTIVE 0x8000000 -#define CONTEXT_SERVICE_ACTIVE 0x10000000 -#define CONTEXT_EXCEPTION_REQUEST 0x40000000 -#define CONTEXT_EXCEPTION_REPORTING 0x80000000 - -#endif /* RC_INVOKED */ - -#endif /* _AMD64_ */ - -typedef enum _INTERLOCKED_RESULT { - ResultNegative = RESULT_NEGATIVE, - ResultZero = RESULT_ZERO, - ResultPositive = RESULT_POSITIVE -} INTERLOCKED_RESULT; +typedef struct _RTL_DYNAMIC_HASH_TABLE { + ULONG Flags; + ULONG Shift; + ULONG TableSize; + ULONG Pivot; + ULONG DivisorMask; + ULONG NumEntries; + ULONG NonEmptyBuckets; + ULONG NumEnumerators; + PVOID Directory; +} RTL_DYNAMIC_HASH_TABLE, *PRTL_DYNAMIC_HASH_TABLE; typedef struct _OSVERSIONINFOA { ULONG dwOSVersionInfoSize; @@ -1591,24 +2783,461 @@ typedef POSVERSIONINFOA POSVERSIONINFO; typedef LPOSVERSIONINFOA LPOSVERSIONINFO; #endif /* UNICODE */ -/* Executive Types */ +#define HASH_ENTRY_KEY(x) ((x)->Signature) -#define PROTECTED_POOL 0x80000000 +/****************************************************************************** + * Security Manager Types * + ******************************************************************************/ +#define SE_UNSOLICITED_INPUT_PRIVILEGE 6 -typedef struct _ZONE_SEGMENT_HEADER { - SINGLE_LIST_ENTRY SegmentList; - PVOID Reserved; -} ZONE_SEGMENT_HEADER, *PZONE_SEGMENT_HEADER; +typedef enum _WELL_KNOWN_SID_TYPE { + WinNullSid = 0, + WinWorldSid = 1, + WinLocalSid = 2, + WinCreatorOwnerSid = 3, + WinCreatorGroupSid = 4, + WinCreatorOwnerServerSid = 5, + WinCreatorGroupServerSid = 6, + WinNtAuthoritySid = 7, + WinDialupSid = 8, + WinNetworkSid = 9, + WinBatchSid = 10, + WinInteractiveSid = 11, + WinServiceSid = 12, + WinAnonymousSid = 13, + WinProxySid = 14, + WinEnterpriseControllersSid = 15, + WinSelfSid = 16, + WinAuthenticatedUserSid = 17, + WinRestrictedCodeSid = 18, + WinTerminalServerSid = 19, + WinRemoteLogonIdSid = 20, + WinLogonIdsSid = 21, + WinLocalSystemSid = 22, + WinLocalServiceSid = 23, + WinNetworkServiceSid = 24, + WinBuiltinDomainSid = 25, + WinBuiltinAdministratorsSid = 26, + WinBuiltinUsersSid = 27, + WinBuiltinGuestsSid = 28, + WinBuiltinPowerUsersSid = 29, + WinBuiltinAccountOperatorsSid = 30, + WinBuiltinSystemOperatorsSid = 31, + WinBuiltinPrintOperatorsSid = 32, + WinBuiltinBackupOperatorsSid = 33, + WinBuiltinReplicatorSid = 34, + WinBuiltinPreWindows2000CompatibleAccessSid = 35, + WinBuiltinRemoteDesktopUsersSid = 36, + WinBuiltinNetworkConfigurationOperatorsSid = 37, + WinAccountAdministratorSid = 38, + WinAccountGuestSid = 39, + WinAccountKrbtgtSid = 40, + WinAccountDomainAdminsSid = 41, + WinAccountDomainUsersSid = 42, + WinAccountDomainGuestsSid = 43, + WinAccountComputersSid = 44, + WinAccountControllersSid = 45, + WinAccountCertAdminsSid = 46, + WinAccountSchemaAdminsSid = 47, + WinAccountEnterpriseAdminsSid = 48, + WinAccountPolicyAdminsSid = 49, + WinAccountRasAndIasServersSid = 50, + WinNTLMAuthenticationSid = 51, + WinDigestAuthenticationSid = 52, + WinSChannelAuthenticationSid = 53, + WinThisOrganizationSid = 54, + WinOtherOrganizationSid = 55, + WinBuiltinIncomingForestTrustBuildersSid = 56, + WinBuiltinPerfMonitoringUsersSid = 57, + WinBuiltinPerfLoggingUsersSid = 58, + WinBuiltinAuthorizationAccessSid = 59, + WinBuiltinTerminalServerLicenseServersSid = 60, + WinBuiltinDCOMUsersSid = 61, + WinBuiltinIUsersSid = 62, + WinIUserSid = 63, + WinBuiltinCryptoOperatorsSid = 64, + WinUntrustedLabelSid = 65, + WinLowLabelSid = 66, + WinMediumLabelSid = 67, + WinHighLabelSid = 68, + WinSystemLabelSid = 69, + WinWriteRestrictedCodeSid = 70, + WinCreatorOwnerRightsSid = 71, + WinCacheablePrincipalsGroupSid = 72, + WinNonCacheablePrincipalsGroupSid = 73, + WinEnterpriseReadonlyControllersSid = 74, + WinAccountReadonlyControllersSid = 75, + WinBuiltinEventLogReadersGroup = 76, + WinNewEnterpriseReadonlyControllersSid = 77, + WinBuiltinCertSvcDComAccessGroup = 78, + WinMediumPlusLabelSid = 79, + WinLocalLogonSid = 80, + WinConsoleLogonSid = 81, + WinThisOrganizationCertificateSid = 82, +} WELL_KNOWN_SID_TYPE; -typedef struct _ZONE_HEADER { - SINGLE_LIST_ENTRY FreeList; - SINGLE_LIST_ENTRY SegmentList; - ULONG BlockSize; - ULONG TotalSegmentSize; -} ZONE_HEADER, *PZONE_HEADER; -/* Executive Functions */ +#if defined(_M_IX86) + +#define PAUSE_PROCESSOR YieldProcessor(); + +#define KERNEL_STACK_SIZE 12288 +#define KERNEL_LARGE_STACK_SIZE 61440 +#define KERNEL_LARGE_STACK_COMMIT 12288 + +#define SIZE_OF_80387_REGISTERS 80 + +#if !defined(RC_INVOKED) + +#define CONTEXT_i386 0x10000 +#define CONTEXT_i486 0x10000 +#define CONTEXT_CONTROL (CONTEXT_i386|0x00000001L) +#define CONTEXT_INTEGER (CONTEXT_i386|0x00000002L) +#define CONTEXT_SEGMENTS (CONTEXT_i386|0x00000004L) +#define CONTEXT_FLOATING_POINT (CONTEXT_i386|0x00000008L) +#define CONTEXT_DEBUG_REGISTERS (CONTEXT_i386|0x00000010L) +#define CONTEXT_EXTENDED_REGISTERS (CONTEXT_i386|0x00000020L) + +#define CONTEXT_FULL (CONTEXT_CONTROL|CONTEXT_INTEGER|CONTEXT_SEGMENTS) +#define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | \ + CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS | \ + CONTEXT_EXTENDED_REGISTERS) + +#define CONTEXT_XSTATE (CONTEXT_i386 | 0x00000040L) + +#endif /* !defined(RC_INVOKED) */ + +typedef struct _FLOATING_SAVE_AREA { + ULONG ControlWord; + ULONG StatusWord; + ULONG TagWord; + ULONG ErrorOffset; + ULONG ErrorSelector; + ULONG DataOffset; + ULONG DataSelector; + UCHAR RegisterArea[SIZE_OF_80387_REGISTERS]; + ULONG Cr0NpxState; +} FLOATING_SAVE_AREA, *PFLOATING_SAVE_AREA; + +#include "pshpack4.h" +typedef struct _CONTEXT { + ULONG ContextFlags; + ULONG Dr0; + ULONG Dr1; + ULONG Dr2; + ULONG Dr3; + ULONG Dr6; + ULONG Dr7; + FLOATING_SAVE_AREA FloatSave; + ULONG SegGs; + ULONG SegFs; + ULONG SegEs; + ULONG SegDs; + ULONG Edi; + ULONG Esi; + ULONG Ebx; + ULONG Edx; + ULONG Ecx; + ULONG Eax; + ULONG Ebp; + ULONG Eip; + ULONG SegCs; + ULONG EFlags; + ULONG Esp; + ULONG SegSs; + UCHAR ExtendedRegisters[MAXIMUM_SUPPORTED_EXTENSION]; +} CONTEXT; +#include "poppack.h" + +#define KeGetPcr() PCR + +#define PCR_MINOR_VERSION 1 +#define PCR_MAJOR_VERSION 1 + +typedef struct _KPCR { + union { + NT_TIB NtTib; + struct { + struct _EXCEPTION_REGISTRATION_RECORD *Used_ExceptionList; + PVOID Used_StackBase; + PVOID Spare2; + PVOID TssCopy; + ULONG ContextSwitches; + KAFFINITY SetMemberCopy; + PVOID Used_Self; + }; + }; + struct _KPCR *SelfPcr; + struct _KPRCB *Prcb; + KIRQL Irql; + ULONG IRR; + ULONG IrrActive; + ULONG IDR; + PVOID KdVersionBlock; + struct _KIDTENTRY *IDT; + struct _KGDTENTRY *GDT; + struct _KTSS *TSS; + USHORT MajorVersion; + USHORT MinorVersion; + KAFFINITY SetMember; + ULONG StallScaleFactor; + UCHAR SpareUnused; + UCHAR Number; + UCHAR Spare0; + UCHAR SecondLevelCacheAssociativity; + ULONG VdmAlert; + ULONG KernelReserved[14]; + ULONG SecondLevelCacheSize; + ULONG HalReserved[16]; +} KPCR, *PKPCR; + +FORCEINLINE +ULONG +KeGetCurrentProcessorNumber(VOID) +{ + return (ULONG)__readfsbyte(FIELD_OFFSET(KPCR, Number)); +} + + + + + + +extern NTKERNELAPI PVOID MmHighestUserAddress; +extern NTKERNELAPI PVOID MmSystemRangeStart; +extern NTKERNELAPI ULONG MmUserProbeAddress; + +#define MM_HIGHEST_USER_ADDRESS MmHighestUserAddress +#define MM_SYSTEM_RANGE_START MmSystemRangeStart +#if defined(_LOCAL_COPY_USER_PROBE_ADDRESS_) +#define MM_USER_PROBE_ADDRESS _LOCAL_COPY_USER_PROBE_ADDRESS_ +extern ULONG _LOCAL_COPY_USER_PROBE_ADDRESS_; +#else +#define MM_USER_PROBE_ADDRESS MmUserProbeAddress +#endif +#define MM_LOWEST_USER_ADDRESS (PVOID)0x10000 +#define MM_KSEG0_BASE MM_SYSTEM_RANGE_START +#define MM_SYSTEM_SPACE_END 0xFFFFFFFF +#if !defined (_X86PAE_) +#define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xC0800000 +#else +#define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xC0C00000 +#endif + +#elif defined(_M_AMD64) + +#define PAUSE_PROCESSOR YieldProcessor(); + +#define KERNEL_STACK_SIZE 0x6000 +#define KERNEL_LARGE_STACK_SIZE 0x12000 +#define KERNEL_LARGE_STACK_COMMIT KERNEL_STACK_SIZE + +#define KERNEL_MCA_EXCEPTION_STACK_SIZE 0x2000 + +#define EXCEPTION_READ_FAULT 0 +#define EXCEPTION_WRITE_FAULT 1 +#define EXCEPTION_EXECUTE_FAULT 8 + +#if !defined(RC_INVOKED) + +#define CONTEXT_AMD64 0x100000 + +#define CONTEXT_CONTROL (CONTEXT_AMD64 | 0x1L) +#define CONTEXT_INTEGER (CONTEXT_AMD64 | 0x2L) +#define CONTEXT_SEGMENTS (CONTEXT_AMD64 | 0x4L) +#define CONTEXT_FLOATING_POINT (CONTEXT_AMD64 | 0x8L) +#define CONTEXT_DEBUG_REGISTERS (CONTEXT_AMD64 | 0x10L) + +#define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_FLOATING_POINT) +#define CONTEXT_ALL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS) + +#define CONTEXT_XSTATE (CONTEXT_AMD64 | 0x20L) + +#define CONTEXT_EXCEPTION_ACTIVE 0x8000000 +#define CONTEXT_SERVICE_ACTIVE 0x10000000 +#define CONTEXT_EXCEPTION_REQUEST 0x40000000 +#define CONTEXT_EXCEPTION_REPORTING 0x80000000 + +#endif /* !defined(RC_INVOKED) */ + +#define INITIAL_MXCSR 0x1f80 +#define INITIAL_FPCSR 0x027f + +typedef struct DECLSPEC_ALIGN(16) _CONTEXT { + ULONG64 P1Home; + ULONG64 P2Home; + ULONG64 P3Home; + ULONG64 P4Home; + ULONG64 P5Home; + ULONG64 P6Home; + ULONG ContextFlags; + ULONG MxCsr; + USHORT SegCs; + USHORT SegDs; + USHORT SegEs; + USHORT SegFs; + USHORT SegGs; + USHORT SegSs; + ULONG EFlags; + ULONG64 Dr0; + ULONG64 Dr1; + ULONG64 Dr2; + ULONG64 Dr3; + ULONG64 Dr6; + ULONG64 Dr7; + ULONG64 Rax; + ULONG64 Rcx; + ULONG64 Rdx; + ULONG64 Rbx; + ULONG64 Rsp; + ULONG64 Rbp; + ULONG64 Rsi; + ULONG64 Rdi; + ULONG64 R8; + ULONG64 R9; + ULONG64 R10; + ULONG64 R11; + ULONG64 R12; + ULONG64 R13; + ULONG64 R14; + ULONG64 R15; + ULONG64 Rip; + union { + XMM_SAVE_AREA32 FltSave; + struct { + M128A Header[2]; + M128A Legacy[8]; + M128A Xmm0; + M128A Xmm1; + M128A Xmm2; + M128A Xmm3; + M128A Xmm4; + M128A Xmm5; + M128A Xmm6; + M128A Xmm7; + M128A Xmm8; + M128A Xmm9; + M128A Xmm10; + M128A Xmm11; + M128A Xmm12; + M128A Xmm13; + M128A Xmm14; + M128A Xmm15; + } DUMMYSTRUCTNAME; + } DUMMYUNIONNAME; + M128A VectorRegister[26]; + ULONG64 VectorControl; + ULONG64 DebugControl; + ULONG64 LastBranchToRip; + ULONG64 LastBranchFromRip; + ULONG64 LastExceptionToRip; + ULONG64 LastExceptionFromRip; +} CONTEXT; + +#define PCR_MINOR_VERSION 1 +#define PCR_MAJOR_VERSION 1 + +typedef struct _KPCR +{ + _ANONYMOUS_UNION union + { + NT_TIB NtTib; + _ANONYMOUS_STRUCT struct + { + union _KGDTENTRY64 *GdtBase; + struct _KTSS64 *TssBase; + ULONG64 UserRsp; + struct _KPCR *Self; + struct _KPRCB *CurrentPrcb; + PKSPIN_LOCK_QUEUE LockArray; + PVOID Used_Self; + }; + }; + union _KIDTENTRY64 *IdtBase; + ULONG64 Unused[2]; + KIRQL Irql; + UCHAR SecondLevelCacheAssociativity; + UCHAR ObsoleteNumber; + UCHAR Fill0; + ULONG Unused0[3]; + USHORT MajorVersion; + USHORT MinorVersion; + ULONG StallScaleFactor; + PVOID Unused1[3]; + ULONG KernelReserved[15]; + ULONG SecondLevelCacheSize; + ULONG HalReserved[16]; + ULONG Unused2; + PVOID KdVersionBlock; + PVOID Unused3; + ULONG PcrAlign1[24]; +} KPCR, *PKPCR; + +FORCEINLINE +PKPCR +KeGetPcr(VOID) +{ + return (PKPCR)__readgsqword(FIELD_OFFSET(KPCR, Self)); +} + +FORCEINLINE +ULONG +KeGetCurrentProcessorNumber(VOID) +{ + return (ULONG)__readgsword(0x184); +} + + +#define PTI_SHIFT 12L +#define PDI_SHIFT 21L +#define PPI_SHIFT 30L +#define PXI_SHIFT 39L +#define PTE_PER_PAGE 512 +#define PDE_PER_PAGE 512 +#define PPE_PER_PAGE 512 +#define PXE_PER_PAGE 512 +#define PTI_MASK_AMD64 (PTE_PER_PAGE - 1) +#define PDI_MASK_AMD64 (PDE_PER_PAGE - 1) +#define PPI_MASK (PPE_PER_PAGE - 1) +#define PXI_MASK (PXE_PER_PAGE - 1) + +#define PXE_BASE 0xFFFFF6FB7DBED000ULL +#define PXE_SELFMAP 0xFFFFF6FB7DBEDF68ULL +#define PPE_BASE 0xFFFFF6FB7DA00000ULL +#define PDE_BASE 0xFFFFF6FB40000000ULL +#define PTE_BASE 0xFFFFF68000000000ULL +#define PXE_TOP 0xFFFFF6FB7DBEDFFFULL +#define PPE_TOP 0xFFFFF6FB7DBFFFFFULL +#define PDE_TOP 0xFFFFF6FB7FFFFFFFULL +#define PTE_TOP 0xFFFFF6FFFFFFFFFFULL + +extern NTKERNELAPI PVOID MmHighestUserAddress; +extern NTKERNELAPI PVOID MmSystemRangeStart; +extern NTKERNELAPI ULONG64 MmUserProbeAddress; + +#define MM_HIGHEST_USER_ADDRESS MmHighestUserAddress +#define MM_SYSTEM_RANGE_START MmSystemRangeStart +#define MM_USER_PROBE_ADDRESS MmUserProbeAddress +#define MM_LOWEST_USER_ADDRESS (PVOID)0x10000 +#define MM_LOWEST_SYSTEM_ADDRESS (PVOID)0xFFFF080000000000ULL + + +#elif defined(_M_IA64) + +#elif defined(_M_PPC) + + +#elif defined(_M_MIPS) + +#elif defined(_M_ARM) +#else +#error Unknown Architecture +#endif + +/****************************************************************************** + * Executive Functions * + ******************************************************************************/ static __inline PVOID ExAllocateFromZone( IN PZONE_HEADER Zone) @@ -1674,8 +3303,36 @@ ExFreeToZone( #define ExIsResourceAcquired ExIsResourceAcquiredSharedLite #define ExReleaseResourceForThread ExReleaseResourceForThreadLite -#if (NTDDI_VERSION >= NTDDI_WIN2K) +typedef enum _INTERLOCKED_RESULT { + ResultNegative = RESULT_NEGATIVE, + ResultZero = RESULT_ZERO, + ResultPositive = RESULT_POSITIVE +} INTERLOCKED_RESULT; +#ifdef _X86_ +NTKERNELAPI +INTERLOCKED_RESULT +FASTCALL +Exfi386InterlockedIncrementLong( + IN OUT LONG volatile *Addend); + +NTKERNELAPI +INTERLOCKED_RESULT +FASTCALL +Exfi386InterlockedDecrementLong( + IN PLONG Addend); + +NTKERNELAPI +ULONG +FASTCALL +Exfi386InterlockedExchangeUlong( + IN PULONG Target, + IN ULONG Value); +#endif + + + +#if (NTDDI_VERSION >= NTDDI_WIN2K) NTKERNELAPI NTSTATUS NTAPI @@ -1712,315 +3369,28 @@ NTKERNELAPI DECLSPEC_NORETURN VOID NTAPI -ExRaiseAccessViolation( - VOID); +ExRaiseAccessViolation(VOID); NTKERNELAPI DECLSPEC_NORETURN VOID NTAPI -ExRaiseDatatypeMisalignment( - VOID); +ExRaiseDatatypeMisalignment(VOID); -#endif -#ifdef _X86_ +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ -NTKERNELAPI -INTERLOCKED_RESULT -FASTCALL -Exfi386InterlockedIncrementLong( - IN OUT LONG volatile *Addend); - -NTKERNELAPI -INTERLOCKED_RESULT -FASTCALL -Exfi386InterlockedDecrementLong( - IN PLONG Addend); - -NTKERNELAPI -ULONG -FASTCALL -Exfi386InterlockedExchangeUlong( - IN PULONG Target, - IN ULONG Value); - -#endif /* _X86_ */ - -#ifndef _ARC_DDK_ -#define _ARC_DDK_ -typedef enum _CONFIGURATION_TYPE { - ArcSystem, - CentralProcessor, - FloatingPointProcessor, - PrimaryIcache, - PrimaryDcache, - SecondaryIcache, - SecondaryDcache, - SecondaryCache, - EisaAdapter, - TcAdapter, - ScsiAdapter, - DtiAdapter, - MultiFunctionAdapter, - DiskController, - TapeController, - CdromController, - WormController, - SerialController, - NetworkController, - DisplayController, - ParallelController, - PointerController, - KeyboardController, - AudioController, - OtherController, - DiskPeripheral, - FloppyDiskPeripheral, - TapePeripheral, - ModemPeripheral, - MonitorPeripheral, - PrinterPeripheral, - PointerPeripheral, - KeyboardPeripheral, - TerminalPeripheral, - OtherPeripheral, - LinePeripheral, - NetworkPeripheral, - SystemMemory, - DockingInformation, - RealModeIrqRoutingTable, - RealModePCIEnumeration, - MaximumType -} CONFIGURATION_TYPE, *PCONFIGURATION_TYPE; -#endif /* !_ARC_DDK_ */ - -typedef struct _CONTROLLER_OBJECT { - CSHORT Type; - CSHORT Size; - PVOID ControllerExtension; - KDEVICE_QUEUE DeviceWaitQueue; - ULONG Spare1; - LARGE_INTEGER Spare2; -} CONTROLLER_OBJECT, *PCONTROLLER_OBJECT; - -typedef struct _CONFIGURATION_INFORMATION { - ULONG DiskCount; - ULONG FloppyCount; - ULONG CdRomCount; - ULONG TapeCount; - ULONG ScsiPortCount; - ULONG SerialCount; - ULONG ParallelCount; - BOOLEAN AtDiskPrimaryAddressClaimed; - BOOLEAN AtDiskSecondaryAddressClaimed; - ULONG Version; - ULONG MediumChangerCount; -} CONFIGURATION_INFORMATION, *PCONFIGURATION_INFORMATION; - -typedef -NTSTATUS -(NTAPI *PIO_QUERY_DEVICE_ROUTINE)( - IN PVOID Context, - IN PUNICODE_STRING PathName, - IN INTERFACE_TYPE BusType, - IN ULONG BusNumber, - IN PKEY_VALUE_FULL_INFORMATION *BusInformation, - IN CONFIGURATION_TYPE ControllerType, - IN ULONG ControllerNumber, - IN PKEY_VALUE_FULL_INFORMATION *ControllerInformation, - IN CONFIGURATION_TYPE PeripheralType, - IN ULONG PeripheralNumber, - IN PKEY_VALUE_FULL_INFORMATION *PeripheralInformation); - -typedef -VOID -(NTAPI DRIVER_REINITIALIZE)( - IN struct _DRIVER_OBJECT *DriverObject, - IN PVOID Context, - IN ULONG Count); - -typedef DRIVER_REINITIALIZE *PDRIVER_REINITIALIZE; - -/** Filesystem runtime library routines **/ - -#if (NTDDI_VERSION >= NTDDI_WIN2K) -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlIsTotalDeviceFailure( - IN NTSTATUS Status); -#endif - -/* Hardware Abstraction Layer Types */ - -typedef VOID -(NTAPI *PciPin2Line)( - IN struct _BUS_HANDLER *BusHandler, - IN struct _BUS_HANDLER *RootHandler, - IN PCI_SLOT_NUMBER SlotNumber, - IN PPCI_COMMON_CONFIG PciData); - -typedef VOID -(NTAPI *PciLine2Pin)( - IN struct _BUS_HANDLER *BusHandler, - IN struct _BUS_HANDLER *RootHandler, - IN PCI_SLOT_NUMBER SlotNumber, - IN PPCI_COMMON_CONFIG PciNewData, - IN PPCI_COMMON_CONFIG PciOldData); - -typedef VOID -(NTAPI *PciReadWriteConfig)( - IN struct _BUS_HANDLER *BusHandler, - IN PCI_SLOT_NUMBER Slot, - IN PVOID Buffer, - IN ULONG Offset, - IN ULONG Length); - -#define PCI_DATA_TAG ' ICP' -#define PCI_DATA_VERSION 1 - -typedef struct _PCIBUSDATA { - ULONG Tag; - ULONG Version; - PciReadWriteConfig ReadConfig; - PciReadWriteConfig WriteConfig; - PciPin2Line Pin2Line; - PciLine2Pin Line2Pin; - PCI_SLOT_NUMBER ParentSlot; - PVOID Reserved[4]; -} PCIBUSDATA, *PPCIBUSDATA; /* Hardware Abstraction Layer Functions */ -#if !defined(NO_LEGACY_DRIVERS) - #if (NTDDI_VERSION >= NTDDI_WIN2K) -NTHALAPI -NTSTATUS -NTAPI -HalAssignSlotResources( - IN PUNICODE_STRING RegistryPath, - IN PUNICODE_STRING DriverClassName, - IN PDRIVER_OBJECT DriverObject, - IN PDEVICE_OBJECT DeviceObject, - IN INTERFACE_TYPE BusType, - IN ULONG BusNumber, - IN ULONG SlotNumber, - IN OUT PCM_RESOURCE_LIST *AllocatedResources); +#if defined(USE_DMA_MACROS) && !defined(_NTHAL_) && (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_) -NTHALAPI -ULONG -NTAPI -HalGetInterruptVector( - IN INTERFACE_TYPE InterfaceType, - IN ULONG BusNumber, - IN ULONG BusInterruptLevel, - IN ULONG BusInterruptVector, - OUT PKIRQL Irql, - OUT PKAFFINITY Affinity); +/* Nothing here */ -NTHALAPI -ULONG -NTAPI -HalSetBusData( - IN BUS_DATA_TYPE BusDataType, - IN ULONG BusNumber, - IN ULONG SlotNumber, - IN PVOID Buffer, - IN ULONG Length); +#else /* USE_DMA_MACROS ... */ -#endif - -#endif /* !defined(NO_LEGACY_DRIVERS) */ - -#if (NTDDI_VERSION >= NTDDI_WIN2K) - -NTHALAPI -PADAPTER_OBJECT -NTAPI -HalGetAdapter( - IN PDEVICE_DESCRIPTION DeviceDescription, - IN OUT PULONG NumberOfMapRegisters); - -NTHALAPI -BOOLEAN -NTAPI -HalMakeBeep( - IN ULONG Frequency); - -VOID -NTAPI -HalPutDmaAdapter( - IN PADAPTER_OBJECT DmaAdapter); - -NTHALAPI -VOID -NTAPI -HalAcquireDisplayOwnership( - IN PHAL_RESET_DISPLAY_PARAMETERS ResetDisplayParameters); - -NTHALAPI -ULONG -NTAPI -HalGetBusData( - IN BUS_DATA_TYPE BusDataType, - IN ULONG BusNumber, - IN ULONG SlotNumber, - OUT PVOID Buffer, - IN ULONG Length); - -NTHALAPI -ULONG -NTAPI -HalGetBusDataByOffset( - IN BUS_DATA_TYPE BusDataType, - IN ULONG BusNumber, - IN ULONG SlotNumber, - OUT PVOID Buffer, - IN ULONG Offset, - IN ULONG Length); - -NTHALAPI -ULONG -NTAPI -HalSetBusDataByOffset( - IN BUS_DATA_TYPE BusDataType, - IN ULONG BusNumber, - IN ULONG SlotNumber, - IN PVOID Buffer, - IN ULONG Offset, - IN ULONG Length); - -NTHALAPI -BOOLEAN -NTAPI -HalTranslateBusAddress( - IN INTERFACE_TYPE InterfaceType, - IN ULONG BusNumber, - IN PHYSICAL_ADDRESS BusAddress, - IN OUT PULONG AddressSpace, - OUT PPHYSICAL_ADDRESS TranslatedAddress); - -#endif - -#if (NTDDI_VERSION >= NTDDI_WINXP) -NTKERNELAPI -VOID -FASTCALL -HalExamineMBR( - IN PDEVICE_OBJECT DeviceObject, - IN ULONG SectorSize, - IN ULONG MBRTypeIdentifier, - OUT PVOID *Buffer); -#endif - -#if defined(USE_DMA_MACROS) && !defined(_NTHAL_) && (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_) -// nothing here -#else - -#if (NTDDI_VERSION >= NTDDI_WIN2K) //DECLSPEC_DEPRECATED_DDK NTHALAPI VOID @@ -2086,12 +3456,207 @@ HalAllocateAdapterChannel( IN ULONG NumberOfMapRegisters, IN PDRIVER_CONTROL ExecutionRoutine); +#endif /* USE_DMA_MACROS ... */ + +#if !defined(NO_LEGACY_DRIVERS) +NTHALAPI +NTSTATUS +NTAPI +HalAssignSlotResources( + IN PUNICODE_STRING RegistryPath, + IN PUNICODE_STRING DriverClassName, + IN PDRIVER_OBJECT DriverObject, + IN PDEVICE_OBJECT DeviceObject, + IN INTERFACE_TYPE BusType, + IN ULONG BusNumber, + IN ULONG SlotNumber, + IN OUT PCM_RESOURCE_LIST *AllocatedResources); + +NTHALAPI +ULONG +NTAPI +HalGetInterruptVector( + IN INTERFACE_TYPE InterfaceType, + IN ULONG BusNumber, + IN ULONG BusInterruptLevel, + IN ULONG BusInterruptVector, + OUT PKIRQL Irql, + OUT PKAFFINITY Affinity); + +NTHALAPI +ULONG +NTAPI +HalSetBusData( + IN BUS_DATA_TYPE BusDataType, + IN ULONG BusNumber, + IN ULONG SlotNumber, + IN PVOID Buffer, + IN ULONG Length); + +NTHALAPI +ULONG +NTAPI +HalGetBusData( + IN BUS_DATA_TYPE BusDataType, + IN ULONG BusNumber, + IN ULONG SlotNumber, + OUT PVOID Buffer, + IN ULONG Length); + +NTHALAPI +BOOLEAN +NTAPI +HalMakeBeep( + IN ULONG Frequency); +#endif /* !defined(NO_LEGACY_DRIVERS) */ + +NTHALAPI +PADAPTER_OBJECT +NTAPI +HalGetAdapter( + IN PDEVICE_DESCRIPTION DeviceDescription, + OUT PULONG NumberOfMapRegisters); + +VOID +NTAPI +HalPutDmaAdapter( + IN PADAPTER_OBJECT DmaAdapter); + +NTHALAPI +VOID +NTAPI +HalAcquireDisplayOwnership( + IN PHAL_RESET_DISPLAY_PARAMETERS ResetDisplayParameters); + +NTHALAPI +ULONG +NTAPI +HalGetBusDataByOffset( + IN BUS_DATA_TYPE BusDataType, + IN ULONG BusNumber, + IN ULONG SlotNumber, + OUT PVOID Buffer, + IN ULONG Offset, + IN ULONG Length); + +NTHALAPI +ULONG +NTAPI +HalSetBusDataByOffset( + IN BUS_DATA_TYPE BusDataType, + IN ULONG BusNumber, + IN ULONG SlotNumber, + IN PVOID Buffer, + IN ULONG Offset, + IN ULONG Length); + +NTHALAPI +BOOLEAN +NTAPI +HalTranslateBusAddress( + IN INTERFACE_TYPE InterfaceType, + IN ULONG BusNumber, + IN PHYSICAL_ADDRESS BusAddress, + IN OUT PULONG AddressSpace, + OUT PPHYSICAL_ADDRESS TranslatedAddress); + +NTHALAPI +PVOID +NTAPI +HalAllocateCrashDumpRegisters( + IN PADAPTER_OBJECT AdapterObject, + IN OUT PULONG NumberOfMapRegisters); + +NTSTATUS +NTAPI +HalGetScatterGatherList( + IN PADAPTER_OBJECT DmaAdapter, + IN PDEVICE_OBJECT DeviceObject, + IN PMDL Mdl, + IN PVOID CurrentVa, + IN ULONG Length, + IN PDRIVER_LIST_CONTROL ExecutionRoutine, + IN PVOID Context, + IN BOOLEAN WriteToDevice); + +VOID +NTAPI +HalPutScatterGatherList( + IN PADAPTER_OBJECT DmaAdapter, + IN PSCATTER_GATHER_LIST ScatterGather, + IN BOOLEAN WriteToDevice); + #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ -#endif /* defined(USE_DMA_MACROS) && !defined(_NTHAL_) && (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_) */ +#if (NTDDI_VERSION >= NTDDI_WINXP) +NTKERNELAPI +VOID +FASTCALL +HalExamineMBR( + IN PDEVICE_OBJECT DeviceObject, + IN ULONG SectorSize, + IN ULONG MBRTypeIdentifier, + OUT PVOID *Buffer); +#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ -/* I/O Manager Functions */ +#if (NTDDI_VERSION >= NTDDI_WIN7) +NTSTATUS +NTAPI +HalAllocateHardwareCounters( + IN PGROUP_AFFINITY GroupAffinty, + IN ULONG GroupCount, + IN PPHYSICAL_COUNTER_RESOURCE_LIST ResourceList, + OUT PHANDLE CounterSetHandle); + +NTSTATUS +NTAPI +HalFreeHardwareCounters( + IN HANDLE CounterSetHandle); + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + +#if defined(_IA64_) +#if (NTDDI_VERSION >= NTDDI_WIN2K) +NTHALAPI +ULONG +NTAPI +HalGetDmaAlignmentRequirement(VOID); +#endif +#endif /* defined(_IA64_) */ + +#if defined(_M_IX86) || defined(_M_AMD64) +#define HalGetDmaAlignmentRequirement() 1L +#endif + +#if (NTDDI_VERSION >= NTDDI_WIN7) + +typedef struct _WHEA_ERROR_SOURCE_DESCRIPTOR *PWHEA_ERROR_SOURCE_DESCRIPTOR; +typedef struct _WHEA_ERROR_RECORD *PWHEA_ERROR_RECORD; + +NTHALAPI +VOID +NTAPI +HalBugCheckSystem( + IN PWHEA_ERROR_SOURCE_DESCRIPTOR ErrorSource, + IN PWHEA_ERROR_RECORD ErrorRecord); + +#else + +typedef struct _WHEA_ERROR_RECORD *PWHEA_ERROR_RECORD; + +NTHALAPI +VOID +NTAPI +HalBugCheckSystem( + IN PWHEA_ERROR_RECORD ErrorRecord); + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + + +/****************************************************************************** + * I/O Manager Functions * + ******************************************************************************/ /* * VOID IoAssignArcName( * IN PUNICODE_STRING ArcName, @@ -2107,8 +3672,19 @@ HalAllocateAdapterChannel( */ #define IoDeassignArcName IoDeleteSymbolicLink -#if (NTDDI_VERSION >= NTDDI_WIN2K) +VOID +FORCEINLINE +NTAPI +IoInitializeDriverCreateContext( + PIO_DRIVER_CREATE_CONTEXT DriverContext) +{ + RtlZeroMemory(DriverContext, sizeof(IO_DRIVER_CREATE_CONTEXT)); + DriverContext->Size = sizeof(IO_DRIVER_CREATE_CONTEXT); +} + + +#if (NTDDI_VERSION >= NTDDI_WIN2K) #if !(defined(USE_DMA_MACROS) && (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_)) NTKERNELAPI NTSTATUS @@ -2121,6 +3697,7 @@ IoAllocateAdapterChannel( IN PVOID Context); #endif +#if !defined(DMA_MACROS_DEFINED) //DECLSPEC_DEPRECATED_DDK NTHALAPI PHYSICAL_ADDRESS @@ -2132,6 +3709,7 @@ IoMapTransfer( IN PVOID CurrentVa, IN OUT PULONG Length, IN BOOLEAN WriteToDevice); +#endif NTKERNELAPI VOID @@ -2163,8 +3741,7 @@ IoFreeController( NTKERNELAPI PCONFIGURATION_INFORMATION NTAPI -IoGetConfigurationInformation( - VOID); +IoGetConfigurationInformation(VOID); NTKERNELAPI PDEVICE_OBJECT @@ -2182,8 +3759,7 @@ IoCancelFileOpen( NTKERNELAPI PGENERIC_MAPPING NTAPI -IoGetFileObjectGenericMapping( - VOID); +IoGetFileObjectGenericMapping(VOID); NTKERNELAPI PIRP @@ -2255,7 +3831,7 @@ IoReportDetectedDevice( IN PCM_RESOURCE_LIST ResourceList OPTIONAL, IN PIO_RESOURCE_REQUIREMENTS_LIST ResourceRequirements OPTIONAL, IN BOOLEAN ResourceAssigned, - IN OUT PDEVICE_OBJECT *DeviceObject); + IN OUT PDEVICE_OBJECT *DeviceObject OPTIONAL); NTKERNELAPI NTSTATUS @@ -2301,9 +3877,59 @@ IoAssignResources( IN PIO_RESOURCE_REQUIREMENTS_LIST RequestedResources OPTIONAL, IN OUT PCM_RESOURCE_LIST *AllocatedResources); +NTKERNELAPI +BOOLEAN +NTAPI +IoSetThreadHardErrorMode( + IN BOOLEAN EnableHardErrors); + #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ +#if (NTDDI_VERSION >= NTDDI_WIN2KSP3) + +NTKERNELAPI +BOOLEAN +NTAPI +IoIsFileOriginRemote( + IN PFILE_OBJECT FileObject); + +NTKERNELAPI +NTSTATUS +NTAPI +IoSetFileOrigin( + IN PFILE_OBJECT FileObject, + IN BOOLEAN Remote); + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2KSP3) */ + #if (NTDDI_VERSION >= NTDDI_WINXP) +NTKERNELAPI +NTSTATUS +FASTCALL +IoReadPartitionTable( + IN PDEVICE_OBJECT DeviceObject, + IN ULONG SectorSize, + IN BOOLEAN ReturnRecognizedPartitions, + OUT struct _DRIVE_LAYOUT_INFORMATION **PartitionBuffer); + +NTKERNELAPI +NTSTATUS +FASTCALL +IoSetPartitionInformation( + IN PDEVICE_OBJECT DeviceObject, + IN ULONG SectorSize, + IN ULONG PartitionNumber, + IN ULONG PartitionType); + +NTKERNELAPI +NTSTATUS +FASTCALL +IoWritePartitionTable( + IN PDEVICE_OBJECT DeviceObject, + IN ULONG SectorSize, + IN ULONG SectorsPerTrack, + IN ULONG NumberOfHeads, + IN struct _DRIVE_LAYOUT_INFORMATION *PartitionBuffer); NTKERNELAPI NTSTATUS @@ -2320,30 +3946,12 @@ IoReadDiskSignature( IN ULONG BytesPerSector, OUT PDISK_SIGNATURE Signature); -NTKERNELAPI -NTSTATUS -FASTCALL -IoReadPartitionTable( - IN PDEVICE_OBJECT DeviceObject, - IN ULONG SectorSize, - IN BOOLEAN ReturnRecognizedPartitions, - OUT struct _DRIVE_LAYOUT_INFORMATION **PartitionBuffer); - NTKERNELAPI NTSTATUS NTAPI IoReadPartitionTableEx( IN PDEVICE_OBJECT DeviceObject, - IN struct _DRIVE_LAYOUT_INFORMATION_EX **PartitionBuffer); - -NTKERNELAPI -NTSTATUS -FASTCALL -IoSetPartitionInformation( - IN PDEVICE_OBJECT DeviceObject, - IN ULONG SectorSize, - IN ULONG PartitionNumber, - IN ULONG PartitionType); + OUT struct _DRIVE_LAYOUT_INFORMATION_EX **PartitionBuffer); NTKERNELAPI NTSTATUS @@ -2359,12 +3967,6 @@ NTAPI IoSetSystemPartition( IN PUNICODE_STRING VolumeNameString); -NTKERNELAPI -BOOLEAN -NTAPI -IoSetThreadHardErrorMode( - IN BOOLEAN EnableHardErrors); - NTKERNELAPI NTSTATUS NTAPI @@ -2379,16 +3981,6 @@ IoVolumeDeviceToDosName( IN PVOID VolumeDeviceObject, OUT PUNICODE_STRING DosName); -NTKERNELAPI -NTSTATUS -FASTCALL -IoWritePartitionTable( - IN PDEVICE_OBJECT DeviceObject, - IN ULONG SectorSize, - IN ULONG SectorsPerTrack, - IN ULONG NumberOfHeads, - IN struct _DRIVE_LAYOUT_INFORMATION *PartitionBuffer); - NTKERNELAPI NTSTATUS NTAPI @@ -2396,6 +3988,26 @@ IoWritePartitionTableEx( IN PDEVICE_OBJECT DeviceObject, IN struct _DRIVE_LAYOUT_INFORMATION_EX *DriveLayout); +NTKERNELAPI +NTSTATUS +NTAPI +IoCreateFileSpecifyDeviceObjectHint( + OUT PHANDLE FileHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN PLARGE_INTEGER AllocationSize OPTIONAL, + IN ULONG FileAttributes, + IN ULONG ShareAccess, + IN ULONG Disposition, + IN ULONG CreateOptions, + IN PVOID EaBuffer OPTIONAL, + IN ULONG EaLength, + IN CREATE_FILE_TYPE CreateFileType, + IN PVOID InternalParameters OPTIONAL, + IN ULONG Options, + IN PVOID DeviceObject OPTIONAL); + NTKERNELAPI NTSTATUS NTAPI @@ -2406,8 +4018,100 @@ IoAttachDeviceToDeviceStackSafe( #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ -/** Kernel debugger routines **/ +#if (NTDDI_VERSION >= NTDDI_WS03) +NTKERNELAPI +IO_PAGING_PRIORITY +FASTCALL +IoGetPagingIoPriority( + IN PIRP Irp); + +#endif /* (NTDDI_VERSION >= NTDDI_WS03) */ + +#if (NTDDI_VERSION >= NTDDI_WS03SP1) +BOOLEAN +NTAPI +IoTranslateBusAddress( + IN INTERFACE_TYPE InterfaceType, + IN ULONG BusNumber, + IN PHYSICAL_ADDRESS BusAddress, + IN OUT PULONG AddressSpace, + OUT PPHYSICAL_ADDRESS TranslatedAddress); +#endif + +#if (NTDDI_VERSION >= NTDDI_VISTA) +NTKERNELAPI +NTSTATUS +NTAPI +IoUpdateDiskGeometry( + IN PDEVICE_OBJECT DeviceObject, + IN struct _DISK_GEOMETRY_EX* OldDiskGeometry, + IN struct _DISK_GEOMETRY_EX* NewDiskGeometry); + +PTXN_PARAMETER_BLOCK +NTAPI +IoGetTransactionParameterBlock( + IN PFILE_OBJECT FileObject); + +NTKERNELAPI +NTSTATUS +NTAPI +IoCreateFileEx( + OUT PHANDLE FileHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN PLARGE_INTEGER AllocationSize OPTIONAL, + IN ULONG FileAttributes, + IN ULONG ShareAccess, + IN ULONG Disposition, + IN ULONG CreateOptions, + IN PVOID EaBuffer OPTIONAL, + IN ULONG EaLength, + IN CREATE_FILE_TYPE CreateFileType, + IN PVOID InternalParameters OPTIONAL, + IN ULONG Options, + IN PIO_DRIVER_CREATE_CONTEXT DriverContext OPTIONAL); + +NTSTATUS +NTAPI +IoSetIrpExtraCreateParameter( + IN OUT PIRP Irp, + IN struct _ECP_LIST *ExtraCreateParameter); + +VOID +NTAPI +IoClearIrpExtraCreateParameter( + IN OUT PIRP Irp); + +NTSTATUS +NTAPI +IoGetIrpExtraCreateParameter( + IN PIRP Irp, + OUT struct _ECP_LIST **ExtraCreateParameter OPTIONAL); + +BOOLEAN +NTAPI +IoIsFileObjectIgnoringSharing( + IN PFILE_OBJECT FileObject); + + +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + + +#if (NTDDI_VERSION >= NTDDI_WIN7) +NTSTATUS +NTAPI +IoSetFileObjectIgnoreSharing( + IN PFILE_OBJECT FileObject); + + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + + +/****************************************************************************** + * Kernel Debugger Functions * + ******************************************************************************/ NTSYSAPI ULONG NTAPI @@ -2416,16 +4120,25 @@ DbgPrompt( OUT PCH Response, IN ULONG MaximumResponseLength); -/* Kernel Functions */ +/****************************************************************************** + * Kernel Functions * + ******************************************************************************/ +NTKERNELAPI +VOID +FASTCALL +KeInvalidateRangeAllCaches( + IN PVOID BaseAddress, + IN ULONG Length); + #if (NTDDI_VERSION >= NTDDI_WIN2K) NTKERNELAPI -DECLSPEC_NORETURN VOID NTAPI -KeBugCheck( - IN ULONG BugCheckCode); +KeSetImportanceDpc( + IN OUT PRKDPC Dpc, + IN KDPC_IMPORTANCE Importance); NTKERNELAPI LONG @@ -2442,24 +4155,204 @@ KeSetBasePriorityThread( IN OUT PRKTHREAD Thread, IN LONG Increment); -#endif +NTKERNELAPI +VOID +NTAPI +KeEnterCriticalRegion(VOID); -/* Memory Manager Types */ +NTKERNELAPI +VOID +NTAPI +KeLeaveCriticalRegion(VOID); -typedef struct _PHYSICAL_MEMORY_RANGE { - PHYSICAL_ADDRESS BaseAddress; - LARGE_INTEGER NumberOfBytes; -} PHYSICAL_MEMORY_RANGE, *PPHYSICAL_MEMORY_RANGE; +NTKERNELAPI +DECLSPEC_NORETURN +VOID +NTAPI +KeBugCheck( + IN ULONG BugCheckCode); -/* Memory Manager Functions */ + +#if defined(SINGLE_GROUP_LEGACY_API) + + +NTKERNELAPI +VOID +NTAPI +KeSetTargetProcessorDpc( + IN OUT PRKDPC Dpc, + IN CCHAR Number); + +NTKERNELAPI +KAFFINITY +NTAPI +KeQueryActiveProcessors(VOID); + +#endif /* defined(SINGLE_GROUP_LEGACY_API) */ + + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ + +#if (NTDDI_VERSION >= NTDDI_WINXP) +NTKERNELAPI +BOOLEAN +NTAPI +KeAreApcsDisabled(VOID); + + +#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ + + +#if (NTDDI_VERSION >= NTDDI_WS03) + + +NTKERNELAPI +BOOLEAN +NTAPI +KeInvalidateAllCaches(VOID); + +#endif /* (NTDDI_VERSION >= NTDDI_WS03) */ + +#if (NTDDI_VERSION >= NTDDI_WS03SP1) + +NTKERNELAPI +NTSTATUS +NTAPI +KeExpandKernelStackAndCallout( + IN PEXPAND_STACK_CALLOUT Callout, + IN PVOID Parameter OPTIONAL, + IN SIZE_T Size); + +NTKERNELAPI +VOID +NTAPI +KeEnterGuardedRegion(VOID); + +NTKERNELAPI +VOID +NTAPI +KeLeaveGuardedRegion(VOID); + + +#endif /* (NTDDI_VERSION >= NTDDI_WS03SP1) */ + +#if (NTDDI_VERSION >= NTDDI_VISTA) + + +#if defined(SINGLE_GROUP_LEGACY_API) +NTKERNELAPI +ULONG +NTAPI +KeQueryActiveProcessorCount( + OUT PKAFFINITY ActiveProcessors OPTIONAL); + +NTKERNELAPI +ULONG +NTAPI +KeQueryMaximumProcessorCount(VOID); + +#endif /* SINGLE_GROUP_LEGACY_API */ + +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + + +#if (NTDDI_VERSION >= NTDDI_WIN7) + +NTKERNELAPI +ULONG +NTAPI +KeQueryActiveProcessorCountEx( + IN USHORT GroupNumber); + +NTKERNELAPI +ULONG +NTAPI +KeQueryMaximumProcessorCountEx( + IN USHORT GroupNumber); + +NTKERNELAPI +USHORT +NTAPI +KeQueryActiveGroupCount(VOID); + +NTKERNELAPI +USHORT +NTAPI +KeQueryMaximumGroupCount(VOID); + +NTKERNELAPI +KAFFINITY +NTAPI +KeQueryGroupAffinity( + IN USHORT GroupNumber); + +NTKERNELAPI +ULONG +NTAPI +KeGetCurrentProcessorNumberEx( + OUT PPROCESSOR_NUMBER ProcNumber OPTIONAL); + +NTKERNELAPI +VOID +NTAPI +KeQueryNodeActiveAffinity( + IN USHORT NodeNumber, + OUT PGROUP_AFFINITY Affinity OPTIONAL, + OUT PUSHORT Count OPTIONAL); + +NTKERNELAPI +USHORT +NTAPI +KeQueryNodeMaximumProcessorCount( + IN USHORT NodeNumber); + +NTKERNELAPI +USHORT +NTAPI +KeQueryHighestNodeNumber(VOID); + +NTKERNELAPI +USHORT +NTAPI +KeGetCurrentNodeNumber(VOID); + +NTKERNELAPI +NTSTATUS +NTAPI +KeQueryLogicalProcessorRelationship( + IN PPROCESSOR_NUMBER ProcessorNumber OPTIONAL, + IN LOGICAL_PROCESSOR_RELATIONSHIP RelationshipType, + OUT PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX Information OPTIONAL, + IN OUT PULONG Length); + +NTKERNELAPI +NTSTATUS +NTAPI +KeSetHardwareCounterConfiguration( + IN PHARDWARE_COUNTER CounterArray, + IN ULONG Count); + +NTKERNELAPI +NTSTATUS +NTAPI +KeQueryHardwareCounterConfiguration( + OUT PHARDWARE_COUNTER CounterArray, + IN ULONG MaximumCount, + OUT PULONG Count); + + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + + +/****************************************************************************** + * Memory manager Functions * + ******************************************************************************/ #if (NTDDI_VERSION >= NTDDI_WIN2K) - NTKERNELAPI PPHYSICAL_MEMORY_RANGE NTAPI -MmGetPhysicalMemoryRanges( - VOID); +MmGetPhysicalMemoryRanges(VOID); NTKERNELAPI PHYSICAL_ADDRESS @@ -2533,8 +4426,7 @@ MmIsAddressValid( NTKERNELAPI BOOLEAN NTAPI -MmIsThisAnNtAsSystem( - VOID); +MmIsThisAnNtAsSystem(VOID); NTKERNELAPI VOID @@ -2582,9 +4474,144 @@ MmUnmapVideoDisplay( IN PVOID BaseAddress, IN SIZE_T NumberOfBytes); +NTKERNELAPI +NTSTATUS +NTAPI +MmAddPhysicalMemory( + IN PPHYSICAL_ADDRESS StartAddress, + IN OUT PLARGE_INTEGER NumberOfBytes); + +NTKERNELAPI +PVOID +NTAPI +MmAllocateContiguousMemory( + IN SIZE_T NumberOfBytes, + IN PHYSICAL_ADDRESS HighestAcceptableAddress); + +NTKERNELAPI +PVOID +NTAPI +MmAllocateContiguousMemorySpecifyCache( + IN SIZE_T NumberOfBytes, + IN PHYSICAL_ADDRESS LowestAcceptableAddress, + IN PHYSICAL_ADDRESS HighestAcceptableAddress, + IN PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL, + IN MEMORY_CACHING_TYPE CacheType); + +NTKERNELAPI +PVOID +NTAPI +MmAllocateContiguousMemorySpecifyCacheNode( + IN SIZE_T NumberOfBytes, + IN PHYSICAL_ADDRESS LowestAcceptableAddress, + IN PHYSICAL_ADDRESS HighestAcceptableAddress, + IN PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL, + IN MEMORY_CACHING_TYPE CacheType, + IN NODE_REQUIREMENT PreferredNode); + +NTKERNELAPI +VOID +NTAPI +MmFreeContiguousMemory( + IN PVOID BaseAddress); + +NTKERNELAPI +VOID +NTAPI +MmFreeContiguousMemorySpecifyCache( + IN PVOID BaseAddress, + IN SIZE_T NumberOfBytes, + IN MEMORY_CACHING_TYPE CacheType); + + #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ -/* NtXxx Functions */ +#if (NTDDI_VERSION >= NTDDI_WINXP) + +NTKERNELAPI +NTSTATUS +NTAPI +MmAdvanceMdl( + IN OUT PMDL Mdl, + IN ULONG NumberOfBytes); + +NTKERNELAPI +PVOID +NTAPI +MmAllocateMappingAddress( + IN SIZE_T NumberOfBytes, + IN ULONG PoolTag); + +NTKERNELAPI +VOID +NTAPI +MmFreeMappingAddress( + IN PVOID BaseAddress, + IN ULONG PoolTag); + +NTKERNELAPI +NTSTATUS +NTAPI +MmIsVerifierEnabled( + OUT PULONG VerifierFlags); + +NTKERNELAPI +PVOID +NTAPI +MmMapLockedPagesWithReservedMapping( + IN PVOID MappingAddress, + IN ULONG PoolTag, + IN PMDL MemoryDescriptorList, + IN MEMORY_CACHING_TYPE CacheType); + +NTKERNELAPI +NTSTATUS +NTAPI +MmProtectMdlSystemAddress( + IN PMDL MemoryDescriptorList, + IN ULONG NewProtect); + +NTKERNELAPI +VOID +NTAPI +MmUnmapReservedMapping( + IN PVOID BaseAddress, + IN ULONG PoolTag, + IN PMDL MemoryDescriptorList); + +NTKERNELAPI +NTSTATUS +NTAPI +MmAddVerifierThunks( + IN PVOID ThunkBuffer, + IN ULONG ThunkBufferSize); + +#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ + +#if (NTDDI_VERSION >= NTDDI_WS03) +NTKERNELAPI +NTSTATUS +NTAPI +MmCreateMirror(VOID); +#endif + + +#if (NTDDI_VERSION >= NTDDI_VISTA) +NTSTATUS +NTAPI +MmRotatePhysicalView( + IN PVOID VirtualAddress, + IN OUT PSIZE_T NumberOfBytes, + IN PMDLX NewMdl OPTIONAL, + IN MM_ROTATE_DIRECTION Direction, + IN PMM_ROTATE_COPY_CALLBACK_FUNCTION CopyFunction, + IN PVOID Context OPTIONAL); + +#endif + +/****************************************************************************** + * Process Manager Functions * + ******************************************************************************/ NTSYSCALLAPI NTSTATUS @@ -2605,35 +4632,15 @@ NtQueryInformationProcess( IN ULONG ProcessInformationLength, OUT PULONG ReturnLength OPTIONAL); -/** Process manager types **/ - -typedef VOID -(NTAPI *PCREATE_PROCESS_NOTIFY_ROUTINE)( - IN HANDLE ParentId, - IN HANDLE ProcessId, - IN BOOLEAN Create); - -typedef VOID -(NTAPI *PCREATE_THREAD_NOTIFY_ROUTINE)( - IN HANDLE ProcessId, - IN HANDLE ThreadId, - IN BOOLEAN Create); - -typedef VOID -(NTAPI *PLOAD_IMAGE_NOTIFY_ROUTINE)( - IN PUNICODE_STRING FullImageName, - IN HANDLE ProcessId, - IN PIMAGE_INFO ImageInfo); - -/** Process manager routines **/ - #if (NTDDI_VERSION >= NTDDI_WIN2K) + NTKERNELAPI NTSTATUS NTAPI -PsSetLoadImageNotifyRoutine( - IN PLOAD_IMAGE_NOTIFY_ROUTINE NotifyRoutine); +PsSetCreateProcessNotifyRoutine( + IN PCREATE_PROCESS_NOTIFY_ROUTINE NotifyRoutine, + IN BOOLEAN Remove); NTKERNELAPI NTSTATUS @@ -2644,21 +4651,18 @@ PsSetCreateThreadNotifyRoutine( NTKERNELAPI NTSTATUS NTAPI -PsSetCreateProcessNotifyRoutine( - IN PCREATE_PROCESS_NOTIFY_ROUTINE NotifyRoutine, - IN BOOLEAN Remove); +PsSetLoadImageNotifyRoutine( + IN PLOAD_IMAGE_NOTIFY_ROUTINE NotifyRoutine); NTKERNELAPI HANDLE NTAPI -PsGetCurrentProcessId( - VOID); +PsGetCurrentProcessId(VOID); NTKERNELAPI HANDLE NTAPI -PsGetCurrentThreadId( - VOID); +PsGetCurrentThreadId(VOID); NTKERNELAPI BOOLEAN @@ -2679,6 +4683,12 @@ NTAPI PsGetProcessId( IN PEPROCESS Process); +NTKERNELAPI +HANDLE +NTAPI +PsGetThreadId( + IN PETHREAD Thread); + NTKERNELAPI NTSTATUS NTAPI @@ -2691,102 +4701,187 @@ NTAPI PsRemoveLoadImageNotifyRoutine( IN PLOAD_IMAGE_NOTIFY_ROUTINE NotifyRoutine); +NTKERNELAPI +LONGLONG +NTAPI +PsGetProcessCreateTimeQuadPart( + IN PEPROCESS Process); + #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ -extern NTKERNELAPI PEPROCESS PsInitialSystemProcess; +#if (NTDDI_VERSION >= NTDDI_WS03) +NTKERNELAPI +HANDLE +NTAPI +PsGetThreadProcessId( + IN PETHREAD Thread); +#endif /* (NTDDI_VERSION >= NTDDI_WS03) */ -/* RTL Types */ +#if (NTDDI_VERSION >= NTDDI_VISTA) -typedef struct _RTL_SPLAY_LINKS { - struct _RTL_SPLAY_LINKS *Parent; - struct _RTL_SPLAY_LINKS *LeftChild; - struct _RTL_SPLAY_LINKS *RightChild; -} RTL_SPLAY_LINKS, *PRTL_SPLAY_LINKS; +NTKERNELAPI +BOOLEAN +NTAPI +PsSetCurrentThreadPrefetching( + IN BOOLEAN Prefetching); -/* RTL Functions */ +NTKERNELAPI +BOOLEAN +NTAPI +PsIsCurrentThreadPrefetching(VOID); -#if (defined(_M_AMD64) || defined(_M_IA64)) && !defined(_REALLY_GET_CALLERS_CALLER_) +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ -#define RtlGetCallersAddress(CallersAddress, CallersCaller) \ - *CallersAddress = (PVOID)_ReturnAddress(); \ - *CallersCaller = NULL; -#else +#if (NTDDI_VERSION >= NTDDI_VISTASP1) +NTKERNELAPI +NTSTATUS +NTAPI +PsSetCreateProcessNotifyRoutineEx( + IN PCREATE_PROCESS_NOTIFY_ROUTINE_EX NotifyRoutine, + IN BOOLEAN Remove); +#endif /* (NTDDI_VERSION >= NTDDI_VISTASP1) */ +/****************************************************************************** + * Runtime Library Functions * + ******************************************************************************/ #if (NTDDI_VERSION >= NTDDI_WIN2K) + + + +#ifndef RTL_USE_AVL_TABLES + NTSYSAPI VOID NTAPI -RtlGetCallersAddress( - OUT PVOID *CallersAddress, - OUT PVOID *CallersCaller); -#endif +RtlInitializeGenericTable( + OUT PRTL_GENERIC_TABLE Table, + IN PRTL_GENERIC_COMPARE_ROUTINE CompareRoutine, + IN PRTL_GENERIC_ALLOCATE_ROUTINE AllocateRoutine, + IN PRTL_GENERIC_FREE_ROUTINE FreeRoutine, + IN PVOID TableContext OPTIONAL); -#endif - -#if !defined(MIDL_PASS) - -FORCEINLINE -LUID -NTAPI_INLINE -RtlConvertLongToLuid( - IN LONG Val) -{ - LUID Luid; - LARGE_INTEGER Temp; - - Temp.QuadPart = Val; - Luid.LowPart = Temp.u.LowPart; - Luid.HighPart = Temp.u.HighPart; - return Luid; -} - -FORCEINLINE -LUID -NTAPI_INLINE -RtlConvertUlongToLuid( - IN ULONG Val) -{ - LUID Luid; - - Luid.LowPart = Val; - Luid.HighPart = 0; - return Luid; -} - -#endif - -#if defined(_AMD64_) || defined(_IA64_) -//DECLSPEC_DEPRECATED_DDK_WINXP -__inline -LARGE_INTEGER -NTAPI_INLINE -RtlLargeIntegerDivide( - IN LARGE_INTEGER Dividend, - IN LARGE_INTEGER Divisor, - OUT PLARGE_INTEGER Remainder OPTIONAL) -{ - LARGE_INTEGER ret; - ret.QuadPart = Dividend.QuadPart / Divisor.QuadPart; - if (Remainder) - Remainder->QuadPart = Dividend.QuadPart % Divisor.QuadPart; - return ret; -} - -#else - -#if (NTDDI_VERSION >= NTDDI_WIN2K) NTSYSAPI -LARGE_INTEGER +PVOID NTAPI -RtlLargeIntegerDivide( - IN LARGE_INTEGER Dividend, - IN LARGE_INTEGER Divisor, - OUT PLARGE_INTEGER Remainder OPTIONAL); -#endif +RtlInsertElementGenericTable( + IN PRTL_GENERIC_TABLE Table, + IN PVOID Buffer, + IN CLONG BufferSize, + OUT PBOOLEAN NewElement OPTIONAL); -#endif /* defined(_AMD64_) || defined(_IA64_) */ +NTSYSAPI +PVOID +NTAPI +RtlInsertElementGenericTableFull( + IN PRTL_GENERIC_TABLE Table, + IN PVOID Buffer, + IN CLONG BufferSize, + OUT PBOOLEAN NewElement OPTIONAL, + IN PVOID NodeOrParent, + IN TABLE_SEARCH_RESULT SearchResult); -#if (NTDDI_VERSION >= NTDDI_WIN2K) +NTSYSAPI +BOOLEAN +NTAPI +RtlDeleteElementGenericTable( + IN PRTL_GENERIC_TABLE Table, + IN PVOID Buffer); + +NTSYSAPI +PVOID +NTAPI +RtlLookupElementGenericTable( + IN PRTL_GENERIC_TABLE Table, + IN PVOID Buffer); + +NTSYSAPI +PVOID +NTAPI +RtlLookupElementGenericTableFull( + IN PRTL_GENERIC_TABLE Table, + IN PVOID Buffer, + OUT PVOID *NodeOrParent, + OUT TABLE_SEARCH_RESULT *SearchResult); + +NTSYSAPI +PVOID +NTAPI +RtlEnumerateGenericTable( + IN PRTL_GENERIC_TABLE Table, + IN BOOLEAN Restart); + +NTSYSAPI +PVOID +NTAPI +RtlEnumerateGenericTableWithoutSplaying( + IN PRTL_GENERIC_TABLE Table, + IN OUT PVOID *RestartKey); + +NTSYSAPI +PVOID +NTAPI +RtlGetElementGenericTable( + IN PRTL_GENERIC_TABLE Table, + IN ULONG I); + +NTSYSAPI +ULONG +NTAPI +RtlNumberGenericTableElements( + IN PRTL_GENERIC_TABLE Table); + +NTSYSAPI +BOOLEAN +NTAPI +RtlIsGenericTableEmpty( + IN PRTL_GENERIC_TABLE Table); + +#endif /* !RTL_USE_AVL_TABLES */ + +#define RTL_STACK_WALKING_MODE_FRAMES_TO_SKIP_SHIFT 8 + +NTSYSAPI +PRTL_SPLAY_LINKS +NTAPI +RtlSplay( + IN OUT PRTL_SPLAY_LINKS Links); + +NTSYSAPI +PRTL_SPLAY_LINKS +NTAPI +RtlDelete( + IN PRTL_SPLAY_LINKS Links); + +NTSYSAPI +VOID +NTAPI +RtlDeleteNoSplay( + IN PRTL_SPLAY_LINKS Links, + IN OUT PRTL_SPLAY_LINKS *Root); + +NTSYSAPI +PRTL_SPLAY_LINKS +NTAPI +RtlSubtreeSuccessor( + IN PRTL_SPLAY_LINKS Links); + +NTSYSAPI +PRTL_SPLAY_LINKS +NTAPI +RtlSubtreePredecessor( + IN PRTL_SPLAY_LINKS Links); + +NTSYSAPI +PRTL_SPLAY_LINKS +NTAPI +RtlRealSuccessor( + IN PRTL_SPLAY_LINKS Links); + +NTSYSAPI +PRTL_SPLAY_LINKS +NTAPI +RtlRealPredecessor( + IN PRTL_SPLAY_LINKS Links); NTSYSAPI BOOLEAN @@ -2845,7 +4940,7 @@ NTAPI RtlCompareString( IN const PSTRING String1, IN const PSTRING String2, - BOOLEAN CaseInSensitive); + IN BOOLEAN CaseInSensitive); NTSYSAPI VOID @@ -2884,9 +4979,513 @@ RtlWalkFrameChain( IN ULONG Count, IN ULONG Flags); + + #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ -/* Security reference monitor routines */ + +#if (NTDDI_VERSION >= NTDDI_WINXP) + + +NTSYSAPI +VOID +NTAPI +RtlInitializeGenericTableAvl( + OUT PRTL_AVL_TABLE Table, + IN PRTL_AVL_COMPARE_ROUTINE CompareRoutine, + IN PRTL_AVL_ALLOCATE_ROUTINE AllocateRoutine, + IN PRTL_AVL_FREE_ROUTINE FreeRoutine, + IN PVOID TableContext OPTIONAL); + +NTSYSAPI +PVOID +NTAPI +RtlInsertElementGenericTableAvl( + IN PRTL_AVL_TABLE Table, + IN PVOID Buffer, + IN CLONG BufferSize, + OUT PBOOLEAN NewElement OPTIONAL); + +NTSYSAPI +PVOID +NTAPI +RtlInsertElementGenericTableFullAvl( + IN PRTL_AVL_TABLE Table, + IN PVOID Buffer, + IN CLONG BufferSize, + OUT PBOOLEAN NewElement OPTIONAL, + IN PVOID NodeOrParent, + IN TABLE_SEARCH_RESULT SearchResult); + +NTSYSAPI +BOOLEAN +NTAPI +RtlDeleteElementGenericTableAvl( + IN PRTL_AVL_TABLE Table, + IN PVOID Buffer); + +NTSYSAPI +PVOID +NTAPI +RtlLookupElementGenericTableAvl( + IN PRTL_AVL_TABLE Table, + IN PVOID Buffer); + +NTSYSAPI +PVOID +NTAPI +RtlLookupElementGenericTableFullAvl( + IN PRTL_AVL_TABLE Table, + IN PVOID Buffer, + OUT PVOID *NodeOrParent, + OUT TABLE_SEARCH_RESULT *SearchResult); + +NTSYSAPI +PVOID +NTAPI +RtlEnumerateGenericTableAvl( + IN PRTL_AVL_TABLE Table, + IN BOOLEAN Restart); + +NTSYSAPI +PVOID +NTAPI +RtlEnumerateGenericTableWithoutSplayingAvl( + IN PRTL_AVL_TABLE Table, + IN OUT PVOID *RestartKey); + +NTSYSAPI +PVOID +NTAPI +RtlLookupFirstMatchingElementGenericTableAvl( + IN PRTL_AVL_TABLE Table, + IN PVOID Buffer, + OUT PVOID *RestartKey); + +NTSYSAPI +PVOID +NTAPI +RtlEnumerateGenericTableLikeADirectory( + IN PRTL_AVL_TABLE Table, + IN PRTL_AVL_MATCH_FUNCTION MatchFunction OPTIONAL, + IN PVOID MatchData OPTIONAL, + IN ULONG NextFlag, + IN OUT PVOID *RestartKey, + IN OUT PULONG DeleteCount, + IN PVOID Buffer); + +NTSYSAPI +PVOID +NTAPI +RtlGetElementGenericTableAvl( + IN PRTL_AVL_TABLE Table, + IN ULONG I); + +NTSYSAPI +ULONG +NTAPI +RtlNumberGenericTableElementsAvl( + IN PRTL_AVL_TABLE Table); + +NTSYSAPI +BOOLEAN +NTAPI +RtlIsGenericTableEmptyAvl( + IN PRTL_AVL_TABLE Table); + + + +#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ + +#if (NTDDI_VERSION >= NTDDI_VISTA) + + +NTSYSAPI +VOID +NTAPI +RtlRunOnceInitialize( + OUT PRTL_RUN_ONCE RunOnce); + +NTSYSAPI +NTSTATUS +NTAPI +RtlRunOnceExecuteOnce( + IN OUT PRTL_RUN_ONCE RunOnce, + IN PRTL_RUN_ONCE_INIT_FN InitFn, + IN OUT PVOID Parameter OPTIONAL, + OUT PVOID *Context OPTIONAL); + +NTSYSAPI +NTSTATUS +NTAPI +RtlRunOnceBeginInitialize( + IN OUT PRTL_RUN_ONCE RunOnce, + IN ULONG Flags, + OUT PVOID *Context OPTIONAL); + +NTSYSAPI +NTSTATUS +NTAPI +RtlRunOnceComplete( + IN OUT PRTL_RUN_ONCE RunOnce, + IN ULONG Flags, + IN PVOID Context OPTIONAL); + +NTSYSAPI +BOOLEAN +NTAPI +RtlGetProductInfo( + IN ULONG OSMajorVersion, + IN ULONG OSMinorVersion, + IN ULONG SpMajorVersion, + IN ULONG SpMinorVersion, + OUT PULONG ReturnedProductType); + + + +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + +#if (NTDDI_VERSION >= NTDDI_WIN7) + + +NTSYSAPI +BOOLEAN +NTAPI +RtlCreateHashTable( + IN OUT PRTL_DYNAMIC_HASH_TABLE *HashTable OPTIONAL, + IN ULONG Shift, + IN ULONG Flags); + +NTSYSAPI +VOID +NTAPI +RtlDeleteHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable); + +NTSYSAPI +BOOLEAN +NTAPI +RtlInsertEntryHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable, + IN PRTL_DYNAMIC_HASH_TABLE_ENTRY Entry, + IN ULONG_PTR Signature, + IN OUT PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context OPTIONAL); + +NTSYSAPI +BOOLEAN +NTAPI +RtlRemoveEntryHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable, + IN PRTL_DYNAMIC_HASH_TABLE_ENTRY Entry, + IN OUT PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context OPTIONAL); + +NTSYSAPI +PRTL_DYNAMIC_HASH_TABLE_ENTRY +NTAPI +RtlLookupEntryHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable, + IN ULONG_PTR Signature, + OUT PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context OPTIONAL); + +NTSYSAPI +PRTL_DYNAMIC_HASH_TABLE_ENTRY +NTAPI +RtlGetNextEntryHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable, + IN PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context); + +NTSYSAPI +BOOLEAN +NTAPI +RtlInitEnumerationHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable, + OUT PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator); + +NTSYSAPI +PRTL_DYNAMIC_HASH_TABLE_ENTRY +NTAPI +RtlEnumerateEntryHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable, + IN OUT PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator); + +NTSYSAPI +VOID +NTAPI +RtlEndEnumerationHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable, + IN OUT PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator); + +NTSYSAPI +BOOLEAN +NTAPI +RtlInitWeakEnumerationHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable, + OUT PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator); + +NTSYSAPI +PRTL_DYNAMIC_HASH_TABLE_ENTRY +NTAPI +RtlWeaklyEnumerateEntryHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable, + IN OUT PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator); + +NTSYSAPI +VOID +NTAPI +RtlEndWeakEnumerationHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable, + IN OUT PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator); + +NTSYSAPI +BOOLEAN +NTAPI +RtlExpandHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable); + +NTSYSAPI +BOOLEAN +NTAPI +RtlContractHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable); + + + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + + +#if defined(_AMD64_) || defined(_IA64_) + + + +//DECLSPEC_DEPRECATED_DDK_WINXP +FORCEINLINE +LARGE_INTEGER +NTAPI_INLINE +RtlLargeIntegerDivide( + IN LARGE_INTEGER Dividend, + IN LARGE_INTEGER Divisor, + OUT PLARGE_INTEGER Remainder OPTIONAL) +{ + LARGE_INTEGER ret; + ret.QuadPart = Dividend.QuadPart / Divisor.QuadPart; + if (Remainder) + Remainder->QuadPart = Dividend.QuadPart % Divisor.QuadPart; + return ret; +} + +#else + +#if (NTDDI_VERSION >= NTDDI_WIN2K) +NTSYSAPI +LARGE_INTEGER +NTAPI +RtlLargeIntegerDivide( + IN LARGE_INTEGER Dividend, + IN LARGE_INTEGER Divisor, + OUT PLARGE_INTEGER Remainder OPTIONAL); +#endif + + +#endif /* defined(_AMD64_) || defined(_IA64_) */ + + + +#ifdef RTL_USE_AVL_TABLES + +#define RtlInitializeGenericTable RtlInitializeGenericTableAvl +#define RtlInsertElementGenericTable RtlInsertElementGenericTableAvl +#define RtlInsertElementGenericTableFull RtlInsertElementGenericTableFullAvl +#define RtlDeleteElementGenericTable RtlDeleteElementGenericTableAvl +#define RtlLookupElementGenericTable RtlLookupElementGenericTableAvl +#define RtlLookupElementGenericTableFull RtlLookupElementGenericTableFullAvl +#define RtlEnumerateGenericTable RtlEnumerateGenericTableAvl +#define RtlEnumerateGenericTableWithoutSplaying RtlEnumerateGenericTableWithoutSplayingAvl +#define RtlGetElementGenericTable RtlGetElementGenericTableAvl +#define RtlNumberGenericTableElements RtlNumberGenericTableElementsAvl +#define RtlIsGenericTableEmpty RtlIsGenericTableEmptyAvl + +#endif /* RTL_USE_AVL_TABLES */ + +#define RtlInitializeSplayLinks(Links) { \ + PRTL_SPLAY_LINKS _SplayLinks; \ + _SplayLinks = (PRTL_SPLAY_LINKS)(Links); \ + _SplayLinks->Parent = _SplayLinks; \ + _SplayLinks->LeftChild = NULL; \ + _SplayLinks->RightChild = NULL; \ +} + +#define RtlIsLeftChild(Links) \ + (RtlLeftChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links)) + +#define RtlIsRightChild(Links) \ + (RtlRightChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links)) + +#define RtlRightChild(Links) \ + ((PRTL_SPLAY_LINKS)(Links))->RightChild + +#define RtlIsRoot(Links) \ + (RtlParent(Links) == (PRTL_SPLAY_LINKS)(Links)) + +#define RtlLeftChild(Links) \ + ((PRTL_SPLAY_LINKS)(Links))->LeftChild + +#define RtlParent(Links) \ + ((PRTL_SPLAY_LINKS)(Links))->Parent + +#define RtlInsertAsLeftChild(ParentLinks,ChildLinks) \ + { \ + PRTL_SPLAY_LINKS _SplayParent; \ + PRTL_SPLAY_LINKS _SplayChild; \ + _SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \ + _SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks); \ + _SplayParent->LeftChild = _SplayChild; \ + _SplayChild->Parent = _SplayParent; \ + } + +#define RtlInsertAsRightChild(ParentLinks,ChildLinks) \ + { \ + PRTL_SPLAY_LINKS _SplayParent; \ + PRTL_SPLAY_LINKS _SplayChild; \ + _SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \ + _SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks); \ + _SplayParent->RightChild = _SplayChild; \ + _SplayChild->Parent = _SplayParent; \ + } + +#if !defined(MIDL_PASS) + +FORCEINLINE +LUID +NTAPI_INLINE +RtlConvertLongToLuid( + IN LONG Val) +{ + LUID Luid; + LARGE_INTEGER Temp; + + Temp.QuadPart = Val; + Luid.LowPart = Temp.u.LowPart; + Luid.HighPart = Temp.u.HighPart; + return Luid; +} + +FORCEINLINE +LUID +NTAPI_INLINE +RtlConvertUlongToLuid( + IN ULONG Val) +{ + LUID Luid; + + Luid.LowPart = Val; + Luid.HighPart = 0; + return Luid; +} + +#endif /* !defined(MIDL_PASS) */ + +#if (defined(_M_AMD64) || defined(_M_IA64)) && !defined(_REALLY_GET_CALLERS_CALLER_) +#define RtlGetCallersAddress(CallersAddress, CallersCaller) \ + *CallersAddress = (PVOID)_ReturnAddress(); \ + *CallersCaller = NULL; +#else +#if (NTDDI_VERSION >= NTDDI_WIN2K) +NTSYSAPI +VOID +NTAPI +RtlGetCallersAddress( + OUT PVOID *CallersAddress, + OUT PVOID *CallersCaller); +#endif +#endif + +#if !defined(MIDL_PASS) && !defined(SORTPP_PASS) + +#if (NTDDI_VERSION >= NTDDI_WIN7) + +FORCEINLINE +VOID +NTAPI +RtlInitHashTableContext( + IN OUT PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context) +{ + Context->ChainHead = NULL; + Context->PrevLinkage = NULL; +} + +FORCEINLINE +VOID +NTAPI +RtlInitHashTableContextFromEnumerator( + IN OUT PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context, + IN PRTL_DYNAMIC_HASH_TABLE_ENUMERATOR Enumerator) +{ + Context->ChainHead = Enumerator->ChainHead; + Context->PrevLinkage = Enumerator->HashEntry.Linkage.Blink; +} + +FORCEINLINE +VOID +NTAPI +RtlReleaseHashTableContext( + IN OUT PRTL_DYNAMIC_HASH_TABLE_CONTEXT Context) +{ + UNREFERENCED_PARAMETER(Context); + return; +} + +FORCEINLINE +ULONG +NTAPI +RtlTotalBucketsHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable) +{ + return HashTable->TableSize; +} + +FORCEINLINE +ULONG +NTAPI +RtlNonEmptyBucketsHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable) +{ + return HashTable->NonEmptyBuckets; +} + +FORCEINLINE +ULONG +NTAPI +RtlEmptyBucketsHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable) +{ + return HashTable->TableSize - HashTable->NonEmptyBuckets; +} + +FORCEINLINE +ULONG +NTAPI +RtlTotalEntriesHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable) +{ + return HashTable->NumEntries; +} + +FORCEINLINE +ULONG +NTAPI +RtlActiveEnumeratorsHashTable( + IN PRTL_DYNAMIC_HASH_TABLE HashTable) +{ + return HashTable->NumEnumerators; +} + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + +#endif /* !defined(MIDL_PASS) && !defined(SORTPP_PASS) */ + +/****************************************************************************** + * Security Manager Functions * + ******************************************************************************/ #if (NTDDI_VERSION >= NTDDI_WIN2K) NTKERNELAPI @@ -2895,12 +5494,42 @@ NTAPI SeSinglePrivilegeCheck( IN LUID PrivilegeValue, IN KPROCESSOR_MODE PreviousMode); -#endif -/* ZwXxx Functions */ + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ + +/****************************************************************************** + * ZwXxx Functions * + ******************************************************************************/ + + + +NTSYSAPI +NTSTATUS +NTAPI +ZwAllocateLocallyUniqueId( + OUT PLUID Luid); + +NTSYSAPI +NTSTATUS +NTAPI +ZwTerminateProcess( + IN HANDLE ProcessHandle OPTIONAL, + IN NTSTATUS ExitStatus); + +NTSYSAPI +NTSTATUS +NTAPI +ZwOpenProcess( + OUT PHANDLE ProcessHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN PCLIENT_ID ClientId OPTIONAL); + #if (NTDDI_VERSION >= NTDDI_WIN2K) + NTSTATUS NTAPI ZwCancelTimer( @@ -2942,12 +5571,190 @@ ZwSetTimer( IN LONG Period OPTIONAL, OUT PBOOLEAN PreviousState OPTIONAL); +NTSYSAPI +NTSTATUS +NTAPI +ZwDisplayString( + IN PUNICODE_STRING String); + +NTSYSAPI +NTSTATUS +NTAPI +ZwPowerInformation( + IN POWER_INFORMATION_LEVEL PowerInformationLevel, + IN PVOID InputBuffer OPTIONAL, + IN ULONG InputBufferLength, + OUT PVOID OutputBuffer OPTIONAL, + IN ULONG OutputBufferLength); + +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryVolumeInformationFile( + IN HANDLE FileHandle, + OUT PIO_STATUS_BLOCK IoStatusBlock, + OUT PVOID FsInformation, + IN ULONG Length, + IN FS_INFORMATION_CLASS FsInformationClass); + +NTSYSAPI +NTSTATUS +NTAPI +ZwDeviceIoControlFile( + IN HANDLE FileHandle, + IN HANDLE Event OPTIONAL, + IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, + IN PVOID ApcContext OPTIONAL, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN ULONG IoControlCode, + IN PVOID InputBuffer OPTIONAL, + IN ULONG InputBufferLength, + OUT PVOID OutputBuffer OPTIONAL, + IN ULONG OutputBufferLength); + + + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ + + +#if (NTDDI_VERSION >= NTDDI_WIN7) + +NTSTATUS +NTAPI +ZwSetTimerEx( + IN HANDLE TimerHandle, + IN TIMER_SET_INFORMATION_CLASS TimerSetInformationClass, + IN OUT PVOID TimerSetInformation, + IN ULONG TimerSetInformationLength); + + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + + + +/* UNSORTED */ + +#define VER_SET_CONDITION(ConditionMask, TypeBitMask, ComparisonType) \ + ((ConditionMask) = VerSetConditionMask((ConditionMask), \ + (TypeBitMask), (ComparisonType))) + +#if (NTDDI_VERSION >= NTDDI_WIN2K) +NTSYSAPI +ULONGLONG +NTAPI +VerSetConditionMask( + IN ULONGLONG ConditionMask, + IN ULONG TypeMask, + IN UCHAR Condition); #endif +typedef struct _KERNEL_USER_TIMES { + LARGE_INTEGER CreateTime; + LARGE_INTEGER ExitTime; + LARGE_INTEGER KernelTime; + LARGE_INTEGER UserTime; +} KERNEL_USER_TIMES, *PKERNEL_USER_TIMES; + +/* NtXxx Functions */ + +typedef enum _SYSTEM_FIRMWARE_TABLE_ACTION { + SystemFirmwareTable_Enumerate, + SystemFirmwareTable_Get +} SYSTEM_FIRMWARE_TABLE_ACTION; + +typedef struct _SYSTEM_FIRMWARE_TABLE_INFORMATION { + ULONG ProviderSignature; + SYSTEM_FIRMWARE_TABLE_ACTION Action; + ULONG TableID; + ULONG TableBufferLength; + UCHAR TableBuffer[ANYSIZE_ARRAY]; +} SYSTEM_FIRMWARE_TABLE_INFORMATION, *PSYSTEM_FIRMWARE_TABLE_INFORMATION; + +typedef NTSTATUS +(__cdecl *PFNFTH)( + IN OUT PSYSTEM_FIRMWARE_TABLE_INFORMATION SystemFirmwareTableInfo); + +typedef struct _SYSTEM_FIRMWARE_TABLE_HANDLER { + ULONG ProviderSignature; + BOOLEAN Register; + PFNFTH FirmwareTableHandler; + PVOID DriverObject; +} SYSTEM_FIRMWARE_TABLE_HANDLER, *PSYSTEM_FIRMWARE_TABLE_HANDLER; + +typedef ULONG_PTR +(NTAPI *PDRIVER_VERIFIER_THUNK_ROUTINE)( + IN PVOID Context); + +typedef struct _DRIVER_VERIFIER_THUNK_PAIRS { + PDRIVER_VERIFIER_THUNK_ROUTINE PristineRoutine; + PDRIVER_VERIFIER_THUNK_ROUTINE NewRoutine; +} DRIVER_VERIFIER_THUNK_PAIRS, *PDRIVER_VERIFIER_THUNK_PAIRS; + +#define DRIVER_VERIFIER_SPECIAL_POOLING 0x0001 +#define DRIVER_VERIFIER_FORCE_IRQL_CHECKING 0x0002 +#define DRIVER_VERIFIER_INJECT_ALLOCATION_FAILURES 0x0004 +#define DRIVER_VERIFIER_TRACK_POOL_ALLOCATIONS 0x0008 +#define DRIVER_VERIFIER_IO_CHECKING 0x0010 + +#define SHARED_GLOBAL_FLAGS_ERROR_PORT_V 0x0 +#define SHARED_GLOBAL_FLAGS_ERROR_PORT (1UL << SHARED_GLOBAL_FLAGS_ERROR_PORT_V) + +#define SHARED_GLOBAL_FLAGS_ELEVATION_ENABLED_V 0x1 +#define SHARED_GLOBAL_FLAGS_ELEVATION_ENABLED (1UL << SHARED_GLOBAL_FLAGS_ELEVATION_ENABLED_V) + +#define SHARED_GLOBAL_FLAGS_VIRT_ENABLED_V 0x2 +#define SHARED_GLOBAL_FLAGS_VIRT_ENABLED (1UL << SHARED_GLOBAL_FLAGS_VIRT_ENABLED_V) + +#define SHARED_GLOBAL_FLAGS_INSTALLER_DETECT_ENABLED_V 0x3 +#define SHARED_GLOBAL_FLAGS_INSTALLER_DETECT_ENABLED \ + (1UL << SHARED_GLOBAL_FLAGS_INSTALLER_DETECT_ENABLED_V) + +#define SHARED_GLOBAL_FLAGS_SPARE_V 0x4 +#define SHARED_GLOBAL_FLAGS_SPARE \ + (1UL << SHARED_GLOBAL_FLAGS_SPARE_V) + +#define SHARED_GLOBAL_FLAGS_DYNAMIC_PROC_ENABLED_V 0x5 +#define SHARED_GLOBAL_FLAGS_DYNAMIC_PROC_ENABLED \ + (1UL << SHARED_GLOBAL_FLAGS_DYNAMIC_PROC_ENABLED_V) + +#define SHARED_GLOBAL_FLAGS_SEH_VALIDATION_ENABLED_V 0x6 +#define SHARED_GLOBAL_FLAGS_SEH_VALIDATION_ENABLED \ + (1UL << SHARED_GLOBAL_FLAGS_SEH_VALIDATION_ENABLED_V) + +#define EX_INIT_BITS(Flags, Bit) \ + *((Flags)) |= (Bit) // Safe to use before concurrently accessible + +#define EX_TEST_SET_BIT(Flags, Bit) \ + InterlockedBitTestAndSet ((PLONG)(Flags), (Bit)) + +#define EX_TEST_CLEAR_BIT(Flags, Bit) \ + InterlockedBitTestAndReset ((PLONG)(Flags), (Bit)) + +#define PCCARD_MAP_ERROR 0x01 +#define PCCARD_DEVICE_PCI 0x10 + +#define PCCARD_SCAN_DISABLED 0x01 +#define PCCARD_MAP_ZERO 0x02 +#define PCCARD_NO_TIMER 0x03 +#define PCCARD_NO_PIC 0x04 +#define PCCARD_NO_LEGACY_BASE 0x05 +#define PCCARD_DUP_LEGACY_BASE 0x06 +#define PCCARD_NO_CONTROLLERS 0x07 + +#define MAXIMUM_EXPANSION_SIZE (KERNEL_LARGE_STACK_SIZE - (PAGE_SIZE / 2)) + +/* Filesystem runtime library routines */ + +#if (NTDDI_VERSION >= NTDDI_WIN2K) +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlIsTotalDeviceFailure( + IN NTSTATUS Status); +#endif + +/* FIXME : These definitions below doesn't belong to NTDDK */ #ifdef __cplusplus } #endif - - -#endif /* _NTDDK_ */ diff --git a/reactos/include/ddk/ntifs.h b/reactos/include/ddk/ntifs.h index 87d0470888c..15bace86764 100644 --- a/reactos/include/ddk/ntifs.h +++ b/reactos/include/ddk/ntifs.h @@ -25,32 +25,10 @@ #define _NTIFS_INCLUDED_ #define _GNU_NTIFS_ -/* Helper macro to enable gcc's extension. */ -#ifndef __GNU_EXTENSION -#ifdef __GNUC__ -#define __GNU_EXTENSION __extension__ -#else -#define __GNU_EXTENSION -#endif -#endif - #ifdef __cplusplus extern "C" { #endif -#if !defined(_NTHALDLL_) && !defined(_BLDR_) -#define NTHALAPI DECLSPEC_IMPORT -#else -#define NTHALAPI -#endif - -/* For ReactOS */ -#if !defined(_NTOSKRNL_) && !defined(_BLDR_) -#define NTKERNELAPI DECLSPEC_IMPORT -#else -#define NTKERNELAPI -#endif - /* Dependencies */ #include #include @@ -76,16 +54,6 @@ extern "C" { #define ClearFlag(_F,_SF) ((_F) &= ~(_SF)) #endif -#define PsGetCurrentProcess IoGetCurrentProcess - -#if (NTDDI_VERSION >= NTDDI_VISTA) -extern NTSYSAPI volatile CCHAR KeNumberProcessors; -#elif (NTDDI_VERSION >= NTDDI_WINXP) -extern NTSYSAPI CCHAR KeNumberProcessors; -#else -extern PCCHAR KeNumberProcessors; -#endif - typedef UNICODE_STRING LSA_UNICODE_STRING, *PLSA_UNICODE_STRING; typedef STRING LSA_STRING, *PLSA_STRING; typedef OBJECT_ATTRIBUTES LSA_OBJECT_ATTRIBUTES, *PLSA_OBJECT_ATTRIBUTES; @@ -751,8 +719,6 @@ typedef enum _OBJECT_INFORMATION_CLASS { MaxObjectInfoClass /* FIXME, not in WDK */ } OBJECT_INFORMATION_CLASS; -#if (NTDDI_VERSION >= NTDDI_NT4) - NTSYSCALLAPI NTSTATUS NTAPI @@ -763,8 +729,6 @@ NtQueryObject( IN ULONG ObjectInformationLength, OUT PULONG ReturnLength OPTIONAL); -#endif - #if (NTDDI_VERSION >= NTDDI_WIN2K) NTSYSCALLAPI @@ -2414,95 +2378,11 @@ extern const PRTL_REALLOCATE_STRING_ROUTINE RtlReallocateStringRoutine; #define RTL_SYSTEM_VOLUME_INFORMATION_FOLDER L"System Volume Information" -#define DEVICE_TYPE ULONG - -#define FILE_DEVICE_BEEP 0x00000001 -#define FILE_DEVICE_CD_ROM 0x00000002 -#define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003 -#define FILE_DEVICE_CONTROLLER 0x00000004 -#define FILE_DEVICE_DATALINK 0x00000005 -#define FILE_DEVICE_DFS 0x00000006 -#define FILE_DEVICE_DISK 0x00000007 -#define FILE_DEVICE_DISK_FILE_SYSTEM 0x00000008 -#define FILE_DEVICE_FILE_SYSTEM 0x00000009 -#define FILE_DEVICE_INPORT_PORT 0x0000000a -#define FILE_DEVICE_KEYBOARD 0x0000000b -#define FILE_DEVICE_MAILSLOT 0x0000000c -#define FILE_DEVICE_MIDI_IN 0x0000000d -#define FILE_DEVICE_MIDI_OUT 0x0000000e -#define FILE_DEVICE_MOUSE 0x0000000f -#define FILE_DEVICE_MULTI_UNC_PROVIDER 0x00000010 -#define FILE_DEVICE_NAMED_PIPE 0x00000011 -#define FILE_DEVICE_NETWORK 0x00000012 -#define FILE_DEVICE_NETWORK_BROWSER 0x00000013 -#define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014 -#define FILE_DEVICE_NULL 0x00000015 -#define FILE_DEVICE_PARALLEL_PORT 0x00000016 -#define FILE_DEVICE_PHYSICAL_NETCARD 0x00000017 -#define FILE_DEVICE_PRINTER 0x00000018 -#define FILE_DEVICE_SCANNER 0x00000019 -#define FILE_DEVICE_SERIAL_MOUSE_PORT 0x0000001a -#define FILE_DEVICE_SERIAL_PORT 0x0000001b -#define FILE_DEVICE_SCREEN 0x0000001c -#define FILE_DEVICE_SOUND 0x0000001d -#define FILE_DEVICE_STREAMS 0x0000001e -#define FILE_DEVICE_TAPE 0x0000001f -#define FILE_DEVICE_TAPE_FILE_SYSTEM 0x00000020 -#define FILE_DEVICE_TRANSPORT 0x00000021 -#define FILE_DEVICE_UNKNOWN 0x00000022 -#define FILE_DEVICE_VIDEO 0x00000023 -#define FILE_DEVICE_VIRTUAL_DISK 0x00000024 -#define FILE_DEVICE_WAVE_IN 0x00000025 -#define FILE_DEVICE_WAVE_OUT 0x00000026 -#define FILE_DEVICE_8042_PORT 0x00000027 -#define FILE_DEVICE_NETWORK_REDIRECTOR 0x00000028 -#define FILE_DEVICE_BATTERY 0x00000029 -#define FILE_DEVICE_BUS_EXTENDER 0x0000002a -#define FILE_DEVICE_MODEM 0x0000002b -#define FILE_DEVICE_VDM 0x0000002c -#define FILE_DEVICE_MASS_STORAGE 0x0000002d -#define FILE_DEVICE_SMB 0x0000002e -#define FILE_DEVICE_KS 0x0000002f -#define FILE_DEVICE_CHANGER 0x00000030 -#define FILE_DEVICE_SMARTCARD 0x00000031 -#define FILE_DEVICE_ACPI 0x00000032 -#define FILE_DEVICE_DVD 0x00000033 -#define FILE_DEVICE_FULLSCREEN_VIDEO 0x00000034 -#define FILE_DEVICE_DFS_FILE_SYSTEM 0x00000035 -#define FILE_DEVICE_DFS_VOLUME 0x00000036 -#define FILE_DEVICE_SERENUM 0x00000037 -#define FILE_DEVICE_TERMSRV 0x00000038 -#define FILE_DEVICE_KSEC 0x00000039 -#define FILE_DEVICE_FIPS 0x0000003A -#define FILE_DEVICE_INFINIBAND 0x0000003B -#define FILE_DEVICE_VMBUS 0x0000003E -#define FILE_DEVICE_CRYPT_PROVIDER 0x0000003F -#define FILE_DEVICE_WPD 0x00000040 -#define FILE_DEVICE_BLUETOOTH 0x00000041 -#define FILE_DEVICE_MT_COMPOSITE 0x00000042 -#define FILE_DEVICE_MT_TRANSPORT 0x00000043 -#define FILE_DEVICE_BIOMETRIC 0x00000044 -#define FILE_DEVICE_PMI 0x00000045 - -#define CTL_CODE(DeviceType, Function, Method, Access) \ - (((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method)) - -#define DEVICE_TYPE_FROM_CTL_CODE(ctl) (((ULONG) (ctl & 0xffff0000)) >> 16) - #define METHOD_FROM_CTL_CODE(ctrlCode) ((ULONG)(ctrlCode & 3)) -#define METHOD_BUFFERED 0 -#define METHOD_IN_DIRECT 1 -#define METHOD_OUT_DIRECT 2 -#define METHOD_NEITHER 3 #define METHOD_DIRECT_TO_HARDWARE METHOD_IN_DIRECT #define METHOD_DIRECT_FROM_HARDWARE METHOD_OUT_DIRECT -#define FILE_ANY_ACCESS 0x00000000 -#define FILE_SPECIAL_ACCESS FILE_ANY_ACCESS -#define FILE_READ_ACCESS 0x00000001 -#define FILE_WRITE_ACCESS 0x00000002 - typedef ULONG LSA_OPERATIONAL_MODE, *PLSA_OPERATIONAL_MODE; typedef enum _SECURITY_LOGON_TYPE { @@ -4673,6 +4553,8 @@ typedef struct _KAPC_STATE { #define KAPC_STATE_ACTUAL_LENGTH (FIELD_OFFSET(KAPC_STATE, UserApcPending) + sizeof(BOOLEAN)) +#define ASSERT_QUEUE(Q) ASSERT(((Q)->Header.Type & KOBJECT_TYPE_MASK) == QueueObject); + typedef struct _KQUEUE { DISPATCHER_HEADER Header; LIST_ENTRY EntryListHead; @@ -4807,7 +4689,7 @@ FASTCALL KeAcquireQueuedSpinLock( IN OUT KSPIN_LOCK_QUEUE_NUMBER Number); -NTHALAPI +_DECL_HAL_KE_IMPORT VOID FASTCALL KeReleaseQueuedSpinLock( @@ -5022,24 +4904,6 @@ typedef NTSTATUS #if (NTDDI_VERSION >= NTDDI_WIN2K) -NTKERNELAPI -VOID -NTAPI -SeCaptureSubjectContext( - OUT PSECURITY_SUBJECT_CONTEXT SubjectContext); - -NTKERNELAPI -VOID -NTAPI -SeLockSubjectContext( - IN PSECURITY_SUBJECT_CONTEXT SubjectContext); - -NTKERNELAPI -VOID -NTAPI -SeUnlockSubjectContext( - IN PSECURITY_SUBJECT_CONTEXT SubjectContext); - NTKERNELAPI VOID NTAPI @@ -5453,18 +5317,6 @@ SeLocateProcessImageName( extern NTKERNELAPI PSE_EXPORTS SeExports; -#if !defined(_PSGETCURRENTTHREAD_) -#define _PSGETCURRENTTHREAD_ - -FORCEINLINE -PETHREAD -PsGetCurrentThread( - VOID) -{ - return (PETHREAD)KeGetCurrentThread(); -} -#endif - #if (NTDDI_VERSION >= NTDDI_WIN2K) NTKERNELAPI @@ -5534,7 +5386,20 @@ PsReturnPoolQuota( IN POOL_TYPE PoolType, IN ULONG_PTR Amount); -#endif +NTKERNELAPI +NTSTATUS +NTAPI +PsAssignImpersonationToken( + IN PETHREAD Thread, + IN HANDLE Token OPTIONAL); + +NTKERNELAPI +HANDLE +NTAPI +PsReferencePrimaryToken( + IN OUT PEPROCESS Process); + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ #if (NTDDI_VERSION >= NTDDI_WINXP) @@ -5823,18 +5688,6 @@ IoPageRead( IN PKEVENT Event, OUT PIO_STATUS_BLOCK IoStatusBlock); -NTKERNELAPI -PDEVICE_OBJECT -NTAPI -IoGetAttachedDevice( - IN PDEVICE_OBJECT DeviceObject); - -NTKERNELAPI -PDEVICE_OBJECT -NTAPI -IoGetAttachedDeviceReference( - IN PDEVICE_OBJECT DeviceObject); - NTKERNELAPI PDEVICE_OBJECT NTAPI @@ -5951,42 +5804,6 @@ NTAPI IoSetTopLevelIrp( IN PIRP Irp OPTIONAL); -NTKERNELAPI -VOID -NTAPI -IoStartNextPacket( - IN PDEVICE_OBJECT DeviceObject, - IN BOOLEAN Cancelable); - -NTKERNELAPI -VOID -NTAPI -IoStartNextPacketByKey( - IN PDEVICE_OBJECT DeviceObject, - IN BOOLEAN Cancelable, - IN ULONG Key); - -NTKERNELAPI -VOID -NTAPI -IoStartPacket( - IN PDEVICE_OBJECT DeviceObject, - IN PIRP Irp, - IN PULONG Key OPTIONAL, - IN PDRIVER_CANCEL CancelFunction OPTIONAL); - -NTKERNELAPI -VOID -NTAPI -IoStartTimer( - IN PDEVICE_OBJECT DeviceObject); - -NTKERNELAPI -VOID -NTAPI -IoStopTimer( - IN PDEVICE_OBJECT DeviceObject); - NTKERNELAPI NTSTATUS NTAPI @@ -6023,12 +5840,6 @@ IoVerifyVolume( IN PDEVICE_OBJECT DeviceObject, IN BOOLEAN AllowRawMount); -NTKERNELAPI -VOID -NTAPI -IoWriteErrorLogEntry( - IN PVOID ElEntry); - NTKERNELAPI NTSTATUS NTAPI @@ -6055,13 +5866,6 @@ IoQueryFileDosDeviceName( IN PFILE_OBJECT FileObject, OUT POBJECT_NAME_INFORMATION *ObjectNameInformation); -VOID -NTAPI -IoSetStartIoAttributes( - IN PDEVICE_OBJECT DeviceObject, - IN BOOLEAN DeferredStartIo, - IN BOOLEAN NonCancelable); - NTKERNELAPI NTSTATUS NTAPI @@ -6160,53 +5964,6 @@ typedef struct _IO_PRIORITY_INFO { #define PO_CB_LID_SWITCH_STATE 4 #define PO_CB_PROCESSOR_POWER_POLICY 5 -#if (NTDDI_VERSION >= NTDDI_WIN2K) - -NTKERNELAPI -PVOID -NTAPI -PoRegisterSystemState( - IN OUT PVOID StateHandle OPTIONAL, - IN EXECUTION_STATE Flags); - -NTKERNELAPI -VOID -NTAPI -PoUnregisterSystemState( - IN OUT PVOID StateHandle); - -NTKERNELAPI -POWER_STATE -NTAPI -PoSetPowerState( - IN PDEVICE_OBJECT DeviceObject, - IN POWER_STATE_TYPE Type, - IN POWER_STATE State); - -NTKERNELAPI -NTSTATUS -NTAPI -PoCallDriver( - IN PDEVICE_OBJECT DeviceObject, - IN OUT PIRP Irp); - -NTKERNELAPI -VOID -NTAPI -PoStartNextPowerIrp( - IN OUT PIRP Irp); - -NTKERNELAPI -PULONG -NTAPI -PoRegisterDeviceForIdleDetection( - IN PDEVICE_OBJECT DeviceObject, - IN ULONG ConservationIdleTime, - IN ULONG PerformanceIdleTime, - IN DEVICE_POWER_STATE State); - -#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ - #if (NTDDI_VERSION >= NTDDI_WINXP) NTKERNELAPI NTSTATUS @@ -6215,84 +5972,6 @@ PoQueueShutdownWorkItem( IN OUT PWORK_QUEUE_ITEM WorkItem); #endif -#if (NTDDI_VERSION >= NTDDI_VISTA) - -NTKERNELAPI -NTSTATUS -NTAPI -PoRegisterPowerSettingCallback( - IN PDEVICE_OBJECT DeviceObject OPTIONAL, - IN LPCGUID SettingGuid, - IN PPOWER_SETTING_CALLBACK Callback, - IN PVOID Context OPTIONAL, - OUT PVOID *Handle); - -NTKERNELAPI -NTSTATUS -PoUnregisterPowerSettingCallback( - IN OUT PVOID Handle); - -#endif - -#if (NTDDI_VERSION >= NTDDI_WIN6SP1) -NTKERNELAPI -VOID -NTAPI -PoSetDeviceBusyEx( - IN OUT PULONG IdlePointer); -#endif - -#if (NTDDI_VERSION >= NTDDI_WIN7) - -NTKERNELAPI -NTSTATUS -NTAPI -PoCreatePowerRequest( - OUT PVOID *PowerRequest, - IN PDEVICE_OBJECT DeviceObject, - IN PCOUNTED_REASON_CONTEXT Context); - -NTKERNELAPI -NTSTATUS -NTAPI -PoSetPowerRequest( - IN OUT PVOID PowerRequest, - IN POWER_REQUEST_TYPE Type); - -NTKERNELAPI -NTSTATUS -NTAPI -PoClearPowerRequest( - IN OUT PVOID PowerRequest, - IN POWER_REQUEST_TYPE Type); - -NTKERNELAPI -VOID -NTAPI -PoDeletePowerRequest( - IN OUT PVOID PowerRequest); - -NTKERNELAPI -VOID -NTAPI -PoStartDeviceBusy( - IN OUT PULONG IdlePointer); - -NTKERNELAPI -VOID -NTAPI -PoEndDeviceBusy( - IN OUT PULONG IdlePointer); - -NTKERNELAPI -BOOLEAN -NTAPI -PoQueryWatchdogTime( - IN PDEVICE_OBJECT Pdo, - OUT PULONG SecondsRemaining); - -#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ - #if defined(_IA64_) #if (NTDDI_VERSION >= NTDDI_WIN2K) //DECLSPEC_DEPRECATED_DDK @@ -6568,6 +6247,188 @@ typedef struct _FILE_LOCK { LONG volatile LockRequestsInProgress; } FILE_LOCK, *PFILE_LOCK; +typedef struct _TUNNEL { + FAST_MUTEX Mutex; + PRTL_SPLAY_LINKS Cache; + LIST_ENTRY TimerQueue; + USHORT NumEntries; +} TUNNEL, *PTUNNEL; + +typedef enum _FSRTL_COMPARISON_RESULT { + LessThan = -1, + EqualTo = 0, + GreaterThan = 1 +} FSRTL_COMPARISON_RESULT; + +#define FSRTL_FAT_LEGAL 0x01 +#define FSRTL_HPFS_LEGAL 0x02 +#define FSRTL_NTFS_LEGAL 0x04 +#define FSRTL_WILD_CHARACTER 0x08 +#define FSRTL_OLE_LEGAL 0x10 +#define FSRTL_NTFS_STREAM_LEGAL (FSRTL_NTFS_LEGAL | FSRTL_OLE_LEGAL) + +typedef struct _BASE_MCB { + ULONG MaximumPairCount; + ULONG PairCount; + USHORT PoolType; + USHORT Flags; + PVOID Mapping; +} BASE_MCB, *PBASE_MCB; + +typedef struct _LARGE_MCB { + PKGUARDED_MUTEX GuardedMutex; + BASE_MCB BaseMcb; +} LARGE_MCB, *PLARGE_MCB; + +#define MCB_FLAG_RAISE_ON_ALLOCATION_FAILURE 1 + +typedef struct _MCB { + LARGE_MCB DummyFieldThatSizesThisStructureCorrectly; +} MCB, *PMCB; + +typedef PVOID OPLOCK, *POPLOCK; + +typedef VOID +(NTAPI *POPLOCK_WAIT_COMPLETE_ROUTINE) ( + IN PVOID Context, + IN PIRP Irp); + +typedef VOID +(NTAPI *POPLOCK_FS_PREPOST_IRP) ( + IN PVOID Context, + IN PIRP Irp); + +#if (NTDDI_VERSION >= NTDDI_VISTASP1) +#define OPLOCK_FLAG_COMPLETE_IF_OPLOCKED 0x00000001 +#endif + +#if (NTDDI_VERSION >= NTDDI_WIN7) +#define OPLOCK_FLAG_OPLOCK_KEY_CHECK_ONLY 0x00000002 +#define OPLOCK_FLAG_BACK_OUT_ATOMIC_OPLOCK 0x00000004 +#define OPLOCK_FLAG_IGNORE_OPLOCK_KEYS 0x00000008 +#define OPLOCK_FSCTRL_FLAG_ALL_KEYS_MATCH 0x00000001 +#endif + +#if (NTDDI_VERSION >= NTDDI_WIN7) + +typedef struct _OPLOCK_KEY_ECP_CONTEXT { + GUID OplockKey; + ULONG Reserved; +} OPLOCK_KEY_ECP_CONTEXT, *POPLOCK_KEY_ECP_CONTEXT; + +DEFINE_GUID( GUID_ECP_OPLOCK_KEY, 0x48850596, 0x3050, 0x4be7, 0x98, 0x63, 0xfe, 0xc3, 0x50, 0xce, 0x8d, 0x7f ); + +#endif + +#define FSRTL_VOLUME_DISMOUNT 1 +#define FSRTL_VOLUME_DISMOUNT_FAILED 2 +#define FSRTL_VOLUME_LOCK 3 +#define FSRTL_VOLUME_LOCK_FAILED 4 +#define FSRTL_VOLUME_UNLOCK 5 +#define FSRTL_VOLUME_MOUNT 6 +#define FSRTL_VOLUME_NEEDS_CHKDSK 7 +#define FSRTL_VOLUME_WORM_NEAR_FULL 8 +#define FSRTL_VOLUME_WEARING_OUT 9 +#define FSRTL_VOLUME_FORCED_CLOSED 10 +#define FSRTL_VOLUME_INFO_MAKE_COMPAT 11 +#define FSRTL_VOLUME_PREPARING_EJECT 12 +#define FSRTL_VOLUME_CHANGE_SIZE 13 +#define FSRTL_VOLUME_BACKGROUND_FORMAT 14 + +typedef PVOID PNOTIFY_SYNC; + +typedef BOOLEAN +(NTAPI *PCHECK_FOR_TRAVERSE_ACCESS) ( + IN PVOID NotifyContext, + IN PVOID TargetContext OPTIONAL, + IN PSECURITY_SUBJECT_CONTEXT SubjectContext); + +typedef BOOLEAN +(NTAPI *PFILTER_REPORT_CHANGE) ( + IN PVOID NotifyContext, + IN PVOID FilterContext); + +typedef VOID +(NTAPI *PFSRTL_STACK_OVERFLOW_ROUTINE) ( + IN PVOID Context, + IN PKEVENT Event); + +#if (NTDDI_VERSION >= NTDDI_VISTA) + +#define FSRTL_UNC_PROVIDER_FLAGS_MAILSLOTS_SUPPORTED 0x00000001 +#define FSRTL_UNC_PROVIDER_FLAGS_CSC_ENABLED 0x00000002 +#define FSRTL_UNC_PROVIDER_FLAGS_DOMAIN_SVC_AWARE 0x00000004 + +#define FSRTL_ALLOCATE_ECPLIST_FLAG_CHARGE_QUOTA 0x00000001 + +#define FSRTL_ALLOCATE_ECP_FLAG_CHARGE_QUOTA 0x00000001 +#define FSRTL_ALLOCATE_ECP_FLAG_NONPAGED_POOL 0x00000002 + +#define FSRTL_ECP_LOOKASIDE_FLAG_NONPAGED_POOL 0x00000002 + +#define FSRTL_VIRTDISK_FULLY_ALLOCATED 0x00000001 +#define FSRTL_VIRTDISK_NO_DRIVE_LETTER 0x00000002 + +typedef struct _FSRTL_MUP_PROVIDER_INFO_LEVEL_1 { + ULONG32 ProviderId; +} FSRTL_MUP_PROVIDER_INFO_LEVEL_1, *PFSRTL_MUP_PROVIDER_INFO_LEVEL_1; + +typedef struct _FSRTL_MUP_PROVIDER_INFO_LEVEL_2 { + ULONG32 ProviderId; + UNICODE_STRING ProviderName; +} FSRTL_MUP_PROVIDER_INFO_LEVEL_2, *PFSRTL_MUP_PROVIDER_INFO_LEVEL_2; + +typedef VOID +(*PFSRTL_EXTRA_CREATE_PARAMETER_CLEANUP_CALLBACK) ( + IN OUT PVOID EcpContext, + IN LPCGUID EcpType); + +typedef struct _ECP_LIST ECP_LIST, *PECP_LIST; + +typedef ULONG FSRTL_ALLOCATE_ECPLIST_FLAGS; +typedef ULONG FSRTL_ALLOCATE_ECP_FLAGS; +typedef ULONG FSRTL_ECP_LOOKASIDE_FLAGS; + +typedef enum _FSRTL_CHANGE_BACKING_TYPE { + ChangeDataControlArea, + ChangeImageControlArea, + ChangeSharedCacheMap +} FSRTL_CHANGE_BACKING_TYPE, *PFSRTL_CHANGE_BACKING_TYPE; + +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + +typedef struct _FSRTL_PER_FILE_CONTEXT { + LIST_ENTRY Links; + PVOID OwnerId; + PVOID InstanceId; + PFREE_FUNCTION FreeCallback; +} FSRTL_PER_FILE_CONTEXT, *PFSRTL_PER_FILE_CONTEXT; + +typedef struct _FSRTL_PER_STREAM_CONTEXT { + LIST_ENTRY Links; + PVOID OwnerId; + PVOID InstanceId; + PFREE_FUNCTION FreeCallback; +} FSRTL_PER_STREAM_CONTEXT, *PFSRTL_PER_STREAM_CONTEXT; + +#if (NTDDI_VERSION >= NTDDI_WIN2K) +typedef VOID +(*PFN_FSRTLTEARDOWNPERSTREAMCONTEXTS) ( + IN PFSRTL_ADVANCED_FCB_HEADER AdvancedHeader); +#endif + +typedef struct _FSRTL_PER_FILEOBJECT_CONTEXT { + LIST_ENTRY Links; + PVOID OwnerId; + PVOID InstanceId; +} FSRTL_PER_FILEOBJECT_CONTEXT, *PFSRTL_PER_FILEOBJECT_CONTEXT; + +#define FsRtlEnterFileSystem KeEnterCriticalRegion +#define FsRtlExitFileSystem KeLeaveCriticalRegion + +#define FSRTL_CC_FLUSH_ERROR_FLAG_NO_HARD_ERROR 0x1 +#define FSRTL_CC_FLUSH_ERROR_FLAG_NO_LOG_ENTRY 0x2 + #if (NTDDI_VERSION >= NTDDI_WIN2K) NTKERNELAPI @@ -6845,15 +6706,2181 @@ FsRtlPrivateLock( IN PVOID Context, IN BOOLEAN AlreadySynchronized); +NTKERNELAPI +VOID +NTAPI +FsRtlInitializeTunnelCache( + IN PTUNNEL Cache); + +NTKERNELAPI +VOID +NTAPI +FsRtlAddToTunnelCache( + IN PTUNNEL Cache, + IN ULONGLONG DirectoryKey, + IN PUNICODE_STRING ShortName, + IN PUNICODE_STRING LongName, + IN BOOLEAN KeyByShortName, + IN ULONG DataLength, + IN PVOID Data); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlFindInTunnelCache( + IN PTUNNEL Cache, + IN ULONGLONG DirectoryKey, + IN PUNICODE_STRING Name, + OUT PUNICODE_STRING ShortName, + OUT PUNICODE_STRING LongName, + IN OUT PULONG DataLength, + OUT PVOID Data); + +NTKERNELAPI +VOID +NTAPI +FsRtlDeleteKeyFromTunnelCache( + IN PTUNNEL Cache, + IN ULONGLONG DirectoryKey); + +NTKERNELAPI +VOID +NTAPI +FsRtlDeleteTunnelCache( + IN PTUNNEL Cache); + +NTKERNELAPI +VOID +NTAPI +FsRtlDissectDbcs( + IN ANSI_STRING Name, + OUT PANSI_STRING FirstPart, + OUT PANSI_STRING RemainingPart); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlDoesDbcsContainWildCards( + IN PANSI_STRING Name); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlIsDbcsInExpression( + IN PANSI_STRING Expression, + IN PANSI_STRING Name); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlIsFatDbcsLegal( + IN ANSI_STRING DbcsName, + IN BOOLEAN WildCardsPermissible, + IN BOOLEAN PathNamePermissible, + IN BOOLEAN LeadingBackslashPermissible); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlIsHpfsDbcsLegal( + IN ANSI_STRING DbcsName, + IN BOOLEAN WildCardsPermissible, + IN BOOLEAN PathNamePermissible, + IN BOOLEAN LeadingBackslashPermissible); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlNormalizeNtstatus( + IN NTSTATUS Exception, + IN NTSTATUS GenericException); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlIsNtstatusExpected( + IN NTSTATUS Ntstatus); + +NTKERNELAPI +PERESOURCE +NTAPI +FsRtlAllocateResource( + VOID); + +NTKERNELAPI +VOID +NTAPI +FsRtlInitializeLargeMcb( + IN PLARGE_MCB Mcb, + IN POOL_TYPE PoolType); + +NTKERNELAPI +VOID +NTAPI +FsRtlUninitializeLargeMcb( + IN PLARGE_MCB Mcb); + +NTKERNELAPI +VOID +NTAPI +FsRtlResetLargeMcb( + IN PLARGE_MCB Mcb, + IN BOOLEAN SelfSynchronized); + +NTKERNELAPI +VOID +NTAPI +FsRtlTruncateLargeMcb( + IN PLARGE_MCB Mcb, + IN LONGLONG Vbn); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlAddLargeMcbEntry( + IN PLARGE_MCB Mcb, + IN LONGLONG Vbn, + IN LONGLONG Lbn, + IN LONGLONG SectorCount); + +NTKERNELAPI +VOID +NTAPI +FsRtlRemoveLargeMcbEntry( + IN PLARGE_MCB Mcb, + IN LONGLONG Vbn, + IN LONGLONG SectorCount); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlLookupLargeMcbEntry( + IN PLARGE_MCB Mcb, + IN LONGLONG Vbn, + OUT PLONGLONG Lbn OPTIONAL, + OUT PLONGLONG SectorCountFromLbn OPTIONAL, + OUT PLONGLONG StartingLbn OPTIONAL, + OUT PLONGLONG SectorCountFromStartingLbn OPTIONAL, + OUT PULONG Index OPTIONAL); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlLookupLastLargeMcbEntry( + IN PLARGE_MCB Mcb, + OUT PLONGLONG Vbn, + OUT PLONGLONG Lbn); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlLookupLastLargeMcbEntryAndIndex( + IN PLARGE_MCB OpaqueMcb, + OUT PLONGLONG LargeVbn, + OUT PLONGLONG LargeLbn, + OUT PULONG Index); + +NTKERNELAPI +ULONG +NTAPI +FsRtlNumberOfRunsInLargeMcb( + IN PLARGE_MCB Mcb); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlGetNextLargeMcbEntry( + IN PLARGE_MCB Mcb, + IN ULONG RunIndex, + OUT PLONGLONG Vbn, + OUT PLONGLONG Lbn, + OUT PLONGLONG SectorCount); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlSplitLargeMcb( + IN PLARGE_MCB Mcb, + IN LONGLONG Vbn, + IN LONGLONG Amount); + +NTKERNELAPI +VOID +NTAPI +FsRtlInitializeMcb( + IN PMCB Mcb, + IN POOL_TYPE PoolType); + +NTKERNELAPI +VOID +NTAPI +FsRtlUninitializeMcb( + IN PMCB Mcb); + +NTKERNELAPI +VOID +NTAPI +FsRtlTruncateMcb( + IN PMCB Mcb, + IN VBN Vbn); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlAddMcbEntry( + IN PMCB Mcb, + IN VBN Vbn, + IN LBN Lbn, + IN ULONG SectorCount); + +NTKERNELAPI +VOID +NTAPI +FsRtlRemoveMcbEntry( + IN PMCB Mcb, + IN VBN Vbn, + IN ULONG SectorCount); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlLookupMcbEntry( + IN PMCB Mcb, + IN VBN Vbn, + OUT PLBN Lbn, + OUT PULONG SectorCount OPTIONAL, + OUT PULONG Index); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlLookupLastMcbEntry( + IN PMCB Mcb, + OUT PVBN Vbn, + OUT PLBN Lbn); + +NTKERNELAPI +ULONG +NTAPI +FsRtlNumberOfRunsInMcb( + IN PMCB Mcb); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlGetNextMcbEntry( + IN PMCB Mcb, + IN ULONG RunIndex, + OUT PVBN Vbn, + OUT PLBN Lbn, + OUT PULONG SectorCount); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlBalanceReads( + IN PDEVICE_OBJECT TargetDevice); + +NTKERNELAPI +VOID +NTAPI +FsRtlInitializeOplock( + IN OUT POPLOCK Oplock); + +NTKERNELAPI +VOID +NTAPI +FsRtlUninitializeOplock( + IN OUT POPLOCK Oplock); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlOplockFsctrl( + IN POPLOCK Oplock, + IN PIRP Irp, + IN ULONG OpenCount); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlCheckOplock( + IN POPLOCK Oplock, + IN PIRP Irp, + IN PVOID Context, + IN POPLOCK_WAIT_COMPLETE_ROUTINE CompletionRoutine OPTIONAL, + IN POPLOCK_FS_PREPOST_IRP PostIrpRoutine OPTIONAL); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlOplockIsFastIoPossible( + IN POPLOCK Oplock); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlCurrentBatchOplock( + IN POPLOCK Oplock); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlNotifyVolumeEvent( + IN PFILE_OBJECT FileObject, + IN ULONG EventCode); + +NTKERNELAPI +VOID +NTAPI +FsRtlNotifyInitializeSync( + IN PNOTIFY_SYNC *NotifySync); + +NTKERNELAPI +VOID +NTAPI +FsRtlNotifyUninitializeSync( + IN PNOTIFY_SYNC *NotifySync); + +NTKERNELAPI +VOID +NTAPI +FsRtlNotifyFullChangeDirectory( + IN PNOTIFY_SYNC NotifySync, + IN PLIST_ENTRY NotifyList, + IN PVOID FsContext, + IN PSTRING FullDirectoryName, + IN BOOLEAN WatchTree, + IN BOOLEAN IgnoreBuffer, + IN ULONG CompletionFilter, + IN PIRP NotifyIrp OPTIONAL, + IN PCHECK_FOR_TRAVERSE_ACCESS TraverseCallback OPTIONAL, + IN PSECURITY_SUBJECT_CONTEXT SubjectContext OPTIONAL); + +NTKERNELAPI +VOID +NTAPI +FsRtlNotifyFilterReportChange( + IN PNOTIFY_SYNC NotifySync, + IN PLIST_ENTRY NotifyList, + IN PSTRING FullTargetName, + IN USHORT TargetNameOffset, + IN PSTRING StreamName OPTIONAL, + IN PSTRING NormalizedParentName OPTIONAL, + IN ULONG FilterMatch, + IN ULONG Action, + IN PVOID TargetContext OPTIONAL, + IN PVOID FilterContext OPTIONAL); + +NTKERNELAPI +VOID +NTAPI +FsRtlNotifyFullReportChange( + IN PNOTIFY_SYNC NotifySync, + IN PLIST_ENTRY NotifyList, + IN PSTRING FullTargetName, + IN USHORT TargetNameOffset, + IN PSTRING StreamName OPTIONAL, + IN PSTRING NormalizedParentName OPTIONAL, + IN ULONG FilterMatch, + IN ULONG Action, + IN PVOID TargetContext OPTIONAL); + +NTKERNELAPI +VOID +NTAPI +FsRtlNotifyCleanup( + IN PNOTIFY_SYNC NotifySync, + IN PLIST_ENTRY NotifyList, + IN PVOID FsContext); + +NTKERNELAPI +VOID +NTAPI +FsRtlDissectName( + IN UNICODE_STRING Name, + OUT PUNICODE_STRING FirstPart, + OUT PUNICODE_STRING RemainingPart); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlDoesNameContainWildCards( + IN PUNICODE_STRING Name); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlAreNamesEqual( + IN PCUNICODE_STRING Name1, + IN PCUNICODE_STRING Name2, + IN BOOLEAN IgnoreCase, + IN PCWCH UpcaseTable OPTIONAL); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlIsNameInExpression( + IN PUNICODE_STRING Expression, + IN PUNICODE_STRING Name, + IN BOOLEAN IgnoreCase, + IN PWCHAR UpcaseTable OPTIONAL); + +NTKERNELAPI +VOID +NTAPI +FsRtlPostPagingFileStackOverflow( + IN PVOID Context, + IN PKEVENT Event, + IN PFSRTL_STACK_OVERFLOW_ROUTINE StackOverflowRoutine); + +NTKERNELAPI +VOID +NTAPI +FsRtlPostStackOverflow ( + IN PVOID Context, + IN PKEVENT Event, + IN PFSRTL_STACK_OVERFLOW_ROUTINE StackOverflowRoutine); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlRegisterUncProvider( + OUT PHANDLE MupHandle, + IN PUNICODE_STRING RedirectorDeviceName, + IN BOOLEAN MailslotsSupported); + +NTKERNELAPI +VOID +NTAPI +FsRtlDeregisterUncProvider( + IN HANDLE Handle); + +NTKERNELAPI +VOID +NTAPI +FsRtlTeardownPerStreamContexts( + IN PFSRTL_ADVANCED_FCB_HEADER AdvancedHeader); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlCreateSectionForDataScan( + OUT PHANDLE SectionHandle, + OUT PVOID *SectionObject, + OUT PLARGE_INTEGER SectionFileSize OPTIONAL, + IN PFILE_OBJECT FileObject, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, + IN PLARGE_INTEGER MaximumSize OPTIONAL, + IN ULONG SectionPageProtection, + IN ULONG AllocationAttributes, + IN ULONG Flags); + #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ +#if (NTDDI_VERSION >= NTDDI_WINXP) + +NTKERNELAPI +VOID +NTAPI +FsRtlNotifyFilterChangeDirectory( + IN PNOTIFY_SYNC NotifySync, + IN PLIST_ENTRY NotifyList, + IN PVOID FsContext, + IN PSTRING FullDirectoryName, + IN BOOLEAN WatchTree, + IN BOOLEAN IgnoreBuffer, + IN ULONG CompletionFilter, + IN PIRP NotifyIrp OPTIONAL, + IN PCHECK_FOR_TRAVERSE_ACCESS TraverseCallback OPTIONAL, + IN PSECURITY_SUBJECT_CONTEXT SubjectContext OPTIONAL, + IN PFILTER_REPORT_CHANGE FilterCallback OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlInsertPerStreamContext( + IN PFSRTL_ADVANCED_FCB_HEADER PerStreamContext, + IN PFSRTL_PER_STREAM_CONTEXT Ptr); + +NTKERNELAPI +PFSRTL_PER_STREAM_CONTEXT +NTAPI +FsRtlLookupPerStreamContextInternal( + IN PFSRTL_ADVANCED_FCB_HEADER StreamContext, + IN PVOID OwnerId OPTIONAL, + IN PVOID InstanceId OPTIONAL); + +NTKERNELAPI +PFSRTL_PER_STREAM_CONTEXT +NTAPI +FsRtlRemovePerStreamContext( + IN PFSRTL_ADVANCED_FCB_HEADER StreamContext, + IN PVOID OwnerId OPTIONAL, + IN PVOID InstanceId OPTIONAL); + +NTKERNELAPI +VOID +NTAPI +FsRtlIncrementCcFastReadNotPossible( + VOID); + +NTKERNELAPI +VOID +NTAPI +FsRtlIncrementCcFastReadWait( + VOID); + +NTKERNELAPI +VOID +NTAPI +FsRtlIncrementCcFastReadNoWait( + VOID); + +NTKERNELAPI +VOID +NTAPI +FsRtlIncrementCcFastReadResourceMiss( + VOID); + +NTKERNELAPI +LOGICAL +NTAPI +FsRtlIsPagingFile( + IN PFILE_OBJECT FileObject); + +#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ + +#if (NTDDI_VERSION >= NTDDI_WS03) + +NTKERNELAPI + VOID +NTAPI +FsRtlInitializeBaseMcb( + IN PBASE_MCB Mcb, + IN POOL_TYPE PoolType); + +NTKERNELAPI +VOID +NTAPI +FsRtlUninitializeBaseMcb( + IN PBASE_MCB Mcb); + +NTKERNELAPI +VOID +NTAPI +FsRtlResetBaseMcb( + IN PBASE_MCB Mcb); + +NTKERNELAPI +VOID +NTAPI +FsRtlTruncateBaseMcb( + IN PBASE_MCB Mcb, + IN LONGLONG Vbn); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlAddBaseMcbEntry( + IN PBASE_MCB Mcb, + IN LONGLONG Vbn, + IN LONGLONG Lbn, + IN LONGLONG SectorCount); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlRemoveBaseMcbEntry( + IN PBASE_MCB Mcb, + IN LONGLONG Vbn, + IN LONGLONG SectorCount); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlLookupBaseMcbEntry( + IN PBASE_MCB Mcb, + IN LONGLONG Vbn, + OUT PLONGLONG Lbn OPTIONAL, + OUT PLONGLONG SectorCountFromLbn OPTIONAL, + OUT PLONGLONG StartingLbn OPTIONAL, + OUT PLONGLONG SectorCountFromStartingLbn OPTIONAL, + OUT PULONG Index OPTIONAL); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlLookupLastBaseMcbEntry( + IN PBASE_MCB Mcb, + OUT PLONGLONG Vbn, + OUT PLONGLONG Lbn); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlLookupLastBaseMcbEntryAndIndex( + IN PBASE_MCB OpaqueMcb, + IN OUT PLONGLONG LargeVbn, + IN OUT PLONGLONG LargeLbn, + IN OUT PULONG Index); + +NTKERNELAPI +ULONG +NTAPI +FsRtlNumberOfRunsInBaseMcb( + IN PBASE_MCB Mcb); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlGetNextBaseMcbEntry( + IN PBASE_MCB Mcb, + IN ULONG RunIndex, + OUT PLONGLONG Vbn, + OUT PLONGLONG Lbn, + OUT PLONGLONG SectorCount); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlSplitBaseMcb( + IN PBASE_MCB Mcb, + IN LONGLONG Vbn, + IN LONGLONG Amount); + +#endif /* (NTDDI_VERSION >= NTDDI_WS03) */ + +#if (NTDDI_VERSION >= NTDDI_VISTA) + +BOOLEAN +NTAPI +FsRtlInitializeBaseMcbEx( + IN PBASE_MCB Mcb, + IN POOL_TYPE PoolType, + IN USHORT Flags); + +NTSTATUS +NTAPI +FsRtlAddBaseMcbEntryEx( + IN PBASE_MCB Mcb, + IN LONGLONG Vbn, + IN LONGLONG Lbn, + IN LONGLONG SectorCount); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlCurrentOplock( + IN POPLOCK Oplock); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlOplockBreakToNone( + IN OUT POPLOCK Oplock, + IN PIO_STACK_LOCATION IrpSp OPTIONAL, + IN PIRP Irp, + IN PVOID Context OPTIONAL, + IN POPLOCK_WAIT_COMPLETE_ROUTINE CompletionRoutine OPTIONAL, + IN POPLOCK_FS_PREPOST_IRP PostIrpRoutine OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlNotifyVolumeEventEx( + IN PFILE_OBJECT FileObject, + IN ULONG EventCode, + IN PTARGET_DEVICE_CUSTOM_NOTIFICATION Event); + +NTKERNELAPI +VOID +NTAPI +FsRtlNotifyCleanupAll( + IN PNOTIFY_SYNC NotifySync, + IN PLIST_ENTRY NotifyList); + +NTSTATUS +NTAPI +FsRtlRegisterUncProviderEx( + OUT PHANDLE MupHandle, + IN PUNICODE_STRING RedirDevName, + IN PDEVICE_OBJECT DeviceObject, + IN ULONG Flags); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlCancellableWaitForSingleObject( + IN PVOID Object, + IN PLARGE_INTEGER Timeout OPTIONAL, + IN PIRP Irp OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlCancellableWaitForMultipleObjects( + IN ULONG Count, + IN PVOID ObjectArray[], + IN WAIT_TYPE WaitType, + IN PLARGE_INTEGER Timeout OPTIONAL, + IN PKWAIT_BLOCK WaitBlockArray OPTIONAL, + IN PIRP Irp OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlMupGetProviderInfoFromFileObject( + IN PFILE_OBJECT pFileObject, + IN ULONG Level, + OUT PVOID pBuffer, + IN OUT PULONG pBufferSize); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlMupGetProviderIdFromName( + IN PUNICODE_STRING pProviderName, + OUT PULONG32 pProviderId); + +NTKERNELAPI +VOID +NTAPI +FsRtlIncrementCcFastMdlReadWait( + VOID); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlValidateReparsePointBuffer( + IN ULONG BufferLength, + IN PREPARSE_DATA_BUFFER ReparseBuffer); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlRemoveDotsFromPath( + IN OUT PWSTR OriginalString, + IN USHORT PathLength, + OUT USHORT *NewLength); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlAllocateExtraCreateParameterList( + IN FSRTL_ALLOCATE_ECPLIST_FLAGS Flags, + OUT PECP_LIST *EcpList); + +NTKERNELAPI +VOID +NTAPI +FsRtlFreeExtraCreateParameterList( + IN PECP_LIST EcpList); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlAllocateExtraCreateParameter( + IN LPCGUID EcpType, + IN ULONG SizeOfContext, + IN FSRTL_ALLOCATE_ECP_FLAGS Flags, + IN PFSRTL_EXTRA_CREATE_PARAMETER_CLEANUP_CALLBACK CleanupCallback OPTIONAL, + IN ULONG PoolTag, + OUT PVOID *EcpContext); + +NTKERNELAPI +VOID +NTAPI +FsRtlFreeExtraCreateParameter( + IN PVOID EcpContext); + +NTKERNELAPI +VOID +NTAPI +FsRtlInitExtraCreateParameterLookasideList( + IN OUT PVOID Lookaside, + IN FSRTL_ECP_LOOKASIDE_FLAGS Flags, + IN SIZE_T Size, + IN ULONG Tag); + +VOID +NTAPI +FsRtlDeleteExtraCreateParameterLookasideList( + IN OUT PVOID Lookaside, + IN FSRTL_ECP_LOOKASIDE_FLAGS Flags); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlAllocateExtraCreateParameterFromLookasideList( + IN LPCGUID EcpType, + IN ULONG SizeOfContext, + IN FSRTL_ALLOCATE_ECP_FLAGS Flags, + IN PFSRTL_EXTRA_CREATE_PARAMETER_CLEANUP_CALLBACK CleanupCallback OPTIONAL, + IN OUT PVOID LookasideList, + OUT PVOID *EcpContext); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlInsertExtraCreateParameter( + IN OUT PECP_LIST EcpList, + IN OUT PVOID EcpContext); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlFindExtraCreateParameter( + IN PECP_LIST EcpList, + IN LPCGUID EcpType, + OUT PVOID *EcpContext OPTIONAL, + OUT ULONG *EcpContextSize OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlRemoveExtraCreateParameter( + IN OUT PECP_LIST EcpList, + IN LPCGUID EcpType, + OUT PVOID *EcpContext, + OUT ULONG *EcpContextSize OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlGetEcpListFromIrp( + IN PIRP Irp, + OUT PECP_LIST *EcpList OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlSetEcpListIntoIrp( + IN OUT PIRP Irp, + IN PECP_LIST EcpList); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlGetNextExtraCreateParameter( + IN PECP_LIST EcpList, + IN PVOID CurrentEcpContext OPTIONAL, + OUT LPGUID NextEcpType OPTIONAL, + OUT PVOID *NextEcpContext OPTIONAL, + OUT ULONG *NextEcpContextSize OPTIONAL); + +NTKERNELAPI +VOID +NTAPI +FsRtlAcknowledgeEcp( + IN PVOID EcpContext); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlIsEcpAcknowledged( + IN PVOID EcpContext); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlIsEcpFromUserMode( + IN PVOID EcpContext); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlChangeBackingFileObject( + IN PFILE_OBJECT CurrentFileObject OPTIONAL, + IN PFILE_OBJECT NewFileObject, + IN FSRTL_CHANGE_BACKING_TYPE ChangeBackingType, + IN ULONG Flags); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlLogCcFlushError( + IN PUNICODE_STRING FileName, + IN PDEVICE_OBJECT DeviceObject, + IN PSECTION_OBJECT_POINTERS SectionObjectPointer, + IN NTSTATUS FlushError, + IN ULONG Flags); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlAreVolumeStartupApplicationsComplete( + VOID); + +NTKERNELAPI +ULONG +NTAPI +FsRtlQueryMaximumVirtualDiskNestingLevel( + VOID); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlGetVirtualDiskNestingLevel( + IN PDEVICE_OBJECT DeviceObject, + OUT PULONG NestingLevel, + OUT PULONG NestingFlags OPTIONAL); + +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + +#if (NTDDI_VERSION >= NTDDI_VISTASP1) +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlCheckOplockEx( + IN POPLOCK Oplock, + IN PIRP Irp, + IN ULONG Flags, + IN PVOID Context OPTIONAL, + IN POPLOCK_WAIT_COMPLETE_ROUTINE CompletionRoutine OPTIONAL, + IN POPLOCK_FS_PREPOST_IRP PostIrpRoutine OPTIONAL); + +#endif + #if (NTDDI_VERSION >= NTDDI_WIN7) + NTKERNELAPI BOOLEAN NTAPI FsRtlAreThereCurrentOrInProgressFileLocks( IN PFILE_LOCK FileLock); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlOplockIsSharedRequest( + IN PIRP Irp); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlOplockBreakH( + IN POPLOCK Oplock, + IN PIRP Irp, + IN ULONG Flags, + IN PVOID Context OPTIONAL, + IN POPLOCK_WAIT_COMPLETE_ROUTINE CompletionRoutine OPTIONAL, + IN POPLOCK_FS_PREPOST_IRP PostIrpRoutine OPTIONAL); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlCurrentOplockH( + IN POPLOCK Oplock); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlOplockBreakToNoneEx( + IN OUT POPLOCK Oplock, + IN PIRP Irp, + IN ULONG Flags, + IN PVOID Context OPTIONAL, + IN POPLOCK_WAIT_COMPLETE_ROUTINE CompletionRoutine OPTIONAL, + IN POPLOCK_FS_PREPOST_IRP PostIrpRoutine OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlOplockFsctrlEx( + IN POPLOCK Oplock, + IN PIRP Irp, + IN ULONG OpenCount, + IN ULONG Flags); + +NTKERNELAPI +BOOLEAN +NTAPI +FsRtlOplockKeysEqual( + IN PFILE_OBJECT Fo1 OPTIONAL, + IN PFILE_OBJECT Fo2 OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlInitializeExtraCreateParameterList( + IN OUT PECP_LIST EcpList); + +NTKERNELAPI +VOID +NTAPI +FsRtlInitializeExtraCreateParameter( + IN PECP_HEADER Ecp, + IN ULONG EcpFlags, + IN PFSRTL_EXTRA_CREATE_PARAMETER_CLEANUP_CALLBACK CleanupCallback OPTIONAL, + IN ULONG TotalSize, + IN LPCGUID EcpType, + IN PVOID ListAllocatedFrom OPTIONAL); + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlInsertPerFileContext( + IN PVOID* PerFileContextPointer, + IN PFSRTL_PER_FILE_CONTEXT Ptr); + +NTKERNELAPI +PFSRTL_PER_FILE_CONTEXT +NTAPI +FsRtlLookupPerFileContext( + IN PVOID* PerFileContextPointer, + IN PVOID OwnerId OPTIONAL, + IN PVOID InstanceId OPTIONAL); + +NTKERNELAPI +PFSRTL_PER_FILE_CONTEXT +NTAPI +FsRtlRemovePerFileContext( + IN PVOID* PerFileContextPointer, + IN PVOID OwnerId OPTIONAL, + IN PVOID InstanceId OPTIONAL); + +NTKERNELAPI +VOID +NTAPI +FsRtlTeardownPerFileContexts( + IN PVOID* PerFileContextPointer); + +NTKERNELAPI +NTSTATUS +NTAPI +FsRtlInsertPerFileObjectContext( + IN PFILE_OBJECT FileObject, + IN PFSRTL_PER_FILEOBJECT_CONTEXT Ptr); + +NTKERNELAPI +PFSRTL_PER_FILEOBJECT_CONTEXT +NTAPI +FsRtlLookupPerFileObjectContext( + IN PFILE_OBJECT FileObject, + IN PVOID OwnerId OPTIONAL, + IN PVOID InstanceId OPTIONAL); + +NTKERNELAPI +PFSRTL_PER_FILEOBJECT_CONTEXT +NTAPI +FsRtlRemovePerFileObjectContext( + IN PFILE_OBJECT FileObject, + IN PVOID OwnerId OPTIONAL, + IN PVOID InstanceId OPTIONAL); + +#define FsRtlFastLock(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11) ( \ + FsRtlPrivateLock(A1, A2, A3, A4, A5, A6, A7, A8, A9, NULL, A10, A11) \ +) + +#define FsRtlAreThereCurrentFileLocks(FL) ( \ + ((FL)->FastIoIsQuestionable) \ +) + +#define FsRtlIncrementLockRequestsInProgress(FL) { \ + ASSERT( (FL)->LockRequestsInProgress >= 0 ); \ + (void) \ + (InterlockedIncrement((LONG volatile *)&((FL)->LockRequestsInProgress)));\ +} + +#define FsRtlDecrementLockRequestsInProgress(FL) { \ + ASSERT( (FL)->LockRequestsInProgress > 0 ); \ + (void) \ + (InterlockedDecrement((LONG volatile *)&((FL)->LockRequestsInProgress)));\ +} + +extern NTKERNELAPI PUSHORT NlsOemLeadByteInfo; +#define NLS_OEM_LEAD_BYTE_INFO NlsOemLeadByteInfo + +#ifdef NLS_MB_CODE_PAGE_TAG +#undef NLS_MB_CODE_PAGE_TAG #endif +#define NLS_MB_CODE_PAGE_TAG NlsMbOemCodePageTag + +/* GCC compatible definition, MS one is retarded */ +extern NTKERNELAPI const UCHAR * const FsRtlLegalAnsiCharacterArray; +#define LEGAL_ANSI_CHARACTER_ARRAY FsRtlLegalAnsiCharacterArray + +#define FsRtlIsAnsiCharacterWild(C) ( \ + FlagOn(FsRtlLegalAnsiCharacterArray[(UCHAR)(C)], FSRTL_WILD_CHARACTER ) \ +) + +#define FsRtlIsAnsiCharacterLegalFat(C, WILD) ( \ + FlagOn(FsRtlLegalAnsiCharacterArray[(UCHAR)(C)], (FSRTL_FAT_LEGAL) | \ + ((WILD) ? FSRTL_WILD_CHARACTER : 0 )) \ +) + +#define FsRtlIsAnsiCharacterLegalHpfs(C, WILD) ( \ + FlagOn(FsRtlLegalAnsiCharacterArray[(UCHAR)(C)], (FSRTL_HPFS_LEGAL) | \ + ((WILD) ? FSRTL_WILD_CHARACTER : 0 )) \ +) + +#define FsRtlIsAnsiCharacterLegalNtfs(C, WILD) ( \ + FlagOn(FsRtlLegalAnsiCharacterArray[(UCHAR)(C)], (FSRTL_NTFS_LEGAL) | \ + ((WILD) ? FSRTL_WILD_CHARACTER : 0 )) \ +) + +#define FsRtlIsAnsiCharacterLegalNtfsStream(C,WILD_OK) ( \ + FsRtlTestAnsiCharacter((C), TRUE, (WILD_OK), FSRTL_NTFS_STREAM_LEGAL) \ +) + +#define FsRtlIsAnsiCharacterLegal(C,FLAGS) ( \ + FsRtlTestAnsiCharacter((C), TRUE, FALSE, (FLAGS)) \ +) + +#define FsRtlTestAnsiCharacter(C, DEFAULT_RET, WILD_OK, FLAGS) ( \ + ((SCHAR)(C) < 0) ? DEFAULT_RET : \ + FlagOn( LEGAL_ANSI_CHARACTER_ARRAY[(C)], \ + (FLAGS) | \ + ((WILD_OK) ? FSRTL_WILD_CHARACTER : 0) ) \ +) + +#define FsRtlIsLeadDbcsCharacter(DBCS_CHAR) ( \ + (BOOLEAN)((UCHAR)(DBCS_CHAR) < 0x80 ? FALSE : \ + (NLS_MB_CODE_PAGE_TAG && \ + (NLS_OEM_LEAD_BYTE_INFO[(UCHAR)(DBCS_CHAR)] != 0))) \ +) + +#define FsRtlIsUnicodeCharacterWild(C) ( \ + (((C) >= 0x40) ? \ + FALSE : \ + FlagOn(FsRtlLegalAnsiCharacterArray[(C)], FSRTL_WILD_CHARACTER )) \ +) + +#define FsRtlInitPerFileContext( _fc, _owner, _inst, _cb) \ + ((_fc)->OwnerId = (_owner), \ + (_fc)->InstanceId = (_inst), \ + (_fc)->FreeCallback = (_cb)) + +#define FsRtlGetPerFileContextPointer(_fo) \ + (FsRtlSupportsPerFileContexts(_fo) ? \ + FsRtlGetPerStreamContextPointer(_fo)->FileContextSupportPointer : \ + NULL) + +#define FsRtlSupportsPerFileContexts(_fo) \ + ((FsRtlGetPerStreamContextPointer(_fo) != NULL) && \ + (FsRtlGetPerStreamContextPointer(_fo)->Version >= FSRTL_FCB_HEADER_V1) && \ + (FsRtlGetPerStreamContextPointer(_fo)->FileContextSupportPointer != NULL)) + +#define FsRtlSetupAdvancedHeaderEx( _advhdr, _fmutx, _fctxptr ) \ +{ \ + FsRtlSetupAdvancedHeader( _advhdr, _fmutx ); \ + if ((_fctxptr) != NULL) { \ + (_advhdr)->FileContextSupportPointer = (_fctxptr); \ + } \ +} + +#define FsRtlGetPerStreamContextPointer(FO) ( \ + (PFSRTL_ADVANCED_FCB_HEADER)(FO)->FsContext \ +) + +#define FsRtlInitPerStreamContext(PSC, O, I, FC) ( \ + (PSC)->OwnerId = (O), \ + (PSC)->InstanceId = (I), \ + (PSC)->FreeCallback = (FC) \ +) + +#define FsRtlSupportsPerStreamContexts(FO) ( \ + (BOOLEAN)((NULL != FsRtlGetPerStreamContextPointer(FO) && \ + FlagOn(FsRtlGetPerStreamContextPointer(FO)->Flags2, \ + FSRTL_FLAG2_SUPPORTS_FILTER_CONTEXTS)) \ +) + +#define FsRtlLookupPerStreamContext(_sc, _oid, _iid) \ + (((NULL != (_sc)) && \ + FlagOn((_sc)->Flags2,FSRTL_FLAG2_SUPPORTS_FILTER_CONTEXTS) && \ + !IsListEmpty(&(_sc)->FilterContexts)) ? \ + FsRtlLookupPerStreamContextInternal((_sc), (_oid), (_iid)) : \ + NULL) + +VOID +FORCEINLINE +NTAPI +FsRtlSetupAdvancedHeader( + IN PVOID AdvHdr, + IN PFAST_MUTEX FMutex ) +{ + PFSRTL_ADVANCED_FCB_HEADER localAdvHdr = (PFSRTL_ADVANCED_FCB_HEADER)AdvHdr; + + localAdvHdr->Flags |= FSRTL_FLAG_ADVANCED_HEADER; + localAdvHdr->Flags2 |= FSRTL_FLAG2_SUPPORTS_FILTER_CONTEXTS; +#if (NTDDI_VERSION >= NTDDI_VISTA) + localAdvHdr->Version = FSRTL_FCB_HEADER_V1; +#else + localAdvHdr->Version = FSRTL_FCB_HEADER_V0; +#endif + InitializeListHead( &localAdvHdr->FilterContexts ); + if (FMutex != NULL) { + localAdvHdr->FastMutex = FMutex; + } +#if (NTDDI_VERSION >= NTDDI_VISTA) + *((PULONG_PTR)(&localAdvHdr->PushLock)) = 0; + localAdvHdr->FileContextSupportPointer = NULL; +#endif +} + +#define FsRtlInitPerFileObjectContext(_fc, _owner, _inst) \ + ((_fc)->OwnerId = (_owner), (_fc)->InstanceId = (_inst)) + +#define FsRtlCompleteRequest(IRP,STATUS) { \ + (IRP)->IoStatus.Status = (STATUS); \ + IoCompleteRequest( (IRP), IO_DISK_INCREMENT ); \ +} + +#if (NTDDI_VERSION >= NTDDI_WIN7) +typedef struct _ECP_HEADER ECP_HEADER, *PECP_HEADER; +#endif + +#if (NTDDI_VERSION >= NTDDI_VISTA) + +typedef enum _NETWORK_OPEN_LOCATION_QUALIFIER { + NetworkOpenLocationAny, + NetworkOpenLocationRemote, + NetworkOpenLocationLoopback +} NETWORK_OPEN_LOCATION_QUALIFIER; + +typedef enum _NETWORK_OPEN_INTEGRITY_QUALIFIER { + NetworkOpenIntegrityAny, + NetworkOpenIntegrityNone, + NetworkOpenIntegritySigned, + NetworkOpenIntegrityEncrypted, + NetworkOpenIntegrityMaximum +} NETWORK_OPEN_INTEGRITY_QUALIFIER; + +#if (NTDDI_VERSION >= NTDDI_WIN7) + +#define NETWORK_OPEN_ECP_IN_FLAG_DISABLE_HANDLE_COLLAPSING 0x1 +#define NETWORK_OPEN_ECP_IN_FLAG_DISABLE_HANDLE_DURABILITY 0x2 +#define NETWORK_OPEN_ECP_IN_FLAG_FORCE_BUFFERED_SYNCHRONOUS_IO_HACK 0x80000000 + +typedef struct _NETWORK_OPEN_ECP_CONTEXT { + USHORT Size; + USHORT Reserved; + struct { + struct { + NETWORK_OPEN_LOCATION_QUALIFIER Location; + NETWORK_OPEN_INTEGRITY_QUALIFIER Integrity; + ULONG Flags; + } in; + struct { + NETWORK_OPEN_LOCATION_QUALIFIER Location; + NETWORK_OPEN_INTEGRITY_QUALIFIER Integrity; + ULONG Flags; + } out; + } DUMMYSTRUCTNAME; +} NETWORK_OPEN_ECP_CONTEXT, *PNETWORK_OPEN_ECP_CONTEXT; + +typedef struct _NETWORK_OPEN_ECP_CONTEXT_V0 { + USHORT Size; + USHORT Reserved; + struct { + struct { + NETWORK_OPEN_LOCATION_QUALIFIER Location; + NETWORK_OPEN_INTEGRITY_QUALIFIER Integrity; + } in; + struct { + NETWORK_OPEN_LOCATION_QUALIFIER Location; + NETWORK_OPEN_INTEGRITY_QUALIFIER Integrity; + } out; + } DUMMYSTRUCTNAME; +} NETWORK_OPEN_ECP_CONTEXT_V0, *PNETWORK_OPEN_ECP_CONTEXT_V0; + +#elif (NTDDI_VERSION >= NTDDI_VISTA) +typedef struct _NETWORK_OPEN_ECP_CONTEXT { + USHORT Size; + USHORT Reserved; + struct { + struct { + NETWORK_OPEN_LOCATION_QUALIFIER Location; + NETWORK_OPEN_INTEGRITY_QUALIFIER Integrity; + } in; + struct { + NETWORK_OPEN_LOCATION_QUALIFIER Location; + NETWORK_OPEN_INTEGRITY_QUALIFIER Integrity; + } out; + } DUMMYSTRUCTNAME; +} NETWORK_OPEN_ECP_CONTEXT, *PNETWORK_OPEN_ECP_CONTEXT; +#endif + +DEFINE_GUID(GUID_ECP_NETWORK_OPEN_CONTEXT, 0xc584edbf, 0x00df, 0x4d28, 0xb8, 0x84, 0x35, 0xba, 0xca, 0x89, 0x11, 0xe8 ); + +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + + +#if (NTDDI_VERSION >= NTDDI_VISTA) + +typedef struct _PREFETCH_OPEN_ECP_CONTEXT { + PVOID Context; +} PREFETCH_OPEN_ECP_CONTEXT, *PPREFETCH_OPEN_ECP_CONTEXT; + +DEFINE_GUID(GUID_ECP_PREFETCH_OPEN, 0xe1777b21, 0x847e, 0x4837, 0xaa, 0x45, 0x64, 0x16, 0x1d, 0x28, 0x6, 0x55 ); + +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + +#if (NTDDI_VERSION >= NTDDI_WIN7) + +DEFINE_GUID (GUID_ECP_NFS_OPEN, 0xf326d30c, 0xe5f8, 0x4fe7, 0xab, 0x74, 0xf5, 0xa3, 0x19, 0x6d, 0x92, 0xdb); +DEFINE_GUID(GUID_ECP_SRV_OPEN, 0xbebfaebc, 0xaabf, 0x489d, 0x9d, 0x2c, 0xe9, 0xe3, 0x61, 0x10, 0x28, 0x53 ); + +typedef struct sockaddr_storage *PSOCKADDR_STORAGE_NFS; + +typedef struct _NFS_OPEN_ECP_CONTEXT { + PUNICODE_STRING ExportAlias; + PSOCKADDR_STORAGE_NFS ClientSocketAddress; +} NFS_OPEN_ECP_CONTEXT, *PNFS_OPEN_ECP_CONTEXT, **PPNFS_OPEN_ECP_CONTEXT; + +typedef struct _SRV_OPEN_ECP_CONTEXT { + PUNICODE_STRING ShareName; + PSOCKADDR_STORAGE_NFS SocketAddress; + BOOLEAN OplockBlockState; + BOOLEAN OplockAppState; + BOOLEAN OplockFinalState; +} SRV_OPEN_ECP_CONTEXT, *PSRV_OPEN_ECP_CONTEXT; + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + +#define VACB_MAPPING_GRANULARITY (0x40000) +#define VACB_OFFSET_SHIFT (18) + +typedef struct _PUBLIC_BCB { + CSHORT NodeTypeCode; + CSHORT NodeByteSize; + ULONG MappedLength; + LARGE_INTEGER MappedFileOffset; +} PUBLIC_BCB, *PPUBLIC_BCB; + +typedef struct _CC_FILE_SIZES { + LARGE_INTEGER AllocationSize; + LARGE_INTEGER FileSize; + LARGE_INTEGER ValidDataLength; +} CC_FILE_SIZES, *PCC_FILE_SIZES; + +typedef BOOLEAN +(NTAPI *PACQUIRE_FOR_LAZY_WRITE) ( + IN PVOID Context, + IN BOOLEAN Wait); + +typedef VOID +(NTAPI *PRELEASE_FROM_LAZY_WRITE) ( + IN PVOID Context); + +typedef BOOLEAN +(NTAPI *PACQUIRE_FOR_READ_AHEAD) ( + IN PVOID Context, + IN BOOLEAN Wait); + +typedef VOID +(NTAPI *PRELEASE_FROM_READ_AHEAD) ( + IN PVOID Context); + +typedef struct _CACHE_MANAGER_CALLBACKS { + PACQUIRE_FOR_LAZY_WRITE AcquireForLazyWrite; + PRELEASE_FROM_LAZY_WRITE ReleaseFromLazyWrite; + PACQUIRE_FOR_READ_AHEAD AcquireForReadAhead; + PRELEASE_FROM_READ_AHEAD ReleaseFromReadAhead; +} CACHE_MANAGER_CALLBACKS, *PCACHE_MANAGER_CALLBACKS; + +typedef struct _CACHE_UNINITIALIZE_EVENT { + struct _CACHE_UNINITIALIZE_EVENT *Next; + KEVENT Event; +} CACHE_UNINITIALIZE_EVENT, *PCACHE_UNINITIALIZE_EVENT; + +typedef VOID +(NTAPI *PDIRTY_PAGE_ROUTINE) ( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN PLARGE_INTEGER OldestLsn, + IN PLARGE_INTEGER NewestLsn, + IN PVOID Context1, + IN PVOID Context2); + +typedef VOID +(NTAPI *PFLUSH_TO_LSN) ( + IN PVOID LogHandle, + IN LARGE_INTEGER Lsn); + +typedef VOID +(NTAPI *PCC_POST_DEFERRED_WRITE) ( + IN PVOID Context1, + IN PVOID Context2); + +#define CcIsFileCached(FO) ( \ + ((FO)->SectionObjectPointer != NULL) && \ + (((PSECTION_OBJECT_POINTERS)(FO)->SectionObjectPointer)->SharedCacheMap != NULL) \ +) + +extern ULONG CcFastMdlReadWait; + +#if (NTDDI_VERSION >= NTDDI_WIN2K) + +NTKERNELAPI +VOID +NTAPI +CcInitializeCacheMap( + IN PFILE_OBJECT FileObject, + IN PCC_FILE_SIZES FileSizes, + IN BOOLEAN PinAccess, + IN PCACHE_MANAGER_CALLBACKS Callbacks, + IN PVOID LazyWriteContext); + +NTKERNELAPI +BOOLEAN +NTAPI +CcUninitializeCacheMap( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER TruncateSize OPTIONAL, + IN PCACHE_UNINITIALIZE_EVENT UninitializeCompleteEvent OPTIONAL); + +NTKERNELAPI +VOID +NTAPI +CcSetFileSizes( + IN PFILE_OBJECT FileObject, + IN PCC_FILE_SIZES FileSizes); + +NTKERNELAPI +VOID +NTAPI +CcSetDirtyPageThreshold( + IN PFILE_OBJECT FileObject, + IN ULONG DirtyPageThreshold); + +NTKERNELAPI +VOID +NTAPI +CcFlushCache( + IN PSECTION_OBJECT_POINTERS SectionObjectPointer, + IN PLARGE_INTEGER FileOffset OPTIONAL, + IN ULONG Length, + OUT PIO_STATUS_BLOCK IoStatus OPTIONAL); + +NTKERNELAPI +LARGE_INTEGER +NTAPI +CcGetFlushedValidData( + IN PSECTION_OBJECT_POINTERS SectionObjectPointer, + IN BOOLEAN BcbListHeld); + +NTKERNELAPI +BOOLEAN +NTAPI +CcZeroData( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER StartOffset, + IN PLARGE_INTEGER EndOffset, + IN BOOLEAN Wait); + +NTKERNELAPI +PVOID +NTAPI +CcRemapBcb( + IN PVOID Bcb); + +NTKERNELAPI +VOID +NTAPI +CcRepinBcb( + IN PVOID Bcb); + +NTKERNELAPI +VOID +NTAPI +CcUnpinRepinnedBcb( + IN PVOID Bcb, + IN BOOLEAN WriteThrough, + OUT PIO_STATUS_BLOCK IoStatus); + +NTKERNELAPI +PFILE_OBJECT +NTAPI +CcGetFileObjectFromSectionPtrs( + IN PSECTION_OBJECT_POINTERS SectionObjectPointer); + +NTKERNELAPI +PFILE_OBJECT +NTAPI +CcGetFileObjectFromBcb( + IN PVOID Bcb); + +NTKERNELAPI +BOOLEAN +NTAPI +CcCanIWrite( + IN PFILE_OBJECT FileObject, + IN ULONG BytesToWrite, + IN BOOLEAN Wait, + IN BOOLEAN Retrying); + +NTKERNELAPI +VOID +NTAPI +CcDeferWrite( + IN PFILE_OBJECT FileObject, + IN PCC_POST_DEFERRED_WRITE PostRoutine, + IN PVOID Context1, + IN PVOID Context2, + IN ULONG BytesToWrite, + IN BOOLEAN Retrying); + +NTKERNELAPI +BOOLEAN +NTAPI +CcCopyRead( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN BOOLEAN Wait, + OUT PVOID Buffer, + OUT PIO_STATUS_BLOCK IoStatus); + +NTKERNELAPI +VOID +NTAPI +CcFastCopyRead( + IN PFILE_OBJECT FileObject, + IN ULONG FileOffset, + IN ULONG Length, + IN ULONG PageCount, + OUT PVOID Buffer, + OUT PIO_STATUS_BLOCK IoStatus); + +NTKERNELAPI +BOOLEAN +NTAPI +CcCopyWrite( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN BOOLEAN Wait, + IN PVOID Buffer); + +NTKERNELAPI +VOID +NTAPI +CcFastCopyWrite( + IN PFILE_OBJECT FileObject, + IN ULONG FileOffset, + IN ULONG Length, + IN PVOID Buffer); + +NTKERNELAPI +VOID +NTAPI +CcMdlRead( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + OUT PMDL *MdlChain, + OUT PIO_STATUS_BLOCK IoStatus); + +NTKERNELAPI +VOID +NTAPI +CcMdlReadComplete( + IN PFILE_OBJECT FileObject, + IN PMDL MdlChain); + +NTKERNELAPI +VOID +NTAPI +CcPrepareMdlWrite( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + OUT PMDL *MdlChain, + OUT PIO_STATUS_BLOCK IoStatus); + +NTKERNELAPI +VOID +NTAPI +CcMdlWriteComplete( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN PMDL MdlChain); + +NTKERNELAPI +VOID +NTAPI +CcScheduleReadAhead( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length); + +NTKERNELAPI +NTSTATUS +NTAPI +CcWaitForCurrentLazyWriterActivity( + VOID); + +NTKERNELAPI +VOID +NTAPI +CcSetReadAheadGranularity( + IN PFILE_OBJECT FileObject, + IN ULONG Granularity); + +NTKERNELAPI +BOOLEAN +NTAPI +CcPinRead( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN ULONG Flags, + OUT PVOID *Bcb, + OUT PVOID *Buffer); + +NTKERNELAPI +BOOLEAN +NTAPI +CcPinMappedData( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN ULONG Flags, + IN OUT PVOID *Bcb); + +NTKERNELAPI +BOOLEAN +NTAPI +CcPreparePinWrite( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN BOOLEAN Zero, + IN ULONG Flags, + OUT PVOID *Bcb, + OUT PVOID *Buffer); + +NTKERNELAPI +VOID +NTAPI +CcSetDirtyPinnedData( + IN PVOID BcbVoid, + IN PLARGE_INTEGER Lsn OPTIONAL); + +NTKERNELAPI +VOID +NTAPI +CcUnpinData( + IN PVOID Bcb); + +NTKERNELAPI +VOID +NTAPI +CcSetBcbOwnerPointer( + IN PVOID Bcb, + IN PVOID OwnerPointer); + +NTKERNELAPI +VOID +NTAPI +CcUnpinDataForThread( + IN PVOID Bcb, + IN ERESOURCE_THREAD ResourceThreadId); + +NTKERNELAPI +VOID +NTAPI +CcSetAdditionalCacheAttributes( + IN PFILE_OBJECT FileObject, + IN BOOLEAN DisableReadAhead, + IN BOOLEAN DisableWriteBehind); + +NTKERNELAPI +BOOLEAN +NTAPI +CcIsThereDirtyData( + IN PVPB Vpb); + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ + +#if (NTDDI_VERSION >= NTDDI_WINXP) + +NTKERNELAPI +VOID +NTAPI +CcMdlWriteAbort( + IN PFILE_OBJECT FileObject, + IN PMDL MdlChain); + +NTKERNELAPI +VOID +NTAPI +CcSetLogHandleForFile( + IN PFILE_OBJECT FileObject, + IN PVOID LogHandle, + IN PFLUSH_TO_LSN FlushToLsnRoutine); + +NTKERNELAPI +LARGE_INTEGER +NTAPI +CcGetDirtyPages( + IN PVOID LogHandle, + IN PDIRTY_PAGE_ROUTINE DirtyPageRoutine, + IN PVOID Context1, + IN PVOID Context2); + +#endif + +#if (NTDDI_VERSION >= NTDDI_WINXP) +NTKERNELAPI +BOOLEAN +NTAPI +CcMapData( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN ULONG Flags, + OUT PVOID *Bcb, + OUT PVOID *Buffer); +#elif (NTDDI_VERSION >= NTDDI_WIN2K) +NTKERNELAPI +BOOLEAN +NTAPI +CcMapData( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length, + IN BOOLEAN Wait, + OUT PVOID *Bcb, + OUT PVOID *Buffer); +#endif + +#if (NTDDI_VERSION >= NTDDI_VISTA) + +NTKERNELAPI +NTSTATUS +NTAPI +CcSetFileSizesEx( + IN PFILE_OBJECT FileObject, + IN PCC_FILE_SIZES FileSizes); + +NTKERNELAPI +PFILE_OBJECT +NTAPI +CcGetFileObjectFromSectionPtrsRef( + IN PSECTION_OBJECT_POINTERS SectionObjectPointer); + +NTKERNELAPI +VOID +NTAPI +CcSetParallelFlushFile( + IN PFILE_OBJECT FileObject, + IN BOOLEAN EnableParallelFlush); + +NTKERNELAPI +BOOLEAN +CcIsThereDirtyDataEx( + IN PVPB Vpb, + IN PULONG NumberOfDirtyPages OPTIONAL); + +#endif + +#if (NTDDI_VERSION >= NTDDI_WIN7) +NTKERNELAPI +VOID +NTAPI +CcCoherencyFlushAndPurgeCache( + IN PSECTION_OBJECT_POINTERS SectionObjectPointer, + IN PLARGE_INTEGER FileOffset OPTIONAL, + IN ULONG Length, + OUT PIO_STATUS_BLOCK IoStatus, + IN ULONG Flags OPTIONAL); +#endif + +#define CcGetFileSizePointer(FO) ( \ + ((PLARGE_INTEGER)((FO)->SectionObjectPointer->SharedCacheMap) + 1) \ +) + +#define UNINITIALIZE_CACHE_MAPS (1) +#define DO_NOT_RETRY_PURGE (2) +#define DO_NOT_PURGE_DIRTY_PAGES (0x4) + +#define CC_FLUSH_AND_PURGE_NO_PURGE (0x1) + +#if (NTDDI_VERSION >= NTDDI_VISTA) +NTKERNELAPI +BOOLEAN +NTAPI +CcPurgeCacheSection( + IN PSECTION_OBJECT_POINTERS SectionObjectPointer, + IN PLARGE_INTEGER FileOffset OPTIONAL, + IN ULONG Length, + IN ULONG Flags); +#elif (NTDDI_VERSION >= NTDDI_WIN2K) +NTKERNELAPI +BOOLEAN +NTAPI +CcPurgeCacheSection( + IN PSECTION_OBJECT_POINTERS SectionObjectPointer, + IN PLARGE_INTEGER FileOffset OPTIONAL, + IN ULONG Length, + IN BOOLEAN UninitializeCacheMaps); +#endif + +#if (NTDDI_VERSION >= NTDDI_WIN7) +NTKERNELAPI +BOOLEAN +NTAPI +CcCopyWriteWontFlush( + IN PFILE_OBJECT FileObject, + IN PLARGE_INTEGER FileOffset, + IN ULONG Length); +#else +#define CcCopyWriteWontFlush(FO, FOFF, LEN) ((LEN) <= 0x10000) +#endif + +#define CcReadAhead(FO, FOFF, LEN) ( \ + if ((LEN) >= 256) { \ + CcScheduleReadAhead((FO), (FOFF), (LEN)); \ + } \ +) + +#define PIN_WAIT (1) +#define PIN_EXCLUSIVE (2) +#define PIN_NO_READ (4) +#define PIN_IF_BCB (8) +#define PIN_CALLER_TRACKS_DIRTY_DATA (32) +#define PIN_HIGH_PRIORITY (64) + +#define MAP_WAIT 1 +#define MAP_NO_READ (16) +#define MAP_HIGH_PRIORITY (64) + +#define IOCTL_REDIR_QUERY_PATH CTL_CODE(FILE_DEVICE_NETWORK_FILE_SYSTEM, 99, METHOD_NEITHER, FILE_ANY_ACCESS) +#define IOCTL_REDIR_QUERY_PATH_EX CTL_CODE(FILE_DEVICE_NETWORK_FILE_SYSTEM, 100, METHOD_NEITHER, FILE_ANY_ACCESS) + +typedef struct _QUERY_PATH_REQUEST { + ULONG PathNameLength; + PIO_SECURITY_CONTEXT SecurityContext; + WCHAR FilePathName[1]; +} QUERY_PATH_REQUEST, *PQUERY_PATH_REQUEST; + +typedef struct _QUERY_PATH_REQUEST_EX { + PIO_SECURITY_CONTEXT pSecurityContext; + ULONG EaLength; + PVOID pEaBuffer; + UNICODE_STRING PathName; + UNICODE_STRING DomainServiceName; + ULONG_PTR Reserved[ 3 ]; +} QUERY_PATH_REQUEST_EX, *PQUERY_PATH_REQUEST_EX; + +typedef struct _QUERY_PATH_RESPONSE { + ULONG LengthAccepted; +} QUERY_PATH_RESPONSE, *PQUERY_PATH_RESPONSE; + +#define VOLSNAPCONTROLTYPE 0x00000053 +#define IOCTL_VOLSNAP_FLUSH_AND_HOLD_WRITES CTL_CODE(VOLSNAPCONTROLTYPE, 0, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) + +#if (NTDDI_VERSION >= NTDDI_WIN2K) + +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryObject( + IN HANDLE Handle OPTIONAL, + IN OBJECT_INFORMATION_CLASS ObjectInformationClass, + OUT PVOID ObjectInformation OPTIONAL, + IN ULONG ObjectInformationLength, + OUT PULONG ReturnLength OPTIONAL); + +NTSYSAPI +NTSTATUS +NTAPI +ZwNotifyChangeKey( + IN HANDLE KeyHandle, + IN HANDLE EventHandle OPTIONAL, + IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, + IN PVOID ApcContext OPTIONAL, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN ULONG NotifyFilter, + IN BOOLEAN WatchSubtree, + OUT PVOID Buffer, + IN ULONG BufferLength, + IN BOOLEAN Asynchronous); + +NTSYSAPI +NTSTATUS +NTAPI +ZwCreateEvent( + OUT PHANDLE EventHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, + IN EVENT_TYPE EventType, + IN BOOLEAN InitialState); + +NTSYSAPI +NTSTATUS +NTAPI +ZwDeleteFile( + IN POBJECT_ATTRIBUTES ObjectAttributes); + +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryDirectoryFile( + IN HANDLE FileHandle, + IN HANDLE Event OPTIONAL, + IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, + IN PVOID ApcContext OPTIONAL, + OUT PIO_STATUS_BLOCK IoStatusBlock, + OUT PVOID FileInformation, + IN ULONG Length, + IN FILE_INFORMATION_CLASS FileInformationClass, + IN BOOLEAN ReturnSingleEntry, + IN PUNICODE_STRING FileName OPTIONAL, + IN BOOLEAN RestartScan); + +NTSYSAPI +NTSTATUS +NTAPI +ZwSetVolumeInformationFile( + IN HANDLE FileHandle, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN PVOID FsInformation, + IN ULONG Length, + IN FS_INFORMATION_CLASS FsInformationClass); + +NTSYSAPI +NTSTATUS +NTAPI +ZwFsControlFile( + IN HANDLE FileHandle, + IN HANDLE Event OPTIONAL, + IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, + IN PVOID ApcContext OPTIONAL, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN ULONG FsControlCode, + IN PVOID InputBuffer OPTIONAL, + IN ULONG InputBufferLength, + OUT PVOID OutputBuffer OPTIONAL, + IN ULONG OutputBufferLength); + +NTSYSAPI +NTSTATUS +NTAPI +ZwDuplicateObject( + IN HANDLE SourceProcessHandle, + IN HANDLE SourceHandle, + IN HANDLE TargetProcessHandle OPTIONAL, + OUT PHANDLE TargetHandle OPTIONAL, + IN ACCESS_MASK DesiredAccess, + IN ULONG HandleAttributes, + IN ULONG Options); + +NTSYSAPI +NTSTATUS +NTAPI +ZwOpenDirectoryObject( + OUT PHANDLE DirectoryHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes); + +NTSYSAPI +NTSTATUS +NTAPI +ZwAllocateVirtualMemory( + IN HANDLE ProcessHandle, + IN OUT PVOID *BaseAddress, + IN ULONG_PTR ZeroBits, + IN OUT PSIZE_T RegionSize, + IN ULONG AllocationType, + IN ULONG Protect); + +NTSYSAPI +NTSTATUS +NTAPI +ZwFreeVirtualMemory( + IN HANDLE ProcessHandle, + IN OUT PVOID *BaseAddress, + IN OUT PSIZE_T RegionSize, + IN ULONG FreeType); + +NTSYSAPI +NTSTATUS +NTAPI +ZwWaitForSingleObject( + IN HANDLE Handle, + IN BOOLEAN Alertable, + IN PLARGE_INTEGER Timeout OPTIONAL); + +NTSYSAPI +NTSTATUS +NTAPI +ZwSetEvent( + IN HANDLE EventHandle, + OUT PLONG PreviousState OPTIONAL); + +NTSYSAPI +NTSTATUS +NTAPI +ZwFlushVirtualMemory( + IN HANDLE ProcessHandle, + IN OUT PVOID *BaseAddress, + IN OUT PSIZE_T RegionSize, + OUT PIO_STATUS_BLOCK IoStatusBlock); + +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryInformationToken( + IN HANDLE TokenHandle, + IN TOKEN_INFORMATION_CLASS TokenInformationClass, + OUT PVOID TokenInformation, + IN ULONG Length, + OUT PULONG ResultLength); + +NTSYSAPI +NTSTATUS +NTAPI +ZwSetSecurityObject( + IN HANDLE Handle, + IN SECURITY_INFORMATION SecurityInformation, + IN PSECURITY_DESCRIPTOR SecurityDescriptor); + +NTSYSAPI +NTSTATUS +NTAPI +ZwQuerySecurityObject( + IN HANDLE FileHandle, + IN SECURITY_INFORMATION SecurityInformation, + OUT PSECURITY_DESCRIPTOR SecurityDescriptor, + IN ULONG Length, + OUT PULONG ResultLength); + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ + +#if (NTDDI_VERSION >= NTDDI_WINXP) + +NTSYSAPI +NTSTATUS +NTAPI +ZwOpenProcessTokenEx( + IN HANDLE ProcessHandle, + IN ACCESS_MASK DesiredAccess, + IN ULONG HandleAttributes, + OUT PHANDLE TokenHandle); + +NTSYSAPI +NTSTATUS +NTAPI +ZwOpenThreadTokenEx( + IN HANDLE ThreadHandle, + IN ACCESS_MASK DesiredAccess, + IN BOOLEAN OpenAsSelf, + IN ULONG HandleAttributes, + OUT PHANDLE TokenHandle); + +#endif + +#if (NTDDI_VERSION >= NTDDI_VISTA) + +NTSYSAPI +NTSTATUS +NTAPI +ZwLockFile( + IN HANDLE FileHandle, + IN HANDLE Event OPTIONAL, + IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, + IN PVOID ApcContext OPTIONAL, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN PLARGE_INTEGER ByteOffset, + IN PLARGE_INTEGER Length, + IN ULONG Key, + IN BOOLEAN FailImmediately, + IN BOOLEAN ExclusiveLock); + +NTSYSAPI +NTSTATUS +NTAPI +ZwUnlockFile( + IN HANDLE FileHandle, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN PLARGE_INTEGER ByteOffset, + IN PLARGE_INTEGER Length, + IN ULONG Key); + +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryQuotaInformationFile( + IN HANDLE FileHandle, + OUT PIO_STATUS_BLOCK IoStatusBlock, + OUT PVOID Buffer, + IN ULONG Length, + IN BOOLEAN ReturnSingleEntry, + IN PVOID SidList, + IN ULONG SidListLength, + IN PSID StartSid OPTIONAL, + IN BOOLEAN RestartScan); + +NTSYSAPI +NTSTATUS +NTAPI +ZwSetQuotaInformationFile( + IN HANDLE FileHandle, + OUT PIO_STATUS_BLOCK IoStatusBlock, + IN PVOID Buffer, + IN ULONG Length); + +NTSYSAPI +NTSTATUS +NTAPI +ZwFlushBuffersFile( + IN HANDLE FileHandle, + OUT PIO_STATUS_BLOCK IoStatusBlock); + +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + +#if (NTDDI_VERSION >= NTDDI_WIN7) +NTSYSAPI +NTSTATUS +NTAPI +ZwSetInformationToken( + IN HANDLE TokenHandle, + IN TOKEN_INFORMATION_CLASS TokenInformationClass, + IN PVOID TokenInformation, + IN ULONG TokenInformationLength); +#endif + +NTSYSAPI +NTSTATUS +NTAPI +ZwQueryEaFile( + IN HANDLE FileHandle, + OUT PIO_STATUS_BLOCK IoStatusBlock, + OUT PVOID Buffer, + IN ULONG Length, + IN BOOLEAN ReturnSingleEntry, + IN PVOID EaList OPTIONAL, + IN ULONG EaListLength, + IN PULONG EaIndex OPTIONAL, + IN BOOLEAN RestartScan); + +NTSYSAPI +NTSTATUS +NTAPI +ZwSetEaFile( + IN HANDLE FileHandle, + OUT PIO_STATUS_BLOCK IoStatusBlock, + OUT PVOID Buffer, + IN ULONG Length); + +NTSYSAPI +NTSTATUS +NTAPI +ZwDuplicateToken( + IN HANDLE ExistingTokenHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN BOOLEAN EffectiveOnly, + IN TOKEN_TYPE TokenType, + OUT PHANDLE NewTokenHandle); #pragma pack(push,4) @@ -6863,11 +8890,6 @@ FsRtlAreThereCurrentOrInProgressFileLocks( #include "csq.h" -#ifdef _NTOSKRNL_ -extern PUCHAR FsRtlLegalAnsiCharacterArray; -#else -extern DECLSPEC_IMPORT PUCHAR FsRtlLegalAnsiCharacterArray; -#endif extern PACL SePublicDefaultDacl; extern PACL SeSystemDefaultDacl; @@ -6890,30 +8912,11 @@ extern PACL SeSystemDefaultDacl; #define FILE_VC_QUOTAS_LOG_VIOLATIONS 0x00000004 -#define FSRTL_VOLUME_DISMOUNT 1 -#define FSRTL_VOLUME_DISMOUNT_FAILED 2 -#define FSRTL_VOLUME_LOCK 3 -#define FSRTL_VOLUME_LOCK_FAILED 4 -#define FSRTL_VOLUME_UNLOCK 5 -#define FSRTL_VOLUME_MOUNT 6 - -#define FSRTL_WILD_CHARACTER 0x08 - -#define FSRTL_FAT_LEGAL 0x01 -#define FSRTL_HPFS_LEGAL 0x02 -#define FSRTL_NTFS_LEGAL 0x04 -#define FSRTL_WILD_CHARACTER 0x08 -#define FSRTL_OLE_LEGAL 0x10 -#define FSRTL_NTFS_STREAM_LEGAL 0x14 - #ifdef _X86_ #define HARDWARE_PTE HARDWARE_PTE_X86 #define PHARDWARE_PTE PHARDWARE_PTE_X86 #endif -#define IO_CHECK_CREATE_PARAMETERS 0x0200 -#define IO_ATTACH_DEVICE 0x0400 - #define IO_ATTACH_DEVICE_API 0x80000000 #define IO_TYPE_APC 18 @@ -6932,8 +8935,6 @@ extern PACL SeSystemDefaultDacl; #define MEM_DOS_LIM 0x40000000 -#define MCB_FLAG_RAISE_ON_ALLOCATION_FAILURE 1 - #define OB_TYPE_TYPE 1 #define OB_TYPE_DIRECTORY 2 #define OB_TYPE_SYMBOLIC_LINK 3 @@ -6958,23 +8959,12 @@ extern PACL SeSystemDefaultDacl; #define OB_TYPE_IO_COMPLETION 22 #define OB_TYPE_FILE 23 -#define PIN_WAIT (1) -#define PIN_EXCLUSIVE (2) -#define PIN_NO_READ (4) -#define PIN_IF_BCB (8) - #define SEC_BASED 0x00200000 -#define SECURITY_WORLD_SID_AUTHORITY {0,0,0,0,0,1} -#define SECURITY_WORLD_RID (0x00000000L) - /* end winnt.h */ #define TOKEN_HAS_ADMIN_GROUP 0x08 -#define VACB_MAPPING_GRANULARITY (0x40000) -#define VACB_OFFSET_SHIFT (18) - #if (VER_PRODUCTBUILD >= 1381) #define FSCTL_GET_HFS_INFORMATION CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 31, METHOD_BUFFERED, FILE_ANY_ACCESS) #endif /* (VER_PRODUCTBUILD >= 1381) */ @@ -7001,18 +8991,6 @@ extern PACL SeSystemDefaultDacl; #define FSCTL_NETWORK_SET_DOMAIN_NAME CTL_CODE(FILE_DEVICE_NETWORK_FILE_SYSTEM, 120, METHOD_BUFFERED, FILE_ANY_ACCESS) #define FSCTL_NETWORK_REMOTE_BOOT_INIT_SCRT CTL_CODE(FILE_DEVICE_NETWORK_FILE_SYSTEM, 250, METHOD_BUFFERED, FILE_ANY_ACCESS) -#define IOCTL_REDIR_QUERY_PATH CTL_CODE(FILE_DEVICE_NETWORK_FILE_SYSTEM, 99, METHOD_NEITHER, FILE_ANY_ACCESS) - -typedef PVOID OPLOCK, *POPLOCK; - -// -// Forwarders -// -struct _RTL_AVL_TABLE; -struct _RTL_GENERIC_TABLE; - -typedef PVOID PNOTIFY_SYNC; - typedef enum _FILE_STORAGE_TYPE { StorageTypeDefault = 1, StorageTypeDirectory, @@ -7048,17 +9026,6 @@ typedef struct _BITMAP_RANGE { PULONG Bitmap; } BITMAP_RANGE, *PBITMAP_RANGE; -typedef struct _CACHE_UNINITIALIZE_EVENT { - struct _CACHE_UNINITIALIZE_EVENT *Next; - KEVENT Event; -} CACHE_UNINITIALIZE_EVENT, *PCACHE_UNINITIALIZE_EVENT; - -typedef struct _CC_FILE_SIZES { - LARGE_INTEGER AllocationSize; - LARGE_INTEGER FileSize; - LARGE_INTEGER ValidDataLength; -} CC_FILE_SIZES, *PCC_FILE_SIZES; - typedef struct _FILE_COPY_ON_WRITE_INFORMATION { BOOLEAN ReplaceIfExists; HANDLE RootDirectory; @@ -7081,49 +9048,6 @@ typedef struct _FILE_FULL_DIRECTORY_INFORMATION { WCHAR FileName[ANYSIZE_ARRAY]; } FILE_FULL_DIRECTORY_INFORMATION, *PFILE_FULL_DIRECTORY_INFORMATION; -typedef struct _FILE_FS_FULL_SIZE_INFORMATION { - LARGE_INTEGER TotalAllocationUnits; - LARGE_INTEGER CallerAvailableAllocationUnits; - LARGE_INTEGER ActualAvailableAllocationUnits; - ULONG SectorsPerAllocationUnit; - ULONG BytesPerSector; -} FILE_FS_FULL_SIZE_INFORMATION, *PFILE_FS_FULL_SIZE_INFORMATION; - -typedef struct _FILE_FS_LABEL_INFORMATION { - ULONG VolumeLabelLength; - WCHAR VolumeLabel[1]; -} FILE_FS_LABEL_INFORMATION, *PFILE_FS_LABEL_INFORMATION; - -#if (VER_PRODUCTBUILD >= 2195) - -typedef struct _FILE_FS_OBJECT_ID_INFORMATION { - UCHAR ObjectId[16]; - UCHAR ExtendedInfo[48]; -} FILE_FS_OBJECT_ID_INFORMATION, *PFILE_FS_OBJECT_ID_INFORMATION; - -#endif /* (VER_PRODUCTBUILD >= 2195) */ - -typedef struct _FILE_FS_SIZE_INFORMATION { - LARGE_INTEGER TotalAllocationUnits; - LARGE_INTEGER AvailableAllocationUnits; - ULONG SectorsPerAllocationUnit; - ULONG BytesPerSector; -} FILE_FS_SIZE_INFORMATION, *PFILE_FS_SIZE_INFORMATION; - -typedef struct _FILE_FS_VOLUME_INFORMATION { - LARGE_INTEGER VolumeCreationTime; - ULONG VolumeSerialNumber; - ULONG VolumeLabelLength; - BOOLEAN SupportsObjects; - WCHAR VolumeLabel[1]; -} FILE_FS_VOLUME_INFORMATION, *PFILE_FS_VOLUME_INFORMATION; - -typedef struct _FILE_FS_OBJECTID_INFORMATION -{ - UCHAR ObjectId[16]; - UCHAR ExtendedInfo[48]; -} FILE_FS_OBJECTID_INFORMATION, *PFILE_FS_OBJECTID_INFORMATION; - /* raw internal file lock struct returned from FsRtlGetNextFileLock */ typedef struct _FILE_SHARED_LOCK_ENTRY { PVOID Unknown1; @@ -7208,51 +9132,6 @@ typedef struct _FILE_OLE_STATE_BITS_INFORMATION { ULONG StateBitsMask; } FILE_OLE_STATE_BITS_INFORMATION, *PFILE_OLE_STATE_BITS_INFORMATION; -typedef enum _FSRTL_COMPARISON_RESULT -{ - LessThan = -1, - EqualTo = 0, - GreaterThan = 1 -} FSRTL_COMPARISON_RESULT; - -#if (VER_PRODUCTBUILD >= 2600) - -typedef struct _FSRTL_PER_STREAM_CONTEXT { - LIST_ENTRY Links; - PVOID OwnerId; - PVOID InstanceId; - PFREE_FUNCTION FreeCallback; -} FSRTL_PER_STREAM_CONTEXT, *PFSRTL_PER_STREAM_CONTEXT; - -typedef struct _FSRTL_PER_FILEOBJECT_CONTEXT -{ - LIST_ENTRY Links; - PVOID OwnerId; - PVOID InstanceId; -} FSRTL_PER_FILEOBJECT_CONTEXT, *PFSRTL_PER_FILEOBJECT_CONTEXT; - -#endif /* (VER_PRODUCTBUILD >= 2600) */ - -typedef struct _BASE_MCB -{ - ULONG MaximumPairCount; - ULONG PairCount; - USHORT PoolType; - USHORT Flags; - PVOID Mapping; -} BASE_MCB, *PBASE_MCB; - -typedef struct _LARGE_MCB -{ - PKGUARDED_MUTEX GuardedMutex; - BASE_MCB BaseMcb; -} LARGE_MCB, *PLARGE_MCB; - -typedef struct _MCB -{ - LARGE_MCB DummyFieldThatSizesThisStructureCorrectly; -} MCB, *PMCB; - typedef struct _MAPPING_PAIR { ULONGLONG Vcn; ULONGLONG Lcn; @@ -7264,8 +9143,6 @@ typedef struct _GET_RETRIEVAL_DESCRIPTOR { MAPPING_PAIR Pair[1]; } GET_RETRIEVAL_DESCRIPTOR, *PGET_RETRIEVAL_DESCRIPTOR; -#define ASSERT_QUEUE(Q) ASSERT(((Q)->Header.Type & KOBJECT_TYPE_MASK) == QueueObject); - typedef struct _MBCB { CSHORT NodeTypeCode; CSHORT NodeIsInZone; @@ -7328,189 +9205,6 @@ typedef struct _OBJECT_ALL_TYPES_INFO { OBJECT_TYPE_INFO ObjectsTypeInfo[1]; } OBJECT_ALL_TYPES_INFO, *POBJECT_ALL_TYPES_INFO; -typedef enum _RTL_GENERIC_COMPARE_RESULTS -{ - GenericLessThan, - GenericGreaterThan, - GenericEqual -} RTL_GENERIC_COMPARE_RESULTS; - -typedef enum _TABLE_SEARCH_RESULT -{ - TableEmptyTree, - TableFoundNode, - TableInsertAsLeft, - TableInsertAsRight -} TABLE_SEARCH_RESULT; - -typedef NTSTATUS -(NTAPI *PRTL_AVL_MATCH_FUNCTION)( - struct _RTL_AVL_TABLE *Table, - PVOID UserData, - PVOID MatchData -); - -typedef RTL_GENERIC_COMPARE_RESULTS -(NTAPI *PRTL_AVL_COMPARE_ROUTINE) ( - struct _RTL_AVL_TABLE *Table, - PVOID FirstStruct, - PVOID SecondStruct -); - -typedef RTL_GENERIC_COMPARE_RESULTS -(NTAPI *PRTL_GENERIC_COMPARE_ROUTINE) ( - struct _RTL_GENERIC_TABLE *Table, - PVOID FirstStruct, - PVOID SecondStruct -); - -typedef PVOID -(NTAPI *PRTL_GENERIC_ALLOCATE_ROUTINE) ( - struct _RTL_GENERIC_TABLE *Table, - CLONG ByteSize -); - -typedef VOID -(NTAPI *PRTL_GENERIC_FREE_ROUTINE) ( - struct _RTL_GENERIC_TABLE *Table, - PVOID Buffer -); - -typedef PVOID -(NTAPI *PRTL_AVL_ALLOCATE_ROUTINE) ( - struct _RTL_AVL_TABLE *Table, - CLONG ByteSize -); - -typedef VOID -(NTAPI *PRTL_AVL_FREE_ROUTINE) ( - struct _RTL_AVL_TABLE *Table, - PVOID Buffer -); - -typedef struct _PUBLIC_BCB { - CSHORT NodeTypeCode; - CSHORT NodeByteSize; - ULONG MappedLength; - LARGE_INTEGER MappedFileOffset; -} PUBLIC_BCB, *PPUBLIC_BCB; - -typedef struct _QUERY_PATH_REQUEST { - ULONG PathNameLength; - PIO_SECURITY_CONTEXT SecurityContext; - WCHAR FilePathName[1]; -} QUERY_PATH_REQUEST, *PQUERY_PATH_REQUEST; - -typedef struct _QUERY_PATH_RESPONSE { - ULONG LengthAccepted; -} QUERY_PATH_RESPONSE, *PQUERY_PATH_RESPONSE; - -typedef struct _RTL_BALANCED_LINKS -{ - struct _RTL_BALANCED_LINKS *Parent; - struct _RTL_BALANCED_LINKS *LeftChild; - struct _RTL_BALANCED_LINKS *RightChild; - CHAR Balance; - UCHAR Reserved[3]; -} RTL_BALANCED_LINKS, *PRTL_BALANCED_LINKS; - -typedef struct _RTL_GENERIC_TABLE -{ - PRTL_SPLAY_LINKS TableRoot; - LIST_ENTRY InsertOrderList; - PLIST_ENTRY OrderedPointer; - ULONG WhichOrderedElement; - ULONG NumberGenericTableElements; - PRTL_GENERIC_COMPARE_ROUTINE CompareRoutine; - PRTL_GENERIC_ALLOCATE_ROUTINE AllocateRoutine; - PRTL_GENERIC_FREE_ROUTINE FreeRoutine; - PVOID TableContext; -} RTL_GENERIC_TABLE, *PRTL_GENERIC_TABLE; - -#undef PRTL_GENERIC_COMPARE_ROUTINE -#undef PRTL_GENERIC_ALLOCATE_ROUTINE -#undef PRTL_GENERIC_FREE_ROUTINE -#undef RTL_GENERIC_TABLE -#undef PRTL_GENERIC_TABLE - -#define PRTL_GENERIC_COMPARE_ROUTINE PRTL_AVL_COMPARE_ROUTINE -#define PRTL_GENERIC_ALLOCATE_ROUTINE PRTL_AVL_ALLOCATE_ROUTINE -#define PRTL_GENERIC_FREE_ROUTINE PRTL_AVL_FREE_ROUTINE -#define RTL_GENERIC_TABLE RTL_AVL_TABLE -#define PRTL_GENERIC_TABLE PRTL_AVL_TABLE - -#define RtlInitializeGenericTable RtlInitializeGenericTableAvl -#define RtlInsertElementGenericTable RtlInsertElementGenericTableAvl -#define RtlInsertElementGenericTableFull RtlInsertElementGenericTableFullAvl -#define RtlDeleteElementGenericTable RtlDeleteElementGenericTableAvl -#define RtlLookupElementGenericTable RtlLookupElementGenericTableAvl -#define RtlLookupElementGenericTableFull RtlLookupElementGenericTableFullAvl -#define RtlEnumerateGenericTable RtlEnumerateGenericTableAvl -#define RtlEnumerateGenericTableWithoutSplaying RtlEnumerateGenericTableWithoutSplayingAvl -#define RtlGetElementGenericTable RtlGetElementGenericTableAvl -#define RtlNumberGenericTableElements RtlNumberGenericTableElementsAvl -#define RtlIsGenericTableEmpty RtlIsGenericTableEmptyAvl - -typedef struct _RTL_AVL_TABLE -{ - RTL_BALANCED_LINKS BalancedRoot; - PVOID OrderedPointer; - ULONG WhichOrderedElement; - ULONG NumberGenericTableElements; - ULONG DepthOfTree; - PRTL_BALANCED_LINKS RestartKey; - ULONG DeleteCount; - PRTL_AVL_COMPARE_ROUTINE CompareRoutine; - PRTL_AVL_ALLOCATE_ROUTINE AllocateRoutine; - PRTL_AVL_FREE_ROUTINE FreeRoutine; - PVOID TableContext; -} RTL_AVL_TABLE, *PRTL_AVL_TABLE; - -NTSYSAPI -VOID -NTAPI -RtlInitializeGenericTableAvl( - PRTL_AVL_TABLE Table, - PRTL_AVL_COMPARE_ROUTINE CompareRoutine, - PRTL_AVL_ALLOCATE_ROUTINE AllocateRoutine, - PRTL_AVL_FREE_ROUTINE FreeRoutine, - PVOID TableContext -); - -NTSYSAPI -PVOID -NTAPI -RtlInsertElementGenericTableAvl ( - PRTL_AVL_TABLE Table, - PVOID Buffer, - CLONG BufferSize, - PBOOLEAN NewElement OPTIONAL - ); - -NTSYSAPI -BOOLEAN -NTAPI -RtlDeleteElementGenericTableAvl ( - PRTL_AVL_TABLE Table, - PVOID Buffer - ); - -NTSYSAPI -PVOID -NTAPI -RtlLookupElementGenericTableAvl ( - PRTL_AVL_TABLE Table, - PVOID Buffer - ); - -NTSYSAPI -PVOID -NTAPI -RtlEnumerateGenericTableWithoutSplayingAvl ( - PRTL_AVL_TABLE Table, - PVOID *RestartKey - ); - #if defined(USE_LPC6432) #define LPC_CLIENT_ID CLIENT_ID64 #define LPC_SIZE_T ULONGLONG @@ -7575,13 +9269,6 @@ typedef struct _REMOTE_PORT_VIEW LPC_PVOID ViewBase; } REMOTE_PORT_VIEW, *PREMOTE_PORT_VIEW; -typedef struct _TUNNEL { - FAST_MUTEX Mutex; - PRTL_SPLAY_LINKS Cache; - LIST_ENTRY TimerQueue; - USHORT NumEntries; -} TUNNEL, *PTUNNEL; - typedef struct _VAD_HEADER { PVOID StartVPN; PVOID EndVPN; @@ -7596,150 +9283,6 @@ typedef struct _VAD_HEADER { LIST_ENTRY Secured; } VAD_HEADER, *PVAD_HEADER; -#if (VER_PRODUCTBUILD >= 2600) - -typedef BOOLEAN -(NTAPI *PFILTER_REPORT_CHANGE) ( - IN PVOID NotifyContext, - IN PVOID FilterContext -); - -#endif - -NTKERNELAPI -BOOLEAN -NTAPI -CcCanIWrite ( - IN PFILE_OBJECT FileObject, - IN ULONG BytesToWrite, - IN BOOLEAN Wait, - IN BOOLEAN Retrying -); - -NTKERNELAPI -BOOLEAN -NTAPI -CcCopyRead ( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN BOOLEAN Wait, - OUT PVOID Buffer, - OUT PIO_STATUS_BLOCK IoStatus -); - -NTKERNELAPI -BOOLEAN -NTAPI -CcCopyWrite ( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN BOOLEAN Wait, - IN PVOID Buffer -); - -#define CcCopyWriteWontFlush(FO, FOFF, LEN) ((LEN) <= 0x10000) - -typedef VOID (NTAPI *PCC_POST_DEFERRED_WRITE) ( - IN PVOID Context1, - IN PVOID Context2 -); - -NTKERNELAPI -VOID -NTAPI -CcDeferWrite ( - IN PFILE_OBJECT FileObject, - IN PCC_POST_DEFERRED_WRITE PostRoutine, - IN PVOID Context1, - IN PVOID Context2, - IN ULONG BytesToWrite, - IN BOOLEAN Retrying -); - -NTKERNELAPI -VOID -NTAPI -CcFastCopyRead ( - IN PFILE_OBJECT FileObject, - IN ULONG FileOffset, - IN ULONG Length, - IN ULONG PageCount, - OUT PVOID Buffer, - OUT PIO_STATUS_BLOCK IoStatus -); - -NTKERNELAPI -VOID -NTAPI -CcFastCopyWrite ( - IN PFILE_OBJECT FileObject, - IN ULONG FileOffset, - IN ULONG Length, - IN PVOID Buffer -); - -NTKERNELAPI -VOID -NTAPI -CcFlushCache ( - IN PSECTION_OBJECT_POINTERS SectionObjectPointer, - IN PLARGE_INTEGER FileOffset OPTIONAL, - IN ULONG Length, - OUT PIO_STATUS_BLOCK IoStatus OPTIONAL -); - -typedef VOID (NTAPI *PDIRTY_PAGE_ROUTINE) ( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN PLARGE_INTEGER OldestLsn, - IN PLARGE_INTEGER NewestLsn, - IN PVOID Context1, - IN PVOID Context2 -); - -NTKERNELAPI -LARGE_INTEGER -NTAPI -CcGetDirtyPages ( - IN PVOID LogHandle, - IN PDIRTY_PAGE_ROUTINE DirtyPageRoutine, - IN PVOID Context1, - IN PVOID Context2 -); - -NTKERNELAPI -PFILE_OBJECT -NTAPI -CcGetFileObjectFromBcb ( - IN PVOID Bcb -); - -NTKERNELAPI -PFILE_OBJECT -NTAPI -CcGetFileObjectFromSectionPtrs ( - IN PSECTION_OBJECT_POINTERS SectionObjectPointer -); - -#define CcGetFileSizePointer(FO) ( \ - ((PLARGE_INTEGER)((FO)->SectionObjectPointer->SharedCacheMap) + 1) \ -) - -#if (VER_PRODUCTBUILD >= 2195) - -NTKERNELAPI -LARGE_INTEGER -NTAPI -CcGetFlushedValidData ( - IN PSECTION_OBJECT_POINTERS SectionObjectPointer, - IN BOOLEAN BcbListHeld -); - -#endif /* (VER_PRODUCTBUILD >= 2195) */ - NTKERNELAPI LARGE_INTEGER NTAPI @@ -7748,428 +9291,6 @@ CcGetLsnForFileObject ( OUT PLARGE_INTEGER OldestLsn OPTIONAL ); -typedef BOOLEAN (NTAPI *PACQUIRE_FOR_LAZY_WRITE) ( - IN PVOID Context, - IN BOOLEAN Wait -); - -typedef VOID (NTAPI *PRELEASE_FROM_LAZY_WRITE) ( - IN PVOID Context -); - -typedef BOOLEAN (NTAPI *PACQUIRE_FOR_READ_AHEAD) ( - IN PVOID Context, - IN BOOLEAN Wait -); - -typedef VOID (NTAPI *PRELEASE_FROM_READ_AHEAD) ( - IN PVOID Context -); - -typedef struct _CACHE_MANAGER_CALLBACKS { - PACQUIRE_FOR_LAZY_WRITE AcquireForLazyWrite; - PRELEASE_FROM_LAZY_WRITE ReleaseFromLazyWrite; - PACQUIRE_FOR_READ_AHEAD AcquireForReadAhead; - PRELEASE_FROM_READ_AHEAD ReleaseFromReadAhead; -} CACHE_MANAGER_CALLBACKS, *PCACHE_MANAGER_CALLBACKS; - -NTKERNELAPI -VOID -NTAPI -CcInitializeCacheMap ( - IN PFILE_OBJECT FileObject, - IN PCC_FILE_SIZES FileSizes, - IN BOOLEAN PinAccess, - IN PCACHE_MANAGER_CALLBACKS Callbacks, - IN PVOID LazyWriteContext -); - -#define CcIsFileCached(FO) ( \ - ((FO)->SectionObjectPointer != NULL) && \ - (((PSECTION_OBJECT_POINTERS)(FO)->SectionObjectPointer)->SharedCacheMap != NULL) \ -) - -extern ULONG CcFastMdlReadWait; - -NTKERNELAPI -BOOLEAN -NTAPI -CcIsThereDirtyData ( - IN PVPB Vpb -); - -NTKERNELAPI -BOOLEAN -NTAPI -CcMapData ( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN ULONG Flags, - OUT PVOID *Bcb, - OUT PVOID *Buffer -); - -NTKERNELAPI -VOID -NTAPI -CcMdlRead ( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - OUT PMDL *MdlChain, - OUT PIO_STATUS_BLOCK IoStatus -); - -NTKERNELAPI -VOID -NTAPI -CcMdlReadComplete ( - IN PFILE_OBJECT FileObject, - IN PMDL MdlChain -); - -NTKERNELAPI -VOID -NTAPI -CcMdlWriteComplete ( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN PMDL MdlChain -); - -#define MAP_WAIT 1 - -NTKERNELAPI -BOOLEAN -NTAPI -CcPinMappedData ( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN ULONG Flags, - IN OUT PVOID *Bcb -); - -NTKERNELAPI -BOOLEAN -NTAPI -CcPinRead ( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN ULONG Flags, - OUT PVOID *Bcb, - OUT PVOID *Buffer -); - -NTKERNELAPI -VOID -NTAPI -CcPrepareMdlWrite ( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - OUT PMDL *MdlChain, - OUT PIO_STATUS_BLOCK IoStatus -); - -NTKERNELAPI -BOOLEAN -NTAPI -CcPreparePinWrite ( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length, - IN BOOLEAN Zero, - IN ULONG Flags, - OUT PVOID *Bcb, - OUT PVOID *Buffer -); - -NTKERNELAPI -BOOLEAN -NTAPI -CcPurgeCacheSection ( - IN PSECTION_OBJECT_POINTERS SectionObjectPointer, - IN PLARGE_INTEGER FileOffset OPTIONAL, - IN ULONG Length, - IN BOOLEAN UninitializeCacheMaps -); - -#define CcReadAhead(FO, FOFF, LEN) ( \ - if ((LEN) >= 256) { \ - CcScheduleReadAhead((FO), (FOFF), (LEN)); \ - } \ -) - -#if (VER_PRODUCTBUILD >= 2195) - -NTKERNELAPI -PVOID -NTAPI -CcRemapBcb ( - IN PVOID Bcb -); - -#endif /* (VER_PRODUCTBUILD >= 2195) */ - -NTKERNELAPI -VOID -NTAPI -CcRepinBcb ( - IN PVOID Bcb -); - -NTKERNELAPI -VOID -NTAPI -CcScheduleReadAhead ( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER FileOffset, - IN ULONG Length -); - -NTKERNELAPI -VOID -NTAPI -CcSetAdditionalCacheAttributes ( - IN PFILE_OBJECT FileObject, - IN BOOLEAN DisableReadAhead, - IN BOOLEAN DisableWriteBehind -); - -NTKERNELAPI -VOID -NTAPI -CcSetBcbOwnerPointer ( - IN PVOID Bcb, - IN PVOID OwnerPointer -); - -NTKERNELAPI -VOID -NTAPI -CcSetDirtyPageThreshold ( - IN PFILE_OBJECT FileObject, - IN ULONG DirtyPageThreshold -); - -NTKERNELAPI -VOID -NTAPI -CcSetDirtyPinnedData ( - IN PVOID BcbVoid, - IN PLARGE_INTEGER Lsn OPTIONAL -); - -NTKERNELAPI -VOID -NTAPI -CcSetFileSizes ( - IN PFILE_OBJECT FileObject, - IN PCC_FILE_SIZES FileSizes -); - -typedef VOID (NTAPI *PFLUSH_TO_LSN) ( - IN PVOID LogHandle, - IN LARGE_INTEGER Lsn -); - -NTKERNELAPI -VOID -NTAPI -CcSetLogHandleForFile ( - IN PFILE_OBJECT FileObject, - IN PVOID LogHandle, - IN PFLUSH_TO_LSN FlushToLsnRoutine -); - -NTKERNELAPI -VOID -NTAPI -CcSetReadAheadGranularity ( - IN PFILE_OBJECT FileObject, - IN ULONG Granularity /* default: PAGE_SIZE */ - /* allowed: 2^n * PAGE_SIZE */ -); - -NTKERNELAPI -BOOLEAN -NTAPI -CcUninitializeCacheMap ( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER TruncateSize OPTIONAL, - IN PCACHE_UNINITIALIZE_EVENT UninitializeCompleteEvent OPTIONAL -); - -NTKERNELAPI -VOID -NTAPI -CcUnpinData ( - IN PVOID Bcb -); - -NTKERNELAPI -VOID -NTAPI -CcUnpinDataForThread ( - IN PVOID Bcb, - IN ERESOURCE_THREAD ResourceThreadId -); - -NTKERNELAPI -VOID -NTAPI -CcUnpinRepinnedBcb ( - IN PVOID Bcb, - IN BOOLEAN WriteThrough, - OUT PIO_STATUS_BLOCK IoStatus -); - -#if (VER_PRODUCTBUILD >= 2195) - -NTKERNELAPI -NTSTATUS -NTAPI -CcWaitForCurrentLazyWriterActivity ( - VOID -); - -#endif /* (VER_PRODUCTBUILD >= 2195) */ - -NTKERNELAPI -BOOLEAN -NTAPI -CcZeroData ( - IN PFILE_OBJECT FileObject, - IN PLARGE_INTEGER StartOffset, - IN PLARGE_INTEGER EndOffset, - IN BOOLEAN Wait -); - -#if (VER_PRODUCTBUILD >= 2600) - -#ifndef __NTOSKRNL__ -NTKERNELAPI -VOID -FASTCALL -ExInitializeRundownProtection ( - IN PEX_RUNDOWN_REF RunRef -); - -NTKERNELAPI -VOID -FASTCALL -ExReInitializeRundownProtection ( - IN PEX_RUNDOWN_REF RunRef -); - -NTKERNELAPI -BOOLEAN -FASTCALL -ExAcquireRundownProtection ( - IN PEX_RUNDOWN_REF RunRef -); - -NTKERNELAPI -BOOLEAN -FASTCALL -ExAcquireRundownProtectionEx ( - IN PEX_RUNDOWN_REF RunRef, - IN ULONG Count -); - -NTKERNELAPI -VOID -FASTCALL -ExReleaseRundownProtection ( - IN PEX_RUNDOWN_REF RunRef -); - -NTKERNELAPI -VOID -FASTCALL -ExReleaseRundownProtectionEx ( - IN PEX_RUNDOWN_REF RunRef, - IN ULONG Count -); - -NTKERNELAPI -VOID -FASTCALL -ExRundownCompleted ( - IN PEX_RUNDOWN_REF RunRef -); - -NTKERNELAPI -VOID -FASTCALL -ExWaitForRundownProtectionRelease ( - IN PEX_RUNDOWN_REF RunRef -); - -#endif -#endif /* (VER_PRODUCTBUILD >= 2600) */ - - -#define FsRtlSetupAdvancedHeader( _advhdr, _fmutx ) \ -{ \ - SetFlag( (_advhdr)->Flags, FSRTL_FLAG_ADVANCED_HEADER ); \ - SetFlag( (_advhdr)->Flags2, FSRTL_FLAG2_SUPPORTS_FILTER_CONTEXTS ); \ - (_advhdr)->Version = FSRTL_FCB_HEADER_V1; \ - InitializeListHead( &(_advhdr)->FilterContexts ); \ - if ((_fmutx) != NULL) { \ - (_advhdr)->FastMutex = (_fmutx); \ - } \ - *((PULONG_PTR)(&(_advhdr)->PushLock)) = 0; \ - /*ExInitializePushLock( &(_advhdr)->PushLock ); API Not avaliable downlevel*/\ - (_advhdr)->FileContextSupportPointer = NULL; \ -} - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlAddBaseMcbEntry ( - IN PBASE_MCB Mcb, - IN LONGLONG Vbn, - IN LONGLONG Lbn, - IN LONGLONG SectorCount -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlAddLargeMcbEntry ( - IN PLARGE_MCB Mcb, - IN LONGLONG Vbn, - IN LONGLONG Lbn, - IN LONGLONG SectorCount -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlAddMcbEntry ( - IN PMCB Mcb, - IN VBN Vbn, - IN LBN Lbn, - IN ULONG SectorCount -); - -NTKERNELAPI -VOID -NTAPI -FsRtlAddToTunnelCache ( - IN PTUNNEL Cache, - IN ULONGLONG DirectoryKey, - IN PUNICODE_STRING ShortName, - IN PUNICODE_STRING LongName, - IN BOOLEAN KeyByShortName, - IN ULONG DataLength, - IN PVOID Data -); - NTKERNELAPI PVOID NTAPI @@ -8204,251 +9325,6 @@ FsRtlAllocatePoolWithTag ( IN ULONG Tag ); -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlAreNamesEqual ( - IN PCUNICODE_STRING Name1, - IN PCUNICODE_STRING Name2, - IN BOOLEAN IgnoreCase, - IN PCWCH UpcaseTable OPTIONAL -); - -#define FsRtlAreThereCurrentFileLocks(FL) ( \ - ((FL)->FastIoIsQuestionable) \ -) - -typedef -VOID -(NTAPI*POPLOCK_WAIT_COMPLETE_ROUTINE) ( - IN PVOID Context, - IN PIRP Irp -); - -typedef -VOID -(NTAPI*POPLOCK_FS_PREPOST_IRP) ( - IN PVOID Context, - IN PIRP Irp -); - -NTKERNELAPI -NTSTATUS -NTAPI -FsRtlCheckOplock ( - IN POPLOCK Oplock, - IN PIRP Irp, - IN PVOID Context, - IN POPLOCK_WAIT_COMPLETE_ROUTINE CompletionRoutine OPTIONAL, - IN POPLOCK_FS_PREPOST_IRP PostIrpRoutine OPTIONAL -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlCurrentBatchOplock ( - IN POPLOCK Oplock -); - -NTKERNELAPI -VOID -NTAPI -FsRtlDeleteKeyFromTunnelCache ( - IN PTUNNEL Cache, - IN ULONGLONG DirectoryKey -); - -NTKERNELAPI -VOID -NTAPI -FsRtlDeleteTunnelCache ( - IN PTUNNEL Cache -); - -NTKERNELAPI -VOID -NTAPI -FsRtlDeregisterUncProvider ( - IN HANDLE Handle -); - -NTKERNELAPI -VOID -NTAPI -FsRtlDissectDbcs ( - IN ANSI_STRING Name, - OUT PANSI_STRING FirstPart, - OUT PANSI_STRING RemainingPart -); - -NTKERNELAPI -VOID -NTAPI -FsRtlDissectName ( - IN UNICODE_STRING Name, - OUT PUNICODE_STRING FirstPart, - OUT PUNICODE_STRING RemainingPart -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlDoesDbcsContainWildCards ( - IN PANSI_STRING Name -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlDoesNameContainWildCards ( - IN PUNICODE_STRING Name -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlIsFatDbcsLegal ( - IN ANSI_STRING DbcsName, - IN BOOLEAN WildCardsPermissible, - IN BOOLEAN PathNamePermissible, - IN BOOLEAN LeadingBackslashPermissible - ); - - -#define FsRtlCompleteRequest(IRP,STATUS) { \ - (IRP)->IoStatus.Status = (STATUS); \ - IoCompleteRequest( (IRP), IO_DISK_INCREMENT ); \ -} - -#define FsRtlEnterFileSystem KeEnterCriticalRegion - -#define FsRtlExitFileSystem KeLeaveCriticalRegion - -#define FsRtlFastLock(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11) ( \ - FsRtlPrivateLock(A1, A2, A3, A4, A5, A6, A7, A8, A9, NULL, A10, A11) \ -) - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlFindInTunnelCache ( - IN PTUNNEL Cache, - IN ULONGLONG DirectoryKey, - IN PUNICODE_STRING Name, - OUT PUNICODE_STRING ShortName, - OUT PUNICODE_STRING LongName, - IN OUT PULONG DataLength, - OUT PVOID Data -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlGetNextBaseMcbEntry ( - IN PBASE_MCB Mcb, - IN ULONG RunIndex, - OUT PLONGLONG Vbn, - OUT PLONGLONG Lbn, - OUT PLONGLONG SectorCount -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlGetNextLargeMcbEntry ( - IN PLARGE_MCB Mcb, - IN ULONG RunIndex, - OUT PLONGLONG Vbn, - OUT PLONGLONG Lbn, - OUT PLONGLONG SectorCount -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlGetNextMcbEntry ( - IN PMCB Mcb, - IN ULONG RunIndex, - OUT PVBN Vbn, - OUT PLBN Lbn, - OUT PULONG SectorCount -); - -#define FsRtlGetPerStreamContextPointer(FO) ( \ - (PFSRTL_ADVANCED_FCB_HEADER)(FO)->FsContext \ -) - -NTKERNELAPI -VOID -NTAPI -FsRtlInitializeBaseMcb ( - IN PBASE_MCB Mcb, - IN POOL_TYPE PoolType -); - -NTKERNELAPI -VOID -NTAPI -FsRtlInitializeLargeMcb ( - IN PLARGE_MCB Mcb, - IN POOL_TYPE PoolType -); - -NTKERNELAPI -VOID -NTAPI -FsRtlInitializeMcb ( - IN PMCB Mcb, - IN POOL_TYPE PoolType -); - -NTKERNELAPI -VOID -NTAPI -FsRtlInitializeOplock ( - IN OUT POPLOCK Oplock -); - -NTKERNELAPI -VOID -NTAPI -FsRtlInitializeTunnelCache ( - IN PTUNNEL Cache -); - -#define FsRtlInitPerStreamContext(PSC, O, I, FC) ( \ - (PSC)->OwnerId = (O), \ - (PSC)->InstanceId = (I), \ - (PSC)->FreeCallback = (FC) \ -) - -NTKERNELAPI -NTSTATUS -NTAPI -FsRtlInsertPerStreamContext ( - IN PFSRTL_ADVANCED_FCB_HEADER PerStreamContext, - IN PFSRTL_PER_STREAM_CONTEXT Ptr -); - -#define FsRtlIsAnsiCharacterLegalFat(C, WILD) ( \ - FlagOn(FsRtlLegalAnsiCharacterArray[(UCHAR)(C)], (FSRTL_FAT_LEGAL) | \ - ((WILD) ? FSRTL_WILD_CHARACTER : 0 )) \ -) - -#define FsRtlIsAnsiCharacterLegalHpfs(C, WILD) ( \ - FlagOn(FsRtlLegalAnsiCharacterArray[(UCHAR)(C)], (FSRTL_HPFS_LEGAL) | \ - ((WILD) ? FSRTL_WILD_CHARACTER : 0 )) \ -) - -#define FsRtlIsAnsiCharacterLegalNtfs(C, WILD) ( \ - FlagOn(FsRtlLegalAnsiCharacterArray[(UCHAR)(C)], (FSRTL_NTFS_LEGAL) | \ - ((WILD) ? FSRTL_WILD_CHARACTER : 0 )) \ -) - -#define FsRtlIsAnsiCharacterWild(C) ( \ - FlagOn(FsRtlLegalAnsiCharacterArray[(UCHAR)(C)], FSRTL_WILD_CHARACTER ) \ -) - NTKERNELAPI BOOLEAN NTAPI @@ -8459,142 +9335,6 @@ FsRtlIsFatDbcsLegal ( IN BOOLEAN LeadingBackslashPermissible ); -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlIsHpfsDbcsLegal ( - IN ANSI_STRING DbcsName, - IN BOOLEAN WildCardsPermissible, - IN BOOLEAN PathNamePermissible, - IN BOOLEAN LeadingBackslashPermissible -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlIsNameInExpression ( - IN PUNICODE_STRING Expression, - IN PUNICODE_STRING Name, - IN BOOLEAN IgnoreCase, - IN PWCHAR UpcaseTable OPTIONAL -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlIsNtstatusExpected ( - IN NTSTATUS Ntstatus -); - -#define NLS_OEM_LEAD_BYTE_INFO NlsOemLeadByteInfo - -extern PUSHORT NlsOemLeadByteInfo; - -#define FsRtlIsLeadDbcsCharacter(DBCS_CHAR) ( \ - (BOOLEAN)((UCHAR)(DBCS_CHAR) < 0x80 ? FALSE : \ - (NLS_MB_CODE_PAGE_TAG && \ - (NLS_OEM_LEAD_BYTE_INFO[(UCHAR)(DBCS_CHAR)] != 0))) \ -) - -#define FsRtlIsUnicodeCharacterWild(C) ( \ - (((C) >= 0x40) ? \ - FALSE : \ - FlagOn(FsRtlLegalAnsiCharacterArray[(C)], FSRTL_WILD_CHARACTER )) \ -) - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlLookupBaseMcbEntry ( - IN PBASE_MCB Mcb, - IN LONGLONG Vbn, - OUT PLONGLONG Lbn OPTIONAL, - OUT PLONGLONG SectorCountFromLbn OPTIONAL, - OUT PLONGLONG StartingLbn OPTIONAL, - OUT PLONGLONG SectorCountFromStartingLbn OPTIONAL, - OUT PULONG Index OPTIONAL -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlLookupLargeMcbEntry ( - IN PLARGE_MCB Mcb, - IN LONGLONG Vbn, - OUT PLONGLONG Lbn OPTIONAL, - OUT PLONGLONG SectorCountFromLbn OPTIONAL, - OUT PLONGLONG StartingLbn OPTIONAL, - OUT PLONGLONG SectorCountFromStartingLbn OPTIONAL, - OUT PULONG Index OPTIONAL -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlLookupLastBaseMcbEntry ( - IN PBASE_MCB Mcb, - OUT PLONGLONG Vbn, - OUT PLONGLONG Lbn -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlLookupLastLargeMcbEntry ( - IN PLARGE_MCB Mcb, - OUT PLONGLONG Vbn, - OUT PLONGLONG Lbn -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlLookupLastMcbEntry ( - IN PMCB Mcb, - OUT PVBN Vbn, - OUT PLBN Lbn -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlLookupLastBaseMcbEntryAndIndex ( - IN PBASE_MCB OpaqueMcb, - IN OUT PLONGLONG LargeVbn, - IN OUT PLONGLONG LargeLbn, - IN OUT PULONG Index -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlLookupLastLargeMcbEntryAndIndex ( - IN PLARGE_MCB OpaqueMcb, - OUT PLONGLONG LargeVbn, - OUT PLONGLONG LargeLbn, - OUT PULONG Index -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlLookupMcbEntry ( - IN PMCB Mcb, - IN VBN Vbn, - OUT PLBN Lbn, - OUT PULONG SectorCount OPTIONAL, - OUT PULONG Index -); - -NTKERNELAPI -PFSRTL_PER_STREAM_CONTEXT -NTAPI -FsRtlLookupPerStreamContextInternal ( - IN PFSRTL_ADVANCED_FCB_HEADER StreamContext, - IN PVOID OwnerId OPTIONAL, - IN PVOID InstanceId OPTIONAL -); - NTKERNELAPI BOOLEAN NTAPI @@ -8612,14 +9352,6 @@ FsRtlMdlWriteComplete ( IN PMDL MdlChain ); -NTKERNELAPI -NTSTATUS -NTAPI -FsRtlNormalizeNtstatus ( - IN NTSTATUS Exception, - IN NTSTATUS GenericException -); - NTKERNELAPI VOID NTAPI @@ -8633,306 +9365,6 @@ FsRtlNotifyChangeDirectory ( IN PIRP NotifyIrp ); -NTKERNELAPI -VOID -NTAPI -FsRtlNotifyCleanup ( - IN PNOTIFY_SYNC NotifySync, - IN PLIST_ENTRY NotifyList, - IN PVOID FsContext -); - -typedef BOOLEAN (NTAPI *PCHECK_FOR_TRAVERSE_ACCESS) ( - IN PVOID NotifyContext, - IN PVOID TargetContext, - IN PSECURITY_SUBJECT_CONTEXT SubjectContext -); - -NTKERNELAPI -VOID -NTAPI -FsRtlNotifyFilterChangeDirectory ( - IN PNOTIFY_SYNC NotifySync, - IN PLIST_ENTRY NotifyList, - IN PVOID FsContext, - IN PSTRING FullDirectoryName, - IN BOOLEAN WatchTree, - IN BOOLEAN IgnoreBuffer, - IN ULONG CompletionFilter, - IN PIRP NotifyIrp, - IN PCHECK_FOR_TRAVERSE_ACCESS TraverseCallback OPTIONAL, - IN PSECURITY_SUBJECT_CONTEXT SubjectContext OPTIONAL, - IN PFILTER_REPORT_CHANGE FilterCallback OPTIONAL); - -NTKERNELAPI -VOID -NTAPI -FsRtlNotifyFilterReportChange ( - IN PNOTIFY_SYNC NotifySync, - IN PLIST_ENTRY NotifyList, - IN PSTRING FullTargetName, - IN USHORT TargetNameOffset, - IN PSTRING StreamName OPTIONAL, - IN PSTRING NormalizedParentName OPTIONAL, - IN ULONG FilterMatch, - IN ULONG Action, - IN PVOID TargetContext, - IN PVOID FilterContext); - -NTKERNELAPI -VOID -NTAPI -FsRtlNotifyFullChangeDirectory ( - IN PNOTIFY_SYNC NotifySync, - IN PLIST_ENTRY NotifyList, - IN PVOID FsContext, - IN PSTRING FullDirectoryName, - IN BOOLEAN WatchTree, - IN BOOLEAN IgnoreBuffer, - IN ULONG CompletionFilter, - IN PIRP NotifyIrp, - IN PCHECK_FOR_TRAVERSE_ACCESS TraverseCallback OPTIONAL, - IN PSECURITY_SUBJECT_CONTEXT SubjectContext OPTIONAL -); - -NTKERNELAPI -VOID -NTAPI -FsRtlNotifyFullReportChange ( - IN PNOTIFY_SYNC NotifySync, - IN PLIST_ENTRY NotifyList, - IN PSTRING FullTargetName, - IN USHORT TargetNameOffset, - IN PSTRING StreamName OPTIONAL, - IN PSTRING NormalizedParentName OPTIONAL, - IN ULONG FilterMatch, - IN ULONG Action, - IN PVOID TargetContext -); - -NTKERNELAPI -VOID -NTAPI -FsRtlNotifyInitializeSync ( - IN PNOTIFY_SYNC *NotifySync -); - -NTKERNELAPI -VOID -NTAPI -FsRtlNotifyUninitializeSync ( - IN PNOTIFY_SYNC *NotifySync -); - -#if (VER_PRODUCTBUILD >= 2195) - -NTKERNELAPI -NTSTATUS -NTAPI -FsRtlNotifyVolumeEvent ( - IN PFILE_OBJECT FileObject, - IN ULONG EventCode -); - -#endif /* (VER_PRODUCTBUILD >= 2195) */ - -NTKERNELAPI -ULONG -NTAPI -FsRtlNumberOfRunsInBaseMcb ( - IN PBASE_MCB Mcb -); - -NTKERNELAPI -ULONG -NTAPI -FsRtlNumberOfRunsInLargeMcb ( - IN PLARGE_MCB Mcb -); - -NTKERNELAPI -ULONG -NTAPI -FsRtlNumberOfRunsInMcb ( - IN PMCB Mcb -); - -NTKERNELAPI -NTSTATUS -NTAPI -FsRtlOplockFsctrl ( - IN POPLOCK Oplock, - IN PIRP Irp, - IN ULONG OpenCount -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlOplockIsFastIoPossible ( - IN POPLOCK Oplock -); - -typedef VOID -(NTAPI *PFSRTL_STACK_OVERFLOW_ROUTINE) ( - IN PVOID Context, - IN PKEVENT Event -); - -NTKERNELAPI -VOID -NTAPI -FsRtlPostPagingFileStackOverflow ( - IN PVOID Context, - IN PKEVENT Event, - IN PFSRTL_STACK_OVERFLOW_ROUTINE StackOverflowRoutine -); - -NTKERNELAPI -VOID -NTAPI -FsRtlPostStackOverflow ( - IN PVOID Context, - IN PKEVENT Event, - IN PFSRTL_STACK_OVERFLOW_ROUTINE StackOverflowRoutine -); - -NTKERNELAPI -NTSTATUS -NTAPI -FsRtlRegisterUncProvider ( - IN OUT PHANDLE MupHandle, - IN PUNICODE_STRING RedirectorDeviceName, - IN BOOLEAN MailslotsSupported -); - -NTKERNELAPI -VOID -NTAPI -FsRtlRemoveBaseMcbEntry ( - IN PBASE_MCB Mcb, - IN LONGLONG Vbn, - IN LONGLONG SectorCount -); - -NTKERNELAPI -VOID -NTAPI -FsRtlRemoveLargeMcbEntry ( - IN PLARGE_MCB Mcb, - IN LONGLONG Vbn, - IN LONGLONG SectorCount -); - -NTKERNELAPI -VOID -NTAPI -FsRtlRemoveMcbEntry ( - IN PMCB Mcb, - IN VBN Vbn, - IN ULONG SectorCount -); - -NTKERNELAPI -PFSRTL_PER_STREAM_CONTEXT -NTAPI -FsRtlRemovePerStreamContext ( - IN PFSRTL_ADVANCED_FCB_HEADER StreamContext, - IN PVOID OwnerId OPTIONAL, - IN PVOID InstanceId OPTIONAL -); - -NTKERNELAPI -VOID -NTAPI -FsRtlResetBaseMcb ( - IN PBASE_MCB Mcb -); - -NTKERNELAPI -VOID -NTAPI -FsRtlResetLargeMcb ( - IN PLARGE_MCB Mcb, - IN BOOLEAN SelfSynchronized -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlSplitBaseMcb ( - IN PBASE_MCB Mcb, - IN LONGLONG Vbn, - IN LONGLONG Amount -); - -NTKERNELAPI -BOOLEAN -NTAPI -FsRtlSplitLargeMcb ( - IN PLARGE_MCB Mcb, - IN LONGLONG Vbn, - IN LONGLONG Amount -); - -#define FsRtlSupportsPerStreamContexts(FO) ( \ - (BOOLEAN)((NULL != FsRtlGetPerStreamContextPointer(FO) && \ - FlagOn(FsRtlGetPerStreamContextPointer(FO)->Flags2, \ - FSRTL_FLAG2_SUPPORTS_FILTER_CONTEXTS)) \ -) - -NTKERNELAPI -VOID -NTAPI -FsRtlTruncateBaseMcb ( - IN PBASE_MCB Mcb, - IN LONGLONG Vbn -); - -NTKERNELAPI -VOID -NTAPI -FsRtlTruncateLargeMcb ( - IN PLARGE_MCB Mcb, - IN LONGLONG Vbn -); - -NTKERNELAPI -VOID -NTAPI -FsRtlTruncateMcb ( - IN PMCB Mcb, - IN VBN Vbn -); - -NTKERNELAPI -VOID -NTAPI -FsRtlUninitializeBaseMcb ( - IN PBASE_MCB Mcb -); - -NTKERNELAPI -VOID -NTAPI -FsRtlUninitializeLargeMcb ( - IN PLARGE_MCB Mcb -); - -NTKERNELAPI -VOID -NTAPI -FsRtlUninitializeMcb ( - IN PMCB Mcb -); - -NTKERNELAPI -VOID -NTAPI -FsRtlUninitializeOplock ( - IN OUT POPLOCK Oplock -); - NTKERNELAPI NTSTATUS NTAPI @@ -8969,23 +9401,6 @@ ObReferenceObjectByName ( OUT PVOID *Object ); -#if (NTDDI_VERSION >= NTDDI_WIN2K) - -NTKERNELAPI -NTSTATUS -NTAPI -PsAssignImpersonationToken( - IN PETHREAD Thread, - IN HANDLE Token OPTIONAL); - -NTKERNELAPI -HANDLE -NTAPI -PsReferencePrimaryToken( - IN OUT PEPROCESS Process); - -#endif - #define PsDereferenceImpersonationToken(T) \ {if (ARGUMENT_PRESENT(T)) { \ (ObDereferenceObject((T))); \ @@ -9003,14 +9418,6 @@ PsLookupProcessThreadByCid ( OUT PETHREAD *Thread ); -NTSYSAPI -VOID -NTAPI -RtlSecondsSince1970ToTime ( - IN ULONG SecondsSince1970, - OUT PLARGE_INTEGER Time -); - NTSYSAPI NTSTATUS NTAPI @@ -9021,105 +9428,6 @@ RtlSetSaclSecurityDescriptor ( IN BOOLEAN SaclDefaulted ); -NTSYSAPI -NTSTATUS -NTAPI -RtlUnicodeStringToCountedOemString ( - IN OUT POEM_STRING DestinationString, - IN PCUNICODE_STRING SourceString, - IN BOOLEAN AllocateDestinationString -); - -/* RTL Splay Tree Functions */ -NTSYSAPI -PRTL_SPLAY_LINKS -NTAPI -RtlSplay(PRTL_SPLAY_LINKS Links); - -NTSYSAPI -PRTL_SPLAY_LINKS -NTAPI -RtlDelete(PRTL_SPLAY_LINKS Links); - -NTSYSAPI -VOID -NTAPI -RtlDeleteNoSplay( - PRTL_SPLAY_LINKS Links, - PRTL_SPLAY_LINKS *Root -); - -NTSYSAPI -PRTL_SPLAY_LINKS -NTAPI -RtlSubtreeSuccessor(PRTL_SPLAY_LINKS Links); - -NTSYSAPI -PRTL_SPLAY_LINKS -NTAPI -RtlSubtreePredecessor(PRTL_SPLAY_LINKS Links); - -NTSYSAPI -PRTL_SPLAY_LINKS -NTAPI -RtlRealSuccessor(PRTL_SPLAY_LINKS Links); - -NTSYSAPI -PRTL_SPLAY_LINKS -NTAPI -RtlRealPredecessor(PRTL_SPLAY_LINKS Links); - -#define RtlIsLeftChild(Links) \ - (RtlLeftChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links)) - -#define RtlIsRightChild(Links) \ - (RtlRightChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links)) - -#define RtlRightChild(Links) \ - ((PRTL_SPLAY_LINKS)(Links))->RightChild - -#define RtlIsRoot(Links) \ - (RtlParent(Links) == (PRTL_SPLAY_LINKS)(Links)) - -#define RtlLeftChild(Links) \ - ((PRTL_SPLAY_LINKS)(Links))->LeftChild - -#define RtlParent(Links) \ - ((PRTL_SPLAY_LINKS)(Links))->Parent - -#define RtlInitializeSplayLinks(Links) \ - { \ - PRTL_SPLAY_LINKS _SplayLinks; \ - _SplayLinks = (PRTL_SPLAY_LINKS)(Links); \ - _SplayLinks->Parent = _SplayLinks; \ - _SplayLinks->LeftChild = NULL; \ - _SplayLinks->RightChild = NULL; \ - } - -#define RtlInsertAsLeftChild(ParentLinks,ChildLinks) \ - { \ - PRTL_SPLAY_LINKS _SplayParent; \ - PRTL_SPLAY_LINKS _SplayChild; \ - _SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \ - _SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks); \ - _SplayParent->LeftChild = _SplayChild; \ - _SplayChild->Parent = _SplayParent; \ - } - -#define RtlInsertAsRightChild(ParentLinks,ChildLinks) \ - { \ - PRTL_SPLAY_LINKS _SplayParent; \ - PRTL_SPLAY_LINKS _SplayChild; \ - _SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \ - _SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks); \ - _SplayParent->RightChild = _SplayChild; \ - _SplayChild->Parent = _SplayParent; \ - } - -// -// RTL time functions -// - #define SeEnableAccessToExports() SeExports = *(PSE_EXPORTS *)SeExports; #if (VER_PRODUCTBUILD >= 2195) @@ -9145,18 +9453,6 @@ ZwAlertThread ( IN HANDLE ThreadHandle ); -NTSYSAPI -NTSTATUS -NTAPI -ZwAllocateVirtualMemory ( - IN HANDLE ProcessHandle, - IN OUT PVOID *BaseAddress, - IN ULONG_PTR ZeroBits, - IN OUT PSIZE_T RegionSize, - IN ULONG AllocationType, - IN ULONG Protect -); - NTSYSAPI NTSTATUS NTAPI @@ -9202,19 +9498,6 @@ ZwCloseObjectAuditAlarm ( IN BOOLEAN GenerateOnClose ); -NTSYSAPI -NTSTATUS -NTAPI -ZwCreateSection ( - OUT PHANDLE SectionHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, - IN PLARGE_INTEGER MaximumSize OPTIONAL, - IN ULONG SectionPageProtection, - IN ULONG AllocationAttributes, - IN HANDLE FileHandle OPTIONAL -); - NTSYSAPI NTSTATUS NTAPI @@ -9225,71 +9508,6 @@ ZwCreateSymbolicLinkObject ( IN PUNICODE_STRING TargetName ); -NTSYSAPI -NTSTATUS -NTAPI -ZwDeleteFile ( - IN POBJECT_ATTRIBUTES ObjectAttributes -); - -NTSYSAPI -NTSTATUS -NTAPI -ZwDeleteValueKey ( - IN HANDLE Handle, - IN PUNICODE_STRING Name -); - - -#if (NTDDI_VERSION >= NTDDI_WIN2K) -NTSYSAPI -NTSTATUS -NTAPI -ZwDeviceIoControlFile ( - IN HANDLE FileHandle, - IN HANDLE Event OPTIONAL, - IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, - IN PVOID ApcContext OPTIONAL, - OUT PIO_STATUS_BLOCK IoStatusBlock, - IN ULONG IoControlCode, - IN PVOID InputBuffer OPTIONAL, - IN ULONG InputBufferLength, - OUT PVOID OutputBuffer OPTIONAL, - IN ULONG OutputBufferLength); -#endif - -NTSYSAPI -NTSTATUS -NTAPI -ZwDisplayString ( - IN PUNICODE_STRING String -); - -NTSYSAPI -NTSTATUS -NTAPI -ZwDuplicateObject ( - IN HANDLE SourceProcessHandle, - IN HANDLE SourceHandle, - IN HANDLE TargetProcessHandle OPTIONAL, - OUT PHANDLE TargetHandle OPTIONAL, - IN ACCESS_MASK DesiredAccess, - IN ULONG HandleAttributes, - IN ULONG Options -); - -NTSYSAPI -NTSTATUS -NTAPI -ZwDuplicateToken ( - IN HANDLE ExistingTokenHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes, - IN BOOLEAN EffectiveOnly, - IN TOKEN_TYPE TokenType, - OUT PHANDLE NewTokenHandle -); - NTSYSAPI NTSTATUS NTAPI @@ -9309,46 +9527,6 @@ ZwFlushBuffersFile( #if (VER_PRODUCTBUILD >= 2195) -NTSYSAPI -NTSTATUS -NTAPI -ZwFlushVirtualMemory ( - IN HANDLE ProcessHandle, - IN OUT PVOID *BaseAddress, - IN OUT PULONG FlushSize, - OUT PIO_STATUS_BLOCK IoStatusBlock -); - -#endif /* (VER_PRODUCTBUILD >= 2195) */ - -NTSYSAPI -NTSTATUS -NTAPI -ZwFreeVirtualMemory ( - IN HANDLE ProcessHandle, - IN OUT PVOID *BaseAddress, - IN OUT PSIZE_T RegionSize, - IN ULONG FreeType -); - -NTSYSAPI -NTSTATUS -NTAPI -ZwFsControlFile ( - IN HANDLE FileHandle, - IN HANDLE Event OPTIONAL, - IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, - IN PVOID ApcContext OPTIONAL, - OUT PIO_STATUS_BLOCK IoStatusBlock, - IN ULONG FsControlCode, - IN PVOID InputBuffer OPTIONAL, - IN ULONG InputBufferLength, - OUT PVOID OutputBuffer OPTIONAL, - IN ULONG OutputBufferLength -); - -#if (VER_PRODUCTBUILD >= 2195) - NTSYSAPI NTSTATUS NTAPI @@ -9361,14 +9539,6 @@ ZwInitiatePowerAction ( #endif /* (VER_PRODUCTBUILD >= 2195) */ -NTSYSAPI -NTSTATUS -NTAPI -ZwLoadDriver ( - /* "\\Registry\\Machine\\System\\CurrentControlSet\\Services\\" */ - IN PUNICODE_STRING RegistryPath -); - NTSYSAPI NTSTATUS NTAPI @@ -9377,41 +9547,6 @@ ZwLoadKey ( IN POBJECT_ATTRIBUTES FileObjectAttributes ); -NTSYSAPI -NTSTATUS -NTAPI -ZwNotifyChangeKey ( - IN HANDLE KeyHandle, - IN HANDLE EventHandle OPTIONAL, - IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, - IN PVOID ApcContext OPTIONAL, - OUT PIO_STATUS_BLOCK IoStatusBlock, - IN ULONG NotifyFilter, - IN BOOLEAN WatchSubtree, - IN PVOID Buffer, - IN ULONG BufferLength, - IN BOOLEAN Asynchronous -); - -NTSYSAPI -NTSTATUS -NTAPI -ZwOpenDirectoryObject ( - OUT PHANDLE DirectoryHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes -); - -NTSYSAPI -NTSTATUS -NTAPI -ZwOpenProcess ( - OUT PHANDLE ProcessHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes, - IN PCLIENT_ID ClientId OPTIONAL -); - NTSYSAPI NTSTATUS NTAPI @@ -9441,21 +9576,6 @@ ZwOpenThreadToken ( OUT PHANDLE TokenHandle ); -#if (VER_PRODUCTBUILD >= 2195) - -NTSYSAPI -NTSTATUS -NTAPI -ZwPowerInformation ( - IN POWER_INFORMATION_LEVEL PowerInformationLevel, - IN PVOID InputBuffer OPTIONAL, - IN ULONG InputBufferLength, - OUT PVOID OutputBuffer OPTIONAL, - IN ULONG OutputBufferLength -); - -#endif /* (VER_PRODUCTBUILD >= 2195) */ - NTSYSAPI NTSTATUS NTAPI @@ -9472,23 +9592,6 @@ ZwQueryDefaultLocale ( OUT PLCID Locale ); -NTSYSAPI -NTSTATUS -NTAPI -ZwQueryDirectoryFile ( - IN HANDLE FileHandle, - IN HANDLE Event OPTIONAL, - IN PIO_APC_ROUTINE ApcRoutine OPTIONAL, - IN PVOID ApcContext OPTIONAL, - OUT PIO_STATUS_BLOCK IoStatusBlock, - OUT PVOID FileInformation, - IN ULONG Length, - IN FILE_INFORMATION_CLASS FileInformationClass, - IN BOOLEAN ReturnSingleEntry, - IN PUNICODE_STRING FileName OPTIONAL, - IN BOOLEAN RestartScan -); - #if (VER_PRODUCTBUILD >= 2195) NTSYSAPI @@ -9504,21 +9607,6 @@ ZwQueryDirectoryObject ( OUT PULONG ReturnLength OPTIONAL ); -NTSYSAPI -NTSTATUS -NTAPI -ZwQueryEaFile ( - IN HANDLE FileHandle, - OUT PIO_STATUS_BLOCK IoStatusBlock, - OUT PVOID Buffer, - IN ULONG Length, - IN BOOLEAN ReturnSingleEntry, - IN PVOID EaList OPTIONAL, - IN ULONG EaListLength, - IN PULONG EaIndex OPTIONAL, - IN BOOLEAN RestartScan -); - #endif /* (VER_PRODUCTBUILD >= 2195) */ NTSYSAPI @@ -9532,39 +9620,6 @@ ZwQueryInformationProcess ( OUT PULONG ReturnLength OPTIONAL ); -NTSYSAPI -NTSTATUS -NTAPI -ZwQueryInformationToken ( - IN HANDLE TokenHandle, - IN TOKEN_INFORMATION_CLASS TokenInformationClass, - OUT PVOID TokenInformation, - IN ULONG Length, - OUT PULONG ResultLength -); - -NTSYSAPI -NTSTATUS -NTAPI -ZwQuerySecurityObject ( - IN HANDLE FileHandle, - IN SECURITY_INFORMATION SecurityInformation, - OUT PSECURITY_DESCRIPTOR SecurityDescriptor, - IN ULONG Length, - OUT PULONG ResultLength -); - -NTSYSAPI -NTSTATUS -NTAPI -ZwQueryVolumeInformationFile ( - IN HANDLE FileHandle, - OUT PIO_STATUS_BLOCK IoStatusBlock, - OUT PVOID FsInformation, - IN ULONG Length, - IN FS_INFORMATION_CLASS FsInformationClass -); - NTSYSAPI NTSTATUS NTAPI @@ -9620,26 +9675,8 @@ ZwSetDefaultUILanguage ( IN LANGID LanguageId ); -NTSYSAPI -NTSTATUS -NTAPI -ZwSetEaFile ( - IN HANDLE FileHandle, - OUT PIO_STATUS_BLOCK IoStatusBlock, - OUT PVOID Buffer, - IN ULONG Length -); - #endif /* (VER_PRODUCTBUILD >= 2195) */ -NTSYSAPI -NTSTATUS -NTAPI -ZwSetEvent ( - IN HANDLE EventHandle, - OUT PLONG PreviousState OPTIONAL -); - NTSYSAPI NTSTATUS NTAPI @@ -9650,19 +9687,6 @@ ZwSetInformationProcess ( IN ULONG ProcessInformationLength ); -#if (VER_PRODUCTBUILD >= 2195) - -NTSYSAPI -NTSTATUS -NTAPI -ZwSetSecurityObject ( - IN HANDLE Handle, - IN SECURITY_INFORMATION SecurityInformation, - IN PSECURITY_DESCRIPTOR SecurityDescriptor -); - -#endif /* (VER_PRODUCTBUILD >= 2195) */ - NTSYSAPI NTSTATUS NTAPI @@ -9671,37 +9695,6 @@ ZwSetSystemTime ( OUT PLARGE_INTEGER OldTime OPTIONAL ); -#if (VER_PRODUCTBUILD >= 2195) - -NTSYSAPI -NTSTATUS -NTAPI -ZwSetVolumeInformationFile ( - IN HANDLE FileHandle, - OUT PIO_STATUS_BLOCK IoStatusBlock, - IN PVOID FsInformation, - IN ULONG Length, - IN FS_INFORMATION_CLASS FsInformationClass -); - -#endif /* (VER_PRODUCTBUILD >= 2195) */ - -NTSYSAPI -NTSTATUS -NTAPI -ZwTerminateProcess ( - IN HANDLE ProcessHandle OPTIONAL, - IN NTSTATUS ExitStatus -); - -NTSYSAPI -NTSTATUS -NTAPI -ZwUnloadDriver ( - /* "\\Registry\\Machine\\System\\CurrentControlSet\\Services\\" */ - IN PUNICODE_STRING RegistryPath -); - NTSYSAPI NTSTATUS NTAPI @@ -9709,16 +9702,6 @@ ZwUnloadKey ( IN POBJECT_ATTRIBUTES KeyObjectAttributes ); -#if (NTDDI_VERSION >= NTDDI_WIN2K) -NTSYSAPI -NTSTATUS -NTAPI -ZwWaitForSingleObject ( - IN HANDLE Handle, - IN BOOLEAN Alertable, - IN PLARGE_INTEGER Timeout OPTIONAL); -#endif - NTSYSAPI NTSTATUS NTAPI diff --git a/reactos/include/ddk/ntimage.h b/reactos/include/ddk/ntimage.h index e008a2daa94..8df984763f7 100644 --- a/reactos/include/ddk/ntimage.h +++ b/reactos/include/ddk/ntimage.h @@ -394,22 +394,33 @@ typedef struct _IMAGE_NT_HEADERS64 { ULONG Signature; IMAGE_FILE_HEADER FileHeader; IMAGE_OPTIONAL_HEADER64 OptionalHeader; -} IMAGE_NT_HEADERS64, *PIMAGE_NT_HEADERS64; +} IMAGE_NT_HEADERS64; typedef struct _IMAGE_NT_HEADERS { ULONG Signature; IMAGE_FILE_HEADER FileHeader; IMAGE_OPTIONAL_HEADER32 OptionalHeader; -} IMAGE_NT_HEADERS32, *PIMAGE_NT_HEADERS32; +} IMAGE_NT_HEADERS32; #ifdef _WIN64 typedef IMAGE_NT_HEADERS64 IMAGE_NT_HEADERS; -typedef PIMAGE_NT_HEADERS64 PIMAGE_NT_HEADERS; #else typedef IMAGE_NT_HEADERS32 IMAGE_NT_HEADERS; +#endif + +#ifndef _NTDDK_ + +typedef struct _IMAGE_NT_HEADERS *PIMAGE_NT_HEADERS32; +typedef struct _IMAGE_NT_HEADERS64 *PIMAGE_NT_HEADERS64; + +#ifdef _WIN64 +typedef PIMAGE_NT_HEADERS64 PIMAGE_NT_HEADERS; +#else typedef PIMAGE_NT_HEADERS32 PIMAGE_NT_HEADERS; #endif +#endif /* _NTDDK_ */ + // // Retreives the first image section header from the Nt Header // diff --git a/reactos/include/ddk/wdm.h b/reactos/include/ddk/wdm.h index 4dd5ae3abc9..3a523235742 100644 --- a/reactos/include/ddk/wdm.h +++ b/reactos/include/ddk/wdm.h @@ -38,15 +38,26 @@ #include #include #include +#include #ifndef GUID_DEFINED #include #endif +#ifdef _MAC +#ifndef _INC_STRING +#include +#endif /* _INC_STRING */ +#else +#include +#endif /* _MAC */ + #ifndef _KTMTYPES_ typedef GUID UOW, *PUOW; #endif +typedef GUID *PGUID; + #if (NTDDI_VERSION >= NTDDI_WINXP) #include #endif @@ -133,8 +144,6 @@ struct _IO_RESOURCE_DESCRIPTOR; typedef struct _OBJECT_TYPE *POBJECT_TYPE; typedef struct _HAL_DISPATCH_TABLE *PHAL_DISPATCH_TABLE; typedef struct _HAL_PRIVATE_DISPATCH_TABLE *PHAL_PRIVATE_DISPATCH_TABLE; -typedef struct _DEVICE_HANDLER_OBJECT *PDEVICE_HANDLER_OBJECT; -typedef struct _ADAPTER_OBJECT *PADAPTER_OBJECT; typedef struct _CALLBACK_OBJECT *PCALLBACK_OBJECT; typedef struct _EPROCESS *PEPROCESS; typedef struct _ETHREAD *PETHREAD; @@ -144,6 +153,42 @@ typedef struct _KPROCESS *PKPROCESS; typedef struct _KTHREAD *PKTHREAD, *PRKTHREAD; typedef struct _CONTEXT *PCONTEXT; +#if defined(USE_DMA_MACROS) && !defined(_NTHAL_) && ( defined(_NTDDK_) || defined(_NTDRIVER_) || defined(_NTOSP_)) +typedef struct _DMA_ADAPTER *PADAPTER_OBJECT; +#elif defined(_WDM_INCLUDED_) +typedef struct _DMA_ADAPTER *PADAPTER_OBJECT; +#else +typedef struct _ADAPTER_OBJECT *PADAPTER_OBJECT; +#endif + +#ifndef DEFINE_GUIDEX +#ifdef _MSC_VER +#define DEFINE_GUIDEX(name) EXTERN_C const CDECL GUID name +#else +#define DEFINE_GUIDEX(name) EXTERN_C const GUID name +#endif +#endif /* DEFINE_GUIDEX */ + +#ifndef STATICGUIDOF +#define STATICGUIDOF(guid) STATIC_##guid +#endif + +/* GUID Comparison */ +#ifndef __IID_ALIGNED__ +#define __IID_ALIGNED__ +#ifdef __cplusplus +inline int IsEqualGUIDAligned(REFGUID guid1, REFGUID guid2) +{ + return ( (*(PLONGLONG)(&guid1) == *(PLONGLONG)(&guid2)) && + (*((PLONGLONG)(&guid1) + 1) == *((PLONGLONG)(&guid2) + 1)) ); +} +#else +#define IsEqualGUIDAligned(guid1, guid2) \ + ( (*(PLONGLONG)(guid1) == *(PLONGLONG)(guid2)) && \ + (*((PLONGLONG)(guid1) + 1) == *((PLONGLONG)(guid2) + 1)) ) +#endif /* __cplusplus */ +#endif /* !__IID_ALIGNED__ */ + /****************************************************************************** * INTERLOCKED Functions * @@ -482,17 +527,29 @@ typedef SLIST_HEADER SLIST_HEADER32, *PSLIST_HEADER32; #endif /* _SLIST_HEADER_ */ - -/* HACK HACK HACK - GCC (or perhaps LD) is messing this up */ -#if defined(_NTSYSTEM_) || defined(__GNUC__) +/* MS definition is broken! */ +extern BOOLEAN NTSYSAPI NlsMbCodePageTag; +extern BOOLEAN NTSYSAPI NlsMbOemCodePageTag; #define NLS_MB_CODE_PAGE_TAG NlsMbCodePageTag #define NLS_MB_OEM_CODE_PAGE_TAG NlsMbOemCodePageTag -#else -#define NLS_MB_CODE_PAGE_TAG (*NlsMbCodePageTag) -#define NLS_MB_OEM_CODE_PAGE_TAG (*NlsMbOemCodePageTag) -#endif /* _NT_SYSTEM */ -extern BOOLEAN NTSYSAPI NLS_MB_CODE_PAGE_TAG; -extern BOOLEAN NTSYSAPI NLS_MB_OEM_CODE_PAGE_TAG; + +#define SHORT_LEAST_SIGNIFICANT_BIT 0 +#define SHORT_MOST_SIGNIFICANT_BIT 1 + +#define LONG_LEAST_SIGNIFICANT_BIT 0 +#define LONG_3RD_MOST_SIGNIFICANT_BIT 1 +#define LONG_2ND_MOST_SIGNIFICANT_BIT 2 +#define LONG_MOST_SIGNIFICANT_BIT 3 + +#define RTLVERLIB_DDI(x) Wdmlib##x + +typedef BOOLEAN +(*PFN_RTL_IS_NTDDI_VERSION_AVAILABLE)( + IN ULONG Version); + +typedef BOOLEAN +(*PFN_RTL_IS_SERVICE_PACK_VERSION_INSTALLED)( + IN ULONG Version); /****************************************************************************** @@ -503,18 +560,116 @@ typedef UCHAR KIRQL, *PKIRQL; typedef CCHAR KPROCESSOR_MODE; typedef LONG KPRIORITY; -typedef ULONG EXECUTION_STATE; - typedef enum _MODE { KernelMode, UserMode, MaximumMode } MODE; +#define CACHE_FULLY_ASSOCIATIVE 0xFF +#define MAXIMUM_SUSPEND_COUNT MAXCHAR + +#define EVENT_QUERY_STATE (0x0001) +#define EVENT_MODIFY_STATE (0x0002) +#define EVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3) + +#define LTP_PC_SMT 0x1 + #if (NTDDI_VERSION < NTDDI_WIN7) || defined(_X86_) || !defined(NT_PROCESSOR_GROUPS) #define SINGLE_GROUP_LEGACY_API 1 #endif +#define SEMAPHORE_QUERY_STATE (0x0001) +#define SEMAPHORE_MODIFY_STATE (0x0002) +#define SEMAPHORE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3) + +typedef enum _LOGICAL_PROCESSOR_RELATIONSHIP { + RelationProcessorCore, + RelationNumaNode, + RelationCache, + RelationProcessorPackage, + RelationGroup, + RelationAll = 0xffff +} LOGICAL_PROCESSOR_RELATIONSHIP; + +typedef enum _PROCESSOR_CACHE_TYPE { + CacheUnified, + CacheInstruction, + CacheData, + CacheTrace +} PROCESSOR_CACHE_TYPE; + +typedef struct _CACHE_DESCRIPTOR { + UCHAR Level; + UCHAR Associativity; + USHORT LineSize; + ULONG Size; + PROCESSOR_CACHE_TYPE Type; +} CACHE_DESCRIPTOR, *PCACHE_DESCRIPTOR; + +typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION { + ULONG_PTR ProcessorMask; + LOGICAL_PROCESSOR_RELATIONSHIP Relationship; + union { + struct { + UCHAR Flags; + } ProcessorCore; + struct { + ULONG NodeNumber; + } NumaNode; + CACHE_DESCRIPTOR Cache; + ULONGLONG Reserved[2]; + } DUMMYUNIONNAME; +} SYSTEM_LOGICAL_PROCESSOR_INFORMATION, *PSYSTEM_LOGICAL_PROCESSOR_INFORMATION; + +typedef struct _PROCESSOR_RELATIONSHIP { + UCHAR Flags; + UCHAR Reserved[21]; + USHORT GroupCount; + GROUP_AFFINITY GroupMask[ANYSIZE_ARRAY]; +} PROCESSOR_RELATIONSHIP, *PPROCESSOR_RELATIONSHIP; + +typedef struct _NUMA_NODE_RELATIONSHIP { + ULONG NodeNumber; + UCHAR Reserved[20]; + GROUP_AFFINITY GroupMask; +} NUMA_NODE_RELATIONSHIP, *PNUMA_NODE_RELATIONSHIP; + +typedef struct _CACHE_RELATIONSHIP { + UCHAR Level; + UCHAR Associativity; + USHORT LineSize; + ULONG CacheSize; + PROCESSOR_CACHE_TYPE Type; + UCHAR Reserved[20]; + GROUP_AFFINITY GroupMask; +} CACHE_RELATIONSHIP, *PCACHE_RELATIONSHIP; + +typedef struct _PROCESSOR_GROUP_INFO { + UCHAR MaximumProcessorCount; + UCHAR ActiveProcessorCount; + UCHAR Reserved[38]; + KAFFINITY ActiveProcessorMask; +} PROCESSOR_GROUP_INFO, *PPROCESSOR_GROUP_INFO; + +typedef struct _GROUP_RELATIONSHIP { + USHORT MaximumGroupCount; + USHORT ActiveGroupCount; + UCHAR Reserved[20]; + PROCESSOR_GROUP_INFO GroupInfo[ANYSIZE_ARRAY]; +} GROUP_RELATIONSHIP, *PGROUP_RELATIONSHIP; + +typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX { + LOGICAL_PROCESSOR_RELATIONSHIP Relationship; + ULONG Size; + union { + PROCESSOR_RELATIONSHIP Processor; + NUMA_NODE_RELATIONSHIP NumaNode; + CACHE_RELATIONSHIP Cache; + GROUP_RELATIONSHIP Group; + } DUMMYUNIONNAME; +} SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX, *PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX;; + /* Processor features */ #define PF_FLOATING_POINT_PRECISION_ERRATA 0 #define PF_FLOATING_POINT_EMULATED 1 @@ -535,7 +690,6 @@ typedef enum _MODE { #define PF_CHANNELS_ENABLED 16 #define PF_XSAVE_ENABLED 17 -#define MAXIMUM_SUPPORTED_EXTENSION 512 #define MAXIMUM_WAIT_OBJECTS 64 #define ASSERT_APC(Object) NT_ASSERT((Object)->Type == ApcObject) @@ -603,6 +757,23 @@ typedef enum _MODE { #define EXCEPTION_NONCONTINUABLE 1 #define EXCEPTION_MAXIMUM_PARAMETERS 15 +#define EXCEPTION_DIVIDED_BY_ZERO 0 +#define EXCEPTION_DEBUG 1 +#define EXCEPTION_NMI 2 +#define EXCEPTION_INT3 3 +#define EXCEPTION_BOUND_CHECK 5 +#define EXCEPTION_INVALID_OPCODE 6 +#define EXCEPTION_NPX_NOT_AVAILABLE 7 +#define EXCEPTION_DOUBLE_FAULT 8 +#define EXCEPTION_NPX_OVERRUN 9 +#define EXCEPTION_INVALID_TSS 0x0A +#define EXCEPTION_SEGMENT_NOT_PRESENT 0x0B +#define EXCEPTION_STACK_FAULT 0x0C +#define EXCEPTION_GP_FAULT 0x0D +#define EXCEPTION_RESERVED_TRAP 0x0F +#define EXCEPTION_NPX_ERROR 0x010 +#define EXCEPTION_ALIGNMENT_CHECK 0x011 + typedef struct _EXCEPTION_RECORD { NTSTATUS ExceptionCode; ULONG ExceptionFlags; @@ -654,6 +825,42 @@ typedef VOID IN ULONG ReasonSpecificDataLength); typedef KBUGCHECK_REASON_CALLBACK_ROUTINE *PKBUGCHECK_REASON_CALLBACK_ROUTINE; +typedef struct _KBUGCHECK_ADD_PAGES { + IN OUT PVOID Context; + IN OUT ULONG Flags; + IN ULONG BugCheckCode; + OUT ULONG_PTR Address; + OUT ULONG_PTR Count; +} KBUGCHECK_ADD_PAGES, *PKBUGCHECK_ADD_PAGES; + +typedef struct _KBUGCHECK_SECONDARY_DUMP_DATA { + IN PVOID InBuffer; + IN ULONG InBufferLength; + IN ULONG MaximumAllowed; + OUT GUID Guid; + OUT PVOID OutBuffer; + OUT ULONG OutBufferLength; +} KBUGCHECK_SECONDARY_DUMP_DATA, *PKBUGCHECK_SECONDARY_DUMP_DATA; + +typedef enum _KBUGCHECK_DUMP_IO_TYPE { + KbDumpIoInvalid, + KbDumpIoHeader, + KbDumpIoBody, + KbDumpIoSecondaryData, + KbDumpIoComplete +} KBUGCHECK_DUMP_IO_TYPE; + +typedef struct _KBUGCHECK_DUMP_IO { + IN ULONG64 Offset; + IN PVOID Buffer; + IN ULONG BufferLength; + IN KBUGCHECK_DUMP_IO_TYPE Type; +} KBUGCHECK_DUMP_IO, *PKBUGCHECK_DUMP_IO; + +#define KB_ADD_PAGES_FLAG_VIRTUAL_ADDRESS 0x00000001UL +#define KB_ADD_PAGES_FLAG_PHYSICAL_ADDRESS 0x00000002UL +#define KB_ADD_PAGES_FLAG_ADDITIONAL_RANGES_EXIST 0x80000000UL + typedef struct _KBUGCHECK_REASON_CALLBACK_RECORD { LIST_ENTRY Entry; PKBUGCHECK_REASON_CALLBACK_ROUTINE CallbackRoutine; @@ -693,20 +900,31 @@ typedef BOOLEAN IN BOOLEAN Handled); typedef NMI_CALLBACK *PNMI_CALLBACK; -typedef enum _TRACE_INFORMATION_CLASS { - TraceIdClass, - TraceHandleClass, - TraceEnableFlagsClass, - TraceEnableLevelClass, - GlobalLoggerHandleClass, - EventLoggerHandleClass, - AllLoggerHandlesClass, - TraceHandleByNameClass, - LoggerEventsLostClass, - TraceSessionSettingsClass, - LoggerEventsLoggedClass, - MaxTraceInformationClass -} TRACE_INFORMATION_CLASS; +typedef enum _KE_PROCESSOR_CHANGE_NOTIFY_STATE { + KeProcessorAddStartNotify = 0, + KeProcessorAddCompleteNotify, + KeProcessorAddFailureNotify +} KE_PROCESSOR_CHANGE_NOTIFY_STATE; + +typedef struct _KE_PROCESSOR_CHANGE_NOTIFY_CONTEXT { + KE_PROCESSOR_CHANGE_NOTIFY_STATE State; + ULONG NtNumber; + NTSTATUS Status; +#if (NTDDI_VERSION >= NTDDI_WIN7) + PROCESSOR_NUMBER ProcNumber; +#endif +} KE_PROCESSOR_CHANGE_NOTIFY_CONTEXT, *PKE_PROCESSOR_CHANGE_NOTIFY_CONTEXT; + +typedef VOID +(NTAPI PROCESSOR_CALLBACK_FUNCTION)( + IN PVOID CallbackContext, + IN PKE_PROCESSOR_CHANGE_NOTIFY_CONTEXT ChangeContext, + IN OUT PNTSTATUS OperationStatus); +typedef PROCESSOR_CALLBACK_FUNCTION *PPROCESSOR_CALLBACK_FUNCTION; + +#define KE_PROCESSOR_CHANGE_ADD_EXISTING 1 + +#define INVALID_PROCESSOR_INDEX 0xffffffff typedef enum _KINTERRUPT_POLARITY { InterruptPolarityUnknown, @@ -803,36 +1021,32 @@ typedef enum _KINTERRUPT_MODE { #define THREAD_WAIT_OBJECTS 3 +typedef VOID +(NTAPI KSTART_ROUTINE)( + IN PVOID StartContext); +typedef KSTART_ROUTINE *PKSTART_ROUTINE; + typedef VOID (NTAPI *PKINTERRUPT_ROUTINE)( VOID); +typedef BOOLEAN +(NTAPI KSERVICE_ROUTINE)( + IN struct _KINTERRUPT *Interrupt, + IN PVOID ServiceContext); +typedef KSERVICE_ROUTINE *PKSERVICE_ROUTINE; + +typedef BOOLEAN +(NTAPI KMESSAGE_SERVICE_ROUTINE)( + IN struct _KINTERRUPT *Interrupt, + IN PVOID ServiceContext, + IN ULONG MessageID); +typedef KMESSAGE_SERVICE_ROUTINE *PKMESSAGE_SERVICE_ROUTINE; + typedef enum _KD_OPTION { KD_OPTION_SET_BLOCK_ENABLE, } KD_OPTION; -typedef enum _INTERFACE_TYPE { - InterfaceTypeUndefined = -1, - Internal, - Isa, - Eisa, - MicroChannel, - TurboChannel, - PCIBus, - VMEBus, - NuBus, - PCMCIABus, - CBus, - MPIBus, - MPSABus, - ProcessorInternal, - InternalPowerBus, - PNPISABus, - PNPBus, - Vmcs, - MaximumInterfaceType -} INTERFACE_TYPE, *PINTERFACE_TYPE; - typedef VOID (NTAPI *PKNORMAL_ROUTINE)( IN PVOID NormalContext OPTIONAL, @@ -870,6 +1084,14 @@ typedef struct _KAPC { BOOLEAN Inserted; } KAPC, *PKAPC, *RESTRICTED_POINTER PRKAPC; +#define KAPC_OFFSET_TO_SPARE_BYTE0 FIELD_OFFSET(KAPC, SpareByte0) +#define KAPC_OFFSET_TO_SPARE_BYTE1 FIELD_OFFSET(KAPC, SpareByte1) +#define KAPC_OFFSET_TO_SPARE_LONG FIELD_OFFSET(KAPC, SpareLong0) +#define KAPC_OFFSET_TO_SYSTEMARGUMENT1 FIELD_OFFSET(KAPC, SystemArgument1) +#define KAPC_OFFSET_TO_SYSTEMARGUMENT2 FIELD_OFFSET(KAPC, SystemArgument2) +#define KAPC_OFFSET_TO_APCSTATEINDEX FIELD_OFFSET(KAPC, ApcStateIndex) +#define KAPC_ACTUAL_LENGTH (FIELD_OFFSET(KAPC, Inserted) + sizeof(BOOLEAN)) + typedef struct _KDEVICE_QUEUE_ENTRY { LIST_ENTRY DeviceListEntry; ULONG SortKey; @@ -886,10 +1108,27 @@ typedef VOID IN PVOID Parameter2 OPTIONAL, IN PVOID Parameter3 OPTIONAL); -typedef -ULONG_PTR -(NTAPI *PKIPI_BROADCAST_WORKER)( +typedef struct _KIPI_COUNTS { + ULONG Freeze; + ULONG Packet; + ULONG DPC; + ULONG APC; + ULONG FlushSingleTb; + ULONG FlushMultipleTb; + ULONG FlushEntireTb; + ULONG GenericCall; + ULONG ChangeColor; + ULONG SweepDcache; + ULONG SweepIcache; + ULONG SweepIcacheRange; + ULONG FlushIoBuffers; + ULONG GratuitousDPC; +} KIPI_COUNTS, *PKIPI_COUNTS; + +typedef ULONG_PTR +(NTAPI KIPI_BROADCAST_WORKER)( IN ULONG_PTR Argument); +typedef KIPI_BROADCAST_WORKER *PKIPI_BROADCAST_WORKER; typedef ULONG_PTR KSPIN_LOCK, *PKSPIN_LOCK; @@ -1088,6 +1327,8 @@ typedef struct _KSEMAPHORE { LONG Limit; } KSEMAPHORE, *PKSEMAPHORE, *RESTRICTED_POINTER PRKSEMAPHORE; +#define KSEMAPHORE_ACTUAL_LENGTH (FIELD_OFFSET(KSEMAPHORE, Limit) + sizeof(LONG)) + typedef struct _KGATE { DISPATCHER_HEADER Header; } KGATE, *PKGATE, *RESTRICTED_POINTER PRKGATE; @@ -1128,6 +1369,14 @@ typedef struct _KTIMER { ULONG Period; } KTIMER, *PKTIMER, *RESTRICTED_POINTER PRKTIMER; +typedef enum _LOCK_OPERATION { + IoReadAccess, + IoWriteAccess, + IoModifyAccess +} LOCK_OPERATION; + +#define KTIMER_ACTUAL_LENGTH (FIELD_OFFSET(KTIMER, Period) + sizeof(LONG)) + typedef BOOLEAN (NTAPI *PKSYNCHRONIZE_ROUTINE)( IN PVOID SynchronizeContext); @@ -1156,19 +1405,32 @@ typedef enum _ALTERNATIVE_ARCHITECTURE_TYPE { EndAlternatives } ALTERNATIVE_ARCHITECTURE_TYPE; -typedef struct _KSYSTEM_TIME -{ +#ifndef _X86_ + +#ifndef IsNEC_98 +#define IsNEC_98 (FALSE) +#endif + +#ifndef IsNotNEC_98 +#define IsNotNEC_98 (TRUE) +#endif + +#ifndef SetNEC_98 +#define SetNEC_98 +#endif + +#ifndef SetNotNEC_98 +#define SetNotNEC_98 +#endif + +#endif + +typedef struct _KSYSTEM_TIME { ULONG LowPart; LONG High1Time; LONG High2Time; } KSYSTEM_TIME, *PKSYSTEM_TIME; -typedef struct _PNP_BUS_INFORMATION { - GUID BusTypeGuid; - INTERFACE_TYPE LegacyBusType; - ULONG BusNumber; -} PNP_BUS_INFORMATION, *PPNP_BUS_INFORMATION; - typedef struct DECLSPEC_ALIGN(16) _M128A { ULONGLONG Low; LONGLONG High; @@ -1200,12 +1462,104 @@ typedef struct DECLSPEC_ALIGN(16) _XSAVE_FORMAT { #endif } XSAVE_FORMAT, *PXSAVE_FORMAT; +typedef struct DECLSPEC_ALIGN(8) _XSAVE_AREA_HEADER { + ULONG64 Mask; + ULONG64 Reserved[7]; +} XSAVE_AREA_HEADER, *PXSAVE_AREA_HEADER; + +typedef struct DECLSPEC_ALIGN(16) _XSAVE_AREA { + XSAVE_FORMAT LegacyState; + XSAVE_AREA_HEADER Header; +} XSAVE_AREA, *PXSAVE_AREA; + +typedef struct _XSTATE_CONTEXT { + ULONG64 Mask; + ULONG Length; + ULONG Reserved1; + PXSAVE_AREA Area; +#if defined(_X86_) + ULONG Reserved2; +#endif + PVOID Buffer; +#if defined(_X86_) + ULONG Reserved3; +#endif +} XSTATE_CONTEXT, *PXSTATE_CONTEXT; + +typedef struct _XSTATE_SAVE { +#if defined(_AMD64_) + struct _XSTATE_SAVE* Prev; + struct _KTHREAD* Thread; + UCHAR Level; + XSTATE_CONTEXT XStateContext; +#elif defined(_IA64_) + ULONG Dummy; +#elif defined(_X86_) + union { + struct { + LONG64 Reserved1; + ULONG Reserved2; + struct _XSTATE_SAVE* Prev; + PXSAVE_AREA Reserved3; + struct _KTHREAD* Thread; + PVOID Reserved4; + UCHAR Level; + }; + XSTATE_CONTEXT XStateContext; + }; +#endif +} XSTATE_SAVE, *PXSTATE_SAVE; + +#ifdef _X86_ + +#define MAXIMUM_SUPPORTED_EXTENSION 512 + +#if !defined(__midl) && !defined(MIDL_PASS) +C_ASSERT(sizeof(XSAVE_FORMAT) == MAXIMUM_SUPPORTED_EXTENSION); +#endif + +#endif /* _X86_ */ + +#define XSAVE_ALIGN 64 +#define MINIMAL_XSTATE_AREA_LENGTH sizeof(XSAVE_AREA) + +#if !defined(__midl) && !defined(MIDL_PASS) +C_ASSERT((sizeof(XSAVE_FORMAT) & (XSAVE_ALIGN - 1)) == 0); +C_ASSERT((FIELD_OFFSET(XSAVE_AREA, Header) & (XSAVE_ALIGN - 1)) == 0); +C_ASSERT(MINIMAL_XSTATE_AREA_LENGTH == 512 + 64); +#endif + +typedef struct _CONTEXT_CHUNK { + LONG Offset; + ULONG Length; +} CONTEXT_CHUNK, *PCONTEXT_CHUNK; + +typedef struct _CONTEXT_EX { + CONTEXT_CHUNK All; + CONTEXT_CHUNK Legacy; + CONTEXT_CHUNK XState; +} CONTEXT_EX, *PCONTEXT_EX; + +#define CONTEXT_EX_LENGTH ALIGN_UP_BY(sizeof(CONTEXT_EX), STACK_ALIGN) + +#if (NTDDI_VERSION >= NTDDI_VISTA) +extern NTSYSAPI volatile CCHAR KeNumberProcessors; +#elif (NTDDI_VERSION >= NTDDI_WINXP) +extern NTSYSAPI CCHAR KeNumberProcessors; +#else +extern PCCHAR KeNumberProcessors; +#endif /****************************************************************************** * Memory manager Types * ******************************************************************************/ +#if (NTDDI_VERSION >= NTDDI_WIN2K) +typedef ULONG NODE_REQUIREMENT; +#define MM_ANY_NODE_OK 0x80000000 +#endif + #define MM_DONT_ZERO_ALLOCATION 0x00000001 #define MM_ALLOCATE_FROM_LOCAL_NODE_ONLY 0x00000002 #define MM_ALLOCATE_FULLY_REQUIRED 0x00000004 @@ -1334,12 +1688,6 @@ typedef enum _MM_PAGE_PRIORITY { HighPagePriority = 32 } MM_PAGE_PRIORITY; -typedef enum _LOCK_OPERATION { - IoReadAccess, - IoWriteAccess, - IoModifyAccess -} LOCK_OPERATION; - typedef enum _MM_SYSTEM_SIZE { MmSmallSystem, MmMediumSystem, @@ -1358,12 +1706,6 @@ extern PVOID MmBadPointer; #define EX_RUNDOWN_COUNT_SHIFT 0x1 #define EX_RUNDOWN_COUNT_INC (1 << EX_RUNDOWN_COUNT_SHIFT) -#ifdef _WIN64 -#define PORT_MAXIMUM_MESSAGE_LENGTH 512 -#else -#define PORT_MAXIMUM_MESSAGE_LENGTH 256 -#endif - typedef struct _FAST_MUTEX { volatile LONG Count; PKTHREAD Owner; @@ -1535,6 +1877,13 @@ typedef struct _EX_RUNDOWN_REF { typedef struct _EX_RUNDOWN_REF_CACHE_AWARE *PEX_RUNDOWN_REF_CACHE_AWARE; +typedef enum _WORK_QUEUE_TYPE { + CriticalWorkQueue, + DelayedWorkQueue, + HyperCriticalWorkQueue, + MaximumWorkQueue +} WORK_QUEUE_TYPE; + typedef VOID (NTAPI WORKER_THREAD_ROUTINE)( IN PVOID Parameter); @@ -1546,6 +1895,78 @@ typedef struct _WORK_QUEUE_ITEM { volatile PVOID Parameter; } WORK_QUEUE_ITEM, *PWORK_QUEUE_ITEM; +typedef ULONG_PTR ERESOURCE_THREAD, *PERESOURCE_THREAD; + +typedef struct _OWNER_ENTRY { + ERESOURCE_THREAD OwnerThread; + union { + struct { + ULONG IoPriorityBoosted:1; + ULONG OwnerReferenced:1; + ULONG OwnerCount:30; + }; + ULONG TableSize; + }; +} OWNER_ENTRY, *POWNER_ENTRY; + +typedef struct _ERESOURCE { + LIST_ENTRY SystemResourcesList; + POWNER_ENTRY OwnerTable; + SHORT ActiveCount; + USHORT Flag; + volatile PKSEMAPHORE SharedWaiters; + volatile PKEVENT ExclusiveWaiters; + OWNER_ENTRY OwnerEntry; + ULONG ActiveEntries; + ULONG ContentionCount; + ULONG NumberOfSharedWaiters; + ULONG NumberOfExclusiveWaiters; +#if defined(_WIN64) + PVOID Reserved2; +#endif + __GNU_EXTENSION union { + PVOID Address; + ULONG_PTR CreatorBackTraceIndex; + }; + KSPIN_LOCK SpinLock; +} ERESOURCE, *PERESOURCE; + +/* ERESOURCE.Flag */ +#define ResourceNeverExclusive 0x0010 +#define ResourceReleaseByOtherThread 0x0020 +#define ResourceOwnedExclusive 0x0080 + +#define RESOURCE_HASH_TABLE_SIZE 64 + +typedef struct _RESOURCE_HASH_ENTRY { + LIST_ENTRY ListEntry; + PVOID Address; + ULONG ContentionCount; + ULONG Number; +} RESOURCE_HASH_ENTRY, *PRESOURCE_HASH_ENTRY; + +typedef struct _RESOURCE_PERFORMANCE_DATA { + ULONG ActiveResourceCount; + ULONG TotalResourceCount; + ULONG ExclusiveAcquire; + ULONG SharedFirstLevel; + ULONG SharedSecondLevel; + ULONG StarveFirstLevel; + ULONG StarveSecondLevel; + ULONG WaitForExclusive; + ULONG OwnerTableExpands; + ULONG MaximumTableExpand; + LIST_ENTRY HashTable[RESOURCE_HASH_TABLE_SIZE]; +} RESOURCE_PERFORMANCE_DATA, *PRESOURCE_PERFORMANCE_DATA; + +/* Global debug flag */ +#if DEVL +extern ULONG NtGlobalFlag; +#define IF_NTOS_DEBUG(FlagName) if (NtGlobalFlag & (FLG_##FlagName)) +#else +#define IF_NTOS_DEBUG(FlagName) if(FALSE) +#endif + /****************************************************************************** * Security Manager Types * @@ -1972,6 +2393,144 @@ typedef enum _POWER_STATE_TYPE { DevicePowerState } POWER_STATE_TYPE, *PPOWER_STATE_TYPE; +#if (NTDDI_VERSION >= NTDDI_VISTA) +typedef struct _SYSTEM_POWER_STATE_CONTEXT { + union { + struct { + ULONG Reserved1:8; + ULONG TargetSystemState:4; + ULONG EffectiveSystemState:4; + ULONG CurrentSystemState:4; + ULONG IgnoreHibernationPath:1; + ULONG PseudoTransition:1; + ULONG Reserved2:10; + } DUMMYSTRUCTNAME; + ULONG ContextAsUlong; + } DUMMYUNIONNAME; +} SYSTEM_POWER_STATE_CONTEXT, *PSYSTEM_POWER_STATE_CONTEXT; +#endif + +#if (NTDDI_VERSION >= NTDDI_WIN7) +typedef struct _COUNTED_REASON_CONTEXT { + ULONG Version; + ULONG Flags; + union { + struct { + UNICODE_STRING ResourceFileName; + USHORT ResourceReasonId; + ULONG StringCount; + PUNICODE_STRING ReasonStrings; + } DUMMYSTRUCTNAME; + UNICODE_STRING SimpleString; + } DUMMYUNIONNAME; +} COUNTED_REASON_CONTEXT, *PCOUNTED_REASON_CONTEXT; +#endif + +#define IOCTL_QUERY_DEVICE_POWER_STATE \ + CTL_CODE(FILE_DEVICE_BATTERY, 0x0, METHOD_BUFFERED, FILE_READ_ACCESS) + +#define IOCTL_SET_DEVICE_WAKE \ + CTL_CODE(FILE_DEVICE_BATTERY, 0x1, METHOD_BUFFERED, FILE_WRITE_ACCESS) + +#define IOCTL_CANCEL_DEVICE_WAKE \ + CTL_CODE(FILE_DEVICE_BATTERY, 0x2, METHOD_BUFFERED, FILE_WRITE_ACCESS) + +#define ES_SYSTEM_REQUIRED 0x00000001 +#define ES_DISPLAY_REQUIRED 0x00000002 +#define ES_USER_PRESENT 0x00000004 +#define ES_CONTINUOUS 0x80000000 + +typedef ULONG EXECUTION_STATE, *PEXECUTION_STATE; + +typedef enum { + LT_DONT_CARE, + LT_LOWEST_LATENCY +} LATENCY_TIME; + +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN7) +#define DIAGNOSTIC_REASON_VERSION 0 +#define DIAGNOSTIC_REASON_SIMPLE_STRING 0x00000001 +#define DIAGNOSTIC_REASON_DETAILED_STRING 0x00000002 +#define DIAGNOSTIC_REASON_NOT_SPECIFIED 0x80000000 +#define DIAGNOSTIC_REASON_INVALID_FLAGS (~0x80000003) +#endif + +#define POWER_REQUEST_CONTEXT_VERSION 0 +#define POWER_REQUEST_CONTEXT_SIMPLE_STRING 0x00000001 +#define POWER_REQUEST_CONTEXT_DETAILED_STRING 0x00000002 + +#define PowerRequestMaximum 3 + +typedef enum _POWER_REQUEST_TYPE { + PowerRequestDisplayRequired, + PowerRequestSystemRequired, + PowerRequestAwayModeRequired +} POWER_REQUEST_TYPE, *PPOWER_REQUEST_TYPE; + +#if (NTDDI_VERSION >= NTDDI_WINXP) + +#define PDCAP_D0_SUPPORTED 0x00000001 +#define PDCAP_D1_SUPPORTED 0x00000002 +#define PDCAP_D2_SUPPORTED 0x00000004 +#define PDCAP_D3_SUPPORTED 0x00000008 +#define PDCAP_WAKE_FROM_D0_SUPPORTED 0x00000010 +#define PDCAP_WAKE_FROM_D1_SUPPORTED 0x00000020 +#define PDCAP_WAKE_FROM_D2_SUPPORTED 0x00000040 +#define PDCAP_WAKE_FROM_D3_SUPPORTED 0x00000080 +#define PDCAP_WARM_EJECT_SUPPORTED 0x00000100 + +typedef struct CM_Power_Data_s { + ULONG PD_Size; + DEVICE_POWER_STATE PD_MostRecentPowerState; + ULONG PD_Capabilities; + ULONG PD_D1Latency; + ULONG PD_D2Latency; + ULONG PD_D3Latency; + DEVICE_POWER_STATE PD_PowerStateMapping[PowerSystemMaximum]; + SYSTEM_POWER_STATE PD_DeepestSystemWake; +} CM_POWER_DATA, *PCM_POWER_DATA; + +#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ + +typedef enum _SYSTEM_POWER_CONDITION { + PoAc, + PoDc, + PoHot, + PoConditionMaximum +} SYSTEM_POWER_CONDITION; + +typedef struct _SET_POWER_SETTING_VALUE { + ULONG Version; + GUID Guid; + SYSTEM_POWER_CONDITION PowerCondition; + ULONG DataLength; + UCHAR Data[ANYSIZE_ARRAY]; +} SET_POWER_SETTING_VALUE, *PSET_POWER_SETTING_VALUE; + +#define POWER_SETTING_VALUE_VERSION (0x1) + +typedef struct _NOTIFY_USER_POWER_SETTING { + GUID Guid; +} NOTIFY_USER_POWER_SETTING, *PNOTIFY_USER_POWER_SETTING; + +typedef struct _APPLICATIONLAUNCH_SETTING_VALUE { + LARGE_INTEGER ActivationTime; + ULONG Flags; + ULONG ButtonInstanceID; +} APPLICATIONLAUNCH_SETTING_VALUE, *PAPPLICATIONLAUNCH_SETTING_VALUE; + +typedef enum _POWER_PLATFORM_ROLE { + PlatformRoleUnspecified = 0, + PlatformRoleDesktop, + PlatformRoleMobile, + PlatformRoleWorkstation, + PlatformRoleEnterpriseServer, + PlatformRoleSOHOServer, + PlatformRoleAppliancePC, + PlatformRolePerformanceServer, + PlatformRoleMaximum +} POWER_PLATFORM_ROLE; + #if (NTDDI_VERSION >= NTDDI_WINXP) || !defined(_BATCLASS_) typedef struct { ULONG Granularity; @@ -2125,12 +2684,6 @@ NTSTATUS IN OUT PVOID Context OPTIONAL); typedef POWER_SETTING_CALLBACK *PPOWER_SETTING_CALLBACK; -#define PO_CB_SYSTEM_POWER_POLICY 0 -#define PO_CB_AC_STATUS 1 -#define PO_CB_BUTTON_COLLISION 2 -#define PO_CB_SYSTEM_STATE_LOCK 3 -#define PO_CB_LID_SWITCH_STATE 4 -#define PO_CB_PROCESSOR_POWER_POLICY 5 /****************************************************************************** * Configuration Manager Types * @@ -2222,6 +2775,15 @@ typedef int CM_RESOURCE_TYPE; REG_OPTION_BACKUP_RESTORE |\ REG_OPTION_OPEN_LINK) +#define REG_OPEN_LEGAL_OPTION \ + (REG_OPTION_RESERVED |\ + REG_OPTION_BACKUP_RESTORE |\ + REG_OPTION_OPEN_LINK) + +#define REG_STANDARD_FORMAT 1 +#define REG_LATEST_FORMAT 2 +#define REG_NO_COMPRESSION 4 + /* Key creation/open disposition */ #define REG_CREATED_NEW_KEY (0x00000001L) #define REG_OPENED_EXISTING_KEY (0x00000002L) @@ -2254,27 +2816,6 @@ typedef int CM_RESOURCE_TYPE; REG_NOTIFY_CHANGE_LAST_SET |\ REG_NOTIFY_CHANGE_SECURITY) -typedef struct _CM_FLOPPY_DEVICE_DATA { - USHORT Version; - USHORT Revision; - CHAR Size[8]; - ULONG MaxDensity; - ULONG MountDensity; - UCHAR StepRateHeadUnloadTime; - UCHAR HeadLoadTime; - UCHAR MotorOffTime; - UCHAR SectorLengthCode; - UCHAR SectorPerTrack; - UCHAR ReadWriteGapLength; - UCHAR DataTransferLength; - UCHAR FormatGapLength; - UCHAR FormatFillCharacter; - UCHAR HeadSettleTime; - UCHAR MotorSettleTime; - UCHAR MaximumTrackValue; - UCHAR DataTransferRate; -} CM_FLOPPY_DEVICE_DATA, *PCM_FLOPPY_DEVICE_DATA; - #include typedef struct _CM_PARTIAL_RESOURCE_DESCRIPTOR { UCHAR Type; @@ -2441,6 +2982,50 @@ typedef enum _CM_SHARE_DISPOSITION { #define CM_RESOURCE_DMA_TYPE_B 0x0020 #define CM_RESOURCE_DMA_TYPE_F 0x0040 +typedef struct _DEVICE_FLAGS { + ULONG Failed:1; + ULONG ReadOnly:1; + ULONG Removable:1; + ULONG ConsoleIn:1; + ULONG ConsoleOut:1; + ULONG Input:1; + ULONG Output:1; +} DEVICE_FLAGS, *PDEVICE_FLAGS; + +typedef enum _INTERFACE_TYPE { + InterfaceTypeUndefined = -1, + Internal, + Isa, + Eisa, + MicroChannel, + TurboChannel, + PCIBus, + VMEBus, + NuBus, + PCMCIABus, + CBus, + MPIBus, + MPSABus, + ProcessorInternal, + InternalPowerBus, + PNPISABus, + PNPBus, + Vmcs, + MaximumInterfaceType +} INTERFACE_TYPE, *PINTERFACE_TYPE; + +typedef struct _CM_COMPONENT_INFORMATION { + DEVICE_FLAGS Flags; + ULONG Version; + ULONG Key; + KAFFINITY AffinityMask; +} CM_COMPONENT_INFORMATION, *PCM_COMPONENT_INFORMATION; + +typedef struct _CM_ROM_BLOCK { + ULONG Address; + ULONG Size; +} CM_ROM_BLOCK, *PCM_ROM_BLOCK; + typedef struct _CM_PARTIAL_RESOURCE_LIST { USHORT Version; USHORT Revision; @@ -2459,6 +3044,12 @@ typedef struct _CM_RESOURCE_LIST { CM_FULL_RESOURCE_DESCRIPTOR List[1]; } CM_RESOURCE_LIST, *PCM_RESOURCE_LIST; +typedef struct _PNP_BUS_INFORMATION { + GUID BusTypeGuid; + INTERFACE_TYPE LegacyBusType; + ULONG BusNumber; +} PNP_BUS_INFORMATION, *PPNP_BUS_INFORMATION; + #include typedef struct _CM_INT13_DRIVE_PARAMETER { @@ -2469,6 +3060,14 @@ typedef struct _CM_INT13_DRIVE_PARAMETER { USHORT NumberDrives; } CM_INT13_DRIVE_PARAMETER, *PCM_INT13_DRIVE_PARAMETER; +typedef struct _CM_MCA_POS_DATA { + USHORT AdapterId; + UCHAR PosData1; + UCHAR PosData2; + UCHAR PosData3; + UCHAR PosData4; +} CM_MCA_POS_DATA, *PCM_MCA_POS_DATA; + typedef struct _CM_PNP_BIOS_DEVICE_NODE { USHORT Size; UCHAR Node; @@ -2510,50 +3109,82 @@ typedef struct _CM_KEYBOARD_DEVICE_DATA { USHORT KeyboardFlags; } CM_KEYBOARD_DEVICE_DATA, *PCM_KEYBOARD_DEVICE_DATA; -typedef struct _CM_MCA_POS_DATA { - USHORT AdapterId; - UCHAR PosData1; - UCHAR PosData2; - UCHAR PosData3; - UCHAR PosData4; -} CM_MCA_POS_DATA, *PCM_MCA_POS_DATA; - -#if (NTDDI_VERSION >= NTDDI_WINXP) -typedef struct CM_Power_Data_s { - ULONG PD_Size; - DEVICE_POWER_STATE PD_MostRecentPowerState; - ULONG PD_Capabilities; - ULONG PD_D1Latency; - ULONG PD_D2Latency; - ULONG PD_D3Latency; - DEVICE_POWER_STATE PD_PowerStateMapping[PowerSystemMaximum]; - SYSTEM_POWER_STATE PD_DeepestSystemWake; -} CM_POWER_DATA, *PCM_POWER_DATA; - -#define PDCAP_D0_SUPPORTED 0x00000001 -#define PDCAP_D1_SUPPORTED 0x00000002 -#define PDCAP_D2_SUPPORTED 0x00000004 -#define PDCAP_D3_SUPPORTED 0x00000008 -#define PDCAP_WAKE_FROM_D0_SUPPORTED 0x00000010 -#define PDCAP_WAKE_FROM_D1_SUPPORTED 0x00000020 -#define PDCAP_WAKE_FROM_D2_SUPPORTED 0x00000040 -#define PDCAP_WAKE_FROM_D3_SUPPORTED 0x00000080 -#define PDCAP_WARM_EJECT_SUPPORTED 0x00000100 - -#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ - typedef struct _CM_SCSI_DEVICE_DATA { USHORT Version; USHORT Revision; UCHAR HostIdentifier; } CM_SCSI_DEVICE_DATA, *PCM_SCSI_DEVICE_DATA; +typedef struct _CM_VIDEO_DEVICE_DATA { + USHORT Version; + USHORT Revision; + ULONG VideoClock; +} CM_VIDEO_DEVICE_DATA, *PCM_VIDEO_DEVICE_DATA; + +typedef struct _CM_SONIC_DEVICE_DATA { + USHORT Version; + USHORT Revision; + USHORT DataConfigurationRegister; + UCHAR EthernetAddress[8]; +} CM_SONIC_DEVICE_DATA, *PCM_SONIC_DEVICE_DATA; + typedef struct _CM_SERIAL_DEVICE_DATA { USHORT Version; USHORT Revision; ULONG BaudClock; } CM_SERIAL_DEVICE_DATA, *PCM_SERIAL_DEVICE_DATA; +typedef struct _CM_MONITOR_DEVICE_DATA { + USHORT Version; + USHORT Revision; + USHORT HorizontalScreenSize; + USHORT VerticalScreenSize; + USHORT HorizontalResolution; + USHORT VerticalResolution; + USHORT HorizontalDisplayTimeLow; + USHORT HorizontalDisplayTime; + USHORT HorizontalDisplayTimeHigh; + USHORT HorizontalBackPorchLow; + USHORT HorizontalBackPorch; + USHORT HorizontalBackPorchHigh; + USHORT HorizontalFrontPorchLow; + USHORT HorizontalFrontPorch; + USHORT HorizontalFrontPorchHigh; + USHORT HorizontalSyncLow; + USHORT HorizontalSync; + USHORT HorizontalSyncHigh; + USHORT VerticalBackPorchLow; + USHORT VerticalBackPorch; + USHORT VerticalBackPorchHigh; + USHORT VerticalFrontPorchLow; + USHORT VerticalFrontPorch; + USHORT VerticalFrontPorchHigh; + USHORT VerticalSyncLow; + USHORT VerticalSync; + USHORT VerticalSyncHigh; +} CM_MONITOR_DEVICE_DATA, *PCM_MONITOR_DEVICE_DATA; + +typedef struct _CM_FLOPPY_DEVICE_DATA { + USHORT Version; + USHORT Revision; + CHAR Size[8]; + ULONG MaxDensity; + ULONG MountDensity; + UCHAR StepRateHeadUnloadTime; + UCHAR HeadLoadTime; + UCHAR MotorOffTime; + UCHAR SectorLengthCode; + UCHAR SectorPerTrack; + UCHAR ReadWriteGapLength; + UCHAR DataTransferLength; + UCHAR FormatGapLength; + UCHAR FormatFillCharacter; + UCHAR HeadSettleTime; + UCHAR MotorSettleTime; + UCHAR MaximumTrackValue; + UCHAR DataTransferRate; +} CM_FLOPPY_DEVICE_DATA, *PCM_FLOPPY_DEVICE_DATA; + typedef enum _KEY_INFORMATION_CLASS { KeyBasicInformation, KeyNodeInformation, @@ -2573,6 +3204,10 @@ typedef struct _KEY_BASIC_INFORMATION { WCHAR Name[1]; } KEY_BASIC_INFORMATION, *PKEY_BASIC_INFORMATION; +typedef struct _KEY_CONTROL_FLAGS_INFORMATION { + ULONG ControlFlags; +} KEY_CONTROL_FLAGS_INFORMATION, *PKEY_CONTROL_FLAGS_INFORMATION; + typedef struct _KEY_FULL_INFORMATION { LARGE_INTEGER LastWriteTime; ULONG TitleIndex; @@ -2587,6 +3222,10 @@ typedef struct _KEY_FULL_INFORMATION { WCHAR Class[1]; } KEY_FULL_INFORMATION, *PKEY_FULL_INFORMATION; +typedef struct _KEY_HANDLE_TAGS_INFORMATION { + ULONG HandleTags; +} KEY_HANDLE_TAGS_INFORMATION, *PKEY_HANDLE_TAGS_INFORMATION; + typedef struct _KEY_NODE_INFORMATION { LARGE_INTEGER LastWriteTime; ULONG TitleIndex; @@ -2596,6 +3235,23 @@ typedef struct _KEY_NODE_INFORMATION { WCHAR Name[1]; } KEY_NODE_INFORMATION, *PKEY_NODE_INFORMATION; +typedef enum _KEY_SET_INFORMATION_CLASS { + KeyWriteTimeInformation, + KeyWow64FlagsInformation, + KeyControlFlagsInformation, + KeySetVirtualizationInformation, + KeySetDebugInformation, + KeySetHandleTagsInformation, + MaxKeySetInfoClass +} KEY_SET_INFORMATION_CLASS; + +typedef struct _KEY_SET_VIRTUALIZATION_INFORMATION { + ULONG VirtualTarget:1; + ULONG VirtualStore:1; + ULONG VirtualSource:1; + ULONG Reserved:29; +} KEY_SET_VIRTUALIZATION_INFORMATION, *PKEY_SET_VIRTUALIZATION_INFORMATION; + typedef struct _KEY_VALUE_BASIC_INFORMATION { ULONG TitleIndex; ULONG Type; @@ -2640,20 +3296,14 @@ typedef enum _KEY_VALUE_INFORMATION_CLASS { KeyValuePartialInformationAlign64 } KEY_VALUE_INFORMATION_CLASS; +typedef struct _KEY_WOW64_FLAGS_INFORMATION { + ULONG UserFlags; +} KEY_WOW64_FLAGS_INFORMATION, *PKEY_WOW64_FLAGS_INFORMATION; + typedef struct _KEY_WRITE_TIME_INFORMATION { LARGE_INTEGER LastWriteTime; } KEY_WRITE_TIME_INFORMATION, *PKEY_WRITE_TIME_INFORMATION; -typedef enum _KEY_SET_INFORMATION_CLASS { - KeyWriteTimeInformation, - KeyWow64FlagsInformation, - KeyControlFlagsInformation, - KeySetVirtualizationInformation, - KeySetDebugInformation, - KeySetHandleTagsInformation, - MaxKeySetInfoClass -} KEY_SET_INFORMATION_CLASS; - typedef enum _REG_NOTIFY_CLASS { RegNtDeleteKey, RegNtPreDeleteKey = RegNtDeleteKey, @@ -2823,6 +3473,54 @@ typedef struct _REG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION { PVOID Reserved; } REG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION, *PREG_QUERY_MULTIPLE_VALUE_KEY_INFORMATION; +typedef struct _REG_RENAME_KEY_INFORMATION { + PVOID Object; + PUNICODE_STRING NewName; + PVOID CallContext; + PVOID ObjectContext; + PVOID Reserved; +} REG_RENAME_KEY_INFORMATION, *PREG_RENAME_KEY_INFORMATION; + +typedef struct _REG_CREATE_KEY_INFORMATION { + PUNICODE_STRING CompleteName; + PVOID RootObject; + PVOID ObjectType; + ULONG CreateOptions; + PUNICODE_STRING Class; + PVOID SecurityDescriptor; + PVOID SecurityQualityOfService; + ACCESS_MASK DesiredAccess; + ACCESS_MASK GrantedAccess; + PULONG Disposition; + PVOID *ResultObject; + PVOID CallContext; + PVOID RootObjectContext; + PVOID Transaction; + PVOID Reserved; +} REG_CREATE_KEY_INFORMATION, REG_OPEN_KEY_INFORMATION,*PREG_CREATE_KEY_INFORMATION, *PREG_OPEN_KEY_INFORMATION; + +typedef struct _REG_CREATE_KEY_INFORMATION_V1 { + PUNICODE_STRING CompleteName; + PVOID RootObject; + PVOID ObjectType; + ULONG Options; + PUNICODE_STRING Class; + PVOID SecurityDescriptor; + PVOID SecurityQualityOfService; + ACCESS_MASK DesiredAccess; + ACCESS_MASK GrantedAccess; + PULONG Disposition; + PVOID *ResultObject; + PVOID CallContext; + PVOID RootObjectContext; + PVOID Transaction; + ULONG_PTR Version; + PUNICODE_STRING RemainingName; + ULONG Wow64Flags; + ULONG Attributes; + KPROCESSOR_MODE CheckAccessMode; +} REG_CREATE_KEY_INFORMATION_V1, REG_OPEN_KEY_INFORMATION_V1,*PREG_CREATE_KEY_INFORMATION_V1, *PREG_OPEN_KEY_INFORMATION_V1; + typedef struct _REG_PRE_CREATE_KEY_INFORMATION { PUNICODE_STRING CompleteName; } REG_PRE_CREATE_KEY_INFORMATION, REG_PRE_OPEN_KEY_INFORMATION,*PREG_PRE_CREATE_KEY_INFORMATION, *PREG_PRE_OPEN_KEY_INFORMATION;; @@ -2850,151 +3548,180 @@ typedef struct _REG_KEY_HANDLE_CLOSE_INFORMATION { PVOID Reserved; } REG_KEY_HANDLE_CLOSE_INFORMATION, *PREG_KEY_HANDLE_CLOSE_INFORMATION; +#if (NTDDI_VERSION >= NTDDI_VISTA) + +typedef struct _REG_LOAD_KEY_INFORMATION { + PVOID Object; + PUNICODE_STRING KeyName; + PUNICODE_STRING SourceFile; + ULONG Flags; + PVOID TrustClassObject; + PVOID UserEvent; + ACCESS_MASK DesiredAccess; + PHANDLE RootHandle; + PVOID CallContext; + PVOID ObjectContext; + PVOID Reserved; +} REG_LOAD_KEY_INFORMATION, *PREG_LOAD_KEY_INFORMATION; + +typedef struct _REG_UNLOAD_KEY_INFORMATION { + PVOID Object; + PVOID UserEvent; + PVOID CallContext; + PVOID ObjectContext; + PVOID Reserved; +} REG_UNLOAD_KEY_INFORMATION, *PREG_UNLOAD_KEY_INFORMATION; + +typedef struct _REG_CALLBACK_CONTEXT_CLEANUP_INFORMATION { + PVOID Object; + PVOID ObjectContext; + PVOID Reserved; +} REG_CALLBACK_CONTEXT_CLEANUP_INFORMATION, *PREG_CALLBACK_CONTEXT_CLEANUP_INFORMATION; + +typedef struct _REG_QUERY_KEY_SECURITY_INFORMATION { + PVOID Object; + PSECURITY_INFORMATION SecurityInformation; + PSECURITY_DESCRIPTOR SecurityDescriptor; + PULONG Length; + PVOID CallContext; + PVOID ObjectContext; + PVOID Reserved; +} REG_QUERY_KEY_SECURITY_INFORMATION, *PREG_QUERY_KEY_SECURITY_INFORMATION; + +typedef struct _REG_SET_KEY_SECURITY_INFORMATION { + PVOID Object; + PSECURITY_INFORMATION SecurityInformation; + PSECURITY_DESCRIPTOR SecurityDescriptor; + PVOID CallContext; + PVOID ObjectContext; + PVOID Reserved; +} REG_SET_KEY_SECURITY_INFORMATION, *PREG_SET_KEY_SECURITY_INFORMATION; + +typedef struct _REG_RESTORE_KEY_INFORMATION { + PVOID Object; + HANDLE FileHandle; + ULONG Flags; + PVOID CallContext; + PVOID ObjectContext; + PVOID Reserved; +} REG_RESTORE_KEY_INFORMATION, *PREG_RESTORE_KEY_INFORMATION; + +typedef struct _REG_SAVE_KEY_INFORMATION { + PVOID Object; + HANDLE FileHandle; + ULONG Format; + PVOID CallContext; + PVOID ObjectContext; + PVOID Reserved; +} REG_SAVE_KEY_INFORMATION, *PREG_SAVE_KEY_INFORMATION; + +typedef struct _REG_REPLACE_KEY_INFORMATION { + PVOID Object; + PUNICODE_STRING OldFileName; + PUNICODE_STRING NewFileName; + PVOID CallContext; + PVOID ObjectContext; + PVOID Reserved; +} REG_REPLACE_KEY_INFORMATION, *PREG_REPLACE_KEY_INFORMATION; + +#endif /* NTDDI_VERSION >= NTDDI_VISTA */ + +#define SERVICE_KERNEL_DRIVER 0x00000001 +#define SERVICE_FILE_SYSTEM_DRIVER 0x00000002 +#define SERVICE_ADAPTER 0x00000004 +#define SERVICE_RECOGNIZER_DRIVER 0x00000008 + +#define SERVICE_DRIVER (SERVICE_KERNEL_DRIVER | \ + SERVICE_FILE_SYSTEM_DRIVER | \ + SERVICE_RECOGNIZER_DRIVER) + +#define SERVICE_WIN32_OWN_PROCESS 0x00000010 +#define SERVICE_WIN32_SHARE_PROCESS 0x00000020 +#define SERVICE_WIN32 (SERVICE_WIN32_OWN_PROCESS | \ + SERVICE_WIN32_SHARE_PROCESS) + +#define SERVICE_INTERACTIVE_PROCESS 0x00000100 + +#define SERVICE_TYPE_ALL (SERVICE_WIN32 | \ + SERVICE_ADAPTER | \ + SERVICE_DRIVER | \ + SERVICE_INTERACTIVE_PROCESS) + +/* Service Start Types */ +#define SERVICE_BOOT_START 0x00000000 +#define SERVICE_SYSTEM_START 0x00000001 +#define SERVICE_AUTO_START 0x00000002 +#define SERVICE_DEMAND_START 0x00000003 +#define SERVICE_DISABLED 0x00000004 + +#define SERVICE_ERROR_IGNORE 0x00000000 +#define SERVICE_ERROR_NORMAL 0x00000001 +#define SERVICE_ERROR_SEVERE 0x00000002 +#define SERVICE_ERROR_CRITICAL 0x00000003 + +typedef enum _CM_SERVICE_NODE_TYPE { + DriverType = SERVICE_KERNEL_DRIVER, + FileSystemType = SERVICE_FILE_SYSTEM_DRIVER, + Win32ServiceOwnProcess = SERVICE_WIN32_OWN_PROCESS, + Win32ServiceShareProcess = SERVICE_WIN32_SHARE_PROCESS, + AdapterType = SERVICE_ADAPTER, + RecognizerType = SERVICE_RECOGNIZER_DRIVER +} SERVICE_NODE_TYPE; + +typedef enum _CM_SERVICE_LOAD_TYPE { + BootLoad = SERVICE_BOOT_START, + SystemLoad = SERVICE_SYSTEM_START, + AutoLoad = SERVICE_AUTO_START, + DemandLoad = SERVICE_DEMAND_START, + DisableLoad = SERVICE_DISABLED +} SERVICE_LOAD_TYPE; + +typedef enum _CM_ERROR_CONTROL_TYPE { + IgnoreError = SERVICE_ERROR_IGNORE, + NormalError = SERVICE_ERROR_NORMAL, + SevereError = SERVICE_ERROR_SEVERE, + CriticalError = SERVICE_ERROR_CRITICAL +} SERVICE_ERROR_TYPE; + +#define CM_SERVICE_NETWORK_BOOT_LOAD 0x00000001 +#define CM_SERVICE_VIRTUAL_DISK_BOOT_LOAD 0x00000002 +#define CM_SERVICE_USB_DISK_BOOT_LOAD 0x00000004 + +#define CM_SERVICE_VALID_PROMOTION_MASK (CM_SERVICE_NETWORK_BOOT_LOAD | \ + CM_SERVICE_VIRTUAL_DISK_BOOT_LOAD | \ + CM_SERVICE_USB_DISK_BOOT_LOAD) + /****************************************************************************** * I/O Manager Types * ******************************************************************************/ - /* PCI_COMMON_CONFIG.Command */ -#define PCI_ENABLE_IO_SPACE 0x0001 -#define PCI_ENABLE_MEMORY_SPACE 0x0002 -#define PCI_ENABLE_BUS_MASTER 0x0004 -#define PCI_ENABLE_SPECIAL_CYCLES 0x0008 -#define PCI_ENABLE_WRITE_AND_INVALIDATE 0x0010 -#define PCI_ENABLE_VGA_COMPATIBLE_PALETTE 0x0020 -#define PCI_ENABLE_PARITY 0x0040 -#define PCI_ENABLE_WAIT_CYCLE 0x0080 -#define PCI_ENABLE_SERR 0x0100 -#define PCI_ENABLE_FAST_BACK_TO_BACK 0x0200 -#define PCI_DISABLE_LEVEL_INTERRUPT 0x0400 +#define WDM_MAJORVERSION 0x06 +#define WDM_MINORVERSION 0x00 -/* PCI_COMMON_CONFIG.Status */ -#define PCI_STATUS_INTERRUPT_PENDING 0x0008 -#define PCI_STATUS_CAPABILITIES_LIST 0x0010 -#define PCI_STATUS_66MHZ_CAPABLE 0x0020 -#define PCI_STATUS_UDF_SUPPORTED 0x0040 -#define PCI_STATUS_FAST_BACK_TO_BACK 0x0080 -#define PCI_STATUS_DATA_PARITY_DETECTED 0x0100 -#define PCI_STATUS_DEVSEL 0x0600 -#define PCI_STATUS_SIGNALED_TARGET_ABORT 0x0800 -#define PCI_STATUS_RECEIVED_TARGET_ABORT 0x1000 -#define PCI_STATUS_RECEIVED_MASTER_ABORT 0x2000 -#define PCI_STATUS_SIGNALED_SYSTEM_ERROR 0x4000 -#define PCI_STATUS_DETECTED_PARITY_ERROR 0x8000 +#if defined(_WIN64) -/* PCI_COMMON_CONFIG.HeaderType */ -#define PCI_MULTIFUNCTION 0x80 -#define PCI_DEVICE_TYPE 0x00 -#define PCI_BRIDGE_TYPE 0x01 -#define PCI_CARDBUS_BRIDGE_TYPE 0x02 +#ifndef USE_DMA_MACROS +#define USE_DMA_MACROS +#endif -#define PCI_CONFIGURATION_TYPE(PciData) \ - (((PPCI_COMMON_CONFIG) (PciData))->HeaderType & ~PCI_MULTIFUNCTION) +#ifndef NO_LEGACY_DRIVERS +#define NO_LEGACY_DRIVERS +#endif -#define PCI_MULTIFUNCTION_DEVICE(PciData) \ - ((((PPCI_COMMON_CONFIG) (PciData))->HeaderType & PCI_MULTIFUNCTION) != 0) +#endif /* defined(_WIN64) */ -/* PCI device classes */ -#define PCI_CLASS_PRE_20 0x00 -#define PCI_CLASS_MASS_STORAGE_CTLR 0x01 -#define PCI_CLASS_NETWORK_CTLR 0x02 -#define PCI_CLASS_DISPLAY_CTLR 0x03 -#define PCI_CLASS_MULTIMEDIA_DEV 0x04 -#define PCI_CLASS_MEMORY_CTLR 0x05 -#define PCI_CLASS_BRIDGE_DEV 0x06 -#define PCI_CLASS_SIMPLE_COMMS_CTLR 0x07 -#define PCI_CLASS_BASE_SYSTEM_DEV 0x08 -#define PCI_CLASS_INPUT_DEV 0x09 -#define PCI_CLASS_DOCKING_STATION 0x0a -#define PCI_CLASS_PROCESSOR 0x0b -#define PCI_CLASS_SERIAL_BUS_CTLR 0x0c -#define PCI_CLASS_WIRELESS_CTLR 0x0d -#define PCI_CLASS_INTELLIGENT_IO_CTLR 0x0e -#define PCI_CLASS_SATELLITE_COMMS_CTLR 0x0f -#define PCI_CLASS_ENCRYPTION_DECRYPTION 0x10 -#define PCI_CLASS_DATA_ACQ_SIGNAL_PROC 0x11 +#define STATUS_CONTINUE_COMPLETION STATUS_SUCCESS -/* PCI device subclasses for class 0 */ -#define PCI_SUBCLASS_PRE_20_NON_VGA 0x00 -#define PCI_SUBCLASS_PRE_20_VGA 0x01 - -/* PCI device subclasses for class 1 (mass storage controllers)*/ -#define PCI_SUBCLASS_MSC_SCSI_BUS_CTLR 0x00 -#define PCI_SUBCLASS_MSC_IDE_CTLR 0x01 -#define PCI_SUBCLASS_MSC_FLOPPY_CTLR 0x02 -#define PCI_SUBCLASS_MSC_IPI_CTLR 0x03 -#define PCI_SUBCLASS_MSC_RAID_CTLR 0x04 -#define PCI_SUBCLASS_MSC_OTHER 0x80 - -/* PCI device subclasses for class 2 (network controllers)*/ -#define PCI_SUBCLASS_NET_ETHERNET_CTLR 0x00 -#define PCI_SUBCLASS_NET_TOKEN_RING_CTLR 0x01 -#define PCI_SUBCLASS_NET_FDDI_CTLR 0x02 -#define PCI_SUBCLASS_NET_ATM_CTLR 0x03 -#define PCI_SUBCLASS_NET_ISDN_CTLR 0x04 -#define PCI_SUBCLASS_NET_OTHER 0x80 - -/* PCI device subclasses for class 3 (display controllers)*/ -#define PCI_SUBCLASS_VID_VGA_CTLR 0x00 -#define PCI_SUBCLASS_VID_XGA_CTLR 0x01 -#define PCI_SUBCLASS_VID_3D_CTLR 0x02 -#define PCI_SUBCLASS_VID_OTHER 0x80 - -/* PCI device subclasses for class 4 (multimedia device)*/ -#define PCI_SUBCLASS_MM_VIDEO_DEV 0x00 -#define PCI_SUBCLASS_MM_AUDIO_DEV 0x01 -#define PCI_SUBCLASS_MM_TELEPHONY_DEV 0x02 -#define PCI_SUBCLASS_MM_OTHER 0x80 - -/* PCI device subclasses for class 5 (memory controller)*/ -#define PCI_SUBCLASS_MEM_RAM 0x00 -#define PCI_SUBCLASS_MEM_FLASH 0x01 -#define PCI_SUBCLASS_MEM_OTHER 0x80 - -/* PCI device subclasses for class 6 (bridge device)*/ -#define PCI_SUBCLASS_BR_HOST 0x00 -#define PCI_SUBCLASS_BR_ISA 0x01 -#define PCI_SUBCLASS_BR_EISA 0x02 -#define PCI_SUBCLASS_BR_MCA 0x03 -#define PCI_SUBCLASS_BR_PCI_TO_PCI 0x04 -#define PCI_SUBCLASS_BR_PCMCIA 0x05 -#define PCI_SUBCLASS_BR_NUBUS 0x06 -#define PCI_SUBCLASS_BR_CARDBUS 0x07 -#define PCI_SUBCLASS_BR_RACEWAY 0x08 -#define PCI_SUBCLASS_BR_OTHER 0x80 - -/* PCI device subclasses for class C (serial bus controller)*/ -#define PCI_SUBCLASS_SB_IEEE1394 0x00 -#define PCI_SUBCLASS_SB_ACCESS 0x01 -#define PCI_SUBCLASS_SB_SSA 0x02 -#define PCI_SUBCLASS_SB_USB 0x03 -#define PCI_SUBCLASS_SB_FIBRE_CHANNEL 0x04 -#define PCI_SUBCLASS_SB_SMBUS 0x05 - -#define PCI_MAX_DEVICES 32 -#define PCI_MAX_FUNCTION 8 -#define PCI_MAX_BRIDGE_NUMBER 0xFF -#define PCI_INVALID_VENDORID 0xFFFF -#define PCI_COMMON_HDR_LENGTH (FIELD_OFFSET(PCI_COMMON_CONFIG, DeviceSpecific)) - -#define PCI_ADDRESS_IO_SPACE 0x00000001 -#define PCI_ADDRESS_MEMORY_TYPE_MASK 0x00000006 -#define PCI_ADDRESS_MEMORY_PREFETCHABLE 0x00000008 -#define PCI_ADDRESS_IO_ADDRESS_MASK 0xfffffffc -#define PCI_ADDRESS_MEMORY_ADDRESS_MASK 0xfffffff0 -#define PCI_ADDRESS_ROM_ADDRESS_MASK 0xfffff800 - -#define PCI_TYPE_32BIT 0 -#define PCI_TYPE_20BIT 2 -#define PCI_TYPE_64BIT 4 +#define CONNECT_FULLY_SPECIFIED 0x1 +#define CONNECT_LINE_BASED 0x2 +#define CONNECT_MESSAGE_BASED 0x3 +#define CONNECT_FULLY_SPECIFIED_GROUP 0x4 +#define CONNECT_CURRENT_VERSION 0x4 #define POOL_COLD_ALLOCATION 256 #define POOL_QUOTA_FAIL_INSTEAD_OF_RAISE 8 #define POOL_RAISE_IF_ALLOCATION_FAILURE 16 -#define PCI_TYPE0_ADDRESSES 6 -#define PCI_TYPE1_ADDRESSES 2 -#define PCI_TYPE2_ADDRESSES 5 - #define IO_TYPE_ADAPTER 1 #define IO_TYPE_CONTROLLER 2 #define IO_TYPE_DEVICE 3 @@ -3018,47 +3745,6 @@ typedef struct _REG_KEY_HANDLE_CLOSE_INFORMATION { #define IO_RESOURCE_DEFAULT 0x02 #define IO_RESOURCE_ALTERNATIVE 0x08 -/* DEVICE_OBJECT.Flags */ -#define DO_VERIFY_VOLUME 0x00000002 -#define DO_BUFFERED_IO 0x00000004 -#define DO_EXCLUSIVE 0x00000008 -#define DO_DIRECT_IO 0x00000010 -#define DO_MAP_IO_BUFFER 0x00000020 -#define DO_DEVICE_INITIALIZING 0x00000080 -#define DO_SHUTDOWN_REGISTERED 0x00000800 -#define DO_BUS_ENUMERATED_DEVICE 0x00001000 -#define DO_POWER_PAGABLE 0x00002000 -#define DO_POWER_INRUSH 0x00004000 - -/* DEVICE_OBJECT.Characteristics */ -#define FILE_REMOVABLE_MEDIA 0x00000001 -#define FILE_READ_ONLY_DEVICE 0x00000002 -#define FILE_FLOPPY_DISKETTE 0x00000004 -#define FILE_WRITE_ONCE_MEDIA 0x00000008 -#define FILE_REMOTE_DEVICE 0x00000010 -#define FILE_DEVICE_IS_MOUNTED 0x00000020 -#define FILE_VIRTUAL_VOLUME 0x00000040 -#define FILE_AUTOGENERATED_DEVICE_NAME 0x00000080 -#define FILE_DEVICE_SECURE_OPEN 0x00000100 -#define FILE_CHARACTERISTIC_PNP_DEVICE 0x00000800 -#define FILE_CHARACTERISTIC_TS_DEVICE 0x00001000 -#define FILE_CHARACTERISTIC_WEBDAV_DEVICE 0x00002000 - -/* DEVICE_OBJECT.AlignmentRequirement */ -#define FILE_BYTE_ALIGNMENT 0x00000000 -#define FILE_WORD_ALIGNMENT 0x00000001 -#define FILE_LONG_ALIGNMENT 0x00000003 -#define FILE_QUAD_ALIGNMENT 0x00000007 -#define FILE_OCTA_ALIGNMENT 0x0000000f -#define FILE_32_BYTE_ALIGNMENT 0x0000001f -#define FILE_64_BYTE_ALIGNMENT 0x0000003f -#define FILE_128_BYTE_ALIGNMENT 0x0000007f -#define FILE_256_BYTE_ALIGNMENT 0x000000ff -#define FILE_512_BYTE_ALIGNMENT 0x000001ff - -/* DEVICE_OBJECT.DeviceType */ -#define DEVICE_TYPE ULONG - #define FILE_DEVICE_BEEP 0x00000001 #define FILE_DEVICE_CD_ROM 0x00000002 #define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003 @@ -3127,6 +3813,44 @@ typedef struct _REG_KEY_HANDLE_CLOSE_INFORMATION { #define FILE_DEVICE_BIOMETRIC 0x00000044 #define FILE_DEVICE_PMI 0x00000045 +#if defined(NT_PROCESSOR_GROUPS) + +typedef USHORT IRQ_DEVICE_POLICY, *PIRQ_DEVICE_POLICY; + +typedef enum _IRQ_DEVICE_POLICY_USHORT { + IrqPolicyMachineDefault = 0, + IrqPolicyAllCloseProcessors = 1, + IrqPolicyOneCloseProcessor = 2, + IrqPolicyAllProcessorsInMachine = 3, + IrqPolicyAllProcessorsInGroup = 3, + IrqPolicySpecifiedProcessors = 4, + IrqPolicySpreadMessagesAcrossAllProcessors = 5}; + +#else /* defined(NT_PROCESSOR_GROUPS) */ + +typedef enum _IRQ_DEVICE_POLICY { + IrqPolicyMachineDefault = 0, + IrqPolicyAllCloseProcessors, + IrqPolicyOneCloseProcessor, + IrqPolicyAllProcessorsInMachine, + IrqPolicySpecifiedProcessors, + IrqPolicySpreadMessagesAcrossAllProcessors +} IRQ_DEVICE_POLICY, *PIRQ_DEVICE_POLICY; + +#endif + +typedef enum _IRQ_PRIORITY { + IrqPriorityUndefined = 0, + IrqPriorityLow, + IrqPriorityNormal, + IrqPriorityHigh +} IRQ_PRIORITY, *PIRQ_PRIORITY; + +typedef enum _IRQ_GROUP_POLICY { + GroupAffinityAllGroupZero = 0, + GroupAffinityDontCare +} IRQ_GROUP_POLICY, *PIRQ_GROUP_POLICY; + #define MAXIMUM_VOLUME_LABEL_LENGTH (32 * sizeof(WCHAR)) typedef struct _OBJECT_HANDLE_INFORMATION { @@ -3139,10 +3863,6 @@ typedef struct _CLIENT_ID { HANDLE UniqueThread; } CLIENT_ID, *PCLIENT_ID; -typedef VOID -(NTAPI *PKSTART_ROUTINE)( - IN PVOID StartContext); - typedef struct _VPB { CSHORT Type; CSHORT Size; @@ -3179,6 +3899,47 @@ typedef struct _WAIT_CONTEXT_BLOCK { PKDPC BufferChainingDpc; } WAIT_CONTEXT_BLOCK, *PWAIT_CONTEXT_BLOCK; +/* DEVICE_OBJECT.Flags */ +#define DO_VERIFY_VOLUME 0x00000002 +#define DO_BUFFERED_IO 0x00000004 +#define DO_EXCLUSIVE 0x00000008 +#define DO_DIRECT_IO 0x00000010 +#define DO_MAP_IO_BUFFER 0x00000020 +#define DO_DEVICE_INITIALIZING 0x00000080 +#define DO_SHUTDOWN_REGISTERED 0x00000800 +#define DO_BUS_ENUMERATED_DEVICE 0x00001000 +#define DO_POWER_PAGABLE 0x00002000 +#define DO_POWER_INRUSH 0x00004000 + +/* DEVICE_OBJECT.Characteristics */ +#define FILE_REMOVABLE_MEDIA 0x00000001 +#define FILE_READ_ONLY_DEVICE 0x00000002 +#define FILE_FLOPPY_DISKETTE 0x00000004 +#define FILE_WRITE_ONCE_MEDIA 0x00000008 +#define FILE_REMOTE_DEVICE 0x00000010 +#define FILE_DEVICE_IS_MOUNTED 0x00000020 +#define FILE_VIRTUAL_VOLUME 0x00000040 +#define FILE_AUTOGENERATED_DEVICE_NAME 0x00000080 +#define FILE_DEVICE_SECURE_OPEN 0x00000100 +#define FILE_CHARACTERISTIC_PNP_DEVICE 0x00000800 +#define FILE_CHARACTERISTIC_TS_DEVICE 0x00001000 +#define FILE_CHARACTERISTIC_WEBDAV_DEVICE 0x00002000 + +/* DEVICE_OBJECT.AlignmentRequirement */ +#define FILE_BYTE_ALIGNMENT 0x00000000 +#define FILE_WORD_ALIGNMENT 0x00000001 +#define FILE_LONG_ALIGNMENT 0x00000003 +#define FILE_QUAD_ALIGNMENT 0x00000007 +#define FILE_OCTA_ALIGNMENT 0x0000000f +#define FILE_32_BYTE_ALIGNMENT 0x0000001f +#define FILE_64_BYTE_ALIGNMENT 0x0000003f +#define FILE_128_BYTE_ALIGNMENT 0x0000007f +#define FILE_256_BYTE_ALIGNMENT 0x000000ff +#define FILE_512_BYTE_ALIGNMENT 0x000001ff + +/* DEVICE_OBJECT.DeviceType */ +#define DEVICE_TYPE ULONG + typedef struct _DEVICE_OBJECT { CSHORT Type; USHORT Size; @@ -3210,6 +3971,153 @@ typedef struct _DEVICE_OBJECT { PVOID Reserved; } DEVICE_OBJECT, *PDEVICE_OBJECT; +typedef enum _IO_SESSION_STATE { + IoSessionStateCreated = 1, + IoSessionStateInitialized, + IoSessionStateConnected, + IoSessionStateDisconnected, + IoSessionStateDisconnectedLoggedOn, + IoSessionStateLoggedOn, + IoSessionStateLoggedOff, + IoSessionStateTerminated, + IoSessionStateMax +} IO_SESSION_STATE, *PIO_SESSION_STATE; + +typedef enum _IO_COMPLETION_ROUTINE_RESULT { + ContinueCompletion = STATUS_CONTINUE_COMPLETION, + StopCompletion = STATUS_MORE_PROCESSING_REQUIRED +} IO_COMPLETION_ROUTINE_RESULT, *PIO_COMPLETION_ROUTINE_RESULT; + +typedef struct _IO_INTERRUPT_MESSAGE_INFO_ENTRY { + PHYSICAL_ADDRESS MessageAddress; + KAFFINITY TargetProcessorSet; + PKINTERRUPT InterruptObject; + ULONG MessageData; + ULONG Vector; + KIRQL Irql; + KINTERRUPT_MODE Mode; + KINTERRUPT_POLARITY Polarity; +} IO_INTERRUPT_MESSAGE_INFO_ENTRY, *PIO_INTERRUPT_MESSAGE_INFO_ENTRY; + +typedef struct _IO_INTERRUPT_MESSAGE_INFO { + KIRQL UnifiedIrql; + ULONG MessageCount; + IO_INTERRUPT_MESSAGE_INFO_ENTRY MessageInfo[1]; +} IO_INTERRUPT_MESSAGE_INFO, *PIO_INTERRUPT_MESSAGE_INFO; + +typedef struct _IO_CONNECT_INTERRUPT_FULLY_SPECIFIED_PARAMETERS { + IN PDEVICE_OBJECT PhysicalDeviceObject; + OUT PKINTERRUPT *InterruptObject; + IN PKSERVICE_ROUTINE ServiceRoutine; + IN PVOID ServiceContext; + IN PKSPIN_LOCK SpinLock OPTIONAL; + IN KIRQL SynchronizeIrql; + IN BOOLEAN FloatingSave; + IN BOOLEAN ShareVector; + IN ULONG Vector; + IN KIRQL Irql; + IN KINTERRUPT_MODE InterruptMode; + IN KAFFINITY ProcessorEnableMask; + IN USHORT Group; +} IO_CONNECT_INTERRUPT_FULLY_SPECIFIED_PARAMETERS, *PIO_CONNECT_INTERRUPT_FULLY_SPECIFIED_PARAMETERS; + +typedef struct _IO_CONNECT_INTERRUPT_LINE_BASED_PARAMETERS { + IN PDEVICE_OBJECT PhysicalDeviceObject; + OUT PKINTERRUPT *InterruptObject; + IN PKSERVICE_ROUTINE ServiceRoutine; + IN PVOID ServiceContext; + IN PKSPIN_LOCK SpinLock OPTIONAL; + IN KIRQL SynchronizeIrql OPTIONAL; + IN BOOLEAN FloatingSave; +} IO_CONNECT_INTERRUPT_LINE_BASED_PARAMETERS, *PIO_CONNECT_INTERRUPT_LINE_BASED_PARAMETERS; + +typedef struct _IO_CONNECT_INTERRUPT_MESSAGE_BASED_PARAMETERS { + IN PDEVICE_OBJECT PhysicalDeviceObject; + union { + OUT PVOID *Generic; + OUT PIO_INTERRUPT_MESSAGE_INFO *InterruptMessageTable; + OUT PKINTERRUPT *InterruptObject; + } ConnectionContext; + IN PKMESSAGE_SERVICE_ROUTINE MessageServiceRoutine; + IN PVOID ServiceContext; + IN PKSPIN_LOCK SpinLock OPTIONAL; + IN KIRQL SynchronizeIrql OPTIONAL; + IN BOOLEAN FloatingSave; + IN PKSERVICE_ROUTINE FallBackServiceRoutine OPTIONAL; +} IO_CONNECT_INTERRUPT_MESSAGE_BASED_PARAMETERS, *PIO_CONNECT_INTERRUPT_MESSAGE_BASED_PARAMETERS; + +typedef struct _IO_CONNECT_INTERRUPT_PARAMETERS { + IN OUT ULONG Version; + union { + IO_CONNECT_INTERRUPT_FULLY_SPECIFIED_PARAMETERS FullySpecified; + IO_CONNECT_INTERRUPT_LINE_BASED_PARAMETERS LineBased; + IO_CONNECT_INTERRUPT_MESSAGE_BASED_PARAMETERS MessageBased; + }; +} IO_CONNECT_INTERRUPT_PARAMETERS, *PIO_CONNECT_INTERRUPT_PARAMETERS; + +typedef struct _IO_DISCONNECT_INTERRUPT_PARAMETERS { + IN ULONG Version; + union { + IN PVOID Generic; + IN PKINTERRUPT InterruptObject; + IN PIO_INTERRUPT_MESSAGE_INFO InterruptMessageTable; + } ConnectionContext; +} IO_DISCONNECT_INTERRUPT_PARAMETERS, *PIO_DISCONNECT_INTERRUPT_PARAMETERS; + +typedef enum _IO_ACCESS_TYPE { + ReadAccess, + WriteAccess, + ModifyAccess +} IO_ACCESS_TYPE; + +typedef enum _IO_ACCESS_MODE { + SequentialAccess, + RandomAccess +} IO_ACCESS_MODE; + +typedef enum _IO_CONTAINER_NOTIFICATION_CLASS { + IoSessionStateNotification, + IoMaxContainerNotificationClass +} IO_CONTAINER_NOTIFICATION_CLASS; + +typedef struct _IO_SESSION_STATE_NOTIFICATION { + ULONG Size; + ULONG Flags; + PVOID IoObject; + ULONG EventMask; + PVOID Context; +} IO_SESSION_STATE_NOTIFICATION, *PIO_SESSION_STATE_NOTIFICATION; + +typedef enum _IO_CONTAINER_INFORMATION_CLASS { + IoSessionStateInformation, + IoMaxContainerInformationClass +} IO_CONTAINER_INFORMATION_CLASS; + +typedef struct _IO_SESSION_STATE_INFORMATION { + ULONG SessionId; + IO_SESSION_STATE SessionState; + BOOLEAN LocalSession; +} IO_SESSION_STATE_INFORMATION, *PIO_SESSION_STATE_INFORMATION; + +#if (NTDDI_VERSION >= NTDDI_WIN7) + +typedef NTSTATUS +(NTAPI *PIO_CONTAINER_NOTIFICATION_FUNCTION)( + VOID); + +typedef NTSTATUS +(NTAPI IO_SESSION_NOTIFICATION_FUNCTION)( + IN PVOID SessionObject, + IN PVOID IoObject, + IN ULONG Event, + IN PVOID Context, + IN PVOID NotificationPayload, + IN ULONG PayloadLength); + +typedef IO_SESSION_NOTIFICATION_FUNCTION *PIO_SESSION_NOTIFICATION_FUNCTION; + +#endif + typedef struct _IO_REMOVE_LOCK_TRACKING_BLOCK * PIO_REMOVE_LOCK_TRACKING_BLOCK; typedef struct _IO_REMOVE_LOCK_COMMON_BLOCK { @@ -3338,22 +4246,6 @@ typedef struct _SHARE_ACCESS { } type2; \ } u; -typedef struct _PCI_COMMON_HEADER { - PCI_COMMON_HEADER_LAYOUT -} PCI_COMMON_HEADER, *PPCI_COMMON_HEADER; - -#ifdef __cplusplus -typedef struct _PCI_COMMON_CONFIG { - PCI_COMMON_HEADER_LAYOUT - UCHAR DeviceSpecific[192]; -} PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG; -#else -typedef struct _PCI_COMMON_CONFIG { - PCI_COMMON_HEADER DUMMYSTRUCTNAME; - UCHAR DeviceSpecific[192]; -} PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG; -#endif - typedef enum _CREATE_FILE_TYPE { CreateFileTypeNone, CreateFileTypeNamedPipe, @@ -3374,16 +4266,12 @@ typedef struct _IO_STATUS_BLOCK { ULONG_PTR Information; } IO_STATUS_BLOCK, *PIO_STATUS_BLOCK; -typedef struct _PCI_SLOT_NUMBER { - union { - struct { - ULONG DeviceNumber : 5; - ULONG FunctionNumber : 3; - ULONG Reserved : 24; - } bits; - ULONG AsULONG; - } u; -} PCI_SLOT_NUMBER, *PPCI_SLOT_NUMBER; +#if defined(_WIN64) +typedef struct _IO_STATUS_BLOCK32 { + NTSTATUS Status; + ULONG Information; +} IO_STATUS_BLOCK32, *PIO_STATUS_BLOCK32; +#endif typedef VOID (NTAPI *PIO_APC_ROUTINE)( @@ -3391,16 +4279,35 @@ typedef VOID IN PIO_STATUS_BLOCK IoStatusBlock, IN ULONG Reserved); -typedef VOID -(NTAPI *WMI_NOTIFICATION_CALLBACK)( - PVOID Wnode, - PVOID Context); +#define PIO_APC_ROUTINE_DEFINED -#define WMIREG_ACTION_REGISTER 1 -#define WMIREG_ACTION_DEREGISTER 2 -#define WMIREG_ACTION_REREGISTER 3 -#define WMIREG_ACTION_UPDATE_GUIDS 4 -#define WMIREG_ACTION_BLOCK_IRPS 5 +typedef enum _IO_SESSION_EVENT { + IoSessionEventIgnore = 0, + IoSessionEventCreated, + IoSessionEventTerminated, + IoSessionEventConnected, + IoSessionEventDisconnected, + IoSessionEventLogon, + IoSessionEventLogoff, + IoSessionEventMax +} IO_SESSION_EVENT, *PIO_SESSION_EVENT; + +#define IO_SESSION_STATE_ALL_EVENTS 0xffffffff +#define IO_SESSION_STATE_CREATION_EVENT 0x00000001 +#define IO_SESSION_STATE_TERMINATION_EVENT 0x00000002 +#define IO_SESSION_STATE_CONNECT_EVENT 0x00000004 +#define IO_SESSION_STATE_DISCONNECT_EVENT 0x00000008 +#define IO_SESSION_STATE_LOGON_EVENT 0x00000010 +#define IO_SESSION_STATE_LOGOFF_EVENT 0x00000020 + +#define IO_SESSION_STATE_VALID_EVENT_MASK 0x0000003f + +#define IO_SESSION_MAX_PAYLOAD_SIZE 256L + +typedef struct _IO_SESSION_CONNECT_INFO { + ULONG SessionId; + BOOLEAN LocalSession; +} IO_SESSION_CONNECT_INFO, *PIO_SESSION_CONNECT_INFO; #define EVENT_INCREMENT 1 #define IO_NO_INCREMENT 0 @@ -3469,6 +4376,7 @@ typedef struct _BOOTDISK_INFORMATION_LITE { #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ +#include typedef struct _EISA_MEMORY_TYPE { UCHAR ReadWrite : 1; @@ -3480,7 +4388,6 @@ typedef struct _EISA_MEMORY_TYPE { UCHAR MoreEntries : 1; } EISA_MEMORY_TYPE, *PEISA_MEMORY_TYPE; -#include typedef struct _EISA_MEMORY_CONFIGURATION { EISA_MEMORY_TYPE ConfigurationByte; UCHAR DataSize; @@ -3488,7 +4395,6 @@ typedef struct _EISA_MEMORY_CONFIGURATION { UCHAR AddressHighByte; USHORT MemorySize; } EISA_MEMORY_CONFIGURATION, *PEISA_MEMORY_CONFIGURATION; -#include typedef struct _EISA_IRQ_DESCRIPTOR { UCHAR Interrupt : 4; @@ -3522,7 +4428,6 @@ typedef struct _EISA_DMA_CONFIGURATION { DMA_CONFIGURATION_BYTE1 ConfigurationByte1; } EISA_DMA_CONFIGURATION, *PEISA_DMA_CONFIGURATION; -#include typedef struct _EISA_PORT_DESCRIPTOR { UCHAR NumberPorts : 5; UCHAR Reserved : 1; @@ -3534,7 +4439,17 @@ typedef struct _EISA_PORT_CONFIGURATION { EISA_PORT_DESCRIPTOR Configuration; USHORT PortAddress; } EISA_PORT_CONFIGURATION, *PEISA_PORT_CONFIGURATION; -#include + +typedef struct _CM_EISA_SLOT_INFORMATION { + UCHAR ReturnCode; + UCHAR ReturnFlags; + UCHAR MajorRevision; + UCHAR MinorRevision; + USHORT Checksum; + UCHAR NumberFunctions; + UCHAR FunctionInformation; + ULONG CompressedId; +} CM_EISA_SLOT_INFORMATION, *PCM_EISA_SLOT_INFORMATION; typedef struct _CM_EISA_FUNCTION_INFORMATION { ULONG CompressedId; @@ -3552,6 +4467,8 @@ typedef struct _CM_EISA_FUNCTION_INFORMATION { UCHAR InitializationData[60]; } CM_EISA_FUNCTION_INFORMATION, *PCM_EISA_FUNCTION_INFORMATION; +#include + /* CM_EISA_FUNCTION_INFORMATION.FunctionFlags */ #define EISA_FUNCTION_ENABLED 0x80 @@ -3566,16 +4483,9 @@ typedef struct _CM_EISA_FUNCTION_INFORMATION { (EISA_HAS_PORT_RANGE + EISA_HAS_DMA_ENTRY + EISA_HAS_IRQ_ENTRY \ + EISA_HAS_MEMORY_ENTRY + EISA_HAS_TYPE_ENTRY) -typedef struct _CM_EISA_SLOT_INFORMATION { - UCHAR ReturnCode; - UCHAR ReturnFlags; - UCHAR MajorRevision; - UCHAR MinorRevision; - USHORT Checksum; - UCHAR NumberFunctions; - UCHAR FunctionInformation; - ULONG CompressedId; -} CM_EISA_SLOT_INFORMATION, *PCM_EISA_SLOT_INFORMATION; +#define EISA_MORE_ENTRIES 0x80 +#define EISA_SYSTEM_MEMORY 0x00 +#define EISA_MEMORY_TYPE_RAM 0x01 /* CM_EISA_SLOT_INFORMATION.ReturnCode */ @@ -3622,6 +4532,45 @@ typedef ULONG IN ULONG Length); typedef GET_SET_DEVICE_DATA *PGET_SET_DEVICE_DATA; +typedef enum _DEVICE_INSTALL_STATE { + InstallStateInstalled, + InstallStateNeedsReinstall, + InstallStateFailedInstall, + InstallStateFinishInstall +} DEVICE_INSTALL_STATE, *PDEVICE_INSTALL_STATE; + +typedef struct _LEGACY_BUS_INFORMATION { + GUID BusTypeGuid; + INTERFACE_TYPE LegacyBusType; + ULONG BusNumber; +} LEGACY_BUS_INFORMATION, *PLEGACY_BUS_INFORMATION; + +typedef enum _DEVICE_REMOVAL_POLICY { + RemovalPolicyExpectNoRemoval = 1, + RemovalPolicyExpectOrderlyRemoval = 2, + RemovalPolicyExpectSurpriseRemoval = 3 +} DEVICE_REMOVAL_POLICY, *PDEVICE_REMOVAL_POLICY; + +typedef VOID +(NTAPI*PREENUMERATE_SELF)( + IN PVOID Context); + +typedef struct _REENUMERATE_SELF_INTERFACE_STANDARD { + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; + PREENUMERATE_SELF SurpriseRemoveAndReenumerateSelf; +} REENUMERATE_SELF_INTERFACE_STANDARD, *PREENUMERATE_SELF_INTERFACE_STANDARD; + +typedef VOID +(NTAPI *PIO_DEVICE_EJECT_CALLBACK)( + IN NTSTATUS Status, + IN OUT PVOID Context OPTIONAL); + +#define PCI_DEVICE_PRESENT_INTERFACE_VERSION 1 + /* PCI_DEVICE_PRESENCE_PARAMETERS.Flags */ #define PCI_USE_SUBSYSTEM_IDS 0x00000001 #define PCI_USE_REVISION 0x00000002 @@ -3682,175 +4631,6 @@ typedef struct _PCI_DEVICE_PRESENT_INTERFACE { PPCI_IS_DEVICE_PRESENT_EX IsDevicePresentEx; } PCI_DEVICE_PRESENT_INTERFACE, *PPCI_DEVICE_PRESENT_INTERFACE; -typedef -BOOLEAN -(*PGPE_SERVICE_ROUTINE2)( - PVOID ObjectContext, - PVOID ServiceContext -); - -typedef -NTSTATUS -(*PGPE_CONNECT_VECTOR2)( - PVOID Context, - ULONG GpeNumber, - KINTERRUPT_MODE Mode, - BOOLEAN Shareable, - PGPE_SERVICE_ROUTINE2 ServiceRoutine, - PVOID ServiceContext, - PVOID *ObjectContext -); - -typedef -NTSTATUS -(*PGPE_DISCONNECT_VECTOR2)( - PVOID Context, - PVOID ObjectContext -); - -typedef -NTSTATUS -(*PGPE_ENABLE_EVENT2)( - PVOID Context, - PVOID ObjectContext -); - -typedef -NTSTATUS -(*PGPE_DISABLE_EVENT2)( - PVOID Context, - PVOID ObjectContext -); - -typedef -NTSTATUS -(*PGPE_CLEAR_STATUS2)( - PVOID Context, - PVOID ObjectContext -); - -typedef -VOID -(*PDEVICE_NOTIFY_CALLBACK2)( - PVOID NotificationContext, - ULONG NotifyCode -); - -typedef -NTSTATUS -(*PREGISTER_FOR_DEVICE_NOTIFICATIONS2)( - PVOID Context, - PDEVICE_NOTIFY_CALLBACK2 NotificationHandler, - PVOID NotificationContext -); - -typedef -VOID -(*PUNREGISTER_FOR_DEVICE_NOTIFICATIONS2)( - PVOID Context -); - -typedef struct -{ - USHORT Size; - USHORT Version; - PVOID Context; - PINTERFACE_REFERENCE InterfaceReference; - PINTERFACE_DEREFERENCE InterfaceDereference; - PGPE_CONNECT_VECTOR2 GpeConnectVector; - PGPE_DISCONNECT_VECTOR2 GpeDisconnectVector; - PGPE_ENABLE_EVENT2 GpeEnableEvent; - PGPE_DISABLE_EVENT2 GpeDisableEvent; - PGPE_CLEAR_STATUS2 GpeClearStatus; - PREGISTER_FOR_DEVICE_NOTIFICATIONS2 RegisterForDeviceNotifications; - PUNREGISTER_FOR_DEVICE_NOTIFICATIONS2 UnregisterForDeviceNotifications; -} ACPI_INTERFACE_STANDARD2, *PACPI_INTERFACE_STANDARD2; - -typedef -BOOLEAN -(*PGPE_SERVICE_ROUTINE)( - PDEVICE_OBJECT ObjectContext, - PVOID ServiceContext -); - -typedef -NTSTATUS -(*PGPE_CONNECT_VECTOR)( - PDEVICE_OBJECT Context, - ULONG GpeNumber, - KINTERRUPT_MODE Mode, - BOOLEAN Shareable, - PGPE_SERVICE_ROUTINE ServiceRoutine, - PVOID ServiceContext, - PVOID *ObjectContext -); - -typedef -NTSTATUS -(*PGPE_DISCONNECT_VECTOR)( - PDEVICE_OBJECT Context, - PVOID ObjectContext -); - -typedef -NTSTATUS -(*PGPE_ENABLE_EVENT)( - PDEVICE_OBJECT Context, - PVOID ObjectContext -); - -typedef -NTSTATUS -(*PGPE_DISABLE_EVENT)( - PDEVICE_OBJECT Context, - PVOID ObjectContext -); - -typedef -NTSTATUS -(*PGPE_CLEAR_STATUS)( - PDEVICE_OBJECT Context, - PVOID ObjectContext -); - -typedef -VOID -(*PDEVICE_NOTIFY_CALLBACK)( - PVOID NotificationContext, - ULONG NotifyCode -); - -typedef -NTSTATUS -(*PREGISTER_FOR_DEVICE_NOTIFICATIONS)( - PDEVICE_OBJECT Context, - PDEVICE_NOTIFY_CALLBACK NotificationHandler, - PVOID NotificationContext -); - -typedef -VOID -(*PUNREGISTER_FOR_DEVICE_NOTIFICATIONS)( - PDEVICE_OBJECT Context, - PDEVICE_NOTIFY_CALLBACK NotificationHandler -); - -typedef struct -{ - USHORT Size; - USHORT Version; - PVOID Context; - PINTERFACE_REFERENCE InterfaceReference; - PINTERFACE_DEREFERENCE InterfaceDereference; - PGPE_CONNECT_VECTOR GpeConnectVector; - PGPE_DISCONNECT_VECTOR GpeDisconnectVector; - PGPE_ENABLE_EVENT GpeEnableEvent; - PGPE_DISABLE_EVENT GpeDisableEvent; - PGPE_CLEAR_STATUS GpeClearStatus; - PREGISTER_FOR_DEVICE_NOTIFICATIONS RegisterForDeviceNotifications; - PUNREGISTER_FOR_DEVICE_NOTIFICATIONS UnregisterForDeviceNotifications; -} ACPI_INTERFACE_STANDARD, *PACPI_INTERFACE_STANDARD; - typedef struct _DEVICE_CAPABILITIES { USHORT Size; USHORT Version; @@ -3940,6 +4720,139 @@ typedef struct _TARGET_DEVICE_REMOVAL_NOTIFICATION { struct _FILE_OBJECT *FileObject; } TARGET_DEVICE_REMOVAL_NOTIFICATION, *PTARGET_DEVICE_REMOVAL_NOTIFICATION; +#if (NTDDI_VERSION >= NTDDI_VISTA) +#include +#define PLUGPLAY_PROPERTY_PERSISTENT 0x00000001 +#endif + +#define PNP_REPLACE_NO_MAP MAXLONGLONG + +typedef NTSTATUS +(NTAPI *PREPLACE_MAP_MEMORY)( + IN PHYSICAL_ADDRESS TargetPhysicalAddress, + IN PHYSICAL_ADDRESS SparePhysicalAddress, + IN OUT PLARGE_INTEGER NumberOfBytes, + OUT PVOID *TargetAddress, + OUT PVOID *SpareAddress); + +typedef struct _PNP_REPLACE_MEMORY_LIST { + ULONG AllocatedCount; + ULONG Count; + ULONGLONG TotalLength; + struct { + PHYSICAL_ADDRESS Address; + ULONGLONG Length; + } Ranges[ANYSIZE_ARRAY]; +} PNP_REPLACE_MEMORY_LIST, *PPNP_REPLACE_MEMORY_LIST; + +typedef struct _PNP_REPLACE_PROCESSOR_LIST { + PKAFFINITY Affinity; + ULONG GroupCount; + ULONG AllocatedCount; + ULONG Count; + ULONG ApicIds[ANYSIZE_ARRAY]; +} PNP_REPLACE_PROCESSOR_LIST, *PPNP_REPLACE_PROCESSOR_LIST; + +typedef struct _PNP_REPLACE_PROCESSOR_LIST_V1 { + KAFFINITY AffinityMask; + ULONG AllocatedCount; + ULONG Count; + ULONG ApicIds[ANYSIZE_ARRAY]; +} PNP_REPLACE_PROCESSOR_LIST_V1, *PPNP_REPLACE_PROCESSOR_LIST_V1; + +#define PNP_REPLACE_PARAMETERS_VERSION 2 + +typedef struct _PNP_REPLACE_PARAMETERS { + ULONG Size; + ULONG Version; + ULONG64 Target; + ULONG64 Spare; + PPNP_REPLACE_PROCESSOR_LIST TargetProcessors; + PPNP_REPLACE_PROCESSOR_LIST SpareProcessors; + PPNP_REPLACE_MEMORY_LIST TargetMemory; + PPNP_REPLACE_MEMORY_LIST SpareMemory; + PREPLACE_MAP_MEMORY MapMemory; +} PNP_REPLACE_PARAMETERS, *PPNP_REPLACE_PARAMETERS; + +typedef VOID +(NTAPI *PREPLACE_UNLOAD)( + VOID); + +typedef NTSTATUS +(NTAPI *PREPLACE_BEGIN)( + IN PPNP_REPLACE_PARAMETERS Parameters, + OUT PVOID *Context); + +typedef NTSTATUS +(NTAPI *PREPLACE_END)( + IN PVOID Context); + +typedef NTSTATUS +(NTAPI *PREPLACE_MIRROR_PHYSICAL_MEMORY)( + IN PVOID Context, + IN PHYSICAL_ADDRESS PhysicalAddress, + IN LARGE_INTEGER ByteCount); + +typedef NTSTATUS +(NTAPI *PREPLACE_SET_PROCESSOR_ID)( + IN PVOID Context, + IN ULONG ApicId, + IN BOOLEAN Target); + +typedef NTSTATUS +(NTAPI *PREPLACE_SWAP)( + IN PVOID Context); + +typedef NTSTATUS +(NTAPI *PREPLACE_INITIATE_HARDWARE_MIRROR)( + IN PVOID Context); + +typedef NTSTATUS +(NTAPI *PREPLACE_MIRROR_PLATFORM_MEMORY)( + IN PVOID Context); + +typedef NTSTATUS +(NTAPI *PREPLACE_GET_MEMORY_DESTINATION)( + IN PVOID Context, + IN PHYSICAL_ADDRESS SourceAddress, + OUT PPHYSICAL_ADDRESS DestinationAddress); + +typedef NTSTATUS +(NTAPI *PREPLACE_ENABLE_DISABLE_HARDWARE_QUIESCE)( + IN PVOID Context, + IN BOOLEAN Enable); + +#define PNP_REPLACE_DRIVER_INTERFACE_VERSION 1 +#define PNP_REPLACE_DRIVER_INTERFACE_MINIMUM_SIZE \ + FIELD_OFFSET(PNP_REPLACE_DRIVER_INTERFACE, InitiateHardwareMirror) + +#define PNP_REPLACE_MEMORY_SUPPORTED 0x0001 +#define PNP_REPLACE_PROCESSOR_SUPPORTED 0x0002 +#define PNP_REPLACE_HARDWARE_MEMORY_MIRRORING 0x0004 +#define PNP_REPLACE_HARDWARE_PAGE_COPY 0x0008 +#define PNP_REPLACE_HARDWARE_QUIESCE 0x0010 + +typedef struct _PNP_REPLACE_DRIVER_INTERFACE { + ULONG Size; + ULONG Version; + ULONG Flags; + PREPLACE_UNLOAD Unload; + PREPLACE_BEGIN BeginReplace; + PREPLACE_END EndReplace; + PREPLACE_MIRROR_PHYSICAL_MEMORY MirrorPhysicalMemory; + PREPLACE_SET_PROCESSOR_ID SetProcessorId; + PREPLACE_SWAP Swap; + PREPLACE_INITIATE_HARDWARE_MIRROR InitiateHardwareMirror; + PREPLACE_MIRROR_PLATFORM_MEMORY MirrorPlatformMemory; + PREPLACE_GET_MEMORY_DESTINATION GetMemoryDestination; + PREPLACE_ENABLE_DISABLE_HARDWARE_QUIESCE EnableDisableHardwareQuiesce; +} PNP_REPLACE_DRIVER_INTERFACE, *PPNP_REPLACE_DRIVER_INTERFACE; + +typedef NTSTATUS +(NTAPI *PREPLACE_DRIVER_INIT)( + IN OUT PPNP_REPLACE_DRIVER_INTERFACE Interface, + IN PVOID Unused); + typedef enum _DEVICE_USAGE_NOTIFICATION_TYPE { DeviceUsageTypeUndefined, DeviceUsageTypePaging, @@ -3986,6 +4899,15 @@ typedef enum _IO_NOTIFICATION_EVENT_CATEGORY { EventCategoryTargetDeviceChange } IO_NOTIFICATION_EVENT_CATEGORY; +typedef enum _IO_PRIORITY_HINT { + IoPriorityVeryLow = 0, + IoPriorityLow, + IoPriorityNormal, + IoPriorityHigh, + IoPriorityCritical, + MaxIoPriorityTypes +} IO_PRIORITY_HINT; + #define PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES 0x00000001 typedef NTSTATUS @@ -4062,7 +4984,6 @@ typedef struct _FILE_POSITION_INFORMATION { LARGE_INTEGER CurrentByteOffset; } FILE_POSITION_INFORMATION, *PFILE_POSITION_INFORMATION; -#include typedef struct _FILE_BASIC_INFORMATION { LARGE_INTEGER CreationTime; LARGE_INTEGER LastAccessTime; @@ -4070,7 +4991,32 @@ typedef struct _FILE_BASIC_INFORMATION { LARGE_INTEGER ChangeTime; ULONG FileAttributes; } FILE_BASIC_INFORMATION, *PFILE_BASIC_INFORMATION; -#include + +typedef struct _FILE_IO_PRIORITY_HINT_INFORMATION { + IO_PRIORITY_HINT PriorityHint; +} FILE_IO_PRIORITY_HINT_INFORMATION, *PFILE_IO_PRIORITY_HINT_INFORMATION; + +typedef struct _FILE_IO_COMPLETION_NOTIFICATION_INFORMATION { + ULONG Flags; +} FILE_IO_COMPLETION_NOTIFICATION_INFORMATION, *PFILE_IO_COMPLETION_NOTIFICATION_INFORMATION; + +typedef struct _FILE_IOSTATUSBLOCK_RANGE_INFORMATION { + PUCHAR IoStatusBlockRange; + ULONG Length; +} FILE_IOSTATUSBLOCK_RANGE_INFORMATION, *PFILE_IOSTATUSBLOCK_RANGE_INFORMATION; + +typedef struct _FILE_IS_REMOTE_DEVICE_INFORMATION { + BOOLEAN IsRemote; +} FILE_IS_REMOTE_DEVICE_INFORMATION, *PFILE_IS_REMOTE_DEVICE_INFORMATION; + +typedef struct _FILE_NUMA_NODE_INFORMATION { + USHORT NodeNumber; +} FILE_NUMA_NODE_INFORMATION, *PFILE_NUMA_NODE_INFORMATION; + +typedef struct _FILE_PROCESS_IDS_USING_FILE_INFORMATION { + ULONG NumberOfProcessIdsInList; + ULONG_PTR ProcessIdList[1]; +} FILE_PROCESS_IDS_USING_FILE_INFORMATION, *PFILE_PROCESS_IDS_USING_FILE_INFORMATION; typedef struct _FILE_STANDARD_INFORMATION { LARGE_INTEGER AllocationSize; @@ -4117,49 +5063,30 @@ typedef struct _FILE_FULL_EA_INFORMATION { CHAR EaName[1]; } FILE_FULL_EA_INFORMATION, *PFILE_FULL_EA_INFORMATION; +typedef struct _FILE_SFIO_RESERVE_INFORMATION { + ULONG RequestsPerPeriod; + ULONG Period; + BOOLEAN RetryFailures; + BOOLEAN Discardable; + ULONG RequestSize; + ULONG NumOutstandingRequests; +} FILE_SFIO_RESERVE_INFORMATION, *PFILE_SFIO_RESERVE_INFORMATION; + +typedef struct _FILE_SFIO_VOLUME_INFORMATION { + ULONG MaximumRequestsPerPeriod; + ULONG MinimumPeriod; + ULONG MinimumTransferSize; +} FILE_SFIO_VOLUME_INFORMATION, *PFILE_SFIO_VOLUME_INFORMATION; + +#define FILE_SKIP_COMPLETION_PORT_ON_SUCCESS 0x1 +#define FILE_SKIP_SET_EVENT_ON_HANDLE 0x2 +#define FILE_SKIP_SET_USER_EVENT_ON_FAST_IO 0x4 + #define FM_LOCK_BIT (0x1) #define FM_LOCK_BIT_V (0x0) #define FM_LOCK_WAITER_WOKEN (0x2) #define FM_LOCK_WAITER_INC (0x4) -typedef ULONG_PTR ERESOURCE_THREAD, *PERESOURCE_THREAD; - -typedef struct _OWNER_ENTRY { - ERESOURCE_THREAD OwnerThread; - _ANONYMOUS_UNION union { - LONG OwnerCount; - ULONG TableSize; - } DUMMYUNIONNAME; -} OWNER_ENTRY, *POWNER_ENTRY; - -typedef struct _ERESOURCE -{ - LIST_ENTRY SystemResourcesList; - POWNER_ENTRY OwnerTable; - SHORT ActiveCount; - USHORT Flag; - volatile PKSEMAPHORE SharedWaiters; - volatile PKEVENT ExclusiveWaiters; - OWNER_ENTRY OwnerEntry; - ULONG ActiveEntries; - ULONG ContentionCount; - ULONG NumberOfSharedWaiters; - ULONG NumberOfExclusiveWaiters; - __GNU_EXTENSION union - { - PVOID Address; - ULONG_PTR CreatorBackTraceIndex; - }; - KSPIN_LOCK SpinLock; -} ERESOURCE, *PERESOURCE; - -/* ERESOURCE.Flag */ -#define ResourceNeverExclusive 0x0010 -#define ResourceReleaseByOtherThread 0x0020 -#define ResourceOwnedExclusive 0x0080 - -#define RESOURCE_HASH_TABLE_SIZE 64 - typedef BOOLEAN (NTAPI FAST_IO_CHECK_IF_POSSIBLE)( IN struct _FILE_OBJECT *FileObject, @@ -4703,6 +5630,12 @@ typedef struct _IO_ERROR_LOG_MESSAGE { #define ERROR_LOG_MAXIMUM_SIZE (IO_ERROR_LOG_MESSAGE_LENGTH - \ IO_ERROR_LOG_MESSAGE_HEADER_LENGTH) +#ifdef _WIN64 +#define PORT_MAXIMUM_MESSAGE_LENGTH 512 +#else +#define PORT_MAXIMUM_MESSAGE_LENGTH 256 +#endif + typedef enum _DMA_WIDTH { Width8Bits, Width16Bits, @@ -5159,12 +6092,6 @@ typedef NTSTATUS (NTAPI *PMM_DLL_UNLOAD)( VOID); -typedef BOOLEAN -(NTAPI KSERVICE_ROUTINE)( - IN struct _KINTERRUPT *Interrupt, - IN PVOID ServiceContext); -typedef KSERVICE_ROUTINE *PKSERVICE_ROUTINE; - typedef VOID (NTAPI IO_TIMER_ROUTINE)( IN struct _DEVICE_OBJECT *DeviceObject, @@ -5248,12 +6175,135 @@ typedef enum _DEVICE_TEXT_TYPE { DeviceTextLocationInformation } DEVICE_TEXT_TYPE, *PDEVICE_TEXT_TYPE; -typedef enum _WORK_QUEUE_TYPE { - CriticalWorkQueue, - DelayedWorkQueue, - HyperCriticalWorkQueue, - MaximumWorkQueue -} WORK_QUEUE_TYPE; +typedef BOOLEAN +(NTAPI *PGPE_SERVICE_ROUTINE)( + PVOID, + PVOID); + +typedef NTSTATUS +(NTAPI *PGPE_CONNECT_VECTOR)( + PDEVICE_OBJECT, + ULONG, + KINTERRUPT_MODE, + BOOLEAN, + PGPE_SERVICE_ROUTINE, + PVOID, + PVOID); + +typedef NTSTATUS +(NTAPI *PGPE_DISCONNECT_VECTOR)( + PVOID); + +typedef NTSTATUS +(NTAPI *PGPE_ENABLE_EVENT)( + PDEVICE_OBJECT, + PVOID); + +typedef NTSTATUS +(NTAPI *PGPE_DISABLE_EVENT)( + PDEVICE_OBJECT, + PVOID); + +typedef NTSTATUS +(NTAPI *PGPE_CLEAR_STATUS)( + PDEVICE_OBJECT, + PVOID); + +typedef VOID +(NTAPI *PDEVICE_NOTIFY_CALLBACK)( + PVOID, + ULONG); + +typedef NTSTATUS +(NTAPI *PREGISTER_FOR_DEVICE_NOTIFICATIONS)( + PDEVICE_OBJECT, + PDEVICE_NOTIFY_CALLBACK, + PVOID); + +typedef VOID +(NTAPI *PUNREGISTER_FOR_DEVICE_NOTIFICATIONS)( + PDEVICE_OBJECT, + PDEVICE_NOTIFY_CALLBACK); + +typedef struct _ACPI_INTERFACE_STANDARD { + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; + PGPE_CONNECT_VECTOR GpeConnectVector; + PGPE_DISCONNECT_VECTOR GpeDisconnectVector; + PGPE_ENABLE_EVENT GpeEnableEvent; + PGPE_DISABLE_EVENT GpeDisableEvent; + PGPE_CLEAR_STATUS GpeClearStatus; + PREGISTER_FOR_DEVICE_NOTIFICATIONS RegisterForDeviceNotifications; + PUNREGISTER_FOR_DEVICE_NOTIFICATIONS UnregisterForDeviceNotifications; +} ACPI_INTERFACE_STANDARD, *PACPI_INTERFACE_STANDARD; + +typedef BOOLEAN +(NTAPI *PGPE_SERVICE_ROUTINE2)( + PVOID ObjectContext, + PVOID ServiceContext); + +typedef NTSTATUS +(NTAPI *PGPE_CONNECT_VECTOR2)( + PVOID Context, + ULONG GpeNumber, + KINTERRUPT_MODE Mode, + BOOLEAN Shareable, + PGPE_SERVICE_ROUTINE ServiceRoutine, + PVOID ServiceContext, + PVOID *ObjectContext); + +typedef NTSTATUS +(NTAPI *PGPE_DISCONNECT_VECTOR2)( + PVOID Context, + PVOID ObjectContext); + +typedef NTSTATUS +(NTAPI *PGPE_ENABLE_EVENT2)( + PVOID Context, + PVOID ObjectContext); + +typedef NTSTATUS +(NTAPI *PGPE_DISABLE_EVENT2)( + PVOID Context, + PVOID ObjectContext); + +typedef NTSTATUS +(NTAPI *PGPE_CLEAR_STATUS2)( + PVOID Context, + PVOID ObjectContext); + +typedef VOID +(NTAPI *PDEVICE_NOTIFY_CALLBACK2)( + PVOID NotificationContext, + ULONG NotifyCode); + +typedef NTSTATUS +(NTAPI *PREGISTER_FOR_DEVICE_NOTIFICATIONS2)( + PVOID Context, + PDEVICE_NOTIFY_CALLBACK2 NotificationHandler, + PVOID NotificationContext); + +typedef VOID +(NTAPI *PUNREGISTER_FOR_DEVICE_NOTIFICATIONS2)( + PVOID Context); + +typedef struct _ACPI_INTERFACE_STANDARD2 { + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; + PGPE_CONNECT_VECTOR2 GpeConnectVector; + PGPE_DISCONNECT_VECTOR2 GpeDisconnectVector; + PGPE_ENABLE_EVENT2 GpeEnableEvent; + PGPE_DISABLE_EVENT2 GpeDisableEvent; + PGPE_CLEAR_STATUS2 GpeClearStatus; + PREGISTER_FOR_DEVICE_NOTIFICATIONS2 RegisterForDeviceNotifications; + PUNREGISTER_FOR_DEVICE_NOTIFICATIONS2 UnregisterForDeviceNotifications; +} ACPI_INTERFACE_STANDARD2, *PACPI_INTERFACE_STANDARD2; #if !defined(_AMD64_) && !defined(_IA64_) #include @@ -5453,11 +6503,6 @@ typedef struct _IO_STACK_LOCATION { #define SL_INVOKE_ON_SUCCESS 0x40 #define SL_INVOKE_ON_ERROR 0x80 -/* IO_STACK_LOCATION.Parameters.ReadWriteControl.WhichSpace */ - -#define PCI_WHICHSPACE_CONFIG 0x0 -#define PCI_WHICHSPACE_ROM 0x52696350 /* 'PciR' */ - #define METHOD_BUFFERED 0 #define METHOD_IN_DIRECT 1 #define METHOD_OUT_DIRECT 2 @@ -5587,10 +6632,920 @@ typedef struct _IO_STACK_LOCATION { /* end winnt.h */ +#define WMIREG_ACTION_REGISTER 1 +#define WMIREG_ACTION_DEREGISTER 2 +#define WMIREG_ACTION_REREGISTER 3 +#define WMIREG_ACTION_UPDATE_GUIDS 4 +#define WMIREG_ACTION_BLOCK_IRPS 5 + +#define WMIREGISTER 0 +#define WMIUPDATE 1 + +typedef VOID +(NTAPI FWMI_NOTIFICATION_CALLBACK)( + PVOID Wnode, + PVOID Context); +typedef FWMI_NOTIFICATION_CALLBACK *WMI_NOTIFICATION_CALLBACK; + +#ifndef _PCI_X_ +#define _PCI_X_ + +typedef struct _PCI_SLOT_NUMBER { + union { + struct { + ULONG DeviceNumber:5; + ULONG FunctionNumber:3; + ULONG Reserved:24; + } bits; + ULONG AsULONG; + } u; +} PCI_SLOT_NUMBER, *PPCI_SLOT_NUMBER; + +#define PCI_TYPE0_ADDRESSES 6 +#define PCI_TYPE1_ADDRESSES 2 +#define PCI_TYPE2_ADDRESSES 5 + +typedef struct _PCI_COMMON_HEADER { + PCI_COMMON_HEADER_LAYOUT +} PCI_COMMON_HEADER, *PPCI_COMMON_HEADER; + +#ifdef __cplusplus +typedef struct _PCI_COMMON_CONFIG { + PCI_COMMON_HEADER_LAYOUT + UCHAR DeviceSpecific[192]; +} PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG; +#else +typedef struct _PCI_COMMON_CONFIG { + PCI_COMMON_HEADER DUMMYSTRUCTNAME; + UCHAR DeviceSpecific[192]; +} PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG; +#endif + +#define PCI_COMMON_HDR_LENGTH (FIELD_OFFSET(PCI_COMMON_CONFIG, DeviceSpecific)) + +#define PCI_EXTENDED_CONFIG_LENGTH 0x1000 + +#define PCI_MAX_DEVICES 32 +#define PCI_MAX_FUNCTION 8 +#define PCI_MAX_BRIDGE_NUMBER 0xFF +#define PCI_INVALID_VENDORID 0xFFFF + +/* PCI_COMMON_CONFIG.HeaderType */ +#define PCI_MULTIFUNCTION 0x80 +#define PCI_DEVICE_TYPE 0x00 +#define PCI_BRIDGE_TYPE 0x01 +#define PCI_CARDBUS_BRIDGE_TYPE 0x02 + +#define PCI_CONFIGURATION_TYPE(PciData) \ + (((PPCI_COMMON_CONFIG) (PciData))->HeaderType & ~PCI_MULTIFUNCTION) + +#define PCI_MULTIFUNCTION_DEVICE(PciData) \ + ((((PPCI_COMMON_CONFIG) (PciData))->HeaderType & PCI_MULTIFUNCTION) != 0) + +/* PCI_COMMON_CONFIG.Command */ +#define PCI_ENABLE_IO_SPACE 0x0001 +#define PCI_ENABLE_MEMORY_SPACE 0x0002 +#define PCI_ENABLE_BUS_MASTER 0x0004 +#define PCI_ENABLE_SPECIAL_CYCLES 0x0008 +#define PCI_ENABLE_WRITE_AND_INVALIDATE 0x0010 +#define PCI_ENABLE_VGA_COMPATIBLE_PALETTE 0x0020 +#define PCI_ENABLE_PARITY 0x0040 +#define PCI_ENABLE_WAIT_CYCLE 0x0080 +#define PCI_ENABLE_SERR 0x0100 +#define PCI_ENABLE_FAST_BACK_TO_BACK 0x0200 +#define PCI_DISABLE_LEVEL_INTERRUPT 0x0400 + +/* PCI_COMMON_CONFIG.Status */ +#define PCI_STATUS_INTERRUPT_PENDING 0x0008 +#define PCI_STATUS_CAPABILITIES_LIST 0x0010 +#define PCI_STATUS_66MHZ_CAPABLE 0x0020 +#define PCI_STATUS_UDF_SUPPORTED 0x0040 +#define PCI_STATUS_FAST_BACK_TO_BACK 0x0080 +#define PCI_STATUS_DATA_PARITY_DETECTED 0x0100 +#define PCI_STATUS_DEVSEL 0x0600 +#define PCI_STATUS_SIGNALED_TARGET_ABORT 0x0800 +#define PCI_STATUS_RECEIVED_TARGET_ABORT 0x1000 +#define PCI_STATUS_RECEIVED_MASTER_ABORT 0x2000 +#define PCI_STATUS_SIGNALED_SYSTEM_ERROR 0x4000 +#define PCI_STATUS_DETECTED_PARITY_ERROR 0x8000 + +/* IO_STACK_LOCATION.Parameters.ReadWriteControl.WhichSpace */ + +#define PCI_WHICHSPACE_CONFIG 0x0 +#define PCI_WHICHSPACE_ROM 0x52696350 /* 'PciR' */ + +#define PCI_CAPABILITY_ID_POWER_MANAGEMENT 0x01 +#define PCI_CAPABILITY_ID_AGP 0x02 +#define PCI_CAPABILITY_ID_VPD 0x03 +#define PCI_CAPABILITY_ID_SLOT_ID 0x04 +#define PCI_CAPABILITY_ID_MSI 0x05 +#define PCI_CAPABILITY_ID_CPCI_HOTSWAP 0x06 +#define PCI_CAPABILITY_ID_PCIX 0x07 +#define PCI_CAPABILITY_ID_HYPERTRANSPORT 0x08 +#define PCI_CAPABILITY_ID_VENDOR_SPECIFIC 0x09 +#define PCI_CAPABILITY_ID_DEBUG_PORT 0x0A +#define PCI_CAPABILITY_ID_CPCI_RES_CTRL 0x0B +#define PCI_CAPABILITY_ID_SHPC 0x0C +#define PCI_CAPABILITY_ID_P2P_SSID 0x0D +#define PCI_CAPABILITY_ID_AGP_TARGET 0x0E +#define PCI_CAPABILITY_ID_SECURE 0x0F +#define PCI_CAPABILITY_ID_PCI_EXPRESS 0x10 +#define PCI_CAPABILITY_ID_MSIX 0x11 + +typedef struct _PCI_CAPABILITIES_HEADER { + UCHAR CapabilityID; + UCHAR Next; +} PCI_CAPABILITIES_HEADER, *PPCI_CAPABILITIES_HEADER; + +typedef struct _PCI_PMC { + UCHAR Version:3; + UCHAR PMEClock:1; + UCHAR Rsvd1:1; + UCHAR DeviceSpecificInitialization:1; + UCHAR Rsvd2:2; + struct _PM_SUPPORT { + UCHAR Rsvd2:1; + UCHAR D1:1; + UCHAR D2:1; + UCHAR PMED0:1; + UCHAR PMED1:1; + UCHAR PMED2:1; + UCHAR PMED3Hot:1; + UCHAR PMED3Cold:1; + } Support; +} PCI_PMC, *PPCI_PMC; + +typedef struct _PCI_PMCSR { + USHORT PowerState:2; + USHORT Rsvd1:6; + USHORT PMEEnable:1; + USHORT DataSelect:4; + USHORT DataScale:2; + USHORT PMEStatus:1; +} PCI_PMCSR, *PPCI_PMCSR; + +typedef struct _PCI_PMCSR_BSE { + UCHAR Rsvd1:6; + UCHAR D3HotSupportsStopClock:1; + UCHAR BusPowerClockControlEnabled:1; +} PCI_PMCSR_BSE, *PPCI_PMCSR_BSE; + +typedef struct _PCI_PM_CAPABILITY { + PCI_CAPABILITIES_HEADER Header; + union { + PCI_PMC Capabilities; + USHORT AsUSHORT; + } PMC; + union { + PCI_PMCSR ControlStatus; + USHORT AsUSHORT; + } PMCSR; + union { + PCI_PMCSR_BSE BridgeSupport; + UCHAR AsUCHAR; + } PMCSR_BSE; + UCHAR Data; +} PCI_PM_CAPABILITY, *PPCI_PM_CAPABILITY; + +typedef struct { + PCI_CAPABILITIES_HEADER Header; + union { + struct { + USHORT DataParityErrorRecoveryEnable:1; + USHORT EnableRelaxedOrdering:1; + USHORT MaxMemoryReadByteCount:2; + USHORT MaxOutstandingSplitTransactions:3; + USHORT Reserved:9; + } bits; + USHORT AsUSHORT; + } Command; + union { + struct { + ULONG FunctionNumber:3; + ULONG DeviceNumber:5; + ULONG BusNumber:8; + ULONG Device64Bit:1; + ULONG Capable133MHz:1; + ULONG SplitCompletionDiscarded:1; + ULONG UnexpectedSplitCompletion:1; + ULONG DeviceComplexity:1; + ULONG DesignedMaxMemoryReadByteCount:2; + ULONG DesignedMaxOutstandingSplitTransactions:3; + ULONG DesignedMaxCumulativeReadSize:3; + ULONG ReceivedSplitCompletionErrorMessage:1; + ULONG CapablePCIX266:1; + ULONG CapablePCIX533:1; + } bits; + ULONG AsULONG; + } Status; +} PCI_X_CAPABILITY, *PPCI_X_CAPABILITY; + +#define PCI_EXPRESS_ADVANCED_ERROR_REPORTING_CAP_ID 0x0001 +#define PCI_EXPRESS_VIRTUAL_CHANNEL_CAP_ID 0x0002 +#define PCI_EXPRESS_DEVICE_SERIAL_NUMBER_CAP_ID 0x0003 +#define PCI_EXPRESS_POWER_BUDGETING_CAP_ID 0x0004 +#define PCI_EXPRESS_RC_LINK_DECLARATION_CAP_ID 0x0005 +#define PCI_EXPRESS_RC_INTERNAL_LINK_CONTROL_CAP_ID 0x0006 +#define PCI_EXPRESS_RC_EVENT_COLLECTOR_ENDPOINT_ASSOCIATION_CAP_ID 0x0007 +#define PCI_EXPRESS_MFVC_CAP_ID 0x0008 +#define PCI_EXPRESS_VC_AND_MFVC_CAP_ID 0x0009 +#define PCI_EXPRESS_RCRB_HEADER_CAP_ID 0x000A +#define PCI_EXPRESS_SINGLE_ROOT_IO_VIRTUALIZATION_CAP_ID 0x0010 + +typedef struct _PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER { + USHORT CapabilityID; + USHORT Version:4; + USHORT Next:12; +} PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER, *PPCI_EXPRESS_ENHANCED_CAPABILITY_HEADER; + +typedef struct _PCI_EXPRESS_SERIAL_NUMBER_CAPABILITY { + PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Header; + ULONG LowSerialNumber; + ULONG HighSerialNumber; +} PCI_EXPRESS_SERIAL_NUMBER_CAPABILITY, *PPCI_EXPRESS_SERIAL_NUMBER_CAPABILITY; + +typedef union _PCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS { + struct { + ULONG Undefined:1; + ULONG Reserved1:3; + ULONG DataLinkProtocolError:1; + ULONG SurpriseDownError:1; + ULONG Reserved2:6; + ULONG PoisonedTLP:1; + ULONG FlowControlProtocolError:1; + ULONG CompletionTimeout:1; + ULONG CompleterAbort:1; + ULONG UnexpectedCompletion:1; + ULONG ReceiverOverflow:1; + ULONG MalformedTLP:1; + ULONG ECRCError:1; + ULONG UnsupportedRequestError:1; + ULONG Reserved3:11; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS, *PPCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS; + +typedef union _PCI_EXPRESS_UNCORRECTABLE_ERROR_MASK { + struct { + ULONG Undefined:1; + ULONG Reserved1:3; + ULONG DataLinkProtocolError:1; + ULONG SurpriseDownError:1; + ULONG Reserved2:6; + ULONG PoisonedTLP:1; + ULONG FlowControlProtocolError:1; + ULONG CompletionTimeout:1; + ULONG CompleterAbort:1; + ULONG UnexpectedCompletion:1; + ULONG ReceiverOverflow:1; + ULONG MalformedTLP:1; + ULONG ECRCError:1; + ULONG UnsupportedRequestError:1; + ULONG Reserved3:11; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_UNCORRECTABLE_ERROR_MASK, *PPCI_EXPRESS_UNCORRECTABLE_ERROR_MASK; + +typedef union _PCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY { + struct { + ULONG Undefined:1; + ULONG Reserved1:3; + ULONG DataLinkProtocolError:1; + ULONG SurpriseDownError:1; + ULONG Reserved2:6; + ULONG PoisonedTLP:1; + ULONG FlowControlProtocolError:1; + ULONG CompletionTimeout:1; + ULONG CompleterAbort:1; + ULONG UnexpectedCompletion:1; + ULONG ReceiverOverflow:1; + ULONG MalformedTLP:1; + ULONG ECRCError:1; + ULONG UnsupportedRequestError:1; + ULONG Reserved3:11; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY, *PPCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY; + +typedef union _PCI_EXPRESS_CORRECTABLE_ERROR_STATUS { + struct { + ULONG ReceiverError:1; + ULONG Reserved1:5; + ULONG BadTLP:1; + ULONG BadDLLP:1; + ULONG ReplayNumRollover:1; + ULONG Reserved2:3; + ULONG ReplayTimerTimeout:1; + ULONG AdvisoryNonFatalError:1; + ULONG Reserved3:18; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_CORRECTABLE_ERROR_STATUS, *PPCI_CORRECTABLE_ERROR_STATUS; + +typedef union _PCI_EXPRESS_CORRECTABLE_ERROR_MASK { + struct { + ULONG ReceiverError:1; + ULONG Reserved1:5; + ULONG BadTLP:1; + ULONG BadDLLP:1; + ULONG ReplayNumRollover:1; + ULONG Reserved2:3; + ULONG ReplayTimerTimeout:1; + ULONG AdvisoryNonFatalError:1; + ULONG Reserved3:18; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_CORRECTABLE_ERROR_MASK, *PPCI_CORRECTABLE_ERROR_MASK; + +typedef union _PCI_EXPRESS_AER_CAPABILITIES { + struct { + ULONG FirstErrorPointer:5; + ULONG ECRCGenerationCapable:1; + ULONG ECRCGenerationEnable:1; + ULONG ECRCCheckCapable:1; + ULONG ECRCCheckEnable:1; + ULONG Reserved:23; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_AER_CAPABILITIES, *PPCI_EXPRESS_AER_CAPABILITIES; + +typedef union _PCI_EXPRESS_ROOT_ERROR_COMMAND { + struct { + ULONG CorrectableErrorReportingEnable:1; + ULONG NonFatalErrorReportingEnable:1; + ULONG FatalErrorReportingEnable:1; + ULONG Reserved:29; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_ROOT_ERROR_COMMAND, *PPCI_EXPRESS_ROOT_ERROR_COMMAND; + +typedef union _PCI_EXPRESS_ROOT_ERROR_STATUS { + struct { + ULONG CorrectableErrorReceived:1; + ULONG MultipleCorrectableErrorsReceived:1; + ULONG UncorrectableErrorReceived:1; + ULONG MultipleUncorrectableErrorsReceived:1; + ULONG FirstUncorrectableFatal:1; + ULONG NonFatalErrorMessagesReceived:1; + ULONG FatalErrorMessagesReceived:1; + ULONG Reserved:20; + ULONG AdvancedErrorInterruptMessageNumber:5; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_ROOT_ERROR_STATUS, *PPCI_EXPRESS_ROOT_ERROR_STATUS; + +typedef union _PCI_EXPRESS_ERROR_SOURCE_ID { + struct { + USHORT CorrectableSourceIdFun:3; + USHORT CorrectableSourceIdDev:5; + USHORT CorrectableSourceIdBus:8; + USHORT UncorrectableSourceIdFun:3; + USHORT UncorrectableSourceIdDev:5; + USHORT UncorrectableSourceIdBus:8; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_ERROR_SOURCE_ID, *PPCI_EXPRESS_ERROR_SOURCE_ID; + +typedef union _PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_STATUS { + struct { + ULONG TargetAbortOnSplitCompletion:1; + ULONG MasterAbortOnSplitCompletion:1; + ULONG ReceivedTargetAbort:1; + ULONG ReceivedMasterAbort:1; + ULONG RsvdZ:1; + ULONG UnexpectedSplitCompletionError:1; + ULONG UncorrectableSplitCompletion:1; + ULONG UncorrectableDataError:1; + ULONG UncorrectableAttributeError:1; + ULONG UncorrectableAddressError:1; + ULONG DelayedTransactionDiscardTimerExpired:1; + ULONG PERRAsserted:1; + ULONG SERRAsserted:1; + ULONG InternalBridgeError:1; + ULONG Reserved:18; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_STATUS, *PPCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_STATUS; + +typedef union _PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_MASK { + struct { + ULONG TargetAbortOnSplitCompletion:1; + ULONG MasterAbortOnSplitCompletion:1; + ULONG ReceivedTargetAbort:1; + ULONG ReceivedMasterAbort:1; + ULONG RsvdZ:1; + ULONG UnexpectedSplitCompletionError:1; + ULONG UncorrectableSplitCompletion:1; + ULONG UncorrectableDataError:1; + ULONG UncorrectableAttributeError:1; + ULONG UncorrectableAddressError:1; + ULONG DelayedTransactionDiscardTimerExpired:1; + ULONG PERRAsserted:1; + ULONG SERRAsserted:1; + ULONG InternalBridgeError:1; + ULONG Reserved:18; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_MASK, *PPCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_MASK; + +typedef union _PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_SEVERITY { + struct { + ULONG TargetAbortOnSplitCompletion:1; + ULONG MasterAbortOnSplitCompletion:1; + ULONG ReceivedTargetAbort:1; + ULONG ReceivedMasterAbort:1; + ULONG RsvdZ:1; + ULONG UnexpectedSplitCompletionError:1; + ULONG UncorrectableSplitCompletion:1; + ULONG UncorrectableDataError:1; + ULONG UncorrectableAttributeError:1; + ULONG UncorrectableAddressError:1; + ULONG DelayedTransactionDiscardTimerExpired:1; + ULONG PERRAsserted:1; + ULONG SERRAsserted:1; + ULONG InternalBridgeError:1; + ULONG Reserved:18; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_SEVERITY, *PPCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_SEVERITY; + +typedef union _PCI_EXPRESS_SEC_AER_CAPABILITIES { + struct { + ULONG SecondaryUncorrectableFirstErrorPtr:5; + ULONG Reserved:27; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_SEC_AER_CAPABILITIES, *PPCI_EXPRESS_SEC_AER_CAPABILITIES; + +#define ROOT_CMD_ENABLE_CORRECTABLE_ERROR_REPORTING 0x00000001 +#define ROOT_CMD_ENABLE_NONFATAL_ERROR_REPORTING 0x00000002 +#define ROOT_CMD_ENABLE_FATAL_ERROR_REPORTING 0x00000004 + +#define ROOT_CMD_ERROR_REPORTING_ENABLE_MASK \ + (ROOT_CMD_ENABLE_FATAL_ERROR_REPORTING | \ + ROOT_CMD_ENABLE_NONFATAL_ERROR_REPORTING | \ + ROOT_CMD_ENABLE_CORRECTABLE_ERROR_REPORTING) + +typedef struct _PCI_EXPRESS_AER_CAPABILITY { + PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Header; + PCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS UncorrectableErrorStatus; + PCI_EXPRESS_UNCORRECTABLE_ERROR_MASK UncorrectableErrorMask; + PCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY UncorrectableErrorSeverity; + PCI_EXPRESS_CORRECTABLE_ERROR_STATUS CorrectableErrorStatus; + PCI_EXPRESS_CORRECTABLE_ERROR_MASK CorrectableErrorMask; + PCI_EXPRESS_AER_CAPABILITIES CapabilitiesAndControl; + ULONG HeaderLog[4]; + PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_STATUS SecUncorrectableErrorStatus; + PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_MASK SecUncorrectableErrorMask; + PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_SEVERITY SecUncorrectableErrorSeverity; + PCI_EXPRESS_SEC_AER_CAPABILITIES SecCapabilitiesAndControl; + ULONG SecHeaderLog[4]; +} PCI_EXPRESS_AER_CAPABILITY, *PPCI_EXPRESS_AER_CAPABILITY; + +typedef struct _PCI_EXPRESS_ROOTPORT_AER_CAPABILITY { + PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Header; + PCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS UncorrectableErrorStatus; + PCI_EXPRESS_UNCORRECTABLE_ERROR_MASK UncorrectableErrorMask; + PCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY UncorrectableErrorSeverity; + PCI_EXPRESS_CORRECTABLE_ERROR_STATUS CorrectableErrorStatus; + PCI_EXPRESS_CORRECTABLE_ERROR_MASK CorrectableErrorMask; + PCI_EXPRESS_AER_CAPABILITIES CapabilitiesAndControl; + ULONG HeaderLog[4]; + PCI_EXPRESS_ROOT_ERROR_COMMAND RootErrorCommand; + PCI_EXPRESS_ROOT_ERROR_STATUS RootErrorStatus; + PCI_EXPRESS_ERROR_SOURCE_ID ErrorSourceId; +} PCI_EXPRESS_ROOTPORT_AER_CAPABILITY, *PPCI_EXPRESS_ROOTPORT_AER_CAPABILITY; + +typedef struct _PCI_EXPRESS_BRIDGE_AER_CAPABILITY { + PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Header; + PCI_EXPRESS_UNCORRECTABLE_ERROR_STATUS UncorrectableErrorStatus; + PCI_EXPRESS_UNCORRECTABLE_ERROR_MASK UncorrectableErrorMask; + PCI_EXPRESS_UNCORRECTABLE_ERROR_SEVERITY UncorrectableErrorSeverity; + PCI_EXPRESS_CORRECTABLE_ERROR_STATUS CorrectableErrorStatus; + PCI_EXPRESS_CORRECTABLE_ERROR_MASK CorrectableErrorMask; + PCI_EXPRESS_AER_CAPABILITIES CapabilitiesAndControl; + ULONG HeaderLog[4]; + PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_STATUS SecUncorrectableErrorStatus; + PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_MASK SecUncorrectableErrorMask; + PCI_EXPRESS_SEC_UNCORRECTABLE_ERROR_SEVERITY SecUncorrectableErrorSeverity; + PCI_EXPRESS_SEC_AER_CAPABILITIES SecCapabilitiesAndControl; + ULONG SecHeaderLog[4]; +} PCI_EXPRESS_BRIDGE_AER_CAPABILITY, *PPCI_EXPRESS_BRIDGE_AER_CAPABILITY; + +typedef union _PCI_EXPRESS_SRIOV_CAPS { + struct { + ULONG VFMigrationCapable:1; + ULONG Reserved1:20; + ULONG VFMigrationInterruptNumber:11; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_SRIOV_CAPS, *PPCI_EXPRESS_SRIOV_CAPS; + +typedef union _PCI_EXPRESS_SRIOV_CONTROL { + struct { + USHORT VFEnable:1; + USHORT VFMigrationEnable:1; + USHORT VFMigrationInterruptEnable:1; + USHORT VFMemorySpaceEnable:1; + USHORT ARICapableHierarchy:1; + USHORT Reserved1:11; + } DUMMYSTRUCTNAME; + USHORT AsUSHORT; +} PCI_EXPRESS_SRIOV_CONTROL, *PPCI_EXPRESS_SRIOV_CONTROL; + +typedef union _PCI_EXPRESS_SRIOV_STATUS { + struct { + USHORT VFMigrationStatus:1; + USHORT Reserved1:15; + } DUMMYSTRUCTNAME; + USHORT AsUSHORT; +} PCI_EXPRESS_SRIOV_STATUS, *PPCI_EXPRESS_SRIOV_STATUS; + +typedef union _PCI_EXPRESS_SRIOV_MIGRATION_STATE_ARRAY { + struct { + ULONG VFMigrationStateBIR:3; + ULONG VFMigrationStateOffset:29; + } DUMMYSTRUCTNAME; + ULONG AsULONG; +} PCI_EXPRESS_SRIOV_MIGRATION_STATE_ARRAY, *PPCI_EXPRESS_SRIOV_MIGRATION_STATE_ARRAY; + +typedef struct _PCI_EXPRESS_SRIOV_CAPABILITY { + PCI_EXPRESS_ENHANCED_CAPABILITY_HEADER Header; + PCI_EXPRESS_SRIOV_CAPS SRIOVCapabilities; + PCI_EXPRESS_SRIOV_CONTROL SRIOVControl; + PCI_EXPRESS_SRIOV_STATUS SRIOVStatus; + USHORT InitialVFs; + USHORT TotalVFs; + USHORT NumVFs; + UCHAR FunctionDependencyLink; + UCHAR RsvdP1; + USHORT FirstVFOffset; + USHORT VFStride; + USHORT RsvdP2; + USHORT VFDeviceId; + ULONG SupportedPageSizes; + ULONG SystemPageSize; + ULONG BaseAddresses[PCI_TYPE0_ADDRESSES]; + PCI_EXPRESS_SRIOV_MIGRATION_STATE_ARRAY VFMigrationStateArrayOffset; +} PCI_EXPRESS_SRIOV_CAPABILITY, *PPCI_EXPRESS_SRIOV_CAPABILITY; + +/* PCI device classes */ +#define PCI_CLASS_PRE_20 0x00 +#define PCI_CLASS_MASS_STORAGE_CTLR 0x01 +#define PCI_CLASS_NETWORK_CTLR 0x02 +#define PCI_CLASS_DISPLAY_CTLR 0x03 +#define PCI_CLASS_MULTIMEDIA_DEV 0x04 +#define PCI_CLASS_MEMORY_CTLR 0x05 +#define PCI_CLASS_BRIDGE_DEV 0x06 +#define PCI_CLASS_SIMPLE_COMMS_CTLR 0x07 +#define PCI_CLASS_BASE_SYSTEM_DEV 0x08 +#define PCI_CLASS_INPUT_DEV 0x09 +#define PCI_CLASS_DOCKING_STATION 0x0a +#define PCI_CLASS_PROCESSOR 0x0b +#define PCI_CLASS_SERIAL_BUS_CTLR 0x0c +#define PCI_CLASS_WIRELESS_CTLR 0x0d +#define PCI_CLASS_INTELLIGENT_IO_CTLR 0x0e +#define PCI_CLASS_SATELLITE_COMMS_CTLR 0x0f +#define PCI_CLASS_ENCRYPTION_DECRYPTION 0x10 +#define PCI_CLASS_DATA_ACQ_SIGNAL_PROC 0x11 +#define PCI_CLASS_NOT_DEFINED 0xff + +/* PCI device subclasses for class 0 */ +#define PCI_SUBCLASS_PRE_20_NON_VGA 0x00 +#define PCI_SUBCLASS_PRE_20_VGA 0x01 + +/* PCI device subclasses for class 1 (mass storage controllers)*/ +#define PCI_SUBCLASS_MSC_SCSI_BUS_CTLR 0x00 +#define PCI_SUBCLASS_MSC_IDE_CTLR 0x01 +#define PCI_SUBCLASS_MSC_FLOPPY_CTLR 0x02 +#define PCI_SUBCLASS_MSC_IPI_CTLR 0x03 +#define PCI_SUBCLASS_MSC_RAID_CTLR 0x04 +#define PCI_SUBCLASS_MSC_OTHER 0x80 + +/* PCI device subclasses for class 2 (network controllers)*/ +#define PCI_SUBCLASS_NET_ETHERNET_CTLR 0x00 +#define PCI_SUBCLASS_NET_TOKEN_RING_CTLR 0x01 +#define PCI_SUBCLASS_NET_FDDI_CTLR 0x02 +#define PCI_SUBCLASS_NET_ATM_CTLR 0x03 +#define PCI_SUBCLASS_NET_ISDN_CTLR 0x04 +#define PCI_SUBCLASS_NET_OTHER 0x80 + +/* PCI device subclasses for class 3 (display controllers)*/ +#define PCI_SUBCLASS_VID_VGA_CTLR 0x00 +#define PCI_SUBCLASS_VID_XGA_CTLR 0x01 +#define PCI_SUBCLASS_VID_3D_CTLR 0x02 +#define PCI_SUBCLASS_VID_OTHER 0x80 + +/* PCI device subclasses for class 4 (multimedia device)*/ +#define PCI_SUBCLASS_MM_VIDEO_DEV 0x00 +#define PCI_SUBCLASS_MM_AUDIO_DEV 0x01 +#define PCI_SUBCLASS_MM_TELEPHONY_DEV 0x02 +#define PCI_SUBCLASS_MM_OTHER 0x80 + +/* PCI device subclasses for class 5 (memory controller)*/ +#define PCI_SUBCLASS_MEM_RAM 0x00 +#define PCI_SUBCLASS_MEM_FLASH 0x01 +#define PCI_SUBCLASS_MEM_OTHER 0x80 + +/* PCI device subclasses for class 6 (bridge device)*/ +#define PCI_SUBCLASS_BR_HOST 0x00 +#define PCI_SUBCLASS_BR_ISA 0x01 +#define PCI_SUBCLASS_BR_EISA 0x02 +#define PCI_SUBCLASS_BR_MCA 0x03 +#define PCI_SUBCLASS_BR_PCI_TO_PCI 0x04 +#define PCI_SUBCLASS_BR_PCMCIA 0x05 +#define PCI_SUBCLASS_BR_NUBUS 0x06 +#define PCI_SUBCLASS_BR_CARDBUS 0x07 +#define PCI_SUBCLASS_BR_RACEWAY 0x08 +#define PCI_SUBCLASS_BR_OTHER 0x80 + +#define PCI_SUBCLASS_COM_SERIAL 0x00 +#define PCI_SUBCLASS_COM_PARALLEL 0x01 +#define PCI_SUBCLASS_COM_MULTIPORT 0x02 +#define PCI_SUBCLASS_COM_MODEM 0x03 +#define PCI_SUBCLASS_COM_OTHER 0x80 + +#define PCI_SUBCLASS_SYS_INTERRUPT_CTLR 0x00 +#define PCI_SUBCLASS_SYS_DMA_CTLR 0x01 +#define PCI_SUBCLASS_SYS_SYSTEM_TIMER 0x02 +#define PCI_SUBCLASS_SYS_REAL_TIME_CLOCK 0x03 +#define PCI_SUBCLASS_SYS_GEN_HOTPLUG_CTLR 0x04 +#define PCI_SUBCLASS_SYS_SDIO_CTRL 0x05 +#define PCI_SUBCLASS_SYS_OTHER 0x80 + +#define PCI_SUBCLASS_INP_KEYBOARD 0x00 +#define PCI_SUBCLASS_INP_DIGITIZER 0x01 +#define PCI_SUBCLASS_INP_MOUSE 0x02 +#define PCI_SUBCLASS_INP_SCANNER 0x03 +#define PCI_SUBCLASS_INP_GAMEPORT 0x04 +#define PCI_SUBCLASS_INP_OTHER 0x80 + +#define PCI_SUBCLASS_DOC_GENERIC 0x00 +#define PCI_SUBCLASS_DOC_OTHER 0x80 + +#define PCI_SUBCLASS_PROC_386 0x00 +#define PCI_SUBCLASS_PROC_486 0x01 +#define PCI_SUBCLASS_PROC_PENTIUM 0x02 +#define PCI_SUBCLASS_PROC_ALPHA 0x10 +#define PCI_SUBCLASS_PROC_POWERPC 0x20 +#define PCI_SUBCLASS_PROC_COPROCESSOR 0x40 + +/* PCI device subclasses for class C (serial bus controller)*/ +#define PCI_SUBCLASS_SB_IEEE1394 0x00 +#define PCI_SUBCLASS_SB_ACCESS 0x01 +#define PCI_SUBCLASS_SB_SSA 0x02 +#define PCI_SUBCLASS_SB_USB 0x03 +#define PCI_SUBCLASS_SB_FIBRE_CHANNEL 0x04 +#define PCI_SUBCLASS_SB_SMBUS 0x05 + +#define PCI_SUBCLASS_WIRELESS_IRDA 0x00 +#define PCI_SUBCLASS_WIRELESS_CON_IR 0x01 +#define PCI_SUBCLASS_WIRELESS_RF 0x10 +#define PCI_SUBCLASS_WIRELESS_OTHER 0x80 + +#define PCI_SUBCLASS_INTIO_I2O 0x00 + +#define PCI_SUBCLASS_SAT_TV 0x01 +#define PCI_SUBCLASS_SAT_AUDIO 0x02 +#define PCI_SUBCLASS_SAT_VOICE 0x03 +#define PCI_SUBCLASS_SAT_DATA 0x04 + +#define PCI_SUBCLASS_CRYPTO_NET_COMP 0x00 +#define PCI_SUBCLASS_CRYPTO_ENTERTAINMENT 0x10 +#define PCI_SUBCLASS_CRYPTO_OTHER 0x80 + +#define PCI_SUBCLASS_DASP_DPIO 0x00 +#define PCI_SUBCLASS_DASP_OTHER 0x80 + +#define PCI_ADDRESS_IO_SPACE 0x00000001 +#define PCI_ADDRESS_MEMORY_TYPE_MASK 0x00000006 +#define PCI_ADDRESS_MEMORY_PREFETCHABLE 0x00000008 +#define PCI_ADDRESS_IO_ADDRESS_MASK 0xfffffffc +#define PCI_ADDRESS_MEMORY_ADDRESS_MASK 0xfffffff0 +#define PCI_ADDRESS_ROM_ADDRESS_MASK 0xfffff800 + +#define PCI_TYPE_32BIT 0 +#define PCI_TYPE_20BIT 2 +#define PCI_TYPE_64BIT 4 + +#define PCI_ROMADDRESS_ENABLED 0x00000001 + +#endif /* _PCI_X_ */ + +#define PCI_EXPRESS_LINK_QUIESCENT_INTERFACE_VERSION 1 + +typedef NTSTATUS +(NTAPI PCI_EXPRESS_ENTER_LINK_QUIESCENT_MODE)( + IN OUT PVOID Context); +typedef PCI_EXPRESS_ENTER_LINK_QUIESCENT_MODE *PPCI_EXPRESS_ENTER_LINK_QUIESCENT_MODE; + +typedef NTSTATUS +(NTAPI PCI_EXPRESS_EXIT_LINK_QUIESCENT_MODE)( + IN OUT PVOID Context); +typedef PCI_EXPRESS_EXIT_LINK_QUIESCENT_MODE *PPCI_EXPRESS_EXIT_LINK_QUIESCENT_MODE; + +typedef struct _PCI_EXPRESS_LINK_QUIESCENT_INTERFACE { + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; + PPCI_EXPRESS_ENTER_LINK_QUIESCENT_MODE PciExpressEnterLinkQuiescentMode; + PPCI_EXPRESS_EXIT_LINK_QUIESCENT_MODE PciExpressExitLinkQuiescentMode; +} PCI_EXPRESS_LINK_QUIESCENT_INTERFACE, *PPCI_EXPRESS_LINK_QUIESCENT_INTERFACE; + +#define PCI_EXPRESS_ROOT_PORT_INTERFACE_VERSION 1 + +typedef ULONG +(NTAPI *PPCI_EXPRESS_ROOT_PORT_READ_CONFIG_SPACE)( + IN PVOID Context, + OUT PVOID Buffer, + IN ULONG Offset, + IN ULONG Length); + +typedef ULONG +(NTAPI *PPCI_EXPRESS_ROOT_PORT_WRITE_CONFIG_SPACE)( + IN PVOID Context, + IN PVOID Buffer, + IN ULONG Offset, + IN ULONG Length); + +typedef struct _PCI_EXPRESS_ROOT_PORT_INTERFACE { + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; + PPCI_EXPRESS_ROOT_PORT_READ_CONFIG_SPACE ReadConfigSpace; + PPCI_EXPRESS_ROOT_PORT_WRITE_CONFIG_SPACE WriteConfigSpace; +} PCI_EXPRESS_ROOT_PORT_INTERFACE, *PPCI_EXPRESS_ROOT_PORT_INTERFACE; + +#define PCI_MSIX_TABLE_CONFIG_INTERFACE_VERSION 1 + +typedef NTSTATUS +(NTAPI PCI_MSIX_SET_ENTRY)( + IN PVOID Context, + IN ULONG TableEntry, + IN ULONG MessageNumber); +typedef PCI_MSIX_SET_ENTRY *PPCI_MSIX_SET_ENTRY; + +typedef NTSTATUS +(NTAPI PCI_MSIX_MASKUNMASK_ENTRY)( + IN PVOID Context, + IN ULONG TableEntry); +typedef PCI_MSIX_MASKUNMASK_ENTRY *PPCI_MSIX_MASKUNMASK_ENTRY; + +typedef NTSTATUS +(NTAPI PCI_MSIX_GET_ENTRY)( + IN PVOID Context, + IN ULONG TableEntry, + OUT PULONG MessageNumber, + OUT PBOOLEAN Masked); +typedef PCI_MSIX_GET_ENTRY *PPCI_MSIX_GET_ENTRY; + +typedef NTSTATUS +(NTAPI PCI_MSIX_GET_TABLE_SIZE)( + IN PVOID Context, + OUT PULONG TableSize); +typedef PCI_MSIX_GET_TABLE_SIZE *PPCI_MSIX_GET_TABLE_SIZE; + +typedef struct _PCI_MSIX_TABLE_CONFIG_INTERFACE { + USHORT Size; + USHORT Version; + PVOID Context; + PINTERFACE_REFERENCE InterfaceReference; + PINTERFACE_DEREFERENCE InterfaceDereference; + PPCI_MSIX_SET_ENTRY SetTableEntry; + PPCI_MSIX_MASKUNMASK_ENTRY MaskTableEntry; + PPCI_MSIX_MASKUNMASK_ENTRY UnmaskTableEntry; + PPCI_MSIX_GET_ENTRY GetTableEntry; + PPCI_MSIX_GET_TABLE_SIZE GetTableSize; +} PCI_MSIX_TABLE_CONFIG_INTERFACE, *PPCI_MSIX_TABLE_CONFIG_INTERFACE; + +#define PCI_MSIX_TABLE_CONFIG_MINIMUM_SIZE \ + RTL_SIZEOF_THROUGH_FIELD(PCI_MSIX_TABLE_CONFIG_INTERFACE, UnmaskTableEntry) + /****************************************************************************** * Object Manager Types * ******************************************************************************/ +#define MAXIMUM_FILENAME_LENGTH 256 +#define OBJ_NAME_PATH_SEPARATOR ((WCHAR)L'\\') + +#define OBJECT_TYPE_CREATE 0x0001 +#define OBJECT_TYPE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0x1) + +#define DIRECTORY_QUERY 0x0001 +#define DIRECTORY_TRAVERSE 0x0002 +#define DIRECTORY_CREATE_OBJECT 0x0004 +#define DIRECTORY_CREATE_SUBDIRECTORY 0x0008 +#define DIRECTORY_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0xF) + +#define SYMBOLIC_LINK_QUERY 0x0001 +#define SYMBOLIC_LINK_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0x1) + +#define DUPLICATE_CLOSE_SOURCE 0x00000001 +#define DUPLICATE_SAME_ACCESS 0x00000002 +#define DUPLICATE_SAME_ATTRIBUTES 0x00000004 + +#define OB_FLT_REGISTRATION_VERSION_0100 0x0100 +#define OB_FLT_REGISTRATION_VERSION OB_FLT_REGISTRATION_VERSION_0100 + +typedef ULONG OB_OPERATION; + +#define OB_OPERATION_HANDLE_CREATE 0x00000001 +#define OB_OPERATION_HANDLE_DUPLICATE 0x00000002 + +typedef struct _OB_PRE_CREATE_HANDLE_INFORMATION { + IN OUT ACCESS_MASK DesiredAccess; + IN ACCESS_MASK OriginalDesiredAccess; +} OB_PRE_CREATE_HANDLE_INFORMATION, *POB_PRE_CREATE_HANDLE_INFORMATION; + +typedef struct _OB_PRE_DUPLICATE_HANDLE_INFORMATION { + IN OUT ACCESS_MASK DesiredAccess; + IN ACCESS_MASK OriginalDesiredAccess; + IN PVOID SourceProcess; + IN PVOID TargetProcess; +} OB_PRE_DUPLICATE_HANDLE_INFORMATION, *POB_PRE_DUPLICATE_HANDLE_INFORMATION; + +typedef union _OB_PRE_OPERATION_PARAMETERS { + IN OUT OB_PRE_CREATE_HANDLE_INFORMATION CreateHandleInformation; + IN OUT OB_PRE_DUPLICATE_HANDLE_INFORMATION DuplicateHandleInformation; +} OB_PRE_OPERATION_PARAMETERS, *POB_PRE_OPERATION_PARAMETERS; + +typedef struct _OB_PRE_OPERATION_INFORMATION { + IN OB_OPERATION Operation; + union { + IN ULONG Flags; + struct { + IN ULONG KernelHandle:1; + IN ULONG Reserved:31; + }; + }; + IN PVOID Object; + IN POBJECT_TYPE ObjectType; + OUT PVOID CallContext; + IN POB_PRE_OPERATION_PARAMETERS Parameters; +} OB_PRE_OPERATION_INFORMATION, *POB_PRE_OPERATION_INFORMATION; + +typedef struct _OB_POST_CREATE_HANDLE_INFORMATION { + IN ACCESS_MASK GrantedAccess; +} OB_POST_CREATE_HANDLE_INFORMATION, *POB_POST_CREATE_HANDLE_INFORMATION; + +typedef struct _OB_POST_DUPLICATE_HANDLE_INFORMATION { + IN ACCESS_MASK GrantedAccess; +} OB_POST_DUPLICATE_HANDLE_INFORMATION, *POB_POST_DUPLICATE_HANDLE_INFORMATION; + +typedef union _OB_POST_OPERATION_PARAMETERS { + IN OB_POST_CREATE_HANDLE_INFORMATION CreateHandleInformation; + IN OB_POST_DUPLICATE_HANDLE_INFORMATION DuplicateHandleInformation; +} OB_POST_OPERATION_PARAMETERS, *POB_POST_OPERATION_PARAMETERS; + +typedef struct _OB_POST_OPERATION_INFORMATION { + IN OB_OPERATION Operation; + union { + IN ULONG Flags; + struct { + IN ULONG KernelHandle:1; + IN ULONG Reserved:31; + }; + }; + IN PVOID Object; + IN POBJECT_TYPE ObjectType; + IN PVOID CallContext; + IN NTSTATUS ReturnStatus; + IN POB_POST_OPERATION_PARAMETERS Parameters; +} OB_POST_OPERATION_INFORMATION,*POB_POST_OPERATION_INFORMATION; + +typedef enum _OB_PREOP_CALLBACK_STATUS { + OB_PREOP_SUCCESS +} OB_PREOP_CALLBACK_STATUS, *POB_PREOP_CALLBACK_STATUS; + +typedef OB_PREOP_CALLBACK_STATUS +(NTAPI *POB_PRE_OPERATION_CALLBACK)( + IN PVOID RegistrationContext, + IN OUT POB_PRE_OPERATION_INFORMATION OperationInformation); + +typedef VOID +(NTAPI *POB_POST_OPERATION_CALLBACK)( + IN PVOID RegistrationContext, + IN POB_POST_OPERATION_INFORMATION OperationInformation); + +typedef struct _OB_OPERATION_REGISTRATION { + IN POBJECT_TYPE *ObjectType; + IN OB_OPERATION Operations; + IN POB_PRE_OPERATION_CALLBACK PreOperation; + IN POB_POST_OPERATION_CALLBACK PostOperation; +} OB_OPERATION_REGISTRATION, *POB_OPERATION_REGISTRATION; + +typedef struct _OB_CALLBACK_REGISTRATION { + IN USHORT Version; + IN USHORT OperationRegistrationCount; + IN UNICODE_STRING Altitude; + IN PVOID RegistrationContext; + IN OB_OPERATION_REGISTRATION *OperationRegistration; +} OB_CALLBACK_REGISTRATION, *POB_CALLBACK_REGISTRATION; + typedef struct _OBJECT_NAME_INFORMATION { UNICODE_STRING Name; } OBJECT_NAME_INFORMATION, *POBJECT_NAME_INFORMATION; @@ -5615,16 +7570,6 @@ extern POBJECT_TYPE NTSYSAPI PsProcessType; #define QUOTA_LIMITS_HARDWS_MAX_DISABLE 0x00000008 #define QUOTA_LIMITS_USE_DEFAULT_LIMITS 0x00000010 -/* Process Qoutas */ -typedef struct _QUOTA_LIMITS { - SIZE_T PagedPoolLimit; - SIZE_T NonPagedPoolLimit; - SIZE_T MinimumWorkingSetSize; - SIZE_T MaximumWorkingSetSize; - SIZE_T PagefileLimit; - LARGE_INTEGER TimeLimit; -} QUOTA_LIMITS, *PQUOTA_LIMITS; - /* Thread Access Rights */ #define THREAD_TERMINATE 0x0001 #define THREAD_SUSPEND_RESUME 0x0002 @@ -5649,18 +7594,76 @@ typedef struct _QUOTA_LIMITS { #define THREAD_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3FF) #endif -#define ES_SYSTEM_REQUIRED 0x00000001 -#define ES_DISPLAY_REQUIRED 0x00000002 -#define ES_USER_PRESENT 0x00000004 -#define ES_CONTINUOUS 0x80000000 - #define LOW_PRIORITY 0 #define LOW_REALTIME_PRIORITY 16 #define HIGH_PRIORITY 31 #define MAXIMUM_PRIORITY 32 -#ifdef _X86_ +/****************************************************************************** + * WMI Library Support Types * + ******************************************************************************/ + +#ifdef RUN_WPP +#include +#include +#endif + +#ifndef _TRACEHANDLE_DEFINED +#define _TRACEHANDLE_DEFINED +typedef ULONG64 TRACEHANDLE, *PTRACEHANDLE; +#endif + +#ifndef TRACE_INFORMATION_CLASS_DEFINE + +typedef struct _ETW_TRACE_SESSION_SETTINGS { + ULONG Version; + ULONG BufferSize; + ULONG MinimumBuffers; + ULONG MaximumBuffers; + ULONG LoggerMode; + ULONG FlushTimer; + ULONG FlushThreshold; + ULONG ClockType; +} ETW_TRACE_SESSION_SETTINGS, *PETW_TRACE_SESSION_SETTINGS; + +typedef enum _TRACE_INFORMATION_CLASS { + TraceIdClass, + TraceHandleClass, + TraceEnableFlagsClass, + TraceEnableLevelClass, + GlobalLoggerHandleClass, + EventLoggerHandleClass, + AllLoggerHandlesClass, + TraceHandleByNameClass, + LoggerEventsLostClass, + TraceSessionSettingsClass, + LoggerEventsLoggedClass, + MaxTraceInformationClass +} TRACE_INFORMATION_CLASS; + +#endif /* TRACE_INFORMATION_CLASS_DEFINE */ + +#ifndef _ETW_KM_ +#define _ETW_KM_ +#endif + +#include + +typedef VOID +(NTAPI *PETWENABLECALLBACK)( + IN LPCGUID SourceId, + IN ULONG ControlCode, + IN UCHAR Level, + IN ULONGLONG MatchAnyKeyword, + IN ULONGLONG MatchAllKeyword, + IN PEVENT_FILTER_DESCRIPTOR FilterData OPTIONAL, + IN OUT PVOID CallbackContext OPTIONAL); + +#define EVENT_WRITE_FLAG_NO_FAULTING 0x00000001 + + +#if defined(_M_IX86) /** Kernel definitions for x86 **/ /* Interrupt request levels */ @@ -5821,11 +7824,346 @@ _KeQueryTickCount( } #define KeQueryTickCount(CurrentCount) _KeQueryTickCount(CurrentCount) -#endif /* _X86_ */ +#elif defined(_M_AMD64) +/** Kernel definitions for AMD64 **/ + +/* Interrupt request levels */ +#define PASSIVE_LEVEL 0 +#define LOW_LEVEL 0 +#define APC_LEVEL 1 +#define DISPATCH_LEVEL 2 +#define CMCI_LEVEL 5 +#define CLOCK_LEVEL 13 +#define IPI_LEVEL 14 +#define DRS_LEVEL 14 +#define POWER_LEVEL 14 +#define PROFILE_LEVEL 15 +#define HIGH_LEVEL 15 + +#define KI_USER_SHARED_DATA 0xFFFFF78000000000ULL +#define SharedUserData ((PKUSER_SHARED_DATA const)KI_USER_SHARED_DATA) +#define SharedInterruptTime (KI_USER_SHARED_DATA + 0x8) +#define SharedSystemTime (KI_USER_SHARED_DATA + 0x14) +#define SharedTickCount (KI_USER_SHARED_DATA + 0x320) + +#define PAGE_SIZE 0x1000 +#define PAGE_SHIFT 12L + +#define EFLAG_SIGN 0x8000 +#define EFLAG_ZERO 0x4000 +#define EFLAG_SELECT (EFLAG_SIGN | EFLAG_ZERO) + +#define RESULT_NEGATIVE ((EFLAG_SIGN & ~EFLAG_ZERO) & EFLAG_SELECT) +#define RESULT_ZERO ((~EFLAG_SIGN & EFLAG_ZERO) & EFLAG_SELECT) +#define RESULT_POSITIVE ((~EFLAG_SIGN & ~EFLAG_ZERO) & EFLAG_SELECT) + + +typedef struct _KFLOATING_SAVE { + ULONG Dummy; +} KFLOATING_SAVE, *PKFLOATING_SAVE; + +typedef XSAVE_FORMAT XMM_SAVE_AREA32, *PXMM_SAVE_AREA32; + +#define KeQueryInterruptTime() \ + (*(volatile ULONG64*)SharedInterruptTime) + +#define KeQuerySystemTime(CurrentCount) \ + *(ULONG64*)(CurrentCount) = *(volatile ULONG64*)SharedSystemTime + +#define KeQueryTickCount(CurrentCount) \ + *(ULONG64*)(CurrentCount) = *(volatile ULONG64*)SharedTickCount + +#define KeGetDcacheFillSize() 1L + +#define YieldProcessor _mm_pause + +FORCEINLINE +KIRQL +KeGetCurrentIrql(VOID) +{ + return (KIRQL)__readcr8(); +} + +FORCEINLINE +VOID +KeLowerIrql(IN KIRQL NewIrql) +{ + //ASSERT(KeGetCurrentIrql() >= NewIrql); + __writecr8(NewIrql); +} + +FORCEINLINE +KIRQL +KfRaiseIrql(IN KIRQL NewIrql) +{ + KIRQL OldIrql; + + OldIrql = __readcr8(); + //ASSERT(OldIrql <= NewIrql); + __writecr8(NewIrql); + return OldIrql; +} +#define KeRaiseIrql(a,b) *(b) = KfRaiseIrql(a) + +FORCEINLINE +KIRQL +KeRaiseIrqlToDpcLevel(VOID) +{ + return KfRaiseIrql(DISPATCH_LEVEL); +} + +FORCEINLINE +KIRQL +KeRaiseIrqlToSynchLevel(VOID) +{ + return KfRaiseIrql(12); // SYNCH_LEVEL = IPI_LEVEL - 2 + } + +FORCEINLINE +PKTHREAD +KeGetCurrentThread(VOID) +{ + return (struct _KTHREAD *)__readgsqword(0x188); +} + +/* VOID + * KeFlushIoBuffers( + * IN PMDL Mdl, + * IN BOOLEAN ReadOperation, + * IN BOOLEAN DmaOperation) + */ +#define KeFlushIoBuffers(_Mdl, _ReadOperation, _DmaOperation) + +/* x86 and x64 performs a 0x2C interrupt */ +#define DbgRaiseAssertionFailure __int2c + +#elif defined(_M_IA64) +/** Kernel definitions for IA64 **/ + +/* Interrupt request levels */ +#define PASSIVE_LEVEL 0 +#define LOW_LEVEL 0 +#define APC_LEVEL 1 +#define DISPATCH_LEVEL 2 +#define CMC_LEVEL 3 +#define DEVICE_LEVEL_BASE 4 +#define PC_LEVEL 12 +#define IPI_LEVEL 14 +#define DRS_LEVEL 14 +#define CLOCK_LEVEL 13 +#define POWER_LEVEL 15 +#define PROFILE_LEVEL 15 +#define HIGH_LEVEL 15 + +#define KI_USER_SHARED_DATA ((ULONG_PTR)(KADDRESS_BASE + 0xFFFE0000)) +extern volatile LARGE_INTEGER KeTickCount; + +#define PAUSE_PROCESSOR __yield(); + +FORCEINLINE +VOID +KeFlushWriteBuffer(VOID) +{ + __mf (); + return; +} + +NTSYSAPI +PKTHREAD +NTAPI +KeGetCurrentThread(VOID); + + +#elif defined(_M_PPC) + +/* Interrupt request levels */ +#define PASSIVE_LEVEL 0 +#define LOW_LEVEL 0 +#define APC_LEVEL 1 +#define DISPATCH_LEVEL 2 +#define PROFILE_LEVEL 27 +#define CLOCK1_LEVEL 28 +#define CLOCK2_LEVEL 28 +#define IPI_LEVEL 29 +#define POWER_LEVEL 30 +#define HIGH_LEVEL 31 + +// +// Used to contain PFNs and PFN counts +// +typedef ULONG PFN_COUNT; +typedef ULONG PFN_NUMBER, *PPFN_NUMBER; +typedef LONG SPFN_NUMBER, *PSPFN_NUMBER; + + +typedef struct _KFLOATING_SAVE { + ULONG Dummy; +} KFLOATING_SAVE, *PKFLOATING_SAVE; + +typedef struct _KPCR_TIB { + PVOID ExceptionList; /* 00 */ + PVOID StackBase; /* 04 */ + PVOID StackLimit; /* 08 */ + PVOID SubSystemTib; /* 0C */ + _ANONYMOUS_UNION union { + PVOID FiberData; /* 10 */ + ULONG Version; /* 10 */ + } DUMMYUNIONNAME; + PVOID ArbitraryUserPointer; /* 14 */ + struct _KPCR_TIB *Self; /* 18 */ +} KPCR_TIB, *PKPCR_TIB; /* 1C */ + +#define PCR_MINOR_VERSION 1 +#define PCR_MAJOR_VERSION 1 + +typedef struct _KPCR { + KPCR_TIB Tib; /* 00 */ + struct _KPCR *Self; /* 1C */ + struct _KPRCB *Prcb; /* 20 */ + KIRQL Irql; /* 24 */ + ULONG IRR; /* 28 */ + ULONG IrrActive; /* 2C */ + ULONG IDR; /* 30 */ + PVOID KdVersionBlock; /* 34 */ + PUSHORT IDT; /* 38 */ + PUSHORT GDT; /* 3C */ + struct _KTSS *TSS; /* 40 */ + USHORT MajorVersion; /* 44 */ + USHORT MinorVersion; /* 46 */ + KAFFINITY SetMember; /* 48 */ + ULONG StallScaleFactor; /* 4C */ + UCHAR SpareUnused; /* 50 */ + UCHAR Number; /* 51 */ +} KPCR, *PKPCR; /* 54 */ + +#define KeGetPcr() PCR + +#define YieldProcessor() __asm__ __volatile__("nop"); + +FORCEINLINE +ULONG +NTAPI +KeGetCurrentProcessorNumber(VOID) +{ + ULONG Number; + __asm__ __volatile__ ( + "lwz %0, %c1(12)\n" + : "=r" (Number) + : "i" (FIELD_OFFSET(KPCR, Number)) + ); + return Number; +} + +NTHALAPI +VOID +FASTCALL +KfLowerIrql( + IN KIRQL NewIrql); +#define KeLowerIrql(a) KfLowerIrql(a) + +NTHALAPI +KIRQL +FASTCALL +KfRaiseIrql( + IN KIRQL NewIrql); +#define KeRaiseIrql(a,b) *(b) = KfRaiseIrql(a) + +NTHALAPI +KIRQL +NTAPI +KeRaiseIrqlToDpcLevel(VOID); + +NTHALAPI +KIRQL +NTAPI +KeRaiseIrqlToSynchLevel(VOID); + + + +#elif defined(_M_MIPS) +#error MIPS Headers are totally incorrect + +// +// Used to contain PFNs and PFN counts +// +typedef ULONG PFN_COUNT; +typedef ULONG PFN_NUMBER, *PPFN_NUMBER; +typedef LONG SPFN_NUMBER, *PSPFN_NUMBER; + +#define PASSIVE_LEVEL 0 +#define APC_LEVEL 1 +#define DISPATCH_LEVEL 2 +#define PROFILE_LEVEL 27 +#define IPI_LEVEL 29 +#define HIGH_LEVEL 31 + +typedef struct _KPCR { + struct _KPRCB *Prcb; /* 20 */ + KIRQL Irql; /* 24 */ + ULONG IRR; /* 28 */ + ULONG IDR; /* 30 */ +} KPCR, *PKPCR; + +#define KeGetPcr() PCR + +typedef struct _KFLOATING_SAVE { +} KFLOATING_SAVE, *PKFLOATING_SAVE; + +static __inline +ULONG +NTAPI +KeGetCurrentProcessorNumber(VOID) +{ + return 0; +} + +#define YieldProcessor() __asm__ __volatile__("nop"); + +#define KeLowerIrql(a) KfLowerIrql(a) +#define KeRaiseIrql(a,b) *(b) = KfRaiseIrql(a) + +NTKERNELAPI +VOID +NTAPI +KfLowerIrql( + IN KIRQL NewIrql); + +NTKERNELAPI +KIRQL +NTAPI +KfRaiseIrql( + IN KIRQL NewIrql); + +NTKERNELAPI +KIRQL +NTAPI +KeRaiseIrqlToDpcLevel(VOID); + +NTKERNELAPI +KIRQL +NTAPI +KeRaiseIrqlToSynchLevel(VOID); + + +#elif defined(_M_ARM) +#include +#else +#error Unknown Architecture +#endif + +/****************************************************************************** + * Runtime Library Functions * + ******************************************************************************/ + + +#if !defined(MIDL_PASS) && !defined(SORTPP_PASS) + +#define RTL_STATIC_LIST_HEAD(x) LIST_ENTRY x = { &x, &x } + FORCEINLINE VOID InitializeListHead( @@ -5834,34 +8172,6 @@ InitializeListHead( ListHead->Flink = ListHead->Blink = ListHead; } -FORCEINLINE -VOID -InsertHeadList( - IN OUT PLIST_ENTRY ListHead, - IN OUT PLIST_ENTRY Entry) -{ - PLIST_ENTRY OldFlink; - OldFlink = ListHead->Flink; - Entry->Flink = OldFlink; - Entry->Blink = ListHead; - OldFlink->Blink = Entry; - ListHead->Flink = Entry; -} - -FORCEINLINE -VOID -InsertTailList( - IN OUT PLIST_ENTRY ListHead, - IN OUT PLIST_ENTRY Entry) -{ - PLIST_ENTRY OldBlink; - OldBlink = ListHead->Blink; - Entry->Flink = ListHead; - Entry->Blink = OldBlink; - OldBlink->Flink = Entry; - ListHead->Blink = Entry; -} - BOOLEAN FORCEINLINE IsListEmpty( @@ -5870,29 +8180,6 @@ IsListEmpty( return (BOOLEAN)(ListHead->Flink == ListHead); } -FORCEINLINE -PSINGLE_LIST_ENTRY -PopEntryList( - IN OUT PSINGLE_LIST_ENTRY ListHead) -{ - PSINGLE_LIST_ENTRY FirstEntry; - FirstEntry = ListHead->Next; - if (FirstEntry != NULL) { - ListHead->Next = FirstEntry->Next; - } - return FirstEntry; -} - -FORCEINLINE -VOID -PushEntryList( - IN OUT PSINGLE_LIST_ENTRY ListHead, - IN OUT PSINGLE_LIST_ENTRY Entry) -{ - Entry->Next = ListHead->Next; - ListHead->Next = Entry; -} - FORCEINLINE BOOLEAN RemoveEntryList( @@ -5938,6 +8225,73 @@ RemoveTailList( return Entry; } +FORCEINLINE +VOID +InsertTailList( + IN OUT PLIST_ENTRY ListHead, + IN OUT PLIST_ENTRY Entry) +{ + PLIST_ENTRY OldBlink; + OldBlink = ListHead->Blink; + Entry->Flink = ListHead; + Entry->Blink = OldBlink; + OldBlink->Flink = Entry; + ListHead->Blink = Entry; +} + +FORCEINLINE +VOID +InsertHeadList( + IN OUT PLIST_ENTRY ListHead, + IN OUT PLIST_ENTRY Entry) +{ + PLIST_ENTRY OldFlink; + OldFlink = ListHead->Flink; + Entry->Flink = OldFlink; + Entry->Blink = ListHead; + OldFlink->Blink = Entry; + ListHead->Flink = Entry; +} + +FORCEINLINE +VOID +AppendTailList( + IN OUT PLIST_ENTRY ListHead, + IN OUT PLIST_ENTRY ListToAppend) +{ + PLIST_ENTRY ListEnd = ListHead->Blink; + + ListHead->Blink->Flink = ListToAppend; + ListHead->Blink = ListToAppend->Blink; + ListToAppend->Blink->Flink = ListHead; + ListToAppend->Blink = ListEnd; +} + +FORCEINLINE +PSINGLE_LIST_ENTRY +PopEntryList( + IN OUT PSINGLE_LIST_ENTRY ListHead) +{ + PSINGLE_LIST_ENTRY FirstEntry; + FirstEntry = ListHead->Next; + if (FirstEntry != NULL) { + ListHead->Next = FirstEntry->Next; + } + return FirstEntry; +} + +FORCEINLINE +VOID +PushEntryList( + IN OUT PSINGLE_LIST_ENTRY ListHead, + IN OUT PSINGLE_LIST_ENTRY Entry) +{ + Entry->Next = ListHead->Next; + ListHead->Next = Entry; +} + +#endif /* !defined(MIDL_PASS) && !defined(SORTPP_PASS) */ + NTSYSAPI VOID NTAPI @@ -6298,15 +8652,6 @@ RtlFindSetBitsAndClear( IN ULONG NumberToFind, IN ULONG HintIndex); -NTSYSAPI -NTSTATUS -NTAPI -RtlHashUnicodeString( - IN CONST UNICODE_STRING *String, - IN BOOLEAN CaseInSensitive, - IN ULONG HashAlgorithm, - OUT PULONG HashValue); - NTSYSAPI VOID NTAPI @@ -6396,49 +8741,10 @@ RtlQueryRegistryValues( #define LONGLONG_MASK (LONGLONG_SIZE - 1) #define LOWBYTE_MASK 0x00FF -/* VOID - * RtlRetrieveUlong( - * PULONG DestinationAddress, - * PULONG SourceAddress); - */ -#if defined(_AMD64_) -#define RtlRetrieveUlong(DestAddress,SrcAddress) \ - *(ULONG UNALIGNED *)(DestAddress) = *(PULONG)(SrcAddress) -#else -#define RtlRetrieveUlong(DestAddress,SrcAddress) \ - if ((ULONG_PTR)(SrcAddress) & LONG_MASK) \ - { \ - ((PUCHAR)(DestAddress))[0]=((PUCHAR)(SrcAddress))[0]; \ - ((PUCHAR)(DestAddress))[1]=((PUCHAR)(SrcAddress))[1]; \ - ((PUCHAR)(DestAddress))[2]=((PUCHAR)(SrcAddress))[2]; \ - ((PUCHAR)(DestAddress))[3]=((PUCHAR)(SrcAddress))[3]; \ - } \ - else \ - { \ - *((PULONG)(DestAddress))=*((PULONG)(SrcAddress)); \ - } -#endif - -/* VOID - * RtlRetrieveUshort( - * PUSHORT DestinationAddress, - * PUSHORT SourceAddress); - */ -#if defined(_AMD64_) -#define RtlRetrieveUshort(DestAddress,SrcAddress) \ - *(USHORT UNALIGNED *)(DestAddress) = *(USHORT)(SrcAddress) -#else -#define RtlRetrieveUshort(DestAddress,SrcAddress) \ - if ((ULONG_PTR)(SrcAddress) & LONG_MASK) \ - { \ - ((PUCHAR)(DestAddress))[0]=((PUCHAR)(SrcAddress))[0]; \ - ((PUCHAR)(DestAddress))[1]=((PUCHAR)(SrcAddress))[1]; \ - } \ - else \ - { \ - *((PUSHORT)(DestAddress))=*((PUSHORT)(SrcAddress)); \ - } -#endif +#define FIRSTBYTE(VALUE) ((VALUE) & LOWBYTE_MASK) +#define SECONDBYTE(VALUE) (((VALUE) >> 8) & LOWBYTE_MASK) +#define THIRDBYTE(VALUE) (((VALUE) >> 16) & LOWBYTE_MASK) +#define FOURTHBYTE(VALUE) (((VALUE) >> 24) & LOWBYTE_MASK) NTSYSAPI VOID @@ -6517,17 +8823,7 @@ RtlSetDaclSecurityDescriptor( else { \ *((PULONG)(Address)) = (ULONG) (Value); \ } -#endif -/* VOID - * RtlStoreUlonglong( - * IN OUT PULONGLONG Address, - * ULONGLONG Value); - */ -#if defined(_AMD64_) -#define RtlStoreUlonglong(Address,Value) \ - *(ULONGLONG UNALIGNED *)(Address) = (Value) -#else #define RtlStoreUlonglong(Address,Value) \ if ((ULONG_PTR)(Address) & LONGLONG_MASK) { \ RtlStoreUlong((ULONG_PTR)(Address), \ @@ -6537,30 +8833,7 @@ RtlSetDaclSecurityDescriptor( } else { \ *((PULONGLONG)(Address)) = (ULONGLONG)(Value); \ } -#endif -/* VOID - * RtlStoreUlongPtr( - * IN OUT PULONG_PTR Address, - * IN ULONG_PTR Value); - */ -#ifdef _WIN64 -#define RtlStoreUlongPtr(Address,Value) \ - RtlStoreUlonglong(Address,Value) -#else -#define RtlStoreUlongPtr(Address,Value) \ - RtlStoreUlong(Address,Value) -#endif - -/* VOID - * RtlStoreUshort( - * IN PUSHORT Address, - * IN USHORT Value); - */ -#if defined(_AMD64_) -#define RtlStoreUshort(Address,Value) \ - *(USHORT UNALIGNED *)(Address) = (Value) -#else #define RtlStoreUshort(Address,Value) \ if ((ULONG_PTR)(Address) & SHORT_MASK) { \ ((PUCHAR) (Address))[SHORT_LEAST_SIGNIFICANT_BIT] = (UCHAR)(FIRSTBYTE(Value)); \ @@ -6569,7 +8842,44 @@ RtlSetDaclSecurityDescriptor( else { \ *((PUSHORT) (Address)) = (USHORT)Value; \ } -#endif + +#define RtlRetrieveUshort(DestAddress,SrcAddress) \ + if ((ULONG_PTR)(SrcAddress) & LONG_MASK) \ + { \ + ((PUCHAR)(DestAddress))[0]=((PUCHAR)(SrcAddress))[0]; \ + ((PUCHAR)(DestAddress))[1]=((PUCHAR)(SrcAddress))[1]; \ + } \ + else \ + { \ + *((PUSHORT)(DestAddress))=*((PUSHORT)(SrcAddress)); \ + } + +#define RtlRetrieveUlong(DestAddress,SrcAddress) \ + if ((ULONG_PTR)(SrcAddress) & LONG_MASK) \ + { \ + ((PUCHAR)(DestAddress))[0]=((PUCHAR)(SrcAddress))[0]; \ + ((PUCHAR)(DestAddress))[1]=((PUCHAR)(SrcAddress))[1]; \ + ((PUCHAR)(DestAddress))[2]=((PUCHAR)(SrcAddress))[2]; \ + ((PUCHAR)(DestAddress))[3]=((PUCHAR)(SrcAddress))[3]; \ + } \ + else \ + { \ + *((PULONG)(DestAddress))=*((PULONG)(SrcAddress)); \ + } + +#endif /* defined(_AMD64_) */ + +#ifdef _WIN64 +/* VOID + * RtlStoreUlongPtr( + * IN OUT PULONG_PTR Address, + * IN ULONG_PTR Value); + */ +#define RtlStoreUlongPtr(Address,Value) RtlStoreUlonglong(Address,Value) +#else +#define RtlStoreUlongPtr(Address,Value) RtlStoreUlong(Address,Value) +#endif /* _WIN64 */ + NTSYSAPI BOOLEAN @@ -6835,6 +9145,34 @@ RtlConvertUlongToLargeInteger( return ret; } +//DECLSPEC_DEPRECATED_DDK_WINXP +static __inline +LARGE_INTEGER +NTAPI_INLINE +RtlLargeIntegerShiftLeft( + IN LARGE_INTEGER LargeInteger, + IN CCHAR ShiftCount) +{ + LARGE_INTEGER Result; + + Result.QuadPart = LargeInteger.QuadPart << ShiftCount; + return Result; +} + +//DECLSPEC_DEPRECATED_DDK_WINXP +static __inline +LARGE_INTEGER +NTAPI_INLINE +RtlLargeIntegerShiftRight( + IN LARGE_INTEGER LargeInteger, + IN CCHAR ShiftCount) +{ + LARGE_INTEGER Result; + + Result.QuadPart = (ULONG64)LargeInteger.QuadPart >> ShiftCount; + return Result; +} + //DECLSPEC_DEPRECATED_DDK static __inline ULONG @@ -6849,6 +9187,33 @@ RtlEnlargedUnsignedDivide( return (ULONG)(Dividend.QuadPart / Divisor); } +//DECLSPEC_DEPRECATED_DDK +static __inline +LARGE_INTEGER +NTAPI_INLINE +RtlLargeIntegerNegate( + IN LARGE_INTEGER Subtrahend) +{ + LARGE_INTEGER Difference; + + Difference.QuadPart = -Subtrahend.QuadPart; + return Difference; +} + +//DECLSPEC_DEPRECATED_DDK +static __inline +LARGE_INTEGER +NTAPI_INLINE +RtlLargeIntegerSubtract( + IN LARGE_INTEGER Minuend, + IN LARGE_INTEGER Subtrahend) +{ + LARGE_INTEGER Difference; + + Difference.QuadPart = Minuend.QuadPart - Subtrahend.QuadPart; + return Difference; +} + //DECLSPEC_DEPRECATED_DDK static __inline LARGE_INTEGER @@ -7127,6 +9492,10 @@ RtlCheckBit( (__annotation(L"Debug", L"AssertFail", msg), \ DbgRaiseAssertionFailure(), FALSE) : TRUE) +#define NT_VERIFY NT_ASSERT +#define NT_VERIFYMSG NT_ASSERTMSG +#define NT_VERIFYMSGW NT_ASSERTMSGW + #else /* GCC doesn't support __annotation (nor PDB) */ @@ -7153,8 +9522,8 @@ RtlCheckBit( #define RTL_SOFT_VERIFYMSG(msg, exp) ((exp) ? TRUE : FALSE) #define NT_ASSERT(exp) ((VOID)0) -#define NT_ASSERTMSG(exp) ((VOID)0) -#define NT_ASSERTMSGW(exp) ((VOID)0) +#define NT_ASSERTMSG(msg, exp) ((VOID)0) +#define NT_ASSERTMSGW(msg, exp) ((VOID)0) #define NT_VERIFY(_exp) ((_exp) ? TRUE : FALSE) #define NT_VERIFYMSG(_msg, _exp ) ((_exp) ? TRUE : FALSE) @@ -7241,16 +9610,61 @@ InterlockedPushEntrySList( #endif /* !defined(_WINBASE_) */ +#define RTL_CONTEXT_EX_OFFSET(ContextEx, Chunk) ((ContextEx)->Chunk.Offset) +#define RTL_CONTEXT_EX_LENGTH(ContextEx, Chunk) ((ContextEx)->Chunk.Length) +#define RTL_CONTEXT_EX_CHUNK(Base, Layout, Chunk) \ + ((PVOID)((PCHAR)(Base) + RTL_CONTEXT_EX_OFFSET(Layout, Chunk))) +#define RTL_CONTEXT_OFFSET(Context, Chunk) \ + RTL_CONTEXT_EX_OFFSET((PCONTEXT_EX)(Context + 1), Chunk) +#define RTL_CONTEXT_LENGTH(Context, Chunk) \ + RTL_CONTEXT_EX_LENGTH((PCONTEXT_EX)(Context + 1), Chunk) +#define RTL_CONTEXT_CHUNK(Context, Chunk) \ + RTL_CONTEXT_EX_CHUNK((PCONTEXT_EX)(Context + 1), \ + (PCONTEXT_EX)(Context + 1), \ + Chunk) + +BOOLEAN +RTLVERLIB_DDI(RtlIsNtDdiVersionAvailable)( + IN ULONG Version); + +BOOLEAN +RTLVERLIB_DDI(RtlIsServicePackVersionInstalled)( + IN ULONG Version); + +#ifndef RtlIsNtDdiVersionAvailable +#define RtlIsNtDdiVersionAvailable WdmlibRtlIsNtDdiVersionAvailable +#endif + +#ifndef RtlIsServicePackVersionInstalled +#define RtlIsServicePackVersionInstalled WdmlibRtlIsServicePackVersionInstalled +#endif + +#define RtlInterlockedSetBits(Flags, Flag) \ + InterlockedOr((PLONG)(Flags), Flag) + +#define RtlInterlockedAndBits(Flags, Flag) \ + InterlockedAnd((PLONG)(Flags), Flag) + +#define RtlInterlockedClearBits(Flags, Flag) \ + RtlInterlockedAndBits(Flags, ~(Flag)) + +#define RtlInterlockedXorBits(Flags, Flag) \ + InterlockedXor(Flags, Flag) + +#define RtlInterlockedSetBitsDiscardReturn(Flags, Flag) \ + (VOID) RtlInterlockedSetBits(Flags, Flag) + +#define RtlInterlockedAndBitsDiscardReturn(Flags, Flag) \ + (VOID) RtlInterlockedAndBits(Flags, Flag) + +#define RtlInterlockedClearBitsDiscardReturn(Flags, Flag) \ + RtlInterlockedAndBitsDiscardReturn(Flags, ~(Flag)) + + /****************************************************************************** * Kernel Functions * ******************************************************************************/ -NTHALAPI -KIRQL -NTAPI -KeGetCurrentIrql( - VOID); - NTKERNELAPI VOID NTAPI @@ -8137,6 +10551,22 @@ KeFlushWriteBuffer(VOID); #define ALIGN_UP_POINTER(ptr, type) \ ALIGN_UP_POINTER_BY(ptr, sizeof(type)) +#ifndef FIELD_OFFSET +#define FIELD_OFFSET(type, field) ((ULONG)&(((type *)0)->field)) +#endif + +#ifndef FIELD_SIZE +#define FIELD_SIZE(type, field) (sizeof(((type *)0)->field)) +#endif + +#define POOL_TAGGING 1 + +#if DBG +#define IF_DEBUG if (TRUE) +#else +#define IF_DEBUG if (FALSE) +#endif /* DBG */ + /* ULONG * BYTE_OFFSET( * IN PVOID Va) @@ -8149,7 +10579,7 @@ KeFlushWriteBuffer(VOID); * IN ULONG Size) */ #define BYTES_TO_PAGES(Size) \ - (((Size) >> PAGE_SHIFT) + (((Size) & (PAGE_SIZE - 1)) != 0)) + (((Size) + PAGE_SIZE - 1) >> PAGE_SHIFT) /* PVOID * PAGE_ALIGN( @@ -8443,7 +10873,16 @@ MmUnmapLockedPages( IN PVOID BaseAddress, IN PMDL MemoryDescriptorList); - +NTKERNELAPI +PVOID +NTAPI +MmAllocateContiguousMemorySpecifyCacheNode( + IN SIZE_T NumberOfBytes, + IN PHYSICAL_ADDRESS LowestAcceptableAddress, + IN PHYSICAL_ADDRESS HighestAcceptableAddress, + IN PHYSICAL_ADDRESS BoundaryAddressMultiple OPTIONAL, + IN MEMORY_CACHING_TYPE CacheType, + IN NODE_REQUIREMENT PreferredNode); #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ @@ -8500,6 +10939,22 @@ MmUnmapReservedMapping( IN ULONG PoolTag, IN PMDL MemoryDescriptorList); +NTKERNELAPI +NTSTATUS +NTAPI +MmAddVerifierThunks( + IN PVOID ThunkBuffer, + IN ULONG ThunkBufferSize); + +#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ + +#if (NTDDI_VERSION >= NTDDI_WS03) +NTKERNELAPI +LOGICAL +NTAPI +MmIsIoSpaceActive( + IN PHYSICAL_ADDRESS StartAddress, + IN SIZE_T NumberOfBytes); #endif #if (NTDDI_VERSION >= NTDDI_WS03SP1) @@ -8728,6 +11183,40 @@ CmGetBoundTransaction( * I/O Manager Functions * ******************************************************************************/ + +/* + * NTSTATUS + * IoAcquireRemoveLock( + * IN PIO_REMOVE_LOCK RemoveLock, + * IN OPTIONAL PVOID Tag) + */ +#if DBG +#define IoAcquireRemoveLock(RemoveLock, Tag) \ + IoAcquireRemoveLockEx(RemoveLock, Tag, __FILE__, __LINE__, sizeof (IO_REMOVE_LOCK)) +#else +#define IoAcquireRemoveLock(RemoveLock, Tag) \ + IoAcquireRemoveLockEx(RemoveLock, Tag, "", 1, sizeof (IO_REMOVE_LOCK)) +#endif + +/* + * VOID + * IoAdjustPagingPathCount( + * IN PLONG Count, + * IN BOOLEAN Increment) + */ +#define IoAdjustPagingPathCount(_Count, \ + _Increment) \ +{ \ + if (_Increment) \ + { \ + InterlockedIncrement(_Count); \ + } \ + else \ + { \ + InterlockedDecrement(_Count); \ + } \ +} + #if !defined(_M_AMD64) NTHALAPI VOID @@ -9254,43 +11743,6 @@ IoAcquireRemoveLockEx( IN PCSTR File, IN ULONG Line, IN ULONG RemlockSize); -#endif - -/* - * NTSTATUS - * IoAcquireRemoveLock( - * IN PIO_REMOVE_LOCK RemoveLock, - * IN OPTIONAL PVOID Tag) - */ -#if DBG -#define IoAcquireRemoveLock(RemoveLock, Tag) \ - IoAcquireRemoveLockEx(RemoveLock, Tag, __FILE__, __LINE__, sizeof (IO_REMOVE_LOCK)) -#else -#define IoAcquireRemoveLock(RemoveLock, Tag) \ - IoAcquireRemoveLockEx(RemoveLock, Tag, "", 1, sizeof (IO_REMOVE_LOCK)) -#endif - -/* - * VOID - * IoAdjustPagingPathCount( - * IN PLONG Count, - * IN BOOLEAN Increment) - */ -#define IoAdjustPagingPathCount(_Count, \ - _Increment) \ -{ \ - if (_Increment) \ - { \ - InterlockedIncrement(_Count); \ - } \ - else \ - { \ - InterlockedDecrement(_Count); \ - } \ -} - -#if (NTDDI_VERSION >= NTDDI_WIN2K) - NTKERNELAPI NTSTATUS NTAPI @@ -10086,9 +12538,237 @@ IoWMISetSingleItem( IN ULONG Version, IN ULONG ValueBufferSize, IN PVOID ValueBuffer); +#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ +#if (NTDDI_VERSION >= NTDDI_WINXPSP1) +NTKERNELAPI +NTSTATUS +NTAPI +IoValidateDeviceIoControlAccess( + IN PIRP Irp, + IN ULONG RequiredAccess); #endif +#if (NTDDI_VERSION >= NTDDI_WS03) + +NTKERNELAPI +NTSTATUS +NTAPI +IoCsqInitializeEx( + IN PIO_CSQ Csq, + IN PIO_CSQ_INSERT_IRP_EX CsqInsertIrp, + IN PIO_CSQ_REMOVE_IRP CsqRemoveIrp, + IN PIO_CSQ_PEEK_NEXT_IRP CsqPeekNextIrp, + IN PIO_CSQ_ACQUIRE_LOCK CsqAcquireLock, + IN PIO_CSQ_RELEASE_LOCK CsqReleaseLock, + IN PIO_CSQ_COMPLETE_CANCELED_IRP CsqCompleteCanceledIrp); + +NTKERNELAPI +NTSTATUS +NTAPI +IoCsqInsertIrpEx( + IN PIO_CSQ Csq, + IN PIRP Irp, + IN PIO_CSQ_IRP_CONTEXT Context OPTIONAL, + IN PVOID InsertContext OPTIONAL); +#endif /* (NTDDI_VERSION >= NTDDI_WS03) */ + + +#if (NTDDI_VERSION >= NTDDI_VISTA) + +NTKERNELAPI +NTSTATUS +NTAPI +IoGetBootDiskInformationLite( + OUT PBOOTDISK_INFORMATION_LITE *BootDiskInformation); + +NTKERNELAPI +NTSTATUS +NTAPI +IoCheckShareAccessEx( + IN ACCESS_MASK DesiredAccess, + IN ULONG DesiredShareAccess, + IN OUT PFILE_OBJECT FileObject, + IN OUT PSHARE_ACCESS ShareAccess, + IN BOOLEAN Update, + IN PBOOLEAN WritePermission); + +NTKERNELAPI +NTSTATUS +NTAPI +IoConnectInterruptEx( + IN OUT PIO_CONNECT_INTERRUPT_PARAMETERS Parameters); + +NTKERNELAPI +VOID +NTAPI +IoDisconnectInterruptEx( + IN PIO_DISCONNECT_INTERRUPT_PARAMETERS Parameters); + +LOGICAL +NTAPI +IoWithinStackLimits( + IN ULONG_PTR RegionStart, + IN SIZE_T RegionSize); + +NTKERNELAPI +VOID +NTAPI +IoSetShareAccessEx( + IN ACCESS_MASK DesiredAccess, + IN ULONG DesiredShareAccess, + IN OUT PFILE_OBJECT FileObject, + OUT PSHARE_ACCESS ShareAccess, + IN PBOOLEAN WritePermission); + +ULONG +NTAPI +IoSizeofWorkItem(VOID); + +VOID +NTAPI +IoInitializeWorkItem( + IN PVOID IoObject, + IN PIO_WORKITEM IoWorkItem); + +VOID +NTAPI +IoUninitializeWorkItem( + IN PIO_WORKITEM IoWorkItem); + +VOID +NTAPI +IoQueueWorkItemEx( + IN PIO_WORKITEM IoWorkItem, + IN PIO_WORKITEM_ROUTINE_EX WorkerRoutine, + IN WORK_QUEUE_TYPE QueueType, + IN PVOID Context OPTIONAL); + +IO_PRIORITY_HINT +NTAPI +IoGetIoPriorityHint( + IN PIRP Irp); + +NTSTATUS +NTAPI +IoSetIoPriorityHint( + IN PIRP Irp, + IN IO_PRIORITY_HINT PriorityHint); + +NTSTATUS +NTAPI +IoAllocateSfioStreamIdentifier( + IN PFILE_OBJECT FileObject, + IN ULONG Length, + IN PVOID Signature, + OUT PVOID *StreamIdentifier); + +PVOID +NTAPI +IoGetSfioStreamIdentifier( + IN PFILE_OBJECT FileObject, + IN PVOID Signature); + +NTSTATUS +NTAPI +IoFreeSfioStreamIdentifier( + IN PFILE_OBJECT FileObject, + IN PVOID Signature); + +NTKERNELAPI +NTSTATUS +NTAPI +IoRequestDeviceEjectEx( + IN PDEVICE_OBJECT PhysicalDeviceObject, + IN PIO_DEVICE_EJECT_CALLBACK Callback OPTIONAL, + IN PVOID Context OPTIONAL, + IN PDRIVER_OBJECT DriverObject OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +IoSetDevicePropertyData( + IN PDEVICE_OBJECT Pdo, + IN CONST DEVPROPKEY *PropertyKey, + IN LCID Lcid, + IN ULONG Flags, + IN DEVPROPTYPE Type, + IN ULONG Size, + IN PVOID Data OPTIONAL); + +NTKERNELAPI +NTSTATUS +NTAPI +IoGetDevicePropertyData( + PDEVICE_OBJECT Pdo, + CONST DEVPROPKEY *PropertyKey, + LCID Lcid, + ULONG Flags, + ULONG Size, + PVOID Data, + PULONG RequiredSize, + PDEVPROPTYPE Type); + +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + +#define IoCallDriverStackSafeDefault(a, b) IoCallDriver(a, b) + +#if (NTDDI_VERSION >= NTDDI_WS08) +NTKERNELAPI +NTSTATUS +NTAPI +IoReplacePartitionUnit( + IN PDEVICE_OBJECT TargetPdo, + IN PDEVICE_OBJECT SparePdo, + IN ULONG Flags); +#endif + +#if (NTDDI_VERSION >= NTDDI_WIN7) + +NTKERNELAPI +NTSTATUS +NTAPI +IoGetAffinityInterrupt( + IN PKINTERRUPT InterruptObject, + OUT PGROUP_AFFINITY GroupAffinity); + +NTSTATUS +NTAPI +IoGetContainerInformation( + IN IO_CONTAINER_INFORMATION_CLASS InformationClass, + IN PVOID ContainerObject OPTIONAL, + IN OUT PVOID Buffer OPTIONAL, + IN ULONG BufferLength); + +NTSTATUS +NTAPI +IoRegisterContainerNotification( + IN IO_CONTAINER_NOTIFICATION_CLASS NotificationClass, + IN PIO_CONTAINER_NOTIFICATION_FUNCTION CallbackFunction, + IN PVOID NotificationInformation OPTIONAL, + IN ULONG NotificationInformationLength, + OUT PVOID CallbackRegistration); + +VOID +NTAPI +IoUnregisterContainerNotification( + IN PVOID CallbackRegistration); + +NTKERNELAPI +NTSTATUS +NTAPI +IoUnregisterPlugPlayNotificationEx( + IN PVOID NotificationEntry); + +NTKERNELAPI +NTSTATUS +NTAPI +IoGetDeviceNumaNode( + IN PDEVICE_OBJECT Pdo, + OUT PUSHORT NodeNumber); + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + #if defined(_WIN64) NTKERNELAPI ULONG @@ -10509,12 +13189,57 @@ PoCreatePowerRequest( #define ExInitializeSListHead InitializeSListHead -#if defined(_X86_) -#if defined(_NTHAL_) +#if defined(_NTHAL_) && defined(_X86_) + +NTKERNELAPI +VOID +FASTCALL +ExiAcquireFastMutex( + IN OUT PFAST_MUTEX FastMutex); + +NTKERNELAPI +VOID +FASTCALL +ExiReleaseFastMutex( + IN OUT PFAST_MUTEX FastMutex); + +NTKERNELAPI +BOOLEAN +FASTCALL +ExiTryToAcquireFastMutex( + IN OUT PFAST_MUTEX FastMutex); + #define ExAcquireFastMutex ExiAcquireFastMutex #define ExReleaseFastMutex ExiReleaseFastMutex #define ExTryToAcquireFastMutex ExiTryToAcquireFastMutex -#endif + +#else + +#if (NTDDI_VERSION >= NTDDI_WIN2K) + +NTKERNELAPI +VOID +FASTCALL +ExAcquireFastMutex( + IN OUT PFAST_MUTEX FastMutex); + +NTKERNELAPI +VOID +FASTCALL +ExReleaseFastMutex( + IN OUT PFAST_MUTEX FastMutex); + +NTKERNELAPI +BOOLEAN +FASTCALL +ExTryToAcquireFastMutex( + IN OUT PFAST_MUTEX FastMutex); + +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ + +#endif /* defined(_NTHAL_) && defined(_X86_) */ + +#if defined(_X86_) #define ExInterlockedAddUlong ExfInterlockedAddUlong #define ExInterlockedInsertHeadList ExfInterlockedInsertHeadList #define ExInterlockedInsertTailList ExfInterlockedInsertTailList @@ -10572,6 +13297,8 @@ FASTCALL ExInterlockedFlushSList( IN OUT PSLIST_HEADER ListHead); +#endif /* !defined(_WIN64) */ + #if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_) NTKERNELAPI @@ -10588,20 +13315,70 @@ ExInterlockedPushEntrySList( IN PSLIST_HEADER ListHead, IN PSINGLE_LIST_ENTRY ListEntry, IN PKSPIN_LOCK Lock); -#else + +NTKERNELAPI +PVOID +NTAPI +ExAllocateFromPagedLookasideList( + IN OUT PPAGED_LOOKASIDE_LIST Lookaside); + +NTKERNELAPI +VOID +NTAPI +ExFreeToPagedLookasideList( + IN OUT PPAGED_LOOKASIDE_LIST Lookaside, + IN PVOID Entry); + +#else /* !_WIN2K_COMPAT_SLIST_USAGE */ + +#if !defined(_WIN64) #define ExInterlockedPopEntrySList(_ListHead, _Lock) \ InterlockedPopEntrySList(_ListHead) #define ExInterlockedPushEntrySList(_ListHead, _ListEntry, _Lock) \ InterlockedPushEntrySList(_ListHead, _ListEntry) -#endif // _WIN2K_COMPAT_SLIST_USAGE +#endif + +static __inline +PVOID +ExAllocateFromPagedLookasideList( + IN OUT PPAGED_LOOKASIDE_LIST Lookaside) +{ + PVOID Entry; + + Lookaside->L.TotalAllocates++; + Entry = InterlockedPopEntrySList(&Lookaside->L.ListHead); + if (Entry == NULL) { + Lookaside->L.AllocateMisses++; + Entry = (Lookaside->L.Allocate)(Lookaside->L.Type, + Lookaside->L.Size, + Lookaside->L.Tag); + } + return Entry; +} + +static __inline +VOID +ExFreeToPagedLookasideList( + IN OUT PPAGED_LOOKASIDE_LIST Lookaside, + IN PVOID Entry) +{ + Lookaside->L.TotalFrees++; + if (ExQueryDepthSList(&Lookaside->L.ListHead) >= Lookaside->L.Depth) { + Lookaside->L.FreeMisses++; + (Lookaside->L.Free)(Entry); + } else { + InterlockedPushEntrySList(&Lookaside->L.ListHead, (PSLIST_ENTRY)Entry); + } +} + +#endif /* _WIN2K_COMPAT_SLIST_USAGE */ -#endif // !defined(_WIN64) /* ERESOURCE_THREAD * ExGetCurrentResourceThread( * VOID); */ -#define ExGetCurrentResourceThread() ((ERESOURCE_THREAD)PsGetCurrentThread()) +#define ExGetCurrentResourceThread() ((ULONG_PTR)PsGetCurrentThread()) #define ExReleaseResource(R) (ExReleaseResourceLite(R)) @@ -10632,24 +13409,6 @@ ExInitializeFastMutex( #if (NTDDI_VERSION >= NTDDI_WIN2K) -NTKERNELAPI -VOID -FASTCALL -ExAcquireFastMutex( - IN OUT PFAST_MUTEX FastMutex); - -NTKERNELAPI -VOID -FASTCALL -ExReleaseFastMutex( - IN OUT PFAST_MUTEX FastMutex); - -NTKERNELAPI -BOOLEAN -FASTCALL -ExTryToAcquireFastMutex( - IN OUT PFAST_MUTEX FastMutex); - NTKERNELAPI VOID FASTCALL @@ -10697,10 +13456,6 @@ ExAllocatePool( IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes); -#ifdef POOL_TAGGING -#define ExAllocatePool(p,n) ExAllocatePoolWithTag(p,n,' kdD') -#endif /* POOL_TAGGING */ - NTKERNELAPI PVOID NTAPI @@ -10708,10 +13463,6 @@ ExAllocatePoolWithQuota( IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes); -#ifdef POOL_TAGGING -#define ExAllocatePoolWithQuota(p,n) ExAllocatePoolWithQuotaTag(p,n,' kdD') -#endif /* POOL_TAGGING */ - NTKERNELAPI PVOID NTAPI @@ -10732,6 +13483,10 @@ ExAllocatePoolWithTag( IN SIZE_T NumberOfBytes, IN ULONG Tag); +#ifndef POOL_TAGGING +#define ExAllocatePoolWithTag(a,b,c) ExAllocatePool(a,b) +#endif + NTKERNELAPI PVOID NTAPI @@ -10780,10 +13535,6 @@ NTAPI ExFreePool( IN PVOID P); -#ifdef POOL_TAGGING -#define ExFreePool(P) ExFreePoolWithTag(P, 0) -#endif - NTKERNELAPI VOID NTAPI @@ -11211,35 +13962,83 @@ ExInitializeLookasideListEx( IN SIZE_T Size, IN ULONG Tag, IN USHORT Depth); -#endif -#if !defined(MIDL_PASS) +NTKERNELAPI +VOID +NTAPI +ExDeleteLookasideListEx( + IN OUT PLOOKASIDE_LIST_EX Lookaside); -static __inline PVOID -ExAllocateFromNPagedLookasideList( - IN PNPAGED_LOOKASIDE_LIST Lookaside) +NTKERNELAPI +VOID +NTAPI +ExFlushLookasideListEx( + IN OUT PLOOKASIDE_LIST_EX Lookaside); + +FORCEINLINE +PVOID +ExAllocateFromLookasideListEx( + IN OUT PLOOKASIDE_LIST_EX Lookaside) { PVOID Entry; Lookaside->L.TotalAllocates += 1; Entry = InterlockedPopEntrySList(&Lookaside->L.ListHead); if (Entry == NULL) { - Lookaside->L.AllocateMisses++; - Entry = (Lookaside->L.Allocate)(Lookaside->L.Type, + Lookaside->L.AllocateMisses += 1; + Entry = (Lookaside->L.AllocateEx)(Lookaside->L.Type, Lookaside->L.Size, - Lookaside->L.Tag); + Lookaside->L.Tag, + Lookaside); } return Entry; } +FORCEINLINE +VOID +ExFreeToLookasideListEx( + IN OUT PLOOKASIDE_LIST_EX Lookaside, + IN PVOID Entry) +{ + Lookaside->L.TotalFrees += 1; + if (ExQueryDepthSList(&Lookaside->L.ListHead) >= Lookaside->L.Depth) { + Lookaside->L.FreeMisses += 1; + (Lookaside->L.FreeEx)(Entry, Lookaside); + } else { + InterlockedPushEntrySList(&Lookaside->L.ListHead, (PSLIST_ENTRY)Entry); + } + return; +} + +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + +#if (NTDDI_VERSION >= NTDDI_WIN7) + +NTKERNELAPI +VOID +NTAPI +ExSetResourceOwnerPointerEx( + IN OUT PERESOURCE Resource, + IN PVOID OwnerPointer, + IN ULONG Flags); + +#define FLAG_OWNER_POINTER_IS_THREAD 0x1 + +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ + static __inline PVOID -ExAllocateFromPagedLookasideList( - IN PPAGED_LOOKASIDE_LIST Lookaside) +ExAllocateFromNPagedLookasideList( + IN OUT PNPAGED_LOOKASIDE_LIST Lookaside) { PVOID Entry; Lookaside->L.TotalAllocates++; +#if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_) + Entry = ExInterlockedPopEntrySList(&Lookaside->L.ListHead, + &Lookaside->Lock__ObsoleteButDoNotDelete); +#else Entry = InterlockedPopEntrySList(&Lookaside->L.ListHead); +#endif if (Entry == NULL) { Lookaside->L.AllocateMisses++; Entry = (Lookaside->L.Allocate)(Lookaside->L.Type, @@ -11259,25 +14058,16 @@ ExFreeToNPagedLookasideList( Lookaside->L.FreeMisses++; (Lookaside->L.Free)(Entry); } else { +#if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_) + ExInterlockedPushEntrySList(&Lookaside->L.ListHead, + (PSLIST_ENTRY)Entry, + &Lookaside->Lock__ObsoleteButDoNotDelete); +#else InterlockedPushEntrySList(&Lookaside->L.ListHead, (PSLIST_ENTRY)Entry); +#endif } } -static __inline VOID -ExFreeToPagedLookasideList( - IN PPAGED_LOOKASIDE_LIST Lookaside, - IN PVOID Entry) -{ - Lookaside->L.TotalFrees++; - if (ExQueryDepthSList(&Lookaside->L.ListHead) >= Lookaside->L.Depth) { - Lookaside->L.FreeMisses++; - (Lookaside->L.Free)(Entry); - } else { - InterlockedPushEntrySList(&Lookaside->L.ListHead, (PSLIST_ENTRY)Entry); - } -} - -#endif // !defined(MIDL_PASS) /****************************************************************************** * Object Manager Functions * @@ -11513,8 +14303,115 @@ WmiTraceMessageVa( IN va_list MessageArgList); #endif +#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ + +#ifndef TRACE_INFORMATION_CLASS_DEFINE + +#if (NTDDI_VERSION >= NTDDI_WINXP) +NTKERNELAPI +NTSTATUS +NTAPI +WmiQueryTraceInformation( + IN TRACE_INFORMATION_CLASS TraceInformationClass, + OUT PVOID TraceInformation, + IN ULONG TraceInformationLength, + OUT PULONG RequiredLength OPTIONAL, + IN PVOID Buffer OPTIONAL); #endif +#define TRACE_INFORMATION_CLASS_DEFINE + +#endif /* TRACE_INFOPRMATION_CLASS_DEFINE */ + +#if (NTDDI_VERSION >= NTDDI_VISTA) + +NTSTATUS +NTKERNELAPI +NTAPI +EtwRegister( + IN LPCGUID ProviderId, + IN PETWENABLECALLBACK EnableCallback OPTIONAL, + IN PVOID CallbackContext OPTIONAL, + OUT PREGHANDLE RegHandle); + +NTSTATUS +NTKERNELAPI +NTAPI +EtwUnregister( + IN REGHANDLE RegHandle); + +BOOLEAN +NTKERNELAPI +NTAPI +EtwEventEnabled( + IN REGHANDLE RegHandle, + IN PCEVENT_DESCRIPTOR EventDescriptor); + +BOOLEAN +NTKERNELAPI +NTAPI +EtwProviderEnabled( + IN REGHANDLE RegHandle, + IN UCHAR Level, + IN ULONGLONG Keyword); + +NTSTATUS +NTKERNELAPI +NTAPI +EtwActivityIdControl( + IN ULONG ControlCode, + IN OUT LPGUID ActivityId); + +NTSTATUS +NTKERNELAPI +NTAPI +EtwWrite( + IN REGHANDLE RegHandle, + IN PCEVENT_DESCRIPTOR EventDescriptor, + IN LPCGUID ActivityId OPTIONAL, + IN ULONG UserDataCount, + IN PEVENT_DATA_DESCRIPTOR UserData OPTIONAL); + +NTSTATUS +NTKERNELAPI +NTAPI +EtwWriteTransfer( + IN REGHANDLE RegHandle, + IN PCEVENT_DESCRIPTOR EventDescriptor, + IN LPCGUID ActivityId OPTIONAL, + IN LPCGUID RelatedActivityId OPTIONAL, + IN ULONG UserDataCount, + IN PEVENT_DATA_DESCRIPTOR UserData OPTIONAL); + +NTSTATUS +NTKERNELAPI +NTAPI +EtwWriteString( + IN REGHANDLE RegHandle, + IN UCHAR Level, + IN ULONGLONG Keyword, + IN LPCGUID ActivityId OPTIONAL, + IN PCWSTR String); + +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + +#if (NTDDI_VERSION >= NTDDI_WIN7) +NTSTATUS +NTKERNELAPI +NTAPI +EtwWriteEx( + IN REGHANDLE RegHandle, + IN PCEVENT_DESCRIPTOR EventDescriptor, + IN ULONG64 Filter, + IN ULONG Flags, + IN LPCGUID ActivityId OPTIONAL, + IN LPCGUID RelatedActivityId OPTIONAL, + IN ULONG UserDataCount, + IN PEVENT_DATA_DESCRIPTOR UserData OPTIONAL); +#endif + + + /****************************************************************************** * Kernel Debugger Functions * ******************************************************************************/ @@ -11526,8 +14423,86 @@ __cdecl DbgPrint( IN PCSTR Format, IN ...); + +#if (NTDDI_VERSION >= NTDDI_WIN2K) +NTSYSAPI +ULONG +__cdecl +DbgPrintReturnControlC( + IN PCCH Format, + IN ...); #endif +#if (NTDDI_VERSION >= NTDDI_WINXP) + +NTSYSAPI +ULONG +__cdecl +DbgPrintEx( + IN ULONG ComponentId, + IN ULONG Level, + IN PCSTR Format, + IN ...); + +#ifdef _VA_LIST_DEFINED + +NTSYSAPI +ULONG +NTAPI +vDbgPrintEx( + IN ULONG ComponentId, + IN ULONG Level, + IN PCCH Format, + IN va_list ap); + +NTSYSAPI +ULONG +NTAPI +vDbgPrintExWithPrefix( + IN PCCH Prefix, + IN ULONG ComponentId, + IN ULONG Level, + IN PCCH Format, + IN va_list ap); + +#endif /* _VA_LIST_DEFINED */ + +NTSYSAPI +NTSTATUS +NTAPI +DbgQueryDebugFilterState( + IN ULONG ComponentId, + IN ULONG Level); + +NTSYSAPI +NTSTATUS +NTAPI +DbgSetDebugFilterState( + IN ULONG ComponentId, + IN ULONG Level, + IN BOOLEAN State); + +#endif /* (NTDDI_VERSION >= NTDDI_WINXP) */ + +#if (NTDDI_VERSION >= NTDDI_VISTA) + +typedef VOID +(*PDEBUG_PRINT_CALLBACK)( + IN PSTRING Output, + IN ULONG ComponentId, + IN ULONG Level); + +NTSYSAPI +NTSTATUS +NTAPI +DbgSetDebugPrintCallback( + IN PDEBUG_PRINT_CALLBACK DebugPrintCallback, + IN BOOLEAN Enable); + +#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */ + +#endif /* _DBGNT_ */ + #if DBG #define KdPrint(_x_) DbgPrint _x_ @@ -11571,31 +14546,6 @@ extern BOOLEAN KdDebuggerEnabled; #endif -#ifdef _VA_LIST_DEFINED -#if (NTDDI_VERSION >= NTDDI_WINXP) - -NTSYSAPI -ULONG -NTAPI -vDbgPrintEx( - IN ULONG ComponentId, - IN ULONG Level, - IN PCCH Format, - IN va_list ap); - -NTSYSAPI -ULONG -NTAPI -vDbgPrintExWithPrefix( - IN PCCH Prefix, - IN ULONG ComponentId, - IN ULONG Level, - IN PCCH Format, - IN va_list ap); - -#endif -#endif // _VA_LIST_DEFINED - #if (NTDDI_VERSION >= NTDDI_WIN2K) NTKERNELAPI @@ -11622,42 +14572,7 @@ NTAPI DbgBreakPointWithStatus( IN ULONG Status); -NTSYSAPI -ULONG -_cdecl -DbgPrintReturnControlC( - IN PCCH Format, - IN ...); - -#endif - -#if (NTDDI_VERSION >= NTDDI_WINXP) - -NTSYSAPI -ULONG -_cdecl -DbgPrintEx( - IN ULONG ComponentId, - IN ULONG Level, - IN PCSTR Format, - IN ...); - -NTSYSAPI -NTSTATUS -NTAPI -DbgQueryDebugFilterState( - IN ULONG ComponentId, - IN ULONG Level); - -NTSYSAPI -NTSTATUS -NTAPI -DbgSetDebugFilterState( - IN ULONG ComponentId, - IN ULONG Level, - IN BOOLEAN State); - -#endif +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ #if (NTDDI_VERSION >= NTDDI_WS03) NTKERNELAPI @@ -11678,6 +14593,9 @@ KdChangeOption( OUT PVOID OutBuffer, OUT PULONG OutBufferNeeded OPTIONAL); #endif +/* Hardware Abstraction Layer Functions */ + +#if (NTDDI_VERSION >= NTDDI_WIN2K) #if defined(USE_DMA_MACROS) && !defined(_NTHAL_) && (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_) @@ -11731,14 +14649,224 @@ HalReadDmaCounter( return counter; } -#endif +FORCEINLINE +ULONG +HalGetDmaAlignment( + IN PDMA_ADAPTER DmaAdapter) +{ + PGET_DMA_ALIGNMENT getDmaAlignment; + ULONG alignment; + getDmaAlignment = *(DmaAdapter)->DmaOperations->GetDmaAlignment; + ASSERT( getDmaAlignment != NULL ); + alignment = getDmaAlignment( DmaAdapter ); + return alignment; +} + +#endif /* USE_DMA_MACROS ... */ +#endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */ #ifndef _NTTMAPI_ #define _NTTMAPI_ #include +#define TRANSACTIONMANAGER_QUERY_INFORMATION (0x0001) +#define TRANSACTIONMANAGER_SET_INFORMATION (0x0002) +#define TRANSACTIONMANAGER_RECOVER (0x0004) +#define TRANSACTIONMANAGER_RENAME (0x0008) +#define TRANSACTIONMANAGER_CREATE_RM (0x0010) +#define TRANSACTIONMANAGER_BIND_TRANSACTION (0x0020) + +#define TRANSACTIONMANAGER_GENERIC_READ (STANDARD_RIGHTS_READ |\ + TRANSACTIONMANAGER_QUERY_INFORMATION) + +#define TRANSACTIONMANAGER_GENERIC_WRITE (STANDARD_RIGHTS_WRITE |\ + TRANSACTIONMANAGER_SET_INFORMATION |\ + TRANSACTIONMANAGER_RECOVER |\ + TRANSACTIONMANAGER_RENAME |\ + TRANSACTIONMANAGER_CREATE_RM) + +#define TRANSACTIONMANAGER_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE) + +#define TRANSACTIONMANAGER_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED |\ + TRANSACTIONMANAGER_GENERIC_READ |\ + TRANSACTIONMANAGER_GENERIC_WRITE |\ + TRANSACTIONMANAGER_GENERIC_EXECUTE |\ + TRANSACTIONMANAGER_BIND_TRANSACTION) + +#define TRANSACTION_QUERY_INFORMATION (0x0001) +#define TRANSACTION_SET_INFORMATION (0x0002) +#define TRANSACTION_ENLIST (0x0004) +#define TRANSACTION_COMMIT (0x0008) +#define TRANSACTION_ROLLBACK (0x0010) +#define TRANSACTION_PROPAGATE (0x0020) +#define TRANSACTION_RIGHT_RESERVED1 (0x0040) + +#define TRANSACTION_GENERIC_READ (STANDARD_RIGHTS_READ |\ + TRANSACTION_QUERY_INFORMATION |\ + SYNCHRONIZE) + +#define TRANSACTION_GENERIC_WRITE (STANDARD_RIGHTS_WRITE |\ + TRANSACTION_SET_INFORMATION |\ + TRANSACTION_COMMIT |\ + TRANSACTION_ENLIST |\ + TRANSACTION_ROLLBACK |\ + TRANSACTION_PROPAGATE |\ + SYNCHRONIZE) + +#define TRANSACTION_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE |\ + TRANSACTION_COMMIT |\ + TRANSACTION_ROLLBACK |\ + SYNCHRONIZE) + +#define TRANSACTION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED |\ + TRANSACTION_GENERIC_READ |\ + TRANSACTION_GENERIC_WRITE |\ + TRANSACTION_GENERIC_EXECUTE) + +#define TRANSACTION_RESOURCE_MANAGER_RIGHTS (TRANSACTION_GENERIC_READ |\ + STANDARD_RIGHTS_WRITE |\ + TRANSACTION_SET_INFORMATION |\ + TRANSACTION_ENLIST |\ + TRANSACTION_ROLLBACK |\ + TRANSACTION_PROPAGATE |\ + SYNCHRONIZE) + +#define RESOURCEMANAGER_QUERY_INFORMATION (0x0001) +#define RESOURCEMANAGER_SET_INFORMATION (0x0002) +#define RESOURCEMANAGER_RECOVER (0x0004) +#define RESOURCEMANAGER_ENLIST (0x0008) +#define RESOURCEMANAGER_GET_NOTIFICATION (0x0010) +#define RESOURCEMANAGER_REGISTER_PROTOCOL (0x0020) +#define RESOURCEMANAGER_COMPLETE_PROPAGATION (0x0040) + +#define RESOURCEMANAGER_GENERIC_READ (STANDARD_RIGHTS_READ |\ + RESOURCEMANAGER_QUERY_INFORMATION |\ + SYNCHRONIZE) + +#define RESOURCEMANAGER_GENERIC_WRITE (STANDARD_RIGHTS_WRITE |\ + RESOURCEMANAGER_SET_INFORMATION |\ + RESOURCEMANAGER_RECOVER |\ + RESOURCEMANAGER_ENLIST |\ + RESOURCEMANAGER_GET_NOTIFICATION |\ + RESOURCEMANAGER_REGISTER_PROTOCOL |\ + RESOURCEMANAGER_COMPLETE_PROPAGATION |\ + SYNCHRONIZE) + +#define RESOURCEMANAGER_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE |\ + RESOURCEMANAGER_RECOVER |\ + RESOURCEMANAGER_ENLIST |\ + RESOURCEMANAGER_GET_NOTIFICATION |\ + RESOURCEMANAGER_COMPLETE_PROPAGATION |\ + SYNCHRONIZE) + +#define RESOURCEMANAGER_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED |\ + RESOURCEMANAGER_GENERIC_READ |\ + RESOURCEMANAGER_GENERIC_WRITE |\ + RESOURCEMANAGER_GENERIC_EXECUTE) + +#define ENLISTMENT_QUERY_INFORMATION (0x0001) +#define ENLISTMENT_SET_INFORMATION (0x0002) +#define ENLISTMENT_RECOVER (0x0004) +#define ENLISTMENT_SUBORDINATE_RIGHTS (0x0008) +#define ENLISTMENT_SUPERIOR_RIGHTS (0x0010) + +#define ENLISTMENT_GENERIC_READ (STANDARD_RIGHTS_READ |\ + ENLISTMENT_QUERY_INFORMATION) + +#define ENLISTMENT_GENERIC_WRITE (STANDARD_RIGHTS_WRITE |\ + ENLISTMENT_SET_INFORMATION |\ + ENLISTMENT_RECOVER |\ + ENLISTMENT_SUBORDINATE_RIGHTS |\ + ENLISTMENT_SUPERIOR_RIGHTS) + +#define ENLISTMENT_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE |\ + ENLISTMENT_RECOVER |\ + ENLISTMENT_SUBORDINATE_RIGHTS |\ + ENLISTMENT_SUPERIOR_RIGHTS) + +#define ENLISTMENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED |\ + ENLISTMENT_GENERIC_READ |\ + ENLISTMENT_GENERIC_WRITE |\ + ENLISTMENT_GENERIC_EXECUTE) + +typedef enum _TRANSACTION_OUTCOME { + TransactionOutcomeUndetermined = 1, + TransactionOutcomeCommitted, + TransactionOutcomeAborted, +} TRANSACTION_OUTCOME; + + +typedef enum _TRANSACTION_STATE { + TransactionStateNormal = 1, + TransactionStateIndoubt, + TransactionStateCommittedNotify, +} TRANSACTION_STATE; + + +typedef struct _TRANSACTION_BASIC_INFORMATION { + GUID TransactionId; + ULONG State; + ULONG Outcome; +} TRANSACTION_BASIC_INFORMATION, *PTRANSACTION_BASIC_INFORMATION; + +typedef struct _TRANSACTIONMANAGER_BASIC_INFORMATION { + GUID TmIdentity; + LARGE_INTEGER VirtualClock; +} TRANSACTIONMANAGER_BASIC_INFORMATION, *PTRANSACTIONMANAGER_BASIC_INFORMATION; + +typedef struct _TRANSACTIONMANAGER_LOG_INFORMATION { + GUID LogIdentity; +} TRANSACTIONMANAGER_LOG_INFORMATION, *PTRANSACTIONMANAGER_LOG_INFORMATION; + +typedef struct _TRANSACTIONMANAGER_LOGPATH_INFORMATION { + ULONG LogPathLength; + WCHAR LogPath[1]; +} TRANSACTIONMANAGER_LOGPATH_INFORMATION, *PTRANSACTIONMANAGER_LOGPATH_INFORMATION; + +typedef struct _TRANSACTIONMANAGER_RECOVERY_INFORMATION { + ULONGLONG LastRecoveredLsn; +} TRANSACTIONMANAGER_RECOVERY_INFORMATION, *PTRANSACTIONMANAGER_RECOVERY_INFORMATION; + +typedef struct _TRANSACTION_PROPERTIES_INFORMATION { + ULONG IsolationLevel; + ULONG IsolationFlags; + LARGE_INTEGER Timeout; + ULONG Outcome; + ULONG DescriptionLength; + WCHAR Description[1]; +} TRANSACTION_PROPERTIES_INFORMATION, *PTRANSACTION_PROPERTIES_INFORMATION; + +typedef struct _TRANSACTION_BIND_INFORMATION { + HANDLE TmHandle; +} TRANSACTION_BIND_INFORMATION, *PTRANSACTION_BIND_INFORMATION; + +typedef struct _TRANSACTION_ENLISTMENT_PAIR { + GUID EnlistmentId; + GUID ResourceManagerId; +} TRANSACTION_ENLISTMENT_PAIR, *PTRANSACTION_ENLISTMENT_PAIR; + +typedef struct _TRANSACTION_ENLISTMENTS_INFORMATION { + ULONG NumberOfEnlistments; + TRANSACTION_ENLISTMENT_PAIR EnlistmentPair[1]; +} TRANSACTION_ENLISTMENTS_INFORMATION, *PTRANSACTION_ENLISTMENTS_INFORMATION; + +typedef struct _TRANSACTION_SUPERIOR_ENLISTMENT_INFORMATION { + TRANSACTION_ENLISTMENT_PAIR SuperiorEnlistmentPair; +} TRANSACTION_SUPERIOR_ENLISTMENT_INFORMATION, *PTRANSACTION_SUPERIOR_ENLISTMENT_INFORMATION; + +typedef struct _RESOURCEMANAGER_BASIC_INFORMATION { + GUID ResourceManagerId; + ULONG DescriptionLength; + WCHAR Description[1]; +} RESOURCEMANAGER_BASIC_INFORMATION, *PRESOURCEMANAGER_BASIC_INFORMATION; + +typedef struct _RESOURCEMANAGER_COMPLETION_INFORMATION { + HANDLE IoCompletionPortHandle; + ULONG_PTR CompletionKey; +} RESOURCEMANAGER_COMPLETION_INFORMATION, *PRESOURCEMANAGER_COMPLETION_INFORMATION; + typedef enum _KTMOBJECT_TYPE { KTMOBJECT_TRANSACTION, KTMOBJECT_TRANSACTION_MANAGER, @@ -11772,12 +14900,421 @@ typedef enum _RESOURCEMANAGER_INFORMATION_CLASS { ResourceManagerCompletionInformation, } RESOURCEMANAGER_INFORMATION_CLASS; +typedef struct _ENLISTMENT_BASIC_INFORMATION { + GUID EnlistmentId; + GUID TransactionId; + GUID ResourceManagerId; +} ENLISTMENT_BASIC_INFORMATION, *PENLISTMENT_BASIC_INFORMATION; + +typedef struct _ENLISTMENT_CRM_INFORMATION { + GUID CrmTransactionManagerId; + GUID CrmResourceManagerId; + GUID CrmEnlistmentId; +} ENLISTMENT_CRM_INFORMATION, *PENLISTMENT_CRM_INFORMATION; + typedef enum _ENLISTMENT_INFORMATION_CLASS { EnlistmentBasicInformation, EnlistmentRecoveryInformation, EnlistmentCrmInformation } ENLISTMENT_INFORMATION_CLASS; +typedef struct _TRANSACTION_LIST_ENTRY { +#if defined(__cplusplus) + ::UOW UOW; +#else + UOW UOW; +#endif +} TRANSACTION_LIST_ENTRY, *PTRANSACTION_LIST_ENTRY; + +typedef struct _TRANSACTION_LIST_INFORMATION { + ULONG NumberOfTransactions; + TRANSACTION_LIST_ENTRY TransactionInformation[1]; +} TRANSACTION_LIST_INFORMATION, *PTRANSACTION_LIST_INFORMATION; + +typedef NTSTATUS +(NTAPI *PFN_NT_CREATE_TRANSACTION)( + OUT PHANDLE TransactionHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, + IN LPGUID Uow OPTIONAL, + IN HANDLE TmHandle OPTIONAL, + IN ULONG CreateOptions OPTIONAL, + IN ULONG IsolationLevel OPTIONAL, + IN ULONG IsolationFlags OPTIONAL, + IN PLARGE_INTEGER Timeout OPTIONAL, + IN PUNICODE_STRING Description OPTIONAL); + +typedef NTSTATUS +(NTAPI *PFN_NT_OPEN_TRANSACTION)( + OUT PHANDLE TransactionHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN LPGUID Uow OPTIONAL, + IN HANDLE TmHandle OPTIONAL); + +typedef NTSTATUS +(NTAPI *PFN_NT_QUERY_INFORMATION_TRANSACTION)( + IN HANDLE TransactionHandle, + IN TRANSACTION_INFORMATION_CLASS TransactionInformationClass, + OUT PVOID TransactionInformation, + IN ULONG TransactionInformationLength, + OUT PULONG ReturnLength OPTIONAL); + +typedef NTSTATUS +(NTAPI *PFN_NT_SET_INFORMATION_TRANSACTION)( + IN HANDLE TransactionHandle, + IN TRANSACTION_INFORMATION_CLASS TransactionInformationClass, + IN PVOID TransactionInformation, + IN ULONG TransactionInformationLength); + +typedef NTSTATUS +(NTAPI *PFN_NT_COMMIT_TRANSACTION)( + IN HANDLE TransactionHandle, + IN BOOLEAN Wait); + +typedef NTSTATUS +(NTAPI *PFN_NT_ROLLBACK_TRANSACTION)( + IN HANDLE TransactionHandle, + IN BOOLEAN Wait); + +#if (NTDDI_VERSION >= NTDDI_VISTA) + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtCreateTransactionManager( + OUT PHANDLE TmHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, + IN PUNICODE_STRING LogFileName OPTIONAL, + IN ULONG CreateOptions OPTIONAL, + IN ULONG CommitStrength OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtOpenTransactionManager( + OUT PHANDLE TmHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, + IN PUNICODE_STRING LogFileName OPTIONAL, + IN LPGUID TmIdentity OPTIONAL, + IN ULONG OpenOptions OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtRenameTransactionManager( + IN PUNICODE_STRING LogFileName, + IN LPGUID ExistingTransactionManagerGuid); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtRollforwardTransactionManager( + IN HANDLE TransactionManagerHandle, + IN PLARGE_INTEGER TmVirtualClock OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtRecoverTransactionManager( + IN HANDLE TransactionManagerHandle); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtQueryInformationTransactionManager( + IN HANDLE TransactionManagerHandle, + IN TRANSACTIONMANAGER_INFORMATION_CLASS TransactionManagerInformationClass, + OUT PVOID TransactionManagerInformation, + IN ULONG TransactionManagerInformationLength, + OUT PULONG ReturnLength); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtSetInformationTransactionManager( + IN HANDLE TmHandle OPTIONAL, + IN TRANSACTIONMANAGER_INFORMATION_CLASS TransactionManagerInformationClass, + IN PVOID TransactionManagerInformation, + IN ULONG TransactionManagerInformationLength); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtEnumerateTransactionObject( + IN HANDLE RootObjectHandle OPTIONAL, + IN KTMOBJECT_TYPE QueryType, + IN OUT PKTMOBJECT_CURSOR ObjectCursor, + IN ULONG ObjectCursorLength, + OUT PULONG ReturnLength); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtCreateTransaction( + OUT PHANDLE TransactionHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, + IN LPGUID Uow OPTIONAL, + IN HANDLE TmHandle OPTIONAL, + IN ULONG CreateOptions OPTIONAL, + IN ULONG IsolationLevel OPTIONAL, + IN ULONG IsolationFlags OPTIONAL, + IN PLARGE_INTEGER Timeout OPTIONAL, + IN PUNICODE_STRING Description OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtOpenTransaction( + OUT PHANDLE TransactionHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN LPGUID Uow, + IN HANDLE TmHandle OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtQueryInformationTransaction( + IN HANDLE TransactionHandle, + IN TRANSACTION_INFORMATION_CLASS TransactionInformationClass, + OUT PVOID TransactionInformation, + IN ULONG TransactionInformationLength, + OUT PULONG ReturnLength OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtSetInformationTransaction( + IN HANDLE TransactionHandle, + IN TRANSACTION_INFORMATION_CLASS TransactionInformationClass, + IN PVOID TransactionInformation, + IN ULONG TransactionInformationLength); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtCommitTransaction( + IN HANDLE TransactionHandle, + IN BOOLEAN Wait); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtRollbackTransaction( + IN HANDLE TransactionHandle, + IN BOOLEAN Wait); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtCreateEnlistment( + OUT PHANDLE EnlistmentHandle, + IN ACCESS_MASK DesiredAccess, + IN HANDLE ResourceManagerHandle, + IN HANDLE TransactionHandle, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, + IN ULONG CreateOptions OPTIONAL, + IN NOTIFICATION_MASK NotificationMask, + IN PVOID EnlistmentKey OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtOpenEnlistment( + OUT PHANDLE EnlistmentHandle, + IN ACCESS_MASK DesiredAccess, + IN HANDLE ResourceManagerHandle, + IN LPGUID EnlistmentGuid, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtQueryInformationEnlistment( + IN HANDLE EnlistmentHandle, + IN ENLISTMENT_INFORMATION_CLASS EnlistmentInformationClass, + OUT PVOID EnlistmentInformation, + IN ULONG EnlistmentInformationLength, + OUT PULONG ReturnLength); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtSetInformationEnlistment( + IN HANDLE EnlistmentHandle OPTIONAL, + IN ENLISTMENT_INFORMATION_CLASS EnlistmentInformationClass, + IN PVOID EnlistmentInformation, + IN ULONG EnlistmentInformationLength); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtRecoverEnlistment( + IN HANDLE EnlistmentHandle, + IN PVOID EnlistmentKey OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtPrePrepareEnlistment( + IN HANDLE EnlistmentHandle, + IN PLARGE_INTEGER TmVirtualClock OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtPrepareEnlistment( + IN HANDLE EnlistmentHandle, + IN PLARGE_INTEGER TmVirtualClock OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtCommitEnlistment( + IN HANDLE EnlistmentHandle, + IN PLARGE_INTEGER TmVirtualClock OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtRollbackEnlistment( + IN HANDLE EnlistmentHandle, + IN PLARGE_INTEGER TmVirtualClock OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtPrePrepareComplete( + IN HANDLE EnlistmentHandle, + IN PLARGE_INTEGER TmVirtualClock OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtPrepareComplete( + IN HANDLE EnlistmentHandle, + IN PLARGE_INTEGER TmVirtualClock OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtCommitComplete( + IN HANDLE EnlistmentHandle, + IN PLARGE_INTEGER TmVirtualClock OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtReadOnlyEnlistment( + IN HANDLE EnlistmentHandle, + IN PLARGE_INTEGER TmVirtualClock OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtRollbackComplete( + IN HANDLE EnlistmentHandle, + IN PLARGE_INTEGER TmVirtualClock OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtSinglePhaseReject( + IN HANDLE EnlistmentHandle, + IN PLARGE_INTEGER TmVirtualClock OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtCreateResourceManager( + OUT PHANDLE ResourceManagerHandle, + IN ACCESS_MASK DesiredAccess, + IN HANDLE TmHandle, + IN LPGUID RmGuid, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, + IN ULONG CreateOptions OPTIONAL, + IN PUNICODE_STRING Description OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtOpenResourceManager( + OUT PHANDLE ResourceManagerHandle, + IN ACCESS_MASK DesiredAccess, + IN HANDLE TmHandle, + IN LPGUID ResourceManagerGuid OPTIONAL, + IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtRecoverResourceManager( + IN HANDLE ResourceManagerHandle); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtGetNotificationResourceManager( + IN HANDLE ResourceManagerHandle, + OUT PTRANSACTION_NOTIFICATION TransactionNotification, + IN ULONG NotificationLength, + IN PLARGE_INTEGER Timeout OPTIONAL, + OUT PULONG ReturnLength OPTIONAL, + IN ULONG Asynchronous, + IN ULONG_PTR AsynchronousContext OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtQueryInformationResourceManager( + IN HANDLE ResourceManagerHandle, + IN RESOURCEMANAGER_INFORMATION_CLASS ResourceManagerInformationClass, + OUT PVOID ResourceManagerInformation, + IN ULONG ResourceManagerInformationLength, + OUT PULONG ReturnLength OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtSetInformationResourceManager( + IN HANDLE ResourceManagerHandle, + IN RESOURCEMANAGER_INFORMATION_CLASS ResourceManagerInformationClass, + IN PVOID ResourceManagerInformation, + IN ULONG ResourceManagerInformationLength); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtRegisterProtocolAddressInformation( + IN HANDLE ResourceManager, + IN PCRM_PROTOCOL_ID ProtocolId, + IN ULONG ProtocolInformationSize, + IN PVOID ProtocolInformation, + IN ULONG CreateOptions OPTIONAL); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtPropagationComplete( + IN HANDLE ResourceManagerHandle, + IN ULONG RequestCookie, + IN ULONG BufferLength, + IN PVOID Buffer); + +NTSYSCALLAPI +NTSTATUS +NTAPI +NtPropagationFailed( + IN HANDLE ResourceManagerHandle, + IN ULONG RequestCookie, + IN NTSTATUS PropStatus); + +#endif /* NTDDI_VERSION >= NTDDI_VISTA */ + #endif /* !_NTTMAPI_ */ /****************************************************************************** * ZwXxx Functions * @@ -12469,78 +16006,8 @@ ZwSetInformationKey( IN PVOID KeySetInformation, IN ULONG KeySetInformationLength); -#endif - -/****************************************************************************** - * Unsorted * - ******************************************************************************/ - -/* GUID Comparison */ -#ifndef __IID_ALIGNED__ -#define __IID_ALIGNED__ -#ifdef __cplusplus -inline int IsEqualGUIDAligned(REFGUID guid1, REFGUID guid2) -{ - return ( (*(PLONGLONG)(&guid1) == *(PLONGLONG)(&guid2)) && - (*((PLONGLONG)(&guid1) + 1) == *((PLONGLONG)(&guid2) + 1)) ); -} -#else -#define IsEqualGUIDAligned(guid1, guid2) \ - ( (*(PLONGLONG)(guid1) == *(PLONGLONG)(guid2)) && \ - (*((PLONGLONG)(guid1) + 1) == *((PLONGLONG)(guid2) + 1)) ) -#endif /* __cplusplus */ -#endif /* !__IID_ALIGNED__ */ - -typedef enum { - LT_DONT_CARE, - LT_LOWEST_LATENCY -} LATENCY_TIME; - -#define MAXIMUM_SUSPEND_COUNT MAXCHAR - -#define MAXIMUM_FILENAME_LENGTH 256 - -#define OBJ_NAME_PATH_SEPARATOR ((WCHAR)L'\\') - -#define OBJECT_TYPE_CREATE (0x0001) -#define OBJECT_TYPE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0x1) - -#define DIRECTORY_QUERY (0x0001) -#define DIRECTORY_TRAVERSE (0x0002) -#define DIRECTORY_CREATE_OBJECT (0x0004) -#define DIRECTORY_CREATE_SUBDIRECTORY (0x0008) -#define DIRECTORY_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0xF) - -#define EVENT_QUERY_STATE (0x0001) -#define EVENT_MODIFY_STATE (0x0002) -#define EVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3) - -#define SEMAPHORE_QUERY_STATE (0x0001) -#define SEMAPHORE_MODIFY_STATE (0x0002) -#define SEMAPHORE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3) - -#define SYMBOLIC_LINK_QUERY 0x0001 -#define SYMBOLIC_LINK_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | 0x1) - -#define DUPLICATE_CLOSE_SOURCE 0x00000001 -#define DUPLICATE_SAME_ACCESS 0x00000002 -#define DUPLICATE_SAME_ATTRIBUTES 0x00000004 - -/* Global debug flag */ -extern ULONG NtGlobalFlag; - -/* Service Start Types */ -#define SERVICE_BOOT_START 0x00000000 -#define SERVICE_SYSTEM_START 0x00000001 -#define SERVICE_AUTO_START 0x00000002 -#define SERVICE_DEMAND_START 0x00000003 -#define SERVICE_DISABLED 0x00000004 - -#ifndef _TRACEHANDLE_DEFINED -#define _TRACEHANDLE_DEFINED -typedef ULONG64 TRACEHANDLE, *PTRACEHANDLE; -#endif +#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ #ifdef __cplusplus diff --git a/reactos/include/ndk/ketypes.h b/reactos/include/ndk/ketypes.h index d4ae1c545f0..67985379372 100644 --- a/reactos/include/ndk/ketypes.h +++ b/reactos/include/ndk/ketypes.h @@ -546,17 +546,6 @@ typedef enum _KAPC_ENVIRONMENT InsertApcEnvironment } KAPC_ENVIRONMENT; -// -// CPU Cache Types -// -typedef enum _PROCESSOR_CACHE_TYPE -{ - CacheUnified, - CacheInstruction, - CacheData, - CacheTrace, -} PROCESSOR_CACHE_TYPE; - // // PRCB DPC Data // @@ -577,18 +566,6 @@ typedef struct _PP_LOOKASIDE_LIST struct _GENERAL_LOOKASIDE *L; } PP_LOOKASIDE_LIST, *PPP_LOOKASIDE_LIST; -// -// CPU Cache Descriptor -// -typedef struct _CACHE_DESCRIPTOR -{ - UCHAR Level; - UCHAR Associativity; - USHORT LineSize; - ULONG Size; - PROCESSOR_CACHE_TYPE Type; -} CACHE_DESCRIPTOR, *PCACHE_DESCRIPTOR; - // // Architectural Types // From a5bffa590240eb37ae5cb9eb4a16258230f811a1 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Tue, 30 Mar 2010 07:56:58 +0000 Subject: [PATCH 099/134] Don't add underscore prefix to amd64 symbols svn path=/trunk/; revision=46588 --- reactos/tools/rbuild/backend/mingw/linkers/ld.mak | 14 ++++++++++---- reactos/tools/rbuild/module.cpp | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/reactos/tools/rbuild/backend/mingw/linkers/ld.mak b/reactos/tools/rbuild/backend/mingw/linkers/ld.mak index cbcc2bc0edb..88da818491e 100644 --- a/reactos/tools/rbuild/backend/mingw/linkers/ld.mak +++ b/reactos/tools/rbuild/backend/mingw/linkers/ld.mak @@ -6,6 +6,12 @@ LDFLAG_CONSOLE:=--subsystem=console LDFLAG_WINDOWS:=--subsystem=windows LDFLAG_NATIVE:=--subsystem=native +LDFLAG_EXCLUDE_ALL_SYMBOLS=-exclude-all-symbols +DLLTOOL_FLAGS=--kill-at +ifeq ($(ARCH),amd64) + DLLTOOL_FLAGS= --no-leading-underscore +endif + #~ #(module, objs, deps, ldflags, output, def, libs, entry, base) #(module, objs, deps, ldflags, output, def, libs, entry, base, extralibs) define RBUILD_LINK @@ -13,15 +19,15 @@ define RBUILD_LINK ifneq ($(6),) ${call RBUILD_intermediate_dir,$(5)}$$(SEP)lib${call RBUILD_name,$(5)}.a: $(6) | ${call RBUILD_intermediate_path,$(5)} $$(ECHO_IMPLIB) - $${dlltool} --def $(6) --kill-at --output-lib=$$@ + $${dlltool} --def $(6) $(DLLTOOL_FLAGS) --output-lib=$$@ ${call RBUILD_intermediate_dir,$(5)}$$(SEP)lib${call RBUILD_name,$(5)}.delayimp.a: $(6) | ${call RBUILD_intermediate_path,$(5)} $$(ECHO_IMPLIB) - $${dlltool} --def $(6) --kill-at --output-delaylib=$$@ + $${dlltool} --def $(6) $(DLLTOOL_FLAGS) --output-delaylib=$$@ ${call RBUILD_intermediate_path_noext,$(5)}.exp: $(6) | ${call RBUILD_intermediate_path,$(5)} $$(ECHO_IMPLIB) - $${dlltool} --def $(6) --kill-at --output-exp=$$@ + $${dlltool} --def $(6) $(DLLTOOL_FLAGS) --output-exp=$$@ $(1)_CLEANFILES+=\ ${call RBUILD_intermediate_dir,$(5)}$$(SEP)lib$(notdir $(5)).a \ @@ -81,4 +87,4 @@ endef #~ #(module, def, deps, ldflags, libs, entry, base) #~ RBUILD_LINK_RULE=${call RBUILD_LINK,$(1),$(value $(1)_OBJS),$(3),$(4),$(value $(1)_TARGET),$(2),$(5) $(value $(1)_LIBS) $(5),$(6),$(7)} #(module, def, deps, ldflags, libs, entry, base, extralibs) -RBUILD_LINK_RULE=${call RBUILD_LINK,$(1),$(value $(1)_OBJS),$(3),$(4),$(value $(1)_TARGET),$(2),$(value $(1)_LIBS),$(6),$(7),$(5)} +RBUILD_LINK_RULE=${call RBUILD_LINK,$(1),$(value $(1)_OBJS),$(3),$(4),$(value $(1)_TARGET),$(2),$(value $(1)_LIBS),$(6),$(7),$(5)} \ No newline at end of file diff --git a/reactos/tools/rbuild/module.cpp b/reactos/tools/rbuild/module.cpp index 1fdc5d64964..38a104a12f9 100644 --- a/reactos/tools/rbuild/module.cpp +++ b/reactos/tools/rbuild/module.cpp @@ -1358,7 +1358,7 @@ Module::GetEntryPoint() const if (entrypoint == "0" || entrypoint == "0x0") return "0"; - if (Environment::GetArch() != "arm") + if (Environment::GetArch() != "arm" && Environment::GetArch() != "amd64") result = "_"; result += entrypoint; From 8627f5ae27ed0e2c35383b3d977030926719d9d3 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Tue, 30 Mar 2010 11:09:21 +0000 Subject: [PATCH 100/134] Merge from amd64-branch: 44467, 44468, 44470, 44471, 46524 [OLDNAMES] Update moldname-msvcrt.def Add a proper oldnames lib, instead of implicitly including it with mingw. 46526 [FTP/DHCP] - remove the oldnames hack, as we now have a proper oldnames lib (included in mingw_common) - protect struct timezone from redefinition svn path=/trunk/; revision=46592 --- reactos/ReactOS-amd64.rbuild | 4 +- reactos/base/applications/network/ftp/fake.h | 9 +- .../base/applications/network/ftp/ftp.rbuild | 12 +- reactos/base/services/dhcp/dhcp.rbuild | 7 +- reactos/lib/3rdparty/mingw/mingw.rbuild | 10 +- .../lib/3rdparty/mingw/moldname-msvcrt.def | 233 +++++++++--------- 6 files changed, 138 insertions(+), 137 deletions(-) diff --git a/reactos/ReactOS-amd64.rbuild b/reactos/ReactOS-amd64.rbuild index 0da944fd749..6d9f8640d08 100644 --- a/reactos/ReactOS-amd64.rbuild +++ b/reactos/ReactOS-amd64.rbuild @@ -1,6 +1,6 @@ - + @@ -28,12 +28,14 @@ -ftracer -momit-leaf-frame-pointer + -fms-extensions -mpreferred-stack-boundary=4 -m64 --win64 -U_X86_ -Wno-format + -fno-leading-underscore diff --git a/reactos/base/applications/network/ftp/fake.h b/reactos/base/applications/network/ftp/fake.h index f622c401970..a22009886bd 100644 --- a/reactos/base/applications/network/ftp/fake.h +++ b/reactos/base/applications/network/ftp/fake.h @@ -9,9 +9,12 @@ #define strcasecmp _stricmp #define strncasecmp _strnicmp +#ifndef _TIMEZONE_DEFINED /* also in sys/time.h */ +#define _TIMEZONE_DEFINED struct timezone { - int tz_minuteswest; /* minutes W of Greenwich */ - int tz_dsttime; /* type of dst correction */ + int tz_minuteswest; + int tz_dsttime; }; -int gettimeofday(struct timeval *tv, struct timezone *tz); + extern int __cdecl gettimeofday (struct timeval *p, struct timezone *z); +#endif diff --git a/reactos/base/applications/network/ftp/ftp.rbuild b/reactos/base/applications/network/ftp/ftp.rbuild index 193fa6e8ebd..fce05853523 100644 --- a/reactos/base/applications/network/ftp/ftp.rbuild +++ b/reactos/base/applications/network/ftp/ftp.rbuild @@ -4,19 +4,9 @@ . - - _chdir - _getcwd - _mktemp - _unlink - _close - _fileno - _read - _write - _lseek - ws2_32 iphlpapi + oldnames cmds.c cmdtab.c domacro.c diff --git a/reactos/base/services/dhcp/dhcp.rbuild b/reactos/base/services/dhcp/dhcp.rbuild index c886e4a4918..ffa05b78465 100644 --- a/reactos/base/services/dhcp/dhcp.rbuild +++ b/reactos/base/services/dhcp/dhcp.rbuild @@ -4,16 +4,11 @@ . include - - _tzset - _close - _read - _write - ntdll ws2_32 iphlpapi advapi32 + oldnames adapter.c alloc.c api.c diff --git a/reactos/lib/3rdparty/mingw/mingw.rbuild b/reactos/lib/3rdparty/mingw/mingw.rbuild index 0e87ee7971b..a4b412edbc2 100644 --- a/reactos/lib/3rdparty/mingw/mingw.rbuild +++ b/reactos/lib/3rdparty/mingw/mingw.rbuild @@ -3,8 +3,12 @@ + + + + include/reactos/mingw-w64 - kernel32 + kernel32 _newmode.c atonexit.c charmax.c @@ -50,4 +54,8 @@ crtdll.c dllargv.c + + + + diff --git a/reactos/lib/3rdparty/mingw/moldname-msvcrt.def b/reactos/lib/3rdparty/mingw/moldname-msvcrt.def index afd7694d40a..af6661fada4 100644 --- a/reactos/lib/3rdparty/mingw/moldname-msvcrt.def +++ b/reactos/lib/3rdparty/mingw/moldname-msvcrt.def @@ -1,118 +1,121 @@ +LIBRARY msvcrt.dll + EXPORTS -access -chdir -chmod -chsize -close -creat -cwait -daylight DATA -dup -dup2 -ecvt -eof -execl -execle -execlp -execlpe -execv -execve -execvp -execvpe -fcvt -fdopen -fgetchar -fgetwchar -filelength -fileno -; fpreset -fputchar -fputwchar -;fstat -ftime -gcvt -getch -getche -getcwd -getpid -getw -heapwalk -isatty -itoa -kbhit -lfind -lsearch -lseek -ltoa -memccpy -memicmp -mkdir -mktemp -open -pclose -popen -putch -putenv -putw -read -rmdir -rmtmp -searchenv -setmode -sopen -spawnl -spawnle -spawnlp -spawnlpe -spawnv -spawnve -spawnvp -spawnvpe -;stat -strcmpi -strdup -stricmp -stricoll -strlwr -strnicmp -strnset -strrev -strset -strupr -swab -tell -tempnam -timezone DATA -tzname DATA -tzset -umask -ungetch -unlink -utime -wcsdup -wcsicmp -wcsicoll -wcslwr -wcsnicmp -wcsnset -wcsrev -wcsset -wcsupr -wpopen -write +access==_access +chdir==_chdir +chmod==_chmod +chsize==_chsize +close==_close +creat==_creat +cwait==_cwait +daylight==_daylight +dup==_dup +dup2==_dup2 +ecvt==_ecvt +eof==_eof +execl==_execl +execle==_execle +execlp==_execlp +execlpe==_execlpe +execv==_execv +execve==_execve +execvp==_execvp +execvpe==_execvpe +fcvt==_fcvt +fdopen==_fdopen +fgetchar==_fgetchar +fgetwchar==_fgetwchar +filelength==_filelength +fileno==_fileno +fpreset==_fpreset +fputchar==_fputchar +fputwchar==_fputwchar +fstat==_fstat +ftime==_ftime +gcvt==_gcvt +getch==_getch +getche==_getche +getcwd==_getcwd +getpid==_getpid +getw==_getw +heapwalk==_heapwalk +isatty==_isatty +itoa==_itoa +kbhit==_kbhit +lfind==_lfind +lsearch==_lsearch +lseek==_lseek +ltoa==_ltoa +memccpy==_memccpy +memicmp==_memicmp +mkdir==_mkdir +mktemp==_mktemp +open==_open +pclose==_pclose +popen==_popen +putch==_putch +putenv==_putenv +putw==_putw +read==_read +rmdir==_rmdir +rmtmp==_rmtmp +searchenv==_searchenv +setmode==_setmode +snprintf=_snprintf +sopen==_sopen +spawnl==_spawnl +spawnle==_spawnle +spawnlp==_spawnlp +spawnlpe==_spawnlpe +spawnv==_spawnv +spawnve==_spawnve +spawnvp==_spawnvp +spawnvpe==_spawnvpe +stat==_stat +strcmpi==_strcmpi +strdup==_strdup +stricmp==_stricmp +stricoll==_stricoll +strlwr==_strlwr +strnicmp==_strnicmp +strnset==_strnset +strrev==_strrev +strset==_strset +strupr==_strupr +swab==_swab +tell==_tell +tempnam==_tempnam +timezone==_timezone +tzname==_tzname +tzset==_tzset +umask==_umask +ungetch==_ungetch +unlink==_unlink +utime==_utime +wcsdup==_wcsdup +wcsicmp==_wcsicmp +wcsicoll==_wcsicoll +wcslwr==_wcslwr +wcsnicmp==_wcsnicmp +wcsnset==_wcsnset +wcsrev==_wcsrev +wcsset==_wcsset +wcsupr==_wcsupr +wpopen==_wpopen +write==_write ; non-ANSI functions declared in math.h -j0 -j1 -jn -y0 -y1 -yn -chgsign -;scalb -finite -fpclass +j0==_j0 +j1==_j1 +jn==_jn +y0==_y0 +y1==_y1 +yn==_yn +chgsign==_chgsign +scalb==_scalb +finite==_finite +fpclass==_fpclass ; C99 functions -cabs -hypot -logb -nextafter +cabs==_cabs +hypot==_hypot +logb==_logb +nextafter==_nextafter From b884e9009cd2d20d2a75955e51b6ed08381f0655 Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Tue, 30 Mar 2010 11:28:10 +0000 Subject: [PATCH 101/134] - Add bdasup to bootcd svn path=/trunk/; revision=46593 --- reactos/boot/bootdata/packages/reactos.dff | 1 + 1 file changed, 1 insertion(+) diff --git a/reactos/boot/bootdata/packages/reactos.dff b/reactos/boot/bootdata/packages/reactos.dff index f16a96ed4ce..5001d3fa9c6 100644 --- a/reactos/boot/bootdata/packages/reactos.dff +++ b/reactos/boot/bootdata/packages/reactos.dff @@ -505,6 +505,7 @@ drivers\input\mouclass\mouclass.sys 2 drivers\input\sermouse\sermouse.sys 2 drivers\ksfilter\ks\ks.sys 2 +drivers\multimedia\bdasup\bdasup.sys 2 drivers\network\afd\afd.sys 2 drivers\network\ndis\ndis.sys 2 From c78ad5ef4501f1aad43afe76c17d08aab68a2947 Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Tue, 30 Mar 2010 11:52:50 +0000 Subject: [PATCH 102/134] [BDAPLGIN, KSPROXY, MSDVBNP, MSVIDCTL] - Register DLLs when ReactOS is installed svn path=/trunk/; revision=46594 --- reactos/dll/directx/bdaplgin/bdaplgin.rbuild | 1 + reactos/dll/directx/ksproxy/ksproxy.rbuild | 1 + reactos/dll/directx/msdvbnp/msdvbnp.rbuild | 1 + reactos/dll/directx/msvidctl/msvidctl.rbuild | 1 + 4 files changed, 4 insertions(+) diff --git a/reactos/dll/directx/bdaplgin/bdaplgin.rbuild b/reactos/dll/directx/bdaplgin/bdaplgin.rbuild index 0824323331b..977cb0472c5 100644 --- a/reactos/dll/directx/bdaplgin/bdaplgin.rbuild +++ b/reactos/dll/directx/bdaplgin/bdaplgin.rbuild @@ -3,6 +3,7 @@ + . ntdll kernel32 diff --git a/reactos/dll/directx/ksproxy/ksproxy.rbuild b/reactos/dll/directx/ksproxy/ksproxy.rbuild index 86cd50a2c1d..4111d023482 100644 --- a/reactos/dll/directx/ksproxy/ksproxy.rbuild +++ b/reactos/dll/directx/ksproxy/ksproxy.rbuild @@ -3,6 +3,7 @@ + . ntdll kernel32 diff --git a/reactos/dll/directx/msdvbnp/msdvbnp.rbuild b/reactos/dll/directx/msdvbnp/msdvbnp.rbuild index a1cf02ac4f7..a34f4179b70 100644 --- a/reactos/dll/directx/msdvbnp/msdvbnp.rbuild +++ b/reactos/dll/directx/msdvbnp/msdvbnp.rbuild @@ -3,6 +3,7 @@ + . ntdll kernel32 diff --git a/reactos/dll/directx/msvidctl/msvidctl.rbuild b/reactos/dll/directx/msvidctl/msvidctl.rbuild index a3da3fcbe09..760d5bb61c0 100644 --- a/reactos/dll/directx/msvidctl/msvidctl.rbuild +++ b/reactos/dll/directx/msvidctl/msvidctl.rbuild @@ -3,6 +3,7 @@ + . ntdll kernel32 From 018a23596b5792665ecea98ab296136d0cc05399 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Tue, 30 Mar 2010 16:17:48 +0000 Subject: [PATCH 103/134] [KERNEL32] Add some amd64 exports svn path=/trunk/; revision=46598 --- reactos/dll/win32/kernel32/kernel32.pspec | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/reactos/dll/win32/kernel32/kernel32.pspec b/reactos/dll/win32/kernel32/kernel32.pspec index 1fb88ce3e56..05f19157a16 100644 --- a/reactos/dll/win32/kernel32/kernel32.pspec +++ b/reactos/dll/win32/kernel32/kernel32.pspec @@ -761,11 +761,19 @@ @ stdcall ResumeThread(long) @ stdcall RtlCaptureContext(ptr) ntdll.RtlCaptureContext @ stdcall RtlCaptureStackBackTrace(long long ptr ptr) ntdll.RtlCaptureStackBackTrace +@ stdcall -arch=x86_64 RtlCompareMemory(ptr ptr ptr) +@ stdcall -arch=x86_64 RtlCopyMemory(ptr ptr ptr) +@ stdcall -arch=x86_64 RtlDeleteFunctionTable(ptr) @ stdcall RtlFillMemory(ptr long long) ntdll.RtlFillMemory +@ stdcall -arch=x86_64 RtlInstallFunctionTableCallback(double double long ptr ptr ptr) +@ stdcall -arch=x86_64 RtlLookupFunctionEntry(ptr ptr ptr) ntdll.RtlLookupFunctionEntry @ stdcall RtlMoveMemory(ptr ptr long) ntdll.RtlMoveMemory +@ stdcall -arch=x86_64 RtlPcToFileHeader(ptr ptr) ntdll.RtlPcToFileHeader +@ stdcall -arch=x86_64 RtlRaiseException(ptr) ntdll.RtlRaiseException +@ stdcall -arch=x86_64 RtlRestoreContext(ptr ptr) ntdll.RtlRestoreContext @ stdcall RtlUnwind(ptr ptr ptr long) ntdll.RtlUnwind -@ stdcall RtlVirtualUnwind(ptr ptr ptr long) ntdll.RtlVirtualUnwind -@ stdcall RtlLookupFunctionEntry(ptr ptr ptr) ntdll.RtlLookupFunctionEntry +@ stdcall -arch=x86_64 RtlUnwindEx(ptr ptr ptr ptr ptr ptr) ntdll.RtlUnwindEx +@ stdcall -arch=x86_64 RtlVirtualUnwind(ptr ptr ptr long) ntdll.RtlVirtualUnwind @ stdcall RtlZeroMemory(ptr long) ntdll.RtlZeroMemory @ stdcall ScrollConsoleScreenBufferA(long ptr ptr ptr ptr) @ stdcall ScrollConsoleScreenBufferW(long ptr ptr ptr ptr) From 5ee8d1be0d12b5f0a11bd218909a1fedd1ba47dd Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Tue, 30 Mar 2010 16:25:51 +0000 Subject: [PATCH 104/134] merge from amd64 branch: 38333 [INTRIN_X86] #define _alloca() to __builtin_alloca() on amd64 46388 [INTRIN_X86] - Add __stosq, __movsq, _bittest64 svn path=/trunk/; revision=46599 --- reactos/include/crt/mingw32/intrin_x86.h | 42 ++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/reactos/include/crt/mingw32/intrin_x86.h b/reactos/include/crt/mingw32/intrin_x86.h index 84c1e663996..9e83ed81838 100644 --- a/reactos/include/crt/mingw32/intrin_x86.h +++ b/reactos/include/crt/mingw32/intrin_x86.h @@ -74,6 +74,10 @@ extern "C" { #define _AddressOfReturnAddress() (&(((void **)(__builtin_frame_address(0)))[1])) /* TODO: __getcallerseflags but how??? */ +/* Maybe the same for x86? */ +#ifdef _x86_64 +#define _alloca(s) __builtin_alloca(s) +#endif /*** Atomic operations ***/ @@ -565,6 +569,18 @@ __INTRIN_INLINE void __stosd(unsigned long * Dest, const unsigned long Data, siz ); } +#ifdef _M_AMD64 +__INTRIN_INLINE void __stosq(unsigned __int64 * Dest, const unsigned __int64 Data, size_t Count) +{ + __asm__ __volatile__ + ( + "rep; stosq" : + [Dest] "=D" (Dest), [Count] "=c" (Count) : + "[Dest]" (Dest), "a" (Data), "[Count]" (Count) + ); +} +#endif + __INTRIN_INLINE void __movsb(unsigned char * Destination, const unsigned char * Source, size_t Count) { __asm__ __volatile__ @@ -595,6 +611,18 @@ __INTRIN_INLINE void __movsd(unsigned long * Destination, const unsigned long * ); } +#ifdef _M_AMD64 +__INTRIN_INLINE void __movsq(unsigned long * Destination, const unsigned long * Source, size_t Count) +{ + __asm__ __volatile__ + ( + "rep; movsq" : + [Destination] "=D" (Destination), [Source] "=S" (Source), [Count] "=c" (Count) : + "[Destination]" (Destination), "[Source]" (Source), "[Count]" (Count) + ); +} +#endif + #if defined(_M_AMD64) /*** GS segment addressing ***/ @@ -787,6 +815,20 @@ __INTRIN_INLINE unsigned char _bittest(const long * const a, const long b) return retval; } +#ifdef _M_AMD64 +__INTRIN_INLINE unsigned char _bittest64(const __int64 * const a, const __int64 b) +{ + unsigned char retval; + + if(__builtin_constant_p(b)) + __asm__("bt %[b], %[a]; setb %b[retval]" : [retval] "=q" (retval) : [a] "mr" (*(a + (b / 64))), [b] "Ir" (b % 64)); + else + __asm__("bt %[b], %[a]; setb %b[retval]" : [retval] "=q" (retval) : [a] "mr" (*a), [b] "r" (b)); + + return retval; +} +#endif + __INTRIN_INLINE unsigned char _bittestandcomplement(long * const a, const long b) { unsigned char retval; From 9dfa15a2cdd70e40ea085233a372b72f0e730d6e Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Tue, 30 Mar 2010 16:34:17 +0000 Subject: [PATCH 105/134] [NTOSKRNL] - Disable ACPI until the resource detection problems are resolved svn path=/trunk/; revision=46600 --- reactos/ntoskrnl/io/pnpmgr/pnpmgr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c b/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c index ff43f2397f8..502787fc41f 100644 --- a/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c +++ b/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c @@ -13,7 +13,7 @@ #define NDEBUG #include -#define ENABLE_ACPI +//#define ENABLE_ACPI /* GLOBALS *******************************************************************/ From 4c530b8f2a2ee0445f6af32633bb66bf2570eeae Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Tue, 30 Mar 2010 16:59:52 +0000 Subject: [PATCH 106/134] [NTOS] Update pspec file with amd64 exports, use -arch= where appropriate svn path=/trunk/; revision=46601 --- reactos/ntoskrnl/ntoskrnl.pspec | 134 ++++++++++++++++++++------------ 1 file changed, 84 insertions(+), 50 deletions(-) diff --git a/reactos/ntoskrnl/ntoskrnl.pspec b/reactos/ntoskrnl/ntoskrnl.pspec index 68e79a20741..5016dbd2b87 100644 --- a/reactos/ntoskrnl/ntoskrnl.pspec +++ b/reactos/ntoskrnl/ntoskrnl.pspec @@ -1,4 +1,5 @@ #include +#undef i386 @ stdcall CcCanIWrite(ptr long long long) @ stdcall CcCopyRead(ptr ptr long long ptr ptr) @@ -55,6 +56,7 @@ @ stdcall DbgPrompt(str ptr long) @ stdcall DbgQueryDebugFilterState(long long) @ stdcall DbgSetDebugFilterState(long long long) +@ stdcall -arch=x86_64 ExAcquireFastMutex(ptr) @ fastcall ExAcquireFastMutexUnsafe(ptr) @ stdcall ExAcquireResourceExclusiveLite(ptr long) @ stdcall ExAcquireResourceSharedLite(ptr long) @@ -101,26 +103,37 @@ @ stdcall ExInitializeRundownProtectionCacheAware(ptr long) @ stdcall ExInitializeZone(ptr long ptr long) @ stdcall ExInterlockedAddLargeInteger(ptr long long ptr) +#ifndef __x86_64__ @ fastcall ExInterlockedAddLargeStatistic(ptr long) +#endif @ stdcall ExInterlockedAddUlong(ptr long ptr) +#ifndef __x86_64__ @ fastcall ExInterlockedCompareExchange64(ptr ptr ptr ptr) @ stdcall ExInterlockedDecrementLong(ptr ptr) @ stdcall ExInterlockedExchangeUlong(ptr long ptr) +#endif @ stdcall ExInterlockedExtendZone(ptr ptr long ptr) +#ifndef __x86_64__ @ fastcall ExInterlockedFlushSList(ptr) @ stdcall ExInterlockedIncrementLong(ptr ptr) +#endif @ stdcall ExInterlockedInsertHeadList(ptr ptr ptr) @ stdcall ExInterlockedInsertTailList(ptr ptr ptr) @ stdcall ExInterlockedPopEntryList(ptr ptr) +#ifndef __x86_64__ @ fastcall ExInterlockedPopEntrySList(ptr ptr) +#endif @ stdcall ExInterlockedPushEntryList(ptr ptr ptr) +#ifndef __x86_64__ @ fastcall ExInterlockedPushEntrySList(ptr ptr ptr) +#endif @ stdcall ExInterlockedRemoveHeadList(ptr ptr) @ stdcall ExIsProcessorFeaturePresent(long) @ stdcall ExIsResourceAcquiredExclusiveLite(ptr) @ stdcall ExIsResourceAcquiredSharedLite(ptr) @ stdcall ExLocalTimeToSystemTime(ptr ptr) @ stdcall ExNotifyCallback(ptr ptr ptr) +@ stdcall -arch=x86_64 ExQueryDepthSList(ptr) @ stdcall ExQueryPoolBlockSize(ptr ptr) @ stdcall ExQueueWorkItem(ptr long) @ stdcall ExRaiseAccessViolation() @@ -132,6 +145,7 @@ @ fastcall ExReInitializeRundownProtectionCacheAware(ptr) ExfReInitializeRundownProtectionCacheAware @ stdcall ExRegisterCallback(ptr ptr ptr) @ stdcall ExReinitializeResourceLite(ptr) +@ stdcall -arch=x86_64 ExReleaseFastMutex(ptr) @ fastcall ExReleaseFastMutexUnsafe(ptr) @ fastcall ExReleaseFastMutexUnsafeAndLeaveCriticalRegion(ptr) @ fastcall ExReleaseResourceAndLeaveCriticalRegion(ptr) @@ -149,6 +163,7 @@ @ stdcall ExSizeOfRundownProtectionCacheAware() @ stdcall ExSystemExceptionFilter() @ stdcall ExSystemTimeToLocalTime(ptr ptr) +@ stdcall -arch=x86_64 ExTryToAcquireFastMutex(ptr) @ stdcall ExUnregisterCallback(ptr) @ stdcall ExUuidCreate(ptr) @ stdcall ExVerifySuite(long) @@ -157,6 +172,7 @@ @ extern ExWindowStationObjectType @ fastcall ExfAcquirePushLockExclusive(ptr) @ fastcall ExfAcquirePushLockShared(ptr) +#ifndef __x86_64__ @ fastcall ExfInterlockedAddUlong(ptr long ptr) @ fastcall ExfInterlockedCompareExchange64(ptr ptr ptr) @ fastcall ExfInterlockedInsertHeadList(ptr ptr ptr) @@ -164,22 +180,24 @@ @ fastcall ExfInterlockedPopEntryList(ptr ptr) @ fastcall ExfInterlockedPushEntryList(ptr ptr ptr) @ fastcall ExfInterlockedRemoveHeadList(ptr ptr) +#endif @ fastcall ExfReleasePushLock(ptr) @ fastcall ExfReleasePushLockExclusive(ptr) @ fastcall ExfReleasePushLockShared(ptr) @ fastcall ExfTryToWakePushLock(ptr) @ fastcall ExfUnblockPushLock(ptr ptr) -#ifdef _M_IX86 -@ fastcall Exfi386InterlockedDecrementLong(ptr) -@ fastcall Exfi386InterlockedExchangeUlong(ptr long) -@ fastcall Exfi386InterlockedIncrementLong(ptr) -@ stdcall Exi386InterlockedDecrementLong(ptr) -@ stdcall Exi386InterlockedExchangeUlong(ptr long long) -@ stdcall Exi386InterlockedIncrementLong(ptr) -#endif -@ fastcall ExiAcquireFastMutex(ptr) ExAcquireFastMutex -@ fastcall ExiReleaseFastMutex(ptr) ExReleaseFastMutex -@ fastcall ExiTryToAcquireFastMutex(ptr) ExTryToAcquireFastMutex +@ stdcall -arch=x86_64 ExpInterlockedFlushSList(ptr) +@ stdcall -arch=x86_64 ExpInterlockedPopEntrySList(ptr ptr) +@ stdcall -arch=x86_64 ExpInterlockedPushEntrySList(ptr ptr) +@ fastcall -arch=i386 Exfi386InterlockedDecrementLong(ptr) +@ fastcall -arch=i386 Exfi386InterlockedExchangeUlong(ptr long) +@ fastcall -arch=i386 Exfi386InterlockedIncrementLong(ptr) +@ stdcall -arch=i386 Exi386InterlockedDecrementLong(ptr) +@ stdcall -arch=i386 Exi386InterlockedExchangeUlong(ptr long long) +@ stdcall -arch=i386 Exi386InterlockedIncrementLong(ptr) +@ fastcall -arch=i386 ExiAcquireFastMutex(ptr) ExAcquireFastMutex +@ fastcall -arch=i386 ExiReleaseFastMutex(ptr) ExReleaseFastMutex +@ fastcall -arch=i386 ExiTryToAcquireFastMutex(ptr) ExTryToAcquireFastMutex @ stdcall FsRtlAcquireFileExclusive(ptr) ;FsRtlAddBaseMcbEntry @ stdcall FsRtlAddLargeMcbEntry(ptr long long long long long long) @@ -316,6 +334,7 @@ @ stdcall InbvSetTextColor(long) @ stdcall InbvSolidColorFill(long long long long long) @ extern InitSafeBootMode +#ifndef __x86_64__ @ fastcall InterlockedCompareExchange(ptr long long) @ fastcall InterlockedDecrement(ptr) @ fastcall InterlockedExchange(ptr long) @@ -323,6 +342,9 @@ @ fastcall InterlockedIncrement(ptr) @ fastcall InterlockedPopEntrySList(ptr) @ fastcall InterlockedPushEntrySList(ptr ptr) +#else +@ stdcall InitializeSListHead(ptr) RtlInitializeSListHead +#endif @ stdcall IoAcquireCancelSpinLock(ptr) @ stdcall IoAcquireRemoveLockEx(ptr ptr str long long) @ stdcall IoAcquireVpbSpinLock(ptr) @@ -536,12 +558,10 @@ @ stdcall KdPowerTransition(long) @ stdcall KdRefreshDebuggerNotPresent() @ stdcall KdSystemDebugControl(long ptr long ptr long ptr long) -#ifdef _M_IX86 -@ stdcall Ke386CallBios(long ptr) -@ stdcall Ke386IoSetAccessProcess(ptr long) -@ stdcall Ke386QueryIoAccessMap(long ptr) -@ stdcall Ke386SetIoAccessMap(long ptr) -#endif +@ stdcall -arch=i386 Ke386CallBios(long ptr) +@ stdcall -arch=i386 Ke386IoSetAccessProcess(ptr long) +@ stdcall -arch=i386 Ke386QueryIoAccessMap(long ptr) +@ stdcall -arch=i386 Ke386SetIoAccessMap(long ptr) @ fastcall KeAcquireGuardedMutex(ptr) @ fastcall KeAcquireGuardedMutexUnsafe(ptr) @ fastcall KeAcquireInStackQueuedSpinLockAtDpcLevel(ptr ptr) @@ -549,6 +569,7 @@ @ stdcall KeAcquireInterruptSpinLock(ptr) @ stdcall KeAcquireSpinLockAtDpcLevel(ptr) @ fastcall KeAcquireSpinLockForDpc(ptr) +@ stdcall -arch=x86_64 KeAcquireSpinLockRaiseToDpc(ptr) @ stdcall KeAddSystemServiceTable(ptr ptr long ptr long) @ stdcall KeAreAllApcsDisabled() @ stdcall KeAreApcsDisabled() @@ -576,18 +597,16 @@ @ stdcall KeGetCurrentThread() @ stdcall KeGetPreviousMode() @ stdcall KeGetRecommendedSharedDataAlignment() -#ifdef _M_IX86 ;KeI386AbiosCall -@ stdcall KeI386AllocateGdtSelectors(ptr long) -;KeI386Call16BitCStyleFunction -;KeI386Call16BitFunction -@ stdcall KeI386FlatToGdtSelector(long long long) -;KeI386GetLid -@ extern KeI386MachineType -@ stdcall KeI386ReleaseGdtSelectors(ptr long) -;KeI386ReleaseLid -;KeI386SetGdtSelector -#endif +@ stdcall -arch=i386 KeI386AllocateGdtSelectors(ptr long) +; -arch=i386 KeI386Call16BitCStyleFunction +; -arch=i386 KeI386Call16BitFunction +@ stdcall -arch=i386 KeI386FlatToGdtSelector(long long long) +; -arch=i386 KeI386GetLid +@ extern -arch=i386 KeI386MachineType +@ stdcall -arch=i386 KeI386ReleaseGdtSelectors(ptr long) +; -arch=i386 KeI386ReleaseLid +; -arch=i386 KeI386SetGdtSelector @ stdcall KeInitializeApc(ptr ptr long ptr ptr ptr long ptr) @ stdcall KeInitializeCrashDumpHeader(long long ptr long ptr) @ stdcall KeInitializeDeviceQueue(ptr) @@ -599,7 +618,9 @@ @ stdcall KeInitializeMutex(ptr long) @ stdcall KeInitializeQueue(ptr long) @ stdcall KeInitializeSemaphore(ptr long long) +#ifndef __x86_64__ @ stdcall KeInitializeSpinLock(ptr) _KeInitializeSpinLock +#endif @ stdcall KeInitializeThreadedDpc(ptr ptr ptr) @ stdcall KeInitializeTimer(ptr) @ stdcall KeInitializeTimerEx(ptr long) @@ -622,10 +643,14 @@ @ stdcall KeProfileInterruptWithSource(ptr long) @ stdcall KePulseEvent(ptr long long) @ stdcall KeQueryActiveProcessors() +#ifndef __x86_64__ @ stdcall KeQueryInterruptTime() +#endif @ stdcall KeQueryPriorityThread(ptr) @ stdcall KeQueryRuntimeThread(ptr ptr) +#ifndef __x86_64__ @ stdcall KeQuerySystemTime(ptr) +#endif @ stdcall KeQueryTickCount(ptr) @ stdcall KeQueryTimeIncrement() @ stdcall KeRaiseUserException(long) @@ -646,6 +671,9 @@ @ stdcall KeReleaseMutant(ptr long long long) @ stdcall KeReleaseMutex(ptr long) @ stdcall KeReleaseSemaphore(ptr long long long) +#ifdef __x86_64__ +@ stdcall KeReleaseSpinLock(ptr long) +#endif @ fastcall KeReleaseSpinLockForDpc(ptr long) @ stdcall KeReleaseSpinLockFromDpcLevel(ptr) @ stdcall KeRemoveByKeyDeviceQueue(ptr long) @@ -695,21 +723,15 @@ @ stdcall KeWaitForSingleObject(ptr long long long ptr) @ fastcall KefAcquireSpinLockAtDpcLevel(ptr) @ fastcall KefReleaseSpinLockFromDpcLevel(ptr) -#ifdef _M_IX86 -@ stdcall Kei386EoiHelper() -@ fastcall KiEoiHelper(ptr) /* FIXME: Evaluate decision */ -#endif +@ stdcall -arch=i386 Kei386EoiHelper() +@ fastcall -arch=i386 KiEoiHelper(ptr) /* FIXME: Evaluate decision */ @ fastcall KiAcquireSpinLock(ptr) @ extern KiBugCheckData @ stdcall KiCheckForKernelApcDelivery() ;KiCheckForSListAddress -#ifdef _M_IX86 -@ stdcall KiCoprocessorError() -#endif +@ stdcall -arch=i386 KiCoprocessorError() @ stdcall KiDeliverApc(long ptr ptr) -#ifdef _M_IX86 -@ stdcall KiDispatchInterrupt() -#endif +@ stdcall -arch=i386 KiDispatchInterrupt() @ extern KiEnableTimerWatchdog @ stdcall KiIpiServiceRoutine(ptr ptr) @ fastcall KiReleaseSpinLock(ptr) @@ -1021,12 +1043,14 @@ @ stdcall PsTerminateSystemThread(long) @ extern PsThreadType _PsThreadType ;PsWrapApcWow64Thread +#ifndef __x86_64__ @ stdcall READ_REGISTER_BUFFER_UCHAR(ptr ptr long) @ stdcall READ_REGISTER_BUFFER_ULONG(ptr ptr long) @ stdcall READ_REGISTER_BUFFER_USHORT(ptr ptr long) @ stdcall READ_REGISTER_UCHAR(ptr) @ stdcall READ_REGISTER_ULONG(ptr) @ stdcall READ_REGISTER_USHORT(ptr) +#endif @ stdcall RtlAbsoluteToSelfRelativeSD(ptr ptr ptr) @ stdcall RtlAddAccessAllowedAce(ptr long long ptr) @ stdcall RtlAddAccessAllowedAceEx(ptr long long long ptr) @@ -1273,8 +1297,10 @@ ;RtlTraceDatabaseLock ;RtlTraceDatabaseUnlock ;RtlTraceDatabaseValidate +#ifndef __x86_64__ @ fastcall RtlUlongByteSwap(long) @ fastcall RtlUlonglongByteSwap(long long) +#endif @ stdcall RtlUnicodeStringToAnsiSize(ptr) RtlxUnicodeStringToAnsiSize @ stdcall RtlUnicodeStringToAnsiString(ptr ptr long) @ stdcall RtlUnicodeStringToCountedOemString(ptr ptr long) @@ -1297,7 +1323,9 @@ @ stdcall RtlUpcaseUnicodeToOemN(ptr long ptr wstr long) @ stdcall RtlUpperChar(long) @ stdcall RtlUpperString(ptr ptr) +#ifndef __x86_64__ @ fastcall RtlUshortByteSwap(long) +#endif @ stdcall RtlValidRelativeSecurityDescriptor(ptr long long) @ stdcall RtlValidSecurityDescriptor(ptr) @ stdcall RtlValidSid(ptr) @@ -1368,12 +1396,14 @@ ;VfFailDriver ;VfFailSystemBIOS ;VfIsVerificationEnabled +#ifndef __x86_64__ @ stdcall WRITE_REGISTER_BUFFER_UCHAR(ptr ptr long) @ stdcall WRITE_REGISTER_BUFFER_ULONG(ptr ptr long) @ stdcall WRITE_REGISTER_BUFFER_USHORT(ptr ptr long) @ stdcall WRITE_REGISTER_UCHAR(ptr long) @ stdcall WRITE_REGISTER_ULONG(ptr long) @ stdcall WRITE_REGISTER_USHORT(ptr long) +#endif ;WmiFlushTrace ;WmiGetClock ;WmiQueryTrace @@ -1512,26 +1542,30 @@ ;_CIcos ;_CIsin ;_CIsqrt +#ifndef __x86_64 @ cdecl _abnormal_termination() -#ifdef _M_IX86 -@ cdecl _alldiv() -@ cdecl _alldvrm() -@ cdecl _allmul() -@ cdecl _alloca_probe() -@ cdecl _allrem() -@ cdecl _allshl() -@ cdecl _allshr() -@ cdecl _aulldiv() -@ cdecl _aulldvrm() -@ cdecl _aullrem() -@ cdecl _aullshr() #endif +@ cdecl -arch=i386 _alldiv() +@ cdecl -arch=i386 _alldvrm() +@ cdecl -arch=i386 _allmul() +@ cdecl -arch=i386 _alloca_probe() +@ cdecl -arch=i386 _allrem() +@ cdecl -arch=i386 _allshl() +@ cdecl -arch=i386 _allshr() +@ cdecl -arch=i386 _aulldiv() +@ cdecl -arch=i386 _aulldvrm() +@ cdecl -arch=i386 _aullrem() +@ cdecl -arch=i386 _aullshr() +#ifndef __x86_64 @ cdecl _except_handler2() @ cdecl _except_handler3() @ cdecl _global_unwind2() +#endif @ cdecl _itoa() @ cdecl _itow() +#ifndef __x86_64 @ cdecl _local_unwind2() +#endif @ cdecl _purecall() @ cdecl _snprintf() @ cdecl _snwprintf() From e3949430d784b12b0b3a76d11b188246dd637193 Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Tue, 30 Mar 2010 17:01:23 +0000 Subject: [PATCH 107/134] [NTOSKRNL] - Move kernel-mode check around, so we won't run it twice when calling NtAccessCheck. - Fix a wrong check for security descriptors with a NULL-DACL. svn path=/trunk/; revision=46602 --- reactos/ntoskrnl/se/semgr.c | 48 +++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/reactos/ntoskrnl/se/semgr.c b/reactos/ntoskrnl/se/semgr.c index 4d5739efcc8..afb4348f2cc 100644 --- a/reactos/ntoskrnl/se/semgr.c +++ b/reactos/ntoskrnl/se/semgr.c @@ -377,28 +377,6 @@ SepAccessCheck(IN PSECURITY_DESCRIPTOR SecurityDescriptor, NTSTATUS Status; PAGED_CODE(); - /* Check if this is kernel mode */ - if (AccessMode == KernelMode) - { - /* Check if kernel wants everything */ - if (DesiredAccess & MAXIMUM_ALLOWED) - { - /* Give it */ - *GrantedAccess = GenericMapping->GenericAll; - *GrantedAccess |= (DesiredAccess &~ MAXIMUM_ALLOWED); - *GrantedAccess |= PreviouslyGrantedAccess; - } - else - { - /* Give the desired and previous access */ - *GrantedAccess = DesiredAccess | PreviouslyGrantedAccess; - } - - /* Success */ - *AccessStatus = STATUS_SUCCESS; - return TRUE; - } - /* Check if we didn't get an SD */ if (!SecurityDescriptor) { @@ -467,7 +445,7 @@ SepAccessCheck(IN PSECURITY_DESCRIPTOR SecurityDescriptor, } /* RULE 1: Grant desired access if the object is unprotected */ - if (Present == TRUE && Dacl == NULL) + if (Present == FALSE || Dacl == NULL) { if (SubjectContextLocked == FALSE) { @@ -678,6 +656,30 @@ SeAccessCheck(IN PSECURITY_DESCRIPTOR SecurityDescriptor, OUT PACCESS_MASK GrantedAccess, OUT PNTSTATUS AccessStatus) { + PAGED_CODE(); + + /* Check if this is kernel mode */ + if (AccessMode == KernelMode) + { + /* Check if kernel wants everything */ + if (DesiredAccess & MAXIMUM_ALLOWED) + { + /* Give it */ + *GrantedAccess = GenericMapping->GenericAll; + *GrantedAccess |= (DesiredAccess &~ MAXIMUM_ALLOWED); + *GrantedAccess |= PreviouslyGrantedAccess; + } + else + { + /* Give the desired and previous access */ + *GrantedAccess = DesiredAccess | PreviouslyGrantedAccess; + } + + /* Success */ + *AccessStatus = STATUS_SUCCESS; + return TRUE; + } + /* Call the internal function */ return SepAccessCheck(SecurityDescriptor, SubjectSecurityContext, From ebf3dfc568d29d5c625dcb78245f403963fd84c9 Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Tue, 30 Mar 2010 19:43:09 +0000 Subject: [PATCH 108/134] [SETUPAPI] - Open Device Class with desired access svn path=/trunk/; revision=46603 --- reactos/dll/win32/setupapi/devinst.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/dll/win32/setupapi/devinst.c b/reactos/dll/win32/setupapi/devinst.c index e589016e903..5e11cd04c18 100644 --- a/reactos/dll/win32/setupapi/devinst.c +++ b/reactos/dll/win32/setupapi/devinst.c @@ -3662,7 +3662,7 @@ HKEY WINAPI SetupDiOpenClassRegKeyExW( if (!(l = RegOpenKeyExW(HKLM, lpKeyName, 0, - 0, + samDesired, &hClassesKey))) { if (MachineName != NULL) From ffd48df71381148574535ea8b5ede526a776c87e Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Tue, 30 Mar 2010 19:59:29 +0000 Subject: [PATCH 109/134] [WINE] define interlocked_xchg_add to InterlockedExchangeAdd svn path=/trunk/; revision=46604 --- reactos/lib/3rdparty/libwine/debug_ros.c | 1 + 1 file changed, 1 insertion(+) diff --git a/reactos/lib/3rdparty/libwine/debug_ros.c b/reactos/lib/3rdparty/libwine/debug_ros.c index fd1e6775257..66904ba33e2 100644 --- a/reactos/lib/3rdparty/libwine/debug_ros.c +++ b/reactos/lib/3rdparty/libwine/debug_ros.c @@ -5,6 +5,7 @@ #define free libwine_free #define realloc libwine_realloc #define _strdup libwine__strdup +#define interlocked_xchg_add InterlockedExchangeAdd #include "debug.c" From d69c4c52489fd09869fc8bf9dee3bb03c0525cba Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Tue, 30 Mar 2010 20:16:26 +0000 Subject: [PATCH 110/134] [NTOSKRNL] - Capture the security descriptor before passing it to SepAccessCheck. - Move the security descriptor check and the impersonation level check from SepAccessCheck to SeAccessCheck. svn path=/trunk/; revision=46605 --- reactos/ntoskrnl/se/semgr.c | 73 +++++++++++++++++++++++++------------ 1 file changed, 50 insertions(+), 23 deletions(-) diff --git a/reactos/ntoskrnl/se/semgr.c b/reactos/ntoskrnl/se/semgr.c index afb4348f2cc..c5ae5083a6d 100644 --- a/reactos/ntoskrnl/se/semgr.c +++ b/reactos/ntoskrnl/se/semgr.c @@ -362,8 +362,7 @@ SepAccessCheck(IN PSECURITY_DESCRIPTOR SecurityDescriptor, IN PGENERIC_MAPPING GenericMapping, IN KPROCESSOR_MODE AccessMode, OUT PACCESS_MASK GrantedAccess, - OUT PNTSTATUS AccessStatus, - SECURITY_IMPERSONATION_LEVEL LowestImpersonationLevel) + OUT PNTSTATUS AccessStatus) { LUID_AND_ATTRIBUTES Privilege; ACCESS_MASK CurrentAccess, AccessMask; @@ -377,22 +376,6 @@ SepAccessCheck(IN PSECURITY_DESCRIPTOR SecurityDescriptor, NTSTATUS Status; PAGED_CODE(); - /* Check if we didn't get an SD */ - if (!SecurityDescriptor) - { - /* Automatic failure */ - *AccessStatus = STATUS_ACCESS_DENIED; - return FALSE; - } - - /* Check for invalid impersonation */ - if ((SubjectSecurityContext->ClientToken) && - (SubjectSecurityContext->ImpersonationLevel < LowestImpersonationLevel)) - { - *AccessStatus = STATUS_BAD_IMPERSONATION_LEVEL; - return FALSE; - } - /* Check for no access desired */ if (!DesiredAccess) { @@ -680,6 +663,22 @@ SeAccessCheck(IN PSECURITY_DESCRIPTOR SecurityDescriptor, return TRUE; } + /* Check if we didn't get an SD */ + if (!SecurityDescriptor) + { + /* Automatic failure */ + *AccessStatus = STATUS_ACCESS_DENIED; + return FALSE; + } + + /* Check for invalid impersonation */ + if ((SubjectSecurityContext->ClientToken) && + (SubjectSecurityContext->ImpersonationLevel < SecurityImpersonation)) + { + *AccessStatus = STATUS_BAD_IMPERSONATION_LEVEL; + return FALSE; + } + /* Call the internal function */ return SepAccessCheck(SecurityDescriptor, SubjectSecurityContext, @@ -690,8 +689,7 @@ SeAccessCheck(IN PSECURITY_DESCRIPTOR SecurityDescriptor, GenericMapping, AccessMode, GrantedAccess, - AccessStatus, - SecurityImpersonation); + AccessStatus); } /* SYSTEM CALLS ***************************************************************/ @@ -710,6 +708,7 @@ NtAccessCheck(IN PSECURITY_DESCRIPTOR SecurityDescriptor, OUT PACCESS_MASK GrantedAccess, OUT PNTSTATUS AccessStatus) { + PSECURITY_DESCRIPTOR CapturedSecurityDescriptor = NULL; SECURITY_SUBJECT_CONTEXT SubjectSecurityContext; KPROCESSOR_MODE PreviousMode = ExGetPreviousMode(); PTOKEN Token; @@ -787,11 +786,35 @@ NtAccessCheck(IN PSECURITY_DESCRIPTOR SecurityDescriptor, return STATUS_BAD_IMPERSONATION_LEVEL; } + /* Capture the security descriptor */ + Status = SeCaptureSecurityDescriptor(SecurityDescriptor, + PreviousMode, + PagedPool, + FALSE, + &CapturedSecurityDescriptor); + if (!NT_SUCCESS(Status)) + { + DPRINT("Failed to capture the Security Descriptor\n"); + ObDereferenceObject(Token); + return Status; + } + + /* Check the captured security descriptor */ + if (CapturedSecurityDescriptor == NULL) + { + DPRINT("Security Descriptor is NULL\n"); + ObDereferenceObject(Token); + return STATUS_INVALID_SECURITY_DESCR; + } + /* Check security descriptor for valid owner and group */ if (SepGetSDOwner(SecurityDescriptor)== NULL || SepGetSDGroup(SecurityDescriptor) == NULL) { DPRINT("Security Descriptor does not have a valid group or owner\n"); + SeReleaseSecurityDescriptor(CapturedSecurityDescriptor, + PreviousMode, + FALSE); ObDereferenceObject(Token); return STATUS_INVALID_SECURITY_DESCR; } @@ -804,7 +827,7 @@ NtAccessCheck(IN PSECURITY_DESCRIPTOR SecurityDescriptor, SeLockSubjectContext(&SubjectSecurityContext); /* Now perform the access check */ - SepAccessCheck(SecurityDescriptor, + SepAccessCheck(CapturedSecurityDescriptor, &SubjectSecurityContext, TRUE, DesiredAccess, @@ -813,12 +836,16 @@ NtAccessCheck(IN PSECURITY_DESCRIPTOR SecurityDescriptor, GenericMapping, PreviousMode, GrantedAccess, - AccessStatus, - SecurityIdentification); + AccessStatus); /* Unlock subject context */ SeUnlockSubjectContext(&SubjectSecurityContext); + /* Release the captured security descriptor */ + SeReleaseSecurityDescriptor(CapturedSecurityDescriptor, + PreviousMode, + FALSE); + /* Dereference the token */ ObDereferenceObject(Token); From 26109e48dede88d6d2c02bd47d90b43abcc0a1af Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Tue, 30 Mar 2010 21:28:38 +0000 Subject: [PATCH 111/134] [MINGW] - add back getopt.c (needed by rosapps) - add ofmt_stub.c and cx_pure_virtual.c svn path=/trunk/; revision=46606 --- reactos/lib/3rdparty/mingw/cxa_pure_virtual.c | 7 + reactos/lib/3rdparty/mingw/getopt.c | 394 ++++++++++++++++++ reactos/lib/3rdparty/mingw/mingw.rbuild | 3 + reactos/lib/3rdparty/mingw/ofmt_stub.c | 6 + 4 files changed, 410 insertions(+) create mode 100644 reactos/lib/3rdparty/mingw/cxa_pure_virtual.c create mode 100644 reactos/lib/3rdparty/mingw/getopt.c create mode 100644 reactos/lib/3rdparty/mingw/ofmt_stub.c diff --git a/reactos/lib/3rdparty/mingw/cxa_pure_virtual.c b/reactos/lib/3rdparty/mingw/cxa_pure_virtual.c new file mode 100644 index 00000000000..308443b8d2a --- /dev/null +++ b/reactos/lib/3rdparty/mingw/cxa_pure_virtual.c @@ -0,0 +1,7 @@ + +void assert(int); + +void __cxa_pure_virtual() +{ + _assert(0); +} diff --git a/reactos/lib/3rdparty/mingw/getopt.c b/reactos/lib/3rdparty/mingw/getopt.c new file mode 100644 index 00000000000..cd759b2ff6a --- /dev/null +++ b/reactos/lib/3rdparty/mingw/getopt.c @@ -0,0 +1,394 @@ +#include +#include +#include +#include +#include +#include +#include + +#define REPLACE_GETOPT + +#define _DIAGASSERT(x) do {} while (0) + +#ifdef REPLACE_GETOPT +#ifdef __weak_alias +__weak_alias(getopt,_getopt) +#endif +int opterr = 1; +int optind = 1; +int optopt = '?'; +int optreset; +char *optarg; +#endif + +#ifdef __weak_alias +__weak_alias(getopt_long,_getopt_long) +#endif + +#ifndef __CYGWIN__ +#define __progname __argv[0] +#else +extern char __declspec(dllimport) *__progname; +#endif + +#define IGNORE_FIRST (*options == '-' || *options == '+') +#define PRINT_ERROR ((opterr) && ((*options != ':') || (IGNORE_FIRST && options[1] != ':'))) + +#ifndef IS_POSIXLY_CORRECT +#define IS_POSIXLY_CORRECT (getenv("POSIXLY_CORRECT") != NULL) +#endif + +#define PERMUTE (!IS_POSIXLY_CORRECT && !IGNORE_FIRST) + +#define IN_ORDER (!IS_POSIXLY_CORRECT && *options == '-') + +#define BADCH (int)'?' +#define BADARG ((IGNORE_FIRST && options[1] == ':') || (*options == ':') ? (int)':' : (int)'?') +#define INORDER (int)1 + +static char EMSG[1]; + +static int getopt_internal (int,char * const *,const char *); +static int gcd (int,int); +static void permute_args (int,int,int,char * const *); + +static char *place = EMSG; + +static int nonopt_start = -1; +static int nonopt_end = -1; + +static const char recargchar[] = "option requires an argument -- %c"; +static const char recargstring[] = "option requires an argument -- %s"; +static const char ambig[] = "ambiguous option -- %.*s"; +static const char noarg[] = "option doesn't take an argument -- %.*s"; +static const char illoptchar[] = "unknown option -- %c"; +static const char illoptstring[] = "unknown option -- %s"; + +static void +_vwarnx(const char *fmt,va_list ap) +{ + (void)fprintf(stderr,"%s: ",__progname); + if (fmt != NULL) + (void)vfprintf(stderr,fmt,ap); + (void)fprintf(stderr,"\n"); +} + +static void +warnx(const char *fmt,...) +{ + va_list ap; + va_start(ap,fmt); + _vwarnx(fmt,ap); + va_end(ap); +} + +static int +gcd(a,b) + int a; + int b; +{ + int c; + + c = a % b; + while (c != 0) { + a = b; + b = c; + c = a % b; + } + + return b; +} + +static void +permute_args(panonopt_start,panonopt_end,opt_end,nargv) + int panonopt_start; + int panonopt_end; + int opt_end; + char * const *nargv; +{ + int cstart,cyclelen,i,j,ncycle,nnonopts,nopts,pos; + char *swap; + + _DIAGASSERT(nargv != NULL); + + nnonopts = panonopt_end - panonopt_start; + nopts = opt_end - panonopt_end; + ncycle = gcd(nnonopts,nopts); + cyclelen = (opt_end - panonopt_start) / ncycle; + + for (i = 0; i < ncycle; i++) { + cstart = panonopt_end+i; + pos = cstart; + for (j = 0; j < cyclelen; j++) { + if (pos >= panonopt_end) + pos -= nnonopts; + else + pos += nopts; + swap = nargv[pos]; + + ((char **) nargv)[pos] = nargv[cstart]; + + ((char **)nargv)[cstart] = swap; + } + } +} + +static int +getopt_internal(nargc,nargv,options) + int nargc; + char * const *nargv; + const char *options; +{ + char *oli; + int optchar; + + _DIAGASSERT(nargv != NULL); + _DIAGASSERT(options != NULL); + + optarg = NULL; + + if (optind == 0) + optind = 1; + + if (optreset) + nonopt_start = nonopt_end = -1; +start: + if (optreset || !*place) { + optreset = 0; + if (optind >= nargc) { + place = EMSG; + if (nonopt_end != -1) { + + permute_args(nonopt_start,nonopt_end,optind,nargv); + optind -= nonopt_end - nonopt_start; + } + else if (nonopt_start != -1) { + + optind = nonopt_start; + } + nonopt_start = nonopt_end = -1; + return -1; + } + if ((*(place = nargv[optind]) != '-') + || (place[1] == '\0')) { + place = EMSG; + if (IN_ORDER) { + + optarg = nargv[optind++]; + return INORDER; + } + if (!PERMUTE) { + + return -1; + } + + if (nonopt_start == -1) + nonopt_start = optind; + else if (nonopt_end != -1) { + permute_args(nonopt_start,nonopt_end,optind,nargv); + nonopt_start = optind - + (nonopt_end - nonopt_start); + nonopt_end = -1; + } + optind++; + + goto start; + } + if (nonopt_start != -1 && nonopt_end == -1) + nonopt_end = optind; + if (place[1] && *++place == '-') { + place++; + return -2; + } + } + if ((optchar = (int)*place++) == (int)':' || + (oli = strchr(options + (IGNORE_FIRST ? 1 : 0),optchar)) == NULL) { + + if (!*place) + ++optind; + if (PRINT_ERROR) + warnx(illoptchar,optchar); + optopt = optchar; + return BADCH; + } + if (optchar == 'W' && oli[1] == ';') { + + if (*place) + return -2; + + if (++optind >= nargc) { + place = EMSG; + if (PRINT_ERROR) + warnx(recargchar,optchar); + optopt = optchar; + return BADARG; + } else + place = nargv[optind]; + + return -2; + } + if (*++oli != ':') { + if (!*place) + ++optind; + } else { + optarg = NULL; + if (*place) + optarg = place; + + else if (oli[1] != ':') { + if (++optind >= nargc) { + place = EMSG; + if (PRINT_ERROR) + warnx(recargchar,optchar); + optopt = optchar; + return BADARG; + } else + optarg = nargv[optind]; + } + place = EMSG; + ++optind; + } + + return optchar; +} + +#ifdef REPLACE_GETOPT + +int +getopt(nargc,nargv,options) + int nargc; + char * const *nargv; + const char *options; +{ + int retval; + + _DIAGASSERT(nargv != NULL); + _DIAGASSERT(options != NULL); + + if ((retval = getopt_internal(nargc,nargv,options)) == -2) { + ++optind; + + if (nonopt_end != -1) { + permute_args(nonopt_start,nonopt_end,optind,nargv); + optind -= nonopt_end - nonopt_start; + } + nonopt_start = nonopt_end = -1; + retval = -1; + } + return retval; +} +#endif + +int +getopt_long(nargc,nargv,options,long_options,idx) + int nargc; + char * const *nargv; + const char *options; + const struct option *long_options; + int *idx; +{ + int retval; + + _DIAGASSERT(nargv != NULL); + _DIAGASSERT(options != NULL); + _DIAGASSERT(long_options != NULL); + + if ((retval = getopt_internal(nargc,nargv,options)) == -2) { + char *current_argv,*has_equal; + size_t current_argv_len; + int i,match; + + current_argv = place; + match = -1; + + optind++; + place = EMSG; + + if (*current_argv == '\0') { + + if (nonopt_end != -1) { + permute_args(nonopt_start,nonopt_end,optind,nargv); + optind -= nonopt_end - nonopt_start; + } + nonopt_start = nonopt_end = -1; + return -1; + } + if ((has_equal = strchr(current_argv,'=')) != NULL) { + + current_argv_len = has_equal - current_argv; + has_equal++; + } else + current_argv_len = strlen(current_argv); + + for (i = 0; long_options[i].name; i++) { + + if (strncmp(current_argv,long_options[i].name,current_argv_len)) + continue; + + if (strlen(long_options[i].name) == + (unsigned)current_argv_len) { + + match = i; + break; + } + if (match == -1) + match = i; + else { + + if (PRINT_ERROR) + warnx(ambig,(int)current_argv_len,current_argv); + optopt = 0; + return BADCH; + } + } + if (match != -1) { + if (long_options[match].has_arg == no_argument + && has_equal) { + if (PRINT_ERROR) + warnx(noarg,(int)current_argv_len,current_argv); + + if (long_options[match].flag == NULL) + optopt = long_options[match].val; + else + optopt = 0; + return BADARG; + } + if (long_options[match].has_arg == required_argument || + long_options[match].has_arg == optional_argument) { + if (has_equal) + optarg = has_equal; + else if (long_options[match].has_arg == + required_argument) { + + optarg = nargv[optind++]; + } + } + if ((long_options[match].has_arg == required_argument) + && (optarg == NULL)) { + + if (PRINT_ERROR) + warnx(recargstring,current_argv); + + if (long_options[match].flag == NULL) + optopt = long_options[match].val; + else + optopt = 0; + --optind; + return BADARG; + } + } else { + if (PRINT_ERROR) + warnx(illoptstring,current_argv); + optopt = 0; + return BADCH; + } + if (long_options[match].flag) { + *long_options[match].flag = long_options[match].val; + retval = 0; + } else + retval = long_options[match].val; + if (idx) + *idx = match; + } + return retval; +} diff --git a/reactos/lib/3rdparty/mingw/mingw.rbuild b/reactos/lib/3rdparty/mingw/mingw.rbuild index 0b9b12e5033..5d1fb5ba32e 100644 --- a/reactos/lib/3rdparty/mingw/mingw.rbuild +++ b/reactos/lib/3rdparty/mingw/mingw.rbuild @@ -20,6 +20,7 @@ crt_handler.c dllentry.c gccmain.c + getopt.c gs_support.c merr.c mingw_helpers.c @@ -35,6 +36,8 @@ xncommod.c xthdloc.c xtxtmode.c + ofmt_stub.c + cxa_pure_virtual.c diff --git a/reactos/lib/3rdparty/mingw/ofmt_stub.c b/reactos/lib/3rdparty/mingw/ofmt_stub.c new file mode 100644 index 00000000000..73e206dcf2b --- /dev/null +++ b/reactos/lib/3rdparty/mingw/ofmt_stub.c @@ -0,0 +1,6 @@ + +int _get_output_format(void) +{ + return 0; +} + From d0747d85c1d60609b0375efb1f95ddfade99ab50 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Tue, 30 Mar 2010 21:35:52 +0000 Subject: [PATCH 112/134] fix a typo svn path=/trunk/; revision=46607 --- reactos/lib/3rdparty/mingw/cxa_pure_virtual.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/lib/3rdparty/mingw/cxa_pure_virtual.c b/reactos/lib/3rdparty/mingw/cxa_pure_virtual.c index 308443b8d2a..2db21a00fbe 100644 --- a/reactos/lib/3rdparty/mingw/cxa_pure_virtual.c +++ b/reactos/lib/3rdparty/mingw/cxa_pure_virtual.c @@ -1,5 +1,5 @@ -void assert(int); +void _assert(int); void __cxa_pure_virtual() { From 0225179140d27bd1b13b32b866dd48b0195461a2 Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Wed, 31 Mar 2010 02:43:57 +0000 Subject: [PATCH 113/134] [SETUPAPI] - Implement SetupDiOpenDeviceInterfaceW svn path=/trunk/; revision=46609 --- reactos/dll/win32/setupapi/devinst.c | 203 ++++++++++++++++++++++++++- 1 file changed, 202 insertions(+), 1 deletion(-) diff --git a/reactos/dll/win32/setupapi/devinst.c b/reactos/dll/win32/setupapi/devinst.c index 5e11cd04c18..94057f30cf6 100644 --- a/reactos/dll/win32/setupapi/devinst.c +++ b/reactos/dll/win32/setupapi/devinst.c @@ -3699,8 +3699,209 @@ BOOL WINAPI SetupDiOpenDeviceInterfaceW( DWORD OpenFlags, PSP_DEVICE_INTERFACE_DATA DeviceInterfaceData) { - FIXME("%p %s %08x %p\n", + struct DeviceInfoSet * list; + PCWSTR pEnd; + DWORD dwLength, dwError, dwIndex, dwKeyName, dwSubIndex; + CLSID ClassId; + WCHAR Buffer[MAX_PATH + 1]; + WCHAR SymBuffer[MAX_PATH + 1]; + WCHAR InstancePath[MAX_PATH + 1]; + HKEY hKey, hDevKey, hSymKey; + struct DeviceInfo * deviceInfo; + struct DeviceInterface *deviceInterface; + BOOL Ret; + PLIST_ENTRY ItemList; + PLIST_ENTRY InterfaceListEntry; + + TRACE("%p %s %08x %p\n", DeviceInfoSet, debugstr_w(DevicePath), OpenFlags, DeviceInterfaceData); + + + if (DeviceInterfaceData && DeviceInterfaceData->cbSize != sizeof(SP_DEVICE_INTERFACE_DATA)) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + + if (((struct DeviceInfoSet *)DeviceInfoSet)->magic != SETUP_DEVICE_INFO_SET_MAGIC) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + + list = (struct DeviceInfoSet * )DeviceInfoSet; + + dwLength = wcslen(DevicePath); + if (dwLength < 39) + { + /* path must be at least a guid length + L'\0' */ + SetLastError(ERROR_BAD_PATHNAME); + return FALSE; + } + + if (DevicePath[0] != L'\\' || + DevicePath[1] != L'\\' || + (DevicePath[2] != L'?' && DevicePath[2] != L'.') || + DevicePath[3] != L'\\') + { + /* invalid formatted path */ + SetLastError(ERROR_BAD_PATHNAME); + return FALSE; + } + + /* check for reference strings */ + pEnd = wcschr(&DevicePath[4], L'\\'); + if (!pEnd) + { + /* no reference string */ + pEnd = DevicePath + dwLength; + } + + /* copy guid */ + wcscpy(Buffer, pEnd - 37); + Buffer[36] = L'\0'; + + dwError = UuidFromStringW(Buffer, &ClassId); + if (dwError != NOERROR) + { + /* invalid formatted path */ + SetLastError(ERROR_BAD_PATHNAME); + return FALSE; + } + + hKey = SetupDiOpenClassRegKeyExW(&ClassId, KEY_READ, DIOCR_INTERFACE, list->MachineName, NULL); + + if (hKey == INVALID_HANDLE_VALUE) + { + /* invalid device class */ + return FALSE; + } + + ItemList = list->ListHead.Flink; + while (ItemList != &list->ListHead) + { + deviceInfo = CONTAINING_RECORD(ItemList, struct DeviceInfo, ListEntry); + InterfaceListEntry = deviceInfo->InterfaceListHead.Flink; + while (InterfaceListEntry != &deviceInfo->InterfaceListHead) + { + deviceInterface = CONTAINING_RECORD(InterfaceListEntry, struct DeviceInterface, ListEntry); + if (!IsEqualIID(&deviceInterface->InterfaceClassGuid, &ClassId)) + { + InterfaceListEntry = InterfaceListEntry->Flink; + continue; + } + + if (!wcsicmp(deviceInterface->SymbolicLink, DevicePath)) + { + if (DeviceInterfaceData) + { + DeviceInterfaceData->Reserved = (ULONG_PTR)deviceInterface; + DeviceInterfaceData->Flags = deviceInterface->Flags; + CopyMemory(&DeviceInterfaceData->InterfaceClassGuid, &ClassId, sizeof(GUID)); + } + + return TRUE; + } + + } + } + + + dwIndex = 0; + do + { + Buffer[0] = 0; + dwKeyName = sizeof(Buffer) / sizeof(WCHAR); + dwError = RegEnumKeyExW(hKey, dwIndex, Buffer, &dwKeyName, NULL, NULL, NULL, NULL); + + if (dwError != ERROR_SUCCESS) + break; + + if (RegOpenKeyExW(hKey, Buffer, 0, KEY_READ, &hDevKey) != ERROR_SUCCESS) + break; + + dwSubIndex = 0; + InstancePath[0] = 0; + dwKeyName = sizeof(InstancePath); + + dwError = RegQueryValueExW(hDevKey, L"DeviceInstance", NULL, NULL, (LPBYTE)InstancePath, &dwKeyName); + + while(TRUE) + { + Buffer[0] = 0; + dwKeyName = sizeof(Buffer) / sizeof(WCHAR); + dwError = RegEnumKeyExW(hDevKey, dwSubIndex, Buffer, &dwKeyName, NULL, NULL, NULL, NULL); + + if (dwError != ERROR_SUCCESS) + break; + + dwError = RegOpenKeyExW(hDevKey, Buffer, 0, KEY_READ, &hSymKey); + if (dwError != ERROR_SUCCESS) + break; + + /* query for symbolic link */ + dwKeyName = sizeof(SymBuffer); + SymBuffer[0] = L'\0'; + dwError = RegQueryValueExW(hSymKey, L"SymbolicLink", NULL, NULL, (LPBYTE)SymBuffer, &dwKeyName); + + if (dwError != ERROR_SUCCESS) + { + RegCloseKey(hSymKey); + break; + } + + if (!wcsicmp(SymBuffer, DevicePath)) + { + Ret = CreateDeviceInfo(list, InstancePath, &ClassId, &deviceInfo); + RegCloseKey(hSymKey); + RegCloseKey(hDevKey); + RegCloseKey(hKey); + + if (Ret) + { + deviceInterface = HeapAlloc(GetProcessHeap(), 0, sizeof(struct DeviceInterface) + (wcslen(SymBuffer) + 1) * sizeof(WCHAR)); + if (deviceInterface) + { + + CopyMemory(&deviceInterface->InterfaceClassGuid, &ClassId, sizeof(GUID)); + deviceInterface->DeviceInfo = deviceInfo; + deviceInterface->Flags = SPINT_ACTIVE; //FIXME + + wcscpy(deviceInterface->SymbolicLink, SymBuffer); + + InsertTailList(&deviceInfo->InterfaceListHead, &deviceInterface->ListEntry); + InsertTailList(&list->ListHead, &deviceInfo->ListEntry); + + + if (DeviceInterfaceData) + { + DeviceInterfaceData->Reserved = (ULONG_PTR)deviceInterface; + DeviceInterfaceData->Flags = deviceInterface->Flags; + CopyMemory(&DeviceInterfaceData->InterfaceClassGuid, &ClassId, sizeof(GUID)); + } + else + { + Ret = FALSE; + SetLastError(ERROR_INVALID_USER_BUFFER); + } + } + } + else + { + HeapFree(GetProcessHeap(), 0, deviceInfo); + Ret = FALSE; + } + return Ret; + } + RegCloseKey(hSymKey); + dwSubIndex++; + } + + RegCloseKey(hDevKey); + dwIndex++; + }while(TRUE); + + RegCloseKey(hKey); return FALSE; } From 03317815a6bf217be57b37db6c63533c3755e345 Mon Sep 17 00:00:00 2001 From: Sir Richard Date: Wed, 31 Mar 2010 04:26:04 +0000 Subject: [PATCH 114/134] [HALACPI]: Add HAL ACPI header. svn path=/trunk/; revision=46610 --- reactos/hal/halx86/include/hal.h | 1 + reactos/hal/halx86/include/halacpi.h | 227 +++++++++++++++++++++++++++ 2 files changed, 228 insertions(+) create mode 100644 reactos/hal/halx86/include/halacpi.h diff --git a/reactos/hal/halx86/include/hal.h b/reactos/hal/halx86/include/hal.h index 3eff1e74b58..97e8f4a810e 100644 --- a/reactos/hal/halx86/include/hal.h +++ b/reactos/hal/halx86/include/hal.h @@ -48,5 +48,6 @@ #include "halp.h" #include "mps.h" #include "ioapic.h" +#include "halacpi.h" /* EOF */ diff --git a/reactos/hal/halx86/include/halacpi.h b/reactos/hal/halx86/include/halacpi.h new file mode 100644 index 00000000000..9d0e1b2818c --- /dev/null +++ b/reactos/hal/halx86/include/halacpi.h @@ -0,0 +1,227 @@ +#pragma once + +// +// Should be shared with FreeLDR +// +typedef struct _ACPI_E820_ENTRY +{ + PHYSICAL_ADDRESS Base; + LARGE_INTEGER Length; + ULONGLONG Type; +} ACPI_E820_ENTRY, *PACPI_E820_ENTRY; + +typedef struct _ACPI_BIOS_MULTI_NODE +{ + PHYSICAL_ADDRESS RsdtAddress; + ULONGLONG Count; + ACPI_E820_ENTRY E820Entry[1]; +} ACPI_BIOS_MULTI_NODE, *PACPI_BIOS_MULTI_NODE; + +// +// ACPI Signatures +// +#define RSDP_SIGNATURE 0x2052545020445352 // "RSD PTR " +#define FACS_SIGNATURE 0x53434146 // "FACS" +#define FADT_SIGNATURE 0x50434146 // "FACP" +#define RSDT_SIGNATURE 0x54445352 // "RSDT" +#define APIC_SIGNATURE 0x43495041 // "APIC" +#define DSDT_SIGNATURE 0x54445344 // "DSDT" +#define SSDT_SIGNATURE 0x54445353 // "SSDT" +#define PSDT_SIGNATURE 0x54445350 // "PSDT" +#define SBST_SIGNATURE 0x54534253 // "SBST" +#define DBGP_SIGNATURE 0x50474244 // "DBGP" + +// +// FADT Flags +// +#define ACPI_TMR_VAL_EXT 0x100 + +// +// ACPI Generic Register Address +// +typedef struct _GEN_ADDR +{ + UCHAR AddressSpaceID; + UCHAR BitWidth; + UCHAR BitOffset; + UCHAR Reserved; + PHYSICAL_ADDRESS Address; +} GEN_ADDR, *PGEN_ADDR; + +// +// ACPI BIOS Structures (packed) +// +#include +typedef struct _RSDP +{ + ULONGLONG Signature; + UCHAR Checksum; + UCHAR OEMID[6]; + UCHAR Reserved[1]; + ULONG RsdtAddress; +} RSDP; +typedef RSDP *PRSDP; + +typedef struct _DESCRIPTION_HEADER +{ + ULONG Signature; + ULONG Length; + UCHAR Revision; + UCHAR Checksum; + UCHAR OEMID[6]; + UCHAR OEMTableID[8]; + ULONG OEMRevision; + UCHAR CreatorID[4]; + ULONG CreatorRev; +} DESCRIPTION_HEADER; +typedef DESCRIPTION_HEADER *PDESCRIPTION_HEADER; + +typedef struct _FACS +{ + ULONG Signature; + ULONG Length; + ULONG HardwareSignature; + ULONG pFirmwareWakingVector; + ULONG GlobalLock; + ULONG Flags; + PHYSICAL_ADDRESS x_FirmwareWakingVector; + UCHAR version; + UCHAR Reserved[32]; +} FACS; +typedef FACS *PFACS; + +typedef struct _FADT +{ + DESCRIPTION_HEADER Header; + ULONG facs; + ULONG dsdt; + UCHAR int_model; + UCHAR pm_profile; + USHORT sci_int_vector; + ULONG smi_cmd_io_port; + UCHAR acpi_on_value; + UCHAR acpi_off_value; + UCHAR s4bios_req; + UCHAR pstate_control; + ULONG pm1a_evt_blk_io_port; + ULONG pm1b_evt_blk_io_port; + ULONG pm1a_ctrl_blk_io_port; + ULONG pm1b_ctrl_blk_io_port; + ULONG pm2_ctrl_blk_io_port; + ULONG pm_tmr_blk_io_port; + ULONG gp0_blk_io_port; + ULONG gp1_blk_io_port; + UCHAR pm1_evt_len; + UCHAR pm1_ctrl_len; + UCHAR pm2_ctrl_len; + UCHAR pm_tmr_len; + UCHAR gp0_blk_len; + UCHAR gp1_blk_len; + UCHAR gp1_base; + UCHAR cstate_control; + USHORT lvl2_latency; + USHORT lvl3_latency; + USHORT flush_size; + USHORT flush_stride; + UCHAR duty_offset; + UCHAR duty_width; + UCHAR day_alarm_index; + UCHAR month_alarm_index; + UCHAR century_alarm_index; + USHORT boot_arch; + UCHAR reserved3[1]; + ULONG flags; + GEN_ADDR reset_reg; + UCHAR reset_val; + UCHAR reserved4[3]; + PHYSICAL_ADDRESS x_firmware_ctrl; + PHYSICAL_ADDRESS x_dsdt; + GEN_ADDR x_pm1a_evt_blk; + GEN_ADDR x_pm1b_evt_blk; + GEN_ADDR x_pm1a_ctrl_blk; + GEN_ADDR x_pm1b_ctrl_blk; + GEN_ADDR x_pm2_ctrl_blk; + GEN_ADDR x_pm_tmr_blk; + GEN_ADDR x_gp0_blk; + GEN_ADDR x_gp1_blk; +} FADT; +typedef FADT *PFADT; + +typedef struct _DSDT +{ + DESCRIPTION_HEADER Header; + UCHAR DiffDefBlock[ANYSIZE_ARRAY]; +} DSDT; +typedef DSDT *PDSDT; + +typedef struct _RSDT +{ + DESCRIPTION_HEADER Header; + ULONG Tables[ANYSIZE_ARRAY]; +} RSDT; +typedef RSDT *PRSDT; + +typedef struct _XSDT +{ + DESCRIPTION_HEADER Header; + PHYSICAL_ADDRESS Tables[ANYSIZE_ARRAY]; +} XSDT; +typedef XSDT *PXSDT; +#include + +// +// Microsoft-specific (pretty much) ACPI Tables, normal MS ABI packing +// +typedef struct _DEBUG_PORT_TABLE +{ + DESCRIPTION_HEADER Header; + UCHAR InterfaceType; + UCHAR Reserved[3]; + GEN_ADDR BaseAddress; +} DEBUG_PORT_TABLE, *PDEBUG_PORT_TABLE; + +typedef struct _BOOT_TABLE +{ + DESCRIPTION_HEADER Header; + UCHAR CMOSIndex; + UCHAR Reserved[3]; +} BOOT_TABLE, *PBOOT_TABLE; + +typedef struct _ACPI_SRAT +{ + DESCRIPTION_HEADER Header; + UCHAR TableRevision; + ULONG Reserved[2]; +} ACPI_SRAT, *PACPI_SRAT; + +// +// Internal HAL structure +// +typedef struct _ACPI_CACHED_TABLE +{ + LIST_ENTRY Links; + DESCRIPTION_HEADER Header; + // table follows + // ... +} ACPI_CACHED_TABLE, *PACPI_CACHED_TABLE; + +NTSTATUS +NTAPI +HalpAcpiTableCacheInit( + IN PLOADER_PARAMETER_BLOCK LoaderBlock +); + +PVOID +NTAPI +HalpAcpiGetTable( + IN PLOADER_PARAMETER_BLOCK LoaderBlock, + IN ULONG Signature +); + +NTSTATUS +NTAPI +HalpSetupAcpiPhase0( + IN PLOADER_PARAMETER_BLOCK LoaderBlock +); + +/* EOF */ From bd4c20220d6181355d3debd9ea8e14b86c3c0052 Mon Sep 17 00:00:00 2001 From: Sir Richard Date: Wed, 31 Mar 2010 04:34:26 +0000 Subject: [PATCH 115/134] [HALACPI]: Add some missing signatures. svn path=/trunk/; revision=46611 --- reactos/hal/halx86/include/halacpi.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/reactos/hal/halx86/include/halacpi.h b/reactos/hal/halx86/include/halacpi.h index 9d0e1b2818c..aa342ab9215 100644 --- a/reactos/hal/halx86/include/halacpi.h +++ b/reactos/hal/halx86/include/halacpi.h @@ -30,6 +30,9 @@ typedef struct _ACPI_BIOS_MULTI_NODE #define PSDT_SIGNATURE 0x54445350 // "PSDT" #define SBST_SIGNATURE 0x54534253 // "SBST" #define DBGP_SIGNATURE 0x50474244 // "DBGP" +#define XSDT_SIGNATURE 'TDSX' +#define BOOT_SIGNATURE 'TOOB' +#define SRAT_SIGNATURE 'TARS' // // FADT Flags From 53b637ba7e7f0ee77447298516b286a1c9b4dac4 Mon Sep 17 00:00:00 2001 From: Sir Richard Date: Wed, 31 Mar 2010 04:38:20 +0000 Subject: [PATCH 116/134] [HAL]: Add Phase 0 HAL Heap Allocation/Mapping/Unmapping APIs, remove current broken APIs that depend on Mm having been initialized. These APIs use the HAL Heap that's typically at 0xFFC00000. FreeLDR seems to map this region correctly. [HAL]: Although currently implemented for ACPI support (to come), these APIs can now also be used to enable DMA in Phase 0 like NT, instead of only in Phase 1 like ReactOS. svn path=/trunk/; revision=46612 --- reactos/hal/halx86/generic/halinit.c | 215 +++++++++++++++++++++++++++ reactos/hal/halx86/generic/misc.c | 26 ---- reactos/hal/halx86/include/halp.h | 16 +- 3 files changed, 230 insertions(+), 27 deletions(-) diff --git a/reactos/hal/halx86/generic/halinit.c b/reactos/hal/halx86/generic/halinit.c index 498bf5cc5bb..8704b398c91 100644 --- a/reactos/hal/halx86/generic/halinit.c +++ b/reactos/hal/halx86/generic/halinit.c @@ -14,10 +14,225 @@ /* GLOBALS *******************************************************************/ +/* Share with Mm headers? */ +#define MM_HAL_VA_START (PVOID)0xFFC00000 +#define MM_HAL_HEAP_START (PVOID)((ULONG_PTR)MM_HAL_VA_START + (1024 * 1024)) + BOOLEAN HalpPciLockSettings; +ULONG HalpUsedAllocDescriptors; +MEMORY_ALLOCATION_DESCRIPTOR HalpAllocationDescriptorArray[64]; +PVOID HalpHeapStart = MM_HAL_HEAP_START; /* PRIVATE FUNCTIONS *********************************************************/ +ULONG +NTAPI +HalpAllocPhysicalMemory(IN PLOADER_PARAMETER_BLOCK LoaderBlock, + IN ULONG MaxAddress, + IN ULONG PageCount, + IN BOOLEAN Aligned) +{ + ULONG UsedDescriptors, Alignment, PhysicalAddress; + PFN_NUMBER MaxPage, BasePage; + PLIST_ENTRY NextEntry; + PMEMORY_ALLOCATION_DESCRIPTOR MdBlock, NewBlock, FreeBlock; + + /* Highest page we'll go */ + MaxPage = MaxAddress >> PAGE_SHIFT; + + /* We need at least two blocks */ + if ((HalpUsedAllocDescriptors + 2) > 64) return 0; + + /* Remember how many we have now */ + UsedDescriptors = HalpUsedAllocDescriptors; + + /* Loop the loader block memory descriptors */ + NextEntry = LoaderBlock->MemoryDescriptorListHead.Flink; + while (NextEntry != &LoaderBlock->MemoryDescriptorListHead) + { + /* Get the block */ + MdBlock = CONTAINING_RECORD(NextEntry, + MEMORY_ALLOCATION_DESCRIPTOR, + ListEntry); + + /* No alignment by default */ + Alignment = 0; + + /* Unless requested, in which case we use a 64KB block alignment */ + if (Aligned) Alignment = ((MdBlock->BasePage + 0x0F) & ~0x0F) - MdBlock->BasePage; + + /* Search for free memory */ + if ((MdBlock->MemoryType == LoaderFree) || + (MdBlock->MemoryType == MemoryFirmwareTemporary)) + { + /* Make sure the page is within bounds, including alignment */ + BasePage = MdBlock->BasePage; + if ((BasePage) && + (MdBlock->PageCount >= PageCount + Alignment) && + (BasePage + PageCount + Alignment < MaxPage)) + { + + /* We found an address */ + PhysicalAddress = (BasePage + Alignment) << PAGE_SHIFT; + break; + } + } + + /* Keep trying */ + NextEntry = NextEntry->Flink; + } + + /* If we didn't find anything, get out of here */ + if (NextEntry == &LoaderBlock->MemoryDescriptorListHead) return 0; + + /* Okay, now get a descriptor */ + NewBlock = &HalpAllocationDescriptorArray[HalpUsedAllocDescriptors]; + NewBlock->PageCount = PageCount; + NewBlock->BasePage = MdBlock->BasePage + Alignment; + NewBlock->MemoryType = LoaderHALCachedMemory; + + /* Update count */ + UsedDescriptors++; + HalpUsedAllocDescriptors = UsedDescriptors; + + /* Check if we had any alignment */ + if (Alignment) + { + /* Check if we had leftovers */ + if ((MdBlock->PageCount - Alignment) != PageCount) + { + /* Get the next descriptor */ + FreeBlock = &HalpAllocationDescriptorArray[UsedDescriptors]; + FreeBlock->PageCount = MdBlock->PageCount - Alignment - PageCount; + FreeBlock->BasePage = MdBlock->BasePage + Alignment + PageCount; + + /* One more */ + HalpUsedAllocDescriptors++; + + /* Insert it into the list */ + InsertHeadList(&MdBlock->ListEntry, &FreeBlock->ListEntry); + } + + /* Use this descriptor */ + NewBlock->PageCount = Alignment; + InsertHeadList(&MdBlock->ListEntry, &NewBlock->ListEntry); + } + else + { + /* Consume memory from this block */ + MdBlock->BasePage += PageCount; + MdBlock->PageCount -= PageCount; + + /* Insert the descriptor */ + InsertTailList(&MdBlock->ListEntry, &NewBlock->ListEntry); + + /* Remove the entry if the whole block was allocated */ + if (!MdBlock->PageCount == 0) RemoveEntryList(&MdBlock->ListEntry); + } + + /* Return the address */ + return PhysicalAddress; +} + +PVOID +NTAPI +HalpMapPhysicalMemory64(IN PHYSICAL_ADDRESS PhysicalAddress, + IN ULONG PageCount) +{ + PHARDWARE_PTE PointerPte; + ULONG UsedPages = 0; + PVOID VirtualAddress, BaseAddress; + + /* Start at the current HAL heap base */ + BaseAddress = HalpHeapStart; + + /* Loop until we have all the pages required */ + while (UsedPages < PageCount) + { + /* Begin a new loop cycle */ + UsedPages = 0; + VirtualAddress = BaseAddress; + + /* If this overflows past the HAL heap, it means there's no space */ + if (BaseAddress == NULL) return NULL; + + /* Loop until we have all the pages required in a single run */ + while (UsedPages < PageCount) + { + /* Get the PTE for this address and check if it's available */ + PointerPte = HalAddressToPte(VirtualAddress); + if (*(PULONG)PointerPte) + { + /* PTE has data, skip it and start with a new base address */ + BaseAddress = (PVOID)((ULONG_PTR)VirtualAddress + PAGE_SIZE); + break; + } + + /* PTE is available, keep going on this run */ + VirtualAddress = (PVOID)((ULONG_PTR)VirtualAddress + PAGE_SIZE); + UsedPages++; + } + } + + /* Take the base address of the page plus the actual offset in the address */ + VirtualAddress = (PVOID)((ULONG_PTR)BaseAddress + + BYTE_OFFSET(PhysicalAddress.LowPart)); + + /* If we are starting at the heap, move the heap */ + if (BaseAddress == HalpHeapStart) + { + /* Past this allocation */ + HalpHeapStart = (PVOID)((ULONG_PTR)BaseAddress + (PageCount * PAGE_SIZE)); + } + + /* Loop pages that can be mapped */ + while (UsedPages--) + { + /* Fill out the PTE */ + PointerPte = HalAddressToPte(BaseAddress); + PointerPte->PageFrameNumber = PhysicalAddress.QuadPart >> PAGE_SHIFT; + PointerPte->Valid = 1; + PointerPte->Write = 1; + + /* Move to the next address */ + PhysicalAddress.QuadPart += PAGE_SIZE; + BaseAddress = (PVOID)((ULONG_PTR)BaseAddress + PAGE_SIZE); + } + + /* Flush the TLB and return the address */ + HalpFlushTLB(); + return VirtualAddress; +} + +VOID +NTAPI +HalpUnmapVirtualAddress(IN PVOID VirtualAddress, + IN ULONG PageCount) +{ + PHARDWARE_PTE PointerPte; + ULONG i; + + /* Only accept valid addresses */ + if (VirtualAddress < MM_HAL_VA_START) return; + + /* Align it down to page size */ + VirtualAddress = (PVOID)((ULONG_PTR)VirtualAddress & ~(PAGE_SIZE - 1)); + + /* Loop PTEs */ + PointerPte = HalAddressToPte(VirtualAddress); + for (i = 0; i < PageCount; i++) + { + *(PULONG)PointerPte = 0; + PointerPte++; + } + + /* Flush the TLB */ + HalpFlushTLB(); + + /* Put the heap back */ + if (HalpHeapStart > VirtualAddress) HalpHeapStart = VirtualAddress; +} + VOID NTAPI HalpGetParameters(IN PLOADER_PARAMETER_BLOCK LoaderBlock) diff --git a/reactos/hal/halx86/generic/misc.c b/reactos/hal/halx86/generic/misc.c index 4ddd30ee589..f778b172d3e 100644 --- a/reactos/hal/halx86/generic/misc.c +++ b/reactos/hal/halx86/generic/misc.c @@ -28,32 +28,6 @@ HalpCheckPowerButton(VOID) return; } -#ifndef _MINIHAL_ -PVOID -NTAPI -HalpMapPhysicalMemory64(IN PHYSICAL_ADDRESS PhysicalAddress, - IN ULONG NumberPage) -{ - // - // Use kernel memory manager I/O map facilities - // - return MmMapIoSpace(PhysicalAddress, - NumberPage << PAGE_SHIFT, - MmNonCached); -} - -VOID -NTAPI -HalpUnmapVirtualAddress(IN PVOID VirtualAddress, - IN ULONG NumberPages) -{ - // - // Use kernel memory manager I/O map facilities - // - MmUnmapIoSpace(VirtualAddress, NumberPages << PAGE_SHIFT); -} -#endif - VOID NTAPI HalpFlushTLB(VOID) diff --git a/reactos/hal/halx86/include/halp.h b/reactos/hal/halx86/include/halp.h index 6fd63fa3e17..6ded9513258 100644 --- a/reactos/hal/halx86/include/halp.h +++ b/reactos/hal/halx86/include/halp.h @@ -681,7 +681,21 @@ HalpReleaseCmosSpinLock( VOID ); - +ULONG +NTAPI +HalpAllocPhysicalMemory( + IN PLOADER_PARAMETER_BLOCK LoaderBlock, + IN ULONG MaxAddress, + IN ULONG PageCount, + IN BOOLEAN Aligned +); + +PVOID +NTAPI +HalpMapPhysicalMemory64( + IN PHYSICAL_ADDRESS PhysicalAddress, + IN ULONG PageCount +); VOID FASTCALL From d623299da02c6c26c5e4fa6e35f6b00d3b8c3d22 Mon Sep 17 00:00:00 2001 From: Sir Richard Date: Wed, 31 Mar 2010 04:43:39 +0000 Subject: [PATCH 117/134] [HALACPI]: Implement beginning of HAL ACPI support (HalpSetupAcpiPhase0). Tested on VMWare, where it found the FACP, SRAT, RSDT and MCFG and the ACPI Timer at 1008H. BOOT and DBGP are not found (optional features). [HALACPI]: Support depends on boot loader creating the ACPI BIOS Multi Node structure in MultiFunctionAdapter in the hardware tree. It seems that FreeLdr does this (wow!) correctly! [HALACPI]: Implement HAL ACPI Table Cache. [HALACPI]: HAL ACPI Table Overrides from the boot loader are not supported (doubt FreeLdr does this). [HALACPI]: The next steps are to write the HAL ACPI PnP Driver and HAL ACPI Power Driver. svn path=/trunk/; revision=46613 --- reactos/hal/halx86/generic/acpi/halacpi.c | 864 ++++++++++++++++++++ reactos/hal/halx86/generic/halinit.c | 3 + reactos/hal/halx86/generic/legacy/halpcat.c | 27 + reactos/hal/halx86/hal_generic.rbuild | 6 + 4 files changed, 900 insertions(+) create mode 100644 reactos/hal/halx86/generic/acpi/halacpi.c create mode 100644 reactos/hal/halx86/generic/legacy/halpcat.c diff --git a/reactos/hal/halx86/generic/acpi/halacpi.c b/reactos/hal/halx86/generic/acpi/halacpi.c new file mode 100644 index 00000000000..f9fe8731dcc --- /dev/null +++ b/reactos/hal/halx86/generic/acpi/halacpi.c @@ -0,0 +1,864 @@ +/* + * PROJECT: ReactOS HAL + * LICENSE: BSD - See COPYING.ARM in the top level directory + * FILE: hal/halx86/generic/acpi/halacpi.c + * PURPOSE: HAL ACPI Code + * PROGRAMMERS: ReactOS Portable Systems Group + */ + +/* INCLUDES *******************************************************************/ + +#include +#define NDEBUG +#include + +/* GLOBALS ********************************************************************/ + +LIST_ENTRY HalpAcpiTableCacheList; +FAST_MUTEX HalpAcpiTableCacheLock; + +BOOLEAN HalpProcessedACPIPhase0; +BOOLEAN HalpPhysicalMemoryMayAppearAbove4GB; + +FADT HalpFixedAcpiDescTable; +PDEBUG_PORT_TABLE HalpDebugPortTable; +PACPI_SRAT HalpAcpiSrat; +PBOOT_TABLE HalpSimpleBootFlagTable; + +PHYSICAL_ADDRESS HalpMaxHotPlugMemoryAddress; +PHYSICAL_ADDRESS HalpLowStubPhysicalAddress; +PHARDWARE_PTE HalpPteForFlush; +PVOID HalpVirtAddrForFlush; +PVOID HalpLowStub; + +PACPI_BIOS_MULTI_NODE HalpAcpiMultiNode; + +LIST_ENTRY HalpAcpiTableMatchList; + +ULONG HalpInvalidAcpiTable; + +/* PRIVATE FUNCTIONS **********************************************************/ + +PDESCRIPTION_HEADER +NTAPI +HalpAcpiGetCachedTable(IN ULONG Signature) +{ + PLIST_ENTRY ListHead, NextEntry; + PACPI_CACHED_TABLE CachedTable; + + /* Loop cached tables */ + ListHead = &HalpAcpiTableCacheList; + NextEntry = ListHead->Flink; + while (NextEntry != ListHead) + { + /* Get the table */ + CachedTable = CONTAINING_RECORD(NextEntry, ACPI_CACHED_TABLE, Links); + + /* Compare signatures */ + if (CachedTable->Header.Signature == Signature) return &CachedTable->Header; + + /* Keep going */ + NextEntry = NextEntry->Flink; + } + + /* Nothing found */ + return NULL; +} + +VOID +NTAPI +HalpAcpiCacheTable(IN PDESCRIPTION_HEADER TableHeader) +{ + PACPI_CACHED_TABLE CachedTable; + + /* Get the cached table and link it */ + CachedTable = CONTAINING_RECORD(TableHeader, ACPI_CACHED_TABLE, Header); + InsertTailList(&HalpAcpiTableCacheList, &CachedTable->Links); +} + +PVOID +NTAPI +HalpAcpiCopyBiosTable(IN PLOADER_PARAMETER_BLOCK LoaderBlock, + IN PDESCRIPTION_HEADER TableHeader) +{ + ULONG Size; + PFN_NUMBER PageCount; + PHYSICAL_ADDRESS PhysAddress; + PACPI_CACHED_TABLE CachedTable; + PDESCRIPTION_HEADER CopiedTable; + + /* Size we'll need for the cached table */ + Size = TableHeader->Length + FIELD_OFFSET(ACPI_CACHED_TABLE, Header); + if (LoaderBlock) + { + /* Phase 0: Convert to pages and use the HAL heap */ + PageCount = BYTES_TO_PAGES(Size); + PhysAddress.LowPart = HalpAllocPhysicalMemory(LoaderBlock, + 0x1000000, + PageCount, + FALSE); + if (PhysAddress.LowPart) + { + /* Map it */ + CachedTable = HalpMapPhysicalMemory64(PhysAddress, PageCount); + } + else + { + /* No memory, so nothing to map */ + CachedTable = NULL; + } + } + else + { + /* Use Mm pool */ + CachedTable = ExAllocatePoolWithTag(NonPagedPool, Size, ' laH'); + } + + /* Do we have the cached table? */ + if (CachedTable) + { + /* Copy the data */ + CopiedTable = &CachedTable->Header; + RtlCopyMemory(CopiedTable, TableHeader, TableHeader->Length); + } + else + { + /* Nothing to return */ + CopiedTable = NULL; + } + + /* Return the table */ + return CopiedTable; +} + +PVOID +NTAPI +HalpAcpiGetTableFromBios(IN PLOADER_PARAMETER_BLOCK LoaderBlock, + IN ULONG Signature) +{ + PHYSICAL_ADDRESS PhysicalAddress; + PXSDT Xsdt; + PRSDT Rsdt; + PFADT Fadt; + PDESCRIPTION_HEADER Header = NULL; + ULONG TableLength; + CHAR CheckSum = 0; + ULONG Offset; + ULONG EntryCount, CurrentEntry; + PCHAR CurrentByte; + PFN_NUMBER PageCount; + + /* Should not query the RSDT/XSDT by itself */ + if ((Signature == RSDT_SIGNATURE) || (Signature == XSDT_SIGNATURE)) return NULL; + + /* Special case request for DSDT, because the FADT points to it */ + if (Signature == DSDT_SIGNATURE) + { + /* Grab the FADT */ + Fadt = HalpAcpiGetTable(LoaderBlock, FADT_SIGNATURE); + if (Fadt) + { + /* Grab the DSDT address and assume 2 pages */ + PhysicalAddress.LowPart = Fadt->dsdt; + TableLength = 2 * PAGE_SIZE; + + /* Map it */ + if (LoaderBlock) + { + /* Phase 0, use HAL heap */ + Header = HalpMapPhysicalMemory64(PhysicalAddress, 2u); + } + else + { + /* Phase 1, use Mm */ + Header = MmMapIoSpace(PhysicalAddress, 2 * PAGE_SIZE, 0); + } + + /* Fail if we couldn't map it */ + if (!Header) + { + DbgPrint("HAL: Failed to map ACPI table.\n"); + return NULL; + } + + /* Validate the signature */ + DPRINT1("ACPI DSDT at 0x%p\n", Header); + if (Header->Signature != DSDT_SIGNATURE) + { + /* Fail and unmap */ + if (LoaderBlock) + { + /* Using HAL heap */ + HalpUnmapVirtualAddress(Header, 2); + } + else + { + /* Using Mm */ + MmUnmapIoSpace(Header, 2 * PAGE_SIZE); + } + + /* Didn't find anything */ + return NULL; + } + } + else + { + /* Couldn't find it */ + return NULL; + } + } + else + { + /* To find tables, we need the RSDT */ + Rsdt = HalpAcpiGetTable(LoaderBlock, RSDT_SIGNATURE); + if (Rsdt) + { + /* Won't be using the XSDT */ + Xsdt = NULL; + } + else + { + /* Only other choice is to use the XSDT */ + Xsdt = HalpAcpiGetTable(LoaderBlock, XSDT_SIGNATURE); + if (!Xsdt) return NULL; + + /* Won't be using the RSDT */ + DPRINT1("ACPI XSDT at 0x%p\n", Xsdt); + Rsdt = NULL; + } + + /* Smallest RSDT/XSDT is one without table entries */ + Offset = FIELD_OFFSET(RSDT, Tables); + if (Xsdt) + { + /* Figure out total size of table and the offset */ + TableLength = Xsdt->Header.Length; + if (TableLength < Offset) Offset = Xsdt->Header.Length; + + /* The entries are each 64-bits, so count them */ + EntryCount = (TableLength - Offset) / sizeof(PHYSICAL_ADDRESS); + } + else + { + /* Figure out total size of table and the offset */ + TableLength = Rsdt->Header.Length; + if (TableLength < Offset) Offset = Rsdt->Header.Length; + + /* The entries are each 32-bits, so count them */ + EntryCount = (TableLength - Offset) / sizeof(ULONG); + } + + /* Start at the beginning of the array and loop it */ + for (CurrentEntry = 0; CurrentEntry < EntryCount; CurrentEntry++) + { + /* Are we using the XSDT? */ + if (!Xsdt) + { + /* Read the 32-bit physical address */ + PhysicalAddress.LowPart = Rsdt->Tables[CurrentEntry]; + } + else + { + /* Read the 64-bit physical address */ + PhysicalAddress = Xsdt->Tables[CurrentEntry]; + } + + /* Had we already mapped a table? */ + if (Header) + { + /* Yes, unmap it */ + if (LoaderBlock) + { + /* Using HAL heap */ + HalpUnmapVirtualAddress(Header, 2); + } + else + { + /* Using Mm */ + MmUnmapIoSpace(Header, 2 * PAGE_SIZE); + } + } + + /* Now map this table */ + if (!LoaderBlock) + { + /* Phase 1: Use HAL heap */ + Header = MmMapIoSpace(PhysicalAddress, 2 * PAGE_SIZE, MmNonCached); + } + else + { + /* Phase 0: Use Mm */ + Header = HalpMapPhysicalMemory64(PhysicalAddress, 2); + } + + /* Check if we mapped it */ + if (!Header) + { + /* Game over */ + DbgPrint("HAL: Failed to map ACPI table.\n"); + return NULL; + } + + /* We found it, break out */ + DPRINT("Found ACPI table %c%c%c%c at 0x%p\n", + Header->Signature & 0xFF, + (Header->Signature & 0xFF00) >> 8, + (Header->Signature & 0xFF0000) >> 16, + (Header->Signature & 0xFF000000) >> 24, + Header); + if (Header->Signature == Signature) break; + } + + /* Did we end up here back at the last entry? */ + if (CurrentEntry == EntryCount) + { + /* Yes, unmap the last table we processed */ + if (LoaderBlock) + { + /* Using HAL heap */ + HalpUnmapVirtualAddress(Header, 2); + } + else + { + /* Using Mm */ + MmUnmapIoSpace(Header, 2 * PAGE_SIZE); + } + + /* Didn't find anything */ + return NULL; + } + } + + /* Past this point, we assume something was found */ + ASSERT(Header); + + /* How many pages do we need? */ + PageCount = BYTES_TO_PAGES(Header->Length); + if (PageCount != 2) + { + /* We assumed two, but this is not the case, free the current mapping */ + if (LoaderBlock) + { + /* Using HAL heap */ + HalpUnmapVirtualAddress(Header, 2); + } + else + { + /* Using Mm */ + MmUnmapIoSpace(Header, 2 * PAGE_SIZE); + } + + /* Now map this table using its correct size */ + if (!LoaderBlock) + { + /* Phase 1: Use HAL heap */ + Header = MmMapIoSpace(PhysicalAddress, PageCount << PAGE_SHIFT, MmNonCached); + } + else + { + /* Phase 0: Use Mm */ + Header = HalpMapPhysicalMemory64(PhysicalAddress, PageCount); + } + } + + /* Fail if the remapped failed */ + if (!Header) return NULL; + + /* All tables in ACPI 3.0 other than the FACP should have correct checksum */ + if ((Header->Signature != FADT_SIGNATURE) || (Header->Revision > 2)) + { + /* Go to the end of the table */ + CheckSum = 0; + CurrentByte = (PCHAR)Header + Header->Length; + while (CurrentByte-- != (PCHAR)Header) + { + /* Add this byte */ + CheckSum += *CurrentByte; + } + + /* The correct checksum is always 0, anything else is illegal */ + if (CheckSum) HalpInvalidAcpiTable = Header->Signature; + } + + /* Return the table */ + return Header; +} + +PVOID +NTAPI +HalpAcpiGetTable(IN PLOADER_PARAMETER_BLOCK LoaderBlock, + IN ULONG Signature) +{ + PFN_NUMBER PageCount; + PDESCRIPTION_HEADER TableAddress, BiosCopy; + + /* See if we have a cached table? */ + TableAddress = HalpAcpiGetCachedTable(Signature); + if (!TableAddress) + { + /* No cache, search the BIOS */ + TableAddress = HalpAcpiGetTableFromBios(LoaderBlock, Signature); + if (TableAddress) + { + /* Found it, copy it into our own memory */ + BiosCopy = HalpAcpiCopyBiosTable(LoaderBlock, TableAddress); + + /* Get the pages, and unmap the BIOS copy */ + PageCount = BYTES_TO_PAGES(TableAddress->Length); + if (LoaderBlock) + { + /* Phase 0, use the HAL heap */ + HalpUnmapVirtualAddress(TableAddress, PageCount); + } + else + { + /* Phase 1, use Mm */ + MmUnmapIoSpace(TableAddress, PageCount << 12); + } + + /* Cache the bios copy */ + TableAddress = BiosCopy; + if (BiosCopy) HalpAcpiCacheTable(BiosCopy); + } + } + + /* Return the table */ + return TableAddress; +} + +PVOID +NTAPI +HalAcpiGetTable(IN PLOADER_PARAMETER_BLOCK LoaderBlock, + IN ULONG Signature) +{ + PDESCRIPTION_HEADER TableHeader; + + /* Is this phase0 */ + if (LoaderBlock) + { + /* Initialize the cache first */ + if (!NT_SUCCESS(HalpAcpiTableCacheInit(LoaderBlock))) return NULL; + } + else + { + /* Lock the cache */ + ExAcquireFastMutex(&HalpAcpiTableCacheLock); + } + + /* Get the table */ + TableHeader = HalpAcpiGetTable(LoaderBlock, Signature); + + /* Release the lock in phase 1 */ + if (!LoaderBlock) ExReleaseFastMutex(&HalpAcpiTableCacheLock); + + /* Return the table */ + return TableHeader; +} + +VOID +NTAPI +HalpNumaInitializeStaticConfiguration(IN PLOADER_PARAMETER_BLOCK LoaderBlock) +{ + PACPI_SRAT SratTable; + + /* Get the SRAT, bail out if it doesn't exist */ + SratTable = HalAcpiGetTable(LoaderBlock, SRAT_SIGNATURE); + HalpAcpiSrat = SratTable; + if (!SratTable) return; +} + +VOID +NTAPI +HalpGetHotPlugMemoryInfo(IN PLOADER_PARAMETER_BLOCK LoaderBlock) +{ + PACPI_SRAT SratTable; + + /* Get the SRAT, bail out if it doesn't exist */ + SratTable = HalAcpiGetTable(LoaderBlock, SRAT_SIGNATURE); + HalpAcpiSrat = SratTable; + if (!SratTable) return; +} + +VOID +NTAPI +HalpDynamicSystemResourceConfiguration(IN PLOADER_PARAMETER_BLOCK LoaderBlock) +{ + /* For this HAL, it means to get hot plug memory information */ + HalpGetHotPlugMemoryInfo(LoaderBlock); +} + +VOID +NTAPI +HalpAcpiDetectMachineSpecificActions(IN PLOADER_PARAMETER_BLOCK LoaderBlock, + IN PFADT DescriptionTable) +{ + /* Does this HAL specify something? */ + if (HalpAcpiTableMatchList.Flink) + { + /* Great, but we don't support it */ + DPRINT1("WARNING: Your HAL has specific ACPI hacks to apply!\n"); + } +} + +VOID +NTAPI +HalpInitBootTable(IN PLOADER_PARAMETER_BLOCK LoaderBlock) +{ + PBOOT_TABLE BootTable; + + /* Get the boot table */ + BootTable = HalAcpiGetTable(LoaderBlock, BOOT_SIGNATURE); + HalpSimpleBootFlagTable = BootTable; + DPRINT1("ACPI BOOT at 0x%p\n", HalpSimpleBootFlagTable); + + /* Validate it */ + if ((BootTable) && + (BootTable->Header.Length >= sizeof(BOOT_TABLE)) && + (BootTable->CMOSIndex >= 9)) + { + DPRINT1("ACPI Boot table found, but not supported!\n"); + } + else + { + /* Invalid or doesn't exist, ignore it */ + HalpSimpleBootFlagTable = 0; + } + + /* Install the end of boot handler */ +// HalEndOfBoot = HalpEndOfBoot; +} + +NTSTATUS +NTAPI +HalpAcpiFindRsdtPhase0(IN PLOADER_PARAMETER_BLOCK LoaderBlock, + OUT PACPI_BIOS_MULTI_NODE* AcpiMultiNode) +{ + PCONFIGURATION_COMPONENT_DATA ComponentEntry; + PCONFIGURATION_COMPONENT_DATA Next = NULL; + PCM_PARTIAL_RESOURCE_LIST ResourceList; + PACPI_BIOS_MULTI_NODE NodeData; + ULONG NodeLength; + PFN_NUMBER PageCount; + PVOID MappedAddress; + PHYSICAL_ADDRESS PhysicalAddress; + + /* Did we already do this once? */ + if (HalpAcpiMultiNode) + { + /* Return what we know */ + *AcpiMultiNode = HalpAcpiMultiNode; + return STATUS_SUCCESS; + } + + /* Assume failure */ + *AcpiMultiNode = NULL; + + /* Find the multi function adapter key */ + ComponentEntry = KeFindConfigurationNextEntry(LoaderBlock->ConfigurationRoot, + AdapterClass, + MultiFunctionAdapter, + 0, + &Next); + while (ComponentEntry) + { + /* Find the ACPI BIOS key */ + if (!_stricmp(ComponentEntry->ComponentEntry.Identifier, "ACPI BIOS")) + { + /* Found it */ + break; + } + + /* Keep searching */ + Next = ComponentEntry; + ComponentEntry = KeFindConfigurationNextEntry(LoaderBlock->ConfigurationRoot, + AdapterClass, + MultiFunctionAdapter, + NULL, + &Next); + } + + /* Make sure we found it */ + if (!ComponentEntry) + { + DbgPrint("**** HalpAcpiFindRsdtPhase0: did NOT find RSDT\n"); + return STATUS_NOT_FOUND; + } + + /* The configuration data is a resource list, and the BIOS node follows */ + ResourceList = ComponentEntry->ConfigurationData; + NodeData = (PACPI_BIOS_MULTI_NODE)(ResourceList + 1); + + /* How many E820 memory entries are there? */ + NodeLength = sizeof(ACPI_BIOS_MULTI_NODE) + + (NodeData->Count - 1) * sizeof(ACPI_E820_ENTRY); + + /* Convert to pages */ + PageCount = BYTES_TO_PAGES(NodeLength); + + /* Allocate the memory */ + PhysicalAddress.LowPart = HalpAllocPhysicalMemory(LoaderBlock, + 0x1000000, + PageCount, + FALSE); + if (PhysicalAddress.LowPart) + { + /* Map it if the allocation worked */ + MappedAddress = HalpMapPhysicalMemory64(PhysicalAddress, PageCount); + } + else + { + /* Otherwise we'll have to fail */ + MappedAddress = NULL; + } + + /* Save the multi node, bail out if we didn't find it */ + HalpAcpiMultiNode = MappedAddress; + if (!MappedAddress) return STATUS_INSUFFICIENT_RESOURCES; + + /* Copy the multi-node data */ + RtlCopyMemory(MappedAddress, NodeData, NodeLength); + + /* Return the data */ + *AcpiMultiNode = HalpAcpiMultiNode; + return STATUS_SUCCESS; +} + +NTSTATUS +NTAPI +HalpAcpiTableCacheInit(IN PLOADER_PARAMETER_BLOCK LoaderBlock) +{ + PACPI_BIOS_MULTI_NODE AcpiMultiNode; + NTSTATUS Status = STATUS_SUCCESS; + PHYSICAL_ADDRESS PhysicalAddress; + PVOID MappedAddress; + ULONG TableLength; + PRSDT Rsdt; + PLOADER_PARAMETER_EXTENSION LoaderExtension; + + /* Only initialize once */ + if (HalpAcpiTableCacheList.Flink) return Status; + + /* Setup the lock and table */ + ExInitializeFastMutex(&HalpAcpiTableCacheLock); + InitializeListHead(&HalpAcpiTableCacheList); + + /* Find the RSDT */ + Status = HalpAcpiFindRsdtPhase0(LoaderBlock, &AcpiMultiNode); + if (!NT_SUCCESS(Status)) return Status; + + /* Map the RSDT */ + if (LoaderBlock) + { + /* Phase0: Use HAL Heap to map the RSDT, we assume it's about 2 pages */ + PhysicalAddress.QuadPart = AcpiMultiNode->RsdtAddress.QuadPart; + MappedAddress = HalpMapPhysicalMemory64(PhysicalAddress, 2); + } + else + { + /* Use an I/O map */ + MappedAddress = MmMapIoSpace(PhysicalAddress, PAGE_SIZE * 2, MmNonCached); + } + + /* Get the RSDT */ + Rsdt = MappedAddress; + if (!MappedAddress) + { + /* Fail, no memory */ + DbgPrint("HAL: Failed to map RSDT\n"); + return STATUS_INSUFFICIENT_RESOURCES; + } + + /* Validate it */ + DPRINT1("ACPI RSDT at 0x%p\n", Rsdt); + if ((Rsdt->Header.Signature != RSDT_SIGNATURE) && + (Rsdt->Header.Signature != XSDT_SIGNATURE)) + { + /* Very bad: crash */ + HalDisplayString("Bad RSDT pointer\n"); + KeBugCheckEx(MISMATCHED_HAL, 4, __LINE__, 0, 0); + } + + /* We assumed two pages -- do we need less or more? */ + TableLength = ADDRESS_AND_SIZE_TO_SPAN_PAGES(PhysicalAddress.LowPart, + Rsdt->Header.Length); + if (TableLength != 2) + { + /* Are we in phase 0 or 1? */ + if (!LoaderBlock) + { + /* Unmap the old table, remap the new one, using Mm I/O space */ + MmUnmapIoSpace(MappedAddress, 2 * PAGE_SIZE); + MappedAddress = MmMapIoSpace(PhysicalAddress, + TableLength << PAGE_SHIFT, + MmNonCached); + } + else + { + /* Unmap the old table, remap the new one, using HAL heap */ + HalpUnmapVirtualAddress(MappedAddress, 2); + MappedAddress = HalpMapPhysicalMemory64(PhysicalAddress, TableLength); + } + + /* Get the remapped table */ + Rsdt = MappedAddress; + if (!MappedAddress) + { + /* Fail, no memory */ + DbgPrint("HAL: Couldn't remap RSDT\n"); + return STATUS_INSUFFICIENT_RESOURCES; + } + } + + /* Now take the BIOS copy and make our own local copy */ + Rsdt = HalpAcpiCopyBiosTable(LoaderBlock, &Rsdt->Header); + if (!Rsdt) + { + /* Fail, no memory */ + DbgPrint("HAL: Couldn't remap RSDT\n"); + return STATUS_INSUFFICIENT_RESOURCES; + } + + /* Get rid of the BIOS mapping */ + if (LoaderBlock) + { + /* Use HAL heap */ + HalpUnmapVirtualAddress(MappedAddress, TableLength); + } + else + { + /* Use Mm */ + MmUnmapIoSpace(MappedAddress, TableLength << PAGE_SHIFT); + } + + /* Cache the RSDT */ + HalpAcpiCacheTable(&Rsdt->Header); + + /* Check for compatible loader block extension */ + LoaderExtension = LoaderBlock->Extension; + if (LoaderExtension->Size >= 0x58) + { + /* Compatible loader: did it provide an ACPI table override? */ + if ((LoaderExtension->AcpiTable) && (LoaderExtension->AcpiTableSize)) + { + /* Great, because we don't support it! */ + DPRINT1("ACPI Table Overrides Not Supported!\n"); + } + } + + /* Done */ + return Status; +} + +VOID +NTAPI +HaliAcpiTimerInit(IN ULONG TimerPort, + IN ULONG TimerValExt) +{ + PAGED_CODE(); + + /* Is this in the init phase? */ + if (!TimerPort ) + { + /* Get the data from the FADT */ + TimerPort = HalpFixedAcpiDescTable.pm_tmr_blk_io_port; + TimerValExt = HalpFixedAcpiDescTable.flags & ACPI_TMR_VAL_EXT; + } + + /* FIXME: Now proceed to the timer initialization */ + DPRINT1("ACPI Timer at: %Xh (EXT: %d)\n", TimerPort, TimerValExt); + //HalaAcpiTimerInit(TimerPort, TimerValExt); +} + +NTSTATUS +NTAPI +HalpSetupAcpiPhase0(IN PLOADER_PARAMETER_BLOCK LoaderBlock) +{ + NTSTATUS Status; + PFADT Fadt; + ULONG TableLength; + PHYSICAL_ADDRESS PhysicalAddress; + + /* Only do this once */ + DPRINT1("You are booting the ACPI HAL!\n"); + if (HalpProcessedACPIPhase0) return STATUS_SUCCESS; + + /* Setup the ACPI table cache */ + Status = HalpAcpiTableCacheInit(LoaderBlock); + if (!NT_SUCCESS(Status)) return Status; + + /* Grab the FADT */ + Fadt = HalAcpiGetTable(LoaderBlock, FADT_SIGNATURE); + if (!Fadt) + { + /* Fail */ + DbgPrint("HAL: Didn't find the FACP\n"); + return STATUS_NOT_FOUND; + } + + /* Assume typical size, otherwise whatever the descriptor table says */ + DPRINT1("ACPI FACP at 0x%p\n", Fadt); + TableLength = sizeof(FADT); + if (Fadt->Header.Length < sizeof(FADT)) TableLength = Fadt->Header.Length; + + /* Copy it in the HAL static buffer */ + RtlCopyMemory(&HalpFixedAcpiDescTable, Fadt, TableLength); + + /* Anything special this HAL needs to do? */ + HalpAcpiDetectMachineSpecificActions(LoaderBlock, &HalpFixedAcpiDescTable); + + /* Get the debug table for KD */ + HalpDebugPortTable = HalAcpiGetTable(LoaderBlock, DBGP_SIGNATURE); + DPRINT1("ACPI DBGP at 0x%p\n", HalpDebugPortTable); + + /* Initialize NUMA through the SRAT */ + HalpNumaInitializeStaticConfiguration(LoaderBlock); + + /* Initialize hotplug through the SRAT */ + HalpDynamicSystemResourceConfiguration(LoaderBlock); + DPRINT1("ACPI SRAT at 0x%p\n", HalpAcpiSrat); + if (HalpAcpiSrat) + { + DPRINT1("Your machine has a SRAT, but NUMA/HotPlug are not supported!\n"); + } + + /* Can there be memory higher than 4GB? */ + if (HalpMaxHotPlugMemoryAddress.HighPart >= 1) + { + /* We'll need this for DMA later */ + HalpPhysicalMemoryMayAppearAbove4GB = TRUE; + } + + /* Setup the ACPI timer */ + HaliAcpiTimerInit(0, 0); + + /* Do we have a low stub address yet? */ + if (!HalpLowStubPhysicalAddress.LowPart) + { + /* Allocate it */ + HalpLowStubPhysicalAddress.LowPart = HalpAllocPhysicalMemory(LoaderBlock, + 0x100000, + 1, + FALSE); + if (HalpLowStubPhysicalAddress.LowPart) + { + /* Map it */ + HalpLowStub = HalpMapPhysicalMemory64(HalpLowStubPhysicalAddress, 1); + } + } + + /* Grab a page for flushes */ + PhysicalAddress.QuadPart = 0x100000; + HalpVirtAddrForFlush = HalpMapPhysicalMemory64(PhysicalAddress, 1); + HalpPteForFlush = HalAddressToPte(HalpVirtAddrForFlush); + + /* Don't do this again */ + HalpProcessedACPIPhase0 = TRUE; + + /* Setup the boot table */ + HalpInitBootTable(LoaderBlock); + + /* Return success */ + return STATUS_SUCCESS; +} + +/* EOF */ diff --git a/reactos/hal/halx86/generic/halinit.c b/reactos/hal/halx86/generic/halinit.c index 8704b398c91..4309ac1a16e 100644 --- a/reactos/hal/halx86/generic/halinit.c +++ b/reactos/hal/halx86/generic/halinit.c @@ -307,6 +307,9 @@ HalInitSystem(IN ULONG BootPhase, } #ifndef _MINIHAL_ + /* Initialize ACPI */ + HalpSetupAcpiPhase0(LoaderBlock); + /* Initialize the PICs */ HalpInitializePICs(TRUE); #endif diff --git a/reactos/hal/halx86/generic/legacy/halpcat.c b/reactos/hal/halx86/generic/legacy/halpcat.c new file mode 100644 index 00000000000..bbabb9c7aa2 --- /dev/null +++ b/reactos/hal/halx86/generic/legacy/halpcat.c @@ -0,0 +1,27 @@ +/* + * PROJECT: ReactOS HAL + * LICENSE: BSD - See COPYING.ARM in the top level directory + * FILE: hal/halx86/generic/acpi/halpcat.c + * PURPOSE: HAL Legacy Support Code + * PROGRAMMERS: ReactOS Portable Systems Group + */ + +/* INCLUDES *******************************************************************/ + +#include +#define NDEBUG +#include + +/* GLOBALS ********************************************************************/ + +/* PRIVATE FUNCTIONS **********************************************************/ + +NTSTATUS +NTAPI +HalpSetupAcpiPhase0(IN PLOADER_PARAMETER_BLOCK LoaderBlock) +{ + /* There is no ACPI on these HALs */ + return STATUS_NO_SUCH_DEVICE; +} + +/* EOF */ diff --git a/reactos/hal/halx86/hal_generic.rbuild b/reactos/hal/halx86/hal_generic.rbuild index cc295ad0fcd..d8f8fa2068f 100644 --- a/reactos/hal/halx86/hal_generic.rbuild +++ b/reactos/hal/halx86/hal_generic.rbuild @@ -7,6 +7,9 @@ + + halpcat.c + bushndlr.c isabus.c @@ -53,6 +56,9 @@ + + halacpi.c + bushndlr.c isabus.c From 3cedfaae34ca5392ebb25dc903cae795cf989eb5 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Wed, 31 Mar 2010 10:21:14 +0000 Subject: [PATCH 118/134] [KERNEL32] Add RtlAddFunctionTable export for amd64 svn path=/trunk/; revision=46614 --- reactos/dll/win32/kernel32/kernel32.pspec | 1 + 1 file changed, 1 insertion(+) diff --git a/reactos/dll/win32/kernel32/kernel32.pspec b/reactos/dll/win32/kernel32/kernel32.pspec index 05f19157a16..b952a287b5d 100644 --- a/reactos/dll/win32/kernel32/kernel32.pspec +++ b/reactos/dll/win32/kernel32/kernel32.pspec @@ -759,6 +759,7 @@ @ stdcall ResetWriteWatch(ptr long) @ stdcall RestoreLastError(long) ntdll.RtlRestoreLastWin32Error @ stdcall ResumeThread(long) +@ stdcall -arch=x86_64 RtlAddFunctionTable(ptr long double) @ stdcall RtlCaptureContext(ptr) ntdll.RtlCaptureContext @ stdcall RtlCaptureStackBackTrace(long long ptr ptr) ntdll.RtlCaptureStackBackTrace @ stdcall -arch=x86_64 RtlCompareMemory(ptr ptr ptr) From 572aa7509d8a6895668f90a00f32936ad879daee Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Wed, 31 Mar 2010 11:57:21 +0000 Subject: [PATCH 119/134] [RBUILD] - Don't link to RosBE's ofmt_stub.a, as we have our own version now. - Don't link to libcoldname.a on amd64, instead link to libgcc_eh.a svn path=/trunk/; revision=46615 --- reactos/tools/rbuild/backend/mingw/mingw.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/reactos/tools/rbuild/backend/mingw/mingw.cpp b/reactos/tools/rbuild/backend/mingw/mingw.cpp index 597b26baad5..76289ac5f5c 100644 --- a/reactos/tools/rbuild/backend/mingw/mingw.cpp +++ b/reactos/tools/rbuild/backend/mingw/mingw.cpp @@ -480,18 +480,17 @@ MingwBackend::GenerateGlobalVariables () const fputs ( "BUILTIN_CXXINCLUDES+= $(TARGET_CPPFLAGS)\n", fMakefile ); fprintf ( fMakefile, "PROJECT_CCLIBS := \"$(shell ${TARGET_CC} -print-libgcc-file-name)\"\n" ); - - // We use our proprietary "ofmt_stub.a" to implement a stub for "_get_output_format" required by "libmingwex.a". - // This archive just contains the compiled "ofmt_stub.s" supplied with the MinGW Runtime sources. - fprintf ( fMakefile, "PROJECT_CXXLIBS := \"$(shell ${TARGET_CPP} -print-file-name=libstdc++.a)\" \"$(shell ${TARGET_CPP} -print-libgcc-file-name)\" \"$(shell ${TARGET_CPP} -print-file-name=libmingw32.a)\" \"$(shell ${TARGET_CPP} -print-file-name=libmingwex.a)\" \"$(shell ${TARGET_CPP} -print-file-name=ofmt_stub.a)\" \"$(shell ${TARGET_CPP} -print-file-name=libcoldname.a)\"\n" ); + + fprintf ( fMakefile, "PROJECT_CXXLIBS := \"$(shell ${TARGET_CPP} -print-file-name=libstdc++.a)\" \"$(shell ${TARGET_CPP} -print-libgcc-file-name)\" \"$(shell ${TARGET_CPP} -print-file-name=libmingw32.a)\" \"$(shell ${TARGET_CPP} -print-file-name=libmingwex.a)\"" ); /* hack to get libgcc_eh.a, should check mingw version or something */ if (Environment::GetArch() == "amd64") - { - fprintf ( fMakefile, "PROJECT_LPPFLAGS += $(shell ${TARGET_CPP} -print-file-name=libgcc_eh.a)\n" ); - } + fprintf ( fMakefile, " \"$(shell ${TARGET_CPP} -print-file-name=libgcc_eh.a)\"" ); + /* hack to get _get_output_format, needed by libmingwex */ + else if (Environment::GetArch() == "i386") + fprintf ( fMakefile, " \"$(shell ${TARGET_CPP} -print-file-name=libcoldname.a)\" "); + fprintf ( fMakefile,"\n"); } - MingwModuleHandler::GenerateParameters ( "PROJECT", "+=", ProjectNode.non_if_data ); MingwModuleHandler::GenerateParameters ( "PROJECT_HOST", "+=", ProjectNode.host_non_if_data ); @@ -975,7 +974,7 @@ MingwBackend::IsSupportedBinutilsVersion ( const string& binutilsVersion ) { int digit = binutilsVersion.find_last_of("."); if(digit == -1) - { + { printf("Unable to detect binutils version!\n"); return false; } From 0e774b5a9bbd781eda98d2a6dc8787a1bac741a8 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Wed, 31 Mar 2010 12:16:42 +0000 Subject: [PATCH 120/134] [tchar.h] enable _tcsnlen definition svn path=/trunk/; revision=46616 --- reactos/include/crt/tchar.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/reactos/include/crt/tchar.h b/reactos/include/crt/tchar.h index 0b5011eadd0..d7c31478341 100644 --- a/reactos/include/crt/tchar.h +++ b/reactos/include/crt/tchar.h @@ -624,9 +624,7 @@ extern "C" { #define _tcscpy_s strcpy_s #define _tcsdup _strdup #define _tcslen strlen -#if 0 #define _tcsnlen strnlen -#endif #define _tcsxfrm strxfrm #define _tcsxfrm_l _strxfrm_l #define _tcserror strerror From 0254cbbcf962ddb394fd49e3ac0e5ceb42562b32 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Wed, 31 Mar 2010 13:25:51 +0000 Subject: [PATCH 121/134] [NTOSKRNL/CONFIG] - Add more assert macros for registry operations: locked or loading, exclusively locked or loading, hash and KCB locks, locked for flushing. - Add macros for getting alloc page from KCB and delay alloc item. svn path=/trunk/; revision=46617 --- reactos/ntoskrnl/include/internal/cm_x.h | 57 ++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/reactos/ntoskrnl/include/internal/cm_x.h b/reactos/ntoskrnl/include/internal/cm_x.h index 581a336d636..02e84219635 100644 --- a/reactos/ntoskrnl/include/internal/cm_x.h +++ b/reactos/ntoskrnl/include/internal/cm_x.h @@ -91,6 +91,14 @@ CmpIsKeyValueBig(IN PHHIVE Hive, ASSERT((CmpSpecialBootCondition == TRUE) || \ (CmpTestRegistryLock() == TRUE)) +// +// Makes sure that the registry is locked or loading +// +#define CMP_ASSERT_REGISTRY_LOCK_OR_LOADING(h) \ + ASSERT((CmpSpecialBootCondition == TRUE) || \ + (((PCMHIVE)h)->HiveIsLoading == TRUE) || \ + (CmpTestRegistryLock() == TRUE)) + // // Makes sure that the registry is exclusively locked // @@ -98,6 +106,14 @@ CmpIsKeyValueBig(IN PHHIVE Hive, ASSERT((CmpSpecialBootCondition == TRUE) || \ (CmpTestRegistryLockExclusive() == TRUE)) +// +// Makes sure that the registry is exclusively locked or loading +// +#define CMP_ASSERT_EXCLUSIVE_REGISTRY_LOCK_OR_LOADING(h) \ + ASSERT((CmpSpecialBootCondition == TRUE) || \ + (((PCMHIVE)h)->HiveIsLoading == TRUE) || \ + (CmpTestRegistryLockExclusive() == TRUE)) + // // Makes sure this is a valid KCB // @@ -255,6 +271,47 @@ CmpConvertKcbSharedToExclusive(IN PCM_KEY_CONTROL_BLOCK k) (k)).Lock); \ } +// +// Asserts that either the registry or the hash entry is locked +// +#define CMP_ASSERT_HASH_ENTRY_LOCK(k) \ +{ \ + ASSERT(((GET_HASH_ENTRY(CmpCacheTable, k).Owner == \ + KeGetCurrentThread())) || \ + (CmpTestRegistryLockExclusive() == TRUE)); \ +} + +// +// Asserts that either the registry or the KCB is locked +// +#define CMP_ASSERT_KCB_LOCK(k) \ +{ \ + ASSERT((CmpIsKcbLockedExclusive(k) == TRUE) || \ + (CmpTestRegistryLockExclusive() == TRUE)); \ +} + +// +// Gets the page attached to the KCB +// +#define CmpGetAllocPageFromKcb(k) \ + (PCM_ALLOC_PAGE)(((ULONG_PTR)(k)) & ~(PAGE_SIZE - 1)) + +// +// Gets the page attached to the delayed allocation +// +#define CmpGetAllocPageFromDelayAlloc(a) \ + (PCM_ALLOC_PAGE)(((ULONG_PTR)(a)) & ~(PAGE_SIZE - 1)) + +// +// Makes sure that the registry is locked for flushes +// +#define CMP_ASSERT_FLUSH_LOCK(h) \ + ASSERT((CmpSpecialBootCondition == TRUE) || \ + (((PCMHIVE)h)->HiveIsLoading == TRUE) || \ + (CmpTestHiveFlusherLockShared((PCMHIVE)h) == TRUE) || \ + (CmpTestHiveFlusherLockExclusive((PCMHIVE)h) == TRUE) || \ + (CmpTestRegistryLockExclusive() == TRUE)); + // // Asserts that either the registry or the KCB is locked // From 3b722382ee8c5fa1e3adbfc0366b504a8248c098 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Wed, 31 Mar 2010 14:10:24 +0000 Subject: [PATCH 122/134] [NTOSKRNL/CONFIG] - Stub support for global quota enable. - Stub support for notifications. - Add a source file for a future HiveList implementation. svn path=/trunk/; revision=46618 --- reactos/ntoskrnl/config/cmhvlist.c | 17 +++++++++++ reactos/ntoskrnl/config/cmnotify.c | 36 ++++++++++++++++++++++++ reactos/ntoskrnl/config/cmquota.c | 26 +++++++++++++++++ reactos/ntoskrnl/ntoskrnl-generic.rbuild | 3 ++ 4 files changed, 82 insertions(+) create mode 100644 reactos/ntoskrnl/config/cmhvlist.c create mode 100644 reactos/ntoskrnl/config/cmnotify.c create mode 100644 reactos/ntoskrnl/config/cmquota.c diff --git a/reactos/ntoskrnl/config/cmhvlist.c b/reactos/ntoskrnl/config/cmhvlist.c new file mode 100644 index 00000000000..f4e97814bbd --- /dev/null +++ b/reactos/ntoskrnl/config/cmhvlist.c @@ -0,0 +1,17 @@ +/* + * PROJECT: ReactOS Kernel + * LICENSE: GPL - See COPYING in the top level directory + * FILE: ntoskrnl/config/cmwraprs.c + * PURPOSE: Configuration Manager - Wrappers for Hive Operations + * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org) + */ + +/* INCLUDES ******************************************************************/ + +#include "ntoskrnl.h" +#define NDEBUG +#include "debug.h" + +/* FUNCTIONS *****************************************************************/ + +/* EOF */ \ No newline at end of file diff --git a/reactos/ntoskrnl/config/cmnotify.c b/reactos/ntoskrnl/config/cmnotify.c new file mode 100644 index 00000000000..afb5d4dfecb --- /dev/null +++ b/reactos/ntoskrnl/config/cmnotify.c @@ -0,0 +1,36 @@ +/* + * PROJECT: ReactOS Kernel + * LICENSE: GPL - See COPYING in the top level directory + * FILE: ntoskrnl/config/cmwraprs.c + * PURPOSE: Configuration Manager - Wrappers for Hive Operations + * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org) + */ + +/* INCLUDES ******************************************************************/ + +#include "ntoskrnl.h" +#define NDEBUG +#include "debug.h" + +/* FUNCTIONS *****************************************************************/ + +VOID +NTAPI +CmpReportNotify(IN PCM_KEY_CONTROL_BLOCK Kcb, + IN PHHIVE Hive, + IN HCELL_INDEX Cell, + IN ULONG Filter) +{ + /* FIXME: TODO */ + return; +} + +VOID +NTAPI +CmpFlushNotify(IN PCM_KEY_BODY KeyBody, + IN BOOLEAN LockHeld) +{ + /* FIXME: TODO */ + return; +} + diff --git a/reactos/ntoskrnl/config/cmquota.c b/reactos/ntoskrnl/config/cmquota.c new file mode 100644 index 00000000000..b5c5a582167 --- /dev/null +++ b/reactos/ntoskrnl/config/cmquota.c @@ -0,0 +1,26 @@ +/* + * PROJECT: ReactOS Kernel + * LICENSE: GPL - See COPYING in the top level directory + * FILE: ntoskrnl/config/cmwraprs.c + * PURPOSE: Configuration Manager - Wrappers for Hive Operations + * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org) + */ + +/* INCLUDES ******************************************************************/ + +#include "ntoskrnl.h" +#define NDEBUG +#include "debug.h" + +BOOLEAN CmpGlobalQuota; +BOOLEAN CmpGlobalQuotaAllowed; + +/* FUNCTIONS *****************************************************************/ + +VOID +NTAPI +CmpSetGlobalQuotaAllowed(VOID) +{ + /* Set flag ON if quota enabled */ + CmpGlobalQuotaAllowed = CmpGlobalQuota; +} diff --git a/reactos/ntoskrnl/ntoskrnl-generic.rbuild b/reactos/ntoskrnl/ntoskrnl-generic.rbuild index 0427f1bceeb..a605ee1b147 100644 --- a/reactos/ntoskrnl/ntoskrnl-generic.rbuild +++ b/reactos/ntoskrnl/ntoskrnl-generic.rbuild @@ -144,13 +144,16 @@ cmdelay.c cmindex.c cminit.c + cmhvlist.c cmhook.c cmkcbncb.c cmkeydel.c cmlazy.c cmmapvw.c cmname.c + cmnotify.c cmparse.c + cmquota.c cmse.c cmsecach.c cmsysini.c From fbf49091871d8c66387d76369df736e8fd79592e Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Wed, 31 Mar 2010 14:27:11 +0000 Subject: [PATCH 123/134] [NTOSKRNL/CONFIG] - Implement new (correct) hive flusher lock/release routines, unused right now. svn path=/trunk/; revision=46619 --- reactos/ntoskrnl/config/cmsysini.c | 51 +++++++++++++++++++++ reactos/ntoskrnl/include/internal/cm.h | 63 ++++++++++++++++++++++++++ 2 files changed, 114 insertions(+) diff --git a/reactos/ntoskrnl/config/cmsysini.c b/reactos/ntoskrnl/config/cmsysini.c index ab3b1d46bb1..0326e88e619 100644 --- a/reactos/ntoskrnl/config/cmsysini.c +++ b/reactos/ntoskrnl/config/cmsysini.c @@ -27,6 +27,7 @@ BOOLEAN CmpFlushOnLockRelease; BOOLEAN CmpSpecialBootCondition; BOOLEAN CmpNoWrite; BOOLEAN CmpWasSetupBoot; +BOOLEAN CmpProfileLoaded; ULONG CmpTraceLevel = 0; extern LONG CmpFlushStarveWriters; @@ -1622,6 +1623,56 @@ CmpTestRegistryLockExclusive(VOID) return !ExIsResourceAcquiredExclusiveLite(&CmpRegistryLock) ? FALSE : TRUE; } +VOID +NTAPI +CmpLockHiveFlusherExclusive(IN PCMHIVE Hive) +{ + /* Lock the flusher. We should already be in a critical section */ + CMP_ASSERT_REGISTRY_LOCK_OR_LOADING(Hive); + ASSERT((ExIsResourceAcquiredShared(Hive->FlusherLock) == 0) && + (ExIsResourceAcquiredExclusiveLite(Hive->FlusherLock) == 0)); + ExAcquireResourceExclusiveLite(Hive->FlusherLock, TRUE); +} + +VOID +NTAPI +CmpLockHiveFlusherShared(IN PCMHIVE Hive) +{ + /* Lock the flusher. We should already be in a critical section */ + CMP_ASSERT_REGISTRY_LOCK_OR_LOADING(Hive); + ASSERT((ExIsResourceAcquiredShared(Hive->FlusherLock) == 0) && + (ExIsResourceAcquiredExclusiveLite(Hive->FlusherLock) == 0)); + ExAcquireResourceSharedLite(Hive->FlusherLock, TRUE); +} + +VOID +NTAPI +CmpUnlockHiveFlusher(IN PCMHIVE Hive) +{ + /* Sanity check */ + CMP_ASSERT_REGISTRY_LOCK_OR_LOADING(Hive); + CMP_ASSERT_FLUSH_LOCK(Hive); + + /* Release the lock */ + ExReleaseResourceLite(Hive->FlusherLock); +} + +BOOLEAN +NTAPI +CmpTestHiveFlusherLockShared(IN PCMHIVE Hive) +{ + /* Test the lock */ + return !ExIsResourceAcquiredSharedLite(Hive->FlusherLock) ? FALSE : TRUE; +} + +BOOLEAN +NTAPI +CmpTestHiveFlusherLockExclusive(IN PCMHIVE Hive) +{ + /* Test the lock */ + return !ExIsResourceAcquiredExclusiveLite(Hive->FlusherLock) ? FALSE : TRUE; +} + VOID NTAPI CmpUnlockRegistry(VOID) diff --git a/reactos/ntoskrnl/include/internal/cm.h b/reactos/ntoskrnl/include/internal/cm.h index 537111a4f29..4880dc08026 100644 --- a/reactos/ntoskrnl/include/internal/cm.h +++ b/reactos/ntoskrnl/include/internal/cm.h @@ -621,6 +621,24 @@ CmCheckRegistry( IN ULONG Flags ); +// +// Hive List Routines +// +NTSTATUS +NTAPI +CmpAddToHiveFileList( + IN PCMHIVE Hive +); + +// +// Quota Routines +// +VOID +NTAPI +CmpSetGlobalQuotaAllowed( + VOID +); + // // Notification Routines // @@ -633,6 +651,13 @@ CmpReportNotify( IN ULONG Filter ); +VOID +NTAPI +CmpFlushNotify( + IN PCM_KEY_BODY KeyBody, + IN BOOLEAN LockHeld +); + VOID NTAPI CmpInitCallback( @@ -822,6 +847,36 @@ CmpUnlockRegistry( VOID ); +VOID +NTAPI +CmpLockHiveFlusherExclusive( + IN PCMHIVE Hive +); + +VOID +NTAPI +CmpLockHiveFlusherShared( + IN PCMHIVE Hive +); + +BOOLEAN +NTAPI +CmpTestHiveFlusherLockExclusive( + IN PCMHIVE Hive +); + +BOOLEAN +NTAPI +CmpTestHiveFlusherLockShared( + IN PCMHIVE Hive +); + +VOID +NTAPI +CmpUnlockHiveFlusher( + IN PCMHIVE Hive +); + // // Delay Functions // @@ -978,6 +1033,13 @@ CmpReleaseTwoKcbLockByKey( IN ULONG ConvKey2 ); +VOID +NTAPI +CmpFlushNotifiesOnKeyBodyList( + IN PCM_KEY_CONTROL_BLOCK Kcb, + IN BOOLEAN LockHeld +); + // // Name Functions // @@ -1507,6 +1569,7 @@ extern ULONG CmpDelayedCloseSize, CmpDelayedCloseIndex; extern BOOLEAN CmpNoWrite; extern BOOLEAN CmpForceForceFlush; extern BOOLEAN CmpWasSetupBoot; +extern BOOLEAN CmpProfileLoaded; extern PCMHIVE CmiVolatileHive; extern LIST_ENTRY CmiKeyObjectListHead; extern BOOLEAN CmpHoldLazyFlush; From 99e6ad789f583f434412475a26a0fb47820583d8 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Wed, 31 Mar 2010 15:11:20 +0000 Subject: [PATCH 124/134] [NTOS] Add internal amd64 headers. svn path=/trunk/; revision=46620 --- .../include/internal/amd64/asmmacro.S | 81 ++++++ .../include/internal/amd64/intrin_i.h | 128 +++++++++ reactos/ntoskrnl/include/internal/amd64/ke.h | 268 ++++++++++++++++++ reactos/ntoskrnl/include/internal/amd64/mm.h | 189 ++++++++++++ .../ntoskrnl/include/internal/arch/intrin_i.h | 2 + reactos/ntoskrnl/include/internal/arch/ke.h | 2 + reactos/ntoskrnl/include/internal/arch/mm.h | 2 + 7 files changed, 672 insertions(+) create mode 100644 reactos/ntoskrnl/include/internal/amd64/asmmacro.S create mode 100644 reactos/ntoskrnl/include/internal/amd64/intrin_i.h create mode 100644 reactos/ntoskrnl/include/internal/amd64/ke.h create mode 100644 reactos/ntoskrnl/include/internal/amd64/mm.h diff --git a/reactos/ntoskrnl/include/internal/amd64/asmmacro.S b/reactos/ntoskrnl/include/internal/amd64/asmmacro.S new file mode 100644 index 00000000000..9d7a1807321 --- /dev/null +++ b/reactos/ntoskrnl/include/internal/amd64/asmmacro.S @@ -0,0 +1,81 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS Kernel + * FILE: ntoskrnl/include/amd64/asmmacro.S + * PURPOSE: Macros for x64 assembly + * PROGRAMMERS: Timo Kreuzer (timo.kreuzer@reactos.org) + */ + +.intel_syntax noprefix +.code64 + +/* Macros for x64 stack unwind OPs */ + +.macro .proc name + .func name + .global _\name + _\name: + .cfi_startproc + .equ cfa_current_offset, -8 +.endm + +.macro .endproc + .cfi_endproc + .endfunc +.endm + +.macro .allocstack size + .cfi_adjust_cfa_offset \size + .set cfa_current_offset, cfa_current_offset - \size +.endm + +.macro .pushframe code + .if (\code == 0) + .cfi_adjust_cfa_offset 0x28 + .set cfa_current_offset, cfa_current_offset - 0x28 + .else + .cfi_adjust_cfa_offset 0x30 + .set cfa_current_offset, cfa_current_offset - 0x30 + .endif +.endm + +.macro .pushreg reg + .cfi_adjust_cfa_offset 8 + .equ cfa_current_offset, cfa_current_offset - 8 + .cfi_offset \reg, cfa_current_offset +.endm + +.macro .savereg reg, offset + // checkme!!! + .cfi_offset \reg, \offset +.endm + +.macro .savexmm128 reg, offset + // checkme!!! + .cfi_offset \reg, \offset +.endm + +.macro .setframe reg, offset + .cfi_def_cfa reg, \offset + .equ cfa_current_offset, \offset +.endm + +.macro .endprolog +.endm + +.macro UNIMPLEMENTED2 line, func + jmp 3f + .equ expr, 12 +1: .asciz "\func" +2: .asciz __FILE__ +3: + sub rsp, 0x20 + lea rcx, _MsgUnimplemented[rip] + lea rdx, 1b[rip] + lea r8, 2b[rip] + mov r9, \line + call _DbgPrint + add rsp, 0x20 +.endm +#define UNIMPLEMENTED UNIMPLEMENTED2 __LINE__, + diff --git a/reactos/ntoskrnl/include/internal/amd64/intrin_i.h b/reactos/ntoskrnl/include/internal/amd64/intrin_i.h new file mode 100644 index 00000000000..d3dca40eaf2 --- /dev/null +++ b/reactos/ntoskrnl/include/internal/amd64/intrin_i.h @@ -0,0 +1,128 @@ +#ifndef _INTRIN_INTERNAL_ +#define _INTRIN_INTERNAL_ + +VOID +FORCEINLINE +KeSetCurrentIrql(KIRQL Irql) +{ + __writecr8(Irql); +} + +PKGDTENTRY64 +FORCEINLINE +KiGetGdtEntry(PVOID pGdt, USHORT Selector) +{ + return (PKGDTENTRY64)((ULONG64)pGdt + (Selector & ~RPL_MASK)); +} + +PVOID +FORCEINLINE +KiGetGdtDescriptorBase(PKGDTENTRY Entry) +{ + return (PVOID)((ULONG64)Entry->BaseLow | + (ULONG64)Entry->Bytes.BaseMiddle << 16 | + (ULONG64)Entry->Bytes.BaseHigh << 24 | + (ULONG64)Entry->BaseUpper << 32); +} + +VOID +FORCEINLINE +KiSetGdtDescriptorBase(PKGDTENTRY Entry, ULONG64 Base) +{ + Entry->BaseLow = Base & 0xffff; + Entry->Bits.BaseMiddle = (Base >> 16) & 0xff; + Entry->Bits.BaseHigh = (Base >> 24) & 0xff; + Entry->BaseUpper = Base >> 32; +} + +VOID +FORCEINLINE +KiSetGdtDescriptorLimit(PKGDTENTRY Entry, ULONG Limit) +{ + Entry->LimitLow = Limit & 0xffff; + Entry->Bits.LimitHigh = Limit >> 16; +} + +VOID +FORCEINLINE +KiInitGdtEntry(PKGDTENTRY64 Entry, ULONG64 Base, ULONG Size, UCHAR Type, UCHAR Dpl) +{ + KiSetGdtDescriptorBase(Entry, Base); + KiSetGdtDescriptorLimit(Entry, Size - 1); + Entry->Bits.Type = Type; + Entry->Bits.Dpl = Dpl; + Entry->Bits.Present = 1; + Entry->Bits.System = 0; + Entry->Bits.LongMode = 0; + Entry->Bits.DefaultBig = 0; + Entry->Bits.Granularity = 0; + Entry->MustBeZero = 0; +} + +#if defined(__GNUC__) + +static __inline__ __attribute__((always_inline)) void __lgdt(void *Source) +{ + __asm__ __volatile__("lgdt %0" : : "m"(*(short*)Source)); +} + +static __inline__ __attribute__((always_inline)) void __sgdt(void *Destination) +{ + __asm__ __volatile__("sgdt %0" : : "m"(*(short*)Destination) : "memory"); +} + +static __inline__ __attribute__((always_inline)) void __lldt(unsigned short Value) +{ + __asm__ __volatile__("lldt %0" : : "rm"(Value)); +} + +static __inline__ __attribute__((always_inline)) void __sldt(void *Destination) +{ + __asm__ __volatile__("sldt %0" : : "m"(*(short*)Destination) : "memory"); +} + +static __inline__ __attribute__((always_inline)) void __ldmxcsr(unsigned long *Source) +{ + __asm__ __volatile__("ldmxcsr %0" : : "m"(*Source)); +} + +static __inline__ __attribute__((always_inline)) void __stmxcsr(unsigned long *Destination) +{ + __asm__ __volatile__("stmxcsr %0" : : "m"(*Destination) : "memory"); +} + +static __inline__ __attribute__((always_inline)) void __ltr(unsigned short Source) +{ + __asm__ __volatile__("ltr %0" : : "rm"(Source)); +} + +static __inline__ __attribute__((always_inline)) void __str(unsigned short *Destination) +{ + __asm__ __volatile__("str %0" : : "m"(*Destination) : "memory"); +} + + +#elif defined(_MSC_VER) + +#define UNIMPLEMENTED DbgPrint("%s is unimplemented!!!\n", __FUNCTION__); + +void __lgdt(void *Source); + +void __sgdt(void *Destination); + +void __lldt(unsigned short Value); + +void __sldt(void *Destination); + +void __ltr(unsigned short Source); + +void __str(unsigned short *Destination); + + +#else +#error Unknown compiler for inline assembler +#endif + +#endif + +/* EOF */ diff --git a/reactos/ntoskrnl/include/internal/amd64/ke.h b/reactos/ntoskrnl/include/internal/amd64/ke.h new file mode 100644 index 00000000000..2e43edc248d --- /dev/null +++ b/reactos/ntoskrnl/include/internal/amd64/ke.h @@ -0,0 +1,268 @@ +#ifndef __NTOSKRNL_INCLUDE_INTERNAL_AMD64_KE_H +#define __NTOSKRNL_INCLUDE_INTERNAL_AMD64_KE_H + +#define X86_EFLAGS_TF 0x00000100 /* Trap flag */ +#define X86_EFLAGS_IF 0x00000200 /* Interrupt Enable flag */ +#define X86_EFLAGS_IOPL 0x00003000 /* I/O Privilege Level bits */ +#define X86_EFLAGS_NT 0x00004000 /* Nested Task flag */ +#define X86_EFLAGS_RF 0x00010000 /* Resume flag */ +#define X86_EFLAGS_VM 0x00020000 /* Virtual Mode */ +#define X86_EFLAGS_ID 0x00200000 /* CPUID detection flag */ + +#define X86_CR0_PE 0x00000001 /* enable Protected Mode */ +#define X86_CR0_NE 0x00000020 /* enable native FPU error reporting */ +#define X86_CR0_TS 0x00000008 /* enable exception on FPU instruction for task switch */ +#define X86_CR0_EM 0x00000004 /* enable FPU emulation (disable FPU) */ +#define X86_CR0_MP 0x00000002 /* enable FPU monitoring */ +#define X86_CR0_WP 0x00010000 /* enable Write Protect (copy on write) */ +#define X86_CR0_PG 0x80000000 /* enable Paging */ + +#define X86_CR4_PAE 0x00000020 /* enable physical address extensions */ +#define X86_CR4_PGE 0x00000080 /* enable global pages */ +#define X86_CR4_OSFXSR 0x00000200 /* enable FXSAVE/FXRSTOR instructions */ +#define X86_CR4_OSXMMEXCPT 0x00000400 /* enable #XF exception */ + +#define X86_FEATURE_VME 0x00000002 /* Virtual 8086 Extensions are present */ +#define X86_FEATURE_TSC 0x00000010 /* time stamp counters are present */ +#define X86_FEATURE_PAE 0x00000040 /* physical address extension is present */ +#define X86_FEATURE_CX8 0x00000100 /* CMPXCHG8B instruction present */ +#define X86_FEATURE_SYSCALL 0x00000800 /* SYSCALL/SYSRET support present */ +#define X86_FEATURE_PGE 0x00002000 /* Page Global Enable */ +#define X86_FEATURE_MMX 0x00800000 /* MMX extension present */ +#define X86_FEATURE_FXSR 0x01000000 /* FXSAVE/FXRSTOR instructions present */ +#define X86_FEATURE_SSE 0x02000000 /* SSE extension present */ +#define X86_FEATURE_SSE2 0x04000000 /* SSE2 extension present */ +#define X86_FEATURE_HT 0x10000000 /* Hyper-Threading present */ + +#define X86_EXT_FEATURE_SSE3 0x00000001 /* SSE3 extension present */ +#define X86_EXT_FEATURE_3DNOW 0x40000000 /* 3DNOW! extension present */ + +#define FRAME_EDITED 0xFFF8 + +#define X86_MSR_GSBASE 0xC0000101 +#define X86_MSR_KERNEL_GSBASE 0xC0000102 +#define X86_MSR_EFER 0xC0000080 +#define X86_MSR_STAR 0xC0000081 +#define X86_MSR_LSTAR 0xC0000082 +#define X86_MSR_CSTAR 0xC0000083 +#define X86_MSR_SFMASK 0xC0000084 + +#define EFER_SCE 0x01 +#define EFER_LME 0x10 +#define EFER_LMA 0x40 +#define EFER_NXE 0x80 +#define EFER_SVME 0x100 +#define EFER_FFXSR 0x400 + +#define AMD64_TSS 9 + +#ifndef __ASM__ + +#include "intrin_i.h" + +typedef struct _KIDT_INIT +{ + UCHAR InterruptId; + UCHAR Dpl; + UCHAR IstIndex; + PVOID ServiceRoutine; +} KIDT_INIT, *PKIDT_INIT; + +extern ULONG Ke386CacheAlignment; +extern ULONG KeI386NpxPresent; +extern ULONG KeI386XMMIPresent; +extern ULONG KeI386FxsrPresent; +extern ULONG KeI386CpuType; +extern ULONG KeI386CpuStep; + +#define IMAGE_FILE_MACHINE_ARCHITECTURE IMAGE_FILE_MACHINE_AMD64 + +// +// INT3 is 1 byte long +// +#define KD_BREAKPOINT_TYPE UCHAR +#define KD_BREAKPOINT_SIZE sizeof(UCHAR) +#define KD_BREAKPOINT_VALUE 0xCC + +// +// Macros for getting and setting special purpose registers in portable code +// +#define KeGetContextPc(Context) \ + ((Context)->Rip) + +#define KeSetContextPc(Context, ProgramCounter) \ + ((Context)->Rip = (ProgramCounter)) + +#define KeGetTrapFramePc(TrapFrame) \ + ((TrapFrame)->Rip) + +#define KeGetContextReturnRegister(Context) \ + ((Context)->Rax) + +#define KeSetContextReturnRegister(Context, ReturnValue) \ + ((Context)->Rax = (ReturnValue)) + +// +// Macro to get trap and exception frame from a thread stack +// +#define KeGetTrapFrame(Thread) \ + (PKTRAP_FRAME)((ULONG_PTR)((Thread)->InitialStack) - \ + sizeof(KTRAP_FRAME)) + +// +// Macro to get context switches from the PRCB +// All architectures but x86 have it in the PRCB's KeContextSwitches +// +#define KeGetContextSwitches(Prcb) \ + (Prcb->KeContextSwitches) + +#define KeGetExceptionFrame(Thread) \ + (PKEXCEPTION_FRAME)((ULONG_PTR)KeGetTrapFrame(Thread) - \ + sizeof(KEXCEPTION_FRAME)) + +// +// Returns the Interrupt State from a Trap Frame. +// ON = TRUE, OFF = FALSE +// +#define KeGetTrapFrameInterruptState(TrapFrame) \ + BooleanFlagOn((TrapFrame)->EFlags, EFLAGS_INTERRUPT_MASK) + +// +// Invalidates the TLB entry for a specified address +// +FORCEINLINE +VOID +KeInvalidateTlbEntry(IN PVOID Address) +{ + /* Invalidate the TLB entry for this address */ + __invlpg(Address); +} + +FORCEINLINE +VOID +KeFlushProcessTb(VOID) +{ + /* Flush the TLB by resetting CR3 */ + __writecr3(__readcr3()); +} + +FORCEINLINE +VOID +KiRundownThread(IN PKTHREAD Thread) +{ +#ifndef CONFIG_SMP + DbgPrint("KiRundownThread is unimplemented\n"); +#else + /* Nothing to do */ +#endif +} + +VOID +FORCEINLINE +KiEndInterrupt(IN KIRQL Irql, + IN PKTRAP_FRAME TrapFrame) +{ + DbgPrint("KiEndInterrupt is unimplemented\n"); +} + +#define Ki386PerfEnd(x) + +struct _KPCR; + +VOID +FASTCALL +KiInitializeTss(IN PKTSS Tss, IN UINT64 Stack); + +VOID KiDivideErrorFault(); +VOID KiDebugTrapOrFault(); +VOID KiNmiInterrupt(); +VOID KiBreakpointTrap(); +VOID KiOverflowTrap(); +VOID KiBoundFault(); +VOID KiInvalidOpcodeFault(); +VOID KiNpxNotAvailableFault(); +VOID KiDoubleFaultAbort(); +VOID KiNpxSegmentOverrunAbort(); +VOID KiInvalidTssFault(); +VOID KiSegmentNotPresentFault(); +VOID KiStackFault(); +VOID KiGeneralProtectionFault(); +VOID KiPageFault(); +VOID KiFloatingErrorFault(); +VOID KiAlignmentFault(); +VOID KiMcheckAbort(); +VOID KiXmmException(); +VOID KiApcInterrupt(); +VOID KiRaiseAssertion(); +VOID KiDebugServiceTrap(); +VOID KiDpcInterrupt(); +VOID KiIpiInterrupt(); + +VOID +KiGdtPrepareForApplicationProcessorInit(ULONG Id); +VOID +Ki386InitializeLdt(VOID); +VOID +Ki386SetProcessorFeatures(VOID); + +VOID +NTAPI +KiGetCacheInformation(VOID); + +BOOLEAN +NTAPI +KiIsNpxPresent( + VOID +); + +BOOLEAN +NTAPI +KiIsNpxErrataPresent( + VOID +); + +VOID +NTAPI +KiSetProcessorType(VOID); + +ULONG +NTAPI +KiGetFeatureBits(VOID); + +VOID +NTAPI +KiInitializeCpuFeatures(); + +ULONG KeAllocateGdtSelector(ULONG Desc[2]); +VOID KeFreeGdtSelector(ULONG Entry); +VOID +NtEarlyInitVdm(VOID); +VOID +KeApplicationProcessorInitDispatcher(VOID); +VOID +KeCreateApplicationProcessorIdleThread(ULONG Id); + +VOID +NTAPI +Ke386InitThreadWithContext(PKTHREAD Thread, + PKSYSTEM_ROUTINE SystemRoutine, + PKSTART_ROUTINE StartRoutine, + PVOID StartContext, + PCONTEXT Context); +#define KeArchInitThreadWithContext(Thread,SystemRoutine,StartRoutine,StartContext,Context) \ + Ke386InitThreadWithContext(Thread,SystemRoutine,StartRoutine,StartContext,Context) + +#ifdef _NTOSKRNL_ /* FIXME: Move flags above to NDK instead of here */ +VOID +NTAPI +KiThreadStartup(PKSYSTEM_ROUTINE SystemRoutine, + PKSTART_ROUTINE StartRoutine, + PVOID StartContext, + BOOLEAN UserThread, + KTRAP_FRAME TrapFrame); +#endif + +#endif +#endif /* __NTOSKRNL_INCLUDE_INTERNAL_AMD64_KE_H */ + +/* EOF */ diff --git a/reactos/ntoskrnl/include/internal/amd64/mm.h b/reactos/ntoskrnl/include/internal/amd64/mm.h new file mode 100644 index 00000000000..6f0b2fd390c --- /dev/null +++ b/reactos/ntoskrnl/include/internal/amd64/mm.h @@ -0,0 +1,189 @@ +/* + * Lowlevel memory managment definitions + */ + +#pragma once + +/* Helper macros */ +#define PAGE_MASK(x) ((x)&(~0xfff)) +#define PAE_PAGE_MASK(x) ((x)&(~0xfffLL)) + +/* Memory layout base addresses */ +#define HYPER_SPACE 0xFFFFF70000000000ULL +#define HYPER_SPACE_END 0xFFFFF77FFFFFFFFFULL +#define MI_SESSION_SPACE_MINIMUM (PVOID)0xFFFFF90000000000ULL +#define MI_SESSION_VIEW_END (PVOID)0xFFFFF97FFF000000ULL +#define MI_SESSION_SPACE_END (PVOID)0xFFFFF98000000000ULL +#define MI_SYSTEM_PTE_START (PVOID)0xFFFFFAA000000000ULL +#define MI_PAGED_POOL_START (PVOID)0xFFFFFA8000000000ULL +#define MI_NON_PAGED_SYSTEM_START_MIN 0xFFFFFAA000000000ULL +#define MI_PFN_DATABASE (PVOID)0xFFFFFAC000000000ULL +#define MI_NONPAGED_POOL_END (PVOID)0xFFFFFAE000000000ULL +#define MI_DEBUG_MAPPING (PVOID)0xFFFFFFFF80000000ULL // FIXME +#define MI_HIGHEST_SYSTEM_ADDRESS (PVOID)0xFFFFFFFFFFFFFFFFULL +#define MI_SYSTEM_CACHE_WS_START (PVOID)0xFFFFF78000001000ULL // CHECKME + +/* Memory sizes */ +#define MI_MIN_PAGES_FOR_NONPAGED_POOL_TUNING ((255*1024*1024) >> PAGE_SHIFT) +#define MI_MIN_PAGES_FOR_SYSPTE_TUNING ((19*1024*1024) >> PAGE_SHIFT) +#define MI_MIN_PAGES_FOR_SYSPTE_BOOST ((32*1024*1024) >> PAGE_SHIFT) +#define MI_MAX_INIT_NONPAGED_POOL_SIZE (128ULL * 1024 * 1024 * 1024) +#define MI_MAX_NONPAGED_POOL_SIZE (128ULL * 1024 * 1024 * 1024) +#define MI_MAX_FREE_PAGE_LISTS 4 +#define MI_MIN_INIT_PAGED_POOLSIZE (32 * 1024 * 1024) +#define MI_SESSION_VIEW_SIZE (20 * 1024 * 1024) +#define MI_SESSION_POOL_SIZE (16 * 1024 * 1024) +#define MI_SESSION_IMAGE_SIZE (8 * 1024 * 1024) +#define MI_SESSION_WORKING_SET_SIZE (4 * 1024 * 1024) +#define MI_SESSION_SIZE (MI_SESSION_VIEW_SIZE + \ + MI_SESSION_POOL_SIZE + \ + MI_SESSION_IMAGE_SIZE + \ + MI_SESSION_WORKING_SET_SIZE) +#define MI_SYSTEM_VIEW_SIZE (16 * 1024 * 1024) +#define MI_NUMBER_SYSTEM_PTES 22000 + +PULONG64 +FORCEINLINE +MmGetPageDirectory(VOID) +{ + return (PULONG64)__readcr3(); +} + +PMMPTE +FORCEINLINE +MiAddressToPxe(PVOID Address) +{ + ULONG64 Offset = (ULONG64)Address >> (PXI_SHIFT - 3); + Offset &= PXI_MASK << 3; + return (PMMPTE)(PXE_BASE + Offset); +} + +PMMPTE +FORCEINLINE +MiAddressToPpe(PVOID Address) +{ + ULONG64 Offset = (ULONG64)Address >> (PPI_SHIFT - 3); + Offset &= 0x3FFFF << 3; + return (PMMPTE)(PPE_BASE + Offset); +} + +PMMPTE +FORCEINLINE +_MiAddressToPde(PVOID Address) +{ + ULONG64 Offset = (ULONG64)Address >> (PDI_SHIFT - 3); + Offset &= 0x7FFFFFF << 3; + return (PMMPTE)(PDE_BASE + Offset); +} +#define MiAddressToPde(x) _MiAddressToPde((PVOID)(x)) + +PMMPTE +FORCEINLINE +_MiAddressToPte(PVOID Address) +{ + ULONG64 Offset = (ULONG64)Address >> (PTI_SHIFT - 3); + Offset &= 0xFFFFFFFFFULL << 3; + return (PMMPTE)(PTE_BASE + Offset); +} +#define MiAddressToPte(x) _MiAddressToPte((PVOID)(x)) + +/* Convert a PTE into a corresponding address */ +PVOID +FORCEINLINE +MiPteToAddress(PMMPTE Pte) +{ + /* Use signed math */ + LONG64 Temp = (LONG64)Pte; + Temp <<= 25; + Temp >>= 16; + return (PVOID)Temp; +} + +BOOLEAN +FORCEINLINE +MiIsPdeForAddressValid(PVOID Address) +{ + return ((MiAddressToPxe(Address)->u.Hard.Valid) && + (MiAddressToPpe(Address)->u.Hard.Valid) && + (MiAddressToPde(Address)->u.Hard.Valid)); +} + +#define ADDR_TO_PAGE_TABLE(v) (((ULONG_PTR)(v)) / (512 * PAGE_SIZE)) +#define ADDR_TO_PDE_OFFSET(v) ((((ULONG_PTR)(v)) / (512 * PAGE_SIZE))) +#define ADDR_TO_PTE_OFFSET(v) ((((ULONG_PTR)(v)) % (512 * PAGE_SIZE)) / PAGE_SIZE) + +#define VAtoPXI(va) ((((ULONG64)va) >> PXI_SHIFT) & 0x1FF) +#define VAtoPPI(va) ((((ULONG64)va) >> PPI_SHIFT) & 0x1FF) +#define VAtoPDI(va) ((((ULONG64)va) >> PDI_SHIFT) & 0x1FF) +#define VAtoPTI(va) ((((ULONG64)va) >> PTI_SHIFT) & 0x1FF) + +/* We don't use these hacks */ +VOID +FORCEINLINE +MmUpdatePageDir(PEPROCESS Process, PVOID Address, ULONG Size) +{ + /* Nothing to do */ +} + +VOID +FORCEINLINE +MmInitGlobalKernelPageDirectory(VOID) +{ + /* Nothing to do */ +} + +#define IS_ALIGNED(addr, align) (((ULONG64)(addr) & (align - 1)) == 0) +#define IS_PAGE_ALIGNED(addr) IS_ALIGNED(addr, PAGE_SIZE) + +/* Easy accessing PFN in PTE */ +#define PFN_FROM_PTE(v) ((v)->u.Hard.PageFrameNumber) + +// FIXME, only copied from x86 +#define MI_MAKE_LOCAL_PAGE(x) ((x)->u.Hard.Global = 0) +#define MI_MAKE_DIRTY_PAGE(x) ((x)->u.Hard.Dirty = 1) +#define MI_PAGE_DISABLE_CACHE(x) ((x)->u.Hard.CacheDisable = 1) +#define MI_PAGE_WRITE_THROUGH(x) ((x)->u.Hard.WriteThrough = 1) +#define MI_PAGE_WRITE_COMBINED(x) ((x)->u.Hard.WriteThrough = 0) +#if !defined(CONFIG_SMP) +#define MI_IS_PAGE_WRITEABLE(x) ((x)->u.Hard.Write == 1) +#else +#define MI_IS_PAGE_WRITEABLE(x) ((x)->u.Hard.Writable == 1) +#endif +#define MI_IS_PAGE_COPY_ON_WRITE(x)((x)->u.Hard.CopyOnWrite == 1) +#define MI_IS_PAGE_DIRTY(x) ((x)->u.Hard.Dirty == 1) +#define MI_MAKE_OWNER_PAGE(x) ((x)->u.Hard.Owner = 1) +#if !defined(CONFIG_SMP) +#define MI_MAKE_WRITE_PAGE(x) ((x)->u.Hard.Write = 1) +#else +#define MI_MAKE_WRITE_PAGE(x) ((x)->u.Hard.Writable = 1) +#endif + +// FIXME!!! +#define PAGE_TO_SECTION_PAGE_DIRECTORY_OFFSET(x) \ + ((x) / (4*1024*1024)) + +#define PAGE_TO_SECTION_PAGE_TABLE_OFFSET(x) \ + ((((x)) % (4*1024*1024)) / (4*1024)) + +#define NR_SECTION_PAGE_TABLES 1024 +#define NR_SECTION_PAGE_ENTRIES 1024 + +//#define TEB_BASE 0x7FFDE000 + +#define MI_HYPERSPACE_PTES (256 - 1) +#define MI_ZERO_PTES (32) +#define MI_MAPPING_RANGE_START (ULONG)HYPER_SPACE +#define MI_MAPPING_RANGE_END (MI_MAPPING_RANGE_START + \ + MI_HYPERSPACE_PTES * PAGE_SIZE) +#define MI_ZERO_PTE (PMMPTE)(MI_MAPPING_RANGE_END + \ + PAGE_SIZE) + +/* On x86, these two are the same */ +#define MMPDE MMPTE +#define PMMPDE PMMPTE + +/* +* FIXME - different architectures have different cache line sizes... +*/ +#define MM_CACHE_LINE_SIZE 32 + diff --git a/reactos/ntoskrnl/include/internal/arch/intrin_i.h b/reactos/ntoskrnl/include/internal/arch/intrin_i.h index f8ce285678c..7d6dfab3557 100644 --- a/reactos/ntoskrnl/include/internal/arch/intrin_i.h +++ b/reactos/ntoskrnl/include/internal/arch/intrin_i.h @@ -27,6 +27,8 @@ #include "../mips/intrin_i.h" #elif defined(_M_ARM) #include "../arm/intrin_i.h" +#elif defined(_M_AMD64) +#include "../amd64/intrin_i.h" #else #error "Unknown processor" #endif diff --git a/reactos/ntoskrnl/include/internal/arch/ke.h b/reactos/ntoskrnl/include/internal/arch/ke.h index ef8a27bd951..3e1b8a5b290 100644 --- a/reactos/ntoskrnl/include/internal/arch/ke.h +++ b/reactos/ntoskrnl/include/internal/arch/ke.h @@ -27,6 +27,8 @@ #include "../mips/ke.h" #elif defined(_M_ARM) #include "../arm/ke.h" +#elif defined(_M_AMD64) +#include "../amd64/ke.h" #else #error "Unknown processor" #endif diff --git a/reactos/ntoskrnl/include/internal/arch/mm.h b/reactos/ntoskrnl/include/internal/arch/mm.h index a2a97919259..f5ee0276ca2 100644 --- a/reactos/ntoskrnl/include/internal/arch/mm.h +++ b/reactos/ntoskrnl/include/internal/arch/mm.h @@ -27,6 +27,8 @@ #include #elif defined(_M_ARM) #include +#elif defined(_M_AMD64) +#include #else #error "Unknown processor" #endif From 1d4dbb9cb7a713954b5b2ef9534fe63e31798b21 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Wed, 31 Mar 2010 15:19:01 +0000 Subject: [PATCH 125/134] [KDCOM] Include ntifs, instead of ntddk, needed by NDK svn path=/trunk/; revision=46621 --- reactos/drivers/base/kddll/kddll.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactos/drivers/base/kddll/kddll.h b/reactos/drivers/base/kddll/kddll.h index 76330922fc4..abbd6d31d44 100644 --- a/reactos/drivers/base/kddll/kddll.h +++ b/reactos/drivers/base/kddll/kddll.h @@ -9,7 +9,7 @@ #pragma once #define NOEXTAPI -#include +#include #define NDEBUG #include #include From af6dcb5bf03b56ab6a015cbda9719753e075591b Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Wed, 31 Mar 2010 15:37:36 +0000 Subject: [PATCH 126/134] [BDASUP] - Fix initialization of filter / pin automation table - Add debug traces svn path=/trunk/; revision=46622 --- reactos/drivers/multimedia/bdasup/bdasup.c | 59 +++++++++++++++++++--- 1 file changed, 53 insertions(+), 6 deletions(-) diff --git a/reactos/drivers/multimedia/bdasup/bdasup.c b/reactos/drivers/multimedia/bdasup/bdasup.c index 82a357ae5ce..f2589c18b34 100644 --- a/reactos/drivers/multimedia/bdasup/bdasup.c +++ b/reactos/drivers/multimedia/bdasup/bdasup.c @@ -52,13 +52,13 @@ KSMETHOD_SET FilterMethodSet = KSAUTOMATION_TABLE FilterAutomationTable = { 1, - sizeof(KSPROPERTY_SET), + sizeof(KSPROPERTY_ITEM), &FilterPropertySet, 1, - sizeof(KSMETHOD_SET), + sizeof(KSMETHOD_ITEM), &FilterMethodSet, 0, - sizeof(KSEVENT_SET), + sizeof(KSEVENT_ITEM), NULL }; @@ -80,13 +80,13 @@ KSPROPERTY_SET PinPropertySet = KSAUTOMATION_TABLE PinAutomationTable = { 1, - sizeof(KSPROPERTY_SET), + sizeof(KSPROPERTY_ITEM), &PinPropertySet, 0, - sizeof(KSMETHOD_SET), + sizeof(KSMETHOD_ITEM), NULL, 0, - sizeof(KSEVENT_SET), + sizeof(KSEVENT_ITEM), NULL }; @@ -157,6 +157,8 @@ NTAPI DllInitialize( PUNICODE_STRING RegistryPath) { + DPRINT("BDASUP::DllInitialize\n"); + KeInitializeSpinLock(&g_Settings.FilterFactoryInstanceListLock); InitializeListHead(&g_Settings.FilterFactoryInstanceList); g_Settings.Initialized = TRUE; @@ -171,6 +173,8 @@ NTSTATUS NTAPI BdaCheckChanges(IN PIRP Irp) { + DPRINT("BdaCheckChanges\n"); + if (!Irp) return STATUS_INVALID_PARAMETER; @@ -184,6 +188,8 @@ NTSTATUS NTAPI BdaCommitChanges(IN PIRP Irp) { + DPRINT("BdaCommitChanges\n"); + if (!Irp) return STATUS_INVALID_PARAMETER; @@ -257,6 +263,7 @@ BdaCreateFilterFactoryEx( NTSTATUS Status; KSFILTER_DESCRIPTOR FilterDescriptor; + DPRINT("BdaCreateFilterFactoryEx\n"); /* backup filter descriptor */ RtlMoveMemory(&FilterDescriptor, pFilterDescriptor, sizeof(KSFILTER_DESCRIPTOR)); @@ -265,7 +272,10 @@ BdaCreateFilterFactoryEx( /* check for success */ if (!NT_SUCCESS(Status)) + { + DPRINT1("KsMergeAutomationTables failed with %lx\n", Status); return Status; + } /* allocate filter instance */ FilterInstance = AllocateItem(NonPagedPool, sizeof(BDA_FILTER_INSTANCE_ENTRY)); @@ -287,6 +297,7 @@ BdaCreateFilterFactoryEx( if (!NT_SUCCESS(Status)) { /* destroy filter instance */ + DPRINT1("KsAddItemToObjectBag failed with %lx\n", Status); FreeItem(FilterInstance); KsDeleteFilterFactory(FilterFactory); return Status; @@ -316,9 +327,11 @@ BdaCreateFilterFactoryEx( { /* failed to create filter factory */ FreeItem(FilterInstance); + DPRINT1("KsCreateFilterFactory failed with %lx\n", Status); } /* done */ + DPRINT("BdaCreateFilterFactoryEx Status %x\n", Status); return Status; } @@ -339,6 +352,8 @@ BdaCreatePin( ULONG PinId; KSPIN_DESCRIPTOR_EX NewPinDescriptor; + DPRINT("BdaCreatePin\n"); + if (!pulPinId || !pKSFilter) return STATUS_INVALID_PARAMETER; @@ -419,6 +434,8 @@ BdaMethodCreatePin( PKSM_PIN Pin; PKSFILTER Filter; + DPRINT("BdaMethodCreatePin\n"); + if (!Irp) { /* invalid parameter */ @@ -453,6 +470,8 @@ BdaInitFilter( ULONG Index, PinId; NTSTATUS Status = STATUS_SUCCESS; + DPRINT("BdaInitFilter\n"); + /* check input parameters */ if (!pKSFilter) return STATUS_INVALID_PARAMETER; @@ -501,6 +520,8 @@ BdaCreateTopology( PKSFILTERFACTORY FilterFactory; KSTOPOLOGY_CONNECTION Connection; + DPRINT("BdaCreateTopology\n"); + /* check input parameters */ if (!pKSFilter) return STATUS_INVALID_PARAMETER; @@ -547,6 +568,7 @@ BdaDeletePin( IN ULONG *pulPinId) { UNIMPLEMENTED + DPRINT("BdaDeletePin\n"); return STATUS_NOT_IMPLEMENTED; } @@ -559,6 +581,7 @@ BdaFilterFactoryUpdateCacheData( IN PKSFILTERFACTORY FilterFactory, IN const KSFILTER_DESCRIPTOR *FilterDescriptor OPTIONAL) { + DPRINT("BdaFilterFactoryUpdateCacheData\n"); return KsFilterFactoryUpdateCacheData(FilterFactory, FilterDescriptor); } @@ -571,6 +594,8 @@ BdaGetChangeState( IN PIRP Irp, OUT BDA_CHANGE_STATE *ChangeState) { + DPRINT("BdaGetChangeState\n"); + if (Irp && ChangeState) { *ChangeState = BDA_CHANGES_COMPLETE; @@ -595,6 +620,8 @@ BdaMethodCreateTopology( PKSFILTER Filter; PKSP_BDA_NODE_PIN Node; + DPRINT("BdaMethodCreateTopology\n"); + /* check input parameters */ if (!Irp || !pKSMethod) return STATUS_INVALID_PARAMETER; @@ -622,6 +649,8 @@ BdaMethodDeletePin( IN KSMETHOD *pKSMethod, OPTIONAL PVOID pvIgnored) { + DPRINT("BdaMethodDeletePin\n"); + if (!Irp) return STATUS_INVALID_PARAMETER; @@ -639,6 +668,7 @@ BdaPropertyGetControllingPinId( OUT ULONG *pulControllingPinId) { UNIMPLEMENTED + DPRINT("BdaPropertyGetControllingPinId\n"); return STATUS_NOT_IMPLEMENTED; } @@ -657,6 +687,8 @@ BdaPropertyGetPinControl( PKSFILTERFACTORY FilterFactory; PBDA_FILTER_INSTANCE_ENTRY InstanceEntry; + DPRINT("BdaPropertyGetPinControl\n"); + /* first get the pin */ Pin = KsGetPinFromIrp(Irp); ASSERT(Pin); @@ -694,6 +726,7 @@ BdaPropertyNodeDescriptors( OUT BDANODE_DESCRIPTOR *pNodeDescriptorProperty) { UNIMPLEMENTED + DPRINT("BdaPropertyNodeDescriptors\n"); return STATUS_NOT_IMPLEMENTED; } @@ -708,6 +741,7 @@ BdaPropertyNodeEvents( OUT GUID *pguidProperty) { UNIMPLEMENTED + DPRINT("BdaPropertyNodeEvents\n"); return STATUS_NOT_IMPLEMENTED; } @@ -722,6 +756,7 @@ BdaPropertyNodeMethods( OUT GUID *pguidProperty) { UNIMPLEMENTED + DPRINT("BdaPropertyNodeMethods\n"); return STATUS_NOT_IMPLEMENTED; } @@ -736,6 +771,7 @@ BdaPropertyNodeProperties( OUT GUID *pguidProperty) { UNIMPLEMENTED + DPRINT("BdaPropertyNodeProperties\n"); return STATUS_NOT_IMPLEMENTED; } @@ -755,6 +791,8 @@ BdaPropertyNodeTypes( PIO_STACK_LOCATION IoStack; ULONG Index; + DPRINT("BdaPropertyNodeTypes\n"); + /* check input parameter */ if (!Irp || !pKSProperty) return STATUS_INVALID_PARAMETER; @@ -821,6 +859,8 @@ BdaPropertyPinTypes( PIO_STACK_LOCATION IoStack; ULONG Index; + DPRINT("BdaPropertyPinTypes\n"); + /* check input parameter */ if (!Irp || !pKSProperty) return STATUS_INVALID_PARAMETER; @@ -886,6 +926,8 @@ BdaPropertyTemplateConnections( PIO_STACK_LOCATION IoStack; ULONG Index; + DPRINT("BdaPropertyTemplateConnections\n"); + /* validate parameters */ if (!Irp || !pKSProperty) return STATUS_INVALID_PARAMETER; @@ -941,6 +983,8 @@ NTSTATUS NTAPI BdaStartChanges(IN PIRP Irp) { + DPRINT("BdaStartChanges\n"); + if (Irp) return STATUS_SUCCESS; else @@ -955,6 +999,7 @@ NTSTATUS NTAPI BdaUninitFilter(IN PKSFILTER pKSFilter) { + DPRINT("BdaUninitFilter\n"); return STATUS_SUCCESS; } @@ -967,6 +1012,8 @@ BdaValidateNodeProperty( IN PIRP Irp, IN KSPROPERTY *KSProperty) { + DPRINT("BdaValidateNodeProperty\n"); + /* check for valid parameter */ if (Irp && KSProperty) return STATUS_SUCCESS; From 9974fe1a9c7bfd55b28125c8e1c20413451bb484 Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Wed, 31 Mar 2010 16:12:02 +0000 Subject: [PATCH 127/134] [KS] - Fix a malicous bug in KsAddItemToObjectBag which caused inifite loops while iterating through object bags - Use a different mutex than the device mutex for object bags - Initialize device / object bag mutex when initializing the device - Initialize object bag lists when initializing the device - Set device / system power state before calling device Add's routine - Check if object driver extension has already been allocated in KsInitializeDevice - Hack KsFilterFactoryUpdateCacheData to return STATUS_SUCCESS - PinnacleSys PCTV DVB-T tv tuner now successfully initializes and registers its device interfaces svn path=/trunk/; revision=46623 --- reactos/drivers/ksfilter/ks/bag.c | 2 +- reactos/drivers/ksfilter/ks/device.c | 124 +++++++++++++++----- reactos/drivers/ksfilter/ks/driver.c | 19 ++- reactos/drivers/ksfilter/ks/filterfactory.c | 5 +- reactos/drivers/ksfilter/ks/kcom.c | 2 +- reactos/drivers/ksfilter/ks/kstypes.h | 2 +- reactos/drivers/ksfilter/ks/misc.c | 2 +- 7 files changed, 115 insertions(+), 41 deletions(-) diff --git a/reactos/drivers/ksfilter/ks/bag.c b/reactos/drivers/ksfilter/ks/bag.c index ec352d25dbe..1b7eec9bc5e 100644 --- a/reactos/drivers/ksfilter/ks/bag.c +++ b/reactos/drivers/ksfilter/ks/bag.c @@ -127,7 +127,7 @@ KsAddItemToObjectBag( BagEntry->Free = ExFreePool; /* insert item */ - InsertTailList(&Bag->ObjectList, &Bag->Entry); + InsertTailList(&Bag->ObjectList, &BagEntry->Entry); /* release mutex */ KeReleaseMutex(Bag->BagMutex, FALSE); diff --git a/reactos/drivers/ksfilter/ks/device.c b/reactos/drivers/ksfilter/ks/device.c index c5c5d26e818..7f2c082b440 100644 --- a/reactos/drivers/ksfilter/ks/device.c +++ b/reactos/drivers/ksfilter/ks/device.c @@ -74,7 +74,7 @@ IKsDevice_fnInitializeObjectBag( if (!Mutex) { /* use device mutex */ - Mutex = &This->DeviceMutex; + Mutex = &This->BagMutex; } /* initialize object bag */ @@ -220,12 +220,10 @@ IKsDevice_PnpPostStart( PPNP_POSTSTART_CONTEXT Ctx = (PPNP_POSTSTART_CONTEXT)Context; /* call driver pnp post routine */ - Status = Ctx->DeviceHeader->Descriptor->Dispatch->PostStart(&Ctx->DeviceHeader->KsDevice); + Status = Ctx->DeviceHeader->KsDevice.Descriptor->Dispatch->PostStart(&Ctx->DeviceHeader->KsDevice); if (!NT_SUCCESS(Status)) { - DPRINT1("Driver: PostStart Routine returned %x\n", Status); - /* set state to disabled */ Ctx->DeviceHeader->TargetState = KSTARGET_STATE_DISABLED; } @@ -240,6 +238,8 @@ IKsDevice_PnpPostStart( /* free work context */ FreeItem(Ctx); + + DPRINT("IKsDevice_PnpPostStart: PostStart Routine returned %x\n", Status); } NTSTATUS @@ -253,6 +253,10 @@ IKsDevice_PnpStartDevice( PKSIDEVICE_HEADER DeviceHeader; PPNP_POSTSTART_CONTEXT Ctx = NULL; NTSTATUS Status; + PCM_RESOURCE_LIST TranslatedResourceList; + PCM_RESOURCE_LIST UntranslatedResourceList; + PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor, UnPartialDescriptor; + ULONG Index; /* get current stack location */ IoStack = IoGetCurrentIrpStackLocation(Irp); @@ -261,6 +265,8 @@ IKsDevice_PnpStartDevice( /* get device header */ DeviceHeader = DeviceExtension->DeviceHeader; + DPRINT("IKsDevice_PnpStartDevice DeviceHeader %p\n", DeviceHeader); + /* first forward irp to lower device object */ Status = KspForwardIrpSynchronous(DeviceObject, Irp); @@ -273,20 +279,55 @@ IKsDevice_PnpStartDevice( return Status; } + TranslatedResourceList = IoStack->Parameters.StartDevice.AllocatedResourcesTranslated; + UntranslatedResourceList = IoStack->Parameters.StartDevice.AllocatedResources; + + DPRINT("ResourceDescriptorCount %lu\n", TranslatedResourceList->List[0].PartialResourceList.Count); + for (Index = 0; Index < TranslatedResourceList->List[0].PartialResourceList.Count; Index ++ ) + { + PartialDescriptor = &TranslatedResourceList->List[0].PartialResourceList.PartialDescriptors[Index]; + UnPartialDescriptor = &UntranslatedResourceList->List[0].PartialResourceList.PartialDescriptors[Index]; + DPRINT("Descriptor Type %u\n", PartialDescriptor->Type); + + if (PartialDescriptor->Type == CmResourceTypeInterrupt) + { + DPRINT("CmResourceTypeInterrupt Index %u TRANS Interrupt Number Affinity %x Level %u Vector %u Flags %x Share %x\n", Index, PartialDescriptor->u.Interrupt.Affinity, PartialDescriptor->u.Interrupt.Level, PartialDescriptor->u.Interrupt.Vector, PartialDescriptor->Flags, PartialDescriptor->ShareDisposition); + DPRINT("CmResourceTypeInterrupt Index %u UNTRANS Interrupt Number Affinity %x Level %u Vector %u Flags %x Share %x\\n", Index, UnPartialDescriptor->u.Interrupt.Affinity, UnPartialDescriptor->u.Interrupt.Level, UnPartialDescriptor->u.Interrupt.Vector, UnPartialDescriptor->Flags, UnPartialDescriptor->ShareDisposition); + + } + else if (PartialDescriptor->Type == CmResourceTypePort) + { + DPRINT("CmResourceTypePort Index %u TRANS Port Length %u Start %u %u Flags %x Share %x\n", Index, PartialDescriptor->u.Port.Length, PartialDescriptor->u.Port.Start.HighPart, PartialDescriptor->u.Port.Start.LowPart, PartialDescriptor->Flags, PartialDescriptor->ShareDisposition); + DPRINT("CmResourceTypePort Index %u UNTRANS Port Length %u Start %u %u Flags %x Share %x\n", Index, UnPartialDescriptor->u.Port.Length, UnPartialDescriptor->u.Port.Start.HighPart, UnPartialDescriptor->u.Port.Start.LowPart, UnPartialDescriptor->Flags, UnPartialDescriptor->ShareDisposition); + } + else if (PartialDescriptor->Type == CmResourceTypeMemory) + { + DPRINT("CmResourceTypeMemory Index %u TRANS Start %x Length %u Flags %x Share %x\n", Index, PartialDescriptor->u.Memory.Start.LowPart, PartialDescriptor->u.Memory.Length, PartialDescriptor->Flags, PartialDescriptor->ShareDisposition); + DPRINT("CmResourceTypeMemory Index %u TRANS Start %x Length %u Flags %x Share %x\n", Index, UnPartialDescriptor->u.Memory.Start.LowPart, UnPartialDescriptor->u.Memory.Length, UnPartialDescriptor->Flags, UnPartialDescriptor->ShareDisposition); + } + } + + ASSERT(DeviceHeader->KsDevice.Descriptor); + ASSERT(DeviceHeader->KsDevice.Descriptor->Dispatch); + ASSERT(DeviceHeader->KsDevice.Descriptor->Dispatch->Start); + + /* do we have a device descriptor */ - if (DeviceHeader->Descriptor) + if (DeviceHeader->KsDevice.Descriptor) { /* does the device want pnp notifications */ - if (DeviceHeader->Descriptor->Dispatch) + if (DeviceHeader->KsDevice.Descriptor->Dispatch) { /* does the driver care about IRP_MN_START_DEVICE */ - if (DeviceHeader->Descriptor->Dispatch->Start) + if (DeviceHeader->KsDevice.Descriptor->Dispatch->Start) { /* call driver start device routine */ - Status = DeviceHeader->Descriptor->Dispatch->Start(&DeviceHeader->KsDevice, Irp, - IoStack->Parameters.StartDevice.AllocatedResourcesTranslated, - IoStack->Parameters.StartDevice.AllocatedResources); + Status = DeviceHeader->KsDevice.Descriptor->Dispatch->Start(&DeviceHeader->KsDevice, Irp, + TranslatedResourceList, + UntranslatedResourceList); + + DPRINT("IKsDevice_PnpStartDevice Start %p, Context %p\n", DeviceHeader->KsDevice.Descriptor->Dispatch->Start, DeviceHeader->KsDevice.Context); ASSERT(Status != STATUS_PENDING); if (!NT_SUCCESS(Status)) @@ -303,7 +344,7 @@ IKsDevice_PnpStartDevice( } /* does the driver need post start routine */ - if (DeviceHeader->Descriptor->Dispatch->PostStart) + if (DeviceHeader->KsDevice.Descriptor->Dispatch->PostStart) { /* allocate pnp post workitem context */ Ctx = (PPNP_POSTSTART_CONTEXT)AllocateItem(NonPagedPool, sizeof(PNP_POSTSTART_CONTEXT)); @@ -351,6 +392,7 @@ IKsDevice_PnpStartDevice( } /* return result */ + DPRINT1("IKsDevice_PnpStartDevice Status %x PostStartRoutine %p\n", Status, Ctx); return Status; } @@ -375,10 +417,10 @@ IKsDevice_Pnp( DeviceHeader = DeviceExtension->DeviceHeader; /* do we have a device descriptor */ - if (DeviceHeader->Descriptor) + if (DeviceHeader->KsDevice.Descriptor && DeviceHeader->KsDevice.Descriptor->Dispatch) { /* does the device want pnp notifications */ - Dispatch = (PKSDEVICE_DISPATCH)DeviceHeader->Descriptor->Dispatch; + Dispatch = (PKSDEVICE_DISPATCH)DeviceHeader->KsDevice.Descriptor->Dispatch; } switch (IoStack->MinorFunction) @@ -472,7 +514,7 @@ IKsDevice_Pnp( /* pass the irp down the driver stack */ Status = KspForwardIrpSynchronous(DeviceObject, Irp); - DPRINT("Next Device: Status %x\n", Status); + DPRINT1("IRP_MN_QUERY_INTERFACE Next Device: Status %x\n", Status); Irp->IoStatus.Status = Status; IoCompleteRequest(Irp, IO_NO_INCREMENT); @@ -480,36 +522,32 @@ IKsDevice_Pnp( } case IRP_MN_QUERY_DEVICE_RELATIONS: { - DPRINT("IRP_MN_QUERY_DEVICE_RELATIONS\n"); - /* pass the irp down the driver stack */ Status = KspForwardIrpSynchronous(DeviceObject, Irp); - DPRINT("Next Device: Status %x\n", Status); + DPRINT("IRP_MN_QUERY_DEVICE_RELATIONS Next Device: Status %x\n", Status); - Irp->IoStatus.Status = Status; + //Irp->IoStatus.Status = Status; IoCompleteRequest(Irp, IO_NO_INCREMENT); return Status; } case IRP_MN_FILTER_RESOURCE_REQUIREMENTS: { - DPRINT("IRP_MN_FILTER_RESOURCE_REQUIREMENTS\n"); /* pass the irp down the driver stack */ - Status = KspForwardIrpSynchronous(DeviceObject, Irp); + //Status = KspForwardIrpSynchronous(DeviceObject, Irp); + Status = Irp->IoStatus.Status; + DPRINT("IRP_MN_FILTER_RESOURCE_REQUIREMENTS Next Device: Status %x\n", Status); - DPRINT("Next Device: Status %x\n", Status); - - Irp->IoStatus.Status = Status; + //Irp->IoStatus.Status = Status; IoCompleteRequest(Irp, IO_NO_INCREMENT); return Status; } case IRP_MN_QUERY_RESOURCE_REQUIREMENTS: { - DPRINT("IRP_MN_QUERY_RESOURCE_REQUIREMENTS\n"); /* pass the irp down the driver stack */ Status = KspForwardIrpSynchronous(DeviceObject, Irp); - DPRINT("Next Device: Status %x\n", Status); + DPRINT("IRP_MN_QUERY_RESOURCE_REQUIREMENTS Next Device: Status %x\n", Status); Irp->IoStatus.Status = Status; IoCompleteRequest(Irp, IO_NO_INCREMENT); @@ -552,7 +590,7 @@ IKsDevice_Create( PKSIOBJECT_HEADER ObjectHeader; NTSTATUS Status; - DPRINT("KS / CREATE\n"); + DPRINT("IKsDevice_Create\n"); /* get current stack location */ IoStack = IoGetCurrentIrpStackLocation(Irp); /* get device extension */ @@ -630,9 +668,11 @@ KsInitializeDevice( PDEVICE_EXTENSION DeviceExtension; PKSIDEVICE_HEADER Header; ULONG Index; - IKsDevice * KsDevice; + PKSIOBJECT_BAG Bag; NTSTATUS Status = STATUS_SUCCESS; + DPRINT("KsInitializeDevice Descriptor %p\n", Descriptor); + /* get device extension */ DeviceExtension = (PDEVICE_EXTENSION)FunctionalDeviceObject->DeviceExtension; @@ -642,10 +682,13 @@ KsInitializeDevice( /* point to allocated header */ Header = DeviceExtension->DeviceHeader; + DPRINT("DeviceHeader %p\n", DeviceExtension->DeviceHeader); + + /* check for success */ if (!NT_SUCCESS(Status)) { - DPRINT1("Failed to allocate device header with %x\n", Status); + DPRINT1("KsInitializeDevice Failed to allocate device header with %x\n", Status); return Status; } @@ -653,7 +696,7 @@ KsInitializeDevice( Header->lpVtblIKsDevice = &vt_IKsDevice; Header->ref = 1; - /* initialize object bag */ + /* allocate object bag */ Header->KsDevice.Bag = AllocateItem(NonPagedPool, sizeof(KSIOBJECT_BAG)); if (!Header->KsDevice.Bag) { @@ -662,25 +705,41 @@ KsInitializeDevice( return STATUS_INSUFFICIENT_RESOURCES; } - KsDevice = (IKsDevice*)&DeviceExtension->DeviceHeader->lpVtblIKsDevice; - KsDevice->lpVtbl->InitializeObjectBag(KsDevice, Header->KsDevice.Bag, NULL); + /* initialize object bag */ + KeInitializeMutex(&Header->BagMutex, 0); + KeInitializeMutex(&Header->DeviceMutex, 0); + Bag = (PKSIOBJECT_BAG)Header->KsDevice.Bag; + Bag->BagMutex = &Header->BagMutex; + InitializeListHead(&Header->ObjectBags); + InitializeListHead(&Bag->ObjectList); + Bag->DeviceHeader = (PVOID)Header; + + /* insert bag into device list */ + InsertTailList(&Header->ObjectBags, &Bag->Entry); /* initialize device header */ Header->KsDevice.FunctionalDeviceObject = FunctionalDeviceObject; Header->KsDevice.PhysicalDeviceObject = PhysicalDeviceObject; Header->KsDevice.NextDeviceObject = NextDeviceObject; Header->KsDevice.Descriptor = Descriptor; + Header->KsDevice.SystemPowerState = PowerSystemWorking; + Header->KsDevice.DevicePowerState = PowerDeviceD0; + Header->KsDevice.Started = FALSE; + Header->KsDevice.Context = NULL; KsSetDevicePnpAndBaseObject(Header, PhysicalDeviceObject, NextDeviceObject); - /* FIXME Power state */ + if (Descriptor) { /* create a filter factory for each filter descriptor */ + DPRINT("KsInitializeDevice FilterDescriptorCount %lu\n", Descriptor->FilterDescriptorsCount); for(Index = 0; Index < Descriptor->FilterDescriptorsCount; Index++) { Status = KspCreateFilterFactory(FunctionalDeviceObject, Descriptor->FilterDescriptors[Index], NULL, NULL, 0, NULL, NULL, NULL); + + DPRINT("KsInitializeDevice Index %lu KspCreateFilterFactory Status %lx\n", Index, Status); /* check for success */ if (!NT_SUCCESS(Status)) { @@ -697,6 +756,7 @@ KsInitializeDevice( Status = Descriptor->Dispatch->Add(&Header->KsDevice); DPRINT("Driver: AddHandler Status %x\n", Status); + Header->KsDevice.Descriptor = Descriptor; } } diff --git a/reactos/drivers/ksfilter/ks/driver.c b/reactos/drivers/ksfilter/ks/driver.c index ac287093447..f6ace30b2bb 100644 --- a/reactos/drivers/ksfilter/ks/driver.c +++ b/reactos/drivers/ksfilter/ks/driver.c @@ -39,6 +39,8 @@ KsGetDevice( { PKSBASIC_HEADER BasicHeader = (PKSBASIC_HEADER)(ULONG_PTR)Object - sizeof(KSBASIC_HEADER); + DPRINT("KsGetDevice %p\n", Object); + ASSERT(BasicHeader->Type == KsObjectTypeFilterFactory || BasicHeader->Type == KsObjectTypeFilter || BasicHeader->Type == BasicHeader->Type); return BasicHeader->KsDevice; @@ -63,6 +65,8 @@ KsCreateDevice( if (!ExtensionSize) ExtensionSize = sizeof(KSDEVICE_HEADER); + DPRINT("KsCreateDevice Descriptor %p ExtensionSize %lu\n", Descriptor, ExtensionSize); + Status = IoCreateDevice(DriverObject, ExtensionSize, NULL, FILE_DEVICE_KS, FILE_DEVICE_SECURE_OPEN, FALSE, &FunctionalDeviceObject); if (!NT_SUCCESS(Status)) return Status; @@ -120,7 +124,8 @@ KsAddDevice( const KSDEVICE_DESCRIPTOR *Descriptor = NULL; /* get stored driver object extension */ - DriverObjectExtension = IoGetDriverObjectExtension(DriverObject, (PVOID)KsAddDevice); + + DriverObjectExtension = IoGetDriverObjectExtension(DriverObject, (PVOID)KsInitializeDriver); if (DriverObjectExtension) { @@ -144,17 +149,23 @@ KsInitializeDriver( ) { PKS_DRIVER_EXTENSION DriverObjectExtension; - NTSTATUS Status; + NTSTATUS Status = STATUS_SUCCESS; if (Descriptor) { - Status = IoAllocateDriverObjectExtension(DriverObject, (PVOID)KsAddDevice, sizeof(KS_DRIVER_EXTENSION), (PVOID*)&DriverObjectExtension); + Status = IoAllocateDriverObjectExtension(DriverObject, (PVOID)KsInitializeDriver, sizeof(KS_DRIVER_EXTENSION), (PVOID*)&DriverObjectExtension); if (NT_SUCCESS(Status)) { DriverObjectExtension->Descriptor = Descriptor; } } + /* sanity check */ + ASSERT(Status == STATUS_SUCCESS); + + if (!NT_SUCCESS(Status)) + return Status; + /* Setting our IRP handlers */ DriverObject->MajorFunction[IRP_MJ_CREATE] = IKsDevice_Create; DriverObject->MajorFunction[IRP_MJ_PNP] = IKsDevice_Pnp; @@ -168,7 +179,7 @@ KsInitializeDriver( DriverObject->DriverExtension->AddDevice = KsAddDevice; /* KS handles these */ - DPRINT1("Setting KS function handlers\n"); + DPRINT1("KsInitializeDriver Setting KS function handlers\n"); KsSetMajorFunctionHandler(DriverObject, IRP_MJ_CLOSE); KsSetMajorFunctionHandler(DriverObject, IRP_MJ_DEVICE_CONTROL); diff --git a/reactos/drivers/ksfilter/ks/filterfactory.c b/reactos/drivers/ksfilter/ks/filterfactory.c index 54e06b72b13..6d43d30d7a2 100644 --- a/reactos/drivers/ksfilter/ks/filterfactory.c +++ b/reactos/drivers/ksfilter/ks/filterfactory.c @@ -338,6 +338,8 @@ KspCreateFilterFactory( IKsFilterFactory * Filter; NTSTATUS Status; + DPRINT("KsCreateFilterFactory\n"); + /* Lets allocate a filterfactory */ This = AllocateItem(NonPagedPool, sizeof(IKsFilterFactoryImpl)); if (!This) @@ -465,7 +467,8 @@ KsFilterFactoryUpdateCacheData ( IN const KSFILTER_DESCRIPTOR* FilterDescriptor OPTIONAL) { UNIMPLEMENTED + DPRINT("KsFilterFactoryUpdateCacheData %p\n", FilterDescriptor); - return STATUS_NOT_IMPLEMENTED; + return STATUS_SUCCESS; } diff --git a/reactos/drivers/ksfilter/ks/kcom.c b/reactos/drivers/ksfilter/ks/kcom.c index 96d763aeb14..8921caf1268 100644 --- a/reactos/drivers/ksfilter/ks/kcom.c +++ b/reactos/drivers/ksfilter/ks/kcom.c @@ -9,7 +9,7 @@ #include "priv.h" -const GUID IID_IUnknown = {0x00000000, 0x0000, 0x0000, {0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}}; +const GUID IID_IUnknown = {0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x46}}; /* http://msdn2.microsoft.com/en-us/library/ms809781.aspx */ COMDDKAPI NTSTATUS NTAPI diff --git a/reactos/drivers/ksfilter/ks/kstypes.h b/reactos/drivers/ksfilter/ks/kstypes.h index a24464eec88..4bdc04c0bcb 100644 --- a/reactos/drivers/ksfilter/ks/kstypes.h +++ b/reactos/drivers/ksfilter/ks/kstypes.h @@ -103,7 +103,7 @@ typedef struct LIST_ENTRY TargetDeviceList; KMUTEX DeviceMutex; - KSDEVICE_DESCRIPTOR* Descriptor; + KMUTEX BagMutex; LIST_ENTRY PowerDispatchList; LIST_ENTRY ObjectBags; diff --git a/reactos/drivers/ksfilter/ks/misc.c b/reactos/drivers/ksfilter/ks/misc.c index 2e7782426d9..cc3d2cc9cca 100644 --- a/reactos/drivers/ksfilter/ks/misc.c +++ b/reactos/drivers/ksfilter/ks/misc.c @@ -70,7 +70,7 @@ KspForwardIrpSynchronous( IoSetCompletionRoutine(Irp, KspForwardIrpSynchronousCompletion, (PVOID)&Event, TRUE, TRUE, TRUE); /* now call the driver */ - Status = IoCallDriver(DeviceHeader->BaseDevice, Irp); + Status = IoCallDriver(DeviceHeader->KsDevice.NextDeviceObject, Irp); /* did the request complete yet */ if (Status == STATUS_PENDING) { From a22801fd63a4d64a9021fee8ae33293299bbe240 Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Wed, 31 Mar 2010 17:13:41 +0000 Subject: [PATCH 128/134] [PSDK] - Add KsFilterFactorySetDeviceClassesState prototype svn path=/trunk/; revision=46624 --- reactos/include/psdk/ks.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/reactos/include/psdk/ks.h b/reactos/include/psdk/ks.h index 2249af3711a..b7f055102db 100644 --- a/reactos/include/psdk/ks.h +++ b/reactos/include/psdk/ks.h @@ -4068,6 +4068,14 @@ KsCreateFilterFactory( IN PFNKSFILTERFACTORYPOWER WakeCallback OPTIONAL, OUT PKSFILTERFACTORY *FilterFactory OPTIONAL); +KSDDKAPI +NTSTATUS +NTAPI +KsFilterFactorySetDeviceClassesState( + IN PKSFILTERFACTORY FilterFactory, + IN BOOLEAN NewState + ); + KSDDKAPI NTSTATUS NTAPI From f33278167ebf81960df397186ca438cfee9419a3 Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Wed, 31 Mar 2010 17:33:49 +0000 Subject: [PATCH 129/134] [KS] - Enable registered device interfaces when device successfully initializes - Fix totally broken KsFilterFactorySetDeviceClassesState implementation svn path=/trunk/; revision=46625 --- reactos/drivers/ksfilter/ks/device.c | 2 ++ reactos/drivers/ksfilter/ks/deviceinterface.c | 33 +++++++++++++++++++ reactos/drivers/ksfilter/ks/filterfactory.c | 4 ++- reactos/drivers/ksfilter/ks/ksfunc.h | 12 +++++++ 4 files changed, 50 insertions(+), 1 deletion(-) diff --git a/reactos/drivers/ksfilter/ks/device.c b/reactos/drivers/ksfilter/ks/device.c index 7f2c082b440..345689f49b8 100644 --- a/reactos/drivers/ksfilter/ks/device.c +++ b/reactos/drivers/ksfilter/ks/device.c @@ -231,6 +231,7 @@ IKsDevice_PnpPostStart( { /* set state to enabled */ Ctx->DeviceHeader->TargetState = KSTARGET_STATE_ENABLED; + Status = KspSetFilterFactoriesState(Ctx->DeviceHeader, TRUE); } /* free work item */ @@ -376,6 +377,7 @@ IKsDevice_PnpStartDevice( { /* set state to enabled, IRP_MJ_CREATE request may now succeed */ DeviceHeader->TargetState = KSTARGET_STATE_ENABLED; + Status = KspSetFilterFactoriesState(DeviceHeader, TRUE); } } } diff --git a/reactos/drivers/ksfilter/ks/deviceinterface.c b/reactos/drivers/ksfilter/ks/deviceinterface.c index e7f6cf79344..b1e74cdfd26 100644 --- a/reactos/drivers/ksfilter/ks/deviceinterface.c +++ b/reactos/drivers/ksfilter/ks/deviceinterface.c @@ -17,6 +17,9 @@ KspSetDeviceInterfacesState( SymEntry = (PSYMBOLIC_LINK_ENTRY)CONTAINING_RECORD(Entry, SYMBOLIC_LINK_ENTRY, Entry); /* set device interface state */ Status = IoSetDeviceInterfaceState(&SymEntry->SymbolicLink, Enable); + + DPRINT("KspSetDeviceInterfacesState SymbolicLink %S Status %lx\n", SymEntry->SymbolicLink.Buffer, Status, Enable); + /* check for success */ if (!NT_SUCCESS(Status)) return Status; @@ -95,4 +98,34 @@ KspRegisterDeviceInterfaces( return Status; } +NTSTATUS +KspSetFilterFactoriesState( + IN PKSIDEVICE_HEADER DeviceHeader, + IN BOOLEAN NewState) +{ + PCREATE_ITEM_ENTRY CreateEntry; + PLIST_ENTRY Entry; + NTSTATUS Status = STATUS_SUCCESS; + /* grab first device interface */ + Entry = DeviceHeader->ItemList.Flink; + while(Entry != &DeviceHeader->ItemList && Status == STATUS_SUCCESS) + { + /* grab create entry */ + CreateEntry = CONTAINING_RECORD(Entry, CREATE_ITEM_ENTRY, Entry); + + /* sanity check */ + ASSERT(CreateEntry->CreateItem); + + if (CreateEntry->CreateItem->Create == IKsFilterFactory_Create) + { + /* found our own filterfactory */ + Status = KsFilterFactorySetDeviceClassesState((PKSFILTERFACTORY)CreateEntry->CreateItem->Context, NewState); + } + + Entry = Entry->Flink; + } + + /* store result */ + return Status; +} diff --git a/reactos/drivers/ksfilter/ks/filterfactory.c b/reactos/drivers/ksfilter/ks/filterfactory.c index 6d43d30d7a2..dc48f3c5c58 100644 --- a/reactos/drivers/ksfilter/ks/filterfactory.c +++ b/reactos/drivers/ksfilter/ks/filterfactory.c @@ -398,8 +398,10 @@ KsFilterFactorySetDeviceClassesState( IN PKSFILTERFACTORY FilterFactory, IN BOOLEAN NewState) { - IKsFilterFactory * Factory = (IKsFilterFactory*)CONTAINING_RECORD(FilterFactory, IKsFilterFactoryImpl, FilterFactory); + IKsFilterFactory * Factory; + IKsFilterFactoryImpl * This = (IKsFilterFactoryImpl*)CONTAINING_RECORD(FilterFactory, IKsFilterFactoryImpl, FilterFactory); + Factory = (IKsFilterFactory*)&This->lpVtbl; return Factory->lpVtbl->SetDeviceClassesState(Factory, NewState); } diff --git a/reactos/drivers/ksfilter/ks/ksfunc.h b/reactos/drivers/ksfilter/ks/ksfunc.h index 3395a94b0b6..8d0836af7d7 100644 --- a/reactos/drivers/ksfilter/ks/ksfunc.h +++ b/reactos/drivers/ksfilter/ks/ksfunc.h @@ -144,3 +144,15 @@ KspPropertyHandler( IN const KSPROPERTY_SET* PropertySet, IN PFNKSALLOCATOR Allocator OPTIONAL, IN ULONG PropertyItemSize OPTIONAL); + +NTSTATUS +NTAPI +IKsFilterFactory_Create( + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp); + +NTSTATUS +KspSetFilterFactoriesState( + IN PKSIDEVICE_HEADER DeviceHeader, + IN BOOLEAN NewState); + From abf91accdbd0474c1c232b6bf08e1cd9deda3d18 Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Wed, 31 Mar 2010 19:53:19 +0000 Subject: [PATCH 130/134] [NTOSKRNL] - Move subject context locking to SeAccessCheck because NtAccessCheck already locks it. - Do not use the captured security descriptor in NtAccessCheck yet, because SeCaptureSecurityDescriptor seems to create broken SDs. svn path=/trunk/; revision=46626 --- reactos/ntoskrnl/se/semgr.c | 82 +++++++++++-------------------------- 1 file changed, 24 insertions(+), 58 deletions(-) diff --git a/reactos/ntoskrnl/se/semgr.c b/reactos/ntoskrnl/se/semgr.c index c5ae5083a6d..6885cb7d4b8 100644 --- a/reactos/ntoskrnl/se/semgr.c +++ b/reactos/ntoskrnl/se/semgr.c @@ -355,7 +355,6 @@ SeSetSecurityAccessMask(IN SECURITY_INFORMATION SecurityInformation, BOOLEAN NTAPI SepAccessCheck(IN PSECURITY_DESCRIPTOR SecurityDescriptor, IN PSECURITY_SUBJECT_CONTEXT SubjectSecurityContext, - IN BOOLEAN SubjectContextLocked, IN ACCESS_MASK DesiredAccess, IN ACCESS_MASK PreviouslyGrantedAccess, OUT PPRIVILEGE_SET* Privileges, @@ -394,9 +393,6 @@ SepAccessCheck(IN PSECURITY_DESCRIPTOR SecurityDescriptor, return TRUE; } - /* Acquire the lock if needed */ - if (!SubjectContextLocked) SeLockSubjectContext(SubjectSecurityContext); - /* Map given accesses */ RtlMapGenericMask(&DesiredAccess, GenericMapping); if (PreviouslyGrantedAccess) @@ -418,11 +414,6 @@ SepAccessCheck(IN PSECURITY_DESCRIPTOR SecurityDescriptor, &Defaulted); if (!NT_SUCCESS(Status)) { - if (SubjectContextLocked == FALSE) - { - SeUnlockSubjectContext(SubjectSecurityContext); - } - *AccessStatus = Status; return FALSE; } @@ -430,11 +421,6 @@ SepAccessCheck(IN PSECURITY_DESCRIPTOR SecurityDescriptor, /* RULE 1: Grant desired access if the object is unprotected */ if (Present == FALSE || Dacl == NULL) { - if (SubjectContextLocked == FALSE) - { - SeUnlockSubjectContext(SubjectSecurityContext); - } - if (DesiredAccess & MAXIMUM_ALLOWED) { *GrantedAccess = GenericMapping->GenericAll; @@ -465,11 +451,6 @@ SepAccessCheck(IN PSECURITY_DESCRIPTOR SecurityDescriptor, if ((DesiredAccess & ~VALID_INHERIT_FLAGS) == (CurrentAccess & ~VALID_INHERIT_FLAGS)) { - if (SubjectContextLocked == FALSE) - { - SeUnlockSubjectContext(SubjectSecurityContext); - } - *GrantedAccess = CurrentAccess; *AccessStatus = STATUS_SUCCESS; return TRUE; @@ -483,11 +464,6 @@ SepAccessCheck(IN PSECURITY_DESCRIPTOR SecurityDescriptor, if (!NT_SUCCESS(Status)) { DPRINT1("RtlGetOwnerSecurityDescriptor() failed (Status %lx)\n", Status); - if (SubjectContextLocked == FALSE) - { - SeUnlockSubjectContext(SubjectSecurityContext); - } - *AccessStatus = Status; return FALSE; } @@ -498,11 +474,6 @@ SepAccessCheck(IN PSECURITY_DESCRIPTOR SecurityDescriptor, if ((DesiredAccess & ~VALID_INHERIT_FLAGS) == (CurrentAccess & ~VALID_INHERIT_FLAGS)) { - if (SubjectContextLocked == FALSE) - { - SeUnlockSubjectContext(SubjectSecurityContext); - } - *GrantedAccess = CurrentAccess; *AccessStatus = STATUS_SUCCESS; return TRUE; @@ -512,11 +483,6 @@ SepAccessCheck(IN PSECURITY_DESCRIPTOR SecurityDescriptor, /* Fail if DACL is absent */ if (Present == FALSE) { - if (SubjectContextLocked == FALSE) - { - SeUnlockSubjectContext(SubjectSecurityContext); - } - *GrantedAccess = 0; *AccessStatus = STATUS_ACCESS_DENIED; return FALSE; @@ -531,11 +497,6 @@ SepAccessCheck(IN PSECURITY_DESCRIPTOR SecurityDescriptor, { if (SepSidInToken(Token, Sid)) { - if (SubjectContextLocked == FALSE) - { - SeUnlockSubjectContext(SubjectSecurityContext); - } - *GrantedAccess = 0; *AccessStatus = STATUS_ACCESS_DENIED; return FALSE; @@ -558,11 +519,6 @@ SepAccessCheck(IN PSECURITY_DESCRIPTOR SecurityDescriptor, CurrentAce = (PACE)((ULONG_PTR)CurrentAce + CurrentAce->Header.AceSize); } - if (SubjectContextLocked == FALSE) - { - SeUnlockSubjectContext(SubjectSecurityContext); - } - DPRINT("CurrentAccess %08lx\n DesiredAccess %08lx\n", CurrentAccess, DesiredAccess); @@ -639,6 +595,8 @@ SeAccessCheck(IN PSECURITY_DESCRIPTOR SecurityDescriptor, OUT PACCESS_MASK GrantedAccess, OUT PNTSTATUS AccessStatus) { + BOOLEAN ret; + PAGED_CODE(); /* Check if this is kernel mode */ @@ -679,17 +637,26 @@ SeAccessCheck(IN PSECURITY_DESCRIPTOR SecurityDescriptor, return FALSE; } + /* Acquire the lock if needed */ + if (!SubjectContextLocked) + SeLockSubjectContext(SubjectSecurityContext); + /* Call the internal function */ - return SepAccessCheck(SecurityDescriptor, - SubjectSecurityContext, - SubjectContextLocked, - DesiredAccess, - PreviouslyGrantedAccess, - Privileges, - GenericMapping, - AccessMode, - GrantedAccess, - AccessStatus); + ret = SepAccessCheck(SecurityDescriptor, + SubjectSecurityContext, + DesiredAccess, + PreviouslyGrantedAccess, + Privileges, + GenericMapping, + AccessMode, + GrantedAccess, + AccessStatus); + + /* Release the lock if needed */ + if (!SubjectContextLocked) + SeUnlockSubjectContext(SubjectSecurityContext); + + return ret; } /* SYSTEM CALLS ***************************************************************/ @@ -808,8 +775,8 @@ NtAccessCheck(IN PSECURITY_DESCRIPTOR SecurityDescriptor, } /* Check security descriptor for valid owner and group */ - if (SepGetSDOwner(SecurityDescriptor)== NULL || - SepGetSDGroup(SecurityDescriptor) == NULL) + if (SepGetSDOwner(SecurityDescriptor) == NULL || // FIXME: use CapturedSecurityDescriptor + SepGetSDGroup(SecurityDescriptor) == NULL) // FIXME: use CapturedSecurityDescriptor { DPRINT("Security Descriptor does not have a valid group or owner\n"); SeReleaseSecurityDescriptor(CapturedSecurityDescriptor, @@ -827,9 +794,8 @@ NtAccessCheck(IN PSECURITY_DESCRIPTOR SecurityDescriptor, SeLockSubjectContext(&SubjectSecurityContext); /* Now perform the access check */ - SepAccessCheck(CapturedSecurityDescriptor, + SepAccessCheck(SecurityDescriptor, // FIXME: use CapturedSecurityDescriptor &SubjectSecurityContext, - TRUE, DesiredAccess, 0, &PrivilegeSet, //FIXME From 44c2da0137fb7c2bed66b701c051bf543d82fd29 Mon Sep 17 00:00:00 2001 From: Sir Richard Date: Wed, 31 Mar 2010 20:54:22 +0000 Subject: [PATCH 131/134] [NDK]: Add missing Io functions. svn path=/trunk/; revision=46627 --- reactos/include/ndk/iofuncs.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/reactos/include/ndk/iofuncs.h b/reactos/include/ndk/iofuncs.h index 06648fd596c..2aab3a1a798 100644 --- a/reactos/include/ndk/iofuncs.h +++ b/reactos/include/ndk/iofuncs.h @@ -44,6 +44,22 @@ IoSynchronousInvalidateDeviceRelations( IN PDEVICE_OBJECT DeviceObject, IN DEVICE_RELATION_TYPE Type ); + +NTSTATUS +NTAPI +IoCreateDriver( + IN PUNICODE_STRING DriverName OPTIONAL, + IN PDRIVER_INITIALIZE InitializationFunction +); + +NTSTATUS +NTAPI +IoReportHalResourceUsage( + IN PUNICODE_STRING HalName, + IN PCM_RESOURCE_LIST RawResourceList, + IN PCM_RESOURCE_LIST TranslatedResourceList, + IN ULONG ResourceListSize +); #endif // From 9e478e990f8c139ee4d56ec7dece26a340c0981e Mon Sep 17 00:00:00 2001 From: Sir Richard Date: Wed, 31 Mar 2010 20:58:42 +0000 Subject: [PATCH 132/134] [HALACPI]: Begin rough implementation of the Hal ACPI PnP Driver. Will probably need some changes to the ReactOS PnP Manager to work properly (it is not initialized yet). [HAL]: Implement helper registry routine. [HAL]: Implement function to set ACPI mode the "Windows way", which is to enable/disable the firmware mapper. PnP Manager should probably check this in the future. svn path=/trunk/; revision=46628 --- reactos/hal/halx86/generic/acpi/halpnpdd.c | 817 +++++++++++++++++++++ reactos/hal/halx86/generic/misc.c | 41 ++ reactos/hal/halx86/hal_generic.rbuild | 1 + reactos/hal/halx86/include/halacpi.h | 7 + reactos/hal/halx86/include/halp.h | 10 + 5 files changed, 876 insertions(+) create mode 100644 reactos/hal/halx86/generic/acpi/halpnpdd.c diff --git a/reactos/hal/halx86/generic/acpi/halpnpdd.c b/reactos/hal/halx86/generic/acpi/halpnpdd.c new file mode 100644 index 00000000000..81bed5539c9 --- /dev/null +++ b/reactos/hal/halx86/generic/acpi/halpnpdd.c @@ -0,0 +1,817 @@ +/* + * PROJECT: ReactOS HAL + * LICENSE: BSD - See COPYING.ARM in the top level directory + * FILE: hal/halx86/generic/acpi/halpnpdd.c + * PURPOSE: HAL Plug and Play Device Driver + * PROGRAMMERS: ReactOS Portable Systems Group + */ + +/* INCLUDES *******************************************************************/ + +#include +#define NDEBUG +#include + +typedef enum _EXTENSION_TYPE +{ + PdoExtensionType = 0xC0, + FdoExtensionType +} EXTENSION_TYPE; + +typedef enum _PDO_TYPE +{ + AcpiPdo = 0x80, + WdPdo +} PDO_TYPE; + +typedef struct _FDO_EXTENSION +{ + EXTENSION_TYPE ExtensionType; + struct _PDO_EXTENSION* ChildPdoList; + PDEVICE_OBJECT PhysicalDeviceObject; + PDEVICE_OBJECT FunctionalDeviceObject; + PDEVICE_OBJECT AttachedDeviceObject; +} FDO_EXTENSION, *PFDO_EXTENSION; + +typedef struct _PDO_EXTENSION +{ + EXTENSION_TYPE ExtensionType; + struct _PDO_EXTENSION* Next; + PDEVICE_OBJECT PhysicalDeviceObject; + PFDO_EXTENSION ParentFdoExtension; + PDO_TYPE PdoType; + PDESCRIPTION_HEADER WdTable; + LONG InterfaceReferenceCount; +} PDO_EXTENSION, *PPDO_EXTENSION; + +/* GLOBALS ********************************************************************/ + +PDRIVER_OBJECT HalpDriverObject; +BOOLEAN HalDisableFirmwareMapper = TRUE; +PWCHAR HalHardwareIdString = L"acpipic_up"; + +/* PRIVATE FUNCTIONS **********************************************************/ + +NTSTATUS +NTAPI +HalpMarkAcpiHal(VOID) +{ + NTSTATUS Status; + UNICODE_STRING KeyString; + HANDLE KeyHandle; + HANDLE Handle; + + /* Open the control set key */ + RtlInitUnicodeString(&KeyString, + L"\\REGISTRY\\MACHINE\\SYSTEM\\CURRENTCONTROLSET"); + Status = HalpOpenRegistryKey(&Handle, 0, &KeyString, KEY_ALL_ACCESS, FALSE); + if (NT_SUCCESS(Status)) + { + /* Open the PNP key */ + RtlInitUnicodeString(&KeyString, L"Control\\Pnp"); + Status = HalpOpenRegistryKey(&KeyHandle, + Handle, + &KeyString, + KEY_ALL_ACCESS, + TRUE); + /* Close root key */ + ZwClose(Handle); + + /* Check if PNP BIOS key exists */ + if (NT_SUCCESS(Status)) + { + /* Set the disable value to false -- we need the mapper */ + RtlInitUnicodeString(&KeyString, L"DisableFirmwareMapper"); + Status = ZwSetValueKey(KeyHandle, + &KeyString, + 0, + REG_DWORD, + &HalDisableFirmwareMapper, + sizeof(HalDisableFirmwareMapper)); + + /* Close subkey */ + ZwClose(KeyHandle); + } + } + + /* Return status */ + return Status; +} + +NTSTATUS +NTAPI +HalpAddDevice(IN PDRIVER_OBJECT DriverObject, + IN PDEVICE_OBJECT TargetDevice) +{ + NTSTATUS Status; + PFDO_EXTENSION FdoExtension; + PPDO_EXTENSION PdoExtension; + PDEVICE_OBJECT DeviceObject, PdoDeviceObject, AttachedDevice; + PDESCRIPTION_HEADER Wdrt; + DbgPrint("HAL: PnP Driver ADD!\n"); + + /* Create the FDO */ + Status = IoCreateDevice(DriverObject, + sizeof(FDO_EXTENSION), + NULL, + FILE_DEVICE_BUS_EXTENDER, + 0, + FALSE, + &DeviceObject); + if (!NT_SUCCESS(Status)) + { + /* Should not happen */ + DbgBreakPoint(); + return Status; + } + + /* Setup the FDO extension */ + FdoExtension = DeviceObject->DeviceExtension; + FdoExtension->ExtensionType = FdoExtensionType; + FdoExtension->PhysicalDeviceObject = TargetDevice; + FdoExtension->FunctionalDeviceObject = DeviceObject; + + /* FDO is done initializing */ + DeviceObject->Flags &= DO_DEVICE_INITIALIZING; + + /* Attach to the physical device object (the bus) */ + AttachedDevice = IoAttachDeviceToDeviceStack(DeviceObject, TargetDevice); + if (!AttachedDevice) + { + /* Failed, undo everything */ + IoDeleteDevice(DeviceObject); + return STATUS_NO_SUCH_DEVICE; + } + + /* Save the attachment */ + FdoExtension->AttachedDeviceObject = AttachedDevice; + + /* Create the PDO */ + Status = IoCreateDevice(DriverObject, + sizeof(PDO_EXTENSION), + NULL, + FILE_DEVICE_BUS_EXTENDER, + FILE_AUTOGENERATED_DEVICE_NAME, + FALSE, + &PdoDeviceObject); + if (!NT_SUCCESS(Status)) + { + /* Fail */ + DbgPrint("HAL: Could not create ACPI device object status=0x%08x\n", Status); + return Status; + } + + /* Setup the PDO device extension */ + PdoExtension = PdoDeviceObject->DeviceExtension; + PdoExtension->Next = NULL; + PdoExtension->ExtensionType = PdoExtensionType; + PdoExtension->PhysicalDeviceObject = PdoDeviceObject; + PdoExtension->ParentFdoExtension = FdoExtension; + PdoExtension->PdoType = AcpiPdo; + + /* Find the ACPI watchdog table */ + Wdrt = HalAcpiGetTable(0, 'TRDW'); + if (!Wdrt) + { + /* None exists, there is nothing to do more */ + PdoDeviceObject->Flags &= DO_DEVICE_INITIALIZING; + FdoExtension->ChildPdoList = PdoExtension; + } + else + { + /* FIXME: TODO */ + DPRINT1("You have an ACPI Watchdog. That's great! You should be proud ;-)\n"); + PdoDeviceObject->Flags &= DO_DEVICE_INITIALIZING; + FdoExtension->ChildPdoList = PdoExtension; + } + + /* Return status */ + DPRINT1("Device added %lx\n", Status); + return Status; +} + +NTSTATUS +NTAPI +HalpQueryInterface(IN PDEVICE_OBJECT DeviceObject, + IN CONST GUID* InterfaceType, + IN USHORT Version, + IN PVOID InterfaceSpecificData, + IN ULONG InterfaceBufferSize, + IN PINTERFACE Interface, + OUT PULONG Length) +{ + UNIMPLEMENTED; + while (TRUE); + return STATUS_NO_SUCH_DEVICE; +} + +NTSTATUS +NTAPI +HalpQueryDeviceRelations(IN PDEVICE_OBJECT DeviceObject, + IN DEVICE_RELATION_TYPE RelationType, + OUT PDEVICE_RELATIONS* DeviceRelations) +{ + EXTENSION_TYPE ExtensionType; + PPDO_EXTENSION PdoExtension; + PFDO_EXTENSION FdoExtension; + PDEVICE_RELATIONS PdoRelations, FdoRelations; + PDEVICE_OBJECT* ObjectEntry; + ULONG i = 0, PdoCount = 0; + + /* Get FDO device extension and PDO count */ + FdoExtension = DeviceObject->DeviceExtension; + ExtensionType = FdoExtension->ExtensionType; + + /* What do they want? */ + if (RelationType == BusRelations) + { + /* This better be an FDO */ + if (ExtensionType == FdoExtensionType) + { + /* Count how many PDOs we have */ + PdoExtension = FdoExtension->ChildPdoList; + while (PdoExtension) + { + /* Next one */ + PdoExtension = PdoExtension->Next; + PdoCount++; + } + + /* Allocate our structure */ + FdoRelations = ExAllocatePoolWithTag(PagedPool, + FIELD_OFFSET(DEVICE_RELATIONS, + Objects) + + 4 * PdoCount, + ' laH'); + if (!FdoRelations) return STATUS_INSUFFICIENT_RESOURCES; + + /* Save our count */ + FdoRelations->Count = PdoCount; + + /* Query existing relations */ + ObjectEntry = FdoRelations->Objects; + if (*DeviceRelations) + { + /* Check if there were any */ + if ((*DeviceRelations)->Count) + { + /* Loop them all */ + do + { + /* Copy into our structure */ + *ObjectEntry++ = (*DeviceRelations)->Objects[i]; + } + while (++i < (*DeviceRelations)->Count); + } + + /* Free existing structure */ + ExFreePoolWithTag(*DeviceRelations, 0); + } + + /* Now check if we have a PDO list */ + PdoExtension = FdoExtension->ChildPdoList; + if (PdoExtension) + { + /* Loop the PDOs */ + do + { + /* Save our own PDO and reference it */ + *ObjectEntry++ = PdoExtension->PhysicalDeviceObject; + ObfReferenceObject(PdoExtension->PhysicalDeviceObject); + + /* Go to our next PDO */ + PdoExtension = PdoExtension->Next; + } + while (PdoExtension); + } + + /* Return the new structure */ + *DeviceRelations = FdoRelations; + return STATUS_SUCCESS; + } + } + else + { + /* The only other thing we support is a target relation for the PDO */ + if ((RelationType == TargetDeviceRelation) && + (ExtensionType == PdoExtensionType)) + { + /* Only one entry */ + PdoRelations = ExAllocatePoolWithTag(PagedPool, + sizeof(DEVICE_RELATIONS), + ' laH'); + if (!PdoRelations) return STATUS_INSUFFICIENT_RESOURCES; + + /* Fill it out and reference us */ + PdoRelations->Count = 1; + PdoRelations->Objects[0] = DeviceObject; + ObfReferenceObject(DeviceObject); + + /* Return it */ + *DeviceRelations = PdoRelations; + return STATUS_SUCCESS; + } + } + + /* We don't support anything else */ + return STATUS_NOT_SUPPORTED; +} + +NTSTATUS +NTAPI +HalpQueryCapabilities(IN PDEVICE_OBJECT DeviceObject, + OUT PDEVICE_CAPABILITIES Capabilities) +{ + PPDO_EXTENSION PdoExtension; + NTSTATUS Status; + PAGED_CODE(); + + /* Get the extension and check for valid version */ + PdoExtension = DeviceObject->DeviceExtension; + ASSERT(Capabilities->Version == 1); + if (Capabilities->Version == 1) + { + /* Can't lock or eject us */ + Capabilities->LockSupported = FALSE; + Capabilities->EjectSupported = FALSE; + + /* Can't remove or dock us */ + Capabilities->Removable = FALSE; + Capabilities->DockDevice = FALSE; + + /* Can't access us raw */ + Capabilities->RawDeviceOK = FALSE; + + /* We have a unique ID, and don't bother the user */ + Capabilities->UniqueID = TRUE; + Capabilities->SilentInstall = TRUE; + + /* Fill out the adress */ + Capabilities->Address = InterfaceTypeUndefined; + Capabilities->UINumber = InterfaceTypeUndefined; + + /* Fill out latencies */ + Capabilities->D1Latency = 0; + Capabilities->D2Latency = 0; + Capabilities->D3Latency = 0; + + /* Fill out supported device states */ + Capabilities->DeviceState[PowerSystemWorking] = PowerDeviceD0; + Capabilities->DeviceState[PowerSystemHibernate] = PowerDeviceD3; + Capabilities->DeviceState[PowerSystemShutdown] = PowerDeviceD3; + Capabilities->DeviceState[PowerSystemSleeping3] = PowerDeviceD3; + + /* Done */ + Status = STATUS_SUCCESS; + } + else + { + /* Fail */ + Status = STATUS_NOT_SUPPORTED; + } + + /* Return status */ + return Status; +} + +NTSTATUS +NTAPI +HalpQueryResources(IN PDEVICE_OBJECT DeviceObject, + OUT PCM_RESOURCE_LIST *Resources) +{ + UNIMPLEMENTED; + while (TRUE); + return STATUS_NO_SUCH_DEVICE; +} + +NTSTATUS +NTAPI +HalpQueryResourceRequirements(IN PDEVICE_OBJECT DeviceObject, + OUT PIO_RESOURCE_REQUIREMENTS_LIST *Requirements) +{ + UNIMPLEMENTED; + while (TRUE); + return STATUS_NO_SUCH_DEVICE; +} + +NTSTATUS +NTAPI +HalpQueryIdPdo(IN PDEVICE_OBJECT DeviceObject, + IN BUS_QUERY_ID_TYPE IdType, + OUT PUSHORT *BusQueryId) +{ + PPDO_EXTENSION PdoExtension; + PDO_TYPE PdoType; + PWCHAR Id; + NTSTATUS Status; + ULONG Length; + PWCHAR Buffer; + + /* Get the PDO type */ + PdoExtension = DeviceObject->DeviceExtension; + PdoType = PdoExtension->PdoType; + + /* What kind of ID is being requested? */ + DPRINT("ID: %d\n", IdType); + switch (IdType) + { + case BusQueryDeviceID: + case BusQueryHardwareIDs: + + /* What kind of PDO is this? */ + if (PdoType == AcpiPdo) + { + /* PCI ID */ + Id = L"ACPI_HAL\\PNP0C08"; + } + else if (PdoType == WdPdo) + { + /* WatchDog ID */ + Id = L"ACPI_HAL\\PNP0C18"; + } + else + { + /* Unknown */ + return STATUS_NOT_SUPPORTED; + } + + /* Static length */ + Length = 32; + break; + + case BusQueryInstanceID: + + /* And our instance ID */ + Id = L"0"; + Length = sizeof(L"0") + sizeof(UNICODE_NULL); + break; + + case BusQueryCompatibleIDs: + default: + + /* We don't support anything else */ + return STATUS_NOT_SUPPORTED; + } + + /* Allocate the buffer */ + Buffer = ExAllocatePoolWithTag(PagedPool, + Length + sizeof(UNICODE_NULL), + ' laH'); + if (Buffer) + { + /* Copy the string and null-terminate it */ + RtlCopyMemory(Buffer, Id, Length); + Buffer[Length / sizeof(WCHAR)] = UNICODE_NULL; + + /* Return string */ + *BusQueryId = Buffer; + Status = STATUS_SUCCESS; + DPRINT("Returning: %S\n", *BusQueryId); + } + else + { + /* Fail */ + Status = STATUS_INSUFFICIENT_RESOURCES; + } + + /* Return status */ + return Status; +} + +NTSTATUS +NTAPI +HalpQueryIdFdo(IN PDEVICE_OBJECT DeviceObject, + IN BUS_QUERY_ID_TYPE IdType, + OUT PUSHORT *BusQueryId) +{ + NTSTATUS Status; + ULONG Length; + PWCHAR Id; + PWCHAR Buffer; + + /* What kind of ID is being requested? */ + DPRINT("ID: %d\n", IdType); + switch (IdType) + { + case BusQueryDeviceID: + case BusQueryHardwareIDs: + + /* This is our hardware ID */ + Id = HalHardwareIdString; + Length = wcslen(HalHardwareIdString) + sizeof(UNICODE_NULL); + break; + + case BusQueryInstanceID: + + /* And our instance ID */ + Id = L"0"; + Length = sizeof(L"0") + sizeof(UNICODE_NULL); + break; + + default: + + /* We don't support anything else */ + return STATUS_NOT_SUPPORTED; + } + + /* Allocate the buffer */ + Buffer = ExAllocatePoolWithTag(PagedPool, + Length + sizeof(UNICODE_NULL), + ' laH'); + if (Buffer) + { + /* Copy the string and null-terminate it */ + RtlCopyMemory(Buffer, Id, Length); + Buffer[Length / sizeof(WCHAR)] = UNICODE_NULL; + + /* Return string */ + *BusQueryId = Buffer; + Status = STATUS_SUCCESS; + DPRINT("Returning: %S\n", *BusQueryId); + } + else + { + /* Fail */ + Status = STATUS_INSUFFICIENT_RESOURCES; + } + + /* Return status */ + return Status; +} + +NTSTATUS +NTAPI +HalpPassIrpFromFdoToPdo(IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp) +{ + PFDO_EXTENSION FdoExtension; + + /* Get the extension */ + FdoExtension = DeviceObject->DeviceExtension; + + /* Pass it to the attached device (our PDO) */ + IoSkipCurrentIrpStackLocation(Irp); + return IoCallDriver(FdoExtension->AttachedDeviceObject, Irp); +} + +NTSTATUS +NTAPI +HalpDispatchPnp(IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp) +{ + PIO_STACK_LOCATION IoStackLocation; + PPDO_EXTENSION PdoExtension; + PFDO_EXTENSION FdoExtension; + NTSTATUS Status; + UCHAR Minor; + + /* Get the device extension and stack location */ + FdoExtension = DeviceObject->DeviceExtension; + IoStackLocation = IoGetCurrentIrpStackLocation(Irp); + Minor = IoStackLocation->MinorFunction; + + /* FDO? */ + if (FdoExtension->ExtensionType == FdoExtensionType) + { + /* Query the IRP type */ + switch (Minor) + { + case IRP_MN_QUERY_DEVICE_RELATIONS: + + /* Call the worker */ + DPRINT("Querying device relations for FDO\n"); + Status = HalpQueryDeviceRelations(DeviceObject, + IoStackLocation->Parameters.QueryDeviceRelations.Type, + (PVOID)&Irp->IoStatus.Information); + break; + + case IRP_MN_QUERY_INTERFACE: + + /* Call the worker */ + DPRINT("Querying interface for FDO\n"); + Status = HalpQueryInterface(DeviceObject, + IoStackLocation->Parameters.QueryInterface.InterfaceType, + IoStackLocation->Parameters.QueryInterface.Size, + IoStackLocation->Parameters.QueryInterface.InterfaceSpecificData, + IoStackLocation->Parameters.QueryInterface.Version, + IoStackLocation->Parameters.QueryInterface.Interface, + (PVOID)&Irp->IoStatus.Information); + break; + + + case IRP_MN_QUERY_ID: + + /* Call the worker */ + DPRINT("Querying ID for FDO\n"); + Status = HalpQueryIdFdo(DeviceObject, + IoStackLocation->Parameters.QueryId.IdType, + (PVOID)&Irp->IoStatus.Information); + break; + + default: + + /* Pass it to the PDO */ + DPRINT("Other IRP: %lx\n", Minor); + return HalpPassIrpFromFdoToPdo(DeviceObject, Irp); + } + + /* What happpened? */ + if ((NT_SUCCESS(Status)) || (Status == STATUS_NOT_SUPPORTED)) + { + /* Set the IRP status, unless this isn't understood */ + if (Status != STATUS_NOT_SUPPORTED) Irp->IoStatus.Status = Status; + + /* Pass it on */ + DPRINT("Passing IRP to PDO\n"); + return HalpPassIrpFromFdoToPdo(DeviceObject, Irp); + } + + /* Otherwise, we failed, so set the status and complete the request */ + DPRINT1("IRP failed with status: %lx\n", Status); + Irp->IoStatus.Status = Status; + IoCompleteRequest(Irp, IO_NO_INCREMENT); + return Status; + } + else + { + /* This is a PDO instead */ + ASSERT(FdoExtension->ExtensionType == PdoExtensionType); + PdoExtension = (PPDO_EXTENSION)FdoExtension; + + /* Query the IRP type */ + Status = STATUS_SUCCESS; + switch (Minor) + { + case IRP_MN_START_DEVICE: + + /* We only care about a PCI PDO */ + DPRINT1("Start device received\n"); + /* Complete the IRP normally */ + break; + + case IRP_MN_REMOVE_DEVICE: + + /* Check if this is a PCI device */ + DPRINT1("Remove device received\n"); + + /* We're done */ + Status = STATUS_SUCCESS; + break; + + case IRP_MN_SURPRISE_REMOVAL: + + /* Inherit whatever status we had */ + DPRINT1("Surprise removal IRP\n"); + Status = Irp->IoStatus.Status; + break; + + case IRP_MN_QUERY_DEVICE_RELATIONS: + + /* Query the device relations */ + DPRINT("Querying PDO relations\n"); + Status = HalpQueryDeviceRelations(DeviceObject, + IoStackLocation->Parameters.QueryDeviceRelations.Type, + (PVOID)&Irp->IoStatus.Information); + break; + + case IRP_MN_QUERY_INTERFACE: + + /* Call the worker */ + DPRINT("Querying interface for PDO\n"); + Status = HalpQueryInterface(DeviceObject, + IoStackLocation->Parameters.QueryInterface.InterfaceType, + IoStackLocation->Parameters.QueryInterface.Size, + IoStackLocation->Parameters.QueryInterface.InterfaceSpecificData, + IoStackLocation->Parameters.QueryInterface.Version, + IoStackLocation->Parameters.QueryInterface.Interface, + (PVOID)&Irp->IoStatus.Information); + break; + + case IRP_MN_QUERY_CAPABILITIES: + + /* Call the worker */ + DPRINT("Querying the capabilities for the PDO\n"); + Status = HalpQueryCapabilities(DeviceObject, + IoStackLocation->Parameters.DeviceCapabilities.Capabilities); + break; + + case IRP_MN_QUERY_RESOURCES: + + /* Call the worker */ + DPRINT("Querying the resources for the PDO\n"); + Status = HalpQueryResources(DeviceObject, (PVOID)&Irp->IoStatus.Information); + break; + + case IRP_MN_QUERY_RESOURCE_REQUIREMENTS: + + /* Call the worker */ + DPRINT("Querying the resource requirements for the PDO\n"); + Status = HalpQueryResourceRequirements(DeviceObject, + (PVOID)&Irp->IoStatus.Information); + break; + + case IRP_MN_QUERY_ID: + + /* Call the worker */ + DPRINT("Query the ID for the PDO\n"); + Status = HalpQueryIdPdo(DeviceObject, + IoStackLocation->Parameters.QueryId.IdType, + (PVOID)&Irp->IoStatus.Information); + break; + + default: + + /* We don't handle anything else, so inherit the old state */ + DPRINT("Illegal IRP: %lx\n", Minor); + Status = Irp->IoStatus.Status; + break; + } + + /* If it's not supported, inherit the old status */ + if (Status == STATUS_NOT_SUPPORTED) Status = Irp->IoStatus.Status; + + /* Complete the IRP */ + DPRINT("IRP completed with status: %lx\n", Status); + Irp->IoStatus.Status = Status; + IoCompleteRequest(Irp, IO_NO_INCREMENT); + return Status; + } +} + +NTSTATUS +NTAPI +HalpDispatchWmi(IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp) +{ + DbgPrint("HAL: PnP Driver WMI!\n"); + while (TRUE); + return STATUS_SUCCESS; +} + +NTSTATUS +NTAPI +HalpDispatchPower(IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp) +{ + DbgPrint("HAL: PnP Driver Power!\n"); + while (TRUE); + return STATUS_SUCCESS; +} + +NTSTATUS +NTAPI +HalpDriverEntry(IN PDRIVER_OBJECT DriverObject, + IN PUNICODE_STRING RegistryPath) +{ + NTSTATUS Status; + PDEVICE_OBJECT TargetDevice = NULL; + DPRINT("HAL: PnP Driver ENTRY!\n"); + + /* This is us */ + HalpDriverObject = DriverObject; + + /* Set up add device */ + DriverObject->DriverExtension->AddDevice = HalpAddDevice; + + /* Set up the callouts */ + DriverObject->MajorFunction[IRP_MJ_PNP] = HalpDispatchPnp; + DriverObject->MajorFunction[IRP_MJ_POWER] = HalpDispatchPower; + DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = HalpDispatchWmi; + + /* Tell the PnP about us */ + Status = IoReportDetectedDevice(DriverObject, + InterfaceTypeUndefined, + -1, + -1, + NULL, + NULL, + FALSE, + &TargetDevice); + + /* Now add us */ + if (NT_SUCCESS(Status)) Status = HalpAddDevice(DriverObject, TargetDevice); + + /* Force re-enumeration??? */ + IoInvalidateDeviceRelations(TargetDevice, 0); + + /* Return to kernel */ + return Status; +} + +NTSTATUS +NTAPI +HaliInitPnpDriver(VOID) +{ + NTSTATUS Status; + UNICODE_STRING DriverString; + PAGED_CODE(); + + /* Create the driver */ + RtlInitUnicodeString(&DriverString, L"\\Driver\\ACPI_HAL"); + Status = IoCreateDriver(&DriverString, HalpDriverEntry); + + /* Return status */ + return Status; +} + +/* EOF */ diff --git a/reactos/hal/halx86/generic/misc.c b/reactos/hal/halx86/generic/misc.c index f778b172d3e..00ea13bd0d8 100644 --- a/reactos/hal/halx86/generic/misc.c +++ b/reactos/hal/halx86/generic/misc.c @@ -18,6 +18,47 @@ BOOLEAN HalpNMIInProgress; /* PRIVATE FUNCTIONS **********************************************************/ +NTSTATUS +NTAPI +HalpOpenRegistryKey(IN PHANDLE KeyHandle, + IN HANDLE RootKey, + IN PUNICODE_STRING KeyName, + IN ACCESS_MASK DesiredAccess, + IN BOOLEAN Create) +{ + NTSTATUS Status; + ULONG Disposition; + OBJECT_ATTRIBUTES ObjectAttributes; + + /* Setup the attributes we received */ + InitializeObjectAttributes(&ObjectAttributes, + KeyName, + OBJ_CASE_INSENSITIVE, + RootKey, + NULL); + + /* What to do? */ + if ( Create ) + { + /* Create the key */ + Status = ZwCreateKey(KeyHandle, + DesiredAccess, + &ObjectAttributes, + 0, + NULL, + REG_OPTION_VOLATILE, + &Disposition); + } + else + { + /* Open the key */ + Status = ZwOpenKey(KeyHandle, DesiredAccess, &ObjectAttributes); + } + + /* We're done */ + return Status; +} + VOID NTAPI HalpCheckPowerButton(VOID) diff --git a/reactos/hal/halx86/hal_generic.rbuild b/reactos/hal/halx86/hal_generic.rbuild index d8f8fa2068f..dccd1615c62 100644 --- a/reactos/hal/halx86/hal_generic.rbuild +++ b/reactos/hal/halx86/hal_generic.rbuild @@ -58,6 +58,7 @@ halacpi.c + halpnpdd.c bushndlr.c diff --git a/reactos/hal/halx86/include/halacpi.h b/reactos/hal/halx86/include/halacpi.h index aa342ab9215..1b4e16bf37d 100644 --- a/reactos/hal/halx86/include/halacpi.h +++ b/reactos/hal/halx86/include/halacpi.h @@ -227,4 +227,11 @@ HalpSetupAcpiPhase0( IN PLOADER_PARAMETER_BLOCK LoaderBlock ); +PVOID +NTAPI +HalAcpiGetTable( + IN PLOADER_PARAMETER_BLOCK LoaderBlock, + IN ULONG Signature +); + /* EOF */ diff --git a/reactos/hal/halx86/include/halp.h b/reactos/hal/halx86/include/halp.h index 6ded9513258..44b81a08791 100644 --- a/reactos/hal/halx86/include/halp.h +++ b/reactos/hal/halx86/include/halp.h @@ -697,6 +697,16 @@ HalpMapPhysicalMemory64( IN ULONG PageCount ); +NTSTATUS +NTAPI +HalpOpenRegistryKey( + IN PHANDLE KeyHandle, + IN HANDLE RootKey, + IN PUNICODE_STRING KeyName, + IN ACCESS_MASK DesiredAccess, + IN BOOLEAN Create +); + VOID FASTCALL KeUpdateSystemTime( From baeb2951340c80b0bb2d18ba0af0891c55f820f4 Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Wed, 31 Mar 2010 21:02:38 +0000 Subject: [PATCH 133/134] [NTORKRNL] SepAccessCheck: Deny access if the DACL is is empty (but not NULL). svn path=/trunk/; revision=46629 --- reactos/ntoskrnl/se/semgr.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/reactos/ntoskrnl/se/semgr.c b/reactos/ntoskrnl/se/semgr.c index 6885cb7d4b8..d06fb04bbb6 100644 --- a/reactos/ntoskrnl/se/semgr.c +++ b/reactos/ntoskrnl/se/semgr.c @@ -457,6 +457,14 @@ SepAccessCheck(IN PSECURITY_DESCRIPTOR SecurityDescriptor, } } + /* Deny access if the DACL is empty */ + if (Dacl->AceCount == 0) + { + *GrantedAccess = 0; + *AccessStatus = STATUS_ACCESS_DENIED; + return FALSE; + } + /* RULE 3: Check whether the token is the owner */ Status = RtlGetOwnerSecurityDescriptor(SecurityDescriptor, &Sid, From f8ed547043c41f580e8447cb05ba2a99d45d7a1d Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Thu, 1 Apr 2010 00:41:09 +0000 Subject: [PATCH 134/134] [PSDK] - Fix _KSNODE_DESCRIPTOR definition svn path=/trunk/; revision=46631 --- reactos/include/psdk/ks.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/reactos/include/psdk/ks.h b/reactos/include/psdk/ks.h index b7f055102db..f728bfb0f78 100644 --- a/reactos/include/psdk/ks.h +++ b/reactos/include/psdk/ks.h @@ -2987,6 +2987,9 @@ struct _KSNODE_DESCRIPTOR const KSAUTOMATION_TABLE* AutomationTable; const GUID* Type; const GUID* Name; +#if !defined(_WIN64) + PVOID Alignment; +#endif }; struct _KSFILTER_DESCRIPTOR